aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-10-20 16:21:37 +0100
committerPhilip Herron <philip.herron@embecosm.com>2021-10-22 10:13:06 +0100
commita1b0df02414eb323dac53dc07702861a9d4b63b6 (patch)
tree9ab8a073a48489d04d51e1c9ee2c9c2ae0f7fee8 /gcc/rust/backend
parent5f19fb535c95f2afef30f8eb976907d5f0986041 (diff)
downloadgcc-a1b0df02414eb323dac53dc07702861a9d4b63b6.zip
gcc-a1b0df02414eb323dac53dc07702861a9d4b63b6.tar.gz
gcc-a1b0df02414eb323dac53dc07702861a9d4b63b6.tar.bz2
Constify BaseType::get_root since this should not change ownership
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r--gcc/rust/backend/rust-compile-base.h8
-rw-r--r--gcc/rust/backend/rust-compile-implitem.h9
-rw-r--r--gcc/rust/backend/rust-compile.cc19
3 files changed, 19 insertions, 17 deletions
diff --git a/gcc/rust/backend/rust-compile-base.h b/gcc/rust/backend/rust-compile-base.h
index 4a81061..d741598 100644
--- a/gcc/rust/backend/rust-compile-base.h
+++ b/gcc/rust/backend/rust-compile-base.h
@@ -205,14 +205,14 @@ protected:
TyTy::BaseType *expected, Location locus);
Bexpression *coerce_to_dyn_object (Bexpression *compiled_ref,
- TyTy::BaseType *actual,
- TyTy::BaseType *expected,
- TyTy::DynamicObjectType *ty,
+ const TyTy::BaseType *actual,
+ const TyTy::BaseType *expected,
+ const TyTy::DynamicObjectType *ty,
Location locus);
Bexpression *
compute_address_for_trait_item (const Resolver::TraitItemReference *ref,
- TyTy::BaseType *receiver);
+ const TyTy::BaseType *receiver);
};
} // namespace Compile
diff --git a/gcc/rust/backend/rust-compile-implitem.h b/gcc/rust/backend/rust-compile-implitem.h
index 1d3ad02..ace5e4c 100644
--- a/gcc/rust/backend/rust-compile-implitem.h
+++ b/gcc/rust/backend/rust-compile-implitem.h
@@ -34,7 +34,7 @@ class CompileInherentImplItem : public HIRCompileBase
using Rust::Compile::HIRCompileBase::visit;
public:
- static Bexpression *Compile (TyTy::BaseType *self, HIR::ImplItem *item,
+ static Bexpression *Compile (const TyTy::BaseType *self, HIR::ImplItem *item,
Context *ctx, bool compile_fns,
TyTy::BaseType *concrete = nullptr,
bool is_query_mode = false,
@@ -309,14 +309,15 @@ public:
}
private:
- CompileInherentImplItem (TyTy::BaseType *self, Context *ctx, bool compile_fns,
- TyTy::BaseType *concrete, Location ref_locus)
+ CompileInherentImplItem (const TyTy::BaseType *self, Context *ctx,
+ bool compile_fns, TyTy::BaseType *concrete,
+ Location ref_locus)
: HIRCompileBase (ctx), self (self), compile_fns (compile_fns),
concrete (concrete), reference (ctx->get_backend ()->error_expression ()),
ref_locus (ref_locus)
{}
- TyTy::BaseType *self;
+ const TyTy::BaseType *self;
bool compile_fns;
TyTy::BaseType *concrete;
Bexpression *reference;
diff --git a/gcc/rust/backend/rust-compile.cc b/gcc/rust/backend/rust-compile.cc
index 23a035f..56d3e40 100644
--- a/gcc/rust/backend/rust-compile.cc
+++ b/gcc/rust/backend/rust-compile.cc
@@ -234,8 +234,8 @@ CompileExpr::visit (HIR::MethodCallExpr &expr)
if (is_dyn_dispatch)
{
- TyTy::DynamicObjectType *dyn
- = static_cast<TyTy::DynamicObjectType *> (receiver->get_root ());
+ const TyTy::DynamicObjectType *dyn
+ = static_cast<const TyTy::DynamicObjectType *> (receiver->get_root ());
size_t offs = 0;
const Resolver::TraitItemReference *ref = nullptr;
@@ -763,8 +763,8 @@ HIRCompileBase::coercion_site (Bexpression *compiled_ref,
if (root_expected_kind == TyTy::TypeKind::DYNAMIC
&& root_actual_kind != TyTy::TypeKind::DYNAMIC)
{
- TyTy::DynamicObjectType *dyn
- = static_cast<TyTy::DynamicObjectType *> (expected->get_root ());
+ const TyTy::DynamicObjectType *dyn
+ = static_cast<const TyTy::DynamicObjectType *> (expected->get_root ());
return coerce_to_dyn_object (compiled_ref, actual, expected, dyn, locus);
}
@@ -773,9 +773,9 @@ HIRCompileBase::coercion_site (Bexpression *compiled_ref,
Bexpression *
HIRCompileBase::coerce_to_dyn_object (Bexpression *compiled_ref,
- TyTy::BaseType *actual,
- TyTy::BaseType *expected,
- TyTy::DynamicObjectType *ty,
+ const TyTy::BaseType *actual,
+ const TyTy::BaseType *expected,
+ const TyTy::DynamicObjectType *ty,
Location locus)
{
Btype *dynamic_object = TyTyResolveCompile::compile (ctx, ty);
@@ -814,7 +814,7 @@ HIRCompileBase::coerce_to_dyn_object (Bexpression *compiled_ref,
std::vector<Resolver::Adjustment> adjustments;
while (e->get_kind () == TyTy::TypeKind::REF)
{
- auto r = static_cast<TyTy::ReferenceType *> (e);
+ auto r = static_cast<const TyTy::ReferenceType *> (e);
e = r->get_base ();
if (r->is_mutable ())
@@ -845,7 +845,8 @@ HIRCompileBase::coerce_to_dyn_object (Bexpression *compiled_ref,
Bexpression *
HIRCompileBase::compute_address_for_trait_item (
- const Resolver::TraitItemReference *trait_item_ref, TyTy::BaseType *receiver)
+ const Resolver::TraitItemReference *trait_item_ref,
+ const TyTy::BaseType *receiver)
{
TyTy::BaseType *item_type = trait_item_ref->get_tyty ();
rust_assert (item_type->get_kind () == TyTy::TypeKind::FNDEF);