diff --git a/tests/near-bindgen/main_near.ts.expected b/tests/near-bindgen/main_near.ts.expected new file mode 100644 index 0000000000..2c89f675e0 --- /dev/null +++ b/tests/near-bindgen/main_near.ts.expected @@ -0,0 +1,365 @@ +import "allocator/arena"; +// TODO: Why cannot import from index? +// import { BSONEncoder, BSONDecoder } from "./bson"; +import { BSONEncoder } from "./bson/encoder"; +import { BSONDecoder } from "./bson/decoder"; +import { near } from "./near"; + +declare function log(str: string): void; + +// Runtime functions +declare function return_value(value_ptr: u32): void; +declare function input_read_len(): u32; +declare function input_read_into(ptr: usize): void; + +export class FooBar { + foo: i32 = 0; + bar: i32 = 1; + flag: bool; + baz: string = "123"; + foobar: Uint8Array; +} + +export class ContainerClass { + foobar: FooBar; +} + +export class AnotherContainerClass { + foobar: FooBar; +} + +export function doNothing(): void {} + +export function add(x: i32, y: i32): i32 { + return x + y; +} + +export function getFoobar(container: ContainerClass): AnotherContainerClass { + let result = new AnotherContainerClass(); + result.foobar = container.foobar; + return result; +} + +export function __near_encode_FooBar( + value: FooBar, + encoder: BSONEncoder +): void { + encoder.setInteger("foo", value.foo); + encoder.setInteger("bar", value.bar); + encoder.setBoolean("flag", value.flag); + if (value.baz != null) { + encoder.setString("baz", value.baz); + } else { + encoder.setNull("baz"); + } + if (value.foobar != null) { + encoder.setUint8Array("foobar", value.foobar); + } else { + encoder.setNull("foobar"); + } +} +export class __near_BSONHandler_FooBar { + buffer: Uint8Array; + decoder: BSONDecoder<__near_BSONHandler_FooBar>; + value: FooBar = new FooBar(); + setInteger(name: string, value: i32): void { + if (name == "foo") { + this.value.foo = value; + return; + } + if (name == "bar") { + this.value.bar = value; + return; + } + } + setString(name: string, value: String): void { + if (name == "baz") { + this.value.baz = value; + return; + } + } + setUint8Array(name: string, value: Uint8Array): void { + if (name == "foobar") { + this.value.foobar = value; + return; + } + } + setBoolean(name: string, value: bool): void { + if (name == "flag") { + this.value.flag = value; + return; + } + } + setNull(name: string): void { + if (name == "foo") { + this.value.foo = null; + } + if (name == "bar") { + this.value.bar = null; + } + if (name == "flag") { + this.value.flag = null; + } + if (name == "baz") { + this.value.baz = null; + } + if (name == "foobar") { + this.value.foobar = null; + } + } + + pushObject(name: string): bool { + return false; + } + popObject(): void {} + pushArray(name: string): bool { + return false; + } + popArray(): void {} +} + +export function __near_decode_FooBar(buffer: Uint8Array, offset: i32): FooBar { + let handler = new __near_BSONHandler_FooBar(); + handler.buffer = buffer; + handler.decoder = new BSONDecoder<__near_BSONHandler_FooBar>(handler); + handler.decoder.deserialize(buffer, offset); + return handler.value; +} + +export function __near_encode_ContainerClass( + value: ContainerClass, + encoder: BSONEncoder +): void { + if (value.foobar != null) { + __near_encode_FooBar(value.foobar, encoder); + } else { + encoder.setNull("foobar"); + } +} +export class __near_BSONHandler_ContainerClass { + buffer: Uint8Array; + decoder: BSONDecoder<__near_BSONHandler_ContainerClass>; + value: ContainerClass = new ContainerClass(); + setInteger(name: string, value: i32): void {} + setString(name: string, value: String): void {} + setUint8Array(name: string, value: Uint8Array): void {} + setBoolean(name: string, value: bool): void {} + setNull(name: string): void { + if (name == "foobar") { + this.value.foobar = null; + } + } + + pushObject(name: string): bool { + if (name == "foobar") { + this.value.foobar = __near_decode_FooBar( + this.buffer, + this.decoder.readIndex + ); + return false; + } + + return false; + } + popObject(): void {} + pushArray(name: string): bool { + return false; + } + popArray(): void {} +} + +export function __near_decode_ContainerClass( + buffer: Uint8Array, + offset: i32 +): ContainerClass { + let handler = new __near_BSONHandler_ContainerClass(); + handler.buffer = buffer; + handler.decoder = new BSONDecoder<__near_BSONHandler_ContainerClass>(handler); + handler.decoder.deserialize(buffer, offset); + return handler.value; +} + +export function __near_encode_AnotherContainerClass( + value: AnotherContainerClass, + encoder: BSONEncoder +): void { + if (value.foobar != null) { + __near_encode_FooBar(value.foobar, encoder); + } else { + encoder.setNull("foobar"); + } +} +export class __near_BSONHandler_AnotherContainerClass { + buffer: Uint8Array; + decoder: BSONDecoder<__near_BSONHandler_AnotherContainerClass>; + value: AnotherContainerClass = new AnotherContainerClass(); + setInteger(name: string, value: i32): void {} + setString(name: string, value: String): void {} + setUint8Array(name: string, value: Uint8Array): void {} + setBoolean(name: string, value: bool): void {} + setNull(name: string): void { + if (name == "foobar") { + this.value.foobar = null; + } + } + + pushObject(name: string): bool { + if (name == "foobar") { + this.value.foobar = __near_decode_FooBar( + this.buffer, + this.decoder.readIndex + ); + return false; + } + + return false; + } + popObject(): void {} + pushArray(name: string): bool { + return false; + } + popArray(): void {} +} + +export function __near_decode_AnotherContainerClass( + buffer: Uint8Array, + offset: i32 +): AnotherContainerClass { + let handler = new __near_BSONHandler_AnotherContainerClass(); + handler.buffer = buffer; + handler.decoder = new BSONDecoder<__near_BSONHandler_AnotherContainerClass>( + handler + ); + handler.decoder.deserialize(buffer, offset); + return handler.value; +} + +export class __near_ArgsParser_doNothing { + buffer: Uint8Array; + decoder: BSONDecoder<__near_ArgsParser_doNothing>; + + setInteger(name: string, value: i32): void {} + setString(name: string, value: String): void {} + setUint8Array(name: string, value: Uint8Array): void {} + setBoolean(name: string, value: bool): void {} + setNull(name: string): void {} + + pushObject(name: string): bool { + return false; + } + popObject(): void {} + pushArray(name: string): bool { + return false; + } + popArray(): void {} +} +export function near_func_doNothing(): void { + let bson = new Uint8Array(input_read_len()); + input_read_into(bson.buffer.data); + let handler = new __near_ArgsParser_doNothing(); + handler.buffer = bson; + handler.decoder = new BSONDecoder<__near_ArgsParser_doNothing>(handler); + handler.decoder.deserialize(bson); + doNothing(); +} +export class __near_ArgsParser_add { + buffer: Uint8Array; + decoder: BSONDecoder<__near_ArgsParser_add>; + + __near_param_x: i32; + __near_param_y: i32; + setInteger(name: string, value: i32): void { + if (name == "x") { + this.__near_param_x = value; + return; + } + if (name == "y") { + this.__near_param_y = value; + return; + } + } + setString(name: string, value: String): void {} + setUint8Array(name: string, value: Uint8Array): void {} + setBoolean(name: string, value: bool): void {} + setNull(name: string): void { + if (name == "x") { + this.__near_param_x = null; + } + if (name == "y") { + this.__near_param_y = null; + } + } + + pushObject(name: string): bool { + return false; + } + popObject(): void {} + pushArray(name: string): bool { + return false; + } + popArray(): void {} +} +export function near_func_add(): void { + let bson = new Uint8Array(input_read_len()); + input_read_into(bson.buffer.data); + let handler = new __near_ArgsParser_add(); + handler.buffer = bson; + handler.decoder = new BSONDecoder<__near_ArgsParser_add>(handler); + handler.decoder.deserialize(bson); + let result = add(handler.__near_param_x, handler.__near_param_y); + + let encoder = new BSONEncoder(); + encoder.setInteger("result", result); + + return_value(near.bufferWithSize(encoder.serialize()).buffer.data); +} +export class __near_ArgsParser_getFoobar { + buffer: Uint8Array; + decoder: BSONDecoder<__near_ArgsParser_getFoobar>; + + __near_param_container: ContainerClass; + setInteger(name: string, value: i32): void {} + setString(name: string, value: String): void {} + setUint8Array(name: string, value: Uint8Array): void {} + setBoolean(name: string, value: bool): void {} + setNull(name: string): void { + if (name == "container") { + this.__near_param_container = null; + } + } + + pushObject(name: string): bool { + if (name == "container") { + this.__near_param_container = __near_decode_ContainerClass( + this.buffer, + this.decoder.readIndex + ); + return false; + } + + return false; + } + popObject(): void {} + pushArray(name: string): bool { + return false; + } + popArray(): void {} +} +export function near_func_getFoobar(): void { + let bson = new Uint8Array(input_read_len()); + input_read_into(bson.buffer.data); + let handler = new __near_ArgsParser_getFoobar(); + handler.buffer = bson; + handler.decoder = new BSONDecoder<__near_ArgsParser_getFoobar>(handler); + handler.decoder.deserialize(bson); + let result = getFoobar(handler.__near_param_container); + + let encoder = new BSONEncoder(); + if (result != null) { + __near_encode_AnotherContainerClass(result, encoder); + } else { + encoder.setNull("result"); + } + + return_value(near.bufferWithSize(encoder.serialize()).buffer.data); +} diff --git a/tests/near-bindgen/test.sh b/tests/near-bindgen/test.sh index 9fc16a923e..d511ce0edb 100755 --- a/tests/near-bindgen/test.sh +++ b/tests/near-bindgen/test.sh @@ -1,8 +1,10 @@ #!/bin/sh +set -e +set -x BASEDIR=../../ -$BASEDIR/bin/asc main.ts --outFile main.wat --nearFile main.near.ts -cp main.near.ts combined.ts -prettier --write combined.ts -$BASEDIR/bin/asc combined.ts -o combined.wat -$BASEDIR/bin/asc test.ts -o test.wasm - +$BASEDIR/bin/asc main.ts --outFile main.wat --nearFile main_near.ts +prettier --write main_near.ts +$BASEDIR/bin/asc main_near.ts -o main_near.wat +diff main_near.ts.expected main_near.ts +$BASEDIR/bin/asc test.ts -o test.wasm --textFile test.wat +diff test.wat.expected test.wat diff --git a/tests/near-bindgen/test.ts b/tests/near-bindgen/test.ts index 851c8864e2..1b703c60bd 100644 --- a/tests/near-bindgen/test.ts +++ b/tests/near-bindgen/test.ts @@ -1,5 +1,5 @@ -import * as main from "./combined"; +import * as main from "./main_near"; import { BSONEncoder } from "./bson/encoder"; @@ -55,4 +55,4 @@ function bin2hex(bin: Uint8Array, uppercase: boolean = false): string { } -runTest(); \ No newline at end of file +runTest(); diff --git a/tests/near-bindgen/test.wat.expected b/tests/near-bindgen/test.wat.expected new file mode 100644 index 0000000000..e1b310db75 --- /dev/null +++ b/tests/near-bindgen/test.wat.expected @@ -0,0 +1,4201 @@ +(module + (type $v (func)) + (type $ii (func (param i32) (result i32))) + (type $iii (func (param i32 i32) (result i32))) + (type $iiiiv (func (param i32 i32 i32 i32))) + (type $iiiv (func (param i32 i32 i32))) + (type $iiv (func (param i32 i32))) + (type $iiiiii (func (param i32 i32 i32 i32 i32) (result i32))) + (type $iiii (func (param i32 i32 i32) (result i32))) + (type $iiiiiv (func (param i32 i32 i32 i32 i32))) + (type $iv (func (param i32))) + (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) + (memory $0 1) + (data (i32.const 8) "\03\00\00\001\002\003\00") + (data (i32.const 24) "\03\00\00\00f\00o\00o\00") + (data (i32.const 40) "\0d\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00.\00t\00s\00") + (data (i32.const 72) "\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00") + (data (i32.const 136) "\1b\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00t\00y\00p\00e\00d\00a\00r\00r\00a\00y\00.\00t\00s\00") + (data (i32.const 200) "\0e\00\00\00~\00l\00i\00b\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s\00") + (data (i32.const 232) "\03\00\00\00b\00a\00r\00") + (data (i32.const 248) "\04\00\00\00f\00l\00a\00g\00") + (data (i32.const 264) "\03\00\00\00b\00a\00z\00") + (data (i32.const 280) "\06\00\00\00f\00o\00o\00b\00a\00r\00") + (data (i32.const 296) "\1e\00\00\00D\00o\00c\00u\00m\00e\00n\00t\00 \00e\00r\00r\00o\00r\00:\00 \00S\00i\00z\00e\00 \00<\00 \005\00 \00b\00y\00t\00e\00s\00") + (data (i32.const 360) "\0f\00\00\00b\00s\00o\00n\00/\00d\00e\00c\00o\00d\00e\00r\00.\00t\00s\00") + (data (i32.const 400) "\1d\00\00\00D\00o\00c\00u\00m\00e\00n\00t\00 \00e\00r\00r\00o\00r\00:\00 \00S\00i\00z\00e\00 \00m\00i\00s\00m\00a\00t\00c\00h\00") + (data (i32.const 464) "#\00\00\00D\00o\00c\00u\00m\00e\00n\00t\00 \00e\00r\00r\00o\00r\00:\00 \00M\00i\00s\00s\00i\00n\00g\00 \00t\00e\00r\00m\00i\00n\00a\00t\00i\00o\00n\00") + (data (i32.const 544) " \00\00\00D\00o\00c\00u\00m\00e\00n\00t\00 \00e\00r\00r\00o\00r\00:\00 \00I\00l\00l\00e\00g\00a\00l\00 \00k\00e\00y\00 \00n\00a\00m\00e\00") + (data (i32.const 616) "\00\00\00\00") + (data (i32.const 624) "\17\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s\00") + (data (i32.const 680) "\04\00\00\00n\00u\00l\00l\00") + (data (i32.const 696) "\1e\00\00\00P\00a\00r\00s\00i\00n\00g\00 \00e\00r\00r\00o\00r\00:\00 \00U\00n\00k\00n\00o\00w\00n\00 \00e\00l\00e\00m\00e\00n\00t\00") + (data (i32.const 760) "\07\00\00\00t\00e\00s\00t\00.\00t\00s\00") + (data (i32.const 784) "\01\00\00\00x\00") + (data (i32.const 792) "\01\00\00\00y\00") + (data (i32.const 800) "\10\00\00\000\001\002\003\004\005\006\007\008\009\00A\00B\00C\00D\00E\00F\00") + (data (i32.const 840) "\10\00\00\000\001\002\003\004\005\006\007\008\009\00a\00b\00c\00d\00e\00f\00") + (data (i32.const 880) "\06\00\00\00r\00e\00s\00u\00l\00t\00") + (table $0 1 anyfunc) + (elem (i32.const 0) $null) + (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) + (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) + (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) + (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) + (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) + (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) + (global $bson/encoder/START_SIZE i32 (i32.const 32)) + (global $bson/encoder/GROWTH_MULT i32 (i32.const 2)) + (global $~lib/internal/arraybuffer/HEADER_SIZE i32 (i32.const 8)) + (global $~lib/internal/arraybuffer/MAX_BLENGTH i32 (i32.const 1073741816)) + (global $~lib/internal/string/HEADER_SIZE i32 (i32.const 4)) + (global $~argc (mut i32) (i32.const 0)) + (global $~lib/internal/string/MAX_LENGTH i32 (i32.const 536870910)) + (global $HEAP_BASE i32 (i32.const 896)) + (export "memory" (memory $0)) + (export "table" (table $0)) + (export "runTest" (func $test/runTest)) + (start $start) + (func $~lib/allocator/arena/__memory_allocate (; 1 ;) (type $ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + get_local $0 + get_global $~lib/internal/allocator/MAX_SIZE_32 + i32.gt_u + if + unreachable + end + get_global $~lib/allocator/arena/offset + set_local $1 + get_local $1 + get_local $0 + tee_local $2 + i32.const 1 + tee_local $3 + get_local $2 + get_local $3 + i32.gt_u + select + i32.add + get_global $~lib/internal/allocator/AL_MASK + i32.add + get_global $~lib/internal/allocator/AL_MASK + i32.const -1 + i32.xor + i32.and + set_local $4 + current_memory + set_local $5 + get_local $4 + get_local $5 + i32.const 16 + i32.shl + i32.gt_u + if + get_local $4 + get_local $1 + i32.sub + i32.const 65535 + i32.add + i32.const 65535 + i32.const -1 + i32.xor + i32.and + i32.const 16 + i32.shr_u + set_local $2 + get_local $5 + tee_local $3 + get_local $2 + tee_local $6 + get_local $3 + get_local $6 + i32.gt_s + select + set_local $3 + get_local $3 + grow_memory + i32.const 0 + i32.lt_s + if + get_local $2 + grow_memory + i32.const 0 + i32.lt_s + if + unreachable + end + end + end + get_local $4 + set_global $~lib/allocator/arena/offset + get_local $1 + ) + (func $~lib/memory/memory.allocate (; 2 ;) (type $ii) (param $0 i32) (result i32) + get_local $0 + call $~lib/allocator/arena/__memory_allocate + return + ) + (func $~lib/internal/arraybuffer/computeSize (; 3 ;) (type $ii) (param $0 i32) (result i32) + i32.const 1 + i32.const 32 + get_local $0 + get_global $~lib/internal/arraybuffer/HEADER_SIZE + i32.add + i32.const 1 + i32.sub + i32.clz + i32.sub + i32.shl + ) + (func $~lib/internal/arraybuffer/allocateUnsafe (; 4 ;) (type $ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + get_local $0 + get_global $~lib/internal/arraybuffer/MAX_BLENGTH + i32.le_u + i32.eqz + if + i32.const 0 + i32.const 72 + i32.const 26 + i32.const 2 + call $~lib/env/abort + unreachable + end + block $~lib/memory/memory.allocate|inlined.0 (result i32) + get_local $0 + call $~lib/internal/arraybuffer/computeSize + set_local $2 + get_local $2 + call $~lib/allocator/arena/__memory_allocate + br $~lib/memory/memory.allocate|inlined.0 + end + set_local $1 + get_local $1 + get_local $0 + i32.store + get_local $1 + ) + (func $~lib/internal/memory/memset (; 5 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i64) + get_local $2 + i32.eqz + if + return + end + get_local $0 + get_local $1 + i32.store8 + get_local $0 + get_local $2 + i32.add + i32.const 1 + i32.sub + get_local $1 + i32.store8 + get_local $2 + i32.const 2 + i32.le_u + if + return + end + get_local $0 + i32.const 1 + i32.add + get_local $1 + i32.store8 + get_local $0 + i32.const 2 + i32.add + get_local $1 + i32.store8 + get_local $0 + get_local $2 + i32.add + i32.const 2 + i32.sub + get_local $1 + i32.store8 + get_local $0 + get_local $2 + i32.add + i32.const 3 + i32.sub + get_local $1 + i32.store8 + get_local $2 + i32.const 6 + i32.le_u + if + return + end + get_local $0 + i32.const 3 + i32.add + get_local $1 + i32.store8 + get_local $0 + get_local $2 + i32.add + i32.const 4 + i32.sub + get_local $1 + i32.store8 + get_local $2 + i32.const 8 + i32.le_u + if + return + end + i32.const 0 + get_local $0 + i32.sub + i32.const 3 + i32.and + set_local $3 + get_local $0 + get_local $3 + i32.add + set_local $0 + get_local $2 + get_local $3 + i32.sub + set_local $2 + get_local $2 + i32.const -4 + i32.and + set_local $2 + i32.const -1 + i32.const 255 + i32.div_u + get_local $1 + i32.const 255 + i32.and + i32.mul + set_local $4 + get_local $0 + get_local $4 + i32.store + get_local $0 + get_local $2 + i32.add + i32.const 4 + i32.sub + get_local $4 + i32.store + get_local $2 + i32.const 8 + i32.le_u + if + return + end + get_local $0 + i32.const 4 + i32.add + get_local $4 + i32.store + get_local $0 + i32.const 8 + i32.add + get_local $4 + i32.store + get_local $0 + get_local $2 + i32.add + i32.const 12 + i32.sub + get_local $4 + i32.store + get_local $0 + get_local $2 + i32.add + i32.const 8 + i32.sub + get_local $4 + i32.store + get_local $2 + i32.const 24 + i32.le_u + if + return + end + get_local $0 + i32.const 12 + i32.add + get_local $4 + i32.store + get_local $0 + i32.const 16 + i32.add + get_local $4 + i32.store + get_local $0 + i32.const 20 + i32.add + get_local $4 + i32.store + get_local $0 + i32.const 24 + i32.add + get_local $4 + i32.store + get_local $0 + get_local $2 + i32.add + i32.const 28 + i32.sub + get_local $4 + i32.store + get_local $0 + get_local $2 + i32.add + i32.const 24 + i32.sub + get_local $4 + i32.store + get_local $0 + get_local $2 + i32.add + i32.const 20 + i32.sub + get_local $4 + i32.store + get_local $0 + get_local $2 + i32.add + i32.const 16 + i32.sub + get_local $4 + i32.store + i32.const 24 + get_local $0 + i32.const 4 + i32.and + i32.add + set_local $3 + get_local $0 + get_local $3 + i32.add + set_local $0 + get_local $2 + get_local $3 + i32.sub + set_local $2 + get_local $4 + i64.extend_u/i32 + get_local $4 + i64.extend_u/i32 + i64.const 32 + i64.shl + i64.or + set_local $5 + block $break|0 + loop $continue|0 + get_local $2 + i32.const 32 + i32.ge_u + if + block + get_local $0 + get_local $5 + i64.store + get_local $0 + i32.const 8 + i32.add + get_local $5 + i64.store + get_local $0 + i32.const 16 + i32.add + get_local $5 + i64.store + get_local $0 + i32.const 24 + i32.add + get_local $5 + i64.store + get_local $2 + i32.const 32 + i32.sub + set_local $2 + get_local $0 + i32.const 32 + i32.add + set_local $0 + end + br $continue|0 + end + end + end + ) + (func $~lib/array/Array#constructor (; 6 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + get_local $1 + i32.const 268435454 + i32.gt_u + if + i32.const 0 + i32.const 40 + i32.const 45 + i32.const 39 + call $~lib/env/abort + unreachable + end + get_local $1 + i32.const 2 + i32.shl + set_local $2 + get_local $2 + call $~lib/internal/arraybuffer/allocateUnsafe + set_local $3 + get_local $0 + if (result i32) + get_local $0 + else + block (result i32) + i32.const 8 + call $~lib/memory/memory.allocate + set_local $4 + get_local $4 + i32.const 0 + i32.store + get_local $4 + i32.const 0 + i32.store offset=4 + get_local $4 + end + tee_local $0 + end + tee_local $0 + get_local $3 + i32.store + get_local $0 + get_local $1 + i32.store offset=4 + get_local $3 + get_global $~lib/internal/arraybuffer/HEADER_SIZE + i32.add + set_local $4 + i32.const 0 + set_local $5 + get_local $4 + get_local $5 + get_local $2 + call $~lib/internal/memory/memset + get_local $0 + ) + (func $~lib/internal/typedarray/TypedArray#constructor (; 7 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + get_local $1 + i32.const 1073741816 + i32.gt_u + if + i32.const 0 + i32.const 136 + i32.const 23 + i32.const 34 + call $~lib/env/abort + unreachable + end + get_local $1 + i32.const 0 + i32.shl + set_local $2 + get_local $2 + call $~lib/internal/arraybuffer/allocateUnsafe + set_local $3 + get_local $3 + get_global $~lib/internal/arraybuffer/HEADER_SIZE + i32.add + set_local $4 + i32.const 0 + set_local $5 + get_local $4 + get_local $5 + get_local $2 + call $~lib/internal/memory/memset + get_local $0 + if (result i32) + get_local $0 + else + block (result i32) + i32.const 12 + call $~lib/memory/memory.allocate + set_local $5 + get_local $5 + i32.const 0 + i32.store + get_local $5 + i32.const 0 + i32.store offset=4 + get_local $5 + i32.const 0 + i32.store offset=8 + get_local $5 + end + tee_local $0 + end + tee_local $0 + get_local $3 + i32.store + get_local $0 + i32.const 0 + i32.store offset=4 + get_local $0 + get_local $2 + i32.store offset=8 + get_local $0 + ) + (func $~lib/internal/typedarray/TypedArray#__get (; 8 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + get_local $1 + get_local $0 + i32.load offset=8 + i32.const 0 + i32.shr_u + i32.ge_u + if + i32.const 0 + i32.const 136 + i32.const 39 + i32.const 63 + call $~lib/env/abort + unreachable + end + block $~lib/internal/arraybuffer/LOAD|inlined.0 (result i32) + get_local $0 + i32.load + set_local $2 + get_local $0 + i32.load offset=4 + set_local $3 + get_local $2 + get_local $1 + i32.const 0 + i32.shl + i32.add + get_local $3 + i32.add + i32.load8_u offset=8 + end + ) + (func $~lib/internal/typedarray/TypedArray#__set (; 9 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + (local $3 i32) + (local $4 i32) + get_local $1 + get_local $0 + i32.load offset=8 + i32.const 0 + i32.shr_u + i32.ge_u + if + i32.const 0 + i32.const 136 + i32.const 50 + i32.const 63 + call $~lib/env/abort + unreachable + end + get_local $0 + i32.load + set_local $3 + get_local $0 + i32.load offset=4 + set_local $4 + get_local $3 + get_local $1 + i32.const 0 + i32.shl + i32.add + get_local $4 + i32.add + get_local $2 + i32.store8 offset=8 + ) + (func $bson/encoder/BSONEncoder#growIfNeeded (; 10 ;) (type $iiv) (param $0 i32) (param $1 i32) + (local $2 i32) + (local $3 i32) + block $~lib/internal/typedarray/TypedArray#get:length|inlined.1 (result i32) + get_local $0 + i32.load offset=4 + set_local $2 + get_local $2 + i32.load offset=8 + i32.const 0 + i32.shr_u + end + get_local $0 + i32.load offset=8 + get_local $1 + i32.add + i32.ge_s + if + return + end + get_local $0 + i32.load offset=4 + set_local $2 + get_local $0 + i32.const 0 + block $~lib/internal/typedarray/TypedArray#get:length|inlined.2 (result i32) + get_local $0 + i32.load offset=4 + set_local $3 + get_local $3 + i32.load offset=8 + i32.const 0 + i32.shr_u + end + get_global $bson/encoder/GROWTH_MULT + i32.mul + call $~lib/internal/typedarray/TypedArray#constructor + i32.store offset=4 + block $break|0 + i32.const 0 + set_local $3 + loop $repeat|0 + get_local $3 + block $~lib/internal/typedarray/TypedArray#get:length|inlined.4 (result i32) + get_local $2 + i32.load offset=8 + i32.const 0 + i32.shr_u + end + i32.lt_s + i32.eqz + br_if $break|0 + get_local $0 + i32.load offset=4 + get_local $3 + get_local $2 + get_local $3 + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + call $~lib/internal/typedarray/TypedArray#__set + get_local $3 + i32.const 1 + i32.add + set_local $3 + br $repeat|0 + unreachable + end + unreachable + end + ) + (func $bson/encoder/BSONEncoder#writeByte (; 11 ;) (type $iiv) (param $0 i32) (param $1 i32) + (local $2 i32) + get_local $0 + i32.const 1 + call $bson/encoder/BSONEncoder#growIfNeeded + get_local $0 + i32.load offset=4 + block (result i32) + get_local $0 + get_local $0 + i32.load offset=8 + tee_local $2 + i32.const 1 + i32.add + i32.store offset=8 + get_local $2 + end + get_local $1 + call $~lib/internal/typedarray/TypedArray#__set + ) + (func $~lib/string/String#charCodeAt (; 12 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + get_local $0 + i32.const 0 + i32.ne + i32.eqz + if + i32.const 0 + i32.const 200 + i32.const 75 + i32.const 4 + call $~lib/env/abort + unreachable + end + get_local $1 + get_local $0 + i32.load + i32.ge_u + if + i32.const -1 + return + end + get_local $0 + get_local $1 + i32.const 1 + i32.shl + i32.add + i32.load16_u offset=4 + ) + (func $bson/encoder/BSONEncoder#cstring (; 13 ;) (type $iiv) (param $0 i32) (param $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + block $break|0 + block + i32.const 0 + set_local $2 + get_local $1 + i32.load + set_local $3 + end + loop $repeat|0 + get_local $2 + get_local $3 + i32.lt_s + i32.eqz + br_if $break|0 + block + get_local $1 + get_local $2 + call $~lib/string/String#charCodeAt + set_local $4 + get_local $4 + i32.const 128 + i32.lt_s + if + get_local $0 + get_local $4 + call $bson/encoder/BSONEncoder#writeByte + else + get_local $4 + i32.const 2048 + i32.lt_s + if + get_local $0 + get_local $4 + i32.const 6 + i32.shr_u + i32.const 192 + i32.or + call $bson/encoder/BSONEncoder#writeByte + get_local $0 + get_local $4 + i32.const 63 + i32.and + i32.const 128 + i32.or + call $bson/encoder/BSONEncoder#writeByte + else + get_local $0 + get_local $4 + i32.const 12 + i32.shr_u + i32.const 224 + i32.or + call $bson/encoder/BSONEncoder#writeByte + get_local $0 + get_local $4 + i32.const 6 + i32.shr_u + i32.const 63 + i32.and + i32.const 128 + i32.or + call $bson/encoder/BSONEncoder#writeByte + get_local $0 + get_local $4 + i32.const 63 + i32.and + i32.const 128 + i32.or + call $bson/encoder/BSONEncoder#writeByte + end + end + end + get_local $2 + i32.const 1 + i32.add + set_local $2 + br $repeat|0 + unreachable + end + unreachable + end + get_local $0 + i32.const 0 + call $bson/encoder/BSONEncoder#writeByte + ) + (func $bson/encoder/BSONEncoder#int32 (; 14 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + get_local $2 + i32.const -1 + i32.eq + if + get_local $0 + i32.const 4 + call $bson/encoder/BSONEncoder#growIfNeeded + get_local $0 + i32.load offset=8 + set_local $2 + get_local $0 + get_local $0 + i32.load offset=8 + i32.const 4 + i32.add + i32.store offset=8 + end + get_local $0 + i32.load offset=4 + get_local $2 + get_local $1 + i32.const 255 + i32.and + call $~lib/internal/typedarray/TypedArray#__set + get_local $0 + i32.load offset=4 + get_local $2 + i32.const 1 + i32.add + get_local $1 + i32.const 8 + i32.shr_u + i32.const 255 + i32.and + call $~lib/internal/typedarray/TypedArray#__set + get_local $0 + i32.load offset=4 + get_local $2 + i32.const 2 + i32.add + get_local $1 + i32.const 16 + i32.shr_u + i32.const 255 + i32.and + call $~lib/internal/typedarray/TypedArray#__set + get_local $0 + i32.load offset=4 + get_local $2 + i32.const 3 + i32.add + get_local $1 + i32.const 24 + i32.shr_u + i32.const 255 + i32.and + call $~lib/internal/typedarray/TypedArray#__set + ) + (func $bson/encoder/BSONEncoder#int32|trampoline (; 15 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + block $1of1 + block $0of1 + block $outOfRange + get_global $~argc + i32.const 1 + i32.sub + br_table $0of1 $1of1 $outOfRange + end + unreachable + end + i32.const -1 + set_local $2 + end + get_local $0 + get_local $1 + get_local $2 + call $bson/encoder/BSONEncoder#int32 + ) + (func $bson/encoder/BSONEncoder#setInteger (; 16 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + get_local $0 + i32.const 16 + call $bson/encoder/BSONEncoder#writeByte + get_local $0 + get_local $1 + call $bson/encoder/BSONEncoder#cstring + i32.const 1 + set_global $~argc + get_local $0 + get_local $2 + i32.const 0 + call $bson/encoder/BSONEncoder#int32|trampoline + ) + (func $bson/encoder/BSONEncoder#setBoolean (; 17 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + get_local $0 + i32.const 8 + call $bson/encoder/BSONEncoder#writeByte + get_local $0 + get_local $1 + call $bson/encoder/BSONEncoder#cstring + get_local $0 + get_local $2 + i32.const 0 + i32.ne + if (result i32) + i32.const 1 + else + i32.const 0 + end + call $bson/encoder/BSONEncoder#writeByte + ) + (func $~lib/internal/string/compareUnsafe (; 18 ;) (type $iiiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (result i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + i32.const 0 + set_local $5 + get_local $0 + get_local $1 + i32.const 1 + i32.shl + i32.add + set_local $6 + get_local $2 + get_local $3 + i32.const 1 + i32.shl + i32.add + set_local $7 + block $break|0 + loop $continue|0 + get_local $4 + if (result i32) + get_local $6 + i32.load16_u offset=4 + get_local $7 + i32.load16_u offset=4 + i32.sub + tee_local $5 + i32.eqz + else + get_local $4 + end + if + block + get_local $4 + i32.const 1 + i32.sub + set_local $4 + get_local $6 + i32.const 2 + i32.add + set_local $6 + get_local $7 + i32.const 2 + i32.add + set_local $7 + end + br $continue|0 + end + end + end + get_local $5 + ) + (func $~lib/string/String.__eq (; 19 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + get_local $0 + get_local $1 + i32.eq + if + i32.const 1 + return + end + get_local $0 + i32.const 0 + i32.eq + tee_local $2 + if (result i32) + get_local $2 + else + get_local $1 + i32.const 0 + i32.eq + end + if + i32.const 0 + return + end + get_local $0 + i32.load + set_local $3 + get_local $3 + get_local $1 + i32.load + i32.ne + if + i32.const 0 + return + end + get_local $0 + i32.const 0 + get_local $1 + i32.const 0 + get_local $3 + call $~lib/internal/string/compareUnsafe + i32.eqz + ) + (func $~lib/string/String.__ne (; 20 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + get_local $0 + get_local $1 + call $~lib/string/String.__eq + i32.eqz + ) + (func $bson/encoder/BSONEncoder#setString (; 21 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + (local $3 i32) + get_local $0 + i32.const 2 + call $bson/encoder/BSONEncoder#writeByte + get_local $0 + get_local $1 + call $bson/encoder/BSONEncoder#cstring + get_local $0 + i32.load offset=8 + set_local $3 + get_local $0 + get_local $0 + i32.load offset=8 + i32.const 4 + i32.add + i32.store offset=8 + get_local $0 + get_local $2 + call $bson/encoder/BSONEncoder#cstring + get_local $0 + get_local $0 + i32.load offset=8 + get_local $3 + i32.sub + i32.const 4 + i32.sub + get_local $3 + call $bson/encoder/BSONEncoder#int32 + ) + (func $bson/encoder/BSONEncoder#setNull (; 22 ;) (type $iiv) (param $0 i32) (param $1 i32) + get_local $0 + i32.const 10 + call $bson/encoder/BSONEncoder#writeByte + get_local $0 + get_local $1 + call $bson/encoder/BSONEncoder#cstring + ) + (func $bson/encoder/BSONEncoder#setUint8Array (; 23 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + (local $3 i32) + get_local $0 + i32.const 5 + call $bson/encoder/BSONEncoder#writeByte + get_local $0 + get_local $1 + call $bson/encoder/BSONEncoder#cstring + i32.const 1 + set_global $~argc + get_local $0 + block $~lib/internal/typedarray/TypedArray#get:length|inlined.5 (result i32) + get_local $2 + i32.load offset=8 + i32.const 0 + i32.shr_u + end + i32.const 0 + call $bson/encoder/BSONEncoder#int32|trampoline + get_local $0 + i32.const 0 + call $bson/encoder/BSONEncoder#writeByte + block $break|0 + i32.const 0 + set_local $3 + loop $repeat|0 + get_local $3 + block $~lib/internal/typedarray/TypedArray#get:length|inlined.7 (result i32) + get_local $2 + i32.load offset=8 + i32.const 0 + i32.shr_u + end + i32.lt_s + i32.eqz + br_if $break|0 + get_local $0 + get_local $2 + get_local $3 + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + call $bson/encoder/BSONEncoder#writeByte + get_local $3 + i32.const 1 + i32.add + set_local $3 + br $repeat|0 + unreachable + end + unreachable + end + ) + (func $main_near/__near_encode_FooBar (; 24 ;) (type $iiv) (param $0 i32) (param $1 i32) + get_local $1 + i32.const 24 + get_local $0 + i32.load + call $bson/encoder/BSONEncoder#setInteger + get_local $1 + i32.const 232 + get_local $0 + i32.load offset=4 + call $bson/encoder/BSONEncoder#setInteger + get_local $1 + i32.const 248 + get_local $0 + i32.load8_u offset=8 + call $bson/encoder/BSONEncoder#setBoolean + get_local $0 + i32.load offset=12 + i32.const 0 + call $~lib/string/String.__ne + if + get_local $1 + i32.const 264 + get_local $0 + i32.load offset=12 + call $bson/encoder/BSONEncoder#setString + else + get_local $1 + i32.const 264 + call $bson/encoder/BSONEncoder#setNull + end + get_local $0 + i32.load offset=16 + i32.const 0 + i32.ne + if + get_local $1 + i32.const 280 + get_local $0 + i32.load offset=16 + call $bson/encoder/BSONEncoder#setUint8Array + else + get_local $1 + i32.const 280 + call $bson/encoder/BSONEncoder#setNull + end + ) + (func $~lib/typedarray/Uint8Array#subarray (; 25 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + block $~lib/internal/typedarray/TypedArray#get:length|inlined.8 (result i32) + get_local $0 + i32.load offset=8 + i32.const 0 + i32.shr_u + end + set_local $3 + get_local $1 + i32.const 0 + i32.lt_s + if + get_local $3 + get_local $1 + i32.add + tee_local $4 + i32.const 0 + tee_local $5 + get_local $4 + get_local $5 + i32.gt_s + select + set_local $1 + else + get_local $1 + tee_local $4 + get_local $3 + tee_local $5 + get_local $4 + get_local $5 + i32.lt_s + select + set_local $1 + end + get_local $2 + i32.const 0 + i32.lt_s + if + get_local $3 + get_local $2 + i32.add + tee_local $4 + get_local $1 + tee_local $5 + get_local $4 + get_local $5 + i32.gt_s + select + set_local $2 + else + get_local $2 + tee_local $4 + get_local $3 + tee_local $5 + get_local $4 + get_local $5 + i32.lt_s + select + tee_local $4 + get_local $1 + tee_local $5 + get_local $4 + get_local $5 + i32.gt_s + select + set_local $2 + end + block $~lib/memory/memory.allocate|inlined.1 (result i32) + i32.const 12 + set_local $4 + get_local $4 + call $~lib/allocator/arena/__memory_allocate + br $~lib/memory/memory.allocate|inlined.1 + end + set_local $4 + get_local $4 + get_local $0 + i32.load + i32.store + get_local $4 + get_local $0 + i32.load offset=4 + get_local $1 + i32.const 0 + i32.shl + i32.add + i32.store offset=4 + get_local $4 + get_local $2 + get_local $1 + i32.sub + i32.const 0 + i32.shl + i32.store offset=8 + get_local $4 + ) + (func $bson/encoder/BSONEncoder#serialize (; 26 ;) (type $ii) (param $0 i32) (result i32) + get_local $0 + i32.const 0 + call $bson/encoder/BSONEncoder#writeByte + get_local $0 + get_local $0 + i32.load offset=8 + i32.const 0 + call $bson/encoder/BSONEncoder#int32 + get_local $0 + i32.load offset=4 + i32.const 0 + get_local $0 + i32.load offset=8 + call $~lib/typedarray/Uint8Array#subarray + ) + (func $bson/decoder/BSONDecoder<__near_BSONHandler_FooBar>#constructor (; 27 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + get_local $0 + if (result i32) + get_local $0 + else + block (result i32) + i32.const 8 + call $~lib/memory/memory.allocate + set_local $2 + get_local $2 + i32.const 0 + i32.store + get_local $2 + i32.const 0 + i32.store offset=4 + get_local $2 + end + tee_local $0 + end + tee_local $0 + get_local $1 + i32.store + get_local $0 + ) + (func $~lib/internal/string/allocateUnsafe (; 28 ;) (type $ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + get_local $0 + i32.const 0 + i32.gt_s + tee_local $1 + if (result i32) + get_local $0 + get_global $~lib/internal/string/MAX_LENGTH + i32.le_s + else + get_local $1 + end + i32.eqz + if + i32.const 0 + i32.const 624 + i32.const 14 + i32.const 2 + call $~lib/env/abort + unreachable + end + block $~lib/memory/memory.allocate|inlined.2 (result i32) + get_global $~lib/internal/string/HEADER_SIZE + get_local $0 + i32.const 1 + i32.shl + i32.add + set_local $1 + get_local $1 + call $~lib/allocator/arena/__memory_allocate + br $~lib/memory/memory.allocate|inlined.2 + end + set_local $2 + get_local $2 + get_local $0 + i32.store + get_local $2 + ) + (func $~lib/string/String.fromCharCode (; 29 ;) (type $ii) (param $0 i32) (result i32) + (local $1 i32) + i32.const 1 + call $~lib/internal/string/allocateUnsafe + set_local $1 + get_local $1 + get_local $0 + i32.store16 offset=4 + get_local $1 + ) + (func $~lib/internal/memory/memcpy (; 30 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + block $break|0 + loop $continue|0 + get_local $2 + if (result i32) + get_local $1 + i32.const 3 + i32.and + else + get_local $2 + end + if + block + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + get_local $2 + i32.const 1 + i32.sub + set_local $2 + end + br $continue|0 + end + end + end + get_local $0 + i32.const 3 + i32.and + i32.const 0 + i32.eq + if + block $break|1 + loop $continue|1 + get_local $2 + i32.const 16 + i32.ge_u + if + block + get_local $0 + get_local $1 + i32.load + i32.store + get_local $0 + i32.const 4 + i32.add + get_local $1 + i32.const 4 + i32.add + i32.load + i32.store + get_local $0 + i32.const 8 + i32.add + get_local $1 + i32.const 8 + i32.add + i32.load + i32.store + get_local $0 + i32.const 12 + i32.add + get_local $1 + i32.const 12 + i32.add + i32.load + i32.store + get_local $1 + i32.const 16 + i32.add + set_local $1 + get_local $0 + i32.const 16 + i32.add + set_local $0 + get_local $2 + i32.const 16 + i32.sub + set_local $2 + end + br $continue|1 + end + end + end + get_local $2 + i32.const 8 + i32.and + if + get_local $0 + get_local $1 + i32.load + i32.store + get_local $0 + i32.const 4 + i32.add + get_local $1 + i32.const 4 + i32.add + i32.load + i32.store + get_local $0 + i32.const 8 + i32.add + set_local $0 + get_local $1 + i32.const 8 + i32.add + set_local $1 + end + get_local $2 + i32.const 4 + i32.and + if + get_local $0 + get_local $1 + i32.load + i32.store + get_local $0 + i32.const 4 + i32.add + set_local $0 + get_local $1 + i32.const 4 + i32.add + set_local $1 + end + get_local $2 + i32.const 2 + i32.and + if + get_local $0 + get_local $1 + i32.load16_u + i32.store16 + get_local $0 + i32.const 2 + i32.add + set_local $0 + get_local $1 + i32.const 2 + i32.add + set_local $1 + end + get_local $2 + i32.const 1 + i32.and + if + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + end + return + end + get_local $2 + i32.const 32 + i32.ge_u + if + block $break|2 + block $case2|2 + block $case1|2 + block $case0|2 + get_local $0 + i32.const 3 + i32.and + set_local $5 + get_local $5 + i32.const 1 + i32.eq + br_if $case0|2 + get_local $5 + i32.const 2 + i32.eq + br_if $case1|2 + get_local $5 + i32.const 3 + i32.eq + br_if $case2|2 + br $break|2 + end + block + get_local $1 + i32.load + set_local $3 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + get_local $2 + i32.const 3 + i32.sub + set_local $2 + block $break|3 + loop $continue|3 + get_local $2 + i32.const 17 + i32.ge_u + if + block + get_local $1 + i32.const 1 + i32.add + i32.load + set_local $4 + get_local $0 + get_local $3 + i32.const 24 + i32.shr_u + get_local $4 + i32.const 8 + i32.shl + i32.or + i32.store + get_local $1 + i32.const 5 + i32.add + i32.load + set_local $3 + get_local $0 + i32.const 4 + i32.add + get_local $4 + i32.const 24 + i32.shr_u + get_local $3 + i32.const 8 + i32.shl + i32.or + i32.store + get_local $1 + i32.const 9 + i32.add + i32.load + set_local $4 + get_local $0 + i32.const 8 + i32.add + get_local $3 + i32.const 24 + i32.shr_u + get_local $4 + i32.const 8 + i32.shl + i32.or + i32.store + get_local $1 + i32.const 13 + i32.add + i32.load + set_local $3 + get_local $0 + i32.const 12 + i32.add + get_local $4 + i32.const 24 + i32.shr_u + get_local $3 + i32.const 8 + i32.shl + i32.or + i32.store + get_local $1 + i32.const 16 + i32.add + set_local $1 + get_local $0 + i32.const 16 + i32.add + set_local $0 + get_local $2 + i32.const 16 + i32.sub + set_local $2 + end + br $continue|3 + end + end + end + br $break|2 + unreachable + end + unreachable + end + block + get_local $1 + i32.load + set_local $3 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + get_local $2 + i32.const 2 + i32.sub + set_local $2 + block $break|4 + loop $continue|4 + get_local $2 + i32.const 18 + i32.ge_u + if + block + get_local $1 + i32.const 2 + i32.add + i32.load + set_local $4 + get_local $0 + get_local $3 + i32.const 16 + i32.shr_u + get_local $4 + i32.const 16 + i32.shl + i32.or + i32.store + get_local $1 + i32.const 6 + i32.add + i32.load + set_local $3 + get_local $0 + i32.const 4 + i32.add + get_local $4 + i32.const 16 + i32.shr_u + get_local $3 + i32.const 16 + i32.shl + i32.or + i32.store + get_local $1 + i32.const 10 + i32.add + i32.load + set_local $4 + get_local $0 + i32.const 8 + i32.add + get_local $3 + i32.const 16 + i32.shr_u + get_local $4 + i32.const 16 + i32.shl + i32.or + i32.store + get_local $1 + i32.const 14 + i32.add + i32.load + set_local $3 + get_local $0 + i32.const 12 + i32.add + get_local $4 + i32.const 16 + i32.shr_u + get_local $3 + i32.const 16 + i32.shl + i32.or + i32.store + get_local $1 + i32.const 16 + i32.add + set_local $1 + get_local $0 + i32.const 16 + i32.add + set_local $0 + get_local $2 + i32.const 16 + i32.sub + set_local $2 + end + br $continue|4 + end + end + end + br $break|2 + unreachable + end + unreachable + end + block + get_local $1 + i32.load + set_local $3 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + get_local $2 + i32.const 1 + i32.sub + set_local $2 + block $break|5 + loop $continue|5 + get_local $2 + i32.const 19 + i32.ge_u + if + block + get_local $1 + i32.const 3 + i32.add + i32.load + set_local $4 + get_local $0 + get_local $3 + i32.const 8 + i32.shr_u + get_local $4 + i32.const 24 + i32.shl + i32.or + i32.store + get_local $1 + i32.const 7 + i32.add + i32.load + set_local $3 + get_local $0 + i32.const 4 + i32.add + get_local $4 + i32.const 8 + i32.shr_u + get_local $3 + i32.const 24 + i32.shl + i32.or + i32.store + get_local $1 + i32.const 11 + i32.add + i32.load + set_local $4 + get_local $0 + i32.const 8 + i32.add + get_local $3 + i32.const 8 + i32.shr_u + get_local $4 + i32.const 24 + i32.shl + i32.or + i32.store + get_local $1 + i32.const 15 + i32.add + i32.load + set_local $3 + get_local $0 + i32.const 12 + i32.add + get_local $4 + i32.const 8 + i32.shr_u + get_local $3 + i32.const 24 + i32.shl + i32.or + i32.store + get_local $1 + i32.const 16 + i32.add + set_local $1 + get_local $0 + i32.const 16 + i32.add + set_local $0 + get_local $2 + i32.const 16 + i32.sub + set_local $2 + end + br $continue|5 + end + end + end + br $break|2 + unreachable + end + unreachable + end + end + get_local $2 + i32.const 16 + i32.and + if + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + end + get_local $2 + i32.const 8 + i32.and + if + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + end + get_local $2 + i32.const 4 + i32.and + if + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + end + get_local $2 + i32.const 2 + i32.and + if + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + end + get_local $2 + i32.const 1 + i32.and + if + block (result i32) + get_local $0 + tee_local $5 + i32.const 1 + i32.add + set_local $0 + get_local $5 + end + block (result i32) + get_local $1 + tee_local $5 + i32.const 1 + i32.add + set_local $1 + get_local $5 + end + i32.load8_u + i32.store8 + end + ) + (func $~lib/internal/memory/memmove (; 31 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + (local $3 i32) + get_local $0 + get_local $1 + i32.eq + if + return + end + get_local $1 + get_local $2 + i32.add + get_local $0 + i32.le_u + tee_local $3 + if (result i32) + get_local $3 + else + get_local $0 + get_local $2 + i32.add + get_local $1 + i32.le_u + end + if + get_local $0 + get_local $1 + get_local $2 + call $~lib/internal/memory/memcpy + return + end + get_local $0 + get_local $1 + i32.lt_u + if + get_local $1 + i32.const 7 + i32.and + get_local $0 + i32.const 7 + i32.and + i32.eq + if + block $break|0 + loop $continue|0 + get_local $0 + i32.const 7 + i32.and + if + block + get_local $2 + i32.eqz + if + return + end + get_local $2 + i32.const 1 + i32.sub + set_local $2 + block (result i32) + get_local $0 + tee_local $3 + i32.const 1 + i32.add + set_local $0 + get_local $3 + end + block (result i32) + get_local $1 + tee_local $3 + i32.const 1 + i32.add + set_local $1 + get_local $3 + end + i32.load8_u + i32.store8 + end + br $continue|0 + end + end + end + block $break|1 + loop $continue|1 + get_local $2 + i32.const 8 + i32.ge_u + if + block + get_local $0 + get_local $1 + i64.load + i64.store + get_local $2 + i32.const 8 + i32.sub + set_local $2 + get_local $0 + i32.const 8 + i32.add + set_local $0 + get_local $1 + i32.const 8 + i32.add + set_local $1 + end + br $continue|1 + end + end + end + end + block $break|2 + loop $continue|2 + get_local $2 + if + block + block (result i32) + get_local $0 + tee_local $3 + i32.const 1 + i32.add + set_local $0 + get_local $3 + end + block (result i32) + get_local $1 + tee_local $3 + i32.const 1 + i32.add + set_local $1 + get_local $3 + end + i32.load8_u + i32.store8 + get_local $2 + i32.const 1 + i32.sub + set_local $2 + end + br $continue|2 + end + end + end + else + get_local $1 + i32.const 7 + i32.and + get_local $0 + i32.const 7 + i32.and + i32.eq + if + block $break|3 + loop $continue|3 + get_local $0 + get_local $2 + i32.add + i32.const 7 + i32.and + if + block + get_local $2 + i32.eqz + if + return + end + get_local $0 + get_local $2 + i32.const 1 + i32.sub + tee_local $2 + i32.add + get_local $1 + get_local $2 + i32.add + i32.load8_u + i32.store8 + end + br $continue|3 + end + end + end + block $break|4 + loop $continue|4 + get_local $2 + i32.const 8 + i32.ge_u + if + block + get_local $2 + i32.const 8 + i32.sub + set_local $2 + get_local $0 + get_local $2 + i32.add + get_local $1 + get_local $2 + i32.add + i64.load + i64.store + end + br $continue|4 + end + end + end + end + block $break|5 + loop $continue|5 + get_local $2 + if + get_local $0 + get_local $2 + i32.const 1 + i32.sub + tee_local $2 + i32.add + get_local $1 + get_local $2 + i32.add + i32.load8_u + i32.store8 + br $continue|5 + end + end + end + end + ) + (func $~lib/internal/string/copyUnsafe (; 32 ;) (type $iiiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + get_local $0 + get_local $1 + i32.const 1 + i32.shl + i32.add + get_global $~lib/internal/string/HEADER_SIZE + i32.add + set_local $5 + get_local $2 + get_local $3 + i32.const 1 + i32.shl + i32.add + get_global $~lib/internal/string/HEADER_SIZE + i32.add + set_local $6 + get_local $4 + i32.const 1 + i32.shl + set_local $7 + get_local $5 + get_local $6 + get_local $7 + call $~lib/internal/memory/memmove + ) + (func $~lib/string/String#concat (; 33 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + get_local $0 + i32.const 0 + i32.ne + i32.eqz + if + i32.const 0 + i32.const 200 + i32.const 110 + i32.const 4 + call $~lib/env/abort + unreachable + end + get_local $1 + i32.const 0 + i32.eq + if + i32.const 680 + set_local $1 + end + get_local $0 + i32.load + set_local $2 + get_local $1 + i32.load + set_local $3 + get_local $2 + get_local $3 + i32.add + set_local $4 + get_local $4 + i32.const 0 + i32.eq + if + i32.const 616 + return + end + get_local $4 + call $~lib/internal/string/allocateUnsafe + set_local $5 + get_local $5 + i32.const 0 + get_local $0 + i32.const 0 + get_local $2 + call $~lib/internal/string/copyUnsafe + get_local $5 + get_local $2 + get_local $1 + i32.const 0 + get_local $3 + call $~lib/internal/string/copyUnsafe + get_local $5 + ) + (func $~lib/string/String.__concat (; 34 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + get_local $0 + i32.eqz + if + i32.const 680 + set_local $0 + end + get_local $0 + get_local $1 + call $~lib/string/String#concat + ) + (func $bson/decoder/bin2str (; 35 ;) (type $ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + i32.const 616 + set_local $1 + block $~lib/internal/typedarray/TypedArray#get:length|inlined.15 (result i32) + get_local $0 + i32.load offset=8 + i32.const 0 + i32.shr_u + end + set_local $2 + i32.const 0 + set_local $3 + block $break|0 + loop $continue|0 + get_local $3 + get_local $2 + i32.lt_s + if + block + get_local $0 + get_local $3 + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + set_local $4 + get_local $4 + i32.const 128 + i32.lt_s + if + get_local $1 + get_local $4 + call $~lib/string/String.fromCharCode + call $~lib/string/String.__concat + set_local $1 + get_local $3 + i32.const 1 + i32.add + set_local $3 + else + get_local $4 + i32.const 191 + i32.gt_s + tee_local $7 + if (result i32) + get_local $4 + i32.const 224 + i32.lt_s + else + get_local $7 + end + if + get_local $0 + get_local $3 + i32.const 1 + i32.add + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + set_local $5 + get_local $1 + get_local $4 + i32.const 31 + i32.and + i32.const 6 + i32.shl + get_local $5 + i32.const 63 + i32.and + i32.or + call $~lib/string/String.fromCharCode + call $~lib/string/String.__concat + set_local $1 + get_local $3 + i32.const 2 + i32.add + set_local $3 + else + get_local $0 + get_local $3 + i32.const 1 + i32.add + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + set_local $5 + get_local $0 + get_local $3 + i32.const 2 + i32.add + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + set_local $6 + get_local $1 + get_local $4 + i32.const 15 + i32.and + i32.const 12 + i32.shl + get_local $5 + i32.const 63 + i32.and + i32.const 6 + i32.shl + i32.or + get_local $6 + i32.const 63 + i32.and + i32.or + call $~lib/string/String.fromCharCode + call $~lib/string/String.__concat + set_local $1 + get_local $3 + i32.const 3 + i32.add + set_local $3 + end + end + end + br $continue|0 + end + end + end + get_local $1 + ) + (func $main_near/__near_BSONHandler_FooBar#setString (; 36 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + get_local $1 + i32.const 264 + call $~lib/string/String.__eq + if + get_local $0 + i32.load offset=8 + get_local $2 + i32.store offset=12 + return + end + ) + (func $main_near/__near_BSONHandler_FooBar#pushObject (; 37 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + i32.const 0 + ) + (func $main_near/__near_BSONHandler_FooBar#popObject (; 38 ;) (type $iv) (param $0 i32) + nop + ) + (func $main_near/__near_BSONHandler_FooBar#pushArray (; 39 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + i32.const 0 + ) + (func $main_near/__near_BSONHandler_FooBar#popArray (; 40 ;) (type $iv) (param $0 i32) + nop + ) + (func $main_near/__near_BSONHandler_FooBar#setUint8Array (; 41 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + get_local $1 + i32.const 280 + call $~lib/string/String.__eq + if + get_local $0 + i32.load offset=8 + get_local $2 + i32.store offset=16 + return + end + ) + (func $main_near/__near_BSONHandler_FooBar#setBoolean (; 42 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + get_local $1 + i32.const 248 + call $~lib/string/String.__eq + if + get_local $0 + i32.load offset=8 + get_local $2 + i32.const 0 + i32.ne + i32.store8 offset=8 + return + end + ) + (func $main_near/__near_BSONHandler_FooBar#setNull (; 43 ;) (type $iiv) (param $0 i32) (param $1 i32) + get_local $1 + i32.const 24 + call $~lib/string/String.__eq + if + get_local $0 + i32.load offset=8 + i32.const 0 + i32.store + end + get_local $1 + i32.const 232 + call $~lib/string/String.__eq + if + get_local $0 + i32.load offset=8 + i32.const 0 + i32.store offset=4 + end + get_local $1 + i32.const 248 + call $~lib/string/String.__eq + if + get_local $0 + i32.load offset=8 + i32.const 0 + i32.store8 offset=8 + end + get_local $1 + i32.const 264 + call $~lib/string/String.__eq + if + get_local $0 + i32.load offset=8 + i32.const 0 + i32.store offset=12 + end + get_local $1 + i32.const 280 + call $~lib/string/String.__eq + if + get_local $0 + i32.load offset=8 + i32.const 0 + i32.store offset=16 + end + ) + (func $main_near/__near_BSONHandler_FooBar#setInteger (; 44 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + get_local $1 + i32.const 24 + call $~lib/string/String.__eq + if + get_local $0 + i32.load offset=8 + get_local $2 + i32.store + return + end + get_local $1 + i32.const 232 + call $~lib/string/String.__eq + if + get_local $0 + i32.load offset=8 + get_local $2 + i32.store offset=4 + return + end + ) + (func $bson/decoder/BSONDecoder<__near_BSONHandler_FooBar>#deserialize (; 45 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + get_local $0 + get_local $2 + i32.store offset=4 + block $~lib/internal/typedarray/TypedArray#get:length|inlined.9 (result i32) + get_local $1 + i32.load offset=8 + i32.const 0 + i32.shr_u + end + i32.const 5 + i32.ge_s + i32.eqz + if + i32.const 296 + i32.const 360 + i32.const 49 + i32.const 8 + call $~lib/env/abort + unreachable + end + get_local $1 + block (result i32) + get_local $0 + get_local $0 + i32.load offset=4 + tee_local $3 + i32.const 1 + i32.add + i32.store offset=4 + get_local $3 + end + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + get_local $1 + block (result i32) + get_local $0 + get_local $0 + i32.load offset=4 + tee_local $3 + i32.const 1 + i32.add + i32.store offset=4 + get_local $3 + end + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + i32.const 8 + i32.shl + i32.or + get_local $1 + block (result i32) + get_local $0 + get_local $0 + i32.load offset=4 + tee_local $3 + i32.const 1 + i32.add + i32.store offset=4 + get_local $3 + end + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + i32.const 16 + i32.shl + i32.or + get_local $1 + block (result i32) + get_local $0 + get_local $0 + i32.load offset=4 + tee_local $3 + i32.const 1 + i32.add + i32.store offset=4 + get_local $3 + end + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + i32.const 24 + i32.shl + i32.or + set_local $3 + get_local $3 + block $~lib/internal/typedarray/TypedArray#get:length|inlined.10 (result i32) + get_local $1 + i32.load offset=8 + i32.const 0 + i32.shr_u + end + i32.le_s + i32.eqz + if + i32.const 400 + i32.const 360 + i32.const 52 + i32.const 8 + call $~lib/env/abort + unreachable + end + get_local $1 + block $~lib/internal/typedarray/TypedArray#get:length|inlined.11 (result i32) + get_local $1 + i32.load offset=8 + i32.const 0 + i32.shr_u + end + i32.const 1 + i32.sub + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + i32.const 0 + i32.eq + i32.eqz + if + i32.const 464 + i32.const 360 + i32.const 53 + i32.const 8 + call $~lib/env/abort + unreachable + end + block $break|0 + loop $repeat|0 + i32.const 1 + i32.eqz + br_if $break|0 + block + get_local $1 + block (result i32) + get_local $0 + get_local $0 + i32.load offset=4 + tee_local $4 + i32.const 1 + i32.add + i32.store offset=4 + get_local $4 + end + call $~lib/internal/typedarray/TypedArray#__get + set_local $4 + get_local $4 + i32.const 255 + i32.and + i32.const 0 + i32.eq + if + br $break|0 + end + get_local $0 + i32.load offset=4 + set_local $5 + block $break|1 + loop $repeat|1 + get_local $1 + get_local $5 + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + i32.const 0 + i32.ne + tee_local $6 + if (result i32) + get_local $5 + block $~lib/internal/typedarray/TypedArray#get:length|inlined.13 (result i32) + get_local $1 + i32.load offset=8 + i32.const 0 + i32.shr_u + end + i32.lt_s + else + get_local $6 + end + i32.eqz + br_if $break|1 + nop + get_local $5 + i32.const 1 + i32.add + set_local $5 + br $repeat|1 + unreachable + end + unreachable + end + get_local $5 + block $~lib/internal/typedarray/TypedArray#get:length|inlined.14 (result i32) + get_local $1 + i32.load offset=8 + i32.const 0 + i32.shr_u + end + i32.const 1 + i32.sub + i32.lt_s + i32.eqz + if + i32.const 544 + i32.const 360 + i32.const 63 + i32.const 12 + call $~lib/env/abort + unreachable + end + get_local $1 + get_local $0 + i32.load offset=4 + get_local $5 + call $~lib/typedarray/Uint8Array#subarray + call $bson/decoder/bin2str + set_local $6 + get_local $0 + get_local $5 + i32.const 1 + i32.add + tee_local $5 + i32.store offset=4 + block $break|2 + block $case7|2 + block $case6|2 + block $case5|2 + block $case4|2 + block $case3|2 + block $case2|2 + block $case1|2 + block $case0|2 + get_local $4 + i32.const 255 + i32.and + set_local $7 + get_local $7 + i32.const 2 + i32.eq + br_if $case0|2 + get_local $7 + i32.const 3 + i32.eq + br_if $case1|2 + get_local $7 + i32.const 4 + i32.eq + br_if $case2|2 + get_local $7 + i32.const 5 + i32.eq + br_if $case3|2 + get_local $7 + i32.const 8 + i32.eq + br_if $case4|2 + get_local $7 + i32.const 10 + i32.eq + br_if $case5|2 + get_local $7 + i32.const 16 + i32.eq + br_if $case6|2 + br $case7|2 + end + get_local $1 + block (result i32) + get_local $0 + get_local $0 + i32.load offset=4 + tee_local $7 + i32.const 1 + i32.add + i32.store offset=4 + get_local $7 + end + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + get_local $1 + block (result i32) + get_local $0 + get_local $0 + i32.load offset=4 + tee_local $7 + i32.const 1 + i32.add + i32.store offset=4 + get_local $7 + end + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + i32.const 8 + i32.shl + i32.or + get_local $1 + block (result i32) + get_local $0 + get_local $0 + i32.load offset=4 + tee_local $7 + i32.const 1 + i32.add + i32.store offset=4 + get_local $7 + end + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + i32.const 16 + i32.shl + i32.or + get_local $1 + block (result i32) + get_local $0 + get_local $0 + i32.load offset=4 + tee_local $7 + i32.const 1 + i32.add + i32.store offset=4 + get_local $7 + end + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + i32.const 24 + i32.shl + i32.or + set_local $3 + get_local $0 + i32.load + get_local $6 + get_local $1 + get_local $0 + i32.load offset=4 + block (result i32) + get_local $0 + i32.load offset=4 + get_local $3 + i32.const 1 + i32.sub + i32.add + set_local $7 + get_local $0 + get_local $7 + i32.store offset=4 + get_local $7 + end + call $~lib/typedarray/Uint8Array#subarray + call $bson/decoder/bin2str + call $main_near/__near_BSONHandler_FooBar#setString + get_local $0 + get_local $0 + i32.load offset=4 + i32.const 1 + i32.add + i32.store offset=4 + br $break|2 + end + get_local $1 + get_local $0 + i32.load offset=4 + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + get_local $1 + get_local $0 + i32.load offset=4 + i32.const 1 + i32.add + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + i32.const 8 + i32.shl + i32.or + get_local $1 + get_local $0 + i32.load offset=4 + i32.const 2 + i32.add + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + i32.const 16 + i32.shl + i32.or + get_local $1 + get_local $0 + i32.load offset=4 + i32.const 3 + i32.add + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + i32.const 24 + i32.shl + i32.or + set_local $3 + get_local $0 + i32.load + get_local $6 + call $main_near/__near_BSONHandler_FooBar#pushObject + if + get_local $0 + get_local $1 + get_local $0 + i32.load offset=4 + call $bson/decoder/BSONDecoder<__near_BSONHandler_FooBar>#deserialize + else + get_local $0 + get_local $0 + i32.load offset=4 + get_local $3 + i32.add + i32.store offset=4 + end + get_local $0 + i32.load + call $main_near/__near_BSONHandler_FooBar#popObject + br $break|2 + end + get_local $1 + get_local $0 + i32.load offset=4 + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + get_local $1 + get_local $0 + i32.load offset=4 + i32.const 1 + i32.add + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + i32.const 8 + i32.shl + i32.or + get_local $1 + get_local $0 + i32.load offset=4 + i32.const 2 + i32.add + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + i32.const 16 + i32.shl + i32.or + get_local $1 + get_local $0 + i32.load offset=4 + i32.const 3 + i32.add + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + i32.const 24 + i32.shl + i32.or + set_local $3 + get_local $0 + i32.load + get_local $6 + call $main_near/__near_BSONHandler_FooBar#pushArray + if + get_local $0 + get_local $1 + get_local $0 + i32.load offset=4 + call $bson/decoder/BSONDecoder<__near_BSONHandler_FooBar>#deserialize + else + get_local $0 + get_local $0 + i32.load offset=4 + get_local $3 + i32.add + i32.store offset=4 + end + get_local $0 + i32.load + call $main_near/__near_BSONHandler_FooBar#popArray + br $break|2 + end + get_local $1 + block (result i32) + get_local $0 + get_local $0 + i32.load offset=4 + tee_local $7 + i32.const 1 + i32.add + i32.store offset=4 + get_local $7 + end + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + get_local $1 + block (result i32) + get_local $0 + get_local $0 + i32.load offset=4 + tee_local $7 + i32.const 1 + i32.add + i32.store offset=4 + get_local $7 + end + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + i32.const 8 + i32.shl + i32.or + get_local $1 + block (result i32) + get_local $0 + get_local $0 + i32.load offset=4 + tee_local $7 + i32.const 1 + i32.add + i32.store offset=4 + get_local $7 + end + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + i32.const 16 + i32.shl + i32.or + get_local $1 + block (result i32) + get_local $0 + get_local $0 + i32.load offset=4 + tee_local $7 + i32.const 1 + i32.add + i32.store offset=4 + get_local $7 + end + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + i32.const 24 + i32.shl + i32.or + set_local $3 + get_local $1 + block (result i32) + get_local $0 + get_local $0 + i32.load offset=4 + tee_local $7 + i32.const 1 + i32.add + i32.store offset=4 + get_local $7 + end + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + i32.const 4 + i32.eq + if + return + end + get_local $0 + i32.load + get_local $6 + get_local $1 + get_local $0 + i32.load offset=4 + block (result i32) + get_local $0 + i32.load offset=4 + get_local $3 + i32.add + set_local $7 + get_local $0 + get_local $7 + i32.store offset=4 + get_local $7 + end + call $~lib/typedarray/Uint8Array#subarray + call $main_near/__near_BSONHandler_FooBar#setUint8Array + br $break|2 + end + get_local $0 + i32.load + get_local $6 + get_local $1 + block (result i32) + get_local $0 + get_local $0 + i32.load offset=4 + tee_local $7 + i32.const 1 + i32.add + i32.store offset=4 + get_local $7 + end + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + i32.const 1 + i32.eq + call $main_near/__near_BSONHandler_FooBar#setBoolean + br $break|2 + end + get_local $0 + i32.load + get_local $6 + call $main_near/__near_BSONHandler_FooBar#setNull + br $break|2 + end + get_local $0 + i32.load + get_local $6 + get_local $1 + block (result i32) + get_local $0 + get_local $0 + i32.load offset=4 + tee_local $7 + i32.const 1 + i32.add + i32.store offset=4 + get_local $7 + end + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + get_local $1 + block (result i32) + get_local $0 + get_local $0 + i32.load offset=4 + tee_local $7 + i32.const 1 + i32.add + i32.store offset=4 + get_local $7 + end + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + i32.const 8 + i32.shl + i32.or + get_local $1 + block (result i32) + get_local $0 + get_local $0 + i32.load offset=4 + tee_local $7 + i32.const 1 + i32.add + i32.store offset=4 + get_local $7 + end + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + i32.const 16 + i32.shl + i32.or + get_local $1 + block (result i32) + get_local $0 + get_local $0 + i32.load offset=4 + tee_local $7 + i32.const 1 + i32.add + i32.store offset=4 + get_local $7 + end + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + i32.const 24 + i32.shl + i32.or + call $main_near/__near_BSONHandler_FooBar#setInteger + br $break|2 + end + i32.const 0 + i32.eqz + if + i32.const 696 + i32.const 360 + i32.const 116 + i32.const 20 + call $~lib/env/abort + unreachable + end + end + end + br $repeat|0 + unreachable + end + unreachable + end + ) + (func $main_near/__near_decode_FooBar (; 46 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + block (result i32) + i32.const 12 + call $~lib/memory/memory.allocate + set_local $2 + get_local $2 + i32.const 0 + i32.store + get_local $2 + i32.const 0 + i32.store offset=4 + get_local $2 + block (result i32) + i32.const 20 + call $~lib/memory/memory.allocate + set_local $3 + get_local $3 + i32.const 0 + i32.store + get_local $3 + i32.const 1 + i32.store offset=4 + get_local $3 + i32.const 0 + i32.store8 offset=8 + get_local $3 + i32.const 8 + i32.store offset=12 + get_local $3 + i32.const 0 + i32.store offset=16 + get_local $3 + end + i32.store offset=8 + get_local $2 + end + set_local $2 + get_local $2 + get_local $0 + i32.store + get_local $2 + i32.const 0 + get_local $2 + call $bson/decoder/BSONDecoder<__near_BSONHandler_FooBar>#constructor + i32.store offset=4 + get_local $2 + i32.load offset=4 + get_local $0 + get_local $1 + call $bson/decoder/BSONDecoder<__near_BSONHandler_FooBar>#deserialize + get_local $2 + i32.load offset=8 + ) + (func $~lib/string/String#charAt (; 47 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + get_local $0 + i32.const 0 + i32.ne + i32.eqz + if + i32.const 0 + i32.const 200 + i32.const 58 + i32.const 4 + call $~lib/env/abort + unreachable + end + get_local $1 + get_local $0 + i32.load + i32.ge_u + if + i32.const 616 + return + end + i32.const 1 + call $~lib/internal/string/allocateUnsafe + set_local $2 + get_local $2 + get_local $0 + get_local $1 + i32.const 1 + i32.shl + i32.add + i32.load16_u offset=4 + i32.store16 offset=4 + get_local $2 + ) + (func $test/bin2hex (; 48 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + get_local $1 + i32.const 0 + i32.ne + if (result i32) + i32.const 800 + else + i32.const 840 + end + set_local $2 + i32.const 616 + set_local $3 + block $break|0 + block + i32.const 0 + set_local $4 + block $~lib/internal/typedarray/TypedArray#get:length|inlined.16 (result i32) + get_local $0 + i32.load offset=8 + i32.const 0 + i32.shr_u + end + set_local $5 + end + loop $repeat|0 + get_local $4 + get_local $5 + i32.lt_s + i32.eqz + br_if $break|0 + get_local $3 + get_local $2 + get_local $0 + get_local $4 + call $~lib/internal/typedarray/TypedArray#__get + i32.const 255 + i32.and + i32.const 4 + i32.shr_u + i32.const 15 + i32.and + call $~lib/string/String#charAt + get_local $2 + get_local $0 + get_local $4 + call $~lib/internal/typedarray/TypedArray#__get + i32.const 15 + i32.and + call $~lib/string/String#charAt + call $~lib/string/String.__concat + call $~lib/string/String.__concat + set_local $3 + get_local $4 + i32.const 1 + i32.add + set_local $4 + br $repeat|0 + unreachable + end + unreachable + end + get_local $3 + ) + (func $test/runTest (; 49 ;) (type $v) + (local $0 i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + block (result i32) + i32.const 20 + call $~lib/memory/memory.allocate + set_local $0 + get_local $0 + i32.const 0 + i32.store + get_local $0 + i32.const 1 + i32.store offset=4 + get_local $0 + i32.const 0 + i32.store8 offset=8 + get_local $0 + i32.const 8 + i32.store offset=12 + get_local $0 + i32.const 0 + i32.store offset=16 + get_local $0 + end + set_local $0 + get_local $0 + i32.const 321 + i32.store + get_local $0 + i32.const 123 + i32.store offset=4 + get_local $0 + i32.const 1 + i32.store8 offset=8 + get_local $0 + i32.const 24 + i32.store offset=12 + block (result i32) + i32.const 12 + call $~lib/memory/memory.allocate + set_local $1 + get_local $1 + i32.const 0 + i32.const 0 + call $~lib/array/Array#constructor + i32.store + get_local $1 + i32.const 0 + get_global $bson/encoder/START_SIZE + call $~lib/internal/typedarray/TypedArray#constructor + i32.store offset=4 + get_local $1 + i32.const 4 + i32.store offset=8 + get_local $1 + end + set_local $1 + get_local $0 + get_local $1 + call $main_near/__near_encode_FooBar + get_local $1 + call $bson/encoder/BSONEncoder#serialize + set_local $2 + get_local $2 + i32.const 0 + call $main_near/__near_decode_FooBar + set_local $3 + get_local $0 + i32.load + get_local $3 + i32.load + i32.eq + i32.eqz + if + i32.const 0 + i32.const 760 + i32.const 20 + i32.const 2 + call $~lib/env/abort + unreachable + end + get_local $0 + i32.load offset=4 + get_local $3 + i32.load offset=4 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 760 + i32.const 21 + i32.const 2 + call $~lib/env/abort + unreachable + end + block (result i32) + i32.const 12 + call $~lib/memory/memory.allocate + set_local $4 + get_local $4 + i32.const 0 + i32.const 0 + call $~lib/array/Array#constructor + i32.store + get_local $4 + i32.const 0 + get_global $bson/encoder/START_SIZE + call $~lib/internal/typedarray/TypedArray#constructor + i32.store offset=4 + get_local $4 + i32.const 4 + i32.store offset=8 + get_local $4 + end + set_local $4 + get_local $4 + i32.const 784 + i32.const 1 + call $bson/encoder/BSONEncoder#setInteger + get_local $4 + i32.const 792 + i32.const 2 + call $bson/encoder/BSONEncoder#setInteger + get_local $4 + call $bson/encoder/BSONEncoder#serialize + i32.const 0 + call $test/bin2hex + set_local $5 + block (result i32) + i32.const 12 + call $~lib/memory/memory.allocate + set_local $6 + get_local $6 + i32.const 0 + i32.const 0 + call $~lib/array/Array#constructor + i32.store + get_local $6 + i32.const 0 + get_global $bson/encoder/START_SIZE + call $~lib/internal/typedarray/TypedArray#constructor + i32.store offset=4 + get_local $6 + i32.const 4 + i32.store offset=8 + get_local $6 + end + set_local $6 + get_local $6 + i32.const 880 + i32.const 3 + call $bson/encoder/BSONEncoder#setInteger + ) + (func $start (; 50 ;) (type $v) + get_global $HEAP_BASE + get_global $~lib/internal/allocator/AL_MASK + i32.add + get_global $~lib/internal/allocator/AL_MASK + i32.const -1 + i32.xor + i32.and + set_global $~lib/allocator/arena/startOffset + get_global $~lib/allocator/arena/startOffset + set_global $~lib/allocator/arena/offset + call $test/runTest + ) + (func $null (; 51 ;) (type $v) + ) +)