From 26b23a68fa76d9b8e6d92391cbc222840c4a8f26 Mon Sep 17 00:00:00 2001 From: Partho Date: Tue, 6 May 2025 15:20:43 -0400 Subject: [PATCH] need to update argument list for the right context --- src/grammar.y | 10 +++++++++- src/symbol_table.c | 42 ++++++++++++++++++++++++++++++++++++++++++ src/symbol_table.h | 2 ++ 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/src/grammar.y b/src/grammar.y index 692df0e..61e9724 100644 --- a/src/grammar.y +++ b/src/grammar.y @@ -1242,12 +1242,20 @@ assignable: cur = CreateScope(cur, -2,-1); }else{ cur = CreateScope(cur, -1,-1); - }} + } + + if(getAdInfoType((TableNode*)$1) == TYPE_FUNCTION_DECLARATION){ + //the function context is created. Pushing the type of the function since that has the information needed + PushFunction(1, getTypeEntry((TableNode*)$1)); + } + + } //we have to consider emmissions in ablocks ablock { //PopContext(); //int type = getAdInfoType(look_up(getParent(cur), getName((TableNode*)$1))); + PopFunction(); int type = getAdInfoType(getTypeEntry((TableNode*)$1)); printdebug("%stype is %d", COLOR_PURPLE, type); printdebug("%s", getName((TableNode*)$1)); diff --git a/src/symbol_table.c b/src/symbol_table.c index 73a9b10..50ae956 100644 --- a/src/symbol_table.c +++ b/src/symbol_table.c @@ -124,6 +124,48 @@ int getArgumentNumber(Function_Stack *fs) { return fs->arg; } +TableNode* getRecordNumberType(TableNode* record, int arg){ + if(record == NULL){ + //case where NULL is being passed in + return undefined; + } + if(getAdInfoType(record) != TYPE_RECORD_TYPE){ + //case where invalid argument number is being passed + return undefined; + } + if(arg