thoughts about implicit includes and imports

This commit is contained in:
Araq 2011-11-29 08:49:17 +01:00
commit 31a994cc10

View file

@ -134,6 +134,15 @@ proc closePassesCached(a: var TPassContextArray) =
m = gPasses[i].close(a[i], m) m = gPasses[i].close(a[i], m)
a[i] = nil # free the memory here 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, proc processModule(module: PSym, filename: string, stream: PLLStream,
rd: PRodReader) = rd: PRodReader) =
var var
@ -153,16 +162,12 @@ proc processModule(module: PSym, filename: string, stream: PLLStream,
openParsers(p, filename, s) openParsers(p, filename, s)
if sfSystemModule notin module.flags: if sfSystemModule notin module.flags:
template processImplicits(implicits, nodeKind: expr): stmt = # XXX what about caching? no processing then? what if I change the
for module in items(implicits): # modules to include between compilation runs? we'd need to track that
var importStmt = newNodeI(nodeKind, gCmdLineInfo) # in ROD files. I think we should enable this feature only
var str = newStrNode(nkStrLit, module) # for the interactive mode.
str.info = gCmdLineInfo processImplicits implicitImports, nkImportStmt, a
importStmt.addSon str processImplicits implicitIncludes, nkIncludeStmt, a
processTopLevelStmt importStmt, a
processImplicits implicitImports, nkImportStmt
processImplicits implicitIncludes, nkIncludeStmt
while true: while true:
var n = parseTopLevelStmt(p) var n = parseTopLevelStmt(p)