PeekSource.smali
.class public final Lokio/PeekSource;
.super Ljava/lang/Object;
# interfaces
.implements Lokio/Source;
# instance fields
.field private final f:Lokio/Buffer;
.field private g:Lokio/Segment;
.field private h:I
.field private i:Z
.field private j:J
.field private final k:Lokio/BufferedSource;
# direct methods
.method public constructor <init>(Lokio/BufferedSource;)V
.registers 3
const-string v0, "upstream"
invoke-static {p1, v0}, Lkotlin/jvm/internal/Intrinsics;->c(Ljava/lang/Object;Ljava/lang/String;)V
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
iput-object p1, p0, Lokio/PeekSource;->k:Lokio/BufferedSource;
invoke-interface {p1}, Lokio/BufferedSource;->c()Lokio/Buffer;
move-result-object p1
iput-object p1, p0, Lokio/PeekSource;->f:Lokio/Buffer;
iget-object p1, p1, Lokio/Buffer;->f:Lokio/Segment;
iput-object p1, p0, Lokio/PeekSource;->g:Lokio/Segment;
if-eqz p1, :cond_19
iget p1, p1, Lokio/Segment;->b:I
goto :goto_1a
:cond_19
const/4 p1, -0x1
:goto_1a
iput p1, p0, Lokio/PeekSource;->h:I
return-void
.end method
# virtual methods
.method public close()V
.registers 2
const/4 v0, 0x1
iput-boolean v0, p0, Lokio/PeekSource;->i:Z
return-void
.end method
.method public o1(Lokio/Buffer;J)J
.registers 12
const-string v0, "sink"
invoke-static {p1, v0}, Lkotlin/jvm/internal/Intrinsics;->c(Ljava/lang/Object;Ljava/lang/String;)V
const/4 v0, 0x0
const-wide/16 v1, 0x0
const/4 v3, 0x1
cmp-long v4, p2, v1
if-ltz v4, :cond_f
const/4 v5, 0x1
goto :goto_10
:cond_f
const/4 v5, 0x0
:goto_10
if-eqz v5, :cond_90
iget-boolean v5, p0, Lokio/PeekSource;->i:Z
xor-int/2addr v5, v3
if-eqz v5, :cond_84
iget-object v5, p0, Lokio/PeekSource;->g:Lokio/Segment;
const/4 v6, 0x0
if-eqz v5, :cond_2f
iget-object v7, p0, Lokio/PeekSource;->f:Lokio/Buffer;
iget-object v7, v7, Lokio/Buffer;->f:Lokio/Segment;
if-ne v5, v7, :cond_30
iget v5, p0, Lokio/PeekSource;->h:I
if-eqz v7, :cond_2b
iget v7, v7, Lokio/Segment;->b:I
if-ne v5, v7, :cond_30
goto :goto_2f
:cond_2b
invoke-static {}, Lkotlin/jvm/internal/Intrinsics;->h()V
throw v6
:cond_2f
:goto_2f
const/4 v0, 0x1
:cond_30
if-eqz v0, :cond_78
if-nez v4, :cond_35
return-wide v1
:cond_35
iget-object v0, p0, Lokio/PeekSource;->k:Lokio/BufferedSource;
iget-wide v1, p0, Lokio/PeekSource;->j:J
const-wide/16 v3, 0x1
add-long/2addr v1, v3
invoke-interface {v0, v1, v2}, Lokio/BufferedSource;->P0(J)Z
move-result v0
if-nez v0, :cond_45
const-wide/16 p1, -0x1
return-wide p1
:cond_45
iget-object v0, p0, Lokio/PeekSource;->g:Lokio/Segment;
if-nez v0, :cond_5c
iget-object v0, p0, Lokio/PeekSource;->f:Lokio/Buffer;
iget-object v0, v0, Lokio/Buffer;->f:Lokio/Segment;
if-eqz v0, :cond_5c
iput-object v0, p0, Lokio/PeekSource;->g:Lokio/Segment;
if-eqz v0, :cond_58
iget v0, v0, Lokio/Segment;->b:I
iput v0, p0, Lokio/PeekSource;->h:I
goto :goto_5c
:cond_58
invoke-static {}, Lkotlin/jvm/internal/Intrinsics;->h()V
throw v6
:cond_5c
:goto_5c
iget-object v0, p0, Lokio/PeekSource;->f:Lokio/Buffer;
invoke-virtual {v0}, Lokio/Buffer;->size()J
move-result-wide v0
iget-wide v2, p0, Lokio/PeekSource;->j:J
sub-long/2addr v0, v2
invoke-static {p2, p3, v0, v1}, Ljava/lang/Math;->min(JJ)J
move-result-wide p2
iget-object v2, p0, Lokio/PeekSource;->f:Lokio/Buffer;
iget-wide v4, p0, Lokio/PeekSource;->j:J
move-object v3, p1
move-wide v6, p2
invoke-virtual/range {v2 .. v7}, Lokio/Buffer;->g(Lokio/Buffer;JJ)Lokio/Buffer;
iget-wide v0, p0, Lokio/PeekSource;->j:J
add-long/2addr v0, p2
iput-wide v0, p0, Lokio/PeekSource;->j:J
return-wide p2
:cond_78
new-instance p1, Ljava/lang/IllegalStateException;
const-string p2, "Peek source is invalid because upstream source was used"
invoke-virtual {p2}, Ljava/lang/Object;->toString()Ljava/lang/String;
move-result-object p2
invoke-direct {p1, p2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw p1
:cond_84
new-instance p1, Ljava/lang/IllegalStateException;
const-string p2, "closed"
invoke-virtual {p2}, Ljava/lang/Object;->toString()Ljava/lang/String;
move-result-object p2
invoke-direct {p1, p2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw p1
:cond_90
new-instance p1, Ljava/lang/StringBuilder;
invoke-direct {p1}, Ljava/lang/StringBuilder;-><init>()V
const-string v0, "byteCount < 0: "
invoke-virtual {p1, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {p1, p2, p3}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;
invoke-virtual {p1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p1
new-instance p2, Ljava/lang/IllegalArgumentException;
invoke-virtual {p1}, Ljava/lang/Object;->toString()Ljava/lang/String;
move-result-object p1
invoke-direct {p2, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
throw p2
.end method
.method public timeout()Lokio/Timeout;
.registers 2
iget-object v0, p0, Lokio/PeekSource;->k:Lokio/BufferedSource;
invoke-interface {v0}, Lokio/Source;->timeout()Lokio/Timeout;
move-result-object v0
return-object v0
.end method