aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorTucker Evans <tuckerevans24@gmail.com>2019-09-12 20:00:18 -0400
committerTucker Evans <tuckerevans24@gmail.com>2019-09-12 20:00:18 -0400
commit7698efc6e34037c3b6ba2968e77c4e33df4b484e (patch)
treeb4e5e240c15a9942e6aacd0d9757bc7ce5db0729 /main.c
parentbb9070ca0d79d2314c25b83e4496f43488446734 (diff)
parentd8f19b2f532d0a0d7131c1141ca481fa2d08b946 (diff)
Merge branch 'master' into mem-management
Diffstat (limited to 'main.c')
-rw-r--r--main.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/main.c b/main.c
index 15135bb..246bfb0 100644
--- a/main.c
+++ b/main.c
@@ -134,6 +134,73 @@ char* msg;
return 0;
}
+int count_args(t)
+ptree *t;
+{
+ int r, l;
+
+ if (!t)
+ return 0;
+
+ if (t->type == LIST){
+ r = count_args(t->r);
+ l = count_args(t->l);
+ } else if (t->type != LIST) {
+ return 1;
+ } else {
+ fprintf(stderr, "PTR: %x\n", t);
+ yyerror("NOT A PARAMETER LIST\n");
+ }
+
+ return r + l;
+}
+
+int set_func_types(t, nxt, size)
+ptree *t;
+int size, *nxt;
+{
+ int tmp;
+
+ if (!t)
+ return size;
+
+ if (t->type == LIST){
+ tmp = set_func_types(t->l, nxt, size);
+ for (;size > tmp; --size) ++nxt;
+ size = set_func_types(t->r, nxt, size);
+ } else if (t->type == ID){
+ if (--size == -1)
+ yyerror("VARIABLE COUNT CHANGED!!!\n");
+
+ *nxt = t->attr.nval->var_type;
+ return size;
+ }
+ return size;
+}
+
+int get_call_types(t, nxt, size)
+ptree *t;
+int size, *nxt;
+{
+ int tmp;
+
+ if (!t)
+ return size;
+
+ if (t->type == LIST){
+ tmp = set_func_types(t->l, nxt, size);
+ for (;size > tmp; --size) ++nxt;
+ size = set_func_types(t->r, nxt, size);
+ } else {
+ if (--size == -1)
+ yyerror("VARIABLE COUNT CHANGED!!!\n");
+ set_ret_type(t);
+ *nxt = t->ret_type;
+ return size;
+ }
+ return size;
+}
+
int main()
{
#ifdef DEBUG_TYPES