class Variable: (source)
A collection of possible bindings for a variable, along with their origins. A variable stores the bindings it can have as well as the CFG nodes at which the bindings occur. The bindings are stored in a list for determinicity; new bindings should be added via AddBinding or (FilterAnd)PasteVariable rather than appended to bindings directly to ensure that bindings and _data_id_to_bindings are updated together. We do this rather than making _data_id_to_binding a collections.OrderedDict because a CFG can easily have tens of thousands of variables, and it takes about 40x as long to create an OrderedDict instance as to create a list and a dict, while adding a binding to the OrderedDict takes 2-3x as long as adding it to both the list and the dict.
Method | __init__ |
Initialize a new Variable. Called through Program.NewVariable. |
Method | __repr__ |
Undocumented |
Method |
|
Add another choice to this variable. |
Method |
|
Assign this variable to a new variable. |
Method |
|
Filters down the possibilities of bindings for this variable. |
Method |
|
Like Bindings(cfg_node), but only return the data. |
Method |
|
Filters down the possibilities of this variable. |
Method |
|
Like Filter(viewpoint), but only return the data. |
Method |
|
Adds a binding from another variable to this one. |
Method |
|
Adds all the bindings from another variable to this one. |
Method |
|
Undocumented |
Class Variable | __slots__ |
Undocumented |
Instance Variable | bindings |
Undocumented |
Instance Variable | id |
Undocumented |
Instance Variable | program |
Undocumented |
Property | data |
Undocumented |
Property | nodes |
Undocumented |
Method | _ |
Add a new binding if necessary, otherwise return existing binding. |
Instance Variable | _cfgnode |
Undocumented |
Instance Variable | _data |
Undocumented |
Add another choice to this variable. This will not overwrite this variable in the current CFG node. (It's legitimate to have multiple bindings for a variable on the same CFG node, e.g. if a union type is introduced at that node.) Arguments: data: A user specified object to uniquely identify this binding. source_set: An instance of SourceSet, i.e. a set of instances of Origin. where: Where in the CFG this variable was assigned to this binding. Returns: The new binding.
Assign this variable to a new variable. This is essentially a copy: All entries in the Union will be copied to the new variable, but with the corresponding current variable binding as an origin. Arguments: where: CFG node where the assignment happens. Returns: A new variable.
Filters down the possibilities of bindings for this variable. It determines this by analyzing the control flow graph. Any definition for this variable that is invisible from the current point in the CFG is filtered out. This function differs from Filter() in that it only honors the CFG, not the source sets. As such, it's much faster. Arguments: viewpoint: The CFG node at which to determine the possible bindings. strict: Whether to allow approximations for speed. Returns: A filtered list of bindings for this variable.
Filters down the possibilities of this variable. It analyzes the control flow graph. Any definition for this variable that is impossible at the current point in the CFG is filtered out. Arguments: viewpoint: The CFG node at which to determine the possible bindings. strict: Whether to allow approximations for speed. Returns: A filtered list of bindings for this variable.