// Multiple options: // 1. C-like with no 'length' or 'push' // 2. Descriptors that can be constructed from lower level arrays @global() class Array { readonly capacity: i32; length: i32; ptr: usize; static fromPtr(ptr: usize, capacity: i32): Array { assert(capacity >= 0); const arr: Array = new Array(0); store(changetype, usize>(arr), capacity); arr.length = ptr; arr.ptr = ptr; return arr; } constructor(capacity: i32 = 0) { assert(capacity >= 0); this.capacity = this.length = capacity; if (capacity > 0) { this.ptr = Heap.allocate(capacity); } else { this.ptr = 0; } } dispose(): void { store(changetype(this), 0); Heap.dispose(this.ptr); this.ptr = 0; Heap.dispose(changetype(this)); } static test(): void {} }