added enum return function

This commit is contained in:
Partho Bhattacharya
2025-03-26 10:54:04 -04:00
parent d817ceaf7d
commit d1f7041c31

View File

@ -40,13 +40,17 @@ typedef enum {
//Declaring what type a function is (what the parameters and output are) //Declaring what type a function is (what the parameters and output are)
TYPE_FUNCTION_TYPE, TYPE_FUNCTION_TYPE,
//The Type being pointed to by the first 4 above that only stores the size //The Type being pointed to by the first 4 above that only stores the size
TYPE_PRIMITIVE TYPE_PRIMITIVE,
//All else (NULL case likely)
TYPE_ALL_ELSE
} types; } types;
/* put in symbol_table.h /* put in symbol_table.h
typedef struct{ typedef struct{
int size; int size; if(strcmp(getType(tn),getName(integ))==0){
return
}
}primitive_info; }primitive_info;
typedef struct{ typedef struct{
@ -366,8 +370,46 @@ if(typeOf == NULL){
return newEntry; return newEntry;
} }
} }
/*
TableNode* integ;
TableNode* addr;
TableNode* chara;
TableNode* stri;
TableNode* boo;
TableNode* recprime;
TableNode* funtypeprime;
*/
char* getType(TableNode* tn) { return tn->theType->theName; } char* getType(TableNode* tn) { return tn->theType->theName; }
int getAdInfoType(TableNode* tn){
if(strcmp(getType(tn),getName(integ))==0){
return TYPE_PRIMITIVE;
}
if(strcmp(getType(tn),getName(addr))==0){
return TYPE_PRIMITIVE;
}
if(strcmp(getType(tn),getName(chara))==0){
return TYPE_PRIMITIVE;
}
if(strcmp(getType(tn),getName(stri))==0){
return TYPE_ARRAY;
}
if(strcmp(getType(tn),getName(boo))==0){
return TYPE_PRIMITIVE;
}
if(strcmp(getType(tn),getName(recprime))==0){
return TYPE_RECORD;
}
if(strcmp(getType(tn),getName(funtypeprime))==0){
return TYPE_FUNCTION_TYPE;
}
if(strcmp(getType(tn),getName(arrayprim))==0){
return TYPE_ARRAY;
}
else{
return TYPE_FUNCTION_DECLARATION;
}
}
char* getName(TableNode* tn) { return tn->theName; } char* getName(TableNode* tn) { return tn->theName; }
int getLine(SymbolTable* st) { return st->Line_Number; } int getLine(SymbolTable* st) { return st->Line_Number; }
int getColumn(SymbolTable* st) { return st->Column_Number; } int getColumn(SymbolTable* st) { return st->Column_Number; }