public CodegenClass Forge(bool includeDebugSymbols) { Supplier<string> debugInformationProvider = () => { var writer = new StringWriter(); _raw.AppendCodeDebugInfo(writer); writer.Write(" output-processor "); writer.Write(_spec.GetType().FullName); return writer.ToString(); }; try { IList<CodegenInnerClass> innerClasses = new List<CodegenInnerClass>(); // build ctor IList<CodegenTypedParam> ctorParms = new List<CodegenTypedParam>(); ctorParms.Add( new CodegenTypedParam( typeof(EPStatementInitServices), EPStatementInitServicesConstants.REF.Ref, false)); ctorParms.Add( new CodegenTypedParam( _namespaceScope.FieldsClassName, null, "statementFields", true, false)); var providerCtor = new CodegenCtor( typeof(StmtClassForgableOPVFactoryProvider), ClassName, includeDebugSymbols, ctorParms); var classScope = new CodegenClassScope(includeDebugSymbols, _namespaceScope, ClassName); var providerExplicitMembers = new List<CodegenTypedParam>(); providerExplicitMembers.Add( new CodegenTypedParam(typeof(StatementResultService), MEMBERNAME_STATEMENTRESULTSVC)); providerExplicitMembers.Add( new CodegenTypedParam(typeof(OutputProcessViewFactory), MEMBERNAME_OPVFACTORY)); if (_spec.IsCodeGenerated) { // make factory and view both, assign to member MakeOPVFactory(classScope, innerClasses, providerExplicitMembers, providerCtor, ClassName); MakeOPV( classScope, innerClasses, Collections.GetEmptyList<CodegenTypedParam>(), providerCtor, ClassName, _spec, _numStreams); } else { // build factory from existing classes var symbols = new SAIFFInitializeSymbol(); var init = providerCtor .MakeChildWithScope(typeof(OutputProcessViewFactory), GetType(), symbols, classScope) .AddParam( typeof(EPStatementInitServices), EPStatementInitServicesConstants.REF.Ref); _spec.ProvideCodegen(init, symbols, classScope); providerCtor.Block.AssignRef( MEMBERNAME_OPVFACTORY, LocalMethod(init, EPStatementInitServicesConstants.REF)); } // make get-factory method var factoryMethodGetter = CodegenProperty.MakePropertyNode( typeof(OutputProcessViewFactory), GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope); factoryMethodGetter.GetterBlock.BlockReturn(Ref(MEMBERNAME_OPVFACTORY)); var properties = new CodegenClassProperties(); var methods = new CodegenClassMethods(); CodegenStackGenerator.RecursiveBuildStack( providerCtor, "ctor", methods, properties); CodegenStackGenerator.RecursiveBuildStack( factoryMethodGetter, "OutputProcessViewFactory", methods, properties); // render and compile return new CodegenClass( typeof(OutputProcessViewFactoryProvider), _namespaceScope.Namespace, ClassName, classScope, providerExplicitMembers, providerCtor, methods, properties, innerClasses); } catch (Exception t) { throw new EPException( "Fatal exception during code-generation for " + debugInformationProvider.Invoke() + " : " + t.Message, t); } }
public CodegenClass Forge(bool includeDebugSymbols) { Supplier<string> debugInformationProvider = () => { var writer = new StringWriter(); _statementRawInfo.AppendCodeDebugInfo(writer); writer.Write(" result-set-processor "); writer.Write(_spec.ResultSetProcessorFactoryForge.GetType().FullName); return writer.ToString(); }; try { IList<CodegenInnerClass> innerClasses = new List<CodegenInnerClass>(); // build ctor IList<CodegenTypedParam> ctorParms = new List<CodegenTypedParam>(); ctorParms.Add( new CodegenTypedParam( typeof(EPStatementInitServices), EPStatementInitServicesConstants.REF.Ref, false)); ctorParms.Add( new CodegenTypedParam( _namespaceScope.FieldsClassName, null, MEMBERNAME_STATEMENT_FIELDS, true, false)); var providerCtor = new CodegenCtor( typeof(StmtClassForgableRSPFactoryProvider), ClassName, includeDebugSymbols, ctorParms); var classScope = new CodegenClassScope(includeDebugSymbols, _namespaceScope, ClassName); var providerExplicitMembers = new List<CodegenTypedParam>(2); // add event type providerExplicitMembers.Add(new CodegenTypedParam(typeof(EventType), MEMBERNAME_RESULTEVENTTYPE)); providerCtor.Block.AssignRef( MEMBERNAME_RESULTEVENTTYPE, EventTypeUtility.ResolveTypeCodegen(_spec.ResultEventType, EPStatementInitServicesConstants.REF)); MakeResultSetProcessorFactory( classScope, innerClasses, providerExplicitMembers, providerCtor, ClassName); MakeResultSetProcessor( classScope, innerClasses, providerExplicitMembers, providerCtor, ClassName, _spec); OrderByProcessorCompiler.MakeOrderByProcessors( _spec.OrderByProcessorFactoryForge, classScope, innerClasses, providerExplicitMembers, providerCtor, ClassName, MEMBERNAME_ORDERBYFACTORY); providerExplicitMembers.Add( new CodegenTypedParam(typeof(AggregationServiceFactory), MEMBERNAME_AGGREGATIONSVCFACTORY)); var aggregationClassNames = new AggregationClassNames(); var aggResult = AggregationServiceFactoryCompiler.MakeInnerClassesAndInit( _spec.IsJoin, _spec.AggregationServiceForgeDesc.AggregationServiceFactoryForge, providerCtor, classScope, ClassName, aggregationClassNames); providerCtor.Block.AssignRef( MEMBERNAME_AGGREGATIONSVCFACTORY, LocalMethod(aggResult.InitMethod, EPStatementInitServicesConstants.REF)); innerClasses.AddAll(aggResult.InnerClasses); MakeSelectExprProcessors( classScope, innerClasses, providerExplicitMembers, providerCtor, ClassName, _spec.IsRollup, _spec.SelectExprProcessorForges); // make provider methods var propResultSetProcessorFactoryMethod = CodegenProperty.MakePropertyNode( typeof(ResultSetProcessorFactory), GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope); propResultSetProcessorFactoryMethod .GetterBlock .BlockReturn(Ref(MEMBERNAME_RESULTSETPROCESSORFACTORY)); var propAggregationServiceFactoryMethod = CodegenProperty.MakePropertyNode( typeof(AggregationServiceFactory), GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope); propAggregationServiceFactoryMethod .GetterBlock .BlockReturn(Ref(MEMBERNAME_AGGREGATIONSVCFACTORY)); var propOrderByProcessorFactoryMethod = CodegenProperty.MakePropertyNode( typeof(OrderByProcessorFactory), GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope); propOrderByProcessorFactoryMethod .GetterBlock .BlockReturn(Ref(MEMBERNAME_ORDERBYFACTORY)); var propResultSetProcessorTypeMethod = CodegenProperty.MakePropertyNode( typeof(ResultSetProcessorType), GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope); propResultSetProcessorTypeMethod .GetterBlock .BlockReturn(EnumValue(typeof(ResultSetProcessorType), _spec.ResultSetProcessorType.GetName())); var propResultEventTypeMethod = CodegenProperty.MakePropertyNode( typeof(EventType), GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope); propResultEventTypeMethod .GetterBlock .BlockReturn(Ref(MEMBERNAME_RESULTEVENTTYPE)); var properties = new CodegenClassProperties(); var methods = new CodegenClassMethods(); CodegenStackGenerator.RecursiveBuildStack(providerCtor, "ctor", methods, properties); CodegenStackGenerator.RecursiveBuildStack( propResultSetProcessorFactoryMethod, "ResultSetProcessorFactory", methods, properties); CodegenStackGenerator.RecursiveBuildStack( propAggregationServiceFactoryMethod, "AggregationServiceFactory", methods, properties); CodegenStackGenerator.RecursiveBuildStack( propOrderByProcessorFactoryMethod, "OrderByProcessorFactory", methods, properties); CodegenStackGenerator.RecursiveBuildStack( propResultSetProcessorTypeMethod, "ResultSetProcessorType", methods, properties); CodegenStackGenerator.RecursiveBuildStack( propResultEventTypeMethod, "ResultEventType", methods, properties); // render and compile return new CodegenClass( typeof(ResultSetProcessorFactoryProvider), _namespaceScope.Namespace, ClassName, classScope, providerExplicitMembers, providerCtor, methods, properties, innerClasses); } catch (Exception t) { throw new EPException( "Fatal exception during code-generation for " + debugInformationProvider.Invoke() + " : " + t.Message, t); } }