use of com.rockwellcollins.atc.agree.analysis.AgreeException in project AGREE by loonwerks.
the class AgreeASTBuilder method caseGetPropertyExpr.
@Override
public Expr caseGetPropertyExpr(GetPropertyExpr expr) {
NamedElement propName = expr.getProp();
PropertyExpression propVal;
if (propName instanceof Property) {
ComponentRef cr = expr.getComponentRef();
NamedElement compName = null;
if (cr instanceof DoubleDotRef) {
compName = ((DoubleDotRef) cr).getElm();
} else if (cr instanceof ThisRef) {
compName = curInst;
}
Property prop = (Property) propName;
propVal = AgreeUtils.getPropExpression(compName, prop);
if (propVal == null) {
if (Activator.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREF_UNSPECIFIED_AADL_PROPERTIES)) {
String propInputName = unspecifiedAadlPropertyPrefix + compName.getName() + dotChar + prop.getName();
unspecifiedAadlProperties.put(propInputName, expr);
return new IdExpr(propInputName);
} else {
throw new AgreeException("Could not locate property value '" + prop.getQualifiedName() + "' in component '" + compName.getName() + "'. Is it possible " + "that a 'this' statement is used in a context in which it wasn't supposed to?" + " Analysis of unspecified AADL properties as inputs may be enabled in the AGREE preferences.");
}
}
} else {
propVal = AgreeUtils.getPropExpression((PropertyConstant) propName);
if (propVal == null) {
throw new AgreeException("Could not locate property value '" + propName.getQualifiedName());
}
}
Expr res = null;
if (propVal != null) {
if (propVal instanceof StringLiteral) {
// nodeStr += value.getValue() + ")";
throw new AgreeException("Property value for '" + propName.getQualifiedName() + "' cannot be of string type");
} else if (propVal instanceof NamedValue) {
// EnumerationLiteral enVal = (EnumerationLiteral) absVal;
throw new AgreeException("Property value for '" + propName.getQualifiedName() + "' cannot be of enumeration type");
} else if (propVal instanceof BooleanLiteral) {
BooleanLiteral value = (BooleanLiteral) propVal;
res = new BoolExpr(value.getValue());
} else if (propVal instanceof IntegerLiteral) {
IntegerLiteral value = (IntegerLiteral) propVal;
res = new IntExpr(BigInteger.valueOf((long) value.getScaledValue()));
} else {
assert (propVal instanceof RealLiteral);
RealLiteral value = (RealLiteral) propVal;
res = new RealExpr(BigDecimal.valueOf(value.getValue()));
}
}
assert (res != null);
return res;
}
use of com.rockwellcollins.atc.agree.analysis.AgreeException in project AGREE by loonwerks.
the class VerifyHandler method runJob.
@Override
protected IStatus runJob(Element root, IProgressMonitor monitor) {
EphemeralImplementationUtil implUtil = new EphemeralImplementationUtil(monitor);
// this flag is set by the rerun handler to prevent clearing the advice map
if (!calledFromRerun) {
rerunAdviceMap.clear();
}
calledFromRerun = false;
disableRerunHandler();
handlerService = getWindow().getService(IHandlerService.class);
try {
// Make sure the user selected a component implementation
ComponentImplementation ci = getComponentImplementation(root, implUtil);
SystemInstance si = getSysInstance(ci, implUtil);
AnalysisResult result;
CompositeAnalysisResult wrapper = new CompositeAnalysisResult("");
if (isRecursive()) {
if (AgreeUtils.usingKind2()) {
throw new AgreeException("Kind2 only supports monolithic verification");
}
result = buildAnalysisResult(ci.getName(), si);
wrapper.addChild(result);
result = wrapper;
} else if (isRealizability()) {
AgreeProgram agreeProgram = new AgreeASTBuilder().getAgreeProgram(si, false);
Program program = LustreAstBuilder.getRealizabilityLustreProgram(agreeProgram);
wrapper.addChild(createVerification("Realizability Check", si, program, agreeProgram, AnalysisType.Realizability));
result = wrapper;
} else {
CompositeAnalysisResult wrapperTop = new CompositeAnalysisResult("Verification for " + ci.getName());
wrapVerificationResult(si, wrapperTop);
wrapper.addChild(wrapperTop);
result = wrapper;
}
showView(result, linker);
return doAnalysis(ci, monitor);
} catch (Throwable e) {
String messages = getNestedMessages(e);
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, messages, e);
} finally {
implUtil.cleanup();
}
}
use of com.rockwellcollins.atc.agree.analysis.AgreeException in project AGREE by loonwerks.
the class VerifyHandler method getSysInstance.
protected SystemInstance getSysInstance(ComponentImplementation ci, EphemeralImplementationUtil implUtil) {
try {
AnalysisErrorReporterManager errorManager = new AnalysisErrorReporterManager(QueuingAnalysisErrorReporter.factory);
SystemInstance result = implUtil.generateEphemeralCompInstanceFromImplementation(ci);
QueuingAnalysisErrorReporter errorReporter = (QueuingAnalysisErrorReporter) errorManager.getReporter(result.eResource());
StringBuilder stringBuilder = new StringBuilder();
List<Message> instantiationMarkers = errorReporter.getErrors();
if (!instantiationMarkers.isEmpty()) {
instantiationMarkers.stream().forEach(marker -> {
stringBuilder.append(marker.message);
});
throw new AgreeException(stringBuilder.toString());
}
return result;
} catch (Exception e) {
Dialog.showError("Model Instantiate", "Error while re-instantiating the model: " + e.getMessage());
throw new AgreeException("Error Instantiating model");
}
}
use of com.rockwellcollins.atc.agree.analysis.AgreeException in project AGREE by loonwerks.
the class VerifyHandler method getComponentImplementation.
protected ComponentImplementation getComponentImplementation(Element root, EphemeralImplementationUtil implUtil) {
Classifier classifier = getOutermostClassifier(root);
if (isRealizability()) {
if (!(classifier instanceof ComponentType)) {
throw new AgreeException("Must select an AADL Component Type");
}
ComponentImplementation result;
try {
result = implUtil.generateEphemeralCompImplFromType((ComponentType) classifier);
} catch (Exception e) {
e.printStackTrace();
throw new AgreeException("Error creating component implementation.");
}
return result;
} else {
if (classifier instanceof ComponentImplementation) {
return (ComponentImplementation) classifier;
}
if (!(classifier instanceof ComponentType)) {
throw new AgreeException("Must select an AADL Component Type or Implementation");
}
ComponentType ct = (ComponentType) classifier;
List<ComponentImplementation> cis = getComponentImplementations(ct);
if (cis.size() == 0) {
throw new AgreeException("AADL Component Type has no implementation to verify");
} else if (cis.size() == 1) {
ComponentImplementation ci = cis.get(0);
Shell shell = getWindow().getShell();
String message = "User selected " + ct.getFullName() + ".\nRunning analysis on " + ci.getFullName() + " instead.";
shell.getDisplay().asyncExec(() -> MessageDialog.openInformation(shell, "Analysis information", message));
return ci;
} else {
throw new AgreeException("AADL Component Type has multiple implementations to verify: please select just one");
}
}
}
use of com.rockwellcollins.atc.agree.analysis.AgreeException in project AGREE by loonwerks.
the class VerifyRealizabilityHandler method isRealizability.
@Override
protected boolean isRealizability() {
IPreferenceStore prefs = Activator.getDefault().getPreferenceStore();
String solver = prefs.getString(PreferenceConstants.PREF_SOLVER);
switch(solver) {
case PreferenceConstants.SOLVER_Z3:
return true;
default:
throw new AgreeException("You must select Z3 as your solver to check realizability.");
}
}
Aggregations