expression-evaluation
Version:
Expression Evaluation
36 lines (35 loc) • 1.01 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.LoopNode = void 0;
const Node_js_1 = require("../Node.js");
const Type_js_1 = require("../Type.js");
class LoopNode extends Node_js_1.Node {
_cnode;
_subnode;
constructor(frame, _cnode, _subnode) {
super(frame);
this._cnode = _cnode;
this._subnode = _subnode;
}
get type() {
return this._subnode.type;
}
compile(type) {
this._cnode = this._cnode.compile(Type_js_1.typeBoolean);
this._subnode = this._subnode.compile(type);
return this;
}
evaluate() {
let value;
while (this._cnode.evaluate()) {
value = this._subnode.evaluate();
}
return value;
}
toString(ident = 0) {
return `${super.toString(ident)} loop node`
+ `, cnode:\n${this._cnode.toString(ident + 1)}`
+ `, subnode:\n${this._subnode.toString(ident + 1)}`;
}
}
exports.LoopNode = LoopNode;
;