You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
1.1 KiB

  1. #include "src/logic/LabelSubstitutionVisitor.h"
  2. #include "src/logic/Formulas.h"
  3. namespace storm {
  4. namespace logic {
  5. LabelSubstitutionVisitor::LabelSubstitutionVisitor(std::map<std::string, storm::expressions::Expression> const& labelToExpressionMapping) : labelToExpressionMapping(labelToExpressionMapping) {
  6. // Intentionally left empty.
  7. }
  8. std::shared_ptr<Formula> LabelSubstitutionVisitor::substitute(Formula const& f) const {
  9. boost::any result = f.accept(*this, boost::any());
  10. return boost::any_cast<std::shared_ptr<Formula>>(result);
  11. }
  12. boost::any LabelSubstitutionVisitor::visit(AtomicLabelFormula const& f, boost::any const& data) const {
  13. auto it = labelToExpressionMapping.find(f.getLabel());
  14. if (it != labelToExpressionMapping.end()) {
  15. return std::static_pointer_cast<Formula>(std::make_shared<AtomicExpressionFormula>(it->second));
  16. } else {
  17. return std::static_pointer_cast<Formula>(std::make_shared<AtomicLabelFormula>(f));
  18. }
  19. }
  20. }
  21. }