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:
Jon Meow
2021-09-01 15:19:58 -07:00
committed by GitHub
parent 9f67c4b9a8
commit 5f8b231322
5 changed files with 24 additions and 33 deletions
+1 -1
View File
@@ -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";
+4 -4
View File
@@ -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.