Browse Source

Change import lookup

gingerBill 7 years ago
parent
commit
4e203feaf4
4 changed files with 10 additions and 6 deletions
  1. 2 2
      core/runtime/core.odin
  2. 1 0
      examples/demo/demo.odin
  3. 1 1
      src/check_expr.cpp
  4. 6 3
      src/parser.cpp

+ 2 - 2
core/runtime/core.odin

@@ -166,7 +166,7 @@ Allocator :: struct {
 
 
 Context :: struct {
-	allocator:  mem.Allocator,
+	allocator:  Allocator,
 	thread_id:  int,
 
 	user_data:  any,
@@ -494,7 +494,7 @@ __dynamic_array_reserve :: proc(array_: rawptr, elem_size, elem_align: int, cap:
 	new_size  := cap * elem_size;
 	allocator := array.allocator;
 
-	new_data := allocator.procedure(allocator.data, mem.Allocator_Mode.Resize, new_size, elem_align, array.data, old_size, 0, loc);
+	new_data := allocator.procedure(allocator.data, Allocator_Mode.Resize, new_size, elem_align, array.data, old_size, 0, loc);
 	if new_data == nil do return false;
 
 	array.data = new_data;

+ 1 - 0
examples/demo/demo.odin

@@ -14,6 +14,7 @@ import "core:strings"
 import "core:types"
 import "core:unicode/utf16"
 import "core:unicode/utf8"
+import "core:c"
 
 import "core:atomics"
 import "core:thread"

+ 1 - 1
src/check_expr.cpp

@@ -2583,7 +2583,7 @@ Entity *check_selector(Checker *c, Operand *operand, AstNode *node, Type *type_h
 			String entity_name = selector->Ident.token.string;
 
 			check_op_expr = false;
-			entity = scope_lookup_entity(import_scope, entity_name);
+			entity = current_scope_lookup_entity(import_scope, entity_name);
 			bool is_declared = entity != nullptr;
 			if (is_declared) {
 				if (entity->kind == Entity_Builtin) {

+ 6 - 3
src/parser.cpp

@@ -4366,6 +4366,11 @@ struct ParserThreadWork {
 	isize   import_index;
 };
 
+void add_shared_package(Parser *p, String name, TokenPos pos, PackageKind kind) {
+	String s = get_fullpath_core(heap_allocator(), name);
+	try_add_import_path(p, s, s, pos, kind);
+}
+
 ParseFileError parse_packages(Parser *p, String init_filename) {
 	GB_ASSERT(init_filename.text[init_filename.len] == 0);
 
@@ -4384,9 +4389,7 @@ ParseFileError parse_packages(Parser *p, String init_filename) {
 
 	isize shared_package_count = 0;
 	if (!build_context.generate_docs) {
-		String s = get_fullpath_core(heap_allocator(), str_lit("runtime"));
-		try_add_import_path(p, s, s, init_pos, Package_Runtime);
-		shared_package_count++;
+		add_shared_package(p, str_lit("runtime"), init_pos, Package_Runtime); shared_package_count++;
 	}
 
 	array_add(&p->imports, init_imported_package);