Class: Rubinius::InstructionSet

Inherits:
Object
  • Object
show all
Defined in:
lib/rubinius/code/compiler/iseq.rb,
lib/rubinius/code/compiler/opcodes.rb

Defined Under Namespace

Classes: InvalidOpCode, OpCode

Constant Summary collapse

CALL_FLAG_CONCAT =
2

Class Method Summary collapse

Class Method Details

.[](name_or_id) ⇒ Object

Returns an opcode given its name or numeric ID.

Raises:



83
84
85
86
87
# File 'lib/rubinius/code/compiler/iseq.rb', line 83

def self.[](name_or_id)
  opcode = opcodes[opcodes_map[name_or_id]]
  raise InvalidOpCode, "Invalid opcode #{op.inspect}" unless opcode
  opcode
end

.opcode(id, name, params = {}) ⇒ Object

Utility method for defining the opcodes.



74
75
76
77
# File 'lib/rubinius/code/compiler/iseq.rb', line 74

def self.opcode(id, name, params={})
  opcodes[id] = OpCode.new name, id, params
  opcodes_map[name] = opcodes_map[id] = id
end

.opcodesObject

Returns an array of OpCode instances.



69
70
71
# File 'lib/rubinius/code/compiler/iseq.rb', line 69

def self.opcodes
  @opcodes ||= []
end

.opcodes_mapObject

Returns the opcode map.



64
65
66
# File 'lib/rubinius/code/compiler/iseq.rb', line 64

def self.opcodes_map
  @opcodes_map ||= Rubinius::LookupTable.new
end