| 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/builtins.h" | 5 #include "src/builtins.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" |
| 9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
| 10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
| (...skipping 1440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 | 1451 |
| 1452 Handle<Name> name; | 1452 Handle<Name> name; |
| 1453 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, | 1453 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, |
| 1454 Object::ToName(isolate, key)); | 1454 Object::ToName(isolate, key)); |
| 1455 | 1455 |
| 1456 PropertyDescriptor desc; | 1456 PropertyDescriptor desc; |
| 1457 if (!PropertyDescriptor::ToPropertyDescriptor(isolate, attributes, &desc)) { | 1457 if (!PropertyDescriptor::ToPropertyDescriptor(isolate, attributes, &desc)) { |
| 1458 return isolate->heap()->exception(); | 1458 return isolate->heap()->exception(); |
| 1459 } | 1459 } |
| 1460 | 1460 |
| 1461 bool result = | 1461 Maybe<bool> result = |
| 1462 JSReceiver::DefineOwnProperty(isolate, Handle<JSReceiver>::cast(target), | 1462 JSReceiver::DefineOwnProperty(isolate, Handle<JSReceiver>::cast(target), |
| 1463 name, &desc, Object::DONT_THROW); | 1463 name, &desc, Object::DONT_THROW); |
| 1464 if (isolate->has_pending_exception()) return isolate->heap()->exception(); | 1464 MAYBE_RETURN(result, isolate->heap()->exception()); |
| 1465 // TODO(neis): Make DefineOwnProperty return Maybe<bool>. | 1465 return *isolate->factory()->ToBoolean(result.FromJust()); |
| 1466 return *isolate->factory()->ToBoolean(result); | |
| 1467 } | 1466 } |
| 1468 | 1467 |
| 1469 | 1468 |
| 1470 // ES6 section 26.1.4 Reflect.deleteProperty | 1469 // ES6 section 26.1.4 Reflect.deleteProperty |
| 1471 BUILTIN(ReflectDeleteProperty) { | 1470 BUILTIN(ReflectDeleteProperty) { |
| 1472 HandleScope scope(isolate); | 1471 HandleScope scope(isolate); |
| 1473 DCHECK_EQ(3, args.length()); | 1472 DCHECK_EQ(3, args.length()); |
| 1474 Handle<Object> target = args.at<Object>(1); | 1473 Handle<Object> target = args.at<Object>(1); |
| 1475 Handle<Object> key = args.at<Object>(2); | 1474 Handle<Object> key = args.at<Object>(2); |
| 1476 | 1475 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1532 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject, | 1531 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject, |
| 1533 isolate->factory()->NewStringFromAsciiChecked( | 1532 isolate->factory()->NewStringFromAsciiChecked( |
| 1534 "Reflect.getOwnPropertyDescriptor"))); | 1533 "Reflect.getOwnPropertyDescriptor"))); |
| 1535 } | 1534 } |
| 1536 | 1535 |
| 1537 Handle<Name> name; | 1536 Handle<Name> name; |
| 1538 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, | 1537 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, |
| 1539 Object::ToName(isolate, key)); | 1538 Object::ToName(isolate, key)); |
| 1540 | 1539 |
| 1541 PropertyDescriptor desc; | 1540 PropertyDescriptor desc; |
| 1542 bool found = JSReceiver::GetOwnPropertyDescriptor( | 1541 Maybe<bool> found = JSReceiver::GetOwnPropertyDescriptor( |
| 1543 isolate, Handle<JSReceiver>::cast(target), name, &desc); | 1542 isolate, Handle<JSReceiver>::cast(target), name, &desc); |
| 1544 if (isolate->has_pending_exception()) return isolate->heap()->exception(); | 1543 MAYBE_RETURN(found, isolate->heap()->exception()); |
| 1545 if (!found) return isolate->heap()->undefined_value(); | 1544 if (!found.FromJust()) return isolate->heap()->undefined_value(); |
| 1546 return *desc.ToObject(isolate); | 1545 return *desc.ToObject(isolate); |
| 1547 } | 1546 } |
| 1548 | 1547 |
| 1549 | 1548 |
| 1550 // ES6 section 26.1.8 Reflect.getPrototypeOf | 1549 // ES6 section 26.1.8 Reflect.getPrototypeOf |
| 1551 BUILTIN(ReflectGetPrototypeOf) { | 1550 BUILTIN(ReflectGetPrototypeOf) { |
| 1552 HandleScope scope(isolate); | 1551 HandleScope scope(isolate); |
| 1553 DCHECK_EQ(2, args.length()); | 1552 DCHECK_EQ(2, args.length()); |
| 1554 Handle<Object> target = args.at<Object>(1); | 1553 Handle<Object> target = args.at<Object>(1); |
| 1555 | 1554 |
| (...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2438 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 2437 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
| 2439 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 2438 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 2440 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 2439 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
| 2441 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 2440 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 2442 #undef DEFINE_BUILTIN_ACCESSOR_C | 2441 #undef DEFINE_BUILTIN_ACCESSOR_C |
| 2443 #undef DEFINE_BUILTIN_ACCESSOR_A | 2442 #undef DEFINE_BUILTIN_ACCESSOR_A |
| 2444 | 2443 |
| 2445 | 2444 |
| 2446 } // namespace internal | 2445 } // namespace internal |
| 2447 } // namespace v8 | 2446 } // namespace v8 |
| OLD | NEW |