diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2021-12-11 21:22:09 +0100 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2021-12-11 21:22:09 +0100 |
| commit | c2c212d0436a6adc853435ca16b0339dfe15a14a (patch) | |
| tree | 241b75f71a72de9e6784bc3f007060b091c51908 /src/analysis | |
| parent | a4d291e9394cce1983be9d0c404d2a7703823001 (diff) | |
Support #caller location directive
Diffstat (limited to 'src/analysis')
| -rw-r--r-- | src/analysis/analysis.odin | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/analysis/analysis.odin b/src/analysis/analysis.odin index 11e3e58..d2cf071 100644 --- a/src/analysis/analysis.odin +++ b/src/analysis/analysis.odin @@ -785,6 +785,18 @@ resolve_basic_lit :: proc(ast_context: ^AstContext, basic_lit: ast.Basic_Lit) -> return symbol, true; } +resolve_basic_directive :: proc(ast_context: ^AstContext, directive: ast.Basic_Directive, a := #caller_location) -> (index.Symbol, bool) { + switch directive.name { + case "caller_location": + ident := index.new_type(ast.Ident, directive.pos, directive.end, context.temp_allocator); + ident.name = "Source_Code_Location"; + ast_context.current_package = ast_context.document_package; + return resolve_type_identifier(ast_context, ident^) + } + + return {}, false; +} + resolve_type_expression :: proc(ast_context: ^AstContext, node: ^ast.Expr) -> (index.Symbol, bool) { if node == nil { @@ -802,6 +814,8 @@ resolve_type_expression :: proc(ast_context: ^AstContext, node: ^ast.Expr) -> (i return make_symbol_map_from_ast(ast_context, v), true; case Proc_Type: return make_symbol_procedure_from_ast(ast_context, node, v, ast_context.field_name), true; + case Basic_Directive: + return resolve_basic_directive(ast_context, v); case Binary_Expr: return resolve_first_symbol_from_binary_expression(ast_context, &v); case Ident: |