Search in sources :

Example 21 with DataType

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

the class VDM2Lustre method visit.

public void visit(NodeBody nodeBody, LustreProgram program) {
    for (VariableDeclaration var : nodeBody.getVariableDeclaration()) {
        DataType data_type = var.getDataType();
        String user_defined_type = null;
        if (data_type != null) {
            user_defined_type = data_type.getUserDefinedType();
        }
        if (user_defined_type != null) {
            // user_defined_type = user_defined_type + "_Impl";
            boolean implemented_type = typeDeclarations.containsKey(user_defined_type);
            if (implemented_type) {
                data_type.setUserDefinedType(user_defined_type);
            }
        }
    }
    for (NodeEquation node_equation : nodeBody.getEquation()) {
        visit(node_equation);
    }
// Update Expression related to Events
// for (NodeEquation node_equation : nodeBody.getEquation()) {
// visitNodeEq(node_equation);
// }
}
Also used : NodeEquation(verdict.vdm.vdm_lustre.NodeEquation) DataType(verdict.vdm.vdm_data.DataType) VariableDeclaration(verdict.vdm.vdm_lustre.VariableDeclaration)

Example 22 with DataType

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

the class VDM2Lustre method getEventType.

protected DataType getEventType(DataType dataType, LustreProgram lustreProgram) {
    // LustreProgram lustreProgram = vdm_model.getDataflowCode();
    DataType eventType = new DataType();
    TypeDeclaration eventTypeDeclaration = defineEventDeclaration(dataType);
    String eventTypeName = eventTypeDeclaration.getName();
    eventType.setUserDefinedType(eventTypeName);
    if (!typeDeclarations.containsKey(eventTypeName)) {
        typeDeclarations.put(eventTypeName, eventTypeDeclaration);
        lustreProgram.getTypeDeclaration().add(eventTypeDeclaration);
    }
    return eventType;
}
Also used : DataType(verdict.vdm.vdm_data.DataType) TypeDeclaration(verdict.vdm.vdm_data.TypeDeclaration)

Example 23 with DataType

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

the class VDM2Lustre method visit.

// Event Ports
public void visit(Port port, LustreProgram lustreProgram) {
    // Print Event Ports.
    if (port.isEvent() != null && port.isEvent()) {
        DataType dataType = port.getType();
        DataType eventType = getEventType(dataType, lustreProgram);
        port.setType(eventType);
    }
}
Also used : DataType(verdict.vdm.vdm_data.DataType)

Example 24 with DataType

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

the class VerdictLustreListener method exitArrayType.

/**
 * Extract an array type.
 */
@Override
public void exitArrayType(LustreParser.ArrayTypeContext ctx) {
    ArrayType arrayType = new ArrayType();
    arrayType.setDataType(ctx.type().dataType);
    arrayType.setDimension(ctx.expr().getText());
    ctx.dataType = new DataType();
    ctx.dataType.setArrayType(arrayType);
}
Also used : ArrayType(verdict.vdm.vdm_data.ArrayType) DataType(verdict.vdm.vdm_data.DataType)

Example 25 with DataType

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

the class VerdictLustreListener method exitSubrangeType.

/**
 * Extract a subrange type.
 */
@Override
public void exitSubrangeType(LustreParser.SubrangeTypeContext ctx) {
    SubrangeType subrangeType = new SubrangeType();
    subrangeType.setLowerBound(ctx.bound(0).getText());
    subrangeType.setType("int");
    subrangeType.setUpperBound(ctx.bound(1).getText());
    ctx.dataType = new DataType();
    ctx.dataType.setSubrangeType(subrangeType);
}
Also used : SubrangeType(verdict.vdm.vdm_data.SubrangeType) DataType(verdict.vdm.vdm_data.DataType)

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