@salang/sa 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/sa.js +13 -1
- package/package.json +8 -7
- package/sa_std/alloc/layout.sal +12 -0
- package/sa_std/alloc/prelude.sa +1 -0
- package/sa_std/alloc/prelude.sal +1 -0
- package/sa_std/alloc/string.sa +3 -0
- package/sa_std/alloc/vec.sa +684 -0
- package/sa_std/alloc/vec.sal +4 -0
- package/sa_std/any.sa +130 -0
- package/sa_std/any.sal +23 -0
- package/sa_std/array.sa +1876 -0
- package/sa_std/ascii.sa +2 -0
- package/sa_std/ascii.sal +1 -0
- package/sa_std/async.sla +116 -0
- package/sa_std/binary_heap.sa +3003 -0
- package/sa_std/binary_heap.sal +7 -0
- package/sa_std/borrow.sa +171 -0
- package/sa_std/borrow.sal +13 -0
- package/sa_std/btree_map.sa +2210 -0
- package/sa_std/btree_map.sal +11 -0
- package/sa_std/btree_set.sa +1072 -0
- package/sa_std/btree_set.sal +6 -0
- package/sa_std/char.sa +1309 -0
- package/sa_std/char.sal +50 -0
- package/sa_std/cmp.sa +554 -0
- package/sa_std/cmp.sal +14 -0
- package/sa_std/collections/binary_heap.sa +1 -0
- package/sa_std/collections/btree_map.sa +1 -0
- package/sa_std/collections/btree_set.sa +1 -0
- package/sa_std/collections/hashmap.sa +1 -0
- package/sa_std/collections/hashset.sa +1 -0
- package/sa_std/collections/linked_list.sa +1120 -0
- package/sa_std/collections/linked_list.sal +10 -0
- package/sa_std/collections/prelude.sa +7 -0
- package/sa_std/collections/prelude.sal +1 -0
- package/sa_std/collections/vec_deque.sa +1 -0
- package/sa_std/collections.sal +13 -0
- package/sa_std/convert.sa +1115 -0
- package/sa_std/convert.sal +24 -0
- package/sa_std/core/arc.sa +233 -0
- package/sa_std/core/arc.sal +4 -0
- package/sa_std/core/ascii.sa +784 -0
- package/sa_std/core/ascii.sal +34 -0
- package/sa_std/core/bit.sa +41 -0
- package/sa_std/core/box.sa +1 -0
- package/sa_std/core/box.sal +2 -0
- package/sa_std/core/cell.sa +108 -0
- package/sa_std/core/cell.sal +5 -0
- package/sa_std/core/cleanup.sa +26 -0
- package/sa_std/core/control.sa +20 -0
- package/sa_std/core/derive.sa +60 -0
- package/sa_std/core/derive.sal +1 -0
- package/sa_std/core/dispatch.sa +7 -0
- package/sa_std/core/dispatch.sal +5 -0
- package/sa_std/core/future.sa +777 -0
- package/sa_std/core/future.sal +73 -0
- package/sa_std/core/hash.sa +48 -0
- package/sa_std/core/iter.sa +2805 -0
- package/sa_std/core/iter.sal +4 -0
- package/sa_std/core/loop.sa +60 -0
- package/sa_std/core/mem.sa +220 -0
- package/sa_std/core/option.sa +825 -0
- package/sa_std/core/option.sal +11 -0
- package/sa_std/core/panic.sa +23 -0
- package/sa_std/core/panic.sal +12 -0
- package/sa_std/core/prelude.sa +18 -0
- package/sa_std/core/prelude.sal +18 -0
- package/sa_std/core/rc.sa +225 -0
- package/sa_std/core/rc.sal +4 -0
- package/sa_std/core/refcell.sa +283 -0
- package/sa_std/core/refcell.sal +13 -0
- package/sa_std/core/result.sa +708 -0
- package/sa_std/core/result.sal +6 -0
- package/sa_std/core/rust_patterns.sal +295 -0
- package/sa_std/core/sa_core.sa +84 -0
- package/sa_std/core/slice.sa +4021 -0
- package/sa_std/core/slice.sal +7 -0
- package/sa_std/core/task.sa +112 -0
- package/sa_std/core/task.sal +15 -0
- package/sa_std/core/trait_object.sa +26 -0
- package/sa_std/core/trait_object.sal +4 -0
- package/sa_std/core/waker.sa +289 -0
- package/sa_std/core/waker.sal +31 -0
- package/sa_std/core/weak.sa +2 -0
- package/sa_std/core/weak.sal +4 -0
- package/sa_std/cow.sa +3 -0
- package/sa_std/cow.sal +2 -0
- package/sa_std/cstring.sa +3 -0
- package/sa_std/cstring.sal +2 -0
- package/sa_std/default.sa +99 -0
- package/sa_std/duration.sa +3 -0
- package/sa_std/duration.sal +2 -0
- package/sa_std/encoding/json.sa +259 -0
- package/sa_std/encoding/json.sai +54 -0
- package/sa_std/encoding/json.sal +35 -0
- package/sa_std/encoding/prelude.sa +1 -0
- package/sa_std/encoding/prelude.sal +0 -0
- package/sa_std/env.sa +390 -0
- package/sa_std/env.sai +25 -0
- package/sa_std/error.sa +253 -0
- package/sa_std/error.sal +44 -0
- package/sa_std/ffi/cstring.sa +3 -0
- package/sa_std/ffi/cstring.sal +1 -0
- package/sa_std/ffi/prelude.sa +2 -0
- package/sa_std/ffi/prelude.sal +2 -0
- package/sa_std/ffi.sa +635 -0
- package/sa_std/ffi.sal +51 -0
- package/sa_std/fmt.sa +2 -0
- package/sa_std/fmt.sai +18 -0
- package/sa_std/fmt.sal +35 -0
- package/sa_std/fs.sa +1023 -0
- package/sa_std/fs.sai +127 -0
- package/sa_std/fs.sal +51 -0
- package/sa_std/future.sa +2 -0
- package/sa_std/future.sal +1 -0
- package/sa_std/hash.sa +1486 -0
- package/sa_std/hash.sal +13 -0
- package/sa_std/hashmap.sa +1962 -0
- package/sa_std/hashmap.sal +20 -0
- package/sa_std/hashset.sa +1004 -0
- package/sa_std/hashset.sal +18 -0
- package/sa_std/http2.sa +78 -0
- package/sa_std/http2.sai +26 -0
- package/sa_std/http2.sal +36 -0
- package/sa_std/instant.sa +3 -0
- package/sa_std/instant.sal +2 -0
- package/sa_std/io/buf_reader.sa +43 -0
- package/sa_std/io/buf_writer.sa +35 -0
- package/sa_std/io/bufio.sa +4 -0
- package/sa_std/io/bufio.sal +4 -0
- package/sa_std/io/prelude.sa +1 -0
- package/sa_std/io/prelude.sal +1 -0
- package/sa_std/io/print.sa +2 -0
- package/sa_std/io/print.sai +3 -0
- package/sa_std/io.sa +925 -0
- package/sa_std/io.sai +25 -0
- package/sa_std/io.sal +84 -0
- package/sa_std/iter.sa +2 -0
- package/sa_std/iter.sal +1 -0
- package/sa_std/join_handle.sa +3 -0
- package/sa_std/join_handle.sal +2 -0
- package/sa_std/libsa_async.sa +80 -0
- package/sa_std/m_async.sa +137 -0
- package/sa_std/m_async.sal +30 -0
- package/sa_std/m_async.sla +2 -0
- package/sa_std/manually_drop.sa +3 -0
- package/sa_std/manually_drop.sal +2 -0
- package/sa_std/marker/phantom_data.sa +3 -0
- package/sa_std/marker/phantom_data.sal +1 -0
- package/sa_std/marker/prelude.sa +4 -0
- package/sa_std/marker/prelude.sal +4 -0
- package/sa_std/marker.sa +220 -0
- package/sa_std/marker.sal +15 -0
- package/sa_std/math.sa +84 -0
- package/sa_std/math.sai +10 -0
- package/sa_std/mem/manually_drop.sa +3 -0
- package/sa_std/mem/manually_drop.sal +1 -0
- package/sa_std/mem/prelude.sa +2 -0
- package/sa_std/mem/prelude.sal +2 -0
- package/sa_std/mem.sa +564 -0
- package/sa_std/mem.sal +40 -0
- package/sa_std/modstate.sai +19 -0
- package/sa_std/net.sa +4227 -0
- package/sa_std/net.sai +239 -0
- package/sa_std/net.sal +159 -0
- package/sa_std/netx.sa +85 -0
- package/sa_std/netx.sai +11 -0
- package/sa_std/netx.sal +39 -0
- package/sa_std/nonzero.sa +3 -0
- package/sa_std/nonzero.sal +2 -0
- package/sa_std/num/nonzero.sa +3 -0
- package/sa_std/num/nonzero.sal +1 -0
- package/sa_std/num/prelude.sa +3 -0
- package/sa_std/num/prelude.sal +3 -0
- package/sa_std/num.sa +17302 -0
- package/sa_std/num.sai +11 -0
- package/sa_std/num.sal +341 -0
- package/sa_std/ops.sa +1884 -0
- package/sa_std/ops.sal +68 -0
- package/sa_std/option.sa +2 -0
- package/sa_std/option.sal +1 -0
- package/sa_std/os/fd.sa +96 -0
- package/sa_std/os/fd.sai +7 -0
- package/sa_std/os/fd.sal +11 -0
- package/sa_std/os/prelude.sa +2 -0
- package/sa_std/os/prelude.sal +1 -0
- package/sa_std/os/unix_ffi.sa +271 -0
- package/sa_std/panic.sa +1 -0
- package/sa_std/panic.sal +1 -0
- package/sa_std/path.sa +3170 -0
- package/sa_std/path.sal +12 -0
- package/sa_std/phantom_data.sa +3 -0
- package/sa_std/phantom_data.sal +2 -0
- package/sa_std/pin.sa +79 -0
- package/sa_std/pin.sal +5 -0
- package/sa_std/plugin_async.sa +90 -0
- package/sa_std/plugin_async.sal +29 -0
- package/sa_std/plugin_async.sla +4 -0
- package/sa_std/plugin_http_async.sa +46 -0
- package/sa_std/plugin_http_server.sa +61 -0
- package/sa_std/plugin_http_server.sla +2 -0
- package/sa_std/plugin_sqlite.sa +106 -0
- package/sa_std/plugin_sqlite.sla +2 -0
- package/sa_std/prelude.sa +60 -0
- package/sa_std/prelude.sal +55 -0
- package/sa_std/process.sa +916 -0
- package/sa_std/process.sai +57 -0
- package/sa_std/process.sal +27 -0
- package/sa_std/ptr.sa +503 -0
- package/sa_std/ptr.sal +2 -0
- package/sa_std/result.sa +2 -0
- package/sa_std/result.sal +1 -0
- package/sa_std/rust_core.sa +51 -0
- package/sa_std/rust_core.sal +26 -0
- package/sa_std/sa.mod +7 -0
- package/sa_std/sort.sa +156 -0
- package/sa_std/str.sla +13 -0
- package/sa_std/string.sa +12240 -0
- package/sa_std/string.sai +25 -0
- package/sa_std/string.sal +17 -0
- package/sa_std/string_format.sa +269 -0
- package/sa_std/sync/atomic.sa +1500 -0
- package/sa_std/sync/atomic.sal +45 -0
- package/sa_std/sync/barrier.sa +105 -0
- package/sa_std/sync/barrier.sal +7 -0
- package/sa_std/sync/condvar.sa +240 -0
- package/sa_std/sync/condvar.sal +4 -0
- package/sa_std/sync/mpsc.sa +758 -0
- package/sa_std/sync/mpsc.sal +42 -0
- package/sa_std/sync/mpsc_list.sa +255 -0
- package/sa_std/sync/mpsc_list.sal +3 -0
- package/sa_std/sync/mutex.sa +182 -0
- package/sa_std/sync/mutex.sal +7 -0
- package/sa_std/sync/once.sa +371 -0
- package/sa_std/sync/once.sal +31 -0
- package/sa_std/sync/poison.sa +36 -0
- package/sa_std/sync/poison.sal +11 -0
- package/sa_std/sync/prelude.sa +8 -0
- package/sa_std/sync/prelude.sal +7 -0
- package/sa_std/sync/rwlock.sa +369 -0
- package/sa_std/sync/rwlock.sal +13 -0
- package/sa_std/task.sa +2 -0
- package/sa_std/task.sal +1 -0
- package/sa_std/term.sa +2 -0
- package/sa_std/term.sai +10 -0
- package/sa_std/term.sal +33 -0
- package/sa_std/testing/assert.sai +4 -0
- package/sa_std/testing/mock_io.sa +174 -0
- package/sa_std/testing/mock_io.sal +5 -0
- package/sa_std/testing/prelude.sa +2 -0
- package/sa_std/testing/prelude.sal +1 -0
- package/sa_std/text/prelude.sa +1 -0
- package/sa_std/text/prelude.sal +1 -0
- package/sa_std/text/regex.sa +2 -0
- package/sa_std/text/regex.sai +9 -0
- package/sa_std/text/regex.sal +33 -0
- package/sa_std/thread/join_handle.sa +3 -0
- package/sa_std/thread/join_handle.sal +1 -0
- package/sa_std/thread/prelude.sa +4 -0
- package/sa_std/thread/prelude.sal +3 -0
- package/sa_std/thread.sa +160 -0
- package/sa_std/thread.sai +11 -0
- package/sa_std/thread.sal +4 -0
- package/sa_std/thread_local.sa +45 -0
- package/sa_std/thread_local.sai +9 -0
- package/sa_std/time/duration.sa +3 -0
- package/sa_std/time/duration.sal +1 -0
- package/sa_std/time/instant.sa +3 -0
- package/sa_std/time/instant.sal +1 -0
- package/sa_std/time/prelude.sa +4 -0
- package/sa_std/time/prelude.sal +4 -0
- package/sa_std/time.sa +850 -0
- package/sa_std/time.sai +37 -0
- package/sa_std/time.sal +35 -0
- package/sa_std/time.sla +67 -0
- package/sa_std/tls_client.sai +39 -0
- package/sa_std/vec.sa +5754 -0
- package/sa_std/vec.sal +1 -0
- package/sa_std/vec_deque.sa +4925 -0
- package/sa_std/vec_deque.sal +8 -0
- package/sa_std/vec_runtime_macros.sa +11 -0
- package/sa_std/ws_client.sai +57 -0
package/sa_std/error.sal
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#def ErrorRef_SIZE = 48
|
|
2
|
+
#def ErrorRef_type_lo = +0
|
|
3
|
+
#def ErrorRef_type_hi = +8
|
|
4
|
+
#def ErrorRef_code = +16
|
|
5
|
+
#def ErrorRef_msg_ptr = +24
|
|
6
|
+
#def ErrorRef_msg_len = +32
|
|
7
|
+
#def ErrorRef_source = +40
|
|
8
|
+
|
|
9
|
+
#def ERROR_TYPE_GENERIC_LO = 1000
|
|
10
|
+
#def ERROR_TYPE_IO_LO = 1001
|
|
11
|
+
#def ERROR_TYPE_PARSE_LO = 1002
|
|
12
|
+
#def ERROR_TYPE_UTF8_LO = 1003
|
|
13
|
+
#def ERROR_TYPE_FMT_LO = 1004
|
|
14
|
+
#def ERROR_TYPE_ID_HI = 0
|
|
15
|
+
|
|
16
|
+
#def ERROR_CODE_NONE = 0
|
|
17
|
+
#def ERROR_CODE_OTHER = 1
|
|
18
|
+
#def ERROR_CODE_NOT_FOUND = 2
|
|
19
|
+
#def ERROR_CODE_PERMISSION_DENIED = 3
|
|
20
|
+
#def ERROR_CODE_INVALID_INPUT = 4
|
|
21
|
+
#def ERROR_CODE_INVALID_DATA = 5
|
|
22
|
+
#def ERROR_CODE_TIMED_OUT = 6
|
|
23
|
+
#def ERROR_CODE_INTERRUPTED = 7
|
|
24
|
+
#def ERROR_CODE_UNSUPPORTED = 8
|
|
25
|
+
#def ERROR_CODE_UNEXPECTED_EOF = 9
|
|
26
|
+
#def ERROR_CODE_CONNECTION_REFUSED = 10
|
|
27
|
+
#def ERROR_CODE_CONNECTION_RESET = 11
|
|
28
|
+
#def ERROR_CODE_CONNECTION_ABORTED = 12
|
|
29
|
+
#def ERROR_CODE_NOT_CONNECTED = 13
|
|
30
|
+
#def ERROR_CODE_ADDR_IN_USE = 14
|
|
31
|
+
#def ERROR_CODE_ADDR_NOT_AVAILABLE = 15
|
|
32
|
+
#def ERROR_CODE_BROKEN_PIPE = 16
|
|
33
|
+
#def ERROR_CODE_ALREADY_EXISTS = 17
|
|
34
|
+
#def ERROR_CODE_OUT_OF_MEMORY = 18
|
|
35
|
+
#def ERROR_CODE_NETWORK_UNREACHABLE = 19
|
|
36
|
+
#def ERROR_CODE_HOST_UNREACHABLE = 20
|
|
37
|
+
#def ERROR_CODE_IS_A_DIRECTORY = 21
|
|
38
|
+
#def ERROR_CODE_DIRECTORY_NOT_EMPTY = 22
|
|
39
|
+
#def ERROR_CODE_READ_ONLY_FILESYSTEM = 23
|
|
40
|
+
#def ERROR_CODE_RESOURCE_BUSY = 24
|
|
41
|
+
#def ERROR_CODE_ARGUMENT_LIST_TOO_LONG = 25
|
|
42
|
+
#def ERROR_CODE_NAME_TOO_LONG = 26
|
|
43
|
+
#def ERROR_CODE_TOO_MANY_LINKS = 27
|
|
44
|
+
#def ERROR_CODE_STORAGE_FULL = 28
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "../ffi.sal"
|
package/sa_std/ffi.sa
ADDED
|
@@ -0,0 +1,635 @@
|
|
|
1
|
+
@import "ffi.sal"
|
|
2
|
+
@import "core/mem.sa"
|
|
3
|
+
@import "core/slice.sa"
|
|
4
|
+
@import "string.sai"
|
|
5
|
+
@import "string.sa"
|
|
6
|
+
@import "hash.sa"
|
|
7
|
+
|
|
8
|
+
[MACRO] CSTR_FROM_PARTS_UNCHECKED %cstr_reg, %ptr_reg, %len_with_nul
|
|
9
|
+
EXPAND SLICE_NEW %cstr_reg, %ptr_reg, %len_with_nul
|
|
10
|
+
[END_MACRO]
|
|
11
|
+
|
|
12
|
+
[MACRO] CSTR_FROM_PTR %cstr_reg, %ptr_reg
|
|
13
|
+
EXPAND CSTR_LEN __cstr_from_ptr_len_%cstr_reg, %ptr_reg
|
|
14
|
+
__cstr_from_ptr_len_nul_%cstr_reg = add __cstr_from_ptr_len_%cstr_reg, 1
|
|
15
|
+
EXPAND SLICE_NEW %cstr_reg, %ptr_reg, __cstr_from_ptr_len_nul_%cstr_reg
|
|
16
|
+
!__cstr_from_ptr_len_nul_%cstr_reg
|
|
17
|
+
!__cstr_from_ptr_len_%cstr_reg
|
|
18
|
+
[END_MACRO]
|
|
19
|
+
|
|
20
|
+
[MACRO] CSTR_LEN %out_len, %ptr_reg
|
|
21
|
+
__cstr_len_slot_%out_len = stack_alloc 8
|
|
22
|
+
store __cstr_len_slot_%out_len+0, 0 as u64
|
|
23
|
+
jmp L_CSTR_LEN_HEAD_%out_len
|
|
24
|
+
|
|
25
|
+
L_CSTR_LEN_HEAD_%out_len:
|
|
26
|
+
__cstr_len_i_%out_len = load __cstr_len_slot_%out_len+0 as u64
|
|
27
|
+
__cstr_len_p_%out_len = ptr_add %ptr_reg, __cstr_len_i_%out_len
|
|
28
|
+
__cstr_len_b_%out_len = load __cstr_len_p_%out_len+0 as u8
|
|
29
|
+
__cstr_len_done_%out_len = eq __cstr_len_b_%out_len, 0
|
|
30
|
+
br __cstr_len_done_%out_len -> L_CSTR_LEN_DONE_%out_len, L_CSTR_LEN_NEXT_%out_len
|
|
31
|
+
|
|
32
|
+
L_CSTR_LEN_NEXT_%out_len:
|
|
33
|
+
__cstr_len_next_%out_len = add __cstr_len_i_%out_len, 1
|
|
34
|
+
store __cstr_len_slot_%out_len+0, __cstr_len_next_%out_len as u64
|
|
35
|
+
!__cstr_len_next_%out_len
|
|
36
|
+
!__cstr_len_done_%out_len
|
|
37
|
+
!__cstr_len_b_%out_len
|
|
38
|
+
!__cstr_len_p_%out_len
|
|
39
|
+
!__cstr_len_i_%out_len
|
|
40
|
+
jmp L_CSTR_LEN_HEAD_%out_len
|
|
41
|
+
|
|
42
|
+
L_CSTR_LEN_DONE_%out_len:
|
|
43
|
+
%out_len = load __cstr_len_slot_%out_len+0 as u64
|
|
44
|
+
!__cstr_len_done_%out_len
|
|
45
|
+
!__cstr_len_b_%out_len
|
|
46
|
+
!__cstr_len_p_%out_len
|
|
47
|
+
!__cstr_len_i_%out_len
|
|
48
|
+
[END_MACRO]
|
|
49
|
+
|
|
50
|
+
[MACRO] CSTR_FROM_BYTES_WITH_NUL %out_status, %cstr_reg, %slice_reg
|
|
51
|
+
__cstr_bytes_ptr_%out_status = load %slice_reg+Slice_ptr as ptr
|
|
52
|
+
__cstr_bytes_len_%out_status = load %slice_reg+Slice_len as u64
|
|
53
|
+
__cstr_bytes_empty_%out_status = eq __cstr_bytes_len_%out_status, 0
|
|
54
|
+
br __cstr_bytes_empty_%out_status -> L_CSTR_BYTES_NOT_TERM_%out_status, L_CSTR_BYTES_SCAN_INIT_%out_status
|
|
55
|
+
|
|
56
|
+
L_CSTR_BYTES_SCAN_INIT_%out_status:
|
|
57
|
+
__cstr_bytes_idx_slot_%out_status = stack_alloc 8
|
|
58
|
+
store __cstr_bytes_idx_slot_%out_status+0, 0 as u64
|
|
59
|
+
jmp L_CSTR_BYTES_SCAN_HEAD_%out_status
|
|
60
|
+
|
|
61
|
+
L_CSTR_BYTES_SCAN_HEAD_%out_status:
|
|
62
|
+
__cstr_bytes_idx_%out_status = load __cstr_bytes_idx_slot_%out_status+0 as u64
|
|
63
|
+
__cstr_bytes_done_scan_%out_status = eq __cstr_bytes_idx_%out_status, __cstr_bytes_len_%out_status
|
|
64
|
+
br __cstr_bytes_done_scan_%out_status -> L_CSTR_BYTES_NOT_TERM_SCAN_%out_status, L_CSTR_BYTES_SCAN_BODY_%out_status
|
|
65
|
+
|
|
66
|
+
L_CSTR_BYTES_SCAN_BODY_%out_status:
|
|
67
|
+
__cstr_bytes_p_%out_status = ptr_add __cstr_bytes_ptr_%out_status, __cstr_bytes_idx_%out_status
|
|
68
|
+
__cstr_bytes_b_%out_status = load __cstr_bytes_p_%out_status+0 as u8
|
|
69
|
+
__cstr_bytes_is_nul_%out_status = eq __cstr_bytes_b_%out_status, 0
|
|
70
|
+
br __cstr_bytes_is_nul_%out_status -> L_CSTR_BYTES_FOUND_NUL_%out_status, L_CSTR_BYTES_SCAN_NEXT_%out_status
|
|
71
|
+
|
|
72
|
+
L_CSTR_BYTES_SCAN_NEXT_%out_status:
|
|
73
|
+
__cstr_bytes_next_%out_status = add __cstr_bytes_idx_%out_status, 1
|
|
74
|
+
store __cstr_bytes_idx_slot_%out_status+0, __cstr_bytes_next_%out_status as u64
|
|
75
|
+
!__cstr_bytes_next_%out_status
|
|
76
|
+
!__cstr_bytes_is_nul_%out_status
|
|
77
|
+
!__cstr_bytes_b_%out_status
|
|
78
|
+
!__cstr_bytes_p_%out_status
|
|
79
|
+
!__cstr_bytes_done_scan_%out_status
|
|
80
|
+
!__cstr_bytes_idx_%out_status
|
|
81
|
+
jmp L_CSTR_BYTES_SCAN_HEAD_%out_status
|
|
82
|
+
|
|
83
|
+
L_CSTR_BYTES_FOUND_NUL_%out_status:
|
|
84
|
+
__cstr_bytes_last_index_%out_status = sub __cstr_bytes_len_%out_status, 1
|
|
85
|
+
__cstr_bytes_at_end_%out_status = eq __cstr_bytes_idx_%out_status, __cstr_bytes_last_index_%out_status
|
|
86
|
+
br __cstr_bytes_at_end_%out_status -> L_CSTR_BYTES_OK_%out_status, L_CSTR_BYTES_INTERIOR_%out_status
|
|
87
|
+
|
|
88
|
+
L_CSTR_BYTES_OK_%out_status:
|
|
89
|
+
EXPAND SLICE_NEW %cstr_reg, __cstr_bytes_ptr_%out_status, __cstr_bytes_len_%out_status
|
|
90
|
+
%out_status = add 0, CSTR_FROM_BYTES_OK
|
|
91
|
+
!__cstr_bytes_at_end_%out_status
|
|
92
|
+
!__cstr_bytes_last_index_%out_status
|
|
93
|
+
!__cstr_bytes_is_nul_%out_status
|
|
94
|
+
!__cstr_bytes_b_%out_status
|
|
95
|
+
!__cstr_bytes_p_%out_status
|
|
96
|
+
!__cstr_bytes_done_scan_%out_status
|
|
97
|
+
!__cstr_bytes_idx_%out_status
|
|
98
|
+
!__cstr_bytes_empty_%out_status
|
|
99
|
+
!__cstr_bytes_len_%out_status
|
|
100
|
+
!__cstr_bytes_ptr_%out_status
|
|
101
|
+
jmp L_CSTR_BYTES_END_%out_status
|
|
102
|
+
|
|
103
|
+
L_CSTR_BYTES_INTERIOR_%out_status:
|
|
104
|
+
%out_status = add 0, CSTR_FROM_BYTES_INTERIOR_NUL
|
|
105
|
+
__cstr_bytes_null_%out_status = 0 as ptr
|
|
106
|
+
EXPAND SLICE_NEW %cstr_reg, __cstr_bytes_null_%out_status, 0
|
|
107
|
+
!__cstr_bytes_null_%out_status
|
|
108
|
+
!__cstr_bytes_at_end_%out_status
|
|
109
|
+
!__cstr_bytes_last_index_%out_status
|
|
110
|
+
!__cstr_bytes_is_nul_%out_status
|
|
111
|
+
!__cstr_bytes_b_%out_status
|
|
112
|
+
!__cstr_bytes_p_%out_status
|
|
113
|
+
!__cstr_bytes_done_scan_%out_status
|
|
114
|
+
!__cstr_bytes_idx_%out_status
|
|
115
|
+
!__cstr_bytes_empty_%out_status
|
|
116
|
+
!__cstr_bytes_len_%out_status
|
|
117
|
+
!__cstr_bytes_ptr_%out_status
|
|
118
|
+
jmp L_CSTR_BYTES_END_%out_status
|
|
119
|
+
|
|
120
|
+
L_CSTR_BYTES_NOT_TERM_SCAN_%out_status:
|
|
121
|
+
!__cstr_bytes_done_scan_%out_status
|
|
122
|
+
!__cstr_bytes_idx_%out_status
|
|
123
|
+
jmp L_CSTR_BYTES_NOT_TERM_%out_status
|
|
124
|
+
|
|
125
|
+
L_CSTR_BYTES_NOT_TERM_%out_status:
|
|
126
|
+
%out_status = add 0, CSTR_FROM_BYTES_NOT_NUL_TERMINATED
|
|
127
|
+
__cstr_bytes_null2_%out_status = 0 as ptr
|
|
128
|
+
EXPAND SLICE_NEW %cstr_reg, __cstr_bytes_null2_%out_status, 0
|
|
129
|
+
!__cstr_bytes_null2_%out_status
|
|
130
|
+
!__cstr_bytes_empty_%out_status
|
|
131
|
+
!__cstr_bytes_len_%out_status
|
|
132
|
+
!__cstr_bytes_ptr_%out_status
|
|
133
|
+
|
|
134
|
+
L_CSTR_BYTES_END_%out_status:
|
|
135
|
+
[END_MACRO]
|
|
136
|
+
|
|
137
|
+
[MACRO] CSTR_VALIDATE_WITH_NUL_DETAIL %out_status, %out_pos, %slice_reg
|
|
138
|
+
__cstr_detail_ptr_%out_status = load %slice_reg+Slice_ptr as ptr
|
|
139
|
+
__cstr_detail_len_%out_status = load %slice_reg+Slice_len as u64
|
|
140
|
+
__cstr_detail_empty_%out_status = eq __cstr_detail_len_%out_status, 0
|
|
141
|
+
br __cstr_detail_empty_%out_status -> L_CSTR_DETAIL_NOT_TERM_%out_status, L_CSTR_DETAIL_SCAN_INIT_%out_status
|
|
142
|
+
|
|
143
|
+
L_CSTR_DETAIL_SCAN_INIT_%out_status:
|
|
144
|
+
__cstr_detail_idx_slot_%out_status = stack_alloc 8
|
|
145
|
+
store __cstr_detail_idx_slot_%out_status+0, 0 as u64
|
|
146
|
+
jmp L_CSTR_DETAIL_SCAN_HEAD_%out_status
|
|
147
|
+
|
|
148
|
+
L_CSTR_DETAIL_SCAN_HEAD_%out_status:
|
|
149
|
+
__cstr_detail_idx_%out_status = load __cstr_detail_idx_slot_%out_status+0 as u64
|
|
150
|
+
__cstr_detail_done_scan_%out_status = eq __cstr_detail_idx_%out_status, __cstr_detail_len_%out_status
|
|
151
|
+
br __cstr_detail_done_scan_%out_status -> L_CSTR_DETAIL_NOT_TERM_SCAN_%out_status, L_CSTR_DETAIL_SCAN_BODY_%out_status
|
|
152
|
+
|
|
153
|
+
L_CSTR_DETAIL_SCAN_BODY_%out_status:
|
|
154
|
+
__cstr_detail_p_%out_status = ptr_add __cstr_detail_ptr_%out_status, __cstr_detail_idx_%out_status
|
|
155
|
+
__cstr_detail_b_%out_status = load __cstr_detail_p_%out_status+0 as u8
|
|
156
|
+
__cstr_detail_is_nul_%out_status = eq __cstr_detail_b_%out_status, 0
|
|
157
|
+
br __cstr_detail_is_nul_%out_status -> L_CSTR_DETAIL_FOUND_NUL_%out_status, L_CSTR_DETAIL_SCAN_NEXT_%out_status
|
|
158
|
+
|
|
159
|
+
L_CSTR_DETAIL_SCAN_NEXT_%out_status:
|
|
160
|
+
__cstr_detail_next_%out_status = add __cstr_detail_idx_%out_status, 1
|
|
161
|
+
store __cstr_detail_idx_slot_%out_status+0, __cstr_detail_next_%out_status as u64
|
|
162
|
+
!__cstr_detail_next_%out_status
|
|
163
|
+
!__cstr_detail_is_nul_%out_status
|
|
164
|
+
!__cstr_detail_b_%out_status
|
|
165
|
+
!__cstr_detail_p_%out_status
|
|
166
|
+
!__cstr_detail_done_scan_%out_status
|
|
167
|
+
!__cstr_detail_idx_%out_status
|
|
168
|
+
jmp L_CSTR_DETAIL_SCAN_HEAD_%out_status
|
|
169
|
+
|
|
170
|
+
L_CSTR_DETAIL_FOUND_NUL_%out_status:
|
|
171
|
+
__cstr_detail_last_index_%out_status = sub __cstr_detail_len_%out_status, 1
|
|
172
|
+
__cstr_detail_at_end_%out_status = eq __cstr_detail_idx_%out_status, __cstr_detail_last_index_%out_status
|
|
173
|
+
br __cstr_detail_at_end_%out_status -> L_CSTR_DETAIL_OK_%out_status, L_CSTR_DETAIL_INTERIOR_%out_status
|
|
174
|
+
|
|
175
|
+
L_CSTR_DETAIL_OK_%out_status:
|
|
176
|
+
%out_status = add 0, CSTR_FROM_BYTES_OK
|
|
177
|
+
%out_pos = add 0, CSTR_ERROR_POS_NONE
|
|
178
|
+
!__cstr_detail_at_end_%out_status
|
|
179
|
+
!__cstr_detail_last_index_%out_status
|
|
180
|
+
!__cstr_detail_is_nul_%out_status
|
|
181
|
+
!__cstr_detail_b_%out_status
|
|
182
|
+
!__cstr_detail_p_%out_status
|
|
183
|
+
!__cstr_detail_done_scan_%out_status
|
|
184
|
+
!__cstr_detail_idx_%out_status
|
|
185
|
+
!__cstr_detail_empty_%out_status
|
|
186
|
+
!__cstr_detail_len_%out_status
|
|
187
|
+
!__cstr_detail_ptr_%out_status
|
|
188
|
+
jmp L_CSTR_DETAIL_END_%out_status
|
|
189
|
+
|
|
190
|
+
L_CSTR_DETAIL_INTERIOR_%out_status:
|
|
191
|
+
%out_status = add 0, CSTR_FROM_BYTES_INTERIOR_NUL
|
|
192
|
+
%out_pos = add 0, __cstr_detail_idx_%out_status
|
|
193
|
+
!__cstr_detail_at_end_%out_status
|
|
194
|
+
!__cstr_detail_last_index_%out_status
|
|
195
|
+
!__cstr_detail_is_nul_%out_status
|
|
196
|
+
!__cstr_detail_b_%out_status
|
|
197
|
+
!__cstr_detail_p_%out_status
|
|
198
|
+
!__cstr_detail_done_scan_%out_status
|
|
199
|
+
!__cstr_detail_idx_%out_status
|
|
200
|
+
!__cstr_detail_empty_%out_status
|
|
201
|
+
!__cstr_detail_len_%out_status
|
|
202
|
+
!__cstr_detail_ptr_%out_status
|
|
203
|
+
jmp L_CSTR_DETAIL_END_%out_status
|
|
204
|
+
|
|
205
|
+
L_CSTR_DETAIL_NOT_TERM_SCAN_%out_status:
|
|
206
|
+
!__cstr_detail_done_scan_%out_status
|
|
207
|
+
!__cstr_detail_idx_%out_status
|
|
208
|
+
jmp L_CSTR_DETAIL_NOT_TERM_%out_status
|
|
209
|
+
|
|
210
|
+
L_CSTR_DETAIL_NOT_TERM_%out_status:
|
|
211
|
+
%out_status = add 0, CSTR_FROM_BYTES_NOT_NUL_TERMINATED
|
|
212
|
+
%out_pos = add 0, __cstr_detail_len_%out_status
|
|
213
|
+
!__cstr_detail_empty_%out_status
|
|
214
|
+
!__cstr_detail_len_%out_status
|
|
215
|
+
!__cstr_detail_ptr_%out_status
|
|
216
|
+
|
|
217
|
+
L_CSTR_DETAIL_END_%out_status:
|
|
218
|
+
[END_MACRO]
|
|
219
|
+
|
|
220
|
+
[MACRO] CSTR_FROM_BYTES_UNTIL_NUL %out_ok, %cstr_reg, %slice_reg
|
|
221
|
+
__cstr_until_ptr_%out_ok = load %slice_reg+Slice_ptr as ptr
|
|
222
|
+
__cstr_until_len_%out_ok = load %slice_reg+Slice_len as u64
|
|
223
|
+
__cstr_until_idx_slot_%out_ok = stack_alloc 8
|
|
224
|
+
store __cstr_until_idx_slot_%out_ok+0, 0 as u64
|
|
225
|
+
jmp L_CSTR_UNTIL_HEAD_%out_ok
|
|
226
|
+
|
|
227
|
+
L_CSTR_UNTIL_HEAD_%out_ok:
|
|
228
|
+
__cstr_until_idx_%out_ok = load __cstr_until_idx_slot_%out_ok+0 as u64
|
|
229
|
+
__cstr_until_done_%out_ok = eq __cstr_until_idx_%out_ok, __cstr_until_len_%out_ok
|
|
230
|
+
br __cstr_until_done_%out_ok -> L_CSTR_UNTIL_MISS_%out_ok, L_CSTR_UNTIL_BODY_%out_ok
|
|
231
|
+
|
|
232
|
+
L_CSTR_UNTIL_BODY_%out_ok:
|
|
233
|
+
__cstr_until_p_%out_ok = ptr_add __cstr_until_ptr_%out_ok, __cstr_until_idx_%out_ok
|
|
234
|
+
__cstr_until_b_%out_ok = load __cstr_until_p_%out_ok+0 as u8
|
|
235
|
+
__cstr_until_nul_%out_ok = eq __cstr_until_b_%out_ok, 0
|
|
236
|
+
br __cstr_until_nul_%out_ok -> L_CSTR_UNTIL_HIT_%out_ok, L_CSTR_UNTIL_NEXT_%out_ok
|
|
237
|
+
|
|
238
|
+
L_CSTR_UNTIL_NEXT_%out_ok:
|
|
239
|
+
__cstr_until_next_%out_ok = add __cstr_until_idx_%out_ok, 1
|
|
240
|
+
store __cstr_until_idx_slot_%out_ok+0, __cstr_until_next_%out_ok as u64
|
|
241
|
+
!__cstr_until_next_%out_ok
|
|
242
|
+
!__cstr_until_nul_%out_ok
|
|
243
|
+
!__cstr_until_b_%out_ok
|
|
244
|
+
!__cstr_until_p_%out_ok
|
|
245
|
+
!__cstr_until_done_%out_ok
|
|
246
|
+
!__cstr_until_idx_%out_ok
|
|
247
|
+
jmp L_CSTR_UNTIL_HEAD_%out_ok
|
|
248
|
+
|
|
249
|
+
L_CSTR_UNTIL_HIT_%out_ok:
|
|
250
|
+
__cstr_until_view_len_%out_ok = add __cstr_until_idx_%out_ok, 1
|
|
251
|
+
EXPAND SLICE_NEW %cstr_reg, __cstr_until_ptr_%out_ok, __cstr_until_view_len_%out_ok
|
|
252
|
+
%out_ok = add 0, 1
|
|
253
|
+
!__cstr_until_view_len_%out_ok
|
|
254
|
+
!__cstr_until_nul_%out_ok
|
|
255
|
+
!__cstr_until_b_%out_ok
|
|
256
|
+
!__cstr_until_p_%out_ok
|
|
257
|
+
!__cstr_until_done_%out_ok
|
|
258
|
+
!__cstr_until_idx_%out_ok
|
|
259
|
+
!__cstr_until_len_%out_ok
|
|
260
|
+
!__cstr_until_ptr_%out_ok
|
|
261
|
+
jmp L_CSTR_UNTIL_END_%out_ok
|
|
262
|
+
|
|
263
|
+
L_CSTR_UNTIL_MISS_%out_ok:
|
|
264
|
+
__cstr_until_null_%out_ok = 0 as ptr
|
|
265
|
+
EXPAND SLICE_NEW %cstr_reg, __cstr_until_null_%out_ok, 0
|
|
266
|
+
%out_ok = add 0, 0
|
|
267
|
+
!__cstr_until_null_%out_ok
|
|
268
|
+
!__cstr_until_done_%out_ok
|
|
269
|
+
!__cstr_until_idx_%out_ok
|
|
270
|
+
!__cstr_until_len_%out_ok
|
|
271
|
+
!__cstr_until_ptr_%out_ok
|
|
272
|
+
|
|
273
|
+
L_CSTR_UNTIL_END_%out_ok:
|
|
274
|
+
[END_MACRO]
|
|
275
|
+
|
|
276
|
+
[MACRO] CSTR_COUNT_BYTES %out_len, %cstr_reg
|
|
277
|
+
__cstr_count_len_%out_len = load %cstr_reg+CStr_len as u64
|
|
278
|
+
%out_len = sub __cstr_count_len_%out_len, 1
|
|
279
|
+
!__cstr_count_len_%out_len
|
|
280
|
+
[END_MACRO]
|
|
281
|
+
|
|
282
|
+
[MACRO] CSTR_IS_EMPTY %out_bool, %cstr_reg
|
|
283
|
+
EXPAND CSTR_COUNT_BYTES __cstr_empty_len_%out_bool, %cstr_reg
|
|
284
|
+
%out_bool = eq __cstr_empty_len_%out_bool, 0
|
|
285
|
+
!__cstr_empty_len_%out_bool
|
|
286
|
+
[END_MACRO]
|
|
287
|
+
|
|
288
|
+
[MACRO] CSTR_TO_BYTES_WITH_NUL %out_slice, %cstr_reg
|
|
289
|
+
__cstr_bytes_ptr_%out_slice = load %cstr_reg+CStr_ptr as ptr
|
|
290
|
+
__cstr_bytes_len_%out_slice = load %cstr_reg+CStr_len as u64
|
|
291
|
+
EXPAND SLICE_NEW %out_slice, __cstr_bytes_ptr_%out_slice, __cstr_bytes_len_%out_slice
|
|
292
|
+
!__cstr_bytes_len_%out_slice
|
|
293
|
+
!__cstr_bytes_ptr_%out_slice
|
|
294
|
+
[END_MACRO]
|
|
295
|
+
|
|
296
|
+
[MACRO] CSTR_TO_BYTES %out_slice, %cstr_reg
|
|
297
|
+
__cstr_no_nul_ptr_%out_slice = load %cstr_reg+CStr_ptr as ptr
|
|
298
|
+
__cstr_no_nul_len_with_%out_slice = load %cstr_reg+CStr_len as u64
|
|
299
|
+
__cstr_no_nul_len_%out_slice = sub __cstr_no_nul_len_with_%out_slice, 1
|
|
300
|
+
EXPAND SLICE_NEW %out_slice, __cstr_no_nul_ptr_%out_slice, __cstr_no_nul_len_%out_slice
|
|
301
|
+
!__cstr_no_nul_len_%out_slice
|
|
302
|
+
!__cstr_no_nul_len_with_%out_slice
|
|
303
|
+
!__cstr_no_nul_ptr_%out_slice
|
|
304
|
+
[END_MACRO]
|
|
305
|
+
|
|
306
|
+
[MACRO] CSTR_TO_STR %out_status, %out_slice, %cstr_reg
|
|
307
|
+
EXPAND CSTR_TO_BYTES %out_slice, %cstr_reg
|
|
308
|
+
__cstr_to_str_ptr_%out_status = load %out_slice+Slice_ptr as ptr
|
|
309
|
+
__cstr_to_str_len_%out_status = load %out_slice+Slice_len as u64
|
|
310
|
+
__cstr_to_str_status_%out_status = call @sa_str_utf8_validate(__cstr_to_str_ptr_%out_status, __cstr_to_str_len_%out_status)
|
|
311
|
+
__cstr_to_str_ok_%out_status = eq __cstr_to_str_status_%out_status, 0
|
|
312
|
+
br __cstr_to_str_ok_%out_status -> L_CSTR_TO_STR_OK_%out_status, L_CSTR_TO_STR_BAD_%out_status
|
|
313
|
+
|
|
314
|
+
L_CSTR_TO_STR_OK_%out_status:
|
|
315
|
+
%out_status = add 0, CSTR_FROM_BYTES_OK
|
|
316
|
+
!__cstr_to_str_ok_%out_status
|
|
317
|
+
!__cstr_to_str_status_%out_status
|
|
318
|
+
!__cstr_to_str_len_%out_status
|
|
319
|
+
!__cstr_to_str_ptr_%out_status
|
|
320
|
+
jmp L_CSTR_TO_STR_END_%out_status
|
|
321
|
+
|
|
322
|
+
L_CSTR_TO_STR_BAD_%out_status:
|
|
323
|
+
%out_status = add 0, CSTR_TO_STR_INVALID_UTF8
|
|
324
|
+
__cstr_to_str_null_%out_status = 0 as ptr
|
|
325
|
+
EXPAND SLICE_NEW %out_slice, __cstr_to_str_null_%out_status, 0
|
|
326
|
+
!__cstr_to_str_null_%out_status
|
|
327
|
+
!__cstr_to_str_ok_%out_status
|
|
328
|
+
!__cstr_to_str_status_%out_status
|
|
329
|
+
!__cstr_to_str_len_%out_status
|
|
330
|
+
!__cstr_to_str_ptr_%out_status
|
|
331
|
+
|
|
332
|
+
L_CSTR_TO_STR_END_%out_status:
|
|
333
|
+
[END_MACRO]
|
|
334
|
+
|
|
335
|
+
[MACRO] CSTRING_NEW %out_status, %cstring_reg, %slice_reg
|
|
336
|
+
__cstring_new_src_ptr_%out_status = load %slice_reg+Slice_ptr as ptr
|
|
337
|
+
__cstring_new_src_len_%out_status = load %slice_reg+Slice_len as u64
|
|
338
|
+
__cstring_new_idx_slot_%out_status = stack_alloc 8
|
|
339
|
+
store __cstring_new_idx_slot_%out_status+0, 0 as u64
|
|
340
|
+
jmp L_CSTRING_NEW_SCAN_HEAD_%out_status
|
|
341
|
+
|
|
342
|
+
L_CSTRING_NEW_SCAN_HEAD_%out_status:
|
|
343
|
+
__cstring_new_idx_%out_status = load __cstring_new_idx_slot_%out_status+0 as u64
|
|
344
|
+
__cstring_new_done_%out_status = eq __cstring_new_idx_%out_status, __cstring_new_src_len_%out_status
|
|
345
|
+
br __cstring_new_done_%out_status -> L_CSTRING_NEW_ALLOC_%out_status, L_CSTRING_NEW_SCAN_BODY_%out_status
|
|
346
|
+
|
|
347
|
+
L_CSTRING_NEW_SCAN_BODY_%out_status:
|
|
348
|
+
__cstring_new_p_%out_status = ptr_add __cstring_new_src_ptr_%out_status, __cstring_new_idx_%out_status
|
|
349
|
+
__cstring_new_b_%out_status = load __cstring_new_p_%out_status+0 as u8
|
|
350
|
+
__cstring_new_is_nul_%out_status = eq __cstring_new_b_%out_status, 0
|
|
351
|
+
br __cstring_new_is_nul_%out_status -> L_CSTRING_NEW_INTERIOR_%out_status, L_CSTRING_NEW_SCAN_NEXT_%out_status
|
|
352
|
+
|
|
353
|
+
L_CSTRING_NEW_SCAN_NEXT_%out_status:
|
|
354
|
+
__cstring_new_next_%out_status = add __cstring_new_idx_%out_status, 1
|
|
355
|
+
store __cstring_new_idx_slot_%out_status+0, __cstring_new_next_%out_status as u64
|
|
356
|
+
!__cstring_new_next_%out_status
|
|
357
|
+
!__cstring_new_is_nul_%out_status
|
|
358
|
+
!__cstring_new_b_%out_status
|
|
359
|
+
!__cstring_new_p_%out_status
|
|
360
|
+
!__cstring_new_done_%out_status
|
|
361
|
+
!__cstring_new_idx_%out_status
|
|
362
|
+
jmp L_CSTRING_NEW_SCAN_HEAD_%out_status
|
|
363
|
+
|
|
364
|
+
L_CSTRING_NEW_ALLOC_%out_status:
|
|
365
|
+
__cstring_new_len_with_%out_status = add __cstring_new_src_len_%out_status, 1
|
|
366
|
+
__cstring_new_dst_%out_status = alloc __cstring_new_len_with_%out_status
|
|
367
|
+
call @sa_mem_copy(&__cstring_new_dst_%out_status, &__cstring_new_src_ptr_%out_status, __cstring_new_src_len_%out_status)
|
|
368
|
+
__cstring_new_nul_p_%out_status = ptr_add __cstring_new_dst_%out_status, __cstring_new_src_len_%out_status
|
|
369
|
+
store __cstring_new_nul_p_%out_status+0, 0 as u8
|
|
370
|
+
EXPAND SLICE_NEW %cstring_reg, __cstring_new_dst_%out_status, __cstring_new_len_with_%out_status
|
|
371
|
+
%out_status = add 0, CSTRING_NEW_OK
|
|
372
|
+
^__cstring_new_dst_%out_status
|
|
373
|
+
!__cstring_new_nul_p_%out_status
|
|
374
|
+
!__cstring_new_len_with_%out_status
|
|
375
|
+
!__cstring_new_done_%out_status
|
|
376
|
+
!__cstring_new_idx_%out_status
|
|
377
|
+
!__cstring_new_src_len_%out_status
|
|
378
|
+
!__cstring_new_src_ptr_%out_status
|
|
379
|
+
jmp L_CSTRING_NEW_END_%out_status
|
|
380
|
+
|
|
381
|
+
L_CSTRING_NEW_INTERIOR_%out_status:
|
|
382
|
+
__cstring_new_null_%out_status = 0 as ptr
|
|
383
|
+
EXPAND SLICE_NEW %cstring_reg, __cstring_new_null_%out_status, 0
|
|
384
|
+
%out_status = add 0, CSTRING_NEW_INTERIOR_NUL
|
|
385
|
+
!__cstring_new_null_%out_status
|
|
386
|
+
!__cstring_new_is_nul_%out_status
|
|
387
|
+
!__cstring_new_b_%out_status
|
|
388
|
+
!__cstring_new_p_%out_status
|
|
389
|
+
!__cstring_new_done_%out_status
|
|
390
|
+
!__cstring_new_idx_%out_status
|
|
391
|
+
!__cstring_new_src_len_%out_status
|
|
392
|
+
!__cstring_new_src_ptr_%out_status
|
|
393
|
+
|
|
394
|
+
L_CSTRING_NEW_END_%out_status:
|
|
395
|
+
[END_MACRO]
|
|
396
|
+
|
|
397
|
+
[MACRO] CSTRING_FROM_BYTES_WITH_NUL %out_status, %cstring_reg, %slice_reg
|
|
398
|
+
__cstring_from_nul_cstr_%out_status = stack_alloc CStr_SIZE
|
|
399
|
+
EXPAND CSTR_FROM_BYTES_WITH_NUL %out_status, __cstring_from_nul_cstr_%out_status, %slice_reg
|
|
400
|
+
__cstring_from_nul_ok_%out_status = eq %out_status, CSTR_FROM_BYTES_OK
|
|
401
|
+
br __cstring_from_nul_ok_%out_status -> L_CSTRING_FROM_NUL_OK_%out_status, L_CSTRING_FROM_NUL_BAD_%out_status
|
|
402
|
+
|
|
403
|
+
L_CSTRING_FROM_NUL_OK_%out_status:
|
|
404
|
+
EXPAND CSTRING_FROM_BYTES_WITH_NUL_UNCHECKED %cstring_reg, %slice_reg
|
|
405
|
+
!__cstring_from_nul_ok_%out_status
|
|
406
|
+
jmp L_CSTRING_FROM_NUL_END_%out_status
|
|
407
|
+
|
|
408
|
+
L_CSTRING_FROM_NUL_BAD_%out_status:
|
|
409
|
+
__cstring_from_nul_null_%out_status = 0 as ptr
|
|
410
|
+
EXPAND SLICE_NEW %cstring_reg, __cstring_from_nul_null_%out_status, 0
|
|
411
|
+
!__cstring_from_nul_null_%out_status
|
|
412
|
+
!__cstring_from_nul_ok_%out_status
|
|
413
|
+
|
|
414
|
+
L_CSTRING_FROM_NUL_END_%out_status:
|
|
415
|
+
[END_MACRO]
|
|
416
|
+
|
|
417
|
+
[MACRO] CSTRING_FROM_BYTES_WITH_NUL_UNCHECKED %cstring_reg, %slice_reg
|
|
418
|
+
__cstring_from_nul_src_ptr_%cstring_reg = load %slice_reg+Slice_ptr as ptr
|
|
419
|
+
__cstring_from_nul_len_%cstring_reg = load %slice_reg+Slice_len as u64
|
|
420
|
+
__cstring_from_nul_dst_%cstring_reg = alloc __cstring_from_nul_len_%cstring_reg
|
|
421
|
+
call @sa_mem_copy(&__cstring_from_nul_dst_%cstring_reg, &__cstring_from_nul_src_ptr_%cstring_reg, __cstring_from_nul_len_%cstring_reg)
|
|
422
|
+
EXPAND SLICE_NEW %cstring_reg, __cstring_from_nul_dst_%cstring_reg, __cstring_from_nul_len_%cstring_reg
|
|
423
|
+
^__cstring_from_nul_dst_%cstring_reg
|
|
424
|
+
!__cstring_from_nul_len_%cstring_reg
|
|
425
|
+
!__cstring_from_nul_src_ptr_%cstring_reg
|
|
426
|
+
[END_MACRO]
|
|
427
|
+
|
|
428
|
+
[MACRO] CSTRING_AS_CSTR %out_cstr, %cstring_reg
|
|
429
|
+
__cstring_as_ptr_%out_cstr = load %cstring_reg+CString_ptr as ptr
|
|
430
|
+
__cstring_as_len_%out_cstr = load %cstring_reg+CString_len as u64
|
|
431
|
+
EXPAND CSTR_FROM_PARTS_UNCHECKED %out_cstr, __cstring_as_ptr_%out_cstr, __cstring_as_len_%out_cstr
|
|
432
|
+
!__cstring_as_len_%out_cstr
|
|
433
|
+
!__cstring_as_ptr_%out_cstr
|
|
434
|
+
[END_MACRO]
|
|
435
|
+
|
|
436
|
+
[MACRO] CSTRING_AS_BYTES_WITH_NUL %out_slice, %cstring_reg
|
|
437
|
+
__cstring_bytes_cstr_%out_slice = stack_alloc CStr_SIZE
|
|
438
|
+
EXPAND CSTRING_AS_CSTR __cstring_bytes_cstr_%out_slice, %cstring_reg
|
|
439
|
+
EXPAND CSTR_TO_BYTES_WITH_NUL %out_slice, __cstring_bytes_cstr_%out_slice
|
|
440
|
+
[END_MACRO]
|
|
441
|
+
|
|
442
|
+
[MACRO] CSTRING_AS_BYTES %out_slice, %cstring_reg
|
|
443
|
+
__cstring_no_nul_cstr_%out_slice = stack_alloc CStr_SIZE
|
|
444
|
+
EXPAND CSTRING_AS_CSTR __cstring_no_nul_cstr_%out_slice, %cstring_reg
|
|
445
|
+
EXPAND CSTR_TO_BYTES %out_slice, __cstring_no_nul_cstr_%out_slice
|
|
446
|
+
[END_MACRO]
|
|
447
|
+
|
|
448
|
+
[MACRO] CSTRING_TO_STR %out_status, %out_slice, %cstring_reg
|
|
449
|
+
__cstring_to_str_cstr_%out_status = stack_alloc CStr_SIZE
|
|
450
|
+
EXPAND CSTRING_AS_CSTR __cstring_to_str_cstr_%out_status, %cstring_reg
|
|
451
|
+
EXPAND CSTR_TO_STR %out_status, %out_slice, __cstring_to_str_cstr_%out_status
|
|
452
|
+
[END_MACRO]
|
|
453
|
+
|
|
454
|
+
[MACRO] DEFAULT_HASHER_WRITE_CSTR %hasher, %cstr_reg
|
|
455
|
+
__cstr_hash_bytes_%hasher = stack_alloc Slice_SIZE
|
|
456
|
+
EXPAND CSTR_TO_BYTES_WITH_NUL __cstr_hash_bytes_%hasher, %cstr_reg
|
|
457
|
+
EXPAND DEFAULT_HASHER_WRITE_SLICE_U8 %hasher, __cstr_hash_bytes_%hasher
|
|
458
|
+
[END_MACRO]
|
|
459
|
+
|
|
460
|
+
[MACRO] CSTR_HASH %out_hash, %cstr_reg
|
|
461
|
+
__cstr_hash_hasher_%out_hash = stack_alloc DefaultHasher_SIZE
|
|
462
|
+
EXPAND DEFAULT_HASHER_NEW __cstr_hash_hasher_%out_hash
|
|
463
|
+
EXPAND DEFAULT_HASHER_WRITE_CSTR __cstr_hash_hasher_%out_hash, %cstr_reg
|
|
464
|
+
EXPAND DEFAULT_HASHER_FINISH %out_hash, __cstr_hash_hasher_%out_hash
|
|
465
|
+
[END_MACRO]
|
|
466
|
+
|
|
467
|
+
[MACRO] BUILD_HASHER_DEFAULT_HASH_ONE_CSTR %out_hash, %builder, %cstr_reg
|
|
468
|
+
__build_hash_one_cstr_hasher_%out_hash = stack_alloc DefaultHasher_SIZE
|
|
469
|
+
EXPAND BUILD_HASHER_DEFAULT_BUILD __build_hash_one_cstr_hasher_%out_hash, %builder
|
|
470
|
+
EXPAND DEFAULT_HASHER_WRITE_CSTR __build_hash_one_cstr_hasher_%out_hash, %cstr_reg
|
|
471
|
+
EXPAND DEFAULT_HASHER_FINISH %out_hash, __build_hash_one_cstr_hasher_%out_hash
|
|
472
|
+
[END_MACRO]
|
|
473
|
+
|
|
474
|
+
[MACRO] RANDOM_STATE_HASH_ONE_CSTR %out_hash, %state, %cstr_reg
|
|
475
|
+
__random_state_hash_one_cstr_hasher_%out_hash = stack_alloc DefaultHasher_SIZE
|
|
476
|
+
EXPAND RANDOM_STATE_BUILD __random_state_hash_one_cstr_hasher_%out_hash, %state
|
|
477
|
+
EXPAND DEFAULT_HASHER_WRITE_CSTR __random_state_hash_one_cstr_hasher_%out_hash, %cstr_reg
|
|
478
|
+
EXPAND DEFAULT_HASHER_FINISH %out_hash, __random_state_hash_one_cstr_hasher_%out_hash
|
|
479
|
+
[END_MACRO]
|
|
480
|
+
|
|
481
|
+
[MACRO] DEFAULT_HASHER_WRITE_CSTRING %hasher, %cstring_reg
|
|
482
|
+
__cstring_hash_bytes_%hasher = stack_alloc Slice_SIZE
|
|
483
|
+
EXPAND CSTRING_AS_BYTES_WITH_NUL __cstring_hash_bytes_%hasher, %cstring_reg
|
|
484
|
+
EXPAND DEFAULT_HASHER_WRITE_SLICE_U8 %hasher, __cstring_hash_bytes_%hasher
|
|
485
|
+
[END_MACRO]
|
|
486
|
+
|
|
487
|
+
[MACRO] CSTRING_HASH %out_hash, %cstring_reg
|
|
488
|
+
__cstring_hash_hasher_%out_hash = stack_alloc DefaultHasher_SIZE
|
|
489
|
+
EXPAND DEFAULT_HASHER_NEW __cstring_hash_hasher_%out_hash
|
|
490
|
+
EXPAND DEFAULT_HASHER_WRITE_CSTRING __cstring_hash_hasher_%out_hash, %cstring_reg
|
|
491
|
+
EXPAND DEFAULT_HASHER_FINISH %out_hash, __cstring_hash_hasher_%out_hash
|
|
492
|
+
[END_MACRO]
|
|
493
|
+
|
|
494
|
+
[MACRO] BUILD_HASHER_DEFAULT_HASH_ONE_CSTRING %out_hash, %builder, %cstring_reg
|
|
495
|
+
__build_hash_one_cstring_hasher_%out_hash = stack_alloc DefaultHasher_SIZE
|
|
496
|
+
EXPAND BUILD_HASHER_DEFAULT_BUILD __build_hash_one_cstring_hasher_%out_hash, %builder
|
|
497
|
+
EXPAND DEFAULT_HASHER_WRITE_CSTRING __build_hash_one_cstring_hasher_%out_hash, %cstring_reg
|
|
498
|
+
EXPAND DEFAULT_HASHER_FINISH %out_hash, __build_hash_one_cstring_hasher_%out_hash
|
|
499
|
+
[END_MACRO]
|
|
500
|
+
|
|
501
|
+
[MACRO] RANDOM_STATE_HASH_ONE_CSTRING %out_hash, %state, %cstring_reg
|
|
502
|
+
__random_state_hash_one_cstring_hasher_%out_hash = stack_alloc DefaultHasher_SIZE
|
|
503
|
+
EXPAND RANDOM_STATE_BUILD __random_state_hash_one_cstring_hasher_%out_hash, %state
|
|
504
|
+
EXPAND DEFAULT_HASHER_WRITE_CSTRING __random_state_hash_one_cstring_hasher_%out_hash, %cstring_reg
|
|
505
|
+
EXPAND DEFAULT_HASHER_FINISH %out_hash, __random_state_hash_one_cstring_hasher_%out_hash
|
|
506
|
+
[END_MACRO]
|
|
507
|
+
|
|
508
|
+
[MACRO] CSTRING_AS_PTR %out_ptr, %cstring_reg
|
|
509
|
+
%out_ptr = load %cstring_reg+CString_ptr as ptr
|
|
510
|
+
[END_MACRO]
|
|
511
|
+
|
|
512
|
+
[MACRO] CSTRING_COUNT_BYTES %out_len, %cstring_reg
|
|
513
|
+
__cstring_count_cstr_%out_len = stack_alloc CStr_SIZE
|
|
514
|
+
EXPAND CSTRING_AS_CSTR __cstring_count_cstr_%out_len, %cstring_reg
|
|
515
|
+
EXPAND CSTR_COUNT_BYTES %out_len, __cstring_count_cstr_%out_len
|
|
516
|
+
[END_MACRO]
|
|
517
|
+
|
|
518
|
+
[MACRO] CSTRING_IS_EMPTY %out_bool, %cstring_reg
|
|
519
|
+
EXPAND CSTRING_COUNT_BYTES __cstring_empty_len_%out_bool, %cstring_reg
|
|
520
|
+
%out_bool = eq __cstring_empty_len_%out_bool, 0
|
|
521
|
+
!__cstring_empty_len_%out_bool
|
|
522
|
+
[END_MACRO]
|
|
523
|
+
|
|
524
|
+
[MACRO] CSTRING_INTO_RAW %out_ptr, %cstring_reg
|
|
525
|
+
%out_ptr = load %cstring_reg+CString_ptr as ptr
|
|
526
|
+
store %cstring_reg+CString_ptr, 0 as ptr
|
|
527
|
+
store %cstring_reg+CString_len, 0 as u64
|
|
528
|
+
[END_MACRO]
|
|
529
|
+
|
|
530
|
+
[MACRO] CSTRING_FROM_RAW %cstring_reg, %ptr_reg
|
|
531
|
+
EXPAND CSTR_FROM_PTR %cstring_reg, %ptr_reg
|
|
532
|
+
[END_MACRO]
|
|
533
|
+
|
|
534
|
+
[MACRO] CSTRING_FREE %cstring_reg
|
|
535
|
+
__cstring_free_ptr_%cstring_reg = load %cstring_reg+CString_ptr as ptr
|
|
536
|
+
__cstring_free_null_%cstring_reg = 0 as ptr
|
|
537
|
+
__cstring_free_has_%cstring_reg = ne __cstring_free_ptr_%cstring_reg, __cstring_free_null_%cstring_reg
|
|
538
|
+
br __cstring_free_has_%cstring_reg -> L_CSTRING_FREE_DO_%cstring_reg, L_CSTRING_FREE_DONE_%cstring_reg
|
|
539
|
+
|
|
540
|
+
L_CSTRING_FREE_DO_%cstring_reg:
|
|
541
|
+
!__cstring_free_ptr_%cstring_reg
|
|
542
|
+
jmp L_CSTRING_FREE_AFTER_%cstring_reg
|
|
543
|
+
|
|
544
|
+
L_CSTRING_FREE_DONE_%cstring_reg:
|
|
545
|
+
!__cstring_free_ptr_%cstring_reg
|
|
546
|
+
|
|
547
|
+
L_CSTRING_FREE_AFTER_%cstring_reg:
|
|
548
|
+
store %cstring_reg+CString_ptr, 0 as ptr
|
|
549
|
+
store %cstring_reg+CString_len, 0 as u64
|
|
550
|
+
!__cstring_free_has_%cstring_reg
|
|
551
|
+
!__cstring_free_null_%cstring_reg
|
|
552
|
+
[END_MACRO]
|
|
553
|
+
|
|
554
|
+
// Owned CString convenience constructors/clones over the existing byte-buffer facade.
|
|
555
|
+
|
|
556
|
+
[MACRO] CSTRING_DEFAULT %out_status, %cstring_reg
|
|
557
|
+
__cstring_default_null_%out_status = 0 as ptr
|
|
558
|
+
__cstring_default_slice_%out_status = stack_alloc Slice_SIZE
|
|
559
|
+
EXPAND SLICE_NEW __cstring_default_slice_%out_status, __cstring_default_null_%out_status, 0
|
|
560
|
+
EXPAND CSTRING_NEW %out_status, %cstring_reg, __cstring_default_slice_%out_status
|
|
561
|
+
!__cstring_default_null_%out_status
|
|
562
|
+
[END_MACRO]
|
|
563
|
+
|
|
564
|
+
[MACRO] CSTRING_CLONE %out_status, %out_cstring, %src_cstring
|
|
565
|
+
__cstring_clone_bytes_%out_status = stack_alloc Slice_SIZE
|
|
566
|
+
EXPAND CSTRING_AS_BYTES_WITH_NUL __cstring_clone_bytes_%out_status, %src_cstring
|
|
567
|
+
EXPAND CSTRING_FROM_BYTES_WITH_NUL %out_status, %out_cstring, __cstring_clone_bytes_%out_status
|
|
568
|
+
[END_MACRO]
|
|
569
|
+
|
|
570
|
+
[MACRO] CSTRING_LIT1 %out_status, %out_cstring, %s0
|
|
571
|
+
EXPAND CSTRING_NEW %out_status, %out_cstring, %s0
|
|
572
|
+
[END_MACRO]
|
|
573
|
+
|
|
574
|
+
// Lossy owned-string materialization from CString bytes (excluding trailing NUL).
|
|
575
|
+
|
|
576
|
+
[MACRO] CSTRING_TO_STRING_LOSSY %out_string, %cstring_reg
|
|
577
|
+
__cstring_lossy_bytes_%out_string = stack_alloc Slice_SIZE
|
|
578
|
+
EXPAND CSTRING_AS_BYTES __cstring_lossy_bytes_%out_string, %cstring_reg
|
|
579
|
+
EXPAND STRING_BUF_FROM_UTF8_LOSSY %out_string, __cstring_lossy_bytes_%out_string
|
|
580
|
+
[END_MACRO]
|
|
581
|
+
|
|
582
|
+
[MACRO] CSTR_TO_STRING_LOSSY %out_string, %cstr_reg
|
|
583
|
+
__cstr_lossy_bytes_%out_string = stack_alloc Slice_SIZE
|
|
584
|
+
EXPAND CSTR_TO_BYTES __cstr_lossy_bytes_%out_string, %cstr_reg
|
|
585
|
+
EXPAND STRING_BUF_FROM_UTF8_LOSSY %out_string, __cstr_lossy_bytes_%out_string
|
|
586
|
+
[END_MACRO]
|
|
587
|
+
|
|
588
|
+
[MACRO] CSTRING_INTO_STRING %out_status, %out_slice, %cstring_reg
|
|
589
|
+
EXPAND CSTRING_TO_STR %out_status, %out_slice, %cstring_reg
|
|
590
|
+
[END_MACRO]
|
|
591
|
+
|
|
592
|
+
[MACRO] CSTRING_AS_C_STR %out_cstr, %cstring_reg
|
|
593
|
+
EXPAND CSTRING_AS_CSTR %out_cstr, %cstring_reg
|
|
594
|
+
[END_MACRO]
|
|
595
|
+
|
|
596
|
+
// Stable std-style aliases for borrowed and owned C strings.
|
|
597
|
+
[MACRO] CSTR_FROM_SLICE %out_status, %cstr_reg, %slice_reg
|
|
598
|
+
EXPAND CSTR_FROM_BYTES_WITH_NUL %out_status, %cstr_reg, %slice_reg
|
|
599
|
+
[END_MACRO]
|
|
600
|
+
|
|
601
|
+
[MACRO] CSTR_AS_BYTES_WITH_NUL %out_slice, %cstr_reg
|
|
602
|
+
EXPAND CSTR_TO_BYTES_WITH_NUL %out_slice, %cstr_reg
|
|
603
|
+
[END_MACRO]
|
|
604
|
+
|
|
605
|
+
[MACRO] CSTR_AS_BYTES %out_slice, %cstr_reg
|
|
606
|
+
EXPAND CSTR_TO_BYTES %out_slice, %cstr_reg
|
|
607
|
+
[END_MACRO]
|
|
608
|
+
|
|
609
|
+
[MACRO] CSTR_AS_STR %out_status, %out_slice, %cstr_reg
|
|
610
|
+
EXPAND CSTR_TO_STR %out_status, %out_slice, %cstr_reg
|
|
611
|
+
[END_MACRO]
|
|
612
|
+
|
|
613
|
+
[MACRO] CSTRING_FROM_SLICE %out_status, %cstring_reg, %slice_reg
|
|
614
|
+
EXPAND CSTRING_NEW %out_status, %cstring_reg, %slice_reg
|
|
615
|
+
[END_MACRO]
|
|
616
|
+
|
|
617
|
+
[MACRO] CSTRING_FROM_SLICE_WITH_NUL %out_status, %cstring_reg, %slice_reg
|
|
618
|
+
EXPAND CSTRING_FROM_BYTES_WITH_NUL %out_status, %cstring_reg, %slice_reg
|
|
619
|
+
[END_MACRO]
|
|
620
|
+
|
|
621
|
+
[MACRO] CSTRING_AS_STR %out_status, %out_slice, %cstring_reg
|
|
622
|
+
EXPAND CSTRING_TO_STR %out_status, %out_slice, %cstring_reg
|
|
623
|
+
[END_MACRO]
|
|
624
|
+
|
|
625
|
+
[MACRO] CSTRING_AS_CSTR_VIEW %out_cstr, %cstring_reg
|
|
626
|
+
EXPAND CSTRING_AS_CSTR %out_cstr, %cstring_reg
|
|
627
|
+
[END_MACRO]
|
|
628
|
+
|
|
629
|
+
[MACRO] CSTRING_AS_BYTES_WITH_NUL_VIEW %out_slice, %cstring_reg
|
|
630
|
+
EXPAND CSTRING_AS_BYTES_WITH_NUL %out_slice, %cstring_reg
|
|
631
|
+
[END_MACRO]
|
|
632
|
+
|
|
633
|
+
[MACRO] CSTRING_AS_BYTES_VIEW %out_slice, %cstring_reg
|
|
634
|
+
EXPAND CSTRING_AS_BYTES %out_slice, %cstring_reg
|
|
635
|
+
[END_MACRO]
|