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)
           
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()
           
 RubyModule getEvalBindingRubyClass()
           
 FiberLibrary.Fiber getFiber()
           
 java.lang.String getFile()
           
 Block getFrameBlock()
           
 int getFrameCount()
           
 JumpTarget getFrameJumpTarget()
           
 RubyModule getFrameKlazz()
           
 java.lang.String getFrameName()
           
 IRubyObject getFrameSelf()
           
 RubyModule getImmediateBindingRubyClass()
           
 CallType getLastCallType()
           
 IRubyObject getLastExitStatus()
           
 Visibility getLastVisibility()
           
 int getLine()
           
 Frame getNextFrame()
           
 Frame getPreviousFrame()
           
 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 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, java.lang.String[] scopeNames)
           
 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 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 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()
           
 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(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)

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()

getImmediateBindingRubyClass

public RubyModule getImmediateBindingRubyClass()

getEvalBindingRubyClass

public RubyModule getEvalBindingRubyClass()

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,
                             java.lang.String[] scopeNames)

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)

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)

postMethodBacktraceOnly

public void postMethodBacktraceOnly()

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


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