destructors; fixes #9594
This commit is contained in:
parent
bc26c08862
commit
234bed1b38
1 changed files with 12 additions and 2 deletions
|
|
@ -56,6 +56,7 @@ type
|
||||||
inCall, inTryStmt: int
|
inCall, inTryStmt: int
|
||||||
blocks: seq[TBlock]
|
blocks: seq[TBlock]
|
||||||
tryStmtFixups: seq[TPosition]
|
tryStmtFixups: seq[TPosition]
|
||||||
|
owner: PSym
|
||||||
|
|
||||||
proc debugInfo(info: TLineInfo): string =
|
proc debugInfo(info: TLineInfo): string =
|
||||||
result = $info.line #info.toFilename & ":" & $info.line
|
result = $info.line #info.toFilename & ":" & $info.line
|
||||||
|
|
@ -259,8 +260,15 @@ proc genRaise(c: var Con; n: PNode) =
|
||||||
else:
|
else:
|
||||||
c.code.add Instr(n: n, kind: goto, dest: high(int) - c.code.len)
|
c.code.add Instr(n: n, kind: goto, dest: high(int) - c.code.len)
|
||||||
|
|
||||||
|
proc genImplicitReturn(c: var Con) =
|
||||||
|
if c.owner.kind in {skProc, skFunc, skMethod, skIterator, skConverter} and resultPos < c.owner.ast.len:
|
||||||
|
gen(c, c.owner.ast.sons[resultPos])
|
||||||
|
|
||||||
proc genReturn(c: var Con; n: PNode) =
|
proc genReturn(c: var Con; n: PNode) =
|
||||||
if n.sons[0].kind != nkEmpty: gen(c, n.sons[0])
|
if n.sons[0].kind != nkEmpty:
|
||||||
|
gen(c, n.sons[0])
|
||||||
|
else:
|
||||||
|
genImplicitReturn(c)
|
||||||
c.code.add Instr(n: n, kind: goto, dest: high(int) - c.code.len)
|
c.code.add Instr(n: n, kind: goto, dest: high(int) - c.code.len)
|
||||||
|
|
||||||
const
|
const
|
||||||
|
|
@ -461,11 +469,13 @@ proc dfa(code: seq[Instr]; conf: ConfigRef) =
|
||||||
proc dataflowAnalysis*(s: PSym; body: PNode; conf: ConfigRef) =
|
proc dataflowAnalysis*(s: PSym; body: PNode; conf: ConfigRef) =
|
||||||
var c = Con(code: @[], blocks: @[])
|
var c = Con(code: @[], blocks: @[])
|
||||||
gen(c, body)
|
gen(c, body)
|
||||||
|
genImplicitReturn(c)
|
||||||
when defined(useDfa) and defined(debugDfa): echoCfg(c.code)
|
when defined(useDfa) and defined(debugDfa): echoCfg(c.code)
|
||||||
dfa(c.code, conf)
|
dfa(c.code, conf)
|
||||||
|
|
||||||
proc constructCfg*(s: PSym; body: PNode): ControlFlowGraph =
|
proc constructCfg*(s: PSym; body: PNode): ControlFlowGraph =
|
||||||
## constructs a control flow graph for ``body``.
|
## constructs a control flow graph for ``body``.
|
||||||
var c = Con(code: @[], blocks: @[])
|
var c = Con(code: @[], blocks: @[], owner: s)
|
||||||
gen(c, body)
|
gen(c, body)
|
||||||
|
genImplicitReturn(c)
|
||||||
shallowCopy(result, c.code)
|
shallowCopy(result, c.code)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue