Skip to content

Commit

Permalink
Migrate Pdb to new lazyvar.
Browse files Browse the repository at this point in the history
  • Loading branch information
Washi1337 committed Apr 20, 2023
1 parent 6ac13ad commit 89f934b
Show file tree
Hide file tree
Showing 47 changed files with 381 additions and 370 deletions.
36 changes: 18 additions & 18 deletions src/AsmResolver.Symbols.Pdb/Leaves/ArrayTypeRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ namespace AsmResolver.Symbols.Pdb.Leaves;
/// </summary>
public class ArrayTypeRecord : CodeViewTypeRecord
{
private readonly LazyVariable<CodeViewTypeRecord?> _elementType;
private readonly LazyVariable<CodeViewTypeRecord?> _indexType;
private readonly LazyVariable<Utf8String> _name;
private readonly LazyVariable<ArrayTypeRecord, CodeViewTypeRecord?> _elementType;
private readonly LazyVariable<ArrayTypeRecord, CodeViewTypeRecord?> _indexType;
private readonly LazyVariable<ArrayTypeRecord, Utf8String> _name;

/// <summary>
/// Initializes a new empty array type.
Expand All @@ -16,9 +16,9 @@ public class ArrayTypeRecord : CodeViewTypeRecord
protected ArrayTypeRecord(uint typeIndex)
: base(typeIndex)
{
_elementType = new LazyVariable<CodeViewTypeRecord?>(GetElementType);
_indexType = new LazyVariable<CodeViewTypeRecord?>(GetIndexType);
_name = new LazyVariable<Utf8String>(GetName);
_elementType = new LazyVariable<ArrayTypeRecord, CodeViewTypeRecord?>(x => x.GetElementType());
_indexType = new LazyVariable<ArrayTypeRecord, CodeViewTypeRecord?>(x => x.GetIndexType());
_name = new LazyVariable<ArrayTypeRecord, Utf8String>(x => x.GetName());
}

/// <summary>
Expand All @@ -30,10 +30,10 @@ protected ArrayTypeRecord(uint typeIndex)
public ArrayTypeRecord(CodeViewTypeRecord elementType, CodeViewTypeRecord indexType, ulong length)
: base(0)
{
_elementType = new LazyVariable<CodeViewTypeRecord?>(elementType);
_indexType = new LazyVariable<CodeViewTypeRecord?>(indexType);
_elementType = new LazyVariable<ArrayTypeRecord, CodeViewTypeRecord?>(elementType);
_indexType = new LazyVariable<ArrayTypeRecord, CodeViewTypeRecord?>(indexType);
_name = new LazyVariable<ArrayTypeRecord, Utf8String>(Utf8String.Empty);
Length = length;
_name = new LazyVariable<Utf8String>(Utf8String.Empty);
}

/// <summary>
Expand All @@ -46,10 +46,10 @@ public ArrayTypeRecord(CodeViewTypeRecord elementType, CodeViewTypeRecord indexT
public ArrayTypeRecord(CodeViewTypeRecord elementType, CodeViewTypeRecord indexType, ulong length, Utf8String name)
: base(0)
{
_elementType = new LazyVariable<CodeViewTypeRecord?>(elementType);
_indexType = new LazyVariable<CodeViewTypeRecord?>(indexType);
_elementType = new LazyVariable<ArrayTypeRecord, CodeViewTypeRecord?>(elementType);
_indexType = new LazyVariable<ArrayTypeRecord, CodeViewTypeRecord?>(indexType);
_name = new LazyVariable<ArrayTypeRecord, Utf8String>(name);
Length = length;
_name = new LazyVariable<Utf8String>(Name);
}

/// <inheritdoc />
Expand All @@ -60,17 +60,17 @@ public ArrayTypeRecord(CodeViewTypeRecord elementType, CodeViewTypeRecord indexT
/// </summary>
public CodeViewTypeRecord? ElementType
{
get => _elementType.Value;
set => _elementType.Value = value;
get => _elementType.GetValue(this);
set => _elementType.SetValue(value);
}

/// <summary>
/// Gets or sets the type that is used to index into the array.
/// </summary>
public CodeViewTypeRecord? IndexType
{
get => _indexType.Value;
set => _indexType.Value = value;
get => _indexType.GetValue(this);
set => _indexType.SetValue(value);
}

/// <summary>
Expand All @@ -87,8 +87,8 @@ public ulong Length
/// </summary>
public Utf8String Name
{
get => _name.Value;
set => _name.Value = value;
get => _name.GetValue(this);
set => _name.SetValue(value);
}

/// <summary>
Expand Down
10 changes: 5 additions & 5 deletions src/AsmResolver.Symbols.Pdb/Leaves/BaseClassField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace AsmResolver.Symbols.Pdb.Leaves;
/// </summary>
public class BaseClassField : CodeViewField
{
private readonly LazyVariable<CodeViewTypeRecord?> _type;
private readonly LazyVariable<BaseClassField, CodeViewTypeRecord?> _type;

/// <summary>
/// Initializes an empty base class.
Expand All @@ -14,7 +14,7 @@ public class BaseClassField : CodeViewField
protected BaseClassField(uint typeIndex)
: base(typeIndex)
{
_type = new LazyVariable<CodeViewTypeRecord?>(GetBaseType);
_type = new LazyVariable<BaseClassField, CodeViewTypeRecord?>(x => x.GetBaseType());
}

/// <summary>
Expand All @@ -24,7 +24,7 @@ protected BaseClassField(uint typeIndex)
public BaseClassField(CodeViewTypeRecord type)
: base(0)
{
_type = new LazyVariable<CodeViewTypeRecord?>(type);
_type = new LazyVariable<BaseClassField, CodeViewTypeRecord?>(type);
}

/// <inheritdoc />
Expand All @@ -35,8 +35,8 @@ public BaseClassField(CodeViewTypeRecord type)
/// </summary>
public CodeViewTypeRecord? Type
{
get => _type.Value;
set => _type.Value = value;
get => _type.GetValue(this);
set => _type.SetValue(value);
}

/// <summary>
Expand Down
10 changes: 5 additions & 5 deletions src/AsmResolver.Symbols.Pdb/Leaves/BitFieldTypeRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace AsmResolver.Symbols.Pdb.Leaves;
/// </summary>
public class BitFieldTypeRecord : CodeViewTypeRecord
{
private readonly LazyVariable<CodeViewTypeRecord?> _type;
private readonly LazyVariable<BitFieldTypeRecord, CodeViewTypeRecord?> _type;

/// <summary>
/// Initializes an empty bit field record.
Expand All @@ -14,7 +14,7 @@ public class BitFieldTypeRecord : CodeViewTypeRecord
protected BitFieldTypeRecord(uint typeIndex)
: base(typeIndex)
{
_type = new LazyVariable<CodeViewTypeRecord?>(GetBaseType);
_type = new LazyVariable<BitFieldTypeRecord, CodeViewTypeRecord?>(x => x.GetBaseType());
}

/// <summary>
Expand All @@ -26,7 +26,7 @@ protected BitFieldTypeRecord(uint typeIndex)
public BitFieldTypeRecord(CodeViewTypeRecord type, byte position, byte length)
: base(0)
{
_type = new LazyVariable<CodeViewTypeRecord?>(type);
_type = new LazyVariable<BitFieldTypeRecord, CodeViewTypeRecord?>(type);
Position = position;
Length = length;
}
Expand All @@ -39,8 +39,8 @@ public BitFieldTypeRecord(CodeViewTypeRecord type, byte position, byte length)
/// </summary>
public CodeViewTypeRecord? Type
{
get => _type.Value;
set => _type.Value = value;
get => _type.GetValue(this);
set => _type.SetValue(value);
}

/// <summary>
Expand Down
20 changes: 10 additions & 10 deletions src/AsmResolver.Symbols.Pdb/Leaves/ClassTypeRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ namespace AsmResolver.Symbols.Pdb.Leaves;
/// </summary>
public class ClassTypeRecord : CodeViewDerivedTypeRecord
{
private readonly LazyVariable<Utf8String> _uniqueName;
private readonly LazyVariable<VTableShapeLeaf?> _vtableShape;
private readonly LazyVariable<ClassTypeRecord, Utf8String> _uniqueName;
private readonly LazyVariable<ClassTypeRecord, VTableShapeLeaf?> _vtableShape;

/// <summary>
/// Initializes an empty class type.
Expand All @@ -25,8 +25,8 @@ protected ClassTypeRecord(CodeViewLeafKind kind, uint typeIndex)
throw new ArgumentOutOfRangeException(nameof(kind));

LeafKind = kind;
_uniqueName = new LazyVariable<Utf8String>(GetUniqueName);
_vtableShape = new LazyVariable<VTableShapeLeaf?>(GetVTableShape);
_uniqueName = new LazyVariable<ClassTypeRecord, Utf8String>(x => x.GetUniqueName());
_vtableShape = new LazyVariable<ClassTypeRecord, VTableShapeLeaf?>(x => x.GetVTableShape());
}

/// <summary>
Expand All @@ -50,8 +50,8 @@ public ClassTypeRecord(CodeViewLeafKind kind, Utf8String name, Utf8String unique

LeafKind = kind;
Name = name;
_uniqueName = new LazyVariable<Utf8String>(uniqueName);
_vtableShape = new LazyVariable<VTableShapeLeaf?>(default(VTableShapeLeaf));
_uniqueName = new LazyVariable<ClassTypeRecord, Utf8String>(uniqueName);
_vtableShape = new LazyVariable<ClassTypeRecord, VTableShapeLeaf?>(default(VTableShapeLeaf));
Size = size;
StructureAttributes = attributes;
BaseType = baseType;
Expand All @@ -77,17 +77,17 @@ public ulong Size
/// </summary>
public Utf8String UniqueName
{
get => _uniqueName.Value;
set => _uniqueName.Value = value;
get => _uniqueName.GetValue(this);
set => _uniqueName.SetValue(value);
}

/// <summary>
/// Gets or sets the shape of the virtual function table of this type, if available.
/// </summary>
public VTableShapeLeaf? VTableShape
{
get => _vtableShape.Value;
set => _vtableShape.Value = value;
get => _vtableShape.GetValue(this);
set => _vtableShape.SetValue(value);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ namespace AsmResolver.Symbols.Pdb.Leaves;
/// </summary>
public abstract class CodeViewCompositeTypeRecord : CodeViewTypeRecord
{
private readonly LazyVariable<Utf8String> _name;
private readonly LazyVariable<FieldListLeaf?> _fields;
private readonly LazyVariable<CodeViewCompositeTypeRecord, Utf8String> _name;
private readonly LazyVariable<CodeViewCompositeTypeRecord, FieldListLeaf?> _fields;

/// <summary>
/// Initializes a new empty composite type.
Expand All @@ -15,8 +15,8 @@ public abstract class CodeViewCompositeTypeRecord : CodeViewTypeRecord
protected CodeViewCompositeTypeRecord(uint typeIndex)
: base(typeIndex)
{
_name = new LazyVariable<Utf8String>(GetName);
_fields = new LazyVariable<FieldListLeaf?>(GetFields);
_name = new LazyVariable<CodeViewCompositeTypeRecord, Utf8String>(x => x.GetName());
_fields = new LazyVariable<CodeViewCompositeTypeRecord, FieldListLeaf?>(x => x.GetFields());
}

/// <summary>
Expand All @@ -33,17 +33,17 @@ public StructureAttributes StructureAttributes
/// </summary>
public Utf8String Name
{
get => _name.Value;
set => _name.Value = value;
get => _name.GetValue(this);
set => _name.SetValue(value);
}

/// <summary>
/// Gets a collection of fields that are defined in the enum.
/// </summary>
public FieldListLeaf? Fields
{
get => _fields.Value;
set => _fields.Value = value;
get => _fields.GetValue(this);
set => _fields.SetValue(value);
}

/// <summary>
Expand Down
10 changes: 5 additions & 5 deletions src/AsmResolver.Symbols.Pdb/Leaves/CodeViewDataField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace AsmResolver.Symbols.Pdb.Leaves;
/// </summary>
public abstract class CodeViewDataField : CodeViewNamedField
{
private readonly LazyVariable<CodeViewTypeRecord> _dataType;
private readonly LazyVariable<CodeViewDataField, CodeViewTypeRecord> _dataType;

/// <summary>
/// Initializes an empty instance data member.
Expand All @@ -14,7 +14,7 @@ public abstract class CodeViewDataField : CodeViewNamedField
protected CodeViewDataField(uint typeIndex)
: base(typeIndex)
{
_dataType = new LazyVariable<CodeViewTypeRecord>(GetDataType);
_dataType = new LazyVariable<CodeViewDataField, CodeViewTypeRecord>(x => x.GetDataType());
}

/// <summary>
Expand All @@ -25,7 +25,7 @@ protected CodeViewDataField(uint typeIndex)
protected CodeViewDataField(CodeViewTypeRecord dataType, Utf8String name)
: base(0)
{
_dataType = new LazyVariable<CodeViewTypeRecord>(dataType);
_dataType = new LazyVariable<CodeViewDataField, CodeViewTypeRecord>(dataType);
Name = name;
}

Expand All @@ -34,8 +34,8 @@ protected CodeViewDataField(CodeViewTypeRecord dataType, Utf8String name)
/// </summary>
public CodeViewTypeRecord DataType
{
get => _dataType.Value;
set => _dataType.Value = value;
get => _dataType.GetValue(this);
set => _dataType.SetValue(value);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ namespace AsmResolver.Symbols.Pdb.Leaves;
/// </summary>
public abstract class CodeViewDerivedTypeRecord : CodeViewCompositeTypeRecord
{
private readonly LazyVariable<CodeViewTypeRecord?> _baseType;
private readonly LazyVariable<CodeViewDerivedTypeRecord, CodeViewTypeRecord?> _baseType;

/// <inheritdoc />
protected CodeViewDerivedTypeRecord(uint typeIndex)
: base(typeIndex)
{
_baseType = new LazyVariable<CodeViewTypeRecord?>(GetBaseType);
_baseType = new LazyVariable<CodeViewDerivedTypeRecord, CodeViewTypeRecord?>(x => x.GetBaseType());
}

/// <summary>
/// Gets or sets the base type that this type is deriving from.
/// </summary>
public CodeViewTypeRecord? BaseType
{
get => _baseType.Value;
set => _baseType.Value = value;
get => _baseType.GetValue(this);
set => _baseType.SetValue(value);
}

/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions src/AsmResolver.Symbols.Pdb/Leaves/CodeViewNamedField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace AsmResolver.Symbols.Pdb.Leaves;
/// </summary>
public abstract class CodeViewNamedField : CodeViewField
{
private readonly LazyVariable<Utf8String> _name;
private readonly LazyVariable<CodeViewNamedField, Utf8String> _name;

/// <summary>
/// Initializes an empty CodeView field leaf.
Expand All @@ -14,16 +14,16 @@ public abstract class CodeViewNamedField : CodeViewField
protected CodeViewNamedField(uint typeIndex)
: base(typeIndex)
{
_name = new LazyVariable<Utf8String>(GetName);
_name = new LazyVariable<CodeViewNamedField, Utf8String>(x => x.GetName());
}

/// <summary>
/// Gets or sets the name of the field.
/// </summary>
public Utf8String Name
{
get => _name.Value;
set => _name.Value = value;
get => _name.GetValue(this);
set => _name.SetValue(value);
}

/// <summary>
Expand Down
10 changes: 5 additions & 5 deletions src/AsmResolver.Symbols.Pdb/Leaves/EnumerateField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace AsmResolver.Symbols.Pdb.Leaves;
/// </summary>
public class EnumerateField : CodeViewNamedField
{
private readonly LazyVariable<object> _value;
private readonly LazyVariable<EnumerateField, object> _value;

/// <summary>
/// Initializes an empty enumerate field leaf.
Expand All @@ -14,7 +14,7 @@ public class EnumerateField : CodeViewNamedField
protected EnumerateField(uint typeIndex)
: base(typeIndex)
{
_value = new LazyVariable<object>(GetValue);
_value = new LazyVariable<EnumerateField, object>(x => x.GetValue());
}

/// <summary>
Expand All @@ -27,7 +27,7 @@ public EnumerateField(Utf8String name, object value, CodeViewFieldAttributes att
: base(0)
{
Name = name;
_value = new LazyVariable<object>(value);
_value = new LazyVariable<EnumerateField, object>(value);
Attributes = attributes;
}

Expand All @@ -39,8 +39,8 @@ public EnumerateField(Utf8String name, object value, CodeViewFieldAttributes att
/// </summary>
public object Value
{
get => _value.Value;
set => _value.Value = value;
get => _value.GetValue(this);
set => _value.SetValue(value);
}

/// <summary>
Expand Down
Loading

0 comments on commit 89f934b

Please sign in to comment.