Search in sources :

Example 1 with AssignStmt

use of org.abs_models.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(org.abs_models.frontend.typechecker.Type) AssignStmt(org.abs_models.frontend.ast.AssignStmt) VarDeclStmt(org.abs_models.frontend.ast.VarDeclStmt) Stmt(org.abs_models.frontend.ast.Stmt) AssignStmt(org.abs_models.frontend.ast.AssignStmt) VarDeclStmt(org.abs_models.frontend.ast.VarDeclStmt) ExpressionStmt(org.abs_models.frontend.ast.ExpressionStmt)

Example 2 with AssignStmt

use of org.abs_models.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(org.abs_models.frontend.ast.AssignStmt)

Aggregations

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