diff options
author | Marius Kintel <marius@kintel.net> | 2013-06-01 20:04:24 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2013-06-01 20:04:24 (GMT) |
commit | 695165542259984ba335cb46e415910dd06b746d (patch) | |
tree | 47ae38921e86a394c63d88f49e2bc93b65e08a93 /src | |
parent | 618c9ff223369f6061776490d872d717bd85e104 (diff) |
Some expressions didn't support toString, which caused an assertion failure. Part of #384
Diffstat (limited to 'src')
-rw-r--r-- | src/expr.cc | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/expr.cc b/src/expr.cc index 4355400..46d606f 100644 --- a/src/expr.cc +++ b/src/expr.cc @@ -172,23 +172,27 @@ std::string Expression::toString() const if (this->type == "*" || this->type == "/" || this->type == "%" || this->type == "+" || this->type == "-" || this->type == "<" || this->type == "<=" || this->type == "==" || - this->type == "!=" || this->type == ">=" || this->type == ">") { + this->type == "!=" || this->type == ">=" || this->type == ">" || + this->type == "&&" || this->type == "||") { stream << "(" << *this->children[0] << " " << this->type << " " << *this->children[1] << ")"; } else if (this->type == "?:") { - stream << "(" << *this->children[0] << " ? " << this->type << " : " << *this->children[1] << ")"; + stream << "(" << *this->children[0] << " ? " << *this->children[1] << " : " << *this->children[2] << ")"; } else if (this->type == "[]") { - stream << "(" << *this->children[0] << "[" << *this->children[1] << "])"; + stream << *this->children[0] << "[" << *this->children[1] << "]"; } else if (this->type == "I") { - stream << "(-" << *this->children[0] << ")"; + stream << "-" << *this->children[0]; + } + else if (this->type == "!") { + stream << "!" << *this->children[0]; } else if (this->type == "C") { 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] << " : " << *this->children[2] << "]"; } else if (this->type == "V") { stream << "["; @@ -202,7 +206,7 @@ std::string Expression::toString() const stream << this->var_name; } else if (this->type == "N") { - stream << "(" << *this->children[0] << "." << this->var_name << ")"; + stream << *this->children[0] << "." << this->var_name; } else if (this->type == "F") { stream << this->call_funcname << "("; |