This uses a pass to interrogate the system for locations, then dumps
those out instead. It handles includes, anonymous labels, and basic
macros, but it does so in a somewhat ugly way. This data can be
readily abbreviated and should also be re-sorted.
Reliable technical documentation for how these instructions are decoded is a
little thin on the ground online, so some of this implementation is still
speculative.
This introduces a new IR node for mutable-during-assembly ranges.
In the common case, where offset and range are hardcoded or missing,
it continues with the older, more efficient behavior.
Full PEP8 compliance. Also, booleans have been inserted where
they make sense (introduced in 2.3!) and I haven't knowingly
added anything that will break 2.3 compatibility.
At this point the code really doesn't look like it was written
ten years ago. Hooray!
Ophis was originally written for Python 2.1, and it kind of shows.
Python 2.3 introduced booleans and optparse, so there's no reason
to not use new-style classes.
This is a full optparse-based parser for all the options we want
to have in Ophis 2.0, but the pass-disablers aren't working yet.
This also doesn't handle positional arguments the way we hope
to eventually; that will come later.
optparse is deprecated in 2.7, but its replacement isn't available
in any previous version of Python, so we avoid it so as to not
gratuitously break compatibility on older machines.
It would be nice to at least stay usable on stock Leopard Macs (2.5).
As part of this change, all assembler chat is being pushed to
standard error, where it probably should have been in the first place.
Scripts and batchfiles that relied on capturing the output of Ophis
will need to capture stderr now instead.
This pass actually isn't an optimizer in that it produces larger
binaries when it triggers. However, the larger binaries created
will actually assemble properly.
The ExtendBranches pass detects Relative instructions (that is,
branches) that extend past the signed-8-bit range Relative instructions
permit, and replaces them with a branch-jump combination with identical
semantics.
Since this may be evidence of a program bug, Ophis will warn when
the optimization is triggered.
Due to similarities between this pass and UpdateLabels, both passes
have been refactored in passing.