RustIdent ident{*canonical_path, item.get_locus ()};
variant = new TyTy::VariantDef (item.get_mappings ().get_hirid (),
+ item.get_mappings ().get_defid (),
item.get_identifier (), ident, discim_expr);
}
RustIdent ident{*canonical_path, item.get_locus ()};
variant = new TyTy::VariantDef (item.get_mappings ().get_hirid (),
+ item.get_mappings ().get_defid (),
item.get_identifier (), ident,
item.get_discriminant_expression ().get ());
}
RustIdent ident{*canonical_path, item.get_locus ()};
variant = new TyTy::VariantDef (item.get_mappings ().get_hirid (),
+ item.get_mappings ().get_defid (),
item.get_identifier (), ident,
TyTy::VariantDef::VariantType::TUPLE,
discim_expr, fields);
RustIdent ident{*canonical_path, item.get_locus ()};
variant = new TyTy::VariantDef (item.get_mappings ().get_hirid (),
+ item.get_mappings ().get_defid (),
item.get_identifier (), ident,
TyTy::VariantDef::VariantType::STRUCT,
discrim_expr, fields);
// its a single variant ADT
std::vector<TyTy::VariantDef *> variants;
variants.push_back (new TyTy::VariantDef (
- struct_decl.get_mappings ().get_hirid (), struct_decl.get_identifier (),
+ struct_decl.get_mappings ().get_hirid (),
+ struct_decl.get_mappings ().get_defid (), struct_decl.get_identifier (),
ident, TyTy::VariantDef::VariantType::TUPLE, nullptr, std::move (fields)));
// Process #[repr(X)] attribute, if any
// its a single variant ADT
std::vector<TyTy::VariantDef *> variants;
variants.push_back (new TyTy::VariantDef (
- struct_decl.get_mappings ().get_hirid (), struct_decl.get_identifier (),
+ struct_decl.get_mappings ().get_hirid (),
+ struct_decl.get_mappings ().get_defid (), struct_decl.get_identifier (),
ident, TyTy::VariantDef::VariantType::STRUCT, nullptr, std::move (fields)));
// Process #[repr(X)] attribute, if any
// there is only a single variant
std::vector<TyTy::VariantDef *> variants;
variants.push_back (new TyTy::VariantDef (
- union_decl.get_mappings ().get_hirid (), union_decl.get_identifier (),
+ union_decl.get_mappings ().get_hirid (),
+ union_decl.get_mappings ().get_defid (), union_decl.get_identifier (),
ident, TyTy::VariantDef::VariantType::STRUCT, nullptr, std::move (fields)));
TyTy::BaseType *type
return "";
}
- VariantDef (HirId id, std::string identifier, RustIdent ident,
+ VariantDef (HirId id, DefId defid, std::string identifier, RustIdent ident,
HIR::Expr *discriminant)
- : id (id), identifier (identifier), ident (ident),
+ : id (id), defid (defid), identifier (identifier), ident (ident),
discriminant (discriminant)
{
fields = {};
}
- VariantDef (HirId id, std::string identifier, RustIdent ident,
+ VariantDef (HirId id, DefId defid, std::string identifier, RustIdent ident,
VariantType type, HIR::Expr *discriminant,
std::vector<StructFieldType *> fields)
- : id (id), identifier (identifier), ident (ident), type (type),
- discriminant (discriminant), fields (fields)
+ : id (id), defid (defid), identifier (identifier), ident (ident),
+ type (type), discriminant (discriminant), fields (fields)
{
rust_assert (
(type == VariantType::NUM && fields.empty ())
}
VariantDef (const VariantDef &other)
- : id (other.id), identifier (other.identifier), ident (other.ident),
- type (other.type), discriminant (other.discriminant),
+ : id (other.id), defid (other.defid), identifier (other.identifier),
+ ident (other.ident), type (other.type), discriminant (other.discriminant),
fields (other.fields)
{}
static VariantDef &get_error_node ()
{
static VariantDef node
- = VariantDef (UNKNOWN_HIRID, "",
+ = VariantDef (UNKNOWN_HIRID, UNKNOWN_DEFID, "",
{Resolver::CanonicalPath::create_empty (),
Linemap::unknown_location ()},
nullptr);
bool is_error () const { return get_id () == UNKNOWN_HIRID; }
HirId get_id () const { return id; }
+ DefId get_defid () const { return defid; }
VariantType get_variant_type () const { return type; }
bool is_data_variant () const { return type != VariantType::NUM; }
for (auto &f : fields)
cloned_fields.push_back ((StructFieldType *) f->clone ());
- return new VariantDef (id, identifier, ident, type, discriminant,
+ return new VariantDef (id, defid, identifier, ident, type, discriminant,
cloned_fields);
}
for (auto &f : fields)
cloned_fields.push_back ((StructFieldType *) f->monomorphized_clone ());
- return new VariantDef (id, identifier, ident, type, discriminant,
+ return new VariantDef (id, defid, identifier, ident, type, discriminant,
cloned_fields);
}
private:
HirId id;
+ DefId defid;
std::string identifier;
RustIdent ident;
VariantType type;