use of com.rockwellcollins.atc.agree.agree.PropertyStatement in project AGREE by loonwerks.
the class AgreeASTBuilder method getPropertyStatements.
private List<AgreeStatement> getPropertyStatements(EList<SpecStatement> specs) {
List<AgreeStatement> props = new ArrayList<>();
for (SpecStatement spec : specs) {
if (spec instanceof PropertyStatement) {
Expr expr = doSwitch(((PropertyStatement) spec).getExpr());
expr = new BinaryExpr(new IdExpr(((PropertyStatement) spec).getName()), BinaryOp.EQUAL, expr);
props.add(new AgreeStatement("", expr, spec));
}
}
return props;
}
use of com.rockwellcollins.atc.agree.agree.PropertyStatement in project AGREE by loonwerks.
the class AgreeASTBuilder method getEquationVars.
private List<AgreeVar> getEquationVars(EList<SpecStatement> specs, ComponentInstance compInst) {
List<AgreeVar> agreeVars = new ArrayList<>();
for (SpecStatement spec : specs) {
if (spec instanceof EqStatement) {
EList<Arg> args = ((EqStatement) spec).getLhs();
List<VarDecl> vars = agreeVarsFromArgs(args, compInst);
for (VarDecl var : vars) {
agreeVars.add((AgreeVar) var);
}
} else if (spec instanceof PropertyStatement) {
agreeVars.add(new AgreeVar(((PropertyStatement) spec).getName(), NamedType.BOOL, spec, compInst, null));
}
}
return agreeVars;
}
use of com.rockwellcollins.atc.agree.agree.PropertyStatement in project AGREE by loonwerks.
the class RenamingVisitor method getReferenceStr.
private String getReferenceStr(AgreeVar var) {
String prefix = getCategory(rootInstance, var);
if (prefix == null) {
return null;
}
if (var.id.endsWith(AgreeASTBuilder.clockIDSuffix)) {
return null;
}
String seperator = (prefix == "" ? "" : ".");
EObject reference = var.reference;
String suffix = "";
if (var.id.endsWith(AgreeASTBuilder.eventSuffix + AgreeInlineLatchedConnections.LATCHED_SUFFIX)) {
suffix = "._EVENT_._LATCHED_";
} else if (var.id.endsWith(AgreeASTBuilder.eventSuffix)) {
suffix = "._EVENT_";
} else if (var.id.endsWith(AgreeInlineLatchedConnections.LATCHED_SUFFIX)) {
suffix = "._LATCHED_";
}
if (reference instanceof GuaranteeStatement) {
String id = ((GuaranteeStatement) reference).getName();
if (id == null || id.isEmpty()) {
id = "";
} else {
id = "[" + id + "] ";
}
return id + ((GuaranteeStatement) reference).getStr();
} else if (reference instanceof AssumeStatement) {
String id = ((AssumeStatement) reference).getName();
if (id == null || id.isEmpty()) {
id = "";
} else {
id = "[" + id + "] ";
}
return prefix + " assume: " + id + ((AssumeStatement) reference).getStr();
} else if (reference instanceof LemmaStatement) {
String id = ((LemmaStatement) reference).getName();
if (id == null || id.isEmpty()) {
id = "";
} else {
id = "[" + id + "] ";
}
return prefix + " lemma: " + id + ((LemmaStatement) reference).getStr();
} else if (reference instanceof ReachableStatement) {
renaming.addInvertedProperty(var.id);
String id = ((ReachableStatement) reference).getName();
if (id == null || id.isEmpty()) {
id = "";
} else {
id = "[" + id + "] ";
}
return prefix + " reachable: " + id + ((ReachableStatement) reference).getStr();
} else if (reference instanceof AssertStatement) {
throw new AgreeException("We really didn't expect to see an assert statement here");
} else if (reference instanceof Arg) {
return prefix + seperator + ((Arg) reference).getName() + suffix;
} else if (reference instanceof EqStatement) {
return prefix + "eq " + String.join(", ", ((EqStatement) reference).getLhs().stream().map(lhs -> argToString(lhs)).collect(Collectors.toList()));
} else if (reference instanceof InputStatement) {
return prefix + "agree_input " + String.join(", ", ((InputStatement) reference).getLhs().stream().map(lhs -> argToString(lhs)).collect(Collectors.toList()));
} else if (reference instanceof DataPort) {
return prefix + seperator + ((DataPort) reference).getName() + suffix;
} else if (reference instanceof EventPort) {
return prefix + seperator + ((EventPort) reference).getName() + suffix;
} else if (reference instanceof EventDataPort) {
return prefix + seperator + ((EventDataPort) reference).getName() + suffix;
} else if (reference instanceof FeatureGroup) {
String featName = ((FeatureGroup) reference).getName();
String varName = var.toString();
featName = varName.substring(varName.indexOf(featName)).replace("__", ".");
return prefix + seperator + featName;
} else if (reference instanceof PropertyStatement) {
return prefix + seperator + ((PropertyStatement) reference).getName();
} else if (reference instanceof Property) {
return "AADL property " + ((Property) reference).getName();
} else if (reference instanceof GetPropertyExpr) {
return "Get_Property(" + ((GetPropertyExpr) reference).getContainingClassifier().getName() + ", " + ((Property) ((GetPropertyExpr) reference).getProp()).getName() + ")";
} else if (reference instanceof ComponentType || reference instanceof ComponentImplementation || reference instanceof SystemImplementation) {
if (var.id.equals(LustreAstBuilder.assumeHistSufix)) {
return "Subcomponent Assumptions";
}
return "Result";
} else if (reference instanceof AgreeStatement) {
return prefix + reference.toString();
}
throw new AgreeException("Unhandled reference type: '" + reference.getClass().getName() + "'");
}
Aggregations