Skip to content

Commit

Permalink
Rename Table fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
wasabii committed Jan 16, 2024
1 parent 233bb20 commit 1be45f1
Show file tree
Hide file tree
Showing 31 changed files with 1,177 additions and 532 deletions.
22 changes: 11 additions & 11 deletions src/IKVM.Reflection/CustomAttributeData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ static void AppendValue(StringBuilder sb, Type type, CustomAttributeTypedArgumen
internal static void ReadDeclarativeSecurity(Module module, int index, List<CustomAttributeData> list)
{
var asm = module.Assembly;
var action = module.DeclSecurity.records[index].Action;
var br = module.GetBlobReader(module.DeclSecurity.records[index].PermissionSet);
var action = module.DeclSecurityTable.records[index].Action;
var br = module.GetBlobReader(module.DeclSecurityTable.records[index].PermissionSet);
if (br.PeekByte() == '.')
{
br.ReadByte();
Expand Down Expand Up @@ -516,17 +516,17 @@ public byte[] __GetBlob()
else if (customAttributeIndex == -1)
return __ToBuilder().GetBlob(module.Assembly);
else
return ((ModuleReader)module).GetBlobCopy(module.CustomAttribute.records[customAttributeIndex].Value);
return ((ModuleReader)module).GetBlobCopy(module.CustomAttributeTable.records[customAttributeIndex].Value);
}

public int __Parent
{
get
{
return customAttributeIndex >= 0
? module.CustomAttribute.records[customAttributeIndex].Parent
? module.CustomAttributeTable.records[customAttributeIndex].Parent
: declSecurityIndex >= 0
? module.DeclSecurity.records[declSecurityIndex].Parent
? module.DeclSecurityTable.records[declSecurityIndex].Parent
: 0;
}
}
Expand All @@ -541,7 +541,7 @@ public ConstructorInfo Constructor
get
{
if (lazyConstructor == null)
lazyConstructor = (ConstructorInfo)module.ResolveMethod(module.CustomAttribute.records[customAttributeIndex].Constructor);
lazyConstructor = (ConstructorInfo)module.ResolveMethod(module.CustomAttributeTable.records[customAttributeIndex].Constructor);

return lazyConstructor;
}
Expand Down Expand Up @@ -584,7 +584,7 @@ public IList<CustomAttributeNamedArgument> NamedArguments

void LazyParseArguments(bool requireNameArguments)
{
var br = module.GetBlobReader(module.CustomAttribute.records[customAttributeIndex].Value);
var br = module.GetBlobReader(module.CustomAttributeTable.records[customAttributeIndex].Value);
if (br.Length == 0)
{
// it's legal to have an empty blob
Expand Down Expand Up @@ -766,7 +766,7 @@ static List<CustomAttributeData> GetCustomAttributesImpl(List<CustomAttributeDat

internal static List<CustomAttributeData> GetCustomAttributesImpl(List<CustomAttributeData> list, Module module, int token, Type attributeType)
{
foreach (var i in module.CustomAttribute.Filter(token))
foreach (var i in module.CustomAttributeTable.Filter(token))
{
if (attributeType == null)
{
Expand All @@ -775,7 +775,7 @@ internal static List<CustomAttributeData> GetCustomAttributesImpl(List<CustomAtt
}
else
{
if (attributeType.IsAssignableFrom(module.ResolveMethod(module.CustomAttribute.records[i].Constructor).DeclaringType))
if (attributeType.IsAssignableFrom(module.ResolveMethod(module.CustomAttributeTable.records[i].Constructor).DeclaringType))
{
list ??= new List<CustomAttributeData>();
list.Add(new CustomAttributeData(module, i));
Expand All @@ -789,8 +789,8 @@ internal static List<CustomAttributeData> GetCustomAttributesImpl(List<CustomAtt
public static IList<CustomAttributeData> __GetCustomAttributes(Type type, Type interfaceType, Type attributeType, bool inherit)
{
var module = type.Module;
foreach (int i in module.InterfaceImpl.Filter(type.MetadataToken))
if (module.ResolveType(module.InterfaceImpl.records[i].Interface, type) == interfaceType)
foreach (int i in module.InterfaceImplTable.Filter(type.MetadataToken))
if (module.ResolveType(module.InterfaceImplTable.records[i].Interface, type) == interfaceType)
return GetCustomAttributesImpl(null, module, (InterfaceImplTable.Index << 24) | (i + 1), attributeType) ?? EmptyList;

return EmptyList;
Expand Down
2 changes: 1 addition & 1 deletion src/IKVM.Reflection/Emit/AssemblyBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ void SaveImpl(string assemblyFileName, Stream streamOrNull, PortableExecutableKi
rec.Flags = (int)resfile.Attributes;
rec.Name = manifestModule.GetOrAddString(resfile.Name);
rec.Implementation = MetadataTokens.GetToken(fileToken);
manifestModule.ManifestResource.AddRecord(rec);
manifestModule.ManifestResourceTable.AddRecord(rec);
}

// write each non-manifest module
Expand Down
4 changes: 2 additions & 2 deletions src/IKVM.Reflection/Emit/EventBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ internal void Bake()
rec.Name = typeBuilder.ModuleBuilder.GetOrAddString(name);
rec.EventType = eventType;

var token = MetadataTokens.GetToken(MetadataTokens.EventDefinitionHandle(typeBuilder.ModuleBuilder.Event.AddRecord(rec)));
var token = MetadataTokens.GetToken(MetadataTokens.EventDefinitionHandle(typeBuilder.ModuleBuilder.EventTable.AddRecord(rec)));
if (lazyPseudoToken == 0)
lazyPseudoToken = token;
else
Expand All @@ -211,7 +211,7 @@ void AddMethodSemantics(short semantics, int methodToken, int propertyToken)
rec.Semantics = semantics;
rec.Method = methodToken;
rec.Association = propertyToken;
typeBuilder.ModuleBuilder.MethodSemantics.AddRecord(rec);
typeBuilder.ModuleBuilder.MethodSemanticsTable.AddRecord(rec);
}

internal override bool IsPublic
Expand Down
12 changes: 6 additions & 6 deletions src/IKVM.Reflection/Emit/FieldBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ internal FieldBuilder(TypeBuilder type, string name, Type fieldType, CustomModif
fieldSig.WriteSig(typeBuilder.ModuleBuilder, sig);
this.signature = typeBuilder.ModuleBuilder.GetOrAddBlob(sig.ToArray());
this.attribs = attribs;
this.typeBuilder.ModuleBuilder.Field.AddVirtualRecord();
this.typeBuilder.ModuleBuilder.FieldTable.AddVirtualRecord();
}

public void SetConstant(object defaultValue)
Expand All @@ -80,7 +80,7 @@ public override object GetRawConstantValue()
throw new NotSupportedException();
}

return typeBuilder.Module.Constant.GetRawConstantValue(typeBuilder.Module, GetCurrentToken());
return typeBuilder.Module.ConstantTable.GetRawConstantValue(typeBuilder.Module, GetCurrentToken());
}

public void __SetDataAndRVA(byte[] data)
Expand All @@ -100,7 +100,7 @@ void SetDataAndRvaImpl(byte[] data, ByteBuffer bb, int readonlyMarker)
bb.Align(8);
rec.RVA = bb.Position + readonlyMarker;
rec.Field = pseudoToken;
typeBuilder.ModuleBuilder.FieldRVA.AddRecord(rec);
typeBuilder.ModuleBuilder.FieldRVATable.AddRecord(rec);
bb.Write(data);
}

Expand All @@ -120,9 +120,9 @@ public override bool __TryGetFieldOffset(out int offset)
if (typeBuilder.ModuleBuilder.IsSaved)
pseudoTokenOrIndex = typeBuilder.ModuleBuilder.ResolvePseudoToken(pseudoToken) & 0xFFFFFF;

foreach (int i in this.Module.FieldLayout.Filter(pseudoTokenOrIndex))
foreach (int i in this.Module.FieldLayoutTable.Filter(pseudoTokenOrIndex))
{
offset = this.Module.FieldLayout.records[i].Offset;
offset = this.Module.FieldLayoutTable.records[i].Offset;
return true;
}

Expand Down Expand Up @@ -163,7 +163,7 @@ public void SetOffset(int iOffset)
FieldLayoutTable.Record rec = new FieldLayoutTable.Record();
rec.Offset = iOffset;
rec.Field = pseudoToken;
typeBuilder.ModuleBuilder.FieldLayout.AddRecord(rec);
typeBuilder.ModuleBuilder.FieldLayoutTable.AddRecord(rec);
}

public override FieldAttributes Attributes
Expand Down
8 changes: 4 additions & 4 deletions src/IKVM.Reflection/Emit/GenericTypeParameterBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ internal GenericTypeParameterBuilder(string name, MethodBuilder method, int posi
rec.Flags = 0;
rec.Owner = type != null ? type.MetadataToken : method.MetadataToken;
rec.Name = ModuleBuilder.GetOrAddString(name);
paramPseudoIndex = ModuleBuilder.GenericParam.AddRecord(rec);
paramPseudoIndex = ModuleBuilder.GenericParamTable.AddRecord(rec);
}

public override string AssemblyQualifiedName
Expand Down Expand Up @@ -216,7 +216,7 @@ public void SetGenericParameterAttributes(GenericParameterAttributes genericPara
{
this.attr = genericParameterAttributes;
// for now we'll back patch the table
this.ModuleBuilder.GenericParam.PatchAttribute(paramPseudoIndex, genericParameterAttributes);
this.ModuleBuilder.GenericParamTable.PatchAttribute(paramPseudoIndex, genericParameterAttributes);
}

public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
Expand Down Expand Up @@ -244,7 +244,7 @@ internal override int GetModuleBuilderToken()
{
var spec = new ByteBuffer(5);
Signature.WriteTypeSpec(ModuleBuilder, spec, this);
typeToken = MetadataTokens.GetToken(MetadataTokens.TypeSpecificationHandle(ModuleBuilder.TypeSpec.AddRecord(ModuleBuilder.GetOrAddBlob(spec.ToArray()))));
typeToken = MetadataTokens.GetToken(MetadataTokens.TypeSpecificationHandle(ModuleBuilder.TypeSpecTable.AddRecord(ModuleBuilder.GetOrAddBlob(spec.ToArray()))));
}
return typeToken;
}
Expand All @@ -265,7 +265,7 @@ internal override int GetCurrentToken()
{
if (ModuleBuilder.IsSaved)
{
return (GenericParamTable.Index << 24) | Module.GenericParam.GetIndexFixup()[paramPseudoIndex - 1] + 1;
return (GenericParamTable.Index << 24) | Module.GenericParamTable.GetIndexFixup()[paramPseudoIndex - 1] + 1;
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/IKVM.Reflection/Emit/ILGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ public void __EmitCalli(OpCode opc, __StandAloneMethodSig sig)
}
var bb = new ByteBuffer(16);
Signature.WriteStandAloneMethodSig(moduleBuilder, bb, sig);
code.Write(MetadataTokens.GetToken(MetadataTokens.StandaloneSignatureHandle(moduleBuilder.StandAloneSig.FindOrAddRecord(moduleBuilder.GetOrAddBlob(bb.ToArray())))));
code.Write(MetadataTokens.GetToken(MetadataTokens.StandaloneSignatureHandle(moduleBuilder.StandAloneSigTable.FindOrAddRecord(moduleBuilder.GetOrAddBlob(bb.ToArray())))));
}

public void EmitWriteLine(string text)
Expand Down
8 changes: 4 additions & 4 deletions src/IKVM.Reflection/Emit/MethodBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ internal void SetDllImportPseudoCustomAttribute(string dllName, string entryName
rec.MappingFlags = flags;
rec.MemberForwarded = pseudoToken;
rec.ImportName = ModuleBuilder.GetOrAddString(entryName ?? name);
rec.ImportScope = MetadataTokens.GetToken(MetadataTokens.ModuleReferenceHandle(ModuleBuilder.ModuleRef.FindOrAddRecord(dllName == null ? default : ModuleBuilder.GetOrAddString(dllName))));
ModuleBuilder.ImplMap.AddRecord(rec);
rec.ImportScope = MetadataTokens.GetToken(MetadataTokens.ModuleReferenceHandle(ModuleBuilder.ModuleRefTable.FindOrAddRecord(dllName == null ? default : ModuleBuilder.GetOrAddString(dllName))));
ModuleBuilder.ImplMapTable.AddRecord(rec);
}

void SetMethodImplAttribute(CustomAttributeBuilder customBuilder)
Expand Down Expand Up @@ -287,7 +287,7 @@ public ParameterBuilder DefineParameter(int position, ParameterAttributes attrib
{
parameters ??= new List<ParameterBuilder>();

ModuleBuilder.Param.AddVirtualRecord();
ModuleBuilder.ParamTable.AddVirtualRecord();
var pb = new ParameterBuilder(ModuleBuilder, position, attributes, strParamName);
if (parameters.Count == 0 || position >= parameters[parameters.Count - 1].Position)
{
Expand Down Expand Up @@ -480,7 +480,7 @@ public override object RawDefaultValue
{
var pb = ParameterBuilder;
if (pb != null && (pb.Attributes & (int)ParameterAttributes.HasDefault) != 0)
return method.ModuleBuilder.Constant.GetRawConstantValue(method.ModuleBuilder, pb.PseudoToken);
return method.ModuleBuilder.ConstantTable.GetRawConstantValue(method.ModuleBuilder, pb.PseudoToken);
if (pb != null && (pb.Attributes & (int)ParameterAttributes.Optional) != 0)
return Missing.Value;

Expand Down
Loading

0 comments on commit 1be45f1

Please sign in to comment.