Search in sources :

Example 1 with InternalMap

use of org.eclipse.ceylon.compiler.java.language.InternalMap in project ceylon by eclipse.

the class Metamodel method getTypeArgumentWithVariances.

public static ceylon.language.Map<? extends ceylon.language.meta.declaration.TypeParameter, ? extends ceylon.language.Sequence<? extends Object>> getTypeArgumentWithVariances(ceylon.language.meta.declaration.GenericDeclaration declaration, Reference appliedFunction) {
    java.util.Map<ceylon.language.meta.declaration.TypeParameter, ceylon.language.Sequence<? extends Object>> typeArguments = new LinkedHashMap<ceylon.language.meta.declaration.TypeParameter, ceylon.language.Sequence<? extends Object>>();
    Iterator<? extends ceylon.language.meta.declaration.TypeParameter> typeParameters = declaration.getTypeParameterDeclarations().iterator();
    Object it;
    java.util.Map<org.eclipse.ceylon.model.typechecker.model.TypeParameter, org.eclipse.ceylon.model.typechecker.model.Type> ptArguments = appliedFunction.getTypeArguments();
    Map<TypeParameter, SiteVariance> varianceOverrides = appliedFunction instanceof org.eclipse.ceylon.model.typechecker.model.Type ? ((org.eclipse.ceylon.model.typechecker.model.Type) appliedFunction).getVarianceOverrides() : null;
    while ((it = typeParameters.next()) != finished_.get_()) {
        org.eclipse.ceylon.compiler.java.runtime.metamodel.decl.TypeParameterImpl tp = (org.eclipse.ceylon.compiler.java.runtime.metamodel.decl.TypeParameterImpl) it;
        org.eclipse.ceylon.model.typechecker.model.TypeParameter tpDecl = (org.eclipse.ceylon.model.typechecker.model.TypeParameter) tp.declaration;
        org.eclipse.ceylon.model.typechecker.model.Type ptArg = ptArguments.get(tpDecl);
        ceylon.language.meta.model.Type<?> ptArgWrapped = Metamodel.getAppliedMetamodel(ptArg);
        ceylon.language.meta.declaration.Variance variance = modelVarianceToMetaModel(varianceOverrides, tpDecl);
        ceylon.language.Sequence<? extends Object> tuple = ceylon.language.Tuple.instance(TD_ClosedTypeArgumentElement, new Object[] { ptArgWrapped, variance });
        typeArguments.put(tp, tuple);
    }
    return new InternalMap<ceylon.language.meta.declaration.TypeParameter, ceylon.language.Sequence<?>>(ceylon.language.meta.declaration.TypeParameter.$TypeDescriptor$, TD_ClosedTypeArgument, typeArguments);
}
Also used : TypeParameter(org.eclipse.ceylon.model.typechecker.model.TypeParameter) Type(org.eclipse.ceylon.model.typechecker.model.Type) LinkedHashMap(java.util.LinkedHashMap) TypeParameter(org.eclipse.ceylon.model.typechecker.model.TypeParameter) Metamodel(org.eclipse.ceylon.compiler.java.runtime.metamodel.Metamodel) InternalMap(org.eclipse.ceylon.compiler.java.language.InternalMap) ReifiedType(org.eclipse.ceylon.compiler.java.runtime.model.ReifiedType) NothingType(org.eclipse.ceylon.model.typechecker.model.NothingType) OpenClassOrInterfaceType(ceylon.language.meta.declaration.OpenClassOrInterfaceType) OpenType(ceylon.language.meta.declaration.OpenType) DeclarationType(org.eclipse.ceylon.model.loader.ModelLoader.DeclarationType) Type(org.eclipse.ceylon.model.typechecker.model.Type) UnknownType(org.eclipse.ceylon.model.typechecker.model.UnknownType) SiteVariance(org.eclipse.ceylon.model.typechecker.model.SiteVariance)

Example 2 with InternalMap

use of org.eclipse.ceylon.compiler.java.language.InternalMap in project ceylon by eclipse.

the class Metamodel method getTypeArguments.

