Migrate error messages, part 10.
R=mvstanton@chromium.org Committed: https://crrev.com/8608e619afe2b4514b0577bfb73a153b1550d41f Cr-Commit-Position: refs/heads/master@{#28357} Review URL: https://codereview.chromium.org/1126043004 Cr-Commit-Position: refs/heads/master@{#28366}
This commit is contained in:
parent
396236bfa0
commit
0bbe787448
@ -7,6 +7,7 @@
|
||||
#include "src/api.h"
|
||||
#include "src/isolate.h"
|
||||
#include "src/lookup.h"
|
||||
#include "src/messages.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -95,10 +96,9 @@ MaybeHandle<Object> DefineDataProperty(Isolate* isolate,
|
||||
duplicate = maybe.FromJust();
|
||||
}
|
||||
if (duplicate) {
|
||||
Handle<Object> args[1] = {key};
|
||||
THROW_NEW_ERROR(isolate, NewTypeError("duplicate_template_property",
|
||||
HandleVector(args, 1)),
|
||||
Object);
|
||||
THROW_NEW_ERROR(
|
||||
isolate, NewTypeError(MessageTemplate::kDuplicateTemplateProperty, key),
|
||||
Object);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -4400,7 +4400,7 @@ Handle<Value> Function::GetDisplayName() const {
|
||||
i::Handle<i::String> property_name =
|
||||
isolate->factory()->NewStringFromStaticChars("displayName");
|
||||
i::Handle<i::Object> value =
|
||||
i::JSObject::GetDataProperty(func, property_name);
|
||||
i::JSReceiver::GetDataProperty(func, property_name);
|
||||
if (value->IsString()) {
|
||||
i::Handle<i::String> name = i::Handle<i::String>::cast(value);
|
||||
if (name->length() > 0) return Utils::ToLocal(name);
|
||||
@ -6239,7 +6239,7 @@ bool Promise::HasHandler() {
|
||||
LOG_API(isolate, "Promise::HasRejectHandler");
|
||||
ENTER_V8(isolate);
|
||||
i::Handle<i::Symbol> key = isolate->factory()->promise_has_handler_symbol();
|
||||
return i::JSObject::GetDataProperty(promise, key)->IsTrue();
|
||||
return i::JSReceiver::GetDataProperty(promise, key)->IsTrue();
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "src/heap-profiler.h"
|
||||
#include "src/ic/handler-compiler.h"
|
||||
#include "src/ic/ic.h"
|
||||
#include "src/messages.h"
|
||||
#include "src/prototype.h"
|
||||
#include "src/vm-state-inl.h"
|
||||
|
||||
@ -1026,17 +1027,15 @@ BUILTIN(ArrayConcat) {
|
||||
|
||||
BUILTIN(RestrictedFunctionPropertiesThrower) {
|
||||
HandleScope scope(isolate);
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(isolate,
|
||||
NewTypeError("restricted_function_properties",
|
||||
HandleVector<Object>(NULL, 0)));
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(
|
||||
isolate, NewTypeError(MessageTemplate::kRestrictedFunctionProperties));
|
||||
}
|
||||
|
||||
|
||||
BUILTIN(RestrictedStrictArgumentsPropertiesThrower) {
|
||||
HandleScope scope(isolate);
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(
|
||||
isolate,
|
||||
NewTypeError("strict_poison_pill", HandleVector<Object>(NULL, 0)));
|
||||
isolate, NewTypeError(MessageTemplate::kStrictPoisonPill));
|
||||
}
|
||||
|
||||
|
||||
@ -1080,9 +1079,8 @@ MUST_USE_RESULT static MaybeHandle<Object> HandleApiCallHelper(
|
||||
|
||||
if (raw_holder->IsNull()) {
|
||||
// This function cannot be called with the given receiver. Abort!
|
||||
THROW_NEW_ERROR(
|
||||
isolate, NewTypeError("illegal_invocation", HandleVector(&function, 1)),
|
||||
Object);
|
||||
THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kIllegalInvocation),
|
||||
Object);
|
||||
}
|
||||
|
||||
Object* raw_call_data = fun_data->call_code();
|
||||
|
@ -2507,7 +2507,7 @@ void Debug::OnPromiseReject(Handle<JSObject> promise, Handle<Object> value) {
|
||||
HandleScope scope(isolate_);
|
||||
// Check whether the promise has been marked as having triggered a message.
|
||||
Handle<Symbol> key = isolate_->factory()->promise_debug_marker_symbol();
|
||||
if (JSObject::GetDataProperty(promise, key)->IsUndefined()) {
|
||||
if (JSReceiver::GetDataProperty(promise, key)->IsUndefined()) {
|
||||
OnException(value, promise);
|
||||
}
|
||||
}
|
||||
@ -2516,9 +2516,9 @@ void Debug::OnPromiseReject(Handle<JSObject> promise, Handle<Object> value) {
|
||||
MaybeHandle<Object> Debug::PromiseHasUserDefinedRejectHandler(
|
||||
Handle<JSObject> promise) {
|
||||
Handle<JSFunction> fun = Handle<JSFunction>::cast(
|
||||
JSObject::GetDataProperty(isolate_->js_builtins_object(),
|
||||
isolate_->factory()->NewStringFromStaticChars(
|
||||
"$promiseHasUserDefinedRejectHandler")));
|
||||
JSReceiver::GetDataProperty(isolate_->js_builtins_object(),
|
||||
isolate_->factory()->NewStringFromStaticChars(
|
||||
"$promiseHasUserDefinedRejectHandler")));
|
||||
return Execution::Call(isolate_, fun, promise, 0, NULL);
|
||||
}
|
||||
|
||||
|
@ -1409,10 +1409,10 @@ class DictionaryElementsAccessor
|
||||
if (is_strict(language_mode)) {
|
||||
// Deleting a non-configurable property in strict mode.
|
||||
Handle<Object> name = isolate->factory()->NewNumberFromUint(key);
|
||||
Handle<Object> args[2] = { name, obj };
|
||||
THROW_NEW_ERROR(isolate, NewTypeError("strict_delete_property",
|
||||
HandleVector(args, 2)),
|
||||
Object);
|
||||
THROW_NEW_ERROR(
|
||||
isolate,
|
||||
NewTypeError(MessageTemplate::kStrictDeleteProperty, name, obj),
|
||||
Object);
|
||||
}
|
||||
return isolate->factory()->false_value();
|
||||
}
|
||||
|
@ -1076,23 +1076,11 @@ Handle<HeapNumber> Factory::NewHeapNumber(double value,
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> Factory::NewTypeError(const char* message,
|
||||
Vector<Handle<Object> > args) {
|
||||
return NewError("MakeTypeError", message, args);
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> Factory::NewTypeError(Handle<String> message) {
|
||||
return NewError("$TypeError", message);
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> Factory::NewRangeError(const char* message,
|
||||
Vector<Handle<Object> > args) {
|
||||
return NewError("MakeRangeError", message, args);
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> Factory::NewRangeError(Handle<String> message) {
|
||||
return NewError("$RangeError", message);
|
||||
}
|
||||
|
@ -547,12 +547,8 @@ class Factory final {
|
||||
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(Handle<String> message);
|
||||
|
||||
Handle<Object> NewRangeError(const char* message,
|
||||
Vector<Handle<Object> > args);
|
||||
Handle<Object> NewRangeError(Handle<String> message);
|
||||
|
||||
Handle<Object> NewInvalidStringLengthError() {
|
||||
|
@ -5917,7 +5917,7 @@ HInstruction* HOptimizedGraphBuilder::BuildLoadNamedField(
|
||||
if (object->IsJSObject()) {
|
||||
LookupIterator it(object, info->name(),
|
||||
LookupIterator::OWN_SKIP_INTERCEPTOR);
|
||||
Handle<Object> value = JSObject::GetDataProperty(&it);
|
||||
Handle<Object> value = JSReceiver::GetDataProperty(&it);
|
||||
if (it.IsFound() && it.IsReadOnly() && !it.IsConfigurable()) {
|
||||
return New<HConstant>(value);
|
||||
}
|
||||
|
14
src/ic/ic.cc
14
src/ic/ic.cc
@ -16,7 +16,6 @@
|
||||
#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"
|
||||
|
||||
@ -362,11 +361,10 @@ void IC::UpdateState(Handle<Object> receiver, Handle<Object> name) {
|
||||
}
|
||||
|
||||
|
||||
MaybeHandle<Object> IC::TypeError(const char* type, Handle<Object> object,
|
||||
Handle<Object> key) {
|
||||
MaybeHandle<Object> IC::TypeError(MessageTemplate::Template index,
|
||||
Handle<Object> object, Handle<Object> key) {
|
||||
HandleScope scope(isolate());
|
||||
Handle<Object> args[2] = {key, object};
|
||||
THROW_NEW_ERROR(isolate(), NewTypeError(type, HandleVector(args, 2)), Object);
|
||||
THROW_NEW_ERROR(isolate(), NewTypeError(index, key, object), Object);
|
||||
}
|
||||
|
||||
|
||||
@ -696,7 +694,7 @@ MaybeHandle<Object> LoadIC::Load(Handle<Object> object, Handle<Name> name) {
|
||||
// If the object is undefined or null it's illegal to try to get any
|
||||
// of its properties; throw a TypeError in that case.
|
||||
if (object->IsUndefined() || object->IsNull()) {
|
||||
return TypeError("non_object_property_load", object, name);
|
||||
return TypeError(MessageTemplate::kNonObjectPropertyLoad, object, name);
|
||||
}
|
||||
|
||||
// Check if the name is trivially convertible to an index and get
|
||||
@ -1558,7 +1556,7 @@ MaybeHandle<Object> StoreIC::Store(Handle<Object> object, Handle<Name> name,
|
||||
Handle<Context> script_context = ScriptContextTable::GetContext(
|
||||
script_contexts, lookup_result.context_index);
|
||||
if (lookup_result.mode == CONST) {
|
||||
return TypeError("const_assign", object, name);
|
||||
return TypeError(MessageTemplate::kConstAssign, object, name);
|
||||
}
|
||||
|
||||
Handle<Object> previous_value =
|
||||
@ -1594,7 +1592,7 @@ MaybeHandle<Object> StoreIC::Store(Handle<Object> object, Handle<Name> name,
|
||||
// If the object is undefined or null it's illegal to try to set any
|
||||
// properties on it; throw a TypeError in that case.
|
||||
if (object->IsUndefined() || object->IsNull()) {
|
||||
return TypeError("non_object_property_store", object, name);
|
||||
return TypeError(MessageTemplate::kNonObjectPropertyStore, object, name);
|
||||
}
|
||||
|
||||
// Check if the given name is an array index.
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "src/ic/ic-state.h"
|
||||
#include "src/macro-assembler.h"
|
||||
#include "src/messages.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -162,8 +163,8 @@ class IC {
|
||||
void TraceIC(const char* type, Handle<Object> name, State old_state,
|
||||
State new_state);
|
||||
|
||||
MaybeHandle<Object> TypeError(const char* type, Handle<Object> object,
|
||||
Handle<Object> key);
|
||||
MaybeHandle<Object> TypeError(MessageTemplate::Template,
|
||||
Handle<Object> object, Handle<Object> key);
|
||||
MaybeHandle<Object> ReferenceError(Handle<Name> name);
|
||||
|
||||
// Access the target code for the given IC address.
|
||||
|
@ -341,9 +341,8 @@ Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSObject> error_object,
|
||||
Handle<String> stackTraceLimit =
|
||||
factory()->InternalizeUtf8String("stackTraceLimit");
|
||||
DCHECK(!stackTraceLimit.is_null());
|
||||
Handle<Object> stack_trace_limit =
|
||||
JSObject::GetDataProperty(Handle<JSObject>::cast(error),
|
||||
stackTraceLimit);
|
||||
Handle<Object> stack_trace_limit = JSReceiver::GetDataProperty(
|
||||
Handle<JSObject>::cast(error), stackTraceLimit);
|
||||
if (!stack_trace_limit->IsNumber()) return factory()->undefined_value();
|
||||
int limit = FastD2IChecked(stack_trace_limit->Number());
|
||||
limit = Max(limit, 0); // Ensure that limit is not negative.
|
||||
@ -446,7 +445,7 @@ MaybeHandle<JSObject> Isolate::CaptureAndSetSimpleStackTrace(
|
||||
Handle<JSArray> Isolate::GetDetailedStackTrace(Handle<JSObject> error_object) {
|
||||
Handle<Name> key_detailed = factory()->detailed_stack_trace_symbol();
|
||||
Handle<Object> stack_trace =
|
||||
JSObject::GetDataProperty(error_object, key_detailed);
|
||||
JSReceiver::GetDataProperty(error_object, key_detailed);
|
||||
if (stack_trace->IsJSArray()) return Handle<JSArray>::cast(stack_trace);
|
||||
|
||||
if (!capture_stack_trace_for_uncaught_exceptions_) return Handle<JSArray>();
|
||||
@ -600,7 +599,7 @@ int PositionFromStackTrace(Handle<FixedArray> elements, int index) {
|
||||
Handle<JSArray> Isolate::GetDetailedFromSimpleStackTrace(
|
||||
Handle<JSObject> error_object) {
|
||||
Handle<Name> key = factory()->stack_trace_symbol();
|
||||
Handle<Object> property = JSObject::GetDataProperty(error_object, key);
|
||||
Handle<Object> property = JSReceiver::GetDataProperty(error_object, key);
|
||||
if (!property->IsJSArray()) return Handle<JSArray>();
|
||||
Handle<JSArray> simple_stack_trace = Handle<JSArray>::cast(property);
|
||||
|
||||
@ -1272,19 +1271,19 @@ bool Isolate::ComputeLocationFromException(MessageLocation* target,
|
||||
if (!exception->IsJSObject()) return false;
|
||||
|
||||
Handle<Name> start_pos_symbol = factory()->error_start_pos_symbol();
|
||||
Handle<Object> start_pos = JSObject::GetDataProperty(
|
||||
Handle<Object> start_pos = JSReceiver::GetDataProperty(
|
||||
Handle<JSObject>::cast(exception), start_pos_symbol);
|
||||
if (!start_pos->IsSmi()) return false;
|
||||
int start_pos_value = Handle<Smi>::cast(start_pos)->value();
|
||||
|
||||
Handle<Name> end_pos_symbol = factory()->error_end_pos_symbol();
|
||||
Handle<Object> end_pos = JSObject::GetDataProperty(
|
||||
Handle<Object> end_pos = JSReceiver::GetDataProperty(
|
||||
Handle<JSObject>::cast(exception), end_pos_symbol);
|
||||
if (!end_pos->IsSmi()) return false;
|
||||
int end_pos_value = Handle<Smi>::cast(end_pos)->value();
|
||||
|
||||
Handle<Name> script_symbol = factory()->error_script_symbol();
|
||||
Handle<Object> script = JSObject::GetDataProperty(
|
||||
Handle<Object> script = JSReceiver::GetDataProperty(
|
||||
Handle<JSObject>::cast(exception), script_symbol);
|
||||
if (!script->IsScript()) return false;
|
||||
|
||||
@ -1301,7 +1300,7 @@ bool Isolate::ComputeLocationFromStackTrace(MessageLocation* target,
|
||||
if (!exception->IsJSObject()) return false;
|
||||
Handle<Name> key = factory()->stack_trace_symbol();
|
||||
Handle<Object> property =
|
||||
JSObject::GetDataProperty(Handle<JSObject>::cast(exception), key);
|
||||
JSReceiver::GetDataProperty(Handle<JSObject>::cast(exception), key);
|
||||
if (!property->IsJSArray()) return false;
|
||||
Handle<JSArray> simple_stack_trace = Handle<JSArray>::cast(property);
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "src/v8.h"
|
||||
|
||||
#include "src/conversions.h"
|
||||
#include "src/messages.h"
|
||||
#include "src/string-builder.h"
|
||||
#include "src/utils.h"
|
||||
|
||||
@ -272,8 +273,8 @@ BasicJsonStringifier::Result BasicJsonStringifier::StackPush(
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (elements->get(i) == *object) {
|
||||
AllowHeapAllocation allow_to_return_error;
|
||||
Handle<Object> error = factory()->NewTypeError(
|
||||
"circular_structure", HandleVector<Object>(NULL, 0));
|
||||
Handle<Object> error =
|
||||
factory()->NewTypeError(MessageTemplate::kCircularStructure);
|
||||
isolate_->Throw(*error);
|
||||
return EXCEPTION;
|
||||
}
|
||||
|
@ -51,9 +51,7 @@ function JSONParse(text, reviver) {
|
||||
|
||||
|
||||
function SerializeArray(value, replacer, stack, indent, gap) {
|
||||
if (!%PushIfAbsent(stack, value)) {
|
||||
throw MakeTypeError('circular_structure', []);
|
||||
}
|
||||
if (!%PushIfAbsent(stack, value)) throw MakeTypeError(kCircularStructure);
|
||||
var stepback = indent;
|
||||
indent += gap;
|
||||
var partial = new InternalArray();
|
||||
@ -82,9 +80,7 @@ function SerializeArray(value, replacer, stack, indent, gap) {
|
||||
|
||||
|
||||
function SerializeObject(value, replacer, stack, indent, gap) {
|
||||
if (!%PushIfAbsent(stack, value)) {
|
||||
throw MakeTypeError('circular_structure', []);
|
||||
}
|
||||
if (!%PushIfAbsent(stack, value)) throw MakeTypeError(kCircularStructure);
|
||||
var stepback = indent;
|
||||
indent += gap;
|
||||
var partial = new InternalArray();
|
||||
|
@ -306,8 +306,8 @@ bool CallSite::IsEval(Isolate* isolate) {
|
||||
bool CallSite::IsConstructor(Isolate* isolate) {
|
||||
if (!receiver_->IsJSObject()) return false;
|
||||
Handle<Object> constructor =
|
||||
JSObject::GetDataProperty(Handle<JSObject>::cast(receiver_),
|
||||
isolate->factory()->constructor_string());
|
||||
JSReceiver::GetDataProperty(Handle<JSObject>::cast(receiver_),
|
||||
isolate->factory()->constructor_string());
|
||||
return constructor.is_identical_to(fun_);
|
||||
}
|
||||
|
||||
|
@ -131,6 +131,10 @@ class CallSite {
|
||||
T(CalledOnNonObject, "% called on non-object") \
|
||||
T(CalledOnNullOrUndefined, "% called on null or undefined") \
|
||||
T(CannotConvertToPrimitive, "Cannot convert object to primitive value") \
|
||||
T(CannotPreventExtExternalArray, \
|
||||
"Cannot prevent extension of an object with external array elements") \
|
||||
T(CircularStructure, "Converting circular structure to JSON") \
|
||||
T(ConstAssign, "Assignment to constant variable.") \
|
||||
T(ConstructorNonCallable, \
|
||||
"Class constructors cannot be invoked without 'new'") \
|
||||
T(ConstructorNotFunction, "Constructor % requires 'new'") \
|
||||
@ -139,12 +143,18 @@ class CallSite {
|
||||
"First argument to DataView constructor must be an ArrayBuffer") \
|
||||
T(DateType, "this is not a Date object.") \
|
||||
T(DefineDisallowed, "Cannot define property:%, object is not extensible.") \
|
||||
T(DuplicateTemplateProperty, "Object template has duplicate property '%'") \
|
||||
T(ExtendsValueGenerator, \
|
||||
"Class extends value % may not be a generator function") \
|
||||
T(ExtendsValueNotFunction, \
|
||||
"Class extends value % is not a function or null") \
|
||||
T(FirstArgumentNotRegExp, \
|
||||
"First argument to % must not be a regular expression") \
|
||||
T(FlagsGetterNonObject, \
|
||||
"RegExp.prototype.flags getter called on non-object %") \
|
||||
T(FunctionBind, "Bind must be called on a function") \
|
||||
T(GeneratorRunning, "Generator is already running") \
|
||||
T(IllegalInvocation, "Illegal invocation") \
|
||||
T(IncompatibleMethodReceiver, "Method % called on incompatible receiver %") \
|
||||
T(InstanceofFunctionExpected, \
|
||||
"Expecting a function in instanceof check, but got %") \
|
||||
@ -160,15 +170,22 @@ class CallSite {
|
||||
T(MethodInvokedOnNullOrUndefined, \
|
||||
"Method invoked on undefined or null value.") \
|
||||
T(MethodInvokedOnWrongType, "Method invoked on an object that is not %.") \
|
||||
T(NonExtensibleProto, "% is not extensible") \
|
||||
T(NonObjectPropertyLoad, "Cannot read property '%' of %") \
|
||||
T(NonObjectPropertyStore, "Cannot set property '%' of %") \
|
||||
T(NoSetterInCallback, "Cannot set property % of % which has only a getter") \
|
||||
T(NotAnIterator, "% is not an iterator") \
|
||||
T(NotAPromise, "% is not a promise") \
|
||||
T(NotConstructor, "% is not a constructor") \
|
||||
T(NotDateObject, "this is not a Date object.") \
|
||||
T(NotIntlObject, "% is not an i18n object.") \
|
||||
T(NotGeneric, "% is not generic") \
|
||||
T(NotIterable, "% is not iterable") \
|
||||
T(NotTypedArray, "this is not a typed array.") \
|
||||
T(ObjectGetterExpectingFunction, \
|
||||
"Object.prototype.__defineGetter__: Expecting function") \
|
||||
T(ObjectGetterCallable, "Getter must be a function: %") \
|
||||
T(ObjectNotExtensible, "Can't add property %, object is not extensible") \
|
||||
T(ObjectSetterExpectingFunction, \
|
||||
"Object.prototype.__defineSetter__: Expecting function") \
|
||||
T(ObjectSetterCallable, "Setter must be a function: %") \
|
||||
@ -190,6 +207,10 @@ class CallSite {
|
||||
T(PropertyDescObject, "Property description must be an object: %") \
|
||||
T(PropertyNotFunction, "Property '%' of object % is not a function") \
|
||||
T(ProtoObjectOrNull, "Object prototype may only be an Object or null: %") \
|
||||
T(PrototypeParentNotAnObject, \
|
||||
"Class extends value does not have valid prototype property %") \
|
||||
T(ProxyHandlerDeleteFailed, \
|
||||
"Proxy handler % did not return a boolean value from 'delete' trap") \
|
||||
T(ProxyHandlerNonObject, "Proxy.% called with non-object as handler") \
|
||||
T(ProxyHandlerReturned, "Proxy handler % returned % from '%' trap") \
|
||||
T(ProxyHandlerTrapMissing, "Proxy handler % has no '%' trap") \
|
||||
@ -204,12 +225,27 @@ class CallSite {
|
||||
T(ProxyTrapFunctionExpected, \
|
||||
"Proxy.createFunction called with non-function for '%' trap") \
|
||||
T(RedefineDisallowed, "Cannot redefine property: %") \
|
||||
T(RedefineExternalArray, \
|
||||
"Cannot redefine a property of an object with external array elements") \
|
||||
T(ReduceNoInitial, "Reduce of empty array with no initial value") \
|
||||
T(ReinitializeIntl, "Trying to re-initialize % object.") \
|
||||
T(ResolvedOptionsCalledOnNonObject, \
|
||||
"resolvedOptions method called on a non-object or on a object that is " \
|
||||
"not Intl.%.") \
|
||||
T(ResolverNotAFunction, "Promise resolver % is not a function") \
|
||||
T(RestrictedFunctionProperties, \
|
||||
"'caller' and 'arguments' are restricted function properties and cannot " \
|
||||
"be accessed in this context.") \
|
||||
T(StaticPrototype, "Classes may not have static property named prototype") \
|
||||
T(StrictCannotAssign, "Cannot assign to read only '% in strict mode") \
|
||||
T(StrictDeleteProperty, "Cannot delete property '%' of %") \
|
||||
T(StrictPoisonPill, \
|
||||
"'caller', 'callee', and 'arguments' properties may not be accessed on " \
|
||||
"strict mode functions or the arguments objects for calls to them") \
|
||||
T(StrictReadOnlyProperty, "Cannot assign to read only property '%' of %") \
|
||||
T(StrongArity, \
|
||||
"In strong mode, calling a function with too few arguments is deprecated") \
|
||||
T(StrongImplicitCast, "In strong mode, implicit conversions are deprecated") \
|
||||
T(SymbolToPrimitive, \
|
||||
"Cannot convert a Symbol wrapper object to a primitive value") \
|
||||
T(SymbolToNumber, "Cannot convert a Symbol value to a number") \
|
||||
@ -218,6 +254,7 @@ class CallSite {
|
||||
T(ValueAndAccessor, \
|
||||
"Invalid property. A property cannot both have accessors and be " \
|
||||
"writable or have a value, %") \
|
||||
T(VarRedeclaration, "Identifier '%' has already been declared") \
|
||||
T(WithExpression, "% has no properties") \
|
||||
T(WrongArgs, "%: Arguments list has wrong type") \
|
||||
/* ReferenceError */ \
|
||||
|
@ -70,21 +70,15 @@ var kMessages = {
|
||||
newline_after_throw: ["Illegal newline after throw"],
|
||||
label_redeclaration: ["Label '", "%0", "' has already been declared"],
|
||||
var_redeclaration: ["Identifier '", "%0", "' has already been declared"],
|
||||
duplicate_template_property: ["Object template has duplicate property '", "%0", "'"],
|
||||
no_catch_or_finally: ["Missing catch or finally after try"],
|
||||
unknown_label: ["Undefined label '", "%0", "'"],
|
||||
uncaught_exception: ["Uncaught ", "%0"],
|
||||
undefined_method: ["Object ", "%1", " has no method '", "%0", "'"],
|
||||
non_object_property_load: ["Cannot read property '", "%0", "' of ", "%1"],
|
||||
non_object_property_store: ["Cannot set property '", "%0", "' of ", "%1"],
|
||||
illegal_invocation: ["Illegal invocation"],
|
||||
no_setter_in_callback: ["Cannot set property ", "%0", " of ", "%1", " which has only a getter"],
|
||||
value_and_accessor: ["Invalid property. A property cannot both have accessors and be writable or have a value, ", "%0"],
|
||||
proto_object_or_null: ["Object prototype may only be an Object or null: ", "%0"],
|
||||
non_extensible_proto: ["%0", " is not extensible"],
|
||||
invalid_weakmap_key: ["Invalid value used as weak map key"],
|
||||
invalid_weakset_value: ["Invalid value used in weak set"],
|
||||
not_date_object: ["this is not a Date object."],
|
||||
not_a_symbol: ["%0", " is not a symbol"],
|
||||
// ReferenceError
|
||||
invalid_lhs_in_assignment: ["Invalid left-hand side in assignment"],
|
||||
@ -100,9 +94,7 @@ var kMessages = {
|
||||
illegal_continue: ["Illegal continue statement"],
|
||||
illegal_return: ["Illegal return statement"],
|
||||
error_loading_debugger: ["Error loading debugger"],
|
||||
circular_structure: ["Converting circular structure to JSON"],
|
||||
array_indexof_not_defined: ["Array.getIndexOf: Argument undefined"],
|
||||
object_not_extensible: ["Can't add property ", "%0", ", object is not extensible"],
|
||||
illegal_access: ["Illegal access"],
|
||||
static_prototype: ["Classes may not have static property named prototype"],
|
||||
strict_mode_with: ["Strict mode code may not include a with statement"],
|
||||
@ -114,17 +106,11 @@ var kMessages = {
|
||||
strict_octal_literal: ["Octal literals are not allowed in strict mode."],
|
||||
template_octal_literal: ["Octal literals are not allowed in template strings."],
|
||||
strict_delete: ["Delete of an unqualified identifier in strict mode."],
|
||||
strict_delete_property: ["Cannot delete property '", "%0", "' of ", "%1"],
|
||||
strict_function: ["In strict mode code, functions can only be declared at top level or immediately within another function." ],
|
||||
strict_read_only_property: ["Cannot assign to read only property '", "%0", "' of ", "%1"],
|
||||
strict_cannot_assign: ["Cannot assign to read only '", "%0", "' in strict mode"],
|
||||
restricted_function_properties: ["'caller' and 'arguments' are restricted function properties and cannot be accessed in this context."],
|
||||
strict_poison_pill: ["'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them"],
|
||||
strict_caller: ["Illegal access to a strict mode caller function."],
|
||||
strong_ellision: ["In strong mode, arrays with holes are deprecated, use maps instead"],
|
||||
strong_arguments: ["In strong mode, 'arguments' is deprecated, use '...args' instead"],
|
||||
strong_undefined: ["In strong mode, binding or assigning to 'undefined' is deprecated"],
|
||||
strong_implicit_cast: ["In strong mode, implicit conversions are deprecated"],
|
||||
strong_direct_eval: ["In strong mode, direct calls to eval are deprecated"],
|
||||
strong_switch_fallthrough : ["In strong mode, switch fall-through is deprecated, terminate each case with 'break', 'continue', 'return' or 'throw'"],
|
||||
strong_equal: ["In strong mode, '==' and '!=' are deprecated, use '===' and '!==' instead"],
|
||||
@ -141,18 +127,11 @@ var kMessages = {
|
||||
strong_constructor_this: ["In strong mode, 'this' can only be used to initialize properties, and cannot be nested inside another statement or expression"],
|
||||
strong_constructor_return_value: ["In strong mode, returning a value from a constructor is deprecated"],
|
||||
strong_constructor_return_misplaced: ["In strong mode, returning from a constructor before its super constructor invocation or all assignments to 'this' is deprecated"],
|
||||
strong_arity: ["In strong mode, calling a function with too few arguments is deprecated"],
|
||||
sloppy_lexical: ["Block-scoped declarations (let, const, function, class) not yet supported outside strict mode"],
|
||||
malformed_arrow_function_parameter_list: ["Malformed arrow function parameter list"],
|
||||
cant_prevent_ext_external_array_elements: ["Cannot prevent extension of an object with external array elements"],
|
||||
redef_external_array_element: ["Cannot redefine a property of an object with external array elements"],
|
||||
const_assign: ["Assignment to constant variable."],
|
||||
module_export_undefined: ["Export '", "%0", "' is not defined in module"],
|
||||
duplicate_export: ["Duplicate export of '", "%0", "'"],
|
||||
unexpected_super: ["'super' keyword unexpected here"],
|
||||
extends_value_not_a_function: ["Class extends value ", "%0", " is not a function or null"],
|
||||
extends_value_generator: ["Class extends value ", "%0", " may not be a generator function"],
|
||||
prototype_parent_not_an_object: ["Class extends value does not have valid prototype property ", "%0"],
|
||||
duplicate_constructor: ["A class may only have one constructor"],
|
||||
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"],
|
||||
|
125
src/objects.cc
125
src/objects.cc
@ -145,15 +145,15 @@ MaybeHandle<Object> Object::GetProperty(LookupIterator* it) {
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> JSObject::GetDataProperty(Handle<JSObject> object,
|
||||
Handle<Name> key) {
|
||||
Handle<Object> JSReceiver::GetDataProperty(Handle<JSReceiver> object,
|
||||
Handle<Name> key) {
|
||||
LookupIterator it(object, key,
|
||||
LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
|
||||
return GetDataProperty(&it);
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> JSObject::GetDataProperty(LookupIterator* it) {
|
||||
Handle<Object> JSReceiver::GetDataProperty(LookupIterator* it) {
|
||||
for (; it->IsFound(); it->Next()) {
|
||||
switch (it->state()) {
|
||||
case LookupIterator::INTERCEPTOR:
|
||||
@ -389,11 +389,10 @@ MaybeHandle<Object> Object::SetPropertyWithAccessor(
|
||||
receiver, Handle<JSReceiver>::cast(setter), value);
|
||||
} else {
|
||||
if (is_sloppy(language_mode)) return value;
|
||||
Handle<Object> args[] = {name, holder};
|
||||
THROW_NEW_ERROR(isolate,
|
||||
NewTypeError("no_setter_in_callback",
|
||||
HandleVector(args, arraysize(args))),
|
||||
Object);
|
||||
THROW_NEW_ERROR(
|
||||
isolate,
|
||||
NewTypeError(MessageTemplate::kNoSetterInCallback, name, holder),
|
||||
Object);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3322,10 +3321,10 @@ MaybeHandle<Object> Object::WriteToReadOnlyProperty(
|
||||
Isolate* isolate, Handle<Object> receiver, Handle<Object> name,
|
||||
Handle<Object> value, LanguageMode language_mode) {
|
||||
if (is_sloppy(language_mode)) return value;
|
||||
Handle<Object> args[] = {name, receiver};
|
||||
THROW_NEW_ERROR(isolate, NewTypeError("strict_read_only_property",
|
||||
HandleVector(args, arraysize(args))),
|
||||
Object);
|
||||
THROW_NEW_ERROR(
|
||||
isolate,
|
||||
NewTypeError(MessageTemplate::kStrictReadOnlyProperty, name, receiver),
|
||||
Object);
|
||||
}
|
||||
|
||||
|
||||
@ -3410,12 +3409,10 @@ MaybeHandle<Object> Object::AddDataProperty(LookupIterator* it,
|
||||
it->PrepareTransitionToDataProperty(value, attributes, store_mode);
|
||||
if (it->state() != LookupIterator::TRANSITION) {
|
||||
if (is_sloppy(language_mode)) return value;
|
||||
|
||||
Handle<Object> args[] = {it->name()};
|
||||
THROW_NEW_ERROR(it->isolate(),
|
||||
NewTypeError("object_not_extensible",
|
||||
HandleVector(args, arraysize(args))),
|
||||
Object);
|
||||
THROW_NEW_ERROR(
|
||||
it->isolate(),
|
||||
NewTypeError(MessageTemplate::kObjectNotExtensible, it->name()),
|
||||
Object);
|
||||
}
|
||||
it->ApplyTransitionToDataProperty();
|
||||
|
||||
@ -3969,10 +3966,9 @@ MaybeHandle<Object> JSProxy::SetPropertyViaPrototypesWithHandler(
|
||||
}
|
||||
|
||||
if (is_sloppy(language_mode)) return value;
|
||||
Handle<Object> args2[] = { name, proxy };
|
||||
THROW_NEW_ERROR(isolate, NewTypeError("no_setter_in_callback",
|
||||
HandleVector(args2, arraysize(args2))),
|
||||
Object);
|
||||
THROW_NEW_ERROR(
|
||||
isolate, NewTypeError(MessageTemplate::kNoSetterInCallback, name, proxy),
|
||||
Object);
|
||||
}
|
||||
|
||||
|
||||
@ -3997,12 +3993,10 @@ MaybeHandle<Object> JSProxy::DeletePropertyWithHandler(
|
||||
bool result_bool = result->BooleanValue();
|
||||
if (is_strict(language_mode) && !result_bool) {
|
||||
Handle<Object> handler(proxy->handler(), isolate);
|
||||
Handle<String> trap_name = isolate->factory()->InternalizeOneByteString(
|
||||
STATIC_CHAR_VECTOR("delete"));
|
||||
Handle<Object> args[] = { handler, trap_name };
|
||||
THROW_NEW_ERROR(isolate, NewTypeError("handler_failed",
|
||||
HandleVector(args, arraysize(args))),
|
||||
Object);
|
||||
THROW_NEW_ERROR(
|
||||
isolate,
|
||||
NewTypeError(MessageTemplate::kProxyHandlerDeleteFailed, handler),
|
||||
Object);
|
||||
}
|
||||
return isolate->factory()->ToBoolean(result_bool);
|
||||
}
|
||||
@ -5313,11 +5307,10 @@ MaybeHandle<Object> JSObject::DeleteElement(Handle<JSObject> object,
|
||||
if (is_strict(language_mode)) {
|
||||
// Deleting a non-configurable property in strict mode.
|
||||
Handle<Object> name = factory->NewNumberFromUint(index);
|
||||
Handle<Object> args[] = {name, object};
|
||||
THROW_NEW_ERROR(isolate,
|
||||
NewTypeError("strict_delete_property",
|
||||
HandleVector(args, arraysize(args))),
|
||||
Object);
|
||||
THROW_NEW_ERROR(
|
||||
isolate,
|
||||
NewTypeError(MessageTemplate::kStrictDeleteProperty, name, object),
|
||||
Object);
|
||||
}
|
||||
return factory->false_value();
|
||||
}
|
||||
@ -5447,10 +5440,9 @@ MaybeHandle<Object> JSObject::DeleteProperty(Handle<JSObject> object,
|
||||
if (!it.IsConfigurable()) {
|
||||
// Fail if the property is not configurable.
|
||||
if (is_strict(language_mode)) {
|
||||
Handle<Object> args[] = {name, object};
|
||||
THROW_NEW_ERROR(it.isolate(),
|
||||
NewTypeError("strict_delete_property",
|
||||
HandleVector(args, arraysize(args))),
|
||||
NewTypeError(MessageTemplate::kStrictDeleteProperty,
|
||||
name, object),
|
||||
Object);
|
||||
}
|
||||
return it.isolate()->factory()->false_value();
|
||||
@ -5671,10 +5663,9 @@ MaybeHandle<Object> JSObject::PreventExtensions(Handle<JSObject> object) {
|
||||
// It's not possible to seal objects with external array elements
|
||||
if (object->HasExternalArrayElements() ||
|
||||
object->HasFixedTypedArrayElements()) {
|
||||
THROW_NEW_ERROR(isolate,
|
||||
NewTypeError("cant_prevent_ext_external_array_elements",
|
||||
HandleVector(&object, 1)),
|
||||
Object);
|
||||
THROW_NEW_ERROR(
|
||||
isolate, NewTypeError(MessageTemplate::kCannotPreventExtExternalArray),
|
||||
Object);
|
||||
}
|
||||
|
||||
// If there are fast elements we normalize.
|
||||
@ -5780,10 +5771,9 @@ MaybeHandle<Object> JSObject::PreventExtensionsWithTransition(
|
||||
// It's not possible to seal or freeze objects with external array elements
|
||||
if (object->HasExternalArrayElements() ||
|
||||
object->HasFixedTypedArrayElements()) {
|
||||
THROW_NEW_ERROR(isolate,
|
||||
NewTypeError("cant_prevent_ext_external_array_elements",
|
||||
HandleVector(&object, 1)),
|
||||
Object);
|
||||
THROW_NEW_ERROR(
|
||||
isolate, NewTypeError(MessageTemplate::kCannotPreventExtExternalArray),
|
||||
Object);
|
||||
}
|
||||
|
||||
Handle<SeededNumberDictionary> new_element_dictionary;
|
||||
@ -10522,7 +10512,7 @@ bool JSFunction::PassesFilter(const char* raw_filter) {
|
||||
Handle<String> JSFunction::GetDebugName(Handle<JSFunction> function) {
|
||||
Isolate* isolate = function->GetIsolate();
|
||||
Handle<Object> name =
|
||||
JSObject::GetDataProperty(function, isolate->factory()->name_string());
|
||||
JSReceiver::GetDataProperty(function, isolate->factory()->name_string());
|
||||
if (name->IsString()) return Handle<String>::cast(name);
|
||||
return handle(function->shared()->DebugName(), isolate);
|
||||
}
|
||||
@ -12597,9 +12587,8 @@ MaybeHandle<Object> JSObject::SetPrototype(Handle<JSObject> object,
|
||||
// or [[Extensible]] must not violate the invariants defined in the preceding
|
||||
// paragraph.
|
||||
if (!object->map()->is_extensible()) {
|
||||
Handle<Object> args[] = { object };
|
||||
THROW_NEW_ERROR(isolate, NewTypeError("non_extensible_proto",
|
||||
HandleVector(args, arraysize(args))),
|
||||
THROW_NEW_ERROR(isolate,
|
||||
NewTypeError(MessageTemplate::kNonExtensibleProto, object),
|
||||
Object);
|
||||
}
|
||||
|
||||
@ -12629,11 +12618,9 @@ MaybeHandle<Object> JSObject::SetPrototype(Handle<JSObject> object,
|
||||
Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter));
|
||||
iter.Advance();
|
||||
if (!real_receiver->map()->is_extensible()) {
|
||||
Handle<Object> args[] = {object};
|
||||
THROW_NEW_ERROR(isolate,
|
||||
NewTypeError("non_extensible_proto",
|
||||
HandleVector(args, arraysize(args))),
|
||||
Object);
|
||||
THROW_NEW_ERROR(
|
||||
isolate, NewTypeError(MessageTemplate::kNonExtensibleProto, object),
|
||||
Object);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -12813,11 +12800,10 @@ MaybeHandle<Object> JSObject::SetElementWithCallback(
|
||||
} else {
|
||||
if (is_sloppy(language_mode)) return value;
|
||||
Handle<Object> key(isolate->factory()->NewNumberFromUint(index));
|
||||
Handle<Object> args[] = {key, holder};
|
||||
THROW_NEW_ERROR(isolate,
|
||||
NewTypeError("no_setter_in_callback",
|
||||
HandleVector(args, arraysize(args))),
|
||||
Object);
|
||||
THROW_NEW_ERROR(
|
||||
isolate,
|
||||
NewTypeError(MessageTemplate::kNoSetterInCallback, key, holder),
|
||||
Object);
|
||||
}
|
||||
}
|
||||
|
||||
@ -13056,11 +13042,9 @@ MaybeHandle<Object> JSObject::SetDictionaryElement(
|
||||
} else {
|
||||
Handle<Object> number = isolate->factory()->NewNumberFromUint(index);
|
||||
Handle<String> name = isolate->factory()->NumberToString(number);
|
||||
Handle<Object> args[] = {name};
|
||||
THROW_NEW_ERROR(isolate,
|
||||
NewTypeError("object_not_extensible",
|
||||
HandleVector(args, arraysize(args))),
|
||||
Object);
|
||||
THROW_NEW_ERROR(
|
||||
isolate, NewTypeError(MessageTemplate::kObjectNotExtensible, name),
|
||||
Object);
|
||||
}
|
||||
}
|
||||
|
||||
@ -13277,11 +13261,8 @@ MaybeHandle<Object> JSObject::SetElement(Handle<JSObject> object,
|
||||
if ((object->HasExternalArrayElements() ||
|
||||
object->HasFixedTypedArrayElements()) &&
|
||||
set_mode == DEFINE_PROPERTY) {
|
||||
Handle<Object> number = isolate->factory()->NewNumberFromUint(index);
|
||||
Handle<Object> args[] = { object, number };
|
||||
THROW_NEW_ERROR(isolate, NewTypeError("redef_external_array_element",
|
||||
HandleVector(args, arraysize(args))),
|
||||
Object);
|
||||
THROW_NEW_ERROR(
|
||||
isolate, NewTypeError(MessageTemplate::kRedefineExternalArray), Object);
|
||||
}
|
||||
|
||||
// Normalize the elements to enable attributes on the property.
|
||||
@ -13724,10 +13705,10 @@ bool JSArray::WouldChangeReadOnlyLength(Handle<JSArray> array,
|
||||
MaybeHandle<Object> JSArray::ReadOnlyLengthError(Handle<JSArray> array) {
|
||||
Isolate* isolate = array->GetIsolate();
|
||||
Handle<Name> length = isolate->factory()->length_string();
|
||||
Handle<Object> args[] = {length, array};
|
||||
THROW_NEW_ERROR(isolate, NewTypeError("strict_read_only_property",
|
||||
HandleVector(args, arraysize(args))),
|
||||
Object);
|
||||
THROW_NEW_ERROR(
|
||||
isolate,
|
||||
NewTypeError(MessageTemplate::kStrictReadOnlyProperty, length, array),
|
||||
Object);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1671,6 +1671,11 @@ class JSReceiver: public HeapObject {
|
||||
MUST_USE_RESULT static inline Maybe<PropertyAttributes>
|
||||
GetOwnElementAttribute(Handle<JSReceiver> object, uint32_t index);
|
||||
|
||||
static Handle<Object> GetDataProperty(Handle<JSReceiver> object,
|
||||
Handle<Name> key);
|
||||
static Handle<Object> GetDataProperty(LookupIterator* it);
|
||||
|
||||
|
||||
// Retrieves a permanent object identity hash code. The undefined value might
|
||||
// be returned in case no hash was created yet.
|
||||
inline Object* GetIdentityHash();
|
||||
@ -2167,10 +2172,6 @@ class JSObject: public JSReceiver {
|
||||
Handle<JSObject> object,
|
||||
AllocationSiteCreationContext* site_context);
|
||||
|
||||
static Handle<Object> GetDataProperty(Handle<JSObject> object,
|
||||
Handle<Name> key);
|
||||
static Handle<Object> GetDataProperty(LookupIterator* it);
|
||||
|
||||
DECLARE_CAST(JSObject)
|
||||
|
||||
// Dispatched behavior.
|
||||
|
@ -236,7 +236,7 @@ ADD_STRONG = function ADD_STRONG(x) {
|
||||
if (IS_NUMBER(this) && IS_NUMBER(x)) return %NumberAdd(this, x);
|
||||
if (IS_STRING(this) && IS_STRING(x)) return %_StringAdd(this, x);
|
||||
|
||||
throw %MakeTypeError('strong_implicit_cast');
|
||||
throw %MakeTypeError(kStrongImplicitCast);
|
||||
}
|
||||
|
||||
|
||||
@ -260,7 +260,7 @@ STRING_ADD_LEFT_STRONG = function STRING_ADD_LEFT_STRONG(y) {
|
||||
if (IS_STRING(y)) {
|
||||
return %_StringAdd(this, y);
|
||||
}
|
||||
throw %MakeTypeError('strong_implicit_cast');
|
||||
throw %MakeTypeError(kStrongImplicitCast);
|
||||
}
|
||||
|
||||
|
||||
@ -285,7 +285,7 @@ STRING_ADD_RIGHT_STRONG = function STRING_ADD_RIGHT_STRONG(y) {
|
||||
if (IS_STRING(this)) {
|
||||
return %_StringAdd(this, y);
|
||||
}
|
||||
throw %MakeTypeError('strong_implicit_cast');
|
||||
throw %MakeTypeError(kStrongImplicitCast);
|
||||
}
|
||||
|
||||
|
||||
@ -302,7 +302,7 @@ SUB_STRONG = function SUB_STRONG(y) {
|
||||
if (IS_NUMBER(this) && IS_NUMBER(y)) {
|
||||
return %NumberSub(this, y);
|
||||
}
|
||||
throw %MakeTypeError('strong_implicit_cast');
|
||||
throw %MakeTypeError(kStrongImplicitCast);
|
||||
}
|
||||
|
||||
|
||||
@ -319,7 +319,7 @@ MUL_STRONG = function MUL_STRONG(y) {
|
||||
if (IS_NUMBER(this) && IS_NUMBER(y)) {
|
||||
return %NumberMul(this, y);
|
||||
}
|
||||
throw %MakeTypeError('strong_implicit_cast');
|
||||
throw %MakeTypeError(kStrongImplicitCast);
|
||||
}
|
||||
|
||||
|
||||
@ -336,7 +336,7 @@ DIV_STRONG = function DIV_STRONG(y) {
|
||||
if (IS_NUMBER(this) && IS_NUMBER(y)) {
|
||||
return %NumberDiv(this, y);
|
||||
}
|
||||
throw %MakeTypeError('strong_implicit_cast');
|
||||
throw %MakeTypeError(kStrongImplicitCast);
|
||||
}
|
||||
|
||||
|
||||
@ -353,7 +353,7 @@ MOD_STRONG = function MOD_STRONG(y) {
|
||||
if (IS_NUMBER(this) && IS_NUMBER(y)) {
|
||||
return %NumberMod(this, y);
|
||||
}
|
||||
throw %MakeTypeError('strong_implicit_cast');
|
||||
throw %MakeTypeError(kStrongImplicitCast);
|
||||
}
|
||||
|
||||
|
||||
@ -375,7 +375,7 @@ BIT_OR_STRONG = function BIT_OR_STRONG(y) {
|
||||
if (IS_NUMBER(this) && IS_NUMBER(y)) {
|
||||
return %NumberOr(this, y);
|
||||
}
|
||||
throw %MakeTypeError('strong_implicit_cast');
|
||||
throw %MakeTypeError(kStrongImplicitCast);
|
||||
}
|
||||
|
||||
|
||||
@ -406,7 +406,7 @@ BIT_AND_STRONG = function BIT_AND_STRONG(y) {
|
||||
if (IS_NUMBER(this) && IS_NUMBER(y)) {
|
||||
return %NumberAnd(this, y);
|
||||
}
|
||||
throw %MakeTypeError('strong_implicit_cast');
|
||||
throw %MakeTypeError(kStrongImplicitCast);
|
||||
}
|
||||
|
||||
|
||||
@ -423,7 +423,7 @@ BIT_XOR_STRONG = function BIT_XOR_STRONG(y) {
|
||||
if (IS_NUMBER(this) && IS_NUMBER(y)) {
|
||||
return %NumberXor(this, y);
|
||||
}
|
||||
throw %MakeTypeError('strong_implicit_cast');
|
||||
throw %MakeTypeError(kStrongImplicitCast);
|
||||
}
|
||||
|
||||
|
||||
@ -440,7 +440,7 @@ SHL_STRONG = function SHL_STRONG(y) {
|
||||
if (IS_NUMBER(this) && IS_NUMBER(y)) {
|
||||
return %NumberShl(this, y);
|
||||
}
|
||||
throw %MakeTypeError('strong_implicit_cast');
|
||||
throw %MakeTypeError(kStrongImplicitCast);
|
||||
}
|
||||
|
||||
|
||||
@ -471,7 +471,7 @@ SAR_STRONG = function SAR_STRONG(y) {
|
||||
if (IS_NUMBER(this) && IS_NUMBER(y)) {
|
||||
return %NumberSar(this, y);
|
||||
}
|
||||
throw %MakeTypeError('strong_implicit_cast');
|
||||
throw %MakeTypeError(kStrongImplicitCast);
|
||||
}
|
||||
|
||||
|
||||
@ -488,7 +488,7 @@ SHR_STRONG = function SHR_STRONG(y) {
|
||||
if (IS_NUMBER(this) && IS_NUMBER(y)) {
|
||||
return %NumberShr(this, y);
|
||||
}
|
||||
throw %MakeTypeError('strong_implicit_cast');
|
||||
throw %MakeTypeError(kStrongImplicitCast);
|
||||
}
|
||||
|
||||
|
||||
|
@ -52,7 +52,7 @@ RUNTIME_FUNCTION(Runtime_ThrowArrayNotSubclassableError) {
|
||||
|
||||
static Object* ThrowStaticPrototypeError(Isolate* isolate) {
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(
|
||||
isolate, NewTypeError("static_prototype", HandleVector<Object>(NULL, 0)));
|
||||
isolate, NewTypeError(MessageTemplate::kStaticPrototype));
|
||||
}
|
||||
|
||||
|
||||
@ -113,28 +113,25 @@ RUNTIME_FUNCTION(Runtime_DefineClass) {
|
||||
prototype_parent = isolate->factory()->null_value();
|
||||
} else if (super_class->IsSpecFunction()) {
|
||||
if (Handle<JSFunction>::cast(super_class)->shared()->is_generator()) {
|
||||
Handle<Object> args[1] = {super_class};
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(
|
||||
isolate,
|
||||
NewTypeError("extends_value_generator", HandleVector(args, 1)));
|
||||
NewTypeError(MessageTemplate::kExtendsValueGenerator, super_class));
|
||||
}
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
|
||||
isolate, prototype_parent,
|
||||
Runtime::GetObjectProperty(isolate, super_class,
|
||||
isolate->factory()->prototype_string()));
|
||||
if (!prototype_parent->IsNull() && !prototype_parent->IsSpecObject()) {
|
||||
Handle<Object> args[1] = {prototype_parent};
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(
|
||||
isolate, NewTypeError("prototype_parent_not_an_object",
|
||||
HandleVector(args, 1)));
|
||||
isolate, NewTypeError(MessageTemplate::kPrototypeParentNotAnObject,
|
||||
prototype_parent));
|
||||
}
|
||||
constructor_parent = super_class;
|
||||
} else {
|
||||
// TODO(arv): Should be IsConstructor.
|
||||
Handle<Object> args[1] = {super_class};
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(
|
||||
isolate,
|
||||
NewTypeError("extends_value_not_a_function", HandleVector(args, 1)));
|
||||
NewTypeError(MessageTemplate::kExtendsValueNotFunction, super_class));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "src/arguments.h"
|
||||
#include "src/date.h"
|
||||
#include "src/dateparser-inl.h"
|
||||
#include "src/messages.h"
|
||||
#include "src/runtime/runtime-utils.h"
|
||||
|
||||
namespace v8 {
|
||||
@ -62,8 +63,8 @@ RUNTIME_FUNCTION(Runtime_DateSetValue) {
|
||||
RUNTIME_FUNCTION(Runtime_ThrowNotDateError) {
|
||||
HandleScope scope(isolate);
|
||||
DCHECK(args.length() == 0);
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(
|
||||
isolate, NewTypeError("not_date_object", HandleVector<Object>(NULL, 0)));
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(isolate,
|
||||
NewTypeError(MessageTemplate::kNotDateObject));
|
||||
}
|
||||
|
||||
|
||||
@ -179,8 +180,7 @@ RUNTIME_FUNCTION(Runtime_DateField) {
|
||||
if (!obj->IsJSDate()) {
|
||||
HandleScope scope(isolate);
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(
|
||||
isolate,
|
||||
NewTypeError("not_date_object", HandleVector<Object>(NULL, 0)));
|
||||
isolate, NewTypeError(MessageTemplate::kNotDateObject));
|
||||
}
|
||||
JSDate* date = JSDate::cast(obj);
|
||||
if (index == 0) return date->value();
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "src/cpu-profiler.h"
|
||||
#include "src/deoptimizer.h"
|
||||
#include "src/frames.h"
|
||||
#include "src/messages.h"
|
||||
#include "src/runtime/runtime-utils.h"
|
||||
|
||||
namespace v8 {
|
||||
@ -610,8 +611,8 @@ RUNTIME_FUNCTION(Runtime_IsFunction) {
|
||||
RUNTIME_FUNCTION(Runtime_ThrowStrongModeTooFewArguments) {
|
||||
HandleScope scope(isolate);
|
||||
DCHECK(args.length() == 0);
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(
|
||||
isolate, NewTypeError("strong_arity", HandleVector<Object>(NULL, 0)));
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(isolate,
|
||||
NewTypeError(MessageTemplate::kStrongArity));
|
||||
}
|
||||
}
|
||||
} // namespace v8::internal
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "src/api-natives.h"
|
||||
#include "src/arguments.h"
|
||||
#include "src/i18n.h"
|
||||
#include "src/messages.h"
|
||||
#include "src/runtime/runtime-utils.h"
|
||||
|
||||
#include "unicode/brkiter.h"
|
||||
@ -234,7 +235,7 @@ RUNTIME_FUNCTION(Runtime_IsInitializedIntlObject) {
|
||||
Handle<JSObject> obj = Handle<JSObject>::cast(input);
|
||||
|
||||
Handle<Symbol> marker = isolate->factory()->intl_initialized_marker_symbol();
|
||||
Handle<Object> tag = JSObject::GetDataProperty(obj, marker);
|
||||
Handle<Object> tag = JSReceiver::GetDataProperty(obj, marker);
|
||||
return isolate->heap()->ToBoolean(!tag->IsUndefined());
|
||||
}
|
||||
|
||||
@ -251,7 +252,7 @@ RUNTIME_FUNCTION(Runtime_IsInitializedIntlObjectOfType) {
|
||||
Handle<JSObject> obj = Handle<JSObject>::cast(input);
|
||||
|
||||
Handle<Symbol> marker = isolate->factory()->intl_initialized_marker_symbol();
|
||||
Handle<Object> tag = JSObject::GetDataProperty(obj, marker);
|
||||
Handle<Object> tag = JSReceiver::GetDataProperty(obj, marker);
|
||||
return isolate->heap()->ToBoolean(tag->IsString() &&
|
||||
String::cast(*tag)->Equals(*expected_type));
|
||||
}
|
||||
@ -281,23 +282,21 @@ RUNTIME_FUNCTION(Runtime_GetImplFromInitializedIntlObject) {
|
||||
|
||||
DCHECK(args.length() == 1);
|
||||
|
||||
CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
|
||||
CONVERT_ARG_HANDLE_CHECKED(JSObject, input, 0);
|
||||
|
||||
if (!input->IsJSObject()) {
|
||||
Vector<Handle<Object> > arguments = HandleVector(&input, 1);
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(isolate,
|
||||
NewTypeError("not_intl_object", arguments));
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(
|
||||
isolate, NewTypeError(MessageTemplate::kNotIntlObject, input));
|
||||
}
|
||||
|
||||
Handle<JSObject> obj = Handle<JSObject>::cast(input);
|
||||
|
||||
Handle<Symbol> marker = isolate->factory()->intl_impl_object_symbol();
|
||||
|
||||
Handle<Object> impl = JSObject::GetDataProperty(obj, marker);
|
||||
Handle<Object> impl = JSReceiver::GetDataProperty(obj, marker);
|
||||
if (impl->IsTheHole()) {
|
||||
Vector<Handle<Object> > arguments = HandleVector(&obj, 1);
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(isolate,
|
||||
NewTypeError("not_intl_object", arguments));
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(
|
||||
isolate, NewTypeError(MessageTemplate::kNotIntlObject, obj));
|
||||
}
|
||||
return *impl;
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ RUNTIME_FUNCTION(Runtime_PromiseRejectEvent) {
|
||||
if (debug_event) isolate->debug()->OnPromiseReject(promise, value);
|
||||
Handle<Symbol> key = isolate->factory()->promise_has_handler_symbol();
|
||||
// Do not report if we actually have a handler.
|
||||
if (JSObject::GetDataProperty(promise, key)->IsUndefined()) {
|
||||
if (JSReceiver::GetDataProperty(promise, key)->IsUndefined()) {
|
||||
isolate->ReportPromiseReject(promise, value,
|
||||
v8::kPromiseRejectWithNoHandler);
|
||||
}
|
||||
@ -93,7 +93,7 @@ RUNTIME_FUNCTION(Runtime_PromiseRevokeReject) {
|
||||
CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0);
|
||||
Handle<Symbol> key = isolate->factory()->promise_has_handler_symbol();
|
||||
// At this point, no revocation has been issued before
|
||||
RUNTIME_ASSERT(JSObject::GetDataProperty(promise, key)->IsUndefined());
|
||||
RUNTIME_ASSERT(JSReceiver::GetDataProperty(promise, key)->IsUndefined());
|
||||
isolate->ReportPromiseReject(promise, Handle<Object>(),
|
||||
v8::kPromiseHandlerAddedAfterReject);
|
||||
return isolate->heap()->undefined_value();
|
||||
|
@ -70,10 +70,10 @@ MaybeHandle<Object> Runtime::GetObjectProperty(Isolate* isolate,
|
||||
Handle<Object> object,
|
||||
Handle<Object> key) {
|
||||
if (object->IsUndefined() || object->IsNull()) {
|
||||
Handle<Object> args[2] = {key, object};
|
||||
THROW_NEW_ERROR(isolate, NewTypeError("non_object_property_load",
|
||||
HandleVector(args, 2)),
|
||||
Object);
|
||||
THROW_NEW_ERROR(
|
||||
isolate,
|
||||
NewTypeError(MessageTemplate::kNonObjectPropertyLoad, key, object),
|
||||
Object);
|
||||
}
|
||||
|
||||
// Check if the given key is an array index.
|
||||
@ -102,10 +102,10 @@ MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate,
|
||||
Handle<Object> value,
|
||||
LanguageMode language_mode) {
|
||||
if (object->IsUndefined() || object->IsNull()) {
|
||||
Handle<Object> args[2] = {key, object};
|
||||
THROW_NEW_ERROR(isolate, NewTypeError("non_object_property_store",
|
||||
HandleVector(args, 2)),
|
||||
Object);
|
||||
THROW_NEW_ERROR(
|
||||
isolate,
|
||||
NewTypeError(MessageTemplate::kNonObjectPropertyStore, key, object),
|
||||
Object);
|
||||
}
|
||||
|
||||
if (object->IsJSProxy()) {
|
||||
@ -1419,9 +1419,9 @@ RUNTIME_FUNCTION(Runtime_DefineDataPropertyUnchecked) {
|
||||
RUNTIME_FUNCTION(Runtime_GetDataProperty) {
|
||||
HandleScope scope(isolate);
|
||||
DCHECK(args.length() == 2);
|
||||
CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
|
||||
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0);
|
||||
CONVERT_ARG_HANDLE_CHECKED(Name, key, 1);
|
||||
return *JSObject::GetDataProperty(object, key);
|
||||
return *JSReceiver::GetDataProperty(object, key);
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,17 +17,15 @@ namespace internal {
|
||||
|
||||
static Object* ThrowRedeclarationError(Isolate* isolate, Handle<String> name) {
|
||||
HandleScope scope(isolate);
|
||||
Handle<Object> args[1] = {name};
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(
|
||||
isolate, NewTypeError("var_redeclaration", HandleVector(args, 1)));
|
||||
isolate, NewTypeError(MessageTemplate::kVarRedeclaration, name));
|
||||
}
|
||||
|
||||
|
||||
RUNTIME_FUNCTION(Runtime_ThrowConstAssignError) {
|
||||
HandleScope scope(isolate);
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(
|
||||
isolate,
|
||||
NewTypeError("const_assign", HandleVector<Object>(NULL, 0)));
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(isolate,
|
||||
NewTypeError(MessageTemplate::kConstAssign));
|
||||
}
|
||||
|
||||
|
||||
@ -1019,8 +1017,7 @@ RUNTIME_FUNCTION(Runtime_StoreLookupSlot) {
|
||||
} else if (is_strict(language_mode)) {
|
||||
// Setting read only property in strict mode.
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(
|
||||
isolate,
|
||||
NewTypeError("strict_cannot_assign", HandleVector(&name, 1)));
|
||||
isolate, NewTypeError(MessageTemplate::kStrictCannotAssign, name));
|
||||
}
|
||||
return *value;
|
||||
}
|
||||
@ -1111,8 +1108,7 @@ RUNTIME_FUNCTION(Runtime_GetArgumentsProperty) {
|
||||
JSFunction* function = frame->function();
|
||||
if (is_strict(function->shared()->language_mode())) {
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(
|
||||
isolate, NewTypeError("strict_arguments_callee",
|
||||
HandleVector<Object>(NULL, 0)));
|
||||
isolate, NewTypeError(MessageTemplate::kStrictPoisonPill));
|
||||
}
|
||||
return function;
|
||||
}
|
||||
|
@ -634,7 +634,7 @@ UNINITIALIZED_DEPENDENT_TEST(CustomContextDeserialization,
|
||||
CHECK(context->global_proxy() == *global_proxy);
|
||||
Handle<String> o = isolate->factory()->NewStringFromAsciiChecked("o");
|
||||
Handle<JSObject> global_object(context->global_object(), isolate);
|
||||
Handle<Object> property = JSObject::GetDataProperty(global_object, o);
|
||||
Handle<Object> property = JSReceiver::GetDataProperty(global_object, o);
|
||||
CHECK(property.is_identical_to(global_proxy));
|
||||
|
||||
v8::Handle<v8::Context> v8_context = v8::Utils::ToLocal(context);
|
||||
@ -1009,11 +1009,11 @@ TEST(SerializeToplevelLargeStrings) {
|
||||
Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked();
|
||||
|
||||
CHECK_EQ(6 * 1999999, Handle<String>::cast(copy_result)->length());
|
||||
Handle<Object> property = JSObject::GetDataProperty(
|
||||
Handle<Object> property = JSReceiver::GetDataProperty(
|
||||
isolate->global_object(), f->NewStringFromAsciiChecked("s"));
|
||||
CHECK(isolate->heap()->InSpace(HeapObject::cast(*property), LO_SPACE));
|
||||
property = JSObject::GetDataProperty(isolate->global_object(),
|
||||
f->NewStringFromAsciiChecked("t"));
|
||||
property = JSReceiver::GetDataProperty(isolate->global_object(),
|
||||
f->NewStringFromAsciiChecked("t"));
|
||||
CHECK(isolate->heap()->InSpace(HeapObject::cast(*property), LO_SPACE));
|
||||
// Make sure we do not serialize too much, e.g. include the source string.
|
||||
CHECK_LT(cache->length(), 13000000);
|
||||
|
@ -3,7 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flags: --stack-size=100 --harmony --harmony-reflect --harmony-arrays
|
||||
// Flags: --harmony-regexps
|
||||
// Flags: --harmony-regexps --strong-mode
|
||||
|
||||
function test(f, expected, type) {
|
||||
try {
|
||||
@ -62,11 +62,30 @@ test(function() {
|
||||
Array.prototype.shift.call(null);
|
||||
}, "Array.prototype.shift called on null or undefined", TypeError);
|
||||
|
||||
// kCannotPreventExtExternalArray
|
||||
test(function() {
|
||||
Object.preventExtensions(new Uint16Array(1));
|
||||
}, "Cannot prevent extension of an object with external array elements", TypeError);
|
||||
|
||||
// kConstAssign
|
||||
test(function() {
|
||||
"use strict";
|
||||
const a = 1;
|
||||
a = 2;
|
||||
}, "Assignment to constant variable.", TypeError);
|
||||
|
||||
// kCannotConvertToPrimitive
|
||||
test(function() {
|
||||
[].join(Object(Symbol(1)));
|
||||
}, "Cannot convert object to primitive value", TypeError);
|
||||
|
||||
// kCircularStructure
|
||||
test(function() {
|
||||
var o = {};
|
||||
o.o = o;
|
||||
JSON.stringify(o);
|
||||
}, "Converting circular structure to JSON", TypeError);
|
||||
|
||||
// kConstructorNotFunction
|
||||
test(function() {
|
||||
Uint16Array(1);
|
||||
@ -160,6 +179,11 @@ test(function() {
|
||||
new Symbol();
|
||||
}, "Symbol is not a constructor", TypeError);
|
||||
|
||||
// kNotDateObject
|
||||
test(function() {
|
||||
Date.prototype.setHours.call(1);
|
||||
}, "this is not a Date object.", TypeError);
|
||||
|
||||
// kNotGeneric
|
||||
test(function() {
|
||||
String.prototype.toString.call(1);
|
||||
@ -204,6 +228,14 @@ test(function() {
|
||||
Object.defineProperty({}, "x", { get: 1 });
|
||||
}, "Getter must be a function: 1", TypeError);
|
||||
|
||||
// kObjectNotExtensible
|
||||
test(function() {
|
||||
"use strict";
|
||||
var o = {};
|
||||
Object.freeze(o);
|
||||
o.a = 1;
|
||||
}, "Can't add property a, object is not extensible", TypeError);
|
||||
|
||||
// kObjectSetterExpectingFunction
|
||||
test(function() {
|
||||
({}).__defineSetter__("x", 0);
|
||||
@ -248,6 +280,34 @@ test(function() {
|
||||
new Promise(1);
|
||||
}, "Promise resolver 1 is not a function", TypeError);
|
||||
|
||||
// kStrictDeleteProperty
|
||||
test(function() {
|
||||
"use strict";
|
||||
var o = {};
|
||||
Object.defineProperty(o, "p", { value: 1, writable: false });
|
||||
delete o.p;
|
||||
}, "Cannot delete property 'p' of #<Object>", TypeError);
|
||||
|
||||
// kStrictPoisonPill
|
||||
test(function() {
|
||||
"use strict";
|
||||
arguments.callee;
|
||||
}, "'caller', 'callee', and 'arguments' properties may not be accessed on " +
|
||||
"strict mode functions or the arguments objects for calls to them",
|
||||
TypeError);
|
||||
|
||||
// kStrictReadOnlyProperty
|
||||
test(function() {
|
||||
"use strict";
|
||||
(1).a = 1;
|
||||
}, "Cannot assign to read only property 'a' of 1", TypeError);
|
||||
|
||||
// kStrongImplicitCast
|
||||
test(function() {
|
||||
"use strong";
|
||||
"a" + 1;
|
||||
}, "In strong mode, implicit conversions are deprecated", TypeError);
|
||||
|
||||
// kSymbolToPrimitive
|
||||
test(function() {
|
||||
1 + Object(Symbol());
|
||||
|
Loading…
Reference in New Issue
Block a user