type checking for non as function calls might be working
This commit is contained in:
@ -173,10 +173,11 @@ definition:
|
||||
cur = CreateScope(cur, 0, 0);
|
||||
}AS L_PAREN {
|
||||
TableNode *parameter = getParameter(table_lookup(getAncestor(cur), getType(table_lookup(getAncestor(cur), $<words>1))));
|
||||
printdebug("%s", getType(parameter));
|
||||
if (parameter == undefined) {
|
||||
printdebug("function defined with as, but parameter is undefined at line %d, column %d", @1.first_line, @1.first_column);
|
||||
}else if(getAdInfoType(parameter) != TYPE_RECORD){
|
||||
printdebug("record: %s., primitive: %s.", getName(parameter), getName(recprime));
|
||||
printdebug("record: %s., primitive: %s.", getType(parameter), getName(recprime));
|
||||
printdebug("function defined with as, but parameter is type %s at line %d, column %d", getType(parameter),@1.first_line, @1.first_column);
|
||||
}else {
|
||||
for (TableNode* entry = getFirstEntry(getRecList(parameter)); entry!= NULL; entry = getNextEntry(entry)){
|
||||
@ -297,11 +298,11 @@ L_PAREN argument_list R_PAREN {$<integ>$ = $<integ>2; printdebug("ablock is %d",
|
||||
|
||||
argument_list:
|
||||
expression COMMA argument_list {
|
||||
CreateEntry(cur, NULL, $1, NULL);
|
||||
CreateEntry(cur, look_up(cur, $1), "", NULL);
|
||||
$<integ>$ = $<integ>3 + 1;
|
||||
printdebug("[ARGUMENT_LIST] argument list is %d", $<integ>$);}
|
||||
| expression {
|
||||
CreateEntry(cur, NULL, $1, NULL);
|
||||
CreateEntry(cur, look_up(cur, $1), "", NULL);
|
||||
$<integ>$ = 1; printdebug("[ARGUMENT_LIST] argument list is %d", $<integ>$);}
|
||||
;
|
||||
|
||||
@ -402,8 +403,8 @@ assignable:
|
||||
}
|
||||
//this isn't very efficient, but will hopefully work
|
||||
while (lastCheckedAct != NULL && lastCheckedRef != NULL) {
|
||||
if (strcmp(getName(lastCheckedAct), getName(lastCheckedRef)) != 0) {
|
||||
printdebug("expected %s expression in function call but got %s at line %d and column %d",getName(lastCheckedRef), getName(lastCheckedAct), @3.first_line, @3.first_column);
|
||||
if (strcmp(getType(lastCheckedAct), getName(lastCheckedRef)) != 0) {
|
||||
printdebug("expected %s expression in function call but got %s at line %d and column %d",getType(lastCheckedRef), getName(lastCheckedAct), @3.first_line, @3.first_column);
|
||||
}
|
||||
lastCheckedAct = getNextEntry(lastCheckedAct);
|
||||
TableNode *tn = getFirstEntry(recList);
|
||||
@ -415,7 +416,7 @@ assignable:
|
||||
|
||||
} else {
|
||||
char *expected = getName(getParameter(look_up(getParent(cur), $1)));
|
||||
char *actual = getName(getFirstEntry(cur));
|
||||
char *actual = getType(getFirstEntry(cur));
|
||||
if (strcmp(expected, actual) != 0) {
|
||||
printdebug("expected %s expression in function call but got %s at line %d and column %d",expected, actual, @3.first_line, @3.first_column);
|
||||
}
|
||||
|
Reference in New Issue
Block a user