Homework # 9
due December 5
Read the ``Inference Rules'' primer.
Read Section 1.5 (Abstract Interpretation) of the textbook.
Do the exercises in the ``Inference Rules'' primer.
Finish the work from lecture: write inference rules describing
inter-procedural effects analysis using judgments of
the following forms:
where
is a set of procedures currently being analyzed,
is a statement,
is a set of definitely written variables and
is a set of variables
that are read before being written. Recall that the middle relation
depend on the left relation, albeit with an empty
. You may use the
``uses'' relation without defining it.
The
set prevents infinite recursion in the analysis.
If a procedure call to a procedure already under analysis is
encountered,
then return the infinite set for must-write and the empty set
for may-read. Otherwise analyze the body
and be sure to mask out the locals and both kinds of formal parameters.
Implement inter-procedural definitely-assigned analysis using the
rules you developed:
- Define two recursive methods; one for each relation.
Each recursive method should use the VISITOR
design pattern to handle each syntactic case
and return a set of variables.
- Write a driver that uses these recursive methods to
determine whether
- every procedure or program correctly defines its results;
if not, then indicate the problems.
- some procedure body may read (directly or
indirectly through a procedure call) any local variable
or result before it has been assigned; list such
variables.
- the program main body may read any non-input variables before
they are set; list any such variables.
Your code should assume function calls are cheap: it should
NOT cache analysis results. Instead whenever it needs
analysis information, it should call one of the two recursive
methods. You may copy in the getUsed method from
the solution LiveVariableAnalysis.
Turn in your inference rules on paper, or send PDF by email to
boyouen.
Do all your programming work in a class CheckDefined in the
default package. Do not use any other classes other
than those in the sklnst.jar file. Send the source of this
class by email.
About this document
John Boyland
2006-12-12