@akala/core
Version:
41 lines • 1.34 kB
JavaScript
/* eslint-disable @typescript-eslint/no-explicit-any */
import { Expression } from './expression.js';
import { ExpressionType } from './expression-type.js';
/**
* Represents a 'new' expression used to instantiate objects or create array literals.
* @template T - The type of the instantiated object.
*/
export class NewExpression extends Expression {
/**
* Gets the type of the expression.
* @returns {ExpressionType.NewExpression} The expression type constant
*/
get type() { return ExpressionType.NewExpression; }
/**
* Array of initialization expressions for the new instance.
*/
init;
/**
* Indicates the type of initialization:
* - '{' for object literals
* - '[' for array literals
*/
newType = '{';
/**
* Creates a new NewExpression instance.
* @param {...MemberExpression<T, any, any>} init - The initialization expressions for the new instance
*/
constructor(...init) {
super();
this.init = init;
}
/**
* Accepts a visitor for the visitor pattern.
* @param {ExpressionVisitor} visitor - The visitor to process this node
* @returns {*} The result of the visitor's processing
*/
accept(visitor) {
return visitor.visitNew(this);
}
}
//# sourceMappingURL=new-expression.js.map