@@ -143,7 +143,7 @@ public struct Exports: Sequence {
143143}
144144
145145/// A stateful instance of a WebAssembly module.
146- /// Usually instantiated by ``Runtime /instantiate(module :)``.
146+ /// Usually instantiated by ``Module /instantiate(store:imports :)``.
147147/// > Note:
148148/// <https://webassembly.github.io/spec/core/exec/runtime.html#module-instances>
149149public struct Instance {
@@ -310,6 +310,30 @@ typealias InternalTable = EntityHandle<TableEntity>
310310public struct Table : Equatable {
311311 let handle : InternalTable
312312 let allocator : StoreAllocator
313+
314+ init ( handle: InternalTable , allocator: StoreAllocator ) {
315+ self . handle = handle
316+ self . allocator = allocator
317+ }
318+
319+ /// Creates a new table instance with the given type.
320+ public init ( store: Store , type: TableType ) throws {
321+ self . init (
322+ handle: try store. allocator. allocate ( tableType: type, resourceLimiter: store. resourceLimiter) ,
323+ allocator: store. allocator
324+ )
325+ }
326+
327+ /// The type of the table instance.
328+ public var type : TableType {
329+ handle. tableType
330+ }
331+
332+ /// Accesses the element at the given index.
333+ public subscript( index: Int ) -> Reference {
334+ get { handle. elements [ index] }
335+ nonmutating set { handle. withValue { $0. elements [ index] = newValue } }
336+ }
313337}
314338
315339struct MemoryEntity /* : ~Copyable */ {
@@ -389,6 +413,11 @@ public struct Memory: Equatable {
389413 public var data : [ UInt8 ] {
390414 handle. data
391415 }
416+
417+ /// The type of the memory instance.
418+ public var type : MemoryType {
419+ handle. limit
420+ }
392421}
393422
394423extension Memory : GuestMemory {
0 commit comments