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

Side by Side Diff: src/mirror-delay.js

Issue 6223: Make sure that the name accessor on functions return the expected... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 12 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « src/messages.js ('k') | src/regexp-delay.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 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 /** 331 /**
332 * Base class for all value mirror objects. 332 * Base class for all value mirror objects.
333 * @param {string} type The type of the mirror 333 * @param {string} type The type of the mirror
334 * @param {value} value The value reflected by this mirror 334 * @param {value} value The value reflected by this mirror
335 * @constructor 335 * @constructor
336 * @extends Mirror 336 * @extends Mirror
337 */ 337 */
338 function ValueMirror(type, value) { 338 function ValueMirror(type, value) {
339 Mirror.call(this, type); 339 Mirror.call(this, type);
340 this.value_ = value; 340 this.value_ = value;
341 }; 341 }
342 inherits(ValueMirror, Mirror); 342 inherits(ValueMirror, Mirror);
343 343
344 344
345 /** 345 /**
346 * Check whether this is a primitive value. 346 * Check whether this is a primitive value.
347 * @return {boolean} True if the mirror reflects a primitive value 347 * @return {boolean} True if the mirror reflects a primitive value
348 */ 348 */
349 ValueMirror.prototype.isPrimitive = function() { 349 ValueMirror.prototype.isPrimitive = function() {
350 var type = this.type(); 350 var type = this.type();
351 return type === 'undefined' || 351 return type === 'undefined' ||
(...skipping 13 matching lines...) Expand all
365 }; 365 };
366 366
367 367
368 /** 368 /**
369 * Mirror object for Undefined. 369 * Mirror object for Undefined.
370 * @constructor 370 * @constructor
371 * @extends ValueMirror 371 * @extends ValueMirror
372 */ 372 */
373 function UndefinedMirror() { 373 function UndefinedMirror() {
374 ValueMirror.call(this, UNDEFINED_TYPE, void 0); 374 ValueMirror.call(this, UNDEFINED_TYPE, void 0);
375 }; 375 }
376 inherits(UndefinedMirror, ValueMirror); 376 inherits(UndefinedMirror, ValueMirror);
377 377
378 378
379 UndefinedMirror.prototype.toText = function() { 379 UndefinedMirror.prototype.toText = function() {
380 return 'undefined'; 380 return 'undefined';
381 } 381 }
382 382
383 383
384 /** 384 /**
385 * Mirror object for null. 385 * Mirror object for null.
386 * @constructor 386 * @constructor
387 * @extends ValueMirror 387 * @extends ValueMirror
388 */ 388 */
389 function NullMirror() { 389 function NullMirror() {
390 ValueMirror.call(this, NULL_TYPE, null); 390 ValueMirror.call(this, NULL_TYPE, null);
391 }; 391 }
392 inherits(NullMirror, ValueMirror); 392 inherits(NullMirror, ValueMirror);
393 393
394 394
395 NullMirror.prototype.toText = function() { 395 NullMirror.prototype.toText = function() {
396 return 'null'; 396 return 'null';
397 } 397 }
398 398
399 399
400 /** 400 /**
401 * Mirror object for boolean values. 401 * Mirror object for boolean values.
402 * @param {boolean} value The boolean value reflected by this mirror 402 * @param {boolean} value The boolean value reflected by this mirror
403 * @constructor 403 * @constructor
404 * @extends ValueMirror 404 * @extends ValueMirror
405 */ 405 */
406 function BooleanMirror(value) { 406 function BooleanMirror(value) {
407 ValueMirror.call(this, BOOLEAN_TYPE, value); 407 ValueMirror.call(this, BOOLEAN_TYPE, value);
408 }; 408 }
409 inherits(BooleanMirror, ValueMirror); 409 inherits(BooleanMirror, ValueMirror);
410 410
411 411
412 BooleanMirror.prototype.fillJSON_ = function(content, details) { 412 BooleanMirror.prototype.fillJSON_ = function(content, details) {
413 BooleanMirror.super_.fillJSONType_.call(this, content); 413 BooleanMirror.super_.fillJSONType_.call(this, content);
414 content.push(MakeJSONPair_('value', BooleanToJSON_(this.value_))); 414 content.push(MakeJSONPair_('value', BooleanToJSON_(this.value_)));
415 } 415 }
416 416
417 417
418 BooleanMirror.prototype.toText = function() { 418 BooleanMirror.prototype.toText = function() {
419 return this.value_ ? 'true' : 'false'; 419 return this.value_ ? 'true' : 'false';
420 } 420 }
421 421
422 422
423 /** 423 /**
424 * Mirror object for number values. 424 * Mirror object for number values.
425 * @param {number} value The number value reflected by this mirror 425 * @param {number} value The number value reflected by this mirror
426 * @constructor 426 * @constructor
427 * @extends ValueMirror 427 * @extends ValueMirror
428 */ 428 */
429 function NumberMirror(value) { 429 function NumberMirror(value) {
430 ValueMirror.call(this, NUMBER_TYPE, value); 430 ValueMirror.call(this, NUMBER_TYPE, value);
431 }; 431 }
432 inherits(NumberMirror, ValueMirror); 432 inherits(NumberMirror, ValueMirror);
433 433
434 434
435 NumberMirror.prototype.fillJSON_ = function(content, details) { 435 NumberMirror.prototype.fillJSON_ = function(content, details) {
436 NumberMirror.super_.fillJSONType_.call(this, content); 436 NumberMirror.super_.fillJSONType_.call(this, content);
437 content.push(MakeJSONPair_('value', NumberToJSON_(this.value_))); 437 content.push(MakeJSONPair_('value', NumberToJSON_(this.value_)));
438 } 438 }
439 439
440 440
441 NumberMirror.prototype.toText = function() { 441 NumberMirror.prototype.toText = function() {
442 return %NumberToString(this.value_); 442 return %NumberToString(this.value_);
443 } 443 }
444 444
445 445
446 /** 446 /**
447 * Mirror object for string values. 447 * Mirror object for string values.
448 * @param {string} value The string value reflected by this mirror 448 * @param {string} value The string value reflected by this mirror
449 * @constructor 449 * @constructor
450 * @extends ValueMirror 450 * @extends ValueMirror
451 */ 451 */
452 function StringMirror(value) { 452 function StringMirror(value) {
453 ValueMirror.call(this, STRING_TYPE, value); 453 ValueMirror.call(this, STRING_TYPE, value);
454 }; 454 }
455 inherits(StringMirror, ValueMirror); 455 inherits(StringMirror, ValueMirror);
456 456
457 457
458 StringMirror.prototype.length = function() { 458 StringMirror.prototype.length = function() {
459 return this.value_.length; 459 return this.value_.length;
460 }; 460 };
461 461
462 462
463 StringMirror.prototype.fillJSON_ = function(content, details) { 463 StringMirror.prototype.fillJSON_ = function(content, details) {
464 StringMirror.super_.fillJSONType_.call(this, content); 464 StringMirror.super_.fillJSONType_.call(this, content);
(...skipping 21 matching lines...) Expand all
486 486
487 487
488 /** 488 /**
489 * Mirror object for objects. 489 * Mirror object for objects.
490 * @param {object} value The object reflected by this mirror 490 * @param {object} value The object reflected by this mirror
491 * @constructor 491 * @constructor
492 * @extends ValueMirror 492 * @extends ValueMirror
493 */ 493 */
494 function ObjectMirror(value, type) { 494 function ObjectMirror(value, type) {
495 ValueMirror.call(this, type || OBJECT_TYPE, value); 495 ValueMirror.call(this, type || OBJECT_TYPE, value);
496 }; 496 }
497 inherits(ObjectMirror, ValueMirror); 497 inherits(ObjectMirror, ValueMirror);
498 498
499 499
500 ObjectMirror.prototype.className = function() { 500 ObjectMirror.prototype.className = function() {
501 return %ClassOf(this.value_); 501 return %ClassOf(this.value_);
502 }; 502 };
503 503
504 504
505 ObjectMirror.prototype.constructorFunction = function() { 505 ObjectMirror.prototype.constructorFunction = function() {
506 return MakeMirror(%DebugGetProperty(this.value_, 'constructor')); 506 return MakeMirror(%DebugGetProperty(this.value_, 'constructor'));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 total += propertyNames.length; 551 total += propertyNames.length;
552 } 552 }
553 if (kind & PropertyKind.Indexed) { 553 if (kind & PropertyKind.Indexed) {
554 elementNames = %DebugLocalElementNames(this.value_) 554 elementNames = %DebugLocalElementNames(this.value_)
555 total += elementNames.length; 555 total += elementNames.length;
556 } 556 }
557 limit = Math.min(limit || total, total); 557 limit = Math.min(limit || total, total);
558 558
559 var names = new Array(limit); 559 var names = new Array(limit);
560 var index = 0; 560 var index = 0;
561 561
562 // Copy names for named properties. 562 // Copy names for named properties.
563 if (kind & PropertyKind.Named) { 563 if (kind & PropertyKind.Named) {
564 for (var i = 0; index < limit && i < propertyNames.length; i++) { 564 for (var i = 0; index < limit && i < propertyNames.length; i++) {
565 names[index++] = propertyNames[i]; 565 names[index++] = propertyNames[i];
566 } 566 }
567 } 567 }
568 568
569 // Copy names for indexed properties. 569 // Copy names for indexed properties.
570 if (kind & PropertyKind.Indexed) { 570 if (kind & PropertyKind.Indexed) {
571 for (var i = 0; index < limit && i < elementNames.length; i++) { 571 for (var i = 0; index < limit && i < elementNames.length; i++) {
572 names[index++] = elementNames[i]; 572 names[index++] = elementNames[i];
573 } 573 }
574 } 574 }
575 575
576 return names; 576 return names;
577 }; 577 };
578 578
(...skipping 28 matching lines...) Expand all
607 ObjectMirror.prototype.interceptorPropertyNames = function(kind, limit) { 607 ObjectMirror.prototype.interceptorPropertyNames = function(kind, limit) {
608 // Find kind. 608 // Find kind.
609 kind = kind || PropertyKind.Named | PropertyKind.Indexed; 609 kind = kind || PropertyKind.Named | PropertyKind.Indexed;
610 var namedInterceptorNames; 610 var namedInterceptorNames;
611 var indexedInterceptorNames; 611 var indexedInterceptorNames;
612 612
613 // Get names for named interceptor properties. 613 // Get names for named interceptor properties.
614 if (this.hasNamedInterceptor() && kind & PropertyKind.Named) { 614 if (this.hasNamedInterceptor() && kind & PropertyKind.Named) {
615 namedInterceptorNames = %DebugNamedInterceptorPropertyNames(this.value_); 615 namedInterceptorNames = %DebugNamedInterceptorPropertyNames(this.value_);
616 } 616 }
617 617
618 // Get names for indexed interceptor properties. 618 // Get names for indexed interceptor properties.
619 if (this.hasIndexedInterceptor() && kind & PropertyKind.Indexed) { 619 if (this.hasIndexedInterceptor() && kind & PropertyKind.Indexed) {
620 indexedInterceptorNames = %DebugIndexedInterceptorElementNames(this.value_); 620 indexedInterceptorNames = %DebugIndexedInterceptorElementNames(this.value_);
621 } 621 }
622 622
623 // Return either retult or both concattenated. 623 // Return either retult or both concattenated.
624 if (namedInterceptorNames && indexedInterceptorNames) { 624 if (namedInterceptorNames && indexedInterceptorNames) {
625 return namedInterceptorNames.concat(indexedInterceptorNames); 625 return namedInterceptorNames.concat(indexedInterceptorNames);
626 } else if (namedInterceptorNames) { 626 } else if (namedInterceptorNames) {
627 return namedInterceptorNames; 627 return namedInterceptorNames;
(...skipping 11 matching lines...) Expand all
639 * interceptor properties are requested 639 * interceptor properties are requested
640 * @param {Array} opt_names Limit the number of properties returned to the 640 * @param {Array} opt_names Limit the number of properties returned to the
641 specified value 641 specified value
642 * @return {Array} properties this object as an array of PropertyMirror objects 642 * @return {Array} properties this object as an array of PropertyMirror objects
643 */ 643 */
644 ObjectMirror.prototype.interceptorProperties = function(opt_kind, opt_names) { 644 ObjectMirror.prototype.interceptorProperties = function(opt_kind, opt_names) {
645 // Find kind. 645 // Find kind.
646 var kind = opt_kind || PropertyKind.Named | PropertyKind.Indexed; 646 var kind = opt_kind || PropertyKind.Named | PropertyKind.Indexed;
647 var namedInterceptorProperties; 647 var namedInterceptorProperties;
648 var indexedInterceptorProperties; 648 var indexedInterceptorProperties;
649 649
650 // Get values for named interceptor properties. 650 // Get values for named interceptor properties.
651 if (kind & PropertyKind.Named) { 651 if (kind & PropertyKind.Named) {
652 var names = opt_names || this.interceptorPropertyNames(PropertyKind.Named); 652 var names = opt_names || this.interceptorPropertyNames(PropertyKind.Named);
653 namedInterceptorProperties = new Array(names.length); 653 namedInterceptorProperties = new Array(names.length);
654 for (i = 0; i < names.length; i++) { 654 for (i = 0; i < names.length; i++) {
655 var value = %DebugNamedInterceptorPropertyValue(this.value_, names[i]); 655 var value = %DebugNamedInterceptorPropertyValue(this.value_, names[i]);
656 namedInterceptorProperties[i] = new InterceptorPropertyMirror(this, names[ i], value); 656 namedInterceptorProperties[i] = new InterceptorPropertyMirror(this, names[ i], value);
657 } 657 }
658 } 658 }
659 659
660 // Get values for indexed interceptor properties. 660 // Get values for indexed interceptor properties.
661 if (kind & PropertyKind.Indexed) { 661 if (kind & PropertyKind.Indexed) {
662 var names = opt_names || this.interceptorPropertyNames(PropertyKind.Indexed) ; 662 var names = opt_names || this.interceptorPropertyNames(PropertyKind.Indexed) ;
663 indexedInterceptorProperties = new Array(names.length); 663 indexedInterceptorProperties = new Array(names.length);
664 for (i = 0; i < names.length; i++) { 664 for (i = 0; i < names.length; i++) {
665 // Don't try to get the value if the name is not a number. 665 // Don't try to get the value if the name is not a number.
666 if (IS_NUMBER(names[i])) { 666 if (IS_NUMBER(names[i])) {
667 var value = %DebugIndexedInterceptorElementValue(this.value_, names[i]); 667 var value = %DebugIndexedInterceptorElementValue(this.value_, names[i]);
668 indexedInterceptorProperties[i] = new InterceptorPropertyMirror(this, na mes[i], value); 668 indexedInterceptorProperties[i] = new InterceptorPropertyMirror(this, na mes[i], value);
669 } 669 }
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 798
799 /** 799 /**
800 * Mirror object for functions. 800 * Mirror object for functions.
801 * @param {function} value The function object reflected by this mirror. 801 * @param {function} value The function object reflected by this mirror.
802 * @constructor 802 * @constructor
803 * @extends ObjectMirror 803 * @extends ObjectMirror
804 */ 804 */
805 function FunctionMirror(value) { 805 function FunctionMirror(value) {
806 ObjectMirror.call(this, value, FUNCTION_TYPE); 806 ObjectMirror.call(this, value, FUNCTION_TYPE);
807 this.resolved_ = true; 807 this.resolved_ = true;
808 }; 808 }
809 inherits(FunctionMirror, ObjectMirror); 809 inherits(FunctionMirror, ObjectMirror);
810 810
811 811
812 /** 812 /**
813 * Returns whether the function is resolved. 813 * Returns whether the function is resolved.
814 * @return {boolean} True if the function is resolved. Unresolved functions can 814 * @return {boolean} True if the function is resolved. Unresolved functions can
815 * only originate as functions from stack frames 815 * only originate as functions from stack frames
816 */ 816 */
817 FunctionMirror.prototype.resolved = function() { 817 FunctionMirror.prototype.resolved = function() {
818 return this.resolved_; 818 return this.resolved_;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 /** 864 /**
865 * Returns objects constructed by this function. 865 * Returns objects constructed by this function.
866 * @param {number} opt_max_instances Optional parameter specifying the maximum 866 * @param {number} opt_max_instances Optional parameter specifying the maximum
867 * number of instances to return. 867 * number of instances to return.
868 * @return {Array or undefined} The objects constructed by this function. 868 * @return {Array or undefined} The objects constructed by this function.
869 */ 869 */
870 FunctionMirror.prototype.constructedBy = function(opt_max_instances) { 870 FunctionMirror.prototype.constructedBy = function(opt_max_instances) {
871 if (this.resolved()) { 871 if (this.resolved()) {
872 // Find all objects constructed from this function. 872 // Find all objects constructed from this function.
873 var result = %DebugConstructedBy(this.value_, opt_max_instances || 0); 873 var result = %DebugConstructedBy(this.value_, opt_max_instances || 0);
874 874
875 // Make mirrors for all the instances found. 875 // Make mirrors for all the instances found.
876 for (var i = 0; i < result.length; i++) { 876 for (var i = 0; i < result.length; i++) {
877 result[i] = MakeMirror(result[i]); 877 result[i] = MakeMirror(result[i]);
878 } 878 }
879 879
880 return result; 880 return result;
881 } else { 881 } else {
882 return []; 882 return [];
883 } 883 }
884 }; 884 };
885 885
886 886
887 FunctionMirror.prototype.fillJSON_ = function(content, details) { 887 FunctionMirror.prototype.fillJSON_ = function(content, details) {
888 // Fill JSON properties from parent (ObjectMirror). 888 // Fill JSON properties from parent (ObjectMirror).
889 FunctionMirror.super_.fillJSON_.call(this, content, details); 889 FunctionMirror.super_.fillJSON_.call(this, content, details);
(...skipping 21 matching lines...) Expand all
911 * @constructor 911 * @constructor
912 * @extends ObjectMirror 912 * @extends ObjectMirror
913 */ 913 */
914 function UnresolvedFunctionMirror(value) { 914 function UnresolvedFunctionMirror(value) {
915 // Construct this using the ValueMirror as an unresolved function is not a 915 // Construct this using the ValueMirror as an unresolved function is not a
916 // real object but just a string. 916 // real object but just a string.
917 ValueMirror.call(this, FUNCTION_TYPE, value); 917 ValueMirror.call(this, FUNCTION_TYPE, value);
918 this.propertyCount_ = 0; 918 this.propertyCount_ = 0;
919 this.elementCount_ = 0; 919 this.elementCount_ = 0;
920 this.resolved_ = false; 920 this.resolved_ = false;
921 }; 921 }
922 inherits(UnresolvedFunctionMirror, FunctionMirror); 922 inherits(UnresolvedFunctionMirror, FunctionMirror);
923 923
924 924
925 UnresolvedFunctionMirror.prototype.className = function() { 925 UnresolvedFunctionMirror.prototype.className = function() {
926 return 'Function'; 926 return 'Function';
927 }; 927 };
928 928
929 929
930 UnresolvedFunctionMirror.prototype.constructorFunction = function() { 930 UnresolvedFunctionMirror.prototype.constructorFunction = function() {
931 return new UndefinedMirror(); 931 return new UndefinedMirror();
(...skipping 21 matching lines...) Expand all
953 953
954 954
955 /** 955 /**
956 * Mirror object for arrays. 956 * Mirror object for arrays.
957 * @param {Array} value The Array object reflected by this mirror 957 * @param {Array} value The Array object reflected by this mirror
958 * @constructor 958 * @constructor
959 * @extends ObjectMirror 959 * @extends ObjectMirror
960 */ 960 */
961 function ArrayMirror(value) { 961 function ArrayMirror(value) {
962 ObjectMirror.call(this, value); 962 ObjectMirror.call(this, value);
963 }; 963 }
964 inherits(ArrayMirror, ObjectMirror); 964 inherits(ArrayMirror, ObjectMirror);
965 965
966 966
967 ArrayMirror.prototype.length = function() { 967 ArrayMirror.prototype.length = function() {
968 return this.value_.length; 968 return this.value_.length;
969 }; 969 };
970 970
971 971
972 ArrayMirror.prototype.indexedPropertiesFromRange = function(opt_from_index, opt_ to_index) { 972 ArrayMirror.prototype.indexedPropertiesFromRange = function(opt_from_index, opt_ to_index) {
973 var from_index = opt_from_index || 0; 973 var from_index = opt_from_index || 0;
(...skipping 27 matching lines...) Expand all
1001 1001
1002 1002
1003 /** 1003 /**
1004 * Mirror object for dates. 1004 * Mirror object for dates.
1005 * @param {Date} value The Date object reflected by this mirror 1005 * @param {Date} value The Date object reflected by this mirror
1006 * @constructor 1006 * @constructor
1007 * @extends ObjectMirror 1007 * @extends ObjectMirror
1008 */ 1008 */
1009 function DateMirror(value) { 1009 function DateMirror(value) {
1010 ObjectMirror.call(this, value); 1010 ObjectMirror.call(this, value);
1011 }; 1011 }
1012 inherits(DateMirror, ObjectMirror); 1012 inherits(DateMirror, ObjectMirror);
1013 1013
1014 1014
1015 DateMirror.prototype.fillJSON_ = function(content, details) { 1015 DateMirror.prototype.fillJSON_ = function(content, details) {
1016 // Fill JSON properties from parent (ObjectMirror). 1016 // Fill JSON properties from parent (ObjectMirror).
1017 DateMirror.super_.fillJSON_.call(this, content, details); 1017 DateMirror.super_.fillJSON_.call(this, content, details);
1018 // Add date specific properties. 1018 // Add date specific properties.
1019 content.push(MakeJSONPair_('value', DateToJSON_(this.value_))); 1019 content.push(MakeJSONPair_('value', DateToJSON_(this.value_)));
1020 } 1020 }
1021 1021
1022 1022
1023 DateMirror.prototype.toText = function() { 1023 DateMirror.prototype.toText = function() {
1024 return DateToISO8601_(this.value_); 1024 return DateToISO8601_(this.value_);
1025 } 1025 }
1026 1026
1027 1027
1028 /** 1028 /**
1029 * Mirror object for regular expressions. 1029 * Mirror object for regular expressions.
1030 * @param {RegExp} value The RegExp object reflected by this mirror 1030 * @param {RegExp} value The RegExp object reflected by this mirror
1031 * @constructor 1031 * @constructor
1032 * @extends ObjectMirror 1032 * @extends ObjectMirror
1033 */ 1033 */
1034 function RegExpMirror(value) { 1034 function RegExpMirror(value) {
1035 ObjectMirror.call(this, value, REGEXP_TYPE); 1035 ObjectMirror.call(this, value, REGEXP_TYPE);
1036 }; 1036 }
1037 inherits(RegExpMirror, ObjectMirror); 1037 inherits(RegExpMirror, ObjectMirror);
1038 1038
1039 1039
1040 /** 1040 /**
1041 * Returns the source to the regular expression. 1041 * Returns the source to the regular expression.
1042 * @return {string or undefined} The source to the regular expression 1042 * @return {string or undefined} The source to the regular expression
1043 */ 1043 */
1044 RegExpMirror.prototype.source = function() { 1044 RegExpMirror.prototype.source = function() {
1045 return this.value_.source; 1045 return this.value_.source;
1046 }; 1046 };
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 1091
1092 1092
1093 /** 1093 /**
1094 * Mirror object for error objects. 1094 * Mirror object for error objects.
1095 * @param {Error} value The error object reflected by this mirror 1095 * @param {Error} value The error object reflected by this mirror
1096 * @constructor 1096 * @constructor
1097 * @extends ObjectMirror 1097 * @extends ObjectMirror
1098 */ 1098 */
1099 function ErrorMirror(value) { 1099 function ErrorMirror(value) {
1100 ObjectMirror.call(this, value, ERROR_TYPE); 1100 ObjectMirror.call(this, value, ERROR_TYPE);
1101 }; 1101 }
1102 inherits(ErrorMirror, ObjectMirror); 1102 inherits(ErrorMirror, ObjectMirror);
1103 1103
1104 1104
1105 /** 1105 /**
1106 * Returns the message for this eror object. 1106 * Returns the message for this eror object.
1107 * @return {string or undefined} The message for this eror object 1107 * @return {string or undefined} The message for this eror object
1108 */ 1108 */
1109 ErrorMirror.prototype.message = function() { 1109 ErrorMirror.prototype.message = function() {
1110 return this.value_.message; 1110 return this.value_.message;
1111 }; 1111 };
(...skipping 26 matching lines...) Expand all
1138 * @param {Object} value The value of the property 1138 * @param {Object} value The value of the property
1139 * @constructor 1139 * @constructor
1140 * @extends Mirror 1140 * @extends Mirror
1141 */ 1141 */
1142 function PropertyMirror(mirror, name, value, details) { 1142 function PropertyMirror(mirror, name, value, details) {
1143 Mirror.call(this, PROPERTY_TYPE); 1143 Mirror.call(this, PROPERTY_TYPE);
1144 this.mirror_ = mirror; 1144 this.mirror_ = mirror;
1145 this.name_ = name; 1145 this.name_ = name;
1146 this.value_ = value; 1146 this.value_ = value;
1147 this.details_ = details; 1147 this.details_ = details;
1148 }; 1148 }
1149 inherits(PropertyMirror, Mirror); 1149 inherits(PropertyMirror, Mirror);
1150 1150
1151 1151
1152 PropertyMirror.prototype.isReadOnly = function() { 1152 PropertyMirror.prototype.isReadOnly = function() {
1153 return (this.attributes() & PropertyAttribute.ReadOnly) != 0; 1153 return (this.attributes() & PropertyAttribute.ReadOnly) != 0;
1154 } 1154 }
1155 1155
1156 1156
1157 PropertyMirror.prototype.isEnum = function() { 1157 PropertyMirror.prototype.isEnum = function() {
1158 return (this.attributes() & PropertyAttribute.DontEnum) == 0; 1158 return (this.attributes() & PropertyAttribute.DontEnum) == 0;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 /** 1221 /**
1222 * Mirror object for interceptor named properties. 1222 * Mirror object for interceptor named properties.
1223 * @param {ObjectMirror} mirror The mirror object having this property 1223 * @param {ObjectMirror} mirror The mirror object having this property
1224 * @param {String} name The name of the property 1224 * @param {String} name The name of the property
1225 * @param {value} value The value of the property 1225 * @param {value} value The value of the property
1226 * @constructor 1226 * @constructor
1227 * @extends PropertyMirror 1227 * @extends PropertyMirror
1228 */ 1228 */
1229 function InterceptorPropertyMirror(mirror, name, value) { 1229 function InterceptorPropertyMirror(mirror, name, value) {
1230 PropertyMirror.call(this, mirror, name, value, PropertyType.Interceptor); 1230 PropertyMirror.call(this, mirror, name, value, PropertyType.Interceptor);
1231 }; 1231 }
1232 inherits(InterceptorPropertyMirror, PropertyMirror); 1232 inherits(InterceptorPropertyMirror, PropertyMirror);
1233 1233
1234 1234
1235 /** 1235 /**
1236 * Mirror object for property accessors. 1236 * Mirror object for property accessors.
1237 * @param {Function} getter The getter function for this accessor 1237 * @param {Function} getter The getter function for this accessor
1238 * @param {Function} setter The setter function for this accessor 1238 * @param {Function} setter The setter function for this accessor
1239 * @constructor 1239 * @constructor
1240 * @extends Mirror 1240 * @extends Mirror
1241 */ 1241 */
1242 function AccessorMirror(getter, setter) { 1242 function AccessorMirror(getter, setter) {
1243 Mirror.call(this, ACCESSOR_TYPE); 1243 Mirror.call(this, ACCESSOR_TYPE);
1244 this.getter_ = getter; 1244 this.getter_ = getter;
1245 this.setter_ = setter; 1245 this.setter_ = setter;
1246 }; 1246 }
1247 inherits(AccessorMirror, Mirror); 1247 inherits(AccessorMirror, Mirror);
1248 1248
1249 1249
1250 /** 1250 /**
1251 * Returns whether this accessor is native or not. A native accessor is either 1251 * Returns whether this accessor is native or not. A native accessor is either
1252 * a VM buildin or provided through the API. A non native accessor is defined 1252 * a VM buildin or provided through the API. A non native accessor is defined
1253 * in JavaScript using the __defineGetter__ and/or __defineGetter__ functions. 1253 * in JavaScript using the __defineGetter__ and/or __defineGetter__ functions.
1254 * @return {boolean} True is the accessor is native 1254 * @return {boolean} True is the accessor is native
1255 */ 1255 */
1256 AccessorMirror.prototype.isNative = function() { 1256 AccessorMirror.prototype.isNative = function() {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 * 6: Construct call 1327 * 6: Construct call
1328 * Arguments name, value 1328 * Arguments name, value
1329 * Locals name, value 1329 * Locals name, value
1330 * @param {number} break_id Current break id 1330 * @param {number} break_id Current break id
1331 * @param {number} index Frame number 1331 * @param {number} index Frame number
1332 * @constructor 1332 * @constructor
1333 */ 1333 */
1334 function FrameDetails(break_id, index) { 1334 function FrameDetails(break_id, index) {
1335 this.break_id_ = break_id; 1335 this.break_id_ = break_id;
1336 this.details_ = %GetFrameDetails(break_id, index); 1336 this.details_ = %GetFrameDetails(break_id, index);
1337 }; 1337 }
1338 1338
1339 1339
1340 FrameDetails.prototype.frameId = function() { 1340 FrameDetails.prototype.frameId = function() {
1341 %CheckExecutionState(this.break_id_); 1341 %CheckExecutionState(this.break_id_);
1342 return this.details_[kFrameDetailsFrameIdIndex]; 1342 return this.details_[kFrameDetailsFrameIdIndex];
1343 } 1343 }
1344 1344
1345 1345
1346 FrameDetails.prototype.receiver = function() { 1346 FrameDetails.prototype.receiver = function() {
1347 %CheckExecutionState(this.break_id_); 1347 %CheckExecutionState(this.break_id_);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 valid 1433 valid
1434 * @param {number} index The frame index (top frame is index 0) 1434 * @param {number} index The frame index (top frame is index 0)
1435 * @constructor 1435 * @constructor
1436 * @extends Mirror 1436 * @extends Mirror
1437 */ 1437 */
1438 function FrameMirror(break_id, index) { 1438 function FrameMirror(break_id, index) {
1439 Mirror.call(this, FRAME_TYPE); 1439 Mirror.call(this, FRAME_TYPE);
1440 this.break_id_ = break_id; 1440 this.break_id_ = break_id;
1441 this.index_ = index; 1441 this.index_ = index;
1442 this.details_ = new FrameDetails(break_id, index); 1442 this.details_ = new FrameDetails(break_id, index);
1443 }; 1443 }
1444 inherits(FrameMirror, Mirror); 1444 inherits(FrameMirror, Mirror);
1445 1445
1446 1446
1447 FrameMirror.prototype.index = function() { 1447 FrameMirror.prototype.index = function() {
1448 return this.index_; 1448 return this.index_;
1449 }; 1449 };
1450 1450
1451 1451
1452 FrameMirror.prototype.func = function() { 1452 FrameMirror.prototype.func = function() {
1453 // Get the function for this frame from the VM. 1453 // Get the function for this frame from the VM.
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1634 result += property.name(); 1634 result += property.name();
1635 } else { 1635 } else {
1636 result += '['; 1636 result += '[';
1637 result += property.name(); 1637 result += property.name();
1638 result += ']'; 1638 result += ']';
1639 } 1639 }
1640 // Also known as - if the name in the function doesn't match the name 1640 // Also known as - if the name in the function doesn't match the name
1641 // under which it was looked up. 1641 // under which it was looked up.
1642 if (func.name() && func.name() != property.name()) { 1642 if (func.name() && func.name() != property.name()) {
1643 result += '(aka ' + func.name() + ')'; 1643 result += '(aka ' + func.name() + ')';
1644 } 1644 }
1645 } else { 1645 } else {
1646 // The function invoked was not found on the receiver. Use the function 1646 // The function invoked was not found on the receiver. Use the function
1647 // name if available for the backtrace. 1647 // name if available for the backtrace.
1648 if (display_receiver) { 1648 if (display_receiver) {
1649 result += '.'; 1649 result += '.';
1650 } 1650 }
1651 result += func.name() ? func.name() : '[anonymous]'; 1651 result += func.name() ? func.name() : '[anonymous]';
1652 } 1652 }
1653 } 1653 }
1654 1654
1655 // Render arguments for normal frames. 1655 // Render arguments for normal frames.
1656 if (!this.isDebuggerFrame()) { 1656 if (!this.isDebuggerFrame()) {
1657 result += '('; 1657 result += '(';
1658 for (var i = 0; i < this.argumentCount(); i++) { 1658 for (var i = 0; i < this.argumentCount(); i++) {
1659 if (i != 0) result += ', '; 1659 if (i != 0) result += ', ';
1660 if (this.argumentName(i)) { 1660 if (this.argumentName(i)) {
1661 result += this.argumentName(i); 1661 result += this.argumentName(i);
1662 result += '='; 1662 result += '=';
1663 } 1663 }
1664 result += this.argumentValue(i).toText(); 1664 result += this.argumentValue(i).toText();
1665 } 1665 }
1666 result += ')'; 1666 result += ')';
1667 } 1667 }
1668 1668
1669 return result; 1669 return result;
1670 } 1670 }
1671 1671
1672 1672
1673 FrameMirror.prototype.sourceAndPositionText = function() { 1673 FrameMirror.prototype.sourceAndPositionText = function() {
1674 // Format source and position. 1674 // Format source and position.
1675 var result = ''; 1675 var result = '';
1676 var func = this.func(); 1676 var func = this.func();
1677 if (func.resolved()) { 1677 if (func.resolved()) {
1678 if (func.script()) { 1678 if (func.script()) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1737 1737
1738 /** 1738 /**
1739 * Mirror object for script source. 1739 * Mirror object for script source.
1740 * @param {Script} script The script object 1740 * @param {Script} script The script object
1741 * @constructor 1741 * @constructor
1742 * @extends Mirror 1742 * @extends Mirror
1743 */ 1743 */
1744 function ScriptMirror(script) { 1744 function ScriptMirror(script) {
1745 Mirror.call(this, SCRIPT_TYPE); 1745 Mirror.call(this, SCRIPT_TYPE);
1746 this.script_ = script; 1746 this.script_ = script;
1747 }; 1747 }
1748 inherits(ScriptMirror, Mirror); 1748 inherits(ScriptMirror, Mirror);
1749 1749
1750 1750
1751 ScriptMirror.prototype.name = function() { 1751 ScriptMirror.prototype.name = function() {
1752 return this.script_.name; 1752 return this.script_.name;
1753 }; 1753 };
1754 1754
1755 1755
1756 ScriptMirror.prototype.lineOffset = function() { 1756 ScriptMirror.prototype.lineOffset = function() {
1757 return this.script_.line_offset; 1757 return this.script_.line_offset;
(...skipping 28 matching lines...) Expand all
1786 ScriptMirror.prototype.fillJSON_ = function(content, details) { 1786 ScriptMirror.prototype.fillJSON_ = function(content, details) {
1787 ScriptMirror.super_.fillJSONType_.call(this, content); 1787 ScriptMirror.super_.fillJSONType_.call(this, content);
1788 if (this.name()) { 1788 if (this.name()) {
1789 content.push(MakeJSONPair_('name', StringToJSON_(this.name()))); 1789 content.push(MakeJSONPair_('name', StringToJSON_(this.name())));
1790 } 1790 }
1791 content.push(MakeJSONPair_('lineOffset', NumberToJSON_(this.lineOffset()))); 1791 content.push(MakeJSONPair_('lineOffset', NumberToJSON_(this.lineOffset())));
1792 content.push(MakeJSONPair_('columnOffset', NumberToJSON_(this.columnOffset())) ); 1792 content.push(MakeJSONPair_('columnOffset', NumberToJSON_(this.columnOffset())) );
1793 content.push(MakeJSONPair_('lineCount', NumberToJSON_(this.lineCount()))); 1793 content.push(MakeJSONPair_('lineCount', NumberToJSON_(this.lineCount())));
1794 content.push(MakeJSONPair_('scriptType', NumberToJSON_(this.scriptType()))); 1794 content.push(MakeJSONPair_('scriptType', NumberToJSON_(this.scriptType())));
1795 } 1795 }
1796 1796
1797 1797
1798 ScriptMirror.prototype.toText = function() { 1798 ScriptMirror.prototype.toText = function() {
1799 var result = ''; 1799 var result = '';
1800 result += this.name(); 1800 result += this.name();
1801 result += ' (lines: '; 1801 result += ' (lines: ';
1802 if (this.lineOffset() > 0) { 1802 if (this.lineOffset() > 0) {
1803 result += this.lineOffset(); 1803 result += this.lineOffset();
1804 result += '-'; 1804 result += '-';
1805 result += this.lineOffset() + this.lineCount() - 1; 1805 result += this.lineOffset() + this.lineCount() - 1;
1806 } else { 1806 } else {
1807 result += this.lineCount(); 1807 result += this.lineCount();
1808 } 1808 }
1809 result += ')'; 1809 result += ')';
1810 return result; 1810 return result;
1811 } 1811 }
1812 1812
1813 1813
1814 function MakeJSONPair_(name, value) { 1814 function MakeJSONPair_(name, value) {
1815 return '"' + name + '":' + value; 1815 return '"' + name + '":' + value;
1816 }; 1816 }
1817 1817
1818 1818
1819 function ArrayToJSONObject_(content) { 1819 function ArrayToJSONObject_(content) {
1820 return '{' + content.join(',') + '}'; 1820 return '{' + content.join(',') + '}';
1821 }; 1821 }
1822 1822
1823 1823
1824 function ArrayToJSONArray_(content) { 1824 function ArrayToJSONArray_(content) {
1825 return '[' + content.join(',') + ']'; 1825 return '[' + content.join(',') + ']';
1826 }; 1826 }
1827 1827
1828 1828
1829 function BooleanToJSON_(value) { 1829 function BooleanToJSON_(value) {
1830 return String(value); 1830 return String(value);
1831 }; 1831 }
1832 1832
1833 1833
1834 function NumberToJSON_(value) { 1834 function NumberToJSON_(value) {
1835 return String(value); 1835 return String(value);
1836 }; 1836 }
1837 1837
1838 1838
1839 // Mapping of some control characters to avoid the \uXXXX syntax for most 1839 // Mapping of some control characters to avoid the \uXXXX syntax for most
1840 // commonly used control cahracters. 1840 // commonly used control cahracters.
1841 const ctrlCharMap_ = { 1841 const ctrlCharMap_ = {
1842 '\b': '\\b', 1842 '\b': '\\b',
1843 '\t': '\\t', 1843 '\t': '\\t',
1844 '\n': '\\n', 1844 '\n': '\\n',
1845 '\f': '\\f', 1845 '\f': '\\f',
1846 '\r': '\\r', 1846 '\r': '\\r',
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1879 // Convert control character to unicode escape sequence. 1879 // Convert control character to unicode escape sequence.
1880 return '\\u00' + 1880 return '\\u00' +
1881 %NumberToRadixString(Math.floor(mapped / 16), 16) + 1881 %NumberToRadixString(Math.floor(mapped / 16), 16) +
1882 %NumberToRadixString(mapped % 16, 16); 1882 %NumberToRadixString(mapped % 16, 16);
1883 }) 1883 })
1884 + '"'; 1884 + '"';
1885 } 1885 }
1886 1886
1887 // Simple string with no special characters. 1887 // Simple string with no special characters.
1888 return '"' + value + '"'; 1888 return '"' + value + '"';
1889 }; 1889 }
1890 1890
1891 1891
1892 /** 1892 /**
1893 * Convert a Date to ISO 8601 format. To avoid depending on the Date object 1893 * Convert a Date to ISO 8601 format. To avoid depending on the Date object
1894 * this method calls the functions in date.js directly and not through the 1894 * this method calls the functions in date.js directly and not through the
1895 * value. 1895 * value.
1896 * @param {Date} value The Date value to format as JSON 1896 * @param {Date} value The Date value to format as JSON
1897 * @return {string} JSON formatted Date value 1897 * @return {string} JSON formatted Date value
1898 */ 1898 */
1899 function DateToISO8601_(value) { 1899 function DateToISO8601_(value) {
1900 function f(n) { 1900 function f(n) {
1901 return n < 10 ? '0' + n : n; 1901 return n < 10 ? '0' + n : n;
1902 } 1902 }
1903 function g(n) { 1903 function g(n) {
1904 return n < 10 ? '00' + n : n < 100 ? '0' + n : n; 1904 return n < 10 ? '00' + n : n < 100 ? '0' + n : n;
1905 } 1905 }
1906 return builtins.GetUTCFullYearFrom(value) + '-' + 1906 return builtins.GetUTCFullYearFrom(value) + '-' +
1907 f(builtins.GetUTCMonthFrom(value) + 1) + '-' + 1907 f(builtins.GetUTCMonthFrom(value) + 1) + '-' +
1908 f(builtins.GetUTCDateFrom(value)) + 'T' + 1908 f(builtins.GetUTCDateFrom(value)) + 'T' +
1909 f(builtins.GetUTCHoursFrom(value)) + ':' + 1909 f(builtins.GetUTCHoursFrom(value)) + ':' +
1910 f(builtins.GetUTCMinutesFrom(value)) + ':' + 1910 f(builtins.GetUTCMinutesFrom(value)) + ':' +
1911 f(builtins.GetUTCSecondsFrom(value)) + '.' + 1911 f(builtins.GetUTCSecondsFrom(value)) + '.' +
1912 g(builtins.GetUTCMillisecondsFrom(value)) + 'Z'; 1912 g(builtins.GetUTCMillisecondsFrom(value)) + 'Z';
1913 }; 1913 }
1914 1914
1915 /** 1915 /**
1916 * Convert a Date to ISO 8601 format. To avoid depending on the Date object 1916 * Convert a Date to ISO 8601 format. To avoid depending on the Date object
1917 * this method calls the functions in date.js directly and not through the 1917 * this method calls the functions in date.js directly and not through the
1918 * value. 1918 * value.
1919 * @param {Date} value The Date value to format as JSON 1919 * @param {Date} value The Date value to format as JSON
1920 * @return {string} JSON formatted Date value 1920 * @return {string} JSON formatted Date value
1921 */ 1921 */
1922 function DateToJSON_(value) { 1922 function DateToJSON_(value) {
1923 return '"' + DateToISO8601_(value) + '"'; 1923 return '"' + DateToISO8601_(value) + '"';
1924 }; 1924 }
OLDNEW
« no previous file with comments | « src/messages.js ('k') | src/regexp-delay.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698