| 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 GlobalArray = global.Array; | 12 var GlobalArray = global.Array; |
| 13 var GlobalBoolean = global.Boolean; | |
| 14 var GlobalNumber = global.Number; | 13 var GlobalNumber = global.Number; |
| 15 var GlobalObject = global.Object; | 14 var GlobalObject = global.Object; |
| 16 var InternalArray = utils.InternalArray; | 15 var InternalArray = utils.InternalArray; |
| 17 var iteratorSymbol = utils.ImportNow("iterator_symbol"); | 16 var iteratorSymbol = utils.ImportNow("iterator_symbol"); |
| 18 var MakeRangeError; | 17 var MakeRangeError; |
| 19 var MakeSyntaxError; | 18 var MakeSyntaxError; |
| 20 var MakeTypeError; | 19 var MakeTypeError; |
| 21 var MathAbs; | 20 var MathAbs; |
| 22 var NaN = %GetRootNaN(); | 21 var NaN = %GetRootNaN(); |
| 23 var ObjectToString = utils.ImportNow("object_to_string"); | 22 var ObjectToString = utils.ImportNow("object_to_string"); |
| (...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 "defineProperties", ObjectDefineProperties, | 870 "defineProperties", ObjectDefineProperties, |
| 872 "getPrototypeOf", ObjectGetPrototypeOf, | 871 "getPrototypeOf", ObjectGetPrototypeOf, |
| 873 "setPrototypeOf", ObjectSetPrototypeOf, | 872 "setPrototypeOf", ObjectSetPrototypeOf, |
| 874 // getOwnPropertySymbols is added in symbol.js. | 873 // getOwnPropertySymbols is added in symbol.js. |
| 875 "is", SameValue, // ECMA-262, Edition 6, section 19.1.2.10 | 874 "is", SameValue, // ECMA-262, Edition 6, section 19.1.2.10 |
| 876 // deliverChangeRecords, getNotifier, observe and unobserve are added | 875 // deliverChangeRecords, getNotifier, observe and unobserve are added |
| 877 // in object-observe.js. | 876 // in object-observe.js. |
| 878 ]); | 877 ]); |
| 879 | 878 |
| 880 | 879 |
| 881 // ---------------------------------------------------------------------------- | |
| 882 // Boolean | |
| 883 | |
| 884 function BooleanToString() { | |
| 885 // NOTE: Both Boolean objects and values can enter here as | |
| 886 // 'this'. This is not as dictated by ECMA-262. | |
| 887 var b = this; | |
| 888 if (!IS_BOOLEAN(b)) { | |
| 889 if (!IS_BOOLEAN_WRAPPER(b)) { | |
| 890 throw MakeTypeError(kNotGeneric, 'Boolean.prototype.toString'); | |
| 891 } | |
| 892 b = %_ValueOf(b); | |
| 893 } | |
| 894 return b ? 'true' : 'false'; | |
| 895 } | |
| 896 | |
| 897 | |
| 898 function BooleanValueOf() { | |
| 899 // NOTE: Both Boolean objects and values can enter here as | |
| 900 // 'this'. This is not as dictated by ECMA-262. | |
| 901 if (!IS_BOOLEAN(this) && !IS_BOOLEAN_WRAPPER(this)) { | |
| 902 throw MakeTypeError(kNotGeneric, 'Boolean.prototype.valueOf'); | |
| 903 } | |
| 904 return %_ValueOf(this); | |
| 905 } | |
| 906 | |
| 907 | |
| 908 // ---------------------------------------------------------------------------- | |
| 909 | |
| 910 %FunctionSetPrototype(GlobalBoolean, new GlobalBoolean(false)); | |
| 911 %AddNamedProperty(GlobalBoolean.prototype, "constructor", GlobalBoolean, | |
| 912 DONT_ENUM); | |
| 913 | |
| 914 utils.InstallFunctions(GlobalBoolean.prototype, DONT_ENUM, [ | |
| 915 "toString", BooleanToString, | |
| 916 "valueOf", BooleanValueOf | |
| 917 ]); | |
| 918 | |
| 919 | 880 |
| 920 // ---------------------------------------------------------------------------- | 881 // ---------------------------------------------------------------------------- |
| 921 // Number | 882 // Number |
| 922 | 883 |
| 923 // ES6 Number.prototype.toString([ radix ]) | 884 // ES6 Number.prototype.toString([ radix ]) |
| 924 function NumberToStringJS(radix) { | 885 function NumberToStringJS(radix) { |
| 925 // NOTE: Both Number objects and values can enter here as | 886 // NOTE: Both Number objects and values can enter here as |
| 926 // 'this'. This is not as dictated by ECMA-262. | 887 // 'this'. This is not as dictated by ECMA-262. |
| 927 var number = this; | 888 var number = this; |
| 928 if (!IS_NUMBER(this)) { | 889 if (!IS_NUMBER(this)) { |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1149 to.ObjectDefineProperties = ObjectDefineProperties; | 1110 to.ObjectDefineProperties = ObjectDefineProperties; |
| 1150 to.ObjectDefineProperty = ObjectDefineProperty; | 1111 to.ObjectDefineProperty = ObjectDefineProperty; |
| 1151 to.ObjectHasOwnProperty = ObjectHasOwnProperty; | 1112 to.ObjectHasOwnProperty = ObjectHasOwnProperty; |
| 1152 }); | 1113 }); |
| 1153 | 1114 |
| 1154 %InstallToContext([ | 1115 %InstallToContext([ |
| 1155 "object_value_of", ObjectValueOf, | 1116 "object_value_of", ObjectValueOf, |
| 1156 ]); | 1117 ]); |
| 1157 | 1118 |
| 1158 }) | 1119 }) |
| OLD | NEW |