Skip to content

Commit

Permalink
feat: upgraded to AssemblyScript v0.18
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinEberhardt committed Feb 17, 2021
1 parent 62e90ef commit 530e807
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 98 deletions.
3 changes: 2 additions & 1 deletion asconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
}
},
"options": {
"transform": []
"transform": [],
"exportRuntime": true
}
}
22 changes: 7 additions & 15 deletions benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
global.TextDecoder = require("text-encoding").TextDecoder;
const fs = require("fs");
const loader = require("@assemblyscript/loader/umd/index");
const loader = require("@assemblyscript/loader");

const Benchmark = require("benchmark");
const suite = new Benchmark.Suite();
Expand All @@ -10,30 +10,22 @@ wasmModule = loader.instantiateSync(
{
env: {
log: () => {
const { __getString, __release } = wasmModule.exports;
str = __getString(strPtr);
console.log(str);
__release(strPtr);
const { __getString } = wasmModule.exports;
console.log(__getString(strPtr));
},
},
}
);

// the executeRegExp exported function is ex
function executeRegex(regexStr, valueStr, untilNull = false) {
const {
executeRegExp,
__newString,
__retain,
__release,
} = wasmModule.exports;
const { executeRegExp, __newString, __pin, __unpin } = wasmModule.exports;

// create the regexp
const regexPtr = __retain(__newString(regexStr));
const strPtr = __retain(__newString(valueStr));
const regexPtr = __pin(__newString(regexStr));
const strPtr = __newString(valueStr);
executeRegExp(regexPtr, strPtr, untilNull ? -1 : 5);
__release(regexPtr);
__release(strPtr);
__unpin(regexPtr);
}

// add tests
Expand Down
177 changes: 98 additions & 79 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
"author": "[email protected]",
"license": "MIT",
"devDependencies": {
"@as-pect/cli": "^5.0.1",
"@assemblyscript/loader": "^0.17.5",
"@as-pect/cli": "^6.0.0",
"@assemblyscript/loader": "^0.18.0",
"@types/node": "^14.14.13",
"@typescript-eslint/eslint-plugin": "^4.14.1",
"@typescript-eslint/parser": "^4.14.1",
"asbuild": "0.0.10",
"assemblyscript": "0.17.5",
"assemblyscript": "^0.18.0",
"benchmark": "^2.1.4",
"eslint": "^7.18.0",
"husky": "^4.2.5",
Expand Down

0 comments on commit 530e807

Please sign in to comment.