コード例 #1
0
 public CodegenExpression EvaluateGetROCollectionEventsCodegen(
     CodegenMethodScope parent,
     ExprForgeCodegenSymbol symbols,
     CodegenClassScope classScope)
 {
     var reader = classScope.AddOrGetDefaultFieldSharable(
         new AggregationTableAccessAggReaderCodegenField(_tableAccessDesc.Reader, classScope, GetType()));
     return StaticMethod(
         typeof(ExprTableIdentNodeSubpropAccessor),
         "EvaluateTableWithReaderCollectionEvents",
         Constant(_streamNum),
         reader,
         Constant(_tableAccessColumn.Column),
         symbols.GetAddEPS(parent),
         symbols.GetAddIsNewData(parent),
         symbols.GetAddExprEvalCtx(parent));
 }
コード例 #2
0
        public CodegenExpression EvaluateCodegen(
            Type requiredType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var result = _fragmentType.IsIndexed ? typeof(EventBean[]) : typeof(EventBean);
            var methodNode = codegenMethodScope.MakeChild(result, typeof(ExprEvalByGetterFragment), codegenClassScope);

            var refEPS = exprSymbol.GetAddEPS(methodNode);
            methodNode.Block
                .DeclareVar<EventBean>("@event", ArrayAtIndex(refEPS, Constant(StreamNum)))
                .IfRefNullReturnNull("@event")
                .MethodReturn(
                    FlexCast(result, Getter.EventBeanFragmentCodegen(Ref("@event"), methodNode, codegenClassScope)));
            return LocalMethod(methodNode);
        }
コード例 #3
0
ファイル: SelectEvalWildcard.cs プロジェクト: lanicon/nesper
 protected override CodegenExpression ProcessSpecificCodegen(
     CodegenExpression resultEventType,
     CodegenExpression eventBeanFactory,
     CodegenExpression props,
     CodegenMethod methodNode,
     SelectExprProcessorCodegenSymbol selectEnv,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     CodegenExpressionRef refEPS = exprSymbol.GetAddEPS(methodNode);
     return ExprDotMethod(
         eventBeanFactory,
         "AdapterForTypedWrapper",
         ArrayAtIndex(refEPS, Constant(0)),
         props,
         resultEventType);
 }
コード例 #4
0
ファイル: ExprPreviousNode.cs プロジェクト: lanicon/nesper
        private CodegenExpression EvaluateCodegenPrevCount(
            Type requiredType,
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var method = parent.MakeChild(ResultType, GetType(), codegenClassScope);

            method.Block
                .DeclareVar<long>("size", Constant(0))
                .DeclareVar<PreviousGetterStrategy>(
                    "strategy",
                    ExprDotMethod(GetterField(codegenClassScope), "GetStrategy", exprSymbol.GetAddExprEvalCtx(method)));

            var randomAccess = method.Block.IfCondition(InstanceOf(Ref("strategy"), typeof(RandomAccessByIndexGetter)));
            {
                randomAccess
                    .IfCondition(Not(exprSymbol.GetAddIsNewData(method)))
                    .BlockReturn(ConstantNull())
                    .DeclareVar<RandomAccessByIndexGetter>(
                        "getter",
                        Cast(typeof(RandomAccessByIndexGetter), Ref("strategy")))
                    .DeclareVar<RandomAccessByIndex>(
                        "randomAccess",
                        ExprDotName(Ref("getter"), "Accessor"))
                    .AssignRef("size", ExprDotName(Ref("randomAccess"), "WindowCount"));
            }
            var relativeAccess = randomAccess.IfElse();
            {
                relativeAccess
                    .DeclareVar<RelativeAccessByEventNIndexGetter>(
                        "getter",
                        Cast(typeof(RelativeAccessByEventNIndexGetter), Ref("strategy")))
                    .DeclareVar<EventBean>(
                        "evalEvent",
                        ArrayAtIndex(exprSymbol.GetAddEPS(method), Constant(StreamNumber)))
                    .DeclareVar<RelativeAccessByEventNIndex>(
                        "relativeAccess",
                        ExprDotMethod(Ref("getter"), "GetAccessor", Ref("evalEvent")))
                    .IfRefNullReturnNull("relativeAccess")
                    .AssignRef("size", ExprDotName(Ref("relativeAccess"), "WindowToEventCount"));
            }

            method.Block.MethodReturn(Ref("size"));
            return LocalMethod(method);
        }
コード例 #5
0
        public override CodegenMethod ProcessCodegen(
            CodegenExpression resultEventType,
            CodegenExpression eventBeanFactory,
            CodegenMethodScope codegenMethodScope,
            SelectExprProcessorCodegenSymbol selectSymbol,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var size = ComputeSize();
            var methodNode = codegenMethodScope.MakeChild(typeof(EventBean), GetType(), codegenClassScope);
            var refEPS = exprSymbol.GetAddEPS(methodNode);

            var block = methodNode.Block
                .DeclareVar<object[]>("props", NewArrayByLength(typeof(object), Constant(size)));
            var count = 0;
            foreach (var forge in context.ExprForges) {
                block.AssignArrayElement(
                    Ref("props"),
                    Constant(count),
                    CodegenLegoMayVoid.ExpressionMayVoid(
                        typeof(object),
                        forge,
                        methodNode,
                        exprSymbol,
                        codegenClassScope));
                count++;
            }

            foreach (var element in namedStreams) {
                var theEvent = ArrayAtIndex(refEPS, Constant(element.StreamNumber));
                block.AssignArrayElement(Ref("props"), Constant(count), theEvent);
                count++;
            }

            if (isUsingWildcard && context.NumStreams > 1) {
                for (var i = 0; i < context.NumStreams; i++) {
                    block.AssignArrayElement(Ref("props"), Constant(count), ArrayAtIndex(refEPS, Constant(i)));
                    count++;
                }
            }

            block.MethodReturn(
                ProcessSpecificCodegen(resultEventType, eventBeanFactory, Ref("props"), codegenClassScope));
            return methodNode;
        }
コード例 #6
0
        public CodegenExpression EvaluateCodegenUninstrumented(
            Type requiredType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            CodegenMethod methodNode = codegenMethodScope.MakeChild(
                typeof(EventBean),
                typeof(ExprEvalStreamInsertUnd),
                codegenClassScope);

            CodegenExpressionRef refEPS = exprSymbol.GetAddEPS(methodNode);
            methodNode.Block
                .IfCondition(EqualsNull(refEPS))
                .BlockReturn(ConstantNull())
                .MethodReturn(ArrayAtIndex(refEPS, Constant(streamNum)));
            return LocalMethod(methodNode);
        }
コード例 #7
0
 public CodegenMethod ProcessCodegen(
     CodegenExpression resultEventType,
     CodegenExpression eventBeanFactory,
     CodegenMethodScope codegenMethodScope,
     SelectExprProcessorCodegenSymbol selectSymbol,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     var methodNode = codegenMethodScope.MakeChild(
         typeof(EventBean),
         this.GetType(),
         codegenClassScope);
     var refEPS = exprSymbol.GetAddEPS(methodNode);
     var type = VariantEventTypeUtil.GetField(variantEventType, codegenClassScope);
     methodNode.Block.MethodReturn(
         ExprDotMethod(type, "GetValueAddEventBean", ArrayAtIndex(refEPS, Constant(0))));
     return methodNode;
 }
コード例 #8
0
ファイル: ExprEvalByGetter.cs プロジェクト: lanicon/nesper
        public CodegenExpression EvaluateCodegen(
            Type requiredType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var methodNode = codegenMethodScope.MakeChild(EvaluationType, typeof(ExprEvalByGetter), codegenClassScope);

            var refEPS = exprSymbol.GetAddEPS(methodNode);
            methodNode.Block
                .DeclareVar<EventBean>("@event", ArrayAtIndex(refEPS, Constant(_streamNum)))
                .IfRefNullReturnNull("@event")
                .MethodReturn(
                    CodegenLegoCast.CastSafeFromObjectType(
                        EvaluationType,
                        _getter.EventBeanGetCodegen(Ref("@event"), methodNode, codegenClassScope)));
            return LocalMethod(methodNode);
        }
コード例 #9
0
 public CodegenMethod ProcessCodegen(
     CodegenExpression resultEventType,
     CodegenExpression eventBeanFactory,
     CodegenMethodScope codegenMethodScope,
     SelectExprProcessorCodegenSymbol selectSymbol,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     CodegenMethod methodNode = codegenMethodScope.MakeChild(
         typeof(EventBean),
         this.GetType(),
         codegenClassScope);
     CodegenExpressionRef refEPS = exprSymbol.GetAddEPS(methodNode);
     CodegenExpression bean = ExprDotName(ArrayAtIndex(refEPS, Constant(streamNumber)), "Underlying");
     methodNode.Block.MethodReturn(
         ExprDotMethod(eventBeanFactory, "AdapterForTypedObject", bean, resultEventType));
     return methodNode;
 }
コード例 #10
0
            public CodegenMethod ProcessCodegen(
                CodegenExpression resultEventType,
                CodegenExpression eventBeanFactory,
                CodegenMethodScope codegenMethodScope,
                SelectExprProcessorCodegenSymbol selectSymbol,
                ExprForgeCodegenSymbol exprSymbol,
                CodegenClassScope codegenClassScope)
            {
                var methodNode = codegenMethodScope.MakeChild(typeof(EventBean), this.GetType(), codegenClassScope);
                var refEPS     = exprSymbol.GetAddEPS(methodNode);
                var block      = methodNode.Block
                                 .DeclareVar(
                    sourceType.UnderlyingType,
                    "src",
                    CastUnderlying(sourceType.UnderlyingType, ArrayAtIndex(refEPS, Constant(underlyingStreamNumber))))
                                 .DeclareVar(resultType.UnderlyingType, "und", NewInstance(resultType.UnderlyingType));

                foreach (var item in items)
                {
                    if (item.OptionalFromField != null)
                    {
                        block.AssignRef("und." + item.ToField.FieldName, Ref("src." + item.OptionalFromField.FieldName));
                    }
                    else
                    {
                        CodegenExpression value;
                        if (item.OptionalWidener != null)
                        {
                            value = item.Forge.EvaluateCodegen(item.Forge.EvaluationType, methodNode, exprSymbol, codegenClassScope);
                            value = item.OptionalWidener.WidenCodegen(value, methodNode, codegenClassScope);
                        }
                        else
                        {
                            value = item.Forge.EvaluateCodegen(typeof(object), methodNode, exprSymbol, codegenClassScope);
                        }

                        block.AssignRef("und." + item.ToField.FieldName, value);
                    }
                }

                methodNode.Block.MethodReturn(ExprDotMethod(eventBeanFactory, "AdapterForTypedJson", Ref("und"), resultEventType));
                return(methodNode);
            }
コード例 #11
0
 protected override CodegenExpression ProcessSpecificCodegen(
     CodegenExpression resultEventType,
     CodegenExpression eventBeanFactory,
     CodegenExpression props,
     CodegenMethod methodNode,
     SelectExprProcessorCodegenSymbol selectEnv,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     CodegenExpressionRef refEPS = exprSymbol.GetAddEPS(methodNode);
     return StaticMethod(
         typeof(SelectEvalInsertWildcardSSWrapper),
         "ProcessSelectExprSSWrapper",
         props,
         refEPS,
         Constant(context.ExprForges.Length == 0),
         eventBeanFactory,
         resultEventType);
 }
コード例 #12
0
 protected override CodegenExpression ProcessSpecificCodegen(
     CodegenExpression resultEventType,
     CodegenExpression eventBeanFactory,
     CodegenExpression props,
     CodegenMethod methodNode,
     SelectExprProcessorCodegenSymbol selectEnv,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     var type = VariantEventTypeUtil.GetField(variantEventType, codegenClassScope);
     var refEPS = exprSymbol.GetAddEPS(methodNode);
     return StaticMethod(
         typeof(SelectEvalInsertWildcardSSWrapperRevision),
         "SelectExprInsertWildcardSSWrapRevision",
         refEPS,
         evaluators == null ? Constant(0) : Constant(evaluators.Length),
         props,
         type);
 }
コード例 #13
0
        public CodegenExpression EvaluateCodegenUninstrumented(
            Type requiredType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var methodNode = codegenMethodScope.MakeChild(typeof(bool?), GetType(), codegenClassScope);

            var refEPS = exprSymbol.GetAddEPS(methodNode);
            methodNode.Block
                .DeclareVar<EventBean>("@event", ArrayAtIndex(refEPS, Constant(identNode.StreamId)))
                .IfRefNullReturnNull("@event")
                .MethodReturn(
                    identNode.ExprEvaluatorIdent.Getter.EventBeanExistsCodegen(
                        Ref("@event"),
                        methodNode,
                        codegenClassScope));
            return LocalMethod(methodNode);
        }
コード例 #14
0
        public CodegenExpression EvaluateGetEventBeanCodegen(
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var methodNode = codegenMethodScope.MakeChild(
                typeof(EventBean),
                typeof(PropertyDotEventSingleForge),
                codegenClassScope);

            var refEPS = exprSymbol.GetAddEPS(methodNode);
            methodNode.Block
                .DeclareVar<EventBean>("@event", ArrayAtIndex(refEPS, Constant(streamId)))
                .IfRefNullReturnNull("@event")
                .MethodReturn(
                    Cast(
                        typeof(EventBean),
                        getter.EventBeanFragmentCodegen(Ref("@event"), methodNode, codegenClassScope)));
            return LocalMethod(methodNode);
        }
コード例 #15
0
 public CodegenExpression EvaluateCodegenUninstrumented(
     Type requiredType,
     CodegenMethodScope codegenMethodScope,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     CodegenExpressionRef refEps = exprSymbol.GetAddEPS(codegenMethodScope);
     CodegenExpression refIsNewData = exprSymbol.GetAddIsNewData(codegenMethodScope);
     CodegenExpressionRef refExprEvalCtx = exprSymbol.GetAddExprEvalCtx(codegenMethodScope);
     CodegenExpressionInstanceField eventToPublic =
         TableDeployTimeResolver.MakeTableEventToPublicField(_tableMetadata, codegenClassScope, this.GetType());
     return StaticMethod(
         typeof(ExprEvalStreamInsertTable),
         "ConvertToTableEvent",
         Constant(_streamNum),
         eventToPublic,
         refEps,
         refIsNewData,
         refExprEvalCtx);
 }
コード例 #16
0
 public CodegenExpression EvaluateCodegen(
     Type requiredType,
     CodegenMethodScope codegenMethodScope,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     CodegenExpressionInstanceField eventToPublic =
         TableDeployTimeResolver.MakeTableEventToPublicField(tableMetadata, codegenClassScope, this.GetType());
     CodegenExpressionRef refEPS = exprSymbol.GetAddEPS(codegenMethodScope);
     CodegenExpression refIsNewData = exprSymbol.GetAddIsNewData(codegenMethodScope);
     CodegenExpressionRef refExprEvalCtx = exprSymbol.GetAddExprEvalCtx(codegenMethodScope);
     return StaticMethod(
         typeof(BindProcessorStreamTable),
         "EvaluateConvertTableEventToUnd",
         Constant(streamNum),
         eventToPublic,
         refEPS,
         refIsNewData,
         refExprEvalCtx);
 }
コード例 #17
0
 public CodegenExpression EvaluateCodegenUninstrumented(
     Type requiredType,
     CodegenMethodScope parent,
     ExprForgeCodegenSymbol symbols,
     CodegenClassScope classScope)
 {
     var reader = classScope.AddOrGetDefaultFieldSharable(
         new AggregationTableAccessAggReaderCodegenField(_tableAccessDesc.Reader, classScope, GetType()));
     return CodegenLegoCast.CastSafeFromObjectType(
         requiredType,
         StaticMethod(
             typeof(ExprTableIdentNodeSubpropAccessor),
             "EvaluateTableWithReader",
             Constant(_streamNum),
             reader,
             Constant(_tableAccessColumn.Column),
             symbols.GetAddEPS(parent),
             symbols.GetAddIsNewData(parent),
             symbols.GetAddExprEvalCtx(parent)));
 }
コード例 #18
0
            public CodegenExpression EvaluateCodegen(
                Type requiredType,
                CodegenMethodScope codegenMethodScope,
                ExprForgeCodegenSymbol exprSymbol,
                CodegenClassScope codegenClassScope)
            {
                var methodNode = codegenMethodScope.MakeChild(returnType, GetType(), codegenClassScope);

                var refEPS = exprSymbol.GetAddEPS(methodNode);

                methodNode.Block
                .DeclareVar <EventBean>(
                    "theEvent",
                    CodegenExpressionBuilder.ArrayAtIndex(refEPS, CodegenExpressionBuilder.Constant(streamNumEval)))
                .IfRefNullReturnNull("theEvent")
                .MethodReturn(
                    CodegenExpressionBuilder.Cast(
                        returnType,
                        CodegenExpressionBuilder.ExprDotUnderlying(CodegenExpressionBuilder.Ref("theEvent"))));
                return(CodegenExpressionBuilder.LocalMethod(methodNode));
            }
コード例 #19
0
        internal override void ApplyLeaveFiltered(
            CodegenMethod method,
            ExprForgeCodegenSymbol symbols,
            CodegenClassScope classScope,
            CodegenNamedMethods namedMethods)
        {
            var eps = symbols.GetAddEPS(method);
            var ctx = symbols.GetAddExprEvalCtx(method);
            var dereferenceRemove = DereferenceRemoveFromCollCodegen(method, namedMethods, classScope);
            method.Block.DeclareVar<EventBean>("theEvent", ArrayAtIndex(eps, Constant(forge.Spec.StreamNum)))
                .IfRefNull("theEvent")
                .BlockReturnNoValue();

            if (joinRefs == null) {
                method.Block.InstanceMethod(dereferenceRemove, Ref("theEvent"), eps, ctx);
            }
            else {
                method.Block.IfCondition(ExprDotMethod(joinRefs, "Remove", Ref("theEvent")))
                    .InstanceMethod(dereferenceRemove, Ref("theEvent"), eps, ctx);
            }
        }
コード例 #20
0
        public CodegenExpression EvaluateCodegenUninstrumented(
            Type requiredType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var methodNode = codegenMethodScope.MakeChild(
                _returnType,
                typeof(ExprEvalStreamInsertUnd),
                codegenClassScope);

            var refEPS = exprSymbol.GetAddEPS(methodNode);
            methodNode.Block
                .IfCondition(EqualsNull(refEPS))
                .BlockReturn(ConstantNull())
                .DeclareVar<EventBean>("bean", ArrayAtIndex(refEPS, Constant(_streamNum)))
                .IfRefNullReturnNull("bean")
                .MethodReturn(FlexCast(_returnType, ExprDotUnderlying(Ref("bean"))));
            
            return LocalMethod(methodNode);
        }
コード例 #21
0
ファイル: ExprPreviousNode.cs プロジェクト: lanicon/nesper
        public CodegenExpression EvaluateGetEventBeanCodegen(
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            if (PreviousType == ExprPreviousNodePreviousType.PREVWINDOW ||
                PreviousType == ExprPreviousNodePreviousType.PREVCOUNT) {
                return ConstantNull();
            }

            var method = parent.MakeChild(typeof(EventBean), GetType(), codegenClassScope);
            method.Block
                .IfCondition(Not(exprSymbol.GetAddIsNewData(method)))
                .BlockReturn(ConstantNull())
                .MethodReturn(
                    LocalMethod(
                        GetSubstituteCodegen(method, exprSymbol, codegenClassScope),
                        exprSymbol.GetAddEPS(method),
                        exprSymbol.GetAddExprEvalCtx(method)));
            return LocalMethod(method);
        }
コード例 #22
0
 public CodegenExpression Codegen(
     CodegenExpression inner,
     Type innerType,
     CodegenMethodScope codegenMethodScope,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     var eventToPublic =
         TableDeployTimeResolver.MakeTableEventToPublicField(table, codegenClassScope, this.GetType());
     var refEPS = exprSymbol.GetAddEPS(codegenMethodScope);
     var refIsNewData = exprSymbol.GetAddIsNewData(codegenMethodScope);
     var refExprEvalCtx = exprSymbol.GetAddExprEvalCtx(codegenMethodScope);
     return StaticMethod(
         typeof(ExprDotForgeUnpackCollEventBeanTable),
         "ConvertToTableUnderling",
         inner,
         eventToPublic,
         refEPS,
         refIsNewData,
         refExprEvalCtx);
 }
コード例 #23
0
        public CodegenExpression EvaluateCodegenUninstrumented(
            Type requiredType,
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var method = parent.MakeChild(EvaluationType, GetType(), codegenClassScope);
            var innerEval = CodegenLegoMethodExpression.CodegenExpression(InnerForge, method, codegenClassScope, true);
            var eps = exprSymbol.GetAddEPS(method);

            // see ExprPriorEvalStrategyBase
            CodegenExpression future = codegenClassScope.NamespaceScope.AddOrGetDefaultFieldWellKnown(
                priorStrategyFieldName,
                typeof(PriorEvalStrategy));

            var innerMethod = LocalMethod(
                innerEval,
                eps,
                exprSymbol.GetAddIsNewData(method),
                exprSymbol.GetAddExprEvalCtx(method));
            method.Block
                .DeclareVar<EventBean>("originalEvent", ArrayAtIndex(eps, Constant(StreamNumber)))
                .DeclareVar<EventBean>(
                    "substituteEvent",
                    ExprDotMethod(
                        future,
                        "GetSubstituteEvent",
                        Ref("originalEvent"),
                        exprSymbol.GetAddIsNewData(method),
                        Constant(ConstantIndexNumber),
                        Constant(RelativeIndex),
                        exprSymbol.GetAddExprEvalCtx(method),
                        Constant(StreamNumber)))
                .AssignArrayElement(eps, Constant(StreamNumber), Ref("substituteEvent"))
                .DeclareVar(EvaluationType, "evalResult", innerMethod)
                .AssignArrayElement(eps, Constant(StreamNumber), Ref("originalEvent"))
                .MethodReturn(Ref("evalResult"));

            return LocalMethod(method);
        }
コード例 #24
0
ファイル: ExprPreviousNode.cs プロジェクト: lanicon/nesper
            public void Accept(CodegenBlock block)
            {
                block
                    .IfCondition(Not(_exprSymbol.GetAddIsNewData(_method)))
                    .BlockReturn(ConstantNull())
                    .DeclareVar<IEnumerator<EventBean>>("events", ConstantNull())
                    .DeclareVar<int>("size", Constant(0));

                var randomAccess = _method.Block.IfCondition(InstanceOf(_getter, typeof(RandomAccessByIndexGetter)));
                {
                    randomAccess
                        .DeclareVar<RandomAccessByIndexGetter>(
                            "getter",
                            Cast(typeof(RandomAccessByIndexGetter), _getter))
                        .DeclareVar<RandomAccessByIndex>(
                            "randomAccess",
                            ExprDotName(Ref("getter"), "Accessor"))
                        .AssignRef("events", ExprDotMethod(Ref("randomAccess"), "GetWindowEnumerator"))
                        .AssignRef("size", ExprDotName(Ref("randomAccess"), "WindowCount"));
                }
                var relativeAccess = randomAccess.IfElse();
                {
                    relativeAccess
                        .DeclareVar<RelativeAccessByEventNIndexGetter>(
                            "getter",
                            Cast(typeof(RelativeAccessByEventNIndexGetter), _getter))
                        .DeclareVar<EventBean>(
                            "evalEvent",
                            ArrayAtIndex(_exprSymbol.GetAddEPS(_method), Constant(_streamNumber)))
                        .DeclareVar<RelativeAccessByEventNIndex>(
                            "relativeAccess",
                            ExprDotMethod(Ref("getter"), "GetAccessor", Ref("evalEvent")))
                        .IfRefNullReturnNull("relativeAccess")
                        .AssignRef("events", ExprDotName(Ref("relativeAccess"), "WindowToEvent"))
                        .AssignRef("size", ExprDotName(Ref("relativeAccess"), "WindowToEventCount"));
                }

                _method.Block.IfCondition(Relational(Ref("size"), LE, Constant(0)))
                    .BlockReturn(ConstantNull());
            }
コード例 #25
0
ファイル: ExprPreviousNode.cs プロジェクト: lanicon/nesper
        private CodegenExpression EvaluateCodegenPrevAndTail(
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var method = parent.MakeChild(ResultType, GetType(), codegenClassScope);

            var eps = exprSymbol.GetAddEPS(method);
            var innerEval = CodegenLegoMethodExpression.CodegenExpression(
                ChildNodes[1].Forge,
                method,
                codegenClassScope,
                true);

            method.Block
                .IfCondition(Not(exprSymbol.GetAddIsNewData(method)))
                .BlockReturn(ConstantNull())
                .DeclareVar<EventBean>(
                    "substituteEvent",
                    LocalMethod(
                        GetSubstituteCodegen(method, exprSymbol, codegenClassScope),
                        eps,
                        exprSymbol.GetAddExprEvalCtx(method)))
                .IfRefNullReturnNull("substituteEvent")
                .DeclareVar<EventBean>("originalEvent", ArrayAtIndex(eps, Constant(StreamNumber)))
                .AssignArrayElement(eps, Constant(StreamNumber), Ref("substituteEvent"))
                .DeclareVar(
                    ResultType,
                    "evalResult",
                    LocalMethod(
                        innerEval,
                        eps,
                        exprSymbol.GetAddIsNewData(method),
                        exprSymbol.GetAddExprEvalCtx(method)))
                .AssignArrayElement(eps, Constant(StreamNumber), Ref("originalEvent"))
                .MethodReturn(Ref("evalResult"));

            return LocalMethod(method);
        }
コード例 #26
0
        public CodegenExpression Codegen(
            CodegenExpression inner,
            Type innerType,
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol symbols,
            CodegenClassScope classScope) 
        {
            CodegenExpression eventToPublic = TableDeployTimeResolver.MakeTableEventToPublicField(tableMetadata, classScope, GetType());
            CodegenMethod methodNode = parent
                .MakeChild(typeof(Object[]), typeof(ExprDotForgeUnpackBeanTable), classScope)
                .AddParam(typeof(EventBean), "target");

            CodegenExpressionRef refEPS = symbols.GetAddEPS(methodNode);
            CodegenExpression refIsNewData = symbols.GetAddIsNewData(methodNode);
            CodegenExpressionRef refExprEvalCtx = symbols.GetAddExprEvalCtx(methodNode);

            methodNode.Block
                .IfRefNullReturnNull("target")
                .MethodReturn(
                    ExprDotMethod(eventToPublic, "ConvertToUnd", Ref("target"), refEPS, refIsNewData, refExprEvalCtx));
            return LocalMethod(methodNode, inner);
        }
コード例 #27
0
ファイル: ExprPreviousNode.cs プロジェクト: lanicon/nesper
        private CodegenExpression EvaluateCodegenPrevWindow(
            Type requiredType,
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var method = parent.MakeChild(ResultType, GetType(), codegenClassScope);

            method.Block
                .DeclareVar<PreviousGetterStrategy>(
                    "strategy",
                    ExprDotMethod(GetterField(codegenClassScope), "GetStrategy", exprSymbol.GetAddExprEvalCtx(method)))
                .Apply(new PreviousBlockGetSizeAndIterator(method, exprSymbol, StreamNumber, Ref("strategy")).Accept);

            var eps = exprSymbol.GetAddEPS(method);
            var innerEval = CodegenLegoMethodExpression.CodegenExpression(
                ChildNodes[1].Forge,
                method,
                codegenClassScope,
                true);

            method.Block.DeclareVar<EventBean>("originalEvent", ArrayAtIndex(eps, Constant(StreamNumber)))
                .DeclareVar(ResultType, "result", NewArrayByLength(ResultType.GetElementType(), Ref("size")))
                .ForLoopIntSimple("i", Ref("size"))
                .ExprDotMethod(Ref("events"), "MoveNext")
                .AssignArrayElement(
                    eps,
                    Constant(StreamNumber),
                    Cast(typeof(EventBean), ExprDotName(Ref("events"), "Current")))
                .AssignArrayElement(
                    "result",
                    Ref("i"),
                    LocalMethod(innerEval, eps, ConstantTrue(), exprSymbol.GetAddExprEvalCtx(method)))
                .BlockEnd()
                .AssignArrayElement(eps, Constant(StreamNumber), Ref("originalEvent"))
                .MethodReturn(Ref("result"));
            return LocalMethod(method);
        }
コード例 #28
0
        public CodegenExpression EvaluateGetROCollectionEventsCodegenImpl(
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var methodNode = codegenMethodScope.MakeChild(
                typeof(FlexCollection),
                typeof(PropertyDotEventCollectionForge),
                codegenClassScope);

            var refEPS = exprSymbol.GetAddEPS(methodNode);

            methodNode.Block
                .DeclareVar<EventBean>("@event", ArrayAtIndex(refEPS, Constant(_streamId)))
                .IfRefNullReturnNull("@event")
                .MethodReturn(
                    CodegenEvaluateInternal(
                        Ref("@event"),
                        method => exprSymbol.GetAddExprEvalCtx(method),
                        methodNode,
                        codegenClassScope));
            return LocalMethod(methodNode);
        }
コード例 #29
0
 public CodegenMethod ProcessCodegen(
     CodegenExpression resultEventType,
     CodegenExpression eventBeanFactory,
     CodegenMethodScope codegenMethodScope,
     SelectExprProcessorCodegenSymbol selectSymbol,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     var methodNode = codegenMethodScope.MakeChild(typeof(EventBean), GetType(), codegenClassScope);
     var refEPS = exprSymbol.GetAddEPS(methodNode);
     var theEvent = CodegenExpressionBuilder.Cast(
         typeof(AvroGenericDataBackedEventBean),
         CodegenExpressionBuilder.ArrayAtIndex(
             refEPS,
             CodegenExpressionBuilder.Constant(_underlyingStreamNumber)));
     methodNode.Block.MethodReturn(
         CodegenExpressionBuilder.ExprDotMethod(
             eventBeanFactory,
             "AdapterForTypedAvro",
             CodegenExpressionBuilder.ExprDotName(theEvent, "Properties"),
             resultEventType));
     return methodNode;
 }
コード例 #30
0
 protected override CodegenExpression ProcessSpecificCodegen(
     CodegenExpression resultEventType,
     CodegenExpression eventBeanFactory,
     CodegenExpression props,
     CodegenMethod methodNode,
     SelectExprProcessorCodegenSymbol selectEnv,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     var innerType = codegenClassScope.AddDefaultFieldUnshared(
         true,
         typeof(EventType),
         EventTypeUtility.ResolveTypeCodegen(innerWrapperType, EPStatementInitServicesConstants.REF));
     var refEPS = exprSymbol.GetAddEPS(methodNode);
     return StaticMethod(
         this.GetType(),
         "WildcardNestedWrapper",
         ArrayAtIndex(refEPS, Constant(0)),
         innerType,
         resultEventType,
         eventBeanFactory,
         props);
 }