OLD | NEW |
---|---|
1 // Copyright 2006-2012 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | |
5 (function(global, utils) { | |
4 "use strict"; | 6 "use strict"; |
5 | 7 |
6 // Handle id counters. | 8 // ---------------------------------------------------------------------------- |
9 // Imports | |
10 | |
11 var GlobalArray = global.Array; | |
12 var IsNaN = global.isNaN; | |
13 var JSONStringify = global.JSON.stringify; | |
14 var MathMin = global.Math.min; | |
15 | |
16 // ---------------------------------------------------------------------------- | |
17 | |
18 // Mirror hierarchy: | |
19 // - Mirror | |
20 // - ValueMirror | |
Jakob Kummerow
2015/08/12 12:47:51
nit: meaningful indentation got lost here
| |
21 // - UndefinedMirror | |
22 // - NullMirror | |
23 // - BooleanMirror | |
24 // - NumberMirror | |
25 // - StringMirror | |
26 // - SymbolMirror | |
27 // - ObjectMirror | |
28 // - FunctionMirror | |
29 // - UnresolvedFunctionMirror | |
30 // - ArrayMirror | |
31 // - DateMirror | |
32 // - RegExpMirror | |
33 // - ErrorMirror | |
34 // - PromiseMirror | |
35 // - MapMirror | |
36 // - SetMirror | |
37 // - IteratorMirror | |
38 // - GeneratorMirror | |
39 // - PropertyMirror | |
40 // - InternalPropertyMirror | |
41 // - FrameMirror | |
42 // - ScriptMirror | |
43 // - ScopeMirror | |
44 | |
45 // Type names of the different mirrors. | |
46 var MirrorType = { | |
47 UNDEFINED_TYPE : 'undefined', | |
48 NULL_TYPE : 'null', | |
49 BOOLEAN_TYPE : 'boolean', | |
50 NUMBER_TYPE : 'number', | |
51 STRING_TYPE : 'string', | |
52 SYMBOL_TYPE : 'symbol', | |
53 OBJECT_TYPE : 'object', | |
54 FUNCTION_TYPE : 'function', | |
55 REGEXP_TYPE : 'regexp', | |
56 ERROR_TYPE : 'error', | |
57 PROPERTY_TYPE : 'property', | |
58 INTERNAL_PROPERTY_TYPE : 'internalProperty', | |
59 FRAME_TYPE : 'frame', | |
60 SCRIPT_TYPE : 'script', | |
61 CONTEXT_TYPE : 'context', | |
62 SCOPE_TYPE : 'scope', | |
63 PROMISE_TYPE : 'promise', | |
64 MAP_TYPE : 'map', | |
65 SET_TYPE : 'set', | |
66 ITERATOR_TYPE : 'iterator', | |
67 GENERATOR_TYPE : 'generator', | |
68 } | |
69 | |
70 | |
71 //Handle id counters. | |
Jakob Kummerow
2015/08/12 12:47:51
nit: space after //
| |
7 var next_handle_ = 0; | 72 var next_handle_ = 0; |
8 var next_transient_handle_ = -1; | 73 var next_transient_handle_ = -1; |
9 | 74 |
10 // Mirror cache. | 75 // Mirror cache. |
11 var mirror_cache_ = []; | 76 var mirror_cache_ = []; |
12 var mirror_cache_enabled_ = true; | 77 var mirror_cache_enabled_ = true; |
13 | 78 |
14 | 79 |
80 function MirrorCacheIsEmpty() { | |
81 return next_handle_ == 0 && mirror_cache_.length == 0; | |
82 } | |
83 | |
84 | |
15 function ToggleMirrorCache(value) { | 85 function ToggleMirrorCache(value) { |
16 mirror_cache_enabled_ = value; | 86 mirror_cache_enabled_ = value; |
87 ClearMirrorCache(); | |
88 } | |
89 | |
90 | |
91 function ClearMirrorCache(value) { | |
17 next_handle_ = 0; | 92 next_handle_ = 0; |
18 mirror_cache_ = []; | 93 mirror_cache_ = []; |
19 } | 94 } |
20 | 95 |
21 | 96 |
22 // Wrapper to check whether an object is a Promise. The call may not work | 97 // Wrapper to check whether an object is a Promise. The call may not work |
23 // if promises are not enabled. | 98 // if promises are not enabled. |
24 // TODO(yangguo): remove try-catch once promises are enabled by default. | 99 // TODO(yangguo): remove try-catch once promises are enabled by default. |
25 function ObjectIsPromise(value) { | 100 function ObjectIsPromise(value) { |
26 try { | 101 try { |
(...skipping 17 matching lines...) Expand all Loading... | |
44 var mirror; | 119 var mirror; |
45 | 120 |
46 // Look for non transient mirrors in the mirror cache. | 121 // Look for non transient mirrors in the mirror cache. |
47 if (!opt_transient && mirror_cache_enabled_) { | 122 if (!opt_transient && mirror_cache_enabled_) { |
48 for (var id in mirror_cache_) { | 123 for (var id in mirror_cache_) { |
49 mirror = mirror_cache_[id]; | 124 mirror = mirror_cache_[id]; |
50 if (mirror.value() === value) { | 125 if (mirror.value() === value) { |
51 return mirror; | 126 return mirror; |
52 } | 127 } |
53 // Special check for NaN as NaN == NaN is false. | 128 // Special check for NaN as NaN == NaN is false. |
54 if (mirror.isNumber() && isNaN(mirror.value()) && | 129 if (mirror.isNumber() && IsNaN(mirror.value()) && |
55 typeof value == 'number' && isNaN(value)) { | 130 typeof value == 'number' && IsNaN(value)) { |
56 return mirror; | 131 return mirror; |
57 } | 132 } |
58 } | 133 } |
59 } | 134 } |
60 | 135 |
61 if (IS_UNDEFINED(value)) { | 136 if (IS_UNDEFINED(value)) { |
62 mirror = new UndefinedMirror(); | 137 mirror = new UndefinedMirror(); |
63 } else if (IS_NULL(value)) { | 138 } else if (IS_NULL(value)) { |
64 mirror = new NullMirror(); | 139 mirror = new NullMirror(); |
65 } else if (IS_BOOLEAN(value)) { | 140 } else if (IS_BOOLEAN(value)) { |
(...skipping 20 matching lines...) Expand all Loading... | |
86 mirror = new MapMirror(value); | 161 mirror = new MapMirror(value); |
87 } else if (IS_SET(value) || IS_WEAKSET(value)) { | 162 } else if (IS_SET(value) || IS_WEAKSET(value)) { |
88 mirror = new SetMirror(value); | 163 mirror = new SetMirror(value); |
89 } else if (IS_MAP_ITERATOR(value) || IS_SET_ITERATOR(value)) { | 164 } else if (IS_MAP_ITERATOR(value) || IS_SET_ITERATOR(value)) { |
90 mirror = new IteratorMirror(value); | 165 mirror = new IteratorMirror(value); |
91 } else if (ObjectIsPromise(value)) { | 166 } else if (ObjectIsPromise(value)) { |
92 mirror = new PromiseMirror(value); | 167 mirror = new PromiseMirror(value); |
93 } else if (IS_GENERATOR(value)) { | 168 } else if (IS_GENERATOR(value)) { |
94 mirror = new GeneratorMirror(value); | 169 mirror = new GeneratorMirror(value); |
95 } else { | 170 } else { |
96 mirror = new ObjectMirror(value, OBJECT_TYPE, opt_transient); | 171 mirror = new ObjectMirror(value, MirrorType.OBJECT_TYPE, opt_transient); |
97 } | 172 } |
98 | 173 |
99 if (mirror_cache_enabled_) mirror_cache_[mirror.handle()] = mirror; | 174 if (mirror_cache_enabled_) mirror_cache_[mirror.handle()] = mirror; |
100 return mirror; | 175 return mirror; |
101 } | 176 } |
102 | 177 |
103 | 178 |
104 /** | 179 /** |
105 * Returns the mirror for a specified mirror handle. | 180 * Returns the mirror for a specified mirror handle. |
106 * | 181 * |
107 * @param {number} handle the handle to find the mirror for | 182 * @param {number} handle the handle to find the mirror for |
108 * @returns {Mirror or undefiend} the mirror with the requested handle or | 183 * @returns {Mirror or undefiend} the mirror with the requested handle or |
109 * undefined if no mirror with the requested handle was found | 184 * undefined if no mirror with the requested handle was found |
110 */ | 185 */ |
111 function LookupMirror(handle) { | 186 function LookupMirror(handle) { |
112 if (!mirror_cache_enabled_) throw new Error("Mirror cache is disabled"); | 187 if (!mirror_cache_enabled_) { |
188 throw MakeError(kDebugger, "Mirror cache is disabled"); | |
189 } | |
113 return mirror_cache_[handle]; | 190 return mirror_cache_[handle]; |
114 } | 191 } |
115 | 192 |
116 | 193 |
117 /** | 194 /** |
118 * Returns the mirror for the undefined value. | 195 * Returns the mirror for the undefined value. |
119 * | 196 * |
120 * @returns {Mirror} the mirror reflects the undefined value | 197 * @returns {Mirror} the mirror reflects the undefined value |
121 */ | 198 */ |
122 function GetUndefinedMirror() { | 199 function GetUndefinedMirror() { |
(...skipping 15 matching lines...) Expand all Loading... | |
138 * @param {function} superCtor Constructor function to inherit prototype from | 215 * @param {function} superCtor Constructor function to inherit prototype from |
139 */ | 216 */ |
140 function inherits(ctor, superCtor) { | 217 function inherits(ctor, superCtor) { |
141 var tempCtor = function(){}; | 218 var tempCtor = function(){}; |
142 tempCtor.prototype = superCtor.prototype; | 219 tempCtor.prototype = superCtor.prototype; |
143 ctor.super_ = superCtor.prototype; | 220 ctor.super_ = superCtor.prototype; |
144 ctor.prototype = new tempCtor(); | 221 ctor.prototype = new tempCtor(); |
145 ctor.prototype.constructor = ctor; | 222 ctor.prototype.constructor = ctor; |
146 } | 223 } |
147 | 224 |
148 | |
149 // Type names of the different mirrors. | |
150 var UNDEFINED_TYPE = 'undefined'; | |
151 var NULL_TYPE = 'null'; | |
152 var BOOLEAN_TYPE = 'boolean'; | |
153 var NUMBER_TYPE = 'number'; | |
154 var STRING_TYPE = 'string'; | |
155 var SYMBOL_TYPE = 'symbol'; | |
156 var OBJECT_TYPE = 'object'; | |
157 var FUNCTION_TYPE = 'function'; | |
158 var REGEXP_TYPE = 'regexp'; | |
159 var ERROR_TYPE = 'error'; | |
160 var PROPERTY_TYPE = 'property'; | |
161 var INTERNAL_PROPERTY_TYPE = 'internalProperty'; | |
162 var FRAME_TYPE = 'frame'; | |
163 var SCRIPT_TYPE = 'script'; | |
164 var CONTEXT_TYPE = 'context'; | |
165 var SCOPE_TYPE = 'scope'; | |
166 var PROMISE_TYPE = 'promise'; | |
167 var MAP_TYPE = 'map'; | |
168 var SET_TYPE = 'set'; | |
169 var ITERATOR_TYPE = 'iterator'; | |
170 var GENERATOR_TYPE = 'generator'; | |
171 | |
172 // Maximum length when sending strings through the JSON protocol. | 225 // Maximum length when sending strings through the JSON protocol. |
173 var kMaxProtocolStringLength = 80; | 226 var kMaxProtocolStringLength = 80; |
174 | 227 |
175 // Different kind of properties. | 228 // Different kind of properties. |
176 var PropertyKind = {}; | 229 var PropertyKind = {}; |
177 PropertyKind.Named = 1; | 230 PropertyKind.Named = 1; |
178 PropertyKind.Indexed = 2; | 231 PropertyKind.Indexed = 2; |
179 | 232 |
180 | 233 |
181 // A copy of the PropertyType enum from property-details.h | 234 // A copy of the PropertyType enum from property-details.h |
(...skipping 15 matching lines...) Expand all Loading... | |
197 // NOTE: these constants should be backward-compatible, so | 250 // NOTE: these constants should be backward-compatible, so |
198 // add new ones to the end of this list. | 251 // add new ones to the end of this list. |
199 var ScopeType = { Global: 0, | 252 var ScopeType = { Global: 0, |
200 Local: 1, | 253 Local: 1, |
201 With: 2, | 254 With: 2, |
202 Closure: 3, | 255 Closure: 3, |
203 Catch: 4, | 256 Catch: 4, |
204 Block: 5, | 257 Block: 5, |
205 Script: 6 }; | 258 Script: 6 }; |
206 | 259 |
207 | |
208 // Mirror hierarchy: | |
209 // - Mirror | |
210 // - ValueMirror | |
211 // - UndefinedMirror | |
212 // - NullMirror | |
213 // - NumberMirror | |
214 // - StringMirror | |
215 // - SymbolMirror | |
216 // - ObjectMirror | |
217 // - FunctionMirror | |
218 // - UnresolvedFunctionMirror | |
219 // - ArrayMirror | |
220 // - DateMirror | |
221 // - RegExpMirror | |
222 // - ErrorMirror | |
223 // - PromiseMirror | |
224 // - MapMirror | |
225 // - SetMirror | |
226 // - IteratorMirror | |
227 // - GeneratorMirror | |
228 // - PropertyMirror | |
229 // - InternalPropertyMirror | |
230 // - FrameMirror | |
231 // - ScriptMirror | |
232 | |
233 | |
234 /** | 260 /** |
235 * Base class for all mirror objects. | 261 * Base class for all mirror objects. |
236 * @param {string} type The type of the mirror | 262 * @param {string} type The type of the mirror |
237 * @constructor | 263 * @constructor |
238 */ | 264 */ |
239 function Mirror(type) { | 265 function Mirror(type) { |
240 this.type_ = type; | 266 this.type_ = type; |
241 } | 267 } |
242 | 268 |
243 | 269 |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
543 return this.value_; | 569 return this.value_; |
544 }; | 570 }; |
545 | 571 |
546 | 572 |
547 /** | 573 /** |
548 * Mirror object for Undefined. | 574 * Mirror object for Undefined. |
549 * @constructor | 575 * @constructor |
550 * @extends ValueMirror | 576 * @extends ValueMirror |
551 */ | 577 */ |
552 function UndefinedMirror() { | 578 function UndefinedMirror() { |
553 %_CallFunction(this, UNDEFINED_TYPE, UNDEFINED, ValueMirror); | 579 %_CallFunction(this, MirrorType.UNDEFINED_TYPE, UNDEFINED, ValueMirror); |
554 } | 580 } |
555 inherits(UndefinedMirror, ValueMirror); | 581 inherits(UndefinedMirror, ValueMirror); |
556 | 582 |
557 | 583 |
558 UndefinedMirror.prototype.toText = function() { | 584 UndefinedMirror.prototype.toText = function() { |
559 return 'undefined'; | 585 return 'undefined'; |
560 }; | 586 }; |
561 | 587 |
562 | 588 |
563 /** | 589 /** |
564 * Mirror object for null. | 590 * Mirror object for null. |
565 * @constructor | 591 * @constructor |
566 * @extends ValueMirror | 592 * @extends ValueMirror |
567 */ | 593 */ |
568 function NullMirror() { | 594 function NullMirror() { |
569 %_CallFunction(this, NULL_TYPE, null, ValueMirror); | 595 %_CallFunction(this, MirrorType.NULL_TYPE, null, ValueMirror); |
570 } | 596 } |
571 inherits(NullMirror, ValueMirror); | 597 inherits(NullMirror, ValueMirror); |
572 | 598 |
573 | 599 |
574 NullMirror.prototype.toText = function() { | 600 NullMirror.prototype.toText = function() { |
575 return 'null'; | 601 return 'null'; |
576 }; | 602 }; |
577 | 603 |
578 | 604 |
579 /** | 605 /** |
580 * Mirror object for boolean values. | 606 * Mirror object for boolean values. |
581 * @param {boolean} value The boolean value reflected by this mirror | 607 * @param {boolean} value The boolean value reflected by this mirror |
582 * @constructor | 608 * @constructor |
583 * @extends ValueMirror | 609 * @extends ValueMirror |
584 */ | 610 */ |
585 function BooleanMirror(value) { | 611 function BooleanMirror(value) { |
586 %_CallFunction(this, BOOLEAN_TYPE, value, ValueMirror); | 612 %_CallFunction(this, MirrorType.BOOLEAN_TYPE, value, ValueMirror); |
587 } | 613 } |
588 inherits(BooleanMirror, ValueMirror); | 614 inherits(BooleanMirror, ValueMirror); |
589 | 615 |
590 | 616 |
591 BooleanMirror.prototype.toText = function() { | 617 BooleanMirror.prototype.toText = function() { |
592 return this.value_ ? 'true' : 'false'; | 618 return this.value_ ? 'true' : 'false'; |
593 }; | 619 }; |
594 | 620 |
595 | 621 |
596 /** | 622 /** |
597 * Mirror object for number values. | 623 * Mirror object for number values. |
598 * @param {number} value The number value reflected by this mirror | 624 * @param {number} value The number value reflected by this mirror |
599 * @constructor | 625 * @constructor |
600 * @extends ValueMirror | 626 * @extends ValueMirror |
601 */ | 627 */ |
602 function NumberMirror(value) { | 628 function NumberMirror(value) { |
603 %_CallFunction(this, NUMBER_TYPE, value, ValueMirror); | 629 %_CallFunction(this, MirrorType.NUMBER_TYPE, value, ValueMirror); |
604 } | 630 } |
605 inherits(NumberMirror, ValueMirror); | 631 inherits(NumberMirror, ValueMirror); |
606 | 632 |
607 | 633 |
608 NumberMirror.prototype.toText = function() { | 634 NumberMirror.prototype.toText = function() { |
609 return %_NumberToString(this.value_); | 635 return %_NumberToString(this.value_); |
610 }; | 636 }; |
611 | 637 |
612 | 638 |
613 /** | 639 /** |
614 * Mirror object for string values. | 640 * Mirror object for string values. |
615 * @param {string} value The string value reflected by this mirror | 641 * @param {string} value The string value reflected by this mirror |
616 * @constructor | 642 * @constructor |
617 * @extends ValueMirror | 643 * @extends ValueMirror |
618 */ | 644 */ |
619 function StringMirror(value) { | 645 function StringMirror(value) { |
620 %_CallFunction(this, STRING_TYPE, value, ValueMirror); | 646 %_CallFunction(this, MirrorType.STRING_TYPE, value, ValueMirror); |
621 } | 647 } |
622 inherits(StringMirror, ValueMirror); | 648 inherits(StringMirror, ValueMirror); |
623 | 649 |
624 | 650 |
625 StringMirror.prototype.length = function() { | 651 StringMirror.prototype.length = function() { |
626 return this.value_.length; | 652 return this.value_.length; |
627 }; | 653 }; |
628 | 654 |
629 StringMirror.prototype.getTruncatedValue = function(maxLength) { | 655 StringMirror.prototype.getTruncatedValue = function(maxLength) { |
630 if (maxLength != -1 && this.length() > maxLength) { | 656 if (maxLength != -1 && this.length() > maxLength) { |
631 return this.value_.substring(0, maxLength) + | 657 return this.value_.substring(0, maxLength) + |
632 '... (length: ' + this.length() + ')'; | 658 '... (length: ' + this.length() + ')'; |
633 } | 659 } |
634 return this.value_; | 660 return this.value_; |
635 }; | 661 }; |
636 | 662 |
637 StringMirror.prototype.toText = function() { | 663 StringMirror.prototype.toText = function() { |
638 return this.getTruncatedValue(kMaxProtocolStringLength); | 664 return this.getTruncatedValue(kMaxProtocolStringLength); |
639 }; | 665 }; |
640 | 666 |
641 | 667 |
642 /** | 668 /** |
643 * Mirror object for a Symbol | 669 * Mirror object for a Symbol |
644 * @param {Object} value The Symbol | 670 * @param {Object} value The Symbol |
645 * @constructor | 671 * @constructor |
646 * @extends Mirror | 672 * @extends Mirror |
647 */ | 673 */ |
648 function SymbolMirror(value) { | 674 function SymbolMirror(value) { |
649 %_CallFunction(this, SYMBOL_TYPE, value, ValueMirror); | 675 %_CallFunction(this, MirrorType.SYMBOL_TYPE, value, ValueMirror); |
650 } | 676 } |
651 inherits(SymbolMirror, ValueMirror); | 677 inherits(SymbolMirror, ValueMirror); |
652 | 678 |
653 | 679 |
654 SymbolMirror.prototype.description = function() { | 680 SymbolMirror.prototype.description = function() { |
655 return %SymbolDescription(%_ValueOf(this.value_)); | 681 return %SymbolDescription(%_ValueOf(this.value_)); |
656 } | 682 } |
657 | 683 |
658 | 684 |
659 SymbolMirror.prototype.toText = function() { | 685 SymbolMirror.prototype.toText = function() { |
660 return %_CallFunction(this.value_, builtins.$symbolToString); | 686 return %_CallFunction(this.value_, builtins.$symbolToString); |
661 } | 687 } |
662 | 688 |
663 | 689 |
664 /** | 690 /** |
665 * Mirror object for objects. | 691 * Mirror object for objects. |
666 * @param {object} value The object reflected by this mirror | 692 * @param {object} value The object reflected by this mirror |
667 * @param {boolean} transient indicate whether this object is transient with a | 693 * @param {boolean} transient indicate whether this object is transient with a |
668 * transient handle | 694 * transient handle |
669 * @constructor | 695 * @constructor |
670 * @extends ValueMirror | 696 * @extends ValueMirror |
671 */ | 697 */ |
672 function ObjectMirror(value, type, transient) { | 698 function ObjectMirror(value, type, transient) { |
673 %_CallFunction(this, type || OBJECT_TYPE, value, transient, ValueMirror); | 699 type = type || MirrorType.OBJECT_TYPE; |
700 %_CallFunction(this, type, value, transient, ValueMirror); | |
674 } | 701 } |
675 inherits(ObjectMirror, ValueMirror); | 702 inherits(ObjectMirror, ValueMirror); |
676 | 703 |
677 | 704 |
678 ObjectMirror.prototype.className = function() { | 705 ObjectMirror.prototype.className = function() { |
679 return %_ClassOf(this.value_); | 706 return %_ClassOf(this.value_); |
680 }; | 707 }; |
681 | 708 |
682 | 709 |
683 ObjectMirror.prototype.constructorFunction = function() { | 710 ObjectMirror.prototype.constructorFunction = function() { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
763 // Get names for indexed interceptor properties. | 790 // Get names for indexed interceptor properties. |
764 if (this.hasIndexedInterceptor() && (kind & PropertyKind.Indexed)) { | 791 if (this.hasIndexedInterceptor() && (kind & PropertyKind.Indexed)) { |
765 var indexedInterceptorNames = | 792 var indexedInterceptorNames = |
766 %GetIndexedInterceptorElementNames(this.value_); | 793 %GetIndexedInterceptorElementNames(this.value_); |
767 if (indexedInterceptorNames) { | 794 if (indexedInterceptorNames) { |
768 elementNames = elementNames.concat(indexedInterceptorNames); | 795 elementNames = elementNames.concat(indexedInterceptorNames); |
769 total += indexedInterceptorNames.length; | 796 total += indexedInterceptorNames.length; |
770 } | 797 } |
771 } | 798 } |
772 } | 799 } |
773 limit = Math.min(limit || total, total); | 800 limit = MathMin(limit || total, total); |
774 | 801 |
775 var names = new Array(limit); | 802 var names = new GlobalArray(limit); |
776 var index = 0; | 803 var index = 0; |
777 | 804 |
778 // Copy names for named properties. | 805 // Copy names for named properties. |
779 if (kind & PropertyKind.Named) { | 806 if (kind & PropertyKind.Named) { |
780 for (var i = 0; index < limit && i < propertyNames.length; i++) { | 807 for (var i = 0; index < limit && i < propertyNames.length; i++) { |
781 names[index++] = propertyNames[i]; | 808 names[index++] = propertyNames[i]; |
782 } | 809 } |
783 } | 810 } |
784 | 811 |
785 // Copy names for indexed properties. | 812 // Copy names for indexed properties. |
(...skipping 10 matching lines...) Expand all Loading... | |
796 /** | 823 /** |
797 * Return the properties for this object as an array of PropertyMirror objects. | 824 * Return the properties for this object as an array of PropertyMirror objects. |
798 * @param {number} kind Indicate whether named, indexed or both kinds of | 825 * @param {number} kind Indicate whether named, indexed or both kinds of |
799 * properties are requested | 826 * properties are requested |
800 * @param {number} limit Limit the number of properties returned to the | 827 * @param {number} limit Limit the number of properties returned to the |
801 specified value | 828 specified value |
802 * @return {Array} Property mirrors for this object | 829 * @return {Array} Property mirrors for this object |
803 */ | 830 */ |
804 ObjectMirror.prototype.properties = function(kind, limit) { | 831 ObjectMirror.prototype.properties = function(kind, limit) { |
805 var names = this.propertyNames(kind, limit); | 832 var names = this.propertyNames(kind, limit); |
806 var properties = new Array(names.length); | 833 var properties = new GlobalArray(names.length); |
807 for (var i = 0; i < names.length; i++) { | 834 for (var i = 0; i < names.length; i++) { |
808 properties[i] = this.property(names[i]); | 835 properties[i] = this.property(names[i]); |
809 } | 836 } |
810 | 837 |
811 return properties; | 838 return properties; |
812 }; | 839 }; |
813 | 840 |
814 | 841 |
815 /** | 842 /** |
816 * Return the internal properties for this object as an array of | 843 * Return the internal properties for this object as an array of |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
913 } | 940 } |
914 | 941 |
915 | 942 |
916 /** | 943 /** |
917 * Mirror object for functions. | 944 * Mirror object for functions. |
918 * @param {function} value The function object reflected by this mirror. | 945 * @param {function} value The function object reflected by this mirror. |
919 * @constructor | 946 * @constructor |
920 * @extends ObjectMirror | 947 * @extends ObjectMirror |
921 */ | 948 */ |
922 function FunctionMirror(value) { | 949 function FunctionMirror(value) { |
923 %_CallFunction(this, value, FUNCTION_TYPE, ObjectMirror); | 950 %_CallFunction(this, value, MirrorType.FUNCTION_TYPE, ObjectMirror); |
924 this.resolved_ = true; | 951 this.resolved_ = true; |
925 } | 952 } |
926 inherits(FunctionMirror, ObjectMirror); | 953 inherits(FunctionMirror, ObjectMirror); |
927 | 954 |
928 | 955 |
929 /** | 956 /** |
930 * Returns whether the function is resolved. | 957 * Returns whether the function is resolved. |
931 * @return {boolean} True if the function is resolved. Unresolved functions can | 958 * @return {boolean} True if the function is resolved. Unresolved functions can |
932 * only originate as functions from stack frames | 959 * only originate as functions from stack frames |
933 */ | 960 */ |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1067 /** | 1094 /** |
1068 * Mirror object for unresolved functions. | 1095 * Mirror object for unresolved functions. |
1069 * @param {string} value The name for the unresolved function reflected by this | 1096 * @param {string} value The name for the unresolved function reflected by this |
1070 * mirror. | 1097 * mirror. |
1071 * @constructor | 1098 * @constructor |
1072 * @extends ObjectMirror | 1099 * @extends ObjectMirror |
1073 */ | 1100 */ |
1074 function UnresolvedFunctionMirror(value) { | 1101 function UnresolvedFunctionMirror(value) { |
1075 // Construct this using the ValueMirror as an unresolved function is not a | 1102 // Construct this using the ValueMirror as an unresolved function is not a |
1076 // real object but just a string. | 1103 // real object but just a string. |
1077 %_CallFunction(this, FUNCTION_TYPE, value, ValueMirror); | 1104 %_CallFunction(this, MirrorType.FUNCTION_TYPE, value, ValueMirror); |
1078 this.propertyCount_ = 0; | 1105 this.propertyCount_ = 0; |
1079 this.elementCount_ = 0; | 1106 this.elementCount_ = 0; |
1080 this.resolved_ = false; | 1107 this.resolved_ = false; |
1081 } | 1108 } |
1082 inherits(UnresolvedFunctionMirror, FunctionMirror); | 1109 inherits(UnresolvedFunctionMirror, FunctionMirror); |
1083 | 1110 |
1084 | 1111 |
1085 UnresolvedFunctionMirror.prototype.className = function() { | 1112 UnresolvedFunctionMirror.prototype.className = function() { |
1086 return 'Function'; | 1113 return 'Function'; |
1087 }; | 1114 }; |
(...skipping 13 matching lines...) Expand all Loading... | |
1101 return GetUndefinedMirror(); | 1128 return GetUndefinedMirror(); |
1102 }; | 1129 }; |
1103 | 1130 |
1104 | 1131 |
1105 UnresolvedFunctionMirror.prototype.name = function() { | 1132 UnresolvedFunctionMirror.prototype.name = function() { |
1106 return this.value_; | 1133 return this.value_; |
1107 }; | 1134 }; |
1108 | 1135 |
1109 | 1136 |
1110 UnresolvedFunctionMirror.prototype.inferredName = function() { | 1137 UnresolvedFunctionMirror.prototype.inferredName = function() { |
1111 return undefined; | 1138 return UNDEFINED; |
1112 }; | 1139 }; |
1113 | 1140 |
1114 | 1141 |
1115 UnresolvedFunctionMirror.prototype.propertyNames = function(kind, limit) { | 1142 UnresolvedFunctionMirror.prototype.propertyNames = function(kind, limit) { |
1116 return []; | 1143 return []; |
1117 }; | 1144 }; |
1118 | 1145 |
1119 | 1146 |
1120 /** | 1147 /** |
1121 * Mirror object for arrays. | 1148 * Mirror object for arrays. |
1122 * @param {Array} value The Array object reflected by this mirror | 1149 * @param {Array} value The Array object reflected by this mirror |
1123 * @constructor | 1150 * @constructor |
1124 * @extends ObjectMirror | 1151 * @extends ObjectMirror |
1125 */ | 1152 */ |
1126 function ArrayMirror(value) { | 1153 function ArrayMirror(value) { |
1127 %_CallFunction(this, value, ObjectMirror); | 1154 %_CallFunction(this, value, ObjectMirror); |
1128 } | 1155 } |
1129 inherits(ArrayMirror, ObjectMirror); | 1156 inherits(ArrayMirror, ObjectMirror); |
1130 | 1157 |
1131 | 1158 |
1132 ArrayMirror.prototype.length = function() { | 1159 ArrayMirror.prototype.length = function() { |
1133 return this.value_.length; | 1160 return this.value_.length; |
1134 }; | 1161 }; |
1135 | 1162 |
1136 | 1163 |
1137 ArrayMirror.prototype.indexedPropertiesFromRange = function(opt_from_index, | 1164 ArrayMirror.prototype.indexedPropertiesFromRange = function(opt_from_index, |
1138 opt_to_index) { | 1165 opt_to_index) { |
1139 var from_index = opt_from_index || 0; | 1166 var from_index = opt_from_index || 0; |
1140 var to_index = opt_to_index || this.length() - 1; | 1167 var to_index = opt_to_index || this.length() - 1; |
1141 if (from_index > to_index) return new Array(); | 1168 if (from_index > to_index) return new GlobalArray(); |
1142 var values = new Array(to_index - from_index + 1); | 1169 var values = new GlobalArray(to_index - from_index + 1); |
1143 for (var i = from_index; i <= to_index; i++) { | 1170 for (var i = from_index; i <= to_index; i++) { |
1144 var details = %DebugGetPropertyDetails(this.value_, builtins.$toString(i)); | 1171 var details = %DebugGetPropertyDetails(this.value_, builtins.$toString(i)); |
1145 var value; | 1172 var value; |
1146 if (details) { | 1173 if (details) { |
1147 value = new PropertyMirror(this, i, details); | 1174 value = new PropertyMirror(this, i, details); |
1148 } else { | 1175 } else { |
1149 value = GetUndefinedMirror(); | 1176 value = GetUndefinedMirror(); |
1150 } | 1177 } |
1151 values[i - from_index] = value; | 1178 values[i - from_index] = value; |
1152 } | 1179 } |
1153 return values; | 1180 return values; |
1154 }; | 1181 }; |
1155 | 1182 |
1156 | 1183 |
1157 /** | 1184 /** |
1158 * Mirror object for dates. | 1185 * Mirror object for dates. |
1159 * @param {Date} value The Date object reflected by this mirror | 1186 * @param {Date} value The Date object reflected by this mirror |
1160 * @constructor | 1187 * @constructor |
1161 * @extends ObjectMirror | 1188 * @extends ObjectMirror |
1162 */ | 1189 */ |
1163 function DateMirror(value) { | 1190 function DateMirror(value) { |
1164 %_CallFunction(this, value, ObjectMirror); | 1191 %_CallFunction(this, value, ObjectMirror); |
1165 } | 1192 } |
1166 inherits(DateMirror, ObjectMirror); | 1193 inherits(DateMirror, ObjectMirror); |
1167 | 1194 |
1168 | 1195 |
1169 DateMirror.prototype.toText = function() { | 1196 DateMirror.prototype.toText = function() { |
1170 var s = JSON.stringify(this.value_); | 1197 var s = JSONStringify(this.value_); |
1171 return s.substring(1, s.length - 1); // cut quotes | 1198 return s.substring(1, s.length - 1); // cut quotes |
1172 }; | 1199 }; |
1173 | 1200 |
1174 | 1201 |
1175 /** | 1202 /** |
1176 * Mirror object for regular expressions. | 1203 * Mirror object for regular expressions. |
1177 * @param {RegExp} value The RegExp object reflected by this mirror | 1204 * @param {RegExp} value The RegExp object reflected by this mirror |
1178 * @constructor | 1205 * @constructor |
1179 * @extends ObjectMirror | 1206 * @extends ObjectMirror |
1180 */ | 1207 */ |
1181 function RegExpMirror(value) { | 1208 function RegExpMirror(value) { |
1182 %_CallFunction(this, value, REGEXP_TYPE, ObjectMirror); | 1209 %_CallFunction(this, value, MirrorType.REGEXP_TYPE, ObjectMirror); |
1183 } | 1210 } |
1184 inherits(RegExpMirror, ObjectMirror); | 1211 inherits(RegExpMirror, ObjectMirror); |
1185 | 1212 |
1186 | 1213 |
1187 /** | 1214 /** |
1188 * Returns the source to the regular expression. | 1215 * Returns the source to the regular expression. |
1189 * @return {string or undefined} The source to the regular expression | 1216 * @return {string or undefined} The source to the regular expression |
1190 */ | 1217 */ |
1191 RegExpMirror.prototype.source = function() { | 1218 RegExpMirror.prototype.source = function() { |
1192 return this.value_.source; | 1219 return this.value_.source; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1244 }; | 1271 }; |
1245 | 1272 |
1246 | 1273 |
1247 /** | 1274 /** |
1248 * Mirror object for error objects. | 1275 * Mirror object for error objects. |
1249 * @param {Error} value The error object reflected by this mirror | 1276 * @param {Error} value The error object reflected by this mirror |
1250 * @constructor | 1277 * @constructor |
1251 * @extends ObjectMirror | 1278 * @extends ObjectMirror |
1252 */ | 1279 */ |
1253 function ErrorMirror(value) { | 1280 function ErrorMirror(value) { |
1254 %_CallFunction(this, value, ERROR_TYPE, ObjectMirror); | 1281 %_CallFunction(this, value, MirrorType.ERROR_TYPE, ObjectMirror); |
1255 } | 1282 } |
1256 inherits(ErrorMirror, ObjectMirror); | 1283 inherits(ErrorMirror, ObjectMirror); |
1257 | 1284 |
1258 | 1285 |
1259 /** | 1286 /** |
1260 * Returns the message for this eror object. | 1287 * Returns the message for this eror object. |
1261 * @return {string or undefined} The message for this eror object | 1288 * @return {string or undefined} The message for this eror object |
1262 */ | 1289 */ |
1263 ErrorMirror.prototype.message = function() { | 1290 ErrorMirror.prototype.message = function() { |
1264 return this.value_.message; | 1291 return this.value_.message; |
(...skipping 12 matching lines...) Expand all Loading... | |
1277 }; | 1304 }; |
1278 | 1305 |
1279 | 1306 |
1280 /** | 1307 /** |
1281 * Mirror object for a Promise object. | 1308 * Mirror object for a Promise object. |
1282 * @param {Object} value The Promise object | 1309 * @param {Object} value The Promise object |
1283 * @constructor | 1310 * @constructor |
1284 * @extends ObjectMirror | 1311 * @extends ObjectMirror |
1285 */ | 1312 */ |
1286 function PromiseMirror(value) { | 1313 function PromiseMirror(value) { |
1287 %_CallFunction(this, value, PROMISE_TYPE, ObjectMirror); | 1314 %_CallFunction(this, value, MirrorType.PROMISE_TYPE, ObjectMirror); |
1288 } | 1315 } |
1289 inherits(PromiseMirror, ObjectMirror); | 1316 inherits(PromiseMirror, ObjectMirror); |
1290 | 1317 |
1291 | 1318 |
1292 function PromiseGetStatus_(value) { | 1319 function PromiseGetStatus_(value) { |
1293 var status = %DebugGetProperty(value, builtins.$promiseStatus); | 1320 var status = %DebugGetProperty(value, builtins.$promiseStatus); |
1294 if (status == 0) return "pending"; | 1321 if (status == 0) return "pending"; |
1295 if (status == 1) return "resolved"; | 1322 if (status == 1) return "resolved"; |
1296 return "rejected"; | 1323 return "rejected"; |
1297 } | 1324 } |
1298 | 1325 |
1299 | 1326 |
1300 function PromiseGetValue_(value) { | 1327 function PromiseGetValue_(value) { |
1301 return %DebugGetProperty(value, builtins.$promiseValue); | 1328 return %DebugGetProperty(value, builtins.$promiseValue); |
1302 } | 1329 } |
1303 | 1330 |
1304 | 1331 |
1305 PromiseMirror.prototype.status = function() { | 1332 PromiseMirror.prototype.status = function() { |
1306 return PromiseGetStatus_(this.value_); | 1333 return PromiseGetStatus_(this.value_); |
1307 }; | 1334 }; |
1308 | 1335 |
1309 | 1336 |
1310 PromiseMirror.prototype.promiseValue = function() { | 1337 PromiseMirror.prototype.promiseValue = function() { |
1311 return MakeMirror(PromiseGetValue_(this.value_)); | 1338 return MakeMirror(PromiseGetValue_(this.value_)); |
1312 }; | 1339 }; |
1313 | 1340 |
1314 | 1341 |
1315 function MapMirror(value) { | 1342 function MapMirror(value) { |
1316 %_CallFunction(this, value, MAP_TYPE, ObjectMirror); | 1343 %_CallFunction(this, value, MirrorType.MAP_TYPE, ObjectMirror); |
1317 } | 1344 } |
1318 inherits(MapMirror, ObjectMirror); | 1345 inherits(MapMirror, ObjectMirror); |
1319 | 1346 |
1320 | 1347 |
1321 /** | 1348 /** |
1322 * Returns an array of key/value pairs of a map. | 1349 * Returns an array of key/value pairs of a map. |
1323 * This will keep keys alive for WeakMaps. | 1350 * This will keep keys alive for WeakMaps. |
1324 * | 1351 * |
1325 * @param {number=} opt_limit Max elements to return. | 1352 * @param {number=} opt_limit Max elements to return. |
1326 * @returns {Array.<Object>} Array of key/value pairs of a map. | 1353 * @returns {Array.<Object>} Array of key/value pairs of a map. |
(...skipping 19 matching lines...) Expand all Loading... | |
1346 result.push({ | 1373 result.push({ |
1347 key: next.value[0], | 1374 key: next.value[0], |
1348 value: next.value[1] | 1375 value: next.value[1] |
1349 }); | 1376 }); |
1350 } | 1377 } |
1351 return result; | 1378 return result; |
1352 }; | 1379 }; |
1353 | 1380 |
1354 | 1381 |
1355 function SetMirror(value) { | 1382 function SetMirror(value) { |
1356 %_CallFunction(this, value, SET_TYPE, ObjectMirror); | 1383 %_CallFunction(this, value, MirrorType.SET_TYPE, ObjectMirror); |
1357 } | 1384 } |
1358 inherits(SetMirror, ObjectMirror); | 1385 inherits(SetMirror, ObjectMirror); |
1359 | 1386 |
1360 | 1387 |
1361 function IteratorGetValues_(iter, next_function, opt_limit) { | 1388 function IteratorGetValues_(iter, next_function, opt_limit) { |
1362 var result = []; | 1389 var result = []; |
1363 var next; | 1390 var next; |
1364 while ((!opt_limit || result.length < opt_limit) && | 1391 while ((!opt_limit || result.length < opt_limit) && |
1365 !(next = %_CallFunction(iter, next_function)).done) { | 1392 !(next = %_CallFunction(iter, next_function)).done) { |
1366 result.push(next.value); | 1393 result.push(next.value); |
(...skipping 13 matching lines...) Expand all Loading... | |
1380 if (IS_WEAKSET(this.value_)) { | 1407 if (IS_WEAKSET(this.value_)) { |
1381 return %GetWeakSetValues(this.value_, opt_limit || 0); | 1408 return %GetWeakSetValues(this.value_, opt_limit || 0); |
1382 } | 1409 } |
1383 | 1410 |
1384 var iter = %_CallFunction(this.value_, builtins.$setValues); | 1411 var iter = %_CallFunction(this.value_, builtins.$setValues); |
1385 return IteratorGetValues_(iter, builtins.$setIteratorNext, opt_limit); | 1412 return IteratorGetValues_(iter, builtins.$setIteratorNext, opt_limit); |
1386 }; | 1413 }; |
1387 | 1414 |
1388 | 1415 |
1389 function IteratorMirror(value) { | 1416 function IteratorMirror(value) { |
1390 %_CallFunction(this, value, ITERATOR_TYPE, ObjectMirror); | 1417 %_CallFunction(this, value, MirrorType.ITERATOR_TYPE, ObjectMirror); |
1391 } | 1418 } |
1392 inherits(IteratorMirror, ObjectMirror); | 1419 inherits(IteratorMirror, ObjectMirror); |
1393 | 1420 |
1394 | 1421 |
1395 /** | 1422 /** |
1396 * Returns a preview of elements of an iterator. | 1423 * Returns a preview of elements of an iterator. |
1397 * Does not change the backing iterator state. | 1424 * Does not change the backing iterator state. |
1398 * | 1425 * |
1399 * @param {number=} opt_limit Max elements to return. | 1426 * @param {number=} opt_limit Max elements to return. |
1400 * @returns {Array.<Object>} Array of elements of an iterator. | 1427 * @returns {Array.<Object>} Array of elements of an iterator. |
(...skipping 11 matching lines...) Expand all Loading... | |
1412 }; | 1439 }; |
1413 | 1440 |
1414 | 1441 |
1415 /** | 1442 /** |
1416 * Mirror object for a Generator object. | 1443 * Mirror object for a Generator object. |
1417 * @param {Object} data The Generator object | 1444 * @param {Object} data The Generator object |
1418 * @constructor | 1445 * @constructor |
1419 * @extends Mirror | 1446 * @extends Mirror |
1420 */ | 1447 */ |
1421 function GeneratorMirror(value) { | 1448 function GeneratorMirror(value) { |
1422 %_CallFunction(this, value, GENERATOR_TYPE, ObjectMirror); | 1449 %_CallFunction(this, value, MirrorType.GENERATOR_TYPE, ObjectMirror); |
1423 } | 1450 } |
1424 inherits(GeneratorMirror, ObjectMirror); | 1451 inherits(GeneratorMirror, ObjectMirror); |
1425 | 1452 |
1426 | 1453 |
1427 function GeneratorGetStatus_(value) { | 1454 function GeneratorGetStatus_(value) { |
1428 var continuation = %GeneratorGetContinuation(value); | 1455 var continuation = %GeneratorGetContinuation(value); |
1429 if (continuation < 0) return "running"; | 1456 if (continuation < 0) return "running"; |
1430 if (continuation == 0) return "closed"; | 1457 if (continuation == 0) return "closed"; |
1431 return "suspended"; | 1458 return "suspended"; |
1432 } | 1459 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1479 | 1506 |
1480 /** | 1507 /** |
1481 * Base mirror object for properties. | 1508 * Base mirror object for properties. |
1482 * @param {ObjectMirror} mirror The mirror object having this property | 1509 * @param {ObjectMirror} mirror The mirror object having this property |
1483 * @param {string} name The name of the property | 1510 * @param {string} name The name of the property |
1484 * @param {Array} details Details about the property | 1511 * @param {Array} details Details about the property |
1485 * @constructor | 1512 * @constructor |
1486 * @extends Mirror | 1513 * @extends Mirror |
1487 */ | 1514 */ |
1488 function PropertyMirror(mirror, name, details) { | 1515 function PropertyMirror(mirror, name, details) { |
1489 %_CallFunction(this, PROPERTY_TYPE, Mirror); | 1516 %_CallFunction(this, MirrorType.PROPERTY_TYPE, Mirror); |
1490 this.mirror_ = mirror; | 1517 this.mirror_ = mirror; |
1491 this.name_ = name; | 1518 this.name_ = name; |
1492 this.value_ = details[0]; | 1519 this.value_ = details[0]; |
1493 this.details_ = details[1]; | 1520 this.details_ = details[1]; |
1494 this.is_interceptor_ = details[2]; | 1521 this.is_interceptor_ = details[2]; |
1495 if (details.length > 3) { | 1522 if (details.length > 3) { |
1496 this.exception_ = details[3]; | 1523 this.exception_ = details[3]; |
1497 this.getter_ = details[4]; | 1524 this.getter_ = details[4]; |
1498 this.setter_ = details[5]; | 1525 this.setter_ = details[5]; |
1499 } | 1526 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1622 /** | 1649 /** |
1623 * Mirror object for internal properties. Internal property reflects properties | 1650 * Mirror object for internal properties. Internal property reflects properties |
1624 * not accessible from user code such as [[BoundThis]] in bound function. | 1651 * not accessible from user code such as [[BoundThis]] in bound function. |
1625 * Their names are merely symbolic. | 1652 * Their names are merely symbolic. |
1626 * @param {string} name The name of the property | 1653 * @param {string} name The name of the property |
1627 * @param {value} property value | 1654 * @param {value} property value |
1628 * @constructor | 1655 * @constructor |
1629 * @extends Mirror | 1656 * @extends Mirror |
1630 */ | 1657 */ |
1631 function InternalPropertyMirror(name, value) { | 1658 function InternalPropertyMirror(name, value) { |
1632 %_CallFunction(this, INTERNAL_PROPERTY_TYPE, Mirror); | 1659 %_CallFunction(this, MirrorType.INTERNAL_PROPERTY_TYPE, Mirror); |
1633 this.name_ = name; | 1660 this.name_ = name; |
1634 this.value_ = value; | 1661 this.value_ = value; |
1635 } | 1662 } |
1636 inherits(InternalPropertyMirror, Mirror); | 1663 inherits(InternalPropertyMirror, Mirror); |
1637 | 1664 |
1638 | 1665 |
1639 InternalPropertyMirror.prototype.name = function() { | 1666 InternalPropertyMirror.prototype.name = function() { |
1640 return this.name_; | 1667 return this.name_; |
1641 }; | 1668 }; |
1642 | 1669 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1835 | 1862 |
1836 /** | 1863 /** |
1837 * Mirror object for stack frames. | 1864 * Mirror object for stack frames. |
1838 * @param {number} break_id The break id in the VM for which this frame is | 1865 * @param {number} break_id The break id in the VM for which this frame is |
1839 valid | 1866 valid |
1840 * @param {number} index The frame index (top frame is index 0) | 1867 * @param {number} index The frame index (top frame is index 0) |
1841 * @constructor | 1868 * @constructor |
1842 * @extends Mirror | 1869 * @extends Mirror |
1843 */ | 1870 */ |
1844 function FrameMirror(break_id, index) { | 1871 function FrameMirror(break_id, index) { |
1845 %_CallFunction(this, FRAME_TYPE, Mirror); | 1872 %_CallFunction(this, MirrorType.FRAME_TYPE, Mirror); |
1846 this.break_id_ = break_id; | 1873 this.break_id_ = break_id; |
1847 this.index_ = index; | 1874 this.index_ = index; |
1848 this.details_ = new FrameDetails(break_id, index); | 1875 this.details_ = new FrameDetails(break_id, index); |
1849 } | 1876 } |
1850 inherits(FrameMirror, Mirror); | 1877 inherits(FrameMirror, Mirror); |
1851 | 1878 |
1852 | 1879 |
1853 FrameMirror.prototype.details = function() { | 1880 FrameMirror.prototype.details = function() { |
1854 return this.details_; | 1881 return this.details_; |
1855 }; | 1882 }; |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2034 return result; | 2061 return result; |
2035 }; | 2062 }; |
2036 | 2063 |
2037 | 2064 |
2038 FrameMirror.prototype.evaluate = function(source, disable_break, | 2065 FrameMirror.prototype.evaluate = function(source, disable_break, |
2039 opt_context_object) { | 2066 opt_context_object) { |
2040 return MakeMirror(%DebugEvaluate(this.break_id_, | 2067 return MakeMirror(%DebugEvaluate(this.break_id_, |
2041 this.details_.frameId(), | 2068 this.details_.frameId(), |
2042 this.details_.inlinedFrameIndex(), | 2069 this.details_.inlinedFrameIndex(), |
2043 source, | 2070 source, |
2044 Boolean(disable_break), | 2071 $toBoolean(disable_break), |
2045 opt_context_object)); | 2072 opt_context_object)); |
2046 }; | 2073 }; |
2047 | 2074 |
2048 | 2075 |
2049 FrameMirror.prototype.invocationText = function() { | 2076 FrameMirror.prototype.invocationText = function() { |
2050 // Format frame invoaction (receiver, function and arguments). | 2077 // Format frame invoaction (receiver, function and arguments). |
2051 var result = ''; | 2078 var result = ''; |
2052 var func = this.func(); | 2079 var func = this.func(); |
2053 var receiver = this.receiver(); | 2080 var receiver = this.receiver(); |
2054 if (this.isConstructCall()) { | 2081 if (this.isConstructCall()) { |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2209 this.details_ = opt_details || | 2236 this.details_ = opt_details || |
2210 %GetScopeDetails(frame.break_id_, | 2237 %GetScopeDetails(frame.break_id_, |
2211 frame.details_.frameId(), | 2238 frame.details_.frameId(), |
2212 frame.details_.inlinedFrameIndex(), | 2239 frame.details_.inlinedFrameIndex(), |
2213 index); | 2240 index); |
2214 this.frame_id_ = frame.details_.frameId(); | 2241 this.frame_id_ = frame.details_.frameId(); |
2215 this.inlined_frame_id_ = frame.details_.inlinedFrameIndex(); | 2242 this.inlined_frame_id_ = frame.details_.inlinedFrameIndex(); |
2216 } else { | 2243 } else { |
2217 this.details_ = opt_details || %GetFunctionScopeDetails(fun.value(), index); | 2244 this.details_ = opt_details || %GetFunctionScopeDetails(fun.value(), index); |
2218 this.fun_value_ = fun.value(); | 2245 this.fun_value_ = fun.value(); |
2219 this.break_id_ = undefined; | 2246 this.break_id_ = UNDEFINED; |
2220 } | 2247 } |
2221 this.index_ = index; | 2248 this.index_ = index; |
2222 } | 2249 } |
2223 | 2250 |
2224 | 2251 |
2225 ScopeDetails.prototype.type = function() { | 2252 ScopeDetails.prototype.type = function() { |
2226 if (!IS_UNDEFINED(this.break_id_)) { | 2253 if (!IS_UNDEFINED(this.break_id_)) { |
2227 %CheckExecutionState(this.break_id_); | 2254 %CheckExecutionState(this.break_id_); |
2228 } | 2255 } |
2229 return this.details_[kScopeDetailsTypeIndex]; | 2256 return this.details_[kScopeDetailsTypeIndex]; |
(...skipping 11 matching lines...) Expand all Loading... | |
2241 ScopeDetails.prototype.setVariableValueImpl = function(name, new_value) { | 2268 ScopeDetails.prototype.setVariableValueImpl = function(name, new_value) { |
2242 var raw_res; | 2269 var raw_res; |
2243 if (!IS_UNDEFINED(this.break_id_)) { | 2270 if (!IS_UNDEFINED(this.break_id_)) { |
2244 %CheckExecutionState(this.break_id_); | 2271 %CheckExecutionState(this.break_id_); |
2245 raw_res = %SetScopeVariableValue(this.break_id_, this.frame_id_, | 2272 raw_res = %SetScopeVariableValue(this.break_id_, this.frame_id_, |
2246 this.inlined_frame_id_, this.index_, name, new_value); | 2273 this.inlined_frame_id_, this.index_, name, new_value); |
2247 } else { | 2274 } else { |
2248 raw_res = %SetScopeVariableValue(this.fun_value_, null, null, this.index_, | 2275 raw_res = %SetScopeVariableValue(this.fun_value_, null, null, this.index_, |
2249 name, new_value); | 2276 name, new_value); |
2250 } | 2277 } |
2251 if (!raw_res) { | 2278 if (!raw_res) throw MakeError(kDebugger, "Failed to set variable value"); |
2252 throw new Error("Failed to set variable value"); | |
2253 } | |
2254 }; | 2279 }; |
2255 | 2280 |
2256 | 2281 |
2257 /** | 2282 /** |
2258 * Mirror object for scope of frame or function. Either frame or function must | 2283 * Mirror object for scope of frame or function. Either frame or function must |
2259 * be specified. | 2284 * be specified. |
2260 * @param {FrameMirror} frame The frame this scope is a part of | 2285 * @param {FrameMirror} frame The frame this scope is a part of |
2261 * @param {FunctionMirror} function The function this scope is a part of | 2286 * @param {FunctionMirror} function The function this scope is a part of |
2262 * @param {number} index The scope index in the frame | 2287 * @param {number} index The scope index in the frame |
2263 * @param {Array=} opt_details Raw scope details data | 2288 * @param {Array=} opt_details Raw scope details data |
2264 * @constructor | 2289 * @constructor |
2265 * @extends Mirror | 2290 * @extends Mirror |
2266 */ | 2291 */ |
2267 function ScopeMirror(frame, function, index, opt_details) { | 2292 function ScopeMirror(frame, fun, index, opt_details) { |
2268 %_CallFunction(this, SCOPE_TYPE, Mirror); | 2293 %_CallFunction(this, MirrorType.SCOPE_TYPE, Mirror); |
2269 if (frame) { | 2294 if (frame) { |
2270 this.frame_index_ = frame.index_; | 2295 this.frame_index_ = frame.index_; |
2271 } else { | 2296 } else { |
2272 this.frame_index_ = undefined; | 2297 this.frame_index_ = UNDEFINED; |
2273 } | 2298 } |
2274 this.scope_index_ = index; | 2299 this.scope_index_ = index; |
2275 this.details_ = new ScopeDetails(frame, function, index, opt_details); | 2300 this.details_ = new ScopeDetails(frame, fun, index, opt_details); |
2276 } | 2301 } |
2277 inherits(ScopeMirror, Mirror); | 2302 inherits(ScopeMirror, Mirror); |
2278 | 2303 |
2279 | 2304 |
2280 ScopeMirror.prototype.details = function() { | 2305 ScopeMirror.prototype.details = function() { |
2281 return this.details_; | 2306 return this.details_; |
2282 }; | 2307 }; |
2283 | 2308 |
2284 | 2309 |
2285 ScopeMirror.prototype.frameIndex = function() { | 2310 ScopeMirror.prototype.frameIndex = function() { |
(...skipping 27 matching lines...) Expand all Loading... | |
2313 }; | 2338 }; |
2314 | 2339 |
2315 | 2340 |
2316 /** | 2341 /** |
2317 * Mirror object for script source. | 2342 * Mirror object for script source. |
2318 * @param {Script} script The script object | 2343 * @param {Script} script The script object |
2319 * @constructor | 2344 * @constructor |
2320 * @extends Mirror | 2345 * @extends Mirror |
2321 */ | 2346 */ |
2322 function ScriptMirror(script) { | 2347 function ScriptMirror(script) { |
2323 %_CallFunction(this, SCRIPT_TYPE, Mirror); | 2348 %_CallFunction(this, MirrorType.SCRIPT_TYPE, Mirror); |
2324 this.script_ = script; | 2349 this.script_ = script; |
2325 this.context_ = new ContextMirror(script.context_data); | 2350 this.context_ = new ContextMirror(script.context_data); |
2326 this.allocateHandle_(); | 2351 this.allocateHandle_(); |
2327 } | 2352 } |
2328 inherits(ScriptMirror, Mirror); | 2353 inherits(ScriptMirror, Mirror); |
2329 | 2354 |
2330 | 2355 |
2331 ScriptMirror.prototype.value = function() { | 2356 ScriptMirror.prototype.value = function() { |
2332 return this.script_; | 2357 return this.script_; |
2333 }; | 2358 }; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2434 }; | 2459 }; |
2435 | 2460 |
2436 | 2461 |
2437 /** | 2462 /** |
2438 * Mirror object for context. | 2463 * Mirror object for context. |
2439 * @param {Object} data The context data | 2464 * @param {Object} data The context data |
2440 * @constructor | 2465 * @constructor |
2441 * @extends Mirror | 2466 * @extends Mirror |
2442 */ | 2467 */ |
2443 function ContextMirror(data) { | 2468 function ContextMirror(data) { |
2444 %_CallFunction(this, CONTEXT_TYPE, Mirror); | 2469 %_CallFunction(this, MirrorType.CONTEXT_TYPE, Mirror); |
2445 this.data_ = data; | 2470 this.data_ = data; |
2446 this.allocateHandle_(); | 2471 this.allocateHandle_(); |
2447 } | 2472 } |
2448 inherits(ContextMirror, Mirror); | 2473 inherits(ContextMirror, Mirror); |
2449 | 2474 |
2450 | 2475 |
2451 ContextMirror.prototype.data = function() { | 2476 ContextMirror.prototype.data = function() { |
2452 return this.data_; | 2477 return this.data_; |
2453 }; | 2478 }; |
2454 | 2479 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2564 * be used to display the value in debugger. | 2589 * be used to display the value in debugger. |
2565 * @param {Mirror} mirror Mirror to serialize. | 2590 * @param {Mirror} mirror Mirror to serialize. |
2566 * @return {Object} Protocol reference object. | 2591 * @return {Object} Protocol reference object. |
2567 */ | 2592 */ |
2568 JSONProtocolSerializer.prototype.serializeReferenceWithDisplayData_ = | 2593 JSONProtocolSerializer.prototype.serializeReferenceWithDisplayData_ = |
2569 function(mirror) { | 2594 function(mirror) { |
2570 var o = {}; | 2595 var o = {}; |
2571 o.ref = mirror.handle(); | 2596 o.ref = mirror.handle(); |
2572 o.type = mirror.type(); | 2597 o.type = mirror.type(); |
2573 switch (mirror.type()) { | 2598 switch (mirror.type()) { |
2574 case UNDEFINED_TYPE: | 2599 case MirrorType.UNDEFINED_TYPE: |
2575 case NULL_TYPE: | 2600 case MirrorType.NULL_TYPE: |
2576 case BOOLEAN_TYPE: | 2601 case MirrorType.BOOLEAN_TYPE: |
2577 case NUMBER_TYPE: | 2602 case MirrorType.NUMBER_TYPE: |
2578 o.value = mirror.value(); | 2603 o.value = mirror.value(); |
2579 break; | 2604 break; |
2580 case STRING_TYPE: | 2605 case MirrorType.STRING_TYPE: |
2581 o.value = mirror.getTruncatedValue(this.maxStringLength_()); | 2606 o.value = mirror.getTruncatedValue(this.maxStringLength_()); |
2582 break; | 2607 break; |
2583 case SYMBOL_TYPE: | 2608 case MirrorType.SYMBOL_TYPE: |
2584 o.description = mirror.description(); | 2609 o.description = mirror.description(); |
2585 break; | 2610 break; |
2586 case FUNCTION_TYPE: | 2611 case MirrorType.FUNCTION_TYPE: |
2587 o.name = mirror.name(); | 2612 o.name = mirror.name(); |
2588 o.inferredName = mirror.inferredName(); | 2613 o.inferredName = mirror.inferredName(); |
2589 if (mirror.script()) { | 2614 if (mirror.script()) { |
2590 o.scriptId = mirror.script().id(); | 2615 o.scriptId = mirror.script().id(); |
2591 } | 2616 } |
2592 break; | 2617 break; |
2593 case ERROR_TYPE: | 2618 case MirrorType.ERROR_TYPE: |
2594 case REGEXP_TYPE: | 2619 case MirrorType.REGEXP_TYPE: |
2595 o.value = mirror.toText(); | 2620 o.value = mirror.toText(); |
2596 break; | 2621 break; |
2597 case OBJECT_TYPE: | 2622 case MirrorType.OBJECT_TYPE: |
2598 o.className = mirror.className(); | 2623 o.className = mirror.className(); |
2599 break; | 2624 break; |
2600 } | 2625 } |
2601 return o; | 2626 return o; |
2602 }; | 2627 }; |
2603 | 2628 |
2604 | 2629 |
2605 JSONProtocolSerializer.prototype.serialize_ = function(mirror, reference, | 2630 JSONProtocolSerializer.prototype.serialize_ = function(mirror, reference, |
2606 details) { | 2631 details) { |
2607 // If serializing a reference to a mirror just return the reference and add | 2632 // If serializing a reference to a mirror just return the reference and add |
(...skipping 13 matching lines...) Expand all Loading... | |
2621 | 2646 |
2622 // Add the mirror handle. | 2647 // Add the mirror handle. |
2623 if (mirror.isValue() || mirror.isScript() || mirror.isContext()) { | 2648 if (mirror.isValue() || mirror.isScript() || mirror.isContext()) { |
2624 content.handle = mirror.handle(); | 2649 content.handle = mirror.handle(); |
2625 } | 2650 } |
2626 | 2651 |
2627 // Always add the type. | 2652 // Always add the type. |
2628 content.type = mirror.type(); | 2653 content.type = mirror.type(); |
2629 | 2654 |
2630 switch (mirror.type()) { | 2655 switch (mirror.type()) { |
2631 case UNDEFINED_TYPE: | 2656 case MirrorType.UNDEFINED_TYPE: |
2632 case NULL_TYPE: | 2657 case MirrorType.NULL_TYPE: |
2633 // Undefined and null are represented just by their type. | 2658 // Undefined and null are represented just by their type. |
2634 break; | 2659 break; |
2635 | 2660 |
2636 case BOOLEAN_TYPE: | 2661 case MirrorType.BOOLEAN_TYPE: |
2637 // Boolean values are simply represented by their value. | 2662 // Boolean values are simply represented by their value. |
2638 content.value = mirror.value(); | 2663 content.value = mirror.value(); |
2639 break; | 2664 break; |
2640 | 2665 |
2641 case NUMBER_TYPE: | 2666 case MirrorType.NUMBER_TYPE: |
2642 // Number values are simply represented by their value. | 2667 // Number values are simply represented by their value. |
2643 content.value = NumberToJSON_(mirror.value()); | 2668 content.value = NumberToJSON_(mirror.value()); |
2644 break; | 2669 break; |
2645 | 2670 |
2646 case STRING_TYPE: | 2671 case MirrorType.STRING_TYPE: |
2647 // String values might have their value cropped to keep down size. | 2672 // String values might have their value cropped to keep down size. |
2648 if (this.maxStringLength_() != -1 && | 2673 if (this.maxStringLength_() != -1 && |
2649 mirror.length() > this.maxStringLength_()) { | 2674 mirror.length() > this.maxStringLength_()) { |
2650 var str = mirror.getTruncatedValue(this.maxStringLength_()); | 2675 var str = mirror.getTruncatedValue(this.maxStringLength_()); |
2651 content.value = str; | 2676 content.value = str; |
2652 content.fromIndex = 0; | 2677 content.fromIndex = 0; |
2653 content.toIndex = this.maxStringLength_(); | 2678 content.toIndex = this.maxStringLength_(); |
2654 } else { | 2679 } else { |
2655 content.value = mirror.value(); | 2680 content.value = mirror.value(); |
2656 } | 2681 } |
2657 content.length = mirror.length(); | 2682 content.length = mirror.length(); |
2658 break; | 2683 break; |
2659 | 2684 |
2660 case SYMBOL_TYPE: | 2685 case MirrorType.SYMBOL_TYPE: |
2661 content.description = mirror.description(); | 2686 content.description = mirror.description(); |
2662 break; | 2687 break; |
2663 | 2688 |
2664 case OBJECT_TYPE: | 2689 case MirrorType.OBJECT_TYPE: |
2665 case FUNCTION_TYPE: | 2690 case MirrorType.FUNCTION_TYPE: |
2666 case ERROR_TYPE: | 2691 case MirrorType.ERROR_TYPE: |
2667 case REGEXP_TYPE: | 2692 case MirrorType.REGEXP_TYPE: |
2668 case PROMISE_TYPE: | 2693 case MirrorType.PROMISE_TYPE: |
2669 case GENERATOR_TYPE: | 2694 case MirrorType.GENERATOR_TYPE: |
2670 // Add object representation. | 2695 // Add object representation. |
2671 this.serializeObject_(mirror, content, details); | 2696 this.serializeObject_(mirror, content, details); |
2672 break; | 2697 break; |
2673 | 2698 |
2674 case PROPERTY_TYPE: | 2699 case MirrorType.PROPERTY_TYPE: |
2675 case INTERNAL_PROPERTY_TYPE: | 2700 case MirrorType.INTERNAL_PROPERTY_TYPE: |
2676 throw new Error('PropertyMirror cannot be serialized independently'); | 2701 throw MakeError(kDebugger, |
2702 'PropertyMirror cannot be serialized independently'); | |
2677 break; | 2703 break; |
2678 | 2704 |
2679 case FRAME_TYPE: | 2705 case MirrorType.FRAME_TYPE: |
2680 // Add object representation. | 2706 // Add object representation. |
2681 this.serializeFrame_(mirror, content); | 2707 this.serializeFrame_(mirror, content); |
2682 break; | 2708 break; |
2683 | 2709 |
2684 case SCOPE_TYPE: | 2710 case MirrorType.SCOPE_TYPE: |
2685 // Add object representation. | 2711 // Add object representation. |
2686 this.serializeScope_(mirror, content); | 2712 this.serializeScope_(mirror, content); |
2687 break; | 2713 break; |
2688 | 2714 |
2689 case SCRIPT_TYPE: | 2715 case MirrorType.SCRIPT_TYPE: |
2690 // Script is represented by id, name and source attributes. | 2716 // Script is represented by id, name and source attributes. |
2691 if (mirror.name()) { | 2717 if (mirror.name()) { |
2692 content.name = mirror.name(); | 2718 content.name = mirror.name(); |
2693 } | 2719 } |
2694 content.id = mirror.id(); | 2720 content.id = mirror.id(); |
2695 content.lineOffset = mirror.lineOffset(); | 2721 content.lineOffset = mirror.lineOffset(); |
2696 content.columnOffset = mirror.columnOffset(); | 2722 content.columnOffset = mirror.columnOffset(); |
2697 content.lineCount = mirror.lineCount(); | 2723 content.lineCount = mirror.lineCount(); |
2698 if (mirror.data()) { | 2724 if (mirror.data()) { |
2699 content.data = mirror.data(); | 2725 content.data = mirror.data(); |
(...skipping 20 matching lines...) Expand all Loading... | |
2720 } | 2746 } |
2721 if (mirror.evalFromFunctionName()) { | 2747 if (mirror.evalFromFunctionName()) { |
2722 content.evalFromFunctionName = mirror.evalFromFunctionName(); | 2748 content.evalFromFunctionName = mirror.evalFromFunctionName(); |
2723 } | 2749 } |
2724 } | 2750 } |
2725 if (mirror.context()) { | 2751 if (mirror.context()) { |
2726 content.context = this.serializeReference(mirror.context()); | 2752 content.context = this.serializeReference(mirror.context()); |
2727 } | 2753 } |
2728 break; | 2754 break; |
2729 | 2755 |
2730 case CONTEXT_TYPE: | 2756 case MirrorType.CONTEXT_TYPE: |
2731 content.data = mirror.data(); | 2757 content.data = mirror.data(); |
2732 break; | 2758 break; |
2733 } | 2759 } |
2734 | 2760 |
2735 // Always add the text representation. | 2761 // Always add the text representation. |
2736 content.text = mirror.toText(); | 2762 content.text = mirror.toText(); |
2737 | 2763 |
2738 // Create and return the JSON string. | 2764 // Create and return the JSON string. |
2739 return content; | 2765 return content; |
2740 }; | 2766 }; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2818 | 2844 |
2819 if (mirror.isPromise()) { | 2845 if (mirror.isPromise()) { |
2820 // Add promise specific properties. | 2846 // Add promise specific properties. |
2821 content.status = mirror.status(); | 2847 content.status = mirror.status(); |
2822 content.promiseValue = this.serializeReference(mirror.promiseValue()); | 2848 content.promiseValue = this.serializeReference(mirror.promiseValue()); |
2823 } | 2849 } |
2824 | 2850 |
2825 // Add actual properties - named properties followed by indexed properties. | 2851 // Add actual properties - named properties followed by indexed properties. |
2826 var propertyNames = mirror.propertyNames(PropertyKind.Named); | 2852 var propertyNames = mirror.propertyNames(PropertyKind.Named); |
2827 var propertyIndexes = mirror.propertyNames(PropertyKind.Indexed); | 2853 var propertyIndexes = mirror.propertyNames(PropertyKind.Indexed); |
2828 var p = new Array(propertyNames.length + propertyIndexes.length); | 2854 var p = new GlobalArray(propertyNames.length + propertyIndexes.length); |
2829 for (var i = 0; i < propertyNames.length; i++) { | 2855 for (var i = 0; i < propertyNames.length; i++) { |
2830 var propertyMirror = mirror.property(propertyNames[i]); | 2856 var propertyMirror = mirror.property(propertyNames[i]); |
2831 p[i] = this.serializeProperty_(propertyMirror); | 2857 p[i] = this.serializeProperty_(propertyMirror); |
2832 if (details) { | 2858 if (details) { |
2833 this.add_(propertyMirror.value()); | 2859 this.add_(propertyMirror.value()); |
2834 } | 2860 } |
2835 } | 2861 } |
2836 for (var i = 0; i < propertyIndexes.length; i++) { | 2862 for (var i = 0; i < propertyIndexes.length; i++) { |
2837 var propertyMirror = mirror.property(propertyIndexes[i]); | 2863 var propertyMirror = mirror.property(propertyIndexes[i]); |
2838 p[propertyNames.length + i] = this.serializeProperty_(propertyMirror); | 2864 p[propertyNames.length + i] = this.serializeProperty_(propertyMirror); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2949 var script = func.script(); | 2975 var script = func.script(); |
2950 if (script) { | 2976 if (script) { |
2951 content.script = this.serializeReference(script); | 2977 content.script = this.serializeReference(script); |
2952 } | 2978 } |
2953 content.constructCall = mirror.isConstructCall(); | 2979 content.constructCall = mirror.isConstructCall(); |
2954 content.atReturn = mirror.isAtReturn(); | 2980 content.atReturn = mirror.isAtReturn(); |
2955 if (mirror.isAtReturn()) { | 2981 if (mirror.isAtReturn()) { |
2956 content.returnValue = this.serializeReference(mirror.returnValue()); | 2982 content.returnValue = this.serializeReference(mirror.returnValue()); |
2957 } | 2983 } |
2958 content.debuggerFrame = mirror.isDebuggerFrame(); | 2984 content.debuggerFrame = mirror.isDebuggerFrame(); |
2959 var x = new Array(mirror.argumentCount()); | 2985 var x = new GlobalArray(mirror.argumentCount()); |
2960 for (var i = 0; i < mirror.argumentCount(); i++) { | 2986 for (var i = 0; i < mirror.argumentCount(); i++) { |
2961 var arg = {}; | 2987 var arg = {}; |
2962 var argument_name = mirror.argumentName(i); | 2988 var argument_name = mirror.argumentName(i); |
2963 if (argument_name) { | 2989 if (argument_name) { |
2964 arg.name = argument_name; | 2990 arg.name = argument_name; |
2965 } | 2991 } |
2966 arg.value = this.serializeReference(mirror.argumentValue(i)); | 2992 arg.value = this.serializeReference(mirror.argumentValue(i)); |
2967 x[i] = arg; | 2993 x[i] = arg; |
2968 } | 2994 } |
2969 content.arguments = x; | 2995 content.arguments = x; |
2970 var x = new Array(mirror.localCount()); | 2996 var x = new GlobalArray(mirror.localCount()); |
2971 for (var i = 0; i < mirror.localCount(); i++) { | 2997 for (var i = 0; i < mirror.localCount(); i++) { |
2972 var local = {}; | 2998 var local = {}; |
2973 local.name = mirror.localName(i); | 2999 local.name = mirror.localName(i); |
2974 local.value = this.serializeReference(mirror.localValue(i)); | 3000 local.value = this.serializeReference(mirror.localValue(i)); |
2975 x[i] = local; | 3001 x[i] = local; |
2976 } | 3002 } |
2977 content.locals = x; | 3003 content.locals = x; |
2978 serializeLocationFields(mirror.sourceLocation(), content); | 3004 serializeLocationFields(mirror.sourceLocation(), content); |
2979 var source_line_text = mirror.sourceLineText(); | 3005 var source_line_text = mirror.sourceLineText(); |
2980 if (!IS_UNDEFINED(source_line_text)) { | 3006 if (!IS_UNDEFINED(source_line_text)) { |
(...skipping 24 matching lines...) Expand all Loading... | |
3005 /** | 3031 /** |
3006 * Convert a number to a protocol value. For all finite numbers the number | 3032 * Convert a number to a protocol value. For all finite numbers the number |
3007 * itself is returned. For non finite numbers NaN, Infinite and | 3033 * itself is returned. For non finite numbers NaN, Infinite and |
3008 * -Infinite the string representation "NaN", "Infinite" or "-Infinite" | 3034 * -Infinite the string representation "NaN", "Infinite" or "-Infinite" |
3009 * (not including the quotes) is returned. | 3035 * (not including the quotes) is returned. |
3010 * | 3036 * |
3011 * @param {number} value The number value to convert to a protocol value. | 3037 * @param {number} value The number value to convert to a protocol value. |
3012 * @returns {number|string} Protocol value. | 3038 * @returns {number|string} Protocol value. |
3013 */ | 3039 */ |
3014 function NumberToJSON_(value) { | 3040 function NumberToJSON_(value) { |
3015 if (isNaN(value)) { | 3041 if (IsNaN(value)) { |
3016 return 'NaN'; | 3042 return 'NaN'; |
3017 } | 3043 } |
3018 if (!NUMBER_IS_FINITE(value)) { | 3044 if (!NUMBER_IS_FINITE(value)) { |
3019 if (value > 0) { | 3045 if (value > 0) { |
3020 return 'Infinity'; | 3046 return 'Infinity'; |
3021 } else { | 3047 } else { |
3022 return '-Infinity'; | 3048 return '-Infinity'; |
3023 } | 3049 } |
3024 } | 3050 } |
3025 return value; | 3051 return value; |
3026 } | 3052 } |
3053 | |
3054 // ---------------------------------------------------------------------------- | |
3055 // Exports | |
3056 | |
3057 %AddNamedProperty(global, "MakeMirror", MakeMirror, DONT_ENUM); | |
Jakob Kummerow
2015/08/12 12:47:51
is there a specific reason to use %AddNamedPropert
| |
3058 %AddNamedProperty(global, "MakeMirrorSerializer", MakeMirrorSerializer, | |
3059 DONT_ENUM); | |
3060 %AddNamedProperty(global, "LookupMirror", LookupMirror, DONT_ENUM); | |
3061 %AddNamedProperty(global, "ToggleMirrorCache", ToggleMirrorCache, DONT_ENUM); | |
3062 %AddNamedProperty(global, "MirrorCacheIsEmpty", MirrorCacheIsEmpty, DONT_ENUM); | |
3063 | |
3064 %AddNamedProperty(global, "Mirror", Mirror, DONT_ENUM); | |
3065 %AddNamedProperty(global, "ValueMirror", ValueMirror, DONT_ENUM); | |
3066 %AddNamedProperty(global, "UndefinedMirror", UndefinedMirror, DONT_ENUM); | |
3067 %AddNamedProperty(global, "NullMirror", NullMirror, DONT_ENUM); | |
3068 %AddNamedProperty(global, "BooleanMirror", BooleanMirror, DONT_ENUM); | |
3069 %AddNamedProperty(global, "NumberMirror", NumberMirror, DONT_ENUM); | |
3070 %AddNamedProperty(global, "StringMirror", StringMirror, DONT_ENUM); | |
3071 %AddNamedProperty(global, "SymbolMirror", SymbolMirror, DONT_ENUM); | |
3072 %AddNamedProperty(global, "ObjectMirror", ObjectMirror, DONT_ENUM); | |
3073 %AddNamedProperty(global, "FunctionMirror", FunctionMirror, DONT_ENUM); | |
3074 %AddNamedProperty(global, "UnresolvedFunctionMirror", UnresolvedFunctionMirror, | |
3075 DONT_ENUM); | |
3076 %AddNamedProperty(global, "ArrayMirror", ArrayMirror, DONT_ENUM); | |
3077 %AddNamedProperty(global, "DateMirror", DateMirror, DONT_ENUM); | |
3078 %AddNamedProperty(global, "RegExpMirror", RegExpMirror, DONT_ENUM); | |
3079 %AddNamedProperty(global, "ErrorMirror", ErrorMirror, DONT_ENUM); | |
3080 %AddNamedProperty(global, "PromiseMirror", PromiseMirror, DONT_ENUM); | |
3081 %AddNamedProperty(global, "MapMirror", MapMirror, DONT_ENUM); | |
3082 %AddNamedProperty(global, "SetMirror", SetMirror, DONT_ENUM); | |
3083 %AddNamedProperty(global, "IteratorMirror", IteratorMirror, DONT_ENUM); | |
3084 %AddNamedProperty(global, "GeneratorMirror", GeneratorMirror, DONT_ENUM); | |
3085 %AddNamedProperty(global, "PropertyMirror", PropertyMirror, DONT_ENUM); | |
3086 %AddNamedProperty(global, "InternalPropertyMirror", InternalPropertyMirror, | |
3087 DONT_ENUM); | |
3088 %AddNamedProperty(global, "FrameMirror", FrameMirror, DONT_ENUM); | |
3089 %AddNamedProperty(global, "ScriptMirror", ScriptMirror, DONT_ENUM); | |
3090 %AddNamedProperty(global, "ScopeMirror", ScopeMirror, DONT_ENUM); | |
3091 %AddNamedProperty(global, "FrameDetails", FrameDetails, DONT_ENUM); | |
3092 | |
3093 %AddNamedProperty(global, "ScopeType", ScopeType, DONT_ENUM); | |
3094 %AddNamedProperty(global, "PropertyKind", PropertyKind, DONT_ENUM); | |
3095 %AddNamedProperty(global, "PropertyType", PropertyType, DONT_ENUM); | |
3096 %AddNamedProperty(global, "PropertyAttribute", PropertyAttribute, DONT_ENUM); | |
3097 | |
3098 // Functions needed by the debugger runtime. | |
3099 %AddNamedProperty(utils, "ClearMirrorCache", ClearMirrorCache, DONT_ENUM); | |
3100 | |
3101 // Export to debug.js | |
3102 utils.Export(function(to) { | |
3103 to.MirrorType = MirrorType; | |
3104 }); | |
3105 }) | |
OLD | NEW |