1
0
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:
Nicolas Sauzede
2020-02-05 06:12:33 +01:00
committed by GitHub
parent c595c9eee1
commit 9d4c943d64
3 changed files with 27 additions and 0 deletions

View File

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