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