use of com.rockwellcollins.atc.agree.analysis.AgreeException in project AGREE by loonwerks.
the class TcgLinkerFactory method createVerification.
protected AnalysisResult createVerification(String resultName, ComponentInstance compInst, Program lustreProgram, AgreeProgram agreeProgram) {
AgreeRenaming agreeRenaming = new AgreeRenaming();
AgreeLayout layout = new AgreeLayout();
RenamingVisitor.addRenamings(lustreProgram, agreeRenaming, compInst, layout);
TcgRenaming renaming = new TcgRenaming(agreeRenaming, agreeRenaming.getRefMap());
Node mainNode = lustreProgram.getMainNode();
if (mainNode == null) {
throw new AgreeException("Could not find main lustre node after translation");
}
List<String> properties = new ArrayList<>();
JKindResult result;
result = new JKindResult(resultName, properties, renaming);
queue.add(result);
ComponentImplementation compImpl = AgreeUtils.getInstanceImplementation(compInst);
linker.setAgreeProgram(result, agreeProgram);
linker.setProgram(result, lustreProgram);
linker.setComponent(result, compImpl);
linker.setContract(result, getContract(compImpl));
linker.setLayout(result, layout);
// linker.setReferenceMap(result, renaming.getRefMap());
linker.setLog(result, AgreeLogger.getLog());
linker.setRenaming(result, renaming);
// System.out.println(program);
return result;
}
use of com.rockwellcollins.atc.agree.analysis.AgreeException in project AGREE by loonwerks.
the class AgreeASTBuilder method caseTagExpr.
@Override
public Expr caseTagExpr(TagExpr e) {
String stemString = null;
if (e.getStem() instanceof NamedElmExpr) {
stemString = ((NamedElmExpr) e.getStem()).getElm().getName();
} else if (e.getStem() instanceof SelectionExpr) {
stemString = dottedNameToString(e.getStem());
} else {
throw new AgreeException("Pattern");
}
String tag = e.getTag();
if (tag != null) {
switch(tag) {
case "_CLK":
IdExpr clockId = new IdExpr(stemString + clockIDSuffix);
return clockId;
default:
throw new AgreeException("use of uknown tag: '" + tag + "' in expression following " + stemString);
}
}
throw new AgreeException("Pattern");
}
use of com.rockwellcollins.atc.agree.analysis.AgreeException 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 com.rockwellcollins.atc.agree.analysis.AgreeException in project AGREE by loonwerks.
the class AgreeASTBuilder method getSynchConstraint.
private Expr getSynchConstraint(SynchStatement spec, List<AgreeNode> subNodes) {
int val1 = Integer.decode(spec.getVal());
if (val1 == 0) {
return new BoolExpr(true);
}
List<Expr> clockIds = new ArrayList<>();
Expr clockAssertion;
for (AgreeNode subNode : subNodes) {
clockIds.add(new IdExpr(subNode.clockVar.id));
}
String dfaPrefix = getObjectLocationPrefix(spec);
if (spec.getVal2() == null) {
Node dfaNode = AgreeCalendarUtils.getDFANode(dfaPrefix + "__DFA_NODE", val1);
Node calNode = AgreeCalendarUtils.getCalendarNode(dfaPrefix + "__CALENDAR_NODE", dfaNode.id, clockIds.size());
// we do not need to make copies of the nodes if they exist
if (!nodeNameExists(dfaNode.id)) {
if (nodeNameExists(calNode.id)) {
throw new AgreeException("The calander node should not exist if the dfa node does not exist");
}
addToNodeList(dfaNode);
addToNodeList(calNode);
}
clockAssertion = new NodeCallExpr(calNode.id, clockIds);
} else {
int val2 = Integer.decode(spec.getVal2());
String nodeName = "__calendar_node_" + val1 + "_" + val2;
nodeName = dfaPrefix + nodeName;
Node calNode = AgreeCalendarUtils.getMNCalendar(nodeName, val1, val2);
if (!nodeNameExists(calNode.id)) {
addToNodeList(calNode);
}
clockAssertion = new BoolExpr(true);
int i, j;
for (i = 0; i < clockIds.size(); i++) {
Expr clock1 = clockIds.get(i);
for (j = i + 1; j < clockIds.size(); j++) {
Expr clock2 = clockIds.get(j);
NodeCallExpr nodeCall = new NodeCallExpr(nodeName, clock1, clock2);
clockAssertion = LustreExprFactory.makeANDExpr(clockAssertion, nodeCall);
nodeCall = new NodeCallExpr(nodeName, clock2, clock1);
clockAssertion = LustreExprFactory.makeANDExpr(clockAssertion, nodeCall);
}
}
}
return clockAssertion;
}
use of com.rockwellcollins.atc.agree.analysis.AgreeException in project AGREE by loonwerks.
the class AgreeASTBuilder method portToAgreeVar.
private void portToAgreeVar(List<AgreeVar> outputs, List<AgreeVar> inputs, FeatureInstance feature, List<AgreeStatement> assumptions, List<AgreeStatement> guarantees) {
Feature dataFeature = feature.getFeature();
NamedElement dataClass;
if (dataFeature instanceof DataPort) {
DataPort dataPort = (DataPort) dataFeature;
dataClass = dataPort.getDataFeatureClassifier();
} else if (dataFeature instanceof EventDataPort) {
EventDataPort eventDataPort = (EventDataPort) dataFeature;
dataClass = eventDataPort.getDataFeatureClassifier();
} else {
dataClass = null;
}
String name = feature.getName();
boolean isEvent = feature.getCategory() == FeatureCategory.EVENT_DATA_PORT || feature.getCategory() == FeatureCategory.EVENT_PORT;
if (isEvent) {
AgreeVar var = new AgreeVar(name + eventSuffix, NamedType.BOOL, feature.getFeature(), feature.getComponentInstance(), feature);
switch(feature.getDirection()) {
case IN:
inputs.add(var);
break;
case OUT:
outputs.add(var);
break;
default:
throw new AgreeException("Unable to reason about bi-directional event port: " + dataFeature.getQualifiedName());
}
}
if (dataClass == null) {
// we do not reason about this type
return;
}
AgreeTypeSystem.TypeDef td = AgreeTypeSystem.inferFromNamedElement(dataFeature);
Type type = symbolTable.updateLustreTypeMap(td);
if (type == null) {
// we do not reason about this type
return;
}
AgreeVar agreeVar = new AgreeVar(name, type, feature.getFeature(), feature.getComponentInstance(), feature);
switch(feature.getDirection()) {
case IN:
inputs.add(agreeVar);
if (dataClass instanceof DataClassifier) {
List<Expr> constraints = getConstraintsFromTypeDef(name, td);
if (!constraints.isEmpty()) {
assumptions.add(getDataClassifierTypePredicate(feature.getName(), constraints, dataFeature));
}
}
break;
case OUT:
outputs.add(agreeVar);
if (dataClass instanceof DataClassifier) {
List<Expr> constraints = getConstraintsFromTypeDef(name, td);
if (!constraints.isEmpty()) {
guarantees.add(getDataClassifierTypePredicate(feature.getName(), constraints, dataFeature));
}
}
break;
default:
throw new AgreeException("Unable to reason about bi-directional event port: " + dataFeature.getQualifiedName());
}
}
Aggregations