@zigc/lib 0.16.0-test.1 → 0.17.0-dev.131

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 (352) hide show
  1. package/LICENSE +19 -0
  2. package/c/fcntl.zig +6 -1
  3. package/c/inttypes.zig +0 -10
  4. package/c/math.zig +138 -114
  5. package/c/pthread.zig +57 -0
  6. package/c/search.zig +1 -27
  7. package/c/stdlib/drand48.zig +0 -57
  8. package/c/stdlib.zig +0 -100
  9. package/c/string.zig +20 -7
  10. package/c/strings.zig +0 -38
  11. package/c/stropts.zig +17 -0
  12. package/c/unistd.zig +27 -26
  13. package/c/wchar.zig +10 -0
  14. package/c.zig +3 -2
  15. package/compiler/aro/aro/Attribute/names.zig +604 -589
  16. package/compiler/aro/aro/Attribute.zig +202 -116
  17. package/compiler/aro/aro/Builtins/common.zig +874 -863
  18. package/compiler/aro/aro/Builtins/eval.zig +15 -7
  19. package/compiler/aro/aro/Builtins.zig +0 -1
  20. package/compiler/aro/aro/CodeGen.zig +8 -7
  21. package/compiler/aro/aro/Compilation.zig +137 -111
  22. package/compiler/aro/aro/Diagnostics.zig +21 -17
  23. package/compiler/aro/aro/Driver/GCCDetector.zig +635 -0
  24. package/compiler/aro/aro/Driver.zig +138 -63
  25. package/compiler/aro/aro/LangOpts.zig +12 -2
  26. package/compiler/aro/aro/Parser/Diagnostic.zig +79 -19
  27. package/compiler/aro/aro/Parser.zig +352 -153
  28. package/compiler/aro/aro/Pragma.zig +3 -2
  29. package/compiler/aro/aro/Preprocessor/Diagnostic.zig +21 -0
  30. package/compiler/aro/aro/Preprocessor.zig +136 -62
  31. package/compiler/aro/aro/Target.zig +17 -12
  32. package/compiler/aro/aro/Tokenizer.zig +31 -14
  33. package/compiler/aro/aro/Toolchain.zig +4 -7
  34. package/compiler/aro/aro/Tree.zig +178 -148
  35. package/compiler/aro/aro/TypeStore.zig +82 -24
  36. package/compiler/aro/aro/Value.zig +13 -17
  37. package/compiler/aro/aro/features.zig +1 -0
  38. package/compiler/aro/aro/pragmas/message.zig +3 -2
  39. package/compiler/aro/aro/pragmas/once.zig +0 -1
  40. package/compiler/aro/aro/record_layout.zig +3 -3
  41. package/compiler/aro/aro/text_literal.zig +3 -2
  42. package/compiler/aro/assembly_backend/x86_64.zig +7 -8
  43. package/compiler/aro/backend/Assembly.zig +1 -2
  44. package/compiler/aro/backend/Interner.zig +2 -2
  45. package/compiler/aro/backend/Ir.zig +100 -92
  46. package/compiler/aro/include/ptrcheck.h +49 -0
  47. package/compiler/aro/main.zig +26 -10
  48. package/compiler/build_runner.zig +1 -2
  49. package/compiler/objdump.zig +93 -0
  50. package/compiler/reduce/Walk.zig +7 -7
  51. package/compiler/reduce.zig +5 -1
  52. package/compiler/resinator/compile.zig +2 -2
  53. package/compiler/resinator/main.zig +7 -1
  54. package/compiler/resinator/preprocess.zig +1 -3
  55. package/compiler/std-docs.zig +8 -1
  56. package/compiler/test_runner.zig +194 -62
  57. package/compiler/translate-c/MacroTranslator.zig +80 -11
  58. package/compiler/translate-c/PatternList.zig +1 -9
  59. package/compiler/translate-c/Scope.zig +43 -6
  60. package/compiler/translate-c/Translator.zig +369 -127
  61. package/compiler/translate-c/ast.zig +19 -11
  62. package/compiler/translate-c/main.zig +76 -17
  63. package/compiler_rt/cos.zig +140 -53
  64. package/compiler_rt/divmodei4.zig +40 -17
  65. package/compiler_rt/exp.zig +1 -6
  66. package/compiler_rt/exp2.zig +1 -6
  67. package/compiler_rt/exp_f128.zig +377 -0
  68. package/compiler_rt/fabs.zig +0 -2
  69. package/compiler_rt/fma.zig +0 -2
  70. package/compiler_rt/fmax.zig +0 -2
  71. package/compiler_rt/fmin.zig +0 -2
  72. package/compiler_rt/fmod.zig +0 -2
  73. package/compiler_rt/limb64.zig +1127 -0
  74. package/compiler_rt/log.zig +0 -2
  75. package/compiler_rt/log10.zig +0 -2
  76. package/compiler_rt/log2.zig +0 -2
  77. package/compiler_rt/long_double.zig +37 -0
  78. package/compiler_rt/mulXi3.zig +1 -1
  79. package/compiler_rt/mulo.zig +6 -1
  80. package/compiler_rt/rem_pio2l.zig +173 -0
  81. package/compiler_rt/round.zig +0 -2
  82. package/compiler_rt/sin.zig +139 -56
  83. package/compiler_rt/sincos.zig +277 -72
  84. package/compiler_rt/sqrt.zig +0 -2
  85. package/compiler_rt/ssp.zig +1 -1
  86. package/compiler_rt/tan.zig +117 -48
  87. package/compiler_rt/trig.zig +256 -6
  88. package/compiler_rt/trunc.zig +0 -2
  89. package/compiler_rt/udivmodei4.zig +28 -0
  90. package/compiler_rt.zig +2 -0
  91. package/fuzzer.zig +857 -307
  92. package/libc/musl/arch/mipsn32/syscall_arch.h +35 -32
  93. package/libc/musl/src/math/pow.c +343 -0
  94. package/package.json +1 -1
  95. package/std/Build/Cache.zig +6 -6
  96. package/std/Build/Fuzz.zig +6 -19
  97. package/std/Build/Module.zig +1 -1
  98. package/std/Build/Step/CheckObject.zig +3 -3
  99. package/std/Build/Step/Compile.zig +18 -1
  100. package/std/Build/Step/ConfigHeader.zig +49 -33
  101. package/std/Build/Step/InstallArtifact.zig +18 -0
  102. package/std/Build/Step/Run.zig +538 -89
  103. package/std/Build/Step/TranslateC.zig +0 -6
  104. package/std/Build/Step.zig +10 -19
  105. package/std/Build/WebServer.zig +31 -19
  106. package/std/Build/abi.zig +47 -11
  107. package/std/Build.zig +17 -17
  108. package/std/Io/Dir.zig +7 -2
  109. package/std/Io/Dispatch.zig +5 -13
  110. package/std/Io/File/Reader.zig +3 -1
  111. package/std/Io/File/Writer.zig +8 -6
  112. package/std/Io/File.zig +1 -0
  113. package/std/Io/Kqueue.zig +2 -2
  114. package/std/Io/Reader.zig +8 -9
  115. package/std/Io/Semaphore.zig +112 -17
  116. package/std/Io/Terminal.zig +1 -1
  117. package/std/Io/Threaded.zig +352 -180
  118. package/std/Io/Uring.zig +15 -16
  119. package/std/Io/Writer.zig +46 -42
  120. package/std/Io/net.zig +11 -11
  121. package/std/Io.zig +1052 -20
  122. package/std/SemanticVersion.zig +1 -1
  123. package/std/Target/Query.zig +2 -2
  124. package/std/Target.zig +53 -7
  125. package/std/Thread.zig +8 -3
  126. package/std/array_hash_map.zig +105 -573
  127. package/std/array_list.zig +22 -31
  128. package/std/bit_set.zig +22 -6
  129. package/std/builtin/assembly.zig +68 -0
  130. package/std/builtin.zig +4 -0
  131. package/std/c/haiku.zig +3 -0
  132. package/std/c/serenity.zig +1 -6
  133. package/std/c.zig +106 -24
  134. package/std/compress/flate/Compress.zig +3 -3
  135. package/std/compress/flate/Decompress.zig +2 -3
  136. package/std/compress/zstd/Decompress.zig +2 -4
  137. package/std/crypto/Certificate/Bundle.zig +15 -1
  138. package/std/crypto/Certificate.zig +13 -1
  139. package/std/crypto/ascon.zig +75 -33
  140. package/std/crypto/codecs/asn1/Oid.zig +12 -1
  141. package/std/crypto/codecs/asn1.zig +33 -18
  142. package/std/crypto/codecs/base64_hex_ct.zig +16 -8
  143. package/std/crypto/ml_kem.zig +2 -9
  144. package/std/crypto/tls/Client.zig +79 -4
  145. package/std/crypto/tls.zig +1 -1
  146. package/std/crypto.zig +1 -0
  147. package/std/debug/Dwarf.zig +29 -9
  148. package/std/debug/Info.zig +4 -0
  149. package/std/debug/MachOFile.zig +46 -8
  150. package/std/debug/Pdb.zig +540 -37
  151. package/std/debug/SelfInfo/Elf.zig +19 -18
  152. package/std/debug/SelfInfo/MachO.zig +18 -7
  153. package/std/debug/SelfInfo/Windows.zig +138 -36
  154. package/std/debug.zig +181 -66
  155. package/std/enums.zig +25 -19
  156. package/std/fmt.zig +8 -3
  157. package/std/fs/path.zig +6 -4
  158. package/std/heap/ArenaAllocator.zig +145 -154
  159. package/std/heap/BufferFirstAllocator.zig +165 -0
  160. package/std/heap/debug_allocator.zig +7 -7
  161. package/std/heap.zig +2 -126
  162. package/std/http/Client.zig +31 -30
  163. package/std/http.zig +14 -13
  164. package/std/json/Scanner.zig +2 -2
  165. package/std/json/Stringify.zig +3 -3
  166. package/std/json/dynamic.zig +4 -4
  167. package/std/math/big/int.zig +16 -17
  168. package/std/mem/Allocator.zig +4 -5
  169. package/std/mem.zig +48 -0
  170. package/std/os/emscripten.zig +2 -18
  171. package/std/os/linux/IoUring.zig +2 -0
  172. package/std/os/linux/aarch64.zig +41 -12
  173. package/std/os/linux/arc.zig +173 -0
  174. package/std/os/linux/arm.zig +41 -12
  175. package/std/os/linux/hexagon.zig +33 -11
  176. package/std/os/linux/loongarch32.zig +41 -13
  177. package/std/os/linux/loongarch64.zig +41 -12
  178. package/std/os/linux/m68k.zig +41 -13
  179. package/std/os/linux/mips.zig +67 -36
  180. package/std/os/linux/mips64.zig +60 -29
  181. package/std/os/linux/mipsn32.zig +60 -29
  182. package/std/os/linux/or1k.zig +41 -12
  183. package/std/os/linux/powerpc.zig +41 -12
  184. package/std/os/linux/powerpc64.zig +41 -12
  185. package/std/os/linux/riscv32.zig +41 -12
  186. package/std/os/linux/riscv64.zig +41 -12
  187. package/std/os/linux/s390x.zig +44 -7
  188. package/std/os/linux/sparc64.zig +83 -52
  189. package/std/os/linux/thumb.zig +52 -36
  190. package/std/os/linux/x32.zig +41 -12
  191. package/std/os/linux/x86.zig +42 -13
  192. package/std/os/linux/x86_64.zig +41 -12
  193. package/std/os/linux.zig +419 -438
  194. package/std/os/uefi/tables/boot_services.zig +9 -8
  195. package/std/os/windows.zig +2 -2
  196. package/std/os.zig +41 -0
  197. package/std/pdb.zig +143 -4
  198. package/std/posix.zig +6 -12
  199. package/std/priority_dequeue.zig +13 -12
  200. package/std/priority_queue.zig +5 -4
  201. package/std/process/Child.zig +1 -1
  202. package/std/process/Environ.zig +1 -1
  203. package/std/process.zig +1 -1
  204. package/std/sort.zig +3 -3
  205. package/std/start.zig +17 -4
  206. package/std/std.zig +19 -6
  207. package/std/testing/FailingAllocator.zig +4 -4
  208. package/std/testing/Smith.zig +37 -2
  209. package/std/zig/Ast/Render.zig +187 -459
  210. package/std/zig/Ast.zig +0 -4
  211. package/std/zig/AstGen.zig +86 -103
  212. package/std/zig/AstRlAnnotate.zig +0 -11
  213. package/std/zig/AstSmith.zig +2602 -0
  214. package/std/zig/BuiltinFn.zig +0 -32
  215. package/std/zig/Client.zig +8 -3
  216. package/std/zig/LibCInstallation.zig +4 -3
  217. package/std/zig/Parse.zig +90 -81
  218. package/std/zig/Server.zig +26 -0
  219. package/std/zig/WindowsSdk.zig +13 -13
  220. package/std/zig/Zir.zig +66 -62
  221. package/std/zig/ZonGen.zig +6 -5
  222. package/std/zig/c_translation/helpers.zig +14 -9
  223. package/std/zig/llvm/Builder.zig +119 -60
  224. package/std/zig/system.zig +20 -4
  225. package/std/zig/tokenizer.zig +2 -1
  226. package/std/zig.zig +7 -10
  227. package/std/zip.zig +5 -5
  228. package/zig.h +340 -1
  229. package/compiler/aro/aro/Driver/Filesystem.zig +0 -241
  230. package/libc/mingw/complex/cabs.c +0 -48
  231. package/libc/mingw/complex/cabsf.c +0 -48
  232. package/libc/mingw/complex/cacos.c +0 -50
  233. package/libc/mingw/complex/cacosf.c +0 -50
  234. package/libc/mingw/complex/carg.c +0 -48
  235. package/libc/mingw/complex/cargf.c +0 -48
  236. package/libc/mingw/complex/casin.c +0 -50
  237. package/libc/mingw/complex/casinf.c +0 -50
  238. package/libc/mingw/complex/catan.c +0 -50
  239. package/libc/mingw/complex/catanf.c +0 -50
  240. package/libc/mingw/complex/ccos.c +0 -50
  241. package/libc/mingw/complex/ccosf.c +0 -50
  242. package/libc/mingw/complex/cexp.c +0 -48
  243. package/libc/mingw/complex/cexpf.c +0 -48
  244. package/libc/mingw/complex/cimag.c +0 -48
  245. package/libc/mingw/complex/cimagf.c +0 -48
  246. package/libc/mingw/complex/clog.c +0 -48
  247. package/libc/mingw/complex/clog10.c +0 -49
  248. package/libc/mingw/complex/clog10f.c +0 -49
  249. package/libc/mingw/complex/clogf.c +0 -48
  250. package/libc/mingw/complex/conj.c +0 -48
  251. package/libc/mingw/complex/conjf.c +0 -48
  252. package/libc/mingw/complex/cpow.c +0 -48
  253. package/libc/mingw/complex/cpowf.c +0 -48
  254. package/libc/mingw/complex/cproj.c +0 -48
  255. package/libc/mingw/complex/cprojf.c +0 -48
  256. package/libc/mingw/complex/creal.c +0 -48
  257. package/libc/mingw/complex/crealf.c +0 -48
  258. package/libc/mingw/complex/csin.c +0 -50
  259. package/libc/mingw/complex/csinf.c +0 -50
  260. package/libc/mingw/complex/csqrt.c +0 -48
  261. package/libc/mingw/complex/csqrtf.c +0 -48
  262. package/libc/mingw/complex/ctan.c +0 -50
  263. package/libc/mingw/complex/ctanf.c +0 -50
  264. package/libc/mingw/math/arm/s_rint.c +0 -86
  265. package/libc/mingw/math/arm/s_rintf.c +0 -51
  266. package/libc/mingw/math/arm/sincos.S +0 -30
  267. package/libc/mingw/math/arm-common/sincosl.c +0 -13
  268. package/libc/mingw/math/arm64/rint.c +0 -12
  269. package/libc/mingw/math/arm64/rintf.c +0 -12
  270. package/libc/mingw/math/arm64/sincos.S +0 -32
  271. package/libc/mingw/math/bsd_private_base.h +0 -148
  272. package/libc/mingw/math/fdiml.c +0 -24
  273. package/libc/mingw/math/frexpf.c +0 -13
  274. package/libc/mingw/math/frexpl.c +0 -71
  275. package/libc/mingw/math/x86/acosf.c +0 -29
  276. package/libc/mingw/math/x86/atanf.c +0 -23
  277. package/libc/mingw/math/x86/atanl.c +0 -18
  278. package/libc/mingw/math/x86/cos.def.h +0 -65
  279. package/libc/mingw/math/x86/cosl.c +0 -46
  280. package/libc/mingw/math/x86/cosl_internal.S +0 -55
  281. package/libc/mingw/math/x86/ldexp.c +0 -23
  282. package/libc/mingw/math/x86/scalbn.S +0 -41
  283. package/libc/mingw/math/x86/scalbnf.S +0 -40
  284. package/libc/mingw/math/x86/sin.def.h +0 -65
  285. package/libc/mingw/math/x86/sinl.c +0 -46
  286. package/libc/mingw/math/x86/sinl_internal.S +0 -58
  287. package/libc/mingw/math/x86/tanl.S +0 -62
  288. package/libc/mingw/misc/btowc.c +0 -28
  289. package/libc/mingw/misc/wcstof.c +0 -66
  290. package/libc/mingw/misc/wcstoimax.c +0 -132
  291. package/libc/mingw/misc/wcstoumax.c +0 -126
  292. package/libc/mingw/misc/wctob.c +0 -29
  293. package/libc/mingw/misc/winbs_uint64.c +0 -6
  294. package/libc/mingw/misc/winbs_ulong.c +0 -6
  295. package/libc/mingw/misc/winbs_ushort.c +0 -6
  296. package/libc/mingw/stdio/_Exit.c +0 -10
  297. package/libc/mingw/stdio/_findfirst64i32.c +0 -21
  298. package/libc/mingw/stdio/_findnext64i32.c +0 -21
  299. package/libc/mingw/stdio/_fstat64i32.c +0 -37
  300. package/libc/mingw/stdio/_stat64i32.c +0 -37
  301. package/libc/mingw/stdio/_wfindfirst64i32.c +0 -21
  302. package/libc/mingw/stdio/_wfindnext64i32.c +0 -21
  303. package/libc/mingw/stdio/_wstat64i32.c +0 -37
  304. package/libc/mingw/winpthreads/spinlock.c +0 -82
  305. package/libc/musl/src/legacy/isastream.c +0 -7
  306. package/libc/musl/src/legacy/valloc.c +0 -8
  307. package/libc/musl/src/linux/tee.c +0 -8
  308. package/libc/musl/src/math/__cosl.c +0 -96
  309. package/libc/musl/src/math/__sinl.c +0 -78
  310. package/libc/musl/src/math/__tanl.c +0 -143
  311. package/libc/musl/src/math/aarch64/lrint.c +0 -10
  312. package/libc/musl/src/math/aarch64/lrintf.c +0 -10
  313. package/libc/musl/src/math/aarch64/rintf.c +0 -7
  314. package/libc/musl/src/math/cosl.c +0 -39
  315. package/libc/musl/src/math/fdim.c +0 -10
  316. package/libc/musl/src/math/fdimf.c +0 -10
  317. package/libc/musl/src/math/fdiml.c +0 -18
  318. package/libc/musl/src/math/finite.c +0 -7
  319. package/libc/musl/src/math/finitef.c +0 -7
  320. package/libc/musl/src/math/frexp.c +0 -23
  321. package/libc/musl/src/math/frexpf.c +0 -23
  322. package/libc/musl/src/math/frexpl.c +0 -29
  323. package/libc/musl/src/math/i386/lrint.c +0 -8
  324. package/libc/musl/src/math/i386/lrintf.c +0 -8
  325. package/libc/musl/src/math/i386/rintf.c +0 -7
  326. package/libc/musl/src/math/lrint.c +0 -72
  327. package/libc/musl/src/math/lrintf.c +0 -8
  328. package/libc/musl/src/math/powerpc64/lrint.c +0 -16
  329. package/libc/musl/src/math/powerpc64/lrintf.c +0 -16
  330. package/libc/musl/src/math/rintf.c +0 -30
  331. package/libc/musl/src/math/s390x/rintf.c +0 -15
  332. package/libc/musl/src/math/sincosl.c +0 -60
  333. package/libc/musl/src/math/sinl.c +0 -41
  334. package/libc/musl/src/math/tanl.c +0 -29
  335. package/libc/musl/src/math/x32/lrint.s +0 -5
  336. package/libc/musl/src/math/x32/lrintf.s +0 -5
  337. package/libc/musl/src/math/x86_64/lrint.c +0 -8
  338. package/libc/musl/src/math/x86_64/lrintf.c +0 -8
  339. package/libc/musl/src/string/strdup.c +0 -10
  340. package/libc/musl/src/string/strndup.c +0 -12
  341. package/libc/musl/src/string/wcsdup.c +0 -10
  342. package/libc/musl/src/thread/pthread_spin_destroy.c +0 -6
  343. package/libc/musl/src/thread/pthread_spin_init.c +0 -6
  344. package/libc/musl/src/thread/pthread_spin_lock.c +0 -8
  345. package/libc/musl/src/thread/pthread_spin_trylock.c +0 -7
  346. package/libc/musl/src/thread/pthread_spin_unlock.c +0 -7
  347. package/libc/musl/src/unistd/dup2.c +0 -20
  348. package/libc/musl/src/unistd/dup3.c +0 -26
  349. package/libc/wasi/libc-bottom-half/sources/reallocarray.c +0 -14
  350. package/libc/wasi/thread-stub/pthread_spin_lock.c +0 -8
  351. package/libc/wasi/thread-stub/pthread_spin_trylock.c +0 -8
  352. package/libc/wasi/thread-stub/pthread_spin_unlock.c +0 -7
