diff options
Diffstat (limited to 'ast.h')
| -rw-r--r-- | ast.h | 84 |
1 files changed, 51 insertions, 33 deletions
@@ -7,11 +7,11 @@ struct stmt_node; struct expr_node; struct type_node { - bool _unsigned; - bool _short; - bool _long; - struct type_def def; + bool is_unsigned; + bool is_short; + bool is_long; unsigned char ptr_level; + struct type_def* def; }; struct int_lit_node { @@ -37,8 +37,6 @@ struct var_ref_node { struct var_decl_node { struct type_node type; char* ident; - - struct var_decl_node* next; }; struct lval_node { @@ -47,9 +45,9 @@ struct lval_node { LVAL_VAR_REF, } type; union { - struct var_ref_node _var_ref; - struct var_decl_node _var_decl; - } as; + struct var_ref_node var_ref; + struct var_decl_node var_decl; + } inner; }; struct assign_node { @@ -57,10 +55,15 @@ struct assign_node { struct expr_node* rval; }; +struct args_eval_node { + struct expr_node* expr; + struct args_eval_node* next; +}; + struct call_node { /* TODO: eventually this could also be a function pointer */ - struct fn_decl_node* called_fn; - struct expr_node* args_head; + struct fn_decl_node* called_fn_ref; /* borrowed */ + struct args_eval_node* args; }; struct unary_node { @@ -94,29 +97,39 @@ struct expr_node { EXPR_BINARY, } type; union { - struct int_lit_node _int_lit; - struct float_lit_node _float_lit; - struct char_lit_node _char_lit; - struct str_lit_node _str_lit; - struct var_ref_node _var_ref; - struct assign_node _assign; - struct call_node _call; - struct unary_node _unary; - struct binary_node _binary; - } as; - - struct expr_node* next; + struct int_lit_node int_lit; + struct float_lit_node float_lit; + struct char_lit_node char_lit; + struct str_lit_node str_lit; + struct var_ref_node var_ref; + struct assign_node assign; + struct call_node call; + struct unary_node unary; + struct binary_node binary; + } inner; + + struct { + bool is_signed; + unsigned long long sz; + } evaluated_type; }; struct group_node { - struct stmt_node* body_head; + struct stmt_node* head; + struct scope* scope; +}; + +struct args_decl_node { + struct var_decl_node* decl; + struct args_decl_node* next; }; struct fn_decl_node { struct type_node return_type; char* name; - struct var_decl_node* args_head; + struct args_decl_node* args; struct group_node body; + struct scope* scope; }; struct return_node { @@ -132,11 +145,11 @@ struct stmt_node { STMT_GROUP, } type; union { - struct expr_node _expr; - struct var_decl_node _var_decl; - struct return_node _return; - struct group_node _group; - } as; + struct expr_node expr; + struct var_decl_node var_decl; + struct return_node return_; + struct group_node group; + } inner; struct stmt_node* next; }; @@ -146,12 +159,17 @@ struct root_node { ROOT_FN_DECL, } type; union { - struct fn_decl_node _fn_decl; - } as; + struct fn_decl_node fn_decl; + } inner; struct root_node* next; }; -void ast_destroy(struct root_node* head); +struct ast { + struct root_node* root_node; + struct scope* root_scope; +}; + +void ast_destroy(struct ast* ast); #endif |
