diff options
author | Tucker Evans <tuckerevans24@gmail.com> | 2019-08-05 21:31:48 -0400 |
---|---|---|
committer | Tucker Evans <tuckerevans24@gmail.com> | 2019-08-16 19:10:49 -0400 |
commit | 7e29eae526f7a5014934b92a239923dd30835afd (patch) | |
tree | 92eb5137963d27b70c7ea82356434110154b2ab0 | |
parent | ee6c598892518d956388bb008095de6d4d7fe123 (diff) |
WIP Add function and array info to node struct
-rw-r--r-- | node.c | 3 | ||||
-rw-r--r-- | node.h | 13 | ||||
-rw-r--r-- | pc.y | 12 |
3 files changed, 27 insertions, 1 deletions
@@ -17,6 +17,9 @@ char *str; p->var_type = -1; + p->func_info = NULL; + p->array_info = NULL; + return p; } @@ -1,5 +1,15 @@ #ifndef NODE_H #define NODE_H +/*function/array info structs*/ +struct fi { + int argc; + int *argv; +}; + +struct ai { + int size; + int start_idx; +}; /* Linked list */ @@ -7,6 +17,9 @@ typedef struct node_s { char *name; struct node_s *next; int var_type; + + struct fi* func_info; + struct ai* array_info; } node; /*constructor*/ @@ -167,8 +167,18 @@ sub_prog_declaration sub_prog_head :FUNC ID arguments ':' standard_type ';' { + node *tmp; + int i = -1; + check_id(cur_scope->prev, $2); - scope_insert(cur_scope->prev, $2); + tmp = scope_insert(cur_scope->prev, $2); + + assert(tmp->func_info = malloc(sizeof struct fi)); + /*TODO add count of parameters*/ + tmp->func_info->argc = i; + assert(tmp->func_info->argv = malloc(i * sizeof int)); + + tmp->var_type = $5 cur_scope->ret_var = scope_insert(cur_scope, $2); cur_scope->ret_var->var_type = $5; |