greybel-interpreter 4.0.1 → 4.0.3
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.d.ts +6 -5
- package/dist/bytecode-generator.js +9 -0
- package/dist/vm.js +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ASTFeatureEnvarExpression, ASTFeatureImportExpression, ASTFeatureIncludeExpression } from 'greybel-core';
|
|
2
2
|
import { ASTAssignmentStatement, ASTBase, ASTCallExpression, ASTEvaluationExpression, ASTForGenericStatement, ASTFunctionStatement, ASTIdentifier, ASTIfStatement, ASTListConstructorExpression, ASTLiteral, ASTMapConstructorExpression, ASTReturnStatement, ASTUnaryExpression, ASTWhileStatement, ASTSliceExpression, ASTIndexExpression, ASTMemberExpression } from 'miniscript-core';
|
|
3
3
|
import { Instruction, SourceLocation } from './byte-compiler/instruction';
|
|
4
|
+
import { Stack } from './utils/stack';
|
|
4
5
|
import { HandlerContainer } from './handler-container';
|
|
5
6
|
export interface BytecodeCompileResult {
|
|
6
7
|
code: Instruction[];
|
|
@@ -16,11 +17,11 @@ export interface BytecodeConverterOptions {
|
|
|
16
17
|
debugMode?: boolean;
|
|
17
18
|
}
|
|
18
19
|
export declare class BytecodeGenerator {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
protected handler: HandlerContainer;
|
|
21
|
+
protected context: Stack<BytecodeGeneratorContext>;
|
|
22
|
+
protected target: Stack<string>;
|
|
23
|
+
protected debugMode: boolean;
|
|
24
|
+
protected imports: Map<string, Instruction[]>;
|
|
24
25
|
constructor(options: BytecodeConverterOptions);
|
|
25
26
|
parse(code: string): ASTBase | import("greybel-core").ASTChunkAdvanced;
|
|
26
27
|
compile(code: string): Promise<BytecodeCompileResult>;
|
|
@@ -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/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: {
|