Skip to content

Commit

Permalink
hir: Rename ComoundAssignment getters
Browse files Browse the repository at this point in the history
Use more a consistent name.

gcc/rust/ChangeLog:

	* backend/rust-compile-expr.cc (CompileExpr::visit): Rename method.
	* checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Rename method.
	* checks/errors/rust-const-checker.cc (ConstChecker::visit): Rename method.
	* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Rename method.
	* hir/rust-hir-dump.cc (Dump::visit): Rename method.
	* hir/tree/rust-hir-expr.h: Rename method.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Rename method.
	* typecheck/rust-tyty.h: Rename method.
  • Loading branch information
jdupak authored and CohenArthur committed Oct 23, 2023
1 parent ba10e40 commit 2e3e600
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions gcc/rust/backend/rust-compile-expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ void
CompileExpr::visit (HIR::CompoundAssignmentExpr &expr)
{
auto op = expr.get_expr_type ();
auto lhs = CompileExpr::Compile (expr.get_left_expr ().get (), ctx);
auto rhs = CompileExpr::Compile (expr.get_right_expr ().get (), ctx);
auto lhs = CompileExpr::Compile (expr.get_lhs ().get (), ctx);
auto rhs = CompileExpr::Compile (expr.get_rhs ().get (), ctx);

// this might be an operator overload situation lets check
TyTy::FnType *fntype;
Expand All @@ -198,8 +198,8 @@ CompileExpr::visit (HIR::CompoundAssignmentExpr &expr)
expr.get_expr_type ());
auto compound_assignment
= resolve_operator_overload (lang_item_type, expr, lhs, rhs,
expr.get_left_expr ().get (),
expr.get_right_expr ().get ());
expr.get_lhs ().get (),
expr.get_rhs ().get ());
ctx->add_statement (compound_assignment);

return;
Expand Down
4 changes: 2 additions & 2 deletions gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ PrivacyReporter::visit (HIR::AssignmentExpr &expr)
void
PrivacyReporter::visit (HIR::CompoundAssignmentExpr &expr)
{
expr.get_left_expr ()->accept_vis (*this);
expr.get_right_expr ()->accept_vis (*this);
expr.get_lhs ()->accept_vis (*this);
expr.get_rhs ()->accept_vis (*this);
}

void
Expand Down
4 changes: 2 additions & 2 deletions gcc/rust/checks/errors/rust-const-checker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ ConstChecker::visit (AssignmentExpr &expr)
void
ConstChecker::visit (CompoundAssignmentExpr &expr)
{
expr.get_left_expr ()->accept_vis (*this);
expr.get_right_expr ()->accept_vis (*this);
expr.get_lhs ()->accept_vis (*this);
expr.get_rhs ()->accept_vis (*this);
}

void
Expand Down
4 changes: 2 additions & 2 deletions gcc/rust/checks/errors/rust-unsafe-checker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ UnsafeChecker::visit (AssignmentExpr &expr)
void
UnsafeChecker::visit (CompoundAssignmentExpr &expr)
{
expr.get_left_expr ()->accept_vis (*this);
expr.get_right_expr ()->accept_vis (*this);
expr.get_lhs ()->accept_vis (*this);
expr.get_rhs ()->accept_vis (*this);
}

void
Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/hir/rust-hir-dump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ Dump::visit (CompoundAssignmentExpr &e)
begin ("CompoundAssignmentExpr");

do_operatorexpr (e);
visit_field ("right_expr", *e.get_right_expr ());
visit_field ("right_expr", *e.get_rhs ());

std::string str;

Expand Down
4 changes: 2 additions & 2 deletions gcc/rust/hir/tree/rust-hir-expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -762,9 +762,9 @@ class CompoundAssignmentExpr : public OperatorExpr
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;

std::unique_ptr<Expr> &get_left_expr () { return main_or_left_expr; }
std::unique_ptr<Expr> &get_lhs () { return main_or_left_expr; }

std::unique_ptr<Expr> &get_right_expr () { return right_expr; }
std::unique_ptr<Expr> &get_rhs () { return right_expr; }

void visit_lhs (HIRFullVisitor &vis) { main_or_left_expr->accept_vis (vis); }
void visit_rhs (HIRFullVisitor &vis) { right_expr->accept_vis (vis); }
Expand Down
10 changes: 4 additions & 6 deletions gcc/rust/typecheck/rust-hir-type-check-expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -249,16 +249,14 @@ TypeCheckExpr::visit (HIR::CompoundAssignmentExpr &expr)
{
infered = TyTy::TupleType::get_unit_type (expr.get_mappings ().get_hirid ());

auto lhs = TypeCheckExpr::Resolve (expr.get_left_expr ().get ());
auto rhs = TypeCheckExpr::Resolve (expr.get_right_expr ().get ());
auto lhs = TypeCheckExpr::Resolve (expr.get_lhs ().get ());
auto rhs = TypeCheckExpr::Resolve (expr.get_rhs ().get ());

// we dont care about the result of the unify from a compound assignment
// since this is a unit-type expr
coercion_site (expr.get_mappings ().get_hirid (),
TyTy::TyWithLocation (lhs,
expr.get_left_expr ()->get_locus ()),
TyTy::TyWithLocation (rhs,
expr.get_right_expr ()->get_locus ()),
TyTy::TyWithLocation (lhs, expr.get_lhs ()->get_locus ()),
TyTy::TyWithLocation (rhs, expr.get_rhs ()->get_locus ()),
expr.get_locus ());

auto lang_item_type
Expand Down
2 changes: 2 additions & 0 deletions gcc/rust/typecheck/rust-tyty.h
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,8 @@ class ArrayType : public BaseType

private:
TyVar element_type;
// FIXME: I dont think this should be in tyty - tyty should already be const
// evaluated
HIR::Expr &capacity_expr;
};

Expand Down

0 comments on commit 2e3e600

Please sign in to comment.