Class: RBS::Dynamic::Tracer::CalledMethod
- Inherits:
-
Object
- Object
- RBS::Dynamic::Tracer::CalledMethod
- Includes:
- Enumerable
- Defined in:
- lib/rbs/dynamic/tracer/called_method.rb
Instance Attribute Summary collapse
-
#call_stack ⇒ Object
readonly
Returns the value of attribute call_stack.
-
#called_line_stack ⇒ Object
readonly
Returns the value of attribute called_line_stack.
-
#trace_point ⇒ Object
readonly
Returns the value of attribute trace_point.
Instance Method Summary collapse
- #called_methods ⇒ Object
- #clear ⇒ Object
- #disable(**opt) ⇒ Object
- #each(&block) ⇒ Object
- #enable(**opt, &block) ⇒ Object
- #ignore_rbs_dynamic_trace(&block) ⇒ Object
-
#initialize(target_filepath_pattern: /.*/, ignore_filepath_pattern: nil, target_classname_pattern: /.*/, ignore_classname_pattern: nil, trace_c_api_method: false) ⇒ CalledMethod
constructor
A new instance of CalledMethod.
- #trace(**opt, &block) ⇒ Object
Constructor Details
#initialize(target_filepath_pattern: /.*/, ignore_filepath_pattern: nil, target_classname_pattern: /.*/, ignore_classname_pattern: nil, trace_c_api_method: false) ⇒ CalledMethod
Returns a new instance of CalledMethod.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/rbs/dynamic/tracer/called_method.rb', line 64 def initialize( target_filepath_pattern: /.*/, ignore_filepath_pattern: nil, target_classname_pattern: /.*/, ignore_classname_pattern: nil, trace_c_api_method: false ) @target_filepath_pattern = Regexp.new(target_filepath_pattern) @ignore_filepath_pattern = ignore_filepath_pattern && Regexp.new(ignore_filepath_pattern) @target_classname_pattern = Regexp.new(target_classname_pattern) @ignore_classname_pattern = ignore_classname_pattern && Regexp.new(ignore_classname_pattern) @trace_c_api_method = trace_c_api_method clear end |
Instance Attribute Details
#call_stack ⇒ Object (readonly)
Returns the value of attribute call_stack.
60 61 62 |
# File 'lib/rbs/dynamic/tracer/called_method.rb', line 60 def call_stack @call_stack end |
#called_line_stack ⇒ Object (readonly)
Returns the value of attribute called_line_stack.
61 62 63 |
# File 'lib/rbs/dynamic/tracer/called_method.rb', line 61 def called_line_stack @called_line_stack end |
#trace_point ⇒ Object (readonly)
Returns the value of attribute trace_point.
62 63 64 |
# File 'lib/rbs/dynamic/tracer/called_method.rb', line 62 def trace_point @trace_point end |
Instance Method Details
#called_methods ⇒ Object
88 89 90 91 92 |
# File 'lib/rbs/dynamic/tracer/called_method.rb', line 88 def called_methods { called_methods: call_stack.first[:called_methods] } end |
#clear ⇒ Object
79 80 81 82 83 84 85 86 |
# File 'lib/rbs/dynamic/tracer/called_method.rb', line 79 def clear @call_stack = [{ called_methods: [], block: [] }] @last_event = nil @called_line_stack = [{}] @ignore_rbs_dynamic_trace = false @trace_point = TracePoint.new(*tarvet_event, &method(:trace_call_methods)) @trace_point.extend trace_point_ext end |
#disable(**opt) ⇒ Object
107 108 109 |
# File 'lib/rbs/dynamic/tracer/called_method.rb', line 107 def disable(**opt) ignore_rbs_dynamic_trace { trace_point.disable(**opt) } end |
#each(&block) ⇒ Object
117 118 119 |
# File 'lib/rbs/dynamic/tracer/called_method.rb', line 117 def each(&block) called_methods.each_called_method(&block) end |
#enable(**opt, &block) ⇒ Object
101 102 103 104 105 |
# File 'lib/rbs/dynamic/tracer/called_method.rb', line 101 def enable(**opt, &block) clear trace_point.enable(**opt, &block) ignore_rbs_dynamic_trace { called_methods } end |
#ignore_rbs_dynamic_trace(&block) ⇒ Object
94 95 96 97 98 99 |
# File 'lib/rbs/dynamic/tracer/called_method.rb', line 94 def ignore_rbs_dynamic_trace(&block) @ignore_rbs_dynamic_trace = true block.call ensure @ignore_rbs_dynamic_trace = false end |
#trace(**opt, &block) ⇒ Object
111 112 113 |
# File 'lib/rbs/dynamic/tracer/called_method.rb', line 111 def trace(**opt, &block) enable(**opt, &block) end |