nitc :: LocalVarInitVisitor :: _maybe_unset_vars
Local variables that are possibly unset (ie local variable without an initial value)nitc :: LocalVarInitVisitor :: maybe_unset_vars
Local variables that are possibly unset (ie local variable without an initial value)nitc :: LocalVarInitVisitor :: maybe_unset_vars=
Local variables that are possibly unset (ie local variable without an initial value)nitc $ LocalVarInitVisitor :: SELF
Type of this instance, automatically specialized in every classnitc $ LocalVarInitVisitor :: visit
What the visitor do when a node is visitednitc :: LocalVarInitVisitor :: _maybe_unset_vars
Local variables that are possibly unset (ie local variable without an initial value)core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitc :: Visitor :: current_node=
The current visited nodecore :: Object :: defaultinit
nitc :: Visitor :: 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 :: LocalVarInitVisitor :: maybe_unset_vars
Local variables that are possibly unset (ie local variable without an initial value)nitc :: LocalVarInitVisitor :: maybe_unset_vars=
Local variables that are possibly unset (ie local variable without an initial value)core :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).
private class LocalVarInitVisitor
super Visitor
var toolcontext: ToolContext
# Local variables that are possibly unset (ie local variable without an initial value)
var maybe_unset_vars: Set[Variable] = new HashSet[Variable]
fun mark_is_unset(node: AExpr, variable: nullable Variable)
do
assert variable != null
self.maybe_unset_vars.add(variable)
end
fun mark_is_set(node: AExpr, variable: nullable Variable)
do
assert variable != null
if not maybe_unset_vars.has(variable) then return
var flow = node.after_flow_context.as(not null)
flow.set_vars.add(variable)
end
fun check_is_set(node: AExpr, variable: nullable Variable)
do
assert variable != null
if not maybe_unset_vars.has(variable) then return
var flow = node.after_flow_context.as(not null)
if not flow.is_variable_set(variable) then
self.toolcontext.error(node.hot_location, "Error: possibly unset variable `{variable}`.")
# Remove the variable to avoid repeating errors
self.maybe_unset_vars.remove(variable)
end
end
redef fun visit(n)
do
n.accept_local_var_visitor(self)
end
end
src/semantize/local_var_init.nit:43,1--83,3