Class: Indis::ARM::InstructionLoader

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/indis-arm/instruction_loader.rb

Overview

InstructionLoader is a DSL parser for arm7.inst.rb DSL. The DSL is evaluated in the context of InstructionLoader singleton, the only top-level command is #instruction

Instance Method Summary collapse

Instance Method Details

#instruction(name, &block) ⇒ Object

Loads a named instruction. The block is evaluated in a context of newly-created EncodingLoader.

Parameters:

  • name (Symbol)

    instruction name



49
50
51
52
# File 'lib/indis-arm/instruction_loader.rb', line 49

def instruction(name, &block)
  el = EncodingLoader.new(name, @classes)
  el.instance_eval(&block)
end

#loadArray

Loads and processes the DSL

Returns:

  • (Array)

    all mapped classes from DSL



36
37
38
39
40
41
42
43
44
# File 'lib/indis-arm/instruction_loader.rb', line 36

def load
  return @classes if @classes
  
  @classes = []
  instr_file = File.join(File.dirname(__FILE__), 'arm7.inst.rb')
  self.instance_eval open(instr_file).read, instr_file, 1
  
  @classes
end