Skip to content

Commit d1009d0

Browse files
committed
more memo:
- add a link to the paper - explain the difference from the example in the paper - better display of `IsDefined`
1 parent beec39e commit d1009d0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

dataflow.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ show(io::IO, ::BotElement) = print(io, "⊥")
8484

8585
# Part 3: dataflow analysis
8686

87-
# Note: the paper uses U+1D56E MATHEMATICAL BOLD FRAKTUR CAPITAL C for this
88-
typealias AbstractValue Dict{Symbol,LatticeElement}
87+
# Note: the paper (https://api.semanticscholar.org/CorpusID:28519618) uses U+1D56E MATHEMATICAL BOLD FRAKTUR CAPITAL C for this
8988
const AbstractValue = Dict{Symbol,LatticeElement}
9089

9190
# Here we extend lattices of values to lattices of mappings of variables
@@ -98,6 +97,10 @@ const AbstractValue = Dict{Symbol,LatticeElement}
9897
<=(X::AbstractValue, Y::AbstractValue) = XY == X
9998
<(X::AbstractValue, Y::AbstractValue) = X<=Y && X!=Y
10099

100+
# Note: we solve an existential data-flow problem below, so:
101+
# - initialize states with `⊥` instead of `⊤`
102+
# - use `!<=` instead of `!<=` to check whether or not the instruction makes a change
103+
# - use `⊔` instead of `⊓` to update states
101104
function max_fixed_point(P::Program, a₁::AbstractValue, eval) where {Program<:AbstractVector{Stmt}}
102105
n = length(P)
103106
bot = AbstractValue( v =>for v in keys(a₁) )
@@ -146,6 +149,7 @@ end
146149
struct IsDefined <: LatticeElement
147150
is::Bool
148151
end
152+
show(io::IO, isdef::IsDefined) = print(io, isdef.is ? "defined" : "undefined")
149153

150154
const undef = IsDefined(false)
151155
const def = IsDefined(true)

0 commit comments

Comments
 (0)