Add logic for keeping PUSHB/PUSHW distinction
And avoid merging consequent pushes. No option to control this
externally right now, but the logic is there.
Part of https://github.com/behdad/fonttools/issues/92
diff --git a/Lib/fontTools/ttLib/tables/ttProgram.py b/Lib/fontTools/ttLib/tables/ttProgram.py
index 8547e31..03f778e 100644
--- a/Lib/fontTools/ttLib/tables/ttProgram.py
+++ b/Lib/fontTools/ttLib/tables/ttProgram.py
@@ -389,7 +389,7 @@
assert max(bytecode) < 256 and min(bytecode) >= 0
self.bytecode = array.array("B", bytecode)
- def _disassemble(self):
+ def _disassemble(self, preserve=False):
assembly = []
i = 0
bytecode = self.bytecode
@@ -427,12 +427,16 @@
value = value - 0x10000
values.append(repr(value))
i = i + 2
+ if preserve:
+ break
+ if not preserve:
+ mnemonic = "PUSH"
nValues = len(values)
if nValues == 1:
- assembly.append("PUSH[ ]")
+ assembly.append("%s[ ]" % mnemonic)
else:
- assembly.append("PUSH[ ] /* %s values pushed */" % nValues)
+ assembly.append("%s[ ] /* %s values pushed */" % (mnemonic, nValues))
assembly.extend(values)
else:
assembly.append("INSTR%d[ ]" % op)