/* @! Separate out the codegen stage cause that can change @! Change type of Stage allocator @! Look into stage allocator and perhaps use it more often to reduce scenarios with 2 allocators, and simplify stuff @! Cleanup big int allocator @! Replace iterator interface @! Clean way to free all memory and reset the compiler @! Bring the Table<> @! Look into List, check if that's neccessary @! Compute time statistics inside context and expose them properly Probably want to implement a Red Black Tree then probably I wouldn't need any sort of heap based data structure. */ struct Lex_Stream{ String stream; S64 iter; U8 *line_begin; Intern_String file; S32 line; S32 inside_brace_paren; Array indent_stack; // @scratch_allocated }; struct Core_Ctx{ Allocator *heap; Push_Arena perm_push_only; Push_Arena *perm; // Stores: AST, tokens, interns Scratch_Arena *scratch; Scratch_Arena *stage_arena; // Lexer stuff Lex_Stream stream; Array tokens; Intern_Table interns; S64 token_iter; U32 token_debug_ids; // Types List all_types; S32 type_ids; int lambda_ids; U64 unique_ids; // @Debug Map type_map; Ast_Module *language_base_module; List files; List modules; List ordered_decls; S32 base_language_ordered_decl_len; Ast_Scope *currently_parsed_scope; Ast_File *currently_parsed_file; U32 scope_ids; U32 scope_visit_id; List module_folders; String module_folder; String exe_folder; String working_folder; List files_to_link; String_Builder helper_builder; F64 generating_time_begin; F64 generating_time_end; F64 resolving_time_begin; F64 resolving_time_end; F64 total_time; F64 init_ctx_time_begin; F64 init_ctx_time_end; F64 parsing_time_begin; F64 parsing_time_end; bool color_codes_enabled; // Codegen stage mostly S64 indent; String_Builder gen; // Codegen stage configurables bool emit_line_directives; bool emit_type_info; String symbol_prefix; bool single_header_library_mode; String single_header_library_name; Token same_scope_token; Token null_token; /*#import meta for i in meta.keywords: print(f'Intern_String keyword_{i.lower()};') for i in meta.interns: print(f'Intern_String intern_{i.lower()};') */ Intern_String keyword_struct; Intern_String keyword_union; Intern_String keyword_true; Intern_String keyword_default; Intern_String keyword_break; Intern_String keyword_false; Intern_String keyword_return; Intern_String keyword_switch; Intern_String keyword_assert; Intern_String keyword_if; Intern_String keyword_elif; Intern_String keyword_pass; Intern_String keyword_else; Intern_String keyword_for; Intern_String keyword_enum; Intern_String intern_typeof; Intern_String intern_sizeof; Intern_String intern_len; Intern_String intern_alignof; Intern_String intern_foreign; Intern_String intern_strict; Intern_String intern_void; Intern_String intern_flag; Intern_String intern_it; Intern_String intern_load; Intern_String intern_import; Intern_String intern_link; /*END*/ Intern_String intern(String string){ assert(string.len > 0); return intern_string(&interns, string); } }; CORE_Static void init_type(); CORE_Static String compile_to_c_code(); CORE_Static Ast_Module *ast_module(Token *pos, Intern_String filename); CORE_Static void insert_builtin_types_into_scope(Ast_Scope *p); CORE_Static void insert_into_scope(Ast_Scope *scope, Ast_Decl *decl); CORE_Static Ast_Type *type_incomplete(Ast *ast); CORE_Static Ast_Expr *parse_expr(S64 minbp = 0);