diff options
author | Araq <rumpf_a@web.de> | 2019-04-12 19:59:04 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2019-04-12 19:59:04 +0200 |
commit | e33266ded1ad31cfd0776e6ec8d1a2c399994068 (patch) | |
tree | 9bd5b5707ced3360b891b1841ef254a55e566e49 | |
parent | 0e57b4cf6414f81e3fb2337fdd06b49990f7424f (diff) | |
download | Nim-e33266ded1ad31cfd0776e6ec8d1a2c399994068.tar.gz |
make koch.nim compile with --newruntime. Again.
-rw-r--r-- | compiler/injectdestructors.nim | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/compiler/injectdestructors.nim b/compiler/injectdestructors.nim index a65819cf0..865b64daa 100644 --- a/compiler/injectdestructors.nim +++ b/compiler/injectdestructors.nim @@ -515,6 +515,11 @@ proc pArg(arg: PNode; c: var Con; isSink: bool): PNode = result = p(arg, c) proc moveOrCopy(dest, ri: PNode; c: var Con): PNode = + # unfortunately, this needs to be kept consistent with the cases + # we handle in the 'case of' statement below: + const movableNodeKinds = (nkCallKinds + {nkSym, nkTupleConstr, nkObjConstr, + nkBracket, nkBracketExpr, nkNilLit}) + template moveOrCopyIfTyped(riPart: PNode): PNode = # typ is nil if we are in if/case expr branch with noreturn if riPart.typ == nil: p(riPart, c) @@ -621,9 +626,7 @@ proc moveOrCopy(dest, ri: PNode; c: var Con): PNode = result = genCopy(c, dest.typ, dest, ri) result.add p(ri, c) of nkHiddenSubConv, nkHiddenStdConv: - let harmless = ri[1].kind in (nkCallKinds + {nkSym, nkTupleConstr, nkObjConstr, - nkBracket, nkBracketExpr, nkNilLit}) - if harmless: + if ri[1].kind in movableNodeKinds: result = moveOrCopy(dest, ri[1], c) var b = newNodeIT(ri.kind, ri.info, ri.typ) b.add ri[0] # add empty node @@ -633,6 +636,16 @@ proc moveOrCopy(dest, ri: PNode; c: var Con): PNode = else: result = genCopy(c, dest.typ, dest, ri) result.add p(ri, c) + of nkObjDownConv, nkObjUpConv: + if ri[0].kind in movableNodeKinds: + result = moveOrCopy(dest, ri[0], c) + var b = newNodeIT(ri.kind, ri.info, ri.typ) + let L = result.len-1 + b.add result[L] + result[L] = b + else: + result = genCopy(c, dest.typ, dest, ri) + result.add p(ri, c) else: # XXX At least string literals can be moved? result = genCopy(c, dest.typ, dest, ri) |