greybel-interpreter 4.0.2 → 4.0.4
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/dist/bytecode-generator.js +9 -0
- package/dist/handler/output.d.ts +11 -11
- package/dist/handler/output.js +5 -5
- package/dist/vm.js +1 -1
- package/package.json +1 -1
|
@@ -743,6 +743,15 @@ class BytecodeGenerator {
|
|
|
743
743
|
for (const item of node.body) {
|
|
744
744
|
yield this.processNode(item);
|
|
745
745
|
}
|
|
746
|
+
this.push({
|
|
747
|
+
op: instruction_1.OpCode.PUSH,
|
|
748
|
+
source: this.getInternalLocation(),
|
|
749
|
+
value: default_1.DefaultType.Void
|
|
750
|
+
});
|
|
751
|
+
this.push({
|
|
752
|
+
op: instruction_1.OpCode.RETURN,
|
|
753
|
+
source: this.getInternalLocation()
|
|
754
|
+
});
|
|
746
755
|
const fnCode = this.popContext().code;
|
|
747
756
|
this.push({
|
|
748
757
|
op: instruction_1.OpCode.FUNCTION_DEFINITION,
|
package/dist/handler/output.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { VM } from '../vm';
|
|
2
2
|
export interface KeyEvent {
|
|
3
3
|
keyCode?: number;
|
|
4
4
|
charCode?: number;
|
|
@@ -9,16 +9,16 @@ export interface PrintOptions {
|
|
|
9
9
|
replace: boolean;
|
|
10
10
|
}
|
|
11
11
|
export declare abstract class OutputHandler {
|
|
12
|
-
abstract print(
|
|
13
|
-
abstract progress(
|
|
14
|
-
abstract waitForInput(
|
|
15
|
-
abstract waitForKeyPress(
|
|
16
|
-
abstract clear(
|
|
12
|
+
abstract print(vm: VM, message: string, options?: Partial<PrintOptions>): void;
|
|
13
|
+
abstract progress(vm: VM, timeout: number): PromiseLike<void>;
|
|
14
|
+
abstract waitForInput(vm: VM, isPassword: boolean, message?: string): PromiseLike<string>;
|
|
15
|
+
abstract waitForKeyPress(vm: VM, message?: string): PromiseLike<KeyEvent>;
|
|
16
|
+
abstract clear(vm: VM): void;
|
|
17
17
|
}
|
|
18
18
|
export declare class DefaultOutputHandler extends OutputHandler {
|
|
19
|
-
print(
|
|
20
|
-
progress(
|
|
21
|
-
waitForInput(
|
|
22
|
-
waitForKeyPress(
|
|
23
|
-
clear(
|
|
19
|
+
print(_vm: VM, message: string, { appendNewLine }?: Partial<PrintOptions>): void;
|
|
20
|
+
progress(_vm: VM, timeout: number): PromiseLike<void>;
|
|
21
|
+
waitForInput(_vm: VM, _isPassword: boolean, _message?: string): PromiseLike<string>;
|
|
22
|
+
waitForKeyPress(_vm: VM, _message?: string): PromiseLike<KeyEvent>;
|
|
23
|
+
clear(_vm: VM): void;
|
|
24
24
|
}
|
package/dist/handler/output.js
CHANGED
|
@@ -5,7 +5,7 @@ class OutputHandler {
|
|
|
5
5
|
}
|
|
6
6
|
exports.OutputHandler = OutputHandler;
|
|
7
7
|
class DefaultOutputHandler extends OutputHandler {
|
|
8
|
-
print(
|
|
8
|
+
print(_vm, message, { appendNewLine = true } = {}) {
|
|
9
9
|
if (appendNewLine) {
|
|
10
10
|
process.stdout.write(message + '\n');
|
|
11
11
|
}
|
|
@@ -13,21 +13,21 @@ class DefaultOutputHandler extends OutputHandler {
|
|
|
13
13
|
process.stdout.write(message);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
progress(
|
|
16
|
+
progress(_vm, timeout) {
|
|
17
17
|
return new Promise((resolve, _reject) => {
|
|
18
18
|
setTimeout(resolve, timeout);
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
waitForInput(
|
|
21
|
+
waitForInput(_vm, _isPassword, _message) {
|
|
22
22
|
return Promise.resolve('test');
|
|
23
23
|
}
|
|
24
|
-
waitForKeyPress(
|
|
24
|
+
waitForKeyPress(_vm, _message) {
|
|
25
25
|
return Promise.resolve({
|
|
26
26
|
keyCode: 13,
|
|
27
27
|
code: 'Enter'
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
clear(
|
|
30
|
+
clear(_vm) {
|
|
31
31
|
console.clear();
|
|
32
32
|
}
|
|
33
33
|
}
|
package/dist/vm.js
CHANGED
|
@@ -625,7 +625,7 @@ class VM {
|
|
|
625
625
|
case instruction_1.OpCode.RETURN: {
|
|
626
626
|
const value = this.popStack();
|
|
627
627
|
this.popFrame();
|
|
628
|
-
this.pushStack(value);
|
|
628
|
+
this.pushStack(value !== null && value !== void 0 ? value : default_1.DefaultType.Void);
|
|
629
629
|
break;
|
|
630
630
|
}
|
|
631
631
|
case instruction_1.OpCode.GET_ENVAR: {
|