예제 #1
0
        public static (ScriptFunctionObject RegExp, ScriptObject RegExpPrototype) Initialise([NotNull] Agent agent, [NotNull] Realm realm)
        {
            var regExp = Intrinsics.CreateBuiltinFunction(realm, RegExp, realm.FunctionPrototype, 2, "RegExp", ConstructorKind.Base);

            var regExpPrototype = agent.ObjectCreate(realm.ObjectPrototype);

            Intrinsics.DefineDataProperty(regExpPrototype, "constructor", regExp);
            Intrinsics.DefineFunction(regExpPrototype, "exec", 1, realm, Exec);
            Intrinsics.DefineAccessorProperty(regExpPrototype, "flags", Intrinsics.CreateBuiltinFunction(realm, GetFlags, realm.FunctionPrototype, 0, "get flags"), null);
            Intrinsics.DefineAccessorProperty(regExpPrototype, "global", Intrinsics.CreateBuiltinFunction(realm, GetGlobal, realm.FunctionPrototype, 0, "get global"), null);
            Intrinsics.DefineAccessorProperty(regExpPrototype, "ignoreCase", Intrinsics.CreateBuiltinFunction(realm, GetIgnoreCase, realm.FunctionPrototype, 0, "get ignoreCase"), null);
            Intrinsics.DefineDataProperty(regExpPrototype, Symbol.Match, Intrinsics.CreateBuiltinFunction(realm, Match, realm.FunctionPrototype, 1, "[Symbol.match]"));
            Intrinsics.DefineAccessorProperty(regExpPrototype, "multiline", Intrinsics.CreateBuiltinFunction(realm, GetMultiline, realm.FunctionPrototype, 0, "get multiline"), null);
            Intrinsics.DefineDataProperty(regExpPrototype, Symbol.Replace, Intrinsics.CreateBuiltinFunction(realm, Replace, realm.FunctionPrototype, 2, "[Symbol.replace]"));
            Intrinsics.DefineDataProperty(regExpPrototype, Symbol.Search, Intrinsics.CreateBuiltinFunction(realm, Search, realm.FunctionPrototype, 1, "[Symbol.search]"));
            Intrinsics.DefineAccessorProperty(regExpPrototype, "source", Intrinsics.CreateBuiltinFunction(realm, GetSource, realm.FunctionPrototype, 0, "get source"), null);
            Intrinsics.DefineDataProperty(regExpPrototype, Symbol.Split, Intrinsics.CreateBuiltinFunction(realm, Split, realm.FunctionPrototype, 2, "[Symbol.split]"));
            Intrinsics.DefineAccessorProperty(regExpPrototype, "sticky", Intrinsics.CreateBuiltinFunction(realm, GetSticky, realm.FunctionPrototype, 0, "get sticky"), null);
            Intrinsics.DefineFunction(regExpPrototype, "test", 1, realm, Test);
            Intrinsics.DefineFunction(regExpPrototype, "toString", 0, realm, ToString);
            Intrinsics.DefineAccessorProperty(regExpPrototype, "unicode", Intrinsics.CreateBuiltinFunction(realm, GetUnicode, realm.FunctionPrototype, 0, "get unicode"), null);

            Intrinsics.DefineDataProperty(regExp, "prototype", regExpPrototype, false, false, false);
            Intrinsics.DefineAccessorProperty(regExp, Symbol.Species, Intrinsics.CreateBuiltinFunction(realm, GetSpecies, realm.FunctionPrototype, 0, "get [Symbol.species]"), null);

            return(regExp, regExpPrototype);
        }
예제 #2
0
        public static (ScriptFunctionObject number, ScriptObject numberPrototype) Initialise([NotNull] Agent agent, [NotNull] Realm realm, [NotNull] ScriptObject objectPrototype, [NotNull] ScriptObject functionPrototype)
        {
            var number = Intrinsics.CreateBuiltinFunction(realm, Number, functionPrototype, 1, "Number", ConstructorKind.Base);

            Intrinsics.DefineDataProperty(number, "EPSILON", 2.2204460492503130808472633361816E-16, false, false, false);
            Intrinsics.DefineDataProperty(number, "MAX_SAFE_INTEGER", 9007199254740991, false, false, false);
            Intrinsics.DefineDataProperty(number, "MAX_VALUE", double.MaxValue, false, false, false);
            Intrinsics.DefineDataProperty(number, "MIN_SAFE_INTEGER", -9007199254740991, false, false, false);
            Intrinsics.DefineDataProperty(number, "MIN_VALUE", double.Epsilon, false, false, false);
            Intrinsics.DefineDataProperty(number, "NaN", double.NaN, false, false, false);
            Intrinsics.DefineDataProperty(number, "NEGATIVE_INFINITY", double.NegativeInfinity, false, false, false);
            Intrinsics.DefineDataProperty(number, "POSITIVE_INFINITY", double.PositiveInfinity, false, false, false);

            Intrinsics.DefineFunction(number, "isFinite", 1, realm, IsFinite);
            Intrinsics.DefineFunction(number, "isInteger", 1, realm, IsInteger);
            Intrinsics.DefineFunction(number, "isNaN", 1, realm, IsNaN);
            Intrinsics.DefineFunction(number, "isSafeInteger", 1, realm, IsSafeInteger);
            Intrinsics.DefineFunction(number, "parseFloat", 1, realm, ParseFloat);
            Intrinsics.DefineFunction(number, "parseInt", 2, realm, ParseInt);

            var numberPrototype = agent.ObjectCreate(objectPrototype, SpecialObjectType.Number);

            Intrinsics.DefineDataProperty(numberPrototype, "constructor", number);

            Intrinsics.DefineFunction(numberPrototype, "toExponential", 1, realm, ToExponential);
            Intrinsics.DefineFunction(numberPrototype, "toFixed", 1, realm, ToFixed);
            Intrinsics.DefineFunction(numberPrototype, "toLocaleString", 0, realm, ToLocaleString);
            Intrinsics.DefineFunction(numberPrototype, "toPrecision", 1, realm, ToPrecision);
            Intrinsics.DefineFunction(numberPrototype, "toString", 1, realm, ToString);
            Intrinsics.DefineFunction(numberPrototype, "valueOf", 0, realm, ValueOf);

            Intrinsics.DefineDataProperty(number, "prototype", numberPrototype, false, false, false);

            return(number, numberPrototype);
        }
예제 #3
0
        public static ScriptFunctionObject Initialise([NotNull] Realm realm)
        {
            var proxy = Intrinsics.CreateBuiltinFunction(realm, Proxy, realm.FunctionPrototype, 2, "Proxy", ConstructorKind.Base);

            Intrinsics.DefineFunction(proxy, "revocable", 2, realm, Revocable);
            return(proxy);
        }
