use of verdict.vdm.vdm_data.DataType in project VERDICT by ge-high-assurance.
the class VDM2Lustre method defaultType.
private DataType defaultType() {
DataType dataType = new DataType();
dataType.setPlainType(PlainType.INT);
return dataType;
}
use of verdict.vdm.vdm_data.DataType in project VERDICT by ge-high-assurance.
the class VDM2Lustre method visit.
public void visit(ContractSpec contractSpec) {
for (SymbolDefinition symbol : contractSpec.getSymbol()) {
DataType data_type = symbol.getDataType();
String user_defined_type = data_type.getUserDefinedType();
if (user_defined_type != null) {
user_defined_type = user_defined_type.replace(".", "_dot_");
user_defined_type = user_defined_type.replace("::", "_double_colon_");
boolean implemented_type = typeDeclarations.containsKey(user_defined_type);
if (implemented_type) {
data_type.setUserDefinedType(user_defined_type);
}
}
Expression expr = symbol.getDefinition();
expr = visitExpression(expr);
symbol.setDefinition(expr);
recordLiteral(expr);
}
String mbas_fml = "((.+):(.+):(.+))|((.+):Formula$)";
Pattern fml_pattern = Pattern.compile(mbas_fml);
List<ContractItem> mbas_guarantee = new ArrayList<ContractItem>();
// guarantee
for (ContractItem contractItem : contractSpec.getGuarantee()) {
if (contractItem.getName() != null) {
Matcher m = fml_pattern.matcher(contractItem.getName());
if (m.find()) {
mbas_guarantee.add(contractItem);
} else {
// Normal Formula
visit(contractItem);
}
} else {
visit(contractItem);
}
}
// remove MBAS guarantee
contractSpec.getGuarantee().removeAll(mbas_guarantee);
}
use of verdict.vdm.vdm_data.DataType in project VERDICT by ge-high-assurance.
the class VDM2Lustre method visit.
public void visit(ConstantDeclaration constantDeclaration) {
// String identifier = constantDeclaration.getName();
DataType data_type = constantDeclaration.getDataType();
String user_defined_type = data_type.getUserDefinedType();
if (user_defined_type != null) {
user_defined_type = user_defined_type.replace(".", "_dot_");
user_defined_type = user_defined_type.replace("::", "_double_colon_");
boolean implemented_type = typeDeclarations.containsKey(user_defined_type);
if (implemented_type) {
data_type.setUserDefinedType(user_defined_type);
}
Expression expr = constantDeclaration.getDefinition();
recordLiteral(expr);
}
}
use of verdict.vdm.vdm_data.DataType in project VERDICT by ge-high-assurance.
the class VDM2Lustre method visit.
// Copying Type Declaration.
public void visit(TypeDeclaration typeDeclaration, LustreProgram program) {
String identifier = typeDeclaration.getName();
// Renaming dot[.] in Type Declaration Identifier.
identifier = identifier.replace(".", "_dot_");
identifier = identifier.replace("::", "_double_colon_");
typeDeclaration.setName(identifier);
DataType data_type = typeDeclaration.getDefinition();
if (data_type != null) {
RecordType record_type = data_type.getRecordType();
if (record_type != null) {
// identifier = identifier + "_Impl";
List<RecordField> record_fields = record_type.getRecordField();
for (RecordField record_field : record_fields) {
// String identifier = record_field.getName();
data_type = record_field.getType();
if (data_type == null) {
data_type = defaultType();
record_field.setType(data_type);
}
String user_defined_type = data_type.getUserDefinedType();
if (user_defined_type != null) {
String updated_defined_type = user_defined_type.replace(".", "_dot_");
updated_defined_type = updated_defined_type.replace("::", "_double_colon_");
// for (TypeDeclaration type_declaration :
// program.getTypeDeclaration()) {
// if
// (user_defined_type.equals(type_declaration.getName())) {
data_type.setUserDefinedType(updated_defined_type);
// }
// }
}
}
// Updating TypeName_Impl
typeDeclaration.setName(identifier);
}
}
typeDeclarations.put(identifier, typeDeclaration);
program.getTypeDeclaration().add(typeDeclaration);
}
use of verdict.vdm.vdm_data.DataType in project VERDICT by ge-high-assurance.
the class PrettyPrinter method visit.
public void visit(ConstantDeclaration constant) {
String var_name = constant.getName();
sb.append(var_name);
sb.append(" : ");
DataType dataType = constant.getDataType();
sb.append(dataType);
}
Aggregations