Skip to content
Snippets Groups Projects
Commit 89494944 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

throws for all unsuccessful abstraction operaions

parent 9c4b6da7
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -15,13 +15,17 @@ public:
bool normalize;
 
std::shared_ptr < abstraction::OperationAbstraction > res = abstraction::Registry::getCastAbstraction ( type, param->getReturnType ( ), normalize );
res->attachInput ( param, 0 );
res->eval ( );
if ( ! res->attachInput ( param, 0 ) )
throw exception::CommonException ( "Can't connect param at 0 of cast to " + type + " with result of type " + param->getReturnType ( ) + "." );
if ( ! res->eval ( ) )
throw exception::CommonException ( "Eval of cast to " + type + " failed." );
 
if ( normalize ) {
std::shared_ptr < abstraction::OperationAbstraction > normalized = abstraction::Registry::getNormalizeAbstraction ( res->getReturnType ( ) );
normalized->attachInput ( res, 0 );
normalized->eval ( );
if ( ! normalized->attachInput ( res, 0 ) )
throw exception::CommonException ( "Can't connect param at 0 of normalize of cast to " + type + " with result of type " + res->getReturnType ( ) + "." );
if ( ! normalized->eval ( ) )
throw exception::CommonException ( "Eval of normalize of cast to " + type + " failed." );
 
res = normalized;
}
......
......@@ -14,8 +14,10 @@ public:
 
virtual std::shared_ptr < abstraction::OperationAbstraction > translateAndEval ( const std::shared_ptr < abstraction::OperationAbstraction > & prev, Environment & environment ) const override {
std::shared_ptr < abstraction::OperationAbstraction > res = abstraction::Registry::getXmlFileWriterAbstraction ( prev->getReturnType ( ), m_file->eval ( environment ) );
res->attachInput ( prev, 0 );
res->eval ( );
if ( ! res->attachInput ( prev, 0 ) )
throw exception::CommonException ( "Can't connect param at 0 of result file statement with result of type " + prev->getReturnType ( ) + "." );
if ( ! res->eval ( ) )
throw exception::CommonException ( "Eval of result file statement failed." );
return res;
}
 
......
......@@ -12,8 +12,10 @@ public:
 
virtual std::shared_ptr < abstraction::OperationAbstraction > translateAndEval ( const std::shared_ptr < abstraction::OperationAbstraction > & prev, Environment & ) const override {
std::shared_ptr < abstraction::OperationAbstraction > res = abstraction::Registry::getValuePrinterAbstraction ( prev->getReturnType ( ) );
res->attachInput ( prev, 0 );
res->eval ( );
if ( ! res->attachInput ( prev, 0 ) )
throw exception::CommonException ( "Can't connect param at 0 of result print statement with result of type " + prev->getReturnType ( ) + "." );
if ( ! res->eval ( ) )
throw exception::CommonException ( "Eval of result print statement failed." );
return res;
}
 
......
......@@ -53,16 +53,20 @@ std::shared_ptr < abstraction::OperationAbstraction > SingleStatement::translate
 
if ( downcast ) {
std::shared_ptr < abstraction::OperationAbstraction > downcaster = abstraction::Registry::getDowncastAbstraction ( algo->getRuntimeReturnType ( ), algo->getReturnType ( ) );
downcaster->attachInput ( algo, 0 );
downcaster->eval ( );
if ( ! downcaster->attachInput ( algo, 0 ) )
throw exception::CommonException ( "Can't connect param at 0 of downcast of algorithm " + name + " with result of type " + algo->getReturnType ( ) + "." );
if ( ! downcaster->eval ( ) )
throw exception::CommonException ( "Eval of downcast of algorithm " + name + " failed." );
 
algo = downcaster;
}
 
if ( normalize ) {
std::shared_ptr < abstraction::OperationAbstraction > normalized = abstraction::Registry::getNormalizeAbstraction ( algo->getReturnType ( ) );
normalized->attachInput ( algo, 0 );
normalized->eval ( );
if ( ! normalized->attachInput ( algo, 0 ) )
throw exception::CommonException ( "Can't connect param at 0 of normalize of algorithm " + name + " with result of type " + algo->getReturnType ( ) + "." );
if ( ! normalized->eval ( ) )
throw exception::CommonException ( "Eval of normalize of algorithm " + name + " failed." );
 
algo = normalized;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment