Exemplo n.º 1
0
        public override Type GCode_GetType(CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            if (element == mCtrlvalue_VectorOut)
            {
                return(mValueType);
            }
            else
            {
                foreach (var data in mLinkOutDic)
                {
                    if (data.Element == element)
                    {
                        return(typeof(System.Single));
                    }
                }
                foreach (var data in mLinkInDic)
                {
                    if (data.Element == element)
                    {
                        return(typeof(System.Single));
                    }
                }
            }

            return(mValueType);
        }
Exemplo n.º 2
0
        public override string GCode_GetValueName(CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            string vecName = "vec_" + EngineNS.Editor.Assist.GetValuedGUIDString(Id);

            if (element == null || element == mCtrlvalue_VectorOut)
            {
                return(vecName);
            }
            else
            {
                foreach (var data in mLinkOutDic)
                {
                    if (data.Element == element)
                    {
                        return(vecName + "." + data.KeyName);
                    }
                }
                foreach (var data in mLinkInDic)
                {
                    if (data.Element == element)
                    {
                        return(vecName + "." + data.KeyName);
                    }
                }
            }

            return(vecName);
        }
Exemplo n.º 3
0
        void AddFloatValue(string keyName)
        {
            var inCtrl  = new CodeGenerateSystem.Base.LinkPinControl();
            var outCtrl = new CodeGenerateSystem.Base.LinkPinControl();

            AddFloatValue_WPF(
                (inC) =>
            {
                inCtrl = inC;
            },
                (outC) =>
            {
                outCtrl = outC;
            },
                keyName);
            AddLinkPinInfo($"{keyName}_in", inCtrl, null);
            var linkData_In = new linkData()
            {
                Element = inCtrl,
                KeyName = keyName,
            };

            mLinkInDic.Add(linkData_In);

            AddLinkPinInfo($"{keyName}_out", outCtrl, null);
            var linkData_Out = new linkData()
            {
                Element = outCtrl,
                KeyName = keyName,
            };

            mLinkOutDic.Add(linkData_Out);
        }
        public override CodeExpression GCode_CodeDom_GetValue(CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context, CodeGenerateSystem.Base.GenerateCodeContext_PreNode preNodeContext = null)
        {
            var param      = CSParam as CenterDataValueControlConstructParam;
            var centerData = new CodeFieldReferenceExpression(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "HostActor"), "CenterData");

            return(new CodeGenerateSystem.CodeDom.CodeCastExpression(param.CenterDataWarpper.CenterDataType, centerData));
        }
Exemplo n.º 5
0
        public override string GCode_GetTypeString(CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            if (element == mCtrlClassLinkHandle_Out)
            {
                return(TargetTypeName);
            }

            return("");
        }
Exemplo n.º 6
0
        public override Type GCode_GetType(CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            if (element == mCtrlClassLinkHandle_Out)
            {
                return(EngineNS.Rtti.RttiHelper.GetTypeFromTypeFullName(TargetTypeName));
            }

            return(null);
        }
Exemplo n.º 7
0
        public override string GCode_GetTypeString(CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            if (mInComponentLinks.Contains(element) ||
                mOutComponentLinks.Contains(element))
            {
                return("System.Single");
            }

            return(mValueType.FullName);
        }
Exemplo n.º 8
0
        public override Type GCode_GetType(CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            if (mInComponentLinks.Contains(element) ||
                mOutComponentLinks.Contains(element))
            {
                return(typeof(System.Single));
            }

            return(mValueType);
        }
