working on make sure types pass properly in grammar
This commit is contained in:
@ -172,7 +172,8 @@ definition:
|
||||
cur = CreateScope(cur, 0, 0);
|
||||
printdebug("Created a new scope");
|
||||
} L_PAREN {
|
||||
TableNode *parameter = getParameter(table_lookup(getAncestor(cur), getType(table_lookup(getAncestor(cur), $1))));
|
||||
TableNode * parameter = getParameter(getTypeEntry(table_lookup(getAncestor(cur), $1)));
|
||||
//TableNode *parameter = getParameter(table_lookup(getAncestor(cur), getType(table_lookup(getAncestor(cur), $1))));
|
||||
printdebug("parameter type: %s", getType(parameter));
|
||||
if (parameter == undefined) {
|
||||
printdebug("[TYPE CHECK] function defined with as, but parameter is undefined at line %d, column %d", @1.first_line, @1.first_column);
|
||||
@ -359,7 +360,7 @@ declaration:
|
||||
}
|
||||
else if(d == TYPE_FUNCTION_TYPE) {
|
||||
printdebug("invalid (function) type passed in declaration list in dblock", @2.first_line, @2.first_column);
|
||||
d = TYPE_FUNCTION_TYPE;
|
||||
d = TYPE_FUNCTION_DECLARATION;
|
||||
CreateEntry(cur,d,(TableNode*)$1,$3,getAdInfo((TableNode*)$1));
|
||||
}
|
||||
else if(d == TYPE_ARRAY_TYPE){
|
||||
|
@ -1124,11 +1124,11 @@ void print_symbol_table(SymbolTable *table, FILE *file_ptr) {
|
||||
}
|
||||
if (getAdInfoType(entry) == TYPE_RECORD_TYPE) {
|
||||
char *recordAdInfo = (char *)malloc(100);
|
||||
sprintf(recordAdInfo, " elements-%d", getRecLength(entry));
|
||||
sprintf(recordAdInfo, " elements-%d size-%d bytes", getRecLength(entry), getRecTotal(entry));
|
||||
if (parentScopeNum == 0) {
|
||||
st_fprint(file_ptr, getName(entry), currentScopeNum, -100, "record type", recordAdInfo);
|
||||
st_fprint(file_ptr, getName(entry), currentScopeNum, -100, " record type", recordAdInfo);
|
||||
} else {
|
||||
st_fprint(file_ptr, getName(entry), currentScopeNum, parentScopeNum, "record type", recordAdInfo);
|
||||
st_fprint(file_ptr, getName(entry), currentScopeNum, parentScopeNum, " record type", recordAdInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1136,15 +1136,15 @@ void print_symbol_table(SymbolTable *table, FILE *file_ptr) {
|
||||
char *recordAdInfo = (char *)malloc(100);
|
||||
sprintf(recordAdInfo, " elements-%d", getRecLength(entry));
|
||||
if (parentScopeNum == 0) {
|
||||
st_fprint(file_ptr, getName(entry), currentScopeNum, -100, "record instance", recordAdInfo);
|
||||
st_fprint(file_ptr, getName(entry), currentScopeNum, -100, getType(entry), "record instance");
|
||||
} else {
|
||||
st_fprint(file_ptr, getName(entry), currentScopeNum, parentScopeNum, "record instance", recordAdInfo);
|
||||
st_fprint(file_ptr, getName(entry), currentScopeNum, parentScopeNum, getType(entry), "record instance");
|
||||
}
|
||||
}
|
||||
|
||||
if (getAdInfoType(entry) == TYPE_PRIMITIVE) {
|
||||
char *primAdInfo = (char *)malloc(100);
|
||||
sprintf(primAdInfo, " size-%d bytes", getPrimSize(entry));
|
||||
sprintf(primAdInfo, " size-%d bytes", getPrimSize(getTypeEntry(entry)));
|
||||
if (parentScopeNum == 0) {
|
||||
st_fprint(file_ptr, getName(entry), currentScopeNum, -100, " Primitive", primAdInfo);
|
||||
} else {
|
||||
@ -1169,9 +1169,9 @@ void print_symbol_table(SymbolTable *table, FILE *file_ptr) {
|
||||
|
||||
if (getAdInfoType(entry) == TYPE_FUNCTION_DECLARATION) {
|
||||
if (parentScopeNum == 0) {
|
||||
st_fprint(file_ptr, getName(entry), currentScopeNum, -100, " Function", " Function Declaration");
|
||||
st_fprint(file_ptr, getName(entry), currentScopeNum, -100, getType(entry), " Function Definition");
|
||||
} else {
|
||||
st_fprint(file_ptr, getName(entry), currentScopeNum, parentScopeNum, " Function", " Function Declaration");
|
||||
st_fprint(file_ptr, getName(entry), currentScopeNum, parentScopeNum, getType(entry), " Function Definition");
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user