Class: Furnace::AVM2::ABC::ControlTransferOpcode

Inherits:
Opcode
  • Object
show all
Defined in:
lib/furnace-avm2/abc/opcodes/control_transfer_opcode.rb

Constant Summary

Constants inherited from Opcode

Opcode::MAP

Instance Attribute Summary collapse

Attributes inherited from Opcode

#sequence

Instance Method Summary collapse

Methods inherited from Opcode

#ast_type, body, #byte_length, #consumes_context, define_property, #disassemble, #disassemble_parameters, #initialize, mnemonic, #next, #offset, #read, #root, #write

Constructor Details

This class inherits a constructor from Furnace::AVM2::ABC::Opcode

Instance Attribute Details

#targetObject

Returns the value of attribute target.



9
10
11
# File 'lib/furnace-avm2/abc/opcodes/control_transfer_opcode.rb', line 9

def target
  @target
end

Instance Method Details

#lookup!Object



29
30
31
# File 'lib/furnace-avm2/abc/opcodes/control_transfer_opcode.rb', line 29

def lookup!
  self.target_offset = @target.offset
end

#parametersObject



5
6
7
# File 'lib/furnace-avm2/abc/opcodes/control_transfer_opcode.rb', line 5

def parameters
  [ target_offset ]
end

#resolve!Object



19
20
21
22
23
24
25
26
27
# File 'lib/furnace-avm2/abc/opcodes/control_transfer_opcode.rb', line 19

def resolve!
  @target = @sequence.opcode_at(target_offset)

  if !@target
    # Probably, we're in the middle of invalid code emitted by this fucking braindead
    # compiler. Do something equally insane.
    @target = self
  end
end

#target_offsetObject



11
12
13
# File 'lib/furnace-avm2/abc/opcodes/control_transfer_opcode.rb', line 11

def target_offset
  self.offset + byte_length + body.jump_offset
end

#target_offset=(new_offset) ⇒ Object



15
16
17
# File 'lib/furnace-avm2/abc/opcodes/control_transfer_opcode.rb', line 15

def target_offset=(new_offset)
  body.jump_offset = new_offset - offset - byte_length
end