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 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 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); } }
protected abstract void GenerateVariableDeclarationStatement(System.CodeDom.CodeVariableDeclarationStatement e);
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); } }