Skip to content

More downstream stuff#31

Open
nickelpro wants to merge 2 commits into
TkTech:nickelpro-developfrom
nickelpro:nickelpro-develop
Open

More downstream stuff#31
nickelpro wants to merge 2 commits into
TkTech:nickelpro-developfrom
nickelpro:nickelpro-develop

Conversation

@nickelpro

@nickelpro nickelpro commented Aug 2, 2021

Copy link
Copy Markdown
Contributor

This gets entries for all of the various table attributes out of the AST.

For BootstrapMethods, it unrolls the MethodHandle constant. Admittedly I don't understand this recommendation 100%, but I don't have a good reason not to do it either. Constants are still rolled into all other attributes though, so let me know if I should be unrolling constants across the board. If that's the case we might want to look into a more universal to_attr method or something.

A TableAttribute base class is added

ReferenceKind is now an IntEnum

@nickelpro nickelpro changed the title Use 'entries' for TableAttributes More downstream stuff Aug 2, 2021
@nickelpro

nickelpro commented Aug 2, 2021

Copy link
Copy Markdown
Contributor Author

Second commit does exactly what it says on the tin, which is very useful for searching methods for various instructions

for ins in code.find(f=lambda x: x.name in ('ldc', 'ldc_w'))

vs

for ins in code.find(name=('ldc','ldc_w'))

@nickelpro nickelpro force-pushed the nickelpro-develop branch 3 times, most recently from 40b82f1 to 2c4e0e2 Compare August 2, 2021 12:03
@nickelpro

Copy link
Copy Markdown
Contributor Author

Wait, I'm dumb, this checks node names not name names. Reverting. I think this needs a better solution because this operation is super common and using a lambda feels clunky.

@TkTech

TkTech commented Aug 2, 2021

Copy link
Copy Markdown
Owner

dmittedly I don't understand this recommendation 100%, but I don't have a good reason not to do it either.

The lawu.constants types are tightly tied to their binary representation, and will be the first thing moved into C/Cython (parsing constants takes the 2nd most time after simple zipfile IO). The AST can come from anywhere, such as Jasmin [which we already have a lexer for and used to have a parser for], as well as Soot's 3 intermediate representations.

I'll probably re-organize the files a bit, such as moving lawu.constants into lawu.cf.constants to make it clear it's for writing/parsing binary ClassFiles.

The reason why I'm trying to keep all the constants unpacked in the AST is to make transformation easier. Constants are a pain, because you can't just edit what you're on, such as an ldc instruction, but also have to clone the constant, or ensure all other references to that constant are okay with the change as well. Some sources like Jasmin don't have a concept of a pool until assembled.

Keep in mind all of this is "alpha" stage, so if you have better suggestions feel free to bring them up :)

@nickelpro

Copy link
Copy Markdown
Contributor Author

That makes perfect sense, I'll have the other attributes unroll constants as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants