diff --git a/src/grammar.y b/src/grammar.y index dbe97b7..b793fb0 100644 --- a/src/grammar.y +++ b/src/grammar.y @@ -1045,10 +1045,14 @@ assignable: throw_error(ERROR_TYPE, "Undefined type returned by function."); } TableNode* node = CreateEntry(cur,t, typeNode2, temp, NULL); - int a = S_Size(S_Peek(stack)); +//----------------------------------------------------------------------------- + // Please don't touch + // the + 1 is here because I don't detach the last param + int a = S_Size(S_Peek(stack)) + 1; emit_push_all(S_Peek(stack)); S_Pop(stack); emit_function_call(node, a, tn_or_const(NODE, $1)); +//----------------------------------------------------------------------------- $$ = node; //NOTE ADD ASSIGNMENT EMIT HERE (MIGHT NEED TO PUSH TO STACK for function call) printdebug("[ASSIGNABLE - RULE 2] assignable = type: %s | name_func = %s", getName(typeNode2), getName((TableNode*)$1)); diff --git a/src/intermediate_code.c b/src/intermediate_code.c index d2868be..8a89721 100644 --- a/src/intermediate_code.c +++ b/src/intermediate_code.c @@ -52,7 +52,7 @@ bool S_IsEmpty(Stack *s){ } int S_Size(Stack *s){ - if (s == NULL || !S_IsEmpty(s)) { + if (s == NULL || S_IsEmpty(s)) { return 0; } return s->size;