mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-18 01:11:32 +00:00
Refactored builtins
This commit is contained in:
3
src/glue/js.d.ts
vendored
3
src/glue/js.d.ts
vendored
@ -14,3 +14,6 @@ declare type bool = boolean;
|
||||
// Raw memory access (here: Binaryen memory)
|
||||
declare function store<T = u8>(ptr: usize, val: T): void;
|
||||
declare function load<T = u8>(ptr: usize): T;
|
||||
|
||||
// Other things that might or might not be useful
|
||||
declare function select<T>(ifTrue: T, ifFalse: T, condition: bool): T;
|
||||
|
@ -8,6 +8,10 @@ globalScope["load"] = function load_u8(ptr: number) {
|
||||
return binaryen.HEAPU8[ptr];
|
||||
};
|
||||
|
||||
globalScope["select"] = function select<T>(ifTrue: T, ifFalse: T, condition: bool): T {
|
||||
return condition ? ifTrue : ifFalse;
|
||||
};
|
||||
|
||||
const binaryen = require("binaryen");
|
||||
for (const key in binaryen)
|
||||
if (/^_(?:Binaryen|Relooper|malloc$|free$)/.test(key))
|
||||
|
Reference in New Issue
Block a user