29
29
import eu .mihosoft .vrl .lang .model .VisualCodeBuilder_Impl ;
30
30
import eu .mihosoft .vrl .lang .model .WhileDeclaration ;
31
31
import java .util .ArrayList ;
32
+ import java .util .Collections ;
32
33
import java .util .List ;
33
34
import java .util .Objects ;
34
35
import java .util .Optional ;
@@ -418,10 +419,6 @@ private void instrumentNonLoopInvocation(ControlFlow cf, int i,
418
419
// variable
419
420
if (invocationTarget .isPresent ()) {
420
421
421
- if (invocationTarget .get ().getMethodName ().contains ("return" )) {
422
- System .out .println ("" );
423
- }
424
-
425
422
// search argument indices
426
423
int [] argumentsToReplace = invocationTarget .get ().
427
424
getArguments ().stream ().
@@ -443,7 +440,6 @@ private void instrumentNonLoopInvocation(ControlFlow cf, int i,
443
440
// on the previously defined tmp variable that stores the return
444
441
// value of the current invocation
445
442
nextI .setObjectProvider (ObjectProvider .fromVariable (varName ));
446
- System .out .println ("VARNAME: " + varName );
447
443
}
448
444
449
445
retValArg = Argument .varArg (result .getVariable (varName ));
@@ -457,6 +453,18 @@ private void instrumentNonLoopInvocation(ControlFlow cf, int i,
457
453
resultInvs .add (VRLInstrumentationUtil .generatePostEvent (
458
454
cf , inv , retValArg ));
459
455
}
456
+
457
+ // if the current invocation is a return,break or continue statement,
458
+ // we need to swap the statement invocation and
459
+ // the post event invocation since after the return statement no event
460
+ // can be generated.
461
+ if (inv instanceof ReturnStatementInvocation
462
+ || inv instanceof ContinueInvocation
463
+ || inv instanceof BreakInvocation ) {
464
+ Collections .swap (resultInvs ,
465
+ resultInvs .indexOf (inv ),
466
+ resultInvs .indexOf (inv )+1 );
467
+ }
460
468
461
469
if (inv instanceof ScopeInvocation ) {
462
470
ScopeInvocation si = (ScopeInvocation ) inv ;
0 commit comments