@@ -155,7 +155,7 @@ Dump::go (bool enable_simplify_cfg)
stream << "}\n";
}
void
-Dump::visit (Statement &stmt)
+Dump::visit (const Statement &stmt)
{
statement_place = stmt.get_place ();
switch (stmt.get_kind ())
@@ -247,7 +247,7 @@ Dump::visit_move_place (PlaceId place_id)
}
void
-Dump::visit (BorrowExpr &expr)
+Dump::visit (const BorrowExpr &expr)
{
stream << "&";
visit_lifetime (statement_place);
@@ -268,7 +268,7 @@ Dump::visit_lifetime (PlaceId place_id)
}
void
-Dump::visit (InitializerExpr &expr)
+Dump::visit (const InitializerExpr &expr)
{
stream << "{";
print_comma_separated (stream, expr.get_values (), [this] (PlaceId place_id) {
@@ -278,7 +278,7 @@ Dump::visit (InitializerExpr &expr)
}
void
-Dump::visit (CallExpr &expr)
+Dump::visit (const CallExpr &expr)
{
stream << "Call(";
if (auto fn_type
@@ -305,7 +305,7 @@ Dump::visit (CallExpr &expr)
}
void
-Dump::visit (Operator<1> &expr)
+Dump::visit (const Operator<1> &expr)
{
stream << "Operator(";
visit_move_place (expr.get_operand<0> ());
@@ -313,7 +313,7 @@ Dump::visit (Operator<1> &expr)
}
void
-Dump::visit (Operator<2> &expr)
+Dump::visit (const Operator<2> &expr)
{
stream << "Operator(";
visit_move_place (expr.get_operand<0> ());
@@ -323,7 +323,7 @@ Dump::visit (Operator<2> &expr)
}
void
-Dump::visit (Assignment &expr)
+Dump::visit (const Assignment &expr)
{
if (func.place_db[expr.get_rhs ()].is_rvalue ())
{
@@ -49,16 +49,16 @@ public:
void go (bool enable_simplify_cfg = false);
protected:
- void visit (Statement &stmt) override;
+ void visit (const Statement &stmt) override;
void visit_place (PlaceId place_id);
void visit_move_place (PlaceId place_id);
- void visit (BorrowExpr &expr) override;
+ void visit (const BorrowExpr &expr) override;
void visit_lifetime (PlaceId place_id);
- void visit (InitializerExpr &expr) override;
- void visit (CallExpr &expr) override;
- void visit (Operator<1> &expr) override;
- void visit (Operator<2> &expr) override;
- void visit (Assignment &expr) override;
+ void visit (const InitializerExpr &expr) override;
+ void visit (const CallExpr &expr) override;
+ void visit (const Operator<1> &expr) override;
+ void visit (const Operator<2> &expr) override;
+ void visit (const Assignment &expr) override;
void visit_scope (ScopeId id, size_t depth = 1);
std::ostream &indent (size_t depth);
@@ -32,13 +32,13 @@ class CallExpr;
class Visitor
{
public:
- virtual void visit (Statement &stmt) = 0;
- virtual void visit (InitializerExpr &expr) = 0;
- virtual void visit (Operator<1> &expr) = 0;
- virtual void visit (Operator<2> &expr) = 0;
- virtual void visit (BorrowExpr &expr) = 0;
- virtual void visit (Assignment &expr) = 0;
- virtual void visit (CallExpr &expr) = 0;
+ virtual void visit (const Statement &stmt) = 0;
+ virtual void visit (const InitializerExpr &expr) = 0;
+ virtual void visit (const Operator<1> &expr) = 0;
+ virtual void visit (const Operator<2> &expr) = 0;
+ virtual void visit (const BorrowExpr &expr) = 0;
+ virtual void visit (const Assignment &expr) = 0;
+ virtual void visit (const CallExpr &expr) = 0;
};
class Visitable
@@ -137,6 +137,10 @@ public:
public:
std::vector<PlaceId> &get_values () { return values; }
+ WARN_UNUSED_RESULT const std::vector<PlaceId> &get_values () const
+ {
+ return values;
+ }
};
template <unsigned ARITY>
@@ -199,7 +203,7 @@ public:
{}
public:
- const std::vector<PlaceId> &get_arguments () { return arguments; }
+ const std::vector<PlaceId> &get_arguments () const { return arguments; }
WARN_UNUSED_RESULT PlaceId get_callable () const { return callable; }
};