Closed phipsgabler closed 5 years ago
There should be an equivalent to the method of IR, pushing a statement at the front of the pipe. Currently I use
function pushfirst!(p::IRTools.Pipe, x) first_v, first_stmt = first(p) IRTools.insert!(p, first_v, x) end
Is the following modification of push! correct, or is there even something simpler?
push!
function pushfirst!(p::IRTools.Pipe, x) tmp = IRTools.var!(p) IRTools.substitute!(p, tmp, IRTools.pushfirst!(p.to, prewalk(IRTools.substitute(p), x))) return tmp end
Note that this wouldn't be more efficient on pipes, but it doesn't do any harm to add it. That looks right to me so would be great to have as a PR.
There should be an equivalent to the method of IR, pushing a statement at the front of the pipe. Currently I use
Is the following modification of
push!
correct, or is there even something simpler?