OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 // Start with breakpoints. Convert their line/column positions and | 179 // Start with breakpoints. Convert their line/column positions and |
180 // temporary remove. | 180 // temporary remove. |
181 var break_points_restorer = TemporaryRemoveBreakPoints(script, change_log); | 181 var break_points_restorer = TemporaryRemoveBreakPoints(script, change_log); |
182 | 182 |
183 var old_script; | 183 var old_script; |
184 | 184 |
185 // Create an old script only if there are function that should be linked | 185 // Create an old script only if there are function that should be linked |
186 // to old version. | 186 // to old version. |
187 if (link_to_old_script_list.length == 0) { | 187 if (link_to_old_script_list.length == 0) { |
188 %LiveEditReplaceScript(script, new_source, null); | 188 %LiveEditReplaceScript(script, new_source, null); |
189 old_script = void 0; | 189 old_script = UNDEFINED; |
190 } else { | 190 } else { |
191 var old_script_name = CreateNameForOldScript(script); | 191 var old_script_name = CreateNameForOldScript(script); |
192 | 192 |
193 // Update the script text and create a new script representing an old | 193 // Update the script text and create a new script representing an old |
194 // version of the script. | 194 // version of the script. |
195 old_script = %LiveEditReplaceScript(script, new_source, | 195 old_script = %LiveEditReplaceScript(script, new_source, |
196 old_script_name); | 196 old_script_name); |
197 | 197 |
198 var link_to_old_script_report = new Array(); | 198 var link_to_old_script_report = new Array(); |
199 change_log.push( { linked_to_old_script: link_to_old_script_report } ); | 199 change_log.push( { linked_to_old_script: link_to_old_script_report } ); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 | 259 |
260 // Sort function infos by start position field. | 260 // Sort function infos by start position field. |
261 var compile_info = new Array(); | 261 var compile_info = new Array(); |
262 var old_index_map = new Array(); | 262 var old_index_map = new Array(); |
263 for (var i = 0; i < raw_compile_info.length; i++) { | 263 for (var i = 0; i < raw_compile_info.length; i++) { |
264 var info = new FunctionCompileInfo(raw_compile_info[i]); | 264 var info = new FunctionCompileInfo(raw_compile_info[i]); |
265 // Remove all links to the actual script. Breakpoints system and | 265 // Remove all links to the actual script. Breakpoints system and |
266 // LiveEdit itself believe that any function in heap that points to a | 266 // LiveEdit itself believe that any function in heap that points to a |
267 // particular script is a regular function. | 267 // particular script is a regular function. |
268 // For some functions we will restore this link later. | 268 // For some functions we will restore this link later. |
269 %LiveEditFunctionSetScript(info.shared_function_info, void 0); | 269 %LiveEditFunctionSetScript(info.shared_function_info, UNDEFINED); |
270 compile_info.push(info); | 270 compile_info.push(info); |
271 old_index_map.push(i); | 271 old_index_map.push(i); |
272 } | 272 } |
273 | 273 |
274 for (var i = 0; i < compile_info.length; i++) { | 274 for (var i = 0; i < compile_info.length; i++) { |
275 var k = i; | 275 var k = i; |
276 for (var j = i + 1; j < compile_info.length; j++) { | 276 for (var j = i + 1; j < compile_info.length; j++) { |
277 if (compile_info[k].start_position > compile_info[j].start_position) { | 277 if (compile_info[k].start_position > compile_info[j].start_position) { |
278 k = j; | 278 k = j; |
279 } | 279 } |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 CHANGED: "changed", | 535 CHANGED: "changed", |
536 // Function is changed but cannot be patched. | 536 // Function is changed but cannot be patched. |
537 DAMAGED: "damaged" | 537 DAMAGED: "damaged" |
538 }; | 538 }; |
539 | 539 |
540 function CodeInfoTreeNode(code_info, children, array_index) { | 540 function CodeInfoTreeNode(code_info, children, array_index) { |
541 this.info = code_info; | 541 this.info = code_info; |
542 this.children = children; | 542 this.children = children; |
543 // an index in array of compile_info | 543 // an index in array of compile_info |
544 this.array_index = array_index; | 544 this.array_index = array_index; |
545 this.parent = void 0; | 545 this.parent = UNDEFINED; |
546 | 546 |
547 this.status = FunctionStatus.UNCHANGED; | 547 this.status = FunctionStatus.UNCHANGED; |
548 // Status explanation is used for debugging purposes and will be shown | 548 // Status explanation is used for debugging purposes and will be shown |
549 // in user UI if some explanations are needed. | 549 // in user UI if some explanations are needed. |
550 this.status_explanation = void 0; | 550 this.status_explanation = UNDEFINED; |
551 this.new_start_pos = void 0; | 551 this.new_start_pos = UNDEFINED; |
552 this.new_end_pos = void 0; | 552 this.new_end_pos = UNDEFINED; |
553 this.corresponding_node = void 0; | 553 this.corresponding_node = UNDEFINED; |
554 this.unmatched_new_nodes = void 0; | 554 this.unmatched_new_nodes = UNDEFINED; |
555 | 555 |
556 // 'Textual' correspondence/matching is weaker than 'pure' | 556 // 'Textual' correspondence/matching is weaker than 'pure' |
557 // correspondence/matching. We need 'textual' level for visual presentation | 557 // correspondence/matching. We need 'textual' level for visual presentation |
558 // in UI, we use 'pure' level for actual code manipulation. | 558 // in UI, we use 'pure' level for actual code manipulation. |
559 // Sometimes only function body is changed (functions in old and new script | 559 // Sometimes only function body is changed (functions in old and new script |
560 // textually correspond), but we cannot patch the code, so we see them | 560 // textually correspond), but we cannot patch the code, so we see them |
561 // as an old function deleted and new function created. | 561 // as an old function deleted and new function created. |
562 this.textual_corresponding_node = void 0; | 562 this.textual_corresponding_node = UNDEFINED; |
563 this.textually_unmatched_new_nodes = void 0; | 563 this.textually_unmatched_new_nodes = UNDEFINED; |
564 | 564 |
565 this.live_shared_function_infos = void 0; | 565 this.live_shared_function_infos = UNDEFINED; |
566 } | 566 } |
567 | 567 |
568 // From array of function infos that is implicitly a tree creates | 568 // From array of function infos that is implicitly a tree creates |
569 // an actual tree of functions in script. | 569 // an actual tree of functions in script. |
570 function BuildCodeInfoTree(code_info_array) { | 570 function BuildCodeInfoTree(code_info_array) { |
571 // Throughtout all function we iterate over input array. | 571 // Throughtout all function we iterate over input array. |
572 var index = 0; | 572 var index = 0; |
573 | 573 |
574 // Recursive function that builds a branch of tree. | 574 // Recursive function that builds a branch of tree. |
575 function BuildNode() { | 575 function BuildNode() { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 old_children[old_index].new_end_pos) { | 733 old_children[old_index].new_end_pos) { |
734 old_children[old_index].corresponding_node = | 734 old_children[old_index].corresponding_node = |
735 new_children[new_index]; | 735 new_children[new_index]; |
736 old_children[old_index].textual_corresponding_node = | 736 old_children[old_index].textual_corresponding_node = |
737 new_children[new_index]; | 737 new_children[new_index]; |
738 if (scope_change_description) { | 738 if (scope_change_description) { |
739 old_children[old_index].status = FunctionStatus.DAMAGED; | 739 old_children[old_index].status = FunctionStatus.DAMAGED; |
740 old_children[old_index].status_explanation = | 740 old_children[old_index].status_explanation = |
741 "Enclosing function is now incompatible. " + | 741 "Enclosing function is now incompatible. " + |
742 scope_change_description; | 742 scope_change_description; |
743 old_children[old_index].corresponding_node = void 0; | 743 old_children[old_index].corresponding_node = UNDEFINED; |
744 } else if (old_children[old_index].status != | 744 } else if (old_children[old_index].status != |
745 FunctionStatus.UNCHANGED) { | 745 FunctionStatus.UNCHANGED) { |
746 ProcessNode(old_children[old_index], | 746 ProcessNode(old_children[old_index], |
747 new_children[new_index]); | 747 new_children[new_index]); |
748 if (old_children[old_index].status == FunctionStatus.DAMAGED) { | 748 if (old_children[old_index].status == FunctionStatus.DAMAGED) { |
749 unmatched_new_nodes_list.push( | 749 unmatched_new_nodes_list.push( |
750 old_children[old_index].corresponding_node); | 750 old_children[old_index].corresponding_node); |
751 old_children[old_index].corresponding_node = void 0; | 751 old_children[old_index].corresponding_node = UNDEFINED; |
752 old_node.status = FunctionStatus.CHANGED; | 752 old_node.status = FunctionStatus.CHANGED; |
753 } | 753 } |
754 } | 754 } |
755 } else { | 755 } else { |
756 old_children[old_index].status = FunctionStatus.DAMAGED; | 756 old_children[old_index].status = FunctionStatus.DAMAGED; |
757 old_children[old_index].status_explanation = | 757 old_children[old_index].status_explanation = |
758 "No corresponding function in new script found"; | 758 "No corresponding function in new script found"; |
759 old_node.status = FunctionStatus.CHANGED; | 759 old_node.status = FunctionStatus.CHANGED; |
760 unmatched_new_nodes_list.push(new_children[new_index]); | 760 unmatched_new_nodes_list.push(new_children[new_index]); |
761 textually_unmatched_new_nodes_list.push(new_children[new_index]); | 761 textually_unmatched_new_nodes_list.push(new_children[new_index]); |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 // Function is public. | 1134 // Function is public. |
1135 this.RestartFrame = RestartFrame; | 1135 this.RestartFrame = RestartFrame; |
1136 | 1136 |
1137 // Functions are public for tests. | 1137 // Functions are public for tests. |
1138 this.TestApi = { | 1138 this.TestApi = { |
1139 PosTranslator: PosTranslator, | 1139 PosTranslator: PosTranslator, |
1140 CompareStrings: CompareStrings, | 1140 CompareStrings: CompareStrings, |
1141 ApplySingleChunkPatch: ApplySingleChunkPatch | 1141 ApplySingleChunkPatch: ApplySingleChunkPatch |
1142 }; | 1142 }; |
1143 }; | 1143 }; |
OLD | NEW |