Getting packages out of resolve_name
This commit is contained in:
11
ccodegen.cpp
11
ccodegen.cpp
@@ -536,7 +536,7 @@ compile_files(Array<String> filename){
|
||||
parse_init(&ctx, scratch, &heap);
|
||||
|
||||
F64 parse_begin = os_time();
|
||||
Array<Ast_Package *> packages = {&heap};
|
||||
pctx->packages = {&heap};
|
||||
For(files){
|
||||
Scratch file_scratch;
|
||||
lex_restream(pctx, it.filecontent, it.filename);
|
||||
@@ -545,7 +545,8 @@ compile_files(Array<String> filename){
|
||||
// by default it's name of the file
|
||||
// but if you add [package name] then it's overwritten
|
||||
Token *token = token_get();
|
||||
it.name = token->file;
|
||||
String filename_without_ext = string_chop_last_period(token->file.s);
|
||||
it.name = pctx->intern(filename_without_ext);
|
||||
|
||||
if(token_is(SAME_SCOPE) && token_is_keyword(keyword_package, 1)){
|
||||
token_next(); token_next();
|
||||
@@ -553,13 +554,13 @@ compile_files(Array<String> filename){
|
||||
it.name = package_token->intern_val;
|
||||
}
|
||||
|
||||
Ast_Package *package = find_package(it.name, &packages);
|
||||
Ast_Package *package = find_package(it.name, &pctx->packages);
|
||||
if(package){
|
||||
package->decls.add(it.decls);
|
||||
} else {
|
||||
package = ast_package(token, &heap, it.name);
|
||||
insert_builtin_types_into_package(package);
|
||||
packages.add(package);
|
||||
pctx->packages.add(package);
|
||||
|
||||
}
|
||||
|
||||
@@ -582,7 +583,7 @@ compile_files(Array<String> filename){
|
||||
}
|
||||
F64 parse_end = os_time();
|
||||
|
||||
For(packages){
|
||||
For(pctx->packages){
|
||||
resolve_package(it);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user