Class: Mirrors::ISeqVisitor
- Inherits:
-
Object
- Object
- Mirrors::ISeqVisitor
- Defined in:
- lib/mirrors/visitors/iseq_visitor.rb
Overview
ISeqVisitor is an abstract class that knows how to walk methods and call the visit() method for each instruction. Internally it tracks the state of the current @pc, @line, and @label during the walk.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#class_refs ⇒ Object
readonly
Returns the value of attribute class_refs.
-
#field_refs ⇒ Object
readonly
Returns the value of attribute field_refs.
-
#iseq ⇒ Object
readonly
Returns the value of attribute iseq.
-
#method_refs ⇒ Object
readonly
Returns the value of attribute method_refs.
Instance Method Summary collapse
-
#call(method) ⇒ Object
visit all the instructions in the supplied method.
-
#visit(_bytecode) ⇒ Object
iterator call once for each opcode.
Instance Attribute Details
#class_refs ⇒ Object (readonly)
Returns the value of attribute class_refs.
10 11 12 |
# File 'lib/mirrors/visitors/iseq_visitor.rb', line 10 def class_refs @class_refs end |
#field_refs ⇒ Object (readonly)
Returns the value of attribute field_refs.
10 11 12 |
# File 'lib/mirrors/visitors/iseq_visitor.rb', line 10 def field_refs @field_refs end |
#iseq ⇒ Object (readonly)
Returns the value of attribute iseq.
10 11 12 |
# File 'lib/mirrors/visitors/iseq_visitor.rb', line 10 def iseq @iseq end |
#method_refs ⇒ Object (readonly)
Returns the value of attribute method_refs.
10 11 12 |
# File 'lib/mirrors/visitors/iseq_visitor.rb', line 10 def method_refs @method_refs end |
Instance Method Details
#call(method) ⇒ Object
visit all the instructions in the supplied method
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/mirrors/visitors/iseq_visitor.rb', line 13 def call(method) @method = method @iseq = method.native_code # extract fields from iseq @magic, @major_version, @minor_version, @format_type, @misc, @label, @path, @absolute_path, @first_lineno, @type, @locals, @params, @catch_table, @bytecode = @iseq.to_a # walk state @pc = 0 # program counter @label # current label walk self end |
#visit(_bytecode) ⇒ Object
iterator call once for each opcode
41 42 43 |
# File 'lib/mirrors/visitors/iseq_visitor.rb', line 41 def visit(_bytecode) raise NotImplementedError, "subclass responsibility" end |