当前位置: 首页>>代码示例>>C#>>正文


C# IMethodReference.ToString方法代码示例

本文整理汇总了C#中IMethodReference.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# IMethodReference.ToString方法的具体用法?C# IMethodReference.ToString怎么用?C# IMethodReference.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMethodReference的用法示例。


在下文中一共展示了IMethodReference.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ResolveMethodThrowing

        public static IMethodDefinition ResolveMethodThrowing(IMethodReference method)
        {
            IMethodDefinition result = method.ResolvedMethod;
            if (result == Dummy.Method ||
                result == null)
            {
                throw new Exception(String.Format("Cannot resolve member '{0}'. Are all dependent assemblies loaded?", method.ToString()));
            }

            Debug.Assert(!result.GetType().Name.Contains("Dummy"));
            return result;
        }
开发者ID:dsgouda,项目名称:buildtools,代码行数:12,代码来源:Util.cs

示例2: VisitMethodCall

        /// <summary>
        /// Detects calls to memory contracts methods and stores the needed information for the instrumentation
        /// </summary>
        public void VisitMethodCall(IMethodReference methodReference, IEnumerable<IExpression> arguments)
        {
            System.Diagnostics.Debug.WriteLine("Visiting method call: " + methodReference.ToString());

            if (methodReference.ContainingType.ToString() == "Contracts.Contract.Memory")
            {
                switch (methodReference.Name.Value)
                {
                    #region Tmp
                    case "Tmp":
                        {
                            if (methodReference is Microsoft.Cci.MutableCodeModel.GenericMethodInstanceReference)
                            {
                                var methodToCall = (Microsoft.Cci.MutableCodeModel.GenericMethodInstanceReference)methodReference;
                                var argsIt = arguments.GetEnumerator();
                                argsIt.MoveNext();
                                var limit = argsIt.Current;
                                var cond = (IExpression)null;
                                if (argsIt.MoveNext())
                                {
                                    cond = argsIt.Current;
                                }

                                var tmpField = AddTmpContractToMethod(_currentMethod, methodToCall.GenericArguments[0], limit, cond);

                                if (!_currentInstrInfo.TmpFieldsToInstrument.ContainsKey(tmpField))
                                {
                                    _currentInstrInfo.TmpFieldsToInstrument.Add(tmpField, new List<IStatement>());
                                }
                            }
                        }
                        break;
                    #endregion
                    #region DestTmp
                    case "DestTmp":
                        {
                            _currentInstrInfo.StoreNextTmp = true;
                            var argsIt = arguments.GetEnumerator();
                            _currentInstrInfo.TrustNextAnnotation = argsIt.MoveNext() &&
                                                                    argsIt.Current is CompileTimeConstant &&
                                                                    (int)((CompileTimeConstant)argsIt.Current).Value == 1;
                            _currentInstrInfo.Instrument = true;

                            //if inside loop and we have all the necessary invariants
                            if (_loopNestLevel > 0 && _loopInvariants.TrueForAll(s => s.Count > 0))
                            {
                                _currentInstrInfo.Instrument = false;
                                _currentInstrInfo.NextStmtPoly = PolytopesCalculator.CountPoints(JoinLoopInvariants(_loopInvariants), GetMethodFreeVars(_currentMethod));
                                //if the count failed, do regular instrumentation
                                if (_currentInstrInfo.NextStmtPoly == null)
                                {
                                    _currentInstrInfo.Instrument = true;
                                }
                            }
                        }
                        break;
                    #endregion
                    #region Rsd
                    case "Rsd":
                        {
                            if (methodReference is Microsoft.Cci.MutableCodeModel.GenericMethodInstanceReference)
                            {
                                var methodToCall = (Microsoft.Cci.MutableCodeModel.GenericMethodInstanceReference)methodReference;
                                var argsIt = arguments.GetEnumerator();
                                argsIt.MoveNext();
                                var rsdName = "";
                                if (argsIt.Current is BoundExpression)
                                {
                                    rsdName = ((BoundExpression)argsIt.Current).Definition.ToString();
                                }
                                argsIt.MoveNext();
                                var limit = argsIt.Current;
                                var cond = (IExpression)null;
                                if (argsIt.MoveNext())
                                {
                                    cond = argsIt.Current;
                                }

                                var rsdField = AddRsdContractToMethod(_currentMethod, methodToCall.GenericArguments[0], rsdName, limit, cond);

                                if (!_currentInstrInfo.RsdFieldsToInstrument.ContainsKey(rsdField))
                                {
                                    _currentInstrInfo.RsdFieldsToInstrument.Add(rsdField, new List<IStatement>());
                                }
                            }
                        }
                        break;
                    #endregion
                    #region DestRsd
                    case "DestRsd":
                        {
                            var argsIt = arguments.GetEnumerator();
                            argsIt.MoveNext();
                            var rsdName = "";
                            if (argsIt.Current is BoundExpression)
                            {
                                rsdName = ((BoundExpression)argsIt.Current).Definition.ToString();
//.........这里部分代码省略.........
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:101,代码来源:MemoryVisitor.cs


注:本文中的IMethodReference.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。