UNPKG

@informalsystems/quint

Version:

Core tool for the Quint specification language

64 lines 2.13 kB
"use strict"; /* ---------------------------------------------------------------------------------- * Copyright 2022 Informal Systems * Licensed under the Apache License, Version 2.0. * See LICENSE in the project root for license information. * --------------------------------------------------------------------------------- */ Object.defineProperty(exports, "__esModule", { value: true }); exports.walkEffect = void 0; /** * Visitor pattern implementation for Effect components. Use this to navigate an * Effect instead of implementing a recursion over it yourself. * * @author Gabriela Moreira * * @module */ const util_1 = require("../util"); /** * Navigates an Effect with a visitor, invoking the correspondent function for each * found Effect. * * @param visitor: the EffectVisitor instance with the functions to be invoked * @param effect: the effect to be navigated * * @returns nothing, any collected information has to be a state inside the EffectVisitor instance. */ function walkEffect(visitor, effect) { switch (effect.kind) { case 'concrete': { if (visitor.enterConcrete) { visitor.enterConcrete(effect); } if (visitor.exitConcrete) { visitor.exitConcrete(effect); } break; } case 'variable': { if (visitor.enterVariable) { visitor.enterVariable(effect); } if (visitor.exitVariable) { visitor.exitVariable(effect); } break; } case 'arrow': { if (visitor.enterArrow) { visitor.enterArrow(effect); } effect.params.forEach(e => walkEffect(visitor, e)); walkEffect(visitor, effect.result); if (visitor.exitArrow) { visitor.exitArrow(effect); } } break; default: (0, util_1.unreachable)(effect); } } exports.walkEffect = walkEffect; //# sourceMappingURL=EffectVisitor.js.map