-
-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Class writing move to ByteCode #283
base: develop
Are you sure you want to change the base?
Conversation
@wasabii this is work in progress and is not complete. Creating PR to inform you about ongoing work. |
Wow dude. It'll take me a bit to go over this one. But awesome. I didn't expect anybody else to go for this. |
@wasabii can you please suggest me Writer class design? I was using your Reader classes design as a reference and can't come up with a good design. How would you design, for example FieldWriter for FieldRecord? |
One of the things I was going to do was introduce a Builder pattern over the records. |
I hadn't even decided yet whether to name them Writers to be inline with Readers, or Builders, because lots of other projects use that terminology. But I had thought that modeling it sort of like System.Metadata.Reflection would be beneficial. |
Obviously different concepts. But they create a MetadataBuilder. Then invoke Add* methods on it. And metadata provides a few basic classes for data allocation, which we would use for Constant pool allocation. Like GetOrAddString(), etc. Which return "handles" that represent the various elements. And the GetOrAdd* pattern lets us deduplicate constants early. But still let the user create duplicate constants if he so desires. A very basic surface API, only exposing the Core concepts. And then other extension methods on top of that, for instance, to add a field the Core API would have AddField(Utf8ConstantHandle, etc). Forcing the user to call GetOrAddUtf8Constant() to get a Utf8ConstantHandle to pass. But we would also provide extension method versions of AddField that took strings as args and called GetOrAdd* itself, etc. |
At the end of the process, our ClassBuilder would have a Build() method which returned a ClassRecord. Which was immutable. And could then be written to a ClassFormatWriter. |
I also wanted to provide a parser over some common string formats, like Descriptors. And then associated builders. |
That's a good idea. I have implemented some builder class. Could you please comment if we go this way or like System.Reflection Ecma builder? |
I would start with modeling it on System.Reflection.Metadata.Ecma. That's the type of structure that seems the most logical to start with to me. Makes it most familiar for people working in this space in .NET. |
# Conflicts: # src/IKVM.Runtime/StubGen/StubGenerator.cs
No description provided.