2
0

WasmSignature.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 Wasm
  7. {
  8. class WasmSignature
  9. {
  10. public:
  11. WasmSignature();
  12. void SetSignatureId(uint32 id);
  13. void AllocateParams(Js::ArgSlot count, Recycler * recycler);
  14. void SetParam(WasmTypes::WasmType type, Js::ArgSlot index);
  15. Local GetParam(Js::ArgSlot index) const;
  16. Js::ArgSlot GetParamCount() const;
  17. Js::ArgSlot GetParamSize(Js::ArgSlot index) const;
  18. Js::ArgSlot GetParamsSize() const;
  19. void AllocateResults(uint32 count, Recycler * recycler);
  20. void SetResult(Local type, uint32 index);
  21. uint32 GetResultCount() const { return m_resultsCount; }
  22. Local GetResult(uint32 index) const;
  23. void FinalizeSignature();
  24. uint32 GetSignatureId() const;
  25. size_t GetShortSig() const;
  26. template<bool useShortSig = true>
  27. bool IsEquivalent(const WasmSignature* sig) const;
  28. static WasmSignature* FromIDL(WasmSignatureIDL* sig);
  29. static uint32 GetOffsetOfShortSig() { return offsetof(WasmSignature, m_shortSig); }
  30. uint32 WriteSignatureToString(_Out_writes_(maxlen) char16 *out, uint32 maxlen);
  31. void Dump(uint32 maxlen = 512);
  32. private:
  33. Field(uint32) m_id;
  34. Field(uint32) m_resultsCount = 0;
  35. Field(Js::ArgSlot) m_paramSize;
  36. Field(Js::ArgSlot) m_paramsCount;
  37. Field(size_t) m_shortSig;
  38. Field(Local*) m_params;
  39. Field(Local*) m_results = nullptr;
  40. };
  41. } // namespace Wasm