#include "byte_defs.h" #include "types.h" #include "hash.h" #pragma once #define SYMBOL_MAP_S (1024*16) enum StatementTypes { ST_None = 0, // Not processed yet ST_Call = 1, // Any kind of function call ST_Builtin = 2, // All special builtins (declarations, control flow...) ST_Const = 3, // Constant ST_Var = 4, // Variable ST_Block = 5, // Scope blocks ST__end }; // Special expressions and ones that map directly to bytecode // Should mesh with StatementTypes enum BuiltinStatements { BI_assign = 6, BI_var = 7, BI_let = 8, BI_if = 9, BI_else = 10, BI_while = 11, BI_fn = 12, BI_import = 13, BI_add = 14, BI_sub = 15, BI_mul = 16, BI_div = 17, BI_mod = 18, BI_sml = 19, BI_sml_eq = 20, BI_eq = 21, BI_gt_eq = 22, BI_gt = 23, BI_not = 24, BI_and = 25, BI_or = 26, BI_is = 27, BI_cast = 28, BI_len = 29, BI_push = 30, BI_pop = 31, BI__end }; struct Statement { i32 type; i32 is_const; // Statement is constant, != is a constant - TODO : implem void **children; i32 child_n; union { Value cons; struct { i32 var_id; Tag var_type; }; FnSig *func; }; }; typedef struct Statement Statement; // In practice, this is allocated in parse.c typedef struct { // Kept for debug messages i32 curr_line; i32 curr_column; i32 max_statement; // Unused while parsing i32 curr_statement; HashMap symbol_map; i32 stack_size; Statement statements[]; } ASTStack; _Static_assert(BI_assign == ST__end);