mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-18 01:11:32 +00:00
Initial commit
This commit is contained in:
16
src/glue/js.d.ts
vendored
Normal file
16
src/glue/js.d.ts
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
// Aliased AssemblyScript types. Beware of semantic differences.
|
||||
declare type i8 = number;
|
||||
declare type u8 = number;
|
||||
declare type i16 = number;
|
||||
declare type u16 = number;
|
||||
declare type i32 = number;
|
||||
declare type u32 = number;
|
||||
declare type isize = number;
|
||||
declare type usize = number;
|
||||
declare type f32 = number;
|
||||
declare type f64 = number;
|
||||
declare type bool = boolean;
|
||||
|
||||
// Raw memory access (here: Binaryen memory, T=u8)
|
||||
declare function store<T>(ptr: usize, val: u8): void;
|
||||
declare function load<T>(ptr: usize): u8;
|
16
src/glue/js.ts
Normal file
16
src/glue/js.ts
Normal file
@ -0,0 +1,16 @@
|
||||
const globalScope = typeof window !== "undefined" && window
|
||||
|| typeof global !== "undefined" && global
|
||||
|| self;
|
||||
|
||||
globalScope["store"] = function store_u8(ptr, val) {
|
||||
binaryen.HEAPU8[ptr] = val;
|
||||
};
|
||||
|
||||
globalScope["load"] = function load_u8(ptr) {
|
||||
return binaryen.HEAPU8[ptr];
|
||||
};
|
||||
|
||||
const binaryen = require("binaryen");
|
||||
for (const key in binaryen)
|
||||
if (/^_(?:Binaryen|Relooper|malloc$|free$)/.test(key))
|
||||
globalScope[key] = binaryen[key];
|
0
src/glue/wasm.ts
Normal file
0
src/glue/wasm.ts
Normal file
Reference in New Issue
Block a user