jawa.assemble module

class jawa.assemble.Label(name)

Bases: tuple


Alias for field number 0


Assemble the given iterable of mnemonics, operands, and lables.

A convienience over constructing individual Instruction and Operand objects, the output of this function can be directly piped to assemble() to produce executable bytecode.

As a simple example, lets produce an infinite loop:

>>> from jawa.assemble import assemble, Label
>>> print(list(assemble((
...     Label('start'),
...     ('goto', Label('start'))
... ))))
[Instruction(mnemonic='goto', opcode=167, operands=[
    Operand(op_type=40, value=0)], pos=0)]

For a more complex example, see examples/hello_world.py.