mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Update IfExpression to follow AST conventions (#1167)
This commit is contained in:
@@ -161,9 +161,8 @@ void Expression::Print(llvm::raw_ostream& out) const {
|
||||
break;
|
||||
case ExpressionKind::IfExpression: {
|
||||
const auto& if_expr = cast<IfExpression>(*this);
|
||||
out << "if " << *if_expr.condition() << " then "
|
||||
<< *if_expr.then_expression() << " else "
|
||||
<< *if_expr.else_expression();
|
||||
out << "if " << if_expr.condition() << " then "
|
||||
<< if_expr.then_expression() << " else " << if_expr.else_expression();
|
||||
break;
|
||||
}
|
||||
case ExpressionKind::UnimplementedExpression: {
|
||||
|
||||
@@ -519,13 +519,18 @@ class IfExpression : public Expression {
|
||||
return InheritsFromIfExpression(node->kind());
|
||||
}
|
||||
|
||||
auto condition() const -> Nonnull<Expression*> { return condition_; }
|
||||
auto then_expression() const -> Nonnull<Expression*> {
|
||||
return then_expression_;
|
||||
auto condition() const -> const Expression& { return *condition_; }
|
||||
auto condition() -> Expression& { return *condition_; }
|
||||
|
||||
auto then_expression() const -> const Expression& {
|
||||
return *then_expression_;
|
||||
}
|
||||
auto else_expression() const -> Nonnull<Expression*> {
|
||||
return else_expression_;
|
||||
auto then_expression() -> Expression& { return *then_expression_; }
|
||||
|
||||
auto else_expression() const -> const Expression& {
|
||||
return *else_expression_;
|
||||
}
|
||||
auto else_expression() -> Expression& { return *else_expression_; }
|
||||
|
||||
private:
|
||||
Nonnull<Expression*> condition_;
|
||||
|
||||
Reference in New Issue
Block a user