CSE 401, Winter 2014

Robert R. Henry

Assignment 7

Type Checking

Due via dropbox Monday February 24 by the end of the day (midnight).

Goals

By the end of this assignment you will be able to type check your program, check the consistency of identifier declarations and uses for all types of identifiers, and check that each part of an expression and the statements are all type correct. You will also check the semantics of method override.

Checking Type Information

  1. By now you have, somehow, handles from identifier names to the class names and declarations as well as method names and declarations.
  2. Crawl the AST to do type checking on class method declarations (for overrides); operators (basically, every node in an expression tree); and statements.  Type checking is essentially compile time constant folding on a different algebraic domain, namely the domain of types, with their rules for compatibility.
  3. Annotate each AST node with the reference into the type graph for the operand types that node takes, and the operand type it yields.  This may make some steps that follow in the weeks to come easier to do.
  4. Issue plausible helpful error messages for the semantic faults you find.  You may stop on the first detected failure.

What should work

  1. You should be able to scan, parse and semantic analyze “error free” all of the “correct” test programs you wrote.
  2. All of the test programs you wrote that should trigger compile time errors should now do so.  You may have to rewrite some of your tests based on what you’ve learned in the previous weeks.
  3. In addition, all of the supplied test programs should analyze without problems.
  4. You may want to disable code generation, since the minimal code generator you wrote a few weeks ago may break under the strain of variables and fields.

What to turn in

  1. Turn in output that convinces us that your test programs that are supposed to find semantic errors do indeed find and report plausible errors.
  2. Include a main method somewhere that can:
  1. Turn in via dropbox a tar file of your entire project subdirectory.