Closed Simn closed 5 years ago
Wow that's actually a pretty cool usage for inline XMLs :)
For my AS3 compiler, I wrote a macro that generates printer for all the syntax tree structures, because I was super-lazy to write them myself. I imagine something like this can be done here too?
At bytecode-level we should probably output whatever javap
outputs.
I'm wondering if we should even somehow expose this to the users at some point. Because untyped __java__
/@:functionCode
is not applicable to the bytecode target, but maybe there are still some cases where one'd want to construct custom code?
Maybe yeah. That requires a parser in OCaml, but the instruction format isn't exactly complicated.
maybe we could get away with normal haxe syntax tho:
haxe.Jvm.code({
Iconst_0;
Istore_1;
Iinc(1, 1);
});
That could be made to work. But is that really more fun than writing the code as string? Not sure...
Meh, at this point I don't really need these kinds of tests anymore. It would be nice to have, but I can't really be arsed to spend time on it.
So the reason I worked on format.jvm.Reader was because I wanted to add support for bytecode-level tests in order to catch regressions there. The basic idea is to get the jvm-tests to read their own .jar file and then compare it to some specific input.
This requires writing a printer for https://github.com/Simn/format/blob/jvm/format/jvm/Data.hx#L47 which fetches items from the constant pool. Once we have that, we can come up with some nice way to define the expected bytecode in-line. I imagine a macro like this would work nicely: