Search in sources :

Example 16 with DoubleDotRef

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

the class Agree2Vdm method translateAgreeDataTypeToVdmDataType.

private void translateAgreeDataTypeToVdmDataType(Type type, HashSet<String> dataTypeDecl, Model model) {
    if (type instanceof DoubleDotRef) {
        DoubleDotRef ddrefType = (DoubleDotRef) type;
        if (ddrefType.getElm() instanceof DataImplementation) {
            // if it is a AADL data implementation definition
            DataImplementation dataImplementationImpl = (DataImplementation) ddrefType.getElm();
            resolveAADLDataImplementationType(dataImplementationImpl, dataTypeDecl, model);
        } else if (ddrefType.getElm() instanceof org.osate.aadl2.DataType) {
            // if it is a AADL data implementation definition
            org.osate.aadl2.DataType aadlDataType = (org.osate.aadl2.DataType) ddrefType.getElm();
            resolveAADLDataType(aadlDataType, dataTypeDecl, model);
        } else {
            System.out.println("Unresolved data type " + ddrefType.getElm().getName() + " in doubledotref. Not AADL DataImplementation or DataType type.");
        }
    } else {
        System.out.println("Unresolved type value is " + type.toString());
    }
}
Also used : DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) DataImplementation(org.osate.aadl2.DataImplementation)

Example 17 with DoubleDotRef

use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project AGREE by loonwerks.

the class EnumLitExprImpl method basicSetEnumType.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetEnumType(DoubleDotRef newEnumType, NotificationChain msgs) {
    DoubleDotRef oldEnumType = enumType;
    enumType = newEnumType;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AgreePackage.ENUM_LIT_EXPR__ENUM_TYPE, oldEnumType, newEnumType);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef)

Example 18 with DoubleDotRef

use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project AGREE by loonwerks.

the class AgreeASTBuilder method caseCallExpr.

/*
	 * CallExpr could be a node call, a regular function call, or an uninterpreted function call.
	 * The former two cases will return a NodeCallExpr, the third case will return a FunctionCallExpr.
	 */
@Override
public Expr caseCallExpr(CallExpr expr) {
    NamedElement namedEl = expr.getRef().getElm();
    String fnName = AgreeUtils.getNodeName(namedEl);
    boolean found = false;
    for (Node node : globalNodes) {
        if (node.id.equals(fnName)) {
            found = true;
            break;
        }
    }
    if (!found) {
        for (Function function : uninterpretedFunc) {
            if (function.id.equals(fnName)) {
                found = true;
                break;
            }
        }
    }
    if (!found) {
        DoubleDotRef fn = expr.getRef();
        doSwitch(fn.getElm());
        // for dReal integration
        if (fnName.substring(0, 7).equalsIgnoreCase("dreal__")) {
            fnName = namedEl.getName();
        }
    }
    List<Expr> argResults = new ArrayList<>();
    for (com.rockwellcollins.atc.agree.agree.Expr argExpr : expr.getArgs()) {
        argResults.add(doSwitch(argExpr));
    }
    if (functionNameExists(fnName)) {
        FunctionCallExpr functionCall = new FunctionCallExpr(fnName.replace("::", "__"), argResults);
        return functionCall;
    }
    NodeCallExpr nodeCall = new NodeCallExpr(fnName.replace("::", "__"), argResults);
    return nodeCall;
}
Also used : Node(jkind.lustre.Node) ArrayList(java.util.ArrayList) Function(jkind.lustre.Function) FunctionCallExpr(jkind.lustre.FunctionCallExpr) EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) IndicesExpr(com.rockwellcollins.atc.agree.agree.IndicesExpr) TimeRiseExpr(com.rockwellcollins.atc.agree.agree.TimeRiseExpr) RecordAccessExpr(jkind.lustre.RecordAccessExpr) FlatmapExpr(com.rockwellcollins.atc.agree.agree.FlatmapExpr) TimeFallExpr(com.rockwellcollins.atc.agree.agree.TimeFallExpr) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) GetPropertyExpr(com.rockwellcollins.atc.agree.agree.GetPropertyExpr) Expr(jkind.lustre.Expr) CastExpr(jkind.lustre.CastExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) TimeOfExpr(com.rockwellcollins.atc.agree.agree.TimeOfExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) RealExpr(jkind.lustre.RealExpr) ArrayExpr(jkind.lustre.ArrayExpr) PrevExpr(com.rockwellcollins.atc.agree.agree.PrevExpr) IdExpr(jkind.lustre.IdExpr) TimeExpr(com.rockwellcollins.atc.agree.agree.TimeExpr) FoldRightExpr(com.rockwellcollins.atc.agree.agree.FoldRightExpr) TagExpr(com.rockwellcollins.atc.agree.agree.TagExpr) EventExpr(com.rockwellcollins.atc.agree.agree.EventExpr) LatchedExpr(com.rockwellcollins.atc.agree.agree.LatchedExpr) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) FunctionCallExpr(jkind.lustre.FunctionCallExpr) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) TupleExpr(jkind.lustre.TupleExpr) UnaryExpr(jkind.lustre.UnaryExpr) ArraySubExpr(com.rockwellcollins.atc.agree.agree.ArraySubExpr) IntExpr(jkind.lustre.IntExpr) PreExpr(com.rockwellcollins.atc.agree.agree.PreExpr) RecordLitExpr(com.rockwellcollins.atc.agree.agree.RecordLitExpr) ExistsExpr(com.rockwellcollins.atc.agree.agree.ExistsExpr) FoldLeftExpr(com.rockwellcollins.atc.agree.agree.FoldLeftExpr) RecordUpdateExpr(com.rockwellcollins.atc.agree.agree.RecordUpdateExpr) ForallExpr(com.rockwellcollins.atc.agree.agree.ForallExpr) ArrayAccessExpr(jkind.lustre.ArrayAccessExpr) ArrayUpdateExpr(com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr) 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) ArrayLiteralExpr(com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) NamedElement(org.osate.aadl2.NamedElement)

