示例#1
0
 static TypeInfo bindGenericParameters(Library typeSystem, GenericParameterBindings genericsScope, TypeInfo typeInfo)
 {
     if (genericsScope.hasBinding(typeInfo))
     {
         return(genericsScope.getBindingValue(typeInfo));
     }
     else if (typeInfo.IsArray)
     {
         return(bindGenericParameters(typeSystem, genericsScope, typeInfo.ElementType).ArrayType);
     }
     else if (typeInfo.TypeKind == TypeKind.UpperBoundedWildcard)
     {
         return(bindGenericParameters(typeSystem, genericsScope, typeInfo.WildcardBound).UpperBoundedWildcard);
     }
     else if (typeInfo.TypeKind == TypeKind.LowerBoundedWildcard)
     {
         return(bindGenericParameters(typeSystem, genericsScope, typeInfo.WildcardBound).LowerBoundedWildcard);
     }
     else if (!typeInfo.IsClosed && typeInfo.GenericArguments.any())
     {
         return(typeSystem.getGenericType(typeInfo, bindGenericParameters(typeSystem, genericsScope, typeInfo.GenericArguments), genericsScope));
     }
     else if (typeInfo.IsGenericParameter && typeInfo.GenericParameterBounds.any())
     {
         var param = new GenericParameterType(typeSystem, typeInfo.FullName, typeInfo);
         genericsScope.declareBinding(typeInfo, param);
         foreach (var t in typeInfo.GenericParameterBounds)
         {
             param.genericParameterBounds.add(bindGenericParameters(typeSystem, genericsScope, t));
         }
         return(param);
     }
     return(typeInfo);
 }
示例#2
0
        static void declareGenericTypeBindings(GenericParameterBindings genericsScope, Iterable <TypeInfo> keys, Iterable <TypeInfo> values)
        {
            if (keys.count() != values.count())
            {
                throw new IllegalStateException();
            }
            var it1 = keys.iterator();
            var it2 = values.iterator();

            while (it1.hasNext())
            {
                var t1 = it1.next();
                var t2 = it2.next();
                if (t1.IsGenericParameter)
                {
                    genericsScope.declareBinding(t1, t2);
                }
            }
        }
 ConstructedGenericType(Library typeSystem, TypeInfo declaringType, TypeInfo genericTypeDefinition, Iterable <TypeInfo> genericArguments,
                        GenericParameterBindings genericsScope)
     : super(typeSystem, genericTypeDefinition.FullName)
示例#4
0
 GenericParameterBindings(GenericParameterBindings next)
 {
     this.next     = next;
     this.bindings = new HashMap <TypeInfo, TypeInfo>();
 }
示例#5
0
 static Iterable <TypeInfo> bindGenericParameters(Library typeSystem, GenericParameterBindings genericsScope, Iterable <TypeInfo> types)
 {
     return(types.select(p => bindGenericParameters(typeSystem, genericsScope, p)).toList());
 }
示例#6
0
 ConstructedGenericMethod(Library typeSystem, TypeInfo declaringType, MethodInfo genericMethodDefinition, Iterable <TypeInfo> genericArguments,
                          GenericParameterBindings genericsScope)
     : super(declaringType, genericMethodDefinition.Name)