The final exam will be cumulative.

For sample questions for the material covered for Midterm 1 you should look at this page. For sample questions for the material covered for Midterm 2 you should look at this page.

Sample questions concerning material covered since Midterm 2:

  1. BRIEFLY define the following terms and give an example of how each term is used:
  2. What are the advantages and disadvantages of an interpreter? Describe two different types of interpreters (as discussed in class).
  3. What are some of the key questions that must be answered in order to implement an interpreter that works by first parsing an entire file and then executing the resulting AST (you may indicate other steps of compilation you think should be included before intepretation occurs)?
  4. How is memory generally laid out for a program? What are the various parts of the memory associated with the program used for?
  5. What are the components of an activation record? How is an AR used?
  6. How does a display of AR pointers work and what process(es) does it make more efficient? What are the drawbacks of a display?
  7. Data can be allocated statically, on the stack, or in the heap. What types of variables are the different sections of the program used for?
  8. How is an AR created during code generation? Which parts of the code are responsible for generating the AR? Explain how the different parts of a function call interact during creation of the AR.
  9. Assume you are in the process of writing a function codegen that does code generation for compiling a simple language to an intermediate language similar to the one discussed in class. What would your codegen routine generate for an addition operator?
  10. How are objects represented in memory during code generation when inheritance occurs? What are the key issues for code generation and inheritance?
  11. Explain how dynamic dispatch works for code containing objects with respect to inheritance. Give an example that illustrates your explanation.
  12. Compilers often generate intermediate code from an AST rather than generating machine code? Why? Are there disadvantages to this approach?
  13. Why is the term optimization something of a misnomer in compilers? What is optimized in the code? Define three different levels of optimization.
  14. Define and give an example of the following types of local optimizations:
    1. Algebraic simplification
    2. Constant folding
    3. Common sub-expression elimination
    4. Copy propagation
    5. Dead code elimination
  15. It is often the case that local optimizations are very simple. How then can they have such profound effects on code? Give an example to illustrate your point.