Package org.jruby.runtime
Class Frame
java.lang.Object
org.jruby.runtime.Frame
A Frame holds per-call information that needs to persist outside the
execution of a given method. Currently a frame holds the following:
- The class against which this method is being invoked. This is usually (always?) the class of "self" within this call.
- The current "self" for the call.
- The name of the method being invoked during this frame, used for backtraces and "super" invocations.
- The block passed to this invocation. If the given code body can't accept a block, it will be Block.NULL_BLOCK.
- Whether this is the frame used for a binding-related call like eval. This is used to determine where to terminate evaled code's backtrace.
- The current visibility for methods defined during this call. Starts out as PUBLIC by default (in most cases) and can be modified by appropriate Kernel.public/private/protected calls.
- The jump target marker for non-local returns.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFrame()
Empty constructor, since Frame objects are pre-allocated and updated when needed. -
Method Summary
Modifier and TypeMethodDescriptioncapture()
clear()
Clear the frame, as when the call completes.void
Clone this frame.Clone this frame for use in backtraces only (avoiding long-lived references to other elements.getBackRef
(IRubyObject nil) getBlock()
Retrieve the block associated with this frame.getKlazz()
Return class that we are calling againstgetLastLine
(IRubyObject nil) getName()
Get the method name associated with this framegetSelf()
Get the self associated with this frameGet the visibility at the time of this frameboolean
setBackRef
(IRubyObject backRef) void
setCaptured
(boolean captured) void
setKlazz
(RubyModule klazz) Set the class we are calling against.setLastLine
(IRubyObject lastLine) void
Set the method name associated with this framevoid
setSelf
(IRubyObject self) Set the self associated with this framevoid
setVisibility
(Visibility visibility) Change the visibility associated with this frametoString()
void
Update the frame with just filename and line, used for top-level frames and method.void
updateFrame
(String name) Update the frame with caller information and method name, so it will show up correctly in call stacks.void
updateFrame
(RubyModule klazz, IRubyObject self, String name, Block block) Update the frame based on the given values.void
updateFrame
(RubyModule klazz, IRubyObject self, String name, Visibility visibility, Block block) Update the frame based on the given values.void
updateFrame
(Frame frame) Update the frame based on information from another frame.void
void
Update the frame based on the given values.
-
Field Details
-
DUMMY
Deprecated.
-
-
Constructor Details
-
Frame
public Frame()Empty constructor, since Frame objects are pre-allocated and updated when needed.
-
-
Method Details
-
updateFrame
public void updateFrame()Update the frame with just filename and line, used for top-level frames and method. -
updateFrame
Update the frame with caller information and method name, so it will show up correctly in call stacks.- Parameters:
name
- The name of the method being called
-
updateFrame
Update the frame based on information from another frame. Used for cloning frames (for blocks, usually) and when entering class bodies.- Parameters:
frame
- The frame whose data to duplicate in this frame
-
updateFrame
Update the frame based on the given values.- Parameters:
klazz
- The class against which the method is being calledself
- The 'self' for the methodname
- The name under which the method is being invokedblock
- The block passed to the method
-
updateFrame
public void updateFrame(RubyModule klazz, IRubyObject self, String name, Visibility visibility, Block block) Update the frame based on the given values.- Parameters:
klazz
- The class against which the method is being calledself
- The 'self' for the methodname
- The name under which the method is being invokedblock
- The block passed to the method
-
updateFrameForEval
Update the frame based on the given values.- Parameters:
self
- The 'self' for the method
-
updateFrameForBackref
public void updateFrameForBackref() -
clearFrameForBackref
public void clearFrameForBackref() -
clear
Clear the frame, as when the call completes. Clearing prevents cached frames from holding references after the call is done. -
duplicate
Clone this frame.- Returns:
- A new frame with duplicate information to the target frame
-
duplicateForBacktrace
Clone this frame for use in backtraces only (avoiding long-lived references to other elements.- Returns:
- A new frame with identical backtrace information to this frame
-
getKlazz
Return class that we are calling against- Returns:
- The class we are calling against
-
setKlazz
Set the class we are calling against.- Parameters:
klazz
- the new class
-
setName
Set the method name associated with this frame- Parameters:
name
- the new name
-
getName
Get the method name associated with this frame- Returns:
- the method name
-
getSelf
Get the self associated with this frame- Returns:
- The self for the frame
-
setSelf
Set the self associated with this frame- Parameters:
self
- The new value of self
-
getVisibility
Get the visibility at the time of this frame- Returns:
- The visibility
-
setVisibility
Change the visibility associated with this frame- Parameters:
visibility
- The new visibility
-
getBlock
Retrieve the block associated with this frame.- Returns:
- The block of this frame or NULL_BLOCK if no block given
-
getBackRef
-
setBackRef
-
getLastLine
-
setLastLine
-
setCaptured
public void setCaptured(boolean captured) -
capture
-
isCaptured
public boolean isCaptured() -
toString
-