updated symbol table entry add order
This commit is contained in:
@ -956,6 +956,11 @@ TableNode *CreateEntry(SymbolTable *table, int tag, TableNode *typeOf, char *id,
|
||||
return NULL;
|
||||
}
|
||||
*/
|
||||
if((id != NULL) && table_lookup(cur,id)!=undefined){
|
||||
printdebug("This name is already defined in the current scope");
|
||||
//throw_error(ERROR_TYPE, "Already defined.");
|
||||
return undefined;
|
||||
}
|
||||
if (typeOf == NULL) {
|
||||
printdebug("Passing an NULL Type Node to Create Entry");
|
||||
return undefined;
|
||||
@ -982,9 +987,14 @@ TableNode *CreateEntry(SymbolTable *table, int tag, TableNode *typeOf, char *id,
|
||||
printdebug("[CreateEntry] Adding %s to the symbol table", id);
|
||||
return newEntry;
|
||||
} else {
|
||||
TableNode *oldEntry = table->entries;
|
||||
table->entries = newEntry;
|
||||
newEntry->next = oldEntry;
|
||||
TableNode*oldEntry = table->entries;
|
||||
while (oldEntry->next != NULL) {
|
||||
oldEntry = oldEntry->next;
|
||||
}
|
||||
oldEntry->next = newEntry;
|
||||
newEntry->next = NULL;
|
||||
//table->entries = newEntry;
|
||||
//newEntry->next = oldEntry;
|
||||
printdebug("[CreateEntry] Adding %s to the symbol table", id);
|
||||
return newEntry;
|
||||
}
|
||||
|
Reference in New Issue
Block a user