UNPKG

@akala/core

Version:
33 lines 1.17 kB
import { Expression } from './expression.js'; import { ExpressionType } from './expression-type.js'; /** * Represents a unary expression which applies an operator to a single operand. */ export class UnaryExpression extends Expression { operand; operator; /** * Gets the type identifier for this expression. * @returns {ExpressionType.UnaryExpression} The expression type constant */ get type() { return ExpressionType.UnaryExpression; } /** * Creates a new unary expression. * @param {Expressions} operand - The operand value to which the operator is applied. * @param {UnaryOperator} operator - The unary operator being applied (e.g., '+', '-', '!') */ constructor(operand, operator) { super(); this.operand = operand; this.operator = operator; } /** * Accepts a visitor to perform visitor pattern operations. * @param {ExpressionVisitor} visitor - The visitor instance. * @returns {any} The result from the visitor's visitUnary method. */ accept(visitor) { return visitor.visitUnary(this); } } //# sourceMappingURL=unary-expression.js.map