Module: AbstractReflection::MethodMirror
- Includes:
- Mirror
- Defined in:
- lib/abstract_reflection/method_mirror.rb
Overview
A MethodMirror should reflect on methods, but in a more general sense than the Method and UnboundMethod classes in Ruby are able to offer.
In actual execution, a method is pretty much every chunk of code, even loading a file triggers a process not unlike compiling a method (if only for the side-effects). Method mirrors should allow access to the runtime objects, but also to their static representations (bytecode, source, …), their debugging information and statistical information
Instance Attribute Summary
Attributes included from Mirror
Instance Method Summary collapse
-
#arguments ⇒ Array<FieldMirror>
Queries the method for it’s arguments and returns a list of mirrors that hold name and value information.
-
#ast ⇒ Object
The AST representation of this method.
-
#binding ⇒ Binding, NilClass
The binding of the method.
-
#block_argument ⇒ FieldMirror?
Return the value the block argument, or nil.
-
#break(step_offset = 1) ⇒ Object
Allows setting a breakpoint in the method, optionally at an offset.
-
#breakpoints ⇒ Object
Query the method for active breakpoints.
-
#bytecode ⇒ Object
If this method was compiled into a VM bytecode representation, return an object describing the bytecode.
-
#defining_class ⇒ ClassMirror
The class this method was originally defined in.
- #delete ⇒ Object
-
#execution_time ⇒ Time
The absolute, total time this method was executed (on top of the stack).
-
#execution_time_average ⇒ Time
The average time each method invocation executes the method, before returning.
-
#execution_time_share ⇒ Time
Each method contributes a certain percentage to the runtime of the system.
-
#file ⇒ String
The filename.
-
#file=(string) ⇒ Object
Change the information about which file this method is stored in.
-
#invocation_count ⇒ Fixnum
The number of times this method has been called.
-
#is_alias? ⇒ true, false
Predicate to determine whether this method is an alias.
-
#is_closure? ⇒ true, false
Predicate to determine whether this method was compiled for closure.
-
#line ⇒ Fixnum
The source line.
-
#line=(string) ⇒ Object
Change the information about the line this method starts at.
-
#native_code ⇒ Object
If this method was JITed, this should return the native code location.
-
#optional_arguments ⇒ Array<FieldMirror>?
Returns names and values of the optional arguments.
-
#original_method ⇒ MethodMirror
Returns the original method to an alias, a proc, or an unbound method object, or the method itself, if the previous options are not applicable.
- #private! ⇒ Object
- #private? ⇒ Boolean
- #protected! ⇒ Object
- #protected? ⇒ Boolean
- #public! ⇒ Object
- #public? ⇒ Boolean
-
#references_name?(string) ⇒ true, false
Determine whether this method references the passed name.
-
#required_arguments ⇒ Array<FieldMirror>?
Returns the name and possibly values of the required arguments.
-
#selector ⇒ String
The method name.
-
#send_offsets ⇒ Hash<String, Fixnum>
The offsets into the source code for method sends.
-
#sends_message?(string) ⇒ true, false
Predicate to determine whether a given message is send within this method.
-
#source ⇒ String
The source code of this method.
-
#source=(string) ⇒ Object
Replace the sourcecode.
-
#splat_argument ⇒ FieldMirror?
Returns a field mirror with name and possibly value of the splat argument, or nil, if there is none to this method.
-
#step_offsets ⇒ Object
The offsets into the source code for stepping in a debugger.
Methods included from Mirror
#initialize, #mirrors?, #name, #reflectee
Methods included from AbstractReflection::Mirror::ClassMethods
#included, #mirror_class, #new, #reflect, #reflect!, #reflects?, #register_mirror
Instance Method Details
#arguments ⇒ Array<FieldMirror>
Queries the method for it’s arguments and returns a list of mirrors that hold name and value information.
44 45 46 |
# File 'lib/abstract_reflection/method_mirror.rb', line 44 def arguments raise CapabilitiesExceeded end |
#ast ⇒ Object
The AST representation of this method.
221 222 223 |
# File 'lib/abstract_reflection/method_mirror.rb', line 221 def ast raise CapabilitiesExceeded end |
#binding ⇒ Binding, NilClass
The binding of the method. May be nil.
127 128 129 |
# File 'lib/abstract_reflection/method_mirror.rb', line 127 def binding raise CapabilitiesExceeded end |
#block_argument ⇒ FieldMirror?
Return the value the block argument, or nil
72 73 74 |
# File 'lib/abstract_reflection/method_mirror.rb', line 72 def block_argument raise CapabilitiesExceeded end |
#break(step_offset = 1) ⇒ Object
Allows setting a breakpoint in the method, optionally at an offset.
108 109 110 |
# File 'lib/abstract_reflection/method_mirror.rb', line 108 def break(step_offset = 1) raise CapabilitiesExceeded end |
#breakpoints ⇒ Object
Query the method for active breakpoints.
113 114 115 |
# File 'lib/abstract_reflection/method_mirror.rb', line 113 def breakpoints raise CapabilitiesExceeded end |
#bytecode ⇒ Object
If this method was compiled into a VM bytecode representation, return an object describing the bytecode. Like #native_code, this should raise a CapabilitiesExceeded only for implementations that do not have a bytecode representation.
216 217 218 |
# File 'lib/abstract_reflection/method_mirror.rb', line 216 def bytecode raise CapabilitiesExceeded end |
#defining_class ⇒ ClassMirror
Returns The class this method was originally defined in.
16 17 18 |
# File 'lib/abstract_reflection/method_mirror.rb', line 16 def defining_class raise CapabilitiesExceeded end |
#delete ⇒ Object
249 250 251 |
# File 'lib/abstract_reflection/method_mirror.rb', line 249 def delete raise CapabilitiesExceeded end |
#execution_time ⇒ Time
The absolute, total time this method was executed (on top of the stack)
183 184 185 |
# File 'lib/abstract_reflection/method_mirror.rb', line 183 def execution_time raise CapabilitiesExceeded end |
#execution_time_average ⇒ Time
The average time each method invocation executes the method, before returning.
191 192 193 |
# File 'lib/abstract_reflection/method_mirror.rb', line 191 def execution_time_average raise CapabilitiesExceeded end |
#execution_time_share ⇒ Time
Each method contributes a certain percentage to the runtime of the system. This method can be used to query the system for the percentage of the mirrored method (in the range 0 < p < 1). If the number is closer to one, that means that the system spends a considerable amount of time executing this method. This method does not consider how often a method is called, i.e. a high share doesn’t tell you whether the method is slow or if it is just called very often.
175 176 177 |
# File 'lib/abstract_reflection/method_mirror.rb', line 175 def execution_time_share raise CapabilitiesExceeded end |
#file ⇒ String
Returns The filename.
36 37 38 |
# File 'lib/abstract_reflection/method_mirror.rb', line 36 def file raise CapabilitiesExceeded end |
#file=(string) ⇒ Object
Change the information about which file this method is stored in. Possibly moves the method into the new file.
84 85 86 |
# File 'lib/abstract_reflection/method_mirror.rb', line 84 def file= string raise CapabilitiesExceeded end |
#invocation_count ⇒ Fixnum
The number of times this method has been called. Not neccessarily an exact number (to allow for optimizations), but should at least give an indication.
200 201 202 |
# File 'lib/abstract_reflection/method_mirror.rb', line 200 def invocation_count raise CapabilitiesExceeded end |
#is_alias? ⇒ true, false
Predicate to determine whether this method is an alias.
134 135 136 |
# File 'lib/abstract_reflection/method_mirror.rb', line 134 def is_alias? raise CapabilitiesExceeded end |
#is_closure? ⇒ true, false
Predicate to determine whether this method was compiled for closure
120 121 122 |
# File 'lib/abstract_reflection/method_mirror.rb', line 120 def is_closure? raise CapabilitiesExceeded end |
#line ⇒ Fixnum
Returns The source line.
26 27 28 |
# File 'lib/abstract_reflection/method_mirror.rb', line 26 def line raise CapabilitiesExceeded end |
#line=(string) ⇒ Object
Change the information about the line this method starts at. Possibly moves the method.
90 91 92 |
# File 'lib/abstract_reflection/method_mirror.rb', line 90 def line= string raise CapabilitiesExceeded end |
#native_code ⇒ Object
If this method was JITed, this should return the native code location. nil, if this method was not jitted, CapabilitiesExceeded should be thrown for implementations that do not have a JIT.
208 209 210 |
# File 'lib/abstract_reflection/method_mirror.rb', line 208 def native_code raise CapabilitiesExceeded end |
#optional_arguments ⇒ Array<FieldMirror>?
Returns names and values of the optional arguments.
59 60 61 |
# File 'lib/abstract_reflection/method_mirror.rb', line 59 def optional_arguments raise CapabilitiesExceeded end |
#original_method ⇒ MethodMirror
Returns the original method to an alias, a proc, or an unbound method object, or the method itself, if the previous options are not applicable.
143 144 145 |
# File 'lib/abstract_reflection/method_mirror.rb', line 143 def original_method raise CapabilitiesExceeded end |
#private! ⇒ Object
237 238 239 |
# File 'lib/abstract_reflection/method_mirror.rb', line 237 def private! raise CapabilitiesExceeded end |
#private? ⇒ Boolean
233 234 235 |
# File 'lib/abstract_reflection/method_mirror.rb', line 233 def private? raise CapabilitiesExceeded end |
#protected! ⇒ Object
245 246 247 |
# File 'lib/abstract_reflection/method_mirror.rb', line 245 def protected! raise CapabilitiesExceeded end |
#protected? ⇒ Boolean
241 242 243 |
# File 'lib/abstract_reflection/method_mirror.rb', line 241 def protected? raise CapabilitiesExceeded end |
#public! ⇒ Object
229 230 231 |
# File 'lib/abstract_reflection/method_mirror.rb', line 229 def public! raise CapabilitiesExceeded end |
#public? ⇒ Boolean
225 226 227 |
# File 'lib/abstract_reflection/method_mirror.rb', line 225 def public? raise CapabilitiesExceeded end |
#references_name?(string) ⇒ true, false
Determine whether this method references the passed name. This should be in a state useable enough to allow e.g. dead local detection.
161 162 163 |
# File 'lib/abstract_reflection/method_mirror.rb', line 161 def references_name?(string) raise CapabilitiesExceeded end |
#required_arguments ⇒ Array<FieldMirror>?
Returns the name and possibly values of the required arguments
65 66 67 |
# File 'lib/abstract_reflection/method_mirror.rb', line 65 def required_arguments raise CapabilitiesExceeded end |
#selector ⇒ String
Returns The method name.
31 32 33 |
# File 'lib/abstract_reflection/method_mirror.rb', line 31 def selector raise CapabilitiesExceeded end |
#send_offsets ⇒ Hash<String, Fixnum>
The offsets into the source code for method sends.
97 98 99 |
# File 'lib/abstract_reflection/method_mirror.rb', line 97 def send_offsets raise CapabilitiesExceeded end |
#sends_message?(string) ⇒ true, false
Predicate to determine whether a given message is send within this method. This should at least report all direct sends, but might also report sends within #evals or through #send
152 153 154 |
# File 'lib/abstract_reflection/method_mirror.rb', line 152 def (string) raise CapabilitiesExceeded end |
#source ⇒ String
Returns The source code of this method.
21 22 23 |
# File 'lib/abstract_reflection/method_mirror.rb', line 21 def source raise CapabilitiesExceeded end |
#source=(string) ⇒ Object
Replace the sourcecode. This should be an in-place operation and immediately visible to the system.
78 79 80 |
# File 'lib/abstract_reflection/method_mirror.rb', line 78 def source= string raise CapabilitiesExceeded end |
#splat_argument ⇒ FieldMirror?
Returns a field mirror with name and possibly value of the splat argument, or nil, if there is none to this method.
52 53 54 |
# File 'lib/abstract_reflection/method_mirror.rb', line 52 def splat_argument raise CapabilitiesExceeded end |
#step_offsets ⇒ Object
The offsets into the source code for stepping in a debugger
102 103 104 |
# File 'lib/abstract_reflection/method_mirror.rb', line 102 def step_offsets raise CapabilitiesExceeded end |