Example 19 with DoubleDotRef

use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project AGREE by loonwerks.

the class RenamingVisitor method argToString.

private String argToString(Arg arg) {
    String result = arg.getName() + " : ";
    if (arg.getType() instanceof PrimType) {
        PrimType primType = (PrimType) arg.getType();
        result += primType.getName();
        String lowLit = (primType.getLowNeg() != null) ? primType.getLowNeg() : "";
        String highLit = (primType.getHighNeg() != null) ? primType.getHighNeg() : "";
        if (primType.getRangeLow() != null) {
            result += " [" + lowLit + primType.getRangeLow() + ", " + highLit + primType.getRangeHigh() + "]";
        }
    } else {
        result += ((DoubleDotRef) arg.getType()).getElm().getName();
    }
    return result;
}
Also used : DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) PrimType(com.rockwellcollins.atc.agree.agree.PrimType)

Example 20 with DoubleDotRef

use of com.rockwellcollins.atc.agree.agree.DoubleDotRef in project AGREE by loonwerks.

the class AgreeTypeSystem method typeDefFromType.

public static TypeDef typeDefFromType(Type t) {
    if (t instanceof PrimType) {
        int lowSign = ((PrimType) t).getLowNeg() == null ? 1 : -1;
        int highSign = ((PrimType) t).getHighNeg() == null ? 1 : -1;
        String lowStr = ((PrimType) t).getRangeLow();
        String highStr = ((PrimType) t).getRangeHigh();
        if (((PrimType) t).getName().equals("int")) {
            if (lowStr == null || highStr == null) {
                return Prim.IntTypeDef;
            } else {
                long low = Long.valueOf(lowStr) * lowSign;
                long high = Long.valueOf(highStr) * highSign;
                return new RangeIntTypeDef(low, high);
            }
        } else if (((PrimType) t).getName().equals("real")) {
            if (lowStr == null || highStr == null) {
                return Prim.RealTypeDef;
            } else {
                double low = Double.valueOf(lowStr) * lowSign;
                double high = Double.valueOf(highStr) * highSign;
                return new RangeRealTypeDef(low, high);
            }
        } else if (((PrimType) t).getName().equals("bool")) {
            return Prim.BoolTypeDef;
        } else {
            return Prim.ErrorTypeDef;
        }
    } else if (t instanceof ArrayType) {
        String size = ((ArrayType) t).getSize();
        TypeDef baseTypeDef = typeDefFromType(((ArrayType) t).getStem());
        return new ArrayTypeDef(baseTypeDef, Integer.parseInt(size), Optional.empty());
    } else if (t instanceof DoubleDotRef) {
        return typeDefFromNE(((DoubleDotRef) t).getElm());
    } else {
        return Prim.ErrorTypeDef;
    }
}
Also used : ArrayType(com.rockwellcollins.atc.agree.agree.ArrayType) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) PrimType(com.rockwellcollins.atc.agree.agree.PrimType) AadlString(org.osate.aadl2.AadlString)

Aggregations

DoubleDotRef (com.rockwellcollins.atc.agree.agree.DoubleDotRef)26 NamedElement (org.osate.aadl2.NamedElement)17 NamedElmExpr (com.rockwellcollins.atc.agree.agree.NamedElmExpr)11 BoolLitExpr (com.rockwellcollins.atc.agree.agree.BoolLitExpr)8 IntLitExpr (com.rockwellcollins.atc.agree.agree.IntLitExpr)8 RealLitExpr (com.rockwellcollins.atc.agree.agree.RealLitExpr)8 SelectionExpr (com.rockwellcollins.atc.agree.agree.SelectionExpr)8 Arg (com.rockwellcollins.atc.agree.agree.Arg)7 CallExpr (com.rockwellcollins.atc.agree.agree.CallExpr)7 EnumLitExpr (com.rockwellcollins.atc.agree.agree.EnumLitExpr)7 EventExpr (com.rockwellcollins.atc.agree.agree.EventExpr)7 NodeBodyExpr (com.rockwellcollins.atc.agree.agree.NodeBodyExpr)7 PreExpr (com.rockwellcollins.atc.agree.agree.PreExpr)7 PrevExpr (com.rockwellcollins.atc.agree.agree.PrevExpr)7 RecordLitExpr (com.rockwellcollins.atc.agree.agree.RecordLitExpr)7 DataImplementation (org.osate.aadl2.DataImplementation)7 ArrayLiteralExpr (com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr)6 ArraySubExpr (com.rockwellcollins.atc.agree.agree.ArraySubExpr)6 ArrayUpdateExpr (com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr)6 ExistsExpr (com.rockwellcollins.atc.agree.agree.ExistsExpr)6