blob: 6d0b94983554d1ff47690fa7c7d61ac3de69fec9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
// run a generated image directly, avoiding compiler time in vm execution tests.
const fs = require('fs');
const { TinyVM } = require('../../src/js/tinyvm.js');
const { mapValues } = require('../../src/js/mapvalues.js');
const header = fs.readFileSync(process.argv[2], 'utf8');
const org = Number(header.match(/#define\s+GORG\s+(\d+)/)[1]);
const words = header.match(/genome\[\]\s*=\s*\{([\s\S]*?)\};/)[1].split(',').map(s => s.trim()).filter(Boolean);
const layout = mapValues(process.argv[3], ['GORG', 'DS0', 'DSLIM', 'RS0', 'RSLIM', 'SYSGATE', 'ZFP', 'HEAP_LO', 'HEAP_HI']);
const machine = new TinyVM({ layout, onMessage: message => process.stderr.write(message) });
machine.loadGenome(words, org);
if (process.argv[4] === '--stdin') machine.setInput(fs.readFileSync(0));
const status = machine.run();
process.stdout.write(machine.getOutput());
process.exit(status);
|