Modifying the class hierarchy and removing globals, allocators, simplifying
This commit is contained in:
@@ -1,4 +1,13 @@
|
||||
|
||||
/*
|
||||
* Get rid of Scratch, move that concept onto the main context, create scratch memory from user allocator
|
||||
* Simplify allocators, only should be derived from the user allocator
|
||||
* Cleanup big int allocator
|
||||
* Replace iterator interface
|
||||
|
||||
* Reset compiler
|
||||
|
||||
*/
|
||||
|
||||
struct Lex_Stream{
|
||||
String stream;
|
||||
@@ -11,31 +20,19 @@ struct Lex_Stream{
|
||||
Array<Token *> indent_stack;
|
||||
};
|
||||
|
||||
struct Lexer{
|
||||
Arena *arena;
|
||||
struct Parse_Ctx{
|
||||
Arena *perm; // Stores: AST, tokens, interns
|
||||
Arena stage_arena;
|
||||
Arena scratch;
|
||||
|
||||
// Lexer stuff
|
||||
Lex_Stream stream;
|
||||
Array<Token> tokens;
|
||||
Intern_Table interns;
|
||||
S64 token_iter;
|
||||
U32 token_debug_ids;
|
||||
|
||||
Intern_String intern(String string){
|
||||
assert(string.len > 0);
|
||||
return intern_string(&interns, string);
|
||||
}
|
||||
};
|
||||
|
||||
// Lexer::interns::map::allocator - array allocator, resizing
|
||||
// Lexer::tokens - array allocator, resizing
|
||||
//
|
||||
// Parser::ast_arena - arena for asts
|
||||
// Lexer::interns::string_allocator - arena for interns
|
||||
//
|
||||
|
||||
struct Parse_Ctx:Lexer{
|
||||
Arena *perm; // Stores: AST, tokens, interns
|
||||
Arena stage_arena;
|
||||
|
||||
// Types
|
||||
List<Ast_Type *> all_types;
|
||||
S32 type_ids;
|
||||
int lambda_ids;
|
||||
@@ -63,10 +60,24 @@ struct Parse_Ctx:Lexer{
|
||||
S64 indent;
|
||||
String_Builder gen;
|
||||
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;
|
||||
|
||||
Intern_String intern(String string){
|
||||
assert(string.len > 0);
|
||||
return intern_string(&interns, string);
|
||||
}
|
||||
};
|
||||
|
||||
CORE_Static void init_type();
|
||||
CORE_Static void lex_init(Arena *token_string_arena, Arena *map_allocator, Lexer *l);
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user