v2: update ident name for resolved const/fn objects
parent
04d5dd8997
commit
7008b1a92c
|
@ -248,12 +248,12 @@ pub enum IdentKind {
|
||||||
// A single identifier
|
// A single identifier
|
||||||
pub struct Ident {
|
pub struct Ident {
|
||||||
pub:
|
pub:
|
||||||
name string
|
|
||||||
value string
|
value string
|
||||||
is_c bool
|
is_c bool
|
||||||
tok_kind token.Kind
|
tok_kind token.Kind
|
||||||
pos token.Position
|
pos token.Position
|
||||||
mut:
|
mut:
|
||||||
|
name string
|
||||||
kind IdentKind
|
kind IdentKind
|
||||||
info IdentInfo
|
info IdentInfo
|
||||||
}
|
}
|
||||||
|
|
|
@ -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']) {
|
if !name.contains('.') && !(c.file.mod.name in ['builtin', 'main']) {
|
||||||
name = '${c.file.mod.name}.$ident.name'
|
name = '${c.file.mod.name}.$ident.name'
|
||||||
}
|
}
|
||||||
// println('# name: $name')
|
|
||||||
// constant
|
// constant
|
||||||
if constant := c.table.find_const(name) {
|
if constant := c.table.find_const(name) {
|
||||||
|
ident.name = name
|
||||||
ident.kind = .constant
|
ident.kind = .constant
|
||||||
ident.info = ast.IdentVar{
|
ident.info = ast.IdentVar{
|
||||||
typ: constant.typ
|
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)`
|
// Function object (not a call), e.g. `onclick(my_click)`
|
||||||
if func := c.table.find_fn(name) {
|
if func := c.table.find_fn(name) {
|
||||||
|
ident.name = name
|
||||||
ident.kind = .function
|
ident.kind = .function
|
||||||
ident.info = ast.IdentFunc{
|
ident.info = ast.IdentFunc{
|
||||||
return_type: func.return_type
|
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
|
return func.return_type
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// TODO
|
||||||
|
// c.error('unknown ident: `$ident.name`', ident.pos)
|
||||||
if ident.is_c {
|
if ident.is_c {
|
||||||
return table.int_type
|
return table.int_type
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue