public CodegenClass Forge(
            bool includeDebugSymbols,
            bool fireAndForget)
        {
            var properties = new CodegenClassProperties();
            var methods    = new CodegenClassMethods();
            var classScope = new CodegenClassScope(includeDebugSymbols, _namespaceScope, _className);

            // --------------------------------------------------------------------------------
            // void Serialize(JsonSerializationContext context, object underlying)
            // --------------------------------------------------------------------------------

            var serializeMethod = CodegenMethod
                                  .MakeParentNode(typeof(void), this.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                                  .AddParam(typeof(JsonSerializationContext), "context")
                                  .AddParam(typeof(object), "underlying");

            MakeSerialize(serializeMethod, classScope);
            CodegenStackGenerator.RecursiveBuildStack(serializeMethod, "Serialize", methods, properties);

            var clazz = new CodegenClass(
                _classType,
                _className,
                classScope,
                EmptyList <CodegenTypedParam> .Instance,
                null,
                methods,
                properties,
                EmptyList <CodegenInnerClass> .Instance);

            clazz.BaseList.AssignType(typeof(IJsonSerializer));
            return(clazz);
        }
        public override void Render(
            StringBuilder builder,
            bool isInnerClass,
            int level,
            CodegenIndent indent)
        {
            builder.Append("new ");
            AppendClassName(builder, interfaceOrSuperClass);
            builder.Append("(");
            RenderExpressions(builder, ctorParams.ToArray(), isInnerClass);
            builder.Append(") {\n");

            var methods = new CodegenClassMethods();
            var properties = new CodegenClassProperties();
            foreach (var pair in this.methods) {
                CodegenStackGenerator.RecursiveBuildStack(
                    pair.Second,
                    pair.First,
                    methods,
                    properties);
            }

            // public properties
            var delimiter = "";
            foreach (var publicMethod in properties.PublicProperties)
            {
                builder.Append(delimiter);
                publicMethod.Render(builder, true, isInnerClass, indent, level + 1);
                delimiter = "\n";
            }

            // private properties
            delimiter = "";
            foreach (var method in properties.PrivateProperties)
            {
                builder.Append(delimiter);
                method.Render(builder, false, isInnerClass, indent, level + 1);
                delimiter = "\n";
            }

            // public methods
            delimiter = "";
            foreach (var publicMethod in methods.PublicMethods) {
                builder.Append(delimiter);
                publicMethod.Render(builder, true, isInnerClass, indent, level + 1);
                delimiter = "\n";
            }

            // private methods
            delimiter = "";
            foreach (var method in methods.PrivateMethods) {
                builder.Append(delimiter);
                method.Render(builder, false, isInnerClass, indent, level + 1);
                delimiter = "\n";
            }

            indent.Indent(builder, level);
            builder.Append("}");
        }
Ejemplo n.º 3
0
        public CodegenClass Forge(bool includeDebugSymbols, bool fireAndForget)
        {
            var properties = new CodegenClassProperties();
            var methods    = new CodegenClassMethods();
            var classScope = new CodegenClassScope(includeDebugSymbols, namespaceScope, className);

            var writeMethod = CodegenMethod
                              .MakeParentNode(typeof(void), typeof(StmtClassForgeableBaseNestableEventTypeSerde), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                              .AddParam(typeof(object), OBJECT_NAME)
                              .AddParam(typeof(DataOutput), OUTPUT_NAME)
                              .AddParam(typeof(byte[]), UNITKEY_NAME)
                              .AddParam(typeof(EventBeanCollatedWriter), WRITER_NAME)
                              .AddThrown(typeof(IOException));

            MakeWriteMethod(writeMethod);
            CodegenStackGenerator.RecursiveBuildStack(writeMethod, "Write", methods, properties);

            var readMethod = CodegenMethod.MakeParentNode(typeof(object), typeof(StmtClassForgeableBaseNestableEventTypeSerde), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                             .AddParam(typeof(DataInput), INPUT_NAME)
                             .AddParam(typeof(byte[]), UNITKEY_NAME)
                             .AddThrown(typeof(IOException));

            MakeReadMethod(readMethod);
            CodegenStackGenerator.RecursiveBuildStack(readMethod, "Read", methods, properties);

            IList <CodegenTypedParam> members = new List <CodegenTypedParam>();

            for (var i = 0; i < forges.Length; i++)
            {
                members.Add(new CodegenTypedParam(forges[i].ForgeClassName(), "s" + i));
            }

            var ctorParams = Collections.SingletonList(
                new CodegenTypedParam(typeof(EventTypeResolver), "resolver", false));
            var providerCtor = new CodegenCtor(this.GetType(), ClassName, includeDebugSymbols, ctorParams);

            for (var i = 0; i < forges.Length; i++)
            {
                providerCtor.Block.AssignRef("s" + i, forges[i].Codegen(providerCtor, classScope, Ref("resolver")));
            }

            return(new CodegenClass(
                       CodegenClassType.EVENTSERDE,
                       typeof(DataInputOutputSerde),
                       className,
                       classScope,
                       members,
                       providerCtor,
                       methods,
                       properties,
                       EmptyList <CodegenInnerClass> .Instance));
        }
Ejemplo n.º 4
0
        private static void MakeFactory(
            OrderByProcessorFactoryForge forge,
            CodegenClassScope classScope,
            IList<CodegenInnerClass> innerClasses,
            string providerClassName)
        {
            var instantiateMethod = CodegenMethod
                .MakeMethod(
                    typeof(OrderByProcessor),
                    typeof(OrderByProcessorCompiler),
                    CodegenSymbolProviderEmpty.INSTANCE,
                    classScope)
                .AddParam(typeof(AgentInstanceContext), MEMBER_AGENTINSTANCECONTEXT.Ref);
            forge.InstantiateCodegen(instantiateMethod, classScope);
            
            var ctorParams = Collections.SingletonList(new CodegenTypedParam(providerClassName, "o"));
            var ctor = new CodegenCtor(typeof(OrderByProcessorCompiler), classScope, ctorParams);

            var methods = new CodegenClassMethods();
            var properties = new CodegenClassProperties();
            
            // --------------------------------------------------------------------------------
            // Add statementFields
            // --------------------------------------------------------------------------------

            var members = new List<CodegenTypedParam> {
                new CodegenTypedParam(
                    classScope.NamespaceScope.FieldsClassName,
                    null,
                    "statementFields",
                    false,
                    false)
            };
            
            ctor.Block.AssignRef(
                Ref("this.statementFields"),
                Ref("o.statementFields"));

            // --------------------------------------------------------------------------------

            CodegenStackGenerator.RecursiveBuildStack(instantiateMethod, "Instantiate", methods, properties);
            var innerClass = new CodegenInnerClass(
                CLASSNAME_ORDERBYPROCESSORFACTORY,
                typeof(OrderByProcessorFactory),
                ctor,
                members,
                methods,
                properties);
            innerClasses.Add(innerClass);
        }
Ejemplo n.º 5
0
        private static void MakeResultSetProcessorFactory(
            CodegenClassScope classScope,
            IList<CodegenInnerClass> innerClasses,
            IList<CodegenTypedParam> providerExplicitMembers,
            CodegenCtor providerCtor,
            string providerClassName)
        {
            var instantiateMethod = CodegenMethod.MakeMethod(
                    typeof(ResultSetProcessor),
                    typeof(StmtClassForgableRSPFactoryProvider),
                    CodegenSymbolProviderEmpty.INSTANCE,
                    classScope)
                .AddParam(typeof(OrderByProcessor), NAME_ORDERBYPROCESSOR)
                .AddParam(typeof(AggregationService), NAME_AGGREGATIONSVC)
                .AddParam(typeof(AgentInstanceContext), NAME_AGENTINSTANCECONTEXT);
            instantiateMethod.Block.MethodReturn(
                NewInstance(
                    CLASSNAME_RESULTSETPROCESSOR,
                    Ref("o"),
                    REF_ORDERBYPROCESSOR,
                    REF_AGGREGATIONSVC,
                    REF_AGENTINSTANCECONTEXT));

            var properties = new CodegenClassProperties();
            var methods = new CodegenClassMethods();
            CodegenStackGenerator.RecursiveBuildStack(instantiateMethod, "Instantiate", methods, properties);

            var ctorParams = Collections.SingletonList(new CodegenTypedParam(providerClassName, "o"));
            var ctor = new CodegenCtor(
                typeof(StmtClassForgableRSPFactoryProvider), 
                classScope,
                ctorParams);

            var innerClass = new CodegenInnerClass(
                CLASSNAME_RESULTSETPROCESSORFACTORY,
                typeof(ResultSetProcessorFactory),
                ctor,
                Collections.GetEmptyList<CodegenTypedParam>(),
                methods,
                properties);
            innerClasses.Add(innerClass);

            providerExplicitMembers.Add(new CodegenTypedParam(typeof(ResultSetProcessorFactory), "rspFactory"));
            providerCtor.Block.AssignRef(
                MEMBERNAME_RESULTSETPROCESSORFACTORY,
                NewInstance(CLASSNAME_RESULTSETPROCESSORFACTORY, Ref("this")));
        }
Ejemplo n.º 6
0
        private static void MakeOPVFactory(
            CodegenClassScope classScope,
            ICollection<CodegenInnerClass> innerClasses,
            ICollection<CodegenTypedParam> providerExplicitMembers,
            CodegenCtor providerCtor,
            string providerClassName)
        {
            var makeViewMethod = CodegenMethod.MakeMethod(
                    typeof(OutputProcessView),
                    typeof(StmtClassForgableOPVFactoryProvider),
                    CodegenSymbolProviderEmpty.INSTANCE,
                    classScope)
                .AddParam(typeof(ResultSetProcessor), NAME_RESULTSETPROCESSOR)
                .AddParam(typeof(AgentInstanceContext), NAME_AGENTINSTANCECONTEXT);
            makeViewMethod.Block.MethodReturn(
                NewInstance(CLASSNAME_OUTPUTPROCESSVIEW, Ref("o"), REF_RESULTSETPROCESSOR, REF_AGENTINSTANCECONTEXT));
            var methods = new CodegenClassMethods();
            var properties = new CodegenClassProperties();

            CodegenStackGenerator.RecursiveBuildStack(makeViewMethod, "MakeView", methods, properties);

            var ctorParams = Collections.SingletonList(new CodegenTypedParam(providerClassName, "o"));
            var ctor = new CodegenCtor(typeof(StmtClassForgableOPVFactoryProvider), classScope, ctorParams);

            var innerClass = new CodegenInnerClass(
                CLASSNAME_OUTPUTPROCESSVIEWFACTORY,
                typeof(OutputProcessViewFactory),
                ctor,
                Collections.GetEmptyList<CodegenTypedParam>(),
                methods,
                properties);
            innerClasses.Add(innerClass);

            providerCtor.Block.AssignRef(
                    MEMBERNAME_OPVFACTORY,
                    NewInstance(CLASSNAME_OUTPUTPROCESSVIEWFACTORY, Ref("this")))
                .AssignRef(
                    MEMBERNAME_STATEMENTRESULTSVC,
                    ExprDotName(
                        EPStatementInitServicesConstants.REF,
                        EPStatementInitServicesConstants.STATEMENTRESULTSERVICE));
        }
Ejemplo n.º 7
0
        public CodegenClass Forge(
            bool includeDebugSymbols,
            bool fireAndForget)
        {
            IList <CodegenTypedParam> @params = new List <CodegenTypedParam>();

            for (var i = 0; i < _types.Length; i++)
            {
                @params.Add(new CodegenTypedParam(_types[i].GetBoxedType(), "k" + i));
            }

            var ctor = new CodegenCtor(typeof(StmtClassForgeableMultiKey), ClassName, includeDebugSymbols, @params);

            var properties = new CodegenClassProperties();
            var methods    = new CodegenClassMethods();
            var classScope = new CodegenClassScope(includeDebugSymbols, _namespaceScope, _className);

            var hashMethod = CodegenMethod
                             .MakeParentNode(typeof(int), typeof(StmtClassForgeableMultiKey), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                             .WithOverride();

            MakeHashMethod(_types.Length, hashMethod);
            CodegenStackGenerator.RecursiveBuildStack(hashMethod, "GetHashCode", methods, properties);

            var equalsMethod = CodegenMethod
                               .MakeParentNode(typeof(bool), typeof(StmtClassForgeableMultiKey), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                               .WithOverride()
                               .AddParam(typeof(object), "o");

            MakeEqualsMethod(_types.Length, equalsMethod);
            CodegenStackGenerator.RecursiveBuildStack(equalsMethod, "Equals", methods, properties);

            var numKeysProperty = CodegenProperty
                                  .MakePropertyNode(typeof(int), typeof(StmtClassForgeableMultiKey), CodegenSymbolProviderEmpty.INSTANCE, classScope);

            numKeysProperty.GetterBlock.BlockReturn(Constant(_types.Length));
            CodegenStackGenerator.RecursiveBuildStack(numKeysProperty, "NumKeys", methods, properties);

            var getKeyMethod = CodegenMethod
                               .MakeParentNode(typeof(object), typeof(StmtClassForgeableMultiKey), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                               .AddParam(typeof(int), "num");

            MakeGetKeyMethod(_types.Length, getKeyMethod);
            CodegenStackGenerator.RecursiveBuildStack(getKeyMethod, "GetKey", methods, properties);

            var toStringMethod = CodegenMethod
                                 .MakeParentNode(typeof(string), typeof(StmtClassForgeableMultiKey), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                                 .WithOverride();

            MakeToStringMethod(toStringMethod);
            CodegenStackGenerator.RecursiveBuildStack(toStringMethod, "ToString", methods, properties);

            return(new CodegenClass(
                       CodegenClassType.KEYPROVISIONING,
                       typeof(MultiKey),
                       _className,
                       classScope,
                       EmptyList <CodegenTypedParam> .Instance,
                       ctor,
                       methods,
                       properties,
                       EmptyList <CodegenInnerClass> .Instance));
        }
Ejemplo n.º 8
0
        public CodegenClass Forge(bool includeDebugSymbols)
        {
            var classScope = new CodegenClassScope(includeDebugSymbols, _namespaceScope, _className);

            // REGION: Constructor
            var ctorParams = new List<CodegenTypedParam>() {
                new CodegenTypedParam(
                    typeof(EPStatementInitServices),
                    EPStatementInitServicesConstants.REF.Ref,
                    false)
            };

            if (_namespaceScope.FieldsClassName != null) {
                ctorParams.Add(
                    new CodegenTypedParam(
                        _namespaceScope.FieldsClassName,
                        MEMBERNAME_STATEMENT_FIELDS));
            }

            var ctor = new CodegenCtor(GetType(), _className, includeDebugSymbols, ctorParams);

            ctor.Block.AssignRef(
                MEMBERNAME_ID,
                StaticMethod(typeof(Guid), "NewGuid"));

            if (_namespaceScope.FieldsClassName != null) {
                ctor.Block.ExprDotMethod(
                    Ref(MEMBERNAME_STATEMENT_FIELDS),
                    "Init",
                    EPStatementInitServicesConstants.REF);
            }

            ctor.Block.AssignRef(
                MEMBERNAME_STATEMENTAIFACTORY,
                LocalMethod(
                    CodegenConstructorInit(ctor, classScope),
                    SAIFFInitializeSymbol.REF_STMTINITSVC));

            // REGION: Members
            var members = new List<CodegenTypedParam>();
            members.Add(new CodegenTypedParam(typeof(Guid), MEMBERNAME_ID));
            members.Add(new CodegenTypedParam(TypeOfFactory(), MEMBERNAME_STATEMENTAIFACTORY));

            // REGION: Properties
            var properties = new CodegenClassProperties();
            var factoryProp = CodegenProperty.MakePropertyNode(
                typeof(StatementAgentInstanceFactory),
                GetType(),
                CodegenSymbolProviderEmpty.INSTANCE,
                classScope);
            factoryProp.GetterBlock.BlockReturn(Ref(MEMBERNAME_STATEMENTAIFACTORY));

            // REGION: Methods
            var methods = new CodegenClassMethods();

            var assignMethod = CodegenMethod
                .MakeMethod(typeof(void), GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                .AddParam(typeof(StatementAIFactoryAssignments), "assignments");
            if (_namespaceScope.FieldsClassName != null) {
                assignMethod.Block.ExprDotMethod(Ref(MEMBERNAME_STATEMENT_FIELDS), "Assign", Ref("assignments"));
                //assignMethod.Block.StaticMethod(_namespaceScope.FieldsClassNameOptional, "Assign", @Ref("assignments"));
            }

            var unassignMethod = CodegenMethod
                .MakeMethod(typeof(void), GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope);
            if (_namespaceScope.FieldsClassName != null) {
                unassignMethod.Block.ExprDotMethod(Ref(MEMBERNAME_STATEMENT_FIELDS), "Unassign");
                //unassignMethod.Block.StaticMethod(_namespaceScope.FieldsClassNameOptional, "Unassign");
            }

            var setValueMethod = CodegenMethod
                .MakeMethod(typeof(void), typeof(StmtClassForgableStmtFields), classScope)
                .AddParam(typeof(int), "index")
                .AddParam(typeof(object), "value");
            CodegenSubstitutionParamEntry.CodegenSetterBody(
                classScope, setValueMethod.Block, Ref(MEMBERNAME_STATEMENT_FIELDS));

            // Assignment, not sure why this is being done... TBD - Burn this

            CodegenStackGenerator.RecursiveBuildStack(factoryProp, "Factory", methods, properties);
            CodegenStackGenerator.RecursiveBuildStack(assignMethod, "Assign", methods, properties);
            CodegenStackGenerator.RecursiveBuildStack(unassignMethod, "Unassign", methods, properties);
            CodegenStackGenerator.RecursiveBuildStack(setValueMethod, "SetValue", methods, properties);
            CodegenStackGenerator.RecursiveBuildStack(ctor, "Ctor", methods, properties);

            return new CodegenClass(
                typeof(StatementAIFactoryProvider),
                _namespaceScope.Namespace,
                _className,
                classScope,
                members,
                ctor,
                methods,
                properties,
                new EmptyList<CodegenInnerClass>());
        }
Ejemplo n.º 9
0
        public CodegenClass Forge(bool includeDebugSymbols)
        {
            // members
            IList<CodegenTypedParam> members = new List<CodegenTypedParam>();

            // Add a reference to "self"
            members.Add(new CodegenTypedParam(_className, null, "statementFields", false, false));

            GenerateNamedMembers(members);

            // numbered members
            foreach (var entry in _namespaceScope.FieldsUnshared) {
                var field = entry.Key;
                members.Add(
                    new CodegenTypedParam(field.Type, field.Name)
                        .WithStatic(false)
                        .WithFinal(false));
            }

            // substitution-parameter members
            GenerateSubstitutionParamMembers(members);

            var classScope = new CodegenClassScope(includeDebugSymbols, _namespaceScope, ClassName);

            // ctor
            var ctor = new CodegenCtor(GetType(), ClassName, includeDebugSymbols, Collections.GetEmptyList<CodegenTypedParam>());
            ctor.Block.AssignRef(Ref("statementFields"), Ref("this"));

            //_namespaceScope
            var initMethod = _namespaceScope.InitMethod;
            foreach (var entry in _namespaceScope.FieldsUnshared) {
                initMethod.Block.AssignRef(entry.Key.Name, entry.Value);
            }

            // assignment methods
            CodegenMethod assignMethod = CodegenMethod
                .MakeMethod(typeof(void), GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                .AddParam(typeof(StatementAIFactoryAssignments), "assignments")
                .WithStatic(false);
            CodegenMethod unassignMethod = CodegenMethod
                .MakeMethod(typeof(void), GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                .WithStatic(false);
            GenerateAssignAndUnassign(_numStreams, assignMethod, unassignMethod, _namespaceScope.FieldsNamed);

            // build methods
            var methods = new CodegenClassMethods();
            var properties = new CodegenClassProperties();

            CodegenStackGenerator.RecursiveBuildStack(initMethod, "Init", methods, properties);
            CodegenStackGenerator.RecursiveBuildStack(assignMethod, "Assign", methods, properties);
            CodegenStackGenerator.RecursiveBuildStack(unassignMethod, "Unassign", methods, properties);

            return new CodegenClass(
                typeof(StatementFields),
                _namespaceScope.Namespace,
                ClassName,
                classScope,
                members,
                ctor,
                methods,
                properties,
                Collections.GetEmptyList<CodegenInnerClass>());
        }
Ejemplo n.º 10
0
        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);
            }
        }
Ejemplo n.º 11
0
        private static void MakeOPV(
            CodegenClassScope classScope,
            IList<CodegenInnerClass> innerClasses,
            IList<CodegenTypedParam> factoryExplicitMembers,
            CodegenCtor factoryCtor,
            string classNameParent,
            OutputProcessViewFactoryForge forge,
            int numStreams)
        {
            IList<CodegenTypedParam> ctorParams = new List<CodegenTypedParam>();
            ctorParams.Add(new CodegenTypedParam(classNameParent, "o"));
            ctorParams.Add(new CodegenTypedParam(typeof(ResultSetProcessor), NAME_RESULTSETPROCESSOR));
            ctorParams.Add(new CodegenTypedParam(typeof(AgentInstanceContext), NAME_AGENTINSTANCECONTEXT));

            // make ctor code
            var serviceCtor = new CodegenCtor(typeof(StmtClassForgableOPVFactoryProvider), classScope, ctorParams);

            // Get-Result-Type Method
            var eventTypeGetter = CodegenProperty
                .MakePropertyNode(typeof(EventType), forge.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                .WithOverride();
            eventTypeGetter.GetterBlock.BlockReturn(ExprDotName(Ref(NAME_RESULTSETPROCESSOR), "ResultEventType"));

            // Process-View-Result Method
            var updateMethod = CodegenMethod
                .MakeMethod(typeof(void), forge.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                .WithOverride()
                .AddParam(typeof(EventBean[]), NAME_NEWDATA)
                .AddParam(typeof(EventBean[]), NAME_OLDDATA);
            if (numStreams == 1) {
                forge.UpdateCodegen(updateMethod, classScope);
            }
            else {
                updateMethod.Block.MethodThrowUnsupported();
            }

            // Process-Join-Result Method
            var processMethod = CodegenMethod
                .MakeMethod(typeof(void), forge.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                .WithOverride()
                .AddParam(typeof(ISet<MultiKey<EventBean>>), NAME_NEWDATA)
                .AddParam(typeof(ISet<MultiKey<EventBean>>), NAME_OLDDATA)
                .AddParam(
                    typeof(ExprEvaluatorContext),
                    "notApplicable");
            if (numStreams == 1) {
                processMethod.Block.MethodThrowUnsupported();
            }
            else {
                forge.ProcessCodegen(processMethod, classScope);
            }

            // Stop-Method (generates last as other methods may allocate members)
            var enumeratorMethod = CodegenMethod
                .MakeMethod(
                    typeof(IEnumerator<EventBean>),
                    forge.GetType(),
                    CodegenSymbolProviderEmpty.INSTANCE,
                    classScope)
                .WithOverride();
            forge.EnumeratorCodegen(enumeratorMethod, classScope);

            // NumChangesetRows (always zero for generated code)
            var numChangesetRowsProp = CodegenProperty
                .MakePropertyNode(typeof(int), forge.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                .WithOverride();
            numChangesetRowsProp.GetterBlock.BlockReturn(Constant(0));

            // OptionalOutputCondition (always null for generated code)
            var optionalOutputConditionProp = CodegenProperty
                .MakePropertyNode(typeof(OutputCondition), forge.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                .WithOverride();
            optionalOutputConditionProp.GetterBlock.BlockReturn(ConstantNull());

            // Stop-Method (no action for generated code)
            CodegenMethod stopMethod = CodegenMethod
                .MakeMethod(typeof(void), forge.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                .WithOverride()
                .AddParam(typeof(AgentInstanceStopServices), "svc");

            // Terminate-Method (no action for generated code)
            CodegenMethod terminatedMethod = CodegenMethod
                .MakeMethod(typeof(void), forge.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                .WithOverride();

            var innerProperties = new CodegenClassProperties();
            var innerMethods = new CodegenClassMethods();
            CodegenStackGenerator.RecursiveBuildStack(
                eventTypeGetter,
                "EventType",
                innerMethods,
                innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(
                updateMethod,
                "Update",
                innerMethods,
                innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(
                processMethod,
                "Process",
                innerMethods,
                innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(
                enumeratorMethod,
                "GetEnumerator",
                innerMethods,
                innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(
                numChangesetRowsProp,
                "NumChangesetRows",
                innerMethods,
                innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(
                optionalOutputConditionProp,
                "OptionalOutputCondition",
                innerMethods,
                innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(
                stopMethod,
                "Stop",
                innerMethods,
                innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(
                terminatedMethod,
                "Terminated",
                innerMethods,
                innerProperties);


            var innerClass = new CodegenInnerClass(
                CLASSNAME_OUTPUTPROCESSVIEW,
                typeof(OutputProcessView),
                serviceCtor,
                Collections.GetEmptyList<CodegenTypedParam>(),
                innerMethods,
                innerProperties);
            innerClasses.Add(innerClass);
        }
Ejemplo n.º 12
0
        public CodegenClass Forge(
            bool includeDebugSymbols,
            bool fireAndForget)
        {
            var classScope = new CodegenClassScope(includeDebugSymbols, _namespaceScope, _className);

            // make members
            var members = new List <CodegenTypedParam>();

            // --------------------------------------------------------------------------------
            // Constructor
            // --------------------------------------------------------------------------------

            var ctorParams = new CodegenTypedParam[] {};
            var ctor       = new CodegenCtor(typeof(StmtClassForgeableRSPFactoryProvider), classScope, ctorParams);

            // --------------------------------------------------------------------------------
            // TryGetProperty(string name, out object value)
            // --------------------------------------------------------------------------------

            var tryGetPropertyMethod = CodegenMethod
                                       .MakeParentNode(typeof(bool), this.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                                       .AddParam(new CodegenNamedParam(typeof(string), "name"))
                                       .AddParam(new CodegenNamedParam(typeof(object), "underlying"))
                                       .AddParam(new CodegenNamedParam(typeof(object), "value").WithOutputModifier());

            tryGetPropertyMethod = MakeTryGetProperty(tryGetPropertyMethod);

            // --------------------------------------------------------------------------------
            // TrySetProperty(string name, object underlying, object value)
            // --------------------------------------------------------------------------------

            var trySetPropertyMethod = CodegenMethod
                                       .MakeParentNode(typeof(bool), this.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                                       .AddParam(new CodegenNamedParam(typeof(string), "name"))
                                       .AddParam(new CodegenNamedParam(typeof(object), "underlying"))
                                       .AddParam(new CodegenNamedParam(typeof(object), "value"));

            trySetPropertyMethod = MakeTrySetProperty(trySetPropertyMethod);

            // --------------------------------------------------------------------------------
            // object TryCopy(object source)
            // --------------------------------------------------------------------------------

            var tryCopyMethod = CodegenMethod
                                .MakeParentNode(typeof(object), this.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                                .AddParam(new CodegenNamedParam(typeof(object), "source"));

            tryCopyMethod = MakeTryCopy(tryCopyMethod, classScope);

            // --------------------------------------------------------------------------------
            // Allocator (property)
            // --------------------------------------------------------------------------------

            var allocateMethod = CodegenMethod
                                 .MakeParentNode(typeof(object), GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope);

            allocateMethod = MakeAllocate(allocateMethod);

            // --------------------------------------------------------------------------------

            var properties = new CodegenClassProperties();

            // walk methods
            var methods = new CodegenClassMethods();

            CodegenStackGenerator.RecursiveBuildStack(tryGetPropertyMethod, "TryGetProperty", methods, properties);
            CodegenStackGenerator.RecursiveBuildStack(trySetPropertyMethod, "TrySetProperty", methods, properties);
            CodegenStackGenerator.RecursiveBuildStack(tryCopyMethod, "TryCopy", methods, properties);
            CodegenStackGenerator.RecursiveBuildStack(allocateMethod, "Allocate", methods, properties);

            var clazz = new CodegenClass(
                _classType,
                _className,
                classScope,
                members,
                ctor,
                methods,
                properties,
                EmptyList <CodegenInnerClass> .Instance);

            clazz.BaseList.AssignType(typeof(IJsonDelegate));

            return(clazz);
        }
Ejemplo n.º 13
0
        private static void MakeService(
            OrderByProcessorFactoryForge forge,
            CodegenClassScope classScope,
            IList<CodegenInnerClass> innerClasses,
            string providerClassName)
        {
            var namedMethods = new CodegenNamedMethods();

            var sortPlainMethod = CodegenMethod.MakeMethod(
                    typeof(EventBean[]),
                    forge.GetType(),
                    CodegenSymbolProviderEmpty.INSTANCE,
                    classScope)
                .AddParam(SORTPLAIN_PARAMS);
            forge.SortPlainCodegen(sortPlainMethod, classScope, namedMethods);

            var sortWGroupKeysMethod = CodegenMethod.MakeMethod(
                    typeof(EventBean[]),
                    forge.GetType(),
                    CodegenSymbolProviderEmpty.INSTANCE,
                    classScope)
                .AddParam(SORTWGROUPKEYS_PARAMS);
            forge.SortWGroupKeysCodegen(sortWGroupKeysMethod, classScope, namedMethods);

            var sortRollupMethod = CodegenMethod.MakeMethod(
                    typeof(EventBean[]),
                    forge.GetType(),
                    CodegenSymbolProviderEmpty.INSTANCE,
                    classScope)
                .AddParam(SORTROLLUP_PARAMS);
            forge.SortRollupCodegen(sortRollupMethod, classScope, namedMethods);

            var getSortKeyMethod = CodegenMethod
                .MakeMethod(typeof(object), forge.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                .AddParam(typeof(EventBean[]), REF_EPS.Ref)
                .AddParam(typeof(bool), ExprForgeCodegenNames.REF_ISNEWDATA.Ref)
                .AddParam(
                    typeof(ExprEvaluatorContext),
                    REF_EXPREVALCONTEXT.Ref);
            forge.GetSortKeyCodegen(getSortKeyMethod, classScope, namedMethods);

            var getSortKeyRollupMethod = CodegenMethod
                .MakeMethod(typeof(object), forge.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                .AddParam(typeof(EventBean[]), REF_EPS.Ref)
                .AddParam(typeof(bool), ExprForgeCodegenNames.REF_ISNEWDATA.Ref)
                .AddParam(typeof(ExprEvaluatorContext), REF_EXPREVALCONTEXT.Ref)
                .AddParam(
                    typeof(AggregationGroupByRollupLevel),
                    REF_ORDERROLLUPLEVEL.Ref);
            forge.GetSortKeyRollupCodegen(getSortKeyRollupMethod, classScope, namedMethods);

            var sortWOrderKeysMethod = CodegenMethod
                .MakeMethod(typeof(EventBean[]), forge.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                .AddParam(typeof(EventBean[]), REF_OUTGOINGEVENTS.Ref)
                .AddParam(typeof(object[]), REF_ORDERKEYS.Ref)
                .AddParam(typeof(ExprEvaluatorContext), REF_EXPREVALCONTEXT.Ref);
            forge.SortWOrderKeysCodegen(sortWOrderKeysMethod, classScope, namedMethods);

            var sortTwoKeysMethod = CodegenMethod.MakeMethod(
                    typeof(EventBean[]),
                    forge.GetType(),
                    CodegenSymbolProviderEmpty.INSTANCE,
                    classScope)
                .AddParam(SORTTWOKEYS_PARAMS);
            forge.SortTwoKeysCodegen(sortTwoKeysMethod, classScope, namedMethods);

            IList<CodegenTypedParam> members = new List<CodegenTypedParam>();
            IList<CodegenTypedParam> ctorParams = new List<CodegenTypedParam>();
            ctorParams.Add(new CodegenTypedParam(providerClassName, "o"));
            var ctor = new CodegenCtor(typeof(OrderByProcessorCompiler), classScope, ctorParams);

            // --------------------------------------------------------------------------------
            // Add statementFields
            // --------------------------------------------------------------------------------

            members.Add(
                new CodegenTypedParam(
                    classScope.NamespaceScope.FieldsClassName,
                    null,
                    "statementFields",
                    false,
                    false));

            ctor.Block.AssignRef(
                Ref("this.statementFields"),
                Ref("o.statementFields"));

            // --------------------------------------------------------------------------------

            forge.CtorCodegen(ctor, members, classScope);

            CodegenClassProperties innerProperties = new CodegenClassProperties();

            var innerMethods = new CodegenClassMethods();
            CodegenStackGenerator.RecursiveBuildStack(sortPlainMethod, "SortPlain", innerMethods, innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(sortWGroupKeysMethod, "SortWGroupKeys", innerMethods, innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(sortRollupMethod, "SortRollup", innerMethods, innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(getSortKeyMethod, "GetSortKey", innerMethods, innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(getSortKeyRollupMethod, "GetSortKeyRollup", innerMethods, innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(sortWOrderKeysMethod, "SortWOrderKeys", innerMethods, innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(sortTwoKeysMethod, "SortTwoKeys", innerMethods, innerProperties);
            foreach (var methodEntry in namedMethods.Methods) {
                CodegenStackGenerator.RecursiveBuildStack(methodEntry.Value, methodEntry.Key, innerMethods, innerProperties);
            }

            var innerClass = new CodegenInnerClass(
                CLASSNAME_ORDERBYPROCESSOR,
                typeof(OrderByProcessor),
                ctor,
                members,
                innerMethods,
                innerProperties);
            innerClasses.Add(innerClass);
        }
Ejemplo n.º 14
0
        private static string CompileModule(
            string optionalModuleName,
            IDictionary<ModuleProperty, object> moduleProperties,
            IList<string> statementClassNames,
            string moduleIdentPostfix,
            ModuleCompileTimeServices compileTimeServices,
            out Assembly assembly)
        {
            // write code to create an implementation of StatementResource
            var statementFieldsClassName = CodeGenerationIDGenerator.GenerateClassNameSimple(
                typeof(StatementFields),
                moduleIdentPostfix);
            var namespaceScope = new CodegenNamespaceScope(
                compileTimeServices.Namespace,
                statementFieldsClassName,
                compileTimeServices.IsInstrumented());
            var moduleClassName = CodeGenerationIDGenerator.GenerateClassNameSimple(
                typeof(ModuleProvider),
                moduleIdentPostfix);
            var classScope = new CodegenClassScope(true, namespaceScope, moduleClassName);
            var methods = new CodegenClassMethods();
            var properties = new CodegenClassProperties();

            // provide module name
            var moduleNameProp = CodegenProperty.MakePropertyNode(
                typeof(string),
                typeof(EPCompilerImpl),
                CodegenSymbolProviderEmpty.INSTANCE,
                classScope);
            moduleNameProp.GetterBlock.BlockReturn(Constant(optionalModuleName));

            // provide module properties
            var modulePropertiesProp = CodegenProperty.MakePropertyNode(
                typeof(IDictionary<ModuleProperty, object>),
                typeof(EPCompilerImpl),
                CodegenSymbolProviderEmpty.INSTANCE,
                classScope);
            MakeModuleProperties(moduleProperties, modulePropertiesProp);

            // provide module dependencies
            var moduleDependenciesProp = CodegenProperty.MakePropertyNode(
                typeof(ModuleDependenciesRuntime),
                typeof(EPCompilerImpl),
                CodegenSymbolProviderEmpty.INSTANCE,
                classScope);
            compileTimeServices.ModuleDependencies.Inject(moduleDependenciesProp.GetterBlock);

            // register types
            var initializeEventTypesMethod = MakeInitEventTypes(classScope, compileTimeServices);

            // register named windows
            var symbolsNamedWindowInit = new ModuleNamedWindowInitializeSymbol();
            var initializeNamedWindowsMethod = CodegenMethod
                .MakeMethod(typeof(void), typeof(EPCompilerImpl), symbolsNamedWindowInit, classScope)
                .AddParam(
                    typeof(EPModuleNamedWindowInitServices),
                    ModuleNamedWindowInitializeSymbol.REF_INITSVC.Ref);
            foreach (var namedWindow in compileTimeServices.NamedWindowCompileTimeRegistry.NamedWindows) {
                var addNamedWindow = RegisterNamedWindowCodegen(
                    namedWindow,
                    initializeNamedWindowsMethod,
                    classScope,
                    symbolsNamedWindowInit);
                initializeNamedWindowsMethod.Block.Expression(LocalMethod(addNamedWindow));
            }

            // register tables
            var symbolsTableInit = new ModuleTableInitializeSymbol();
            var initializeTablesMethod = CodegenMethod
                .MakeMethod(typeof(void), typeof(EPCompilerImpl), symbolsTableInit, classScope)
                .AddParam(typeof(EPModuleTableInitServices), ModuleTableInitializeSymbol.REF_INITSVC.Ref);
            foreach (var table in compileTimeServices.TableCompileTimeRegistry.Tables) {
                var addTable = RegisterTableCodegen(table, initializeTablesMethod, classScope, symbolsTableInit);
                initializeTablesMethod.Block.Expression(LocalMethod(addTable));
            }

            // register indexes
            var symbolsIndexInit = new ModuleIndexesInitializeSymbol();
            var initializeIndexesMethod = CodegenMethod
                .MakeMethod(typeof(void), typeof(EPCompilerImpl), symbolsIndexInit, classScope)
                .AddParam(typeof(EPModuleIndexInitServices), EPModuleIndexInitServicesConstants.REF.Ref);
            foreach (KeyValuePair<IndexCompileTimeKey, IndexDetailForge> index in compileTimeServices
                .IndexCompileTimeRegistry.Indexes) {
                var addIndex = RegisterIndexCodegen(index, initializeIndexesMethod, classScope, symbolsIndexInit);
                initializeIndexesMethod.Block.Expression(LocalMethod(addIndex));
            }

            // register contexts
            var symbolsContextInit = new ModuleContextInitializeSymbol();
            var initializeContextsMethod = CodegenMethod
                .MakeMethod(typeof(void), typeof(EPCompilerImpl), symbolsContextInit, classScope)
                .AddParam(
                    typeof(EPModuleContextInitServices),
                    ModuleContextInitializeSymbol.REF_INITSVC.Ref);
            foreach (var context in compileTimeServices.ContextCompileTimeRegistry.Contexts) {
                var addContext = RegisterContextCodegen(
                    context,
                    initializeContextsMethod,
                    classScope,
                    symbolsContextInit);
                initializeContextsMethod.Block.Expression(LocalMethod(addContext));
            }

            // register variables
            var symbolsVariablesInit = new ModuleVariableInitializeSymbol();
            var initializeVariablesMethod = CodegenMethod
                .MakeMethod(typeof(void), typeof(EPCompilerImpl), symbolsVariablesInit, classScope)
                .AddParam(
                    typeof(EPModuleVariableInitServices),
                    ModuleVariableInitializeSymbol.REF_INITSVC.Ref);
            foreach (var variable in compileTimeServices.VariableCompileTimeRegistry.Variables) {
                var addVariable = RegisterVariableCodegen(
                    variable,
                    initializeVariablesMethod,
                    classScope,
                    symbolsVariablesInit);
                initializeVariablesMethod.Block.Expression(LocalMethod(addVariable));
            }

            // register expressions
            var symbolsExprDeclaredInit = new ModuleExpressionDeclaredInitializeSymbol();
            var initializeExprDeclaredMethod = CodegenMethod
                .MakeMethod(typeof(void), typeof(EPCompilerImpl), symbolsExprDeclaredInit, classScope)
                .AddParam(
                    typeof(EPModuleExprDeclaredInitServices),
                    ModuleExpressionDeclaredInitializeSymbol.REF_INITSVC.Ref);
            foreach (var expression in compileTimeServices.ExprDeclaredCompileTimeRegistry.Expressions) {
                var addExpression = RegisterExprDeclaredCodegen(
                    expression,
                    initializeExprDeclaredMethod,
                    classScope,
                    symbolsExprDeclaredInit);
                initializeExprDeclaredMethod.Block.Expression(LocalMethod(addExpression));
            }

            // register scripts
            var symbolsScriptInit = new ModuleScriptInitializeSymbol();
            var initializeScriptsMethod = CodegenMethod
                .MakeMethod(typeof(void), typeof(EPCompilerImpl), symbolsScriptInit, classScope)
                .AddParam(typeof(EPModuleScriptInitServices), ModuleScriptInitializeSymbol.REF_INITSVC.Ref);
            foreach (var expression in compileTimeServices.ScriptCompileTimeRegistry.Scripts) {
                var addScript = RegisterScriptCodegen(
                    expression,
                    initializeScriptsMethod,
                    classScope,
                    symbolsScriptInit);
                initializeScriptsMethod.Block.Expression(LocalMethod(addScript));
            }

            // register provided classes
            var symbolsClassProvidedInit = new ModuleClassProvidedInitializeSymbol();
            var initializeClassProvidedMethod = CodegenMethod
                .MakeParentNode(typeof(void), typeof(EPCompilerImpl), symbolsClassProvidedInit, classScope)
                .AddParam(typeof(EPModuleClassProvidedInitServices), ModuleClassProvidedInitializeSymbol.REF_INITSVC.Ref);
            foreach (var currClazz in compileTimeServices.ClassProvidedCompileTimeRegistry.Classes) {
                var addClassProvided = RegisterClassProvidedCodegen(
                    currClazz,
                    initializeClassProvidedMethod,
                    classScope,
                    symbolsClassProvidedInit);
                initializeClassProvidedMethod.Block.Expression(LocalMethod(addClassProvided));
            }
            
            // instantiate factories for statements
            var statementsProp = CodegenProperty.MakePropertyNode(
                typeof(IList<StatementProvider>),
                typeof(EPCompilerImpl),
                CodegenSymbolProviderEmpty.INSTANCE,
                classScope);
            statementsProp.GetterBlock.DeclareVar<IList<StatementProvider>>(
                "statements",
                NewInstance(typeof(List<StatementProvider>), Constant(statementClassNames.Count)));
            foreach (var statementClassName in statementClassNames) {
                statementsProp.GetterBlock.ExprDotMethod(
                    Ref("statements"),
                    "Add",
                    NewInstanceInner(statementClassName));
            }

            statementsProp.GetterBlock.BlockReturn(Ref("statements"));

            // build stack
            CodegenStackGenerator.RecursiveBuildStack(
                moduleNameProp,
                "ModuleName",
                methods,
                properties);
            CodegenStackGenerator.RecursiveBuildStack(
                modulePropertiesProp,
                "ModuleProperties",
                methods,
                properties);
            CodegenStackGenerator.RecursiveBuildStack(
                moduleDependenciesProp,
                "ModuleDependencies",
                methods,
                properties);
            CodegenStackGenerator.RecursiveBuildStack(
                initializeEventTypesMethod,
                "InitializeEventTypes",
                methods,
                properties);
            CodegenStackGenerator.RecursiveBuildStack(
                initializeNamedWindowsMethod,
                "InitializeNamedWindows",
                methods,
                properties);
            CodegenStackGenerator.RecursiveBuildStack(
                initializeTablesMethod,
                "InitializeTables",
                methods,
                properties);
            CodegenStackGenerator.RecursiveBuildStack(
                initializeIndexesMethod,
                "InitializeIndexes",
                methods,
                properties);
            CodegenStackGenerator.RecursiveBuildStack(
                initializeContextsMethod,
                "InitializeContexts",
                methods,
                properties);
            CodegenStackGenerator.RecursiveBuildStack(
                initializeVariablesMethod,
                "InitializeVariables",
                methods,
                properties);
            CodegenStackGenerator.RecursiveBuildStack(
                initializeExprDeclaredMethod,
                "InitializeExprDeclareds",
                methods,
                properties);
            CodegenStackGenerator.RecursiveBuildStack(
                initializeScriptsMethod,
                "InitializeScripts",
                methods,
                properties);
            CodegenStackGenerator.RecursiveBuildStack(
                initializeClassProvidedMethod,
                "InitializeClassProvided",
                methods,
                properties);
            CodegenStackGenerator.RecursiveBuildStack(
                statementsProp,
                "Statements",
                methods,
                properties);

            var clazz = new CodegenClass(
                CodegenClassType.MODULEPROVIDER,
                typeof(ModuleProvider),
                moduleClassName,
                classScope,
                new EmptyList<CodegenTypedParam>(),
                null,
                methods,
                properties,
                new EmptyList<CodegenInnerClass>());
            
            var container = compileTimeServices.Container;
            var compiler = container
                .RoslynCompiler()
                .WithCodeLogging(compileTimeServices.Configuration.Compiler.Logging.IsEnableCode)
                .WithCodeAuditDirectory(compileTimeServices.Configuration.Compiler.Logging.AuditDirectory)
                .WithCodegenClasses(new[] {clazz});

            assembly = compiler.Compile();

            return CodeGenerationIDGenerator.GenerateClassNameWithNamespace(
                compileTimeServices.Namespace,
                typeof(ModuleProvider),
                moduleIdentPostfix);
        }
Ejemplo n.º 15
0
        private static void MakeResultSetProcessor(
            CodegenClassScope classScope,
            IList<CodegenInnerClass> innerClasses,
            IList<CodegenTypedParam> factoryExplicitMembers,
            CodegenCtor factoryCtor,
            string classNameParent,
            ResultSetProcessorDesc spec)
        {
            IList<CodegenTypedParam> ctorParams = new List<CodegenTypedParam>();
            ctorParams.Add(new CodegenTypedParam(classNameParent, "o"));
            ctorParams.Add(new CodegenTypedParam(typeof(OrderByProcessor), "orderByProcessor"));
            ctorParams.Add(new CodegenTypedParam(typeof(AggregationService), "aggregationService"));
            ctorParams.Add(new CodegenTypedParam(typeof(AgentInstanceContext), "agentInstanceContext"));

            // make ctor code
            var serviceCtor = new CodegenCtor(
                typeof(StmtClassForgableRSPFactoryProvider), 
                classScope,
                ctorParams);

            // Get-Result-Type Method
            var forge = spec.ResultSetProcessorFactoryForge;
            var resultEventTypeGetter = CodegenProperty.MakePropertyNode(
                typeof(EventType),
                forge.GetType(),
                CodegenSymbolProviderEmpty.INSTANCE,
                classScope);
            resultEventTypeGetter.GetterBlock.BlockReturn(Ref("o." + MEMBERNAME_RESULTEVENTTYPE));

            // Instance members and methods
            var instance = new CodegenInstanceAux(serviceCtor);

            // --------------------------------------------------------------------------------
            // Add statementFields
            // --------------------------------------------------------------------------------

            instance.Members.Add(
                new CodegenTypedParam(
                    classScope.NamespaceScope.FieldsClassName,
                    null,
                    "statementFields",
                    false,
                    false));

            serviceCtor.Block.AssignRef(
                Ref("this.statementFields"),
                Ref("o.statementFields"));

            // --------------------------------------------------------------------------------

            forge.InstanceCodegen(instance, classScope, factoryCtor, factoryExplicitMembers);

            // Process-View-Result Method
            var processViewResultMethod = CodegenMethod.MakeMethod(
                    typeof(UniformPair<EventBean[]>),
                    forge.GetType(),
                    CodegenSymbolProviderEmpty.INSTANCE,
                    classScope)
                .AddParam(typeof(EventBean[]), NAME_NEWDATA)
                .AddParam(typeof(EventBean[]), NAME_OLDDATA)
                .AddParam(typeof(bool), NAME_ISSYNTHESIZE);
            if (!spec.IsJoin) {
                GenerateInstrumentedProcessView(forge, classScope, processViewResultMethod, instance);
            }
            else {
                processViewResultMethod.Block.MethodThrowUnsupported();
            }

            // Process-Join-Result Method
            var processJoinResultMethod = CodegenMethod
                .MakeMethod(
                    typeof(UniformPair<EventBean[]>),
                    forge.GetType(),
                    CodegenSymbolProviderEmpty.INSTANCE,
                    classScope)
                .AddParam(typeof(ISet<MultiKey<EventBean>>), NAME_NEWDATA)
                .AddParam(typeof(ISet<MultiKey<EventBean>>), NAME_OLDDATA)
                .AddParam(typeof(bool), NAME_ISSYNTHESIZE);

            processJoinResultMethod.Block.DebugStack();
            
            if (!spec.IsJoin) {
                processJoinResultMethod.Block.MethodThrowUnsupported();
            }
            else {
                GenerateInstrumentedProcessJoin(forge, classScope, processJoinResultMethod, instance);
            }

            // Clear-Method
            var clearMethod = CodegenMethod
                .MakeMethod(typeof(void), forge.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope);
            forge.ClearMethodCodegen(classScope, clearMethod);

            // Get-Enumerator-View
            var getEnumeratorMethodView = CodegenMethod
                .MakeMethod(
                    typeof(IEnumerator<EventBean>),
                    forge.GetType(),
                    CodegenSymbolProviderEmpty.INSTANCE,
                    classScope)
                .AddParam(typeof(Viewable), NAME_VIEWABLE);
            if (!spec.IsJoin) {
                forge.GetEnumeratorViewCodegen(classScope, getEnumeratorMethodView, instance);
            }
            else {
                getEnumeratorMethodView.Block.MethodThrowUnsupported();
            }

            // Get-Enumerator-Join
            var getEnumeratorMethodJoin = CodegenMethod
                .MakeMethod(
                    typeof(IEnumerator<EventBean>),
                    forge.GetType(),
                    CodegenSymbolProviderEmpty.INSTANCE,
                    classScope)
                .AddParam(typeof(ISet<MultiKey<EventBean>>), NAME_JOINSET);
            if (!spec.IsJoin) {
                getEnumeratorMethodJoin.Block.MethodThrowUnsupported();
            }
            else {
                forge.GetEnumeratorJoinCodegen(classScope, getEnumeratorMethodJoin, instance);
            }

            // Process-output-rate-buffered-view
            var processOutputLimitedViewMethod = CodegenMethod
                .MakeMethod(
                    typeof(UniformPair<EventBean[]>),
                    forge.GetType(),
                    CodegenSymbolProviderEmpty.INSTANCE,
                    classScope)
                .AddParam(typeof(IList<UniformPair<EventBean[]>>), NAME_VIEWEVENTSLIST)
                .AddParam(typeof(bool), NAME_ISSYNTHESIZE);
            if (!spec.IsJoin && spec.HasOutputLimit && !spec.HasOutputLimitSnapshot) {
                forge.ProcessOutputLimitedViewCodegen(classScope, processOutputLimitedViewMethod, instance);
            }
            else {
                processOutputLimitedViewMethod.Block.MethodThrowUnsupported();
            }

            // Process-output-rate-buffered-join
            var processOutputLimitedJoinMethod = CodegenMethod
                .MakeMethod(
                    typeof(UniformPair<EventBean[]>),
                    forge.GetType(),
                    CodegenSymbolProviderEmpty.INSTANCE,
                    classScope)
                .AddParam(typeof(IList<UniformPair<ISet<MultiKey<EventBean>>>>), NAME_JOINEVENTSSET)
                .AddParam(typeof(bool), NAME_ISSYNTHESIZE);
            if (!spec.IsJoin || !spec.HasOutputLimit || spec.HasOutputLimitSnapshot) {
                processOutputLimitedJoinMethod.Block.MethodThrowUnsupported();
            }
            else {
                forge.ProcessOutputLimitedJoinCodegen(classScope, processOutputLimitedJoinMethod, instance);
            }

            // Set-Agent-Instance is supported for fire-and-forget queries only
            var setAgentInstanceContextMethod = CodegenMethod
                .MakeMethod(typeof(void), forge.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                .AddParam(typeof(AgentInstanceContext), "value");
            setAgentInstanceContextMethod.Block.AssignRef(NAME_AGENTINSTANCECONTEXT, Ref("value"));

            // Apply-view
            var applyViewResultMethod = CodegenMethod
                .MakeMethod(typeof(void), forge.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                .AddParam(typeof(EventBean[]), NAME_NEWDATA)
                .AddParam(typeof(EventBean[]), NAME_OLDDATA);
            if (!spec.IsJoin && spec.HasOutputLimit && spec.HasOutputLimitSnapshot) {
                forge.ApplyViewResultCodegen(classScope, applyViewResultMethod, instance);
            }
            else {
                applyViewResultMethod.Block.MethodThrowUnsupported();
            }

            // Apply-join
            var applyJoinResultMethod = CodegenMethod
                .MakeMethod(typeof(void), forge.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                .AddParam(typeof(ISet<MultiKey<EventBean>>), NAME_NEWDATA)
                .AddParam(typeof(ISet<MultiKey<EventBean>>), NAME_OLDDATA);
            if (!spec.IsJoin || !spec.HasOutputLimit || !spec.HasOutputLimitSnapshot) {
                applyJoinResultMethod.Block.MethodThrowUnsupported();
            }
            else {
                forge.ApplyJoinResultCodegen(classScope, applyJoinResultMethod, instance);
            }

            // Process-output-unbuffered-view
            var processOutputLimitedLastAllNonBufferedViewMethod = CodegenMethod
                .MakeMethod(typeof(void), forge.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                .AddParam(typeof(EventBean[]), NAME_NEWDATA)
                .AddParam(typeof(EventBean[]), NAME_OLDDATA)
                .AddParam(typeof(bool), NAME_ISSYNTHESIZE);
            if (!spec.IsJoin && spec.HasOutputLimit && spec.OutputConditionType == POLICY_LASTALL_UNORDERED) {
                forge.ProcessOutputLimitedLastAllNonBufferedViewCodegen(
                    classScope,
                    processOutputLimitedLastAllNonBufferedViewMethod,
                    instance);
            }
            else {
                processOutputLimitedLastAllNonBufferedViewMethod.Block.MethodThrowUnsupported();
            }

            // Process-output-unbuffered-join
            var processOutputLimitedLastAllNonBufferedJoinMethod = CodegenMethod
                .MakeMethod(typeof(void), forge.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                .AddParam(typeof(ISet<MultiKey<EventBean>>), NAME_NEWDATA)
                .AddParam(typeof(ISet<MultiKey<EventBean>>), NAME_OLDDATA)
                .AddParam(typeof(bool), NAME_ISSYNTHESIZE);
            if (!spec.IsJoin || !spec.HasOutputLimit || spec.OutputConditionType != POLICY_LASTALL_UNORDERED) {
                processOutputLimitedLastAllNonBufferedJoinMethod.Block.MethodThrowUnsupported();
            }
            else {
                forge.ProcessOutputLimitedLastAllNonBufferedJoinCodegen(
                    classScope,
                    processOutputLimitedLastAllNonBufferedJoinMethod,
                    instance);
            }

            // Continue-output-unbuffered-view
            var continueOutputLimitedLastAllNonBufferedViewMethod = CodegenMethod
                .MakeMethod(
                    typeof(UniformPair<EventBean[]>),
                    forge.GetType(),
                    CodegenSymbolProviderEmpty.INSTANCE,
                    classScope)
                .AddParam(typeof(bool), NAME_ISSYNTHESIZE);
            if (!spec.IsJoin && spec.HasOutputLimit && spec.OutputConditionType == POLICY_LASTALL_UNORDERED) {
                forge.ContinueOutputLimitedLastAllNonBufferedViewCodegen(
                    classScope,
                    continueOutputLimitedLastAllNonBufferedViewMethod,
                    instance);
            }
            else {
                continueOutputLimitedLastAllNonBufferedViewMethod.Block.MethodThrowUnsupported();
            }

            // Continue-output-unbuffered-join
            var continueOutputLimitedLastAllNonBufferedJoinMethod = CodegenMethod
                .MakeMethod(
                    typeof(UniformPair<EventBean[]>),
                    forge.GetType(),
                    CodegenSymbolProviderEmpty.INSTANCE,
                    classScope)
                .AddParam(typeof(bool), NAME_ISSYNTHESIZE);
            if (!spec.IsJoin || !spec.HasOutputLimit || spec.OutputConditionType != POLICY_LASTALL_UNORDERED) {
                continueOutputLimitedLastAllNonBufferedJoinMethod.Block.MethodThrowUnsupported();
            }
            else {
                forge.ContinueOutputLimitedLastAllNonBufferedJoinCodegen(
                    classScope,
                    continueOutputLimitedLastAllNonBufferedJoinMethod,
                    instance);
            }

            // Accept-Helper-Visitor
            var acceptHelperVisitorMethod = CodegenMethod
                .MakeMethod(typeof(void), forge.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                .AddParam(typeof(ResultSetProcessorOutputHelperVisitor), NAME_RESULTSETVISITOR);
            forge.AcceptHelperVisitorCodegen(classScope, acceptHelperVisitorMethod, instance);

            // Stop-Method (generates last as other methods may allocate members)
            var stopMethod = CodegenMethod.MakeMethod(
                typeof(void),
                forge.GetType(),
                CodegenSymbolProviderEmpty.INSTANCE,
                classScope);
            forge.StopMethodCodegen(classScope, stopMethod, instance);

            var innerProperties = new CodegenClassProperties();
            var innerMethods = new CodegenClassMethods();
            CodegenStackGenerator.RecursiveBuildStack(
                resultEventTypeGetter,
                "ResultEventType",
                innerMethods,
                innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(
                processViewResultMethod,
                "ProcessViewResult",
                innerMethods,
                innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(
                processJoinResultMethod,
                "ProcessJoinResult",
                innerMethods,
                innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(
                getEnumeratorMethodView,
                "GetEnumerator",
                innerMethods,
                innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(
                getEnumeratorMethodJoin,
                "GetEnumerator",
                innerMethods,
                innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(
                clearMethod,
                "Clear",
                innerMethods,
                innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(
                stopMethod,
                "Stop",
                innerMethods,
                innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(
                processOutputLimitedJoinMethod,
                "ProcessOutputLimitedJoin",
                innerMethods,
                innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(
                processOutputLimitedViewMethod,
                "ProcessOutputLimitedView",
                innerMethods,
                innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(
                setAgentInstanceContextMethod,
                "SetAgentInstanceContext",
                innerMethods,
                innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(
                applyViewResultMethod,
                "ApplyViewResult",
                innerMethods,
                innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(
                applyJoinResultMethod,
                "ApplyJoinResult",
                innerMethods,
                innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(
                processOutputLimitedLastAllNonBufferedViewMethod,
                "ProcessOutputLimitedLastAllNonBufferedView",
                innerMethods,
                innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(
                processOutputLimitedLastAllNonBufferedJoinMethod,
                "ProcessOutputLimitedLastAllNonBufferedJoin",
                innerMethods,
                innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(
                continueOutputLimitedLastAllNonBufferedViewMethod,
                "ContinueOutputLimitedLastAllNonBufferedView",
                innerMethods,
                innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(
                continueOutputLimitedLastAllNonBufferedJoinMethod,
                "ContinueOutputLimitedLastAllNonBufferedJoin",
                innerMethods,
                innerProperties);
            CodegenStackGenerator.RecursiveBuildStack(
                acceptHelperVisitorMethod,
                "AcceptHelperVisitor",
                innerMethods,
                innerProperties);

            foreach (var propertyEntry in instance.Properties.Properties)
            {
                CodegenStackGenerator.RecursiveBuildStack(
                    propertyEntry.Value,
                    propertyEntry.Key,
                    innerMethods,
                    innerProperties);
            }

            foreach (var methodEntry in instance.Methods.Methods) {
                CodegenStackGenerator.RecursiveBuildStack(
                    methodEntry.Value,
                    methodEntry.Key,
                    innerMethods,
                    innerProperties);
            }

            var innerClass = new CodegenInnerClass(
                CLASSNAME_RESULTSETPROCESSOR,
                forge.InterfaceClass,
                serviceCtor,
                instance.Members,
                innerMethods,
                innerProperties);
            innerClasses.Add(innerClass);
        }
Ejemplo n.º 16
0
        public CodegenClass Forge(
            bool includeDebugSymbols,
            bool fireAndForget)
        {
            var dynamic = NeedDynamic();
            var ctor    = new CodegenCtor(typeof(StmtClassForgeableJsonUnderlying), includeDebugSymbols, EmptyList <CodegenTypedParam> .Instance);

            if (dynamic)
            {
                ctor.Block.AssignRef(DYNAMIC_PROP_FIELD, NewInstance(typeof(LinkedHashMap <string, object>)));
            }

            var properties = new CodegenClassProperties();
            var methods    = new CodegenClassMethods();
            var classScope = new CodegenClassScope(includeDebugSymbols, namespaceScope, className);

            IList <CodegenTypedParam> explicitMembers = new List <CodegenTypedParam>(desc.PropertiesThisType.Count);

            if (dynamic)
            {
                explicitMembers.Add(new CodegenTypedParam(typeof(IDictionary <string, object>), DYNAMIC_PROP_FIELD, false, true));
            }

            // add members
            foreach (var property in desc.PropertiesThisType)
            {
                var field = desc.FieldDescriptorsInclSupertype.Get(property.Key);
                explicitMembers.Add(new CodegenTypedParam(field.PropertyType, field.FieldName, false, true));
            }

            // --------------------------------------------------------------------------------
            // - NativeCount => int
            // --------------------------------------------------------------------------------

            var nativeCountProperty = CodegenProperty
                                      .MakePropertyNode(typeof(int), this.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                                      .WithOverride();

            nativeCountProperty.GetterBlock
            .BlockReturn(Constant(desc.PropertiesThisType.Count + desc.NumFieldsSupertype));
            CodegenStackGenerator.RecursiveBuildStack(nativeCountProperty, "NativeCount", methods, properties);

            // --------------------------------------------------------------------------------
            // - TryGetNativeEntry(string, out KeyValuePair<string, object>
            // --------------------------------------------------------------------------------

            var tryGetNativeEntryMethod = CodegenMethod
                                          .MakeParentNode(typeof(bool), this.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                                          .AddParam(typeof(string), "name")
                                          .AddParam(new CodegenNamedParam(typeof(KeyValuePair <string, object>), "value").WithOutputModifier())
                                          .WithOverride();

            MakeTryGetNativeEntry(tryGetNativeEntryMethod, classScope);
            CodegenStackGenerator.RecursiveBuildStack(tryGetNativeEntryMethod, "TryGetNativeEntry", methods, properties);

            // --------------------------------------------------------------------------------
            // - TrySetNativeValue(string, object)
            // --------------------------------------------------------------------------------

            var trySetNativeValueMethod = CodegenMethod
                                          .MakeParentNode(typeof(bool), this.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                                          .AddParam(typeof(string), "name")
                                          .AddParam(typeof(object), "value")
                                          .WithOverride();

            MakeTrySetNativeValue(trySetNativeValueMethod, classScope);
            CodegenStackGenerator.RecursiveBuildStack(trySetNativeValueMethod, "TrySetNativeValue", methods, properties);

            // --------------------------------------------------------------------------------
            // - NativeEnumerable => IEnumerable<KeyValuePair<string, object>>
            // --------------------------------------------------------------------------------

            var nativeEnumerable = CodegenProperty
                                   .MakePropertyNode(typeof(IEnumerable <KeyValuePair <string, object> >), this.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                                   .WithOverride();

            MakeNativeEnumerable(nativeEnumerable, classScope);
            CodegenStackGenerator.RecursiveBuildStack(nativeEnumerable, "NativeEnumerable", methods, properties);

            // --------------------------------------------------------------------------------
            // - NativeContainsKey(string)
            // --------------------------------------------------------------------------------

            var nativeContainsKeyMethod = CodegenMethod
                                          .MakeParentNode(typeof(bool), this.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                                          .AddParam(typeof(string), "name")
                                          .WithOverride();

            MakeNativeContainsKey(nativeContainsKeyMethod);
            CodegenStackGenerator.RecursiveBuildStack(nativeContainsKeyMethod, "NativeContainsKey", methods, properties);

            // --------------------------------------------------------------------------------
            // - NativeWrite(Utf8JsonWriter)
            // --------------------------------------------------------------------------------

            var nativeWriteMethod = CodegenMethod
                                    .MakeParentNode(typeof(void), this.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                                    .AddParam(typeof(JsonSerializationContext), "context")
                                    .WithOverride();

            MakeNativeWrite(nativeWriteMethod, classScope);
            CodegenStackGenerator.RecursiveBuildStack(nativeWriteMethod, "NativeWrite", methods, properties);

            if (!ParentDynamic() && dynamic)
            {
                // --------------------------------------------------------------------------------
                // AddJsonValue
                // --------------------------------------------------------------------------------

                var addJsonValueMethod = CodegenMethod
                                         .MakeParentNode(typeof(void), this.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                                         .AddParam(typeof(string), "name")
                                         .AddParam(typeof(object), "value")
                                         .WithOverride();
                addJsonValueMethod.Block.ExprDotMethod(Ref(DYNAMIC_PROP_FIELD), "Put", Ref("name"), Ref("value"));

                CodegenStackGenerator.RecursiveBuildStack(addJsonValueMethod, "AddJsonValue", methods, properties);

                // - JsonValues => IDictionary<string, object>
                var jsonValuesProperty = CodegenProperty
                                         .MakePropertyNode(typeof(IDictionary <string, object>), this.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                                         .WithOverride();
                jsonValuesProperty.GetterBlock.BlockReturn(Ref(DYNAMIC_PROP_FIELD));
                CodegenStackGenerator.RecursiveBuildStack(jsonValuesProperty, "JsonValues", methods, properties);
            }

            var clazz = new CodegenClass(
                CodegenClassType.JSONEVENT,
                className,
                classScope,
                explicitMembers,
                ctor,
                methods,
                properties,
                EmptyList <CodegenInnerClass> .Instance);

            if (desc.OptionalSupertype == null)
            {
                clazz.BaseList.AssignType(typeof(JsonEventObjectBase));
            }
            else
            {
                clazz.BaseList.AssignType(desc.OptionalSupertype.UnderlyingType);
            }

            return(clazz);
        }
Ejemplo n.º 17
0
        public CodegenClass Forge(bool includeDebugSymbols)
        {
            var debugInformationProvider = new Supplier<string>(
                () => {
                    var writer = new StringWriter();
                    writer.Write("FAF query");
                    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(GetType(), ClassName, includeDebugSymbols, ctorParms);
                var classScope = new CodegenClassScope(includeDebugSymbols, _namespaceScope, ClassName);

                // add query method member
                IList<CodegenTypedParam> providerExplicitMembers = new List<CodegenTypedParam>(2);
                providerExplicitMembers.Add(new CodegenTypedParam(typeof(FAFQueryMethod), MEMBERNAME_QUERYMETHOD));

                var symbols = new SAIFFInitializeSymbol();
                var makeMethod = providerCtor.MakeChildWithScope(typeof(FAFQueryMethod), GetType(), symbols, classScope)
                    .AddParam(typeof(EPStatementInitServices), EPStatementInitServicesConstants.REF.Ref);
                providerCtor.Block
                    .ExprDotMethod(Ref("statementFields"), "Init", EPStatementInitServicesConstants.REF)
                    .AssignRef(MEMBERNAME_QUERYMETHOD, LocalMethod(makeMethod, EPStatementInitServicesConstants.REF));
                _forge.MakeMethod(makeMethod, symbols, classScope);

                // make provider methods
                var propQueryMethod = CodegenProperty.MakePropertyNode(
                    typeof(FAFQueryMethod),
                    GetType(),
                    CodegenSymbolProviderEmpty.INSTANCE,
                    classScope);
                propQueryMethod
                    .GetterBlock
                    .BlockReturn(Ref(MEMBERNAME_QUERYMETHOD));

                // add get-informational methods
                var propQueryInformationals = CodegenProperty.MakePropertyNode(
                    typeof(FAFQueryInformationals),
                    GetType(),
                    CodegenSymbolProviderEmpty.INSTANCE,
                    classScope);
                var queryInformationals = FAFQueryInformationals.From(
                    _namespaceScope.SubstitutionParamsByNumber,
                    _namespaceScope.SubstitutionParamsByName);

                queryInformationals.Make(
                    propQueryInformationals.GetterBlock,
                    classScope);

                // add get-statement-fields method
                var propSubstitutionFieldSetter = CodegenProperty.MakePropertyNode(
                    typeof(FAFQueryMethodAssignerSetter),
                    GetType(),
                    CodegenSymbolProviderEmpty.INSTANCE,
                    classScope);
                StmtClassForgableStmtFields.MakeSubstitutionSetter(
                    _namespaceScope,
                    propSubstitutionFieldSetter.GetterBlock,
                    classScope);

                // make provider methods
                var methods = new CodegenClassMethods();
                var properties = new CodegenClassProperties();
                CodegenStackGenerator.RecursiveBuildStack(providerCtor, "ctor", methods, properties);
                CodegenStackGenerator.RecursiveBuildStack(propQueryMethod, "QueryMethod", methods, properties);
                CodegenStackGenerator.RecursiveBuildStack(propQueryInformationals, "QueryInformationals", methods, properties);
                CodegenStackGenerator.RecursiveBuildStack(propSubstitutionFieldSetter, "SubstitutionFieldSetter", methods, properties);

                // render and compile
                return new CodegenClass(
                    typeof(FAFQueryMethodProvider),
                    _namespaceScope.Namespace,
                    ClassName,
                    classScope,
                    providerExplicitMembers,
                    providerCtor,
                    methods,
                    properties,
                    innerClasses);
            }
            catch (EPException) {
                throw;
            }
            catch (Exception e) {
                throw new EPException(
                    "Fatal exception during code-generation for " +
                    debugInformationProvider.Invoke() +
                    " : " +
                    e.Message,
                    e);
            }
        }
Ejemplo n.º 18
0
        private static string MakeFAFProvider(
            string queryMethodProviderClassName,
            string classPostfix,
            ModuleCompileTimeServices compileTimeServices,
            out Assembly assembly)
        {
            var statementFieldsClassName = CodeGenerationIDGenerator.GenerateClassNameSimple(
                typeof(StatementFields), classPostfix);
            var namespaceScope = new CodegenNamespaceScope(
                compileTimeServices.Namespace, statementFieldsClassName, compileTimeServices.IsInstrumented());
            var fafProviderClassName =
                CodeGenerationIDGenerator.GenerateClassNameSimple(typeof(FAFProvider), classPostfix);
            var classScope = new CodegenClassScope(true, namespaceScope, fafProviderClassName);
            var methods = new CodegenClassMethods();
            var properties = new CodegenClassProperties();

            // --------------------------------------------------------------------------------
            // Add statementFields
            // --------------------------------------------------------------------------------

            var ctor = new CodegenCtor(
                typeof(CompilerHelperFAFProvider),
                classScope,
                new List<CodegenTypedParam>());

            ctor.Block.AssignRef(Ref("statementFields"), NewInstanceInner(statementFieldsClassName));

            // initialize-event-types
            var initializeEventTypesMethod = MakeInitEventTypes(classScope, compileTimeServices);

            // initialize-query
            var initializeQueryMethod = CodegenMethod
                .MakeMethod(
                    typeof(void),
                    typeof(EPCompilerImpl),
                    CodegenSymbolProviderEmpty.INSTANCE,
                    classScope)
                .AddParam(
                    typeof(EPStatementInitServices),
                    EPStatementInitServicesConstants.REF.Ref);
            initializeQueryMethod.Block.AssignMember(
                MEMBERNAME_QUERY_METHOD_PROVIDER,
                NewInstanceInner(queryMethodProviderClassName, EPStatementInitServicesConstants.REF, Ref("statementFields")));

            // get-execute
            var queryMethodProviderProperty = CodegenProperty.MakePropertyNode(
                typeof(FAFQueryMethodProvider),
                typeof(EPCompilerImpl),
                CodegenSymbolProviderEmpty.INSTANCE,
                classScope);
            queryMethodProviderProperty.GetterBlock.BlockReturn(Ref(MEMBERNAME_QUERY_METHOD_PROVIDER));

            // provide module dependencies
            var moduleDependenciesProperty = CodegenProperty.MakePropertyNode(
                typeof(ModuleDependenciesRuntime),
                typeof(EPCompilerImpl),
                CodegenSymbolProviderEmpty.INSTANCE,
                classScope);
            moduleDependenciesProperty.GetterBlock
                .BlockReturn(compileTimeServices.ModuleDependencies.Make(
                    initializeQueryMethod, classScope));

            // build stack
            CodegenStackGenerator.RecursiveBuildStack(moduleDependenciesProperty, "ModuleDependencies", methods, properties);
            CodegenStackGenerator.RecursiveBuildStack(initializeEventTypesMethod, "InitializeEventTypes", methods, properties);
            CodegenStackGenerator.RecursiveBuildStack(initializeQueryMethod, "InitializeQuery", methods, properties);
            CodegenStackGenerator.RecursiveBuildStack(queryMethodProviderProperty, "QueryMethodProvider", methods, properties);

            IList<CodegenTypedParam> members = new List<CodegenTypedParam>();
            members.Add(new CodegenTypedParam(statementFieldsClassName, null, "statementFields"));
            var typedParam = new CodegenTypedParam(typeof(FAFQueryMethodProvider), MEMBERNAME_QUERY_METHOD_PROVIDER);
            typedParam.IsReadonly = false;
            members.Add(typedParam);

            var clazz = new CodegenClass(
                CodegenClassType.FAFPROVIDER,
                typeof(FAFProvider),
                fafProviderClassName,
                classScope,
                members,
                ctor,
                methods,
                properties,
                new EmptyList<CodegenInnerClass>());

            var container = compileTimeServices.Container;
            var compiler = container
                .RoslynCompiler()
                .WithCodeLogging(compileTimeServices.Configuration.Compiler.Logging.IsEnableCode)
                .WithCodeAuditDirectory(compileTimeServices.Configuration.Compiler.Logging.AuditDirectory)
                .WithCodegenClasses(new List<CodegenClass>() { clazz });

            assembly = compiler.Compile();

            return CodeGenerationIDGenerator.GenerateClassNameWithNamespace(
                compileTimeServices.Namespace,
                typeof(FAFProvider),
                classPostfix);
        }
Ejemplo n.º 19
0
        public CodegenClass Forge(bool includeDebugSymbols)
        {
            // write code to create an implementation of StatementResource
            var methods = new CodegenClassMethods();
            var properties = new CodegenClassProperties();

            // members
            IList<CodegenTypedParam> members = new List<CodegenTypedParam>();
            if (_namespaceScope.FieldsClassName != null) {
                members.Add(new CodegenTypedParam(_namespaceScope.FieldsClassName, MEMBERNAME_STATEMENT_FIELDS));
            }

            members.Add(new CodegenTypedParam(typeof(StatementInformationalsRuntime), MEMBERNAME_INFORMATION));
            members.Add(new CodegenTypedParam(typeof(StatementAIFactoryProvider), MEMBERNAME_FACTORY_PROVIDER));

            // ctor
            var ctor = new CodegenCtor(GetType(), ClassName, includeDebugSymbols, Collections.GetEmptyList<CodegenTypedParam>());
            var classScope = new CodegenClassScope(includeDebugSymbols, _namespaceScope, ClassName);
            if (_namespaceScope.FieldsClassName != null) {
                ctor.Block.AssignRef(MEMBERNAME_INFORMATION, _statementInformationals.Make(ctor, classScope));
            }

            var initializeMethod = MakeInitialize(classScope);
            var statementAIFactoryProviderProp = MakeGetStatementAIFactoryProvider(classScope);
            var statementInformationalsProp = CodegenProperty.MakePropertyNode(
                    typeof(StatementInformationalsRuntime),
                    typeof(StmtClassForgableStmtProvider),
                    CodegenSymbolProviderEmpty.INSTANCE,
                    classScope);
            statementInformationalsProp
                .GetterBlock.BlockReturn(Ref(MEMBERNAME_INFORMATION));

            CodegenStackGenerator.RecursiveBuildStack(
                statementInformationalsProp, 
                "Informationals", 
                methods,
                properties);
            CodegenStackGenerator.RecursiveBuildStack(
                initializeMethod, 
                "Initialize", 
                methods,
                properties);
            CodegenStackGenerator.RecursiveBuildStack(
                statementAIFactoryProviderProp,
                "StatementAIFactoryProvider",
                methods,
                properties);
            CodegenStackGenerator.RecursiveBuildStack(
                ctor,
                "ctor",
                methods,
                properties);

            return new CodegenClass(
                typeof(StatementProvider),
                _namespaceScope.Namespace,
                ClassName,
                classScope,
                members,
                ctor,
                methods,
                properties,
                new EmptyList<CodegenInnerClass>());
        }
Ejemplo n.º 20
0
        public CodegenClass Forge(
            bool includeDebugSymbols,
            bool fireAndForget)
        {
            var properties = new CodegenClassProperties();
            var methods    = new CodegenClassMethods();
            var classScope = new CodegenClassScope(includeDebugSymbols, namespaceScope, className);

            var writeMethod = CodegenMethod
                              .MakeParentNode(typeof(void), typeof(StmtClassForgeableMultiKeySerde), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                              .AddParam(typeof(object), OBJECT_NAME)
                              .AddParam(typeof(DataOutput), OUTPUT_NAME)
                              .AddParam(typeof(byte[]), UNITKEY_NAME)
                              .AddParam(typeof(EventBeanCollatedWriter), WRITER_NAME)
                              .AddThrown(typeof(IOException));

            if (!fireAndForget)
            {
                MakeWriteMethod(writeMethod);
            }

            CodegenStackGenerator.RecursiveBuildStack(writeMethod, "Write", methods, properties);

            var readMethod = CodegenMethod.MakeParentNode(
                typeof(object),
                typeof(StmtClassForgeableMultiKeySerde),
                CodegenSymbolProviderEmpty.INSTANCE,
                classScope)
                             .AddParam(typeof(DataInput), INPUT_NAME)
                             .AddParam(typeof(byte[]), UNITKEY_NAME)
                             .AddThrown(typeof(IOException));

            if (!fireAndForget)
            {
                MakeReadMethod(readMethod);
            }
            else
            {
                readMethod.Block.MethodReturn(ConstantNull());
            }

            CodegenStackGenerator.RecursiveBuildStack(readMethod, "Read", methods, properties);

            IList <CodegenTypedParam> members = new List <CodegenTypedParam>();

            for (var i = 0; i < forges.Length; i++)
            {
                members.Add(new CodegenTypedParam(forges[i].ForgeClassName(), "s" + i));
            }

            var providerCtor = new CodegenCtor(GetType(), ClassName, includeDebugSymbols, EmptyList <CodegenTypedParam> .Instance);

            for (var i = 0; i < forges.Length; i++)
            {
                providerCtor.Block.AssignRef("s" + i, forges[i].Codegen(providerCtor, classScope, null));
            }

            return(new CodegenClass(
                       CodegenClassType.KEYPROVISIONINGSERDE,
                       typeof(DataInputOutputSerde),
                       className,
                       classScope,
                       members,
                       providerCtor,
                       methods,
                       properties,
                       EmptyList <CodegenInnerClass> .Instance));
        }
Ejemplo n.º 21
0
        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);
        }
Ejemplo n.º 22
0
        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);
            }
        }
        public CodegenClass Forge(
            bool includeDebugSymbols,
            bool fireAndForget)
        {
            var makeVirtual = (_desc.OptionalSupertype == null);

            var classScope = new CodegenClassScope(includeDebugSymbols, _namespaceScope, _className);

            // make members
            var members = new List <CodegenTypedParam>();

            // --------------------------------------------------------------------------------
            // Constructor
            // --------------------------------------------------------------------------------

            var ctorParams = new CodegenTypedParam[] {};
            var ctor       = new CodegenCtor(typeof(StmtClassForgeableRSPFactoryProvider), classScope, ctorParams);

            // --------------------------------------------------------------------------------
            // Deserialize(JsonElement)
            // --------------------------------------------------------------------------------
            var deserializeMethod = CodegenMethod
                                    //.MakeParentNode(_underlyingClassName, GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                                    .MakeParentNode(typeof(object), GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope)
                                    .AddParam(typeof(JsonElement), JsonDeserializeRefs.INSTANCE.ElementName);

            deserializeMethod = MakeDeserialize(deserializeMethod, classScope, makeVirtual);

            // --------------------------------------------------------------------------------
            // Properties (property)
            // --------------------------------------------------------------------------------

            var propertiesProp = CodegenProperty
                                 .MakePropertyNode(typeof(ILookup <string, IJsonDeserializer>), GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope);

            propertiesProp = makeVirtual
                                ? propertiesProp.WithVirtual()
                                : propertiesProp.WithOverride();

            propertiesProp.GetterBlock.BlockReturn(ConstantNull());             // TBD

            // --------------------------------------------------------------------------------

            var properties = new CodegenClassProperties();

            // walk methods
            var methods = new CodegenClassMethods();

            //CodegenStackGenerator.RecursiveBuildStack(getResultMethod, "GetResult", methods, properties);
            CodegenStackGenerator.RecursiveBuildStack(deserializeMethod, "Deserialize", methods, properties);
            CodegenStackGenerator.RecursiveBuildStack(propertiesProp, "Properties", methods, properties);

            var clazz = new CodegenClass(
                _classType,
                _className,
                classScope,
                members,
                ctor,
                methods,
                properties,
                EmptyList <CodegenInnerClass> .Instance);

            if (_desc.OptionalSupertype == null)
            {
                clazz.BaseList.AssignType(typeof(JsonCompositeDeserializer));
            }
            else
            {
                clazz.BaseList.AssignBaseType(_desc.OptionalSupertype.Detail.DeserializerClassName);
            }

            return(clazz);
        }