1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

v2: update ident name for resolved const/fn objects

This commit is contained in:
Joe Conigliaro 2020-03-06 10:10:01 +11:00
parent 04d5dd8997
commit 7008b1a92c
2 changed files with 5 additions and 2 deletions

View File

@ -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
}

View File

@ -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
}