Skip to content

Commit

Permalink
Fixed: array swap issue #5
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelmontenegro committed Sep 18, 2014
1 parent a68ada1 commit 4f19bb6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/de/wwu/muggl/instructions/general/Load.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import de.wwu.muggl.vm.execution.MugglToJavaConversion;
import de.wwu.muggl.vm.impl.symbolic.SymbolicExecutionException;
import de.wwu.muggl.vm.impl.symbolic.SymbolicVirtualMachine;
import de.wwu.muggl.vm.initialization.ModifieableArrayref;
import de.wwu.testtool.expressions.Variable;

/**
Expand Down Expand Up @@ -178,7 +179,12 @@ public void executeSymbolically(Frame frame, int localVariable) throws NoExcepti

// Generate an ArrayInitializationChoicePoint.
((SymbolicVirtualMachine) frame.getVm()).generateNewChoicePoint(this, null, null);
frame.getMethod().setGeneratedValue(localVariable, localVariables[localVariable]);

if (localVariables[localVariable] == null) {
frame.getMethod().setGeneratedValue(localVariable, null);
} else {
frame.getMethod().setGeneratedValue(localVariable, ((ModifieableArrayref)localVariables[localVariable]).clone());
}
} else {
// Create and push an non array type.
Variable variable = this.typedInstruction.getNewVariable(frame.getMethod(), localVariable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,11 @@ public synchronized void applyStateChanges() {
// Set or push?
if (this.index != -1) {
this.frame.setLocalVariable(this.index, this.preparedArray);
this.frame.getMethod().setGeneratedValue(this.index, this.preparedArray);
if (this.preparedArray == null) {
this.frame.getMethod().setGeneratedValue(this.index, null);
} else {
this.frame.getMethod().setGeneratedValue(this.index, this.preparedArray.clone());
}
} else {
// Push.
this.frame.getOperandStack().push(this.preparedArray);
Expand Down

0 comments on commit 4f19bb6

Please sign in to comment.