aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2021-04-02 12:36:57 +0200
committerDanielGavin <danielgavin5@hotmail.com>2021-04-02 12:36:57 +0200
commit111f6ccb5221734ba5ef8f95a03253df83df1a70 (patch)
tree4de0da6d45b1010c55b0146e8fe5e5e8938fa90a /src
parent8a760dfbebffbdd091508c026c26c792ef11bb29 (diff)
extract the distinct type in locals and globals
Diffstat (limited to 'src')
-rw-r--r--src/common/ast.odin1
-rw-r--r--src/server/analysis.odin13
2 files changed, 12 insertions, 2 deletions
diff --git a/src/common/ast.odin b/src/common/ast.odin
index 4f5850f..4f6a3c8 100644
--- a/src/common/ast.odin
+++ b/src/common/ast.odin
@@ -50,7 +50,6 @@ collect_value_decl :: proc(exprs: ^[dynamic]GlobalExpr, file: ast.File, stmt: ^a
}
}
-//TODO(add a sub procedure to avoid repeating the value decl work)
collect_globals :: proc(file: ast.File) -> []GlobalExpr {
exprs := make([dynamic]GlobalExpr, context.temp_allocator);
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index 5d7cc40..8e5f38b 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -742,6 +742,12 @@ resolve_type_identifier :: proc(ast_context: ^AstContext, node: ast.Ident) -> (i
//note(Daniel, if global and local ends up being 100% same just make a function that takes the map)
if local := get_local(ast_context, node.pos.offset, node.name); local != nil && ast_context.use_locals {
+ if dist, ok := local.derived.(ast.Distinct_Type); ok {
+ if dist.type != nil {
+ local = dist.type; //save information for overloading
+ }
+ }
+
switch v in local.derived {
case Ident:
@@ -775,10 +781,15 @@ resolve_type_identifier :: proc(ast_context: ^AstContext, node: ast.Ident) -> (i
case:
log.warnf("default type node kind: %T", v);
return resolve_type_expression(ast_context, local);
- //return make_symbol_generic_from_ast(ast_context, local), true;
}
} else if global, ok := ast_context.globals[node.name]; ast_context.use_globals && ok {
+ if dist, ok := global.derived.(ast.Distinct_Type); ok {
+ if dist.type != nil {
+ global = dist.type; //save information for overloading
+ }
+ }
+
switch v in global.derived {
case Ident: