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

Migrate error messages, part 9.

R=mvstanton@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#28291}
parent eaf0a6b1
......@@ -1444,7 +1444,7 @@ static void ModuleGetExport(
Handle<String> name = v8::Utils::OpenHandle(*property);
Handle<Object> exception = isolate->factory()->NewReferenceError(
"not_defined", HandleVector(&name, 1));
MessageTemplate::kNotDefined, name);
isolate->ScheduleThrow(*exception);
return;
}
......@@ -1465,7 +1465,7 @@ static void ModuleSetExport(
if (old_value->IsTheHole()) {
Handle<String> name = v8::Utils::OpenHandle(*property);
Handle<Object> exception = isolate->factory()->NewReferenceError(
"not_defined", HandleVector(&name, 1));
MessageTemplate::kNotDefined, name);
isolate->ScheduleThrow(*exception);
return;
}
......
......@@ -1109,12 +1109,6 @@ Handle<Object> Factory::NewSyntaxError(Handle<String> message) {
}
Handle<Object> Factory::NewReferenceError(const char* message,
Vector<Handle<Object> > args) {
return NewError("MakeReferenceError", message, args);
}
Handle<Object> Factory::NewReferenceError(const char* message,
Handle<JSArray> args) {
return NewError("MakeReferenceError", message, args);
......@@ -1173,12 +1167,6 @@ Handle<Object> Factory::NewError(const char* maker,
}
Handle<Object> Factory::NewEvalError(const char* message,
Vector<Handle<Object> > args) {
return NewError("MakeEvalError", message, args);
}
Handle<Object> Factory::NewError(MessageTemplate::Template template_index,
Handle<Object> arg0, Handle<Object> arg1,
Handle<Object> arg2) {
......@@ -1193,6 +1181,13 @@ Handle<Object> Factory::NewTypeError(MessageTemplate::Template template_index,
}
Handle<Object> Factory::NewReferenceError(
MessageTemplate::Template template_index, Handle<Object> arg0,
Handle<Object> arg1, Handle<Object> arg2) {
return NewError("MakeReferenceError", template_index, arg0, arg1, arg2);
}
Handle<Object> Factory::NewRangeError(MessageTemplate::Template template_index,
Handle<Object> arg0, Handle<Object> arg1,
Handle<Object> arg2) {
......
......@@ -562,14 +562,9 @@ class Factory final {
Handle<Object> NewSyntaxError(const char* message, Handle<JSArray> args);
Handle<Object> NewSyntaxError(Handle<String> message);
Handle<Object> NewReferenceError(const char* message,
Vector<Handle<Object> > args);
Handle<Object> NewReferenceError(const char* message, Handle<JSArray> args);
Handle<Object> NewReferenceError(Handle<String> message);
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,
......@@ -585,6 +580,11 @@ class Factory final {
Handle<Object> arg1 = Handle<Object>(),
Handle<Object> arg2 = Handle<Object>());
Handle<Object> NewReferenceError(MessageTemplate::Template template_index,
Handle<Object> arg0 = Handle<Object>(),
Handle<Object> arg1 = Handle<Object>(),
Handle<Object> arg2 = Handle<Object>());
Handle<Object> NewRangeError(MessageTemplate::Template template_index,
Handle<Object> arg0 = Handle<Object>(),
Handle<Object> arg1 = Handle<Object>(),
......
......@@ -16,6 +16,7 @@
#include "src/ic/ic-inl.h"
#include "src/ic/ic-compiler.h"
#include "src/ic/stub-cache.h"
#include "src/messages.h"
#include "src/prototype.h"
#include "src/runtime/runtime.h"
......@@ -369,10 +370,10 @@ MaybeHandle<Object> IC::TypeError(const char* type, Handle<Object> object,
}
MaybeHandle<Object> IC::ReferenceError(const char* type, Handle<Name> name) {
MaybeHandle<Object> IC::ReferenceError(Handle<Name> name) {
HandleScope scope(isolate());
THROW_NEW_ERROR(isolate(), NewReferenceError(type, HandleVector(&name, 1)),
Object);
THROW_NEW_ERROR(
isolate(), NewReferenceError(MessageTemplate::kNotDefined, name), Object);
}
......@@ -737,7 +738,7 @@ MaybeHandle<Object> LoadIC::Load(Handle<Object> object, Handle<Name> name) {
if (*result == *isolate()->factory()->the_hole_value()) {
// Do not install stubs and stay pre-monomorphic for
// uninitialized accesses.
return ReferenceError("not_defined", name);
return ReferenceError(name);
}
if (use_ic && LoadScriptContextFieldStub::Accepted(&lookup_result)) {
......@@ -767,7 +768,7 @@ MaybeHandle<Object> LoadIC::Load(Handle<Object> object, Handle<Name> name) {
return result;
}
}
return ReferenceError("not_defined", name);
return ReferenceError(name);
}
......@@ -1566,7 +1567,7 @@ MaybeHandle<Object> StoreIC::Store(Handle<Object> object, Handle<Name> name,
if (*previous_value == *isolate()->factory()->the_hole_value()) {
// Do not install stubs and stay pre-monomorphic for
// uninitialized accesses.
return ReferenceError("not_defined", name);
return ReferenceError(name);
}
if (FLAG_use_ic &&
......@@ -2937,7 +2938,7 @@ static Object* ThrowReferenceError(Isolate* isolate, Name* name) {
// Throw a reference error.
Handle<Name> name_handle(name);
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewReferenceError("not_defined", HandleVector(&name_handle, 1)));
isolate, NewReferenceError(MessageTemplate::kNotDefined, name_handle));
}
......
......@@ -164,7 +164,7 @@ class IC {
MaybeHandle<Object> TypeError(const char* type, Handle<Object> object,
Handle<Object> key);
MaybeHandle<Object> ReferenceError(const char* type, Handle<Name> name);
MaybeHandle<Object> ReferenceError(Handle<Name> name);
// Access the target code for the given IC address.
static inline Code* GetTargetAtAddress(Address address,
......
......@@ -126,10 +126,13 @@ class CallSite {
"function") \
T(ArrayFunctionsOnFrozen, "Cannot modify frozen array elements") \
T(ArrayFunctionsOnSealed, "Cannot add/remove sealed array elements") \
T(ArrayNotSubclassable, "Subclassing Arrays is not currently supported.") \
T(CalledNonCallable, "% is not a function") \
T(CalledOnNonObject, "% called on non-object") \
T(CalledOnNullOrUndefined, "% called on null or undefined") \
T(CannotConvertToPrimitive, "Cannot convert object to primitive value") \
T(ConstructorNonCallable, \
"Class constructors cannot be invoked without 'new'") \
T(ConstructorNotFunction, "Constructor % requires 'new'") \
T(CurrencyCode, "Currency code is required with currency style.") \
T(DataViewNotArrayBuffer, \
......@@ -217,6 +220,10 @@ class CallSite {
"writable or have a value, %") \
T(WithExpression, "% has no properties") \
T(WrongArgs, "%: Arguments list has wrong type") \
/* ReferenceError */ \
T(NonMethod, "'super' is referenced from non-method") \
T(NotDefined, "% is not defined") \
T(UnsupportedSuper, "Unsupported reference to 'super'") \
/* RangeError */ \
T(ArrayLengthOutOfRange, "defineProperty() array length out of range") \
T(DateRange, "Provided date is not in valid range.") \
......
......@@ -75,9 +75,6 @@ var kMessages = {
unknown_label: ["Undefined label '", "%0", "'"],
uncaught_exception: ["Uncaught ", "%0"],
undefined_method: ["Object ", "%1", " has no method '", "%0", "'"],
not_defined: ["%0", " is not defined"],
non_method: ["'super' is referenced from non-method"],
unsupported_super: ["Unsupported reference to 'super'"],
non_object_property_load: ["Cannot read property '", "%0", "' of ", "%1"],
non_object_property_store: ["Cannot set property '", "%0", "' of ", "%1"],
illegal_invocation: ["Illegal invocation"],
......@@ -159,9 +156,7 @@ var kMessages = {
super_constructor_call: ["A 'super' constructor call may only appear as the first statement of a function, and its arguments may not access 'this'. Other forms are not yet supported."],
duplicate_proto: ["Duplicate __proto__ fields are not allowed in object literals"],
param_after_rest: ["Rest parameter must be last formal parameter"],
constructor_noncallable: ["Class constructors cannot be invoked without 'new'"],
derived_constructor_return: ["Derived constructors may only return object or undefined"],
array_not_subclassable: ["Subclassing Arrays is not currently supported."],
for_in_loop_initializer: ["for-in loop variable declaration may not have an initializer."],
for_of_loop_initializer: ["for-of loop variable declaration may not have an initializer."],
for_inof_loop_multi_bindings: ["Invalid left-hand side in ", "%0", " loop: Must have a single binding."],
......
......@@ -3228,11 +3228,9 @@ MaybeHandle<Object> Object::SetPropertyInternal(LookupIterator* it,
// the property did not exist yet on the global object itself, we have to
// throw a reference error in strict mode.
if (it->GetReceiver()->IsJSGlobalObject() && is_strict(language_mode)) {
Handle<Object> args[] = {it->name()};
THROW_NEW_ERROR(
it->isolate(),
NewReferenceError("not_defined", HandleVector(args, arraysize(args))),
Object);
THROW_NEW_ERROR(it->isolate(),
NewReferenceError(MessageTemplate::kNotDefined, it->name()),
Object);
}
*found = false;
......
......@@ -9,6 +9,7 @@
#include "src/arguments.h"
#include "src/debug.h"
#include "src/messages.h"
#include "src/runtime/runtime.h"
#include "src/runtime/runtime-utils.h"
......@@ -21,21 +22,15 @@ RUNTIME_FUNCTION(Runtime_ThrowNonMethodError) {
HandleScope scope(isolate);
DCHECK(args.length() == 0);
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewReferenceError("non_method", HandleVector<Object>(NULL, 0)));
}
static Object* ThrowUnsupportedSuper(Isolate* isolate) {
THROW_NEW_ERROR_RETURN_FAILURE(
isolate,
NewReferenceError("unsupported_super", HandleVector<Object>(NULL, 0)));
isolate, NewReferenceError(MessageTemplate::kNonMethod));
}
RUNTIME_FUNCTION(Runtime_ThrowUnsupportedSuperError) {
HandleScope scope(isolate);
DCHECK(args.length() == 0);
return ThrowUnsupportedSuper(isolate);
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewReferenceError(MessageTemplate::kUnsupportedSuper));
}
......@@ -43,8 +38,7 @@ RUNTIME_FUNCTION(Runtime_ThrowConstructorNonCallableError) {
HandleScope scope(isolate);
DCHECK(args.length() == 0);
THROW_NEW_ERROR_RETURN_FAILURE(
isolate,
NewTypeError("constructor_noncallable", HandleVector<Object>(NULL, 0)));
isolate, NewTypeError(MessageTemplate::kConstructorNonCallable));
}
......@@ -52,8 +46,7 @@ RUNTIME_FUNCTION(Runtime_ThrowArrayNotSubclassableError) {
HandleScope scope(isolate);
DCHECK(args.length() == 0);
THROW_NEW_ERROR_RETURN_FAILURE(
isolate,
NewTypeError("array_not_subclassable", HandleVector<Object>(NULL, 0)));
isolate, NewTypeError(MessageTemplate::kArrayNotSubclassable));
}
......
......@@ -56,7 +56,7 @@ RUNTIME_FUNCTION(Runtime_ThrowReferenceError) {
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(Object, name, 0);
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewReferenceError("not_defined", HandleVector(&name, 1)));
isolate, NewReferenceError(MessageTemplate::kNotDefined, name));
}
......
......@@ -911,7 +911,7 @@ static ObjectPair LoadLookupSlotHelper(Arguments args, Isolate* isolate,
case IMMUTABLE_CHECK_INITIALIZED_HARMONY:
if (value->IsTheHole()) {
Handle<Object> error = isolate->factory()->NewReferenceError(
"not_defined", HandleVector(&name, 1));
MessageTemplate::kNotDefined, name);
isolate->Throw(*error);
return MakePair(isolate->heap()->exception(), NULL);
}
......@@ -959,7 +959,7 @@ static ObjectPair LoadLookupSlotHelper(Arguments args, Isolate* isolate,
if (throw_error) {
// The property doesn't exist - throw exception.
Handle<Object> error = isolate->factory()->NewReferenceError(
"not_defined", HandleVector(&name, 1));
MessageTemplate::kNotDefined, name);
isolate->Throw(*error);
return MakePair(isolate->heap()->exception(), NULL);
} else {
......@@ -1021,7 +1021,7 @@ RUNTIME_FUNCTION(Runtime_StoreLookupSlot) {
} else if (is_strict(language_mode)) {
// If absent in strict mode: throw.
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewReferenceError("not_defined", HandleVector(&name, 1)));
isolate, NewReferenceError(MessageTemplate::kNotDefined, name));
} else {
// If absent in sloppy mode: add the property to the global object.
object = Handle<JSReceiver>(context->global_object());
......
......@@ -300,6 +300,13 @@ test(function() {
}, "Function arg string contains parenthesis", SyntaxError);
// === ReferenceError ===
test(function() {
"use strict";
o;
}, "o is not defined", ReferenceError);
// === RangeError ===
// kArrayLengthOutOfRange
......
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