@salang/sa 0.1.2 → 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.
Files changed (282) hide show
  1. package/bin/sa.js +19 -1
  2. package/package.json +8 -7
  3. package/sa_std/alloc/layout.sal +12 -0
  4. package/sa_std/alloc/prelude.sa +1 -0
  5. package/sa_std/alloc/prelude.sal +1 -0
  6. package/sa_std/alloc/string.sa +3 -0
  7. package/sa_std/alloc/vec.sa +684 -0
  8. package/sa_std/alloc/vec.sal +4 -0
  9. package/sa_std/any.sa +130 -0
  10. package/sa_std/any.sal +23 -0
  11. package/sa_std/array.sa +1876 -0
  12. package/sa_std/ascii.sa +2 -0
  13. package/sa_std/ascii.sal +1 -0
  14. package/sa_std/async.sla +116 -0
  15. package/sa_std/binary_heap.sa +3003 -0
  16. package/sa_std/binary_heap.sal +7 -0
  17. package/sa_std/borrow.sa +171 -0
  18. package/sa_std/borrow.sal +13 -0
  19. package/sa_std/btree_map.sa +2210 -0
  20. package/sa_std/btree_map.sal +11 -0
  21. package/sa_std/btree_set.sa +1072 -0
  22. package/sa_std/btree_set.sal +6 -0
  23. package/sa_std/char.sa +1309 -0
  24. package/sa_std/char.sal +50 -0
  25. package/sa_std/cmp.sa +554 -0
  26. package/sa_std/cmp.sal +14 -0
  27. package/sa_std/collections/binary_heap.sa +1 -0
  28. package/sa_std/collections/btree_map.sa +1 -0
  29. package/sa_std/collections/btree_set.sa +1 -0
  30. package/sa_std/collections/hashmap.sa +1 -0
  31. package/sa_std/collections/hashset.sa +1 -0
  32. package/sa_std/collections/linked_list.sa +1120 -0
  33. package/sa_std/collections/linked_list.sal +10 -0
  34. package/sa_std/collections/prelude.sa +7 -0
  35. package/sa_std/collections/prelude.sal +1 -0
  36. package/sa_std/collections/vec_deque.sa +1 -0
  37. package/sa_std/collections.sal +13 -0
  38. package/sa_std/convert.sa +1115 -0
  39. package/sa_std/convert.sal +24 -0
  40. package/sa_std/core/arc.sa +233 -0
  41. package/sa_std/core/arc.sal +4 -0
  42. package/sa_std/core/ascii.sa +784 -0
  43. package/sa_std/core/ascii.sal +34 -0
  44. package/sa_std/core/bit.sa +41 -0
  45. package/sa_std/core/box.sa +1 -0
  46. package/sa_std/core/box.sal +2 -0
  47. package/sa_std/core/cell.sa +108 -0
  48. package/sa_std/core/cell.sal +5 -0
  49. package/sa_std/core/cleanup.sa +26 -0
  50. package/sa_std/core/control.sa +20 -0
  51. package/sa_std/core/derive.sa +60 -0
  52. package/sa_std/core/derive.sal +1 -0
  53. package/sa_std/core/dispatch.sa +7 -0
  54. package/sa_std/core/dispatch.sal +5 -0
  55. package/sa_std/core/future.sa +777 -0
  56. package/sa_std/core/future.sal +73 -0
  57. package/sa_std/core/hash.sa +48 -0
  58. package/sa_std/core/iter.sa +2805 -0
  59. package/sa_std/core/iter.sal +4 -0
  60. package/sa_std/core/loop.sa +60 -0
  61. package/sa_std/core/mem.sa +220 -0
  62. package/sa_std/core/option.sa +825 -0
  63. package/sa_std/core/option.sal +11 -0
  64. package/sa_std/core/panic.sa +23 -0
  65. package/sa_std/core/panic.sal +12 -0
  66. package/sa_std/core/prelude.sa +18 -0
  67. package/sa_std/core/prelude.sal +18 -0
  68. package/sa_std/core/rc.sa +225 -0
  69. package/sa_std/core/rc.sal +4 -0
  70. package/sa_std/core/refcell.sa +283 -0
  71. package/sa_std/core/refcell.sal +13 -0
  72. package/sa_std/core/result.sa +708 -0
  73. package/sa_std/core/result.sal +6 -0
  74. package/sa_std/core/rust_patterns.sal +295 -0
  75. package/sa_std/core/sa_core.sa +84 -0
  76. package/sa_std/core/slice.sa +4021 -0
  77. package/sa_std/core/slice.sal +7 -0
  78. package/sa_std/core/task.sa +112 -0
  79. package/sa_std/core/task.sal +15 -0
  80. package/sa_std/core/trait_object.sa +26 -0
  81. package/sa_std/core/trait_object.sal +4 -0
  82. package/sa_std/core/waker.sa +289 -0
  83. package/sa_std/core/waker.sal +31 -0
  84. package/sa_std/core/weak.sa +2 -0
  85. package/sa_std/core/weak.sal +4 -0
  86. package/sa_std/cow.sa +3 -0
  87. package/sa_std/cow.sal +2 -0
  88. package/sa_std/cstring.sa +3 -0
  89. package/sa_std/cstring.sal +2 -0
  90. package/sa_std/default.sa +99 -0
  91. package/sa_std/duration.sa +3 -0
  92. package/sa_std/duration.sal +2 -0
  93. package/sa_std/encoding/json.sa +259 -0
  94. package/sa_std/encoding/json.sai +54 -0
  95. package/sa_std/encoding/json.sal +35 -0
  96. package/sa_std/encoding/prelude.sa +1 -0
  97. package/sa_std/encoding/prelude.sal +0 -0
  98. package/sa_std/env.sa +390 -0
  99. package/sa_std/env.sai +25 -0
  100. package/sa_std/error.sa +253 -0
  101. package/sa_std/error.sal +44 -0
  102. package/sa_std/ffi/cstring.sa +3 -0
  103. package/sa_std/ffi/cstring.sal +1 -0
  104. package/sa_std/ffi/prelude.sa +2 -0
  105. package/sa_std/ffi/prelude.sal +2 -0
  106. package/sa_std/ffi.sa +635 -0
  107. package/sa_std/ffi.sal +51 -0
  108. package/sa_std/fmt.sa +2 -0
  109. package/sa_std/fmt.sai +18 -0
  110. package/sa_std/fmt.sal +35 -0
  111. package/sa_std/fs.sa +1023 -0
  112. package/sa_std/fs.sai +127 -0
  113. package/sa_std/fs.sal +51 -0
  114. package/sa_std/future.sa +2 -0
  115. package/sa_std/future.sal +1 -0
  116. package/sa_std/hash.sa +1486 -0
  117. package/sa_std/hash.sal +13 -0
  118. package/sa_std/hashmap.sa +1962 -0
  119. package/sa_std/hashmap.sal +20 -0
  120. package/sa_std/hashset.sa +1004 -0
  121. package/sa_std/hashset.sal +18 -0
  122. package/sa_std/http2.sa +78 -0
  123. package/sa_std/http2.sai +26 -0
  124. package/sa_std/http2.sal +36 -0
  125. package/sa_std/instant.sa +3 -0
  126. package/sa_std/instant.sal +2 -0
  127. package/sa_std/io/buf_reader.sa +43 -0
  128. package/sa_std/io/buf_writer.sa +35 -0
  129. package/sa_std/io/bufio.sa +4 -0
  130. package/sa_std/io/bufio.sal +4 -0
  131. package/sa_std/io/prelude.sa +1 -0
  132. package/sa_std/io/prelude.sal +1 -0
  133. package/sa_std/io/print.sa +2 -0
  134. package/sa_std/io/print.sai +3 -0
  135. package/sa_std/io.sa +925 -0
  136. package/sa_std/io.sai +25 -0
  137. package/sa_std/io.sal +84 -0
  138. package/sa_std/iter.sa +2 -0
  139. package/sa_std/iter.sal +1 -0
  140. package/sa_std/join_handle.sa +3 -0
  141. package/sa_std/join_handle.sal +2 -0
  142. package/sa_std/libsa_async.sa +80 -0
  143. package/sa_std/m_async.sa +137 -0
  144. package/sa_std/m_async.sal +30 -0
  145. package/sa_std/m_async.sla +2 -0
  146. package/sa_std/manually_drop.sa +3 -0
  147. package/sa_std/manually_drop.sal +2 -0
  148. package/sa_std/marker/phantom_data.sa +3 -0
  149. package/sa_std/marker/phantom_data.sal +1 -0
  150. package/sa_std/marker/prelude.sa +4 -0
  151. package/sa_std/marker/prelude.sal +4 -0
  152. package/sa_std/marker.sa +220 -0
  153. package/sa_std/marker.sal +15 -0
  154. package/sa_std/math.sa +84 -0
  155. package/sa_std/math.sai +10 -0
  156. package/sa_std/mem/manually_drop.sa +3 -0
  157. package/sa_std/mem/manually_drop.sal +1 -0
  158. package/sa_std/mem/prelude.sa +2 -0
  159. package/sa_std/mem/prelude.sal +2 -0
  160. package/sa_std/mem.sa +564 -0
  161. package/sa_std/mem.sal +40 -0
  162. package/sa_std/modstate.sai +19 -0
  163. package/sa_std/net.sa +4227 -0
  164. package/sa_std/net.sai +239 -0
  165. package/sa_std/net.sal +159 -0
  166. package/sa_std/netx.sa +85 -0
  167. package/sa_std/netx.sai +11 -0
  168. package/sa_std/netx.sal +39 -0
  169. package/sa_std/nonzero.sa +3 -0
  170. package/sa_std/nonzero.sal +2 -0
  171. package/sa_std/num/nonzero.sa +3 -0
  172. package/sa_std/num/nonzero.sal +1 -0
  173. package/sa_std/num/prelude.sa +3 -0
  174. package/sa_std/num/prelude.sal +3 -0
  175. package/sa_std/num.sa +17302 -0
  176. package/sa_std/num.sai +11 -0
  177. package/sa_std/num.sal +341 -0
  178. package/sa_std/ops.sa +1884 -0
  179. package/sa_std/ops.sal +68 -0
  180. package/sa_std/option.sa +2 -0
  181. package/sa_std/option.sal +1 -0
  182. package/sa_std/os/fd.sa +96 -0
  183. package/sa_std/os/fd.sai +7 -0
  184. package/sa_std/os/fd.sal +11 -0
  185. package/sa_std/os/prelude.sa +2 -0
  186. package/sa_std/os/prelude.sal +1 -0
  187. package/sa_std/os/unix_ffi.sa +271 -0
  188. package/sa_std/panic.sa +1 -0
  189. package/sa_std/panic.sal +1 -0
  190. package/sa_std/path.sa +3170 -0
  191. package/sa_std/path.sal +12 -0
  192. package/sa_std/phantom_data.sa +3 -0
  193. package/sa_std/phantom_data.sal +2 -0
  194. package/sa_std/pin.sa +79 -0
  195. package/sa_std/pin.sal +5 -0
  196. package/sa_std/plugin_async.sa +90 -0
  197. package/sa_std/plugin_async.sal +29 -0
  198. package/sa_std/plugin_async.sla +4 -0
  199. package/sa_std/plugin_http_async.sa +46 -0
  200. package/sa_std/plugin_http_server.sa +61 -0
  201. package/sa_std/plugin_http_server.sla +2 -0
  202. package/sa_std/plugin_sqlite.sa +106 -0
  203. package/sa_std/plugin_sqlite.sla +2 -0
  204. package/sa_std/prelude.sa +60 -0
  205. package/sa_std/prelude.sal +55 -0
  206. package/sa_std/process.sa +916 -0
  207. package/sa_std/process.sai +57 -0
  208. package/sa_std/process.sal +27 -0
  209. package/sa_std/ptr.sa +503 -0
  210. package/sa_std/ptr.sal +2 -0
  211. package/sa_std/result.sa +2 -0
  212. package/sa_std/result.sal +1 -0
  213. package/sa_std/rust_core.sa +51 -0
  214. package/sa_std/rust_core.sal +26 -0
  215. package/sa_std/sa.mod +7 -0
  216. package/sa_std/sort.sa +156 -0
  217. package/sa_std/str.sla +13 -0
  218. package/sa_std/string.sa +12240 -0
  219. package/sa_std/string.sai +25 -0
  220. package/sa_std/string.sal +17 -0
  221. package/sa_std/string_format.sa +269 -0
  222. package/sa_std/sync/atomic.sa +1500 -0
  223. package/sa_std/sync/atomic.sal +45 -0
  224. package/sa_std/sync/barrier.sa +105 -0
  225. package/sa_std/sync/barrier.sal +7 -0
  226. package/sa_std/sync/condvar.sa +240 -0
  227. package/sa_std/sync/condvar.sal +4 -0
  228. package/sa_std/sync/mpsc.sa +758 -0
  229. package/sa_std/sync/mpsc.sal +42 -0
  230. package/sa_std/sync/mpsc_list.sa +255 -0
  231. package/sa_std/sync/mpsc_list.sal +3 -0
  232. package/sa_std/sync/mutex.sa +182 -0
  233. package/sa_std/sync/mutex.sal +7 -0
  234. package/sa_std/sync/once.sa +371 -0
  235. package/sa_std/sync/once.sal +31 -0
  236. package/sa_std/sync/poison.sa +36 -0
  237. package/sa_std/sync/poison.sal +11 -0
  238. package/sa_std/sync/prelude.sa +8 -0
  239. package/sa_std/sync/prelude.sal +7 -0
  240. package/sa_std/sync/rwlock.sa +369 -0
  241. package/sa_std/sync/rwlock.sal +13 -0
  242. package/sa_std/task.sa +2 -0
  243. package/sa_std/task.sal +1 -0
  244. package/sa_std/term.sa +2 -0
  245. package/sa_std/term.sai +10 -0
  246. package/sa_std/term.sal +33 -0
  247. package/sa_std/testing/assert.sai +4 -0
  248. package/sa_std/testing/mock_io.sa +174 -0
  249. package/sa_std/testing/mock_io.sal +5 -0
  250. package/sa_std/testing/prelude.sa +2 -0
  251. package/sa_std/testing/prelude.sal +1 -0
  252. package/sa_std/text/prelude.sa +1 -0
  253. package/sa_std/text/prelude.sal +1 -0
  254. package/sa_std/text/regex.sa +2 -0
  255. package/sa_std/text/regex.sai +9 -0
  256. package/sa_std/text/regex.sal +33 -0
  257. package/sa_std/thread/join_handle.sa +3 -0
  258. package/sa_std/thread/join_handle.sal +1 -0
  259. package/sa_std/thread/prelude.sa +4 -0
  260. package/sa_std/thread/prelude.sal +3 -0
  261. package/sa_std/thread.sa +160 -0
  262. package/sa_std/thread.sai +11 -0
  263. package/sa_std/thread.sal +4 -0
  264. package/sa_std/thread_local.sa +45 -0
  265. package/sa_std/thread_local.sai +9 -0
  266. package/sa_std/time/duration.sa +3 -0
  267. package/sa_std/time/duration.sal +1 -0
  268. package/sa_std/time/instant.sa +3 -0
  269. package/sa_std/time/instant.sal +1 -0
  270. package/sa_std/time/prelude.sa +4 -0
  271. package/sa_std/time/prelude.sal +4 -0
  272. package/sa_std/time.sa +850 -0
  273. package/sa_std/time.sai +37 -0
  274. package/sa_std/time.sal +35 -0
  275. package/sa_std/time.sla +67 -0
  276. package/sa_std/tls_client.sai +39 -0
  277. package/sa_std/vec.sa +5754 -0
  278. package/sa_std/vec.sal +1 -0
  279. package/sa_std/vec_deque.sa +4925 -0
  280. package/sa_std/vec_deque.sal +8 -0
  281. package/sa_std/vec_runtime_macros.sa +11 -0
  282. package/sa_std/ws_client.sai +57 -0
