package g.e0.j.a;

import g.e0.j.a.f;
import g.h0.c.l;
import g.i;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

/* JADX INFO: compiled from: ContinuationImpl.kt */
/* JADX INFO: loaded from: classes.dex */
@i
public abstract class a implements g.e0.d<Object>, d, Serializable {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final g.e0.d<Object> f4084b;

    public a(g.e0.d<Object> dVar) {
        this.f4084b = dVar;
    }

    public StackTraceElement a() {
        int iIntValue;
        String strC;
        l.f(this, "<this>");
        e eVar = (e) getClass().getAnnotation(e.class);
        String str = null;
        if (eVar == null) {
            return null;
        }
        int iV = eVar.v();
        if (iV > 1) {
            throw new IllegalStateException(("Debug metadata version mismatch. Expected: 1, got " + iV + ". Please update the Kotlin standard library.").toString());
        }
        try {
            Field declaredField = getClass().getDeclaredField("label");
            declaredField.setAccessible(true);
            Object obj = declaredField.get(this);
            Integer num = obj instanceof Integer ? (Integer) obj : null;
            iIntValue = (num != null ? num.intValue() : 0) - 1;
        } catch (Exception unused) {
            iIntValue = -1;
        }
        int i2 = iIntValue >= 0 ? eVar.l()[iIntValue] : -1;
        l.f(this, "continuation");
        f.a aVar = f.f4089c;
        if (aVar == null) {
            try {
                f.a aVar2 = new f.a(Class.class.getDeclaredMethod("getModule", new Class[0]), getClass().getClassLoader().loadClass("java.lang.Module").getDeclaredMethod("getDescriptor", new Class[0]), getClass().getClassLoader().loadClass("java.lang.module.ModuleDescriptor").getDeclaredMethod("name", new Class[0]));
                f.f4089c = aVar2;
                aVar = aVar2;
            } catch (Exception unused2) {
                aVar = f.f4088b;
                f.f4089c = aVar;
            }
        }
        if (aVar != f.f4088b) {
            Method method = aVar.a;
            Object objInvoke = method != null ? method.invoke(getClass(), new Object[0]) : null;
            if (objInvoke != null) {
                Method method2 = aVar.f4090b;
                Object objInvoke2 = method2 != null ? method2.invoke(objInvoke, new Object[0]) : null;
                if (objInvoke2 != null) {
                    Method method3 = aVar.f4091c;
                    Object objInvoke3 = method3 != null ? method3.invoke(objInvoke2, new Object[0]) : null;
                    if (objInvoke3 instanceof String) {
                        str = (String) objInvoke3;
                    }
                }
            }
        }
        if (str == null) {
            strC = eVar.c();
        } else {
            strC = str + '/' + eVar.c();
        }
        return new StackTraceElement(strC, eVar.m(), eVar.f(), i2);
    }

    public abstract Object b(Object obj);

    @Override // g.e0.j.a.d
    public d c() {
        g.e0.d<Object> dVar = this.f4084b;
        if (dVar instanceof d) {
            return (d) dVar;
        }
        return null;
    }

    @Override // g.e0.d
    public final void f(Object obj) {
        g.e0.d<Object> dVar = this;
        while (true) {
            l.f(dVar, "frame");
            a aVar = (a) dVar;
            g.e0.d<Object> dVar2 = aVar.f4084b;
            l.c(dVar2);
            try {
                obj = aVar.b(obj);
                if (obj == g.e0.i.a.COROUTINE_SUSPENDED) {
                    return;
                }
            } catch (Throwable th) {
                obj = f.a.y.a.L(th);
            }
            aVar.g();
            if (!(dVar2 instanceof a)) {
                dVar2.f(obj);
                return;
            }
            dVar = dVar2;
        }
    }

    public void g() {
    }

    public String toString() {
        StringBuilder sbB = d.b.a.a.a.B("Continuation at ");
        Object objA = a();
        if (objA == null) {
            objA = getClass().getName();
        }
        sbB.append(objA);
        return sbB.toString();
    }
}
