Index: src/accessors.cc |
diff --git a/src/accessors.cc b/src/accessors.cc |
index c2361b3e9cda753c69ae5e12bb57ded05385cde8..dd09a69c5a0fd2431bdcf6bd9293cebb386b9477 100644 |
--- a/src/accessors.cc |
+++ b/src/accessors.cc |
@@ -156,6 +156,53 @@ bool SetPropertyOnInstanceIfInherited( |
// |
+// Accessors::ArgumentsIterator |
+// |
+ |
+ |
+void Accessors::ArgumentsIteratorGetter( |
+ v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { |
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
+ DisallowHeapAllocation no_allocation; |
+ HandleScope scope(isolate); |
+ Object* result = isolate->native_context()->array_values_iterator(); |
+ info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate))); |
+} |
+ |
+ |
+void Accessors::ArgumentsIteratorSetter( |
+ v8::Local<v8::Name> name, v8::Local<v8::Value> val, |
+ 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<Object> value = Utils::OpenHandle(*val); |
+ LookupIterator it(object, Utils::OpenHandle(*name)); |
Toon Verwaest
2014/08/22 11:01:02
What about just
if (SetPropertyOnInstanceIfInheri
wingo
2014/08/25 08:42:30
Done, works fine; thanks for the tip. The differe
|
+ if (it.HasProperty() && it.HolderIsReceiverOrHiddenPrototype()) { |
+ // The receiver is an arguments object. Replace this weird accessor with a |
+ // normal data property. |
+ Object::SetDataProperty(&it, value).Check(); |
+ } else { |
+ // The receiver has an arguments object on the proto chain. Add a new data |
+ // property to the receiver, if it's extensible. |
+ if (Object::AddDataProperty(&it, value, DONT_ENUM, STRICT, |
+ Object::CERTAINLY_NOT_STORE_FROM_KEYED) |
+ .is_null()) { |
+ isolate->OptionalRescheduleException(false); |
+ } |
+ } |
+} |
+ |
+ |
+Handle<AccessorInfo> Accessors::ArgumentsIteratorInfo( |
+ Isolate* isolate, PropertyAttributes attributes) { |
+ Handle<Name> name(isolate->native_context()->iterator_symbol(), isolate); |
+ return MakeAccessor(isolate, name, &ArgumentsIteratorGetter, |
+ &ArgumentsIteratorSetter, attributes); |
+} |
+ |
+ |
+// |
// Accessors::ArrayLength |
// |