Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Apr 7, 2020
1 parent 3643901 commit cb7b079
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions compiler/vmconv.nim
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,15 @@ proc fromLit*(a: PNode, T: typedesc): auto =
proc toLit*[T](a: T): PNode =
## generic type => PNode
## see also reverse operation `fromLit`
when T is string: result = newStrNode(nkStrLit, a)
elif T is Ordinal: result = newIntNode(nkIntLit, a.ord)
when T is string: newStrNode(nkStrLit, a)
elif T is Ordinal: newIntNode(nkIntLit, a.ord)
elif T is (proc): newNode(nkNilLit)
elif T is ref:
if a == nil: newNode(nkNilLit)
else: toLit(a[])
elif T is tuple:
result = newTree(nkTupleConstr)
for ai in fields(a): result.add toLit(ai)
elif T is (proc):
result = newNode(nkNilLit)
elif T is ref:
if a == nil:
result = newNode(nkNilLit)
else:
result = toLit(a[])
elif T is object:
result = newTree(nkObjConstr)
result.add(newNode(nkEmpty))
Expand Down

0 comments on commit cb7b079

Please sign in to comment.