Exemplo n.º 1
0
        /// <summary>
        /// Gives the string representing the location
        /// </summary>
        /// <returns></returns>
        //^ [Confined, MustOverride]
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat(CultureInfo.InvariantCulture, "ILLocation({0},0x{1})", _methodDefinition.ToString(), _offset.ToString("X8", CultureInfo.InvariantCulture));
            return(sb.ToString());
        }
Exemplo n.º 2
0
 public static MethodDefinition FindMatchingMethod(TypeDefinition tdef, IMethodDefinition item)
 {
     return(tdef.Methods.FirstOrDefault(m => m.ToString() == item.ToString()));
 }
Exemplo n.º 3
0
 private static string GetMethodSignature(IMethodDefinition pDefinition)
 {
     // TODO: Fix for ByReference parameters that may make this not unique
     return(pDefinition.ToString());
 }
Exemplo n.º 4
0
 public override string ToString()
 {
     return(method.ToString());
 }
Exemplo n.º 5
0
 private static string GetMethodSignature(IMethodDefinition pDefinition)
 {
     // TODO: Fix for ByReference parameters that may make this not unique
     return pDefinition.ToString();
 }
Exemplo n.º 6
0
 public MethodIdentifier(IMethodDefinition method)
     : base(method.ContainingTypeDefinition as INamedTypeDefinition)
 {
     _methodSignature = method.ToString();
 }
Exemplo n.º 7
0
 public MethodIdentifier(IMethodDefinition method)
     : base(method.ContainingTypeDefinition as INamedTypeDefinition)
 {
     _methodSignature = method.ToString();
 }
        protected void GlobalPolyVerifcationRsd(IMethodDefinition method, InstrumentationInformation instrInfo, string type, string name, GlobalPolyInfo polyInfo)
        {
            var methodStatements = ((BasicBlock)((Microsoft.Cci.ILToCodeModel.SourceMethodBody)method.Body).Block).Statements;

            var int32Type = _host.PlatformType.SystemInt32;

            var rsdField = GetRsdField(method, name, type);

            if (polyInfo.AllContractsRequiredAvailable)
            {
                var candPolys = new List<string>();
                var conds = new List<string>();
                conds.AddRange(GetMethodRequiresExprs(method));
                foreach (var poly in polyInfo.DirectQuantityLoops)
                {
                    candPolys.Add(poly.Poly);
                    conds.Add(poly.Cond);
                }
                foreach (var poly in polyInfo.QuantityTransferLoops)
                {
                    candPolys.Add(poly.Poly);
                    conds.Add(poly.Cond);
                }
                if (polyInfo.DirectQuantity > 0)
                {
                    candPolys.Add(polyInfo.DirectQuantity.ToString());
                }
                candPolys.AddRange(polyInfo.QuantityTransfer);
                if (candPolys.Count > 0)
                {
                    var candPoly = string.Join(" + ", candPolys);
                    //find rsd contracts for the type and compare with candPoly
                    var methodName = method.ToString();
                    if (_memoryContractsInformation.MethodsRsdContractsWithConds.ContainsKey(methodName))
                    {
                        var methodRsdContracts = _memoryContractsInformation.MethodsRsdContractsWithConds[methodName];
                        //methodName -> rsd name -> type of rsd -> cond -> contract (string expr + code model expr)
                        //public Dictionary<string, Dictionary<string, Dictionary<ITypeReference, Dictionary<string, Tuple<string, IExpression>>>>> MethodsRsdContractsWithConds = new Dictionary<string, Dictionary<string, Dictionary<ITypeReference, Dictionary<string, Tuple<string, IExpression>>>>>();
                        foreach (var rsdName in methodRsdContracts.Keys)
                        {
                            foreach (var rsdType in methodRsdContracts[rsdName].Keys)
                            {
                                if (rsdName == name && rsdType.ToString() == type)
                                {
                                    foreach (var contractCond in methodRsdContracts[rsdName][rsdType].Keys)
                                    {
                                        var methodContract = methodRsdContracts[rsdName][rsdType][contractCond].Item1;
                                        var methodContractExpressionObject = methodRsdContracts[rsdName][rsdType][contractCond].Item2;
                                        //see if candPoly <= methodContract
                                        string cond;
                                        var newConds = new List<string>();
                                        newConds.AddRange(conds);
                                        if (contractCond != "true")
                                        {
                                            newConds.Add(contractCond);
                                        }
                                        if (PolytopesCalculator.LowerOrEqual(candPoly, methodContract, newConds, GetMethodFreeVars(method), out cond))
                                        {
                                            //insert the statement: if (cond) Contract.Assume(candPoly <= methodContract);
                                            var condExpr = ExpressionGenerator.GenerateExpressionFromString(cond, _host, method);

                                            if (condExpr != null)
                                            {
                                                InsertStatementAtBottom(methodStatements,
                                                    new ConditionalStatement()
                                                    {
                                                        Condition = condExpr,
                                                        TrueBranch =
                                                            new AssumeStatement()
                                                            {
                                                                Condition =
                                                                    new LessThanOrEqual()
                                                                    {
                                                                        LeftOperand = new BoundExpression()
                                                                        {
                                                                            Definition = rsdField,
                                                                            Type = rsdField.Type
                                                                        },
                                                                        RightOperand = methodContractExpressionObject,
                                                                        Type = _host.PlatformType.SystemBoolean,
                                                                    }
                                                            },
                                                        FalseBranch = new EmptyStatement()
                                                    });
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 9
0
 public static bool IsDefaultCtor(this IMethodDefinition method)
 {
     return(method.ToString().EndsWith("..ctor()"));
 }
Exemplo n.º 10
0
 public static string Signature(this IMethodDefinition method)
 {
     return(method.ToString().Replace(", ", ","));
 }