Class Dim


  • public class Dim
    extends java.lang.Object
    Dim or Debugger Implementation for Rhino.
    • Field Detail

      • IPROXY_STRING_IS_COMPILABLE

        private static final int IPROXY_STRING_IS_COMPILABLE
        See Also:
        Constant Field Values
      • IPROXY_OBJECT_TO_STRING

        private static final int IPROXY_OBJECT_TO_STRING
        See Also:
        Constant Field Values
      • IPROXY_OBJECT_PROPERTY

        private static final int IPROXY_OBJECT_PROPERTY
        See Also:
        Constant Field Values
      • callback

        private GuiCallback callback
        Interface to the debugger GUI.
      • breakFlag

        private boolean breakFlag
        Whether the debugger should break.
      • scopeProvider

        private ScopeProvider scopeProvider
        The ScopeProvider object that provides the scope in which to evaluate script.
      • sourceProvider

        private SourceProvider sourceProvider
        The SourceProvider object that provides the source of evaluated scripts.
      • frameIndex

        private int frameIndex
        The index of the current stack frame.
      • interruptedContextData

        private volatile Dim.ContextData interruptedContextData
        Information about the current stack at the point of interruption.
      • contextFactory

        private ContextFactory contextFactory
        The ContextFactory to listen to for debugging information.
      • monitor

        private java.lang.Object monitor
        Synchronization object used to allow script evaluations to happen when a thread is resumed.
      • eventThreadMonitor

        private java.lang.Object eventThreadMonitor
        Synchronization object used to wait for valid interruptedContextData.
      • returnValue

        private volatile int returnValue
        The action to perform to end the interruption loop.
      • insideInterruptLoop

        private boolean insideInterruptLoop
        Whether the debugger is inside the interruption loop.
      • evalRequest

        private java.lang.String evalRequest
        The requested script string to be evaluated when the thread has been resumed.
      • evalResult

        private java.lang.String evalResult
        The result of evaluating evalRequest.
      • breakOnExceptions

        private boolean breakOnExceptions
        Whether the debugger should break when a script exception is thrown.
      • breakOnEnter

        private boolean breakOnEnter
        Whether the debugger should break when a script function is entered.
      • breakOnReturn

        private boolean breakOnReturn
        Whether the debugger should break when a script function is returned from.
      • urlToSourceInfo

        private final java.util.Map<java.lang.String,​Dim.SourceInfo> urlToSourceInfo
        Table mapping URLs to information about the script source.
      • functionNames

        private final java.util.Map<java.lang.String,​Dim.FunctionSource> functionNames
        Table mapping function names to information about the function.
    • Constructor Detail

      • Dim

        public Dim()
    • Method Detail

      • setGuiCallback

        public void setGuiCallback​(GuiCallback callback)
        Sets the GuiCallback object to use.
      • setBreak

        public void setBreak()
        Tells the debugger to break at the next opportunity.
      • setScopeProvider

        public void setScopeProvider​(ScopeProvider scopeProvider)
        Sets the ScopeProvider to be used.
      • setSourceProvider

        public void setSourceProvider​(SourceProvider sourceProvider)
        Sets the ScopeProvider to be used.
      • contextSwitch

        public void contextSwitch​(int frameIndex)
        Switches context to the stack frame with the given index.
      • setBreakOnExceptions

        public void setBreakOnExceptions​(boolean breakOnExceptions)
        Sets whether the debugger should break on exceptions.
      • setBreakOnEnter

        public void setBreakOnEnter​(boolean breakOnEnter)
        Sets whether the debugger should break on function entering.
      • setBreakOnReturn

        public void setBreakOnReturn​(boolean breakOnReturn)
        Sets whether the debugger should break on function return.
      • attachTo

        public void attachTo​(ContextFactory factory)
        Attaches the debugger to the given ContextFactory.
      • detach

        public void detach()
        Detaches the debugger from the current ContextFactory.
      • dispose

        public void dispose()
        Releases resources associated with this debugger.
      • loadSource

        private java.lang.String loadSource​(java.lang.String sourceUrl)
        Loads the script at the given URL.
      • registerTopScript

        private void registerTopScript​(DebuggableScript topScript,
                                       java.lang.String source)
        Registers the given script as a top-level script in the debugger.
      • functionNames

        public java.lang.String[] functionNames()
        Returns an array of all function names.
      • functionSourceByName

        public Dim.FunctionSource functionSourceByName​(java.lang.String functionName)
        Returns the FunctionSource object for the function with the given name.
      • sourceInfo

        public Dim.SourceInfo sourceInfo​(java.lang.String url)
        Returns the SourceInfo object for the given URL.
      • getNormalizedUrl

        private java.lang.String getNormalizedUrl​(DebuggableScript fnOrScript)
        Returns the source URL for the given script or function.
      • clearAllBreakpoints

        public void clearAllBreakpoints()
        Clears all breakpoints.
      • handleBreakpointHit

        private void handleBreakpointHit​(Dim.StackFrame frame,
                                         Context cx)
        Called when a breakpoint has been hit.
      • handleExceptionThrown

        private void handleExceptionThrown​(Context cx,
                                           java.lang.Throwable ex,
                                           Dim.StackFrame frame)
        Called when a script exception has been thrown.
      • currentContextData

        public Dim.ContextData currentContextData()
        Returns the current ContextData object.
      • setReturnValue

        public void setReturnValue​(int returnValue)
        Sets the action to perform to end interruption.
      • go

        public void go()
        Resumes execution of script.
      • eval

        public java.lang.String eval​(java.lang.String expr)
        Evaluates the given script.
      • compileScript

        public void compileScript​(java.lang.String url,
                                  java.lang.String text)
        Compiles the given script.
      • evalScript

        public void evalScript​(java.lang.String url,
                               java.lang.String text)
        Evaluates the given script.
      • objectToString

        public java.lang.String objectToString​(java.lang.Object object)
        Converts the given script object to a string.
      • stringIsCompilableUnit

        public boolean stringIsCompilableUnit​(java.lang.String str)
        Returns whether the given string is syntactically valid script.
      • getObjectProperty

        public java.lang.Object getObjectProperty​(java.lang.Object object,
                                                  java.lang.Object id)
        Returns the value of a property on the given script object.
      • getObjectIds

        public java.lang.Object[] getObjectIds​(java.lang.Object object)
        Returns an array of the property names on the given script object.
      • getObjectPropertyImpl

        private java.lang.Object getObjectPropertyImpl​(Context cx,
                                                       java.lang.Object object,
                                                       java.lang.Object id)
        Returns the value of a property on the given script object.
      • getObjectIdsImpl

        private java.lang.Object[] getObjectIdsImpl​(Context cx,
                                                    java.lang.Object object)
        Returns an array of the property names on the given script object.
      • interrupted

        private void interrupted​(Context cx,
                                 Dim.StackFrame frame,
                                 java.lang.Throwable scriptException)
        Interrupts script execution.
      • do_eval

        private static java.lang.String do_eval​(Context cx,
                                                Dim.StackFrame frame,
                                                java.lang.String expr)
        Evaluates script in the given stack frame.