Search in sources :

Example 1 with GetExp

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;
}
Also used : WhileStmt(abs.frontend.ast.WhileStmt) ParametricDataTypeUse(abs.frontend.ast.ParametricDataTypeUse) DataTypeUse(abs.frontend.ast.DataTypeUse) Block(abs.frontend.ast.Block) MainBlock(abs.frontend.ast.MainBlock) GetExp(abs.frontend.ast.GetExp) VarUse(abs.frontend.ast.VarUse)

Example 2 with GetExp

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;
}
Also used : GetExp(abs.frontend.ast.GetExp)

Example 3 with GetExp

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();
}
Also used : FieldDecl(abs.frontend.ast.FieldDecl) GetExp(abs.frontend.ast.GetExp)

Example 4 with GetExp

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);
    }
}
Also used : GetExp(abs.frontend.ast.GetExp) VarUse(abs.frontend.ast.VarUse)

Aggregations

GetExp (abs.frontend.ast.GetExp)4 VarUse (abs.frontend.ast.VarUse)2 Block (abs.frontend.ast.Block)1 DataTypeUse (abs.frontend.ast.DataTypeUse)1 FieldDecl (abs.frontend.ast.FieldDecl)1 MainBlock (abs.frontend.ast.MainBlock)1 ParametricDataTypeUse (abs.frontend.ast.ParametricDataTypeUse)1 WhileStmt (abs.frontend.ast.WhileStmt)1