summary refs log tree commit diff stats
path: root/compiler/nimeval.nim
blob: ff91861d08d881ca869314d6d74c77ecff099e45 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#
#
#           The Nim Compiler
#        (c) Copyright 2013 Andreas Rumpf
#
#    See the file "copying.txt", included in this
#    distribution, for details about the copyright.
#

## exposes the Nim VM to clients.
import
  ast, modules, passes, passaux, condsyms,
  options, nimconf, sem, semdata, llstream, vm, modulegraphs, idents

proc execute*(program: string) =
  passes.gIncludeFile = includeModule
  passes.gImportModule = importModule
  initDefines()
  loadConfigs(DefaultConfig)

  initDefines()
  defineSymbol("nimrodvm")
  defineSymbol("nimscript")
  when hasFFI: defineSymbol("nimffi")
  registerPass(verbosePass)
  registerPass(semPass)
  registerPass(evalPass)

  searchPaths.add options.libpath
  var graph = newModuleGraph()
  var cache = newIdentCache()
  var m = makeStdinModule(graph)
  incl(m.flags, sfMainModule)
  compileSystemModule(graph,cache)
  processModule(graph,m, llStreamOpen(program), nil, cache)