From 7008b1a92c6d0d6e06ef235ed45ee87e45b9f10d Mon Sep 17 00:00:00 2001 From: Joe Conigliaro Date: Fri, 6 Mar 2020 10:10:01 +1100 Subject: [PATCH] v2: update ident name for resolved const/fn objects --- vlib/v/ast/ast.v | 2 +- vlib/v/checker/checker.v | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/vlib/v/ast/ast.v b/vlib/v/ast/ast.v index 97feb876a4..dfddc60056 100644 --- a/vlib/v/ast/ast.v +++ b/vlib/v/ast/ast.v @@ -248,12 +248,12 @@ pub enum IdentKind { // A single identifier pub struct Ident { pub: - name string value string is_c bool tok_kind token.Kind pos token.Position mut: + name string kind IdentKind info IdentInfo } diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 373615bcaf..ddac2c378c 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -649,9 +649,9 @@ pub fn (c mut Checker) ident(ident mut ast.Ident) table.Type { if !name.contains('.') && !(c.file.mod.name in ['builtin', 'main']) { name = '${c.file.mod.name}.$ident.name' } - // println('# name: $name') // constant if constant := c.table.find_const(name) { + ident.name = name ident.kind = .constant ident.info = ast.IdentVar{ typ: constant.typ @@ -660,6 +660,7 @@ pub fn (c mut Checker) ident(ident mut ast.Ident) table.Type { } // Function object (not a call), e.g. `onclick(my_click)` if func := c.table.find_fn(name) { + ident.name = name ident.kind = .function ident.info = ast.IdentFunc{ return_type: func.return_type @@ -667,6 +668,8 @@ pub fn (c mut Checker) ident(ident mut ast.Ident) table.Type { return func.return_type } } + // TODO + // c.error('unknown ident: `$ident.name`', ident.pos) if ident.is_c { return table.int_type }