Commit cba9b86d authored by Martin Spoto's avatar Martin Spoto
Browse files

Fix reexecute of built-ins while redoing

parent 66cdf43f
......@@ -49,16 +49,16 @@ public class ProloGraalProofTreeNode extends Node {
// filter clauses that are unifiable with the current goal
List<ProloGraalClause> unifiableClauses =
IntStream.range(0, possibleClauses.size())
.filter(x -> {
ProloGraalClause clause = possibleClauses.get(x).copy();
currentGoal.save();
boolean r = clause.getHead().unify(currentGoal);
currentGoal.undo();
return r;
})
.mapToObj(x -> possibleClauses.get(x).copy())
.collect(Collectors.toList());
IntStream.range(0, possibleClauses.size())
.filter(x -> {
ProloGraalClause clause = possibleClauses.get(x).copy();
currentGoal.save();
boolean r = clause.getHead().unify(currentGoal);
currentGoal.undo();
return r;
})
.mapToObj(x -> possibleClauses.get(x).copy())
.collect(Collectors.toList());
for (int i = start; i < unifiableClauses.size(); i++) {
ProloGraalClause unifiableClause = unifiableClauses.get(i);
......@@ -71,9 +71,11 @@ public class ProloGraalProofTreeNode extends Node {
System.out.println("Unified " + currentGoal + " with " + unifiableClause.getHead());
}
if (unifiableClause instanceof ProloGraalBultinClause) {
// if the clause is a built-in, execute its internal behaviour
((ProloGraalBultinClause) unifiableClause).execute();
if (branches.isEmpty()) {
if (unifiableClause instanceof ProloGraalBultinClause) {
// if the clause is a built-in, execute its internal behaviour
((ProloGraalBultinClause) unifiableClause).execute();
}
}
// create a copy of the current goals
......
......@@ -9,4 +9,8 @@ redo.
redo.
redo.
testWrite.
redo.
\ No newline at end of file
redo.
go.
redo.
redo.
redo.
......@@ -32,5 +32,14 @@ yes
% redo.
d
yes
% go.
10
yes
% redo.
yes
% redo.
yes
% redo.
no
% EOF
yes
\ No newline at end of file
......@@ -16,4 +16,12 @@ t(b).
t(c).
t(d).
end(c).
end(d).
\ No newline at end of file
end(d).
go :-
write(10),
a.
a.
a.
a.
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment