CS712/CS812
Project Phase 3
Spring 2015
Due Sunday April 5
Add objects to your Tscript system by adding the following features:
- (50 points) The
new
operator and the
property
accessors.
You only need to implement the "dot" operator for property accessors,
and not the square-bracket notation.
The "base" of a property access must be an object, otherwise throw
a type error message string (or report a type error if you are not supporting
exceptions).
You do not need to implement prototypal inheritance for this work item.
You also do not need to implement property attributes.
All properties should be data properties that are enumerable, writable
and configurable.
Finally, do not report an error if the expression for the new operator
is not a function object.
Go ahead and create and return a new object whose prototype is null.
In fact, because some students may not have functions implemented, I
will not test this level of the assignment except with non-function
values for the expression of the new operator.
- (10 points) Add support for prototypal inheritance.
When creating a new object, take the prototype for the new object
from the "prototype" property of the object produced by the
expression of the new operator.
If the expression does not produce an object,
or if the "prototype" property of the object is not an object,
then make the prototype of the new object be null.
- (10 points) Add support for the
global
environment and the
global
object.
Support the three value properties of the global object:
NaN, Infinity and undefined.
(Because we are not implementing property attributes, it is okay for
the properties of the global object to be configurable, enumerable and
writable.)
Be sure to change the behavior for assigning to undefined identifiers to cause
properties to be added to the global object.
- (10 points) Add support for built-in functions.
This will require that you implement function call, if you have not
already done so.
Support a non-standard function property of the global object called
"readln" which reads the next line from stdin and returns it (including
the newline on the end) as a string.
At EOF, the function should return the empty string.
Also support these two standard function properties of the global object:
isNaN and isFinite.
Note that these functions take an argument, so your
function call mechanism needs to support at least one argument.
- (10 points) Add support for the
this keyword.
Add a non-standard function property of the global object
called "testThis" that will
expect an object to be bound to "this", will add a property to it called
"xyz" containing the value 42, and will return "this".
This function object should have a "prototype" property referencing an object
that contains a function property called "printXYZ" that will display
the contents of the "xyz" property of the object referenced by "this".
I will test calling the "testThis" function as both a constructor and
as a function.
- (10 points) Add support for objects to the
abstract
operation ToPrimitive.
This involves implementing the "internal" method
DefaultValue.
For this level, you will need to have function expressions implemented.
And you should include support for references to "this" in the
body of functions.
You should implement items in the above list in the order that they
are listed.
Items earlier in the list might be used to test items later in the list.
Remember that you need to be sure that your compiler supports the
first three work items from Phase 1 (logical not operator, the equals
operator, the less-than operator, the greater-than operator, the Boolean
type and the Undefined type) and the first four work items from Phase 2
(the block statement, the empty statement, the if statement and the
else statement).
To get full credit, your code must be adequately documented and structured.
If I can't easily read and understand your code, you may lose points.
You must give me back the system in the same form that I gave it to
you.
I must be able to install it and run it in the exact same way as
when it was delivered to you.
I would also like you to keep the source code organized in the
same directory hierarchy.
If you fail to do this, a significant deduction
will be made to your grade.
Note that there is a script, distribute.sh, in tscript/bin,
which will generate a tar file for you.
This tar file is what I require you to submit to me for grading.
To turn in this assignment, type:
~cs712/bin/submit phase3 tscript.tar
Submissions can be checked by typing:
~cs712/bin/scheck phase3
The assignment is due on Sunday April 5.
Submissions between 8am April 6 and 8am April 7 will
have a late penalty of 10 points.
Submissions between 8am April 7 and 8am April 8 will
have a late penalty of 30 points.
No program may be turned in after 8am on Wednesday
April 8.
Remember: you are expected to do your own work on this assignment.
Last modified on March 5, 2015.
Comments and questions should be directed to
hatcher@unh.edu