| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // LiveEdit feature implementation. The script should be executed after | 5 // LiveEdit feature implementation. The script should be executed after |
| 6 // debug.js. | 6 // debug.js. |
| 7 | 7 |
| 8 // A LiveEdit namespace. It contains functions that modifies JavaScript code | 8 // A LiveEdit namespace. It contains functions that modifies JavaScript code |
| 9 // according to changes of script source (if possible). | 9 // according to changes of script source (if possible). |
| 10 // | 10 // |
| (...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 | 1007 |
| 1008 var script = e.scriptObject; | 1008 var script = e.scriptObject; |
| 1009 | 1009 |
| 1010 var position_struct = { | 1010 var position_struct = { |
| 1011 start: createPositionStruct(script, e.startPosition), | 1011 start: createPositionStruct(script, e.startPosition), |
| 1012 end: createPositionStruct(script, e.endPosition) | 1012 end: createPositionStruct(script, e.endPosition) |
| 1013 }; | 1013 }; |
| 1014 details.position = position_struct; | 1014 details.position = position_struct; |
| 1015 } | 1015 } |
| 1016 | 1016 |
| 1017 // A testing entry. | |
| 1018 function GetPcFromSourcePos(func, source_pos) { | |
| 1019 return %GetFunctionCodePositionFromSource(func, source_pos); | |
| 1020 } | |
| 1021 | |
| 1022 // LiveEdit main entry point: changes a script text to a new string. | 1017 // LiveEdit main entry point: changes a script text to a new string. |
| 1023 function SetScriptSource(script, new_source, preview_only, change_log) { | 1018 function SetScriptSource(script, new_source, preview_only, change_log) { |
| 1024 var old_source = script.source; | 1019 var old_source = script.source; |
| 1025 var diff = CompareStrings(old_source, new_source); | 1020 var diff = CompareStrings(old_source, new_source); |
| 1026 return ApplyPatchMultiChunk(script, diff, new_source, preview_only, | 1021 return ApplyPatchMultiChunk(script, diff, new_source, preview_only, |
| 1027 change_log); | 1022 change_log); |
| 1028 } | 1023 } |
| 1029 | 1024 |
| 1030 function CompareStrings(s1, s2) { | 1025 function CompareStrings(s1, s2) { |
| 1031 return %LiveEditCompareStrings(s1, s2); | 1026 return %LiveEditCompareStrings(s1, s2); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1112 return ProcessOldNode(old_code_tree); | 1107 return ProcessOldNode(old_code_tree); |
| 1113 } | 1108 } |
| 1114 | 1109 |
| 1115 // ------------------------------------------------------------------- | 1110 // ------------------------------------------------------------------- |
| 1116 // Exports | 1111 // Exports |
| 1117 | 1112 |
| 1118 var LiveEdit = {}; | 1113 var LiveEdit = {}; |
| 1119 LiveEdit.SetScriptSource = SetScriptSource; | 1114 LiveEdit.SetScriptSource = SetScriptSource; |
| 1120 LiveEdit.ApplyPatchMultiChunk = ApplyPatchMultiChunk; | 1115 LiveEdit.ApplyPatchMultiChunk = ApplyPatchMultiChunk; |
| 1121 LiveEdit.Failure = Failure; | 1116 LiveEdit.Failure = Failure; |
| 1122 LiveEdit.GetPcFromSourcePos = GetPcFromSourcePos; | |
| 1123 | 1117 |
| 1124 LiveEdit.TestApi = { | 1118 LiveEdit.TestApi = { |
| 1125 PosTranslator: PosTranslator, | 1119 PosTranslator: PosTranslator, |
| 1126 CompareStrings: CompareStrings, | 1120 CompareStrings: CompareStrings, |
| 1127 ApplySingleChunkPatch: ApplySingleChunkPatch | 1121 ApplySingleChunkPatch: ApplySingleChunkPatch |
| 1128 }; | 1122 }; |
| 1129 | 1123 |
| 1130 global.Debug.LiveEdit = LiveEdit; | 1124 global.Debug.LiveEdit = LiveEdit; |
| 1131 | 1125 |
| 1132 }) | 1126 }) |
| OLD | NEW |