Exemple #1
0
 public static void GetEnumerableScalarCodegen(
     AggregationAccessorFirstLastIndexWEvalForge forge,
     AggregationAccessorForgeGetCodegenContext context)
 {
     AggregationStateLinearForge stateForge = (AggregationStateLinearForge) context.AccessStateForge;
     CodegenMethod getBeanFirstLastIndex = GetBeanFirstLastIndexCodegen(
         forge,
         context.Column,
         context.ClassScope,
         stateForge,
         context.Method,
         context.NamedMethods);
     context.Method.Block.DeclareVar<EventBean>("bean", LocalMethod(getBeanFirstLastIndex))
         .DebugStack()
         .IfRefNullReturnNull("bean")
         .DeclareVar<EventBean[]>(
             "eventsPerStreamBuf",
             NewArrayByLength(typeof(EventBean), Constant(forge.StreamNum + 1)))
         .AssignArrayElement("eventsPerStreamBuf", Constant(forge.StreamNum), Ref("bean"))
         .DeclareVar<object>(
             "value",
             LocalMethod(
                 CodegenLegoMethodExpression.CodegenExpression(
                     forge.ChildNode,
                     context.Method,
                     context.ClassScope,
                     true),
                 Ref("eventsPerStreamBuf"),
                 ConstantTrue(),
                 ConstantNull()))
         .IfRefNullReturnNull("value")
         .MethodReturn(StaticMethod(typeof(Collections), "SingletonList", Ref("value")));
 }
Exemple #2
0
 public static void GetEnumerableEventCodegen(
     AggregationAccessorFirstLastIndexWEvalForge forge,
     AggregationAccessorForgeGetCodegenContext context)
 {
     AggregationStateLinearForge stateForge = (AggregationStateLinearForge) context.AccessStateForge;
     CodegenMethod getBeanFirstLastIndex = GetBeanFirstLastIndexCodegen(
         forge,
         context.Column,
         context.ClassScope,
         stateForge,
         context.Method,
         context.NamedMethods);
     context.Method.Block.MethodReturn(LocalMethod(getBeanFirstLastIndex));
 }
Exemple #3
0
 public static void GetEnumerableEventsCodegen(
     AggregationAccessorFirstLastIndexWEvalForge forge,
     AggregationAccessorForgeGetCodegenContext context)
 {
     AggregationStateLinearForge stateForge = (AggregationStateLinearForge) context.AccessStateForge;
     CodegenMethod getBeanFirstLastIndex = GetBeanFirstLastIndexCodegen(
         forge,
         context.Column,
         context.ClassScope,
         stateForge,
         context.Method,
         context.NamedMethods);
     context.Method.Block.DeclareVar<EventBean>("bean", LocalMethod(getBeanFirstLastIndex))
         .IfRefNullReturnNull("bean")
         .MethodReturn(StaticMethod(typeof(Collections), "SingletonList", Ref("bean")));
 }
Exemple #4
0
        private static CodegenMethod GetBeanFirstLastIndexCodegen(
            AggregationAccessorFirstLastIndexWEvalForge forge,
            int column,
            CodegenClassScope classScope,
            AggregationStateLinearForge stateForge,
            CodegenMethod parent,
            CodegenNamedMethods namedMethods)
        {
            CodegenMethod method = parent.MakeChild(
                typeof(EventBean),
                typeof(AggregationAccessorFirstLastIndexWEval),
                classScope);
            if (forge.Constant == -1) {
                Type evalType = forge.IndexNode.EvaluationType;
                method.Block.DeclareVar(
                    evalType,
                    "indexResult",
                    LocalMethod(
                        CodegenLegoMethodExpression.CodegenExpression(
                            forge.IndexNode,
                            method, 
                            classScope,
                            true),
                        ConstantNull(),
                        ConstantTrue(),
                        ConstantNull()));
                if (evalType.CanBeNull()) {
                    method.Block.IfRefNullReturnNull("indexResult");
                }

                method.Block.DeclareVar<int>(
                    "index",
                    SimpleNumberCoercerFactory.CoercerInt.CodegenInt(Ref("indexResult"), evalType));
            }
            else {
                method.Block.DeclareVar<int>("index", Constant(forge.Constant));
            }

            CodegenExpression value = forge.IsFirst
                ? stateForge.AggregatorLinear.GetFirstNthValueCodegen(Ref("index"), method, classScope, namedMethods)
                : stateForge.AggregatorLinear.GetLastNthValueCodegen(Ref("index"), method, classScope, namedMethods);
            method.Block.MethodReturn(value);
            return method;
        }