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);
 }
示例#2
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);
        }