Revision f230a1cf deps/v8/src/liveedit-debugger.js
deps/v8/src/liveedit-debugger.js | ||
---|---|---|
186 | 186 |
// to old version. |
187 | 187 |
if (link_to_old_script_list.length == 0) { |
188 | 188 |
%LiveEditReplaceScript(script, new_source, null); |
189 |
old_script = void 0;
|
|
189 |
old_script = UNDEFINED;
|
|
190 | 190 |
} else { |
191 | 191 |
var old_script_name = CreateNameForOldScript(script); |
192 | 192 |
|
... | ... | |
221 | 221 |
change_log.push( {position_patched: position_patch_report} ); |
222 | 222 |
|
223 | 223 |
for (var i = 0; i < update_positions_list.length; i++) { |
224 |
// TODO(LiveEdit): take into account wether it's source_changed or |
|
224 |
// TODO(LiveEdit): take into account whether it's source_changed or
|
|
225 | 225 |
// unchanged and whether positions changed at all. |
226 | 226 |
PatchPositions(update_positions_list[i], diff_array, |
227 | 227 |
position_patch_report); |
... | ... | |
266 | 266 |
// LiveEdit itself believe that any function in heap that points to a |
267 | 267 |
// particular script is a regular function. |
268 | 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 | 270 |
compile_info.push(info); |
271 | 271 |
old_index_map.push(i); |
272 | 272 |
} |
... | ... | |
288 | 288 |
} |
289 | 289 |
} |
290 | 290 |
|
291 |
// After sorting update outer_inder field using old_index_map. Also
|
|
291 |
// After sorting update outer_index field using old_index_map. Also
|
|
292 | 292 |
// set next_sibling_index field. |
293 | 293 |
var current_index = 0; |
294 | 294 |
|
... | ... | |
542 | 542 |
this.children = children; |
543 | 543 |
// an index in array of compile_info |
544 | 544 |
this.array_index = array_index; |
545 |
this.parent = void 0;
|
|
545 |
this.parent = UNDEFINED;
|
|
546 | 546 |
|
547 | 547 |
this.status = FunctionStatus.UNCHANGED; |
548 | 548 |
// Status explanation is used for debugging purposes and will be shown |
549 | 549 |
// in user UI if some explanations are needed. |
550 |
this.status_explanation = void 0;
|
|
551 |
this.new_start_pos = void 0;
|
|
552 |
this.new_end_pos = void 0;
|
|
553 |
this.corresponding_node = void 0;
|
|
554 |
this.unmatched_new_nodes = void 0;
|
|
550 |
this.status_explanation = UNDEFINED;
|
|
551 |
this.new_start_pos = UNDEFINED;
|
|
552 |
this.new_end_pos = UNDEFINED;
|
|
553 |
this.corresponding_node = UNDEFINED;
|
|
554 |
this.unmatched_new_nodes = UNDEFINED;
|
|
555 | 555 |
|
556 | 556 |
// 'Textual' correspondence/matching is weaker than 'pure' |
557 | 557 |
// correspondence/matching. We need 'textual' level for visual presentation |
... | ... | |
559 | 559 |
// Sometimes only function body is changed (functions in old and new script |
560 | 560 |
// textually correspond), but we cannot patch the code, so we see them |
561 | 561 |
// as an old function deleted and new function created. |
562 |
this.textual_corresponding_node = void 0;
|
|
563 |
this.textually_unmatched_new_nodes = void 0;
|
|
562 |
this.textual_corresponding_node = UNDEFINED;
|
|
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 | 568 |
// From array of function infos that is implicitly a tree creates |
... | ... | |
692 | 692 |
ProcessInternals(code_info_tree); |
693 | 693 |
} |
694 | 694 |
|
695 |
// For ecah old function (if it is not damaged) tries to find a corresponding
|
|
695 |
// For each old function (if it is not damaged) tries to find a corresponding
|
|
696 | 696 |
// function in new script. Typically it should succeed (non-damaged functions |
697 | 697 |
// by definition may only have changes inside their bodies). However there are |
698 |
// reasons for corresponence not to be found; function with unmodified text |
|
698 |
// reasons for correspondence not to be found; function with unmodified text
|
|
699 | 699 |
// in new script may become enclosed into other function; the innocent change |
700 | 700 |
// inside function body may in fact be something like "} function B() {" that |
701 | 701 |
// splits a function into 2 functions. |
... | ... | |
703 | 703 |
|
704 | 704 |
// A recursive function that tries to find a correspondence for all |
705 | 705 |
// child functions and for their inner functions. |
706 |
function ProcessChildren(old_node, new_node) { |
|
706 |
function ProcessNode(old_node, new_node) { |
|
707 |
var scope_change_description = |
|
708 |
IsFunctionContextLocalsChanged(old_node.info, new_node.info); |
|
709 |
if (scope_change_description) { |
|
710 |
old_node.status = FunctionStatus.CHANGED; |
|
711 |
} |
|
712 |
|
|
707 | 713 |
var old_children = old_node.children; |
708 | 714 |
var new_children = new_node.children; |
709 | 715 |
|
... | ... | |
729 | 735 |
new_children[new_index]; |
730 | 736 |
old_children[old_index].textual_corresponding_node = |
731 | 737 |
new_children[new_index]; |
732 |
if (old_children[old_index].status != FunctionStatus.UNCHANGED) { |
|
733 |
ProcessChildren(old_children[old_index], |
|
738 |
if (scope_change_description) { |
|
739 |
old_children[old_index].status = FunctionStatus.DAMAGED; |
|
740 |
old_children[old_index].status_explanation = |
|
741 |
"Enclosing function is now incompatible. " + |
|
742 |
scope_change_description; |
|
743 |
old_children[old_index].corresponding_node = UNDEFINED; |
|
744 |
} else if (old_children[old_index].status != |
|
745 |
FunctionStatus.UNCHANGED) { |
|
746 |
ProcessNode(old_children[old_index], |
|
734 | 747 |
new_children[new_index]); |
735 | 748 |
if (old_children[old_index].status == FunctionStatus.DAMAGED) { |
736 | 749 |
unmatched_new_nodes_list.push( |
737 | 750 |
old_children[old_index].corresponding_node); |
738 |
old_children[old_index].corresponding_node = void 0;
|
|
751 |
old_children[old_index].corresponding_node = UNDEFINED;
|
|
739 | 752 |
old_node.status = FunctionStatus.CHANGED; |
740 | 753 |
} |
741 | 754 |
} |
... | ... | |
772 | 785 |
} |
773 | 786 |
|
774 | 787 |
if (old_node.status == FunctionStatus.CHANGED) { |
775 |
var why_wrong_expectations = |
|
776 |
WhyFunctionExpectationsDiffer(old_node.info, new_node.info); |
|
777 |
if (why_wrong_expectations) { |
|
788 |
if (old_node.info.param_num != new_node.info.param_num) { |
|
778 | 789 |
old_node.status = FunctionStatus.DAMAGED; |
779 |
old_node.status_explanation = why_wrong_expectations; |
|
790 |
old_node.status_explanation = "Changed parameter number: " + |
|
791 |
old_node.info.param_num + " and " + new_node.info.param_num; |
|
780 | 792 |
} |
781 | 793 |
} |
782 | 794 |
old_node.unmatched_new_nodes = unmatched_new_nodes_list; |
... | ... | |
784 | 796 |
textually_unmatched_new_nodes_list; |
785 | 797 |
} |
786 | 798 |
|
787 |
ProcessChildren(old_code_tree, new_code_tree);
|
|
799 |
ProcessNode(old_code_tree, new_code_tree);
|
|
788 | 800 |
|
789 | 801 |
old_code_tree.corresponding_node = new_code_tree; |
790 | 802 |
old_code_tree.textual_corresponding_node = new_code_tree; |
... | ... | |
856 | 868 |
this.raw_array = raw_array; |
857 | 869 |
} |
858 | 870 |
|
859 |
// Changes positions (including all statments) in function. |
|
871 |
// Changes positions (including all statements) in function.
|
|
860 | 872 |
function PatchPositions(old_info_node, diff_array, report_array) { |
861 | 873 |
if (old_info_node.live_shared_function_infos) { |
862 | 874 |
old_info_node.live_shared_function_infos.forEach(function (info) { |
... | ... | |
878 | 890 |
return script.name + " (old)"; |
879 | 891 |
} |
880 | 892 |
|
881 |
// Compares a function interface old and new version, whether it
|
|
893 |
// Compares a function scope heap structure, old and new version, whether it
|
|
882 | 894 |
// changed or not. Returns explanation if they differ. |
883 |
function WhyFunctionExpectationsDiffer(function_info1, function_info2) { |
|
884 |
// Check that function has the same number of parameters (there may exist |
|
885 |
// an adapter, that won't survive function parameter number change). |
|
886 |
if (function_info1.param_num != function_info2.param_num) { |
|
887 |
return "Changed parameter number: " + function_info1.param_num + |
|
888 |
" and " + function_info2.param_num; |
|
889 |
} |
|
895 |
function IsFunctionContextLocalsChanged(function_info1, function_info2) { |
|
890 | 896 |
var scope_info1 = function_info1.scope_info; |
891 | 897 |
var scope_info2 = function_info2.scope_info; |
892 | 898 |
|
... | ... | |
905 | 911 |
} |
906 | 912 |
|
907 | 913 |
if (scope_info1_text != scope_info2_text) { |
908 |
return "Incompatible variable maps: [" + scope_info1_text +
|
|
909 |
"] and [" + scope_info2_text + "]";
|
|
914 |
return "Variable map changed: [" + scope_info1_text +
|
|
915 |
"] => [" + scope_info2_text + "]";
|
|
910 | 916 |
} |
911 | 917 |
// No differences. Return undefined. |
912 | 918 |
return; |
Also available in: Unified diff