当前位置: 首页>>代码示例>>C#>>正文


C# XTypeReference.IsChar方法代码示例

本文整理汇总了C#中Dot42.CompilerLib.XModel.XTypeReference.IsChar方法的典型用法代码示例。如果您正苦于以下问题:C# XTypeReference.IsChar方法的具体用法?C# XTypeReference.IsChar怎么用?C# XTypeReference.IsChar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dot42.CompilerLib.XModel.XTypeReference的用法示例。


在下文中一共展示了XTypeReference.IsChar方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConvertIfNeeded

        /// <summary>
        /// Convert the result of the given node to uint8/uint16 if needed.
        /// </summary>
        private static void ConvertIfNeeded(AstExpression node, XTypeReference valueType, AstExpression parent)
        {
            AstCode convCode;
            if (valueType.IsByte())
            {
                // Convert from int to uint8
                convCode = AstCode.Int_to_ubyte;
            }
            else if (valueType.IsUInt16())
            {
                // Convert from int to uint16
                convCode = AstCode.Int_to_ushort;
            }
            else if (valueType.IsChar())
            {
                // Convert from int to uint16
                convCode = AstCode.Conv_U2;
            }
            else
            {
                // Do not convert
                return;
            }

            // Avoid recursion
            if ((parent != null) && (parent.Code == convCode))
                return;

            // Copy load expression
            var clone = new AstExpression(node);

            // Convert node
            node.Code = convCode;
            node.Arguments.Clear();
            node.Arguments.Add(clone);
            node.Operand = null;
            node.InferredType = valueType;
            
            // keep the expected type!
            node.ExpectedType = clone.ExpectedType;
            clone.ExpectedType = valueType;
            
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:46,代码来源:ConvertAfterLoadConversionConverter.cs

示例2: ConvertIfNeeded

 /// <summary>
 /// Convert the given argument if it does not match the target type.
 /// </summary>
 private static void ConvertIfNeeded(AstExpression arg, XTypeReference targetType)
 {
     var argType = arg.GetResultType();
     if (!targetType.IsSame(argType))
     {
         if (targetType.IsChar())
         {
             if (argType.IsUInt16() || argType.IsByte()) Convert(arg, AstCode.Conv_U2, targetType);
         }
         else if (targetType.IsUInt16())
         {
             if (argType.IsChar() || argType.IsByte()) Convert(arg, AstCode.Int_to_ushort, targetType);
         }
         else if (targetType.IsInt16())
         {
             if (argType.IsChar() || argType.IsByte()) Convert(arg, AstCode.Conv_I2, targetType);
         }
     }
 }
开发者ID:rfcclub,项目名称:dot42,代码行数:22,代码来源:ConvertBeforeStoreConversionConverter.cs

示例3: GetAsEnumerableTMethodName

 /// <summary>
 /// Returns the method name when converting an array to an IEnumerableT in compiler helper.
 /// 
 /// (not sure if this is the best place for this method...)
 /// </summary>
 public static string GetAsEnumerableTMethodName(XTypeReference sourceArrayElementType)
 {
     var convertMethodName = "AsObjectEnumerable";
     if (sourceArrayElementType.IsPrimitive)
     {
         if (sourceArrayElementType.IsBoolean()) convertMethodName = "AsBoolEnumerable";
         else if (sourceArrayElementType.IsByte()) convertMethodName = "AsByteEnumerable";
         else if (sourceArrayElementType.IsSByte()) convertMethodName = "AsSByteEnumerable";
         else if (sourceArrayElementType.IsChar()) convertMethodName = "AsCharEnumerable";
         else if (sourceArrayElementType.IsInt16()) convertMethodName = "AsInt16Enumerable";
         else if (sourceArrayElementType.IsUInt16()) convertMethodName = "AsUInt16Enumerable";
         else if (sourceArrayElementType.IsInt32()) convertMethodName = "AsInt32Enumerable";
         else if (sourceArrayElementType.IsUInt32()) convertMethodName = "AsUInt32Enumerable";
         else if (sourceArrayElementType.IsInt64()) convertMethodName = "AsInt64Enumerable";
         else if (sourceArrayElementType.IsFloat()) convertMethodName = "AsFloatEnumerable";
         else if (sourceArrayElementType.IsDouble()) convertMethodName = "AsDoubleEnumerable";
         else throw new ArgumentOutOfRangeException("Unknown primitive array element type " + sourceArrayElementType);
     }
     return convertMethodName;
 }
开发者ID:Xtremrules,项目名称:dot42,代码行数:25,代码来源:FrameworkReferences.cs

示例4: OpcodeForType

        /// <summary>
        /// Generate an Add opcode.
        /// </summary>
        private static RCode OpcodeForType(XTypeReference type, RCode[] opcodes)
        {
            if (type.IsInt32() || type.IsUInt32() || type.IsInt16() || type.IsUInt16() || type.IsChar() || type.IsByte() || type.IsSByte() || type.IsBoolean()) return opcodes[0];
            if (type.IsInt64() || type.IsUInt64()) return opcodes[1];
            if (type.IsFloat()) return opcodes[2];
            if (type.IsDouble()) return opcodes[3];

            XTypeDefinition typeDef;
            if (type.TryResolve(out typeDef))
            {
                if (typeDef.IsEnum)
                {
                    return OpcodeForType(typeDef.GetEnumUnderlyingType(), opcodes);
                }
            }

            throw new ArgumentException("Unsupported type " + type);
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:21,代码来源:RCode.cs


注:本文中的Dot42.CompilerLib.XModel.XTypeReference.IsChar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。