2017-12-16 02:27:39 +01:00
|
|
|
@global()
|
2017-12-16 17:54:53 +01:00
|
|
|
export class Array<T> {
|
2017-12-11 18:46:11 +01:00
|
|
|
|
2017-12-23 00:48:54 +01:00
|
|
|
private ptr: usize;
|
|
|
|
|
2017-12-11 18:46:11 +01:00
|
|
|
readonly capacity: i32;
|
|
|
|
length: i32;
|
|
|
|
|
|
|
|
constructor(capacity: i32 = 0) {
|
2017-12-16 17:54:53 +01:00
|
|
|
if (capacity < 0)
|
|
|
|
throw new RangeError("invalid array length");
|
2017-12-11 18:46:11 +01:00
|
|
|
this.capacity = this.length = capacity;
|
|
|
|
if (capacity > 0) {
|
|
|
|
this.ptr = Heap.allocate(<usize>capacity);
|
|
|
|
} else {
|
|
|
|
this.ptr = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dispose(): void {
|
|
|
|
store<i64>(changetype<this,usize>(this), 0);
|
|
|
|
Heap.dispose(this.ptr);
|
|
|
|
this.ptr = 0;
|
|
|
|
Heap.dispose(changetype<this,usize>(this));
|
|
|
|
}
|
2017-12-16 02:27:39 +01:00
|
|
|
|
2017-12-16 17:54:53 +01:00
|
|
|
// TODO
|
2017-12-11 18:46:11 +01:00
|
|
|
}
|