Index: Source/bindings/dart/DartDebugHooks.js |
diff --git a/Source/bindings/dart/DartDebugHooks.js b/Source/bindings/dart/DartDebugHooks.js |
deleted file mode 100644 |
index fe02324bb2a690a8f3409183adf44c54ef422f2c..0000000000000000000000000000000000000000 |
--- a/Source/bindings/dart/DartDebugHooks.js |
+++ /dev/null |
@@ -1,456 +0,0 @@ |
-/* |
- * Copyright (C) 2012 Google Inc. All rights reserved. |
- * |
- * Redistribution and use in source and binary forms, with or without |
- * modification, are permitted provided that the following conditions are |
- * met: |
- * |
- * * Redistributions of source code must retain the above copyright |
- * notice, this list of conditions and the following disclaimer. |
- * * Redistributions in binary form must reproduce the above |
- * copyright notice, this list of conditions and the following disclaimer |
- * in the documentation and/or other materials provided with the |
- * distribution. |
- * * Neither the name of Google Inc. nor the names of its |
- * contributors may be used to endorse or promote products derived from |
- * this software without specific prior written permission. |
- * |
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
- */ |
- |
-(function() { |
- |
-// Monkey patch the ScopeType class defined by the V8 engine. |
-ScopeType.Instance = 6; |
-ScopeType.Class = 7; |
-ScopeType.Library = 8; |
- |
-var DartDebug = {}; |
- |
-DartDebug.ExecutionState = function(callFrames) |
-{ |
- this._callFrames = []; |
- for (var i = 0; i < callFrames.length; ++i) { |
- this._callFrames.push(new DartDebug.FrameMirror(callFrames[i])); |
- } |
-}; |
- |
-DartDebug.ExecutionState.prototype = { |
- frameCount: function() |
- { |
- return this._callFrames.length; |
- }, |
- |
- frame: function(index) |
- { |
- return this._callFrames[index]; |
- }, |
- |
- prepareStep: function(action, count) |
- { |
- if (action === Debug.StepAction.StepIn) |
- return DartDebug.nativeCallbacks.stepInto(); |
- if (action === Debug.StepAction.StepNext) |
- return DartDebug.nativeCallbacks.stepOver(); |
- if (action === Debug.StepAction.StepOut) |
- return DartDebug.nativeCallbacks.stepOut(); |
- } |
-}; |
- |
-DartDebug.EventData = function(exception) |
-{ |
- this._exception = exception; |
-}; |
- |
-DartDebug.EventData.prototype = { |
- exception: function() |
- { |
- return this._exception; |
- } |
-}; |
- |
-DartDebug.Script = function(id, scriptData) |
-{ |
- this.id = id; |
- this.url = scriptData.scriptURL; |
- this.source = scriptData.source; |
- this.line_offset = 0; |
- this.column_offset = 0; |
- this.context_data = scriptData.contextData; |
- this.language = 'Dart'; |
- this.libraryId = scriptData.libraryId; |
-}; |
- |
-DartDebug.Script.prototype = { |
- get line_ends() |
- { |
- var result = []; |
- var pos = this.source.indexOf('\n'); |
- while (pos !== -1) { |
- result.push(pos); |
- pos = this.source.indexOf('\n', pos + 1); |
- } |
- result.push(this.source.length); |
- return result; |
- }, |
- |
- nameOrSourceURL: function() |
- { |
- return this.url; |
- } |
-}; |
- |
-DartDebug.FrameMirror = function(callFrame) |
-{ |
- this._callFrame = callFrame; |
- this._functionName = callFrame.functionName; |
- this._scriptId = DartDebug.scriptURLToScriptId[callFrame.scriptURL]; |
- this._lineNumber = callFrame.lineNumber; |
- this._columnNumber = callFrame.columnNumber; |
- this._localScope = new DartDebug.ScopeMirror(callFrame.localScopeProxy, ScopeType.Local); |
- this._globalScope = new DartDebug.ScopeMirror(callFrame.libraryProxy, ScopeType.Global); |
- this._librariesScope = new DartDebug.ScopeMirror(callFrame.librariesProxy, ScopeType.Library); |
- |
- this._scopes = [this._localScope]; |
- if (callFrame.localScopeProxy.this) { |
- this._classInstanceScope = new DartDebug.ScopeMirror(callFrame.localScopeProxy.this, ScopeType.Instance); |
- this._scopes.push(this._classInstanceScope); |
- } |
- if (callFrame.classProxy) { |
- this._classScope = new DartDebug.ScopeMirror(callFrame.classProxy, ScopeType.Class); |
- this._scopes.push(this._classScope); |
- } |
- this._scopes.push(this._globalScope); |
- this._scopes.push(this._librariesScope); |
-}; |
- |
-DartDebug.FrameMirror.prototype = { |
- func: function() |
- { |
- var self = this; |
- return { |
- name: function() { return self._functionName; }, |
- inferredName: function() { return self._functionName; }, |
- script: function() { return { id: function() { return self._scriptId; } }; } |
- }; |
- }, |
- |
- sourceLocation: function() |
- { |
- return { line: this._lineNumber, column: this._columnNumber }; |
- }, |
- |
- scopeCount: function() |
- { |
- return this._scopes.length; |
- }, |
- |
- scope: function(index) |
- { |
- return this._scopes[index]; |
- }, |
- |
- allScopes: function(fastAsyncScopes) |
- { |
- return this._scopes; |
- }, |
- |
- evaluate: function(expression, disableBreak) |
- { |
- var result = DartDebug.nativeCallbacks.invocationTrampoline( |
- DartDebug.nativeCallbacks.evaluateInScope, |
- [expression, this._localScope.receiver(), this._callFrame.functionProxy, this._callFrame.localVariables]); |
- return { value: function() { return result; } }; |
- }, |
- |
- restart: function() { |
- return false; // Not yet supported by the Dart VM. |
- }, |
- |
- details: function() { |
- return this.details_; |
- }, |
- |
- get details_() |
- { |
- var receiver = this._localScope.receiver(); |
- var func = this.func(); |
- var sourceLocation = this.sourceLocation(); |
- return { |
- receiver: function() |
- { |
- return receiver; |
- }, |
- |
- func: function() |
- { |
- return func; |
- }, |
- |
- sourceLocation: function() |
- { |
- return sourceLocation; |
- }, |
- |
- isAtReturn: function() |
- { |
- // FIXMEDART: actually determine whether we are at a return. |
- return false; |
- } |
- }; |
- } |
-}; |
- |
-DartDebug.ScopeMirror = function(object, scopeType) |
-{ |
- this._object = object; |
- this._scopeType = scopeType; |
-}; |
- |
-DartDebug.ScopeMirror.prototype = { |
- scopeType: function() |
- { |
- return this._scopeType; |
- }, |
- |
- scopeObject: function() |
- { |
- var properties = []; |
- for (var name in this._object) { |
- if (name !== 'this') |
- properties.push(new DartDebug.PropertyMirror(name, this._object[name])); |
- } |
- return { properties: function() { return properties; } }; |
- }, |
- |
- get details_() |
- { |
- var object = this._object; |
- var type = this._scopeType; |
- return { |
- object: function() { return object; }, |
- type: function() { return type; } |
- }; |
- }, |
- |
- details: function() |
- { |
- return this.details_; |
- }, |
- |
- receiver: function() |
- { |
- return this._object['this']; |
- } |
-}; |
- |
-DartDebug.PropertyMirror = function(name, value) |
-{ |
- this._name = name; |
- this._value = value; |
-}; |
- |
-DartDebug.PropertyMirror.prototype = { |
- name: function() |
- { |
- return this._name; |
- }, |
- |
- get value_() |
- { |
- return this._value; |
- } |
-}; |
- |
-DartDebug.isolates = {}; |
- |
-DartDebug.scriptArray = []; |
-DartDebug.scripts = {}; |
-DartDebug.scriptURLToScriptId = {}; |
-DartDebug.lastScriptId = 0; |
- |
-DartDebug.breakpoints = {}; |
-DartDebug.lastBreakpointId = 0; |
- |
-DartDebug.registerIsolate = function(isolateHandle) |
-{ |
- this.isolates[isolateHandle] = true; |
-}; |
- |
-DartDebug.unregisterIsolate = function(isolateHandle) |
-{ |
- delete this.isolates[isolateHandle]; |
- if (Object.keys(this.isolates).length) |
- return; |
- |
- // The page was destroyed. |
- DartDebug.scripts = {}; |
- DartDebug.scriptArray = []; |
- DartDebug.scriptURLToScriptId = {}; |
- DartDebug.libraryScopeCache = {}; |
- DartDebug.breakpoints = {}; |
-}; |
- |
-DartDebug.isolateLoaded = function(isolateHandle) |
-{ |
- var isolateScripts = DartDebug.nativeCallbacks.scriptsForIsolate(isolateHandle); |
- for (var i = 0; i < isolateScripts.length; ++i) { |
- var script = DartDebug.registerScript(isolateHandle, isolateScripts[i]); |
- if (!script) |
- continue; |
- var executionState = {}; |
- var eventData = { script_: { script_: script } }; |
- DartDebug.nativeCallbacks.handleDebugEvent(Debug.DebugEvent.AfterCompile, executionState, eventData); |
- } |
- DartDebug.nativeCallbacks.setExceptionPauseInfo(isolateHandle, Debug.isBreakOnException(), Debug.isBreakOnUncaughtException()); |
-}; |
- |
-DartDebug.disable = function() |
-{ |
- for (var breakpointId in DartDebug.breakpoints) { |
- var vmBreakpoints = DartDebug.breakpoints[breakpointId].vmBreakpoints; |
- for (var i = 0; i < vmBreakpoints.length; ++i) |
- DartDebug.nativeCallbacks.removeBreakpoint(vmBreakpoints[i].isolateHandle, vmBreakpoints[i].id); |
- } |
- for (var isolateHandle in DartDebug.isolates) { |
- DartDebug.nativeCallbacks.setExceptionPauseInfo(isolateHandle, false, false); |
- } |
- DartDebug.breakpoints = {}; |
- DartDebug.scripts = {}; |
- DartDebug.scriptURLToScriptId = {}; |
-}; |
- |
-DartDebug.registerScript = function(isolateHandle, scriptData) |
-{ |
- if (scriptData.scriptURL in DartDebug.scriptURLToScriptId) |
- return; |
- |
- var scriptId = --this.lastScriptId; |
- var script = new DartDebug.Script(scriptId, scriptData); |
- |
- DartDebug.scripts[scriptId] = script; |
- DartDebug.scriptArray.push(script); |
- DartDebug.scriptURLToScriptId[scriptData.scriptURL] = scriptId; |
- |
- return script; |
-}; |
- |
-DartDebug.updateExceptionPauseInfo = function() |
-{ |
- for (var isolateHandle in DartDebug.isolates) |
- DartDebug.nativeCallbacks.setExceptionPauseInfo(isolateHandle, Debug.isBreakOnException(), Debug.isBreakOnUncaughtException()); |
-} |
- |
-var originals = {}; |
- |
-Debug.dartScripts = function() |
-{ |
- for (var isolateHandle in DartDebug.isolates) { |
- var isolateScripts = DartDebug.nativeCallbacks.scriptsForIsolate(isolateHandle); |
- for (var i = 0; i < isolateScripts.length; ++i) { |
- DartDebug.registerScript(isolateHandle, isolateScripts[i]); |
- } |
- } |
- return DartDebug.scriptArray; |
-}; |
- |
-originals.setScriptBreakPointById = Debug.setScriptBreakPointById; |
- |
-Debug.setScriptBreakPointById = function(scriptId, lineNumber) |
-{ |
- var script = DartDebug.scripts[scriptId]; |
- if (!script) |
- return originals.setScriptBreakPointById.apply(Debug, arguments); |
- |
- var vmBreakpoints = []; |
- for (var isolateHandle in DartDebug.isolates) { |
- var vmBreakpointId = DartDebug.nativeCallbacks.setBreakpoint(isolateHandle, script.url, lineNumber + 1); |
- if (vmBreakpointId) |
- vmBreakpoints.push({ id: vmBreakpointId, isolateHandle: isolateHandle }); |
- } |
- |
- var breakpointId = 'dart-' + (++DartDebug.lastBreakpointId); |
- DartDebug.breakpoints[breakpointId] = { vmBreakpoints: vmBreakpoints }; |
- return breakpointId; |
-}; |
- |
-originals.findBreakPointActualLocations = Debug.findBreakPointActualLocations; |
- |
-Debug.findBreakPointActualLocations = function(breakpointId) |
-{ |
- var breakpoint = DartDebug.breakpoints[breakpointId]; |
- if (!breakpoint) |
- return originals.findBreakPointActualLocations.apply(Debug, arguments); |
- |
- var locations = []; |
- var vmBreakpoints = breakpoint.vmBreakpoints; |
- for (var i = 0; i < vmBreakpoints.length; ++i) { |
- var lineNumber = DartDebug.nativeCallbacks.getBreakpointLine(vmBreakpoints[i].isolateHandle, vmBreakpoints[i].id); |
- // FIXME: provide column. |
- locations.push({ line: lineNumber - 1, column: 0 }); |
- } |
- return locations; |
-} |
- |
-originals.findBreakPoint = Debug.findBreakPoint; |
- |
-Debug.findBreakPoint = function(breakpointId, remove) |
-{ |
- var breakpoint = DartDebug.breakpoints[breakpointId]; |
- if (!breakpoint) |
- return originals.findBreakPoint.apply(Debug, arguments); |
- |
- if (remove) { |
- var vmBreakpoints = breakpoint.vmBreakpoints; |
- for (var i = 0; i < vmBreakpoints.length; ++i) |
- DartDebug.nativeCallbacks.removeBreakpoint(vmBreakpoints[i].isolateHandle, vmBreakpoints[i].id); |
- delete DartDebug.breakpoints[breakpointId]; |
- } |
-}; |
- |
- |
-originals.setBreakOnException = Debug.setBreakOnException; |
- |
-Debug.setBreakOnException = function() |
-{ |
- originals.setBreakOnException.apply(Debug); |
- DartDebug.updateExceptionPauseInfo(); |
-} |
- |
-originals.clearBreakOnException = Debug.clearBreakOnException; |
- |
-Debug.clearBreakOnException = function() |
-{ |
- originals.clearBreakOnException.apply(Debug); |
- DartDebug.updateExceptionPauseInfo(); |
-} |
- |
-originals.setBreakOnUncaughtException = Debug.setBreakOnUncaughtException; |
- |
-Debug.setBreakOnUncaughtException = function() |
-{ |
- originals.setBreakOnUncaughtException.apply(Debug); |
- DartDebug.updateExceptionPauseInfo(); |
-} |
- |
-originals.clearBreakOnUncaughtException = Debug.clearBreakOnUncaughtException; |
- |
-Debug.clearBreakOnUncaughtException = function() |
-{ |
- originals.clearBreakOnUncaughtException.apply(Debug); |
- DartDebug.updateExceptionPauseInfo(); |
-} |
- |
-return DartDebug; |
- |
-})() |