nitc :: ReachingDefsAnalysis :: kill
Kill a variable definition in thecurrent_outset
.
nitc $ ReachingDefsAnalysis :: FLOW
Type of FlowSet representation used by the StaticAnalysis.nitc $ ReachingDefsAnalysis :: SELF
Type of this instance, automatically specialized in every classnitc $ ReachingDefsAnalysis :: new_initial_flow
New initial flows are empty (conservative analysis).nitc $ ReachingDefsAnalysis :: new_initial_method_flow
New initial flows for methods contains the parameters.nitc $ ReachingDefsAnalysis :: pretty_print
Pretty print the outsets of this analysis.nitc $ ReachingDefsAnalysis :: visit
What the visitor do when a node is visitednitc :: StaticAnalysis :: FLOW
Type of FlowSet representation used by the StaticAnalysis.nitc :: StaticAnalysis :: _current_inset
"in" set for the currently visited node.nitc :: StaticAnalysis :: _current_outset
'out' set for the currently visited node.nitc :: StaticAnalysis :: _modelbuilder
ModelBuilder used to lookup AST nodes.core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitc :: StaticAnalysis :: current_inset
"in" set for the currently visited node.nitc :: StaticAnalysis :: current_inset=
"in" set for the currently visited node.nitc :: Visitor :: current_node=
The current visited nodenitc :: StaticAnalysis :: current_outset
'out' set for the currently visited node.nitc :: StaticAnalysis :: current_outset=
'out' set for the currently visited node.nitc :: Visitor :: defaultinit
core :: Object :: defaultinit
nitc :: ForwardAnalysis :: defaultinit
nitc :: StaticAnalysis :: defaultinit
nitc :: Visitor :: enter_visit
Ask the visitor to visit a given node.core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
nitc :: ReachingDefsAnalysis :: kill
Kill a variable definition in thecurrent_outset
.
nitc :: StaticAnalysis :: modelbuilder
ModelBuilder used to lookup AST nodes.nitc :: StaticAnalysis :: modelbuilder=
ModelBuilder used to lookup AST nodes.core :: Object :: native_class_name
The class name of the object in CString format.nitc :: StaticAnalysis :: new_initial_flow
Initial flow set to use.nitc :: StaticAnalysis :: new_initial_method_flow
Initial flow set to use within methods.core :: Object :: output_class_name
Display class name on stdout (debug only).nitc :: StaticAnalysis :: pretty_print
Pretty print the outsets of this analysis.
# Determines wich variables definitions reach each statement.
class ReachingDefsAnalysis
super ForwardAnalysis
redef type FLOW: FlowHashSet[VarDef]
# New initial flows are empty (conservative analysis).
redef fun new_initial_flow do return new FlowHashSet[VarDef]
# New initial flows for methods contains the parameters.
redef fun new_initial_method_flow(n) do
var flow = new_initial_flow
var n_signature = n.n_signature
if n_signature == null then return flow
for n_param in n_signature.n_params do
var variable = n_param.variable
if variable == null then continue
flow.add(new VarDef(variable, n_param.location))
end
return flow
end
# Perform set union (used for **some path** analysis).
redef fun merge(s1, s2) do return s1.flow_union(s2)
redef fun visit(n) do n.accept_reaching_defs(self)
# Generate a new variable definition in the `current_outset`.
fun gen(variable: Variable, location: Location) do
current_outset.add(new VarDef(variable, location))
end
# Kill a variable definition in the `current_outset`.
fun kill(variable: Variable) do
for vardef in current_outset.to_a do
if vardef.variable == variable then current_outset.remove(vardef)
end
end
redef fun pretty_print do
for node, outset in outsets do
if outset.is_empty then continue
var values = outset.to_a
default_comparator.sort(values)
print "{node.location.line_end}: {values.join(", ")} out of {node.class_name}"
end
end
end
src/saf/reaching_defs.nit:20,1--67,3