/// <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 = StackUtils.BuildArrayPointer(ptr); heap.Heaplist[ptr].Dict = dict; return(overallSv); } }
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] = StackUtils.BuildNull(); } return(StackUtils.BuildArrayPointer(ptr)); } }
/// <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); } }
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(StackUtils.BuildArrayPointer(ptr)); } }
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(StackUtils.BuildArrayPointer(ptr)); } }
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] = StackUtils.BuildDouble(csArray[n]); } retVal = StackUtils.BuildArrayPointer(ptr); //dsi.runtime.rmem.Push(StackUtils.BuildArrayPointer(ptr)); } return(retVal); }