Package is Decl

This commit is contained in:
Krzosa Karol
2022-06-12 19:54:37 +02:00
parent 31c2c00452
commit cdaf85438e
4 changed files with 29 additions and 24 deletions

View File

@@ -435,11 +435,7 @@ 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();
String filename_without_ext = {};
if(string_find(token->file.s, "."_s, MatchFlag_None, &filename_without_ext.len)){
filename_without_ext.str = token->file.str;
} else filename_without_ext = token->file.s;
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)){
@@ -450,14 +446,14 @@ compile_files(Array<String> filename){
Ast_Package *package = find_package(it.name, &pctx->packages);
if(package){
package->decls.add(it.decls);
package->scope->decls.add(it.decls);
} else {
package = ast_package(token, &heap, it.name);
insert_builtin_types_into_package(package);
pctx->packages.add(package);
}
pctx->currently_parsed_scope = package;
pctx->currently_parsed_scope = package->scope;
while(token_expect(SAME_SCOPE)){
Ast_Decl *decl = parse_decl(true);
if(!decl) break;
@@ -469,7 +465,7 @@ compile_files(Array<String> filename){
decl->state = DECL_RESOLVED;
}
insert_into_scope(package, decl);
insert_into_scope(package->scope, decl);
}
pctx->currently_parsed_scope = 0;