finished more type check stuff and some loops
This commit is contained in:
@ -619,8 +619,8 @@ simple_statement:
|
||||
|
||||
|
||||
else {
|
||||
printf("%d\n",getAdInfoType((TableNode*)$1));
|
||||
printf("%d\n",getAdInfoType((TableNode*)$3));
|
||||
//printf("%d\n",getAdInfoType((TableNode*)$1));
|
||||
//printf("%d\n",getAdInfoType((TableNode*)$3));
|
||||
//printf("%d\n",getAdInfoType((TableNode*)$1));
|
||||
//printf("%d\n",getAdInfoType((TableNode*)$3));
|
||||
throw_error(ERROR_TYPE, "Assignable Assign Expression - Object %s of type %s != Object %s of type %s", getName(node), getType(node), getName((TableNode*)$3), getType((TableNode*)$3));
|
||||
@ -662,7 +662,8 @@ ablock:
|
||||
argument_list:
|
||||
//NEED TO EMIT PARAMETERS HERE. MAYBE USE STACK STRUCTURE
|
||||
expression{
|
||||
TableNode* arg = CreateEntry(cur, getAdInfoType((TableNode*)$1), getTypeEntry((TableNode*)$1), arg_var_gen(), NULL);
|
||||
char* name = arg_var_gen();
|
||||
TableNode* arg = CreateEntry(cur, getAdInfoType((TableNode*)$1), getTypeEntry((TableNode*)$1), name, NULL);
|
||||
emit_parameter(tn_or_const(NODE,arg));
|
||||
//S_Push(stack,current);
|
||||
//emit_detach();
|
||||
@ -673,8 +674,9 @@ argument_list:
|
||||
|
||||
| expression
|
||||
|
||||
{
|
||||
TableNode* arg = CreateEntry(cur, getAdInfoType((TableNode*)$1), getTypeEntry((TableNode*)$1), arg_var_gen(), NULL);
|
||||
{
|
||||
char* name = arg_var_gen();
|
||||
TableNode* arg = CreateEntry(cur, getAdInfoType((TableNode*)$1), getTypeEntry((TableNode*)$1), name, NULL);
|
||||
emit_parameter(tn_or_const(NODE,arg));
|
||||
//S_Push(stack,current);
|
||||
//emit_detach();
|
||||
@ -949,7 +951,7 @@ assignable:
|
||||
}else{
|
||||
TableNode* param_arg_type = getFirstEntry(getRecList(expected));
|
||||
TableNode* arg_given = getFirstEntry(cur);
|
||||
while(arg_given != NULL && getName(arg_given)[0]!='&'){
|
||||
while(arg_given != NULL && arg_given != undefined && getName(arg_given)[0]!='&'){
|
||||
arg_given = getNextEntry(arg_given);
|
||||
}
|
||||
if(getTypeEntry(arg_given) != getTypeEntry(param_arg_type)){
|
||||
@ -957,7 +959,7 @@ assignable:
|
||||
}
|
||||
param_arg_type = getNextEntry(param_arg_type);
|
||||
arg_given = getNextEntry(arg_given);
|
||||
while(arg_given != NULL && param_arg_type != NULL){
|
||||
while(arg_given != NULL && arg_given != undefined && param_arg_type != NULL){
|
||||
while(arg_given != NULL && getName(arg_given)[0]!='&'){
|
||||
arg_given = getNextEntry(arg_given);
|
||||
}
|
||||
@ -970,7 +972,7 @@ assignable:
|
||||
}
|
||||
}else{
|
||||
TableNode*actual_instance = getFirstEntry(cur);
|
||||
while(actual_instance != NULL && getName(actual_instance)[0] !='&'){
|
||||
while(actual_instance != NULL && actual_instance != undefined && getName(actual_instance)[0] !='&'){
|
||||
actual_instance = getNextEntry(actual_instance);
|
||||
}
|
||||
if(actual_instance == NULL){
|
||||
|
@ -27,7 +27,7 @@ char *temp_var_gen() {
|
||||
}
|
||||
char *arg_var_gen() {
|
||||
char *ret = calloc(9, sizeof(*ret));
|
||||
sprintf(ret, "&t%d", temp3_count);
|
||||
sprintf(ret, "&%d", temp3_count);
|
||||
temp3_count++;
|
||||
return ret;
|
||||
}
|
||||
@ -1216,6 +1216,9 @@ void print_symbol_table(SymbolTable *table, FILE *file_ptr) {
|
||||
}
|
||||
|
||||
for (; entry != NULL; entry = getNextEntry(entry)) {
|
||||
if((getName(entry)[0] == '$' || getName(entry)[0] == '&') && ir_flag == NULL){
|
||||
continue;
|
||||
}
|
||||
if (getAdInfoType(entry) == TYPE_ARRAY_TYPE) {
|
||||
char *arrayType = (char *)malloc(100);
|
||||
sprintf(arrayType, " %d -> %s", getNumArrDim(entry),
|
||||
|
@ -15,6 +15,8 @@
|
||||
#define SIZE_CHAR 1
|
||||
#define SIZE_BOOL 1
|
||||
|
||||
extern FILE *ir_flag;
|
||||
|
||||
struct TableNode;
|
||||
typedef struct TFList TFList;
|
||||
typedef struct CGNode CGNode;
|
||||
|
Reference in New Issue
Block a user