More work on modules, Ast_Module, Ast_File and Ast_Scope got unified
This commit is contained in:
18
compiler.h
18
compiler.h
@@ -1,3 +1,10 @@
|
||||
struct Ast_Scope;
|
||||
struct Ast_Decl;
|
||||
struct Ast_File_Namespace;
|
||||
struct Ast_File;
|
||||
struct Ast_Module;
|
||||
function Ast_Module *ast_module(Intern_String filename);
|
||||
function void insert_builtin_types_into_scope(Ast_Scope *p);
|
||||
|
||||
enum Token_Kind{
|
||||
TK_End,
|
||||
@@ -163,11 +170,6 @@ Intern_String intern_foreign;
|
||||
Intern_String intern_strict;
|
||||
Intern_String intern_flag;
|
||||
|
||||
struct Ast_Scope;
|
||||
struct Ast_Decl;
|
||||
struct Ast_File_Namespace;
|
||||
struct Ast_File;
|
||||
struct Ast_Module;
|
||||
struct Parse_Ctx:Lexer{
|
||||
Allocator *perm; // Stores: AST, tokens, interns
|
||||
Allocator *heap;
|
||||
@@ -175,6 +177,7 @@ struct Parse_Ctx:Lexer{
|
||||
U64 unique_ids;
|
||||
Map type_map;
|
||||
|
||||
Ast_Module *builtins;
|
||||
Array<Ast_Module *> modules;
|
||||
Ast_Scope *currently_parsed_scope;
|
||||
Ast_File *currently_parsed_file;
|
||||
@@ -218,6 +221,7 @@ lex_init(Allocator *token_string_arena, Allocator *map_allocator, Lexer *l){
|
||||
|
||||
function void
|
||||
parse_init(Parse_Ctx *ctx, Allocator *perm_allocator, Allocator *heap_allocator){
|
||||
pctx = ctx;
|
||||
ctx->perm = perm_allocator;
|
||||
ctx->heap = heap_allocator;
|
||||
ctx->gen = {ctx->perm};
|
||||
@@ -227,7 +231,9 @@ parse_init(Parse_Ctx *ctx, Allocator *perm_allocator, Allocator *heap_allocator)
|
||||
bigint_allocator = ctx->perm;
|
||||
|
||||
lex_init(ctx->perm, ctx->heap, ctx);
|
||||
pctx = ctx;
|
||||
|
||||
ctx->builtins = ast_module(ctx->intern("builtins"_s));
|
||||
insert_builtin_types_into_scope((Ast_Scope *)ctx->builtins);
|
||||
|
||||
init_type();
|
||||
}
|
||||
Reference in New Issue
Block a user