@@ -8,12 +8,17 @@ namespace Js
88{
99 bool JavascriptProxy::IsRevoked () const
1010 {
11- return (target == nullptr );
11+ if (target == nullptr )
12+ {
13+ Assert (handler == nullptr );
14+ return true ;
15+ }
16+ return false ;
1217 }
1318
1419 RecyclableObject* JavascriptProxy::GetTarget ()
1520 {
16- if (target == nullptr )
21+ if (IsRevoked () )
1722 {
1823 JavascriptError::ThrowTypeError (GetScriptContext (), JSERR_ErrorOnRevokedProxy, _u (" " ));
1924 }
@@ -22,7 +27,7 @@ namespace Js
2227
2328 RecyclableObject* JavascriptProxy::GetHandler ()
2429 {
25- if (handler == nullptr )
30+ if (IsRevoked () )
2631 {
2732 JavascriptError::ThrowTypeError (GetScriptContext (), JSERR_ErrorOnRevokedProxy, _u (" " ));
2833 }
@@ -74,7 +79,7 @@ namespace Js
7479#endif
7580 if (VarIs<JavascriptProxy>(target))
7681 {
77- if (VarTo <JavascriptProxy>(target)->target == nullptr )
82+ if (UnsafeVarTo <JavascriptProxy>(target)->IsRevoked () )
7883 {
7984 JavascriptError::ThrowTypeError (scriptContext, JSERR_InvalidProxyArgument, _u (" target" ));
8085 }
@@ -87,7 +92,7 @@ namespace Js
8792 handler = VarTo<DynamicObject>(args[2 ]);
8893 if (VarIs<JavascriptProxy>(handler))
8994 {
90- if (VarTo <JavascriptProxy>(handler)->handler == nullptr )
95+ if (UnsafeVarTo <JavascriptProxy>(handler)->IsRevoked () )
9196 {
9297 JavascriptError::ThrowTypeError (scriptContext, JSERR_InvalidProxyArgument, _u (" handler" ));
9398 }
@@ -969,7 +974,7 @@ namespace Js
969974 // 1. Assert: Either Type(V) is Object or Type(V) is Null.
970975 // 2. Let handler be the value of the[[ProxyHandler]] internal slot of O.
971976 // 3. If handler is null, then throw a TypeError exception.
972- if (this -> handler == nullptr )
977+ if (IsRevoked () )
973978 {
974979 // the proxy has been revoked; TypeError.
975980 if (!threadContext->RecordImplicitException ())
@@ -1056,7 +1061,7 @@ namespace Js
10561061 BOOL JavascriptProxy::Equals (__in Var other, __out BOOL* value, ScriptContext* requestContext)
10571062 {
10581063 // RecyclableObject* targetObj;
1059- if (this -> target == nullptr )
1064+ if (IsRevoked () )
10601065 {
10611066 // the proxy has been revoked; TypeError.
10621067 JavascriptError::ThrowTypeError (requestContext, JSERR_ErrorOnRevokedProxy, _u (" equal" ));
@@ -1077,7 +1082,7 @@ namespace Js
10771082 {
10781083 *value = FALSE ;
10791084 // RecyclableObject* targetObj;
1080- if (this -> target == nullptr )
1085+ if (IsRevoked () )
10811086 {
10821087 // the proxy has been revoked; TypeError.
10831088 JavascriptError::ThrowTypeError (requestContext, JSERR_ErrorOnRevokedProxy, _u (" strict equal" ));
@@ -1601,7 +1606,7 @@ namespace Js
16011606 Var JavascriptProxy::ToString (ScriptContext* scriptContext)
16021607 {
16031608 // RecyclableObject* targetObj;
1604- if (this -> handler == nullptr )
1609+ if (IsRevoked () )
16051610 {
16061611 ThreadContext* threadContext = GetScriptContext ()->GetThreadContext ();
16071612 // the proxy has been revoked; TypeError.
@@ -1617,7 +1622,7 @@ namespace Js
16171622 const JavascriptProxy* JavascriptProxy::UnwrapNestedProxies (const JavascriptProxy* proxy)
16181623 {
16191624 // continue while we have a proxy that is not revoked
1620- while (proxy->handler != nullptr )
1625+ while (! proxy->IsRevoked () )
16211626 {
16221627 JavascriptProxy* nestedProxy = JavascriptOperators::TryFromVar<JavascriptProxy>(proxy->target );
16231628 if (nestedProxy == nullptr )
@@ -1636,7 +1641,7 @@ namespace Js
16361641 const JavascriptProxy* proxy = UnwrapNestedProxies (this );
16371642
16381643 // RecyclableObject* targetObj;
1639- if (proxy->handler == nullptr )
1644+ if (proxy->IsRevoked () )
16401645 {
16411646 ThreadContext* threadContext = GetScriptContext ()->GetThreadContext ();
16421647 // the proxy has been revoked; TypeError.
@@ -1650,7 +1655,7 @@ namespace Js
16501655 RecyclableObject* JavascriptProxy::ToObject (ScriptContext * requestContext)
16511656 {
16521657 // RecyclableObject* targetObj;
1653- if (this -> handler == nullptr )
1658+ if (IsRevoked () )
16541659 {
16551660 ThreadContext* threadContext = GetScriptContext ()->GetThreadContext ();
16561661 // the proxy has been revoked; TypeError.
@@ -1927,7 +1932,7 @@ namespace Js
19271932 {
19281933 // 2. Let handler be the value of the[[ProxyHandler]] internal slot of O.
19291934 // 3. If handler is null, then throw a TypeError exception.
1930- if (this -> handler == nullptr )
1935+ if (IsRevoked () )
19311936 {
19321937 // the proxy has been revoked; TypeError.
19331938 JavascriptError::ThrowTypeError (requestContext, JSERR_ErrorOnRevokedProxy, requestContext->GetPropertyName (methodId)->GetBuffer ());
0 commit comments