#ifndef TABLE_H #define TABLE_H #include #include /*defined constants*/ #define START_TABLE_SIZE 128 #define NAME_MAX_LENGTH 30 // a list of all type typedef enum enumVarType {INT, FLOAT} enumVarType; // a list of all type's sizes extern int memorySizes[2] = {1,1}; // TODO : PROBLEM DOES'NT COMPILE typedef struct { char name[NAME_MAX_LENGTH]; bool init; enumVarType varType; int offset; int depth; } Symbol; /*============================ Array and Reallocation ============================*/ /*reallocates the array with the specified size*/ void reallocateArray(int size); /*Checks for the length of the array and reallocates if necessary*/ void checkArraySanity(); /* /!\ To be called at the beginning * Initializes the array of Symbols*/ void initSymbolTable(); /*============================ Element Management ============================*/ /* removes all symbols associated with the current Depth*/ void clearOutOfScopeVariable(); /* Adds an element */ void addElement(char* name, enumVarType type); /*creates a new structure and updates variables*/ Symbol createNewStructure(char* name, enumVarType type); /*============================ Element Edition ============================*/ /* Toggles the init state of the symbol */ void toggleInit(char *name); /*============================ Element Access ============================*/ /* Returns the index with this name*/ int getIndex(char* name); /* Returns the structure with this name */ Symbol getStruct(char* name); /* Returns the offset from EBP to the symbol in the stack */ int getOffset(char* name); /*========================== Flow/Block control =========================*/ /*increases the depth (i.e. when entering a block)*/ void increaseDepth(); /*decreases the depth (i.e. when leaving a block)*/ void decreaseDepth(); /*============================================ Display, Todo : put in another .h file ============================================*/ void error(char* mess); void line(); void doubleLine(); #endif