| 1582 | } |
| 1583 | |
| 1584 | Expression Expression::operator+(const Expression &other_expr) const { |
| 1585 | if (is_dynamic() && other_expr.is_dynamic()) { |
| 1586 | auto val_fn = val_fn_; |
| 1587 | auto other_val_fn = other_expr.val_fn_; |
| 1588 | auto sub_expr_generator = sub_expr_generator_; |
| 1589 | auto other_sub_expr_generator = other_expr.sub_expr_generator_; |
| 1590 | return make_dynamic([val_fn, |
| 1591 | other_val_fn, |
| 1592 | sub_expr_generator, |
| 1593 | other_sub_expr_generator](const Parameters ¶ms, |
| 1594 | const std::vector<Expression>& /*sub_exprs*/) -> Value { |
| 1595 | Value result = val_fn(params, sub_expr_generator(params)); |
| 1596 | return Value(result.asString().append(other_val_fn(params, other_sub_expr_generator(params)).asString())); |
| 1597 | }); |
| 1598 | } else if (is_dynamic() && !other_expr.is_dynamic()) { |
| 1599 | auto val_fn = val_fn_; |
| 1600 | auto other_val = other_expr.val_; |
| 1601 | auto sub_expr_generator = sub_expr_generator_; |
| 1602 | return make_dynamic([val_fn, |
| 1603 | other_val, |
| 1604 | sub_expr_generator](const Parameters ¶ms, |
| 1605 | const std::vector<Expression>& /*sub_exprs*/) -> Value { |
| 1606 | Value result = val_fn(params, sub_expr_generator(params)); |
| 1607 | return Value(result.asString().append(other_val.asString())); |
| 1608 | }); |
| 1609 | } else if (!is_dynamic() && other_expr.is_dynamic()) { |
| 1610 | auto val = val_; |
| 1611 | auto other_val_fn = other_expr.val_fn_; |
| 1612 | auto other_sub_expr_generator = other_expr.sub_expr_generator_; |
| 1613 | return make_dynamic([val, |
| 1614 | other_val_fn, |
| 1615 | other_sub_expr_generator](const Parameters ¶ms, |
| 1616 | const std::vector<Expression>& /*sub_exprs*/) -> Value { |
| 1617 | Value result(val); |
| 1618 | return Value(result.asString().append(other_val_fn(params, other_sub_expr_generator(params)).asString())); |
| 1619 | }); |
| 1620 | } else if (!is_dynamic() && !other_expr.is_dynamic()) { |
| 1621 | std::string result(val_.asString()); |
| 1622 | result.append(other_expr.val_.asString()); |
| 1623 | return make_static(result); |
| 1624 | } else { |
| 1625 | throw std::runtime_error("Invalid function composition"); |
| 1626 | } |
| 1627 | } |
| 1628 | |
| 1629 | Value Expression::operator()(const Parameters ¶ms) const { |
| 1630 | if (is_dynamic()) { |
nothing calls this directly
no test coverage detected