Files
DiceCloud/app/imports/parser/parseTree/ConstantNode.js
2020-09-09 17:09:50 +02:00

24 lines
540 B
JavaScript

import ParseNode from '/imports/parser/parseTree/ParseNode.js';
export default class ConstantNode extends ParseNode {
constructor({value, type, errors}){
super();
// string, number, boolean, numberArray, uncompiledNode
this.type = type;
this.value = value;
if (errors) this.errors = errors;
}
compile(){
return this;
}
toString(){
return `${this.value}`;
}
get isNumber(){
return this.type === 'number';
}
get isInteger(){
return this.isNumberNode && Number.isInteger(this.value);
}
}