Corrected several assertions which could occur when using unary operators and
unresolved identifiers.
This commit is contained in:
parent
01aa3800fb
commit
660c40a6d3
1 changed files with 12 additions and 10 deletions
22
src/op.cc
22
src/op.cc
|
|
@ -141,11 +141,9 @@ value_t expr_t::op_t::calc(scope_t& scope)
|
||||||
return left()->calc(scope) / right()->calc(scope);
|
return left()->calc(scope) / right()->calc(scope);
|
||||||
|
|
||||||
case O_NEG:
|
case O_NEG:
|
||||||
assert(! right());
|
|
||||||
return left()->calc(scope).negate();
|
return left()->calc(scope).negate();
|
||||||
|
|
||||||
case O_NOT:
|
case O_NOT:
|
||||||
assert(! right());
|
|
||||||
return ! left()->calc(scope);
|
return ! left()->calc(scope);
|
||||||
|
|
||||||
case O_AND:
|
case O_AND:
|
||||||
|
|
@ -443,9 +441,10 @@ void expr_t::op_t::dump(std::ostream& out, const int depth) const
|
||||||
if (kind > TERMINALS || kind == IDENT) {
|
if (kind > TERMINALS || kind == IDENT) {
|
||||||
if (left()) {
|
if (left()) {
|
||||||
left()->dump(out, depth + 1);
|
left()->dump(out, depth + 1);
|
||||||
if (right())
|
if (kind > UNARY_OPERATORS && right())
|
||||||
right()->dump(out, depth + 1);
|
right()->dump(out, depth + 1);
|
||||||
} else {
|
}
|
||||||
|
else if (kind > UNARY_OPERATORS) {
|
||||||
assert(! right());
|
assert(! right());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -459,7 +458,7 @@ void expr_t::op_t::read(const char *& data)
|
||||||
set_left(new expr_t::op_t());
|
set_left(new expr_t::op_t());
|
||||||
left()->read(data);
|
left()->read(data);
|
||||||
|
|
||||||
if (binary::read_bool(data)) {
|
if (kind > UNARY_OPERATORS && binary::read_bool(data)) {
|
||||||
set_right(new expr_t::op_t());
|
set_right(new expr_t::op_t());
|
||||||
right()->read(data);
|
right()->read(data);
|
||||||
}
|
}
|
||||||
|
|
@ -503,11 +502,14 @@ void expr_t::op_t::write(std::ostream& out) const
|
||||||
|
|
||||||
if (kind > TERMINALS) {
|
if (kind > TERMINALS) {
|
||||||
left()->write(out);
|
left()->write(out);
|
||||||
if (right()) {
|
|
||||||
binary::write_bool(out, true);
|
if (kind > UNARY_OPERATORS) {
|
||||||
right()->write(out);
|
if (right()) {
|
||||||
} else {
|
binary::write_bool(out, true);
|
||||||
binary::write_bool(out, false);
|
right()->write(out);
|
||||||
|
} else {
|
||||||
|
binary::write_bool(out, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue