org.jruby.runtime
Class Frame

java.lang.Object
  extended by org.jruby.runtime.Frame
All Implemented Interfaces:
JumpTarget

public final class Frame
extends java.lang.Object
implements JumpTarget

A Frame holds per-call information that needs to persist outside the execution of a given method. Currently a frame holds the following:

Frames are allocated for all Ruby methods (in compatibility mode, default) and for some core methods. In general, a frame is required for a method to show up in a backtrace, and so some methods only use frame for backtrace information (so-called "backtrace frames").

See Also:
ThreadContext

Constructor Summary
Frame()
          Empty constructor, since Frame objects are pre-allocated and updated when needed.
 
Method Summary
 void clear()
          Clear the frame, as when the call completes.
 Frame duplicate()
          Clone this frame.
 Block getBlock()
          Retrieve the block associated with this frame.
 java.lang.String getFile()
          Get the filename of the caller.
 JumpTarget getJumpTarget()
          Get the jump target for non-local returns in this frame.
 RubyModule getKlazz()
          Return class that we are calling against
 int getLine()
          Get the line number where this call is being made.
 java.lang.String getName()
          Get the method name associated with this frame
 Visibility getVisibility()
          Get the visibility at the time of this frame
 boolean isBindingFrame()
          Is this frame the frame which started a binding eval?
 void setFile(java.lang.String fileName)
          Set the filename of the caller.
 void setFileAndLine(java.lang.String file, int line)
          Set both the file and line
 void setIsBindingFrame(boolean isBindingFrame)
          Set whether this is a binding frame or not
 void setJumpTarget(JumpTarget jumpTarget)
          Deprecated. 
 void setKlazz(RubyModule klazz)
          Set the class we are calling against.
 void setLine(int line)
          Set the line number where this call is being made
 void setName(java.lang.String name)
          Set the method name associated with this frame
 void setSelf(IRubyObject self)
          Set the self associated with this frame
 void setVisibility(Visibility visibility)
          Change the visibility associated with this frame
 java.lang.String toString()
           
 void updateFrame(Frame frame)
          Update the frame based on information from another frame.
 void updateFrame(RubyModule klazz, IRubyObject self, java.lang.String name, Block block, java.lang.String fileName, int line)
          Update the frame based on the given values.
 void updateFrame(java.lang.String fileName, int line)
          Update the frame with just filename and line, used for top-level frames and method.
 void updateFrame(java.lang.String name, java.lang.String fileName, int line)
          Update the frame with caller information and method name, so it will show up correctly in call stacks.
 void updateFrameForEval(IRubyObject self, java.lang.String fileName, int line)
          Update the frame based on the given values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Frame

public Frame()
Empty constructor, since Frame objects are pre-allocated and updated when needed.

Method Detail

updateFrame

public void updateFrame(java.lang.String fileName,
                        int line)
Update the frame with just filename and line, used for top-level frames and method.

Parameters:
fileName - The file where the calling method is located
line - The line number in the calling method where the call is made

updateFrame

public void updateFrame(java.lang.String name,
                        java.lang.String fileName,
                        int line)
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
fileName - The file of the calling method
line - The line number of the call to this method

updateFrame

public void updateFrame(Frame frame)
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

public void updateFrame(RubyModule klazz,
                        IRubyObject self,
                        java.lang.String name,
                        Block block,
                        java.lang.String fileName,
                        int line)
Update the frame based on the given values.

Parameters:
klazz - The class against which the method is being called
self - The 'self' for the method
name - The name under which the method is being invoked
block - The block passed to the method
fileName - The filename of the calling method
line - The line number where the call is being made
jumpTarget - The target for non-local jumps (return in block)

updateFrameForEval

public void updateFrameForEval(IRubyObject self,
                               java.lang.String fileName,
                               int line)
Update the frame based on the given values.

Parameters:
klazz - The class against which the method is being called
self - The 'self' for the method
name - The name under which the method is being invoked
block - The block passed to the method
fileName - The filename of the calling method
line - The line number where the call is being made
jumpTarget - The target for non-local jumps (return in block)

clear

public void clear()
Clear the frame, as when the call completes. Clearing prevents cached frames from holding references after the call is done.


duplicate

public Frame duplicate()
Clone this frame.

Returns:
A new frame with duplicate information to the target frame

getJumpTarget

public JumpTarget getJumpTarget()
Get the jump target for non-local returns in this frame.

Returns:
The jump target for non-local returns

setJumpTarget

@Deprecated
public void setJumpTarget(JumpTarget jumpTarget)
Deprecated. 

Set the jump target for non-local returns in this frame.

Parameters:
jumpTarget - The new jump target for non-local returns

getFile

public java.lang.String getFile()
Get the filename of the caller.

Returns:
The filename of the caller

setFile

public void setFile(java.lang.String fileName)
Set the filename of the caller.

Parameters:
fileName -

getLine

public int getLine()
Get the line number where this call is being made.

Returns:
The line number where this call is being made

setLine

public void setLine(int line)
Set the line number where this call is being made

Parameters:
line - The new line number where this call is being made

setFileAndLine

public void setFileAndLine(java.lang.String file,
                           int line)
Set both the file and line


getKlazz

public RubyModule getKlazz()
Return class that we are calling against

Returns:
The class we are calling against

setKlazz

public void setKlazz(RubyModule klazz)
Set the class we are calling against.

Parameters:
klazz - the new class

setName

public void setName(java.lang.String name)
Set the method name associated with this frame

Parameters:
name - the new name

getName

public java.lang.String getName()
Get the method name associated with this frame

Returns:
the method name

setSelf

public void setSelf(IRubyObject self)
Set the self associated with this frame

Parameters:
self - The new value of self

getVisibility

public Visibility getVisibility()
Get the visibility at the time of this frame

Returns:
The visibility

setVisibility

public void setVisibility(Visibility visibility)
Change the visibility associated with this frame

Parameters:
visibility - The new visibility

isBindingFrame

public boolean isBindingFrame()
Is this frame the frame which started a binding eval?

Returns:
Whether this is a binding frame

setIsBindingFrame

public void setIsBindingFrame(boolean isBindingFrame)
Set whether this is a binding frame or not

Parameters:
isBindingFrame - Whether this is a binding frame

getBlock

public Block getBlock()
Retrieve the block associated with this frame.

Returns:
The block of this frame or NULL_BLOCK if no block given

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2002-2007 JRuby Team. All Rights Reserved.