use of abs.frontend.ast.GetExp in project abstools by abstools.
the class ASTBasedABSTestRunnerGenerator method generateWaitSyncAST.
private WhileStmt generateWaitSyncAST() {
WhileStmt ws = new WhileStmt();
ws.setCondition(getFnApp("hasNext", new VarUse(futs)));
Block body = new Block();
DataTypeUse u = getType("Pair", getType("Set", getType("Fut", getType("Unit"))), getType("Fut", getType("Unit")));
body.addStmtNoTransform(getVarDecl("nt", u, getFnApp("next", new VarUse(futs))));
body.addStmtNoTransform(getVAssign(fut, getFnApp("snd", new VarUse("nt"))));
body.addStmtNoTransform(getVAssign(futs, getFnApp("fst", new VarUse("nt"))));
body.addStmtNoTransform(getExpStmt(new GetExp(new VarUse("fut"))));
// Attach body at the end, since JastAdd will avoid touching ASTs without parents.
ws.setBody(body);
return ws;
}
use of abs.frontend.ast.GetExp in project abstools by abstools.
the class DeadlockPreanalysis method lookforGetOperation.
// private void processAwait (AwaitStmt await, ASTNode<?> next) {
// if (await.getGuard().getChild(0) instanceof VarUse) {
// String varAwait = ((VarUse)await.getGuard().getChild(0)).getName();
// lookforGetOperation(await,next,varAwait);
// }
// }
private GetExp lookforGetOperation(AwaitStmt await, ASTNode<?> node, String varName) {
GetExp result = null;
if (node instanceof GetExp) {
GetExp get = (GetExp) node;
if (varName.equals(((VarUse) get.getChild(0)).getName())) {
result = (GetExp) node;
getExpressions.put((GetExp) node, await);
}
}
for (int i = 0; i < node.getNumChild() && result == null; i++) {
result = lookforGetOperation(await, node.getChild(i), varName);
}
return result;
}
use of abs.frontend.ast.GetExp in project abstools by abstools.
the class DeadlockPreanalysis method toString.
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append("***** Deadlock Preanalysis Results: *****\n");
buffer.append("----- GET Expressions evaluation --------\n");
for (GetExp get : getExpressions.keySet()) {
buffer.append(get.toString());
buffer.append("[");
int line = get.getStartLine();
buffer.append(get.getCompilationUnit().getName() + ":" + (line != 0 ? +line : "_"));
buffer.append("]");
buffer.append(":" + (getExpressions.get(get) != null ? true : false) + "\n");
}
buffer.append("----- Field Types -----------------------\n");
for (FieldDecl field : dataFieldDecls.keySet()) {
buffer.append(field.getContextDecl().getName() + "." + field.getName() + " [" + field.getCompilationUnit().getName() + ":" + field.getStartLine() + "]");
buffer.append(" might contain a future value?: " + dataFieldDecls.get(field) + "\n");
}
buffer.append("*****************************************");
return buffer.toString();
}
use of abs.frontend.ast.GetExp in project abstools by abstools.
the class DeadlockPreanalysis method processAwait.
private void processAwait(AwaitStmt await, int position, ASTNode<?> node) {
String varAwait = null;
if (await.getGuard().getChild(0) instanceof VarUse) {
varAwait = ((VarUse) await.getGuard().getChild(0)).getName();
}
int getPos = position + 1;
GetExp getInst = null;
if (varAwait != null) {
while (getPos < node.getNumChild() && getInst == null) {
getInst = lookforGetOperation(await, node.getChild(getPos), varAwait);
if (getInst == null) {
getPos++;
}
}
}
// System.out.println("PROCESANDO " + position + " " + getPos);
boolean used = false;
for (int i = position + 1; i < getPos && !used; i++) {
used = isVarUsed(node.getChild(i), varAwait);
}
if (used && getInst != null) {
getExpressions.put((GetExp) getInst, null);
}
}
Aggregations