#include "lattice_climb.hpp" #include #include namespace shoop { using namespace std::string_literals; using ln = invocation_lattice_node; ln ln::promote( const formula &pre ) const { auto node = *this; for ( const auto var : pre.referenced_parameters() ) { auto &par = node._pattern[ var ]; if ( par == parameter_domain::unit ) par = parameter_domain::term; } return node; } ln ln::promote() const { auto node = *this; for ( size_t i = 0; i < _pattern.size(); ++i ) { auto &par = node._pattern[ i ]; if ( par == parameter_domain::unit ) par = parameter_domain::term; } return node; } std::vector< ln > ln::get_successors() const { auto succs = std::vector< ln >(); for ( size_t i = 0; i < _pattern.size(); ++i ) { if ( _pattern[ i ] == parameter_domain::sunit ) { auto new_pattern = _pattern; new_pattern[ i ] = parameter_domain::unit; succs.emplace_back( std::move( new_pattern ) ); } } return succs; } std::string ln::to_string( const std::string &unit, const std::string &sunit, const std::string &term, const std::string &separator ) const { // TODO: Change to brq::stringbuilder (see trace.cpp) auto ss = std::stringstream(); auto sep = ""; for ( auto dom : _pattern ) { ss << sep; ss << from_domain( dom, unit, sunit, term ); sep = separator.c_str(); } return ss.str(); } }