CS 3520 Homework 11   - Due November 29

Start with this code. Turn in a single interpreter/compiler with all of the revisions requested below. When you modify a function, update its contract and purpose statement. When adding a new helper function, provide a contract and purpose statement.

Important In DrScheme, click the EoPL and select CS3520 Support Page in the popup menu. The resulting window will contain a hyperlink that lets you download and install a patch to the EoPL library. You can complete the homework without the patch, but the test case will run very slowly.

You can also download the patch manually: eopl-patch.plt. In Windows, double-click the patch to install it.

Exercise 11.1, Lexical addresses

The initial translation-of-expression converts send expressions to use a method index, and removes unnecessary cast and instanceof expressions.

It does not translate identifiers to lexical indices, even through the language grammar and interpreter have been extended already with a lexvar form.

Modify translation-of-expression so that it converts any variable expression to an equivalent lexvar expression. You may need to extend the implementation of type environments.

You can test your change using run-time-tests, which runs list-program with and without translation. (The results should be the same!)

Exercise 11.2, Object creation

The given interpreter implements new by finding the instanitated class in a run-time class environment, then extracting the class's field count.

Add an object-creation form to the language that contains directly the number of fields in the class, so the interpreter need not find the class at run time.

Implement the added form in eval-expression.

Change translation-of-expression so that it translates new expressions to the added form.

Exercise 11.3, Finding Initialize

Although the initial translator converts send expressions to use a method index, the implementation of new still finds initialize by name at run time.

Modify your object-creation form from 11.2 so that it also contains a method index for initialize.

Modify the implementation of the form in eval-expression to use the index.

Exercise 11.4, Finding Classes

Although methods are found by index, the translations of both new and send still find class information by name in the run-time class environment. Partly, this is because object records contain class names.

Modify the implementation of the static class environment so that it can find an index for a class name.

Modify the implementation of the run-time class environment so that it can find a class record by index.

Modify the object record so that it contains a class index as well as a class name.

Modify the new form that uses method indices so that it contains a class index as well as a class name.

Exercise 11.5, Super Calls

The super form uses the environment to find the identity of the superclass at run time (via %super), but the superclass is actually known statically.

Add a super-call form to the language that contains the class index and method index for the target of the super call.

Implement the added form in eval-expression.

Change translation-of-expression so that it translates super expressions to the added form.

Exercise 11.6, Extra Transformations (Optional)

Invent and implement other meaning-preserving transformations for extra credit. Transformations that speed up a large class of useful programs will receive the most credit.

When implementing extra transformations, supply a function named extra-credit that takes no arguments and returns a string. The string should provide a brief description of your extra transformations, which will help the graders identify the potential for extra credit.


Last update: Monday, November 27th, 2000
mflatt@cs.utah.edu