Skip to content

Commit

Permalink
Fix copy in PDDL compiler.
Browse files Browse the repository at this point in the history
  • Loading branch information
ztangent committed May 9, 2024
1 parent 5af6fdd commit 6d8b655
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/compiler/state.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,19 @@ function generate_state_constructors(domain::Domain, state::State,
for (name, pred) in sortedpairs(get_predicates(domain))
name in keys(get_axioms(domain)) && continue # Skip derived predicates
push!(state_inits, generate_pred_init(domain, state, pred))
push!(state_copies, :(state.$name))
copy_expr = arity(pred) == 0 ? :(state.$name) : :(copy(state.$name))
push!(state_copies, copy_expr)
end
for (name, fn) in sortedpairs(get_functions(domain))
push!(state_inits, generate_func_init(domain, state, fn))
push!(state_copies,
:(isbits(state.$name) ? state.$name : copy(state.$name)))
if arity(pred) == 0
copy_expr = :(isbits(state.$name) ?
state.$name : copy(state.$name))
else
copy_expr = :(isbitstype(eltype(state.$name)) ?
copy(state.$name) : deepcopy(state.$name))
end
push!(state_copies, copy_expr)
end
state_constructor_defs = quote
$state_type() = $state_type($(state_inits...))
Expand Down

0 comments on commit 6d8b655

Please sign in to comment.