aboutsummaryrefslogtreecommitdiff
path: root/src/index
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2020-11-16 21:30:18 +0100
committerDanielGavin <danielgavin5@hotmail.com>2020-11-16 21:30:18 +0100
commitee4a7f64bcb9d6d7b60d5495fc072b2a62b5f790 (patch)
tree4ff2c689e5e1456a514993bead6d3dcf4c6e1300 /src/index
parent1c2c7cd727bcc420d99741e1862573fa07294c90 (diff)
overloaded function work
Diffstat (limited to 'src/index')
-rw-r--r--src/index/build.odin8
-rw-r--r--src/index/clone.odin16
2 files changed, 19 insertions, 5 deletions
diff --git a/src/index/build.odin b/src/index/build.odin
index 8f3c114..f9529ba 100644
--- a/src/index/build.odin
+++ b/src/index/build.odin
@@ -5,6 +5,7 @@ import "core:os"
import "core:fmt"
import "core:odin/parser"
import "core:odin/ast"
+import "core:log"
import "core:odin/tokenizer"
import "shared:common"
@@ -35,7 +36,7 @@ build_static_index :: proc(allocator := context.allocator, config: ^common.Confi
}
//bit worried about using temp allocator here since we might overwrite all our temp allocator budget
- data, ok := os.read_entire_file(info.fullpath, context.allocator);
+ data, ok := os.read_entire_file(info.fullpath, context.temp_allocator);
if !ok {
return 1, false;
@@ -51,14 +52,13 @@ build_static_index :: proc(allocator := context.allocator, config: ^common.Confi
src = data,
};
- parser.parse_file(&p, &file);
+ ok = parser.parse_file(&p, &file);
uri := common.create_uri(info.fullpath, context.temp_allocator);
collect_symbols(&symbol_collection, file, uri.uri);
- delete(data);
-
+ common.free_ast_file(file);
return 0, false;
};
diff --git a/src/index/clone.odin b/src/index/clone.odin
index 0dcb0b9..a09f1b7 100644
--- a/src/index/clone.odin
+++ b/src/index/clone.odin
@@ -7,6 +7,16 @@ import "core:odin/ast"
import "core:strings"
import "core:log"
+new_type :: proc($T: typeid, pos, end: tokenizer.Pos, allocator := context.allocator) -> ^T {
+ n := mem.new(T);
+ n.pos = pos;
+ n.end = end;
+ n.derived = n^;
+ base: ^ast.Node = n; // dummy check
+ _ = base; // "Use" type to make -vet happy
+ return n;
+}
+
clone_type :: proc{
clone_node,
clone_expr,
@@ -72,7 +82,6 @@ clone_node :: proc(node: ^ast.Node, allocator := context.allocator) -> ^ast.Node
case Implicit:
case Undef:
case Basic_Lit:
-
case Ellipsis:
r := cast(^Ellipsis)res;
r.expr = clone_type(r.expr, allocator);
@@ -165,6 +174,11 @@ clone_node :: proc(node: ^ast.Node, allocator := context.allocator) -> ^ast.Node
case Typeid_Type:
r := cast(^Typeid_Type)res;
r.specialization = clone_type(r.specialization, allocator);
+ case Ternary_When_Expr:
+ r := cast(^Ternary_When_Expr)res;
+ r.x = clone_type(r.x);
+ r.cond = clone_type(r.cond);
+ r.y = clone_type(r.y);
case:
log.error("Unhandled node kind: %T", n);
}