Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Unified Diff: src/debug-debugger.js

Issue 289473005: Use table to dispatch debug commands. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/debug-debugger.js
diff --git a/src/debug-debugger.js b/src/debug-debugger.js
index 0ce88328ba3b4eb7d7dc5d09da677727a06ba789..ebd7dbd4d6cf568a6d0da9ae496afac4fe030535 100644
--- a/src/debug-debugger.js
+++ b/src/debug-debugger.js
@@ -1388,63 +1388,10 @@ DebugCommandProcessor.prototype.processDebugJSONRequest = function(
}
}
- if (request.command == 'continue') {
- this.continueRequest_(request, response);
- } else if (request.command == 'break') {
- this.breakRequest_(request, response);
- } else if (request.command == 'setbreakpoint') {
- this.setBreakPointRequest_(request, response);
- } else if (request.command == 'changebreakpoint') {
- this.changeBreakPointRequest_(request, response);
- } else if (request.command == 'clearbreakpoint') {
- this.clearBreakPointRequest_(request, response);
- } else if (request.command == 'clearbreakpointgroup') {
- this.clearBreakPointGroupRequest_(request, response);
- } else if (request.command == 'disconnect') {
- this.disconnectRequest_(request, response);
- } else if (request.command == 'setexceptionbreak') {
- this.setExceptionBreakRequest_(request, response);
- } else if (request.command == 'listbreakpoints') {
- this.listBreakpointsRequest_(request, response);
- } else if (request.command == 'backtrace') {
- this.backtraceRequest_(request, response);
- } else if (request.command == 'frame') {
- this.frameRequest_(request, response);
- } else if (request.command == 'scopes') {
- this.scopesRequest_(request, response);
- } else if (request.command == 'scope') {
- this.scopeRequest_(request, response);
- } else if (request.command == 'setVariableValue') {
- this.setVariableValueRequest_(request, response);
- } else if (request.command == 'evaluate') {
- this.evaluateRequest_(request, response);
- } else if (request.command == 'lookup') {
- this.lookupRequest_(request, response);
- } else if (request.command == 'references') {
- this.referencesRequest_(request, response);
- } else if (request.command == 'source') {
- this.sourceRequest_(request, response);
- } else if (request.command == 'scripts') {
- this.scriptsRequest_(request, response);
- } else if (request.command == 'threads') {
- this.threadsRequest_(request, response);
- } else if (request.command == 'suspend') {
- this.suspendRequest_(request, response);
- } else if (request.command == 'version') {
- this.versionRequest_(request, response);
- } else if (request.command == 'changelive') {
- this.changeLiveRequest_(request, response);
- } else if (request.command == 'restartframe') {
- this.restartFrameRequest_(request, response);
- } else if (request.command == 'flags') {
- this.debuggerFlagsRequest_(request, response);
- } else if (request.command == 'v8flags') {
- this.v8FlagsRequest_(request, response);
-
- // GC tools:
- } else if (request.command == 'gc') {
- this.gcRequest_(request, response);
-
+ var key = request.command.toLowerCase();
+ var handler = DebugCommandProcessor.prototype.dispatch_[key];
+ if (IS_FUNCTION(handler)) {
+ %_CallFunction(this, request, response, handler);
} else {
throw new Error('Unknown command "' + request.command + '" in request');
}
@@ -2492,6 +2439,40 @@ DebugCommandProcessor.prototype.gcRequest_ = function(request, response) {
};
+DebugCommandProcessor.prototype.dispatch_ = (function() {
+ var proto = DebugCommandProcessor.prototype;
+ return {
+ "continue": proto.continueRequest_,
+ "break" : proto.breakRequest_,
+ "setbreakpoint" : proto.setBreakPointRequest_,
+ "changebreakpoint": proto.changeBreakPointRequest_,
+ "clearbreakpoint": proto.clearBreakPointRequest_,
+ "clearbreakpointgroup": proto.clearBreakPointGroupRequest_,
+ "disconnect": proto.disconnectRequest_,
+ "setexceptionbreak": proto.setExceptionBreakRequest_,
+ "listbreakpoints": proto.listBreakpointsRequest_,
+ "backtrace": proto.backtraceRequest_,
+ "frame": proto.frameRequest_,
+ "scopes": proto.scopesRequest_,
+ "scope": proto.scopeRequest_,
+ "setvariablevalue": proto.setVariableValueRequest_,
+ "evaluate": proto.evaluateRequest_,
+ "lookup": proto.lookupRequest_,
+ "references": proto.referencesRequest_,
+ "source": proto.sourceRequest_,
+ "scripts": proto.scriptsRequest_,
+ "threads": proto.threadsRequest_,
+ "suspend": proto.suspendRequest_,
+ "version": proto.versionRequest_,
+ "changelive": proto.changeLiveRequest_,
+ "restartframe": proto.restartFrameRequest_,
+ "flags": proto.debuggerFlagsRequest_,
+ "v8flag": proto.v8FlagsRequest_,
+ "gc": proto.gcRequest_,
+ };
+})();
+
+
// Check whether the previously processed command caused the VM to become
// running.
DebugCommandProcessor.prototype.isRunning = function() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698