-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-examples.js
36 lines (36 loc) · 1.58 KB
/
build-examples.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = require("fs");
const esprima_1 = require("esprima");
const escodegen_1 = require("escodegen");
const __1 = require("..");
const build1Bit = () => {
console.log('1 bit');
const gameYukiSource = fs_1.readFileSync('./examples/1-bit/src/game.yuki.js', 'utf8');
const gameLibSource = fs_1.readFileSync('./examples/1-bit/src/lib.js', 'utf8');
const yukiAst = esprima_1.parseScript(gameYukiSource, { loc: true });
const libAst = esprima_1.parseScript(gameLibSource);
const { main, memoryUsed, programSize } = __1.compile(yukiAst, { lib: libAst });
const source = escodegen_1.generate(main);
fs_1.writeFileSync('./examples/1-bit/main.js', source, 'utf8');
console.log({ memoryUsed, programSize });
};
const buildChannelY = () => {
console.log('channel Y');
const gameYukiSource = fs_1.readFileSync('./examples/channel-y/src/game.yuki.js', 'utf8');
const gameLibSource = fs_1.readFileSync('./examples/channel-y/src/lib.js', 'utf8');
const yukiAst = esprima_1.parseScript(gameYukiSource, { loc: true });
const libAst = esprima_1.parseScript(gameLibSource);
const { main, memoryUsed, programSize } = __1.compile(yukiAst, {
lib: libAst,
maxProgramSize: 2048,
memorySize: 64,
requiredSubroutines: ['tick']
});
const source = escodegen_1.generate(main);
fs_1.writeFileSync('./examples/channel-y/main.js', source, 'utf8');
console.log({ memoryUsed, programSize });
};
build1Bit();
buildChannelY();
//# sourceMappingURL=build-examples.js.map