Search in sources :

Example 1 with AssignStmt

use of abs.frontend.ast.AssignStmt in project abstools by abstools.

the class AbsASTBuilderUtil method getVAssign.

public static final AssignStmt getVAssign(VarOrFieldUse v, Exp exp) {
    AssignStmt s = new AssignStmt();
    s.setVar(v);
    s.setValue(exp);
    return s;
}
Also used : AssignStmt(abs.frontend.ast.AssignStmt)

Example 2 with AssignStmt

use of abs.frontend.ast.AssignStmt in project abstools by abstools.

the class FrontendTest method getTypeOfNthAssignment.

protected Type getTypeOfNthAssignment(Model m, int n) {
    int count = 0;
    for (Stmt s : m.getMainBlock().getStmts()) {
        Type t = null;
        if (s instanceof AssignStmt) {
            AssignStmt as = (AssignStmt) s;
            t = as.getValue().getType();
        } else if (s instanceof VarDeclStmt) {
            VarDeclStmt vd = (VarDeclStmt) s;
            if (vd.getVarDecl().hasInitExp()) {
                t = vd.getVarDecl().getInitExp().getType();
            }
        }
        if (t != null) {
            count++;
            if (count == n) {
                return t;
            }
        }
    }
    return null;
}
Also used : Type(abs.frontend.typechecker.Type) AssignStmt(abs.frontend.ast.AssignStmt) VarDeclStmt(abs.frontend.ast.VarDeclStmt) VarDeclStmt(abs.frontend.ast.VarDeclStmt) AssignStmt(abs.frontend.ast.AssignStmt) Stmt(abs.frontend.ast.Stmt) ExpressionStmt(abs.frontend.ast.ExpressionStmt)

Aggregations

AssignStmt (abs.frontend.ast.AssignStmt)2 ExpressionStmt (abs.frontend.ast.ExpressionStmt)1 Stmt (abs.frontend.ast.Stmt)1 VarDeclStmt (abs.frontend.ast.VarDeclStmt)1 Type (abs.frontend.typechecker.Type)1