parent
b64dd795b1
commit
28c9c062a4
4 changed files with 22 additions and 7 deletions
|
|
@ -355,6 +355,8 @@ proc semUnown(c: PContext; n: PNode): PNode =
|
||||||
|
|
||||||
result = copyTree(n[1])
|
result = copyTree(n[1])
|
||||||
result.typ = unownedType(c, result.typ)
|
result.typ = unownedType(c, result.typ)
|
||||||
|
# little hack for injectdestructors.nim (see bug #11350):
|
||||||
|
#result.sons[0].typ = nil
|
||||||
|
|
||||||
proc magicsAfterOverloadResolution(c: PContext, n: PNode,
|
proc magicsAfterOverloadResolution(c: PContext, n: PNode,
|
||||||
flags: TExprFlags): PNode =
|
flags: TExprFlags): PNode =
|
||||||
|
|
|
||||||
|
|
@ -501,7 +501,7 @@ proc genTry(c: PCtx; n: PNode; dest: var TDest) =
|
||||||
c.gen(n.sons[0], dest)
|
c.gen(n.sons[0], dest)
|
||||||
c.clearDest(n, dest)
|
c.clearDest(n, dest)
|
||||||
# Add a jump past the exception handling code
|
# Add a jump past the exception handling code
|
||||||
endings.add(c.xjmp(n, opcJmp, 0))
|
let jumpToFinally = c.xjmp(n, opcJmp, 0)
|
||||||
# This signals where the body ends and where the exception handling begins
|
# This signals where the body ends and where the exception handling begins
|
||||||
c.patch(ehPos)
|
c.patch(ehPos)
|
||||||
for i in 1 ..< n.len:
|
for i in 1 ..< n.len:
|
||||||
|
|
@ -525,6 +525,7 @@ proc genTry(c: PCtx; n: PNode; dest: var TDest) =
|
||||||
let fin = lastSon(n)
|
let fin = lastSon(n)
|
||||||
# we always generate an 'opcFinally' as that pops the safepoint
|
# we always generate an 'opcFinally' as that pops the safepoint
|
||||||
# from the stack if no exception is raised in the body.
|
# from the stack if no exception is raised in the body.
|
||||||
|
c.patch(jumpToFinally)
|
||||||
c.gABx(fin, opcFinally, 0, 0)
|
c.gABx(fin, opcFinally, 0, 0)
|
||||||
for endPos in endings: c.patch(endPos)
|
for endPos in endings: c.patch(endPos)
|
||||||
if fin.kind == nkFinally:
|
if fin.kind == nkFinally:
|
||||||
|
|
@ -2230,7 +2231,7 @@ proc genProc(c: PCtx; s: PSym): int =
|
||||||
c.gABC(body, opcEof, eofInstr.regA)
|
c.gABC(body, opcEof, eofInstr.regA)
|
||||||
c.optimizeJumps(result)
|
c.optimizeJumps(result)
|
||||||
s.offset = c.prc.maxSlots
|
s.offset = c.prc.maxSlots
|
||||||
# if s.name.s == "fun1":
|
#if s.name.s == "main":
|
||||||
# echo renderTree(body)
|
# echo renderTree(body)
|
||||||
# c.echoCode(result)
|
# c.echoCode(result)
|
||||||
c.prc = oldPrc
|
c.prc = oldPrc
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,10 @@ discard """
|
||||||
[127, 127, 0, 255]
|
[127, 127, 0, 255]
|
||||||
'''
|
'''
|
||||||
|
|
||||||
nimout: '''caught Exception'''
|
nimout: '''caught Exception
|
||||||
|
main:begin
|
||||||
|
main:end
|
||||||
|
'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
#bug #1009
|
#bug #1009
|
||||||
|
|
@ -69,3 +72,12 @@ block:
|
||||||
let x1 = fun1()
|
let x1 = fun1()
|
||||||
const x2 = fun1()
|
const x2 = fun1()
|
||||||
doAssert(x1 == x2)
|
doAssert(x1 == x2)
|
||||||
|
|
||||||
|
# bug #11610
|
||||||
|
proc simpleTryFinally()=
|
||||||
|
try:
|
||||||
|
echo "main:begin"
|
||||||
|
finally:
|
||||||
|
echo "main:end"
|
||||||
|
|
||||||
|
static: simpleTryFinally()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue