Beispiel #1
0
        public override void Initialize(
            DotMethodFP footprint,
            EnumMethodEnum enumMethod,
            string enumMethodUsedName,
            EventType inputEventType,
            Type collectionComponentType,
            IList<ExprNode> parameters,
            StreamTypeService streamTypeService,
            StatementRawInfo statementRawInfo,
            StatementCompileTimeServices services)
        {
            // validate
            var ctx = new EnumMethodValidateContext(
                footprint,
                inputEventType,
                collectionComponentType,
                streamTypeService,
                enumMethod,
                parameters,
                statementRawInfo);
            var enumMethodMode = _forgeFactory.Validate(ctx);
            if (!(enumMethodMode is EnumMethodModeStaticMethod)) {
                throw new ExprValidationException("Unexpected EnumMethodMode implementation, expected a provided implementation");
            }

            Mode = (EnumMethodModeStaticMethod) enumMethodMode;
        }
            public EnumMethodDescriptor Initialize(EnumMethodInitializeContext context)
            {
                var footprints = new DotMethodFP[] {
                    new DotMethodFP(DotMethodFPInputEnum.ANY, new DotMethodFPParam(2, "value, index", EPLExpressionParamType.BOOLEAN))
                };

                return(new EnumMethodDescriptor(footprints));
            }
            public EnumMethodDescriptor Initialize(EnumMethodInitializeContext context)
            {
                var footprints = new DotMethodFP[] {
                    new DotMethodFP(DotMethodFPInputEnum.EVENTCOLL, new DotMethodFPParam(1, "predicate", EPLExpressionParamType.BOOLEAN))
                };

                return(new EnumMethodDescriptor(footprints));
            }
Beispiel #4
0
 public abstract EnumForgeDescFactory GetForgeFactory(
     DotMethodFP footprint,
     IList<ExprNode> parameters,
     EnumMethodEnum enumMethod,
     string enumMethodUsedName,
     EventType inputEventType,
     Type collectionComponentType,
     ExprValidationContext validationContext);
Beispiel #5
0
 public override EnumForgeDescFactory GetForgeFactory(
     DotMethodFP footprint,
     IList<ExprNode> parameters,
     EnumMethodEnum enumMethod,
     String enumMethodUsedName,
     EventType inputEventType,
     Type collectionComponentType,
     ExprValidationContext validationContext)
 {
     return new EnumForgeDescFactorySeqEqual(inputEventType == null);
 }
Beispiel #6
0
	    /// <summary>
	    ///     Ctor.
	    /// </summary>
	    /// <param name="footprintFound">actual footprint chosen</param>
	    /// <param name="streamTypeService">event type information</param>
	    /// <param name="currentMethod">information on the current method</param>
	    /// <param name="currentParameters">parameters</param>
	    /// <param name="statementRawInfo">EPL statement information</param>
	    public DateTimeMethodValidateContext(
            DotMethodFP footprintFound,
            StreamTypeService streamTypeService,
            DatetimeMethodDesc currentMethod,
            IList<ExprNode> currentParameters,
            StatementRawInfo statementRawInfo)
        {
            FootprintFound = footprintFound;
            StreamTypeService = streamTypeService;
            CurrentMethod = currentMethod;
            CurrentParameters = currentParameters;
            StatementRawInfo = statementRawInfo;
        }
Beispiel #7
0
 public virtual void Initialize(
     DotMethodFP footprint,
     EnumMethodEnum enumMethod,
     string enumMethodUsedName,
     EventType inputEventType,
     Type collectionComponentType,
     IList<ExprNode> parameters,
     StreamTypeService streamTypeService,
     StatementRawInfo statementRawInfo,
     StatementCompileTimeServices services)
 {
     // override as required
 }
