aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2022-02-02 14:25:50 +0000
committerPhilip Herron <philip.herron@embecosm.com>2022-02-02 15:50:13 +0000
commitd2a0fa7fc5fd3332e9f180339a262f29641f62c6 (patch)
tree0a911f2033756f2ef2a29c840d0ea61413b20ffb /gcc/rust/backend
parentf7f14de056eb3887e70f29b0f29da4025f746559 (diff)
downloadgcc-d2a0fa7fc5fd3332e9f180339a262f29641f62c6.zip
gcc-d2a0fa7fc5fd3332e9f180339a262f29641f62c6.tar.gz
gcc-d2a0fa7fc5fd3332e9f180339a262f29641f62c6.tar.bz2
Add new RustIdent struct to track canonical-path and location info
This refactors our TyTy type abstractions to contain their repspective canonical-path and location info. This cleans up alot of location tracking for example when we have generic structures we create implicit hirids which may or may not have location info this now tracks the location info of the declaration of the type avoiding any confustion.
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r--gcc/rust/backend/rust-compile-type.cc35
1 files changed, 17 insertions, 18 deletions
diff --git a/gcc/rust/backend/rust-compile-type.cc b/gcc/rust/backend/rust-compile-type.cc
index f4bc2e4..11784c9 100644
--- a/gcc/rust/backend/rust-compile-type.cc
+++ b/gcc/rust/backend/rust-compile-type.cc
@@ -132,13 +132,14 @@ TyTyResolveCompile::visit (const TyTy::FnType &type)
}
if (!type.is_varadic ())
- translated = ctx->get_backend ()->function_type (
- receiver, parameters, results, NULL,
- ctx->get_mappings ()->lookup_location (type.get_ref ()));
+ translated
+ = ctx->get_backend ()->function_type (receiver, parameters, results, NULL,
+ type.get_ident ().locus);
else
- translated = ctx->get_backend ()->function_type_varadic (
- receiver, parameters, results, NULL,
- ctx->get_mappings ()->lookup_location (type.get_ref ()));
+ translated
+ = ctx->get_backend ()->function_type_varadic (receiver, parameters,
+ results, NULL,
+ type.get_ident ().locus);
}
void
@@ -153,9 +154,8 @@ TyTyResolveCompile::visit (const TyTy::FnPtr &type)
return true;
});
- translated = ctx->get_backend ()->function_ptr_type (
- result_type, parameters,
- ctx->get_mappings ()->lookup_location (type.get_ref ()));
+ translated = ctx->get_backend ()->function_ptr_type (result_type, parameters,
+ type.get_ident ().locus);
}
void
@@ -248,8 +248,8 @@ TyTyResolveCompile::visit (const TyTy::ADTType &type)
tree variant_record = ctx->get_backend ()->struct_type (fields);
tree named_variant_record = ctx->get_backend ()->named_type (
- variant->get_identifier (), variant_record,
- ctx->get_mappings ()->lookup_location (variant->get_id ()));
+ variant->get_ident ().path.get (), variant_record,
+ variant->get_ident ().locus);
// set the qualifier to be a builtin
DECL_ARTIFICIAL (TYPE_FIELDS (variant_record)) = 1;
@@ -278,10 +278,11 @@ TyTyResolveCompile::visit (const TyTy::ADTType &type)
type_record = ctx->get_backend ()->union_type (enum_fields);
}
+ std::string named_struct_str
+ = type.get_ident ().path.get () + type.subst_as_string ();
tree named_struct
- = ctx->get_backend ()->named_type (type.get_name (), type_record,
- ctx->get_mappings ()->lookup_location (
- type.get_ref ()));
+ = ctx->get_backend ()->named_type (named_struct_str, type_record,
+ type.get_ident ().locus);
ctx->push_type (named_struct);
translated = named_struct;
@@ -324,8 +325,7 @@ TyTyResolveCompile::visit (const TyTy::TupleType &type)
tree struct_type_record = ctx->get_backend ()->struct_type (fields);
tree named_struct
= ctx->get_backend ()->named_type (type.as_string (), struct_type_record,
- ctx->get_mappings ()->lookup_location (
- type.get_ty_ref ()));
+ type.get_ident ().locus);
ctx->push_type (named_struct);
ctx->insert_compiled_type (type.get_ty_ref (), named_struct, &type);
@@ -496,8 +496,7 @@ TyTyResolveCompile::visit (const TyTy::DynamicObjectType &type)
tree type_record = ctx->get_backend ()->struct_type (fields);
tree named_struct
= ctx->get_backend ()->named_type (type.get_name (), type_record,
- ctx->get_mappings ()->lookup_location (
- type.get_ty_ref ()));
+ type.get_ident ().locus);
ctx->push_type (named_struct);
translated = named_struct;