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


C# IType.IsNull方法代码示例

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


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

示例1: AssertTypeCompatibility

		public bool AssertTypeCompatibility(Node sourceNode, IType expectedType, IType actualType)
		{
			if (IsError(expectedType) || IsError(actualType))
				return false;

			if (expectedType.IsPointer && actualType.IsPointer)
				return true; //if both types are unmanaged pointers casting is always possible

			if (TypeSystemServices.IsNullable(expectedType) && actualType.IsNull())
				return true;

			if (!CanBeReachedFrom(sourceNode, expectedType, actualType))
			{
				_errors.Instance.Add(CompilerErrorFactory.IncompatibleExpressionType(sourceNode, expectedType, actualType));
				return false;
			}
			return true;
		}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:18,代码来源:TypeChecker.cs

示例2: MapNullToObject

 IType MapNullToObject(IType type)
 {
     // FIXME: refactor to TypeSystemServices
     if (type.IsNull())
         return TypeSystemServices.ObjectType;
     if (EmptyArrayType.Default == type)
         return TypeSystemServices.ObjectArrayType;
     return type;
 }
开发者ID:stuman08,项目名称:boo,代码行数:9,代码来源:ProcessMethodBodies.cs

示例3: SystemTypeFrom

        private Type SystemTypeFrom(IType entity)
        {
            var external = entity as ExternalType;
            if (null != external)
                return external.ActualType;

            if (entity.IsArray)
            {
                IArrayType arrayType = (IArrayType)entity;
                Type systemType = GetSystemType(arrayType.ElementType);
                int rank = arrayType.Rank;

                if (rank == 1) return systemType.MakeArrayType();
                return systemType.MakeArrayType(rank);
            }

            if (entity.ConstructedInfo != null)
            {
                // Type is a constructed generic type - create it using its definition's system type
                Type[] arguments = Array.ConvertAll<IType, Type>(entity.ConstructedInfo.GenericArguments, GetSystemType);
                return GetSystemType(entity.ConstructedInfo.GenericDefinition).MakeGenericType(arguments);
            }

            if (entity.IsNull())
                return Types.Object;

            if (entity is InternalGenericParameter)
                return (Type)GetBuilder(((InternalGenericParameter)entity).Node);

            if (entity is AbstractInternalType)
            {
                TypeDefinition typedef = ((AbstractInternalType) entity).TypeDefinition;
                var type = (Type)GetBuilder(typedef);

                if (null != entity.GenericInfo && !type.IsGenericType) //hu-oh, early-bound
                    DefineGenericParameters(typedef);

                if (entity.IsPointer && null != type)
                    return type.MakePointerType();

                return type;
            }

            return null;
        }
开发者ID:skalinets,项目名称:boo,代码行数:45,代码来源:EmitAssembly.cs

示例4: CanBeReachedByPromotionImpl

 private bool CanBeReachedByPromotionImpl(IType expectedType, IType actualType)
 {
     if (IsNullable(expectedType) && actualType.IsNull())
         return true;
     if (IsIntegerNumber(actualType) && CanBeExplicitlyCastToPrimitiveNumber(expectedType))
         return true;
     if (IsIntegerNumber(expectedType) && CanBeExplicitlyCastToPrimitiveNumber(actualType))
         return true;
     return (expectedType.IsValueType && IsNumber(expectedType) && IsNumber(actualType));
 }
开发者ID:boo-lang,项目名称:boo,代码行数:10,代码来源:TypeSystemServices.cs

示例5: MapWildcardType

 public IType MapWildcardType(IType type)
 {
     if (type.IsNull())
         return ObjectType;
     if (EmptyArrayType.Default == type)
         return ObjectArrayType;
     return type;
 }
开发者ID:boo-lang,项目名称:boo,代码行数:8,代码来源:TypeSystemServices.cs

示例6: IsCallableTypeAssignableFrom

        public bool IsCallableTypeAssignableFrom(ICallableType lhs, IType rhs)
        {
            if (lhs == rhs) return true;
            if (rhs.IsNull()) return true;

            var other = rhs as ICallableType;
            if (null == other) return false;

            CallableSignature lvalue = lhs.GetSignature();
            CallableSignature rvalue = other.GetSignature();
            if (lvalue == rvalue) return true;

            IParameter[] lparams = lvalue.Parameters;
            IParameter[] rparams = rvalue.Parameters;
            if (lparams.Length < rparams.Length) return false;

            for (int i = 0; i < rparams.Length; ++i)
                if (!CanBeReachedFrom(lparams[i].Type, rparams[i].Type))
                    return false;

            return CompatibleReturnTypes(lvalue, rvalue);
        }
开发者ID:boo-lang,项目名称:boo,代码行数:22,代码来源:TypeSystemServices.cs

示例7: IsAssignableFrom

		public virtual bool IsAssignableFrom(IType other)
		{			
			if (other == this || other.IsNull())
				return true;

			if (!other.IsArray)
				return false;

			var otherArray = (IArrayType)other;
			if (otherArray.Rank != _rank)
				return false;

			if (otherArray == EmptyArrayType.Default)
				return true;

			IType otherElementType = otherArray.ElementType;
			return IsAssignableFrom(_elementType, otherElementType);
		}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:18,代码来源:ArrayType.cs

示例8: IsAssignableFrom

		public virtual bool IsAssignableFrom(IType other)
		{
			if (other == this)
                return true;
		
			if (other.IsNull())
				return IsClass;

			var otherParameter = other as IGenericParameter;
			if (otherParameter != null && Array.Exists(otherParameter.GetTypeConstraints(), constraint => TypeCompatibilityRules.IsAssignableFrom(this, constraint)))
				return true;

			return false;
		}
开发者ID:Rfvgyhn,项目名称:boo,代码行数:14,代码来源:AbstractGenericParameter.cs

示例9: IsAssignableFrom

		public virtual bool IsAssignableFrom(IType other)
		{
			if (other == null)
				return false;

			if (other == this || other.IsSubclassOf(this) || (other.IsNull() && !IsValueType))
				return true;

			return false;
		}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:10,代码来源:GenericConstructedType.cs


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