1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 /*jshint bitwise: true, camelcase: false, curly: false, eqeqeq: true,
6 es5: true, forin: true, immed: true, indent: 4, latedef: false,
7 newcap: false, noarg: true, noempty: true, nonew: true,
8 plusplus: false, quotmark: false, regexp: true, undef: true,
9 unused: false, strict: false, trailing: true,
12 /*global ToObject: false, ToInteger: false, IsCallable: false,
13 ThrowError: false, AssertionFailed: false, SetScriptHints: false,
14 MakeConstructible: false, DecompileArg: false,
15 RuntimeDefaultLocale: false,
16 ParallelDo: false, ParallelSlices: false, NewDenseArray: false,
17 UnsafePutElements: false, ShouldForceSequential: false,
18 ParallelTestsShouldPass: false,
22 JSMSG_NOT_FUNCTION: false, JSMSG_MISSING_FUN_ARG: false,
23 JSMSG_EMPTY_ARRAY_REDUCE: false, JSMSG_CANT_CONVERT_TO: false,
26 #include "SelfHostingDefines.h"
28 // All C++-implemented standard builtins library functions used in self-hosted
29 // code are installed via the std_functions JSFunctionSpec[] in
32 // The few items below here are either self-hosted or installing them under a
33 // std_Foo name would require ugly contortions, so they just get aliased here.
34 var std_Array_indexOf = ArrayIndexOf;
35 var std_String_substring = String_substring;
36 // WeakMap is a bare constructor without properties or methods.
37 var std_WeakMap = WeakMap;
38 // StopIteration is a bare constructor without properties or methods.
39 var std_StopIteration = StopIteration;
42 /********** List specification type **********/
45 /* Spec: ECMAScript Language Specification, 5.1 edition, 8.8 */
48 let ListProto = std_Object_create(null);
49 ListProto.indexOf = std_Array_indexOf;
50 ListProto.join = std_Array_join;
51 ListProto.push = std_Array_push;
52 ListProto.slice = std_Array_slice;
53 ListProto.sort = std_Array_sort;
54 MakeConstructible(List, ListProto);
58 /********** Record specification type **********/
61 /* Spec: ECMAScript Internationalization API Specification, draft, 5 */
63 return std_Object_create(null);
65 MakeConstructible(Record, {});
68 /********** Abstract operations defined in ECMAScript Language Specification **********/
71 /* Spec: ECMAScript Language Specification, 5.1 edition, 8.12.6 and 11.8.7 */
72 function HasProperty(o, p) {
77 /* Spec: ECMAScript Language Specification, 5.1 edition, 9.2 and 11.4.9 */
78 function ToBoolean(v) {
83 /* Spec: ECMAScript Language Specification, 5.1 edition, 9.3 and 11.4.6 */
84 function ToNumber(v) {
89 /* Spec: ECMAScript Language Specification, 5.1 edition, 9.10 */
90 function CheckObjectCoercible(v) {
91 if (v === undefined || v === null)
92 ThrowError(JSMSG_CANT_CONVERT_TO, ToString(v), "object");
95 /* Spec: ECMAScript Draft, 6 edition May 22, 2014, 7.1.15 */
96 function ToLength(v) {
102 // Math.pow(2, 53) - 1 = 0x1fffffffffffff
103 return std_Math_min(v, 0x1fffffffffffff);
106 // Spec: ECMAScript Draft, 6th edition Oct 14, 2014, 7.2.4.
107 function SameValueZero(x, y) {
108 return x === y || (x !== x && y !== y);