예제 #4
0
        public static (ScriptFunctionObject DataView, ScriptObject DataViewPrototype) Initialise([NotNull] Agent agent, [NotNull] Realm realm)
        {
            var dataView = Intrinsics.CreateBuiltinFunction(realm, DataView, realm.FunctionPrototype, 1, "DataView", ConstructorKind.Base);

            var dataViewPrototype = agent.ObjectCreate(realm.ObjectPrototype);

            Intrinsics.DefineAccessorProperty(dataViewPrototype, "buffer", Intrinsics.CreateBuiltinFunction(realm, GetBuffer, realm.FunctionPrototype, 0, "get buffer"), null);
            Intrinsics.DefineAccessorProperty(dataViewPrototype, "byteLength", Intrinsics.CreateBuiltinFunction(realm, GetByteLength, realm.FunctionPrototype, 0, "get byteLength"), null);
            Intrinsics.DefineAccessorProperty(dataViewPrototype, "byteOffset", Intrinsics.CreateBuiltinFunction(realm, GetByteOffset, realm.FunctionPrototype, 0, "get byteOffset"), null);
            Intrinsics.DefineDataProperty(dataViewPrototype, "constructor", dataView);
            Intrinsics.DefineFunction(dataViewPrototype, "getFloat32", 1, realm, GetFloat32);
            Intrinsics.DefineFunction(dataViewPrototype, "getFloat64", 1, realm, GetFloat64);
            Intrinsics.DefineFunction(dataViewPrototype, "getInt8", 1, realm, GetInt8);
            Intrinsics.DefineFunction(dataViewPrototype, "getInt16", 1, realm, GetInt16);
            Intrinsics.DefineFunction(dataViewPrototype, "getInt32", 1, realm, GetInt32);
            Intrinsics.DefineFunction(dataViewPrototype, "getUint8", 1, realm, GetUint8);
            Intrinsics.DefineFunction(dataViewPrototype, "getUint16", 1, realm, GetUint16);
            Intrinsics.DefineFunction(dataViewPrototype, "getUint32", 1, realm, GetUint32);
            Intrinsics.DefineFunction(dataViewPrototype, "setFloat32", 2, realm, SetFloat32);
            Intrinsics.DefineFunction(dataViewPrototype, "setFloat64", 2, realm, SetFloat64);
            Intrinsics.DefineFunction(dataViewPrototype, "setInt8", 2, realm, SetInt8);
            Intrinsics.DefineFunction(dataViewPrototype, "setInt16", 2, realm, SetInt16);
            Intrinsics.DefineFunction(dataViewPrototype, "setInt32", 2, realm, SetInt32);
            Intrinsics.DefineFunction(dataViewPrototype, "setUint8", 2, realm, SetUint8);
            Intrinsics.DefineFunction(dataViewPrototype, "setUint16", 2, realm, SetUint16);
            Intrinsics.DefineFunction(dataViewPrototype, "setUint32", 2, realm, SetUint32);
            Intrinsics.DefineDataProperty(dataViewPrototype, Symbol.ToStringTag, "DataView", false);

            Intrinsics.DefineDataProperty(dataView, "prototype", dataViewPrototype, false, false, false);

            return(dataView, dataViewPrototype);
        }
예제 #5
0
        public static (ScriptFunctionObject date, ScriptObject datePrototype) Initialise([NotNull] Agent agent, [NotNull] Realm realm, [NotNull] ScriptObject objectPrototype, [NotNull] ScriptObject functionPrototype)
        {
            var date = Intrinsics.CreateBuiltinFunction(realm, Date, functionPrototype, 7, "Date", ConstructorKind.Base);

            Intrinsics.DefineFunction(date, "now", 0, realm, Now);
            Intrinsics.DefineFunction(date, "parse", 1, realm, Parse);
            Intrinsics.DefineFunction(date, "UTC", 7, realm, UTC);

            var datePrototype = agent.ObjectCreate(objectPrototype);

            Intrinsics.DefineDataProperty(datePrototype, "constructor", date);
            Intrinsics.DefineFunction(datePrototype, "getDate", 0, realm, GetDate);
            Intrinsics.DefineFunction(datePrototype, "getDay", 0, realm, GetDay);
            Intrinsics.DefineFunction(datePrototype, "getFullYear", 0, realm, GetFullYear);
            Intrinsics.DefineFunction(datePrototype, "getHours", 0, realm, GetHours);
            Intrinsics.DefineFunction(datePrototype, "getMilliseconds", 0, realm, GetMilliseconds);
            Intrinsics.DefineFunction(datePrototype, "getMinutes", 0, realm, GetMinutes);
            Intrinsics.DefineFunction(datePrototype, "getMonth", 0, realm, GetMonth);
            Intrinsics.DefineFunction(datePrototype, "getSeconds", 0, realm, GetSeconds);
            Intrinsics.DefineFunction(datePrototype, "getTime", 0, realm, GetTime);
            Intrinsics.DefineFunction(datePrototype, "getTimezoneOffset", 0, realm, GetTimezoneOffset);
            Intrinsics.DefineFunction(datePrototype, "getUTCDate", 0, realm, GetUTCDate);
            Intrinsics.DefineFunction(datePrototype, "getUTCDay", 0, realm, GetUTCDay);
            Intrinsics.DefineFunction(datePrototype, "getUTCFullYear", 0, realm, GetUTCFullYear);
            Intrinsics.DefineFunction(datePrototype, "getUTCHours", 0, realm, GetUTCHours);
            Intrinsics.DefineFunction(datePrototype, "getUTCMilliseconds", 0, realm, GetUTCMilliseconds);
            Intrinsics.DefineFunction(datePrototype, "getUTCMinutes", 0, realm, GetUTCMinutes);
            Intrinsics.DefineFunction(datePrototype, "getUTCMonth", 0, realm, GetUTCMonth);
            Intrinsics.DefineFunction(datePrototype, "getUTCSeconds", 0, realm, GetUTCSeconds);
            Intrinsics.DefineFunction(datePrototype, "setDate", 1, realm, SetDate);
            Intrinsics.DefineFunction(datePrototype, "setFullYear", 3, realm, SetFullYear);
            Intrinsics.DefineFunction(datePrototype, "setHours", 4, realm, SetHours);
            Intrinsics.DefineFunction(datePrototype, "setMilliseconds", 1, realm, SetMilliseconds);
            Intrinsics.DefineFunction(datePrototype, "setMinutes", 3, realm, SetMinutes);
            Intrinsics.DefineFunction(datePrototype, "setMonth", 2, realm, SetMonth);
            Intrinsics.DefineFunction(datePrototype, "setSeconds", 2, realm, SetSeconds);
            Intrinsics.DefineFunction(datePrototype, "setTime", 1, realm, SetTime);
            Intrinsics.DefineFunction(datePrototype, "setUTCDate", 1, realm, SetUTCDate);
            Intrinsics.DefineFunction(datePrototype, "setUTCFullYear", 3, realm, SetUTCFullYear);
            Intrinsics.DefineFunction(datePrototype, "setUTCHours", 4, realm, SetUTCHours);
            Intrinsics.DefineFunction(datePrototype, "setUTCMilliseconds", 1, realm, SetUTCMilliseconds);
            Intrinsics.DefineFunction(datePrototype, "setUTCMinutes", 3, realm, SetUTCMinutes);
            Intrinsics.DefineFunction(datePrototype, "setUTCMonth", 2, realm, SetUTCMonth);
            Intrinsics.DefineFunction(datePrototype, "setUTCSeconds", 2, realm, SetUTCSeconds);
            Intrinsics.DefineFunction(datePrototype, "toDateString", 0, realm, ToDateString);
            Intrinsics.DefineFunction(datePrototype, "toISOString", 0, realm, ToISOString);
            Intrinsics.DefineFunction(datePrototype, "toJSON", 1, realm, ToJSON);
            Intrinsics.DefineFunction(datePrototype, "toLocaleDateString", 0, realm, ToLocaleDateString);
            Intrinsics.DefineFunction(datePrototype, "toLocaleString", 0, realm, ToLocaleString);
            Intrinsics.DefineFunction(datePrototype, "toLocaleTimeString", 0, realm, ToLocaleTimeString);
            Intrinsics.DefineFunction(datePrototype, "toString", 0, realm, ToString);
            Intrinsics.DefineFunction(datePrototype, "toTimeString", 0, realm, ToTimeString);
            Intrinsics.DefineFunction(datePrototype, "toUTCString", 0, realm, ToUTCString);
            Intrinsics.DefineFunction(datePrototype, "valueOf", 0, realm, ValueOf);
            Intrinsics.DefineDataProperty(datePrototype, Symbol.ToPrimitive, Intrinsics.CreateBuiltinFunction(realm, ToPrimitive, functionPrototype, 1, "[Symbol.toPrimitive]"), false);

            Intrinsics.DefineDataProperty(date, "prototype", datePrototype, false, false, false);

            return(date, datePrototype);
        }
