calcium-lang
Version:
Calcium language interpreter
17 lines • 604 B
JavaScript
import { Block, Kind, Result } from "../runtime/block";
/**
* a base class for `If`, `Elif` and `Else` commands
*/
export default class Conditional {
execute(env) {
if (this.isSatisfied(env)) {
const block = new Block(Kind.IfElifElse, env.address, () => true, (env) => {
env.address.shift(-2); // the indent is now same as Ifs command
env.blocks.pop(); // therefore the Ifs block will be popped here
return Result.Jumpped;
});
block.willEnter(env);
}
}
}
//# sourceMappingURL=conditional.js.map