-
-
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.
Add some encoders for records straight through.
Fix bootstrap method type.
- Loading branch information
Showing
10 changed files
with
230 additions
and
16 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
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
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
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,56 @@ | ||
using System; | ||
|
||
using IKVM.ByteCode.Buffers; | ||
using IKVM.ByteCode.Parsing; | ||
|
||
namespace IKVM.ByteCode.Writing | ||
{ | ||
|
||
/// <summary> | ||
/// Encodes an 'element_value_table' structure. | ||
/// </summary> | ||
public struct ElementValueTableEncoder | ||
{ | ||
|
||
readonly BlobBuilder _builder; | ||
readonly Blob _countBlob; | ||
ushort _count; | ||
|
||
/// <summary> | ||
/// Initializes a new instance. | ||
/// </summary> | ||
/// <param name="constants"></param> | ||
public ElementValueTableEncoder(BlobBuilder builder) | ||
{ | ||
_builder = builder ?? throw new ArgumentNullException(nameof(builder)); | ||
_countBlob = _builder.ReserveBytes(ClassFormatWriter.U2); | ||
_count = 0; | ||
} | ||
|
||
/// <summary> | ||
/// Encodes an existing set of elements. | ||
/// </summary> | ||
/// <param name="elements"></param> | ||
/// <exception cref="NotImplementedException"></exception> | ||
public void Encode(ReadOnlySpan<ElementValueRecord> elements) | ||
{ | ||
foreach (var i in elements) | ||
Element(e => e.Encode(i)); | ||
} | ||
|
||
/// <summary> | ||
/// Adds an element value pair. | ||
/// </summary> | ||
/// <param name="value"></param> | ||
public void Element(Action<ElementValueEncoder> value) | ||
{ | ||
if (value is null) | ||
throw new ArgumentNullException(nameof(value)); | ||
|
||
value(new ElementValueEncoder(_builder)); | ||
new ClassFormatWriter(_countBlob.GetBytes()).TryWriteU2(++_count); | ||
} | ||
|
||
} | ||
|
||
} |
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
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