JSONStack.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #pragma once
  6. namespace JSON
  7. {
  8. class StrictEqualsObjectComparer
  9. {
  10. public:
  11. static bool Equals(Js::Var x, Js::Var y);
  12. };
  13. class JSONStack
  14. {
  15. private:
  16. Js::Var tempValues[2];
  17. SList<Js::Var> jsObjectStack; // Consider: key-only dictionary here
  18. typedef JsUtil::List<Js::Var, ArenaAllocator, false, Js::CopyRemovePolicy,
  19. SpecializedComparer<Js::Var, JSON::StrictEqualsObjectComparer>::TComparerType> DOMObjectStack;
  20. DOMObjectStack *domObjectStack;
  21. ArenaAllocator *alloc;
  22. Js::ScriptContext *scriptContext;
  23. public:
  24. JSONStack(ArenaAllocator *allocator, Js::ScriptContext *context);
  25. static bool Equals(Js::Var x, Js::Var y);
  26. bool Has(Js::Var data, bool bJsObject = true) const;
  27. bool Push(Js::Var data, bool bJsObject = true);
  28. void Pop(bool bJsObject = true);
  29. ~JSONStack()
  30. {
  31. tempValues[0] = nullptr; // _JS_VALUE
  32. tempValues[1] = nullptr; // _DOM_VALUE
  33. }
  34. private:
  35. void EnsuresDomObjectStack(void);
  36. };
  37. } // namespace JSON