mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
compiler: add very simple nameof token to get type name as string
This commit is contained in:
@@ -813,6 +813,15 @@ fn (p mut Parser) factor() string {
|
||||
// p.fgen('$sizeof_typ)')
|
||||
return 'int'
|
||||
}
|
||||
.key_nameof {
|
||||
p.next()
|
||||
p.check(.lpar)
|
||||
mut nameof_typ := p.get_type()
|
||||
p.check(.rpar)
|
||||
p.gen('tos3("$nameof_typ")')
|
||||
// return 'byteptr'
|
||||
return 'string'
|
||||
}
|
||||
.key_offsetof {
|
||||
p.next()
|
||||
p.check(.lpar)
|
||||
|
||||
Reference in New Issue
Block a user