Skip to content

Commit

Permalink
issue #61 : fixed id issue: all invocations use the correct id now
Browse files Browse the repository at this point in the history
this should be sufficient for visualizing instrumentation events (issue #58)

TODO investigate whether id generation should be inside object initialization or inside the code-builder
  • Loading branch information
miho committed Aug 7, 2015
1 parent a1c719b commit 7fe412f
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static Invocation generatePreEvent(ControlFlow cf, Invocation inv) {
}

return cf.callStaticMethod(
"id",
"",
Type.fromClass(VRLInstrumentationUtil.class),
"__preEvent", Type.VOID, args);
}
Expand Down Expand Up @@ -116,8 +116,8 @@ public static void __preEvent(String id, String invName, Object... args) {
argsStr[i] = "'" + s + "'";
}

System.out.println("pre-event: " + invName + ", id: " + id
+ ", args: [ " + String.join(", ", argsStr) + " ]");
System.out.println("pre-event: " + invName + ", id: '" + id
+ "', args: [ " + String.join(", ", argsStr) + " ]");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ public class BinaryOperatorInvocationImpl extends InvocationImpl implements Bina

private final Operator operator;

public BinaryOperatorInvocationImpl(Scope parent, IArgument leftArg, IArgument rightArg, Operator operator) {
public BinaryOperatorInvocationImpl(String id, Scope parent, IArgument leftArg, IArgument rightArg, Operator operator) {

super(parent, "", null, "op " + operator, Type.VOID, false, true, leftArg, rightArg);
super(parent, id, null, "op " + operator, Type.VOID, false, true, leftArg, rightArg);

this.operator = operator;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
*/
public class BreakInvocationImpl extends InvocationImpl implements BreakInvocation {

public BreakInvocationImpl(Scope parent) {
public BreakInvocationImpl(String id, Scope parent) {

super(parent, "", null, "break", Type.VOID, false, true);
super(parent, id, null, "break", Type.VOID, false, true);

getNode().setTitle("break");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
*/
public class ContinueInvocationImpl extends InvocationImpl implements ContinueInvocation {

public ContinueInvocationImpl(Scope parent) {
public ContinueInvocationImpl(String id, Scope parent) {

super(parent, "", null, "continue", Type.VOID, false, true);
super(parent, id, null, "continue", Type.VOID, false, true);

getNode().setTitle("continue");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public BinaryOperatorInvocation assignConstant(String id, String varName, IArgum
throw new IllegalArgumentException("Variable " + varName + " does not exist!");
}

BinaryOperatorInvocation invocation = new BinaryOperatorInvocationImpl(parent,
BinaryOperatorInvocation invocation = new BinaryOperatorInvocationImpl(id,parent,
Argument.varArg(var), arg, Operator.ASSIGN);

getInvocations().add(invocation);
Expand All @@ -315,7 +315,7 @@ public BinaryOperatorInvocation assignVariable(String id, String varName, IArgum
throw new IllegalArgumentException("Variable " + varName + " does not exist!");
}

BinaryOperatorInvocation invocation = new BinaryOperatorInvocationImpl(parent,
BinaryOperatorInvocation invocation = new BinaryOperatorInvocationImpl(id,parent,
Argument.varArg(var), arg, Operator.ASSIGN);

getInvocations().add(invocation);
Expand All @@ -331,7 +331,7 @@ public BinaryOperatorInvocation assignInvocationResult(String id, String varName
throw new IllegalArgumentException("Variable " + varName + " does not exist!");
}

BinaryOperatorInvocation result = new BinaryOperatorInvocationImpl(parent,
BinaryOperatorInvocation result = new BinaryOperatorInvocationImpl(id,parent,
Argument.varArg(var), Argument.invArg(invocation), Operator.ASSIGN);

getInvocations().add(result);
Expand All @@ -343,7 +343,7 @@ public BinaryOperatorInvocation assignInvocationResult(String id, String varName
public DeclarationInvocation declareVariable(String id, IType type, String varName) {
VariableImpl var = (VariableImpl) ((ScopeImpl) parent)._createVariable(type, varName);

DeclarationInvocationImpl invocation = new DeclarationInvocationImpl(parent, var);
DeclarationInvocationImpl invocation = new DeclarationInvocationImpl(id, parent, var);

var.setDeclaration(invocation);

Expand All @@ -367,7 +367,7 @@ public DeclarationInvocation declareVariable(String id, IType type, String varNa
@Override
public BinaryOperatorInvocation invokeOperator(String id, IArgument leftArg,
IArgument rightArg, Operator operator) {
BinaryOperatorInvocation invocation = new BinaryOperatorInvocationImpl(parent,
BinaryOperatorInvocation invocation = new BinaryOperatorInvocationImpl(id,parent,
leftArg, rightArg, operator);

getInvocations().add(invocation);
Expand All @@ -382,7 +382,8 @@ public Scope getParent() {

@Override
public ReturnStatementInvocation returnValue(String id, IArgument arg) {
ReturnStatementInvocation invocation = new ReturnStatementInvocationImpl(parent, arg);
ReturnStatementInvocation invocation =
new ReturnStatementInvocationImpl(id,parent, arg);

getInvocations().add(invocation);

Expand All @@ -391,7 +392,7 @@ public ReturnStatementInvocation returnValue(String id, IArgument arg) {

@Override
public BreakInvocation invokeBreak(String id) {
BreakInvocation invocation = new BreakInvocationImpl(parent);
BreakInvocation invocation = new BreakInvocationImpl(id,parent);

getInvocations().add(invocation);

Expand All @@ -400,7 +401,7 @@ public BreakInvocation invokeBreak(String id) {

@Override
public ContinueInvocation invokeContinue(String id) {
ContinueInvocation invocation = new ContinueInvocationImpl(parent);
ContinueInvocation invocation = new ContinueInvocationImpl(id,parent);

getInvocations().add(invocation);

Expand All @@ -409,7 +410,7 @@ public ContinueInvocation invokeContinue(String id) {

@Override
public NotInvocation invokeNot(String id, IArgument arg) {
NotInvocation invocation = new NotInvocationImpl(parent, arg);
NotInvocation invocation = new NotInvocationImpl(id,parent, arg);

getInvocations().add(invocation);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ public class DeclarationInvocationImpl extends InvocationImpl implements Declara

private final Variable declaredVariable;

public DeclarationInvocationImpl(Scope parent, IType type, String varName) {
super(parent, "", null, "declare " + varName, type, false, true, new IArgument[0]);
public DeclarationInvocationImpl(String id, Scope parent, IType type, String varName) {
super(parent, id, null, "declare " + varName, type, false, true, new IArgument[0]);
this.declaredVariable = parent.createVariable(type, varName);
getNode().setTitle("declare " + varName);
}

public DeclarationInvocationImpl(Scope parent, Variable declaredVariable) {
super(parent, "", null, "declare " + declaredVariable.getName(), declaredVariable.getType(), false, true, new IArgument[0]);
public DeclarationInvocationImpl(String id, Scope parent, Variable declaredVariable) {
super(parent, id, null, "declare " + declaredVariable.getName(), declaredVariable.getType(), false, true, new IArgument[0]);
this.declaredVariable = declaredVariable;
getNode().setTitle("declare " + declaredVariable.getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
*/
public class NotInvocationImpl extends InvocationImpl implements NotInvocation {

public NotInvocationImpl(Scope parent, IArgument arg) {
public NotInvocationImpl(String id, Scope parent, IArgument arg) {

super(parent, "", null, "not", Type.BOOLEAN, false, true, arg);
super(parent, id, null, "not", Type.BOOLEAN, false, true, arg);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
*/
public class ReturnStatementInvocationImpl extends InvocationImpl implements ReturnStatementInvocation {

public ReturnStatementInvocationImpl(Scope parent, IArgument arg ) {
public ReturnStatementInvocationImpl(String id, Scope parent, IArgument arg ) {

super(parent, "", null, "return", arg.getType(), false, true, arg);
super(parent, id, null, "return", arg.getType(), false, true, arg);

getNode().setTitle("return ");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ public interface Scope extends CodeEntity {

// public Variable createStaticVariable(IType type);

public BinaryOperatorInvocation assignInvocationResult(String varName, Invocation invocation);
public BinaryOperatorInvocation assignInvocationResult(String id, String varName, Invocation invocation);

public BinaryOperatorInvocation assignConstant(String varName, Object constant);
public BinaryOperatorInvocation assignConstant(String id, String varName, Object constant);

public BinaryOperatorInvocation assignVariable(String varNameDest, String varNameSrc);
public BinaryOperatorInvocation assignVariable(String id, String varNameDest, String varNameSrc);

public ControlFlow getControlFlow();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ Variable _createVariable(IType type, String varName) {
// return variable;
// }
@Override
public BinaryOperatorInvocation assignConstant(String varName, Object constant) {
public BinaryOperatorInvocation assignConstant(String id, String varName, Object constant) {
Variable var = getVariable(varName);

if (var == null) {
Expand All @@ -313,7 +313,7 @@ public BinaryOperatorInvocation assignConstant(String varName, Object constant)
}

@Override
public BinaryOperatorInvocation assignVariable(String varNameDest, String varNameSrc) {
public BinaryOperatorInvocation assignVariable(String id, String varNameDest, String varNameSrc) {
Variable varDest = getVariable(varNameDest);
Variable varSrc = getVariable(varNameSrc);

Expand All @@ -332,7 +332,7 @@ public BinaryOperatorInvocation assignVariable(String varNameDest, String varNam
}

@Override
public BinaryOperatorInvocation assignInvocationResult(String varName, Invocation invocation) {
public BinaryOperatorInvocation assignInvocationResult(String id, String varName, Invocation invocation) {
Variable varDest = getVariable(varName);

if (varDest == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ class ScopeInvocationImpl extends InvocationImpl implements ScopeInvocation {
private ObservableCodeImpl observableCode;

public ScopeInvocationImpl(Scope s) {
super(s, "", null, "scope", Type.VOID, false, true);
// TODO 07.08.2015 investigate whether scope and the corresponding
// invocation can have the same id
super(s, s.getId(), null, "scope", Type.VOID, false, true);
this.scope = s;

VNode node = scope.getNode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,17 @@ public Invocation invokeStaticMethod(ControlFlowScope scope, IType type, String

@Override
public BinaryOperatorInvocation assignVariable(Scope scope, String varNameDest, String varNameSrc) {
return scope.assignVariable(varNameDest, varNameSrc);
return scope.assignVariable(idRequest.request(), varNameDest, varNameSrc);
}

@Override
public BinaryOperatorInvocation assignConstant(Scope scope, String varName, Object constant) {
return scope.assignConstant(varName, constant);
return scope.assignConstant(idRequest.request(), varName, constant);
}

@Override
public BinaryOperatorInvocation assignInvocationResult(Scope scope, String varName, Invocation invocation) {
return scope.assignInvocationResult(varName, invocation);
return scope.assignInvocationResult(idRequest.request(), varName, invocation);
}

public void setIdRequest(IdRequest idRequest) {
Expand Down

0 comments on commit 7fe412f

Please sign in to comment.