コード例 #1
0
        public static byte[] Hash <Field, Method>(InferredExpr <Field, Method> expr, bool trace)
        {
            Contract.Ensures(Contract.Result <byte[]>() != null);

            using (var tw = new HashWriter(trace))
            {
                tw.Write(expr.ToHashString());
                return(tw.GetHash());
            }
        }
コード例 #2
0
        public static byte[] Hash(BoxedExpression expr, bool trace)
        {
            Contract.Ensures(Contract.Result <byte[]>() != null);

            using (var tw = new HashWriter(trace))
            {
                tw.WriteLine(expr.ToString());
                return(tw.GetHash());
            }
        }
コード例 #3
0
        public MethodHasher(
            AnalysisDriver <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly, Expression, SymbolicValue, ILogOptions, IMethodResult <SymbolicValue> > driver,
            IMethodDriver <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly, Expression, SymbolicValue, ILogOptions> mDriver,
            bool trace,
            Func <Subroutine, int> subroutineIdentifier = null,
            Func <Type, int> typeIdentifier             = null
            )
        {
            this.driver  = driver;
            this.mDriver = mDriver;

            this.tw = new HashWriter(trace);

            this.ilHasher = new ILHasher(this.mDriver.StackLayer, this.tw, this.ReferenceType, this.InlinedSubroutine);

            if (subroutineIdentifier != null)
            {
                this.subroutineIdentifier = subroutineIdentifier;
            }
            else
            {
                // unique ID for a subroutine (used to put warnings into contexts)
                var subroutineLocalIds = new BijectiveMap <Subroutine, int>();

                this.subroutineIdentifier = sub =>
                {
                    int res;
                    if (!subroutineLocalIds.TryGetValue(sub, out res))
                    {
                        subroutineLocalIds.Add(sub, res = subroutineLocalIds.Count);
                    }
                    return(res);
                };
            }

            if (typeIdentifier != null)
            {
                this.typeIdentifier = typeIdentifier;
            }
            else
            {
                // unique ID for types (used for general serialization of boxed expressions)
                var referencedTypesLocalIds = new BijectiveMap <Type, int>();

                this.typeIdentifier = typ =>
                {
                    int res;
                    if (!referencedTypesLocalIds.TryGetValue(typ, out res))
                    {
                        referencedTypesLocalIds.Add(typ, res = referencedTypesLocalIds.Count);
                    }
                    return(res);
                };
            }
        }
コード例 #4
0
    public static byte[] Hash(IEnumerable<BoxedExpression> exprs, bool trace)
    {
      Contract.Ensures(Contract.Result<byte[]>() != null);

      using (var tw = new HashWriter(trace))
      {
        foreach (var expr in exprs)
          tw.WriteLine(expr.ToString());
        return tw.GetHash();
      }
    }