|
@@ -1,6 +1,6 @@
|
|
|
import { Stack } from "./stack.js";
|
|
|
import { InstructionPointer } from "./pointer.js";
|
|
|
-import { EmptyCodeBoxError, FailedToParseCodeBoxError, WrongStackSizeError } from "./errors.js";
|
|
|
+import { EmptyCodeBoxError, FailedToParseCodeBoxError, StackOutOfBoundsError, WrongStackSizeError } from "./errors.js";
|
|
|
import { CodeBoxOptions, OrdinalDirection } from "./types.js";
|
|
|
import { charToDecimal, deepClone } from "./common.js";
|
|
|
import { Node } from "typescript";
|
|
@@ -377,14 +377,14 @@ export class CodeBox {
|
|
|
case InstructionDictionary.STACK_INDEX_INCREMENT: {
|
|
|
this.currentStackIndex++;
|
|
|
if (this.currentStackIndex > this.stacks.length) {
|
|
|
- throw new RangeError("stack index out of bounds");
|
|
|
+ throw new StackOutOfBoundsError(this.currentStackIndex);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
case InstructionDictionary.STACK_INDEX_DECREMENT: {
|
|
|
this.currentStackIndex--;
|
|
|
if (this.currentStackIndex < 0) {
|
|
|
- throw new RangeError("stack index out of bounds");
|
|
|
+ throw new StackOutOfBoundsError(this.currentStackIndex);
|
|
|
}
|
|
|
break;
|
|
|
}
|