greybel-interpreter 4.0.0 → 4.0.2

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.
@@ -1,6 +1,7 @@
1
1
  import { ASTFeatureEnvarExpression, ASTFeatureImportExpression, ASTFeatureIncludeExpression } from 'greybel-core';
2
- import { ASTBase, ASTCallExpression, ASTForGenericStatement, ASTIfStatement, ASTUnaryExpression, ASTWhileStatement } from 'miniscript-core';
3
- import { Instruction } from './byte-compiler/instruction';
2
+ import { ASTAssignmentStatement, ASTBase, ASTCallExpression, ASTEvaluationExpression, ASTForGenericStatement, ASTFunctionStatement, ASTIdentifier, ASTIfStatement, ASTListConstructorExpression, ASTLiteral, ASTMapConstructorExpression, ASTReturnStatement, ASTUnaryExpression, ASTWhileStatement, ASTSliceExpression, ASTIndexExpression, ASTMemberExpression } from 'miniscript-core';
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,46 +17,46 @@ export interface BytecodeConverterOptions {
16
17
  debugMode?: boolean;
17
18
  }
18
19
  export declare class BytecodeGenerator {
19
- private handler;
20
- private context;
21
- private target;
22
- private debugMode;
23
- private imports;
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>;
27
- private getCurrentPointer;
28
- private getSourceLocation;
29
- private getInternalLocation;
30
- private pushContext;
31
- private popContext;
32
- private getLastJumpoint;
33
- private pushJumppoint;
34
- private popJumppoint;
35
- private push;
36
- private processNode;
37
- private processSubNode;
38
- private processMemberExpression;
39
- private processIndexExpression;
40
- private processSliceExpression;
41
- private processIdentifier;
42
- private processAssignmentStatement;
43
- private processLiteral;
44
- private processEvaluationExpression;
45
- private processReturn;
46
- private processBreak;
47
- private processContinue;
48
- private processMapConstructorExpression;
49
- private processListConstructorExpression;
50
- private processFunctionDeclaration;
51
- processWhileStatement(node: ASTWhileStatement): Promise<void>;
52
- processUnaryExpression(node: ASTUnaryExpression): Promise<void>;
53
- processCallExpression(node: ASTCallExpression): Promise<void>;
54
- processIfStatement(node: ASTIfStatement): Promise<void>;
55
- processForGenericStatement(node: ASTForGenericStatement): Promise<void>;
56
- processEnvarExpression(node: ASTFeatureEnvarExpression): Promise<void>;
57
- createImport(node: ASTFeatureImportExpression, path: string, code: string): Promise<void>;
58
- processImportExpression(node: ASTFeatureImportExpression): Promise<void>;
59
- processIncludeExpression(node: ASTFeatureIncludeExpression): Promise<void>;
60
- processDebuggerExpression(node: ASTBase): Promise<void>;
28
+ protected getCurrentPointer(): number;
29
+ protected getSourceLocation(node: ASTBase): SourceLocation;
30
+ protected getInternalLocation(): SourceLocation;
31
+ protected pushContext(): void;
32
+ protected popContext(): BytecodeGeneratorContext;
33
+ protected getLastJumpoint(): [Instruction, Instruction];
34
+ protected pushJumppoint(start: Instruction, end: Instruction): void;
35
+ protected popJumppoint(): [Instruction, Instruction];
36
+ protected push(item: Instruction): void;
37
+ protected processNode(node: ASTBase): Promise<void>;
38
+ protected processSubNode(node: ASTBase, ignoreOuter?: boolean): Promise<void>;
39
+ protected processMemberExpression(node: ASTMemberExpression, isInvoke?: boolean): Promise<void>;
40
+ protected processIndexExpression(node: ASTIndexExpression, isInvoke?: boolean): Promise<void>;
41
+ protected processSliceExpression(node: ASTSliceExpression): Promise<void>;
42
+ protected processIdentifier(node: ASTIdentifier, isFirst?: boolean, isInvoke?: boolean): Promise<void>;
43
+ protected processAssignmentStatement(node: ASTAssignmentStatement): Promise<void>;
44
+ protected processLiteral(node: ASTLiteral): Promise<void>;
45
+ protected processEvaluationExpression(node: ASTEvaluationExpression): Promise<void>;
46
+ protected processReturn(node: ASTReturnStatement): Promise<void>;
47
+ protected processBreak(node: ASTBase): Promise<void>;
48
+ protected processContinue(node: ASTBase): Promise<void>;
49
+ protected processMapConstructorExpression(node: ASTMapConstructorExpression): Promise<void>;
50
+ protected processListConstructorExpression(node: ASTListConstructorExpression): Promise<void>;
51
+ protected processFunctionDeclaration(node: ASTFunctionStatement, ignoreOuter?: boolean): Promise<void>;
52
+ protected processWhileStatement(node: ASTWhileStatement): Promise<void>;
53
+ protected processUnaryExpression(node: ASTUnaryExpression): Promise<void>;
54
+ protected processCallExpression(node: ASTCallExpression): Promise<void>;
55
+ protected processIfStatement(node: ASTIfStatement): Promise<void>;
56
+ protected processForGenericStatement(node: ASTForGenericStatement): Promise<void>;
57
+ protected processEnvarExpression(node: ASTFeatureEnvarExpression): Promise<void>;
58
+ protected createImport(node: ASTFeatureImportExpression, path: string, code: string): Promise<void>;
59
+ protected processImportExpression(node: ASTFeatureImportExpression): Promise<void>;
60
+ protected processIncludeExpression(node: ASTFeatureIncludeExpression): Promise<void>;
61
+ protected processDebuggerExpression(node: ASTBase): Promise<void>;
61
62
  }
@@ -6,6 +6,7 @@ import { CustomValue } from './types/base';
6
6
  import { CustomString } from './types/string';
7
7
  import { ObjectValue } from './utils/object-value';
8
8
  import { Debugger, VM } from './vm';
9
+ import { BytecodeCompileResult } from './bytecode-generator';
9
10
  export declare const PARAMS_PROPERTY: CustomString;
10
11
  export declare const IS_GREYBEL_PROPERTY: CustomString;
11
12
  export interface InterpreterOptions {
@@ -39,8 +40,8 @@ export declare class Interpreter extends EventEmitter {
39
40
  setHandler(handler: HandlerContainer): Interpreter;
40
41
  inject(code: string, context?: OperationContext): Promise<Interpreter>;
41
42
  injectInLastContext(code: string): Promise<Interpreter>;
42
- private initVM;
43
- private start;
43
+ protected initVM(result: BytecodeCompileResult): void;
44
+ protected start(): Promise<Interpreter>;
44
45
  run({ customCode }?: InterpreterRunOptions): Promise<Interpreter>;
45
46
  resume(): Interpreter;
46
47
  pause(): Interpreter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "greybel-interpreter",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "Interpreter",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index",