Exemple #1
0
        public CodegenExpression Codegen(
            CodegenExpression inner,
            Type innerType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            CodegenExpression eventToPublic = TableDeployTimeResolver.MakeTableEventToPublicField(
                tableMetadata,
                codegenClassScope,
                this.GetType());
            CodegenMethod methodNode = codegenMethodScope
                .MakeChild(typeof(object[]), typeof(ExprDotForgeUnpackBeanTable), codegenClassScope)
                .AddParam(typeof(EventBean), "target");

            CodegenExpressionRef refEPS = exprSymbol.GetAddEPS(methodNode);
            CodegenExpression refIsNewData = exprSymbol.GetAddIsNewData(methodNode);
            CodegenExpressionRef refExprEvalCtx = exprSymbol.GetAddExprEvalCtx(methodNode);

            methodNode.Block
                .IfRefNullReturnNull("target")
                .MethodReturn(
                    ExprDotMethod(eventToPublic, "ConvertToUnd", Ref("target"), refEPS, refIsNewData, refExprEvalCtx));
            return LocalMethod(methodNode, inner);
        }
 public override CodegenExpression EvaluateCodegen(
     CodegenMethodScope parent,
     ExprSubselectEvalMatchSymbol symbols,
     CodegenClassScope classScope)
 {
     var eventToPublic = TableDeployTimeResolver.MakeTableEventToPublicField(table, classScope, GetType());
     var method = parent.MakeChild(subselect.EvaluationType, GetType(), classScope);
     method.Block
         .IfCondition(
             Relational(
                 ExprDotName(symbols.GetAddMatchingEvents(method), "Count"),
                 CodegenExpressionRelational.CodegenRelational.GT,
                 Constant(1)))
         .BlockReturn(ConstantNull())
         .DeclareVar<EventBean>(
             "@event",
             StaticMethod(
                 typeof(EventBeanUtility),
                 "GetNonemptyFirstEvent",
                 symbols.GetAddMatchingEvents(method)))
         .MethodReturn(
             ExprDotMethod(
                 eventToPublic,
                 "ConvertToUnd",
                 Ref("@event"),
                 symbols.GetAddEPS(method),
                 symbols.GetAddIsNewData(method),
                 symbols.GetAddExprEvalCtx(method)));
     return LocalMethod(method);
 }
        public void GetValueCodegen(AggregationAccessorForgeGetCodegenContext context)
        {
            var eventToPublic =
                TableDeployTimeResolver.MakeTableEventToPublicField(table, context.ClassScope, GetType());
            var sorted = (AggregatorAccessSorted) context.AccessStateForge.Aggregator;
            var size = sorted.SizeCodegen();
            var enumerator = max ? sorted.ReverseEnumeratorCodegen() : sorted.EnumeratorCodegen();

            context.Method.Block.IfCondition(EqualsIdentity(size, Constant(0)))
                .BlockReturn(ConstantNull())
                .DeclareVar(TypeHelper.GetArrayType(componentType), "array", NewArrayByLength(componentType, size))
                .DeclareVar<int>("count", Constant(0))
                .DeclareVar<IEnumerator<EventBean>>("enumerator", enumerator)
                .WhileLoop(ExprDotMethod(Ref("enumerator"), "MoveNext"))
                .DeclareVar<EventBean>("bean", Cast(typeof(EventBean), ExprDotName(Ref("enumerator"), "Current")))
                .AssignArrayElement(
                    Ref("array"),
                    Ref("count"),
                    ExprDotMethod(
                        eventToPublic,
                        "ConvertToUnd",
                        Ref("bean"),
                        REF_EPS,
                        REF_ISNEWDATA,
                        REF_EXPREVALCONTEXT))
                .IncrementRef("count")
                .BlockEnd()
                .MethodReturn(Ref("array"));
        }
Exemple #4
0
        public override CodegenExpression EvaluateCodegen(
            CodegenMethodScope parent,
            ExprSubselectEvalMatchSymbol symbols,
            CodegenClassScope classScope)
        {
            CodegenExpressionInstanceField eventToPublic =
                TableDeployTimeResolver.MakeTableEventToPublicField(table, classScope, this.GetType());
            CodegenMethod method = parent.MakeChild(subselect.EvaluationType, this.GetType(), classScope);

            method.Block.ApplyTri(DECLARE_EVENTS_SHIFTED, method, symbols);

            method.Block.DeclareVar<EventBean>("filtered", ConstantNull());
            CodegenBlock @foreach = method.Block.ForEach(
                typeof(EventBean),
                "@event",
                symbols.GetAddMatchingEvents(method));
            {
                @foreach.AssignArrayElement(REF_EVENTS_SHIFTED, Constant(0), Ref("@event"));
                CodegenMethod filter = CodegenLegoMethodExpression.CodegenExpression(subselect.FilterExpr, method, classScope, true);
                CodegenLegoBooleanExpression.CodegenContinueIfNotNullAndNotPass(
                    @foreach,
                    typeof(bool?),
                    LocalMethod(
                        filter,
                        REF_EVENTS_SHIFTED,
                        symbols.GetAddIsNewData(method),
                        symbols.GetAddExprEvalCtx(method)));
                @foreach.IfCondition(NotEqualsNull(Ref("filtered")))
                    .BlockReturn(ConstantNull())
                    .AssignRef("filtered", Ref("@event"));
            }

            method.Block.IfRefNullReturnNull("filtered")
                .MethodReturn(
                    ExprDotMethod(
                        eventToPublic,
                        "ConvertToUnd",
                        Ref("filtered"),
                        symbols.GetAddEPS(method),
                        symbols.GetAddIsNewData(method),
                        symbols.GetAddExprEvalCtx(method)));
            return LocalMethod(method);
        }
 public CodegenExpression EvaluateCodegen(
     Type requiredType,
     CodegenMethodScope codegenMethodScope,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     CodegenExpressionInstanceField eventToPublic =
         TableDeployTimeResolver.MakeTableEventToPublicField(tableMetadata, codegenClassScope, this.GetType());
     CodegenExpressionRef refEPS = exprSymbol.GetAddEPS(codegenMethodScope);
     CodegenExpression refIsNewData = exprSymbol.GetAddIsNewData(codegenMethodScope);
     CodegenExpressionRef refExprEvalCtx = exprSymbol.GetAddExprEvalCtx(codegenMethodScope);
     return StaticMethod(
         typeof(BindProcessorStreamTable),
         "EvaluateConvertTableEventToUnd",
         Constant(streamNum),
         eventToPublic,
         refEPS,
         refIsNewData,
         refExprEvalCtx);
 }
 public CodegenExpression EvaluateCodegenUninstrumented(
     Type requiredType,
     CodegenMethodScope codegenMethodScope,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     CodegenExpressionRef refEps = exprSymbol.GetAddEPS(codegenMethodScope);
     CodegenExpression refIsNewData = exprSymbol.GetAddIsNewData(codegenMethodScope);
     CodegenExpressionRef refExprEvalCtx = exprSymbol.GetAddExprEvalCtx(codegenMethodScope);
     CodegenExpressionInstanceField eventToPublic =
         TableDeployTimeResolver.MakeTableEventToPublicField(_tableMetadata, codegenClassScope, this.GetType());
     return StaticMethod(
         typeof(ExprEvalStreamInsertTable),
         "ConvertToTableEvent",
         Constant(_streamNum),
         eventToPublic,
         refEps,
         refIsNewData,
         refExprEvalCtx);
 }
Exemple #7
0
 public override void GetValueCodegen(AggregationAccessorForgeGetCodegenContext context)
 {
     var eventToPublic =
         TableDeployTimeResolver.MakeTableEventToPublicField(table, context.ClassScope, GetType());
     var forge = (AggregatorAccessSorted) context.AccessStateForge.Aggregator;
     context.Method.Block.DeclareVar<EventBean>(
             "@event",
             max
                 ? forge.GetLastValueCodegen(context.ClassScope, context.Method)
                 : forge.GetFirstValueCodegen(context.ClassScope, context.Method))
         .IfRefNullReturnNull("@event")
         .MethodReturn(
             ExprDotMethod(
                 eventToPublic,
                 "ConvertToUnd",
                 Ref("@event"),
                 REF_EPS,
                 REF_ISNEWDATA,
                 REF_EXPREVALCONTEXT));
 }
Exemple #8
0
 public CodegenExpression Codegen(
     CodegenExpression inner,
     Type innerType,
     CodegenMethodScope codegenMethodScope,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     var eventToPublic =
         TableDeployTimeResolver.MakeTableEventToPublicField(table, codegenClassScope, this.GetType());
     var refEPS = exprSymbol.GetAddEPS(codegenMethodScope);
     var refIsNewData = exprSymbol.GetAddIsNewData(codegenMethodScope);
     var refExprEvalCtx = exprSymbol.GetAddExprEvalCtx(codegenMethodScope);
     return StaticMethod(
         typeof(ExprDotForgeUnpackCollEventBeanTable),
         "ConvertToTableUnderling",
         inner,
         eventToPublic,
         refEPS,
         refIsNewData,
         refExprEvalCtx);
 }
Exemple #9
0
 public CodegenMethod ProcessCodegen(
     CodegenExpression resultEventType,
     CodegenExpression eventBeanFactory,
     CodegenMethodScope codegenMethodScope,
     SelectExprProcessorCodegenSymbol selectSymbol,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope)
 {
     CodegenExpressionInstanceField eventToPublic =
         TableDeployTimeResolver.MakeTableEventToPublicField(table, codegenClassScope, this.GetType());
     CodegenMethod methodNode = codegenMethodScope.MakeChild(
         typeof(EventBean),
         this.GetType(),
         codegenClassScope);
     CodegenExpressionRef refEPS = exprSymbol.GetAddEPS(methodNode);
     CodegenExpression refIsNewData = exprSymbol.GetAddIsNewData(methodNode);
     CodegenExpressionRef refExprEvalCtx = exprSymbol.GetAddExprEvalCtx(methodNode);
     methodNode.Block
         .DeclareVar<EventBean>("@event", ArrayAtIndex(refEPS, Constant(0)))
         .IfRefNullReturnNull("@event")
         .MethodReturn(
             ExprDotMethod(eventToPublic, "Convert", Ref("@event"), refEPS, refIsNewData, refExprEvalCtx));
     return methodNode;
 }
Exemple #10
0
        protected override CodegenExpression ProcessSpecificCodegen(
            CodegenExpression resultEventType,
            CodegenExpression eventBeanFactory,
            CodegenExpression props,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var methodNode = codegenMethodScope
                .MakeChild(typeof(EventBean), typeof(SelectEvalStreamWUnderlying), codegenClassScope)
                .AddParam(typeof(IDictionary<string, object>), "props");
            var wrapperUndType = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(EventType),
                EventTypeUtility.ResolveTypeCodegen(
                    wrapperEventType.UnderlyingEventType,
                    EPStatementInitServicesConstants.REF));

            var refEPS = exprSymbol.GetAddEPS(methodNode);
            var refIsNewData = exprSymbol.GetAddIsNewData(methodNode);
            var refExprEvalCtx = exprSymbol.GetAddExprEvalCtx(methodNode);

            var block = methodNode.Block;
            if (singleStreamWrapper) {
                block.DeclareVar<DecoratingEventBean>(
                        "wrapper",
                        Cast(typeof(DecoratingEventBean), ArrayAtIndex(refEPS, Constant(0))))
                    .IfRefNotNull("wrapper")
                    .ExprDotMethod(props, "PutAll", ExprDotName(Ref("wrapper"), "DecoratingProperties"))
                    .BlockEnd();
            }

            if (underlyingIsFragmentEvent) {
                var fragment = ((EventTypeSPI) eventTypes[underlyingStreamNumber])
                    .GetGetterSPI(unnamedStreams[0].StreamSelected.StreamName)
                    .EventBeanFragmentCodegen(
                        Ref("eventBean"),
                        methodNode,
                        codegenClassScope);
                block.DeclareVar<EventBean>("eventBean", ArrayAtIndex(refEPS, Constant(underlyingStreamNumber)))
                    .DeclareVar<EventBean>("theEvent", Cast(typeof(EventBean), fragment));
            }
            else if (underlyingPropertyEventGetter != null) {
                block.DeclareVar<EventBean>("theEvent", ConstantNull())
                    .DeclareVar<object>(
                        "value",
                        underlyingPropertyEventGetter.EventBeanGetCodegen(
                            ArrayAtIndex(refEPS, Constant(underlyingStreamNumber)),
                            methodNode,
                            codegenClassScope))
                    .IfRefNotNull("value")
                    .AssignRef(
                        "theEvent",
                        ExprDotMethod(eventBeanFactory, "AdapterForTypedObject", Ref("value"), wrapperUndType))
                    .BlockEnd();
            }
            else if (underlyingExprForge != null) {
                block.DeclareVar<EventBean>("theEvent", ConstantNull())
                    .DeclareVar<object>(
                        "value",
                        underlyingExprForge.EvaluateCodegen(typeof(object), methodNode, exprSymbol, codegenClassScope))
                    .IfRefNotNull("value")
                    .AssignRef(
                        "theEvent",
                        ExprDotMethod(eventBeanFactory, "AdapterForTypedObject", Ref("value"), wrapperUndType))
                    .BlockEnd();
            }
            else {
                block.DeclareVar<EventBean>("theEvent", ArrayAtIndex(refEPS, Constant(underlyingStreamNumber)));
                if (tableMetadata != null) {
                    var eventToPublic = TableDeployTimeResolver.MakeTableEventToPublicField(
                        tableMetadata,
                        codegenClassScope,
                        GetType());
                    block.IfRefNotNull("theEvent")
                        .AssignRef(
                            "theEvent",
                            ExprDotMethod(
                                eventToPublic,
                                "Convert",
                                Ref("theEvent"),
                                refEPS,
                                refIsNewData,
                                refExprEvalCtx))
                        .BlockEnd();
                }
            }

            block.MethodReturn(
                ExprDotMethod(
                    eventBeanFactory,
                    "AdapterForTypedWrapper",
                    Ref("theEvent"),
                    Ref("props"),
                    resultEventType));
            return LocalMethod(methodNode, props);
        }
Exemple #11
0
        public override CodegenMethod ProcessCodegen(
            CodegenExpression resultEventType,
            CodegenExpression eventBeanFactory,
            CodegenMethodScope codegenMethodScope,
            SelectExprProcessorCodegenSymbol selectSymbol,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var size = context.ExprForges.Length +
                       namedStreams.Count +
                       (isUsingWildcard && context.NumStreams > 1 ? context.NumStreams : 0);

            var methodNode = codegenMethodScope.MakeChild(typeof(EventBean), GetType(), codegenClassScope);
            var refEPS = exprSymbol.GetAddEPS(methodNode);
            var refIsNewData = exprSymbol.GetAddIsNewData(methodNode);
            var refExprEvalCtx = exprSymbol.GetAddExprEvalCtx(methodNode);

            var init = size == 0
                ? StaticMethod(typeof(Collections), "GetEmptyMap", new[] { typeof(string), typeof(object) })
                : NewInstance(typeof(HashMap<string, object>));
            var block = methodNode.Block
                .DeclareVar<IDictionary<string, object>>("props", init);
            var count = 0;
            foreach (var forge in context.ExprForges) {
                block.Expression(
                    ExprDotMethod(
                        Ref("props"),
                        "Put",
                        Constant(context.ColumnNames[count]),
                        CodegenLegoMayVoid.ExpressionMayVoid(
                            typeof(object),
                            forge,
                            methodNode,
                            exprSymbol,
                            codegenClassScope)));
                count++;
            }

            foreach (var element in namedStreams) {
                var theEvent = ArrayAtIndex(refEPS, Constant(element.StreamNumber));
                if (element.TableMetadata != null) {
                    var eventToPublic = TableDeployTimeResolver.MakeTableEventToPublicField(
                        element.TableMetadata,
                        codegenClassScope,
                        GetType());
                    theEvent = ExprDotMethod(eventToPublic, "Convert", theEvent, refEPS, refIsNewData, refExprEvalCtx);
                }

                block.Expression(ExprDotMethod(Ref("props"), "Put", Constant(context.ColumnNames[count]), theEvent));
                count++;
            }

            if (isUsingWildcard && context.NumStreams > 1) {
                for (var i = 0; i < context.NumStreams; i++) {
                    block.Expression(
                        ExprDotMethod(
                            Ref("props"),
                            "Put",
                            Constant(context.ColumnNames[count]),
                            ArrayAtIndex(refEPS, Constant(i))));
                    count++;
                }
            }

            block.MethodReturn(
                ProcessSpecificCodegen(
                    resultEventType,
                    eventBeanFactory,
                    Ref("props"),
                    methodNode,
                    exprSymbol,
                    codegenClassScope));
            return methodNode;
        }