示例#1
0
        public CodegenExpression EvaluateGetROCollectionEventsCodegen(
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            if (PreviousType == ExprPreviousNodePreviousType.PREV ||
                PreviousType == ExprPreviousNodePreviousType.PREVTAIL ||
                PreviousType == ExprPreviousNodePreviousType.PREVCOUNT) {
                return ConstantNull();
            }

            if (PreviousType != ExprPreviousNodePreviousType.PREVWINDOW) {
                throw new IllegalStateException("Unrecognized previous type " + PreviousType);
            }

            var method = parent.MakeChild(typeof(FlexCollection), GetType(), codegenClassScope);
            method.Block.DeclareVar<PreviousGetterStrategy>(
                "strategy",
                ExprDotMethod(
                    GetterField(codegenClassScope),
                    "GetStrategy",
                    exprSymbol.GetAddExprEvalCtx(method)));

            method.Block.IfCondition(Not(exprSymbol.GetAddIsNewData(method))).BlockReturn(ConstantNull());
            var randomAccess = method.Block.IfCondition(InstanceOf(Ref("strategy"), typeof(RandomAccessByIndexGetter)));
            {
                randomAccess
                    .DeclareVar<RandomAccessByIndexGetter>(
                        "getter",
                        Cast(typeof(RandomAccessByIndexGetter), Ref("strategy")))
                    .DeclareVar<RandomAccessByIndex>(
                        "randomAccess",
                        ExprDotName(Ref("getter"), "Accessor"))
                    .BlockReturn(FlexWrap(ExprDotName(Ref("randomAccess"), "WindowCollectionReadOnly")));
            }
            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")
                    .BlockReturn(FlexWrap(ExprDotName(Ref("relativeAccess"), "WindowToEventCollReadOnly")));
            }
            return LocalMethod(method);
        }