text: //-------------------------------------------------------------------------------------------------------
  // Copyright (C) Microsoft. All rights reserved.
  // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  //-------------------------------------------------------------------------------------------------------
  #include "RuntimeLibraryPch.h"
  
  namespace Js
  {
      JavascriptSymbolObject::JavascriptSymbolObject(JavascriptSymbol* value, DynamicType * type)
          : DynamicObject(type), value(value)
      {
          Assert(type->GetTypeId() == TypeIds_SymbolObject);
      }
  
      bool JavascriptSymbolObject::Is(Var aValue)
      {
          return JavascriptOperators::GetTypeId(aValue) == TypeIds_SymbolObject;
      }
  
      JavascriptSymbolObject* JavascriptSymbolObject::FromVar(Js::Var aValue)
      {
          AssertOrFailFastMsg(Is(aValue), "Ensure var is actually a 'JavascriptSymbolObject'");
  
          return static_cast<JavascriptSymbolObject *>(aValue);
      }
  
      JavascriptSymbolObject* JavascriptSymbolObject::UnsafeFromVar(Js::Var aValue)
      {
          AssertMsg(Is(aValue), "Ensure var is actually a 'JavascriptSymbolObject'");
  
          return static_cast<JavascriptSymbolObject *>(aValue);
      }
  
      Var JavascriptSymbolObject::Unwrap() const
      {
          return value;
      }
  
      BOOL JavascriptSymbolObject::GetDiagValueString(StringBuilder<ArenaAllocator>* stringBuilder, ScriptContext* requestContext)
      {
          if (this->GetValue())
          {
              stringBuilder->Append(this->GetValue()->GetBuffer(), this->GetValue()->GetLength());
          }
          return TRUE;
      }
  
      BOOL JavascriptSymbolObject::GetDiagTypeString(StringBuilder<ArenaAllocator>* stringBuilder, ScriptContext* requestContext)
      {
          stringBuilder->AppendCppLiteral(_u("Symbol, (Object)"));
          return TRUE;
      }
  
  #if ENABLE_TTD
      void JavascriptSymbolObject::SetValue_TTD(Js::Var val)
      {
          AssertMsg(val == nullptr || Js::JavascriptSymbol::Is(val), "Only allowable values!");
  
          this->value = static_cast<Js::JavascriptSymbol*>(val);
      }
  
      void JavascriptSymbolObject::MarkVisitKindSpecificPtrs(TTD::SnapshotExtractor* extractor)
      {
          if(this->value != nullptr)
          {
              extractor->MarkVisitVar(this->value);
          }
      }
  
      TTD::NSSnapObjects::SnapObjectType JavascriptSymbolObject::GetSnapTag_TTD() const
      {
          return TTD::NSSnapObjects::SnapObjectType::SnapBoxedValueObject;
      }
  
      void JavascriptSymbolObject::ExtractSnapObjectDataInto(TTD::NSSnapObjects::SnapObject* objData, TTD::SlabAllocator& alloc)
      {
          TTD::NSSnapObjects::StdExtractSetKindSpecificInfo<TTD::TTDVar, TTD::NSSnapObjects::SnapObjectType::SnapBoxedValueObject>(objData, this->value);
      }
  #endif
  } // namespace Js
  