Exemplo n.º 9
0
 public override string GCode_GetValueName(CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
 {
     if (element == null || element == mCastResultPin)
     {
         return("castValue_" + EngineNS.Editor.Assist.GetValuedGUIDString(Id));
     }
     else
     {
         throw new InvalidOperationException();
     }
 }
Exemplo n.º 10
0
        public override System.CodeDom.CodeExpression GCode_CodeDom_GetValue(CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context, CodeGenerateSystem.Base.GenerateCodeContext_PreNode preNodeContext = null)
        {
            var value1        = new System.CodeDom.CodeVariableReferenceExpression("System.DateTime.Now.Millisecond");
            var value2        = new System.CodeDom.CodePrimitiveExpression(0.001f);
            var arithmeticExp = new System.CodeDom.CodeBinaryOperatorExpression();

            arithmeticExp.Left     = value1;
            arithmeticExp.Right    = value2;
            arithmeticExp.Operator = System.CodeDom.CodeBinaryOperatorType.Multiply;
            return(arithmeticExp);
        }
Exemplo n.º 11
0
        public override System.CodeDom.CodeExpression GCode_CodeDom_GetValue(CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context, CodeGenerateSystem.Base.GenerateCodeContext_PreNode preNodeContext = null)
        {
            if (element == mCtrlClassLinkHandle_Out)
            {
                if (mCtrlClassLinkHandle_In.HasLink)
                {
                    return(new CodeGenerateSystem.CodeDom.CodeCastExpression(GCode_GetType(element, context),
                                                                             mCtrlClassLinkHandle_In.GetLinkedObject(0, true).GCode_CodeDom_GetValue(mCtrlClassLinkHandle_In.GetLinkedPinControl(0, true), context)));
                }
            }

            return(null);
        }
Exemplo n.º 12
0
        public override Type GCode_GetType(CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            var param = CSParam as EnumConstructParam;

            if (element == mCtrlValueLinkHandle)
            {
                if (SelectedIndex >= 0)
                {
                    return(param.EnumType);
                }
            }

            return(null);
        }
Exemplo n.º 13
0
        public virtual CodeGenerateSystem.Base.LinkPinControl GetLinkObjectWithGUID(ref Guid guid)
        {
            CodeGenerateSystem.Base.LinkPinControl retLinkObj = null;

            foreach (var ctrlNode in mCtrlNodeList)
            {
                retLinkObj = ctrlNode.GetLinkPinInfo(ref guid);
                if (retLinkObj != null)
                {
                    return(retLinkObj);
                }
            }

            return(retLinkObj);
        }
Exemplo n.º 14
0
 public override System.CodeDom.CodeExpression GCode_CodeDom_GetValue(CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context, CodeGenerateSystem.Base.GenerateCodeContext_PreNode preNodeContext = null)
 {
     if (element == null || element == mCastResultPin)
     {
         return(new CodeVariableReferenceExpression(GCode_GetValueName(element, context)));
     }
     else if (element == mTargetPin)
     {
         return(mTargetPin.GetLinkedObject(0).GCode_CodeDom_GetValue(mTargetPin.GetLinkedPinControl(0), context));
     }
     else
     {
         throw new InvalidOperationException();
     }
 }
Exemplo n.º 15
0
        public override string GCode_GetTypeString(CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            var param = CSParam as ClassCastControlConstructParam;

            if (element == mCastResultPin)
            {
                return(EngineNS.Rtti.RttiHelper.GetAppTypeString(param.ResultType));
            }
            else if (element == mTargetPin)
            {
                return(EngineNS.Rtti.RttiHelper.GetAppTypeString(param.TargetType));
            }
            else
            {
                throw new InvalidOperationException();
            }
        }
Exemplo n.º 16
0
        public override System.CodeDom.CodeExpression GCode_CodeDom_GetValue(CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context, CodeGenerateSystem.Base.GenerateCodeContext_PreNode preNodeContext = null)
        {
            return(new System.CodeDom.CodeVariableReferenceExpression(GCode_GetValueName(null, context)));
            //var XInputLinkOI = GetLinkPinInfo(ValueInputHandle);
            //if (!XInputLinkOI.bHasLink)
            //{
            //    return new System.CodeDom.CodePrimitiveExpression(0);
            //}

            //// code: EngineNS.BezierCalculate.ValueOnBezier(mBezierPoints_XXX, XPos);
            //return new System.CodeDom.CodeMethodInvokeExpression(
            //                new System.CodeDom.CodeTypeReferenceExpression(typeof(EngineNS.BezierCalculate)),
            //                "ValueOnBezier",
            //                new System.CodeDom.CodeExpression[]{
            //                    new System.CodeDom.CodeFieldReferenceExpression(new System.CodeDom.CodeThisReferenceExpression(), StaticBezierPointsName),
            //                    XInputLinkOI.GetLinkObject(0, true).GCode_CodeDom_GetValue(XInputLinkOI.GetLinkElement(0, true))
            //                });
        }
Exemplo n.º 17
0
        public override CodeExpression GCode_CodeDom_GetValue(CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context, CodeGenerateSystem.Base.GenerateCodeContext_PreNode preNodeContext = null)
        {
            if (element == mCtrlvalue_VectorOut)
            {
                return(new System.CodeDom.CodeVariableReferenceExpression(GCode_GetValueName(null, context)));
            }
            else
            {
                foreach (var data in mLinkOutDic)
                {
                    if (data.Element == element)
                    {
                        return(new System.CodeDom.CodeVariableReferenceExpression(GCode_GetValueName(null, context) + "." + data.KeyName));
                    }
                }
            }

            return(base.GCode_CodeDom_GetValue(element, context));
        }
Exemplo n.º 18
0
        string GetValuePureName(CodeGenerateSystem.Base.LinkPinControl element)
        {
            if (element == mCtrlValueOutR)
            {
                return("Red");
            }
            else if (element == mCtrlValueOutG)
            {
                return("Green");
            }
            else if (element == mCtrlValueOutB)
            {
                return("Blue");
            }
            else if (element == mCtrlValueOutA)
            {
                return("Alpha");
            }

            return("");
        }
Exemplo n.º 19
0
        public override CodeExpression GCode_CodeDom_GetValue(CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context, CodeGenerateSystem.Base.GenerateCodeContext_PreNode preNodeContext = null)
        {
            if (element == mCtrlValueOutR)
            {
                return(new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(GCode_GetValueName(null, context)), "Red"));
            }
            else if (element == mCtrlValueOutG)
            {
                return(new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(GCode_GetValueName(null, context)), "Green"));
            }
            else if (element == mCtrlValueOutB)
            {
                return(new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(GCode_GetValueName(null, context)), "Blue"));
            }
            else if (element == mCtrlValueOutA)
            {
                return(new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(GCode_GetValueName(null, context)), "Alpha"));
            }

            return(new CodeVariableReferenceExpression(GCode_GetValueName(null, context)));
        }
