コード例 #1
0
 public static void GetEnumerableEventsCodegen(
     AggregationAccessorWindowWEvalForge 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));
 }
コード例 #2
0
 public static void GetEnumerableScalarCodegen(
     AggregationAccessorWindowWEvalForge 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>>(
             "enumerator",
             stateForge.AggregatorLinear.EnumeratorCodegen(
                 context.ClassScope,
                 context.Method,
                 context.NamedMethods))
         .DebugStack()
         .DeclareVar<EventBean[]>(
             "eventsPerStreamBuf",
             NewArrayByLength(typeof(EventBean), Constant(forge.StreamNum + 1)))
         .WhileLoop(ExprDotMethod(Ref("enumerator"), "MoveNext"))
         .DeclareVar<EventBean>("bean", Cast(typeof(EventBean), ExprDotName(Ref("enumerator"), "Current")))
         .AssignArrayElement("eventsPerStreamBuf", Constant(forge.StreamNum), Ref("bean"))
         .DeclareVar(
             forge.ChildNode.EvaluationType.GetBoxedType(),
             "value",
             LocalMethod(
                 CodegenLegoMethodExpression.CodegenExpression(
                     forge.ChildNode,
                     context.Method,
                     context.ClassScope,
                     true),
                 Ref("eventsPerStreamBuf"),
                 ConstantTrue(),
                 ConstantNull()))
         .ExprDotMethod(Ref("values"), "Add", Ref("value"))
         .BlockEnd()
         .MethodReturn(Ref("values"));
 }
コード例 #3
0
        public static void GetValueCodegen(
            AggregationAccessorWindowWEvalForge forge,
            AggregationStateLinearForge accessStateFactory,
            AggregationAccessorForgeGetCodegenContext context)
        {
            var size = accessStateFactory.AggregatorLinear.SizeCodegen();
            var enumerator = accessStateFactory.AggregatorLinear.EnumeratorCodegen(
                context.ClassScope,
                context.Method,
                context.NamedMethods);
            var childExpr = CodegenLegoMethodExpression.CodegenExpression(
                forge.ChildNode,
                context.Method,
                context.ClassScope,
                false);
            var childExprType = forge.ChildNode.EvaluationType;

            CodegenExpression invokeChild = LocalMethod(childExpr, Ref("eventsPerStreamBuf"), Constant(true), ConstantNull());
            if (forge.ComponentType != childExprType) {
                invokeChild = Unbox(invokeChild);
            }

            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>>("enumerator", enumerator)
                .DebugStack()
                .DeclareVar<EventBean[]>("eventsPerStreamBuf", NewArrayByLength(typeof(EventBean), Constant(forge.StreamNum + 1)))
                .WhileLoop(ExprDotMethod(Ref("enumerator"), "MoveNext"))
                .DeclareVar<EventBean>("bean", Cast(typeof(EventBean), ExprDotName(Ref("enumerator"), "Current")))
                .AssignArrayElement("eventsPerStreamBuf", Constant(forge.StreamNum), Ref("bean"))
                .AssignArrayElement(Ref("array"), Ref("count"), invokeChild)
                .IncrementRef("count")
                .BlockEnd()
                .MethodReturn(Ref("array"));
        }