expression-evaluation
Version:
Expression Evaluation
34 lines (33 loc) • 1.08 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VariableNode = void 0;
const Node_js_1 = require("../Node.js");
class VariableNode extends Node_js_1.Node {
_variable;
_subnode;
constructor(frame, _variable, _subnode) {
super(frame);
this._variable = _variable;
this._subnode = _subnode;
}
get type() {
return this._variable.type;
}
compile(type) {
this._subnode = this._subnode?.compile(type);
this._variable.type = this.reduceType(this._subnode?.type ?? type);
this._variable.signature = this._subnode?.signature;
return this;
}
evaluate() {
return this._subnode ? this._variable.value = this._subnode.evaluate() : this._variable.value;
}
get signature() {
return this._variable.signature;
}
toString(ident = 0) {
return `${super.toString(ident)} variable node`
+ (this._subnode ? `, subnode:\n${this._subnode?.toString(ident + 1) ?? ''}` : '');
}
}
exports.VariableNode = VariableNode;