aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-context.h
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-01-21 17:04:14 +0000
committerPhilip Herron <herron.philip@googlemail.com>2021-01-26 11:59:39 +0000
commit5294dfe7dce7a58fbaf2131c7589d115008ebf0e (patch)
tree04ea7976bb99c19de924eab28310a913434d5d70 /gcc/rust/backend/rust-compile-context.h
parentbe371b9f49e0c4fd7752cad6708fed8b1f2719a3 (diff)
downloadgcc-5294dfe7dce7a58fbaf2131c7589d115008ebf0e.zip
gcc-5294dfe7dce7a58fbaf2131c7589d115008ebf0e.tar.gz
gcc-5294dfe7dce7a58fbaf2131c7589d115008ebf0e.tar.bz2
Remove TyTy::ParamType this was wrongly used to represent FunctionParams
TyTy::ParamType is meant to be used to represent Generic Types which is not handled yet as part of this current milestone.
Diffstat (limited to 'gcc/rust/backend/rust-compile-context.h')
-rw-r--r--gcc/rust/backend/rust-compile-context.h56
1 files changed, 5 insertions, 51 deletions
diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h
index 6516c71..df29e36 100644
--- a/gcc/rust/backend/rust-compile-context.h
+++ b/gcc/rust/backend/rust-compile-context.h
@@ -26,6 +26,7 @@
#include "rust-backend.h"
#include "rust-compile-tyty.h"
#include "rust-ast-full.h"
+#include "rust-hir-full.h"
namespace Rust {
namespace Compile {
@@ -227,8 +228,6 @@ public:
void visit (TyTy::StructFieldType &type) override { gcc_unreachable (); }
- void visit (TyTy::ParamType &type) override { gcc_unreachable (); }
-
void visit (TyTy::FnType &type) override
{
Backend::Btyped_identifier receiver;
@@ -244,14 +243,14 @@ public:
ctx->get_mappings ()->lookup_location (hir_type->get_ref ())));
}
- for (size_t i = 0; i < type.num_params (); i++)
+ for (auto &param_pair : type.get_params ())
{
- auto param_tyty = type.param_at (i);
+ auto param_tyty = param_pair.second;
auto compiled_param_type
- = TyTyResolveCompile::compile (ctx, param_tyty->get_base_type ());
+ = TyTyResolveCompile::compile (ctx, param_tyty);
auto compiled_param = Backend::Btyped_identifier (
- param_tyty->get_identifier (), compiled_param_type,
+ param_pair.first->as_string (), compiled_param_type,
ctx->get_mappings ()->lookup_location (param_tyty->get_ref ()));
parameters.push_back (compiled_param);
@@ -351,51 +350,6 @@ private:
::Btype *translated;
};
-class TyTyCompileParam : public TyTy::TyVisitor
-{
-public:
- static ::Bvariable *compile (Context *ctx, Bfunction *fndecl,
- TyTy::TyBase *ty)
- {
- TyTyCompileParam compiler (ctx, fndecl);
- ty->accept_vis (compiler);
- rust_assert (compiler.translated != nullptr);
- return compiler.translated;
- }
-
- ~TyTyCompileParam () {}
-
- void visit (TyTy::UnitType &type) override { gcc_unreachable (); }
- void visit (TyTy::InferType &type) override { gcc_unreachable (); }
- void visit (TyTy::StructFieldType &type) override { gcc_unreachable (); }
- void visit (TyTy::ADTType &type) override { gcc_unreachable (); }
- void visit (TyTy::FnType &type) override { gcc_unreachable (); }
- void visit (TyTy::ArrayType &type) override { gcc_unreachable (); }
- void visit (TyTy::BoolType &type) override { gcc_unreachable (); }
- void visit (TyTy::IntType &type) override { gcc_unreachable (); }
- void visit (TyTy::UintType &type) override { gcc_unreachable (); }
- void visit (TyTy::FloatType &type) override { gcc_unreachable (); }
- void visit (TyTy::ErrorType &type) override { gcc_unreachable (); }
-
- void visit (TyTy::ParamType &type) override
- {
- auto btype = TyTyResolveCompile::compile (ctx, type.get_base_type ());
- bool tree_addressable = false;
- translated = ctx->get_backend ()->parameter_variable (
- fndecl, type.get_identifier (), btype, tree_addressable,
- ctx->get_mappings ()->lookup_location (type.get_ref ()));
- }
-
-private:
- TyTyCompileParam (Context *ctx, ::Bfunction *fndecl)
- : ctx (ctx), fndecl (fndecl), translated (nullptr)
- {}
-
- Context *ctx;
- ::Bfunction *fndecl;
- ::Bvariable *translated;
-};
-
} // namespace Compile
} // namespace Rust