本文整理匯總了C#中ProtoCore.DSASM.StackValue.ToDouble方法的典型用法代碼示例。如果您正苦於以下問題:C# StackValue.ToDouble方法的具體用法?C# StackValue.ToDouble怎麽用?C# StackValue.ToDouble使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ProtoCore.DSASM.StackValue
的用法示例。
在下文中一共展示了StackValue.ToDouble方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Coerce
//.........這裏部分代碼省略.........
newTargetType.rank = targetType.rank - 1;
//Upcast once
StackValue coercedValue = Coerce(sv, newTargetType, runtimeCore);
StackValue newSv = rmem.Heap.AllocateArray(new StackValue[] { coercedValue });
return newSv;
}
}
if (sv.IsPointer)
{
StackValue ret = ClassCoerece(sv, targetType, runtimeCore);
return ret;
}
//If it's anything other than array, just create a new copy
switch (targetType.UID)
{
case (int)PrimitiveType.kInvalidType:
runtimeCore.RuntimeStatus.LogWarning(Runtime.WarningID.kInvalidType, Resources.kInvalidType);
return StackValue.Null;
case (int)PrimitiveType.kTypeBool:
return sv.ToBoolean(runtimeCore);
case (int)PrimitiveType.kTypeChar:
{
StackValue newSV = sv.ShallowClone();
newSV.metaData = new MetaData { type = (int)PrimitiveType.kTypeChar };
return newSV;
}
case (int)PrimitiveType.kTypeDouble:
return sv.ToDouble();
case (int)PrimitiveType.kTypeFunctionPointer:
if (sv.metaData.type != (int)PrimitiveType.kTypeFunctionPointer)
{
runtimeCore.RuntimeStatus.LogWarning(Runtime.WarningID.kTypeMismatch, Resources.kFailToConverToFunction);
return StackValue.Null;
}
return sv;
case (int)PrimitiveType.kTypeInt:
{
if (sv.metaData.type == (int)PrimitiveType.kTypeDouble)
{
//TODO(lukechurch): Once the API is improved (MAGN-5174)
//Replace this with a log entry notification
//core.RuntimeStatus.LogWarning(RuntimeData.WarningID.kTypeConvertionCauseInfoLoss, Resources.kConvertDoubleToInt);
}
return sv.ToInteger();
}
case (int)PrimitiveType.kTypeNull:
{
if (sv.metaData.type != (int)PrimitiveType.kTypeNull)
{
runtimeCore.RuntimeStatus.LogWarning(Runtime.WarningID.kTypeMismatch, Resources.kFailToConverToNull);
return StackValue.Null;
}
return sv;
}
case (int)PrimitiveType.kTypePointer:
{
示例2: IsNodeModified
private bool IsNodeModified(StackValue svGraphNode, StackValue svUpdateNode)
{
bool isPointerModified = svGraphNode.IsPointer || svUpdateNode.IsPointer;
bool isArrayModified = svGraphNode.IsArray || svUpdateNode.IsArray;
bool isDataModified = svGraphNode.opdata != svUpdateNode.opdata;
bool isDoubleDataModified = svGraphNode.IsDouble && svGraphNode.RawDoubleValue != svUpdateNode.ToDouble().RawDoubleValue;
bool isTypeModified = !svGraphNode.IsInvalid && !svUpdateNode.IsInvalid && svGraphNode.optype != svUpdateNode.optype;
// Jun Comment: an invalid optype means that the value was not set
bool isInvalid = svGraphNode.IsInvalid || svUpdateNode.IsInvalid;
return isInvalid || isPointerModified || isArrayModified || isDataModified || isDoubleDataModified || isTypeModified;
}