Search in sources :

Example 1 with EnumLitExpr

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

the class Agree2Vdm method getVdmExpressionFromAgreeExpression.

// method to translate expression in Agree to expression in vdm
private Expression getVdmExpressionFromAgreeExpression(Expr agreeExpr, HashSet<String> dataTypeDecl, HashSet<String> nodeDecl, Model model) {
    Expression vdmExpr = new Expression();
    if (agreeExpr instanceof IfThenElseExpr) {
        IfThenElseExpr ifexpr = (IfThenElseExpr) agreeExpr;
        // for vdm model
        IfThenElse ifThenElseVal = new IfThenElse();
        Expression condExpr = getVdmExpressionFromAgreeExpression(ifexpr.getA(), dataTypeDecl, nodeDecl, model);
        ifThenElseVal.setCondition(condExpr);
        Expression thenBranchExpr = getVdmExpressionFromAgreeExpression(ifexpr.getB(), dataTypeDecl, nodeDecl, model);
        ifThenElseVal.setThenBranch(thenBranchExpr);
        Expression elseBranchExpr = getVdmExpressionFromAgreeExpression(ifexpr.getC(), dataTypeDecl, nodeDecl, model);
        ifThenElseVal.setElseBranch(elseBranchExpr);
        vdmExpr.setConditionalExpression(ifThenElseVal);
    } else if (agreeExpr instanceof CallExpr) {
        CallExpr callExpr = (CallExpr) agreeExpr;
        DoubleDotRef ddref = (DoubleDotRef) callExpr.getRef();
        if (ddref.getElm() instanceof NodeDef) {
            NodeDef nodeDef = (NodeDef) ddref.getElm();
            addNodeDefToTypeDeclarations(nodeDef, dataTypeDecl, nodeDecl, model);
            // create node call in vdm model
            NodeCall vdmNodeCall = new NodeCall();
            // setting node name
            vdmNodeCall.setNodeId(nodeDef.getName());
            EList<Expr> callExprArgs = callExpr.getArgs();
            // below are the parameters passed to the function call
            for (Expr callExprArg : callExprArgs) {
                Expression argExpr = getVdmExpressionFromAgreeExpression(callExprArg, dataTypeDecl, nodeDecl, model);
                // setting node arguments
                vdmNodeCall.getArgument().add(argExpr);
            }
            vdmExpr.setCall(vdmNodeCall);
        } else {
            System.out.println("Unmapped Typed");
        }
    } else if (agreeExpr instanceof NamedElmExpr) {
        NamedElmExpr nmExpr = (NamedElmExpr) agreeExpr;
        vdmExpr.setIdentifier(nmExpr.getElm().getName());
        // define corresponding types in the VDM if not already defined
        if (nmExpr.getElm() instanceof Arg) {
            Arg nmElmArg = (Arg) nmExpr.getElm();
            // define corresponding type in the VDM if not already defined
            Type argType = nmElmArg.getType();
            defineDataTypeDataImplementationTypeInVDM(argType, dataTypeDecl, model);
        } else if (nmExpr.getElm() instanceof Port) {
            Port nmElmPort = (Port) nmExpr.getElm();
            // define corresponding type in the VDM if not already defined
            if (nmElmPort instanceof DataPortImpl) {
                DataPort nmElmDataPort = (DataPort) nmElmPort;
                DataSubcomponentType dSubCompType = nmElmDataPort.getDataFeatureClassifier();
                defineDataTypeDataImplementationTypeInVDM(dSubCompType, dataTypeDecl, model);
            } else if (nmElmPort instanceof EventDataPortImpl) {
                EventDataPort nmElmDataPort = (EventDataPort) nmElmPort;
                DataSubcomponentType dSubCompType = nmElmDataPort.getDataFeatureClassifier();
                defineDataTypeDataImplementationTypeInVDM(dSubCompType, dataTypeDecl, model);
            } else {
                if (!(nmElmPort instanceof EventPort)) {
                    System.out.println("Unresolved Port Type");
                }
            }
        } else if (nmExpr.getElm() instanceof ConstStatement) {
            ConstStatement nmElmConstStatement = (ConstStatement) nmExpr.getElm();
            String nmElmConstStatementName = nmElmConstStatement.getName();
            // add const declaration to VDM if not already defined
            if (!dataTypeDecl.contains(nmElmConstStatementName)) {
                dataTypeDecl.add(nmElmConstStatementName);
                ConstantDeclaration vdmConstDeclaration = new ConstantDeclaration();
                vdmConstDeclaration.setName(nmElmConstStatementName);
                vdmConstDeclaration.setDefinition(getVdmExpressionFromAgreeExpression(nmElmConstStatement.getExpr(), dataTypeDecl, nodeDecl, model));
                vdmConstDeclaration.setDataType(getVdmTypeFromAgreeType(nmElmConstStatement.getType(), dataTypeDecl, model));
                LustreProgram lustreProgram = model.getDataflowCode();
                lustreProgram.getConstantDeclaration().add(vdmConstDeclaration);
                model.setDataflowCode(lustreProgram);
            }
        } else {
            System.out.println("Unresolved/unmapped NamedExprElm: " + nmExpr.getElm().getName());
        }
    } else if (agreeExpr instanceof SelectionExpr) {
        // selection expression corresponds to record projection in VDM
        RecordProjection vdmRecordProj = new RecordProjection();
        SelectionExpr selExpr = (SelectionExpr) agreeExpr;
        if (selExpr.getField() == null) {
            System.out.println("Null Selection Expr field: " + selExpr.getField());
        } else {
            NamedElement field = selExpr.getField();
            // set record-projection's reference
            if (selExpr.getTarget() != null) {
                // target can be NamedElmExpr or a SelectionExpr
                vdmRecordProj.setRecordReference(getVdmExpressionFromAgreeExpression(selExpr.getTarget(), dataTypeDecl, nodeDecl, model));
            }
            // set record-projection's field id
            vdmRecordProj.setFieldId(field.getName());
            // also set the name of the field's type as the record-projection's record-type
            if (field instanceof DataPortImpl) {
                DataPort dport = (DataPort) field;
                DataSubcomponentType dSubCompType = dport.getDataFeatureClassifier();
                defineDataTypeDataImplementationTypeInVDM(dSubCompType, dataTypeDecl, model);
                vdmRecordProj.setRecordType(dSubCompType.getName());
            } else if (field instanceof DataSubcomponentImpl) {
                DataSubcomponent dSubComp = (DataSubcomponent) field;
                DataSubcomponentType dSubCompType = dSubComp.getDataSubcomponentType();
                defineDataTypeDataImplementationTypeInVDM(dSubCompType, dataTypeDecl, model);
                vdmRecordProj.setRecordType(dSubCompType.getName());
            } else if (field instanceof ArgImpl) {
                Arg arg = (Arg) field;
                Type argType = arg.getType();
                defineDataTypeDataImplementationTypeInVDM(argType, dataTypeDecl, model);
                if (argType instanceof PrimType) {
                    vdmRecordProj.setRecordType(getDataTypeName(argType));
                } else {
                    System.out.println("Unresolved Arg Type so not setting record-type in record-projection.");
                }
            } else {
                System.out.println("Unresolved type of field.");
            }
        }
        vdmExpr.setRecordProjection(vdmRecordProj);
    } else if (agreeExpr instanceof BinaryExpr) {
        BinaryExpr binExpr = (BinaryExpr) agreeExpr;
        // for vdm
        BinaryOperation binoper = new BinaryOperation();
        // set left operand
        Expression leftOperand = getVdmExpressionFromAgreeExpression(binExpr.getLeft(), dataTypeDecl, nodeDecl, model);
        binoper.setLhsOperand(leftOperand);
        // set right operand
        Expression rightOperand = getVdmExpressionFromAgreeExpression(binExpr.getRight(), dataTypeDecl, nodeDecl, model);
        binoper.setRhsOperand(rightOperand);
        // set appropriate operator
        String operator = binExpr.getOp();
        if (operator.equalsIgnoreCase("->")) {
            vdmExpr.setArrow(binoper);
        } else if (operator.equalsIgnoreCase("=>")) {
            vdmExpr.setImplies(binoper);
        } else if (operator.equalsIgnoreCase("and")) {
            vdmExpr.setAnd(binoper);
        } else if (operator.equalsIgnoreCase("or")) {
            vdmExpr.setOr(binoper);
        } else if (operator.equalsIgnoreCase("=")) {
            vdmExpr.setEqual(binoper);
        } else if (operator.equalsIgnoreCase(">")) {
            vdmExpr.setGreaterThan(binoper);
        } else if (operator.equalsIgnoreCase("<")) {
            vdmExpr.setLessThan(binoper);
        } else if (operator.equalsIgnoreCase(">=")) {
            vdmExpr.setGreaterThanOrEqualTo(binoper);
        } else if (operator.equalsIgnoreCase("<=")) {
            vdmExpr.setLessThanOrEqualTo(binoper);
        } else if (operator.equalsIgnoreCase("+")) {
            vdmExpr.setPlus(binoper);
        } else if (operator.equalsIgnoreCase("-")) {
            vdmExpr.setMinus(binoper);
        } else if (operator.equalsIgnoreCase("!=") || operator.equalsIgnoreCase("<>")) {
            vdmExpr.setNotEqual(binoper);
        } else if (operator.equalsIgnoreCase("/")) {
            vdmExpr.setDiv(binoper);
        } else if (operator.equalsIgnoreCase("*")) {
            vdmExpr.setTimes(binoper);
        } else {
            System.out.println("Unmapped binary operator: " + operator);
        }
    } else if (agreeExpr instanceof UnaryExpr) {
        UnaryExpr unExpr = (UnaryExpr) agreeExpr;
        Expression singleOperand = getVdmExpressionFromAgreeExpression(unExpr.getExpr(), dataTypeDecl, nodeDecl, model);
        String operator = unExpr.getOp();
        if (operator.equalsIgnoreCase("this")) {
            vdmExpr.setCurrent(singleOperand);
        } else if (operator.equalsIgnoreCase("not")) {
            vdmExpr.setNot(singleOperand);
        } else if (operator.equalsIgnoreCase("-")) {
            vdmExpr.setNegative(singleOperand);
        } else {
            System.out.println("Unmapped unary operator.");
        }
    } else if (agreeExpr instanceof BoolLitExpr) {
        BoolLitExpr boolExpr = (BoolLitExpr) agreeExpr;
        vdmExpr.setBoolLiteral(boolExpr.getVal().getValue());
    } else if (agreeExpr instanceof EnumLitExpr) {
        EnumLitExpr enumExpr = (EnumLitExpr) agreeExpr;
        // check if elm is DataImplementationImpl or DataTypeImpl -- if yes add definition to type declarations if not already present
        DoubleDotRef enumType = enumExpr.getEnumType();
        if (enumType.getElm() instanceof DataTypeImpl) {
            org.osate.aadl2.DataType aadlDType = (org.osate.aadl2.DataType) enumType.getElm();
            resolveAADLDataType(aadlDType, dataTypeDecl, model);
        } else {
            System.out.println("Unexpected Elm type for EnumLitExpr");
        }
        vdmExpr.setIdentifier(enumExpr.getValue());
    } else if (agreeExpr instanceof PreExpr) {
        PreExpr preExpr = (PreExpr) agreeExpr;
        Expression expr = getVdmExpressionFromAgreeExpression(preExpr.getExpr(), dataTypeDecl, nodeDecl, model);
        vdmExpr.setPre(expr);
    } else if (agreeExpr instanceof RecordLitExpr) {
        RecordLiteral vdmRecordLiteral = new RecordLiteral();
        RecordLitExpr recLitExpr = (RecordLitExpr) agreeExpr;
        if (recLitExpr.getRecordType() instanceof DoubleDotRef) {
            DoubleDotRef recType = (DoubleDotRef) recLitExpr.getRecordType();
            if (recType.getElm().getName() != null) {
                // check if elm is DataImplementationImpl -- if yes add definition to type declarations if not already present
                if (recType.getElm() instanceof DataImplementation) {
                    org.osate.aadl2.DataImplementation aadlDImpl = (org.osate.aadl2.DataImplementation) recType.getElm();
                    resolveAADLDataImplementationType(aadlDImpl, dataTypeDecl, model);
                } else {
                    System.out.println("Unexpected Elm type for EnumLitExpr");
                }
                // set name of the record literal in the vdm model
                vdmRecordLiteral.setRecordType(recType.getElm().getName());
                // get args and arg-expr and set them as field identifier and value in the vdm model
                EList<NamedElement> recLitArgs = recLitExpr.getArgs();
                EList<Expr> recLitArgsExpr = recLitExpr.getArgExpr();
                // below are the values set to variable
                for (int ind = 0; ind < recLitArgs.size(); ind++) {
                    FieldDefinition fieldDef = new FieldDefinition();
                    fieldDef.setFieldIdentifier(recLitArgs.get(ind).getName());
                    fieldDef.setFieldValue(getVdmExpressionFromAgreeExpression(recLitArgsExpr.get(ind), dataTypeDecl, nodeDecl, model));
                    // set field definitions in the record literal in the vdm model
                    vdmRecordLiteral.getFieldDefinition().add(fieldDef);
                }
                vdmExpr.setRecordLiteral(vdmRecordLiteral);
            } else {
                System.out.println("Unexpected Literal's Record Type that has null named elm.");
            }
        } else {
            System.out.println("Unresolved or unmapped record literal expression.");
        }
    } else if (agreeExpr instanceof IntLitExpr) {
        IntLitExpr intLitExpr = (IntLitExpr) agreeExpr;
        BigInteger bigInt = new BigInteger(intLitExpr.getVal());
        vdmExpr.setIntLiteral(bigInt);
    } else if (agreeExpr instanceof RealLitExpr) {
        RealLitExpr realLitExpr = (RealLitExpr) agreeExpr;
        BigDecimal bigDecimal = new BigDecimal(realLitExpr.getVal());
        vdmExpr.setRealLiteral(bigDecimal);
    } else if (agreeExpr instanceof EventExpr) {
        EventExpr eventExpr = (EventExpr) agreeExpr;
        if (eventExpr.getPort() != null) {
            vdmExpr.setEvent(getVdmExpressionFromAgreeExpression(eventExpr.getPort(), dataTypeDecl, nodeDecl, model));
        } else {
            System.out.println("EventExpr does not have port infornation.");
        }
    } else if (agreeExpr instanceof RealCast) {
        RealCast realCastExpr = (RealCast) agreeExpr;
        vdmExpr.setToReal(getVdmExpressionFromAgreeExpression(realCastExpr.getExpr(), dataTypeDecl, nodeDecl, model));
    } else {
        System.out.println("Unresolved/umapped agree expr" + agreeExpr.toString());
    }
    return vdmExpr;
}
Also used : BinaryOperation(verdict.vdm.vdm_lustre.BinaryOperation) EventPort(org.osate.aadl2.EventPort) DataPort(org.osate.aadl2.DataPort) Port(org.osate.aadl2.Port) EventDataPort(org.osate.aadl2.EventDataPort) FieldDefinition(verdict.vdm.vdm_lustre.FieldDefinition) ConstantDeclaration(verdict.vdm.vdm_lustre.ConstantDeclaration) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) DataPort(org.osate.aadl2.DataPort) EventDataPort(org.osate.aadl2.EventDataPort) RealCast(com.rockwellcollins.atc.agree.agree.RealCast) RecordProjection(verdict.vdm.vdm_lustre.RecordProjection) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) PrimType(com.rockwellcollins.atc.agree.agree.PrimType) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) EventDataPort(org.osate.aadl2.EventDataPort) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) RecordLiteral(verdict.vdm.vdm_lustre.RecordLiteral) EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) EventDataPortImpl(org.osate.aadl2.impl.EventDataPortImpl) RecordLitExpr(com.rockwellcollins.atc.agree.agree.RecordLitExpr) UnaryExpr(com.rockwellcollins.atc.agree.agree.UnaryExpr) IfThenElseExpr(com.rockwellcollins.atc.agree.agree.IfThenElseExpr) ConstStatement(com.rockwellcollins.atc.agree.agree.ConstStatement) DataSubcomponentType(org.osate.aadl2.DataSubcomponentType) PreExpr(com.rockwellcollins.atc.agree.agree.PreExpr) 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) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) Arg(com.rockwellcollins.atc.agree.agree.Arg) BigInteger(java.math.BigInteger) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) NamedElement(org.osate.aadl2.NamedElement) ArgImpl(com.rockwellcollins.atc.agree.agree.impl.ArgImpl) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) NodeDef(com.rockwellcollins.atc.agree.agree.NodeDef) EventExpr(com.rockwellcollins.atc.agree.agree.EventExpr) DataSubcomponentImpl(org.osate.aadl2.impl.DataSubcomponentImpl) EventPort(org.osate.aadl2.EventPort) NodeCall(verdict.vdm.vdm_lustre.NodeCall) DataPortImpl(org.osate.aadl2.impl.DataPortImpl) EventDataPortImpl(org.osate.aadl2.impl.EventDataPortImpl) BinaryExpr(com.rockwellcollins.atc.agree.agree.BinaryExpr) DataImplementation(org.osate.aadl2.DataImplementation) BigDecimal(java.math.BigDecimal) PrimType(com.rockwellcollins.atc.agree.agree.PrimType) DataSubcomponentType(org.osate.aadl2.DataSubcomponentType) Type(com.rockwellcollins.atc.agree.agree.Type) EnumType(verdict.vdm.vdm_data.EnumType) RecordType(verdict.vdm.vdm_data.RecordType) SystemType(org.osate.aadl2.SystemType) ComponentType(verdict.vdm.vdm_model.ComponentType) EList(org.eclipse.emf.common.util.EList) PropertyExpression(org.osate.aadl2.PropertyExpression) Expression(verdict.vdm.vdm_lustre.Expression) LustreProgram(verdict.vdm.vdm_lustre.LustreProgram) DataSubcomponent(org.osate.aadl2.DataSubcomponent) DataTypeImpl(org.osate.aadl2.impl.DataTypeImpl) IfThenElse(verdict.vdm.vdm_lustre.IfThenElse)

Example 2 with EnumLitExpr

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

the class AgreeValidator method checkAADLEnumerator.

@Check(CheckType.FAST)
public void checkAADLEnumerator(EnumLitExpr aadlEnum) {
    DoubleDotRef enumType = aadlEnum.getEnumType();
    NamedElement enumTypeNamedElement = enumType.getElm();
    // >>>>>>> origin/develop
    if (!AgreeAADLEnumerationUtils.isAADLEnumeration(enumTypeNamedElement)) {
        error(enumType, "AADL Enumerations must refer to a Data Type with \"Enum\" data representation " + "property and have an \"Enumerators\' property value list.");
    } else {
        String enumVal = aadlEnum.getValue();
        List<String> enumerators = AgreeAADLEnumerationUtils.getEnumerators((ComponentClassifier) enumTypeNamedElement).stream().map(pe -> ((org.osate.aadl2.StringLiteral) pe).getValue()).collect(Collectors.toList());
        if (!enumerators.stream().anyMatch(ev -> ev.equalsIgnoreCase(enumVal))) {
            error(aadlEnum, "AADL Enumeration " + enumTypeNamedElement.getQualifiedName() + " does not have an enumeration value " + enumVal);
        }
    }
}
Also used : EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) IndicesExpr(com.rockwellcollins.atc.agree.agree.IndicesExpr) AnnexUtil(org.osate.annexsupport.AnnexUtil) TimeRiseExpr(com.rockwellcollins.atc.agree.agree.TimeRiseExpr) RecordDef(com.rockwellcollins.atc.agree.agree.RecordDef) FnDef(com.rockwellcollins.atc.agree.agree.FnDef) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) 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) Map(java.util.Map) OrderStatement(com.rockwellcollins.atc.agree.agree.OrderStatement) InputStatement(com.rockwellcollins.atc.agree.agree.InputStatement) BigInteger(java.math.BigInteger) Check(org.eclipse.xtext.validation.Check) WheneverOccursStatement(com.rockwellcollins.atc.agree.agree.WheneverOccursStatement) CalenStatement(com.rockwellcollins.atc.agree.agree.CalenStatement) AgreeContract(com.rockwellcollins.atc.agree.agree.AgreeContract) SporadicStatement(com.rockwellcollins.atc.agree.agree.SporadicStatement) PrimType(com.rockwellcollins.atc.agree.agree.PrimType) Set(java.util.Set) ComponentRef(com.rockwellcollins.atc.agree.agree.ComponentRef) AadlPackage(org.osate.aadl2.AadlPackage) MNSynchStatement(com.rockwellcollins.atc.agree.agree.MNSynchStatement) ModelUnit(org.osate.aadl2.ModelUnit) ConnectionStatement(com.rockwellcollins.atc.agree.agree.ConnectionStatement) SpecStatement(com.rockwellcollins.atc.agree.agree.SpecStatement) GuaranteeStatement(com.rockwellcollins.atc.agree.agree.GuaranteeStatement) TimeInterval(com.rockwellcollins.atc.agree.agree.TimeInterval) DataType(org.osate.aadl2.DataType) TimeOfExpr(com.rockwellcollins.atc.agree.agree.TimeOfExpr) AgreePackage(com.rockwellcollins.atc.agree.agree.AgreePackage) Feature(org.osate.aadl2.Feature) ComponentImplementation(org.osate.aadl2.ComponentImplementation) AgreeTypeSystem.nameOfTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.nameOfTypeDef) ArrayList(java.util.ArrayList) ComponentClassifier(org.osate.aadl2.ComponentClassifier) EnumStatement(com.rockwellcollins.atc.agree.agree.EnumStatement) CheckType(org.eclipse.xtext.validation.CheckType) LiftContractStatement(com.rockwellcollins.atc.agree.agree.LiftContractStatement) Aadl2Package(org.osate.aadl2.Aadl2Package) Subcomponent(org.osate.aadl2.Subcomponent) AgreeAADLEnumerationUtils(com.rockwellcollins.atc.agree.AgreeAADLEnumerationUtils) PrevExpr(com.rockwellcollins.atc.agree.agree.PrevExpr) FeatureGroup(org.osate.aadl2.FeatureGroup) ArrayTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.ArrayTypeDef) AadlUtil(org.osate.aadl2.modelsupport.util.AadlUtil) 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) ReachableStatement(com.rockwellcollins.atc.agree.agree.ReachableStatement) PropertyConstant(org.osate.aadl2.PropertyConstant) EventPort(org.osate.aadl2.EventPort) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) FeatureGroupType(org.osate.aadl2.FeatureGroupType) RealCast(com.rockwellcollins.atc.agree.agree.RealCast) DataPort(org.osate.aadl2.DataPort) ConstStatement(com.rockwellcollins.atc.agree.agree.ConstStatement) LibraryFnDef(com.rockwellcollins.atc.agree.agree.LibraryFnDef) PeriodicStatement(com.rockwellcollins.atc.agree.agree.PeriodicStatement) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) AnnexSubclause(org.osate.aadl2.AnnexSubclause) NamedElement(org.osate.aadl2.NamedElement) UninterpretedFnDef(com.rockwellcollins.atc.agree.agree.UninterpretedFnDef) NodeStmt(com.rockwellcollins.atc.agree.agree.NodeStmt) DataImplementation(org.osate.aadl2.DataImplementation) AsynchStatement(com.rockwellcollins.atc.agree.agree.AsynchStatement) NamedID(com.rockwellcollins.atc.agree.agree.NamedID) AgreeContractLibrary(com.rockwellcollins.atc.agree.agree.AgreeContractLibrary) Port(org.osate.aadl2.Port) IfThenElseExpr(com.rockwellcollins.atc.agree.agree.IfThenElseExpr) ArraySubExpr(com.rockwellcollins.atc.agree.agree.ArraySubExpr) HashMultimap(com.google.common.collect.HashMultimap) Classifier(org.osate.aadl2.Classifier) ComponentType(org.osate.aadl2.ComponentType) Type(com.rockwellcollins.atc.agree.agree.Type) LatchedStatement(com.rockwellcollins.atc.agree.agree.LatchedStatement) AgreeTypeSystem(com.rockwellcollins.atc.agree.AgreeTypeSystem) PreExpr(com.rockwellcollins.atc.agree.agree.PreExpr) AgreeContractSubclause(com.rockwellcollins.atc.agree.agree.AgreeContractSubclause) AssertStatement(com.rockwellcollins.atc.agree.agree.AssertStatement) NodeEq(com.rockwellcollins.atc.agree.agree.NodeEq) NodeLemma(com.rockwellcollins.atc.agree.agree.NodeLemma) EObject(org.eclipse.emf.ecore.EObject) Connection(org.osate.aadl2.Connection) RecordLitExpr(com.rockwellcollins.atc.agree.agree.RecordLitExpr) Collectors(java.util.stream.Collectors) BinaryExpr(com.rockwellcollins.atc.agree.agree.BinaryExpr) NodeDef(com.rockwellcollins.atc.agree.agree.NodeDef) List(java.util.List) UnaryExpr(com.rockwellcollins.atc.agree.agree.UnaryExpr) Property(org.osate.aadl2.Property) ExistsExpr(com.rockwellcollins.atc.agree.agree.ExistsExpr) RecordTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.RecordTypeDef) FoldLeftExpr(com.rockwellcollins.atc.agree.agree.FoldLeftExpr) SynchStatement(com.rockwellcollins.atc.agree.agree.SynchStatement) AnnexLibrary(org.osate.aadl2.AnnexLibrary) RecordUpdateExpr(com.rockwellcollins.atc.agree.agree.RecordUpdateExpr) TypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef) ForallExpr(com.rockwellcollins.atc.agree.agree.ForallExpr) Arg(com.rockwellcollins.atc.agree.agree.Arg) AgreeSubclause(com.rockwellcollins.atc.agree.agree.AgreeSubclause) WhenHoldsStatement(com.rockwellcollins.atc.agree.agree.WhenHoldsStatement) FloorCast(com.rockwellcollins.atc.agree.agree.FloorCast) HashMap(java.util.HashMap) LinearizationDef(com.rockwellcollins.atc.agree.agree.LinearizationDef) Expr(com.rockwellcollins.atc.agree.agree.Expr) HashSet(java.util.HashSet) DataSubcomponent(org.osate.aadl2.DataSubcomponent) InitialStatement(com.rockwellcollins.atc.agree.agree.InitialStatement) EcoreUtil2(org.eclipse.xtext.EcoreUtil2) DirectionType(org.osate.aadl2.DirectionType) WheneverBecomesTrueStatement(com.rockwellcollins.atc.agree.agree.WheneverBecomesTrueStatement) ExprCycleVisitor(com.rockwellcollins.atc.agree.visitors.ExprCycleVisitor) LinkedList(java.util.LinkedList) PropertyStatement(com.rockwellcollins.atc.agree.agree.PropertyStatement) ThisRef(com.rockwellcollins.atc.agree.agree.ThisRef) Iterator(java.util.Iterator) AssignStatement(com.rockwellcollins.atc.agree.agree.AssignStatement) ArrayUpdateExpr(com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr) AssumeStatement(com.rockwellcollins.atc.agree.agree.AssumeStatement) EqStatement(com.rockwellcollins.atc.agree.agree.EqStatement) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) NodeBodyExpr(com.rockwellcollins.atc.agree.agree.NodeBodyExpr) EList(org.eclipse.emf.common.util.EList) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) LemmaStatement(com.rockwellcollins.atc.agree.agree.LemmaStatement) NamedSpecStatement(com.rockwellcollins.atc.agree.agree.NamedSpecStatement) EventDataPort(org.osate.aadl2.EventDataPort) LinearizationInterval(com.rockwellcollins.atc.agree.agree.LinearizationInterval) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) WheneverImpliesStatement(com.rockwellcollins.atc.agree.agree.WheneverImpliesStatement) WheneverHoldsStatement(com.rockwellcollins.atc.agree.agree.WheneverHoldsStatement) Abstraction(com.rockwellcollins.atc.agree.agree.Abstraction) WhenOccursStatment(com.rockwellcollins.atc.agree.agree.WhenOccursStatment) Collections(java.util.Collections) ArrayLiteralExpr(com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr) ComponentClassifier(org.osate.aadl2.ComponentClassifier) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) NamedElement(org.osate.aadl2.NamedElement) Check(org.eclipse.xtext.validation.Check)

Example 3 with EnumLitExpr

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

the class AgreeValidator method isTimingConst.

/**
 * Is a given expression a usable timing constant
 *
 * Determine whether the given expression is a constant that may be a
 * statically evaluated such that can be used to set the timing model
 *
 * @param expr
 * @return true if acceptable timing constant, false otherwise
 */
protected boolean isTimingConst(Expr expr) {
    if (expr instanceof SelectionExpr) {
        SelectionExpr id = (SelectionExpr) expr;
        NamedElement finalId = id.getField();
        return (finalId instanceof ConstStatement);
    } else if (expr instanceof EnumLitExpr) {
        return true;
    }
    return false;
}
Also used : ConstStatement(com.rockwellcollins.atc.agree.agree.ConstStatement) EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) NamedElement(org.osate.aadl2.NamedElement)

Aggregations

ConstStatement (com.rockwellcollins.atc.agree.agree.ConstStatement)3 EnumLitExpr (com.rockwellcollins.atc.agree.agree.EnumLitExpr)3 SelectionExpr (com.rockwellcollins.atc.agree.agree.SelectionExpr)3 NamedElement (org.osate.aadl2.NamedElement)3 Arg (com.rockwellcollins.atc.agree.agree.Arg)2 BinaryExpr (com.rockwellcollins.atc.agree.agree.BinaryExpr)2 BoolLitExpr (com.rockwellcollins.atc.agree.agree.BoolLitExpr)2 CallExpr (com.rockwellcollins.atc.agree.agree.CallExpr)2 DoubleDotRef (com.rockwellcollins.atc.agree.agree.DoubleDotRef)2 EventExpr (com.rockwellcollins.atc.agree.agree.EventExpr)2 Expr (com.rockwellcollins.atc.agree.agree.Expr)2 HashMultimap (com.google.common.collect.HashMultimap)1 AgreeAADLEnumerationUtils (com.rockwellcollins.atc.agree.AgreeAADLEnumerationUtils)1 AgreeTypeSystem (com.rockwellcollins.atc.agree.AgreeTypeSystem)1 ArrayTypeDef (com.rockwellcollins.atc.agree.AgreeTypeSystem.ArrayTypeDef)1 RecordTypeDef (com.rockwellcollins.atc.agree.AgreeTypeSystem.RecordTypeDef)1 TypeDef (com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef)1 AgreeTypeSystem.nameOfTypeDef (com.rockwellcollins.atc.agree.AgreeTypeSystem.nameOfTypeDef)1 Abstraction (com.rockwellcollins.atc.agree.agree.Abstraction)1 AgreeContract (com.rockwellcollins.atc.agree.agree.AgreeContract)1