Machine-translated by Google. Questions are authored in English.
Top

Intermediate Code Generation Questions and Answers

Answer: A

Correct answer: summing the widths of its fields with any alignment padding

The width is the total the fields occupy, including any padding inserted so that each field begins at an address its type requires. That padding is why a record can be wider than the sum of its fields, and why reordering fields can change the size of a structure without changing its contents.

Please log in or register to report this question.

Answer: B

Correct answer: a running total carried along the list of fields

Each field is placed at the current total, after which the total is advanced by that field’s width plus any padding. The offset is therefore an inherited attribute passed along the field list, and it is one of the standard illustrations of a syntax-directed definition using inherited attributes.

Please log in or register to report this question.

Answer: C

A declaration reserves storage and records a type, both of which live in the symbol table. Any initialiser attached to it does generate ordinary assignment code. Storage layout decisions are recorded there rather than emitted as instructions.

Please log in or register to report this question.

44.

State whether the following is true or false.
Intermediate code is always machine independent.

Answer: D

Some intermediate forms deliberately expose machine properties such as word size or the register set, and the widths used in address arithmetic come from the target. Machine independence is a design goal that is approached rather than absolutely achieved.

Please log in or register to report this question.

Answer: A

Correct answer: retains more of the source structure and less machine detail

A high level representation keeps array indexing, structure references and loops as such, which suits optimisations that reason about program structure. Lowering it exposes address arithmetic and machine operations, which suits optimisations closer to the target. Neither is better in general, which is why several are used in sequence.

Please log in or register to report this question.

Answer: B

Correct answer: lowering the program gradually toward the target machine

Each level exposes different detail and permits different optimisations, so a modern compiler moves through several - a structured form, then a linear one, then something close to the machine. Optimisations are placed where the information they need is still visible, which no single representation could achieve.

Please log in or register to report this question.

Answer: C

Correct answer: an intermediate representation designed to be portable and executable

Bytecode occupies both roles: it is an intermediate representation in the compiler’s sense and a program the virtual machine can execute directly. That combination is what allows the same compiled file to run wherever the virtual machine exists, and it can be optimised both before and during execution.

Please log in or register to report this question.

Answer: D

Semantic rules attached to the productions emit the instructions. Whether an explicit tree is built first depends on how many passes the compiler makes. A one pass compiler emits instructions as the productions are reduced.

Please log in or register to report this question.

Answer: A

Each rule emits an instruction computing into a new place and reports that place upward. Register assignment happens much later, in the code generator. The name is all the translation needs to refer to the value again.

Please log in or register to report this question.

Answer: B

Control enters only at the top and leaves only at the bottom, so either every instruction in the block runs or none does. That guarantee is what makes local optimisation within a block so much simpler than reasoning across the whole procedure.

Please log in or register to report this question.

Loading…
Tags: Intermediate Code Generation Questions and Answers || Intermediate Code Generation MCQ Questions and Answers || Intermediate Code Generation GK Questions and Answers || Intermediate Code Generation GK MCQ Questions || Intermediate Code Generation Multiple Choice Questions and Answers || Intermediate Code Generation GK || GK on Intermediate Code Generation || Compiler Design Questions and Answers || Compiler Design MCQ Questions and Answers || Compiler Design GK Questions and Answers || GK on Compiler Design