/// <summary> /// Allocate an array. /// </summary> /// <param name="values">Array elements whose indices are integer</param> /// <param name="dict">Array elements whose indices are not integer</param> /// <returns></returns> public StackValue AllocateArray(StackValue[] values) { int index = AllocateInternal(values, PrimitiveType.kTypeArray); var heapElement = heapElements[index]; heapElement.MetaData = new MetaData { type = (int)PrimitiveType.kTypeArray }; return StackValue.BuildArrayPointer(index); }
public StackValue AllocateArray(IEnumerable <StackValue> values, Dictionary <StackValue, StackValue> dict = null) { int index = AllocateInternal(values); heapElements[index].Dict = dict; return(StackValue.BuildArrayPointer(index)); }
/// <summary> /// Allocate an array. /// </summary> /// <param name="values">Array elements whose indices are integer</param> /// <param name="dict">Array elements whose indices are not integer</param> /// <returns></returns> public StackValue AllocateArray(IEnumerable <StackValue> values, Dictionary <StackValue, StackValue> dict = null) { int index = AllocateInternal(values); var heapElement = heapElements[index]; heapElement.Dict = dict; heapElement.MetaData = new MetaData { type = (int)PrimitiveType.kTypeArray }; return(StackValue.BuildArrayPointer(index)); }
/// <summary> /// Try to get the host array and key value from StackValue. The address /// type of StackValue should be AddressType.ArrayKey. /// </summary> /// <param name="array"></param> /// <param name="index"></param> /// <returns></returns> public bool TryGetArrayKey(out StackValue array, out int index) { array = StackValue.Null; index = Constants.kInvalidIndex; if (!this.IsArrayKey || opdata == Constants.kInvalidIndex) { return(false); } array = StackValue.BuildArrayPointer((int)RawDoubleValue); index = (int)this.opdata; return(true); }
/// <summary> /// Allocate an array. /// /// Exceptions: ProtoCore.Exceptions.RunOutOfMemoryException /// </summary> /// <param name="values">Array elements whose indices are integer</param> /// <param name="dict">Array elements whose indices are not integer</param> /// <returns></returns> public StackValue AllocateArray(StackValue[] values) { try { int index = AllocateInternal(values, PrimitiveType.Array); var heapElement = heapElements[index]; heapElement.MetaData = new MetaData { type = (int)PrimitiveType.Array }; return(StackValue.BuildArrayPointer(index)); } catch (OutOfMemoryException) { throw new RunOutOfMemoryException(); } }
/// <summary> /// Try to get the host array and key value from StackValue. The address /// type of StackValue should be AddressType.ArrayKey. /// </summary> /// <param name="array"></param> /// <param name="index"></param> /// <returns></returns> public bool TryGetArrayKey(out StackValue array, out int index) { array = StackValue.Null; index = Constants.kInvalidIndex; if (!this.IsArrayKey || opdata == Constants.kInvalidIndex) { return(false); } if (this.metaData.type == (int)PrimitiveType.kTypeString) { array = StackValue.BuildString((long)RawDoubleValue); } else { array = StackValue.BuildArrayPointer((long)RawDoubleValue); } index = (int)this.opdata; return(true); }