public void SortPlainCodegen(
     CodegenMethod method,
     CodegenClassScope classScope,
     CodegenNamedMethods namedMethods)
 {
     OrderByProcessorImpl.SortPlainCodegen(this, method, classScope, namedMethods);
 }
        protected internal static void SortPlainCodegenCodegen(
            OrderByProcessorOrderedLimitForge forge,
            CodegenMethod method,
            CodegenClassScope classScope,
            CodegenNamedMethods namedMethods)
        {
            var limit1 = EqualsIdentity(ExprDotName(REF_ROWLIMITPROCESSOR, "CurrentRowLimit"), Constant(1));
            var offset0 = EqualsIdentity(ExprDotName(REF_ROWLIMITPROCESSOR, "CurrentOffset"), Constant(0));
            var haveOutgoing = And(
                NotEqualsNull(REF_OUTGOINGEVENTS),
                Relational(ArrayLength(REF_OUTGOINGEVENTS), GT, Constant(1)));
            var determineLocalMinMax = OrderByProcessorImpl.DetermineLocalMinMaxCodegen(
                forge.OrderByProcessorForge,
                classScope,
                namedMethods);

            var sortPlain = method.MakeChild(typeof(EventBean[]), typeof(OrderByProcessorOrderedLimit), classScope)
                .AddParam(SORTPLAIN_PARAMS);
            OrderByProcessorImpl.SortPlainCodegen(forge.OrderByProcessorForge, sortPlain, classScope, namedMethods);

            method.Block.ExprDotMethod(REF_ROWLIMITPROCESSOR, "DetermineCurrentLimit")
                .IfCondition(And(limit1, offset0, haveOutgoing))
                .DeclareVar<EventBean>(
                    "minmax",
                    LocalMethod(
                        determineLocalMinMax,
                        REF_OUTGOINGEVENTS,
                        REF_GENERATINGEVENTS,
                        ExprForgeCodegenNames.REF_ISNEWDATA,
                        REF_EXPREVALCONTEXT,
                        MEMBER_AGGREGATIONSVC))
                .BlockReturn(NewArrayWithInit(typeof(EventBean), Ref("minmax")))
                .DeclareVar<EventBean[]>(
                    "sorted",
                    LocalMethod(
                        sortPlain,
                        REF_OUTGOINGEVENTS,
                        REF_GENERATINGEVENTS,
                        ExprForgeCodegenNames.REF_ISNEWDATA,
                        REF_EXPREVALCONTEXT,
                        MEMBER_AGGREGATIONSVC))
                .MethodReturn(ExprDotMethod(REF_ROWLIMITPROCESSOR, "ApplyLimit", Ref("sorted")));
        }