greybel-interpreter 5.1.0 → 5.1.1
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/expression.js +2 -2
- package/dist/bytecode-generator/instruction.d.ts +3 -2
- package/dist/bytecode-generator/instruction.js +1 -0
- package/dist/bytecode-generator/statement.d.ts +1 -1
- package/dist/bytecode-generator/statement.js +4 -0
- package/dist/vm.d.ts +1 -0
- package/dist/vm.js +16 -0
- package/package.json +1 -1
|
@@ -352,8 +352,8 @@ class BytecodeExpressionGenerator {
|
|
|
352
352
|
arguments: args,
|
|
353
353
|
code: fnCode,
|
|
354
354
|
/*
|
|
355
|
-
|
|
356
|
-
|
|
355
|
+
Can be removed after MiniScript fixed outer context bug.
|
|
356
|
+
*/
|
|
357
357
|
ignoreOuter: !(context === null || context === void 0 ? void 0 : context.includeOuter)
|
|
358
358
|
}, node);
|
|
359
359
|
});
|
|
@@ -60,7 +60,8 @@ export declare enum OpCode {
|
|
|
60
60
|
BITWISE_UNSIGNED_RIGHT_SHIFT = 54,
|
|
61
61
|
BREAKPOINT = 55,
|
|
62
62
|
BREAKPOINT_ENABLE = 56,
|
|
63
|
-
IMPORT = 57
|
|
63
|
+
IMPORT = 57,
|
|
64
|
+
EXPORT = 58
|
|
64
65
|
}
|
|
65
66
|
export interface FunctionDefinitionInstructionArgument {
|
|
66
67
|
name: CustomString;
|
|
@@ -125,7 +126,7 @@ export interface CallInternalInstruction extends BaseInstruction {
|
|
|
125
126
|
arguments: FunctionDefinitionInstructionArgument[];
|
|
126
127
|
}
|
|
127
128
|
export interface ImportInstruction extends BaseInstruction {
|
|
128
|
-
op: OpCode.IMPORT;
|
|
129
|
+
op: OpCode.IMPORT | OpCode.EXPORT;
|
|
129
130
|
path: string;
|
|
130
131
|
}
|
|
131
132
|
export interface ComparisonGroupInstruction extends BaseInstruction {
|
|
@@ -61,4 +61,5 @@ var OpCode;
|
|
|
61
61
|
OpCode[OpCode["BREAKPOINT"] = 55] = "BREAKPOINT";
|
|
62
62
|
OpCode[OpCode["BREAKPOINT_ENABLE"] = 56] = "BREAKPOINT_ENABLE";
|
|
63
63
|
OpCode[OpCode["IMPORT"] = 57] = "IMPORT";
|
|
64
|
+
OpCode[OpCode["EXPORT"] = 58] = "EXPORT";
|
|
64
65
|
})(OpCode = exports.OpCode || (exports.OpCode = {}));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ASTFeatureImportExpression, ASTFeatureIncludeExpression } from 'greybel-core';
|
|
2
|
-
import { ASTAssignmentStatement, ASTBase, ASTCallExpression, ASTForGenericStatement, ASTIdentifier, ASTIfStatement, ASTIndexExpression, ASTListConstructorExpression, ASTLogicalExpression, ASTMapConstructorExpression, ASTMemberExpression, ASTReturnStatement, ASTUnaryExpression,
|
|
2
|
+
import { ASTAssignmentStatement, ASTBase, ASTBinaryExpression, ASTCallExpression, ASTForGenericStatement, ASTIdentifier, ASTIfStatement, ASTIndexExpression, ASTListConstructorExpression, ASTLogicalExpression, ASTMapConstructorExpression, ASTMemberExpression, ASTReturnStatement, ASTUnaryExpression, ASTWhileStatement } from 'miniscript-core';
|
|
3
3
|
import { Context } from './context';
|
|
4
4
|
import { LineCallableContext, LineIdentifierContext } from './line';
|
|
5
5
|
import { IBytecodeExpressionGenerator, IBytecodeStatementGenerator, ParseCodeFunction } from './models';
|
|
@@ -664,6 +664,10 @@ class BytecodeStatementGenerator {
|
|
|
664
664
|
op: instruction_1.OpCode.IMPORT,
|
|
665
665
|
path: importTarget
|
|
666
666
|
}, node);
|
|
667
|
+
this.context.pushCode({
|
|
668
|
+
op: instruction_1.OpCode.EXPORT,
|
|
669
|
+
path: importTarget
|
|
670
|
+
}, node);
|
|
667
671
|
this.context.pushCode({
|
|
668
672
|
op: instruction_1.OpCode.ASSIGN
|
|
669
673
|
}, node);
|
package/dist/vm.d.ts
CHANGED
|
@@ -58,6 +58,7 @@ export declare class VM {
|
|
|
58
58
|
readonly handler: HandlerContainer;
|
|
59
59
|
readonly debugger: Debugger;
|
|
60
60
|
readonly imports: Map<string, Instruction[]>;
|
|
61
|
+
readonly exports: Map<string, CustomValue>;
|
|
61
62
|
readonly externalFrames: Stack<OperationContext>;
|
|
62
63
|
constructor(options: VMOptions);
|
|
63
64
|
getTime(): number;
|
package/dist/vm.js
CHANGED
|
@@ -106,6 +106,7 @@ class VM {
|
|
|
106
106
|
this.debugger = options.debugger;
|
|
107
107
|
this.environmentVariables = (_b = options.environmentVariables) !== null && _b !== void 0 ? _b : new Map();
|
|
108
108
|
this.imports = (_c = options.imports) !== null && _c !== void 0 ? _c : new Map();
|
|
109
|
+
this.exports = new Map();
|
|
109
110
|
this.externalFrames = (_d = options.externalFrames) !== null && _d !== void 0 ? _d : new stack_1.Stack();
|
|
110
111
|
}
|
|
111
112
|
getTime() {
|
|
@@ -242,10 +243,25 @@ class VM {
|
|
|
242
243
|
}
|
|
243
244
|
case instruction_1.OpCode.IMPORT: {
|
|
244
245
|
const importInstruction = instruction;
|
|
246
|
+
const exportValue = this.exports.get(importInstruction.path);
|
|
247
|
+
if (exportValue) {
|
|
248
|
+
this.pushStack(exportValue);
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
245
251
|
const code = this.imports.get(importInstruction.path);
|
|
246
252
|
this.createFrame({ code });
|
|
247
253
|
break;
|
|
248
254
|
}
|
|
255
|
+
case instruction_1.OpCode.EXPORT: {
|
|
256
|
+
const persistImportInstruction = instruction;
|
|
257
|
+
const exportValue = this.exports.get(persistImportInstruction.path);
|
|
258
|
+
if (!exportValue) {
|
|
259
|
+
const value = this.popStack();
|
|
260
|
+
this.exports.set(persistImportInstruction.path, value);
|
|
261
|
+
this.pushStack(value);
|
|
262
|
+
}
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
249
265
|
case instruction_1.OpCode.ASSIGN: {
|
|
250
266
|
const value = this.popStack();
|
|
251
267
|
const key = this.popStack();
|