use of com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming in project AGREE by loonwerks.
the class TestCaseGeneratorMenuListener method addViewTestCaseMenu.
private void addViewTestCaseMenu(IMenuManager manager, AnalysisResult result) {
final Counterexample cex = getCounterexample(result);
TcgExtractorRegistry tcgReg = (TcgExtractorRegistry) ExtensionRegistry.getRegistry(ExtensionRegistry.TCG_EXTRACTOR_EXT_ID);
List<TcgExtractor> extractors = tcgReg.getTcgExtractors();
if (cex != null) {
final String cexType = getCounterexampleType(result);
final Layout layout = linker.getLayout(result.getParent());
final Renaming renaming = linker.getRenaming(result.getParent());
final Map<String, EObject> refMap = ((TcgRenaming) renaming).getTcgRefMap();
final Counterexample translatedCex = AgreeMenuListener.translateCounterexampleArrayIndices(cex);
MenuManager sub = new MenuManager("View " + cexType + "Test Case in");
manager.add(sub);
sub.add(new Action("Console") {
@Override
public void run() {
viewCexConsole(translatedCex, layout, refMap, (TcgRenaming) renaming);
}
});
sub.add(new Action("Eclipse") {
@Override
public void run() {
viewCexEclipse(translatedCex, layout, refMap);
}
});
sub.add(new Action("Spreadsheet") {
@Override
public void run() {
viewCexSpreadsheet(translatedCex, layout);
}
});
// send counterexamples to external plugins
PropertyResult pr = (PropertyResult) result;
EObject property = refMap.get(pr.getName());
ComponentImplementation compImpl = linker.getComponent(result.getParent());
for (TcgExtractor ex : extractors) {
sub.add(new Action(ex.getDisplayText()) {
@Override
public void run() {
ex.receiveCex(compImpl, property, translatedCex, refMap);
}
});
}
}
}
use of com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming in project AGREE by loonwerks.
the class TestCaseGeneratorMenuListener method addResultsLinkingMenu.
private void addResultsLinkingMenu(IMenuManager manager, AnalysisResult result) {
if (result instanceof PropertyResult) {
PropertyResult pr = (PropertyResult) result;
Map<String, EObject> refMap = ((TcgRenaming) linker.getRenaming(result.getParent())).getTcgRefMap();
if (refMap != null) {
EObject property = refMap.get(pr.getName());
if (property instanceof GuaranteeStatement) {
manager.add(createHyperlinkAction("Go To Guarantee", property));
}
if (property instanceof LemmaStatement) {
manager.add(createHyperlinkAction("Go To Lemma", property));
}
if (property instanceof AssumeStatement) {
manager.add(createHyperlinkAction("Go To Assumption", property));
}
if (property instanceof CallExpr) {
manager.add(createHyperlinkAction("Go To Node Call", property));
}
}
}
}
use of com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming in project AGREE by loonwerks.
the class TestSuiteMenuListener method addViewTestCaseMenu.
private void addViewTestCaseMenu(IMenuManager manager, TestCase testCase) {
final Counterexample cex = testCase.getCex();
TcgExtractorRegistry tcgReg = (TcgExtractorRegistry) ExtensionRegistry.getRegistry(ExtensionRegistry.TCG_EXTRACTOR_EXT_ID);
List<TcgExtractor> extractors = tcgReg.getTcgExtractors();
if (cex != null) {
/*
* TODO: getCounterexampleType?
*/
// final String cexType = getCounterexampleType(result);
final String cexType = "";
final Layout layout = linker.getLayout(result);
final Renaming renaming = linker.getRenaming(result);
final Map<String, EObject> refMap = ((TcgRenaming) linker.getRenaming(result)).getTcgRefMap();
final Counterexample translatedCex = AgreeMenuListener.translateCounterexampleArrayIndices(cex);
MenuManager sub = new MenuManager("View " + cexType + "Test Case in");
manager.add(sub);
sub.add(new Action("Console") {
@Override
public void run() {
viewCexConsole(translatedCex, layout, refMap, (TcgRenaming) renaming);
}
});
sub.add(new Action("Eclipse") {
@Override
public void run() {
viewCexEclipse(translatedCex, layout, refMap);
}
});
sub.add(new Action("Spreadsheet") {
@Override
public void run() {
viewCexSpreadsheet(translatedCex, layout);
}
});
// send counterexamples to external plugins
EObject property = refMap.get(testCase.getName());
ComponentImplementation compImpl = linker.getComponent(result);
for (TcgExtractor ex : extractors) {
sub.add(new Action(ex.getDisplayText()) {
@Override
public void run() {
ex.receiveCex(compImpl, property, translatedCex, refMap);
}
});
}
}
}
use of com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming 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.tcg.obligations.ufc.TcgRenaming in project AGREE by loonwerks.
the class VerifyHandler method doAnalysis.
protected IStatus doAnalysis(final Element root, final IProgressMonitor monitor) {
Thread analysisThread = new Thread() {
@Override
public void run() {
activateTerminateHandler(monitor);
KindApi api = PreferencesUtil.getKindApi();
while (!queue.isEmpty() && !monitor.isCanceled()) {
JKindResult result = queue.peek();
NullProgressMonitor subMonitor = new NullProgressMonitor();
monitorRef.set(subMonitor);
TcgRenaming tcgRenaming = (TcgRenaming) linker.getRenaming(result);
Program ufcProgram = constructUfcProgram(linker.getProgram(result), tcgRenaming);
ufcProgram.getMainNode().properties.forEach(p -> result.addProperty(p));
writeIntermediateFiles(linker.getProgram(result), ufcProgram);
try {
System.out.println("Calling jkind...");
api.execute(ufcProgram, result, monitor);
System.out.println("executed API...");
TestSuite testSuite = TestSuiteUtils.testSuiteFromJKindResult(result, linker.getComponent(result).getQualifiedName(), result.getName(), result.getText(), tcgRenaming);
emitResult(testSuite);
// showSuiteView(testSuite, linker);
} catch (JKindException e) {
System.out.println(result.getText());
System.out.println("******** Error Occurred: HERE IS THE LUSTRE ********");
System.out.println(linker.getProgram(result));
break;
} finally {
deactivateTerminateHandler();
System.out.println("UFC generation complete");
}
queue.remove();
}
}
};
analysisThread.start();
return Status.OK_STATUS;
}
Aggregations