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
FieldsModifier and TypeFieldDescriptionprivate IRubyObjectbackrefprivate BlockThe block that was passed in for this frame (as either a block or a &block argument).(package private) booleanwhether this frame has been captured into a bindingstatic final FrameDeprecated.private RubyModuleThe class against which this call is executing.private IRubyObjectlastlineprivate StringThe name of the method being invoked in this frame.private IRubyObjectThe 'self' for this frame.private VisibilityThe current visibility for anything defined under this frame -
Constructor Summary
ConstructorsModifierConstructorDescriptionFrame()Empty constructor, since Frame objects are pre-allocated and updated when needed.privateUsed only by static init to avoid accessing NULL_BLOCK before initialized.privateCopy 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.voidClone 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 framebooleansetBackRef(IRubyObject backRef) voidsetCaptured(boolean captured) voidsetKlazz(RubyModule klazz) Set the class we are calling against.setLastLine(IRubyObject lastLine) voidSet the method name associated with this framevoidsetSelf(IRubyObject self) Set the self associated with this framevoidsetVisibility(Visibility visibility) Change the visibility associated with this frametoString()voidUpdate the frame with just filename and line, used for top-level frames and method.voidupdateFrame(String name) Update the frame with caller information and method name, so it will show up correctly in call stacks.voidupdateFrame(RubyModule klazz, IRubyObject self, String name, Block block) Update the frame based on the given values.voidupdateFrame(RubyModule klazz, IRubyObject self, String name, Visibility visibility, Block block) Update the frame based on the given values.voidupdateFrame(Frame frame) Update the frame based on information from another frame.voidvoidUpdate the frame based on the given values.
-
Field Details
-
klazz
The class against which this call is executing. -
self
The 'self' for this frame. -
name
The name of the method being invoked in this frame. -
block
The block that was passed in for this frame (as either a block or a &block argument). The frame captures the block for super/zsuper, but also for Proc.new (with no arguments) and also for block_given?. Both of those methods needs access to the block of the previous frame to work. -
visibility
The current visibility for anything defined under this frame -
backRef
backref -
lastLine
lastline -
captured
boolean capturedwhether this frame has been captured into a binding -
DUMMY
Deprecated.
-
-
Constructor Details
-
Frame
public Frame()Empty constructor, since Frame objects are pre-allocated and updated when needed. -
Frame
Used only by static init to avoid accessing NULL_BLOCK before initialized.- Parameters:
nullBlock-
-
Frame
Copy 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
-