Scheme to implement translation .
S if E then M S 1
backpatch(E.truelist, M.quad)
S.nextlist = merge(E.falselist, S 1 .nextlist)
S if E them M 1 S1 N else M 2 S2
backpatch(E.truelist, M 1 .quad)
backpatch(E.falselist, M 2 .quad )
S.next = merge(S 1 .nextlist, N.nextlist, S 2 .nextlist
S while M 1 E do M 2 S1
backpatch(S1 .nextlist, M 1 .quad)
backpatch(E.truelist, M2 .quad)
S.nextlist = E.falselist
emit(goto M 1 .quad)
We explained the rules for S while M 1 E do M2 S1 in the previous slide. Now you can see the rules for all the other statements and you can infer them quite easily on similar grounds, from all you have been told in the previous few slides.
|