Ejemplo 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));
     }
 }
Ejemplo 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);
            }
        }
Ejemplo n.º 3
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));
     }
 }
Ejemplo n.º 4
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));
                }
            }
Ejemplo n.º 5
0
        private object ConvertCSArrayToDSArray(double[] csArray, ProtoCore.DSASM.Interpreter dsi)
        {
            var    core   = dsi.runtime.Core;
            object retVal = null;

            lock (core.Heap.cslock)
            {
                var numElems = csArray.Length;
                int ptr      = core.Heap.Allocate(numElems);
                for (int n = numElems - 1; n >= 0; --n)
                {
                    core.Heap.Heaplist[ptr].Stack[n] = StackValue.BuildDouble(csArray[n]);
                }
                retVal = StackValue.BuildArrayPointer(ptr);
                //dsi.runtime.rmem.Push(StackValue.BuildArrayPointer(ptr));
            }

            return(retVal);
        }