/* @! 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; 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);