i::Handle<i::Object> args[] = { obj, key_name };
i::Handle<i::Object> result;
has_pending_exception =
- !CallV8HeapFunction(isolate, "ObjectGetOwnPropertyDescriptor",
+ !CallV8HeapFunction(isolate, "$objectGetOwnPropertyDescriptor",
isolate->factory()->undefined_value(),
arraysize(args), args).ToHandle(&result);
RETURN_ON_FAILED_EXECUTION(Value);
%FunctionSetPrototype(ArrayIterator, new GlobalObject());
%FunctionSetInstanceClassName(ArrayIterator, 'Array Iterator');
-InstallFunctions(ArrayIterator.prototype, DONT_ENUM, [
+$installFunctions(ArrayIterator.prototype, DONT_ENUM, [
'next', ArrayIteratorNext
]);
-SetFunctionName(ArrayIteratorIterator, symbolIterator);
+$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, [
+$installFunctions(GlobalArray.prototype, DONT_ENUM, [
// No 'values' since it breaks webcompat: http://crbug.com/409858
'entries', ArrayEntries,
'keys', ArrayKeys
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.
-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.
-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.
-SetUpLockedPrototype(InternalArray, GlobalArray(), [
+$setUpLockedPrototype(InternalArray, GlobalArray(), [
"concat", getFunction("concat", ArrayConcatJS),
"indexOf", getFunction("indexOf", ArrayIndexOf),
"join", getFunction("join", ArrayJoin),
"splice", getFunction("splice", ArraySplice)
]);
-SetUpLockedPrototype(InternalPackedArray, GlobalArray(), [
+$setUpLockedPrototype(InternalPackedArray, GlobalArray(), [
"join", getFunction("join", ArrayJoin),
"pop", getFunction("pop", ArrayPop),
"push", getFunction("push", ArrayPush),
%AddNamedProperty(GlobalArrayBuffer.prototype,
symbolToStringTag, "ArrayBuffer", DONT_ENUM | READ_ONLY);
-InstallGetter(GlobalArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLen);
+$installGetter(GlobalArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLen);
-InstallFunctions(GlobalArrayBuffer, DONT_ENUM, [
+$installFunctions(GlobalArrayBuffer, DONT_ENUM, [
"isView", ArrayBufferIsViewJS
]);
-InstallFunctions(GlobalArrayBuffer.prototype, DONT_ENUM, [
+$installFunctions(GlobalArrayBuffer.prototype, DONT_ENUM, [
"slice", ArrayBufferSlice
]);
INSTALL_NATIVE(JSFunction, "ToInt32", to_int32_fun);
INSTALL_NATIVE(JSFunction, "ToLength", to_length_fun);
- INSTALL_NATIVE(JSFunction, "GlobalEval", global_eval_fun);
+ INSTALL_NATIVE(JSFunction, "$globalEval", global_eval_fun);
INSTALL_NATIVE(JSFunction, "$getStackTraceLine", get_stack_trace_line_fun);
- INSTALL_NATIVE(JSFunction, "ToCompletePropertyDescriptor",
+ INSTALL_NATIVE(JSFunction, "$toCompletePropertyDescriptor",
to_complete_property_descriptor);
INSTALL_NATIVE(Symbol, "$promiseStatus", promise_status);
%SetCode(SetIterator, SetIteratorConstructor);
%FunctionSetPrototype(SetIterator, new GlobalObject());
%FunctionSetInstanceClassName(SetIterator, 'Set Iterator');
-InstallFunctions(SetIterator.prototype, DONT_ENUM, [
+$installFunctions(SetIterator.prototype, DONT_ENUM, [
'next', SetIteratorNextJS
]);
-SetFunctionName(SetIteratorSymbolIterator, symbolIterator);
+$setFunctionName(SetIteratorSymbolIterator, symbolIterator);
%AddNamedProperty(SetIterator.prototype, symbolIterator,
SetIteratorSymbolIterator, DONT_ENUM);
%AddNamedProperty(SetIterator.prototype, symbolToStringTag,
"Set Iterator", READ_ONLY | DONT_ENUM);
-InstallFunctions(GlobalSet.prototype, DONT_ENUM, [
+$installFunctions(GlobalSet.prototype, DONT_ENUM, [
'entries', SetEntries,
'keys', SetValues,
'values', SetValues
%SetCode(MapIterator, MapIteratorConstructor);
%FunctionSetPrototype(MapIterator, new GlobalObject());
%FunctionSetInstanceClassName(MapIterator, 'Map Iterator');
-InstallFunctions(MapIterator.prototype, DONT_ENUM, [
+$installFunctions(MapIterator.prototype, DONT_ENUM, [
'next', MapIteratorNextJS
]);
-SetFunctionName(MapIteratorSymbolIterator, symbolIterator);
+$setFunctionName(MapIteratorSymbolIterator, symbolIterator);
%AddNamedProperty(MapIterator.prototype, symbolIterator,
MapIteratorSymbolIterator, DONT_ENUM);
%AddNamedProperty(MapIterator.prototype, symbolToStringTag,
"Map Iterator", READ_ONLY | DONT_ENUM);
-InstallFunctions(GlobalMap.prototype, DONT_ENUM, [
+$installFunctions(GlobalMap.prototype, DONT_ENUM, [
'entries', MapEntries,
'keys', MapKeys,
'values', MapValues
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.
-InstallGetter(GlobalSet.prototype, "size", SetGetSize);
-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.
-InstallGetter(GlobalMap.prototype, "size", MapGetSize);
-InstallFunctions(GlobalMap.prototype, DONT_ENUM, [
+$installGetter(GlobalMap.prototype, "size", MapGetSize);
+$installFunctions(GlobalMap.prototype, DONT_ENUM, [
"get", MapGet,
"set", MapSet,
"has", MapHas,
%FunctionSetPrototype(GlobalDate, new GlobalDate(NAN));
// Set up non-enumerable properties of the Date object itself.
-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.
-InstallFunctions(GlobalDate.prototype, DONT_ENUM, [
+$installFunctions(GlobalDate.prototype, DONT_ENUM, [
"toString", DateToString,
"toDateString", DateToDateString,
"toTimeString", DateToTimeString,
function GeneratorFunctionConstructor(arg1) { // length == 1
- var source = NewFunctionString(arguments, 'function*');
+ var source = $newFunctionString(arguments, 'function*');
var global_proxy = %GlobalProxy(global);
// 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;
-InstallFunctions(GeneratorObjectPrototype,
+$installFunctions(GeneratorObjectPrototype,
DONT_ENUM,
["next", GeneratorObjectNext,
"throw", GeneratorObjectThrow]);
-SetFunctionName(GeneratorObjectIterator, symbolIterator);
+$setFunctionName(GeneratorObjectIterator, symbolIterator);
%AddNamedProperty(GeneratorObjectPrototype, symbolIterator,
GeneratorObjectIterator, DONT_ENUM | DONT_DELETE | READ_ONLY);
%AddNamedProperty(GeneratorObjectPrototype, "constructor",
%FunctionSetLength(ArrayIncludes, 1);
// Set up the non-enumerable functions on the Array prototype object.
-InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
+$installFunctions(GlobalArray.prototype, DONT_ENUM, [
"includes", ArrayIncludes
]);
if (end > length) end = length;
}
- if ((end - i) > 0 && ObjectIsFrozen(array)) {
+ if ((end - i) > 0 && $objectIsFrozen(array)) {
throw MakeTypeError(kArrayFunctionsOnFrozen);
}
}
}
- 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) {
// -------------------------------------------------------------------
-InstallConstants(GlobalSymbol, [
+$installConstants(GlobalSymbol, [
// TODO(dslomov, caitp): Move to symbol.js when shipping
"isConcatSpreadable", symbolIsConcatSpreadable
]);
%FunctionSetLength(ArrayFrom, 1);
// Set up non-enumerable functions on the Array object.
-InstallFunctions(GlobalArray, DONT_ENUM, [
+$installFunctions(GlobalArray, DONT_ENUM, [
"from", ArrayFrom,
"of", ArrayOf
]);
// Set up the non-enumerable functions on the Array prototype object.
-InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
+$installFunctions(GlobalArray.prototype, DONT_ENUM, [
"copyWithin", ArrayCopyWithin,
"find", ArrayFind,
"findIndex", ArrayFindIndex,
var GlobalReflect = global.Reflect;
-InstallFunctions(GlobalReflect, DONT_ENUM, [
+$installFunctions(GlobalReflect, DONT_ENUM, [
"apply", $reflectApply,
"construct", $reflectConstruct
]);
var GlobalSymbol = global.Symbol;
-InstallConstants(GlobalSymbol, [
+$installConstants(GlobalSymbol, [
// TODO(dslomov, caitp): Move to symbol.js when shipping
"toStringTag", symbolToStringTag
]);
%CheckIsBootstrapping();
-// -------------------------------------------------------------------
-
macro TYPED_ARRAYS(FUNCTION)
// arrayIds below should be synchronized with Runtime_TypedArrayInitialize.
FUNCTION(1, Uint8Array, 1)
FUNCTION(9, Uint8ClampedArray, 1)
endmacro
+macro DECLARE_GLOBALS(INDEX, NAME, SIZE)
+var GlobalNAME = global.NAME;
+endmacro
+
+TYPED_ARRAYS(DECLARE_GLOBALS)
+
+// -------------------------------------------------------------------
macro TYPED_ARRAY_HARMONY_ADDITIONS(ARRAY_ID, NAME, ELEMENT_SIZE)
macro EXTEND_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE)
// Set up non-enumerable functions on the object.
- InstallFunctions(global.NAME, DONT_ENUM | DONT_DELETE | READ_ONLY, [
+ $installFunctions(GlobalNAME, DONT_ENUM | DONT_DELETE | READ_ONLY, [
"of", NAMEOf
]);
// Set up non-enumerable functions on the prototype object.
- InstallFunctions(global.NAME.prototype, DONT_ENUM, [
+ $installFunctions(GlobalNAME.prototype, DONT_ENUM, [
"forEach", NAMEForEach
]);
endmacro
}
}
}
- 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);
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,
+$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',
+ $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;
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);
'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);
* 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);
}
* 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);
}
}
} else {
for (var p in val) {
- if (%_CallFunction(val, p, ObjectHasOwnProperty)) {
+ 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 (%_CallFunction(replacer, i, ObjectHasOwnProperty)) {
+ 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 (%_CallFunction(value, p, ObjectHasOwnProperty)) {
+ 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.
-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(obj, index) = (%_CallFunction(obj, 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.
-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.
-InstallFunctions(Math, DONT_ENUM, [
+$installFunctions(Math, DONT_ENUM, [
"random", MathRandom,
"abs", MathAbs,
"acos", MathAcosJS,
}
+function NoSideEffectsObjectToString() {
+ if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) return "[object Undefined]";
+ if (IS_NULL(this)) return "[object Null]";
+ return "[object " + %_ClassOf(TO_OBJECT_INLINE(this)) + "]";
+}
+
+
function NoSideEffectToString(obj) {
if (IS_STRING(obj)) return obj;
if (IS_NUMBER(obj)) return %_NumberToString(obj);
if (IS_UNDEFINED(obj)) return 'undefined';
if (IS_NULL(obj)) return 'null';
if (IS_FUNCTION(obj)) {
- var str = %_CallFunction(obj, FunctionToString);
+ var str = %_CallFunction(obj, obj, $functionSourceString);
if (str.length > 128) {
str = %_SubString(str, 0, 111) + "...<omitted>..." +
%_SubString(str, str.length - 2, str.length);
}
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;
}
-SetUpLockedPrototype(Script, [
+$setUpLockedPrototype(Script, [
"source",
"name",
"source_url",
}
-SetUpLockedPrototype(SourceLocation,
+$setUpLockedPrototype(SourceLocation,
["script", "position", "line", "column", "start", "end"],
["sourceText", SourceLocationSourceText]
);
$stringSubstring);
}
-SetUpLockedPrototype(SourceSlice,
+$setUpLockedPrototype(SourceSlice,
["script", "from_line", "to_line", "from_position", "to_position"],
["sourceText", SourceSliceSourceText]
);
var fun = GET_PRIVATE(this, CallSiteFunctionKey);
var ownName = fun.name;
if (ownName && receiver &&
- (%_CallFunction(receiver, ownName, ObjectLookupGetter) === fun ||
- %_CallFunction(receiver, ownName, ObjectLookupSetter) === fun ||
+ (%_CallFunction(receiver, ownName, $objectLookupGetter) === fun ||
+ %_CallFunction(receiver, ownName, $objectLookupSetter) === fun ||
(IS_OBJECT(receiver) && %GetDataProperty(receiver, ownName) === fun))) {
// To handle DontEnum properties we guess that the method has
// the same name as the function.
}
var name = null;
for (var prop in receiver) {
- if (%_CallFunction(receiver, prop, ObjectLookupGetter) === fun ||
- %_CallFunction(receiver, prop, ObjectLookupSetter) === fun ||
+ if (%_CallFunction(receiver, prop, $objectLookupGetter) === fun ||
+ %_CallFunction(receiver, prop, $objectLookupSetter) === fun ||
(IS_OBJECT(receiver) && %GetDataProperty(receiver, prop) === fun)) {
// If we find more than one match bail out to avoid confusion.
if (name) {
return line;
}
-SetUpLockedPrototype(CallSite, ["receiver", "fun", "pos"], [
+$setUpLockedPrototype(CallSite, ["receiver", "fun", "pos"], [
"getThis", CallSiteGetThis,
"getTypeName", CallSiteGetTypeName,
"isToplevel", CallSiteIsToplevel,
// 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 });
+ $objectDefineProperty(obj, 'stack', { get: StackTraceGetter,
+ set: StackTraceSetter,
+ configurable: true });
%CollectStackTrace(obj, cons_opt ? cons_opt : captureStackTrace);
}
}
}
-InstallFunctions(GlobalError.prototype, DONT_ENUM, ['toString', ErrorToString]);
+$installFunctions(GlobalError.prototype, DONT_ENUM,
+ ['toString', ErrorToString]);
$errorToString = ErrorToString;
$formatMessage = FormatMessage;
// Return source if function is resolved. Otherwise just fall through to
// return undefined.
if (this.resolved()) {
- return builtins.FunctionSourceString(this.value_);
+ return builtins.$functionSourceString(this.value_);
}
};
throw MakeTypeError("observe_global_proxy", ["observe"]);
if (!IS_SPEC_FUNCTION(callback))
throw MakeTypeError("observe_non_function", ["observe"]);
- if (ObjectIsFrozen(callback))
+ if ($objectIsFrozen(callback))
throw MakeTypeError("observe_callback_frozen");
var objectObserveFn = %GetObjectContextObjectObserve(object);
%DefineDataPropertyUnchecked(
newRecord, prop, changeRecord[prop], READ_ONLY + DONT_DELETE);
}
- ObjectFreezeJS(newRecord);
+ $objectFreeze(newRecord);
ObjectInfoEnqueueInternalChangeRecord(objectInfo, newRecord);
}
addedCount: addedCount
};
- ObjectFreezeJS(changeRecord);
- ObjectFreezeJS(changeRecord.removed);
+ $objectFreeze(changeRecord);
+ $objectFreeze(changeRecord.removed);
ObjectInfoEnqueueInternalChangeRecord(objectInfo, changeRecord);
}
};
}
- ObjectFreezeJS(changeRecord);
+ $objectFreeze(changeRecord);
ObjectInfoEnqueueInternalChangeRecord(objectInfo, changeRecord);
}
if (%IsJSGlobalProxy(object))
throw MakeTypeError("observe_global_proxy", ["getNotifier"]);
- if (ObjectIsFrozen(object)) return null;
+ if ($objectIsFrozen(object)) return null;
if (!%ObjectWasCreatedInCurrentOrigin(object)) return null;
// -------------------------------------------------------------------
-InstallFunctions(GlobalObject, DONT_ENUM, [
+$installFunctions(GlobalObject, DONT_ENUM, [
"deliverChangeRecords", ObjectDeliverChangeRecords,
"getNotifier", ObjectGetNotifier,
"observe", ObjectObserve,
"unobserve", ObjectUnobserve
]);
-InstallFunctions(GlobalArray, DONT_ENUM, [
+$installFunctions(GlobalArray, DONT_ENUM, [
"observe", ArrayObserve,
"unobserve", ArrayUnobserve
]);
-InstallFunctions(notifierPrototype, DONT_ENUM, [
+$installFunctions(notifierPrototype, DONT_ENUM, [
"notify", ObjectNotifierNotify,
"performChange", ObjectNotifierPerformChange
]);
%AddNamedProperty(GlobalPromise.prototype, symbolToStringTag, "Promise",
DONT_ENUM | READ_ONLY);
-InstallFunctions(GlobalPromise, DONT_ENUM, [
+$installFunctions(GlobalPromise, DONT_ENUM, [
"defer", PromiseDeferred,
"accept", PromiseResolved,
"reject", PromiseRejected,
"resolve", PromiseCast
]);
-InstallFunctions(GlobalPromise.prototype, DONT_ENUM, [
+$installFunctions(GlobalPromise.prototype, DONT_ENUM, [
"chain", PromiseChain,
"then", PromiseThen,
"catch", PromiseCatch
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.
-InstallFunctions(Proxy, DONT_ENUM, [
+$installFunctions(Proxy, DONT_ENUM, [
"create", ProxyCreate,
"createFunction", ProxyCreateFunction
])
GlobalRegExp.prototype, 'constructor', GlobalRegExp, DONT_ENUM);
%SetCode(GlobalRegExp, RegExpConstructor);
-InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, [
+$installFunctions(GlobalRegExp.prototype, DONT_ENUM, [
"exec", RegExpExecJS,
"test", RegExpTest,
"toString", RegExpToString,
%FunctionSetPrototype(StringIterator, new GlobalObject());
%FunctionSetInstanceClassName(StringIterator, 'String Iterator');
-InstallFunctions(StringIterator.prototype, DONT_ENUM, [
+$installFunctions(StringIterator.prototype, DONT_ENUM, [
'next', StringIteratorNext
]);
-SetFunctionName(StringIteratorIterator, symbolIterator);
+$setFunctionName(StringIteratorIterator, symbolIterator);
%AddNamedProperty(StringIterator.prototype, symbolIterator,
StringIteratorIterator, DONT_ENUM);
%AddNamedProperty(StringIterator.prototype, symbolToStringTag,
"String Iterator", READ_ONLY | DONT_ENUM);
-SetFunctionName(StringPrototypeIterator, symbolIterator);
+$setFunctionName(StringPrototypeIterator, symbolIterator);
%AddNamedProperty(GlobalString.prototype, symbolIterator,
StringPrototypeIterator, DONT_ENUM);
GlobalString.prototype, "constructor", GlobalString, DONT_ENUM);
// Set up the non-enumerable functions on the String object.
-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.
-InstallFunctions(GlobalString.prototype, DONT_ENUM, [
+$installFunctions(GlobalString.prototype, DONT_ENUM, [
"valueOf", StringValueOf,
"toString", StringToString,
"charAt", StringCharAtJS,
// 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());
-InstallConstants(GlobalSymbol, [
+$installConstants(GlobalSymbol, [
// TODO(rossberg): expose when implemented.
// "hasInstance", symbolHasInstance,
// "isConcatSpreadable", symbolIsConcatSpreadable,
"unscopables", symbolUnscopables
]);
-InstallFunctions(GlobalSymbol, DONT_ENUM, [
+$installFunctions(GlobalSymbol, DONT_ENUM, [
"for", SymbolFor,
"keyFor", SymbolKeyFor
]);
%AddNamedProperty(
GlobalSymbol.prototype, symbolToStringTag, "Symbol", DONT_ENUM | READ_ONLY);
-InstallFunctions(GlobalSymbol.prototype, DONT_ENUM, [
+$installFunctions(GlobalSymbol.prototype, DONT_ENUM, [
"toString", SymbolToString,
"valueOf", SymbolValueOf
]);
-InstallFunctions(GlobalObject, DONT_ENUM, [
+$installFunctions(GlobalObject, DONT_ENUM, [
"getOwnPropertySymbols", ObjectGetOwnPropertySymbols
]);
//-------------------------------------------------------------------
-InstallFunctions(GlobalMath, DONT_ENUM, [
+$installFunctions(GlobalMath, DONT_ENUM, [
"cos", MathCos,
"sin", MathSin,
"tan", MathTan,
var GlobalArray = global.Array;
var GlobalArrayBuffer = global.ArrayBuffer;
+var GlobalDataView = global.DataView;
+var GlobalObject = global.Object;
-// --------------- Typed Arrays ---------------------
macro TYPED_ARRAYS(FUNCTION)
// arrayIds below should be synchronized with Runtime_TypedArrayInitialize.
FUNCTION(1, Uint8Array, 1)
FUNCTION(9, Uint8ClampedArray, 1)
endmacro
+macro DECLARE_GLOBALS(INDEX, NAME, SIZE)
+var GlobalNAME = global.NAME;
+endmacro
+
+TYPED_ARRAYS(DECLARE_GLOBALS)
+
+// --------------- Typed Arrays ---------------------
+
macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE)
function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) {
if (!IS_UNDEFINED(byteOffset)) {
return %_TypedArrayGetLength(this);
}
-var $NAME = global.NAME;
-
function NAMESubArray(begin, end) {
if (!(%_ClassOf(this) === 'NAME')) {
throw MakeTypeError(kIncompatibleMethodReceiver, "NAME.subarray", this);
var newLength = endInt - beginInt;
var beginByteOffset =
%_ArrayBufferViewGetByteOffset(this) + beginInt * ELEMENT_SIZE;
- return new $NAME(%TypedArrayGetBuffer(this),
- beginByteOffset, newLength);
+ return new GlobalNAME(%TypedArrayGetBuffer(this),
+ beginByteOffset, newLength);
}
endmacro
// -------------------------------------------------------------------
macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE)
- %SetCode(global.NAME, NAMEConstructor);
- %FunctionSetPrototype(global.NAME, new $Object());
+ %SetCode(GlobalNAME, NAMEConstructor);
+ %FunctionSetPrototype(GlobalNAME, new GlobalObject());
- %AddNamedProperty(global.NAME, "BYTES_PER_ELEMENT", ELEMENT_SIZE,
+ %AddNamedProperty(GlobalNAME, "BYTES_PER_ELEMENT", ELEMENT_SIZE,
READ_ONLY | DONT_ENUM | DONT_DELETE);
- %AddNamedProperty(global.NAME.prototype,
+ %AddNamedProperty(GlobalNAME.prototype,
"constructor", global.NAME, DONT_ENUM);
- %AddNamedProperty(global.NAME.prototype,
+ %AddNamedProperty(GlobalNAME.prototype,
"BYTES_PER_ELEMENT", ELEMENT_SIZE,
READ_ONLY | DONT_ENUM | DONT_DELETE);
- InstallGetter(global.NAME.prototype, "buffer", NAME_GetBuffer);
- InstallGetter(global.NAME.prototype, "byteOffset", NAME_GetByteOffset,
- DONT_ENUM | DONT_DELETE);
- InstallGetter(global.NAME.prototype, "byteLength", NAME_GetByteLength,
- DONT_ENUM | DONT_DELETE);
- InstallGetter(global.NAME.prototype, "length", NAME_GetLength,
- DONT_ENUM | DONT_DELETE);
- InstallGetter(global.NAME.prototype, symbolToStringTag,
- TypedArrayGetToStringTag);
- InstallFunctions(global.NAME.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
]);
// --------------------------- DataView -----------------------------
-var $DataView = global.DataView;
-
function DataViewConstructor(buffer, byteOffset, byteLength) { // length = 3
if (%_IsConstructCall()) {
if (!IS_ARRAYBUFFER(buffer)) {
DATA_VIEW_TYPES(DATA_VIEW_GETTER_SETTER)
// Setup the DataView constructor.
-%SetCode($DataView, DataViewConstructor);
-%FunctionSetPrototype($DataView, new $Object);
+%SetCode(GlobalDataView, DataViewConstructor);
+%FunctionSetPrototype(GlobalDataView, new GlobalObject);
// Set up constructor property on the DataView prototype.
-%AddNamedProperty($DataView.prototype, "constructor", $DataView, DONT_ENUM);
-%AddNamedProperty(
- $DataView.prototype, symbolToStringTag, "DataView", READ_ONLY|DONT_ENUM);
+%AddNamedProperty(GlobalDataView.prototype, "constructor", GlobalDataView,
+ DONT_ENUM);
+%AddNamedProperty(GlobalDataView.prototype, symbolToStringTag, "DataView",
+ READ_ONLY|DONT_ENUM);
-InstallGetter($DataView.prototype, "buffer", DataViewGetBufferJS);
-InstallGetter($DataView.prototype, "byteOffset", DataViewGetByteOffset);
-InstallGetter($DataView.prototype, "byteLength", DataViewGetByteLength);
+$installGetter(GlobalDataView.prototype, "buffer", DataViewGetBufferJS);
+$installGetter(GlobalDataView.prototype, "byteOffset", DataViewGetByteOffset);
+$installGetter(GlobalDataView.prototype, "byteLength", DataViewGetByteLength);
-InstallFunctions($DataView.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.
-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.
-// This file relies on the fact that the following declarations have been made
-// in runtime.js:
-// var $Object = global.Object;
-// var $Boolean = global.Boolean;
-// var $Number = global.Number;
-// var $Function = global.Function;
-// var $Array = global.Array;
-
-var $isNaN = GlobalIsNaN;
-var $isFinite = GlobalIsFinite;
+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 $setFunctionName;
+var $setUpLockedPrototype;
+var $toCompletePropertyDescriptor;
+var $toNameArray;
+
+(function() {
+
+%CheckIsBootstrapping();
+
+var GlobalArray = global.Array;
+var GlobalBoolean = global.Boolean;
+var GlobalFunction = global.Function;
+var GlobalNumber = global.Number;
+var GlobalObject = global.Object;
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Set up global object.
-function SetUpGlobal() {
- %CheckIsBootstrapping();
-
- var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY;
+var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY;
+InstallConstants(global, [
// ECMA 262 - 15.1.1.1.
- %AddNamedProperty(global, "NaN", NAN, attributes);
-
+ "NaN", NAN,
// ECMA-262 - 15.1.1.2.
- %AddNamedProperty(global, "Infinity", INFINITY, attributes);
-
- // ECMA-262 - 15.1.1.3.
- %AddNamedProperty(global, "undefined", UNDEFINED, attributes);
-
- // Set up non-enumerable function on the global object.
- InstallFunctions(global, DONT_ENUM, [
- "isNaN", GlobalIsNaN,
- "isFinite", GlobalIsFinite,
- "parseInt", GlobalParseInt,
- "parseFloat", GlobalParseFloat,
- "eval", GlobalEval
- ]);
-}
+ "Infinity", INFINITY,
+ // ECMA-262 - 15.1.1.2.
+ "undefined", UNDEFINED,
+]);
-SetUpGlobal();
+// Set up non-enumerable function on the global object.
+InstallFunctions(global, DONT_ENUM, [
+ "isNaN", GlobalIsNaN,
+ "isFinite", GlobalIsFinite,
+ "parseInt", GlobalParseInt,
+ "parseFloat", GlobalParseFloat,
+ "eval", GlobalEval
+]);
// ----------------------------------------------------------------------------
// Object
// ECMA-262 - 15.2.4.2
-function NoSideEffectsObjectToString() {
- if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) return "[object Undefined]";
- if (IS_NULL(this)) return "[object Null]";
- return "[object " + %_ClassOf(TO_OBJECT_INLINE(this)) + "]";
-}
-
-
function ObjectToString() {
if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) return "[object Undefined]";
if (IS_NULL(this)) return "[object Null]";
// TODO(caitp): cannot wait to get rid of this flag :>
if (harmony_tostring) {
- var tag = O[symbolToStringTag];
+ tag = O[symbolToStringTag];
if (!IS_STRING(tag)) {
tag = builtinTag;
}
// Harmony Proxies
function FromGenericPropertyDescriptor(desc) {
if (IS_UNDEFINED(desc)) return desc;
- var obj = new $Object();
+ var obj = new GlobalObject();
if (desc.hasValue()) {
%AddNamedProperty(obj, "value", desc.getValue(), NONE);
throw MakeTypeError(kProxyNonObjectPropNames, trap, obj);
}
var n = ToUint32(obj.length);
- var array = new $Array(n);
+ var array = new GlobalArray(n);
var realLength = 0;
var names = { __proto__: null }; // TODO(rossberg): use sets once ready.
for (var index = 0; index < n; index++) {
%SetCode(obj, code);
// TODO(rossberg): What about length and other properties? Not specified.
// We just put in some half-reasonable defaults for now.
- var prototype = new $Object();
- $Object.defineProperty(prototype, "constructor",
+ var prototype = new GlobalObject();
+ ObjectDefineProperty(prototype, "constructor",
{value: obj, writable: true, enumerable: false, configurable: true});
// TODO(v8:1530): defineProperty does not handle prototype and length.
%FunctionSetPrototype(obj, prototype);
// ----------------------------------------------------------------------------
// Object
-function SetUpObject() {
- %CheckIsBootstrapping();
-
- %SetNativeFlag($Object);
- %SetCode($Object, ObjectConstructor);
-
- %AddNamedProperty($Object.prototype, "constructor", $Object, DONT_ENUM);
-
- // Set up non-enumerable functions on the Object.prototype object.
- InstallFunctions($Object.prototype, DONT_ENUM, [
- "toString", ObjectToString,
- "toLocaleString", ObjectToLocaleString,
- "valueOf", ObjectValueOf,
- "hasOwnProperty", ObjectHasOwnProperty,
- "isPrototypeOf", ObjectIsPrototypeOf,
- "propertyIsEnumerable", ObjectPropertyIsEnumerable,
- "__defineGetter__", ObjectDefineGetter,
- "__lookupGetter__", ObjectLookupGetter,
- "__defineSetter__", ObjectDefineSetter,
- "__lookupSetter__", ObjectLookupSetter
- ]);
- InstallGetterSetter($Object.prototype, "__proto__",
- ObjectGetProto, ObjectSetProto);
-
- // Set up non-enumerable functions in the Object object.
- InstallFunctions($Object, DONT_ENUM, [
- "keys", ObjectKeys,
- "create", ObjectCreate,
- "defineProperty", ObjectDefineProperty,
- "defineProperties", ObjectDefineProperties,
- "freeze", ObjectFreezeJS,
- "getPrototypeOf", ObjectGetPrototypeOf,
- "setPrototypeOf", ObjectSetPrototypeOf,
- "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor,
- "getOwnPropertyNames", ObjectGetOwnPropertyNames,
- // getOwnPropertySymbols is added in symbol.js.
- "is", ObjectIs,
- "isExtensible", ObjectIsExtensible,
- "isFrozen", ObjectIsFrozen,
- "isSealed", ObjectIsSealed,
- "preventExtensions", ObjectPreventExtension,
- "seal", ObjectSealJS
- // deliverChangeRecords, getNotifier, observe and unobserve are added
- // in object-observe.js.
- ]);
-}
-
-SetUpObject();
+%SetNativeFlag(GlobalObject);
+%SetCode(GlobalObject, ObjectConstructor);
+
+%AddNamedProperty(GlobalObject.prototype, "constructor", GlobalObject,
+ DONT_ENUM);
+
+// Set up non-enumerable functions on the Object.prototype object.
+InstallFunctions(GlobalObject.prototype, DONT_ENUM, [
+ "toString", ObjectToString,
+ "toLocaleString", ObjectToLocaleString,
+ "valueOf", ObjectValueOf,
+ "hasOwnProperty", ObjectHasOwnProperty,
+ "isPrototypeOf", ObjectIsPrototypeOf,
+ "propertyIsEnumerable", ObjectPropertyIsEnumerable,
+ "__defineGetter__", ObjectDefineGetter,
+ "__lookupGetter__", ObjectLookupGetter,
+ "__defineSetter__", ObjectDefineSetter,
+ "__lookupSetter__", ObjectLookupSetter
+]);
+InstallGetterSetter(GlobalObject.prototype, "__proto__", ObjectGetProto,
+ ObjectSetProto);
+
+// Set up non-enumerable functions in the Object object.
+InstallFunctions(GlobalObject, DONT_ENUM, [
+ "keys", ObjectKeys,
+ "create", ObjectCreate,
+ "defineProperty", ObjectDefineProperty,
+ "defineProperties", ObjectDefineProperties,
+ "freeze", ObjectFreezeJS,
+ "getPrototypeOf", ObjectGetPrototypeOf,
+ "setPrototypeOf", ObjectSetPrototypeOf,
+ "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor,
+ "getOwnPropertyNames", ObjectGetOwnPropertyNames,
+ // getOwnPropertySymbols is added in symbol.js.
+ "is", ObjectIs,
+ "isExtensible", ObjectIsExtensible,
+ "isFrozen", ObjectIsFrozen,
+ "isSealed", ObjectIsSealed,
+ "preventExtensions", ObjectPreventExtension,
+ "seal", ObjectSealJS
+ // deliverChangeRecords, getNotifier, observe and unobserve are added
+ // in object-observe.js.
+]);
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
-function SetUpBoolean () {
- %CheckIsBootstrapping();
-
- %SetCode($Boolean, BooleanConstructor);
- %FunctionSetPrototype($Boolean, new $Boolean(false));
- %AddNamedProperty($Boolean.prototype, "constructor", $Boolean, DONT_ENUM);
+%SetCode(GlobalBoolean, BooleanConstructor);
+%FunctionSetPrototype(GlobalBoolean, new GlobalBoolean(false));
+%AddNamedProperty(GlobalBoolean.prototype, "constructor", GlobalBoolean,
+ DONT_ENUM);
- InstallFunctions($Boolean.prototype, DONT_ENUM, [
- "toString", BooleanToString,
- "valueOf", BooleanValueOf
- ]);
-}
-
-SetUpBoolean();
+InstallFunctions(GlobalBoolean.prototype, DONT_ENUM, [
+ "toString", BooleanToString,
+ "valueOf", BooleanValueOf
+]);
// ----------------------------------------------------------------------------
function NumberIsSafeInteger(number) {
if (NumberIsFinite(number)) {
var integral = TO_INTEGER(number);
- if (integral == number) return $abs(integral) <= $Number.MAX_SAFE_INTEGER;
+ if (integral == number) {
+ return $abs(integral) <= GlobalNumber.MAX_SAFE_INTEGER;
+ }
}
return false;
}
// ----------------------------------------------------------------------------
-function SetUpNumber() {
- %CheckIsBootstrapping();
+%SetCode(GlobalNumber, NumberConstructor);
+%FunctionSetPrototype(GlobalNumber, new GlobalNumber(0));
+
+%OptimizeObjectForAddingMultipleProperties(GlobalNumber.prototype, 8);
+// Set up the constructor property on the Number prototype object.
+%AddNamedProperty(GlobalNumber.prototype, "constructor", GlobalNumber,
+ DONT_ENUM);
+
+InstallConstants(GlobalNumber, [
+ // ECMA-262 section 15.7.3.1.
+ "MAX_VALUE", 1.7976931348623157e+308,
+ // ECMA-262 section 15.7.3.2.
+ "MIN_VALUE", 5e-324,
+ // ECMA-262 section 15.7.3.3.
+ "NaN", NAN,
+ // ECMA-262 section 15.7.3.4.
+ "NEGATIVE_INFINITY", -INFINITY,
+ // ECMA-262 section 15.7.3.5.
+ "POSITIVE_INFINITY", INFINITY,
+
+ // --- Harmony constants (no spec refs until settled.)
+
+ "MAX_SAFE_INTEGER", %_MathPow(2, 53) - 1,
+ "MIN_SAFE_INTEGER", -%_MathPow(2, 53) + 1,
+ "EPSILON", %_MathPow(2, -52)
+]);
- %SetCode($Number, NumberConstructor);
- %FunctionSetPrototype($Number, new $Number(0));
-
- %OptimizeObjectForAddingMultipleProperties($Number.prototype, 8);
- // Set up the constructor property on the Number prototype object.
- %AddNamedProperty($Number.prototype, "constructor", $Number, DONT_ENUM);
-
- InstallConstants($Number, [
- // ECMA-262 section 15.7.3.1.
- "MAX_VALUE", 1.7976931348623157e+308,
- // ECMA-262 section 15.7.3.2.
- "MIN_VALUE", 5e-324,
- // ECMA-262 section 15.7.3.3.
- "NaN", NAN,
- // ECMA-262 section 15.7.3.4.
- "NEGATIVE_INFINITY", -INFINITY,
- // ECMA-262 section 15.7.3.5.
- "POSITIVE_INFINITY", INFINITY,
-
- // --- Harmony constants (no spec refs until settled.)
-
- "MAX_SAFE_INTEGER", %_MathPow(2, 53) - 1,
- "MIN_SAFE_INTEGER", -%_MathPow(2, 53) + 1,
- "EPSILON", %_MathPow(2, -52)
- ]);
-
- // Set up non-enumerable functions on the Number prototype object.
- InstallFunctions($Number.prototype, DONT_ENUM, [
- "toString", NumberToStringJS,
- "toLocaleString", NumberToLocaleString,
- "valueOf", NumberValueOf,
- "toFixed", NumberToFixedJS,
- "toExponential", NumberToExponentialJS,
- "toPrecision", NumberToPrecisionJS
- ]);
-
- // Harmony Number constructor additions
- InstallFunctions($Number, DONT_ENUM, [
- "isFinite", NumberIsFinite,
- "isInteger", NumberIsInteger,
- "isNaN", NumberIsNaN,
- "isSafeInteger", NumberIsSafeInteger,
- "parseInt", GlobalParseInt,
- "parseFloat", GlobalParseFloat
- ]);
-
- %SetInlineBuiltinFlag(NumberIsNaN);
-}
-
-SetUpNumber();
+// Set up non-enumerable functions on the Number prototype object.
+InstallFunctions(GlobalNumber.prototype, DONT_ENUM, [
+ "toString", NumberToStringJS,
+ "toLocaleString", NumberToLocaleString,
+ "valueOf", NumberValueOf,
+ "toFixed", NumberToFixedJS,
+ "toExponential", NumberToExponentialJS,
+ "toPrecision", NumberToPrecisionJS
+]);
+
+// Harmony Number constructor additions
+InstallFunctions(GlobalNumber, DONT_ENUM, [
+ "isFinite", NumberIsFinite,
+ "isInteger", NumberIsInteger,
+ "isNaN", NumberIsNaN,
+ "isSafeInteger", NumberIsSafeInteger,
+ "parseInt", GlobalParseInt,
+ "parseFloat", GlobalParseFloat
+]);
+
+%SetInlineBuiltinFlag(NumberIsNaN);
// ----------------------------------------------------------------------------
}
-function NewFunctionString(arguments, function_token) {
- var n = arguments.length;
+function NewFunctionString(args, function_token) {
+ var n = args.length;
var p = '';
if (n > 1) {
- p = ToString(arguments[0]);
+ p = ToString(args[0]);
for (var i = 1; i < n - 1; i++) {
- p += ',' + ToString(arguments[i]);
+ p += ',' + ToString(args[i]);
}
// If the formal parameters string include ) - an illegal
// character - it may make the combined function expression
// comments we can include a trailing block comment to catch this.
p += '\n/' + '**/';
}
- var body = (n > 0) ? ToString(arguments[n - 1]) : '';
+ var body = (n > 0) ? ToString(args[n - 1]) : '';
return '(' + function_token + '(' + p + ') {\n' + body + '\n})';
}
// ----------------------------------------------------------------------------
-function SetUpFunction() {
- %CheckIsBootstrapping();
-
- %SetCode($Function, FunctionConstructor);
- %AddNamedProperty($Function.prototype, "constructor", $Function, DONT_ENUM);
-
- InstallFunctions($Function.prototype, DONT_ENUM, [
- "bind", FunctionBind,
- "toString", FunctionToString
- ]);
-}
-
-SetUpFunction();
+%SetCode(GlobalFunction, FunctionConstructor);
+%AddNamedProperty(GlobalFunction.prototype, "constructor", GlobalFunction,
+ DONT_ENUM);
+InstallFunctions(GlobalFunction.prototype, DONT_ENUM, [
+ "bind", FunctionBind,
+ "toString", FunctionToString
+]);
// ----------------------------------------------------------------------------
// Iterator related spec functions.
}
return iterator;
}
+
+//----------------------------------------------------------------------------
+
+$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;
+$setFunctionName = SetFunctionName;
+$setUpLockedPrototype = SetUpLockedPrototype;
+$toCompletePropertyDescriptor = ToCompletePropertyDescriptor;
+$toNameArray = ToNameArray;
+
+})();
DONT_ENUM | READ_ONLY);
// Set up the non-enumerable functions on the WeakMap prototype object.
-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.
-InstallFunctions(GlobalWeakSet.prototype, DONT_ENUM, [
+$installFunctions(GlobalWeakSet.prototype, DONT_ENUM, [
"add", WeakSetAdd,
"has", WeakSetHas,
"delete", WeakSetDelete
// Test call of JS runtime functions.
-var a = %GlobalParseInt("21", 16);
-assertEquals(33, a);
+var a = %$isNaN(0/0);
+assertEquals(true, a);
The string that should replace the match in the rewritten program.
"""
matched_text = m.group(0)
+
+ if matched_text.startswith("`") and matched_text.endswith("`"):
+ return re.sub(r"\$\{([\w$%]+)\}",
+ lambda m: '${' + self.FindNewName(m.group(1)) + '}',
+ matched_text)
+
if matched_text == "{":
self.Push()
return matched_text
return self.map[var_name]
if self.nesting == 0:
return var_name
+ # Do not rename arguments object.
+ if var_name == 'arguments':
+ return 'arguments'
while True:
identifier_first_char = self.identifier_counter % 52
identifier_second_char = self.identifier_counter // 52
return entire_match
if re.match(r'".*"$', entire_match):
return entire_match
+ if re.match(r"`.*`$", entire_match):
+ return entire_match
if re.match(r"/.+/$", entire_match):
return entire_match
return replacement
# This regexp can handle embedded backslash-escaped characters including
# embedded backslash-escaped double quotes.
double_quoted_string = r'"(?:[^"\\]|\\.)*"'
- # A regexp that matches a literal string surrounded by 'double quotes'.
+ # A regexp that matches a literal string surrounded by 'single quotes'.
single_quoted_string = r"'(?:[^'\\]|\\.)*'"
+ # A regexp that matches a template string
+ template_string = r"`(?:[^'\\]|\\.)*`"
# A regexp that matches a regexp literal surrounded by /slashes/.
# Don't allow a regexp to have a ) before the first ( since that's a
# syntax error and it's probably just two unrelated slashes.
# Replace multiple spaces with a single space.
line = re.sub("|".join([double_quoted_string,
single_quoted_string,
+ template_string,
slash_quoted_regexp,
"( )+"]),
self.RemoveSpaces,
# and after the space. % and $ are counted as identifier characters.
line = re.sub("|".join([double_quoted_string,
single_quoted_string,
+ template_string,
slash_quoted_regexp,
r"(?<![a-zA-Z_0-9$%]) | (?![a-zA-Z_0-9$%])()"]),
self.RemoveSpaces,
variable_use_regexp = r"(?<![.\w$%])[\w$%]+" + block_trailing_colon
line = re.sub("|".join([double_quoted_string,
single_quoted_string,
+ template_string,
slash_quoted_regexp,
r"\{", # Curly braces.
r"\}",