diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2018-06-02 09:41:27 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-06-02 09:41:27 +0200 |
commit | 826c1e2d7850026335d33e3be2fce54dee4f6698 (patch) | |
tree | 61b23c163c8cd9063ea8628798d727da404e1f1d /compiler/importer.nim | |
parent | cae19738562f14fbb76004748bed8d2f337d6f0b (diff) | |
download | Nim-826c1e2d7850026335d33e3be2fce54dee4f6698.tar.gz |
incremental compilation: implemented basic replay logic
Diffstat (limited to 'compiler/importer.nim')
-rw-r--r-- | compiler/importer.nim | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/compiler/importer.nim b/compiler/importer.nim index f30c23731..c013b93ab 100644 --- a/compiler/importer.nim +++ b/compiler/importer.nim @@ -133,7 +133,7 @@ proc importModuleAs(c: PContext; n: PNode, realModule: PSym): PSym = result = createModuleAlias(realModule, n.sons[1].ident, realModule.info, c.config.options) -proc myImportModule(c: PContext, n: PNode): PSym = +proc myImportModule(c: PContext, n: PNode; importStmtResult: PNode): PSym = var f = checkModuleName(c.config, n) if f != InvalidFileIDX: let L = c.graph.importStack.len @@ -147,7 +147,7 @@ proc myImportModule(c: PContext, n: PNode): PSym = err.add toFullPath(c.config, c.graph.importStack[i]) & " imports " & toFullPath(c.config, c.graph.importStack[i+1]) c.recursiveDep = err - result = importModuleAs(c, n, gImportModule(c.graph, c.module, f, c.cache)) + result = importModuleAs(c, n, c.graph.importModuleCallback(c.graph, c.module, f)) #echo "set back to ", L c.graph.importStack.setLen(L) # we cannot perform this check reliably because of @@ -162,9 +162,10 @@ proc myImportModule(c: PContext, n: PNode): PSym = else: message(c.config, n.info, warnDeprecated, result.name.s) suggestSym(c.config, n.info, result, c.graph.usageSym, false) + importStmtResult.add newStrNode(toFullPath(c.config, f), n.info) -proc impMod(c: PContext; it: PNode) = - let m = myImportModule(c, it) +proc impMod(c: PContext; it: PNode; importStmtResult: PNode) = + let m = myImportModule(c, it, importStmtResult) if m != nil: var emptySet: IntSet # ``addDecl`` needs to be done before ``importAllSymbols``! @@ -173,7 +174,8 @@ proc impMod(c: PContext; it: PNode) = #importForwarded(c, m.ast, emptySet) proc evalImport(c: PContext, n: PNode): PNode = - result = n + #result = n + result = newNodeI(nkImportStmt, n.info) for i in countup(0, sonsLen(n) - 1): let it = n.sons[i] if it.kind == nkInfix and it.len == 3 and it[2].kind == nkBracket: @@ -185,14 +187,14 @@ proc evalImport(c: PContext, n: PNode): PNode = a.add sep # dummy entry, replaced in the loop for x in it[2]: a.sons[2] = x - impMod(c, a) + impMod(c, a, result) else: - impMod(c, it) + impMod(c, it, result) proc evalFrom(c: PContext, n: PNode): PNode = - result = n + result = newNodeI(nkImportStmt, n.info) checkMinSonsLen(n, 2, c.config) - var m = myImportModule(c, n.sons[0]) + var m = myImportModule(c, n.sons[0], result) if m != nil: n.sons[0] = newSymNode(m) addDecl(c, m, n.info) # add symbol to symbol table of module @@ -201,9 +203,9 @@ proc evalFrom(c: PContext, n: PNode): PNode = importSymbol(c, n.sons[i], m) proc evalImportExcept*(c: PContext, n: PNode): PNode = - result = n + result = newNodeI(nkImportStmt, n.info) checkMinSonsLen(n, 2, c.config) - var m = myImportModule(c, n.sons[0]) + var m = myImportModule(c, n.sons[0], result) if m != nil: n.sons[0] = newSymNode(m) addDecl(c, m, n.info) # add symbol to symbol table of module |