diff options
author | Araq <rumpf_a@web.de> | 2011-11-29 08:49:17 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-11-29 08:49:17 +0100 |
commit | 31a994cc107100c9c6f84455832ccce0b5fd9661 (patch) | |
tree | 217931fb8659b29a39135cd65edbcd4cb5eb09d7 | |
parent | 455994664ec838202df91592718442e478854aeb (diff) | |
download | Nim-31a994cc107100c9c6f84455832ccce0b5fd9661.tar.gz |
thoughts about implicit includes and imports
-rwxr-xr-x | compiler/passes.nim | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/compiler/passes.nim b/compiler/passes.nim index e24f82927..8e677b523 100755 --- a/compiler/passes.nim +++ b/compiler/passes.nim @@ -134,6 +134,15 @@ proc closePassesCached(a: var TPassContextArray) = m = gPasses[i].close(a[i], m) a[i] = nil # free the memory here +proc processImplicits(implicits: seq[string], nodeKind: TNodeKind, + a: var TPassContextArray) = + for module in items(implicits): + var importStmt = newNodeI(nodeKind, gCmdLineInfo) + var str = newStrNode(nkStrLit, module) + str.info = gCmdLineInfo + importStmt.addSon str + processTopLevelStmt importStmt, a + proc processModule(module: PSym, filename: string, stream: PLLStream, rd: PRodReader) = var @@ -153,16 +162,12 @@ proc processModule(module: PSym, filename: string, stream: PLLStream, openParsers(p, filename, s) if sfSystemModule notin module.flags: - template processImplicits(implicits, nodeKind: expr): stmt = - for module in items(implicits): - var importStmt = newNodeI(nodeKind, gCmdLineInfo) - var str = newStrNode(nkStrLit, module) - str.info = gCmdLineInfo - importStmt.addSon str - processTopLevelStmt importStmt, a - - processImplicits implicitImports, nkImportStmt - processImplicits implicitIncludes, nkIncludeStmt + # XXX what about caching? no processing then? what if I change the + # modules to include between compilation runs? we'd need to track that + # in ROD files. I think we should enable this feature only + # for the interactive mode. + processImplicits implicitImports, nkImportStmt, a + processImplicits implicitIncludes, nkIncludeStmt, a while true: var n = parseTopLevelStmt(p) @@ -174,7 +179,7 @@ proc processModule(module: PSym, filename: string, stream: PLLStream, closePasses(a) # id synchronization point for more consistent code generation: IDsynchronizationPoint(1000) - else: + else: openPassesCached(a, module, filename, rd) var n = loadInitSection(rd) for i in countup(0, sonsLen(n) - 1): processTopLevelStmtCached(n.sons[i], a) |