示例#1
0
        public static System.CodeDom.CodeStatementCollection BeginMacrossDebugCodeStatments(System.CodeDom.CodeStatementCollection codes)
        {
            var retValue = new System.CodeDom.CodeStatementCollection();

            codes.Add(new System.CodeDom.CodeSnippetStatement("#if MacrossDebug"));
            return(retValue);
        }
        /// <summary>
        /// Serializes the specified object into a CodeDOM object.
        /// </summary>
        /// <param name="manager">A serialization manager interface that is used during the deserialization process.</param>
        /// <param name="value">The object to serialize.</param>
        /// <returns>A CodeDOM object representing the object that has been serialized.</returns>
        public override object Serialize(IDesignerSerializationManager manager, object value)
        {
            // Set serialization flag
            bool oldSerializationFlag = false;
            SerializationStatus oldSerializationStatus = SerializationStatus.None;

            Chart chart = value as Chart;

            if (chart != null)
            {
                oldSerializationFlag   = chart.serializing;
                oldSerializationStatus = chart.serializationStatus;

                chart.serializing         = true;
                chart.serializationStatus = SerializationStatus.Saving;
            }

            // Serialize object using the base class serializer
            object            result         = null;
            CodeDomSerializer baseSerializer = (CodeDomSerializer)manager.GetSerializer(typeof(Chart).BaseType, typeof(CodeDomSerializer));

            if (baseSerializer != null)
            {
                result = baseSerializer.Serialize(manager, value);

                System.CodeDom.CodeStatementCollection statements = result as System.CodeDom.CodeStatementCollection;

                // Sustom serialization of the DataSource property
                if (statements != null && chart != null)
                {
                    // Check if DataSource property is set
                    if (chart.DataSource != null && chart.DataSource is String && ((String)chart.DataSource) != "(none)")
                    {
                        // Add assignment statement for the DataSource property
                        System.CodeDom.CodeExpression targetObject =
                            base.SerializeToExpression(manager, value);
                        if (targetObject != null)
                        {
                            System.CodeDom.CodeAssignStatement assignStatement = new System.CodeDom.CodeAssignStatement(
                                new System.CodeDom.CodePropertyReferenceExpression(targetObject, "DataSource"),
                                new System.CodeDom.CodePropertyReferenceExpression(new System.CodeDom.CodeThisReferenceExpression(), (String)chart.DataSource));
                            statements.Add(assignStatement);
                        }
                    }
                }
            }

            // Clear serialization flag
            if (chart != null)
            {
                chart.serializing         = oldSerializationFlag;
                chart.serializationStatus = oldSerializationStatus;
            }

            return(result);
        }
示例#3
0
        public static void GetSetDataValueCodeStatement(System.CodeDom.CodeStatementCollection codeStatementCollection, string name, System.CodeDom.CodeExpression valueExp, Type valueType)
        {
            var stat = new System.CodeDom.CodeAssignStatement(
                valueExp,
                new CodeGenerateSystem.CodeDom.CodeCastExpression(
                    valueType,
                    new System.CodeDom.CodeFieldReferenceExpression(
                        new System.CodeDom.CodeVariableReferenceExpression("mDebuggerContext"), name)
                    ));

            codeStatementCollection.Add(stat);
        }
示例#4
0
        public static void GetGatherDataValueCodeStatement(System.CodeDom.CodeStatementCollection codeStatementCollection, string name, System.CodeDom.CodeExpression valueExp, string valueType, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            // 指针类型不生成收集代码
            if (valueType.Contains("*"))
            {
                return;
            }

            // 收集debug用数据
            if (!mDebugValueFieldDic.ContainsKey(name))
            {
                var field = new System.CodeDom.CodeMemberField(valueType, name);
                field.Attributes = System.CodeDom.MemberAttributes.Public;
                context.ClassContext.DebugContextClass.Members.Add(field);
                mDebugValueFieldDic[name] = field;
            }

            // 代码: Debugger.XXX = XXX;
            codeStatementCollection.Add(new System.CodeDom.CodeAssignStatement(
                                            new System.CodeDom.CodeFieldReferenceExpression(new System.CodeDom.CodeVariableReferenceExpression("mDebuggerContext"), name),
                                            //new CodeGenerateSystem.CodeDom.CodeCastExpression(valueType, valueExp)));
                                            valueExp));

            //// 代码:EngineNS.Editor.Runner.RunnerManager.Instance.GatherDataValue(id, name, value, valueType, canChangeValue)
            //var methodExp = new System.CodeDom.CodeExpressionStatement(
            //                new System.CodeDom.CodeMethodInvokeExpression(
            //                        new System.CodeDom.CodeVariableReferenceExpression("EngineNS.Editor.Runner.RunnerManager.Instance"),
            //                        "GatherDataValue",
            //                        new System.CodeDom.CodeExpression[] {
            //                                                new System.CodeDom.CodeSnippetExpression("EngineNS.Rtti.RttiHelper.GuidTryParse(\"" + id.ToString() + "\")"),
            //                                                new System.CodeDom.CodePrimitiveExpression(name),
            //                                                new CodeGenerateSystem.CodeDom.CodeCastExpression(valueType, valueExp),
            //                                                new System.CodeDom.CodeTypeOfExpression(valueType),
            //                                                new System.CodeDom.CodePrimitiveExpression(canChangeValueWhenDebug),
            //                        }));
            //codeStatementCollection.Add(methodExp);
        }
示例#5
0
 public void ExportClientServerCode(ActionBranch currentAction, ActionBranch nextAction, ILimnorCodeCompiler compiler, MathExp.IMethodCompile methodToCompile, System.CodeDom.CodeMemberMethod method, System.CodeDom.CodeStatementCollection statements, bool debug, System.Collections.Specialized.StringCollection jsCode, System.Collections.Specialized.StringCollection methodCode, LimnorDesigner.MethodBuilder.JsMethodCompiler data)
 {
 }
示例#6
0
 public void ExportCode(ActionBranch currentAction, ActionBranch nextAction, ILimnorCodeCompiler compiler, MathExp.IMethodCompile methodToCompile, System.CodeDom.CodeMemberMethod method, System.CodeDom.CodeStatementCollection statements, bool debug)
 {
 }
示例#7
0
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(System.CodeDom.CodeTypeDeclaration codeClass, System.CodeDom.CodeStatementCollection codeStatementCollection, CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            GetBezierPointsFromCtrl();

            if (!codeClass.Members.Contains(mBezierPointsField))
            {
                // code: private static System.Collections.Generic.List<EngineNS.BezierPointBase> mBezierPoints_XXX = new System.Collections.Generic.List<EngineNS.BezierPointBase>(new BezierPoint[] { new EngineNS.BezierPointBase(), new EngineNS.BezierPointBase() });
                mBezierPointsField.Type       = new System.CodeDom.CodeTypeReference(BezierPointsListType);
                mBezierPointsField.Name       = StaticBezierPointsName;
                mBezierPointsField.Attributes = System.CodeDom.MemberAttributes.Private;
                var arrayCreateExp = new System.CodeDom.CodeArrayCreateExpression();
                arrayCreateExp.CreateType = new System.CodeDom.CodeTypeReference(typeof(EngineNS.BezierPointBase));
                foreach (var bPt in mBezierPoints)
                {
                    var newBPT = new System.CodeDom.CodeObjectCreateExpression();
                    newBPT.CreateType = new System.CodeDom.CodeTypeReference(typeof(EngineNS.BezierPointBase));
                    newBPT.Parameters.Add(new System.CodeDom.CodeObjectCreateExpression(typeof(EngineNS.Vector2),
                                                                                        new System.CodeDom.CodeExpression[] {
                        new System.CodeDom.CodePrimitiveExpression(bPt.Position.X),
                        new System.CodeDom.CodePrimitiveExpression(bPt.Position.Y)
                    }));
                    newBPT.Parameters.Add(new System.CodeDom.CodeObjectCreateExpression(typeof(EngineNS.Vector2),
                                                                                        new System.CodeDom.CodeExpression[] {
                        new System.CodeDom.CodePrimitiveExpression(bPt.ControlPoint.X),
                        new System.CodeDom.CodePrimitiveExpression(bPt.ControlPoint.Y)
                    }));
                    arrayCreateExp.Initializers.Add(newBPT);
                }
                mBezierPointsField.InitExpression = new System.CodeDom.CodeObjectCreateExpression(BezierPointsListType, arrayCreateExp);
                codeClass.Members.Add(mBezierPointsField);
            }

            // 判断5个输入链接是否需要生成代码
            if (mCtrlValueInputHandle.HasLink)
            {
                if (!mCtrlValueInputHandle.GetLinkedObject(0, true).IsOnlyReturnValue)
                {
                    await mCtrlValueInputHandle.GetLinkedObject(0, true).GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, mCtrlValueInputHandle.GetLinkedPinControl(0, true), context);
                }
            }

            if (mCtrlValueYMaxInputHandle.HasLink)
            {
                if (!mCtrlValueYMaxInputHandle.GetLinkedObject(0, true).IsOnlyReturnValue)
                {
                    await mCtrlValueYMaxInputHandle.GetLinkedObject(0, true).GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, mCtrlValueYMaxInputHandle.GetLinkedPinControl(0, true), context);
                }
            }

            if (mCtrlValueYMinInputHandle.HasLink)
            {
                if (!mCtrlValueYMinInputHandle.GetLinkedObject(0, true).IsOnlyReturnValue)
                {
                    await mCtrlValueYMinInputHandle.GetLinkedObject(0, true).GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, mCtrlValueYMinInputHandle.GetLinkedPinControl(0, true), context);
                }
            }

            if (mCtrlValueXMaxInputHandle.HasLink)
            {
                if (!mCtrlValueXMaxInputHandle.GetLinkedObject(0, true).IsOnlyReturnValue)
                {
                    await mCtrlValueXMaxInputHandle.GetLinkedObject(0, true).GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, mCtrlValueXMaxInputHandle.GetLinkedPinControl(0, true), context);
                }
            }

            if (mCtrlValueXMinInputHandle.HasLink)
            {
                if (!mCtrlValueXMinInputHandle.GetLinkedObject(0, true).IsOnlyReturnValue)
                {
                    await mCtrlValueXMinInputHandle.GetLinkedObject(0, true).GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, mCtrlValueXMinInputHandle.GetLinkedPinControl(0, true), context);
                }
            }

            if (mCtrlValueXLoopHandle.HasLink)
            {
                if (!mCtrlValueXLoopHandle.GetLinkedObject(0, true).IsOnlyReturnValue)
                {
                    await mCtrlValueXLoopHandle.GetLinkedObject(0, true).GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, mCtrlValueXLoopHandle.GetLinkedPinControl(0, true), context);
                }
            }

            // 自身代码生成
            if (!context.Method.Statements.Contains(mVariableDeclaration))
            {
                // 声明
                mVariableDeclaration.Type           = new System.CodeDom.CodeTypeReference(typeof(double));
                mVariableDeclaration.Name           = GCode_GetValueName(null, context);
                mVariableDeclaration.InitExpression = CodeGenerateSystem.Program.GetDefaultValueExpressionFromType(typeof(double));
                context.Method.Statements.Insert(0, mVariableDeclaration);
            }

            var assignExp = new System.CodeDom.CodeAssignStatement();

            assignExp.Left = new System.CodeDom.CodeVariableReferenceExpression(GCode_GetValueName(null, context));
            var classType = mTemplateClassInstance.GetType();

            System.CodeDom.CodeExpression minXExp, maxXExp, minYExp, maxYExp, isXLoopExp;
            if (mCtrlValueXMinInputHandle.HasLink)
            {
                minXExp = mCtrlValueXMinInputHandle.GetLinkedObject(0, true).GCode_CodeDom_GetValue(mCtrlValueXMinInputHandle.GetLinkedPinControl(0, true), context);
            }
            else
            {
                var pro  = classType.GetProperty("XMin");
                var xMin = pro.GetValue(mTemplateClassInstance);
                minXExp = new System.CodeDom.CodePrimitiveExpression(xMin);
            }

            if (mCtrlValueXMaxInputHandle.HasLink)
            {
                maxXExp = mCtrlValueXMaxInputHandle.GetLinkedObject(0, true).GCode_CodeDom_GetValue(mCtrlValueXMaxInputHandle.GetLinkedPinControl(0, true), context);
            }
            else
            {
                var pro  = classType.GetProperty("XMax");
                var xMax = pro.GetValue(mTemplateClassInstance);
                maxXExp = new System.CodeDom.CodePrimitiveExpression(xMax);
            }

            if (mCtrlValueYMinInputHandle.HasLink)
            {
                minYExp = mCtrlValueYMinInputHandle.GetLinkedObject(0, true).GCode_CodeDom_GetValue(mCtrlValueYMinInputHandle.GetLinkedPinControl(0, true), context);
            }
            else
            {
                var pro  = classType.GetProperty("YMin");
                var yMin = pro.GetValue(mTemplateClassInstance);
                minYExp = new System.CodeDom.CodePrimitiveExpression(yMin);
            }

            if (mCtrlValueYMaxInputHandle.HasLink)
            {
                maxYExp = mCtrlValueYMaxInputHandle.GetLinkedObject(0, true).GCode_CodeDom_GetValue(mCtrlValueYMaxInputHandle.GetLinkedPinControl(0, true), context);
            }
            else
            {
                var pro  = classType.GetProperty("YMax");
                var yMax = pro.GetValue(mTemplateClassInstance);
                maxYExp = new System.CodeDom.CodePrimitiveExpression(yMax);
            }

            if (mCtrlValueXLoopHandle.HasLink)
            {
                isXLoopExp = mCtrlValueXLoopHandle.GetLinkedObject(0, true).GCode_CodeDom_GetValue(mCtrlValueXLoopHandle.GetLinkedPinControl(0, true), context);
            }
            else
            {
                var pro     = classType.GetProperty("XLoop");
                var isXLoop = pro.GetValue(mTemplateClassInstance);
                isXLoopExp = new System.CodeDom.CodePrimitiveExpression(isXLoop);
            }

            // code: EngineNS.BezierCalculate.ValueOnBezier(mBezierPoints_XXX, XPos);
            assignExp.Right = new CodeGenerateSystem.CodeDom.CodeMethodInvokeExpression(
                new System.CodeDom.CodeTypeReferenceExpression(typeof(EngineNS.BezierCalculate)),
                "ValueOnBezier",
                new System.CodeDom.CodeExpression[] {
                new System.CodeDom.CodeVariableReferenceExpression(StaticBezierPointsName),                                                         // bezierPtList
                mCtrlValueInputHandle.GetLinkedObject(0, true).GCode_CodeDom_GetValue(mCtrlValueInputHandle.GetLinkedPinControl(0, true), context), // xValue
                minXExp, maxXExp, minYExp, maxYExp,
                new System.CodeDom.CodePrimitiveExpression(0),                                                                                      // MinBezierX
                new System.CodeDom.CodePrimitiveExpression(mBezierWidth),                                                                           // MaxBezierX
                new System.CodeDom.CodePrimitiveExpression(0),                                                                                      // MinBezierY
                new System.CodeDom.CodePrimitiveExpression(mBezierHeight),                                                                          // MaxBezierY
                isXLoopExp                                                                                                                          // bLoopX
            });

            codeStatementCollection.Add(assignExp);

            // 收集用于调试的数据的代码
            var debugCodes = CodeDomNode.BreakPoint.BeginMacrossDebugCodeStatments(codeStatementCollection);

            CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugCodes, this.mCtrlValueInputHandle.GetLinkPinKeyName(),
                                                                   mCtrlValueInputHandle.GetLinkedObject(0, true).GCode_CodeDom_GetValue(mCtrlValueInputHandle.GetLinkedPinControl(0, true), context),
                                                                   mCtrlValueInputHandle.GetLinkedObject(0, true).GCode_GetTypeString(mCtrlValueInputHandle.GetLinkedPinControl(0, true), context), context);
            CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugCodes, mCtrlValueOutputHandle.GetLinkPinKeyName(),
                                                                   assignExp.Left, GCode_GetTypeString(null, context), context);
            CodeDomNode.BreakPoint.EndMacrossDebugCodeStatements(codeStatementCollection, debugCodes);
        }
示例#8
0
 public void Compile(LimnorDesigner.Action.ActionBranch currentAction, LimnorDesigner.Action.ActionBranch nextAction, ILimnorCodeCompiler compiler, MathExp.IMethodCompile methodToCompile, System.CodeDom.CodeMemberMethod method, System.CodeDom.CodeStatementCollection statements, System.CodeDom.CodeExpressionCollection parameters, IObjectPointer returnReceiver, bool debug)
 {
     throw new NotImplementedException();
 }
示例#9
0
 public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(System.CodeDom.CodeTypeDeclaration codeClass, System.CodeDom.CodeStatementCollection codeStatementCollection, CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
 {
     if (element == mCtrlClassLinkHandle_Out)
     {
         if (mCtrlClassLinkHandle_In.HasLink)
         {
             if (!mCtrlClassLinkHandle_In.GetLinkedObject(0, true).IsOnlyReturnValue)
             {
                 await mCtrlClassLinkHandle_In.GetLinkedObject(0, true).GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, mCtrlClassLinkHandle_In.GetLinkedPinControl(0, true), context);
             }
         }
     }
 }
示例#10
0
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(System.CodeDom.CodeTypeDeclaration codeClass, System.CodeDom.CodeStatementCollection codeStatementCollection, CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            if (!mCtrlValue1.HasLink)
            {
                return;
            }

            // 计算结果
            if (!context.Method.Statements.Contains(mVariableDeclaration))
            {
                var valueType = GCode_GetTypeString(mCtrlResultLink, context);
                var type      = EngineNS.Rtti.RttiHelper.GetTypeFromTypeFullName(valueType);
                mVariableDeclaration = new System.CodeDom.CodeVariableDeclarationStatement(
                    valueType,
                    GCode_GetValueName(mCtrlResultLink, context),
                    CodeGenerateSystem.Program.GetDefaultValueExpressionFromType(type));
                context.Method.Statements.Insert(0, mVariableDeclaration);
            }

            // 参数1
            var linkObj1 = mCtrlValue1.GetLinkedObject(0, true);
            var linkElm1 = mCtrlValue1.GetLinkedPinControl(0, true);

            if (!linkObj1.IsOnlyReturnValue)
            {
                await linkObj1.GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, linkElm1, context);
            }

            System.CodeDom.CodeExpression valueExp1 = null;
            var valueType1    = typeof(bool);
            var valueType1Str = valueType1.FullName;

            if (linkObj1.Pin_UseOrigionParamName(linkElm1))
            {
                if (linkElm1.GetLinkType(0, true) == CodeGenerateSystem.Base.enLinkType.Bool)
                {
                    var condition = new System.CodeDom.CodeBinaryOperatorExpression(linkObj1.GCode_CodeDom_GetValue(linkElm1, context),
                                                                                    System.CodeDom.CodeBinaryOperatorType.IdentityEquality,
                                                                                    new System.CodeDom.CodePrimitiveExpression(false));
                    valueExp1 = condition;
                }
                else if (linkElm1.GetLinkType(0, true) == CodeGenerateSystem.Base.enLinkType.Class)
                {
                    var condition = new System.CodeDom.CodeBinaryOperatorExpression(linkObj1.GCode_CodeDom_GetValue(linkElm1, context),
                                                                                    System.CodeDom.CodeBinaryOperatorType.IdentityEquality,
                                                                                    new System.CodeDom.CodePrimitiveExpression(null));
                    valueExp1 = condition;
                }
            }
            else
            {
                var tempValueName1 = "InverterControl_" + EngineNS.Editor.Assist.GetValuedGUIDString(this.Id) + "_Value1";
                if (!context.Method.Statements.Contains(mVariableDeclarationStatement_Value1))
                {
                    mVariableDeclarationStatement_Value1 = new System.CodeDom.CodeVariableDeclarationStatement(
                        valueType1Str,
                        tempValueName1,
                        CodeGenerateSystem.Program.GetDefaultValueExpressionFromType(EngineNS.Rtti.RttiHelper.GetTypeFromTypeFullName(valueType1Str)));
                    context.Method.Statements.Insert(0, mVariableDeclarationStatement_Value1);
                }


                if (linkElm1.GetLinkType(0, true) == CodeGenerateSystem.Base.enLinkType.Bool)
                {
                    var condition = new System.CodeDom.CodeBinaryOperatorExpression(linkObj1.GCode_CodeDom_GetValue(linkElm1, context),
                                                                                    System.CodeDom.CodeBinaryOperatorType.IdentityEquality,
                                                                                    new System.CodeDom.CodePrimitiveExpression(false));
                    codeStatementCollection.Add(new System.CodeDom.CodeAssignStatement(
                                                    new System.CodeDom.CodeTypeReferenceExpression(tempValueName1),
                                                    condition));
                }
                else if (linkElm1.GetLinkType(0, true) == CodeGenerateSystem.Base.enLinkType.Class)
                {
                    var condition = new System.CodeDom.CodeBinaryOperatorExpression(linkObj1.GCode_CodeDom_GetValue(linkElm1, context),
                                                                                    System.CodeDom.CodeBinaryOperatorType.IdentityEquality,
                                                                                    new System.CodeDom.CodePrimitiveExpression(null));
                    codeStatementCollection.Add(new System.CodeDom.CodeAssignStatement(
                                                    new System.CodeDom.CodeTypeReferenceExpression(tempValueName1),
                                                    condition));
                }
                valueExp1 = new System.CodeDom.CodeVariableReferenceExpression(tempValueName1);
            }
            //var valueExp1 = linkObj1.GCode_CodeDom_GetValue(linkElm1, context);

            // 收集用于调试的数据的代码
            var debugCodes = CodeDomNode.BreakPoint.BeginMacrossDebugCodeStatments(codeStatementCollection);

            if (linkObj1.Pin_UseOrigionParamName(linkElm1))
            {
                CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugCodes, this.mCtrlValue1.GetLinkPinKeyName(), valueExp1, valueType1Str, context);
            }
            else
            {
                CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugCodes, this.mCtrlValue1.GetLinkPinKeyName(), valueExp1, valueType1Str, context);
            }
            // 调试用代码
            var breakCondStatement = CodeDomNode.BreakPoint.BreakCodeStatement(codeClass, debugCodes, HostNodesContainer.GUID, Id);

            // 设置数据代码
            if (!linkObj1.Pin_UseOrigionParamName(this.mCtrlValue1))
            {
                CodeDomNode.BreakPoint.GetSetDataValueCodeStatement(breakCondStatement.TrueStatements, this.mCtrlValue1.GetLinkPinKeyName(), valueExp1, valueType1);
            }
            CodeDomNode.BreakPoint.EndMacrossDebugCodeStatements(codeStatementCollection, debugCodes);

            if (element == mCtrlResultLink)
            {
                // 创建结果并赋值
                if (mAssignStatement == null)
                {
                    mAssignStatement      = new System.CodeDom.CodeAssignStatement();
                    mAssignStatement.Left = new System.CodeDom.CodeVariableReferenceExpression(GCode_GetValueName(null, context));
                }
                mAssignStatement.Right = valueExp1;

                if (codeStatementCollection.Contains(mAssignStatement))
                {
                    //var assign = new System.CodeDom.CodeAssignStatement(GCode_CodeDom_GetValue(null) , InverterControlExp);
                    //codeStatementCollection.Add(assign);
                }
                else
                {
                    codeStatementCollection.Add(mAssignStatement);
                }

                debugCodes = CodeDomNode.BreakPoint.BeginMacrossDebugCodeStatments(codeStatementCollection);
                CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugCodes, mCtrlResultLink.GetLinkPinKeyName(), GCode_CodeDom_GetValue(mCtrlResultLink, context), GCode_GetTypeString(mCtrlResultLink, context), context);
                CodeDomNode.BreakPoint.EndMacrossDebugCodeStatements(codeStatementCollection, debugCodes);
            }
        }
 public void ExportClientServerCode(LimnorDesigner.Action.ActionBranch currentAction, LimnorDesigner.Action.ActionBranch nextAction, ILimnorCodeCompiler compiler, MathExp.IMethodCompile methodToCompile, System.CodeDom.CodeMemberMethod method, System.CodeDom.CodeStatementCollection statements, bool debug, System.Collections.Specialized.StringCollection jsCode, System.Collections.Specialized.StringCollection methodCode, JsMethodCompiler data)
 {
     throw new NotImplementedException();
 }
示例#12
0
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(System.CodeDom.CodeTypeDeclaration codeClass, System.CodeDom.CodeStatementCollection codeStatementCollection, CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            if (!mCtrlValue1.HasLink || !mCtrlValue2.HasLink)
            {
                return;
            }

            // 计算结果
            if (!context.Method.Statements.Contains(mVariableDeclaration))
            {
                var valueType = GCode_GetTypeString(mCtrlResultLink, context);
                var type      = EngineNS.Rtti.RttiHelper.GetTypeFromTypeFullName(valueType);
                mVariableDeclaration = new System.CodeDom.CodeVariableDeclarationStatement(
                    valueType,
                    GCode_GetValueName(mCtrlResultLink, context),
                    CodeGenerateSystem.Program.GetDefaultValueExpressionFromType(type));
                context.Method.Statements.Insert(0, mVariableDeclaration);
            }

            // 参数1
            var linkObj1 = mCtrlValue1.GetLinkedObject(0, true);
            var linkElm1 = mCtrlValue1.GetLinkedPinControl(0, true);

            if (!linkObj1.IsOnlyReturnValue)
            {
                await linkObj1.GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, linkElm1, context);
            }

            System.CodeDom.CodeExpression valueExp1 = null;
            var valueType1Str = linkObj1.GCode_GetTypeString(linkElm1, context);
            var valueType1    = linkObj1.GCode_GetType(linkElm1, context);

            if (CSParam.ConstructParam == "&&" || CSParam.ConstructParam == "||")
            {
                valueType1Str = "System.Boolean";
                valueType1    = typeof(bool);
            }
            if (linkObj1.Pin_UseOrigionParamName(linkElm1))
            {
                if (linkElm1.GetLinkType(0, true) == CodeGenerateSystem.Base.enLinkType.Bool)
                {
                    valueExp1 = linkObj1.GCode_CodeDom_GetValue(linkElm1, context);
                }
                else if (linkElm1.GetLinkType(0, true) == CodeGenerateSystem.Base.enLinkType.Class)
                {
                    var condition = new System.CodeDom.CodeBinaryOperatorExpression(linkObj1.GCode_CodeDom_GetValue(linkElm1, context),
                                                                                    System.CodeDom.CodeBinaryOperatorType.IdentityInequality,
                                                                                    new System.CodeDom.CodePrimitiveExpression(null));
                    valueExp1 = condition;
                }
                else
                {
                    valueExp1 = linkObj1.GCode_CodeDom_GetValue(linkElm1, context);
                }
            }
            else
            {
                var tempValueName1 = "arithmetic_" + EngineNS.Editor.Assist.GetValuedGUIDString(this.Id) + "_Value1";
                if (!context.Method.Statements.Contains(mVariableDeclarationStatement_Value1))
                {
                    mVariableDeclarationStatement_Value1 = new System.CodeDom.CodeVariableDeclarationStatement(
                        valueType1Str,
                        tempValueName1,
                        CodeGenerateSystem.Program.GetDefaultValueExpressionFromType(EngineNS.Rtti.RttiHelper.GetTypeFromTypeFullName(valueType1Str)));
                    context.Method.Statements.Insert(0, mVariableDeclarationStatement_Value1);
                }


                if (linkElm1.GetLinkType(0, true) == CodeGenerateSystem.Base.enLinkType.Bool)
                {
                    codeStatementCollection.Add(new System.CodeDom.CodeAssignStatement(
                                                    new System.CodeDom.CodeTypeReferenceExpression(tempValueName1),
                                                    linkObj1.GCode_CodeDom_GetValue(linkElm1, context)));
                }
                else if (linkElm1.GetLinkType(0, true) == CodeGenerateSystem.Base.enLinkType.Class)
                {
                    var condition = new System.CodeDom.CodeBinaryOperatorExpression(linkObj1.GCode_CodeDom_GetValue(linkElm1, context),
                                                                                    System.CodeDom.CodeBinaryOperatorType.IdentityInequality,
                                                                                    new System.CodeDom.CodePrimitiveExpression(null));
                    codeStatementCollection.Add(new System.CodeDom.CodeAssignStatement(
                                                    new System.CodeDom.CodeTypeReferenceExpression(tempValueName1),
                                                    condition));
                }
                else
                {
                    codeStatementCollection.Add(new System.CodeDom.CodeAssignStatement(
                                                    new System.CodeDom.CodeTypeReferenceExpression(tempValueName1),
                                                    linkObj1.GCode_CodeDom_GetValue(linkElm1, context)));
                }
                valueExp1 = new System.CodeDom.CodeVariableReferenceExpression(tempValueName1);
            }
            //var valueExp1 = linkObj1.GCode_CodeDom_GetValue(linkElm1, context);

            // 参数2
            var linkObj2 = mCtrlValue2.GetLinkedObject(0, true);
            var linkElm2 = mCtrlValue2.GetLinkedPinControl(0, true);

            if (!linkObj2.IsOnlyReturnValue)
            {
                await linkObj2.GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, linkElm2, context);
            }

            System.CodeDom.CodeExpression valueExp2 = null;
            var valueType2Str = linkObj2.GCode_GetTypeString(linkElm2, context);
            var valueType2    = linkObj2.GCode_GetType(linkElm2, context);

            if (CSParam.ConstructParam == "&&" || CSParam.ConstructParam == "||")
            {
                valueType2Str = "System.Boolean";
                valueType2    = typeof(bool);
            }
            if (linkObj2.Pin_UseOrigionParamName(linkElm2))
            {
                if (linkElm2.GetLinkType(0, true) == CodeGenerateSystem.Base.enLinkType.Bool)
                {
                    valueExp2 = linkObj2.GCode_CodeDom_GetValue(linkElm2, context);
                }
                else if (linkElm2.GetLinkType(0, true) == CodeGenerateSystem.Base.enLinkType.Class)
                {
                    var condition = new System.CodeDom.CodeBinaryOperatorExpression(linkObj2.GCode_CodeDom_GetValue(linkElm2, context),
                                                                                    System.CodeDom.CodeBinaryOperatorType.IdentityInequality,
                                                                                    new System.CodeDom.CodePrimitiveExpression(null));
                    valueExp2 = condition;
                }
                else
                {
                    valueExp2 = linkObj2.GCode_CodeDom_GetValue(linkElm2, context);
                }
            }
            else
            {
                var tempValueName2 = "arithmetic_" + EngineNS.Editor.Assist.GetValuedGUIDString(this.Id) + "_Value2";
                if (!context.Method.Statements.Contains(mVariableDeclarationStatement_Value2))
                {
                    mVariableDeclarationStatement_Value2 = new System.CodeDom.CodeVariableDeclarationStatement(
                        valueType2Str,
                        tempValueName2,
                        CodeGenerateSystem.Program.GetDefaultValueExpressionFromType(EngineNS.Rtti.RttiHelper.GetTypeFromTypeFullName(valueType2Str)));
                    context.Method.Statements.Insert(0, mVariableDeclarationStatement_Value2);
                }


                if (linkElm2.GetLinkType(0, true) == CodeGenerateSystem.Base.enLinkType.Bool)
                {
                    codeStatementCollection.Add(new System.CodeDom.CodeAssignStatement(
                                                    new System.CodeDom.CodeTypeReferenceExpression(tempValueName2),
                                                    linkObj2.GCode_CodeDom_GetValue(linkElm2, context)));
                }
                else if (linkElm2.GetLinkType(0, true) == CodeGenerateSystem.Base.enLinkType.Class)
                {
                    var condition = new System.CodeDom.CodeBinaryOperatorExpression(linkObj2.GCode_CodeDom_GetValue(linkElm2, context),
                                                                                    System.CodeDom.CodeBinaryOperatorType.IdentityInequality,
                                                                                    new System.CodeDom.CodePrimitiveExpression(null));
                    codeStatementCollection.Add(new System.CodeDom.CodeAssignStatement(
                                                    new System.CodeDom.CodeTypeReferenceExpression(tempValueName2),
                                                    condition));
                }
                else
                {
                    codeStatementCollection.Add(new System.CodeDom.CodeAssignStatement(
                                                    new System.CodeDom.CodeTypeReferenceExpression(tempValueName2),
                                                    linkObj2.GCode_CodeDom_GetValue(linkElm2, context)));
                }
                valueExp2 = new System.CodeDom.CodeVariableReferenceExpression(tempValueName2);
            }
            //var valueExp2 = linkObj2.GCode_CodeDom_GetValue(linkElm2, context);

            // 运算
            var arithmeticExp = new System.CodeDom.CodeBinaryOperatorExpression();

            arithmeticExp.Left  = valueExp1;
            arithmeticExp.Right = valueExp2;
            switch (CSParam.ConstructParam)
            {
            case "+":
                arithmeticExp.Operator = System.CodeDom.CodeBinaryOperatorType.Add;
                break;

            case "-":
                arithmeticExp.Operator = System.CodeDom.CodeBinaryOperatorType.Subtract;
                break;

            case "×":
                arithmeticExp.Operator = System.CodeDom.CodeBinaryOperatorType.Multiply;
                break;

            case "÷":
                arithmeticExp.Operator = System.CodeDom.CodeBinaryOperatorType.Divide;
                break;

            case "&&":
                arithmeticExp.Operator = System.CodeDom.CodeBinaryOperatorType.BooleanAnd;
                break;

            case "||":
                arithmeticExp.Operator = System.CodeDom.CodeBinaryOperatorType.BooleanOr;
                break;

            case "&":
                arithmeticExp.Operator = System.CodeDom.CodeBinaryOperatorType.BitwiseAnd;
                break;

            case "|":
                arithmeticExp.Operator = System.CodeDom.CodeBinaryOperatorType.BitwiseOr;
                break;
            }

            // 收集用于调试的数据的代码
            var debugCodes = CodeDomNode.BreakPoint.BeginMacrossDebugCodeStatments(codeStatementCollection);

            if (linkObj1.Pin_UseOrigionParamName(linkElm1))
            {
                CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugCodes, this.mCtrlValue1.GetLinkPinKeyName(), valueExp1, valueType1Str, context);
            }
            else
            {
                CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugCodes, this.mCtrlValue1.GetLinkPinKeyName(), valueExp1, valueType1Str, context);
            }
            if (linkObj2.Pin_UseOrigionParamName(linkElm2))
            {
                CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugCodes, this.mCtrlValue2.GetLinkPinKeyName(), valueExp2, valueType2Str, context);
            }
            else
            {
                CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugCodes, this.mCtrlValue2.GetLinkPinKeyName(), valueExp2, valueType2Str, context);
            }
            // 调试用代码
            var breakCondStatement = CodeDomNode.BreakPoint.BreakCodeStatement(codeClass, debugCodes, HostNodesContainer.GUID, Id);

            // 设置数据代码
            if (!linkObj1.Pin_UseOrigionParamName(this.mCtrlValue1))
            {
                CodeDomNode.BreakPoint.GetSetDataValueCodeStatement(breakCondStatement.TrueStatements, this.mCtrlValue1.GetLinkPinKeyName(), valueExp1, valueType1);
            }
            if (!linkObj2.Pin_UseOrigionParamName(this.mCtrlValue2))
            {
                CodeDomNode.BreakPoint.GetSetDataValueCodeStatement(breakCondStatement.TrueStatements, this.mCtrlValue2.GetLinkPinKeyName(), valueExp2, valueType2);
            }
            CodeDomNode.BreakPoint.EndMacrossDebugCodeStatements(codeStatementCollection, debugCodes);

            if (element == mCtrlResultLink)
            {
                // 创建结果并赋值
                if (mAssignStatement == null)
                {
                    mAssignStatement      = new System.CodeDom.CodeAssignStatement();
                    mAssignStatement.Left = new System.CodeDom.CodeVariableReferenceExpression(GCode_GetValueName(null, context));
                }
                mAssignStatement.Right = arithmeticExp;

                if (codeStatementCollection.Contains(mAssignStatement))
                {
                    //var assign = new System.CodeDom.CodeAssignStatement(GCode_CodeDom_GetValue(null) , arithmeticExp);
                    //codeStatementCollection.Add(assign);
                }
                else
                {
                    codeStatementCollection.Add(mAssignStatement);
                }

                debugCodes = CodeDomNode.BreakPoint.BeginMacrossDebugCodeStatments(codeStatementCollection);
                CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugCodes, mCtrlResultLink.GetLinkPinKeyName(), GCode_CodeDom_GetValue(mCtrlResultLink, context), GCode_GetTypeString(mCtrlResultLink, context), context);
                CodeDomNode.BreakPoint.EndMacrossDebugCodeStatements(codeStatementCollection, debugCodes);
            }
        }
示例#13
0
        public static System.CodeDom.CodeConditionStatement BreakCodeStatement(System.CodeDom.CodeTypeDeclaration codeClass, System.CodeDom.CodeStatementCollection codeStatementCollection, Guid debuggerId, Guid breakId)
        {
            if (debuggerId == Guid.Empty || breakId == Guid.Empty)
            {
                throw new InvalidOperationException();
            }
            //var ret = new System.CodeDom.CodeConditionStatement();
            //ret.Condition = new System.CodeDom.CodePrimitiveExpression(false);
            //return ret;

            var breakEnalbeVariableName = "BreakEnable_" + EngineNS.Editor.Assist.GetValuedGUIDString(breakId);

            System.CodeDom.CodeMemberField member;
            if (!CodeMemberFieldDic.TryGetValue(breakId, out member))
            {
                // 代码:public static bool BreakEnable_XXXXX = false;
                member                = new System.CodeDom.CodeMemberField(typeof(bool), breakEnalbeVariableName);
                member.Attributes     = System.CodeDom.MemberAttributes.Public | System.CodeDom.MemberAttributes.Static;
                member.InitExpression = new System.CodeDom.CodePrimitiveExpression(false);
                codeClass.Members.Add(member);
                CodeMemberFieldDic.Add(breakId, member);
            }
            else
            {
                if (!codeClass.Members.Contains(member))
                {
                    codeClass.Members.Add(member);
                }
            }

            // 代码: if(BreakEnable_XXXXX)
            //       {
            //          var breakContext = new EngineNS.Editor.Runner.RunnerManager.BreakContext();
            //
            //          EngineNS.Editor.Runner.RunnerManager.Instance.Break(breakContext);
            //       }
            var conditionSt = new System.CodeDom.CodeConditionStatement();

            conditionSt.Condition = new System.CodeDom.CodeVariableReferenceExpression(breakEnalbeVariableName);

            var breakContextVarName = "breakContext";
            var breakContextType    = typeof(EngineNS.Editor.Runner.RunnerManager.BreakContext);

            conditionSt.TrueStatements.Add(new System.CodeDom.CodeVariableDeclarationStatement(breakContextType, breakContextVarName, new System.CodeDom.CodeObjectCreateExpression(breakContextType, new System.CodeDom.CodeExpression[] { })));
            conditionSt.TrueStatements.Add(new System.CodeDom.CodeAssignStatement(
                                               new System.CodeDom.CodeFieldReferenceExpression(
                                                   new System.CodeDom.CodeVariableReferenceExpression(breakContextVarName), "ThisObject"),
                                               new System.CodeDom.CodeThisReferenceExpression()));

            conditionSt.TrueStatements.Add(new System.CodeDom.CodeAssignStatement(
                                               new System.CodeDom.CodeFieldReferenceExpression(
                                                   new System.CodeDom.CodeVariableReferenceExpression(breakContextVarName), "DebuggerId"),
                                               new System.CodeDom.CodeSnippetExpression("EngineNS.Rtti.RttiHelper.GuidTryParse(\"" + debuggerId.ToString() + "\")")));
            conditionSt.TrueStatements.Add(new System.CodeDom.CodeAssignStatement(
                                               new System.CodeDom.CodeFieldReferenceExpression(
                                                   new System.CodeDom.CodeVariableReferenceExpression(breakContextVarName), "BreakId"),
                                               new System.CodeDom.CodeSnippetExpression("EngineNS.Rtti.RttiHelper.GuidTryParse(\"" + breakId.ToString() + "\")")));
            conditionSt.TrueStatements.Add(new System.CodeDom.CodeAssignStatement(
                                               new System.CodeDom.CodeFieldReferenceExpression(
                                                   new System.CodeDom.CodeVariableReferenceExpression(breakContextVarName), "ClassName"),
                                               new System.CodeDom.CodePrimitiveExpression(codeClass.Name)));
            conditionSt.TrueStatements.Add(new System.CodeDom.CodeAssignStatement(
                                               new System.CodeDom.CodeFieldReferenceExpression(
                                                   new System.CodeDom.CodeVariableReferenceExpression(breakContextVarName), "ValueContext"),
                                               new System.CodeDom.CodeVariableReferenceExpression("mDebuggerContext")));


            var methodExpState = new System.CodeDom.CodeExpressionStatement(
                new CodeGenerateSystem.CodeDom.CodeMethodInvokeExpression(
                    new System.CodeDom.CodeVariableReferenceExpression("EngineNS.Editor.Runner.RunnerManager.Instance"),
                    "Break",
                    new System.CodeDom.CodeExpression[] { new System.CodeDom.CodeVariableReferenceExpression(breakContextVarName) }));

            conditionSt.TrueStatements.Add(methodExpState);
            codeStatementCollection.Add(conditionSt);

            return(conditionSt);
        }
示例#14
0
 public static void EndMacrossDebugCodeStatements(System.CodeDom.CodeStatementCollection codes, System.CodeDom.CodeStatementCollection debugCodes)
 {
     codes.AddRange(debugCodes);
     codes.Add(new System.CodeDom.CodeSnippetStatement("#endif"));
 }
示例#15
0
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(System.CodeDom.CodeTypeDeclaration codeClass, System.CodeDom.CodeStatementCollection codeStatementCollection, CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            if (!mCtrlParamLink_1.HasLink || !mCtrlParamLink_2.HasLink)
            {
                return;
            }

            if (!mCtrlParamLink_1.GetLinkedObject(0, true).IsOnlyReturnValue)
            {
                await mCtrlParamLink_1.GetLinkedObject(0, true).GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, mCtrlParamLink_1.GetLinkedPinControl(0, true), context);
            }

            if (!mCtrlParamLink_2.GetLinkedObject(0, true).IsOnlyReturnValue)
            {
                await mCtrlParamLink_2.GetLinkedObject(0, true).GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, mCtrlParamLink_2.GetLinkedPinControl(0, true), context);
            }

            var param1Exp = mCtrlParamLink_1.GetLinkedObject(0, true).GCode_CodeDom_GetValue(mCtrlParamLink_1.GetLinkedPinControl(0, true), context);
            var param2Exp = mCtrlParamLink_2.GetLinkedObject(0, true).GCode_CodeDom_GetValue(mCtrlParamLink_2.GetLinkedPinControl(0, true), context);

            var type1 = mCtrlParamLink_1.GetLinkedObject(0, true).GCode_GetType(mCtrlParamLink_1.GetLinkedPinControl(0, true), context);
            var type2 = mCtrlParamLink_2.GetLinkedObject(0, true).GCode_GetType(mCtrlParamLink_2.GetLinkedPinControl(0, true), context);

            if (type1.IsEnum && !type2.IsEnum)
            {
                param1Exp = new CodeGenerateSystem.CodeDom.CodeCastExpression(type2, param1Exp);
            }
            else if (!type1.IsEnum && type2.IsEnum)
            {
                param2Exp = new CodeGenerateSystem.CodeDom.CodeCastExpression(type1, param2Exp);
            }

            var compareExp = new System.CodeDom.CodeBinaryOperatorExpression();

            compareExp.Left  = param1Exp;
            compareExp.Right = param2Exp;

            switch (CSParam.ConstructParam)
            {
            case ">":
                compareExp.Operator = System.CodeDom.CodeBinaryOperatorType.GreaterThan;
                break;

            case "=":
            case "==":
                compareExp.Operator = System.CodeDom.CodeBinaryOperatorType.ValueEquality;
                break;

            case "<":
                compareExp.Operator = System.CodeDom.CodeBinaryOperatorType.LessThan;
                break;

            case "≥":
                compareExp.Operator = System.CodeDom.CodeBinaryOperatorType.GreaterThanOrEqual;
                break;

            case "≤":
                compareExp.Operator = System.CodeDom.CodeBinaryOperatorType.LessThanOrEqual;
                break;

            case "≠":
                compareExp.Operator = System.CodeDom.CodeBinaryOperatorType.IdentityInequality;
                break;
            }

            if (!context.Method.Statements.Contains(mVariableDeclarationStatement))
            {
                mVariableDeclarationStatement = new System.CodeDom.CodeVariableDeclarationStatement(typeof(bool), GCode_GetValueName(null, context));
                context.Method.Statements.Insert(0, mVariableDeclarationStatement);
            }
            if (!codeStatementCollection.Contains(mVariableAssignStatement))
            {
                //mVariableDeclarationStatement = new System.CodeDom.CodeVariableDeclarationStatement(typeof(bool), GCode_GetValueName(null, context), compareExp);
                mVariableAssignStatement = new System.CodeDom.CodeAssignStatement(GCode_CodeDom_GetValue(null, context), compareExp);
                codeStatementCollection.Add(mVariableAssignStatement);

                // 收集用于调试的数据的代码
                var debugCodes = CodeDomNode.BreakPoint.BeginMacrossDebugCodeStatments(codeStatementCollection);
                CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugCodes, mCtrlresultHandle.GetLinkPinKeyName(), GCode_CodeDom_GetValue(null, context), GCode_GetTypeString(null, context), context);
                CodeDomNode.BreakPoint.EndMacrossDebugCodeStatements(codeStatementCollection, debugCodes);
            }
        }
示例#16
0
 public System.CodeDom.CodeExpression GetReferenceCode(MathExp.IMethodCompile method, System.CodeDom.CodeStatementCollection statements, bool forValue)
 {
     return(null);
 }
 public void ExportCode(LimnorDesigner.Action.ActionBranch currentAction, LimnorDesigner.Action.ActionBranch nextAction, ILimnorCodeCompiler compiler, MathExp.IMethodCompile methodToCompile, System.CodeDom.CodeMemberMethod method, System.CodeDom.CodeStatementCollection statements, bool debug)
 {
     throw new NotImplementedException();
 }
示例#18
0
 protected void GenerateStatements(System.CodeDom.CodeStatementCollection stms)
 {
     Contract.Requires(stms != null);
 }
示例#19
0
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(System.CodeDom.CodeTypeDeclaration codeClass, System.CodeDom.CodeStatementCollection codeStatementCollection, CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            MethodInvokeParameterControl retCtrl = null;
            Dictionary <CodeGenerateSystem.Base.BaseNodeControl, System.CodeDom.CodeExpression> paramCodeExps = new Dictionary <CodeGenerateSystem.Base.BaseNodeControl, System.CodeDom.CodeExpression>();
            var rcParam = CSParam as ReturnCustomConstructParam;

            if (rcParam.MethodInfo.IsAsync)
            {
                // 异步不能有out,只能有一个返回值
                if (mChildNodes.Count == 1)
                {
                    retCtrl = mChildNodes[0] as MethodInvokeParameterControl;
                }
            }
            else
            {
                foreach (var paramNode in mChildNodes)
                {
                    if (paramNode is MethodInvokeParameterControl)
                    {
                        var pm    = paramNode as MethodInvokeParameterControl;
                        var param = pm.CSParam as MethodInvokeParameterControl.MethodInvokeParameterConstructionParams;
                        if (param.ParamInfo.ParamName == "Return")
                        {
                            retCtrl = pm;
                            continue;
                        }
                        if (pm.HasLink())
                        {
                            await pm.GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, pm.ParamPin, context);

                            var exp = new CodeGenerateSystem.CodeDom.CodeCastExpression(param.ParamInfo.ParameterType, pm.GCode_CodeDom_GetValue(pm.ParamPin, context));
                            paramCodeExps[paramNode] = exp;
                            codeStatementCollection.Add(new System.CodeDom.CodeAssignStatement(
                                                            new System.CodeDom.CodeVariableReferenceExpression(param.ParamInfo.ParamName),
                                                            exp));
                        }
                        else if (mTemplateClassInstance != null)
                        {
                            var    proInfo = mTemplateClassInstance.GetType().GetProperty(param.ParamInfo.ParamName);
                            object proValue;
                            if (proInfo == null)
                            {
                                proValue = CodeGenerateSystem.Program.GetDefaultValueFromType(param.ParamInfo.ParameterType);
                            }
                            else
                            {
                                proValue = proInfo.GetValue(mTemplateClassInstance);
                            }
                            var valueExp = Program.GetValueCode(codeStatementCollection, param.ParamInfo.ParameterType, proValue);
                            paramCodeExps[paramNode] = valueExp;
                            codeStatementCollection.Add(new System.CodeDom.CodeAssignStatement(new System.CodeDom.CodeVariableReferenceExpression(param.ParamInfo.ParamName), valueExp));
                        }
                    }
                    else
                    {
                        throw new InvalidOperationException();
                    }
                }
            }

            if (retCtrl != null)
            {
                if (retCtrl.HasLink())
                {
                    await retCtrl.GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, retCtrl.ParamPin, context);
                }

                System.CodeDom.CodeExpression retExp = null;
                if (retCtrl.HasLink())
                {
                    var retStatement = new System.CodeDom.CodeMethodReturnStatement();
                    retExp = retCtrl.GCode_CodeDom_GetValue(retCtrl.ParamPin, context);
                    paramCodeExps[retCtrl] = retExp;
                }
                else if (mTemplateClassInstance != null)
                {
                    var    param   = retCtrl.CSParam as MethodInvokeParameterControl.MethodInvokeParameterConstructionParams;
                    var    proInfo = mTemplateClassInstance.GetType().GetProperty(param.ParamInfo.ParamName);
                    object proValue;
                    if (proInfo == null)
                    {
                        proValue = CodeGenerateSystem.Program.GetDefaultValueFromType(param.ParamInfo.ParameterType);
                    }
                    else
                    {
                        proValue = proInfo.GetValue(mTemplateClassInstance);
                    }
                    retExp = Program.GetValueCode(codeStatementCollection, param.ParamInfo.ParameterType, proValue);
                    paramCodeExps[retCtrl] = retExp;
                }

                #region Debug
                var debugCodes = CodeDomNode.BreakPoint.BeginMacrossDebugCodeStatments(codeStatementCollection);
                foreach (var paramNode in mChildNodes)
                {
                    if (paramNode is MethodInvokeParameterControl)
                    {
                        var pm = paramNode as MethodInvokeParameterControl;
                        System.CodeDom.CodeExpression exp;
                        if (paramCodeExps.TryGetValue(paramNode, out exp))
                        {
                            CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugCodes, pm.ParamPin.GetLinkPinKeyName(), exp, pm.GCode_GetTypeString(pm.ParamPin, context), context);
                        }
                    }
                    else
                    {
                        throw new InvalidOperationException("未实现");
                    }
                }
                var breakCondStatement = CodeDomNode.BreakPoint.BreakCodeStatement(codeClass, debugCodes, HostNodesContainer.GUID, Id);
                CodeDomNode.BreakPoint.EndMacrossDebugCodeStatements(codeStatementCollection, debugCodes);
                #endregion

                codeStatementCollection.Add(new System.CodeDom.CodeMethodReturnStatement(retExp));
            }
            else
            {
                #region Debug
                var debugCodes         = CodeDomNode.BreakPoint.BeginMacrossDebugCodeStatments(codeStatementCollection);
                var breakCondStatement = CodeDomNode.BreakPoint.BreakCodeStatement(codeClass, debugCodes, HostNodesContainer.GUID, Id);
                CodeDomNode.BreakPoint.EndMacrossDebugCodeStatements(codeStatementCollection, debugCodes);
                #endregion
                codeStatementCollection.Add(new System.CodeDom.CodeMethodReturnStatement());
            }
        }
 public void AddRange(System.CodeDom.CodeStatementCollection value)
 {
 }
示例#21
0
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(System.CodeDom.CodeTypeDeclaration codeClass, System.CodeDom.CodeStatementCollection codeStatementCollection, CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            if (element == mCtrlMethodLink_Pre)
            {
                // 正常逻辑执行代码
                if (mCtrlValueElement.HasLink && mCtrlSetValueElement.HasLink)
                {
                    var codeAss = new System.CodeDom.CodeAssignStatement();
                    codeAss.Left = mCtrlValueElement.GetLinkedObject(0, false).GCode_CodeDom_GetValue(mCtrlValueElement.GetLinkedPinControl(0, false), context);

                    if (!mCtrlSetValueElement.GetLinkedObject(0, true).IsOnlyReturnValue)
                    {
                        await mCtrlSetValueElement.GetLinkedObject(0, true).GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, mCtrlSetValueElement.GetLinkedPinControl(0, true), context);
                    }

                    string valueTypeStr = mCtrlSetValueElement.GetLinkedObject(0, true).GCode_GetTypeString(mCtrlSetValueElement.GetLinkedPinControl(0, true), context);
                    var    valueType    = mCtrlSetValueElement.GetLinkedObject(0, true).GCode_GetType(mCtrlSetValueElement.GetLinkedPinControl(0, true), context);
                    var    tempValName  = "assign_" + EngineNS.Editor.Assist.GetValuedGUIDString(this.Id);
                    if (!context.Method.Statements.Contains(mVariableDeclarationStatement))
                    {
                        var type = EngineNS.Rtti.RttiHelper.GetTypeFromTypeFullName(valueTypeStr);
                        mVariableDeclarationStatement = new System.CodeDom.CodeVariableDeclarationStatement(
                            valueTypeStr,
                            tempValName,
                            CodeGenerateSystem.Program.GetDefaultValueExpressionFromType(type));
                        context.Method.Statements.Insert(0, mVariableDeclarationStatement);
                    }
                    var assignStatement = new System.CodeDom.CodeAssignStatement(
                        new System.CodeDom.CodeVariableReferenceExpression(tempValName),
                        mCtrlSetValueElement.GetLinkedObject(0, true).GCode_CodeDom_GetValue(mCtrlSetValueElement.GetLinkedPinControl(0, true), context));
                    codeStatementCollection.Add(assignStatement);

                    // 收集用于调试的数据的代码
                    var debugCodes = CodeDomNode.BreakPoint.BeginMacrossDebugCodeStatments(codeStatementCollection);

                    CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugCodes, mCtrlSetValueElement.GetLinkPinKeyName(),
                                                                           new System.CodeDom.CodeVariableReferenceExpression(tempValName),
                                                                           valueTypeStr, context);
                    // 调试用代码
                    var breakCondStatement = CodeDomNode.BreakPoint.BreakCodeStatement(codeClass, debugCodes, HostNodesContainer.GUID, Id);
                    // 设置数据代码
                    CodeDomNode.BreakPoint.GetSetDataValueCodeStatement(breakCondStatement.TrueStatements, mCtrlSetValueElement.GetLinkPinKeyName(),
                                                                        new System.CodeDom.CodeVariableReferenceExpression(tempValName),
                                                                        valueType);
                    if (!mCtrlValueElement.GetLinkedObject(0, false).IsOnlyReturnValue)
                    {
                        await mCtrlValueElement.GetLinkedObject(0, false).GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, element, context);
                    }
                    codeAss.Right = new CodeGenerateSystem.CodeDom.CodeCastExpression(mCtrlValueElement.GetLinkedObject(0, false).GCode_GetType(mCtrlValueElement.GetLinkedPinControl(0, false), context),
                                                                                      new System.CodeDom.CodeVariableReferenceExpression(tempValName));

                    codeStatementCollection.Add(codeAss);

                    // 收集结果代码
                    CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugCodes, mCtrlValueElement.GetLinkPinKeyName(),
                                                                           mCtrlValueElement.GetLinkedObject(0, false).GCode_CodeDom_GetValue(mCtrlValueElement.GetLinkedPinControl(0, false), context),
                                                                           mCtrlValueElement.GetLinkedObject(0, false).GCode_GetTypeString(mCtrlValueElement.GetLinkedPinControl(0, false), context), context);
                    CodeDomNode.BreakPoint.EndMacrossDebugCodeStatements(codeStatementCollection, debugCodes);
                }

                if (context.GenerateNext)
                {
                    if (mCtrlMethodLink_Next.HasLink)
                    {
                        await mCtrlMethodLink_Next.GetLinkedObject(0, false).GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, mCtrlMethodLink_Next.GetLinkedPinControl(0, false), context);
                    }
                }
            }
        }
 public CodeStatementCollection(System.CodeDom.CodeStatementCollection value)
 {
 }
示例#23
0
        public override void GCode_CodeDom_GenerateCode(System.CodeDom.CodeTypeDeclaration codeClass, System.CodeDom.CodeStatementCollection codeStatementCollection, FrameworkElement element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            if (element == UpLink || element == null)
            {
                foreach (MethodControl mc in mChildNodes)
                {
                    CodeGenerateSystem.Base.LinkObjInfo info = mc.GetLinkObjInfo(mc.methodEll);
                    if (!info.HasLink)
                    {
                        continue;
                    }

                    info.GetLinkObject(0, true).GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, info.GetLinkElement(0, true), context);
                }
            }
        }
示例#24
0
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(System.CodeDom.CodeTypeDeclaration codeClass, System.CodeDom.CodeStatementCollection codeStatementCollection, CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            var codeSC = codeStatementCollection;

            foreach (ConditionControl cc in mChildNodes)
            {
                await cc.GCode_CodeDom_GenerateCode(codeClass, codeSC, null, context);

                codeSC = cc.ElseStatementCollection;
            }

            if (mCtrlMethodLink_False.HasLink)
            {
                await mCtrlMethodLink_False.GetLinkedObject(0, false).GCode_CodeDom_GenerateCode(codeClass, codeSC, mCtrlMethodLink_False.GetLinkedPinControl(0, false), context);
            }
        }
示例#25
0
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(System.CodeDom.CodeTypeDeclaration codeClass, System.CodeDom.CodeStatementCollection codeStatementCollection, CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var retStatement = new System.CodeDom.CodeMethodReturnStatement();

            codeStatementCollection.Add(new System.CodeDom.CodeSnippetExpression(mValueStr));
        }
 // Methods
 public abstract virtual void Serialize(IDesignerSerializationManager manager, object value, System.ComponentModel.MemberDescriptor descriptor, System.CodeDom.CodeStatementCollection statements)
 {
 }