Our current process is to update bytecode.yaml, run a small transform on it to fill in some defaults and convert it to JSON (so we don't add pyyaml as a distribution dependency). At runtime this JSON file is loaded and used as the bytecode reference.
Instead, lets transform bytecode.yaml directly into python. The primary reasoning for this is to support autocomplete, help tags and type hinting for operand values. For example in our yaml file we have ->
aaload:
op: 0x32
desc: load onto the stack a reference from an array
stack:
before:
- ArrayRef
- Index
after:
- Value
runtime:
- NullPointerException
- ArrayIndexOutOfBoundsException
We can turn this into ->
class aaload(Instruction):
"""load onto the stack a reference from an array"""
__slots__ = ('op', 'mnemonic', 'stack', 'runtime', 'operands')
op = 0x32
mnemonic = 'aaload'
...
So that we can do for example...
import jawa.bytecode as I
method.code.assemble((
I.aaload,
I.bipush(6),
I.return_
))
enhancement