mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Switch Clause to Ptr (#800)
This is consistent with other lists, doesn't seem to benefit from being a Ptr.
This commit is contained in:
@@ -23,7 +23,7 @@ void Statement::PrintDepth(int depth, llvm::raw_ostream& out) const {
|
||||
out << "match (" << *match.Exp() << ") {";
|
||||
if (depth < 0 || depth > 1) {
|
||||
out << "\n";
|
||||
for (auto& clause : *match.Clauses()) {
|
||||
for (auto& clause : match.Clauses()) {
|
||||
out << "case " << *clause.first << " =>\n";
|
||||
clause.second->PrintDepth(depth - 1, out);
|
||||
out << "\n";
|
||||
|
||||
@@ -226,8 +226,8 @@ class Continue : public Statement {
|
||||
class Match : public Statement {
|
||||
public:
|
||||
Match(SourceLocation loc, Ptr<const Expression> exp,
|
||||
std::list<std::pair<Ptr<const Pattern>, Ptr<const Statement>>>* clauses)
|
||||
: Statement(Kind::Match, loc), exp(exp), clauses(clauses) {}
|
||||
std::list<std::pair<Ptr<const Pattern>, Ptr<const Statement>>> clauses)
|
||||
: Statement(Kind::Match, loc), exp(exp), clauses(std::move(clauses)) {}
|
||||
|
||||
static auto classof(const Statement* stmt) -> bool {
|
||||
return stmt->Tag() == Kind::Match;
|
||||
@@ -235,13 +235,13 @@ class Match : public Statement {
|
||||
|
||||
auto Exp() const -> Ptr<const Expression> { return exp; }
|
||||
auto Clauses() const
|
||||
-> const std::list<std::pair<Ptr<const Pattern>, Ptr<const Statement>>>* {
|
||||
-> const std::list<std::pair<Ptr<const Pattern>, Ptr<const Statement>>>& {
|
||||
return clauses;
|
||||
}
|
||||
|
||||
private:
|
||||
Ptr<const Expression> exp;
|
||||
std::list<std::pair<Ptr<const Pattern>, Ptr<const Statement>>>* clauses;
|
||||
std::list<std::pair<Ptr<const Pattern>, Ptr<const Statement>>> clauses;
|
||||
};
|
||||
|
||||
// A continuation statement.
|
||||
|
||||
Reference in New Issue
Block a user