Search in sources :

Example 51 with Expr

use of com.rockwellcollins.atc.agree.agree.Expr in project AMASE by loonwerks.

the class SafetyValidator method checkIntervalEqStatement.

/**
 * Interval eq stmts:
 * Checks:
 * - Only primitive types supported for intervals.
 * - The interval type matches high and low parameters of interval.
 * - High and low parameters of interval are same type.
 * @param intervalEq
 */
@Check(CheckType.FAST)
public void checkIntervalEqStatement(IntervalEq intervalEq) {
    Arg arg = intervalEq.getLhs_int();
    String typeName = "";
    SafetyInterval interval = intervalEq.getInterv();
    Expr low = interval.getLow();
    Expr high = interval.getHigh();
    if (arg.getType() instanceof PrimType) {
        typeName = ((PrimType) arg.getType()).getName();
        if (typeName.equalsIgnoreCase("bool")) {
            error(arg, "Boolean intervals are not allowed. Only real or int intervals are supported.");
        }
    } else {
        error(arg, "The only types that are supported for intervals are real and int.");
    }
    // Negative values are allowed: hence the check for UnaryExpr
    if (low instanceof UnaryExpr) {
        UnaryExpr unex_low = (UnaryExpr) low;
        if (!(unex_low.getExpr() instanceof IntLitExpr) & !(unex_low.getExpr() instanceof RealLitExpr)) {
            error(low, "Only real and integer types are supported for intervals.");
        }
        if (high instanceof UnaryExpr) {
            UnaryExpr unex_high = (UnaryExpr) high;
            if (!(unex_high.getExpr() instanceof IntLitExpr) & !(unex_high.getExpr() instanceof RealLitExpr)) {
                error(high, "Only real and integer types are supported for intervals.");
            }
            testLowAndHighTypes(intervalEq, typeName, unex_low.getExpr(), unex_high.getExpr());
        } else {
            testLowAndHighTypes(intervalEq, typeName, unex_low.getExpr(), high);
        }
    } else {
        testLowAndHighTypes(intervalEq, typeName, low, high);
    }
}
Also used : RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) UnaryExpr(com.rockwellcollins.atc.agree.agree.UnaryExpr) Expr(com.rockwellcollins.atc.agree.agree.Expr) PrevExpr(com.rockwellcollins.atc.agree.agree.PrevExpr) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) Arg(com.rockwellcollins.atc.agree.agree.Arg) PrimType(com.rockwellcollins.atc.agree.agree.PrimType) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) SafetyInterval(edu.umn.cs.crisys.safety.safety.SafetyInterval) UnaryExpr(com.rockwellcollins.atc.agree.agree.UnaryExpr) Check(org.eclipse.xtext.validation.Check)

Example 52 with Expr

use of com.rockwellcollins.atc.agree.agree.Expr in project AMASE by loonwerks.

the class SetEqImpl method basicSetL1.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetL1(Expr newL1, NotificationChain msgs) {
    Expr oldL1 = l1;
    l1 = newL1;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SafetyPackage.SET_EQ__L1, oldL1, newL1);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : Expr(com.rockwellcollins.atc.agree.agree.Expr) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 53 with Expr

use of com.rockwellcollins.atc.agree.agree.Expr in project AMASE by loonwerks.

the class SafetyIntervalImpl method basicSetLow.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetLow(Expr newLow, NotificationChain msgs) {
    Expr oldLow = low;
    low = newLow;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SafetyPackage.SAFETY_INTERVAL__LOW, oldLow, newLow);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : Expr(com.rockwellcollins.atc.agree.agree.Expr) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 54 with Expr

use of com.rockwellcollins.atc.agree.agree.Expr in project AMASE by loonwerks.

the class EqValueImpl method basicSetExpr.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetExpr(Expr newExpr, NotificationChain msgs) {
    Expr oldExpr = expr;
    expr = newExpr;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SafetyPackage.EQ_VALUE__EXPR, oldExpr, newExpr);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : Expr(com.rockwellcollins.atc.agree.agree.Expr) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 55 with Expr

use of com.rockwellcollins.atc.agree.agree.Expr in project VERDICT by ge-high-assurance.

the class Agree2Vdm method translateAssumeStatement.

private ContractItem translateAssumeStatement(AssumeStatement assumeStmt, HashSet<String> dataTypeDecl, HashSet<String> nodeDecl, Model model) {
    ContractItem contractItem = new ContractItem();
    contractItem.setName(assumeStmt.getStr());
    Expr agreeExpr = assumeStmt.getExpr();
    Expression vdmlustrExpr = getVdmExpressionFromAgreeExpression(agreeExpr, dataTypeDecl, nodeDecl, model);
    contractItem.setExpression(vdmlustrExpr);
    return contractItem;
}
Also used : EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) EventExpr(com.rockwellcollins.atc.agree.agree.EventExpr) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) IfThenElseExpr(com.rockwellcollins.atc.agree.agree.IfThenElseExpr) PreExpr(com.rockwellcollins.atc.agree.agree.PreExpr) RecordLitExpr(com.rockwellcollins.atc.agree.agree.RecordLitExpr) BinaryExpr(com.rockwellcollins.atc.agree.agree.BinaryExpr) UnaryExpr(com.rockwellcollins.atc.agree.agree.UnaryExpr) Expr(com.rockwellcollins.atc.agree.agree.Expr) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) NodeBodyExpr(com.rockwellcollins.atc.agree.agree.NodeBodyExpr) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) ContractItem(verdict.vdm.vdm_lustre.ContractItem) PropertyExpression(org.osate.aadl2.PropertyExpression) Expression(verdict.vdm.vdm_lustre.Expression)

Aggregations

Expr (com.rockwellcollins.atc.agree.agree.Expr)103 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)69 BinaryExpr (com.rockwellcollins.atc.agree.agree.BinaryExpr)34 BoolLitExpr (com.rockwellcollins.atc.agree.agree.BoolLitExpr)34 IfThenElseExpr (com.rockwellcollins.atc.agree.agree.IfThenElseExpr)34 NamedElmExpr (com.rockwellcollins.atc.agree.agree.NamedElmExpr)34 RealLitExpr (com.rockwellcollins.atc.agree.agree.RealLitExpr)34 UnaryExpr (com.rockwellcollins.atc.agree.agree.UnaryExpr)34 IntLitExpr (com.rockwellcollins.atc.agree.agree.IntLitExpr)33 EventExpr (com.rockwellcollins.atc.agree.agree.EventExpr)32 PreExpr (com.rockwellcollins.atc.agree.agree.PreExpr)32 SelectionExpr (com.rockwellcollins.atc.agree.agree.SelectionExpr)32 CallExpr (com.rockwellcollins.atc.agree.agree.CallExpr)31 EnumLitExpr (com.rockwellcollins.atc.agree.agree.EnumLitExpr)31 NodeBodyExpr (com.rockwellcollins.atc.agree.agree.NodeBodyExpr)31 PrevExpr (com.rockwellcollins.atc.agree.agree.PrevExpr)31 RecordLitExpr (com.rockwellcollins.atc.agree.agree.RecordLitExpr)31 FoldLeftExpr (com.rockwellcollins.atc.agree.agree.FoldLeftExpr)30 FoldRightExpr (com.rockwellcollins.atc.agree.agree.FoldRightExpr)30 ArraySubExpr (com.rockwellcollins.atc.agree.agree.ArraySubExpr)29