AST change: keep nkStaticStmt in the AST for incremental compilation support

This commit is contained in:
Andreas Rumpf
2018-06-03 20:16:29 +02:00
parent 1ed7751dac
commit 9ab92824f6
4 changed files with 9 additions and 6 deletions

View File

@@ -2306,7 +2306,7 @@ proc expr(p: BProc, n: PNode, d: var TLoc) =
genTypeSection(p.module, n)
of nkCommentStmt, nkIteratorDef, nkIncludeStmt,
nkImportStmt, nkImportExceptStmt, nkExportStmt, nkExportExceptStmt,
nkFromStmt, nkTemplateDef, nkMacroDef:
nkFromStmt, nkTemplateDef, nkMacroDef, nkStaticStmt:
discard
of nkPragma: genPragma(p, n)
of nkPragmaBlock: expr(p, n.lastSon, d)

View File

@@ -2155,7 +2155,7 @@ proc gen(p: PProc, n: PNode, r: var TCompRes) =
of nkRaiseStmt: genRaiseStmt(p, n)
of nkTypeSection, nkCommentStmt, nkIteratorDef, nkIncludeStmt,
nkImportStmt, nkImportExceptStmt, nkExportStmt, nkExportExceptStmt,
nkFromStmt, nkTemplateDef, nkMacroDef: discard
nkFromStmt, nkTemplateDef, nkMacroDef, nkStaticStmt: discard
of nkPragma: genPragma(p, n)
of nkProcDef, nkFuncDef, nkMethodDef, nkConverterDef:
var s = n.sons[namePos].sym

View File

@@ -573,7 +573,8 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
message(c.config, v.info, hintGlobalVar)
if hasCompileTime:
vm.setupCompileTimeVar(c.module, c.graph, result)
c.graph.recordStmt(c.graph, c.module, result)
# handled by the VM codegen:
#c.graph.recordStmt(c.graph, c.module, result)
proc semConst(c: PContext, n: PNode): PNode =
result = copyNode(n)
@@ -1772,8 +1773,10 @@ proc semStaticStmt(c: PContext, n: PNode): PNode =
dec c.inStaticContext
n.sons[0] = a
evalStaticStmt(c.module, c.graph, a, c.p.owner)
result = newNodeI(nkDiscardStmt, n.info, 1)
result.sons[0] = c.graph.emptyNode
# for incremental replays, keep the AST as required for replays:
result = n
#result = newNodeI(nkDiscardStmt, n.info, 1)
#result.sons[0] = c.graph.emptyNode
proc usesResult(n: PNode): bool =
# nkStmtList(expr) properly propagates the void context,

View File

@@ -863,7 +863,7 @@ proc transform(c: PTransf, n: PNode): PTransNode =
# ensure that e.g. discard "some comment" gets optimized away
# completely:
result = PTransNode(newNode(nkCommentStmt))
of nkCommentStmt, nkTemplateDef:
of nkCommentStmt, nkTemplateDef, nkImportStmt, nkStaticStmt:
return n.PTransNode
of nkConstSection:
# do not replace ``const c = 3`` with ``const 3 = 3``