Fix and also unify ugc example, see #101

This commit is contained in:
dcodeIO 2018-05-09 15:22:38 +02:00
parent 1f3bb61fae
commit dae9880428
5 changed files with 970 additions and 1072 deletions

View File

@ -9,7 +9,7 @@ Instructions
To build [assembly/ugc.ts](./assembly/ugc.ts) to an untouched and an optimized `.wasm` including their respective `.wat` representations, run:
```
$> npm run build
$> npm run asbuild
```
Afterwards, to run the included [test](./tests/index.js):

View File

@ -3,9 +3,9 @@
"version": "1.0.0",
"private": true,
"scripts": {
"build": "npm run build:untouched && npm run build:optimized",
"build:untouched": "asc assembly/index.ts -b ugc.untouched.wasm -t ugc.untouched.wat --validate --sourceMap --measure",
"build:optimized": "asc -O3 assembly/index.ts -b ugc.optimized.wasm -t ugc.optimized.wat --validate --noDebug --noAssert --sourceMap --measure",
"asbuild": "npm run asbuild:untouched && npm run asbuild:optimized",
"asbuild:untouched": "asc assembly/index.ts -b build/untouched.wasm -t build/untouched.wat --validate --sourceMap --measure",
"asbuild:optimized": "asc -O3 assembly/index.ts -b build/optimized.wasm -t build/optimized.wat --validate --noDebug --noAssert --sourceMap --measure",
"test": "node tests"
}
}

View File

@ -2,7 +2,11 @@ var fs = require("fs");
// NOTE that this doesn't do anything useful, yet
var ugc = new WebAssembly.Instance(new WebAssembly.Module(fs.readFileSync(__dirname + "/../ugc.untouched.wasm"))).exports;
var ugc = new WebAssembly.Instance(new WebAssembly.Module(fs.readFileSync(__dirname + "/../build/untouched.wasm")), {
env: { abort: function(msg, file, line, column) {
console.log("abort called at " + line + ":" + column);
} }
}).exports;
function mem(memory, offset, count) {
if (!offset) offset = 0;