@@ -8,12 +8,17 @@ namespace Js
8
8
{
9
9
bool JavascriptProxy::IsRevoked () const
10
10
{
11
- return (target == nullptr );
11
+ if (target == nullptr )
12
+ {
13
+ Assert (handler == nullptr );
14
+ return true ;
15
+ }
16
+ return false ;
12
17
}
13
18
14
19
RecyclableObject* JavascriptProxy::GetTarget ()
15
20
{
16
- if (target == nullptr )
21
+ if (IsRevoked () )
17
22
{
18
23
JavascriptError::ThrowTypeError (GetScriptContext (), JSERR_ErrorOnRevokedProxy, _u (" " ));
19
24
}
@@ -22,7 +27,7 @@ namespace Js
22
27
23
28
RecyclableObject* JavascriptProxy::GetHandler ()
24
29
{
25
- if (handler == nullptr )
30
+ if (IsRevoked () )
26
31
{
27
32
JavascriptError::ThrowTypeError (GetScriptContext (), JSERR_ErrorOnRevokedProxy, _u (" " ));
28
33
}
@@ -74,7 +79,7 @@ namespace Js
74
79
#endif
75
80
if (VarIs<JavascriptProxy>(target))
76
81
{
77
- if (VarTo <JavascriptProxy>(target)->target == nullptr )
82
+ if (UnsafeVarTo <JavascriptProxy>(target)->IsRevoked () )
78
83
{
79
84
JavascriptError::ThrowTypeError (scriptContext, JSERR_InvalidProxyArgument, _u (" target" ));
80
85
}
@@ -87,7 +92,7 @@ namespace Js
87
92
handler = VarTo<DynamicObject>(args[2 ]);
88
93
if (VarIs<JavascriptProxy>(handler))
89
94
{
90
- if (VarTo <JavascriptProxy>(handler)->handler == nullptr )
95
+ if (UnsafeVarTo <JavascriptProxy>(handler)->IsRevoked () )
91
96
{
92
97
JavascriptError::ThrowTypeError (scriptContext, JSERR_InvalidProxyArgument, _u (" handler" ));
93
98
}
@@ -969,7 +974,7 @@ namespace Js
969
974
// 1. Assert: Either Type(V) is Object or Type(V) is Null.
970
975
// 2. Let handler be the value of the[[ProxyHandler]] internal slot of O.
971
976
// 3. If handler is null, then throw a TypeError exception.
972
- if (this -> handler == nullptr )
977
+ if (IsRevoked () )
973
978
{
974
979
// the proxy has been revoked; TypeError.
975
980
if (!threadContext->RecordImplicitException ())
@@ -1056,7 +1061,7 @@ namespace Js
1056
1061
BOOL JavascriptProxy::Equals (__in Var other, __out BOOL* value, ScriptContext* requestContext)
1057
1062
{
1058
1063
// RecyclableObject* targetObj;
1059
- if (this -> target == nullptr )
1064
+ if (IsRevoked () )
1060
1065
{
1061
1066
// the proxy has been revoked; TypeError.
1062
1067
JavascriptError::ThrowTypeError (requestContext, JSERR_ErrorOnRevokedProxy, _u (" equal" ));
@@ -1077,7 +1082,7 @@ namespace Js
1077
1082
{
1078
1083
*value = FALSE ;
1079
1084
// RecyclableObject* targetObj;
1080
- if (this -> target == nullptr )
1085
+ if (IsRevoked () )
1081
1086
{
1082
1087
// the proxy has been revoked; TypeError.
1083
1088
JavascriptError::ThrowTypeError (requestContext, JSERR_ErrorOnRevokedProxy, _u (" strict equal" ));
@@ -1601,7 +1606,7 @@ namespace Js
1601
1606
Var JavascriptProxy::ToString (ScriptContext* scriptContext)
1602
1607
{
1603
1608
// RecyclableObject* targetObj;
1604
- if (this -> handler == nullptr )
1609
+ if (IsRevoked () )
1605
1610
{
1606
1611
ThreadContext* threadContext = GetScriptContext ()->GetThreadContext ();
1607
1612
// the proxy has been revoked; TypeError.
@@ -1617,7 +1622,7 @@ namespace Js
1617
1622
const JavascriptProxy* JavascriptProxy::UnwrapNestedProxies (const JavascriptProxy* proxy)
1618
1623
{
1619
1624
// continue while we have a proxy that is not revoked
1620
- while (proxy->handler != nullptr )
1625
+ while (! proxy->IsRevoked () )
1621
1626
{
1622
1627
JavascriptProxy* nestedProxy = JavascriptOperators::TryFromVar<JavascriptProxy>(proxy->target );
1623
1628
if (nestedProxy == nullptr )
@@ -1636,7 +1641,7 @@ namespace Js
1636
1641
const JavascriptProxy* proxy = UnwrapNestedProxies (this );
1637
1642
1638
1643
// RecyclableObject* targetObj;
1639
- if (proxy->handler == nullptr )
1644
+ if (proxy->IsRevoked () )
1640
1645
{
1641
1646
ThreadContext* threadContext = GetScriptContext ()->GetThreadContext ();
1642
1647
// the proxy has been revoked; TypeError.
@@ -1650,7 +1655,7 @@ namespace Js
1650
1655
RecyclableObject* JavascriptProxy::ToObject (ScriptContext * requestContext)
1651
1656
{
1652
1657
// RecyclableObject* targetObj;
1653
- if (this -> handler == nullptr )
1658
+ if (IsRevoked () )
1654
1659
{
1655
1660
ThreadContext* threadContext = GetScriptContext ()->GetThreadContext ();
1656
1661
// the proxy has been revoked; TypeError.
@@ -1927,7 +1932,7 @@ namespace Js
1927
1932
{
1928
1933
// 2. Let handler be the value of the[[ProxyHandler]] internal slot of O.
1929
1934
// 3. If handler is null, then throw a TypeError exception.
1930
- if (this -> handler == nullptr )
1935
+ if (IsRevoked () )
1931
1936
{
1932
1937
// the proxy has been revoked; TypeError.
1933
1938
JavascriptError::ThrowTypeError (requestContext, JSERR_ErrorOnRevokedProxy, requestContext->GetPropertyName (methodId)->GetBuffer ());
0 commit comments