| Index: src/debug-debugger.js
|
| ===================================================================
|
| --- src/debug-debugger.js (revision 3964)
|
| +++ src/debug-debugger.js (working copy)
|
| @@ -1251,7 +1251,9 @@
|
| } else if (request.command == 'version') {
|
| this.versionRequest_(request, response);
|
| } else if (request.command == 'profile') {
|
| - this.profileRequest_(request, response);
|
| + this.profileRequest_(request, response);
|
| + } else if (request.command == 'changelive') {
|
| + this.changeLiveRequest_(request, response);
|
| } else {
|
| throw new Error('Unknown command "' + request.command + '" in request');
|
| }
|
| @@ -1954,6 +1956,52 @@
|
| };
|
|
|
|
|
| +DebugCommandProcessor.prototype.changeLiveRequest_ = function(request, response) {
|
| + if (!Debug.LiveEditChangeScript) {
|
| + return response.failed('LiveEdit feature is not supported');
|
| + }
|
| + if (!request.arguments) {
|
| + return response.failed('Missing arguments');
|
| + }
|
| + var script_id = request.arguments.script_id;
|
| + var change_pos = parseInt(request.arguments.change_pos);
|
| + var change_len = parseInt(request.arguments.change_len);
|
| + var new_string = request.arguments.new_string;
|
| + if (!IS_STRING(new_string)) {
|
| + response.failed('Argument "new_string" is not a string value');
|
| + return;
|
| + }
|
| +
|
| + var scripts = %DebugGetLoadedScripts();
|
| +
|
| + var the_script = null;
|
| + for (var i = 0; i < scripts.length; i++) {
|
| + if (scripts[i].id == script_id) {
|
| + the_script = scripts[i];
|
| + }
|
| + }
|
| + if (!the_script) {
|
| + response.failed('Script not found');
|
| + return;
|
| + }
|
| +
|
| + var change_log = new Array();
|
| + try {
|
| + Debug.LiveEditChangeScript(the_script, change_pos, change_len, new_string,
|
| + change_log);
|
| + } catch (e) {
|
| + if (e instanceof Debug.LiveEditChangeScript.Failure) {
|
| + // Let's treat it as a "success" so that body with change_log will be
|
| + // sent back. "change_log" will have "failure" field set.
|
| + change_log.push( { failure: true } );
|
| + } else {
|
| + throw e;
|
| + }
|
| + }
|
| + response.body = {change_log: change_log};
|
| +};
|
| +
|
| +
|
| // Check whether the previously processed command caused the VM to become
|
| // running.
|
| DebugCommandProcessor.prototype.isRunning = function() {
|
|
|