org.jruby.runtime
Class ThreadContext

java.lang.Object
  extended by org.jruby.runtime.ThreadContext

public final class ThreadContext
extends java.lang.Object


Nested Class Summary
static class ThreadContext.FrameType
           
static class ThreadContext.RubyStackTraceElement
           
 
Field Summary
static java.util.Map<java.lang.String,ThreadContext.FrameType> INTERPRETED_FRAMES
           
 
Method Summary
 void callThreadPoll()
           
 Frame[] createBacktrace(int level, boolean nativeException)
          Create an Array with backtrace information.
 ThreadContext.RubyStackTraceElement[] createBacktrace2(int level, boolean nativeException)
          Create an Array with backtrace information.
static IRubyObject createBacktraceFromFrames(Ruby runtime, ThreadContext.RubyStackTraceElement[] backtraceFrames)
          Create an Array with backtrace information.
static IRubyObject createBacktraceFromFrames(Ruby runtime, ThreadContext.RubyStackTraceElement[] backtraceFrames, boolean cropAtEval)
          Create an Array with backtrace information.
 IRubyObject createCallerBacktrace(Ruby runtime, int level)
          Create an Array with backtrace information.
static IRubyObject createRawBacktrace(Ruby runtime, java.lang.StackTraceElement[] stackTrace, boolean filter)
           
static java.lang.String createRawBacktraceStringFromThrowable(java.lang.Throwable t)
           
static IRubyObject createRubyCompiledBacktrace(Ruby runtime, java.lang.StackTraceElement[] stackTrace)
           
static IRubyObject createRubyHybridBacktrace(Ruby runtime, ThreadContext.RubyStackTraceElement[] backtraceFrames, ThreadContext.RubyStackTraceElement[] stackTrace, boolean debug)
           
 Binding currentBinding()
          Return a binding representing the current call's state
 Binding currentBinding(IRubyObject self)
          Return a binding representing the current call's state but with a specified self
 Binding currentBinding(IRubyObject self, DynamicScope scope)
          Return a binding representing the current call's state but with the specified scope and self.
 Binding currentBinding(IRubyObject self, Visibility visibility)
          Return a binding representing the current call's state but with the specified visibility and self.
 Binding currentBinding(IRubyObject self, Visibility visibility, DynamicScope scope)
          Return a binding representing the current call's state but with the specified visibility, scope, and self.
protected  void finalize()
           
 RubyKernel.CatchTarget[] getActiveCatches()
           
 IRubyObject getConstant(java.lang.String internedName)
          Used by the evaluator and the compiler to look up a constant by name
 boolean getConstantDefined(java.lang.String internedName)
           
 Frame getCurrentFrame()
           
 Frame getCurrentRubyFrame()
           
 DynamicScope getCurrentScope()
           
 Visibility getCurrentVisibility()
           
 IRubyObject getErrorInfo()
           
 FiberLibrary.Fiber getFiber()
           
 java.lang.String getFile()
           
 Block getFrameBlock()
           
 int getFrameCount()
           
 JumpTarget getFrameJumpTarget()
           
 RubyModule getFrameKlazz()
           
 java.lang.String getFrameName()
           
 IRubyObject getFrameSelf()
           
 CallType getLastCallType()
           
 IRubyObject getLastExitStatus()
           
 Visibility getLastVisibility()
           
 int getLine()
           
 Frame getNextFrame()
           
 Frame getPreviousFrame()
           
 RubyModule getPreviousRubyClass()
           
 DynamicScope getPreviousScope()
           
 Visibility getPreviousVisibility()
           
 RubyModule getRubyClass()
           
 int getRubyFrameDelta()
           
 Ruby getRuntime()
           
 RubyThread getThread()
           
 boolean isWithinDefined()
          Is this thread actively in defined? at the moment.
 boolean isWithinTrace()
          Is this thread actively tracing at this moment.
