diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-10-30 17:22:19 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2021-11-01 15:48:54 +0000 |
commit | e8d57d424b94f6278140784561dfb6e3d4173cf3 (patch) | |
tree | f4ea7f5750e7976701a9959cab0f278e93e439d6 /gcc | |
parent | 56e4a9db1e0804150d391e5b4a5d6a03d7525c8d (diff) | |
download | gcc-e8d57d424b94f6278140784561dfb6e3d4173cf3.zip gcc-e8d57d424b94f6278140784561dfb6e3d4173cf3.tar.gz gcc-e8d57d424b94f6278140784561dfb6e3d4173cf3.tar.bz2 |
Add missing ID to variant ids
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-enumitem.h | 12 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-stmt.h | 21 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-toplevel.h | 21 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-tyty.h | 21 |
4 files changed, 38 insertions, 37 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-enumitem.h b/gcc/rust/typecheck/rust-hir-type-check-enumitem.h index 1ab07b3..e4dcaeb23 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-enumitem.h +++ b/gcc/rust/typecheck/rust-hir-type-check-enumitem.h @@ -49,7 +49,8 @@ public: rust_error_at (item.get_locus (), "discriminant too big"); variant - = new TyTy::VariantDef (item.get_identifier (), last_discriminant + 1); + = new TyTy::VariantDef (item.get_mappings ().get_hirid (), + item.get_identifier (), last_discriminant + 1); } void visit (HIR::EnumItemDiscriminant &item) override @@ -83,7 +84,8 @@ public: rust_assert (ok); variant - = new TyTy::VariantDef (item.get_identifier (), specified_discriminant); + = new TyTy::VariantDef (item.get_mappings ().get_hirid (), + item.get_identifier (), specified_discriminant); } void visit (HIR::EnumItemTuple &item) override @@ -107,7 +109,8 @@ public: } variant - = new TyTy::VariantDef (item.get_identifier (), + = new TyTy::VariantDef (item.get_mappings ().get_hirid (), + item.get_identifier (), TyTy::VariantDef::VariantType::TUPLE, fields); } @@ -130,7 +133,8 @@ public: } variant - = new TyTy::VariantDef (item.get_identifier (), + = new TyTy::VariantDef (item.get_mappings ().get_hirid (), + item.get_identifier (), TyTy::VariantDef::VariantType::STRUCT, fields); } diff --git a/gcc/rust/typecheck/rust-hir-type-check-stmt.h b/gcc/rust/typecheck/rust-hir-type-check-stmt.h index 7f98c46..8df43d9 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-stmt.h +++ b/gcc/rust/typecheck/rust-hir-type-check-stmt.h @@ -172,10 +172,9 @@ public: // there is only a single variant std::vector<TyTy::VariantDef *> variants; - variants.push_back ( - new TyTy::VariantDef (struct_decl.get_identifier (), - TyTy::VariantDef::VariantType::TUPLE, - std::move (fields))); + variants.push_back (new TyTy::VariantDef ( + struct_decl.get_mappings ().get_hirid (), struct_decl.get_identifier (), + TyTy::VariantDef::VariantType::TUPLE, std::move (fields))); TyTy::BaseType *type = new TyTy::ADTType (struct_decl.get_mappings ().get_hirid (), @@ -283,10 +282,9 @@ public: // there is only a single variant std::vector<TyTy::VariantDef *> variants; - variants.push_back ( - new TyTy::VariantDef (struct_decl.get_identifier (), - TyTy::VariantDef::VariantType::STRUCT, - std::move (fields))); + variants.push_back (new TyTy::VariantDef ( + struct_decl.get_mappings ().get_hirid (), struct_decl.get_identifier (), + TyTy::VariantDef::VariantType::STRUCT, std::move (fields))); TyTy::BaseType *type = new TyTy::ADTType (struct_decl.get_mappings ().get_hirid (), @@ -342,10 +340,9 @@ public: // there is only a single variant std::vector<TyTy::VariantDef *> variants; - variants.push_back ( - new TyTy::VariantDef (union_decl.get_identifier (), - TyTy::VariantDef::VariantType::STRUCT, - std::move (fields))); + variants.push_back (new TyTy::VariantDef ( + union_decl.get_mappings ().get_hirid (), union_decl.get_identifier (), + TyTy::VariantDef::VariantType::STRUCT, std::move (fields))); TyTy::BaseType *type = new TyTy::ADTType (union_decl.get_mappings ().get_hirid (), diff --git a/gcc/rust/typecheck/rust-hir-type-check-toplevel.h b/gcc/rust/typecheck/rust-hir-type-check-toplevel.h index 98f037e..7b1dfc9 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-toplevel.h +++ b/gcc/rust/typecheck/rust-hir-type-check-toplevel.h @@ -104,10 +104,9 @@ public: // there is only a single variant std::vector<TyTy::VariantDef *> variants; - variants.push_back ( - new TyTy::VariantDef (struct_decl.get_identifier (), - TyTy::VariantDef::VariantType::TUPLE, - std::move (fields))); + variants.push_back (new TyTy::VariantDef ( + struct_decl.get_mappings ().get_hirid (), struct_decl.get_identifier (), + TyTy::VariantDef::VariantType::TUPLE, std::move (fields))); TyTy::BaseType *type = new TyTy::ADTType (struct_decl.get_mappings ().get_hirid (), @@ -174,10 +173,9 @@ public: // there is only a single variant std::vector<TyTy::VariantDef *> variants; - variants.push_back ( - new TyTy::VariantDef (struct_decl.get_identifier (), - TyTy::VariantDef::VariantType::STRUCT, - std::move (fields))); + variants.push_back (new TyTy::VariantDef ( + struct_decl.get_mappings ().get_hirid (), struct_decl.get_identifier (), + TyTy::VariantDef::VariantType::STRUCT, std::move (fields))); TyTy::BaseType *type = new TyTy::ADTType (struct_decl.get_mappings ().get_hirid (), @@ -288,10 +286,9 @@ public: // there is only a single variant std::vector<TyTy::VariantDef *> variants; - variants.push_back ( - new TyTy::VariantDef (union_decl.get_identifier (), - TyTy::VariantDef::VariantType::STRUCT, - std::move (fields))); + variants.push_back (new TyTy::VariantDef ( + union_decl.get_mappings ().get_hirid (), union_decl.get_identifier (), + TyTy::VariantDef::VariantType::STRUCT, std::move (fields))); TyTy::BaseType *type = new TyTy::ADTType (union_decl.get_mappings ().get_hirid (), diff --git a/gcc/rust/typecheck/rust-tyty.h b/gcc/rust/typecheck/rust-tyty.h index 1afb0ed..473572f 100644 --- a/gcc/rust/typecheck/rust-tyty.h +++ b/gcc/rust/typecheck/rust-tyty.h @@ -1020,31 +1020,33 @@ public: STRUCT }; - VariantDef (std::string identifier, int discriminant) - : identifier (identifier), discriminant (discriminant) + VariantDef (HirId id, std::string identifier, int discriminant) + : id (id), identifier (identifier), discriminant (discriminant) { type = VariantType::NUM; fields = {}; } - VariantDef (std::string identifier, VariantType type, + VariantDef (HirId id, std::string identifier, VariantType type, std::vector<StructFieldType *> fields) - : identifier (identifier), type (type), fields (fields) + : id (id), identifier (identifier), type (type), fields (fields) { discriminant = 0; rust_assert (type == VariantType::TUPLE || type == VariantType::STRUCT); } - VariantDef (std::string identifier, VariantType type, int discriminant, - std::vector<StructFieldType *> fields) - : identifier (identifier), type (type), discriminant (discriminant), - fields (fields) + VariantDef (HirId id, std::string identifier, VariantType type, + int discriminant, std::vector<StructFieldType *> fields) + : id (id), identifier (identifier), type (type), + discriminant (discriminant), fields (fields) { rust_assert ((type == VariantType::NUM && fields.empty ()) || (type == VariantType::TUPLE && discriminant == 0) || (type == VariantType::STRUCT && discriminant == 0)); } + HirId get_id () const { return id; } + VariantType get_variant_type () const { return type; } std::string get_identifier () const { return identifier; } @@ -1132,10 +1134,11 @@ public: for (auto &f : fields) cloned_fields.push_back ((StructFieldType *) f->clone ()); - return new VariantDef (identifier, type, discriminant, cloned_fields); + return new VariantDef (id, identifier, type, discriminant, cloned_fields); } private: + HirId id; std::string identifier; VariantType type; int discriminant; /* Either discriminant or fields are valid. */ |