Skip to content

Commit 178edc0

Browse files
author
KDr2
committed
bugfix
1 parent cc79a38 commit 178edc0

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/tapedfunction.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function reset!(tf::TapedFunction, ir::IRTools.IR, tape::RawTape)
7979
tf.tape = tape
8080
blk_map = Dict{Int, Int}()
8181

82-
for (i, ins) in tf.tape
82+
for (i, ins) in enumerate(tf.tape)
8383
isa(ins, BlockInstruction) || continue
8484
blk_map[ins.id] = i
8585
end
@@ -159,7 +159,8 @@ end
159159
function (instr::Instruction{F})() where F
160160
# catch run-time exceptions / errors.
161161
try
162-
output = instr.func(map(val, instr.input)...)
162+
func = val(instr.func)
163+
output = func(map(val, instr.input)...)
163164
instr.output.val = output
164165
instr.tape.counter += 1
165166
catch e
@@ -225,7 +226,7 @@ end
225226

226227
function translate!(taped::Taped, ir::IRTools.IR)
227228
tape = taped.tape
228-
boxes = Dict{Any, Box{Any}}()
229+
boxes = Dict{IRTools.Variable, Box{Any}}()
229230
_box = (x) -> arg_boxer(x, boxes)
230231
for (blk_id, blk) in enumerate(IRTools.blocks(ir))
231232
# blocks

src/tapedtask.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,12 @@ end
201201
copy_box(o, roster::Dict{UInt64, Any}) = o
202202

203203
function Base.copy(x::Instruction, on_tape::Taped, roster::Dict{UInt64, Any})
204+
func = copy_box(x.func, roster)
204205
input = map(x.input) do ob
205206
copy_box(ob, roster)
206207
end
207208
output = copy_box(x.output, roster)
208-
Instruction(x.func, input, output, on_tape)
209+
Instruction(func, input, output, on_tape)
209210
end
210211

211212
function Base.copy(x::BlockInstruction, on_tape::Taped, roster::Dict{UInt64, Any})
@@ -235,6 +236,10 @@ function Base.copy(old_data::RawTape, on_tape::Taped, roster::Dict{UInt64, Any})
235236
new_ins = copy(x, on_tape, roster)
236237
new_data[i] = new_ins
237238
end
239+
240+
init_ins = Instruction(args_initializer(new_data[2]), (),
241+
Box{Any}(nothing), on_tape)
242+
new_data[1] = init_ins
238243
return new_data
239244
end
240245

0 commit comments

Comments
 (0)