public CodegenExpression EvaluateCodegen(
            Type requiredType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            CodegenMethod methodNode = codegenMethodScope.MakeChild(
                typeof(ICollection<object>),
                GetType(),
                codegenClassScope);
            CodegenExpressionRef refEPS = exprSymbol.GetAddEPS(methodNode);

            methodNode.Block
                .DeclareVar<EventBean>(
                    "@event",
                    CodegenExpressionBuilder.ArrayAtIndex(refEPS, CodegenExpressionBuilder.Constant(_streamNum)))
                .IfRefNullReturnNull("@event")
                .DeclareVar<object[]>(
                    "result",
                    CodegenExpressionBuilder.Cast(
                        typeof(object[]),
                        _getter.EventBeanGetCodegen(
                            CodegenExpressionBuilder.Ref("@event"),
                            methodNode,
                            codegenClassScope)))
                .IfRefNullReturnNull("result")
                .MethodReturn(
                    CodegenExpressionBuilder.StaticMethod(
                        typeof(CompatExtensions),
                        "AsList",
                        CodegenExpressionBuilder.Ref("result")));
            return CodegenExpressionBuilder.LocalMethod(methodNode);
        }
            public CodegenExpression EvaluateCodegen(
                Type requiredType,
                CodegenMethodScope codegenMethodScope,
                ExprForgeCodegenSymbol exprSymbol,
                CodegenClassScope codegenClassScope)
            {
                var methodNode = codegenMethodScope.MakeChild(
                    typeof(object),
                    typeof(ExprForgeStreamWithGetter),
                    codegenClassScope);
                var refEPS = exprSymbol.GetAddEPS(methodNode);

                methodNode.Block
                .DeclareVar <EventBean>(
                    "theEvent",
                    CodegenExpressionBuilder.ArrayAtIndex(refEPS, CodegenExpressionBuilder.Constant(0)))
                .IfRefNotNull("theEvent")
                .BlockReturn(
                    getter.EventBeanGetCodegen(
                        CodegenExpressionBuilder.Ref("theEvent"),
                        methodNode,
                        codegenClassScope))
                .MethodReturn(CodegenExpressionBuilder.ConstantNull());
                return(CodegenExpressionBuilder.LocalMethod(methodNode));
            }
Exemple #3
0
            public CodegenExpression EvaluateCodegen(
                Type requiredType,
                CodegenMethodScope codegenMethodScope,
                ExprForgeCodegenSymbol exprSymbol,
                CodegenClassScope codegenClassScope)
            {
                var methodNode = codegenMethodScope.MakeChild(returnType, GetType(), codegenClassScope);

                var refEPS = exprSymbol.GetAddEPS(methodNode);

                methodNode.Block
                .DeclareVar <EventBean>(
                    "theEvent",
                    CodegenExpressionBuilder.ArrayAtIndex(refEPS, CodegenExpressionBuilder.Constant(streamNumEval)))
                .IfRefNullReturnNull("theEvent")
                .MethodReturn(
                    CodegenExpressionBuilder.Cast(
                        returnType,
                        CodegenExpressionBuilder.ExprDotUnderlying(CodegenExpressionBuilder.Ref("theEvent"))));
                return(CodegenExpressionBuilder.LocalMethod(methodNode));
            }
Exemple #4
0
 public CodegenMethod ProcessCodegen(
     CodegenExpression resultEventType,
     CodegenExpression eventBeanFactory,
     CodegenMethodScope codegenMethodScope,
     SelectExprProcessorCodegenSymbol selectSymbol,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     var methodNode = codegenMethodScope.MakeChild(typeof(EventBean), GetType(), codegenClassScope);
     var refEPS = exprSymbol.GetAddEPS(methodNode);
     var theEvent = CodegenExpressionBuilder.Cast(
         typeof(AvroGenericDataBackedEventBean),
         CodegenExpressionBuilder.ArrayAtIndex(
             refEPS,
             CodegenExpressionBuilder.Constant(_underlyingStreamNumber)));
     methodNode.Block.MethodReturn(
         CodegenExpressionBuilder.ExprDotMethod(
             eventBeanFactory,
             "AdapterForTypedAvro",
             CodegenExpressionBuilder.ExprDotName(theEvent, "Properties"),
             resultEventType));
     return methodNode;
 }
Exemple #5
0
        public CodegenExpression EvaluateCodegen(
            Type requiredType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            CodegenMethod methodNode = codegenMethodScope.MakeChild(_returnType, GetType(), codegenClassScope);

            CodegenExpressionRef refEPS = exprSymbol.GetAddEPS(methodNode);
            methodNode.Block
                .DeclareVar<EventBean>(
                    "streamEvent",
                    CodegenExpressionBuilder.ArrayAtIndex(refEPS, CodegenExpressionBuilder.Constant(_streamNum)))
                .IfRefNullReturnNull("streamEvent")
                .MethodReturn(
                    CodegenLegoCast.CastSafeFromObjectType(
                        _returnType,
                        _getter.EventBeanGetCodegen(
                            CodegenExpressionBuilder.Ref("streamEvent"),
                            methodNode,
                            codegenClassScope)));
            return CodegenExpressionBuilder.LocalMethod(methodNode);
        }
Exemple #6
0
            public CodegenExpression EvaluateCodegen(
                Type requiredType,
                CodegenMethodScope codegenMethodScope,
                ExprForgeCodegenSymbol exprSymbol,
                CodegenClassScope codegenClassScope)
            {
                var arrayType  = TypeHelper.GetArrayType(componentReturnType);
                var methodNode = codegenMethodScope.MakeChild(arrayType, GetType(), codegenClassScope);

                methodNode.Block
                .DeclareVar <EventBean[]>(
                    "events",
                    CodegenExpressionBuilder.Cast(
                        typeof(EventBean[]),
                        inner.EvaluateCodegen(requiredType, methodNode, exprSymbol, codegenClassScope)))
                .IfRefNullReturnNull("events")
                .DeclareVar(
                    arrayType,
                    "values",
                    CodegenExpressionBuilder.NewArrayByLength(
                        componentReturnType,
                        CodegenExpressionBuilder.ArrayLength(CodegenExpressionBuilder.Ref("events"))))
                .ForLoopIntSimple("i", CodegenExpressionBuilder.ArrayLength(CodegenExpressionBuilder.Ref("events")))
                .AssignArrayElement(
                    "values",
                    CodegenExpressionBuilder.Ref("i"),
                    CodegenExpressionBuilder.Cast(
                        componentReturnType,
                        CodegenExpressionBuilder.ExprDotUnderlying(
                            CodegenExpressionBuilder.ArrayAtIndex(
                                CodegenExpressionBuilder.Ref("events"),
                                CodegenExpressionBuilder.Ref("i")))))
                .BlockEnd()
                .MethodReturn(CodegenExpressionBuilder.Ref("values"));
                return(CodegenExpressionBuilder.LocalMethod(methodNode));
            }
Exemple #7
0
            public CodegenMethod ProcessCodegen(
                CodegenExpression resultEventType,
                CodegenExpression eventBeanFactory,
                CodegenMethodScope codegenMethodScope,
                SelectExprProcessorCodegenSymbol selectSymbol,
                ExprForgeCodegenSymbol exprSymbol,
                CodegenClassScope codegenClassScope)
            {
                var schema = codegenClassScope.NamespaceScope.AddDefaultFieldUnshared(
                    true,
                    typeof(RecordSchema),
                    CodegenExpressionBuilder.StaticMethod(
                        typeof(AvroSchemaUtil),
                        "ResolveRecordSchema",
                        EventTypeUtility.ResolveTypeCodegen(ResultEventType, EPStatementInitServicesConstants.REF)));
                var methodNode = codegenMethodScope.MakeChild(typeof(EventBean), GetType(), codegenClassScope);
                var refEPS = exprSymbol.GetAddEPS(methodNode);
                var block = methodNode.Block
                    .DeclareVar<AvroGenericDataBackedEventBean>(
                        "theEvent",
                        CodegenExpressionBuilder.Cast(
                            typeof(AvroGenericDataBackedEventBean),
                            CodegenExpressionBuilder.ArrayAtIndex(
                                refEPS,
                                CodegenExpressionBuilder.Constant(_underlyingStreamNumber))))
                    .DeclareVar<GenericRecord>(
                        "source",
                        CodegenExpressionBuilder.ExprDotName(
                            CodegenExpressionBuilder.Ref("theEvent"),
                            "Properties"))
                    .DeclareVar<GenericRecord>(
                        "target",
                        CodegenExpressionBuilder.NewInstance(typeof(GenericRecord), schema));
                
                foreach (var item in _items) {
                    CodegenExpression value;
                    if (item.OptionalFromIndex != null) {
                        value = CodegenExpressionBuilder.StaticMethod(
                            typeof(GenericRecordExtensions),
                            "Get",
                            CodegenExpressionBuilder.Ref("source"),
                            CodegenExpressionBuilder.Constant(item.OptionalFromIndex.Name));
                    }
                    else {
                        if (item.OptionalWidener != null) {
                            value = item.Forge.EvaluateCodegen(
                                item.Forge.EvaluationType,
                                methodNode,
                                exprSymbol,
                                codegenClassScope);
                            value = item.OptionalWidener.WidenCodegen(value, methodNode, codegenClassScope);
                        }
                        else {
                            value = item.Forge.EvaluateCodegen(
                                typeof(object),
                                methodNode,
                                exprSymbol,
                                codegenClassScope);
                        }
                    }

                    block.StaticMethod(
                        typeof(GenericRecordExtensions),
                        "Put",
                        CodegenExpressionBuilder.Ref("target"),
                        CodegenExpressionBuilder.Constant(item.ToIndex.Name),
                        value);
                }

                block.MethodReturn(
                    CodegenExpressionBuilder.ExprDotMethod(
                        eventBeanFactory,
                        "AdapterForTypedAvro",
                        CodegenExpressionBuilder.Ref("target"),
                        resultEventType));
                return methodNode;
            }