diff --git a/alib2abstraction/src/abstraction/NaryOperationAbstraction.cpp b/alib2abstraction/src/abstraction/NaryOperationAbstraction.cpp new file mode 100644 index 0000000000000000000000000000000000000000..28824adcdaea24b3451b2e37e463e492003b832c --- /dev/null +++ b/alib2abstraction/src/abstraction/NaryOperationAbstraction.cpp @@ -0,0 +1,13 @@ +/* + * NaryOperationAbstraction.hpp + * + * Created on: 20. 8. 2017 + * Author: Jan Travnicek + */ + +#include "NaryOperationAbstraction.hpp" + +template class abstraction::NaryOperationAbstractionImpl < 0 >; +template class abstraction::NaryOperationAbstractionImpl < 1 >; +template class abstraction::NaryOperationAbstractionImpl < 2 >; +template class abstraction::NaryOperationAbstractionImpl < 3 >; diff --git a/alib2abstraction/src/abstraction/ReturnValueOperationAbstraction.cpp b/alib2abstraction/src/abstraction/ReturnValueOperationAbstraction.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5c1263a9944d5585a368af781c68730cf8fd11d0 --- /dev/null +++ b/alib2abstraction/src/abstraction/ReturnValueOperationAbstraction.cpp @@ -0,0 +1,28 @@ +/* + * ValueOperationAbstraction.cpp + * + * Created on: 11. 7. 2017 + * Author: Jan Travnicek + */ + +#include <abstraction/ReturnValueOperationAbstraction.hpp> + +namespace abstraction { + +ext::type_index ReturnValueOperationAbstraction < void >::getReturnTypeIndex ( ) const { + return ext::type_index ( typeid ( void ) ); +} + +ext::set < abstraction::ParamQualifiers::ParamQualifier > ReturnValueOperationAbstraction < void >::getReturnTypeQualifiers ( ) const { + return abstraction::ParamQualifiers::paramQualifiers < void > ( ); +} + +bool ReturnValueOperationAbstraction < void >::evaluated ( ) const { + return false; +} + +std::shared_ptr < abstraction::OperationAbstraction > ReturnValueOperationAbstraction < void >::getVariableOperationAbstraction ( ) { + throw std::domain_error ( "Cannot create variable of void type" ); +} + +} /* namespace abstraction */ diff --git a/alib2abstraction/src/common/AlgorithmHelper.cpp b/alib2abstraction/src/common/AlgorithmHelper.cpp index 5527a5440edd6a86e726e5d45a1dc509ac7a1306..516bc7529a6b8539569fe53ac0c5bf174a55e303 100644 --- a/alib2abstraction/src/common/AlgorithmHelper.cpp +++ b/alib2abstraction/src/common/AlgorithmHelper.cpp @@ -12,7 +12,7 @@ namespace abstraction { -std::shared_ptr < abstraction::OperationAbstraction > AlgorithmHelper::eval ( const std::string & name, const ext::vector < std::string > & templateParams, const ext::vector < std::shared_ptr < abstraction::OperationAbstraction > > & params, std::vector < bool > & moves, AlgorithmCategories::AlgorithmCategory category ) { +std::shared_ptr < abstraction::OperationAbstraction > AlgorithmHelper::eval ( const std::string & name, const ext::vector < std::string > & templateParams, const ext::vector < std::shared_ptr < abstraction::OperationAbstraction > > & params, const std::vector < bool > & moves, AlgorithmCategories::AlgorithmCategory category ) { ext::vector < std::string > paramTypes; ext::vector < ext::set < abstraction::ParamQualifiers::ParamQualifier > > paramTypeQualifiers; for ( const std::shared_ptr < abstraction::OperationAbstraction > & param : params ) { @@ -29,7 +29,6 @@ std::shared_ptr < abstraction::OperationAbstraction > AlgorithmHelper::eval ( co casted_params.push_back ( param ); } else { casted_params.push_back ( abstraction::CastHelper::eval ( param, algo->getParamType ( i ), moves [ i ] ) ); - moves [ i ] = true; } ++ i; } @@ -61,5 +60,4 @@ std::shared_ptr < abstraction::OperationAbstraction > AlgorithmHelper::eval ( co return algo; } - } /* namespace abstraction */ diff --git a/alib2abstraction/src/common/AlgorithmHelper.h b/alib2abstraction/src/common/AlgorithmHelper.h index 59033af8e1372d3730a5b99e8d964f7d6ab285a5..49cb0a7d7d27a3c0feae8d1a6d51e67a32bd6f9f 100644 --- a/alib2abstraction/src/common/AlgorithmHelper.h +++ b/alib2abstraction/src/common/AlgorithmHelper.h @@ -18,7 +18,7 @@ namespace abstraction { class AlgorithmHelper { public: - static std::shared_ptr < abstraction::OperationAbstraction > eval ( const std::string & name, const ext::vector < std::string > & templateParams, const ext::vector < std::shared_ptr < abstraction::OperationAbstraction > > & params, std::vector < bool > & moves, AlgorithmCategories::AlgorithmCategory category ); + static std::shared_ptr < abstraction::OperationAbstraction > eval ( const std::string & name, const ext::vector < std::string > & templateParams, const ext::vector < std::shared_ptr < abstraction::OperationAbstraction > > & params, const std::vector < bool > & moves, AlgorithmCategories::AlgorithmCategory category ); }; diff --git a/alib2cli/src/ast/Statement.h b/alib2cli/src/ast/Statement.h index cffb0e994e8a3f472af9db310030710d33675317..398fd0baa0de36a4d6f92cd26cdeec4fb736fdf5 100644 --- a/alib2cli/src/ast/Statement.h +++ b/alib2cli/src/ast/Statement.h @@ -12,8 +12,6 @@ public: virtual ~Statement ( ) noexcept = default; virtual std::shared_ptr < abstraction::OperationAbstraction > translateAndEval ( const std::shared_ptr < abstraction::OperationAbstraction > & prev, Environment & environment ) const = 0; - - virtual bool getImplicitMove ( ) const = 0; }; } /* namespace cli */ diff --git a/alib2cli/src/ast/statements/CastStatement.h b/alib2cli/src/ast/statements/CastStatement.h index 1c66b10e1b962a43f9bf620f142a3bf38c09dce5..59c913faa437540d14a05d1d47a7e62f6843cef3 100644 --- a/alib2cli/src/ast/statements/CastStatement.h +++ b/alib2cli/src/ast/statements/CastStatement.h @@ -23,10 +23,6 @@ public: return abstraction::CastHelper::eval ( translatedStatement, type, m_move ); } - bool getImplicitMove ( ) const override { - return true; - } - }; } /* namespace cli */ diff --git a/alib2cli/src/ast/statements/ContainerStatement.cpp b/alib2cli/src/ast/statements/ContainerStatement.cpp index 976d2c0f2b4c9a830759580569cbff540c75abae..0d514e1757ad9f98a998205f78e1d3e92c003665 100644 --- a/alib2cli/src/ast/statements/ContainerStatement.cpp +++ b/alib2cli/src/ast/statements/ContainerStatement.cpp @@ -18,28 +18,20 @@ std::shared_ptr < abstraction::OperationAbstraction > ContainerStatement::transl std::shared_ptr < abstraction::OperationAbstraction > algo = abstraction::Registry::getContainerAbstraction ( m_container, m_type->getType ( ) ); - ext::vector < bool > moves ( m_moves.size ( ) ); - unsigned i = 0; - for ( const std::shared_ptr < Statement > & param : m_params ) { - moves [ i ] = m_moves [ i ] | param->getImplicitMove ( ); - ++ i; - } - - i = 0; + int i = 0; ext::vector < std::shared_ptr < abstraction::OperationAbstraction > > casted_params; for ( const std::shared_ptr < abstraction::OperationAbstraction > & param : params ) { if ( abstraction::Registry::isCastNoOp ( algo->getParamType ( i ), param->getReturnType ( ) ) ) { casted_params.push_back ( param ); } else { - casted_params.push_back ( abstraction::CastHelper::eval ( param, algo->getParamType ( i ), moves [ i ] ) ); - moves [ i ] = true; + casted_params.push_back ( abstraction::CastHelper::eval ( param, algo->getParamType ( i ), m_moves [ i ] ) ); } ++ i; } i = 0; for ( const std::shared_ptr < abstraction::OperationAbstraction > & param : casted_params ) { - if ( ! algo->attachInput ( param, i, moves [ i ], true ) ) + if ( ! algo->attachInput ( param, i, m_moves [ i ], true ) ) throw std::invalid_argument ( "Can't connect param at " + ext::to_string ( i ) + " of algorithm " + m_container + " with result of type " + param->getReturnType ( ) + "." ); ++ i; } diff --git a/alib2cli/src/ast/statements/ContainerStatement.h b/alib2cli/src/ast/statements/ContainerStatement.h index fdca5a93580cc101651222791d298dc063df57e5..15afd19278dffc79e97d52600069bbcdb632f928 100644 --- a/alib2cli/src/ast/statements/ContainerStatement.h +++ b/alib2cli/src/ast/statements/ContainerStatement.h @@ -17,9 +17,6 @@ public: std::shared_ptr < abstraction::OperationAbstraction > translateAndEval ( const std::shared_ptr < abstraction::OperationAbstraction > & prev, Environment & environment ) const override; - bool getImplicitMove ( ) const override { - return true; - } }; } /* namespace cli */ diff --git a/alib2cli/src/ast/statements/FileStatement.h b/alib2cli/src/ast/statements/FileStatement.h index 80e492823d7e113a356740dbd7f0f7bee09300b1..ceaeff0540725713a0b33bbe9d3a264186531d2a 100644 --- a/alib2cli/src/ast/statements/FileStatement.h +++ b/alib2cli/src/ast/statements/FileStatement.h @@ -17,9 +17,6 @@ public: std::shared_ptr < abstraction::OperationAbstraction > translateAndEval ( const std::shared_ptr < abstraction::OperationAbstraction > &, Environment & environment ) const override; - bool getImplicitMove ( ) const override { - return true; - } }; } /* namespace cli */ diff --git a/alib2cli/src/ast/statements/ImmediateStatement.h b/alib2cli/src/ast/statements/ImmediateStatement.h index 75f910acfc1771bf50f40e5cc81f99a5369f08ef..96f04b0b858d868c8602011e5dc7e5a5ff243d06 100644 --- a/alib2cli/src/ast/statements/ImmediateStatement.h +++ b/alib2cli/src/ast/statements/ImmediateStatement.h @@ -18,9 +18,6 @@ public: return std::make_shared < abstraction::ImmediateValueAbstraction < Type > > ( m_data ); } - bool getImplicitMove ( ) const override { - return true; - } }; } /* namespace cli */ diff --git a/alib2cli/src/ast/statements/PreviousResultStatement.h b/alib2cli/src/ast/statements/PreviousResultStatement.h index 5dd56bcea06a02bb50d7a11f6e016945305de971..fd7855fb23ed38aec539678f3aabef2c29947413 100644 --- a/alib2cli/src/ast/statements/PreviousResultStatement.h +++ b/alib2cli/src/ast/statements/PreviousResultStatement.h @@ -14,9 +14,6 @@ public: return prev; } - bool getImplicitMove ( ) const override { - return false; - } }; } /* namespace cli */ diff --git a/alib2cli/src/ast/statements/ResultFileStatement.h b/alib2cli/src/ast/statements/ResultFileStatement.h index 97a7e2a536f0244131be81d2d71f7571cb5374ad..72678e62b06871e2bffd03c2aa4f389b530bb06e 100644 --- a/alib2cli/src/ast/statements/ResultFileStatement.h +++ b/alib2cli/src/ast/statements/ResultFileStatement.h @@ -30,10 +30,6 @@ public: return res; } - bool getImplicitMove ( ) const override { - return false; - } - }; } /* namespace cli */ diff --git a/alib2cli/src/ast/statements/ResultPrintStatement.h b/alib2cli/src/ast/statements/ResultPrintStatement.h index 54a3fe4f5797e08cad2548647edbe1b6f7891bee..e43e3b4f7671f4674d99829e152caf01cead4257 100644 --- a/alib2cli/src/ast/statements/ResultPrintStatement.h +++ b/alib2cli/src/ast/statements/ResultPrintStatement.h @@ -24,10 +24,6 @@ public: return res; } - bool getImplicitMove ( ) const override { - return false; - } - }; } /* namespace cli */ diff --git a/alib2cli/src/ast/statements/ResultVariableStatement.h b/alib2cli/src/ast/statements/ResultVariableStatement.h index bc98979183ba7f530eaa6e6567076b08f38f1844..f3bda09aa8d996bb4d21a266f055885523ea6c79 100644 --- a/alib2cli/src/ast/statements/ResultVariableStatement.h +++ b/alib2cli/src/ast/statements/ResultVariableStatement.h @@ -19,10 +19,6 @@ public: return res; } - bool getImplicitMove ( ) const override { - return false; - } - }; } /* namespace cli */ diff --git a/alib2cli/src/ast/statements/SingleStatement.cpp b/alib2cli/src/ast/statements/SingleStatement.cpp index bd77d7b1fd61939786615b42d85ee4b116bfc6dd..5c249ca512d59f687c1c8ca487764ed140b4d62b 100644 --- a/alib2cli/src/ast/statements/SingleStatement.cpp +++ b/alib2cli/src/ast/statements/SingleStatement.cpp @@ -14,13 +14,6 @@ std::shared_ptr < abstraction::OperationAbstraction > SingleStatement::translate params.push_back ( param->translateAndEval ( prev, environment ) ); } - ext::vector < bool > moves ( m_moves.size ( ) ); - unsigned i = 0; - for ( const std::shared_ptr < Statement > & param : m_params ) { - moves [ i ] = m_moves [ i ] | param->getImplicitMove ( ); - ++ i; - } - std::string name = m_name->eval ( environment ); ext::vector < std::string > templateParams; @@ -31,7 +24,7 @@ std::shared_ptr < abstraction::OperationAbstraction > SingleStatement::translate if ( m_category ) category = m_category->getCategory ( ); - return abstraction::AlgorithmHelper::eval ( name, templateParams, params, moves, category ); + return abstraction::AlgorithmHelper::eval ( name, templateParams, params, m_moves, category ); } } /* namespace cli */ diff --git a/alib2cli/src/ast/statements/SingleStatement.h b/alib2cli/src/ast/statements/SingleStatement.h index 8502a5b031929076540a3a3a1e5dd1f420934654..2f6265f5b03008b99d9e2184f37c6081ffc0049b 100644 --- a/alib2cli/src/ast/statements/SingleStatement.h +++ b/alib2cli/src/ast/statements/SingleStatement.h @@ -19,9 +19,6 @@ public: std::shared_ptr < abstraction::OperationAbstraction > translateAndEval ( const std::shared_ptr < abstraction::OperationAbstraction > & prev, Environment & environment ) const override; - bool getImplicitMove ( ) const override { - return false; - } }; } /* namespace cli */ diff --git a/alib2cli/src/ast/statements/StatementList.h b/alib2cli/src/ast/statements/StatementList.h index 842bc9f163fc2d6832cf7eccc61234a9aabb993d..3fbe8c714451bd9f7e89016738a50f1d20c843b8 100644 --- a/alib2cli/src/ast/statements/StatementList.h +++ b/alib2cli/src/ast/statements/StatementList.h @@ -27,9 +27,6 @@ public: m_statements.emplace_back ( std::move ( statement ) ); } - bool getImplicitMove ( ) const override { - return false; - } }; } /* namespace cli */ diff --git a/alib2cli/src/ast/statements/ValueStatement.h b/alib2cli/src/ast/statements/ValueStatement.h index ec526380ad14334740ca9eed7055fba57ae8be34..94f8d52fb756a0dac2c9894b6ad4cf6afb1c3691 100644 --- a/alib2cli/src/ast/statements/ValueStatement.h +++ b/alib2cli/src/ast/statements/ValueStatement.h @@ -17,9 +17,6 @@ public: return std::make_shared < abstraction::ImmediateValueAbstraction < std::string > > ( m_arg->eval ( environment ) ); } - bool getImplicitMove ( ) const override { - return true; - } }; } /* namespace cli */ diff --git a/alib2cli/src/ast/statements/VariableStatement.h b/alib2cli/src/ast/statements/VariableStatement.h index f3a655e30c559af717f857f825894eb82561ea16..7a9c9851ddfba1664bb0ae985b46b1ee2c0776e0 100644 --- a/alib2cli/src/ast/statements/VariableStatement.h +++ b/alib2cli/src/ast/statements/VariableStatement.h @@ -17,9 +17,6 @@ public: return environment.getVariable ( m_name->eval ( environment ) ); } - bool getImplicitMove ( ) const override { - return false; - } }; } /* namespace cli */ diff --git a/alib2raw_cli_integration/src/InputFileTypeRegistration.cpp b/alib2raw_cli_integration/src/InputFileTypeRegistration.cpp index cbd4faf4c9c6efc0c723312712b7778a189e0d80..1e7f823f7364367a3555788e5c336a040bead0b3 100644 --- a/alib2raw_cli_integration/src/InputFileTypeRegistration.cpp +++ b/alib2raw_cli_integration/src/InputFileTypeRegistration.cpp @@ -7,6 +7,9 @@ #include <abstraction/WrapperAbstraction.hpp> #include <abstraction/PackingAbstraction.hpp> +#include <registry/Registry.h> +#include <common/AlgorithmCategories.hpp> + namespace { std::shared_ptr < abstraction::OperationAbstraction > dummy4 ( const std::string & typehint, const ext::vector < std::string > & ) { diff --git a/alib2raw_cli_integration/src/OutputFileTypeRegistration.cpp b/alib2raw_cli_integration/src/OutputFileTypeRegistration.cpp index 668c59300a95a8d9133f9d009c20fcff309a004b..cbbd101832efdcba19cdbb598efd1913ae1516a8 100644 --- a/alib2raw_cli_integration/src/OutputFileTypeRegistration.cpp +++ b/alib2raw_cli_integration/src/OutputFileTypeRegistration.cpp @@ -8,6 +8,9 @@ #include <abstraction/PackingAbstraction.hpp> +#include <registry/Registry.h> +#include <common/AlgorithmCategories.hpp> + namespace { std::shared_ptr < abstraction::OperationAbstraction > dummy4 ( const std::string & typehint ) { diff --git a/alib2str_cli_integration/src/InputFileTypeRegistration.cpp b/alib2str_cli_integration/src/InputFileTypeRegistration.cpp index b6eed2f0239bd2a64874243e4bfe8f4867afd09f..2ed435e197c1b08ee00b0a96d5926442996658ae 100644 --- a/alib2str_cli_integration/src/InputFileTypeRegistration.cpp +++ b/alib2str_cli_integration/src/InputFileTypeRegistration.cpp @@ -7,6 +7,9 @@ #include <abstraction/WrapperAbstraction.hpp> #include <abstraction/PackingAbstraction.hpp> +#include <registry/Registry.h> +#include <common/AlgorithmCategories.hpp> + namespace { std::shared_ptr < abstraction::OperationAbstraction > dummy3 ( const std::string & typehint, const ext::vector < std::string > & ) { diff --git a/alib2str_cli_integration/src/OutputFileTypeRegistration.cpp b/alib2str_cli_integration/src/OutputFileTypeRegistration.cpp index 1b32d896488582454a389d0d7340dcecb0bd7876..22c682adb6ace121430036fd715be24f8ccc9fa0 100644 --- a/alib2str_cli_integration/src/OutputFileTypeRegistration.cpp +++ b/alib2str_cli_integration/src/OutputFileTypeRegistration.cpp @@ -8,6 +8,9 @@ #include <abstraction/PackingAbstraction.hpp> +#include <registry/Registry.h> +#include <common/AlgorithmCategories.hpp> + namespace { std::shared_ptr < abstraction::OperationAbstraction > dummy3 ( const std::string & typehint ) {