static ThreadContext newContext(Ruby runtime)
           
 void pollThreadEvents()
           
 void popCatch()
           
 RubyModule popRubyClass()
           
 void popScope()
           
 void postBsfApply()
           
 void postClassEval()
           
 void postCompiledClass()
           
 void postEvalScriptlet()
           
 void postEvalWithBinding(Binding binding, Frame lastFrame)
           
 void postExecuteUnder()
           
 void postMethodBacktraceAndScope()
           
 void postMethodBacktraceDummyScope()
           
 void postMethodBacktraceOnly()
           
 void postMethodFrameAndScope()
           
 void postMethodFrameOnly()
           
 void postMethodScopeOnly()
           
 void postMproc()
           
 void postNodeEval()
           
 void postScopedBody()
           
 void postScopeNode()
           
 void postTrace()
           
 void postYield(Binding binding, Frame lastFrame)
           
 void postYieldLight(Binding binding, Frame lastFrame)
           
 void postYieldNoScope(Frame lastFrame)
           
 void preAdoptThread()
           
 void preBsfApply(java.lang.String[] names)
           
 void preClassEval(StaticScope staticScope, RubyModule type)
           
 void preCompiledClass(RubyModule type, StaticScope staticScope)
           
 void preCompiledClassDummyScope(RubyModule type, StaticScope staticScope)
           
 void preEvalScriptlet(DynamicScope scope)
           
 Frame preEvalWithBinding(Binding binding)
           
 void preExecuteUnder(RubyModule executeUnderClass, Block block)
           
 Frame preForBlock(Binding binding, RubyModule klass)
           
 void preMethodBacktraceAndScope(java.lang.String name, RubyModule clazz, StaticScope staticScope)
           
 void preMethodBacktraceDummyScope(RubyModule clazz, java.lang.String name, StaticScope staticScope)
           
 void preMethodBacktraceOnly(java.lang.String name)
           
 void preMethodFrameAndDummyScope(RubyModule clazz, java.lang.String name, IRubyObject self, Block block, StaticScope staticScope)
           
 void preMethodFrameAndScope(RubyModule clazz, java.lang.String name, IRubyObject self, Block block, StaticScope staticScope)
           
 void preMethodFrameOnly(RubyModule clazz, java.lang.String name, IRubyObject self, Block block)
           
 void preMethodNoFrameAndDummyScope(RubyModule clazz, StaticScope staticScope)
           
 void preMethodScopeOnly(RubyModule clazz, StaticScope staticScope)
           
 void preMproc()
           
 void preNodeEval(RubyModule rubyClass, IRubyObject self)
           
 void preNodeEval(RubyModule rubyClass, IRubyObject self, java.lang.String name)
           
 void prepareTopLevel(RubyClass objectClass, IRubyObject topSelf)
           
 void preRunThread(Frame currentFrame)
           
 void preScopedBody(DynamicScope scope)
           
 void preScopeNode(StaticScope staticScope)
           
 void preTrace()
           
 Binding previousBinding()
          Return a binding representing the previous call's state
 Binding previousBinding(IRubyObject self)
          Return a binding representing the previous call's state but with a specified self
 Frame preYieldLightBlock(Binding binding, DynamicScope emptyScope, RubyModule klass)
           
 Frame preYieldNoScope(Binding binding, RubyModule klass)
           
 Frame preYieldSpecificBlock(Binding binding, StaticScope scope, RubyModule klass)
           
 void printScope()
           
 void pushCatch(RubyKernel.CatchTarget catchTarget)
           
 void pushRubyClass(RubyModule currentModule)
           
 void pushScope(DynamicScope scope)
           
 JumpException.ReturnJump returnJump(IRubyObject value)
           
 IRubyObject setConstantInCurrent(java.lang.String internedName, IRubyObject result)
          Used by the evaluator and the compiler to set a constant by name This is for a null const decl
 IRubyObject setConstantInModule(java.lang.String internedName, IRubyObject target, IRubyObject result)
          Used by the evaluator and the compiler to set a constant by name.
 IRubyObject setConstantInObject(java.lang.String internedName, IRubyObject result)
          Used by the evaluator and the compiler to set a constant by name This is for a Colon2 const decl
 void setCurrentVisibility(Visibility visibility)
           
 IRubyObject setErrorInfo(IRubyObject errorInfo)
           
 void setFiber(FiberLibrary.Fiber fiber)
           
 void setFile(java.lang.String file)
           
 void setFileAndLine(Frame frame)
           
 void setFileAndLine(ISourcePosition position)
           
 void setFileAndLine(java.lang.String file, int line)
           
 void setFrameJumpTarget(JumpTarget target)
          Deprecated. 
 void setLastCallStatus(CallType callType)
          Returns the lastCallStatus.
 void setLastCallStatusAndVisibility(CallType callType, Visibility visibility)
           
 void setLastExitStatus(IRubyObject lastExitStatus)
           
 void setLastVisibility(Visibility visibility)
           
 void setLine(int line)
           
 void setRubyFrameDelta(int newDelta)
           
 void setThread(RubyThread thread)
           
 void setWithinDefined(boolean isWithinDefined)
          Set whether we are actively within defined? or not.
 void setWithinTrace(boolean isWithinTrace)
          Set whether we are actively tracing or not on this thread.
 void trace(RubyEvent event, java.lang.String name, RubyModule implClass)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INTERPRETED_FRAMES

public static final java.util.Map<java.lang.String,ThreadContext.FrameType> INTERPRETED_FRAMES
Method Detail

newContext

public static ThreadContext newContext(Ruby runtime)

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

getRuntime

public final Ruby getRuntime()

getErrorInfo

public IRubyObject getErrorInfo()

setErrorInfo

public IRubyObject setErrorInfo(IRubyObject errorInfo)

returnJump

public JumpException.ReturnJump returnJump(IRubyObject value)

setLastCallStatus

public void setLastCallStatus(CallType callType)
Returns the lastCallStatus.


getLastCallType

public CallType getLastCallType()

setLastVisibility

public void setLastVisibility(Visibility visibility)

getLastVisibility

public Visibility getLastVisibility()

setLastCallStatusAndVisibility

public void setLastCallStatusAndVisibility(CallType callType,
                                           Visibility visibility)

getLastExitStatus

public IRubyObject getLastExitStatus()

setLastExitStatus

public void setLastExitStatus(IRubyObject lastExitStatus)

printScope

public void printScope()

getCurrentScope

public DynamicScope getCurrentScope()

getPreviousScope

public DynamicScope getPreviousScope()

pushScope

public void pushScope(DynamicScope scope)

popScope

public void popScope()

getThread

public RubyThread getThread()

setThread

public void setThread(RubyThread thread)

getFiber

public FiberLibrary.Fiber getFiber()

setFiber

public void setFiber(FiberLibrary.Fiber fiber)

pushCatch

public void pushCatch(RubyKernel.CatchTarget catchTarget)

popCatch

public void popCatch()

getActiveCatches

public RubyKernel.CatchTarget[] getActiveCatches()

getCurrentFrame

public Frame getCurrentFrame()

getRubyFrameDelta

public int getRubyFrameDelta()

setRubyFrameDelta

public void setRubyFrameDelta(int newDelta)

getCurrentRubyFrame

public Frame getCurrentRubyFrame()

getNextFrame

public Frame getNextFrame()

getPreviousFrame

public Frame getPreviousFrame()

getFrameCount

public int getFrameCount()

getFrameName

public java.lang.String getFrameName()

getFrameSelf

public IRubyObject getFrameSelf()

getFrameJumpTarget

public JumpTarget getFrameJumpTarget()

setFrameJumpTarget

@Deprecated
public void setFrameJumpTarget(JumpTarget target)
Deprecated. 


getFrameKlazz

public RubyModule getFrameKlazz()

getFrameBlock

public Block getFrameBlock()

getFile

public java.lang.String getFile()

getLine

public int getLine()

setFile

public void setFile(java.lang.String file)

setLine

public void setLine(int line)

setFileAndLine

public void setFileAndLine(java.lang.String file,
                           int line)

setFileAndLine

public void setFileAndLine(Frame frame)

setFileAndLine

public void setFileAndLine(ISourcePosition position)

getCurrentVisibility

public Visibility getCurrentVisibility()

getPreviousVisibility

public Visibility getPreviousVisibility()

setCurrentVisibility

public void setCurrentVisibility(Visibility visibility)

pollThreadEvents

public void pollThreadEvents()

callThreadPoll

public void callThreadPoll()

trace

public void trace(RubyEvent event,
                  java.lang.String name,
                  RubyModule implClass)

pushRubyClass

public void pushRubyClass(RubyModule currentModule)

popRubyClass

public RubyModule popRubyClass()

getRubyClass

public RubyModule getRubyClass()

getPreviousRubyClass

public RubyModule getPreviousRubyClass()

getConstantDefined

public boolean getConstantDefined(java.lang.String internedName)

getConstant

public IRubyObject getConstant(java.lang.String internedName)
Used by the evaluator and the compiler to look up a constant by name


setConstantInCurrent

public IRubyObject setConstantInCurrent(java.lang.String internedName,
                                        IRubyObject result)
Used by the evaluator and the compiler to set a constant by name This is for a null const decl


setConstantInModule

public IRubyObject setConstantInModule(java.lang.String internedName,
                                       IRubyObject target,
                                       IRubyObject result)
