tzo 1.0.19 → 1.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +284 -280
- package/bin/package.json +2 -2
- package/bin/tzo +3 -3
- package/bin/tzo.mjs +3 -3
- package/dist/browser/cli.d.ts +1 -1
- package/dist/browser/cli.js +34 -34
- package/dist/browser/concisetext/ConciseTextLexer.d.ts +30 -30
- package/dist/browser/concisetext/ConciseTextLexer.js +122 -122
- package/dist/browser/concisetext/ConciseTextListener.d.ts +14 -14
- package/dist/browser/concisetext/ConciseTextListener.js +35 -35
- package/dist/browser/concisetext/ConciseTextParser.d.ts +99 -99
- package/dist/browser/concisetext/ConciseTextParser.js +438 -438
- package/dist/browser/getStackParams.d.ts +2 -2
- package/dist/browser/getStackParams.js +23 -23
- package/dist/browser/index.d.ts +5 -5
- package/dist/browser/index.js +17 -17
- package/dist/browser/interfaces.d.ts +42 -42
- package/dist/browser/interfaces.js +2 -2
- package/dist/browser/opcodes/and.d.ts +3 -3
- package/dist/browser/opcodes/and.js +8 -8
- package/dist/browser/opcodes/charCode.d.ts +3 -3
- package/dist/browser/opcodes/charCode.js +9 -9
- package/dist/browser/opcodes/closeBrace.d.ts +3 -3
- package/dist/browser/opcodes/closeBrace.js +6 -6
- package/dist/browser/opcodes/concat.d.ts +3 -3
- package/dist/browser/opcodes/concat.js +8 -8
- package/dist/browser/opcodes/delContext.d.ts +3 -3
- package/dist/browser/opcodes/delContext.js +8 -8
- package/dist/browser/opcodes/dup.d.ts +6 -6
- package/dist/browser/opcodes/dup.js +12 -12
- package/dist/browser/opcodes/eq.d.ts +3 -3
- package/dist/browser/opcodes/eq.js +9 -9
- package/dist/browser/opcodes/exit.d.ts +3 -3
- package/dist/browser/opcodes/exit.js +6 -6
- package/dist/browser/opcodes/getContext.d.ts +3 -3
- package/dist/browser/opcodes/getContext.js +12 -12
- package/dist/browser/opcodes/goto.d.ts +3 -3
- package/dist/browser/opcodes/goto.js +19 -19
- package/dist/browser/opcodes/gt.d.ts +3 -3
- package/dist/browser/opcodes/gt.js +9 -9
- package/dist/browser/opcodes/hasContext.d.ts +3 -3
- package/dist/browser/opcodes/hasContext.js +13 -13
- package/dist/browser/opcodes/jgz.d.ts +3 -3
- package/dist/browser/opcodes/jgz.js +10 -10
- package/dist/browser/opcodes/jz.d.ts +3 -3
- package/dist/browser/opcodes/jz.js +10 -10
- package/dist/browser/opcodes/lt.d.ts +3 -3
- package/dist/browser/opcodes/lt.js +9 -9
- package/dist/browser/opcodes/min.d.ts +3 -3
- package/dist/browser/opcodes/min.js +10 -10
- package/dist/browser/opcodes/mul.d.ts +3 -3
- package/dist/browser/opcodes/mul.js +10 -10
- package/dist/browser/opcodes/nop.d.ts +6 -6
- package/dist/browser/opcodes/nop.js +9 -9
- package/dist/browser/opcodes/not.d.ts +6 -6
- package/dist/browser/opcodes/not.js +16 -16
- package/dist/browser/opcodes/openBrace.d.ts +3 -3
- package/dist/browser/opcodes/openBrace.js +20 -20
- package/dist/browser/opcodes/or.d.ts +3 -3
- package/dist/browser/opcodes/or.js +8 -8
- package/dist/browser/opcodes/pause.d.ts +3 -3
- package/dist/browser/opcodes/pause.js +6 -6
- package/dist/browser/opcodes/plus.d.ts +3 -3
- package/dist/browser/opcodes/plus.js +10 -10
- package/dist/browser/opcodes/pop.d.ts +3 -3
- package/dist/browser/opcodes/pop.js +6 -6
- package/dist/browser/opcodes/ppc.d.ts +6 -6
- package/dist/browser/opcodes/ppc.js +9 -9
- package/dist/browser/opcodes/randInt.d.ts +3 -3
- package/dist/browser/opcodes/randInt.js +9 -9
- package/dist/browser/opcodes/rconcat.d.ts +3 -3
- package/dist/browser/opcodes/rconcat.js +8 -8
- package/dist/browser/opcodes/setContext.d.ts +3 -3
- package/dist/browser/opcodes/setContext.js +8 -8
- package/dist/browser/opcodes/stacksize.d.ts +3 -3
- package/dist/browser/opcodes/stacksize.js +6 -6
- package/dist/browser/opcodes/stdout.d.ts +3 -3
- package/dist/browser/opcodes/stdout.js +6 -6
- package/dist/browser/util/builder.d.ts +12 -12
- package/dist/browser/util/builder.js +37 -37
- package/dist/browser/util/fix_antlr_grammar_ts.d.ts +1 -1
- package/dist/browser/util/fix_antlr_grammar_ts.js +7 -7
- package/dist/browser/util/tokenizer.d.ts +20 -20
- package/dist/browser/util/tokenizer.js +176 -176
- package/dist/browser/util/tokenizer.js.map +1 -1
- package/dist/browser/vm.d.ts +26 -26
- package/dist/browser/vm.js +201 -201
- package/dist/browser/vm.test.d.ts +1 -1
- package/dist/browser/vm.test.js +398 -355
- package/dist/browser/vm.test.js.map +1 -1
- package/dist/node/cli.d.ts +1 -1
- package/dist/node/cli.js +34 -34
- package/dist/node/concisetext/ConciseTextLexer.d.ts +30 -30
- package/dist/node/concisetext/ConciseTextLexer.js +122 -122
- package/dist/node/concisetext/ConciseTextListener.d.ts +14 -14
- package/dist/node/concisetext/ConciseTextListener.js +35 -35
- package/dist/node/concisetext/ConciseTextParser.d.ts +99 -99
- package/dist/node/concisetext/ConciseTextParser.js +438 -438
- package/dist/node/getStackParams.d.ts +2 -2
- package/dist/node/getStackParams.js +23 -23
- package/dist/node/index.d.ts +5 -5
- package/dist/node/index.js +17 -17
- package/dist/node/interfaces.d.ts +42 -42
- package/dist/node/interfaces.js +2 -2
- package/dist/node/opcodes/and.d.ts +3 -3
- package/dist/node/opcodes/and.js +8 -8
- package/dist/node/opcodes/charCode.d.ts +3 -3
- package/dist/node/opcodes/charCode.js +9 -9
- package/dist/node/opcodes/closeBrace.d.ts +3 -3
- package/dist/node/opcodes/closeBrace.js +6 -6
- package/dist/node/opcodes/concat.d.ts +3 -3
- package/dist/node/opcodes/concat.js +8 -8
- package/dist/node/opcodes/delContext.d.ts +3 -3
- package/dist/node/opcodes/delContext.js +8 -8
- package/dist/node/opcodes/dup.d.ts +6 -6
- package/dist/node/opcodes/dup.js +12 -12
- package/dist/node/opcodes/eq.d.ts +3 -3
- package/dist/node/opcodes/eq.js +9 -9
- package/dist/node/opcodes/exit.d.ts +3 -3
- package/dist/node/opcodes/exit.js +6 -6
- package/dist/node/opcodes/getContext.d.ts +3 -3
- package/dist/node/opcodes/getContext.js +12 -12
- package/dist/node/opcodes/goto.d.ts +3 -3
- package/dist/node/opcodes/goto.js +19 -19
- package/dist/node/opcodes/gt.d.ts +3 -3
- package/dist/node/opcodes/gt.js +9 -9
- package/dist/node/opcodes/hasContext.d.ts +3 -3
- package/dist/node/opcodes/hasContext.js +13 -13
- package/dist/node/opcodes/jgz.d.ts +3 -3
- package/dist/node/opcodes/jgz.js +10 -10
- package/dist/node/opcodes/jz.d.ts +3 -3
- package/dist/node/opcodes/jz.js +10 -10
- package/dist/node/opcodes/lt.d.ts +3 -3
- package/dist/node/opcodes/lt.js +9 -9
- package/dist/node/opcodes/min.d.ts +3 -3
- package/dist/node/opcodes/min.js +10 -10
- package/dist/node/opcodes/mul.d.ts +3 -3
- package/dist/node/opcodes/mul.js +10 -10
- package/dist/node/opcodes/nop.d.ts +6 -6
- package/dist/node/opcodes/nop.js +9 -9
- package/dist/node/opcodes/not.d.ts +6 -6
- package/dist/node/opcodes/not.js +16 -16
- package/dist/node/opcodes/openBrace.d.ts +3 -3
- package/dist/node/opcodes/openBrace.js +20 -20
- package/dist/node/opcodes/or.d.ts +3 -3
- package/dist/node/opcodes/or.js +8 -8
- package/dist/node/opcodes/pause.d.ts +3 -3
- package/dist/node/opcodes/pause.js +6 -6
- package/dist/node/opcodes/plus.d.ts +3 -3
- package/dist/node/opcodes/plus.js +10 -10
- package/dist/node/opcodes/pop.d.ts +3 -3
- package/dist/node/opcodes/pop.js +6 -6
- package/dist/node/opcodes/ppc.d.ts +6 -6
- package/dist/node/opcodes/ppc.js +9 -9
- package/dist/node/opcodes/randInt.d.ts +3 -3
- package/dist/node/opcodes/randInt.js +9 -9
- package/dist/node/opcodes/rconcat.d.ts +3 -3
- package/dist/node/opcodes/rconcat.js +8 -8
- package/dist/node/opcodes/setContext.d.ts +3 -3
- package/dist/node/opcodes/setContext.js +8 -8
- package/dist/node/opcodes/stacksize.d.ts +3 -3
- package/dist/node/opcodes/stacksize.js +6 -6
- package/dist/node/opcodes/stdout.d.ts +3 -3
- package/dist/node/opcodes/stdout.js +6 -6
- package/dist/node/util/builder.d.ts +12 -12
- package/dist/node/util/builder.js +37 -37
- package/dist/node/util/fix_antlr_grammar_ts.d.ts +1 -1
- package/dist/node/util/fix_antlr_grammar_ts.js +7 -7
- package/dist/node/util/tokenizer.d.ts +20 -20
- package/dist/node/util/tokenizer.js +176 -176
- package/dist/node/util/tokenizer.js.map +1 -1
- package/dist/node/vm.d.ts +26 -26
- package/dist/node/vm.js +201 -201
- package/dist/node/vm.test.d.ts +1 -1
- package/dist/node/vm.test.js +398 -355
- package/dist/node/vm.test.js.map +1 -1
- package/jest.config.js +4 -4
- package/package.json +50 -50
- package/tsconfig-browser.json +8 -8
- package/tsconfig.json +28 -28
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getStackParams_1 = require("../getStackParams");
|
|
4
|
-
const jz = (stack, context, vm) => {
|
|
5
|
-
const [num1] = getStackParams_1.getStackParams("jz", ["number"], stack);
|
|
6
|
-
if (num1 === 0) {
|
|
7
|
-
vm.programCounter += 2; // it would normally already jump one, but since we modify it won't and we have to jump over ourselves
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
exports.default = jz;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getStackParams_1 = require("../getStackParams");
|
|
4
|
+
const jz = (stack, context, vm) => {
|
|
5
|
+
const [num1] = getStackParams_1.getStackParams("jz", ["number"], stack);
|
|
6
|
+
if (num1 === 0) {
|
|
7
|
+
vm.programCounter += 2; // it would normally already jump one, but since we modify it won't and we have to jump over ourselves
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
exports.default = jz;
|
|
11
11
|
//# sourceMappingURL=jz.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
declare const lt: FunctionInvocationOperation;
|
|
3
|
-
export default lt;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
declare const lt: FunctionInvocationOperation;
|
|
3
|
+
export default lt;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getStackParams_1 = require("../getStackParams");
|
|
4
|
-
const lt = (stack, context) => {
|
|
5
|
-
const [num1, num2] = getStackParams_1.getStackParams("lt", ["number", "number"], stack);
|
|
6
|
-
const retval = num1 < num2 ? 1 : 0;
|
|
7
|
-
stack.push(retval);
|
|
8
|
-
};
|
|
9
|
-
exports.default = lt;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getStackParams_1 = require("../getStackParams");
|
|
4
|
+
const lt = (stack, context) => {
|
|
5
|
+
const [num1, num2] = getStackParams_1.getStackParams("lt", ["number", "number"], stack);
|
|
6
|
+
const retval = num1 < num2 ? 1 : 0;
|
|
7
|
+
stack.push(retval);
|
|
8
|
+
};
|
|
9
|
+
exports.default = lt;
|
|
10
10
|
//# sourceMappingURL=lt.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
declare const min: FunctionInvocationOperation;
|
|
3
|
-
export default min;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
declare const min: FunctionInvocationOperation;
|
|
3
|
+
export default min;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getStackParams_1 = require("../getStackParams");
|
|
4
|
-
// also known as '-'
|
|
5
|
-
const min = (stack) => {
|
|
6
|
-
const [num1, num2] = getStackParams_1.getStackParams("-", ["number", "number"], stack);
|
|
7
|
-
const retval = num1 - num2;
|
|
8
|
-
stack.push(retval);
|
|
9
|
-
};
|
|
10
|
-
exports.default = min;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getStackParams_1 = require("../getStackParams");
|
|
4
|
+
// also known as '-'
|
|
5
|
+
const min = (stack) => {
|
|
6
|
+
const [num1, num2] = getStackParams_1.getStackParams("-", ["number", "number"], stack);
|
|
7
|
+
const retval = num1 - num2;
|
|
8
|
+
stack.push(retval);
|
|
9
|
+
};
|
|
10
|
+
exports.default = min;
|
|
11
11
|
//# sourceMappingURL=min.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
declare const mul: FunctionInvocationOperation;
|
|
3
|
-
export default mul;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
declare const mul: FunctionInvocationOperation;
|
|
3
|
+
export default mul;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getStackParams_1 = require("../getStackParams");
|
|
4
|
-
// also known as '*'
|
|
5
|
-
const mul = (stack) => {
|
|
6
|
-
const [num1, num2] = getStackParams_1.getStackParams("*", ["number", "number"], stack);
|
|
7
|
-
const retval = num1 * num2;
|
|
8
|
-
stack.push(retval);
|
|
9
|
-
};
|
|
10
|
-
exports.default = mul;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getStackParams_1 = require("../getStackParams");
|
|
4
|
+
// also known as '*'
|
|
5
|
+
const mul = (stack) => {
|
|
6
|
+
const [num1, num2] = getStackParams_1.getStackParams("*", ["number", "number"], stack);
|
|
7
|
+
const retval = num1 * num2;
|
|
8
|
+
stack.push(retval);
|
|
9
|
+
};
|
|
10
|
+
exports.default = mul;
|
|
11
11
|
//# sourceMappingURL=mul.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
/**
|
|
3
|
-
* nop opcode: do nothing.
|
|
4
|
-
*/
|
|
5
|
-
declare const nop: FunctionInvocationOperation;
|
|
6
|
-
export default nop;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* nop opcode: do nothing.
|
|
4
|
+
*/
|
|
5
|
+
declare const nop: FunctionInvocationOperation;
|
|
6
|
+
export default nop;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* nop opcode: do nothing.
|
|
5
|
-
*/
|
|
6
|
-
const nop = () => {
|
|
7
|
-
// do nothing
|
|
8
|
-
};
|
|
9
|
-
exports.default = nop;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* nop opcode: do nothing.
|
|
5
|
+
*/
|
|
6
|
+
const nop = () => {
|
|
7
|
+
// do nothing
|
|
8
|
+
};
|
|
9
|
+
exports.default = nop;
|
|
10
10
|
//# sourceMappingURL=nop.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
/**
|
|
3
|
-
* not opcode: pop one element from the stack. If it is 0, push 1. Otherwise, push 0.
|
|
4
|
-
*/
|
|
5
|
-
declare const not: FunctionInvocationOperation;
|
|
6
|
-
export default not;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* not opcode: pop one element from the stack. If it is 0, push 1. Otherwise, push 0.
|
|
4
|
+
*/
|
|
5
|
+
declare const not: FunctionInvocationOperation;
|
|
6
|
+
export default not;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getStackParams_1 = require("../getStackParams");
|
|
4
|
-
/**
|
|
5
|
-
* not opcode: pop one element from the stack. If it is 0, push 1. Otherwise, push 0.
|
|
6
|
-
*/
|
|
7
|
-
const not = (stack) => {
|
|
8
|
-
const [num1] = getStackParams_1.getStackParams("not", ["number"], stack);
|
|
9
|
-
if (num1 === 0) {
|
|
10
|
-
stack.push(1);
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
stack.push(0);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
exports.default = not;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getStackParams_1 = require("../getStackParams");
|
|
4
|
+
/**
|
|
5
|
+
* not opcode: pop one element from the stack. If it is 0, push 1. Otherwise, push 0.
|
|
6
|
+
*/
|
|
7
|
+
const not = (stack) => {
|
|
8
|
+
const [num1] = getStackParams_1.getStackParams("not", ["number"], stack);
|
|
9
|
+
if (num1 === 0) {
|
|
10
|
+
stack.push(1);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
stack.push(0);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
exports.default = not;
|
|
17
17
|
//# sourceMappingURL=not.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
declare const openBrace: FunctionInvocationOperation;
|
|
3
|
-
export default openBrace;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
declare const openBrace: FunctionInvocationOperation;
|
|
3
|
+
export default openBrace;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const openBrace = function openBrace(stack, context, vm) {
|
|
4
|
-
let i = 0;
|
|
5
|
-
let pc = vm.programCounter + 1;
|
|
6
|
-
while (true) {
|
|
7
|
-
if (vm.programList[pc].name === "openBrace") { // bit dirty! TODO: improve?
|
|
8
|
-
i += 1;
|
|
9
|
-
}
|
|
10
|
-
if (vm.programList[pc].name === "closeBrace") { // bit dirty! TODO: improve?
|
|
11
|
-
i -= 1;
|
|
12
|
-
if (i === -1) {
|
|
13
|
-
vm.programCounter = pc + 1;
|
|
14
|
-
break;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
pc += 1;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
exports.default = openBrace;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const openBrace = function openBrace(stack, context, vm) {
|
|
4
|
+
let i = 0;
|
|
5
|
+
let pc = vm.programCounter + 1;
|
|
6
|
+
while (true) {
|
|
7
|
+
if (vm.programList[pc].name === "openBrace") { // bit dirty! TODO: improve?
|
|
8
|
+
i += 1;
|
|
9
|
+
}
|
|
10
|
+
if (vm.programList[pc].name === "closeBrace") { // bit dirty! TODO: improve?
|
|
11
|
+
i -= 1;
|
|
12
|
+
if (i === -1) {
|
|
13
|
+
vm.programCounter = pc + 1;
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
pc += 1;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
exports.default = openBrace;
|
|
21
21
|
//# sourceMappingURL=openBrace.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
declare const or: FunctionInvocationOperation;
|
|
3
|
-
export default or;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
declare const or: FunctionInvocationOperation;
|
|
3
|
+
export default or;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getStackParams_1 = require("../getStackParams");
|
|
4
|
-
const or = (stack, context) => {
|
|
5
|
-
const [num1, num2] = getStackParams_1.getStackParams("or", ["number", "number"], stack);
|
|
6
|
-
stack.push(num1 !== 0 || num2 !== 0 ? 1 : 0);
|
|
7
|
-
};
|
|
8
|
-
exports.default = or;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getStackParams_1 = require("../getStackParams");
|
|
4
|
+
const or = (stack, context) => {
|
|
5
|
+
const [num1, num2] = getStackParams_1.getStackParams("or", ["number", "number"], stack);
|
|
6
|
+
stack.push(num1 !== 0 || num2 !== 0 ? 1 : 0);
|
|
7
|
+
};
|
|
8
|
+
exports.default = or;
|
|
9
9
|
//# sourceMappingURL=or.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
declare const pause: FunctionInvocationOperation;
|
|
3
|
-
export default pause;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
declare const pause: FunctionInvocationOperation;
|
|
3
|
+
export default pause;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const pause = (stack, context, vm) => {
|
|
4
|
-
vm.suspend();
|
|
5
|
-
};
|
|
6
|
-
exports.default = pause;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const pause = (stack, context, vm) => {
|
|
4
|
+
vm.suspend();
|
|
5
|
+
};
|
|
6
|
+
exports.default = pause;
|
|
7
7
|
//# sourceMappingURL=pause.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
declare const plus: FunctionInvocationOperation;
|
|
3
|
-
export default plus;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
declare const plus: FunctionInvocationOperation;
|
|
3
|
+
export default plus;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getStackParams_1 = require("../getStackParams");
|
|
4
|
-
// also known as '+'
|
|
5
|
-
const plus = (stack) => {
|
|
6
|
-
const [num1, num2] = getStackParams_1.getStackParams("+", ["number", "number"], stack);
|
|
7
|
-
const retval = num1 + num2;
|
|
8
|
-
stack.push(retval);
|
|
9
|
-
};
|
|
10
|
-
exports.default = plus;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getStackParams_1 = require("../getStackParams");
|
|
4
|
+
// also known as '+'
|
|
5
|
+
const plus = (stack) => {
|
|
6
|
+
const [num1, num2] = getStackParams_1.getStackParams("+", ["number", "number"], stack);
|
|
7
|
+
const retval = num1 + num2;
|
|
8
|
+
stack.push(retval);
|
|
9
|
+
};
|
|
10
|
+
exports.default = plus;
|
|
11
11
|
//# sourceMappingURL=plus.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
declare const pop: FunctionInvocationOperation;
|
|
3
|
-
export default pop;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
declare const pop: FunctionInvocationOperation;
|
|
3
|
+
export default pop;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const pop = (stack) => {
|
|
4
|
-
stack.pop();
|
|
5
|
-
};
|
|
6
|
-
exports.default = pop;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const pop = (stack) => {
|
|
4
|
+
stack.pop();
|
|
5
|
+
};
|
|
6
|
+
exports.default = pop;
|
|
7
7
|
//# sourceMappingURL=pop.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
/**
|
|
3
|
-
* ppc opcode: push the current program counter (pointing to the location of this `ppc` instruction in the program memory) to the stack.
|
|
4
|
-
*/
|
|
5
|
-
declare const ppc: FunctionInvocationOperation;
|
|
6
|
-
export default ppc;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* ppc opcode: push the current program counter (pointing to the location of this `ppc` instruction in the program memory) to the stack.
|
|
4
|
+
*/
|
|
5
|
+
declare const ppc: FunctionInvocationOperation;
|
|
6
|
+
export default ppc;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* ppc opcode: push the current program counter (pointing to the location of this `ppc` instruction in the program memory) to the stack.
|
|
5
|
-
*/
|
|
6
|
-
const ppc = (stack, context, vm) => {
|
|
7
|
-
stack.push(vm.programCounter);
|
|
8
|
-
};
|
|
9
|
-
exports.default = ppc;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* ppc opcode: push the current program counter (pointing to the location of this `ppc` instruction in the program memory) to the stack.
|
|
5
|
+
*/
|
|
6
|
+
const ppc = (stack, context, vm) => {
|
|
7
|
+
stack.push(vm.programCounter);
|
|
8
|
+
};
|
|
9
|
+
exports.default = ppc;
|
|
10
10
|
//# sourceMappingURL=ppc.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
declare const randInt: FunctionInvocationOperation;
|
|
3
|
-
export default randInt;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
declare const randInt: FunctionInvocationOperation;
|
|
3
|
+
export default randInt;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getStackParams_1 = require("../getStackParams");
|
|
4
|
-
const randInt = (stack) => {
|
|
5
|
-
const [max] = getStackParams_1.getStackParams("randInt", ["number"], stack);
|
|
6
|
-
const retval = Math.floor(Math.random() * max);
|
|
7
|
-
stack.push(retval);
|
|
8
|
-
};
|
|
9
|
-
exports.default = randInt;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getStackParams_1 = require("../getStackParams");
|
|
4
|
+
const randInt = (stack) => {
|
|
5
|
+
const [max] = getStackParams_1.getStackParams("randInt", ["number"], stack);
|
|
6
|
+
const retval = Math.floor(Math.random() * max);
|
|
7
|
+
stack.push(retval);
|
|
8
|
+
};
|
|
9
|
+
exports.default = randInt;
|
|
10
10
|
//# sourceMappingURL=randInt.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
declare const rconcat: FunctionInvocationOperation;
|
|
3
|
-
export default rconcat;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
declare const rconcat: FunctionInvocationOperation;
|
|
3
|
+
export default rconcat;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getStackParams_1 = require("../getStackParams");
|
|
4
|
-
const rconcat = (stack) => {
|
|
5
|
-
const [val1, val2] = getStackParams_1.getStackParams("rconcat", ["string | number", "string | number"], stack);
|
|
6
|
-
stack.push(`${val2}${val1}`);
|
|
7
|
-
};
|
|
8
|
-
exports.default = rconcat;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getStackParams_1 = require("../getStackParams");
|
|
4
|
+
const rconcat = (stack) => {
|
|
5
|
+
const [val1, val2] = getStackParams_1.getStackParams("rconcat", ["string | number", "string | number"], stack);
|
|
6
|
+
stack.push(`${val2}${val1}`);
|
|
7
|
+
};
|
|
8
|
+
exports.default = rconcat;
|
|
9
9
|
//# sourceMappingURL=rconcat.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
declare const setContext: FunctionInvocationOperation;
|
|
3
|
-
export default setContext;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
declare const setContext: FunctionInvocationOperation;
|
|
3
|
+
export default setContext;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getStackParams_1 = require("../getStackParams");
|
|
4
|
-
const setContext = (stack, context) => {
|
|
5
|
-
const [str1, arg2] = getStackParams_1.getStackParams("setContext", ["string", "string | number"], stack);
|
|
6
|
-
context[str1] = arg2;
|
|
7
|
-
};
|
|
8
|
-
exports.default = setContext;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getStackParams_1 = require("../getStackParams");
|
|
4
|
+
const setContext = (stack, context) => {
|
|
5
|
+
const [str1, arg2] = getStackParams_1.getStackParams("setContext", ["string", "string | number"], stack);
|
|
6
|
+
context[str1] = arg2;
|
|
7
|
+
};
|
|
8
|
+
exports.default = setContext;
|
|
9
9
|
//# sourceMappingURL=setContext.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
declare const stacksize: FunctionInvocationOperation;
|
|
3
|
-
export default stacksize;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
declare const stacksize: FunctionInvocationOperation;
|
|
3
|
+
export default stacksize;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const stacksize = (stack) => {
|
|
4
|
-
stack.push(stack.length);
|
|
5
|
-
};
|
|
6
|
-
exports.default = stacksize;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const stacksize = (stack) => {
|
|
4
|
+
stack.push(stack.length);
|
|
5
|
+
};
|
|
6
|
+
exports.default = stacksize;
|
|
7
7
|
//# sourceMappingURL=stacksize.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
declare const stdout: FunctionInvocationOperation;
|
|
3
|
-
export default stdout;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
declare const stdout: FunctionInvocationOperation;
|
|
3
|
+
export default stdout;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const stdout = (stack) => {
|
|
4
|
-
process.stdout.write("" + stack.pop());
|
|
5
|
-
};
|
|
6
|
-
exports.default = stdout;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const stdout = (stack) => {
|
|
4
|
+
process.stdout.write("" + stack.pop());
|
|
5
|
+
};
|
|
6
|
+
exports.default = stdout;
|
|
7
7
|
//# sourceMappingURL=stdout.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Context, Instruction, TzoVMState } from "..";
|
|
2
|
-
export declare class Builder {
|
|
3
|
-
fakeLabelMap: {
|
|
4
|
-
[key: string]: Instruction;
|
|
5
|
-
};
|
|
6
|
-
programList: Instruction[];
|
|
7
|
-
context: Context;
|
|
8
|
-
withLabel(instr: Instruction, label: string): Instruction;
|
|
9
|
-
add(instructions: Instruction[]): void;
|
|
10
|
-
contextParam(paramName: string, value: string | number): void;
|
|
11
|
-
build(): TzoVMState;
|
|
12
|
-
}
|
|
1
|
+
import { Context, Instruction, TzoVMState } from "..";
|
|
2
|
+
export declare class Builder {
|
|
3
|
+
fakeLabelMap: {
|
|
4
|
+
[key: string]: Instruction;
|
|
5
|
+
};
|
|
6
|
+
programList: Instruction[];
|
|
7
|
+
context: Context;
|
|
8
|
+
withLabel(instr: Instruction, label: string): Instruction;
|
|
9
|
+
add(instructions: Instruction[]): void;
|
|
10
|
+
contextParam(paramName: string, value: string | number): void;
|
|
11
|
+
build(): TzoVMState;
|
|
12
|
+
}
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Builder = void 0;
|
|
4
|
-
class Builder {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.fakeLabelMap = {};
|
|
7
|
-
this.programList = [];
|
|
8
|
-
this.context = {};
|
|
9
|
-
}
|
|
10
|
-
withLabel(instr, label) {
|
|
11
|
-
this.fakeLabelMap[label] = instr;
|
|
12
|
-
return instr;
|
|
13
|
-
}
|
|
14
|
-
add(instructions) {
|
|
15
|
-
instructions.forEach(x => this.programList.push(x));
|
|
16
|
-
}
|
|
17
|
-
contextParam(paramName, value) {
|
|
18
|
-
this.context[paramName] = value;
|
|
19
|
-
}
|
|
20
|
-
build() {
|
|
21
|
-
const labelMap = Object.entries(this.fakeLabelMap).reduce((memo, entry) => {
|
|
22
|
-
memo[entry[0]] = this.programList.findIndex(x => x === entry[1]);
|
|
23
|
-
return memo;
|
|
24
|
-
}, {});
|
|
25
|
-
const vmstate = {
|
|
26
|
-
context: this.context,
|
|
27
|
-
exit: false,
|
|
28
|
-
pause: false,
|
|
29
|
-
labelMap,
|
|
30
|
-
programList: this.programList,
|
|
31
|
-
programCounter: 0,
|
|
32
|
-
stack: []
|
|
33
|
-
};
|
|
34
|
-
return vmstate;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.Builder = Builder;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Builder = void 0;
|
|
4
|
+
class Builder {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.fakeLabelMap = {};
|
|
7
|
+
this.programList = [];
|
|
8
|
+
this.context = {};
|
|
9
|
+
}
|
|
10
|
+
withLabel(instr, label) {
|
|
11
|
+
this.fakeLabelMap[label] = instr;
|
|
12
|
+
return instr;
|
|
13
|
+
}
|
|
14
|
+
add(instructions) {
|
|
15
|
+
instructions.forEach(x => this.programList.push(x));
|
|
16
|
+
}
|
|
17
|
+
contextParam(paramName, value) {
|
|
18
|
+
this.context[paramName] = value;
|
|
19
|
+
}
|
|
20
|
+
build() {
|
|
21
|
+
const labelMap = Object.entries(this.fakeLabelMap).reduce((memo, entry) => {
|
|
22
|
+
memo[entry[0]] = this.programList.findIndex(x => x === entry[1]);
|
|
23
|
+
return memo;
|
|
24
|
+
}, {});
|
|
25
|
+
const vmstate = {
|
|
26
|
+
context: this.context,
|
|
27
|
+
exit: false,
|
|
28
|
+
pause: false,
|
|
29
|
+
labelMap,
|
|
30
|
+
programList: this.programList,
|
|
31
|
+
programCounter: 0,
|
|
32
|
+
stack: []
|
|
33
|
+
};
|
|
34
|
+
return vmstate;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.Builder = Builder;
|
|
38
38
|
//# sourceMappingURL=builder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|