Exemple #1
0
 public static void UnboxTypedRef(object box, TypedRefPtr typedRef)
 {
     UnboxTypedRef(box, typedRef, box.GetType());
     if (box is IValueTypeBox)
     {
         CastTypedRef(typedRef, ((IValueTypeBox)box).GetValueType());
     }
 }
Exemple #2
0
        public static void UnboxTypedRef(object box, TypedRefPtr typedRef)
        {
            TypedReferenceHelpers.UnboxTypedRef(box, typedRef, box.GetType());
            bool flag = box is IValueTypeBox;

            if (flag)
            {
                TypedReferenceHelpers.CastTypedRef(typedRef, ((IValueTypeBox)box).GetValueType());
            }
        }
        public static void UnboxTypedRef(object box, TypedRefPtr typedRef, Type boxType)
        {
            var helper = unboxHelpers[boxType];

            if (helper == null)
            {
                lock (unboxHelpers) {
                    helper = unboxHelpers[boxType];
                    if (helper == null)
                    {
                        helper = BuildUnboxHelper(boxType);
                        unboxHelpers[boxType] = helper;
                    }
                }
            }
            ((Unbox)helper)(box, typedRef);
        }
        public static void MakeTypedRef(void *ptr, TypedRefPtr typedRef, Type targetType)
        {
            var helper = makeHelpers[targetType];

            if (helper == null)
            {
                lock (makeHelpers) {
                    helper = makeHelpers[targetType];
                    if (helper == null)
                    {
                        helper = BuildMakeHelper(targetType);
                        makeHelpers[targetType] = helper;
                    }
                }
            }
            ((Make)helper)(ptr, typedRef);
        }
        public static void SetTypedRef(object value, TypedRefPtr typedRef)
        {
            Type type   = TypedReference.GetTargetType(*(TypedReference *)typedRef);
            var  helper = setHelpers[type];

            if (helper == null)
            {
                lock (setHelpers) {
                    helper = setHelpers[type];
                    if (helper == null)
                    {
                        helper           = BuildSetHelper(type);
                        setHelpers[type] = helper;
                    }
                }
            }
            ((Set)helper)(value, typedRef);
        }
Exemple #6
0
        public static void UnboxTypedRef(object box, TypedRefPtr typedRef, Type boxType)
        {
            object obj  = TypedReferenceHelpers.unboxHelpers[boxType];
            bool   flag = obj == null;

            if (flag)
            {
                Hashtable obj2 = TypedReferenceHelpers.unboxHelpers;
                lock (obj2) {
                    obj = TypedReferenceHelpers.unboxHelpers[boxType];
                    bool flag2 = obj == null;
                    if (flag2)
                    {
                        obj = TypedReferenceHelpers.BuildUnboxHelper(boxType);
                        TypedReferenceHelpers.unboxHelpers[boxType] = obj;
                    }
                }
            }
            ((TypedReferenceHelpers.Unbox)obj)(box, typedRef);
        }
Exemple #7
0
        public unsafe static void MakeTypedRef(void *ptr, TypedRefPtr typedRef, Type targetType)
        {
            object obj  = TypedReferenceHelpers.makeHelpers[targetType];
            bool   flag = obj == null;

            if (flag)
            {
                Hashtable obj2 = TypedReferenceHelpers.makeHelpers;
                lock (obj2) {
                    obj = TypedReferenceHelpers.makeHelpers[targetType];
                    bool flag2 = obj == null;
                    if (flag2)
                    {
                        obj = TypedReferenceHelpers.BuildMakeHelper(targetType);
                        TypedReferenceHelpers.makeHelpers[targetType] = obj;
                    }
                }
            }
            ((TypedReferenceHelpers.Make)obj)(ptr, typedRef);
        }
        public static void CastTypedRef(TypedRefPtr typedRef, Type targetType)
        {
            Type sourceType = TypedReference.GetTargetType(*(TypedReference *)typedRef);
            var  key        = new KeyValuePair <Type, Type>(sourceType, targetType);

            var helper = castHelpers[key];

            if (helper == null)
            {
                lock (castHelpers) {
                    helper = castHelpers[key];
                    if (helper == null)
                    {
                        helper           = BuildCastHelper(sourceType, targetType);
                        castHelpers[key] = helper;
                    }
                }
            }
            ((Cast)helper)(typedRef);
        }
Exemple #9
0
        public unsafe static void SetTypedRef(object value, TypedRefPtr typedRef)
        {
            Type   targetType = TypedReference.GetTargetType(*(TypedReference *)typedRef);
            object obj        = TypedReferenceHelpers.setHelpers[targetType];
            bool   flag       = obj == null;

            if (flag)
            {
                Hashtable obj2 = TypedReferenceHelpers.setHelpers;
                lock (obj2) {
                    obj = TypedReferenceHelpers.setHelpers[targetType];
                    bool flag2 = obj == null;
                    if (flag2)
                    {
                        obj = TypedReferenceHelpers.BuildSetHelper(targetType);
                        TypedReferenceHelpers.setHelpers[targetType] = obj;
                    }
                }
            }
            ((TypedReferenceHelpers.Set)obj)(value, typedRef);
        }
Exemple #10
0
        public unsafe static void CastTypedRef(TypedRefPtr typedRef, Type targetType)
        {
            Type targetType2 = TypedReference.GetTargetType(*(TypedReference *)typedRef);
            KeyValuePair <Type, Type> keyValuePair = new KeyValuePair <Type, Type>(targetType2, targetType);
            object obj  = TypedReferenceHelpers.castHelpers[keyValuePair];
            bool   flag = obj == null;

            if (flag)
            {
                Hashtable obj2 = TypedReferenceHelpers.castHelpers;
                lock (obj2) {
                    obj = TypedReferenceHelpers.castHelpers[keyValuePair];
                    bool flag2 = obj == null;
                    if (flag2)
                    {
                        obj = TypedReferenceHelpers.BuildCastHelper(targetType2, targetType);
                        TypedReferenceHelpers.castHelpers[keyValuePair] = obj;
                    }
                }
            }
            ((TypedReferenceHelpers.Cast)obj)(typedRef);
        }
Exemple #11
0
        public static void GetFieldAddr(DarksVMContext context, object obj, FieldInfo field, TypedRefPtr typedRef)
        {
            var helper = fieldAddrHelpers[field];

            if (helper == null)
            {
                lock (fieldAddrHelpers)
                {
                    helper = fieldAddrHelpers[field];
                    if (helper == null)
                    {
                        helper = BuildAddrHelper(field);
                        fieldAddrHelpers[field] = helper;
                    }
                }
            }
            TypedReference objRef;

            if (obj == null)
            {
                objRef = default(TypedReference);
            }
            else if (obj is IReference)
            {
                ((IReference)obj).ToTypedReference(context, &objRef, field.DeclaringType);
            }
            else
            {
                objRef = __makeref(obj);
                CastTypedRef(&objRef, obj.GetType());
            }

            ((FieldAdr)helper)(&objRef, typedRef);
        }
Exemple #12
0
        public unsafe static void GetFieldAddr(EmuContext context, object obj, FieldInfo field, TypedRefPtr typedRef)
        {
            object obj2 = TypedReferenceHelpers.fieldAddrHelpers[field];
            bool   flag = obj2 == null;

            if (flag)
            {
                Hashtable obj3 = TypedReferenceHelpers.fieldAddrHelpers;
                lock (obj3) {
                    obj2 = TypedReferenceHelpers.fieldAddrHelpers[field];
                    bool flag2 = obj2 == null;
                    if (flag2)
                    {
                        obj2 = TypedReferenceHelpers.BuildAddrHelper(field);
                        TypedReferenceHelpers.fieldAddrHelpers[field] = obj2;
                    }
                }
            }
            bool           flag3 = obj == null;
            TypedReference typedReference;

            if (flag3)
            {
                typedReference = default(TypedReference);
            }
            else
            {
                bool flag4 = obj is IReference;
                if (flag4)
                {
                    ((IReference)obj).ToTypedReference(context, (void *)(&typedReference), field.DeclaringType);
                }
                else
                {
                    typedReference = __makeref(obj);
                    TypedReferenceHelpers.CastTypedRef((void *)(&typedReference), obj.GetType());
                }
            }
            ((TypedReferenceHelpers.FieldAdr)obj2)((void *)(&typedReference), typedRef);
        } // Token: 0x0600019C RID: 412 RVA: 0x0000AD9C File Offset: 0x00008F9C