@@ -538,6 +538,32 @@ export class InstantiateExpr extends Expression {
538538 }
539539}
540540
541+ export class RegularExpressionLiteral extends Expression {
542+ constructor (
543+ public body : string ,
544+ public flags : string | null ,
545+ sourceSpan ?: ParseSourceSpan | null ,
546+ ) {
547+ super ( null , sourceSpan ) ;
548+ }
549+
550+ override isEquivalent ( e : Expression ) : boolean {
551+ return e instanceof RegularExpressionLiteral && this . body === e . body && this . flags === e . flags ;
552+ }
553+
554+ override isConstant ( ) {
555+ return true ;
556+ }
557+
558+ override visitExpression ( visitor : ExpressionVisitor , context : any ) : any {
559+ return visitor . visitRegularExpressionLiteral ( this , context ) ;
560+ }
561+
562+ override clone ( ) : RegularExpressionLiteral {
563+ return new RegularExpressionLiteral ( this . body , this . flags , this . sourceSpan ) ;
564+ }
565+ }
566+
541567export class LiteralExpr extends Expression {
542568 constructor (
543569 public value : number | string | boolean | null | undefined ,
@@ -1400,6 +1426,7 @@ export interface ExpressionVisitor {
14001426 visitVoidExpr ( ast : VoidExpr , context : any ) : any ;
14011427 visitArrowFunctionExpr ( ast : ArrowFunctionExpr , context : any ) : any ;
14021428 visitParenthesizedExpr ( ast : ParenthesizedExpr , context : any ) : any ;
1429+ visitRegularExpressionLiteral ( ast : RegularExpressionLiteral , context : any ) : any ;
14031430}
14041431
14051432export const NULL_EXPR = new LiteralExpr ( null , null , null ) ;
@@ -1627,6 +1654,9 @@ export class RecursiveAstVisitor implements StatementVisitor, ExpressionVisitor
16271654 visitLiteralExpr ( ast : LiteralExpr , context : any ) : any {
16281655 return this . visitExpression ( ast , context ) ;
16291656 }
1657+ visitRegularExpressionLiteral ( ast : RegularExpressionLiteral , context : any ) : any {
1658+ return this . visitExpression ( ast , context ) ;
1659+ }
16301660 visitLocalizedString ( ast : LocalizedString , context : any ) : any {
16311661 return this . visitExpression ( ast , context ) ;
16321662 }
0 commit comments