fixed type checking issues I think
This commit is contained in:
@ -612,7 +612,7 @@ simple_statement:
|
||||
|
||||
|
||||
else {
|
||||
throw_error(ERROR_TYPE, "Object %s of type %s != Object %s of type %s", getName(node), getType(node), getName((TableNode*)$3), getType((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));
|
||||
}
|
||||
|
||||
$$ = undefined;
|
||||
@ -907,7 +907,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 && getName(arg_given)[0]!='&'){
|
||||
arg_given = getNextEntry(arg_given);
|
||||
}
|
||||
if(getTypeEntry(arg_given) != param_arg_type){
|
||||
@ -927,14 +927,22 @@ assignable:
|
||||
}
|
||||
}
|
||||
}else{
|
||||
TableNode *actual = getTypeEntry(getFirstEntry(cur));
|
||||
if (expected == actual) {
|
||||
throw_error(ERROR_TYPE, "expected %s expression in function call but got %s", expected, actual);
|
||||
TableNode*actual_instance = getFirstEntry(cur);
|
||||
while(actual_instance != NULL && getName(actual_instance)[0] =='&'){
|
||||
actual_instance = getNextEntry(actual_instance);
|
||||
}
|
||||
if(actual_instance == NULL){
|
||||
throw_error(ERROR_TYPE, "Invalid function call. No arguments passed");
|
||||
break;
|
||||
}
|
||||
TableNode *actual = getTypeEntry(actual_instance);
|
||||
if (expected != actual) {
|
||||
throw_error(ERROR_TYPE, "expected %s expression in function call but got %s", getName(expected), getName(actual));
|
||||
}
|
||||
if ($3 != 1) {
|
||||
throw_error(ERROR_SYNTAX, "expected 1 argument but got %d", $3); }
|
||||
printTableNode(getReturn(getTypeEntry((TableNode*)$1)));
|
||||
|
||||
}
|
||||
char* temp = temp_var_gen();
|
||||
TableNode* typeNode2 = getReturn(getTypeEntry($1));
|
||||
int t = -1;
|
||||
@ -947,6 +955,7 @@ assignable:
|
||||
else if(getAdInfoType(typeNode2) == TYPE_RECORD_TYPE){
|
||||
t = TYPE_RECORD;
|
||||
}
|
||||
//this may need to be updated to provide the correct name of things
|
||||
else if(getAdInfoType(typeNode2) == TYPE_FUNCTION_TYPE){
|
||||
t = TYPE_FUNCTION_DECLARATION;
|
||||
}else{
|
||||
@ -957,7 +966,6 @@ assignable:
|
||||
$$ = node;
|
||||
//NOTE ADD ASSIGNMENT EMIT HERE (MIGHT NEED TO PUSH TO STACK for function call)
|
||||
printdebug("[ASSIGNABLE - RULE 2] assignable = type: %s | name_func = %s", getName(typeNode2), getName((TableNode*)$1));
|
||||
}
|
||||
} else if (type == TYPE_ARRAY_TYPE) {
|
||||
printdebug("%sEntering array call", COLOR_LIGHTGREEN);
|
||||
if (getNumArrDim(look_up(getParent(cur), getType((TableNode*)$1))) != $<integ>2) {
|
||||
|
Reference in New Issue
Block a user