UNPKG

expression-evaluation

Version:
41 lines (40 loc) 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConstantNode = void 0; const Node_js_1 = require("../Node.js"); const Type_js_1 = require("../Type.js"); class ConstantNode extends Node_js_1.Node { _value; _signature; _subnode; constructor(frame, _value, _signature, _subnode) { super(frame); this._value = _value; this._signature = _signature; this._subnode = _subnode; } get type() { return Type_js_1.Type.of(this._value); } compile(type) { this.reduceType(type); if (this._signature && this._subnode) { this._subnode = this._subnode.compile(this._signature.type); } return this; } evaluate() { return this._value; } get constant() { return !this._subnode; } get signature() { return this._signature; } toString(ident = 0) { return `${super.toString(ident)} constant node` + (this._subnode ? `, subnode:\n${this._subnode.toString(ident + 1)}` : ''); } } exports.ConstantNode = ConstantNode;