WasmFunctionInfo.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 WasmFunctionInfo
  9. {
  10. public:
  11. WasmFunctionInfo(ArenaAllocator* alloc, WasmSignature* signature, uint32 number);
  12. void AddLocal(WasmTypes::WasmType type, uint count = 1);
  13. Local GetLocal(uint index) const;
  14. Local GetParam(uint index) const;
  15. WasmTypes::WasmType GetResultType() const;
  16. uint32 GetLocalCount() const;
  17. uint32 GetParamCount() const;
  18. void SetName(const char16* name, uint32 nameLength) { m_name = name; m_nameLength = nameLength; }
  19. const char16* GetName() const { return m_name; }
  20. uint32 GetNameLength() const { return m_nameLength; }
  21. uint32 GetNumber() const { return m_number; }
  22. WasmSignature* GetSignature() const { return m_signature; }
  23. void SetExitLabel(Js::ByteCodeLabel label) { m_ExitLabel = label; }
  24. Js::ByteCodeLabel GetExitLabel() const { return m_ExitLabel; }
  25. Js::FunctionBody* GetBody() const { return m_body; }
  26. void SetBody(Js::FunctionBody* val) { m_body = val; }
  27. WasmReaderBase* GetCustomReader() const { return m_customReader; }
  28. void SetCustomReader(WasmReaderBase* customReader) { m_customReader = customReader; }
  29. #if DBG_DUMP
  30. FieldNoBarrier(WasmImport*) importedFunctionReference;
  31. #endif
  32. Field(FunctionBodyReaderInfo) m_readerInfo;
  33. private:
  34. FieldNoBarrier(ArenaAllocator*) m_alloc;
  35. typedef JsUtil::GrowingArray<Local, ArenaAllocator> WasmTypeArray;
  36. Field(WasmTypeArray) m_locals;
  37. Field(Js::FunctionBody*) m_body;
  38. Field(WasmSignature*) m_signature;
  39. Field(Js::ByteCodeLabel) m_ExitLabel;
  40. Field(WasmReaderBase*) m_customReader;
  41. Field(const char16*) m_name;
  42. Field(uint32) m_nameLength;
  43. Field(uint32) m_number;
  44. };
  45. } // namespace Wasm