@@ -0,0 +1,11 @@
1
+ #def Option_SIZE = 16
2
+ #def Option_tag = +0
3
+ #def Option_value = +8
4
+ #def Option_NONE = 0
5
+ #def Option_SOME = 1
6
+
7
+
8
+ #def OptionPairU64_SIZE = 24
9
+ #def OptionPairU64_tag = +0
10
+ #def OptionPairU64_value1 = +8
11
+ #def OptionPairU64_value2 = +16
@@ -0,0 +1,23 @@
1
+ [MACRO] PANIC %code
2
+ panic(%code)
3
+ [END_MACRO]
4
+
5
+ [MACRO] PANIC_MSG %code, %msg_ptr, %msg_len
6
+ panic_msg(%code, %msg_ptr, %msg_len)
7
+ [END_MACRO]
8
+
9
+ @const TODO_PANIC = utf8:"called todo!() in SA"
10
+ @const UNIMPLEMENTED_PANIC = utf8:"called unimplemented!() in SA"
11
+ @const UNREACHABLE_PANIC = utf8:"entered unreachable!() in SA"
12
+
13
+ [MACRO] TODO
14
+ EXPAND PANIC_MSG 102, *TODO_PANIC, 20
15
+ [END_MACRO]
16
+
17
+ [MACRO] UNIMPLEMENTED
18
+ EXPAND PANIC_MSG 102, *UNIMPLEMENTED_PANIC, 29
19
+ [END_MACRO]
20
+
21
+ [MACRO] UNREACHABLE
22
+ EXPAND PANIC_MSG 102, *UNREACHABLE_PANIC, 28
23
+ [END_MACRO]
@@ -0,0 +1,12 @@
1
+ #def PanicLocation_SIZE = 24
2
+ #def PanicLocation_ALIGN = 8
3
+ #def PanicLocation_file = +0
4
+ #def PanicLocation_file_ptr = +0
5
+ #def PanicLocation_file_len = +8
6
+ #def PanicLocation_line = +16
7
+ #def PanicLocation_column = +20
8
+ #def PanicLocation_col = PanicLocation_column
9
+
10
+ #def AssertUnwindSafeU64_SIZE = 8
11
+ #def AssertUnwindSafeU64_ALIGN = 8
12
+ #def AssertUnwindSafeU64_value = +0
@@ -0,0 +1,18 @@
1
+ @import "sa_core.sa"
2
+ @import "arc.sa"
3
+ @import "ascii.sa"
4
+ @import "box.sa"
5
+ @import "cell.sa"
6
+ @import "derive.sa"
7
+ @import "dispatch.sa"
8
+ @import "future.sa"
9
+ @import "iter.sa"
10
+ @import "option.sa"
11
+ @import "panic.sa"
12
+ @import "rc.sa"
13
+ @import "refcell.sa"
14
+ @import "result.sa"
15
+ @import "task.sa"
16
+ @import "trait_object.sa"
17
+ @import "waker.sa"
18
+ @import "weak.sa"
@@ -0,0 +1,18 @@
1
+ @import "sa_core.sa"
2
+ @import "arc.sal"
3
+ @import "ascii.sal"
4
+ @import "box.sal"
5
+ @import "cell.sal"
6
+ @import "derive.sal"
7
+ @import "dispatch.sal"
8
+ @import "future.sal"
9
+ @import "iter.sal"
10
+ @import "option.sal"
11
+ @import "panic.sal"
12
+ @import "rc.sal"
13
+ @import "refcell.sal"
14
+ @import "result.sal"
15
+ @import "task.sal"
16
+ @import "trait_object.sal"
17
+ @import "waker.sal"
18
+ @import "weak.sal"
@@ -0,0 +1,225 @@
1
+ @import "rc.sal"
2
+
3
+ [MACRO] RC_NEW %out_rc, %value
4
+ %out_rc = alloc RcBox_SIZE
5
+ store %out_rc+RcBox_strong, 1 as u64
6
+ store %out_rc+RcBox_weak, 1 as u64
7
+ store %out_rc+RcBox_data, %value as u64
8
+ [END_MACRO]
9
+
10
+ // Rust-style Default for concrete Rc<u64>: Rc::new(0).
11
+ [MACRO] RC_DEFAULT_U64 %out_rc
12
+ EXPAND RC_NEW %out_rc, 0
13
+ [END_MACRO]
14
+
15
+ // Rust method-name alias over RC_DEFAULT_U64.
16
+ [MACRO] RC_DEFAULT %out_rc
17
+ EXPAND RC_DEFAULT_U64 %out_rc
18
+ [END_MACRO]
19
+
20
+ [MACRO] RC_CLONE %rc_reg
21
+ __rc_strong_%rc_reg = load %rc_reg+RcBox_strong as u64
22
+ __rc_next_strong_%rc_reg = add __rc_strong_%rc_reg, 1
23
+ store %rc_reg+RcBox_strong, __rc_next_strong_%rc_reg as u64
24
+ !__rc_next_strong_%rc_reg
25
+ !__rc_strong_%rc_reg
26
+ [END_MACRO]
27
+
28
+ [MACRO] RC_CLONE_OUT %out_rc, %rc_reg
29
+ %out_rc = add %rc_reg, 0
30
+ EXPAND RC_CLONE %out_rc
31
+ [END_MACRO]
32
+
33
+ [MACRO] RC_GET %out_value, %rc_reg
34
+ %out_value = load %rc_reg+RcBox_data as u64
35
+ [END_MACRO]
36
+
37
+ [MACRO] RC_AS_PTR %out_ptr, %rc_reg
38
+ %out_ptr = ptr_add %rc_reg, RcBox_data
39
+ [END_MACRO]
40
+
41
+ [MACRO] RC_INTO_RAW %out_ptr, %rc_reg
42
+ %out_ptr = ptr_add %rc_reg, RcBox_data
43
+ [END_MACRO]
44
+
45
+ [MACRO] RC_FROM_RAW %out_rc, %raw_ptr
46
+ %out_rc = sub %raw_ptr, RcBox_data
47
+ [END_MACRO]
48
+
49
+ [MACRO] RC_INCREMENT_STRONG_COUNT %raw_ptr
50
+ __rc_inc_box_%raw_ptr = sub %raw_ptr, RcBox_data
51
+ __rc_inc_count_%raw_ptr = load __rc_inc_box_%raw_ptr+RcBox_strong as u64
52
+ __rc_inc_next_%raw_ptr = add __rc_inc_count_%raw_ptr, 1
53
+ store __rc_inc_box_%raw_ptr+RcBox_strong, __rc_inc_next_%raw_ptr as u64
54
+ !__rc_inc_next_%raw_ptr
55
+ !__rc_inc_count_%raw_ptr
56
+ !__rc_inc_box_%raw_ptr
57
+ [END_MACRO]
58
+
59
+ [MACRO] RC_DECREMENT_STRONG_COUNT %raw_ptr
60
+ __rc_dec_box_%raw_ptr = sub %raw_ptr, RcBox_data
61
+ __rc_dec_count_%raw_ptr = load __rc_dec_box_%raw_ptr+RcBox_strong as u64
62
+ __rc_dec_next_%raw_ptr = sub __rc_dec_count_%raw_ptr, 1
63
+ store __rc_dec_box_%raw_ptr+RcBox_strong, __rc_dec_next_%raw_ptr as u64
64
+ !__rc_dec_next_%raw_ptr
65
+ !__rc_dec_count_%raw_ptr
66
+ !__rc_dec_box_%raw_ptr
67
+ [END_MACRO]
68
+
69
+ [MACRO] RC_STRONG_COUNT %out_count, %rc_reg
70
+ %out_count = load %rc_reg+RcBox_strong as u64
71
+ [END_MACRO]
72
+
73
+ [MACRO] RC_WEAK_COUNT %out_count, %rc_reg
74
+ __rc_weak_total_%out_count = load %rc_reg+RcBox_weak as u64
75
+ %out_count = sub __rc_weak_total_%out_count, 1
76
+ !__rc_weak_total_%out_count
77
+ [END_MACRO]
78
+
79
+ [MACRO] RC_PTR_EQ %out_bool, %left_rc, %right_rc
80
+ %out_bool = eq %left_rc, %right_rc
81
+ [END_MACRO]
82
+
83
+ [MACRO] RC_GET_MUT %out_ok, %out_ptr, %rc_reg
84
+ __rc_mut_strong_%out_ok = load %rc_reg+RcBox_strong as u64
85
+ __rc_mut_weak_%out_ok = load %rc_reg+RcBox_weak as u64
86
+ __rc_mut_strong_one_%out_ok = eq __rc_mut_strong_%out_ok, 1
87
+ __rc_mut_weak_one_%out_ok = eq __rc_mut_weak_%out_ok, 1
88
+ __rc_mut_unique_%out_ok = and __rc_mut_strong_one_%out_ok, __rc_mut_weak_one_%out_ok
89
+ br __rc_mut_unique_%out_ok -> L_RC_GET_MUT_OK_%out_ok, L_RC_GET_MUT_FAIL_%out_ok
90
+ L_RC_GET_MUT_OK_%out_ok:
91
+ %out_ptr = ptr_add %rc_reg, RcBox_data
92
+ %out_ok = add 0, 1
93
+ jmp L_RC_GET_MUT_DONE_%out_ok
94
+ L_RC_GET_MUT_FAIL_%out_ok:
95
+ %out_ptr = 0 as ptr
96
+ %out_ok = add 0, 0
97
+ L_RC_GET_MUT_DONE_%out_ok:
98
+ !__rc_mut_unique_%out_ok
99
+ !__rc_mut_weak_one_%out_ok
100
+ !__rc_mut_strong_one_%out_ok
101
+ !__rc_mut_weak_%out_ok
102
+ !__rc_mut_strong_%out_ok
103
+ [END_MACRO]
104
+
105
+ [MACRO] RC_TRY_UNWRAP %out_ok, %out_value, %rc_reg
106
+ __rc_unwrap_strong_%out_ok = load %rc_reg+RcBox_strong as u64
107
+ __rc_unwrap_unique_%out_ok = eq __rc_unwrap_strong_%out_ok, 1
108
+ br __rc_unwrap_unique_%out_ok -> L_RC_TRY_UNWRAP_OK_%out_ok, L_RC_TRY_UNWRAP_FAIL_%out_ok
109
+ L_RC_TRY_UNWRAP_OK_%out_ok:
110
+ %out_value = load %rc_reg+RcBox_data as u64
111
+ %out_ok = add 0, 1
112
+ jmp L_RC_TRY_UNWRAP_DONE_%out_ok
113
+ L_RC_TRY_UNWRAP_FAIL_%out_ok:
114
+ %out_value = add 0, 0
115
+ %out_ok = add 0, 0
116
+ L_RC_TRY_UNWRAP_DONE_%out_ok:
117
+ !__rc_unwrap_unique_%out_ok
118
+ !__rc_unwrap_strong_%out_ok
119
+ [END_MACRO]
120
+
121
+ [MACRO] RC_MAKE_MUT_U64 %out_ptr, %rc_reg
122
+ %out_ptr = ptr_add %rc_reg, RcBox_data
123
+ [END_MACRO]
124
+
125
+ // Rust method-name alias over RC_MAKE_MUT_U64.
126
+ [MACRO] RC_MAKE_MUT %out_ptr, %rc_reg
127
+ EXPAND RC_MAKE_MUT_U64 %out_ptr, %rc_reg
128
+ [END_MACRO]
129
+
130
+ [MACRO] RC_UNWRAP_OR_CLONE_U64 %out_value, %rc_reg
131
+ %out_value = load %rc_reg+RcBox_data as u64
132
+ [END_MACRO]
133
+
134
+ // Rust method-name alias over RC_UNWRAP_OR_CLONE_U64.
135
+ [MACRO] RC_UNWRAP_OR_CLONE %out_value, %rc_reg
136
+ EXPAND RC_UNWRAP_OR_CLONE_U64 %out_value, %rc_reg
137
+ [END_MACRO]
138
+
139
+ [MACRO] RC_DROP %rc_reg, %cleanup_label
140
+ __rc_strong_%rc_reg = load %rc_reg+RcBox_strong as u64
141
+ __rc_next_strong_%rc_reg = sub __rc_strong_%rc_reg, 1
142
+ store %rc_reg+RcBox_strong, __rc_next_strong_%rc_reg as u64
143
+ __rc_is_last_%rc_reg = eq __rc_next_strong_%rc_reg, 0
144
+ br __rc_is_last_%rc_reg -> %cleanup_label, L_RC_DROP_DONE_%rc_reg
145
+ L_RC_DROP_DONE_%rc_reg:
146
+ !__rc_is_last_%rc_reg
147
+ !__rc_next_strong_%rc_reg
148
+ !__rc_strong_%rc_reg
149
+ [END_MACRO]
150
+
151
+ [MACRO] RC_DOWNGRADE %out_weak, %rc_reg
152
+ __rc_weak_%out_weak = load %rc_reg+RcBox_weak as u64
153
+ __rc_next_weak_%out_weak = add __rc_weak_%out_weak, 1
154
+ store %rc_reg+RcBox_weak, __rc_next_weak_%out_weak as u64
155
+ %out_weak = add %rc_reg, 0
156
+ !__rc_next_weak_%out_weak
157
+ !__rc_weak_%out_weak
158
+ [END_MACRO]
159
+
160
+ [MACRO] WEAK_CLONE %weak_reg
161
+ __weak_count_%weak_reg = load %weak_reg+RcBox_weak as u64
162
+ __weak_next_%weak_reg = add __weak_count_%weak_reg, 1
163
+ store %weak_reg+RcBox_weak, __weak_next_%weak_reg as u64
164
+ !__weak_next_%weak_reg
165
+ !__weak_count_%weak_reg
166
+ [END_MACRO]
167
+
168
+ [MACRO] WEAK_NEW %out_weak
169
+ %out_weak = alloc RcBox_SIZE
170
+ store %out_weak+RcBox_strong, 0 as u64
171
+ store %out_weak+RcBox_weak, 1 as u64
172
+ store %out_weak+RcBox_data, 0 as u64
173
+ [END_MACRO]
174
+
175
+ // Rust-style Default alias for Weak::new().
176
+ [MACRO] WEAK_DEFAULT %out_weak
177
+ EXPAND WEAK_NEW %out_weak
178
+ [END_MACRO]
179
+
180
+ [MACRO] WEAK_STRONG_COUNT %out_count, %weak_reg
181
+ %out_count = load %weak_reg+RcBox_strong as u64
182
+ [END_MACRO]
183
+
184
+ [MACRO] WEAK_WEAK_COUNT %out_count, %weak_reg
185
+ __weak_total_%out_count = load %weak_reg+RcBox_weak as u64
186
+ %out_count = sub __weak_total_%out_count, 1
187
+ !__weak_total_%out_count
188
+ [END_MACRO]
189
+
190
+ [MACRO] WEAK_PTR_EQ %out_bool, %left_weak, %right_weak
191
+ %out_bool = eq %left_weak, %right_weak
192
+ [END_MACRO]
193
+
194
+ [MACRO] WEAK_DROP %weak_reg, %free_label
195
+ __weak_count_%weak_reg = load %weak_reg+RcBox_weak as u64
196
+ __weak_next_count_%weak_reg = sub __weak_count_%weak_reg, 1
197
+ store %weak_reg+RcBox_weak, __weak_next_count_%weak_reg as u64
198
+ __weak_is_last_%weak_reg = eq __weak_next_count_%weak_reg, 0
199
+ br __weak_is_last_%weak_reg -> %free_label, L_WEAK_DROP_DONE_%weak_reg
200
+ L_WEAK_DROP_DONE_%weak_reg:
201
+ !__weak_is_last_%weak_reg
202
+ !__weak_next_count_%weak_reg
203
+ !__weak_count_%weak_reg
204
+ [END_MACRO]
205
+
206
+ [MACRO] WEAK_UPGRADE %out_rc, %out_ok, %weak_reg
207
+ __weak_strong_%out_rc = load %weak_reg+RcBox_strong as u64
208
+ __weak_is_alive_%out_rc = ne __weak_strong_%out_rc, 0
209
+ br __weak_is_alive_%out_rc -> L_WEAK_UPGRADE_OK_%out_rc, L_WEAK_UPGRADE_NONE_%out_rc
210
+ L_WEAK_UPGRADE_OK_%out_rc:
211
+ __weak_next_strong_%out_rc = add __weak_strong_%out_rc, 1
212
+ store %weak_reg+RcBox_strong, __weak_next_strong_%out_rc as u64
213
+ %out_rc = add %weak_reg, 0
214
+ %out_ok = add 0, 1
215
+ !__weak_next_strong_%out_rc
216
+ !__weak_is_alive_%out_rc
217
+ !__weak_strong_%out_rc
218
+ jmp L_WEAK_UPGRADE_END_%out_rc
219
+ L_WEAK_UPGRADE_NONE_%out_rc:
220
+ %out_rc = add 0, 0
221
+ %out_ok = add 0, 0
222
+ !__weak_is_alive_%out_rc
223
+ !__weak_strong_%out_rc
224
+ L_WEAK_UPGRADE_END_%out_rc:
225
+ [END_MACRO]
@@ -0,0 +1,4 @@
1
+ #def RcBox_SIZE = 24
2
+ #def RcBox_strong = +0
3
+ #def RcBox_weak = +8
4
+ #def RcBox_data = +16
@@ -0,0 +1,283 @@
1
+ @import "refcell.sal"
2
+
3
+ // RefCell borrow counts are intentionally non-atomic and mirror Rust's !Sync shape.
4
+ // Do not share RefCell storage across threads; use Arc plus atomic or lock-backed state instead.
5
+
6
+ [MACRO] REFCELL_NEW %out_cell, %value
7
+ %out_cell = alloc RefCell_SIZE
8
+ store %out_cell+RefCell_value, %value as u64
9
+ store %out_cell+RefCell_borrows, 0 as u64
10
+ [END_MACRO]
11
+
12
+ [MACRO] REFCELL_DEFAULT %out_cell
13
+ %out_cell = alloc RefCell_SIZE
14
+ store %out_cell+RefCell_value, 0 as u64
15
+ store %out_cell+RefCell_borrows, 0 as u64
16
+ [END_MACRO]
17
+
18
+ [MACRO] REFCELL_BORROW %out_ok, %out_borrow, %cell_reg, %err_label
19
+ __refcell_borrows_%out_ok = load %cell_reg+RefCell_borrows as i64
20
+ __refcell_can_share_%out_ok = sge __refcell_borrows_%out_ok, 0
21
+ br __refcell_can_share_%out_ok -> L_REFCELL_BORROW_OK_%out_ok, L_REFCELL_BORROW_FAIL_%out_ok
22
+ L_REFCELL_BORROW_OK_%out_ok:
23
+ __refcell_next_borrows_%out_ok = add __refcell_borrows_%out_ok, 1
24
+ store %cell_reg+RefCell_borrows, __refcell_next_borrows_%out_ok as u64
25
+ %out_borrow = add %cell_reg, 0
26
+ %out_ok = add 0, 1
27
+ !__refcell_next_borrows_%out_ok
28
+ !__refcell_can_share_%out_ok
29
+ !__refcell_borrows_%out_ok
30
+ jmp L_REFCELL_BORROW_END_%out_ok
31
+ L_REFCELL_BORROW_FAIL_%out_ok:
32
+ %out_borrow = add 0, 0
33
+ %out_ok = add 0, 0
34
+ !__refcell_can_share_%out_ok
35
+ !__refcell_borrows_%out_ok
36
+ jmp %err_label
37
+ L_REFCELL_BORROW_END_%out_ok:
38
+ [END_MACRO]
39
+
40
+ [MACRO] REFCELL_BORROW_MUT %out_ok, %out_borrow, %cell_reg, %err_label
41
+ __refcell_borrows_%out_ok = load %cell_reg+RefCell_borrows as i64
42
+ __refcell_is_free_%out_ok = eq __refcell_borrows_%out_ok, 0
43
+ br __refcell_is_free_%out_ok -> L_REFCELL_BORROW_MUT_OK_%out_ok, L_REFCELL_BORROW_MUT_FAIL_%out_ok
44
+ L_REFCELL_BORROW_MUT_OK_%out_ok:
45
+ __refcell_next_borrows_%out_ok = sub 0, 1
46
+ store %cell_reg+RefCell_borrows, __refcell_next_borrows_%out_ok as u64
47
+ %out_borrow = add %cell_reg, 0
48
+ %out_ok = add 0, 1
49
+ !__refcell_next_borrows_%out_ok
50
+ !__refcell_is_free_%out_ok
51
+ !__refcell_borrows_%out_ok
52
+ jmp L_REFCELL_BORROW_MUT_END_%out_ok
53
+ L_REFCELL_BORROW_MUT_FAIL_%out_ok:
54
+ %out_borrow = add 0, 0
55
+ %out_ok = add 0, 0
56
+ !__refcell_is_free_%out_ok
57
+ !__refcell_borrows_%out_ok
58
+ jmp %err_label
59
+ L_REFCELL_BORROW_MUT_END_%out_ok:
60
+ [END_MACRO]
61
+
62
+ [MACRO] REFCELL_RELEASE %cell_reg
63
+ __refcell_borrows_%cell_reg = load %cell_reg+RefCell_borrows as i64
64
+ __refcell_is_mut_%cell_reg = eq __refcell_borrows_%cell_reg, -1
65
+ br __refcell_is_mut_%cell_reg -> L_REFCELL_RELEASE_MUT_%cell_reg, L_REFCELL_RELEASE_SHARED_%cell_reg
66
+ L_REFCELL_RELEASE_MUT_%cell_reg:
67
+ __refcell_next_borrows_%cell_reg = add 0, 0
68
+ store %cell_reg+RefCell_borrows, 0 as u64
69
+ jmp L_REFCELL_RELEASE_END_%cell_reg
70
+ L_REFCELL_RELEASE_SHARED_%cell_reg:
71
+ __refcell_next_borrows_%cell_reg = sub __refcell_borrows_%cell_reg, 1
72
+ store %cell_reg+RefCell_borrows, __refcell_next_borrows_%cell_reg as u64
73
+ L_REFCELL_RELEASE_END_%cell_reg:
74
+ !__refcell_next_borrows_%cell_reg
75
+ !__refcell_is_mut_%cell_reg
76
+ !__refcell_borrows_%cell_reg
77
+ [END_MACRO]
78
+
79
+ [MACRO] REFCELL_GET %out_value, %cell_reg
80
+ %out_value = load %cell_reg+RefCell_value as u64
81
+ [END_MACRO]
82
+
83
+ [MACRO] REFCELL_SET %cell_reg, %value
84
+ store %cell_reg+RefCell_value, %value as u64
85
+ [END_MACRO]
86
+
87
+ [MACRO] REFCELL_U64_NEW %out_cell, %value
88
+ %out_cell = alloc RefCellU64_SIZE
89
+ store %out_cell+RefCellU64_value, %value as u64
90
+ store %out_cell+RefCellU64_borrows, 0 as i64
91
+ [END_MACRO]
92
+
93
+ // Rust-style Default for concrete RefCell<u64>: value 0, free borrow state.
94
+ [MACRO] REFCELL_U64_DEFAULT %out_cell
95
+ EXPAND REFCELL_U64_NEW %out_cell, 0
96
+ [END_MACRO]
97
+
98
+ [MACRO] REFCELL_U64_BORROW_COUNT %out_count, %cell_reg
99
+ %out_count = load %cell_reg+RefCellU64_borrows as i64
100
+ [END_MACRO]
101
+
102
+ [MACRO] REFCELL_U64_IS_BORROWED %out_bool, %cell_reg
103
+ __refcell_u64_count_%out_bool = load %cell_reg+RefCellU64_borrows as i64
104
+ %out_bool = ne __refcell_u64_count_%out_bool, 0
105
+ !__refcell_u64_count_%out_bool
106
+ [END_MACRO]
107
+
108
+ [MACRO] REFCELL_U64_TRY_BORROW %out_ok, %out_ptr, %cell_reg
109
+ __refcell_u64_borrows_%out_ok = load %cell_reg+RefCellU64_borrows as i64
110
+ __refcell_u64_can_share_%out_ok = sge __refcell_u64_borrows_%out_ok, 0
111
+ br __refcell_u64_can_share_%out_ok -> L_REFCELL_U64_BORROW_OK_%out_ok, L_REFCELL_U64_BORROW_FAIL_%out_ok
112
+ L_REFCELL_U64_BORROW_OK_%out_ok:
113
+ __refcell_u64_next_%out_ok = add __refcell_u64_borrows_%out_ok, 1
114
+ store %cell_reg+RefCellU64_borrows, __refcell_u64_next_%out_ok as i64
115
+ %out_ptr = ptr_add %cell_reg, RefCellU64_value
116
+ %out_ok = add 0, 1
117
+ !__refcell_u64_next_%out_ok
118
+ !__refcell_u64_can_share_%out_ok
119
+ !__refcell_u64_borrows_%out_ok
120
+ jmp L_REFCELL_U64_BORROW_END_%out_ok
121
+ L_REFCELL_U64_BORROW_FAIL_%out_ok:
122
+ %out_ptr = 0 as ptr
123
+ %out_ok = add 0, 0
124
+ !__refcell_u64_can_share_%out_ok
125
+ !__refcell_u64_borrows_%out_ok
126
+ L_REFCELL_U64_BORROW_END_%out_ok:
127
+ [END_MACRO]
128
+
129
+ [MACRO] REFCELL_U64_TRY_BORROW_MUT %out_ok, %out_ptr, %cell_reg
130
+ __refcell_u64_mut_borrows_%out_ok = load %cell_reg+RefCellU64_borrows as i64
131
+ __refcell_u64_mut_free_%out_ok = eq __refcell_u64_mut_borrows_%out_ok, 0
132
+ br __refcell_u64_mut_free_%out_ok -> L_REFCELL_U64_BORROW_MUT_OK_%out_ok, L_REFCELL_U64_BORROW_MUT_FAIL_%out_ok
133
+ L_REFCELL_U64_BORROW_MUT_OK_%out_ok:
134
+ store %cell_reg+RefCellU64_borrows, -1 as i64
135
+ %out_ptr = ptr_add %cell_reg, RefCellU64_value
136
+ %out_ok = add 0, 1
137
+ !__refcell_u64_mut_free_%out_ok
138
+ !__refcell_u64_mut_borrows_%out_ok
139
+ jmp L_REFCELL_U64_BORROW_MUT_END_%out_ok
140
+ L_REFCELL_U64_BORROW_MUT_FAIL_%out_ok:
141
+ %out_ptr = 0 as ptr
142
+ %out_ok = add 0, 0
143
+ !__refcell_u64_mut_free_%out_ok
144
+ !__refcell_u64_mut_borrows_%out_ok
145
+ L_REFCELL_U64_BORROW_MUT_END_%out_ok:
146
+ [END_MACRO]
147
+
148
+ [MACRO] REFCELL_U64_RELEASE_SHARED %cell_reg
149
+ __refcell_u64_shared_%cell_reg = load %cell_reg+RefCellU64_borrows as i64
150
+ __refcell_u64_next_%cell_reg = sub __refcell_u64_shared_%cell_reg, 1
151
+ store %cell_reg+RefCellU64_borrows, __refcell_u64_next_%cell_reg as i64
152
+ !__refcell_u64_next_%cell_reg
153
+ !__refcell_u64_shared_%cell_reg
154
+ [END_MACRO]
155
+
156
+ [MACRO] REFCELL_U64_RELEASE_MUT %cell_reg
157
+ store %cell_reg+RefCellU64_borrows, 0 as i64
158
+ [END_MACRO]
159
+
160
+ [MACRO] REFCELL_U64_GET %out_value, %cell_reg
161
+ %out_value = load %cell_reg+RefCellU64_value as u64
162
+ [END_MACRO]
163
+
164
+ [MACRO] REFCELL_U64_SET %cell_reg, %value
165
+ store %cell_reg+RefCellU64_value, %value as u64
166
+ [END_MACRO]
167
+
168
+ [MACRO] REFCELL_U64_REPLACE %out_old, %cell_reg, %value
169
+ %out_old = load %cell_reg+RefCellU64_value as u64
170
+ store %cell_reg+RefCellU64_value, %value as u64
171
+ [END_MACRO]
172
+
173
+ [MACRO] REFCELL_U64_TRY_REPLACE %out_ok, %out_old, %cell_reg, %value
174
+ __refcell_u64_replace_borrows_%out_ok = load %cell_reg+RefCellU64_borrows as i64
175
+ __refcell_u64_replace_free_%out_ok = eq __refcell_u64_replace_borrows_%out_ok, 0
176
+ br __refcell_u64_replace_free_%out_ok -> L_REFCELL_U64_REPLACE_OK_%out_ok, L_REFCELL_U64_REPLACE_FAIL_%out_ok
177
+
178
+ L_REFCELL_U64_REPLACE_OK_%out_ok:
179
+ EXPAND REFCELL_U64_REPLACE %out_old, %cell_reg, %value
180
+ %out_ok = add 0, 1
181
+ !__refcell_u64_replace_free_%out_ok
182
+ !__refcell_u64_replace_borrows_%out_ok
183
+ jmp L_REFCELL_U64_REPLACE_END_%out_ok
184
+
185
+ L_REFCELL_U64_REPLACE_FAIL_%out_ok:
186
+ %out_old = add 0, 0
187
+ %out_ok = add 0, 0
188
+ !__refcell_u64_replace_free_%out_ok
189
+ !__refcell_u64_replace_borrows_%out_ok
190
+
191
+ L_REFCELL_U64_REPLACE_END_%out_ok:
192
+ [END_MACRO]
193
+
194
+ [MACRO] REFCELL_U64_TAKE %out_old, %cell_reg
195
+ %out_old = load %cell_reg+RefCellU64_value as u64
196
+ store %cell_reg+RefCellU64_value, 0 as u64
197
+ [END_MACRO]
198
+
199
+ [MACRO] REFCELL_U64_TRY_TAKE %out_ok, %out_old, %cell_reg
200
+ EXPAND REFCELL_U64_TRY_REPLACE %out_ok, %out_old, %cell_reg, 0
201
+ [END_MACRO]
202
+
203
+ [MACRO] REFCELL_U64_SWAP %left_cell, %right_cell
204
+ __refcell_u64_swap_left_%left_cell = load %left_cell+RefCellU64_value as u64
205
+ __refcell_u64_swap_right_%left_cell = load %right_cell+RefCellU64_value as u64
206
+ store %left_cell+RefCellU64_value, __refcell_u64_swap_right_%left_cell as u64
207
+ store %right_cell+RefCellU64_value, __refcell_u64_swap_left_%left_cell as u64
208
+ !__refcell_u64_swap_right_%left_cell
209
+ !__refcell_u64_swap_left_%left_cell
210
+ [END_MACRO]
211
+
212
+ [MACRO] REFCELL_U64_TRY_SWAP %out_ok, %left_cell, %right_cell
213
+ __refcell_u64_swap_left_borrows_%out_ok = load %left_cell+RefCellU64_borrows as i64
214
+ __refcell_u64_swap_right_borrows_%out_ok = load %right_cell+RefCellU64_borrows as i64
215
+ __refcell_u64_swap_left_free_%out_ok = eq __refcell_u64_swap_left_borrows_%out_ok, 0
216
+ __refcell_u64_swap_right_free_%out_ok = eq __refcell_u64_swap_right_borrows_%out_ok, 0
217
+ __refcell_u64_swap_can_%out_ok = and __refcell_u64_swap_left_free_%out_ok, __refcell_u64_swap_right_free_%out_ok
218
+ br __refcell_u64_swap_can_%out_ok -> L_REFCELL_U64_SWAP_OK_%out_ok, L_REFCELL_U64_SWAP_FAIL_%out_ok
219
+
220
+ L_REFCELL_U64_SWAP_OK_%out_ok:
221
+ EXPAND REFCELL_U64_SWAP %left_cell, %right_cell
222
+ %out_ok = add 0, 1
223
+ !__refcell_u64_swap_can_%out_ok
224
+ !__refcell_u64_swap_right_free_%out_ok
225
+ !__refcell_u64_swap_left_free_%out_ok
226
+ !__refcell_u64_swap_right_borrows_%out_ok
227
+ !__refcell_u64_swap_left_borrows_%out_ok
228
+ jmp L_REFCELL_U64_SWAP_END_%out_ok
229
+
230
+ L_REFCELL_U64_SWAP_FAIL_%out_ok:
231
+ %out_ok = add 0, 0
232
+ !__refcell_u64_swap_can_%out_ok
233
+ !__refcell_u64_swap_right_free_%out_ok
234
+ !__refcell_u64_swap_left_free_%out_ok
235
+ !__refcell_u64_swap_right_borrows_%out_ok
236
+ !__refcell_u64_swap_left_borrows_%out_ok
237
+
238
+ L_REFCELL_U64_SWAP_END_%out_ok:
239
+ [END_MACRO]
240
+
241
+ [MACRO] REFCELL_U64_UPDATE %out_old, %out_new, %cell_reg, %update_fn
242
+ %out_old = load %cell_reg+RefCellU64_value as u64
243
+ %out_new = call %update_fn(%out_old)
244
+ store %cell_reg+RefCellU64_value, %out_new as u64
245
+ [END_MACRO]
246
+
247
+ [MACRO] REFCELL_U64_REPLACE_WITH %out_old, %out_new, %cell_reg, %update_fn
248
+ EXPAND REFCELL_U64_UPDATE %out_old, %out_new, %cell_reg, %update_fn
249
+ [END_MACRO]
250
+
251
+ [MACRO] REFCELL_U64_TRY_REPLACE_WITH %out_ok, %out_old, %out_new, %cell_reg, %update_fn
252
+ __refcell_u64_replace_with_borrows_%out_ok = load %cell_reg+RefCellU64_borrows as i64
253
+ __refcell_u64_replace_with_free_%out_ok = eq __refcell_u64_replace_with_borrows_%out_ok, 0
254
+ br __refcell_u64_replace_with_free_%out_ok -> L_REFCELL_U64_REPLACE_WITH_OK_%out_ok, L_REFCELL_U64_REPLACE_WITH_FAIL_%out_ok
255
+
256
+ L_REFCELL_U64_REPLACE_WITH_OK_%out_ok:
257
+ EXPAND REFCELL_U64_REPLACE_WITH %out_old, %out_new, %cell_reg, %update_fn
258
+ %out_ok = add 0, 1
259
+ !__refcell_u64_replace_with_free_%out_ok
260
+ !__refcell_u64_replace_with_borrows_%out_ok
261
+ jmp L_REFCELL_U64_REPLACE_WITH_END_%out_ok
262
+
263
+ L_REFCELL_U64_REPLACE_WITH_FAIL_%out_ok:
264
+ %out_old = add 0, 0
265
+ %out_new = add 0, 0
266
+ %out_ok = add 0, 0
267
+ !__refcell_u64_replace_with_free_%out_ok
268
+ !__refcell_u64_replace_with_borrows_%out_ok
269
+
270
+ L_REFCELL_U64_REPLACE_WITH_END_%out_ok:
271
+ [END_MACRO]
272
+
273
+ [MACRO] REFCELL_U64_INTO_INNER %out_value, %cell_reg
274
+ %out_value = load %cell_reg+RefCellU64_value as u64
275
+ [END_MACRO]
276
+
277
+ [MACRO] REFCELL_U64_AS_PTR %out_ptr, %cell_reg
278
+ %out_ptr = ptr_add %cell_reg, RefCellU64_value
279
+ [END_MACRO]
280
+
281
+ [MACRO] REFCELL_U64_GET_MUT_PTR %out_ptr, %cell_reg
282
+ %out_ptr = ptr_add %cell_reg, RefCellU64_value
283
+ [END_MACRO]
@@ -0,0 +1,13 @@
1
+ #def RefCell_SIZE = 8
2
+ #def RefCell_value = +0
3
+ #def RefCell_borrows = +4
4
+
5
+ #def RefCellU64_SIZE = 16
6
+ #def RefCellU64_value = +0
7
+ #def RefCellU64_borrows = +8
8
+
9
+ #def BorrowError_SIZE = 0
10
+ #def BorrowError_ALIGN = 1
11
+
12
+ #def BorrowMutError_SIZE = 0
13
+ #def BorrowMutError_ALIGN = 1