tzo 1.0.18 → 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/cli.js.map +1 -1
- 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/closeBrace.js.map +1 -1
- 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/openBrace.js.map +1 -1
- 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/cli.js.map +1 -1
- 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/closeBrace.js.map +1 -1
- 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/openBrace.js.map +1 -1
- 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,2 +1,2 @@
|
|
|
1
|
-
import { Stack } from "./interfaces";
|
|
2
|
-
export declare function getStackParams(functionName: string, paramTypes: Array<"string" | "number" | "string | number">, stack: Stack): (string | number)[];
|
|
1
|
+
import { Stack } from "./interfaces";
|
|
2
|
+
export declare function getStackParams(functionName: string, paramTypes: Array<"string" | "number" | "string | number">, stack: Stack): (string | number)[];
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getStackParams = void 0;
|
|
4
|
-
function getStackParams(functionName, paramTypes, stack) {
|
|
5
|
-
/**
|
|
6
|
-
* Convenience function. Gets params from the stack and throws an error if there's an issue.
|
|
7
|
-
*/
|
|
8
|
-
return paramTypes.map((paramType, i) => {
|
|
9
|
-
const val = stack.pop();
|
|
10
|
-
if (paramType === "string | number") {
|
|
11
|
-
if (typeof val !== "number" && typeof val !== "string") {
|
|
12
|
-
throw new Error(`${functionName}: stack param ${i + 1} is not a string or number!`);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
if (typeof val !== paramType) {
|
|
17
|
-
throw new Error(`${functionName}: stack param ${i + 1} is not a ${paramType}! Value: ${val}`);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return val;
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
exports.getStackParams = getStackParams;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getStackParams = void 0;
|
|
4
|
+
function getStackParams(functionName, paramTypes, stack) {
|
|
5
|
+
/**
|
|
6
|
+
* Convenience function. Gets params from the stack and throws an error if there's an issue.
|
|
7
|
+
*/
|
|
8
|
+
return paramTypes.map((paramType, i) => {
|
|
9
|
+
const val = stack.pop();
|
|
10
|
+
if (paramType === "string | number") {
|
|
11
|
+
if (typeof val !== "number" && typeof val !== "string") {
|
|
12
|
+
throw new Error(`${functionName}: stack param ${i + 1} is not a string or number!`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
if (typeof val !== paramType) {
|
|
17
|
+
throw new Error(`${functionName}: stack param ${i + 1} is not a ${paramType}! Value: ${val}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return val;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
exports.getStackParams = getStackParams;
|
|
24
24
|
//# sourceMappingURL=getStackParams.js.map
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from "./vm";
|
|
2
|
-
export * from "./interfaces";
|
|
3
|
-
export * from "./util/tokenizer";
|
|
4
|
-
export * from "./getStackParams";
|
|
5
|
-
export * from "./util/builder";
|
|
1
|
+
export * from "./vm";
|
|
2
|
+
export * from "./interfaces";
|
|
3
|
+
export * from "./util/tokenizer";
|
|
4
|
+
export * from "./getStackParams";
|
|
5
|
+
export * from "./util/builder";
|
package/dist/browser/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./vm"), exports);
|
|
14
|
-
__exportStar(require("./interfaces"), exports);
|
|
15
|
-
__exportStar(require("./util/tokenizer"), exports);
|
|
16
|
-
__exportStar(require("./getStackParams"), exports);
|
|
17
|
-
__exportStar(require("./util/builder"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./vm"), exports);
|
|
14
|
+
__exportStar(require("./interfaces"), exports);
|
|
15
|
+
__exportStar(require("./util/tokenizer"), exports);
|
|
16
|
+
__exportStar(require("./getStackParams"), exports);
|
|
17
|
+
__exportStar(require("./util/builder"), exports);
|
|
18
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { VM } from "./vm";
|
|
2
|
-
export declare type instructiontype = "push-number-instruction" | "push-string-instruction" | "invoke-function-instruction";
|
|
3
|
-
export declare type BaseInstruction<T extends instructiontype> = {
|
|
4
|
-
type: T;
|
|
5
|
-
comment?: string;
|
|
6
|
-
label?: string;
|
|
7
|
-
};
|
|
8
|
-
export declare type PushNumberInstruction = BaseInstruction<"push-number-instruction"> & {
|
|
9
|
-
value: number;
|
|
10
|
-
};
|
|
11
|
-
export declare type PushStringInstruction = BaseInstruction<"push-string-instruction"> & {
|
|
12
|
-
value: string;
|
|
13
|
-
};
|
|
14
|
-
export declare type InvokeFunctionInstruction = BaseInstruction<"invoke-function-instruction"> & {
|
|
15
|
-
functionName: string;
|
|
16
|
-
};
|
|
17
|
-
export declare type Instruction = PushNumberInstruction | PushStringInstruction | InvokeFunctionInstruction;
|
|
18
|
-
export declare type NumberPushOperation = (stack: Stack, context?: Context) => number;
|
|
19
|
-
export declare type StringPushOperation = (stack: Stack, context?: Context) => string;
|
|
20
|
-
export declare type FunctionInvocationOperation = (stack: Stack, context: Context, vm?: VM) => void;
|
|
21
|
-
export declare type ReturnType<T> = T extends (...args: any[]) => infer R ? R : any;
|
|
22
|
-
export declare type InstructionOperation = NumberPushOperation | StringPushOperation | FunctionInvocationOperation;
|
|
23
|
-
export declare type Stack = Array<string | number>;
|
|
24
|
-
export declare type Context = {
|
|
25
|
-
[key: string]: string | number | null;
|
|
26
|
-
};
|
|
27
|
-
export declare type Instructions = Array<InstructionOperation>;
|
|
28
|
-
export declare type LabelMap = {
|
|
29
|
-
[key: string]: number;
|
|
30
|
-
};
|
|
31
|
-
export declare type Functions = {
|
|
32
|
-
[key: string]: FunctionInvocationOperation;
|
|
33
|
-
};
|
|
34
|
-
export declare type TzoVMState = {
|
|
35
|
-
stack: Stack;
|
|
36
|
-
context: Context;
|
|
37
|
-
programList: Instruction[];
|
|
38
|
-
labelMap: LabelMap;
|
|
39
|
-
programCounter: number;
|
|
40
|
-
exit: boolean;
|
|
41
|
-
pause: boolean;
|
|
42
|
-
};
|
|
1
|
+
import { VM } from "./vm";
|
|
2
|
+
export declare type instructiontype = "push-number-instruction" | "push-string-instruction" | "invoke-function-instruction";
|
|
3
|
+
export declare type BaseInstruction<T extends instructiontype> = {
|
|
4
|
+
type: T;
|
|
5
|
+
comment?: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare type PushNumberInstruction = BaseInstruction<"push-number-instruction"> & {
|
|
9
|
+
value: number;
|
|
10
|
+
};
|
|
11
|
+
export declare type PushStringInstruction = BaseInstruction<"push-string-instruction"> & {
|
|
12
|
+
value: string;
|
|
13
|
+
};
|
|
14
|
+
export declare type InvokeFunctionInstruction = BaseInstruction<"invoke-function-instruction"> & {
|
|
15
|
+
functionName: string;
|
|
16
|
+
};
|
|
17
|
+
export declare type Instruction = PushNumberInstruction | PushStringInstruction | InvokeFunctionInstruction;
|
|
18
|
+
export declare type NumberPushOperation = (stack: Stack, context?: Context) => number;
|
|
19
|
+
export declare type StringPushOperation = (stack: Stack, context?: Context) => string;
|
|
20
|
+
export declare type FunctionInvocationOperation = (stack: Stack, context: Context, vm?: VM) => void;
|
|
21
|
+
export declare type ReturnType<T> = T extends (...args: any[]) => infer R ? R : any;
|
|
22
|
+
export declare type InstructionOperation = NumberPushOperation | StringPushOperation | FunctionInvocationOperation;
|
|
23
|
+
export declare type Stack = Array<string | number>;
|
|
24
|
+
export declare type Context = {
|
|
25
|
+
[key: string]: string | number | null;
|
|
26
|
+
};
|
|
27
|
+
export declare type Instructions = Array<InstructionOperation>;
|
|
28
|
+
export declare type LabelMap = {
|
|
29
|
+
[key: string]: number;
|
|
30
|
+
};
|
|
31
|
+
export declare type Functions = {
|
|
32
|
+
[key: string]: FunctionInvocationOperation;
|
|
33
|
+
};
|
|
34
|
+
export declare type TzoVMState = {
|
|
35
|
+
stack: Stack;
|
|
36
|
+
context: Context;
|
|
37
|
+
programList: Instruction[];
|
|
38
|
+
labelMap: LabelMap;
|
|
39
|
+
programCounter: number;
|
|
40
|
+
exit: boolean;
|
|
41
|
+
pause: boolean;
|
|
42
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=interfaces.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
declare const and: FunctionInvocationOperation;
|
|
3
|
-
export default and;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
declare const and: FunctionInvocationOperation;
|
|
3
|
+
export default and;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getStackParams_1 = require("../getStackParams");
|
|
4
|
-
const and = (stack, context) => {
|
|
5
|
-
const [num1, num2] = getStackParams_1.getStackParams("and", ["number", "number"], stack);
|
|
6
|
-
stack.push(num1 !== 0 && num2 !== 0 ? 1 : 0);
|
|
7
|
-
};
|
|
8
|
-
exports.default = and;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getStackParams_1 = require("../getStackParams");
|
|
4
|
+
const and = (stack, context) => {
|
|
5
|
+
const [num1, num2] = getStackParams_1.getStackParams("and", ["number", "number"], stack);
|
|
6
|
+
stack.push(num1 !== 0 && num2 !== 0 ? 1 : 0);
|
|
7
|
+
};
|
|
8
|
+
exports.default = and;
|
|
9
9
|
//# sourceMappingURL=and.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
declare const charCode: FunctionInvocationOperation;
|
|
3
|
-
export default charCode;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
declare const charCode: FunctionInvocationOperation;
|
|
3
|
+
export default charCode;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getStackParams_1 = require("../getStackParams");
|
|
4
|
-
const charCode = (stack) => {
|
|
5
|
-
const [num] = getStackParams_1.getStackParams("charCode", ["number"], stack);
|
|
6
|
-
const retval = String.fromCharCode(num);
|
|
7
|
-
stack.push(retval);
|
|
8
|
-
};
|
|
9
|
-
exports.default = charCode;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getStackParams_1 = require("../getStackParams");
|
|
4
|
+
const charCode = (stack) => {
|
|
5
|
+
const [num] = getStackParams_1.getStackParams("charCode", ["number"], stack);
|
|
6
|
+
const retval = String.fromCharCode(num);
|
|
7
|
+
stack.push(retval);
|
|
8
|
+
};
|
|
9
|
+
exports.default = charCode;
|
|
10
10
|
//# sourceMappingURL=charCode.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
declare const closeBrace: FunctionInvocationOperation;
|
|
3
|
-
export default closeBrace;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
declare const closeBrace: FunctionInvocationOperation;
|
|
3
|
+
export default closeBrace;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const closeBrace = (stack)
|
|
4
|
-
// do nothing. We support "executing" these so that we can have if/else statements
|
|
5
|
-
};
|
|
6
|
-
exports.default = closeBrace;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const closeBrace = function closeBrace(stack) {
|
|
4
|
+
// do nothing. We support "executing" these so that we can have if/else statements
|
|
5
|
+
};
|
|
6
|
+
exports.default = closeBrace;
|
|
7
7
|
//# sourceMappingURL=closeBrace.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"closeBrace.js","sourceRoot":"","sources":["../../../src/opcodes/closeBrace.ts"],"names":[],"mappings":";;AAGA,MAAM,UAAU,GAAgC,CAAC,KAAY
|
|
1
|
+
{"version":3,"file":"closeBrace.js","sourceRoot":"","sources":["../../../src/opcodes/closeBrace.ts"],"names":[],"mappings":";;AAGA,MAAM,UAAU,GAAgC,SAAS,UAAU,CAAC,KAAY;IAC9E,kFAAkF;AACpF,CAAC,CAAA;AACD,kBAAe,UAAU,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
declare const concat: FunctionInvocationOperation;
|
|
3
|
-
export default concat;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
declare const concat: FunctionInvocationOperation;
|
|
3
|
+
export default concat;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getStackParams_1 = require("../getStackParams");
|
|
4
|
-
const concat = (stack) => {
|
|
5
|
-
const [val1, val2] = getStackParams_1.getStackParams("concat", ["string | number", "string | number"], stack);
|
|
6
|
-
stack.push(`${val1}${val2}`);
|
|
7
|
-
};
|
|
8
|
-
exports.default = concat;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getStackParams_1 = require("../getStackParams");
|
|
4
|
+
const concat = (stack) => {
|
|
5
|
+
const [val1, val2] = getStackParams_1.getStackParams("concat", ["string | number", "string | number"], stack);
|
|
6
|
+
stack.push(`${val1}${val2}`);
|
|
7
|
+
};
|
|
8
|
+
exports.default = concat;
|
|
9
9
|
//# sourceMappingURL=concat.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
declare const delContext: FunctionInvocationOperation;
|
|
3
|
-
export default delContext;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
declare const delContext: FunctionInvocationOperation;
|
|
3
|
+
export default delContext;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getStackParams_1 = require("../getStackParams");
|
|
4
|
-
const delContext = (stack, context) => {
|
|
5
|
-
const [str] = getStackParams_1.getStackParams("delContext", ["string"], stack);
|
|
6
|
-
delete context[str];
|
|
7
|
-
};
|
|
8
|
-
exports.default = delContext;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getStackParams_1 = require("../getStackParams");
|
|
4
|
+
const delContext = (stack, context) => {
|
|
5
|
+
const [str] = getStackParams_1.getStackParams("delContext", ["string"], stack);
|
|
6
|
+
delete context[str];
|
|
7
|
+
};
|
|
8
|
+
exports.default = delContext;
|
|
9
9
|
//# sourceMappingURL=delContext.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
/**
|
|
3
|
-
* Pop the top item from the stack, then push it twice, effectively duplicating it.
|
|
4
|
-
*/
|
|
5
|
-
declare const dup: FunctionInvocationOperation;
|
|
6
|
-
export default dup;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* Pop the top item from the stack, then push it twice, effectively duplicating it.
|
|
4
|
+
*/
|
|
5
|
+
declare const dup: FunctionInvocationOperation;
|
|
6
|
+
export default dup;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getStackParams_1 = require("../getStackParams");
|
|
4
|
-
/**
|
|
5
|
-
* Pop the top item from the stack, then push it twice, effectively duplicating it.
|
|
6
|
-
*/
|
|
7
|
-
const dup = (stack, context) => {
|
|
8
|
-
const [val] = getStackParams_1.getStackParams("dup", ["string | number"], stack);
|
|
9
|
-
stack.push(val);
|
|
10
|
-
stack.push(val);
|
|
11
|
-
};
|
|
12
|
-
exports.default = dup;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getStackParams_1 = require("../getStackParams");
|
|
4
|
+
/**
|
|
5
|
+
* Pop the top item from the stack, then push it twice, effectively duplicating it.
|
|
6
|
+
*/
|
|
7
|
+
const dup = (stack, context) => {
|
|
8
|
+
const [val] = getStackParams_1.getStackParams("dup", ["string | number"], stack);
|
|
9
|
+
stack.push(val);
|
|
10
|
+
stack.push(val);
|
|
11
|
+
};
|
|
12
|
+
exports.default = dup;
|
|
13
13
|
//# sourceMappingURL=dup.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
declare const eq: FunctionInvocationOperation;
|
|
3
|
-
export default eq;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
declare const eq: FunctionInvocationOperation;
|
|
3
|
+
export default eq;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getStackParams_1 = require("../getStackParams");
|
|
4
|
-
const eq = (stack, context) => {
|
|
5
|
-
const [val1, val2] = getStackParams_1.getStackParams("eq", ["string | number", "string | number"], stack);
|
|
6
|
-
const retval = val1 === val2 ? 1 : 0;
|
|
7
|
-
stack.push(retval);
|
|
8
|
-
};
|
|
9
|
-
exports.default = eq;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getStackParams_1 = require("../getStackParams");
|
|
4
|
+
const eq = (stack, context) => {
|
|
5
|
+
const [val1, val2] = getStackParams_1.getStackParams("eq", ["string | number", "string | number"], stack);
|
|
6
|
+
const retval = val1 === val2 ? 1 : 0;
|
|
7
|
+
stack.push(retval);
|
|
8
|
+
};
|
|
9
|
+
exports.default = eq;
|
|
10
10
|
//# sourceMappingURL=eq.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
declare const exit: FunctionInvocationOperation;
|
|
3
|
-
export default exit;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
declare const exit: FunctionInvocationOperation;
|
|
3
|
+
export default exit;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const exit = (stack, context, vm) => {
|
|
4
|
-
vm.quit();
|
|
5
|
-
};
|
|
6
|
-
exports.default = exit;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const exit = (stack, context, vm) => {
|
|
4
|
+
vm.quit();
|
|
5
|
+
};
|
|
6
|
+
exports.default = exit;
|
|
7
7
|
//# sourceMappingURL=exit.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
declare const getContext: FunctionInvocationOperation;
|
|
3
|
-
export default getContext;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
declare const getContext: FunctionInvocationOperation;
|
|
3
|
+
export default getContext;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getStackParams_1 = require("../getStackParams");
|
|
4
|
-
const getContext = (stack, context) => {
|
|
5
|
-
const [str1] = getStackParams_1.getStackParams("getContext", ["string"], stack);
|
|
6
|
-
const retval = context[str1];
|
|
7
|
-
if (retval === null || retval === undefined) {
|
|
8
|
-
throw new Error(`getContext: null/undefined can not be pushed to the context! StackParam: ${str1}`);
|
|
9
|
-
}
|
|
10
|
-
stack.push(retval);
|
|
11
|
-
};
|
|
12
|
-
exports.default = getContext;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getStackParams_1 = require("../getStackParams");
|
|
4
|
+
const getContext = (stack, context) => {
|
|
5
|
+
const [str1] = getStackParams_1.getStackParams("getContext", ["string"], stack);
|
|
6
|
+
const retval = context[str1];
|
|
7
|
+
if (retval === null || retval === undefined) {
|
|
8
|
+
throw new Error(`getContext: null/undefined can not be pushed to the context! StackParam: ${str1}`);
|
|
9
|
+
}
|
|
10
|
+
stack.push(retval);
|
|
11
|
+
};
|
|
12
|
+
exports.default = getContext;
|
|
13
13
|
//# sourceMappingURL=getContext.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
declare const goto: FunctionInvocationOperation;
|
|
3
|
-
export default goto;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
declare const goto: FunctionInvocationOperation;
|
|
3
|
+
export default goto;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getStackParams_1 = require("../getStackParams");
|
|
4
|
-
const goto = (stack, context, vm) => {
|
|
5
|
-
const [val1] = getStackParams_1.getStackParams("goto", ["string | number"], stack);
|
|
6
|
-
if (typeof val1 === "string") {
|
|
7
|
-
const newPC = vm.labelMap[val1];
|
|
8
|
-
if (newPC === undefined) {
|
|
9
|
-
throw new Error(`goto: attempting to jump to undefined label ${val1}`);
|
|
10
|
-
}
|
|
11
|
-
vm.logger(`goto: setting pC to ${newPC} (goto ${val1}) `);
|
|
12
|
-
vm.programCounter = newPC;
|
|
13
|
-
}
|
|
14
|
-
else if (typeof val1 === "number") {
|
|
15
|
-
vm.logger(`goto: setting pC to ${val1} (goto ${val1}) `);
|
|
16
|
-
vm.programCounter = val1;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
exports.default = goto;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getStackParams_1 = require("../getStackParams");
|
|
4
|
+
const goto = (stack, context, vm) => {
|
|
5
|
+
const [val1] = getStackParams_1.getStackParams("goto", ["string | number"], stack);
|
|
6
|
+
if (typeof val1 === "string") {
|
|
7
|
+
const newPC = vm.labelMap[val1];
|
|
8
|
+
if (newPC === undefined) {
|
|
9
|
+
throw new Error(`goto: attempting to jump to undefined label ${val1}`);
|
|
10
|
+
}
|
|
11
|
+
vm.logger(`goto: setting pC to ${newPC} (goto ${val1}) `);
|
|
12
|
+
vm.programCounter = newPC;
|
|
13
|
+
}
|
|
14
|
+
else if (typeof val1 === "number") {
|
|
15
|
+
vm.logger(`goto: setting pC to ${val1} (goto ${val1}) `);
|
|
16
|
+
vm.programCounter = val1;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
exports.default = goto;
|
|
20
20
|
//# sourceMappingURL=goto.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
declare const gt: FunctionInvocationOperation;
|
|
3
|
-
export default gt;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
declare const gt: FunctionInvocationOperation;
|
|
3
|
+
export default gt;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getStackParams_1 = require("../getStackParams");
|
|
4
|
-
const gt = (stack, context) => {
|
|
5
|
-
const [num1, num2] = getStackParams_1.getStackParams("gt", ["number", "number"], stack);
|
|
6
|
-
const retval = num1 > num2 ? 1 : 0;
|
|
7
|
-
stack.push(retval);
|
|
8
|
-
};
|
|
9
|
-
exports.default = gt;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getStackParams_1 = require("../getStackParams");
|
|
4
|
+
const gt = (stack, context) => {
|
|
5
|
+
const [num1, num2] = getStackParams_1.getStackParams("gt", ["number", "number"], stack);
|
|
6
|
+
const retval = num1 > num2 ? 1 : 0;
|
|
7
|
+
stack.push(retval);
|
|
8
|
+
};
|
|
9
|
+
exports.default = gt;
|
|
10
10
|
//# sourceMappingURL=gt.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
declare const hasContext: FunctionInvocationOperation;
|
|
3
|
-
export default hasContext;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
declare const hasContext: FunctionInvocationOperation;
|
|
3
|
+
export default hasContext;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getStackParams_1 = require("../getStackParams");
|
|
4
|
-
const hasContext = (stack, context) => {
|
|
5
|
-
const [str1] = getStackParams_1.getStackParams("hasContext", ["string"], stack);
|
|
6
|
-
if (context.hasOwnProperty(str1)) {
|
|
7
|
-
stack.push(1);
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
stack.push(0);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
exports.default = hasContext;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getStackParams_1 = require("../getStackParams");
|
|
4
|
+
const hasContext = (stack, context) => {
|
|
5
|
+
const [str1] = getStackParams_1.getStackParams("hasContext", ["string"], stack);
|
|
6
|
+
if (context.hasOwnProperty(str1)) {
|
|
7
|
+
stack.push(1);
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
stack.push(0);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
exports.default = hasContext;
|
|
14
14
|
//# sourceMappingURL=hasContext.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
declare const jgz: FunctionInvocationOperation;
|
|
3
|
-
export default jgz;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
declare const jgz: FunctionInvocationOperation;
|
|
3
|
+
export default jgz;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getStackParams_1 = require("../getStackParams");
|
|
4
|
-
const jgz = (stack, context, vm) => {
|
|
5
|
-
const [num1] = getStackParams_1.getStackParams("jgz", ["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 = jgz;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getStackParams_1 = require("../getStackParams");
|
|
4
|
+
const jgz = (stack, context, vm) => {
|
|
5
|
+
const [num1] = getStackParams_1.getStackParams("jgz", ["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 = jgz;
|
|
11
11
|
//# sourceMappingURL=jgz.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
-
declare const jz: FunctionInvocationOperation;
|
|
3
|
-
export default jz;
|
|
1
|
+
import { FunctionInvocationOperation } from "../interfaces";
|
|
2
|
+
declare const jz: FunctionInvocationOperation;
|
|
3
|
+
export default jz;
|