fixes #1310
This commit is contained in:
parent
887a1ebe68
commit
21be7bf85a
3 changed files with 20 additions and 1 deletions
|
|
@ -138,6 +138,9 @@ proc createStrKeepNode(x: var TFullReg) =
|
||||||
template createStr(x) =
|
template createStr(x) =
|
||||||
x.node = newNode(nkStrLit)
|
x.node = newNode(nkStrLit)
|
||||||
|
|
||||||
|
template createSet(x) =
|
||||||
|
x.node = newNode(nkCurly)
|
||||||
|
|
||||||
proc moveConst(x: var TFullReg, y: TFullReg) =
|
proc moveConst(x: var TFullReg, y: TFullReg) =
|
||||||
if x.kind != y.kind:
|
if x.kind != y.kind:
|
||||||
myreset(x)
|
myreset(x)
|
||||||
|
|
@ -722,18 +725,22 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||||
regs[ra].intVal = ord(containsSets(a, b) and not equalSets(a, b))
|
regs[ra].intVal = ord(containsSets(a, b) and not equalSets(a, b))
|
||||||
of opcMulSet:
|
of opcMulSet:
|
||||||
decodeBC(rkNode)
|
decodeBC(rkNode)
|
||||||
|
createSet(regs[ra])
|
||||||
move(regs[ra].node.sons,
|
move(regs[ra].node.sons,
|
||||||
nimsets.intersectSets(regs[rb].node, regs[rc].node).sons)
|
nimsets.intersectSets(regs[rb].node, regs[rc].node).sons)
|
||||||
of opcPlusSet:
|
of opcPlusSet:
|
||||||
decodeBC(rkNode)
|
decodeBC(rkNode)
|
||||||
|
createSet(regs[ra])
|
||||||
move(regs[ra].node.sons,
|
move(regs[ra].node.sons,
|
||||||
nimsets.unionSets(regs[rb].node, regs[rc].node).sons)
|
nimsets.unionSets(regs[rb].node, regs[rc].node).sons)
|
||||||
of opcMinusSet:
|
of opcMinusSet:
|
||||||
decodeBC(rkNode)
|
decodeBC(rkNode)
|
||||||
|
createSet(regs[ra])
|
||||||
move(regs[ra].node.sons,
|
move(regs[ra].node.sons,
|
||||||
nimsets.diffSets(regs[rb].node, regs[rc].node).sons)
|
nimsets.diffSets(regs[rb].node, regs[rc].node).sons)
|
||||||
of opcSymdiffSet:
|
of opcSymdiffSet:
|
||||||
decodeBC(rkNode)
|
decodeBC(rkNode)
|
||||||
|
createSet(regs[ra])
|
||||||
move(regs[ra].node.sons,
|
move(regs[ra].node.sons,
|
||||||
nimsets.symdiffSets(regs[rb].node, regs[rc].node).sons)
|
nimsets.symdiffSets(regs[rb].node, regs[rc].node).sons)
|
||||||
of opcConcatStr:
|
of opcConcatStr:
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,12 @@
|
||||||
# assignments ('x = y'). For simple data types that fit into a register
|
# assignments ('x = y'). For simple data types that fit into a register
|
||||||
# this doesn't matter. However it matters for strings and other complex
|
# this doesn't matter. However it matters for strings and other complex
|
||||||
# types that use the 'node' field; the reason is that slots are
|
# types that use the 'node' field; the reason is that slots are
|
||||||
# re-used in a register based VM. XXX Come up with an example.
|
# re-used in a register based VM. Example:
|
||||||
|
#
|
||||||
|
# .. code-block:: nimrod
|
||||||
|
# let s = a & b # no matter what, create fresh node
|
||||||
|
# s = a & b # no matter what, keep the node
|
||||||
|
#
|
||||||
|
|
||||||
import
|
import
|
||||||
unsigned, strutils, ast, astalgo, types, msgs, renderer, vmdef,
|
unsigned, strutils, ast, astalgo, types, msgs, renderer, vmdef,
|
||||||
|
|
@ -1335,6 +1340,8 @@ proc genVarSection(c: PCtx; n: PNode) =
|
||||||
if a.sons[2].kind == nkEmpty:
|
if a.sons[2].kind == nkEmpty:
|
||||||
c.gABx(a, ldNullOpcode(s.typ), s.position, c.genType(s.typ))
|
c.gABx(a, ldNullOpcode(s.typ), s.position, c.genType(s.typ))
|
||||||
else:
|
else:
|
||||||
|
if not fitsRegister(s.typ):
|
||||||
|
c.gABx(a, ldNullOpcode(s.typ), s.position, c.genType(s.typ))
|
||||||
gen(c, a.sons[2], s.position.TRegister)
|
gen(c, a.sons[2], s.position.TRegister)
|
||||||
else:
|
else:
|
||||||
# assign to a.sons[0]; happens for closures
|
# assign to a.sons[0]; happens for closures
|
||||||
|
|
|
||||||
|
|
@ -16,4 +16,9 @@ const
|
||||||
|
|
||||||
echo "##", x, "##"
|
echo "##", x, "##"
|
||||||
|
|
||||||
|
# bug #1310
|
||||||
|
static:
|
||||||
|
var i, j: set[int8] = {}
|
||||||
|
var k = i + j
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue