Method: Atomy::Module#evaluate

Defined in:
lib/atomy/module.rb

#evaluate(node, binding = nil) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/atomy/module.rb', line 49

def evaluate(node, binding = nil)
  binding ||=
    Binding.setup(
      Rubinius::VariableScope.of_sender,
      Rubinius::CompiledCode.of_sender,
      Rubinius::LexicalScope.of_sender,
      self)

  code = Atomy::Compiler.compile(
    node,
    self,
    Atomy::EvalLocalState.new(binding.variables))

  code. :for_eval, true

  block = Atomy::Compiler.construct_block(code, binding)
  block.call
end