Exemplo n.º 1
0
        public static RubyModule /*!*/ Of(RubyContext /*!*/ context, TypeGroup /*!*/ self, int genericArity)
        {
            TypeTracker tracker = self.GetTypeForArity(genericArity);

            if (tracker == null)
            {
                throw RubyExceptions.CreateArgumentError("Type group `{0}' does not contain a type of generic arity {1}", self.Name, genericArity);
            }

            return(context.GetModule(tracker.Type));
        }
Exemplo n.º 2
0
        private static Type /*!*/ GetNonGenericType(TypeGroup /*!*/ self)
        {
            TypeTracker type = self.GetTypeForArity(0);

            if (type == null)
            {
                throw RubyExceptions.CreateTypeError("type group doesn't include non-generic type");
            }

            return(type.Type);
        }
Exemplo n.º 3
0
        private static PythonType GetItemHelper(TypeGroup self, PythonType[] types)
        {
            TypeTracker genType = self.GetTypeForArity(types.Length);

            if (genType == null)
            {
                throw new ValueErrorException(String.Format("could not find compatible generic type for {0} type arguments", types.Length));
            }

            Type res = genType.Type;

            if (types.Length != 0)
            {
                res = res.MakeGenericType(PythonTypeOps.ConvertToTypes(types));
            }

            return(DynamicHelpers.GetPythonTypeFromType(res));
        }
Exemplo n.º 4
0
        public static RubyModule /*!*/ Of(RubyContext /*!*/ context, TypeGroup /*!*/ self, [NotNullItems] params object /*!*/[] /*!*/ typeArgs)
        {
            TypeTracker tracker = self.GetTypeForArity(typeArgs.Length);

            if (tracker == null)
            {
                throw RubyExceptions.CreateArgumentError("Invalid number of type arguments for `{0}'", self.Name);
            }

            Type concreteType;

            if (typeArgs.Length > 0)
            {
                concreteType = tracker.Type.MakeGenericType(Protocols.ToTypes(context, typeArgs));
            }
            else
            {
                concreteType = tracker.Type;
            }

            return(context.GetModule(concreteType));
        }
Exemplo n.º 5
0
        private static PythonType GetItemHelper(TypeGroup self, PythonType[] types) {
            TypeTracker genType = self.GetTypeForArity(types.Length);
            if (genType == null) {
                throw new ValueErrorException(String.Format("could not find compatible generic type for {0} type arguments", types.Length));
            }

            Type res = genType.Type;
            if (types.Length != 0) {
                res = res.MakeGenericType(PythonTypeOps.ConvertToTypes(types));
            }

            return DynamicHelpers.GetPythonTypeFromType(res);
        }