OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/contexts.h" | 10 #include "src/contexts.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 // properties. | 149 // properties. |
150 if (!object->map()->is_extensible()) return true; | 150 if (!object->map()->is_extensible()) return true; |
151 JSObject::SetOwnPropertyIgnoreAttributes(object, Utils::OpenHandle(*name), | 151 JSObject::SetOwnPropertyIgnoreAttributes(object, Utils::OpenHandle(*name), |
152 value, NONE).Check(); | 152 value, NONE).Check(); |
153 } | 153 } |
154 return true; | 154 return true; |
155 } | 155 } |
156 | 156 |
157 | 157 |
158 // | 158 // |
159 // Accessors::ArgumentsIterator | |
160 // | |
161 | |
162 | |
163 void Accessors::ArgumentsIteratorGetter( | |
164 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { | |
165 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | |
166 DisallowHeapAllocation no_allocation; | |
167 HandleScope scope(isolate); | |
168 Object* result = isolate->native_context()->array_values_iterator(); | |
169 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate))); | |
170 } | |
171 | |
172 | |
173 void Accessors::ArgumentsIteratorSetter( | |
174 v8::Local<v8::Name> name, v8::Local<v8::Value> val, | |
175 const v8::PropertyCallbackInfo<void>& info) { | |
176 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | |
177 HandleScope scope(isolate); | |
178 Handle<JSObject> object = Utils::OpenHandle(*info.This()); | |
179 Handle<Object> value = Utils::OpenHandle(*val); | |
180 LookupIterator it(object, Utils::OpenHandle(*name)); | |
181 // Advance the iterator to find out more about the property. | |
182 bool has_property = it.HasProperty(); | |
183 DCHECK(has_property); | |
184 MaybeHandle<Object> maybe = Object::SetDataProperty(&it, value); | |
Toon Verwaest
2014/08/18 13:47:25
This doesn't seem right to me, if only because the
arv (Not doing code reviews)
2014/08/18 14:16:56
The intent is to replace the existing interceptor
wingo
2014/08/20 15:46:57
As Erik says the intent is that arguments[@@iterat
Toon Verwaest
2014/08/21 11:07:20
To be clear what I meant, what about:
o = {__prot
| |
185 maybe.Check(); | |
186 } | |
187 | |
188 | |
189 Handle<AccessorInfo> Accessors::ArgumentsIteratorInfo( | |
190 Isolate* isolate, PropertyAttributes attributes) { | |
191 return MakeAccessor(isolate, isolate->factory()->length_string(), | |
Toon Verwaest
2014/08/21 11:07:20
Ok, in that case this is part of what confused me.
| |
192 &ArgumentsIteratorGetter, &ArgumentsIteratorSetter, | |
193 attributes); | |
194 } | |
195 | |
196 | |
197 // | |
159 // Accessors::ArrayLength | 198 // Accessors::ArrayLength |
160 // | 199 // |
161 | 200 |
162 | 201 |
163 // The helper function will 'flatten' Number objects. | 202 // The helper function will 'flatten' Number objects. |
164 Handle<Object> Accessors::FlattenNumber(Isolate* isolate, | 203 Handle<Object> Accessors::FlattenNumber(Isolate* isolate, |
165 Handle<Object> value) { | 204 Handle<Object> value) { |
166 if (value->IsNumber() || !value->IsJSValue()) return value; | 205 if (value->IsNumber() || !value->IsJSValue()) return value; |
167 Handle<JSValue> wrapper = Handle<JSValue>::cast(value); | 206 Handle<JSValue> wrapper = Handle<JSValue>::cast(value); |
168 DCHECK(wrapper->GetIsolate()->native_context()->number_function()-> | 207 DCHECK(wrapper->GetIsolate()->native_context()->number_function()-> |
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1354 info->set_data(Smi::FromInt(index)); | 1393 info->set_data(Smi::FromInt(index)); |
1355 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); | 1394 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); |
1356 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); | 1395 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); |
1357 info->set_getter(*getter); | 1396 info->set_getter(*getter); |
1358 if (!(attributes & ReadOnly)) info->set_setter(*setter); | 1397 if (!(attributes & ReadOnly)) info->set_setter(*setter); |
1359 return info; | 1398 return info; |
1360 } | 1399 } |
1361 | 1400 |
1362 | 1401 |
1363 } } // namespace v8::internal | 1402 } } // namespace v8::internal |
OLD | NEW |