/////////////////////////////////////////////////////////////////////// internal void Refresh( ArgumentCallback argumentCallback, EvaluateScriptCallback evaluateScriptCallback, EvaluateFileCallback evaluateFileCallback, EvaluateEncodedFileCallback evaluateEncodedFileCallback, InteractiveLoopCallback interactiveLoopCallback ) { if (!hadArgumentCallback) { this.argumentCallback = argumentCallback; } if (!hadEvaluateScriptCallback) { this.evaluateScriptCallback = evaluateScriptCallback; } if (!hadEvaluateFileCallback) { this.evaluateFileCallback = evaluateFileCallback; } if (!hadEvaluateEncodedFileCallback) { this.evaluateEncodedFileCallback = evaluateEncodedFileCallback; } if (!hadInteractiveLoopCallback) { this.interactiveLoopCallback = interactiveLoopCallback; } }
/////////////////////////////////////////////////////////////////////// private /* protected virtual */ void Dispose( bool disposing ) { TraceOps.DebugTrace(String.Format( "Dispose: disposing = {0}, interpreter = {1}, disposed = {2}", disposing, FormatOps.InterpreterNoThrow(interpreter), disposed), typeof(EngineContext).Name, TracePriority.CleanupDebug); if (!disposed) { if (disposing) { //////////////////////////////////// // dispose managed resources here... //////////////////////////////////// interpreter = null; /* NOT OWNED: Do not dispose. */ threadId = 0; /////////////////////////////////////////////////////////// #if DEBUGGER interactiveLoopCallback = null; #endif /////////////////////////////////////////////////////////// #if SHELL argumentCallback = null; evaluateScriptCallback = null; evaluateFileCallback = null; evaluateEncodedFileCallback = null; #endif /////////////////////////////////////////////////////////// levels = 0; maximumLevels = 0; scriptLevels = 0; maximumScriptLevels = 0; parserLevels = 0; maximumParserLevels = 0; expressionLevels = 0; maximumExpressionLevels = 0; previousLevels = 0; catchLevels = 0; unknownLevels = 0; traceLevels = 0; subCommandLevels = 0; #if ARGUMENT_CACHE cacheArgument = null; #endif #if DEBUGGER watchpointLevels = 0; #endif #if NOTIFY || NOTIFY_OBJECT notifyLevels = 0; notifyTypes = NotifyType.None; notifyFlags = NotifyFlags.None; #endif policyLevels = 0; testLevels = 0; #if DEBUGGER isDebuggerExiting = false; #endif stackOverflow = false; #if DEBUGGER if (debugger != null) { IDisposable disposable = debugger as IDisposable; if (disposable != null) { disposable.Dispose(); disposable = null; } debugger = null; } #endif #if PREVIOUS_RESULT previousResult = null; #endif engineFlags = EngineFlags.None; parseState = null; returnCode = ReturnCode.Ok; errorLine = 0; errorCode = null; errorInfo = null; errorFrames = 0; exception = null; scriptLocation = null; /////////////////////////////////////////////////////////// if (scriptLocations != null) { scriptLocations.Clear(); scriptLocations = null; } /////////////////////////////////////////////////////////// previousProcessId = 0; /////////////////////////////////////////////////////////// if (arraySearches != null) { arraySearches.Clear(); arraySearches = null; } /////////////////////////////////////////////////////////// #if HISTORY historyEngineFilter = null; if (history != null) { history.Clear(); history = null; } #endif /////////////////////////////////////////////////////////// complaint = null; } ////////////////////////////////////// // release unmanaged resources here... ////////////////////////////////////// disposed = true; } }
/////////////////////////////////////////////////////////////////////// #region Debugger Breakpoint Support Methods #if DEBUGGER public static ReturnCode Breakpoint( IDebugger debugger, Interpreter interpreter, InteractiveLoopData loopData, ref Result result ) { if (interpreter == null) { result = "invalid interpreter"; return(ReturnCode.Error); } if (!interpreter.Interactive) { result = "cannot break into interactive loop"; return(ReturnCode.Error); } if (debugger != null) { /* IGNORED */ debugger.EnterLoop(); } try { ReturnCode code; InteractiveLoopCallback interactiveLoopCallback = interpreter.InteractiveLoopCallback; if (interactiveLoopCallback != null) { code = interactiveLoopCallback( interpreter, new InteractiveLoopData(loopData, true), ref result); } else { #if SHELL // // NOTE: This is the only place in the debugger subsystem // where the InteractiveLoop method may be called. // All other methods in the Debugger class and/or // any external classes that desire the interactive // debugging functionality should call this method. // code = Interpreter.InteractiveLoop( interpreter, new InteractiveLoopData(loopData, true), ref result); #else result = "not implemented"; code = ReturnCode.Error; #endif } // // NOTE: Only check (or update) the interpreter state at this // point if the interpreter is still usable (i.e. it is // not disposed) -AND- the interactive loop returned a // successful result. // if ((code == ReturnCode.Ok) && Engine.IsUsable(interpreter)) { // // NOTE: Upon exiting the interactive loop, temporarily // prevent the engine from checking interpreter // readiness. This is used to avoid potentially // breaking back into the interactive loop due to // breakpoints caused by script cancellation, etc. // interpreter.IsDebuggerExiting = true; } return(code); } finally { if (debugger != null) { /* IGNORED */ debugger.ExitLoop(); } } }