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));
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations