diff options
author | Marius Kintel <marius@kintel.net> | 2013-12-09 04:12:13 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2013-12-09 04:12:13 (GMT) |
commit | 462d4d447885594629fefb8a658f9f1d079bcc44 (patch) | |
tree | 6690951e4f814b87a1a372a913b75ceda1f6cc1a /src/expr.cc | |
parent | 435e0c021c5018ee5de69d3218c3e31c8ab75be5 (diff) | |
parent | 33c34b6f7c43d19bbfa3bf91e7b577bcc062e5bd (diff) |
Merge branch 'master' into travis
Diffstat (limited to 'src/expr.cc')
-rw-r--r-- | src/expr.cc | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/expr.cc b/src/expr.cc index 594fccf..08615ba 100644 --- a/src/expr.cc +++ b/src/expr.cc @@ -117,11 +117,18 @@ Value Expression::evaluate(const Context *context) const if (this->type == "R") { Value v1 = this->children[0]->evaluate(context); Value v2 = this->children[1]->evaluate(context); - Value v3 = this->children[2]->evaluate(context); - if (v1.type() == Value::NUMBER && v2.type() == Value::NUMBER && v3.type() == Value::NUMBER) { - Value::RangeType range(v1.toDouble(), v2.toDouble(), v3.toDouble()); - return Value(range); - } + if (this->children.size() == 2) { + if (v1.type() == Value::NUMBER && v2.type() == Value::NUMBER) { + Value::RangeType range(v1.toDouble(), v2.toDouble()); + return Value(range); + } + } else { + Value v3 = this->children[2]->evaluate(context); + if (v1.type() == Value::NUMBER && v2.type() == Value::NUMBER && v3.type() == Value::NUMBER) { + Value::RangeType range(v1.toDouble(), v2.toDouble(), v3.toDouble()); + return Value(range); + } + } return Value(); } if (this->type == "V") { @@ -192,7 +199,11 @@ std::string Expression::toString() const stream << this->const_value; } else if (this->type == "R") { - stream << "[" << *this->children[0] << " : " << *this->children[1] << " : " << *this->children[2] << "]"; + stream << "[" << *this->children[0] << " : " << *this->children[1]; + if (this->children.size() > 2) { + stream << " : " << *this->children[2]; + } + stream << "]"; } else if (this->type == "V") { stream << "["; |