Skip to content

Commit

Permalink
Merge pull request #227 from kennytm/top-level-pack-with-repl
Browse files Browse the repository at this point in the history
Fix bug with PackWithReplacements when replacing top-level object with complex values.
  • Loading branch information
sjrd committed Sep 26, 2014
2 parents bdeaf6c + 6a3936f commit 76914ec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
12 changes: 11 additions & 1 deletion platform-test/base/pickle.oz
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import
%BootPickle(pack:Pack unpack:Unpack) at 'x-oz://boot/Pickle'
Pickle(pack:Pack unpack:Unpack packWithReplacements:PackWithReplacements)
BootName(newUnique:NewUniqueName newNamed:NewNamedName) at 'x-oz://boot/Name'
System
export
Return
define
Expand Down Expand Up @@ -140,5 +139,16 @@ define
true = (A \= B)
end
)

packWithReplacementsTopLevel(
proc {$}
A = {NewCell 1}
VBS = {PackWithReplacements A [A#(a(b))]}
U = {Unpack VBS}
in
true = {IsCell A}
U = a(b)
end
)
])
end
9 changes: 5 additions & 4 deletions vm/vm/main/pickler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ void Pickler::pickle(RichNode value, RichNode temporaryReplacement) {
auto typesRecord = RichNode(*vm->getPickleTypesRecord()).as<Record>();
auto statelessTypes = RichNode(*typesRecord.getArity()).as<Arity>();

SerializationCallback cb(vm);
UnstableNode topLevelIndex = OptVar::build(vm);
cb.copy(topLevelIndex, value);

bool futures = false;
nativeint count = 0;
VMAllocatedList<NodeBackup> nodeBackups;
Expand All @@ -104,10 +100,15 @@ void Pickler::pickle(RichNode value, RichNode temporaryReplacement) {
nodeReplacementBackups.push_front(vm, replacement.first.makeBackup());
replacement.first.reinit(vm, replacement.second);
}
value.update();

replacements.clear(vm);
}

SerializationCallback cb(vm);
UnstableNode topLevelIndex = OptVar::build(vm);
cb.copy(topLevelIndex, value);

// Replace serialized nodes by Serialized(index)
// and add them to the nodes list
while (!cb.todoFrom.empty()) {
Expand Down

0 comments on commit 76914ec

Please sign in to comment.