Implement reference counting (#592)

This commit is contained in:
Daniel Wirtz
2019-06-05 23:15:39 +02:00
committed by GitHub
parent 3ed76a97f0
commit 0484a6b740
601 changed files with 261645 additions and 146131 deletions

View File

@ -1,5 +1,3 @@
import "allocator/tlsf";
export { memory };
export const COLOR: string = "red";
@ -39,10 +37,6 @@ export class Car {
this.doorsOpen = false;
return true;
}
dispose(): void {
memory.free(changetype<usize>(this));
}
}
export function sum(arr: Int32Array): i32 {
@ -51,11 +45,15 @@ export function sum(arr: Int32Array): i32 {
return v;
}
export function changeLength(arr: Array<i32>, length: i32): void {
arr.length = length;
}
export function varadd(a: i32 = 1, b: i32 = 2): i32 {
return a + b;
}
export const varadd_ptr = varadd;
export const varadd_ref = varadd;
export function calladd(fn: (a: i32, b: i32) => i32, a: i32, b: i32): i32 {
return fn(a, b);
@ -64,3 +62,8 @@ export function calladd(fn: (a: i32, b: i32) => i32, a: i32, b: i32): i32 {
export function dotrace(num: f64): void {
trace("The answer is", 1, num);
}
export const INT32ARRAY_ID = idof<Int32Array>();
export const UINT32ARRAY_ID = idof<Uint32Array>();
export const FLOAT32ARRAY_ID = idof<Float32Array>();
export const ARRAYI32_ID = idof<Array<i32>>();