diff --git a/src/grammar.y b/src/grammar.y index b793fb0..a412fd6 100644 --- a/src/grammar.y +++ b/src/grammar.y @@ -566,10 +566,17 @@ compound_statement: emit_label(label_gen()); emit_backpatch(S_Pop(TrueList), getLabel(current)); } sblock ELSE { + // NOTE we are not going back to + int l = label_gen(); + emit_backpatch(S_Pop(FalseList), l); + S_Push(FalseList, S_Init(), 0); + emit_goto(0); + S_Push(S_Peek(FalseList), current, 1); + emit_label(l); + } sblock { int l = label_gen(); emit_backpatch(S_Pop(FalseList), l); emit_label(l); - } sblock { if ($8 == undefined && $11 != undefined) { $$ = $11; } else if ($8 != undefined && $11 == undefined) { @@ -681,16 +688,18 @@ ablock: argument_list: expression{ TableNode* arg = CreateEntry(cur, getAdInfoType((TableNode*)$1), getTypeEntry((TableNode*)$1), arg_var_gen(), NULL); - // this emits params for function and arrays TODO: fix +// ---------------------------------------------------------------------------- + // this is emitting the param withthe wrong TableNode + // We need to fiture out how to get the right one. Stack * t = S_Peek(stack); if(t==NULL){ t = S_Init(); S_Push(stack, t, 1); } - emit_parameter(tn_or_const(NODE,arg)); + emit_parameter(tn_or_const(NODE,$1)); S_Push(t, current, 1); emit_detach(); - //printdebug("[ARGUMENT_LIST] argument list is %d", $$); +// ---------------------------------------------------------------------------- } COMMA argument_list {$$ = $4 + 1;} @@ -699,7 +708,7 @@ argument_list: { TableNode* arg = CreateEntry(cur, getAdInfoType((TableNode*)$1), getTypeEntry((TableNode*)$1), arg_var_gen(), NULL); - emit_parameter(tn_or_const(NODE,arg)); + emit_parameter(tn_or_const(NODE,$1)); $$ = 1; printdebug("[ARGUMENT_LIST] argument list is %d", $$); } diff --git a/tests/sprint3/test/sp3_if_else.alpha b/tests/sprint3/test/sp3_if_else.alpha index efb6d69..422da89 100644 --- a/tests/sprint3/test/sp3_if_else.alpha +++ b/tests/sprint3/test/sp3_if_else.alpha @@ -13,14 +13,13 @@ bar (r,s) := { entry (arg) := { [ integer: result ; rec: w] if ( result = result ) then { - result := result + 8; - if ( result < w.y ) then { + if ( result < w.y ) then { result := 8; } else { result := 9; - } + }(* *) } else { - result := bar('c', 7); + result := 1; (* bar('c', 7); *) } return 0; }