Search in sources :

Example 6 with ConstantDeclaration

use of verdict.vdm.vdm_lustre.ConstantDeclaration in project VERDICT by ge-high-assurance.

the class VerdictLustreListener method exitRecordProjectionExpr.

/**
 * Extract a record projection expression.
 */
@Override
public void exitRecordProjectionExpr(LustreParser.RecordProjectionExprContext ctx) {
    RecordProjection recordProjection = new RecordProjection();
    if (ctx.ID() != null) {
        recordProjection.setFieldId(ctx.ID().getText());
    }
    if (ctx.expr() != null) {
        recordProjection.setRecordReference(ctx.expr().expression);
        String identifier = ctx.expr().expression.getIdentifier();
        if (identifier != null) {
            ConstantDeclaration constantDeclaration = constantDeclarations.get(identifier);
            if (constantDeclaration != null) {
                Expression definition = constantDeclaration.getDefinition();
                if (definition != null) {
                    RecordLiteral recordLiteral = definition.getRecordLiteral();
                    if (recordLiteral != null) {
                        recordProjection.setRecordType(recordLiteral.getRecordType());
                    }
                }
            }
        }
    }
    ctx.expression = new Expression();
    ctx.expression.setRecordProjection(recordProjection);
}
Also used : RecordLiteral(verdict.vdm.vdm_lustre.RecordLiteral) Expression(verdict.vdm.vdm_lustre.Expression) RecordProjection(verdict.vdm.vdm_lustre.RecordProjection) ConstantDeclaration(verdict.vdm.vdm_lustre.ConstantDeclaration)

Example 7 with ConstantDeclaration

use of verdict.vdm.vdm_lustre.ConstantDeclaration in project VERDICT by ge-high-assurance.

the class VerdictLustreListener method exitOneConstDecl.

/**
 * Extract a constant declaration.
 */
@Override
public void exitOneConstDecl(LustreParser.OneConstDeclContext ctx) {
    LustreProgram program = model.getDataflowCode();
    ctx.ID().forEach(id -> {
        ConstantDeclaration constantDeclaration = new ConstantDeclaration();
        if (ctx.type() != null) {
            constantDeclaration.setDataType(ctx.type().dataType);
        }
        if (ctx.expr() != null) {
            constantDeclaration.setDefinition(ctx.expr().expression);
        }
        String name = id.getText();
        constantDeclaration.setName(name);
        constantDeclarations.put(name, constantDeclaration);
        program.getConstantDeclaration().add(constantDeclaration);
    });
}
Also used : LustreProgram(verdict.vdm.vdm_lustre.LustreProgram) ConstantDeclaration(verdict.vdm.vdm_lustre.ConstantDeclaration)

Example 8 with ConstantDeclaration

use of verdict.vdm.vdm_lustre.ConstantDeclaration in project VERDICT by ge-high-assurance.

the class PrettyPrinter method visit.

public void visit(NodeBody nodeBody) {
    sb.append("let");
    sb.append(NL);
    if (nodeBody.getVariableDeclaration().size() > 0) {
        sb.append("var");
        sb.append(NL);
    }
    for (VariableDeclaration var : nodeBody.getVariableDeclaration()) {
        visit(var);
        sb.append(NL);
        sb.append(";");
    }
    for (ConstantDeclaration constant : nodeBody.getConstantDeclaration()) {
        sb.append("const");
        visit(constant);
        sb.append(NL);
        sb.append(";");
    }
    for (Expression expr : nodeBody.getAssertion()) {
        visit(expr);
    }
    for (NodeEquation neq : nodeBody.getEquation()) {
        visit(neq);
    }
    for (NodeProperty property : nodeBody.getProperty()) {
        visit(property);
    }
    sb.append("tel");
}
Also used : NodeEquation(verdict.vdm.vdm_lustre.NodeEquation) Expression(verdict.vdm.vdm_lustre.Expression) NodeProperty(verdict.vdm.vdm_lustre.NodeProperty) ConstantDeclaration(verdict.vdm.vdm_lustre.ConstantDeclaration) VariableDeclaration(verdict.vdm.vdm_lustre.VariableDeclaration)

Example 9 with ConstantDeclaration

use of verdict.vdm.vdm_lustre.ConstantDeclaration in project VERDICT by ge-high-assurance.

the class Agree2Vdm method translateConstStatementImpl.

private ConstantDeclaration translateConstStatementImpl(ConstStatementImpl constStmtImpl, HashSet<String> dataTypeDecl, HashSet<String> nodeDecl, Model model) {
    ConstantDeclaration vdmConstDeclaration = new ConstantDeclaration();
    vdmConstDeclaration.setName(constStmtImpl.getName());
    vdmConstDeclaration.setDefinition(getVdmExpressionFromAgreeExpression(constStmtImpl.getExpr(), dataTypeDecl, nodeDecl, model));
    vdmConstDeclaration.setDataType(getVdmTypeFromAgreeType(constStmtImpl.getType(), dataTypeDecl, model));
    return vdmConstDeclaration;
}
Also used : ConstantDeclaration(verdict.vdm.vdm_lustre.ConstantDeclaration)

Aggregations

ConstantDeclaration (verdict.vdm.vdm_lustre.ConstantDeclaration)9 Expression (verdict.vdm.vdm_lustre.Expression)5 LustreProgram (verdict.vdm.vdm_lustre.LustreProgram)4 ComponentType (verdict.vdm.vdm_model.ComponentType)4 ComponentImpl (verdict.vdm.vdm_model.ComponentImpl)3 PropertyExpression (org.osate.aadl2.PropertyExpression)2 SystemType (org.osate.aadl2.SystemType)2 ContractItem (verdict.vdm.vdm_lustre.ContractItem)2 AgreeContract (com.rockwellcollins.atc.agree.agree.AgreeContract)1 AgreeContractSubclause (com.rockwellcollins.atc.agree.agree.AgreeContractSubclause)1 Arg (com.rockwellcollins.atc.agree.agree.Arg)1 AssumeStatement (com.rockwellcollins.atc.agree.agree.AssumeStatement)1 BinaryExpr (com.rockwellcollins.atc.agree.agree.BinaryExpr)1 BoolLitExpr (com.rockwellcollins.atc.agree.agree.BoolLitExpr)1 CallExpr (com.rockwellcollins.atc.agree.agree.CallExpr)1 ConstStatement (com.rockwellcollins.atc.agree.agree.ConstStatement)1 DoubleDotRef (com.rockwellcollins.atc.agree.agree.DoubleDotRef)1 EnumLitExpr (com.rockwellcollins.atc.agree.agree.EnumLitExpr)1 EqStatement (com.rockwellcollins.atc.agree.agree.EqStatement)1 EventExpr (com.rockwellcollins.atc.agree.agree.EventExpr)1