Reland "Migrate error messages, part 2."
Review URL: https://codereview.chromium.org/1083083004 Cr-Commit-Position: refs/heads/master@{#27907}
This commit is contained in:
parent
548a0b3bbd
commit
ae2057e81a
@ -73,8 +73,8 @@ function ArrayIteratorNext() {
|
||||
var iterator = ToObject(this);
|
||||
|
||||
if (!HAS_DEFINED_PRIVATE(iterator, arrayIteratorNextIndexSymbol)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['Array Iterator.prototype.next']);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'Array Iterator.prototype.next', this);
|
||||
}
|
||||
|
||||
var array = GET_PRIVATE(iterator, arrayIteratorObjectSymbol);
|
||||
|
24
src/array.js
24
src/array.js
@ -1142,9 +1142,7 @@ function ArrayFilter(f, receiver) {
|
||||
var array = ToObject(this);
|
||||
var length = ToUint32(array.length);
|
||||
|
||||
if (!IS_SPEC_FUNCTION(f)) {
|
||||
throw MakeTypeError('called_non_callable', [ f ]);
|
||||
}
|
||||
if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f);
|
||||
var needs_wrapper = false;
|
||||
if (IS_NULL_OR_UNDEFINED(receiver)) {
|
||||
receiver = %GetDefaultReceiver(f) || receiver;
|
||||
@ -1181,9 +1179,7 @@ function ArrayForEach(f, receiver) {
|
||||
var array = ToObject(this);
|
||||
var length = TO_UINT32(array.length);
|
||||
|
||||
if (!IS_SPEC_FUNCTION(f)) {
|
||||
throw MakeTypeError('called_non_callable', [ f ]);
|
||||
}
|
||||
if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f);
|
||||
var needs_wrapper = false;
|
||||
if (IS_NULL_OR_UNDEFINED(receiver)) {
|
||||
receiver = %GetDefaultReceiver(f) || receiver;
|
||||
@ -1215,9 +1211,7 @@ function ArraySome(f, receiver) {
|
||||
var array = ToObject(this);
|
||||
var length = TO_UINT32(array.length);
|
||||
|
||||
if (!IS_SPEC_FUNCTION(f)) {
|
||||
throw MakeTypeError('called_non_callable', [ f ]);
|
||||
}
|
||||
if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f);
|
||||
var needs_wrapper = false;
|
||||
if (IS_NULL_OR_UNDEFINED(receiver)) {
|
||||
receiver = %GetDefaultReceiver(f) || receiver;
|
||||
@ -1248,9 +1242,7 @@ function ArrayEvery(f, receiver) {
|
||||
var array = ToObject(this);
|
||||
var length = TO_UINT32(array.length);
|
||||
|
||||
if (!IS_SPEC_FUNCTION(f)) {
|
||||
throw MakeTypeError('called_non_callable', [ f ]);
|
||||
}
|
||||
if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f);
|
||||
var needs_wrapper = false;
|
||||
if (IS_NULL_OR_UNDEFINED(receiver)) {
|
||||
receiver = %GetDefaultReceiver(f) || receiver;
|
||||
@ -1280,9 +1272,7 @@ function ArrayMap(f, receiver) {
|
||||
var array = ToObject(this);
|
||||
var length = TO_UINT32(array.length);
|
||||
|
||||
if (!IS_SPEC_FUNCTION(f)) {
|
||||
throw MakeTypeError('called_non_callable', [ f ]);
|
||||
}
|
||||
if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f);
|
||||
var needs_wrapper = false;
|
||||
if (IS_NULL_OR_UNDEFINED(receiver)) {
|
||||
receiver = %GetDefaultReceiver(f) || receiver;
|
||||
@ -1427,7 +1417,7 @@ function ArrayReduce(callback, current) {
|
||||
var length = ToUint32(array.length);
|
||||
|
||||
if (!IS_SPEC_FUNCTION(callback)) {
|
||||
throw MakeTypeError('called_non_callable', [callback]);
|
||||
throw MakeTypeError(kCalledNonCallable, callback);
|
||||
}
|
||||
|
||||
var is_array = IS_ARRAY(array);
|
||||
@ -1464,7 +1454,7 @@ function ArrayReduceRight(callback, current) {
|
||||
var length = ToUint32(array.length);
|
||||
|
||||
if (!IS_SPEC_FUNCTION(callback)) {
|
||||
throw MakeTypeError('called_non_callable', [callback]);
|
||||
throw MakeTypeError(kCalledNonCallable, callback);
|
||||
}
|
||||
|
||||
var is_array = IS_ARRAY(array);
|
||||
|
@ -24,8 +24,8 @@ function ArrayBufferConstructor(length) { // length = 1
|
||||
|
||||
function ArrayBufferGetByteLen() {
|
||||
if (!IS_ARRAYBUFFER(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['ArrayBuffer.prototype.byteLength', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'ArrayBuffer.prototype.byteLength', this);
|
||||
}
|
||||
return %_ArrayBufferGetByteLength(this);
|
||||
}
|
||||
@ -33,8 +33,8 @@ function ArrayBufferGetByteLen() {
|
||||
// ES6 Draft 15.13.5.5.3
|
||||
function ArrayBufferSlice(start, end) {
|
||||
if (!IS_ARRAYBUFFER(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['ArrayBuffer.prototype.slice', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'ArrayBuffer.prototype.slice', this);
|
||||
}
|
||||
|
||||
var relativeStart = TO_INTEGER(start);
|
||||
|
@ -26,8 +26,8 @@ function SetIteratorConstructor(set, kind) {
|
||||
|
||||
function SetIteratorNextJS() {
|
||||
if (!IS_SET_ITERATOR(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['Set Iterator.prototype.next', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'Set Iterator.prototype.next', this);
|
||||
}
|
||||
|
||||
var value_array = [UNDEFINED, UNDEFINED];
|
||||
@ -56,8 +56,8 @@ function SetIteratorSymbolIterator() {
|
||||
|
||||
function SetEntries() {
|
||||
if (!IS_SET(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['Set.prototype.entries', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'Set.prototype.entries', this);
|
||||
}
|
||||
return new SetIterator(this, ITERATOR_KIND_ENTRIES);
|
||||
}
|
||||
@ -65,8 +65,8 @@ function SetEntries() {
|
||||
|
||||
function SetValues() {
|
||||
if (!IS_SET(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['Set.prototype.values', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'Set.prototype.values', this);
|
||||
}
|
||||
return new SetIterator(this, ITERATOR_KIND_VALUES);
|
||||
}
|
||||
@ -111,8 +111,8 @@ function MapIteratorSymbolIterator() {
|
||||
|
||||
function MapIteratorNextJS() {
|
||||
if (!IS_MAP_ITERATOR(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['Map Iterator.prototype.next', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'Map Iterator.prototype.next', this);
|
||||
}
|
||||
|
||||
var value_array = [UNDEFINED, UNDEFINED];
|
||||
@ -137,8 +137,8 @@ function MapIteratorNextJS() {
|
||||
|
||||
function MapEntries() {
|
||||
if (!IS_MAP(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['Map.prototype.entries', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'Map.prototype.entries', this);
|
||||
}
|
||||
return new MapIterator(this, ITERATOR_KIND_ENTRIES);
|
||||
}
|
||||
@ -146,8 +146,8 @@ function MapEntries() {
|
||||
|
||||
function MapKeys() {
|
||||
if (!IS_MAP(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['Map.prototype.keys', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'Map.prototype.keys', this);
|
||||
}
|
||||
return new MapIterator(this, ITERATOR_KIND_KEYS);
|
||||
}
|
||||
@ -155,8 +155,8 @@ function MapKeys() {
|
||||
|
||||
function MapValues() {
|
||||
if (!IS_MAP(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['Map.prototype.values', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'Map.prototype.values', this);
|
||||
}
|
||||
return new MapIterator(this, ITERATOR_KIND_VALUES);
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ function SetConstructor(iterable) {
|
||||
if (!IS_NULL_OR_UNDEFINED(iterable)) {
|
||||
var adder = this.add;
|
||||
if (!IS_SPEC_FUNCTION(adder)) {
|
||||
throw MakeTypeError(kPropertyNotFunction, ['add', this]);
|
||||
throw MakeTypeError(kPropertyNotFunction, 'add', this);
|
||||
}
|
||||
|
||||
for (var value of iterable) {
|
||||
@ -111,8 +111,7 @@ function SetConstructor(iterable) {
|
||||
|
||||
function SetAdd(key) {
|
||||
if (!IS_SET(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['Set.prototype.add', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver, 'Set.prototype.add', this);
|
||||
}
|
||||
// Normalize -0 to +0 as required by the spec.
|
||||
// Even though we use SameValueZero as the comparison for the keys we don't
|
||||
@ -152,8 +151,7 @@ function SetAdd(key) {
|
||||
|
||||
function SetHas(key) {
|
||||
if (!IS_SET(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['Set.prototype.has', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver, 'Set.prototype.has', this);
|
||||
}
|
||||
var table = %_JSCollectionGetTable(this);
|
||||
var numBuckets = ORDERED_HASH_TABLE_BUCKET_COUNT(table);
|
||||
@ -164,8 +162,8 @@ function SetHas(key) {
|
||||
|
||||
function SetDelete(key) {
|
||||
if (!IS_SET(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['Set.prototype.delete', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'Set.prototype.delete', this);
|
||||
}
|
||||
var table = %_JSCollectionGetTable(this);
|
||||
var numBuckets = ORDERED_HASH_TABLE_BUCKET_COUNT(table);
|
||||
@ -186,8 +184,8 @@ function SetDelete(key) {
|
||||
|
||||
function SetGetSize() {
|
||||
if (!IS_SET(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['Set.prototype.size', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'Set.prototype.size', this);
|
||||
}
|
||||
var table = %_JSCollectionGetTable(this);
|
||||
return ORDERED_HASH_TABLE_ELEMENT_COUNT(table);
|
||||
@ -196,8 +194,8 @@ function SetGetSize() {
|
||||
|
||||
function SetClearJS() {
|
||||
if (!IS_SET(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['Set.prototype.clear', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'Set.prototype.clear', this);
|
||||
}
|
||||
%_SetClear(this);
|
||||
}
|
||||
@ -205,13 +203,11 @@ function SetClearJS() {
|
||||
|
||||
function SetForEach(f, receiver) {
|
||||
if (!IS_SET(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['Set.prototype.forEach', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'Set.prototype.forEach', this);
|
||||
}
|
||||
|
||||
if (!IS_SPEC_FUNCTION(f)) {
|
||||
throw MakeTypeError('called_non_callable', [f]);
|
||||
}
|
||||
if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f);
|
||||
var needs_wrapper = false;
|
||||
if (IS_NULL_OR_UNDEFINED(receiver)) {
|
||||
receiver = %GetDefaultReceiver(f) || receiver;
|
||||
@ -266,7 +262,7 @@ function MapConstructor(iterable) {
|
||||
if (!IS_NULL_OR_UNDEFINED(iterable)) {
|
||||
var adder = this.set;
|
||||
if (!IS_SPEC_FUNCTION(adder)) {
|
||||
throw MakeTypeError(kPropertyNotFunction, ['set', this]);
|
||||
throw MakeTypeError(kPropertyNotFunction, 'set', this);
|
||||
}
|
||||
|
||||
for (var nextItem of iterable) {
|
||||
@ -281,8 +277,8 @@ function MapConstructor(iterable) {
|
||||
|
||||
function MapGet(key) {
|
||||
if (!IS_MAP(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['Map.prototype.get', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'Map.prototype.get', this);
|
||||
}
|
||||
var table = %_JSCollectionGetTable(this);
|
||||
var numBuckets = ORDERED_HASH_TABLE_BUCKET_COUNT(table);
|
||||
@ -295,8 +291,8 @@ function MapGet(key) {
|
||||
|
||||
function MapSet(key, value) {
|
||||
if (!IS_MAP(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['Map.prototype.set', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'Map.prototype.set', this);
|
||||
}
|
||||
// Normalize -0 to +0 as required by the spec.
|
||||
// Even though we use SameValueZero as the comparison for the keys we don't
|
||||
@ -343,8 +339,8 @@ function MapSet(key, value) {
|
||||
|
||||
function MapHas(key) {
|
||||
if (!IS_MAP(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['Map.prototype.has', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'Map.prototype.has', this);
|
||||
}
|
||||
var table = %_JSCollectionGetTable(this);
|
||||
var numBuckets = ORDERED_HASH_TABLE_BUCKET_COUNT(table);
|
||||
@ -355,8 +351,8 @@ function MapHas(key) {
|
||||
|
||||
function MapDelete(key) {
|
||||
if (!IS_MAP(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['Map.prototype.delete', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'Map.prototype.delete', this);
|
||||
}
|
||||
var table = %_JSCollectionGetTable(this);
|
||||
var numBuckets = ORDERED_HASH_TABLE_BUCKET_COUNT(table);
|
||||
@ -378,8 +374,8 @@ function MapDelete(key) {
|
||||
|
||||
function MapGetSize() {
|
||||
if (!IS_MAP(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['Map.prototype.size', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'Map.prototype.size', this);
|
||||
}
|
||||
var table = %_JSCollectionGetTable(this);
|
||||
return ORDERED_HASH_TABLE_ELEMENT_COUNT(table);
|
||||
@ -388,8 +384,8 @@ function MapGetSize() {
|
||||
|
||||
function MapClearJS() {
|
||||
if (!IS_MAP(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['Map.prototype.clear', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'Map.prototype.clear', this);
|
||||
}
|
||||
%_MapClear(this);
|
||||
}
|
||||
@ -397,13 +393,11 @@ function MapClearJS() {
|
||||
|
||||
function MapForEach(f, receiver) {
|
||||
if (!IS_MAP(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['Map.prototype.forEach', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'Map.prototype.forEach', this);
|
||||
}
|
||||
|
||||
if (!IS_SPEC_FUNCTION(f)) {
|
||||
throw MakeTypeError('called_non_callable', [f]);
|
||||
}
|
||||
if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f);
|
||||
var needs_wrapper = false;
|
||||
if (IS_NULL_OR_UNDEFINED(receiver)) {
|
||||
receiver = %GetDefaultReceiver(f) || receiver;
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "src/codegen.h"
|
||||
#include "src/deoptimizer.h"
|
||||
#include "src/isolate-inl.h"
|
||||
#include "src/messages.h"
|
||||
#include "src/vm-state-inl.h"
|
||||
|
||||
namespace v8 {
|
||||
@ -279,8 +280,8 @@ MaybeHandle<Object> Execution::TryGetFunctionDelegate(Isolate* isolate,
|
||||
|
||||
// If the Object doesn't have an instance-call handler we should
|
||||
// throw a non-callable exception.
|
||||
THROW_NEW_ERROR(isolate, NewTypeError("called_non_callable",
|
||||
i::HandleVector<i::Object>(&object, 1)),
|
||||
THROW_NEW_ERROR(isolate,
|
||||
NewTypeError(MessageTemplate::kCalledNonCallable, object),
|
||||
Object);
|
||||
}
|
||||
|
||||
@ -335,8 +336,8 @@ MaybeHandle<Object> Execution::TryGetConstructorDelegate(
|
||||
|
||||
// If the Object doesn't have an instance-call handler we should
|
||||
// throw a non-callable exception.
|
||||
THROW_NEW_ERROR(isolate, NewTypeError("called_non_callable",
|
||||
i::HandleVector<i::Object>(&object, 1)),
|
||||
THROW_NEW_ERROR(isolate,
|
||||
NewTypeError(MessageTemplate::kCalledNonCallable, object),
|
||||
Object);
|
||||
}
|
||||
|
||||
|
@ -1080,13 +1080,6 @@ Handle<Object> Factory::NewTypeError(const char* message,
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> Factory::NewTypeError(MessageTemplate::Template template_index,
|
||||
Handle<Object> arg0, Handle<Object> arg1,
|
||||
Handle<Object> arg2) {
|
||||
return NewError("MakeTypeError2", template_index, arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> Factory::NewTypeError(Handle<String> message) {
|
||||
return NewError("$TypeError", message);
|
||||
}
|
||||
@ -1184,9 +1177,24 @@ Handle<Object> Factory::NewEvalError(const char* message,
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> Factory::NewError(const char* message,
|
||||
Vector<Handle<Object> > args) {
|
||||
return NewError("MakeError", message, args);
|
||||
Handle<Object> Factory::NewError(MessageTemplate::Template template_index,
|
||||
Handle<Object> arg0, Handle<Object> arg1,
|
||||
Handle<Object> arg2) {
|
||||
return NewError("MakeError", template_index, arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> Factory::NewTypeError(MessageTemplate::Template template_index,
|
||||
Handle<Object> arg0, Handle<Object> arg1,
|
||||
Handle<Object> arg2) {
|
||||
return NewError("MakeTypeError", template_index, arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> Factory::NewEvalError(MessageTemplate::Template template_index,
|
||||
Handle<Object> arg0, Handle<Object> arg1,
|
||||
Handle<Object> arg2) {
|
||||
return NewError("MakeEvalError", template_index, arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
|
||||
|
@ -537,20 +537,12 @@ class Factory FINAL {
|
||||
Handle<Object> NewError(const char* maker, const char* message,
|
||||
Vector<Handle<Object> > args);
|
||||
Handle<Object> NewError(const char* message, Vector<Handle<Object> > args);
|
||||
Handle<Object> NewError(const char* maker,
|
||||
MessageTemplate::Template template_index,
|
||||
Handle<Object> arg0, Handle<Object> arg1,
|
||||
Handle<Object> arg2);
|
||||
|
||||
Handle<Object> NewError(Handle<String> message);
|
||||
Handle<Object> NewError(const char* constructor, Handle<String> message);
|
||||
|
||||
Handle<Object> NewTypeError(const char* message,
|
||||
Vector<Handle<Object> > args);
|
||||
Handle<Object> NewTypeError(MessageTemplate::Template template_index,
|
||||
Handle<Object> arg0 = Handle<Object>(),
|
||||
Handle<Object> arg1 = Handle<Object>(),
|
||||
Handle<Object> arg2 = Handle<Object>());
|
||||
Handle<Object> NewTypeError(Handle<String> message);
|
||||
|
||||
Handle<Object> NewRangeError(const char* message,
|
||||
@ -573,6 +565,26 @@ class Factory FINAL {
|
||||
Handle<Object> NewEvalError(const char* message,
|
||||
Vector<Handle<Object> > args);
|
||||
|
||||
Handle<Object> NewError(const char* maker,
|
||||
MessageTemplate::Template template_index,
|
||||
Handle<Object> arg0, Handle<Object> arg1,
|
||||
Handle<Object> arg2);
|
||||
|
||||
Handle<Object> NewError(MessageTemplate::Template template_index,
|
||||
Handle<Object> arg0 = Handle<Object>(),
|
||||
Handle<Object> arg1 = Handle<Object>(),
|
||||
Handle<Object> arg2 = Handle<Object>());
|
||||
|
||||
Handle<Object> NewTypeError(MessageTemplate::Template template_index,
|
||||
Handle<Object> arg0 = Handle<Object>(),
|
||||
Handle<Object> arg1 = Handle<Object>(),
|
||||
Handle<Object> arg2 = Handle<Object>());
|
||||
|
||||
Handle<Object> NewEvalError(MessageTemplate::Template template_index,
|
||||
Handle<Object> arg0 = Handle<Object>(),
|
||||
Handle<Object> arg1 = Handle<Object>(),
|
||||
Handle<Object> arg2 = Handle<Object>());
|
||||
|
||||
Handle<String> NumberToString(Handle<Object> number,
|
||||
bool check_number_string_cache = true);
|
||||
|
||||
|
@ -16,8 +16,8 @@
|
||||
|
||||
function GeneratorObjectNext(value) {
|
||||
if (!IS_GENERATOR(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['[Generator].prototype.next', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'[Generator].prototype.next', this);
|
||||
}
|
||||
|
||||
var continuation = %GeneratorGetContinuation(this);
|
||||
@ -35,14 +35,14 @@ function GeneratorObjectNext(value) {
|
||||
return { value: void 0, done: true };
|
||||
} else {
|
||||
// Generator is running.
|
||||
throw MakeTypeError('generator_running', []);
|
||||
throw MakeTypeError(kGeneratorRunning);
|
||||
}
|
||||
}
|
||||
|
||||
function GeneratorObjectThrow(exn) {
|
||||
if (!IS_GENERATOR(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['[Generator].prototype.throw', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'[Generator].prototype.throw', this);
|
||||
}
|
||||
|
||||
var continuation = %GeneratorGetContinuation(this);
|
||||
@ -59,7 +59,7 @@ function GeneratorObjectThrow(exn) {
|
||||
throw exn;
|
||||
} else {
|
||||
// Generator is running.
|
||||
throw MakeTypeError('generator_running', []);
|
||||
throw MakeTypeError(kGeneratorRunning);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ function ArrayFind(predicate /* thisArg */) { // length == 1
|
||||
var length = ToInteger(array.length);
|
||||
|
||||
if (!IS_SPEC_FUNCTION(predicate)) {
|
||||
throw MakeTypeError('called_non_callable', [predicate]);
|
||||
throw MakeTypeError(kCalledNonCallable, predicate);
|
||||
}
|
||||
|
||||
var thisArg;
|
||||
@ -55,7 +55,7 @@ function ArrayFindIndex(predicate /* thisArg */) { // length == 1
|
||||
var length = ToInteger(array.length);
|
||||
|
||||
if (!IS_SPEC_FUNCTION(predicate)) {
|
||||
throw MakeTypeError('called_non_callable', [predicate]);
|
||||
throw MakeTypeError(kCalledNonCallable, predicate);
|
||||
}
|
||||
|
||||
var thisArg;
|
||||
@ -134,7 +134,7 @@ function ArrayFrom(arrayLike, mapfn, receiver) {
|
||||
|
||||
if (mapping) {
|
||||
if (!IS_SPEC_FUNCTION(mapfn)) {
|
||||
throw MakeTypeError('called_non_callable', [ mapfn ]);
|
||||
throw MakeTypeError(kCalledNonCallable, mapfn);
|
||||
} else if (IS_NULL_OR_UNDEFINED(receiver)) {
|
||||
receiver = %GetDefaultReceiver(mapfn) || receiver;
|
||||
} else if (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(mapfn)) {
|
||||
|
@ -31,9 +31,7 @@ function NAMEForEach(f /* thisArg */) { // length == 1
|
||||
if (!%IsTypedArray(this)) {
|
||||
throw MakeTypeError('not_typed_array', []);
|
||||
}
|
||||
if (!IS_SPEC_FUNCTION(f)) {
|
||||
throw MakeTypeError('called_non_callable', [ f ]);
|
||||
}
|
||||
if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f);
|
||||
|
||||
var length = %_TypedArrayGetLength(this);
|
||||
var receiver;
|
||||
|
@ -89,8 +89,16 @@ class MessageHandler {
|
||||
|
||||
|
||||
#define MESSAGE_TEMPLATES(T) \
|
||||
/* Error */ \
|
||||
T(CyclicProto, "Cyclic __proto__ value") \
|
||||
/* TypeError */ \
|
||||
T(CalledNonCallable, "% is not a function") \
|
||||
T(GeneratorRunning, "Generator is already running") \
|
||||
T(IncompatibleMethodReceiver, "Method % called on incompatible receiver %") \
|
||||
T(PropertyNotFunction, "Property '%' of object % is not a function") \
|
||||
T(WithExpression, "% has no properties")
|
||||
T(WithExpression, "% has no properties") \
|
||||
/* EvalError */ \
|
||||
T(CodeGenFromStrings, "%")
|
||||
|
||||
class MessageTemplate {
|
||||
public:
|
||||
|
@ -6,12 +6,9 @@
|
||||
|
||||
var kMessages = {
|
||||
// Error
|
||||
cyclic_proto: ["Cyclic __proto__ value"],
|
||||
code_gen_from_strings: ["%0"],
|
||||
constructor_is_generator: ["Class constructor may not be a generator"],
|
||||
constructor_is_accessor: ["Class constructor may not be an accessor"],
|
||||
// TypeError
|
||||
generator_running: ["Generator is already running"],
|
||||
unexpected_token: ["Unexpected token ", "%0"],
|
||||
unexpected_token_number: ["Unexpected number"],
|
||||
unexpected_token_string: ["Unexpected string"],
|
||||
@ -27,7 +24,6 @@ var kMessages = {
|
||||
unterminated_template_expr: ["Missing } in template expression"],
|
||||
unterminated_arg_list: ["missing ) after argument list"],
|
||||
regexp_flags: ["Cannot supply flags when constructing one RegExp from another"],
|
||||
incompatible_method_receiver: ["Method ", "%0", " called on incompatible receiver ", "%1"],
|
||||
multiple_defaults_in_switch: ["More than one default clause in switch statement"],
|
||||
newline_after_throw: ["Illegal newline after throw"],
|
||||
label_redeclaration: ["Label '", "%0", "' has already been declared"],
|
||||
@ -36,8 +32,6 @@ var kMessages = {
|
||||
no_catch_or_finally: ["Missing catch or finally after try"],
|
||||
unknown_label: ["Undefined label '", "%0", "'"],
|
||||
uncaught_exception: ["Uncaught ", "%0"],
|
||||
stack_trace: ["Stack Trace:\n", "%0"],
|
||||
called_non_callable: ["%0", " is not a function"],
|
||||
undefined_method: ["Object ", "%1", " has no method '", "%0", "'"],
|
||||
cannot_convert_to_primitive: ["Cannot convert object to primitive value"],
|
||||
not_constructor: ["%0", " is not a constructor"],
|
||||
@ -318,13 +312,8 @@ function ToDetailString(obj) {
|
||||
}
|
||||
|
||||
|
||||
function MakeGenericError(constructor, type, args) {
|
||||
if (IS_UNDEFINED(args)) args = [];
|
||||
return new constructor(FormatMessage(type, args));
|
||||
}
|
||||
|
||||
|
||||
function MakeGenericError2(constructor, type, arg0, arg1, arg2) {
|
||||
function MakeGenericError(constructor, type, arg0, arg1, arg2) {
|
||||
if (IS_UNDEFINED(arg0) && IS_STRING(type)) arg0 = [];
|
||||
return new constructor(FormatMessage(type, arg0, arg1, arg2));
|
||||
}
|
||||
|
||||
@ -381,42 +370,35 @@ function GetSourceLine(message) {
|
||||
}
|
||||
|
||||
|
||||
function MakeTypeError(type, args) {
|
||||
return MakeGenericError($TypeError, type, args);
|
||||
function MakeError(type, arg0, arg1, arg2) {
|
||||
return MakeGenericError($Error, type, arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
|
||||
// TODO(yangguo): rename this once we migrated all messages.
|
||||
function MakeTypeError2(type, arg0, arg1, arg2) {
|
||||
return MakeGenericError2($TypeError, type, arg0, arg1, arg2);
|
||||
function MakeTypeError(type, arg0, arg1, arg2) {
|
||||
return MakeGenericError($TypeError, type, arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
|
||||
function MakeRangeError(type, args) {
|
||||
return MakeGenericError($RangeError, type, args);
|
||||
function MakeRangeError(type, arg0, arg1, arg2) {
|
||||
return MakeGenericError($RangeError, type, arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
|
||||
function MakeSyntaxError(type, args) {
|
||||
return MakeGenericError($SyntaxError, type, args);
|
||||
function MakeSyntaxError(type, arg0, arg1, arg2) {
|
||||
return MakeGenericError($SyntaxError, type, arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
|
||||
function MakeReferenceError(type, args) {
|
||||
return MakeGenericError($ReferenceError, type, args);
|
||||
function MakeReferenceError(type, arg0, arg1, arg2) {
|
||||
return MakeGenericError($ReferenceError, type, arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
|
||||
function MakeEvalError(type, args) {
|
||||
return MakeGenericError($EvalError, type, args);
|
||||
function MakeEvalError(type, arg0, arg1, arg2) {
|
||||
return MakeGenericError($EvalError, type, arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
|
||||
function MakeError(type, args) {
|
||||
return MakeGenericError($Error, type, args);
|
||||
}
|
||||
|
||||
|
||||
// The embedded versions are called from unoptimized code, with embedded
|
||||
// arguments. Those arguments cannot be arrays, which are context-dependent.
|
||||
function MakeTypeErrorEmbedded(type, arg) {
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "src/log.h"
|
||||
#include "src/lookup.h"
|
||||
#include "src/macro-assembler.h"
|
||||
#include "src/messages.h"
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/prototype.h"
|
||||
#include "src/safepoint-table.h"
|
||||
@ -297,10 +298,9 @@ MaybeHandle<Object> Object::GetPropertyWithAccessor(Handle<Object> receiver,
|
||||
if (structure->IsAccessorInfo()) {
|
||||
Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(structure);
|
||||
if (!info->IsCompatibleReceiver(*receiver)) {
|
||||
Handle<Object> args[] = {name, receiver};
|
||||
THROW_NEW_ERROR(isolate,
|
||||
NewTypeError("incompatible_method_receiver",
|
||||
HandleVector(args, arraysize(args))),
|
||||
NewTypeError(MessageTemplate::kIncompatibleMethodReceiver,
|
||||
name, receiver),
|
||||
Object);
|
||||
}
|
||||
|
||||
@ -362,10 +362,9 @@ MaybeHandle<Object> Object::SetPropertyWithAccessor(
|
||||
// api style callbacks
|
||||
ExecutableAccessorInfo* info = ExecutableAccessorInfo::cast(*structure);
|
||||
if (!info->IsCompatibleReceiver(*receiver)) {
|
||||
Handle<Object> args[] = {name, receiver};
|
||||
THROW_NEW_ERROR(isolate,
|
||||
NewTypeError("incompatible_method_receiver",
|
||||
HandleVector(args, arraysize(args))),
|
||||
NewTypeError(MessageTemplate::kIncompatibleMethodReceiver,
|
||||
name, receiver),
|
||||
Object);
|
||||
}
|
||||
Object* call_obj = info->setter();
|
||||
@ -12489,9 +12488,7 @@ MaybeHandle<Object> JSObject::SetPrototype(Handle<JSObject> object,
|
||||
!iter.IsAtEnd(); iter.Advance()) {
|
||||
if (JSReceiver::cast(iter.GetCurrent()) == *object) {
|
||||
// Cycle detected.
|
||||
THROW_NEW_ERROR(isolate,
|
||||
NewError("cyclic_proto", HandleVector<Object>(NULL, 0)),
|
||||
Object);
|
||||
THROW_NEW_ERROR(isolate, NewError(MessageTemplate::kCyclicProto), Object);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,8 +88,8 @@ function RegExpCompileJS(pattern, flags) {
|
||||
// behavior.
|
||||
if (this == GlobalRegExp.prototype) {
|
||||
// We don't allow recompiling RegExp.prototype.
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['RegExp.prototype.compile', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'RegExp.prototype.compile', this);
|
||||
}
|
||||
if (IS_UNDEFINED(pattern) && %_ArgumentsLength() != 0) {
|
||||
DoConstructRegExp(this, 'undefined', flags);
|
||||
@ -146,8 +146,8 @@ function RegExpExecNoTests(regexp, string, start) {
|
||||
|
||||
function RegExpExecJS(string) {
|
||||
if (!IS_REGEXP(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['RegExp.prototype.exec', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'RegExp.prototype.exec', this);
|
||||
}
|
||||
|
||||
string = TO_STRING_INLINE(string);
|
||||
@ -194,8 +194,8 @@ var regexp_val;
|
||||
// else implements.
|
||||
function RegExpTest(string) {
|
||||
if (!IS_REGEXP(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['RegExp.prototype.test', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'RegExp.prototype.test', this);
|
||||
}
|
||||
string = TO_STRING_INLINE(string);
|
||||
|
||||
@ -256,8 +256,8 @@ function TrimRegExp(regexp) {
|
||||
|
||||
function RegExpToString() {
|
||||
if (!IS_REGEXP(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['RegExp.prototype.toString', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'RegExp.prototype.toString', this);
|
||||
}
|
||||
var result = '/' + this.source + '/';
|
||||
if (this.global) result += 'g';
|
||||
|
@ -379,7 +379,7 @@ function CALL_NON_FUNCTION() {
|
||||
if (!IS_FUNCTION(delegate)) {
|
||||
var callsite = %RenderCallSite();
|
||||
if (callsite == "") callsite = typeof this;
|
||||
throw %MakeTypeError('called_non_callable', [callsite]);
|
||||
throw %MakeTypeError(kCalledNonCallable, callsite);
|
||||
}
|
||||
return %Apply(delegate, this, arguments, 0, %_ArgumentsLength());
|
||||
}
|
||||
@ -390,7 +390,7 @@ function CALL_NON_FUNCTION_AS_CONSTRUCTOR() {
|
||||
if (!IS_FUNCTION(delegate)) {
|
||||
var callsite = %RenderCallSite();
|
||||
if (callsite == "") callsite = typeof this;
|
||||
throw %MakeTypeError('called_non_callable', [callsite]);
|
||||
throw %MakeTypeError(kCalledNonCallable, callsite);
|
||||
}
|
||||
return %Apply(delegate, this, arguments, 0, %_ArgumentsLength());
|
||||
}
|
||||
@ -463,7 +463,7 @@ function REFLECT_APPLY_PREPARE(args) {
|
||||
}
|
||||
|
||||
if (!IS_SPEC_FUNCTION(this)) {
|
||||
throw %MakeTypeError('called_non_callable', [ %ToString(this) ]);
|
||||
throw %MakeTypeError(kCalledNonCallable, %ToString(this));
|
||||
}
|
||||
|
||||
if (!IS_SPEC_OBJECT(args)) {
|
||||
@ -503,7 +503,7 @@ function REFLECT_CONSTRUCT_PREPARE(args, newTarget) {
|
||||
|
||||
if (!ctorOk) {
|
||||
if (!IS_SPEC_FUNCTION(this)) {
|
||||
throw %MakeTypeError('called_non_callable', [ %ToString(this) ]);
|
||||
throw %MakeTypeError(kCalledNonCallable, %ToString(this));
|
||||
} else {
|
||||
throw %MakeTypeError('not_constructor', [ %ToString(this) ]);
|
||||
}
|
||||
@ -511,7 +511,7 @@ function REFLECT_CONSTRUCT_PREPARE(args, newTarget) {
|
||||
|
||||
if (!newTargetOk) {
|
||||
if (!IS_SPEC_FUNCTION(newTarget)) {
|
||||
throw %MakeTypeError('called_non_callable', [ %ToString(newTarget) ]);
|
||||
throw %MakeTypeError(kCalledNonCallable, %ToString(newTarget));
|
||||
} else {
|
||||
throw %MakeTypeError('not_constructor', [ %ToString(newTarget) ]);
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "src/frames.h"
|
||||
#include "src/full-codegen.h"
|
||||
#include "src/isolate-inl.h"
|
||||
#include "src/messages.h"
|
||||
#include "src/runtime/runtime-utils.h"
|
||||
#include "src/v8threads.h"
|
||||
#include "src/vm-state-inl.h"
|
||||
@ -364,8 +365,8 @@ RUNTIME_FUNCTION(Runtime_CompileString) {
|
||||
Handle<Object> error_message =
|
||||
context->ErrorMessageForCodeGenerationFromStrings();
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(
|
||||
isolate, NewEvalError("code_gen_from_strings",
|
||||
HandleVector<Object>(&error_message, 1)));
|
||||
isolate,
|
||||
NewEvalError(MessageTemplate::kCodeGenFromStrings, error_message));
|
||||
}
|
||||
|
||||
// Compile source string in the native context.
|
||||
@ -398,7 +399,7 @@ static ObjectPair CompileGlobalEval(Isolate* isolate, Handle<String> source,
|
||||
native_context->ErrorMessageForCodeGenerationFromStrings();
|
||||
Handle<Object> error;
|
||||
MaybeHandle<Object> maybe_error = isolate->factory()->NewEvalError(
|
||||
"code_gen_from_strings", HandleVector<Object>(&error_message, 1));
|
||||
MessageTemplate::kCodeGenFromStrings, error_message);
|
||||
if (maybe_error.ToHandle(&error)) isolate->Throw(*error);
|
||||
return MakePair(isolate->heap()->exception(), NULL);
|
||||
}
|
||||
|
@ -42,8 +42,8 @@ function StringIteratorNext() {
|
||||
var iterator = ToObject(this);
|
||||
|
||||
if (!HAS_DEFINED_PRIVATE(iterator, stringIteratorNextIndexSymbol)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['String Iterator.prototype.next']);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'String Iterator.prototype.next');
|
||||
}
|
||||
|
||||
var s = GET_PRIVATE(iterator, stringIteratorIteratedStringSymbol);
|
||||
|
@ -34,8 +34,8 @@ function SymbolConstructor(x) {
|
||||
|
||||
function SymbolToString() {
|
||||
if (!(IS_SYMBOL(this) || IS_SYMBOL_WRAPPER(this))) {
|
||||
throw MakeTypeError(
|
||||
'incompatible_method_receiver', ["Symbol.prototype.toString", this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
"Symbol.prototype.toString", this);
|
||||
}
|
||||
var description = %SymbolDescription(%_ValueOf(this));
|
||||
return "Symbol(" + (IS_UNDEFINED(description) ? "" : description) + ")";
|
||||
@ -44,8 +44,8 @@ function SymbolToString() {
|
||||
|
||||
function SymbolValueOf() {
|
||||
if (!(IS_SYMBOL(this) || IS_SYMBOL_WRAPPER(this))) {
|
||||
throw MakeTypeError(
|
||||
'incompatible_method_receiver', ["Symbol.prototype.valueOf", this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
"Symbol.prototype.valueOf", this);
|
||||
}
|
||||
return %_ValueOf(this);
|
||||
}
|
||||
|
@ -119,32 +119,28 @@ function NAMEConstructor(arg1, arg2, arg3) {
|
||||
|
||||
function NAME_GetBuffer() {
|
||||
if (!(%_ClassOf(this) === 'NAME')) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
["NAME.buffer", this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver, "NAME.buffer", this);
|
||||
}
|
||||
return %TypedArrayGetBuffer(this);
|
||||
}
|
||||
|
||||
function NAME_GetByteLength() {
|
||||
if (!(%_ClassOf(this) === 'NAME')) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
["NAME.byteLength", this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver, "NAME.byteLength", this);
|
||||
}
|
||||
return %_ArrayBufferViewGetByteLength(this);
|
||||
}
|
||||
|
||||
function NAME_GetByteOffset() {
|
||||
if (!(%_ClassOf(this) === 'NAME')) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
["NAME.byteOffset", this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver, "NAME.byteOffset", this);
|
||||
}
|
||||
return %_ArrayBufferViewGetByteOffset(this);
|
||||
}
|
||||
|
||||
function NAME_GetLength() {
|
||||
if (!(%_ClassOf(this) === 'NAME')) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
["NAME.length", this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver, "NAME.length", this);
|
||||
}
|
||||
return %_TypedArrayGetLength(this);
|
||||
}
|
||||
@ -153,8 +149,7 @@ var $NAME = global.NAME;
|
||||
|
||||
function NAMESubArray(begin, end) {
|
||||
if (!(%_ClassOf(this) === 'NAME')) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
["NAME.subarray", this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver, "NAME.subarray", this);
|
||||
}
|
||||
var beginInt = TO_INTEGER(begin);
|
||||
if (!IS_UNDEFINED(end)) {
|
||||
@ -366,24 +361,23 @@ function DataViewConstructor(buffer, byteOffset, byteLength) { // length = 3
|
||||
|
||||
function DataViewGetBufferJS() {
|
||||
if (!IS_DATAVIEW(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['DataView.buffer', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver, 'DataView.buffer', this);
|
||||
}
|
||||
return %DataViewGetBuffer(this);
|
||||
}
|
||||
|
||||
function DataViewGetByteOffset() {
|
||||
if (!IS_DATAVIEW(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['DataView.byteOffset', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'DataView.byteOffset', this);
|
||||
}
|
||||
return %_ArrayBufferViewGetByteOffset(this);
|
||||
}
|
||||
|
||||
function DataViewGetByteLength() {
|
||||
if (!IS_DATAVIEW(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['DataView.byteLength', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'DataView.byteLength', this);
|
||||
}
|
||||
return %_ArrayBufferViewGetByteLength(this);
|
||||
}
|
||||
@ -407,8 +401,8 @@ function ToPositiveDataViewOffset(offset) {
|
||||
macro DATA_VIEW_GETTER_SETTER(TYPENAME)
|
||||
function DataViewGetTYPENAMEJS(offset, little_endian) {
|
||||
if (!IS_DATAVIEW(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['DataView.getTYPENAME', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'DataView.getTYPENAME', this);
|
||||
}
|
||||
if (%_ArgumentsLength() < 1) {
|
||||
throw MakeTypeError('invalid_argument');
|
||||
@ -420,8 +414,8 @@ function DataViewGetTYPENAMEJS(offset, little_endian) {
|
||||
|
||||
function DataViewSetTYPENAMEJS(offset, value, little_endian) {
|
||||
if (!IS_DATAVIEW(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['DataView.setTYPENAME', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'DataView.setTYPENAME', this);
|
||||
}
|
||||
if (%_ArgumentsLength() < 2) {
|
||||
throw MakeTypeError('invalid_argument');
|
||||
|
@ -691,7 +691,7 @@ function GetMethod(obj, p) {
|
||||
var func = obj[p];
|
||||
if (IS_NULL_OR_UNDEFINED(func)) return UNDEFINED;
|
||||
if (IS_SPEC_FUNCTION(func)) return func;
|
||||
throw MakeTypeError('called_non_callable', [typeof func]);
|
||||
throw MakeTypeError(kCalledNonCallable, typeof func);
|
||||
}
|
||||
|
||||
|
||||
@ -1587,8 +1587,8 @@ function NumberToFixedJS(fractionDigits) {
|
||||
var x = this;
|
||||
if (!IS_NUMBER(this)) {
|
||||
if (!IS_NUMBER_WRAPPER(this)) {
|
||||
throw MakeTypeError("incompatible_method_receiver",
|
||||
["Number.prototype.toFixed", this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
"Number.prototype.toFixed", this);
|
||||
}
|
||||
// Get the value of this number in case it's an object.
|
||||
x = %_ValueOf(this);
|
||||
@ -1612,8 +1612,8 @@ function NumberToExponentialJS(fractionDigits) {
|
||||
var x = this;
|
||||
if (!IS_NUMBER(this)) {
|
||||
if (!IS_NUMBER_WRAPPER(this)) {
|
||||
throw MakeTypeError("incompatible_method_receiver",
|
||||
["Number.prototype.toExponential", this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
"Number.prototype.toExponential", this);
|
||||
}
|
||||
// Get the value of this number in case it's an object.
|
||||
x = %_ValueOf(this);
|
||||
@ -1638,8 +1638,8 @@ function NumberToPrecisionJS(precision) {
|
||||
var x = this;
|
||||
if (!IS_NUMBER(this)) {
|
||||
if (!IS_NUMBER_WRAPPER(this)) {
|
||||
throw MakeTypeError("incompatible_method_receiver",
|
||||
["Number.prototype.toPrecision", this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
"Number.prototype.toPrecision", this);
|
||||
}
|
||||
// Get the value of this number in case it's an object.
|
||||
x = %_ValueOf(this);
|
||||
|
@ -25,7 +25,7 @@ function WeakMapConstructor(iterable) {
|
||||
if (!IS_NULL_OR_UNDEFINED(iterable)) {
|
||||
var adder = this.set;
|
||||
if (!IS_SPEC_FUNCTION(adder)) {
|
||||
throw MakeTypeError(kPropertyNotFunction, ['set', this]);
|
||||
throw MakeTypeError(kPropertyNotFunction, 'set', this);
|
||||
}
|
||||
for (var nextItem of iterable) {
|
||||
if (!IS_SPEC_OBJECT(nextItem)) {
|
||||
@ -39,8 +39,8 @@ function WeakMapConstructor(iterable) {
|
||||
|
||||
function WeakMapGet(key) {
|
||||
if (!IS_WEAKMAP(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['WeakMap.prototype.get', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'WeakMap.prototype.get', this);
|
||||
}
|
||||
if (!IS_SPEC_OBJECT(key)) return UNDEFINED;
|
||||
return %WeakCollectionGet(this, key);
|
||||
@ -49,8 +49,8 @@ function WeakMapGet(key) {
|
||||
|
||||
function WeakMapSet(key, value) {
|
||||
if (!IS_WEAKMAP(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['WeakMap.prototype.set', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'WeakMap.prototype.set', this);
|
||||
}
|
||||
if (!IS_SPEC_OBJECT(key)) {
|
||||
throw %MakeTypeError('invalid_weakmap_key', [this, key]);
|
||||
@ -61,8 +61,8 @@ function WeakMapSet(key, value) {
|
||||
|
||||
function WeakMapHas(key) {
|
||||
if (!IS_WEAKMAP(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['WeakMap.prototype.has', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'WeakMap.prototype.has', this);
|
||||
}
|
||||
if (!IS_SPEC_OBJECT(key)) return false;
|
||||
return %WeakCollectionHas(this, key);
|
||||
@ -71,8 +71,8 @@ function WeakMapHas(key) {
|
||||
|
||||
function WeakMapDelete(key) {
|
||||
if (!IS_WEAKMAP(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['WeakMap.prototype.delete', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'WeakMap.prototype.delete', this);
|
||||
}
|
||||
if (!IS_SPEC_OBJECT(key)) return false;
|
||||
return %WeakCollectionDelete(this, key);
|
||||
@ -110,7 +110,7 @@ function WeakSetConstructor(iterable) {
|
||||
if (!IS_NULL_OR_UNDEFINED(iterable)) {
|
||||
var adder = this.add;
|
||||
if (!IS_SPEC_FUNCTION(adder)) {
|
||||
throw MakeTypeError(kPropertyNotFunction, ['add', this]);
|
||||
throw MakeTypeError(kPropertyNotFunction, 'add', this);
|
||||
}
|
||||
for (var value of iterable) {
|
||||
%_CallFunction(this, value, adder);
|
||||
@ -121,8 +121,8 @@ function WeakSetConstructor(iterable) {
|
||||
|
||||
function WeakSetAdd(value) {
|
||||
if (!IS_WEAKSET(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['WeakSet.prototype.add', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'WeakSet.prototype.add', this);
|
||||
}
|
||||
if (!IS_SPEC_OBJECT(value)) {
|
||||
throw %MakeTypeError('invalid_weakset_value', [this, value]);
|
||||
@ -133,8 +133,8 @@ function WeakSetAdd(value) {
|
||||
|
||||
function WeakSetHas(value) {
|
||||
if (!IS_WEAKSET(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['WeakSet.prototype.has', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'WeakSet.prototype.has', this);
|
||||
}
|
||||
if (!IS_SPEC_OBJECT(value)) return false;
|
||||
return %WeakCollectionHas(this, value);
|
||||
@ -143,8 +143,8 @@ function WeakSetHas(value) {
|
||||
|
||||
function WeakSetDelete(value) {
|
||||
if (!IS_WEAKSET(this)) {
|
||||
throw MakeTypeError('incompatible_method_receiver',
|
||||
['WeakSet.prototype.delete', this]);
|
||||
throw MakeTypeError(kIncompatibleMethodReceiver,
|
||||
'WeakSet.prototype.delete', this);
|
||||
}
|
||||
if (!IS_SPEC_OBJECT(value)) return false;
|
||||
return %WeakCollectionDelete(this, value);
|
||||
|
54
test/mjsunit/messages.js
Normal file
54
test/mjsunit/messages.js
Normal file
@ -0,0 +1,54 @@
|
||||
// Copyright 2015 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
function test(f, expected, type) {
|
||||
try {
|
||||
f();
|
||||
assertUnreachable();
|
||||
} catch (e) {
|
||||
assertInstanceof(e, type);
|
||||
assertEquals(expected, e.message);
|
||||
}
|
||||
}
|
||||
|
||||
// === Error ===
|
||||
|
||||
// kCyclicProto
|
||||
test(function() {
|
||||
var o = {};
|
||||
o.__proto__ = o;
|
||||
}, "Cyclic __proto__ value", Error);
|
||||
|
||||
|
||||
// === TypeError ===
|
||||
|
||||
// kGeneratorRunning
|
||||
test(function() {
|
||||
var iter;
|
||||
function* generator() { yield iter.next(); }
|
||||
var iter = generator();
|
||||
iter.next();
|
||||
}, "Generator is already running", TypeError);
|
||||
|
||||
// kCalledNonCallable
|
||||
test(function() {
|
||||
[].forEach(1);
|
||||
}, "1 is not a function", TypeError);
|
||||
|
||||
// kIncompatibleMethodReceiver
|
||||
test(function() {
|
||||
RegExp.prototype.compile.call(RegExp.prototype);
|
||||
}, "Method RegExp.prototype.compile called on incompatible receiver " +
|
||||
"[object RegExp]", TypeError);
|
||||
|
||||
// kPropertyNotFunction
|
||||
test(function() {
|
||||
Set.prototype.add = 0;
|
||||
new Set(1);
|
||||
}, "Property 'add' of object #<Set> is not a function", TypeError);
|
||||
|
||||
// kWithExpression
|
||||
test(function() {
|
||||
with (null) {}
|
||||
}, "null has no properties", TypeError);
|
Loading…
Reference in New Issue
Block a user