| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
| 9 #include "src/debug.h" | 9 #include "src/debug.h" |
| 10 #include "src/messages.h" | 10 #include "src/messages.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 if (name->AsArrayIndex(&index)) { | 167 if (name->AsArrayIndex(&index)) { |
| 168 // TODO(verwaest): Support non-JSObject receivers. | 168 // TODO(verwaest): Support non-JSObject receivers. |
| 169 if (!object->IsJSObject()) return value; | 169 if (!object->IsJSObject()) return value; |
| 170 Handle<JSObject> js_object = Handle<JSObject>::cast(object); | 170 Handle<JSObject> js_object = Handle<JSObject>::cast(object); |
| 171 return JSObject::SetElement(js_object, index, value, language_mode); | 171 return JSObject::SetElement(js_object, index, value, language_mode); |
| 172 } | 172 } |
| 173 return Object::SetProperty(object, name, value, language_mode); | 173 return Object::SetProperty(object, name, value, language_mode); |
| 174 } | 174 } |
| 175 | 175 |
| 176 | 176 |
| 177 MaybeHandle<Object> Runtime::DefineObjectProperty(Handle<JSObject> js_object, | 177 MaybeHandle<Object> Runtime::DefineObjectProperty( |
| 178 Handle<Object> key, | 178 Handle<JSObject> js_object, Handle<Object> key, Handle<Object> value, |
| 179 Handle<Object> value, | 179 PropertyAttributes attrs, |
| 180 PropertyAttributes attrs) { | 180 JSObject::ExecutableAccessorInfoHandling handling) { |
| 181 Isolate* isolate = js_object->GetIsolate(); | 181 Isolate* isolate = js_object->GetIsolate(); |
| 182 // Check if the given key is an array index. | 182 // Check if the given key is an array index. |
| 183 uint32_t index = 0; | 183 uint32_t index = 0; |
| 184 if (key->ToArrayIndex(&index)) { | 184 if (key->ToArrayIndex(&index)) { |
| 185 return JSObject::SetOwnElementIgnoreAttributes(js_object, index, value, | 185 return JSObject::SetOwnElementIgnoreAttributes(js_object, index, value, |
| 186 attrs); | 186 attrs, handling); |
| 187 } | 187 } |
| 188 | 188 |
| 189 Handle<Name> name; | 189 Handle<Name> name; |
| 190 if (key->IsName()) { | 190 if (key->IsName()) { |
| 191 name = Handle<Name>::cast(key); | 191 name = Handle<Name>::cast(key); |
| 192 } else { | 192 } else { |
| 193 // Call-back into JavaScript to convert the key to a string. | 193 // Call-back into JavaScript to convert the key to a string. |
| 194 Handle<Object> converted; | 194 Handle<Object> converted; |
| 195 ASSIGN_RETURN_ON_EXCEPTION(isolate, converted, | 195 ASSIGN_RETURN_ON_EXCEPTION(isolate, converted, |
| 196 Execution::ToString(isolate, key), Object); | 196 Execution::ToString(isolate, key), Object); |
| 197 name = Handle<String>::cast(converted); | 197 name = Handle<String>::cast(converted); |
| 198 } | 198 } |
| 199 | 199 |
| 200 if (name->AsArrayIndex(&index)) { | 200 if (name->AsArrayIndex(&index)) { |
| 201 return JSObject::SetOwnElementIgnoreAttributes(js_object, index, value, | 201 return JSObject::SetOwnElementIgnoreAttributes(js_object, index, value, |
| 202 attrs); | 202 attrs, handling); |
| 203 } else { | 203 } else { |
| 204 if (name->IsString()) name = String::Flatten(Handle<String>::cast(name)); | 204 if (name->IsString()) name = String::Flatten(Handle<String>::cast(name)); |
| 205 return JSObject::SetOwnPropertyIgnoreAttributes(js_object, name, value, | 205 return JSObject::SetOwnPropertyIgnoreAttributes(js_object, name, value, |
| 206 attrs); | 206 attrs, handling); |
| 207 } | 207 } |
| 208 } | 208 } |
| 209 | 209 |
| 210 | 210 |
| 211 MaybeHandle<Object> Runtime::GetPrototype(Isolate* isolate, | 211 MaybeHandle<Object> Runtime::GetPrototype(Isolate* isolate, |
| 212 Handle<Object> obj) { | 212 Handle<Object> obj) { |
| 213 // We don't expect access checks to be needed on JSProxy objects. | 213 // We don't expect access checks to be needed on JSProxy objects. |
| 214 DCHECK(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); | 214 DCHECK(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); |
| 215 PrototypeIterator iter(isolate, obj, PrototypeIterator::START_AT_RECEIVER); | 215 PrototypeIterator iter(isolate, obj, PrototypeIterator::START_AT_RECEIVER); |
| 216 do { | 216 do { |
| (...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1364 if (it.IsFound() && it.state() == LookupIterator::ACCESS_CHECK) { | 1364 if (it.IsFound() && it.state() == LookupIterator::ACCESS_CHECK) { |
| 1365 if (!isolate->MayAccess(js_object)) { | 1365 if (!isolate->MayAccess(js_object)) { |
| 1366 return isolate->heap()->undefined_value(); | 1366 return isolate->heap()->undefined_value(); |
| 1367 } | 1367 } |
| 1368 it.Next(); | 1368 it.Next(); |
| 1369 } | 1369 } |
| 1370 | 1370 |
| 1371 Handle<Object> result; | 1371 Handle<Object> result; |
| 1372 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1372 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 1373 isolate, result, | 1373 isolate, result, |
| 1374 Runtime::DefineObjectProperty(js_object, name, obj_value, attrs)); | 1374 Runtime::DefineObjectProperty(js_object, name, obj_value, attrs, |
| 1375 JSObject::DONT_FORCE_FIELD)); |
| 1375 return *result; | 1376 return *result; |
| 1376 } | 1377 } |
| 1377 | 1378 |
| 1378 | 1379 |
| 1379 // Return property without being observable by accessors or interceptors. | 1380 // Return property without being observable by accessors or interceptors. |
| 1380 RUNTIME_FUNCTION(Runtime_GetDataProperty) { | 1381 RUNTIME_FUNCTION(Runtime_GetDataProperty) { |
| 1381 HandleScope scope(isolate); | 1382 HandleScope scope(isolate); |
| 1382 DCHECK(args.length() == 2); | 1383 DCHECK(args.length() == 2); |
| 1383 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); | 1384 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); |
| 1384 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); | 1385 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1522 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); | 1523 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); |
| 1523 | 1524 |
| 1524 RETURN_FAILURE_ON_EXCEPTION( | 1525 RETURN_FAILURE_ON_EXCEPTION( |
| 1525 isolate, | 1526 isolate, |
| 1526 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), | 1527 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), |
| 1527 setter, attrs)); | 1528 setter, attrs)); |
| 1528 return isolate->heap()->undefined_value(); | 1529 return isolate->heap()->undefined_value(); |
| 1529 } | 1530 } |
| 1530 } // namespace internal | 1531 } // namespace internal |
| 1531 } // namespace v8 | 1532 } // namespace v8 |
| OLD | NEW |