Search in sources :

Example 1 with SubstitutionVisitor

use of jkind.translation.SubstitutionVisitor in project AGREE by loonwerks.

the class InlineNodeCalls method createAssignmentEquations.

private void createAssignmentEquations(final String prefix, List<Equation> equations, Map<String, IdExpr> translation) {
    SubstitutionVisitor substitution = new SubstitutionVisitor(translation) {

        @Override
        public Expr visit(NodeCallExpr e) {
            return new NodeCallExpr(e.location, prefix + e.node, visitExprs(e.args));
        }
    };
    for (Equation eq : equations) {
        List<IdExpr> lhs = new ArrayList<>();
        for (IdExpr idExpr : eq.lhs) {
            lhs.add(translation.get(idExpr.id));
        }
        Expr expr = eq.expr.accept(substitution);
        queue.add(new Equation(eq.location, lhs, expr));
    }
}
Also used : SubstitutionVisitor(jkind.translation.SubstitutionVisitor) IdExpr(jkind.lustre.IdExpr) TupleExpr(jkind.lustre.TupleExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) Expr(jkind.lustre.Expr) IdExpr(jkind.lustre.IdExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) ArrayList(java.util.ArrayList) Equation(jkind.lustre.Equation)

Example 2 with SubstitutionVisitor

use of jkind.translation.SubstitutionVisitor in project AGREE by loonwerks.

the class AgreeASTBuilder method caseExistsExpr.

@Override
public Expr caseExistsExpr(ExistsExpr expr) {
    com.rockwellcollins.atc.agree.agree.Expr arrayExpr = expr.getArray();
    Expr array = doSwitch(arrayExpr);
    AgreeTypeSystem.TypeDef agreeType = AgreeTypeSystem.infer(arrayExpr);
    int size = 0;
    if (agreeType instanceof AgreeTypeSystem.ArrayTypeDef) {
        size = ((AgreeTypeSystem.ArrayTypeDef) agreeType).size;
    } else {
        throw new AgreeException("ERROR: caseExistsExpr - '" + agreeType.getClass() + "' not handled");
    }
    NamedID binding = expr.getBinding();
    Expr final_expr = new BoolExpr(false);
    for (int i = 0; i < size; ++i) {
        Expr arrayAccess = new ArrayAccessExpr(array, i);
        Expr body = doSwitch(expr.getExpr()).accept(new SubstitutionVisitor(binding.getName(), arrayAccess));
        final_expr = LustreExprFactory.makeORExpr(final_expr, body);
    }
    return final_expr;
}
Also used : BoolExpr(jkind.lustre.BoolExpr) ArrayAccessExpr(jkind.lustre.ArrayAccessExpr) NamedID(com.rockwellcollins.atc.agree.agree.NamedID) AgreeTypeSystem(com.rockwellcollins.atc.agree.AgreeTypeSystem) SubstitutionVisitor(jkind.translation.SubstitutionVisitor) EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) IndicesExpr(com.rockwellcollins.atc.agree.agree.IndicesExpr) TimeRiseExpr(com.rockwellcollins.atc.agree.agree.TimeRiseExpr) RecordAccessExpr(jkind.lustre.RecordAccessExpr) FlatmapExpr(com.rockwellcollins.atc.agree.agree.FlatmapExpr) TimeFallExpr(com.rockwellcollins.atc.agree.agree.TimeFallExpr) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) GetPropertyExpr(com.rockwellcollins.atc.agree.agree.GetPropertyExpr) Expr(jkind.lustre.Expr) CastExpr(jkind.lustre.CastExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) TimeOfExpr(com.rockwellcollins.atc.agree.agree.TimeOfExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) RealExpr(jkind.lustre.RealExpr) ArrayExpr(jkind.lustre.ArrayExpr) PrevExpr(com.rockwellcollins.atc.agree.agree.PrevExpr) IdExpr(jkind.lustre.IdExpr) TimeExpr(com.rockwellcollins.atc.agree.agree.TimeExpr) FoldRightExpr(com.rockwellcollins.atc.agree.agree.FoldRightExpr) TagExpr(com.rockwellcollins.atc.agree.agree.TagExpr) EventExpr(com.rockwellcollins.atc.agree.agree.EventExpr) LatchedExpr(com.rockwellcollins.atc.agree.agree.LatchedExpr) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) FunctionCallExpr(jkind.lustre.FunctionCallExpr) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) TupleExpr(jkind.lustre.TupleExpr) UnaryExpr(jkind.lustre.UnaryExpr) ArraySubExpr(com.rockwellcollins.atc.agree.agree.ArraySubExpr) IntExpr(jkind.lustre.IntExpr) PreExpr(com.rockwellcollins.atc.agree.agree.PreExpr) RecordLitExpr(com.rockwellcollins.atc.agree.agree.RecordLitExpr) ExistsExpr(com.rockwellcollins.atc.agree.agree.ExistsExpr) FoldLeftExpr(com.rockwellcollins.atc.agree.agree.FoldLeftExpr) RecordUpdateExpr(com.rockwellcollins.atc.agree.agree.RecordUpdateExpr) ForallExpr(com.rockwellcollins.atc.agree.agree.ForallExpr) ArrayAccessExpr(jkind.lustre.ArrayAccessExpr) ArrayUpdateExpr(com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) NodeBodyExpr(com.rockwellcollins.atc.agree.agree.NodeBodyExpr) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) ArrayLiteralExpr(com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException)

Example 3 with SubstitutionVisitor

use of jkind.translation.SubstitutionVisitor in project AGREE by loonwerks.

the class AgreeASTBuilder method getGuaranteeStatements.

private List<AgreeStatement> getGuaranteeStatements(EList<SpecStatement> specs, Map<String, jkind.lustre.Expr> rewriteMap) {
    List<AgreeStatement> guarantees = new ArrayList<>();
    for (SpecStatement spec : specs) {
        if (spec instanceof GuaranteeStatement) {
            GuaranteeStatement guarantee = (GuaranteeStatement) spec;
            String str = guarantee.getStr();
            if (guarantee.getExpr() != null) {
                guarantees.add(new AgreeStatement(str, doSwitch(guarantee.getExpr()).accept(new SubstitutionVisitor(rewriteMap)), guarantee));
            } else {
                PatternStatement pattern = guarantee.getPattern();
                AgreeStatement patStatement = new AgreePatternBuilder(str, guarantee, this).doSwitch(pattern);
                patStatement.expr = patStatement.expr.accept(new SubstitutionVisitor(rewriteMap));
                guarantees.add(patStatement);
            }
        }
    }
    return guarantees;
}
Also used : GuaranteeStatement(com.rockwellcollins.atc.agree.agree.GuaranteeStatement) SubstitutionVisitor(jkind.translation.SubstitutionVisitor) PatternStatement(com.rockwellcollins.atc.agree.agree.PatternStatement) ArrayList(java.util.ArrayList) SpecStatement(com.rockwellcollins.atc.agree.agree.SpecStatement) AgreePatternBuilder(com.rockwellcollins.atc.agree.analysis.realtime.AgreePatternBuilder)

Example 4 with SubstitutionVisitor

use of jkind.translation.SubstitutionVisitor in project AGREE by loonwerks.

the class AgreeASTBuilder method getReachableStatements.

private List<AgreeStatement> getReachableStatements(EList<SpecStatement> specs, Map<String, jkind.lustre.Expr> rewriteMap) {
    List<AgreeStatement> reachables = new ArrayList<>();
    for (SpecStatement spec : specs) {
        if (spec instanceof ReachableStatement) {
            ReachableStatement reachable = (ReachableStatement) spec;
            if (reachable.getExpr() != null) {
                reachables.add(new AgreeStatement(reachable.getStr(), new jkind.lustre.UnaryExpr(jkind.lustre.UnaryOp.NOT, doSwitch(reachable.getExpr()).accept(new SubstitutionVisitor(rewriteMap))), spec));
            } else {
                PatternStatement pattern = reachable.getPattern();
                AgreeStatement patStatement = new AgreePatternBuilder(reachable.getStr(), reachable, this).doSwitch(pattern);
                patStatement.expr = new jkind.lustre.UnaryExpr(jkind.lustre.UnaryOp.NOT, patStatement.expr.accept(new SubstitutionVisitor(rewriteMap)));
                reachables.add(patStatement);
            }
        }
    }
    return reachables;
}
Also used : SubstitutionVisitor(jkind.translation.SubstitutionVisitor) PatternStatement(com.rockwellcollins.atc.agree.agree.PatternStatement) ArrayList(java.util.ArrayList) UnaryExpr(jkind.lustre.UnaryExpr) SpecStatement(com.rockwellcollins.atc.agree.agree.SpecStatement) AgreePatternBuilder(com.rockwellcollins.atc.agree.analysis.realtime.AgreePatternBuilder) UnaryExpr(jkind.lustre.UnaryExpr) ReachableStatement(com.rockwellcollins.atc.agree.agree.ReachableStatement)

