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 1781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1792 isolate, | 1792 isolate, |
1793 NewTypeError(MessageTemplate::kConstructorNotFunction, | 1793 NewTypeError(MessageTemplate::kConstructorNotFunction, |
1794 isolate->factory()->NewStringFromAsciiChecked("Proxy"))); | 1794 isolate->factory()->NewStringFromAsciiChecked("Proxy"))); |
1795 } | 1795 } |
1796 | 1796 |
1797 | 1797 |
1798 // ES6 section 26.2.1.1 Proxy ( target, handler ) for the [[Construct]] case. | 1798 // ES6 section 26.2.1.1 Proxy ( target, handler ) for the [[Construct]] case. |
1799 BUILTIN(ProxyConstructor_ConstructStub) { | 1799 BUILTIN(ProxyConstructor_ConstructStub) { |
1800 HandleScope scope(isolate); | 1800 HandleScope scope(isolate); |
1801 DCHECK(isolate->proxy_function()->IsConstructor()); | 1801 DCHECK(isolate->proxy_function()->IsConstructor()); |
1802 DCHECK_EQ(3, args.length()); | 1802 Handle<Object> target; |
1803 Handle<Object> target = args.at<Object>(1); | 1803 if (args.length() < 2) { |
1804 Handle<Object> handler = args.at<Object>(2); | 1804 target = isolate->factory()->undefined_value(); |
| 1805 } else { |
| 1806 target = args.at<Object>(1); |
| 1807 } |
| 1808 Handle<Object> handler; |
| 1809 if (args.length() < 3) { |
| 1810 handler = isolate->factory()->undefined_value(); |
| 1811 } else { |
| 1812 handler = args.at<Object>(2); |
| 1813 } |
1805 // The ConstructStub is executed in the context of the caller, so we need | 1814 // The ConstructStub is executed in the context of the caller, so we need |
1806 // to enter the callee context first before raising an exception. | 1815 // to enter the callee context first before raising an exception. |
1807 isolate->set_context(args.target()->context()); | 1816 isolate->set_context(args.target()->context()); |
1808 Handle<JSProxy> result; | 1817 Handle<JSProxy> result; |
1809 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | 1818 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, |
1810 ProxyCreate(isolate, target, handler)); | 1819 ProxyCreate(isolate, target, handler)); |
1811 return *result; | 1820 return *result; |
1812 } | 1821 } |
1813 | 1822 |
1814 | 1823 |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2435 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 2444 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
2436 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 2445 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
2437 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 2446 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
2438 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 2447 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
2439 #undef DEFINE_BUILTIN_ACCESSOR_C | 2448 #undef DEFINE_BUILTIN_ACCESSOR_C |
2440 #undef DEFINE_BUILTIN_ACCESSOR_A | 2449 #undef DEFINE_BUILTIN_ACCESSOR_A |
2441 | 2450 |
2442 | 2451 |
2443 } // namespace internal | 2452 } // namespace internal |
2444 } // namespace v8 | 2453 } // namespace v8 |
OLD | NEW |