Ejemplo n.º 1
0
 /// <summary>
 /// Creates a new call stack
 /// </summary>
 /// <param name="memoryManager">The memory manager</param>
 /// <param name="managedObjectReferences">The object references</param>
 /// <param name="size">The maximum number of entries in the call stack</param>
 public CallStack(MemoryManager memoryManager, ManagedObjectReferences managedObjectReferences, int size)
 {
     this.memoryManager           = memoryManager;
     this.managedObjectReferences = managedObjectReferences;
     this.Size            = size;
     this.callStackMemory = memoryManager.CreatePage(Constants.NativePointerSize + size * CallStackEntrySize);
     NativeHelpers.SetLong(this.TopPointer, 0, this.CallStackStart.ToInt64());
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new object reference for the given object
        /// </summary>
        /// <param name="managedObjectReferences">The managed object references</param>
        /// <param name="pointer">A pointer to the start of the data part of the object</param>
        public ObjectReference(ManagedObjectReferences managedObjectReferences, IntPtr pointer)
        {
            this.pointer = pointer - Constants.ObjectHeaderSize;
            var typeId = NativeHelpers.ReadInt(this.pointer);

            this.Type = managedObjectReferences.GetObject <BaseType>(typeId);

            if (this.Type.IsArray)
            {
                var arrayType   = (ArrayType)this.Type;
                var elementSize = TypeSystem.SizeOf(arrayType.ElementType);
                var length      = NativeHelpers.ReadInt(this.pointer + Constants.ObjectHeaderSize);
                this.Size = Constants.ArrayLengthSize + (length * elementSize);
            }
            else
            {
                this.Size = ((ClassType)this.Type).Metadata.Size;
            }
        }