Search in sources :

Example 1 with NodeParameter

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");
        }
    }
}
Also used : Pattern(java.util.regex.Pattern) PortMode(verdict.vdm.vdm_model.PortMode) NodeParameter(verdict.vdm.vdm_lustre.NodeParameter) Matcher(java.util.regex.Matcher) DataType(verdict.vdm.vdm_data.DataType)

Example 2 with NodeParameter

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;
}
Also used : ContractBuilder(edu.uiowa.cs.clc.kind2.lustre.ContractBuilder) NodeParameter(verdict.vdm.vdm_lustre.NodeParameter)

Example 3 with NodeParameter

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);
    });
}
Also used : NodeParameter(verdict.vdm.vdm_lustre.NodeParameter)

Example 4 with 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);
}
Also used : NodeParameter(verdict.vdm.vdm_lustre.NodeParameter) ContractSpec(verdict.vdm.vdm_lustre.ContractSpec)

Example 5 with NodeParameter

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);
    }
// }
}
Also used : NodeParameter(verdict.vdm.vdm_lustre.NodeParameter) NodeBody(verdict.vdm.vdm_lustre.NodeBody) ContractSpec(verdict.vdm.vdm_lustre.ContractSpec)

Aggregations

NodeParameter (verdict.vdm.vdm_lustre.NodeParameter)6 ContractSpec (verdict.vdm.vdm_lustre.ContractSpec)2 NodeBody (verdict.vdm.vdm_lustre.NodeBody)2 Arg (com.rockwellcollins.atc.agree.agree.Arg)1 NodeBodyExpr (com.rockwellcollins.atc.agree.agree.NodeBodyExpr)1 NodeEq (com.rockwellcollins.atc.agree.agree.NodeEq)1 NodeStmt (com.rockwellcollins.atc.agree.agree.NodeStmt)1 NodeEqImpl (com.rockwellcollins.atc.agree.agree.impl.NodeEqImpl)1 ContractBuilder (edu.uiowa.cs.clc.kind2.lustre.ContractBuilder)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 DataType (verdict.vdm.vdm_data.DataType)1 LustreProgram (verdict.vdm.vdm_lustre.LustreProgram)1 Node (verdict.vdm.vdm_lustre.Node)1 NodeEquation (verdict.vdm.vdm_lustre.NodeEquation)1 NodeEquationLHS (verdict.vdm.vdm_lustre.NodeEquationLHS)1 PortMode (verdict.vdm.vdm_model.PortMode)1