OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 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 | 4 |
5 (function(global, utils) { | 5 (function(global, utils) { |
6 | 6 |
7 %CheckIsBootstrapping(); | 7 %CheckIsBootstrapping(); |
8 | 8 |
9 // ---------------------------------------------------------------------------- | 9 // ---------------------------------------------------------------------------- |
10 // Imports | 10 // Imports |
11 | 11 |
12 var GlobalNumber = global.Number; | |
13 var GlobalObject = global.Object; | 12 var GlobalObject = global.Object; |
14 var iteratorSymbol = utils.ImportNow("iterator_symbol"); | 13 var iteratorSymbol = utils.ImportNow("iterator_symbol"); |
15 var NaN = %GetRootNaN(); | 14 var NaN = %GetRootNaN(); |
16 var ObjectToString = utils.ImportNow("object_to_string"); | 15 var ObjectToString = utils.ImportNow("object_to_string"); |
17 | 16 |
18 // ---------------------------------------------------------------------------- | 17 // ---------------------------------------------------------------------------- |
19 | 18 |
20 | 19 |
21 // Set up global object. | 20 // Set up global object. |
22 var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY; | 21 var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY; |
23 | 22 |
24 utils.InstallConstants(global, [ | |
25 // ES6 18.1.1 | |
26 "Infinity", INFINITY, | |
27 // ES6 18.1.2 | |
28 "NaN", NaN, | |
29 // ES6 18.1.3 | |
30 "undefined", UNDEFINED, | |
31 ]); | |
32 | |
33 | 23 |
34 // ---------------------------------------------------------------------------- | 24 // ---------------------------------------------------------------------------- |
35 // Object | 25 // Object |
36 | 26 |
37 // ES6 19.1.3.5 Object.prototype.toLocaleString([reserved1 [,reserved2]]) | 27 // ES6 19.1.3.5 Object.prototype.toLocaleString([reserved1 [,reserved2]]) |
38 function ObjectToLocaleString() { | 28 function ObjectToLocaleString() { |
39 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.toLocaleString"); | 29 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.toLocaleString"); |
40 return this.toString(); | 30 return this.toString(); |
41 } | 31 } |
42 | 32 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 "isPrototypeOf", ObjectIsPrototypeOf, | 80 "isPrototypeOf", ObjectIsPrototypeOf, |
91 // propertyIsEnumerable is added in bootstrapper.cc. | 81 // propertyIsEnumerable is added in bootstrapper.cc. |
92 // __defineGetter__ is added in bootstrapper.cc. | 82 // __defineGetter__ is added in bootstrapper.cc. |
93 // __lookupGetter__ is added in bootstrapper.cc. | 83 // __lookupGetter__ is added in bootstrapper.cc. |
94 // __defineSetter__ is added in bootstrapper.cc. | 84 // __defineSetter__ is added in bootstrapper.cc. |
95 // __lookupSetter__ is added in bootstrapper.cc. | 85 // __lookupSetter__ is added in bootstrapper.cc. |
96 ]); | 86 ]); |
97 | 87 |
98 | 88 |
99 // ---------------------------------------------------------------------------- | 89 // ---------------------------------------------------------------------------- |
100 // Number | |
101 | |
102 utils.InstallConstants(GlobalNumber, [ | |
103 // ECMA-262 section 15.7.3.1. | |
104 "MAX_VALUE", 1.7976931348623157e+308, | |
105 // ECMA-262 section 15.7.3.2. | |
106 "MIN_VALUE", 5e-324, | |
107 // ECMA-262 section 15.7.3.3. | |
108 "NaN", NaN, | |
109 // ECMA-262 section 15.7.3.4. | |
110 "NEGATIVE_INFINITY", -INFINITY, | |
111 // ECMA-262 section 15.7.3.5. | |
112 "POSITIVE_INFINITY", INFINITY, | |
113 | |
114 // --- Harmony constants (no spec refs until settled.) | |
115 | |
116 "MAX_SAFE_INTEGER", 9007199254740991, | |
117 "MIN_SAFE_INTEGER", -9007199254740991, | |
118 "EPSILON", 2.220446049250313e-16, | |
119 ]); | |
120 | |
121 | |
122 // ---------------------------------------------------------------------------- | |
123 // Iterator related spec functions. | 90 // Iterator related spec functions. |
124 | 91 |
125 // ES6 7.4.1 GetIterator(obj, method) | 92 // ES6 7.4.1 GetIterator(obj, method) |
126 function GetIterator(obj, method) { | 93 function GetIterator(obj, method) { |
127 if (IS_UNDEFINED(method)) { | 94 if (IS_UNDEFINED(method)) { |
128 method = obj[iteratorSymbol]; | 95 method = obj[iteratorSymbol]; |
129 } | 96 } |
130 if (!IS_CALLABLE(method)) { | 97 if (!IS_CALLABLE(method)) { |
131 throw %make_type_error(kNotIterable, obj); | 98 throw %make_type_error(kNotIterable, obj); |
132 } | 99 } |
(...skipping 11 matching lines...) Expand all Loading... |
144 to.GetIterator = GetIterator; | 111 to.GetIterator = GetIterator; |
145 to.GetMethod = GetMethod; | 112 to.GetMethod = GetMethod; |
146 to.ObjectHasOwnProperty = GlobalObject.prototype.hasOwnProperty; | 113 to.ObjectHasOwnProperty = GlobalObject.prototype.hasOwnProperty; |
147 }); | 114 }); |
148 | 115 |
149 %InstallToContext([ | 116 %InstallToContext([ |
150 "object_value_of", ObjectValueOf, | 117 "object_value_of", ObjectValueOf, |
151 ]); | 118 ]); |
152 | 119 |
153 }) | 120 }) |
OLD | NEW |