Fix spilling imports

This commit is contained in:
Krzosa Karol
2022-06-13 23:44:40 +02:00
parent bc3d3d00ca
commit 1a6d2598a3
3 changed files with 11 additions and 9 deletions

View File

@@ -1,4 +1,5 @@
Windows :: #import "Windows.kl"
#import "Windows.kl"
SizeU :: #strict U64
OS_PAGE_SIZE :: 4096

View File

@@ -1,9 +1,8 @@
Base :: #load "base.kl"
Win :: #load "Windows.kl"
#import "base.kl"
main :: (argc: int, argv: **char): int
memory := Base.reserve(size = 10000)
handle := Win.GetStdHandle(Win.STD_OUTPUT_HANDLE)
memory := reserve(size = 10000)
handle := Windows.GetStdHandle(Windows.STD_OUTPUT_HANDLE)
string: *char = "hello world"
Win.WriteConsoleA(handle, string->*void, 11, 0, 0)
Windows.WriteConsoleA(handle, string->*void, 11, 0, 0)

View File

@@ -313,7 +313,7 @@ _rewrite_into_const(Ast *node, U64 ast_size, Value value){
}
function Ast_Decl *
_search_for_decl(Ast_Scope *scope, Intern_String name){
_search_for_decl(Ast_Scope *scope, Intern_String name, S32 level){
For(scope->decls){
if(it->name == name){
return it;
@@ -321,7 +321,9 @@ _search_for_decl(Ast_Scope *scope, Intern_String name){
}
For(scope->implicit_imports){
Ast_Decl *result = _search_for_decl(it, name);
Ast_Decl *result = 0;
if(scope->kind == AST_MODULE && level > 1);
else result = _search_for_decl(it, name, level+1);
if(result) return result;
}
@@ -332,13 +334,13 @@ function Ast_Decl *
search_for_decl(Ast_Scope *scope, Intern_String name, Search_Flag flags = 0){
Ast_Decl *result = 0;
for(Ast_Scope *it = scope; it; it=it->parent_scope){
result = _search_for_decl(it, name);
result = _search_for_decl(it, name, 0);
if(result) break;
if(is_flag_set(flags, SEARCH_ONLY_CURRENT_SCOPE)) break;
}
if(!result && !is_flag_set(flags, SEARCH_ONLY_CURRENT_SCOPE)){
result = _search_for_decl(scope->module, name);
result = _search_for_decl(scope->module, name, 0);
}
return result;
}