I added some code to push args but its not working

This commit is contained in:
Meyer Simon
2025-05-01 11:12:58 -04:00
parent 2b07464f84
commit 456346f68e
2 changed files with 20 additions and 4 deletions

View File

@ -654,8 +654,11 @@ rec_op:
ablock: ablock:
L_PAREN {} L_PAREN{
argument_list R_PAREN emit_push_all(S_Pop(stack));
}
argument_list {
} R_PAREN
{ {
// here // here
$$ = $3; $$ = $3;
@ -671,7 +674,6 @@ argument_list:
expression{ expression{
TableNode* arg = CreateEntry(cur, getAdInfoType((TableNode*)$1), getTypeEntry((TableNode*)$1), arg_var_gen(), NULL); TableNode* arg = CreateEntry(cur, getAdInfoType((TableNode*)$1), getTypeEntry((TableNode*)$1), arg_var_gen(), NULL);
// this emits params for function and arrays TODO: fix // this emits params for function and arrays TODO: fix
emit_parameter(tn_or_const(NODE,arg));
Stack * t = S_Peek(stack); Stack * t = S_Peek(stack);
if (stack == NULL){ if (stack == NULL){
stack = S_Init(); stack = S_Init();
@ -680,6 +682,7 @@ argument_list:
t = S_Init(); t = S_Init();
S_Push(stack, t, 0); S_Push(stack, t, 0);
} }
emit_parameter(tn_or_const(NODE,arg));
S_Push(t, current, 1); S_Push(t, current, 1);
emit_detach(); emit_detach();
//printdebug("[ARGUMENT_LIST] argument list is %d", $$); //printdebug("[ARGUMENT_LIST] argument list is %d", $$);
@ -691,8 +694,17 @@ argument_list:
{ {
TableNode* arg = CreateEntry(cur, getAdInfoType((TableNode*)$1), getTypeEntry((TableNode*)$1), arg_var_gen(), NULL); TableNode* arg = CreateEntry(cur, getAdInfoType((TableNode*)$1), getTypeEntry((TableNode*)$1), arg_var_gen(), NULL);
Stack * t = S_Peek(stack);
if (stack == NULL){
stack = S_Init();
}
if(t == NULL){
t = S_Init();
S_Push(stack, t, 0);
}
emit_parameter(tn_or_const(NODE,arg)); emit_parameter(tn_or_const(NODE,arg));
emit_push_all(S_Pop(stack)); S_Push(t, current, 1);
emit_detach();
$$ = 1; $$ = 1;
printdebug("[ARGUMENT_LIST] argument list is %d", $$); printdebug("[ARGUMENT_LIST] argument list is %d", $$);
} }
@ -1023,6 +1035,7 @@ assignable:
int a = S_Size(S_Peek(stack)); int a = S_Size(S_Peek(stack));
} }
*/ */
emit_push_all(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)

View File

@ -143,6 +143,9 @@ void emit_release(TableNode * pointer);
void emit_field_access(char* result, char* record, char* field); void emit_field_access(char* result, char* record, char* field);
void emit_array_access(Op op, TableNode * result, TNodeOrConst * array, TNodeOrConst * index); void emit_array_access(Op op, TableNode * result, TNodeOrConst * array, TNodeOrConst * index);
void emit_bounds_check(TNodeOrConst * index, TNodeOrConst * arr); void emit_bounds_check(TNodeOrConst * index, TNodeOrConst * arr);
void emit_goto(int i);
void emit_detach();
void emit_push_all(Stack * s);
int getLabel(Instruction * i); int getLabel(Instruction * i);