-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System; | ||
|
||
using IKVM.ByteCode.Buffers; | ||
using IKVM.ByteCode.Parsing; | ||
|
||
namespace IKVM.ByteCode.Writing | ||
{ | ||
|
||
public struct InnerClassesTableEncoder | ||
{ | ||
|
||
readonly BlobBuilder _builder; | ||
readonly Blob _countBlob; | ||
ushort _count; | ||
|
||
/// <summary> | ||
/// Intializes a new instance. | ||
/// </summary> | ||
/// <param name="builder"></param> | ||
public InnerClassesTableEncoder(BlobBuilder builder) | ||
{ | ||
_builder = builder ?? throw new ArgumentNullException(nameof(builder)); | ||
_countBlob = _builder.ReserveBytes(ClassFormatWriter.U2); | ||
_count = 0; | ||
} | ||
|
||
/// <summary> | ||
/// Adds a package to the table. | ||
/// </summary> | ||
/// <param name="package"></param> | ||
public InnerClassesTableEncoder Add(ClassConstantHandle innerClass, ClassConstantHandle outerClass, Utf8ConstantHandle innerName, AccessFlag innerAccessFlags) | ||
{ | ||
var w = new ClassFormatWriter(_builder.ReserveBytes(ClassFormatWriter.U2 + ClassFormatWriter.U2 + ClassFormatWriter.U2 + ClassFormatWriter.U2).GetBytes()); | ||
w.TryWriteU2(innerClass.Index); | ||
w.TryWriteU2(outerClass.Index); | ||
w.TryWriteU2(innerName.Index); | ||
w.TryWriteU2((ushort)innerAccessFlags); | ||
new ClassFormatWriter(_countBlob.GetBytes()).TryWriteU2(++_count); | ||
return this; | ||
} | ||
|
||
} | ||
|
||
} |