Ejemplo n.º 1
0
        public override EnumEval GetEnumEval(MethodResolutionService methodResolutionService, EventAdapterService eventAdapterService, StreamTypeService streamTypeService, int statementId, string enumMethodUsedName, IList <ExprDotEvalParam> bodiesAndParameters, EventType inputEventType, Type collectionComponentType, int numStreamsIncoming, bool disablePropertyExpressionEventCollCache)
        {
            ExprDotEvalParam first = bodiesAndParameters[0];

            ExprDotEnumerationSource enumSrc = ExprDotNodeUtility.GetEnumerationSource(
                first.Body, streamTypeService, eventAdapterService, statementId, true,
                disablePropertyExpressionEventCollCache);

            if (inputEventType != null)
            {
                base.TypeInfo = EPTypeHelper.CollectionOfEvents(inputEventType);
            }
            else
            {
                base.TypeInfo = EPTypeHelper.CollectionOfSingleValue(collectionComponentType);
            }

            if (enumSrc.Enumeration == null)
            {
                String message = "Enumeration method '" + enumMethodUsedName +
                                 "' requires an expression yielding an event-collection as input paramater";
                throw new ExprValidationException(message);
            }

            var setType = enumSrc.Enumeration.GetEventTypeCollection(eventAdapterService, statementId);

            if (!Equals(setType, inputEventType))
            {
                bool isSubtype = EventTypeUtility.IsTypeOrSubTypeOf(setType, inputEventType);
                if (!isSubtype)
                {
                    String message = "Enumeration method '" + enumMethodUsedName + "' expects event type '" +
                                     inputEventType.Name + "' but receives event type '" +
                                     enumSrc.Enumeration.GetEventTypeCollection(eventAdapterService, statementId).Name +
                                     "'";
                    throw new ExprValidationException(message);
                }
            }

            if (EnumMethodEnum == EnumMethodEnum.UNION)
            {
                return(new EnumEvalUnion(numStreamsIncoming, enumSrc.Enumeration, inputEventType == null));
            }
            else if (EnumMethodEnum == EnumMethodEnum.INTERSECT)
            {
                return(new EnumEvalIntersect(numStreamsIncoming, enumSrc.Enumeration, inputEventType == null));
            }
            else if (EnumMethodEnum == EnumMethodEnum.EXCEPT)
            {
                return(new EnumEvalExcept(numStreamsIncoming, enumSrc.Enumeration, inputEventType == null));
            }
            else
            {
                throw new ArgumentException("Invalid enumeration method for this factory: " + EnumMethodEnum);
            }
        }
Ejemplo n.º 2
0
        public override EnumForgeDescFactory GetForgeFactory(
            DotMethodFP footprint,
            IList<ExprNode> parameters,
            EnumMethodEnum enumMethod,
            String enumMethodUsedName,
            EventType inputEventType,
            Type collectionComponentType,
            ExprValidationContext validationContext)
        {
            var first = parameters[0];

            var enumSrc = ExprDotNodeUtility.GetEnumerationSource(
                first,
                validationContext.StreamTypeService,
                true,
                validationContext.IsDisablePropertyExpressionEventCollCache,
                validationContext.StatementRawInfo,
                validationContext.StatementCompileTimeService);

            EPType type;
            if (inputEventType != null) {
                type = EPTypeHelper.CollectionOfEvents(inputEventType);
            }
            else {
                type = EPTypeHelper.CollectionOfSingleValue(collectionComponentType, null);
            }

            if (inputEventType != null) {
                var setType = enumSrc.Enumeration?.GetEventTypeCollection(
                    validationContext.StatementRawInfo,
                    validationContext.StatementCompileTimeService);

                if (setType == null) {
                    var message = "Enumeration method '" +
                                  enumMethodUsedName +
                                  "' requires an expression yielding a " +
                                  "collection of events of type '" +
                                  inputEventType.Name +
                                  "' as input parameter";
                    throw new ExprValidationException(message);
                }

                if (setType != inputEventType) {
                    var isSubtype = EventTypeUtility.IsTypeOrSubTypeOf(setType, inputEventType);
                    if (!isSubtype) {
                        var message = "Enumeration method '" +
                                      enumMethodUsedName +
                                      "' expects event type '" +
                                      inputEventType.Name +
                                      "' but receives event type '" +
                                      setType.Name +
                                      "'";
                        throw new ExprValidationException(message);
                    }
                }
            }
            else {
                var setType = enumSrc.Enumeration?.ComponentTypeCollection;
                if (setType == null) {
                    var message = "Enumeration method '" +
                                  enumMethodUsedName +
                                  "' requires an expression yielding a " +
                                  "collection of values of type '" +
                                  collectionComponentType.Name +
                                  "' as input parameter";
                    throw new ExprValidationException(message);
                }

                if (!setType.IsAssignmentCompatible(collectionComponentType)) {
                    var message = "Enumeration method '" +
                                  enumMethodUsedName +
                                  "' expects scalar type '" +
                                  collectionComponentType.Name +
                                  "' but receives event type '" +
                                  setType.Name +
                                  "'";
                    throw new ExprValidationException(message);
                }
            }

            return new EnumForgeDescFactoryEIU(enumMethod, type, enumSrc);
        }
Ejemplo n.º 3
0
        public override EnumForge GetEnumForge(StreamTypeService streamTypeService,
            string enumMethodUsedName,
            IList<ExprDotEvalParam> bodiesAndParameters,
            EventType inputEventType,
            Type collectionComponentType,
            int numStreamsIncoming,
            bool disablePropertyExpressionEventCollCache,
            StatementRawInfo statementRawInfo,
            StatementCompileTimeServices services)
        {
            var first = bodiesAndParameters[0];

            var enumSrc = ExprDotNodeUtility.GetEnumerationSource(
                first.Body,
                streamTypeService,
                true,
                disablePropertyExpressionEventCollCache,
                statementRawInfo,
                services);
            if (inputEventType != null) {
                TypeInfo = EPTypeHelper.CollectionOfEvents(inputEventType);
            }
            else {
                TypeInfo = EPTypeHelper.CollectionOfSingleValue(collectionComponentType, null);
            }

            if (inputEventType != null) {
                var setType = enumSrc.Enumeration == null
                    ? null
                    : enumSrc.Enumeration.GetEventTypeCollection(statementRawInfo, services);
                if (setType == null) {
                    var message = "Enumeration method '" +
                                     enumMethodUsedName +
                                     "' requires an expression yielding a " +
                                     "collection of events of type '" +
                                     inputEventType.Name +
                                     "' as input parameter";
                    throw new ExprValidationException(message);
                }

                if (setType != inputEventType) {
                    var isSubtype = EventTypeUtility.IsTypeOrSubTypeOf(setType, inputEventType);
                    if (!isSubtype) {
                        var message = "Enumeration method '" +
                                         enumMethodUsedName +
                                         "' expects event type '" +
                                         inputEventType.Name +
                                         "' but receives event type '" +
                                         setType.Name +
                                         "'";
                        throw new ExprValidationException(message);
                    }
                }
            }
            else {
                var setType = enumSrc.Enumeration?.ComponentTypeCollection;
                if (setType == null) {
                    var message = "Enumeration method '" +
                                     enumMethodUsedName +
                                     "' requires an expression yielding a " +
                                     "collection of values of type '" +
                                     collectionComponentType.CleanName() +
                                     "' as input parameter";
                    throw new ExprValidationException(message);
                }

                if (!TypeHelper.IsAssignmentCompatible(setType, collectionComponentType)) {
                    var message = "Enumeration method '" +
                                     enumMethodUsedName +
                                     "' expects scalar type '" +
                                     collectionComponentType.Name +
                                     "' but receives event type '" +
                                     setType.Name +
                                     "'";
                    throw new ExprValidationException(message);
                }
            }

            if (EnumMethodEnum == EnumMethodEnum.UNION) {
                return new EnumUnionForge(numStreamsIncoming, enumSrc.Enumeration, inputEventType == null);
            }
            else if (EnumMethodEnum == EnumMethodEnum.INTERSECT) {
                return new EnumIntersectForge(numStreamsIncoming, enumSrc.Enumeration, inputEventType == null);
            }
            else if (EnumMethodEnum == EnumMethodEnum.EXCEPT) {
                return new EnumExceptForge(numStreamsIncoming, enumSrc.Enumeration, inputEventType == null);
            }
            else {
                throw new ArgumentException("Invalid enumeration method for this factory: " + EnumMethodEnum);
            }
        }