Closed mattfysh closed 2 years ago
Hi @mattfysh. I don't have any concrete examples to point to but this usage seems reasonable. Avro supports unions which are convenient for modeling ASTs (as you're doing for instructions). Logical types can be handy as well. If Avro supports all the languages you target, this sounds like a good fit.
Great, thanks @mtth. Let me know if you do happen to come across any other examples of Avro generating bytecode
The only two things I've stumbled on so far are:
['string', 'boolean']
but this added an extra byte before each item because of the union, so now its just 'string'
and the bytecode is much smallerDatumReader
doesn't wrap union types with the type name in the same way your library does, I had to subclass it and override the read_union
method
Hi there, I'm looking at generating bytecode for a toy language and searched for a while to find a binary packing/unpacking library written in JS but there are not that many great options.
So I started using avsc and it seems to be outputting what I need, e.g. I have a type
Instruction
which is a union type of all possible instruction set types.Has Avro been used in this way before, and do you see any issues using it this way? My compiler and tooling is all written in javascript but the goal of producing bytecode is to write interpreters in other languages (e.g. Python) that can use Avro to decode the binary into a program structure and execute