discord-jadx/app/src/main/java/d0/f0/j.java

137 lines
4.0 KiB
Java

package d0.f0;
import d0.k;
import d0.l;
import d0.w.f;
import d0.w.g.c;
import d0.w.h.a.g;
import d0.z.d.g0.a;
import d0.z.d.m;
import java.util.Iterator;
import java.util.NoSuchElementException;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.CoroutineContext;
/* compiled from: SequenceBuilder.kt */
public final class j<T> extends k<T> implements Iterator<T>, Continuation<Unit>, a {
public int i;
public T j;
public Iterator<? extends T> k;
public Continuation<? super Unit> l;
public final Throwable c() {
int i = this.i;
if (i == 4) {
return new NoSuchElementException();
}
if (i == 5) {
return new IllegalStateException("Iterator has failed.");
}
StringBuilder L = c.d.b.a.a.L("Unexpected state of the iterator: ");
L.append(this.i);
return new IllegalStateException(L.toString());
}
@Override // kotlin.coroutines.Continuation
public CoroutineContext getContext() {
return f.i;
}
@Override // java.util.Iterator
public boolean hasNext() {
while (true) {
int i = this.i;
if (i != 0) {
if (i == 1) {
Iterator<? extends T> it = this.k;
m.checkNotNull(it);
if (it.hasNext()) {
this.i = 2;
return true;
}
this.k = null;
} else if (i == 2 || i == 3) {
return true;
} else {
if (i == 4) {
return false;
}
throw c();
}
}
this.i = 5;
Continuation<? super Unit> continuation = this.l;
m.checkNotNull(continuation);
this.l = null;
Unit unit = Unit.a;
k.a aVar = k.i;
continuation.resumeWith(k.m78constructorimpl(unit));
}
}
@Override // java.util.Iterator
public T next() {
int i = this.i;
if (i == 0 || i == 1) {
if (hasNext()) {
return next();
}
throw new NoSuchElementException();
} else if (i == 2) {
this.i = 1;
Iterator<? extends T> it = this.k;
m.checkNotNull(it);
return (T) it.next();
} else if (i == 3) {
this.i = 0;
T t = this.j;
this.j = null;
return t;
} else {
throw c();
}
}
@Override // java.util.Iterator
public void remove() {
throw new UnsupportedOperationException("Operation is not supported for read-only collection");
}
@Override // kotlin.coroutines.Continuation
public void resumeWith(Object obj) {
l.throwOnFailure(obj);
this.i = 4;
}
public final void setNextStep(Continuation<? super Unit> continuation) {
this.l = continuation;
}
@Override // d0.f0.k
public Object yield(T t, Continuation<? super Unit> continuation) {
this.j = t;
this.i = 3;
this.l = continuation;
Object coroutine_suspended = c.getCOROUTINE_SUSPENDED();
if (coroutine_suspended == c.getCOROUTINE_SUSPENDED()) {
g.probeCoroutineSuspended(continuation);
}
return coroutine_suspended == c.getCOROUTINE_SUSPENDED() ? coroutine_suspended : Unit.a;
}
@Override // d0.f0.k
public Object yieldAll(Iterator<? extends T> it, Continuation<? super Unit> continuation) {
if (!it.hasNext()) {
return Unit.a;
}
this.k = it;
this.i = 2;
this.l = continuation;
Object coroutine_suspended = c.getCOROUTINE_SUSPENDED();
if (coroutine_suspended == c.getCOROUTINE_SUSPENDED()) {
g.probeCoroutineSuspended(continuation);
}
return coroutine_suspended == c.getCOROUTINE_SUSPENDED() ? coroutine_suspended : Unit.a;
}
}