Esempio n. 1
0
            public override CodegenMethod ProcessCodegen(
                CodegenExpression resultEventType,
                CodegenExpression eventBeanFactory,
                CodegenMethodScope codegenMethodScope,
                SelectExprProcessorCodegenSymbol selectSymbol,
                ExprForgeCodegenSymbol exprSymbol,
                CodegenClassScope codegenClassScope)
            {
                var methodNode = codegenMethodScope.MakeChild(typeof(EventBean), GetType(), codegenClassScope);
                var expr       = exprForge.EvaluateCodegen(
                    typeof(IDictionary <string, object>),
                    methodNode,
                    exprSymbol,
                    codegenClassScope);

                if (!TypeHelper.IsSubclassOrImplementsInterface(
                        exprForge.EvaluationType,
                        typeof(IDictionary <string, object>)))
                {
                    expr = CodegenExpressionBuilder.Cast(typeof(IDictionary <string, object>), expr);
                }

                methodNode.Block.DeclareVar <IDictionary <string, object> >("result", expr)
                .IfRefNullReturnNull("result")
                .MethodReturn(
                    CodegenExpressionBuilder.ExprDotMethod(
                        eventBeanFactory,
                        "AdapterForTypedMap",
                        CodegenExpressionBuilder.Ref("result"),
                        resultEventType));
                return(methodNode);
            }
        public CodegenMethod ProcessCodegen(
            CodegenExpression resultEventType,
            CodegenExpression eventBeanFactory,
            CodegenMethodScope codegenMethodScope,
            SelectExprProcessorCodegenSymbol selectSymbol,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var processMethod = codegenMethodScope.MakeChild(typeof(EventBean), this.GetType(), codegenClassScope);

            var isSythesize     = selectSymbol.GetAddSynthesize(processMethod);
            var syntheticMethod = syntheticProcessorForge.ProcessCodegen(
                resultEventType,
                eventBeanFactory,
                processMethod,
                selectSymbol,
                exprSymbol,
                codegenClassScope);

            var stmtResultSvc = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(StatementResultService),
                ExprDotName(EPStatementInitServicesConstants.REF, EPStatementInitServicesConstants.STATEMENTRESULTSERVICE));

            processMethod.Block
            .IfCondition(Or(isSythesize, ExprDotName(stmtResultSvc, "IsMakeSynthetic")))
            .BlockReturn(LocalMethod(syntheticMethod))
            .MethodReturn(ConstantNull());

            return(processMethod);
        }
 public abstract CodegenMethod ProcessCodegen(
     CodegenExpression resultEventType,
     CodegenExpression eventBeanFactory,
     CodegenMethodScope codegenMethodScope,
     SelectExprProcessorCodegenSymbol selectSymbol,
     ExprForgeCodegenSymbol exprSymbol,
     CodegenClassScope codegenClassScope);
            public override CodegenMethod ProcessCodegen(
                CodegenExpression resultEventType,
                CodegenExpression eventBeanFactory,
                CodegenMethodScope codegenMethodScope,
                SelectExprProcessorCodegenSymbol selectSymbol,
                ExprForgeCodegenSymbol exprSymbol,
                CodegenClassScope codegenClassScope)
            {
                CodegenMethod methodNode = codegenMethodScope
                                           .MakeChild(typeof(EventBean), GetType(), codegenClassScope);

                methodNode
                .Block
                .DeclareVar <string>("result", exprForge.EvaluateCodegen(typeof(string), methodNode, exprSymbol, codegenClassScope))
                .IfRefNullReturnNull("result")
                .DeclareVar <object>("und", ExprDotMethod(Cast(typeof(JsonEventType), resultEventType), "Parse", Ref("result")))
                .MethodReturn(ExprDotMethod(eventBeanFactory, "AdapterForTypedJson", Ref("und"), resultEventType));
                return(methodNode);
            }
Esempio n. 5
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 manufacturer = codegenClassScope.AddDefaultFieldUnshared(
                    true,
                    typeof(EventBeanManufacturer),
                    eventManufacturer.Make(methodNode.Block, codegenMethodScope, codegenClassScope));

                methodNode.Block.MethodReturn(
                    CodegenExpressionBuilder.ExprDotMethod(
                        manufacturer,
                        "Make",
                        CodegenExpressionBuilder.PublicConstValue(typeof(CollectionUtil), "OBJECTARRAY_EMPTY")));
                return(methodNode);
            }
            public override CodegenMethod ProcessCodegen(
                CodegenExpression resultEventType,
                CodegenExpression eventBeanFactory,
                CodegenMethodScope codegenMethodScope,
                SelectExprProcessorCodegenSymbol selectSymbol,
                ExprForgeCodegenSymbol exprSymbol,
                CodegenClassScope codegenClassScope)
            {
                var methodNode   = codegenMethodScope.MakeChild(typeof(EventBean), GetType(), codegenClassScope);
                var manufacturer = codegenClassScope.AddDefaultFieldUnshared(
                    true,
                    typeof(EventBeanManufacturer),
                    eventManufacturer.Make(methodNode.Block, codegenMethodScope, codegenClassScope));
                var block = methodNode.Block
                            .DeclareVar <object[]>(
                    "values",
                    CodegenExpressionBuilder.NewArrayByLength(
                        typeof(object),
                        CodegenExpressionBuilder.Constant(exprForges.Length)));

                for (var i = 0; i < exprForges.Length; i++)
                {
                    var expression = CodegenLegoMayVoid.ExpressionMayVoid(
                        typeof(object),
                        exprForges[i],
                        methodNode,
                        exprSymbol,
                        codegenClassScope);
                    block.AssignArrayElement("values", CodegenExpressionBuilder.Constant(i), expression);
                }

                block.MethodReturn(
                    CodegenExpressionBuilder.ExprDotMethod(
                        manufacturer,
                        "Make",
                        CodegenExpressionBuilder.Ref("values")));
                return(methodNode);
            }
            public override CodegenMethod ProcessCodegen(
                CodegenExpression resultEventType,
                CodegenExpression eventBeanFactory,
                CodegenMethodScope codegenMethodScope,
                SelectExprProcessorCodegenSymbol selectSymbol,
                ExprForgeCodegenSymbol exprSymbol,
                CodegenClassScope codegenClassScope)
            {
                var methodNode = codegenMethodScope.MakeChild(typeof(EventBean), GetType(), codegenClassScope);

                methodNode.Block
                .DeclareVar <object>(
                    "result",
                    exprForge.EvaluateCodegen(typeof(object), methodNode, exprSymbol, codegenClassScope))
                .IfRefNullReturnNull("result")
                .MethodReturn(
                    CodegenExpressionBuilder.ExprDotMethod(
                        eventBeanFactory,
                        "AdapterForTypedObject",
                        CodegenExpressionBuilder.Ref("result"),
                        resultEventType));
                return(methodNode);
            }
Esempio n. 8
0
        public static CodegenExpression MakeAnonymous(
            SelectExprProcessorForge insertHelper,
            CodegenMethod method,
            CodegenExpressionRef initSvc,
            CodegenClassScope classScope)
        {
            var resultType = classScope.AddDefaultFieldUnshared(
                true,
                typeof(EventType),
                EventTypeUtility.ResolveTypeCodegen(insertHelper.ResultEventType, initSvc));
            var eventBeanFactory = classScope.AddOrGetDefaultFieldSharable(EventBeanTypedEventFactoryCodegenField.INSTANCE);

            var exprSymbol = new ExprForgeCodegenSymbol(true, true);
            var selectEnv = new SelectExprProcessorCodegenSymbol();
            CodegenSymbolProvider symbolProvider = new ProxyCodegenSymbolProvider {
                ProcProvide = symbols => {
                    exprSymbol.Provide(symbols);
                    selectEnv.Provide(symbols);
                }
            };

            var processMethod = method
                .MakeChildWithScope(typeof(EventBean), typeof(SelectExprProcessorUtil), symbolProvider, classScope)
                .AddParam(typeof(EventBean[]), NAME_EPS)
                .AddParam(typeof(bool), ExprForgeCodegenNames.NAME_ISNEWDATA)
                .AddParam(typeof(bool), SelectExprProcessorCodegenSymbol.NAME_ISSYNTHESIZE)
                .AddParam(typeof(ExprEvaluatorContext), NAME_EXPREVALCONTEXT);
            
            //var anonymousSelect = NewAnonymousClass(method.Block, typeof(ProxySelectExprProcessor));
            //var processMethod = CodegenMethod.MakeMethod(
            //        typeof(EventBean),
            //        typeof(SelectExprProcessorUtil),
            //        symbolProvider,
            //        classScope)
            //    .AddParam(typeof(EventBean[]), NAME_EPS)
            //    .AddParam(typeof(bool), ExprForgeCodegenNames.NAME_ISNEWDATA)
            //    .AddParam(typeof(bool), SelectExprProcessorCodegenSymbol.NAME_ISSYNTHESIZE)
            //    .AddParam(typeof(ExprEvaluatorContext), NAME_EXPREVALCONTEXT);
            //anonymousSelect.AddMethod("Process", processMethod);

            processMethod.Block.Apply(
                Instblock(
                    classScope,
                    "qSelectClause",
                    REF_EPS,
                    ResultSetProcessorCodegenNames.REF_ISNEWDATA,
                    REF_ISSYNTHESIZE,
                    REF_EXPREVALCONTEXT));

            var performMethod = insertHelper.ProcessCodegen(
                resultType,
                eventBeanFactory,
                processMethod,
                selectEnv,
                exprSymbol,
                classScope);

            exprSymbol.DerivedSymbolsCodegen(method, processMethod.Block, classScope);
            //exprSymbol.DerivedSymbolsCodegen(processMethod, processMethod.Block, classScope);
            processMethod.Block
                .DeclareVar<EventBean>("result", LocalMethod(performMethod))
                .Apply(
                    Instblock(
                        classScope,
                        "aSelectClause",
                        ResultSetProcessorCodegenNames.REF_ISNEWDATA,
                        Ref("result"),
                        ConstantNull()))
                .MethodReturn(Ref("result"));

            var processLambda = new CodegenExpressionLambda(method.Block)
                .WithParam(typeof(EventBean[]), NAME_EPS)
                .WithParam(typeof(bool), ExprForgeCodegenNames.NAME_ISNEWDATA)
                .WithParam(typeof(bool), SelectExprProcessorCodegenSymbol.NAME_ISSYNTHESIZE)
                .WithParam(typeof(ExprEvaluatorContext), NAME_EXPREVALCONTEXT)
                .WithBody(
                    block => {
                        block.DebugStack();
                        block.BlockReturn(
                            LocalMethod(
                                processMethod,
                                ExprForgeCodegenNames.REF_EPS,
                                ExprForgeCodegenNames.REF_ISNEWDATA,
                                SelectExprProcessorCodegenSymbol.REF_ISSYNTHESIZE,
                                ExprForgeCodegenNames.REF_EXPREVALCONTEXT));
                    });

            var anonymousSelect = NewInstance<ProxySelectExprProcessor>(processLambda);
            return anonymousSelect;
        }
            public override CodegenMethod ProcessCodegen(
                CodegenExpression resultEventType,
                CodegenExpression eventBeanFactory,
                CodegenMethodScope codegenMethodScope,
                SelectExprProcessorCodegenSymbol selectSymbol,
                ExprForgeCodegenSymbol exprSymbol,
                CodegenClassScope codegenClassScope)
            {
                var methodNode   = codegenMethodScope.MakeChild(typeof(EventBean), GetType(), codegenClassScope);
                var manufacturer = codegenClassScope.AddDefaultFieldUnshared(
                    true,
                    typeof(EventBeanManufacturer),
                    eventManufacturer.Make(methodNode.Block, codegenMethodScope, codegenClassScope));
                var block = methodNode.Block
                            .DeclareVar <object[]>(
                    "values",
                    CodegenExpressionBuilder.NewArrayByLength(
                        typeof(object),
                        CodegenExpressionBuilder.Constant(exprForges.Length)));

                for (var i = 0; i < exprForges.Length; i++)
                {
                    var expression = CodegenLegoMayVoid.ExpressionMayVoid(
                        exprForges[i].EvaluationType,
                        exprForges[i],
                        methodNode,
                        exprSymbol,
                        codegenClassScope);
                    if (wideners[i] == null)
                    {
                        block.AssignArrayElement("values", CodegenExpressionBuilder.Constant(i), expression);
                    }
                    else
                    {
                        var refname = "evalResult" + i;
                        block.DeclareVar(exprForges[i].EvaluationType, refname, expression);
                        if (exprForges[i].EvaluationType.CanBeNull())
                        {
                            block.IfRefNotNull(refname)
                            .AssignArrayElement(
                                "values",
                                CodegenExpressionBuilder.Constant(i),
                                wideners[i]
                                .WidenCodegen(
                                    CodegenExpressionBuilder.Ref(refname),
                                    methodNode,
                                    codegenClassScope))
                            .BlockEnd();
                        }
                        else
                        {
                            block.AssignArrayElement(
                                "values",
                                CodegenExpressionBuilder.Constant(i),
                                wideners[i]
                                .WidenCodegen(
                                    CodegenExpressionBuilder.Ref(refname),
                                    methodNode,
                                    codegenClassScope));
                        }
                    }
                }

                block.MethodReturn(
                    CodegenExpressionBuilder.ExprDotMethod(
                        manufacturer,
                        "Make",
                        CodegenExpressionBuilder.Ref("values")));
                return(methodNode);
            }