Esempio n. 1
0
        public static void GetValueCodegen(
            AggregationAccessorWindowNoEvalForge forge,
            AggregationStateLinearForge accessStateFactory,
            AggregationAccessorForgeGetCodegenContext context)
        {
            var size = accessStateFactory.AggregatorLinear.SizeCodegen();
            var iterator = accessStateFactory.AggregatorLinear.EnumeratorCodegen(
                context.ClassScope,
                context.Method,
                context.NamedMethods);

            context.Method.Block.IfCondition(EqualsIdentity(size, Constant(0)))
                .BlockReturn(ConstantNull())
                .DeclareVar(
                    TypeHelper.GetArrayType(forge.ComponentType),
                    "array",
                    NewArrayByLength(forge.ComponentType, size))
                .DeclareVar<int>("count", Constant(0))
                .DeclareVar<IEnumerator<EventBean>>("it", iterator)
                .WhileLoop(ExprDotMethod(Ref("it"), "MoveNext"))
                .DeclareVar<EventBean>("bean", Cast(typeof(EventBean), ExprDotName(Ref("it"), "Current")))
                .AssignArrayElement(
                    Ref("array"),
                    Ref("count"),
                    Cast(forge.ComponentType, ExprDotUnderlying(Ref("bean"))))
                .Increment("count")
                .BlockEnd()
                .MethodReturn(Ref("array"));
        }
Esempio n. 2
0
 public static void GetEnumerableEventsCodegen(
     AggregationAccessorWindowNoEvalForge forge,
     AggregationStateLinearForge stateForge,
     AggregationAccessorForgeGetCodegenContext context)
 {
     context.Method.Block.IfCondition(EqualsIdentity(stateForge.AggregatorLinear.SizeCodegen(), Constant(0)))
         .BlockReturn(ConstantNull())
         .MethodReturn(
             stateForge.AggregatorLinear.CollectionReadOnlyCodegen(
                 context.Method,
                 context.ClassScope,
                 context.NamedMethods));
 }
Esempio n. 3
0
 public static void GetEnumerableScalarCodegen(
     AggregationAccessorWindowNoEvalForge forge,
     AggregationStateLinearForge stateForge,
     AggregationAccessorForgeGetCodegenContext context)
 {
     context.Method.Block.DeclareVar<int>("size", stateForge.AggregatorLinear.SizeCodegen())
         .IfCondition(EqualsIdentity(Ref("size"), Constant(0)))
         .BlockReturn(ConstantNull())
         .DeclareVar<IList<object>>("values", NewInstance<List<object>>(Ref("size")))
         .DeclareVar<IEnumerator<EventBean>>(
             "it",
             stateForge.AggregatorLinear.EnumeratorCodegen(
                 context.ClassScope,
                 context.Method,
                 context.NamedMethods))
         .WhileLoop(ExprDotMethod(Ref("it"), "MoveNext"))
         .DeclareVar<EventBean>("bean", Cast(typeof(EventBean), ExprDotName(Ref("it"), "Current")))
         .DeclareVar(forge.ComponentType, "value", Cast(forge.ComponentType, ExprDotUnderlying(Ref("bean"))))
         .ExprDotMethod(Ref("values"), "Add", Ref("value"))
         .BlockEnd()
         .MethodReturn(Ref("values"));
 }