Both implementations follow a two-step approach. They first instruct the outlines to an intermediate configuration, which is chosen to minimize the number of instructions required afterwards. The second step consists of a loop that is iterated once for each digit. In the loop, the rectangles are aligned with established points, to create their final form.
These debug glyphs will push any TrueType interpreter to its limits, with a healthy dose of math, stack manipulation, and inline functions. Some might even say they are a bit silly. I would agree with them. Hence...
While working on the Oxanium fonts, I realized that I only use the debug glyph to check if the instructions are executed at all. Therefore, I implemented a much more lightweight boolean marker, in the form of a simple triangle. In its unhinted configuration, it points downward. When the instructions are executed, they turn the triangle upside down.