// 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) {
%FunctionSetPrototype(ArrayIterator, {__proto__: $iteratorPrototype});
%FunctionSetInstanceClassName(ArrayIterator, 'Array Iterator');
-utils.InstallFunctions(ArrayIterator.prototype, DONT_ENUM, [
+$installFunctions(ArrayIterator.prototype, DONT_ENUM, [
'next', ArrayIteratorNext
]);
-utils.SetFunctionName(ArrayIteratorIterator, symbolIterator);
+$setFunctionName(ArrayIteratorIterator, symbolIterator);
%AddNamedProperty(ArrayIterator.prototype, symbolIterator,
ArrayIteratorIterator, DONT_ENUM);
%AddNamedProperty(ArrayIterator.prototype, symbolToStringTag,
"Array Iterator", READ_ONLY | DONT_ENUM);
-utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
+$installFunctions(GlobalArray.prototype, DONT_ENUM, [
// No 'values' since it breaks webcompat: http://crbug.com/409858
'entries', ArrayEntries,
'keys', ArrayKeys
TYPED_ARRAYS(EXTEND_TYPED_ARRAY)
-// -------------------------------------------------------------------
-// Exports
-
-utils.Export(function(to) {
- to.ArrayIteratorCreateResultObject = CreateIteratorResultObject;
-});
-
+$iteratorCreateResultObject = CreateIteratorResultObject;
$arrayValues = ArrayValues;
})
// 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) {
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;
});
// -------------------------------------------------------------------
func = array.join;
}
if (!IS_SPEC_FUNCTION(func)) {
- return %_CallFunction(array, ObjectToString);
+ return %_CallFunction(array, $objectToString);
}
return %_CallFunction(array, func);
}
n--;
var value = array[n];
- Delete(array, $toName(n), true);
+ $delete(array, $toName(n), true);
array.length = n;
return value;
}
return;
}
- if (ObjectIsSealed(array)) throw MakeTypeError(kArrayFunctionsOnSealed);
+ if ($objectIsSealed(array)) throw MakeTypeError(kArrayFunctionsOnSealed);
if (%IsObserved(array))
return ObservedArrayShift.call(array, len);
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);
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);
}
DONT_ENUM | READ_ONLY);
// Set up non-enumerable functions on the Array object.
-utils.InstallFunctions(GlobalArray, DONT_ENUM, [
+$installFunctions(GlobalArray, DONT_ENUM, [
"isArray", ArrayIsArray
]);
// set their names.
// Manipulate the length of some of the functions to meet
// expectations set by ECMA-262 or Mozilla.
-utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
+$installFunctions(GlobalArray.prototype, DONT_ENUM, [
"toString", getFunction("toString", ArrayToString),
"toLocaleString", getFunction("toLocaleString", ArrayToLocaleString),
"join", getFunction("join", ArrayJoin),
// 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.
-utils.SetUpLockedPrototype(InternalArray, GlobalArray(), [
+$setUpLockedPrototype(InternalArray, GlobalArray(), [
"concat", getFunction("concat", ArrayConcatJS),
"indexOf", getFunction("indexOf", ArrayIndexOf),
"join", getFunction("join", ArrayJoin),
"splice", getFunction("splice", ArraySplice)
]);
-utils.SetUpLockedPrototype(InternalPackedArray, GlobalArray(), [
+$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;
$arraySplice = ArraySplice;
$arrayUnshift = ArrayUnshift;
+$innerArrayEvery = InnerArrayEvery;
+$innerArrayFilter = InnerArrayFilter;
+$innerArrayForEach = InnerArrayForEach;
+$innerArrayIndexOf = InnerArrayIndexOf;
+$innerArrayLastIndexOf = InnerArrayLastIndexOf;
+$innerArrayMap = InnerArrayMap;
+$innerArrayReverse = InnerArrayReverse;
+$innerArraySome = InnerArraySome;
+$innerArraySort = InnerArraySort;
+
});
%CheckIsBootstrapping();
+
// -------------------------------------------------------------------
// Imports
%AddNamedProperty(GlobalArrayBuffer.prototype,
symbolToStringTag, "ArrayBuffer", DONT_ENUM | READ_ONLY);
-utils.InstallGetter(GlobalArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLen);
+$installGetter(GlobalArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLen);
-utils.InstallFunctions(GlobalArrayBuffer, DONT_ENUM, [
+$installFunctions(GlobalArrayBuffer, DONT_ENUM, [
"isView", ArrayBufferIsViewJS
]);
-utils.InstallFunctions(GlobalArrayBuffer.prototype, DONT_ENUM, [
+$installFunctions(GlobalArrayBuffer.prototype, DONT_ENUM, [
"slice", ArrayBufferSlice
]);
isolate->factory()->NewStringFromAsciiChecked(name);
Handle<Object> fun = JSObject::GetDataProperty(utils, name_string);
Handle<Object> receiver = isolate->factory()->undefined_value();
- Handle<Object> args[] = {utils};
- return !Execution::Call(isolate, fun, receiver, 1, args).is_null();
+ return !Execution::Call(isolate, fun, receiver, 0, NULL).is_null();
}
#undef INSTALL_EXPERIMENTAL_NATIVES
}
- CallUtilsFunction(isolate(), "PostExperimentals");
-
InstallExperimentalNativeFunctions();
return true;
}
%SetCode(SetIterator, SetIteratorConstructor);
%FunctionSetPrototype(SetIterator, {__proto__: $iteratorPrototype});
%FunctionSetInstanceClassName(SetIterator, 'Set Iterator');
-utils.InstallFunctions(SetIterator.prototype, DONT_ENUM, [
+$installFunctions(SetIterator.prototype, DONT_ENUM, [
'next', SetIteratorNextJS
]);
%AddNamedProperty(SetIterator.prototype, symbolToStringTag,
"Set Iterator", READ_ONLY | DONT_ENUM);
-utils.InstallFunctions(GlobalSet.prototype, DONT_ENUM, [
+$installFunctions(GlobalSet.prototype, DONT_ENUM, [
'entries', SetEntries,
'keys', SetValues,
'values', SetValues
%SetCode(MapIterator, MapIteratorConstructor);
%FunctionSetPrototype(MapIterator, {__proto__: $iteratorPrototype});
%FunctionSetInstanceClassName(MapIterator, 'Map Iterator');
-utils.InstallFunctions(MapIterator.prototype, DONT_ENUM, [
+$installFunctions(MapIterator.prototype, DONT_ENUM, [
'next', MapIteratorNextJS
]);
"Map Iterator", READ_ONLY | DONT_ENUM);
-utils.InstallFunctions(GlobalMap.prototype, DONT_ENUM, [
+$installFunctions(GlobalMap.prototype, DONT_ENUM, [
'entries', MapEntries,
'keys', MapKeys,
'values', MapValues
%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) {
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)) {
if (key === candidate) {
return entry;
}
- if (keyIsNaN && NumberIsNaN(candidate)) {
+ if (keyIsNaN && $numberIsNaN(candidate)) {
return entry;
}
}
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)) {
if (key === candidate) {
return entry;
}
- if (keyIsNaN && NumberIsNaN(candidate)) {
+ if (keyIsNaN && $numberIsNaN(candidate)) {
return entry;
}
}
%FunctionSetLength(SetForEach, 1);
// Set up the non-enumerable functions on the Set prototype object.
-utils.InstallGetter(GlobalSet.prototype, "size", SetGetSize);
-utils.InstallFunctions(GlobalSet.prototype, DONT_ENUM, [
+$installGetter(GlobalSet.prototype, "size", SetGetSize);
+$installFunctions(GlobalSet.prototype, DONT_ENUM, [
"add", SetAdd,
"has", SetHas,
"delete", SetDelete,
%FunctionSetLength(MapForEach, 1);
// Set up the non-enumerable functions on the Map prototype object.
-utils.InstallGetter(GlobalMap.prototype, "size", MapGetSize);
-utils.InstallFunctions(GlobalMap.prototype, DONT_ENUM, [
+$installGetter(GlobalMap.prototype, "size", MapGetSize);
+$installFunctions(GlobalMap.prototype, DONT_ENUM, [
"get", MapGet,
"set", MapSet,
"has", MapHas,
// 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;
// -------------------------------------------------------------------
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;
});
// 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
// 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);
// 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);
}
%FunctionSetPrototype(GlobalDate, new GlobalDate(NAN));
// Set up non-enumerable properties of the Date object itself.
-utils.InstallFunctions(GlobalDate, DONT_ENUM, [
+$installFunctions(GlobalDate, DONT_ENUM, [
"UTC", DateUTC,
"parse", DateParse,
"now", DateNow
// Set up non-enumerable functions of the Date prototype object and
// set their names.
-utils.InstallFunctions(GlobalDate.prototype, DONT_ENUM, [
+$installFunctions(GlobalDate.prototype, DONT_ENUM, [
"toString", DateToString,
"toDateString", DateToDateString,
"toTimeString", DateToTimeString,
%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
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.
// Set up non-enumerable functions on the generator prototype object.
var GeneratorObjectPrototype = GeneratorFunctionPrototype.prototype;
-utils.InstallFunctions(GeneratorObjectPrototype,
- DONT_ENUM,
- ["next", GeneratorObjectNext,
- "throw", GeneratorObjectThrow]);
+$installFunctions(GeneratorObjectPrototype,
+ DONT_ENUM,
+ ["next", GeneratorObjectNext,
+ "throw", GeneratorObjectThrow]);
%AddNamedProperty(GeneratorObjectPrototype, "constructor",
GeneratorFunctionPrototype, DONT_ENUM | READ_ONLY);
%FunctionSetLength(ArrayIncludes, 1);
// Set up the non-enumerable functions on the Array prototype object.
-utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
+$installFunctions(GlobalArray.prototype, DONT_ENUM, [
"includes", ArrayIncludes
]);
// 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';
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;
});
// -------------------------------------------------------------------
return array;
}
+$innerArrayCopyWithin = InnerArrayCopyWithin;
// ES6 draft 03-17-15, section 22.1.3.3
function ArrayCopyWithin(target, start, end) {
return;
}
+$innerArrayFind = InnerArrayFind;
// ES6 draft 07-15-13, section 15.4.3.23
function ArrayFind(predicate, thisArg) {
return -1;
}
+$innerArrayFindIndex = InnerArrayFindIndex;
// ES6 draft 07-15-13, section 15.4.3.24
function ArrayFindIndex(predicate, thisArg) {
if (end > length) end = length;
}
- if ((end - i) > 0 && ObjectIsFrozen(array)) {
+ if ((end - i) > 0 && $objectIsFrozen(array)) {
throw MakeTypeError(kArrayFunctionsOnFrozen);
}
array[i] = value;
return array;
}
+$innerArrayFill = InnerArrayFill;
// ES6, draft 04-05-14, section 22.1.3.6
function ArrayFill(value, start, end) {
}
}
- var iterable = GetMethod(items, symbolIterator);
+ var iterable = $getMethod(items, symbolIterator);
var k;
var result;
var mappedValue;
if (!IS_UNDEFINED(iterable)) {
result = %IsConstructor(this) ? new this() : [];
- var iterator = GetIterator(items, iterable);
+ var iterator = $getIterator(items, iterable);
k = 0;
while (true) {
return result;
}
}
+$arrayFrom = ArrayFrom;
// ES6, draft 05-22-14, section 22.1.2.3
function ArrayOf() {
// -------------------------------------------------------------------
-utils.InstallConstants(GlobalSymbol, [
+$installConstants(GlobalSymbol, [
// TODO(dslomov, caitp): Move to symbol.js when shipping
"isConcatSpreadable", symbolIsConcatSpreadable
]);
%FunctionSetLength(ArrayFindIndex, 1);
// Set up non-enumerable functions on the Array object.
-utils.InstallFunctions(GlobalArray, DONT_ENUM, [
+$installFunctions(GlobalArray, DONT_ENUM, [
"from", ArrayFrom,
"of", ArrayOf
]);
// Set up the non-enumerable functions on the Array prototype object.
-utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
+$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;
-});
-
})
%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);
}
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) {
}
// Set up non-enumerable functions on the Object object.
-utils.InstallFunctions(GlobalObject, DONT_ENUM, [
+$installFunctions(GlobalObject, DONT_ENUM, [
"assign", ObjectAssign
]);
var GlobalReflect = global.Reflect;
-utils.InstallFunctions(GlobalReflect, DONT_ENUM, [
+$installFunctions(GlobalReflect, DONT_ENUM, [
"apply", $reflectApply,
"construct", $reflectConstruct
]);
var GlobalSymbol = global.Symbol;
-utils.InstallConstants(GlobalSymbol, [
+$installConstants(GlobalSymbol, [
// TODO(dslomov, caitp): Move to symbol.js when shipping
"toStringTag", symbolToStringTag
]);
%CheckIsBootstrapping();
-// -------------------------------------------------------------------
-// Imports
-
macro TYPED_ARRAYS(FUNCTION)
// arrayIds below should be synchronized with Runtime_TypedArrayInitialize.
FUNCTION(Uint8Array)
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) {
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);
var length = %_TypedArrayGetLength(this);
- return InnerArrayEvery(f, receiver, this, length);
+ return $innerArrayEvery(f, receiver, this, length);
}
%FunctionSetLength(TypedArrayEvery, 1);
var length = %_TypedArrayGetLength(this);
- InnerArrayForEach(f, receiver, this, length);
+ $innerArrayForEach(f, receiver, this, length);
}
%FunctionSetLength(TypedArrayForEach, 1);
var length = %_TypedArrayGetLength(this);
- return InnerArrayFill(value, start, end, this, length);
+ return $innerArrayFill(value, start, end, this, length);
}
%FunctionSetLength(TypedArrayFill, 1);
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);
var length = %_TypedArrayGetLength(this);
- return InnerArrayFind(predicate, thisArg, this, length);
+ return $innerArrayFind(predicate, thisArg, this, length);
}
%FunctionSetLength(TypedArrayFind, 1);
var length = %_TypedArrayGetLength(this);
- return InnerArrayFindIndex(predicate, thisArg, this, length);
+ return $innerArrayFindIndex(predicate, thisArg, this, length);
}
%FunctionSetLength(TypedArrayFindIndex, 1);
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) {
comparefn = TypedArrayComparefn;
}
- return %_CallFunction(this, length, comparefn, InnerArraySort);
+ return %_CallFunction(this, length, comparefn, $innerArraySort);
}
var length = %_TypedArrayGetLength(this);
- return %_CallFunction(this, element, index, length, InnerArrayIndexOf);
+ return %_CallFunction(this, element, index, length, $innerArrayIndexOf);
}
%FunctionSetLength(TypedArrayIndexOf, 1);
var length = %_TypedArrayGetLength(this);
return %_CallFunction(this, element, index, length,
- %_ArgumentsLength(), InnerArrayLastIndexOf);
+ %_ArgumentsLength(), $innerArrayLastIndexOf);
}
%FunctionSetLength(TypedArrayLastIndexOf, 1);
// 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);
var length = %_TypedArrayGetLength(this);
- return InnerArraySome(f, receiver, this, length);
+ return $innerArraySome(f, receiver, this, length);
}
%FunctionSetLength(TypedArraySome, 1);
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);
// TODO(littledan): Fix the TypedArray proto chain (bug v8:4085).
macro EXTEND_TYPED_ARRAY(NAME)
// Set up non-enumerable functions on the object.
- utils.InstallFunctions(GlobalNAME, DONT_ENUM | DONT_DELETE | READ_ONLY, [
+ $installFunctions(GlobalNAME, DONT_ENUM | DONT_DELETE | READ_ONLY, [
"from", TypedArrayFrom,
"of", TypedArrayOf
]);
// Set up non-enumerable functions on the prototype object.
- utils.InstallFunctions(GlobalNAME.prototype, DONT_ENUM, [
+ $installFunctions(GlobalNAME.prototype, DONT_ENUM, [
"copyWithin", TypedArrayCopyWithin,
"every", TypedArrayEvery,
"fill", TypedArrayFill,
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;
});
* 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);
}
}
}
- SetFunctionName(boundMethod, internalName);
+ $setFunctionName(boundMethod, internalName);
%FunctionRemovePrototype(boundMethod);
%SetNativeFlag(boundMethod);
this[internalName] = boundMethod;
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
*/
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;
}
* 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});
}
* 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});
}
// 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},
// 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;
}
},
DONT_ENUM
);
-SetFunctionName(Intl.Collator.prototype.resolvedOptions, 'resolvedOptions');
+$setFunctionName(Intl.Collator.prototype.resolvedOptions, 'resolvedOptions');
%FunctionRemovePrototype(Intl.Collator.prototype.resolvedOptions);
%SetNativeFlag(Intl.Collator.prototype.resolvedOptions);
},
DONT_ENUM
);
-SetFunctionName(Intl.Collator.supportedLocalesOf, 'supportedLocalesOf');
+$setFunctionName(Intl.Collator.supportedLocalesOf, 'supportedLocalesOf');
%FunctionRemovePrototype(Intl.Collator.supportedLocalesOf);
%SetNativeFlag(Intl.Collator.supportedLocalesOf);
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);
getOption, internalOptions);
var requestedLocale = locale.locale + extension;
- var resolved = ObjectDefineProperties({}, {
+ var resolved = $objectDefineProperties({}, {
currency: {writable: true},
currencyDisplay: {writable: true},
locale: {writable: true},
// 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;
}
},
DONT_ENUM
);
-SetFunctionName(Intl.NumberFormat.prototype.resolvedOptions, 'resolvedOptions');
+$setFunctionName(Intl.NumberFormat.prototype.resolvedOptions,
+ 'resolvedOptions');
%FunctionRemovePrototype(Intl.NumberFormat.prototype.resolvedOptions);
%SetNativeFlag(Intl.NumberFormat.prototype.resolvedOptions);
},
DONT_ENUM
);
-SetFunctionName(Intl.NumberFormat.supportedLocalesOf, 'supportedLocalesOf');
+$setFunctionName(Intl.NumberFormat.supportedLocalesOf, 'supportedLocalesOf');
%FunctionRemovePrototype(Intl.NumberFormat.supportedLocalesOf);
%SetNativeFlag(Intl.NumberFormat.supportedLocalesOf);
}
if (needsDefault && (defaults === 'date' || defaults === 'all')) {
- ObjectDefineProperty(options, 'year', {value: 'numeric',
- writable: true,
- enumerable: true,
- configurable: true});
- ObjectDefineProperty(options, 'month', {value: 'numeric',
+ $objectDefineProperty(options, 'year', {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',
+ $objectDefineProperty(options, 'month', {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;
getOption, internalOptions);
var requestedLocale = locale.locale + extension;
- var resolved = ObjectDefineProperties({}, {
+ var resolved = $objectDefineProperties({}, {
calendar: {writable: true},
day: {writable: true},
era: {writable: true},
}
%MarkAsInitializedIntlObjectOfType(dateFormat, 'dateformat', formatter);
- ObjectDefineProperty(dateFormat, 'resolved', {value: resolved});
+ $objectDefineProperty(dateFormat, 'resolved', {value: resolved});
return dateFormat;
}
},
DONT_ENUM
);
-SetFunctionName(Intl.DateTimeFormat.prototype.resolvedOptions,
+$setFunctionName(Intl.DateTimeFormat.prototype.resolvedOptions,
'resolvedOptions');
%FunctionRemovePrototype(Intl.DateTimeFormat.prototype.resolvedOptions);
%SetNativeFlag(Intl.DateTimeFormat.prototype.resolvedOptions);
},
DONT_ENUM
);
-SetFunctionName(Intl.DateTimeFormat.supportedLocalesOf, 'supportedLocalesOf');
+$setFunctionName(Intl.DateTimeFormat.supportedLocalesOf, 'supportedLocalesOf');
%FunctionRemovePrototype(Intl.DateTimeFormat.supportedLocalesOf);
%SetNativeFlag(Intl.DateTimeFormat.supportedLocalesOf);
dateMs = $toNumber(dateValue);
}
- if (!IsFinite(dateMs)) throw MakeRangeError(kDateRange);
+ if (!$isFinite(dateMs)) throw MakeRangeError(kDateRange);
return %InternalDateFormat(%GetImplFromInitializedIntlObject(formatter),
new GlobalDate(dateMs));
'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}
%MarkAsInitializedIntlObjectOfType(iterator, 'breakiterator',
internalIterator);
- ObjectDefineProperty(iterator, 'resolved', {value: resolved});
+ $objectDefineProperty(iterator, 'resolved', {value: resolved});
return iterator;
}
},
DONT_ENUM
);
-SetFunctionName(Intl.v8BreakIterator.prototype.resolvedOptions,
+$setFunctionName(Intl.v8BreakIterator.prototype.resolvedOptions,
'resolvedOptions');
%FunctionRemovePrototype(Intl.v8BreakIterator.prototype.resolvedOptions);
%SetNativeFlag(Intl.v8BreakIterator.prototype.resolvedOptions);
},
DONT_ENUM
);
-SetFunctionName(Intl.v8BreakIterator.supportedLocalesOf, 'supportedLocalesOf');
+$setFunctionName(Intl.v8BreakIterator.supportedLocalesOf, 'supportedLocalesOf');
%FunctionRemovePrototype(Intl.v8BreakIterator.supportedLocalesOf);
%SetNativeFlag(Intl.v8BreakIterator.supportedLocalesOf);
}
-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);
}
* 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);
}
* 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);
}
throw MakeTypeError(kMethodInvokedOnWrongType, "Date");
}
- if (IsNaN(date)) return 'Invalid Date';
+ if ($isNaN(date)) {
+ return 'Invalid Date';
+ }
var internalOptions = toDateTimeOptions(options, required, defaults);
* 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);
}
* 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);
}
* 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);
}
return this;
}
- utils.SetFunctionName(IteratorPrototypeIterator, symbolIterator);
+ $setFunctionName(IteratorPrototypeIterator, symbolIterator);
%AddNamedProperty($iteratorPrototype, symbolIterator,
IteratorPrototypeIterator, DONT_ENUM);
})
var MathMax;
var MathMin;
-var ObjectHasOwnProperty;
utils.Import(function(from) {
MathMax = from.MathMax;
MathMin = from.MathMin;
- ObjectHasOwnProperty = from.ObjectHasOwnProperty;
});
// -------------------------------------------------------------------
}
} else {
for (var p in val) {
- if (HAS_OWN_PROPERTY(val, p)) {
+ if (%_CallFunction(val, p, $objectHasOwnProperty)) {
var newElement = Revive(val, p, reviver);
if (IS_UNDEFINED(newElement)) {
delete val[p];
if (IS_ARRAY(replacer)) {
var length = replacer.length;
for (var i = 0; i < length; i++) {
- if (HAS_OWN_PROPERTY(replacer, i)) {
+ if (%_CallFunction(replacer, i, $objectHasOwnProperty)) {
var p = replacer[i];
var strP = JSONSerialize(p, value, replacer, stack, indent, gap);
if (!IS_UNDEFINED(strP)) {
}
} else {
for (var p in value) {
- if (HAS_OWN_PROPERTY(value, p)) {
+ if (%_CallFunction(value, p, $objectHasOwnProperty)) {
var strP = JSONSerialize(p, value, replacer, stack, indent, gap);
if (!IS_UNDEFINED(strP)) {
var member = %QuoteJSONString(p) + ":";
%AddNamedProperty(GlobalJSON, symbolToStringTag, "JSON", READ_ONLY | DONT_ENUM);
// Set up non-enumerable properties of the JSON object.
-utils.InstallFunctions(GlobalJSON, DONT_ENUM, [
+$installFunctions(GlobalJSON, DONT_ENUM, [
"parse", JSONParse,
"stringify", JSONStringify
]);
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));
%AddNamedProperty(Math, symbolToStringTag, "Math", READ_ONLY | DONT_ENUM);
// Set up math constants.
-utils.InstallConstants(Math, [
+$installConstants(Math, [
// ECMA-262, section 15.8.1.1.
"E", 2.7182818284590452354,
// ECMA-262, section 15.8.1.2.
// Set up non-enumerable functions of the Math object and
// set their names.
-utils.InstallFunctions(Math, DONT_ENUM, [
+$installFunctions(Math, DONT_ENUM, [
"random", MathRandom,
"abs", MathAbs,
"acos", MathAcosJS,
var MakeSyntaxError;
var MakeTypeError;
var MakeURIError;
+var MakeReferenceErrorEmbedded;
+var MakeSyntaxErrorEmbedded;
+var MakeTypeErrorEmbedded;
(function(global, utils) {
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;
}
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;
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;
}
-utils.SetUpLockedPrototype(Script, [
+$setUpLockedPrototype(Script, [
"source",
"name",
"source_url",
}
-utils.SetUpLockedPrototype(SourceLocation,
+$setUpLockedPrototype(SourceLocation,
["script", "position", "line", "column", "start", "end"],
["sourceText", SourceLocationSourceText]
);
StringSubstring);
}
-utils.SetUpLockedPrototype(SourceSlice,
+$setUpLockedPrototype(SourceSlice,
["script", "from_line", "to_line", "from_position", "to_position"],
["sourceText", SourceSliceSourceText]
);
return line;
}
-utils.SetUpLockedPrototype(CallSite, ["receiver", "fun", "pos"], [
+$setUpLockedPrototype(CallSite, ["receiver", "fun", "pos"], [
"getThis", CallSiteGetThis,
"getTypeName", CallSiteGetTypeName,
"isToplevel", CallSiteIsToplevel,
}
lines.push(" at " + line);
}
- return %_CallFunction(lines, "\n", ArrayJoin);
+ return %_CallFunction(lines, "\n", $arrayJoin);
}
// Use a dummy function since we do not actually want to capture a stack trace
// when constructing the initial Error prototytpes.
-var captureStackTrace = function() {};
+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);
+}
// Define special error type constructors.
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
}
}
-utils.InstallFunctions(GlobalError.prototype, DONT_ENUM,
- ['toString', ErrorToString]);
+$installFunctions(GlobalError.prototype, DONT_ENUM,
+ ['toString', ErrorToString]);
$errorToString = ErrorToString;
$getStackTraceLine = GetStackTraceLine;
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;
-
-});
+})
var GlobalObject = global.Object;
var InternalArray = utils.InternalArray;
-var ObjectFreeze;
-var ObjectIsFrozen;
-
-utils.Import(function(from) {
- ObjectFreeze = from.ObjectFreeze;
- ObjectIsFrozen = from.ObjectIsFrozen;
-});
-
// -------------------------------------------------------------------
// Overview:
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);
%DefineDataPropertyUnchecked(
newRecord, prop, changeRecord[prop], READ_ONLY + DONT_DELETE);
}
- ObjectFreeze(newRecord);
+ $objectFreeze(newRecord);
ObjectInfoEnqueueInternalChangeRecord(objectInfo, newRecord);
}
addedCount: addedCount
};
- ObjectFreeze(changeRecord);
- ObjectFreeze(changeRecord.removed);
+ $objectFreeze(changeRecord);
+ $objectFreeze(changeRecord.removed);
ObjectInfoEnqueueInternalChangeRecord(objectInfo, changeRecord);
}
};
}
- ObjectFreeze(changeRecord);
+ $objectFreeze(changeRecord);
ObjectInfoEnqueueInternalChangeRecord(objectInfo, changeRecord);
}
if (%IsJSGlobalProxy(object))
throw MakeTypeError(kObserveGlobalProxy, "getNotifier");
- if (ObjectIsFrozen(object)) return null;
+ if ($objectIsFrozen(object)) return null;
if (!%ObjectWasCreatedInCurrentOrigin(object)) return null;
// -------------------------------------------------------------------
-utils.InstallFunctions(GlobalObject, DONT_ENUM, [
+$installFunctions(GlobalObject, DONT_ENUM, [
"deliverChangeRecords", ObjectDeliverChangeRecords,
"getNotifier", ObjectGetNotifier,
"observe", ObjectObserve,
"unobserve", ObjectUnobserve
]);
-utils.InstallFunctions(GlobalArray, DONT_ENUM, [
+$installFunctions(GlobalArray, DONT_ENUM, [
"observe", ArrayObserve,
"unobserve", ArrayUnobserve
]);
-utils.InstallFunctions(notifierPrototype, DONT_ENUM, [
+$installFunctions(notifierPrototype, DONT_ENUM, [
"notify", ObjectNotifierNotify,
"performChange", ObjectNotifierPerformChange
]);
var imports = UNDEFINED;
var exports = UNDEFINED;
-var imports_from_experimental = UNDEFINED;
-// 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) {
+utils.Export = function Export(f) {
f.next = exports;
exports = 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) {
+utils.Import = 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
-var experimental_exports = UNDEFINED;
-
-function PostNatives(utils) {
+utils.PostNatives = function() {
%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",
];
- experimental_exports = {};
+ var experimental = {};
%OptimizeObjectForAddingMultipleProperties(
- experimental_exports, expose_to_experimental.length);
- for (var key of expose_to_experimental) {
- experimental_exports[key] = container[key];
- }
- %ToFastProperties(experimental_exports);
+ experimental, expose_to_experimental.length);
+ for (var key of expose_to_experimental) experimental[key] = container[key];
+ %ToFastProperties(experimental);
container = UNDEFINED;
- utils.PostNatives = UNDEFINED;
- 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;
+ utils.PostNatives = UNDEFINED;
+ utils.Import = function ImportFromExperimental(f) {
+ f(experimental);
+ };
};
-// -----------------------------------------------------------------------
-
-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,
-]);
-
})
%AddNamedProperty(GlobalPromise.prototype, symbolToStringTag, "Promise",
DONT_ENUM | READ_ONLY);
-utils.InstallFunctions(GlobalPromise, DONT_ENUM, [
+$installFunctions(GlobalPromise, DONT_ENUM, [
"defer", PromiseDeferred,
"accept", PromiseResolved,
"reject", PromiseRejected,
"resolve", PromiseCast
]);
-utils.InstallFunctions(GlobalPromise.prototype, DONT_ENUM, [
+$installFunctions(GlobalPromise.prototype, DONT_ENUM, [
"chain", PromiseChain,
"then", PromiseThen,
"catch", PromiseCatch
// 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;
%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))
if (IS_UNDEFINED(handler.enumerate)) {
return %Apply(DerivedEnumerateTrap, handler, [], 0, 0)
} else {
- return ToNameArray(handler.enumerate(), "enumerate", false)
+ return $toNameArray(handler.enumerate(), "enumerate", false)
}
}
%AddNamedProperty(global, "Proxy", Proxy, DONT_ENUM);
//Set up non-enumerable properties of the Proxy object.
-utils.InstallFunctions(Proxy, DONT_ENUM, [
+$installFunctions(Proxy, DONT_ENUM, [
"create", ProxyCreate,
"createFunction", ProxyCreateFunction
])
-// -------------------------------------------------------------------
-// Exports
-
+$proxyDelegateCallAndConstruct = DelegateCallAndConstruct;
$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;
-});
-
})
// 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;
// -------------------------------------------------------------------
// 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.
-var RegExpLastMatchInfo = new InternalPackedArray(
+$regexpLastMatchInfo = new InternalPackedArray(
2, // REGEXP_NUMBER_OF_CAPTURES
"", // Last subject.
UNDEFINED, // Last input - settable with RegExpSetInput.
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;
}
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);
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;
// Successful match.
$regexpLastMatchInfoOverride = null;
if (updateLastIndex) {
- this.lastIndex = RegExpLastMatchInfo[CAPTURE1];
+ this.lastIndex = $regexpLastMatchInfo[CAPTURE1];
}
RETURN_NEW_RESULT_FROM_MATCH_INFO(matchIndices, 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.
%_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;
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]);
}
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);
}
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);
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);
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);
};
}
GlobalRegExp.prototype, 'constructor', GlobalRegExp, DONT_ENUM);
%SetCode(GlobalRegExp, RegExpConstructor);
-utils.InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, [
+$installFunctions(GlobalRegExp.prototype, DONT_ENUM, [
"exec", RegExpExecJS,
"test", RegExpTest,
"toString", RegExpToString,
// 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);
}
%ToFastProperties(GlobalRegExp);
-// -------------------------------------------------------------------
-// Exports
-
-utils.Export(function(to) {
- to.RegExpExec = DoRegExpExec;
- to.RegExpExecNoTests = RegExpExecNoTests;
- to.RegExpLastMatchInfo = RegExpLastMatchInfo;
-});
+$regexpExecNoTests = RegExpExecNoTests;
+$regexpExec = DoRegExpExec;
})
%CheckIsBootstrapping();
-// -------------------------------------------------------------------
-// Imports
-
var GlobalString = global.String;
-var ArrayIteratorCreateResultObject;
-
-utils.Import(function(from) {
- ArrayIteratorCreateResultObject = from.ArrayIteratorCreateResultObject;
-});
-
-// -------------------------------------------------------------------
+//-------------------------------------------------------------------
var stringIteratorIteratedStringSymbol =
GLOBAL_PRIVATE("StringIterator#iteratedString");
var s = GET_PRIVATE(iterator, stringIteratorIteratedStringSymbol);
if (IS_UNDEFINED(s)) {
- return ArrayIteratorCreateResultObject(UNDEFINED, true);
+ return $iteratorCreateResultObject(UNDEFINED, true);
}
var position = GET_PRIVATE(iterator, stringIteratorNextIndexSymbol);
if (position >= length) {
SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol,
UNDEFINED);
- return ArrayIteratorCreateResultObject(UNDEFINED, true);
+ return $iteratorCreateResultObject(UNDEFINED, true);
}
var first = %_StringCharCodeAt(s, position);
SET_PRIVATE(iterator, stringIteratorNextIndexSymbol, position);
- return ArrayIteratorCreateResultObject(resultString, false);
+ return $iteratorCreateResultObject(resultString, false);
}
%FunctionSetPrototype(StringIterator, {__proto__: $iteratorPrototype});
%FunctionSetInstanceClassName(StringIterator, 'String Iterator');
-utils.InstallFunctions(StringIterator.prototype, DONT_ENUM, [
+$installFunctions(StringIterator.prototype, DONT_ENUM, [
'next', StringIteratorNext
]);
%AddNamedProperty(StringIterator.prototype, symbolToStringTag,
"String Iterator", READ_ONLY | DONT_ENUM);
-utils.SetFunctionName(StringPrototypeIterator, symbolIterator);
+$setFunctionName(StringPrototypeIterator, symbolIterator);
%AddNamedProperty(GlobalString.prototype, symbolIterator,
StringPrototypeIterator, DONT_ENUM);
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;
});
//-------------------------------------------------------------------
// 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);
}
}
-// 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
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;
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);
}
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;
}
}
var res = %RegExpExecMultiple(regexp,
subject,
- RegExpLastMatchInfo,
+ $regexpLastMatchInfo,
resultArray);
regexp.lastIndex = 0;
if (IS_NULL(res)) {
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.
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;
} 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];
}
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];
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;
GlobalString.prototype, "constructor", GlobalString, DONT_ENUM);
// Set up the non-enumerable functions on the String object.
-utils.InstallFunctions(GlobalString, DONT_ENUM, [
+$installFunctions(GlobalString, DONT_ENUM, [
"fromCharCode", StringFromCharCode,
"fromCodePoint", StringFromCodePoint,
"raw", StringRaw
]);
// Set up the non-enumerable functions on the String prototype object.
-utils.InstallFunctions(GlobalString.prototype, DONT_ENUM, [
+$installFunctions(GlobalString.prototype, DONT_ENUM, [
"valueOf", StringValueOf,
"toString", StringToString,
"charAt", StringCharAtJS,
%CheckIsBootstrapping();
-// -------------------------------------------------------------------
-// Imports
-
var GlobalObject = global.Object;
var GlobalSymbol = global.Symbol;
-var ObjectGetOwnPropertyKeys;
-
-utils.Import(function(from) {
- ObjectGetOwnPropertyKeys = from.ObjectGetOwnPropertyKeys;
-});
-
// -------------------------------------------------------------------
function SymbolConstructor(x) {
// TODO(arv): Proxies use a shared trap for String and Symbol keys.
- return ObjectGetOwnPropertyKeys(obj, PROPERTY_ATTRIBUTES_STRING);
+ return $objectGetOwnPropertyKeys(obj, PROPERTY_ATTRIBUTES_STRING);
}
//-------------------------------------------------------------------
%SetCode(GlobalSymbol, SymbolConstructor);
%FunctionSetPrototype(GlobalSymbol, new GlobalObject());
-utils.InstallConstants(GlobalSymbol, [
+$installConstants(GlobalSymbol, [
// TODO(rossberg): expose when implemented.
// "hasInstance", symbolHasInstance,
// "isConcatSpreadable", symbolIsConcatSpreadable,
"unscopables", symbolUnscopables
]);
-utils.InstallFunctions(GlobalSymbol, DONT_ENUM, [
+$installFunctions(GlobalSymbol, DONT_ENUM, [
"for", SymbolFor,
"keyFor", SymbolKeyFor
]);
%AddNamedProperty(
GlobalSymbol.prototype, symbolToStringTag, "Symbol", DONT_ENUM | READ_ONLY);
-utils.InstallFunctions(GlobalSymbol.prototype, DONT_ENUM, [
+$installFunctions(GlobalSymbol.prototype, DONT_ENUM, [
"toString", SymbolToString,
"valueOf", SymbolValueOf
]);
-utils.InstallFunctions(GlobalObject, DONT_ENUM, [
+$installFunctions(GlobalObject, DONT_ENUM, [
"getOwnPropertySymbols", ObjectGetOwnPropertySymbols
]);
//-------------------------------------------------------------------
-utils.InstallFunctions(GlobalMath, DONT_ENUM, [
+$installFunctions(GlobalMath, DONT_ENUM, [
"cos", MathCos,
"sin", MathSin,
"tan", MathTan,
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)
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)
%AddNamedProperty(GlobalNAME.prototype,
"BYTES_PER_ELEMENT", ELEMENT_SIZE,
READ_ONLY | DONT_ENUM | DONT_DELETE);
- 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, [
+ $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, [
"subarray", NAMESubArray,
"set", TypedArraySet
]);
%AddNamedProperty(GlobalDataView.prototype, symbolToStringTag, "DataView",
READ_ONLY|DONT_ENUM);
-utils.InstallGetter(GlobalDataView.prototype, "buffer", DataViewGetBufferJS);
-utils.InstallGetter(GlobalDataView.prototype, "byteOffset",
- DataViewGetByteOffset);
-utils.InstallGetter(GlobalDataView.prototype, "byteLength",
- DataViewGetByteLength);
+$installGetter(GlobalDataView.prototype, "buffer", DataViewGetBufferJS);
+$installGetter(GlobalDataView.prototype, "byteOffset", DataViewGetByteOffset);
+$installGetter(GlobalDataView.prototype, "byteLength", DataViewGetByteLength);
-utils.InstallFunctions(GlobalDataView.prototype, DONT_ENUM, [
+$installFunctions(GlobalDataView.prototype, DONT_ENUM, [
"getInt8", DataViewGetInt8JS,
"setInt8", DataViewSetInt8JS,
// Set up non-enumerable URI functions on the global object and set
// their names.
-utils.InstallFunctions(global, DONT_ENUM, [
+$installFunctions(global, DONT_ENUM, [
"escape", URIEscapeJS,
"unescape", URIUnescapeJS,
"decodeURI", URIDecode,
// 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) {
var InternalArray = utils.InternalArray;
var MathAbs;
-var ProxyDelegateCallAndConstruct;
-var ProxyDerivedHasOwnTrap;
-var ProxyDerivedKeysTrap;
var StringIndexOf;
utils.Import(function(from) {
StringIndexOf = from.StringIndexOf;
});
-utils.ImportFromExperimental(function(from) {
- ProxyDelegateCallAndConstruct = from.ProxyDelegateCallAndConstruct;
- ProxyDerivedHasOwnTrap = from.ProxyDerivedHasOwnTrap;
- ProxyDerivedKeysTrap = from.ProxyDerivedKeysTrap;
-});
+// ----------------------------------------------------------------------------
+
+// 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);
+}
+
// ----------------------------------------------------------------------------
// Set up global object.
var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY;
-utils.InstallConstants(global, [
+InstallConstants(global, [
// ECMA 262 - 15.1.1.1.
"NaN", NAN,
// ECMA-262 - 15.1.1.2.
]);
// Set up non-enumerable function on the global object.
-utils.InstallFunctions(global, DONT_ENUM, [
+InstallFunctions(global, DONT_ENUM, [
"isNaN", GlobalIsNaN,
"isFinite", GlobalIsFinite,
"parseInt", GlobalParseInt,
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));
}
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);
this.hasSetter_ = false;
}
-utils.SetUpLockedPrototype(PropertyDescriptor, [
+SetUpLockedPrototype(PropertyDescriptor, [
"value_",
"hasValue_",
"writable_",
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.
DONT_ENUM);
// Set up non-enumerable functions on the Object.prototype object.
-utils.InstallFunctions(GlobalObject.prototype, DONT_ENUM, [
+InstallFunctions(GlobalObject.prototype, DONT_ENUM, [
"toString", ObjectToString,
"toLocaleString", ObjectToLocaleString,
"valueOf", ObjectValueOf,
"__defineSetter__", ObjectDefineSetter,
"__lookupSetter__", ObjectLookupSetter
]);
-utils.InstallGetterSetter(GlobalObject.prototype, "__proto__", ObjectGetProto,
+InstallGetterSetter(GlobalObject.prototype, "__proto__", ObjectGetProto,
ObjectSetProto);
// Set up non-enumerable functions in the Object object.
-utils.InstallFunctions(GlobalObject, DONT_ENUM, [
+InstallFunctions(GlobalObject, DONT_ENUM, [
"keys", ObjectKeys,
"create", ObjectCreate,
"defineProperty", ObjectDefineProperty,
%AddNamedProperty(GlobalBoolean.prototype, "constructor", GlobalBoolean,
DONT_ENUM);
-utils.InstallFunctions(GlobalBoolean.prototype, DONT_ENUM, [
+InstallFunctions(GlobalBoolean.prototype, DONT_ENUM, [
"toString", BooleanToString,
"valueOf", BooleanValueOf
]);
%AddNamedProperty(GlobalNumber.prototype, "constructor", GlobalNumber,
DONT_ENUM);
-utils.InstallConstants(GlobalNumber, [
+InstallConstants(GlobalNumber, [
// ECMA-262 section 15.7.3.1.
"MAX_VALUE", 1.7976931348623157e+308,
// ECMA-262 section 15.7.3.2.
]);
// Set up non-enumerable functions on the Number prototype object.
-utils.InstallFunctions(GlobalNumber.prototype, DONT_ENUM, [
+InstallFunctions(GlobalNumber.prototype, DONT_ENUM, [
"toString", NumberToStringJS,
"toLocaleString", NumberToLocaleString,
"valueOf", NumberValueOf,
]);
// Harmony Number constructor additions
-utils.InstallFunctions(GlobalNumber, DONT_ENUM, [
+InstallFunctions(GlobalNumber, DONT_ENUM, [
"isFinite", NumberIsFinite,
"isInteger", NumberIsInteger,
"isNaN", NumberIsNaN,
%AddNamedProperty(GlobalFunction.prototype, "constructor", GlobalFunction,
DONT_ENUM);
-utils.InstallFunctions(GlobalFunction.prototype, DONT_ENUM, [
+InstallFunctions(GlobalFunction.prototype, DONT_ENUM, [
"bind", FunctionBind,
"toString", FunctionToString
]);
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;
-
-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;
-});
+$toNameArray = ToNameArray;
})
DONT_ENUM | READ_ONLY);
// Set up the non-enumerable functions on the WeakMap prototype object.
-utils.InstallFunctions(GlobalWeakMap.prototype, DONT_ENUM, [
+$installFunctions(GlobalWeakMap.prototype, DONT_ENUM, [
"get", WeakMapGet,
"set", WeakMapSet,
"has", WeakMapHas,
DONT_ENUM | READ_ONLY);
// Set up the non-enumerable functions on the WeakSet prototype object.
-utils.InstallFunctions(GlobalWeakSet.prototype, DONT_ENUM, [
+$installFunctions(GlobalWeakSet.prototype, DONT_ENUM, [
"add", WeakSetAdd,
"has", WeakSetHas,
"delete", WeakSetDelete
// Test call of JS runtime functions.
-var a = %MakeError(0, "error");
-assertInstanceof(a, Error);
+var a = %$isNaN(0/0);
+assertEquals(true, a);