Exemplo n.º 20
0
        public override string GCode_GetValueName(CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            string strValueName = "";

            if (string.IsNullOrEmpty(NodeName) || NodeName == CodeGenerateSystem.Program.NodeDefaultName)
            {
                strValueName = "color_" + EngineNS.Editor.Assist.GetValuedGUIDString(Id);
            }
            else
            {
                strValueName = NodeName;
            }

            var name = GetValuePureName(element);

            if (!string.IsNullOrEmpty(name))
            {
                strValueName += "." + name;
            }

            return(strValueName);
        }
Exemplo n.º 21
0
        public override System.CodeDom.CodeExpression GCode_CodeDom_GetValue(CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context, CodeGenerateSystem.Base.GenerateCodeContext_PreNode preNodeContext = null)
        {
            var param   = CSParam as EnumConstructParam;
            var newType = EngineNS.CEngine.Instance.MacrossDataManager.MacrossScripAssembly.GetType(param.EnumType.FullName);

            string str = "";

            if (mFlag)
            {
                var enumParam = CSParam as EnumConstructParam;
                foreach (var val in enumParam.FlagEnumValues)
                {
                    var name = System.Enum.GetName(newType, val);
                    str += name + "|";
                }
                str = str.TrimEnd('|');
            }
            else
            {
                str = SelectedItem.ToString();
            }
            return(new System.CodeDom.CodeFieldReferenceExpression(new System.CodeDom.CodeTypeReferenceExpression(param.EnumType), SelectedItem.ToString()));
        }
Exemplo n.º 22
0
        public override string GCode_GetValueName(CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            var strValueName = "InverterControlResult_" + EngineNS.Editor.Assist.GetValuedGUIDString(Id);

            return(strValueName);
        }
Exemplo n.º 23
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());
            }
        }
Exemplo n.º 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)
        {
            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);
            }
        }
Exemplo n.º 25
0
 public override System.CodeDom.CodeExpression GCode_CodeDom_GetValue(CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context, CodeGenerateSystem.Base.GenerateCodeContext_PreNode preNodeContext = null)
 {
     return(new System.CodeDom.CodeVariableReferenceExpression(GCode_GetValueName(null, context)));
 }
Exemplo n.º 26
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);
             }
         }
     }
 }
Exemplo n.º 27
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);
                    }
                }
            }
        }
Exemplo n.º 28
0
 public override Type GCode_GetType(CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
 {
     return(typeof(System.Boolean));
 }
Exemplo n.º 29
0
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(CodeTypeDeclaration codeClass, CodeStatementCollection codeStatementCollection, CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            var strValueName = GCode_GetValueName(null, context);

            if (!context.Method.Statements.Contains(mVariableDeclaration))
            {
                mVariableDeclaration.Type           = new CodeTypeReference(mValueType);
                mVariableDeclaration.Name           = strValueName;
                mVariableDeclaration.InitExpression = new CodeObjectCreateExpression(mValueType, new CodePrimitiveExpression(1.0f),
                                                                                     new CodePrimitiveExpression(1.0f),
                                                                                     new CodePrimitiveExpression(1.0f),
                                                                                     new CodePrimitiveExpression(1.0f));
                context.Method.Statements.Insert(0, mVariableDeclaration);
            }


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

                var express = mCtrlValueIn.GetLinkedObject(0, true).GCode_CodeDom_GetValue(mCtrlValueIn.GetLinkedPinControl(0, true), context);
                GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, express, strValueName);
            }
            else
            {
            }
            if (mCtrlValueIn.HasLink)
            {
                //if (!mCtrlvalue_ColorIn.GetLinkedObject(0, true).IsOnlyReturnValue)
                //    await mCtrlvalue_ColorIn.GetLinkedObject(0, true).GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, element, context);

                //var assignStatement = new System.CodeDom.CodeAssignStatement(
                //                                                        new System.CodeDom.CodeVariableReferenceExpression(strValueName),
                //                                                        mCtrlvalue_ColorIn.GetLinkedObject(0, true).GCode_CodeDom_GetValue(mCtrlvalue_ColorIn.GetLinkedPinControl(0, true), context));
                //codeStatementCollection.Add(assignStatement);
            }

            // r、g、b、a有链接的情况
            //foreach (var link in mInComponentLinks)
            //{
            //    if (link.HasLink)
            //    {
            //        if (!link.GetLinkedObject(0, true).IsOnlyReturnValue)
            //            await link.GetLinkedObject(0, true).GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, element, context);

            //        var fieldRef = new CodeFieldReferenceExpression();
            //        fieldRef.TargetObject = new CodeVariableReferenceExpression(strValueName);
            //        fieldRef.FieldName = GetValuePureName(link);
            //        var statValAss = new CodeAssignStatement();
            //        statValAss.Left = fieldRef;
            //        statValAss.Right = new CodeGenerateSystem.CodeDom.CodeCastExpression(typeof(float), link.GetLinkedObject(0, true).GCode_CodeDom_GetValue(link.GetLinkedPinControl(0, true), context));
            //        codeStatementCollection.Add(statValAss);
            //    }
            //}

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

            CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugCodes, mCtrlvalue_ColorOut.GetLinkPinKeyName(),
                                                                   new CodeVariableReferenceExpression(GCode_GetValueName(mCtrlvalue_ColorOut, context)),
                                                                   GCode_GetTypeString(mCtrlvalue_ColorOut, context), context);
            CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugCodes, mCtrlValueOutR.GetLinkPinKeyName(),
                                                                   new CodeVariableReferenceExpression(GCode_GetValueName(mCtrlValueOutR, context)),
                                                                   GCode_GetTypeString(mCtrlValueOutR, context), context);
            CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugCodes, mCtrlValueOutG.GetLinkPinKeyName(),
                                                                   new CodeVariableReferenceExpression(GCode_GetValueName(mCtrlValueOutG, context)),
                                                                   GCode_GetTypeString(mCtrlValueOutG, context), context);
            CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugCodes, mCtrlValueOutB.GetLinkPinKeyName(),
                                                                   new CodeVariableReferenceExpression(GCode_GetValueName(mCtrlValueOutB, context)),
                                                                   GCode_GetTypeString(mCtrlValueOutB, context), context);
            CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugCodes, mCtrlValueOutA.GetLinkPinKeyName(),
                                                                   new CodeVariableReferenceExpression(GCode_GetValueName(mCtrlValueOutA, context)),
                                                                   GCode_GetTypeString(mCtrlValueOutA, context), context);
            CodeDomNode.BreakPoint.EndMacrossDebugCodeStatements(codeStatementCollection, debugCodes);
        }
Exemplo n.º 30
0
 public override string GCode_GetTypeString(CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
 {
     return("System.Boolean");
 }