Your FlowVal
class may contain any data necessary to represent the
flow values. It is common for flow values to consist of sets of objects in
the program (set of variables, set of definitions, set of expressions). Sets
can be represented directly using the STL set
container, or indirectly
using bit-sets. The former is more easily specified, while the latter is
significantly more efficient. For example, to store sets of variable
definitions, we have the following two choices:
// -- Represent the set directly... set< binaryNode * > _defs; // -- Represent the set indirectly... bitset<128> _def_bits;
The first option keeps the set of assignments explicitly. The second defines a bitset, where each bit stands for one of the assignments: if the bit is ``1'', then that particular assignment is in the set. To use bitsets, we need to remember how the objects in the set are mapped onto bits. There are many ways to do this, but one option is to define a map:
os_map< binaryNode *, unsigned int, less< binaryNode * > _defs_map;
To set a particular bit, we would use the following expression:
_def_bits.set(_defs_map[the_binary]);
When the analysis is complete, we also want to perform the reverse operation: look up the definitions that are given in the bitsets. This can be done by searching the map directly, or creating a separate map for the reverse mapping.
The rest of this document assumes a bitset representation. The bitset
class is defined in the standard template library.