Used by the evaluator and the compiler to set a constant by name. This is for a Colon2 const decl


setConstantInObject

public IRubyObject setConstantInObject(java.lang.String internedName,
                                       IRubyObject result)
Used by the evaluator and the compiler to set a constant by name This is for a Colon2 const decl


createBacktraceFromFrames

public static IRubyObject createBacktraceFromFrames(Ruby runtime,
                                                    ThreadContext.RubyStackTraceElement[] backtraceFrames)
Create an Array with backtrace information.

Parameters:
runtime -
level -
nativeException -
Returns:
an Array with the backtrace

createCallerBacktrace

public IRubyObject createCallerBacktrace(Ruby runtime,
                                         int level)
Create an Array with backtrace information.

Parameters:
runtime -
level -
nativeException -
Returns:
an Array with the backtrace

createBacktraceFromFrames

public static IRubyObject createBacktraceFromFrames(Ruby runtime,
                                                    ThreadContext.RubyStackTraceElement[] backtraceFrames,
                                                    boolean cropAtEval)
Create an Array with backtrace information.

Parameters:
runtime -
level -
nativeException -
Returns:
an Array with the backtrace

createBacktrace

public Frame[] createBacktrace(int level,
                               boolean nativeException)
Create an Array with backtrace information.

Parameters:
runtime -
level -
nativeException -
Returns:
an Array with the backtrace

createBacktrace2

public ThreadContext.RubyStackTraceElement[] createBacktrace2(int level,
                                                              boolean nativeException)
Create an Array with backtrace information.

Parameters:
runtime -
level -
nativeException -
Returns:
an Array with the backtrace

createRawBacktraceStringFromThrowable

public static java.lang.String createRawBacktraceStringFromThrowable(java.lang.Throwable t)

createRawBacktrace

public static IRubyObject createRawBacktrace(Ruby runtime,
                                             java.lang.StackTraceElement[] stackTrace,
                                             boolean filter)

createRubyCompiledBacktrace

public static IRubyObject createRubyCompiledBacktrace(Ruby runtime,
                                                      java.lang.StackTraceElement[] stackTrace)

createRubyHybridBacktrace

public static IRubyObject createRubyHybridBacktrace(Ruby runtime,
                                                    ThreadContext.RubyStackTraceElement[] backtraceFrames,
                                                    ThreadContext.RubyStackTraceElement[] stackTrace,
                                                    boolean debug)

preAdoptThread

public void preAdoptThread()

preCompiledClass

public void preCompiledClass(RubyModule type,
                             StaticScope staticScope)

preCompiledClassDummyScope

public void preCompiledClassDummyScope(RubyModule type,
                                       StaticScope staticScope)

postCompiledClass

public void postCompiledClass()

preScopeNode

public void preScopeNode(StaticScope staticScope)

postScopeNode

public void postScopeNode()

preClassEval

public void preClassEval(StaticScope staticScope,
                         RubyModule type)

postClassEval

public void postClassEval()

preBsfApply

public void preBsfApply(java.lang.String[] names)

postBsfApply

public void postBsfApply()

preMethodFrameAndScope

public void preMethodFrameAndScope(RubyModule clazz,
                                   java.lang.String name,
                                   IRubyObject self,
                                   Block block,
                                   StaticScope staticScope)

preMethodFrameAndDummyScope

public void preMethodFrameAndDummyScope(RubyModule clazz,
                                        java.lang.String name,
                                        IRubyObject self,
                                        Block block,
                                        StaticScope staticScope)

preMethodNoFrameAndDummyScope

public void preMethodNoFrameAndDummyScope(RubyModule clazz,
                                          StaticScope staticScope)

postMethodFrameAndScope

public void postMethodFrameAndScope()

preMethodFrameOnly

public void preMethodFrameOnly(RubyModule clazz,
                               java.lang.String name,
                               IRubyObject self,
                               Block block)

postMethodFrameOnly

public void postMethodFrameOnly()

preMethodScopeOnly

public void preMethodScopeOnly(RubyModule clazz,
                               StaticScope staticScope)

postMethodScopeOnly

public void postMethodScopeOnly()

preMethodBacktraceAndScope

public void preMethodBacktraceAndScope(java.lang.String name,
                                       RubyModule clazz,
                                       StaticScope staticScope)

postMethodBacktraceAndScope

public void postMethodBacktraceAndScope()

preMethodBacktraceOnly

public void preMethodBacktraceOnly(java.lang.String name)

preMethodBacktraceDummyScope

