Module: RVM::Interpreter

Included in:
Languages::Math::Compiler
Defined in:
lib/rvm/interpreter.rb

Overview

This Module hold all the VM Classes, so it is quite important to read and understand if you feel like making a own compiler.

The basic idea is to translate your own code into a tree of objects from this.

Defined Under Namespace

Classes: Assignment, Block, Condition, Constant, Enviroment, FunctionCall, FunctionDefinition, Loop, ObjectContext, Parameter, Return, ReturnException, Sequence, SetClassFunction, Variable, VariableStorage, VariableStorageCallback

Class Method Summary collapse

Class Method Details

.const(type, value, pos = nil) ⇒ Object

This is a helper function that generates a constat of a simple constant, for example if you’ve a lot of string constants it is way quickly to call this then writing it out the whole time.



21
22
23
# File 'lib/rvm/interpreter.rb', line 21

def Interpreter.const type, value, pos = nil
  RVM::Interpreter::Constant.new(RVM::Classes[type].new(value), pos)
end

.env(aenv = {}) ⇒ Object

This is a helper fuctio to quickly generate a empty enviorment.



13
14
15
16
# File 'lib/rvm/interpreter.rb', line 13

def Interpreter.env aenv = {}
  RVM::debug "Interpreter.env" if $DEBUG
  Enviroment.new aenv
end