Class: Dappgen::Interpreter

Inherits:
Object
  • Object
show all
Defined in:
lib/dappgen/interpreter.rb

Instance Method Summary collapse

Constructor Details

#initialize(script, machine) ⇒ Interpreter

Returns a new instance of Interpreter.



5
6
7
8
# File 'lib/dappgen/interpreter.rb', line 5

def initialize(script, machine)
  @script = script
  @machine = machine
end

Instance Method Details

#built_scriptObject



10
11
12
# File 'lib/dappgen/interpreter.rb', line 10

def built_script
  @built_script ||= @script.built_script
end

#run!Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/dappgen/interpreter.rb', line 14

def run!
  built_script.each do |statement|
    args = [
      statement.first.first,
      statement.first[1]
    ]

    options = statement.to_a[1..-1].to_h

    args << options unless options.empty?
    @machine.public_send(*args)
  end
end