Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement AliasType #134

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/tpi/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub enum TypeData<'t> {
Enumerate(EnumerateType<'t>),
Array(ArrayType),
Union(UnionType<'t>),
Alias(AliasType<'t>),
Bitfield(BitfieldType),
FieldList(FieldList<'t>),
ArgumentList(ArgumentList),
Expand All @@ -50,7 +51,8 @@ impl<'t> TypeData<'t> {
| Self::Nested(NestedType { ref name, .. })
| Self::Enumeration(EnumerationType { ref name, .. })
| Self::Enumerate(EnumerateType { ref name, .. })
| Self::Union(UnionType { ref name, .. }) => name,
| Self::Union(UnionType { ref name, .. })
| Self::Alias(AliasType { ref name, .. }) => name,
_ => return None,
};

Expand Down Expand Up @@ -336,6 +338,12 @@ pub(crate) fn parse_type_data<'t>(buf: &mut ParseBuffer<'t>) -> Result<TypeData<
Ok(TypeData::Union(union))
}

// https://github.com/Microsoft/microsoft-pdb/blob/082c5290e5aff028ae84e43affa8be717aa7af73/include/cvinfo.h#L1669-L1673
LF_ALIAS | LF_ALIAS_ST => Ok(TypeData::Alias(AliasType {
underlying_type: buf.parse()?,
name: parse_string(leaf, buf)?,
})),

// https://github.com/Microsoft/microsoft-pdb/blob/082c5290e5aff028ae84e43affa8be717aa7af73/include/cvinfo.h#L2164-L2170
LF_BITFIELD => Ok(TypeData::Bitfield(BitfieldType {
underlying_type: buf.parse()?,
Expand Down Expand Up @@ -1023,6 +1031,13 @@ pub struct UnionType<'t> {
pub unique_name: Option<RawString<'t>>,
}

/// The information parsed from a type record with kind `LF_ALIAS` or `LF_ALIAS_ST`.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct AliasType<'t> {
pub underlying_type: TypeIndex,
pub name: RawString<'t>,
}

/// The information parsed from a type record with kind `LF_BITFIELD`.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct BitfieldType {
Expand Down