split into encoders and decoders

This commit is contained in:
dcode 2019-03-28 22:49:22 +01:00
parent aa38d06c31
commit a742537dd9
14 changed files with 378 additions and 231 deletions

View File

@ -1,46 +1,71 @@
import { ALLOCATE, REGISTER, REALLOCATE, MAX_BYTELENGTH } from "./runtime"; import { ALLOCATE, REGISTER, REALLOCATE, MAX_BYTELENGTH } from "./runtime";
import { E_INVALIDLENGTH } from "./util/error"; import { E_INVALIDLENGTH, E_NOTIMPLEMENTED } from "./util/error";
/** UTF16 encoding. */ export class UTF16Encoder {
export namespace UTF16 {
/** Calculates the length of a string when encoded as an UTF16 buffer. */ /** Calculates the length of a string when encoded as UTF16 bytes. */
export function length(str: string): i32 { static byteLength(str: string): i32 {
return str.length << 1; return str.length << 1;
} }
/** Encodes a string as an UTF16 buffer. */ /** Encodes a string to UTF16 bytes. */
export function encode(str: string): ArrayBuffer { static encode(str: string): ArrayBuffer {
var size = <usize>str.length << 1; var size = <usize>str.length << 1;
var buf = ALLOCATE(size); var buf = ALLOCATE(size);
memory.copy(buf, changetype<usize>(str), size); memory.copy(buf, changetype<usize>(str), size);
return REGISTER<ArrayBuffer>(buf); return REGISTER<ArrayBuffer>(buf);
} }
/** Decodes an UTF16 buffer to a string.*/ constructor() {
export function decode(buf: ArrayBuffer): string { throw new Error(E_NOTIMPLEMENTED);
return decodeRaw(changetype<usize>(buf), buf.byteLength);
} }
// @ts-ignore: decorator write(str: string): void {
throw new Error(E_NOTIMPLEMENTED);
}
end(): ArrayBuffer {
throw new Error(E_NOTIMPLEMENTED);
}
}
export class UTF16Decoder {
/** Decodes UTF16 bytes to a string.*/
static decode(buf: ArrayBuffer): string {
return UTF16Decoder.decodeUnsafe(changetype<usize>(buf), buf.byteLength);
}
/** Decodes UTF16 bytes to a string. */
@unsafe @unsafe
export function decodeRaw(buf: usize, len: i32): string { static decodeUnsafe(buf: usize, len: i32): string {
if (<usize>len > <usize>MAX_BYTELENGTH) throw new RangeError(E_INVALIDLENGTH); if (<usize>len > <usize>MAX_BYTELENGTH) throw new RangeError(E_INVALIDLENGTH);
var size = <usize>len; var size = <usize>len;
var str = ALLOCATE(size); var str = ALLOCATE(size);
memory.copy(str, changetype<usize>(buf), size); memory.copy(str, changetype<usize>(buf), size);
return REGISTER<string>(str); return REGISTER<string>(str);
} }
constructor() {
throw new Error(E_NOTIMPLEMENTED);
} }
/** UTF8 encoding. */ write(buf: ArrayBuffer): void {
export namespace UTF8 { throw new Error(E_NOTIMPLEMENTED);
}
/** Calculates the length of a string when encoded as an UTF8 buffer. */ end(): string {
export function length(str: string, delimited: bool = false): i32 { throw new Error(E_NOTIMPLEMENTED);
}
}
export class UTF8Encoder {
/** Calculates the length of a string when encoded as UTF8 bytes. */
static byteLength(str: string, nullTerminated: bool = false): i32 {
var strOff = changetype<usize>(str); var strOff = changetype<usize>(str);
var strEnd = changetype<usize>(str) + (<usize>str.length << 1); var strEnd = changetype<usize>(str) + (<usize>str.length << 1);
var bufLen = delimited ? 1 : 0; var bufLen = nullTerminated ? 1 : 0;
while (strOff < strEnd) { while (strOff < strEnd) {
let c = <u32>load<u16>(strOff); let c = <u32>load<u16>(strOff);
if (c < 128) { if (c < 128) {
@ -60,11 +85,11 @@ export namespace UTF8 {
return bufLen; return bufLen;
} }
/** Encodes a string as an UTF8 buffer. */ /** Encodes a string as UTF8 bytes. */
export function encode(str: string, delimited: bool = false): ArrayBuffer { static encode(str: string, nullTerminated: bool = false): ArrayBuffer {
var strOff = changetype<usize>(str); var strOff = changetype<usize>(str);
var strEnd = changetype<usize>(str) + (<usize>str.length << 1); var strEnd = changetype<usize>(str) + (<usize>str.length << 1);
var buf = ALLOCATE(<usize>length(str, delimited)); var buf = ALLOCATE(<usize>UTF8Encoder.byteLength(str, nullTerminated));
var bufOff = changetype<usize>(buf); var bufOff = changetype<usize>(buf);
while (strOff < strEnd) { while (strOff < strEnd) {
let c1 = <u32>load<u16>(strOff); let c1 = <u32>load<u16>(strOff);
@ -95,22 +120,39 @@ export namespace UTF8 {
} }
} }
assert(strOff == strEnd); assert(strOff == strEnd);
if (delimited) store<u8>(bufOff, 0); if (nullTerminated) store<u8>(bufOff, 0);
return REGISTER<ArrayBuffer>(buf); return REGISTER<ArrayBuffer>(buf);
} }
/** Decodes an UTF8 buffer to a string.*/ constructor() {
export function decode(buf: ArrayBuffer, delimited: bool = false): string { throw new Error(E_NOTIMPLEMENTED);
return delimited
? decodeRawDelimited(changetype<usize>(buf), buf.byteLength)
: decodeRaw(changetype<usize>(buf), buf.byteLength);
} }
// @ts-ignore: decorator write(str: string): void {
throw new Error(E_NOTIMPLEMENTED);
}
end(): ArrayBuffer {
throw new Error(E_NOTIMPLEMENTED);
}
}
export class UTF8Decoder {
/** Decodes UTF8 bytes to a string.*/
static decode(buf: ArrayBuffer, nullTerminated: bool = false): string {
return nullTerminated
? UTF8Decoder.decodeNullTerminatedUnsafe(changetype<usize>(buf), buf.byteLength)
: UTF8Decoder.decodeUnsafe(changetype<usize>(buf), buf.byteLength);
}
/** Decodes UTF8 bytes to a string.*/
@unsafe @unsafe
export function decodeRaw(buf: usize, len: i32): string { static decodeUnsafe(buf: usize, len: i32): string {
if (<usize>len > <usize>MAX_BYTELENGTH) throw new RangeError(E_INVALIDLENGTH);
var bufOff = buf; var bufOff = buf;
var bufEnd = buf + <usize>len; var bufEnd = buf + <usize>len;
assert(bufEnd >= bufOff); // guard wraparound
var str = ALLOCATE(<usize>len << 1); // max is one u16 char per u8 byte var str = ALLOCATE(<usize>len << 1); // max is one u16 char per u8 byte
var strOff = str; var strOff = str;
while (bufOff < bufEnd) { while (bufOff < bufEnd) {
@ -144,13 +186,14 @@ export namespace UTF8 {
return REGISTER<string>(REALLOCATE(str, strOff - str)); return REGISTER<string>(REALLOCATE(str, strOff - str));
} }
// @ts-ignore: decorator /** Decodes UTF8 bytes to a string. Zero terminated. */
@unsafe @unsafe
export function decodeRawDelimited(buf: usize, maxLen: i32 = MAX_BYTELENGTH): string { static decodeNullTerminatedUnsafe(buf: usize, maxLen: i32 = MAX_BYTELENGTH): string {
if (<usize>maxLen > <usize>MAX_BYTELENGTH) throw new RangeError(E_INVALIDLENGTH);
var bufOff = buf; var bufOff = buf;
var bufLim = buf + <usize>maxLen; var bufLim = buf + <usize>maxLen;
assert(bufLim > bufOff); // guard wraparound assert(bufLim >= bufOff); // guard wraparound
var str = ALLOCATE(16); // optimize for small strings var str = ALLOCATE(min(maxLen, 16)); // optimize for small strings
var strLen = <usize>0; var strLen = <usize>0;
while (bufOff < bufLim) { while (bufOff < bufLim) {
let cp = <u32>load<u8>(bufOff++); let cp = <u32>load<u8>(bufOff++);
@ -191,4 +234,16 @@ export namespace UTF8 {
} }
return REGISTER<string>(REALLOCATE(str, strLen)); return REGISTER<string>(REALLOCATE(str, strLen));
} }
constructor() {
throw new Error(E_NOTIMPLEMENTED);
}
write(buf: ArrayBuffer): void {
throw new Error(E_NOTIMPLEMENTED);
}
end(): string {
throw new Error(E_NOTIMPLEMENTED);
}
} }

View File

@ -1254,19 +1254,34 @@ declare class String {
toString(): string; toString(): string;
} }
declare namespace UTF16 { declare class UTF16Encoder {
export function length(str: string): i32; /** Calculates the length of a string when encoded as UTF16 bytes. */
export function encode(str: string): ArrayBuffer; static byteLength(str: string): i32;
export function decode(buf: ArrayBuffer, delimited?: bool): string; /** Encodes a string to UTF16 bytes. */
export function decodeRaw(buf: usize, len: i32): string; // unsafe static encode(str: string): ArrayBuffer;
} }
declare namespace UTF8 { declare class UTF16Decoder {
export function length(str: string, delimited?: bool): i32; /** Decodes UTF16 bytes to a string.*/
export function encode(str: string, delimited?: bool): ArrayBuffer; static decode(buf: ArrayBuffer): string;
export function decode(buf: ArrayBuffer, delimited?: bool): string; /** Decodes UTF16 bytes to a string. */
export function decodeRaw(buf: usize, len: i32): string; // unsafe static decodeUnsafe(buf: usize, len: i32): string;
export function decodeRawDelimited(buf: usize, maxLen?: i32): string; // unsafe }
declare class UTF8Encoder {
/** Calculates the length of a string when encoded as UTF8 bytes. */
static byteLength(str: string, nullTerminated?: bool): i32;
/** Encodes a string as UTF8 bytes. */
static encode(str: string, nullTerminated?: bool): ArrayBuffer;
}
declare class UTF8Decoder {
/** Decodes UTF8 bytes to a string.*/
static decode(buf: ArrayBuffer, nullTerminated?: bool): string;
/** Decodes UTF8 bytes to a string.*/
static decodeUnsafe(buf: usize, len: i32): string;
/** Decodes UTF8 bytes to a string. */
static decodeNullTerminatedUnsafe(buf: usize, maxLen?: i32): string;
} }
/** Class for representing a runtime error. Base class of all errors. */ /** Class for representing a runtime error. Base class of all errors. */

View File

@ -4,7 +4,6 @@ import { ALLOCATE, REGISTER, HEADER, HEADER_SIZE, MAKEARRAY, ArrayBufferView } f
import { MAX_SIZE_32 } from "./util/allocator"; import { MAX_SIZE_32 } from "./util/allocator";
import { compareImpl, parse, CharCode, isWhiteSpaceOrLineTerminator } from "./util/string"; import { compareImpl, parse, CharCode, isWhiteSpaceOrLineTerminator } from "./util/string";
import { E_INVALIDLENGTH } from "./util/error"; import { E_INVALIDLENGTH } from "./util/error";
import { UTF8 } from "./encoding";
@sealed export abstract class String { @sealed export abstract class String {

View File

@ -2358,7 +2358,7 @@
if if
i32.const 0 i32.const 0
i32.const 1648 i32.const 1648
i32.const 190 i32.const 189
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable

View File

@ -3424,7 +3424,7 @@
if if
i32.const 0 i32.const 0
i32.const 1648 i32.const 1648
i32.const 190 i32.const 189
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable

View File

@ -142,7 +142,7 @@
if if
i32.const 0 i32.const 0
i32.const 64 i32.const 64
i32.const 165 i32.const 164
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable

View File

@ -219,7 +219,7 @@
if if
i32.const 0 i32.const 0
i32.const 64 i32.const 64
i32.const 165 i32.const 164
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable

View File

@ -6229,7 +6229,7 @@
if if
i32.const 0 i32.const 0
i32.const 4376 i32.const 4376
i32.const 190 i32.const 189
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable

View File

@ -8951,7 +8951,7 @@
if if
i32.const 0 i32.const 0
i32.const 4376 i32.const 4376
i32.const 40 i32.const 39
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -9590,7 +9590,7 @@
if if
i32.const 0 i32.const 0
i32.const 4376 i32.const 4376
i32.const 190 i32.const 189
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable

View File

@ -25,7 +25,7 @@
(export "memory" (memory $0)) (export "memory" (memory $0))
(export "table" (table $0)) (export "table" (table $0))
(start $start) (start $start)
(func $~lib/encoding/UTF8.length (; 1 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (func $~lib/encoding/UTF8Encoder.byteLength (; 1 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
local.get $0 local.get $0
@ -119,7 +119,7 @@
(func $std/encoding/testUTF8Length (; 2 ;) (type $FUNCSIG$v) (func $std/encoding/testUTF8Length (; 2 ;) (type $FUNCSIG$v)
global.get $std/encoding/str global.get $std/encoding/str
i32.const 0 i32.const 0
call $~lib/encoding/UTF8.length call $~lib/encoding/UTF8Encoder.byteLength
i32.const 10 i32.const 10
i32.ne i32.ne
if if
@ -132,7 +132,7 @@
end end
global.get $std/encoding/str global.get $std/encoding/str
i32.const 1 i32.const 1
call $~lib/encoding/UTF8.length call $~lib/encoding/UTF8Encoder.byteLength
i32.const 11 i32.const 11
i32.ne i32.ne
if if
@ -260,7 +260,7 @@
i32.store i32.store
local.get $0 local.get $0
) )
(func $~lib/encoding/UTF8.encode (; 6 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (func $~lib/encoding/UTF8Encoder.encode (; 6 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
@ -279,7 +279,7 @@
local.set $4 local.set $4
local.get $0 local.get $0
local.get $1 local.get $1
call $~lib/encoding/UTF8.length call $~lib/encoding/UTF8Encoder.byteLength
call $~lib/runtime/allocate call $~lib/runtime/allocate
local.tee $6 local.tee $6
local.set $2 local.set $2
@ -443,7 +443,7 @@
if if
i32.const 0 i32.const 0
i32.const 80 i32.const 80
i32.const 97 i32.const 122
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -462,7 +462,7 @@
(local $0 i32) (local $0 i32)
global.get $std/encoding/str global.get $std/encoding/str
i32.const 0 i32.const 0
call $~lib/encoding/UTF8.encode call $~lib/encoding/UTF8Encoder.encode
local.tee $0 local.tee $0
i32.const 8 i32.const 8
i32.sub i32.sub
@ -598,11 +598,11 @@
unreachable unreachable
end end
) )
(func $std/encoding/testUTF8EncodeDelimited (; 8 ;) (type $FUNCSIG$v) (func $std/encoding/testUTF8EncodeNullTerminated (; 8 ;) (type $FUNCSIG$v)
(local $0 i32) (local $0 i32)
global.get $std/encoding/str global.get $std/encoding/str
i32.const 1 i32.const 1
call $~lib/encoding/UTF8.encode call $~lib/encoding/UTF8Encoder.encode
local.tee $0 local.tee $0
i32.const 8 i32.const 8
i32.sub i32.sub
@ -2096,26 +2096,42 @@
i32.store offset=4 i32.store offset=4
local.get $0 local.get $0
) )
(func $~lib/encoding/UTF8.decodeRawDelimited (; 13 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (func $~lib/encoding/UTF8Decoder.decodeNullTerminatedUnsafe (; 13 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
(local $5 i32) (local $5 i32)
local.get $1
i32.const 1073741816
i32.gt_u
if
i32.const 0
i32.const 80
i32.const 192
i32.const 47
call $~lib/env/abort
unreachable
end
local.get $0 local.get $0
local.get $1 local.get $1
i32.add i32.add
local.tee $5 local.tee $5
local.get $0 local.get $0
i32.le_u i32.lt_u
if if
i32.const 0 i32.const 0
i32.const 80 i32.const 80
i32.const 152 i32.const 195
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
local.get $1
i32.const 16 i32.const 16
local.get $1
i32.const 16
i32.lt_s
select
call $~lib/runtime/allocate call $~lib/runtime/allocate
local.set $4 local.set $4
loop $continue|0 loop $continue|0
@ -2326,15 +2342,36 @@
i32.const 1 i32.const 1
call $~lib/runtime/register call $~lib/runtime/register
) )
(func $~lib/encoding/UTF8.decodeRaw (; 14 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (func $~lib/encoding/UTF8Decoder.decodeUnsafe (; 14 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
(local $5 i32) (local $5 i32)
local.get $1
i32.const 1073741816
i32.gt_u
if
i32.const 0
i32.const 80
i32.const 152
i32.const 44
call $~lib/env/abort
unreachable
end
local.get $0 local.get $0
local.get $1 local.get $1
i32.add i32.add
local.set $5 local.tee $5
local.get $0
i32.lt_u
if
i32.const 0
i32.const 80
i32.const 155
i32.const 4
call $~lib/env/abort
unreachable
end
local.get $1 local.get $1
i32.const 1 i32.const 1
i32.shl i32.shl
@ -2500,7 +2537,7 @@
i32.const 1 i32.const 1
call $~lib/runtime/register call $~lib/runtime/register
) )
(func $~lib/encoding/UTF8.decode (; 15 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (func $~lib/encoding/UTF8Decoder.decode (; 15 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
local.get $1 local.get $1
if (result i32) if (result i32)
local.get $0 local.get $0
@ -2508,14 +2545,14 @@
i32.const 8 i32.const 8
i32.sub i32.sub
i32.load offset=4 i32.load offset=4
call $~lib/encoding/UTF8.decodeRawDelimited call $~lib/encoding/UTF8Decoder.decodeNullTerminatedUnsafe
else else
local.get $0 local.get $0
local.get $0 local.get $0
i32.const 8 i32.const 8
i32.sub i32.sub
i32.load offset=4 i32.load offset=4
call $~lib/encoding/UTF8.decodeRaw call $~lib/encoding/UTF8Decoder.decodeUnsafe
end end
) )
(func $~lib/util/string/compareImpl (; 16 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (func $~lib/util/string/compareImpl (; 16 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
@ -2600,9 +2637,9 @@
(func $std/encoding/testUTF8Decode (; 18 ;) (type $FUNCSIG$v) (func $std/encoding/testUTF8Decode (; 18 ;) (type $FUNCSIG$v)
global.get $std/encoding/str global.get $std/encoding/str
i32.const 0 i32.const 0
call $~lib/encoding/UTF8.encode call $~lib/encoding/UTF8Encoder.encode
i32.const 0 i32.const 0
call $~lib/encoding/UTF8.decode call $~lib/encoding/UTF8Decoder.decode
global.get $std/encoding/str global.get $std/encoding/str
call $~lib/string/String.__eq call $~lib/string/String.__eq
i32.eqz i32.eqz
@ -2615,12 +2652,12 @@
unreachable unreachable
end end
) )
(func $std/encoding/testUTF8DecodeDelimited (; 19 ;) (type $FUNCSIG$v) (func $std/encoding/testUTF8DecodeNullTerminated (; 19 ;) (type $FUNCSIG$v)
global.get $std/encoding/str global.get $std/encoding/str
i32.const 1 i32.const 1
call $~lib/encoding/UTF8.encode call $~lib/encoding/UTF8Encoder.encode
i32.const 1 i32.const 1
call $~lib/encoding/UTF8.decode call $~lib/encoding/UTF8Decoder.decode
global.get $std/encoding/str global.get $std/encoding/str
call $~lib/string/String.__eq call $~lib/string/String.__eq
i32.eqz i32.eqz
@ -2633,14 +2670,14 @@
unreachable unreachable
end end
) )
(func $std/encoding/testUTF8Raw (; 20 ;) (type $FUNCSIG$v) (func $std/encoding/testUTF8DecodeUnsafe (; 20 ;) (type $FUNCSIG$v)
(local $0 i32) (local $0 i32)
global.get $std/encoding/str global.get $std/encoding/str
i32.const 0 i32.const 0
call $~lib/encoding/UTF8.encode call $~lib/encoding/UTF8Encoder.encode
local.tee $0 local.tee $0
i32.const 0 i32.const 0
call $~lib/encoding/UTF8.decodeRaw call $~lib/encoding/UTF8Decoder.decodeUnsafe
i32.const 160 i32.const 160
call $~lib/string/String.__eq call $~lib/string/String.__eq
i32.eqz i32.eqz
@ -2655,8 +2692,8 @@
local.get $0 local.get $0
global.get $std/encoding/str global.get $std/encoding/str
i32.const 0 i32.const 0
call $~lib/encoding/UTF8.length call $~lib/encoding/UTF8Encoder.byteLength
call $~lib/encoding/UTF8.decodeRaw call $~lib/encoding/UTF8Decoder.decodeUnsafe
global.get $std/encoding/str global.get $std/encoding/str
call $~lib/string/String.__eq call $~lib/string/String.__eq
i32.eqz i32.eqz
@ -2670,7 +2707,7 @@
end end
local.get $0 local.get $0
i32.const 4 i32.const 4
call $~lib/encoding/UTF8.decodeRaw call $~lib/encoding/UTF8Decoder.decodeUnsafe
i32.const 168 i32.const 168
call $~lib/string/String.__eq call $~lib/string/String.__eq
i32.eqz i32.eqz
@ -2686,7 +2723,7 @@
i32.const 4 i32.const 4
i32.add i32.add
i32.const 2 i32.const 2
call $~lib/encoding/UTF8.decodeRaw call $~lib/encoding/UTF8Decoder.decodeUnsafe
i32.const 184 i32.const 184
call $~lib/string/String.__eq call $~lib/string/String.__eq
i32.eqz i32.eqz
@ -2702,7 +2739,7 @@
i32.const 6 i32.const 6
i32.add i32.add
i32.const 4 i32.const 4
call $~lib/encoding/UTF8.decodeRaw call $~lib/encoding/UTF8Decoder.decodeUnsafe
i32.const 200 i32.const 200
call $~lib/string/String.__eq call $~lib/string/String.__eq
i32.eqz i32.eqz
@ -2718,7 +2755,7 @@
i32.const 10 i32.const 10
i32.add i32.add
i32.const 0 i32.const 0
call $~lib/encoding/UTF8.decodeRaw call $~lib/encoding/UTF8Decoder.decodeUnsafe
i32.const 160 i32.const 160
call $~lib/string/String.__eq call $~lib/string/String.__eq
i32.eqz i32.eqz
@ -2737,7 +2774,7 @@
i32.const 4 i32.const 4
i32.add i32.add
i32.const 1073741816 i32.const 1073741816
call $~lib/encoding/UTF8.decodeRawDelimited call $~lib/encoding/UTF8Decoder.decodeNullTerminatedUnsafe
i32.const 216 i32.const 216
call $~lib/string/String.__eq call $~lib/string/String.__eq
i32.eqz i32.eqz
@ -2753,7 +2790,7 @@
i32.const 6 i32.const 6
i32.add i32.add
i32.const 1073741816 i32.const 1073741816
call $~lib/encoding/UTF8.decodeRawDelimited call $~lib/encoding/UTF8Decoder.decodeNullTerminatedUnsafe
i32.const 200 i32.const 200
call $~lib/string/String.__eq call $~lib/string/String.__eq
i32.eqz i32.eqz
@ -2769,7 +2806,7 @@
i32.const 10 i32.const 10
i32.add i32.add
i32.const 1073741816 i32.const 1073741816
call $~lib/encoding/UTF8.decodeRawDelimited call $~lib/encoding/UTF8Decoder.decodeNullTerminatedUnsafe
i32.const 160 i32.const 160
call $~lib/string/String.__eq call $~lib/string/String.__eq
i32.eqz i32.eqz
@ -2789,10 +2826,10 @@
global.get $~lib/allocator/arena/startOffset global.get $~lib/allocator/arena/startOffset
global.set $~lib/allocator/arena/offset global.set $~lib/allocator/arena/offset
call $std/encoding/testUTF8Encode call $std/encoding/testUTF8Encode
call $std/encoding/testUTF8EncodeDelimited call $std/encoding/testUTF8EncodeNullTerminated
call $std/encoding/testUTF8Decode call $std/encoding/testUTF8Decode
call $std/encoding/testUTF8DecodeDelimited call $std/encoding/testUTF8DecodeNullTerminated
call $std/encoding/testUTF8Raw call $std/encoding/testUTF8DecodeUnsafe
) )
(func $null (; 22 ;) (type $FUNCSIG$v) (func $null (; 22 ;) (type $FUNCSIG$v)
nop nop

View File

@ -3,13 +3,13 @@ import "allocator/arena";
var str = "𐐷hi𤭢"; // -> f0 90 90 b7 68 69 f0 a4 ad a2 [00] var str = "𐐷hi𤭢"; // -> f0 90 90 b7 68 69 f0 a4 ad a2 [00]
function testUTF8Length(): void { function testUTF8Length(): void {
assert(UTF8.length(str) == 10); assert(UTF8Encoder.byteLength(str) == 10);
assert(UTF8.length(str, true) == 11); assert(UTF8Encoder.byteLength(str, true) == 11);
} }
testUTF8Length(); testUTF8Length();
function testUTF8Encode(): void { function testUTF8Encode(): void {
var buf = UTF8.encode(str); var buf = UTF8Encoder.encode(str);
var ptr = changetype<usize>(buf); var ptr = changetype<usize>(buf);
assert(buf.byteLength == 10); assert(buf.byteLength == 10);
assert(load<u8>(ptr, 0) == 0xf0); assert(load<u8>(ptr, 0) == 0xf0);
@ -25,8 +25,8 @@ function testUTF8Encode(): void {
} }
testUTF8Encode(); testUTF8Encode();
function testUTF8EncodeDelimited(): void { function testUTF8EncodeNullTerminated(): void {
var buf = UTF8.encode(str, true); var buf = UTF8Encoder.encode(str, true);
var ptr = changetype<usize>(buf); var ptr = changetype<usize>(buf);
assert(buf.byteLength == 11); assert(buf.byteLength == 11);
assert(load<u8>(ptr, 0) == 0xf0); assert(load<u8>(ptr, 0) == 0xf0);
@ -41,33 +41,33 @@ function testUTF8EncodeDelimited(): void {
assert(load<u8>(ptr, 9) == 0xa2); assert(load<u8>(ptr, 9) == 0xa2);
assert(load<u8>(ptr, 10) == 0x00); assert(load<u8>(ptr, 10) == 0x00);
} }
testUTF8EncodeDelimited(); testUTF8EncodeNullTerminated();
function testUTF8Decode(): void { function testUTF8Decode(): void {
var buf = UTF8.encode(str); var buf = UTF8Encoder.encode(str);
assert(UTF8.decode(buf) == str); assert(UTF8Decoder.decode(buf) == str);
} }
testUTF8Decode(); testUTF8Decode();
function testUTF8DecodeDelimited(): void { function testUTF8DecodeNullTerminated(): void {
var buf = UTF8.encode(str, true); var buf = UTF8Encoder.encode(str, true);
assert(UTF8.decode(buf, true) == str); assert(UTF8Decoder.decode(buf, true) == str);
} }
testUTF8DecodeDelimited(); testUTF8DecodeNullTerminated();
function testUTF8Raw(): void { function testUTF8DecodeUnsafe(): void {
var buf = changetype<usize>(UTF8.encode(str)); var buf = changetype<usize>(UTF8Encoder.encode(str));
assert(UTF8.decodeRaw(buf, 0) == ""); assert(UTF8Decoder.decodeUnsafe(buf, 0) == "");
assert(UTF8.decodeRaw(buf, UTF8.length(str)) == str); assert(UTF8Decoder.decodeUnsafe(buf, UTF8Encoder.byteLength(str)) == str);
assert(UTF8.decodeRaw(buf, 4) == "𐐷"); assert(UTF8Decoder.decodeUnsafe(buf, 4) == "𐐷");
assert(UTF8.decodeRaw(buf + 4, 2) == "hi"); assert(UTF8Decoder.decodeUnsafe(buf + 4, 2) == "hi");
assert(UTF8.decodeRaw(buf + 6, 4) == "𤭢"); assert(UTF8Decoder.decodeUnsafe(buf + 6, 4) == "𤭢");
assert(UTF8.decodeRaw(buf + 10, 0) == ""); assert(UTF8Decoder.decodeUnsafe(buf + 10, 0) == "");
store<u8>(buf, 0, 10); // don't try this at home store<u8>(buf, 0, 10); // don't try this at home
assert(UTF8.decodeRawDelimited(buf + 4) == "hi𤭢"); assert(UTF8Decoder.decodeNullTerminatedUnsafe(buf + 4) == "hi𤭢");
assert(UTF8.decodeRawDelimited(buf + 6) == "𤭢"); assert(UTF8Decoder.decodeNullTerminatedUnsafe(buf + 6) == "𤭢");
assert(UTF8.decodeRawDelimited(buf + 10) == ""); assert(UTF8Decoder.decodeNullTerminatedUnsafe(buf + 10) == "");
} }
testUTF8Raw(); testUTF8DecodeUnsafe();

View File

@ -38,7 +38,7 @@
i32.const 1 i32.const 1
i32.shr_u i32.shr_u
) )
(func $~lib/encoding/UTF8.length (; 2 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (func $~lib/encoding/UTF8Encoder.byteLength (; 2 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
@ -152,7 +152,7 @@
(func $std/encoding/testUTF8Length (; 3 ;) (type $FUNCSIG$v) (func $std/encoding/testUTF8Length (; 3 ;) (type $FUNCSIG$v)
global.get $std/encoding/str global.get $std/encoding/str
i32.const 0 i32.const 0
call $~lib/encoding/UTF8.length call $~lib/encoding/UTF8Encoder.byteLength
i32.const 10 i32.const 10
i32.eq i32.eq
i32.eqz i32.eqz
@ -166,7 +166,7 @@
end end
global.get $std/encoding/str global.get $std/encoding/str
i32.const 1 i32.const 1
call $~lib/encoding/UTF8.length call $~lib/encoding/UTF8Encoder.byteLength
i32.const 11 i32.const 11
i32.eq i32.eq
i32.eqz i32.eqz
@ -327,7 +327,7 @@
i32.store i32.store
local.get $0 local.get $0
) )
(func $~lib/encoding/UTF8.encode (; 9 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (func $~lib/encoding/UTF8Encoder.encode (; 9 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
@ -346,7 +346,7 @@
block $~lib/runtime/ALLOCATE|inlined.0 (result i32) block $~lib/runtime/ALLOCATE|inlined.0 (result i32)
local.get $0 local.get $0
local.get $1 local.get $1
call $~lib/encoding/UTF8.length call $~lib/encoding/UTF8Encoder.byteLength
local.set $4 local.set $4
local.get $4 local.get $4
call $~lib/runtime/allocate call $~lib/runtime/allocate
@ -532,7 +532,7 @@
if if
i32.const 0 i32.const 0
i32.const 80 i32.const 80
i32.const 97 i32.const 122
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -564,7 +564,7 @@
(local $1 i32) (local $1 i32)
global.get $std/encoding/str global.get $std/encoding/str
i32.const 0 i32.const 0
call $~lib/encoding/UTF8.encode call $~lib/encoding/UTF8Encoder.encode
local.set $0 local.set $0
local.get $0 local.get $0
local.set $1 local.set $1
@ -712,12 +712,12 @@
unreachable unreachable
end end
) )
(func $std/encoding/testUTF8EncodeDelimited (; 12 ;) (type $FUNCSIG$v) (func $std/encoding/testUTF8EncodeNullTerminated (; 12 ;) (type $FUNCSIG$v)
(local $0 i32) (local $0 i32)
(local $1 i32) (local $1 i32)
global.get $std/encoding/str global.get $std/encoding/str
i32.const 1 i32.const 1
call $~lib/encoding/UTF8.encode call $~lib/encoding/UTF8Encoder.encode
local.set $0 local.set $0
local.get $0 local.get $0
local.set $1 local.set $1
@ -2671,7 +2671,7 @@
i32.store offset=4 i32.store offset=4
local.get $0 local.get $0
) )
(func $~lib/encoding/UTF8.decodeRawDelimited (; 19 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (func $~lib/encoding/UTF8Decoder.decodeNullTerminatedUnsafe (; 19 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
@ -2679,6 +2679,17 @@
(local $6 i32) (local $6 i32)
(local $7 i32) (local $7 i32)
(local $8 i32) (local $8 i32)
local.get $1
global.get $~lib/runtime/MAX_BYTELENGTH
i32.gt_u
if
i32.const 0
i32.const 80
i32.const 192
i32.const 47
call $~lib/env/abort
unreachable
end
local.get $0 local.get $0
local.set $2 local.set $2
local.get $0 local.get $0
@ -2687,25 +2698,32 @@
local.set $3 local.set $3
local.get $3 local.get $3
local.get $2 local.get $2
i32.gt_u i32.ge_u
i32.eqz i32.eqz
if if
i32.const 0 i32.const 0
i32.const 80 i32.const 80
i32.const 152 i32.const 195
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
block $~lib/runtime/ALLOCATE|inlined.1 (result i32) block $~lib/runtime/ALLOCATE|inlined.1 (result i32)
local.get $1
local.tee $5
i32.const 16 i32.const 16
local.tee $6
local.get $5
local.get $6
i32.lt_s
select
local.set $4 local.set $4
local.get $4 local.get $4
call $~lib/runtime/allocate call $~lib/runtime/allocate
end end
local.set $5 local.set $7
i32.const 0 i32.const 0
local.set $6 local.set $8
block $break|0 block $break|0
loop $continue|0 loop $continue|0
local.get $2 local.get $2
@ -2733,37 +2751,37 @@
br $break|0 br $break|0
end end
block $~lib/runtime/REALLOCATE|inlined.0 (result i32) block $~lib/runtime/REALLOCATE|inlined.0 (result i32)
local.get $5 local.get $7
local.set $8 local.set $6
local.get $6 local.get $8
i32.const 2 i32.const 2
i32.add i32.add
local.set $7 local.set $5
local.get $8 local.get $6
local.get $7 local.get $5
call $~lib/runtime/reallocate call $~lib/runtime/reallocate
end end
local.set $5 local.set $7
local.get $5 local.get $7
local.get $6 local.get $8
i32.add i32.add
local.get $4 local.get $4
i32.store16 i32.store16
local.get $6 local.get $8
i32.const 2 i32.const 2
i32.add i32.add
local.set $6 local.set $8
else else
local.get $4 local.get $4
i32.const 191 i32.const 191
i32.gt_u i32.gt_u
local.tee $7 local.tee $5
if (result i32) if (result i32)
local.get $4 local.get $4
i32.const 224 i32.const 224
i32.lt_u i32.lt_u
else else
local.get $7 local.get $5
end end
if if
local.get $2 local.get $2
@ -2773,19 +2791,19 @@
br $break|0 br $break|0
end end
block $~lib/runtime/REALLOCATE|inlined.1 (result i32) block $~lib/runtime/REALLOCATE|inlined.1 (result i32)
local.get $5 local.get $7
local.set $8 local.set $6
local.get $6 local.get $8
i32.const 2 i32.const 2
i32.add i32.add
local.set $7 local.set $5
local.get $8 local.get $6
local.get $7 local.get $5
call $~lib/runtime/reallocate call $~lib/runtime/reallocate
end end
local.set $5 local.set $7
local.get $5 local.get $7
local.get $6 local.get $8
i32.add i32.add
local.get $4 local.get $4
i32.const 31 i32.const 31
@ -2794,32 +2812,32 @@
i32.shl i32.shl
block (result i32) block (result i32)
local.get $2 local.get $2
local.tee $7 local.tee $5
i32.const 1 i32.const 1
i32.add i32.add
local.set $2 local.set $2
local.get $7 local.get $5
end end
i32.load8_u i32.load8_u
i32.const 63 i32.const 63
i32.and i32.and
i32.or i32.or
i32.store16 i32.store16
local.get $6 local.get $8
i32.const 2 i32.const 2
i32.add i32.add
local.set $6 local.set $8
else else
local.get $4 local.get $4
i32.const 239 i32.const 239
i32.gt_u i32.gt_u
local.tee $7 local.tee $5
if (result i32) if (result i32)
local.get $4 local.get $4
i32.const 365 i32.const 365
i32.lt_u i32.lt_u
else else
local.get $7 local.get $5
end end
if if
local.get $2 local.get $2
@ -2862,39 +2880,39 @@
i32.add i32.add
local.set $2 local.set $2
block $~lib/runtime/REALLOCATE|inlined.2 (result i32) block $~lib/runtime/REALLOCATE|inlined.2 (result i32)
local.get $5 local.get $7
local.set $8 local.set $6
local.get $6 local.get $8
i32.const 4 i32.const 4
i32.add i32.add
local.set $7 local.set $5
local.get $8 local.get $6
local.get $7 local.get $5
call $~lib/runtime/reallocate call $~lib/runtime/reallocate
end end
local.set $5
local.get $5
local.get $6
i32.add
local.set $7 local.set $7
local.get $7 local.get $7
local.get $8
i32.add
local.set $5
local.get $5
i32.const 55296 i32.const 55296
local.get $4 local.get $4
i32.const 10 i32.const 10
i32.shr_u i32.shr_u
i32.add i32.add
i32.store16 i32.store16
local.get $7 local.get $5
i32.const 56320 i32.const 56320
local.get $4 local.get $4
i32.const 1023 i32.const 1023
i32.and i32.and
i32.add i32.add
i32.store16 offset=2 i32.store16 offset=2
local.get $6 local.get $8
i32.const 4 i32.const 4
i32.add i32.add
local.set $6 local.set $8
else else
local.get $2 local.get $2
i32.const 2 i32.const 2
@ -2905,19 +2923,19 @@
br $break|0 br $break|0
end end
block $~lib/runtime/REALLOCATE|inlined.3 (result i32) block $~lib/runtime/REALLOCATE|inlined.3 (result i32)
local.get $5 local.get $7
local.set $8 local.set $6
local.get $6 local.get $8
i32.const 2 i32.const 2
i32.add i32.add
local.set $7 local.set $5
local.get $8 local.get $6
local.get $7 local.get $5
call $~lib/runtime/reallocate call $~lib/runtime/reallocate
end end
local.set $5 local.set $7
local.get $5 local.get $7
local.get $6 local.get $8
i32.add i32.add
local.get $4 local.get $4
i32.const 15 i32.const 15
@ -2941,10 +2959,10 @@
i32.const 2 i32.const 2
i32.add i32.add
local.set $2 local.set $2
local.get $6 local.get $8
i32.const 2 i32.const 2
i32.add i32.add
local.set $6 local.set $8
end end
end end
end end
@ -2955,12 +2973,12 @@
end end
block $~lib/runtime/REGISTER<~lib/string/String>|inlined.0 (result i32) block $~lib/runtime/REGISTER<~lib/string/String>|inlined.0 (result i32)
block $~lib/runtime/REALLOCATE|inlined.4 (result i32) block $~lib/runtime/REALLOCATE|inlined.4 (result i32)
local.get $5
local.set $8
local.get $6
local.set $7
local.get $8
local.get $7 local.get $7
local.set $6
local.get $8
local.set $5
local.get $6
local.get $5
call $~lib/runtime/reallocate call $~lib/runtime/reallocate
end end
local.set $4 local.set $4
@ -2969,7 +2987,7 @@
call $~lib/runtime/register call $~lib/runtime/register
end end
) )
(func $~lib/encoding/UTF8.decodeRaw (; 20 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (func $~lib/encoding/UTF8Decoder.decodeUnsafe (; 20 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
@ -2977,12 +2995,35 @@
(local $6 i32) (local $6 i32)
(local $7 i32) (local $7 i32)
(local $8 i32) (local $8 i32)
local.get $1
global.get $~lib/runtime/MAX_BYTELENGTH
i32.gt_u
if
i32.const 0
i32.const 80
i32.const 152
i32.const 44
call $~lib/env/abort
unreachable
end
local.get $0 local.get $0
local.set $2 local.set $2
local.get $0 local.get $0
local.get $1 local.get $1
i32.add i32.add
local.set $3 local.set $3
local.get $3
local.get $2
i32.ge_u
i32.eqz
if
i32.const 0
i32.const 80
i32.const 155
i32.const 4
call $~lib/env/abort
unreachable
end
block $~lib/runtime/ALLOCATE|inlined.2 (result i32) block $~lib/runtime/ALLOCATE|inlined.2 (result i32)
local.get $1 local.get $1
i32.const 1 i32.const 1
@ -3174,7 +3215,7 @@
call $~lib/runtime/register call $~lib/runtime/register
end end
) )
(func $~lib/encoding/UTF8.decode (; 21 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (func $~lib/encoding/UTF8Decoder.decode (; 21 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
local.get $1 local.get $1
i32.const 0 i32.const 0
i32.ne i32.ne
@ -3182,12 +3223,12 @@
local.get $0 local.get $0
local.get $0 local.get $0
call $~lib/arraybuffer/ArrayBuffer#get:byteLength call $~lib/arraybuffer/ArrayBuffer#get:byteLength
call $~lib/encoding/UTF8.decodeRawDelimited call $~lib/encoding/UTF8Decoder.decodeNullTerminatedUnsafe
else else
local.get $0 local.get $0
local.get $0 local.get $0
call $~lib/arraybuffer/ArrayBuffer#get:byteLength call $~lib/arraybuffer/ArrayBuffer#get:byteLength
call $~lib/encoding/UTF8.decodeRaw call $~lib/encoding/UTF8Decoder.decodeUnsafe
end end
) )
(func $~lib/util/string/compareImpl (; 22 ;) (type $FUNCSIG$iiiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (result i32) (func $~lib/util/string/compareImpl (; 22 ;) (type $FUNCSIG$iiiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (result i32)
@ -3291,11 +3332,11 @@
(local $0 i32) (local $0 i32)
global.get $std/encoding/str global.get $std/encoding/str
i32.const 0 i32.const 0
call $~lib/encoding/UTF8.encode call $~lib/encoding/UTF8Encoder.encode
local.set $0 local.set $0
local.get $0 local.get $0
i32.const 0 i32.const 0
call $~lib/encoding/UTF8.decode call $~lib/encoding/UTF8Decoder.decode
global.get $std/encoding/str global.get $std/encoding/str
call $~lib/string/String.__eq call $~lib/string/String.__eq
i32.eqz i32.eqz
@ -3308,15 +3349,15 @@
unreachable unreachable
end end
) )
(func $std/encoding/testUTF8DecodeDelimited (; 25 ;) (type $FUNCSIG$v) (func $std/encoding/testUTF8DecodeNullTerminated (; 25 ;) (type $FUNCSIG$v)
(local $0 i32) (local $0 i32)
global.get $std/encoding/str global.get $std/encoding/str
i32.const 1 i32.const 1
call $~lib/encoding/UTF8.encode call $~lib/encoding/UTF8Encoder.encode
local.set $0 local.set $0
local.get $0 local.get $0
i32.const 1 i32.const 1
call $~lib/encoding/UTF8.decode call $~lib/encoding/UTF8Decoder.decode
global.get $std/encoding/str global.get $std/encoding/str
call $~lib/string/String.__eq call $~lib/string/String.__eq
i32.eqz i32.eqz
@ -3329,15 +3370,15 @@
unreachable unreachable
end end
) )
(func $std/encoding/testUTF8Raw (; 26 ;) (type $FUNCSIG$v) (func $std/encoding/testUTF8DecodeUnsafe (; 26 ;) (type $FUNCSIG$v)
(local $0 i32) (local $0 i32)
global.get $std/encoding/str global.get $std/encoding/str
i32.const 0 i32.const 0
call $~lib/encoding/UTF8.encode call $~lib/encoding/UTF8Encoder.encode
local.set $0 local.set $0
local.get $0 local.get $0
i32.const 0 i32.const 0
call $~lib/encoding/UTF8.decodeRaw call $~lib/encoding/UTF8Decoder.decodeUnsafe
i32.const 160 i32.const 160
call $~lib/string/String.__eq call $~lib/string/String.__eq
i32.eqz i32.eqz
@ -3352,8 +3393,8 @@
local.get $0 local.get $0
global.get $std/encoding/str global.get $std/encoding/str
i32.const 0 i32.const 0
call $~lib/encoding/UTF8.length call $~lib/encoding/UTF8Encoder.byteLength
call $~lib/encoding/UTF8.decodeRaw call $~lib/encoding/UTF8Decoder.decodeUnsafe
global.get $std/encoding/str global.get $std/encoding/str
call $~lib/string/String.__eq call $~lib/string/String.__eq
i32.eqz i32.eqz
@ -3367,7 +3408,7 @@
end end
local.get $0 local.get $0
i32.const 4 i32.const 4
call $~lib/encoding/UTF8.decodeRaw call $~lib/encoding/UTF8Decoder.decodeUnsafe
i32.const 168 i32.const 168
call $~lib/string/String.__eq call $~lib/string/String.__eq
i32.eqz i32.eqz
@ -3383,7 +3424,7 @@
i32.const 4 i32.const 4
i32.add i32.add
i32.const 2 i32.const 2
call $~lib/encoding/UTF8.decodeRaw call $~lib/encoding/UTF8Decoder.decodeUnsafe
i32.const 184 i32.const 184
call $~lib/string/String.__eq call $~lib/string/String.__eq
i32.eqz i32.eqz
@ -3399,7 +3440,7 @@
i32.const 6 i32.const 6
i32.add i32.add
i32.const 4 i32.const 4
call $~lib/encoding/UTF8.decodeRaw call $~lib/encoding/UTF8Decoder.decodeUnsafe
i32.const 200 i32.const 200
call $~lib/string/String.__eq call $~lib/string/String.__eq
i32.eqz i32.eqz
@ -3415,7 +3456,7 @@
i32.const 10 i32.const 10
i32.add i32.add
i32.const 0 i32.const 0
call $~lib/encoding/UTF8.decodeRaw call $~lib/encoding/UTF8Decoder.decodeUnsafe
i32.const 160 i32.const 160
call $~lib/string/String.__eq call $~lib/string/String.__eq
i32.eqz i32.eqz
@ -3434,7 +3475,7 @@
i32.const 4 i32.const 4
i32.add i32.add
global.get $~lib/runtime/MAX_BYTELENGTH global.get $~lib/runtime/MAX_BYTELENGTH
call $~lib/encoding/UTF8.decodeRawDelimited call $~lib/encoding/UTF8Decoder.decodeNullTerminatedUnsafe
i32.const 216 i32.const 216
call $~lib/string/String.__eq call $~lib/string/String.__eq
i32.eqz i32.eqz
@ -3450,7 +3491,7 @@
i32.const 6 i32.const 6
i32.add i32.add
global.get $~lib/runtime/MAX_BYTELENGTH global.get $~lib/runtime/MAX_BYTELENGTH
call $~lib/encoding/UTF8.decodeRawDelimited call $~lib/encoding/UTF8Decoder.decodeNullTerminatedUnsafe
i32.const 200 i32.const 200
call $~lib/string/String.__eq call $~lib/string/String.__eq
i32.eqz i32.eqz
@ -3466,7 +3507,7 @@
i32.const 10 i32.const 10
i32.add i32.add
global.get $~lib/runtime/MAX_BYTELENGTH global.get $~lib/runtime/MAX_BYTELENGTH
call $~lib/encoding/UTF8.decodeRawDelimited call $~lib/encoding/UTF8Decoder.decodeNullTerminatedUnsafe
i32.const 160 i32.const 160
call $~lib/string/String.__eq call $~lib/string/String.__eq
i32.eqz i32.eqz
@ -3492,10 +3533,10 @@
global.get $~lib/allocator/arena/startOffset global.get $~lib/allocator/arena/startOffset
global.set $~lib/allocator/arena/offset global.set $~lib/allocator/arena/offset
call $std/encoding/testUTF8Encode call $std/encoding/testUTF8Encode
call $std/encoding/testUTF8EncodeDelimited call $std/encoding/testUTF8EncodeNullTerminated
call $std/encoding/testUTF8Decode call $std/encoding/testUTF8Decode
call $std/encoding/testUTF8DecodeDelimited call $std/encoding/testUTF8DecodeNullTerminated
call $std/encoding/testUTF8Raw call $std/encoding/testUTF8DecodeUnsafe
) )
(func $start (; 28 ;) (type $FUNCSIG$v) (func $start (; 28 ;) (type $FUNCSIG$v)
call $start:std/encoding call $start:std/encoding

View File

@ -575,7 +575,7 @@
if if
i32.const 0 i32.const 0
i32.const 216 i32.const 216
i32.const 25 i32.const 24
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -630,7 +630,7 @@
if if
i32.const 0 i32.const 0
i32.const 216 i32.const 216
i32.const 165 i32.const 164
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -678,7 +678,7 @@
if if
i32.const 0 i32.const 0
i32.const 216 i32.const 216
i32.const 78 i32.const 77
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -726,7 +726,7 @@
if if
i32.const 0 i32.const 0
i32.const 216 i32.const 216
i32.const 134 i32.const 133
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -1877,7 +1877,7 @@
if if
i32.const 0 i32.const 0
i32.const 216 i32.const 216
i32.const 282 i32.const 281
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -1972,7 +1972,7 @@
if if
i32.const 0 i32.const 0
i32.const 216 i32.const 216
i32.const 303 i32.const 302
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -2068,7 +2068,7 @@
if if
i32.const 0 i32.const 0
i32.const 216 i32.const 216
i32.const 150 i32.const 149
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -2490,7 +2490,7 @@
if if
i32.const 0 i32.const 0
i32.const 216 i32.const 216
i32.const 464 i32.const 463
i32.const 10 i32.const 10
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -2762,7 +2762,7 @@
if if
i32.const 0 i32.const 0
i32.const 216 i32.const 216
i32.const 324 i32.const 323
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -2792,7 +2792,7 @@
if if
i32.const 0 i32.const 0
i32.const 216 i32.const 216
i32.const 329 i32.const 328
i32.const 6 i32.const 6
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3354,7 +3354,7 @@
if if
i32.const 0 i32.const 0
i32.const 216 i32.const 216
i32.const 351 i32.const 350
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -5072,7 +5072,7 @@
if if
i32.const 0 i32.const 0
i32.const 216 i32.const 216
i32.const 190 i32.const 189
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable

View File

@ -524,7 +524,7 @@
if if
i32.const 0 i32.const 0
i32.const 216 i32.const 216
i32.const 25 i32.const 24
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -597,7 +597,7 @@
if if
i32.const 0 i32.const 0
i32.const 216 i32.const 216
i32.const 165 i32.const 164
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -663,7 +663,7 @@
if if
i32.const 0 i32.const 0
i32.const 216 i32.const 216
i32.const 78 i32.const 77
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -727,7 +727,7 @@
if if
i32.const 0 i32.const 0
i32.const 216 i32.const 216
i32.const 134 i32.const 133
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -2288,7 +2288,7 @@
if if
i32.const 0 i32.const 0
i32.const 216 i32.const 216
i32.const 282 i32.const 281
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -2397,7 +2397,7 @@
if if
i32.const 0 i32.const 0
i32.const 216 i32.const 216
i32.const 303 i32.const 302
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -2507,7 +2507,7 @@
if if
i32.const 0 i32.const 0
i32.const 216 i32.const 216
i32.const 150 i32.const 149
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3021,7 +3021,7 @@
if if
i32.const 0 i32.const 0
i32.const 216 i32.const 216
i32.const 464 i32.const 463
i32.const 10 i32.const 10
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3311,7 +3311,7 @@
if if
i32.const 0 i32.const 0
i32.const 216 i32.const 216
i32.const 324 i32.const 323
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3339,7 +3339,7 @@
if if
i32.const 0 i32.const 0
i32.const 216 i32.const 216
i32.const 329 i32.const 328
i32.const 6 i32.const 6
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -4110,7 +4110,7 @@
if if
i32.const 0 i32.const 0
i32.const 216 i32.const 216
i32.const 351 i32.const 350
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -6587,7 +6587,7 @@
if if
i32.const 0 i32.const 0
i32.const 216 i32.const 216
i32.const 190 i32.const 189
i32.const 4 i32.const 4
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable