Skip to content

Commit

Permalink
Fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
wasabii committed Aug 3, 2024
1 parent 01b3178 commit 12566e5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
20 changes: 10 additions & 10 deletions src/IKVM.ByteCode/Parsing/ModuleAttributeRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/IKVM.ByteCode/Writing/AnnotationEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public AnnotationEncoder(BlobBuilder builder)
/// <param name="annotation"></param>
public void Encode(AnnotationRecord annotation)
{
Encode(annotation.Type, e => e.AddMany(annotation.Elements));
Encode(annotation.Type, e => e.AddMany(annotation.Elements.AsSpan()));
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/IKVM.ByteCode/Writing/ElementValueEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/IKVM.ByteCode/Writing/TypeAnnotationEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down

0 comments on commit 12566e5

Please sign in to comment.