nitc :: FlowContext :: defaultinit
# A Node in the static flow graph.
# A same `FlowContext` can be shared by more than one `ANode`.
class FlowContext
# The reachable previous flow
var previous = new Array[FlowContext]
# Additional reachable flow that loop up to self.
# Loops appears in `loop`, `while`, `for`, and with `continue`
var loops = new Array[FlowContext]
private var is_marked_unreachable: Bool = false
# Is the flow dead?
fun is_unreachable: Bool
do
# Are we explicitly marked unreachable?
if self.is_marked_unreachable then return true
# Are we the starting flow context?
if is_start then return false
# De we have a reachable previous?
if previous.length == 0 then return true
return false
end
# Flag to avoid repeated errors
var is_already_unreachable: Bool = false
# Mark that self is the starting flow context.
# Such a context is reachable even if there is no previous flow
var is_start: Bool = false
# The node that introduce the flow (for debugging)
var node: nullable ANode = null
# Additional information for the flow (for debugging)
var name: String = ""
# The sub-flow to use if the associated expr is true
var when_true: FlowContext = self
# The sub-flow to use if the associated expr is true
var when_false: FlowContext = self
# Add a previous flow (iff it is reachable)
private fun add_previous(flow: FlowContext)
do
if not flow.is_unreachable and not previous.has(flow) then
previous.add(flow)
end
end
# Add a previous loop flow (iff it is reachable)
private fun add_loop(flow: FlowContext)
do
if not flow.is_unreachable and not previous.has(flow) then
loops.add(flow)
end
end
end
src/semantize/flow.nit:186,1--247,3