Skip to content

Commit

Permalink
fixing post-event bug related to issue #58
Browse files Browse the repository at this point in the history
  • Loading branch information
miho committed Aug 20, 2015
1 parent 4a4e98e commit 57970e8
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import eu.mihosoft.vrl.lang.model.VisualCodeBuilder_Impl;
import eu.mihosoft.vrl.lang.model.WhileDeclaration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
Expand Down Expand Up @@ -418,10 +419,6 @@ private void instrumentNonLoopInvocation(ControlFlow cf, int i,
// variable
if (invocationTarget.isPresent()) {

if (invocationTarget.get().getMethodName().contains("return")) {
System.out.println("");
}

// search argument indices
int[] argumentsToReplace = invocationTarget.get().
getArguments().stream().
Expand All @@ -443,7 +440,6 @@ private void instrumentNonLoopInvocation(ControlFlow cf, int i,
// on the previously defined tmp variable that stores the return
// value of the current invocation
nextI.setObjectProvider(ObjectProvider.fromVariable(varName));
System.out.println("VARNAME: " + varName);
}

retValArg = Argument.varArg(result.getVariable(varName));
Expand All @@ -457,6 +453,18 @@ private void instrumentNonLoopInvocation(ControlFlow cf, int i,
resultInvs.add(VRLInstrumentationUtil.generatePostEvent(
cf, inv, retValArg));
}

// if the current invocation is a return,break or continue statement,
// we need to swap the statement invocation and
// the post event invocation since after the return statement no event
// can be generated.
if(inv instanceof ReturnStatementInvocation
|| inv instanceof ContinueInvocation
|| inv instanceof BreakInvocation) {
Collections.swap(resultInvs,
resultInvs.indexOf(inv),
resultInvs.indexOf(inv)+1);
}

if (inv instanceof ScopeInvocation) {
ScopeInvocation si = (ScopeInvocation) inv;
Expand Down

0 comments on commit 57970e8

Please sign in to comment.