Exemplo n.º 1
0
        public bool SupportsType(MType type)
        {
            Contract.Requires(type != null);

            return((!type.IsComplex || SupportsComplex) &&
                   (type.Class.Kind & SupportedClassKinds) != 0);
        }
Exemplo n.º 2
0
        static MArray()
        {
            // Ensure the generic type is one that supports being in arrays.
            var type = MType.FromCliType(typeof(TScalar));

            Contract.Assert(type != null && type.IsPrimitive);
        }
Exemplo n.º 3
0
        static MFullArray()
        {
            var type = MType.FromCliType(typeof(TScalar));

            Contract.Assert(type != null && type.IsPrimitive);
            repr = new MRepr(type, MStructuralClass.FullArray);
        }
Exemplo n.º 4
0
Arquivo: MRepr.cs Projeto: Sable/McCli
        public MRepr(MType type, MStructuralClass structuralClass)
        {
            Contract.Requires(type == null || structuralClass != null);

            Contract.Assert(structuralClass != MStructuralClass.Array, "Non-full arrays unsupported.");
            this.type            = type;
            this.structuralClass = structuralClass;
        }
Exemplo n.º 5
0
        static MComplex()
        {
            // Ensure the generic type is one that supports complex numbers.
            var @class = MType.FromCliType(typeof(TNumeric)) as MClass;

            if (@class == null || (@class.Kind & MClassKinds.SupportsComplexMask) == 0)
            {
                throw new InvalidOperationException("Invalid scalar type for MComplex type.");
            }
        }
Exemplo n.º 6
0
        public Type GetCliType(MType type)
        {
            Contract.Requires(type != null && SupportsType(type));

            var scalarCliType    = type.CliType;
            var containerCliType = ContainerCliType;

            if (containerCliType == null)
            {
                return(scalarCliType);
            }
            if (!containerCliType.IsGenericTypeDefinition)
            {
                return(containerCliType);
            }
            return(containerCliType.MakeGenericType(scalarCliType));
        }
Exemplo n.º 7
0
Arquivo: MRepr.cs Projeto: Sable/McCli
        public static MRepr FromCliType(Type type)
        {
            Contract.Requires(type != null);

            var mtype = MType.FromCliType(type);

            if (mtype != null)
            {
                return(new MRepr(mtype, mtype.IsPrimitive ? MStructuralClass.Scalar : null));
            }

            if (!type.IsGenericType)
            {
                return(Any);
            }

            mtype = MType.FromCliType(type.GetGenericArguments()[0]);
            if (mtype == null)
            {
                return(Any);
            }

            var genericTypeDefinition = type.GetGenericTypeDefinition();

            if (genericTypeDefinition == typeof(MArray <>))
            {
                return(new MRepr(mtype, MStructuralClass.Array));
            }
            if (genericTypeDefinition == typeof(MFullArray <>))
            {
                return(new MRepr(mtype, MStructuralClass.FullArray));
            }
            if (genericTypeDefinition == typeof(MIntegralRange <>))
            {
                return(new MRepr(mtype, MStructuralClass.IntegralRange));
            }
            return(Any);
        }
Exemplo n.º 8
0
        static MIntegralRange()
        {
            var @class = MType.FromCliType(typeof(TReal));

            Contract.Assert(@class != null && @class.IsNumeric && [email protected]);
        }
Exemplo n.º 9
0
Arquivo: MRepr.cs Projeto: Sable/McCli
 public MRepr(MType type)
 {
     this.type       = type;
     structuralClass = type == null ? null : MStructuralClass.FullArray;
 }