This commit is contained in:
Dominik Picheta 2017-02-01 21:11:40 +01:00
commit 3cbfd56e1d
4 changed files with 41 additions and 19 deletions

View file

@ -1585,12 +1585,21 @@ proc skipStmtList*(n: PNode): PNode =
result = n
proc toRef*(typ: PType): PType =
## If ``typ`` is a tyObject then it is converted into a `ref <typ>` and
## returned. Otherwise ``typ`` is simply returned as-is.
result = typ
if typ.kind == tyObject:
# Convert to a `ref T`.
result = newType(tyRef, typ.owner)
rawAddSon(result, typ)
proc toObject*(typ: PType): PType =
## If ``typ`` is a tyRef then its immediate son is returned (which in many
## cases should be a ``tyObject``).
## Otherwise ``typ`` is simply returned as-is.
result = typ
if result.kind == tyRef:
result = result.sons[0]
when false:
proc containsNil*(n: PNode): bool =
# only for debugging