Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: preface to allow closures #940

Closed
wants to merge 2 commits into from
Closed
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
22 changes: 13 additions & 9 deletions src/build_function.jl
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ function _build_function(target::JuliaTarget, rhss::AbstractArray, args...;
checkbounds = false,
postprocess_fbody=ex -> ex,
linenumbers = false,
preface = [],
outputidxs=nothing,
skipzeros = false,
force_SA = false,
Expand All @@ -272,8 +273,11 @@ function _build_function(target::JuliaTarget, rhss::AbstractArray, args...;
similarto = force_SA ? SArray : i === nothing ? Array : dargs[i].name

oop, iip = iip_config
closed_args = unique!(vcat(dargs, [a.lhs for a in preface]))
prepend_preface(x) = Let(preface, x, false)
postprocess = postprocess_fbody ∘ prepend_preface
oop_body = if oop
postprocess_fbody(make_array(parallel, dargs, rhss, similarto, cse))
postprocess(make_array(parallel, closed_args, rhss, similarto, cse))
else
term(throw_missing_specialization, length(dargs))
end
Expand All @@ -285,14 +289,14 @@ function _build_function(target::JuliaTarget, rhss::AbstractArray, args...;

out = Sym{Any}(:ˍ₋out)
ip_body = if iip
postprocess_fbody(set_array(parallel,
dargs,
out,
outputidxs,
rhss,
checkbounds,
skipzeros,
cse,))
postprocess(set_array(parallel,
closed_args,
out,
outputidxs,
rhss,
checkbounds,
skipzeros,
cse,))
else
term(throw_missing_specialization, length(dargs) + 1)
end
Expand Down