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 1727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1738 HandleScope scope(isolate); | 1738 HandleScope scope(isolate); |
1739 // The ConstructStub is executed in the context of the caller, so we need | 1739 // The ConstructStub is executed in the context of the caller, so we need |
1740 // to enter the callee context first before raising an exception. | 1740 // to enter the callee context first before raising an exception. |
1741 isolate->set_context(args.target()->context()); | 1741 isolate->set_context(args.target()->context()); |
1742 THROW_NEW_ERROR_RETURN_FAILURE( | 1742 THROW_NEW_ERROR_RETURN_FAILURE( |
1743 isolate, NewTypeError(MessageTemplate::kNotConstructor, | 1743 isolate, NewTypeError(MessageTemplate::kNotConstructor, |
1744 isolate->factory()->Symbol_string())); | 1744 isolate->factory()->Symbol_string())); |
1745 } | 1745 } |
1746 | 1746 |
1747 | 1747 |
| 1748 namespace { |
| 1749 |
| 1750 // ES6 section 9.5.15 ProxyCreate (target, handler) |
| 1751 MaybeHandle<JSProxy> ProxyCreate(Isolate* isolate, Handle<Object> target, |
| 1752 Handle<Object> handler) { |
| 1753 if (!target->IsJSReceiver()) { |
| 1754 THROW_NEW_ERROR( |
| 1755 isolate, NewTypeError(MessageTemplate::kProxyTargetNonObject), JSProxy); |
| 1756 } |
| 1757 if (target->IsJSProxy() && JSProxy::cast(*target)->IsRevoked()) { |
| 1758 THROW_NEW_ERROR(isolate, |
| 1759 NewTypeError(MessageTemplate::kProxyHandlerOrTargetRevoked), |
| 1760 JSProxy); |
| 1761 } |
| 1762 if (!handler->IsJSReceiver()) { |
| 1763 THROW_NEW_ERROR(isolate, |
| 1764 NewTypeError(MessageTemplate::kProxyHandlerNonObject), |
| 1765 JSProxy); |
| 1766 } |
| 1767 if (handler->IsJSProxy() && JSProxy::cast(*handler)->IsRevoked()) { |
| 1768 THROW_NEW_ERROR(isolate, |
| 1769 NewTypeError(MessageTemplate::kProxyHandlerOrTargetRevoked), |
| 1770 JSProxy); |
| 1771 } |
| 1772 return isolate->factory()->NewJSProxy(Handle<JSReceiver>::cast(target), |
| 1773 Handle<JSReceiver>::cast(handler)); |
| 1774 } |
| 1775 |
| 1776 } // namespace |
| 1777 |
| 1778 |
| 1779 // ES6 section 26.2.1.1 Proxy ( target, handler ) for the [[Call]] case. |
| 1780 BUILTIN(ProxyConstructor) { |
| 1781 HandleScope scope(isolate); |
| 1782 THROW_NEW_ERROR_RETURN_FAILURE( |
| 1783 isolate, |
| 1784 NewTypeError(MessageTemplate::kConstructorNotFunction, |
| 1785 isolate->factory()->NewStringFromAsciiChecked("Proxy"))); |
| 1786 } |
| 1787 |
| 1788 |
| 1789 // ES6 section 26.2.1.1 Proxy ( target, handler ) for the [[Construct]] case. |
| 1790 BUILTIN(ProxyConstructor_ConstructStub) { |
| 1791 HandleScope scope(isolate); |
| 1792 DCHECK_EQ(3, args.length()); |
| 1793 Handle<Object> target = args.at<Object>(1); |
| 1794 Handle<Object> handler = args.at<Object>(2); |
| 1795 // The ConstructStub is executed in the context of the caller, so we need |
| 1796 // to enter the callee context first before raising an exception. |
| 1797 isolate->set_context(args.target()->context()); |
| 1798 Handle<JSProxy> result; |
| 1799 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, |
| 1800 ProxyCreate(isolate, target, handler)); |
| 1801 return *result; |
| 1802 } |
| 1803 |
| 1804 |
1748 // ----------------------------------------------------------------------------- | 1805 // ----------------------------------------------------------------------------- |
1749 // Throwers for restricted function properties and strict arguments object | 1806 // Throwers for restricted function properties and strict arguments object |
1750 // properties | 1807 // properties |
1751 | 1808 |
1752 | 1809 |
1753 BUILTIN(RestrictedFunctionPropertiesThrower) { | 1810 BUILTIN(RestrictedFunctionPropertiesThrower) { |
1754 HandleScope scope(isolate); | 1811 HandleScope scope(isolate); |
1755 THROW_NEW_ERROR_RETURN_FAILURE( | 1812 THROW_NEW_ERROR_RETURN_FAILURE( |
1756 isolate, NewTypeError(MessageTemplate::kRestrictedFunctionProperties)); | 1813 isolate, NewTypeError(MessageTemplate::kRestrictedFunctionProperties)); |
1757 } | 1814 } |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2375 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 2432 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
2376 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 2433 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
2377 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 2434 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
2378 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 2435 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
2379 #undef DEFINE_BUILTIN_ACCESSOR_C | 2436 #undef DEFINE_BUILTIN_ACCESSOR_C |
2380 #undef DEFINE_BUILTIN_ACCESSOR_A | 2437 #undef DEFINE_BUILTIN_ACCESSOR_A |
2381 | 2438 |
2382 | 2439 |
2383 } // namespace internal | 2440 } // namespace internal |
2384 } // namespace v8 | 2441 } // namespace v8 |
OLD | NEW |