UNPKG

@informalsystems/quint

Version:

Core tool for the Quint specification language

146 lines (145 loc) 7.07 kB
/** * Visitor pattern-like implementation for Quint IR components. Use this to * transform the IR instead of implementing a recursion over it yourself. * * @author Gabriela Moreira * * @module */ import * as ir from './quintIr'; import * as t from './quintTypes'; import { LookupDefinition } from '../names/base'; export declare class IRTransformer { enterModule?: (module: ir.QuintModule) => ir.QuintModule; exitModule?: (module: ir.QuintModule) => ir.QuintModule; /** General components */ enterExpr?: (expr: ir.QuintEx) => ir.QuintEx; exitExpr?: (expr: ir.QuintEx) => ir.QuintEx; enterDef?: (def: ir.QuintDef) => ir.QuintDef; exitDef?: (def: ir.QuintDef) => ir.QuintDef; enterDecl?: (decl: ir.QuintDeclaration) => ir.QuintDeclaration; exitDecl?: (decl: ir.QuintDeclaration) => ir.QuintDeclaration; enterType?: (type: t.QuintType) => t.QuintType; exitType?: (type: t.QuintType) => t.QuintType; /** Definitions */ enterOpDef?: (def: ir.QuintOpDef) => ir.QuintOpDef; exitOpDef?: (def: ir.QuintOpDef) => ir.QuintOpDef; enterConst?: (def: ir.QuintConst) => ir.QuintConst; exitConst?: (def: ir.QuintConst) => ir.QuintConst; enterVar?: (def: ir.QuintVar) => ir.QuintVar; exitVar?: (def: ir.QuintVar) => ir.QuintVar; enterAssume?: (def: ir.QuintAssume) => ir.QuintAssume; exitAssume?: (def: ir.QuintAssume) => ir.QuintAssume; enterTypeDef?: (def: ir.QuintTypeDef) => ir.QuintTypeDef; exitTypeDef?: (def: ir.QuintTypeDef) => ir.QuintTypeDef; enterImport?: (def: ir.QuintImport) => ir.QuintImport; exitImport?: (def: ir.QuintImport) => ir.QuintImport; enterExport?: (def: ir.QuintExport) => ir.QuintExport; exitExport?: (def: ir.QuintExport) => ir.QuintExport; enterInstance?: (def: ir.QuintInstance) => ir.QuintInstance; exitInstance?: (def: ir.QuintInstance) => ir.QuintInstance; /** Expressions */ enterName?: (expr: ir.QuintName) => ir.QuintName; exitName?: (expr: ir.QuintName) => ir.QuintName; enterLiteral?: (expr: ir.QuintBool | ir.QuintInt | ir.QuintStr) => ir.QuintBool | ir.QuintInt | ir.QuintStr; exitLiteral?: (expr: ir.QuintBool | ir.QuintInt | ir.QuintStr) => ir.QuintBool | ir.QuintInt | ir.QuintStr; enterApp?: (expr: ir.QuintApp) => ir.QuintApp; exitApp?: (expr: ir.QuintApp) => ir.QuintApp; enterLambda?: (expr: ir.QuintLambda) => ir.QuintLambda; exitLambda?: (expr: ir.QuintLambda) => ir.QuintLambda; enterLet?: (expr: ir.QuintLet) => ir.QuintLet; exitLet?: (expr: ir.QuintLet) => ir.QuintLet; /** Types */ enterLiteralType?: (type: t.QuintBoolType | t.QuintIntType | t.QuintStrType) => t.QuintBoolType | t.QuintIntType | t.QuintStrType; exitLiteralType?: (type: t.QuintBoolType | t.QuintIntType | t.QuintStrType) => t.QuintBoolType | t.QuintIntType | t.QuintStrType; enterConstType?: (type: t.QuintConstType) => t.QuintConstType; exitConstType?: (type: t.QuintConstType) => t.QuintConstType; enterVarType?: (type: t.QuintVarType) => t.QuintVarType; exitVarType?: (type: t.QuintVarType) => t.QuintVarType; enterSetType?: (type: t.QuintSetType) => t.QuintSetType; exitSetType?: (type: t.QuintSetType) => t.QuintSetType; enterSeqType?: (type: t.QuintSeqType) => t.QuintSeqType; exitSeqType?: (type: t.QuintSeqType) => t.QuintSeqType; enterFunType?: (type: t.QuintFunType) => t.QuintFunType; exitFunType?: (type: t.QuintFunType) => t.QuintFunType; enterOperType?: (type: t.QuintOperType) => t.QuintOperType; exitOperType?: (type: t.QuintOperType) => t.QuintOperType; enterTupleType?: (type: t.QuintTupleType) => t.QuintTupleType; exitTupleType?: (type: t.QuintTupleType) => t.QuintTupleType; enterRecordType?: (type: t.QuintRecordType) => t.QuintRecordType; exitRecordType?: (type: t.QuintRecordType) => t.QuintRecordType; enterSumType?: (type: t.QuintSumType) => t.QuintSumType; exitSumType?: (type: t.QuintSumType) => t.QuintSumType; enterAppType?: (type: t.QuintAppType) => t.QuintAppType; exitAppType?: (type: t.QuintAppType) => t.QuintAppType; /** Row types */ enterRow?: (row: t.Row) => t.Row; exitRow?: (row: t.Row) => t.Row; enterConcreteRow?: (row: t.ConcreteRow) => t.ConcreteRow; exitConcreteRow?: (row: t.ConcreteRow) => t.ConcreteRow; enterVarRow?: (row: t.VarRow) => t.VarRow; exitVarRow?: (row: t.VarRow) => t.VarRow; enterEmptyRow?: (row: t.EmptyRow) => t.EmptyRow; exitEmptyRow?: (row: t.EmptyRow) => t.EmptyRow; } /** * Navigates a Quint module with a transformer, invoking the correspondent function for each * found IR component. * * @param transformer: the IRTransformer instance with the functions to be invoked * @param quintModule: the Quint module to be navigated * * @returns the transformed Quint module */ export declare function transformModule(transformer: IRTransformer, quintModule: ir.QuintModule): ir.QuintModule; /** * Navigates a Quint type with a transformer, invoking the correspondent function for each * inner type. * * @param transformer: the IRTransformer instance with the functions to be invoked * @param type: the Quint type to be navigated * * @returns the transformed Quint type */ export declare function transformType(transformer: IRTransformer, type: t.QuintType): t.QuintType; /** * Transforms a Quint LookupDefinition with a transformer * * This is just a thin wrapper to deal with the fact that LookupDefinitions are a slightly awkward union. * * @param transformer: the IRTransformer instance with the functions to be invoked * @param lud: the Quint LookupDefinition to be transformed * * @returns the transformed LookupDefinition */ export declare function transformLookupDefinition(transformer: IRTransformer, lud: LookupDefinition): LookupDefinition; /** * Transforms a Quint declaration with a transformer, invoking the corresponding function for each * inner component. * * @param transformer: the IRTransformer instance with the functions to be invoked * @param decl: the Quint declaration to be transformed * * @returns the transformed Quint definition */ export declare function transformDeclaration(transformer: IRTransformer, decl: ir.QuintDeclaration): ir.QuintDeclaration; /** * Transforms a Quint definition with a transformer, invoking the correspondent function for each * inner component. * * @param transformer: the IRTransformer instance with the functions to be invoked * @param def: the Quint definition to be transformed * * @returns the transformed Quint definition */ export declare function transformDefinition(transformer: IRTransformer, def: ir.QuintDef): ir.QuintDef; /** * Transforms a Quint row with a transformer, invoking the correspondent function for each * inner component. * * @param transformer: the IRTransformer instance with the functions to be invoked * @param row: the Quint row to be transformed * * @returns the transformed Quint row */ export declare function transformRow(transformer: IRTransformer, row: t.Row): t.Row;