Skip to content

Commit

Permalink
Don't use write and copy method names in injective
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoct committed Sep 15, 2018
1 parent 0a2b9c5 commit 97d2efd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/injective.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ macro inj(ast)
end

macro write(value, addr)
Expr(:call, :write, esc(state), esc(value), esc(addr))
Expr(:call, :write_to_addr, esc(state), esc(value), esc(addr))
end

macro copy(input_addr, output_addr)
Expr(:call, :copy, esc(state), esc(input_addr), esc(output_addr))
Expr(:call, :copy_addr, esc(state), esc(input_addr), esc(output_addr))
end

macro swap(value, input_addr, output_addr)
Expand Down Expand Up @@ -97,21 +97,21 @@ function read(state::InjectiveApplyState, addr)
end
end

function write(state::InjectiveApplyState, value, addr)
function write_to_addr(state::InjectiveApplyState, value, addr)
visit!(state.visitor, addr)
set_leaf_node!(state.output, addr, value)
nothing
end

function write(state::InjectiveApplyState, tracked_value::TrackedReal, addr)
function write_to_addr(state::InjectiveApplyState, tracked_value::TrackedReal, addr)
visit!(state.visitor, addr)
# TODO what if user tries to write same tracked value to two diff addrs?
set_leaf_node!(state.tracked_writes, addr, tracked_value)
set_leaf_node!(state.output, addr, ReverseDiff.value(tracked_value))
nothing
end

function copy(state::InjectiveApplyState, input_addr, output_addr)
function copy_addr(state::InjectiveApplyState, input_addr, output_addr)
visit!(state.visitor, output_addr)
if !has_leaf_node(state.input, input_addr)
error("Value at $input_addr not found in input ($(state.input))")
Expand Down

0 comments on commit 97d2efd

Please sign in to comment.