mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 06:34:41 +01:00
Refactor Action accessors (#891)
This commit is contained in:
@@ -75,62 +75,62 @@ class Action {
|
||||
|
||||
class LValAction : public Action {
|
||||
public:
|
||||
explicit LValAction(Nonnull<const Expression*> exp)
|
||||
: Action(Kind::LValAction), exp(exp) {}
|
||||
explicit LValAction(Nonnull<const Expression*> expression)
|
||||
: Action(Kind::LValAction), expression_(expression) {}
|
||||
|
||||
static auto classof(const Action* action) -> bool {
|
||||
return action->kind() == Kind::LValAction;
|
||||
}
|
||||
|
||||
auto Exp() const -> Nonnull<const Expression*> { return exp; }
|
||||
auto expression() const -> const Expression& { return *expression_; }
|
||||
|
||||
private:
|
||||
Nonnull<const Expression*> exp;
|
||||
Nonnull<const Expression*> expression_;
|
||||
};
|
||||
|
||||
class ExpressionAction : public Action {
|
||||
public:
|
||||
explicit ExpressionAction(Nonnull<const Expression*> exp)
|
||||
: Action(Kind::ExpressionAction), exp(exp) {}
|
||||
explicit ExpressionAction(Nonnull<const Expression*> expression)
|
||||
: Action(Kind::ExpressionAction), expression_(expression) {}
|
||||
|
||||
static auto classof(const Action* action) -> bool {
|
||||
return action->kind() == Kind::ExpressionAction;
|
||||
}
|
||||
|
||||
auto Exp() const -> Nonnull<const Expression*> { return exp; }
|
||||
auto expression() const -> const Expression& { return *expression_; }
|
||||
|
||||
private:
|
||||
Nonnull<const Expression*> exp;
|
||||
Nonnull<const Expression*> expression_;
|
||||
};
|
||||
|
||||
class PatternAction : public Action {
|
||||
public:
|
||||
explicit PatternAction(Nonnull<const Pattern*> pat)
|
||||
: Action(Kind::PatternAction), pat(pat) {}
|
||||
explicit PatternAction(Nonnull<const Pattern*> pattern)
|
||||
: Action(Kind::PatternAction), pattern_(pattern) {}
|
||||
|
||||
static auto classof(const Action* action) -> bool {
|
||||
return action->kind() == Kind::PatternAction;
|
||||
}
|
||||
|
||||
auto Pat() const -> Nonnull<const Pattern*> { return pat; }
|
||||
auto pattern() const -> const Pattern& { return *pattern_; }
|
||||
|
||||
private:
|
||||
Nonnull<const Pattern*> pat;
|
||||
Nonnull<const Pattern*> pattern_;
|
||||
};
|
||||
|
||||
class StatementAction : public Action {
|
||||
public:
|
||||
explicit StatementAction(Nonnull<const Statement*> stmt)
|
||||
: Action(Kind::StatementAction), stmt(stmt) {}
|
||||
explicit StatementAction(Nonnull<const Statement*> statement)
|
||||
: Action(Kind::StatementAction), statement_(statement) {}
|
||||
|
||||
static auto classof(const Action* action) -> bool {
|
||||
return action->kind() == Kind::StatementAction;
|
||||
}
|
||||
|
||||
auto Stmt() const -> Nonnull<const Statement*> { return stmt; }
|
||||
auto statement() const -> const Statement& { return *statement_; }
|
||||
|
||||
private:
|
||||
Nonnull<const Statement*> stmt;
|
||||
Nonnull<const Statement*> statement_;
|
||||
};
|
||||
|
||||
} // namespace Carbon
|
||||
|
||||
Reference in New Issue
Block a user