Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/JuliaVariables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ end

SymRef(sym::Symbol, ana::Union{Nothing, Analyzer}) = SymRef(sym, ana, false)

struct Var
struct Var{ID}
name::Symbol
unique_id:: Union{Ref{Bool}, Nothing} # nothing when it's a global variable
unique_id:: ID # nothing when it's a global variable
is_mutable::Bool
is_shared::Bool
is_global::Bool
Expand Down Expand Up @@ -130,7 +130,7 @@ satifies following conditions:
- No macros included in the expression, as we don't know how much a macro
could change the code.
"""
function solve!(ast; toplevel=true)
function solve!(id_function, ast; toplevel=true)
S = Ref(State(top_analyzer(), C_LEXICAL, Set{Symbol}()))
ScopeInfo = IdDict{Expr,Any}()
PHYSICAL = true
Expand Down Expand Up @@ -444,7 +444,7 @@ function solve!(ast; toplevel=true)
end

function local_var_to_var(var::LocalVar)::Var
unique_id = var.is_shared
unique_id = id_function(var.is_shared, var.sym)
Var(var.sym, unique_id, var.is_mutable[], var.is_shared[], false)
end

Expand Down Expand Up @@ -508,6 +508,10 @@ function solve!(ast; toplevel=true)
transform(ast)
end # module struct

solve!(ast; toplevel=true) = solve!((a, _) -> a, ast; toplevel=toplevel)

solve_from_local!(id_function, @nospecialize(ex)) = solve!(id_function, ex; toplevel=false)

solve_from_local!(@nospecialize(ex)) = solve!(ex; toplevel=false)

_depwarn(sym) = Base.depwarn(
Expand Down