Beispiel #8
0
	    /// <summary>
	    ///     Ctor.
	    /// </summary>
	    /// <param name="footprintFound">actual footprint chosen</param>
	    /// <param name="inputEventType">input event type or null if the input is not a collection of events</param>
	    /// <param name="inputCollectionComponentType">type of scalar or object (non-event) input values, or null if the input is a collection of events</param>
	    /// <param name="streamTypeService">event type information</param>
	    /// <param name="currentMethod">information on the current method</param>
	    /// <param name="currentParameters">parameters</param>
	    /// <param name="statementRawInfo">EPL statement information</param>
	    public EnumMethodValidateContext(
            DotMethodFP footprintFound,
            EventType inputEventType,
            Type inputCollectionComponentType,
            StreamTypeService streamTypeService,
            EnumMethodEnum currentMethod,
            IList<ExprNode> currentParameters,
            StatementRawInfo statementRawInfo)
        {
            FootprintFound = footprintFound;
            InputEventType = inputEventType;
            InputCollectionComponentType = inputCollectionComponentType;
            StreamTypeService = streamTypeService;
            CurrentMethod = currentMethod;
            CurrentParameters = currentParameters;
            StatementRawInfo = statementRawInfo;
        }
 public override EnumForgeDescFactory GetForgeFactory(
     DotMethodFP footprint,
     IList<ExprNode> parameters,
     EnumMethodEnum enumMethod,
     String enumMethodUsedName,
     EventType inputEventType,
     Type collectionComponentType,
     ExprValidationContext validationContext) 
 {
     EPType type;
     if (inputEventType != null) {
         type = EPTypeHelper.CollectionOfEvents(inputEventType);
     } else {
         type = EPTypeHelper.CollectionOfSingleValue(collectionComponentType, null);
     }
     return new EnumForgeDescFactoryTake(enumMethod, type, inputEventType == null);
 }
Beispiel #10
0
        public override EnumForgeDescFactory GetForgeFactory(
            DotMethodFP footprint,
            IList <ExprNode> parameters,
            EnumMethodEnum enumMethod,
            string enumMethodUsedName,
            EventType inputEventType,
            Type collectionComponentType,
            ExprValidationContext validationContext)
        {
            var goesNode      = (ExprLambdaGoesNode)parameters[1];
            var numParameters = goesNode.GoesToNames.Count;
            var firstName     = goesNode.GoesToNames[0];
            var secondName    = goesNode.GoesToNames[1];

            IDictionary <string, object> fields = new Dictionary <string, object>();
            var initializationType = parameters[0].Forge.EvaluationType;

            fields.Put(firstName, initializationType);
            if (inputEventType == null)
            {
                fields.Put(secondName, collectionComponentType);
            }

            if (numParameters > 2)
            {
                fields.Put(goesNode.GoesToNames[2], typeof(int));
                if (numParameters > 3)
                {
                    fields.Put(goesNode.GoesToNames[3], typeof(int));
                }
            }

            var evalEventType = ExprDotNodeUtility.MakeTransientOAType(
                enumMethodUsedName,
                fields,
                validationContext.StatementRawInfo,
                validationContext.StatementCompileTimeService);

            if (inputEventType == null)
            {
                return(new EnumForgeDescFactoryAggregateScalar(evalEventType));
            }

            return(new EnumForgeDescFactoryAggregateEvent(evalEventType, inputEventType, secondName, numParameters));
        }
Beispiel #11
0
 public EnumForgeDescFactoryPlugin(
     EnumMethodModeStaticMethod mode,
     string enumMethodUsedName,
     DotMethodFP footprint,
     IList<ExprNode> parameters,
     EventType inputEventType,
     Type collectionComponentType,
     StatementRawInfo raw,
     StatementCompileTimeServices services)
 {
     _mode = mode;
     _enumMethodUsedName = enumMethodUsedName;
     _footprint = footprint;
     _parameters = parameters;
     _inputEventType = inputEventType;
     _collectionComponentType = collectionComponentType;
     _raw = raw;
     _services = services;
 }
