コード例 #1
0
 public override CodegenMethod MakeCodegen(
     CodegenMethodScope parent,
     SAIFFInitializeSymbolWEventType symbols,
     CodegenClassScope classScope)
 {
     var method = parent.MakeChild(
         typeof(FilterSpecLookupableAdvancedIndex),
         typeof(FilterSpecLookupableAdvancedIndexForge),
         classScope);
     Func<EventPropertyGetterSPI, CodegenExpression> toEval = getter =>
         EventTypeUtility.CodegenGetterWCoerce(getter, typeof(double?), null, method, GetType(), classScope);
     method.Block
         .DeclareVar<FilterSpecLookupableAdvancedIndex>(
             "lookupable",
             NewInstance<FilterSpecLookupableAdvancedIndex>(
                 Constant(Expression),
                 ConstantNull(),
                 Typeof(ReturnType)))
         .SetProperty(Ref("lookupable"), "QuadTreeConfig", QuadTreeConfig.Make())
         .SetProperty(Ref("lookupable"), "X", toEval.Invoke(_x))
         .SetProperty(Ref("lookupable"), "Y", toEval.Invoke(_y))
         .SetProperty(Ref("lookupable"), "Width", toEval.Invoke(_width))
         .SetProperty(Ref("lookupable"), "Height", toEval.Invoke(_height))
         .SetProperty(Ref("lookupable"), "IndexType", Constant(IndexType))
         .Expression(
             ExprDotMethodChain(symbols.GetAddInitSvc(method))
                 .Get(EPStatementInitServicesConstants.FILTERSHAREDLOOKUPABLEREGISTERY)
                 .Add(
                     "RegisterLookupable",
                     symbols.GetAddEventType(method),
                     Ref("lookupable")))
         .MethodReturn(Ref("lookupable"));
     return method;
 }
コード例 #2
0
        public virtual CodegenMethod MakeCodegen(
            CodegenMethodScope parent,
            SAIFFInitializeSymbolWEventType symbols,
            CodegenClassScope classScope)
        {
            var method = parent.MakeChild(
                typeof(ExprFilterSpecLookupable),
                typeof(ExprFilterSpecLookupableForge),
                classScope);
            CodegenExpression singleEventEvalExpr = ConstantNull();
            if (_optionalEventEvalForge != null) {
                var eval = new CodegenExpressionLambda(method.Block)
                    .WithParam<EventBean>("bean")
                    .WithParam<ExprEvaluatorContext>("ctx");
                var anonymous = NewInstance<ProxyExprEventEvaluator>(eval);
                eval.Block.BlockReturn(
                    _optionalEventEvalForge.EventBeanWithCtxGet(Ref("bean"), Ref("ctx"), method, classScope));
                singleEventEvalExpr = anonymous;
            }

            CodegenExpression epsEvalExpr = ConstantNull();
            if (_optionalExprForge != null) {
                epsEvalExpr = ExprNodeUtilityCodegen.CodegenEvaluator(
                    _optionalExprForge, method, typeof(ExprFilterSpecLookupableForge), classScope);
            }

            CodegenExpression serdeExpr = _valueSerde == null ? ConstantNull() : _valueSerde.Codegen(method, classScope, null);
            CodegenExpression returnTypeExpr = _returnType == null ? ConstantNull() : Typeof(_returnType);

            method.Block
                .DeclareVar<ExprEventEvaluator>("eval", singleEventEvalExpr)
                .DeclareVar<ExprEvaluator>("expr", epsEvalExpr)
                .DeclareVar<ExprFilterSpecLookupable>(
                    "lookupable",
                    NewInstance<ExprFilterSpecLookupable>(
                        Constant(_expression),
                        Ref("eval"),
                        Ref("expr"),
                        returnTypeExpr,
                        Constant(_isNonPropertyGetter),
                        serdeExpr))
                .Expression(
                    ExprDotMethodChain(symbols.GetAddInitSvc(method))
                        .Get(EPStatementInitServicesConstants.FILTERSHAREDLOOKUPABLEREGISTERY)
                        .Add(
                            "RegisterLookupable",
                            symbols.GetAddEventType(method),
                            Ref("lookupable")))
                .MethodReturn(Ref("lookupable"));
            return method;
        }
コード例 #3
0
        public virtual CodegenMethod MakeCodegen(
            CodegenMethodScope parent,
            SAIFFInitializeSymbolWEventType symbols,
            CodegenClassScope classScope)
        {
            var method = parent.MakeChild(
                typeof(ExprFilterSpecLookupable),
                typeof(ExprFilterSpecLookupableForge),
                classScope);
            CodegenExpression getterExpr;
            if (optionalEventPropForge != null) {
                var get = new CodegenExpressionLambda(method.Block)
                    .WithParams(CodegenNamedParam.From(typeof(EventBean), "bean"));
                var anonymous = NewInstance<ProxyEventPropertyValueGetter>(get);

                //var anonymous = NewAnonymousClass(method.Block, typeof(EventPropertyValueGetter));
                //var get = CodegenMethod.MakeParentNode(typeof(object), GetType(), classScope)
                //    .AddParam(CodegenNamedParam.From(typeof(EventBean), "bean"));
                //anonymous.AddMethod("Get", get);

                get.Block.BlockReturn(optionalEventPropForge.EventBeanGetCodegen(Ref("bean"), method, classScope));
                getterExpr = anonymous;
            }
            else {
                getterExpr = ConstantNull();
            }

            method.Block.DeclareVar<EventPropertyValueGetter>("getter", getterExpr);

            method.Block
                .DeclareVar<ExprFilterSpecLookupable>(
                    "lookupable",
                    NewInstance<ExprFilterSpecLookupable>(
                        Constant(expression),
                        Ref("getter"),
                        Typeof(returnType),
                        Constant(isNonPropertyGetter)))
                .Expression(
                    ExprDotMethodChain(symbols.GetAddInitSvc(method))
                        .Get(EPStatementInitServicesConstants.FILTERSHAREDLOOKUPABLEREGISTERY)
                        .Add(
                            "RegisterLookupable",
                            symbols.GetAddEventType(method),
                            Ref("lookupable")))
                .MethodReturn(Ref("lookupable"));
            return method;
        }
コード例 #4
0
        public override CodegenMethod MakeCodegen(
            CodegenClassScope classScope,
            CodegenMethodScope parent,
            SAIFFInitializeSymbolWEventType symbols)
        {
            if (FilterBoolExprId == -1) {
                throw new IllegalStateException("Unassigned filter boolean expression path num");
            }

            var method = parent.MakeChild(typeof(FilterSpecParamExprNode), GetType(), classScope);
            method.Block
                .DeclareVar<ExprFilterSpecLookupable>(
                    "lookupable",
                    LocalMethod(lookupable.MakeCodegen(method, symbols, classScope)))
                .DeclareVar<FilterOperator>("filterOperator", EnumValue(typeof(FilterOperator), filterOperator.GetName()));

            // getFilterValue-FilterSpecParamExprNode code
            //var param = NewAnonymousClass(
            //    method.Block,
            //    typeof(FilterSpecParamExprNode),
            //    Arrays.AsList<CodegenExpression>(Ref("lookupable"), Ref("filterOperator")));
            //var getFilterValue = CodegenMethod.MakeMethod(typeof(object), GetType(), classScope)
            //    .AddParam(GET_FILTER_VALUE_FP);
            //param.AddMethod("GetFilterValue", getFilterValue);

            var getFilterValue = new CodegenExpressionLambda(method.Block)
                .WithParams(GET_FILTER_VALUE_FP);

            var param = NewInstance<ProxyFilterSpecParamExprNode>(
                Ref("lookupable"),
                Ref("filterOperator"));

            if (TaggedEventTypes != null && !TaggedEventTypes.IsEmpty() ||
                _arrayEventTypes != null && !_arrayEventTypes.IsEmpty()) {
                var size = TaggedEventTypes?.Count ?? 0;
                size += _arrayEventTypes?.Count ?? 0;
                getFilterValue.Block.DeclareVar<EventBean[]>(
                    "events",
                    NewArrayByLength(typeof(EventBean), Constant(size + 1)));

                var count = 1;
                if (TaggedEventTypes != null) {
                    foreach (var tag in TaggedEventTypes.Keys) {
                        getFilterValue.Block.AssignArrayElement(
                            "events",
                            Constant(count),
                            ExprDotMethod(REF_MATCHEDEVENTMAP, "GetMatchingEventByTag", Constant(tag)));
                        count++;
                    }
                }

                if (_arrayEventTypes != null) {
                    foreach (var entry in _arrayEventTypes) {
                        var compositeEventType = entry.Value.First;
                        var compositeEventTypeMember = classScope.AddDefaultFieldUnshared(
                            true,
                            typeof(EventType),
                            EventTypeUtility.ResolveTypeCodegen(
                                compositeEventType,
                                EPStatementInitServicesConstants.REF));
                        var factory = classScope.AddOrGetDefaultFieldSharable(EventBeanTypedEventFactoryCodegenField.INSTANCE);
                        var matchingAsMap = ExprDotName(REF_MATCHEDEVENTMAP, "MatchingEventsAsMap");
                        var mapBean = ExprDotMethod(
                            factory,
                            "AdapterForTypedMap",
                            matchingAsMap,
                            compositeEventTypeMember);
                        getFilterValue.Block.AssignArrayElement("events", Constant(count), mapBean);
                        count++;
                    }
                }
            }
            else {
                getFilterValue.Block.DeclareVar<EventBean[]>("events", ConstantNull());
            }

            getFilterValue.Block
                .DeclareVar<object>(
                    "value",
                    ExprDotMethod(
                        ExprDotName(Ref("node"), "FilterBooleanExpressionFactory"),
                        "Make",
                        Ref("node"), // FilterSpecParamExprNode filterSpecParamExprNode
                        Ref("events"), // EventBean[] events
                        REF_EXPREVALCONTEXT, // ExprEvaluatorContext exprEvaluatorContext
                        ExprDotName(REF_EXPREVALCONTEXT, "AgentInstanceId"), // int agentInstanceId
                        REF_STMTCTXFILTEREVALENV))
                .BlockReturn(FilterValueSetParamImpl.CodegenNew(Ref("value")));

            // expression evaluator
            var evaluator = ExprNodeUtilityCodegen.CodegenEvaluatorNoCoerce(
                ExprNode.Forge,
                method,
                GetType(),
                classScope);

            // setter calls
            method.Block
                .DeclareVar<ProxyFilterSpecParamExprNode>("node", param)
                .SetProperty(Ref("node"), "ProcGetFilterValue", getFilterValue)
                .SetProperty(Ref("node"), "ExprText", 
                    Constant(
                        StringValue.StringDelimitedTo60Char(
                            ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(ExprNode))))
                .SetProperty(Ref("node"), "ExprNode", evaluator)
                .SetProperty(Ref("node"), "HasVariable", Constant(_hasVariable))
                .SetProperty(Ref("node"), "HasFilterStreamSubquery", Constant(_hasFilterStreamSubquery))
                .SetProperty(Ref("node"), "FilterBoolExprId", Constant(FilterBoolExprId))
                .SetProperty(Ref("node"), "HasTableAccess", Constant(_hasTableAccess))
                .SetProperty(
                    Ref("node"),
                    "FilterBooleanExpressionFactory",
                    ExprDotName(
                        symbols.GetAddInitSvc(method),
                        EPStatementInitServicesConstants.FILTERBOOLEANEXPRESSIONFACTORY))
                .SetProperty(
                    Ref("node"),
                    "UseLargeThreadingProfile",
                    Constant(
                        _compileTimeServices.Configuration.Common.Execution.ThreadingProfile ==
                        ThreadingProfile.LARGE));

            if (TaggedEventTypes != null && !TaggedEventTypes.IsEmpty() ||
                _arrayEventTypes != null && !_arrayEventTypes.IsEmpty()) {
                var size = TaggedEventTypes != null ? TaggedEventTypes.Count : 0;
                size += _arrayEventTypes != null ? _arrayEventTypes.Count : 0;
                method.Block.DeclareVar<EventType[]>(
                    "providedTypes",
                    NewArrayByLength(typeof(EventType), Constant(size + 1)));
                for (var i = 1; i < _streamTypeService.StreamNames.Length; i++) {
                    var tag = _streamTypeService.StreamNames[i];
                    var eventType = FindMayNull(tag, TaggedEventTypes);
                    if (eventType == null) {
                        eventType = FindMayNull(tag, _arrayEventTypes);
                    }

                    if (eventType == null) {
                        throw new IllegalStateException("Failed to find event type for tag '" + tag + "'");
                    }

                    method.Block.AssignArrayElement(
                        "providedTypes",
                        Constant(i),
                        EventTypeUtility.ResolveTypeCodegen(eventType, EPStatementInitServicesConstants.REF));
                    // note: we leave index zero at null as that is the current event itself
                }

                method.Block.SetProperty(Ref("node"), "EventTypesProvidedBy", Ref("providedTypes"));
            }

            // register boolean expression so it can be found
            method.Block.Expression(
                ExprDotMethodChain(symbols.GetAddInitSvc(method))
                    .Get(EPStatementInitServicesConstants.FILTERSHAREDBOOLEXPRREGISTERY)
                    .Add("RegisterBoolExpr", Ref("node")));

            method.Block.MethodReturn(Ref("node"));
            return method;
        }