AST change: keep nkStaticStmt in the AST for incremental compilation support
This commit is contained in:
parent
1ed7751dac
commit
9ab92824f6
4 changed files with 9 additions and 6 deletions
|
|
@ -2306,7 +2306,7 @@ proc expr(p: BProc, n: PNode, d: var TLoc) =
|
||||||
genTypeSection(p.module, n)
|
genTypeSection(p.module, n)
|
||||||
of nkCommentStmt, nkIteratorDef, nkIncludeStmt,
|
of nkCommentStmt, nkIteratorDef, nkIncludeStmt,
|
||||||
nkImportStmt, nkImportExceptStmt, nkExportStmt, nkExportExceptStmt,
|
nkImportStmt, nkImportExceptStmt, nkExportStmt, nkExportExceptStmt,
|
||||||
nkFromStmt, nkTemplateDef, nkMacroDef:
|
nkFromStmt, nkTemplateDef, nkMacroDef, nkStaticStmt:
|
||||||
discard
|
discard
|
||||||
of nkPragma: genPragma(p, n)
|
of nkPragma: genPragma(p, n)
|
||||||
of nkPragmaBlock: expr(p, n.lastSon, d)
|
of nkPragmaBlock: expr(p, n.lastSon, d)
|
||||||
|
|
|
||||||
|
|
@ -2155,7 +2155,7 @@ proc gen(p: PProc, n: PNode, r: var TCompRes) =
|
||||||
of nkRaiseStmt: genRaiseStmt(p, n)
|
of nkRaiseStmt: genRaiseStmt(p, n)
|
||||||
of nkTypeSection, nkCommentStmt, nkIteratorDef, nkIncludeStmt,
|
of nkTypeSection, nkCommentStmt, nkIteratorDef, nkIncludeStmt,
|
||||||
nkImportStmt, nkImportExceptStmt, nkExportStmt, nkExportExceptStmt,
|
nkImportStmt, nkImportExceptStmt, nkExportStmt, nkExportExceptStmt,
|
||||||
nkFromStmt, nkTemplateDef, nkMacroDef: discard
|
nkFromStmt, nkTemplateDef, nkMacroDef, nkStaticStmt: discard
|
||||||
of nkPragma: genPragma(p, n)
|
of nkPragma: genPragma(p, n)
|
||||||
of nkProcDef, nkFuncDef, nkMethodDef, nkConverterDef:
|
of nkProcDef, nkFuncDef, nkMethodDef, nkConverterDef:
|
||||||
var s = n.sons[namePos].sym
|
var s = n.sons[namePos].sym
|
||||||
|
|
|
||||||
|
|
@ -573,7 +573,8 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
|
||||||
message(c.config, v.info, hintGlobalVar)
|
message(c.config, v.info, hintGlobalVar)
|
||||||
if hasCompileTime:
|
if hasCompileTime:
|
||||||
vm.setupCompileTimeVar(c.module, c.graph, result)
|
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 =
|
proc semConst(c: PContext, n: PNode): PNode =
|
||||||
result = copyNode(n)
|
result = copyNode(n)
|
||||||
|
|
@ -1772,8 +1773,10 @@ proc semStaticStmt(c: PContext, n: PNode): PNode =
|
||||||
dec c.inStaticContext
|
dec c.inStaticContext
|
||||||
n.sons[0] = a
|
n.sons[0] = a
|
||||||
evalStaticStmt(c.module, c.graph, a, c.p.owner)
|
evalStaticStmt(c.module, c.graph, a, c.p.owner)
|
||||||
result = newNodeI(nkDiscardStmt, n.info, 1)
|
# for incremental replays, keep the AST as required for replays:
|
||||||
result.sons[0] = c.graph.emptyNode
|
result = n
|
||||||
|
#result = newNodeI(nkDiscardStmt, n.info, 1)
|
||||||
|
#result.sons[0] = c.graph.emptyNode
|
||||||
|
|
||||||
proc usesResult(n: PNode): bool =
|
proc usesResult(n: PNode): bool =
|
||||||
# nkStmtList(expr) properly propagates the void context,
|
# nkStmtList(expr) properly propagates the void context,
|
||||||
|
|
|
||||||
|
|
@ -863,7 +863,7 @@ proc transform(c: PTransf, n: PNode): PTransNode =
|
||||||
# ensure that e.g. discard "some comment" gets optimized away
|
# ensure that e.g. discard "some comment" gets optimized away
|
||||||
# completely:
|
# completely:
|
||||||
result = PTransNode(newNode(nkCommentStmt))
|
result = PTransNode(newNode(nkCommentStmt))
|
||||||
of nkCommentStmt, nkTemplateDef:
|
of nkCommentStmt, nkTemplateDef, nkImportStmt, nkStaticStmt:
|
||||||
return n.PTransNode
|
return n.PTransNode
|
||||||
of nkConstSection:
|
of nkConstSection:
|
||||||
# do not replace ``const c = 3`` with ``const 3 = 3``
|
# do not replace ``const c = 3`` with ``const 3 = 3``
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue