Example #1
0
        public static void MakeSubstitutionSetter(
            CodegenNamespaceScope packageScope,
            CodegenBlock enclosingBlock,
            CodegenClassScope classScope)
        {
            var assignLambda = new CodegenExpressionLambda(enclosingBlock)
                .WithParam<StatementAIFactoryAssignments>("assignments");

            //var assignMethod = CodegenMethod
            //    .MakeParentNode(typeof(void), typeof(StmtClassForgableStmtFields), classScope)
            //    .AddParam(typeof(StatementAIFactoryAssignments), "assignments");
            //assignerSetterClass.AddMethod("Assign", assignMethod);

            assignLambda.Block.ExprDotMethod(Ref("statementFields"), "Assign", Ref("assignments"));
            //assignMethod.Block.StaticMethod(packageScope.FieldsClassName, "Assign", Ref("assignments"));

            var setValueMethod = new CodegenExpressionLambda(enclosingBlock)
                .WithParam(typeof(int), "index")
                .WithParam(typeof(object), "value");
            //assignerSetterClass.AddMethod("SetValue", setValueMethod);

            var assignerSetterClass = NewInstance<ProxyFAFQueryMethodAssignerSetter>(
                assignLambda, setValueMethod);

            //var assignerSetterClass = NewAnonymousClass(enclosingBlock, typeof(FAFQueryMethodAssignerSetter));
            enclosingBlock.ReturnMethodOrBlock(assignerSetterClass);

            CodegenSubstitutionParamEntry.CodegenSetterBody(
                classScope, setValueMethod.Block, Ref("statementFields"));
        }
Example #2
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>());
        }