Search in sources :

Example 6 with Type

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

the class AgreeAnnexContentAssist method getNestedDotIDCandidates.

private List<String> getNestedDotIDCandidates(SelectionExpr id) {
    NamedElement base = ((NamedElmExpr) id).getElm();
    NamedElement namedEl = null;
    if (base instanceof Arg) {
        Type type = ((Arg) base).getType();
        DoubleDotRef elID = ((DoubleDotRef) type);
        namedEl = elID.getElm();
    // =======
    // DoubleDotRef elID = ((RecordType) type).getRecord();
    // namedEl = elID.getElm();
    // >>>>>>> origin/develop
    } else if (base instanceof DataPort) {
        namedEl = ((DataPort) base).getDataFeatureClassifier();
    } else if (base instanceof EventDataPort) {
        namedEl = ((EventDataPort) base).getDataFeatureClassifier();
    } else if (base instanceof AadlPackage) {
        return getNestedDotIDCandidates((AadlPackage) base);
    } else {
        return new ArrayList<>();
    }
    return getNestedDotIDCandidates(namedEl);
}
Also used : DataPort(org.osate.aadl2.DataPort) EventDataPort(org.osate.aadl2.EventDataPort) Type(com.rockwellcollins.atc.agree.agree.Type) AadlPackage(org.osate.aadl2.AadlPackage) Arg(com.rockwellcollins.atc.agree.agree.Arg) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) EventDataPort(org.osate.aadl2.EventDataPort) NamedElement(org.osate.aadl2.NamedElement) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr)

Example 7 with Type

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

the class AgreeValidator method checkArg.

@Check(CheckType.FAST)
public void checkArg(Arg arg) {
    Type type = arg.getType();
    if (type instanceof PrimType) {
        PrimType primType = (PrimType) type;
        String strType = primType.getName();
        String rangeLow = primType.getRangeLow();
        String rangeHigh = primType.getRangeHigh();
        if (rangeLow != null && rangeHigh != null) {
            // this is a ranged argument. It can show up only in an equation statement
            EObject container = arg.eContainer();
            if (!(container instanceof EqStatement || container instanceof InputStatement)) {
                error(arg, "Ranged arguments can appear only in equation statements or agree_input statements");
            }
            boolean rangeLowDot = rangeLow.contains(".");
            boolean rangeHighDot = rangeHigh.contains(".");
            if (rangeLowDot != rangeHighDot) {
                error(arg, "The range intervals are of differing types");
            }
            if (strType.equals("int") && (rangeLowDot || rangeHighDot)) {
                error(arg, "Ranged variable of type 'int' contains a 'real' value in its interval");
            }
            if (strType.equals("real") && (!rangeLowDot || !rangeHighDot)) {
                error(arg, "Ranged variable of type 'real' contains an 'int' value in its interval");
            }
            float low = Float.valueOf(rangeLow);
            float high = Float.valueOf(rangeHigh);
            low *= primType.getLowNeg() == null ? 1.0 : -1.0;
            high *= primType.getHighNeg() == null ? 1.0 : -1.0;
            if (low >= high) {
                error(arg, "The low value of the interval is greater than or equal to the high end");
            }
        }
    } else if (type instanceof DoubleDotRef) {
        DoubleDotRef recType = (DoubleDotRef) type;
        NamedElement finalId = recType.getElm();
        if (!(finalId instanceof DataImplementation) && !(finalId instanceof RecordDef) && !(finalId instanceof DataType) && !(finalId instanceof EnumStatement)) {
            error(recType, "types must be record definition, array definition, data implementation, enumeration, or datatype");
        }
        if (finalId instanceof DataImplementation) {
            if (AgreeTypeSystem.typesEqual(AgreeTypeSystem.typeDefFromType(recType), AgreeTypeSystem.Prim.ErrorTypeDef)) {
                error(recType, "Data Implementations with no subcomponents must extend" + " a Base_Type that AGREE can reason about.");
                return;
            }
            if (((DataImplementation) finalId).getAllSubcomponents().size() != 0) {
                if (AgreeTypeSystem.typesEqual(AgreeTypeSystem.typeDefFromType(recType), AgreeTypeSystem.Prim.BoolTypeDef) || AgreeTypeSystem.typesEqual(AgreeTypeSystem.typeDefFromType(recType), AgreeTypeSystem.Prim.IntTypeDef) || AgreeTypeSystem.typesEqual(AgreeTypeSystem.typeDefFromType(recType), AgreeTypeSystem.Prim.RealTypeDef)) {
                    error(finalId, "Data implementations with subcomponents cannot be" + " interpreted by AGREE if they extend Base_Types");
                }
            }
            // dataImplCycleCheck(recId);
            return;
        }
        if (finalId instanceof DataType) {
            if (AgreeTypeSystem.typesEqual(AgreeTypeSystem.typeDefFromType(recType), AgreeTypeSystem.Prim.ErrorTypeDef)) {
                error(recType, "AADL Datatypes must extend" + " a Base_Type that AGREE can reason about.");
                return;
            }
        }
    }
}
Also used : DataImplementation(org.osate.aadl2.DataImplementation) PrimType(com.rockwellcollins.atc.agree.agree.PrimType) DataType(org.osate.aadl2.DataType) CheckType(org.eclipse.xtext.validation.CheckType) FeatureGroupType(org.osate.aadl2.FeatureGroupType) ComponentType(org.osate.aadl2.ComponentType) Type(com.rockwellcollins.atc.agree.agree.Type) DirectionType(org.osate.aadl2.DirectionType) EObject(org.eclipse.emf.ecore.EObject) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) EnumStatement(com.rockwellcollins.atc.agree.agree.EnumStatement) PrimType(com.rockwellcollins.atc.agree.agree.PrimType) DataType(org.osate.aadl2.DataType) EqStatement(com.rockwellcollins.atc.agree.agree.EqStatement) InputStatement(com.rockwellcollins.atc.agree.agree.InputStatement) NamedElement(org.osate.aadl2.NamedElement) RecordDef(com.rockwellcollins.atc.agree.agree.RecordDef) Check(org.eclipse.xtext.validation.Check)

Example 8 with Type

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

the class AgreeValidator method checkRecordDefExpr.

// =======
// //    private List<AgreeType> getArgTypes(NestedDotID recId){
// //
// //    	NamedElement rec = getFinalNestId(recId);
// //    	List<AgreeType> types = new ArrayList<AgreeType>();
// //
// //    	if(rec instanceof RecordDefExpr){
// //    		RecordDefExpr recDef = (RecordDefExpr)rec;
// //    		for(Arg arg : recDef.getArgs()){
// //    			types.add(getAgreeType(arg.getType()));
// //    		}
// //    	}else if(rec instanceof FeatureGroupType){
// //    		FeatureGroupType featGroup = (FeatureGroupType)rec;
// //    		for(Feature feat : featGroup.getAllFeatures()){
// //    			types.add(getAgreeType(feat));
// //    		}
// //    	}
// //
// //    	return types;
// //    }
// 
// private void dataImplCycleCheck(NestedDotID dataID) {
// NamedElement finalId = dataID.getBase();
// DataImplementation dataImpl = (DataImplementation) finalId;
// dataImplCycleCheck(dataImpl, dataID);
// }
// 
// private void dataImplCycleCheck(DoubleDotRef dataID) {
// NamedElement finalId = dataID.getElm();
// DataImplementation dataImpl = (DataImplementation) finalId;
// dataImplCycleCheck(dataImpl, dataID);
// }
// 
// 
// private void dataImplCycleCheck(DataImplementation dataImpl, EObject errorSource) {
// Set<DataImplementation> dataClosure = new HashSet<>();
// Set<DataImplementation> prevClosure = null;
// 
// for (Subcomponent sub : dataImpl.getAllSubcomponents()) {
// ComponentImplementation subImpl = sub.getComponentImplementation();
// if (subImpl != null) {
// dataClosure.add((DataImplementation) subImpl);
// }
// }
// 
// do {
// prevClosure = new HashSet<>(dataClosure);
// for (DataImplementation subImpl : prevClosure) {
// if (subImpl == dataImpl) {
// error(errorSource, "The component implementation '" + dataImpl.getName()
// + "' has a cyclic definition.  This cannot be reasoned about by AGREE.");
// break;
// }
// for (Subcomponent subSub : subImpl.getAllSubcomponents()) {
// ComponentImplementation subSubImpl = subSub.getComponentImplementation();
// if (subSubImpl != null) {
// dataClosure.add((DataImplementation) subSubImpl);
// }
// }
// 
// }
// 
// } while (!prevClosure.equals(dataClosure));
// 
// }
// >>>>>>> origin/develop
@Check(CheckType.FAST)
public void checkRecordDefExpr(RecordDef recordDef) {
    Set<RecordDef> recordClosure = new HashSet<>();
    Set<RecordDef> prevClosure = null;
    for (Arg arg : recordDef.getArgs()) {
        Type type = arg.getType();
        if (type instanceof DoubleDotRef) {
            NamedElement finalId = ((DoubleDotRef) type).getElm();
            if (finalId instanceof RecordDef) {
                recordClosure.add((RecordDef) finalId);
            }
        }
    }
    do {
        prevClosure = new HashSet<>(recordClosure);
        for (RecordDef subRecDef : prevClosure) {
            if (subRecDef == recordDef) {
                error(recordDef, "The definition of type '" + recordDef.getName() + "' is involved in a cyclic definition");
                break;
            }
            for (Arg arg : subRecDef.getArgs()) {
                Type type = arg.getType();
                if (type instanceof DoubleDotRef) {
                    NamedElement subFinalEl = ((DoubleDotRef) type).getElm();
                    if (subFinalEl instanceof RecordDef) {
                        recordClosure.add((RecordDef) subFinalEl);
                    // =======
                    // if (type instanceof RecordType) {
                    // DoubleDotRef subRecId = ((RecordType) type).getRecord();
                    // NamedElement subFinalEl = subRecId.getElm();
                    // if (subFinalEl instanceof RecordDefExpr) {
                    // recordClosure.add((RecordDefExpr) subFinalEl);
                    // >>>>>>> origin/develop
                    }
                }
            }
        }
    } while (!prevClosure.equals(recordClosure));
}
Also used : PrimType(com.rockwellcollins.atc.agree.agree.PrimType) DataType(org.osate.aadl2.DataType) CheckType(org.eclipse.xtext.validation.CheckType) FeatureGroupType(org.osate.aadl2.FeatureGroupType) ComponentType(org.osate.aadl2.ComponentType) Type(com.rockwellcollins.atc.agree.agree.Type) DirectionType(org.osate.aadl2.DirectionType) Arg(com.rockwellcollins.atc.agree.agree.Arg) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) NamedElement(org.osate.aadl2.NamedElement) RecordDef(com.rockwellcollins.atc.agree.agree.RecordDef) HashSet(java.util.HashSet) Check(org.eclipse.xtext.validation.Check)

Example 9 with Type

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

the class UninterpretedFnDefImpl method basicSetType.

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

Example 10 with Type

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

the class SafetyAnnexContentAssist method getNestedDotIDCandidates.

private List<String> getNestedDotIDCandidates(SelectionExpr id) {
    NamedElement base = ((NamedElmExpr) id).getElm();
    NamedElement namedEl = null;
    if (base instanceof Arg) {
        Type type = ((Arg) base).getType();
        DoubleDotRef elID = ((DoubleDotRef) type);
        namedEl = elID.getElm();
    } else if (base instanceof DataPort) {
        namedEl = ((DataPort) base).getDataFeatureClassifier();
    } else if (base instanceof EventDataPort) {
        namedEl = ((EventDataPort) base).getDataFeatureClassifier();
    } else if (base instanceof AadlPackage) {
        return getNestedDotIDCandidates((AadlPackage) base);
    } else {
        return new ArrayList<>();
    }
    return getNestedDotIDCandidates(namedEl);
}
Also used : DataPort(org.osate.aadl2.DataPort) EventDataPort(org.osate.aadl2.EventDataPort) Type(com.rockwellcollins.atc.agree.agree.Type) AadlPackage(org.osate.aadl2.AadlPackage) Arg(com.rockwellcollins.atc.agree.agree.Arg) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) EventDataPort(org.osate.aadl2.EventDataPort) NamedElement(org.osate.aadl2.NamedElement) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr)

Aggregations

Type (com.rockwellcollins.atc.agree.agree.Type)14 DoubleDotRef (com.rockwellcollins.atc.agree.agree.DoubleDotRef)7 NamedElement (org.osate.aadl2.NamedElement)7 Arg (com.rockwellcollins.atc.agree.agree.Arg)6 NamedElmExpr (com.rockwellcollins.atc.agree.agree.NamedElmExpr)5 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)5 DataPort (org.osate.aadl2.DataPort)5 EventDataPort (org.osate.aadl2.EventDataPort)5 BinaryExpr (com.rockwellcollins.atc.agree.agree.BinaryExpr)3 BoolLitExpr (com.rockwellcollins.atc.agree.agree.BoolLitExpr)3 CallExpr (com.rockwellcollins.atc.agree.agree.CallExpr)3 ConstStatement (com.rockwellcollins.atc.agree.agree.ConstStatement)3 EnumLitExpr (com.rockwellcollins.atc.agree.agree.EnumLitExpr)3 EnumStatement (com.rockwellcollins.atc.agree.agree.EnumStatement)3 EqStatement (com.rockwellcollins.atc.agree.agree.EqStatement)3 EventExpr (com.rockwellcollins.atc.agree.agree.EventExpr)3 PrimType (com.rockwellcollins.atc.agree.agree.PrimType)3 AadlPackage (org.osate.aadl2.AadlPackage)3 HashMultimap (com.google.common.collect.HashMultimap)2 AgreeAADLEnumerationUtils (com.rockwellcollins.atc.agree.AgreeAADLEnumerationUtils)2