diff options
author | Tucker Evans <tuckerevans24@gmail.com> | 2019-09-08 22:00:47 -0400 |
---|---|---|
committer | Tucker Evans <tuckerevans24@gmail.com> | 2019-09-11 13:10:58 -0400 |
commit | 6130381c23c2ca4e050e83b7a20e3ba56d0fc283 (patch) | |
tree | af2abb5436876d1f3a2c58bf91fc03805e4fc960 | |
parent | 948b0460c9d079e5eff4e6247d35aa946956e4a5 (diff) |
Adds type checking procedure arguments
-rw-r--r-- | pc.y | 2 | ||||
-rw-r--r-- | sem_check.c | 6 | ||||
-rw-r--r-- | sem_check.h | 2 | ||||
-rw-r--r-- | tree.c | 1 |
4 files changed, 9 insertions, 2 deletions
@@ -270,6 +270,7 @@ statement |proc_statement { $$ = $1; + check_call($$); } |compound_statement { @@ -346,6 +347,7 @@ proc_statement tmp = check_exists(cur_scope, $1); $$ = mktree(PCALL, mkid(tmp), $3); } + /*calls checked with proc_statement*/ ; expr_list diff --git a/sem_check.c b/sem_check.c index f6e412a..af97507 100644 --- a/sem_check.c +++ b/sem_check.c @@ -183,10 +183,12 @@ ptree *t; { int argc, *argv; - print_tree(t); - if (!(t && t->attr.nval && t->attr.nval->func_info)) + if (!(t && (t->type == FCALL || t->type == PCALL))) yyerror("Tree is not a function call\n"); + if (!(t->l && t->l->attr.nval && t->l->attr.nval->func_info)) + yyerror("Incorrect Call Tree\n"); + argc = t->l->attr.nval->func_info->argc; if (t->l->attr.nval->func_info->argc != count_args(t->r)) /*TODO add info about expected argument count*/ diff --git a/sem_check.h b/sem_check.h index ce7d7fb..0da2cc9 100644 --- a/sem_check.h +++ b/sem_check.h @@ -10,4 +10,6 @@ node* check_exists(scope*, char*); int check_ret_type(ptree*); +void check_call(ptree*); + #endif @@ -22,6 +22,7 @@ ptree *l, *r; t->l = l; t->r = r; t->ret_type = 0; + t->attr.nval = 0; return t; } |