Esempio n. 1
0
        internal static object CreateObject(libsupcs.TysosType type)
        {
            /* Create an object of a certain type
             *
             * If type is an unboxed value type, then we return the boxed equivalent
             *
             * To do this, we get the VTable entry from the type then dereference it
             * to get the boxed type.  For reference types this does nothing apart from
             * return the original typeinfo again.
             *
             * Then, set the __vtbl field to the VTable, set the __object_id field and
             * set the mutex lock field
             */

            throw new NotImplementedException();
            unsafe
            {
                //IntPtr vtable_object = type.VTable;
                IntPtr             vtable_object        = (IntPtr)0;
                IntPtr             actual_type_info_ptr = *(IntPtr *)vtable_object;
                libsupcs.TysosType actual_type_info     = libsupcs.TysosType.ReinterpretAsType(actual_type_info_ptr);

                /* The following is specific for x86_64 */
                ulong obj = gc.gc.Alloc((ulong)actual_type_info.GetClassSize());

                *(ulong *)obj        = (ulong)vtable_object;
                *(int *)(obj + 8)    = Program.GetNewObjId();
                *(ulong *)(obj + 12) = 0; // mutex_lock

                return(libsupcs.CastOperations.ReinterpretAsObject(obj));
            }
        }
Esempio n. 2
0
        internal static object PlacementNew(libsupcs.TysosType type, ulong obj)
        {
            unsafe
            {
                throw new NotImplementedException();
                //IntPtr vtable_object = type.VTable;
                IntPtr             vtable_object        = (IntPtr)0;
                IntPtr             actual_type_info_ptr = *(IntPtr *)vtable_object;
                libsupcs.TysosType actual_type_info     = libsupcs.TysosType.ReinterpretAsType(actual_type_info_ptr);

                /* The following is specific for x86_64 */
                *(ulong *)obj        = (ulong)vtable_object;
                *(int *)(obj + 8)    = Program.GetNewObjId();
                *(ulong *)(obj + 12) = 0; // mutex_lock

                return(libsupcs.CastOperations.ReinterpretAsObject(obj));
            }
        }