Revert of Revert of Hook up more import/exports in natives. (patchset #1 id:1 of https://codereview.chromium.org/1154743003/)
Reason for revert: Unrelated failure that was uncovered by this CL has been fixed (https://codereview.chromium.org/1152243002/) Original issue's description: > Revert of Hook up more import/exports in natives. (patchset #3 id:40001 of https://codereview.chromium.org/1154483002/) > > Reason for revert: > [Sheriff] Speculative revert for gc stress failures: > http://build.chromium.org/p/client.v8/builders/V8%20Linux64%20GC%20Stress%20-%20custom%20snapshot/builds/481 > > Original issue's description: > > Hook up more import/exports in natives. > > > > R=jkummerow@chromium.org > > > > Committed: https://crrev.com/7a918ac9658d11778f39593bfcc19d7c506defd9 > > Cr-Commit-Position: refs/heads/master@{#28573} > > > > Committed: https://crrev.com/e13a39dd7f4062898709d7c68900677df0513995 > > Cr-Commit-Position: refs/heads/master@{#28578} > > TBR=jkummerow@chromium.org,erik.corry@gmail.com,yangguo@chromium.org > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > > Committed: https://crrev.com/eb0024d1dbdda5f51b006dd54887404ee6c5cbfc > Cr-Commit-Position: refs/heads/master@{#28584} TBR=jkummerow@chromium.org,erik.corry@gmail.com,machenbach@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/1149773003 Cr-Commit-Position: refs/heads/master@{#28608}
This commit is contained in:
parent
61a5962bd3
commit
5cb925e448
@ -2,7 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
var $iteratorCreateResultObject;
|
||||
var $arrayValues;
|
||||
|
||||
(function(global, utils) {
|
||||
@ -124,16 +123,16 @@ function ArrayKeys() {
|
||||
%FunctionSetPrototype(ArrayIterator, {__proto__: $iteratorPrototype});
|
||||
%FunctionSetInstanceClassName(ArrayIterator, 'Array Iterator');
|
||||
|
||||
$installFunctions(ArrayIterator.prototype, DONT_ENUM, [
|
||||
utils.InstallFunctions(ArrayIterator.prototype, DONT_ENUM, [
|
||||
'next', ArrayIteratorNext
|
||||
]);
|
||||
$setFunctionName(ArrayIteratorIterator, symbolIterator);
|
||||
utils.SetFunctionName(ArrayIteratorIterator, symbolIterator);
|
||||
%AddNamedProperty(ArrayIterator.prototype, symbolIterator,
|
||||
ArrayIteratorIterator, DONT_ENUM);
|
||||
%AddNamedProperty(ArrayIterator.prototype, symbolToStringTag,
|
||||
"Array Iterator", READ_ONLY | DONT_ENUM);
|
||||
|
||||
$installFunctions(GlobalArray.prototype, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
|
||||
// No 'values' since it breaks webcompat: http://crbug.com/409858
|
||||
'entries', ArrayEntries,
|
||||
'keys', ArrayKeys
|
||||
@ -152,7 +151,13 @@ endmacro
|
||||
|
||||
TYPED_ARRAYS(EXTEND_TYPED_ARRAY)
|
||||
|
||||
$iteratorCreateResultObject = CreateIteratorResultObject;
|
||||
// -------------------------------------------------------------------
|
||||
// Exports
|
||||
|
||||
utils.Export(function(to) {
|
||||
to.ArrayIteratorCreateResultObject = CreateIteratorResultObject;
|
||||
});
|
||||
|
||||
$arrayValues = ArrayValues;
|
||||
|
||||
})
|
||||
|
67
src/array.js
67
src/array.js
@ -3,22 +3,12 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
var $arrayConcat;
|
||||
var $arrayJoin;
|
||||
var $arrayPush;
|
||||
var $arrayPop;
|
||||
var $arrayShift;
|
||||
var $arraySlice;
|
||||
var $arraySplice;
|
||||
var $arrayUnshift;
|
||||
var $innerArrayForEach;
|
||||
var $innerArrayEvery;
|
||||
var $innerArrayFilter;
|
||||
var $innerArrayIndexOf;
|
||||
var $innerArrayLastIndexOf;
|
||||
var $innerArrayMap;
|
||||
var $innerArrayReverse;
|
||||
var $innerArraySome;
|
||||
var $innerArraySort;
|
||||
|
||||
(function(global, utils) {
|
||||
|
||||
@ -33,10 +23,20 @@ var GlobalArray = global.Array;
|
||||
var InternalArray = utils.InternalArray;
|
||||
var InternalPackedArray = utils.InternalPackedArray;
|
||||
|
||||
var Delete;
|
||||
var MathMin;
|
||||
var ObjectHasOwnProperty;
|
||||
var ObjectIsFrozen;
|
||||
var ObjectIsSealed;
|
||||
var ObjectToString;
|
||||
|
||||
utils.Import(function(from) {
|
||||
Delete = from.Delete;
|
||||
MathMin = from.MathMin;
|
||||
ObjectHasOwnProperty = from.ObjectHasOwnProperty;
|
||||
ObjectIsFrozen = from.ObjectIsFrozen;
|
||||
ObjectIsSealed = from.ObjectIsSealed;
|
||||
ObjectToString = from.ObjectToString;
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
@ -392,7 +392,7 @@ function ArrayToString() {
|
||||
func = array.join;
|
||||
}
|
||||
if (!IS_SPEC_FUNCTION(func)) {
|
||||
return %_CallFunction(array, $objectToString);
|
||||
return %_CallFunction(array, ObjectToString);
|
||||
}
|
||||
return %_CallFunction(array, func);
|
||||
}
|
||||
@ -467,7 +467,7 @@ function ArrayPop() {
|
||||
|
||||
n--;
|
||||
var value = array[n];
|
||||
$delete(array, $toName(n), true);
|
||||
Delete(array, $toName(n), true);
|
||||
array.length = n;
|
||||
return value;
|
||||
}
|
||||
@ -645,7 +645,7 @@ function ArrayShift() {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($objectIsSealed(array)) throw MakeTypeError(kArrayFunctionsOnSealed);
|
||||
if (ObjectIsSealed(array)) throw MakeTypeError(kArrayFunctionsOnSealed);
|
||||
|
||||
if (%IsObserved(array))
|
||||
return ObservedArrayShift.call(array, len);
|
||||
@ -696,7 +696,7 @@ function ArrayUnshift(arg1) { // length == 1
|
||||
var num_arguments = %_ArgumentsLength();
|
||||
|
||||
if (len > 0 && UseSparseVariant(array, len, IS_ARRAY(array), len) &&
|
||||
!$objectIsSealed(array)) {
|
||||
!ObjectIsSealed(array)) {
|
||||
SparseMove(array, 0, 0, len, num_arguments);
|
||||
} else {
|
||||
SimpleMove(array, 0, 0, len, num_arguments);
|
||||
@ -842,9 +842,9 @@ function ArraySplice(start, delete_count) {
|
||||
deleted_elements.length = del_count;
|
||||
var num_elements_to_add = num_arguments > 2 ? num_arguments - 2 : 0;
|
||||
|
||||
if (del_count != num_elements_to_add && $objectIsSealed(array)) {
|
||||
if (del_count != num_elements_to_add && ObjectIsSealed(array)) {
|
||||
throw MakeTypeError(kArrayFunctionsOnSealed);
|
||||
} else if (del_count > 0 && $objectIsFrozen(array)) {
|
||||
} else if (del_count > 0 && ObjectIsFrozen(array)) {
|
||||
throw MakeTypeError(kArrayFunctionsOnFrozen);
|
||||
}
|
||||
|
||||
@ -1582,7 +1582,7 @@ var unscopables = {
|
||||
DONT_ENUM | READ_ONLY);
|
||||
|
||||
// Set up non-enumerable functions on the Array object.
|
||||
$installFunctions(GlobalArray, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalArray, DONT_ENUM, [
|
||||
"isArray", ArrayIsArray
|
||||
]);
|
||||
|
||||
@ -1603,7 +1603,7 @@ var getFunction = function(name, jsBuiltin, len) {
|
||||
// set their names.
|
||||
// Manipulate the length of some of the functions to meet
|
||||
// expectations set by ECMA-262 or Mozilla.
|
||||
$installFunctions(GlobalArray.prototype, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
|
||||
"toString", getFunction("toString", ArrayToString),
|
||||
"toLocaleString", getFunction("toLocaleString", ArrayToLocaleString),
|
||||
"join", getFunction("join", ArrayJoin),
|
||||
@ -1632,7 +1632,7 @@ $installFunctions(GlobalArray.prototype, DONT_ENUM, [
|
||||
// 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, GlobalArray(), [
|
||||
utils.SetUpLockedPrototype(InternalArray, GlobalArray(), [
|
||||
"concat", getFunction("concat", ArrayConcatJS),
|
||||
"indexOf", getFunction("indexOf", ArrayIndexOf),
|
||||
"join", getFunction("join", ArrayJoin),
|
||||
@ -1642,15 +1642,30 @@ $setUpLockedPrototype(InternalArray, GlobalArray(), [
|
||||
"splice", getFunction("splice", ArraySplice)
|
||||
]);
|
||||
|
||||
$setUpLockedPrototype(InternalPackedArray, GlobalArray(), [
|
||||
utils.SetUpLockedPrototype(InternalPackedArray, GlobalArray(), [
|
||||
"join", getFunction("join", ArrayJoin),
|
||||
"pop", getFunction("pop", ArrayPop),
|
||||
"push", getFunction("push", ArrayPush),
|
||||
"shift", getFunction("shift", ArrayShift)
|
||||
]);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Exports
|
||||
|
||||
utils.Export(function(to) {
|
||||
to.ArrayJoin = ArrayJoin;
|
||||
to.InnerArrayEvery = InnerArrayEvery;
|
||||
to.InnerArrayFilter = InnerArrayFilter;
|
||||
to.InnerArrayForEach = InnerArrayForEach;
|
||||
to.InnerArrayIndexOf = InnerArrayIndexOf;
|
||||
to.InnerArrayLastIndexOf = InnerArrayLastIndexOf;
|
||||
to.InnerArrayMap = InnerArrayMap;
|
||||
to.InnerArrayReverse = InnerArrayReverse;
|
||||
to.InnerArraySome = InnerArraySome;
|
||||
to.InnerArraySort = InnerArraySort;
|
||||
});
|
||||
|
||||
$arrayConcat = ArrayConcatJS;
|
||||
$arrayJoin = ArrayJoin;
|
||||
$arrayPush = ArrayPush;
|
||||
$arrayPop = ArrayPop;
|
||||
$arrayShift = ArrayShift;
|
||||
@ -1658,14 +1673,4 @@ $arraySlice = ArraySlice;
|
||||
$arraySplice = ArraySplice;
|
||||
$arrayUnshift = ArrayUnshift;
|
||||
|
||||
$innerArrayEvery = InnerArrayEvery;
|
||||
$innerArrayFilter = InnerArrayFilter;
|
||||
$innerArrayForEach = InnerArrayForEach;
|
||||
$innerArrayIndexOf = InnerArrayIndexOf;
|
||||
$innerArrayLastIndexOf = InnerArrayLastIndexOf;
|
||||
$innerArrayMap = InnerArrayMap;
|
||||
$innerArrayReverse = InnerArrayReverse;
|
||||
$innerArraySome = InnerArraySome;
|
||||
$innerArraySort = InnerArraySort;
|
||||
|
||||
});
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Imports
|
||||
|
||||
@ -95,13 +94,13 @@ function ArrayBufferIsViewJS(obj) {
|
||||
%AddNamedProperty(GlobalArrayBuffer.prototype,
|
||||
symbolToStringTag, "ArrayBuffer", DONT_ENUM | READ_ONLY);
|
||||
|
||||
$installGetter(GlobalArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLen);
|
||||
utils.InstallGetter(GlobalArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLen);
|
||||
|
||||
$installFunctions(GlobalArrayBuffer, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalArrayBuffer, DONT_ENUM, [
|
||||
"isView", ArrayBufferIsViewJS
|
||||
]);
|
||||
|
||||
$installFunctions(GlobalArrayBuffer.prototype, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalArrayBuffer.prototype, DONT_ENUM, [
|
||||
"slice", ArrayBufferSlice
|
||||
]);
|
||||
|
||||
|
@ -1530,7 +1530,8 @@ bool Genesis::CallUtilsFunction(Isolate* isolate, const char* name) {
|
||||
isolate->factory()->NewStringFromAsciiChecked(name);
|
||||
Handle<Object> fun = JSObject::GetDataProperty(utils, name_string);
|
||||
Handle<Object> receiver = isolate->factory()->undefined_value();
|
||||
return !Execution::Call(isolate, fun, receiver, 0, NULL).is_null();
|
||||
Handle<Object> args[] = {utils};
|
||||
return !Execution::Call(isolate, fun, receiver, 1, args).is_null();
|
||||
}
|
||||
|
||||
|
||||
@ -2446,6 +2447,8 @@ bool Genesis::InstallExperimentalNatives() {
|
||||
#undef INSTALL_EXPERIMENTAL_NATIVES
|
||||
}
|
||||
|
||||
CallUtilsFunction(isolate(), "PostExperimentals");
|
||||
|
||||
InstallExperimentalNativeFunctions();
|
||||
return true;
|
||||
}
|
||||
|
@ -70,14 +70,14 @@ function SetValues() {
|
||||
%SetCode(SetIterator, SetIteratorConstructor);
|
||||
%FunctionSetPrototype(SetIterator, {__proto__: $iteratorPrototype});
|
||||
%FunctionSetInstanceClassName(SetIterator, 'Set Iterator');
|
||||
$installFunctions(SetIterator.prototype, DONT_ENUM, [
|
||||
utils.InstallFunctions(SetIterator.prototype, DONT_ENUM, [
|
||||
'next', SetIteratorNextJS
|
||||
]);
|
||||
|
||||
%AddNamedProperty(SetIterator.prototype, symbolToStringTag,
|
||||
"Set Iterator", READ_ONLY | DONT_ENUM);
|
||||
|
||||
$installFunctions(GlobalSet.prototype, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalSet.prototype, DONT_ENUM, [
|
||||
'entries', SetEntries,
|
||||
'keys', SetValues,
|
||||
'values', SetValues
|
||||
@ -152,7 +152,7 @@ function MapValues() {
|
||||
%SetCode(MapIterator, MapIteratorConstructor);
|
||||
%FunctionSetPrototype(MapIterator, {__proto__: $iteratorPrototype});
|
||||
%FunctionSetInstanceClassName(MapIterator, 'Map Iterator');
|
||||
$installFunctions(MapIterator.prototype, DONT_ENUM, [
|
||||
utils.InstallFunctions(MapIterator.prototype, DONT_ENUM, [
|
||||
'next', MapIteratorNextJS
|
||||
]);
|
||||
|
||||
@ -160,7 +160,7 @@ $installFunctions(MapIterator.prototype, DONT_ENUM, [
|
||||
"Map Iterator", READ_ONLY | DONT_ENUM);
|
||||
|
||||
|
||||
$installFunctions(GlobalMap.prototype, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalMap.prototype, DONT_ENUM, [
|
||||
'entries', MapEntries,
|
||||
'keys', MapKeys,
|
||||
'values', MapValues
|
||||
|
@ -8,10 +8,19 @@
|
||||
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Imports
|
||||
|
||||
var GlobalMap = global.Map;
|
||||
var GlobalObject = global.Object;
|
||||
var GlobalSet = global.Set;
|
||||
|
||||
var NumberIsNaN;
|
||||
|
||||
utils.Import(function(from) {
|
||||
NumberIsNaN = from.NumberIsNaN;
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
function HashToEntry(table, hash, numBuckets) {
|
||||
@ -22,7 +31,7 @@ function HashToEntry(table, hash, numBuckets) {
|
||||
|
||||
|
||||
function SetFindEntry(table, numBuckets, key, hash) {
|
||||
var keyIsNaN = $numberIsNaN(key);
|
||||
var keyIsNaN = NumberIsNaN(key);
|
||||
for (var entry = HashToEntry(table, hash, numBuckets);
|
||||
entry !== NOT_FOUND;
|
||||
entry = ORDERED_HASH_SET_CHAIN_AT(table, entry, numBuckets)) {
|
||||
@ -30,7 +39,7 @@ function SetFindEntry(table, numBuckets, key, hash) {
|
||||
if (key === candidate) {
|
||||
return entry;
|
||||
}
|
||||
if (keyIsNaN && $numberIsNaN(candidate)) {
|
||||
if (keyIsNaN && NumberIsNaN(candidate)) {
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
@ -40,7 +49,7 @@ function SetFindEntry(table, numBuckets, key, hash) {
|
||||
|
||||
|
||||
function MapFindEntry(table, numBuckets, key, hash) {
|
||||
var keyIsNaN = $numberIsNaN(key);
|
||||
var keyIsNaN = NumberIsNaN(key);
|
||||
for (var entry = HashToEntry(table, hash, numBuckets);
|
||||
entry !== NOT_FOUND;
|
||||
entry = ORDERED_HASH_MAP_CHAIN_AT(table, entry, numBuckets)) {
|
||||
@ -48,7 +57,7 @@ function MapFindEntry(table, numBuckets, key, hash) {
|
||||
if (key === candidate) {
|
||||
return entry;
|
||||
}
|
||||
if (keyIsNaN && $numberIsNaN(candidate)) {
|
||||
if (keyIsNaN && NumberIsNaN(candidate)) {
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
@ -239,8 +248,8 @@ function SetForEach(f, receiver) {
|
||||
%FunctionSetLength(SetForEach, 1);
|
||||
|
||||
// Set up the non-enumerable functions on the Set prototype object.
|
||||
$installGetter(GlobalSet.prototype, "size", SetGetSize);
|
||||
$installFunctions(GlobalSet.prototype, DONT_ENUM, [
|
||||
utils.InstallGetter(GlobalSet.prototype, "size", SetGetSize);
|
||||
utils.InstallFunctions(GlobalSet.prototype, DONT_ENUM, [
|
||||
"add", SetAdd,
|
||||
"has", SetHas,
|
||||
"delete", SetDelete,
|
||||
@ -427,8 +436,8 @@ function MapForEach(f, receiver) {
|
||||
%FunctionSetLength(MapForEach, 1);
|
||||
|
||||
// Set up the non-enumerable functions on the Map prototype object.
|
||||
$installGetter(GlobalMap.prototype, "size", MapGetSize);
|
||||
$installFunctions(GlobalMap.prototype, DONT_ENUM, [
|
||||
utils.InstallGetter(GlobalMap.prototype, "size", MapGetSize);
|
||||
utils.InstallFunctions(GlobalMap.prototype, DONT_ENUM, [
|
||||
"get", MapGet,
|
||||
"set", MapSet,
|
||||
"has", MapHas,
|
||||
|
22
src/date.js
22
src/date.js
@ -2,10 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// This file relies on the fact that the following declarations have been made
|
||||
// in v8natives.js:
|
||||
// var $isFinite = GlobalIsFinite;
|
||||
|
||||
var $createDate;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
@ -22,10 +18,12 @@ var $createDate;
|
||||
var GlobalDate = global.Date;
|
||||
var InternalArray = utils.InternalArray;
|
||||
|
||||
var IsFinite;
|
||||
var MathAbs;
|
||||
var MathFloor;
|
||||
|
||||
utils.Import(function(from) {
|
||||
IsFinite = from.IsFinite;
|
||||
MathAbs = from.MathAbs;
|
||||
MathFloor = from.MathFloor;
|
||||
});
|
||||
@ -60,10 +58,10 @@ function UTC(time) {
|
||||
|
||||
// ECMA 262 - 15.9.1.11
|
||||
function MakeTime(hour, min, sec, ms) {
|
||||
if (!$isFinite(hour)) return NAN;
|
||||
if (!$isFinite(min)) return NAN;
|
||||
if (!$isFinite(sec)) return NAN;
|
||||
if (!$isFinite(ms)) return NAN;
|
||||
if (!IsFinite(hour)) return NAN;
|
||||
if (!IsFinite(min)) return NAN;
|
||||
if (!IsFinite(sec)) return NAN;
|
||||
if (!IsFinite(ms)) return NAN;
|
||||
return TO_INTEGER(hour) * msPerHour
|
||||
+ TO_INTEGER(min) * msPerMinute
|
||||
+ TO_INTEGER(sec) * msPerSecond
|
||||
@ -84,7 +82,7 @@ function TimeInYear(year) {
|
||||
// MakeDay(2007, -33, 1) --> MakeDay(2004, 3, 1)
|
||||
// MakeDay(2007, 14, -50) --> MakeDay(2007, 8, 11)
|
||||
function MakeDay(year, month, date) {
|
||||
if (!$isFinite(year) || !$isFinite(month) || !$isFinite(date)) return NAN;
|
||||
if (!IsFinite(year) || !IsFinite(month) || !IsFinite(date)) return NAN;
|
||||
|
||||
// Convert to integer and map -0 to 0.
|
||||
year = TO_INTEGER_MAP_MINUS_ZERO(year);
|
||||
@ -116,7 +114,7 @@ function MakeDate(day, time) {
|
||||
|
||||
// ECMA 262 - 15.9.1.14
|
||||
function TimeClip(time) {
|
||||
if (!$isFinite(time)) return NAN;
|
||||
if (!IsFinite(time)) return NAN;
|
||||
if (MathAbs(time) > MAX_TIME_MS) return NAN;
|
||||
return TO_INTEGER(time);
|
||||
}
|
||||
@ -774,7 +772,7 @@ function CreateDate(time) {
|
||||
%FunctionSetPrototype(GlobalDate, new GlobalDate(NAN));
|
||||
|
||||
// Set up non-enumerable properties of the Date object itself.
|
||||
$installFunctions(GlobalDate, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalDate, DONT_ENUM, [
|
||||
"UTC", DateUTC,
|
||||
"parse", DateParse,
|
||||
"now", DateNow
|
||||
@ -785,7 +783,7 @@ $installFunctions(GlobalDate, DONT_ENUM, [
|
||||
|
||||
// Set up non-enumerable functions of the Date prototype object and
|
||||
// set their names.
|
||||
$installFunctions(GlobalDate.prototype, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalDate.prototype, DONT_ENUM, [
|
||||
"toString", DateToString,
|
||||
"toDateString", DateToDateString,
|
||||
"toTimeString", DateToTimeString,
|
||||
|
@ -8,8 +8,17 @@
|
||||
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Imports
|
||||
|
||||
var GlobalFunction = global.Function;
|
||||
|
||||
var NewFunctionString;
|
||||
|
||||
utils.Import(function(from) {
|
||||
NewFunctionString = from.NewFunctionString;
|
||||
});
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Generator functions and objects are specified by ES6, sections 15.19.3 and
|
||||
@ -67,7 +76,7 @@ function GeneratorObjectThrow(exn) {
|
||||
|
||||
|
||||
function GeneratorFunctionConstructor(arg1) { // length == 1
|
||||
var source = $newFunctionString(arguments, 'function*');
|
||||
var source = NewFunctionString(arguments, 'function*');
|
||||
var global_proxy = %GlobalProxy(GeneratorFunctionConstructor);
|
||||
// Compile the string in the constructor and not a helper so that errors
|
||||
// appear to come from here.
|
||||
@ -85,10 +94,10 @@ function GeneratorFunctionConstructor(arg1) { // length == 1
|
||||
|
||||
// Set up non-enumerable functions on the generator prototype object.
|
||||
var GeneratorObjectPrototype = GeneratorFunctionPrototype.prototype;
|
||||
$installFunctions(GeneratorObjectPrototype,
|
||||
DONT_ENUM,
|
||||
["next", GeneratorObjectNext,
|
||||
"throw", GeneratorObjectThrow]);
|
||||
utils.InstallFunctions(GeneratorObjectPrototype,
|
||||
DONT_ENUM,
|
||||
["next", GeneratorObjectNext,
|
||||
"throw", GeneratorObjectThrow]);
|
||||
|
||||
%AddNamedProperty(GeneratorObjectPrototype, "constructor",
|
||||
GeneratorFunctionPrototype, DONT_ENUM | READ_ONLY);
|
||||
|
@ -52,7 +52,7 @@ function ArrayIncludes(searchElement, fromIndex) {
|
||||
%FunctionSetLength(ArrayIncludes, 1);
|
||||
|
||||
// Set up the non-enumerable functions on the Array prototype object.
|
||||
$installFunctions(GlobalArray.prototype, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
|
||||
"includes", ArrayIncludes
|
||||
]);
|
||||
|
||||
|
@ -2,12 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
var $innerArrayCopyWithin;
|
||||
var $innerArrayFill;
|
||||
var $innerArrayFind;
|
||||
var $innerArrayFindIndex;
|
||||
var $arrayFrom;
|
||||
|
||||
(function(global, utils) {
|
||||
|
||||
'use strict';
|
||||
@ -20,12 +14,18 @@ var $arrayFrom;
|
||||
var GlobalArray = global.Array;
|
||||
var GlobalSymbol = global.Symbol;
|
||||
|
||||
var GetIterator;
|
||||
var GetMethod;
|
||||
var MathMax;
|
||||
var MathMin;
|
||||
var ObjectIsFrozen;
|
||||
|
||||
utils.Import(function(from) {
|
||||
GetIterator = from.GetIterator;
|
||||
GetMethod = from.GetMethod;
|
||||
MathMax = from.MathMax;
|
||||
MathMin = from.MathMin;
|
||||
ObjectIsFrozen = from.ObjectIsFrozen;
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
@ -76,7 +76,6 @@ function InnerArrayCopyWithin(target, start, end, array, length) {
|
||||
|
||||
return array;
|
||||
}
|
||||
$innerArrayCopyWithin = InnerArrayCopyWithin;
|
||||
|
||||
// ES6 draft 03-17-15, section 22.1.3.3
|
||||
function ArrayCopyWithin(target, start, end) {
|
||||
@ -112,7 +111,6 @@ function InnerArrayFind(predicate, thisArg, array, length) {
|
||||
|
||||
return;
|
||||
}
|
||||
$innerArrayFind = InnerArrayFind;
|
||||
|
||||
// ES6 draft 07-15-13, section 15.4.3.23
|
||||
function ArrayFind(predicate, thisArg) {
|
||||
@ -148,7 +146,6 @@ function InnerArrayFindIndex(predicate, thisArg, array, length) {
|
||||
|
||||
return -1;
|
||||
}
|
||||
$innerArrayFindIndex = InnerArrayFindIndex;
|
||||
|
||||
// ES6 draft 07-15-13, section 15.4.3.24
|
||||
function ArrayFindIndex(predicate, thisArg) {
|
||||
@ -179,7 +176,7 @@ function InnerArrayFill(value, start, end, array, length) {
|
||||
if (end > length) end = length;
|
||||
}
|
||||
|
||||
if ((end - i) > 0 && $objectIsFrozen(array)) {
|
||||
if ((end - i) > 0 && ObjectIsFrozen(array)) {
|
||||
throw MakeTypeError(kArrayFunctionsOnFrozen);
|
||||
}
|
||||
|
||||
@ -187,7 +184,6 @@ function InnerArrayFill(value, start, end, array, length) {
|
||||
array[i] = value;
|
||||
return array;
|
||||
}
|
||||
$innerArrayFill = InnerArrayFill;
|
||||
|
||||
// ES6, draft 04-05-14, section 22.1.3.6
|
||||
function ArrayFill(value, start, end) {
|
||||
@ -216,7 +212,7 @@ function ArrayFrom(arrayLike, mapfn, receiver) {
|
||||
}
|
||||
}
|
||||
|
||||
var iterable = $getMethod(items, symbolIterator);
|
||||
var iterable = GetMethod(items, symbolIterator);
|
||||
var k;
|
||||
var result;
|
||||
var mappedValue;
|
||||
@ -225,7 +221,7 @@ function ArrayFrom(arrayLike, mapfn, receiver) {
|
||||
if (!IS_UNDEFINED(iterable)) {
|
||||
result = %IsConstructor(this) ? new this() : [];
|
||||
|
||||
var iterator = $getIterator(items, iterable);
|
||||
var iterator = GetIterator(items, iterable);
|
||||
|
||||
k = 0;
|
||||
while (true) {
|
||||
@ -266,7 +262,6 @@ function ArrayFrom(arrayLike, mapfn, receiver) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
$arrayFrom = ArrayFrom;
|
||||
|
||||
// ES6, draft 05-22-14, section 22.1.2.3
|
||||
function ArrayOf() {
|
||||
@ -283,7 +278,7 @@ function ArrayOf() {
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
$installConstants(GlobalSymbol, [
|
||||
utils.InstallConstants(GlobalSymbol, [
|
||||
// TODO(dslomov, caitp): Move to symbol.js when shipping
|
||||
"isConcatSpreadable", symbolIsConcatSpreadable
|
||||
]);
|
||||
@ -295,17 +290,28 @@ $installConstants(GlobalSymbol, [
|
||||
%FunctionSetLength(ArrayFindIndex, 1);
|
||||
|
||||
// Set up non-enumerable functions on the Array object.
|
||||
$installFunctions(GlobalArray, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalArray, DONT_ENUM, [
|
||||
"from", ArrayFrom,
|
||||
"of", ArrayOf
|
||||
]);
|
||||
|
||||
// Set up the non-enumerable functions on the Array prototype object.
|
||||
$installFunctions(GlobalArray.prototype, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
|
||||
"copyWithin", ArrayCopyWithin,
|
||||
"find", ArrayFind,
|
||||
"findIndex", ArrayFindIndex,
|
||||
"fill", ArrayFill
|
||||
]);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Exports
|
||||
|
||||
utils.Export(function(to) {
|
||||
to.ArrayFrom = ArrayFrom;
|
||||
to.InnerArrayCopyWithin = InnerArrayCopyWithin;
|
||||
to.InnerArrayFill = InnerArrayFill;
|
||||
to.InnerArrayFind = InnerArrayFind;
|
||||
to.InnerArrayFindIndex = InnerArrayFindIndex;
|
||||
});
|
||||
|
||||
})
|
||||
|
@ -9,8 +9,19 @@
|
||||
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Imports
|
||||
|
||||
var GlobalObject = global.Object;
|
||||
|
||||
var OwnPropertyKeys;
|
||||
|
||||
utils.Import(function(from) {
|
||||
OwnPropertyKeys = from.OwnPropertyKeys;
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
// ES6, draft 04-03-15, section 19.1.2.1
|
||||
function ObjectAssign(target, sources) {
|
||||
var to = TO_OBJECT_INLINE(target);
|
||||
@ -24,7 +35,7 @@ function ObjectAssign(target, sources) {
|
||||
}
|
||||
|
||||
var from = TO_OBJECT_INLINE(nextSource);
|
||||
var keys = $ownPropertyKeys(from);
|
||||
var keys = OwnPropertyKeys(from);
|
||||
var len = keys.length;
|
||||
|
||||
for (var j = 0; j < len; ++j) {
|
||||
@ -39,7 +50,7 @@ function ObjectAssign(target, sources) {
|
||||
}
|
||||
|
||||
// Set up non-enumerable functions on the Object object.
|
||||
$installFunctions(GlobalObject, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalObject, DONT_ENUM, [
|
||||
"assign", ObjectAssign
|
||||
]);
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
var GlobalReflect = global.Reflect;
|
||||
|
||||
$installFunctions(GlobalReflect, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalReflect, DONT_ENUM, [
|
||||
"apply", $reflectApply,
|
||||
"construct", $reflectConstruct
|
||||
]);
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
var GlobalSymbol = global.Symbol;
|
||||
|
||||
$installConstants(GlobalSymbol, [
|
||||
utils.InstallConstants(GlobalSymbol, [
|
||||
// TODO(dslomov, caitp): Move to symbol.js when shipping
|
||||
"toStringTag", symbolToStringTag
|
||||
]);
|
||||
|
@ -8,6 +8,9 @@
|
||||
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Imports
|
||||
|
||||
macro TYPED_ARRAYS(FUNCTION)
|
||||
// arrayIds below should be synchronized with Runtime_TypedArrayInitialize.
|
||||
FUNCTION(Uint8Array)
|
||||
@ -28,6 +31,40 @@ endmacro
|
||||
TYPED_ARRAYS(DECLARE_GLOBALS)
|
||||
DECLARE_GLOBALS(Array)
|
||||
|
||||
var ArrayFrom;
|
||||
var InnerArrayCopyWithin;
|
||||
var InnerArrayEvery;
|
||||
var InnerArrayFill;
|
||||
var InnerArrayFilter;
|
||||
var InnerArrayFind;
|
||||
var InnerArrayFindIndex;
|
||||
var InnerArrayForEach;
|
||||
var InnerArrayIndexOf;
|
||||
var InnerArrayLastIndexOf;
|
||||
var InnerArrayMap;
|
||||
var InnerArrayReverse;
|
||||
var InnerArraySome;
|
||||
var InnerArraySort;
|
||||
var IsNaN;
|
||||
|
||||
utils.Import(function(from) {
|
||||
ArrayFrom = from.ArrayFrom;
|
||||
InnerArrayCopyWithin = from.InnerArrayCopyWithin;
|
||||
InnerArrayEvery = from.InnerArrayEvery;
|
||||
InnerArrayFill = from.InnerArrayFill;
|
||||
InnerArrayFilter = from.InnerArrayFilter;
|
||||
InnerArrayFind = from.InnerArrayFind;
|
||||
InnerArrayFindIndex = from.InnerArrayFindIndex;
|
||||
InnerArrayForEach = from.InnerArrayForEach;
|
||||
InnerArrayIndexOf = from.InnerArrayIndexOf;
|
||||
InnerArrayLastIndexOf = from.InnerArrayLastIndexOf;
|
||||
InnerArrayMap = from.InnerArrayMap;
|
||||
InnerArrayReverse = from.InnerArrayReverse;
|
||||
InnerArraySome = from.InnerArraySome;
|
||||
InnerArraySort = from.InnerArraySort;
|
||||
IsNaN = from.IsNaN;
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
function ConstructTypedArray(constructor, array) {
|
||||
@ -58,7 +95,7 @@ function TypedArrayCopyWithin(target, start, end) {
|
||||
var length = %_TypedArrayGetLength(this);
|
||||
|
||||
// TODO(littledan): Replace with a memcpy for better performance
|
||||
return $innerArrayCopyWithin(target, start, end, this, length);
|
||||
return InnerArrayCopyWithin(target, start, end, this, length);
|
||||
}
|
||||
%FunctionSetLength(TypedArrayCopyWithin, 2);
|
||||
|
||||
@ -68,7 +105,7 @@ function TypedArrayEvery(f, receiver) {
|
||||
|
||||
var length = %_TypedArrayGetLength(this);
|
||||
|
||||
return $innerArrayEvery(f, receiver, this, length);
|
||||
return InnerArrayEvery(f, receiver, this, length);
|
||||
}
|
||||
%FunctionSetLength(TypedArrayEvery, 1);
|
||||
|
||||
@ -78,7 +115,7 @@ function TypedArrayForEach(f, receiver) {
|
||||
|
||||
var length = %_TypedArrayGetLength(this);
|
||||
|
||||
$innerArrayForEach(f, receiver, this, length);
|
||||
InnerArrayForEach(f, receiver, this, length);
|
||||
}
|
||||
%FunctionSetLength(TypedArrayForEach, 1);
|
||||
|
||||
@ -88,7 +125,7 @@ function TypedArrayFill(value, start, end) {
|
||||
|
||||
var length = %_TypedArrayGetLength(this);
|
||||
|
||||
return $innerArrayFill(value, start, end, this, length);
|
||||
return InnerArrayFill(value, start, end, this, length);
|
||||
}
|
||||
%FunctionSetLength(TypedArrayFill, 1);
|
||||
|
||||
@ -97,7 +134,7 @@ function TypedArrayFilter(predicate, thisArg) {
|
||||
if (!%IsTypedArray(this)) throw MakeTypeError(kNotTypedArray);
|
||||
|
||||
var length = %_TypedArrayGetLength(this);
|
||||
var array = $innerArrayFilter(predicate, thisArg, this, length);
|
||||
var array = InnerArrayFilter(predicate, thisArg, this, length);
|
||||
return ConstructTypedArrayLike(this, array);
|
||||
}
|
||||
%FunctionSetLength(TypedArrayFilter, 1);
|
||||
@ -108,7 +145,7 @@ function TypedArrayFind(predicate, thisArg) {
|
||||
|
||||
var length = %_TypedArrayGetLength(this);
|
||||
|
||||
return $innerArrayFind(predicate, thisArg, this, length);
|
||||
return InnerArrayFind(predicate, thisArg, this, length);
|
||||
}
|
||||
%FunctionSetLength(TypedArrayFind, 1);
|
||||
|
||||
@ -118,7 +155,7 @@ function TypedArrayFindIndex(predicate, thisArg) {
|
||||
|
||||
var length = %_TypedArrayGetLength(this);
|
||||
|
||||
return $innerArrayFindIndex(predicate, thisArg, this, length);
|
||||
return InnerArrayFindIndex(predicate, thisArg, this, length);
|
||||
}
|
||||
%FunctionSetLength(TypedArrayFindIndex, 1);
|
||||
|
||||
@ -128,15 +165,15 @@ function TypedArrayReverse() {
|
||||
|
||||
var length = %_TypedArrayGetLength(this);
|
||||
|
||||
return $innerArrayReverse(this, length);
|
||||
return InnerArrayReverse(this, length);
|
||||
}
|
||||
|
||||
|
||||
function TypedArrayComparefn(x, y) {
|
||||
if ($isNaN(x) && $isNaN(y)) {
|
||||
return $isNaN(y) ? 0 : 1;
|
||||
if (IsNaN(x) && IsNaN(y)) {
|
||||
return IsNaN(y) ? 0 : 1;
|
||||
}
|
||||
if ($isNaN(x)) {
|
||||
if (IsNaN(x)) {
|
||||
return 1;
|
||||
}
|
||||
if (x === 0 && x === y) {
|
||||
@ -162,7 +199,7 @@ function TypedArraySort(comparefn) {
|
||||
comparefn = TypedArrayComparefn;
|
||||
}
|
||||
|
||||
return %_CallFunction(this, length, comparefn, $innerArraySort);
|
||||
return %_CallFunction(this, length, comparefn, InnerArraySort);
|
||||
}
|
||||
|
||||
|
||||
@ -172,7 +209,7 @@ function TypedArrayIndexOf(element, index) {
|
||||
|
||||
var length = %_TypedArrayGetLength(this);
|
||||
|
||||
return %_CallFunction(this, element, index, length, $innerArrayIndexOf);
|
||||
return %_CallFunction(this, element, index, length, InnerArrayIndexOf);
|
||||
}
|
||||
%FunctionSetLength(TypedArrayIndexOf, 1);
|
||||
|
||||
@ -184,7 +221,7 @@ function TypedArrayLastIndexOf(element, index) {
|
||||
var length = %_TypedArrayGetLength(this);
|
||||
|
||||
return %_CallFunction(this, element, index, length,
|
||||
%_ArgumentsLength(), $innerArrayLastIndexOf);
|
||||
%_ArgumentsLength(), InnerArrayLastIndexOf);
|
||||
}
|
||||
%FunctionSetLength(TypedArrayLastIndexOf, 1);
|
||||
|
||||
@ -196,7 +233,7 @@ function TypedArrayMap(predicate, thisArg) {
|
||||
// TODO(littledan): Preallocate rather than making an intermediate
|
||||
// InternalArray, for better performance.
|
||||
var length = %_TypedArrayGetLength(this);
|
||||
var array = $innerArrayMap(predicate, thisArg, this, length);
|
||||
var array = InnerArrayMap(predicate, thisArg, this, length);
|
||||
return ConstructTypedArrayLike(this, array);
|
||||
}
|
||||
%FunctionSetLength(TypedArrayMap, 1);
|
||||
@ -208,7 +245,7 @@ function TypedArraySome(f, receiver) {
|
||||
|
||||
var length = %_TypedArrayGetLength(this);
|
||||
|
||||
return $innerArraySome(f, receiver, this, length);
|
||||
return InnerArraySome(f, receiver, this, length);
|
||||
}
|
||||
%FunctionSetLength(TypedArraySome, 1);
|
||||
|
||||
@ -227,7 +264,7 @@ function TypedArrayOf() {
|
||||
function TypedArrayFrom(source, mapfn, thisArg) {
|
||||
// TODO(littledan): Investigate if there is a receiver which could be
|
||||
// faster to accumulate on than Array, e.g., a TypedVector.
|
||||
var array = %_CallFunction(GlobalArray, source, mapfn, thisArg, $arrayFrom);
|
||||
var array = %_CallFunction(GlobalArray, source, mapfn, thisArg, ArrayFrom);
|
||||
return ConstructTypedArray(this, array);
|
||||
}
|
||||
%FunctionSetLength(TypedArrayFrom, 1);
|
||||
@ -235,13 +272,13 @@ function TypedArrayFrom(source, mapfn, thisArg) {
|
||||
// TODO(littledan): Fix the TypedArray proto chain (bug v8:4085).
|
||||
macro EXTEND_TYPED_ARRAY(NAME)
|
||||
// Set up non-enumerable functions on the object.
|
||||
$installFunctions(GlobalNAME, DONT_ENUM | DONT_DELETE | READ_ONLY, [
|
||||
utils.InstallFunctions(GlobalNAME, DONT_ENUM | DONT_DELETE | READ_ONLY, [
|
||||
"from", TypedArrayFrom,
|
||||
"of", TypedArrayOf
|
||||
]);
|
||||
|
||||
// Set up non-enumerable functions on the prototype object.
|
||||
$installFunctions(GlobalNAME.prototype, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalNAME.prototype, DONT_ENUM, [
|
||||
"copyWithin", TypedArrayCopyWithin,
|
||||
"every", TypedArrayEvery,
|
||||
"fill", TypedArrayFill,
|
||||
|
148
src/i18n.js
148
src/i18n.js
@ -22,10 +22,17 @@ var GlobalDate = global.Date;
|
||||
var GlobalNumber = global.Number;
|
||||
var GlobalRegExp = global.RegExp;
|
||||
var GlobalString = global.String;
|
||||
var ObjectDefineProperties = utils.ObjectDefineProperties;
|
||||
var ObjectDefineProperty = utils.ObjectDefineProperty;
|
||||
var SetFunctionName = utils.SetFunctionName;
|
||||
|
||||
var IsFinite;
|
||||
var IsNaN;
|
||||
var MathFloor;
|
||||
|
||||
utils.Import(function(from) {
|
||||
IsFinite = from.IsFinite;
|
||||
IsNaN = from.IsNaN;
|
||||
MathFloor = from.MathFloor;
|
||||
});
|
||||
|
||||
@ -153,6 +160,7 @@ function GetTimezoneNameCheckRE() {
|
||||
* Adds bound method to the prototype of the given object.
|
||||
*/
|
||||
function addBoundMethod(obj, methodName, implementation, length) {
|
||||
%CheckIsBootstrapping();
|
||||
function getter() {
|
||||
if (!%IsInitializedIntlObject(this)) {
|
||||
throw MakeTypeError(kMethodCalledOnWrongObject, methodName);
|
||||
@ -190,7 +198,7 @@ function addBoundMethod(obj, methodName, implementation, length) {
|
||||
}
|
||||
}
|
||||
}
|
||||
$setFunctionName(boundMethod, internalName);
|
||||
SetFunctionName(boundMethod, internalName);
|
||||
%FunctionRemovePrototype(boundMethod);
|
||||
%SetNativeFlag(boundMethod);
|
||||
this[internalName] = boundMethod;
|
||||
@ -198,11 +206,11 @@ function addBoundMethod(obj, methodName, implementation, length) {
|
||||
return this[internalName];
|
||||
}
|
||||
|
||||
$setFunctionName(getter, methodName);
|
||||
SetFunctionName(getter, methodName);
|
||||
%FunctionRemovePrototype(getter);
|
||||
%SetNativeFlag(getter);
|
||||
|
||||
$objectDefineProperty(obj.prototype, methodName, {
|
||||
ObjectDefineProperty(obj.prototype, methodName, {
|
||||
get: getter,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
@ -521,14 +529,14 @@ function setOptions(inOptions, extensionMap, keyValues, getOption, outOptions) {
|
||||
*/
|
||||
function freezeArray(array) {
|
||||
array.forEach(function(element, index) {
|
||||
$objectDefineProperty(array, index, {value: element,
|
||||
configurable: false,
|
||||
writable: false,
|
||||
enumerable: true});
|
||||
ObjectDefineProperty(array, index, {value: element,
|
||||
configurable: false,
|
||||
writable: false,
|
||||
enumerable: true});
|
||||
});
|
||||
|
||||
$objectDefineProperty(array, 'length', {value: array.length,
|
||||
writable: false});
|
||||
ObjectDefineProperty(array, 'length', {value: array.length,
|
||||
writable: false});
|
||||
return array;
|
||||
}
|
||||
|
||||
@ -589,8 +597,8 @@ function getAvailableLocalesOf(service) {
|
||||
* Configurable is false by default.
|
||||
*/
|
||||
function defineWEProperty(object, property, value) {
|
||||
$objectDefineProperty(object, property,
|
||||
{value: value, writable: true, enumerable: true});
|
||||
ObjectDefineProperty(object, property,
|
||||
{value: value, writable: true, enumerable: true});
|
||||
}
|
||||
|
||||
|
||||
@ -609,10 +617,10 @@ function addWEPropertyIfDefined(object, property, value) {
|
||||
* Defines a property and sets writable, enumerable and configurable to true.
|
||||
*/
|
||||
function defineWECProperty(object, property, value) {
|
||||
$objectDefineProperty(object, property, {value: value,
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true});
|
||||
ObjectDefineProperty(object, property, {value: value,
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true});
|
||||
}
|
||||
|
||||
|
||||
@ -873,7 +881,7 @@ function initializeCollator(collator, locales, options) {
|
||||
// problems. If malicious user decides to redefine Object.prototype.locale
|
||||
// we can't just use plain x.locale = 'us' or in C++ Set("locale", "us").
|
||||
// ObjectDefineProperties will either succeed defining or throw an error.
|
||||
var resolved = $objectDefineProperties({}, {
|
||||
var resolved = ObjectDefineProperties({}, {
|
||||
caseFirst: {writable: true},
|
||||
collation: {value: internalOptions.collation, writable: true},
|
||||
ignorePunctuation: {writable: true},
|
||||
@ -891,7 +899,7 @@ function initializeCollator(collator, locales, options) {
|
||||
|
||||
// Writable, configurable and enumerable are set to false by default.
|
||||
%MarkAsInitializedIntlObjectOfType(collator, 'collator', internalCollator);
|
||||
$objectDefineProperty(collator, 'resolved', {value: resolved});
|
||||
ObjectDefineProperty(collator, 'resolved', {value: resolved});
|
||||
|
||||
return collator;
|
||||
}
|
||||
@ -946,7 +954,7 @@ function initializeCollator(collator, locales, options) {
|
||||
},
|
||||
DONT_ENUM
|
||||
);
|
||||
$setFunctionName(Intl.Collator.prototype.resolvedOptions, 'resolvedOptions');
|
||||
SetFunctionName(Intl.Collator.prototype.resolvedOptions, 'resolvedOptions');
|
||||
%FunctionRemovePrototype(Intl.Collator.prototype.resolvedOptions);
|
||||
%SetNativeFlag(Intl.Collator.prototype.resolvedOptions);
|
||||
|
||||
@ -966,7 +974,7 @@ $setFunctionName(Intl.Collator.prototype.resolvedOptions, 'resolvedOptions');
|
||||
},
|
||||
DONT_ENUM
|
||||
);
|
||||
$setFunctionName(Intl.Collator.supportedLocalesOf, 'supportedLocalesOf');
|
||||
SetFunctionName(Intl.Collator.supportedLocalesOf, 'supportedLocalesOf');
|
||||
%FunctionRemovePrototype(Intl.Collator.supportedLocalesOf);
|
||||
%SetNativeFlag(Intl.Collator.supportedLocalesOf);
|
||||
|
||||
@ -1009,7 +1017,7 @@ function getNumberOption(options, property, min, max, fallback) {
|
||||
var value = options[property];
|
||||
if (!IS_UNDEFINED(value)) {
|
||||
value = GlobalNumber(value);
|
||||
if ($isNaN(value) || value < min || value > max) {
|
||||
if (IsNaN(value) || value < min || value > max) {
|
||||
throw MakeRangeError(kPropertyValueOutOfRange, property);
|
||||
}
|
||||
return MathFloor(value);
|
||||
@ -1096,7 +1104,7 @@ function initializeNumberFormat(numberFormat, locales, options) {
|
||||
getOption, internalOptions);
|
||||
|
||||
var requestedLocale = locale.locale + extension;
|
||||
var resolved = $objectDefineProperties({}, {
|
||||
var resolved = ObjectDefineProperties({}, {
|
||||
currency: {writable: true},
|
||||
currencyDisplay: {writable: true},
|
||||
locale: {writable: true},
|
||||
@ -1121,12 +1129,12 @@ function initializeNumberFormat(numberFormat, locales, options) {
|
||||
// We can't get information about number or currency style from ICU, so we
|
||||
// assume user request was fulfilled.
|
||||
if (internalOptions.style === 'currency') {
|
||||
$objectDefineProperty(resolved, 'currencyDisplay', {value: currencyDisplay,
|
||||
writable: true});
|
||||
ObjectDefineProperty(resolved, 'currencyDisplay', {value: currencyDisplay,
|
||||
writable: true});
|
||||
}
|
||||
|
||||
%MarkAsInitializedIntlObjectOfType(numberFormat, 'numberformat', formatter);
|
||||
$objectDefineProperty(numberFormat, 'resolved', {value: resolved});
|
||||
ObjectDefineProperty(numberFormat, 'resolved', {value: resolved});
|
||||
|
||||
return numberFormat;
|
||||
}
|
||||
@ -1199,8 +1207,7 @@ function initializeNumberFormat(numberFormat, locales, options) {
|
||||
},
|
||||
DONT_ENUM
|
||||
);
|
||||
$setFunctionName(Intl.NumberFormat.prototype.resolvedOptions,
|
||||
'resolvedOptions');
|
||||
SetFunctionName(Intl.NumberFormat.prototype.resolvedOptions, 'resolvedOptions');
|
||||
%FunctionRemovePrototype(Intl.NumberFormat.prototype.resolvedOptions);
|
||||
%SetNativeFlag(Intl.NumberFormat.prototype.resolvedOptions);
|
||||
|
||||
@ -1220,7 +1227,7 @@ $setFunctionName(Intl.NumberFormat.prototype.resolvedOptions,
|
||||
},
|
||||
DONT_ENUM
|
||||
);
|
||||
$setFunctionName(Intl.NumberFormat.supportedLocalesOf, 'supportedLocalesOf');
|
||||
SetFunctionName(Intl.NumberFormat.supportedLocalesOf, 'supportedLocalesOf');
|
||||
%FunctionRemovePrototype(Intl.NumberFormat.supportedLocalesOf);
|
||||
%SetNativeFlag(Intl.NumberFormat.supportedLocalesOf);
|
||||
|
||||
@ -1416,33 +1423,33 @@ function toDateTimeOptions(options, required, defaults) {
|
||||
}
|
||||
|
||||
if (needsDefault && (defaults === 'date' || defaults === 'all')) {
|
||||
$objectDefineProperty(options, 'year', {value: 'numeric',
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true});
|
||||
$objectDefineProperty(options, 'month', {value: 'numeric',
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true});
|
||||
$objectDefineProperty(options, 'day', {value: 'numeric',
|
||||
ObjectDefineProperty(options, 'year', {value: 'numeric',
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true});
|
||||
}
|
||||
|
||||
if (needsDefault && (defaults === 'time' || defaults === 'all')) {
|
||||
$objectDefineProperty(options, 'hour', {value: 'numeric',
|
||||
ObjectDefineProperty(options, 'month', {value: 'numeric',
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true});
|
||||
$objectDefineProperty(options, 'minute', {value: 'numeric',
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true});
|
||||
$objectDefineProperty(options, 'second', {value: 'numeric',
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true});
|
||||
ObjectDefineProperty(options, 'day', {value: 'numeric',
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true});
|
||||
}
|
||||
|
||||
if (needsDefault && (defaults === 'time' || defaults === 'all')) {
|
||||
ObjectDefineProperty(options, 'hour', {value: 'numeric',
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true});
|
||||
ObjectDefineProperty(options, 'minute', {value: 'numeric',
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true});
|
||||
ObjectDefineProperty(options, 'second', {value: 'numeric',
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true});
|
||||
}
|
||||
|
||||
return options;
|
||||
@ -1500,7 +1507,7 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
|
||||
getOption, internalOptions);
|
||||
|
||||
var requestedLocale = locale.locale + extension;
|
||||
var resolved = $objectDefineProperties({}, {
|
||||
var resolved = ObjectDefineProperties({}, {
|
||||
calendar: {writable: true},
|
||||
day: {writable: true},
|
||||
era: {writable: true},
|
||||
@ -1528,7 +1535,7 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
|
||||
}
|
||||
|
||||
%MarkAsInitializedIntlObjectOfType(dateFormat, 'dateformat', formatter);
|
||||
$objectDefineProperty(dateFormat, 'resolved', {value: resolved});
|
||||
ObjectDefineProperty(dateFormat, 'resolved', {value: resolved});
|
||||
|
||||
return dateFormat;
|
||||
}
|
||||
@ -1620,7 +1627,7 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
|
||||
},
|
||||
DONT_ENUM
|
||||
);
|
||||
$setFunctionName(Intl.DateTimeFormat.prototype.resolvedOptions,
|
||||
SetFunctionName(Intl.DateTimeFormat.prototype.resolvedOptions,
|
||||
'resolvedOptions');
|
||||
%FunctionRemovePrototype(Intl.DateTimeFormat.prototype.resolvedOptions);
|
||||
%SetNativeFlag(Intl.DateTimeFormat.prototype.resolvedOptions);
|
||||
@ -1641,7 +1648,7 @@ $setFunctionName(Intl.DateTimeFormat.prototype.resolvedOptions,
|
||||
},
|
||||
DONT_ENUM
|
||||
);
|
||||
$setFunctionName(Intl.DateTimeFormat.supportedLocalesOf, 'supportedLocalesOf');
|
||||
SetFunctionName(Intl.DateTimeFormat.supportedLocalesOf, 'supportedLocalesOf');
|
||||
%FunctionRemovePrototype(Intl.DateTimeFormat.supportedLocalesOf);
|
||||
%SetNativeFlag(Intl.DateTimeFormat.supportedLocalesOf);
|
||||
|
||||
@ -1659,7 +1666,7 @@ function formatDate(formatter, dateValue) {
|
||||
dateMs = $toNumber(dateValue);
|
||||
}
|
||||
|
||||
if (!$isFinite(dateMs)) throw MakeRangeError(kDateRange);
|
||||
if (!IsFinite(dateMs)) throw MakeRangeError(kDateRange);
|
||||
|
||||
return %InternalDateFormat(%GetImplFromInitializedIntlObject(formatter),
|
||||
new GlobalDate(dateMs));
|
||||
@ -1736,7 +1743,7 @@ function initializeBreakIterator(iterator, locales, options) {
|
||||
'type', 'string', ['character', 'word', 'sentence', 'line'], 'word'));
|
||||
|
||||
var locale = resolveLocale('breakiterator', locales, options);
|
||||
var resolved = $objectDefineProperties({}, {
|
||||
var resolved = ObjectDefineProperties({}, {
|
||||
requestedLocale: {value: locale.locale, writable: true},
|
||||
type: {value: internalOptions.type, writable: true},
|
||||
locale: {writable: true}
|
||||
@ -1748,7 +1755,7 @@ function initializeBreakIterator(iterator, locales, options) {
|
||||
|
||||
%MarkAsInitializedIntlObjectOfType(iterator, 'breakiterator',
|
||||
internalIterator);
|
||||
$objectDefineProperty(iterator, 'resolved', {value: resolved});
|
||||
ObjectDefineProperty(iterator, 'resolved', {value: resolved});
|
||||
|
||||
return iterator;
|
||||
}
|
||||
@ -1799,7 +1806,7 @@ function initializeBreakIterator(iterator, locales, options) {
|
||||
},
|
||||
DONT_ENUM
|
||||
);
|
||||
$setFunctionName(Intl.v8BreakIterator.prototype.resolvedOptions,
|
||||
SetFunctionName(Intl.v8BreakIterator.prototype.resolvedOptions,
|
||||
'resolvedOptions');
|
||||
%FunctionRemovePrototype(Intl.v8BreakIterator.prototype.resolvedOptions);
|
||||
%SetNativeFlag(Intl.v8BreakIterator.prototype.resolvedOptions);
|
||||
@ -1821,7 +1828,7 @@ $setFunctionName(Intl.v8BreakIterator.prototype.resolvedOptions,
|
||||
},
|
||||
DONT_ENUM
|
||||
);
|
||||
$setFunctionName(Intl.v8BreakIterator.supportedLocalesOf, 'supportedLocalesOf');
|
||||
SetFunctionName(Intl.v8BreakIterator.supportedLocalesOf, 'supportedLocalesOf');
|
||||
%FunctionRemovePrototype(Intl.v8BreakIterator.supportedLocalesOf);
|
||||
%SetNativeFlag(Intl.v8BreakIterator.supportedLocalesOf);
|
||||
|
||||
@ -1911,11 +1918,22 @@ function cachedOrNewService(service, locales, options, defaults) {
|
||||
}
|
||||
|
||||
|
||||
function OverrideFunction(object, name, f) {
|
||||
%CheckIsBootstrapping();
|
||||
ObjectDefineProperty(object, name, { value: f,
|
||||
writeable: true,
|
||||
configurable: true,
|
||||
enumerable: false });
|
||||
SetFunctionName(f, name);
|
||||
%FunctionRemovePrototype(f);
|
||||
%SetNativeFlag(f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares this and that, and returns less than 0, 0 or greater than 0 value.
|
||||
* Overrides the built-in method.
|
||||
*/
|
||||
$overrideFunction(GlobalString.prototype, 'localeCompare', function(that) {
|
||||
OverrideFunction(GlobalString.prototype, 'localeCompare', function(that) {
|
||||
if (%_IsConstructCall()) {
|
||||
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
|
||||
}
|
||||
@ -1939,7 +1957,7 @@ $overrideFunction(GlobalString.prototype, 'localeCompare', function(that) {
|
||||
* If the form is not one of "NFC", "NFD", "NFKC", or "NFKD", then throw
|
||||
* a RangeError Exception.
|
||||
*/
|
||||
$overrideFunction(GlobalString.prototype, 'normalize', function(that) {
|
||||
OverrideFunction(GlobalString.prototype, 'normalize', function(that) {
|
||||
if (%_IsConstructCall()) {
|
||||
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
|
||||
}
|
||||
@ -1964,7 +1982,7 @@ $overrideFunction(GlobalString.prototype, 'normalize', function(that) {
|
||||
* Formats a Number object (this) using locale and options values.
|
||||
* If locale or options are omitted, defaults are used.
|
||||
*/
|
||||
$overrideFunction(GlobalNumber.prototype, 'toLocaleString', function() {
|
||||
OverrideFunction(GlobalNumber.prototype, 'toLocaleString', function() {
|
||||
if (%_IsConstructCall()) {
|
||||
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
|
||||
}
|
||||
@ -1989,9 +2007,7 @@ function toLocaleDateTime(date, locales, options, required, defaults, service) {
|
||||
throw MakeTypeError(kMethodInvokedOnWrongType, "Date");
|
||||
}
|
||||
|
||||
if ($isNaN(date)) {
|
||||
return 'Invalid Date';
|
||||
}
|
||||
if (IsNaN(date)) return 'Invalid Date';
|
||||
|
||||
var internalOptions = toDateTimeOptions(options, required, defaults);
|
||||
|
||||
@ -2007,7 +2023,7 @@ function toLocaleDateTime(date, locales, options, required, defaults, service) {
|
||||
* If locale or options are omitted, defaults are used - both date and time are
|
||||
* present in the output.
|
||||
*/
|
||||
$overrideFunction(GlobalDate.prototype, 'toLocaleString', function() {
|
||||
OverrideFunction(GlobalDate.prototype, 'toLocaleString', function() {
|
||||
if (%_IsConstructCall()) {
|
||||
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
|
||||
}
|
||||
@ -2025,7 +2041,7 @@ $overrideFunction(GlobalDate.prototype, 'toLocaleString', function() {
|
||||
* If locale or options are omitted, defaults are used - only date is present
|
||||
* in the output.
|
||||
*/
|
||||
$overrideFunction(GlobalDate.prototype, 'toLocaleDateString', function() {
|
||||
OverrideFunction(GlobalDate.prototype, 'toLocaleDateString', function() {
|
||||
if (%_IsConstructCall()) {
|
||||
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
|
||||
}
|
||||
@ -2043,7 +2059,7 @@ $overrideFunction(GlobalDate.prototype, 'toLocaleDateString', function() {
|
||||
* If locale or options are omitted, defaults are used - only time is present
|
||||
* in the output.
|
||||
*/
|
||||
$overrideFunction(GlobalDate.prototype, 'toLocaleTimeString', function() {
|
||||
OverrideFunction(GlobalDate.prototype, 'toLocaleTimeString', function() {
|
||||
if (%_IsConstructCall()) {
|
||||
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ var $iteratorPrototype;
|
||||
return this;
|
||||
}
|
||||
|
||||
$setFunctionName(IteratorPrototypeIterator, symbolIterator);
|
||||
utils.SetFunctionName(IteratorPrototypeIterator, symbolIterator);
|
||||
%AddNamedProperty($iteratorPrototype, symbolIterator,
|
||||
IteratorPrototypeIterator, DONT_ENUM);
|
||||
})
|
||||
|
10
src/json.js
10
src/json.js
@ -18,10 +18,12 @@ var InternalArray = utils.InternalArray;
|
||||
|
||||
var MathMax;
|
||||
var MathMin;
|
||||
var ObjectHasOwnProperty;
|
||||
|
||||
utils.Import(function(from) {
|
||||
MathMax = from.MathMax;
|
||||
MathMin = from.MathMin;
|
||||
ObjectHasOwnProperty = from.ObjectHasOwnProperty;
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
@ -37,7 +39,7 @@ function Revive(holder, name, reviver) {
|
||||
}
|
||||
} else {
|
||||
for (var p in val) {
|
||||
if (%_CallFunction(val, p, $objectHasOwnProperty)) {
|
||||
if (HAS_OWN_PROPERTY(val, p)) {
|
||||
var newElement = Revive(val, p, reviver);
|
||||
if (IS_UNDEFINED(newElement)) {
|
||||
delete val[p];
|
||||
@ -99,7 +101,7 @@ function SerializeObject(value, replacer, stack, indent, gap) {
|
||||
if (IS_ARRAY(replacer)) {
|
||||
var length = replacer.length;
|
||||
for (var i = 0; i < length; i++) {
|
||||
if (%_CallFunction(replacer, i, $objectHasOwnProperty)) {
|
||||
if (HAS_OWN_PROPERTY(replacer, i)) {
|
||||
var p = replacer[i];
|
||||
var strP = JSONSerialize(p, value, replacer, stack, indent, gap);
|
||||
if (!IS_UNDEFINED(strP)) {
|
||||
@ -112,7 +114,7 @@ function SerializeObject(value, replacer, stack, indent, gap) {
|
||||
}
|
||||
} else {
|
||||
for (var p in value) {
|
||||
if (%_CallFunction(value, p, $objectHasOwnProperty)) {
|
||||
if (HAS_OWN_PROPERTY(value, p)) {
|
||||
var strP = JSONSerialize(p, value, replacer, stack, indent, gap);
|
||||
if (!IS_UNDEFINED(strP)) {
|
||||
var member = %QuoteJSONString(p) + ":";
|
||||
@ -232,7 +234,7 @@ function JSONStringify(value, replacer, space) {
|
||||
%AddNamedProperty(GlobalJSON, symbolToStringTag, "JSON", READ_ONLY | DONT_ENUM);
|
||||
|
||||
// Set up non-enumerable properties of the JSON object.
|
||||
$installFunctions(GlobalJSON, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalJSON, DONT_ENUM, [
|
||||
"parse", JSONParse,
|
||||
"stringify", JSONStringify
|
||||
]);
|
||||
|
@ -154,7 +154,7 @@ macro TO_STRING_INLINE(arg) = (IS_STRING(%IS_VAR(arg)) ? arg : $nonStringToStrin
|
||||
macro TO_NUMBER_INLINE(arg) = (IS_NUMBER(%IS_VAR(arg)) ? arg : $nonNumberToNumber(arg));
|
||||
macro TO_OBJECT_INLINE(arg) = (IS_SPEC_OBJECT(%IS_VAR(arg)) ? arg : $toObject(arg));
|
||||
macro JSON_NUMBER_TO_STRING(arg) = ((%_IsSmi(%IS_VAR(arg)) || arg - arg == 0) ? %_NumberToString(arg) : "null");
|
||||
macro HAS_OWN_PROPERTY(arg, index) = (%_CallFunction(arg, index, $objectHasOwnProperty));
|
||||
macro HAS_OWN_PROPERTY(arg, index) = (%_CallFunction(arg, index, ObjectHasOwnProperty));
|
||||
macro SHOULD_CREATE_WRAPPER(functionName, receiver) = (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(functionName));
|
||||
macro HAS_INDEX(array, index, is_array) = ((is_array && %_HasFastPackedElements(%IS_VAR(array))) ? (index < array.length) : (index in array));
|
||||
|
||||
|
@ -292,7 +292,7 @@ var Math = new MathConstructor();
|
||||
%AddNamedProperty(Math, symbolToStringTag, "Math", READ_ONLY | DONT_ENUM);
|
||||
|
||||
// Set up math constants.
|
||||
$installConstants(Math, [
|
||||
utils.InstallConstants(Math, [
|
||||
// ECMA-262, section 15.8.1.1.
|
||||
"E", 2.7182818284590452354,
|
||||
// ECMA-262, section 15.8.1.2.
|
||||
@ -309,7 +309,7 @@ $installConstants(Math, [
|
||||
|
||||
// Set up non-enumerable functions of the Math object and
|
||||
// set their names.
|
||||
$installFunctions(Math, DONT_ENUM, [
|
||||
utils.InstallFunctions(Math, DONT_ENUM, [
|
||||
"random", MathRandom,
|
||||
"abs", MathAbs,
|
||||
"acos", MathAcosJS,
|
||||
|
@ -27,9 +27,6 @@ var MakeReferenceError;
|
||||
var MakeSyntaxError;
|
||||
var MakeTypeError;
|
||||
var MakeURIError;
|
||||
var MakeReferenceErrorEmbedded;
|
||||
var MakeSyntaxErrorEmbedded;
|
||||
var MakeTypeErrorEmbedded;
|
||||
|
||||
(function(global, utils) {
|
||||
|
||||
@ -40,12 +37,17 @@ var MakeTypeErrorEmbedded;
|
||||
|
||||
var GlobalObject = global.Object;
|
||||
var InternalArray = utils.InternalArray;
|
||||
var ObjectDefineProperty = utils.ObjectDefineProperty;
|
||||
|
||||
var ArrayJoin;
|
||||
var ObjectToString;
|
||||
var StringCharAt;
|
||||
var StringIndexOf;
|
||||
var StringSubstring;
|
||||
|
||||
utils.Import(function(from) {
|
||||
ArrayJoin = from.ArrayJoin;
|
||||
ObjectToString = from.ObjectToString;
|
||||
StringCharAt = from.StringCharAt;
|
||||
StringIndexOf = from.StringIndexOf;
|
||||
StringSubstring = from.StringSubstring;
|
||||
@ -85,7 +87,7 @@ function NoSideEffectToString(obj) {
|
||||
}
|
||||
if (IS_SYMBOL(obj)) return %_CallFunction(obj, $symbolToString);
|
||||
if (IS_OBJECT(obj)
|
||||
&& %GetDataProperty(obj, "toString") === $objectToString) {
|
||||
&& %GetDataProperty(obj, "toString") === ObjectToString) {
|
||||
var constructor = %GetDataProperty(obj, "constructor");
|
||||
if (typeof constructor == "function") {
|
||||
var constructorName = constructor.name;
|
||||
@ -137,7 +139,7 @@ function ToStringCheckErrorObject(obj) {
|
||||
|
||||
|
||||
function ToDetailString(obj) {
|
||||
if (obj != null && IS_OBJECT(obj) && obj.toString === $objectToString) {
|
||||
if (obj != null && IS_OBJECT(obj) && obj.toString === ObjectToString) {
|
||||
var constructor = obj.constructor;
|
||||
if (typeof constructor == "function") {
|
||||
var constructorName = constructor.name;
|
||||
@ -409,7 +411,7 @@ function ScriptNameOrSourceURL() {
|
||||
}
|
||||
|
||||
|
||||
$setUpLockedPrototype(Script, [
|
||||
utils.SetUpLockedPrototype(Script, [
|
||||
"source",
|
||||
"name",
|
||||
"source_url",
|
||||
@ -473,7 +475,7 @@ function SourceLocationSourceText() {
|
||||
}
|
||||
|
||||
|
||||
$setUpLockedPrototype(SourceLocation,
|
||||
utils.SetUpLockedPrototype(SourceLocation,
|
||||
["script", "position", "line", "column", "start", "end"],
|
||||
["sourceText", SourceLocationSourceText]
|
||||
);
|
||||
@ -517,7 +519,7 @@ function SourceSliceSourceText() {
|
||||
StringSubstring);
|
||||
}
|
||||
|
||||
$setUpLockedPrototype(SourceSlice,
|
||||
utils.SetUpLockedPrototype(SourceSlice,
|
||||
["script", "from_line", "to_line", "from_position", "to_position"],
|
||||
["sourceText", SourceSliceSourceText]
|
||||
);
|
||||
@ -715,7 +717,7 @@ function CallSiteToString() {
|
||||
return line;
|
||||
}
|
||||
|
||||
$setUpLockedPrototype(CallSite, ["receiver", "fun", "pos"], [
|
||||
utils.SetUpLockedPrototype(CallSite, ["receiver", "fun", "pos"], [
|
||||
"getThis", CallSiteGetThis,
|
||||
"getTypeName", CallSiteGetTypeName,
|
||||
"isToplevel", CallSiteIsToplevel,
|
||||
@ -842,7 +844,7 @@ function FormatStackTrace(obj, raw_stack) {
|
||||
}
|
||||
lines.push(" at " + line);
|
||||
}
|
||||
return %_CallFunction(lines, "\n", $arrayJoin);
|
||||
return %_CallFunction(lines, "\n", ArrayJoin);
|
||||
}
|
||||
|
||||
|
||||
@ -902,13 +904,7 @@ var StackTraceSetter = function(v) {
|
||||
|
||||
// Use a dummy function since we do not actually want to capture a stack trace
|
||||
// when constructing the initial Error prototytpes.
|
||||
var captureStackTrace = function captureStackTrace(obj, cons_opt) {
|
||||
// Define accessors first, as this may fail and throw.
|
||||
$objectDefineProperty(obj, 'stack', { get: StackTraceGetter,
|
||||
set: StackTraceSetter,
|
||||
configurable: true });
|
||||
%CollectStackTrace(obj, cons_opt ? cons_opt : captureStackTrace);
|
||||
}
|
||||
var captureStackTrace = function() {};
|
||||
|
||||
|
||||
// Define special error type constructors.
|
||||
@ -963,9 +959,6 @@ GlobalSyntaxError = DefineError(global, function SyntaxError() { });
|
||||
GlobalTypeError = DefineError(global, function TypeError() { });
|
||||
GlobalURIError = DefineError(global, function URIError() { });
|
||||
|
||||
|
||||
GlobalError.captureStackTrace = captureStackTrace;
|
||||
|
||||
%AddNamedProperty(GlobalError.prototype, 'message', '', DONT_ENUM);
|
||||
|
||||
// Global list of error objects visited during ErrorToString. This is
|
||||
@ -1030,8 +1023,8 @@ function ErrorToString() {
|
||||
}
|
||||
}
|
||||
|
||||
$installFunctions(GlobalError.prototype, DONT_ENUM,
|
||||
['toString', ErrorToString]);
|
||||
utils.InstallFunctions(GlobalError.prototype, DONT_ENUM,
|
||||
['toString', ErrorToString]);
|
||||
|
||||
$errorToString = ErrorToString;
|
||||
$getStackTraceLine = GetStackTraceLine;
|
||||
@ -1077,10 +1070,22 @@ MakeURIError = function() {
|
||||
return MakeGenericError(GlobalURIError, kURIMalformed);
|
||||
}
|
||||
|
||||
//Boilerplate for exceptions for stack overflows. Used from
|
||||
//Isolate::StackOverflow().
|
||||
// Boilerplate for exceptions for stack overflows. Used from
|
||||
// Isolate::StackOverflow().
|
||||
$stackOverflowBoilerplate = MakeRangeError(kStackOverflow);
|
||||
%DefineAccessorPropertyUnchecked($stackOverflowBoilerplate, 'stack',
|
||||
StackTraceGetter, StackTraceSetter, DONT_ENUM);
|
||||
StackTraceGetter, StackTraceSetter,
|
||||
DONT_ENUM);
|
||||
|
||||
})
|
||||
// Define actual captureStackTrace function after everything has been set up.
|
||||
captureStackTrace = function captureStackTrace(obj, cons_opt) {
|
||||
// Define accessors first, as this may fail and throw.
|
||||
ObjectDefineProperty(obj, 'stack', { get: StackTraceGetter,
|
||||
set: StackTraceSetter,
|
||||
configurable: true });
|
||||
%CollectStackTrace(obj, cons_opt ? cons_opt : captureStackTrace);
|
||||
};
|
||||
|
||||
GlobalError.captureStackTrace = captureStackTrace;
|
||||
|
||||
});
|
||||
|
@ -23,6 +23,14 @@ var GlobalArray = global.Array;
|
||||
var GlobalObject = global.Object;
|
||||
var InternalArray = utils.InternalArray;
|
||||
|
||||
var ObjectFreeze;
|
||||
var ObjectIsFrozen;
|
||||
|
||||
utils.Import(function(from) {
|
||||
ObjectFreeze = from.ObjectFreeze;
|
||||
ObjectIsFrozen = from.ObjectIsFrozen;
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
// Overview:
|
||||
@ -380,7 +388,7 @@ function ObjectObserve(object, callback, acceptList) {
|
||||
throw MakeTypeError(kObserveGlobalProxy, "observe");
|
||||
if (!IS_SPEC_FUNCTION(callback))
|
||||
throw MakeTypeError(kObserveNonFunction, "observe");
|
||||
if ($objectIsFrozen(callback))
|
||||
if (ObjectIsFrozen(callback))
|
||||
throw MakeTypeError(kObserveCallbackFrozen);
|
||||
|
||||
var objectObserveFn = %GetObjectContextObjectObserve(object);
|
||||
@ -473,7 +481,7 @@ function ObjectInfoEnqueueExternalChangeRecord(objectInfo, changeRecord, type) {
|
||||
%DefineDataPropertyUnchecked(
|
||||
newRecord, prop, changeRecord[prop], READ_ONLY + DONT_DELETE);
|
||||
}
|
||||
$objectFreeze(newRecord);
|
||||
ObjectFreeze(newRecord);
|
||||
|
||||
ObjectInfoEnqueueInternalChangeRecord(objectInfo, newRecord);
|
||||
}
|
||||
@ -525,8 +533,8 @@ function EnqueueSpliceRecord(array, index, removed, addedCount) {
|
||||
addedCount: addedCount
|
||||
};
|
||||
|
||||
$objectFreeze(changeRecord);
|
||||
$objectFreeze(changeRecord.removed);
|
||||
ObjectFreeze(changeRecord);
|
||||
ObjectFreeze(changeRecord.removed);
|
||||
ObjectInfoEnqueueInternalChangeRecord(objectInfo, changeRecord);
|
||||
}
|
||||
|
||||
@ -550,7 +558,7 @@ function NotifyChange(type, object, name, oldValue) {
|
||||
};
|
||||
}
|
||||
|
||||
$objectFreeze(changeRecord);
|
||||
ObjectFreeze(changeRecord);
|
||||
ObjectInfoEnqueueInternalChangeRecord(objectInfo, changeRecord);
|
||||
}
|
||||
|
||||
@ -607,7 +615,7 @@ function ObjectGetNotifier(object) {
|
||||
if (%IsJSGlobalProxy(object))
|
||||
throw MakeTypeError(kObserveGlobalProxy, "getNotifier");
|
||||
|
||||
if ($objectIsFrozen(object)) return null;
|
||||
if (ObjectIsFrozen(object)) return null;
|
||||
|
||||
if (!%ObjectWasCreatedInCurrentOrigin(object)) return null;
|
||||
|
||||
@ -665,17 +673,17 @@ function ObserveMicrotaskRunner() {
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
$installFunctions(GlobalObject, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalObject, DONT_ENUM, [
|
||||
"deliverChangeRecords", ObjectDeliverChangeRecords,
|
||||
"getNotifier", ObjectGetNotifier,
|
||||
"observe", ObjectObserve,
|
||||
"unobserve", ObjectUnobserve
|
||||
]);
|
||||
$installFunctions(GlobalArray, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalArray, DONT_ENUM, [
|
||||
"observe", ArrayObserve,
|
||||
"unobserve", ArrayUnobserve
|
||||
]);
|
||||
$installFunctions(notifierPrototype, DONT_ENUM, [
|
||||
utils.InstallFunctions(notifierPrototype, DONT_ENUM, [
|
||||
"notify", ObjectNotifierNotify,
|
||||
"performChange", ObjectNotifierPerformChange
|
||||
]);
|
||||
|
191
src/prologue.js
191
src/prologue.js
@ -13,45 +13,214 @@
|
||||
|
||||
var imports = UNDEFINED;
|
||||
var exports = UNDEFINED;
|
||||
var imports_from_experimental = UNDEFINED;
|
||||
|
||||
|
||||
utils.Export = function Export(f) {
|
||||
// Export to other scripts.
|
||||
// In normal natives, this exports functions to other normal natives.
|
||||
// In experimental natives, this exports to other experimental natives and
|
||||
// to normal natives that import using utils.ImportFromExperimental.
|
||||
function Export(f) {
|
||||
f.next = exports;
|
||||
exports = f;
|
||||
};
|
||||
|
||||
|
||||
utils.Import = function Import(f) {
|
||||
// Import from other scripts.
|
||||
// In normal natives, this imports from other normal natives.
|
||||
// In experimental natives, this imports from other experimental natives and
|
||||
// whitelisted exports from normal natives.
|
||||
function Import(f) {
|
||||
f.next = imports;
|
||||
imports = f;
|
||||
};
|
||||
|
||||
|
||||
// In normal natives, import from experimental natives.
|
||||
// Not callable from experimental natives.
|
||||
function ImportFromExperimental(f) {
|
||||
f.next = imports_from_experimental;
|
||||
imports_from_experimental = f;
|
||||
};
|
||||
|
||||
|
||||
function SetFunctionName(f, name, prefix) {
|
||||
if (IS_SYMBOL(name)) {
|
||||
name = "[" + %SymbolDescription(name) + "]";
|
||||
}
|
||||
if (IS_UNDEFINED(prefix)) {
|
||||
%FunctionSetName(f, name);
|
||||
} else {
|
||||
%FunctionSetName(f, prefix + " " + name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function InstallConstants(object, constants) {
|
||||
%CheckIsBootstrapping();
|
||||
%OptimizeObjectForAddingMultipleProperties(object, constants.length >> 1);
|
||||
var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY;
|
||||
for (var i = 0; i < constants.length; i += 2) {
|
||||
var name = constants[i];
|
||||
var k = constants[i + 1];
|
||||
%AddNamedProperty(object, name, k, attributes);
|
||||
}
|
||||
%ToFastProperties(object);
|
||||
}
|
||||
|
||||
|
||||
function InstallFunctions(object, attributes, functions) {
|
||||
%CheckIsBootstrapping();
|
||||
%OptimizeObjectForAddingMultipleProperties(object, functions.length >> 1);
|
||||
for (var i = 0; i < functions.length; i += 2) {
|
||||
var key = functions[i];
|
||||
var f = functions[i + 1];
|
||||
SetFunctionName(f, key);
|
||||
%FunctionRemovePrototype(f);
|
||||
%AddNamedProperty(object, key, f, attributes);
|
||||
%SetNativeFlag(f);
|
||||
}
|
||||
%ToFastProperties(object);
|
||||
}
|
||||
|
||||
|
||||
// Helper function to install a getter-only accessor property.
|
||||
function InstallGetter(object, name, getter, attributes) {
|
||||
%CheckIsBootstrapping();
|
||||
if (typeof attributes == "undefined") {
|
||||
attributes = DONT_ENUM;
|
||||
}
|
||||
SetFunctionName(getter, name, "get");
|
||||
%FunctionRemovePrototype(getter);
|
||||
%DefineAccessorPropertyUnchecked(object, name, getter, null, attributes);
|
||||
%SetNativeFlag(getter);
|
||||
}
|
||||
|
||||
|
||||
// Helper function to install a getter/setter accessor property.
|
||||
function InstallGetterSetter(object, name, getter, setter) {
|
||||
%CheckIsBootstrapping();
|
||||
SetFunctionName(getter, name, "get");
|
||||
SetFunctionName(setter, name, "set");
|
||||
%FunctionRemovePrototype(getter);
|
||||
%FunctionRemovePrototype(setter);
|
||||
%DefineAccessorPropertyUnchecked(object, name, getter, setter, DONT_ENUM);
|
||||
%SetNativeFlag(getter);
|
||||
%SetNativeFlag(setter);
|
||||
}
|
||||
|
||||
|
||||
// Prevents changes to the prototype of a built-in function.
|
||||
// The "prototype" property of the function object is made non-configurable,
|
||||
// and the prototype object is made non-extensible. The latter prevents
|
||||
// changing the __proto__ property.
|
||||
function SetUpLockedPrototype(
|
||||
constructor, fields, methods) {
|
||||
%CheckIsBootstrapping();
|
||||
var prototype = constructor.prototype;
|
||||
// Install functions first, because this function is used to initialize
|
||||
// PropertyDescriptor itself.
|
||||
var property_count = (methods.length >> 1) + (fields ? fields.length : 0);
|
||||
if (property_count >= 4) {
|
||||
%OptimizeObjectForAddingMultipleProperties(prototype, property_count);
|
||||
}
|
||||
if (fields) {
|
||||
for (var i = 0; i < fields.length; i++) {
|
||||
%AddNamedProperty(prototype, fields[i],
|
||||
UNDEFINED, DONT_ENUM | DONT_DELETE);
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < methods.length; i += 2) {
|
||||
var key = methods[i];
|
||||
var f = methods[i + 1];
|
||||
%AddNamedProperty(prototype, key, f, DONT_ENUM | DONT_DELETE | READ_ONLY);
|
||||
%SetNativeFlag(f);
|
||||
}
|
||||
%InternalSetPrototype(prototype, null);
|
||||
%ToFastProperties(prototype);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// To be called by bootstrapper
|
||||
|
||||
utils.PostNatives = function() {
|
||||
var experimental_exports = UNDEFINED;
|
||||
|
||||
function PostNatives(utils) {
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
var container = {};
|
||||
for ( ; !IS_UNDEFINED(exports); exports = exports.next) exports(container);
|
||||
for ( ; !IS_UNDEFINED(imports); imports = imports.next) imports(container);
|
||||
|
||||
// Whitelist of exports from normal natives to experimental natives.
|
||||
var expose_to_experimental = [
|
||||
"GetIterator",
|
||||
"GetMethod",
|
||||
"InnerArrayEvery",
|
||||
"InnerArrayFilter",
|
||||
"InnerArrayForEach",
|
||||
"InnerArrayIndexOf",
|
||||
"InnerArrayLastIndexOf",
|
||||
"InnerArrayMap",
|
||||
"InnerArrayReverse",
|
||||
"InnerArraySome",
|
||||
"InnerArraySort",
|
||||
"IsNaN",
|
||||
"MathMax",
|
||||
"MathMin",
|
||||
"ObjectIsFrozen",
|
||||
"OwnPropertyKeys",
|
||||
"ToNameArray",
|
||||
];
|
||||
var experimental = {};
|
||||
experimental_exports = {};
|
||||
%OptimizeObjectForAddingMultipleProperties(
|
||||
experimental, expose_to_experimental.length);
|
||||
for (var key of expose_to_experimental) experimental[key] = container[key];
|
||||
%ToFastProperties(experimental);
|
||||
experimental_exports, expose_to_experimental.length);
|
||||
for (var key of expose_to_experimental) {
|
||||
experimental_exports[key] = container[key];
|
||||
}
|
||||
%ToFastProperties(experimental_exports);
|
||||
container = UNDEFINED;
|
||||
|
||||
utils.Export = UNDEFINED;
|
||||
utils.PostNatives = UNDEFINED;
|
||||
utils.Import = function ImportFromExperimental(f) {
|
||||
f(experimental);
|
||||
};
|
||||
utils.ImportFromExperimental = UNDEFINED;
|
||||
};
|
||||
|
||||
|
||||
function PostExperimentals(utils) {
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
for ( ; !IS_UNDEFINED(exports); exports = exports.next) {
|
||||
exports(experimental_exports);
|
||||
}
|
||||
for ( ; !IS_UNDEFINED(imports); imports = imports.next) {
|
||||
imports(experimental_exports);
|
||||
}
|
||||
for ( ; !IS_UNDEFINED(imports_from_experimental);
|
||||
imports_from_experimental = imports_from_experimental.next) {
|
||||
imports_from_experimental(experimental_exports);
|
||||
}
|
||||
|
||||
experimental_exports = UNDEFINED;
|
||||
|
||||
utils.PostExperimentals = UNDEFINED;
|
||||
utils.Import = UNDEFINED;
|
||||
utils.Export = UNDEFINED;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
InstallFunctions(utils, NONE, [
|
||||
"Import", Import,
|
||||
"Export", Export,
|
||||
"ImportFromExperimental", ImportFromExperimental,
|
||||
"SetFunctionName", SetFunctionName,
|
||||
"InstallConstants", InstallConstants,
|
||||
"InstallFunctions", InstallFunctions,
|
||||
"InstallGetter", InstallGetter,
|
||||
"InstallGetterSetter", InstallGetterSetter,
|
||||
"SetUpLockedPrototype", SetUpLockedPrototype,
|
||||
"PostNatives", PostNatives,
|
||||
"PostExperimentals", PostExperimentals,
|
||||
]);
|
||||
|
||||
})
|
||||
|
@ -371,7 +371,7 @@ function PromiseHasUserDefinedRejectHandler() {
|
||||
%AddNamedProperty(GlobalPromise.prototype, symbolToStringTag, "Promise",
|
||||
DONT_ENUM | READ_ONLY);
|
||||
|
||||
$installFunctions(GlobalPromise, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalPromise, DONT_ENUM, [
|
||||
"defer", PromiseDeferred,
|
||||
"accept", PromiseResolved,
|
||||
"reject", PromiseRejected,
|
||||
@ -380,7 +380,7 @@ $installFunctions(GlobalPromise, DONT_ENUM, [
|
||||
"resolve", PromiseCast
|
||||
]);
|
||||
|
||||
$installFunctions(GlobalPromise.prototype, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalPromise.prototype, DONT_ENUM, [
|
||||
"chain", PromiseChain,
|
||||
"then", PromiseThen,
|
||||
"catch", PromiseCatch
|
||||
|
30
src/proxy.js
30
src/proxy.js
@ -2,11 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
var $proxyDelegateCallAndConstruct;
|
||||
var $proxyDerivedGetTrap;
|
||||
var $proxyDerivedHasTrap;
|
||||
var $proxyDerivedHasOwnTrap;
|
||||
var $proxyDerivedKeysTrap;
|
||||
var $proxyDerivedSetTrap;
|
||||
var $proxyEnumerate;
|
||||
|
||||
@ -16,10 +13,19 @@ var $proxyEnumerate;
|
||||
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Imports
|
||||
|
||||
var GlobalFunction = global.Function;
|
||||
var GlobalObject = global.Object;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
var ToNameArray;
|
||||
|
||||
utils.Import(function(from) {
|
||||
ToNameArray = from.ToNameArray;
|
||||
});
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
function ProxyCreate(handler, proto) {
|
||||
if (!IS_SPEC_OBJECT(handler))
|
||||
@ -175,7 +181,7 @@ function ProxyEnumerate(proxy) {
|
||||
if (IS_UNDEFINED(handler.enumerate)) {
|
||||
return %Apply(DerivedEnumerateTrap, handler, [], 0, 0)
|
||||
} else {
|
||||
return $toNameArray(handler.enumerate(), "enumerate", false)
|
||||
return ToNameArray(handler.enumerate(), "enumerate", false)
|
||||
}
|
||||
}
|
||||
|
||||
@ -185,17 +191,23 @@ var Proxy = new GlobalObject();
|
||||
%AddNamedProperty(global, "Proxy", Proxy, DONT_ENUM);
|
||||
|
||||
//Set up non-enumerable properties of the Proxy object.
|
||||
$installFunctions(Proxy, DONT_ENUM, [
|
||||
utils.InstallFunctions(Proxy, DONT_ENUM, [
|
||||
"create", ProxyCreate,
|
||||
"createFunction", ProxyCreateFunction
|
||||
])
|
||||
|
||||
$proxyDelegateCallAndConstruct = DelegateCallAndConstruct;
|
||||
// -------------------------------------------------------------------
|
||||
// Exports
|
||||
|
||||
$proxyDerivedGetTrap = DerivedGetTrap;
|
||||
$proxyDerivedHasTrap = DerivedHasTrap;
|
||||
$proxyDerivedHasOwnTrap = DerivedHasOwnTrap;
|
||||
$proxyDerivedKeysTrap = DerivedKeysTrap;
|
||||
$proxyDerivedSetTrap = DerivedSetTrap;
|
||||
$proxyEnumerate = ProxyEnumerate;
|
||||
|
||||
utils.Export(function(to) {
|
||||
to.ProxyDelegateCallAndConstruct = DelegateCallAndConstruct;
|
||||
to.ProxyDerivedHasOwnTrap = DerivedHasOwnTrap;
|
||||
to.ProxyDerivedKeysTrap = DerivedKeysTrap;
|
||||
});
|
||||
|
||||
})
|
||||
|
@ -2,9 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
var $regexpExec;
|
||||
var $regexpExecNoTests;
|
||||
var $regexpLastMatchInfo;
|
||||
var $regexpLastMatchInfoOverride;
|
||||
var harmony_regexps = false;
|
||||
var harmony_unicode_regexps = false;
|
||||
@ -22,12 +19,12 @@ var InternalPackedArray = utils.InternalPackedArray;
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
// Property of the builtins object for recording the result of the last
|
||||
// regexp match. The property $regexpLastMatchInfo includes the matchIndices
|
||||
// regexp match. The property RegExpLastMatchInfo includes the matchIndices
|
||||
// array of the last successful regexp match (an array of start/end index
|
||||
// pairs for the match and all the captured substrings), the invariant is
|
||||
// that there are at least two capture indeces. The array also contains
|
||||
// the subject string for the last successful match.
|
||||
$regexpLastMatchInfo = new InternalPackedArray(
|
||||
var RegExpLastMatchInfo = new InternalPackedArray(
|
||||
2, // REGEXP_NUMBER_OF_CAPTURES
|
||||
"", // Last subject.
|
||||
UNDEFINED, // Last input - settable with RegExpSetInput.
|
||||
@ -104,7 +101,7 @@ function RegExpCompileJS(pattern, flags) {
|
||||
|
||||
|
||||
function DoRegExpExec(regexp, string, index) {
|
||||
var result = %_RegExpExec(regexp, string, index, $regexpLastMatchInfo);
|
||||
var result = %_RegExpExec(regexp, string, index, RegExpLastMatchInfo);
|
||||
if (result !== null) $regexpLastMatchInfoOverride = null;
|
||||
return result;
|
||||
}
|
||||
@ -138,7 +135,7 @@ endmacro
|
||||
|
||||
function RegExpExecNoTests(regexp, string, start) {
|
||||
// Must be called with RegExp, string and positive integer as arguments.
|
||||
var matchInfo = %_RegExpExec(regexp, string, start, $regexpLastMatchInfo);
|
||||
var matchInfo = %_RegExpExec(regexp, string, start, RegExpLastMatchInfo);
|
||||
if (matchInfo !== null) {
|
||||
$regexpLastMatchInfoOverride = null;
|
||||
RETURN_NEW_RESULT_FROM_MATCH_INFO(matchInfo, string);
|
||||
@ -171,8 +168,8 @@ function RegExpExecJS(string) {
|
||||
i = 0;
|
||||
}
|
||||
|
||||
// matchIndices is either null or the $regexpLastMatchInfo array.
|
||||
var matchIndices = %_RegExpExec(this, string, i, $regexpLastMatchInfo);
|
||||
// matchIndices is either null or the RegExpLastMatchInfo array.
|
||||
var matchIndices = %_RegExpExec(this, string, i, RegExpLastMatchInfo);
|
||||
|
||||
if (IS_NULL(matchIndices)) {
|
||||
this.lastIndex = 0;
|
||||
@ -182,7 +179,7 @@ function RegExpExecJS(string) {
|
||||
// Successful match.
|
||||
$regexpLastMatchInfoOverride = null;
|
||||
if (updateLastIndex) {
|
||||
this.lastIndex = $regexpLastMatchInfo[CAPTURE1];
|
||||
this.lastIndex = RegExpLastMatchInfo[CAPTURE1];
|
||||
}
|
||||
RETURN_NEW_RESULT_FROM_MATCH_INFO(matchIndices, string);
|
||||
}
|
||||
@ -214,14 +211,14 @@ function RegExpTest(string) {
|
||||
this.lastIndex = 0;
|
||||
return false;
|
||||
}
|
||||
// matchIndices is either null or the $regexpLastMatchInfo array.
|
||||
var matchIndices = %_RegExpExec(this, string, i, $regexpLastMatchInfo);
|
||||
// matchIndices is either null or the RegExpLastMatchInfo array.
|
||||
var matchIndices = %_RegExpExec(this, string, i, RegExpLastMatchInfo);
|
||||
if (IS_NULL(matchIndices)) {
|
||||
this.lastIndex = 0;
|
||||
return false;
|
||||
}
|
||||
$regexpLastMatchInfoOverride = null;
|
||||
this.lastIndex = $regexpLastMatchInfo[CAPTURE1];
|
||||
this.lastIndex = RegExpLastMatchInfo[CAPTURE1];
|
||||
return true;
|
||||
} else {
|
||||
// Non-global, non-sticky regexp.
|
||||
@ -235,8 +232,8 @@ function RegExpTest(string) {
|
||||
%_StringCharCodeAt(regexp.source, 2) != 63) { // '?'
|
||||
regexp = TrimRegExp(regexp);
|
||||
}
|
||||
// matchIndices is either null or the $regexpLastMatchInfo array.
|
||||
var matchIndices = %_RegExpExec(regexp, string, 0, $regexpLastMatchInfo);
|
||||
// matchIndices is either null or the RegExpLastMatchInfo array.
|
||||
var matchIndices = %_RegExpExec(regexp, string, 0, RegExpLastMatchInfo);
|
||||
if (IS_NULL(matchIndices)) {
|
||||
this.lastIndex = 0;
|
||||
return false;
|
||||
@ -281,10 +278,10 @@ function RegExpGetLastMatch() {
|
||||
if ($regexpLastMatchInfoOverride !== null) {
|
||||
return OVERRIDE_MATCH($regexpLastMatchInfoOverride);
|
||||
}
|
||||
var regExpSubject = LAST_SUBJECT($regexpLastMatchInfo);
|
||||
var regExpSubject = LAST_SUBJECT(RegExpLastMatchInfo);
|
||||
return %_SubString(regExpSubject,
|
||||
$regexpLastMatchInfo[CAPTURE0],
|
||||
$regexpLastMatchInfo[CAPTURE1]);
|
||||
RegExpLastMatchInfo[CAPTURE0],
|
||||
RegExpLastMatchInfo[CAPTURE1]);
|
||||
}
|
||||
|
||||
|
||||
@ -294,14 +291,14 @@ function RegExpGetLastParen() {
|
||||
if (override.length <= 3) return '';
|
||||
return override[override.length - 3];
|
||||
}
|
||||
var length = NUMBER_OF_CAPTURES($regexpLastMatchInfo);
|
||||
var length = NUMBER_OF_CAPTURES(RegExpLastMatchInfo);
|
||||
if (length <= 2) return ''; // There were no captures.
|
||||
// We match the SpiderMonkey behavior: return the substring defined by the
|
||||
// last pair (after the first pair) of elements of the capture array even if
|
||||
// it is empty.
|
||||
var regExpSubject = LAST_SUBJECT($regexpLastMatchInfo);
|
||||
var start = $regexpLastMatchInfo[CAPTURE(length - 2)];
|
||||
var end = $regexpLastMatchInfo[CAPTURE(length - 1)];
|
||||
var regExpSubject = LAST_SUBJECT(RegExpLastMatchInfo);
|
||||
var start = RegExpLastMatchInfo[CAPTURE(length - 2)];
|
||||
var end = RegExpLastMatchInfo[CAPTURE(length - 1)];
|
||||
if (start != -1 && end != -1) {
|
||||
return %_SubString(regExpSubject, start, end);
|
||||
}
|
||||
@ -313,8 +310,8 @@ function RegExpGetLeftContext() {
|
||||
var start_index;
|
||||
var subject;
|
||||
if (!$regexpLastMatchInfoOverride) {
|
||||
start_index = $regexpLastMatchInfo[CAPTURE0];
|
||||
subject = LAST_SUBJECT($regexpLastMatchInfo);
|
||||
start_index = RegExpLastMatchInfo[CAPTURE0];
|
||||
subject = LAST_SUBJECT(RegExpLastMatchInfo);
|
||||
} else {
|
||||
var override = $regexpLastMatchInfoOverride;
|
||||
start_index = OVERRIDE_POS(override);
|
||||
@ -328,8 +325,8 @@ function RegExpGetRightContext() {
|
||||
var start_index;
|
||||
var subject;
|
||||
if (!$regexpLastMatchInfoOverride) {
|
||||
start_index = $regexpLastMatchInfo[CAPTURE1];
|
||||
subject = LAST_SUBJECT($regexpLastMatchInfo);
|
||||
start_index = RegExpLastMatchInfo[CAPTURE1];
|
||||
subject = LAST_SUBJECT(RegExpLastMatchInfo);
|
||||
} else {
|
||||
var override = $regexpLastMatchInfoOverride;
|
||||
subject = OVERRIDE_SUBJECT(override);
|
||||
@ -352,11 +349,11 @@ function RegExpMakeCaptureGetter(n) {
|
||||
return '';
|
||||
}
|
||||
var index = n * 2;
|
||||
if (index >= NUMBER_OF_CAPTURES($regexpLastMatchInfo)) return '';
|
||||
var matchStart = $regexpLastMatchInfo[CAPTURE(index)];
|
||||
var matchEnd = $regexpLastMatchInfo[CAPTURE(index + 1)];
|
||||
if (index >= NUMBER_OF_CAPTURES(RegExpLastMatchInfo)) return '';
|
||||
var matchStart = RegExpLastMatchInfo[CAPTURE(index)];
|
||||
var matchEnd = RegExpLastMatchInfo[CAPTURE(index + 1)];
|
||||
if (matchStart == -1 || matchEnd == -1) return '';
|
||||
return %_SubString(LAST_SUBJECT($regexpLastMatchInfo), matchStart, matchEnd);
|
||||
return %_SubString(LAST_SUBJECT(RegExpLastMatchInfo), matchStart, matchEnd);
|
||||
};
|
||||
}
|
||||
|
||||
@ -367,7 +364,7 @@ function RegExpMakeCaptureGetter(n) {
|
||||
GlobalRegExp.prototype, 'constructor', GlobalRegExp, DONT_ENUM);
|
||||
%SetCode(GlobalRegExp, RegExpConstructor);
|
||||
|
||||
$installFunctions(GlobalRegExp.prototype, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, [
|
||||
"exec", RegExpExecJS,
|
||||
"test", RegExpTest,
|
||||
"toString", RegExpToString,
|
||||
@ -381,11 +378,11 @@ $installFunctions(GlobalRegExp.prototype, DONT_ENUM, [
|
||||
// value is set the value it is set to is coerced to a string.
|
||||
// Getter and setter for the input.
|
||||
var RegExpGetInput = function() {
|
||||
var regExpInput = LAST_INPUT($regexpLastMatchInfo);
|
||||
var regExpInput = LAST_INPUT(RegExpLastMatchInfo);
|
||||
return IS_UNDEFINED(regExpInput) ? "" : regExpInput;
|
||||
};
|
||||
var RegExpSetInput = function(string) {
|
||||
LAST_INPUT($regexpLastMatchInfo) = $toString(string);
|
||||
LAST_INPUT(RegExpLastMatchInfo) = $toString(string);
|
||||
};
|
||||
|
||||
%OptimizeObjectForAddingMultipleProperties(GlobalRegExp, 22);
|
||||
@ -443,7 +440,13 @@ for (var i = 1; i < 10; ++i) {
|
||||
}
|
||||
%ToFastProperties(GlobalRegExp);
|
||||
|
||||
$regexpExecNoTests = RegExpExecNoTests;
|
||||
$regexpExec = DoRegExpExec;
|
||||
// -------------------------------------------------------------------
|
||||
// Exports
|
||||
|
||||
utils.Export(function(to) {
|
||||
to.RegExpExec = DoRegExpExec;
|
||||
to.RegExpExecNoTests = RegExpExecNoTests;
|
||||
to.RegExpLastMatchInfo = RegExpLastMatchInfo;
|
||||
});
|
||||
|
||||
})
|
||||
|
@ -8,9 +8,18 @@
|
||||
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Imports
|
||||
|
||||
var GlobalString = global.String;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
var ArrayIteratorCreateResultObject;
|
||||
|
||||
utils.Import(function(from) {
|
||||
ArrayIteratorCreateResultObject = from.ArrayIteratorCreateResultObject;
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
var stringIteratorIteratedStringSymbol =
|
||||
GLOBAL_PRIVATE("StringIterator#iteratedString");
|
||||
@ -41,7 +50,7 @@ function StringIteratorNext() {
|
||||
|
||||
var s = GET_PRIVATE(iterator, stringIteratorIteratedStringSymbol);
|
||||
if (IS_UNDEFINED(s)) {
|
||||
return $iteratorCreateResultObject(UNDEFINED, true);
|
||||
return ArrayIteratorCreateResultObject(UNDEFINED, true);
|
||||
}
|
||||
|
||||
var position = GET_PRIVATE(iterator, stringIteratorNextIndexSymbol);
|
||||
@ -50,7 +59,7 @@ function StringIteratorNext() {
|
||||
if (position >= length) {
|
||||
SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol,
|
||||
UNDEFINED);
|
||||
return $iteratorCreateResultObject(UNDEFINED, true);
|
||||
return ArrayIteratorCreateResultObject(UNDEFINED, true);
|
||||
}
|
||||
|
||||
var first = %_StringCharCodeAt(s, position);
|
||||
@ -67,7 +76,7 @@ function StringIteratorNext() {
|
||||
|
||||
SET_PRIVATE(iterator, stringIteratorNextIndexSymbol, position);
|
||||
|
||||
return $iteratorCreateResultObject(resultString, false);
|
||||
return ArrayIteratorCreateResultObject(resultString, false);
|
||||
}
|
||||
|
||||
|
||||
@ -81,13 +90,13 @@ function StringPrototypeIterator() {
|
||||
%FunctionSetPrototype(StringIterator, {__proto__: $iteratorPrototype});
|
||||
%FunctionSetInstanceClassName(StringIterator, 'String Iterator');
|
||||
|
||||
$installFunctions(StringIterator.prototype, DONT_ENUM, [
|
||||
utils.InstallFunctions(StringIterator.prototype, DONT_ENUM, [
|
||||
'next', StringIteratorNext
|
||||
]);
|
||||
%AddNamedProperty(StringIterator.prototype, symbolToStringTag,
|
||||
"String Iterator", READ_ONLY | DONT_ENUM);
|
||||
|
||||
$setFunctionName(StringPrototypeIterator, symbolIterator);
|
||||
utils.SetFunctionName(StringPrototypeIterator, symbolIterator);
|
||||
%AddNamedProperty(GlobalString.prototype, symbolIterator,
|
||||
StringPrototypeIterator, DONT_ENUM);
|
||||
|
||||
|
@ -16,10 +16,16 @@ var InternalPackedArray = utils.InternalPackedArray;
|
||||
|
||||
var MathMax;
|
||||
var MathMin;
|
||||
var RegExpExec;
|
||||
var RegExpExecNoTests;
|
||||
var RegExpLastMatchInfo;
|
||||
|
||||
utils.Import(function(from) {
|
||||
MathMax = from.MathMax;
|
||||
MathMin = from.MathMin;
|
||||
RegExpExec = from.RegExpExec;
|
||||
RegExpExecNoTests = from.RegExpExecNoTests;
|
||||
RegExpLastMatchInfo = from.RegExpLastMatchInfo;
|
||||
});
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@ -162,15 +168,15 @@ function StringMatchJS(regexp) {
|
||||
// value is discarded.
|
||||
var lastIndex = regexp.lastIndex;
|
||||
TO_INTEGER_FOR_SIDE_EFFECT(lastIndex);
|
||||
if (!regexp.global) return $regexpExecNoTests(regexp, subject, 0);
|
||||
var result = %StringMatch(subject, regexp, $regexpLastMatchInfo);
|
||||
if (!regexp.global) return RegExpExecNoTests(regexp, subject, 0);
|
||||
var result = %StringMatch(subject, regexp, RegExpLastMatchInfo);
|
||||
if (result !== null) $regexpLastMatchInfoOverride = null;
|
||||
regexp.lastIndex = 0;
|
||||
return result;
|
||||
}
|
||||
// Non-regexp argument.
|
||||
regexp = new GlobalRegExp(regexp);
|
||||
return $regexpExecNoTests(regexp, subject, 0);
|
||||
return RegExpExecNoTests(regexp, subject, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -195,7 +201,7 @@ function StringNormalizeJS(form) {
|
||||
}
|
||||
|
||||
|
||||
// This has the same size as the $regexpLastMatchInfo array, and can be used
|
||||
// This has the same size as the RegExpLastMatchInfo array, and can be used
|
||||
// for functions that expect that structure to be returned. It is used when
|
||||
// the needle is a string rather than a regexp. In this case we can't update
|
||||
// lastMatchArray without erroneously affecting the properties on the global
|
||||
@ -237,7 +243,7 @@ function StringReplace(search, replace) {
|
||||
|
||||
if (!search.global) {
|
||||
// Non-global regexp search, string replace.
|
||||
var match = $regexpExec(search, subject, 0);
|
||||
var match = RegExpExec(search, subject, 0);
|
||||
if (match == null) {
|
||||
search.lastIndex = 0
|
||||
return subject;
|
||||
@ -246,7 +252,7 @@ function StringReplace(search, replace) {
|
||||
return %_SubString(subject, 0, match[CAPTURE0]) +
|
||||
%_SubString(subject, match[CAPTURE1], subject.length)
|
||||
}
|
||||
return ExpandReplacement(replace, subject, $regexpLastMatchInfo,
|
||||
return ExpandReplacement(replace, subject, RegExpLastMatchInfo,
|
||||
%_SubString(subject, 0, match[CAPTURE0])) +
|
||||
%_SubString(subject, match[CAPTURE1], subject.length);
|
||||
}
|
||||
@ -255,17 +261,17 @@ function StringReplace(search, replace) {
|
||||
search.lastIndex = 0;
|
||||
if ($regexpLastMatchInfoOverride == null) {
|
||||
return %StringReplaceGlobalRegExpWithString(
|
||||
subject, search, replace, $regexpLastMatchInfo);
|
||||
subject, search, replace, RegExpLastMatchInfo);
|
||||
} else {
|
||||
// We use this hack to detect whether StringReplaceRegExpWithString
|
||||
// found at least one hit. In that case we need to remove any
|
||||
// override.
|
||||
var saved_subject = $regexpLastMatchInfo[LAST_SUBJECT_INDEX];
|
||||
$regexpLastMatchInfo[LAST_SUBJECT_INDEX] = 0;
|
||||
var saved_subject = RegExpLastMatchInfo[LAST_SUBJECT_INDEX];
|
||||
RegExpLastMatchInfo[LAST_SUBJECT_INDEX] = 0;
|
||||
var answer = %StringReplaceGlobalRegExpWithString(
|
||||
subject, search, replace, $regexpLastMatchInfo);
|
||||
if (%_IsSmi($regexpLastMatchInfo[LAST_SUBJECT_INDEX])) {
|
||||
$regexpLastMatchInfo[LAST_SUBJECT_INDEX] = saved_subject;
|
||||
subject, search, replace, RegExpLastMatchInfo);
|
||||
if (%_IsSmi(RegExpLastMatchInfo[LAST_SUBJECT_INDEX])) {
|
||||
RegExpLastMatchInfo[LAST_SUBJECT_INDEX] = saved_subject;
|
||||
} else {
|
||||
$regexpLastMatchInfoOverride = null;
|
||||
}
|
||||
@ -431,7 +437,7 @@ function StringReplaceGlobalRegExpWithFunction(subject, regexp, replace) {
|
||||
}
|
||||
var res = %RegExpExecMultiple(regexp,
|
||||
subject,
|
||||
$regexpLastMatchInfo,
|
||||
RegExpLastMatchInfo,
|
||||
resultArray);
|
||||
regexp.lastIndex = 0;
|
||||
if (IS_NULL(res)) {
|
||||
@ -440,7 +446,7 @@ function StringReplaceGlobalRegExpWithFunction(subject, regexp, replace) {
|
||||
return subject;
|
||||
}
|
||||
var len = res.length;
|
||||
if (NUMBER_OF_CAPTURES($regexpLastMatchInfo) == 2) {
|
||||
if (NUMBER_OF_CAPTURES(RegExpLastMatchInfo) == 2) {
|
||||
// If the number of captures is two then there are no explicit captures in
|
||||
// the regexp, just the implicit capture that captures the whole match. In
|
||||
// this case we can simplify quite a bit and end up with something faster.
|
||||
@ -494,7 +500,7 @@ function StringReplaceGlobalRegExpWithFunction(subject, regexp, replace) {
|
||||
|
||||
|
||||
function StringReplaceNonGlobalRegExpWithFunction(subject, regexp, replace) {
|
||||
var matchInfo = $regexpExec(regexp, subject, 0);
|
||||
var matchInfo = RegExpExec(regexp, subject, 0);
|
||||
if (IS_NULL(matchInfo)) {
|
||||
regexp.lastIndex = 0;
|
||||
return subject;
|
||||
@ -542,7 +548,7 @@ function StringSearch(re) {
|
||||
} else {
|
||||
regexp = new GlobalRegExp(re);
|
||||
}
|
||||
var match = $regexpExec(regexp, TO_STRING_INLINE(this), 0);
|
||||
var match = RegExpExec(regexp, TO_STRING_INLINE(this), 0);
|
||||
if (match) {
|
||||
return match[CAPTURE0];
|
||||
}
|
||||
@ -628,7 +634,7 @@ function StringSplitJS(separator, limit) {
|
||||
|
||||
function StringSplitOnRegExp(subject, separator, limit, length) {
|
||||
if (length === 0) {
|
||||
if ($regexpExec(separator, subject, 0, 0) != null) {
|
||||
if (RegExpExec(separator, subject, 0, 0) != null) {
|
||||
return [];
|
||||
}
|
||||
return [subject];
|
||||
@ -647,7 +653,7 @@ function StringSplitOnRegExp(subject, separator, limit, length) {
|
||||
break;
|
||||
}
|
||||
|
||||
var matchInfo = $regexpExec(separator, subject, startIndex);
|
||||
var matchInfo = RegExpExec(separator, subject, startIndex);
|
||||
if (matchInfo == null || length === (startMatch = matchInfo[CAPTURE0])) {
|
||||
result[result.length] = %_SubString(subject, currentIndex, length);
|
||||
break;
|
||||
@ -1124,14 +1130,14 @@ function StringRaw(callSite) {
|
||||
GlobalString.prototype, "constructor", GlobalString, DONT_ENUM);
|
||||
|
||||
// Set up the non-enumerable functions on the String object.
|
||||
$installFunctions(GlobalString, DONT_ENUM, [
|
||||
utils.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, [
|
||||
utils.InstallFunctions(GlobalString.prototype, DONT_ENUM, [
|
||||
"valueOf", StringValueOf,
|
||||
"toString", StringToString,
|
||||
"charAt", StringCharAtJS,
|
||||
|
@ -18,9 +18,18 @@ var $symbolToString;
|
||||
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Imports
|
||||
|
||||
var GlobalObject = global.Object;
|
||||
var GlobalSymbol = global.Symbol;
|
||||
|
||||
var ObjectGetOwnPropertyKeys;
|
||||
|
||||
utils.Import(function(from) {
|
||||
ObjectGetOwnPropertyKeys = from.ObjectGetOwnPropertyKeys;
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
function SymbolConstructor(x) {
|
||||
@ -73,7 +82,7 @@ function ObjectGetOwnPropertySymbols(obj) {
|
||||
|
||||
// TODO(arv): Proxies use a shared trap for String and Symbol keys.
|
||||
|
||||
return $objectGetOwnPropertyKeys(obj, PROPERTY_ATTRIBUTES_STRING);
|
||||
return ObjectGetOwnPropertyKeys(obj, PROPERTY_ATTRIBUTES_STRING);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@ -81,7 +90,7 @@ function ObjectGetOwnPropertySymbols(obj) {
|
||||
%SetCode(GlobalSymbol, SymbolConstructor);
|
||||
%FunctionSetPrototype(GlobalSymbol, new GlobalObject());
|
||||
|
||||
$installConstants(GlobalSymbol, [
|
||||
utils.InstallConstants(GlobalSymbol, [
|
||||
// TODO(rossberg): expose when implemented.
|
||||
// "hasInstance", symbolHasInstance,
|
||||
// "isConcatSpreadable", symbolIsConcatSpreadable,
|
||||
@ -93,7 +102,7 @@ $installConstants(GlobalSymbol, [
|
||||
"unscopables", symbolUnscopables
|
||||
]);
|
||||
|
||||
$installFunctions(GlobalSymbol, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalSymbol, DONT_ENUM, [
|
||||
"for", SymbolFor,
|
||||
"keyFor", SymbolKeyFor
|
||||
]);
|
||||
@ -103,12 +112,12 @@ $installFunctions(GlobalSymbol, DONT_ENUM, [
|
||||
%AddNamedProperty(
|
||||
GlobalSymbol.prototype, symbolToStringTag, "Symbol", DONT_ENUM | READ_ONLY);
|
||||
|
||||
$installFunctions(GlobalSymbol.prototype, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalSymbol.prototype, DONT_ENUM, [
|
||||
"toString", SymbolToString,
|
||||
"valueOf", SymbolValueOf
|
||||
]);
|
||||
|
||||
$installFunctions(GlobalObject, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalObject, DONT_ENUM, [
|
||||
"getOwnPropertySymbols", ObjectGetOwnPropertySymbols
|
||||
]);
|
||||
|
||||
|
2
src/third_party/fdlibm/fdlibm.js
vendored
2
src/third_party/fdlibm/fdlibm.js
vendored
@ -1023,7 +1023,7 @@ function MathLog2(x) {
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
$installFunctions(GlobalMath, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalMath, DONT_ENUM, [
|
||||
"cos", MathCos,
|
||||
"sin", MathSin,
|
||||
"tan", MathTan,
|
||||
|
@ -16,17 +16,6 @@ var GlobalArrayBuffer = global.ArrayBuffer;
|
||||
var GlobalDataView = global.DataView;
|
||||
var GlobalObject = global.Object;
|
||||
|
||||
var MathMax;
|
||||
var MathMin;
|
||||
|
||||
utils.Import(function(from) {
|
||||
MathMax = from.MathMax;
|
||||
MathMin = from.MathMin;
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
|
||||
macro TYPED_ARRAYS(FUNCTION)
|
||||
// arrayIds below should be synchronized with Runtime_TypedArrayInitialize.
|
||||
FUNCTION(1, Uint8Array, 1)
|
||||
@ -46,6 +35,14 @@ endmacro
|
||||
|
||||
TYPED_ARRAYS(DECLARE_GLOBALS)
|
||||
|
||||
var MathMax;
|
||||
var MathMin;
|
||||
|
||||
utils.Import(function(from) {
|
||||
MathMax = from.MathMax;
|
||||
MathMin = from.MathMin;
|
||||
});
|
||||
|
||||
// --------------- Typed Arrays ---------------------
|
||||
|
||||
macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE)
|
||||
@ -326,16 +323,16 @@ macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE)
|
||||
%AddNamedProperty(GlobalNAME.prototype,
|
||||
"BYTES_PER_ELEMENT", ELEMENT_SIZE,
|
||||
READ_ONLY | DONT_ENUM | DONT_DELETE);
|
||||
$installGetter(GlobalNAME.prototype, "buffer", NAME_GetBuffer);
|
||||
$installGetter(GlobalNAME.prototype, "byteOffset", NAME_GetByteOffset,
|
||||
DONT_ENUM | DONT_DELETE);
|
||||
$installGetter(GlobalNAME.prototype, "byteLength", NAME_GetByteLength,
|
||||
DONT_ENUM | DONT_DELETE);
|
||||
$installGetter(GlobalNAME.prototype, "length", NAME_GetLength,
|
||||
DONT_ENUM | DONT_DELETE);
|
||||
$installGetter(GlobalNAME.prototype, symbolToStringTag,
|
||||
TypedArrayGetToStringTag);
|
||||
$installFunctions(GlobalNAME.prototype, DONT_ENUM, [
|
||||
utils.InstallGetter(GlobalNAME.prototype, "buffer", NAME_GetBuffer);
|
||||
utils.InstallGetter(GlobalNAME.prototype, "byteOffset", NAME_GetByteOffset,
|
||||
DONT_ENUM | DONT_DELETE);
|
||||
utils.InstallGetter(GlobalNAME.prototype, "byteLength", NAME_GetByteLength,
|
||||
DONT_ENUM | DONT_DELETE);
|
||||
utils.InstallGetter(GlobalNAME.prototype, "length", NAME_GetLength,
|
||||
DONT_ENUM | DONT_DELETE);
|
||||
utils.InstallGetter(GlobalNAME.prototype, symbolToStringTag,
|
||||
TypedArrayGetToStringTag);
|
||||
utils.InstallFunctions(GlobalNAME.prototype, DONT_ENUM, [
|
||||
"subarray", NAMESubArray,
|
||||
"set", TypedArraySet
|
||||
]);
|
||||
@ -442,11 +439,13 @@ DATA_VIEW_TYPES(DATA_VIEW_GETTER_SETTER)
|
||||
%AddNamedProperty(GlobalDataView.prototype, symbolToStringTag, "DataView",
|
||||
READ_ONLY|DONT_ENUM);
|
||||
|
||||
$installGetter(GlobalDataView.prototype, "buffer", DataViewGetBufferJS);
|
||||
$installGetter(GlobalDataView.prototype, "byteOffset", DataViewGetByteOffset);
|
||||
$installGetter(GlobalDataView.prototype, "byteLength", DataViewGetByteLength);
|
||||
utils.InstallGetter(GlobalDataView.prototype, "buffer", DataViewGetBufferJS);
|
||||
utils.InstallGetter(GlobalDataView.prototype, "byteOffset",
|
||||
DataViewGetByteOffset);
|
||||
utils.InstallGetter(GlobalDataView.prototype, "byteLength",
|
||||
DataViewGetByteLength);
|
||||
|
||||
$installFunctions(GlobalDataView.prototype, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalDataView.prototype, DONT_ENUM, [
|
||||
"getInt8", DataViewGetInt8JS,
|
||||
"setInt8", DataViewSetInt8JS,
|
||||
|
||||
|
@ -360,7 +360,7 @@ function URIEncodeComponent(component) {
|
||||
|
||||
// Set up non-enumerable URI functions on the global object and set
|
||||
// their names.
|
||||
$installFunctions(global, DONT_ENUM, [
|
||||
utils.InstallFunctions(global, DONT_ENUM, [
|
||||
"escape", URIEscapeJS,
|
||||
"unescape", URIUnescapeJS,
|
||||
"decodeURI", URIDecode,
|
||||
|
218
src/v8natives.js
218
src/v8natives.js
@ -2,35 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
var $delete;
|
||||
var $functionSourceString;
|
||||
var $getIterator;
|
||||
var $getMethod;
|
||||
var $globalEval;
|
||||
var $installConstants;
|
||||
var $installFunctions;
|
||||
var $installGetter;
|
||||
var $isFinite;
|
||||
var $isNaN;
|
||||
var $newFunctionString;
|
||||
var $numberIsNaN;
|
||||
var $objectDefineProperties;
|
||||
var $objectDefineProperty;
|
||||
var $objectFreeze;
|
||||
var $objectGetOwnPropertyDescriptor;
|
||||
var $objectGetOwnPropertyKeys;
|
||||
var $objectHasOwnProperty;
|
||||
var $objectIsFrozen;
|
||||
var $objectIsSealed;
|
||||
var $objectLookupGetter;
|
||||
var $objectLookupSetter;
|
||||
var $objectToString;
|
||||
var $overrideFunction;
|
||||
var $ownPropertyKeys;
|
||||
var $setFunctionName;
|
||||
var $setUpLockedPrototype;
|
||||
var $toCompletePropertyDescriptor;
|
||||
var $toNameArray;
|
||||
|
||||
(function(global, utils) {
|
||||
|
||||
@ -47,6 +22,9 @@ var GlobalObject = global.Object;
|
||||
var InternalArray = utils.InternalArray;
|
||||
|
||||
var MathAbs;
|
||||
var ProxyDelegateCallAndConstruct;
|
||||
var ProxyDerivedHasOwnTrap;
|
||||
var ProxyDerivedKeysTrap;
|
||||
var StringIndexOf;
|
||||
|
||||
utils.Import(function(from) {
|
||||
@ -54,113 +32,11 @@ utils.Import(function(from) {
|
||||
StringIndexOf = from.StringIndexOf;
|
||||
});
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// ES6 - 9.2.11 SetFunctionName
|
||||
function SetFunctionName(f, name, prefix) {
|
||||
if (IS_SYMBOL(name)) {
|
||||
name = "[" + %SymbolDescription(name) + "]";
|
||||
}
|
||||
if (IS_UNDEFINED(prefix)) {
|
||||
%FunctionSetName(f, name);
|
||||
} else {
|
||||
%FunctionSetName(f, prefix + " " + name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Helper function used to install functions on objects.
|
||||
function InstallFunctions(object, attributes, functions) {
|
||||
%OptimizeObjectForAddingMultipleProperties(object, functions.length >> 1);
|
||||
for (var i = 0; i < functions.length; i += 2) {
|
||||
var key = functions[i];
|
||||
var f = functions[i + 1];
|
||||
SetFunctionName(f, key);
|
||||
%FunctionRemovePrototype(f);
|
||||
%AddNamedProperty(object, key, f, attributes);
|
||||
%SetNativeFlag(f);
|
||||
}
|
||||
%ToFastProperties(object);
|
||||
}
|
||||
|
||||
|
||||
function OverrideFunction(object, name, f) {
|
||||
ObjectDefineProperty(object, name, { value: f,
|
||||
writeable: true,
|
||||
configurable: true,
|
||||
enumerable: false });
|
||||
SetFunctionName(f, name);
|
||||
%FunctionRemovePrototype(f);
|
||||
%SetNativeFlag(f);
|
||||
}
|
||||
|
||||
|
||||
// Helper function to install a getter-only accessor property.
|
||||
function InstallGetter(object, name, getter, attributes) {
|
||||
if (typeof attributes == "undefined") {
|
||||
attributes = DONT_ENUM;
|
||||
}
|
||||
SetFunctionName(getter, name, "get");
|
||||
%FunctionRemovePrototype(getter);
|
||||
%DefineAccessorPropertyUnchecked(object, name, getter, null, attributes);
|
||||
%SetNativeFlag(getter);
|
||||
}
|
||||
|
||||
|
||||
// Helper function to install a getter/setter accessor property.
|
||||
function InstallGetterSetter(object, name, getter, setter) {
|
||||
SetFunctionName(getter, name, "get");
|
||||
SetFunctionName(setter, name, "set");
|
||||
%FunctionRemovePrototype(getter);
|
||||
%FunctionRemovePrototype(setter);
|
||||
%DefineAccessorPropertyUnchecked(object, name, getter, setter, DONT_ENUM);
|
||||
%SetNativeFlag(getter);
|
||||
%SetNativeFlag(setter);
|
||||
}
|
||||
|
||||
|
||||
// Helper function for installing constant properties on objects.
|
||||
function InstallConstants(object, constants) {
|
||||
%OptimizeObjectForAddingMultipleProperties(object, constants.length >> 1);
|
||||
var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY;
|
||||
for (var i = 0; i < constants.length; i += 2) {
|
||||
var name = constants[i];
|
||||
var k = constants[i + 1];
|
||||
%AddNamedProperty(object, name, k, attributes);
|
||||
}
|
||||
%ToFastProperties(object);
|
||||
}
|
||||
|
||||
|
||||
// Prevents changes to the prototype of a built-in function.
|
||||
// The "prototype" property of the function object is made non-configurable,
|
||||
// and the prototype object is made non-extensible. The latter prevents
|
||||
// changing the __proto__ property.
|
||||
function SetUpLockedPrototype(constructor, fields, methods) {
|
||||
%CheckIsBootstrapping();
|
||||
var prototype = constructor.prototype;
|
||||
// Install functions first, because this function is used to initialize
|
||||
// PropertyDescriptor itself.
|
||||
var property_count = (methods.length >> 1) + (fields ? fields.length : 0);
|
||||
if (property_count >= 4) {
|
||||
%OptimizeObjectForAddingMultipleProperties(prototype, property_count);
|
||||
}
|
||||
if (fields) {
|
||||
for (var i = 0; i < fields.length; i++) {
|
||||
%AddNamedProperty(prototype, fields[i],
|
||||
UNDEFINED, DONT_ENUM | DONT_DELETE);
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < methods.length; i += 2) {
|
||||
var key = methods[i];
|
||||
var f = methods[i + 1];
|
||||
%AddNamedProperty(prototype, key, f, DONT_ENUM | DONT_DELETE | READ_ONLY);
|
||||
%SetNativeFlag(f);
|
||||
}
|
||||
%InternalSetPrototype(prototype, null);
|
||||
%ToFastProperties(prototype);
|
||||
}
|
||||
|
||||
utils.ImportFromExperimental(function(from) {
|
||||
ProxyDelegateCallAndConstruct = from.ProxyDelegateCallAndConstruct;
|
||||
ProxyDerivedHasOwnTrap = from.ProxyDerivedHasOwnTrap;
|
||||
ProxyDerivedKeysTrap = from.ProxyDerivedKeysTrap;
|
||||
});
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@ -238,7 +114,7 @@ function GlobalEval(x) {
|
||||
// Set up global object.
|
||||
var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY;
|
||||
|
||||
InstallConstants(global, [
|
||||
utils.InstallConstants(global, [
|
||||
// ECMA 262 - 15.1.1.1.
|
||||
"NaN", NAN,
|
||||
// ECMA-262 - 15.1.1.2.
|
||||
@ -248,7 +124,7 @@ InstallConstants(global, [
|
||||
]);
|
||||
|
||||
// Set up non-enumerable function on the global object.
|
||||
InstallFunctions(global, DONT_ENUM, [
|
||||
utils.InstallFunctions(global, DONT_ENUM, [
|
||||
"isNaN", GlobalIsNaN,
|
||||
"isFinite", GlobalIsFinite,
|
||||
"parseInt", GlobalParseInt,
|
||||
@ -302,7 +178,7 @@ function ObjectHasOwnProperty(V) {
|
||||
if (IS_SYMBOL(V)) return false;
|
||||
|
||||
var handler = %GetHandler(this);
|
||||
return CallTrap1(handler, "hasOwn", $proxyDerivedHasOwnTrap, $toName(V));
|
||||
return CallTrap1(handler, "hasOwn", ProxyDerivedHasOwnTrap, $toName(V));
|
||||
}
|
||||
return %HasOwnProperty(TO_OBJECT_INLINE(this), $toName(V));
|
||||
}
|
||||
@ -385,7 +261,7 @@ function ObjectKeys(obj) {
|
||||
obj = TO_OBJECT_INLINE(obj);
|
||||
if (%_IsJSProxy(obj)) {
|
||||
var handler = %GetHandler(obj);
|
||||
var names = CallTrap0(handler, "keys", $proxyDerivedKeysTrap);
|
||||
var names = CallTrap0(handler, "keys", ProxyDerivedKeysTrap);
|
||||
return ToNameArray(names, "keys", false);
|
||||
}
|
||||
return %OwnKeys(obj);
|
||||
@ -542,7 +418,7 @@ function PropertyDescriptor() {
|
||||
this.hasSetter_ = false;
|
||||
}
|
||||
|
||||
SetUpLockedPrototype(PropertyDescriptor, [
|
||||
utils.SetUpLockedPrototype(PropertyDescriptor, [
|
||||
"value_",
|
||||
"hasValue_",
|
||||
"writable_",
|
||||
@ -1286,7 +1162,7 @@ function ProxyFix(obj) {
|
||||
if (%IsJSFunctionProxy(obj)) {
|
||||
var callTrap = %GetCallTrap(obj);
|
||||
var constructTrap = %GetConstructTrap(obj);
|
||||
var code = $proxyDelegateCallAndConstruct(callTrap, constructTrap);
|
||||
var code = ProxyDelegateCallAndConstruct(callTrap, constructTrap);
|
||||
%Fix(obj); // becomes a regular function
|
||||
%SetCode(obj, code);
|
||||
// TODO(rossberg): What about length and other properties? Not specified.
|
||||
@ -1464,7 +1340,7 @@ function ObjectConstructor(x) {
|
||||
DONT_ENUM);
|
||||
|
||||
// Set up non-enumerable functions on the Object.prototype object.
|
||||
InstallFunctions(GlobalObject.prototype, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalObject.prototype, DONT_ENUM, [
|
||||
"toString", ObjectToString,
|
||||
"toLocaleString", ObjectToLocaleString,
|
||||
"valueOf", ObjectValueOf,
|
||||
@ -1476,11 +1352,11 @@ InstallFunctions(GlobalObject.prototype, DONT_ENUM, [
|
||||
"__defineSetter__", ObjectDefineSetter,
|
||||
"__lookupSetter__", ObjectLookupSetter
|
||||
]);
|
||||
InstallGetterSetter(GlobalObject.prototype, "__proto__", ObjectGetProto,
|
||||
utils.InstallGetterSetter(GlobalObject.prototype, "__proto__", ObjectGetProto,
|
||||
ObjectSetProto);
|
||||
|
||||
// Set up non-enumerable functions in the Object object.
|
||||
InstallFunctions(GlobalObject, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalObject, DONT_ENUM, [
|
||||
"keys", ObjectKeys,
|
||||
"create", ObjectCreate,
|
||||
"defineProperty", ObjectDefineProperty,
|
||||
@ -1545,7 +1421,7 @@ function BooleanValueOf() {
|
||||
%AddNamedProperty(GlobalBoolean.prototype, "constructor", GlobalBoolean,
|
||||
DONT_ENUM);
|
||||
|
||||
InstallFunctions(GlobalBoolean.prototype, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalBoolean.prototype, DONT_ENUM, [
|
||||
"toString", BooleanToString,
|
||||
"valueOf", BooleanValueOf
|
||||
]);
|
||||
@ -1722,7 +1598,7 @@ function NumberIsSafeInteger(number) {
|
||||
%AddNamedProperty(GlobalNumber.prototype, "constructor", GlobalNumber,
|
||||
DONT_ENUM);
|
||||
|
||||
InstallConstants(GlobalNumber, [
|
||||
utils.InstallConstants(GlobalNumber, [
|
||||
// ECMA-262 section 15.7.3.1.
|
||||
"MAX_VALUE", 1.7976931348623157e+308,
|
||||
// ECMA-262 section 15.7.3.2.
|
||||
@ -1742,7 +1618,7 @@ InstallConstants(GlobalNumber, [
|
||||
]);
|
||||
|
||||
// Set up non-enumerable functions on the Number prototype object.
|
||||
InstallFunctions(GlobalNumber.prototype, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalNumber.prototype, DONT_ENUM, [
|
||||
"toString", NumberToStringJS,
|
||||
"toLocaleString", NumberToLocaleString,
|
||||
"valueOf", NumberValueOf,
|
||||
@ -1752,7 +1628,7 @@ InstallFunctions(GlobalNumber.prototype, DONT_ENUM, [
|
||||
]);
|
||||
|
||||
// Harmony Number constructor additions
|
||||
InstallFunctions(GlobalNumber, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalNumber, DONT_ENUM, [
|
||||
"isFinite", NumberIsFinite,
|
||||
"isInteger", NumberIsInteger,
|
||||
"isNaN", NumberIsNaN,
|
||||
@ -1920,7 +1796,7 @@ function FunctionConstructor(arg1) { // length == 1
|
||||
%AddNamedProperty(GlobalFunction.prototype, "constructor", GlobalFunction,
|
||||
DONT_ENUM);
|
||||
|
||||
InstallFunctions(GlobalFunction.prototype, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalFunction.prototype, DONT_ENUM, [
|
||||
"bind", FunctionBind,
|
||||
"toString", FunctionToString
|
||||
]);
|
||||
@ -1944,36 +1820,34 @@ function GetIterator(obj, method) {
|
||||
return iterator;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
// Exports
|
||||
|
||||
$delete = Delete;
|
||||
$functionSourceString = FunctionSourceString;
|
||||
$getIterator = GetIterator;
|
||||
$getMethod = GetMethod;
|
||||
$globalEval = GlobalEval;
|
||||
$installConstants = InstallConstants;
|
||||
$installFunctions = InstallFunctions;
|
||||
$installGetter = InstallGetter;
|
||||
$isFinite = GlobalIsFinite;
|
||||
$isNaN = GlobalIsNaN;
|
||||
$newFunctionString = NewFunctionString;
|
||||
$numberIsNaN = NumberIsNaN;
|
||||
$objectDefineProperties = ObjectDefineProperties;
|
||||
$objectDefineProperty = ObjectDefineProperty;
|
||||
$objectFreeze = ObjectFreezeJS;
|
||||
$objectGetOwnPropertyDescriptor = ObjectGetOwnPropertyDescriptor;
|
||||
$objectGetOwnPropertyKeys = ObjectGetOwnPropertyKeys;
|
||||
$objectHasOwnProperty = ObjectHasOwnProperty;
|
||||
$objectIsFrozen = ObjectIsFrozen;
|
||||
$objectIsSealed = ObjectIsSealed;
|
||||
$objectLookupGetter = ObjectLookupGetter;
|
||||
$objectLookupSetter = ObjectLookupSetter;
|
||||
$objectToString = ObjectToString;
|
||||
$overrideFunction = OverrideFunction;
|
||||
$ownPropertyKeys = OwnPropertyKeys;
|
||||
$setFunctionName = SetFunctionName;
|
||||
$setUpLockedPrototype = SetUpLockedPrototype;
|
||||
$toCompletePropertyDescriptor = ToCompletePropertyDescriptor;
|
||||
$toNameArray = ToNameArray;
|
||||
|
||||
utils.ObjectDefineProperties = ObjectDefineProperties;
|
||||
utils.ObjectDefineProperty = ObjectDefineProperty;
|
||||
|
||||
utils.Export(function(to) {
|
||||
to.Delete = Delete;
|
||||
to.GetIterator = GetIterator;
|
||||
to.GetMethod = GetMethod;
|
||||
to.IsFinite = GlobalIsFinite;
|
||||
to.IsNaN = GlobalIsNaN;
|
||||
to.NewFunctionString = NewFunctionString;
|
||||
to.NumberIsNaN = NumberIsNaN;
|
||||
to.ObjectDefineProperty = ObjectDefineProperty;
|
||||
to.ObjectFreeze = ObjectFreezeJS;
|
||||
to.ObjectGetOwnPropertyKeys = ObjectGetOwnPropertyKeys;
|
||||
to.ObjectHasOwnProperty = ObjectHasOwnProperty;
|
||||
to.ObjectIsFrozen = ObjectIsFrozen;
|
||||
to.ObjectIsSealed = ObjectIsSealed;
|
||||
to.ObjectToString = ObjectToString;
|
||||
to.OwnPropertyKeys = OwnPropertyKeys;
|
||||
to.ToNameArray = ToNameArray;
|
||||
});
|
||||
|
||||
})
|
||||
|
@ -88,7 +88,7 @@ function WeakMapDelete(key) {
|
||||
DONT_ENUM | READ_ONLY);
|
||||
|
||||
// Set up the non-enumerable functions on the WeakMap prototype object.
|
||||
$installFunctions(GlobalWeakMap.prototype, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalWeakMap.prototype, DONT_ENUM, [
|
||||
"get", WeakMapGet,
|
||||
"set", WeakMapSet,
|
||||
"has", WeakMapHas,
|
||||
@ -158,7 +158,7 @@ function WeakSetDelete(value) {
|
||||
DONT_ENUM | READ_ONLY);
|
||||
|
||||
// Set up the non-enumerable functions on the WeakSet prototype object.
|
||||
$installFunctions(GlobalWeakSet.prototype, DONT_ENUM, [
|
||||
utils.InstallFunctions(GlobalWeakSet.prototype, DONT_ENUM, [
|
||||
"add", WeakSetAdd,
|
||||
"has", WeakSetHas,
|
||||
"delete", WeakSetDelete
|
||||
|
@ -29,5 +29,5 @@
|
||||
|
||||
// Test call of JS runtime functions.
|
||||
|
||||
var a = %$isNaN(0/0);
|
||||
assertEquals(true, a);
|
||||
var a = %MakeError(0, "error");
|
||||
assertInstanceof(a, Error);
|
||||
|
Loading…
Reference in New Issue
Block a user