WebAssemblyTable.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 WebAssemblyTable * Create(uint32 initial, uint32 maximum, ScriptContext * scriptContext);
  32. uint32 GetCurrentLength() const;
  33. uint32 GetInitialLength() const;
  34. uint32 GetMaximumLength() const;
  35. void DirectSetValue(uint index, Var val);
  36. Var DirectGetValue(uint index) const;
  37. static uint32 GetOffsetOfValues() { return offsetof(WebAssemblyTable, m_values); }
  38. static uint32 GetOffsetOfCurrentLength() { return offsetof(WebAssemblyTable, m_currentLength); }
  39. private:
  40. Field(uint32) m_initialLength;
  41. Field(uint32) m_maxLength;
  42. Field(uint32) m_currentLength;
  43. Field(Field(Var)*) m_values;
  44. #endif
  45. };
  46. template <> inline bool VarIsImpl<WebAssemblyTable>(RecyclableObject* obj)
  47. {
  48. return JavascriptOperators::GetTypeId(obj) == TypeIds_WebAssemblyTable;
  49. }
  50. }