HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
formula_index_node.hpp
1// Copyright Take Vos 2020.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "formula_binary_operator_node.hpp"
8
9namespace tt {
10
14
15 datum evaluate(formula_evaluation_context& context) const override {
16 auto lhs_ = lhs->evaluate(context);
17 auto rhs_ = rhs->evaluate(context);
18
19 if (!lhs_.contains(rhs_)) {
20 tt_error_info().set<"parse_location">(location);
21 throw operation_error("Unknown key '{}'", rhs_);
22 }
23
24 try {
25 return lhs_[rhs_];
26 } catch (...) {
27 error_info(true).set<"parse_location">(location);
28 throw;
29 }
30 }
31
33 auto &lhs_ = lhs->evaluate_lvalue(context);
34 auto rhs_ = rhs->evaluate(context);
35 try {
36 return lhs_[rhs_];
37 } catch (...) {
38 error_info(true).set<"parse_location">(location);
39 throw;
40 }
41 }
42
43 std::string string() const noexcept override {
44 return fmt::format("({}[{}])", *lhs, *rhs);
45 }
46};
47
48}
Error information passed alongside an error code or exception.
Definition error_info.hpp:81
error_info & set(Arg &&value) noexcept
Set an information for a given tag.
Definition error_info.hpp:144
Exception thrown during execution of a dynamic operation.
Definition exception.hpp:37
Definition formula_binary_operator_node.hpp:11
Definition formula_evaluation_context.hpp:16
Definition formula_index_node.hpp:11
datum & evaluate_lvalue(formula_evaluation_context &context) const override
Evaluate an existing lvalue.
Definition formula_index_node.hpp:32
datum evaluate(formula_evaluation_context &context) const override
Evaluate an rvalue.
Definition formula_index_node.hpp:15
Definition parse_location.hpp:16
T move(T... args)