UNPKG

calcium-lang

Version:
25 lines 689 B
import { Block, Kind, Result } from "../runtime/block"; import retrieveValue from "../util/retrieveValue"; /** * `while` loop */ export default class While { /** * * @param condition if the value is `True`, then continue the loop */ constructor(condition) { this.condition = condition; } execute(env) { const block = new Block(Kind.While, env.address, (env) => { const value = retrieveValue(this.condition, env); return value ? true : false; }, (env) => { block.willEnter(env); return Result.Jumpped; }); block.willEnter(env); } } //# sourceMappingURL=while.js.map