Support write_to_stream for arithmetic expressions.
This commit is contained in:
parent
2063c5ee9d
commit
cc508d1626
|
|
@ -162,6 +162,11 @@ class ExpBinary : public Expression {
|
||||||
bool eval_operand1(ScopeBase*scope, int64_t&val) const;
|
bool eval_operand1(ScopeBase*scope, int64_t&val) const;
|
||||||
bool eval_operand2(ScopeBase*scope, int64_t&val) const;
|
bool eval_operand2(ScopeBase*scope, int64_t&val) const;
|
||||||
|
|
||||||
|
inline void write_to_stream_operand1(std::ostream&out)
|
||||||
|
{ operand1_->write_to_stream(out); }
|
||||||
|
inline void write_to_stream_operand2(std::ostream&out)
|
||||||
|
{ operand2_->write_to_stream(out); }
|
||||||
|
|
||||||
void dump_operands(ostream&out, int indent = 0) const;
|
void dump_operands(ostream&out, int indent = 0) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,42 @@ void ExpAggregate::write_to_stream(ostream&)
|
||||||
ivl_assert(*this, !"Not supported");
|
ivl_assert(*this, !"Not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpArithmetic::write_to_stream(ostream&)
|
void ExpArithmetic::write_to_stream(ostream&out)
|
||||||
{
|
{
|
||||||
ivl_assert(*this, !"Not supported");
|
out << "(";
|
||||||
|
write_to_stream_operand1(out);
|
||||||
|
out << ")";
|
||||||
|
|
||||||
|
switch (fun_) {
|
||||||
|
case PLUS:
|
||||||
|
out << "+";
|
||||||
|
break;
|
||||||
|
case MINUS:
|
||||||
|
out << "-";
|
||||||
|
break;
|
||||||
|
case MULT:
|
||||||
|
out << "*";
|
||||||
|
break;
|
||||||
|
case DIV:
|
||||||
|
out << "/";
|
||||||
|
break;
|
||||||
|
case MOD:
|
||||||
|
out << "mod";
|
||||||
|
break;
|
||||||
|
case REM:
|
||||||
|
out << "rem";
|
||||||
|
break;
|
||||||
|
case POW:
|
||||||
|
out << "**";
|
||||||
|
break;
|
||||||
|
case CONCAT:
|
||||||
|
out << "&";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
out << "(";
|
||||||
|
write_to_stream_operand2(out);
|
||||||
|
out << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpAttribute::write_to_stream(ostream&)
|
void ExpAttribute::write_to_stream(ostream&)
|
||||||
|
|
@ -92,7 +125,7 @@ void ExpRelation::write_to_stream(ostream&)
|
||||||
ivl_assert(*this, !"Not supported");
|
ivl_assert(*this, !"Not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpString::write_to_stream(ostream&fd)
|
void ExpString::write_to_stream(ostream&)
|
||||||
{
|
{
|
||||||
ivl_assert(*this, !"Not supported");
|
ivl_assert(*this, !"Not supported");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue