Rabbit-R1/switch port/smali/smali_classes3/kotlin/io/encoding/EncodeOutputStream.smali
2024-05-21 17:08:36 -04:00

550 lines
14 KiB
Smali

.class final Lkotlin/io/encoding/EncodeOutputStream;
.super Ljava/io/OutputStream;
.source "Base64IOStream.kt"
# annotations
.annotation runtime Lkotlin/Metadata;
d1 = {
"\u00000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0008\u0002\n\u0002\u0018\u0002\n\u0002\u0008\u0002\n\u0002\u0010\u0012\n\u0000\n\u0002\u0010\u0008\n\u0000\n\u0002\u0010\u000b\n\u0002\u0008\u0003\n\u0002\u0010\u0002\n\u0002\u0008\r\u0008\u0003\u0018\u00002\u00020\u0001B\u0015\u0012\u0006\u0010\u0002\u001a\u00020\u0001\u0012\u0006\u0010\u0003\u001a\u00020\u0004\u00a2\u0006\u0002\u0010\u0005J\u0008\u0010\u000e\u001a\u00020\u000fH\u0002J\u0008\u0010\u0010\u001a\u00020\u000fH\u0016J \u0010\u0011\u001a\u00020\t2\u0006\u0010\u0012\u001a\u00020\u00072\u0006\u0010\u0013\u001a\u00020\t2\u0006\u0010\u0014\u001a\u00020\tH\u0002J\u0008\u0010\u0015\u001a\u00020\u000fH\u0002J \u0010\u0016\u001a\u00020\t2\u0006\u0010\u0012\u001a\u00020\u00072\u0006\u0010\u0013\u001a\u00020\t2\u0006\u0010\u0014\u001a\u00020\tH\u0002J\u0008\u0010\u0017\u001a\u00020\u000fH\u0016J \u0010\u0018\u001a\u00020\u000f2\u0006\u0010\u0012\u001a\u00020\u00072\u0006\u0010\u0019\u001a\u00020\t2\u0006\u0010\u001a\u001a\u00020\tH\u0016J\u0010\u0010\u0018\u001a\u00020\u000f2\u0006\u0010\u001b\u001a\u00020\tH\u0016R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082\u0004\u00a2\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0007X\u0082\u0004\u00a2\u0006\u0002\n\u0000R\u000e\u0010\u0008\u001a\u00020\tX\u0082\u000e\u00a2\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\u000bX\u0082\u000e\u00a2\u0006\u0002\n\u0000R\u000e\u0010\u000c\u001a\u00020\tX\u0082\u000e\u00a2\u0006\u0002\n\u0000R\u000e\u0010\u0002\u001a\u00020\u0001X\u0082\u0004\u00a2\u0006\u0002\n\u0000R\u000e\u0010\r\u001a\u00020\u0007X\u0082\u0004\u00a2\u0006\u0002\n\u0000\u00a8\u0006\u001c"
}
d2 = {
"Lkotlin/io/encoding/EncodeOutputStream;",
"Ljava/io/OutputStream;",
"output",
"base64",
"Lkotlin/io/encoding/Base64;",
"(Ljava/io/OutputStream;Lkotlin/io/encoding/Base64;)V",
"byteBuffer",
"",
"byteBufferLength",
"",
"isClosed",
"",
"lineLength",
"symbolBuffer",
"checkOpen",
"",
"close",
"copyIntoByteBuffer",
"source",
"startIndex",
"endIndex",
"encodeByteBufferIntoOutput",
"encodeIntoOutput",
"flush",
"write",
"offset",
"length",
"b",
"kotlin-stdlib"
}
k = 0x1
mv = {
0x1,
0x9,
0x0
}
xi = 0x30
.end annotation
# instance fields
.field private final base64:Lkotlin/io/encoding/Base64;
.field private final byteBuffer:[B
.field private byteBufferLength:I
.field private isClosed:Z
.field private lineLength:I
.field private final output:Ljava/io/OutputStream;
.field private final symbolBuffer:[B
# direct methods
.method public constructor <init>(Ljava/io/OutputStream;Lkotlin/io/encoding/Base64;)V
.locals 1
const-string v0, "output"
invoke-static {p1, v0}, Lkotlin/jvm/internal/Intrinsics;->checkNotNullParameter(Ljava/lang/Object;Ljava/lang/String;)V
const-string v0, "base64"
invoke-static {p2, v0}, Lkotlin/jvm/internal/Intrinsics;->checkNotNullParameter(Ljava/lang/Object;Ljava/lang/String;)V
.line 235
invoke-direct {p0}, Ljava/io/OutputStream;-><init>()V
iput-object p1, p0, Lkotlin/io/encoding/EncodeOutputStream;->output:Ljava/io/OutputStream;
iput-object p2, p0, Lkotlin/io/encoding/EncodeOutputStream;->base64:Lkotlin/io/encoding/Base64;
.line 238
invoke-virtual {p2}, Lkotlin/io/encoding/Base64;->isMimeScheme$kotlin_stdlib()Z
move-result p1
if-eqz p1, :cond_0
const/16 p1, 0x4c
goto :goto_0
:cond_0
const/4 p1, -0x1
:goto_0
iput p1, p0, Lkotlin/io/encoding/EncodeOutputStream;->lineLength:I
const/16 p1, 0x400
new-array p1, p1, [B
iput-object p1, p0, Lkotlin/io/encoding/EncodeOutputStream;->symbolBuffer:[B
const/4 p1, 0x3
new-array p1, p1, [B
iput-object p1, p0, Lkotlin/io/encoding/EncodeOutputStream;->byteBuffer:[B
return-void
.end method
.method private final checkOpen()V
.locals 1
iget-boolean p0, p0, Lkotlin/io/encoding/EncodeOutputStream;->isClosed:Z
if-nez p0, :cond_0
return-void
.line 341
:cond_0
new-instance p0, Ljava/io/IOException;
const-string v0, "The output stream is closed."
invoke-direct {p0, v0}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
throw p0
.end method
.method private final copyIntoByteBuffer([BII)I
.locals 4
iget v0, p0, Lkotlin/io/encoding/EncodeOutputStream;->byteBufferLength:I
const/4 v1, 0x3
rsub-int/lit8 v0, v0, 0x3
sub-int/2addr p3, p2
.line 307
invoke-static {v0, p3}, Ljava/lang/Math;->min(II)I
move-result p3
iget-object v0, p0, Lkotlin/io/encoding/EncodeOutputStream;->byteBuffer:[B
iget v2, p0, Lkotlin/io/encoding/EncodeOutputStream;->byteBufferLength:I
add-int v3, p2, p3
.line 308
invoke-static {p1, v0, v2, p2, v3}, Lkotlin/collections/ArraysKt;->copyInto([B[BIII)[B
iget p1, p0, Lkotlin/io/encoding/EncodeOutputStream;->byteBufferLength:I
add-int/2addr p1, p3
iput p1, p0, Lkotlin/io/encoding/EncodeOutputStream;->byteBufferLength:I
if-ne p1, v1, :cond_0
.line 311
invoke-direct {p0}, Lkotlin/io/encoding/EncodeOutputStream;->encodeByteBufferIntoOutput()V
:cond_0
return p3
.end method
.method private final encodeByteBufferIntoOutput()V
.locals 3
iget-object v0, p0, Lkotlin/io/encoding/EncodeOutputStream;->byteBuffer:[B
iget v1, p0, Lkotlin/io/encoding/EncodeOutputStream;->byteBufferLength:I
const/4 v2, 0x0
.line 317
invoke-direct {p0, v0, v2, v1}, Lkotlin/io/encoding/EncodeOutputStream;->encodeIntoOutput([BII)I
move-result v0
const/4 v1, 0x4
if-ne v0, v1, :cond_0
iput v2, p0, Lkotlin/io/encoding/EncodeOutputStream;->byteBufferLength:I
return-void
.line 318
:cond_0
new-instance p0, Ljava/lang/IllegalStateException;
const-string v0, "Check failed."
invoke-virtual {v0}, Ljava/lang/Object;->toString()Ljava/lang/String;
move-result-object v0
invoke-direct {p0, v0}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw p0
.end method
.method private final encodeIntoOutput([BII)I
.locals 6
iget-object v0, p0, Lkotlin/io/encoding/EncodeOutputStream;->base64:Lkotlin/io/encoding/Base64;
iget-object v2, p0, Lkotlin/io/encoding/EncodeOutputStream;->symbolBuffer:[B
const/4 v3, 0x0
move-object v1, p1
move v4, p2
move v5, p3
.line 323
invoke-virtual/range {v0 .. v5}, Lkotlin/io/encoding/Base64;->encodeIntoByteArray([B[BIII)I
move-result p1
iget p2, p0, Lkotlin/io/encoding/EncodeOutputStream;->lineLength:I
if-nez p2, :cond_1
iget-object p2, p0, Lkotlin/io/encoding/EncodeOutputStream;->output:Ljava/io/OutputStream;
.line 331
sget-object p3, Lkotlin/io/encoding/Base64;->Default:Lkotlin/io/encoding/Base64$Default;
invoke-virtual {p3}, Lkotlin/io/encoding/Base64$Default;->getMimeLineSeparatorSymbols$kotlin_stdlib()[B
move-result-object p3
invoke-virtual {p2, p3}, Ljava/io/OutputStream;->write([B)V
const/16 p2, 0x4c
iput p2, p0, Lkotlin/io/encoding/EncodeOutputStream;->lineLength:I
if-gt p1, p2, :cond_0
goto :goto_0
.line 333
:cond_0
new-instance p0, Ljava/lang/IllegalStateException;
const-string p1, "Check failed."
invoke-virtual {p1}, Ljava/lang/Object;->toString()Ljava/lang/String;
move-result-object p1
invoke-direct {p0, p1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw p0
:cond_1
:goto_0
iget-object p2, p0, Lkotlin/io/encoding/EncodeOutputStream;->output:Ljava/io/OutputStream;
iget-object p3, p0, Lkotlin/io/encoding/EncodeOutputStream;->symbolBuffer:[B
const/4 v0, 0x0
.line 335
invoke-virtual {p2, p3, v0, p1}, Ljava/io/OutputStream;->write([BII)V
iget p2, p0, Lkotlin/io/encoding/EncodeOutputStream;->lineLength:I
sub-int/2addr p2, p1
iput p2, p0, Lkotlin/io/encoding/EncodeOutputStream;->lineLength:I
return p1
.end method
# virtual methods
.method public close()V
.locals 1
iget-boolean v0, p0, Lkotlin/io/encoding/EncodeOutputStream;->isClosed:Z
if-nez v0, :cond_1
const/4 v0, 0x1
iput-boolean v0, p0, Lkotlin/io/encoding/EncodeOutputStream;->isClosed:Z
iget v0, p0, Lkotlin/io/encoding/EncodeOutputStream;->byteBufferLength:I
if-eqz v0, :cond_0
.line 298
invoke-direct {p0}, Lkotlin/io/encoding/EncodeOutputStream;->encodeByteBufferIntoOutput()V
:cond_0
iget-object p0, p0, Lkotlin/io/encoding/EncodeOutputStream;->output:Ljava/io/OutputStream;
.line 300
invoke-virtual {p0}, Ljava/io/OutputStream;->close()V
:cond_1
return-void
.end method
.method public flush()V
.locals 0
.line 290
invoke-direct {p0}, Lkotlin/io/encoding/EncodeOutputStream;->checkOpen()V
iget-object p0, p0, Lkotlin/io/encoding/EncodeOutputStream;->output:Ljava/io/OutputStream;
.line 291
invoke-virtual {p0}, Ljava/io/OutputStream;->flush()V
return-void
.end method
.method public write(I)V
.locals 3
.line 246
invoke-direct {p0}, Lkotlin/io/encoding/EncodeOutputStream;->checkOpen()V
iget-object v0, p0, Lkotlin/io/encoding/EncodeOutputStream;->byteBuffer:[B
iget v1, p0, Lkotlin/io/encoding/EncodeOutputStream;->byteBufferLength:I
add-int/lit8 v2, v1, 0x1
iput v2, p0, Lkotlin/io/encoding/EncodeOutputStream;->byteBufferLength:I
int-to-byte p1, p1
.line 247
aput-byte p1, v0, v1
const/4 p1, 0x3
if-ne v2, p1, :cond_0
.line 249
invoke-direct {p0}, Lkotlin/io/encoding/EncodeOutputStream;->encodeByteBufferIntoOutput()V
:cond_0
return-void
.end method
.method public write([BII)V
.locals 4
const-string v0, "source"
invoke-static {p1, v0}, Lkotlin/jvm/internal/Intrinsics;->checkNotNullParameter(Ljava/lang/Object;Ljava/lang/String;)V
.line 254
invoke-direct {p0}, Lkotlin/io/encoding/EncodeOutputStream;->checkOpen()V
if-ltz p2, :cond_6
if-ltz p3, :cond_6
add-int v0, p2, p3
.line 255
array-length v1, p1
if-gt v0, v1, :cond_6
if-nez p3, :cond_0
return-void
:cond_0
iget p3, p0, Lkotlin/io/encoding/EncodeOutputStream;->byteBufferLength:I
const-string v1, "Check failed."
const/4 v2, 0x3
if-ge p3, v2, :cond_5
if-eqz p3, :cond_1
.line 268
invoke-direct {p0, p1, p2, v0}, Lkotlin/io/encoding/EncodeOutputStream;->copyIntoByteBuffer([BII)I
move-result p3
add-int/2addr p2, p3
iget p3, p0, Lkotlin/io/encoding/EncodeOutputStream;->byteBufferLength:I
if-eqz p3, :cond_1
return-void
:cond_1
:goto_0
add-int/lit8 p3, p2, 0x3
if-gt p3, v0, :cond_4
iget-object p3, p0, Lkotlin/io/encoding/EncodeOutputStream;->base64:Lkotlin/io/encoding/Base64;
.line 275
invoke-virtual {p3}, Lkotlin/io/encoding/Base64;->isMimeScheme$kotlin_stdlib()Z
move-result p3
if-eqz p3, :cond_2
iget p3, p0, Lkotlin/io/encoding/EncodeOutputStream;->lineLength:I
goto :goto_1
:cond_2
iget-object p3, p0, Lkotlin/io/encoding/EncodeOutputStream;->symbolBuffer:[B
array-length p3, p3
:goto_1
div-int/lit8 p3, p3, 0x4
sub-int v3, v0, p2
.line 276
div-int/2addr v3, v2
invoke-static {p3, v3}, Ljava/lang/Math;->min(II)I
move-result p3
mul-int/lit8 v3, p3, 0x3
add-int/2addr v3, p2
.line 279
invoke-direct {p0, p1, p2, v3}, Lkotlin/io/encoding/EncodeOutputStream;->encodeIntoOutput([BII)I
move-result p2
mul-int/lit8 p3, p3, 0x4
if-ne p2, p3, :cond_3
move p2, v3
goto :goto_0
.line 280
:cond_3
new-instance p0, Ljava/lang/IllegalStateException;
invoke-virtual {v1}, Ljava/lang/Object;->toString()Ljava/lang/String;
move-result-object p1
invoke-direct {p0, p1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw p0
:cond_4
iget-object p3, p0, Lkotlin/io/encoding/EncodeOutputStream;->byteBuffer:[B
const/4 v1, 0x0
.line 285
invoke-static {p1, p3, v1, p2, v0}, Lkotlin/collections/ArraysKt;->copyInto([B[BIII)[B
sub-int/2addr v0, p2
iput v0, p0, Lkotlin/io/encoding/EncodeOutputStream;->byteBufferLength:I
return-void
.line 262
:cond_5
new-instance p0, Ljava/lang/IllegalStateException;
invoke-virtual {v1}, Ljava/lang/Object;->toString()Ljava/lang/String;
move-result-object p1
invoke-direct {p0, p1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw p0
.line 256
:cond_6
new-instance p0, Ljava/lang/IndexOutOfBoundsException;
new-instance v0, Ljava/lang/StringBuilder;
const-string v1, "offset: "
invoke-direct {v0, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
invoke-virtual {v0, p2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
move-result-object p2
const-string v0, ", length: "
invoke-virtual {p2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object p2
invoke-virtual {p2, p3}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
move-result-object p2
const-string p3, ", source size: "
invoke-virtual {p2, p3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object p2
array-length p1, p1
invoke-virtual {p2, p1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
move-result-object p1
invoke-virtual {p1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p1
invoke-direct {p0, p1}, Ljava/lang/IndexOutOfBoundsException;-><init>(Ljava/lang/String;)V
throw p0
.end method