2017-04-02 22:26:53 +02:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
var nodeFS = require('fs');
|
|
|
|
|
|
|
|
var filename = '{test.wasm}';
|
|
|
|
var ret = nodeFS['readFileSync'](filename);
|
|
|
|
|
|
|
|
function instantiate(bytes, imports) {
|
|
|
|
return WebAssembly.compile(bytes).then(
|
|
|
|
m => new WebAssembly.Instance(m, imports), reason => console.log(reason) );
|
|
|
|
}
|
|
|
|
|
|
|
|
var dependencies = {
|
|
|
|
"global": {},
|
|
|
|
"env": {}
|
|
|
|
};
|
|
|
|
dependencies["global.Math"] = Math;
|
|
|
|
|
|
|
|
|
|
|
|
instantiate( ret, dependencies ).then(
|
2017-04-04 21:19:37 +02:00
|
|
|
instance => console.log( instance.exports[process.argv[2]]( ...process.argv.slice(3) ) ),
|
2017-04-02 22:26:53 +02:00
|
|
|
reason => console.log(reason)
|
|
|
|
);
|