Class: SyntaxTree::YARV::SeaOfNodes::InsnNode

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree/yarv/sea_of_nodes.rb

Overview

This object represents a node in the graph that holds a YARV instruction.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(insn, offset) ⇒ InsnNode

Returns a new instance of InsnNode.



17
18
19
20
21
22
23
# File 'lib/syntax_tree/yarv/sea_of_nodes.rb', line 17

def initialize(insn, offset)
  @inputs = []
  @outputs = []

  @insn = insn
  @offset = offset
end

Instance Attribute Details

#inputsObject (readonly)

Returns the value of attribute inputs.



15
16
17
# File 'lib/syntax_tree/yarv/sea_of_nodes.rb', line 15

def inputs
  @inputs
end

#insnObject (readonly)

Returns the value of attribute insn.



15
16
17
# File 'lib/syntax_tree/yarv/sea_of_nodes.rb', line 15

def insn
  @insn
end

#offsetObject (readonly)

Returns the value of attribute offset.



15
16
17
# File 'lib/syntax_tree/yarv/sea_of_nodes.rb', line 15

def offset
  @offset
end

#outputsObject (readonly)

Returns the value of attribute outputs.



15
16
17
# File 'lib/syntax_tree/yarv/sea_of_nodes.rb', line 15

def outputs
  @outputs
end

Instance Method Details

#idObject



25
26
27
# File 'lib/syntax_tree/yarv/sea_of_nodes.rb', line 25

def id
  offset
end

#labelObject



29
30
31
# File 'lib/syntax_tree/yarv/sea_of_nodes.rb', line 29

def label
  "%04d %s" % [offset, insn.disasm(Disassembler::Squished.new)]
end