Due Date: Mon 21 NovPair ProjectObjectivesApplication of design patterns
Study of object-oriented language mechanisms
DescriptionYour job is to extend an interpreter for a simple, dynamically typed Smalltalk-like object-oriented language called miniool. This interpreter is an extension of the interpreter for the simple imperative language with records you have already seen in project 2a. The interpreter skeleton and test cases are available in the course repository. The language miniool is based on the simple imperative language. It adds the following concepts:
and the following syntactic constructs:
Besides the classes for the various constructs, you are given a visitor Execute for evaluating a statement down to an l-value. Your specific assignment is described in the following. It is suggested that you proceed with each portion of the project in the order given here. Completion of given codeComplete the missing code marked "your job" in execute.scala. Once you have done that, some of the given unit tests should work as expected. Until you complete this part, you will get failures in most of the unit tests! You must not make any other changes to the given code other than the ones specified below! MyInt classComplete the Clazz MyInt in TestMyInt to include the missing methods. class myInt { // ... intValue() { /* the value as an Integer object */ minus(that) { /* binary minus, returning a myInt */ } uminus() { /* unary minus, as in -7, returning a myInt */ } times(that) { /* multiplication returning a myInt, using itimes */ } } Furthermore, implement the following expression in the Statement that uses the myInt class in TestMyInt. v = z.minus(10).times(4).uminus().times(3).minus(7).intValue(); Fibonacci classComplete the (linearly recursive) fib method in the myInt class in FibonacciTest. Observe that fib(0) = 0, fib(1) = 1, fib(n) = fib(n - 1) + fib(n - 2) where n > 1. DocumentationIt is not necessary to write any additional scaladoc comments for this project since this project description already serves as documentation for the various components. However, you need to generate the scaladoc. Furthermore, you are required to provide inline comments for your code where appropriate similar to those in Execute case Message. How to submitPlease refer to the online submission procedure. |