예제 #6
0
        public static (ScriptFunctionObject symbol, ScriptObject symbolPrototype) Initialise([NotNull] Agent agent, [NotNull] Realm realm, [NotNull] ScriptObject objectPrototype, [NotNull] ScriptObject functionPrototype)
        {
            var symbol = Intrinsics.CreateBuiltinFunction(realm, SymbolConstructor, functionPrototype, 0, "Symbol", ConstructorKind.Base);

            Intrinsics.DefineFunction(symbol, "for", 1, realm, For);
            Intrinsics.DefineDataProperty(symbol, "hasInstance", Symbol.HasInstance, false, false, false);
            Intrinsics.DefineDataProperty(symbol, "isConcatSpreadable", Symbol.IsConcatSpreadable, false, false, false);
            Intrinsics.DefineDataProperty(symbol, "iterator", Symbol.Iterator, false, false, false);
            Intrinsics.DefineFunction(symbol, "keyFor", 1, realm, KeyFor);
            Intrinsics.DefineDataProperty(symbol, "match", Symbol.Match, false, false, false);
            Intrinsics.DefineDataProperty(symbol, "replace", Symbol.Replace, false, false, false);
            Intrinsics.DefineDataProperty(symbol, "search", Symbol.Search, false, false, false);
            Intrinsics.DefineDataProperty(symbol, "species", Symbol.Species, false, false, false);
            Intrinsics.DefineDataProperty(symbol, "split", Symbol.Split, false, false, false);
            Intrinsics.DefineDataProperty(symbol, "toPrimitive", Symbol.ToPrimitive, false, false, false);
            Intrinsics.DefineDataProperty(symbol, "toStringTag", Symbol.ToStringTag, false, false, false);
            Intrinsics.DefineDataProperty(symbol, "unscopables", Symbol.Unscopables, false, false, false);

            var symbolPrototype = agent.ObjectCreate(objectPrototype);

            Intrinsics.DefineDataProperty(symbolPrototype, "constructor", symbol);
            Intrinsics.DefineFunction(symbolPrototype, "toString", 0, realm, ToString);
            Intrinsics.DefineFunction(symbolPrototype, "valueOf", 0, realm, ValueOf);
            Intrinsics.DefineDataProperty(symbolPrototype, Symbol.ToPrimitive, Intrinsics.CreateBuiltinFunction(realm, ToPrimitive, functionPrototype, 1, "[Symbol.toPrimitive]"), false);
            Intrinsics.DefineDataProperty(symbolPrototype, Symbol.ToStringTag, "Symbol", false);

            Intrinsics.DefineDataProperty(symbol, "prototype", symbolPrototype, false, false, false);

            return(symbol, symbolPrototype);
        }
예제 #7
0
        public static (ScriptFunctionObject Set, ScriptObject SetPrototype, ScriptObject SetIteratorPrototype) Initialise([NotNull] Agent agent, [NotNull] Realm realm)
        {
            var set = Intrinsics.CreateBuiltinFunction(realm, Set, realm.FunctionPrototype, 0, "Set", ConstructorKind.Base);

            Intrinsics.DefineAccessorProperty(set, Symbol.Species, Intrinsics.CreateBuiltinFunction(realm, GetSpecies, realm.FunctionPrototype, 0, "get [Symbol.species]"), null);

            var setPrototype = agent.ObjectCreate(realm.ObjectPrototype);

            Intrinsics.DefineFunction(setPrototype, "add", 1, realm, Add);
            Intrinsics.DefineFunction(setPrototype, "clear", 0, realm, Clear);
            Intrinsics.DefineDataProperty(setPrototype, "constructor", set);
            Intrinsics.DefineFunction(setPrototype, "delete", 1, realm, Delete);
            var setEntries = Intrinsics.DefineFunction(setPrototype, "entries", 0, realm, Entries);

            Intrinsics.DefineFunction(setPrototype, "forEach", 1, realm, ForEach);
            Intrinsics.DefineFunction(setPrototype, "has", 1, realm, Has);
            Intrinsics.DefineFunction(setPrototype, "keys", 0, realm, Keys);
            Intrinsics.DefineAccessorProperty(setPrototype, "size", Intrinsics.CreateBuiltinFunction(realm, GetSize, realm.FunctionPrototype, 0, "get size"), null);
            Intrinsics.DefineFunction(setPrototype, "values", 0, realm, Values);
            Intrinsics.DefineDataProperty(setPrototype, Symbol.Iterator, setEntries);
            Intrinsics.DefineDataProperty(setPrototype, Symbol.ToStringTag, "Set", false);

            Intrinsics.DefineDataProperty(set, "prototype", setPrototype, false, false, false);

            var setIteratorPrototype = agent.ObjectCreate(realm.IteratorPrototype);

            Intrinsics.DefineFunction(setIteratorPrototype, "next", 0, realm, Next);
            Intrinsics.DefineDataProperty(setIteratorPrototype, Symbol.ToStringTag, "Set Iterator", false);

            return(set, setPrototype, setIteratorPrototype);
        }
예제 #8
0
        public static (ScriptObject Json, ScriptFunctionObject JsonParse) Initialise([NotNull] Agent agent, [NotNull] Realm realm)
        {
            var json = agent.ObjectCreate(realm.ObjectPrototype);

            var jsonParse = Intrinsics.DefineFunction(json, "parse", 2, realm, Parse);

            Intrinsics.DefineFunction(json, "stringify", 3, realm, Stringify);
            Intrinsics.DefineDataProperty(json, Symbol.ToStringTag, "JSON", false);

            return(json, jsonParse);
        }
예제 #9
0
        public static ScriptObject Initialise([NotNull] Agent agent, [NotNull] Realm realm)
        {
            var maths = agent.ObjectCreate(realm.ObjectPrototype);

            Intrinsics.DefineDataProperty(maths, "E", Math.E, false, false, false);
            Intrinsics.DefineDataProperty(maths, "LN10", Math.Log(10), false, false, false);
            Intrinsics.DefineDataProperty(maths, "LN2", Math.Log(2), false, false, false);
            Intrinsics.DefineDataProperty(maths, "LOG10E", Math.Log10(Math.E), false, false, false);
            Intrinsics.DefineDataProperty(maths, "LOG2E", Math.Log10(Math.E) / Math.Log10(2), false, false, false);
            Intrinsics.DefineDataProperty(maths, "PI", Math.PI, false, false, false);
            Intrinsics.DefineDataProperty(maths, "SQRT1_2", Math.Sqrt(0.5), false, false, false);
            Intrinsics.DefineDataProperty(maths, "SQRT2", Math.Sqrt(2), false, false, false);
            Intrinsics.DefineDataProperty(maths, Symbol.ToStringTag, "Math", false);

            Intrinsics.DefineFunction(maths, "abs", 1, realm, Abs);
            Intrinsics.DefineFunction(maths, "acos", 1, realm, Acos);
            Intrinsics.DefineFunction(maths, "acosh", 1, realm, Acosh);
            Intrinsics.DefineFunction(maths, "asin", 1, realm, Asin);
            Intrinsics.DefineFunction(maths, "asinh", 1, realm, Asinh);
            Intrinsics.DefineFunction(maths, "atan", 1, realm, Atan);
            Intrinsics.DefineFunction(maths, "atanh", 1, realm, Atanh);
            Intrinsics.DefineFunction(maths, "atan2", 2, realm, Atan2);
            Intrinsics.DefineFunction(maths, "cbrt", 1, realm, Cbrt);
            Intrinsics.DefineFunction(maths, "ceil", 1, realm, Ceiling);
            Intrinsics.DefineFunction(maths, "clz32", 1, realm, Clz32);
            Intrinsics.DefineFunction(maths, "cos", 1, realm, Cos);
            Intrinsics.DefineFunction(maths, "cosh", 1, realm, Cosh);
            Intrinsics.DefineFunction(maths, "exp", 1, realm, Exp);
            Intrinsics.DefineFunction(maths, "expm1", 1, realm, Expm1);
            Intrinsics.DefineFunction(maths, "floor", 1, realm, Floor);
            Intrinsics.DefineFunction(maths, "fround", 1, realm, Fround);
            Intrinsics.DefineFunction(maths, "hypot", 1, realm, Hypot);
            Intrinsics.DefineFunction(maths, "imul", 2, realm, Imul);
            Intrinsics.DefineFunction(maths, "log", 1, realm, Log);
            Intrinsics.DefineFunction(maths, "log1p", 1, realm, Log1P);
            Intrinsics.DefineFunction(maths, "log2", 1, realm, Log2);
            Intrinsics.DefineFunction(maths, "max", 1, realm, Max);
            Intrinsics.DefineFunction(maths, "min", 1, realm, Min);
            Intrinsics.DefineFunction(maths, "pow", 2, realm, Pow);
            Intrinsics.DefineFunction(maths, "random", 0, realm, Random);
            Intrinsics.DefineFunction(maths, "round", 1, realm, Round);
            Intrinsics.DefineFunction(maths, "sign", 1, realm, Sign);
            Intrinsics.DefineFunction(maths, "sin", 1, realm, Sin);
            Intrinsics.DefineFunction(maths, "sinh", 1, realm, Sinh);
            Intrinsics.DefineFunction(maths, "sqrt", 1, realm, Sqrt);
            Intrinsics.DefineFunction(maths, "tan", 1, realm, Tan);
            Intrinsics.DefineFunction(maths, "tanh", 1, realm, Tanh);
            Intrinsics.DefineFunction(maths, "trunc", 1, realm, Trunc);

            return(maths);
        }
예제 #10
0
        public static (ScriptFunctionObject boolean, ScriptObject booleanPrototype) Initialise([NotNull] Agent agent, [NotNull] Realm realm, [NotNull] ScriptObject objectPrototype, [NotNull] ScriptObject functionPrototype)
        {
            var boolean = Intrinsics.CreateBuiltinFunction(realm, Boolean, functionPrototype, 1, "Boolean", ConstructorKind.Base);

            var booleanPrototype = agent.ObjectCreate(objectPrototype, SpecialObjectType.Boolean);

            Intrinsics.DefineDataProperty(booleanPrototype, "constructor", boolean);
            Intrinsics.DefineFunction(booleanPrototype, "toString", 0, realm, ToString);
            Intrinsics.DefineFunction(booleanPrototype, "valueOf", 0, realm, ValueOf);

            Intrinsics.DefineDataProperty(boolean, "prototype", booleanPrototype, false, false, false);

            return(boolean, booleanPrototype);
        }
예제 #11
0
        public static (ScriptFunctionObject stringConstructor, ScriptObject stringIteratorPrototype, ScriptObject stringPrototype) Initialise([NotNull] Agent agent, [NotNull] Realm realm, [NotNull] ScriptObject objectPrototype, [NotNull] ScriptObject functionPrototype)
        {
            var stringConstructor = Intrinsics.CreateBuiltinFunction(realm, String, functionPrototype, 1, "String", ConstructorKind.Base);

            Intrinsics.DefineFunction(stringConstructor, "fromCharCode", 1, realm, FromCharCode);
            Intrinsics.DefineFunction(stringConstructor, "fromCodePoint", 1, realm, FromCodePoint);
            Intrinsics.DefineFunction(stringConstructor, "raw", 1, realm, Raw);

            var stringPrototype = new ScriptStringObject(realm, objectPrototype, "");

            Intrinsics.DefineFunction(stringPrototype, "charAt", 1, realm, CharAt);
            Intrinsics.DefineFunction(stringPrototype, "charCodeAt", 1, realm, CharCodeAt);
            Intrinsics.DefineFunction(stringPrototype, "codePointAt", 1, realm, CodePointAt);
            Intrinsics.DefineFunction(stringPrototype, "concat", 1, realm, Concat);
            Intrinsics.DefineDataProperty(stringPrototype, "constructor", stringConstructor);
            Intrinsics.DefineFunction(stringPrototype, "endsWith", 1, realm, EndsWith);
            Intrinsics.DefineFunction(stringPrototype, "includes", 1, realm, Includes);
            Intrinsics.DefineFunction(stringPrototype, "indexOf", 1, realm, IndexOf);
            Intrinsics.DefineFunction(stringPrototype, "lastIndexOf", 1, realm, LastIndexOf);
            Intrinsics.DefineFunction(stringPrototype, "localeCompare", 1, realm, LocaleCompare);
            Intrinsics.DefineFunction(stringPrototype, "match", 1, realm, Match);
            Intrinsics.DefineFunction(stringPrototype, "normalize", 0, realm, Normalise);
            Intrinsics.DefineFunction(stringPrototype, "padEnd", 1, realm, PadEnd);
            Intrinsics.DefineFunction(stringPrototype, "padStart", 1, realm, PadStart);
            Intrinsics.DefineFunction(stringPrototype, "repeat", 1, realm, Repeat);
            Intrinsics.DefineFunction(stringPrototype, "replace", 2, realm, Replace);
            Intrinsics.DefineFunction(stringPrototype, "search", 1, realm, Search);
            Intrinsics.DefineFunction(stringPrototype, "slice", 2, realm, Slice);
            Intrinsics.DefineFunction(stringPrototype, "split", 2, realm, Split);
            Intrinsics.DefineFunction(stringPrototype, "startsWith", 1, realm, StartsWith);
            Intrinsics.DefineFunction(stringPrototype, "substring", 2, realm, Substring);
            Intrinsics.DefineFunction(stringPrototype, "toLocaleLowerCase", 0, realm, ToLocaleLowerCase);
            Intrinsics.DefineFunction(stringPrototype, "toLocaleUpperCase", 0, realm, ToLocaleUpperCase);
            Intrinsics.DefineFunction(stringPrototype, "toLowerCase", 0, realm, ToLowerCase);
            Intrinsics.DefineFunction(stringPrototype, "toString", 0, realm, ToString);
            Intrinsics.DefineFunction(stringPrototype, "toUpperCase", 0, realm, ToUpperCase);
            Intrinsics.DefineFunction(stringPrototype, "trim", 0, realm, Trim);
            Intrinsics.DefineFunction(stringPrototype, "valueOf", 0, realm, ValueOf);
            Intrinsics.DefineDataProperty(stringPrototype, Symbol.Iterator, Intrinsics.CreateBuiltinFunction(realm, Iterator, functionPrototype, 0, "[Symbol.iterator]"));

            var stringIteratorPrototype = agent.ObjectCreate(realm.IteratorPrototype);

            Intrinsics.DefineFunction(stringIteratorPrototype, "next", 0, realm, Next);
            Intrinsics.DefineDataProperty(stringIteratorPrototype, Symbol.ToStringTag, "String Iterator", false);

            Intrinsics.DefineDataProperty(stringConstructor, "prototype", stringPrototype, false, false, false);

            return(stringConstructor, stringIteratorPrototype, stringPrototype);
        }
예제 #12
0
        public static (ScriptFunctionObject WeakSet, ScriptObject WeakSetPrototype) Initialise([NotNull] Agent agent, [NotNull] Realm realm)
        {
            var weakSet = Intrinsics.CreateBuiltinFunction(realm, Set, realm.FunctionPrototype, 0, "Set", ConstructorKind.Base);

            var weakSetPrototype = agent.ObjectCreate(realm.ObjectPrototype);

            Intrinsics.DefineFunction(weakSetPrototype, "add", 1, realm, Add);
            Intrinsics.DefineDataProperty(weakSetPrototype, "constructor", weakSet);
            Intrinsics.DefineFunction(weakSetPrototype, "delete", 1, realm, Delete);
            Intrinsics.DefineFunction(weakSetPrototype, "has", 1, realm, Has);
            Intrinsics.DefineDataProperty(weakSetPrototype, Symbol.ToStringTag, "WeakSet", false);

            Intrinsics.DefineDataProperty(weakSet, "prototype", weakSetPrototype, false, false, false);

            return(weakSet, weakSetPrototype);
        }
        public static (ScriptFunctionObject SharedArrayBuffer, ScriptObject SharedArrayBufferPrototype) Initialise([NotNull] Agent agent, [NotNull] Realm realm)
        {
            var sharedArrayBuffer = Intrinsics.CreateBuiltinFunction(realm, SharedArrayBuffer, realm.FunctionPrototype, 1, "SharedArrayBuffer", ConstructorKind.Base);

            Intrinsics.DefineAccessorProperty(sharedArrayBuffer, Symbol.Species, Intrinsics.CreateBuiltinFunction(realm, GetSpecies, realm.FunctionPrototype, 0, "get [Symbol.species]"), null);

            var sharedArrayBufferPrototype = agent.ObjectCreate(realm.ObjectPrototype);

            Intrinsics.DefineAccessorProperty(sharedArrayBufferPrototype, "byteLength", Intrinsics.CreateBuiltinFunction(realm, GetByteLength, realm.FunctionPrototype, 0, "get byteLength"), null);
            Intrinsics.DefineDataProperty(sharedArrayBufferPrototype, "constructor", sharedArrayBuffer);
            Intrinsics.DefineFunction(sharedArrayBufferPrototype, "slice", 2, realm, Slice);
            Intrinsics.DefineDataProperty(sharedArrayBufferPrototype, Symbol.ToStringTag, "SharedArrayBuffer", false);

            Intrinsics.DefineDataProperty(sharedArrayBuffer, "prototype", sharedArrayBufferPrototype, false, false, false);

            return(sharedArrayBuffer, sharedArrayBufferPrototype);
        }
예제 #14
0
        public static (ScriptFunctionObject error, ScriptObject errorPrototype) Initialise([NotNull] Agent agent, [NotNull] Realm realm, [NotNull] ScriptObject objectPrototype, [NotNull] ScriptObject functionPrototype)
        {
            //https://tc39.github.io/ecma262/#sec-error-objects

            var error = Intrinsics.CreateBuiltinFunction(realm, ErrorConstructor, functionPrototype, 1, "Error", ConstructorKind.Base);

            var errorPrototype = agent.ObjectCreate(objectPrototype);

            Intrinsics.DefineDataProperty(errorPrototype, "constructor", error);
            Intrinsics.DefineDataProperty(errorPrototype, "message", string.Empty);
            Intrinsics.DefineDataProperty(errorPrototype, "name", "Error");
            Intrinsics.DefineFunction(errorPrototype, "toString", 0, realm, ToString);

            Intrinsics.DefineDataProperty(error, "prototype", errorPrototype, false, false, false);

            return(error, errorPrototype);
        }
