mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-07 04:14:19 +00:00
Added nimscript support to repl (#10834)
* added nimscript support to repl * added bool parameter to runRepl en/disabling nimscript support
This commit is contained in:
@@ -11,7 +11,8 @@
|
||||
import
|
||||
ast, astalgo, modules, passes, condsyms,
|
||||
options, sem, semdata, llstream, vm, vmdef,
|
||||
modulegraphs, idents, os, pathutils, passaux
|
||||
modulegraphs, idents, os, pathutils, passaux,
|
||||
scriptconfig
|
||||
|
||||
type
|
||||
Interpreter* = ref object ## Use Nim as an interpreter with this object
|
||||
@@ -126,7 +127,9 @@ proc destroyInterpreter*(i: Interpreter) =
|
||||
## destructor.
|
||||
discard "currently nothing to do."
|
||||
|
||||
proc runRepl*(r: TLLRepl; searchPaths: openArray[string]) =
|
||||
proc runRepl*(r: TLLRepl;
|
||||
searchPaths: openArray[string];
|
||||
supportNimscript: bool) =
|
||||
var conf = newConfigRef()
|
||||
var cache = newIdentCache()
|
||||
var graph = newModuleGraph(cache, conf)
|
||||
@@ -139,11 +142,13 @@ proc runRepl*(r: TLLRepl; searchPaths: openArray[string]) =
|
||||
conf.errorMax = high(int)
|
||||
initDefines(conf.symbols)
|
||||
defineSymbol(conf.symbols, "nimscript")
|
||||
if supportNimscript: defineSymbol(conf.symbols, "nimconfig")
|
||||
when hasFFI: defineSymbol(graph.config.symbols, "nimffi")
|
||||
registerPass(graph, verbosePass)
|
||||
registerPass(graph, semPass)
|
||||
registerPass(graph, evalPass)
|
||||
var m = graph.makeStdinModule()
|
||||
incl(m.flags, sfMainModule)
|
||||
if supportNimscript: graph.vm = setupVM(m, cache, "stdin", graph)
|
||||
graph.compileSystemModule()
|
||||
processModule(graph, m, llStreamOpenStdIn(r))
|
||||
|
||||
Reference in New Issue
Block a user