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

Move error message makers off js builtins object.

R=cbruni@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#31467}
parent efbbf0fd
......@@ -15,6 +15,8 @@ var IsNaN = global.isNaN;
var JSONParse = global.JSON.parse;
var JSONStringify = global.JSON.stringify;
var LookupMirror = global.LookupMirror;
var MakeError;
var MakeTypeError;
var MakeMirror = global.MakeMirror;
var MakeMirrorSerializer = global.MakeMirrorSerializer;
var MathMin = global.Math.min;
......@@ -24,6 +26,8 @@ var ParseInt = global.parseInt;
var ValueMirror = global.ValueMirror;
utils.Import(function(from) {
MakeError = from.MakeError;
MakeTypeError = from.MakeTypeError;
MirrorType = from.MirrorType;
});
......
......@@ -13,6 +13,7 @@ var FunctionSourceString;
var GlobalArray = global.Array;
var IsNaN = global.isNaN;
var JSONStringify = global.JSON.stringify;
var MakeError;
var MapEntries;
var MapIteratorNext;
var MathMin = global.Math.min;
......@@ -25,6 +26,7 @@ var SymbolToString;
utils.Import(function(from) {
ErrorToString = from.ErrorToString;
FunctionSourceString = from.FunctionSourceString;
MakeError = from.MakeError;
MapEntries = from.MapEntries;
MapIteratorNext = from.MapIteratorNext;
SetIteratorNext = from.SetIteratorNext;
......
......@@ -20,6 +20,7 @@ var arrayIteratorObjectSymbol =
var GlobalArray = global.Array;
var IteratorPrototype = utils.ImportNow("IteratorPrototype");
var iteratorSymbol = utils.ImportNow("iterator_symbol");
var MakeTypeError;
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
macro TYPED_ARRAYS(FUNCTION)
......@@ -40,6 +41,10 @@ endmacro
TYPED_ARRAYS(COPY_FROM_GLOBAL)
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
})
// -----------------------------------------------------------------------
function ArrayIterator() {}
......
......@@ -16,6 +16,7 @@ var FLAG_harmony_tolength;
var GlobalArray = global.Array;
var InternalArray = utils.InternalArray;
var InternalPackedArray = utils.InternalPackedArray;
var MakeTypeError;
var MinSimple;
var ObjectHasOwnProperty;
var ObjectIsFrozen;
......@@ -28,6 +29,7 @@ var unscopablesSymbol = utils.ImportNow("unscopables_symbol");
utils.Import(function(from) {
Delete = from.Delete;
MakeTypeError = from.MakeTypeError;
MinSimple = from.MinSimple;
ObjectHasOwnProperty = from.ObjectHasOwnProperty;
ObjectIsFrozen = from.ObjectIsFrozen;
......
......@@ -13,12 +13,14 @@
var GlobalArrayBuffer = global.ArrayBuffer;
var GlobalObject = global.Object;
var MakeTypeError;
var MaxSimple;
var MinSimple;
var ToPositiveInteger;
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
MaxSimple = from.MaxSimple;
MinSimple = from.MinSimple;
ToPositiveInteger = from.ToPositiveInteger;
......
......@@ -8,13 +8,21 @@
%CheckIsBootstrapping();
// -------------------------------------------------------------------
// Imports
var GlobalMap = global.Map;
var GlobalSet = global.Set;
var iteratorSymbol = utils.ImportNow("iterator_symbol");
var MakeTypeError;
var MapIterator = utils.ImportNow("MapIterator");
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
var SetIterator = utils.ImportNow("SetIterator");
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
});
// -------------------------------------------------------------------
function SetIteratorConstructor(set, kind) {
......
......@@ -15,6 +15,7 @@ var GlobalObject = global.Object;
var GlobalSet = global.Set;
var hashCodeSymbol = utils.ImportNow("hash_code_symbol");
var IntRandom;
var MakeTypeError;
var MapIterator;
var NumberIsNaN;
var SetIterator;
......@@ -22,6 +23,7 @@ var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
IntRandom = from.IntRandom;
MakeTypeError = from.MakeTypeError;
MapIterator = from.MapIterator;
NumberIsNaN = from.NumberIsNaN;
SetIterator = from.SetIterator;
......
......@@ -17,12 +17,14 @@ var GlobalDate = global.Date;
var GlobalObject = global.Object;
var InternalArray = utils.InternalArray;
var IsFinite;
var MakeRangeError;
var MathAbs;
var MathFloor;
var NaN = %GetRootNaN();
utils.Import(function(from) {
IsFinite = from.IsFinite;
MakeRangeError = from.MakeRangeError;
MathAbs = from.MathAbs;
MathFloor = from.MathFloor;
});
......
......@@ -14,10 +14,12 @@
var GeneratorFunctionPrototype = utils.ImportNow("GeneratorFunctionPrototype");
var GeneratorFunction = utils.ImportNow("GeneratorFunction");
var GlobalFunction = global.Function;
var MakeTypeError;
var NewFunctionString;
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
NewFunctionString = from.NewFunctionString;
});
......
......@@ -8,10 +8,15 @@
%CheckIsBootstrapping();
// -------------------------------------------------------------------
// Imports
var GlobalArray = global.Array;
var MakeTypeError;
var SameValueZero;
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
SameValueZero = from.SameValueZero;
});
......
......@@ -16,6 +16,7 @@ var GetIterator;
var GetMethod;
var GlobalArray = global.Array;
var iteratorSymbol = utils.ImportNow("iterator_symbol");
var MakeTypeError;
var MaxSimple;
var MinSimple;
var ObjectIsFrozen;
......@@ -25,6 +26,7 @@ utils.Import(function(from) {
FLAG_harmony_tolength = from.FLAG_harmony_tolength;
GetIterator = from.GetIterator;
GetMethod = from.GetMethod;
MakeTypeError = from.MakeTypeError;
MaxSimple = from.MaxSimple;
MinSimple = from.MinSimple;
ObjectIsFrozen = from.ObjectIsFrozen;
......
......@@ -12,10 +12,12 @@
// Imports
var GlobalObject = global.Object;
var MakeTypeError;
var MaxSimple;
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
MaxSimple = from.MaxSimple;
});
......
......@@ -8,10 +8,20 @@
%CheckIsBootstrapping();
// -------------------------------------------------------------------
// Imports
var GlobalReflect = global.Reflect;
var MakeTypeError;
var ReflectApply = utils.ImportNow("reflect_apply");
var ReflectConstruct = utils.ImportNow("reflect_construct");
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
});
// -------------------------------------------------------------------
function ReflectEnumerate(obj) {
if (!IS_SPEC_OBJECT(obj))
throw MakeTypeError(kCalledOnNonObject, "Reflect.enumerate")
......
......@@ -12,6 +12,11 @@
// Imports
var GlobalRegExp = global.RegExp;
var MakeTypeError;
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
});
// -------------------------------------------------------------------
......
......@@ -10,10 +10,12 @@
var GlobalSharedArrayBuffer = global.SharedArrayBuffer;
var GlobalObject = global.Object;
var MakeTypeError;
var ToPositiveInteger;
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
ToPositiveInteger = from.ToPositiveInteger;
})
......
......@@ -12,8 +12,15 @@
// Imports
var GlobalSIMD = global.SIMD;
var MakeTypeError;
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
});
// -------------------------------------------------------------------
macro SIMD_FLOAT_TYPES(FUNCTION)
FUNCTION(Float32x4, float32x4, 4)
endmacro
......
......@@ -9,6 +9,11 @@
// -------------------------------------------------------------------
// Imports
var InternalArray = utils.InternalArray;
var MakeTypeError;
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
});
// -------------------------------------------------------------------
......
......@@ -48,6 +48,7 @@ var InnerArraySome;
var InnerArraySort;
var InnerArrayToLocaleString;
var IsNaN;
var MakeTypeError;
var MaxSimple;
var MinSimple;
var PackedArrayReverse;
......@@ -72,6 +73,7 @@ utils.Import(function(from) {
InnerArraySort = from.InnerArraySort;
InnerArrayToLocaleString = from.InnerArrayToLocaleString;
IsNaN = from.IsNaN;
MakeTypeError = from.MakeTypeError;
MaxSimple = from.MaxSimple;
MinSimple = from.MinSimple;
PackedArrayReverse = from.PackedArrayReverse;
......
......@@ -27,6 +27,9 @@ var GlobalDate = global.Date;
var GlobalNumber = global.Number;
var GlobalRegExp = global.RegExp;
var GlobalString = global.String;
var MakeError;
var MakeRangeError;
var MakeTypeError;
var MathFloor;
var ObjectDefineProperties = utils.ImportNow("ObjectDefineProperties");
var ObjectDefineProperty = utils.ImportNow("ObjectDefineProperty");
......@@ -45,6 +48,9 @@ utils.Import(function(from) {
ArrayPush = from.ArrayPush;
IsFinite = from.IsFinite;
IsNaN = from.IsNaN;
MakeError = from.MakeError;
MakeRangeError = from.MakeRangeError;
MakeTypeError = from.MakeTypeError;
MathFloor = from.MathFloor;
RegExpTest = from.RegExpTest;
StringIndexOf = from.StringIndexOf;
......
......@@ -13,14 +13,18 @@
var GlobalJSON = global.JSON;
var InternalArray = utils.InternalArray;
var MakeTypeError;
var MaxSimple;
var MinSimple;
var ObjectHasOwnProperty;
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
MaxSimple = from.MaxSimple;
MinSimple = from.MinSimple;
MathMax = from.MathMax;
MathMin = from.MathMin;
ObjectHasOwnProperty = from.ObjectHasOwnProperty;
});
......
......@@ -4,14 +4,6 @@
// -------------------------------------------------------------------
var MakeError;
var MakeEvalError;
var MakeRangeError;
var MakeReferenceError;
var MakeSyntaxError;
var MakeTypeError;
var MakeURIError;
(function(global, utils) {
%CheckIsBootstrapping();
......@@ -972,6 +964,9 @@ GlobalURIError = DefineError(global, function URIError() { });
%AddNamedProperty(GlobalError.prototype, 'message', '', DONT_ENUM);
utils.InstallFunctions(GlobalError.prototype, DONT_ENUM,
['toString', ErrorToString]);
function ErrorToString() {
if (!IS_SPEC_OBJECT(this)) {
throw MakeTypeError(kCalledOnNonObject, "Error.prototype.toString");
......@@ -980,26 +975,23 @@ function ErrorToString() {
return %ErrorToStringRT(this);
}
utils.InstallFunctions(GlobalError.prototype, DONT_ENUM,
['toString', ErrorToString]);
MakeError = function(type, arg0, arg1, arg2) {
function MakeError(type, arg0, arg1, arg2) {
return MakeGenericError(GlobalError, type, arg0, arg1, arg2);
}
MakeRangeError = function(type, arg0, arg1, arg2) {
function MakeRangeError(type, arg0, arg1, arg2) {
return MakeGenericError(GlobalRangeError, type, arg0, arg1, arg2);
}
MakeSyntaxError = function(type, arg0, arg1, arg2) {
function MakeSyntaxError(type, arg0, arg1, arg2) {
return MakeGenericError(GlobalSyntaxError, type, arg0, arg1, arg2);
}
MakeTypeError = function(type, arg0, arg1, arg2) {
function MakeTypeError(type, arg0, arg1, arg2) {
return MakeGenericError(GlobalTypeError, type, arg0, arg1, arg2);
}
MakeURIError = function() {
function MakeURIError() {
return MakeGenericError(GlobalURIError, kURIMalformed);
}
......@@ -1043,6 +1035,11 @@ GlobalError.captureStackTrace = captureStackTrace;
utils.Export(function(to) {
to.ErrorToString = ErrorToString;
to.MakeError = MakeError;
to.MakeRangeError = MakeRangeError;
to.MakeSyntaxError = MakeSyntaxError;
to.MakeTypeError = MakeTypeError;
to.MakeURIError = MakeURIError;
});
});
......@@ -15,11 +15,13 @@ var GetHash;
var GlobalArray = global.Array;
var GlobalObject = global.Object;
var InternalArray = utils.InternalArray;
var MakeTypeError;
var ObjectFreeze;
var ObjectIsFrozen;
utils.Import(function(from) {
GetHash = from.GetHash;
MakeTypeError = from.MakeTypeError;
ObjectFreeze = from.ObjectFreeze;
ObjectIsFrozen = from.ObjectIsFrozen;
});
......
......@@ -181,6 +181,8 @@ function PostNatives(utils) {
"InnerArraySort",
"InnerArrayToLocaleString",
"IsNaN",
"MakeError",
"MakeTypeError",
"MapEntries",
"MapIterator",
"MapIteratorNext",
......
......@@ -12,6 +12,7 @@
// Imports
var InternalArray = utils.InternalArray;
var MakeTypeError;
var promiseCombinedDeferredSymbol =
utils.ImportNow("promise_combined_deferred_symbol");
var promiseHasHandlerSymbol =
......@@ -24,6 +25,10 @@ var promiseStatusSymbol = utils.ImportNow("promise_status_symbol");
var promiseValueSymbol = utils.ImportNow("promise_value_symbol");
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
});
// -------------------------------------------------------------------
// Status values: 0 = pending, +1 = resolved, -1 = rejected
......
......@@ -13,10 +13,11 @@
var GlobalFunction = global.Function;
var GlobalObject = global.Object;
var MakeTypeError;
var ToNameArray;
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
ToNameArray = from.ToNameArray;
});
......
......@@ -16,6 +16,7 @@ var FLAG_harmony_tolength;
var FLAG_harmony_unicode_regexps;
var GlobalRegExp = global.RegExp;
var InternalPackedArray = utils.InternalPackedArray;
var MakeTypeError;
utils.ImportFromExperimental(function(from) {
FLAG_harmony_regexps = from.FLAG_harmony_regexps;
......@@ -23,6 +24,10 @@ utils.ImportFromExperimental(function(from) {
FLAG_harmony_unicode_regexps = from.FLAG_harmony_unicode_regexps;
});
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
});
// -------------------------------------------------------------------
// Property of the builtins object for recording the result of the last
......
......@@ -21,6 +21,11 @@ var GlobalBoolean = global.Boolean;
var GlobalString = global.String;
var isConcatSpreadableSymbol =
utils.ImportNow("is_concat_spreadable_symbol");
var MakeRangeError;
utils.Import(function(from) {
MakeRangeError = from.MakeRangeError;
});
// ----------------------------------------------------------------------------
......
......@@ -14,12 +14,17 @@
var GlobalString = global.String;
var IteratorPrototype = utils.ImportNow("IteratorPrototype");
var iteratorSymbol = utils.ImportNow("iterator_symbol");
var MakeTypeError;
var stringIteratorIteratedStringSymbol =
utils.ImportNow("string_iterator_iterated_string_symbol");
var stringIteratorNextIndexSymbol =
utils.ImportNow("string_iterator_next_index_symbol");
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
});
// -------------------------------------------------------------------
function StringIterator() {}
......
......@@ -15,6 +15,8 @@ var GlobalRegExp = global.RegExp;
var GlobalString = global.String;
var InternalArray = utils.InternalArray;
var InternalPackedArray = utils.InternalPackedArray;
var MakeRangeError;
var MakeTypeError;
var RegExpExec;
var RegExpExecNoTests;
var RegExpLastMatchInfo;
......@@ -22,6 +24,8 @@ var RegExpLastMatchInfo;
utils.Import(function(from) {
ArrayIndexOf = from.ArrayIndexOf;
ArrayJoin = from.ArrayJoin;
MakeRangeError = from.MakeRangeError;
MakeTypeError = from.MakeTypeError;
RegExpExec = from.RegExpExec;
RegExpExecNoTests = from.RegExpExecNoTests;
RegExpLastMatchInfo = from.RegExpLastMatchInfo;
......
......@@ -18,12 +18,14 @@ var isConcatSpreadableSymbol =
utils.ImportNow("is_concat_spreadable_symbol");
var isRegExpSymbol = utils.ImportNow("is_regexp_symbol");
var iteratorSymbol = utils.ImportNow("iterator_symbol");
var MakeTypeError;
var ObjectGetOwnPropertyKeys;
var toPrimitiveSymbol = utils.ImportNow("to_primitive_symbol");
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
var unscopablesSymbol = utils.ImportNow("unscopables_symbol");
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
ObjectGetOwnPropertyKeys = from.ObjectGetOwnPropertyKeys;
});
......
......@@ -18,6 +18,8 @@ var GlobalDataView = global.DataView;
var GlobalObject = global.Object;
var InternalArray = utils.InternalArray;
var iteratorSymbol = utils.ImportNow("iterator_symbol");
var MakeRangeError;
var MakeTypeError;
var MaxSimple;
var MinSimple;
var ToPositiveInteger;
......@@ -44,6 +46,8 @@ TYPED_ARRAYS(DECLARE_GLOBALS)
utils.Import(function(from) {
ArrayValues = from.ArrayValues;
MakeRangeError = from.MakeRangeError;
MakeTypeError = from.MakeTypeError;
MaxSimple = from.MaxSimple;
MinSimple = from.MinSimple;
ToPositiveInteger = from.ToPositiveInteger;
......
......@@ -17,6 +17,12 @@
var GlobalObject = global.Object;
var GlobalArray = global.Array;
var InternalArray = utils.InternalArray;
var MakeURIError;
utils.Import(function(from) {
MakeURIError = from.MakeURIError;
});
// -------------------------------------------------------------------
// Define internal helper functions.
......
......@@ -17,6 +17,9 @@ var GlobalNumber = global.Number;
var GlobalObject = global.Object;
var InternalArray = utils.InternalArray;
var iteratorSymbol = utils.ImportNow("iterator_symbol");
var MakeRangeError;
var MakeSyntaxError;
var MakeTypeError;
var MathAbs;
var NaN = %GetRootNaN();
var ObserveBeginPerformSplice;
......@@ -30,6 +33,9 @@ var StringIndexOf;
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
MakeRangeError = from.MakeRangeError;
MakeSyntaxError = from.MakeSyntaxError;
MakeTypeError = from.MakeTypeError;
MathAbs = from.MathAbs;
ObserveBeginPerformSplice = from.ObserveBeginPerformSplice;
ObserveEndPerformSplice = from.ObserveEndPerformSplice;
......
......@@ -16,11 +16,13 @@ var GetHash;
var GlobalObject = global.Object;
var GlobalWeakMap = global.WeakMap;
var GlobalWeakSet = global.WeakSet;
var MakeTypeError;
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
GetExistingHash = from.GetExistingHash;
GetHash = from.GetHash;
MakeTypeError = from.MakeTypeError;
});
// -------------------------------------------------------------------
......
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