Home | DMP | Project | Journal | Contact
Relevant Java Classes | Delete Call Site | Template Call Graph | Research | Final Report
Previous (Type Inference Algorithms and Call Graph Construction)
Next (Reaching Definitions)

In type inference, assignments are considered to be non-destructive. They do not overwrite the former type of the assigned variable; instead, types continue to accumulate in the variable's concrete type set. For example, if a variable x first holds integers, then boolean values, its type is {int, boolean}. Though x may hold both integer and boolean values, many reads (or accesses) of x retrieve only integers or only booleans. In response to this situation, writes Agesen, there are two basic type inference approaches:

1. Flow-insensitive
Types are assigned to variables. Variable accesses always have the same type as the variable being accessed. With this approach, all reads of our example variable x would have the type {int, boolean}.
2. Flow-sensitive
Types are assigned to variable accesses. Variable reads are not required to have the full type of the variable they access. The type of a specific access can be narrowed if the inferencer is able to determine that the access can only return objects of a subset of the types the variable may hold throughout the target program. Increased precision results; reads of x that always return integers would have the type {int}, while reads always retrieving booleans would have the type {boolean}.

The additional power provided by flow-sensitive systems can be vital when adding a type system to an existing body of code. The precision of type inference relates inversely to the relative number of templates; less precise types are more general (concrete types have higher cardinality), which in turn makes the Cartesian products larger, increasing the number of templates generated. There are several approaches to typing variable accesses, including static single assignment and the elimination of dead initializers, but the approach most relevant to the current research is the use of reaching definitions.




Home | DMP | Project | Journal | Contact
Relevant Java Classes | Delete Call Site | Template Call Graph | Research | Final Report
Previous (Type Inference Algorithms and Call Graph Construction)
Next (Reaching Definitions)

©2002, Katie Heise