UNPKG

@sschepis/resolang

Version:

ResoLang - Core quantum resonance computation library for browser and Node.js

22 lines (17 loc) 621 B
// assembly/runtime/instructions/flow/break.ts import { IInstructionHandler } from "../types"; import { RISAEngine } from "../../../runtime"; import { Argument } from "../../argument"; class BreakInstruction implements IInstructionHandler { execute(engine: RISAEngine, args: Argument[]): bool { const context = engine.getContext(); if (context.loopStack.length === 0) { return false; // BREAK outside of a loop. } engine.getStackManager().popLoop(context); engine.skipToEndLoop(); return false; } } const breakInstruction = new BreakInstruction(); export default breakInstruction;