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
|
diff -q "$file" "$exp" > /dev/null
|
||||||
if [[ $? -eq 0 ]]; then
|
if [[ $? -eq 0 ]]; then
|
||||||
echo -e "${GREEN}[✔] ${PURPLE}$filename ${WHITE}passed.${NOCOLOR}"
|
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
|
else
|
||||||
echo -e "\n${RED}[✘] ${PURPLE}$file ${WHITE}failed with an unexpected value...${NOCOLOR}"
|
echo -e "\n${RED}[✘] ${PURPLE}$file ${WHITE}failed with an unexpected value...${NOCOLOR}"
|
||||||
diff --color=always "$file" "$exp"
|
diff --color=always "$file" "$exp"
|
||||||
|
@ -623,7 +623,12 @@ assignable:
|
|||||||
printdebug("as function");
|
printdebug("as function");
|
||||||
//char *funtype = getType(look_up(cur, $1));
|
//char *funtype = getType(look_up(cur, $1));
|
||||||
printdebug("%s", getType(look_up(cur, getName((TableNode*)$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)));
|
TableNode *param = getParameter(look_up(getParent(cur), getName((TableNode*)$1)));
|
||||||
|
printTableNode(table_lookup(getAncestor(cur), getName((TableNode*)$1)));
|
||||||
|
|
||||||
|
|
||||||
SymbolTable *recList = getRecList(param);
|
SymbolTable *recList = getRecList(param);
|
||||||
TableNode *lastCheckedRef = getFirstEntry(recList);
|
TableNode *lastCheckedRef = getFirstEntry(recList);
|
||||||
TableNode *lastCheckedAct = getFirstEntry(cur);
|
TableNode *lastCheckedAct = getFirstEntry(cur);
|
||||||
|
@ -261,9 +261,10 @@ bool getAsKeyword(TableNode *definition) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (strcmp(getType(definition), "primitive function") != 0) {
|
if (strcmp(getType(definition), "primitive function") != 0) {
|
||||||
printdebug(
|
printdebug("not checking if a function is called with as or "
|
||||||
"not checking if a function is called with as or not (%s) -- "
|
"not (%s) -- "
|
||||||
"invalid op", getType(definition));
|
"invalid op",
|
||||||
|
getType(definition));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return definition->additionalinfo->FunDecAdInfo->regularoras;
|
return definition->additionalinfo->FunDecAdInfo->regularoras;
|
||||||
@ -563,7 +564,7 @@ AdInfo *getAdInfo(TableNode *tn) {
|
|||||||
return tn->additionalinfo;
|
return tn->additionalinfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
//simplified getAdInfoType
|
// simplified getAdInfoType
|
||||||
int getAdInfoType(TableNode *tn) {
|
int getAdInfoType(TableNode *tn) {
|
||||||
if (tn == NULL) {
|
if (tn == NULL) {
|
||||||
printdebug(
|
printdebug(
|
||||||
@ -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) {
|
if (table == NULL) {
|
||||||
printdebug("Null reference to table");
|
printdebug("Null reference to table");
|
||||||
@ -656,12 +658,12 @@ TableNode *CreateEntry(SymbolTable *table, int tag, TableNode *typeOf, char *id,
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TableNode *newEntry = (TableNode *)calloc(1, sizeof(TableNode));
|
TableNode *newEntry = (TableNode *)calloc(1, sizeof(TableNode));
|
||||||
if(tag<1 && tag>11){
|
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;
|
newEntry->tag = TYPE_UNDEFINED;
|
||||||
} else{
|
} else {
|
||||||
newEntry->tag = tag;
|
newEntry->tag = tag;
|
||||||
}
|
}
|
||||||
newEntry->theType = typeOf /*topDef*/;
|
newEntry->theType = typeOf /*topDef*/;
|
||||||
@ -680,8 +682,6 @@ TableNode *CreateEntry(SymbolTable *table, int tag, TableNode *typeOf, char *id,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TableNode *getTypeEntry(TableNode *tn) {
|
TableNode *getTypeEntry(TableNode *tn) {
|
||||||
if (tn == NULL) {
|
if (tn == NULL) {
|
||||||
printdebug("passed a NULL table entry to getType");
|
printdebug("passed a NULL table entry to getType");
|
||||||
@ -766,7 +766,7 @@ TableNode *addName(TableNode *tn, char *str) {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
if (tn->theName != NULL) {
|
if (tn->theName != NULL) {
|
||||||
//printdebug(
|
// printdebug(
|
||||||
//"Name doesn't look like it is empty before you change. "
|
//"Name doesn't look like it is empty before you change. "
|
||||||
//"Are you sure you need to update name?");
|
//"Are you sure you need to update name?");
|
||||||
if (str != NULL) {
|
if (str != NULL) {
|
||||||
@ -1138,3 +1138,101 @@ TableNode *getNextEntry(TableNode *tn) {
|
|||||||
}
|
}
|
||||||
return tn->next;
|
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 *getFirstEntry(SymbolTable *st);
|
||||||
TableNode *getNextEntry(TableNode *tn);
|
TableNode *getNextEntry(TableNode *tn);
|
||||||
|
|
||||||
|
TableNode * printTableNode(TableNode * tn);
|
||||||
void printdebug_impl(char *file, int line, const char *format, ...);
|
void printdebug_impl(char *file, int line, const char *format, ...);
|
||||||
#define printdebug(format, ...) \
|
#define printdebug(format, ...) \
|
||||||
printdebug_impl(__FILE__, __LINE__, format, ##__VA_ARGS__)
|
printdebug_impl(__FILE__, __LINE__, format, ##__VA_ARGS__)
|
||||||
|
Reference in New Issue
Block a user