Search in sources :

Example 16 with DataType

use of verdict.vdm.vdm_data.DataType in project VERDICT by ge-high-assurance.

the class PrettyPrinter method visit.

public void visit(VariableDeclaration var) {
    String var_name = var.getName();
    sb.append(var_name);
    sb.append(" : ");
    DataType dataType = var.getDataType();
    sb.append(dataType);
}
Also used : DataType(verdict.vdm.vdm_data.DataType)

Example 17 with DataType

use of verdict.vdm.vdm_data.DataType in project VERDICT by ge-high-assurance.

the class VerdictLustreListener method exitRealType.

/**
 * Extract a plain real type.
 */
@Override
public void exitRealType(LustreParser.RealTypeContext ctx) {
    ctx.dataType = new DataType();
    ctx.dataType.setPlainType(PlainType.REAL);
}
Also used : DataType(verdict.vdm.vdm_data.DataType)

Example 18 with DataType

use of verdict.vdm.vdm_data.DataType 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 19 with DataType

use of verdict.vdm.vdm_data.DataType in project VERDICT by ge-high-assurance.

the class VDM2Lustre method getEventrecord.

protected RecordType getEventrecord(String userDefineType) {
    // Define a Record
    RecordType eventRecord = new RecordType();
    // is_present: bool
    RecordField eventField = new RecordField();
    DataType boolType = new DataType();
    boolType.setPlainType(PlainType.BOOL);
    eventField.setName("is_present");
    eventField.setType(boolType);
    eventRecord.getRecordField().add(eventField);
    // value: UserDefined
    if (userDefineType != null) {
        RecordField eventValue = new RecordField();
        DataType valueType = new DataType();
        valueType.setUserDefinedType(userDefineType);
        eventValue.setName("value");
        eventValue.setType(valueType);
        eventRecord.getRecordField().add(eventValue);
    }
    return eventRecord;
}
Also used : RecordField(verdict.vdm.vdm_data.RecordField) RecordType(verdict.vdm.vdm_data.RecordType) DataType(verdict.vdm.vdm_data.DataType)

Example 20 with DataType

use of verdict.vdm.vdm_data.DataType in project VERDICT by ge-high-assurance.

the class VDMInstrumentor method add_vars_assume.

protected SymbolDefinition add_vars_assume(String var, List<String> connections) {
    SymbolDefinition var_dec = new SymbolDefinition();
    Expression var_expr = new Expression();
    Stack<Expression> var_stack = new Stack<Expression>();
    for (String con : connections) {
        Expression expr = new Expression();
        expr.setIdentifier(con);
        var_stack.push(expr);
    }
    if (!var_stack.isEmpty()) {
        var_expr = or_expr(var_stack);
    }
    if (var_expr == null) {
        var_expr = new Expression();
        var_expr.setIdentifier(var);
    }
    var_dec.setDefinition(var_expr);
    var_dec.setName(var);
    DataType dataType = new DataType();
    dataType.setPlainType(PlainType.BOOL);
    var_dec.setDataType(dataType);
    return var_dec;
}
Also used : Expression(verdict.vdm.vdm_lustre.Expression) DataType(verdict.vdm.vdm_data.DataType) SymbolDefinition(verdict.vdm.vdm_lustre.SymbolDefinition) Stack(java.util.Stack)

Aggregations

DataType (verdict.vdm.vdm_data.DataType)26 Expression (verdict.vdm.vdm_lustre.Expression)6 RecordType (verdict.vdm.vdm_data.RecordType)4 RecordField (verdict.vdm.vdm_data.RecordField)3 ArrayList (java.util.ArrayList)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 TypeDeclaration (verdict.vdm.vdm_data.TypeDeclaration)2 ContractItem (verdict.vdm.vdm_lustre.ContractItem)2 NodeEquation (verdict.vdm.vdm_lustre.NodeEquation)2 SymbolDefinition (verdict.vdm.vdm_lustre.SymbolDefinition)2 VariableDeclaration (verdict.vdm.vdm_lustre.VariableDeclaration)2 CompInstancePort (verdict.vdm.vdm_model.CompInstancePort)2 Port (verdict.vdm.vdm_model.Port)2 PortMode (verdict.vdm.vdm_model.PortMode)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Stack (java.util.Stack)1 ArrayType (verdict.vdm.vdm_data.ArrayType)1