Example 5 with SubstitutionVisitor

use of jkind.translation.SubstitutionVisitor in project AGREE by loonwerks.

the class AgreeASTBuilder method getAssumptionStatements.

private List<AgreeStatement> getAssumptionStatements(EList<SpecStatement> specs, Map<String, jkind.lustre.Expr> rewriteMap) {
    List<AgreeStatement> assumptions = new ArrayList<>();
    for (SpecStatement spec : specs) {
        if (spec instanceof AssumeStatement) {
            AssumeStatement assumption = (AssumeStatement) spec;
            String str = assumption.getStr();
            if (assumption.getExpr() != null) {
                assumptions.add(new AgreeStatement(str, doSwitch(assumption.getExpr()).accept(new SubstitutionVisitor(rewriteMap)), assumption));
            } else {
                PatternStatement pattern = assumption.getPattern();
                AgreeStatement patAssumption = new AgreePatternBuilder(str, assumption, this).doSwitch(pattern);
                patAssumption.expr = patAssumption.expr.accept(new SubstitutionVisitor(rewriteMap));
                assumptions.add(patAssumption);
            }
        }
    }
    return assumptions;
}
Also used : SubstitutionVisitor(jkind.translation.SubstitutionVisitor) PatternStatement(com.rockwellcollins.atc.agree.agree.PatternStatement) AssumeStatement(com.rockwellcollins.atc.agree.agree.AssumeStatement) ArrayList(java.util.ArrayList) SpecStatement(com.rockwellcollins.atc.agree.agree.SpecStatement) AgreePatternBuilder(com.rockwellcollins.atc.agree.analysis.realtime.AgreePatternBuilder)

Aggregations

SubstitutionVisitor (jkind.translation.SubstitutionVisitor)10 Expr (jkind.lustre.Expr)7 IdExpr (jkind.lustre.IdExpr)7 ArrayLiteralExpr (com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr)6 ArraySubExpr (com.rockwellcollins.atc.agree.agree.ArraySubExpr)6 ArrayUpdateExpr (com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr)6 BoolLitExpr (com.rockwellcollins.atc.agree.agree.BoolLitExpr)6 CallExpr (com.rockwellcollins.atc.agree.agree.CallExpr)6 EnumLitExpr (com.rockwellcollins.atc.agree.agree.EnumLitExpr)6 EventExpr (com.rockwellcollins.atc.agree.agree.EventExpr)6 ExistsExpr (com.rockwellcollins.atc.agree.agree.ExistsExpr)6 FlatmapExpr (com.rockwellcollins.atc.agree.agree.FlatmapExpr)6 FoldLeftExpr (com.rockwellcollins.atc.agree.agree.FoldLeftExpr)6 FoldRightExpr (com.rockwellcollins.atc.agree.agree.FoldRightExpr)6 ForallExpr (com.rockwellcollins.atc.agree.agree.ForallExpr)6 GetPropertyExpr (com.rockwellcollins.atc.agree.agree.GetPropertyExpr)6 IndicesExpr (com.rockwellcollins.atc.agree.agree.IndicesExpr)6 IntLitExpr (com.rockwellcollins.atc.agree.agree.IntLitExpr)6 LatchedExpr (com.rockwellcollins.atc.agree.agree.LatchedExpr)6 NamedElmExpr (com.rockwellcollins.atc.agree.agree.NamedElmExpr)6