S→ if B then Ms1 backpatch(B truelist, M code) S netlist: -merge(B. falselist, S,netlist)) s- ifb then mis nelse m s backpatch(B truelist, Mj. code) backpatch(B. falselist, M2. code) S netlist: -merge(S, netlist merge(N netlist, S, netlist)))
S→ if B then M S1 { backpatch(B.truelist,M.code); S.nextlist:=merge(B.falselist,S1 .nextlist) } S→ if B then M1 S1 N else M2 S2 { backpatch(B.truelist,M1 .code); backpatch(B.falselist,M2 .code); S.nextlist:=merge(S1 .nextlist, merge(N.nextlist,S2 .nextlist)) }
S→ While m1BdoM2S1 i backpatch(B truelist, M,code) backpatch(S netlist, Mrcode) emit(,",Mi.code) S netlist: = B. falselist j
S→ while M1 B do M2 S1 { backpatch(B.truelist,M2 .code); backpatch(S1 .nextlist,M1 .code); emit(j,-,-,M1 .code); S.nextlist:=B.falselist }
例1: if asb then a:=a+b的翻译 fasb 108 ifB B truelist=100 100:(j<ab,0) B. falselist=104 104:(j,-2-20) ifb then e ifb then m M code=10 8 e ifb then M a:=a+b if B then msi S1 netlist=0 108:(+,a,b,t1) 2(:=,tl,a) S backpatch(100, 108) S netlist=104
例1: if a<b then a:=a+b 的翻译 if a<b if B B.truelist=100 100:(j<,a,b,0) B.falselist=104 104:(j,-,-,0) if B then if B then M M.code=108 if B then M a:=a+b if B then M S1 S1.nextlist=0 108:(+,a,b,t1) 112:(:=,t1,-,a) S backpatch(100,108) S.nextlist=104 108