Beispiel #12
0
 public override EnumForgeDescFactory GetForgeFactory(
     DotMethodFP footprint,
     IList<ExprNode> parameters,
     EnumMethodEnum enumMethod,
     string enumMethodUsedName,
     EventType inputEventType,
     Type collectionComponentType,
     ExprValidationContext validationContext)
 {
     return new ProxyEnumForgeDescFactory() {
         ProcGetLambdaStreamTypesForParameter = parameterNum => new EnumForgeLambdaDesc(new EventType[0], new String[0]),
         ProcMakeEnumForgeDesc = (
             bodiesAndParameters,
             streamCountIncoming,
             services) => {
             var type = EPTypeHelper.CollectionOfEvents(inputEventType);
             return new EnumForgeDesc(type, new EnumForgeNoOp(streamCountIncoming));
         }
     };
 }
Beispiel #13
0
        public override EnumForgeDescFactory GetForgeFactory(
            DotMethodFP footprint,
            IList<ExprNode> parameters,
            EnumMethodEnum enumMethod,
            string enumMethodUsedName,
            EventType inputEventType,
            Type collectionComponentType,
            ExprValidationContext validationContext)
        {
            if (Mode == null) {
                throw new IllegalStateException("Initialize did not take place");
            }

            return new EnumForgeDescFactoryPlugin(
                Mode,
                enumMethodUsedName,
                footprint,
                parameters,
                inputEventType,
                collectionComponentType,
                validationContext.StatementRawInfo,
                validationContext.StatementCompileTimeService);
        }
        public override EnumForgeDescFactory GetForgeFactory(
            DotMethodFP footprint,
            IList <ExprNode> parameters,
            EnumMethodEnum enumMethod,
            string enumMethodUsedName,
            EventType inputEventType,
            Type collectionComponentType,
            ExprValidationContext validationContext)
        {
            if (parameters.IsEmpty())
            {
                var typeX = InitAndNoParamsReturnType(inputEventType, collectionComponentType);
                return(new ThreeFormNoParamFactory(typeX, NoParamsForge(enumMethod, typeX, validationContext.StatementCompileTimeService)));
            }

            var goesNode    = (ExprLambdaGoesNode)parameters[0];
            var goesToNames = goesNode.GoesToNames;

            if (inputEventType != null)
            {
                var streamName = goesToNames[0];
                if (goesToNames.Count == 1)
                {
                    return(new ThreeFormEventPlainFactory(
                               InitAndSingleParamReturnType(inputEventType, collectionComponentType),
                               inputEventType,
                               streamName,
                               SingleParamEventPlain(enumMethod)));
                }

                IDictionary <string, object> fieldsX = new LinkedHashMap <string, object>();
                fieldsX.Put(goesToNames[1], typeof(int?));
                if (goesToNames.Count > 2)
                {
                    fieldsX.Put(goesToNames[2], typeof(int?));
                }

                var fieldType = ExprDotNodeUtility.MakeTransientOAType(
                    enumMethodUsedName,
                    fieldsX,
                    validationContext.StatementRawInfo,
                    validationContext.StatementCompileTimeService);
                return(new ThreeFormEventPlusFactory(
                           InitAndSingleParamReturnType(inputEventType, collectionComponentType),
                           inputEventType,
                           streamName,
                           fieldType,
                           goesToNames.Count,
                           SingleParamEventPlus(enumMethod)));
            }

            var fields = new LinkedHashMap <string, object>();

            fields.Put(goesToNames[0], collectionComponentType);
            if (goesToNames.Count > 1)
            {
                fields.Put(goesToNames[1], typeof(int?));
            }

            if (goesToNames.Count > 2)
            {
                fields.Put(goesToNames[2], typeof(int?));
            }

            var type = ExprDotNodeUtility.MakeTransientOAType(
                enumMethodUsedName,
                fields,
                validationContext.StatementRawInfo,
                validationContext.StatementCompileTimeService);

            return(new ThreeFormScalarFactory(
                       InitAndSingleParamReturnType(inputEventType, collectionComponentType),
                       type,
                       goesToNames.Count,
                       SingleParamScalar(enumMethod)));
        }
Beispiel #15
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);
        }
Beispiel #16
0
        public override EnumForgeDescFactory GetForgeFactory(
            DotMethodFP footprint,
            IList <ExprNode> parameters,
            EnumMethodEnum enumMethod,
            string enumMethodUsedName,
            EventType inputEventType,
            Type collectionComponentType,
            ExprValidationContext validationContext)
        {
            if (parameters.Count < 2)
            {
                throw new IllegalStateException();
            }

            EPType             returnType   = ReturnType(inputEventType, collectionComponentType);
            ExprLambdaGoesNode lambdaFirst  = (ExprLambdaGoesNode)parameters[0];
            ExprLambdaGoesNode lambdaSecond = (ExprLambdaGoesNode)parameters[1];

            if (lambdaFirst.GoesToNames.Count != lambdaSecond.GoesToNames.Count)
            {
                throw new ExprValidationException(
                          "Enumeration method '" + enumMethodUsedName + "' expected the same number of parameters for both the key and the value expression");
            }

            int numParameters = lambdaFirst.GoesToNames.Count;

            if (inputEventType != null)
            {
                string streamNameFirst  = lambdaFirst.GoesToNames[0];
                string streamNameSecond = lambdaSecond.GoesToNames[0];
                if (numParameters == 1)
                {
                    return(new TwoLambdaThreeFormEventPlainFactory(inputEventType, streamNameFirst, streamNameSecond, returnType, TwoParamEventPlain()));
                }

                IDictionary <string, object> fieldsFirst  = new Dictionary <string, object>();
                IDictionary <string, object> fieldsSecond = new Dictionary <string, object>();
                fieldsFirst.Put(lambdaFirst.GoesToNames[1], typeof(int?));
                fieldsSecond.Put(lambdaSecond.GoesToNames[1], typeof(int?));
                if (numParameters > 2)
                {
                    fieldsFirst.Put(lambdaFirst.GoesToNames[2], typeof(int?));
                    fieldsSecond.Put(lambdaSecond.GoesToNames[2], typeof(int?));
                }

                ObjectArrayEventType typeFirst = ExprDotNodeUtility.MakeTransientOAType(
                    enumMethodUsedName,
                    fieldsFirst,
                    validationContext.StatementRawInfo,
                    validationContext.StatementCompileTimeService);
                ObjectArrayEventType typeSecond = ExprDotNodeUtility.MakeTransientOAType(
                    enumMethodUsedName,
                    fieldsSecond,
                    validationContext.StatementRawInfo,
                    validationContext.StatementCompileTimeService);
                return(new TwoLambdaThreeFormEventPlusFactory(
                           inputEventType,
                           streamNameFirst,
                           streamNameSecond,
                           typeFirst,
                           typeSecond,
                           lambdaFirst.GoesToNames.Count,
                           returnType,
                           TwoParamEventPlus()));
            }
            else
            {
                IDictionary <string, object> fieldsFirst  = new Dictionary <string, object>();
                IDictionary <string, object> fieldsSecond = new Dictionary <string, object>();
                fieldsFirst.Put(lambdaFirst.GoesToNames[0], collectionComponentType);
                fieldsSecond.Put(lambdaSecond.GoesToNames[0], collectionComponentType);
                if (numParameters > 1)
                {
                    fieldsFirst.Put(lambdaFirst.GoesToNames[1], typeof(int?));
                    fieldsSecond.Put(lambdaSecond.GoesToNames[1], typeof(int?));
                }

                if (numParameters > 2)
                {
                    fieldsFirst.Put(lambdaFirst.GoesToNames[2], typeof(int?));
                    fieldsSecond.Put(lambdaSecond.GoesToNames[2], typeof(int?));
                }

                ObjectArrayEventType typeFirst = ExprDotNodeUtility.MakeTransientOAType(
                    enumMethodUsedName,
                    fieldsFirst,
                    validationContext.StatementRawInfo,
                    validationContext.StatementCompileTimeService);
                ObjectArrayEventType typeSecond = ExprDotNodeUtility.MakeTransientOAType(
                    enumMethodUsedName,
                    fieldsSecond,
                    validationContext.StatementRawInfo,
                    validationContext.StatementCompileTimeService);

                return(new TwoLambdaThreeFormScalarFactory(
                           typeFirst,
                           typeSecond,
                           lambdaFirst.GoesToNames.Count,
                           returnType,
                           TwoParamScalar()));
            }
        }
Beispiel #17
0
        public void Init(
            int? streamOfProviderIfApplicable,
            EnumMethodEnum enumMethodEnum,
            string enumMethodUsedName,
            EPType typeInfo,
            IList<ExprNode> parameters,
            ExprValidationContext validationContext)
        {
            var eventTypeColl = typeInfo.GetEventTypeMultiValued();
            var eventTypeBean = typeInfo.GetEventTypeSingleValued();
            var collectionComponentType = typeInfo.GetClassMultiValued();

            this.enumMethodEnum = enumMethodEnum;
            this.enumMethodUsedName = enumMethodUsedName;
            streamCountIncoming = validationContext.StreamTypeService.EventTypes.Length;

            if (eventTypeColl == null && collectionComponentType == null && eventTypeBean == null) {
                throw new ExprValidationException(
                    "Invalid input for built-in enumeration method '" +
                    enumMethodUsedName +
                    "', expecting collection of event-type or scalar values as input, received " +
                    typeInfo.ToTypeDescriptive());
            }

            // compile parameter abstract for validation against available footprints
            DotMethodFPProvided footprintProvided = DotMethodUtil.GetProvidedFootprint(parameters);

            // validate parameters
            DotMethodInputTypeMatcher inputTypeMatcher = new ProxyDotMethodInputTypeMatcher {
                ProcMatches = fp => {
                    if (fp.Input == DotMethodFPInputEnum.EVENTCOLL &&
                        eventTypeBean == null &&
                        eventTypeColl == null) {
                        return false;
                    }

                    if (fp.Input == DotMethodFPInputEnum.SCALAR_ANY && collectionComponentType == null) {
                        return false;
                    }

                    return true;
                }
            };

            DotMethodFP footprint = DotMethodUtil.ValidateParametersDetermineFootprint(
                enumMethodEnum.GetFootprints(),
                DotMethodTypeEnum.ENUM,
                enumMethodUsedName,
                footprintProvided,
                inputTypeMatcher);

            // validate input criteria met for this footprint
            if (footprint.Input != DotMethodFPInputEnum.ANY) {
                var message = "Invalid input for built-in enumeration method '" +
                              enumMethodUsedName +
                              "' and " +
                              footprint.Parameters.Length +
                              "-parameter footprint, expecting collection of ";
                var received = " as input, received " + EPTypeHelper.ToTypeDescriptive(typeInfo);
                if (footprint.Input == DotMethodFPInputEnum.EVENTCOLL && eventTypeColl == null) {
                    throw new ExprValidationException(message + "events" + received);
                }

                if (footprint.Input.IsScalar() && collectionComponentType == null) {
                    throw new ExprValidationException(message + "values (typically scalar values)" + received);
                }

                if (footprint.Input == DotMethodFPInputEnum.SCALAR_NUMERIC && !collectionComponentType.IsNumeric()) {
                    throw new ExprValidationException(message + "numeric values" + received);
                }
            }

            // manage context of this lambda-expression in regards to outer lambda-expression that may call this one.
            var enumCallStackHelper = validationContext.EnumMethodCallStackHelper;
            enumCallStackHelper.PushStack(this);

            IList<ExprDotEvalParam> bodiesAndParameters = new List<ExprDotEvalParam>();
            var count = 0;
            var inputEventType = eventTypeBean == null ? eventTypeColl : eventTypeBean;
            foreach (var node in parameters) {
                var bodyAndParameter = GetBodyAndParameter(
                    enumMethodUsedName,
                    count++,
                    node,
                    inputEventType,
                    collectionComponentType,
                    validationContext,
                    bodiesAndParameters,
                    footprint);
                bodiesAndParameters.Add(bodyAndParameter);
            }

            enumForge = GetEnumForge(
                validationContext.StreamTypeService,
                enumMethodUsedName,
                bodiesAndParameters,
                inputEventType, // TBD: collectionType, may not be applicable
                collectionComponentType,
                streamCountIncoming,
                validationContext.IsDisablePropertyExpressionEventCollCache,
                validationContext.StatementRawInfo,
                validationContext.StatementCompileTimeService);
            enumEvalNumRequiredEvents = enumForge.StreamNumSize;

            // determine the stream ids of event properties asked for in the evaluator(s)
            var streamsRequired = new HashSet<int>();
            var visitor = new ExprNodeIdentifierCollectVisitor();
            foreach (var desc in bodiesAndParameters) {
                desc.Body.Accept(visitor);
                foreach (var ident in visitor.ExprProperties) {
                    streamsRequired.Add(ident.StreamId);
                }
            }

            if (streamOfProviderIfApplicable != null) {
                streamsRequired.Add(streamOfProviderIfApplicable.Value);
            }

            // We turn on caching if the stack is not empty (we are an inner lambda) and the dependency does not include the stream.
            var isInner = !enumCallStackHelper.PopLambda();
            if (isInner) {
                // If none of the properties that the current lambda uses comes from the ultimate parent(s) or subsequent streams, then cache.
                Deque<ExpressionResultCacheStackEntry> parents = enumCallStackHelper.GetStack();
                var found = false;
                foreach (var req in streamsRequired) {
                    var first = (ExprDotForgeEnumMethodBase) parents.First;
                    var parentIncoming = first.streamCountIncoming - 1;
                    var selfAdded = streamCountIncoming; // the one we use ourselfs
                    if (req > parentIncoming && req < selfAdded) {
                        found = true;
                    }
                }

                cache = !found;
            }
        }
        private ExprDotEvalParam GetBodyAndParameter(
            String enumMethodUsedName,
            int parameterNum,
            ExprNode parameterNode,
            EventType inputEventType,
            Type collectionComponentType,
            ExprValidationContext validationContext,
            IList <ExprDotEvalParam> priorParameters,
            DotMethodFP footprint)
        {
            // handle an expression that is a constant or other (not =>)
            if (!(parameterNode is ExprLambdaGoesNode))
            {
                // no node subtree validation is required here, the chain parameter validation has taken place in ExprDotNode.validate
                // validation of parameter types has taken place in footprint matching
                return(new ExprDotEvalParamExpr(parameterNum, parameterNode, parameterNode.ExprEvaluator));
            }

            var goesNode = (ExprLambdaGoesNode)parameterNode;

            // Get secondary
            var additionalTypes = GetAddStreamTypes(
                enumMethodUsedName, goesNode.GoesToNames, inputEventType, collectionComponentType, priorParameters, validationContext.EventAdapterService);
            var additionalStreamNames = goesNode.GoesToNames.ToArray();

            ValidateDuplicateStreamNames(validationContext.StreamTypeService.StreamNames, additionalStreamNames);

            // add name and type to list of known types
            var addTypes =
                (EventType[])
                CollectionUtil.ArrayExpandAddElements(
                    validationContext.StreamTypeService.EventTypes, additionalTypes);
            var addNames =
                (String[])
                CollectionUtil.ArrayExpandAddElements(
                    validationContext.StreamTypeService.StreamNames, additionalStreamNames);

            var types = new StreamTypeServiceImpl(
                addTypes, addNames, new bool[addTypes.Length], null, false);

            // validate expression body
            var filter = goesNode.ChildNodes[0];

            try
            {
                var filterValidationContext = new ExprValidationContext(types, validationContext);
                filter = ExprNodeUtility.GetValidatedSubtree(ExprNodeOrigin.DECLAREDEXPRBODY, filter, filterValidationContext);
            }
            catch (ExprValidationException ex)
            {
                throw new ExprValidationException(
                          "Error validating enumeration method '" + enumMethodUsedName + "' parameter " + parameterNum + ": " +
                          ex.Message, ex);
            }

            var filterEvaluator = filter.ExprEvaluator;
            var expectedType    = footprint.Parameters[parameterNum].ParamType;

            // Lambda-methods don't use a specific expected return-type, so passing null for type is fine.
            DotMethodUtil.ValidateSpecificType(
                enumMethodUsedName, DotMethodTypeEnum.ENUM, expectedType, null, filterEvaluator.ReturnType, parameterNum,
                filter);

            var numStreamsIncoming = validationContext.StreamTypeService.EventTypes.Length;

            return(new ExprDotEvalParamLambda(
                       parameterNum, filter, filterEvaluator,
                       numStreamsIncoming, goesNode.GoesToNames, additionalTypes));
        }
Beispiel #19
0
        private ExprDotEvalParam GetBodyAndParameter(
            EnumForgeDescFactory forgeDescFactory,
            string enumMethodUsedName,
            int parameterNum,
            ExprNode parameterNode,
            ExprValidationContext validationContext,
            DotMethodFP footprint)
        {
            // handle an expression that is a constant or other (not =>)
            if (!(parameterNode is ExprLambdaGoesNode)) {
                // no node subtree validation is required here, the chain parameter validation has taken place in ExprDotNode.validate
                // validation of parameter types has taken place in footprint matching
                return new ExprDotEvalParamExpr(parameterNum, parameterNode, parameterNode.Forge);
            }

            var goesNode = (ExprLambdaGoesNode) parameterNode;

            // Get secondary
            var lambdaDesc = forgeDescFactory.GetLambdaStreamTypesForParameter(parameterNum);
            string[] additionalStreamNames = lambdaDesc.StreamNames;
            var additionalEventTypes = lambdaDesc.Types;

            ValidateDuplicateStreamNames(validationContext.StreamTypeService.StreamNames, goesNode.GoesToNames);

            // add name and type to list of known types
            var addTypes = CollectionUtil.ArrayExpandAddElements<EventType>(
                validationContext.StreamTypeService.EventTypes, additionalEventTypes);
            var addNames = CollectionUtil.ArrayExpandAddElements<string>(
                validationContext.StreamTypeService.StreamNames, additionalStreamNames);

            var types = new StreamTypeServiceImpl(
                addTypes,
                addNames,
                new bool[addTypes.Length],
                false,
                validationContext.StreamTypeService.IsOptionalStreams);

            // validate expression body
            var filter = goesNode.ChildNodes[0];
            try {
                var filterValidationContext = new ExprValidationContext(types, validationContext);
                filter = ExprNodeUtilityValidate.GetValidatedSubtree(ExprNodeOrigin.DECLAREDEXPRBODY, filter, filterValidationContext);
            }
            catch (ExprValidationException ex) {
                throw new ExprValidationException(
                    "Failed to validate enumeration method '" + enumMethodUsedName + "' parameter " + parameterNum + ": " + ex.Message,
                    ex);
            }

            var filterForge = filter.Forge;
            var expectedType = footprint.Parameters[parameterNum].ParamType;
            // Lambda-methods don't use a specific expected return-type, so passing null for type is fine.
            EPLValidationUtil.ValidateParameterType(
                enumMethodUsedName,
                DotMethodTypeEnum.ENUM.GetTypeName(),
                false,
                expectedType,
                null,
                filterForge.EvaluationType,
                parameterNum,
                filter);

            var numStreamsIncoming = validationContext.StreamTypeService.EventTypes.Length;
            return new ExprDotEvalParamLambda(
                parameterNum,
                filter,
                filterForge,
                numStreamsIncoming,
                goesNode.GoesToNames,
                lambdaDesc);
        }