當前位置: 首頁>>代碼示例>>C#>>正文


C# StackValue.ShallowClone方法代碼示例

本文整理匯總了C#中ProtoCore.DSASM.StackValue.ShallowClone方法的典型用法代碼示例。如果您正苦於以下問題:C# StackValue.ShallowClone方法的具體用法?C# StackValue.ShallowClone怎麽用?C# StackValue.ShallowClone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ProtoCore.DSASM.StackValue的用法示例。


在下文中一共展示了StackValue.ShallowClone方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Coerce


//.........這裏部分代碼省略.........
                    Type newTargetType = new Type();
                    newTargetType.UID = targetType.UID;
                    newTargetType.IsIndexable = true;
                    newTargetType.Name = targetType.Name;
                    newTargetType.rank = targetType.rank -1;

                    //Upcast once
                    StackValue coercedValue = Coerce(sv, newTargetType, core);
                    GCUtils.GCRetain(coercedValue, core);
                    StackValue newSv = HeapUtils.StoreArray(new StackValue[] { coercedValue }, core);
                    return newSv;
                }

            }

            if (sv.optype == AddressType.Pointer)
            {
                StackValue ret = ClassCoerece(sv, targetType, core);
                return ret;
            }

            //If it's anything other than array, just create a new copy
            switch (targetType.UID)
            {
                case (int)PrimitiveType.kInvalidType:
                    Validity.Assert(false, "Can't convert invalid type");
                    break;

                case (int)PrimitiveType.kTypeBool:
                    return sv.AsBoolean(core);

                case (int)PrimitiveType.kTypeChar:
                    {
                        StackValue newSV = sv.ShallowClone();
                        newSV.metaData = new MetaData { type = (int)PrimitiveType.kTypeChar };
                        return newSV;
                    }

                case (int)PrimitiveType.kTypeDouble:
                    return sv.AsDouble();

                case (int)PrimitiveType.kTypeFunctionPointer:
                    if (sv.metaData.type != (int)PrimitiveType.kTypeFunctionPointer)
                    {
                        core.RuntimeStatus.LogWarning(RuntimeData.WarningID.kTypeMismatch, ProtoCore.RuntimeData.WarningMessage.kFailToConverToFunction);
                        return StackUtils.BuildNull();
                    }
                    return sv.ShallowClone();

                case (int)PrimitiveType.kTypeHostEntityID:
                    {
                        StackValue newSV = sv.ShallowClone();
                        newSV.metaData = new MetaData { type = (int)PrimitiveType.kTypeHostEntityID };
                        return newSV;
                    }

                case (int)PrimitiveType.kTypeInt:
                    {
                        if (sv.metaData.type == (int)PrimitiveType.kTypeDouble)
                        {
                            core.RuntimeStatus.LogWarning(RuntimeData.WarningID.kTypeConvertionCauseInfoLoss, ProtoCore.RuntimeData.WarningMessage.kConvertDoubleToInt);
                        }
                        return sv.AsInt();
                    }

                case (int)PrimitiveType.kTypeNull:
開發者ID:junmendoza,項目名稱:designscript,代碼行數:67,代碼來源:Type.cs

示例2: Coerce


//.........這裏部分代碼省略.........
                {
                    Validity.Assert(targetType.rank > 1, "Target rank should be greater than one for this clause");

                    Type newTargetType = new Type();
                    newTargetType.UID = targetType.UID;
                    newTargetType.Name = targetType.Name;
                    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;
開發者ID:joespiff,項目名稱:Dynamo,代碼行數:67,代碼來源:Type.cs

示例3: ClassCoerece

        //@TODO: Factor this into the type system
        public static StackValue ClassCoerece(StackValue sv, Type targetType, Core core)
        {
            //@TODO: Add proper coersion testing here.

            if (targetType.UID == (int)PrimitiveType.kTypeBool)
                return StackUtils.BuildBoolean(true);

            return sv.ShallowClone();
        }
開發者ID:junmendoza,項目名稱:designscript,代碼行數:10,代碼來源:Type.cs


注:本文中的ProtoCore.DSASM.StackValue.ShallowClone方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。