package/std/zig/Ast.zig CHANGED
@@ -504,9 +504,6 @@ pub fn renderError(tree: Ast, parse_error: Error, w: *Writer) Writer.Error!void
504
504
  .varargs_nonfinal => {
505
505
  return w.writeAll("function prototype has parameter after varargs");
506
506
  },
507
- .expected_continue_expr => {
508
- return w.writeAll("expected ':' before while continue expression");
509
- },
510
507
 
511
508
  .expected_semi_after_decl => {
512
509
  return w.writeAll("expected ';' after declaration");
@@ -2888,7 +2885,6 @@ pub const Error = struct {
2888
2885
  test_doc_comment,
2889
2886
  comptime_doc_comment,
2890
2887
  varargs_nonfinal,
2891
- expected_continue_expr,
2892
2888
  expected_semi_after_decl,
2893
2889
  expected_semi_after_stmt,
2894
2890
  expected_comma_after_field,
@@ -199,7 +199,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir {
199
199
  assert(struct_decl_ref.toIndex().? == .main_struct_inst);
200
200
  break :fatal false;
201
201
  } else |err| switch (err) {
202
- error.OutOfMemory => return error.OutOfMemory,
202
+ error.OutOfMemory => |e| return e,
203
203
  error.AnalysisFail => break :fatal true, // Handled via compile_errors below.
204
204
  }
205
205
  } else fatal: {
@@ -1776,11 +1776,12 @@ fn structInitExpr(
1776
1776
  }
1777
1777
 
1778
1778
  {
1779
- var sfba = std.heap.stackFallback(256, astgen.arena);
1780
- const sfba_allocator = sfba.get();
1779
+ var bfa_buf: [256]u8 = undefined;
1780
+ var bfa_state: std.heap.BufferFirstAllocator = .init(&bfa_buf, astgen.arena);
1781
+ const bfa = bfa_state.allocator();
1781
1782
 
1782
- var duplicate_names = std.AutoArrayHashMap(Zir.NullTerminatedString, ArrayList(Ast.TokenIndex)).init(sfba_allocator);
1783
- try duplicate_names.ensureTotalCapacity(@intCast(struct_init.ast.fields.len));
1783
+ var duplicate_names: std.array_hash_map.Auto(Zir.NullTerminatedString, ArrayList(Ast.TokenIndex)) = .empty;
1784
+ try duplicate_names.ensureTotalCapacity(bfa, @intCast(struct_init.ast.fields.len));
1784
1785
 
1785
1786
  // When there aren't errors, use this to avoid a second iteration.
1786
1787
  var any_duplicate = false;
@@ -1789,14 +1790,14 @@ fn structInitExpr(
1789
1790
  const name_token = tree.firstToken(field) - 2;
1790
1791
  const name_index = try astgen.identAsString(name_token);
1791
1792
 
1792
- const gop = try duplicate_names.getOrPut(name_index);
1793
+ const gop = try duplicate_names.getOrPut(bfa, name_index);
1793
1794
 
1794
1795
  if (gop.found_existing) {
1795
- try gop.value_ptr.append(sfba_allocator, name_token);
1796
+ try gop.value_ptr.append(bfa, name_token);
1796
1797
  any_duplicate = true;
1797
1798
  } else {
1798
1799
  gop.value_ptr.* = .empty;
1799
- try gop.value_ptr.append(sfba_allocator, name_token);
1800
+ try gop.value_ptr.append(bfa, name_token);
1800
1801
  }
1801
1802
  }
1802
1803
 
@@ -2870,7 +2871,6 @@ fn addEnsureResult(gz: *GenZir, maybe_unused_result: Zir.Inst.Ref, statement: As
2870
2871
  .mul_add,
2871
2872
  .max,
2872
2873
  .min,
2873
- .c_import,
2874
2874
  .@"resume",
2875
2875
  .ret_err_value_code,
2876
2876
  .ret_ptr,
@@ -5681,7 +5681,7 @@ fn containerMember(
5681
5681
 
5682
5682
  const prev_decl_index = wip_decls.index;
5683
5683
  astgen.fnDecl(gz, scope, wip_decls, member_node, body, full) catch |err| switch (err) {
5684
- error.OutOfMemory => return error.OutOfMemory,
5684
+ error.OutOfMemory => |e| return e,
5685
5685
  error.AnalysisFail => {
5686
5686
  wip_decls.index = prev_decl_index;
5687
5687
  try addFailedDeclaration(
@@ -5704,7 +5704,7 @@ fn containerMember(
5704
5704
  const full = tree.fullVarDecl(member_node).?;
5705
5705
  const prev_decl_index = wip_decls.index;
5706
5706
  astgen.globalVarDecl(gz, scope, wip_decls, member_node, full) catch |err| switch (err) {
5707
- error.OutOfMemory => return error.OutOfMemory,
5707
+ error.OutOfMemory => |e| return e,
5708
5708
  error.AnalysisFail => {
5709
5709
  wip_decls.index = prev_decl_index;
5710
5710
  try addFailedDeclaration(
@@ -5722,7 +5722,7 @@ fn containerMember(
5722
5722
  .@"comptime" => {
5723
5723
  const prev_decl_index = wip_decls.index;
5724
5724
  astgen.comptimeDecl(gz, scope, wip_decls, member_node) catch |err| switch (err) {
5725
- error.OutOfMemory => return error.OutOfMemory,
5725
+ error.OutOfMemory => |e| return e,
5726
5726
  error.AnalysisFail => {
5727
5727
  wip_decls.index = prev_decl_index;
5728
5728
  try addFailedDeclaration(
@@ -5742,7 +5742,7 @@ fn containerMember(
5742
5742
  // Since it doesn't strictly matter *what* this is, let's save ourselves the trouble
5743
5743
  // of duplicating the test name logic, and just assume this is an unnamed test.
5744
5744
  astgen.testDecl(gz, scope, wip_decls, member_node) catch |err| switch (err) {
5745
- error.OutOfMemory => return error.OutOfMemory,
5745
+ error.OutOfMemory => |e| return e,
5746
5746
  error.AnalysisFail => {
5747
5747
  wip_decls.index = prev_decl_index;
5748
5748
  try addFailedDeclaration(
@@ -6656,9 +6656,16 @@ fn whileExpr(
6656
6656
  .operand = undefined,
6657
6657
  } },
6658
6658
  });
6659
+ if (!continue_scope.is_comptime) {
6660
+ _ = try continue_scope.addRestoreErrRetIndex(.{ .block = continue_block }, .always, then_node);
6661
+ }
6659
6662
  _ = try continue_scope.addBreak(break_tag, continue_block, .void_value);
6660
6663
  }
6661
6664
  try continue_scope.setBlockBody(continue_block);
6665
+ if (!then_scope.is_comptime) {
6666
+ const cont_node = while_full.ast.cont_expr.unwrap() orelse then_node;
6667
+ _ = try then_scope.addRestoreErrRetIndex(.{ .block = cond_block }, .always, cont_node);
6668
+ }
6662
6669
  _ = try then_scope.addBreak(break_tag, cond_block, .void_value);
6663
6670
 
6664
6671
  var else_scope = parent_gz.makeSubBlock(&cond_scope.base);
@@ -6703,6 +6710,9 @@ fn whileExpr(
6703
6710
 
6704
6711
  try checkUsed(parent_gz, &else_scope.base, sub_scope);
6705
6712
  if (!else_scope.endsWithNoReturn()) {
6713
+ if (!else_scope.is_comptime) {
6714
+ _ = try else_scope.addRestoreErrRetIndex(.{ .block = loop_block }, .always, else_node);
6715
+ }
6706
6716
  _ = try else_scope.addBreakWithSrcNode(break_tag, loop_block, else_result, else_node);
6707
6717
  }
6708
6718
  } else {
@@ -6973,6 +6983,9 @@ fn forExpr(
6973
6983
  });
6974
6984
 
6975
6985
  const break_tag: Zir.Inst.Tag = if (is_inline) .break_inline else .@"break";
6986
+ if (!then_scope.is_comptime) {
6987
+ _ = try then_scope.addRestoreErrRetIndex(.{ .block = cond_block }, .always, then_node);
6988
+ }
6976
6989
  _ = try then_scope.addBreak(break_tag, cond_block, .void_value);
6977
6990
 
6978
6991
  var else_scope = parent_gz.makeSubBlock(&cond_scope.base);
@@ -6990,6 +7003,9 @@ fn forExpr(
6990
7003
  _ = try addEnsureResult(&else_scope, else_result, else_node);
6991
7004
  }
6992
7005
  if (!else_scope.endsWithNoReturn()) {
7006
+ if (!else_scope.is_comptime) {
7007
+ _ = try else_scope.addRestoreErrRetIndex(.{ .block = loop_block }, .always, else_node);
7008
+ }
6993
7009
  _ = try else_scope.addBreakWithSrcNode(break_tag, loop_block, else_result, else_node);
6994
7010
  }
6995
7011
  } else {
@@ -8405,9 +8421,10 @@ fn tunnelThroughClosure(
8405
8421
 
8406
8422
  // Otherwise we need a tunnel. First, figure out the path of namespaces we
8407
8423
  // are tunneling through. This is usually only going to be one or two, so
8408
- // use an SFBA to optimize for the common case.
8409
- var sfba = std.heap.stackFallback(@sizeOf(usize) * 2, astgen.arena);
8410
- var intermediate_tunnels = try sfba.get().alloc(*Scope.Namespace, num_tunnels - 1);
8424
+ // use an BFA to optimize for the common case.
8425
+ var bfa_buf: [2]usize = undefined;
8426
+ var bfa: std.heap.BufferFirstAllocator = .init(@ptrCast(&bfa_buf), astgen.arena);
8427
+ var intermediate_tunnels = try bfa.allocator().alloc(*Scope.Namespace, num_tunnels - 1);
8411
8428
 
8412
8429
  const root_ns = ns: {
8413
8430
  var i: usize = num_tunnels - 1;
@@ -8562,7 +8579,7 @@ fn numberLiteral(gz: *GenZir, ri: ResultInfo, node: Ast.Node.Index, source_node:
8562
8579
  big_int.setString(@intFromEnum(base), bytes[prefix_offset..]) catch |err| switch (err) {
8563
8580
  error.InvalidCharacter => unreachable, // caught in `parseNumberLiteral`
8564
8581
  error.InvalidBase => unreachable, // we only pass 16, 8, 2, see above
8565
- error.OutOfMemory => return error.OutOfMemory,
8582
+ error.OutOfMemory => |e| return e,
8566
8583
  };
8567
8584
 
8568
8585
  const limbs = big_int.limbs[0..big_int.len()];
@@ -8955,7 +8972,6 @@ fn typeOf(
8955
8972
  var typeof_scope = gz.makeSubBlock(scope);
8956
8973
  typeof_scope.is_comptime = false;
8957
8974
  typeof_scope.is_typeof = true;
8958
- typeof_scope.c_import = false;
8959
8975
  defer typeof_scope.unstack();
8960
8976
 
8961
8977
  const ty_expr = try reachableExpr(&typeof_scope, &typeof_scope.base, .{ .rl = .none }, args[0], node);
@@ -9055,8 +9071,7 @@ fn builtinCall(
9055
9071
  const builtin_name = tree.tokenSlice(builtin_token);
9056
9072
 
9057
9073
  // We handle the different builtins manually because they have different semantics depending
9058
- // on the function. For example, `@as` and others participate in result location semantics,
9059
- // and `@cImport` creates a special scope that collects a .c source code text buffer.
9074
+ // on the function. For example, `@as` and others participate in result location semantics.
9060
9075
  // Also, some builtins have a variable number of parameters.
9061
9076
 
9062
9077
  const info = BuiltinFn.list.get(builtin_name) orelse {
@@ -9175,7 +9190,6 @@ fn builtinCall(
9175
9190
  .bit_cast => return bitCast( gz, scope, ri, node, params[0]),
9176
9191
  .TypeOf => return typeOf( gz, scope, ri, node, params),
9177
9192
  .union_init => return unionInit(gz, scope, ri, node, params),
9178
- .c_import => return cImport( gz, scope, node, params[0]),
9179
9193
  .min => return minMax( gz, scope, ri, node, params, .min),
9180
9194
  .max => return minMax( gz, scope, ri, node, params, .max),
9181
9195
  // zig fmt: on
@@ -9266,10 +9280,10 @@ fn builtinCall(
9266
9280
  .log => return floatUnOp(gz, scope, ri, node, params[0], .log),
9267
9281
  .log2 => return floatUnOp(gz, scope, ri, node, params[0], .log2),
9268
9282
  .log10 => return floatUnOp(gz, scope, ri, node, params[0], .log10),
9269
- .floor => return floatUnOp(gz, scope, ri, node, params[0], .floor),
9270
- .ceil => return floatUnOp(gz, scope, ri, node, params[0], .ceil),
9271
- .trunc => return floatUnOp(gz, scope, ri, node, params[0], .trunc),
9272
- .round => return floatUnOp(gz, scope, ri, node, params[0], .round),
9283
+ .floor => return floatRoundOp(gz, scope, ri, node, params[0], .floor),
9284
+ .ceil => return floatRoundOp(gz, scope, ri, node, params[0], .ceil),
9285
+ .trunc => return floatRoundOp(gz, scope, ri, node, params[0], .trunc),
9286
+ .round => return floatRoundOp(gz, scope, ri, node, params[0], .round),
9273
9287
 
9274
9288
  .int_from_float => return typeCast(gz, scope, ri, node, params[0], .int_from_float, builtin_name),
9275
9289
  .float_from_int => return typeCast(gz, scope, ri, node, params[0], .float_from_int, builtin_name),
@@ -9484,9 +9498,6 @@ fn builtinCall(
9484
9498
  .bit_offset_of => return offsetOf(gz, scope, ri, node, params[0], params[1], .bit_offset_of),
9485
9499
  .offset_of => return offsetOf(gz, scope, ri, node, params[0], params[1], .offset_of),
9486
9500
 
9487
- .c_undef => return simpleCBuiltin(gz, scope, ri, node, params[0], .c_undef),
9488
- .c_include => return simpleCBuiltin(gz, scope, ri, node, params[0], .c_include),
9489
-
9490
9501
  .cmpxchg_strong => return cmpxchg(gz, scope, ri, node, params, 1),
9491
9502
  .cmpxchg_weak => return cmpxchg(gz, scope, ri, node, params, 0),
9492
9503
  // zig fmt: on
@@ -9509,17 +9520,6 @@ fn builtinCall(
9509
9520
  });
9510
9521
  return rvalue(gz, ri, result, node);
9511
9522
  },
9512
- .c_define => {
9513
- if (!gz.c_import) return gz.astgen.failNode(node, "C define valid only inside C import block", .{});
9514
- const name = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .slice_const_u8_type } }, params[0], .operand_cDefine_macro_name);
9515
- const value = try comptimeExpr(gz, scope, .{ .rl = .none }, params[1], .operand_cDefine_macro_value);
9516
- const result = try gz.addExtendedPayload(.c_define, Zir.Inst.BinNode{
9517
- .node = gz.nodeIndexToRelative(node),
9518
- .lhs = name,
9519
- .rhs = value,
9520
- });
9521
- return rvalue(gz, ri, result, node);
9522
- },
9523
9523
  .splat => {
9524
9524
  const result_type = try ri.rl.resultTypeForCast(gz, node, builtin_name);
9525
9525
  const elem_type = try gz.addUnNode(.splat_op_result_ty, result_type, node);
@@ -9819,6 +9819,43 @@ fn simpleUnOp(
9819
9819
  return rvalue(gz, ri, result, node);
9820
9820
  }
9821
9821
 
9822
+ fn floatRoundOp(
9823
+ gz: *GenZir,
9824
+ scope: *Scope,
9825
+ ri: ResultInfo,
9826
+ node: Ast.Node.Index,
9827
+ operand_node: Ast.Node.Index,
9828
+ float_tag: Zir.Inst.Tag,
9829
+ ) InnerError!Zir.Inst.Ref {
9830
+ if (try ri.rl.resultType(gz, node)) |dest_type| {
9831
+ const cursor = maybeAdvanceSourceCursorToMainToken(gz, node);
9832
+
9833
+ const operand_ty_inst = try gz.addExtendedPayload(.round_op_ty, Zir.Inst.UnNode{
9834
+ .node = gz.nodeIndexToRelative(node),
9835
+ .operand = dest_type,
9836
+ });
9837
+
9838
+ const operand = try expr(gz, scope, .{ .rl = .{ .coerced_ty = operand_ty_inst } }, operand_node);
9839
+
9840
+ try emitDbgStmt(gz, cursor);
9841
+ const round_op: Zir.Inst.RoundOp = switch (float_tag) {
9842
+ .round => .round,
9843
+ .floor => .floor,
9844
+ .ceil => .ceil,
9845
+ .trunc => .trunc,
9846
+ else => unreachable,
9847
+ };
9848
+ const result = try gz.addExtendedPayloadSmall(.round_op, @intFromEnum(round_op), Zir.Inst.BinNode{
9849
+ .node = gz.nodeIndexToRelative(node),
9850
+ .lhs = dest_type,
9851
+ .rhs = operand,
9852
+ });
9853
+ return rvalue(gz, ri, result, node);
9854
+ } else {
9855
+ return floatUnOp(gz, scope, ri, node, operand_node, float_tag);
9856
+ }
9857
+ }
9858
+
9822
9859
  fn floatUnOp(
9823
9860
  gz: *GenZir,
9824
9861
  scope: *Scope,
@@ -9914,30 +9951,6 @@ fn divBuiltin(
9914
9951
  return rvalue(gz, ri, result, node);
9915
9952
  }
9916
9953
 
9917
- fn simpleCBuiltin(
9918
- gz: *GenZir,
9919
- scope: *Scope,
9920
- ri: ResultInfo,
9921
- node: Ast.Node.Index,
9922
- operand_node: Ast.Node.Index,
9923
- tag: Zir.Inst.Extended,
9924
- ) InnerError!Zir.Inst.Ref {
9925
- const name: []const u8 = if (tag == .c_undef) "C undef" else "C include";
9926
- if (!gz.c_import) return gz.astgen.failNode(node, "{s} valid only inside C import block", .{name});
9927
- const operand = try comptimeExpr(
9928
- gz,
9929
- scope,
9930
- .{ .rl = .{ .coerced_ty = .slice_const_u8_type } },
9931
- operand_node,
9932
- if (tag == .c_undef) .operand_cUndef_macro_name else .operand_cInclude_file_name,
9933
- );
9934
- _ = try gz.addExtendedPayload(tag, Zir.Inst.UnNode{
9935
- .node = gz.nodeIndexToRelative(node),
9936
- .operand = operand,
9937
- });
9938
- return rvalue(gz, ri, .void_value, node);
9939
- }
9940
-
9941
9954
  fn offsetOf(
9942
9955
  gz: *GenZir,
9943
9956
  scope: *Scope,
@@ -9987,35 +10000,6 @@ fn shiftOp(
9987
10000
  return rvalue(gz, ri, result, node);
9988
10001
  }
9989
10002
 
9990
- fn cImport(
9991
- gz: *GenZir,
9992
- scope: *Scope,
9993
- node: Ast.Node.Index,
9994
- body_node: Ast.Node.Index,
9995
- ) InnerError!Zir.Inst.Ref {
9996
- const astgen = gz.astgen;
9997
- const gpa = astgen.gpa;
9998
-
9999
- if (gz.c_import) return gz.astgen.failNode(node, "cannot nest @cImport", .{});
10000
-
10001
- var block_scope = gz.makeSubBlock(scope);
10002
- block_scope.is_comptime = true;
10003
- block_scope.c_import = true;
10004
- defer block_scope.unstack();
10005
-
10006
- const block_inst = try gz.makeBlockInst(.c_import, node);
10007
- const block_result = try fullBodyExpr(&block_scope, &block_scope.base, .{ .rl = .none }, body_node, .normal);
10008
- _ = try gz.addUnNode(.ensure_result_used, block_result, node);
10009
- if (!gz.refIsNoReturn(block_result)) {
10010
- _ = try block_scope.addBreak(.break_inline, block_inst, .void_value);
10011
- }
10012
- try block_scope.setBlockBody(block_inst);
10013
- // block_scope unstacked now, can add new instructions to gz
10014
- try gz.instructions.append(gpa, block_inst);
10015
-
10016
- return block_inst.toRef();
10017
- }
10018
-
10019
10003
  fn overflowArithmetic(
10020
10004
  gz: *GenZir,
10021
10005
  scope: *Scope,
@@ -11302,7 +11286,6 @@ const GenZir = struct {
11302
11286
  /// This is set to true for a `GenZir` of a `block_inline`, indicating that
11303
11287
  /// exits from this block should use `break_inline` rather than `break`.
11304
11288
  is_inline: bool = false,
11305
- c_import: bool = false,
11306
11289
  /// The containing decl AST node.
11307
11290
  decl_node_index: Ast.Node.Index,
11308
11291
  /// The containing decl line index, absolute.
@@ -11390,7 +11373,6 @@ const GenZir = struct {
11390
11373
  return .{
11391
11374
  .is_comptime = gz.is_comptime,
11392
11375
  .is_typeof = gz.is_typeof,
11393
- .c_import = gz.c_import,
11394
11376
  .decl_node_index = gz.decl_node_index,
11395
11377
  .decl_line = gz.decl_line,
11396
11378
  .parent = scope,
@@ -12962,17 +12944,18 @@ fn scanContainer(
12962
12944
  next: ?*@This(),
12963
12945
  };
12964
12946
 
12965
- // The maps below are allocated into this SFBA to avoid using the GPA for small namespaces.
12966
- var sfba_state = std.heap.stackFallback(512, astgen.gpa);
12967
- const sfba = sfba_state.get();
12947
+ // The maps below are allocated into this BFA to avoid using the GPA for small namespaces.
12948
+ var bfa_buf: [512]u8 = undefined;
12949
+ var bfa_state: std.heap.BufferFirstAllocator = .init(&bfa_buf, astgen.gpa);
12950
+ const bfa = bfa_state.allocator();
12968
12951
 
12969
12952
  var names: std.AutoArrayHashMapUnmanaged(Zir.NullTerminatedString, NameEntry) = .empty;
12970
12953
  var test_names: std.AutoArrayHashMapUnmanaged(Zir.NullTerminatedString, NameEntry) = .empty;
12971
12954
  var decltest_names: std.AutoArrayHashMapUnmanaged(Zir.NullTerminatedString, NameEntry) = .empty;
12972
12955
  defer {
12973
- names.deinit(sfba);
12974
- test_names.deinit(sfba);
12975
- decltest_names.deinit(sfba);
12956
+ names.deinit(bfa);
12957
+ test_names.deinit(bfa);
12958
+ decltest_names.deinit(bfa);
12976
12959
  }
12977
12960
 
12978
12961
  var any_duplicates = false;
@@ -13044,7 +13027,7 @@ fn scanContainer(
13044
13027
  else => {}, // unnamed test
13045
13028
  .string_literal => {
13046
13029
  const name = try astgen.strLitAsString(test_name_token);
13047
- const gop = try test_names.getOrPut(sfba, name.index);
13030
+ const gop = try test_names.getOrPut(bfa, name.index);
13048
13031
  if (gop.found_existing) {
13049
13032
  var e = gop.value_ptr;
13050
13033
  while (e.next) |n| e = n;
@@ -13057,7 +13040,7 @@ fn scanContainer(
13057
13040
  },
13058
13041
  .identifier => {
13059
13042
  const name = try astgen.identAsString(test_name_token);
13060
- const gop = try decltest_names.getOrPut(sfba, name);
13043
+ const gop = try decltest_names.getOrPut(bfa, name);
13061
13044
  if (gop.found_existing) {
13062
13045
  var e = gop.value_ptr;
13063
13046
  while (e.next) |n| e = n;
@@ -13084,7 +13067,7 @@ fn scanContainer(
13084
13067
  }
13085
13068
 
13086
13069
  {
13087
- const gop = try names.getOrPut(sfba, name_str_index);
13070
+ const gop = try names.getOrPut(bfa, name_str_index);
13088
13071
  const new_ent: NameEntry = .{
13089
13072
  .tok = name_token,
13090
13073
  .next = null,
@@ -842,10 +842,6 @@ fn builtinCall(astrl: *AstRlAnnotate, block: ?*Block, ri: ResultInfo, node: Ast.
842
842
  _ = try astrl.expr(args[2], block, ResultInfo.type_only);
843
843
  return false;
844
844
  },
845
- .c_import => {
846
- _ = try astrl.expr(args[0], block, ResultInfo.none);
847
- return false;
848
- },
849
845
  .min, .max => {
850
846
  for (args) |arg_node| {
851
847
  _ = try astrl.expr(arg_node, block, ResultInfo.none);
@@ -907,8 +903,6 @@ fn builtinCall(astrl: *AstRlAnnotate, block: ?*Block, ri: ResultInfo, node: Ast.
907
903
  .error_name,
908
904
  .set_runtime_safety,
909
905
  .Tuple,
910
- .c_undef,
911
- .c_include,
912
906
  .wasm_memory_size,
913
907
  .splat,
914
908
  .set_float_mode,
@@ -986,11 +980,6 @@ fn builtinCall(astrl: *AstRlAnnotate, block: ?*Block, ri: ResultInfo, node: Ast.
986
980
  _ = try astrl.expr(args[1], block, ResultInfo.type_only);
987
981
  return false;
988
982
  },
989
- .c_define => {
990
- _ = try astrl.expr(args[0], block, ResultInfo.type_only);
991
- _ = try astrl.expr(args[1], block, ResultInfo.none);
992
- return false;
993
- },
994
983
  .reduce => {
995
984
  _ = try astrl.expr(args[0], block, ResultInfo.type_only);
996
985
  _ = try astrl.expr(args[1], block, ResultInfo.none);