class SystemNavigation::CompiledMethod
Constants
- CVAR
- GVAR
- IVAR
Attributes
source[R]
Public Class Methods
compile(method)
click to toggle source
# File lib/system_navigation/compiled_method.rb, line 3 def self.compile(method) self.new(method).compile end
new(method)
click to toggle source
# File lib/system_navigation/compiled_method.rb, line 13 def initialize(method) @method = method @scanner = SystemNavigation::InstructionStream.on(method) @decoder = InstructionStream::Decoder.new(@scanner) begin @source = FastMethodSource.source_for(@method) rescue FastMethodSource::SourceNotFoundError, IOError @source = '' end begin @comment = FastMethodSource.comment_for(@method) rescue FastMethodSource::SourceNotFoundError, IOError @comment = '' end end
Public Instance Methods
c_method?()
click to toggle source
# File lib/system_navigation/compiled_method.rb, line 93 def c_method? @method.source_location.nil? end
compile()
click to toggle source
# File lib/system_navigation/compiled_method.rb, line 31 def compile @scanner.decode self end
has_literal?(literal)
click to toggle source
Literals that are referenced by the receiver as described in `doc/syntax/literals.rdoc` in your Ruby, installation minus procs and backticks.
# File lib/system_navigation/compiled_method.rb, line 48 def has_literal?(literal) return true if self.scan_for { @decoder.literal_scan(literal) } return false if self.c_method? exptree = ExpressionTree.of(method: @method, source: @source) exptree.includes?(literal) end
method_missing(method_name, *args, &block)
click to toggle source
# File lib/system_navigation/compiled_method.rb, line 37 def method_missing(method_name, *args, &block) @method.send(method_name, *args, &block) end
rb_method?()
click to toggle source
# File lib/system_navigation/compiled_method.rb, line 97 def rb_method? !self.c_method? end
reads_field?(var)
click to toggle source
# File lib/system_navigation/compiled_method.rb, line 56 def reads_field?(var) case var when IVAR self.scan_for { @decoder.ivar_read_scan(var) } when CVAR self.scan_for { @decoder.cvar_read_scan(var) } when GVAR self.scan_for { @decoder.gvar_read_scan(var) } else raise ArgumentError, "unknown argument #{var}" end end
sends_message?(message)
click to toggle source
# File lib/system_navigation/compiled_method.rb, line 82 def sends_message?(message) self.scan_for { @decoder.msg_send_scan(message) } end
sent_messages()
click to toggle source
# File lib/system_navigation/compiled_method.rb, line 101 def sent_messages @decoder.scan_for_sent_messages end
source_contains?(string, match_case)
click to toggle source
# File lib/system_navigation/compiled_method.rb, line 86 def source_contains?(string, match_case) string = string.dup code_and_comment = @source + @comment code_and_comment.downcase! && string.downcase! unless match_case !!code_and_comment.match(string) end
unwrap()
click to toggle source
# File lib/system_navigation/compiled_method.rb, line 41 def unwrap @method end
writes_field?(var)
click to toggle source
# File lib/system_navigation/compiled_method.rb, line 69 def writes_field?(var) case var when IVAR self.scan_for { @decoder.ivar_write_scan(var) } when CVAR self.scan_for { @decoder.cvar_write_scan(var) } when GVAR self.scan_for { @decoder.gvar_write_scan(var) } else raise ArgumentError, "unknown argument #{var}" end end
Protected Instance Methods
scan_for() { || ... }
click to toggle source
# File lib/system_navigation/compiled_method.rb, line 107 def scan_for @scanner.scan_for(yield) end
scan_for_literal(literal)
click to toggle source
# File lib/system_navigation/compiled_method.rb, line 111 def scan_for_literal(literal) return false if self.c_method? exptree = ExpressionTree.of(method: @method, source: @source) exptree.includes?(literal) end