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
  • Loading branch information
JeffBezanson committed Mar 6, 2016
1 parent 2119e87 commit fc28900
Show file tree
Hide file tree
Showing 18 changed files with 401 additions and 405 deletions.
16 changes: 11 additions & 5 deletions base/expr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,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 @@ -157,23 +157,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 fc28900

Please sign in to comment.