use of verdict.vdm.vdm_lustre.NodeParameter in project VERDICT by ge-high-assurance.
the class VDM2Lustre method visit.
public void visit(Port port, Node node) {
PortMode port_mode = port.getMode();
NodeParameter node_parameter = new NodeParameter();
// Node Name
String port_name = port.getName();
node_parameter.setName(port_name);
// Node DataType
DataType dataType = port.getType();
// Change Null DataType to Integer Default Type
if (dataType == null) {
port.setType(defaultType());
}
node_parameter.setDataType(dataType);
// Node Input Parameter
if (port_mode == PortMode.IN) {
node.getInputParameter().add(node_parameter);
} else // Node OutputParameter
if (port_mode == PortMode.OUT) {
node.getOutputParameter().add(node_parameter);
// if(node.isIsImported() != null) {
String inst_cmp = "(.+)_Inst_.*";
Pattern inst_pattern = Pattern.compile(inst_cmp);
Matcher m = inst_pattern.matcher(node.getName());
if (m.matches()) {
node_parameter.setName(node_parameter.getName() + "_instrumented");
}
}
}
use of verdict.vdm.vdm_lustre.NodeParameter in project VERDICT by ge-high-assurance.
the class VDMLustre2Kind2 method visit.
/**
* Translate VDM model contract to Kind 2 Lustre contract.
*
* @param modelContract the VDM model contract
* @return the Kind 2 Lustre contract builder
*/
private static ContractBuilder visit(Contract modelContract) {
ContractBuilder cb = new ContractBuilder(modelContract.getName());
for (NodeParameter inputParam : modelContract.getInputParameter()) {
if (inputParam.isIsConstant() != null && inputParam.isIsConstant()) {
cb.createVarInput(inputParam.getName(), visit(inputParam.getDataType()));
} else {
cb.createConstInput(inputParam.getName(), visit(inputParam.getDataType()));
}
}
for (NodeParameter outputParam : modelContract.getOutputParameter()) {
cb.createVarOutput(outputParam.getName(), visit(outputParam.getDataType()));
}
cb.setContractBody(visit(modelContract.getSpecification().get(0)));
return cb;
}
use of verdict.vdm.vdm_lustre.NodeParameter in project VERDICT by ge-high-assurance.
the class VerdictLustreListener method exitParamGroup.
/**
* Extract a group of node parameters.
*/
@Override
public void exitParamGroup(LustreParser.ParamGroupContext ctx) {
ctx.nodeParameters = new ArrayList<>();
ctx.ID().forEach(id -> {
NodeParameter nodeParameter = new NodeParameter();
nodeParameter.setName(id.getText());
if (ctx.type() != null) {
nodeParameter.setDataType(ctx.type().dataType);
}
if (ctx.isConst != null) {
nodeParameter.setIsConstant(true);
}
ctx.nodeParameters.add(nodeParameter);
});
}
use of verdict.vdm.vdm_lustre.NodeParameter in project VERDICT by ge-high-assurance.
the class PrettyPrinter method visit.
// @Override
public void visit(Contract contract) {
sb.append("contract ").append(contract.getName());
sb.append(" (").append(NL);
for (NodeParameter param : contract.getInputParameter()) {
visit(param);
}
sb.append(")").append(NL);
sb.append("returns (").append(NL);
for (NodeParameter param : contract.getInputParameter()) {
visit(param);
}
sb.append(");").append(NL);
// Specifications
sb.append("let").append(NL);
for (ContractSpec contractSpec : contract.getSpecification()) {
visit(contractSpec);
}
sb.append("tel");
sb.append(NL);
}
use of verdict.vdm.vdm_lustre.NodeParameter in project VERDICT by ge-high-assurance.
the class PrettyPrinter method visit.
public void visit(Node node) {
sb.append("node ");
// if (node.isIsImported()) {
sb.append("imported ");
// }
sb.append(node.getName());
sb.append("(");
sb.append(NL);
for (NodeParameter param : node.getInputParameter()) {
visit(param);
}
sb.append(")");
sb.append(NL);
sb.append("returns (");
sb.append(NL);
for (NodeParameter param : node.getOutputParameter()) {
visit(param);
}
sb.append(");");
sb.append(NL);
ContractSpec contractSpec = node.getContract();
if (contractSpec != null) {
sb.append("(*@contract ");
visit(contractSpec);
sb.append("*)");
// sb.append(NL);
}
// if (node.isIsFunction()) {
NodeBody nodeBody = node.getBody();
if (nodeBody != null) {
// sb.append("{");
sb.append(NL);
visit(nodeBody);
// sb.append("}");
sb.append(NL);
}
// }
}
Aggregations