summaryrefslogtreecommitdiff
path: root/src/mbgl/style/expression
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/style/expression')
-rw-r--r--src/mbgl/style/expression/assertion.cpp10
-rw-r--r--src/mbgl/style/expression/boolean_operator.cpp8
-rw-r--r--src/mbgl/style/expression/case.cpp13
-rw-r--r--src/mbgl/style/expression/coalesce.cpp10
-rw-r--r--src/mbgl/style/expression/coercion.cpp10
-rw-r--r--src/mbgl/style/expression/equals.cpp4
-rw-r--r--src/mbgl/style/expression/interpolate.cpp10
-rw-r--r--src/mbgl/style/expression/let.cpp8
-rw-r--r--src/mbgl/style/expression/match.cpp14
-rw-r--r--src/mbgl/style/expression/step.cpp10
10 files changed, 97 insertions, 0 deletions
diff --git a/src/mbgl/style/expression/assertion.cpp b/src/mbgl/style/expression/assertion.cpp
index a17c53cf54..0187921af9 100644
--- a/src/mbgl/style/expression/assertion.cpp
+++ b/src/mbgl/style/expression/assertion.cpp
@@ -66,6 +66,16 @@ bool Assertion::operator==(const Expression& e) const {
return false;
}
+std::vector<optional<Value>> Assertion::possibleOutputs() const {
+ std::vector<optional<Value>> result;
+ for (const auto& input : inputs) {
+ for (auto& output : input->possibleOutputs()) {
+ result.push_back(std::move(output));
+ }
+ }
+ return result;
+}
+
} // namespace expression
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/expression/boolean_operator.cpp b/src/mbgl/style/expression/boolean_operator.cpp
index 88797f965a..8d277450ba 100644
--- a/src/mbgl/style/expression/boolean_operator.cpp
+++ b/src/mbgl/style/expression/boolean_operator.cpp
@@ -26,6 +26,10 @@ bool Any::operator==(const Expression& e) const {
return false;
}
+std::vector<optional<Value>> Any::possibleOutputs() const {
+ return {{ true }, { false }};
+}
+
EvaluationResult All::evaluate(const EvaluationContext& params) const {
for (auto it = inputs.begin(); it != inputs.end(); it++) {
@@ -49,6 +53,10 @@ bool All::operator==(const Expression& e) const {
return false;
}
+std::vector<optional<Value>> All::possibleOutputs() const {
+ return {{ true }, { false }};
+}
+
using namespace mbgl::style::conversion;
template <class T>
diff --git a/src/mbgl/style/expression/case.cpp b/src/mbgl/style/expression/case.cpp
index 049f258606..295e694189 100644
--- a/src/mbgl/style/expression/case.cpp
+++ b/src/mbgl/style/expression/case.cpp
@@ -34,6 +34,19 @@ bool Case::operator==(const Expression& e) const {
return false;
}
+std::vector<optional<Value>> Case::possibleOutputs() const {
+ std::vector<optional<Value>> result;
+ for (const auto& branch : branches) {
+ for (auto& output : branch.second->possibleOutputs()) {
+ result.push_back(std::move(output));
+ }
+ }
+ for (auto& output : otherwise->possibleOutputs()) {
+ result.push_back(std::move(output));
+ }
+ return result;
+}
+
using namespace mbgl::style::conversion;
ParseResult Case::parse(const Convertible& value, ParsingContext& ctx) {
assert(isArray(value));
diff --git a/src/mbgl/style/expression/coalesce.cpp b/src/mbgl/style/expression/coalesce.cpp
index 0373c9626c..872a9abbef 100644
--- a/src/mbgl/style/expression/coalesce.cpp
+++ b/src/mbgl/style/expression/coalesce.cpp
@@ -27,6 +27,16 @@ bool Coalesce::operator==(const Expression& e) const {
return false;
}
+std::vector<optional<Value>> Coalesce::possibleOutputs() const {
+ std::vector<optional<Value>> result;
+ for (const auto& arg : args) {
+ for (auto& output : arg->possibleOutputs()) {
+ result.push_back(std::move(output));
+ }
+ }
+ return result;
+}
+
using namespace mbgl::style::conversion;
ParseResult Coalesce::parse(const Convertible& value, ParsingContext& ctx) {
assert(isArray(value));
diff --git a/src/mbgl/style/expression/coercion.cpp b/src/mbgl/style/expression/coercion.cpp
index 8ed8e160dd..56ab33fcfd 100644
--- a/src/mbgl/style/expression/coercion.cpp
+++ b/src/mbgl/style/expression/coercion.cpp
@@ -136,6 +136,16 @@ bool Coercion::operator==(const Expression& e) const {
return false;
}
+std::vector<optional<Value>> Coercion::possibleOutputs() const {
+ std::vector<optional<Value>> result;
+ for (const auto& input : inputs) {
+ for (auto& output : input->possibleOutputs()) {
+ result.push_back(std::move(output));
+ }
+ }
+ return result;
+}
+
} // namespace expression
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/expression/equals.cpp b/src/mbgl/style/expression/equals.cpp
index 08ef85e92b..6d963cc1d8 100644
--- a/src/mbgl/style/expression/equals.cpp
+++ b/src/mbgl/style/expression/equals.cpp
@@ -37,6 +37,10 @@ bool Equals::operator==(const Expression& e) const {
return false;
}
+std::vector<optional<Value>> Equals::possibleOutputs() const {
+ return {{ true }, { false }};
+}
+
static bool isComparableType(const type::Type& type) {
return type == type::String ||
type == type::Number ||
diff --git a/src/mbgl/style/expression/interpolate.cpp b/src/mbgl/style/expression/interpolate.cpp
index 5ddfca8e9f..4cb22a3e4f 100644
--- a/src/mbgl/style/expression/interpolate.cpp
+++ b/src/mbgl/style/expression/interpolate.cpp
@@ -206,6 +206,16 @@ ParseResult parseInterpolate(const Convertible& value, ParsingContext& ctx) {
);
}
+std::vector<optional<Value>> InterpolateBase::possibleOutputs() const {
+ std::vector<optional<Value>> result;
+ for (const auto& stop : stops) {
+ for (auto& output : stop.second->possibleOutputs()) {
+ result.push_back(std::move(output));
+ }
+ }
+ return result;
+}
+
} // namespace expression
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/expression/let.cpp b/src/mbgl/style/expression/let.cpp
index 5c08248eef..fe48138ac3 100644
--- a/src/mbgl/style/expression/let.cpp
+++ b/src/mbgl/style/expression/let.cpp
@@ -17,6 +17,10 @@ void Let::eachChild(const std::function<void(const Expression&)>& visit) const {
visit(*result);
}
+std::vector<optional<Value>> Let::possibleOutputs() const {
+ return result->possibleOutputs();
+}
+
using namespace mbgl::style::conversion;
ParseResult Let::parse(const Convertible& value, ParsingContext& ctx) {
@@ -67,6 +71,10 @@ EvaluationResult Var::evaluate(const EvaluationContext& params) const {
void Var::eachChild(const std::function<void(const Expression&)>&) const {}
+std::vector<optional<Value>> Var::possibleOutputs() const {
+ return { nullopt };
+}
+
ParseResult Var::parse(const Convertible& value_, ParsingContext& ctx) {
assert(isArray(value_));
diff --git a/src/mbgl/style/expression/match.cpp b/src/mbgl/style/expression/match.cpp
index 35356747c9..0b2790b688 100644
--- a/src/mbgl/style/expression/match.cpp
+++ b/src/mbgl/style/expression/match.cpp
@@ -26,6 +26,20 @@ bool Match<T>::operator==(const Expression& e) const {
return false;
}
+template <typename T>
+std::vector<optional<Value>> Match<T>::possibleOutputs() const {
+ std::vector<optional<Value>> result;
+ for (const auto& branch : branches) {
+ for (auto& output : branch.second->possibleOutputs()) {
+ result.push_back(std::move(output));
+ }
+ }
+ for (auto& output : otherwise->possibleOutputs()) {
+ result.push_back(std::move(output));
+ }
+ return result;
+}
+
template<> EvaluationResult Match<std::string>::evaluate(const EvaluationContext& params) const {
const EvaluationResult inputValue = input->evaluate(params);
diff --git a/src/mbgl/style/expression/step.cpp b/src/mbgl/style/expression/step.cpp
index 11bf543b76..614a2addad 100644
--- a/src/mbgl/style/expression/step.cpp
+++ b/src/mbgl/style/expression/step.cpp
@@ -47,6 +47,16 @@ bool Step::operator==(const Expression& e) const {
return false;
}
+std::vector<optional<Value>> Step::possibleOutputs() const {
+ std::vector<optional<Value>> result;
+ for (const auto& stop : stops) {
+ for (auto& output : stop.second->possibleOutputs()) {
+ result.push_back(std::move(output));
+ }
+ }
+ return result;
+}
+
Range<float> Step::getCoveringStops(const double lower, const double upper) const {
return ::mbgl::style::expression::getCoveringStops(stops, lower, upper);
}