Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: src/liveedit-debugger.js

Issue 1559006: Remove trailing regexp from .js files. (Closed)
Patch Set: Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/debug-debugger.js ('k') | src/messages.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 14 matching lines...) Expand all
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 // LiveEdit feature implementation. The script should be executed after 28 // LiveEdit feature implementation. The script should be executed after
29 // debug-debugger.js. 29 // debug-debugger.js.
30 30
31 31
32 // Changes script text and recompiles all relevant functions if possible. 32 // Changes script text and recompiles all relevant functions if possible.
33 // The change is always a substring (change_pos, change_pos + change_len) 33 // The change is always a substring (change_pos, change_pos + change_len)
34 // being replaced with a completely different string new_str. 34 // being replaced with a completely different string new_str.
35 // 35 //
36 // Only one function will have its Code changed in result of this function. 36 // Only one function will have its Code changed in result of this function.
37 // All nested functions (should they have any instances at the moment) are left 37 // All nested functions (should they have any instances at the moment) are left
38 // unchanged and re-linked to a newly created script instance representing old 38 // unchanged and re-linked to a newly created script instance representing old
39 // version of the source. (Generally speaking, 39 // version of the source. (Generally speaking,
40 // during the change all nested functions are erased and completely different 40 // during the change all nested functions are erased and completely different
41 // set of nested functions are introduced.) All other functions just have 41 // set of nested functions are introduced.) All other functions just have
42 // their positions updated. 42 // their positions updated.
43 // 43 //
44 // @param {Script} script that is being changed 44 // @param {Script} script that is being changed
45 // @param {Array} change_log a list that collects engineer-readable description 45 // @param {Array} change_log a list that collects engineer-readable description
46 // of what happened. 46 // of what happened.
47 Debug.LiveEditChangeScript = function(script, change_pos, change_len, new_str, 47 Debug.LiveEditChangeScript = function(script, change_pos, change_len, new_str,
48 change_log) { 48 change_log) {
49 49
50 // So far the function works as namespace. 50 // So far the function works as namespace.
51 var liveedit = Debug.LiveEditChangeScript; 51 var liveedit = Debug.LiveEditChangeScript;
52 var Assert = liveedit.Assert; 52 var Assert = liveedit.Assert;
53 53
54 // Fully compiles source string as a script. Returns Array of 54 // Fully compiles source string as a script. Returns Array of
55 // FunctionCompileInfo -- a descriptions of all functions of the script. 55 // FunctionCompileInfo -- a descriptions of all functions of the script.
56 // Elements of array are ordered by start positions of functions (from top 56 // Elements of array are ordered by start positions of functions (from top
57 // to bottom) in the source. Fields outer_index and next_sibling_index help 57 // to bottom) in the source. Fields outer_index and next_sibling_index help
58 // to navigate the nesting structure of functions. 58 // to navigate the nesting structure of functions.
59 // 59 //
60 // The script is used for compilation, because it produces code that 60 // The script is used for compilation, because it produces code that
61 // needs to be linked with some particular script (for nested functions). 61 // needs to be linked with some particular script (for nested functions).
62 function DebugGatherCompileInfo(source) { 62 function DebugGatherCompileInfo(source) {
63 // Get function info, elements are partially sorted (it is a tree 63 // Get function info, elements are partially sorted (it is a tree
64 // of nested functions serialized as parent followed by serialized children. 64 // of nested functions serialized as parent followed by serialized children.
65 var raw_compile_info = %LiveEditGatherCompileInfo(script, source); 65 var raw_compile_info = %LiveEditGatherCompileInfo(script, source);
66 66
67 // Sort function infos by start position field. 67 // Sort function infos by start position field.
68 var compile_info = new Array(); 68 var compile_info = new Array();
69 var old_index_map = new Array(); 69 var old_index_map = new Array();
70 for (var i = 0; i < raw_compile_info.length; i++) { 70 for (var i = 0; i < raw_compile_info.length; i++) {
71 compile_info.push(new liveedit.FunctionCompileInfo(raw_compile_info[i])) ; 71 compile_info.push(new liveedit.FunctionCompileInfo(raw_compile_info[i])) ;
72 old_index_map.push(i); 72 old_index_map.push(i);
73 } 73 }
74 74
75 for (var i = 0; i < compile_info.length; i++) { 75 for (var i = 0; i < compile_info.length; i++) {
76 var k = i; 76 var k = i;
77 for (var j = i + 1; j < compile_info.length; j++) { 77 for (var j = i + 1; j < compile_info.length; j++) {
78 if (compile_info[k].start_position > compile_info[j].start_position) { 78 if (compile_info[k].start_position > compile_info[j].start_position) {
79 k = j; 79 k = j;
80 } 80 }
81 } 81 }
82 if (k != i) { 82 if (k != i) {
83 var temp_info = compile_info[k]; 83 var temp_info = compile_info[k];
84 var temp_index = old_index_map[k]; 84 var temp_index = old_index_map[k];
(...skipping 20 matching lines...) Expand all
105 compile_info[previous_sibling].next_sibling_index = saved_index; 105 compile_info[previous_sibling].next_sibling_index = saved_index;
106 } 106 }
107 previous_sibling = saved_index; 107 previous_sibling = saved_index;
108 current_index++; 108 current_index++;
109 ResetIndexes(saved_index, old_index_map[saved_index]); 109 ResetIndexes(saved_index, old_index_map[saved_index]);
110 } 110 }
111 if (previous_sibling != -1) { 111 if (previous_sibling != -1) {
112 compile_info[previous_sibling].next_sibling_index = -1; 112 compile_info[previous_sibling].next_sibling_index = -1;
113 } 113 }
114 } 114 }
115 115
116 ResetIndexes(-1, -1); 116 ResetIndexes(-1, -1);
117 Assert(current_index == compile_info.length); 117 Assert(current_index == compile_info.length);
118 118
119 return compile_info; 119 return compile_info;
120 } 120 }
121 121
122 // Given a positions, finds a function that fully includes the entire change. 122 // Given a positions, finds a function that fully includes the entire change.
123 function FindChangedFunction(compile_info, offset, len) { 123 function FindChangedFunction(compile_info, offset, len) {
124 // First condition: function should start before the change region. 124 // First condition: function should start before the change region.
125 // Function #0 (whole-script function) always does, but we want 125 // Function #0 (whole-script function) always does, but we want
126 // one, that is later in this list. 126 // one, that is later in this list.
127 var index = 0; 127 var index = 0;
128 while (index + 1 < compile_info.length && 128 while (index + 1 < compile_info.length &&
129 compile_info[index + 1].start_position <= offset) { 129 compile_info[index + 1].start_position <= offset) {
130 index++; 130 index++;
(...skipping 10 matching lines...) Expand all
141 141
142 // Variable forward declarations. Preprocessor "Minifier" needs them. 142 // Variable forward declarations. Preprocessor "Minifier" needs them.
143 var old_compile_info; 143 var old_compile_info;
144 var shared_infos; 144 var shared_infos;
145 // Finds SharedFunctionInfo that corresponds compile info with index 145 // Finds SharedFunctionInfo that corresponds compile info with index
146 // in old version of the script. 146 // in old version of the script.
147 function FindFunctionInfo(index) { 147 function FindFunctionInfo(index) {
148 var old_info = old_compile_info[index]; 148 var old_info = old_compile_info[index];
149 for (var i = 0; i < shared_infos.length; i++) { 149 for (var i = 0; i < shared_infos.length; i++) {
150 var info = shared_infos[i]; 150 var info = shared_infos[i];
151 if (info.start_position == old_info.start_position && 151 if (info.start_position == old_info.start_position &&
152 info.end_position == old_info.end_position) { 152 info.end_position == old_info.end_position) {
153 return info; 153 return info;
154 } 154 }
155 } 155 }
156 } 156 }
157 157
158 // Replaces function's Code. 158 // Replaces function's Code.
159 function PatchCode(new_info, shared_info) { 159 function PatchCode(new_info, shared_info) {
160 %LiveEditReplaceFunctionCode(new_info.raw_array, shared_info.raw_array); 160 %LiveEditReplaceFunctionCode(new_info.raw_array, shared_info.raw_array);
161 161
162 change_log.push( {function_patched: new_info.function_name} ); 162 change_log.push( {function_patched: new_info.function_name} );
163 } 163 }
164 164
165 var change_len_old; 165 var change_len_old;
166 var change_len_new; 166 var change_len_new;
167 // Translate position in old version of script into position in new 167 // Translate position in old version of script into position in new
168 // version of script. 168 // version of script.
169 function PosTranslator(old_pos) { 169 function PosTranslator(old_pos) {
170 if (old_pos <= change_pos) { 170 if (old_pos <= change_pos) {
171 return old_pos; 171 return old_pos;
172 } 172 }
173 if (old_pos >= change_pos + change_len_old) { 173 if (old_pos >= change_pos + change_len_old) {
174 return old_pos + change_len_new - change_len_old; 174 return old_pos + change_len_new - change_len_old;
175 } 175 }
176 return -1; 176 return -1;
177 } 177 }
178 178
179 var position_change_array; 179 var position_change_array;
180 var position_patch_report; 180 var position_patch_report;
181 function PatchPositions(new_info, shared_info) { 181 function PatchPositions(new_info, shared_info) {
182 if (!shared_info) { 182 if (!shared_info) {
183 // TODO: explain what is happening. 183 // TODO: explain what is happening.
184 return; 184 return;
185 } 185 }
186 %LiveEditPatchFunctionPositions(shared_info.raw_array, 186 %LiveEditPatchFunctionPositions(shared_info.raw_array,
187 position_change_array); 187 position_change_array);
188 position_patch_report.push( { name: new_info.function_name } ); 188 position_patch_report.push( { name: new_info.function_name } );
189 } 189 }
190 190
191 var link_to_old_script_report; 191 var link_to_old_script_report;
192 var old_script; 192 var old_script;
193 // Makes a function associated with another instance of a script (the 193 // Makes a function associated with another instance of a script (the
194 // one representing its old version). This way the function still 194 // one representing its old version). This way the function still
195 // may access its own text. 195 // may access its own text.
196 function LinkToOldScript(shared_info) { 196 function LinkToOldScript(shared_info) {
197 %LiveEditRelinkFunctionToScript(shared_info.raw_array, old_script); 197 %LiveEditRelinkFunctionToScript(shared_info.raw_array, old_script);
198 198
199 link_to_old_script_report.push( { name: shared_info.function_name } ); 199 link_to_old_script_report.push( { name: shared_info.function_name } );
200 } 200 }
201 201
202 202
203 203
204 var old_source = script.source; 204 var old_source = script.source;
205 var change_len_old = change_len; 205 var change_len_old = change_len;
206 var change_len_new = new_str.length; 206 var change_len_new = new_str.length;
207 207
208 // Prepare new source string. 208 // Prepare new source string.
209 var new_source = old_source.substring(0, change_pos) + 209 var new_source = old_source.substring(0, change_pos) +
210 new_str + old_source.substring(change_pos + change_len); 210 new_str + old_source.substring(change_pos + change_len);
211 211
212 // Find all SharedFunctionInfo's that are compiled from this script. 212 // Find all SharedFunctionInfo's that are compiled from this script.
213 var shared_raw_list = %LiveEditFindSharedFunctionInfosForScript(script); 213 var shared_raw_list = %LiveEditFindSharedFunctionInfosForScript(script);
214 214
215 var shared_infos = new Array(); 215 var shared_infos = new Array();
216 216
217 for (var i = 0; i < shared_raw_list.length; i++) { 217 for (var i = 0; i < shared_raw_list.length; i++) {
218 shared_infos.push(new liveedit.SharedInfoWrapper(shared_raw_list[i])); 218 shared_infos.push(new liveedit.SharedInfoWrapper(shared_raw_list[i]));
219 } 219 }
220 220
221 // Gather compile information about old version of script. 221 // Gather compile information about old version of script.
222 var old_compile_info = DebugGatherCompileInfo(old_source); 222 var old_compile_info = DebugGatherCompileInfo(old_source);
223 223
224 // Gather compile information about new version of script. 224 // Gather compile information about new version of script.
225 var new_compile_info; 225 var new_compile_info;
226 try { 226 try {
227 new_compile_info = DebugGatherCompileInfo(new_source); 227 new_compile_info = DebugGatherCompileInfo(new_source);
228 } catch (e) { 228 } catch (e) {
229 throw new liveedit.Failure("Failed to compile new version of script: " + e); 229 throw new liveedit.Failure("Failed to compile new version of script: " + e);
230 } 230 }
231 231
232 // An index of a single function, that is going to have its code replaced. 232 // An index of a single function, that is going to have its code replaced.
233 var function_being_patched = 233 var function_being_patched =
234 FindChangedFunction(old_compile_info, change_pos, change_len_old); 234 FindChangedFunction(old_compile_info, change_pos, change_len_old);
235 235
236 // In old and new script versions function with a change should have the 236 // In old and new script versions function with a change should have the
237 // same indexes. 237 // same indexes.
238 var function_being_patched2 = 238 var function_being_patched2 =
239 FindChangedFunction(new_compile_info, change_pos, change_len_new); 239 FindChangedFunction(new_compile_info, change_pos, change_len_new);
240 Assert(function_being_patched == function_being_patched2, 240 Assert(function_being_patched == function_being_patched2,
241 "inconsistent old/new compile info"); 241 "inconsistent old/new compile info");
242 242
243 // Check that function being patched has the same expectations in a new 243 // Check that function being patched has the same expectations in a new
244 // version. Otherwise we cannot safely patch its behavior and should 244 // version. Otherwise we cannot safely patch its behavior and should
245 // choose the outer function instead. 245 // choose the outer function instead.
246 while (!liveedit.CompareFunctionExpectations( 246 while (!liveedit.CompareFunctionExpectations(
247 old_compile_info[function_being_patched], 247 old_compile_info[function_being_patched],
248 new_compile_info[function_being_patched])) { 248 new_compile_info[function_being_patched])) {
249 249
250 Assert(old_compile_info[function_being_patched].outer_index == 250 Assert(old_compile_info[function_being_patched].outer_index ==
251 new_compile_info[function_being_patched].outer_index); 251 new_compile_info[function_being_patched].outer_index);
252 function_being_patched = 252 function_being_patched =
253 old_compile_info[function_being_patched].outer_index; 253 old_compile_info[function_being_patched].outer_index;
254 Assert(function_being_patched != -1); 254 Assert(function_being_patched != -1);
255 } 255 }
256 256
257 // Check that function being patched is not currently on stack. 257 // Check that function being patched is not currently on stack.
258 liveedit.CheckStackActivations( 258 liveedit.CheckStackActivations(
259 [ FindFunctionInfo(function_being_patched) ], change_log ); 259 [ FindFunctionInfo(function_being_patched) ], change_log );
260 260
261 261
262 // Committing all changes. 262 // Committing all changes.
263 var old_script_name = liveedit.CreateNameForOldScript(script); 263 var old_script_name = liveedit.CreateNameForOldScript(script);
264 264
265 // Update the script text and create a new script representing an old 265 // Update the script text and create a new script representing an old
266 // version of the script. 266 // version of the script.
267 var old_script = %LiveEditReplaceScript(script, new_source, old_script_name); 267 var old_script = %LiveEditReplaceScript(script, new_source, old_script_name);
268 268
269 PatchCode(new_compile_info[function_being_patched], 269 PatchCode(new_compile_info[function_being_patched],
270 FindFunctionInfo(function_being_patched)); 270 FindFunctionInfo(function_being_patched));
271 271
272 var position_patch_report = new Array(); 272 var position_patch_report = new Array();
273 change_log.push( {position_patched: position_patch_report} ); 273 change_log.push( {position_patched: position_patch_report} );
274 274
275 var position_change_array = [ change_pos, 275 var position_change_array = [ change_pos,
276 change_pos + change_len_old, 276 change_pos + change_len_old,
277 change_pos + change_len_new ]; 277 change_pos + change_len_new ];
278 278
279 // Update positions of all outer functions (i.e. all functions, that 279 // Update positions of all outer functions (i.e. all functions, that
280 // are partially below the function being patched). 280 // are partially below the function being patched).
281 for (var i = new_compile_info[function_being_patched].outer_index; 281 for (var i = new_compile_info[function_being_patched].outer_index;
282 i != -1; 282 i != -1;
283 i = new_compile_info[i].outer_index) { 283 i = new_compile_info[i].outer_index) {
284 PatchPositions(new_compile_info[i], FindFunctionInfo(i)); 284 PatchPositions(new_compile_info[i], FindFunctionInfo(i));
285 } 285 }
286 286
287 // Update positions of all functions that are fully below the function 287 // Update positions of all functions that are fully below the function
288 // being patched. 288 // being patched.
(...skipping 12 matching lines...) Expand all
301 301
302 for (var i = old_next_sibling, j = new_next_sibling; 302 for (var i = old_next_sibling, j = new_next_sibling;
303 i < old_compile_info.length; i++, j++) { 303 i < old_compile_info.length; i++, j++) {
304 PatchPositions(new_compile_info[j], FindFunctionInfo(i)); 304 PatchPositions(new_compile_info[j], FindFunctionInfo(i));
305 } 305 }
306 } 306 }
307 307
308 var link_to_old_script_report = new Array(); 308 var link_to_old_script_report = new Array();
309 change_log.push( { linked_to_old_script: link_to_old_script_report } ); 309 change_log.push( { linked_to_old_script: link_to_old_script_report } );
310 310
311 // We need to link to old script all former nested functions. 311 // We need to link to old script all former nested functions.
312 for (var i = function_being_patched + 1; i < old_next_sibling; i++) { 312 for (var i = function_being_patched + 1; i < old_next_sibling; i++) {
313 LinkToOldScript(FindFunctionInfo(i), old_script); 313 LinkToOldScript(FindFunctionInfo(i), old_script);
314 } 314 }
315 } 315 }
316 316
317 Debug.LiveEditChangeScript.Assert = function(condition, message) { 317 Debug.LiveEditChangeScript.Assert = function(condition, message) {
318 if (!condition) { 318 if (!condition) {
319 if (message) { 319 if (message) {
320 throw "Assert " + message; 320 throw "Assert " + message;
321 } else { 321 } else {
322 throw "Assert"; 322 throw "Assert";
323 } 323 }
324 } 324 }
325 } 325 }
326 326
327 // An object describing function compilation details. Its index fields 327 // An object describing function compilation details. Its index fields
328 // apply to indexes inside array that stores these objects. 328 // apply to indexes inside array that stores these objects.
329 Debug.LiveEditChangeScript.FunctionCompileInfo = function(raw_array) { 329 Debug.LiveEditChangeScript.FunctionCompileInfo = function(raw_array) {
330 this.function_name = raw_array[0]; 330 this.function_name = raw_array[0];
331 this.start_position = raw_array[1]; 331 this.start_position = raw_array[1];
332 this.end_position = raw_array[2]; 332 this.end_position = raw_array[2];
333 this.param_num = raw_array[3]; 333 this.param_num = raw_array[3];
334 this.code = raw_array[4]; 334 this.code = raw_array[4];
335 this.scope_info = raw_array[5]; 335 this.scope_info = raw_array[5];
336 this.outer_index = raw_array[6]; 336 this.outer_index = raw_array[6];
337 this.next_sibling_index = null; 337 this.next_sibling_index = null;
338 this.raw_array = raw_array; 338 this.raw_array = raw_array;
339 } 339 }
340 340
341 // A structure describing SharedFunctionInfo. 341 // A structure describing SharedFunctionInfo.
342 Debug.LiveEditChangeScript.SharedInfoWrapper = function(raw_array) { 342 Debug.LiveEditChangeScript.SharedInfoWrapper = function(raw_array) {
343 this.function_name = raw_array[0]; 343 this.function_name = raw_array[0];
344 this.start_position = raw_array[1]; 344 this.start_position = raw_array[1];
345 this.end_position = raw_array[2]; 345 this.end_position = raw_array[2];
346 this.info = raw_array[3]; 346 this.info = raw_array[3];
347 this.raw_array = raw_array; 347 this.raw_array = raw_array;
348 } 348 }
349 349
350 // Adds a suffix to script name to mark that it is old version. 350 // Adds a suffix to script name to mark that it is old version.
351 Debug.LiveEditChangeScript.CreateNameForOldScript = function(script) { 351 Debug.LiveEditChangeScript.CreateNameForOldScript = function(script) {
352 // TODO(635): try better than this; support several changes. 352 // TODO(635): try better than this; support several changes.
353 return script.name + " (old)"; 353 return script.name + " (old)";
354 } 354 }
355 355
356 // Compares a function interface old and new version, whether it 356 // Compares a function interface old and new version, whether it
357 // changed or not. 357 // changed or not.
358 Debug.LiveEditChangeScript.CompareFunctionExpectations = 358 Debug.LiveEditChangeScript.CompareFunctionExpectations =
359 function(function_info1, function_info2) { 359 function(function_info1, function_info2) {
360 // Check that function has the same number of parameters (there may exist 360 // Check that function has the same number of parameters (there may exist
361 // an adapter, that won't survive function parameter number change). 361 // an adapter, that won't survive function parameter number change).
362 if (function_info1.param_num != function_info2.param_num) { 362 if (function_info1.param_num != function_info2.param_num) {
363 return false; 363 return false;
364 } 364 }
365 var scope_info1 = function_info1.scope_info; 365 var scope_info1 = function_info1.scope_info;
366 var scope_info2 = function_info2.scope_info; 366 var scope_info2 = function_info2.scope_info;
367 367
368 if (!scope_info1) { 368 if (!scope_info1) {
369 return !scope_info2; 369 return !scope_info2;
370 } 370 }
371 371
372 if (scope_info1.length != scope_info2.length) { 372 if (scope_info1.length != scope_info2.length) {
373 return false; 373 return false;
374 } 374 }
375 375
376 // Check that outer scope structure is not changed. Otherwise the function 376 // Check that outer scope structure is not changed. Otherwise the function
377 // will not properly work with existing scopes. 377 // will not properly work with existing scopes.
378 return scope_info1.toString() == scope_info2.toString(); 378 return scope_info1.toString() == scope_info2.toString();
379 } 379 }
380 380
381 // For array of wrapped shared function infos checks that none of them 381 // For array of wrapped shared function infos checks that none of them
382 // have activations on stack (of any thread). Throws a Failure exception 382 // have activations on stack (of any thread). Throws a Failure exception
383 // if this proves to be false. 383 // if this proves to be false.
384 Debug.LiveEditChangeScript.CheckStackActivations = function(shared_wrapper_list, 384 Debug.LiveEditChangeScript.CheckStackActivations = function(shared_wrapper_list,
385 change_log) { 385 change_log) {
386 var liveedit = Debug.LiveEditChangeScript; 386 var liveedit = Debug.LiveEditChangeScript;
387 387
388 var shared_list = new Array(); 388 var shared_list = new Array();
389 for (var i = 0; i < shared_wrapper_list.length; i++) { 389 for (var i = 0; i < shared_wrapper_list.length; i++) {
390 shared_list[i] = shared_wrapper_list[i].info; 390 shared_list[i] = shared_wrapper_list[i].info;
391 } 391 }
392 var result = %LiveEditCheckStackActivations(shared_list); 392 var result = %LiveEditCheckStackActivations(shared_list);
393 var problems = new Array(); 393 var problems = new Array();
394 for (var i = 0; i < shared_list.length; i++) { 394 for (var i = 0; i < shared_list.length; i++) {
395 if (result[i] == liveedit.FunctionPatchabilityStatus.FUNCTION_BLOCKED_ON_STA CK) { 395 if (result[i] == liveedit.FunctionPatchabilityStatus.FUNCTION_BLOCKED_ON_STA CK) {
396 var shared = shared_list[i]; 396 var shared = shared_list[i];
397 var description = { 397 var description = {
398 name: shared.function_name, 398 name: shared.function_name,
399 start_pos: shared.start_position, 399 start_pos: shared.start_position,
400 end_pos: shared.end_position 400 end_pos: shared.end_position
401 }; 401 };
402 problems.push(description); 402 problems.push(description);
403 } 403 }
404 } 404 }
405 if (problems.length > 0) { 405 if (problems.length > 0) {
406 change_log.push( { functions_on_stack: problems } ); 406 change_log.push( { functions_on_stack: problems } );
407 throw new liveedit.Failure("Blocked by functions on stack"); 407 throw new liveedit.Failure("Blocked by functions on stack");
408 } 408 }
409 } 409 }
410 410
411 // A copy of the FunctionPatchabilityStatus enum from liveedit.h 411 // A copy of the FunctionPatchabilityStatus enum from liveedit.h
412 Debug.LiveEditChangeScript.FunctionPatchabilityStatus = { 412 Debug.LiveEditChangeScript.FunctionPatchabilityStatus = {
413 FUNCTION_AVAILABLE_FOR_PATCH: 0, 413 FUNCTION_AVAILABLE_FOR_PATCH: 0,
414 FUNCTION_BLOCKED_ON_STACK: 1 414 FUNCTION_BLOCKED_ON_STACK: 1
415 } 415 }
416 416
417 417
418 // A logical failure in liveedit process. This means that change_log 418 // A logical failure in liveedit process. This means that change_log
419 // is valid and consistent description of what happened. 419 // is valid and consistent description of what happened.
420 Debug.LiveEditChangeScript.Failure = function(message) { 420 Debug.LiveEditChangeScript.Failure = function(message) {
421 this.message = message; 421 this.message = message;
422 } 422 }
423 423
424 Debug.LiveEditChangeScript.Failure.prototype.toString = function() { 424 Debug.LiveEditChangeScript.Failure.prototype.toString = function() {
425 return "LiveEdit Failure: " + this.message; 425 return "LiveEdit Failure: " + this.message;
426 } 426 }
427 427
428 // A testing entry. 428 // A testing entry.
429 Debug.LiveEditChangeScript.GetPcFromSourcePos = function(func, source_pos) { 429 Debug.LiveEditChangeScript.GetPcFromSourcePos = function(func, source_pos) {
430 return %GetFunctionCodePositionFromSource(func, source_pos); 430 return %GetFunctionCodePositionFromSource(func, source_pos);
431 } 431 }
OLDNEW
« no previous file with comments | « src/debug-debugger.js ('k') | src/messages.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698