本文整理匯總了C#中ProtoCore.DSASM.StackValue.TryGetArrayKey方法的典型用法代碼示例。如果您正苦於以下問題:C# StackValue.TryGetArrayKey方法的具體用法?C# StackValue.TryGetArrayKey怎麽用?C# StackValue.TryGetArrayKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ProtoCore.DSASM.StackValue
的用法示例。
在下文中一共展示了StackValue.TryGetArrayKey方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetValueAtIndex
public StackValue GetValueAtIndex(StackValue index, RuntimeCore runtimeCore)
{
int pos = Constants.kInvalidIndex;
if (index.IsNumeric)
{
pos = (int)index.ToInteger().IntegerValue;
return GetValueAtIndex(pos, runtimeCore);
}
else if (index.IsArrayKey)
{
StackValue array;
index.TryGetArrayKey(out array, out pos);
return GetValueAtIndex(pos, runtimeCore);
}
else
{
if (runtimeCore != null)
runtimeCore.RuntimeStatus.LogWarning(WarningID.InvalidIndexing, Resources.kInvalidArguments);
return StackValue.Null;
}
}
示例2: GetNextKey
/// <summary>
/// Get an array's next key
/// </summary>
/// <param name="key"></param>
/// <param name="core"></param>
/// <returns></returns>
public static StackValue GetNextKey(StackValue key, Core core)
{
StackValue array;
int index;
if (!key.TryGetArrayKey(out array, out index))
{
return StackValue.Null;
}
HeapElement he = GetHeapElement(array, core);
if ((he.VisibleSize > index + 1) ||
(he.Dict != null && he.Dict.Count + he.VisibleSize > index + 1))
{
return StackValue.BuildArrayKey(array, index + 1);
}
return StackValue.Null;
}
示例3: GetValueFromIndex
/// <summary>
/// = array[index].
///
/// Note this function doesn't support the replication of array indexing.
/// </summary>
/// <param name="index"></param>
/// <param name="core"></param>
/// <returns></returns>
public StackValue GetValueFromIndex(StackValue index, RuntimeCore runtimeCore)
{
if (index.IsNumeric)
{
index = index.ToInteger();
return GetValueFromIndex((int)index.IntegerValue, runtimeCore);
}
else if (index.IsArrayKey)
{
int fullIndex = Constants.kInvalidIndex;
StackValue array;
index.TryGetArrayKey(out array, out fullIndex);
if (Count > fullIndex)
{
return GetValueFromIndex(fullIndex, runtimeCore);
}
else
{
fullIndex = fullIndex - Count;
if (Dict != null && Dict.Count > fullIndex)
{
int count = 0;
foreach (var key in Dict.Keys)
{
if (count == fullIndex)
{
return Dict[key];
}
count = count + 1;
}
}
}
return StackValue.Null;
}
else
{
StackValue value = StackValue.Null;
if (Dict.TryGetValue(index, out value))
{
return value;
}
else
{
return StackValue.Null;
}
}
}
示例4: GetNextKey
/// <summary>
/// Get an array's next key
/// </summary>
/// <param name="key"></param>
/// <param name="core"></param>
/// <returns></returns>
public static StackValue GetNextKey(StackValue key, RuntimeCore runtimeCore)
{
StackValue array;
int index;
if (!key.TryGetArrayKey(out array, out index))
{
return StackValue.Null;
}
int nextIndex = Constants.kInvalidIndex;
if (array.IsString)
{
var str = runtimeCore.Heap.GetString(array);
if (str.Length > index + 1)
nextIndex = index + 1;
}
else
{
HeapElement he = GetHeapElement(array, runtimeCore);
if ((he.VisibleSize > index + 1) ||
(he.Dict != null && he.Dict.Count + he.VisibleSize > index + 1))
nextIndex = index + 1;
}
return nextIndex == Constants.kInvalidIndex ? StackValue.Null : StackValue.BuildArrayKey(array, nextIndex);
}