Skip to content

Commit

Permalink
move var metadata from LambdaInfo.ast to fields of LambdaInfo
Browse files Browse the repository at this point in the history
LambdaInfo.ast is now LambdaInfo.code, and is just an array of
statements

store LambdaInfo objects in the tfunc cache, instead of just ASTs

now type inference operates on InferenceState.linfo in place, and
eventually copies the results to InferenceState.destination if
necessary.
  • Loading branch information
JeffBezanson committed Mar 24, 2016
1 parent ab5c34e commit 1bc0168
Show file tree
Hide file tree
Showing 25 changed files with 608 additions and 517 deletions.
16 changes: 11 additions & 5 deletions base/expr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ end

function popmeta!(body::Expr, sym::Symbol)
body.head == :block || return false, []
found, metaex = findmeta_block(body)
found, metaex = findmeta_block(body.args)
if !found
return false, []
end
Expand All @@ -151,23 +151,29 @@ function popmeta!(body::Expr, sym::Symbol)
false, []
end
popmeta!(arg, sym) = (false, [])
function popmeta!(body::Array{Any,1}, sym::Symbol)
ex = Expr(:block); ex.args = body
popmeta!(ex, sym)
end

function findmeta(ex::Expr)
if ex.head == :function || (ex.head == :(=) && typeof(ex.args[1]) == Expr && ex.args[1].head == :call)
body::Expr = ex.args[2]
body.head == :block || error(body, " is not a block expression")
return findmeta_block(ex)
return findmeta_block(ex.args)
end
error(ex, " is not a function expression")
end

function findmeta_block(ex::Expr)
for a in ex.args
findmeta(ex::Array{Any,1}) = findmeta_block(ex)

function findmeta_block(exargs)
for a in exargs
if isa(a, Expr)
if (a::Expr).head == :meta
return true, a::Expr
elseif (a::Expr).head == :block
found, exb = findmeta_block(a)
found, exb = findmeta_block(a.args)
if found
return found, exb
end
Expand Down
Loading

0 comments on commit 1bc0168

Please sign in to comment.