While producing three address code of if — then — else statement, we may not knowing the labels where control must go by following the go to statements in a single pass, We can therefore use two passes.
In first pass we can generate labels also we can generate goto statements with unspecified destinations,
In the second pass, we can fill these unspecified destinationi, with prorr This technique of filling labels is known as backpatchlng,
Backpatching is the activity of filling ,tip unfipecified information of labels using appropriate semantic actions in during the code generation process. In the semantic actions the functions used are mklist (1), merge_llst ( p,, p2) and Backpatching
Functions that are used in backpatching.
- mklist(i) creates the new list. The index i is passed as an argument to this function where 1 is an index to the array of quadruple,.
- merge_list( p„ p2 ) this function conentonates two lists pointed by p, and p, . ft returns the, pointer to the concatenated list.
- backpatch(p,i) inserts i as target label for the statement pointed by pointer p.