Class: SystemNavigation::InstructionStream
- Inherits:
-
Object
- Object
- SystemNavigation::InstructionStream
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
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.
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
#method ⇒ Object
7
8
9
|
# File 'lib/system_navigation/instruction_stream.rb', line 7
def method
@method
end
|
Class Method Details
.on(method) ⇒ Object
3
4
5
|
# File 'lib/system_navigation/instruction_stream.rb', line 3
def self.on(method)
self.new(method: method)
end
|
Instance Method Details
#decode ⇒ Object
14
15
16
|
# File 'lib/system_navigation/instruction_stream.rb', line 14
def decode
@iseq ||= RubyVM::InstructionSequence.disasm(@method) || ''
end
|
#iseqs(sym) ⇒ Object
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
18
19
20
|
# File 'lib/system_navigation/instruction_stream.rb', line 18
def scan_for(selected_instructs)
selected_instructs.any?
end
|