| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 MarkChangedFunctions(root_old_node, pos_translator.GetChunks()); | 69 MarkChangedFunctions(root_old_node, pos_translator.GetChunks()); |
| 70 | 70 |
| 71 // Find all SharedFunctionInfo's that were compiled from this script. | 71 // Find all SharedFunctionInfo's that were compiled from this script. |
| 72 FindLiveSharedInfos(root_old_node, script); | 72 FindLiveSharedInfos(root_old_node, script); |
| 73 | 73 |
| 74 // Gather compile information about new version of script. | 74 // Gather compile information about new version of script. |
| 75 var new_compile_info; | 75 var new_compile_info; |
| 76 try { | 76 try { |
| 77 new_compile_info = GatherCompileInfo(new_source, script); | 77 new_compile_info = GatherCompileInfo(new_source, script); |
| 78 } catch (e) { | 78 } catch (e) { |
| 79 throw new Failure("Failed to compile new version of script: " + e); | 79 var failure = |
| 80 new Failure("Failed to compile new version of script: " + e); |
| 81 if (e instanceof SyntaxError) { |
| 82 var details = { |
| 83 type: "liveedit_compile_error", |
| 84 syntaxErrorMessage: e.message |
| 85 }; |
| 86 CopyErrorPositionToDetails(e, details); |
| 87 failure.details = details; |
| 88 } |
| 89 throw failure; |
| 80 } | 90 } |
| 81 var root_new_node = BuildCodeInfoTree(new_compile_info); | 91 var root_new_node = BuildCodeInfoTree(new_compile_info); |
| 82 | 92 |
| 83 // Link recompiled script data with other data. | 93 // Link recompiled script data with other data. |
| 84 FindCorrespondingFunctions(root_old_node, root_new_node); | 94 FindCorrespondingFunctions(root_old_node, root_new_node); |
| 85 | 95 |
| 86 // Prepare to-do lists. | 96 // Prepare to-do lists. |
| 87 var replace_code_list = new Array(); | 97 var replace_code_list = new Array(); |
| 88 var link_to_old_script_list = new Array(); | 98 var link_to_old_script_list = new Array(); |
| 89 var link_to_original_script_list = new Array(); | 99 var link_to_original_script_list = new Array(); |
| (...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 function Failure(message) { | 981 function Failure(message) { |
| 972 this.message = message; | 982 this.message = message; |
| 973 } | 983 } |
| 974 // Function (constructor) is public. | 984 // Function (constructor) is public. |
| 975 this.Failure = Failure; | 985 this.Failure = Failure; |
| 976 | 986 |
| 977 Failure.prototype.toString = function() { | 987 Failure.prototype.toString = function() { |
| 978 return "LiveEdit Failure: " + this.message; | 988 return "LiveEdit Failure: " + this.message; |
| 979 }; | 989 }; |
| 980 | 990 |
| 991 function CopyErrorPositionToDetails(e, details) { |
| 992 function createPositionStruct(script, position) { |
| 993 if (position == -1) return; |
| 994 var location = script.locationFromPosition(position, true); |
| 995 if (location == null) return; |
| 996 return { |
| 997 line: location.line + 1, |
| 998 column: location.column + 1, |
| 999 position: position |
| 1000 }; |
| 1001 } |
| 1002 |
| 1003 if (!("scriptObject" in e) || !("startPosition" in e)) { |
| 1004 return; |
| 1005 } |
| 1006 |
| 1007 var script = e.scriptObject; |
| 1008 |
| 1009 var position_struct = { |
| 1010 start: createPositionStruct(script, e.startPosition), |
| 1011 end: createPositionStruct(script, e.endPosition) |
| 1012 }; |
| 1013 details.position = position_struct; |
| 1014 } |
| 1015 |
| 981 // A testing entry. | 1016 // A testing entry. |
| 982 function GetPcFromSourcePos(func, source_pos) { | 1017 function GetPcFromSourcePos(func, source_pos) { |
| 983 return %GetFunctionCodePositionFromSource(func, source_pos); | 1018 return %GetFunctionCodePositionFromSource(func, source_pos); |
| 984 } | 1019 } |
| 985 // Function is public. | 1020 // Function is public. |
| 986 this.GetPcFromSourcePos = GetPcFromSourcePos; | 1021 this.GetPcFromSourcePos = GetPcFromSourcePos; |
| 987 | 1022 |
| 988 // LiveEdit main entry point: changes a script text to a new string. | 1023 // LiveEdit main entry point: changes a script text to a new string. |
| 989 function SetScriptSource(script, new_source, preview_only, change_log) { | 1024 function SetScriptSource(script, new_source, preview_only, change_log) { |
| 990 var old_source = script.source; | 1025 var old_source = script.source; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 // Function is public. | 1128 // Function is public. |
| 1094 this.RestartFrame = RestartFrame; | 1129 this.RestartFrame = RestartFrame; |
| 1095 | 1130 |
| 1096 // Functions are public for tests. | 1131 // Functions are public for tests. |
| 1097 this.TestApi = { | 1132 this.TestApi = { |
| 1098 PosTranslator: PosTranslator, | 1133 PosTranslator: PosTranslator, |
| 1099 CompareStrings: CompareStrings, | 1134 CompareStrings: CompareStrings, |
| 1100 ApplySingleChunkPatch: ApplySingleChunkPatch | 1135 ApplySingleChunkPatch: ApplySingleChunkPatch |
| 1101 }; | 1136 }; |
| 1102 }; | 1137 }; |
| OLD | NEW |