From 1a6d2598a310862f79143d38e70a140abb7bb4c7 Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Mon, 13 Jun 2022 23:44:40 +0200 Subject: [PATCH] Fix spilling imports --- base.kl | 1 + main.kl | 9 ++++----- typechecking.cpp | 10 ++++++---- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/base.kl b/base.kl index b166720..19c77dc 100644 --- a/base.kl +++ b/base.kl @@ -1,4 +1,5 @@ Windows :: #import "Windows.kl" +#import "Windows.kl" SizeU :: #strict U64 OS_PAGE_SIZE :: 4096 diff --git a/main.kl b/main.kl index 9c475a0..c94d8bf 100644 --- a/main.kl +++ b/main.kl @@ -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) diff --git a/typechecking.cpp b/typechecking.cpp index 313a9e8..e76799b 100644 --- a/typechecking.cpp +++ b/typechecking.cpp @@ -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; }