fixed several small issues

This commit is contained in:
Partho
2025-04-15 01:40:18 -04:00
parent 2b1557b52c
commit 8057060f26
4 changed files with 18 additions and 12 deletions

View File

@ -92,9 +92,10 @@ int getNumArrDim(TableNode *definition) {
"function. Invalid.");
return -1;
}
if (strcmp(getType(definition), "array") != 0) {
printdebug("not checking the dim of an array -- invalid op");
return 0;
if(getAdInfoType(definition) != TYPE_ARRAY_TYPE){
printdebug(
"passed an invalid node to getNumArrDim. Seeing tag %d in getNumArrDim. Invalid.",getAdInfoType(definition));
return -1;
}
return definition->additionalinfo->ArrayAdInfo->numofdimensions;
}
@ -113,8 +114,9 @@ TableNode *getArrType(TableNode *definition) {
"function. Invalid.");
return undefined;
}
if (strcmp(getType(definition), "array") != 0) {
printdebug("not checking the type of an array -- invalid op");
if(getAdInfoType(definition) != TYPE_ARRAY_TYPE){
printdebug(
"passed an invalid node to getArrType. Seeing tag %d. Invalid.",getAdInfoType(definition));
return undefined;
}
return definition->additionalinfo->ArrayAdInfo->typeofarray;
@ -1132,8 +1134,8 @@ void print_symbol_table(SymbolTable *table, FILE *file_ptr) {
}
if (getAdInfoType(entry) == TYPE_ARRAY) {
char *arrayType = (char *)malloc(100);
sprintf(arrayType, " %d -> %s", getNumArrDim(entry),
getName(getArrType(entry)));
//sprintf(arrayType, " %d -> %s", getNumArrDim(entry),
// getName(getArrType(entry)));
if (parentScopeNum == 0) {
st_fprint(file_ptr, getName(entry), currentScopeNum, -100, getType(entry), " Array Instance");