New module scheme
This commit is contained in:
26
compiler.h
26
compiler.h
@@ -153,7 +153,6 @@ Intern_String keyword_if;
|
||||
Intern_String keyword_else;
|
||||
Intern_String keyword_true;
|
||||
Intern_String keyword_false;
|
||||
Intern_String keyword_package;
|
||||
Intern_String keyword_for;
|
||||
Intern_String keyword_pass;
|
||||
Intern_String keyword_cast;
|
||||
@@ -164,10 +163,25 @@ Intern_String intern_foreign;
|
||||
Intern_String intern_strict;
|
||||
Intern_String intern_flag;
|
||||
|
||||
|
||||
struct Ast_Scope;
|
||||
struct Ast_Decl;
|
||||
struct Ast_Package;
|
||||
struct Ast_File_Namespace;
|
||||
struct Ast_File;
|
||||
struct Ast_Module{
|
||||
Intern_String name;
|
||||
Array<Ast_File *> files;
|
||||
};
|
||||
|
||||
struct Ast_File{
|
||||
Intern_String filename;
|
||||
Ast_Module *module;
|
||||
|
||||
B32 global_implicit_load;
|
||||
String filecontent;
|
||||
Intern_String name;
|
||||
Ast_Scope *scope;
|
||||
};
|
||||
|
||||
struct Parse_Ctx:Lexer{
|
||||
Allocator *perm; // Stores: AST, tokens, interns
|
||||
Allocator *heap;
|
||||
@@ -175,8 +189,10 @@ struct Parse_Ctx:Lexer{
|
||||
U64 unique_ids;
|
||||
Map type_map;
|
||||
|
||||
Array<Ast_Package *> packages;
|
||||
Array<Ast_Module *> modules;
|
||||
Array<Ast_File_Namespace *> packages;
|
||||
Ast_Scope *currently_parsed_scope;
|
||||
Ast_File *currently_parsed_file;
|
||||
Array<Ast_Decl *> ordered_decls;
|
||||
|
||||
S64 indent;
|
||||
@@ -200,7 +216,6 @@ lex_init(Allocator *token_string_arena, Allocator *map_allocator, Lexer *l){
|
||||
keyword_cast = l->intern("cast"_s);
|
||||
keyword_true = l->intern("true"_s);
|
||||
keyword_false = l->intern("false"_s);
|
||||
keyword_package = l->intern("package"_s);
|
||||
keyword_return = l->intern("return"_s);
|
||||
keyword_if = l->intern("if"_s);
|
||||
keyword_pass = l->intern("pass"_s);
|
||||
@@ -223,6 +238,7 @@ parse_init(Parse_Ctx *ctx, Allocator *perm_allocator, Allocator *heap_allocator)
|
||||
ctx->gen = {ctx->perm};
|
||||
ctx->ordered_decls = {ctx->heap};
|
||||
ctx->type_map = {ctx->heap};
|
||||
ctx->modules = {ctx->heap};
|
||||
bigint_allocator = ctx->perm;
|
||||
|
||||
lex_init(ctx->perm, ctx->heap, ctx);
|
||||
|
||||
Reference in New Issue
Block a user