diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2021-09-07 20:35:32 +0200 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2021-09-07 20:35:32 +0200 |
| commit | 610dffa617f9e2059ef533b3845a31a6daade10e (patch) | |
| tree | 6ee448e9a7ea3a742467e85c030ea2afa7d3d8fd /src | |
| parent | beb847bdb64ef80cb77e5f9d609c8ffedce6e963 (diff) | |
Add arena in static indexing, and add tests to check the builtin indexed files.
Diffstat (limited to 'src')
| -rw-r--r-- | src/index/build.odin | 16 | ||||
| -rw-r--r-- | src/testing/testing.odin | 3 |
2 files changed, 13 insertions, 6 deletions
diff --git a/src/index/build.odin b/src/index/build.odin index c45fa36..b6577cb 100644 --- a/src/index/build.odin +++ b/src/index/build.odin @@ -9,6 +9,7 @@ import "core:odin/ast" import "core:log" import "core:odin/tokenizer" import "core:strings" +import "core:mem" import "shared:common" @@ -84,11 +85,15 @@ build_static_index :: proc(allocator := context.allocator, config: ^common.Confi filepath.walk(builtin_package, walk_static_index_build); - context.allocator = context.temp_allocator; + temp_arena: mem.Arena; + + mem.init_arena(&temp_arena, make([]byte, mem.megabytes(100))); + + context.allocator = mem.arena_allocator(&temp_arena); for fullpath in files { - data, ok := os.read_entire_file(fullpath, context.temp_allocator); + data, ok := os.read_entire_file(fullpath, context.allocator); if !ok { log.errorf("failed to read entire file for indexing %v", fullpath); @@ -102,7 +107,7 @@ build_static_index :: proc(allocator := context.allocator, config: ^common.Confi //have to cheat the parser since it really wants to parse an entire package with the new changes... - dir := filepath.base(filepath.dir(fullpath, context.temp_allocator)); + dir := filepath.base(filepath.dir(fullpath, context.allocator)); pkg := new(ast.Package); pkg.kind = .Normal; @@ -126,17 +131,18 @@ build_static_index :: proc(allocator := context.allocator, config: ^common.Confi log.errorf("error in parse file for indexing %v", fullpath); } - uri := common.create_uri(fullpath, context.temp_allocator); + uri := common.create_uri(fullpath, context.allocator); //ERROR hover on uri does not show string collect_symbols(&symbol_collection, file, uri.uri); - free_all(context.temp_allocator); + free_all(context.allocator); delete(fullpath, allocator); } delete(files); + delete(temp_arena.data); indexer.static_index = make_memory_index(symbol_collection); } diff --git a/src/testing/testing.odin b/src/testing/testing.odin index 07bf75d..4720497 100644 --- a/src/testing/testing.odin +++ b/src/testing/testing.odin @@ -74,7 +74,8 @@ setup :: proc(src: ^Source) { There is a lot code here that is used in the real code, then i'd like to see. */ - index.indexer.static_index = index.make_memory_index(index.make_symbol_collection(context.allocator, &common.config)); + index.build_static_index(context.allocator, &common.config); + index.indexer.dynamic_index = index.make_memory_index(index.make_symbol_collection(context.allocator, &common.config)); for src_pkg in src.packages { |