Exemplo n.º 1
0
 public StackValue BuildNullArray(int size)
 {
     lock (Heap.cslock)
     {
         int ptr = Heap.Allocate(size);
         for (int n = 0; n < size; ++n)
         {
             Heap.Heaplist[ptr].Stack[n] = StackValue.Null;
         }
         return(StackValue.BuildArrayPointer(ptr));
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Take an array of already allocated StackValues and push them into
        /// the heap and returning the stack value that represents the array
        /// </summary>
        /// <param name="elements"></param>
        /// <param name="core"></param>
        /// <returns></returns>
        public static StackValue StoreArray(StackValue[] elements, Dictionary <StackValue, StackValue> dict, Core core)
        {
            Heap heap = core.Heap;

            lock (heap.cslock)
            {
                int        ptr       = heap.Allocate(elements);
                StackValue overallSv = StackValue.BuildArrayPointer(ptr);
                heap.Heaplist[ptr].Dict = dict;
                return(overallSv);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Take an array of already allocated StackValues and push them into the heap
        /// Returning the stack value that represents the array
        /// </summary>
        /// <param name="arrayElements"></param>
        /// <param name="core"></param>
        /// <returns></returns>
        public static StackValue StoreArray(StackValue[] arrayElements, Core core)
        {
            Heap heap = core.Heap;

            lock (heap.cslock)
            {
                int ptr = heap.Allocate(arrayElements);
                // ++heap.Heaplist[ptr].Refcount;
                StackValue overallSv = StackUtils.BuildArrayPointer(ptr);
                return(overallSv);
            }
        }
Exemplo n.º 4
0
 public StackValue BuildArrayFromStack(int size)
 {
     lock (Heap.cslock)
     {
         int ptr = Heap.Allocate(size);
         for (int n = size - 1; n >= 0; --n)
         {
             StackValue sv = Pop();
             Heap.IncRefCount(sv);
             Heap.Heaplist[ptr].Stack[n] = sv;
         }
         return(StackValue.BuildArrayPointer(ptr));
     }
 }
Exemplo n.º 5
0
            public StackValue BuildArray(StackValue[] arrayElements)
            {
                int size = arrayElements.Length;

                lock (Heap.cslock)
                {
                    int ptr = Heap.Allocate(size);
                    for (int n = size - 1; n >= 0; --n)
                    {
                        StackValue sv = arrayElements[n];
                        Heap.IncRefCount(sv);
                        Heap.Heaplist[ptr].Stack[n] = sv;
                    }
                    return(StackValue.BuildArrayPointer(ptr));
                }
            }
Exemplo n.º 6
0
 public void Allocate_GenericInvalidHeapSizeForAllocation_RequestCannotBeSatisfied(int size)
 {
     Assert.Throws <HeapManagementException>(() => _uut.Allocate(size));
 }