More work on modules, Ast_Module, Ast_File and Ast_Scope got unified
This commit is contained in:
48
ccodegen.cpp
48
ccodegen.cpp
@@ -452,31 +452,31 @@ parse_file(Ast_File *file){
|
||||
}
|
||||
|
||||
function void
|
||||
insert_type_into_file(Ast_File *p, String name, Ast_Type *type){
|
||||
insert_builtin_into_scope(Ast_Scope *p, String name, Ast_Type *type){
|
||||
Intern_String string = pctx->intern(name);
|
||||
Ast_Decl *decl = ast_type(&null_token, string, type);
|
||||
Ast_Decl *decl = ast_type(0, string, type);
|
||||
decl->parent_scope = p;
|
||||
decl->state = DECL_RESOLVED;
|
||||
insert_into_scope(p, decl);
|
||||
}
|
||||
|
||||
function void
|
||||
insert_builtin_types_into_file(Ast_File *p){
|
||||
insert_type_into_file(p, "void"_s , type_void);
|
||||
insert_type_into_file(p, "Bool"_s , type_bool);
|
||||
insert_type_into_file(p, "String"_s, type_string);
|
||||
insert_type_into_file(p, "char"_s, type_char);
|
||||
insert_type_into_file(p, "int"_s, type_int);
|
||||
insert_type_into_file(p, "S8"_s, type_s8);
|
||||
insert_type_into_file(p, "S16"_s, type_s16);
|
||||
insert_type_into_file(p, "S32"_s, type_s32);
|
||||
insert_type_into_file(p, "S64"_s, type_s64);
|
||||
insert_type_into_file(p, "U8"_s, type_u8);
|
||||
insert_type_into_file(p, "U16"_s, type_u16);
|
||||
insert_type_into_file(p, "U32"_s, type_u32);
|
||||
insert_type_into_file(p, "U64"_s, type_u64);
|
||||
insert_type_into_file(p, "F32"_s, type_f32);
|
||||
insert_type_into_file(p, "F64"_s, type_f64);
|
||||
insert_builtin_types_into_scope(Ast_Scope *p){
|
||||
insert_builtin_into_scope(p, "void"_s , type_void);
|
||||
insert_builtin_into_scope(p, "Bool"_s , type_bool);
|
||||
insert_builtin_into_scope(p, "String"_s, type_string);
|
||||
insert_builtin_into_scope(p, "char"_s, type_char);
|
||||
insert_builtin_into_scope(p, "int"_s, type_int);
|
||||
insert_builtin_into_scope(p, "S8"_s, type_s8);
|
||||
insert_builtin_into_scope(p, "S16"_s, type_s16);
|
||||
insert_builtin_into_scope(p, "S32"_s, type_s32);
|
||||
insert_builtin_into_scope(p, "S64"_s, type_s64);
|
||||
insert_builtin_into_scope(p, "U8"_s, type_u8);
|
||||
insert_builtin_into_scope(p, "U16"_s, type_u16);
|
||||
insert_builtin_into_scope(p, "U32"_s, type_u32);
|
||||
insert_builtin_into_scope(p, "U64"_s, type_u64);
|
||||
insert_builtin_into_scope(p, "F32"_s, type_f32);
|
||||
insert_builtin_into_scope(p, "F64"_s, type_f64);
|
||||
}
|
||||
|
||||
global F64 parsing_time_begin;
|
||||
@@ -494,13 +494,11 @@ parse_all_modules(){
|
||||
parsing_time_begin = os_time();
|
||||
For(pctx->modules){
|
||||
parse_files(it);
|
||||
// @todo maybe add module?
|
||||
insert_builtin_types_into_file(it->all_loaded_files[0]);
|
||||
it->implicit_imports.add(pctx->builtins);
|
||||
}
|
||||
parsing_time_end = os_time();
|
||||
}
|
||||
|
||||
|
||||
function Ast_Module *
|
||||
add_module(Intern_String filename){
|
||||
For(pctx->modules){
|
||||
@@ -508,13 +506,7 @@ add_module(Intern_String filename){
|
||||
return it;
|
||||
}
|
||||
|
||||
Ast_Module *result = exp_alloc_type(pctx->perm, Ast_Module);
|
||||
result->kind = AST_MODULE;
|
||||
result->name = filename;
|
||||
result->all_loaded_files = {pctx->heap};
|
||||
result->implicit_loads = {pctx->heap};
|
||||
result->implicit_imports = {pctx->heap};
|
||||
|
||||
Ast_Module *result = ast_module(filename);
|
||||
register_ast_file(result->name, result, true);
|
||||
pctx->modules.add(result);
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user