| 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 1883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1894 Handle<Object> object = args.at<Object>(0); | 1894 Handle<Object> object = args.at<Object>(0); |
| 1895 Handle<String> result; | 1895 Handle<String> result; |
| 1896 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1896 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 1897 isolate, result, JSObject::ObjectProtoToString(isolate, object)); | 1897 isolate, result, JSObject::ObjectProtoToString(isolate, object)); |
| 1898 return *result; | 1898 return *result; |
| 1899 } | 1899 } |
| 1900 | 1900 |
| 1901 | 1901 |
| 1902 namespace { | 1902 namespace { |
| 1903 | 1903 |
| 1904 // ES6 section 9.5.15 ProxyCreate (target, handler) | |
| 1905 MaybeHandle<JSProxy> ProxyCreate(Isolate* isolate, Handle<Object> target, | |
| 1906 Handle<Object> handler) { | |
| 1907 if (!target->IsJSReceiver()) { | |
| 1908 THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kProxyNonObject), | |
| 1909 JSProxy); | |
| 1910 } | |
| 1911 if (target->IsJSProxy() && JSProxy::cast(*target)->IsRevoked()) { | |
| 1912 THROW_NEW_ERROR(isolate, | |
| 1913 NewTypeError(MessageTemplate::kProxyHandlerOrTargetRevoked), | |
| 1914 JSProxy); | |
| 1915 } | |
| 1916 if (!handler->IsJSReceiver()) { | |
| 1917 THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kProxyNonObject), | |
| 1918 JSProxy); | |
| 1919 } | |
| 1920 if (handler->IsJSProxy() && JSProxy::cast(*handler)->IsRevoked()) { | |
| 1921 THROW_NEW_ERROR(isolate, | |
| 1922 NewTypeError(MessageTemplate::kProxyHandlerOrTargetRevoked), | |
| 1923 JSProxy); | |
| 1924 } | |
| 1925 return isolate->factory()->NewJSProxy(Handle<JSReceiver>::cast(target), | |
| 1926 Handle<JSReceiver>::cast(handler)); | |
| 1927 } | |
| 1928 | |
| 1929 } // namespace | 1904 } // namespace |
| 1930 | 1905 |
| 1931 | 1906 |
| 1932 // ES6 section 26.2.1.1 Proxy ( target, handler ) for the [[Call]] case. | 1907 // ES6 section 26.2.1.1 Proxy ( target, handler ) for the [[Call]] case. |
| 1933 BUILTIN(ProxyConstructor) { | 1908 BUILTIN(ProxyConstructor) { |
| 1934 HandleScope scope(isolate); | 1909 HandleScope scope(isolate); |
| 1935 THROW_NEW_ERROR_RETURN_FAILURE( | 1910 THROW_NEW_ERROR_RETURN_FAILURE( |
| 1936 isolate, | 1911 isolate, |
| 1937 NewTypeError(MessageTemplate::kConstructorNotFunction, | 1912 NewTypeError(MessageTemplate::kConstructorNotFunction, |
| 1938 isolate->factory()->NewStringFromAsciiChecked("Proxy"))); | 1913 isolate->factory()->NewStringFromAsciiChecked("Proxy"))); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1953 if (args.length() < 3) { | 1928 if (args.length() < 3) { |
| 1954 handler = isolate->factory()->undefined_value(); | 1929 handler = isolate->factory()->undefined_value(); |
| 1955 } else { | 1930 } else { |
| 1956 handler = args.at<Object>(2); | 1931 handler = args.at<Object>(2); |
| 1957 } | 1932 } |
| 1958 // The ConstructStub is executed in the context of the caller, so we need | 1933 // The ConstructStub is executed in the context of the caller, so we need |
| 1959 // to enter the callee context first before raising an exception. | 1934 // to enter the callee context first before raising an exception. |
| 1960 isolate->set_context(args.target()->context()); | 1935 isolate->set_context(args.target()->context()); |
| 1961 Handle<JSProxy> result; | 1936 Handle<JSProxy> result; |
| 1962 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | 1937 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, |
| 1963 ProxyCreate(isolate, target, handler)); | 1938 JSProxy::New(isolate, target, handler)); |
| 1964 return *result; | 1939 return *result; |
| 1965 } | 1940 } |
| 1966 | 1941 |
| 1967 | 1942 |
| 1968 // ----------------------------------------------------------------------------- | 1943 // ----------------------------------------------------------------------------- |
| 1969 // Throwers for restricted function properties and strict arguments object | 1944 // Throwers for restricted function properties and strict arguments object |
| 1970 // properties | 1945 // properties |
| 1971 | 1946 |
| 1972 | 1947 |
| 1973 BUILTIN(RestrictedFunctionPropertiesThrower) { | 1948 BUILTIN(RestrictedFunctionPropertiesThrower) { |
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2590 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 2565 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
| 2591 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 2566 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 2592 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 2567 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
| 2593 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 2568 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 2594 #undef DEFINE_BUILTIN_ACCESSOR_C | 2569 #undef DEFINE_BUILTIN_ACCESSOR_C |
| 2595 #undef DEFINE_BUILTIN_ACCESSOR_A | 2570 #undef DEFINE_BUILTIN_ACCESSOR_A |
| 2596 | 2571 |
| 2597 | 2572 |
| 2598 } // namespace internal | 2573 } // namespace internal |
| 2599 } // namespace v8 | 2574 } // namespace v8 |
| OLD | NEW |