PeekSource.smali
.class public final Lokio/PeekSource;
.super Ljava/lang/Object;
.source "PeekSource.kt"
# interfaces
.implements Lokio/Source;
# annotations
.annotation system Ldalvik/annotation/SourceDebugExtension;
value = "SMAP\nPeekSource.kt\nKotlin\n*S Kotlin\n*F\n+ 1 PeekSource.kt\nokio/PeekSource\n*L\n1#1,72:1\n*E\n"
.end annotation
.annotation runtime Lkotlin/Metadata;
bv = {
0x1,
0x0,
0x3
}
d1 = {
"\u0000>\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0008\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010\u0008\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0000\n\u0002\u0010\u0002\n\u0002\u0008\u0004\n\u0002\u0018\u0002\n\u0000\u0008\u0000\u0018\u00002\u00020\u0001B\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u00a2\u0006\u0002\u0010\u0004J\u0008\u0010\u000f\u001a\u00020\u0010H\u0016J\u0018\u0010\u0011\u001a\u00020\u000e2\u0006\u0010\u0012\u001a\u00020\u00062\u0006\u0010\u0013\u001a\u00020\u000eH\u0016J\u0008\u0010\u0014\u001a\u00020\u0015H\u0016R\u000e\u0010\u0005\u001a\u00020\u0006X\u0082\u0004\u00a2\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\u0008X\u0082\u000e\u00a2\u0006\u0002\n\u0000R\u000e\u0010\t\u001a\u00020\nX\u0082\u000e\u00a2\u0006\u0002\n\u0000R\u0010\u0010\u000b\u001a\u0004\u0018\u00010\u000cX\u0082\u000e\u00a2\u0006\u0002\n\u0000R\u000e\u0010\r\u001a\u00020\u000eX\u0082\u000e\u00a2\u0006\u0002\n\u0000R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004\u00a2\u0006\u0002\n\u0000\u00a8\u0006\u0016"
}
d2 = {
"Lokio/PeekSource;",
"Lokio/Source;",
"upstream",
"Lokio/BufferedSource;",
"(Lokio/BufferedSource;)V",
"buffer",
"Lokio/Buffer;",
"closed",
"",
"expectedPos",
"",
"expectedSegment",
"Lokio/Segment;",
"pos",
"",
"close",
"",
"read",
"sink",
"byteCount",
"timeout",
"Lokio/Timeout;",
"okio"
}
k = 0x1
mv = {
0x1,
0x1,
0xf
}
.end annotation
# instance fields
.field private final buffer:Lokio/Buffer;
.field private closed:Z
.field private expectedPos:I
.field private expectedSegment:Lokio/Segment;
.field private pos:J
.field private final upstream:Lokio/BufferedSource;
# direct methods
.method public constructor <init>(Lokio/BufferedSource;)V
.registers 3
const-string/jumbo v0, "upstream"
invoke-static {p1, v0}, Lkotlin/jvm/internal/Intrinsics;->checkParameterIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V
.line 28
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
iput-object p1, p0, Lokio/PeekSource;->upstream:Lokio/BufferedSource;
.line 31
invoke-interface {p1}, Lokio/BufferedSource;->getBuffer()Lokio/Buffer;
move-result-object p1
iput-object p1, p0, Lokio/PeekSource;->buffer:Lokio/Buffer;
.line 32
iget-object p1, p1, Lokio/Buffer;->head:Lokio/Segment;
iput-object p1, p0, Lokio/PeekSource;->expectedSegment:Lokio/Segment;
.line 33
iget-object p1, p0, Lokio/PeekSource;->buffer:Lokio/Buffer;
iget-object p1, p1, Lokio/Buffer;->head:Lokio/Segment;
if-eqz p1, :cond_1e
iget p1, p1, Lokio/Segment;->pos:I
goto :goto_1f
:cond_1e
const/4 p1, -0x1
:goto_1f
iput p1, p0, Lokio/PeekSource;->expectedPos:I
return-void
.end method
# virtual methods
.method public close()V
.registers 2
const/4 v0, 0x1
.line 69
iput-boolean v0, p0, Lokio/PeekSource;->closed:Z
return-void
.end method
.method public read(Lokio/Buffer;J)J
.registers 12
const-string v0, "sink"
invoke-static {p1, v0}, Lkotlin/jvm/internal/Intrinsics;->checkParameterIsNotNull(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_9b
.line 40
iget-boolean v5, p0, Lokio/PeekSource;->closed:Z
xor-int/2addr v5, v3
if-eqz v5, :cond_8d
.line 44
iget-object v5, p0, Lokio/PeekSource;->expectedSegment:Lokio/Segment;
if-eqz v5, :cond_30
iget-object v6, p0, Lokio/PeekSource;->buffer:Lokio/Buffer;
iget-object v6, v6, Lokio/Buffer;->head:Lokio/Segment;
if-ne v5, v6, :cond_31
iget v5, p0, Lokio/PeekSource;->expectedPos:I
iget-object v6, p0, Lokio/PeekSource;->buffer:Lokio/Buffer;
iget-object v6, v6, Lokio/Buffer;->head:Lokio/Segment;
if-nez v6, :cond_2c
invoke-static {}, Lkotlin/jvm/internal/Intrinsics;->throwNpe()V
:cond_2c
iget v6, v6, Lokio/Segment;->pos:I
if-ne v5, v6, :cond_31
:cond_30
const/4 v0, 0x1
:cond_31
if-eqz v0, :cond_7f
if-nez v4, :cond_36
return-wide v1
.line 48
:cond_36
iget-object v0, p0, Lokio/PeekSource;->upstream:Lokio/BufferedSource;
iget-wide v1, p0, Lokio/PeekSource;->pos:J
const-wide/16 v3, 0x1
add-long/2addr v1, v3
invoke-interface {v0, v1, v2}, Lokio/BufferedSource;->request(J)Z
move-result v0
if-nez v0, :cond_46
const-wide/16 p1, -0x1
return-wide p1
.line 50
:cond_46
iget-object v0, p0, Lokio/PeekSource;->expectedSegment:Lokio/Segment;
if-nez v0, :cond_63
iget-object v0, p0, Lokio/PeekSource;->buffer:Lokio/Buffer;
iget-object v0, v0, Lokio/Buffer;->head:Lokio/Segment;
if-eqz v0, :cond_63
.line 54
iget-object v0, p0, Lokio/PeekSource;->buffer:Lokio/Buffer;
iget-object v0, v0, Lokio/Buffer;->head:Lokio/Segment;
iput-object v0, p0, Lokio/PeekSource;->expectedSegment:Lokio/Segment;
.line 55
iget-object v0, p0, Lokio/PeekSource;->buffer:Lokio/Buffer;
iget-object v0, v0, Lokio/Buffer;->head:Lokio/Segment;
if-nez v0, :cond_5f
invoke-static {}, Lkotlin/jvm/internal/Intrinsics;->throwNpe()V
:cond_5f
iget v0, v0, Lokio/Segment;->pos:I
iput v0, p0, Lokio/PeekSource;->expectedPos:I
.line 58
:cond_63
iget-object v0, p0, Lokio/PeekSource;->buffer:Lokio/Buffer;
invoke-virtual {v0}, Lokio/Buffer;->size()J
move-result-wide v0
iget-wide v2, p0, Lokio/PeekSource;->pos:J
sub-long/2addr v0, v2
invoke-static {p2, p3, v0, v1}, Ljava/lang/Math;->min(JJ)J
move-result-wide p2
.line 59
iget-object v2, p0, Lokio/PeekSource;->buffer:Lokio/Buffer;
iget-wide v4, p0, Lokio/PeekSource;->pos:J
move-object v3, p1
move-wide v6, p2
invoke-virtual/range {v2 .. v7}, Lokio/Buffer;->copyTo(Lokio/Buffer;JJ)Lokio/Buffer;
.line 60
iget-wide v0, p0, Lokio/PeekSource;->pos:J
add-long/2addr v0, p2
iput-wide v0, p0, Lokio/PeekSource;->pos:J
return-wide p2
.line 43
:cond_7f
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
check-cast p1, Ljava/lang/Throwable;
throw p1
.line 40
:cond_8d
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
check-cast p1, Ljava/lang/Throwable;
throw p1
.line 39
:cond_9b
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
check-cast p2, Ljava/lang/Throwable;
throw p2
.end method
.method public timeout()Lokio/Timeout;
.registers 2
.line 65
iget-object v0, p0, Lokio/PeekSource;->upstream:Lokio/BufferedSource;
invoke-interface {v0}, Lokio/BufferedSource;->timeout()Lokio/Timeout;
move-result-object v0
return-object v0
.end method