Discussion
Consider the following statements about the use of backpatching in a compiler for intermediate code generation:
(I) Backpatching can be used to generate code for Boolean expression in one pass.
(II) Backpatching can be used to generate code for flow-of-control statements in one pass.
Which ONE of the following options is CORRECT?
Answer: C
Both (I) and (II) are correct.
Backpatching solves the problem of generating jumps whose targets are not yet known. The compiler emits a jump with its target left blank, records the instruction in a list (such as truelist, falselist or nextlist), and fills in the target later, once the label is known.
This lets a one-pass translator generate short-circuit code for Boolean expressions, where 'true' and 'false' exits jump forward to code not yet generated (I). It equally handles flow-of-control statements such as if, if-else and while, whose exit and loop-back jumps are patched when the statement ends (II). The classic textbook treatment (Aho, Sethi and Ullman) uses it for both.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development