enable destructors for top level statements; needs to be documented
This commit is contained in:
parent
c1aecb8914
commit
3c461755e2
4 changed files with 27 additions and 6 deletions
|
|
@ -125,6 +125,10 @@ proc processImplicits(conf: ConfigRef; implicits: seq[string], nodeKind: TNodeKi
|
||||||
importStmt.addSon str
|
importStmt.addSon str
|
||||||
if not processTopLevelStmt(importStmt, a): break
|
if not processTopLevelStmt(importStmt, a): break
|
||||||
|
|
||||||
|
const
|
||||||
|
imperativeCode = {low(TNodeKind)..high(TNodeKind)} - {nkTemplateDef, nkProcDef, nkMethodDef,
|
||||||
|
nkMacroDef, nkConverterDef, nkIteratorDef, nkFuncDef}
|
||||||
|
|
||||||
proc processModule*(graph: ModuleGraph; module: PSym, stream: PLLStream): bool {.discardable.} =
|
proc processModule*(graph: ModuleGraph; module: PSym, stream: PLLStream): bool {.discardable.} =
|
||||||
if graph.stopCompile(): return true
|
if graph.stopCompile(): return true
|
||||||
var
|
var
|
||||||
|
|
@ -191,7 +195,22 @@ proc processModule*(graph: ModuleGraph; module: PSym, stream: PLLStream): bool {
|
||||||
sl = reorder(graph, sl, module)
|
sl = reorder(graph, sl, module)
|
||||||
discard processTopLevelStmt(sl, a)
|
discard processTopLevelStmt(sl, a)
|
||||||
break
|
break
|
||||||
elif not processTopLevelStmt(n, a): break
|
elif n.kind in imperativeCode:
|
||||||
|
# read everything until the next proc declaration etc.
|
||||||
|
var sl = newNodeI(nkStmtList, n.info)
|
||||||
|
sl.add n
|
||||||
|
var rest: PNode = nil
|
||||||
|
while true:
|
||||||
|
var n = parseTopLevelStmt(p)
|
||||||
|
if n.kind == nkEmpty or n.kind notin imperativeCode:
|
||||||
|
rest = n
|
||||||
|
break
|
||||||
|
sl.add n
|
||||||
|
if not processTopLevelStmt(sl, a): break
|
||||||
|
if rest != nil:
|
||||||
|
if not processTopLevelStmt(rest, a): break
|
||||||
|
else:
|
||||||
|
if not processTopLevelStmt(n, a): break
|
||||||
closeParsers(p)
|
closeParsers(p)
|
||||||
if s.kind != llsStdIn: break
|
if s.kind != llsStdIn: break
|
||||||
closePasses(graph, a)
|
closePasses(graph, a)
|
||||||
|
|
|
||||||
|
|
@ -1054,8 +1054,8 @@ proc transformStmt*(g: ModuleGraph; module: PSym, n: PNode): PNode =
|
||||||
when useEffectSystem: trackTopLevelStmt(g, module, result)
|
when useEffectSystem: trackTopLevelStmt(g, module, result)
|
||||||
#if n.info ?? "temp.nim":
|
#if n.info ?? "temp.nim":
|
||||||
# echo renderTree(result, {renderIds})
|
# echo renderTree(result, {renderIds})
|
||||||
#if c.needsDestroyPass:
|
if c.needsDestroyPass:
|
||||||
# result = injectDestructorCalls(g, module, result)
|
result = injectDestructorCalls(g, module, result)
|
||||||
incl(result.flags, nfTransf)
|
incl(result.flags, nfTransf)
|
||||||
|
|
||||||
proc transformExpr*(g: ModuleGraph; module: PSym, n: PNode): PNode =
|
proc transformExpr*(g: ModuleGraph; module: PSym, n: PNode): PNode =
|
||||||
|
|
@ -1067,6 +1067,6 @@ proc transformExpr*(g: ModuleGraph; module: PSym, n: PNode): PNode =
|
||||||
liftDefer(c, result)
|
liftDefer(c, result)
|
||||||
# expressions are not to be injected with destructor calls as that
|
# expressions are not to be injected with destructor calls as that
|
||||||
# the list of top level statements needs to be collected before.
|
# the list of top level statements needs to be collected before.
|
||||||
#if c.needsDestroyPass:
|
if c.needsDestroyPass:
|
||||||
# result = injectDestructorCalls(g, module, result)
|
result = injectDestructorCalls(g, module, result)
|
||||||
incl(result.flags, nfTransf)
|
incl(result.flags, nfTransf)
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ discard """
|
||||||
exitcode: 0
|
exitcode: 0
|
||||||
output: '''assingment
|
output: '''assingment
|
||||||
assingment
|
assingment
|
||||||
|
assingment
|
||||||
|
assingment
|
||||||
'''
|
'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,4 +59,4 @@ for x in getPony():
|
||||||
echo x
|
echo x
|
||||||
# XXX this needs to be enabled once top level statements
|
# XXX this needs to be enabled once top level statements
|
||||||
# produce destructor calls again.
|
# produce destructor calls again.
|
||||||
echo "Pony is dying!"
|
#echo "Pony is dying!"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue