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 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 // getOwnPropertySymbols is added in symbol.js. | 874 // getOwnPropertySymbols is added in symbol.js. |
875 "is", SameValue, // ECMA-262, Edition 6, section 19.1.2.10 | 875 "is", SameValue, // ECMA-262, Edition 6, section 19.1.2.10 |
876 // deliverChangeRecords, getNotifier, observe and unobserve are added | 876 // deliverChangeRecords, getNotifier, observe and unobserve are added |
877 // in object-observe.js. | 877 // in object-observe.js. |
878 ]); | 878 ]); |
879 | 879 |
880 | 880 |
881 // ---------------------------------------------------------------------------- | 881 // ---------------------------------------------------------------------------- |
882 // Boolean | 882 // Boolean |
883 | 883 |
884 function BooleanConstructor(x) { | |
885 // TODO(bmeurer): Move this to toplevel. | |
886 "use strict"; | |
887 if (!IS_UNDEFINED(new.target)) { | |
888 %_SetValueOf(this, TO_BOOLEAN(x)); | |
889 } else { | |
890 return TO_BOOLEAN(x); | |
891 } | |
892 } | |
893 | |
894 | |
895 function BooleanToString() { | 884 function BooleanToString() { |
896 // NOTE: Both Boolean objects and values can enter here as | 885 // NOTE: Both Boolean objects and values can enter here as |
897 // 'this'. This is not as dictated by ECMA-262. | 886 // 'this'. This is not as dictated by ECMA-262. |
898 var b = this; | 887 var b = this; |
899 if (!IS_BOOLEAN(b)) { | 888 if (!IS_BOOLEAN(b)) { |
900 if (!IS_BOOLEAN_WRAPPER(b)) { | 889 if (!IS_BOOLEAN_WRAPPER(b)) { |
901 throw MakeTypeError(kNotGeneric, 'Boolean.prototype.toString'); | 890 throw MakeTypeError(kNotGeneric, 'Boolean.prototype.toString'); |
902 } | 891 } |
903 b = %_ValueOf(b); | 892 b = %_ValueOf(b); |
904 } | 893 } |
905 return b ? 'true' : 'false'; | 894 return b ? 'true' : 'false'; |
906 } | 895 } |
907 | 896 |
908 | 897 |
909 function BooleanValueOf() { | 898 function BooleanValueOf() { |
910 // NOTE: Both Boolean objects and values can enter here as | 899 // NOTE: Both Boolean objects and values can enter here as |
911 // 'this'. This is not as dictated by ECMA-262. | 900 // 'this'. This is not as dictated by ECMA-262. |
912 if (!IS_BOOLEAN(this) && !IS_BOOLEAN_WRAPPER(this)) { | 901 if (!IS_BOOLEAN(this) && !IS_BOOLEAN_WRAPPER(this)) { |
913 throw MakeTypeError(kNotGeneric, 'Boolean.prototype.valueOf'); | 902 throw MakeTypeError(kNotGeneric, 'Boolean.prototype.valueOf'); |
914 } | 903 } |
915 return %_ValueOf(this); | 904 return %_ValueOf(this); |
916 } | 905 } |
917 | 906 |
918 | 907 |
919 // ---------------------------------------------------------------------------- | 908 // ---------------------------------------------------------------------------- |
920 | 909 |
921 %SetCode(GlobalBoolean, BooleanConstructor); | |
922 %FunctionSetPrototype(GlobalBoolean, new GlobalBoolean(false)); | 910 %FunctionSetPrototype(GlobalBoolean, new GlobalBoolean(false)); |
923 %AddNamedProperty(GlobalBoolean.prototype, "constructor", GlobalBoolean, | 911 %AddNamedProperty(GlobalBoolean.prototype, "constructor", GlobalBoolean, |
924 DONT_ENUM); | 912 DONT_ENUM); |
925 | 913 |
926 utils.InstallFunctions(GlobalBoolean.prototype, DONT_ENUM, [ | 914 utils.InstallFunctions(GlobalBoolean.prototype, DONT_ENUM, [ |
927 "toString", BooleanToString, | 915 "toString", BooleanToString, |
928 "valueOf", BooleanValueOf | 916 "valueOf", BooleanValueOf |
929 ]); | 917 ]); |
930 | 918 |
931 | 919 |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1161 to.ObjectDefineProperties = ObjectDefineProperties; | 1149 to.ObjectDefineProperties = ObjectDefineProperties; |
1162 to.ObjectDefineProperty = ObjectDefineProperty; | 1150 to.ObjectDefineProperty = ObjectDefineProperty; |
1163 to.ObjectHasOwnProperty = ObjectHasOwnProperty; | 1151 to.ObjectHasOwnProperty = ObjectHasOwnProperty; |
1164 }); | 1152 }); |
1165 | 1153 |
1166 %InstallToContext([ | 1154 %InstallToContext([ |
1167 "object_value_of", ObjectValueOf, | 1155 "object_value_of", ObjectValueOf, |
1168 ]); | 1156 ]); |
1169 | 1157 |
1170 }) | 1158 }) |
OLD | NEW |