#pragma once #include #include #include #include #include namespace mbgl { namespace style { namespace expression { class Let : public Expression { public: using Bindings = std::map>; Let(Bindings bindings_, std::unique_ptr result_) : Expression(result_->getType()), bindings(std::move(bindings_)), result(std::move(result_)) {} static ParseResult parse(const mbgl::style::conversion::Convertible&, ParsingContext&); EvaluationResult evaluate(const EvaluationContext& params) const override; void eachChild(const std::function&) const override; bool operator==(const Expression& e) const override { if (auto rhs = dynamic_cast(&e)) { return *result == *(rhs->result); } return false; } std::vector> possibleOutputs() const override; Expression* getResult() const { return result.get(); } mbgl::Value serialize() const override; std::string getOperator() const override { return "let"; } private: Bindings bindings; std::unique_ptr result; }; class Var : public Expression { public: Var(std::string name_, std::shared_ptr value_) : Expression(value_->getType()), name(std::move(name_)), value(value_) {} static ParseResult parse(const mbgl::style::conversion::Convertible&, ParsingContext&); EvaluationResult evaluate(const EvaluationContext& params) const override; void eachChild(const std::function&) const override; bool operator==(const Expression& e) const override { if (auto rhs = dynamic_cast(&e)) { return *value == *(rhs->value); } return false; } std::vector> possibleOutputs() const override; mbgl::Value serialize() const override; std::string getOperator() const override { return "var"; } const std::shared_ptr& getBoundExpression() const { return value; } private: std::string name; std::shared_ptr value; }; } // namespace expression } // namespace style } // namespace mbgl