added entries for reserve and release

This commit is contained in:
Partho
2025-04-15 19:44:46 -04:00
parent b325548b97
commit 90f9eb2f00
3 changed files with 28 additions and 3 deletions

View File

@ -392,6 +392,7 @@ sblock:
printdebug("Moving up a scope after seeing sblock with dblock"); printdebug("Moving up a scope after seeing sblock with dblock");
cur = getParent(cur); cur = getParent(cur);
//$<tn>$ = $5; //$<tn>$ = $5;
} }
R_BRACE R_BRACE
{$$ = $5;} {$$ = $5;}

View File

@ -605,20 +605,31 @@ SymbolTable *init(SymbolTable *start) {
chara = (TableNode *)calloc(1, sizeof(TableNode)); chara = (TableNode *)calloc(1, sizeof(TableNode));
stri = (TableNode *)calloc(1, sizeof(TableNode)); stri = (TableNode *)calloc(1, sizeof(TableNode));
boo = (TableNode *)calloc(1, sizeof(TableNode)); boo = (TableNode *)calloc(1, sizeof(TableNode));
TableNode* reservetype = (TableNode *)calloc(1, sizeof(TableNode));
TableNode* reserve = (TableNode *)calloc(1, sizeof(TableNode));
TableNode* releasetype = (TableNode *)calloc(1, sizeof(TableNode));
TableNode* release = (TableNode *)calloc(1, sizeof(TableNode));
// TableNode* arr = (TableNode*)malloc(sizeof(SymbolTable)); // TableNode* arr = (TableNode*)malloc(sizeof(SymbolTable));
start->entries = integ; start->entries = integ;
integ->next = addr; integ->next = addr;
addr->next = chara; addr->next = chara;
chara->next = stri; chara->next = stri;
stri->next = boo; stri->next = boo;
// boo->next = arr; boo->next = reservetype;
boo->next = NULL; reservetype->next = reserve;
reserve->next = releasetype;
releasetype->next = release;
release->next = NULL;
integ->theName = "integer"; integ->theName = "integer";
addr->theName = "address"; addr->theName = "address";
chara->theName = "character"; chara->theName = "character";
boo->theName = "Boolean"; boo->theName = "Boolean";
stri->theName = "string"; stri->theName = "string";
reserve->theName = "reserve";
reservetype->theName = "reserve type";
releasetype->theName = "release type";
release->theName = "release";
// arr->theName= "array" // arr->theName= "array"
// root TableNode that all are pointing to but not in table // root TableNode that all are pointing to but not in table
@ -685,6 +696,11 @@ SymbolTable *init(SymbolTable *start) {
chara->theType = prime; chara->theType = prime;
stri->theType = arrayprim; stri->theType = arrayprim;
boo->theType = prime; boo->theType = prime;
reserve->theType = reservetype;
reservetype->theType = funtypeprime;
releasetype->theType = funtypeprime;
release->theType = releasetype;
// arr->theType=arrayprim; // arr->theType=arrayprim;
// filling in all the values for the additional info for initial types // filling in all the values for the additional info for initial types
@ -697,12 +713,20 @@ SymbolTable *init(SymbolTable *start) {
chara->additionalinfo = CreatePrimitiveInfo(SIZE_CHAR); chara->additionalinfo = CreatePrimitiveInfo(SIZE_CHAR);
stri->additionalinfo = CreateArrayInfo(1, chara); stri->additionalinfo = CreateArrayInfo(1, chara);
boo->additionalinfo = CreatePrimitiveInfo(SIZE_BOOL); boo->additionalinfo = CreatePrimitiveInfo(SIZE_BOOL);
reserve->additionalinfo = CreateFunctionDeclarationInfo(0, false);
reservetype->additionalinfo = CreateFunctionTypeInfo(integ, addr);
releasetype->additionalinfo = CreateFunctionTypeInfo(addr, integ);
release->additionalinfo = CreateFunctionDeclarationInfo(0, false);
integ->tag = TYPE_PRIMITIVE_TYPE; // explicitly set the type for integ integ->tag = TYPE_PRIMITIVE_TYPE; // explicitly set the type for integ
addr->tag = TYPE_PRIMITIVE_TYPE; // explicitly set the type for addr addr->tag = TYPE_PRIMITIVE_TYPE; // explicitly set the type for addr
chara->tag = TYPE_PRIMITIVE_TYPE; // explicitly set the type for chara chara->tag = TYPE_PRIMITIVE_TYPE; // explicitly set the type for chara
stri->tag = TYPE_ARRAY_TYPE; // explicitly set the type for stri stri->tag = TYPE_ARRAY_TYPE; // explicitly set the type for stri
boo->tag = TYPE_PRIMITIVE_TYPE; // explicitly set the type for boo boo->tag = TYPE_PRIMITIVE_TYPE; // explicitly set the type for boo
reserve->tag = TYPE_FUNCTION_DECLARATION;
reservetype->tag = TYPE_FUNCTION_TYPE;
releasetype->tag = TYPE_FUNCTION_TYPE;
release->tag = TYPE_FUNCTION_DECLARATION;
// addr->additionalinfo = CreatePrimitiveInfo(8); // addr->additionalinfo = CreatePrimitiveInfo(8);
start->Line_Number = 1; start->Line_Number = 1;