Handlify JSReceiver::SetElement method.

R=rossberg@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16448 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 4cf77d77
......@@ -452,14 +452,17 @@ MaybeObject* JSProxy::GetElementWithHandler(Object* receiver,
}
MaybeObject* JSProxy::SetElementWithHandler(JSReceiver* receiver,
Handle<Object> JSProxy::SetElementWithHandler(Handle<JSProxy> proxy,
Handle<JSReceiver> receiver,
uint32_t index,
Object* value,
Handle<Object> value,
StrictModeFlag strict_mode) {
String* name;
MaybeObject* maybe = GetHeap()->Uint32ToString(index);
if (!maybe->To<String>(&name)) return maybe;
return SetPropertyWithHandler(receiver, name, value, NONE, strict_mode);
Isolate* isolate = proxy->GetIsolate();
Handle<String> name = isolate->factory()->Uint32ToString(index);
CALL_HEAP_FUNCTION(isolate,
proxy->SetPropertyWithHandler(
*receiver, *name, *value, NONE, strict_mode),
Object);
}
......@@ -3541,20 +3544,20 @@ MUST_USE_RESULT MaybeObject* JSProxy::SetPropertyViaPrototypesWithHandler(
Handle<Object> JSProxy::DeletePropertyWithHandler(
Handle<JSProxy> object, Handle<Name> name, DeleteMode mode) {
Isolate* isolate = object->GetIsolate();
Handle<JSProxy> proxy, Handle<Name> name, DeleteMode mode) {
Isolate* isolate = proxy->GetIsolate();
// TODO(rossberg): adjust once there is a story for symbols vs proxies.
if (name->IsSymbol()) return isolate->factory()->false_value();
Handle<Object> args[] = { name };
Handle<Object> result = object->CallTrap(
Handle<Object> result = proxy->CallTrap(
"delete", Handle<Object>(), ARRAY_SIZE(args), args);
if (isolate->has_pending_exception()) return Handle<Object>();
bool result_bool = result->BooleanValue();
if (mode == STRICT_DELETION && !result_bool) {
Handle<Object> handler(object->handler(), isolate);
Handle<Object> handler(proxy->handler(), isolate);
Handle<String> trap_name = isolate->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("delete"));
Handle<Object> args[] = { handler, trap_name };
......@@ -3568,10 +3571,10 @@ Handle<Object> JSProxy::DeletePropertyWithHandler(
Handle<Object> JSProxy::DeleteElementWithHandler(
Handle<JSProxy> object, uint32_t index, DeleteMode mode) {
Isolate* isolate = object->GetIsolate();
Handle<JSProxy> proxy, uint32_t index, DeleteMode mode) {
Isolate* isolate = proxy->GetIsolate();
Handle<String> name = isolate->factory()->Uint32ToString(index);
return JSProxy::DeletePropertyWithHandler(object, name, mode);
return JSProxy::DeletePropertyWithHandler(proxy, name, mode);
}
......@@ -12111,18 +12114,17 @@ MUST_USE_RESULT MaybeObject* JSObject::SetFastDoubleElement(
}
MaybeObject* JSReceiver::SetElement(uint32_t index,
Object* value,
Handle<Object> JSReceiver::SetElement(Handle<JSReceiver> object,
uint32_t index,
Handle<Object> value,
PropertyAttributes attributes,
StrictModeFlag strict_mode,
bool check_proto) {
if (IsJSProxy()) {
return JSProxy::cast(this)->SetElementWithHandler(
this, index, value, strict_mode);
} else {
return JSObject::cast(this)->SetElement(
index, value, attributes, strict_mode, check_proto);
StrictModeFlag strict_mode) {
if (object->IsJSProxy()) {
return JSProxy::SetElementWithHandler(
Handle<JSProxy>::cast(object), object, index, value, strict_mode);
}
return JSObject::SetElement(
Handle<JSObject>::cast(object), index, value, attributes, strict_mode);
}
......
......@@ -1936,6 +1936,11 @@ class JSReceiver: public HeapObject {
Handle<Object> value,
PropertyAttributes attributes,
StrictModeFlag strict_mode);
static Handle<Object> SetElement(Handle<JSReceiver> object,
uint32_t index,
Handle<Object> value,
PropertyAttributes attributes,
StrictModeFlag strict_mode);
MUST_USE_RESULT static MaybeObject* SetPropertyOrFail(
Handle<JSReceiver> object,
......@@ -1969,14 +1974,6 @@ class JSReceiver: public HeapObject {
uint32_t index,
DeleteMode mode = NORMAL_DELETION);
// Set the index'th array element.
// Can cause GC, or return failure if GC is required.
MUST_USE_RESULT MaybeObject* SetElement(uint32_t index,
Object* value,
PropertyAttributes attributes,
StrictModeFlag strict_mode,
bool check_prototype);
// Tests for the fast common case for property enumeration.
bool IsSimpleEnum();
......@@ -9088,11 +9085,6 @@ class JSProxy: public JSReceiver {
Object* value,
PropertyAttributes attributes,
StrictModeFlag strict_mode);
MUST_USE_RESULT MaybeObject* SetElementWithHandler(
JSReceiver* receiver,
uint32_t index,
Object* value,
StrictModeFlag strict_mode);
// If the handler defines an accessor property with a setter, invoke it.
// If it defines an accessor property without a setter, or a data property
......@@ -9151,10 +9143,16 @@ class JSProxy: public JSReceiver {
private:
friend class JSReceiver;
static Handle<Object> DeletePropertyWithHandler(Handle<JSProxy> object,
static Handle<Object> SetElementWithHandler(Handle<JSProxy> proxy,
Handle<JSReceiver> receiver,
uint32_t index,
Handle<Object> value,
StrictModeFlag strict_mode);
static Handle<Object> DeletePropertyWithHandler(Handle<JSProxy> proxy,
Handle<Name> name,
DeleteMode mode);
static Handle<Object> DeleteElementWithHandler(Handle<JSProxy> object,
static Handle<Object> DeleteElementWithHandler(Handle<JSProxy> proxy,
uint32_t index,
DeleteMode mode);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment