System.ValueType

using System.Runtime.InteropServices;
using System.Reflection;
namespace System
{
    [ComVisibleAttribute(true)]
    public abstract class ValueType : System.Object
    {
        public override bool Equals(object obj)
        {
            //.maxstack  3
            //.locals init (class System.RuntimeType V_0,
            //         class System.RuntimeType V_1,
            //         object V_2,
            //         object V_3,
            //         object V_4,
            //         class System.Reflection.FieldInfo[] V_5,
            //         int32 V_6)
            //IL_0000:  ldarg.1
            //IL_0001:  brtrue.s   IL_0005

            //IL_0003:  ldc.i4.0
            //IL_0004:  ret

            //IL_0005:  ldarg.0
            //IL_0006:  call       instance class System.Type System.Object::GetType()
            //IL_000b:  castclass  System.RuntimeType
            //IL_0010:  stloc.0
            //IL_0011:  ldarg.1
            //IL_0012:  callvirt   instance class System.Type System.Object::GetType()
            //IL_0017:  castclass  System.RuntimeType
            //IL_001c:  stloc.1
            //IL_001d:  ldloc.1
            //IL_001e:  ldloc.0
            //IL_001f:  beq.s      IL_0023

            //IL_0021:  ldc.i4.0
            //IL_0022:  ret

            //IL_0023:  ldarg.0
            //IL_0024:  stloc.2
            //IL_0025:  ldarg.0
            //IL_0026:  call       bool System.ValueType::CanCompareBits(object)
            //IL_002b:  brfalse.s  IL_0035

            //IL_002d:  ldloc.2
            //IL_002e:  ldarg.1
            //IL_002f:  call       bool System.ValueType::FastEqualsCheck(object,
            //                                                            object)
            //IL_0034:  ret

            //IL_0035:  ldloc.0
            //IL_0036:  ldc.i4.s   52
            //IL_0038:  callvirt   instance class System.Reflection.FieldInfo[] System.Type::GetFields(valuetype System.Reflection.BindingFlags)
            //IL_003d:  stloc.s    V_5
            //IL_003f:  ldc.i4.0
            //IL_0040:  stloc.s    V_6
            //IL_0042:  br.s       IL_0084

            //IL_0044:  ldloc.s    V_5
            //IL_0046:  ldloc.s    V_6
            //IL_0048:  ldelem.ref
            //IL_0049:  castclass  System.Reflection.RtFieldInfo
            //IL_004e:  ldloc.2
            //IL_004f:  ldc.i4.0
            //IL_0050:  callvirt   instance object System.Reflection.RtFieldInfo::InternalGetValue(object,
            //                                                                                     bool)
            //IL_0055:  stloc.3
            //IL_0056:  ldloc.s    V_5
            //IL_0058:  ldloc.s    V_6
            //IL_005a:  ldelem.ref
            //IL_005b:  castclass  System.Reflection.RtFieldInfo
            //IL_0060:  ldarg.1
            //IL_0061:  ldc.i4.0
            //IL_0062:  callvirt   instance object System.Reflection.RtFieldInfo::InternalGetValue(object,
            //                                                                                     bool)
            //IL_0067:  stloc.s    V_4
            //IL_0069:  ldloc.3
            //IL_006a:  brtrue.s   IL_0072

            //IL_006c:  ldloc.s    V_4
            //IL_006e:  brfalse.s  IL_007e

            //IL_0070:  ldc.i4.0
            //IL_0071:  ret

            //IL_0072:  ldloc.3
            //IL_0073:  ldloc.s    V_4
            //IL_0075:  callvirt   instance bool System.Object::Equals(object)
            //IL_007a:  brtrue.s   IL_007e

            //IL_007c:  ldc.i4.0
            //IL_007d:  ret

            //IL_007e:  ldloc.s    V_6
            //IL_0080:  ldc.i4.1
            //IL_0081:  add
            //IL_0082:  stloc.s    V_6
            //IL_0084:  ldloc.s    V_6
            //IL_0086:  ldloc.s    V_5
            //IL_0088:  ldlen
            //IL_0089:  conv.i4
            //IL_008a:  blt.s      IL_0044

            //IL_008c:  ldc.i4.1
            //IL_008d:  ret
            System.RuntimeType V_0,V_1;
            object V_2,V_3,V_4;
            FieldInfo[] V_5;
            int V_6;
            if (obj == null)
            {
                return false;
            }
            else
            {
                V_0=(System.RuntimeType)this.GetType();
                V_1 = (System.RuntimeType)obj.GetType();
                if (V_1 != V_0)//
                {
                    return false;
                }
                V_2 = this;
                if (ValueType.CanCompareBits(this))
                {
                    return ValueType.FastEqualsCheck(V_2,obj);
                }
                else
                {
                    V_5=V_0.GetFields(BindingFlags.Instance|BindingFlags.Public|BindingFlags.NonPublic);
                    V_6 = 0;
                    for(int V_6=0;V_5.Length > V_6;V_6++)
                    {
                        V_3=((RtFieldInfo)V_5[V_6]).InternalGetValue(V_2, false);
                        V_4 = ((RtFieldInfo)V_5[V_6]).InternalGetValue(obj, false);
                        if (V_3 == null)
                        {
                            if (V_4 != null)
                            {
                                return false;
                            }                            
                        }
                        else
                        {
                            if (!V_3.Equals(V_4))
                            {
                                return false;
                            }                            
                        }
                    }
                    return true;
                }
            }

        }
        private static bool CanCompareBits(object obj)
        {
            //internalcall
        }
        private static bool  FastEqualsCheck(object a,object b)
        {
            //internalcall
        }
        public override int GetHashCode()
        {
            //internalcall
        }
        public override string ToString()
        {
            //.maxstack  8
            //IL_0000:  ldarg.0
            //IL_0001:  call       instance class System.Type System.Object::GetType()
            //IL_0006:  callvirt   instance string System.Object::ToString()
            //IL_000b:  ret
            return this.GetType().ToString();
        }
        protected ValueType():base()
        {
            //.maxstack  8
            //IL_0000:  ldarg.0
            //IL_0001:  call       instance void System.Object::.ctor()
            //IL_0006:  ret            
        }
    }
}

posted @ 2010-08-28 21:21  Aegis  阅读(495)  评论(0编辑  收藏  举报