| 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 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 } | 45 } |
| 46 | 46 |
| 47 if (%_HasCachedArrayIndex(string) && | 47 if (%_HasCachedArrayIndex(string) && |
| 48 (radix == 0 || radix == 10)) { | 48 (radix == 0 || radix == 10)) { |
| 49 return %_GetCachedArrayIndex(string); | 49 return %_GetCachedArrayIndex(string); |
| 50 } | 50 } |
| 51 return %StringParseInt(string, radix); | 51 return %StringParseInt(string, radix); |
| 52 } | 52 } |
| 53 | 53 |
| 54 | 54 |
| 55 // ES6 18.2.4 parseFloat(string) | |
| 56 function GlobalParseFloat(string) { | |
| 57 // 1. Let inputString be ? ToString(string). | |
| 58 string = TO_STRING(string); | |
| 59 if (%_HasCachedArrayIndex(string)) return %_GetCachedArrayIndex(string); | |
| 60 return %StringParseFloat(string); | |
| 61 } | |
| 62 | |
| 63 | |
| 64 // ---------------------------------------------------------------------------- | 55 // ---------------------------------------------------------------------------- |
| 65 | 56 |
| 66 // Set up global object. | 57 // Set up global object. |
| 67 var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY; | 58 var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY; |
| 68 | 59 |
| 69 utils.InstallConstants(global, [ | 60 utils.InstallConstants(global, [ |
| 70 // ES6 18.1.1 | 61 // ES6 18.1.1 |
| 71 "Infinity", INFINITY, | 62 "Infinity", INFINITY, |
| 72 // ES6 18.1.2 | 63 // ES6 18.1.2 |
| 73 "NaN", NaN, | 64 "NaN", NaN, |
| 74 // ES6 18.1.3 | 65 // ES6 18.1.3 |
| 75 "undefined", UNDEFINED, | 66 "undefined", UNDEFINED, |
| 76 ]); | 67 ]); |
| 77 | 68 |
| 78 // Set up non-enumerable function on the global object. | 69 // Set up non-enumerable function on the global object. |
| 79 utils.InstallFunctions(global, DONT_ENUM, [ | 70 utils.InstallFunctions(global, DONT_ENUM, [ |
| 80 "parseInt", GlobalParseInt, | 71 "parseInt", GlobalParseInt, |
| 81 "parseFloat", GlobalParseFloat, | |
| 82 ]); | 72 ]); |
| 83 | 73 |
| 84 | 74 |
| 85 // ---------------------------------------------------------------------------- | 75 // ---------------------------------------------------------------------------- |
| 86 // Object | 76 // Object |
| 87 | 77 |
| 88 // ES6 19.1.3.5 Object.prototype.toLocaleString([reserved1 [,reserved2]]) | 78 // ES6 19.1.3.5 Object.prototype.toLocaleString([reserved1 [,reserved2]]) |
| 89 function ObjectToLocaleString() { | 79 function ObjectToLocaleString() { |
| 90 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.toLocaleString"); | 80 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.toLocaleString"); |
| 91 return this.toString(); | 81 return this.toString(); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 // --- Harmony constants (no spec refs until settled.) | 196 // --- Harmony constants (no spec refs until settled.) |
| 207 | 197 |
| 208 "MAX_SAFE_INTEGER", 9007199254740991, | 198 "MAX_SAFE_INTEGER", 9007199254740991, |
| 209 "MIN_SAFE_INTEGER", -9007199254740991, | 199 "MIN_SAFE_INTEGER", -9007199254740991, |
| 210 "EPSILON", 2.220446049250313e-16, | 200 "EPSILON", 2.220446049250313e-16, |
| 211 ]); | 201 ]); |
| 212 | 202 |
| 213 // Harmony Number constructor additions | 203 // Harmony Number constructor additions |
| 214 utils.InstallFunctions(GlobalNumber, DONT_ENUM, [ | 204 utils.InstallFunctions(GlobalNumber, DONT_ENUM, [ |
| 215 "parseInt", GlobalParseInt, | 205 "parseInt", GlobalParseInt, |
| 216 "parseFloat", GlobalParseFloat | |
| 217 ]); | 206 ]); |
| 218 | 207 |
| 219 | 208 |
| 220 | 209 |
| 221 // ---------------------------------------------------------------------------- | 210 // ---------------------------------------------------------------------------- |
| 222 // Iterator related spec functions. | 211 // Iterator related spec functions. |
| 223 | 212 |
| 224 // ES6 7.4.1 GetIterator(obj, method) | 213 // ES6 7.4.1 GetIterator(obj, method) |
| 225 function GetIterator(obj, method) { | 214 function GetIterator(obj, method) { |
| 226 if (IS_UNDEFINED(method)) { | 215 if (IS_UNDEFINED(method)) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 243 to.GetIterator = GetIterator; | 232 to.GetIterator = GetIterator; |
| 244 to.GetMethod = GetMethod; | 233 to.GetMethod = GetMethod; |
| 245 to.ObjectHasOwnProperty = GlobalObject.prototype.hasOwnProperty; | 234 to.ObjectHasOwnProperty = GlobalObject.prototype.hasOwnProperty; |
| 246 }); | 235 }); |
| 247 | 236 |
| 248 %InstallToContext([ | 237 %InstallToContext([ |
| 249 "object_value_of", ObjectValueOf, | 238 "object_value_of", ObjectValueOf, |
| 250 ]); | 239 ]); |
| 251 | 240 |
| 252 }) | 241 }) |
| OLD | NEW |