| 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 2000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2011 for (var i = 0; i < scripts.length; i++) { | 2011 for (var i = 0; i < scripts.length; i++) { |
| 2012 if (scripts[i].id == script_id) { | 2012 if (scripts[i].id == script_id) { |
| 2013 the_script = scripts[i]; | 2013 the_script = scripts[i]; |
| 2014 } | 2014 } |
| 2015 } | 2015 } |
| 2016 if (!the_script) { | 2016 if (!the_script) { |
| 2017 response.failed('Script not found'); | 2017 response.failed('Script not found'); |
| 2018 return; | 2018 return; |
| 2019 } | 2019 } |
| 2020 | 2020 |
| 2021 // A function that calls a proper signature of LiveEdit API. | |
| 2022 var invocation; | |
| 2023 | |
| 2024 var change_log = new Array(); | 2021 var change_log = new Array(); |
| 2025 | 2022 |
| 2026 if (IS_STRING(request.arguments.new_source)) { | 2023 if (!IS_STRING(request.arguments.new_source)) { |
| 2027 var new_source = request.arguments.new_source; | 2024 throw "new_source argument expected"; |
| 2028 invocation = function() { | |
| 2029 return Debug.LiveEdit.SetScriptSource(the_script, new_source, change_log); | |
| 2030 } | |
| 2031 } else { | |
| 2032 var change_pos = parseInt(request.arguments.change_pos); | |
| 2033 var change_len = parseInt(request.arguments.change_len); | |
| 2034 var new_string = request.arguments.new_string; | |
| 2035 if (!IS_STRING(new_string)) { | |
| 2036 response.failed('Argument "new_string" is not a string value'); | |
| 2037 return; | |
| 2038 } | |
| 2039 invocation = function() { | |
| 2040 return Debug.LiveEdit.ApplyPatch(the_script, change_pos, change_len, | |
| 2041 new_string, change_log); | |
| 2042 } | |
| 2043 } | 2025 } |
| 2044 | 2026 |
| 2027 var new_source = request.arguments.new_source; |
| 2028 |
| 2045 try { | 2029 try { |
| 2046 invocation(); | 2030 Debug.LiveEdit.SetScriptSource(the_script, new_source, change_log); |
| 2047 } catch (e) { | 2031 } catch (e) { |
| 2048 if (e instanceof Debug.LiveEdit.Failure) { | 2032 if (e instanceof Debug.LiveEdit.Failure) { |
| 2049 // Let's treat it as a "success" so that body with change_log will be | 2033 // Let's treat it as a "success" so that body with change_log will be |
| 2050 // sent back. "change_log" will have "failure" field set. | 2034 // sent back. "change_log" will have "failure" field set. |
| 2051 change_log.push( { failure: true, message: e.toString() } ); | 2035 change_log.push( { failure: true, message: e.toString() } ); |
| 2052 } else { | 2036 } else { |
| 2053 throw e; | 2037 throw e; |
| 2054 } | 2038 } |
| 2055 } | 2039 } |
| 2056 response.body = {change_log: change_log}; | 2040 response.body = {change_log: change_log}; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2176 case 'string': | 2160 case 'string': |
| 2177 case 'number': | 2161 case 'number': |
| 2178 json = value; | 2162 json = value; |
| 2179 break | 2163 break |
| 2180 | 2164 |
| 2181 default: | 2165 default: |
| 2182 json = null; | 2166 json = null; |
| 2183 } | 2167 } |
| 2184 return json; | 2168 return json; |
| 2185 } | 2169 } |
| OLD | NEW |