mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-16 08:21:44 +00:00
Fixes; Builtins; Testing in the interpreter
This commit is contained in:
17
std/impl/array.ts
Normal file
17
std/impl/array.ts
Normal file
@ -0,0 +1,17 @@
|
||||
/// <reference path="../../assembly.d.ts" />
|
||||
|
||||
@global()
|
||||
class Array<T> {
|
||||
|
||||
length: i32;
|
||||
readonly capacity: i32;
|
||||
readonly data: usize;
|
||||
|
||||
constructor(capacity: i32) {
|
||||
if (capacity < 0)
|
||||
throw new RangeError("capacity out of bounds");
|
||||
this.length = capacity;
|
||||
this.capacity = capacity;
|
||||
this.data = Memory.allocate(sizeof<T>() * capacity);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user