Class: SystemNavigation::InstructionStream

Inherits:
Object
  • Object
show all
Defined in:
lib/system_navigation/instruction_stream.rb,
lib/system_navigation/instruction_stream/decoder.rb,
lib/system_navigation/instruction_stream/instruction.rb,
lib/system_navigation/instruction_stream/instruction/attr_instruction.rb

Overview

Since:

  • 0.1.0

Defined Under Namespace

Classes: Decoder, Instruction

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method: nil, iseq: nil) ⇒ InstructionStream

Returns a new instance of InstructionStream.

Since:

  • 0.1.0



9
10
11
12
# File 'lib/system_navigation/instruction_stream.rb', line 9

def initialize(method: nil, iseq: nil)
  @method = method
  @iseq = iseq
end

Instance Attribute Details

#methodObject (readonly)

Since:

  • 0.1.0



7
8
9
# File 'lib/system_navigation/instruction_stream.rb', line 7

def method
  @method
end

Class Method Details

.on(method) ⇒ Object

Since:

  • 0.1.0



3
4
5
# File 'lib/system_navigation/instruction_stream.rb', line 3

def self.on(method)
  self.new(method: method)
end

Instance Method Details

#decodeObject

Since:

  • 0.1.0



14
15
16
# File 'lib/system_navigation/instruction_stream.rb', line 14

def decode
  @iseq ||= RubyVM::InstructionSequence.disasm(@method) || ''
end

#iseqs(sym) ⇒ Object

Since:

  • 0.1.0



22
23
24
25
26
27
28
29
30
31
# File 'lib/system_navigation/instruction_stream.rb', line 22

def iseqs(sym)
  iseqs = @iseq.split("\n")

  if iseqs.any?
    instructions = iseqs.map { |instruction| Instruction.parse(instruction) }
    instructions.compact.select(&:vm_operative?)
  else
    Instruction::AttrInstruction.parse(@method, sym) || []
  end
end

#scan_for(selected_instructs) ⇒ Object

Since:

  • 0.1.0



18
19
20
# File 'lib/system_navigation/instruction_stream.rb', line 18

def scan_for(selected_instructs)
  selected_instructs.any?
end