Search in sources :

Example 1 with ReplaceIdVisitor

use of edu.umn.cs.crisys.safety.analysis.ast.visitors.ReplaceIdVisitor in project AMASE by loonwerks.

the class FaultASTBuilder method renameEqId.

/**
 * Make new fault with updated eq stmt ids
 * @param f fault to update
 * @param idMap map from old id to new
 * @return new updated fault
 */
private Fault renameEqId(Fault f, Map<String, String> idMap) {
    Fault newFault = new Fault(f);
    newFault.safetyEqVars.clear();
    newFault.safetyEqAsserts.clear();
    newFault.faultOutputMap.clear();
    newFault.faultInputMap.clear();
    if (!f.triggers.isEmpty()) {
        throw new SafetyException("User-defined triggers are currently unsupported.");
    }
    // update the variable declarations
    for (AgreeVar eq : f.safetyEqVars) {
        if (idMap.containsKey(eq.id)) {
            eq = new AgreeVar(idMap.get(eq.id), eq.type, eq.reference);
        }
        newFault.safetyEqVars.add(eq);
    }
    ReplaceIdVisitor visitor = new ReplaceIdVisitor(idMap);
    for (AgreeStatement s : f.safetyEqAsserts) {
        newFault.safetyEqAsserts.add(visitor.visit(s));
    }
    for (Map.Entry<Expr, String> element : f.faultOutputMap.entrySet()) {
        newFault.faultOutputMap.put(element.getKey().accept(visitor), element.getValue());
    }
    for (Map.Entry<String, Expr> element : f.faultInputMap.entrySet()) {
        newFault.faultInputMap.put(element.getKey(), element.getValue().accept(visitor));
    }
    return newFault;
}
Also used : AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) RecordAccessExpr(jkind.lustre.RecordAccessExpr) TupleExpr(jkind.lustre.TupleExpr) Expr(jkind.lustre.Expr) NodeCallExpr(jkind.lustre.NodeCallExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) IdExpr(jkind.lustre.IdExpr) ReplaceIdVisitor(edu.umn.cs.crisys.safety.analysis.ast.visitors.ReplaceIdVisitor) SafetyException(edu.umn.cs.crisys.safety.analysis.SafetyException) Map(java.util.Map) HashMap(java.util.HashMap) AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)

Aggregations

AgreeStatement (com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement)1 AgreeVar (com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)1 SafetyException (edu.umn.cs.crisys.safety.analysis.SafetyException)1 ReplaceIdVisitor (edu.umn.cs.crisys.safety.analysis.ast.visitors.ReplaceIdVisitor)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 BinaryExpr (jkind.lustre.BinaryExpr)1 BoolExpr (jkind.lustre.BoolExpr)1 Expr (jkind.lustre.Expr)1 IdExpr (jkind.lustre.IdExpr)1 NodeCallExpr (jkind.lustre.NodeCallExpr)1 RecordAccessExpr (jkind.lustre.RecordAccessExpr)1 TupleExpr (jkind.lustre.TupleExpr)1