예제 #15
0
        public static (ScriptFunctionObject TypedArray, ScriptObject TypedArrayPrototype) Initialise([NotNull] Agent agent, [NotNull] Realm realm)
        {
            var typedArray = Intrinsics.CreateBuiltinFunction(realm, TypedArray, realm.FunctionPrototype, 0, "TypedArray", ConstructorKind.Base);

            Intrinsics.DefineFunction(typedArray, "from", 1, realm, From);
            Intrinsics.DefineFunction(typedArray, "of", 1, realm, Of);
            Intrinsics.DefineAccessorProperty(typedArray, Symbol.Species, Intrinsics.CreateBuiltinFunction(realm, GetSpecies, realm.FunctionPrototype, 0, "get [Symbol.species]"), null);

            var typedArrayPrototype = agent.ObjectCreate(realm.ObjectPrototype);

            Intrinsics.DefineAccessorProperty(typedArrayPrototype, "buffer", Intrinsics.CreateBuiltinFunction(realm, GetBuffer, realm.FunctionPrototype, 0, "get buffer"), null);
            Intrinsics.DefineAccessorProperty(typedArrayPrototype, "byteLength", Intrinsics.CreateBuiltinFunction(realm, GetByteLength, realm.FunctionPrototype, 0, "get byteLength"), null);
            Intrinsics.DefineAccessorProperty(typedArrayPrototype, "byteOffset", Intrinsics.CreateBuiltinFunction(realm, GetByteOffset, realm.FunctionPrototype, 0, "get byteOffset"), null);
            Intrinsics.DefineDataProperty(typedArrayPrototype, "constructor", typedArray);
            Intrinsics.DefineFunction(typedArrayPrototype, "copyWithin", 2, realm, CopyWithin);
            Intrinsics.DefineFunction(typedArrayPrototype, "entries", 0, realm, Entries);
            Intrinsics.DefineFunction(typedArrayPrototype, "every", 1, realm, Every);
            Intrinsics.DefineFunction(typedArrayPrototype, "fill", 1, realm, Fill);
            Intrinsics.DefineFunction(typedArrayPrototype, "findIndex", 1, realm, FindIndex);
            Intrinsics.DefineFunction(typedArrayPrototype, "forEach", 1, realm, ForEach);
            Intrinsics.DefineFunction(typedArrayPrototype, "includes", 1, realm, Includes);
            Intrinsics.DefineFunction(typedArrayPrototype, "indexOf", 1, realm, IndexOf);
            Intrinsics.DefineFunction(typedArrayPrototype, "join", 1, realm, Join);
            Intrinsics.DefineFunction(typedArrayPrototype, "keys", 0, realm, Keys);
            Intrinsics.DefineFunction(typedArrayPrototype, "lastIndexOf", 1, realm, LastIndexOf);
            Intrinsics.DefineAccessorProperty(typedArrayPrototype, "length", Intrinsics.CreateBuiltinFunction(realm, GetLength, realm.FunctionPrototype, 0, "get length"), null);
            Intrinsics.DefineFunction(typedArrayPrototype, "map", 1, realm, Map);
            Intrinsics.DefineFunction(typedArrayPrototype, "reduce", 1, realm, Reduce);
            Intrinsics.DefineFunction(typedArrayPrototype, "reduceRight", 1, realm, ReduceRight);
            Intrinsics.DefineFunction(typedArrayPrototype, "reverse", 0, realm, Reverse);
            Intrinsics.DefineFunction(typedArrayPrototype, "set", 1, realm, Set);
            Intrinsics.DefineFunction(typedArrayPrototype, "slice", 2, realm, Slice);
            Intrinsics.DefineFunction(typedArrayPrototype, "some", 1, realm, Some);
            Intrinsics.DefineFunction(typedArrayPrototype, "sort", 1, realm, Sort);
            Intrinsics.DefineFunction(typedArrayPrototype, "subarray", 2, realm, Subarray);
            Intrinsics.DefineFunction(typedArrayPrototype, "toLocaleString", 0, realm, ToLocaleString);
            Intrinsics.DefineFunction(typedArrayPrototype, "toString", 0, realm, ToString);
            var values = Intrinsics.DefineFunction(typedArrayPrototype, "values", 0, realm, Values);

            Intrinsics.DefineDataProperty(typedArrayPrototype, Symbol.Iterator, values);
            Intrinsics.DefineAccessorProperty(typedArrayPrototype, Symbol.ToStringTag, Intrinsics.CreateBuiltinFunction(realm, GetToStringTag, realm.FunctionPrototype, 0, "get [Symbol.toStringTag]"), null);

            Intrinsics.DefineDataProperty(typedArray, "prototype", typedArrayPrototype, false, false, false);

            return(typedArray, typedArrayPrototype);
        }
예제 #16
0
        public static ScriptObject Initialise([NotNull] Agent agent, [NotNull] Realm realm)
        {
            var reflect = agent.ObjectCreate(realm.ObjectPrototype);

            Intrinsics.DefineFunction(reflect, "apply", 3, realm, Apply);
            Intrinsics.DefineFunction(reflect, "construct", 2, realm, Construct);
            Intrinsics.DefineFunction(reflect, "defineProperty", 3, realm, DefineProperty);
            Intrinsics.DefineFunction(reflect, "deleteProperty", 2, realm, DeleteProperty);
            Intrinsics.DefineFunction(reflect, "get", 2, realm, Get);
            Intrinsics.DefineFunction(reflect, "getOwnPropertyDescriptor", 2, realm, GetOwnPropertyDescriptor);
            Intrinsics.DefineFunction(reflect, "getPrototypeOf", 1, realm, GetPrototypeOf);
            Intrinsics.DefineFunction(reflect, "has", 2, realm, Has);
            Intrinsics.DefineFunction(reflect, "isExtensible", 1, realm, IsExtensible);
            Intrinsics.DefineFunction(reflect, "ownKeys", 1, realm, OwnKeys);
            Intrinsics.DefineFunction(reflect, "preventExtensions", 1, realm, PreventExtensions);
            Intrinsics.DefineFunction(reflect, "set", 3, realm, Set);
            Intrinsics.DefineFunction(reflect, "setPrototypeOf", 2, realm, SetPrototypeOf);

            return(reflect);
        }
예제 #17
0
        public static ScriptFunctionObject Initialise([NotNull] Realm realm, [NotNull] ScriptObject functionPrototype)
        {
            //https://tc39.github.io/ecma262/#sec-function-objects

            var function = Intrinsics.CreateBuiltinFunction(realm, Function, functionPrototype, 1, "Function", ConstructorKind.Base);

            Intrinsics.DefineDataProperty(function, "prototype", functionPrototype, false, false, false);

            Intrinsics.DefineDataProperty(functionPrototype, "length", 0);
            Intrinsics.DefineDataProperty(functionPrototype, "name", "");

            Intrinsics.DefineFunction(functionPrototype, "apply", 2, realm, Apply);
            Intrinsics.DefineFunction(functionPrototype, "bind", 1, realm, Bind);
            Intrinsics.DefineFunction(functionPrototype, "call", 1, realm, Call);
            Intrinsics.DefineDataProperty(functionPrototype, "constructor", function);
            Intrinsics.DefineFunction(functionPrototype, "toString", 0, realm, ToString);
            Intrinsics.DefineDataProperty(functionPrototype, Symbol.HasInstance, Intrinsics.CreateBuiltinFunction(realm, HasInstance, functionPrototype, 1, "[Symbol.hasInstance]"), false, false, false);

            return(function);
        }
예제 #18
0
        public static ScriptObject Initialise([NotNull] Agent agent, [NotNull] Realm realm)
        {
            var atomics = agent.ObjectCreate(realm.ObjectPrototype);

            Intrinsics.DefineFunction(atomics, "add", 3, realm, Add);
            Intrinsics.DefineFunction(atomics, "and", 3, realm, And);
            Intrinsics.DefineFunction(atomics, "compareExchange", 4, realm, CompareExchange);
            Intrinsics.DefineFunction(atomics, "exchange", 3, realm, Exchange);
            Intrinsics.DefineFunction(atomics, "isLockFree", 1, realm, IsLockFree);
            Intrinsics.DefineFunction(atomics, "load", 2, realm, Load);
            Intrinsics.DefineFunction(atomics, "or", 3, realm, Or);
            Intrinsics.DefineFunction(atomics, "store", 3, realm, Store);
            Intrinsics.DefineFunction(atomics, "sub", 3, realm, Sub);
            Intrinsics.DefineFunction(atomics, "wait", 4, realm, Wait);
            Intrinsics.DefineFunction(atomics, "wake", 3, realm, Wake);
            Intrinsics.DefineFunction(atomics, "xor", 3, realm, Xor);
            Intrinsics.DefineDataProperty(atomics, Symbol.ToStringTag, "Atomics", false);

            return(atomics);
        }
예제 #19
0
        public static (ScriptObject Generator, ScriptObject GeneratorPrototype, ScriptFunctionObject GeneratorFunction) Initialise([NotNull] Agent agent, [NotNull] Realm realm, [NotNull] ScriptObject functionPrototype)
        {
            var generator = agent.ObjectCreate(functionPrototype);

            var generatorPrototype = agent.ObjectCreate(realm.IteratorPrototype);

            Intrinsics.DefineDataProperty(generatorPrototype, "constructor", generator, false);
            Intrinsics.DefineFunction(generatorPrototype, "next", 1, realm, Next);
            Intrinsics.DefineFunction(generatorPrototype, "return", 1, realm, Return);
            Intrinsics.DefineFunction(generatorPrototype, "throw", 1, realm, Throw);
            Intrinsics.DefineDataProperty(generatorPrototype, Symbol.ToStringTag, "Generator", false);

            var generatorFunction = Intrinsics.CreateBuiltinFunction(realm, GeneratorFunction, realm.Function, 1, "GeneratorFunction", ConstructorKind.Base);

            Intrinsics.DefineDataProperty(generatorFunction, "prototype", generator, false, false, false);

            Intrinsics.DefineDataProperty(generator, "constructor", generatorFunction, false);
            Intrinsics.DefineDataProperty(generator, "prototype", generatorPrototype, false);
            Intrinsics.DefineDataProperty(generator, Symbol.ToStringTag, "GeneratorFunction", false);

            return(generator, generatorPrototype, generatorFunction);
        }
예제 #20
0
                       ScriptFunctionObject PromiseResolve) Initialise([NotNull] Agent agent, [NotNull] Realm realm)
        {
            var promise    = Intrinsics.CreateBuiltinFunction(realm, Promise, realm.FunctionPrototype, 1, "Promise", ConstructorKind.Base);
            var promiseAll = Intrinsics.DefineFunction(promise, "all", 1, realm, All);

            Intrinsics.DefineFunction(promise, "race", 1, realm, Race);
            var promiseReject  = Intrinsics.DefineFunction(promise, "reject", 1, realm, Reject);
            var promiseResolve = Intrinsics.DefineFunction(promise, "resolve", 1, realm, Resolve);

            Intrinsics.DefineAccessorProperty(promise, Symbol.Species, Intrinsics.CreateBuiltinFunction(realm, GetSpecies, realm.FunctionPrototype, 0, "get [Symbol.species]"), null);

            var promisePrototype = agent.ObjectCreate(realm.ObjectPrototype);

            Intrinsics.DefineFunction(promisePrototype, "catch", 1, realm, Catch);
            var promiseProtoThen = Intrinsics.DefineFunction(promisePrototype, "then", 2, realm, Then);

            Intrinsics.DefineDataProperty(promisePrototype, "constructor", promise);
            Intrinsics.DefineDataProperty(promisePrototype, Symbol.ToStringTag, "Promise", false);

            Intrinsics.DefineDataProperty(promise, "prototype", promisePrototype, false, false, false);

            return(promise, promisePrototype, promiseProtoThen, promiseAll, promiseReject, promiseResolve);
        }
예제 #21
0
                       ScriptFunctionObject objectPrototypeValueOf) Initialise([NotNull] Realm realm, [NotNull] ScriptObject objectPrototype, [NotNull] ScriptObject functionPrototype)
        {
            var objectConstructor = Intrinsics.CreateBuiltinFunction(realm, Object, functionPrototype, 1, "Object", ConstructorKind.Base);

            Intrinsics.DefineFunction(objectConstructor, "assign", 2, realm, Assign);
            Intrinsics.DefineFunction(objectConstructor, "create", 2, realm, Create);
            Intrinsics.DefineFunction(objectConstructor, "defineProperties", 2, realm, DefineProperties);
            Intrinsics.DefineFunction(objectConstructor, "defineProperty", 3, realm, DefineProperty);
            Intrinsics.DefineFunction(objectConstructor, "entries", 1, realm, Entries);
            Intrinsics.DefineFunction(objectConstructor, "freeze", 1, realm, Freeze);
            Intrinsics.DefineFunction(objectConstructor, "getOwnPropertyDescriptor", 2, realm, GetOwnPropertyDescriptor);
            Intrinsics.DefineFunction(objectConstructor, "getOwnPropertyDescriptors", 1, realm, GetOwnPropertyDescriptors);
            Intrinsics.DefineFunction(objectConstructor, "getOwnPropertyNames", 1, realm, GetOwnPropertyNames);
            Intrinsics.DefineFunction(objectConstructor, "getOwnPropertySymbols", 1, realm, GetOwnPropertySymbols);
            Intrinsics.DefineFunction(objectConstructor, "getPrototypeOf", 1, realm, GetPrototypeOf);
            Intrinsics.DefineFunction(objectConstructor, "is", 2, realm, Is);
            Intrinsics.DefineFunction(objectConstructor, "isExtensible", 1, realm, IsExtensible);
            Intrinsics.DefineFunction(objectConstructor, "isFrozen", 1, realm, IsFrozen);
            Intrinsics.DefineFunction(objectConstructor, "isSealed", 1, realm, IsSealed);
            Intrinsics.DefineFunction(objectConstructor, "keys", 1, realm, Keys);
            Intrinsics.DefineFunction(objectConstructor, "preventExtensions", 1, realm, PreventExtensions);
            Intrinsics.DefineDataProperty(objectConstructor, "prototype", objectPrototype, false, false, false);
            Intrinsics.DefineFunction(objectConstructor, "seal", 1, realm, Seal);
            Intrinsics.DefineFunction(objectConstructor, "setPrototypeOf", 2, realm, SetPrototypeOf);
            Intrinsics.DefineFunction(objectConstructor, "values", 1, realm, Values);

            Intrinsics.DefineDataProperty(objectPrototype, "constructor", objectConstructor);
            Intrinsics.DefineFunction(objectPrototype, "hasOwnProperty", 1, realm, HasOwnProperty);
            Intrinsics.DefineFunction(objectPrototype, "isPrototypeOf", 1, realm, IsPrototypeOf);
            Intrinsics.DefineFunction(objectPrototype, "propertyIsEnumerable", 1, realm, PropertyIsEnumerable);
            Intrinsics.DefineFunction(objectPrototype, "toLocaleString", 0, realm, ToLocaleString);
            var objectPrototypeToString = Intrinsics.DefineFunction(objectPrototype, "toString", 0, realm, ToString);
            var objectPrototypeValueOf  = Intrinsics.DefineFunction(objectPrototype, "valueOf", 0, realm, ValueOf);

            return(objectConstructor, objectPrototypeToString, objectPrototypeValueOf);
        }
예제 #22
0
                       ScriptFunctionObject ArrayProtoValues) Initialise([NotNull] Agent agent, [NotNull] Realm realm, ScriptObject objectPrototype, ScriptObject functionPrototype)
        {
            var array = Intrinsics.CreateBuiltinFunction(realm, Array, functionPrototype, 1, "Array", ConstructorKind.Base);

            Intrinsics.DefineFunction(array, "from", 1, realm, From);
            Intrinsics.DefineFunction(array, "isArray", 1, realm, IsArray);
            Intrinsics.DefineFunction(array, "of", 0, realm, Of);
            Intrinsics.DefineAccessorProperty(array, Symbol.Species, Intrinsics.CreateBuiltinFunction(realm, arguments => arguments.ThisValue, functionPrototype, 0, "get [Symbol.species]"), null);

            var arrayPrototype = new ScriptArrayObject(realm, objectPrototype, true, 0);

            Intrinsics.DefineFunction(arrayPrototype, "concat", 1, realm, Concat);
            Intrinsics.DefineDataProperty(arrayPrototype, "constructor", array);
            Intrinsics.DefineFunction(arrayPrototype, "copyWithin", 2, realm, CopyWithin);
            var arrayProtoEntries = Intrinsics.DefineFunction(arrayPrototype, "entries", 0, realm, Entries);

            Intrinsics.DefineFunction(arrayPrototype, "every", 1, realm, Every);
            Intrinsics.DefineFunction(arrayPrototype, "fill", 1, realm, Fill);
            Intrinsics.DefineFunction(arrayPrototype, "filter", 1, realm, Filter);
            Intrinsics.DefineFunction(arrayPrototype, "find", 1, realm, Find);
            Intrinsics.DefineFunction(arrayPrototype, "findIndex", 1, realm, FindIndex);
            var arrayProtoForEach = Intrinsics.DefineFunction(arrayPrototype, "forEach", 1, realm, ForEach);

            Intrinsics.DefineFunction(arrayPrototype, "includes", 1, realm, Includes);
            Intrinsics.DefineFunction(arrayPrototype, "indexOf", 1, realm, IndexOf);
            Intrinsics.DefineFunction(arrayPrototype, "join", 1, realm, Join);
            var arrayProtoKeys = Intrinsics.DefineFunction(arrayPrototype, "keys", 0, realm, Keys);

            Intrinsics.DefineFunction(arrayPrototype, "lastIndexOf", 1, realm, LastIndexOf);
            Intrinsics.DefineFunction(arrayPrototype, "map", 1, realm, Map);
            Intrinsics.DefineFunction(arrayPrototype, "pop", 0, realm, Pop);
            Intrinsics.DefineFunction(arrayPrototype, "push", 1, realm, Push);
            Intrinsics.DefineFunction(arrayPrototype, "reduce", 1, realm, Reduce);
            Intrinsics.DefineFunction(arrayPrototype, "reduceRight", 1, realm, ReduceRight);
            Intrinsics.DefineFunction(arrayPrototype, "reverse", 0, realm, Reverse);
            Intrinsics.DefineFunction(arrayPrototype, "shift", 0, realm, Shift);
            Intrinsics.DefineFunction(arrayPrototype, "slice", 2, realm, Slice);
            Intrinsics.DefineFunction(arrayPrototype, "some", 1, realm, Some);
            Intrinsics.DefineFunction(arrayPrototype, "sort", 1, realm, Sort);
            Intrinsics.DefineFunction(arrayPrototype, "splice", 2, realm, Splice);
            Intrinsics.DefineFunction(arrayPrototype, "toLocaleString", 0, realm, ToLocaleString);
            Intrinsics.DefineFunction(arrayPrototype, "toString", 0, realm, ToString);
            Intrinsics.DefineFunction(arrayPrototype, "unshift", 1, realm, Unshift);
            var arrayProtoValues = Intrinsics.DefineFunction(arrayPrototype, "values", 0, realm, Values);

            Intrinsics.DefineDataProperty(arrayPrototype, Symbol.Iterator, arrayProtoValues);

            var unscopableList = Agent.ObjectCreate(realm, null);

            unscopableList.CreateDataProperty("copyWithin", true);
            unscopableList.CreateDataProperty("entries", true);
            unscopableList.CreateDataProperty("fill", true);
            unscopableList.CreateDataProperty("find", true);
            unscopableList.CreateDataProperty("findIndex", true);
            unscopableList.CreateDataProperty("includes", true);
            unscopableList.CreateDataProperty("keys", true);
            unscopableList.CreateDataProperty("values", true);
            Intrinsics.DefineDataProperty(arrayPrototype, Symbol.Unscopables, unscopableList, false);

            var arrayIteratorPrototype = agent.ObjectCreate(realm.IteratorPrototype);

            Intrinsics.DefineFunction(arrayIteratorPrototype, "next", 0, realm, Next);
            Intrinsics.DefineDataProperty(arrayIteratorPrototype, Symbol.ToStringTag, "Array Iterator", false);

            Intrinsics.DefineDataProperty(array, "prototype", arrayPrototype, false, false, false);

            return(array, arrayPrototype, arrayIteratorPrototype, arrayProtoEntries, arrayProtoForEach, arrayProtoKeys, arrayProtoValues);
        }