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

Wrap v8natives.js into a function.

R=jkummerow@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#28174}
parent 986e2429
......@@ -3589,7 +3589,7 @@ MaybeLocal<Value> v8::Object::GetOwnPropertyDescriptor(Local<Context> context,
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);
......
......@@ -125,16 +125,16 @@ function ArrayKeys() {
%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
......
......@@ -372,7 +372,7 @@ function ArrayToString() {
func = array.join;
}
if (!IS_SPEC_FUNCTION(func)) {
return %_CallFunction(array, ObjectToString);
return %_CallFunction(array, $objectToString);
}
return %_CallFunction(array, func);
}
......@@ -447,7 +447,7 @@ function ArrayPop() {
n--;
var value = array[n];
Delete(array, ToName(n), true);
$delete(array, ToName(n), true);
array.length = n;
return value;
}
......@@ -620,7 +620,7 @@ function ArrayShift() {
return;
}
if (ObjectIsSealed(array)) throw MakeTypeError(kArrayFunctionsOnSealed);
if ($objectIsSealed(array)) throw MakeTypeError(kArrayFunctionsOnSealed);
if (%IsObserved(array))
return ObservedArrayShift.call(array, len);
......@@ -671,7 +671,7 @@ function ArrayUnshift(arg1) { // length == 1
var num_arguments = %_ArgumentsLength();
if (len > 0 && UseSparseVariant(array, len, IS_ARRAY(array), len) &&
!ObjectIsSealed(array)) {
!$objectIsSealed(array)) {
SparseMove(array, 0, 0, len, num_arguments);
} else {
SimpleMove(array, 0, 0, len, num_arguments);
......@@ -817,9 +817,9 @@ function ArraySplice(start, delete_count) {
deleted_elements.length = del_count;
var num_elements_to_add = num_arguments > 2 ? num_arguments - 2 : 0;
if (del_count != num_elements_to_add && ObjectIsSealed(array)) {
if (del_count != num_elements_to_add && $objectIsSealed(array)) {
throw MakeTypeError(kArrayFunctionsOnSealed);
} else if (del_count > 0 && ObjectIsFrozen(array)) {
} else if (del_count > 0 && $objectIsFrozen(array)) {
throw MakeTypeError(kArrayFunctionsOnFrozen);
}
......@@ -1523,7 +1523,7 @@ var unscopables = {
DONT_ENUM | READ_ONLY);
// Set up non-enumerable functions on the Array object.
InstallFunctions(GlobalArray, DONT_ENUM, [
$installFunctions(GlobalArray, DONT_ENUM, [
"isArray", ArrayIsArray
]);
......@@ -1544,7 +1544,7 @@ var getFunction = function(name, jsBuiltin, len) {
// set their names.
// Manipulate the length of some of the functions to meet
// expectations set by ECMA-262 or Mozilla.
InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
$installFunctions(GlobalArray.prototype, DONT_ENUM, [
"toString", getFunction("toString", ArrayToString),
"toLocaleString", getFunction("toLocaleString", ArrayToLocaleString),
"join", getFunction("join", ArrayJoin),
......@@ -1573,7 +1573,7 @@ InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
// The internal Array prototype doesn't need to be fancy, since it's never
// exposed to user code.
// Adding only the functions that are actually used.
SetUpLockedPrototype(InternalArray, GlobalArray(), [
$setUpLockedPrototype(InternalArray, GlobalArray(), [
"concat", getFunction("concat", ArrayConcatJS),
"indexOf", getFunction("indexOf", ArrayIndexOf),
"join", getFunction("join", ArrayJoin),
......@@ -1583,7 +1583,7 @@ SetUpLockedPrototype(InternalArray, GlobalArray(), [
"splice", getFunction("splice", ArraySplice)
]);
SetUpLockedPrototype(InternalPackedArray, GlobalArray(), [
$setUpLockedPrototype(InternalPackedArray, GlobalArray(), [
"join", getFunction("join", ArrayJoin),
"pop", getFunction("pop", ArrayPop),
"push", getFunction("push", ArrayPush),
......
......@@ -83,13 +83,13 @@ function ArrayBufferIsViewJS(obj) {
%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
]);
......
......@@ -1552,9 +1552,9 @@ void Genesis::InstallNativeFunctions() {
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);
......
......@@ -76,17 +76,17 @@ function SetValues() {
%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
......@@ -166,18 +166,18 @@ function MapValues() {
%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
......
......@@ -22,7 +22,7 @@ function HashToEntry(table, hash, numBuckets) {
function SetFindEntry(table, numBuckets, key, hash) {
var keyIsNaN = NumberIsNaN(key);
var keyIsNaN = $numberIsNaN(key);
for (var entry = HashToEntry(table, hash, numBuckets);
entry !== NOT_FOUND;
entry = ORDERED_HASH_SET_CHAIN_AT(table, entry, numBuckets)) {
......@@ -30,7 +30,7 @@ function SetFindEntry(table, numBuckets, key, hash) {
if (key === candidate) {
return entry;
}
if (keyIsNaN && NumberIsNaN(candidate)) {
if (keyIsNaN && $numberIsNaN(candidate)) {
return entry;
}
}
......@@ -40,7 +40,7 @@ function SetFindEntry(table, numBuckets, key, hash) {
function MapFindEntry(table, numBuckets, key, hash) {
var keyIsNaN = NumberIsNaN(key);
var keyIsNaN = $numberIsNaN(key);
for (var entry = HashToEntry(table, hash, numBuckets);
entry !== NOT_FOUND;
entry = ORDERED_HASH_MAP_CHAIN_AT(table, entry, numBuckets)) {
......@@ -48,7 +48,7 @@ function MapFindEntry(table, numBuckets, key, hash) {
if (key === candidate) {
return entry;
}
if (keyIsNaN && NumberIsNaN(candidate)) {
if (keyIsNaN && $numberIsNaN(candidate)) {
return entry;
}
}
......@@ -239,8 +239,8 @@ function SetForEach(f, receiver) {
%FunctionSetLength(SetForEach, 1);
// Set up the non-enumerable functions on the Set prototype object.
InstallGetter(GlobalSet.prototype, "size", SetGetSize);
InstallFunctions(GlobalSet.prototype, DONT_ENUM, [
$installGetter(GlobalSet.prototype, "size", SetGetSize);
$installFunctions(GlobalSet.prototype, DONT_ENUM, [
"add", SetAdd,
"has", SetHas,
"delete", SetDelete,
......@@ -427,8 +427,8 @@ function MapForEach(f, receiver) {
%FunctionSetLength(MapForEach, 1);
// Set up the non-enumerable functions on the Map prototype object.
InstallGetter(GlobalMap.prototype, "size", MapGetSize);
InstallFunctions(GlobalMap.prototype, DONT_ENUM, [
$installGetter(GlobalMap.prototype, "size", MapGetSize);
$installFunctions(GlobalMap.prototype, DONT_ENUM, [
"get", MapGet,
"set", MapSet,
"has", MapHas,
......
......@@ -760,7 +760,7 @@ function CreateDate(time) {
%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
......@@ -771,7 +771,7 @@ InstallFunctions(GlobalDate, DONT_ENUM, [
// 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,
......
......@@ -72,7 +72,7 @@ function GeneratorObjectIterator() {
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.
......@@ -90,12 +90,12 @@ function GeneratorFunctionConstructor(arg1) { // length == 1
// 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",
......
......@@ -52,7 +52,7 @@ function ArrayIncludes(searchElement, fromIndex) {
%FunctionSetLength(ArrayIncludes, 1);
// Set up the non-enumerable functions on the Array prototype object.
InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
$installFunctions(GlobalArray.prototype, DONT_ENUM, [
"includes", ArrayIncludes
]);
......
......@@ -173,7 +173,7 @@ function ArrayFill(value /* [, start [, end ] ] */) { // length == 1
if (end > length) end = length;
}
if ((end - i) > 0 && ObjectIsFrozen(array)) {
if ((end - i) > 0 && $objectIsFrozen(array)) {
throw MakeTypeError(kArrayFunctionsOnFrozen);
}
......@@ -197,7 +197,7 @@ function ArrayFrom(arrayLike, mapfn, receiver) {
}
}
var iterable = GetMethod(items, symbolIterator);
var iterable = $getMethod(items, symbolIterator);
var k;
var result;
var mappedValue;
......@@ -206,7 +206,7 @@ function ArrayFrom(arrayLike, mapfn, receiver) {
if (!IS_UNDEFINED(iterable)) {
result = %IsConstructor(this) ? new this() : [];
var iterator = GetIterator(items, iterable);
var iterator = $getIterator(items, iterable);
k = 0;
while (true) {
......@@ -263,7 +263,7 @@ function ArrayOf() {
// -------------------------------------------------------------------
InstallConstants(GlobalSymbol, [
$installConstants(GlobalSymbol, [
// TODO(dslomov, caitp): Move to symbol.js when shipping
"isConcatSpreadable", symbolIsConcatSpreadable
]);
......@@ -272,13 +272,13 @@ InstallConstants(GlobalSymbol, [
%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,
......
......@@ -10,7 +10,7 @@
var GlobalReflect = global.Reflect;
InstallFunctions(GlobalReflect, DONT_ENUM, [
$installFunctions(GlobalReflect, DONT_ENUM, [
"apply", $reflectApply,
"construct", $reflectConstruct
]);
......
......@@ -10,7 +10,7 @@
var GlobalSymbol = global.Symbol;
InstallConstants(GlobalSymbol, [
$installConstants(GlobalSymbol, [
// TODO(dslomov, caitp): Move to symbol.js when shipping
"toStringTag", symbolToStringTag
]);
......
......@@ -8,8 +8,6 @@
%CheckIsBootstrapping();
// -------------------------------------------------------------------
macro TYPED_ARRAYS(FUNCTION)
// arrayIds below should be synchronized with Runtime_TypedArrayInitialize.
FUNCTION(1, Uint8Array, 1)
......@@ -23,6 +21,13 @@ FUNCTION(8, Float64Array, 8)
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)
......@@ -74,12 +79,12 @@ TYPED_ARRAYS(TYPED_ARRAY_HARMONY_ADDITIONS)
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
......
This diff is collapsed.
......@@ -909,10 +909,14 @@ void Isolate::InvokeApiInterruptCallbacks() {
}
void ReportBootstrappingException(Handle<Object> exception,
MessageLocation* location) {
void Isolate::ReportBootstrappingException(Handle<Object> exception,
MessageLocation* location) {
base::OS::PrintError("Exception thrown during bootstrapping\n");
if (location == NULL || location->script().is_null()) return;
if (location == NULL || location->script().is_null()) {
exception->Print();
PrintStack(stdout);
return;
}
// We are bootstrapping and caught an error where the location is set
// and we have a script for the location.
// In this case we could have an extension (or an internal error
......@@ -981,8 +985,12 @@ Object* Isolate::Throw(Object* exception, MessageLocation* location) {
debug()->OnThrow(exception_handle);
}
// Generate the message if required.
if (requires_message && !rethrowing_message) {
if (bootstrapper()->IsActive()) {
// It's not safe to try to make message objects or collect stack traces
// while the bootstrapper is active since the infrastructure may not have
// been properly initialized.
ReportBootstrappingException(exception_handle, location);
} else if (requires_message && !rethrowing_message) {
MessageLocation potential_computed_location;
if (location == NULL) {
// If no location was specified we use a computed one instead.
......@@ -990,27 +998,20 @@ Object* Isolate::Throw(Object* exception, MessageLocation* location) {
location = &potential_computed_location;
}
if (bootstrapper()->IsActive()) {
// It's not safe to try to make message objects or collect stack traces
// while the bootstrapper is active since the infrastructure may not have
// been properly initialized.
ReportBootstrappingException(exception_handle, location);
} else {
Handle<Object> message_obj = CreateMessage(exception_handle, location);
thread_local_top()->pending_message_obj_ = *message_obj;
// If the abort-on-uncaught-exception flag is specified, abort on any
// exception not caught by JavaScript, even when an external handler is
// present. This flag is intended for use by JavaScript developers, so
// print a user-friendly stack trace (not an internal one).
if (FLAG_abort_on_uncaught_exception &&
PredictExceptionCatcher() != CAUGHT_BY_JAVASCRIPT) {
FLAG_abort_on_uncaught_exception = false; // Prevent endless recursion.
PrintF(stderr, "%s\n\nFROM\n",
MessageHandler::GetLocalizedMessage(this, message_obj).get());
PrintCurrentStackTrace(stderr);
base::OS::Abort();
}
Handle<Object> message_obj = CreateMessage(exception_handle, location);
thread_local_top()->pending_message_obj_ = *message_obj;
// If the abort-on-uncaught-exception flag is specified, abort on any
// exception not caught by JavaScript, even when an external handler is
// present. This flag is intended for use by JavaScript developers, so
// print a user-friendly stack trace (not an internal one).
if (FLAG_abort_on_uncaught_exception &&
PredictExceptionCatcher() != CAUGHT_BY_JAVASCRIPT) {
FLAG_abort_on_uncaught_exception = false; // Prevent endless recursion.
PrintF(stderr, "%s\n\nFROM\n",
MessageHandler::GetLocalizedMessage(this, message_obj).get());
PrintCurrentStackTrace(stderr);
base::OS::Abort();
}
}
......
......@@ -751,6 +751,9 @@ class Isolate {
Object* Throw(Object* exception, MessageLocation* location = NULL);
Object* ThrowIllegalOperation();
void ReportBootstrappingException(Handle<Object> exception,
MessageLocation* location);
template <typename T>
MUST_USE_RESULT MaybeHandle<T> Throw(Handle<Object> exception,
MessageLocation* location = NULL) {
......
......@@ -25,7 +25,7 @@ function Revive(holder, name, reviver) {
}
} 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];
......@@ -91,7 +91,7 @@ function SerializeObject(value, replacer, stack, indent, gap) {
if (IS_ARRAY(replacer)) {
var length = replacer.length;
for (var i = 0; i < length; i++) {
if (%_CallFunction(replacer, i, ObjectHasOwnProperty)) {
if (%_CallFunction(replacer, i, $objectHasOwnProperty)) {
var p = replacer[i];
var strP = JSONSerialize(p, value, replacer, stack, indent, gap);
if (!IS_UNDEFINED(strP)) {
......@@ -104,7 +104,7 @@ function SerializeObject(value, replacer, stack, indent, gap) {
}
} 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) + ":";
......@@ -224,7 +224,7 @@ function JSONStringify(value, replacer, space) {
%AddNamedProperty(GlobalJSON, symbolToStringTag, "JSON", READ_ONLY | DONT_ENUM);
// Set up non-enumerable properties of the JSON object.
InstallFunctions(GlobalJSON, DONT_ENUM, [
$installFunctions(GlobalJSON, DONT_ENUM, [
"parse", JSONParse,
"stringify", JSONStringify
]);
......
......@@ -152,7 +152,7 @@ macro TO_STRING_INLINE(arg) = (IS_STRING(%IS_VAR(arg)) ? arg : NonStringToString
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));
......
......@@ -294,7 +294,7 @@ var Math = new MathConstructor();
%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.
......@@ -311,7 +311,7 @@ InstallConstants(Math, [
// 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,
......
......@@ -243,6 +243,13 @@ function FormatString(format, args) {
}
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);
......@@ -250,7 +257,7 @@ function NoSideEffectToString(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);
......@@ -259,7 +266,7 @@ function NoSideEffectToString(obj) {
}
if (IS_SYMBOL(obj)) return %_CallFunction(obj, $symbolToString);
if (IS_OBJECT(obj)
&& %GetDataProperty(obj, "toString") === ObjectToString) {
&& %GetDataProperty(obj, "toString") === $objectToString) {
var constructor = %GetDataProperty(obj, "constructor");
if (typeof constructor == "function") {
var constructorName = constructor.name;
......@@ -311,7 +318,7 @@ function ToStringCheckErrorObject(obj) {
function ToDetailString(obj) {
if (obj != null && IS_OBJECT(obj) && obj.toString === ObjectToString) {
if (obj != null && IS_OBJECT(obj) && obj.toString === $objectToString) {
var constructor = obj.constructor;
if (typeof constructor == "function") {
var constructorName = constructor.name;
......@@ -589,7 +596,7 @@ function ScriptNameOrSourceURL() {
}
SetUpLockedPrototype(Script, [
$setUpLockedPrototype(Script, [
"source",
"name",
"source_url",
......@@ -653,7 +660,7 @@ function SourceLocationSourceText() {
}
SetUpLockedPrototype(SourceLocation,
$setUpLockedPrototype(SourceLocation,
["script", "position", "line", "column", "start", "end"],
["sourceText", SourceLocationSourceText]
);
......@@ -697,7 +704,7 @@ function SourceSliceSourceText() {
$stringSubstring);
}
SetUpLockedPrototype(SourceSlice,
$setUpLockedPrototype(SourceSlice,
["script", "from_line", "to_line", "from_position", "to_position"],
["sourceText", SourceSliceSourceText]
);
......@@ -792,8 +799,8 @@ function CallSiteGetMethodName() {
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.
......@@ -801,8 +808,8 @@ function CallSiteGetMethodName() {
}
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) {
......@@ -919,7 +926,7 @@ function CallSiteToString() {
return line;
}
SetUpLockedPrototype(CallSite, ["receiver", "fun", "pos"], [
$setUpLockedPrototype(CallSite, ["receiver", "fun", "pos"], [
"getThis", CallSiteGetThis,
"getTypeName", CallSiteGetTypeName,
"isToplevel", CallSiteIsToplevel,
......@@ -1108,9 +1115,9 @@ var StackTraceSetter = function(v) {
// 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);
}
......@@ -1234,7 +1241,8 @@ function ErrorToString() {
}
}
InstallFunctions(GlobalError.prototype, DONT_ENUM, ['toString', ErrorToString]);
$installFunctions(GlobalError.prototype, DONT_ENUM,
['toString', ErrorToString]);
$errorToString = ErrorToString;
$formatMessage = FormatMessage;
......
......@@ -1008,7 +1008,7 @@ FunctionMirror.prototype.source = function() {
// 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_);
}
};
......
......@@ -377,7 +377,7 @@ function ObjectObserve(object, callback, acceptList) {
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);
......@@ -470,7 +470,7 @@ function ObjectInfoEnqueueExternalChangeRecord(objectInfo, changeRecord, type) {
%DefineDataPropertyUnchecked(
newRecord, prop, changeRecord[prop], READ_ONLY + DONT_DELETE);
}
ObjectFreezeJS(newRecord);
$objectFreeze(newRecord);
ObjectInfoEnqueueInternalChangeRecord(objectInfo, newRecord);
}
......@@ -522,8 +522,8 @@ function EnqueueSpliceRecord(array, index, removed, addedCount) {
addedCount: addedCount
};
ObjectFreezeJS(changeRecord);
ObjectFreezeJS(changeRecord.removed);
$objectFreeze(changeRecord);
$objectFreeze(changeRecord.removed);
ObjectInfoEnqueueInternalChangeRecord(objectInfo, changeRecord);
}
......@@ -547,7 +547,7 @@ function NotifyChange(type, object, name, oldValue) {
};
}
ObjectFreezeJS(changeRecord);
$objectFreeze(changeRecord);
ObjectInfoEnqueueInternalChangeRecord(objectInfo, changeRecord);
}
......@@ -604,7 +604,7 @@ function ObjectGetNotifier(object) {
if (%IsJSGlobalProxy(object))
throw MakeTypeError("observe_global_proxy", ["getNotifier"]);
if (ObjectIsFrozen(object)) return null;
if ($objectIsFrozen(object)) return null;
if (!%ObjectWasCreatedInCurrentOrigin(object)) return null;
......@@ -662,17 +662,17 @@ function ObserveMicrotaskRunner() {
// -------------------------------------------------------------------
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
]);
......
......@@ -366,7 +366,7 @@ function PromiseHasUserDefinedRejectHandler() {
%AddNamedProperty(GlobalPromise.prototype, symbolToStringTag, "Promise",
DONT_ENUM | READ_ONLY);
InstallFunctions(GlobalPromise, DONT_ENUM, [
$installFunctions(GlobalPromise, DONT_ENUM, [
"defer", PromiseDeferred,
"accept", PromiseResolved,
"reject", PromiseRejected,
......@@ -375,7 +375,7 @@ InstallFunctions(GlobalPromise, DONT_ENUM, [
"resolve", PromiseCast
]);
InstallFunctions(GlobalPromise.prototype, DONT_ENUM, [
$installFunctions(GlobalPromise.prototype, DONT_ENUM, [
"chain", PromiseChain,
"then", PromiseThen,
"catch", PromiseCatch
......
......@@ -176,7 +176,7 @@ function ProxyEnumerate(proxy) {
if (IS_UNDEFINED(handler.enumerate)) {
return %Apply(DerivedEnumerateTrap, handler, [], 0, 0)
} else {
return ToNameArray(handler.enumerate(), "enumerate", false)
return $toNameArray(handler.enumerate(), "enumerate", false)
}
}
......@@ -186,7 +186,7 @@ var Proxy = new GlobalObject();
%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
])
......
......@@ -363,7 +363,7 @@ function RegExpMakeCaptureGetter(n) {
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,
......
......@@ -88,16 +88,16 @@ function StringPrototypeIterator() {
%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);
......
......@@ -1123,14 +1123,14 @@ function StringRaw(callSite) {
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,
......
......@@ -73,7 +73,7 @@ function ObjectGetOwnPropertySymbols(obj) {
// TODO(arv): Proxies use a shared trap for String and Symbol keys.
return ObjectGetOwnPropertyKeys(obj, PROPERTY_ATTRIBUTES_STRING);
return $objectGetOwnPropertyKeys(obj, PROPERTY_ATTRIBUTES_STRING);
}
//-------------------------------------------------------------------
......@@ -81,7 +81,7 @@ function ObjectGetOwnPropertySymbols(obj) {
%SetCode(GlobalSymbol, SymbolConstructor);
%FunctionSetPrototype(GlobalSymbol, new GlobalObject());
InstallConstants(GlobalSymbol, [
$installConstants(GlobalSymbol, [
// TODO(rossberg): expose when implemented.
// "hasInstance", symbolHasInstance,
// "isConcatSpreadable", symbolIsConcatSpreadable,
......@@ -93,7 +93,7 @@ InstallConstants(GlobalSymbol, [
"unscopables", symbolUnscopables
]);
InstallFunctions(GlobalSymbol, DONT_ENUM, [
$installFunctions(GlobalSymbol, DONT_ENUM, [
"for", SymbolFor,
"keyFor", SymbolKeyFor
]);
......@@ -103,12 +103,12 @@ InstallFunctions(GlobalSymbol, DONT_ENUM, [
%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
]);
......
......@@ -1012,7 +1012,7 @@ function MathLog2(x) {
//-------------------------------------------------------------------
InstallFunctions(GlobalMath, DONT_ENUM, [
$installFunctions(GlobalMath, DONT_ENUM, [
"cos", MathCos,
"sin", MathSin,
"tan", MathTan,
......
......@@ -10,8 +10,9 @@
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)
......@@ -25,6 +26,14 @@ FUNCTION(8, Float64Array, 8)
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)) {
......@@ -145,8 +154,6 @@ function NAME_GetLength() {
return %_TypedArrayGetLength(this);
}
var $NAME = global.NAME;
function NAMESubArray(begin, end) {
if (!(%_ClassOf(this) === 'NAME')) {
throw MakeTypeError(kIncompatibleMethodReceiver, "NAME.subarray", this);
......@@ -175,8 +182,8 @@ function NAMESubArray(begin, end) {
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
......@@ -297,26 +304,26 @@ function TypedArrayGetToStringTag() {
// -------------------------------------------------------------------
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
]);
......@@ -326,8 +333,6 @@ TYPED_ARRAYS(SETUP_TYPED_ARRAY)
// --------------------------- DataView -----------------------------
var $DataView = global.DataView;
function DataViewConstructor(buffer, byteOffset, byteLength) { // length = 3
if (%_IsConstructCall()) {
if (!IS_ARRAYBUFFER(buffer)) {
......@@ -430,19 +435,20 @@ endmacro
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,
......
......@@ -356,7 +356,7 @@ function URIEncodeComponent(component) {
// 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,
......
This diff is collapsed.
......@@ -90,7 +90,7 @@ function WeakMapDelete(key) {
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,
......@@ -162,7 +162,7 @@ function WeakSetDelete(value) {
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
......
......@@ -29,5 +29,5 @@
// Test call of JS runtime functions.
var a = %GlobalParseInt("21", 16);
assertEquals(33, a);
var a = %$isNaN(0/0);
assertEquals(true, a);
......@@ -100,6 +100,12 @@ class JavaScriptMinifier(object):
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
......@@ -152,6 +158,9 @@ class JavaScriptMinifier(object):
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
......@@ -184,6 +193,8 @@ class JavaScriptMinifier(object):
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
......@@ -227,8 +238,10 @@ class JavaScriptMinifier(object):
# 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.
......@@ -238,6 +251,7 @@ class JavaScriptMinifier(object):
# Replace multiple spaces with a single space.
line = re.sub("|".join([double_quoted_string,
single_quoted_string,
template_string,
slash_quoted_regexp,
"( )+"]),
self.RemoveSpaces,
......@@ -246,6 +260,7 @@ class JavaScriptMinifier(object):
# 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,
......@@ -269,6 +284,7 @@ class JavaScriptMinifier(object):
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"\}",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment