found one segfault. (not fixed yet)
This commit is contained in:
2
check.sh
2
check.sh
@ -33,6 +33,8 @@ compare_files() {
|
||||
diff -q "$file" "$exp" > /dev/null
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo -e "${GREEN}[✔] ${PURPLE}$filename ${WHITE}passed.${NOCOLOR}"
|
||||
elif [[ ! -s "$file" ]]; then
|
||||
echo -e "${RED}[✘] ${PURPLE}$filename ${WHITE}failed with an empty file. (did it segfault?)${NOCOLOR}"
|
||||
else
|
||||
echo -e "\n${RED}[✘] ${PURPLE}$file ${WHITE}failed with an unexpected value...${NOCOLOR}"
|
||||
diff --color=always "$file" "$exp"
|
||||
|
@ -623,7 +623,12 @@ assignable:
|
||||
printdebug("as function");
|
||||
//char *funtype = getType(look_up(cur, $1));
|
||||
printdebug("%s", getType(look_up(cur, getName((TableNode*)$1))));
|
||||
|
||||
// Something fishy is going on here.......
|
||||
TableNode *param = getParameter(look_up(getParent(cur), getName((TableNode*)$1)));
|
||||
printTableNode(table_lookup(getAncestor(cur), getName((TableNode*)$1)));
|
||||
|
||||
|
||||
SymbolTable *recList = getRecList(param);
|
||||
TableNode *lastCheckedRef = getFirstEntry(recList);
|
||||
TableNode *lastCheckedAct = getFirstEntry(cur);
|
||||
|
@ -261,9 +261,10 @@ bool getAsKeyword(TableNode *definition) {
|
||||
return false;
|
||||
}
|
||||
if (strcmp(getType(definition), "primitive function") != 0) {
|
||||
printdebug(
|
||||
"not checking if a function is called with as or not (%s) -- "
|
||||
"invalid op", getType(definition));
|
||||
printdebug("not checking if a function is called with as or "
|
||||
"not (%s) -- "
|
||||
"invalid op",
|
||||
getType(definition));
|
||||
return 0;
|
||||
}
|
||||
return definition->additionalinfo->FunDecAdInfo->regularoras;
|
||||
@ -633,7 +634,8 @@ int getAdInfoType(TableNode *tn) {
|
||||
}*/
|
||||
}
|
||||
|
||||
TableNode *CreateEntry(SymbolTable *table, int tag, TableNode *typeOf, char *id, AdInfo *ad) {
|
||||
TableNode *CreateEntry(SymbolTable *table, int tag, TableNode *typeOf, char *id,
|
||||
AdInfo *ad) {
|
||||
|
||||
if (table == NULL) {
|
||||
printdebug("Null reference to table");
|
||||
@ -656,10 +658,10 @@ TableNode *CreateEntry(SymbolTable *table, int tag, TableNode *typeOf, char *id,
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
TableNode *newEntry = (TableNode *)calloc(1, sizeof(TableNode));
|
||||
if (tag < 1 && tag > 11) {
|
||||
printdebug("Note- not passing in valid 'tag' identifier to create entry function. Setting tag to undefined");
|
||||
printdebug("Note- not passing in valid 'tag' identifier to "
|
||||
"create entry function. Setting tag to undefined");
|
||||
newEntry->tag = TYPE_UNDEFINED;
|
||||
} else {
|
||||
newEntry->tag = tag;
|
||||
@ -680,8 +682,6 @@ TableNode *CreateEntry(SymbolTable *table, int tag, TableNode *typeOf, char *id,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
TableNode *getTypeEntry(TableNode *tn) {
|
||||
if (tn == NULL) {
|
||||
printdebug("passed a NULL table entry to getType");
|
||||
@ -1138,3 +1138,101 @@ TableNode *getNextEntry(TableNode *tn) {
|
||||
}
|
||||
return tn->next;
|
||||
}
|
||||
|
||||
// Prints all info about a table node
|
||||
// Uses pointers to the table node to print the info
|
||||
TableNode *printTableNode(TableNode *tn) {
|
||||
if (DEBUG == 0) {
|
||||
return tn;
|
||||
}
|
||||
|
||||
if (tn == NULL) {
|
||||
printdebug("%s[PrintTN] Passed a NULL tablenode!", COLOR_RED);
|
||||
return undefined;
|
||||
}
|
||||
if (tn->theName == NULL) {
|
||||
printdebug("%s[PrintTN] Passed a tablenode with NULL name!",
|
||||
COLOR_RED);
|
||||
return undefined;
|
||||
}
|
||||
if (tn->theType == NULL) {
|
||||
printdebug("%s[PrintTN] Passed a tablenode with NULL type!",
|
||||
COLOR_RED);
|
||||
return undefined;
|
||||
}
|
||||
if (tn == undefined) {
|
||||
printdebug("%s[PrintTN] Passed an undefined tablenode!",
|
||||
COLOR_RED);
|
||||
return undefined;
|
||||
}
|
||||
if (tn->additionalinfo == NULL) {
|
||||
printdebug(
|
||||
"%s[PrintTN] Passed a tablenode with NULL additional info!",
|
||||
COLOR_RED);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
printdebug("%s[PrintTN] Printing tablenode...", COLOR_ORANGE);
|
||||
printdebug(" %sName: %s%s", COLOR_YELLOW, COLOR_LIGHTBLUE,
|
||||
tn->theName);
|
||||
printdebug(" %sType: %s%s", COLOR_YELLOW, COLOR_LIGHTBLUE,
|
||||
tn->theType->theName);
|
||||
printdebug(" %sTag: %s%d", COLOR_YELLOW, COLOR_LIGHTBLUE, tn->tag);
|
||||
|
||||
if (tn->tag == TYPE_RECORD_TYPE || tn->tag == TYPE_RECORD) {
|
||||
printdebug(" %sAdditional Info: %sRecAdInfo", COLOR_YELLOW,
|
||||
COLOR_LIGHTBLUE);
|
||||
printdebug(" %snumberOfElements: %s%d", COLOR_YELLOW,
|
||||
COLOR_LIGHTBLUE,
|
||||
tn->additionalinfo->RecAdInfo->numofelements);
|
||||
if (tn->additionalinfo->RecAdInfo->recordScope == NULL) {
|
||||
printdebug(" %srecordScope (line): %s(NULL)",
|
||||
COLOR_YELLOW, COLOR_LIGHTBLUE);
|
||||
} else {
|
||||
printdebug(" %srecordScope (line): %s%d",
|
||||
COLOR_YELLOW, COLOR_LIGHTBLUE,
|
||||
tn->additionalinfo->RecAdInfo->recordScope
|
||||
->Line_Number);
|
||||
}
|
||||
} else if (tn->tag == TYPE_ARRAY_TYPE || tn->tag == TYPE_ARRAY) {
|
||||
printdebug(" %sAdditional Info: %sArrayAdInfo", COLOR_YELLOW,
|
||||
COLOR_LIGHTBLUE);
|
||||
printdebug(" %snumberOfDimensions: %s%d", COLOR_YELLOW,
|
||||
COLOR_LIGHTBLUE,
|
||||
tn->additionalinfo->ArrayAdInfo->numofdimensions);
|
||||
printdebug(
|
||||
" %stypeOfArray: %s%s", COLOR_YELLOW,
|
||||
COLOR_LIGHTBLUE,
|
||||
tn->additionalinfo->ArrayAdInfo->typeofarray->theName);
|
||||
} else if (tn->tag == TYPE_FUNCTION_TYPE) {
|
||||
printdebug(" %sAdditional Info: %sFunTypeAdInfo",
|
||||
COLOR_YELLOW, COLOR_LIGHTBLUE);
|
||||
printdebug(
|
||||
" %sparameter: %s%s", COLOR_YELLOW, COLOR_LIGHTBLUE,
|
||||
tn->additionalinfo->FunTypeAdInfo->parameter->theName);
|
||||
printdebug(
|
||||
" %sreturntype: %s%s", COLOR_YELLOW, COLOR_LIGHTBLUE,
|
||||
tn->additionalinfo->FunTypeAdInfo->returntype->theName);
|
||||
} else if (tn->tag == TYPE_FUNCTION_DECLARATION) {
|
||||
printdebug(" %sAdditional Info: %sFunDecAdInfo",
|
||||
COLOR_YELLOW, COLOR_LIGHTBLUE);
|
||||
printdebug(" %sstartLineNumber: %s%d", COLOR_YELLOW,
|
||||
COLOR_LIGHTBLUE,
|
||||
tn->additionalinfo->FunDecAdInfo->startlinenumber);
|
||||
printdebug(" %sregularOrAs: %s%s", COLOR_YELLOW,
|
||||
COLOR_LIGHTBLUE,
|
||||
tn->additionalinfo->FunDecAdInfo->regularoras
|
||||
? "true"
|
||||
: "false");
|
||||
} else if (tn->tag == TYPE_PRIMITIVE) {
|
||||
printdebug(" %sAdditional Info: %sPrimAdInfo", COLOR_YELLOW,
|
||||
COLOR_LIGHTBLUE);
|
||||
printdebug(" %ssize: %s%d", COLOR_YELLOW,
|
||||
COLOR_LIGHTBLUE,
|
||||
tn->additionalinfo->PrimAdInfo->size);
|
||||
} else {
|
||||
printdebug(" AdInfo not handled.");
|
||||
}
|
||||
|
||||
return tn;
|
||||
}
|
@ -124,6 +124,7 @@ ListOfTable *getRestOfChildren(ListOfTable *lt);
|
||||
TableNode *getFirstEntry(SymbolTable *st);
|
||||
TableNode *getNextEntry(TableNode *tn);
|
||||
|
||||
TableNode * printTableNode(TableNode * tn);
|
||||
void printdebug_impl(char *file, int line, const char *format, ...);
|
||||
#define printdebug(format, ...) \
|
||||
printdebug_impl(__FILE__, __LINE__, format, ##__VA_ARGS__)
|
||||
|
Reference in New Issue
Block a user