thoughts about implicit includes and imports
This commit is contained in:
parent
455994664e
commit
31a994cc10
1 changed files with 16 additions and 11 deletions
|
|
@ -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)
|
||||||
|
|
@ -174,7 +179,7 @@ proc processModule(module: PSym, filename: string, stream: PLLStream,
|
||||||
closePasses(a)
|
closePasses(a)
|
||||||
# id synchronization point for more consistent code generation:
|
# id synchronization point for more consistent code generation:
|
||||||
IDsynchronizationPoint(1000)
|
IDsynchronizationPoint(1000)
|
||||||
else:
|
else:
|
||||||
openPassesCached(a, module, filename, rd)
|
openPassesCached(a, module, filename, rd)
|
||||||
var n = loadInitSection(rd)
|
var n = loadInitSection(rd)
|
||||||
for i in countup(0, sonsLen(n) - 1): processTopLevelStmtCached(n.sons[i], a)
|
for i in countup(0, sonsLen(n) - 1): processTopLevelStmtCached(n.sons[i], a)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue