Commit fc0dec31 authored by yangguo's avatar yangguo Committed by Commit bot

Use array literals instead of array constructor in native javascript.

R=jkummerow@chromium.org

Review URL: https://codereview.chromium.org/1065863003

Cr-Commit-Position: refs/heads/master@{#27760}
parent e0681f0b
......@@ -106,9 +106,9 @@ function SetUpArrayIterator() {
%FunctionSetPrototype(ArrayIterator, new $Object());
%FunctionSetInstanceClassName(ArrayIterator, 'Array Iterator');
InstallFunctions(ArrayIterator.prototype, DONT_ENUM, $Array(
InstallFunctions(ArrayIterator.prototype, DONT_ENUM, [
'next', ArrayIteratorNext
));
]);
%FunctionSetName(ArrayIteratorIterator, '[Symbol.iterator]');
%AddNamedProperty(ArrayIterator.prototype, symbolIterator,
ArrayIteratorIterator, DONT_ENUM);
......@@ -121,11 +121,11 @@ SetUpArrayIterator();
function ExtendArrayPrototype() {
%CheckIsBootstrapping();
InstallFunctions($Array.prototype, DONT_ENUM, $Array(
InstallFunctions($Array.prototype, DONT_ENUM, [
// No 'values' since it breaks webcompat: http://crbug.com/409858
'entries', ArrayEntries,
'keys', ArrayKeys
));
]);
%AddNamedProperty($Array.prototype, symbolIterator, ArrayValues, DONT_ENUM);
}
......
......@@ -1521,9 +1521,9 @@ function SetUpArray() {
DONT_ENUM | READ_ONLY);
// Set up non-enumerable functions on the Array object.
InstallFunctions($Array, DONT_ENUM, $Array(
InstallFunctions($Array, DONT_ENUM, [
"isArray", ArrayIsArray
));
]);
var specialFunctions = %SpecialArrayFunctions();
......@@ -1542,7 +1542,7 @@ function SetUpArray() {
// set their names.
// Manipulate the length of some of the functions to meet
// expectations set by ECMA-262 or Mozilla.
InstallFunctions($Array.prototype, DONT_ENUM, $Array(
InstallFunctions($Array.prototype, DONT_ENUM, [
"toString", getFunction("toString", ArrayToString),
"toLocaleString", getFunction("toLocaleString", ArrayToLocaleString),
"join", getFunction("join", ArrayJoin),
......@@ -1564,27 +1564,27 @@ function SetUpArray() {
"lastIndexOf", getFunction("lastIndexOf", ArrayLastIndexOf, 1),
"reduce", getFunction("reduce", ArrayReduce, 1),
"reduceRight", getFunction("reduceRight", ArrayReduceRight, 1)
));
]);
%FinishArrayPrototypeSetup($Array.prototype);
// The internal Array prototype doesn't need to be fancy, since it's never
// exposed to user code.
// Adding only the functions that are actually used.
SetUpLockedPrototype(InternalArray, $Array(), $Array(
SetUpLockedPrototype(InternalArray, $Array(), [
"concat", getFunction("concat", ArrayConcatJS),
"indexOf", getFunction("indexOf", ArrayIndexOf),
"join", getFunction("join", ArrayJoin),
"pop", getFunction("pop", ArrayPop),
"push", getFunction("push", ArrayPush),
"splice", getFunction("splice", ArraySplice)
));
]);
SetUpLockedPrototype(InternalPackedArray, $Array(), $Array(
SetUpLockedPrototype(InternalPackedArray, $Array(), [
"join", getFunction("join", ArrayJoin),
"pop", getFunction("pop", ArrayPop),
"push", getFunction("push", ArrayPush)
));
]);
}
SetUpArray();
......@@ -82,13 +82,13 @@ function SetUpArrayBuffer() {
InstallGetter($ArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLen);
InstallFunctions($ArrayBuffer, DONT_ENUM, $Array(
InstallFunctions($ArrayBuffer, DONT_ENUM, [
"isView", ArrayBufferIsViewJS
));
]);
InstallFunctions($ArrayBuffer.prototype, DONT_ENUM, $Array(
InstallFunctions($ArrayBuffer.prototype, DONT_ENUM, [
"slice", ArrayBufferSlice
));
]);
}
SetUpArrayBuffer();
......@@ -70,9 +70,9 @@ function SetUpSetIterator() {
%SetCode(SetIterator, SetIteratorConstructor);
%FunctionSetPrototype(SetIterator, new $Object());
%FunctionSetInstanceClassName(SetIterator, 'Set Iterator');
InstallFunctions(SetIterator.prototype, DONT_ENUM, $Array(
InstallFunctions(SetIterator.prototype, DONT_ENUM, [
'next', SetIteratorNextJS
));
]);
%FunctionSetName(SetIteratorSymbolIterator, '[Symbol.iterator]');
%AddNamedProperty(SetIterator.prototype, symbolIterator,
......@@ -87,11 +87,11 @@ SetUpSetIterator();
function ExtendSetPrototype() {
%CheckIsBootstrapping();
InstallFunctions($Set.prototype, DONT_ENUM, $Array(
InstallFunctions($Set.prototype, DONT_ENUM, [
'entries', SetEntries,
'keys', SetValues,
'values', SetValues
));
]);
%AddNamedProperty($Set.prototype, symbolIterator, SetValues, DONT_ENUM);
}
......@@ -169,9 +169,9 @@ function SetUpMapIterator() {
%SetCode(MapIterator, MapIteratorConstructor);
%FunctionSetPrototype(MapIterator, new $Object());
%FunctionSetInstanceClassName(MapIterator, 'Map Iterator');
InstallFunctions(MapIterator.prototype, DONT_ENUM, $Array(
InstallFunctions(MapIterator.prototype, DONT_ENUM, [
'next', MapIteratorNextJS
));
]);
%FunctionSetName(MapIteratorSymbolIterator, '[Symbol.iterator]');
%AddNamedProperty(MapIterator.prototype, symbolIterator,
......@@ -186,11 +186,11 @@ SetUpMapIterator();
function ExtendMapPrototype() {
%CheckIsBootstrapping();
InstallFunctions($Map.prototype, DONT_ENUM, $Array(
InstallFunctions($Map.prototype, DONT_ENUM, [
'entries', MapEntries,
'keys', MapKeys,
'values', MapValues
));
]);
%AddNamedProperty($Map.prototype, symbolIterator, MapEntries, DONT_ENUM);
}
......
......@@ -245,13 +245,13 @@ function SetForEach(f, receiver) {
// Set up the non-enumerable functions on the Set prototype object.
InstallGetter($Set.prototype, "size", SetGetSize);
InstallFunctions($Set.prototype, DONT_ENUM, $Array(
InstallFunctions($Set.prototype, DONT_ENUM, [
"add", SetAdd,
"has", SetHas,
"delete", SetDelete,
"clear", SetClearJS,
"forEach", SetForEach
));
]);
// -------------------------------------------------------------------
......@@ -433,13 +433,13 @@ function MapForEach(f, receiver) {
// Set up the non-enumerable functions on the Map prototype object.
InstallGetter($Map.prototype, "size", MapGetSize);
InstallFunctions($Map.prototype, DONT_ENUM, $Array(
InstallFunctions($Map.prototype, DONT_ENUM, [
"get", MapGet,
"set", MapSet,
"has", MapHas,
"delete", MapDelete,
"clear", MapClearJS,
"forEach", MapForEach
));
]);
})();
......@@ -250,7 +250,7 @@ function DatePrintString(date) {
// -------------------------------------------------------------------
// Reused output buffer. Used when parsing date strings.
var parse_buffer = $Array(8);
var parse_buffer = new InternalArray(8);
// ECMA 262 - 15.9.4.2
function DateParse(string) {
......@@ -765,18 +765,18 @@ function CreateDate(time) {
%FunctionSetPrototype(GlobalDate, new GlobalDate(NAN));
// Set up non-enumerable properties of the Date object itself.
InstallFunctions(GlobalDate, DONT_ENUM, $Array(
InstallFunctions(GlobalDate, DONT_ENUM, [
"UTC", DateUTC,
"parse", DateParse,
"now", DateNow
));
]);
// Set up non-enumerable constructor property of the Date prototype object.
%AddNamedProperty(GlobalDate.prototype, "constructor", GlobalDate, DONT_ENUM);
// Set up non-enumerable functions of the Date prototype object and
// set their names.
InstallFunctions(GlobalDate.prototype, DONT_ENUM, $Array(
InstallFunctions(GlobalDate.prototype, DONT_ENUM, [
"toString", DateToString,
"toDateString", DateToDateString,
"toTimeString", DateToTimeString,
......@@ -823,7 +823,7 @@ InstallFunctions(GlobalDate.prototype, DONT_ENUM, $Array(
"setYear", DateSetYear,
"toISOString", DateToISOString,
"toJSON", DateToJSON
));
]);
// Expose to the global scope.
$createDate = CreateDate;
......
......@@ -53,9 +53,9 @@ function HarmonyArrayIncludesExtendArrayPrototype() {
%FunctionSetLength(ArrayIncludes, 1);
// Set up the non-enumerable functions on the Array prototype object.
InstallFunctions($Array.prototype, DONT_ENUM, $Array(
InstallFunctions($Array.prototype, DONT_ENUM, [
"includes", ArrayIncludes
));
]);
}
HarmonyArrayIncludesExtendArrayPrototype();
......@@ -211,10 +211,10 @@ function ArrayOf() {
function HarmonyArrayExtendSymbolPrototype() {
%CheckIsBootstrapping();
InstallConstants(global.Symbol, $Array(
InstallConstants(global.Symbol, [
// TODO(dslomov, caitp): Move to symbol.js when shipping
"isConcatSpreadable", symbolIsConcatSpreadable
));
]);
}
HarmonyArrayExtendSymbolPrototype();
......@@ -225,17 +225,17 @@ function HarmonyArrayExtendArrayPrototype() {
%FunctionSetLength(ArrayFrom, 1);
// Set up non-enumerable functions on the Array object.
InstallFunctions($Array, DONT_ENUM, $Array(
InstallFunctions($Array, DONT_ENUM, [
"from", ArrayFrom,
"of", ArrayOf
));
]);
// Set up the non-enumerable functions on the Array prototype object.
InstallFunctions($Array.prototype, DONT_ENUM, $Array(
InstallFunctions($Array.prototype, DONT_ENUM, [
"find", ArrayFind,
"findIndex", ArrayFindIndex,
"fill", ArrayFill
));
]);
}
HarmonyArrayExtendArrayPrototype();
......@@ -9,10 +9,10 @@ var $Reflect = global.Reflect;
function SetUpReflect() {
%CheckIsBootstrapping();
InstallFunctions($Reflect, DONT_ENUM, $Array(
InstallFunctions($Reflect, DONT_ENUM, [
"apply", ReflectApply,
"construct", ReflectConstruct
));
]);
}
SetUpReflect();
......@@ -7,10 +7,10 @@
function HarmonyToStringExtendSymbolPrototype() {
%CheckIsBootstrapping();
InstallConstants(global.Symbol, $Array(
InstallConstants(global.Symbol, [
// TODO(dslomov, caitp): Move to symbol.js when shipping
"toStringTag", symbolToStringTag
));
]);
}
HarmonyToStringExtendSymbolPrototype();
......@@ -79,14 +79,14 @@ macro EXTEND_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE)
%CheckIsBootstrapping();
// Set up non-enumerable functions on the object.
InstallFunctions(global.NAME, DONT_ENUM | DONT_DELETE | READ_ONLY, $Array(
InstallFunctions(global.NAME, DONT_ENUM | DONT_DELETE | READ_ONLY, [
"of", NAMEOf
));
]);
// Set up non-enumerable functions on the prototype object.
InstallFunctions(global.NAME.prototype, DONT_ENUM, $Array(
InstallFunctions(global.NAME.prototype, DONT_ENUM, [
"forEach", NAMEForEach
));
]);
endmacro
TYPED_ARRAYS(EXTEND_TYPED_ARRAY)
......
......@@ -49,7 +49,7 @@ function JSONParse(text, reviver) {
function SerializeArray(value, replacer, stack, indent, gap) {
if (!%PushIfAbsent(stack, value)) {
throw MakeTypeError('circular_structure', $Array());
throw MakeTypeError('circular_structure', []);
}
var stepback = indent;
indent += gap;
......@@ -79,7 +79,7 @@ function SerializeArray(value, replacer, stack, indent, gap) {
function SerializeObject(value, replacer, stack, indent, gap) {
if (!%PushIfAbsent(stack, value)) {
throw MakeTypeError('circular_structure', $Array());
throw MakeTypeError('circular_structure', []);
}
var stepback = indent;
indent += gap;
......@@ -223,10 +223,10 @@ function SetUpJSON() {
%AddNamedProperty($JSON, symbolToStringTag, "JSON", READ_ONLY | DONT_ENUM);
// Set up non-enumerable properties of the JSON object.
InstallFunctions($JSON, DONT_ENUM, $Array(
InstallFunctions($JSON, DONT_ENUM, [
"parse", JSONParse,
"stringify", JSONStringify
));
]);
}
SetUpJSON();
......
......@@ -17,7 +17,6 @@ var $min;
%CheckIsBootstrapping();
var GlobalObject = global.Object;
var GlobalArray = global.Array;
//-------------------------------------------------------------------
......@@ -295,7 +294,7 @@ var Math = new MathConstructor();
%AddNamedProperty(Math, symbolToStringTag, "Math", READ_ONLY | DONT_ENUM);
// Set up math constants.
InstallConstants(Math, GlobalArray(
InstallConstants(Math, [
// ECMA-262, section 15.8.1.1.
"E", 2.7182818284590452354,
// ECMA-262, section 15.8.1.2.
......@@ -308,11 +307,11 @@ InstallConstants(Math, GlobalArray(
"PI", 3.1415926535897932,
"SQRT1_2", 0.7071067811865476,
"SQRT2", 1.4142135623730951
));
]);
// Set up non-enumerable functions of the Math object and
// set their names.
InstallFunctions(Math, DONT_ENUM, GlobalArray(
InstallFunctions(Math, DONT_ENUM, [
"random", MathRandom,
"abs", MathAbs,
"acos", MathAcosJS,
......@@ -339,7 +338,7 @@ InstallFunctions(Math, DONT_ENUM, GlobalArray(
"fround", MathFroundJS,
"clz32", MathClz32JS,
"cbrt", MathCbrt
));
]);
%SetInlineBuiltinFlag(MathAbs);
%SetInlineBuiltinFlag(MathAcosJS);
......
......@@ -615,10 +615,15 @@ function ScriptNameOrSourceURL() {
}
SetUpLockedPrototype(Script,
$Array("source", "name", "source_url", "source_mapping_url", "line_ends",
"line_offset", "column_offset"),
$Array(
SetUpLockedPrototype(Script, [
"source",
"name",
"source_url",
"source_mapping_url",
"line_ends",
"line_offset",
"column_offset"
], [
"lineFromPosition", ScriptLineFromPosition,
"locationFromPosition", ScriptLocationFromPosition,
"locationFromLine", ScriptLocationFromLine,
......@@ -626,7 +631,7 @@ SetUpLockedPrototype(Script,
"sourceLine", ScriptSourceLine,
"lineCount", ScriptLineCount,
"nameOrSourceURL", ScriptNameOrSourceURL
)
]
);
......@@ -675,10 +680,8 @@ function SourceLocationSourceText() {
SetUpLockedPrototype(SourceLocation,
$Array("script", "position", "line", "column", "start", "end"),
$Array(
"sourceText", SourceLocationSourceText
)
["script", "position", "line", "column", "start", "end"],
["sourceText", SourceLocationSourceText]
);
......@@ -721,8 +724,8 @@ function SourceSliceSourceText() {
}
SetUpLockedPrototype(SourceSlice,
$Array("script", "from_line", "to_line", "from_position", "to_position"),
$Array("sourceText", SourceSliceSourceText)
["script", "from_line", "to_line", "from_position", "to_position"],
["sourceText", SourceSliceSourceText]
);
......@@ -953,7 +956,7 @@ function CallSiteToString() {
return line;
}
SetUpLockedPrototype(CallSite, $Array("receiver", "fun", "pos"), $Array(
SetUpLockedPrototype(CallSite, ["receiver", "fun", "pos"], [
"getThis", CallSiteGetThis,
"getTypeName", CallSiteGetTypeName,
"isToplevel", CallSiteIsToplevel,
......@@ -970,7 +973,7 @@ SetUpLockedPrototype(CallSite, $Array("receiver", "fun", "pos"), $Array(
"getPosition", CallSiteGetPosition,
"isConstructor", CallSiteIsConstructor,
"toString", CallSiteToString
));
]);
function FormatEvalOrigin(script) {
......
......@@ -594,20 +594,20 @@ function ObserveMicrotaskRunner() {
function SetupObjectObserve() {
%CheckIsBootstrapping();
InstallFunctions($Object, DONT_ENUM, $Array(
InstallFunctions($Object, DONT_ENUM, [
"deliverChangeRecords", ObjectDeliverChangeRecords,
"getNotifier", ObjectGetNotifier,
"observe", ObjectObserve,
"unobserve", ObjectUnobserve
));
InstallFunctions($Array, DONT_ENUM, $Array(
]);
InstallFunctions($Array, DONT_ENUM, [
"observe", ArrayObserve,
"unobserve", ArrayUnobserve
));
InstallFunctions(notifierPrototype, DONT_ENUM, $Array(
]);
InstallFunctions(notifierPrototype, DONT_ENUM, [
"notify", ObjectNotifierNotify,
"performChange", ObjectNotifierPerformChange
));
]);
}
SetupObjectObserve();
......@@ -14,7 +14,6 @@ var harmony_unicode_regexps = false;
%CheckIsBootstrapping();
var GlobalRegExp = global.RegExp;
var GlobalArray = global.Array;
// Property of the builtins object for recording the result of the last
// regexp match. The property $regexpLastMatchInfo includes the matchIndices
......@@ -364,12 +363,12 @@ function RegExpMakeCaptureGetter(n) {
GlobalRegExp.prototype, 'constructor', GlobalRegExp, DONT_ENUM);
%SetCode(GlobalRegExp, RegExpConstructor);
InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, GlobalArray(
InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, [
"exec", RegExpExecJS,
"test", RegExpTest,
"toString", RegExpToString,
"compile", RegExpCompileJS
));
]);
// The length of compile is 1 in SpiderMonkey.
%FunctionSetLength(GlobalRegExp.prototype.compile, 1);
......
......@@ -1576,6 +1576,12 @@ void PartialSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code,
FlushSkip(skip);
// Clear literal boilerplates.
if (obj->IsJSFunction() && !JSFunction::cast(obj)->shared()->bound()) {
FixedArray* literals = JSFunction::cast(obj)->literals();
for (int i = 0; i < literals->length(); i++) literals->set_undefined(i);
}
// Object has not yet been serialized. Serialize it here.
ObjectSerializer serializer(this, obj, sink_, how_to_code, where_to_point);
serializer.Serialize();
......
......@@ -8,7 +8,6 @@
%CheckIsBootstrapping();
var GlobalArray = global.Array;
var GlobalObject = global.Object;
var GlobalString = global.String;
......@@ -89,9 +88,9 @@ function StringPrototypeIterator() {
%FunctionSetPrototype(StringIterator, new GlobalObject());
%FunctionSetInstanceClassName(StringIterator, 'String Iterator');
InstallFunctions(StringIterator.prototype, DONT_ENUM, GlobalArray(
InstallFunctions(StringIterator.prototype, DONT_ENUM, [
'next', StringIteratorNext
));
]);
%FunctionSetName(StringIteratorIterator, '[Symbol.iterator]');
%AddNamedProperty(StringIterator.prototype, symbolIterator,
StringIteratorIterator, DONT_ENUM);
......
......@@ -10,7 +10,6 @@ var $stringSubstring;
%CheckIsBootstrapping();
var GlobalArray = global.Array;
var GlobalRegExp = global.RegExp;
var GlobalString = global.String;
......@@ -1125,14 +1124,14 @@ function StringRaw(callSite) {
GlobalString.prototype, "constructor", GlobalString, DONT_ENUM);
// Set up the non-enumerable functions on the String object.
InstallFunctions(GlobalString, DONT_ENUM, GlobalArray(
InstallFunctions(GlobalString, DONT_ENUM, [
"fromCharCode", StringFromCharCode,
"fromCodePoint", StringFromCodePoint,
"raw", StringRaw
));
]);
// Set up the non-enumerable functions on the String prototype object.
InstallFunctions(GlobalString.prototype, DONT_ENUM, GlobalArray(
InstallFunctions(GlobalString.prototype, DONT_ENUM, [
"valueOf", StringValueOf,
"toString", StringToString,
"charAt", StringCharAtJS,
......@@ -1175,7 +1174,7 @@ InstallFunctions(GlobalString.prototype, DONT_ENUM, GlobalArray(
"strike", StringStrike,
"sub", StringSub,
"sup", StringSup
));
]);
$stringCharAt = StringCharAtJS;
$stringIndexOf = StringIndexOfJS;
......
......@@ -18,7 +18,6 @@ var $symbolToString;
%CheckIsBootstrapping();
var GlobalArray = global.Array;
var GlobalObject = global.Object;
var GlobalSymbol = global.Symbol;
......@@ -84,7 +83,7 @@ function ObjectGetOwnPropertySymbols(obj) {
%SetCode(GlobalSymbol, SymbolConstructor);
%FunctionSetPrototype(GlobalSymbol, new GlobalObject());
InstallConstants(GlobalSymbol, GlobalArray(
InstallConstants(GlobalSymbol, [
// TODO(rossberg): expose when implemented.
// "hasInstance", symbolHasInstance,
// "isConcatSpreadable", symbolIsConcatSpreadable,
......@@ -94,26 +93,26 @@ InstallConstants(GlobalSymbol, GlobalArray(
// Move here when shipping
// "toStringTag", symbolToStringTag,
"unscopables", symbolUnscopables
));
]);
InstallFunctions(GlobalSymbol, DONT_ENUM, GlobalArray(
InstallFunctions(GlobalSymbol, DONT_ENUM, [
"for", SymbolFor,
"keyFor", SymbolKeyFor
));
]);
%AddNamedProperty(
GlobalSymbol.prototype, "constructor", GlobalSymbol, DONT_ENUM);
%AddNamedProperty(
GlobalSymbol.prototype, symbolToStringTag, "Symbol", DONT_ENUM | READ_ONLY);
InstallFunctions(GlobalSymbol.prototype, DONT_ENUM, GlobalArray(
InstallFunctions(GlobalSymbol.prototype, DONT_ENUM, [
"toString", SymbolToString,
"valueOf", SymbolValueOf
));
]);
InstallFunctions(GlobalObject, DONT_ENUM, GlobalArray(
InstallFunctions(GlobalObject, DONT_ENUM, [
"getOwnPropertySymbols", ObjectGetOwnPropertySymbols
));
]);
$symbolToString = SymbolToString;
......
......@@ -33,7 +33,6 @@ var rempio2result;
%CheckIsBootstrapping();
var GlobalMath = global.Math;
var GlobalArray = global.Array;
//-------------------------------------------------------------------
......@@ -887,12 +886,12 @@ function MathLog10(x) {
if (hx >= 0x7ff00000) return x;
k += (hx >> 20) - 1023;
i = (k & 0x80000000) >> 31;
var i = (k & 0x80000000) >> 31;
hx = (hx & 0x000fffff) | ((0x3ff - i) << 20);
y = k + i;
var y = k + i;
x = %_ConstructDouble(hx, lx);
z = y * LOG10_2LO + IVLN10 * %_MathLogRT(x);
var z = y * LOG10_2LO + IVLN10 * %_MathLogRT(x);
return z + y * LOG10_2HI;
}
......@@ -1013,7 +1012,7 @@ function MathLog2(x) {
//-------------------------------------------------------------------
InstallFunctions(GlobalMath, DONT_ENUM, GlobalArray(
InstallFunctions(GlobalMath, DONT_ENUM, [
"cos", MathCos,
"sin", MathSin,
"tan", MathTan,
......@@ -1023,7 +1022,7 @@ InstallFunctions(GlobalMath, DONT_ENUM, GlobalArray(
"log2", MathLog2,
"log1p", MathLog1p,
"expm1", MathExpm1
));
]);
%SetInlineBuiltinFlag(MathSin);
%SetInlineBuiltinFlag(MathCos);
......
......@@ -322,10 +322,10 @@ macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE)
DONT_ENUM | DONT_DELETE);
InstallGetter(global.NAME.prototype, symbolToStringTag,
TypedArrayGetToStringTag);
InstallFunctions(global.NAME.prototype, DONT_ENUM, $Array(
InstallFunctions(global.NAME.prototype, DONT_ENUM, [
"subarray", NAMESubArray,
"set", TypedArraySet
));
]);
endmacro
TYPED_ARRAYS(SETUP_TYPED_ARRAY)
......@@ -455,7 +455,7 @@ function SetupDataView() {
InstallGetter($DataView.prototype, "byteOffset", DataViewGetByteOffset);
InstallGetter($DataView.prototype, "byteLength", DataViewGetByteLength);
InstallFunctions($DataView.prototype, DONT_ENUM, $Array(
InstallFunctions($DataView.prototype, DONT_ENUM, [
"getInt8", DataViewGetInt8JS,
"setInt8", DataViewSetInt8JS,
......@@ -479,7 +479,7 @@ function SetupDataView() {
"getFloat64", DataViewGetFloat64JS,
"setFloat64", DataViewSetFloat64JS
));
]);
}
SetupDataView();
......@@ -376,13 +376,13 @@ function URIEncodeComponent(component) {
// Set up non-enumerable URI functions on the global object and set
// their names.
InstallFunctions(global, DONT_ENUM, GlobalArray(
InstallFunctions(global, DONT_ENUM, [
"escape", URIEscapeJS,
"unescape", URIUnescapeJS,
"decodeURI", URIDecode,
"decodeURIComponent", URIDecodeComponent,
"encodeURI", URIEncode,
"encodeURIComponent", URIEncodeComponent
));
]);
})();
......@@ -201,13 +201,13 @@ function SetUpGlobal() {
%AddNamedProperty(global, "undefined", UNDEFINED, attributes);
// Set up non-enumerable function on the global object.
InstallFunctions(global, DONT_ENUM, $Array(
InstallFunctions(global, DONT_ENUM, [
"isNaN", GlobalIsNaN,
"isFinite", GlobalIsFinite,
"parseInt", GlobalParseInt,
"parseFloat", GlobalParseFloat,
"eval", GlobalEval
));
]);
}
SetUpGlobal();
......@@ -508,7 +508,7 @@ function PropertyDescriptor() {
this.hasSetter_ = false;
}
SetUpLockedPrototype(PropertyDescriptor, $Array(
SetUpLockedPrototype(PropertyDescriptor, [
"value_",
"hasValue_",
"writable_",
......@@ -521,7 +521,7 @@ SetUpLockedPrototype(PropertyDescriptor, $Array(
"hasGetter_",
"set_",
"hasSetter_"
), $Array(
], [
"toString", function PropertyDescriptor_ToString() {
return "[object PropertyDescriptor]";
},
......@@ -585,7 +585,8 @@ SetUpLockedPrototype(PropertyDescriptor, $Array(
},
"hasSetter", function PropertyDescriptor_HasSetter() {
return this.hasSetter_;
}));
}
]);
// Converts an array returned from Runtime_GetOwnProperty to an actual
......@@ -1429,7 +1430,7 @@ function SetUpObject() {
%AddNamedProperty($Object.prototype, "constructor", $Object, DONT_ENUM);
// Set up non-enumerable functions on the Object.prototype object.
InstallFunctions($Object.prototype, DONT_ENUM, $Array(
InstallFunctions($Object.prototype, DONT_ENUM, [
"toString", ObjectToString,
"toLocaleString", ObjectToLocaleString,
"valueOf", ObjectValueOf,
......@@ -1440,12 +1441,12 @@ function SetUpObject() {
"__lookupGetter__", ObjectLookupGetter,
"__defineSetter__", ObjectDefineSetter,
"__lookupSetter__", ObjectLookupSetter
));
]);
InstallGetterSetter($Object.prototype, "__proto__",
ObjectGetProto, ObjectSetProto);
// Set up non-enumerable functions in the Object object.
InstallFunctions($Object, DONT_ENUM, $Array(
InstallFunctions($Object, DONT_ENUM, [
"keys", ObjectKeys,
"create", ObjectCreate,
"defineProperty", ObjectDefineProperty,
......@@ -1464,7 +1465,7 @@ function SetUpObject() {
"seal", ObjectSealJS
// deliverChangeRecords, getNotifier, observe and unobserve are added
// in object-observe.js.
));
]);
}
SetUpObject();
......@@ -1515,10 +1516,10 @@ function SetUpBoolean () {
%FunctionSetPrototype($Boolean, new $Object());
%AddNamedProperty($Boolean.prototype, "constructor", $Boolean, DONT_ENUM);
InstallFunctions($Boolean.prototype, DONT_ENUM, $Array(
InstallFunctions($Boolean.prototype, DONT_ENUM, [
"toString", BooleanToString,
"valueOf", BooleanValueOf
));
]);
}
SetUpBoolean();
......@@ -1697,7 +1698,7 @@ function SetUpNumber() {
// Set up the constructor property on the Number prototype object.
%AddNamedProperty($Number.prototype, "constructor", $Number, DONT_ENUM);
InstallConstants($Number, $Array(
InstallConstants($Number, [
// ECMA-262 section 15.7.3.1.
"MAX_VALUE", 1.7976931348623157e+308,
// ECMA-262 section 15.7.3.2.
......@@ -1714,27 +1715,27 @@ function SetUpNumber() {
"MAX_SAFE_INTEGER", %_MathPow(2, 53) - 1,
"MIN_SAFE_INTEGER", -%_MathPow(2, 53) + 1,
"EPSILON", %_MathPow(2, -52)
));
]);
// Set up non-enumerable functions on the Number prototype object.
InstallFunctions($Number.prototype, DONT_ENUM, $Array(
InstallFunctions($Number.prototype, DONT_ENUM, [
"toString", NumberToStringJS,
"toLocaleString", NumberToLocaleString,
"valueOf", NumberValueOf,
"toFixed", NumberToFixedJS,
"toExponential", NumberToExponentialJS,
"toPrecision", NumberToPrecisionJS
));
]);
// Harmony Number constructor additions
InstallFunctions($Number, DONT_ENUM, $Array(
InstallFunctions($Number, DONT_ENUM, [
"isFinite", NumberIsFinite,
"isInteger", NumberIsInteger,
"isNaN", NumberIsNaN,
"isSafeInteger", NumberIsSafeInteger,
"parseInt", GlobalParseInt,
"parseFloat", GlobalParseFloat
));
]);
%SetInlineBuiltinFlag(NumberIsNaN);
}
......@@ -1893,10 +1894,10 @@ function SetUpFunction() {
%SetCode($Function, FunctionConstructor);
%AddNamedProperty($Function.prototype, "constructor", $Function, DONT_ENUM);
InstallFunctions($Function.prototype, DONT_ENUM, $Array(
InstallFunctions($Function.prototype, DONT_ENUM, [
"bind", FunctionBind,
"toString", FunctionToString
));
]);
}
SetUpFunction();
......
......@@ -91,12 +91,12 @@ function SetUpWeakMap() {
$WeakMap.prototype, symbolToStringTag, "WeakMap", DONT_ENUM | READ_ONLY);
// Set up the non-enumerable functions on the WeakMap prototype object.
InstallFunctions($WeakMap.prototype, DONT_ENUM, $Array(
InstallFunctions($WeakMap.prototype, DONT_ENUM, [
"get", WeakMapGet,
"set", WeakMapSet,
"has", WeakMapHas,
"delete", WeakMapDelete
));
]);
}
SetUpWeakMap();
......@@ -168,11 +168,11 @@ function SetUpWeakSet() {
$WeakSet.prototype, symbolToStringTag, "WeakSet", DONT_ENUM | READ_ONLY);
// Set up the non-enumerable functions on the WeakSet prototype object.
InstallFunctions($WeakSet.prototype, DONT_ENUM, $Array(
InstallFunctions($WeakSet.prototype, DONT_ENUM, [
"add", WeakSetAdd,
"has", WeakSetHas,
"delete", WeakSetDelete
));
]);
}
SetUpWeakSet();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment