diff --git a/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/Argument.java b/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/Argument.java index 3bb3f86b..ece277fd 100644 --- a/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/Argument.java +++ b/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/Argument.java @@ -85,7 +85,8 @@ public IType getType() { @Override public String toString() { - return "[Argument: argType=" + getArgType() + ", type=" + getType() + "]"; + String valueString = ", val='"+getConstant().orElse("?").toString()+"'"; + return "[Argument: argType=" + getArgType() + ", type=" + getType() + valueString + "]"; } } diff --git a/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/BinaryOperatorInvocationImpl.java b/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/BinaryOperatorInvocationImpl.java index b902f299..56d023e2 100644 --- a/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/BinaryOperatorInvocationImpl.java +++ b/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/BinaryOperatorInvocationImpl.java @@ -69,6 +69,7 @@ public static boolean booleanOperator(Operator operator) { || operator == Operator.NOT_EQUALS || operator == Operator.LESS_EQUALS || operator == Operator.GREATER_EQUALS + || operator == Operator.GREATER || operator == Operator.LESS || operator == Operator.GREATER_EQUALS || operator == Operator.OR diff --git a/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/ControlFlow.java b/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/ControlFlow.java index d6a34b25..272f8c25 100644 --- a/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/ControlFlow.java +++ b/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/ControlFlow.java @@ -51,6 +51,7 @@ package eu.mihosoft.vrl.lang.model; import java.util.List; +import java.util.Optional; /** * @@ -77,6 +78,7 @@ public interface ControlFlow { public List getInvocations(); public boolean isUsedAsInput(Invocation invocation); + public Optional returnInvTargetIfPresent(Invocation invocation); public BinaryOperatorInvocation invokeOperator(String id, IArgument leftArg, IArgument rightArg, Operator operator); diff --git a/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/ControlFlowImpl.java b/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/ControlFlowImpl.java index 80ba5ba2..d00288a8 100644 --- a/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/ControlFlowImpl.java +++ b/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/ControlFlowImpl.java @@ -55,6 +55,8 @@ import eu.mihosoft.vrl.workflow.WorkflowUtil; import java.util.ArrayList; import java.util.List; +import java.util.Optional; +import javafx.beans.Observable; import javafx.collections.FXCollections; import javafx.collections.ListChangeListener; import javafx.collections.ObservableList; @@ -81,20 +83,25 @@ public ControlFlowImpl(Scope parent) { } private void initListeners() { - invocations.addListener((ListChangeListener.Change c) -> { -// while(c.next()) { -// if (c.wasAdded()) { -// // -// } -// ... TODO -// -// } - + invocations.addListener((Observable observable) -> { if (!currentlyUpdatingInvocations) { updateConnections(); + // update invocation parent; + for (Invocation invocation : invocations) { + ((InvocationImpl) invocation).setParent(getParent()); + } } - }); +// invocations.addListener((ListChangeListener.Change c) -> { +// while (c.next()) { +// if (c.wasAdded()) { +// c.getAddedSubList().stream().forEach((inv) -> { +// System.out.println("inv-add: " + inv); +// ((InvocationImpl) inv).setParent(getParent()); +// }); +// } +// } +// }); flow.getConnections(WorkflowUtil.CONTROL_FLOW).getConnections().addListener( new ListChangeListener() { @@ -124,7 +131,6 @@ private void updateConnections() { flow.getConnections(WorkflowUtil.CONTROL_FLOW).getConnections().clear(); Invocation prevInvocation = null; for (Invocation invocation : invocations) { - if (prevInvocation != null) { flow.connect(prevInvocation.getNode(), invocation.getNode(), WorkflowUtil.CONTROL_FLOW); @@ -254,6 +260,12 @@ public Invocation callMethod(String id, String varName, @Override public boolean isUsedAsInput(Invocation invocation) { + return returnInvTargetIfPresent(invocation).isPresent(); + } + + @Override + public Optional returnInvTargetIfPresent(Invocation invocation) { + for (Invocation inv : invocations) { if (inv instanceof ScopeInvocation) { @@ -261,7 +273,7 @@ public boolean isUsedAsInput(Invocation invocation) { if (sInv.getScope() instanceof WhileDeclaration) { WhileDeclaration whileD = (WhileDeclaration) sInv.getScope(); if (invocation == whileD.getCheck()) { - return true; + return Optional.of(inv); } } } @@ -270,13 +282,13 @@ public boolean isUsedAsInput(Invocation invocation) { if (arg.getArgType() == ArgumentType.INVOCATION) { if (arg.getInvocation().get().equals(invocation)) { - return true; + return Optional.of(inv); } } } } - return false; + return Optional.empty(); } @Override diff --git a/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/InvocationImpl.java b/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/InvocationImpl.java index 14bbdd43..0c144f90 100644 --- a/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/InvocationImpl.java +++ b/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/InvocationImpl.java @@ -74,7 +74,7 @@ class InvocationImpl implements Invocation { private final boolean constructor; private boolean Void; // private String code; - private final Scope parent; + private Scope parent; private boolean Static; private ICodeRange location; private IType returnType; @@ -105,11 +105,11 @@ public InvocationImpl( // } else { // returnValue = parent.createVariable(this); // } - init(varName); + init(varName, parent); } - private void init(String varName) { + private void init(String varName, Scope oldParent) { if (varName != null && !varName.isEmpty()) { Variable var = null; @@ -134,7 +134,10 @@ private void init(String varName) { if (isScope()) { // nothing (see ScopeInvocationImpl) } else { - if (node == null) { + if (node == null || parent != oldParent) { + if (node != null) { + oldParent.getFlow().remove(node); + } node = parent.getFlow().newNode(); } else { List delList = new ArrayList<>(); @@ -419,7 +422,15 @@ public void setTextRenderingEnabled(boolean textRenderingEnabled) { @Override public void setVariableName(String variableName) { this.varName = variableName; - init(varName); + init(varName, parent); + } + + void setParent(Scope parent) { + Scope oldParent = this.parent; + this.parent = parent; + if (parent != oldParent) { + init(varName, oldParent); + } } } diff --git a/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/transform/CodeTransform.java b/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/transform/CodeTransform.java index ef8b812a..e1fbe09d 100644 --- a/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/transform/CodeTransform.java +++ b/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/transform/CodeTransform.java @@ -13,5 +13,5 @@ */ @FunctionalInterface public interface CodeTransform { - public T transform(T ce); + public T transform(T ce, String indent); } diff --git a/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/transform/InstrumentCode.java b/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/transform/InstrumentCode.java index 64ee6593..b0f2464d 100644 --- a/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/transform/InstrumentCode.java +++ b/VRL/VRL-Lang/src/main/java/eu/mihosoft/vrl/lang/model/transform/InstrumentCode.java @@ -11,15 +11,21 @@ import eu.mihosoft.vrl.lang.model.ControlFlow; import eu.mihosoft.vrl.lang.model.ControlFlowScope; import eu.mihosoft.vrl.lang.model.IArgument; +import eu.mihosoft.vrl.lang.model.IfDeclaration; import eu.mihosoft.vrl.lang.model.Invocation; import eu.mihosoft.vrl.lang.model.MethodDeclaration; import eu.mihosoft.vrl.lang.model.Operator; +import eu.mihosoft.vrl.lang.model.Scope; import eu.mihosoft.vrl.lang.model.ScopeInvocation; import eu.mihosoft.vrl.lang.model.Type; import eu.mihosoft.vrl.lang.model.Variable; +import eu.mihosoft.vrl.lang.model.VisualCodeBuilder; +import eu.mihosoft.vrl.lang.model.VisualCodeBuilder_Impl; +import eu.mihosoft.vrl.lang.model.WhileDeclaration; import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.Optional; /** * @@ -28,7 +34,7 @@ public class InstrumentCode implements CodeTransform { @Override - public CompilationUnitDeclaration transform(CompilationUnitDeclaration cu) { + public CompilationUnitDeclaration transform(CompilationUnitDeclaration cu, String indent) { // TODO 01.08.2015 add clone() CompilationUnitDeclaration result = cu; @@ -38,7 +44,7 @@ public CompilationUnitDeclaration transform(CompilationUnitDeclaration cu) { for (ClassDeclaration cd : result.getDeclaredClasses()) { List methods = new ArrayList<>(); for (MethodDeclaration md : cd.getDeclaredMethods()) { - methods.add((MethodDeclaration) im.transform(md)); + methods.add((MethodDeclaration) im.transform(md, indent)); } cd.getDeclaredMethods().clear(); cd.getDeclaredMethods().addAll(methods); @@ -56,8 +62,125 @@ private String newVarName() { return "__vrl_reserved_intermediate_var_" + ++varNameCounter; } + private boolean isWhileLoop(Invocation inv) { + + if (inv.isScope()) { + ScopeInvocation si = (ScopeInvocation) inv; + return si.getScope() instanceof WhileDeclaration; + } + + return false; + } + + private List getInvAndConnectedInvs(ControlFlow cf, + List invocations, Invocation inv) { + List result = new ArrayList<>(); + + int invIndex = invocations.indexOf(inv); + +// System.out.println("---->"); +// System.out.println("-> inv: " + inv); +// System.out.println(" -> #inv: " + invocations.size()); + for (Invocation pInv : invocations) { +// System.out.println(" -> sw: " + pInv); + } + + for (int i = invIndex + 1; i < invocations.size(); i++) { + + Invocation nextInv = invocations.get(i); + + if (cf.isUsedAsInput(inv) + || isRetValObjectOfNextInv(nextInv)) { + result.add(inv); + if (i == invocations.size() - 1) { + result.add(nextInv); + } + } else { + result.add(inv); + break; + } + inv = nextInv; + } + +// for (Invocation pInv : result) { +// System.out.println(" -> ci: " + pInv); +// } +// System.out.println("<----"); + return result; + } + + class WLLookahead { + + private final int startIndex; + private final List condInvocations; + private final ScopeInvocation whileInv; + + public WLLookahead(int startIndex, + List condInvocations, + ScopeInvocation whileInv) { + this.startIndex = startIndex; + this.condInvocations = condInvocations; + this.whileInv = whileInv; + } + + public List getCondInvocations() { + return condInvocations; + } + + public int getStartIndex() { + return startIndex; + } + + public ScopeInvocation getWhileInv() { + return whileInv; + } + } + + private boolean isNextWhileLoop(List invocations, Invocation inv) { + int i = invocations.indexOf(inv); + + boolean lastInvocation = i == invocations.size() - 1; + + if (lastInvocation) { + return false; + } else { + Invocation nextI = invocations.get(i + 1); + return isWhileLoop(nextI); + } + } + + private Optional lookupNextWhileLoop(ControlFlow cf, + List invocations, Invocation inv) { + int i = invocations.indexOf(inv); + + List potentialInvocations + = getInvAndConnectedInvs(cf, invocations, inv); + + ScopeInvocation whileInv = null; + + if (potentialInvocations.size() > 1) { + Invocation potentialWL = potentialInvocations. + get(potentialInvocations.size() - 1); +// System.out.println("POT: " + potentialWL); + if (isWhileLoop(potentialWL)) { + whileInv = (ScopeInvocation) potentialWL; + } + } + + if (whileInv == null) { + return Optional.empty(); + } + + List condInvs = new ArrayList<>(); + + condInvs.addAll(potentialInvocations.subList( + 0, potentialInvocations.size() - 1)); + + return Optional.of(new WLLookahead(i, condInvs, whileInv)); + } + @Override - public ControlFlowScope transform(ControlFlowScope ce) { + public ControlFlowScope transform(ControlFlowScope ce, String indent) { // TODO 01.08.2015 add clone() ControlFlowScope result = ce; @@ -65,84 +188,209 @@ public ControlFlowScope transform(ControlFlowScope ce) { List invocations = new ArrayList<>(); invocations.addAll(ce.getControlFlow().getInvocations()); - result.getControlFlow().getInvocations().clear(); - ControlFlow cf = result.getControlFlow(); + addInstrumentation(cf, invocations, indent); + + return result; + } + + private void addInstrumentation( + ControlFlow cf, List invocations, String indent) { + + List instrumentedInvocations = new ArrayList<>(); for (int i = 0; i < invocations.size(); i++) { Invocation inv = invocations.get(i); + System.out.println(indent + " inv: " + inv); - System.out.println("i : " + inv); + // while loop instrumented separately + if (isWhileLoop(inv)) { + continue; + } + + Optional wlLookAheadRes + = lookupNextWhileLoop(cf, invocations, inv); - String varName = newVarName(); + if (wlLookAheadRes.isPresent()) { + WLLookahead wLLookAhead = wlLookAheadRes.get(); - Invocation preEventInv - = cf.callMethod("", "this", "println", Type.VOID, Argument.constArg( - Type.STRING, "pre-m-call: " + inv.getMethodName() + ", id: " + inv.getId())); +// System.out.println(indent + "->"); +// List instrumentedCondInvocations = new ArrayList<>(); +// for (int j = 0; j < wLLookAhead.getCondInvocations().size(); j++) { +// Invocation cInv = wLLookAhead.getCondInvocations().get(j); +//// System.out.println(indent + " cond: " + cf.isUsedAsInput(cInv)); +// instrumentNonLoopInvocation(cf, j, wLLookAhead.getCondInvocations(), instrumentedCondInvocations, indent); +// } +// System.out.println(indent + "<-"); + instrumentWhileLoop(cf, wLLookAhead.getCondInvocations(), + wLLookAhead.getWhileInv(), instrumentedInvocations, indent); - boolean lastInvocation = i == invocations.size() - 1; + // move forward to next invocation after the loop + i += wLLookAhead.getCondInvocations().size(); - IArgument retValArg = Argument.NULL; + } else { + instrumentNonLoopInvocation(cf, i, invocations, instrumentedInvocations, indent); + } + } // end for i - if (!lastInvocation) { - Invocation nextI = invocations.get(i + 1); + cf.getInvocations().clear(); + cf.getInvocations().addAll(instrumentedInvocations); + } - boolean iIsArgOfNextI = nextI.getArguments().stream(). - filter(a -> Objects.equals(a.getInvocation().orElse(null), inv)). - findAny().isPresent(); + private void instrumentNonLoopInvocation(ControlFlow cf, int i, List invocations, List resultInvs, String indent) { + Invocation inv = invocations.get(i); - // TODO 04.08.2015 chained method check buggy, needs to be modeled too - boolean retValIsObjectOfNextI - = nextI.getVariableName() != null - && nextI.getVariableName().isEmpty(); + Scope result = cf.getParent(); - if (iIsArgOfNextI || retValIsObjectOfNextI) { + String varName = newVarName(); + Invocation preEventInv + = cf.callMethod("", "this", "println", Type.VOID, Argument.constArg( + Type.STRING, "pre-m-call: " + inv.getMethodName() + ", id: " + inv.getId())); - cf.declareVariable("", inv.getReturnType(), varName); - cf.assignVariable("", varName, Argument.invArg(inv)); + resultInvs.add(preEventInv); - if (iIsArgOfNextI) { - int[] argumentsToReplace = nextI.getArguments().stream(). - filter(a -> Objects.equals(a.getInvocation().orElse(null), inv)). - mapToInt(a -> nextI.getArguments().indexOf(a)).toArray(); + boolean lastInvocation = i == invocations.size() - 1; - for (int aIndex : argumentsToReplace) { - nextI.getArguments().set(aIndex, - Argument.varArg(result.getVariable(varName))); - } - } else { - nextI.setVariableName(varName); - } + IArgument retValArg = Argument.NULL; - cf.declareVariable("", Type.STRING, varName + "_post_arg"); - Variable rightArgVariable = ce.getVariable(varName + "_post_arg"); - Invocation retValPostArgInv = cf.invokeOperator("", - Argument.constArg(Type.STRING, "post-m-call: " + inv.getMethodName() + ", retVal: "), - Argument.varArg(result.getVariable(varName)), Operator.PLUS); - cf.assignVariable("", rightArgVariable.getName(), Argument.invArg(retValPostArgInv)); + if (!lastInvocation) { + Invocation nextI = invocations.get(i + 1); - retValArg = Argument.varArg(rightArgVariable); +// boolean iIsArgOfNextI = isInvArgOfNextInv(nextI, inv); + boolean retValIsObjectOfNextI = isRetValObjectOfNextInv(nextI); + + Optional invocationTarget = isInvArg(inv, cf); + + if (invocationTarget.isPresent() || retValIsObjectOfNextI) { + + resultInvs.add(cf.declareVariable("", inv.getReturnType(), varName)); + resultInvs.add(cf.assignVariable("", varName, Argument.invArg(inv))); + + if (invocationTarget.isPresent()) { + int[] argumentsToReplace = invocationTarget.get().getArguments().stream(). + filter(a -> Objects.equals(a.getInvocation().orElse(null), inv)). + mapToInt(a -> invocationTarget.get().getArguments().indexOf(a)).toArray(); + + for (int aIndex : argumentsToReplace) { + invocationTarget.get().getArguments().set(aIndex, + Argument.varArg(cf.getParent().getVariable(varName))); + } + } else { + // retValIsObjectOfNextI + nextI.setVariableName(varName); } - } + resultInvs.add(cf.declareVariable("", Type.STRING, varName + "_post_arg")); + Variable rightArgVariable = result.getVariable(varName + "_post_arg"); + Invocation retValPostArgInv = cf.invokeOperator("", + Argument.constArg(Type.STRING, "post-m-call: " + inv.getMethodName() + ", retVal: "), + Argument.varArg(result.getVariable(varName)), Operator.PLUS); + resultInvs.add(retValPostArgInv); + resultInvs.add(cf.assignVariable("", rightArgVariable.getName(), + Argument.invArg(retValPostArgInv))); - cf.getInvocations().add(inv); - if (Objects.equals(retValArg, Argument.NULL)) { - cf.callMethod("", "this", "println", Type.VOID, Argument.constArg( - Type.STRING, "post-m-call: " + inv.getMethodName())); - } else { - cf.callMethod("", "this", "println", Type.VOID, retValArg); + retValArg = Argument.varArg(rightArgVariable); } + } - if (inv instanceof ScopeInvocation) { - ScopeInvocation si = (ScopeInvocation) inv; - transform((ControlFlowScope) si.getScope()); - } + cf.getInvocations().add(inv); + resultInvs.add(inv); + if (Objects.equals(retValArg, Argument.NULL)) { + resultInvs.add(cf.callMethod("", "this", "println", Type.VOID, Argument.constArg( + Type.STRING, "post-m-call: " + inv.getMethodName()))); + } else { + resultInvs.add(cf.callMethod("", "this", "println", Type.VOID, retValArg)); + } + if (inv instanceof ScopeInvocation) { + ScopeInvocation si = (ScopeInvocation) inv; + transform((ControlFlowScope) si.getScope(), indent + "--|"); } + } - return result; + private boolean isRetValObjectOfNextInv(Invocation nextI) { + // TODO 04.08.2015 chained method check buggy, needs to be modeled too + boolean retValIsObjectOfNextI + = nextI.getVariableName() != null + && nextI.getVariableName().isEmpty(); + return retValIsObjectOfNextI; + } + +// private boolean isInvArgOfNextInv(Invocation nextI, Invocation inv) { +// boolean iIsArgOfNextI = nextI.getArguments().stream(). +// filter(a -> Objects.equals(a.getInvocation().orElse(null), inv)). +// findAny().isPresent(); +// return iIsArgOfNextI; +// } + + private Optional isInvArg(Invocation inv, ControlFlow cf) { + return cf.returnInvTargetIfPresent(inv); + } + + private void instrumentWhileLoop( + ControlFlow cf, + List condInvs, + ScopeInvocation whileLoopInv, + List resultInvs, String indent) { + + Invocation preWhileEventInv + = cf.callMethod("", "this", "println", Type.VOID, + Argument.constArg( + Type.STRING, + "pre-m-call: " + + whileLoopInv.getMethodName() + + ", id: " + whileLoopInv.getId())); + + resultInvs.add(preWhileEventInv); + + String varName = newVarName(); + resultInvs.add(cf.declareVariable("", Type.BOOLEAN, varName)); + + whileLoopInv.getArguments().set(0, Argument.constArg(Type.BOOLEAN, true)); + + cf.getInvocations().add(whileLoopInv); + resultInvs.add(whileLoopInv); + + ControlFlowScope whileScope = (ControlFlowScope) whileLoopInv.getScope(); + + transform(whileScope, indent + "while--|"); + + ControlFlow whileCf = whileLoopInv.getScope().getControlFlow(); + + List instrumentedWhileInvocations = new ArrayList<>(); + instrumentedWhileInvocations.addAll(whileCf.getInvocations()); + whileCf.getInvocations().clear(); + + VisualCodeBuilder builder = new VisualCodeBuilder_Impl(); + + List instrumentedCondInvs = new ArrayList<>(); + whileCf.getInvocations().addAll(condInvs); + addInstrumentation(whileCf, condInvs, indent + "while-cond--|"); + instrumentedCondInvs.addAll(whileCf.getInvocations()); + + whileCf.getInvocations().clear(); + + Invocation notInv = whileCf.invokeNot("", + Argument.invArg(condInvs.get(condInvs.size() - 1))); + instrumentedCondInvs.add(notInv); + instrumentedCondInvs.add(whileCf.assignVariable("", + varName, Argument.invArg(notInv))); + + IfDeclaration ifDecl = builder.invokeIf( + whileScope, Argument.varArg(cf.getParent().getVariable(varName))); + Invocation conditionIfInv = whileScope.getControlFlow().getInvocations().get( + whileScope.getControlFlow().getInvocations().size() - 1); + + ifDecl.getControlFlow().invokeBreak(""); + + whileCf.getInvocations().clear(); + whileCf.getInvocations().addAll(instrumentedCondInvs); + whileCf.getInvocations().add(conditionIfInv); + whileCf.getInvocations().addAll(instrumentedWhileInvocations); + + resultInvs.add(cf.callMethod("", "this", "println", Type.VOID, Argument.constArg( + Type.STRING, "post-m-call: " + whileLoopInv.getMethodName()))); } } diff --git a/VRL/VRL-Lang/src/test/java/eu/mihosoft/vrl/lang/model/transform/InstrumentationTest.java b/VRL/VRL-Lang/src/test/java/eu/mihosoft/vrl/lang/model/transform/InstrumentationTest.java index 1bf95b80..af963408 100644 --- a/VRL/VRL-Lang/src/test/java/eu/mihosoft/vrl/lang/model/transform/InstrumentationTest.java +++ b/VRL/VRL-Lang/src/test/java/eu/mihosoft/vrl/lang/model/transform/InstrumentationTest.java @@ -87,7 +87,7 @@ public void instrumentationTest() { InstrumentCode instrumentCode = new InstrumentCode(); - CompilationUnitDeclaration newCu = instrumentCode.transform(cu); + CompilationUnitDeclaration newCu = instrumentCode.transform(cu,"--|"); String instrumentedCode = Scope2Code.getCode(newCu); diff --git a/VRL/VRL-Lang/src/test/resources/eu/mihosoft/vrl/lang/Instrumentation02.groovy b/VRL/VRL-Lang/src/test/resources/eu/mihosoft/vrl/lang/Instrumentation02.groovy index 2585153f..881da612 100644 --- a/VRL/VRL-Lang/src/test/resources/eu/mihosoft/vrl/lang/Instrumentation02.groovy +++ b/VRL/VRL-Lang/src/test/resources/eu/mihosoft/vrl/lang/Instrumentation02.groovy @@ -7,12 +7,18 @@ package my.testpackage; */ @eu.mihosoft.vrl.instrumentation.VRLVisualization public class MyFileClass { + + static int m(int v) { + return v+v; + } public static void main(String[] args) { int n = 3; int i = 0; - while(i