class Sol::Nodes
Collection of nodes each one representing an expression.
Public Instance Methods
<<(node)
click to toggle source
# File lib/sol/nodes.rb, line 6 def <<(node) nodes << node return self end
eval(context)
click to toggle source
This method is the “interpreter” part of our language. All nodes know how to eval itself and returns the result of its evaluation by implementing the “eval” method. The “context” variable is the environment in which the node is evaluated (local variables, current class, etc.).
# File lib/sol/interpreter.rb, line 27 def eval(context) return_value = nil nodes.each do |node| return_value = node.eval(context) end # The last value evaluated in a method is the return value. Or null if node return_value || RuntimeModel::Runtime["null"] end