1pub extern "wasm" fn extend16(value : 
Int
Int
) ->
Int
Int
=
2 #|(func (param i32) (result i32) local.get 0 i32.extend16_s) 3 4pub extern "wasm" fn extend8(value :
Int
Int
) ->
Int
Int
=
5 #|(func (param i32) (result i32) local.get 0 i32.extend8_s) 6 7pub extern "wasm" fn store8(offset :
Int
Int
, value :
Int
Int
) =
8 #|(func (param i32) (param i32) local.get 0 local.get 1 i32.store8) 9 10pub extern "wasm" fn load8_u(offset :
Int
Int
) ->
Int
Int
=
11 #|(func (param i32) (result i32) local.get 0 i32.load8_u) 12 13pub extern "wasm" fn load8(offset :
Int
Int
) ->
Int
Int
=
14 #|(func (param i32) (result i32) local.get 0 i32.load8_s) 15 16pub extern "wasm" fn store16(offset :
Int
Int
, value :
Int
Int
) =
17 #|(func (param i32) (param i32) local.get 0 local.get 1 i32.store16) 18 19pub extern "wasm" fn load16(offset :
Int
Int
) ->
Int
Int
=
20 #|(func (param i32) (result i32) local.get 0 i32.load16_s) 21 22pub extern "wasm" fn load16_u(offset :
Int
Int
) ->
Int
Int
=
23 #|(func (param i32) (result i32) local.get 0 i32.load16_u) 24 25pub extern "wasm" fn store32(offset :
Int
Int
, value :
Int
Int
) =
26 #|(func (param i32) (param i32) local.get 0 local.get 1 i32.store) 27 28pub extern "wasm" fn load32(offset :
Int
Int
) ->
Int
Int
=
29 #|(func (param i32) (result i32) local.get 0 i32.load) 30 31pub extern "wasm" fn store64(offset :
Int
Int
, value :
Int64
Int64
) =
32 #|(func (param i32) (param i64) local.get 0 local.get 1 i64.store) 33 34pub extern "wasm" fn load64(offset :
Int
Int
) ->
Int64
Int64
=
35 #|(func (param i32) (result i64) local.get 0 i64.load) 36 37pub extern "wasm" fn storef32(offset :
Int
Int
, value :
Float
Float
) =
38 #|(func (param i32) (param f32) local.get 0 local.get 1 f32.store) 39 40pub extern "wasm" fn loadf32(offset :
Int
Int
) ->
Float
Float
=
41 #|(func (param i32) (result f32) local.get 0 f32.load) 42 43pub extern "wasm" fn storef64(offset :
Int
Int
, value :
Double
Double
) =
44 #|(func (param i32) (param f64) local.get 0 local.get 1 f64.store) 45 46pub extern "wasm" fn loadf64(offset :
Int
Int
) ->
Double
Double
=
47 #|(func (param i32) (result f64) local.get 0 f64.load) 48 49pub extern "wasm" fn f32_to_i32(value :
Float
Float
) ->
Int
Int
=
50 #|(func (param f32) (result i32) local.get 0 f32.convert_i32_s) 51 52pub extern "wasm" fn f32_to_i64(value :
Float
Float
) ->
Int64
Int64
=
53 #|(func (param f32) (result i64) local.get 0 f32.convert_i64_s) 54 55// set pseudo header; allocate extra bytes for string 56pub extern "wasm" fn malloc(size :
Int
Int
) ->
Int
Int
=
57 #|(func (param i32) (result i32) (local i32) 58 #| local.get 0 i32.const 4 i32.add call $moonbit.gc.malloc 59 #| local.tee 1 i32.const 0 call $moonbit.init_array8 60 #| local.get 1 i32.const 8 i32.add) 61 62pub extern "wasm" fn free(position :
Int
Int
) =
63 #|(func (param i32) local.get 0 i32.const 8 i32.sub call $moonbit.decref) 64 65extern "wasm" fn copy(dest :
Int
Int
, src :
Int
Int
, len :
Int
Int
) =
66 #|(func (param i32) (param i32) (param i32) local.get 0 local.get 1 local.get 2 memory.copy) 67 68pub extern "wasm" fn str2ptr(str :
String
String
) ->
Int
Int
=
69 #|(func (param i32) (result i32) local.get 0 i32.const 8 i32.add) 70 71pub extern "wasm" fn ptr2str(ptr :
Int
Int
, len :
Int
Int
) ->
String
String
=
72 #|(func (param i32) (param i32) (result i32) (local i32) 73 #| local.get 0 i32.const 8 i32.sub local.tee 2 74 #| local.get 1 call $moonbit.init_array16 75 #| local.get 2) 76 77pub extern "wasm" fn bytes2ptr(bytes :
type FixedArray[A]
FixedArray
[
Byte
Byte
]) ->
Int
Int
=
78 #|(func (param i32) (result i32) local.get 0 i32.const 8 i32.add) 79 80pub extern "wasm" fn ptr2bytes(ptr :
Int
Int
, len :
Int
Int
) ->
type FixedArray[A]
FixedArray
[
Byte
Byte
] =
81 #|(func (param i32) (param i32) (result i32) (local i32) 82 #| local.get 0 i32.const 8 i32.sub local.tee 2 83 #| local.get 1 call $moonbit.init_array8 84 #| local.get 2) 85 86pub extern "wasm" fn uint_array2ptr(array :
type FixedArray[A]
FixedArray
[
UInt
UInt
]) ->
Int
Int
=
87 #|(func (param i32) (result i32) local.get 0 i32.const 8 i32.add) 88 89pub extern "wasm" fn uint64_array2ptr(array :
type FixedArray[A]
FixedArray
[
UInt64
UInt64
]) ->
Int
Int
=
90 #|(func (param i32) (result i32) local.get 0 i32.const 8 i32.add) 91 92pub extern "wasm" fn int_array2ptr(array :
type FixedArray[A]
FixedArray
[
Int
Int
]) ->
Int
Int
=
93 #|(func (param i32) (result i32) local.get 0 i32.const 8 i32.add) 94 95pub extern "wasm" fn int64_array2ptr(array :
type FixedArray[A]
FixedArray
[
Int64
Int64
]) ->
Int
Int
=
96 #|(func (param i32) (result i32) local.get 0 i32.const 8 i32.add) 97 98pub extern "wasm" fn float_array2ptr(array :
type FixedArray[A]
FixedArray
[
Float
Float
]) ->
Int
Int
=
99 #|(func (param i32) (result i32) local.get 0 i32.const 8 i32.add) 100 101pub extern "wasm" fn double_array2ptr(array :
type FixedArray[A]
FixedArray
[
Double
Double
]) ->
Int
Int
=
102 #|(func (param i32) (result i32) local.get 0 i32.const 8 i32.add) 103 104pub extern "wasm" fn ptr2uint_array(ptr :
Int
Int
, len :
Int
Int
) ->
type FixedArray[A]
FixedArray
[
UInt
UInt
] =
105 #|(func (param i32) (param i32) (result i32) (local i32) 106 #| local.get 0 i32.const 8 i32.sub local.tee 2 107 #| local.get 1 call $moonbit.init_array32 108 #| local.get 2) 109 110pub extern "wasm" fn ptr2int_array(ptr :
Int
Int
, len :
Int
Int
) ->
type FixedArray[A]
FixedArray
[
Int
Int
] =
111 #|(func (param i32) (param i32) (result i32) (local i32) 112 #| local.get 0 i32.const 8 i32.sub local.tee 2 113 #| local.get 1 call $moonbit.init_array32 114 #| local.get 2) 115 116pub extern "wasm" fn ptr2float_array(ptr :
Int
Int
, len :
Int
Int
) ->
type FixedArray[A]
FixedArray
[
Float
Float
] =
117 #|(func (param i32) (param i32) (result i32) (local i32) 118 #| local.get 0 i32.const 8 i32.sub local.tee 2 119 #| local.get 1 call $moonbit.init_array32 120 #| local.get 2) 121 122pub extern "wasm" fn ptr2uint64_array(ptr :
Int
Int
, len :
Int
Int
) ->
type FixedArray[A]
FixedArray
[
UInt64
UInt64
] =
123 #|(func (param i32) (param i32) (result i32) (local i32) 124 #| local.get 0 i32.const 8 i32.sub local.tee 2 125 #| local.get 1 call $moonbit.init_array64 126 #| local.get 2) 127 128pub extern "wasm" fn ptr2int64_array(ptr :
Int
Int
, len :
Int
Int
) ->
type FixedArray[A]
FixedArray
[
Int64
Int64
] =
129 #|(func (param i32) (param i32) (result i32) (local i32) 130 #| local.get 0 i32.const 8 i32.sub local.tee 2 131 #| local.get 1 call $moonbit.init_array64 132 #| local.get 2) 133 134pub extern "wasm" fn ptr2double_array(ptr :
Int
Int
, len :
Int
Int
) ->
type FixedArray[A]
FixedArray
[
Double
Double
] =
135 #|(func (param i32) (param i32) (result i32) (local i32) 136 #| local.get 0 i32.const 8 i32.sub local.tee 2 137 #| local.get 1 call $moonbit.init_array64 138 #| local.get 2) 139 140pub fn
(src_offset : Int, src_size : Int, _dst_alignment : Int, dst_size : Int) -> Int
cabi_realloc
(
141
Int
src_offset
:
Int
Int
,
142
Int
src_size
:
Int
Int
,
143
Int
_dst_alignment
:
Int
Int
,
144
Int
dst_size
:
Int
Int
145) ->
Int
Int
{{
146 // malloc 147 if
Int
src_offset
(self : Int, other : Int) -> Bool

Compares two integers for equality.

Parameters:

  • self : The first integer to compare.
  • other : The second integer to compare.

Returns true if both integers have the same value, false otherwise.

Example:

test "Int::op_equal" {
  inspect(42 == 42, content="true")
  inspect(42 == -42, content="false")
}
==
0
(Bool, Bool) -> Bool
&&
Int
src_size
(self : Int, other : Int) -> Bool

Compares two integers for equality.

Parameters:

  • self : The first integer to compare.
  • other : The second integer to compare.

Returns true if both integers have the same value, false otherwise.

Example:

test "Int::op_equal" {
  inspect(42 == 42, content="true")
  inspect(42 == -42, content="false")
}
==
0 {{
148 return
(size : Int) -> Int
malloc
(
Int
dst_size
)
149 }} 150 // free 151 if
Int
dst_size
(self : Int, other : Int) -> Bool

Compares two integers for equality.

Parameters:

  • self : The first integer to compare.
  • other : The second integer to compare.

Returns true if both integers have the same value, false otherwise.

Example:

test "Int::op_equal" {
  inspect(42 == 42, content="true")
  inspect(42 == -42, content="false")
}
==
0 {{
152
(position : Int) -> Unit
free
(
Int
src_offset
)
153 return 0 154 }} 155 // realloc 156 let
Int
dst
=
(size : Int) -> Int
malloc
(
Int
dst_size
)
157
(dest : Int, src : Int, len : Int) -> Unit
copy
(
Int
dst
,
Int
src_offset
, if
Int
src_size
(self_ : Int, other : Int) -> Bool
<
Int
dst_size
{
Int
src_size
} else {
Int
dst_size
})
158
(position : Int) -> Unit
free
(
Int
src_offset
)
159
Int
dst
160}} 161 162pub(open) trait
trait Any {
}
Any
{}
163pub(all) struct Cleanup { 164
Int
address
:
Int
Int
165
Int
size
:
Int
Int
166
Int
align
:
Int
Int
167}