private MStructuralClass(string name, Type containerCliType, MClassKinds supportedClassKinds, bool supportsComplex) { Contract.Requires(name != null); this.name = name; this.containerCliType = containerCliType; this.supportedClassKinds = supportedClassKinds & MClassKinds.PrimitiveMask; this.supportsComplex = supportsComplex; var type = containerCliType; while (type != null && type != typeof(object)) { if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(MArray <>)) { isArray = true; } else if (type == typeof(MValue)) { isMValue = true; } type = type.BaseType; } }
public static MClass ByClassKind(MClassKinds kind) { MClass @class; byClassKind.TryGetValue(kind, out @class); return(@class); }
internal MPrimitiveClass(MClassKinds kind, Type cliType) { Contract.Requires(cliType != null); this.kind = kind; this.cliType = cliType; this.name = kind.ToString().ToLowerInvariant(); if ((kind & MClassKinds.NumericMask) != 0) { complexType = new MComplexType(this); } }
internal static void GetTypeInfo(Type t, out MClassKinds kind, out object constants, out object operations) { var primitiveClass = MClass.FromCliType(t) as MPrimitiveClass; kind = primitiveClass.Kind; switch (kind) { case MClassKinds.Double: constants = new MPrimitives <double> .Constants { Zero = 0, One = 1, MinValue = double.NegativeInfinity, MaxValue = double.PositiveInfinity, }; operations = new MPrimitives <double> .Operations { ToDouble = x => x, FromDouble = x => x, Negate = x => - x, Add = (x, y) => x + y, Subtract = (x, y) => x - y, Multiply = (x, y) => x * y, Divide = (x, y) => x / y, Remainder = (x, y) => x % y, Equal = (x, y) => x == y, NotEqual = (x, y) => x != y, LessThan = (x, y) => x <y, LessThanOrEqual = (x, y) => x <= y, GreaterThan = (x, y) => x> y, GreaterThanOrEqual = (x, y) => x >= y, }; return; default: throw new NotImplementedException(); } }
internal ArrayClass(string name, Type containerCliType, MClassKinds supportedClassKinds) : base(name, containerCliType, supportedClassKinds, supportsComplex: true) { }
public GenericMTypeAttribute(MClassKinds classKinds, bool allowComplex) { this.classKinds = classKinds; this.allowComplex = allowComplex; }
public static MClass FromKind(MClassKinds kind) { return(MTypeLookup.ByClassKind(kind)); }