greybel-interpreter 4.0.12 → 4.0.13

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.
@@ -30,7 +30,7 @@ export declare class BytecodeGenerator {
30
30
  protected getInternalLocation(): SourceLocation;
31
31
  protected pushContext(): void;
32
32
  protected popContext(): BytecodeGeneratorContext;
33
- protected getLastJumpoint(): [Instruction, Instruction];
33
+ protected getLastJumpPoint(): [Instruction, Instruction];
34
34
  protected pushJumppoint(start: Instruction, end: Instruction): void;
35
35
  protected popJumppoint(): [Instruction, Instruction];
36
36
  protected push(item: Instruction): void;
@@ -98,8 +98,11 @@ class BytecodeGenerator {
98
98
  popContext() {
99
99
  return this.context.pop();
100
100
  }
101
- getLastJumpoint() {
101
+ getLastJumpPoint() {
102
102
  const jumpPoints = this.context.peek().jumpPoints;
103
+ if (jumpPoints.length === 0) {
104
+ return null;
105
+ }
103
106
  return jumpPoints[jumpPoints.length - 1];
104
107
  }
105
108
  pushJumppoint(start, end) {
@@ -705,7 +708,10 @@ class BytecodeGenerator {
705
708
  }
706
709
  processBreak(node) {
707
710
  return __awaiter(this, void 0, void 0, function* () {
708
- const [_, end] = this.getLastJumpoint();
711
+ const jumpPoint = this.getLastJumpPoint();
712
+ if (jumpPoint === null)
713
+ return;
714
+ const [_, end] = jumpPoint;
709
715
  this.push({
710
716
  op: instruction_1.OpCode.GOTO_A,
711
717
  source: this.getSourceLocation(node),
@@ -715,7 +721,10 @@ class BytecodeGenerator {
715
721
  }
716
722
  processContinue(node) {
717
723
  return __awaiter(this, void 0, void 0, function* () {
718
- const [start] = this.getLastJumpoint();
724
+ const jumpPoint = this.getLastJumpPoint();
725
+ if (jumpPoint === null)
726
+ return;
727
+ const [start] = jumpPoint;
719
728
  this.push({
720
729
  op: instruction_1.OpCode.GOTO_A,
721
730
  source: this.getSourceLocation(node),
@@ -1001,6 +1010,7 @@ class BytecodeGenerator {
1001
1010
  op: instruction_1.OpCode.POP_ITERATOR,
1002
1011
  source: this.getSourceLocation(node.iterator)
1003
1012
  };
1013
+ this.pushJumppoint(start, end);
1004
1014
  this.push({
1005
1015
  op: instruction_1.OpCode.GET_LOCALS,
1006
1016
  source: this.getSourceLocation(node)
@@ -1039,6 +1049,7 @@ class BytecodeGenerator {
1039
1049
  goto: start
1040
1050
  });
1041
1051
  this.push(end);
1052
+ this.popJumppoint();
1042
1053
  });
1043
1054
  }
1044
1055
  processEnvarExpression(node) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "greybel-interpreter",
3
- "version": "4.0.12",
3
+ "version": "4.0.13",
4
4
  "description": "Interpreter",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index",