fixes #4139
This commit is contained in:
parent
39aef12446
commit
d1f5e3b110
1 changed files with 15 additions and 8 deletions
|
|
@ -1755,8 +1755,7 @@ proc genMagic(p: PProc, n: PNode, r: var TCompRes) =
|
||||||
binaryExpr(p, n, r, "addChar",
|
binaryExpr(p, n, r, "addChar",
|
||||||
"if ($1 != null) { addChar($1, $2); } else { $1 = [$2, 0]; }")
|
"if ($1 != null) { addChar($1, $2); } else { $1 = [$2, 0]; }")
|
||||||
else:
|
else:
|
||||||
binaryExpr(p, n, r, "",
|
binaryExpr(p, n, r, "", "$1 .= chr($2)")
|
||||||
"$1 .= chr($2)")
|
|
||||||
of mAppendStrStr:
|
of mAppendStrStr:
|
||||||
if p.target == targetJS:
|
if p.target == targetJS:
|
||||||
if skipTypes(n.sons[1].typ, abstractVarRange).kind == tyCString:
|
if skipTypes(n.sons[1].typ, abstractVarRange).kind == tyCString:
|
||||||
|
|
@ -1766,15 +1765,23 @@ proc genMagic(p: PProc, n: PNode, r: var TCompRes) =
|
||||||
"if ($1 != null) { $1 = ($1.slice(0, -1)).concat($2); } else { $1 = $2;}")
|
"if ($1 != null) { $1 = ($1.slice(0, -1)).concat($2); } else { $1 = $2;}")
|
||||||
# XXX: make a copy of $2, because of Javascript's sucking semantics
|
# XXX: make a copy of $2, because of Javascript's sucking semantics
|
||||||
else:
|
else:
|
||||||
binaryExpr(p, n, r, "",
|
binaryExpr(p, n, r, "", "$1 .= $2;")
|
||||||
"$1 .= $2;")
|
|
||||||
of mAppendSeqElem:
|
of mAppendSeqElem:
|
||||||
if p.target == targetJS:
|
if p.target == targetJS:
|
||||||
binaryExpr(p, n, r, "",
|
var x, y: TCompRes
|
||||||
"if ($1 != null) { $1.push($2); } else { $1 = [$2]; }")
|
gen(p, n.sons[1], x)
|
||||||
|
gen(p, n.sons[2], y)
|
||||||
|
if needsNoCopy(p, n[2]):
|
||||||
|
r.res = "if ($1 != null) { $1.push($2); } else { $1 = [$2]; }" % [x.rdLoc, y.rdLoc]
|
||||||
else:
|
else:
|
||||||
binaryExpr(p, n, r, "",
|
useMagic(p, "nimCopy")
|
||||||
"$1[] = $2")
|
let c = getTemp(p, defineInLocals=false)
|
||||||
|
lineF(p, "var $1 = nimCopy(null, $2, $3);$n",
|
||||||
|
[c, y.rdLoc, genTypeInfo(p, n[2].typ)])
|
||||||
|
r.res = "if ($1 != null) { $1.push($2); } else { $1 = [$2]; }" % [x.rdLoc, c]
|
||||||
|
r.kind = resExpr
|
||||||
|
else:
|
||||||
|
binaryExpr(p, n, r, "", "$1[] = $2")
|
||||||
of mConStrStr:
|
of mConStrStr:
|
||||||
if p.target == targetJS:
|
if p.target == targetJS:
|
||||||
genConStrStr(p, n, r)
|
genConStrStr(p, n, r)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue