private static CodegenInnerClass MakeSelectExprProcessor( string className, string classNameParent, CodegenClassScope classScope, SelectExprProcessorForge forge) { var exprSymbol = new ExprForgeCodegenSymbol(true, null); var selectEnv = new SelectExprProcessorCodegenSymbol(); CodegenSymbolProvider symbolProvider = new ProxyCodegenSymbolProvider { ProcProvide = symbols => { exprSymbol.Provide(symbols); selectEnv.Provide(symbols); } }; IList<CodegenTypedParam> members = new List<CodegenTypedParam>(2); members.Add(new CodegenTypedParam(classScope.NamespaceScope.FieldsClassName, NAME_STATEMENT_FIELDS)); members.Add(new CodegenTypedParam(typeof(EventBeanTypedEventFactory), "factory")); IList<CodegenTypedParam> ctorParams = new List<CodegenTypedParam>(2); ctorParams.Add(new CodegenTypedParam(classNameParent, "o")); ctorParams.Add( new CodegenTypedParam( typeof(EPStatementInitServices), EPStatementInitServicesConstants.REF.Ref, false)); var ctor = new CodegenCtor(typeof(StmtClassForgableRSPFactoryProvider), classScope, ctorParams); ctor.Block.AssignRef( NAME_STATEMENT_FIELDS, ExprDotName(Ref("o"), NAME_STATEMENT_FIELDS)); ctor.Block.AssignRef( "factory", ExprDotName(EPStatementInitServicesConstants.REF, "EventBeanTypedEventFactory")); var processMethod = CodegenMethod.MakeMethod( typeof(EventBean), typeof(StmtClassForgableRSPFactoryProvider), symbolProvider, classScope) .AddParam(typeof(EventBean[]), NAME_EPS) .AddParam(typeof(bool), ExprForgeCodegenNames.NAME_ISNEWDATA) .AddParam(typeof(bool), SelectExprProcessorCodegenSymbol.NAME_ISSYNTHESIZE) .AddParam(typeof(ExprEvaluatorContext), NAME_EXPREVALCONTEXT); processMethod.Block.Apply( InstrumentationCode.Instblock( classScope, "qSelectClause", REF_EPS, ResultSetProcessorCodegenNames.REF_ISNEWDATA, REF_ISSYNTHESIZE, REF_EXPREVALCONTEXT)); var performMethod = forge.ProcessCodegen( Ref("o." + MEMBERNAME_RESULTEVENTTYPE), Ref("factory"), processMethod, selectEnv, exprSymbol, classScope); exprSymbol.DerivedSymbolsCodegen(processMethod, processMethod.Block, classScope); processMethod.Block .DeclareVar<EventBean>("@out", LocalMethod(performMethod)) .Apply( InstrumentationCode.Instblock( classScope, "aSelectClause", ResultSetProcessorCodegenNames.REF_ISNEWDATA, Ref("@out"), ConstantNull())) .MethodReturn(Ref("@out")); var allProperties = new CodegenClassProperties(); var allMethods = new CodegenClassMethods(); CodegenStackGenerator.RecursiveBuildStack( processMethod, "Process", allMethods, allProperties); return new CodegenInnerClass( className, typeof(SelectExprProcessor), ctor, members, allMethods, allProperties); }
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; }