public void preMethodBacktraceDummyScope(RubyModule clazz,
                                         java.lang.String name,
                                         StaticScope staticScope)

postMethodBacktraceOnly

public void postMethodBacktraceOnly()

postMethodBacktraceDummyScope

public void postMethodBacktraceDummyScope()

prepareTopLevel

public void prepareTopLevel(RubyClass objectClass,
                            IRubyObject topSelf)

preNodeEval

public void preNodeEval(RubyModule rubyClass,
                        IRubyObject self,
                        java.lang.String name)

preNodeEval

public void preNodeEval(RubyModule rubyClass,
                        IRubyObject self)

postNodeEval

public void postNodeEval()

preExecuteUnder

public void preExecuteUnder(RubyModule executeUnderClass,
                            Block block)

postExecuteUnder

public void postExecuteUnder()

preMproc

public void preMproc()

postMproc

public void postMproc()

preRunThread

public void preRunThread(Frame currentFrame)

preTrace

public void preTrace()

postTrace

public void postTrace()

preForBlock

public Frame preForBlock(Binding binding,
                         RubyModule klass)

preYieldSpecificBlock

public Frame preYieldSpecificBlock(Binding binding,
                                   StaticScope scope,
                                   RubyModule klass)

preYieldLightBlock

public Frame preYieldLightBlock(Binding binding,
                                DynamicScope emptyScope,
                                RubyModule klass)

preYieldNoScope

public Frame preYieldNoScope(Binding binding,
                             RubyModule klass)

preEvalScriptlet

public void preEvalScriptlet(DynamicScope scope)

postEvalScriptlet

public void postEvalScriptlet()

preEvalWithBinding

public Frame preEvalWithBinding(Binding binding)

postEvalWithBinding

public void postEvalWithBinding(Binding binding,
                                Frame lastFrame)

postYield

public void postYield(Binding binding,
                      Frame lastFrame)

postYieldLight

public void postYieldLight(Binding binding,
                           Frame lastFrame)

postYieldNoScope

public void postYieldNoScope(Frame lastFrame)

preScopedBody

public void preScopedBody(DynamicScope scope)

postScopedBody

public void postScopedBody()

isWithinTrace

public boolean isWithinTrace()
Is this thread actively tracing at this moment.

Returns:
true if so
See Also:
org.jruby.Ruby#callTraceFunction(String, ISourcePosition, IRubyObject, String, IRubyObject)

setWithinTrace

public void setWithinTrace(boolean isWithinTrace)
Set whether we are actively tracing or not on this thread.

Parameters:
isWithinTrace - true is so
See Also:
org.jruby.Ruby#callTraceFunction(String, ISourcePosition, IRubyObject, String, IRubyObject)

isWithinDefined

public boolean isWithinDefined()
Is this thread actively in defined? at the moment.

Returns:
true if within defined?

setWithinDefined

public void setWithinDefined(boolean isWithinDefined)
Set whether we are actively within defined? or not.

Parameters:
isWithinDefined - true if so

currentBinding

public Binding currentBinding()
Return a binding representing the current call's state

Returns:
the current binding

currentBinding

public Binding currentBinding(IRubyObject self)
Return a binding representing the current call's state but with a specified self

Parameters:
self - the self object to use
Returns:
the current binding, using the specified self

currentBinding

public Binding currentBinding(IRubyObject self,
                              Visibility visibility)
Return a binding representing the current call's state but with the specified visibility and self.

Parameters:
self - the self object to use
visibility - the visibility to use
Returns:
the current binding using the specified self and visibility

currentBinding

public Binding currentBinding(IRubyObject self,
                              DynamicScope scope)
Return a binding representing the current call's state but with the specified scope and self.

Parameters:
self - the self object to use
visibility - the scope to use
Returns:
the current binding using the specified self and scope

currentBinding

public Binding currentBinding(IRubyObject self,
                              Visibility visibility,
                              DynamicScope scope)
Return a binding representing the current call's state but with the specified visibility, scope, and self. For shared-scope binding consumers like for loops.

Parameters:
self - the self object to use
visibility - the visibility to use
scope - the scope to use
Returns:
the current binding using the specified self, scope, and visibility

previousBinding

public Binding previousBinding()
Return a binding representing the previous call's state

Returns:
the current binding

previousBinding

public Binding previousBinding(IRubyObject self)
Return a binding representing the previous call's state but with a specified self

Parameters:
self - the self object to use
Returns:
the current binding, using the specified self


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