WebAssemblyTable.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 Js
  7. {
  8. class WebAssemblyTable : public DynamicObject
  9. {
  10. protected:
  11. DEFINE_VTABLE_CTOR( WebAssemblyTable, DynamicObject );
  12. DEFINE_MARSHAL_OBJECT_TO_SCRIPT_CONTEXT( WebAssemblyTable );
  13. #ifdef ENABLE_WASM
  14. public:
  15. class EntryInfo
  16. {
  17. public:
  18. static FunctionInfo NewInstance;
  19. static FunctionInfo GetterLength;
  20. static FunctionInfo Grow;
  21. static FunctionInfo Get;
  22. static FunctionInfo Set;
  23. };
  24. WebAssemblyTable(
  25. Field(Var) * values, uint32 currentLength, uint32 initialLength, uint32 maxLength, DynamicType * type);
  26. static Var NewInstance(RecyclableObject* function, CallInfo callInfo, ...);
  27. static Var EntryGetterLength(RecyclableObject* function, CallInfo callInfo, ...);
  28. static Var EntryGrow(RecyclableObject* function, CallInfo callInfo, ...);
  29. static Var EntryGet(RecyclableObject* function, CallInfo callInfo, ...);
  30. static Var EntrySet(RecyclableObject* function, CallInfo callInfo, ...);
  31. static bool Is(Var aValue);
  32. static WebAssemblyTable * FromVar(Var aValue);
  33. static WebAssemblyTable * UnsafeFromVar(Var aValue);
  34. static WebAssemblyTable * Create(uint32 initial, uint32 maximum, ScriptContext * scriptContext);
  35. uint32 GetCurrentLength() const;
  36. uint32 GetInitialLength() const;
  37. uint32 GetMaximumLength() const;
  38. void DirectSetValue(uint index, Var val);
  39. Var DirectGetValue(uint index) const;
  40. static uint32 GetOffsetOfValues() { return offsetof(WebAssemblyTable, m_values); }
  41. static uint32 GetOffsetOfCurrentLength() { return offsetof(WebAssemblyTable, m_currentLength); }
  42. private:
  43. Field(uint32) m_initialLength;
  44. Field(uint32) m_maxLength;
  45. Field(uint32) m_currentLength;
  46. Field(Field(Var)*) m_values;
  47. #endif
  48. };
  49. }