OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 2052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2063 | 2063 |
2064 | 2064 |
2065 DebugCommandProcessor.prototype.changeLiveRequest_ = function(request, response)
{ | 2065 DebugCommandProcessor.prototype.changeLiveRequest_ = function(request, response)
{ |
2066 if (!Debug.LiveEdit) { | 2066 if (!Debug.LiveEdit) { |
2067 return response.failed('LiveEdit feature is not supported'); | 2067 return response.failed('LiveEdit feature is not supported'); |
2068 } | 2068 } |
2069 if (!request.arguments) { | 2069 if (!request.arguments) { |
2070 return response.failed('Missing arguments'); | 2070 return response.failed('Missing arguments'); |
2071 } | 2071 } |
2072 var script_id = request.arguments.script_id; | 2072 var script_id = request.arguments.script_id; |
| 2073 var preview_only = !!request.arguments.preview_only; |
2073 | 2074 |
2074 var scripts = %DebugGetLoadedScripts(); | 2075 var scripts = %DebugGetLoadedScripts(); |
2075 | 2076 |
2076 var the_script = null; | 2077 var the_script = null; |
2077 for (var i = 0; i < scripts.length; i++) { | 2078 for (var i = 0; i < scripts.length; i++) { |
2078 if (scripts[i].id == script_id) { | 2079 if (scripts[i].id == script_id) { |
2079 the_script = scripts[i]; | 2080 the_script = scripts[i]; |
2080 } | 2081 } |
2081 } | 2082 } |
2082 if (!the_script) { | 2083 if (!the_script) { |
2083 response.failed('Script not found'); | 2084 response.failed('Script not found'); |
2084 return; | 2085 return; |
2085 } | 2086 } |
2086 | 2087 |
2087 var change_log = new Array(); | 2088 var change_log = new Array(); |
2088 | 2089 |
2089 if (!IS_STRING(request.arguments.new_source)) { | 2090 if (!IS_STRING(request.arguments.new_source)) { |
2090 throw "new_source argument expected"; | 2091 throw "new_source argument expected"; |
2091 } | 2092 } |
2092 | 2093 |
2093 var new_source = request.arguments.new_source; | 2094 var new_source = request.arguments.new_source; |
2094 | 2095 |
2095 try { | 2096 var result_description = Debug.LiveEdit.SetScriptSource(the_script, |
2096 Debug.LiveEdit.SetScriptSource(the_script, new_source, change_log); | 2097 new_source, preview_only, change_log); |
2097 } catch (e) { | 2098 response.body = {change_log: change_log, result: result_description}; |
2098 if (e instanceof Debug.LiveEdit.Failure) { | |
2099 // Let's treat it as a "success" so that body with change_log will be | |
2100 // sent back. "change_log" will have "failure" field set. | |
2101 change_log.push( { failure: true, message: e.toString() } ); | |
2102 } else { | |
2103 throw e; | |
2104 } | |
2105 } | |
2106 response.body = {change_log: change_log}; | |
2107 }; | 2099 }; |
2108 | 2100 |
2109 | 2101 |
2110 // Check whether the previously processed command caused the VM to become | 2102 // Check whether the previously processed command caused the VM to become |
2111 // running. | 2103 // running. |
2112 DebugCommandProcessor.prototype.isRunning = function() { | 2104 DebugCommandProcessor.prototype.isRunning = function() { |
2113 return this.running_; | 2105 return this.running_; |
2114 } | 2106 } |
2115 | 2107 |
2116 | 2108 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2226 case 'string': | 2218 case 'string': |
2227 case 'number': | 2219 case 'number': |
2228 json = value; | 2220 json = value; |
2229 break | 2221 break |
2230 | 2222 |
2231 default: | 2223 default: |
2232 json = null; | 2224 json = null; |
2233 } | 2225 } |
2234 return json; | 2226 return json; |
2235 } | 2227 } |
OLD | NEW |