From: Tim King Date: Tue, 11 Sep 2012 00:20:51 +0000 (+0000) Subject: Partially reverting the changes made in 4308. There is now both an Expr and Node... X-Git-Tag: cvc5-1.0.0~7817 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d8883776ce80199096f99d1088910d478fd0cd6e;p=cvc5.git Partially reverting the changes made in 4308. There is now both an Expr and Node version of getValue() in TheoryModel. --- diff --git a/src/printer/cvc/cvc_printer.cpp b/src/printer/cvc/cvc_printer.cpp index 9e61fb8df..5803ad23f 100644 --- a/src/printer/cvc/cvc_printer.cpp +++ b/src/printer/cvc/cvc_printer.cpp @@ -777,7 +777,7 @@ void CvcPrinter::toStream(std::ostream& out, Model* m, Command* c, int c_type ) } out << "): "; } - out << Node::fromExpr( tm->getValue( n.toExpr() ) ); + out << tm->getValue( n ); out << ";" << std::endl; /* diff --git a/src/printer/smt2/smt2_printer.cpp b/src/printer/smt2/smt2_printer.cpp index 6c6d2a576..9400b7732 100644 --- a/src/printer/smt2/smt2_printer.cpp +++ b/src/printer/smt2/smt2_printer.cpp @@ -558,7 +558,7 @@ void Smt2Printer::toStream(std::ostream& out, Model* m, Command* c, int c_type ) out << ") " << tn; } out << " "; - out << Node::fromExpr( tm->getValue( n.toExpr() ) ); + out << tm->getValue( n ); out << ")" << std::endl; /* diff --git a/src/smt/smt_engine.cpp b/src/smt/smt_engine.cpp index 6e6ee365a..b9732c32e 100644 --- a/src/smt/smt_engine.cpp +++ b/src/smt/smt_engine.cpp @@ -1768,7 +1768,7 @@ Expr SmtEngine::getValue(const Expr& e) theory::TheoryModel* m = d_theoryEngine->getModel(); Node resultNode; if( m ){ - resultNode = Node::fromExpr( m->getValue( n.toExpr() ) ); + resultNode = m->getValue( n ); } Trace("smt") << "--- got value " << n << " = " << resultNode << endl; // type-check the result we got @@ -1846,7 +1846,7 @@ CVC4::SExpr SmtEngine::getAssignment() throw(ModalException, AssertionException) theory::TheoryModel* m = d_theoryEngine->getModel(); Node resultNode; if( m ){ - resultNode = Node::fromExpr( m->getValue( n.toExpr() ) ); + resultNode = m->getValue( n ); } // type-check the result we got diff --git a/src/theory/model.cpp b/src/theory/model.cpp index 67640c309..dc0ae7877 100644 --- a/src/theory/model.cpp +++ b/src/theory/model.cpp @@ -46,12 +46,16 @@ void TheoryModel::reset(){ d_rep_set.clear(); } -Expr TheoryModel::getValue( const Expr& expr ){ - Node n = Node::fromExpr( expr ); +Node TheoryModel::getValue( TNode n ){ //apply substitutions Node nn = d_substitutions.apply( n ); //get value in model - Node ret = getModelValue( nn ); + return getModelValue( nn ); +} + +Expr TheoryModel::getValue( const Expr& expr ){ + Node n = Node::fromExpr( expr ); + Node ret = getValue( n ); return ret.toExpr(); } @@ -553,4 +557,4 @@ Node TheoryEngineModelBuilder::normalizeNode( TheoryModel* m, Node r, std::map< }else{ return r; } -} \ No newline at end of file +} diff --git a/src/theory/model.h b/src/theory/model.h index 06618e07c..ea1fa0fed 100644 --- a/src/theory/model.h +++ b/src/theory/model.h @@ -70,6 +70,12 @@ protected: */ Node getModelValue( TNode n ); public: + /** + * Get value function. This should be called only after a ModelBuilder has called buildModel(...) + * on this model. + */ + Node getValue( TNode n ); + /** get existing domain value, with possible exclusions * This function returns a term in d_rep_set.d_type_reps[tn] but not in exclude */ @@ -108,8 +114,10 @@ public: bool areEqual( Node a, Node b ); bool areDisequal( Node a, Node b ); public: - /** get value function */ + /** get value function for Exprs. */ Expr getValue( const Expr& expr ); + + /** to stream function */ void toStream( std::ostream& out ); public: