This final stage emits the target-code tree as a class definition in Object Rexx. To help with debugging, we try to make the generated code as readable as possible, so the output stage is in fact also a pretty-printer for a restricted subset of Object Rexx.
We show an example of the generated code below. It is more complicated than the examples in Section 2.7, as I omitted some details from them for simplicity.
/* FACT.cmd */ ::class FACT subclass Page public /* ivars */ ::method getOwnAttributeNames class return .set~new ::method setup self~~setup:super c691 = .WebObjectContents~of(, "s ",, .IntegerField~new("input",self), ~~setdisplay(""),, "r229:8",, .Text~new("output",self), ~~setvalue(""),, "r259:33",, "s ", ) self~setContents(.WebObjectContents~of(, "r0:185",, .WOMForm690~new("WOMForm689",self), ~~setContents(c691),, "r532:24",, "s ", )) return ::method getWOMFile class return "D:\ho\FACT.wom" ::method factorial use arg n if n=1 then return 1 else return n*self~factorial(n-1) ::class WOMForm690 subclass WOMForm public /* ivars */ ::method OnSubmit localnamebase = self~getParent n = localnamebase~findLocalInstanceFromPath('input'), ~getValue if n<1 then localnamebase~findLocalInstanceFromPath('output'), ~setValue( "Input must be positive" ) else do f = localnamebase~factorial(n) localnamebase~findLocalInstanceFromPath('output'), ~setValue( n||'! =' f ) end returnIn this code, the strings that begin with
r
contain
byte pointers into WOM source file, whose name is
returned
by the getWOMFile
method. The strings starting with s
are
explicit string constants (spaces).