src/vms/vm

Source   Edit  

Types

DeclarerKind = enum
  Const, Let, Var
Source   Edit  
VariableDeclaration = object
  declarer*: DeclarerKind
  name*: string
  typ*: string
  initializer*: string
Source   Edit  
Vm = ref object of RootObj
  tmpPath*: string
  importsBasePath*: string
  declarationsBasePath*: string
  commandBasePath*: string
  stateBasePath*: string
  imports*: seq[string]
  newImports*: seq[string]
  variables*: seq[VariableDeclaration]
  newVariables*: seq[VariableDeclaration]
  declarations*: seq[string]
  newDeclarations*: seq[string]
Source   Edit  

Consts

checkSuffix = "check"
Source   Edit  
nimExt = ".nim"
Source   Edit  

Procs

proc `$`(self: DeclarerKind): string {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc commandPath(self: Vm): Path {....raises: [], tags: [], forbids: [].}
Temporary path where the vm stored the last command. Source   Edit  
proc declarationsCheckPath(self: Vm): Path {....raises: [], tags: [], forbids: [].}
Temporary path where the vm writes the last declarations that were validated. Source   Edit  
proc declarationsPath(self: Vm): Path {....raises: [], tags: [], forbids: [].}
Temporary path where the vm stores its declarations. Source   Edit  
proc declare(self: Vm; declaration: string) {....raises: [], tags: [], forbids: [].}
Declares a new proc, template, macro, iterator, etc. and/or type. This will not be effective until updateDeclarations is called. Source   Edit  
proc declareImport(self: Vm; declaration: string) {....raises: [], tags: [],
    forbids: [].}
Declares a new import. This will not be effective until updateImports is called. Source   Edit  
proc declareVar(self: Vm; declarer: DeclarerKind; name: string;
                typ: string = ""; initializer: string = "") {.
    ...raises: [Exception], tags: [], forbids: [].}
Declares a new variable. This will not be effective until updateState is called. declarer: declarer of the variable, corresponding to const, let or var. name: name of the variable. typ: type of the variable. initializer: initial value of the variable. one or both of typ and initializer are required. Note: code in `initializer` should never side-effect, as it will be executed each time `updateState` is called. Source   Edit  
proc importsCheckPath(self: Vm): Path {....raises: [], tags: [], forbids: [].}
Temporary path where the vm writes the last imports that were validated. Source   Edit  
proc importsPath(self: Vm): Path {....raises: [], tags: [], forbids: [].}
Temporary path where the vm stores its imports. Source   Edit  
proc isSuccess(toCheck: (string, int)): bool {....raises: [], tags: [], forbids: [].}
Checks if the given result is successful. Source   Edit  
proc statePath(self: Vm): Path {....raises: [], tags: [], forbids: [].}
Temporary path where the vm stored the last state. Source   Edit  

Methods

method clean(self: Vm) {.base, ...raises: [], tags: [], forbids: [].}
Cleans up the vm state. Source   Edit  
method runCommand(self: Vm; command: string): (string, int) {.base, ...raises: [],
    tags: [], forbids: [].}
Runs a command. Compiles the command, runs it, and returns a success or an error. Source   Edit  
method updateDeclarations(self: Vm): (string, int) {.base, ...raises: [], tags: [],
    forbids: [].}
Updates the declarations. Compiles all declarations and returns a success or an error. Source   Edit  
method updateImports(self: Vm): (string, int) {.base, ...raises: [], tags: [],
    forbids: [].}
Updates the imports. Compiles all declared imports and returns a success or an error. Source   Edit  
method updateState(self: Vm): (string, int) {.base, ...raises: [], tags: [],
    forbids: [].}
Updates the state's structure, initializes the new variables while keeping the values of the previous state. Compiles all variable declarations, and returns a success or an error. Source   Edit