OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 // - ScriptMirror | 218 // - ScriptMirror |
219 | 219 |
220 | 220 |
221 /** | 221 /** |
222 * Base class for all mirror objects. | 222 * Base class for all mirror objects. |
223 * @param {string} type The type of the mirror | 223 * @param {string} type The type of the mirror |
224 * @constructor | 224 * @constructor |
225 */ | 225 */ |
226 function Mirror(type) { | 226 function Mirror(type) { |
227 this.type_ = type; | 227 this.type_ = type; |
228 }; | 228 } |
229 | 229 |
230 | 230 |
231 Mirror.prototype.type = function() { | 231 Mirror.prototype.type = function() { |
232 return this.type_; | 232 return this.type_; |
233 }; | 233 }; |
234 | 234 |
235 | 235 |
236 /** | 236 /** |
237 * Check whether the mirror reflects a value. | 237 * Check whether the mirror reflects a value. |
238 * @returns {boolean} True if the mirror reflects a value. | 238 * @returns {boolean} True if the mirror reflects a value. |
239 */ | 239 */ |
240 Mirror.prototype.isValue = function() { | 240 Mirror.prototype.isValue = function() { |
241 return this instanceof ValueMirror; | 241 return this instanceof ValueMirror; |
242 } | 242 }; |
243 | 243 |
244 | 244 |
245 /** | 245 /** |
246 * Check whether the mirror reflects the undefined value. | 246 * Check whether the mirror reflects the undefined value. |
247 * @returns {boolean} True if the mirror reflects the undefined value. | 247 * @returns {boolean} True if the mirror reflects the undefined value. |
248 */ | 248 */ |
249 Mirror.prototype.isUndefined = function() { | 249 Mirror.prototype.isUndefined = function() { |
250 return this instanceof UndefinedMirror; | 250 return this instanceof UndefinedMirror; |
251 } | 251 }; |
252 | 252 |
253 | 253 |
254 /** | 254 /** |
255 * Check whether the mirror reflects the null value. | 255 * Check whether the mirror reflects the null value. |
256 * @returns {boolean} True if the mirror reflects the null value | 256 * @returns {boolean} True if the mirror reflects the null value |
257 */ | 257 */ |
258 Mirror.prototype.isNull = function() { | 258 Mirror.prototype.isNull = function() { |
259 return this instanceof NullMirror; | 259 return this instanceof NullMirror; |
260 } | 260 }; |
261 | 261 |
262 | 262 |
263 /** | 263 /** |
264 * Check whether the mirror reflects a boolean value. | 264 * Check whether the mirror reflects a boolean value. |
265 * @returns {boolean} True if the mirror reflects a boolean value | 265 * @returns {boolean} True if the mirror reflects a boolean value |
266 */ | 266 */ |
267 Mirror.prototype.isBoolean = function() { | 267 Mirror.prototype.isBoolean = function() { |
268 return this instanceof BooleanMirror; | 268 return this instanceof BooleanMirror; |
269 } | 269 }; |
270 | 270 |
271 | 271 |
272 /** | 272 /** |
273 * Check whether the mirror reflects a number value. | 273 * Check whether the mirror reflects a number value. |
274 * @returns {boolean} True if the mirror reflects a number value | 274 * @returns {boolean} True if the mirror reflects a number value |
275 */ | 275 */ |
276 Mirror.prototype.isNumber = function() { | 276 Mirror.prototype.isNumber = function() { |
277 return this instanceof NumberMirror; | 277 return this instanceof NumberMirror; |
278 } | 278 }; |
279 | 279 |
280 | 280 |
281 /** | 281 /** |
282 * Check whether the mirror reflects a string value. | 282 * Check whether the mirror reflects a string value. |
283 * @returns {boolean} True if the mirror reflects a string value | 283 * @returns {boolean} True if the mirror reflects a string value |
284 */ | 284 */ |
285 Mirror.prototype.isString = function() { | 285 Mirror.prototype.isString = function() { |
286 return this instanceof StringMirror; | 286 return this instanceof StringMirror; |
287 } | 287 }; |
288 | 288 |
289 | 289 |
290 /** | 290 /** |
291 * Check whether the mirror reflects an object. | 291 * Check whether the mirror reflects an object. |
292 * @returns {boolean} True if the mirror reflects an object | 292 * @returns {boolean} True if the mirror reflects an object |
293 */ | 293 */ |
294 Mirror.prototype.isObject = function() { | 294 Mirror.prototype.isObject = function() { |
295 return this instanceof ObjectMirror; | 295 return this instanceof ObjectMirror; |
296 } | 296 }; |
297 | 297 |
298 | 298 |
299 /** | 299 /** |
300 * Check whether the mirror reflects a function. | 300 * Check whether the mirror reflects a function. |
301 * @returns {boolean} True if the mirror reflects a function | 301 * @returns {boolean} True if the mirror reflects a function |
302 */ | 302 */ |
303 Mirror.prototype.isFunction = function() { | 303 Mirror.prototype.isFunction = function() { |
304 return this instanceof FunctionMirror; | 304 return this instanceof FunctionMirror; |
305 } | 305 }; |
306 | 306 |
307 | 307 |
308 /** | 308 /** |
309 * Check whether the mirror reflects an unresolved function. | 309 * Check whether the mirror reflects an unresolved function. |
310 * @returns {boolean} True if the mirror reflects an unresolved function | 310 * @returns {boolean} True if the mirror reflects an unresolved function |
311 */ | 311 */ |
312 Mirror.prototype.isUnresolvedFunction = function() { | 312 Mirror.prototype.isUnresolvedFunction = function() { |
313 return this instanceof UnresolvedFunctionMirror; | 313 return this instanceof UnresolvedFunctionMirror; |
314 } | 314 }; |
315 | 315 |
316 | 316 |
317 /** | 317 /** |
318 * Check whether the mirror reflects an array. | 318 * Check whether the mirror reflects an array. |
319 * @returns {boolean} True if the mirror reflects an array | 319 * @returns {boolean} True if the mirror reflects an array |
320 */ | 320 */ |
321 Mirror.prototype.isArray = function() { | 321 Mirror.prototype.isArray = function() { |
322 return this instanceof ArrayMirror; | 322 return this instanceof ArrayMirror; |
323 } | 323 }; |
324 | 324 |
325 | 325 |
326 /** | 326 /** |
327 * Check whether the mirror reflects a date. | 327 * Check whether the mirror reflects a date. |
328 * @returns {boolean} True if the mirror reflects a date | 328 * @returns {boolean} True if the mirror reflects a date |
329 */ | 329 */ |
330 Mirror.prototype.isDate = function() { | 330 Mirror.prototype.isDate = function() { |
331 return this instanceof DateMirror; | 331 return this instanceof DateMirror; |
332 } | 332 }; |
333 | 333 |
334 | 334 |
335 /** | 335 /** |
336 * Check whether the mirror reflects a regular expression. | 336 * Check whether the mirror reflects a regular expression. |
337 * @returns {boolean} True if the mirror reflects a regular expression | 337 * @returns {boolean} True if the mirror reflects a regular expression |
338 */ | 338 */ |
339 Mirror.prototype.isRegExp = function() { | 339 Mirror.prototype.isRegExp = function() { |
340 return this instanceof RegExpMirror; | 340 return this instanceof RegExpMirror; |
341 } | 341 }; |
342 | 342 |
343 | 343 |
344 /** | 344 /** |
345 * Check whether the mirror reflects an error. | 345 * Check whether the mirror reflects an error. |
346 * @returns {boolean} True if the mirror reflects an error | 346 * @returns {boolean} True if the mirror reflects an error |
347 */ | 347 */ |
348 Mirror.prototype.isError = function() { | 348 Mirror.prototype.isError = function() { |
349 return this instanceof ErrorMirror; | 349 return this instanceof ErrorMirror; |
350 } | 350 }; |
351 | 351 |
352 | 352 |
353 /** | 353 /** |
354 * Check whether the mirror reflects a property. | 354 * Check whether the mirror reflects a property. |
355 * @returns {boolean} True if the mirror reflects a property | 355 * @returns {boolean} True if the mirror reflects a property |
356 */ | 356 */ |
357 Mirror.prototype.isProperty = function() { | 357 Mirror.prototype.isProperty = function() { |
358 return this instanceof PropertyMirror; | 358 return this instanceof PropertyMirror; |
359 } | 359 }; |
360 | 360 |
361 | 361 |
362 /** | 362 /** |
363 * Check whether the mirror reflects a stack frame. | 363 * Check whether the mirror reflects a stack frame. |
364 * @returns {boolean} True if the mirror reflects a stack frame | 364 * @returns {boolean} True if the mirror reflects a stack frame |
365 */ | 365 */ |
366 Mirror.prototype.isFrame = function() { | 366 Mirror.prototype.isFrame = function() { |
367 return this instanceof FrameMirror; | 367 return this instanceof FrameMirror; |
368 } | 368 }; |
369 | 369 |
370 | 370 |
371 /** | 371 /** |
372 * Check whether the mirror reflects a script. | 372 * Check whether the mirror reflects a script. |
373 * @returns {boolean} True if the mirror reflects a script | 373 * @returns {boolean} True if the mirror reflects a script |
374 */ | 374 */ |
375 Mirror.prototype.isScript = function() { | 375 Mirror.prototype.isScript = function() { |
376 return this instanceof ScriptMirror; | 376 return this instanceof ScriptMirror; |
377 } | 377 }; |
378 | 378 |
379 | 379 |
380 /** | 380 /** |
381 * Check whether the mirror reflects a context. | 381 * Check whether the mirror reflects a context. |
382 * @returns {boolean} True if the mirror reflects a context | 382 * @returns {boolean} True if the mirror reflects a context |
383 */ | 383 */ |
384 Mirror.prototype.isContext = function() { | 384 Mirror.prototype.isContext = function() { |
385 return this instanceof ContextMirror; | 385 return this instanceof ContextMirror; |
386 } | 386 }; |
387 | 387 |
388 | 388 |
389 /** | 389 /** |
390 * Check whether the mirror reflects a scope. | 390 * Check whether the mirror reflects a scope. |
391 * @returns {boolean} True if the mirror reflects a scope | 391 * @returns {boolean} True if the mirror reflects a scope |
392 */ | 392 */ |
393 Mirror.prototype.isScope = function() { | 393 Mirror.prototype.isScope = function() { |
394 return this instanceof ScopeMirror; | 394 return this instanceof ScopeMirror; |
395 } | 395 }; |
396 | 396 |
397 | 397 |
398 /** | 398 /** |
399 * Allocate a handle id for this object. | 399 * Allocate a handle id for this object. |
400 */ | 400 */ |
401 Mirror.prototype.allocateHandle_ = function() { | 401 Mirror.prototype.allocateHandle_ = function() { |
402 this.handle_ = next_handle_++; | 402 this.handle_ = next_handle_++; |
403 } | 403 }; |
404 | 404 |
405 | 405 |
406 /** | 406 /** |
407 * Allocate a transient handle id for this object. Transient handles are | 407 * Allocate a transient handle id for this object. Transient handles are |
408 * negative. | 408 * negative. |
409 */ | 409 */ |
410 Mirror.prototype.allocateTransientHandle_ = function() { | 410 Mirror.prototype.allocateTransientHandle_ = function() { |
411 this.handle_ = next_transient_handle_--; | 411 this.handle_ = next_transient_handle_--; |
412 } | 412 }; |
413 | 413 |
414 | 414 |
415 Mirror.prototype.toText = function() { | 415 Mirror.prototype.toText = function() { |
416 // Simpel to text which is used when on specialization in subclass. | 416 // Simpel to text which is used when on specialization in subclass. |
417 return "#<" + this.constructor.name + ">"; | 417 return "#<" + this.constructor.name + ">"; |
418 } | 418 }; |
419 | 419 |
420 | 420 |
421 /** | 421 /** |
422 * Base class for all value mirror objects. | 422 * Base class for all value mirror objects. |
423 * @param {string} type The type of the mirror | 423 * @param {string} type The type of the mirror |
424 * @param {value} value The value reflected by this mirror | 424 * @param {value} value The value reflected by this mirror |
425 * @param {boolean} transient indicate whether this object is transient with a | 425 * @param {boolean} transient indicate whether this object is transient with a |
426 * transient handle | 426 * transient handle |
427 * @constructor | 427 * @constructor |
428 * @extends Mirror | 428 * @extends Mirror |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 * @extends ValueMirror | 473 * @extends ValueMirror |
474 */ | 474 */ |
475 function UndefinedMirror() { | 475 function UndefinedMirror() { |
476 %_CallFunction(this, UNDEFINED_TYPE, void 0, ValueMirror); | 476 %_CallFunction(this, UNDEFINED_TYPE, void 0, ValueMirror); |
477 } | 477 } |
478 inherits(UndefinedMirror, ValueMirror); | 478 inherits(UndefinedMirror, ValueMirror); |
479 | 479 |
480 | 480 |
481 UndefinedMirror.prototype.toText = function() { | 481 UndefinedMirror.prototype.toText = function() { |
482 return 'undefined'; | 482 return 'undefined'; |
483 } | 483 }; |
484 | 484 |
485 | 485 |
486 /** | 486 /** |
487 * Mirror object for null. | 487 * Mirror object for null. |
488 * @constructor | 488 * @constructor |
489 * @extends ValueMirror | 489 * @extends ValueMirror |
490 */ | 490 */ |
491 function NullMirror() { | 491 function NullMirror() { |
492 %_CallFunction(this, NULL_TYPE, null, ValueMirror); | 492 %_CallFunction(this, NULL_TYPE, null, ValueMirror); |
493 } | 493 } |
494 inherits(NullMirror, ValueMirror); | 494 inherits(NullMirror, ValueMirror); |
495 | 495 |
496 | 496 |
497 NullMirror.prototype.toText = function() { | 497 NullMirror.prototype.toText = function() { |
498 return 'null'; | 498 return 'null'; |
499 } | 499 }; |
500 | 500 |
501 | 501 |
502 /** | 502 /** |
503 * Mirror object for boolean values. | 503 * Mirror object for boolean values. |
504 * @param {boolean} value The boolean value reflected by this mirror | 504 * @param {boolean} value The boolean value reflected by this mirror |
505 * @constructor | 505 * @constructor |
506 * @extends ValueMirror | 506 * @extends ValueMirror |
507 */ | 507 */ |
508 function BooleanMirror(value) { | 508 function BooleanMirror(value) { |
509 %_CallFunction(this, BOOLEAN_TYPE, value, ValueMirror); | 509 %_CallFunction(this, BOOLEAN_TYPE, value, ValueMirror); |
510 } | 510 } |
511 inherits(BooleanMirror, ValueMirror); | 511 inherits(BooleanMirror, ValueMirror); |
512 | 512 |
513 | 513 |
514 BooleanMirror.prototype.toText = function() { | 514 BooleanMirror.prototype.toText = function() { |
515 return this.value_ ? 'true' : 'false'; | 515 return this.value_ ? 'true' : 'false'; |
516 } | 516 }; |
517 | 517 |
518 | 518 |
519 /** | 519 /** |
520 * Mirror object for number values. | 520 * Mirror object for number values. |
521 * @param {number} value The number value reflected by this mirror | 521 * @param {number} value The number value reflected by this mirror |
522 * @constructor | 522 * @constructor |
523 * @extends ValueMirror | 523 * @extends ValueMirror |
524 */ | 524 */ |
525 function NumberMirror(value) { | 525 function NumberMirror(value) { |
526 %_CallFunction(this, NUMBER_TYPE, value, ValueMirror); | 526 %_CallFunction(this, NUMBER_TYPE, value, ValueMirror); |
527 } | 527 } |
528 inherits(NumberMirror, ValueMirror); | 528 inherits(NumberMirror, ValueMirror); |
529 | 529 |
530 | 530 |
531 NumberMirror.prototype.toText = function() { | 531 NumberMirror.prototype.toText = function() { |
532 return %NumberToString(this.value_); | 532 return %NumberToString(this.value_); |
533 } | 533 }; |
534 | 534 |
535 | 535 |
536 /** | 536 /** |
537 * Mirror object for string values. | 537 * Mirror object for string values. |
538 * @param {string} value The string value reflected by this mirror | 538 * @param {string} value The string value reflected by this mirror |
539 * @constructor | 539 * @constructor |
540 * @extends ValueMirror | 540 * @extends ValueMirror |
541 */ | 541 */ |
542 function StringMirror(value) { | 542 function StringMirror(value) { |
543 %_CallFunction(this, STRING_TYPE, value, ValueMirror); | 543 %_CallFunction(this, STRING_TYPE, value, ValueMirror); |
544 } | 544 } |
545 inherits(StringMirror, ValueMirror); | 545 inherits(StringMirror, ValueMirror); |
546 | 546 |
547 | 547 |
548 StringMirror.prototype.length = function() { | 548 StringMirror.prototype.length = function() { |
549 return this.value_.length; | 549 return this.value_.length; |
550 }; | 550 }; |
551 | 551 |
552 StringMirror.prototype.getTruncatedValue = function(maxLength) { | 552 StringMirror.prototype.getTruncatedValue = function(maxLength) { |
553 if (maxLength != -1 && this.length() > maxLength) { | 553 if (maxLength != -1 && this.length() > maxLength) { |
554 return this.value_.substring(0, maxLength) + | 554 return this.value_.substring(0, maxLength) + |
555 '... (length: ' + this.length() + ')'; | 555 '... (length: ' + this.length() + ')'; |
556 } | 556 } |
557 return this.value_; | 557 return this.value_; |
558 } | 558 }; |
559 | 559 |
560 StringMirror.prototype.toText = function() { | 560 StringMirror.prototype.toText = function() { |
561 return this.getTruncatedValue(kMaxProtocolStringLength); | 561 return this.getTruncatedValue(kMaxProtocolStringLength); |
562 } | 562 }; |
563 | 563 |
564 | 564 |
565 /** | 565 /** |
566 * Mirror object for objects. | 566 * Mirror object for objects. |
567 * @param {object} value The object reflected by this mirror | 567 * @param {object} value The object reflected by this mirror |
568 * @param {boolean} transient indicate whether this object is transient with a | 568 * @param {boolean} transient indicate whether this object is transient with a |
569 * transient handle | 569 * transient handle |
570 * @constructor | 570 * @constructor |
571 * @extends ValueMirror | 571 * @extends ValueMirror |
572 */ | 572 */ |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 | 891 |
892 return result; | 892 return result; |
893 } else { | 893 } else { |
894 return []; | 894 return []; |
895 } | 895 } |
896 }; | 896 }; |
897 | 897 |
898 | 898 |
899 FunctionMirror.prototype.toText = function() { | 899 FunctionMirror.prototype.toText = function() { |
900 return this.source(); | 900 return this.source(); |
901 } | 901 }; |
902 | 902 |
903 | 903 |
904 /** | 904 /** |
905 * Mirror object for unresolved functions. | 905 * Mirror object for unresolved functions. |
906 * @param {string} value The name for the unresolved function reflected by this | 906 * @param {string} value The name for the unresolved function reflected by this |
907 * mirror. | 907 * mirror. |
908 * @constructor | 908 * @constructor |
909 * @extends ObjectMirror | 909 * @extends ObjectMirror |
910 */ | 910 */ |
911 function UnresolvedFunctionMirror(value) { | 911 function UnresolvedFunctionMirror(value) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 }; | 944 }; |
945 | 945 |
946 | 946 |
947 UnresolvedFunctionMirror.prototype.inferredName = function() { | 947 UnresolvedFunctionMirror.prototype.inferredName = function() { |
948 return undefined; | 948 return undefined; |
949 }; | 949 }; |
950 | 950 |
951 | 951 |
952 UnresolvedFunctionMirror.prototype.propertyNames = function(kind, limit) { | 952 UnresolvedFunctionMirror.prototype.propertyNames = function(kind, limit) { |
953 return []; | 953 return []; |
954 } | 954 }; |
955 | 955 |
956 | 956 |
957 /** | 957 /** |
958 * Mirror object for arrays. | 958 * Mirror object for arrays. |
959 * @param {Array} value The Array object reflected by this mirror | 959 * @param {Array} value The Array object reflected by this mirror |
960 * @constructor | 960 * @constructor |
961 * @extends ObjectMirror | 961 * @extends ObjectMirror |
962 */ | 962 */ |
963 function ArrayMirror(value) { | 963 function ArrayMirror(value) { |
964 %_CallFunction(this, value, ObjectMirror); | 964 %_CallFunction(this, value, ObjectMirror); |
965 } | 965 } |
966 inherits(ArrayMirror, ObjectMirror); | 966 inherits(ArrayMirror, ObjectMirror); |
967 | 967 |
968 | 968 |
969 ArrayMirror.prototype.length = function() { | 969 ArrayMirror.prototype.length = function() { |
970 return this.value_.length; | 970 return this.value_.length; |
971 }; | 971 }; |
972 | 972 |
973 | 973 |
974 ArrayMirror.prototype.indexedPropertiesFromRange = function(opt_from_index, opt_
to_index) { | 974 ArrayMirror.prototype.indexedPropertiesFromRange = function(opt_from_index, |
| 975 opt_to_index) { |
975 var from_index = opt_from_index || 0; | 976 var from_index = opt_from_index || 0; |
976 var to_index = opt_to_index || this.length() - 1; | 977 var to_index = opt_to_index || this.length() - 1; |
977 if (from_index > to_index) return new Array(); | 978 if (from_index > to_index) return new Array(); |
978 var values = new Array(to_index - from_index + 1); | 979 var values = new Array(to_index - from_index + 1); |
979 for (var i = from_index; i <= to_index; i++) { | 980 for (var i = from_index; i <= to_index; i++) { |
980 var details = %DebugGetPropertyDetails(this.value_, %ToString(i)); | 981 var details = %DebugGetPropertyDetails(this.value_, %ToString(i)); |
981 var value; | 982 var value; |
982 if (details) { | 983 if (details) { |
983 value = new PropertyMirror(this, i, details); | 984 value = new PropertyMirror(this, i, details); |
984 } else { | 985 } else { |
985 value = GetUndefinedMirror(); | 986 value = GetUndefinedMirror(); |
986 } | 987 } |
987 values[i - from_index] = value; | 988 values[i - from_index] = value; |
988 } | 989 } |
989 return values; | 990 return values; |
990 } | 991 }; |
991 | 992 |
992 | 993 |
993 /** | 994 /** |
994 * Mirror object for dates. | 995 * Mirror object for dates. |
995 * @param {Date} value The Date object reflected by this mirror | 996 * @param {Date} value The Date object reflected by this mirror |
996 * @constructor | 997 * @constructor |
997 * @extends ObjectMirror | 998 * @extends ObjectMirror |
998 */ | 999 */ |
999 function DateMirror(value) { | 1000 function DateMirror(value) { |
1000 %_CallFunction(this, value, ObjectMirror); | 1001 %_CallFunction(this, value, ObjectMirror); |
1001 } | 1002 } |
1002 inherits(DateMirror, ObjectMirror); | 1003 inherits(DateMirror, ObjectMirror); |
1003 | 1004 |
1004 | 1005 |
1005 DateMirror.prototype.toText = function() { | 1006 DateMirror.prototype.toText = function() { |
1006 var s = JSON.stringify(this.value_); | 1007 var s = JSON.stringify(this.value_); |
1007 return s.substring(1, s.length - 1); // cut quotes | 1008 return s.substring(1, s.length - 1); // cut quotes |
1008 } | 1009 }; |
1009 | 1010 |
1010 | 1011 |
1011 /** | 1012 /** |
1012 * Mirror object for regular expressions. | 1013 * Mirror object for regular expressions. |
1013 * @param {RegExp} value The RegExp object reflected by this mirror | 1014 * @param {RegExp} value The RegExp object reflected by this mirror |
1014 * @constructor | 1015 * @constructor |
1015 * @extends ObjectMirror | 1016 * @extends ObjectMirror |
1016 */ | 1017 */ |
1017 function RegExpMirror(value) { | 1018 function RegExpMirror(value) { |
1018 %_CallFunction(this, value, REGEXP_TYPE, ObjectMirror); | 1019 %_CallFunction(this, value, REGEXP_TYPE, ObjectMirror); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 * @return {boolean} Value of the multiline flag | 1053 * @return {boolean} Value of the multiline flag |
1053 */ | 1054 */ |
1054 RegExpMirror.prototype.multiline = function() { | 1055 RegExpMirror.prototype.multiline = function() { |
1055 return this.value_.multiline; | 1056 return this.value_.multiline; |
1056 }; | 1057 }; |
1057 | 1058 |
1058 | 1059 |
1059 RegExpMirror.prototype.toText = function() { | 1060 RegExpMirror.prototype.toText = function() { |
1060 // Simpel to text which is used when on specialization in subclass. | 1061 // Simpel to text which is used when on specialization in subclass. |
1061 return "/" + this.source() + "/"; | 1062 return "/" + this.source() + "/"; |
1062 } | 1063 }; |
1063 | 1064 |
1064 | 1065 |
1065 /** | 1066 /** |
1066 * Mirror object for error objects. | 1067 * Mirror object for error objects. |
1067 * @param {Error} value The error object reflected by this mirror | 1068 * @param {Error} value The error object reflected by this mirror |
1068 * @constructor | 1069 * @constructor |
1069 * @extends ObjectMirror | 1070 * @extends ObjectMirror |
1070 */ | 1071 */ |
1071 function ErrorMirror(value) { | 1072 function ErrorMirror(value) { |
1072 %_CallFunction(this, value, ERROR_TYPE, ObjectMirror); | 1073 %_CallFunction(this, value, ERROR_TYPE, ObjectMirror); |
(...skipping 12 matching lines...) Expand all Loading... |
1085 | 1086 |
1086 ErrorMirror.prototype.toText = function() { | 1087 ErrorMirror.prototype.toText = function() { |
1087 // Use the same text representation as in messages.js. | 1088 // Use the same text representation as in messages.js. |
1088 var text; | 1089 var text; |
1089 try { | 1090 try { |
1090 str = %_CallFunction(this.value_, builtins.ErrorToString); | 1091 str = %_CallFunction(this.value_, builtins.ErrorToString); |
1091 } catch (e) { | 1092 } catch (e) { |
1092 str = '#<Error>'; | 1093 str = '#<Error>'; |
1093 } | 1094 } |
1094 return str; | 1095 return str; |
1095 } | 1096 }; |
1096 | 1097 |
1097 | 1098 |
1098 /** | 1099 /** |
1099 * Base mirror object for properties. | 1100 * Base mirror object for properties. |
1100 * @param {ObjectMirror} mirror The mirror object having this property | 1101 * @param {ObjectMirror} mirror The mirror object having this property |
1101 * @param {string} name The name of the property | 1102 * @param {string} name The name of the property |
1102 * @param {Array} details Details about the property | 1103 * @param {Array} details Details about the property |
1103 * @constructor | 1104 * @constructor |
1104 * @extends Mirror | 1105 * @extends Mirror |
1105 */ | 1106 */ |
1106 function PropertyMirror(mirror, name, details) { | 1107 function PropertyMirror(mirror, name, details) { |
1107 %_CallFunction(this, PROPERTY_TYPE, Mirror); | 1108 %_CallFunction(this, PROPERTY_TYPE, Mirror); |
1108 this.mirror_ = mirror; | 1109 this.mirror_ = mirror; |
1109 this.name_ = name; | 1110 this.name_ = name; |
1110 this.value_ = details[0]; | 1111 this.value_ = details[0]; |
1111 this.details_ = details[1]; | 1112 this.details_ = details[1]; |
1112 if (details.length > 2) { | 1113 if (details.length > 2) { |
1113 this.exception_ = details[2] | 1114 this.exception_ = details[2]; |
1114 this.getter_ = details[3]; | 1115 this.getter_ = details[3]; |
1115 this.setter_ = details[4]; | 1116 this.setter_ = details[4]; |
1116 } | 1117 } |
1117 } | 1118 } |
1118 inherits(PropertyMirror, Mirror); | 1119 inherits(PropertyMirror, Mirror); |
1119 | 1120 |
1120 | 1121 |
1121 PropertyMirror.prototype.isReadOnly = function() { | 1122 PropertyMirror.prototype.isReadOnly = function() { |
1122 return (this.attributes() & PropertyAttribute.ReadOnly) != 0; | 1123 return (this.attributes() & PropertyAttribute.ReadOnly) != 0; |
1123 } | 1124 }; |
1124 | 1125 |
1125 | 1126 |
1126 PropertyMirror.prototype.isEnum = function() { | 1127 PropertyMirror.prototype.isEnum = function() { |
1127 return (this.attributes() & PropertyAttribute.DontEnum) == 0; | 1128 return (this.attributes() & PropertyAttribute.DontEnum) == 0; |
1128 } | 1129 }; |
1129 | 1130 |
1130 | 1131 |
1131 PropertyMirror.prototype.canDelete = function() { | 1132 PropertyMirror.prototype.canDelete = function() { |
1132 return (this.attributes() & PropertyAttribute.DontDelete) == 0; | 1133 return (this.attributes() & PropertyAttribute.DontDelete) == 0; |
1133 } | 1134 }; |
1134 | 1135 |
1135 | 1136 |
1136 PropertyMirror.prototype.name = function() { | 1137 PropertyMirror.prototype.name = function() { |
1137 return this.name_; | 1138 return this.name_; |
1138 } | 1139 }; |
1139 | 1140 |
1140 | 1141 |
1141 PropertyMirror.prototype.isIndexed = function() { | 1142 PropertyMirror.prototype.isIndexed = function() { |
1142 for (var i = 0; i < this.name_.length; i++) { | 1143 for (var i = 0; i < this.name_.length; i++) { |
1143 if (this.name_[i] < '0' || '9' < this.name_[i]) { | 1144 if (this.name_[i] < '0' || '9' < this.name_[i]) { |
1144 return false; | 1145 return false; |
1145 } | 1146 } |
1146 } | 1147 } |
1147 return true; | 1148 return true; |
1148 } | 1149 }; |
1149 | 1150 |
1150 | 1151 |
1151 PropertyMirror.prototype.value = function() { | 1152 PropertyMirror.prototype.value = function() { |
1152 return MakeMirror(this.value_, false); | 1153 return MakeMirror(this.value_, false); |
1153 } | 1154 }; |
1154 | 1155 |
1155 | 1156 |
1156 /** | 1157 /** |
1157 * Returns whether this property value is an exception. | 1158 * Returns whether this property value is an exception. |
1158 * @return {booolean} True if this property value is an exception | 1159 * @return {booolean} True if this property value is an exception |
1159 */ | 1160 */ |
1160 PropertyMirror.prototype.isException = function() { | 1161 PropertyMirror.prototype.isException = function() { |
1161 return this.exception_ ? true : false; | 1162 return this.exception_ ? true : false; |
1162 } | 1163 }; |
1163 | 1164 |
1164 | 1165 |
1165 PropertyMirror.prototype.attributes = function() { | 1166 PropertyMirror.prototype.attributes = function() { |
1166 return %DebugPropertyAttributesFromDetails(this.details_); | 1167 return %DebugPropertyAttributesFromDetails(this.details_); |
1167 } | 1168 }; |
1168 | 1169 |
1169 | 1170 |
1170 PropertyMirror.prototype.propertyType = function() { | 1171 PropertyMirror.prototype.propertyType = function() { |
1171 return %DebugPropertyTypeFromDetails(this.details_); | 1172 return %DebugPropertyTypeFromDetails(this.details_); |
1172 } | 1173 }; |
1173 | 1174 |
1174 | 1175 |
1175 PropertyMirror.prototype.insertionIndex = function() { | 1176 PropertyMirror.prototype.insertionIndex = function() { |
1176 return %DebugPropertyIndexFromDetails(this.details_); | 1177 return %DebugPropertyIndexFromDetails(this.details_); |
1177 } | 1178 }; |
1178 | 1179 |
1179 | 1180 |
1180 /** | 1181 /** |
1181 * Returns whether this property has a getter defined through __defineGetter__. | 1182 * Returns whether this property has a getter defined through __defineGetter__. |
1182 * @return {booolean} True if this property has a getter | 1183 * @return {booolean} True if this property has a getter |
1183 */ | 1184 */ |
1184 PropertyMirror.prototype.hasGetter = function() { | 1185 PropertyMirror.prototype.hasGetter = function() { |
1185 return this.getter_ ? true : false; | 1186 return this.getter_ ? true : false; |
1186 } | 1187 }; |
1187 | 1188 |
1188 | 1189 |
1189 /** | 1190 /** |
1190 * Returns whether this property has a setter defined through __defineSetter__. | 1191 * Returns whether this property has a setter defined through __defineSetter__. |
1191 * @return {booolean} True if this property has a setter | 1192 * @return {booolean} True if this property has a setter |
1192 */ | 1193 */ |
1193 PropertyMirror.prototype.hasSetter = function() { | 1194 PropertyMirror.prototype.hasSetter = function() { |
1194 return this.setter_ ? true : false; | 1195 return this.setter_ ? true : false; |
1195 } | 1196 }; |
1196 | 1197 |
1197 | 1198 |
1198 /** | 1199 /** |
1199 * Returns the getter for this property defined through __defineGetter__. | 1200 * Returns the getter for this property defined through __defineGetter__. |
1200 * @return {Mirror} FunctionMirror reflecting the getter function or | 1201 * @return {Mirror} FunctionMirror reflecting the getter function or |
1201 * UndefinedMirror if there is no getter for this property | 1202 * UndefinedMirror if there is no getter for this property |
1202 */ | 1203 */ |
1203 PropertyMirror.prototype.getter = function() { | 1204 PropertyMirror.prototype.getter = function() { |
1204 if (this.hasGetter()) { | 1205 if (this.hasGetter()) { |
1205 return MakeMirror(this.getter_); | 1206 return MakeMirror(this.getter_); |
1206 } else { | 1207 } else { |
1207 return GetUndefinedMirror(); | 1208 return GetUndefinedMirror(); |
1208 } | 1209 } |
1209 } | 1210 }; |
1210 | 1211 |
1211 | 1212 |
1212 /** | 1213 /** |
1213 * Returns the setter for this property defined through __defineSetter__. | 1214 * Returns the setter for this property defined through __defineSetter__. |
1214 * @return {Mirror} FunctionMirror reflecting the setter function or | 1215 * @return {Mirror} FunctionMirror reflecting the setter function or |
1215 * UndefinedMirror if there is no setter for this property | 1216 * UndefinedMirror if there is no setter for this property |
1216 */ | 1217 */ |
1217 PropertyMirror.prototype.setter = function() { | 1218 PropertyMirror.prototype.setter = function() { |
1218 if (this.hasSetter()) { | 1219 if (this.hasSetter()) { |
1219 return MakeMirror(this.setter_); | 1220 return MakeMirror(this.setter_); |
1220 } else { | 1221 } else { |
1221 return GetUndefinedMirror(); | 1222 return GetUndefinedMirror(); |
1222 } | 1223 } |
1223 } | 1224 }; |
1224 | 1225 |
1225 | 1226 |
1226 /** | 1227 /** |
1227 * Returns whether this property is natively implemented by the host or a set | 1228 * Returns whether this property is natively implemented by the host or a set |
1228 * through JavaScript code. | 1229 * through JavaScript code. |
1229 * @return {boolean} True if the property is | 1230 * @return {boolean} True if the property is |
1230 * UndefinedMirror if there is no setter for this property | 1231 * UndefinedMirror if there is no setter for this property |
1231 */ | 1232 */ |
1232 PropertyMirror.prototype.isNative = function() { | 1233 PropertyMirror.prototype.isNative = function() { |
1233 return (this.propertyType() == PropertyType.Interceptor) || | 1234 return (this.propertyType() == PropertyType.Interceptor) || |
1234 ((this.propertyType() == PropertyType.Callbacks) && | 1235 ((this.propertyType() == PropertyType.Callbacks) && |
1235 !this.hasGetter() && !this.hasSetter()); | 1236 !this.hasGetter() && !this.hasSetter()); |
1236 } | 1237 }; |
1237 | 1238 |
1238 | 1239 |
1239 const kFrameDetailsFrameIdIndex = 0; | 1240 const kFrameDetailsFrameIdIndex = 0; |
1240 const kFrameDetailsReceiverIndex = 1; | 1241 const kFrameDetailsReceiverIndex = 1; |
1241 const kFrameDetailsFunctionIndex = 2; | 1242 const kFrameDetailsFunctionIndex = 2; |
1242 const kFrameDetailsArgumentCountIndex = 3; | 1243 const kFrameDetailsArgumentCountIndex = 3; |
1243 const kFrameDetailsLocalCountIndex = 4; | 1244 const kFrameDetailsLocalCountIndex = 4; |
1244 const kFrameDetailsSourcePositionIndex = 5; | 1245 const kFrameDetailsSourcePositionIndex = 5; |
1245 const kFrameDetailsConstructCallIndex = 6; | 1246 const kFrameDetailsConstructCallIndex = 6; |
1246 const kFrameDetailsAtReturnIndex = 7; | 1247 const kFrameDetailsAtReturnIndex = 7; |
(...skipping 30 matching lines...) Expand all Loading... |
1277 */ | 1278 */ |
1278 function FrameDetails(break_id, index) { | 1279 function FrameDetails(break_id, index) { |
1279 this.break_id_ = break_id; | 1280 this.break_id_ = break_id; |
1280 this.details_ = %GetFrameDetails(break_id, index); | 1281 this.details_ = %GetFrameDetails(break_id, index); |
1281 } | 1282 } |
1282 | 1283 |
1283 | 1284 |
1284 FrameDetails.prototype.frameId = function() { | 1285 FrameDetails.prototype.frameId = function() { |
1285 %CheckExecutionState(this.break_id_); | 1286 %CheckExecutionState(this.break_id_); |
1286 return this.details_[kFrameDetailsFrameIdIndex]; | 1287 return this.details_[kFrameDetailsFrameIdIndex]; |
1287 } | 1288 }; |
1288 | 1289 |
1289 | 1290 |
1290 FrameDetails.prototype.receiver = function() { | 1291 FrameDetails.prototype.receiver = function() { |
1291 %CheckExecutionState(this.break_id_); | 1292 %CheckExecutionState(this.break_id_); |
1292 return this.details_[kFrameDetailsReceiverIndex]; | 1293 return this.details_[kFrameDetailsReceiverIndex]; |
1293 } | 1294 }; |
1294 | 1295 |
1295 | 1296 |
1296 FrameDetails.prototype.func = function() { | 1297 FrameDetails.prototype.func = function() { |
1297 %CheckExecutionState(this.break_id_); | 1298 %CheckExecutionState(this.break_id_); |
1298 return this.details_[kFrameDetailsFunctionIndex]; | 1299 return this.details_[kFrameDetailsFunctionIndex]; |
1299 } | 1300 }; |
1300 | 1301 |
1301 | 1302 |
1302 FrameDetails.prototype.isConstructCall = function() { | 1303 FrameDetails.prototype.isConstructCall = function() { |
1303 %CheckExecutionState(this.break_id_); | 1304 %CheckExecutionState(this.break_id_); |
1304 return this.details_[kFrameDetailsConstructCallIndex]; | 1305 return this.details_[kFrameDetailsConstructCallIndex]; |
1305 } | 1306 }; |
1306 | 1307 |
1307 | 1308 |
1308 FrameDetails.prototype.isAtReturn = function() { | 1309 FrameDetails.prototype.isAtReturn = function() { |
1309 %CheckExecutionState(this.break_id_); | 1310 %CheckExecutionState(this.break_id_); |
1310 return this.details_[kFrameDetailsAtReturnIndex]; | 1311 return this.details_[kFrameDetailsAtReturnIndex]; |
1311 } | 1312 }; |
1312 | 1313 |
1313 | 1314 |
1314 FrameDetails.prototype.isDebuggerFrame = function() { | 1315 FrameDetails.prototype.isDebuggerFrame = function() { |
1315 %CheckExecutionState(this.break_id_); | 1316 %CheckExecutionState(this.break_id_); |
1316 var f = kFrameDetailsFlagDebuggerFrameMask; | 1317 var f = kFrameDetailsFlagDebuggerFrameMask; |
1317 return (this.details_[kFrameDetailsFlagsIndex] & f) == f; | 1318 return (this.details_[kFrameDetailsFlagsIndex] & f) == f; |
1318 } | 1319 }; |
1319 | 1320 |
1320 | 1321 |
1321 FrameDetails.prototype.isOptimizedFrame = function() { | 1322 FrameDetails.prototype.isOptimizedFrame = function() { |
1322 %CheckExecutionState(this.break_id_); | 1323 %CheckExecutionState(this.break_id_); |
1323 var f = kFrameDetailsFlagOptimizedFrameMask; | 1324 var f = kFrameDetailsFlagOptimizedFrameMask; |
1324 return (this.details_[kFrameDetailsFlagsIndex] & f) == f; | 1325 return (this.details_[kFrameDetailsFlagsIndex] & f) == f; |
1325 } | 1326 }; |
1326 | 1327 |
1327 | 1328 |
1328 FrameDetails.prototype.isInlinedFrame = function() { | 1329 FrameDetails.prototype.isInlinedFrame = function() { |
1329 return this.inlinedFrameIndex() > 0; | 1330 return this.inlinedFrameIndex() > 0; |
1330 } | 1331 }; |
1331 | 1332 |
1332 | 1333 |
1333 FrameDetails.prototype.inlinedFrameIndex = function() { | 1334 FrameDetails.prototype.inlinedFrameIndex = function() { |
1334 %CheckExecutionState(this.break_id_); | 1335 %CheckExecutionState(this.break_id_); |
1335 var f = kFrameDetailsFlagInlinedFrameIndexMask; | 1336 var f = kFrameDetailsFlagInlinedFrameIndexMask; |
1336 return (this.details_[kFrameDetailsFlagsIndex] & f) >> 2 | 1337 return (this.details_[kFrameDetailsFlagsIndex] & f) >> 2; |
1337 } | 1338 }; |
1338 | 1339 |
1339 | 1340 |
1340 FrameDetails.prototype.argumentCount = function() { | 1341 FrameDetails.prototype.argumentCount = function() { |
1341 %CheckExecutionState(this.break_id_); | 1342 %CheckExecutionState(this.break_id_); |
1342 return this.details_[kFrameDetailsArgumentCountIndex]; | 1343 return this.details_[kFrameDetailsArgumentCountIndex]; |
1343 } | 1344 }; |
1344 | 1345 |
1345 | 1346 |
1346 FrameDetails.prototype.argumentName = function(index) { | 1347 FrameDetails.prototype.argumentName = function(index) { |
1347 %CheckExecutionState(this.break_id_); | 1348 %CheckExecutionState(this.break_id_); |
1348 if (index >= 0 && index < this.argumentCount()) { | 1349 if (index >= 0 && index < this.argumentCount()) { |
1349 return this.details_[kFrameDetailsFirstDynamicIndex + | 1350 return this.details_[kFrameDetailsFirstDynamicIndex + |
1350 index * kFrameDetailsNameValueSize + | 1351 index * kFrameDetailsNameValueSize + |
1351 kFrameDetailsNameIndex] | 1352 kFrameDetailsNameIndex]; |
1352 } | 1353 } |
1353 } | 1354 }; |
1354 | 1355 |
1355 | 1356 |
1356 FrameDetails.prototype.argumentValue = function(index) { | 1357 FrameDetails.prototype.argumentValue = function(index) { |
1357 %CheckExecutionState(this.break_id_); | 1358 %CheckExecutionState(this.break_id_); |
1358 if (index >= 0 && index < this.argumentCount()) { | 1359 if (index >= 0 && index < this.argumentCount()) { |
1359 return this.details_[kFrameDetailsFirstDynamicIndex + | 1360 return this.details_[kFrameDetailsFirstDynamicIndex + |
1360 index * kFrameDetailsNameValueSize + | 1361 index * kFrameDetailsNameValueSize + |
1361 kFrameDetailsValueIndex] | 1362 kFrameDetailsValueIndex]; |
1362 } | 1363 } |
1363 } | 1364 }; |
1364 | 1365 |
1365 | 1366 |
1366 FrameDetails.prototype.localCount = function() { | 1367 FrameDetails.prototype.localCount = function() { |
1367 %CheckExecutionState(this.break_id_); | 1368 %CheckExecutionState(this.break_id_); |
1368 return this.details_[kFrameDetailsLocalCountIndex]; | 1369 return this.details_[kFrameDetailsLocalCountIndex]; |
1369 } | 1370 }; |
1370 | 1371 |
1371 | 1372 |
1372 FrameDetails.prototype.sourcePosition = function() { | 1373 FrameDetails.prototype.sourcePosition = function() { |
1373 %CheckExecutionState(this.break_id_); | 1374 %CheckExecutionState(this.break_id_); |
1374 return this.details_[kFrameDetailsSourcePositionIndex]; | 1375 return this.details_[kFrameDetailsSourcePositionIndex]; |
1375 } | 1376 }; |
1376 | 1377 |
1377 | 1378 |
1378 FrameDetails.prototype.localName = function(index) { | 1379 FrameDetails.prototype.localName = function(index) { |
1379 %CheckExecutionState(this.break_id_); | 1380 %CheckExecutionState(this.break_id_); |
1380 if (index >= 0 && index < this.localCount()) { | 1381 if (index >= 0 && index < this.localCount()) { |
1381 var locals_offset = kFrameDetailsFirstDynamicIndex + | 1382 var locals_offset = kFrameDetailsFirstDynamicIndex + |
1382 this.argumentCount() * kFrameDetailsNameValueSize | 1383 this.argumentCount() * kFrameDetailsNameValueSize; |
1383 return this.details_[locals_offset + | 1384 return this.details_[locals_offset + |
1384 index * kFrameDetailsNameValueSize + | 1385 index * kFrameDetailsNameValueSize + |
1385 kFrameDetailsNameIndex] | 1386 kFrameDetailsNameIndex]; |
1386 } | 1387 } |
1387 } | 1388 }; |
1388 | 1389 |
1389 | 1390 |
1390 FrameDetails.prototype.localValue = function(index) { | 1391 FrameDetails.prototype.localValue = function(index) { |
1391 %CheckExecutionState(this.break_id_); | 1392 %CheckExecutionState(this.break_id_); |
1392 if (index >= 0 && index < this.localCount()) { | 1393 if (index >= 0 && index < this.localCount()) { |
1393 var locals_offset = kFrameDetailsFirstDynamicIndex + | 1394 var locals_offset = kFrameDetailsFirstDynamicIndex + |
1394 this.argumentCount() * kFrameDetailsNameValueSize | 1395 this.argumentCount() * kFrameDetailsNameValueSize; |
1395 return this.details_[locals_offset + | 1396 return this.details_[locals_offset + |
1396 index * kFrameDetailsNameValueSize + | 1397 index * kFrameDetailsNameValueSize + |
1397 kFrameDetailsValueIndex] | 1398 kFrameDetailsValueIndex]; |
1398 } | 1399 } |
1399 } | 1400 }; |
1400 | 1401 |
1401 | 1402 |
1402 FrameDetails.prototype.returnValue = function() { | 1403 FrameDetails.prototype.returnValue = function() { |
1403 %CheckExecutionState(this.break_id_); | 1404 %CheckExecutionState(this.break_id_); |
1404 var return_value_offset = | 1405 var return_value_offset = |
1405 kFrameDetailsFirstDynamicIndex + | 1406 kFrameDetailsFirstDynamicIndex + |
1406 (this.argumentCount() + this.localCount()) * kFrameDetailsNameValueSize; | 1407 (this.argumentCount() + this.localCount()) * kFrameDetailsNameValueSize; |
1407 if (this.details_[kFrameDetailsAtReturnIndex]) { | 1408 if (this.details_[kFrameDetailsAtReturnIndex]) { |
1408 return this.details_[return_value_offset]; | 1409 return this.details_[return_value_offset]; |
1409 } | 1410 } |
1410 } | 1411 }; |
1411 | 1412 |
1412 | 1413 |
1413 FrameDetails.prototype.scopeCount = function() { | 1414 FrameDetails.prototype.scopeCount = function() { |
1414 return %GetScopeCount(this.break_id_, this.frameId()); | 1415 return %GetScopeCount(this.break_id_, this.frameId()); |
1415 } | 1416 }; |
1416 | 1417 |
1417 | 1418 |
1418 /** | 1419 /** |
1419 * Mirror object for stack frames. | 1420 * Mirror object for stack frames. |
1420 * @param {number} break_id The break id in the VM for which this frame is | 1421 * @param {number} break_id The break id in the VM for which this frame is |
1421 valid | 1422 valid |
1422 * @param {number} index The frame index (top frame is index 0) | 1423 * @param {number} index The frame index (top frame is index 0) |
1423 * @constructor | 1424 * @constructor |
1424 * @extends Mirror | 1425 * @extends Mirror |
1425 */ | 1426 */ |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1568 FrameMirror.prototype.scopeCount = function() { | 1569 FrameMirror.prototype.scopeCount = function() { |
1569 return this.details_.scopeCount(); | 1570 return this.details_.scopeCount(); |
1570 }; | 1571 }; |
1571 | 1572 |
1572 | 1573 |
1573 FrameMirror.prototype.scope = function(index) { | 1574 FrameMirror.prototype.scope = function(index) { |
1574 return new ScopeMirror(this, index); | 1575 return new ScopeMirror(this, index); |
1575 }; | 1576 }; |
1576 | 1577 |
1577 | 1578 |
1578 FrameMirror.prototype.evaluate = function(source, disable_break, opt_context_obj
ect) { | 1579 FrameMirror.prototype.evaluate = function(source, disable_break, |
| 1580 opt_context_object) { |
1579 var result = %DebugEvaluate(this.break_id_, | 1581 var result = %DebugEvaluate(this.break_id_, |
1580 this.details_.frameId(), | 1582 this.details_.frameId(), |
1581 this.details_.inlinedFrameIndex(), | 1583 this.details_.inlinedFrameIndex(), |
1582 source, | 1584 source, |
1583 Boolean(disable_break), | 1585 Boolean(disable_break), |
1584 opt_context_object); | 1586 opt_context_object); |
1585 return MakeMirror(result); | 1587 return MakeMirror(result); |
1586 }; | 1588 }; |
1587 | 1589 |
1588 | 1590 |
1589 FrameMirror.prototype.invocationText = function() { | 1591 FrameMirror.prototype.invocationText = function() { |
1590 // Format frame invoaction (receiver, function and arguments). | 1592 // Format frame invoaction (receiver, function and arguments). |
1591 var result = ''; | 1593 var result = ''; |
1592 var func = this.func(); | 1594 var func = this.func(); |
1593 var receiver = this.receiver(); | 1595 var receiver = this.receiver(); |
1594 if (this.isConstructCall()) { | 1596 if (this.isConstructCall()) { |
1595 // For constructor frames display new followed by the function name. | 1597 // For constructor frames display new followed by the function name. |
1596 result += 'new '; | 1598 result += 'new '; |
1597 result += func.name() ? func.name() : '[anonymous]'; | 1599 result += func.name() ? func.name() : '[anonymous]'; |
1598 } else if (this.isDebuggerFrame()) { | 1600 } else if (this.isDebuggerFrame()) { |
1599 result += '[debugger]'; | 1601 result += '[debugger]'; |
1600 } else { | 1602 } else { |
1601 // If the receiver has a className which is 'global' don't display it. | 1603 // If the receiver has a className which is 'global' don't display it. |
1602 var display_receiver = !receiver.className || receiver.className() != 'globa
l'; | 1604 var display_receiver = |
| 1605 !receiver.className || (receiver.className() != 'global'); |
1603 if (display_receiver) { | 1606 if (display_receiver) { |
1604 result += receiver.toText(); | 1607 result += receiver.toText(); |
1605 } | 1608 } |
1606 // Try to find the function as a property in the receiver. Include the | 1609 // Try to find the function as a property in the receiver. Include the |
1607 // prototype chain in the lookup. | 1610 // prototype chain in the lookup. |
1608 var property = GetUndefinedMirror(); | 1611 var property = GetUndefinedMirror(); |
1609 if (receiver.isObject()) { | 1612 if (receiver.isObject()) { |
1610 for (var r = receiver; | 1613 for (var r = receiver; |
1611 !r.isNull() && property.isUndefined(); | 1614 !r.isNull() && property.isUndefined(); |
1612 r = r.protoObject()) { | 1615 r = r.protoObject()) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1654 } | 1657 } |
1655 result += ')'; | 1658 result += ')'; |
1656 } | 1659 } |
1657 | 1660 |
1658 if (this.isAtReturn()) { | 1661 if (this.isAtReturn()) { |
1659 result += ' returning '; | 1662 result += ' returning '; |
1660 result += this.returnValue().toText(); | 1663 result += this.returnValue().toText(); |
1661 } | 1664 } |
1662 | 1665 |
1663 return result; | 1666 return result; |
1664 } | 1667 }; |
1665 | 1668 |
1666 | 1669 |
1667 FrameMirror.prototype.sourceAndPositionText = function() { | 1670 FrameMirror.prototype.sourceAndPositionText = function() { |
1668 // Format source and position. | 1671 // Format source and position. |
1669 var result = ''; | 1672 var result = ''; |
1670 var func = this.func(); | 1673 var func = this.func(); |
1671 if (func.resolved()) { | 1674 if (func.resolved()) { |
1672 if (func.script()) { | 1675 if (func.script()) { |
1673 if (func.script().name()) { | 1676 if (func.script().name()) { |
1674 result += func.script().name(); | 1677 result += func.script().name(); |
(...skipping 11 matching lines...) Expand all Loading... |
1686 } | 1689 } |
1687 } | 1690 } |
1688 } else { | 1691 } else { |
1689 result += '[no source]'; | 1692 result += '[no source]'; |
1690 } | 1693 } |
1691 } else { | 1694 } else { |
1692 result += '[unresolved]'; | 1695 result += '[unresolved]'; |
1693 } | 1696 } |
1694 | 1697 |
1695 return result; | 1698 return result; |
1696 } | 1699 }; |
1697 | 1700 |
1698 | 1701 |
1699 FrameMirror.prototype.localsText = function() { | 1702 FrameMirror.prototype.localsText = function() { |
1700 // Format local variables. | 1703 // Format local variables. |
1701 var result = ''; | 1704 var result = ''; |
1702 var locals_count = this.localCount() | 1705 var locals_count = this.localCount(); |
1703 if (locals_count > 0) { | 1706 if (locals_count > 0) { |
1704 for (var i = 0; i < locals_count; ++i) { | 1707 for (var i = 0; i < locals_count; ++i) { |
1705 result += ' var '; | 1708 result += ' var '; |
1706 result += this.localName(i); | 1709 result += this.localName(i); |
1707 result += ' = '; | 1710 result += ' = '; |
1708 result += this.localValue(i).toText(); | 1711 result += this.localValue(i).toText(); |
1709 if (i < locals_count - 1) result += '\n'; | 1712 if (i < locals_count - 1) result += '\n'; |
1710 } | 1713 } |
1711 } | 1714 } |
1712 | 1715 |
1713 return result; | 1716 return result; |
1714 } | 1717 }; |
1715 | 1718 |
1716 | 1719 |
1717 FrameMirror.prototype.toText = function(opt_locals) { | 1720 FrameMirror.prototype.toText = function(opt_locals) { |
1718 var result = ''; | 1721 var result = ''; |
1719 result += '#' + (this.index() <= 9 ? '0' : '') + this.index(); | 1722 result += '#' + (this.index() <= 9 ? '0' : '') + this.index(); |
1720 result += ' '; | 1723 result += ' '; |
1721 result += this.invocationText(); | 1724 result += this.invocationText(); |
1722 result += ' '; | 1725 result += ' '; |
1723 result += this.sourceAndPositionText(); | 1726 result += this.sourceAndPositionText(); |
1724 if (opt_locals) { | 1727 if (opt_locals) { |
1725 result += '\n'; | 1728 result += '\n'; |
1726 result += this.localsText(); | 1729 result += this.localsText(); |
1727 } | 1730 } |
1728 return result; | 1731 return result; |
1729 } | 1732 }; |
1730 | 1733 |
1731 | 1734 |
1732 const kScopeDetailsTypeIndex = 0; | 1735 const kScopeDetailsTypeIndex = 0; |
1733 const kScopeDetailsObjectIndex = 1; | 1736 const kScopeDetailsObjectIndex = 1; |
1734 | 1737 |
1735 function ScopeDetails(frame, index) { | 1738 function ScopeDetails(frame, index) { |
1736 this.break_id_ = frame.break_id_; | 1739 this.break_id_ = frame.break_id_; |
1737 this.details_ = %GetScopeDetails(frame.break_id_, | 1740 this.details_ = %GetScopeDetails(frame.break_id_, |
1738 frame.details_.frameId(), | 1741 frame.details_.frameId(), |
1739 frame.details_.inlinedFrameIndex(), | 1742 frame.details_.inlinedFrameIndex(), |
1740 index); | 1743 index); |
1741 } | 1744 } |
1742 | 1745 |
1743 | 1746 |
1744 ScopeDetails.prototype.type = function() { | 1747 ScopeDetails.prototype.type = function() { |
1745 %CheckExecutionState(this.break_id_); | 1748 %CheckExecutionState(this.break_id_); |
1746 return this.details_[kScopeDetailsTypeIndex]; | 1749 return this.details_[kScopeDetailsTypeIndex]; |
1747 } | 1750 }; |
1748 | 1751 |
1749 | 1752 |
1750 ScopeDetails.prototype.object = function() { | 1753 ScopeDetails.prototype.object = function() { |
1751 %CheckExecutionState(this.break_id_); | 1754 %CheckExecutionState(this.break_id_); |
1752 return this.details_[kScopeDetailsObjectIndex]; | 1755 return this.details_[kScopeDetailsObjectIndex]; |
1753 } | 1756 }; |
1754 | 1757 |
1755 | 1758 |
1756 /** | 1759 /** |
1757 * Mirror object for scope. | 1760 * Mirror object for scope. |
1758 * @param {FrameMirror} frame The frame this scope is a part of | 1761 * @param {FrameMirror} frame The frame this scope is a part of |
1759 * @param {number} index The scope index in the frame | 1762 * @param {number} index The scope index in the frame |
1760 * @constructor | 1763 * @constructor |
1761 * @extends Mirror | 1764 * @extends Mirror |
1762 */ | 1765 */ |
1763 function ScopeMirror(frame, index) { | 1766 function ScopeMirror(frame, index) { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1855 | 1858 |
1856 | 1859 |
1857 ScriptMirror.prototype.lineCount = function() { | 1860 ScriptMirror.prototype.lineCount = function() { |
1858 return this.script_.lineCount(); | 1861 return this.script_.lineCount(); |
1859 }; | 1862 }; |
1860 | 1863 |
1861 | 1864 |
1862 ScriptMirror.prototype.locationFromPosition = function( | 1865 ScriptMirror.prototype.locationFromPosition = function( |
1863 position, include_resource_offset) { | 1866 position, include_resource_offset) { |
1864 return this.script_.locationFromPosition(position, include_resource_offset); | 1867 return this.script_.locationFromPosition(position, include_resource_offset); |
1865 } | 1868 }; |
1866 | 1869 |
1867 | 1870 |
1868 ScriptMirror.prototype.sourceSlice = function (opt_from_line, opt_to_line) { | 1871 ScriptMirror.prototype.sourceSlice = function (opt_from_line, opt_to_line) { |
1869 return this.script_.sourceSlice(opt_from_line, opt_to_line); | 1872 return this.script_.sourceSlice(opt_from_line, opt_to_line); |
1870 } | 1873 }; |
1871 | 1874 |
1872 | 1875 |
1873 ScriptMirror.prototype.context = function() { | 1876 ScriptMirror.prototype.context = function() { |
1874 return this.context_; | 1877 return this.context_; |
1875 }; | 1878 }; |
1876 | 1879 |
1877 | 1880 |
1878 ScriptMirror.prototype.evalFromScript = function() { | 1881 ScriptMirror.prototype.evalFromScript = function() { |
1879 return MakeMirror(this.script_.eval_from_script); | 1882 return MakeMirror(this.script_.eval_from_script); |
1880 }; | 1883 }; |
(...skipping 19 matching lines...) Expand all Loading... |
1900 result += ' (lines: '; | 1903 result += ' (lines: '; |
1901 if (this.lineOffset() > 0) { | 1904 if (this.lineOffset() > 0) { |
1902 result += this.lineOffset(); | 1905 result += this.lineOffset(); |
1903 result += '-'; | 1906 result += '-'; |
1904 result += this.lineOffset() + this.lineCount() - 1; | 1907 result += this.lineOffset() + this.lineCount() - 1; |
1905 } else { | 1908 } else { |
1906 result += this.lineCount(); | 1909 result += this.lineCount(); |
1907 } | 1910 } |
1908 result += ')'; | 1911 result += ')'; |
1909 return result; | 1912 return result; |
1910 } | 1913 }; |
1911 | 1914 |
1912 | 1915 |
1913 /** | 1916 /** |
1914 * Mirror object for context. | 1917 * Mirror object for context. |
1915 * @param {Object} data The context data | 1918 * @param {Object} data The context data |
1916 * @constructor | 1919 * @constructor |
1917 * @extends Mirror | 1920 * @extends Mirror |
1918 */ | 1921 */ |
1919 function ContextMirror(data) { | 1922 function ContextMirror(data) { |
1920 %_CallFunction(this, CONTEXT_TYPE, Mirror); | 1923 %_CallFunction(this, CONTEXT_TYPE, Mirror); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1958 | 1961 |
1959 /** | 1962 /** |
1960 * Returns a serialization of an object reference. The referenced object are | 1963 * Returns a serialization of an object reference. The referenced object are |
1961 * added to the serialization state. | 1964 * added to the serialization state. |
1962 * | 1965 * |
1963 * @param {Mirror} mirror The mirror to serialize | 1966 * @param {Mirror} mirror The mirror to serialize |
1964 * @returns {String} JSON serialization | 1967 * @returns {String} JSON serialization |
1965 */ | 1968 */ |
1966 JSONProtocolSerializer.prototype.serializeReference = function(mirror) { | 1969 JSONProtocolSerializer.prototype.serializeReference = function(mirror) { |
1967 return this.serialize_(mirror, true, true); | 1970 return this.serialize_(mirror, true, true); |
1968 } | 1971 }; |
1969 | 1972 |
1970 | 1973 |
1971 /** | 1974 /** |
1972 * Returns a serialization of an object value. The referenced objects are | 1975 * Returns a serialization of an object value. The referenced objects are |
1973 * added to the serialization state. | 1976 * added to the serialization state. |
1974 * | 1977 * |
1975 * @param {Mirror} mirror The mirror to serialize | 1978 * @param {Mirror} mirror The mirror to serialize |
1976 * @returns {String} JSON serialization | 1979 * @returns {String} JSON serialization |
1977 */ | 1980 */ |
1978 JSONProtocolSerializer.prototype.serializeValue = function(mirror) { | 1981 JSONProtocolSerializer.prototype.serializeValue = function(mirror) { |
1979 var json = this.serialize_(mirror, false, true); | 1982 var json = this.serialize_(mirror, false, true); |
1980 return json; | 1983 return json; |
1981 } | 1984 }; |
1982 | 1985 |
1983 | 1986 |
1984 /** | 1987 /** |
1985 * Returns a serialization of all the objects referenced. | 1988 * Returns a serialization of all the objects referenced. |
1986 * | 1989 * |
1987 * @param {Mirror} mirror The mirror to serialize. | 1990 * @param {Mirror} mirror The mirror to serialize. |
1988 * @returns {Array.<Object>} Array of the referenced objects converted to | 1991 * @returns {Array.<Object>} Array of the referenced objects converted to |
1989 * protcol objects. | 1992 * protcol objects. |
1990 */ | 1993 */ |
1991 JSONProtocolSerializer.prototype.serializeReferencedObjects = function() { | 1994 JSONProtocolSerializer.prototype.serializeReferencedObjects = function() { |
1992 // Collect the protocol representation of the referenced objects in an array. | 1995 // Collect the protocol representation of the referenced objects in an array. |
1993 var content = []; | 1996 var content = []; |
1994 | 1997 |
1995 // Get the number of referenced objects. | 1998 // Get the number of referenced objects. |
1996 var count = this.mirrors_.length; | 1999 var count = this.mirrors_.length; |
1997 | 2000 |
1998 for (var i = 0; i < count; i++) { | 2001 for (var i = 0; i < count; i++) { |
1999 content.push(this.serialize_(this.mirrors_[i], false, false)); | 2002 content.push(this.serialize_(this.mirrors_[i], false, false)); |
2000 } | 2003 } |
2001 | 2004 |
2002 return content; | 2005 return content; |
2003 } | 2006 }; |
2004 | 2007 |
2005 | 2008 |
2006 JSONProtocolSerializer.prototype.includeSource_ = function() { | 2009 JSONProtocolSerializer.prototype.includeSource_ = function() { |
2007 return this.options_ && this.options_.includeSource; | 2010 return this.options_ && this.options_.includeSource; |
2008 } | 2011 }; |
2009 | 2012 |
2010 | 2013 |
2011 JSONProtocolSerializer.prototype.inlineRefs_ = function() { | 2014 JSONProtocolSerializer.prototype.inlineRefs_ = function() { |
2012 return this.options_ && this.options_.inlineRefs; | 2015 return this.options_ && this.options_.inlineRefs; |
2013 } | 2016 }; |
2014 | 2017 |
2015 | 2018 |
2016 JSONProtocolSerializer.prototype.maxStringLength_ = function() { | 2019 JSONProtocolSerializer.prototype.maxStringLength_ = function() { |
2017 if (IS_UNDEFINED(this.options_) || | 2020 if (IS_UNDEFINED(this.options_) || |
2018 IS_UNDEFINED(this.options_.maxStringLength)) { | 2021 IS_UNDEFINED(this.options_.maxStringLength)) { |
2019 return kMaxProtocolStringLength; | 2022 return kMaxProtocolStringLength; |
2020 } | 2023 } |
2021 return this.options_.maxStringLength; | 2024 return this.options_.maxStringLength; |
2022 } | 2025 }; |
2023 | 2026 |
2024 | 2027 |
2025 JSONProtocolSerializer.prototype.add_ = function(mirror) { | 2028 JSONProtocolSerializer.prototype.add_ = function(mirror) { |
2026 // If this mirror is already in the list just return. | 2029 // If this mirror is already in the list just return. |
2027 for (var i = 0; i < this.mirrors_.length; i++) { | 2030 for (var i = 0; i < this.mirrors_.length; i++) { |
2028 if (this.mirrors_[i] === mirror) { | 2031 if (this.mirrors_[i] === mirror) { |
2029 return; | 2032 return; |
2030 } | 2033 } |
2031 } | 2034 } |
2032 | 2035 |
2033 // Add the mirror to the list of mirrors to be serialized. | 2036 // Add the mirror to the list of mirrors to be serialized. |
2034 this.mirrors_.push(mirror); | 2037 this.mirrors_.push(mirror); |
2035 } | 2038 }; |
2036 | 2039 |
2037 | 2040 |
2038 /** | 2041 /** |
2039 * Formats mirror object to protocol reference object with some data that can | 2042 * Formats mirror object to protocol reference object with some data that can |
2040 * be used to display the value in debugger. | 2043 * be used to display the value in debugger. |
2041 * @param {Mirror} mirror Mirror to serialize. | 2044 * @param {Mirror} mirror Mirror to serialize. |
2042 * @return {Object} Protocol reference object. | 2045 * @return {Object} Protocol reference object. |
2043 */ | 2046 */ |
2044 JSONProtocolSerializer.prototype.serializeReferenceWithDisplayData_ = | 2047 JSONProtocolSerializer.prototype.serializeReferenceWithDisplayData_ = |
2045 function(mirror) { | 2048 function(mirror) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2132 | 2135 |
2133 case OBJECT_TYPE: | 2136 case OBJECT_TYPE: |
2134 case FUNCTION_TYPE: | 2137 case FUNCTION_TYPE: |
2135 case ERROR_TYPE: | 2138 case ERROR_TYPE: |
2136 case REGEXP_TYPE: | 2139 case REGEXP_TYPE: |
2137 // Add object representation. | 2140 // Add object representation. |
2138 this.serializeObject_(mirror, content, details); | 2141 this.serializeObject_(mirror, content, details); |
2139 break; | 2142 break; |
2140 | 2143 |
2141 case PROPERTY_TYPE: | 2144 case PROPERTY_TYPE: |
2142 throw new Error('PropertyMirror cannot be serialized independeltly') | 2145 throw new Error('PropertyMirror cannot be serialized independeltly'); |
2143 break; | 2146 break; |
2144 | 2147 |
2145 case FRAME_TYPE: | 2148 case FRAME_TYPE: |
2146 // Add object representation. | 2149 // Add object representation. |
2147 this.serializeFrame_(mirror, content); | 2150 this.serializeFrame_(mirror, content); |
2148 break; | 2151 break; |
2149 | 2152 |
2150 case SCOPE_TYPE: | 2153 case SCOPE_TYPE: |
2151 // Add object representation. | 2154 // Add object representation. |
2152 this.serializeScope_(mirror, content); | 2155 this.serializeScope_(mirror, content); |
(...skipping 19 matching lines...) Expand all Loading... |
2172 } | 2175 } |
2173 content.sourceLength = mirror.source().length; | 2176 content.sourceLength = mirror.source().length; |
2174 content.scriptType = mirror.scriptType(); | 2177 content.scriptType = mirror.scriptType(); |
2175 content.compilationType = mirror.compilationType(); | 2178 content.compilationType = mirror.compilationType(); |
2176 // For compilation type eval emit information on the script from which | 2179 // For compilation type eval emit information on the script from which |
2177 // eval was called if a script is present. | 2180 // eval was called if a script is present. |
2178 if (mirror.compilationType() == 1 && | 2181 if (mirror.compilationType() == 1 && |
2179 mirror.evalFromScript()) { | 2182 mirror.evalFromScript()) { |
2180 content.evalFromScript = | 2183 content.evalFromScript = |
2181 this.serializeReference(mirror.evalFromScript()); | 2184 this.serializeReference(mirror.evalFromScript()); |
2182 var evalFromLocation = mirror.evalFromLocation() | 2185 var evalFromLocation = mirror.evalFromLocation(); |
2183 if (evalFromLocation) { | 2186 if (evalFromLocation) { |
2184 content.evalFromLocation = { line: evalFromLocation.line, | 2187 content.evalFromLocation = { line: evalFromLocation.line, |
2185 column: evalFromLocation.column }; | 2188 column: evalFromLocation.column }; |
2186 } | 2189 } |
2187 if (mirror.evalFromFunctionName()) { | 2190 if (mirror.evalFromFunctionName()) { |
2188 content.evalFromFunctionName = mirror.evalFromFunctionName(); | 2191 content.evalFromFunctionName = mirror.evalFromFunctionName(); |
2189 } | 2192 } |
2190 } | 2193 } |
2191 if (mirror.context()) { | 2194 if (mirror.context()) { |
2192 content.context = this.serializeReference(mirror.context()); | 2195 content.context = this.serializeReference(mirror.context()); |
2193 } | 2196 } |
2194 break; | 2197 break; |
2195 | 2198 |
2196 case CONTEXT_TYPE: | 2199 case CONTEXT_TYPE: |
2197 content.data = mirror.data(); | 2200 content.data = mirror.data(); |
2198 break; | 2201 break; |
2199 } | 2202 } |
2200 | 2203 |
2201 // Always add the text representation. | 2204 // Always add the text representation. |
2202 content.text = mirror.toText(); | 2205 content.text = mirror.toText(); |
2203 | 2206 |
2204 // Create and return the JSON string. | 2207 // Create and return the JSON string. |
2205 return content; | 2208 return content; |
2206 } | 2209 }; |
2207 | 2210 |
2208 | 2211 |
2209 /** | 2212 /** |
2210 * Serialize object information to the following JSON format. | 2213 * Serialize object information to the following JSON format. |
2211 * | 2214 * |
2212 * {"className":"<class name>", | 2215 * {"className":"<class name>", |
2213 * "constructorFunction":{"ref":<number>}, | 2216 * "constructorFunction":{"ref":<number>}, |
2214 * "protoObject":{"ref":<number>}, | 2217 * "protoObject":{"ref":<number>}, |
2215 * "prototypeObject":{"ref":<number>}, | 2218 * "prototypeObject":{"ref":<number>}, |
2216 * "namedInterceptor":<boolean>, | 2219 * "namedInterceptor":<boolean>, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2271 } | 2274 } |
2272 } | 2275 } |
2273 for (var i = 0; i < propertyIndexes.length; i++) { | 2276 for (var i = 0; i < propertyIndexes.length; i++) { |
2274 var propertyMirror = mirror.property(propertyIndexes[i]); | 2277 var propertyMirror = mirror.property(propertyIndexes[i]); |
2275 p[propertyNames.length + i] = this.serializeProperty_(propertyMirror); | 2278 p[propertyNames.length + i] = this.serializeProperty_(propertyMirror); |
2276 if (details) { | 2279 if (details) { |
2277 this.add_(propertyMirror.value()); | 2280 this.add_(propertyMirror.value()); |
2278 } | 2281 } |
2279 } | 2282 } |
2280 content.properties = p; | 2283 content.properties = p; |
2281 } | 2284 }; |
2282 | 2285 |
2283 | 2286 |
2284 /** | 2287 /** |
2285 * Serialize location information to the following JSON format: | 2288 * Serialize location information to the following JSON format: |
2286 * | 2289 * |
2287 * "position":"<position>", | 2290 * "position":"<position>", |
2288 * "line":"<line>", | 2291 * "line":"<line>", |
2289 * "column":"<column>", | 2292 * "column":"<column>", |
2290 * | 2293 * |
2291 * @param {SourceLocation} location The location to serialize, may be undefined. | 2294 * @param {SourceLocation} location The location to serialize, may be undefined. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2335 } else { | 2338 } else { |
2336 if (propertyMirror.attributes() != PropertyAttribute.None) { | 2339 if (propertyMirror.attributes() != PropertyAttribute.None) { |
2337 result.attributes = propertyMirror.attributes(); | 2340 result.attributes = propertyMirror.attributes(); |
2338 } | 2341 } |
2339 if (propertyMirror.propertyType() != PropertyType.Normal) { | 2342 if (propertyMirror.propertyType() != PropertyType.Normal) { |
2340 result.propertyType = propertyMirror.propertyType(); | 2343 result.propertyType = propertyMirror.propertyType(); |
2341 } | 2344 } |
2342 result.ref = propertyValue.handle(); | 2345 result.ref = propertyValue.handle(); |
2343 } | 2346 } |
2344 return result; | 2347 return result; |
2345 } | 2348 }; |
2346 | 2349 |
2347 | 2350 |
2348 JSONProtocolSerializer.prototype.serializeFrame_ = function(mirror, content) { | 2351 JSONProtocolSerializer.prototype.serializeFrame_ = function(mirror, content) { |
2349 content.index = mirror.index(); | 2352 content.index = mirror.index(); |
2350 content.receiver = this.serializeReference(mirror.receiver()); | 2353 content.receiver = this.serializeReference(mirror.receiver()); |
2351 var func = mirror.func(); | 2354 var func = mirror.func(); |
2352 content.func = this.serializeReference(func); | 2355 content.func = this.serializeReference(func); |
2353 if (func.script()) { | 2356 if (func.script()) { |
2354 content.script = this.serializeReference(func.script()); | 2357 content.script = this.serializeReference(func.script()); |
2355 } | 2358 } |
2356 content.constructCall = mirror.isConstructCall(); | 2359 content.constructCall = mirror.isConstructCall(); |
2357 content.atReturn = mirror.isAtReturn(); | 2360 content.atReturn = mirror.isAtReturn(); |
2358 if (mirror.isAtReturn()) { | 2361 if (mirror.isAtReturn()) { |
2359 content.returnValue = this.serializeReference(mirror.returnValue()); | 2362 content.returnValue = this.serializeReference(mirror.returnValue()); |
2360 } | 2363 } |
2361 content.debuggerFrame = mirror.isDebuggerFrame(); | 2364 content.debuggerFrame = mirror.isDebuggerFrame(); |
2362 var x = new Array(mirror.argumentCount()); | 2365 var x = new Array(mirror.argumentCount()); |
2363 for (var i = 0; i < mirror.argumentCount(); i++) { | 2366 for (var i = 0; i < mirror.argumentCount(); i++) { |
2364 var arg = {}; | 2367 var arg = {}; |
2365 var argument_name = mirror.argumentName(i) | 2368 var argument_name = mirror.argumentName(i); |
2366 if (argument_name) { | 2369 if (argument_name) { |
2367 arg.name = argument_name; | 2370 arg.name = argument_name; |
2368 } | 2371 } |
2369 arg.value = this.serializeReference(mirror.argumentValue(i)); | 2372 arg.value = this.serializeReference(mirror.argumentValue(i)); |
2370 x[i] = arg; | 2373 x[i] = arg; |
2371 } | 2374 } |
2372 content.arguments = x; | 2375 content.arguments = x; |
2373 var x = new Array(mirror.localCount()); | 2376 var x = new Array(mirror.localCount()); |
2374 for (var i = 0; i < mirror.localCount(); i++) { | 2377 for (var i = 0; i < mirror.localCount(); i++) { |
2375 var local = {}; | 2378 var local = {}; |
2376 local.name = mirror.localName(i); | 2379 local.name = mirror.localName(i); |
2377 local.value = this.serializeReference(mirror.localValue(i)); | 2380 local.value = this.serializeReference(mirror.localValue(i)); |
2378 x[i] = local; | 2381 x[i] = local; |
2379 } | 2382 } |
2380 content.locals = x; | 2383 content.locals = x; |
2381 serializeLocationFields(mirror.sourceLocation(), content); | 2384 serializeLocationFields(mirror.sourceLocation(), content); |
2382 var source_line_text = mirror.sourceLineText(); | 2385 var source_line_text = mirror.sourceLineText(); |
2383 if (!IS_UNDEFINED(source_line_text)) { | 2386 if (!IS_UNDEFINED(source_line_text)) { |
2384 content.sourceLineText = source_line_text; | 2387 content.sourceLineText = source_line_text; |
2385 } | 2388 } |
2386 | 2389 |
2387 content.scopes = []; | 2390 content.scopes = []; |
2388 for (var i = 0; i < mirror.scopeCount(); i++) { | 2391 for (var i = 0; i < mirror.scopeCount(); i++) { |
2389 var scope = mirror.scope(i); | 2392 var scope = mirror.scope(i); |
2390 content.scopes.push({ | 2393 content.scopes.push({ |
2391 type: scope.scopeType(), | 2394 type: scope.scopeType(), |
2392 index: i | 2395 index: i |
2393 }); | 2396 }); |
2394 } | 2397 } |
2395 } | 2398 }; |
2396 | 2399 |
2397 | 2400 |
2398 JSONProtocolSerializer.prototype.serializeScope_ = function(mirror, content) { | 2401 JSONProtocolSerializer.prototype.serializeScope_ = function(mirror, content) { |
2399 content.index = mirror.scopeIndex(); | 2402 content.index = mirror.scopeIndex(); |
2400 content.frameIndex = mirror.frameIndex(); | 2403 content.frameIndex = mirror.frameIndex(); |
2401 content.type = mirror.scopeType(); | 2404 content.type = mirror.scopeType(); |
2402 content.object = this.inlineRefs_() ? | 2405 content.object = this.inlineRefs_() ? |
2403 this.serializeValue(mirror.scopeObject()) : | 2406 this.serializeValue(mirror.scopeObject()) : |
2404 this.serializeReference(mirror.scopeObject()); | 2407 this.serializeReference(mirror.scopeObject()); |
2405 } | 2408 }; |
2406 | 2409 |
2407 | 2410 |
2408 /** | 2411 /** |
2409 * Convert a number to a protocol value. For all finite numbers the number | 2412 * Convert a number to a protocol value. For all finite numbers the number |
2410 * itself is returned. For non finite numbers NaN, Infinite and | 2413 * itself is returned. For non finite numbers NaN, Infinite and |
2411 * -Infinite the string representation "NaN", "Infinite" or "-Infinite" | 2414 * -Infinite the string representation "NaN", "Infinite" or "-Infinite" |
2412 * (not including the quotes) is returned. | 2415 * (not including the quotes) is returned. |
2413 * | 2416 * |
2414 * @param {number} value The number value to convert to a protocol value. | 2417 * @param {number} value The number value to convert to a protocol value. |
2415 * @returns {number|string} Protocol value. | 2418 * @returns {number|string} Protocol value. |
2416 */ | 2419 */ |
2417 function NumberToJSON_(value) { | 2420 function NumberToJSON_(value) { |
2418 if (isNaN(value)) { | 2421 if (isNaN(value)) { |
2419 return 'NaN'; | 2422 return 'NaN'; |
2420 } | 2423 } |
2421 if (!NUMBER_IS_FINITE(value)) { | 2424 if (!NUMBER_IS_FINITE(value)) { |
2422 if (value > 0) { | 2425 if (value > 0) { |
2423 return 'Infinity'; | 2426 return 'Infinity'; |
2424 } else { | 2427 } else { |
2425 return '-Infinity'; | 2428 return '-Infinity'; |
2426 } | 2429 } |
2427 } | 2430 } |
2428 return value; | 2431 return value; |
2429 } | 2432 } |
OLD | NEW |