diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-07-20 13:47:56 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2021-07-20 18:46:04 +0100 |
commit | aa4feb8867da90a03d1d04dcfa61a049a2779df5 (patch) | |
tree | b108c383397dc0bf36153c6eabdebe62d42a20e6 /gcc/rust/backend/rust-compile-context.h | |
parent | 02713d245aaffd45d8daaf8c914b1dda5baa6eb4 (diff) | |
download | gcc-aa4feb8867da90a03d1d04dcfa61a049a2779df5.zip gcc-aa4feb8867da90a03d1d04dcfa61a049a2779df5.tar.gz gcc-aa4feb8867da90a03d1d04dcfa61a049a2779df5.tar.bz2 |
Raw pointer support
This adds the initial support for raw pointers. Pointers rely on coercion
rules to be able to coerce the raw fat pointers from a borrow expression
into a normal raw pointer.
Fixes #124
Diffstat (limited to 'gcc/rust/backend/rust-compile-context.h')
-rw-r--r-- | gcc/rust/backend/rust-compile-context.h | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h index efca267..bb4f0ab 100644 --- a/gcc/rust/backend/rust-compile-context.h +++ b/gcc/rust/backend/rust-compile-context.h @@ -536,10 +536,29 @@ public: { Btype *base_compiled_type = TyTyResolveCompile::compile (ctx, type.get_base ()); - translated = ctx->get_backend ()->reference_type (base_compiled_type); - if (!type.is_mutable ()) + if (type.is_mutable ()) { - translated = ctx->get_backend ()->immutable_type (translated); + translated = ctx->get_backend ()->reference_type (base_compiled_type); + } + else + { + auto base = ctx->get_backend ()->immutable_type (base_compiled_type); + translated = ctx->get_backend ()->reference_type (base); + } + } + + void visit (TyTy::PointerType &type) override + { + Btype *base_compiled_type + = TyTyResolveCompile::compile (ctx, type.get_base ()); + if (type.is_mutable ()) + { + translated = ctx->get_backend ()->pointer_type (base_compiled_type); + } + else + { + auto base = ctx->get_backend ()->immutable_type (base_compiled_type); + translated = ctx->get_backend ()->pointer_type (base); } } |