make koch.nim compile with --newruntime. Again.
This commit is contained in:
parent
0e57b4cf64
commit
e33266ded1
1 changed files with 16 additions and 3 deletions
|
|
@ -515,6 +515,11 @@ proc pArg(arg: PNode; c: var Con; isSink: bool): PNode =
|
||||||
result = p(arg, c)
|
result = p(arg, c)
|
||||||
|
|
||||||
proc moveOrCopy(dest, ri: PNode; c: var Con): PNode =
|
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 =
|
template moveOrCopyIfTyped(riPart: PNode): PNode =
|
||||||
# typ is nil if we are in if/case expr branch with noreturn
|
# typ is nil if we are in if/case expr branch with noreturn
|
||||||
if riPart.typ == nil: p(riPart, c)
|
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 = genCopy(c, dest.typ, dest, ri)
|
||||||
result.add p(ri, c)
|
result.add p(ri, c)
|
||||||
of nkHiddenSubConv, nkHiddenStdConv:
|
of nkHiddenSubConv, nkHiddenStdConv:
|
||||||
let harmless = ri[1].kind in (nkCallKinds + {nkSym, nkTupleConstr, nkObjConstr,
|
if ri[1].kind in movableNodeKinds:
|
||||||
nkBracket, nkBracketExpr, nkNilLit})
|
|
||||||
if harmless:
|
|
||||||
result = moveOrCopy(dest, ri[1], c)
|
result = moveOrCopy(dest, ri[1], c)
|
||||||
var b = newNodeIT(ri.kind, ri.info, ri.typ)
|
var b = newNodeIT(ri.kind, ri.info, ri.typ)
|
||||||
b.add ri[0] # add empty node
|
b.add ri[0] # add empty node
|
||||||
|
|
@ -633,6 +636,16 @@ proc moveOrCopy(dest, ri: PNode; c: var Con): PNode =
|
||||||
else:
|
else:
|
||||||
result = genCopy(c, dest.typ, dest, ri)
|
result = genCopy(c, dest.typ, dest, ri)
|
||||||
result.add p(ri, c)
|
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:
|
else:
|
||||||
# XXX At least string literals can be moved?
|
# XXX At least string literals can be moved?
|
||||||
result = genCopy(c, dest.typ, dest, ri)
|
result = genCopy(c, dest.typ, dest, ri)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue