public static CodegenExpression ProcessFirstColCodegen(
     CodegenExpression expression,
     CodegenExpression eventBeanFactory,
     CodegenClassScope codegenClassScope,
     WrapperEventType wrapperEventType,
     string adapterMethod,
     Type castType)
 {
     var memberUndType = codegenClassScope.AddDefaultFieldUnshared(
         true,
         typeof(EventType),
         EventTypeUtility.ResolveTypeCodegen(
             wrapperEventType.UnderlyingEventType,
             EPStatementInitServicesConstants.REF));
     var memberWrapperType = codegenClassScope.AddDefaultFieldUnshared(
         true,
         typeof(WrapperEventType),
         Cast(
             typeof(WrapperEventType),
             EventTypeUtility.ResolveTypeCodegen(wrapperEventType, EPStatementInitServicesConstants.REF)));
     var wrapped = ExprDotMethod(
         eventBeanFactory,
         adapterMethod,
         castType == typeof(object) ? expression : Cast(castType, expression),
         memberUndType);
     return ExprDotMethod(
         eventBeanFactory,
         "AdapterForTypedWrapper",
         wrapped,
         StaticMethod(typeof(Collections), "GetEmptyMap", new[] { typeof(string), typeof(object) }),
         memberWrapperType);
 }
コード例 #2
0
        public CodegenExpression Make(
            CodegenBlock codegenBlock,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            var factory = codegenClassScope.AddOrGetDefaultFieldSharable(
                EventBeanTypedEventFactoryCodegenField.INSTANCE);
            var eventType = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(EventType),
                EventTypeUtility.ResolveTypeCodegen(this.eventType, EPStatementInitServicesConstants.REF));

            var makeUndLambda = new CodegenExpressionLambda(codegenBlock)
                .WithParam<object[]>("properties")
                .WithBody(block => MakeUnderlyingCodegen(block, codegenClassScope));

            var manufacturer = NewInstance<ProxyObjectArrayEventBeanManufacturer>(
                eventType, factory, makeUndLambda);

            //var makeUndProc = CodegenMethod.MakeMethod(typeof(object[]), GetType(), codegenClassScope)
            //    .AddParam(typeof(object[]), "properties");
            //manufacturer.AddMethod("MakeUnderlying", makeUndProc);
            //MakeUnderlyingCodegen(makeUndProc, codegenClassScope);

            //var makeProc = CodegenMethod.MakeMethod(typeof(EventBean), GetType(), codegenClassScope)
            //    .AddParam(typeof(object[]), "properties");
            //manufacturer.AddMethod("Make", makeProc);

            return codegenClassScope.AddDefaultFieldUnshared(true, typeof(EventBeanManufacturer), manufacturer);
        }
コード例 #3
0
        public CodegenExpression Make(
            CodegenBlock codegenBlock,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            var factory = codegenClassScope.AddOrGetDefaultFieldSharable(EventBeanTypedEventFactoryCodegenField.INSTANCE);
            var eventType = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(EventType),
                EventTypeUtility.ResolveTypeCodegen(_beanEventType, EPStatementInitServicesConstants.REF));

            var makeUndLambda = new CodegenExpressionLambda(codegenBlock)
                .WithParam<object[]>("properties")
                .WithBody(block => MakeUnderlyingCodegen(codegenMethodScope, block, codegenClassScope));

            var manufacturer = NewInstance<ProxyBeanEventBeanManufacturer>(
                eventType, factory, makeUndLambda);

            //var manufacturer = NewAnonymousClass(init.Block, typeof(EventBeanManufacturer));

            //var makeUndMethod = CodegenMethod.MakeMethod(typeof(object), GetType(), codegenClassScope)
            //    .AddParam(typeof(object[]), "properties");
            //manufacturer.AddMethod("MakeUnderlying", makeUndMethod);
            //MakeUnderlyingCodegen(makeUndMethod, codegenClassScope);

            //var makeMethod = CodegenMethod.MakeMethod(typeof(EventBean), GetType(), codegenClassScope)
            //    .AddParam(typeof(object[]), "properties");
            //manufacturer.AddMethod("Make", makeMethod);
            //makeMethod.Block
            //    .DeclareVar<object>("und", LocalMethod(makeUndMethod, Ref("properties")))
            //    .MethodReturn(ExprDotMethod(factory, "AdapterForTypedObject", Ref("und"), beanType));

            return codegenClassScope.AddDefaultFieldUnshared(true, typeof(EventBeanManufacturer), manufacturer);
        }
コード例 #4
0
        public CodegenExpression Make(
            CodegenBlock codegenBlock,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            var init      = codegenClassScope.NamespaceScope.InitMethod;
            var factory   = codegenClassScope.AddOrGetDefaultFieldSharable(EventBeanTypedEventFactoryCodegenField.INSTANCE);
            var eventType = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(EventType),
                EventTypeUtility.ResolveTypeCodegen(_jsonEventType, EPStatementInitServicesConstants.REF));

            var makeUndFunc = new CodegenExpressionLambda(codegenBlock)
                              .WithParam <object[]>("properties")
                              .WithBody(block => MakeUnderlyingCodegen(block, codegenMethodScope, codegenClassScope));

            var manufacturer = NewInstance <ProxyJsonEventBeanManufacturer>(eventType, factory, makeUndFunc);

            // CodegenExpressionNewAnonymousClass manufacturer = newAnonymousClass(init.getBlock(), EventBeanManufacturer.class);
            //
            // CodegenMethod makeUndMethod = CodegenMethod.makeParentNode(Object.class, this.getClass(), codegenClassScope).addParam(Object[].class, "properties");
            // manufacturer.addMethod("makeUnderlying", makeUndMethod);
            // makeUnderlyingCodegen(makeUndMethod, codegenClassScope);
            //
            // CodegenMethod makeMethod = CodegenMethod.makeParentNode(EventBean.class, this.getClass(), codegenClassScope).addParam(Object[].class, "properties");
            // manufacturer.addMethod("make", makeMethod);
            // makeMethod.getBlock()
            //  .declareVar(Object.class, "und", localMethod(makeUndMethod, ref("properties")))
            //  .methodReturn(exprDotMethod(factory, "adapterForTypedJson", ref("und"), beanType));


            return(codegenClassScope.AddDefaultFieldUnshared(true, typeof(EventBeanManufacturer), manufacturer));
        }
コード例 #5
0
        public static CodegenExpression Codegen(
            EnumWhereScalarIndexForge forge,
            EnumForgeCodegenParams args,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            var evalTypeMember = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(ObjectArrayEventType),
                Cast(
                    typeof(ObjectArrayEventType),
                    EventTypeUtility.ResolveTypeCodegen(forge.evalEventType, EPStatementInitServicesConstants.REF)));
            var indexTypeMember = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(ObjectArrayEventType),
                Cast(
                    typeof(ObjectArrayEventType),
                    EventTypeUtility.ResolveTypeCodegen(forge.indexEventType, EPStatementInitServicesConstants.REF)));

            var scope = new ExprForgeCodegenSymbol(false, null);
            var methodNode = codegenMethodScope
                .MakeChildWithScope(
                    typeof(FlexCollection),
                    typeof(EnumWhereScalarIndexForgeEval),
                    scope,
                    codegenClassScope)
                .AddParam(EnumForgeCodegenNames.PARAMS);

            var block = methodNode.Block
                .IfCondition(ExprDotMethod(EnumForgeCodegenNames.REF_ENUMCOLL, "IsEmpty"))
                .BlockReturn(EnumForgeCodegenNames.REF_ENUMCOLL);
            block
                .DeclareVar<ArrayDeque<object>>("result", NewInstance(typeof(ArrayDeque<object>)))
                .DeclareVar<ObjectArrayEventBean>(
                    "evalEvent",
                    NewInstance<ObjectArrayEventBean>(NewArrayByLength(typeof(object), Constant(1)), evalTypeMember))
                .AssignArrayElement(EnumForgeCodegenNames.REF_EPS, Constant(forge.streamNumLambda), Ref("evalEvent"))
                .DeclareVar<object[]>("evalProps", ExprDotName(Ref("evalEvent"), "Properties"))
                .DeclareVar<ObjectArrayEventBean>(
                    "indexEvent",
                    NewInstance<ObjectArrayEventBean>(NewArrayByLength(typeof(object), Constant(1)), indexTypeMember))
                .AssignArrayElement(
                    EnumForgeCodegenNames.REF_EPS,
                    Constant(forge.streamNumLambda + 1),
                    Ref("indexEvent"))
                .DeclareVar<object[]>("indexProps", ExprDotName(Ref("indexEvent"), "Properties"))
                .DeclareVar<int>("count", Constant(-1));
            var forEach = block.ForEach(typeof(object), "next", EnumForgeCodegenNames.REF_ENUMCOLL)
                .Increment("count")
                .AssignArrayElement("evalProps", Constant(0), Ref("next"))
                .AssignArrayElement("indexProps", Constant(0), Ref("count"));
            CodegenLegoBooleanExpression.CodegenContinueIfNotNullAndNotPass(
                forEach,
                forge.innerExpression.EvaluationType,
                forge.innerExpression.EvaluateCodegen(typeof(bool?), methodNode, scope, codegenClassScope));
            forEach.Expression(ExprDotMethod(Ref("result"), "Add", Ref("next")));
            block.MethodReturn(FlexWrap(Ref("result")));
            return LocalMethod(methodNode, args.Eps, args.Enumcoll, args.IsNewData, args.ExprCtx);
        }
コード例 #6
0
        public static CodegenExpression Codegen(
            ExprInstanceofNodeForge forge,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            CodegenExpression cache = codegenClassScope.AddDefaultFieldUnshared<CopyOnWriteList<Pair<Type, bool>>>(
                true,
                NewInstance(typeof(CopyOnWriteList<Pair<Type, bool>>)));
            var methodNode = codegenMethodScope.MakeChild(
                typeof(bool),
                typeof(ExprInstanceofNodeForgeEval),
                codegenClassScope);

            var block = methodNode.Block
                .DeclareVar<object>(
                    "result",
                    forge.ForgeRenderableInstanceOf.ChildNodes[0]
                        .Forge.EvaluateCodegen(
                            typeof(object),
                            methodNode,
                            exprSymbol,
                            codegenClassScope))
                .IfRefNullReturnFalse("result");
            block.MethodReturn(
                StaticMethod(
                    typeof(ExprInstanceofNodeForgeEval),
                    "InstanceofCacheCheckOrAdd",
                    Constant(forge.Classes),
                    cache,
                    Ref("result")));
            return LocalMethod(methodNode);
        }
コード例 #7
0
        private CodegenMethod GetFragmentCodegen(
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            var factory = codegenClassScope.AddOrGetDefaultFieldSharable(EventBeanTypedEventFactoryCodegenField.INSTANCE);
            var eventType = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(EventType),
                EventTypeUtility.ResolveTypeCodegen(FragmentType, EPStatementInitServicesConstants.REF));
            var method = codegenMethodScope.MakeChild(typeof(object), GetType(), codegenClassScope)
                .AddParam(Field.DeclaringType, "record");
            method.Block
                .DeclareVar<object>("value", UnderlyingGetCodegen(Ref("record"), codegenMethodScope, codegenClassScope))
                .IfRefNullReturnNull("value");
            string adapterMethod;
            if (FragmentType is BeanEventType) {
                adapterMethod = "AdapterForTypedObject";
            }
            else if (FragmentType is JsonEventType) {
                adapterMethod = "AdapterForTypedJson";
            }
            else {
                throw new IllegalStateException("Unrecognized fragment event type " + FragmentType);
            }

            method.Block.MethodReturn(ExprDotMethod(factory, adapterMethod, Ref("value"), eventType));
            return method;
        }
コード例 #8
0
 public CodegenMethod ProcessCodegen(
     CodegenExpression resultEventTypeOuter,
     CodegenExpression eventBeanFactory,
     CodegenMethodScope codegenMethodScope,
     SelectExprProcessorCodegenSymbol selectSymbol,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     // NOTE: Maintaining result-event-type as out own field as we may be an "inner" select-expr-processor
     var mType = codegenClassScope.AddDefaultFieldUnshared(
         true,
         typeof(EventType),
         EventTypeUtility.ResolveTypeCodegen(ResultEventType, EPStatementInitServicesConstants.REF));
     var methodNode = codegenMethodScope.MakeChild(typeof(EventBean), GetType(), codegenClassScope);
     var refEPS = exprSymbol.GetAddEPS(methodNode);
     methodNode.Block
         .DeclareVar<object[]>("tuple", NewArrayByLength(typeof(object), Constant(streamNames.Length)))
         .StaticMethod(
             typeof(Array),
             "Copy",
             refEPS,
             Constant(0),
             Ref("tuple"),
             Constant(0),
             Constant(streamNames.Length))
         .MethodReturn(ExprDotMethod(eventBeanFactory, "AdapterForTypedObjectArray", Ref("tuple"), mType));
     return methodNode;
 }
コード例 #9
0
        public CodegenMethod ProcessCodegen(
            CodegenExpression resultEventType,
            CodegenExpression eventBeanFactory,
            CodegenMethodScope codegenMethodScope,
            SelectExprProcessorCodegenSymbol selectSymbol,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var processMethod = codegenMethodScope.MakeChild(typeof(EventBean), this.GetType(), codegenClassScope);

            var isSythesize     = selectSymbol.GetAddSynthesize(processMethod);
            var syntheticMethod = syntheticProcessorForge.ProcessCodegen(
                resultEventType,
                eventBeanFactory,
                processMethod,
                selectSymbol,
                exprSymbol,
                codegenClassScope);

            var stmtResultSvc = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(StatementResultService),
                ExprDotName(EPStatementInitServicesConstants.REF, EPStatementInitServicesConstants.STATEMENTRESULTSERVICE));

            processMethod.Block
            .IfCondition(Or(isSythesize, ExprDotName(stmtResultSvc, "IsMakeSynthetic")))
            .BlockReturn(LocalMethod(syntheticMethod))
            .MethodReturn(ConstantNull());

            return(processMethod);
        }
コード例 #10
0
        private void MakeBlock(
            string getterMethod,
            int column,
            CodegenMethod method,
            CodegenClassScope classScope)
        {
            if (_accessorField == null) {
                var injectionStrategy =
                    (InjectionStrategyClassNewInstance) _mode.InjectionStrategyAggregationAccessorFactory;
                _accessorField = classScope.AddDefaultFieldUnshared(
                    true,
                    typeof(AggregationMultiFunctionAccessor),
                    ExprDotMethod(
                        injectionStrategy.GetInitializationExpression(classScope),
                        "NewAccessor",
                        ConstantNull()));
            }

            method.Block.MethodReturn(
                ExprDotMethod(
                    _accessorField,
                    getterMethod,
                    MemberCol("state", column),
                    REF_EPS,
                    REF_ISNEWDATA,
                    REF_EXPREVALCONTEXT));
        }
コード例 #11
0
 private static void ProcessOutputLimitedLastAllNonBufferedCodegen(
     ResultSetProcessorSimpleForge forge,
     string methodName,
     CodegenClassScope classScope,
     CodegenMethod method,
     CodegenInstanceAux instance)
 {
     var factory = classScope.AddOrGetDefaultFieldSharable(ResultSetProcessorHelperFactoryField.INSTANCE);
     CodegenExpression eventTypes = classScope.AddDefaultFieldUnshared(
         true,
         typeof(EventType[]),
         EventTypeUtility.ResolveTypeArrayCodegen(forge.EventTypes, EPStatementInitServicesConstants.REF));
     if (forge.IsOutputAll) {
         instance.AddMember(NAME_OUTPUTALLHELPER, typeof(ResultSetProcessorSimpleOutputAllHelper));
         instance.ServiceCtor.Block.AssignRef(
             NAME_OUTPUTALLHELPER,
             ExprDotMethod(factory, "MakeRSSimpleOutputAll", Ref("this"), MEMBER_AGENTINSTANCECONTEXT, eventTypes));
         method.Block.ExprDotMethod(Member(NAME_OUTPUTALLHELPER), methodName, REF_NEWDATA, REF_OLDDATA);
     }
     else if (forge.IsOutputLast) {
         instance.AddMember(NAME_OUTPUTLASTHELPER, typeof(ResultSetProcessorSimpleOutputLastHelper));
         instance.ServiceCtor.Block.AssignRef(
             NAME_OUTPUTLASTHELPER,
             ExprDotMethod(
                 factory,
                 "MakeRSSimpleOutputLast",
                 Ref("this"),
                 MEMBER_AGENTINSTANCECONTEXT,
                 eventTypes));
         method.Block.ExprDotMethod(Member(NAME_OUTPUTLASTHELPER), methodName, REF_NEWDATA, REF_OLDDATA);
     }
 }
コード例 #12
0
        public CodegenMethod ProcessCodegen(
            CodegenExpression resultEventTypeOuter,
            CodegenExpression eventBeanFactory,
            CodegenMethodScope codegenMethodScope,
            SelectExprProcessorCodegenSymbol selectSymbol,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            // NOTE: Maintaining result-event-type as out own field as we may be an "inner" select-expr-processor
            var mType = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(EventType),
                EventTypeUtility.ResolveTypeCodegen(resultEventType, EPStatementInitServicesConstants.REF));
            var methodNode = codegenMethodScope.MakeChild(typeof(EventBean), GetType(), codegenClassScope);
            var refEPS = exprSymbol.GetAddEPS(methodNode);
            methodNode.Block
                .DeclareVar(resultEventType.UnderlyingType, "tuple", NewInstanceInner(resultEventType.Detail.UnderlyingClassName));
            for (var i = 0; i < streamNames.Length; i++) {
                var @event = ArrayAtIndex(refEPS, Constant(i));
                var field = resultEventType.Detail.FieldDescriptors.Get(streamNames[i]);
                var rhs = Cast(field.PropertyType, ExprDotUnderlying(@event));
                methodNode.Block.AssignRef(ExprDotName(Ref("tuple"), field.FieldName), rhs);
            }

            methodNode.Block.MethodReturn(ExprDotMethod(eventBeanFactory, "AdapterForTypedJson", Ref("tuple"), mType));
            return methodNode;
        }
コード例 #13
0
        public static CodegenMethod Codegen(
            ExprRegexpNodeForgeConst forge,
            ExprNode lhs,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            CodegenExpression mPattern = codegenClassScope.AddDefaultFieldUnshared<Regex>(true, forge.PatternInit);
            var methodNode = codegenMethodScope.MakeChild(
                typeof(bool?),
                typeof(ExprRegexpNodeForgeConstEval),
                codegenClassScope);

            if (!forge.IsNumericValue) {
                methodNode.Block
                    .DeclareVar<string>(
                        "value",
                        lhs.Forge.EvaluateCodegen(typeof(string), methodNode, exprSymbol, codegenClassScope))
                    .IfRefNullReturnNull("value")
                    .MethodReturn(GetRegexpCode(forge, mPattern, Ref("value")));
            }
            else {
                var valueRender = StaticMethod(typeof(CompatExtensions), "RenderAny", Ref("value"));
                methodNode.Block
                    .DeclareVar<object>(
                        "value",
                        lhs.Forge.EvaluateCodegen(typeof(object), methodNode, exprSymbol, codegenClassScope))
                    .IfRefNullReturnNull("value")
                    .MethodReturn(GetRegexpCode(forge, mPattern, valueRender));
            }

            return methodNode;
        }
コード例 #14
0
ファイル: ReformatFormatForge.cs プロジェクト: lanicon/nesper
        private CodegenExpressionInstanceField CodegenFormatFieldInit(CodegenClassScope classScope)
        {
            var formatEvalDtx = CodegenLegoMethodExpression.CodegenExpression(
                _formatter,
                classScope.NamespaceScope.InitMethod,
                classScope,
                true);
            var formatEval = LocalMethod(formatEvalDtx, ConstantNull(), ConstantTrue(), ConstantNull());
            CodegenExpression init;
            if (_formatterType.FormatterType != typeof(string)) {
                init = formatEval;
            }
            else {
                var parse = classScope.NamespaceScope.InitMethod.MakeChild(
                    typeof(DateFormat),
                    GetType(),
                    classScope);
                parse.Block.MethodReturn(NewInstance<SimpleDateFormat>(formatEval));
                init = LocalMethod(parse);
            }

            return classScope.AddDefaultFieldUnshared(
                true,
                typeof(DateFormat),
                init);
        }
コード例 #15
0
        protected override CodegenExpression CodegenEventsPerStreamRewritten(
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var method = codegenMethodScope.MakeChild(typeof(EventBean[]), typeof(ExprDeclaredForgeRewriteWValue), codegenClassScope);
            var valueType = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(ObjectArrayEventType),
                Cast(typeof(ObjectArrayEventType), EventTypeUtility.ResolveTypeCodegen(_valueEventType, EPStatementInitServicesConstants.REF)));

            method.Block
                .DeclareVar<object[]>("props", NewArrayByLength(typeof(object), Constant(_valueExpressions.Count)))
                .DeclareVar<EventBean[]>("events", NewArrayByLength(typeof(EventBean), Constant(_eventEnumerationForges.Length)))
                .AssignArrayElement("events", Constant(0), NewInstance(typeof(ObjectArrayEventBean), Ref("props"), valueType));
            for (var i = 0; i < _valueExpressions.Count; i++) {
                method.Block.AssignArrayElement(
                    "props",
                    Constant(i),
                    _valueExpressions[i].Forge.EvaluateCodegen(typeof(object), method, exprSymbol, codegenClassScope));
            }

            for (var i = 1; i < _eventEnumerationForges.Length; i++) {
                method.Block.AssignArrayElement(
                    "events",
                    Constant(i),
                    _eventEnumerationForges[i].EvaluateGetEventBeanCodegen(method, exprSymbol, codegenClassScope));
            }

            method.Block.MethodReturn(Ref("events"));

            return LocalMethod(method);
        }
コード例 #16
0
 public CodegenMethod ProcessCodegen(
     CodegenExpression resultEventTypeOuter,
     CodegenExpression eventBeanFactory,
     CodegenMethodScope codegenMethodScope,
     SelectExprProcessorCodegenSymbol selectSymbol,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     // NOTE: Maintaining result-event-type as out own field as we may be an "inner" select-expr-processor
     var mType = codegenClassScope.AddDefaultFieldUnshared(
         true,
         typeof(EventType),
         EventTypeUtility.ResolveTypeCodegen(_resultEventTypeAvro, EPStatementInitServicesConstants.REF));
     var schema = codegenClassScope.NamespaceScope.AddDefaultFieldUnshared(
         true,
         typeof(RecordSchema),
         CodegenExpressionBuilder.StaticMethod(
             typeof(AvroSchemaUtil),
             "ResolveRecordSchema",
             EventTypeUtility.ResolveTypeCodegen(_resultEventTypeAvro, EPStatementInitServicesConstants.REF)));
     var methodNode = codegenMethodScope.MakeChild(typeof(EventBean), GetType(), codegenClassScope);
     var refEPS = exprSymbol.GetAddEPS(methodNode);
     methodNode.Block.MethodReturn(
         CodegenExpressionBuilder.StaticMethod(
             typeof(SelectExprJoinWildcardProcessorAvro),
             "ProcessSelectExprJoinWildcardAvro",
             refEPS,
             schema,
             eventBeanFactory,
             mType));
     return methodNode;
 }
コード例 #17
0
        public CodegenExpression UnderlyingFragmentCodegen(
            CodegenExpression underlyingExpression,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            var ff = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(FragmentFactory),
                fragmentFactory.Make(codegenClassScope.NamespaceScope.InitMethod, codegenClassScope));
            if (!isArray) {
                return StaticMethod(
                    GetType(),
                    "GetValueAsNodeFragment",
                    underlyingExpression,
                    Constant(propertyName),
                    ff);
            }

            return StaticMethod(
                GetType(),
                "GetValueAsNodeFragmentArray",
                underlyingExpression,
                Constant(propertyName),
                ff);
        }
 public CodegenExpressionInstanceField Make(CodegenClassScope classScope)
 {
     return classScope.AddDefaultFieldUnshared(
         true,
         typeof(AggSvcGroupByReclaimAgedEvalFuncFactoryConst),
         NewInstance<AggSvcGroupByReclaimAgedEvalFuncFactoryConst>(Constant(valueDouble)));
 }
コード例 #19
0
        public static CodegenExpression Codegen(
            ExprCastNodeForge forge,
            CodegenClassScope codegenClassScope)
        {
            if (forge.EvaluationType == null) {
                return ConstantNull();
            }

            var evaluationType = forge.EvaluationType.GetBoxedType();
            var initMethod = codegenClassScope.NamespaceScope.InitMethod.MakeChildWithScope(
                evaluationType,
                typeof(ExprCastNodeForgeConstEval),
                CodegenSymbolProviderEmpty.INSTANCE,
                codegenClassScope);

            var exprSymbol = new ExprForgeCodegenSymbol(true, null);
            var compute = initMethod.MakeChildWithScope(
                    evaluationType,
                    typeof(ExprCastNodeForgeConstEval),
                    exprSymbol,
                    codegenClassScope)
                .AddParam(ExprForgeCodegenNames.PARAMS);
            compute.Block.MethodReturn(
                ExprCastNodeForgeNonConstEval.Codegen(forge, compute, exprSymbol, codegenClassScope));

            initMethod.Block.MethodReturn(LocalMethod(compute, Constant(null), ConstantTrue(), ConstantNull()));

            return codegenClassScope.AddDefaultFieldUnshared(true, evaluationType, LocalMethod(initMethod));
        }
コード例 #20
0
        public static CodegenMethod Codegen(
            ExprLikeNodeForgeConst forge,
            ExprNode lhs,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var mLikeUtil = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(LikeUtil),
                forge.LikeUtilInit);


            var methodNode = codegenMethodScope.MakeChild(
                typeof(bool?),
                typeof(ExprLikeNodeForgeConstEval),
                codegenClassScope);
            if (!forge.IsNumericValue) {
                methodNode.Block
                    .DeclareVar<string>(
                        "value",
                        lhs.Forge.EvaluateCodegen(typeof(string), methodNode, exprSymbol, codegenClassScope))
                    .IfRefNullReturnNull("value")
                    .MethodReturn(GetLikeCode(forge, mLikeUtil, Ref("value")));
            }
            else {
                methodNode.Block.DeclareVar<object>(
                        "value",
                        lhs.Forge.EvaluateCodegen(typeof(object), methodNode, exprSymbol, codegenClassScope))
                    .IfRefNullReturnNull("value")
                    .MethodReturn(GetLikeCode(forge, mLikeUtil, ExprDotMethod(Ref("value"), "ToString")));
            }

            return methodNode;
        }
コード例 #21
0
        public static CodegenExpression Codegen(
            EnumCountOfSelectorScalarForge forge,
            EnumForgeCodegenParams args,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            var typeMember = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(ObjectArrayEventType),
                Cast(
                    typeof(ObjectArrayEventType),
                    EventTypeUtility.ResolveTypeCodegen(forge.type, EPStatementInitServicesConstants.REF)));

            var scope = new ExprForgeCodegenSymbol(false, null);
            var methodNode = codegenMethodScope
                .MakeChildWithScope(typeof(int), typeof(EnumCountOfSelectorScalarForgeEval), scope, codegenClassScope)
                .AddParam(EnumForgeCodegenNames.PARAMS);

            var block = methodNode.Block
                .DeclareVar<int>("count", Constant(0))
                .DeclareVar<ObjectArrayEventBean>(
                    "evalEvent",
                    NewInstance<ObjectArrayEventBean>(NewArrayByLength(typeof(object), Constant(1)), typeMember))
                .AssignArrayElement(EnumForgeCodegenNames.REF_EPS, Constant(forge.StreamNumLambda), Ref("evalEvent"))
                .DeclareVar<object[]>("props", ExprDotName(Ref("evalEvent"), "Properties"));
            var forEach = block.ForEach(typeof(object), "next", EnumForgeCodegenNames.REF_ENUMCOLL)
                .AssignArrayElement(Ref("props"), Constant(0), Ref("next"));
            CodegenLegoBooleanExpression.CodegenContinueIfNotNullAndNotPass(
                forEach,
                forge.InnerExpression.EvaluationType,
                forge.InnerExpression.EvaluateCodegen(typeof(bool?), methodNode, scope, codegenClassScope));
            forEach.Increment("count");
            block.MethodReturn(Ref("count"));
            return LocalMethod(methodNode, args.Eps, args.Enumcoll, args.IsNewData, args.ExprCtx);
        }
コード例 #22
0
        public static CodegenExpression Codegen(
            SelectExprProcessorTypableMapForge forge,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            CodegenExpression mapType = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(EventType),
                EventTypeUtility.ResolveTypeCodegen(forge.MapType, EPStatementInitServicesConstants.REF));
            CodegenExpression beanFactory =
                codegenClassScope.AddOrGetDefaultFieldSharable(EventBeanTypedEventFactoryCodegenField.INSTANCE);

            CodegenMethod methodNode = codegenMethodScope.MakeChild(
                typeof(EventBean),
                typeof(SelectExprProcessorTypableMapEval),
                codegenClassScope);

            methodNode.Block
                .DeclareVar<IDictionary<string, object>>(
                    "values",
                    forge.innerForge.EvaluateCodegen(
                        typeof(IDictionary<string, object>),
                        methodNode,
                        exprSymbol,
                        codegenClassScope))
                .DeclareVarNoInit(typeof(IDictionary<string, object>), "map")
                .IfRefNull("values")
                .AssignRef("values", StaticMethod(typeof(Collections), "GetEmptyMap", new[] { typeof(string), typeof(object) }))
                .BlockEnd()
                .MethodReturn(ExprDotMethod(beanFactory, "AdapterForTypedMap", Ref("values"), mapType));
            return LocalMethod(methodNode);
        }
コード例 #23
0
        public CodegenMethod ProcessCodegen(
            CodegenExpression resultEventTypeOuter,
            CodegenExpression eventBeanFactory,
            CodegenMethodScope codegenMethodScope,
            SelectExprProcessorCodegenSymbol selectSymbol,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            // NOTE: Maintaining result-event-type as out own field as we may be an "inner" select-expr-processor
            CodegenExpressionInstanceField mType = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(EventType),
                EventTypeUtility.ResolveTypeCodegen(resultEventType, EPStatementInitServicesConstants.REF));
            CodegenMethod methodNode = codegenMethodScope.MakeChild(
                typeof(EventBean),
                this.GetType(),
                codegenClassScope);
            CodegenExpressionRef refEPS = exprSymbol.GetAddEPS(methodNode);
            methodNode.Block.DeclareVar<IDictionary<string, object>>(
                "tuple", NewInstance(typeof(HashMap<string, object>)));
            for (int i = 0; i < streamNames.Length; i++) {
                methodNode.Block.Expression(
                    ExprDotMethod(Ref("tuple"), "Put", Constant(streamNames[i]), ArrayAtIndex(refEPS, Constant(i))));
            }

            methodNode.Block.MethodReturn(ExprDotMethod(eventBeanFactory, "AdapterForTypedMap", Ref("tuple"), mType));
            return methodNode;
        }
コード例 #24
0
        public AggregatorPlugInManaged(
            AggregationMethodFactoryPluginMethod factory,
            int col,
            CodegenCtor rowCtor,
            CodegenMemberCol membersColumnized,
            CodegenClassScope classScope,
            Type optionalDistinctValueType,
            bool hasFilter,
            ExprNode optionalFilter,
            AggregationFunctionModeManaged mode)
            : base(
                factory,
                col,
                rowCtor,
                membersColumnized,
                classScope,
                optionalDistinctValueType,
                hasFilter,
                optionalFilter)

        {
            this.mode = mode;

            var injectionStrategy =
                (InjectionStrategyClassNewInstance) mode.InjectionStrategyAggregationFunctionFactory;
            var factoryField = classScope.AddDefaultFieldUnshared<AggregationFunctionFactory>(
                true,
                injectionStrategy.GetInitializationExpression(classScope));

            plugin = membersColumnized.AddMember(col, typeof(AggregationFunction), "plugin");
            rowCtor.Block.AssignRef(plugin, ExprDotMethod(factoryField, "NewAggregator", ConstantNull()));
        }
コード例 #25
0
        public override CodegenExpression Codegen(
            EnumForgeCodegenParams premade,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            var resultTypeMember = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(ObjectArrayEventType),
                Cast(typeof(ObjectArrayEventType), EventTypeUtility.ResolveTypeCodegen(_resultEventType, EPStatementInitServicesConstants.REF)));

            var scope      = new ExprForgeCodegenSymbol(false, null);
            var methodNode = codegenMethodScope
                             .MakeChildWithScope(typeof(IDictionary <object, object>), GetType(), scope, codegenClassScope)
                             .AddParam(EnumForgeCodegenNames.PARAMS);
            var hasIndex = _numParameters >= 2;
            var hasSize  = _numParameters >= 3;

            var returnIfEmpty = ReturnIfEmptyOptional();

            if (returnIfEmpty != null)
            {
                methodNode.Block
                .IfCondition(ExprDotMethod(EnumForgeCodegenNames.REF_ENUMCOLL, "IsEmpty"))
                .BlockReturn(returnIfEmpty);
            }

            InitBlock(methodNode.Block, methodNode, scope, codegenClassScope);

            methodNode.Block
            .DeclareVar <ObjectArrayEventBean>(
                "resultEvent",
                NewInstance(typeof(ObjectArrayEventBean), NewArrayByLength(typeof(object), Constant(_numParameters)), resultTypeMember))
            .AssignArrayElement(EnumForgeCodegenNames.REF_EPS, Constant(StreamNumLambda), Ref("resultEvent"))
            .DeclareVar <object[]>("props", ExprDotName(Ref("resultEvent"), "Properties"));
            if (hasIndex)
            {
                methodNode.Block.DeclareVar <int>("count", Constant(-1));
            }

            if (hasSize)
            {
                methodNode.Block.AssignArrayElement(Ref("props"), Constant(2), ExprDotName(REF_ENUMCOLL, "Count"));
            }

            var forEach = methodNode.Block
                          .ForEach(typeof(object), "next", EnumForgeCodegenNames.REF_ENUMCOLL)
                          .AssignArrayElement("props", Constant(0), Ref("next"));

            if (hasIndex)
            {
                forEach.IncrementRef("count").AssignArrayElement("props", Constant(1), Ref("count"));
            }

            ForEachBlock(forEach, methodNode, scope, codegenClassScope);

            ReturnResult(methodNode.Block);
            return(LocalMethod(methodNode, premade.Eps, premade.Enumcoll, premade.IsNewData, premade.ExprCtx));
        }
コード例 #26
0
        public static CodegenExpression Codegen(
            EnumMinMaxByScalarLambdaForge forge,
            EnumForgeCodegenParams args,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            var innerType = forge.InnerExpression.EvaluationType;
            var innerTypeBoxed = Boxing.GetBoxedType(innerType);
            var resultTypeBoxed = Boxing.GetBoxedType(EPTypeHelper.GetCodegenReturnType(forge.resultType));
            var resultTypeMember = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(ObjectArrayEventType),
                Cast(
                    typeof(ObjectArrayEventType),
                    EventTypeUtility.ResolveTypeCodegen(forge.resultEventType, EPStatementInitServicesConstants.REF)));

            var scope = new ExprForgeCodegenSymbol(false, null);
            var methodNode = codegenMethodScope
                .MakeChildWithScope(
                    resultTypeBoxed,
                    typeof(EnumMinMaxByScalarLambdaForgeEval),
                    scope,
                    codegenClassScope)
                .AddParam(EnumForgeCodegenNames.PARAMS);

            var block = methodNode.Block
                .DeclareVar(innerTypeBoxed, "minKey", ConstantNull())
                .DeclareVar(resultTypeBoxed, "result", ConstantNull())
                .DeclareVar<ObjectArrayEventBean>(
                    "resultEvent",
                    NewInstance<ObjectArrayEventBean>(NewArrayByLength(typeof(object), Constant(1)), resultTypeMember))
                .AssignArrayElement(EnumForgeCodegenNames.REF_EPS, Constant(forge.StreamNumLambda), Ref("resultEvent"))
                .DeclareVar<object[]>("props", ExprDotName(Ref("resultEvent"), "Properties"));

            var forEach = block.ForEach(typeof(object), "next", EnumForgeCodegenNames.REF_ENUMCOLL)
                .AssignArrayElement("props", Constant(0), Ref("next"))
                .DeclareVar(
                    innerTypeBoxed,
                    "value",
                    forge.InnerExpression.EvaluateCodegen(innerTypeBoxed, methodNode, scope, codegenClassScope))
                .IfRefNull("value")
                .BlockContinue();

            forEach.IfCondition(EqualsNull(Ref("minKey")))
                .AssignRef("minKey", Ref("value"))
                .AssignRef("result", Cast(resultTypeBoxed, Ref("next")))
                .IfElse()
                .IfCondition(
                    Relational(
                        ExprDotMethod(Unbox(Ref("minKey"), innerTypeBoxed), "CompareTo", Ref("value")),
                        forge.max ? LT : GT,
                        Constant(0)))
                .AssignRef("minKey", Ref("value"))
                .AssignRef("result", Cast(resultTypeBoxed, Ref("next")));

            block.MethodReturn(Ref("result"));
            return LocalMethod(methodNode, args.Eps, args.Enumcoll, args.IsNewData, args.ExprCtx);
        }
コード例 #27
0
 private static CodegenExpression FormatField(
     string dateFormatString,
     CodegenClassScope codegenClassScope)
 {
     return codegenClassScope.AddDefaultFieldUnshared(
         true,
         typeof(DateFormat),
         NewInstance<SimpleDateFormat>(Constant(dateFormatString)));
 }
コード例 #28
0
        public static CodegenExpression Codegen(
            EnumAggregateEventsForge forge,
            EnumForgeCodegenParams args,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            var typeMember = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(ObjectArrayEventType),
                Cast(
                    typeof(ObjectArrayEventType),
                    EventTypeUtility.ResolveTypeCodegen(
                        forge.ResultEventType, EPStatementInitServicesConstants.REF)));

            var scope = new ExprForgeCodegenSymbol(false, null);
            var methodNode = codegenMethodScope.MakeChildWithScope(
                    forge.Initialization.EvaluationType,
                    typeof(EnumAggregateEventsForgeEval),
                    scope,
                    codegenClassScope)
                .AddParam(EnumForgeCodegenNames.PARAMS);

            var initType = forge.Initialization.EvaluationType;
            var initTypeBoxed = initType.GetBoxedType();
            var unboxRequired = initType != initTypeBoxed;
            var innerType = forge.InnerExpression.EvaluationType;

            var block = methodNode.Block;
            block.DeclareVar(
                    initTypeBoxed,
                    "value",
                    forge.Initialization.EvaluateCodegen(initType, methodNode, scope, codegenClassScope))
                .IfCondition(ExprDotMethod(EnumForgeCodegenNames.REF_ENUMCOLL, "IsEmpty"))
                .BlockReturn(
                    unboxRequired
                        ? (CodegenExpression) ExprDotName(Ref("value"), "Value")
                        : (CodegenExpression) Ref("value"));
            block.DeclareVar<ObjectArrayEventBean>(
                    "resultEvent",
                    NewInstance<ObjectArrayEventBean>(NewArrayByLength(typeof(object), Constant(1)), typeMember))
                .AssignArrayElement(EnumForgeCodegenNames.REF_EPS, Constant(forge.StreamNumLambda), Ref("resultEvent"))
                .DeclareVar<object[]>("props", ExprDotName(Ref("resultEvent"), "Properties"));
            block.ForEach(typeof(EventBean), "next", EnumForgeCodegenNames.REF_ENUMCOLL)
                .AssignArrayElement("props", Constant(0), Ref("value"))
                .AssignArrayElement(EnumForgeCodegenNames.REF_EPS, Constant(forge.StreamNumLambda + 1), Ref("next"))
                .AssignRef(
                    "value",
                    forge.InnerExpression.EvaluateCodegen(
                        innerType, methodNode, scope, codegenClassScope))
                .BlockEnd();
            block.MethodReturn(
                unboxRequired
                    ? (CodegenExpression) ExprDotName(Ref("value"), "Value")
                    : (CodegenExpression) Ref("value"));
            return LocalMethod(methodNode, args.Eps, args.Enumcoll, args.IsNewData, args.ExprCtx);
        }
コード例 #29
0
        public static CodegenExpression Codegen(
            EnumAverageScalarLambdaForge forge,
            EnumForgeCodegenParams args,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            var innerType = forge.InnerExpression.EvaluationType;
            var resultTypeMember = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(ObjectArrayEventType),
                Cast(
                    typeof(ObjectArrayEventType),
                    EventTypeUtility.ResolveTypeCodegen(forge.resultEventType, EPStatementInitServicesConstants.REF)));

            var scope = new ExprForgeCodegenSymbol(false, null);
            var methodNode = codegenMethodScope.MakeChildWithScope(
                    typeof(double?),
                    typeof(EnumAverageEventsForgeEval),
                    scope,
                    codegenClassScope)
                .AddParam(EnumForgeCodegenNames.PARAMS);

            var block = methodNode.Block
                .DeclareVar<double>("sum", Constant(0d))
                .DeclareVar<int>("count", Constant(0))
                .DeclareVar<ObjectArrayEventBean>(
                    "resultEvent",
                    NewInstance<ObjectArrayEventBean>(
                        NewArrayByLength(typeof(object), Constant(1)),
                        resultTypeMember))
                .AssignArrayElement(EnumForgeCodegenNames.REF_EPS, Constant(forge.StreamNumLambda), Ref("resultEvent"))
                .DeclareVar<object[]>("props", ExprDotName(Ref("resultEvent"), "Properties"));

            var forEach = block.ForEach(typeof(object), "next", EnumForgeCodegenNames.REF_ENUMCOLL)
                .AssignArrayElement("props", Constant(0), Ref("next"))
                .DeclareVar(
                    innerType,
                    "num",
                    forge.InnerExpression.EvaluateCodegen(innerType, methodNode, scope, codegenClassScope));
            if (innerType.CanBeNull()) {
                forEach.IfRefNull("num").BlockContinue();
            }

            forEach.Increment("count")
                .AssignRef(
                    "sum",
                    Op(
                        Ref("sum"),
                        "+",
                        SimpleNumberCoercerFactory.CoercerDouble.CodegenDouble(Ref("num"), innerType)))
                .BlockEnd();
            block.IfCondition(EqualsIdentity(Ref("count"), Constant(0)))
                .BlockReturn(ConstantNull())
                .MethodReturn(Op(Ref("sum"), "/", Ref("count")));
            return LocalMethod(methodNode, args.Eps, args.Enumcoll, args.IsNewData, args.ExprCtx);
        }
コード例 #30
0
        public static CodegenExpression Codegen(
            EnumMostLeastFrequentScalarLamdaForge forge,
            EnumForgeCodegenParams args,
            CodegenMethodScope codegenMethodScope,
            CodegenClassScope codegenClassScope)
        {
            var resultTypeMember = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(ObjectArrayEventType),
                Cast(
                    typeof(ObjectArrayEventType),
                    EventTypeUtility.ResolveTypeCodegen(forge.resultEventType, EPStatementInitServicesConstants.REF)));
            var returnType = Boxing.GetBoxedType(forge.InnerExpression.EvaluationType);

            var scope = new ExprForgeCodegenSymbol(false, null);
            var paramTypes = EnumForgeCodegenNames.PARAMS;
            var methodNode = codegenMethodScope
                .MakeChildWithScope(
                    returnType,
                    typeof(EnumMostLeastFrequentScalarLamdaForgeEval),
                    scope,
                    codegenClassScope)
                .AddParam(paramTypes);

            var block = methodNode.Block
                .IfCondition(ExprDotMethod(EnumForgeCodegenNames.REF_ENUMCOLL, "IsEmpty"))
                .BlockReturn(ConstantNull())
                .DeclareVar<IDictionary<object, int>>("items", NewInstance(typeof(HashMap<object, int>)))
                .DeclareVar<ObjectArrayEventBean>(
                    "resultEvent",
                    NewInstance<ObjectArrayEventBean>(NewArrayByLength(typeof(object), Constant(1)), resultTypeMember))
                .AssignArrayElement(EnumForgeCodegenNames.REF_EPS, Constant(forge.StreamNumLambda), Ref("resultEvent"))
                .DeclareVar<object[]>("props", ExprDotName(Ref("resultEvent"), "Properties"));

            block.ForEach(typeof(object), "next", EnumForgeCodegenNames.REF_ENUMCOLL)
                .AssignArrayElement("props", Constant(0), Ref("next"))
                .DeclareVar<object>(
                    "item",
                    forge.InnerExpression.EvaluateCodegen(typeof(object), methodNode, scope, codegenClassScope))
                .DeclareVar<int?>("existing", ExprDotMethod(Ref("items"), "GetBoxed", Ref("item")))
                .IfCondition(EqualsNull(Ref("existing")))
                .AssignRef("existing", Constant(1))
                .IfElse()
                .Increment("existing")
                .BlockEnd()
                .ExprDotMethod(Ref("items"), "Put", Ref("item"), Unbox(Ref("existing")));
            block.MethodReturn(
                Cast(
                    returnType,
                    StaticMethod(
                        typeof(EnumMostLeastFrequentEventForgeEval),
                        "GetEnumMostLeastFrequentResult",
                        Ref("items"),
                        Constant(forge.isMostFrequent))));
            return LocalMethod(methodNode, args.Eps, args.Enumcoll, args.IsNewData, args.ExprCtx);
        }