mirror of
https://github.com/remko/waforth
synced 2025-01-18 22:26:39 +01:00
remove commander dependency
This commit is contained in:
parent
89e0ef71d8
commit
10bfbf3876
4 changed files with 14 additions and 22 deletions
4
Makefile
4
Makefile
|
@ -26,13 +26,13 @@ src/waforth.wasm: src/waforth.wat
|
|||
$(WAT2WASM) $(WAT2WASM_FLAGS) -o $@ $<
|
||||
|
||||
src/waforth.vanilla.wat: src/waforth.wat
|
||||
./src/tools/process.js $< > $@
|
||||
./src/tools/process.js $< $@
|
||||
|
||||
src/waforth.bulkmem.wasm: src/waforth.bulkmem.wat
|
||||
$(WAT2WASM) $(WAT2WASM_FLAGS) --enable-bulk-memory -o $@ $<
|
||||
|
||||
src/waforth.bulkmem.wat: src/waforth.wat
|
||||
./src/tools/process.js --enable-bulk-memory $< > $@
|
||||
./src/tools/process.js --enable-bulk-memory $< $@
|
||||
|
||||
src/benchmarks/sieve-vanilla.wasm: src/benchmarks/sieve-vanilla.wat
|
||||
$(WAT2WASM) $(WAT2WASM_FLAGS) -o $@ $<
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
"@babel/preset-env": "^7.16.11",
|
||||
"@babel/register": "^7.17.7",
|
||||
"chai": "^4.3.6",
|
||||
"commander": "^9.1.0",
|
||||
"esbuild": "^0.14.36",
|
||||
"eslint": "^8.13.0",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
|
|
|
@ -3,25 +3,21 @@
|
|||
const process = require("process");
|
||||
const fs = require("fs");
|
||||
const _ = require("lodash");
|
||||
const program = require("commander");
|
||||
|
||||
let file;
|
||||
program
|
||||
.arguments("<file>")
|
||||
.option(
|
||||
"--enable-bulk-memory",
|
||||
"use bulk memory operations instead of own implementation"
|
||||
)
|
||||
.action((f) => {
|
||||
file = f;
|
||||
});
|
||||
program.parse(process.argv);
|
||||
const args = process.argv.slice(2);
|
||||
let enableBulkMemory = false;
|
||||
if (args[0] === "--enable-bulk-memory") {
|
||||
enableBulkMemory = true;
|
||||
args.shift();
|
||||
}
|
||||
const [file, outfile] = args;
|
||||
|
||||
const lines = fs.readFileSync(file).toString().split("\n");
|
||||
|
||||
const definitions = {};
|
||||
let skipLevel = 0;
|
||||
let skippingDefinition = false;
|
||||
let out = [];
|
||||
lines.forEach((line) => {
|
||||
// Constants
|
||||
Object.keys(definitions).forEach((k) => {
|
||||
|
@ -39,7 +35,7 @@ lines.forEach((line) => {
|
|||
}
|
||||
|
||||
// Bulk memory operations
|
||||
if (program.enableBulkMemory) {
|
||||
if (enableBulkMemory) {
|
||||
line = line
|
||||
.replace(/\(call \$memcopy/g, "(memory.copy")
|
||||
.replace(/\(call \$memset/g, "(memory.fill");
|
||||
|
@ -55,10 +51,12 @@ lines.forEach((line) => {
|
|||
|
||||
// Output line
|
||||
if (!skippingDefinition) {
|
||||
console.log(line);
|
||||
out.push(line);
|
||||
}
|
||||
|
||||
if (skippingDefinition && skipLevel <= 0) {
|
||||
skippingDefinition = false;
|
||||
}
|
||||
});
|
||||
|
||||
fs.writeFileSync(outfile, out.join("\n"));
|
||||
|
|
|
@ -1225,11 +1225,6 @@ color-name@~1.1.4:
|
|||
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
|
||||
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==
|
||||
|
||||
commander@^9.1.0:
|
||||
version "9.1.0"
|
||||
resolved "https://registry.yarnpkg.com/commander/-/commander-9.1.0.tgz#a6b263b2327f2e188c6402c42623327909f2dbec"
|
||||
integrity sha512-i0/MaqBtdbnJ4XQs4Pmyb+oFQl+q0lsAmokVUH92SlSw4fkeAcG3bVon+Qt7hmtF+u3Het6o4VgrcY3qAoEB6w==
|
||||
|
||||
commondir@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b"
|
||||
|
|
Loading…
Reference in a new issue