From 12566e5210252539deaa72be9a49eb0459856708 Mon Sep 17 00:00:00 2001 From: Jerome Haltom Date: Sat, 3 Aug 2024 10:31:59 -0500 Subject: [PATCH] Fix. --- .../Parsing/ModuleAttributeRecord.cs | 20 +++++++++---------- .../Writing/AnnotationEncoder.cs | 2 +- .../Writing/ElementValueEncoder.cs | 2 +- .../Writing/TypeAnnotationEncoder.cs | 20 +++++++++---------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/IKVM.ByteCode/Parsing/ModuleAttributeRecord.cs b/src/IKVM.ByteCode/Parsing/ModuleAttributeRecord.cs index 93e205f..380970f 100644 --- a/src/IKVM.ByteCode/Parsing/ModuleAttributeRecord.cs +++ b/src/IKVM.ByteCode/Parsing/ModuleAttributeRecord.cs @@ -28,7 +28,7 @@ public static bool TryReadModuleAttribute(ref ClassFormatReader reader, out Attr if (reader.TryReadU2(out ushort requiresVersionIndex) == false) return false; - requires[i] = new ModuleAttributeRequiresRecord(requiresIndex, (ModuleRequiresFlag)requiresFlags, requiresVersionIndex); + requires[i] = new ModuleAttributeRequiresRecord(new(requiresIndex), (ModuleRequiresFlag)requiresFlags, new(requiresVersionIndex)); } if (reader.TryReadU2(out ushort exportsCount) == false) @@ -45,16 +45,16 @@ public static bool TryReadModuleAttribute(ref ClassFormatReader reader, out Attr if (reader.TryReadU2(out ushort exportsModuleCount) == false) return false; - var exportsModules = new ushort[exportsModuleCount]; + var exportsModules = new ModuleConstantHandle[exportsModuleCount]; for (int j = 0; j < exportsModuleCount; j++) { if (reader.TryReadU2(out ushort exportsToModuleIndex) == false) return false; - exportsModules[j] = exportsToModuleIndex; + exportsModules[j] = new(exportsToModuleIndex); } - exports[i] = new ModuleAttributeExportsRecord(exportsIndex, (ModuleExportsFlag)exportsFlags, exportsModules); + exports[i] = new ModuleAttributeExportsRecord(new(exportsIndex), (ModuleExportsFlag)exportsFlags, exportsModules); } if (reader.TryReadU2(out ushort opensCount) == false) @@ -71,16 +71,16 @@ public static bool TryReadModuleAttribute(ref ClassFormatReader reader, out Attr if (reader.TryReadU2(out ushort opensModulesCount) == false) return false; - var opensModules = new ushort[opensModulesCount]; + var opensModules = new ModuleConstantHandle[opensModulesCount]; for (int j = 0; j < opensModulesCount; j++) { if (reader.TryReadU2(out ushort opensModuleIndex) == false) return false; - opensModules[j] = opensModuleIndex; + opensModules[j] = new(opensModuleIndex); } - opens[i] = new ModuleAttributeOpensRecord(opensIndex, (ModuleOpensFlag)opensFlags, opensModules); + opens[i] = new ModuleAttributeOpensRecord(new(opensIndex), (ModuleOpensFlag)opensFlags, opensModules); } if (reader.TryReadU2(out ushort usesCount) == false) @@ -107,16 +107,16 @@ public static bool TryReadModuleAttribute(ref ClassFormatReader reader, out Attr if (reader.TryReadU2(out ushort providesModulesCount) == false) return false; - var providesModules = new ushort[providesModulesCount]; + var providesModules = new ClassConstantHandle[providesModulesCount]; for (int j = 0; j < providesModulesCount; j++) { if (reader.TryReadU2(out ushort providesModuleIndex) == false) return false; - providesModules[j] = providesModuleIndex; + providesModules[j] = new(providesModuleIndex); } - provides[i] = new ModuleAttributeProvidesRecord(providesIndex, providesModules); + provides[i] = new ModuleAttributeProvidesRecord(new(providesIndex), providesModules); } attribute = new ModuleAttributeRecord(new(moduleNameIndex), (ModuleFlag)moduleFlags, new(moduleVersionIndex), requires, exports, opens, uses, provides); diff --git a/src/IKVM.ByteCode/Writing/AnnotationEncoder.cs b/src/IKVM.ByteCode/Writing/AnnotationEncoder.cs index 2aaf33a..479721b 100644 --- a/src/IKVM.ByteCode/Writing/AnnotationEncoder.cs +++ b/src/IKVM.ByteCode/Writing/AnnotationEncoder.cs @@ -42,7 +42,7 @@ public AnnotationEncoder(BlobBuilder builder) /// public void Encode(AnnotationRecord annotation) { - Encode(annotation.Type, e => e.AddMany(annotation.Elements)); + Encode(annotation.Type, e => e.AddMany(annotation.Elements.AsSpan())); } /// diff --git a/src/IKVM.ByteCode/Writing/ElementValueEncoder.cs b/src/IKVM.ByteCode/Writing/ElementValueEncoder.cs index d19e886..a833bfe 100644 --- a/src/IKVM.ByteCode/Writing/ElementValueEncoder.cs +++ b/src/IKVM.ByteCode/Writing/ElementValueEncoder.cs @@ -69,7 +69,7 @@ public void Encode(ElementValueRecord value) Annotation(e => e.Encode(((ElementValueAnnotationValueRecord)value.Value).Annotation)); break; case ElementValueTag.Array: - Array(e => e.AddMany(((ElementValueArrayValueRecord)value.Value).Values)); + Array(e => e.AddMany(((ElementValueArrayValueRecord)value.Value).Values.AsSpan())); break; } } diff --git a/src/IKVM.ByteCode/Writing/TypeAnnotationEncoder.cs b/src/IKVM.ByteCode/Writing/TypeAnnotationEncoder.cs index acba10a..35670c6 100644 --- a/src/IKVM.ByteCode/Writing/TypeAnnotationEncoder.cs +++ b/src/IKVM.ByteCode/Writing/TypeAnnotationEncoder.cs @@ -33,34 +33,34 @@ public void Encode(TypeAnnotationRecord record) switch (record.Target) { case TypeParameterTargetRecord target: - TypeParameterTarget(record.TargetType, target.ParameterIndex, e => e.Encode(record.TargetPath), record.Type, e => e.AddMany(record.Elements)); + TypeParameterTarget(record.TargetType, target.ParameterIndex, e => e.Encode(record.TargetPath), record.Type, e => e.AddMany(record.Elements.AsSpan())); break; case SuperTypeTargetRecord target: - SuperTypeTarget(record.TargetType, target.SuperTypeIndex, e => e.Encode(record.TargetPath), record.Type, e => e.AddMany(record.Elements)); + SuperTypeTarget(record.TargetType, target.SuperTypeIndex, e => e.Encode(record.TargetPath), record.Type, e => e.AddMany(record.Elements.AsSpan())); break; case TypeParameterBoundTargetRecord target: - TypeParameterBoundTarget(record.TargetType, target.ParameterIndex, target.BoundIndex, e => e.Encode(record.TargetPath), record.Type, e => e.AddMany(record.Elements)); + TypeParameterBoundTarget(record.TargetType, target.ParameterIndex, target.BoundIndex, e => e.Encode(record.TargetPath), record.Type, e => e.AddMany(record.Elements.AsSpan())); break; case EmptyTargetRecord target: - EmptyTarget(record.TargetType, e => e.Encode(record.TargetPath), record.Type, e => e.AddMany(record.Elements)); + EmptyTarget(record.TargetType, e => e.Encode(record.TargetPath), record.Type, e => e.AddMany(record.Elements.AsSpan())); break; case FormalParameterTargetRecord target: - FormalParameterTarget(record.TargetType, target.ParameterIndex, e => e.Encode(record.TargetPath), record.Type, e => e.AddMany(record.Elements)); + FormalParameterTarget(record.TargetType, target.ParameterIndex, e => e.Encode(record.TargetPath), record.Type, e => e.AddMany(record.Elements.AsSpan())); break; case ThrowsTargetRecord target: - ThrowsTarget(record.TargetType, target.ThrowsTypeIndex, e => e.Encode(record.TargetPath), record.Type, e => e.AddMany(record.Elements)); + ThrowsTarget(record.TargetType, target.ThrowsTypeIndex, e => e.Encode(record.TargetPath), record.Type, e => e.AddMany(record.Elements.AsSpan())); break; case LocalVariableTargetTableRecord target: - LocalVarTarget(record.TargetType, e => e.AddMany(target), e => e.Encode(record.TargetPath), record.Type, e => e.AddMany(record.Elements)); + LocalVarTarget(record.TargetType, e => e.AddMany(target.Items.AsSpan()), e => e.Encode(record.TargetPath), record.Type, e => e.AddMany(record.Elements.AsSpan())); break; case CatchTargetRecord target: - CatchTarget(record.TargetType, target.ExceptionTableIndex, e => e.Encode(record.TargetPath), record.Type, e => e.AddMany(record.Elements)); + CatchTarget(record.TargetType, target.ExceptionTableIndex, e => e.Encode(record.TargetPath), record.Type, e => e.AddMany(record.Elements.AsSpan())); break; case OffsetTargetRecord target: - OffsetTarget(record.TargetType, target.Offset, e => e.Encode(record.TargetPath), record.Type, e => e.AddMany(record.Elements)); + OffsetTarget(record.TargetType, target.Offset, e => e.Encode(record.TargetPath), record.Type, e => e.AddMany(record.Elements.AsSpan())); break; case TypeArgumentTargetRecord target: - TypeArgumentTarget(record.TargetType, target.Offset, target.TypeArgumentIndex, e => e.Encode(record.TargetPath), record.Type, e => e.AddMany(record.Elements)); + TypeArgumentTarget(record.TargetType, target.Offset, target.TypeArgumentIndex, e => e.Encode(record.TargetPath), record.Type, e => e.AddMany(record.Elements.AsSpan())); break; default: throw new InvalidOperationException("Invalid type annotation.");