Module: AbstractReflection::MethodMirror

Includes:
Mirror
Included in:
Maglev::Reflection::MethodMirror, Ruby::Reflection::MethodMirror
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

#reflection

Instance Method Summary collapse

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

#argumentsArray<FieldMirror>

Queries the method for it’s arguments and returns a list of mirrors that hold name and value information.

Returns:

Raises:



44
45
46
# File 'lib/abstract_reflection/method_mirror.rb', line 44

def arguments
  raise CapabilitiesExceeded
end

#astObject

The AST representation of this method.



221
222
223
# File 'lib/abstract_reflection/method_mirror.rb', line 221

def ast
  raise CapabilitiesExceeded
end

#bindingBinding, NilClass

The binding of the method. May be nil.

Returns:

  • (Binding, NilClass)

Raises:



127
128
129
# File 'lib/abstract_reflection/method_mirror.rb', line 127

def binding
  raise CapabilitiesExceeded
end

#block_argumentFieldMirror?

Return the value the block argument, or nil

Returns:

Raises:



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

#breakpointsObject

Query the method for active breakpoints.



113
114
115
# File 'lib/abstract_reflection/method_mirror.rb', line 113

def breakpoints
  raise CapabilitiesExceeded
end

#bytecodeObject

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_classClassMirror

Returns The class this method was originally defined in.

Returns:

  • (ClassMirror)

    The class this method was originally defined in

Raises:



16
17
18
# File 'lib/abstract_reflection/method_mirror.rb', line 16

def defining_class
  raise CapabilitiesExceeded
end

#deleteObject



249
250
251
# File 'lib/abstract_reflection/method_mirror.rb', line 249

def delete
  raise CapabilitiesExceeded
end

#execution_timeTime

The absolute, total time this method was executed (on top of the stack)

Returns:

  • (Time)

Raises:



183
184
185
# File 'lib/abstract_reflection/method_mirror.rb', line 183

def execution_time
  raise CapabilitiesExceeded
end

#execution_time_averageTime

The average time each method invocation executes the method, before returning.

Returns:

  • (Time)

Raises:



191
192
193
# File 'lib/abstract_reflection/method_mirror.rb', line 191

def execution_time_average
  raise CapabilitiesExceeded
end

#execution_time_shareTime

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.

Returns:

  • (Time)

Raises:



175
176
177
# File 'lib/abstract_reflection/method_mirror.rb', line 175

def execution_time_share
  raise CapabilitiesExceeded
end

#fileString

Returns The filename.

Returns:

  • (String)

    The filename

Raises:



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_countFixnum

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.

Returns:

  • (Fixnum)

Raises:



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.

Returns:

  • (true, false)

Raises:



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

Returns:

  • (true, false)

Raises:



120
121
122
# File 'lib/abstract_reflection/method_mirror.rb', line 120

def is_closure?
  raise CapabilitiesExceeded
end

#lineFixnum

Returns The source line.

Returns:

  • (Fixnum)

    The source line

Raises:



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_codeObject

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_argumentsArray<FieldMirror>?

Returns names and values of the optional arguments.

Returns:

Raises:



59
60
61
# File 'lib/abstract_reflection/method_mirror.rb', line 59

def optional_arguments
  raise CapabilitiesExceeded
end

#original_methodMethodMirror

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.

Returns:

Raises:



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

Returns:

  • (Boolean)

Raises:



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

Returns:

  • (Boolean)

Raises:



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

Returns:

  • (Boolean)

Raises:



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.

Returns:

  • (true, false)

Raises:



161
162
163
# File 'lib/abstract_reflection/method_mirror.rb', line 161

def references_name?(string)
  raise CapabilitiesExceeded
end

#required_argumentsArray<FieldMirror>?

Returns the name and possibly values of the required arguments

Returns:

Raises:



65
66
67
# File 'lib/abstract_reflection/method_mirror.rb', line 65

def required_arguments
  raise CapabilitiesExceeded
end

#selectorString

Returns The method name.

Returns:

  • (String)

    The method name

Raises:



31
32
33
# File 'lib/abstract_reflection/method_mirror.rb', line 31

def selector
  raise CapabilitiesExceeded
end

#send_offsetsHash<String, Fixnum>

The offsets into the source code for method sends.

Returns:

  • (Hash<String, Fixnum>)

    a hash of selector-offset pairs

Raises:



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

Returns:

  • (true, false)

Raises:



152
153
154
# File 'lib/abstract_reflection/method_mirror.rb', line 152

def sends_message?(string)
  raise CapabilitiesExceeded
end

#sourceString

Returns The source code of this method.

Returns:

  • (String)

    The source code of this method

Raises:



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_argumentFieldMirror?

Returns a field mirror with name and possibly value of the splat argument, or nil, if there is none to this method.

Returns:

Raises:



52
53
54
# File 'lib/abstract_reflection/method_mirror.rb', line 52

def splat_argument
  raise CapabilitiesExceeded
end

#step_offsetsObject

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