General Information
Tutorials
Reference Manuals
Libraries
Translation Tasks
Tools
Administration
|
Type AnalysisProgram-Dependent Property ComputationThere are language constructs which need to set a property of an entity that depends on a property of another entity. If the order of accessing and setting the properties depends on the particular program, those operations can not be specified by dependent computations in trees, rather a program dependent mechanism is needed. An example for such a construct is a variable declaration of the form like a b;The variable b is declared to have the same type as the variable
a has. A program may have arbitrary long chains of such type references,
which may occur in any order.
This module provides a worklist algorithm to solve such problems:
Tree computations create worklist tasks, which try to access and set certain
properties as described by call-back functions, and store them on the worklist.
They are re-executed in sweeps through the worklist until no futher task
can be completed.
The module is instantiated by $/Type/PropertyWorklist.gnrc+instance=`prefix':instIf the instance parameter is given, the prefix is added to
every name exported by that instantiation, e.g. prefixTaskFct .
In the following we write *TaskFct to indicate that such a prefix will be
added to that name. Several instances of the module with different
prefixes may be used, if several worklists are needed,
The module provides the roles
The attribute
Each function used as a All these function declarations have the following signature: void WLCallBackSetType (PropertyTaskPtr this)In the body of the function the values of the four attributes, e.g. INH.*PropKeyA , can be accessed via the parameter,
e.g. this->PropKeyA . Furthermore, the coordinates of the
creation context are available by this->coord of type
CoordPtr .
In case of the above example with the DefTableKey tp = GetTypeOf (this->PropKeyB, NoKey); if (tp == NoKey) return; ResetTypeOf (this->PropKeyA, tp); this->done = 1; return;
Between the start of the worklist algorithm and its completion, no computations
in tree contexts are executed. Hence, there are only two ways to
propagate information from one worklist task to another: either via
setting and accessing properties of
This feature can be used to substitute the attribute value propagation between
related
The attribute PTRSELECT (THIS.*WLTask, done) <- INCLUDING *RootWorklist.*WLSolved
The accumulating attribute PropertyTaskPtr CreatePropertyTask (PropWLPtr wl, DefTableKey PropKeyA, DefTableKey PropKeyB, PropertyTaskPtr WLDepOnTaskA, PropertyTaskPtr WLDepOnTaskB, WLTaskFctType TaskFct, CoordPtr coord);The first parameter is the reference to the list of worklist tasks, it is obtained from the attribute INCLUDING *RootWorklist.*Worklist ; the meaning of the other
parameters can be deduced from their names.
It is possible and may be useful in certain cases to call
CreatePropertyTask from inside a worklist function;
then care must be taken to guarantee termination.
If the CreatePropertyTask is called in a C module,
PropertyWL.h is to be included.
|