public:
V8_INLINE Isolate* GetIsolate() const;
V8_INLINE Local<Value> Data() const;
- V8_INLINE Local<Object> This() const;
+ V8_INLINE Local<Value> This() const;
V8_INLINE Local<Object> Holder() const;
V8_INLINE ReturnValue<T> GetReturnValue() const;
// This shouldn't be public, but the arm compiler needs it.
template<typename T>
-Local<Object> PropertyCallbackInfo<T>::This() const {
- return Local<Object>(reinterpret_cast<Object*>(&args_[kThisIndex]));
+Local<Value> PropertyCallbackInfo<T>::This() const {
+ return Local<Value>(reinterpret_cast<Value*>(&args_[kThisIndex]));
}
const v8::PropertyCallbackInfo<void>& info) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
HandleScope scope(isolate);
- Handle<JSObject> object = Utils::OpenHandle(*info.This());
+ Handle<JSObject> object =
+ Handle<JSObject>::cast(Utils::OpenHandle(*info.This()));
Handle<Object> value = Utils::OpenHandle(*val);
SetFunctionPrototype(isolate, object, value);
V(Script, JSFunction) \
V(UnboundScript, SharedFunctionInfo) \
V(Function, JSFunction) \
- V(Message, JSObject) \
+ V(Message, JSMessageObject) \
V(Context, Context) \
- V(External, Foreign) \
+ V(External, Object) \
V(StackTrace, JSArray) \
V(StackFrame, JSObject) \
V(DeclaredAccessorDescriptor, DeclaredAccessorDescriptor)
const v8::From* that, bool allow_empty_handle) { \
EXTRA_CHECK(allow_empty_handle || that != NULL); \
EXTRA_CHECK(that == NULL || \
- !(*reinterpret_cast<v8::internal::To**>( \
- const_cast<v8::From*>(that)))->IsFailure()); \
+ (*reinterpret_cast<v8::internal::Object**>( \
+ const_cast<v8::From*>(that)))->Is##To()); \
return v8::internal::Handle<v8::internal::To>( \
reinterpret_cast<v8::internal::To**>(const_cast<v8::From*>(that))); \
}
}
+bool Object::IsTemplateInfo() {
+ return IsObjectTemplateInfo() || IsFunctionTemplateInfo();
+}
+
+
bool Object::IsInternalizedString() {
if (!this->IsHeapObject()) return false;
uint32_t type = HeapObject::cast(this)->map()->instance_type();
FixedArray);
ASSIGN_RETURN_ON_EXCEPTION(
isolate, content,
- FixedArray::AddKeysFromJSArray(
- content, Handle<JSArray>::cast(names)),
+ FixedArray::AddKeysFromArrayLike(
+ content, Handle<JSObject>::cast(names)),
FixedArray);
break;
}
// Add the element keys from the interceptor.
if (current->HasIndexedInterceptor()) {
- Handle<JSArray> result;
+ Handle<JSObject> result;
if (JSObject::GetKeysForIndexedInterceptor(
current, object).ToHandle(&result)) {
ASSIGN_RETURN_ON_EXCEPTION(
isolate, content,
- FixedArray::AddKeysFromJSArray(content, result),
+ FixedArray::AddKeysFromArrayLike(content, result),
FixedArray);
}
ASSERT(ContainsOnlyValidKeys(content));
// Add the property keys from the interceptor.
if (current->HasNamedInterceptor()) {
- Handle<JSArray> result;
+ Handle<JSObject> result;
if (JSObject::GetKeysForNamedInterceptor(
current, object).ToHandle(&result)) {
ASSIGN_RETURN_ON_EXCEPTION(
isolate, content,
- FixedArray::AddKeysFromJSArray(content, result),
+ FixedArray::AddKeysFromArrayLike(content, result),
FixedArray);
}
ASSERT(ContainsOnlyValidKeys(content));
}
-MaybeHandle<FixedArray> FixedArray::AddKeysFromJSArray(
+MaybeHandle<FixedArray> FixedArray::AddKeysFromArrayLike(
Handle<FixedArray> content,
- Handle<JSArray> array) {
+ Handle<JSObject> array) {
+ ASSERT(array->IsJSArray() || array->HasSloppyArgumentsElements());
ElementsAccessor* accessor = array->GetElementsAccessor();
Handle<FixedArray> result;
ASSIGN_RETURN_ON_EXCEPTION(
// Compute the property keys from the interceptor.
// TODO(rossberg): support symbols in API, and filter here if needed.
-MaybeHandle<JSArray> JSObject::GetKeysForNamedInterceptor(
+MaybeHandle<JSObject> JSObject::GetKeysForNamedInterceptor(
Handle<JSObject> object, Handle<JSReceiver> receiver) {
Isolate* isolate = receiver->GetIsolate();
Handle<InterceptorInfo> interceptor(object->GetNamedInterceptor());
PropertyCallbackArguments
args(isolate, interceptor->data(), *receiver, *object);
- v8::Handle<v8::Array> result;
+ v8::Handle<v8::Object> result;
if (!interceptor->enumerator()->IsUndefined()) {
v8::NamedPropertyEnumeratorCallback enum_fun =
v8::ToCData<v8::NamedPropertyEnumeratorCallback>(
LOG(isolate, ApiObjectAccess("interceptor-named-enum", *object));
result = args.Call(enum_fun);
}
- if (result.IsEmpty()) return MaybeHandle<JSArray>();
+ if (result.IsEmpty()) return MaybeHandle<JSObject>();
#if ENABLE_EXTRA_CHECKS
- CHECK(v8::Utils::OpenHandle(*result)->IsJSObject());
+ CHECK(v8::Utils::OpenHandle(*result)->IsJSArray() ||
+ v8::Utils::OpenHandle(*result)->HasSloppyArgumentsElements());
#endif
// Rebox before returning.
return handle(*v8::Utils::OpenHandle(*result), isolate);
// Compute the element keys from the interceptor.
-MaybeHandle<JSArray> JSObject::GetKeysForIndexedInterceptor(
+MaybeHandle<JSObject> JSObject::GetKeysForIndexedInterceptor(
Handle<JSObject> object, Handle<JSReceiver> receiver) {
Isolate* isolate = receiver->GetIsolate();
Handle<InterceptorInfo> interceptor(object->GetIndexedInterceptor());
PropertyCallbackArguments
args(isolate, interceptor->data(), *receiver, *object);
- v8::Handle<v8::Array> result;
+ v8::Handle<v8::Object> result;
if (!interceptor->enumerator()->IsUndefined()) {
v8::IndexedPropertyEnumeratorCallback enum_fun =
v8::ToCData<v8::IndexedPropertyEnumeratorCallback>(
LOG(isolate, ApiObjectAccess("interceptor-indexed-enum", *object));
result = args.Call(enum_fun);
}
- if (result.IsEmpty()) return MaybeHandle<JSArray>();
+ if (result.IsEmpty()) return MaybeHandle<JSObject>();
#if ENABLE_EXTRA_CHECKS
- CHECK(v8::Utils::OpenHandle(*result)->IsJSObject());
+ CHECK(v8::Utils::OpenHandle(*result)->IsJSArray() ||
+ v8::Utils::OpenHandle(*result)->HasSloppyArgumentsElements());
#endif
// Rebox before returning.
return handle(*v8::Utils::OpenHandle(*result), isolate);
CONSTANT_POOL_ARRAY_TYPE,
SHARED_FUNCTION_INFO_TYPE,
- JS_MESSAGE_OBJECT_TYPE,
-
// All the following types are subtypes of JSReceiver, which corresponds to
// objects in the JS sense. The first and the last type in this range are
// the two forms of function. This organization enables using the same
JS_PROXY_TYPE, // LAST_JS_PROXY_TYPE
JS_VALUE_TYPE, // FIRST_JS_OBJECT_TYPE
+ JS_MESSAGE_OBJECT_TYPE,
JS_DATE_TYPE,
JS_OBJECT_TYPE,
JS_CONTEXT_EXTENSION_OBJECT_TYPE,
INLINE(bool IsSpecObject());
INLINE(bool IsSpecFunction());
+ INLINE(bool IsTemplateInfo());
bool IsCallable();
// Oddball testing.
// Computes the enumerable keys from interceptors. Used for debug mirrors and
// by JSReceiver::GetKeys.
- MUST_USE_RESULT static MaybeHandle<JSArray> GetKeysForNamedInterceptor(
+ MUST_USE_RESULT static MaybeHandle<JSObject> GetKeysForNamedInterceptor(
Handle<JSObject> object,
Handle<JSReceiver> receiver);
- MUST_USE_RESULT static MaybeHandle<JSArray> GetKeysForIndexedInterceptor(
+ MUST_USE_RESULT static MaybeHandle<JSObject> GetKeysForIndexedInterceptor(
Handle<JSObject> object,
Handle<JSReceiver> receiver);
PretenureFlag pretenure = NOT_TENURED);
// Add the elements of a JSArray to this FixedArray.
- MUST_USE_RESULT static MaybeHandle<FixedArray> AddKeysFromJSArray(
+ MUST_USE_RESULT static MaybeHandle<FixedArray> AddKeysFromArrayLike(
Handle<FixedArray> content,
- Handle<JSArray> array);
+ Handle<JSObject> array);
// Computes the union of keys and return the result.
// Used for implementing "for (n in object) { }"
CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
if (obj->HasNamedInterceptor()) {
- Handle<JSArray> result;
+ Handle<JSObject> result;
if (JSObject::GetKeysForNamedInterceptor(obj, obj).ToHandle(&result)) {
return *result;
}
CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
if (obj->HasIndexedInterceptor()) {
- Handle<JSArray> result;
+ Handle<JSObject> result;
if (JSObject::GetKeysForIndexedInterceptor(obj, obj).ToHandle(&result)) {
return *result;
}
void SimpleAccessorGetter(Local<String> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
- Handle<Object> self = info.This();
+ Handle<Object> self = Handle<Object>::Cast(info.This());
info.GetReturnValue().Set(
self->Get(String::Concat(v8_str("accessor_"), name)));
}
void SimpleAccessorSetter(Local<String> name, Local<Value> value,
const v8::PropertyCallbackInfo<void>& info) {
- Handle<Object> self = info.This();
+ Handle<Object> self = Handle<Object>::Cast(info.This());
self->Set(String::Concat(v8_str("accessor_"), name), value);
}
for (i = 0; name_str[i] && prefix[i]; ++i) {
if (name_str[i] != prefix[i]) return;
}
- Handle<Object> self = info.This();
+ Handle<Object> self = Handle<Object>::Cast(info.This());
info.GetReturnValue().Set(self->GetHiddenValue(v8_str(name_str + i)));
}
if (!prefix[i]) return;
if (value->IsInt32() && value->Int32Value() < 10000) {
- Handle<Object> self = info.This();
+ Handle<Object> self = Handle<Object>::Cast(info.This());
self->SetHiddenValue(name, value);
info.GetReturnValue().Set(value);
}
static void YSetter(Local<String> name,
Local<Value> value,
const v8::PropertyCallbackInfo<void>& info) {
- if (info.This()->Has(name)) {
- info.This()->Delete(name);
- }
- info.This()->Set(name, value);
+ Local<Object> this_obj = Local<Object>::Cast(info.This());
+ if (this_obj->Has(name)) this_obj->Delete(name);
+ this_obj->Set(name, value);
}
static void SetOnThis(Local<String> name,
Local<Value> value,
const v8::PropertyCallbackInfo<void>& info) {
- info.This()->ForceSet(name, value);
+ Local<Object>::Cast(info.This())->ForceSet(name, value);
}
const v8::PropertyCallbackInfo<void>& info) {
CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject());
CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject());
- info.This()->Set(v8_str("y"), v8_num(23));
+ Local<Object>::Cast(info.This())->Set(v8_str("y"), v8_num(23));
}
CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject());
CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject());
if (!name->Equals(v8_str("foo"))) return;
- info.This()->Set(v8_str("y"), v8_num(23));
+ Local<Object>::Cast(info.This())->Set(v8_str("y"), v8_num(23));
info.GetReturnValue().Set(v8_num(23));
}
Local<Value> value,
const v8::PropertyCallbackInfo<v8::Value>& info) {
if (name->Equals(v8_str("x"))) {
- info.This()->Set(v8_str("y"), v8_num(23));
+ Local<Object>::Cast(info.This())->Set(v8_str("y"), v8_num(23));
}
}