Assignment_10_Compiler Solution
Assignment_10_Compiler Solution
Compiler Design
Assignment- Week 10
TYPE OF QUESTION:MCQ
Number ofquestions:13 Total mark: 13 X 1 = 13
1.
Ans: c)
Explanation:
If the activation record is static, this means that each function has a fixed memory
location allocated at compile time rather than dynamically allocating space on the stack
during execution. This has significant implications:
2.
Ans: b)
Explanation:
The control link (also known as the dynamic link) in an activation record is a pointer to
the activation record of the calling (parent) function. It helps maintain the correct
function call sequence and is crucial for returning to the correct activation record after a
function call completes.
3.
Ans: b)
Explanation:
Ans: a)
Explanation:
5.
Ans: b)
Explanation:
6. Access link points to the
The access link (also called a static link) is used in languages that support nested
procedures or static scoping. It points to the activation record of the lexically enclosing
function (parent function) rather than the function that called it.
• In static scoping, a function can be nested inside another function, and it needs
access to the non-local variables of the lexically enclosing function.
• The access link helps in reaching these non-local variables.
• The control link (dynamic link), on the other hand, helps with returning to the
caller, but that's different from the access link.
Ans: b)
Explanation:
High-level languages (HLL) like C, C++, and Rust support pointers explicitly. However,
the intermediate language (IL) used in a compiler does not necessarily have to support
pointers in the same way. Instead, the IL might represent pointers using addresses,
references, or other constructs that serve a similar purpose without direct pointer
manipulation.
For example:
8.
Ans: a)
9.
Ans: c)
Explanation:
Explanation:
The frame pointer (FP) is a register that points to the current activation record (stack
frame) in memory. It serves as a stable reference point for accessing local variables,
function parameters, and saved registers within the current function call.
Explanation:
11.
Which of the following is a key purpose of the stack pointer in an activation record?
Answer: (C)
Explanation: The stack pointer (SP) keeps track of the top of the stack, ensuring that
function calls, local variable allocation, and return addresses are managed properly. It
helps in pushing and popping activation records dynamically during execution.
12.
Answer: (B)
Explanation: A static activation record means that activation records are allocated in a
fixed location, making it impossible to handle multiple function calls at different
recursion depths. When recursion is attempted, new function calls overwrite the existing
activation record, leading to incorrect execution.
13.
END of Assignment