7.5 GENERATOR
The generator produced the necessary code for the whole application in the assembly
language that Domatic used. As the generator was based on existing best-practice
FIGURE 7.7 Home automation generator structure
GENERATOR 153
code, the output was virtually indistinguishable from handwritten applications. One
concession was made to the time constraints: it would have been hard to generate the
correct absolute memory addresses for jumps, as this would have required calculating
the byte length of each assembly instruction. Instead, labels were generated as part of
the output, and jumps were directed to the labels. A quick change to the assembler
made these jumps function properly.
7.5.1 Generator Structure
The generator was divided between the two modeling languages in the obvious way.
Figure 7.7 shows the parts of the generator and the calls between them.
At the top level, a VoiceMenu generator started off the generation for
the top-level VoiceMenu diagram, iterating over each VoiceOutput object and
each _DTMF_Input object. The handling of DTMF input, invalid input and
timeouts was all generated at this level. For the sample VoiceMenu from Fig. 7.5,
the code output for the ?¬?rst VoiceOutput and DTMF_Input is shown in Listing 7.2.
Listing 7.2 Generator output for ?¬?rst VoiceOutput in sample VoiceMenu.
Pages:
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295