Operator overload preparations

This commit is contained in:
dcodeIO
2018-01-06 10:20:38 +01:00
parent 859a0e05bf
commit d8fa04f910
8 changed files with 142 additions and 45 deletions

View File

@ -18,13 +18,13 @@ export class Array<T> {
}
@operator("[]")
get(index: i32): T {
private __get(index: i32): T {
assert(index > 0 && index < this.capacity);
throw new Error("not implemented");
}
@operator("[]=")
set(index: i32, value: T): void {
private __set(index: i32, value: T): void {
assert(index > 0 && index < this.capacity);
throw new Error("not implemented");
}
@ -46,12 +46,12 @@ export class CArray<T> {
private constructor() {}
@operator("[]")
get(index: usize): T {
private __get(index: usize): T {
return load<T>(changetype<usize>(this) + index * sizeof<T>());
}
@operator("[]=")
set(index: usize, value: T): void {
private __set(index: usize, value: T): void {
store<T>(changetype<usize>(this) + index * sizeof<T>(), value);
}
}