Function calls are being emitted with the right int for args

This commit is contained in:
Meyer Simon
2025-05-01 21:15:58 -04:00
parent 558c09e60f
commit 60ffb33c58
2 changed files with 6 additions and 2 deletions

View File

@ -1045,10 +1045,14 @@ assignable:
throw_error(ERROR_TYPE, "Undefined type returned by function."); throw_error(ERROR_TYPE, "Undefined type returned by function.");
} }
TableNode* node = CreateEntry(cur,t, typeNode2, temp, NULL); 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)); emit_push_all(S_Peek(stack));
S_Pop(stack); S_Pop(stack);
emit_function_call(node, a, tn_or_const(NODE, $1)); emit_function_call(node, a, tn_or_const(NODE, $1));
//-----------------------------------------------------------------------------
$$ = node; $$ = node;
//NOTE ADD ASSIGNMENT EMIT HERE (MIGHT NEED TO PUSH TO STACK for function call) //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)); printdebug("[ASSIGNABLE - RULE 2] assignable = type: %s | name_func = %s", getName(typeNode2), getName((TableNode*)$1));

View File

@ -52,7 +52,7 @@ bool S_IsEmpty(Stack *s){
} }
int S_Size(Stack *s){ int S_Size(Stack *s){
if (s == NULL || !S_IsEmpty(s)) { if (s == NULL || S_IsEmpty(s)) {
return 0; return 0;
} }
return s->size; return s->size;