Prechádzať zdrojové kódy

Add a flag for variables in TDZ

When examining locals through the debugging API, this adds a flag,
IN_TDZ, for block-scoped variables still in the temporal dead zone, so
they can be quickly distinguished by the host.
Bruce Pascoe 8 rokov pred
rodič
commit
7c34d85fd4

+ 1 - 0
lib/Jsrt/ChakraDebug.h

@@ -414,6 +414,7 @@ typedef unsigned __int32 uint32_t;
     ///         NONE = 0x1,
     ///         HAVE_CHILDRENS = 0x2,
     ///         READ_ONLY_VALUE = 0x4,
+    ///         IN_TDZ = 0x8,
     ///     </para>
     ///     <para>
     ///     {

+ 6 - 0
lib/Jsrt/JsrtDebugUtils.cpp

@@ -145,6 +145,7 @@ void JsrtDebugUtils::AddPropertyType(Js::DynamicObject * object, Js::IDiagObject
     bool addValue = false;
 
     Js::Var varValue = objectDisplayRef->GetVarValue(FALSE);
+    Js::IDiagObjectAddress* varAddress = objectDisplayRef->GetDiagAddress();
 
     if (varValue != nullptr)
     {
@@ -366,6 +367,11 @@ void JsrtDebugUtils::AddPropertyType(Js::DynamicObject * object, Js::IDiagObject
         propertyAttributes |= JsrtDebugPropertyAttribute::HAVE_CHILDRENS;
     }
 
+    if (varAddress != nullptr && varAddress->IsInDeadZone())
+    {
+        propertyAttributes |= JsrtDebugPropertyAttribute::IN_TDZ;
+    }
+
     JsrtDebugUtils::AddPropertyToObject(object, JsrtDebugPropertyId::propertyAttributes, (UINT)propertyAttributes, scriptContext);
 }
 

+ 1 - 0
lib/Jsrt/JsrtDebugUtils.h

@@ -14,6 +14,7 @@ BEGIN_ENUM_UINT(JsrtDebugPropertyAttribute)
     NONE = 0x1,
     HAVE_CHILDRENS = 0x2,
     READ_ONLY_VALUE = 0x4,
+    IN_TDZ = 0x8,
 END_ENUM_UINT()
 
 class JsrtDebugUtils