protected void init() {
    com.redhat.ceylon.compiler.typechecker.model.ClassOrInterface decl =
        (com.redhat.ceylon.compiler.typechecker.model.ClassOrInterface)
            producedType.getDeclaration();
    this.declaration = (FreeClassOrInterface) Metamodel.getOrCreateMetamodel(decl);
    java.util.Map<
            ceylon.language.meta.declaration.TypeParameter,
            ceylon.language.meta.declaration.OpenType>
        typeArguments =
            new LinkedHashMap<
                ceylon.language.meta.declaration.TypeParameter,
                ceylon.language.meta.declaration.OpenType>();
    Iterator<? extends ceylon.language.meta.declaration.TypeParameter> typeParameters =
        declaration.getTypeParameterDeclarations().iterator();
    Object it;
    java.util.Map<
            com.redhat.ceylon.compiler.typechecker.model.TypeParameter,
            com.redhat.ceylon.compiler.typechecker.model.ProducedType>
        ptArguments = producedType.getTypeArguments();
    while ((it = typeParameters.next()) != finished_.$get()) {
      com.redhat.ceylon.compiler.java.runtime.metamodel.FreeTypeParameter tp =
          (com.redhat.ceylon.compiler.java.runtime.metamodel.FreeTypeParameter) it;
      com.redhat.ceylon.compiler.typechecker.model.TypeParameter tpDecl =
          (com.redhat.ceylon.compiler.typechecker.model.TypeParameter) tp.declaration;
      com.redhat.ceylon.compiler.typechecker.model.ProducedType ptArg = ptArguments.get(tpDecl);
      OpenType ptArgWrapped = Metamodel.getMetamodel(ptArg);
      typeArguments.put(tp, ptArgWrapped);
    }
    this.typeArguments =
        new InternalMap<
            ceylon.language.meta.declaration.TypeParameter,
            ceylon.language.meta.declaration.OpenType>(
            ceylon.language.meta.declaration.TypeParameter.$TypeDescriptor,
            ceylon.language.meta.declaration.OpenType.$TypeDescriptor,
            typeArguments);

    com.redhat.ceylon.compiler.typechecker.model.ProducedType superType = decl.getExtendedType();
    if (superType != null) {
      com.redhat.ceylon.compiler.typechecker.model.ProducedType superTypeResolved =
          superType.substitute(producedType.getTypeArguments());
      this.superclass =
          (ceylon.language.meta.declaration.OpenClassType)
              Metamodel.getMetamodel(superTypeResolved);
    }

    List<com.redhat.ceylon.compiler.typechecker.model.ProducedType> satisfiedTypes =
        decl.getSatisfiedTypes();
    ceylon.language.meta.declaration.OpenInterfaceType[] interfaces =
        new ceylon.language.meta.declaration.OpenInterfaceType[satisfiedTypes.size()];
    int i = 0;
    for (com.redhat.ceylon.compiler.typechecker.model.ProducedType pt : satisfiedTypes) {
      com.redhat.ceylon.compiler.typechecker.model.ProducedType resolvedPt =
          pt.substitute(producedType.getTypeArguments());
      interfaces[i++] =
          (ceylon.language.meta.declaration.OpenInterfaceType) Metamodel.getMetamodel(resolvedPt);
    }
    this.interfaces =
        Util.sequentialInstance(
            ceylon.language.meta.declaration.OpenInterfaceType.$TypeDescriptor, interfaces);
  }
 public java.lang.Object next() {
   elem = orig.next();
   if (!(elem instanceof Finished)) {
     return sel.$call(elem);
   }
   return elem;
 }
示例#3
0
 @SuppressWarnings("unchecked")
 public static <T> List<T> collectIterable(
     Iterable<? extends T, ? extends java.lang.Object> sequence) {
   List<T> list = new LinkedList<T>();
   if (sequence != null) {
     Iterator<? extends T> iterator = sequence.iterator();
     Object o;
     while ((o = iterator.next()) != finished_.getFinished$()) {
       list.add((T) o);
     }
   }
   return list;
 }
示例#4
0
 @Override
 public boolean containsAny(Iterable<? extends Object, ? extends Object> arg0) {
   Iterator<? extends Object> iter = arg0.iterator();
   Object item;
   while (!((item = iter.next()) instanceof Finished)) {
     if (item instanceof ceylon.language.Byte) {
       for (int ii = this.start; ii < this.end; ii += this.step) {
         if (array[ii] == ((ceylon.language.Byte) item).byteValue()) {
           return true;
         }
       }
     }
   }
   return false;
 }
示例#5
0
 /**
  * Return {@link empty_#getEmpty$ empty} or an {@link ArraySequence} wrapping the given elements,
  * depending on whether the given array and varargs are empty
  *
  * @param rest The elements at the end of the sequence
  * @param elements the elements at the start of the sequence
  * @return A Sequential
  */
 public static <T> Sequential<? extends T> sequentialInstance(
     TypeDescriptor $reifiedT, Sequential<? extends T> rest, T... elements) {
   if (elements.length == 0) {
     if (rest.getEmpty()) {
       return (Sequential) empty_.getEmpty$();
     }
     return rest;
   }
   // elements is not empty
   if (rest.getEmpty()) return ArraySequence.<T>instance($reifiedT, elements);
   // we have both, let's find the total size
   int total = (int) (rest.getSize() + elements.length);
   java.lang.Object[] newArray = new java.lang.Object[total];
   System.arraycopy(elements, 0, newArray, 0, elements.length);
   Iterator<? extends T> iterator = rest.iterator();
   int i = elements.length;
   for (Object elem; (elem = iterator.next()) != finished_.getFinished$(); i++) {
     newArray[i] = elem;
   }
   return ArraySequence.<T>instance($reifiedT, newArray);
 }