UNPKG

@informalsystems/quint

Version:

Core tool for the Quint specification language

130 lines (129 loc) 5.77 kB
/** * Visitor pattern implementation for Quint IR components. Use this to navigate the IR instead * of implementing a recursion over it yourself. * * @author Gabriela Moreira * * @module */ import * as ir from './quintIr'; import * as t from './quintTypes'; /** * Interface to be implemented by visitor classes. * Optionally defines functions for each IR component. */ export interface IRVisitor { definitionDepth?: number; enterModule?: (_module: ir.QuintModule) => void; exitModule?: (_module: ir.QuintModule) => void; /** General components */ enterExpr?: (_expr: ir.QuintEx) => void; exitExpr?: (_expr: ir.QuintEx) => void; enterDecl?: (_def: ir.QuintDeclaration) => void; exitDecl?: (_def: ir.QuintDeclaration) => void; enterDef?: (_def: ir.QuintDef) => void; exitDef?: (_def: ir.QuintDef) => void; enterType?: (_type: t.QuintType) => void; exitType?: (_type: t.QuintType) => void; /** Definitions */ enterOpDef?: (_def: ir.QuintOpDef) => void; exitOpDef?: (_def: ir.QuintOpDef) => void; enterConst?: (_def: ir.QuintConst) => void; exitConst?: (_def: ir.QuintConst) => void; enterVar?: (_def: ir.QuintVar) => void; exitVar?: (_def: ir.QuintVar) => void; enterAssume?: (_def: ir.QuintAssume) => void; exitAssume?: (_def: ir.QuintAssume) => void; enterTypeDef?: (_def: ir.QuintTypeDef) => void; exitTypeDef?: (_def: ir.QuintTypeDef) => void; enterImport?: (_def: ir.QuintImport) => void; exitImport?: (_def: ir.QuintImport) => void; enterExport?: (_def: ir.QuintExport) => void; exitExport?: (_def: ir.QuintExport) => void; enterInstance?: (_def: ir.QuintInstance) => void; exitInstance?: (_def: ir.QuintInstance) => void; /** Expressions */ enterName?: (_expr: ir.QuintName) => void; exitName?: (_expr: ir.QuintName) => void; enterLiteral?: (_expr: ir.QuintBool | ir.QuintInt | ir.QuintStr) => void; exitLiteral?: (_expr: ir.QuintBool | ir.QuintInt | ir.QuintStr) => void; enterApp?: (_expr: ir.QuintApp) => void; exitApp?: (_expr: ir.QuintApp) => void; enterLambda?: (_expr: ir.QuintLambda) => void; exitLambda?: (_expr: ir.QuintLambda) => void; enterLet?: (_expr: ir.QuintLet) => void; exitLet?: (_expr: ir.QuintLet) => void; /** Types */ enterLiteralType?: (_type: t.QuintBoolType | t.QuintIntType | t.QuintStrType) => void; exitLiteralType?: (_type: t.QuintBoolType | t.QuintIntType | t.QuintStrType) => void; enterConstType?: (_type: t.QuintConstType) => void; exitConstType?: (_type: t.QuintConstType) => void; enterVarType?: (_type: t.QuintVarType) => void; exitVarType?: (_type: t.QuintVarType) => void; enterSetType?: (_type: t.QuintSetType) => void; exitSetType?: (_type: t.QuintSetType) => void; enterSeqType?: (_type: t.QuintSeqType) => void; exitSeqType?: (_type: t.QuintSeqType) => void; enterFunType?: (_type: t.QuintFunType) => void; exitFunType?: (_type: t.QuintFunType) => void; enterOperType?: (_type: t.QuintOperType) => void; exitOperType?: (_type: t.QuintOperType) => void; enterTupleType?: (_type: t.QuintTupleType) => void; exitTupleType?: (_type: t.QuintTupleType) => void; enterRecordType?: (_type: t.QuintRecordType) => void; exitRecordType?: (_type: t.QuintRecordType) => void; enterSumType?: (_type: t.QuintSumType) => void; exitSumType?: (_type: t.QuintSumType) => void; enterAppType?: (_type: t.QuintAppType) => void; exitAppType?: (_type: t.QuintAppType) => void; /** Row types */ enterRow?: (_row: t.Row) => void; exitRow?: (_row: t.Row) => void; enterConcreteRow?: (_row: t.ConcreteRow) => void; exitConcreteRow?: (_row: t.ConcreteRow) => void; enterVarRow?: (_row: t.VarRow) => void; exitVarRow?: (_row: t.VarRow) => void; enterEmptyRow?: (_row: t.EmptyRow) => void; exitEmptyRow?: (_row: t.EmptyRow) => void; } /** * Navigates a Quint module with a visitor, invoking the correspondent function for each * found IR component. * * @param visitor: the IRVisitor instance with the functions to be invoked * @param quintModule: the Quint module to be navigated * * @returns nothing, any collected information has to be a state inside the IRVisitor instance. */ export declare function walkModule(visitor: IRVisitor, quintModule: ir.QuintModule): void; /** * Navigates a Quint type with a visitor, invoking the correspondent function for each * inner type. * * @param visitor: the IRVisitor instance with the functions to be invoked * @param type: the Quint type to be navigated * * @returns nothing, any collected information has to be a state inside the IRVisitor instance. */ export declare function walkType(visitor: IRVisitor, type: t.QuintType): void; /** * Navigates a Quint declaration with a visitor, invoking the correspondent function for each * inner component. * * @param visitor: the IRVisitor instance with the functions to be invoked * @param decl: the Quint declaration to be navigated * * @returns nothing, any collected information has to be a state inside the IRVisitor instance. */ export declare function walkDeclaration(visitor: IRVisitor, decl: ir.QuintDeclaration): void; /** * Navigates a Quint definition with a visitor, invoking the correspondent function for each * inner component. * * @param visitor: the IRVisitor instance with the functions to be invoked * @param def: the Quint definition to be navigated * * @returns nothing, any collected information has to be a state inside the IRVisitor instance. */ export declare function walkDefinition(visitor: IRVisitor, def: ir.QuintDef): void; export declare function walkExpression(visitor: IRVisitor, expr: ir.QuintEx): void;