Search in sources :

Example 6 with BinaryOperation

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

the class VDM2Lustre method recordLiteral.

public void recordLiteral(Expression expr) {
    if (expr != null) {
        RecordLiteral recordLiteral = expr.getRecordLiteral();
        if (recordLiteral != null) {
            String identifier = recordLiteral.getRecordType();
            identifier = identifier.replace(".", "_dot_");
            identifier = identifier.replace("::", "_double_colon_");
            recordLiteral.setRecordType(identifier);
            for (FieldDefinition fieldDef : recordLiteral.getFieldDefinition()) {
                expr = fieldDef.getFieldValue();
                recordLiteral(expr);
            }
        } else {
            BinaryOperation op = expr.getEqual();
            if (op == null) {
                op = expr.getNotEqual();
                if (op == null) {
                    op = expr.getAnd();
                    if (op == null) {
                        op = expr.getImplies();
                    }
                }
            }
            if (op != null) {
                Expression lhs_expr = op.getLhsOperand();
                recordLiteral(lhs_expr);
                Expression rhs_expr = op.getRhsOperand();
                recordLiteral(rhs_expr);
            }
            Expression not_expr = expr.getNot();
            if (not_expr != null) {
                recordLiteral(not_expr);
            } else {
                Expression pre_expr = expr.getPre();
                recordLiteral(pre_expr);
            }
            NodeCall nodeCall = expr.getCall();
            if (nodeCall != null) {
                for (Expression arg : nodeCall.getArgument()) {
                    recordLiteral(arg);
                }
            }
        }
    }
}
Also used : RecordLiteral(verdict.vdm.vdm_lustre.RecordLiteral) NodeCall(verdict.vdm.vdm_lustre.NodeCall) Expression(verdict.vdm.vdm_lustre.Expression) BinaryOperation(verdict.vdm.vdm_lustre.BinaryOperation) FieldDefinition(verdict.vdm.vdm_lustre.FieldDefinition)

Example 7 with BinaryOperation

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

the class VDMInstrumentor method xor_expr.

protected Expression xor_expr(String i_id, String j_id) {
    Expression amo_expr = new Expression();
    Expression expr_i = new Expression();
    expr_i.setIdentifier(i_id);
    Expression expr_j = new Expression();
    expr_j.setIdentifier(j_id);
    Expression notexpr_i = new Expression();
    notexpr_i.setNot(expr_i);
    Expression notexpr_j = new Expression();
    notexpr_j.setNot(expr_j);
    BinaryOperation or_op = new BinaryOperation();
    or_op.setLhsOperand(notexpr_i);
    or_op.setRhsOperand(notexpr_j);
    amo_expr.setOr(or_op);
    return amo_expr;
}
Also used : Expression(verdict.vdm.vdm_lustre.Expression) BinaryOperation(verdict.vdm.vdm_lustre.BinaryOperation)

Example 8 with BinaryOperation

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

the class VDMInstrumentor method and_expr.

protected Expression and_expr(Stack<Expression> expr_stack) {
    while (expr_stack.size() > 1) {
        Expression left_expr = expr_stack.pop();
        Expression right_expr = expr_stack.pop();
        BinaryOperation and_op = new BinaryOperation();
        and_op.setLhsOperand(left_expr);
        and_op.setRhsOperand(right_expr);
        Expression and_expr = new Expression();
        and_expr.setAnd(and_op);
        expr_stack.push(and_expr);
    }
    return expr_stack.pop();
}
Also used : Expression(verdict.vdm.vdm_lustre.Expression) BinaryOperation(verdict.vdm.vdm_lustre.BinaryOperation)

Aggregations

BinaryOperation (verdict.vdm.vdm_lustre.BinaryOperation)8 Expression (verdict.vdm.vdm_lustre.Expression)8 FieldDefinition (verdict.vdm.vdm_lustre.FieldDefinition)3 NodeCall (verdict.vdm.vdm_lustre.NodeCall)3 RecordLiteral (verdict.vdm.vdm_lustre.RecordLiteral)3 BigDecimal (java.math.BigDecimal)2 BigInteger (java.math.BigInteger)2 IfThenElse (verdict.vdm.vdm_lustre.IfThenElse)2 RecordProjection (verdict.vdm.vdm_lustre.RecordProjection)2 Arg (com.rockwellcollins.atc.agree.agree.Arg)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 EventExpr (com.rockwellcollins.atc.agree.agree.EventExpr)1 Expr (com.rockwellcollins.atc.agree.agree.Expr)1 IfThenElseExpr (com.rockwellcollins.atc.agree.agree.IfThenElseExpr)1 IntLitExpr (com.rockwellcollins.atc.agree.agree.IntLitExpr)1