aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-expr.h
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-02-25 11:14:37 +0000
committerGitHub <noreply@github.com>2022-02-25 11:14:37 +0000
commitd3a4cf93b73fb32ab8d18541cc4fa5ff7b74c8e8 (patch)
tree188edbabfaa677bf7971b44a2450f83f4ba0cfba /gcc/rust/backend/rust-compile-expr.h
parentbf92a1012264f2544e73a7a8dd0ac1e473c7f658 (diff)
parent22c6bca60a9bc80c043e4da9a94cb80023dde04c (diff)
downloadgcc-d3a4cf93b73fb32ab8d18541cc4fa5ff7b74c8e8.zip
gcc-d3a4cf93b73fb32ab8d18541cc4fa5ff7b74c8e8.tar.gz
gcc-d3a4cf93b73fb32ab8d18541cc4fa5ff7b74c8e8.tar.bz2
Merge #974
974: Add support for ranges and index lang items along with the TyTy::SliceType r=philberty a=philberty This PR contains more code to begin supporting Slices which requires support for more intrinsic, range and index lang items. More work is needed to support slices such as the const_ptr lang item and the offset intrinsic but this is a big PR already and adds support for more lang items along the way. Fixes #975 Addresses #849 Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile-expr.h')
-rw-r--r--gcc/rust/backend/rust-compile-expr.h43
1 files changed, 12 insertions, 31 deletions
diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h
index 2fee3be..f2b4df8 100644
--- a/gcc/rust/backend/rust-compile-expr.h
+++ b/gcc/rust/backend/rust-compile-expr.h
@@ -201,36 +201,7 @@ public:
void visit (HIR::CompoundAssignmentExpr &expr) override;
- void visit (HIR::ArrayIndexExpr &expr) override
- {
- tree array_reference = CompileExpr::Compile (expr.get_array_expr (), ctx);
- tree index = CompileExpr::Compile (expr.get_index_expr (), ctx);
-
- // lets check if the array is a reference type then we can add an
- // indirection if required
- TyTy::BaseType *array_expr_ty = nullptr;
- bool ok = ctx->get_tyctx ()->lookup_type (
- expr.get_array_expr ()->get_mappings ().get_hirid (), &array_expr_ty);
- rust_assert (ok);
-
- // do we need to add an indirect reference
- if (array_expr_ty->get_kind () == TyTy::TypeKind::REF)
- {
- TyTy::ReferenceType *r
- = static_cast<TyTy::ReferenceType *> (array_expr_ty);
- TyTy::BaseType *tuple_type = r->get_base ();
- tree array_tyty = TyTyResolveCompile::compile (ctx, tuple_type);
-
- array_reference
- = ctx->get_backend ()->indirect_expression (array_tyty,
- array_reference, true,
- expr.get_locus ());
- }
-
- translated
- = ctx->get_backend ()->array_index_expression (array_reference, index,
- expr.get_locus ());
- }
+ void visit (HIR::ArrayIndexExpr &expr) override;
void visit (HIR::ArrayExpr &expr) override;
@@ -803,6 +774,16 @@ public:
void visit (HIR::MatchExpr &expr) override;
+ void visit (HIR::RangeFromToExpr &expr) override;
+
+ void visit (HIR::RangeFromExpr &expr) override;
+
+ void visit (HIR::RangeToExpr &expr) override;
+
+ void visit (HIR::RangeFullExpr &expr) override;
+
+ void visit (HIR::RangeFromToInclExpr &expr) override;
+
protected:
tree compile_dyn_dispatch_call (const TyTy::DynamicObjectType *dyn,
TyTy::BaseType *receiver,
@@ -818,7 +799,7 @@ protected:
tree
resolve_operator_overload (Analysis::RustLangItem::ItemType lang_item_type,
- HIR::OperatorExpr &expr, tree lhs, tree rhs,
+ HIR::OperatorExprMeta expr, tree lhs, tree rhs,
HIR::Expr *lhs_expr, HIR::Expr *rhs_expr);
tree compile_bool_literal (const HIR::LiteralExpr &expr,