File: tgettype.nim

package info (click to toggle)
nim 0.19.4-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 462,356 kB
  • sloc: sh: 11,089; ansic: 4,699; makefile: 706; python: 309; sql: 297; asm: 141; xml: 13
file content (27 lines) | stat: -rw-r--r-- 568 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
discard """
msg: '''ObjectTy(Sym(Model), RecList(Sym(name), Sym(password)))
BracketExpr(Sym(typeDesc), Sym(User))'''
"""
import strutils, macros

type
  Model = object of RootObj
  User = object of Model
    name : string
    password : string

macro testUser: string =
  result = newLit(User.getType.lispRepr)

macro testGeneric(T: typedesc[Model]): string=
  result = newLit(T.getType.lispRepr)

echo testUser
echo User.testGeneric

macro assertVoid(e: typed): untyped =
  assert(getTypeInst(e).typeKind == ntyVoid)

proc voidProc() = discard

assertVoid voidProc()