Skip to content

Commit

Permalink
more memo:
Browse files Browse the repository at this point in the history
- add a link to the paper
- explain the difference from the example in the paper
- better display of `IsDefined`
  • Loading branch information
aviatesk committed Oct 16, 2020
1 parent beec39e commit d1009d0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions dataflow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ show(io::IO, ::BotElement) = print(io, "⊥")

# Part 3: dataflow analysis

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

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

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

const undef = IsDefined(false)
const def = IsDefined(true)
Expand Down

0 comments on commit d1009d0

Please sign in to comment.