use of jkind.lustre.Type in project AGREE by loonwerks.
the class AgreeUtils method getLustreTypes.
public static List<TypeDef> getLustreTypes(AgreeProgram agreeProgram) {
List<TypeDef> types = new ArrayList<>();
for (Type type : agreeProgram.globalTypes) {
String typeName;
if (type instanceof RecordType) {
typeName = ((RecordType) type).id;
} else if (type instanceof EnumType) {
typeName = ((EnumType) type).id;
} else {
throw new AgreeException("Unable to handle type of type '" + type.getClass() + "'");
}
types.add(new TypeDef(typeName, type));
}
// add synonym types
types.addAll(getTypeSynonmyms());
return types;
}
use of jkind.lustre.Type in project AGREE by loonwerks.
the class SaveHandler method doAnalysis.
protected IStatus doAnalysis(final IProgressMonitor monitor) {
Thread analysisThread = new Thread() {
String filePath;
TestSuiteView view;
@Override
public void run() {
activateTerminateHandler(monitor);
Shell activeShell = getWindow().getShell();
System.out.println("Saving test suite...");
syncExec(() -> {
view = (TestSuiteView) getWindow().getActivePage().findView(TestSuiteView.ID);
});
if (view != null) {
TestSuite suite = view.getInput();
if (suite != null) {
System.out.println("Bringing up file dialog...");
syncExec(() -> {
FileDialog dialog = new FileDialog(activeShell, SWT.SAVE);
if (startingFilePath != null) {
dialog.setFileName(startingFilePath);
}
String[] filterNames = new String[] { "XML Files", "All Files (*)" };
String[] filterExtensions = new String[] { "*.xml", "*" };
dialog.setFilterNames(filterNames);
dialog.setFilterExtensions(filterExtensions);
dialog.setOverwrite(true);
filePath = dialog.open();
});
if (filePath != null) {
startingFilePath = filePath;
System.out.println("filePath: " + filePath);
TestSuiteLinker linker = (TestSuiteLinker) view.getMenuListener().getLinker();
AnalysisResult result = view.getMenuListener().getAnalysisResult();
List<Type> types = linker.getAgreeProgram(result).globalTypes;
try {
TcgXmlWriter tcgXmlWriter = new TcgXmlWriter(filePath, types, false);
tcgXmlWriter.writeSuite(suite);
System.out.println("This would be where test suite written to " + filePath);
} catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
}
// TcgXmlWriter consoleWriter = new TcgXmlWriter(null, null, true);
// consoleWriter.writeSuite(suite);
}
} else {
syncExec(() -> {
MessageBox mb = new MessageBox(activeShell);
mb.setMessage("Error: no test suite loaded. Please open a test suite\n");
mb.open();
});
}
} else {
syncExec(() -> {
MessageBox mb = new MessageBox(activeShell);
mb.setMessage("Error: test suite view needs to be active in order to save.\n");
mb.open();
});
}
deactivateTerminateHandler();
}
};
analysisThread.start();
return Status.OK_STATUS;
}
use of jkind.lustre.Type in project AGREE by loonwerks.
the class GenerateUfcObligationsVisitor method addBoundaryValueTests.
// /////////////////////////////////////////////////////////////////////////
//
// Note: this is not really correct; we want a value that is *less than or equal to*
// the boundary distance, not *exactly* at the boundary distance. For integers with
// delta 1, it is the same, but it should be fixed for floating point numbers. Note
// also that to write these tests, we need to introduce additional inputs to
// represent the deltas.
//
// /////////////////////////////////////////////////////////////////////////
protected void addBoundaryValueTests(Expr e, ObligationSet s) {
if (e instanceof BinaryExpr && this.generateBoundaryValueTests) {
Expr rightDelta = null;
BinaryExpr be = (BinaryExpr) e;
if (be.op == BinaryOp.EQUAL || be.op == BinaryOp.GREATER || be.op == BinaryOp.GREATEREQUAL || be.op == BinaryOp.LESS || be.op == BinaryOp.LESSEQUAL) {
Type t = getType(be.left);
if (t == NamedType.INT) {
rightDelta = new IntExpr(BigInteger.valueOf(this.intDelta));
} else if (t == NamedType.REAL) {
rightDelta = new RealExpr(BigDecimal.valueOf(this.realDelta));
}
// Add tests at the boundary.
if (rightDelta != null) {
s.add(new BinaryExpr(be.left, BinaryOp.EQUAL, new BinaryExpr(be.right, BinaryOp.PLUS, rightDelta)));
s.add(new BinaryExpr(be.left, BinaryOp.EQUAL, rightDelta));
s.add(new BinaryExpr(be.left, BinaryOp.EQUAL, new BinaryExpr(be.right, BinaryOp.MINUS, rightDelta)));
}
}
}
}
Aggregations