calcium-lang
Version:
Calcium language interpreter
23 lines • 660 B
JavaScript
import * as Kw from "../keyword";
import { retrieveValue } from "../util";
import createBool from "../factory/bool";
import { default as Sym } from "../symbol";
/**
* use a unary operator and calculate
*/
export default class UnaryOperation {
constructor(operator, operand) {
this.operator = operator;
this.operand = operand;
}
[Sym.evaluate](env) {
const value = retrieveValue(this.operand, env);
return UnaryOperation.table[this.operator](value);
}
}
UnaryOperation.table = {
[Kw.UnaryOperator.Not]: (operand) => {
return createBool(!operand);
},
};
//# sourceMappingURL=unaryOperation.js.map