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:
parent
8ceba8a7f3
commit
ab872be476
1 changed files with 7 additions and 2 deletions
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue