fixes #4526
This commit is contained in:
parent
64663387db
commit
e8aa6f6c30
1 changed files with 15 additions and 7 deletions
|
|
@ -85,6 +85,17 @@ proc mapTypeToBracketX(name: string; m: TMagic; t: PType; info: TLineInfo;
|
||||||
else:
|
else:
|
||||||
result.add mapTypeToAstX(t.sons[i], info, inst)
|
result.add mapTypeToAstX(t.sons[i], info, inst)
|
||||||
|
|
||||||
|
proc objectNode(n: PNode): PNode =
|
||||||
|
if n.kind == nkSym:
|
||||||
|
result = newNodeI(nkIdentDefs, n.info)
|
||||||
|
result.add n # name
|
||||||
|
result.add mapTypeToAstX(n.sym.typ, n.info, true, false) # type
|
||||||
|
result.add ast.emptyNode # no assigned value
|
||||||
|
else:
|
||||||
|
result = copyNode(n)
|
||||||
|
for i in 0 ..< n.safeLen:
|
||||||
|
result.add objectNode(n[i])
|
||||||
|
|
||||||
proc mapTypeToAstX(t: PType; info: TLineInfo;
|
proc mapTypeToAstX(t: PType; info: TLineInfo;
|
||||||
inst=false; allowRecursionX=false): PNode =
|
inst=false; allowRecursionX=false): PNode =
|
||||||
var allowRecursion = allowRecursionX
|
var allowRecursion = allowRecursionX
|
||||||
|
|
@ -167,7 +178,7 @@ proc mapTypeToAstX(t: PType; info: TLineInfo;
|
||||||
result = newNodeX(nkDistinctTy)
|
result = newNodeX(nkDistinctTy)
|
||||||
result.add mapTypeToAst(t.sons[0], info)
|
result.add mapTypeToAst(t.sons[0], info)
|
||||||
else:
|
else:
|
||||||
if allowRecursion or t.sym==nil:
|
if allowRecursion or t.sym == nil:
|
||||||
result = mapTypeToBracket("distinct", mDistinct, t, info)
|
result = mapTypeToBracket("distinct", mDistinct, t, info)
|
||||||
else:
|
else:
|
||||||
result = atomicType(t.sym.name.s, t.sym.magic)
|
result = atomicType(t.sym.name.s, t.sym.magic)
|
||||||
|
|
@ -177,16 +188,13 @@ proc mapTypeToAstX(t: PType; info: TLineInfo;
|
||||||
if inst:
|
if inst:
|
||||||
result = newNodeX(nkObjectTy)
|
result = newNodeX(nkObjectTy)
|
||||||
result.add ast.emptyNode # pragmas not reconstructed yet
|
result.add ast.emptyNode # pragmas not reconstructed yet
|
||||||
if t.sons[0]==nil: result.add ast.emptyNode # handle parent object
|
if t.sons[0] == nil: result.add ast.emptyNode # handle parent object
|
||||||
else:
|
else:
|
||||||
var nn = newNodeX(nkOfInherit)
|
var nn = newNodeX(nkOfInherit)
|
||||||
nn.add mapTypeToAst(t.sons[0], info)
|
nn.add mapTypeToAst(t.sons[0], info)
|
||||||
result.add nn
|
result.add nn
|
||||||
if t.n.sons.len>0:
|
if t.n.len > 0:
|
||||||
var rl = copyNode(t.n) # handle nkRecList
|
result.add objectNode(t.n)
|
||||||
for s in t.n.sons:
|
|
||||||
rl.add newIdentDefs(s)
|
|
||||||
result.add rl
|
|
||||||
else:
|
else:
|
||||||
result.add ast.emptyNode
|
result.add ast.emptyNode
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue