added reference to function scopes

This commit is contained in:
Partho
2025-05-03 14:16:31 -04:00
parent 5a47e40227
commit 6b239b0724
3 changed files with 86 additions and 12 deletions

View File

@ -171,6 +171,7 @@ definition:
setAsKeyword(node, true);
}
cur = CreateScope(cur, 0, 0);
setFunScope(node, cur);
printdebug("Created a new scope");
} L_PAREN {
TableNode * parameter = getParameter(getTypeEntry(table_lookup(getAncestor(cur), $1)));
@ -290,11 +291,11 @@ function_declaration:
if(getAdInfoType(table_lookup(cur, $4))==TYPE_FUNCTION_TYPE){
//printf("%s\n",$2);
//printf("%s\n",getName(table_lookup(cur, $4)));
CreateEntry(cur,TYPE_FUNCTION_DECLARATION, table_lookup(cur, $4), $2, CreateFunctionDeclarationInfo(-1, false));
CreateEntry(cur,TYPE_FUNCTION_DECLARATION, table_lookup(cur, $4), $2, CreateFunctionDeclarationInfo(-1, false,NULL));
}
else{
throw_error(ERROR_TYPE, "Function declatation (%s) is not a valid function type", $2);
CreateEntry(cur,TYPE_FUNCTION_DECLARATION, look_up(cur, $4), $2, CreateFunctionDeclarationInfo(-1, false));
CreateEntry(cur,TYPE_FUNCTION_DECLARATION, look_up(cur, $4), $2, CreateFunctionDeclarationInfo(-1, false,NULL));
}
}
@ -302,11 +303,11 @@ function_declaration:
| EXTERNAL FUNCTION ID COLON ID
{
if(getAdInfoType(look_up(cur, $5))==TYPE_FUNCTION_TYPE){
CreateEntry(cur,TYPE_FUNCTION_DECLARATION, look_up(cur, $5), $3, CreateFunctionDeclarationInfo(-1, false));
CreateEntry(cur,TYPE_FUNCTION_DECLARATION, look_up(cur, $5), $3, CreateFunctionDeclarationInfo(-1, false,NULL));
}
else{
throw_error(ERROR_TYPE, "Function declatation (%s) is not a valid function type", $3);
CreateEntry(cur,TYPE_FUNCTION_DECLARATION, look_up(cur, $5), $3, CreateFunctionDeclarationInfo(-1, false));
CreateEntry(cur,TYPE_FUNCTION_DECLARATION, look_up(cur, $5), $3, CreateFunctionDeclarationInfo(-1, false,NULL));
}
}
@ -467,7 +468,7 @@ declaration:
printdebug("invalid (function) type passed in declaration list in dblock", @2.first_line, @2.first_column);
d = TYPE_FUNCTION_DECLARATION;
if(CreateEntry(cur,d,(TableNode*)$1,$3,getAdInfo((TableNode*)$1)) == undefined){
if(CreateEntry(cur,d,(TableNode*)$1,$3,NULL) == undefined){
throw_error(ERROR_TYPE, "Duplicate defination of function in declaration list");
}