parent
7c08303faf
commit
0b2a3f6f7f
2 changed files with 34 additions and 7 deletions
|
|
@ -388,16 +388,28 @@ proc genIf(c: PCtx, n: PNode; dest: var TDest) =
|
||||||
for endPos in endings: c.patch(endPos)
|
for endPos in endings: c.patch(endPos)
|
||||||
c.clearDest(n, dest)
|
c.clearDest(n, dest)
|
||||||
|
|
||||||
|
proc isTemp(c: PCtx; dest: TDest): bool =
|
||||||
|
result = dest >= 0 and c.prc.slots[dest].kind >= slotTempUnknown
|
||||||
|
|
||||||
proc genAndOr(c: PCtx; n: PNode; opc: TOpcode; dest: var TDest) =
|
proc genAndOr(c: PCtx; n: PNode; opc: TOpcode; dest: var TDest) =
|
||||||
# asgn dest, a
|
# asgn dest, a
|
||||||
# tjmp|fjmp L1
|
# tjmp|fjmp L1
|
||||||
# asgn dest, b
|
# asgn dest, b
|
||||||
# L1:
|
# L1:
|
||||||
if dest < 0: dest = getTemp(c, n.typ)
|
let copyBack = dest < 0 or not isTemp(c, dest)
|
||||||
c.gen(n.sons[1], dest)
|
let tmp = if copyBack:
|
||||||
let L1 = c.xjmp(n, opc, dest)
|
getTemp(c, n.typ)
|
||||||
c.gen(n.sons[2], dest)
|
else:
|
||||||
|
TRegister dest
|
||||||
|
c.gen(n.sons[1], tmp)
|
||||||
|
let L1 = c.xjmp(n, opc, tmp)
|
||||||
|
c.gen(n.sons[2], tmp)
|
||||||
c.patch(L1)
|
c.patch(L1)
|
||||||
|
if dest < 0:
|
||||||
|
dest = tmp
|
||||||
|
elif copyBack:
|
||||||
|
c.gABC(n, opcAsgnInt, dest, tmp)
|
||||||
|
freeTemp(c, tmp)
|
||||||
|
|
||||||
proc canonValue*(n: PNode): PNode =
|
proc canonValue*(n: PNode): PNode =
|
||||||
result = n
|
result = n
|
||||||
|
|
@ -1469,9 +1481,6 @@ proc checkCanEval(c: PCtx; n: PNode) =
|
||||||
skIterator} and sfForward in s.flags:
|
skIterator} and sfForward in s.flags:
|
||||||
cannotEval(c, n)
|
cannotEval(c, n)
|
||||||
|
|
||||||
proc isTemp(c: PCtx; dest: TDest): bool =
|
|
||||||
result = dest >= 0 and c.prc.slots[dest].kind >= slotTempUnknown
|
|
||||||
|
|
||||||
template needsAdditionalCopy(n): untyped =
|
template needsAdditionalCopy(n): untyped =
|
||||||
not c.isTemp(dest) and not fitsRegister(n.typ)
|
not c.isTemp(dest) and not fitsRegister(n.typ)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -160,3 +160,21 @@ block:
|
||||||
["", "M", "MM", "MMM", "--", "-", "--", "---", "----", "--"],
|
["", "M", "MM", "MMM", "--", "-", "--", "---", "----", "--"],
|
||||||
]
|
]
|
||||||
doAssert encoding.len == 4
|
doAssert encoding.len == 4
|
||||||
|
|
||||||
|
# #10886
|
||||||
|
|
||||||
|
proc tor(): bool =
|
||||||
|
result = true
|
||||||
|
result = false or result
|
||||||
|
|
||||||
|
proc tand(): bool =
|
||||||
|
result = false
|
||||||
|
result = true and result
|
||||||
|
|
||||||
|
const
|
||||||
|
ctor = tor()
|
||||||
|
ctand = not tand()
|
||||||
|
|
||||||
|
static:
|
||||||
|
doAssert ctor
|
||||||
|
doAssert ctand
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue