Fixed the else jump It was falling through

This commit is contained in:
Meyer Simon
2025-05-02 12:02:07 -04:00
parent 60ffb33c58
commit b762127879
2 changed files with 17 additions and 9 deletions

View File

@ -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", $$);
}

View File

@ -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;
}