make rendering of typeof operator clearer; refs #3710
This commit is contained in:
parent
1fbeedaba2
commit
1a2867146b
1 changed files with 4 additions and 2 deletions
|
|
@ -438,7 +438,7 @@ proc lsub(n: PNode): int =
|
||||||
len("if_:_")
|
len("if_:_")
|
||||||
of nkElifExpr: result = lsons(n) + len("_elif_:_")
|
of nkElifExpr: result = lsons(n) + len("_elif_:_")
|
||||||
of nkElseExpr: result = lsub(n.sons[0]) + len("_else:_") # type descriptions
|
of nkElseExpr: result = lsub(n.sons[0]) + len("_else:_") # type descriptions
|
||||||
of nkTypeOfExpr: result = (if n.len > 0: lsub(n.sons[0]) else: 0)+len("type_")
|
of nkTypeOfExpr: result = (if n.len > 0: lsub(n.sons[0]) else: 0)+len("type()")
|
||||||
of nkRefTy: result = (if n.len > 0: lsub(n.sons[0])+1 else: 0) + len("ref")
|
of nkRefTy: result = (if n.len > 0: lsub(n.sons[0])+1 else: 0) + len("ref")
|
||||||
of nkPtrTy: result = (if n.len > 0: lsub(n.sons[0])+1 else: 0) + len("ptr")
|
of nkPtrTy: result = (if n.len > 0: lsub(n.sons[0])+1 else: 0) + len("ptr")
|
||||||
of nkVarTy: result = (if n.len > 0: lsub(n.sons[0])+1 else: 0) + len("var")
|
of nkVarTy: result = (if n.len > 0: lsub(n.sons[0])+1 else: 0) + len("var")
|
||||||
|
|
@ -1030,8 +1030,10 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext) =
|
||||||
putWithSpace(g, tkColon, ":")
|
putWithSpace(g, tkColon, ":")
|
||||||
gsub(g, n.sons[0])
|
gsub(g, n.sons[0])
|
||||||
of nkTypeOfExpr:
|
of nkTypeOfExpr:
|
||||||
putWithSpace(g, tkType, "type")
|
put(g, tkType, "type")
|
||||||
|
put(g, tkParLe, "(")
|
||||||
if n.len > 0: gsub(g, n.sons[0])
|
if n.len > 0: gsub(g, n.sons[0])
|
||||||
|
put(g, tkParRi, ")")
|
||||||
of nkRefTy:
|
of nkRefTy:
|
||||||
if sonsLen(n) > 0:
|
if sonsLen(n) > 0:
|
||||||
putWithSpace(g, tkRef, "ref")
|
putWithSpace(g, tkRef, "ref")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue