#include "src/api.h"
#include "src/isolate.h"
#include "src/lookup.h"
+#include "src/messages.h"
namespace v8 {
namespace internal {
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
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);
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();
}
#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"
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));
}
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();
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);
}
}
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);
}
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();
}
}
-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);
}
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() {
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);
}
#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"
}
-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);
}
// 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
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 =
// 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.
#include "src/ic/ic-state.h"
#include "src/macro-assembler.h"
+#include "src/messages.h"
namespace v8 {
namespace internal {
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.
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.
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>();
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);
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;
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);
#include "src/v8.h"
#include "src/conversions.h"
+#include "src/messages.h"
#include "src/string-builder.h"
#include "src/utils.h"
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;
}
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();
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();
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_);
}
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'") \
"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 %") \
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: %") \
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") \
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") \
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 */ \
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"],
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"],
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"],
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"],
}
-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:
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);
}
}
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);
}
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();
}
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);
}
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);
}
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();
}
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();
// 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.
// 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;
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);
}
// 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);
}
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);
}
}
}
} 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);
}
}
} 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);
}
}
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.
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);
}
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();
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.
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);
}
if (IS_STRING(y)) {
return %_StringAdd(this, y);
}
- throw %MakeTypeError('strong_implicit_cast');
+ throw %MakeTypeError(kStrongImplicitCast);
}
if (IS_STRING(this)) {
return %_StringAdd(this, y);
}
- throw %MakeTypeError('strong_implicit_cast');
+ throw %MakeTypeError(kStrongImplicitCast);
}
if (IS_NUMBER(this) && IS_NUMBER(y)) {
return %NumberSub(this, y);
}
- throw %MakeTypeError('strong_implicit_cast');
+ throw %MakeTypeError(kStrongImplicitCast);
}
if (IS_NUMBER(this) && IS_NUMBER(y)) {
return %NumberMul(this, y);
}
- throw %MakeTypeError('strong_implicit_cast');
+ throw %MakeTypeError(kStrongImplicitCast);
}
if (IS_NUMBER(this) && IS_NUMBER(y)) {
return %NumberDiv(this, y);
}
- throw %MakeTypeError('strong_implicit_cast');
+ throw %MakeTypeError(kStrongImplicitCast);
}
if (IS_NUMBER(this) && IS_NUMBER(y)) {
return %NumberMod(this, y);
}
- throw %MakeTypeError('strong_implicit_cast');
+ throw %MakeTypeError(kStrongImplicitCast);
}
if (IS_NUMBER(this) && IS_NUMBER(y)) {
return %NumberOr(this, y);
}
- throw %MakeTypeError('strong_implicit_cast');
+ throw %MakeTypeError(kStrongImplicitCast);
}
if (IS_NUMBER(this) && IS_NUMBER(y)) {
return %NumberAnd(this, y);
}
- throw %MakeTypeError('strong_implicit_cast');
+ throw %MakeTypeError(kStrongImplicitCast);
}
if (IS_NUMBER(this) && IS_NUMBER(y)) {
return %NumberXor(this, y);
}
- throw %MakeTypeError('strong_implicit_cast');
+ throw %MakeTypeError(kStrongImplicitCast);
}
if (IS_NUMBER(this) && IS_NUMBER(y)) {
return %NumberShl(this, y);
}
- throw %MakeTypeError('strong_implicit_cast');
+ throw %MakeTypeError(kStrongImplicitCast);
}
if (IS_NUMBER(this) && IS_NUMBER(y)) {
return %NumberSar(this, y);
}
- throw %MakeTypeError('strong_implicit_cast');
+ throw %MakeTypeError(kStrongImplicitCast);
}
if (IS_NUMBER(this) && IS_NUMBER(y)) {
return %NumberShr(this, y);
}
- throw %MakeTypeError('strong_implicit_cast');
+ throw %MakeTypeError(kStrongImplicitCast);
}
static Object* ThrowStaticPrototypeError(Isolate* isolate) {
THROW_NEW_ERROR_RETURN_FAILURE(
- isolate, NewTypeError("static_prototype", HandleVector<Object>(NULL, 0)));
+ isolate, NewTypeError(MessageTemplate::kStaticPrototype));
}
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));
}
}
#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 {
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));
}
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();
#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 {
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
#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"
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());
}
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));
}
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;
}
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);
}
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();
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.
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()) {
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);
}
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));
}
} 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;
}
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;
}
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);
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);
// 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 {
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);
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);
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);
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());