public static ceylon.language.Map<? extends ceylon.language.meta.declaration.TypeParameter, ? extends ceylon.language.meta.model.Type<?>> getTypeArguments(ceylon.language.meta.declaration.GenericDeclaration declaration, Reference appliedFunction) {
    java.util.Map<ceylon.language.meta.declaration.TypeParameter, ceylon.language.meta.model.Type<?>> typeArguments = new LinkedHashMap<ceylon.language.meta.declaration.TypeParameter, ceylon.language.meta.model.Type<?>>();
    Iterator<? extends ceylon.language.meta.declaration.TypeParameter> typeParameters = declaration.getTypeParameterDeclarations().iterator();
    Object it;
    java.util.Map<org.eclipse.ceylon.model.typechecker.model.TypeParameter, org.eclipse.ceylon.model.typechecker.model.Type> ptArguments = appliedFunction.getTypeArguments();
    while ((it = typeParameters.next()) != finished_.get_()) {
        org.eclipse.ceylon.compiler.java.runtime.metamodel.decl.TypeParameterImpl tp = (org.eclipse.ceylon.compiler.java.runtime.metamodel.decl.TypeParameterImpl) it;
        org.eclipse.ceylon.model.typechecker.model.TypeParameter tpDecl = (org.eclipse.ceylon.model.typechecker.model.TypeParameter) tp.declaration;
        org.eclipse.ceylon.model.typechecker.model.Type ptArg = ptArguments.get(tpDecl);
        ceylon.language.meta.model.Type<?> ptArgWrapped = Metamodel.getAppliedMetamodel(ptArg);
        typeArguments.put(tp, ptArgWrapped);
    }
    return new InternalMap<ceylon.language.meta.declaration.TypeParameter, ceylon.language.meta.model.Type<?>>(ceylon.language.meta.declaration.TypeParameter.$TypeDescriptor$, TD_ClosedTypeOfAnything, typeArguments);
}
Also used : TypeParameter(org.eclipse.ceylon.model.typechecker.model.TypeParameter) Type(org.eclipse.ceylon.model.typechecker.model.Type) LinkedHashMap(java.util.LinkedHashMap) TypeParameter(org.eclipse.ceylon.model.typechecker.model.TypeParameter) Metamodel(org.eclipse.ceylon.compiler.java.runtime.metamodel.Metamodel) InternalMap(org.eclipse.ceylon.compiler.java.language.InternalMap) ReifiedType(org.eclipse.ceylon.compiler.java.runtime.model.ReifiedType) NothingType(org.eclipse.ceylon.model.typechecker.model.NothingType) OpenClassOrInterfaceType(ceylon.language.meta.declaration.OpenClassOrInterfaceType) OpenType(ceylon.language.meta.declaration.OpenType) DeclarationType(org.eclipse.ceylon.model.loader.ModelLoader.DeclarationType) Type(org.eclipse.ceylon.model.typechecker.model.Type) UnknownType(org.eclipse.ceylon.model.typechecker.model.UnknownType)

Aggregations

OpenClassOrInterfaceType (ceylon.language.meta.declaration.OpenClassOrInterfaceType)2 OpenType (ceylon.language.meta.declaration.OpenType)2 LinkedHashMap (java.util.LinkedHashMap)2 InternalMap (org.eclipse.ceylon.compiler.java.language.InternalMap)2 Metamodel (org.eclipse.ceylon.compiler.java.runtime.metamodel.Metamodel)2 ReifiedType (org.eclipse.ceylon.compiler.java.runtime.model.ReifiedType)2 DeclarationType (org.eclipse.ceylon.model.loader.ModelLoader.DeclarationType)2 NothingType (org.eclipse.ceylon.model.typechecker.model.NothingType)2 Type (org.eclipse.ceylon.model.typechecker.model.Type)2 TypeParameter (org.eclipse.ceylon.model.typechecker.model.TypeParameter)2 UnknownType (org.eclipse.ceylon.model.typechecker.model.UnknownType)2 SiteVariance (org.eclipse.ceylon.model.typechecker.model.SiteVariance)1