diff --git a/src/language/ast/ASTNodeBuiltinFunctionExpressionBuilder.cpp b/src/language/ast/ASTNodeBuiltinFunctionExpressionBuilder.cpp index 54b0970eff20190d4b57d2adfc596ba71cf174d0..cdd9c43d977c6718dc5d900dbe0b96a15de54f47 100644 --- a/src/language/ast/ASTNodeBuiltinFunctionExpressionBuilder.cpp +++ b/src/language/ast/ASTNodeBuiltinFunctionExpressionBuilder.cpp @@ -231,6 +231,9 @@ ASTNodeBuiltinFunctionExpressionBuilder::_getArgumentConverter(const ASTNodeData } case ASTNodeDataType::double_t: { return std::make_unique<FunctionTupleArgumentConverter<ParameterContentT, double>>(argument_number); + } + case ASTNodeDataType::string_t: { + return std::make_unique<FunctionTupleArgumentConverter<ParameterContentT, std::string>>(argument_number); } // LCOV_EXCL_START default: { @@ -265,6 +268,9 @@ ASTNodeBuiltinFunctionExpressionBuilder::_getArgumentConverter(const ASTNodeData case ASTNodeDataType::double_t: { return std::make_unique<FunctionTupleArgumentConverter<ParameterContentT, double>>(argument_number); } + case ASTNodeDataType::string_t: { + return std::make_unique<FunctionTupleArgumentConverter<ParameterContentT, std::string>>(argument_number); + } case ASTNodeDataType::function_t: { const ASTNode& parent_node = argument_node_sub_data_type.m_parent_node; auto symbol_table = parent_node.m_symbol_table; @@ -457,7 +463,7 @@ ASTNodeBuiltinFunctionExpressionBuilder::_getArgumentConverter(const ASTNodeData } } case ASTNodeDataType::string_t: { - return get_function_argument_to_string_converter(); + return get_function_argument_to_tuple_converter(std::string{}); } // LCOV_EXCL_START default: { diff --git a/src/language/node_processor/FunctionArgumentConverter.hpp b/src/language/node_processor/FunctionArgumentConverter.hpp index f747672e2c036ab59402610cb7170218f96c15e3..3e22a9ae188574db47278f69cc264d0faf0c2f2c 100644 --- a/src/language/node_processor/FunctionArgumentConverter.hpp +++ b/src/language/node_processor/FunctionArgumentConverter.hpp @@ -219,6 +219,48 @@ class FunctionTupleArgumentConverter final : public IFunctionArgumentConverter } }, value); + } else if constexpr (std::is_same_v<std::string, ContentType>) { + std::visit( + [&](auto&& v) { + using ValueT = std::decay_t<decltype(v)>; + Assert(not std::is_same_v<ValueT, ContentType>, "should have been treated before"); + if constexpr (is_std_vector_v<ValueT>) { + using ContentT = typename ValueT::value_type; + if constexpr (std::is_same_v<ContentT, ContentType>) { + TupleType list_value; + list_value.reserve(v.size()); + for (size_t i = 0; i < v.size(); ++i) { + list_value.emplace_back(std::move(v[i])); + } + exec_policy.currentContext()[m_argument_id] = std::move(list_value); + } else if constexpr (not is_shared_ptr_v<ContentT>) { + TupleType list_value; + list_value.reserve(v.size()); + for (size_t i = 0; i < v.size(); ++i) { + std::ostringstream os; + const ContentT& content = v[i]; // useless helper for clang10 + os << content; + list_value.push_back(std::move(os.str())); + } + exec_policy.currentContext()[m_argument_id] = std::move(list_value); + } else { + // LCOV_EXCL_START + throw UnexpectedError(std::string{"cannot convert '"} + demangle<ValueT>() + "' to '" + + demangle<ContentType>() + "'"); + // LCOV_EXCL_STOP + } + } else if constexpr (not is_shared_ptr_v<ContentType>) { + std::ostringstream os; + os << v; + exec_policy.currentContext()[m_argument_id] = std::move(TupleType{std::move(os.str())}); + } else { + // LCOV_EXCL_START + throw UnexpectedError(std::string{"cannot convert '"} + demangle<ValueT>() + "' to '" + + demangle<ContentType>() + "'"); + // LCOV_EXCL_STOP + } + }, + value); } else { // LCOV_EXCL_START