diff options
author | Marc Poulhiès <dkm@kataplop.net> | 2021-03-08 21:13:02 +0100 |
---|---|---|
committer | Philip Herron <herron.philip@googlemail.com> | 2021-03-27 18:03:34 +0000 |
commit | fabb3894d5fe5c2ca87917fd08b2f0813553532d (patch) | |
tree | c31d037df544c9dbd3adaa1f904ce38620037d3b /gcc/rust/backend | |
parent | f9f1f1d7211e555ae7a22b21723ced7610fa5657 (diff) | |
download | gcc-fabb3894d5fe5c2ca87917fd08b2f0813553532d.zip gcc-fabb3894d5fe5c2ca87917fd08b2f0813553532d.tar.gz gcc-fabb3894d5fe5c2ca87917fd08b2f0813553532d.tar.bz2 |
WIP for #252
Removed TyTy::UnitType and TyTy::TypeKind::UNIT.
Replaced by TyTy::TupleType with an empty list of fields.
Added default empty vector for fields in ctor for TyTy::TypeType.
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r-- | gcc/rust/backend/rust-compile-context.h | 11 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-expr.h | 8 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-stmt.h | 2 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-tyty.h | 10 |
4 files changed, 18 insertions, 13 deletions
diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h index 6f45e57..6347464 100644 --- a/gcc/rust/backend/rust-compile-context.h +++ b/gcc/rust/backend/rust-compile-context.h @@ -351,11 +351,6 @@ public: ctx->get_mappings ()->lookup_location (type.get_ref ())); } - void visit (TyTy::UnitType &) override - { - translated = ctx->get_backend ()->void_type (); - } - void visit (TyTy::ADTType &type) override { if (ctx->lookup_compiled_types (type.get_ty_ref (), &translated, &type)) @@ -389,6 +384,12 @@ public: void visit (TyTy::TupleType &type) override { + if (type.num_fields () == 0) + { + translated = ctx->get_backend ()->void_type (); + return; + } + bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &translated); if (ok) return; diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h index f4353cd..d0c752c 100644 --- a/gcc/rust/backend/rust-compile-expr.h +++ b/gcc/rust/backend/rust-compile-expr.h @@ -368,7 +368,7 @@ public: } Bvariable *tmp = NULL; - bool needs_temp = if_type->get_kind () != TyTy::TypeKind::UNIT; + bool needs_temp = !if_type->is_unit (); if (needs_temp) { fncontext fnctx = ctx->peek_fn (); @@ -405,7 +405,7 @@ public: } Bvariable *tmp = NULL; - bool needs_temp = if_type->get_kind () != TyTy::TypeKind::UNIT; + bool needs_temp = !if_type->is_unit (); if (needs_temp) { fncontext fnctx = ctx->peek_fn (); @@ -441,7 +441,7 @@ public: } Bvariable *tmp = NULL; - bool needs_temp = block_tyty->get_kind () != TyTy::TypeKind::UNIT; + bool needs_temp = !block_tyty->is_unit (); if (needs_temp) { fncontext fnctx = ctx->peek_fn (); @@ -541,7 +541,7 @@ public: fncontext fnctx = ctx->peek_fn (); Bvariable *tmp = NULL; - bool needs_temp = block_tyty->get_kind () != TyTy::TypeKind::UNIT; + bool needs_temp = !block_tyty->is_unit (); if (needs_temp) { Bblock *enclosing_scope = ctx->peek_enclosing_scope (); diff --git a/gcc/rust/backend/rust-compile-stmt.h b/gcc/rust/backend/rust-compile-stmt.h index 3c2916d..a777df6 100644 --- a/gcc/rust/backend/rust-compile-stmt.h +++ b/gcc/rust/backend/rust-compile-stmt.h @@ -81,7 +81,7 @@ public: return; auto fnctx = ctx->peek_fn (); - if (ty->get_kind () == TyTy::TypeKind::UNIT) + if (ty->is_unit ()) { Bstatement *expr_stmt = ctx->get_backend ()->expression_statement (fnctx.fndecl, init); diff --git a/gcc/rust/backend/rust-compile-tyty.h b/gcc/rust/backend/rust-compile-tyty.h index 774fd2e..44d9416 100644 --- a/gcc/rust/backend/rust-compile-tyty.h +++ b/gcc/rust/backend/rust-compile-tyty.h @@ -50,7 +50,13 @@ public: void visit (TyTy::ADTType &) override { gcc_unreachable (); } - void visit (TyTy::TupleType &) override { gcc_unreachable (); } + void visit (TyTy::TupleType &type) override + { + if (type.num_fields () == 0) + translated = backend->void_type (); + else + gcc_unreachable (); + } void visit (TyTy::ArrayType &) override { gcc_unreachable (); } @@ -60,8 +66,6 @@ public: void visit (TyTy::FnPtr &type) override { gcc_unreachable (); } - void visit (TyTy::UnitType &) override { translated = backend->void_type (); } - void visit (TyTy::FnType &type) override { Backend::Btyped_identifier receiver; |