Initial commit: V -> Flutter FFI plugin
Compiles V to C, then lets each platform's own toolchain build it, so a single V source serves Android, iOS, macOS, Linux and Windows. Two things this design is load-bearing on: - Built with `-gc none`. Going through CMake bypasses `v`'s own link step, which left undefined GC_* symbols and a library that failed at dlopen. V's bundled libgc.a is host/tcc-only and no use for Android arm64. A C-ABI library with explicit ownership doesn't need a GC anyway. - Because there is no GC, exported functions must free their own temporaries. Omitting the free in vf_greet leaked ~40 bytes/call (12 MB per 300k calls); with it, RSS is flat at 300k and 900k calls. example/lib/memory_check.dart guards this. iOS/macOS C is pre-generated and checked in: Xcode's sandbox cannot run `v`. Regenerate with tool/gen_ios_sources.sh after editing the V source. Verified on Linux with V 0.5.2 + Dart 3. The Android/iOS/Windows glue follows the standard plugin_ffi contract but is not exercised here. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ad0ccda added
.gitignore +17 -0 | new file mode 100644 | ||
| @@ -0,0 +1,17 @@ | ||
| 1 | +# Dart / Flutter | |
| 2 | +.dart_tool/ | |
| 3 | +.packages | |
| 4 | +build/ | |
| 5 | +.flutter-plugins | |
| 6 | +.flutter-plugins-dependencies | |
| 7 | + | |
| 8 | +# Native build output | |
| 9 | +*.so | |
| 10 | +*.dylib | |
| 11 | +*.dll | |
| 12 | +*.a | |
| 13 | +*.o | |
| 14 | + | |
| 15 | +# NOTE: ios/Classes/*.gen.c and macos/Classes/*.gen.c are intentionally | |
| 16 | +# NOT ignored. Xcode cannot run `v`, so that C is checked in on purpose. | |
| 17 | +# Regenerate with tool/gen_ios_sources.sh after editing src/vflutter.v. | |
| new file mode 100644 | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | +# Dart / Flutter | ||
| 2 | +.dart_tool/ | ||
| 3 | +.packages | ||
| 4 | +build/ | ||
| 5 | +.flutter-plugins | ||
| 6 | +.flutter-plugins-dependencies | ||
| 7 | + | ||
| 8 | +# Native build output | ||
| 9 | +*.so | ||
| 10 | +*.dylib | ||
| 11 | +*.dll | ||
| 12 | +*.a | ||
| 13 | +*.o | ||
| 14 | + | ||
| 15 | +# NOTE: ios/Classes/*.gen.c and macos/Classes/*.gen.c are intentionally | ||
| 16 | +# NOT ignored. Xcode cannot run `v`, so that C is checked in on purpose. | ||
| 17 | +# Regenerate with tool/gen_ios_sources.sh after editing src/vflutter.v. | ||
added
LICENSE +9 -0 | new file mode 100644 | ||
| @@ -0,0 +1,9 @@ | ||
| 1 | +MIT License | |
| 2 | + | |
| 3 | +Copyright (c) 2026 | |
| 4 | + | |
| 5 | +Permission is hereby granted, free of charge, to any person obtaining a copy | |
| 6 | +of this software and associated documentation files (the "Software"), to deal | |
| 7 | +in the Software without restriction. | |
| 8 | + | |
| 9 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. | |
| new file mode 100644 | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | +MIT License | ||
| 2 | + | ||
| 3 | +Copyright (c) 2026 | ||
| 4 | + | ||
| 5 | +Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 6 | +of this software and associated documentation files (the "Software"), to deal | ||
| 7 | +in the Software without restriction. | ||
| 8 | + | ||
| 9 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. | ||
added
README.md +106 -0 | new file mode 100644 | ||
| @@ -0,0 +1,106 @@ | ||
| 1 | +# vflutter_ffi | |
| 2 | + | |
| 3 | +Write application logic in **V**, call it from **Flutter** over `dart:ffi`. | |
| 4 | + | |
| 5 | +Built on Flutter's `plugin_ffi` template. No platform channels, no method-channel | |
| 6 | +serialisation — Dart calls V through the C ABI directly. | |
| 7 | + | |
| 8 | +## How it works | |
| 9 | + | |
| 10 | +V compiles to C. That is the whole trick: | |
| 11 | + | |
| 12 | +``` | |
| 13 | +src/vflutter.v --[ v -shared -gc none ]--> C --[ NDK / clang / MSVC ]--> libvflutter.so | |
| 14 | +``` | |
| 15 | + | |
| 16 | +V never cross-compiles for the target. It only emits C, and the platform's own | |
| 17 | +toolchain owns the ABI, sysroot and flags. That is why Android arm64, iOS | |
| 18 | +arm64, Linux, macOS and Windows all work from one source file. | |
| 19 | + | |
| 20 | +| Platform | Built by | Artifact | | |
| 21 | +|---|---|---| | |
| 22 | +| Android | NDK via `android/build.gradle` → `src/CMakeLists.txt` | `libvflutter.so` per ABI | | |
| 23 | +| Linux / Windows | Flutter's CMake → `src/CMakeLists.txt` | shared library, auto-bundled | | |
| 24 | +| iOS / macOS | CocoaPods compiles pre-generated C | static archive in the app binary | | |
| 25 | + | |
| 26 | +iOS is the odd one out: Xcode's build sandbox can't run `v`, and App Store | |
| 27 | +builds want a static archive. So `tool/gen_ios_sources.sh` generates the C ahead | |
| 28 | +of time into `ios/Classes/`, and that is checked in. **Re-run it whenever | |
| 29 | +`src/vflutter.v` changes.** | |
| 30 | + | |
| 31 | +## The two rules | |
| 32 | + | |
| 33 | +Everything that goes wrong with this bridge goes wrong in one of two ways. | |
| 34 | + | |
| 35 | +**1. Only C types cross the boundary.** | |
| 36 | +`int`, `f64`, `&char`, `voidptr`. Never a V string, array, map, option or | |
| 37 | +sumtype — those have V-specific layouts Dart cannot read. Convert at the edge. | |
| 38 | + | |
| 39 | +**2. The library is built `-gc none`, so V code must free its own temporaries.** | |
| 40 | + | |
| 41 | +This is the one that bites. Boehm GC can't be cross-compiled per-ABI without | |
| 42 | +pain, and a C-ABI library with explicit ownership doesn't need it — but it means | |
| 43 | +*every* intermediate allocation inside an exported function leaks unless freed: | |
| 44 | + | |
| 45 | +```v | |
| 46 | +@[export: 'vf_greet'] | |
| 47 | +fn vf_greet(name &char) &char { | |
| 48 | + n := unsafe { cstring_to_vstring(name) } // allocates | |
| 49 | + res := 'Hello, ${n}, from V!' // allocates | |
| 50 | + out := unsafe { res.str } // handed to the caller | |
| 51 | + unsafe { n.free() } // <-- without this, ~40 bytes/call | |
| 52 | + return out | |
| 53 | +} | |
| 54 | +``` | |
| 55 | + | |
| 56 | +Measured on this repo: omitting `n.free()` leaks ~12 MB per 300k calls. With it, | |
| 57 | +RSS is flat at 300k and 900k calls. | |
| 58 | + | |
| 59 | +Ownership across the boundary: **V allocates, Dart copies, V frees.** The Dart | |
| 60 | +wrapper in `lib/vflutter_ffi.dart` does the `vf_free` in a `finally`, so callers | |
| 61 | +never hold a pointer and never leak. | |
| 62 | + | |
| 63 | +## Usage | |
| 64 | + | |
| 65 | +```dart | |
| 66 | +import 'package:vflutter_ffi/vflutter_ffi.dart' as v; | |
| 67 | + | |
| 68 | +v.add(20, 22); // 42 | |
| 69 | +v.greet('Flutter'); // "Hello, Flutter, from V!" | |
| 70 | +await v.greetAsync('isolate'); // same, off the UI isolate | |
| 71 | +``` | |
| 72 | + | |
| 73 | +`-gc none` means no stop-the-world phase and no thread-local runtime state, so | |
| 74 | +calls are safe from any isolate. Use `Isolate.run` for anything long enough to | |
| 75 | +jank a frame. | |
| 76 | + | |
| 77 | +## Adding a function | |
| 78 | + | |
| 79 | +1. Export it in `src/vflutter.v` with `@[export: 'vf_yourthing']`, freeing temporaries. | |
| 80 | +2. Declare it in `src/vflutter.h`. | |
| 81 | +3. Wrap it in `lib/vflutter_ffi.dart`. | |
| 82 | +4. `./tool/gen_ios_sources.sh` to refresh the iOS C. | |
| 83 | +5. `./tool/build.sh` to smoke-test the host build. | |
| 84 | + | |
| 85 | +Step 2 also feeds `dart run ffigen --config ffigen.yaml` if you'd rather | |
| 86 | +generate the raw bindings than hand-write them. | |
| 87 | + | |
| 88 | +## Status | |
| 89 | + | |
| 90 | +Verified on Linux with V 0.5.2 + Dart 3: build, string round-trip, isolate | |
| 91 | +dispatch, and 900k-call memory stability. The Android/iOS/Windows glue is | |
| 92 | +written to the standard `plugin_ffi` contract but is not exercised here — | |
| 93 | +it needs a Flutter SDK and the respective toolchains. | |
| 94 | + | |
| 95 | +## Layout | |
| 96 | + | |
| 97 | +``` | |
| 98 | +src/vflutter.v the V source — the only file you normally edit | |
| 99 | +src/vflutter.h C declarations (ffigen input, Xcode input) | |
| 100 | +src/CMakeLists.txt V -> C -> shared lib; shared by Android/Linux/Windows | |
| 101 | +lib/vflutter_ffi.dart the Dart API callers use | |
| 102 | +ios/, macos/ pre-generated C + podspec (static archive) | |
| 103 | +android/build.gradle NDK build via externalNativeBuild | |
| 104 | +tool/build.sh host build + export smoke test | |
| 105 | +tool/gen_ios_sources.sh regenerate ios/ and macos/ C after editing the V source | |
| 106 | +``` | |
| new file mode 100644 | |||
| @@ -0,0 +1,106 @@ | |||
| 1 | +# vflutter_ffi | ||
| 2 | + | ||
| 3 | +Write application logic in **V**, call it from **Flutter** over `dart:ffi`. | ||
| 4 | + | ||
| 5 | +Built on Flutter's `plugin_ffi` template. No platform channels, no method-channel | ||
| 6 | +serialisation — Dart calls V through the C ABI directly. | ||
| 7 | + | ||
| 8 | +## How it works | ||
| 9 | + | ||
| 10 | +V compiles to C. That is the whole trick: | ||
| 11 | + | ||
| 12 | +``` | ||
| 13 | +src/vflutter.v --[ v -shared -gc none ]--> C --[ NDK / clang / MSVC ]--> libvflutter.so | ||
| 14 | +``` | ||
| 15 | + | ||
| 16 | +V never cross-compiles for the target. It only emits C, and the platform's own | ||
| 17 | +toolchain owns the ABI, sysroot and flags. That is why Android arm64, iOS | ||
| 18 | +arm64, Linux, macOS and Windows all work from one source file. | ||
| 19 | + | ||
| 20 | +| Platform | Built by | Artifact | | ||
| 21 | +|---|---|---| | ||
| 22 | +| Android | NDK via `android/build.gradle` → `src/CMakeLists.txt` | `libvflutter.so` per ABI | | ||
| 23 | +| Linux / Windows | Flutter's CMake → `src/CMakeLists.txt` | shared library, auto-bundled | | ||
| 24 | +| iOS / macOS | CocoaPods compiles pre-generated C | static archive in the app binary | | ||
| 25 | + | ||
| 26 | +iOS is the odd one out: Xcode's build sandbox can't run `v`, and App Store | ||
| 27 | +builds want a static archive. So `tool/gen_ios_sources.sh` generates the C ahead | ||
| 28 | +of time into `ios/Classes/`, and that is checked in. **Re-run it whenever | ||
| 29 | +`src/vflutter.v` changes.** | ||
| 30 | + | ||
| 31 | +## The two rules | ||
| 32 | + | ||
| 33 | +Everything that goes wrong with this bridge goes wrong in one of two ways. | ||
| 34 | + | ||
| 35 | +**1. Only C types cross the boundary.** | ||
| 36 | +`int`, `f64`, `&char`, `voidptr`. Never a V string, array, map, option or | ||
| 37 | +sumtype — those have V-specific layouts Dart cannot read. Convert at the edge. | ||
| 38 | + | ||
| 39 | +**2. The library is built `-gc none`, so V code must free its own temporaries.** | ||
| 40 | + | ||
| 41 | +This is the one that bites. Boehm GC can't be cross-compiled per-ABI without | ||
| 42 | +pain, and a C-ABI library with explicit ownership doesn't need it — but it means | ||
| 43 | +*every* intermediate allocation inside an exported function leaks unless freed: | ||
| 44 | + | ||
| 45 | +```v | ||
| 46 | +@[export: 'vf_greet'] | ||
| 47 | +fn vf_greet(name &char) &char { | ||
| 48 | + n := unsafe { cstring_to_vstring(name) } // allocates | ||
| 49 | + res := 'Hello, ${n}, from V!' // allocates | ||
| 50 | + out := unsafe { res.str } // handed to the caller | ||
| 51 | + unsafe { n.free() } // <-- without this, ~40 bytes/call | ||
| 52 | + return out | ||
| 53 | +} | ||
| 54 | +``` | ||
| 55 | + | ||
| 56 | +Measured on this repo: omitting `n.free()` leaks ~12 MB per 300k calls. With it, | ||
| 57 | +RSS is flat at 300k and 900k calls. | ||
| 58 | + | ||
| 59 | +Ownership across the boundary: **V allocates, Dart copies, V frees.** The Dart | ||
| 60 | +wrapper in `lib/vflutter_ffi.dart` does the `vf_free` in a `finally`, so callers | ||
| 61 | +never hold a pointer and never leak. | ||
| 62 | + | ||
| 63 | +## Usage | ||
| 64 | + | ||
| 65 | +```dart | ||
| 66 | +import 'package:vflutter_ffi/vflutter_ffi.dart' as v; | ||
| 67 | + | ||
| 68 | +v.add(20, 22); // 42 | ||
| 69 | +v.greet('Flutter'); // "Hello, Flutter, from V!" | ||
| 70 | +await v.greetAsync('isolate'); // same, off the UI isolate | ||
| 71 | +``` | ||
| 72 | + | ||
| 73 | +`-gc none` means no stop-the-world phase and no thread-local runtime state, so | ||
| 74 | +calls are safe from any isolate. Use `Isolate.run` for anything long enough to | ||
| 75 | +jank a frame. | ||
| 76 | + | ||
| 77 | +## Adding a function | ||
| 78 | + | ||
| 79 | +1. Export it in `src/vflutter.v` with `@[export: 'vf_yourthing']`, freeing temporaries. | ||
| 80 | +2. Declare it in `src/vflutter.h`. | ||
| 81 | +3. Wrap it in `lib/vflutter_ffi.dart`. | ||
| 82 | +4. `./tool/gen_ios_sources.sh` to refresh the iOS C. | ||
| 83 | +5. `./tool/build.sh` to smoke-test the host build. | ||
| 84 | + | ||
| 85 | +Step 2 also feeds `dart run ffigen --config ffigen.yaml` if you'd rather | ||
| 86 | +generate the raw bindings than hand-write them. | ||
| 87 | + | ||
| 88 | +## Status | ||
| 89 | + | ||
| 90 | +Verified on Linux with V 0.5.2 + Dart 3: build, string round-trip, isolate | ||
| 91 | +dispatch, and 900k-call memory stability. The Android/iOS/Windows glue is | ||
| 92 | +written to the standard `plugin_ffi` contract but is not exercised here — | ||
| 93 | +it needs a Flutter SDK and the respective toolchains. | ||
| 94 | + | ||
| 95 | +## Layout | ||
| 96 | + | ||
| 97 | +``` | ||
| 98 | +src/vflutter.v the V source — the only file you normally edit | ||
| 99 | +src/vflutter.h C declarations (ffigen input, Xcode input) | ||
| 100 | +src/CMakeLists.txt V -> C -> shared lib; shared by Android/Linux/Windows | ||
| 101 | +lib/vflutter_ffi.dart the Dart API callers use | ||
| 102 | +ios/, macos/ pre-generated C + podspec (static archive) | ||
| 103 | +android/build.gradle NDK build via externalNativeBuild | ||
| 104 | +tool/build.sh host build + export smoke test | ||
| 105 | +tool/gen_ios_sources.sh regenerate ios/ and macos/ C after editing the V source | ||
| 106 | +``` | ||
added
android/build.gradle +26 -0 | new file mode 100644 | ||
| @@ -0,0 +1,26 @@ | ||
| 1 | +group 'dev.vflutter.vflutter_ffi' | |
| 2 | +version '0.1.0' | |
| 3 | + | |
| 4 | +buildscript { | |
| 5 | + repositories { google(); mavenCentral() } | |
| 6 | + dependencies { classpath 'com.android.tools.build:gradle:8.1.0' } | |
| 7 | +} | |
| 8 | +rootProject.allprojects { repositories { google(); mavenCentral() } } | |
| 9 | + | |
| 10 | +apply plugin: 'com.android.library' | |
| 11 | + | |
| 12 | +android { | |
| 13 | + namespace 'dev.vflutter.vflutter_ffi' | |
| 14 | + compileSdk 34 | |
| 15 | + defaultConfig { | |
| 16 | + minSdk 21 | |
| 17 | + // V emits C; the NDK compiles it. No V-side cross-compilation needed. | |
| 18 | + externalNativeBuild { cmake { arguments '-DANDROID_STL=none' } } | |
| 19 | + } | |
| 20 | + externalNativeBuild { | |
| 21 | + cmake { | |
| 22 | + path '../src/CMakeLists.txt' | |
| 23 | + version '3.22.1' | |
| 24 | + } | |
| 25 | + } | |
| 26 | +} | |
| new file mode 100644 | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | +group 'dev.vflutter.vflutter_ffi' | ||
| 2 | +version '0.1.0' | ||
| 3 | + | ||
| 4 | +buildscript { | ||
| 5 | + repositories { google(); mavenCentral() } | ||
| 6 | + dependencies { classpath 'com.android.tools.build:gradle:8.1.0' } | ||
| 7 | +} | ||
| 8 | +rootProject.allprojects { repositories { google(); mavenCentral() } } | ||
| 9 | + | ||
| 10 | +apply plugin: 'com.android.library' | ||
| 11 | + | ||
| 12 | +android { | ||
| 13 | + namespace 'dev.vflutter.vflutter_ffi' | ||
| 14 | + compileSdk 34 | ||
| 15 | + defaultConfig { | ||
| 16 | + minSdk 21 | ||
| 17 | + // V emits C; the NDK compiles it. No V-side cross-compilation needed. | ||
| 18 | + externalNativeBuild { cmake { arguments '-DANDROID_STL=none' } } | ||
| 19 | + } | ||
| 20 | + externalNativeBuild { | ||
| 21 | + cmake { | ||
| 22 | + path '../src/CMakeLists.txt' | ||
| 23 | + version '3.22.1' | ||
| 24 | + } | ||
| 25 | + } | ||
| 26 | +} | ||
added
example/lib/main_test.dart +14 -0 | new file mode 100644 | ||
| @@ -0,0 +1,14 @@ | ||
| 1 | +import 'package:vflutter_ffi/vflutter_ffi.dart' as v; | |
| 2 | + | |
| 3 | +Future<void> main() async { | |
| 4 | + print('add(20, 22) = ${v.add(20, 22)}'); | |
| 5 | + print('greet("Flutter") = ${v.greet("Flutter")}'); | |
| 6 | + print('greetAsync = ${await v.greetAsync("isolate")}'); | |
| 7 | + | |
| 8 | + // Ownership check: if greet() leaked or double-freed V memory, | |
| 9 | + // a few thousand round trips would surface it. | |
| 10 | + for (var i = 0; i < 20000; i++) { | |
| 11 | + v.greet('stress$i'); | |
| 12 | + } | |
| 13 | + print('20k round trips = OK (no leak/double-free)'); | |
| 14 | +} | |
| new file mode 100644 | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | +import 'package:vflutter_ffi/vflutter_ffi.dart' as v; | ||
| 2 | + | ||
| 3 | +Future<void> main() async { | ||
| 4 | + print('add(20, 22) = ${v.add(20, 22)}'); | ||
| 5 | + print('greet("Flutter") = ${v.greet("Flutter")}'); | ||
| 6 | + print('greetAsync = ${await v.greetAsync("isolate")}'); | ||
| 7 | + | ||
| 8 | + // Ownership check: if greet() leaked or double-freed V memory, | ||
| 9 | + // a few thousand round trips would surface it. | ||
| 10 | + for (var i = 0; i < 20000; i++) { | ||
| 11 | + v.greet('stress$i'); | ||
| 12 | + } | ||
| 13 | + print('20k round trips = OK (no leak/double-free)'); | ||
| 14 | +} | ||
added
example/lib/memory_check.dart +21 -0 | new file mode 100644 | ||
| @@ -0,0 +1,21 @@ | ||
| 1 | +import 'dart:ffi'; | |
| 2 | +import 'dart:io'; | |
| 3 | +import 'package:ffi/ffi.dart'; | |
| 4 | +int rss() => int.parse(File('/proc/self/status').readAsLinesSync() | |
| 5 | + .firstWhere((l)=>l.startsWith('VmRSS')).split(RegExp(r'\s+'))[1]); | |
| 6 | + | |
| 7 | +void main(){ | |
| 8 | + final lib = DynamicLibrary.open('libvflutter.so'); | |
| 9 | + final greet = lib.lookupFunction<Pointer<Utf8> Function(Pointer<Utf8>), | |
| 10 | + Pointer<Utf8> Function(Pointer<Utf8>)>('vf_greet'); | |
| 11 | + final vfree = lib.lookupFunction<Void Function(Pointer<Void>), | |
| 12 | + void Function(Pointer<Void>)>('vf_free'); | |
| 13 | + | |
| 14 | + // Regression guard for the -gc none ownership rule: RSS must stay flat. | |
| 15 | + final arg = 'fixed'.toNativeUtf8(); | |
| 16 | + for (var i=0;i<5000;i++){ vfree(greet(arg).cast()); } | |
| 17 | + final before = rss(); | |
| 18 | + for (var i=0;i<900000;i++){ vfree(greet(arg).cast()); } | |
| 19 | + print('native-only before: $before kB after: ${rss()} kB'); | |
| 20 | + calloc.free(arg); | |
| 21 | +} | |
| new file mode 100644 | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | +import 'dart:ffi'; | ||
| 2 | +import 'dart:io'; | ||
| 3 | +import 'package:ffi/ffi.dart'; | ||
| 4 | +int rss() => int.parse(File('/proc/self/status').readAsLinesSync() | ||
| 5 | + .firstWhere((l)=>l.startsWith('VmRSS')).split(RegExp(r'\s+'))[1]); | ||
| 6 | + | ||
| 7 | +void main(){ | ||
| 8 | + final lib = DynamicLibrary.open('libvflutter.so'); | ||
| 9 | + final greet = lib.lookupFunction<Pointer<Utf8> Function(Pointer<Utf8>), | ||
| 10 | + Pointer<Utf8> Function(Pointer<Utf8>)>('vf_greet'); | ||
| 11 | + final vfree = lib.lookupFunction<Void Function(Pointer<Void>), | ||
| 12 | + void Function(Pointer<Void>)>('vf_free'); | ||
| 13 | + | ||
| 14 | + // Regression guard for the -gc none ownership rule: RSS must stay flat. | ||
| 15 | + final arg = 'fixed'.toNativeUtf8(); | ||
| 16 | + for (var i=0;i<5000;i++){ vfree(greet(arg).cast()); } | ||
| 17 | + final before = rss(); | ||
| 18 | + for (var i=0;i<900000;i++){ vfree(greet(arg).cast()); } | ||
| 19 | + print('native-only before: $before kB after: ${rss()} kB'); | ||
| 20 | + calloc.free(arg); | ||
| 21 | +} | ||
added
ffigen.yaml +14 -0 | new file mode 100644 | ||
| @@ -0,0 +1,14 @@ | ||
| 1 | +# Regenerate low-level bindings: dart run ffigen --config ffigen.yaml | |
| 2 | +# The hand-written API in lib/vflutter_ffi.dart wraps these. | |
| 3 | +name: VFlutterBindings | |
| 4 | +description: Raw bindings to the V C-ABI surface. | |
| 5 | +output: 'lib/src/bindings.g.dart' | |
| 6 | +headers: | |
| 7 | + entry-points: | |
| 8 | + - 'src/vflutter.h' | |
| 9 | +functions: | |
| 10 | + include: | |
| 11 | + - 'vf_.*' | |
| 12 | +preamble: | | |
| 13 | + // GENERATED — do not edit. See ffigen.yaml. | |
| 14 | + // ignore_for_file: always_specify_types, camel_case_types | |
| new file mode 100644 | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | +# Regenerate low-level bindings: dart run ffigen --config ffigen.yaml | ||
| 2 | +# The hand-written API in lib/vflutter_ffi.dart wraps these. | ||
| 3 | +name: VFlutterBindings | ||
| 4 | +description: Raw bindings to the V C-ABI surface. | ||
| 5 | +output: 'lib/src/bindings.g.dart' | ||
| 6 | +headers: | ||
| 7 | + entry-points: | ||
| 8 | + - 'src/vflutter.h' | ||
| 9 | +functions: | ||
| 10 | + include: | ||
| 11 | + - 'vf_.*' | ||
| 12 | +preamble: | | ||
| 13 | + // GENERATED — do not edit. See ffigen.yaml. | ||
| 14 | + // ignore_for_file: always_specify_types, camel_case_types | ||
added
ios/Classes/vflutter.gen.c +16587 -0 | new file mode 100644 | ||
| @@ -0,0 +1,16587 @@ | ||
| 1 | + | |
| 2 | +#ifndef V_COMMIT_HASH | |
| 3 | + #define V_COMMIT_HASH "45ae01d23168b6372f734eeb38a77360bbcf184a" | |
| 4 | +#endif | |
| 5 | + | |
| 6 | +#define V_USE_SIGNAL_H | |
| 7 | + | |
| 8 | +// V comptime_definitions: | |
| 9 | +// V compile time defines by -d or -define flags: | |
| 10 | +// All custom defines : linux | |
| 11 | +// Turned ON custom defines: linux | |
| 12 | +#define CUSTOM_DEFINE_linux | |
| 13 | + | |
| 14 | + | |
| 15 | +// V typedefs: | |
| 16 | +typedef struct IError IError; | |
| 17 | +typedef struct none none; | |
| 18 | + | |
| 19 | +// BEGIN_array_fixed_return_typedefs | |
| 20 | +typedef struct _v_Array_fixed_string_11 _v_Array_fixed_string_11; | |
| 21 | +typedef struct _v_Array_fixed_voidptr_11 _v_Array_fixed_voidptr_11; | |
| 22 | +typedef struct _v_Array_fixed_u8_128 _v_Array_fixed_u8_128; | |
| 23 | +typedef struct _v_Array_fixed_u8_32 _v_Array_fixed_u8_32; | |
| 24 | +typedef struct _v_Array_fixed_u8_64 _v_Array_fixed_u8_64; | |
| 25 | +typedef struct _v_Array_fixed_u8_5 _v_Array_fixed_u8_5; | |
| 26 | +typedef struct _v_Array_fixed_u8_20 _v_Array_fixed_u8_20; | |
| 27 | +typedef struct _v_Array_fixed_u8_15 _v_Array_fixed_u8_15; | |
| 28 | +typedef struct _v_Array_fixed_u8_6 _v_Array_fixed_u8_6; | |
| 29 | +typedef struct _v_Array_fixed_u8_256 _v_Array_fixed_u8_256; | |
| 30 | +typedef struct _v_Array_fixed_u64_309 _v_Array_fixed_u64_309; | |
| 31 | +typedef struct _v_Array_fixed_u64_324 _v_Array_fixed_u64_324; | |
| 32 | +typedef struct _v_Array_fixed_u32_10 _v_Array_fixed_u32_10; | |
| 33 | +typedef struct _v_Array_fixed_u64_20 _v_Array_fixed_u64_20; | |
| 34 | +typedef struct _v_Array_fixed_u64_584 _v_Array_fixed_u64_584; | |
| 35 | +typedef struct _v_Array_fixed_u64_652 _v_Array_fixed_u64_652; | |
| 36 | +typedef struct _v_Array_fixed_f64_36 _v_Array_fixed_f64_36; | |
| 37 | +typedef struct _v_Array_fixed_u8_26 _v_Array_fixed_u8_26; | |
| 38 | +typedef struct _v_Array_fixed_u8_512 _v_Array_fixed_u8_512; | |
| 39 | +typedef struct _v_Array_fixed_u64_47 _v_Array_fixed_u64_47; | |
| 40 | +typedef struct _v_Array_fixed_u64_31 _v_Array_fixed_u64_31; | |
| 41 | +typedef struct _v_Array_fixed_int_64 _v_Array_fixed_int_64; | |
| 42 | +typedef struct _v_Array_fixed_voidptr_64 _v_Array_fixed_voidptr_64; | |
| 43 | +typedef struct _v_Array_fixed_voidptr_100 _v_Array_fixed_voidptr_100; | |
| 44 | +typedef struct _v_Array_fixed_u8_1000 _v_Array_fixed_u8_1000; | |
| 45 | +typedef struct _v_Array_fixed_u8_17 _v_Array_fixed_u8_17; | |
| 46 | +typedef struct _v_Array_fixed_i32_1264 _v_Array_fixed_i32_1264; | |
| 47 | +typedef struct _v_Array_fixed_int_10 _v_Array_fixed_int_10; | |
| 48 | +typedef struct _v_Array_fixed_int_20 _v_Array_fixed_int_20; | |
| 49 | +// END_array_fixed_return_typedefs | |
| 50 | + | |
| 51 | + | |
| 52 | +// BEGIN_multi_return_typedefs | |
| 53 | +typedef struct multi_return_u32_u32 multi_return_u32_u32; | |
| 54 | +typedef struct multi_return_string_string multi_return_string_string; | |
| 55 | +typedef struct multi_return_int_int multi_return_int_int; | |
| 56 | +typedef struct multi_return_rune_int multi_return_rune_int; | |
| 57 | +typedef struct multi_return_u32_u32_u32 multi_return_u32_u32_u32; | |
| 58 | +typedef struct multi_return_strconv__ParserState_strconv__PrepNumber multi_return_strconv__ParserState_strconv__PrepNumber; | |
| 59 | +typedef struct multi_return_u64_int multi_return_u64_int; | |
| 60 | +typedef struct multi_return_i64_int multi_return_i64_int; | |
| 61 | +typedef struct multi_return_strconv__Dec32_bool multi_return_strconv__Dec32_bool; | |
| 62 | +typedef struct multi_return_strconv__Dec64_bool multi_return_strconv__Dec64_bool; | |
| 63 | +typedef struct multi_return_u64_u64 multi_return_u64_u64; | |
| 64 | +typedef struct multi_return_f64_int multi_return_f64_int; | |
| 65 | +// END_multi_return_typedefs | |
| 66 | + | |
| 67 | +typedef struct strings__IndentParam strings__IndentParam; | |
| 68 | +typedef struct builtin__closure__ClosurePage builtin__closure__ClosurePage; | |
| 69 | +typedef struct builtin__closure__ClosureLiveInfo builtin__closure__ClosureLiveInfo; | |
| 70 | +typedef struct builtin__closure__ClosureLifetimeRecord builtin__closure__ClosureLifetimeRecord; | |
| 71 | +typedef struct builtin__closure__ClosureLifetimeFrame builtin__closure__ClosureLifetimeFrame; | |
| 72 | +typedef struct builtin__closure__ClosureLifetimeState builtin__closure__ClosureLifetimeState; | |
| 73 | +typedef struct builtin__closure__Lifetime builtin__closure__Lifetime; | |
| 74 | +typedef struct builtin__closure__FrameToken builtin__closure__FrameToken; | |
| 75 | +typedef struct builtin__closure__Closure builtin__closure__Closure; | |
| 76 | +typedef struct builtin__closure__ClosureMutex builtin__closure__ClosureMutex; | |
| 77 | +typedef struct strconv__AtoF64Param strconv__AtoF64Param; | |
| 78 | +typedef struct strconv__BF_param strconv__BF_param; | |
| 79 | +typedef struct strconv__PrepNumber strconv__PrepNumber; | |
| 80 | +typedef struct strconv__Dec32 strconv__Dec32; | |
| 81 | +typedef struct strconv__Dec64 strconv__Dec64; | |
| 82 | +typedef struct strconv__Uint128 strconv__Uint128; | |
| 83 | +typedef union strconv__Uf32 strconv__Uf32; | |
| 84 | +typedef union strconv__Uf64 strconv__Uf64; | |
| 85 | +typedef union strconv__Float64u strconv__Float64u; | |
| 86 | +typedef union strconv__Float32u strconv__Float32u; | |
| 87 | +typedef struct GCHeapUsage GCHeapUsage; | |
| 88 | +typedef struct array array; | |
| 89 | +typedef struct ArrayDataHeader ArrayDataHeader; | |
| 90 | +typedef struct _result _result; | |
| 91 | +typedef struct Error Error; | |
| 92 | +typedef struct MessageError MessageError; | |
| 93 | +typedef struct _option _option; | |
| 94 | +typedef struct None__ None__; | |
| 95 | +typedef struct GraphemeState GraphemeState; | |
| 96 | +typedef struct InputRuneIterator InputRuneIterator; | |
| 97 | +typedef struct DenseArray DenseArray; | |
| 98 | +typedef struct map map; | |
| 99 | +typedef struct VAssertMetaInfo VAssertMetaInfo; | |
| 100 | +typedef struct SortedMap SortedMap; | |
| 101 | +typedef struct mapnode mapnode; | |
| 102 | +typedef struct string string; | |
| 103 | +typedef struct RepIndex RepIndex; | |
| 104 | +typedef struct WrapConfig WrapConfig; | |
| 105 | +typedef struct RunesIterator RunesIterator; | |
| 106 | +typedef union StrIntpMem StrIntpMem; | |
| 107 | +typedef struct StrIntpData StrIntpData; | |
| 108 | +typedef struct ToWideConfig ToWideConfig; | |
| 109 | +typedef struct _result_int _result_int; | |
| 110 | +typedef struct _result_builtin__closure__ClosureLifetimeState_ptr _result_builtin__closure__ClosureLifetimeState_ptr; | |
| 111 | +typedef struct _result_builtin__closure__FrameToken _result_builtin__closure__FrameToken; | |
| 112 | +typedef struct _result_void _result_void; | |
| 113 | +typedef struct _result_f64 _result_f64; | |
| 114 | +typedef struct _result_u64 _result_u64; | |
| 115 | +typedef struct _result_i64 _result_i64; | |
| 116 | +typedef struct _result_multi_return_i64_int _result_multi_return_i64_int; | |
| 117 | +typedef struct _result_i8 _result_i8; | |
| 118 | +typedef struct _result_i16 _result_i16; | |
| 119 | +typedef struct _result_i32 _result_i32; | |
| 120 | +typedef struct _result_u8 _result_u8; | |
| 121 | +typedef struct _result_u16 _result_u16; | |
| 122 | +typedef struct _result_u32 _result_u32; | |
| 123 | +typedef struct _result_rune _result_rune; | |
| 124 | +typedef struct _result_string _result_string; | |
| 125 | +typedef struct _option_builtin__closure__ClosureLiveInfo _option_builtin__closure__ClosureLiveInfo; | |
| 126 | +typedef struct _option_builtin__closure__ClosureLifetimeState_ptr _option_builtin__closure__ClosureLifetimeState_ptr; | |
| 127 | +typedef struct _option_int _option_int; | |
| 128 | +typedef struct _option_rune _option_rune; | |
| 129 | +typedef struct _option_multi_return_string_string _option_multi_return_string_string; | |
| 130 | +typedef struct _option_u8 _option_u8; | |
| 131 | + | |
| 132 | + // V preincludes: | |
| 133 | +#define _GNU_SOURCE | |
| 134 | + | |
| 135 | +#if defined(__TINYC__) && defined(__has_include) // tcc does not support has_include properly yet, turn it off completely | |
| 136 | +#undef __has_include | |
| 137 | +#endif | |
| 138 | + | |
| 139 | +#if defined(__TINYC__) && defined(__BIONIC__) | |
| 140 | + #define __builtin_nanf(ignored_string) (0.0F / 0.0F) | |
| 141 | + #define __builtin_nan(ignored_string) (0.0 / 0.0) | |
| 142 | + #define __builtin_nanl(ignored_string) (0.0L / 0.0L) | |
| 143 | + #define __builtin_inff() (1.0F / 0.0F) | |
| 144 | + #define __builtin_inf() (1.0 / 0.0) | |
| 145 | + #define __builtin_infl() (1.0L / 0.0L) | |
| 146 | + #define __builtin_huge_valf() (1.0F / 0.0F) | |
| 147 | + #define __builtin_huge_val() (1.0 / 0.0) | |
| 148 | + #define __builtin_huge_vall() (1.0L / 0.0L) | |
| 149 | +#endif | |
| 150 | + | |
| 151 | +// V cheaders: | |
| 152 | +// Generated by the V compiler | |
| 153 | + | |
| 154 | +#if defined __GNUC__ && __GNUC__ >= 14 | |
| 155 | +#pragma GCC diagnostic warning "-Wimplicit-function-declaration" | |
| 156 | +#pragma GCC diagnostic warning "-Wincompatible-pointer-types" | |
| 157 | +#pragma GCC diagnostic warning "-Wint-conversion" | |
| 158 | +#pragma GCC diagnostic warning "-Wreturn-mismatch" | |
| 159 | +#endif | |
| 160 | + | |
| 161 | + | |
| 162 | +#if defined(__TINYC__) && defined(__has_include) // tcc does not support has_include properly yet, turn it off completely | |
| 163 | +#undef __has_include | |
| 164 | +#endif | |
| 165 | + | |
| 166 | +#if defined(__TINYC__) && defined(__BIONIC__) | |
| 167 | + #define __builtin_nanf(ignored_string) (0.0F / 0.0F) | |
| 168 | + #define __builtin_nan(ignored_string) (0.0 / 0.0) | |
| 169 | + #define __builtin_nanl(ignored_string) (0.0L / 0.0L) | |
| 170 | + #define __builtin_inff() (1.0F / 0.0F) | |
| 171 | + #define __builtin_inf() (1.0 / 0.0) | |
| 172 | + #define __builtin_infl() (1.0L / 0.0L) | |
| 173 | + #define __builtin_huge_valf() (1.0F / 0.0F) | |
| 174 | + #define __builtin_huge_val() (1.0 / 0.0) | |
| 175 | + #define __builtin_huge_vall() (1.0L / 0.0L) | |
| 176 | +#endif | |
| 177 | + | |
| 178 | +#ifdef __TINYC__ | |
| 179 | +#include <inttypes.h> | |
| 180 | +#else | |
| 181 | +#if defined(__has_include) | |
| 182 | +#if __has_include(<inttypes.h>) | |
| 183 | +#include <inttypes.h> | |
| 184 | +#elif __has_include(<stdint.h>) | |
| 185 | +#include <stdint.h> | |
| 186 | +#else | |
| 187 | +#error VERROR_MESSAGE The C compiler can not find <stdint.h>. Please install the package `build-essential`. | |
| 188 | +#endif | |
| 189 | +#else | |
| 190 | +#include <stdint.h> | |
| 191 | +#endif | |
| 192 | +#endif | |
| 193 | + | |
| 194 | + | |
| 195 | +#ifdef __TINYC__ | |
| 196 | +#include <stddef.h> | |
| 197 | +#else | |
| 198 | +#if defined(__has_include) | |
| 199 | +#if __has_include(<stddef.h>) | |
| 200 | +#include <stddef.h> | |
| 201 | +#else | |
| 202 | +#error VERROR_MESSAGE The C compiler can not find <stddef.h>. Please install the package `build-essential`. | |
| 203 | +#endif | |
| 204 | +#else | |
| 205 | +#include <stddef.h> | |
| 206 | +#endif | |
| 207 | +#endif | |
| 208 | + | |
| 209 | + | |
| 210 | +//================================== builtin types ================================*/ | |
| 211 | +#if defined(__x86_64__) || defined(_M_AMD64) || defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64) || (defined(__riscv_xlen) && __riscv_xlen == 64) || defined(__s390x__) || (defined(__powerpc64__) && defined(__LITTLE_ENDIAN__)) || defined(__loongarch64) || defined(__sparc__) || (defined(__powerpc64__) && defined(__BIG_ENDIAN__)) | |
| 212 | +typedef int64_t vint_t; | |
| 213 | +#else | |
| 214 | +typedef int32_t vint_t; | |
| 215 | +#endif | |
| 216 | +typedef int64_t i64; | |
| 217 | +typedef int16_t i16; | |
| 218 | +typedef int8_t i8; | |
| 219 | +typedef uint64_t u64; | |
| 220 | +typedef uint32_t u32; | |
| 221 | +typedef uint8_t u8; | |
| 222 | +typedef uint16_t u16; | |
| 223 | +typedef u8 byte; | |
| 224 | +typedef int32_t i32; | |
| 225 | +typedef uint32_t rune; | |
| 226 | +typedef size_t usize; | |
| 227 | +typedef ptrdiff_t isize; | |
| 228 | +#ifndef VNOFLOAT | |
| 229 | +typedef float f32; | |
| 230 | +typedef double f64; | |
| 231 | +#else | |
| 232 | +typedef int32_t f32; | |
| 233 | +typedef int64_t f64; | |
| 234 | +#endif | |
| 235 | +typedef int64_t int_literal; | |
| 236 | +#ifndef VNOFLOAT | |
| 237 | +typedef double float_literal; | |
| 238 | +#else | |
| 239 | +typedef int64_t float_literal; | |
| 240 | +#endif | |
| 241 | +typedef unsigned char* byteptr; | |
| 242 | +typedef void* voidptr; | |
| 243 | +typedef char* charptr; | |
| 244 | +typedef u8 array_fixed_byte_300 [300]; | |
| 245 | +typedef struct sync__Channel* chan; | |
| 246 | +#ifndef CUSTOM_DEFINE_no_bool | |
| 247 | + #ifndef __cplusplus | |
| 248 | + #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 202311L | |
| 249 | + #ifndef bool | |
| 250 | + #ifdef CUSTOM_DEFINE_4bytebool | |
| 251 | + typedef int bool; | |
| 252 | + #else | |
| 253 | + typedef u8 bool; | |
| 254 | + #endif | |
| 255 | + #define true 1 | |
| 256 | + #define false 0 | |
| 257 | + #endif | |
| 258 | + #endif | |
| 259 | + #endif | |
| 260 | +#endif | |
| 261 | + | |
| 262 | + | |
| 263 | +#define V_SAFE_SHIFT_BITS(type) ((u64)(sizeof(type) * 8)) | |
| 264 | +#define V_SAFE_LSHIFT_UNSIGNED(name, type) static inline type name(type x, u64 y) { return y >= V_SAFE_SHIFT_BITS(type) ? (type)0 : (type)(x << y); } | |
| 265 | +#define V_SAFE_LSHIFT_SIGNED(name, type, unsigned_type) static inline type name(type x, u64 y) { return y >= V_SAFE_SHIFT_BITS(type) ? (type)0 : (type)(((unsigned_type)x) << y); } | |
| 266 | +#define V_SAFE_RSHIFT_UNSIGNED(name, type) static inline type name(type x, u64 y) { return y >= V_SAFE_SHIFT_BITS(type) ? (type)0 : (type)(x >> y); } | |
| 267 | +#define V_SAFE_RSHIFT_SIGNED(name, type) static inline type name(type x, u64 y) { return y >= V_SAFE_SHIFT_BITS(type) ? (type)(x < 0 ? -1 : 0) : (type)(x >> y); } | |
| 268 | +V_SAFE_LSHIFT_SIGNED(v__lshift_char, char, u8) | |
| 269 | +V_SAFE_RSHIFT_SIGNED(v__rshift_char, char) | |
| 270 | +V_SAFE_LSHIFT_SIGNED(v__lshift_i8, i8, u8) | |
| 271 | +V_SAFE_RSHIFT_SIGNED(v__rshift_i8, i8) | |
| 272 | +V_SAFE_LSHIFT_SIGNED(v__lshift_i16, i16, u16) | |
| 273 | +V_SAFE_RSHIFT_SIGNED(v__rshift_i16, i16) | |
| 274 | +V_SAFE_LSHIFT_SIGNED(v__lshift_i32, i32, u32) | |
| 275 | +V_SAFE_RSHIFT_SIGNED(v__rshift_i32, i32) | |
| 276 | +V_SAFE_LSHIFT_SIGNED(v__lshift_int, int, unsigned int) | |
| 277 | +V_SAFE_RSHIFT_SIGNED(v__rshift_int, int) | |
| 278 | +V_SAFE_LSHIFT_SIGNED(v__lshift_vint_t, vint_t, u64) | |
| 279 | +V_SAFE_RSHIFT_SIGNED(v__rshift_vint_t, vint_t) | |
| 280 | +V_SAFE_LSHIFT_SIGNED(v__lshift_i64, i64, u64) | |
| 281 | +V_SAFE_RSHIFT_SIGNED(v__rshift_i64, i64) | |
| 282 | +V_SAFE_LSHIFT_SIGNED(v__lshift_isize, isize, usize) | |
| 283 | +V_SAFE_RSHIFT_SIGNED(v__rshift_isize, isize) | |
| 284 | +V_SAFE_LSHIFT_UNSIGNED(v__lshift_u8, u8) | |
| 285 | +V_SAFE_RSHIFT_UNSIGNED(v__rshift_u8, u8) | |
| 286 | +V_SAFE_LSHIFT_UNSIGNED(v__lshift_u16, u16) | |
| 287 | +V_SAFE_RSHIFT_UNSIGNED(v__rshift_u16, u16) | |
| 288 | +V_SAFE_LSHIFT_UNSIGNED(v__lshift_u32, u32) | |
| 289 | +V_SAFE_RSHIFT_UNSIGNED(v__rshift_u32, u32) | |
| 290 | +V_SAFE_LSHIFT_UNSIGNED(v__lshift_u64, u64) | |
| 291 | +V_SAFE_RSHIFT_UNSIGNED(v__rshift_u64, u64) | |
| 292 | +V_SAFE_LSHIFT_UNSIGNED(v__lshift_usize, usize) | |
| 293 | +V_SAFE_RSHIFT_UNSIGNED(v__rshift_usize, usize) | |
| 294 | +V_SAFE_LSHIFT_UNSIGNED(v__lshift_rune, rune) | |
| 295 | +V_SAFE_RSHIFT_UNSIGNED(v__rshift_rune, rune) | |
| 296 | +V_SAFE_LSHIFT_SIGNED(v__lshift_int_literal, int_literal, u64) | |
| 297 | +V_SAFE_RSHIFT_SIGNED(v__rshift_int_literal, int_literal) | |
| 298 | +#undef V_SAFE_RSHIFT_SIGNED | |
| 299 | +#undef V_SAFE_RSHIFT_UNSIGNED | |
| 300 | +#undef V_SAFE_LSHIFT_SIGNED | |
| 301 | +#undef V_SAFE_LSHIFT_UNSIGNED | |
| 302 | +#undef V_SAFE_SHIFT_BITS | |
| 303 | + | |
| 304 | + | |
| 305 | +typedef u64 (*MapHashFn)(voidptr); | |
| 306 | +typedef bool (*MapEqFn)(voidptr, voidptr); | |
| 307 | +typedef void (*MapCloneFn)(voidptr, voidptr); | |
| 308 | +typedef void (*MapFreeFn)(voidptr); | |
| 309 | + | |
| 310 | +//============================== HELPER C MACROS =============================*/ | |
| 311 | +// _SLIT0 is used as NULL string for literal arguments | |
| 312 | +// `"" s` is used to enforce a string literal argument | |
| 313 | +#define _SLIT0 (string){.str=(byteptr)(""), .len=0, .is_lit=1} | |
| 314 | +#define _S(s) ((string){.str=(byteptr)("" s), .len=(sizeof(s)-1), .is_lit=1}) | |
| 315 | +#define _SLEN(s, n) ((string){.str=(byteptr)("" s), .len=n, .is_lit=1}) | |
| 316 | +// optimized way to compare literal strings | |
| 317 | +#define _SLIT_EQ(sptr, slen, lit) (slen == sizeof("" lit)-1 && !builtin__vmemcmp(sptr, "" lit, slen)) | |
| 318 | +#define _SLIT_NE(sptr, slen, lit) (slen != sizeof("" lit)-1 || builtin__vmemcmp(sptr, "" lit, slen)) | |
| 319 | +// take the address of an rvalue | |
| 320 | +#define ADDR(type, expr) (&((type[]){expr}[0])) | |
| 321 | +// copy something to the heap | |
| 322 | +#define HEAP(type, expr) ((type*)builtin__memdup((void*)&((type[]){expr}[0]), sizeof(type))) | |
| 323 | +#define HEAP_noscan(type, expr) ((type*)builtin__memdup_noscan((void*)&((type[]){expr}[0]), sizeof(type))) | |
| 324 | +#define HEAP_align(type, expr, align) ((type*)builtin__memdup_align((void*)&((type[]){expr}[0]), sizeof(type), align)) | |
| 325 | +#define HEAP_vgc(type, expr, ptrmap, nptrs) ((type*)builtin__vgc_memdup_typed((void*)&((type[]){expr}[0]), sizeof(type), (ptrmap), (nptrs))) | |
| 326 | +#define _PUSH_MANY(arr, val, tmp, tmp_typ) {tmp_typ tmp = (val); builtin__array_push_many(arr, tmp.data, tmp.len);} | |
| 327 | +#define _PUSH_MANY_noscan(arr, val, tmp, tmp_typ) {tmp_typ tmp = (val); builtin__array_push_many_noscan(arr, tmp.data, tmp.len);} | |
| 328 | + | |
| 329 | +#define E_STRUCT_DECL | |
| 330 | +#define E_STRUCT | |
| 331 | +#define __NOINLINE __attribute__((noinline)) | |
| 332 | +#define __IRQHANDLER __attribute__((interrupt)) | |
| 333 | +#define __V_architecture 0 | |
| 334 | +#if defined(__x86_64__) || defined(_M_AMD64) | |
| 335 | + #define __V_amd64 1 | |
| 336 | + #undef __V_architecture | |
| 337 | + #define __V_architecture 1 | |
| 338 | +#endif | |
| 339 | +#if defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64) | |
| 340 | + #define __V_arm64 1 | |
| 341 | + #undef __V_architecture | |
| 342 | + #define __V_architecture 2 | |
| 343 | +#endif | |
| 344 | +#if defined(__arm__) || defined(_M_ARM) | |
| 345 | + #define __V_arm32 1 | |
| 346 | + #undef __V_architecture | |
| 347 | + #define __V_architecture 3 | |
| 348 | +#endif | |
| 349 | +#if defined(__riscv) && __riscv_xlen == 64 | |
| 350 | + #define __V_rv64 1 | |
| 351 | + #undef __V_architecture | |
| 352 | + #define __V_architecture 4 | |
| 353 | +#endif | |
| 354 | +#if defined(__riscv) && __riscv_xlen == 32 | |
| 355 | + #define __V_rv32 1 | |
| 356 | + #undef __V_architecture | |
| 357 | + #define __V_architecture 5 | |
| 358 | +#endif | |
| 359 | +#if defined(__i386__) || defined(_M_IX86) | |
| 360 | + #define __V_x86 1 | |
| 361 | + #undef __V_architecture | |
| 362 | + #define __V_architecture 6 | |
| 363 | +#endif | |
| 364 | +#if defined(__s390x__) | |
| 365 | + #define __V_s390x 1 | |
| 366 | + #undef __V_architecture | |
| 367 | + #define __V_architecture 7 | |
| 368 | +#endif | |
| 369 | +#if defined(__powerpc64__) && defined(__LITTLE_ENDIAN__) | |
| 370 | + #define __V_ppc64le 1 | |
| 371 | + #undef __V_architecture | |
| 372 | + #define __V_architecture 8 | |
| 373 | +#endif | |
| 374 | +#if defined(__loongarch64) | |
| 375 | + #define __V_loongarch64 1 | |
| 376 | + #undef __V_architecture | |
| 377 | + #define __V_architecture 9 | |
| 378 | +#endif | |
| 379 | +#if defined(__sparc__) | |
| 380 | + #define __V_sparc64 1 | |
| 381 | + #undef __V_architecture | |
| 382 | + #define __V_architecture 10 | |
| 383 | +#endif | |
| 384 | +#if defined(__powerpc64__) && defined(__BIG_ENDIAN__) | |
| 385 | + #define __V_ppc64 1 | |
| 386 | + #undef __V_architecture | |
| 387 | + #define __V_architecture 11 | |
| 388 | +#endif | |
| 389 | +#if (defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) || defined(__ppc__) || defined(__ppc) || defined(__PPC__)) && !defined(__powerpc64__) && !defined(__ppc64__) && !defined(__PPC64__) | |
| 390 | + #define __V_ppc 1 | |
| 391 | + #undef __V_architecture | |
| 392 | + #define __V_architecture 12 | |
| 393 | +#endif | |
| 394 | +// Using just __GNUC__ for detecting gcc, is not reliable because other compilers define it too: | |
| 395 | +#ifdef __GNUC__ | |
| 396 | + #define __V_GCC__ | |
| 397 | +#endif | |
| 398 | +#ifdef __TINYC__ | |
| 399 | + #undef __V_GCC__ | |
| 400 | +#endif | |
| 401 | +#ifdef __cplusplus | |
| 402 | + #undef __V_GCC__ | |
| 403 | +#endif | |
| 404 | +#ifdef __clang__ | |
| 405 | + #undef __V_GCC__ | |
| 406 | +#endif | |
| 407 | +#ifdef _MSC_VER | |
| 408 | + #undef __V_GCC__ | |
| 409 | + #undef E_STRUCT_DECL | |
| 410 | + #undef E_STRUCT | |
| 411 | + #define E_STRUCT_DECL unsigned char _dummy_pad | |
| 412 | + #define E_STRUCT 0 | |
| 413 | +#endif | |
| 414 | +#if defined(__has_include) && !defined(__TINYC__) | |
| 415 | + #if __has_include(<execinfo.h>) && !defined(_WIN32) | |
| 416 | + #define __V_HAVE_EXECINFO_H 1 | |
| 417 | + #include <execinfo.h> | |
| 418 | + #else | |
| 419 | + // On linux: int backtrace(void **__array, int __size); | |
| 420 | + // On BSD: size_t backtrace(void **, size_t); | |
| 421 | + #endif | |
| 422 | +#elif (defined(__linux__) && (defined(__GLIBC__) || defined(__GNU_LIBRARY__))) || defined(__APPLE__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) | |
| 423 | + #define __V_HAVE_EXECINFO_H 1 | |
| 424 | + #include <execinfo.h> | |
| 425 | +#else | |
| 426 | + // On linux: int backtrace(void **__array, int __size); | |
| 427 | + // On BSD: size_t backtrace(void **, size_t); | |
| 428 | +#endif | |
| 429 | +#ifndef __V_HAVE_EXECINFO_H | |
| 430 | + #ifdef __cplusplus | |
| 431 | + extern "C" { | |
| 432 | + #endif | |
| 433 | + int backtrace(void **__array, int __size); | |
| 434 | + char **backtrace_symbols(void *const *__array, int __size); | |
| 435 | + void backtrace_symbols_fd(void *const *__array, int __size, int __fd); | |
| 436 | + #ifdef __cplusplus | |
| 437 | + } | |
| 438 | + #endif | |
| 439 | +#endif | |
| 440 | +#ifdef __TINYC__ | |
| 441 | + #define _Atomic volatile | |
| 442 | + #undef E_STRUCT_DECL | |
| 443 | + #undef E_STRUCT | |
| 444 | + #define E_STRUCT_DECL unsigned char _dummy_pad | |
| 445 | + #define E_STRUCT 0 | |
| 446 | + #undef __NOINLINE | |
| 447 | + #undef __IRQHANDLER | |
| 448 | + // tcc does not support inlining at all | |
| 449 | + #define __NOINLINE | |
| 450 | + #define __IRQHANDLER | |
| 451 | + // #include <byteswap.h> | |
| 452 | + int tcc_backtrace(const char *fmt, ...); | |
| 453 | +#endif | |
| 454 | +// Use __offsetof_ptr instead of __offset_of, when you *do* have a valid pointer, to avoid UB: | |
| 455 | +#ifndef __offsetof_ptr | |
| 456 | + #define __offsetof_ptr(ptr,PTYPE,FIELDNAME) ((size_t)((byte *)&((PTYPE *)ptr)->FIELDNAME - (byte *)ptr)) | |
| 457 | +#endif | |
| 458 | +// for __offset_of | |
| 459 | +#ifndef __offsetof | |
| 460 | +#if defined(__TINYC__) || defined(_MSC_VER) | |
| 461 | + #define __offsetof(PTYPE,FIELDNAME) ((size_t)(&((PTYPE *)0)->FIELDNAME)) | |
| 462 | +#else | |
| 463 | + #define __offsetof(st, m) __builtin_offsetof(st, m) | |
| 464 | +#endif | |
| 465 | +#endif | |
| 466 | +#if defined(_WIN32) || defined(__CYGWIN__) | |
| 467 | + #define VV_EXP extern __declspec(dllexport) | |
| 468 | + #ifdef _VPARALLELCC | |
| 469 | + #define VV_LOC | |
| 470 | + #else | |
| 471 | + #define VV_LOC static | |
| 472 | + #endif | |
| 473 | +#else | |
| 474 | + // 4 < gcc < 5 is used by some older Ubuntu LTS and Centos versions, | |
| 475 | + // and does not support __has_attribute(visibility) ... | |
| 476 | + #ifndef __has_attribute | |
| 477 | + #define __has_attribute(x) 0 // Compatibility with non-clang compilers. | |
| 478 | + #endif | |
| 479 | + #if (defined(__GNUC__) && (__GNUC__ >= 4)) || (defined(__clang__) && __has_attribute(visibility)) | |
| 480 | + #ifdef ARM | |
| 481 | + #define VV_EXP extern __attribute__((externally_visible,visibility("default"))) | |
| 482 | + #else | |
| 483 | + #define VV_EXP extern __attribute__((visibility("default"))) | |
| 484 | + #endif | |
| 485 | + #if defined(_VOBJECTFILE) || (defined(__clang__) && (defined(_VUSECACHE) || defined(_VBUILDMODULE))) | |
| 486 | + #define VV_LOC static | |
| 487 | + #else | |
| 488 | + #define VV_LOC __attribute__ ((visibility ("hidden"))) | |
| 489 | + #endif | |
| 490 | + #else | |
| 491 | + #define VV_EXP extern | |
| 492 | + #ifdef _VPARALLELCC | |
| 493 | + #define VV_LOC | |
| 494 | + #else | |
| 495 | + #define VV_LOC static | |
| 496 | + #endif | |
| 497 | + #endif | |
| 498 | +#endif | |
| 499 | +#ifdef __cplusplus | |
| 500 | + #include <utility> | |
| 501 | + #define _MOV std::move | |
| 502 | +#else | |
| 503 | + #define _MOV | |
| 504 | +#endif | |
| 505 | +#if defined(__TINYC__) && defined(__has_include) // tcc does not support has_include properly yet, turn it off completely | |
| 506 | +#undef __has_include | |
| 507 | +#endif | |
| 508 | +//likely and unlikely macros | |
| 509 | +#if defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__clang__) | |
| 510 | + #define _likely_(x) __builtin_expect(x,1) | |
| 511 | + #define _unlikely_(x) __builtin_expect(x,0) | |
| 512 | +#else | |
| 513 | + #define _likely_(x) (x) | |
| 514 | + #define _unlikely_(x) (x) | |
| 515 | +#endif | |
| 516 | + | |
| 517 | +#if !defined(VCALLCONV) | |
| 518 | + #ifdef _MSC_VER | |
| 519 | + #define VCALLCONV(name) __##name | |
| 520 | + #else | |
| 521 | + #define VCALLCONV(name) __attribute__((name)) | |
| 522 | + #endif | |
| 523 | +#endif | |
| 524 | + | |
| 525 | +// c_headers | |
| 526 | +typedef int (*qsort_callback_func)(const void*, const void*); | |
| 527 | +#if defined(_MSC_VER) && !defined(__clang__) | |
| 528 | + #define V_CRT_LINKAGE __declspec(dllimport) | |
| 529 | + #define V_CRT_CALL VCALLCONV(cdecl) | |
| 530 | +#else | |
| 531 | + #define V_CRT_LINKAGE | |
| 532 | + #define V_CRT_CALL | |
| 533 | +#endif | |
| 534 | +#if (defined(_MSC_VER) && !defined(__clang__)) || defined(__cplusplus) | |
| 535 | +// Under C++ (g++/clang++), let libc declare FILE/stdio/string/stdlib to keep | |
| 536 | +// noexcept specifiers consistent — the manual extern "C" prototypes below | |
| 537 | +// would otherwise conflict with system headers under -std=c++NN. | |
| 538 | +#include <stdarg.h> | |
| 539 | +#include <stdio.h> | |
| 540 | +#include <stdlib.h> | |
| 541 | +#include <string.h> | |
| 542 | +#ifndef va_copy | |
| 543 | + #define va_copy(dest, src) ((dest) = (src)) | |
| 544 | +#endif | |
| 545 | +#ifndef _TRUNCATE | |
| 546 | + #define _TRUNCATE ((size_t)-1) | |
| 547 | +#endif | |
| 548 | +#elif defined(__NetBSD__) | |
| 549 | +// NetBSD exposes stdin/stdout/stderr as macros into a single `__sF[3]` | |
| 550 | +// array whose element size (sizeof(FILE)) depends on the platform and libc | |
| 551 | +// version, so we cannot forward-declare them. The FreeBSD-style | |
| 552 | +// `__stdinp/__stdoutp/__stderrp` symbols also do not exist on NetBSD (see | |
| 553 | +// vlang/v#27190). Defer to the system headers for FILE, the stdio streams, | |
| 554 | +// and the libc prototypes that would otherwise clash with the | |
| 555 | +// `__restrict`-qualified declarations in NetBSD libc. | |
| 556 | +#include <stdarg.h> | |
| 557 | +#include <stdio.h> | |
| 558 | +#include <stdlib.h> | |
| 559 | +#include <string.h> | |
| 560 | +#elif defined(__TINYC__) && (defined(__FreeBSD__) || defined(__OpenBSD__)) | |
| 561 | +// TinyCC reports a hard redefinition error if system OpenSSL pulls in | |
| 562 | +// <stdarg.h> after V has provided its own va_start macro. Include it first, | |
| 563 | +// but keep V manual FILE declarations on these BSD libc variants. | |
| 564 | +#include <stdarg.h> | |
| 565 | +#if defined(__FreeBSD__) | |
| 566 | +typedef struct __sFILE FILE; | |
| 567 | +extern FILE* __stdinp; | |
| 568 | +extern FILE* __stdoutp; | |
| 569 | +extern FILE* __stderrp; | |
| 570 | +#define stdin __stdinp | |
| 571 | +#define stdout __stdoutp | |
| 572 | +#define stderr __stderrp | |
| 573 | +#else | |
| 574 | +typedef struct __sFILE FILE; | |
| 575 | +#ifndef _STDFILES_DECLARED | |
| 576 | + #define _STDFILES_DECLARED | |
| 577 | +struct __sFstub { long _stub; }; | |
| 578 | +extern struct __sFstub __stdin[]; | |
| 579 | +extern struct __sFstub __stdout[]; | |
| 580 | +extern struct __sFstub __stderr[]; | |
| 581 | +#endif | |
| 582 | +#define stdin ((struct __sFILE *)__stdin) | |
| 583 | +#define stdout ((struct __sFILE *)__stdout) | |
| 584 | +#define stderr ((struct __sFILE *)__stderr) | |
| 585 | +#endif | |
| 586 | +#elif (defined(__MINGW32__) || defined(__MINGW64__)) && defined(__V_GCC__) | |
| 587 | +// mingw-w64 stdio.h provides fprintf/vfprintf as static inline overrides | |
| 588 | +// when __USE_MINGW_ANSI_STDIO is enabled, so use the system declarations | |
| 589 | +// instead of the manual formatted-stdio prototypes below. | |
| 590 | +#include <stdarg.h> | |
| 591 | +#include <stdio.h> | |
| 592 | +#elif defined(__MINGW32__) || defined(__MINGW64__) || (defined(__clang__) && (defined(_WIN32) || defined(_WIN64))) | |
| 593 | +typedef struct _iobuf FILE; | |
| 594 | +FILE* __cdecl __acrt_iob_func(unsigned index); | |
| 595 | +#define stdin (__acrt_iob_func(0)) | |
| 596 | +#define stdout (__acrt_iob_func(1)) | |
| 597 | +#define stderr (__acrt_iob_func(2)) | |
| 598 | +#elif defined(__TINYC__) && (defined(_WIN32) || defined(_WIN64)) | |
| 599 | +#ifndef _FILE_DEFINED | |
| 600 | +struct _iobuf { | |
| 601 | + char *_ptr; | |
| 602 | + int _cnt; | |
| 603 | + char *_base; | |
| 604 | + int _flag; | |
| 605 | + int _file; | |
| 606 | + int _charbuf; | |
| 607 | + int _bufsiz; | |
| 608 | + char *_tmpfname; | |
| 609 | +}; | |
| 610 | +typedef struct _iobuf FILE; | |
| 611 | +#define _FILE_DEFINED | |
| 612 | +#endif | |
| 613 | + #if defined(_WIN64) | |
| 614 | +FILE* __cdecl __iob_func(void); | |
| 615 | + #else | |
| 616 | + #ifdef _MSVCRT_ | |
| 617 | +extern FILE _iob[]; | |
| 618 | + #define __iob_func() (_iob) | |
| 619 | + #else | |
| 620 | +extern FILE (*_imp___iob)[]; | |
| 621 | + #define __iob_func() (*_imp___iob) | |
| 622 | + #define _iob __iob_func() | |
| 623 | + #endif | |
| 624 | + #endif | |
| 625 | +#define stdin (&__iob_func()[0]) | |
| 626 | +#define stdout (&__iob_func()[1]) | |
| 627 | +#define stderr (&__iob_func()[2]) | |
| 628 | +#elif defined(__vinix__) | |
| 629 | +typedef struct __file FILE; | |
| 630 | +extern FILE* stdin; | |
| 631 | +extern FILE* stdout; | |
| 632 | +extern FILE* stderr; | |
| 633 | +struct __thread_data; | |
| 634 | +struct __threadattr; | |
| 635 | +// pthread_t handling for vinix builds: | |
| 636 | +// - Vinix kernel (freestanding, __STDC_HOSTED__=0): no libc, define | |
| 637 | +// pthread_t ourselves so V code that references it compiles. | |
| 638 | +// - util-vinix cross-compiled on a libc-providing host (hosted, e.g. | |
| 639 | +// glibc on Linux or macOS with -D__vinix__): pull pthread_t from | |
| 640 | +// libc to avoid colliding with the libc typedef. | |
| 641 | +#if defined(__STDC_HOSTED__) && __STDC_HOSTED__ && defined(__has_include) && __has_include(<pthread.h>) | |
| 642 | +#include <pthread.h> | |
| 643 | +#else | |
| 644 | +typedef struct __thread_data *pthread_t; | |
| 645 | +#endif | |
| 646 | +typedef __builtin_va_list va_list; | |
| 647 | +#ifndef va_start | |
| 648 | + #define va_start(ap, v) __builtin_va_start(ap, v) | |
| 649 | +#endif | |
| 650 | +#ifndef va_arg | |
| 651 | + #define va_arg(ap, t) __builtin_va_arg(ap, t) | |
| 652 | +#endif | |
| 653 | +#ifndef va_end | |
| 654 | + #define va_end(ap) __builtin_va_end(ap) | |
| 655 | +#endif | |
| 656 | +#ifndef va_copy | |
| 657 | + #define va_copy(dest, src) __builtin_va_copy(dest, src) | |
| 658 | +#endif | |
| 659 | +#else | |
| 660 | + #if defined(__APPLE__) || defined(__FreeBSD__) | |
| 661 | +typedef struct __sFILE FILE; | |
| 662 | +extern FILE* __stdinp; | |
| 663 | +extern FILE* __stdoutp; | |
| 664 | +extern FILE* __stderrp; | |
| 665 | +#define stdin __stdinp | |
| 666 | +#define stdout __stdoutp | |
| 667 | +#define stderr __stderrp | |
| 668 | + #elif defined(__DragonFly__) | |
| 669 | +typedef struct __sFILE FILE; | |
| 670 | +extern FILE* __stdinp; | |
| 671 | +extern FILE* __stdoutp; | |
| 672 | +extern FILE* __stderrp; | |
| 673 | +#define stdin __stdinp | |
| 674 | +#define stdout __stdoutp | |
| 675 | +#define stderr __stderrp | |
| 676 | + #elif defined(__OpenBSD__) | |
| 677 | +typedef struct __sFILE FILE; | |
| 678 | +#ifndef _STDFILES_DECLARED | |
| 679 | + #define _STDFILES_DECLARED | |
| 680 | +struct __sFstub { long _stub; }; | |
| 681 | +extern struct __sFstub __stdin[]; | |
| 682 | +extern struct __sFstub __stdout[]; | |
| 683 | +extern struct __sFstub __stderr[]; | |
| 684 | +#endif | |
| 685 | +#define stdin ((struct __sFILE *)__stdin) | |
| 686 | +#define stdout ((struct __sFILE *)__stdout) | |
| 687 | +#define stderr ((struct __sFILE *)__stderr) | |
| 688 | + #elif defined(__BIONIC__) | |
| 689 | +struct __sFILE; | |
| 690 | +typedef struct __sFILE FILE; | |
| 691 | +extern FILE* stdin; | |
| 692 | +extern FILE* stdout; | |
| 693 | +extern FILE* stderr; | |
| 694 | + #elif defined(__linux__) && !defined(__GLIBC__) && !defined(__GNU_LIBRARY__) && !defined(__BIONIC__) && !defined(__UCLIBC__) | |
| 695 | +typedef struct _IO_FILE FILE; | |
| 696 | +// musl exposes the stdio streams as `FILE *const`, so match that to stay | |
| 697 | +// compatible with later <stdio.h> includes from headers like miniz.h. | |
| 698 | +extern FILE* const stdin; | |
| 699 | +extern FILE* const stdout; | |
| 700 | +extern FILE* const stderr; | |
| 701 | + #else | |
| 702 | +typedef struct _IO_FILE FILE; | |
| 703 | +extern FILE* stdin; | |
| 704 | +extern FILE* stdout; | |
| 705 | +extern FILE* stderr; | |
| 706 | + #endif | |
| 707 | +typedef __builtin_va_list va_list; | |
| 708 | +#ifndef va_start | |
| 709 | + #define va_start(ap, v) __builtin_va_start(ap, v) | |
| 710 | +#endif | |
| 711 | +#ifndef va_arg | |
| 712 | + #define va_arg(ap, t) __builtin_va_arg(ap, t) | |
| 713 | +#endif | |
| 714 | +#ifndef va_end | |
| 715 | + #define va_end(ap) __builtin_va_end(ap) | |
| 716 | +#endif | |
| 717 | +#ifndef va_copy | |
| 718 | + #define va_copy(dest, src) __builtin_va_copy(dest, src) | |
| 719 | +#endif | |
| 720 | +#endif | |
| 721 | +#if (!defined(_MSC_VER) || defined(__clang__)) && !defined(__cplusplus) && !defined(__NetBSD__) | |
| 722 | +// mingw-w64 stdio.h declares these as static __mingw_ovr inline overrides | |
| 723 | +// when __USE_MINGW_ANSI_STDIO is on. Skip them under gcc+mingw to avoid | |
| 724 | +// static-after-extern conflicts; clang+mingw needs them because it builds | |
| 725 | +// with -Werror=implicit-function-declaration and does not hit the conflict. | |
| 726 | +// NetBSD pulls these prototypes from <stdio.h>/<stdlib.h>/<string.h> via | |
| 727 | +// the include block above to avoid `__restrict` qualifier conflicts. | |
| 728 | +#if !((defined(__MINGW32__) || defined(__MINGW64__)) && !defined(__clang__)) | |
| 729 | +V_CRT_LINKAGE int V_CRT_CALL vfprintf(FILE *stream, const char *format, va_list ap); | |
| 730 | +V_CRT_LINKAGE int V_CRT_CALL vsnprintf(char *str, size_t size, const char *format, va_list ap); | |
| 731 | +V_CRT_LINKAGE int V_CRT_CALL fprintf(FILE *stream, const char *format, ...); | |
| 732 | +V_CRT_LINKAGE int V_CRT_CALL printf(const char *format, ...); | |
| 733 | +V_CRT_LINKAGE int V_CRT_CALL snprintf(char *str, size_t size, const char *format, ...); | |
| 734 | +V_CRT_LINKAGE int V_CRT_CALL sprintf(char *str, const char *format, ...); | |
| 735 | +V_CRT_LINKAGE int V_CRT_CALL sscanf(const char *str, const char *format, ...); | |
| 736 | +V_CRT_LINKAGE int V_CRT_CALL scanf(const char *format, ...); | |
| 737 | +#endif | |
| 738 | +V_CRT_LINKAGE int V_CRT_CALL puts(const char *str); | |
| 739 | +V_CRT_LINKAGE void V_CRT_CALL perror(const char *str); | |
| 740 | +V_CRT_LINKAGE int V_CRT_CALL fputs(const char *str, FILE *stream); | |
| 741 | +V_CRT_LINKAGE int V_CRT_CALL getchar(void); | |
| 742 | +V_CRT_LINKAGE int V_CRT_CALL putchar(int ch); | |
| 743 | +V_CRT_LINKAGE int V_CRT_CALL getc(FILE *stream); | |
| 744 | +V_CRT_LINKAGE int V_CRT_CALL fgetc(FILE *stream); | |
| 745 | +V_CRT_LINKAGE int V_CRT_CALL ungetc(int ch, FILE *stream); | |
| 746 | +V_CRT_LINKAGE int V_CRT_CALL fflush(FILE *stream); | |
| 747 | +V_CRT_LINKAGE int V_CRT_CALL feof(FILE *stream); | |
| 748 | +V_CRT_LINKAGE int V_CRT_CALL ferror(FILE *stream); | |
| 749 | +V_CRT_LINKAGE void V_CRT_CALL clearerr(FILE *stream); | |
| 750 | +V_CRT_LINKAGE int V_CRT_CALL setvbuf(FILE *stream, char *buf, int mode, size_t size); | |
| 751 | +V_CRT_LINKAGE long V_CRT_CALL ftell(FILE *stream); | |
| 752 | +V_CRT_LINKAGE void V_CRT_CALL rewind(FILE *stream); | |
| 753 | +V_CRT_LINKAGE FILE * V_CRT_CALL fopen(const char *filename, const char *mode); | |
| 754 | +V_CRT_LINKAGE FILE * V_CRT_CALL fdopen(int fd, const char *mode); | |
| 755 | +V_CRT_LINKAGE FILE * V_CRT_CALL freopen(const char *filename, const char *mode, FILE *stream); | |
| 756 | +V_CRT_LINKAGE int V_CRT_CALL fileno(FILE *stream); | |
| 757 | +V_CRT_LINKAGE size_t V_CRT_CALL fread(void *ptr, size_t size, size_t items, FILE *stream); | |
| 758 | +V_CRT_LINKAGE size_t V_CRT_CALL fwrite(const void *ptr, size_t size, size_t items, FILE *stream); | |
| 759 | +#if defined(__vinix__) | |
| 760 | +V_CRT_LINKAGE char * V_CRT_CALL fgets(char *str, size_t size, FILE *stream); | |
| 761 | +#else | |
| 762 | +V_CRT_LINKAGE char * V_CRT_CALL fgets(char *str, int size, FILE *stream); | |
| 763 | +#endif | |
| 764 | +V_CRT_LINKAGE int V_CRT_CALL fclose(FILE *stream); | |
| 765 | +#if defined(__vinix__) | |
| 766 | +V_CRT_LINKAGE FILE * V_CRT_CALL popen(char *command, char *mode); | |
| 767 | +#else | |
| 768 | +V_CRT_LINKAGE FILE * V_CRT_CALL popen(const char *command, const char *mode); | |
| 769 | +#endif | |
| 770 | +V_CRT_LINKAGE int V_CRT_CALL pclose(FILE *stream); | |
| 771 | +V_CRT_LINKAGE void * V_CRT_CALL malloc(size_t size); | |
| 772 | +V_CRT_LINKAGE void * V_CRT_CALL calloc(size_t nitems, size_t size); | |
| 773 | +V_CRT_LINKAGE void * V_CRT_CALL realloc(void *ptr, size_t size); | |
| 774 | +V_CRT_LINKAGE void * V_CRT_CALL aligned_alloc(size_t alignment, size_t size); | |
| 775 | +V_CRT_LINKAGE int V_CRT_CALL posix_memalign(void **memptr, size_t alignment, size_t size); | |
| 776 | +V_CRT_LINKAGE void V_CRT_CALL free(void *ptr); | |
| 777 | +V_CRT_LINKAGE int V_CRT_CALL rand(void); | |
| 778 | +V_CRT_LINKAGE void V_CRT_CALL srand(unsigned int seed); | |
| 779 | +V_CRT_LINKAGE int V_CRT_CALL atexit(void (*cb)(void)); | |
| 780 | +V_CRT_LINKAGE void V_CRT_CALL exit(int status); | |
| 781 | +V_CRT_LINKAGE int V_CRT_CALL abs(int n); | |
| 782 | +V_CRT_LINKAGE int V_CRT_CALL atoi(const char *str); | |
| 783 | +V_CRT_LINKAGE double V_CRT_CALL atof(const char *str); | |
| 784 | +V_CRT_LINKAGE char * V_CRT_CALL getenv(const char *name); | |
| 785 | +V_CRT_LINKAGE int V_CRT_CALL setenv(const char *name, const char *value, int overwrite); | |
| 786 | +V_CRT_LINKAGE int V_CRT_CALL unsetenv(const char *name); | |
| 787 | +V_CRT_LINKAGE int V_CRT_CALL system(const char *command); | |
| 788 | +V_CRT_LINKAGE int V_CRT_CALL remove(const char *path); | |
| 789 | +V_CRT_LINKAGE int V_CRT_CALL rename(const char *old_path, const char *new_path); | |
| 790 | +V_CRT_LINKAGE char * V_CRT_CALL realpath(const char *path, char *resolved_path); | |
| 791 | +V_CRT_LINKAGE int V_CRT_CALL mkstemp(char *stemplate); | |
| 792 | +V_CRT_LINKAGE void V_CRT_CALL qsort(void *base, size_t items, size_t item_size, qsort_callback_func cb); | |
| 793 | +#if defined(__vinix__) | |
| 794 | +V_CRT_LINKAGE int V_CRT_CALL strcmp(char *left, char *right); | |
| 795 | +V_CRT_LINKAGE int V_CRT_CALL strncmp(char *left, char *right, size_t n); | |
| 796 | +#else | |
| 797 | +V_CRT_LINKAGE int V_CRT_CALL strcmp(const char *left, const char *right); | |
| 798 | +V_CRT_LINKAGE int V_CRT_CALL strncmp(const char *left, const char *right, size_t n); | |
| 799 | +#endif | |
| 800 | +#if !defined(_WIN32) && !defined(_WIN64) && !defined(__BIONIC__) | |
| 801 | +V_CRT_LINKAGE char * V_CRT_CALL strdup(const char *str); | |
| 802 | +#endif | |
| 803 | +#if !defined(_WIN32) && !defined(_WIN64) | |
| 804 | +V_CRT_LINKAGE int V_CRT_CALL strcasecmp(const char *left, const char *right); | |
| 805 | +V_CRT_LINKAGE int V_CRT_CALL strncasecmp(const char *left, const char *right, size_t n); | |
| 806 | +#endif | |
| 807 | +#if defined(__vinix__) | |
| 808 | +V_CRT_LINKAGE size_t V_CRT_CALL strlen(char *str); | |
| 809 | +#else | |
| 810 | +V_CRT_LINKAGE size_t V_CRT_CALL strlen(const char *str); | |
| 811 | +#endif | |
| 812 | +V_CRT_LINKAGE char * V_CRT_CALL strerror(int errnum); | |
| 813 | +V_CRT_LINKAGE void * V_CRT_CALL memcpy(void *dest, const void *src, size_t n); | |
| 814 | +V_CRT_LINKAGE void * V_CRT_CALL memmove(void *dest, const void *src, size_t n); | |
| 815 | +V_CRT_LINKAGE void * V_CRT_CALL memset(void *dest, int ch, size_t n); | |
| 816 | +V_CRT_LINKAGE int V_CRT_CALL memcmp(const void *left, const void *right, size_t n); | |
| 817 | +V_CRT_LINKAGE void * V_CRT_CALL memchr(const void *str, int c, size_t n); | |
| 818 | +V_CRT_LINKAGE char * V_CRT_CALL strchr(const char *str, int c); | |
| 819 | +V_CRT_LINKAGE char * V_CRT_CALL strrchr(const char *str, int c); | |
| 820 | +V_CRT_LINKAGE char * V_CRT_CALL strstr(const char *haystack, const char *needle); | |
| 821 | +V_CRT_LINKAGE int V_CRT_CALL fseek(FILE *stream, long offset, int whence); | |
| 822 | +V_CRT_LINKAGE isize V_CRT_CALL getline(char **lineptr, size_t *n, FILE *stream); | |
| 823 | +#if defined(_WIN32) || defined(_WIN64) | |
| 824 | +V_CRT_LINKAGE int V_CRT_CALL _fileno(FILE *stream); | |
| 825 | +V_CRT_LINKAGE FILE * V_CRT_CALL _wfopen(const unsigned short *filename, const unsigned short *mode); | |
| 826 | +V_CRT_LINKAGE int V_CRT_CALL _wremove(const unsigned short *path); | |
| 827 | +V_CRT_LINKAGE void * V_CRT_CALL _aligned_malloc(size_t size, size_t alignment); | |
| 828 | +V_CRT_LINKAGE void * V_CRT_CALL _aligned_realloc(void *memory, size_t size, size_t alignment); | |
| 829 | +V_CRT_LINKAGE void V_CRT_CALL _aligned_free(void *memory); | |
| 830 | +V_CRT_LINKAGE unsigned short * V_CRT_CALL _wgetenv(const unsigned short *varname); | |
| 831 | +V_CRT_LINKAGE int V_CRT_CALL _wputenv(const unsigned short *envstring); | |
| 832 | +#endif | |
| 833 | +#if defined(_MSC_VER) && !defined(__clang__) | |
| 834 | +#ifndef _TRUNCATE | |
| 835 | + #define _TRUNCATE ((size_t)-1) | |
| 836 | +#endif | |
| 837 | +V_CRT_LINKAGE int V_CRT_CALL _vscprintf(const char *format, va_list ap); | |
| 838 | +V_CRT_LINKAGE int V_CRT_CALL _vsnprintf_s(char *buffer, size_t size, size_t count, const char *format, va_list ap); | |
| 839 | +#endif | |
| 840 | +#endif | |
| 841 | +#ifndef _IOFBF | |
| 842 | + #define _IOFBF 0 | |
| 843 | +#endif | |
| 844 | +#ifndef _IOLBF | |
| 845 | + #define _IOLBF 1 | |
| 846 | +#endif | |
| 847 | +#ifndef _IONBF | |
| 848 | + #define _IONBF 2 | |
| 849 | +#endif | |
| 850 | +#ifndef EOF | |
| 851 | + #define EOF (-1) | |
| 852 | +#endif | |
| 853 | +#ifndef SEEK_SET | |
| 854 | + #define SEEK_SET 0 | |
| 855 | +#endif | |
| 856 | +#ifndef SEEK_CUR | |
| 857 | + #define SEEK_CUR 1 | |
| 858 | +#endif | |
| 859 | +#ifndef SEEK_END | |
| 860 | + #define SEEK_END 2 | |
| 861 | +#endif | |
| 862 | +#ifndef RAND_MAX | |
| 863 | +enum { | |
| 864 | + #if defined(_MSC_VER) | |
| 865 | + RAND_MAX = 0x7fff | |
| 866 | + #else | |
| 867 | + RAND_MAX = 2147483647 | |
| 868 | + #endif | |
| 869 | +}; | |
| 870 | +#endif | |
| 871 | +#undef V_CRT_LINKAGE | |
| 872 | +#undef V_CRT_CALL | |
| 873 | +static void v_stable_sort(void *base, size_t items, size_t item_size, qsort_callback_func cb) { | |
| 874 | + if (items < 2 || item_size == 0) { | |
| 875 | + return; | |
| 876 | + } | |
| 877 | + if (items > ((size_t)-1) / item_size) { | |
| 878 | + qsort(base, items, item_size, cb); | |
| 879 | + return; | |
| 880 | + } | |
| 881 | + const size_t bytes = items * item_size; | |
| 882 | + char *base_bytes = (char*)base; | |
| 883 | + char *tmp = (char*)malloc(bytes); | |
| 884 | + if (tmp == 0) { | |
| 885 | + qsort(base, items, item_size, cb); | |
| 886 | + return; | |
| 887 | + } | |
| 888 | + char *src = base_bytes; | |
| 889 | + char *dst = tmp; | |
| 890 | + for (size_t width = 1; width < items;) { | |
| 891 | + for (size_t left = 0; left < items;) { | |
| 892 | + size_t mid = left; | |
| 893 | + mid += width; | |
| 894 | + if (mid > items) { | |
| 895 | + mid = items; | |
| 896 | + } | |
| 897 | + size_t right = mid; | |
| 898 | + right += width; | |
| 899 | + if (right > items || right < mid) { | |
| 900 | + right = items; | |
| 901 | + } | |
| 902 | + size_t i = left; | |
| 903 | + size_t j = mid; | |
| 904 | + size_t k = left; | |
| 905 | + while (i < mid && j < right) { | |
| 906 | + char *leftp = src; | |
| 907 | + leftp += i * item_size; | |
| 908 | + char *rightp = src; | |
| 909 | + rightp += j * item_size; | |
| 910 | + char *dstp = dst; | |
| 911 | + dstp += k * item_size; | |
| 912 | + if (cb(leftp, rightp) <= 0) { | |
| 913 | + memcpy(dstp, leftp, item_size); | |
| 914 | + i++; | |
| 915 | + } else { | |
| 916 | + memcpy(dstp, rightp, item_size); | |
| 917 | + j++; | |
| 918 | + } | |
| 919 | + k++; | |
| 920 | + } | |
| 921 | + while (i < mid) { | |
| 922 | + char *dstp = dst; | |
| 923 | + dstp += k * item_size; | |
| 924 | + char *srcp = src; | |
| 925 | + srcp += i * item_size; | |
| 926 | + memcpy(dstp, srcp, item_size); | |
| 927 | + i++; | |
| 928 | + k++; | |
| 929 | + } | |
| 930 | + while (j < right) { | |
| 931 | + char *dstp = dst; | |
| 932 | + dstp += k * item_size; | |
| 933 | + char *srcp = src; | |
| 934 | + srcp += j * item_size; | |
| 935 | + memcpy(dstp, srcp, item_size); | |
| 936 | + j++; | |
| 937 | + k++; | |
| 938 | + } | |
| 939 | + left = right; | |
| 940 | + } | |
| 941 | + char *next_src = dst; | |
| 942 | + dst = src; | |
| 943 | + src = next_src; | |
| 944 | + if (width > items / 2) { | |
| 945 | + width = items; | |
| 946 | + } else { | |
| 947 | + width *= 2; | |
| 948 | + } | |
| 949 | + } | |
| 950 | + if (src != base_bytes) { | |
| 951 | + memcpy(base_bytes, src, bytes); | |
| 952 | + } | |
| 953 | + free(tmp); | |
| 954 | +} | |
| 955 | +#if defined(__TINYC__) | |
| 956 | +// https://lists.nongnu.org/archive/html/tinycc-devel/2025-10/msg00007.html | |
| 957 | +// gnu headers use to #define __attribute__ to empty for non-gcc compilers | |
| 958 | +#undef __attribute__ | |
| 959 | +#endif | |
| 960 | +#if defined(_MSC_VER) && !defined(__clang__) | |
| 961 | +// Ensure C99-like return semantics and NUL-termination for MSVC snprintf/vsnprintf. | |
| 962 | +static int v__vsnprintf(char *s, size_t n, const char *fmt, va_list ap) { | |
| 963 | + va_list ap_copy; | |
| 964 | + va_copy(ap_copy, ap); | |
| 965 | + const int needed = _vscprintf(fmt, ap_copy); | |
| 966 | + va_end(ap_copy); | |
| 967 | + if (n > 0) { | |
| 968 | + const int written = _vsnprintf_s(s, n, _TRUNCATE, fmt, ap); | |
| 969 | + if (written < 0) { | |
| 970 | + s[n - | |
| 971 | + 1] = 0; | |
| 972 | + } | |
| 973 | + } | |
| 974 | + return needed; | |
| 975 | +} | |
| 976 | +static int v__snprintf(char *s, size_t n, const char *fmt, ...) { | |
| 977 | + va_list ap; | |
| 978 | + va_start(ap, fmt); | |
| 979 | + const int needed = v__vsnprintf(s, n, fmt, ap); | |
| 980 | + va_end(ap); | |
| 981 | + return needed; | |
| 982 | +} | |
| 983 | +#define vsnprintf v__vsnprintf | |
| 984 | +#define snprintf v__snprintf | |
| 985 | +#endif | |
| 986 | +//================================== GLOBALS =================================*/ | |
| 987 | +#ifdef _VOBJECTFILE | |
| 988 | +static void _vinit(int ___argc, voidptr ___argv); | |
| 989 | +static void _vcleanup(void); | |
| 990 | +#else | |
| 991 | +void _vinit(int ___argc, voidptr ___argv); | |
| 992 | +void _vcleanup(void); | |
| 993 | +#endif | |
| 994 | +#ifdef _WIN32 | |
| 995 | + // Export helpers so the autogenerated DllMain, or a user-defined one, | |
| 996 | + // can reuse the default V shared-library init/cleanup path. | |
| 997 | + #ifdef _VOBJECTFILE | |
| 998 | + static void _vinit_caller(); | |
| 999 | + static void _vcleanup_caller(); | |
| 1000 | + #else | |
| 1001 | + VV_EXP void _vinit_caller(); | |
| 1002 | + VV_EXP void _vcleanup_caller(); | |
| 1003 | + #endif | |
| 1004 | +#endif | |
| 1005 | +#if !defined(_WIN32) | |
| 1006 | +#define sigaction_size sizeof(sigaction); | |
| 1007 | +#endif | |
| 1008 | +#define _ARR_LEN(a) ( (sizeof(a)) / (sizeof(a[0])) ) | |
| 1009 | +#if INTPTR_MAX == INT32_MAX | |
| 1010 | + #define TARGET_IS_32BIT 1 | |
| 1011 | +#elif INTPTR_MAX == INT64_MAX | |
| 1012 | + #define TARGET_IS_64BIT 1 | |
| 1013 | +#else | |
| 1014 | + #error "The environment is not 32 or 64-bit." | |
| 1015 | +#endif | |
| 1016 | +#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ || defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN || defined(__BIG_ENDIAN__) || defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || defined(_MIBSEB) || defined(__MIBSEB) || defined(__MIBSEB__) | |
| 1017 | + #define TARGET_ORDER_IS_BIG 1 | |
| 1018 | +#elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ || defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN || defined(__LITTLE_ENDIAN__) || defined(__ARMEL__) || defined(__THUMBEL__) || defined(__AARCH64EL__) || defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__) || defined(_M_AMD64) || defined(_M_ARM64) || defined(_M_X64) || defined(_M_IX86) | |
| 1019 | + #define TARGET_ORDER_IS_LITTLE 1 | |
| 1020 | +#else | |
| 1021 | + #error "Unknown architecture endianness" | |
| 1022 | +#endif | |
| 1023 | +#if !defined(_WIN32) && !defined(__vinix__) | |
| 1024 | + #include <ctype.h> | |
| 1025 | + #include <locale.h> // tolower | |
| 1026 | + #include <sys/time.h> | |
| 1027 | + #include <unistd.h> // sleep | |
| 1028 | + extern char **environ; | |
| 1029 | + #include <pthread.h> | |
| 1030 | + #ifndef PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP | |
| 1031 | + // musl does not have that | |
| 1032 | + #define pthread_rwlockattr_setkind_np(a, b) | |
| 1033 | + #endif | |
| 1034 | +#endif | |
| 1035 | +#if (defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__serenity__) || defined(__sun) || defined(__plan9__) || defined(__OpenBSD__)) && !defined(__vinix__) | |
| 1036 | + #include <sys/types.h> | |
| 1037 | + #include <sys/wait.h> // for os__wait | |
| 1038 | +#endif | |
| 1039 | +#ifdef __OpenBSD__ | |
| 1040 | + #include <sys/resource.h> | |
| 1041 | +#endif | |
| 1042 | +#ifdef __FreeBSD__ | |
| 1043 | + #include <signal.h> | |
| 1044 | + #include <execinfo.h> | |
| 1045 | +#endif | |
| 1046 | +#ifdef __NetBSD__ | |
| 1047 | + #include <sys/wait.h> // for os__wait | |
| 1048 | +#endif | |
| 1049 | +#ifdef __TERMUX__ | |
| 1050 | +#if !defined(__BIONIC_AVAILABILITY_GUARD) | |
| 1051 | + #define __BIONIC_AVAILABILITY_GUARD(api_level) 0 | |
| 1052 | +#endif | |
| 1053 | +#if __BIONIC_AVAILABILITY_GUARD(28) | |
| 1054 | +#else | |
| 1055 | +void * aligned_alloc(size_t alignment, size_t size) { return malloc(size); } | |
| 1056 | +#endif | |
| 1057 | +#endif | |
| 1058 | +#ifdef __APPLE__ | |
| 1059 | + // macOS only exports aligned_alloc starting with 10.15. | |
| 1060 | + #if !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500 | |
| 1061 | +static void *v__aligned_alloc_fallback(size_t alignment, size_t size) { | |
| 1062 | + void *res = 0; | |
| 1063 | + if (alignment < sizeof(void *)) { | |
| 1064 | + alignment = sizeof(void *); | |
| 1065 | + } | |
| 1066 | + if (posix_memalign(&res, alignment, size) != 0) { | |
| 1067 | + return 0; | |
| 1068 | + } | |
| 1069 | + return res; | |
| 1070 | +} | |
| 1071 | + #define aligned_alloc v__aligned_alloc_fallback | |
| 1072 | + #endif | |
| 1073 | +#endif | |
| 1074 | +#ifdef _WIN32 | |
| 1075 | + #ifdef WINVER | |
| 1076 | + #undef WINVER | |
| 1077 | + #endif | |
| 1078 | + #define WINVER 0x0600 | |
| 1079 | + #ifdef _WIN32_WINNT | |
| 1080 | + #undef _WIN32_WINNT | |
| 1081 | + #endif | |
| 1082 | + #define _WIN32_WINNT 0x0600 | |
| 1083 | + #ifndef WIN32_FULL | |
| 1084 | + #define WIN32_LEAN_AND_MEAN | |
| 1085 | + #endif | |
| 1086 | + #ifndef _UNICODE | |
| 1087 | + #define _UNICODE | |
| 1088 | + #endif | |
| 1089 | + #ifndef UNICODE | |
| 1090 | + #define UNICODE | |
| 1091 | + #endif | |
| 1092 | + #include <windows.h> | |
| 1093 | + #include <io.h> // _waccess | |
| 1094 | + #include <direct.h> // _wgetcwd | |
| 1095 | + #ifdef V_USE_SIGNAL_H | |
| 1096 | + #include <signal.h> // signal and SIGSEGV for segmentation fault handler | |
| 1097 | + #endif | |
| 1098 | + #ifdef _MSC_VER | |
| 1099 | + // On MSVC these are the same (as long as /volatile:ms is passed) | |
| 1100 | + #define _Atomic volatile | |
| 1101 | + // MSVC cannot parse some things properly | |
| 1102 | + #undef __NOINLINE | |
| 1103 | + #undef __IRQHANDLER | |
| 1104 | + #define __NOINLINE __declspec(noinline) | |
| 1105 | + #define __IRQHANDLER __declspec(naked) | |
| 1106 | + #include <dbghelp.h> | |
| 1107 | + #pragma comment(lib, "Dbghelp") | |
| 1108 | + #endif | |
| 1109 | +#endif | |
| 1110 | +#if defined(__CYGWIN__) && !defined(_WIN32) | |
| 1111 | + #error Cygwin is not supported, please use MinGW or Visual Studio. | |
| 1112 | +#endif | |
| 1113 | +#if defined(__MINGW32__) || defined(__MINGW64__) || (defined(_WIN32) && defined(__TINYC__)) || defined(_MSC_VER) | |
| 1114 | + #undef PRId64 | |
| 1115 | + #undef PRIi64 | |
| 1116 | + #undef PRIo64 | |
| 1117 | + #undef PRIu64 | |
| 1118 | + #undef PRIx64 | |
| 1119 | + #undef PRIX64 | |
| 1120 | + #define PRId64 "lld" | |
| 1121 | + #define PRIi64 "lli" | |
| 1122 | + #define PRIo64 "llo" | |
| 1123 | + #define PRIu64 "llu" | |
| 1124 | + #define PRIx64 "llx" | |
| 1125 | + #define PRIX64 "llX" | |
| 1126 | +#endif | |
| 1127 | +#ifdef _VFREESTANDING | |
| 1128 | +#undef _VFREESTANDING | |
| 1129 | +#endif | |
| 1130 | + | |
| 1131 | + | |
| 1132 | +// deterministic float -> u64 conversions for explicit V casts | |
| 1133 | +// direct C casts are undefined for out-of-range values | |
| 1134 | +static inline uint64_t _v_f64_to_u64(double x) { | |
| 1135 | + if (!(x >= 0.0)) { | |
| 1136 | + return 0; | |
| 1137 | + } | |
| 1138 | + if (x >= 18446744073709551616.0) { | |
| 1139 | + return UINT64_MAX; | |
| 1140 | + } | |
| 1141 | + return (uint64_t)x; | |
| 1142 | +} | |
| 1143 | + | |
| 1144 | + | |
| 1145 | +// unsigned/signed comparisons | |
| 1146 | +static inline bool _us32_gt(uint32_t a, int32_t b) { return a > INT32_MAX || (int32_t)a > b; } | |
| 1147 | +static inline bool _us32_ge(uint32_t a, int32_t b) { return a >= INT32_MAX || (int32_t)a >= b; } | |
| 1148 | +static inline bool _us32_eq(uint32_t a, int32_t b) { return a <= INT32_MAX && (int32_t)a == b; } | |
| 1149 | +static inline bool _us32_ne(uint32_t a, int32_t b) { return a > INT32_MAX || (int32_t)a != b; } | |
| 1150 | +static inline bool _us32_le(uint32_t a, int32_t b) { return a <= INT32_MAX && (int32_t)a <= b; } | |
| 1151 | +static inline bool _us32_lt(uint32_t a, int32_t b) { return a < INT32_MAX && (int32_t)a < b; } | |
| 1152 | +static inline bool _us64_gt(uint64_t a, int64_t b) { return a > INT64_MAX || (int64_t)a > b; } | |
| 1153 | +static inline bool _us64_ge(uint64_t a, int64_t b) { return a >= INT64_MAX || (int64_t)a >= b; } | |
| 1154 | +static inline bool _us64_eq(uint64_t a, int64_t b) { return a <= INT64_MAX && (int64_t)a == b; } | |
| 1155 | +static inline bool _us64_ne(uint64_t a, int64_t b) { return a > INT64_MAX || (int64_t)a != b; } | |
| 1156 | +static inline bool _us64_le(uint64_t a, int64_t b) { return a <= INT64_MAX && (int64_t)a <= b; } | |
| 1157 | +static inline bool _us64_lt(uint64_t a, int64_t b) { return a < INT64_MAX && (int64_t)a < b; } | |
| 1158 | + | |
| 1159 | + | |
| 1160 | +#if !defined(VNORETURN) | |
| 1161 | + #if defined(__TINYC__) | |
| 1162 | + #define VNORETURN __attribute__((noreturn)) | |
| 1163 | + # elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L | |
| 1164 | + # define VNORETURN _Noreturn | |
| 1165 | + # elif !defined(VNORETURN) && defined(__GNUC__) && __GNUC__ >= 2 | |
| 1166 | + # define VNORETURN __attribute__((noreturn)) | |
| 1167 | + # endif | |
| 1168 | + #ifndef VNORETURN | |
| 1169 | + #define VNORETURN | |
| 1170 | + #endif | |
| 1171 | +#endif | |
| 1172 | + | |
| 1173 | + | |
| 1174 | +#if !defined(VUNREACHABLE) | |
| 1175 | + #if defined(__GNUC__) && !defined(__clang__) | |
| 1176 | + #define V_GCC_VERSION (__GNUC__ * 10000L + __GNUC_MINOR__ * 100L + __GNUC_PATCHLEVEL__) | |
| 1177 | + #if (V_GCC_VERSION >= 40500L) && !defined(__TINYC__) | |
| 1178 | + #define VUNREACHABLE() do { __builtin_unreachable(); } while (0) | |
| 1179 | + #endif | |
| 1180 | + #endif | |
| 1181 | + #if defined(__clang__) && defined(__has_builtin) && !defined(__TINYC__) | |
| 1182 | + #if __has_builtin(__builtin_unreachable) | |
| 1183 | + #define VUNREACHABLE() do { __builtin_unreachable(); } while (0) | |
| 1184 | + #endif | |
| 1185 | + #endif | |
| 1186 | + #ifndef VUNREACHABLE | |
| 1187 | + #define VUNREACHABLE() do { } while (0) | |
| 1188 | + #endif | |
| 1189 | +#endif | |
| 1190 | + | |
| 1191 | + | |
| 1192 | +#ifndef wyhash_final_version_4_2 | |
| 1193 | +#define wyhash_final_version_4_2 | |
| 1194 | +#ifndef WYHASH_CONDOM | |
| 1195 | +// protections that produce different results: | |
| 1196 | +// 1: normal valid behavior | |
| 1197 | +// 2: extra protection against entropy loss (probability=2^-63), aka. "blind multiplication" | |
| 1198 | +#define WYHASH_CONDOM 1 | |
| 1199 | +#endif | |
| 1200 | +#ifndef WYHASH_32BIT_MUM | |
| 1201 | +// 0: normal version, slow on 32 bit systems | |
| 1202 | +// 1: faster on 32 bit systems but produces different results, incompatible with wy2u0k function | |
| 1203 | +#define WYHASH_32BIT_MUM 0 | |
| 1204 | +#endif | |
| 1205 | +// includes | |
| 1206 | +#include <stdint.h> | |
| 1207 | +#if defined(_MSC_VER) && defined(_M_X64) | |
| 1208 | + #include <intrin.h> | |
| 1209 | + #pragma intrinsic(_umul128) | |
| 1210 | +#endif | |
| 1211 | +// 128bit multiply function | |
| 1212 | +static inline uint64_t _wyrot(uint64_t x) { return (x>>32)|(x<<32); } | |
| 1213 | +static inline void _wymum(uint64_t *A, uint64_t *B){ | |
| 1214 | +#if(WYHASH_32BIT_MUM) | |
| 1215 | + uint64_t hh=(*A>>32)*(*B>>32), hl=(*A>>32)*(uint32_t)*B, lh=(uint32_t)*A*(*B>>32), ll=(uint64_t)(uint32_t)*A*(uint32_t)*B; | |
| 1216 | + #if(WYHASH_CONDOM>1) | |
| 1217 | + *A^=_wyrot(hl)^hh; *B^=_wyrot(lh)^ll; | |
| 1218 | + #else | |
| 1219 | + *A=_wyrot(hl)^hh; *B=_wyrot(lh)^ll; | |
| 1220 | + #endif | |
| 1221 | +#elif defined(__SIZEOF_INT128__) && !defined(VWASM) | |
| 1222 | + __uint128_t r=*A; r*=*B; | |
| 1223 | + #if(WYHASH_CONDOM>1) | |
| 1224 | + *A^=(uint64_t)r; *B^=(uint64_t)(r>>64); | |
| 1225 | + #else | |
| 1226 | + *A=(uint64_t)r; *B=(uint64_t)(r>>64); | |
| 1227 | + #endif | |
| 1228 | +#elif defined(_MSC_VER) && defined(_M_X64) | |
| 1229 | + #if(WYHASH_CONDOM>1) | |
| 1230 | + uint64_t a, b; | |
| 1231 | + a=_umul128(*A,*B,&b); | |
| 1232 | + *A^=a; *B^=b; | |
| 1233 | + #else | |
| 1234 | + *A=_umul128(*A,*B,B); | |
| 1235 | + #endif | |
| 1236 | +#else | |
| 1237 | + uint64_t ha=*A>>32, hb=*B>>32, la=(uint32_t)*A, lb=(uint32_t)*B, hi, lo; | |
| 1238 | + uint64_t rh=ha*hb, rm0=ha*lb, rm1=hb*la, rl=la*lb, t=rl+(rm0<<32), c=t<rl; | |
| 1239 | + lo=t+(rm1<<32); c+=lo<t; hi=rh+(rm0>>32)+(rm1>>32)+c; | |
| 1240 | + #if(WYHASH_CONDOM>1) | |
| 1241 | + *A^=lo; *B^=hi; | |
| 1242 | + #else | |
| 1243 | + *A=lo; *B=hi; | |
| 1244 | + #endif | |
| 1245 | +#endif | |
| 1246 | +} | |
| 1247 | +// multiply and xor mix function, aka MUM | |
| 1248 | +static inline uint64_t _wymix(uint64_t A, uint64_t B){ _wymum(&A,&B); return A^B; } | |
| 1249 | +// endian macros | |
| 1250 | +#ifndef WYHASH_LITTLE_ENDIAN | |
| 1251 | + #ifdef TARGET_ORDER_IS_LITTLE | |
| 1252 | + #define WYHASH_LITTLE_ENDIAN 1 | |
| 1253 | + #else | |
| 1254 | + #define WYHASH_LITTLE_ENDIAN 0 | |
| 1255 | + #endif | |
| 1256 | +#endif | |
| 1257 | +// read functions | |
| 1258 | +#if (WYHASH_LITTLE_ENDIAN) | |
| 1259 | + static inline uint64_t _wyr8(const uint8_t *p) { uint64_t v; memcpy(&v, p, 8); return v;} | |
| 1260 | + static inline uint64_t _wyr4(const uint8_t *p) { uint32_t v; memcpy(&v, p, 4); return v;} | |
| 1261 | +#elif !defined(__TINYC__) && (defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__clang__)) | |
| 1262 | + static inline uint64_t _wyr8(const uint8_t *p) { uint64_t v; memcpy(&v, p, 8); return __builtin_bswap64(v);} | |
| 1263 | + static inline uint64_t _wyr4(const uint8_t *p) { uint32_t v; memcpy(&v, p, 4); return __builtin_bswap32(v);} | |
| 1264 | +#elif defined(_MSC_VER) | |
| 1265 | + static inline uint64_t _wyr8(const uint8_t *p) { uint64_t v; memcpy(&v, p, 8); return _byteswap_uint64(v);} | |
| 1266 | + static inline uint64_t _wyr4(const uint8_t *p) { uint32_t v; memcpy(&v, p, 4); return _byteswap_ulong(v);} | |
| 1267 | +#else | |
| 1268 | + static inline uint64_t _wyr8(const uint8_t *p) { | |
| 1269 | + uint64_t v; memcpy(&v, p, 8); | |
| 1270 | + return (((v >> 56) & 0xff)| ((v >> 40) & 0xff00)| ((v >> 24) & 0xff0000)| ((v >> 8) & 0xff000000)| ((v << 8) & 0xff00000000)| ((v << 24) & 0xff0000000000)| ((v << 40) & 0xff000000000000)| ((v << 56) & 0xff00000000000000)); | |
| 1271 | + } | |
| 1272 | + static inline uint64_t _wyr4(const uint8_t *p) { | |
| 1273 | + uint32_t v; memcpy(&v, p, 4); | |
| 1274 | + return (((v >> 24) & 0xff)| ((v >> 8) & 0xff00)| ((v << 8) & 0xff0000)| ((v << 24) & 0xff000000)); | |
| 1275 | + } | |
| 1276 | +#endif | |
| 1277 | +static inline uint64_t _wyr3(const uint8_t *p, size_t k) { return (((uint64_t)p[0])<<16)|(((uint64_t)p[k>>1])<<8)|p[k-1];} | |
| 1278 | +// wyhash main function | |
| 1279 | +static inline uint64_t wyhash(const void *key, size_t len, uint64_t seed, const uint64_t *secret){ | |
| 1280 | + const uint8_t *p=(const uint8_t *)key; seed^=_wymix(seed^secret[0]^len,secret[1]); uint64_t a, b; | |
| 1281 | + if (_likely_(len<=16)) { | |
| 1282 | + if (_likely_(len>=4)) { a=(_wyr4(p)<<32)|_wyr4(p+((len>>3)<<2)); b=(_wyr4(p+len-4)<<32)|_wyr4(p+len-4-((len>>3)<<2)); } | |
| 1283 | + else if (_likely_(len>0)) { a=_wyr3(p,len); b=0; } | |
| 1284 | + else a=b=0; | |
| 1285 | + } else { | |
| 1286 | + size_t i=len; | |
| 1287 | + if (_unlikely_(i>=48)) { | |
| 1288 | + uint64_t see1=seed, see2=seed; | |
| 1289 | + do { | |
| 1290 | + seed=_wymix(_wyr8(p)^secret[1],_wyr8(p+8)^seed); | |
| 1291 | + see1=_wymix(_wyr8(p+16)^secret[2],_wyr8(p+24)^see1); | |
| 1292 | + see2=_wymix(_wyr8(p+32)^secret[3],_wyr8(p+40)^see2); | |
| 1293 | + p+=48; i-=48; | |
| 1294 | + } while(_likely_(i>=48)); | |
| 1295 | + seed^=see1^see2; | |
| 1296 | + } | |
| 1297 | + while(_unlikely_(i>16)) { seed=_wymix(_wyr8(p)^secret[1],_wyr8(p+8)^seed); i-=16; p+=16; } | |
| 1298 | + a=_wyr8(p+i-16); b=_wyr8(p+i-8); | |
| 1299 | + } | |
| 1300 | + a^=secret[1]; b^=seed; _wymum(&a,&b); | |
| 1301 | + return _wymix(a^secret[0]^len,b^secret[1]); | |
| 1302 | +} | |
| 1303 | +// the default secret parameters | |
| 1304 | +static const uint64_t _wyp[4] = {0x2d358dccaa6c78a5ull, 0x8bb84b93962eacc9ull, 0x4b33a62ed433d4a3ull, 0x4d5a2da51de1aa47ull}; | |
| 1305 | +// a useful 64bit-64bit mix function to produce deterministic pseudo random numbers that can pass BigCrush and PractRand | |
| 1306 | +static inline uint64_t wyhash64(uint64_t A, uint64_t B){ A^=0x2d358dccaa6c78a5ull; B^=0x8bb84b93962eacc9ull; _wymum(&A,&B); return _wymix(A^0x2d358dccaa6c78a5ull,B^0x8bb84b93962eacc9ull);} | |
| 1307 | +// the wyrand PRNG that pass BigCrush and PractRand | |
| 1308 | +static inline uint64_t wyrand(uint64_t *seed){ *seed+=0x2d358dccaa6c78a5ull; return _wymix(*seed,*seed^0x8bb84b93962eacc9ull);} | |
| 1309 | +#ifndef __vinix__ | |
| 1310 | +// convert any 64 bit pseudo random numbers to uniform distribution [0,1). It can be combined with wyrand, wyhash64 or wyhash. | |
| 1311 | +static inline double wy2u01(uint64_t r){ const double _wynorm=1.0/(1ull<<52); return (r>>12)*_wynorm;} | |
| 1312 | +// convert any 64 bit pseudo random numbers to APPROXIMATE Gaussian distribution. It can be combined with wyrand, wyhash64 or wyhash. | |
| 1313 | +static inline double wy2gau(uint64_t r){ const double _wynorm=1.0/(1ull<<20); return ((r&0x1fffff)+((r>>21)&0x1fffff)+((r>>42)&0x1fffff))*_wynorm-3.0;} | |
| 1314 | +#endif | |
| 1315 | +#if(!WYHASH_32BIT_MUM) | |
| 1316 | +// fast range integer random number generation on [0,k) credit to Daniel Lemire. May not work when WYHASH_32BIT_MUM=1. It can be combined with wyrand, wyhash64 or wyhash. | |
| 1317 | +static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; } | |
| 1318 | +#endif | |
| 1319 | +#endif | |
| 1320 | +#define _IN_MAP(val, m) builtin__map_exists(m, val) | |
| 1321 | + | |
| 1322 | +#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 30 | |
| 1323 | +#include <sys/syscall.h> | |
| 1324 | +#define gettid() syscall(SYS_gettid) | |
| 1325 | +#endif | |
| 1326 | + | |
| 1327 | +// V includes: | |
| 1328 | + | |
| 1329 | +#if defined(__TINYC__) && defined(__has_include) // tcc does not support has_include properly yet, turn it off completely | |
| 1330 | +#undef __has_include | |
| 1331 | +#endif | |
| 1332 | + | |
| 1333 | +#if defined(__TINYC__) && defined(__BIONIC__) | |
| 1334 | + #define __builtin_nanf(ignored_string) (0.0F / 0.0F) | |
| 1335 | + #define __builtin_nan(ignored_string) (0.0 / 0.0) | |
| 1336 | + #define __builtin_nanl(ignored_string) (0.0L / 0.0L) | |
| 1337 | + #define __builtin_inff() (1.0F / 0.0F) | |
| 1338 | + #define __builtin_inf() (1.0 / 0.0) | |
| 1339 | + #define __builtin_infl() (1.0L / 0.0L) | |
| 1340 | + #define __builtin_huge_valf() (1.0F / 0.0F) | |
| 1341 | + #define __builtin_huge_val() (1.0 / 0.0) | |
| 1342 | + #define __builtin_huge_vall() (1.0L / 0.0L) | |
| 1343 | +#endif | |
| 1344 | + | |
| 1345 | +#if 1 | |
| 1346 | + | |
| 1347 | +// added by module `builtin.closure`, file: closure_nix.c.v:4: | |
| 1348 | + | |
| 1349 | +#ifdef __TINYC__ | |
| 1350 | +#include <sys/mman.h> | |
| 1351 | +#else | |
| 1352 | +#if defined(__has_include) | |
| 1353 | +#if __has_include(<sys/mman.h>) | |
| 1354 | +#include <sys/mman.h> | |
| 1355 | +#else | |
| 1356 | +#error VERROR_MESSAGE Header file <sys/mman.h>, needed for module `builtin.closure` was not found. Please install the corresponding development headers. | |
| 1357 | +#endif | |
| 1358 | +#else | |
| 1359 | +#include <sys/mman.h> | |
| 1360 | +#endif | |
| 1361 | +#endif | |
| 1362 | + | |
| 1363 | + | |
| 1364 | +// inserted by module `builtin.closure`, file: closure_nix.c.v:5: | |
| 1365 | +#ifndef V_CLOSURE_ONCE_NIX_H | |
| 1366 | +#define V_CLOSURE_ONCE_NIX_H | |
| 1367 | + | |
| 1368 | +#include <pthread.h> | |
| 1369 | + | |
| 1370 | +typedef void (*v_closure_init_fn)(void); | |
| 1371 | + | |
| 1372 | +#ifndef V_CLOSURE_STATIC_INLINE | |
| 1373 | +# ifdef _MSC_VER | |
| 1374 | +# define V_CLOSURE_STATIC_INLINE static __inline | |
| 1375 | +# else | |
| 1376 | +# define V_CLOSURE_STATIC_INLINE static inline | |
| 1377 | +# endif | |
| 1378 | +#endif | |
| 1379 | + | |
| 1380 | +static pthread_mutex_t v_closure_once_mutex = PTHREAD_MUTEX_INITIALIZER; | |
| 1381 | +static int v_closure_once_done = 0; | |
| 1382 | + | |
| 1383 | +V_CLOSURE_STATIC_INLINE void v_closure_init_once(v_closure_init_fn init_fn) { | |
| 1384 | + pthread_mutex_lock(&v_closure_once_mutex); | |
| 1385 | + if (!v_closure_once_done) { | |
| 1386 | + init_fn(); | |
| 1387 | + v_closure_once_done = 1; | |
| 1388 | + } | |
| 1389 | + pthread_mutex_unlock(&v_closure_once_mutex); | |
| 1390 | +} | |
| 1391 | + | |
| 1392 | +#endif | |
| 1393 | + | |
| 1394 | +#endif | |
| 1395 | + | |
| 1396 | +#if 1 | |
| 1397 | + | |
| 1398 | +// added by module `builtin.closure`, file: closure_nix.c.v:4: | |
| 1399 | + | |
| 1400 | +#ifdef __TINYC__ | |
| 1401 | +#include <sys/mman.h> | |
| 1402 | +#else | |
| 1403 | +#if defined(__has_include) | |
| 1404 | +#if __has_include(<sys/mman.h>) | |
| 1405 | +#include <sys/mman.h> | |
| 1406 | +#else | |
| 1407 | +#error VERROR_MESSAGE Header file <sys/mman.h>, needed for module `builtin.closure` was not found. Please install the corresponding development headers. | |
| 1408 | +#endif | |
| 1409 | +#else | |
| 1410 | +#include <sys/mman.h> | |
| 1411 | +#endif | |
| 1412 | +#endif | |
| 1413 | + | |
| 1414 | + | |
| 1415 | +// inserted by module `builtin.closure`, file: closure_nix.c.v:5: | |
| 1416 | +#ifndef V_CLOSURE_ONCE_NIX_H | |
| 1417 | +#define V_CLOSURE_ONCE_NIX_H | |
| 1418 | + | |
| 1419 | +#include <pthread.h> | |
| 1420 | + | |
| 1421 | +typedef void (*v_closure_init_fn)(void); | |
| 1422 | + | |
| 1423 | +#ifndef V_CLOSURE_STATIC_INLINE | |
| 1424 | +# ifdef _MSC_VER | |
| 1425 | +# define V_CLOSURE_STATIC_INLINE static __inline | |
| 1426 | +# else | |
| 1427 | +# define V_CLOSURE_STATIC_INLINE static inline | |
| 1428 | +# endif | |
| 1429 | +#endif | |
| 1430 | + | |
| 1431 | +static pthread_mutex_t v_closure_once_mutex = PTHREAD_MUTEX_INITIALIZER; | |
| 1432 | +static int v_closure_once_done = 0; | |
| 1433 | + | |
| 1434 | +V_CLOSURE_STATIC_INLINE void v_closure_init_once(v_closure_init_fn init_fn) { | |
| 1435 | + pthread_mutex_lock(&v_closure_once_mutex); | |
| 1436 | + if (!v_closure_once_done) { | |
| 1437 | + init_fn(); | |
| 1438 | + v_closure_once_done = 1; | |
| 1439 | + } | |
| 1440 | + pthread_mutex_unlock(&v_closure_once_mutex); | |
| 1441 | +} | |
| 1442 | + | |
| 1443 | +#endif | |
| 1444 | + | |
| 1445 | +#endif | |
| 1446 | + | |
| 1447 | +// inserted by module `builtin`, file: allocation.c.v:43: | |
| 1448 | +#ifndef V_TRACK_HEAP_CHECKS_H | |
| 1449 | +#define V_TRACK_HEAP_CHECKS_H | |
| 1450 | + | |
| 1451 | +#if defined(CUSTOM_DEFINE_track_heap) && (defined(_VGCBOEHM) || defined(CUSTOM_DEFINE_gcboehm)) | |
| 1452 | +#error "-d track_heap requires manual memory management; rebuild with -gc none" | |
| 1453 | +#endif | |
| 1454 | + | |
| 1455 | +#if defined(CUSTOM_DEFINE_track_heap) && defined(CUSTOM_DEFINE_vgc) | |
| 1456 | +#error "-d track_heap requires manual memory management; rebuild with -gc none" | |
| 1457 | +#endif | |
| 1458 | + | |
| 1459 | +#if defined(CUSTOM_DEFINE_track_heap) && defined(_VPREALLOC) | |
| 1460 | +#error "-d track_heap requires manual memory management; rebuild with -gc none (not -prealloc)" | |
| 1461 | +#endif | |
| 1462 | + | |
| 1463 | +#endif | |
| 1464 | + | |
| 1465 | + | |
| 1466 | +// added by module `builtin`, file: float.c.v:9: | |
| 1467 | + | |
| 1468 | +#ifdef __TINYC__ | |
| 1469 | +#include <float.h> | |
| 1470 | +#else | |
| 1471 | +#if defined(__has_include) | |
| 1472 | +#if __has_include(<float.h>) | |
| 1473 | +#include <float.h> | |
| 1474 | +#else | |
| 1475 | +#error VERROR_MESSAGE Header file <float.h>, needed for module `builtin` was not found. Please install the corresponding development headers. | |
| 1476 | +#endif | |
| 1477 | +#else | |
| 1478 | +#include <float.h> | |
| 1479 | +#endif | |
| 1480 | +#endif | |
| 1481 | + | |
| 1482 | +#if !defined(__cplusplus) && !defined(CUSTOM_DEFINE_no_bool) | |
| 1483 | +#ifdef bool | |
| 1484 | +#undef bool | |
| 1485 | +#endif | |
| 1486 | +#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 202311L | |
| 1487 | +#ifdef CUSTOM_DEFINE_4bytebool | |
| 1488 | +typedef int bool; | |
| 1489 | +#else | |
| 1490 | +typedef u8 bool; | |
| 1491 | +#endif | |
| 1492 | +#endif | |
| 1493 | +#endif | |
| 1494 | + | |
| 1495 | +// V global/const #define ... : | |
| 1496 | +#define _const_builtin__closure__assumed_page_size 16384 | |
| 1497 | +#define _const_strconv__digits 18 | |
| 1498 | +#define _const_strconv__c_dpoint '.' | |
| 1499 | +#define _const_strconv__c_plus '+' | |
| 1500 | +#define _const_strconv__c_minus '-' | |
| 1501 | +#define _const_strconv__c_zero '0' | |
| 1502 | +#define _const_strconv__c_nine '9' | |
| 1503 | +#define _const_strconv__int_size 32 | |
| 1504 | +#define _const_strconv__max_size_f64_char 512 | |
| 1505 | +#define _const_autostr_type_stack_max_depth 64 | |
| 1506 | +#define _const_min_int -2147483648 | |
| 1507 | +#define _const_max_int 2147483647 | |
| 1508 | +#define _const_hashbits 24 | |
| 1509 | +#define _const_max_cached_hashbits 16 | |
| 1510 | +#define _const_init_log_capicity 5 | |
| 1511 | +#define _const_init_capicity 32 | |
| 1512 | +#define _const_init_even_index 30 | |
| 1513 | +#define _const_extra_metas_inc 4 | |
| 1514 | +#define _const_rune_maps_columns_in_row 4 | |
| 1515 | +#define _const_rune_maps_ul -3 | |
| 1516 | +#define _const_rune_maps_utl -2 | |
| 1517 | +#define _const_degree 6 | |
| 1518 | +#define _const_mid_index 5 | |
| 1519 | +#define _const_max_len 11 | |
| 1520 | +#define _const_replace_stack_buffer_size 10 | |
| 1521 | +#define _const_kmp_stack_buffer_size 20 | |
| 1522 | + | |
| 1523 | +// Enum definitions: | |
| 1524 | + | |
| 1525 | +typedef enum { | |
| 1526 | + strings__IndentState__normal, // | |
| 1527 | + strings__IndentState__in_string, // +1 | |
| 1528 | +} strings__IndentState; | |
| 1529 | + | |
| 1530 | +typedef enum { | |
| 1531 | + builtin__closure__MemoryProtectAtrr__read_exec, // | |
| 1532 | + builtin__closure__MemoryProtectAtrr__read_write, // +1 | |
| 1533 | +} builtin__closure__MemoryProtectAtrr; | |
| 1534 | + | |
| 1535 | +typedef enum { | |
| 1536 | + strconv__ParserState__ok, // | |
| 1537 | + strconv__ParserState__pzero, // +1 | |
| 1538 | + strconv__ParserState__mzero, // +2 | |
| 1539 | + strconv__ParserState__pinf, // +3 | |
| 1540 | + strconv__ParserState__minf, // +4 | |
| 1541 | + strconv__ParserState__invalid_number, // +5 | |
| 1542 | + strconv__ParserState__extra_char, // +6 | |
| 1543 | +} strconv__ParserState; | |
| 1544 | + | |
| 1545 | +typedef enum { | |
| 1546 | + strconv__Align_text__right = 0, // 0 | |
| 1547 | + strconv__Align_text__left, // 0+1 | |
| 1548 | + strconv__Align_text__center, // 0+2 | |
| 1549 | +} strconv__Align_text; | |
| 1550 | + | |
| 1551 | +typedef enum { | |
| 1552 | + strconv__Char_parse_state__start, // | |
| 1553 | + strconv__Char_parse_state__norm_char, // +1 | |
| 1554 | + strconv__Char_parse_state__field_char, // +2 | |
| 1555 | + strconv__Char_parse_state__pad_ch, // +3 | |
| 1556 | + strconv__Char_parse_state__len_set_start, // +4 | |
| 1557 | + strconv__Char_parse_state__len_set_in, // +5 | |
| 1558 | + strconv__Char_parse_state__check_type, // +6 | |
| 1559 | + strconv__Char_parse_state__check_float, // +7 | |
| 1560 | + strconv__Char_parse_state__check_float_in, // +8 | |
| 1561 | + strconv__Char_parse_state__reset_params, // +9 | |
| 1562 | +} strconv__Char_parse_state; | |
| 1563 | + | |
| 1564 | +typedef enum { | |
| 1565 | + ArrayFlags__noslices = 1U, // u64(1) << 0 | |
| 1566 | + ArrayFlags__noshrink = 2U, // u64(1) << 1 | |
| 1567 | + ArrayFlags__nogrow = 4U, // u64(1) << 2 | |
| 1568 | + ArrayFlags__nofree = 8U, // u64(1) << 3 | |
| 1569 | + ArrayFlags__managed = 16U, // u64(1) << 4 | |
| 1570 | + ArrayFlags__noscan_data = 32U, // u64(1) << 5 | |
| 1571 | + ArrayFlags__is_slice = 64U, // u64(1) << 6 | |
| 1572 | +} ArrayFlags; | |
| 1573 | + | |
| 1574 | +typedef enum { | |
| 1575 | + ChanState__success, // | |
| 1576 | + ChanState__not_ready, // +1 | |
| 1577 | + ChanState__closed, // +2 | |
| 1578 | +} ChanState; | |
| 1579 | + | |
| 1580 | +typedef enum { | |
| 1581 | + GraphemeBreakProperty__other, // | |
| 1582 | + GraphemeBreakProperty__cr, // +1 | |
| 1583 | + GraphemeBreakProperty__lf, // +2 | |
| 1584 | + GraphemeBreakProperty__control, // +3 | |
| 1585 | + GraphemeBreakProperty__extend, // +4 | |
| 1586 | + GraphemeBreakProperty__regional_indicator, // +5 | |
| 1587 | + GraphemeBreakProperty__prepend, // +6 | |
| 1588 | + GraphemeBreakProperty__spacing_mark, // +7 | |
| 1589 | + GraphemeBreakProperty__l, // +8 | |
| 1590 | + GraphemeBreakProperty__v, // +9 | |
| 1591 | + GraphemeBreakProperty__t, // +10 | |
| 1592 | + GraphemeBreakProperty__lv, // +11 | |
| 1593 | + GraphemeBreakProperty__lvt, // +12 | |
| 1594 | + GraphemeBreakProperty__zwj, // +13 | |
| 1595 | +} GraphemeBreakProperty; | |
| 1596 | + | |
| 1597 | +typedef enum { | |
| 1598 | + AttributeKind__plain, // | |
| 1599 | + AttributeKind__string, // +1 | |
| 1600 | + AttributeKind__number, // +2 | |
| 1601 | + AttributeKind__bool, // +3 | |
| 1602 | + AttributeKind__comptime_define, // +4 | |
| 1603 | +} AttributeKind; | |
| 1604 | + | |
| 1605 | +typedef enum { | |
| 1606 | + MapMode__to_upper, // | |
| 1607 | + MapMode__to_lower, // +1 | |
| 1608 | + MapMode__to_title, // +2 | |
| 1609 | +} MapMode; | |
| 1610 | + | |
| 1611 | +typedef enum { | |
| 1612 | + TrimMode__trim_left, // | |
| 1613 | + TrimMode__trim_right, // +1 | |
| 1614 | + TrimMode__trim_both, // +2 | |
| 1615 | +} TrimMode; | |
| 1616 | + | |
| 1617 | +typedef enum { | |
| 1618 | + StrIntpType__si_no_str = 0, // 0 | |
| 1619 | + StrIntpType__si_c, // 0+1 | |
| 1620 | + StrIntpType__si_u8, // 0+2 | |
| 1621 | + StrIntpType__si_i8, // 0+3 | |
| 1622 | + StrIntpType__si_u16, // 0+4 | |
| 1623 | + StrIntpType__si_i16, // 0+5 | |
| 1624 | + StrIntpType__si_u32, // 0+6 | |
| 1625 | + StrIntpType__si_i32, // 0+7 | |
| 1626 | + StrIntpType__si_u64, // 0+8 | |
| 1627 | + StrIntpType__si_i64, // 0+9 | |
| 1628 | + StrIntpType__si_e32, // 0+10 | |
| 1629 | + StrIntpType__si_e64, // 0+11 | |
| 1630 | + StrIntpType__si_f32, // 0+12 | |
| 1631 | + StrIntpType__si_f64, // 0+13 | |
| 1632 | + StrIntpType__si_g32, // 0+14 | |
| 1633 | + StrIntpType__si_g64, // 0+15 | |
| 1634 | + StrIntpType__si_s, // 0+16 | |
| 1635 | + StrIntpType__si_p, // 0+17 | |
| 1636 | + StrIntpType__si_r, // 0+18 | |
| 1637 | + StrIntpType__si_vp, // 0+19 | |
| 1638 | +} StrIntpType; | |
| 1639 | + | |
| 1640 | +// V type definitions: | |
| 1641 | +struct IError { | |
| 1642 | + union { | |
| 1643 | + void* _object; | |
| 1644 | + None__* _None__; | |
| 1645 | + voidptr* _voidptr; | |
| 1646 | + MessageError* _MessageError; | |
| 1647 | + Error* _Error; | |
| 1648 | + }; | |
| 1649 | + u32 _typ; | |
| 1650 | + void* _methods; | |
| 1651 | +}; | |
| 1652 | + | |
| 1653 | +struct string { | |
| 1654 | + u8* str; | |
| 1655 | + int len; | |
| 1656 | + int is_lit; | |
| 1657 | +}; | |
| 1658 | + | |
| 1659 | +struct array { | |
| 1660 | + voidptr data; | |
| 1661 | + int offset; | |
| 1662 | + int len; | |
| 1663 | + int cap; | |
| 1664 | + ArrayFlags flags; | |
| 1665 | + int element_size; | |
| 1666 | +}; | |
| 1667 | + | |
| 1668 | +struct DenseArray { | |
| 1669 | + int key_bytes; | |
| 1670 | + int value_bytes; | |
| 1671 | + int cap; | |
| 1672 | + int len; | |
| 1673 | + u32 deletes; | |
| 1674 | + u8* all_deleted; | |
| 1675 | + u8* keys; | |
| 1676 | + u8* values; | |
| 1677 | +}; | |
| 1678 | + | |
| 1679 | +struct map { | |
| 1680 | + int key_bytes; | |
| 1681 | + int value_bytes; | |
| 1682 | + u32 even_index; | |
| 1683 | + u8 cached_hashbits; | |
| 1684 | + u8 shift; | |
| 1685 | + DenseArray key_values; | |
| 1686 | + u32* metas; | |
| 1687 | + u32 extra_metas; | |
| 1688 | + bool has_string_keys; | |
| 1689 | + MapHashFn hash_fn; | |
| 1690 | + MapEqFn key_eq_fn; | |
| 1691 | + MapCloneFn clone_fn; | |
| 1692 | + MapFreeFn free_fn; | |
| 1693 | + int len; | |
| 1694 | +}; | |
| 1695 | + | |
| 1696 | +struct Error { | |
| 1697 | + E_STRUCT_DECL; | |
| 1698 | +}; | |
| 1699 | + | |
| 1700 | +struct _option { | |
| 1701 | + u8 state; | |
| 1702 | + IError err; | |
| 1703 | +}; | |
| 1704 | + | |
| 1705 | +struct _result { | |
| 1706 | + bool is_error; | |
| 1707 | + IError err; | |
| 1708 | +}; | |
| 1709 | +typedef array Array_string; | |
| 1710 | +typedef array Array_u8; | |
| 1711 | +typedef array Array_voidptr; | |
| 1712 | +typedef array Array_int; | |
| 1713 | +typedef array Array_IError; | |
| 1714 | +typedef array Array_rune; | |
| 1715 | +typedef string Array_fixed_string_11 [11]; | |
| 1716 | +typedef voidptr Array_fixed_voidptr_11 [11]; | |
| 1717 | +typedef array Array_RepIndex; | |
| 1718 | +typedef map Map_string_int; | |
| 1719 | +typedef array Array_bool; | |
| 1720 | +typedef array Array_builtin__closure__ClosureLifetimeRecord; | |
| 1721 | +typedef array Array_builtin__closure__ClosureLifetimeFrame; | |
| 1722 | +typedef map Map_voidptr_builtin__closure__ClosureLiveInfo; | |
| 1723 | +typedef map Map_u64_builtin__closure__ClosureLifetimeState_ptr; | |
| 1724 | +typedef u8 Array_fixed_u8_128 [128]; | |
| 1725 | +typedef u8 Array_fixed_u8_32 [32]; | |
| 1726 | +typedef u8 Array_fixed_u8_64 [64]; | |
| 1727 | +typedef u8 Array_fixed_u8_5 [5]; | |
| 1728 | +typedef u8 Array_fixed_u8_20 [20]; | |
| 1729 | +typedef u8 Array_fixed_u8_15 [15]; | |
| 1730 | +typedef u8 Array_fixed_u8_6 [6]; | |
| 1731 | +typedef u8 Array_fixed_u8_256 [256]; | |
| 1732 | +typedef u64 Array_fixed_u64_309 [309]; | |
| 1733 | +typedef u64 Array_fixed_u64_324 [324]; | |
| 1734 | +typedef u32 Array_fixed_u32_10 [10]; | |
| 1735 | +typedef u64 Array_fixed_u64_20 [20]; | |
| 1736 | +typedef u64 Array_fixed_u64_584 [584]; | |
| 1737 | +typedef u64 Array_fixed_u64_652 [652]; | |
| 1738 | +typedef f64 Array_fixed_f64_36 [36]; | |
| 1739 | +typedef u8 Array_fixed_u8_26 [26]; | |
| 1740 | +typedef u8 Array_fixed_u8_512 [512]; | |
| 1741 | +typedef u64 Array_fixed_u64_47 [47]; | |
| 1742 | +typedef u64 Array_fixed_u64_31 [31]; | |
| 1743 | +typedef int Array_fixed_int_64 [64]; | |
| 1744 | +typedef voidptr Array_fixed_voidptr_64 [64]; | |
| 1745 | +typedef voidptr Array_fixed_voidptr_100 [100]; | |
| 1746 | +typedef u8 Array_fixed_u8_1000 [1000]; | |
| 1747 | +typedef array Array_GraphemeBreakProperty; | |
| 1748 | +typedef u8 Array_fixed_u8_17 [17]; | |
| 1749 | +typedef i32 Array_fixed_i32_1264 [1264]; | |
| 1750 | +typedef int Array_fixed_int_10 [10]; | |
| 1751 | +typedef int Array_fixed_int_20 [20]; | |
| 1752 | +typedef array Array_StrIntpType; | |
| 1753 | +typedef Array_u8 strings__Builder; | |
| 1754 | +typedef bool (*anon_fn_voidptr__bool)(voidptr); | |
| 1755 | +typedef voidptr (*anon_fn_voidptr__voidptr)(voidptr); | |
| 1756 | +typedef int (*anon_fn_voidptr_voidptr__int)(voidptr,voidptr); | |
| 1757 | +typedef int (*FnSortCB)(const void*,const void*); | |
| 1758 | +typedef void (*FnExitCb)(); | |
| 1759 | +typedef void (*FnGC_WarnCB)(char*,usize); | |
| 1760 | +typedef voidptr (*builtin__closure__ClosureGetDataFn)(); | |
| 1761 | +typedef void (*builtin__closure__ClosureInitFn)(); | |
| 1762 | +typedef void (*anon_fn_)(); | |
| 1763 | +// #start sorted_symbols | |
| 1764 | +struct none { | |
| 1765 | + E_STRUCT_DECL; | |
| 1766 | +}; | |
| 1767 | + | |
| 1768 | +struct None__ { | |
| 1769 | + Error Error; | |
| 1770 | +}; | |
| 1771 | + | |
| 1772 | +struct InputRuneIterator { | |
| 1773 | + E_STRUCT_DECL; | |
| 1774 | +}; | |
| 1775 | + | |
| 1776 | +struct GCHeapUsage { | |
| 1777 | + usize heap_size; | |
| 1778 | + usize free_bytes; | |
| 1779 | + usize total_bytes; | |
| 1780 | + usize unmapped_bytes; | |
| 1781 | + usize bytes_since_gc; | |
| 1782 | +}; | |
| 1783 | + | |
| 1784 | +struct ArrayDataHeader { | |
| 1785 | + bool has_slices; | |
| 1786 | +}; | |
| 1787 | + | |
| 1788 | +struct MessageError { | |
| 1789 | + string msg; | |
| 1790 | + int code; | |
| 1791 | +}; | |
| 1792 | + | |
| 1793 | +union strconv__Float64u { | |
| 1794 | + f64 f; | |
| 1795 | + u64 u; | |
| 1796 | +}; | |
| 1797 | + | |
| 1798 | +union strconv__Float32u { | |
| 1799 | + f32 f; | |
| 1800 | + u32 u; | |
| 1801 | +}; | |
| 1802 | + | |
| 1803 | +struct GraphemeState { | |
| 1804 | + GraphemeBreakProperty prev_prop; | |
| 1805 | + int ri_count; | |
| 1806 | + u8 extended_pictographic_state; | |
| 1807 | +}; | |
| 1808 | + | |
| 1809 | +struct VAssertMetaInfo { | |
| 1810 | + string fpath; | |
| 1811 | + int line_nr; | |
| 1812 | + string fn_name; | |
| 1813 | + string src; | |
| 1814 | + string op; | |
| 1815 | + string llabel; | |
| 1816 | + string rlabel; | |
| 1817 | + string lvalue; | |
| 1818 | + string rvalue; | |
| 1819 | + string message; | |
| 1820 | + bool has_msg; | |
| 1821 | +}; | |
| 1822 | + | |
| 1823 | +struct SortedMap { | |
| 1824 | + int value_bytes; | |
| 1825 | + mapnode* root; | |
| 1826 | + int len; | |
| 1827 | +}; | |
| 1828 | + | |
| 1829 | +struct RepIndex { | |
| 1830 | + int idx; | |
| 1831 | + int val_idx; | |
| 1832 | +}; | |
| 1833 | + | |
| 1834 | +struct WrapConfig { | |
| 1835 | + int width; | |
| 1836 | + string end; | |
| 1837 | +}; | |
| 1838 | + | |
| 1839 | +struct RunesIterator { | |
| 1840 | + string s; | |
| 1841 | + int i; | |
| 1842 | +}; | |
| 1843 | + | |
| 1844 | +union StrIntpMem { | |
| 1845 | + u32 d_c; | |
| 1846 | + u8 d_u8; | |
| 1847 | + i8 d_i8; | |
| 1848 | + u16 d_u16; | |
| 1849 | + i16 d_i16; | |
| 1850 | + u32 d_u32; | |
| 1851 | + i32 d_i32; | |
| 1852 | + u64 d_u64; | |
| 1853 | + i64 d_i64; | |
| 1854 | + f32 d_f32; | |
| 1855 | + f64 d_f64; | |
| 1856 | + string d_s; | |
| 1857 | + string d_r; | |
| 1858 | + voidptr d_p; | |
| 1859 | + voidptr d_vp; | |
| 1860 | +}; | |
| 1861 | + | |
| 1862 | +struct strconv__BF_param { | |
| 1863 | + u8 pad_ch; | |
| 1864 | + int len0; | |
| 1865 | + int len1; | |
| 1866 | + bool positive; | |
| 1867 | + bool sign_flag; | |
| 1868 | + strconv__Align_text align; | |
| 1869 | + bool rm_tail_zero; | |
| 1870 | +}; | |
| 1871 | + | |
| 1872 | +struct ToWideConfig { | |
| 1873 | + bool from_ansi; | |
| 1874 | +}; | |
| 1875 | + | |
| 1876 | +struct strings__IndentParam { | |
| 1877 | + rune block_start; | |
| 1878 | + rune block_end; | |
| 1879 | + rune indent_char; | |
| 1880 | + int indent_count; | |
| 1881 | + int starting_level; | |
| 1882 | +}; | |
| 1883 | + | |
| 1884 | +struct strconv__PrepNumber { | |
| 1885 | + bool negative; | |
| 1886 | + int exponent; | |
| 1887 | + u64 mantissa; | |
| 1888 | +}; | |
| 1889 | + | |
| 1890 | +struct strconv__AtoF64Param { | |
| 1891 | + bool allow_extra_chars; | |
| 1892 | +}; | |
| 1893 | + | |
| 1894 | +struct strconv__Dec32 { | |
| 1895 | + u32 m; | |
| 1896 | + int e; | |
| 1897 | +}; | |
| 1898 | + | |
| 1899 | +union strconv__Uf32 { | |
| 1900 | + f32 f; | |
| 1901 | + u32 u; | |
| 1902 | +}; | |
| 1903 | + | |
| 1904 | +struct strconv__Dec64 { | |
| 1905 | + u64 m; | |
| 1906 | + int e; | |
| 1907 | +}; | |
| 1908 | + | |
| 1909 | +struct strconv__Uint128 { | |
| 1910 | + u64 lo; | |
| 1911 | + u64 hi; | |
| 1912 | +}; | |
| 1913 | + | |
| 1914 | +union strconv__Uf64 { | |
| 1915 | + f64 f; | |
| 1916 | + u64 u; | |
| 1917 | +}; | |
| 1918 | + | |
| 1919 | +struct builtin__closure__ClosurePage { | |
| 1920 | + builtin__closure__ClosurePage* next; | |
| 1921 | + voidptr exec_page_start; | |
| 1922 | +}; | |
| 1923 | + | |
| 1924 | +struct builtin__closure__ClosureLiveInfo { | |
| 1925 | + voidptr ctx; | |
| 1926 | + bool owns_data; | |
| 1927 | + u64 generation; | |
| 1928 | +}; | |
| 1929 | + | |
| 1930 | +struct builtin__closure__ClosureLifetimeRecord { | |
| 1931 | + voidptr exec_ptr; | |
| 1932 | + u64 generation; | |
| 1933 | +}; | |
| 1934 | + | |
| 1935 | +struct builtin__closure__ClosureLifetimeFrame { | |
| 1936 | + int start; | |
| 1937 | + int end; | |
| 1938 | +}; | |
| 1939 | + | |
| 1940 | +struct builtin__closure__ClosureLifetimeState { | |
| 1941 | + u64 owner_thread; | |
| 1942 | + bool active; | |
| 1943 | + bool disposed; | |
| 1944 | + int suspended; | |
| 1945 | + int frame_start; | |
| 1946 | + u64 frame_gen; | |
| 1947 | + u64 generation; | |
| 1948 | + u64 frame_generation; | |
| 1949 | + Array_builtin__closure__ClosureLifetimeRecord records; | |
| 1950 | + Array_builtin__closure__ClosureLifetimeFrame frames; | |
| 1951 | + builtin__closure__ClosureLifetimeState* next_free; | |
| 1952 | +}; | |
| 1953 | + | |
| 1954 | +struct builtin__closure__Lifetime { | |
| 1955 | + builtin__closure__ClosureLifetimeState* state; | |
| 1956 | + u64 generation; | |
| 1957 | + bool disposed; | |
| 1958 | +}; | |
| 1959 | + | |
| 1960 | +struct builtin__closure__FrameToken { | |
| 1961 | + builtin__closure__ClosureLifetimeState* state; | |
| 1962 | + u64 thread_id; | |
| 1963 | + u64 state_generation; | |
| 1964 | + u64 generation; | |
| 1965 | +}; | |
| 1966 | + | |
| 1967 | +struct mapnode { | |
| 1968 | + voidptr* children; | |
| 1969 | + int len; | |
| 1970 | + Array_fixed_string_11 keys; | |
| 1971 | + Array_fixed_voidptr_11 values; | |
| 1972 | +}; | |
| 1973 | + | |
| 1974 | +struct StrIntpData { | |
| 1975 | + string str; | |
| 1976 | + u32 fmt; | |
| 1977 | + StrIntpMem d; | |
| 1978 | + int dyn_width; | |
| 1979 | + int dyn_precision; | |
| 1980 | + u8 dyn_flags; | |
| 1981 | +}; | |
| 1982 | + | |
| 1983 | +struct builtin__closure__ClosureMutex { | |
| 1984 | + Array_fixed_u8_128 closure_mtx; | |
| 1985 | +}; | |
| 1986 | + | |
| 1987 | +struct builtin__closure__Closure { | |
| 1988 | + builtin__closure__ClosureMutex ClosureMutex; | |
| 1989 | + voidptr closure_ptr; | |
| 1990 | + builtin__closure__ClosureGetDataFn closure_get_data; | |
| 1991 | + int closure_cap; | |
| 1992 | + voidptr free_closure_ptr; | |
| 1993 | + builtin__closure__ClosurePage* pages; | |
| 1994 | + int v_page_size; | |
| 1995 | + Map_voidptr_builtin__closure__ClosureLiveInfo live; | |
| 1996 | + Map_u64_builtin__closure__ClosureLifetimeState_ptr active_lifetimes; | |
| 1997 | + u64 next_generation; | |
| 1998 | + builtin__closure__ClosureLifetimeState* free_lifetime_states; | |
| 1999 | + u64 next_lifetime_generation; | |
| 2000 | + u64 lifetime_state_allocs; | |
| 2001 | +}; | |
| 2002 | +// #end sorted_symbols | |
| 2003 | + | |
| 2004 | +// BEGIN_array_fixed_return_structs | |
| 2005 | +struct _v_Array_fixed_string_11 { | |
| 2006 | + string ret_arr[11]; | |
| 2007 | +}; | |
| 2008 | +struct _v_Array_fixed_voidptr_11 { | |
| 2009 | + voidptr ret_arr[11]; | |
| 2010 | +}; | |
| 2011 | +struct _v_Array_fixed_u8_128 { | |
| 2012 | + u8 ret_arr[128]; | |
| 2013 | +}; | |
| 2014 | +struct _v_Array_fixed_u8_32 { | |
| 2015 | + u8 ret_arr[32]; | |
| 2016 | +}; | |
| 2017 | +struct _v_Array_fixed_u8_64 { | |
| 2018 | + u8 ret_arr[64]; | |
| 2019 | +}; | |
| 2020 | +struct _v_Array_fixed_u8_5 { | |
| 2021 | + u8 ret_arr[5]; | |
| 2022 | +}; | |
| 2023 | +struct _v_Array_fixed_u8_20 { | |
| 2024 | + u8 ret_arr[20]; | |
| 2025 | +}; | |
| 2026 | +struct _v_Array_fixed_u8_15 { | |
| 2027 | + u8 ret_arr[15]; | |
| 2028 | +}; | |
| 2029 | +struct _v_Array_fixed_u8_6 { | |
| 2030 | + u8 ret_arr[6]; | |
| 2031 | +}; | |
| 2032 | +struct _v_Array_fixed_u8_256 { | |
| 2033 | + u8 ret_arr[256]; | |
| 2034 | +}; | |
| 2035 | +struct _v_Array_fixed_u64_309 { | |
| 2036 | + u64 ret_arr[309]; | |
| 2037 | +}; | |
| 2038 | +struct _v_Array_fixed_u64_324 { | |
| 2039 | + u64 ret_arr[324]; | |
| 2040 | +}; | |
| 2041 | +struct _v_Array_fixed_u32_10 { | |
| 2042 | + u32 ret_arr[10]; | |
| 2043 | +}; | |
| 2044 | +struct _v_Array_fixed_u64_20 { | |
| 2045 | + u64 ret_arr[20]; | |
| 2046 | +}; | |
| 2047 | +struct _v_Array_fixed_u64_584 { | |
| 2048 | + u64 ret_arr[584]; | |
| 2049 | +}; | |
| 2050 | +struct _v_Array_fixed_u64_652 { | |
| 2051 | + u64 ret_arr[652]; | |
| 2052 | +}; | |
| 2053 | +struct _v_Array_fixed_f64_36 { | |
| 2054 | + f64 ret_arr[36]; | |
| 2055 | +}; | |
| 2056 | +struct _v_Array_fixed_u8_26 { | |
| 2057 | + u8 ret_arr[26]; | |
| 2058 | +}; | |
| 2059 | +struct _v_Array_fixed_u8_512 { | |
| 2060 | + u8 ret_arr[512]; | |
| 2061 | +}; | |
| 2062 | +struct _v_Array_fixed_u64_47 { | |
| 2063 | + u64 ret_arr[47]; | |
| 2064 | +}; | |
| 2065 | +struct _v_Array_fixed_u64_31 { | |
| 2066 | + u64 ret_arr[31]; | |
| 2067 | +}; | |
| 2068 | +struct _v_Array_fixed_int_64 { | |
| 2069 | + int ret_arr[64]; | |
| 2070 | +}; | |
| 2071 | +struct _v_Array_fixed_voidptr_64 { | |
| 2072 | + voidptr ret_arr[64]; | |
| 2073 | +}; | |
| 2074 | +struct _v_Array_fixed_voidptr_100 { | |
| 2075 | + voidptr ret_arr[100]; | |
| 2076 | +}; | |
| 2077 | +struct _v_Array_fixed_u8_1000 { | |
| 2078 | + u8 ret_arr[1000]; | |
| 2079 | +}; | |
| 2080 | +struct _v_Array_fixed_u8_17 { | |
| 2081 | + u8 ret_arr[17]; | |
| 2082 | +}; | |
| 2083 | +struct _v_Array_fixed_i32_1264 { | |
| 2084 | + i32 ret_arr[1264]; | |
| 2085 | +}; | |
| 2086 | +struct _v_Array_fixed_int_10 { | |
| 2087 | + int ret_arr[10]; | |
| 2088 | +}; | |
| 2089 | +struct _v_Array_fixed_int_20 { | |
| 2090 | + int ret_arr[20]; | |
| 2091 | +}; | |
| 2092 | +// END_array_fixed_return_structs | |
| 2093 | + | |
| 2094 | + | |
| 2095 | +// BEGIN_multi_return_structs | |
| 2096 | +struct multi_return_u32_u32 { | |
| 2097 | + u32 arg0; | |
| 2098 | + u32 arg1; | |
| 2099 | +}; | |
| 2100 | + | |
| 2101 | +struct multi_return_string_string { | |
| 2102 | + string arg0; | |
| 2103 | + string arg1; | |
| 2104 | +}; | |
| 2105 | + | |
| 2106 | +struct multi_return_int_int { | |
| 2107 | + int arg0; | |
| 2108 | + int arg1; | |
| 2109 | +}; | |
| 2110 | + | |
| 2111 | +struct multi_return_rune_int { | |
| 2112 | + rune arg0; | |
| 2113 | + int arg1; | |
| 2114 | +}; | |
| 2115 | + | |
| 2116 | +struct multi_return_u32_u32_u32 { | |
| 2117 | + u32 arg0; | |
| 2118 | + u32 arg1; | |
| 2119 | + u32 arg2; | |
| 2120 | +}; | |
| 2121 | + | |
| 2122 | +struct multi_return_strconv__ParserState_strconv__PrepNumber { | |
| 2123 | + strconv__ParserState arg0; | |
| 2124 | + strconv__PrepNumber arg1; | |
| 2125 | +}; | |
| 2126 | + | |
| 2127 | +struct multi_return_u64_int { | |
| 2128 | + u64 arg0; | |
| 2129 | + int arg1; | |
| 2130 | +}; | |
| 2131 | + | |
| 2132 | +struct multi_return_i64_int { | |
| 2133 | + i64 arg0; | |
| 2134 | + int arg1; | |
| 2135 | +}; | |
| 2136 | + | |
| 2137 | +struct multi_return_strconv__Dec32_bool { | |
| 2138 | + strconv__Dec32 arg0; | |
| 2139 | + bool arg1; | |
| 2140 | +}; | |
| 2141 | + | |
| 2142 | +struct multi_return_strconv__Dec64_bool { | |
| 2143 | + strconv__Dec64 arg0; | |
| 2144 | + bool arg1; | |
| 2145 | +}; | |
| 2146 | + | |
| 2147 | +struct multi_return_u64_u64 { | |
| 2148 | + u64 arg0; | |
| 2149 | + u64 arg1; | |
| 2150 | +}; | |
| 2151 | + | |
| 2152 | +struct multi_return_f64_int { | |
| 2153 | + f64 arg0; | |
| 2154 | + int arg1; | |
| 2155 | +}; | |
| 2156 | + | |
| 2157 | +// END_multi_return_structs | |
| 2158 | + | |
| 2159 | +static bool Array_u8_contains(Array_u8 a, u8 v); | |
| 2160 | + | |
| 2161 | +// V Option_xxx definitions: | |
| 2162 | +struct _option_builtin__closure__ClosureLiveInfo { | |
| 2163 | + byte state; | |
| 2164 | + IError err; | |
| 2165 | + byte data[sizeof(builtin__closure__ClosureLiveInfo) > 1 ? sizeof(builtin__closure__ClosureLiveInfo) : 1]; | |
| 2166 | +}; | |
| 2167 | + | |
| 2168 | +struct _option_builtin__closure__ClosureLifetimeState_ptr { | |
| 2169 | + byte state; | |
| 2170 | + IError err; | |
| 2171 | + byte data[sizeof(builtin__closure__ClosureLifetimeState*) > 1 ? sizeof(builtin__closure__ClosureLifetimeState*) : 1]; | |
| 2172 | +}; | |
| 2173 | + | |
| 2174 | +struct _option_int { | |
| 2175 | + byte state; | |
| 2176 | + IError err; | |
| 2177 | + byte data[sizeof(int) > 1 ? sizeof(int) : 1]; | |
| 2178 | +}; | |
| 2179 | + | |
| 2180 | +struct _option_rune { | |
| 2181 | + byte state; | |
| 2182 | + IError err; | |
| 2183 | + byte data[sizeof(rune) > 1 ? sizeof(rune) : 1]; | |
| 2184 | +}; | |
| 2185 | + | |
| 2186 | +struct _option_multi_return_string_string { | |
| 2187 | + byte state; | |
| 2188 | + IError err; | |
| 2189 | + byte data[sizeof(multi_return_string_string) > 1 ? sizeof(multi_return_string_string) : 1]; | |
| 2190 | +}; | |
| 2191 | + | |
| 2192 | +struct _option_u8 { | |
| 2193 | + byte state; | |
| 2194 | + IError err; | |
| 2195 | + byte data[sizeof(u8) > 1 ? sizeof(u8) : 1]; | |
| 2196 | +}; | |
| 2197 | + | |
| 2198 | + | |
| 2199 | +// V result_xxx definitions: | |
| 2200 | +struct _result_int { | |
| 2201 | + bool is_error; | |
| 2202 | + IError err; | |
| 2203 | + byte data[sizeof(int) > 1 ? sizeof(int) : 1]; | |
| 2204 | +}; | |
| 2205 | + | |
| 2206 | +struct _result_builtin__closure__ClosureLifetimeState_ptr { | |
| 2207 | + bool is_error; | |
| 2208 | + IError err; | |
| 2209 | + byte data[sizeof(builtin__closure__ClosureLifetimeState*) > 1 ? sizeof(builtin__closure__ClosureLifetimeState*) : 1]; | |
| 2210 | +}; | |
| 2211 | + | |
| 2212 | +struct _result_builtin__closure__FrameToken { | |
| 2213 | + bool is_error; | |
| 2214 | + IError err; | |
| 2215 | + byte data[sizeof(builtin__closure__FrameToken) > 1 ? sizeof(builtin__closure__FrameToken) : 1]; | |
| 2216 | +}; | |
| 2217 | + | |
| 2218 | +struct _result_void { | |
| 2219 | + bool is_error; | |
| 2220 | + IError err; | |
| 2221 | + byte data[sizeof(u8) > 1 ? sizeof(u8) : 1]; | |
| 2222 | +}; | |
| 2223 | + | |
| 2224 | +struct _result_f64 { | |
| 2225 | + bool is_error; | |
| 2226 | + IError err; | |
| 2227 | + byte data[sizeof(f64) > 1 ? sizeof(f64) : 1]; | |
| 2228 | +}; | |
| 2229 | + | |
| 2230 | +struct _result_u64 { | |
| 2231 | + bool is_error; | |
| 2232 | + IError err; | |
| 2233 | + byte data[sizeof(u64) > 1 ? sizeof(u64) : 1]; | |
| 2234 | +}; | |
| 2235 | + | |
| 2236 | +struct _result_i64 { | |
| 2237 | + bool is_error; | |
| 2238 | + IError err; | |
| 2239 | + byte data[sizeof(i64) > 1 ? sizeof(i64) : 1]; | |
| 2240 | +}; | |
| 2241 | + | |
| 2242 | +struct _result_multi_return_i64_int { | |
| 2243 | + bool is_error; | |
| 2244 | + IError err; | |
| 2245 | + byte data[sizeof(multi_return_i64_int) > 1 ? sizeof(multi_return_i64_int) : 1]; | |
| 2246 | +}; | |
| 2247 | + | |
| 2248 | +struct _result_i8 { | |
| 2249 | + bool is_error; | |
| 2250 | + IError err; | |
| 2251 | + byte data[sizeof(i8) > 1 ? sizeof(i8) : 1]; | |
| 2252 | +}; | |
| 2253 | + | |
| 2254 | +struct _result_i16 { | |
| 2255 | + bool is_error; | |
| 2256 | + IError err; | |
| 2257 | + byte data[sizeof(i16) > 1 ? sizeof(i16) : 1]; | |
| 2258 | +}; | |
| 2259 | + | |
| 2260 | +struct _result_i32 { | |
| 2261 | + bool is_error; | |
| 2262 | + IError err; | |
| 2263 | + byte data[sizeof(i32) > 1 ? sizeof(i32) : 1]; | |
| 2264 | +}; | |
| 2265 | + | |
| 2266 | +struct _result_u8 { | |
| 2267 | + bool is_error; | |
| 2268 | + IError err; | |
| 2269 | + byte data[sizeof(u8) > 1 ? sizeof(u8) : 1]; | |
| 2270 | +}; | |
| 2271 | + | |
| 2272 | +struct _result_u16 { | |
| 2273 | + bool is_error; | |
| 2274 | + IError err; | |
| 2275 | + byte data[sizeof(u16) > 1 ? sizeof(u16) : 1]; | |
| 2276 | +}; | |
| 2277 | + | |
| 2278 | +struct _result_u32 { | |
| 2279 | + bool is_error; | |
| 2280 | + IError err; | |
| 2281 | + byte data[sizeof(u32) > 1 ? sizeof(u32) : 1]; | |
| 2282 | +}; | |
| 2283 | + | |
| 2284 | +struct _result_rune { | |
| 2285 | + bool is_error; | |
| 2286 | + IError err; | |
| 2287 | + byte data[sizeof(rune) > 1 ? sizeof(rune) : 1]; | |
| 2288 | +}; | |
| 2289 | + | |
| 2290 | +struct _result_string { | |
| 2291 | + bool is_error; | |
| 2292 | + IError err; | |
| 2293 | + byte data[sizeof(string) > 1 ? sizeof(string) : 1]; | |
| 2294 | +}; | |
| 2295 | + | |
| 2296 | + | |
| 2297 | +// V definitions: | |
| 2298 | +static char * v_typeof_interface_IError(u32 sidx); | |
| 2299 | +u32 v_typeof_interface_idx_IError(u32 sidx); | |
| 2300 | +// end of definitions #endif | |
| 2301 | +strings__Builder strings__new_builder(int initial_size); | |
| 2302 | +Array_u8 strings__Builder_reuse_as_plain_u8_array(strings__Builder* b); | |
| 2303 | +void strings__Builder_write_ptr(strings__Builder* b, u8* ptr, int len); | |
| 2304 | +void strings__Builder_write_rune(strings__Builder* b, rune r); | |
| 2305 | +void strings__Builder_write_runes(strings__Builder* b, Array_rune runes); | |
| 2306 | +void strings__Builder_write_u8(strings__Builder* b, u8 data); | |
| 2307 | +void strings__Builder_write_byte(strings__Builder* b, u8 data); | |
| 2308 | +void strings__Builder_write_decimal(strings__Builder* b, i64 n); | |
| 2309 | +void strings__Builder_write_u_decimal(strings__Builder* b, u64 n); | |
| 2310 | +_result_int strings__Builder_write(strings__Builder* b, Array_u8 data); | |
| 2311 | +void strings__Builder_drain_builder(strings__Builder* b, strings__Builder* other, int other_new_cap); | |
| 2312 | +u8 strings__Builder_byte_at(strings__Builder* b, int n); | |
| 2313 | +void strings__Builder_write_string(strings__Builder* b, string s); | |
| 2314 | +void strings__Builder_write_string2(strings__Builder* b, string s1, string s2); | |
| 2315 | +void strings__Builder_go_back(strings__Builder* b, int n); | |
| 2316 | +string strings__Builder_spart(strings__Builder* b, int start_pos, int n); | |
| 2317 | +string strings__Builder_cut_last(strings__Builder* b, int n); | |
| 2318 | +string strings__Builder_cut_to(strings__Builder* b, int pos); | |
| 2319 | +void strings__Builder_go_back_to(strings__Builder* b, int pos); | |
| 2320 | +void strings__Builder_writeln(strings__Builder* b, string s); | |
| 2321 | +void strings__Builder_writeln2(strings__Builder* b, string s1, string s2); | |
| 2322 | +string strings__Builder_last_n(strings__Builder* b, int n); | |
| 2323 | +string strings__Builder_after(strings__Builder* b, int n); | |
| 2324 | +string strings__Builder_str(strings__Builder* b); | |
| 2325 | +void strings__Builder_ensure_cap(strings__Builder* b, int n); | |
| 2326 | +void strings__Builder_grow_len(strings__Builder* b, int n); | |
| 2327 | +void strings__Builder_free(strings__Builder* b); | |
| 2328 | +void strings__Builder_write_repeated_rune(strings__Builder* b, rune r, int count); | |
| 2329 | +void strings__Builder_indent(strings__Builder* b, string s, strings__IndentParam param); | |
| 2330 | +VV_LOC int strings__min(int a, int b, int c); | |
| 2331 | +VV_LOC int strings__max2(int a, int b); | |
| 2332 | +VV_LOC int strings__min2(int a, int b); | |
| 2333 | +VV_LOC int strings__abs2(int a, int b); | |
| 2334 | +int strings__levenshtein_distance(string a, string b); | |
| 2335 | +f32 strings__levenshtein_distance_percentage(string a, string b); | |
| 2336 | +f32 strings__dice_coefficient(string s1, string s2); | |
| 2337 | +int strings__hamming_distance(string a, string b); | |
| 2338 | +f32 strings__hamming_similarity(string a, string b); | |
| 2339 | +f64 strings__jaro_similarity(string a, string b); | |
| 2340 | +f64 strings__jaro_winkler_similarity(string a, string b); | |
| 2341 | +string strings__repeat(u8 c, int n); | |
| 2342 | +string strings__repeat_string(string s, int n); | |
| 2343 | +string strings__find_between_pair_u8(string input, u8 start, u8 end); | |
| 2344 | +string strings__find_between_pair_rune(string input, rune start, rune end); | |
| 2345 | +string strings__find_between_pair_string(string input, string start, string end); | |
| 2346 | +Array_string strings__split_capital(string s); | |
| 2347 | +VV_LOC bool builtin__closure__is_ppc64(void); | |
| 2348 | +VV_LOC voidptr* builtin__closure__closure_slot_meta(voidptr exec_ptr); | |
| 2349 | +VV_LOC void builtin__closure__closure_register_page(voidptr exec_page_start); | |
| 2350 | +VV_LOC bool builtin__closure__closure_is_managed(voidptr exec_ptr); | |
| 2351 | +VV_LOC builtin__closure__ClosureLiveInfo builtin__closure__closure_live_delete(voidptr exec_ptr); | |
| 2352 | +VV_LOC builtin__closure__ClosureLifetimeState* builtin__closure__new_closure_lifetime_state_no_lock(void); | |
| 2353 | +VV_LOC builtin__closure__ClosureLifetimeState* builtin__closure__new_closure_lifetime_state(void); | |
| 2354 | +VV_LOC void builtin__closure__closure_lifetime_recycle_state_no_lock(builtin__closure__ClosureLifetimeState** state); | |
| 2355 | +VV_LOC string builtin__closure__closure_lifetime_error(builtin__closure__ClosureLifetimeState* state, u64 generation, u64 thread_id); | |
| 2356 | +VV_LOC _result_builtin__closure__ClosureLifetimeState_ptr builtin__closure__Lifetime_ensure_state(builtin__closure__Lifetime* lifetime); | |
| 2357 | +VV_LOC voidptr builtin__closure__closure_slot_data(voidptr exec_ptr); | |
| 2358 | +VV_LOC bool builtin__closure__closure_release_no_lock(voidptr exec_ptr, u64 generation); | |
| 2359 | +VV_LOC void builtin__closure__closure_lifetime_release_records_no_lock(Array_builtin__closure__ClosureLifetimeRecord records, int start, int end); | |
| 2360 | +VV_LOC void builtin__closure__closure_lifetime_reclaim_no_lock(builtin__closure__ClosureLifetimeState* state, int retain); | |
| 2361 | +VV_LOC void builtin__closure__closure_ensure_initialized(void); | |
| 2362 | +builtin__closure__Lifetime builtin__closure__new_lifetime(void); | |
| 2363 | +VV_LOC _result_builtin__closure__FrameToken builtin__closure__Lifetime_begin_frame(builtin__closure__Lifetime* lifetime); | |
| 2364 | +VV_LOC _result_void builtin__closure__Lifetime_end_frame(builtin__closure__Lifetime* lifetime, builtin__closure__FrameToken token); | |
| 2365 | +_result_void builtin__closure__Lifetime_frame(builtin__closure__Lifetime* lifetime, void (*work)()); | |
| 2366 | +_result_void builtin__closure__Lifetime_reclaim(builtin__closure__Lifetime* lifetime, int retain); | |
| 2367 | +_result_void builtin__closure__Lifetime_reclaim_all(builtin__closure__Lifetime* lifetime); | |
| 2368 | +_result_void builtin__closure__Lifetime_dispose(builtin__closure__Lifetime* lifetime); | |
| 2369 | +_result_void builtin__closure__Lifetime_suspend(builtin__closure__Lifetime* lifetime, void (*work)()); | |
| 2370 | +_result_void builtin__closure__Lifetime_untracked(builtin__closure__Lifetime* lifetime, void (*work)()); | |
| 2371 | +VV_LOC void builtin__closure__closure_alloc(void); | |
| 2372 | +VV_LOC void builtin__closure__closure_init_body(void); | |
| 2373 | +VV_LOC voidptr builtin__closure__closure_mtx_ptr_platform(void); | |
| 2374 | +VV_LOC u8* builtin__closure__closure_alloc_platform(void); | |
| 2375 | +VV_LOC void builtin__closure__closure_memory_protect_platform(voidptr ptr, isize size, builtin__closure__MemoryProtectAtrr attr); | |
| 2376 | +VV_LOC int builtin__closure__get_page_size_platform(void); | |
| 2377 | +VV_LOC void builtin__closure__closure_mtx_lock_init_platform(void); | |
| 2378 | +VV_LOC void builtin__closure__closure_mtx_lock_platform(void); | |
| 2379 | +VV_LOC void builtin__closure__closure_mtx_unlock_platform(void); | |
| 2380 | +VV_LOC u64 builtin__closure__closure_current_thread_id_platform(void); | |
| 2381 | +VV_LOC void builtin__closure__closure_init_once_platform(void); | |
| 2382 | +multi_return_u64_u64 math__bits__mul_64(u64 x, u64 y); | |
| 2383 | +multi_return_u64_u64 math__bits__mul_add_64(u64 x, u64 y, u64 z); | |
| 2384 | +multi_return_u64_u64 math__bits__div_64(u64 hi, u64 lo, u64 y1); | |
| 2385 | +int math__bits__leading_zeros_8(u8 x); | |
| 2386 | +int math__bits__leading_zeros_16(u16 x); | |
| 2387 | +int math__bits__leading_zeros_32(u32 x); | |
| 2388 | +int math__bits__leading_zeros_64(u64 x); | |
| 2389 | +int math__bits__trailing_zeros_8(u8 x); | |
| 2390 | +int math__bits__trailing_zeros_16(u16 x); | |
| 2391 | +int math__bits__trailing_zeros_32(u32 x); | |
| 2392 | +int math__bits__trailing_zeros_64(u64 x); | |
| 2393 | +int math__bits__ones_count_8(u8 x); | |
| 2394 | +int math__bits__ones_count_16(u16 x); | |
| 2395 | +int math__bits__ones_count_32(u32 x); | |
| 2396 | +int math__bits__ones_count_64(u64 x); | |
| 2397 | +int math__bits__pure_v_but_overridden_by_c_leading_zeros_8(u8 x); | |
| 2398 | +VV_LOC int math__bits__leading_zeros_8_default(u8 x); | |
| 2399 | +int math__bits__pure_v_but_overridden_by_c_leading_zeros_16(u16 x); | |
| 2400 | +VV_LOC int math__bits__leading_zeros_16_default(u16 x); | |
| 2401 | +int math__bits__pure_v_but_overridden_by_c_leading_zeros_32(u32 x); | |
| 2402 | +VV_LOC int math__bits__leading_zeros_32_default(u32 x); | |
| 2403 | +int math__bits__pure_v_but_overridden_by_c_leading_zeros_64(u64 x); | |
| 2404 | +VV_LOC int math__bits__leading_zeros_64_default(u64 x); | |
| 2405 | +int math__bits__pure_v_but_overridden_by_c_trailing_zeros_8(u8 x); | |
| 2406 | +VV_LOC int math__bits__trailing_zeros_8_default(u8 x); | |
| 2407 | +int math__bits__pure_v_but_overridden_by_c_trailing_zeros_16(u16 x); | |
| 2408 | +VV_LOC int math__bits__trailing_zeros_16_default(u16 x); | |
| 2409 | +int math__bits__pure_v_but_overridden_by_c_trailing_zeros_32(u32 x); | |
| 2410 | +VV_LOC int math__bits__trailing_zeros_32_default(u32 x); | |
| 2411 | +int math__bits__pure_v_but_overridden_by_c_trailing_zeros_64(u64 x); | |
| 2412 | +VV_LOC int math__bits__trailing_zeros_64_default(u64 x); | |
| 2413 | +int math__bits__pure_v_but_overridden_by_c_ones_count_8(u8 x); | |
| 2414 | +VV_LOC int math__bits__ones_count_8_default(u8 x); | |
| 2415 | +int math__bits__pure_v_but_overridden_by_c_ones_count_16(u16 x); | |
| 2416 | +VV_LOC int math__bits__ones_count_16_default(u16 x); | |
| 2417 | +int math__bits__pure_v_but_overridden_by_c_ones_count_32(u32 x); | |
| 2418 | +VV_LOC int math__bits__ones_count_32_default(u32 x); | |
| 2419 | +int math__bits__pure_v_but_overridden_by_c_ones_count_64(u64 x); | |
| 2420 | +VV_LOC int math__bits__ones_count_64_default(u64 x); | |
| 2421 | +u8 math__bits__rotate_left_8(u8 x, int k); | |
| 2422 | +u16 math__bits__rotate_left_16(u16 x, int k); | |
| 2423 | +u32 math__bits__rotate_left_32(u32 x, int k); | |
| 2424 | +u64 math__bits__rotate_left_64(u64 x, int k); | |
| 2425 | +u8 math__bits__reverse_8(u8 x); | |
| 2426 | +u16 math__bits__reverse_16(u16 x); | |
| 2427 | +u32 math__bits__reverse_32(u32 x); | |
| 2428 | +u64 math__bits__reverse_64(u64 x); | |
| 2429 | +u16 math__bits__reverse_bytes_16(u16 x); | |
| 2430 | +u32 math__bits__reverse_bytes_32(u32 x); | |
| 2431 | +u64 math__bits__reverse_bytes_64(u64 x); | |
| 2432 | +int math__bits__len_8(u8 x); | |
| 2433 | +int math__bits__len_16(u16 x); | |
| 2434 | +int math__bits__len_32(u32 x); | |
| 2435 | +int math__bits__len_64(u64 x); | |
| 2436 | +multi_return_u32_u32 math__bits__add_32(u32 x, u32 y, u32 carry); | |
| 2437 | +multi_return_u64_u64 math__bits__add_64(u64 x, u64 y, u64 carry); | |
| 2438 | +multi_return_u32_u32 math__bits__sub_32(u32 x, u32 y, u32 borrow); | |
| 2439 | +multi_return_u64_u64 math__bits__sub_64(u64 x, u64 y, u64 borrow); | |
| 2440 | +multi_return_u32_u32 math__bits__mul_32(u32 x, u32 y); | |
| 2441 | +VV_LOC multi_return_u32_u32 math__bits__mul_32_default(u32 x, u32 y); | |
| 2442 | +multi_return_u64_u64 math__bits__pure_v_but_overridden_by_amd64_mul_64(u64 x, u64 y); | |
| 2443 | +VV_LOC multi_return_u64_u64 math__bits__mul_64_default(u64 x, u64 y); | |
| 2444 | +multi_return_u32_u32 math__bits__mul_add_32(u32 x, u32 y, u32 z); | |
| 2445 | +VV_LOC multi_return_u32_u32 math__bits__mul_add_32_default(u32 x, u32 y, u32 z); | |
| 2446 | +multi_return_u64_u64 math__bits__pure_v_but_overridden_by_amd64_mul_add_64(u64 x, u64 y, u64 z); | |
| 2447 | +VV_LOC multi_return_u64_u64 math__bits__mul_add_64_default(u64 x, u64 y, u64 z); | |
| 2448 | +multi_return_u32_u32 math__bits__div_32(u32 hi, u32 lo, u32 y); | |
| 2449 | +VV_LOC multi_return_u32_u32 math__bits__div_32_default(u32 hi, u32 lo, u32 y); | |
| 2450 | +multi_return_u64_u64 math__bits__pure_v_but_overridden_by_amd64_div_64(u64 hi, u64 lo, u64 y1); | |
| 2451 | +VV_LOC multi_return_u64_u64 math__bits__div_64_default(u64 hi, u64 lo, u64 y1); | |
| 2452 | +u32 math__bits__rem_32(u32 hi, u32 lo, u32 y); | |
| 2453 | +u64 math__bits__rem_64(u64 hi, u64 lo, u64 y); | |
| 2454 | +multi_return_f64_int math__bits__normalize(f64 x); | |
| 2455 | +u32 math__bits__f32_bits(f32 f); | |
| 2456 | +f32 math__bits__f32_from_bits(u32 b); | |
| 2457 | +u64 math__bits__f64_bits(f64 f); | |
| 2458 | +f64 math__bits__f64_from_bits(u64 b); | |
| 2459 | +VV_LOC multi_return_u32_u32_u32 strconv__lsr96(u32 s2, u32 s1, u32 s0); | |
| 2460 | +VV_LOC multi_return_u32_u32_u32 strconv__lsl96(u32 s2, u32 s1, u32 s0); | |
| 2461 | +VV_LOC multi_return_u32_u32_u32 strconv__add96(u32 s2, u32 s1, u32 s0, u32 d2, u32 d1, u32 d0); | |
| 2462 | +VV_LOC multi_return_strconv__ParserState_strconv__PrepNumber strconv__parser(string s); | |
| 2463 | +VV_LOC u64 strconv__converter(strconv__PrepNumber* pn); | |
| 2464 | +_result_f64 strconv__atof64(string s, strconv__AtoF64Param param); | |
| 2465 | +f64 strconv__atof_quick(string s); | |
| 2466 | +u8 strconv__byte_to_lower(u8 c); | |
| 2467 | +_result_u64 strconv__common_parse_uint(string s, int _base, int _bit_size, bool error_on_non_digit, bool error_on_high_digit); | |
| 2468 | +multi_return_u64_int strconv__common_parse_uint2(string s, int _base, int _bit_size); | |
| 2469 | +_result_u64 strconv__parse_uint(string s, int _base, int _bit_size); | |
| 2470 | +_result_i64 strconv__common_parse_int(string _s, int base, int _bit_size, bool error_on_non_digit, bool error_on_high_digit); | |
| 2471 | +_result_i64 strconv__parse_int(string _s, int base, int _bit_size); | |
| 2472 | +VV_LOC _result_multi_return_i64_int strconv__atoi_common_check(string s); | |
| 2473 | +VV_LOC _result_i64 strconv__atoi_common(string s, i64 type_min, i64 type_max); | |
| 2474 | +_result_int strconv__atoi(string s); | |
| 2475 | +_result_i8 strconv__atoi8(string s); | |
| 2476 | +_result_i16 strconv__atoi16(string s); | |
| 2477 | +_result_i32 strconv__atoi32(string s); | |
| 2478 | +_result_i64 strconv__atoi64(string s); | |
| 2479 | +VV_LOC _result_i64 strconv__safe_add_64bits(i64 a, i64 b); | |
| 2480 | +VV_LOC _result_i64 strconv__safe_mul10_64bits(i64 a); | |
| 2481 | +VV_LOC _result_int strconv__atou_common_check(string s); | |
| 2482 | +VV_LOC _result_u64 strconv__atou_common(string s, u64 type_max); | |
| 2483 | +_result_u8 strconv__atou8(string s); | |
| 2484 | +_result_u16 strconv__atou16(string s); | |
| 2485 | +_result_u32 strconv__atou(string s); | |
| 2486 | +_result_u32 strconv__atou32(string s); | |
| 2487 | +_result_u64 strconv__atou64(string s); | |
| 2488 | +string strconv__Dec32_get_string_32(strconv__Dec32 d, bool neg, int i_n_digit, int i_pad_digit); | |
| 2489 | +VV_LOC multi_return_strconv__Dec32_bool strconv__f32_to_decimal_exact_int(u32 i_mant, u32 exp); | |
| 2490 | +VV_LOC strconv__Dec32 strconv__f32_to_decimal(u32 mant, u32 exp); | |
| 2491 | +string strconv__f32_to_str(f32 f, int n_digit); | |
| 2492 | +string strconv__f32_to_str_pad(f32 f, int n_digit); | |
| 2493 | +VV_LOC string strconv__Dec64_get_string_64(strconv__Dec64 d, bool neg, int i_n_digit, int i_pad_digit); | |
| 2494 | +VV_LOC multi_return_strconv__Dec64_bool strconv__f64_to_decimal_exact_int(u64 i_mant, u64 exp); | |
| 2495 | +VV_LOC strconv__Dec64 strconv__f64_to_decimal(u64 mant, u64 exp); | |
| 2496 | +string strconv__f64_to_str(f64 f, int n_digit); | |
| 2497 | +string strconv__f64_to_str_pad(f64 f, int n_digit); | |
| 2498 | +string strconv__format_str(string s, strconv__BF_param p); | |
| 2499 | +void strconv__format_str_sb(string s, strconv__BF_param p, strings__Builder* sb); | |
| 2500 | +void strconv__format_dec_sb(u64 d, strconv__BF_param p, strings__Builder* res); | |
| 2501 | +string strconv__f64_to_str_lnd1(f64 f, int dec_digit); | |
| 2502 | +string strconv__format_fl(f64 f, strconv__BF_param p); | |
| 2503 | +string strconv__format_es(f64 f, strconv__BF_param p); | |
| 2504 | +string strconv__remove_tail_zeros(string s); | |
| 2505 | +string strconv__ftoa_64(f64 f); | |
| 2506 | +string strconv__ftoa_long_64(f64 f); | |
| 2507 | +string strconv__ftoa_32(f32 f); | |
| 2508 | +string strconv__ftoa_long_32(f32 f); | |
| 2509 | +string strconv__format_int(i64 n, int radix); | |
| 2510 | +string strconv__format_uint(u64 n, int radix); | |
| 2511 | +string strconv__f32_to_str_l(f32 f); | |
| 2512 | +string strconv__f32_to_str_l_with_dot(f32 f); | |
| 2513 | +string strconv__f64_to_str_l(f64 f); | |
| 2514 | +string strconv__f64_to_str_l_with_dot(f64 f); | |
| 2515 | +string strconv__fxx_to_str_l_parse(string s); | |
| 2516 | +string strconv__fxx_to_str_l_parse_with_dot(string s); | |
| 2517 | +VV_LOC u32 strconv__bool_to_u32(bool b); | |
| 2518 | +VV_LOC u64 strconv__bool_to_u64(bool b); | |
| 2519 | +VV_LOC string strconv__get_string_special(bool neg, bool expZero, bool mantZero); | |
| 2520 | +VV_LOC u32 strconv__mul_shift_32(u32 m, u64 mul, int ishift); | |
| 2521 | +VV_LOC u32 strconv__mul_pow5_invdiv_pow2(u32 m, u32 q, int j); | |
| 2522 | +VV_LOC u32 strconv__mul_pow5_div_pow2(u32 m, u32 i, int j); | |
| 2523 | +VV_LOC u32 strconv__pow5_factor_32(u32 i_v); | |
| 2524 | +VV_LOC bool strconv__multiple_of_power_of_five_32(u32 v, u32 p); | |
| 2525 | +VV_LOC bool strconv__multiple_of_power_of_two_32(u32 v, u32 p); | |
| 2526 | +VV_LOC u32 strconv__log10_pow2(int e); | |
| 2527 | +VV_LOC u32 strconv__log10_pow5(int e); | |
| 2528 | +VV_LOC int strconv__pow5_bits(int e); | |
| 2529 | +VV_LOC u64 strconv__shift_right_128(strconv__Uint128 v, int shift); | |
| 2530 | +VV_LOC u64 strconv__mul_shift_64(u64 m, strconv__Uint128 mul, int shift); | |
| 2531 | +VV_LOC u32 strconv__pow5_factor_64(u64 v_i); | |
| 2532 | +VV_LOC bool strconv__multiple_of_power_of_five_64(u64 v, u32 p); | |
| 2533 | +VV_LOC bool strconv__multiple_of_power_of_two_64(u64 v, u32 p); | |
| 2534 | +int strconv__dec_digits(u64 n); | |
| 2535 | +void strconv__v_printf(string str, Array_voidptr pt); | |
| 2536 | +string strconv__v_sprintf(string str, Array_voidptr pt); | |
| 2537 | +VV_LOC void strconv__v_sprintf_panic(int idx, int len); | |
| 2538 | +VV_LOC f64 strconv__fabs(f64 x); | |
| 2539 | +string strconv__format_fl_old(f64 f, strconv__BF_param p); | |
| 2540 | +VV_LOC string strconv__format_es_old(f64 f, strconv__BF_param p); | |
| 2541 | +VV_LOC string strconv__remove_tail_zeros_old(string s); | |
| 2542 | +string strconv__format_dec_old(u64 d, strconv__BF_param p); | |
| 2543 | +int strconv__write_dec(i64 n, Array_u8* buf); | |
| 2544 | +int strconv__write_dec_u(u64 n, Array_u8* buf); | |
| 2545 | +VV_LOC void strconv__write_dec_u_digits(u64 n, Array_u8* buf, int offset, int ndigits); | |
| 2546 | +VV_LOC void builtin___memory_panic(string fname, isize size); | |
| 2547 | +u8* builtin___v_malloc(isize n); | |
| 2548 | +u8* builtin__malloc_noscan(isize n); | |
| 2549 | +VV_LOC u8* builtin__malloc_uninit(isize n); | |
| 2550 | +VV_LOC u64 builtin____at_least_one(u64 how_many); | |
| 2551 | +u8* builtin__malloc_uncollectable(isize n); | |
| 2552 | +u8* builtin__v_realloc(u8* b, isize n); | |
| 2553 | +u8* builtin__realloc_data(u8* old_data, int old_size, int new_size); | |
| 2554 | +u8* builtin__vcalloc(isize n); | |
| 2555 | +u8* builtin__vcalloc_noscan(isize n); | |
| 2556 | +void builtin___v_free(voidptr ptr); | |
| 2557 | +voidptr builtin__memdup(voidptr src, isize sz); | |
| 2558 | +voidptr builtin__memdup_noscan(voidptr src, isize sz); | |
| 2559 | +voidptr builtin__memdup_uncollectable(voidptr src, isize sz); | |
| 2560 | +voidptr builtin__memdup_align(voidptr src, isize sz, isize align); | |
| 2561 | +GCHeapUsage builtin__gc_heap_usage(void); | |
| 2562 | +usize builtin__gc_memory_use(void); | |
| 2563 | +VV_LOC int builtin__array_data_header_size(void); | |
| 2564 | +VV_LOC u64 builtin__array_data_allocation_size(u64 total_size); | |
| 2565 | +VV_LOC voidptr builtin__alloc_array_data(u64 total_size); | |
| 2566 | +VV_LOC voidptr builtin__alloc_array_data_uninit(u64 total_size); | |
| 2567 | +VV_LOC bool builtin__array_uses_noscan_data(array a); | |
| 2568 | +VV_LOC voidptr builtin__array_alloc_array_data_like(array a, u64 total_size); | |
| 2569 | +VV_LOC voidptr builtin__array_alloc_array_data_like_uninit(array a, u64 total_size); | |
| 2570 | +VV_LOC ArrayDataHeader* builtin__array_data_header(array a); | |
| 2571 | +VV_LOC bool builtin__array_buffer_has_slices(array a); | |
| 2572 | +VV_LOC void builtin__array_mark_buffer_has_slices(array* a); | |
| 2573 | +VV_LOC void builtin__array_set_managed_flags(array* a, bool is_slice); | |
| 2574 | +VV_LOC void builtin__array_clone_shallow_to_cap(array* a, int new_cap); | |
| 2575 | +VV_LOC int builtin__v_ni_index(int i, int len); | |
| 2576 | +VV_LOC array builtin____new_array(int mylen, int cap, int elm_size); | |
| 2577 | +VV_LOC array builtin____new_array_with_default(int mylen, int cap, int elm_size, voidptr val); | |
| 2578 | +VV_LOC array builtin____new_array_with_multi_default(int mylen, int cap, int elm_size, voidptr val); | |
| 2579 | +VV_LOC array builtin____new_array_with_array_default(int mylen, int cap, int elm_size, array val, int depth); | |
| 2580 | +VV_LOC array builtin__new_array_from_c_array(int len, int cap, int elm_size, voidptr c_array); | |
| 2581 | +void builtin__array_ensure_cap(array* a, int required); | |
| 2582 | +array builtin__array_repeat(array a, int count); | |
| 2583 | +array builtin__array_repeat_to_depth(array a, int count, int depth); | |
| 2584 | +VV_LOC bool builtin__array_needs_unique_shift(array a, int required); | |
| 2585 | +VV_LOC bool builtin__array_needs_unique_append(array a, int required); | |
| 2586 | +VV_LOC bool builtin__array_needs_unique_shrink(array a); | |
| 2587 | +void builtin__array_insert(array* a, int i, voidptr val); | |
| 2588 | +void builtin__array_prepend(array* a, voidptr val); | |
| 2589 | +void builtin__array_delete(array* a, int i); | |
| 2590 | +void builtin__array_delete_many(array* a, int i, int size); | |
| 2591 | +void builtin__array_clear(array* a); | |
| 2592 | +void builtin__array_reset(array* a); | |
| 2593 | +void builtin__array_trim(array* a, int index); | |
| 2594 | +void builtin__array_drop(array* a, int num); | |
| 2595 | +VV_LOC voidptr builtin__array_get_unsafe(array a, int i); | |
| 2596 | +VV_LOC voidptr builtin__array_get(array a, int i); | |
| 2597 | +VV_LOC voidptr builtin__array_get_i64(array a, i64 i); | |
| 2598 | +VV_LOC voidptr builtin__array_get_u64(array a, u64 i); | |
| 2599 | +VV_LOC voidptr builtin__array_get_ni(array a, int i); | |
| 2600 | +VV_LOC voidptr builtin__array_get_with_check(array a, int i); | |
| 2601 | +VV_LOC voidptr builtin__array_get_with_check_i64(array a, i64 i); | |
| 2602 | +VV_LOC voidptr builtin__array_get_with_check_u64(array a, u64 i); | |
| 2603 | +VV_LOC voidptr builtin__array_get_with_check_ni(array a, int i); | |
| 2604 | +voidptr builtin__array_first(array a); | |
| 2605 | +voidptr builtin__array_last(array a); | |
| 2606 | +voidptr builtin__array_pop_left(array* a); | |
| 2607 | +voidptr builtin__array_pop(array* a); | |
| 2608 | +void builtin__array_delete_last(array* a); | |
| 2609 | +VV_LOC array builtin__array_slice(array a, int start, int _end); | |
| 2610 | +VV_LOC array builtin__array_slice_ni(array a, int _start, int _end); | |
| 2611 | +VV_LOC array builtin__array_clone_static_to_depth(array a, int depth); | |
| 2612 | +array builtin__array_clone(array* a); | |
| 2613 | +array builtin__array_clone_to_depth(array* a, int depth); | |
| 2614 | +VV_LOC void builtin__array_set_unsafe(array* a, int i, voidptr val); | |
| 2615 | +VV_LOC void builtin__array_set(array* a, int i, voidptr val); | |
| 2616 | +VV_LOC void builtin__array_set_i64(array* a, i64 i, voidptr val); | |
| 2617 | +VV_LOC void builtin__array_set_u64(array* a, u64 i, voidptr val); | |
| 2618 | +VV_LOC void builtin__array_set_ni(array* a, int i, voidptr val); | |
| 2619 | +VV_LOC void builtin__copy_element_to(voidptr dest, voidptr src, int element_size); | |
| 2620 | +VV_LOC void builtin__array_push(array* a, voidptr val); | |
| 2621 | +void builtin__array_push_many(array* a, voidptr val, int size); | |
| 2622 | +void builtin__array_reverse_in_place(array* a); | |
| 2623 | +array builtin__array_reverse(array a); | |
| 2624 | +void builtin__array_free(array* a); | |
| 2625 | +array builtin__array_filter(array a, bool (*predicate)(voidptr _d1)); | |
| 2626 | +bool builtin__array_any(array a, bool (*predicate)(voidptr _d1)); | |
| 2627 | +int builtin__array_count(array a, bool (*predicate)(voidptr _d1)); | |
| 2628 | +bool builtin__array_all(array a, bool (*predicate)(voidptr _d1)); | |
| 2629 | +array builtin__array_map(array a, voidptr (*callback)(voidptr _d1)); | |
| 2630 | +void builtin__array_sort(array* a, int (*callback)(voidptr _d1, voidptr _d2)); | |
| 2631 | +array builtin__array_sorted(array* a, int (*callback)(voidptr _d1, voidptr _d2)); | |
| 2632 | +void builtin__array_sort_with_compare(array* a, int (*callback)(const void* const_a, const void* const_b)); | |
| 2633 | +array builtin__array_sorted_with_compare(array* a, int (*callback)(const void* const_a, const void* const_b)); | |
| 2634 | +bool builtin__array_contains(array a, voidptr value); | |
| 2635 | +int builtin__array_index(array a, voidptr value); | |
| 2636 | +int builtin__array_last_index(array a, voidptr value); | |
| 2637 | +void Array_string_free(Array_string* a); | |
| 2638 | +string Array_string_str(Array_string a); | |
| 2639 | +string Array_u8_hex(Array_u8 b); | |
| 2640 | +int builtin__copy(Array_u8* dst, Array_u8 src); | |
| 2641 | +void builtin__array_grow_cap(array* a, int amount); | |
| 2642 | +void builtin__array_grow_len(array* a, int amount); | |
| 2643 | +Array_voidptr builtin__array_pointers(array a); | |
| 2644 | +Array_u8 builtin__voidptr_vbytes(voidptr data, int len); | |
| 2645 | +Array_u8 builtin__u8_vbytes(u8* data, int len); | |
| 2646 | +void builtin__u8_free(u8* data); | |
| 2647 | +VV_LOC void builtin__panic_on_negative_len(int len); | |
| 2648 | +VV_LOC void builtin__panic_on_negative_cap(int cap); | |
| 2649 | +VV_LOC array builtin____new_array_noscan(int mylen, int cap, int elm_size); | |
| 2650 | +VV_LOC array builtin____new_array_with_default_noscan(int mylen, int cap, int elm_size, voidptr val); | |
| 2651 | +VV_LOC array builtin____new_array_with_multi_default_noscan(int mylen, int cap, int elm_size, voidptr val); | |
| 2652 | +VV_LOC array builtin____new_array_with_array_default_noscan(int mylen, int cap, int elm_size, array val, int depth); | |
| 2653 | +VV_LOC void builtin__array_push_noscan(array* a, voidptr val); | |
| 2654 | +VV_LOC void builtin__array_push_many_noscan(array* a, voidptr val, int size); | |
| 2655 | +VV_LOC bool builtin__autostr_type_in_stack(int typ); | |
| 2656 | +VV_LOC void builtin__autostr_type_push(int typ); | |
| 2657 | +VV_LOC void builtin__autostr_type_pop(void); | |
| 2658 | +VV_LOC bool builtin__autostr_addr_in_stack(voidptr addr); | |
| 2659 | +VV_LOC void builtin__autostr_addr_push(voidptr addr); | |
| 2660 | +VV_LOC void builtin__autostr_addr_pop(void); | |
| 2661 | +VV_LOC string builtin__autostr_array_circular(int len); | |
| 2662 | +void builtin__print_backtrace(void); | |
| 2663 | +VV_LOC string builtin__demangle_v_symbol(string cname); | |
| 2664 | +VV_LOC Array_string builtin__split_generic_params(string s); | |
| 2665 | +VV_LOC string builtin__demangle_backtrace_sym(string s); | |
| 2666 | +VV_LOC void builtin__eprint_space_padding(string output, int max_len); | |
| 2667 | +bool builtin__print_backtrace_skipping_top_frames(int xskipframes); | |
| 2668 | +VV_LOC string builtin__backtrace_current_executable_name(void); | |
| 2669 | +VV_LOC string builtin__backtrace_addr2line_executable(string executable, string current_executable_name); | |
| 2670 | +VV_LOC string builtin__backtrace_shell_quote(string s); | |
| 2671 | +VV_LOC bool builtin__print_backtrace_skipping_top_frames_linux(int skipframes); | |
| 2672 | +void builtin___v_exit(int code); | |
| 2673 | +_result_void builtin__at_exit(void (*cb)()); | |
| 2674 | +VV_LOC void builtin__v_segmentation_fault_handler(i32 signal_number); | |
| 2675 | +VV_LOC int builtin__v_fixed_index(int i, int len); | |
| 2676 | +VV_LOC int builtin__v_fixed_index_i64(i64 i, int len); | |
| 2677 | +VV_LOC int builtin__v_fixed_index_u64(u64 i, int len); | |
| 2678 | +VV_LOC int builtin__v_fixed_index_ni(int i, int len); | |
| 2679 | +VV_LOC int builtin__v_slice_index_i64(i64 i); | |
| 2680 | +VV_LOC int builtin__v_slice_index_u64(u64 i); | |
| 2681 | +Array_string builtin__arguments(void); | |
| 2682 | +string builtin__vcurrent_hash(void); | |
| 2683 | +u64 builtin__v_getpid(void); | |
| 2684 | +u64 builtin__v_gettid(void); | |
| 2685 | +bool builtin__isnil(voidptr v); | |
| 2686 | +VV_LOC void builtin__builtin_init(void); | |
| 2687 | +void builtin__panic_lasterr(string base); | |
| 2688 | +void builtin__gc_check_leaks(void); | |
| 2689 | +bool builtin__gc_is_enabled(void); | |
| 2690 | +void builtin__gc_enable(void); | |
| 2691 | +void builtin__gc_disable(void); | |
| 2692 | +void builtin__gc_collect(void); | |
| 2693 | +void builtin__gc_get_warn_proc(void); | |
| 2694 | +void builtin__gc_set_warn_proc(void (*cb)(char* msg, usize arg)); | |
| 2695 | +int builtin__vstrlen(u8* s); | |
| 2696 | +int builtin__vstrlen_char(char* s); | |
| 2697 | +voidptr builtin__vmemcpy(voidptr dest, const void* const_src, isize n); | |
| 2698 | +voidptr builtin__vmemmove(voidptr dest, const void* const_src, isize n); | |
| 2699 | +int builtin__vmemcmp(const void* const_s1, const void* const_s2, isize n); | |
| 2700 | +voidptr builtin__vmemset(voidptr s, int c, isize n); | |
| 2701 | +VV_LOC voidptr builtin__vsort_ptr_at(voidptr base, usize index, usize size); | |
| 2702 | +VV_LOC void builtin__vstable_sort_merge(voidptr source, voidptr dest, usize left, usize mid, usize right, usize size, int (*sort_cb)(const void* const_a, const void* const_b)); | |
| 2703 | +VV_LOC void builtin__vqsort(voidptr base, usize nmemb, usize size, int (*sort_cb)(const void* const_a, const void* const_b)); | |
| 2704 | +void builtin__chan_close(chan ch, Array_IError err); | |
| 2705 | +ChanState builtin__chan_try_pop(chan ch, voidptr obj); | |
| 2706 | +ChanState builtin__chan_try_push(chan ch, voidptr obj); | |
| 2707 | +VV_LOC void builtin___result_ok(voidptr data, _result* res, int size); | |
| 2708 | +VV_LOC void builtin___result_clone(_result* current, _result* res, int size); | |
| 2709 | +string builtin__IError_str(IError err); | |
| 2710 | +string builtin__Error_msg(Error err); | |
| 2711 | +int builtin__Error_code(Error err); | |
| 2712 | +string builtin__MessageError_str(MessageError err); | |
| 2713 | +string builtin__MessageError_msg(MessageError err); | |
| 2714 | +int builtin__MessageError_code(MessageError err); | |
| 2715 | +void builtin__MessageError_free(MessageError* err); | |
| 2716 | +IError builtin___v_error(string message); | |
| 2717 | +IError builtin__error_with_code(string message, int code); | |
| 2718 | +VV_LOC void builtin___option_none(voidptr data, _option* option, int size); | |
| 2719 | +VV_LOC void builtin___option_ok(voidptr data, _option* option, int size); | |
| 2720 | +VV_LOC void builtin___option_clone(_option* current, _option* option, int size); | |
| 2721 | +VV_LOC void builtin___result_ok_markused(void); | |
| 2722 | +VV_LOC string builtin__None___str(None__ _d1); | |
| 2723 | +string builtin__none_str(none _d1); | |
| 2724 | +int builtin__input_character(void); | |
| 2725 | +int builtin__print_character(u8 ch); | |
| 2726 | +string builtin__f64_str(f64 x); | |
| 2727 | +string builtin__f64_strg(f64 x); | |
| 2728 | +string builtin__float_literal_str(float_literal d); | |
| 2729 | +string builtin__f64_strsci(f64 x, int digit_num); | |
| 2730 | +string builtin__f64_strlong(f64 x); | |
| 2731 | +string builtin__f32_str(f32 x); | |
| 2732 | +string builtin__f32_strg(f32 x); | |
| 2733 | +string builtin__f32_strsci(f32 x, int digit_num); | |
| 2734 | +string builtin__f32_strlong(f32 x); | |
| 2735 | +f32 builtin__f32_abs(f32 a); | |
| 2736 | +f64 builtin__f64_abs(f64 a); | |
| 2737 | +f32 builtin__f32_min(f32 a, f32 b); | |
| 2738 | +f32 builtin__f32_max(f32 a, f32 b); | |
| 2739 | +f64 builtin__f64_min(f64 a, f64 b); | |
| 2740 | +f64 builtin__f64_max(f64 a, f64 b); | |
| 2741 | +bool builtin__f32_eq_epsilon(f32 a, f32 b); | |
| 2742 | +bool builtin__f64_eq_epsilon(f64 a, f64 b); | |
| 2743 | +VV_LOC u32 builtin__grapheme_hex_nibble(u8 c); | |
| 2744 | +VV_LOC u32 builtin__grapheme_hex_byte(string ranges, int i); | |
| 2745 | +VV_LOC u32 builtin__grapheme_range_value(string ranges, int value_idx); | |
| 2746 | +VV_LOC bool builtin__in_grapheme_ranges(rune r, string ranges); | |
| 2747 | +VV_LOC GraphemeBreakProperty builtin__grapheme_break_property(rune r); | |
| 2748 | +VV_LOC bool builtin__is_extended_pictographic(rune r); | |
| 2749 | +VV_LOC GraphemeState builtin__grapheme_state_from_rune(rune r, GraphemeBreakProperty prop); | |
| 2750 | +VV_LOC void builtin__GraphemeState_push(GraphemeState* gs, rune r, GraphemeBreakProperty prop); | |
| 2751 | +VV_LOC bool builtin__should_break_grapheme(GraphemeState gs, rune r, GraphemeBreakProperty prop); | |
| 2752 | +VV_LOC int builtin__utf8_rune_visible_width(rune r, GraphemeBreakProperty prop); | |
| 2753 | +VV_LOC Array_string builtin__string_graphemes_impl(string s); | |
| 2754 | +VV_LOC int builtin__utf8_grapheme_visible_length(string s); | |
| 2755 | +_option_rune builtin__input_rune(void); | |
| 2756 | +_option_rune builtin__InputRuneIterator_next(InputRuneIterator* self); | |
| 2757 | +InputRuneIterator builtin__input_rune_iterator(void); | |
| 2758 | +string builtin__ptr_str(voidptr ptr); | |
| 2759 | +string builtin__isize_str(isize x); | |
| 2760 | +string builtin__usize_str(usize x); | |
| 2761 | +string builtin__char_str(char* cptr); | |
| 2762 | +VV_LOC string builtin__int_str_l(int nn, int max); | |
| 2763 | +string builtin__i8_str(i8 n); | |
| 2764 | +string builtin__i16_str(i16 n); | |
| 2765 | +string builtin__u16_str(u16 n); | |
| 2766 | +string builtin__i32_str(i32 n); | |
| 2767 | +string builtin__int_hex_full(int nn); | |
| 2768 | +string builtin__int_str(int n); | |
| 2769 | +string builtin__u32_str(u32 nn); | |
| 2770 | +string builtin__int_literal_str(int_literal n); | |
| 2771 | +string builtin__i64_str(i64 nn); | |
| 2772 | +VV_LOC string builtin__impl_i64_to_string(i64 nn); | |
| 2773 | +string builtin__u64_str(u64 nn); | |
| 2774 | +string builtin__bool_str(bool b); | |
| 2775 | +VV_LOC string builtin__u64_to_hex(u64 nn, u8 len); | |
| 2776 | +VV_LOC string builtin__u64_to_hex_no_leading_zeros(u64 nn, u8 len); | |
| 2777 | +string builtin__u8_hex(u8 nn); | |
| 2778 | +string builtin__char_hex(char c); | |
| 2779 | +string builtin__rune_hex(rune r); | |
| 2780 | +string builtin__i8_hex(i8 nn); | |
| 2781 | +string builtin__u16_hex(u16 nn); | |
| 2782 | +string builtin__i16_hex(i16 nn); | |
| 2783 | +string builtin__u32_hex(u32 nn); | |
| 2784 | +string builtin__int_hex(int nn); | |
| 2785 | +string builtin__int_hex2(int n); | |
| 2786 | +string builtin__u64_hex(u64 nn); | |
| 2787 | +string builtin__i64_hex(i64 nn); | |
| 2788 | +string builtin__int_literal_hex(int_literal nn); | |
| 2789 | +string builtin__voidptr_str(voidptr nn); | |
| 2790 | +string builtin__byteptr_str(byteptr nn); | |
| 2791 | +string builtin__charptr_str(charptr nn); | |
| 2792 | +string builtin__u8_hex_full(u8 nn); | |
| 2793 | +string builtin__i8_hex_full(i8 nn); | |
| 2794 | +string builtin__u16_hex_full(u16 nn); | |
| 2795 | +string builtin__i16_hex_full(i16 nn); | |
| 2796 | +string builtin__u32_hex_full(u32 nn); | |
| 2797 | +string builtin__i64_hex_full(i64 nn); | |
| 2798 | +string builtin__voidptr_hex_full(voidptr nn); | |
| 2799 | +string builtin__int_literal_hex_full(int_literal nn); | |
| 2800 | +string builtin__u64_hex_full(u64 nn); | |
| 2801 | +string builtin__u8_str(u8 b); | |
| 2802 | +string builtin__u8_ascii_str(u8 b); | |
| 2803 | +string builtin__u8_str_escaped(u8 b); | |
| 2804 | +bool builtin__u8_is_capital(u8 c); | |
| 2805 | +string Array_u8_bytestr(Array_u8 b); | |
| 2806 | +_result_rune Array_u8_byterune(Array_u8 b); | |
| 2807 | +string builtin__u8_repeat(u8 b, int count); | |
| 2808 | +int builtin__int_min(int a, int b); | |
| 2809 | +int builtin__int_max(int a, int b); | |
| 2810 | +VV_LOC bool builtin__fast_string_eq(string a, string b); | |
| 2811 | +VV_LOC u64 builtin__map_hash_string(voidptr pkey); | |
| 2812 | +VV_LOC u64 builtin__map_hash_int_1(voidptr pkey); | |
| 2813 | +VV_LOC u64 builtin__map_hash_int_2(voidptr pkey); | |
| 2814 | +VV_LOC u64 builtin__map_hash_int_4(voidptr pkey); | |
| 2815 | +VV_LOC u64 builtin__map_hash_int_8(voidptr pkey); | |
| 2816 | +VV_LOC voidptr builtin__map_enum_fn(int kind, int esize); | |
| 2817 | +VV_LOC void builtin__DenseArray_zeros_to_end(DenseArray* d); | |
| 2818 | +VV_LOC DenseArray builtin__new_dense_array(int key_bytes, int value_bytes); | |
| 2819 | +VV_LOC voidptr builtin__DenseArray_key(DenseArray* d, int i); | |
| 2820 | +VV_LOC voidptr builtin__DenseArray_value(DenseArray* d, int i); | |
| 2821 | +VV_LOC bool builtin__DenseArray_has_index(DenseArray* d, int i); | |
| 2822 | +VV_LOC void builtin__DenseArray_trim_deleted_tail(DenseArray* d); | |
| 2823 | +VV_LOC int builtin__DenseArray_expand(DenseArray* d); | |
| 2824 | +VV_LOC bool builtin__map_eq_string(voidptr a, voidptr b); | |
| 2825 | +VV_LOC bool builtin__map_eq_int_1(voidptr a, voidptr b); | |
| 2826 | +VV_LOC bool builtin__map_eq_int_2(voidptr a, voidptr b); | |
| 2827 | +VV_LOC bool builtin__map_eq_int_4(voidptr a, voidptr b); | |
| 2828 | +VV_LOC bool builtin__map_eq_int_8(voidptr a, voidptr b); | |
| 2829 | +VV_LOC bool builtin__map_map_eq(map a, map b); | |
| 2830 | +VV_LOC void builtin__map_clone_string(voidptr dest, voidptr pkey); | |
| 2831 | +VV_LOC void builtin__map_clone_int_1(voidptr dest, voidptr pkey); | |
| 2832 | +VV_LOC void builtin__map_clone_int_2(voidptr dest, voidptr pkey); | |
| 2833 | +VV_LOC void builtin__map_clone_int_4(voidptr dest, voidptr pkey); | |
| 2834 | +VV_LOC void builtin__map_clone_int_8(voidptr dest, voidptr pkey); | |
| 2835 | +VV_LOC void builtin__map_free_string(voidptr pkey); | |
| 2836 | +VV_LOC void builtin__map_free_nop(voidptr _d1); | |
| 2837 | +VV_LOC map builtin__new_map(int key_bytes, int value_bytes, u64 (*hash_fn)(voidptr _d1), bool (*key_eq_fn)(voidptr _d1, voidptr _d2), void (*clone_fn)(voidptr _d1, voidptr _d2), void (*free_fn)(voidptr _d1)); | |
| 2838 | +VV_LOC map builtin__new_map_init(u64 (*hash_fn)(voidptr _d1), bool (*key_eq_fn)(voidptr _d1, voidptr _d2), void (*clone_fn)(voidptr _d1, voidptr _d2), void (*free_fn)(voidptr _d1), int n, int key_bytes, int value_bytes, voidptr keys, voidptr values); | |
| 2839 | +map builtin__map_move(map* m); | |
| 2840 | +void builtin__map_clear(map* m); | |
| 2841 | +VV_LOC multi_return_u32_u32 builtin__map_key_to_index(map* m, voidptr pkey); | |
| 2842 | +VV_LOC multi_return_u32_u32 builtin__map_meta_less(map* m, u32 _index, u32 _metas); | |
| 2843 | +VV_LOC void builtin__map_meta_greater(map* m, u32 _index, u32 _metas, u32 kvi); | |
| 2844 | +VV_LOC void builtin__map_ensure_extra_metas_grow(map* m); | |
| 2845 | +VV_LOC void builtin__map_ensure_extra_metas(map* m, u32 probe_count); | |
| 2846 | +VV_LOC void builtin__map_set(map* m, voidptr key, voidptr value); | |
| 2847 | +VV_LOC void builtin__map_expand(map* m); | |
| 2848 | +VV_LOC void builtin__map_rehash(map* m); | |
| 2849 | +VV_LOC void builtin__map_reserve_metas(map* m, u32 meta_bytes); | |
| 2850 | +void builtin__map_reserve(map* m, u32 n); | |
| 2851 | +VV_LOC void builtin__map_cached_rehash(map* m, u32 old_cap); | |
| 2852 | +VV_LOC voidptr builtin__map_get_and_set(map* m, voidptr key, voidptr zero); | |
| 2853 | +VV_LOC voidptr builtin__map_get(map* m, voidptr key, voidptr zero); | |
| 2854 | +VV_LOC voidptr builtin__map_get_check(map* m, voidptr key); | |
| 2855 | +VV_LOC bool builtin__map_exists(map* m, voidptr key); | |
| 2856 | +VV_LOC void builtin__DenseArray_delete(DenseArray* d, int i); | |
| 2857 | +void builtin__map_delete(map* m, voidptr key); | |
| 2858 | +array builtin__map_keys(map* m); | |
| 2859 | +array builtin__map_values(map* m); | |
| 2860 | +VV_LOC DenseArray builtin__DenseArray_clone(DenseArray* d); | |
| 2861 | +map builtin__map_clone(map* m); | |
| 2862 | +void builtin__map_free(map* m); | |
| 2863 | +void builtin__VAssertMetaInfo_free(VAssertMetaInfo* ami); | |
| 2864 | +void builtin__IError_free(IError* ie); | |
| 2865 | +void builtin__panic_option_not_set(string s); | |
| 2866 | +void builtin__panic_result_not_set(string s); | |
| 2867 | +void builtin___v_panic(string s); | |
| 2868 | +string builtin__c_error_number_str(int errnum); | |
| 2869 | +void builtin__panic_n(string s, i64 number1); | |
| 2870 | +void builtin__panic_n2(string s, i64 number1, i64 number2); | |
| 2871 | +VV_LOC void builtin__panic_n3(string s, i64 number1, i64 number2, i64 number3); | |
| 2872 | +void builtin__panic_error_number(string basestr, int errnum); | |
| 2873 | +VV_LOC void builtin__set_stream_unbuffered(FILE* stream); | |
| 2874 | +void builtin__eprintln(string s); | |
| 2875 | +void builtin__eprint(string s); | |
| 2876 | +void builtin__flush_stdout(void); | |
| 2877 | +void builtin__flush_stderr(void); | |
| 2878 | +void builtin__unbuffer_stdout(void); | |
| 2879 | +void builtin__print(string s); | |
| 2880 | +void builtin__println(string s); | |
| 2881 | +VV_LOC void builtin___writeln_to_fd(int fd, string s); | |
| 2882 | +VV_LOC void builtin___write_buf_to_fd(int fd, u8* buf, int buf_len); | |
| 2883 | +string builtin__reuse_data_as_string(Array_u8 buffer); | |
| 2884 | +Array_u8 builtin__reuse_string_as_data(string s); | |
| 2885 | +string builtin__rune_str(rune c); | |
| 2886 | +string Array_rune_string(Array_rune ra); | |
| 2887 | +string builtin__rune_repeat(rune c, int count); | |
| 2888 | +Array_u8 builtin__rune_bytes(rune c); | |
| 2889 | +int builtin__rune_length_in_bytes(rune c); | |
| 2890 | +rune builtin__rune_to_upper(rune c); | |
| 2891 | +rune builtin__rune_to_lower(rune c); | |
| 2892 | +rune builtin__rune_to_title(rune c); | |
| 2893 | +VV_LOC rune builtin__rune_map_to(rune c, MapMode mode); | |
| 2894 | +VV_LOC int builtin__mapnode_find_key(mapnode* n, string k); | |
| 2895 | +VV_LOC bool builtin__mapnode_remove_key(mapnode* n, string k); | |
| 2896 | +VV_LOC void builtin__mapnode_remove_from_leaf(mapnode* n, int idx); | |
| 2897 | +VV_LOC void builtin__mapnode_remove_from_non_leaf(mapnode* n, int idx); | |
| 2898 | +VV_LOC void builtin__mapnode_fill(mapnode* n, int idx); | |
| 2899 | +VV_LOC void builtin__mapnode_borrow_from_prev(mapnode* n, int idx); | |
| 2900 | +VV_LOC void builtin__mapnode_borrow_from_next(mapnode* n, int idx); | |
| 2901 | +VV_LOC void builtin__mapnode_merge(mapnode* n, int idx); | |
| 2902 | +void builtin__SortedMap_delete(SortedMap* m, string key); | |
| 2903 | +VV_LOC int builtin__mapnode_subkeys(mapnode* n, Array_string* keys, int at); | |
| 2904 | +Array_string builtin__SortedMap_keys(SortedMap* m); | |
| 2905 | +VV_LOC void builtin__mapnode_free(mapnode* n); | |
| 2906 | +void builtin__SortedMap_free(SortedMap* m); | |
| 2907 | +Array_rune builtin__string_runes(string s); | |
| 2908 | +Array_string builtin__string_graphemes(string s); | |
| 2909 | +string builtin__cstring_to_vstring(const char* const_s); | |
| 2910 | +string builtin__tos_clone(const u8* const_s); | |
| 2911 | +string builtin__tos(u8* s, int len); | |
| 2912 | +string builtin__tos2(u8* s); | |
| 2913 | +string builtin__tos3(char* s); | |
| 2914 | +string builtin__tos4(u8* s); | |
| 2915 | +string builtin__tos5(char* s); | |
| 2916 | +string builtin__u8_vstring(u8* bp); | |
| 2917 | +string builtin__u8_vstring_with_len(u8* bp, int len); | |
| 2918 | +string builtin__char_vstring(char* cp); | |
| 2919 | +string builtin__char_vstring_with_len(char* cp, int len); | |
| 2920 | +string builtin__u8_vstring_literal(u8* bp); | |
| 2921 | +string builtin__u8_vstring_literal_with_len(u8* bp, int len); | |
| 2922 | +string builtin__char_vstring_literal(char* cp); | |
| 2923 | +string builtin__char_vstring_literal_with_len(char* cp, int len); | |
| 2924 | +int builtin__string_len_utf8(string s); | |
| 2925 | +bool builtin__string_is_pure_ascii(string s); | |
| 2926 | +string builtin__string_clone(string a); | |
| 2927 | +string builtin__string_replace_once(string s, string rep, string with); | |
| 2928 | +string builtin__string_replace(string s, string rep, string with); | |
| 2929 | +string builtin__string_replace_each(string s, Array_string vals); | |
| 2930 | +string builtin__string_format(string s, Array_string args); | |
| 2931 | +string builtin__string_replace_char(string s, u8 rep, u8 with, int repeat); | |
| 2932 | +string builtin__string_normalize_tabs(string s, int tab_len); | |
| 2933 | +string builtin__string_expand_tabs(string s, int tab_len); | |
| 2934 | +bool builtin__string_bool(string s); | |
| 2935 | +i8 builtin__string_i8(string s); | |
| 2936 | +i16 builtin__string_i16(string s); | |
| 2937 | +i32 builtin__string_i32(string s); | |
| 2938 | +int builtin__string_int(string s); | |
| 2939 | +i64 builtin__string_i64(string s); | |
| 2940 | +f32 builtin__string_f32(string s); | |
| 2941 | +f64 builtin__string_f64(string s); | |
| 2942 | +Array_u8 builtin__string_u8_array(string s); | |
| 2943 | +u8 builtin__string_u8(string s); | |
| 2944 | +u16 builtin__string_u16(string s); | |
| 2945 | +u32 builtin__string_u32(string s); | |
| 2946 | +u64 builtin__string_u64(string s); | |
| 2947 | +_result_u64 builtin__string_parse_uint(string s, int _base, int _bit_size); | |
| 2948 | +_result_i64 builtin__string_parse_int(string s, int _base, int _bit_size); | |
| 2949 | +VV_LOC bool builtin__string__eq(string s, string a); | |
| 2950 | +int builtin__string_compare(string s, string a); | |
| 2951 | +VV_LOC bool builtin__string__lt(string s, string a); | |
| 2952 | +VV_LOC string builtin__string__plus(string s, string a); | |
| 2953 | +VV_LOC string builtin__string_plus_many(int data_len, string* input_base); | |
| 2954 | +VV_LOC string builtin__string_plus_two(string s, string a, string b); | |
| 2955 | +Array_string builtin__string_split_any(string s, string delim); | |
| 2956 | +Array_string builtin__string_rsplit_any(string s, string delim); | |
| 2957 | +Array_string builtin__string_split(string s, string delim); | |
| 2958 | +Array_string builtin__string_rsplit(string s, string delim); | |
| 2959 | +_option_multi_return_string_string builtin__string_split_once(string s, string delim); | |
| 2960 | +_option_multi_return_string_string builtin__string_rsplit_once(string s, string delim); | |
| 2961 | +Array_string builtin__string_split_n(string s, string delim, int n); | |
| 2962 | +Array_string builtin__string_split_nth(string s, string delim, int nth); | |
| 2963 | +Array_string builtin__string_rsplit_nth(string s, string delim, int nth); | |
| 2964 | +Array_string builtin__string_split_into_lines(string s); | |
| 2965 | +Array_string builtin__string_split_by_space(string s); | |
| 2966 | +string builtin__string_substr(string s, int start, int _end); | |
| 2967 | +string builtin__string_substr_unsafe(string s, int start, int _end); | |
| 2968 | +string builtin__string_substr_or(string s, int start, int _end, string fallback); | |
| 2969 | +_result_string builtin__string_substr_with_check(string s, int start, int _end); | |
| 2970 | +string builtin__string_substr_ni(string s, int _start, int _end); | |
| 2971 | +int builtin__string_index_(string s, string p); | |
| 2972 | +_option_int builtin__string_index(string s, string p); | |
| 2973 | +_option_int builtin__string_last_index(string s, string needle); | |
| 2974 | +VV_LOC int builtin__string_index_kmp(string s, string p); | |
| 2975 | +int builtin__string_index_any(string s, string chars); | |
| 2976 | +VV_LOC int builtin__string_index_last_(string s, string p); | |
| 2977 | +_option_int builtin__string_index_after(string s, string p, int start); | |
| 2978 | +int builtin__string_index_after_(string s, string p, int start); | |
| 2979 | +int builtin__string_index_u8(string s, u8 c); | |
| 2980 | +int builtin__string_last_index_u8(string s, u8 c); | |
| 2981 | +int builtin__string_count(string s, string substr); | |
| 2982 | +bool builtin__string_contains_u8(string s, u8 x); | |
| 2983 | +bool builtin__string_contains(string s, string substr); | |
| 2984 | +bool builtin__string_contains_any(string s, string chars); | |
| 2985 | +bool builtin__string_contains_only(string s, string chars); | |
| 2986 | +bool builtin__string_contains_any_substr(string s, Array_string substrs); | |
| 2987 | +bool builtin__string_starts_with(string s, string p); | |
| 2988 | +bool builtin__string_ends_with(string s, string p); | |
| 2989 | +string builtin__string_to_lower_ascii(string s); | |
| 2990 | +string builtin__string_to_lower(string s); | |
| 2991 | +bool builtin__string_is_lower(string s); | |
| 2992 | +string builtin__string_to_upper_ascii(string s); | |
| 2993 | +string builtin__string_to_upper(string s); | |
| 2994 | +bool builtin__string_is_upper(string s); | |
| 2995 | +string builtin__string_capitalize(string s); | |
| 2996 | +string builtin__string_uncapitalize(string s); | |
| 2997 | +bool builtin__string_is_capital(string s); | |
| 2998 | +bool builtin__string_starts_with_capital(string s); | |
| 2999 | +string builtin__string_title(string s); | |
| 3000 | +bool builtin__string_is_title(string s); | |
| 3001 | +string builtin__string_find_between(string s, string start, string end); | |
| 3002 | +string builtin__string_trim_space(string s); | |
| 3003 | +string builtin__string_trim_space_left(string s); | |
| 3004 | +string builtin__string_trim_space_right(string s); | |
| 3005 | +string builtin__string_trim(string s, string cutset); | |
| 3006 | +multi_return_int_int builtin__string_trim_indexes(string s, string cutset); | |
| 3007 | +VV_LOC string builtin__string_trim_chars(string s, string cutset, TrimMode mode); | |
| 3008 | +VV_LOC string builtin__string_trim_runes(string s, string cutset, TrimMode mode); | |
| 3009 | +string builtin__string_trim_left(string s, string cutset); | |
| 3010 | +string builtin__string_trim_right(string s, string cutset); | |
| 3011 | +string builtin__string_trim_string_left(string s, string str); | |
| 3012 | +string builtin__string_trim_string_right(string s, string str); | |
| 3013 | +int builtin__compare_strings(string* a, string* b); | |
| 3014 | +VV_LOC int builtin__compare_strings_by_len(string* a, string* b); | |
| 3015 | +VV_LOC int builtin__compare_lower_strings(string* a, string* b); | |
| 3016 | +void Array_string_sort_ignore_case(Array_string* s); | |
| 3017 | +void Array_string_sort_by_len(Array_string* s); | |
| 3018 | +string builtin__string_str(string s); | |
| 3019 | +VV_LOC u8 builtin__string_at(string s, int idx); | |
| 3020 | +VV_LOC u8 builtin__string_at_i64(string s, i64 idx); | |
| 3021 | +VV_LOC u8 builtin__string_at_u64(string s, u64 idx); | |
| 3022 | +VV_LOC u8 builtin__string_at_ni(string s, int idx); | |
| 3023 | +VV_LOC _option_u8 builtin__string_at_with_check(string s, int idx); | |
| 3024 | +VV_LOC _option_u8 builtin__string_at_with_check_i64(string s, i64 idx); | |
| 3025 | +VV_LOC _option_u8 builtin__string_at_with_check_u64(string s, u64 idx); | |
| 3026 | +VV_LOC _option_u8 builtin__string_at_with_check_ni(string s, int idx); | |
| 3027 | +bool builtin__string_is_oct(string str); | |
| 3028 | +bool builtin__string_is_bin(string str); | |
| 3029 | +bool builtin__string_is_hex(string str); | |
| 3030 | +bool builtin__string_is_int(string str); | |
| 3031 | +bool builtin__u8_is_space(u8 c); | |
| 3032 | +bool builtin__u8_is_digit(u8 c); | |
| 3033 | +bool builtin__u8_is_hex_digit(u8 c); | |
| 3034 | +bool builtin__u8_is_oct_digit(u8 c); | |
| 3035 | +bool builtin__u8_is_bin_digit(u8 c); | |
| 3036 | +bool builtin__u8_is_letter(u8 c); | |
| 3037 | +bool builtin__u8_is_alnum(u8 c); | |
| 3038 | +void builtin__string_free(string* s); | |
| 3039 | +string builtin__string_before(string s, string sub); | |
| 3040 | +string builtin__string_all_before(string s, string sub); | |
| 3041 | +string builtin__string_all_before_last(string s, string sub); | |
| 3042 | +string builtin__string_all_after(string s, string sub); | |
| 3043 | +string builtin__string_all_after_last(string s, string sub); | |
| 3044 | +string builtin__string_all_after_first(string s, string sub); | |
| 3045 | +string builtin__string_after(string s, string sub); | |
| 3046 | +string builtin__string_after_char(string s, u8 sub); | |
| 3047 | +string Array_string_join(Array_string a, string sep); | |
| 3048 | +string Array_string_join_lines(Array_string s); | |
| 3049 | +string builtin__string_reverse(string s); | |
| 3050 | +string builtin__string_limit(string s, int max); | |
| 3051 | +int builtin__string_hash(string s); | |
| 3052 | +Array_u8 builtin__string_bytes(string s); | |
| 3053 | +string builtin__string_repeat(string s, int count); | |
| 3054 | +Array_string builtin__string_fields(string s); | |
| 3055 | +string builtin__string_strip_margin(string s); | |
| 3056 | +string builtin__string_strip_margin_custom(string s, u8 del); | |
| 3057 | +string builtin__string_trim_indent(string s); | |
| 3058 | +int builtin__string_indent_width(string s); | |
| 3059 | +bool builtin__string_is_blank(string s); | |
| 3060 | +bool builtin__string_match_glob(string name, string pattern); | |
| 3061 | +bool builtin__string_is_ascii(string s); | |
| 3062 | +bool builtin__string_is_identifier(string s); | |
| 3063 | +string builtin__string_camel_to_snake(string s); | |
| 3064 | +string builtin__string_snake_to_camel(string s); | |
| 3065 | +string builtin__string_wrap(string s, WrapConfig config); | |
| 3066 | +string builtin__string_hex(string s); | |
| 3067 | +VV_LOC string builtin__data_to_hex_string(u8* data, int len); | |
| 3068 | +RunesIterator builtin__string_runes_iterator(string s); | |
| 3069 | +_option_rune builtin__RunesIterator_next(RunesIterator* ri); | |
| 3070 | +Array_u8 builtin__byteptr_vbytes(byteptr data, int len); | |
| 3071 | +string builtin__byteptr_vstring(byteptr bp); | |
| 3072 | +string builtin__byteptr_vstring_with_len(byteptr bp, int len); | |
| 3073 | +string builtin__charptr_vstring(charptr cp); | |
| 3074 | +string builtin__charptr_vstring_with_len(charptr cp, int len); | |
| 3075 | +string builtin__byteptr_vstring_literal(byteptr bp); | |
| 3076 | +string builtin__byteptr_vstring_literal_with_len(byteptr bp, int len); | |
| 3077 | +string builtin__charptr_vstring_literal(charptr cp); | |
| 3078 | +string builtin__charptr_vstring_literal_with_len(charptr cp, int len); | |
| 3079 | +string builtin__StrIntpType_str(StrIntpType x); | |
| 3080 | +VV_LOC f32 builtin__fabs32(f32 x); | |
| 3081 | +VV_LOC f64 builtin__fabs64(f64 x); | |
| 3082 | +VV_LOC u64 builtin__abs64(i64 x); | |
| 3083 | +u64 builtin__get_str_intp_u64_format(StrIntpType fmt_type, int in_width, int in_precision, bool in_tail_zeros, bool in_sign, u8 in_pad_ch, int in_base, bool in_upper_case); | |
| 3084 | +u32 builtin__get_str_intp_u32_format(StrIntpType fmt_type, int in_width, int in_precision, bool in_tail_zeros, bool in_sign, u8 in_pad_ch, int in_base, bool in_upper_case); | |
| 3085 | +VV_LOC void builtin__StrIntpData_process_str_intp_data(StrIntpData* data, strings__Builder* sb); | |
| 3086 | +string builtin__str_intp(int data_len, StrIntpData* input_base); | |
| 3087 | +string builtin__str_intp_sq(string in_str); | |
| 3088 | +string builtin__str_intp_rune(string in_str); | |
| 3089 | +string builtin__str_intp_g32(string in_str); | |
| 3090 | +string builtin__str_intp_g64(string in_str); | |
| 3091 | +string builtin__str_intp_sub(string base_str, string in_str); | |
| 3092 | +u16* builtin__string_to_wide(string _str, ToWideConfig param); | |
| 3093 | +string builtin__string_from_wide(u16* _wstr); | |
| 3094 | +string builtin__string_from_wide2(u16* _wstr, int len); | |
| 3095 | +Array_u8 builtin__wide_to_ansi(u16* _wstr); | |
| 3096 | +int builtin__utf8_char_len(u8 b); | |
| 3097 | +string builtin__utf32_to_str(u32 code); | |
| 3098 | +string builtin__utf32_to_str_no_malloc(u32 code, u8* buf); | |
| 3099 | +int builtin__utf32_decode_to_buffer(u32 code, u8* buf); | |
| 3100 | +int builtin__string_utf32_code(string _rune); | |
| 3101 | +_result_rune Array_u8_utf8_to_utf32(Array_u8 _bytes); | |
| 3102 | +VV_LOC bool builtin__utf8_is_continuation(u8 b); | |
| 3103 | +VV_LOC multi_return_rune_int builtin__utf8_decode_rune(u8* _bytes, int available_len); | |
| 3104 | +VV_LOC rune builtin__impl_utf8_to_utf32(u8* _bytes, int _bytes_len); | |
| 3105 | +int builtin__utf8_str_visible_length(string s); | |
| 3106 | +Array_u8 builtin__string_to_ansi_not_null_terminated(string _str); | |
| 3107 | +bool builtin__ArrayFlags_is_empty(ArrayFlags* e); | |
| 3108 | +bool builtin__ArrayFlags_has(ArrayFlags* e, ArrayFlags flag_); | |
| 3109 | +bool builtin__ArrayFlags_all(ArrayFlags* e, ArrayFlags flag_); | |
| 3110 | +void builtin__ArrayFlags_set(ArrayFlags* e, ArrayFlags flag_); | |
| 3111 | +void builtin__ArrayFlags_set_all(ArrayFlags* e); | |
| 3112 | +void builtin__ArrayFlags_clear(ArrayFlags* e, ArrayFlags flag_); | |
| 3113 | +void builtin__ArrayFlags_clear_all(ArrayFlags* e); | |
| 3114 | +void builtin__ArrayFlags_toggle(ArrayFlags* e, ArrayFlags flag_); | |
| 3115 | +ArrayFlags builtin__ArrayFlags__static__zero(void); | |
| 3116 | +VV_LOC void main__vf_init(void); | |
| 3117 | +VV_EXP void vf_init(void); // exported fn main.vf_init | |
| 3118 | +VV_LOC int main__vf_add(int a, int b); | |
| 3119 | +VV_EXP int vf_add(int a, int b); // exported fn main.vf_add | |
| 3120 | +VV_LOC char* main__vf_greet(char* name); | |
| 3121 | +VV_EXP char* vf_greet(char* name); // exported fn main.vf_greet | |
| 3122 | +VV_LOC void main__vf_free(voidptr p); | |
| 3123 | +VV_EXP void vf_free(voidptr p); // exported fn main.vf_free | |
| 3124 | +VV_LOC void main__main(void); | |
| 3125 | +static bool Array_rune_arr_eq(Array_rune a, Array_rune b); | |
| 3126 | +static bool builtin__closure__ClosureLifetimeState_struct_eq(builtin__closure__ClosureLifetimeState a, builtin__closure__ClosureLifetimeState b); | |
| 3127 | +static bool Array_builtin__closure__ClosureLifetimeRecord_arr_eq(Array_builtin__closure__ClosureLifetimeRecord a, Array_builtin__closure__ClosureLifetimeRecord b); | |
| 3128 | +static bool builtin__closure__ClosureLifetimeRecord_struct_eq(builtin__closure__ClosureLifetimeRecord a, builtin__closure__ClosureLifetimeRecord b); | |
| 3129 | +static bool Array_builtin__closure__ClosureLifetimeFrame_arr_eq(Array_builtin__closure__ClosureLifetimeFrame a, Array_builtin__closure__ClosureLifetimeFrame b); | |
| 3130 | +static bool builtin__closure__ClosureLifetimeFrame_struct_eq(builtin__closure__ClosureLifetimeFrame a, builtin__closure__ClosureLifetimeFrame b); | |
| 3131 | + | |
| 3132 | +// V global/const non-precomputed definitions: | |
| 3133 | +static string _const_math__bits__overflow_error; // a string literal, inited later | |
| 3134 | +static string _const_math__bits__divide_error; // a string literal, inited later | |
| 3135 | +static string _const_strconv__digit_pairs; // a string literal, inited later | |
| 3136 | +static string _const_strconv__base_digits; // a string literal, inited later | |
| 3137 | +static string _const_grapheme_control_ranges; // a string literal, inited later | |
| 3138 | +static string _const_grapheme_extend_ranges; // a string literal, inited later | |
| 3139 | +static string _const_grapheme_spacing_mark_ranges; // a string literal, inited later | |
| 3140 | +static string _const_grapheme_prepend_ranges; // a string literal, inited later | |
| 3141 | +static string _const_grapheme_extended_pictographic_ranges; // a string literal, inited later | |
| 3142 | +static string _const_digit_pairs; // a string literal, inited later | |
| 3143 | +static string _const_si_s_code; // a string literal, inited later | |
| 3144 | +static string _const_si_g32_code; // a string literal, inited later | |
| 3145 | +static string _const_si_g64_code; // a string literal, inited later | |
| 3146 | +builtin__closure__Closure g_closure; // global 6 | |
| 3147 | + | |
| 3148 | +static Array_fixed_u8_15 _const_builtin__closure__closure_thunk; // inited later | |
| 3149 | +static Array_fixed_u8_6 _const_builtin__closure__closure_get_data_bytes; // inited later | |
| 3150 | +static const u32 _const_math__bits__de_bruijn32 = 125613361; // precomputed2 | |
| 3151 | +static Array_fixed_u8_32 _const_math__bits__de_bruijn32tab = {((u8)(0)), 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, | |
| 3152 | +31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9}; // fixed array const | |
| 3153 | +static const u64 _const_math__bits__de_bruijn64 = 285870213051353865U; // precomputed2 | |
| 3154 | +static Array_fixed_u8_64 _const_math__bits__de_bruijn64tab = {((u8)(0)), 1, 56, 2, 57, 49, 28, 3, 61, 58, 42, 50, 38, 29, 17, 4, | |
| 3155 | +62, 47, 59, 36, 45, 43, 51, 22, 53, 39, 33, 30, 24, 18, 12, 5, | |
| 3156 | +63, 55, 48, 27, 60, 41, 37, 16, 46, 35, 44, 21, 52, 32, 23, 11, | |
| 3157 | +54, 26, 40, 15, 34, 20, 31, 10, 25, 14, 19, 9, 13, 8, 7, 6}; // fixed array const | |
| 3158 | +static const u64 _const_math__bits__m0 = 6148914691236517205U; // precomputed2 | |
| 3159 | +static const u64 _const_math__bits__m1 = 3689348814741910323U; // precomputed2 | |
| 3160 | +static const u64 _const_math__bits__m2 = 1085102592571150095U; // precomputed2 | |
| 3161 | +static const u64 _const_math__bits__m3 = 71777214294589695U; // precomputed2 | |
| 3162 | +static const u64 _const_math__bits__m4 = 281470681808895U; // precomputed2 | |
| 3163 | +static const u8 _const_math__bits__n8 = 8; // precomputed2 | |
| 3164 | +static const u16 _const_math__bits__n16 = 16; // precomputed2 | |
| 3165 | +static const u32 _const_math__bits__n32 = 32; // precomputed2 | |
| 3166 | +static const u64 _const_math__bits__n64 = 64U; // precomputed2 | |
| 3167 | +static const u64 _const_math__bits__two32 = 4294967296U; // precomputed2 | |
| 3168 | +static const u64 _const_math__bits__mask32 = 4294967295U; // precomputed2 | |
| 3169 | +static Array_fixed_u8_256 _const_math__bits__ntz_8_tab = {((u8)(0x08)), 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3170 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3171 | +0x05, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3172 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3173 | +0x06, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3174 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3175 | +0x05, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3176 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3177 | +0x07, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3178 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3179 | +0x05, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3180 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3181 | +0x06, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3182 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3183 | +0x05, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3184 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00}; // fixed array const | |
| 3185 | +static Array_fixed_u8_256 _const_math__bits__pop_8_tab = {((u8)(0x00)), 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, 0x03, 0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04, | |
| 3186 | +0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04, 0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, | |
| 3187 | +0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04, 0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, | |
| 3188 | +0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, | |
| 3189 | +0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04, 0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, | |
| 3190 | +0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, | |
| 3191 | +0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, | |
| 3192 | +0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, 0x04, 0x05, 0x05, 0x06, 0x05, 0x06, 0x06, 0x07, | |
| 3193 | +0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04, 0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, | |
| 3194 | +0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, | |
| 3195 | +0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, | |
| 3196 | +0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, 0x04, 0x05, 0x05, 0x06, 0x05, 0x06, 0x06, 0x07, | |
| 3197 | +0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, | |
| 3198 | +0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, 0x04, 0x05, 0x05, 0x06, 0x05, 0x06, 0x06, 0x07, | |
| 3199 | +0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, 0x04, 0x05, 0x05, 0x06, 0x05, 0x06, 0x06, 0x07, | |
| 3200 | +0x04, 0x05, 0x05, 0x06, 0x05, 0x06, 0x06, 0x07, 0x05, 0x06, 0x06, 0x07, 0x06, 0x07, 0x07, 0x08}; // fixed array const | |
| 3201 | +static Array_fixed_u8_256 _const_math__bits__rev_8_tab = {((u8)(0x00)), 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, | |
| 3202 | +0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, | |
| 3203 | +0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, | |
| 3204 | +0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, | |
| 3205 | +0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, | |
| 3206 | +0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, | |
| 3207 | +0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, | |
| 3208 | +0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, | |
| 3209 | +0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, | |
| 3210 | +0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, | |
| 3211 | +0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, | |
| 3212 | +0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, | |
| 3213 | +0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, | |
| 3214 | +0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, | |
| 3215 | +0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, | |
| 3216 | +0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff}; // fixed array const | |
| 3217 | +static Array_fixed_u8_256 _const_math__bits__len_8_tab = {((u8)(0x00)), 0x01, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, | |
| 3218 | +0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, | |
| 3219 | +0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, | |
| 3220 | +0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, | |
| 3221 | +0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, | |
| 3222 | +0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, | |
| 3223 | +0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, | |
| 3224 | +0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, | |
| 3225 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | |
| 3226 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | |
| 3227 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | |
| 3228 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | |
| 3229 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | |
| 3230 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | |
| 3231 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | |
| 3232 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08}; // fixed array const | |
| 3233 | +static const u32 _const_strconv__single_plus_zero = 0; // precomputed2 | |
| 3234 | +static const u32 _const_strconv__single_minus_zero = 2147483648; // precomputed2 | |
| 3235 | +static const u32 _const_strconv__single_plus_infinity = 2139095040; // precomputed2 | |
| 3236 | +static const u32 _const_strconv__single_minus_infinity = 4286578688; // precomputed2 | |
| 3237 | +static const u64 _const_strconv__double_plus_zero = 0U; // precomputed2 | |
| 3238 | +static const u64 _const_strconv__double_minus_zero = 9223372036854775808U; // precomputed2 | |
| 3239 | +static const u64 _const_strconv__double_plus_infinity = 9218868437227405312U; // precomputed2 | |
| 3240 | +static const u64 _const_strconv__double_minus_infinity = 18442240474082181120U; // precomputed2 | |
| 3241 | +static const u32 _const_strconv__c_ten = 10; // precomputed2 | |
| 3242 | +static Array_fixed_u64_309 _const_strconv__pos_exp = {((u64)(0x3ff0000000000000LL)), ((u64)(0x4024000000000000LL)), ((u64)(0x4059000000000000LL)), ((u64)(0x408f400000000000LL)), ((u64)(0x40c3880000000000LL)), ((u64)(0x40f86a0000000000LL)), ((u64)(0x412e848000000000LL)), ((u64)(0x416312d000000000LL)), ((u64)(0x4197d78400000000LL)), ((u64)(0x41cdcd6500000000LL)), ((u64)(0x4202a05f20000000LL)), ((u64)(0x42374876e8000000LL)), ((u64)(0x426d1a94a2000000LL)), ((u64)(0x42a2309ce5400000LL)), ((u64)(0x42d6bcc41e900000LL)), ((u64)(0x430c6bf526340000LL)), | |
| 3243 | +((u64)(0x4341c37937e08000LL)), ((u64)(0x4376345785d8a000LL)), ((u64)(0x43abc16d674ec800LL)), ((u64)(0x43e158e460913d00LL)), ((u64)(0x4415af1d78b58c40LL)), ((u64)(0x444b1ae4d6e2ef50LL)), ((u64)(0x4480f0cf064dd592LL)), ((u64)(0x44b52d02c7e14af6LL)), ((u64)(0x44ea784379d99db4LL)), ((u64)(0x45208b2a2c280291LL)), ((u64)(0x4554adf4b7320335LL)), ((u64)(0x4589d971e4fe8402LL)), ((u64)(0x45c027e72f1f1281LL)), ((u64)(0x45f431e0fae6d721LL)), ((u64)(0x46293e5939a08ceaLL)), ((u64)(0x465f8def8808b024LL)), | |
| 3244 | +((u64)(0x4693b8b5b5056e17LL)), ((u64)(0x46c8a6e32246c99cLL)), ((u64)(0x46fed09bead87c03LL)), ((u64)(0x4733426172c74d82LL)), ((u64)(0x476812f9cf7920e3LL)), ((u64)(0x479e17b84357691bLL)), ((u64)(0x47d2ced32a16a1b1LL)), ((u64)(0x48078287f49c4a1dLL)), ((u64)(0x483d6329f1c35ca5LL)), ((u64)(0x48725dfa371a19e7LL)), ((u64)(0x48a6f578c4e0a061LL)), ((u64)(0x48dcb2d6f618c879LL)), ((u64)(0x4911efc659cf7d4cLL)), ((u64)(0x49466bb7f0435c9eLL)), ((u64)(0x497c06a5ec5433c6LL)), ((u64)(0x49b18427b3b4a05cLL)), | |
| 3245 | +((u64)(0x49e5e531a0a1c873LL)), ((u64)(0x4a1b5e7e08ca3a8fLL)), ((u64)(0x4a511b0ec57e649aLL)), ((u64)(0x4a8561d276ddfdc0LL)), ((u64)(0x4ababa4714957d30LL)), ((u64)(0x4af0b46c6cdd6e3eLL)), ((u64)(0x4b24e1878814c9ceLL)), ((u64)(0x4b5a19e96a19fc41LL)), ((u64)(0x4b905031e2503da9LL)), ((u64)(0x4bc4643e5ae44d13LL)), ((u64)(0x4bf97d4df19d6057LL)), ((u64)(0x4c2fdca16e04b86dLL)), ((u64)(0x4c63e9e4e4c2f344LL)), ((u64)(0x4c98e45e1df3b015LL)), ((u64)(0x4ccf1d75a5709c1bLL)), ((u64)(0x4d03726987666191LL)), | |
| 3246 | +((u64)(0x4d384f03e93ff9f5LL)), ((u64)(0x4d6e62c4e38ff872LL)), ((u64)(0x4da2fdbb0e39fb47LL)), ((u64)(0x4dd7bd29d1c87a19LL)), ((u64)(0x4e0dac74463a989fLL)), ((u64)(0x4e428bc8abe49f64LL)), ((u64)(0x4e772ebad6ddc73dLL)), ((u64)(0x4eacfa698c95390cLL)), ((u64)(0x4ee21c81f7dd43a7LL)), ((u64)(0x4f16a3a275d49491LL)), ((u64)(0x4f4c4c8b1349b9b5LL)), ((u64)(0x4f81afd6ec0e1411LL)), ((u64)(0x4fb61bcca7119916LL)), ((u64)(0x4feba2bfd0d5ff5bLL)), ((u64)(0x502145b7e285bf99LL)), ((u64)(0x50559725db272f7fLL)), | |
| 3247 | +((u64)(0x508afcef51f0fb5fLL)), ((u64)(0x50c0de1593369d1bLL)), ((u64)(0x50f5159af8044462LL)), ((u64)(0x512a5b01b605557bLL)), ((u64)(0x516078e111c3556dLL)), ((u64)(0x5194971956342ac8LL)), ((u64)(0x51c9bcdfabc1357aLL)), ((u64)(0x5200160bcb58c16cLL)), ((u64)(0x52341b8ebe2ef1c7LL)), ((u64)(0x526922726dbaae39LL)), ((u64)(0x529f6b0f092959c7LL)), ((u64)(0x52d3a2e965b9d81dLL)), ((u64)(0x53088ba3bf284e24LL)), ((u64)(0x533eae8caef261adLL)), ((u64)(0x53732d17ed577d0cLL)), ((u64)(0x53a7f85de8ad5c4fLL)), | |
| 3248 | +((u64)(0x53ddf67562d8b363LL)), ((u64)(0x5412ba095dc7701eLL)), ((u64)(0x5447688bb5394c25LL)), ((u64)(0x547d42aea2879f2eLL)), ((u64)(0x54b249ad2594c37dLL)), ((u64)(0x54e6dc186ef9f45cLL)), ((u64)(0x551c931e8ab87173LL)), ((u64)(0x5551dbf316b346e8LL)), ((u64)(0x558652efdc6018a2LL)), ((u64)(0x55bbe7abd3781ecaLL)), ((u64)(0x55f170cb642b133fLL)), ((u64)(0x5625ccfe3d35d80eLL)), ((u64)(0x565b403dcc834e12LL)), ((u64)(0x569108269fd210cbLL)), ((u64)(0x56c54a3047c694feLL)), ((u64)(0x56fa9cbc59b83a3dLL)), | |
| 3249 | +((u64)(0x5730a1f5b8132466LL)), ((u64)(0x5764ca732617ed80LL)), ((u64)(0x5799fd0fef9de8e0LL)), ((u64)(0x57d03e29f5c2b18cLL)), ((u64)(0x58044db473335defLL)), ((u64)(0x583961219000356bLL)), ((u64)(0x586fb969f40042c5LL)), ((u64)(0x58a3d3e2388029bbLL)), ((u64)(0x58d8c8dac6a0342aLL)), ((u64)(0x590efb1178484135LL)), ((u64)(0x59435ceaeb2d28c1LL)), ((u64)(0x59783425a5f872f1LL)), ((u64)(0x59ae412f0f768fadLL)), ((u64)(0x59e2e8bd69aa19ccLL)), ((u64)(0x5a17a2ecc414a03fLL)), ((u64)(0x5a4d8ba7f519c84fLL)), | |
| 3250 | +((u64)(0x5a827748f9301d32LL)), ((u64)(0x5ab7151b377c247eLL)), ((u64)(0x5aecda62055b2d9eLL)), ((u64)(0x5b22087d4358fc82LL)), ((u64)(0x5b568a9c942f3ba3LL)), ((u64)(0x5b8c2d43b93b0a8cLL)), ((u64)(0x5bc19c4a53c4e697LL)), ((u64)(0x5bf6035ce8b6203dLL)), ((u64)(0x5c2b843422e3a84dLL)), ((u64)(0x5c6132a095ce4930LL)), ((u64)(0x5c957f48bb41db7cLL)), ((u64)(0x5ccadf1aea12525bLL)), ((u64)(0x5d00cb70d24b7379LL)), ((u64)(0x5d34fe4d06de5057LL)), ((u64)(0x5d6a3de04895e46dLL)), ((u64)(0x5da066ac2d5daec4LL)), | |
| 3251 | +((u64)(0x5dd4805738b51a75LL)), ((u64)(0x5e09a06d06e26112LL)), ((u64)(0x5e400444244d7cabLL)), ((u64)(0x5e7405552d60dbd6LL)), ((u64)(0x5ea906aa78b912ccLL)), ((u64)(0x5edf485516e7577fLL)), ((u64)(0x5f138d352e5096afLL)), ((u64)(0x5f48708279e4bc5bLL)), ((u64)(0x5f7e8ca3185deb72LL)), ((u64)(0x5fb317e5ef3ab327LL)), ((u64)(0x5fe7dddf6b095ff1LL)), ((u64)(0x601dd55745cbb7edLL)), ((u64)(0x6052a5568b9f52f4LL)), ((u64)(0x60874eac2e8727b1LL)), ((u64)(0x60bd22573a28f19dLL)), ((u64)(0x60f2357684599702LL)), | |
| 3252 | +((u64)(0x6126c2d4256ffcc3LL)), ((u64)(0x615c73892ecbfbf4LL)), ((u64)(0x6191c835bd3f7d78LL)), ((u64)(0x61c63a432c8f5cd6LL)), ((u64)(0x61fbc8d3f7b3340cLL)), ((u64)(0x62315d847ad00087LL)), ((u64)(0x6265b4e5998400a9LL)), ((u64)(0x629b221effe500d4LL)), ((u64)(0x62d0f5535fef2084LL)), ((u64)(0x630532a837eae8a5LL)), ((u64)(0x633a7f5245e5a2cfLL)), ((u64)(0x63708f936baf85c1LL)), ((u64)(0x63a4b378469b6732LL)), ((u64)(0x63d9e056584240feLL)), ((u64)(0x64102c35f729689fLL)), ((u64)(0x6444374374f3c2c6LL)), | |
| 3253 | +((u64)(0x647945145230b378LL)), ((u64)(0x64af965966bce056LL)), ((u64)(0x64e3bdf7e0360c36LL)), ((u64)(0x6518ad75d8438f43LL)), ((u64)(0x654ed8d34e547314LL)), ((u64)(0x6583478410f4c7ecLL)), ((u64)(0x65b819651531f9e8LL)), ((u64)(0x65ee1fbe5a7e7861LL)), ((u64)(0x6622d3d6f88f0b3dLL)), ((u64)(0x665788ccb6b2ce0cLL)), ((u64)(0x668d6affe45f818fLL)), ((u64)(0x66c262dfeebbb0f9LL)), ((u64)(0x66f6fb97ea6a9d38LL)), ((u64)(0x672cba7de5054486LL)), ((u64)(0x6761f48eaf234ad4LL)), ((u64)(0x679671b25aec1d89LL)), | |
| 3254 | +((u64)(0x67cc0e1ef1a724ebLL)), ((u64)(0x680188d357087713LL)), ((u64)(0x6835eb082cca94d7LL)), ((u64)(0x686b65ca37fd3a0dLL)), ((u64)(0x68a11f9e62fe4448LL)), ((u64)(0x68d56785fbbdd55aLL)), ((u64)(0x690ac1677aad4ab1LL)), ((u64)(0x6940b8e0acac4eafLL)), ((u64)(0x6974e718d7d7625aLL)), ((u64)(0x69aa20df0dcd3af1LL)), ((u64)(0x69e0548b68a044d6LL)), ((u64)(0x6a1469ae42c8560cLL)), ((u64)(0x6a498419d37a6b8fLL)), ((u64)(0x6a7fe52048590673LL)), ((u64)(0x6ab3ef342d37a408LL)), ((u64)(0x6ae8eb0138858d0aLL)), | |
| 3255 | +((u64)(0x6b1f25c186a6f04cLL)), ((u64)(0x6b537798f4285630LL)), ((u64)(0x6b88557f31326bbbLL)), ((u64)(0x6bbe6adefd7f06aaLL)), ((u64)(0x6bf302cb5e6f642aLL)), ((u64)(0x6c27c37e360b3d35LL)), ((u64)(0x6c5db45dc38e0c82LL)), ((u64)(0x6c9290ba9a38c7d1LL)), ((u64)(0x6cc734e940c6f9c6LL)), ((u64)(0x6cfd022390f8b837LL)), ((u64)(0x6d3221563a9b7323LL)), ((u64)(0x6d66a9abc9424febLL)), ((u64)(0x6d9c5416bb92e3e6LL)), ((u64)(0x6dd1b48e353bce70LL)), ((u64)(0x6e0621b1c28ac20cLL)), ((u64)(0x6e3baa1e332d728fLL)), | |
| 3256 | +((u64)(0x6e714a52dffc6799LL)), ((u64)(0x6ea59ce797fb817fLL)), ((u64)(0x6edb04217dfa61dfLL)), ((u64)(0x6f10e294eebc7d2cLL)), ((u64)(0x6f451b3a2a6b9c76LL)), ((u64)(0x6f7a6208b5068394LL)), ((u64)(0x6fb07d457124123dLL)), ((u64)(0x6fe49c96cd6d16ccLL)), ((u64)(0x7019c3bc80c85c7fLL)), ((u64)(0x70501a55d07d39cfLL)), ((u64)(0x708420eb449c8843LL)), ((u64)(0x70b9292615c3aa54LL)), ((u64)(0x70ef736f9b3494e9LL)), ((u64)(0x7123a825c100dd11LL)), ((u64)(0x7158922f31411456LL)), ((u64)(0x718eb6bafd91596bLL)), | |
| 3257 | +((u64)(0x71c33234de7ad7e3LL)), ((u64)(0x71f7fec216198ddcLL)), ((u64)(0x722dfe729b9ff153LL)), ((u64)(0x7262bf07a143f6d4LL)), ((u64)(0x72976ec98994f489LL)), ((u64)(0x72cd4a7bebfa31abLL)), ((u64)(0x73024e8d737c5f0bLL)), ((u64)(0x7336e230d05b76cdLL)), ((u64)(0x736c9abd04725481LL)), ((u64)(0x73a1e0b622c774d0LL)), ((u64)(0x73d658e3ab795204LL)), ((u64)(0x740bef1c9657a686LL)), ((u64)(0x74417571ddf6c814LL)), ((u64)(0x7475d2ce55747a18LL)), ((u64)(0x74ab4781ead1989eLL)), ((u64)(0x74e10cb132c2ff63LL)), | |
| 3258 | +((u64)(0x75154fdd7f73bf3cLL)), ((u64)(0x754aa3d4df50af0bLL)), ((u64)(0x7580a6650b926d67LL)), ((u64)(0x75b4cffe4e7708c0LL)), ((u64)(0x75ea03fde214caf1LL)), ((u64)(0x7620427ead4cfed6LL)), ((u64)(0x7654531e58a03e8cLL)), ((u64)(0x768967e5eec84e2fLL)), ((u64)(0x76bfc1df6a7a61bbLL)), ((u64)(0x76f3d92ba28c7d15LL)), ((u64)(0x7728cf768b2f9c5aLL)), ((u64)(0x775f03542dfb8370LL)), ((u64)(0x779362149cbd3226LL)), ((u64)(0x77c83a99c3ec7eb0LL)), ((u64)(0x77fe494034e79e5cLL)), ((u64)(0x7832edc82110c2f9LL)), | |
| 3259 | +((u64)(0x7867a93a2954f3b8LL)), ((u64)(0x789d9388b3aa30a5LL)), ((u64)(0x78d27c35704a5e67LL)), ((u64)(0x79071b42cc5cf601LL)), ((u64)(0x793ce2137f743382LL)), ((u64)(0x79720d4c2fa8a031LL)), ((u64)(0x79a6909f3b92c83dLL)), ((u64)(0x79dc34c70a777a4dLL)), ((u64)(0x7a11a0fc668aac70LL)), ((u64)(0x7a46093b802d578cLL)), ((u64)(0x7a7b8b8a6038ad6fLL)), ((u64)(0x7ab137367c236c65LL)), ((u64)(0x7ae585041b2c477fLL)), ((u64)(0x7b1ae64521f7595eLL)), ((u64)(0x7b50cfeb353a97dbLL)), ((u64)(0x7b8503e602893dd2LL)), | |
| 3260 | +((u64)(0x7bba44df832b8d46LL)), ((u64)(0x7bf06b0bb1fb384cLL)), ((u64)(0x7c2485ce9e7a065fLL)), ((u64)(0x7c59a742461887f6LL)), ((u64)(0x7c9008896bcf54faLL)), ((u64)(0x7cc40aabc6c32a38LL)), ((u64)(0x7cf90d56b873f4c7LL)), ((u64)(0x7d2f50ac6690f1f8LL)), ((u64)(0x7d63926bc01a973bLL)), ((u64)(0x7d987706b0213d0aLL)), ((u64)(0x7dce94c85c298c4cLL)), ((u64)(0x7e031cfd3999f7b0LL)), ((u64)(0x7e37e43c8800759cLL)), ((u64)(0x7e6ddd4baa009303LL)), ((u64)(0x7ea2aa4f4a405be2LL)), ((u64)(0x7ed754e31cd072daLL)), ((u64)(0x7f0d2a1be4048f90LL)), ((u64)(0x7f423a516e82d9baLL)), ((u64)(0x7f76c8e5ca239029LL)), ((u64)(0x7fac7b1f3cac7433LL)), ((u64)(0x7fe1ccf385ebc8a0LL))}; // fixed array const | |
| 3261 | +static Array_fixed_u64_324 _const_strconv__neg_exp = {((u64)(0x3ff0000000000000LL)), ((u64)(0x3fb999999999999aLL)), ((u64)(0x3f847ae147ae147bLL)), ((u64)(0x3f50624dd2f1a9fcLL)), ((u64)(0x3f1a36e2eb1c432dLL)), ((u64)(0x3ee4f8b588e368f1LL)), ((u64)(0x3eb0c6f7a0b5ed8dLL)), ((u64)(0x3e7ad7f29abcaf48LL)), ((u64)(0x3e45798ee2308c3aLL)), ((u64)(0x3e112e0be826d695LL)), ((u64)(0x3ddb7cdfd9d7bdbbLL)), ((u64)(0x3da5fd7fe1796495LL)), ((u64)(0x3d719799812dea11LL)), ((u64)(0x3d3c25c268497682LL)), ((u64)(0x3d06849b86a12b9bLL)), ((u64)(0x3cd203af9ee75616LL)), | |
| 3262 | +((u64)(0x3c9cd2b297d889bcLL)), ((u64)(0x3c670ef54646d497LL)), ((u64)(0x3c32725dd1d243acLL)), ((u64)(0x3bfd83c94fb6d2acLL)), ((u64)(0x3bc79ca10c924223LL)), ((u64)(0x3b92e3b40a0e9b4fLL)), ((u64)(0x3b5e392010175ee6LL)), ((u64)(0x3b282db34012b251LL)), ((u64)(0x3af357c299a88ea7LL)), ((u64)(0x3abef2d0f5da7dd9LL)), ((u64)(0x3a88c240c4aecb14LL)), ((u64)(0x3a53ce9a36f23c10LL)), ((u64)(0x3a1fb0f6be506019LL)), ((u64)(0x39e95a5efea6b347LL)), ((u64)(0x39b4484bfeebc2a0LL)), ((u64)(0x398039d665896880LL)), | |
| 3263 | +((u64)(0x3949f623d5a8a733LL)), ((u64)(0x3914c4e977ba1f5cLL)), ((u64)(0x38e09d8792fb4c49LL)), ((u64)(0x38aa95a5b7f87a0fLL)), ((u64)(0x38754484932d2e72LL)), ((u64)(0x3841039d428a8b8fLL)), ((u64)(0x380b38fb9daa78e4LL)), ((u64)(0x37d5c72fb1552d83LL)), ((u64)(0x37a16c262777579cLL)), ((u64)(0x376be03d0bf225c7LL)), ((u64)(0x37364cfda3281e39LL)), ((u64)(0x3701d7314f534b61LL)), ((u64)(0x36cc8b8218854567LL)), ((u64)(0x3696d601ad376ab9LL)), ((u64)(0x366244ce242c5561LL)), ((u64)(0x362d3ae36d13bbceLL)), | |
| 3264 | +((u64)(0x35f7624f8a762fd8LL)), ((u64)(0x35c2b50c6ec4f313LL)), ((u64)(0x358dee7a4ad4b81fLL)), ((u64)(0x3557f1fb6f10934cLL)), ((u64)(0x352327fc58da0f70LL)), ((u64)(0x34eea6608e29b24dLL)), ((u64)(0x34b8851a0b548ea4LL)), ((u64)(0x34839dae6f76d883LL)), ((u64)(0x344f62b0b257c0d2LL)), ((u64)(0x34191bc08eac9a41LL)), ((u64)(0x33e41633a556e1ceLL)), ((u64)(0x33b011c2eaabe7d8LL)), ((u64)(0x3379b604aaaca626LL)), ((u64)(0x3344919d5556eb52LL)), ((u64)(0x3310747ddddf22a8LL)), ((u64)(0x32da53fc9631d10dLL)), | |
| 3265 | +((u64)(0x32a50ffd44f4a73dLL)), ((u64)(0x3270d9976a5d5297LL)), ((u64)(0x323af5bf109550f2LL)), ((u64)(0x32059165a6ddda5bLL)), ((u64)(0x31d1411e1f17e1e3LL)), ((u64)(0x319b9b6364f30304LL)), ((u64)(0x316615e91d8f359dLL)), ((u64)(0x3131ab20e472914aLL)), ((u64)(0x30fc45016d841baaLL)), ((u64)(0x30c69d9abe034955LL)), ((u64)(0x309217aefe690777LL)), ((u64)(0x305cf2b1970e7258LL)), ((u64)(0x3027288e1271f513LL)), ((u64)(0x2ff286d80ec190dcLL)), ((u64)(0x2fbda48ce468e7c7LL)), ((u64)(0x2f87b6d71d20b96cLL)), | |
| 3266 | +((u64)(0x2f52f8ac174d6123LL)), ((u64)(0x2f1e5aacf2156838LL)), ((u64)(0x2ee8488a5b445360LL)), ((u64)(0x2eb36d3b7c36a91aLL)), ((u64)(0x2e7f152bf9f10e90LL)), ((u64)(0x2e48ddbcc7f40ba6LL)), ((u64)(0x2e13e497065cd61fLL)), ((u64)(0x2ddfd424d6faf031LL)), ((u64)(0x2da97683df2f268dLL)), ((u64)(0x2d745ecfe5bf520bLL)), ((u64)(0x2d404bd984990e6fLL)), ((u64)(0x2d0a12f5a0f4e3e5LL)), ((u64)(0x2cd4dbf7b3f71cb7LL)), ((u64)(0x2ca0aff95cc5b092LL)), ((u64)(0x2c6ab328946f80eaLL)), ((u64)(0x2c355c2076bf9a55LL)), | |
| 3267 | +((u64)(0x2c0116805effaeaaLL)), ((u64)(0x2bcb5733cb32b111LL)), ((u64)(0x2b95df5ca28ef40dLL)), ((u64)(0x2b617f7d4ed8c33eLL)), ((u64)(0x2b2bff2ee48e0530LL)), ((u64)(0x2af665bf1d3e6a8dLL)), ((u64)(0x2ac1eaff4a98553dLL)), ((u64)(0x2a8cab3210f3bb95LL)), ((u64)(0x2a56ef5b40c2fc77LL)), ((u64)(0x2a225915cd68c9f9LL)), ((u64)(0x29ed5b561574765bLL)), ((u64)(0x29b77c44ddf6c516LL)), ((u64)(0x2982c9d0b1923745LL)), ((u64)(0x294e0fb44f50586eLL)), ((u64)(0x29180c903f7379f2LL)), ((u64)(0x28e33d4032c2c7f5LL)), | |
| 3268 | +((u64)(0x28aec866b79e0cbaLL)), ((u64)(0x2878a0522c7e7095LL)), ((u64)(0x2843b374f06526deLL)), ((u64)(0x280f8587e7083e30LL)), ((u64)(0x27d9379fec069826LL)), ((u64)(0x27a42c7ff0054685LL)), ((u64)(0x277023998cd10537LL)), ((u64)(0x2739d28f47b4d525LL)), ((u64)(0x2704a8729fc3ddb7LL)), ((u64)(0x26d086c219697e2cLL)), ((u64)(0x269a71368f0f3047LL)), ((u64)(0x2665275ed8d8f36cLL)), ((u64)(0x2630ec4be0ad8f89LL)), ((u64)(0x25fb13ac9aaf4c0fLL)), ((u64)(0x25c5a956e225d672LL)), ((u64)(0x2591544581b7dec2LL)), | |
| 3269 | +((u64)(0x255bba08cf8c979dLL)), ((u64)(0x25262e6d72d6dfb0LL)), ((u64)(0x24f1bebdf578b2f4LL)), ((u64)(0x24bc6463225ab7ecLL)), ((u64)(0x2486b6b5b5155ff0LL)), ((u64)(0x24522bc490dde65aLL)), ((u64)(0x241d12d41afca3c3LL)), ((u64)(0x23e7424348ca1c9cLL)), ((u64)(0x23b29b69070816e3LL)), ((u64)(0x237dc574d80cf16bLL)), ((u64)(0x2347d12a4670c123LL)), ((u64)(0x23130dbb6b8d674fLL)), ((u64)(0x22de7c5f127bd87eLL)), ((u64)(0x22a8637f41fcad32LL)), ((u64)(0x227382cc34ca2428LL)), ((u64)(0x223f37ad21436d0cLL)), | |
| 3270 | +((u64)(0x2208f9574dcf8a70LL)), ((u64)(0x21d3faac3e3fa1f3LL)), ((u64)(0x219ff779fd329cb9LL)), ((u64)(0x216992c7fdc216faLL)), ((u64)(0x2134756ccb01abfbLL)), ((u64)(0x21005df0a267bcc9LL)), ((u64)(0x20ca2fe76a3f9475LL)), ((u64)(0x2094f31f8832dd2aLL)), ((u64)(0x2060c27fa028b0efLL)), ((u64)(0x202ad0cc33744e4bLL)), ((u64)(0x1ff573d68f903ea2LL)), ((u64)(0x1fc1297872d9cbb5LL)), ((u64)(0x1f8b758d848fac55LL)), ((u64)(0x1f55f7a46a0c89ddLL)), ((u64)(0x1f2192e9ee706e4bLL)), ((u64)(0x1eec1e43171a4a11LL)), | |
| 3271 | +((u64)(0x1eb67e9c127b6e74LL)), ((u64)(0x1e81fee341fc585dLL)), ((u64)(0x1e4ccb0536608d61LL)), ((u64)(0x1e1708d0f84d3de7LL)), ((u64)(0x1de26d73f9d764b9LL)), ((u64)(0x1dad7becc2f23ac2LL)), ((u64)(0x1d779657025b6235LL)), ((u64)(0x1d42deac01e2b4f7LL)), ((u64)(0x1d0e3113363787f2LL)), ((u64)(0x1cd8274291c6065bLL)), ((u64)(0x1ca3529ba7d19eafLL)), ((u64)(0x1c6eea92a61c3118LL)), ((u64)(0x1c38bba884e35a7aLL)), ((u64)(0x1c03c9539d82aec8LL)), ((u64)(0x1bcfa885c8d117a6LL)), ((u64)(0x1b99539e3a40dfb8LL)), | |
| 3272 | +((u64)(0x1b6442e4fb671960LL)), ((u64)(0x1b303583fc527ab3LL)), ((u64)(0x1af9ef3993b72ab8LL)), ((u64)(0x1ac4bf6142f8eefaLL)), ((u64)(0x1a90991a9bfa58c8LL)), ((u64)(0x1a5a8e90f9908e0dLL)), ((u64)(0x1a253eda614071a4LL)), ((u64)(0x19f0ff151a99f483LL)), ((u64)(0x19bb31bb5dc320d2LL)), ((u64)(0x1985c162b168e70eLL)), ((u64)(0x1951678227871f3eLL)), ((u64)(0x191bd8d03f3e9864LL)), ((u64)(0x18e6470cff6546b6LL)), ((u64)(0x18b1d270cc51055fLL)), ((u64)(0x187c83e7ad4e6efeLL)), ((u64)(0x1846cfec8aa52598LL)), | |
| 3273 | +((u64)(0x18123ff06eea847aLL)), ((u64)(0x17dd331a4b10d3f6LL)), ((u64)(0x17a75c1508da432bLL)), ((u64)(0x1772b010d3e1cf56LL)), ((u64)(0x173de6815302e556LL)), ((u64)(0x1707eb9aa8cf1ddeLL)), ((u64)(0x16d322e220a5b17eLL)), ((u64)(0x169e9e369aa2b597LL)), ((u64)(0x16687e92154ef7acLL)), ((u64)(0x16339874ddd8c623LL)), ((u64)(0x15ff5a549627a36cLL)), ((u64)(0x15c91510781fb5f0LL)), ((u64)(0x159410d9f9b2f7f3LL)), ((u64)(0x15600d7b2e28c65cLL)), ((u64)(0x1529af2b7d0e0a2dLL)), ((u64)(0x14f48c22ca71a1bdLL)), | |
| 3274 | +((u64)(0x14c0701bd527b498LL)), ((u64)(0x148a4cf9550c5426LL)), ((u64)(0x14550a6110d6a9b8LL)), ((u64)(0x1420d51a73deee2dLL)), ((u64)(0x13eaee90b964b047LL)), ((u64)(0x13b58ba6fab6f36cLL)), ((u64)(0x13813c85955f2923LL)), ((u64)(0x134b9408eefea839LL)), ((u64)(0x1316100725988694LL)), ((u64)(0x12e1a66c1e139eddLL)), ((u64)(0x12ac3d79c9b8fe2eLL)), ((u64)(0x12769794a160cb58LL)), ((u64)(0x124212dd4de70913LL)), ((u64)(0x120ceafbafd80e85LL)), ((u64)(0x11d72262f3133ed1LL)), ((u64)(0x11a281e8c275cbdaLL)), | |
| 3275 | +((u64)(0x116d9ca79d89462aLL)), ((u64)(0x1137b08617a104eeLL)), ((u64)(0x1102f39e794d9d8bLL)), ((u64)(0x10ce5297287c2f45LL)), ((u64)(0x1098421286c9bf6bLL)), ((u64)(0x1063680ed23aff89LL)), ((u64)(0x102f0ce4839198dbLL)), ((u64)(0x0ff8d71d360e13e2LL)), ((u64)(0x0fc3df4a91a4dcb5LL)), ((u64)(0x0f8fcbaa82a16121LL)), ((u64)(0x0f596fbb9bb44db4LL)), ((u64)(0x0f245962e2f6a490LL)), ((u64)(0x0ef047824f2bb6daLL)), ((u64)(0x0eba0c03b1df8af6LL)), ((u64)(0x0e84d6695b193bf8LL)), ((u64)(0x0e50ab877c142ffaLL)), | |
| 3276 | +((u64)(0x0e1aac0bf9b9e65cLL)), ((u64)(0x0de5566ffafb1eb0LL)), ((u64)(0x0db111f32f2f4bc0LL)), ((u64)(0x0d7b4feb7eb212cdLL)), ((u64)(0x0d45d98932280f0aLL)), ((u64)(0x0d117ad428200c08LL)), ((u64)(0x0cdbf7b9d9cce00dLL)), ((u64)(0x0ca65fc7e170b33eLL)), ((u64)(0x0c71e6398126f5cbLL)), ((u64)(0x0c3ca38f350b22dfLL)), ((u64)(0x0c06e93f5da2824cLL)), ((u64)(0x0bd25432b14ecea3LL)), ((u64)(0x0b9d53844ee47dd1LL)), ((u64)(0x0b677603725064a8LL)), ((u64)(0x0b32c4cf8ea6b6ecLL)), ((u64)(0x0afe07b27dd78b14LL)), | |
| 3277 | +((u64)(0x0ac8062864ac6f43LL)), ((u64)(0x0a9338205089f29cLL)), ((u64)(0x0a5ec033b40fea93LL)), ((u64)(0x0a2899c2f6732210LL)), ((u64)(0x09f3ae3591f5b4d9LL)), ((u64)(0x09bf7d228322baf5LL)), ((u64)(0x098930e868e89591LL)), ((u64)(0x0954272053ed4474LL)), ((u64)(0x09201f4d0ff10390LL)), ((u64)(0x08e9cbae7fe805b3LL)), ((u64)(0x08b4a2f1ffecd15cLL)), ((u64)(0x0880825b3323dab0LL)), ((u64)(0x084a6a2b85062ab3LL)), ((u64)(0x081521bc6a6b555cLL)), ((u64)(0x07e0e7c9eebc444aLL)), ((u64)(0x07ab0c764ac6d3a9LL)), | |
| 3278 | +((u64)(0x0775a391d56bdc87LL)), ((u64)(0x07414fa7ddefe3a0LL)), ((u64)(0x070bb2a62fe638ffLL)), ((u64)(0x06d62884f31e93ffLL)), ((u64)(0x06a1ba03f5b21000LL)), ((u64)(0x066c5cd322b67fffLL)), ((u64)(0x0636b0a8e891ffffLL)), ((u64)(0x060226ed86db3333LL)), ((u64)(0x05cd0b15a491eb84LL)), ((u64)(0x05973c115074bc6aLL)), ((u64)(0x05629674405d6388LL)), ((u64)(0x052dbd86cd6238d9LL)), ((u64)(0x04f7cad23de82d7bLL)), ((u64)(0x04c308a831868ac9LL)), ((u64)(0x048e74404f3daadbLL)), ((u64)(0x04585d003f6488afLL)), | |
| 3279 | +((u64)(0x04237d99cc506d59LL)), ((u64)(0x03ef2f5c7a1a488eLL)), ((u64)(0x03b8f2b061aea072LL)), ((u64)(0x0383f559e7bee6c1LL)), ((u64)(0x034feef63f97d79cLL)), ((u64)(0x03198bf832dfdfb0LL)), ((u64)(0x02e46ff9c24cb2f3LL)), ((u64)(0x02b059949b708f29LL)), ((u64)(0x027a28edc580e50eLL)), ((u64)(0x0244ed8b04671da5LL)), ((u64)(0x0210be08d0527e1dLL)), ((u64)(0x01dac9a7b3b7302fLL)), ((u64)(0x01a56e1fc2f8f359LL)), ((u64)(0x017124e63593f5e1LL)), ((u64)(0x013b6e3d22865634LL)), ((u64)(0x0105f1ca820511c3LL)), | |
| 3280 | +((u64)(0x00d18e3b9b374169LL)), ((u64)(0x009c16c5c5253575LL)), ((u64)(0x0066789e3750f791LL)), ((u64)(0x0031fa182c40c60dLL)), ((u64)(0x000730d67819e8d2LL)), ((u64)(0x0000b8157268fdafLL)), ((u64)(0x000012688b70e62bLL)), ((u64)(0x000001d74124e3d1LL)), ((u64)(0x0000002f201d49fbLL)), ((u64)(0x00000004b6695433LL)), ((u64)(0x0000000078a42205)), ((u64)(0x000000000c1069cd)), ((u64)(0x000000000134d761)), ((u64)(0x00000000001ee257)), ((u64)(0x00000000000316a2)), ((u64)(0x0000000000004f10)), ((u64)(0x00000000000007e8)), ((u64)(0x00000000000000ca)), ((u64)(0x0000000000000014)), ((u64)(0x0000000000000002))}; // fixed array const | |
| 3281 | +static i64 _const_strconv__i64_min_int32; // inited later | |
| 3282 | +static i64 _const_strconv__i64_max_int32; // inited later | |
| 3283 | +static Array_fixed_u32_10 _const_strconv__ten_pow_table_32 = {((u32)(1)), ((u32)(10)), ((u32)(100)), ((u32)(1000)), ((u32)(10000)), ((u32)(100000)), ((u32)(1000000)), ((u32)(10000000)), ((u32)(100000000)), ((u32)(1000000000))}; // fixed array const | |
| 3284 | +static const u32 _const_strconv__mantbits32 = 23; // precomputed2 | |
| 3285 | +static const u32 _const_strconv__expbits32 = 8; // precomputed2 | |
| 3286 | +static Array_fixed_u64_20 _const_strconv__ten_pow_table_64 = {((u64)(1)), ((u64)(10)), ((u64)(100)), ((u64)(1000)), ((u64)(10000)), ((u64)(100000)), ((u64)(1000000)), ((u64)(10000000)), ((u64)(100000000)), ((u64)(1000000000)), ((u64)(10000000000LL)), ((u64)(100000000000LL)), ((u64)(1000000000000LL)), ((u64)(10000000000000LL)), ((u64)(100000000000000LL)), ((u64)(1000000000000000LL)), ((u64)(10000000000000000LL)), ((u64)(100000000000000000LL)), ((u64)(1000000000000000000LL)), ((u64)(10000000000000000000ULL))}; // fixed array const | |
| 3287 | +static const u32 _const_strconv__mantbits64 = 52; // precomputed2 | |
| 3288 | +static const u32 _const_strconv__expbits64 = 11; // precomputed2 | |
| 3289 | +static Array_fixed_f64_36 _const_strconv__dec_round = {((f64)(0.5)), 0.05, 0.005, 0.0005, 0.00005, 0.000005, 0.0000005, 0.00000005, 0.000000005, 0.0000000005, 0.00000000005, 0.000000000005, 0.0000000000005, 0.00000000000005, 0.000000000000005, 0.0000000000000005, | |
| 3290 | +0.00000000000000005, 0.000000000000000005, 0.0000000000000000005, 0.00000000000000000005, 0.000000000000000000005, 0.0000000000000000000005, 0.00000000000000000000005, 0.000000000000000000000005, 0.0000000000000000000000005, 0.00000000000000000000000005, 0.000000000000000000000000005, 0.0000000000000000000000000005, 0.00000000000000000000000000005, 0.000000000000000000000000000005, 0.0000000000000000000000000000005, 0.00000000000000000000000000000005, 0.000000000000000000000000000000005, 0.0000000000000000000000000000000005, 0.00000000000000000000000000000000005, 0.000000000000000000000000000000000005}; // fixed array const | |
| 3291 | +static Array_fixed_u64_47 _const_strconv__pow5_split_32 = {((u64)(1152921504606846976LL)), ((u64)(1441151880758558720LL)), ((u64)(1801439850948198400LL)), ((u64)(2251799813685248000LL)), ((u64)(1407374883553280000LL)), ((u64)(1759218604441600000LL)), ((u64)(2199023255552000000LL)), ((u64)(1374389534720000000LL)), ((u64)(1717986918400000000LL)), ((u64)(2147483648000000000LL)), ((u64)(1342177280000000000LL)), ((u64)(1677721600000000000LL)), ((u64)(2097152000000000000LL)), ((u64)(1310720000000000000LL)), ((u64)(1638400000000000000LL)), ((u64)(2048000000000000000LL)), | |
| 3292 | +((u64)(1280000000000000000LL)), ((u64)(1600000000000000000LL)), ((u64)(2000000000000000000LL)), ((u64)(1250000000000000000LL)), ((u64)(1562500000000000000LL)), ((u64)(1953125000000000000LL)), ((u64)(1220703125000000000LL)), ((u64)(1525878906250000000LL)), ((u64)(1907348632812500000LL)), ((u64)(1192092895507812500LL)), ((u64)(1490116119384765625LL)), ((u64)(1862645149230957031LL)), ((u64)(1164153218269348144LL)), ((u64)(1455191522836685180LL)), ((u64)(1818989403545856475LL)), ((u64)(2273736754432320594LL)), | |
| 3293 | +((u64)(1421085471520200371LL)), ((u64)(1776356839400250464LL)), ((u64)(2220446049250313080LL)), ((u64)(1387778780781445675LL)), ((u64)(1734723475976807094LL)), ((u64)(2168404344971008868LL)), ((u64)(1355252715606880542LL)), ((u64)(1694065894508600678LL)), ((u64)(2117582368135750847LL)), ((u64)(1323488980084844279LL)), ((u64)(1654361225106055349LL)), ((u64)(2067951531382569187LL)), ((u64)(1292469707114105741LL)), ((u64)(1615587133892632177LL)), ((u64)(2019483917365790221LL))}; // fixed array const | |
| 3294 | +static Array_fixed_u64_31 _const_strconv__pow5_inv_split_32 = {((u64)(576460752303423489LL)), ((u64)(461168601842738791LL)), ((u64)(368934881474191033LL)), ((u64)(295147905179352826LL)), ((u64)(472236648286964522LL)), ((u64)(377789318629571618LL)), ((u64)(302231454903657294LL)), ((u64)(483570327845851670LL)), ((u64)(386856262276681336LL)), ((u64)(309485009821345069LL)), ((u64)(495176015714152110LL)), ((u64)(396140812571321688LL)), ((u64)(316912650057057351LL)), ((u64)(507060240091291761LL)), ((u64)(405648192073033409LL)), ((u64)(324518553658426727LL)), | |
| 3295 | +((u64)(519229685853482763LL)), ((u64)(415383748682786211LL)), ((u64)(332306998946228969LL)), ((u64)(531691198313966350LL)), ((u64)(425352958651173080LL)), ((u64)(340282366920938464LL)), ((u64)(544451787073501542LL)), ((u64)(435561429658801234LL)), ((u64)(348449143727040987LL)), ((u64)(557518629963265579LL)), ((u64)(446014903970612463LL)), ((u64)(356811923176489971LL)), ((u64)(570899077082383953LL)), ((u64)(456719261665907162LL)), ((u64)(365375409332725730LL))}; // fixed array const | |
| 3296 | +static Array_fixed_u64_652 _const_strconv__pow5_split_64_x = {((u64)(0x0000000000000000)), ((u64)(0x0100000000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x0140000000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x0190000000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01f4000000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x0138800000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x0186a00000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01e8480000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01312d0000000000LL)), | |
| 3297 | +((u64)(0x0000000000000000)), ((u64)(0x017d784000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01dcd65000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x012a05f200000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x0174876e80000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01d1a94a20000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x012309ce54000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x016bcc41e9000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01c6bf5263400000LL)), | |
| 3298 | +((u64)(0x0000000000000000)), ((u64)(0x011c37937e080000LL)), ((u64)(0x0000000000000000)), ((u64)(0x016345785d8a0000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01bc16d674ec8000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01158e460913d000LL)), ((u64)(0x0000000000000000)), ((u64)(0x015af1d78b58c400LL)), ((u64)(0x0000000000000000)), ((u64)(0x01b1ae4d6e2ef500LL)), ((u64)(0x0000000000000000)), ((u64)(0x010f0cf064dd5920LL)), ((u64)(0x0000000000000000)), ((u64)(0x0152d02c7e14af68LL)), | |
| 3299 | +((u64)(0x0000000000000000)), ((u64)(0x01a784379d99db42LL)), ((u64)(0x4000000000000000LL)), ((u64)(0x0108b2a2c2802909LL)), ((u64)(0x9000000000000000ULL)), ((u64)(0x014adf4b7320334bLL)), ((u64)(0x7400000000000000LL)), ((u64)(0x019d971e4fe8401eLL)), ((u64)(0x0880000000000000LL)), ((u64)(0x01027e72f1f12813LL)), ((u64)(0xcaa0000000000000ULL)), ((u64)(0x01431e0fae6d7217LL)), ((u64)(0xbd48000000000000ULL)), ((u64)(0x0193e5939a08ce9dLL)), ((u64)(0x2c9a000000000000LL)), ((u64)(0x01f8def8808b0245LL)), | |
| 3300 | +((u64)(0x3be0400000000000LL)), ((u64)(0x013b8b5b5056e16bLL)), ((u64)(0x0ad8500000000000LL)), ((u64)(0x018a6e32246c99c6LL)), ((u64)(0x8d8e640000000000ULL)), ((u64)(0x01ed09bead87c037LL)), ((u64)(0xb878fe8000000000ULL)), ((u64)(0x013426172c74d822LL)), ((u64)(0x66973e2000000000LL)), ((u64)(0x01812f9cf7920e2bLL)), ((u64)(0x403d0da800000000LL)), ((u64)(0x01e17b84357691b6LL)), ((u64)(0xe826288900000000ULL)), ((u64)(0x012ced32a16a1b11LL)), ((u64)(0x622fb2ab40000000LL)), ((u64)(0x0178287f49c4a1d6LL)), | |
| 3301 | +((u64)(0xfabb9f5610000000ULL)), ((u64)(0x01d6329f1c35ca4bLL)), ((u64)(0x7cb54395ca000000LL)), ((u64)(0x0125dfa371a19e6fLL)), ((u64)(0x5be2947b3c800000LL)), ((u64)(0x016f578c4e0a060bLL)), ((u64)(0x32db399a0ba00000LL)), ((u64)(0x01cb2d6f618c878eLL)), ((u64)(0xdfc9040047440000ULL)), ((u64)(0x011efc659cf7d4b8LL)), ((u64)(0x17bb450059150000LL)), ((u64)(0x0166bb7f0435c9e7LL)), ((u64)(0xddaa16406f5a4000ULL)), ((u64)(0x01c06a5ec5433c60LL)), ((u64)(0x8a8a4de845986800ULL)), ((u64)(0x0118427b3b4a05bcLL)), | |
| 3302 | +((u64)(0xad2ce16256fe8200ULL)), ((u64)(0x015e531a0a1c872bLL)), ((u64)(0x987819baecbe2280ULL)), ((u64)(0x01b5e7e08ca3a8f6LL)), ((u64)(0x1f4b1014d3f6d590LL)), ((u64)(0x0111b0ec57e6499aLL)), ((u64)(0xa71dd41a08f48af4ULL)), ((u64)(0x01561d276ddfdc00LL)), ((u64)(0xd0e549208b31adb1ULL)), ((u64)(0x01aba4714957d300LL)), ((u64)(0x828f4db456ff0c8eULL)), ((u64)(0x010b46c6cdd6e3e0LL)), ((u64)(0xa33321216cbecfb2ULL)), ((u64)(0x014e1878814c9cd8LL)), ((u64)(0xcbffe969c7ee839eULL)), ((u64)(0x01a19e96a19fc40eLL)), | |
| 3303 | +((u64)(0x3f7ff1e21cf51243LL)), ((u64)(0x0105031e2503da89LL)), ((u64)(0x8f5fee5aa43256d4ULL)), ((u64)(0x014643e5ae44d12bLL)), ((u64)(0x7337e9f14d3eec89LL)), ((u64)(0x0197d4df19d60576LL)), ((u64)(0x1005e46da08ea7abLL)), ((u64)(0x01fdca16e04b86d4LL)), ((u64)(0x8a03aec4845928cbULL)), ((u64)(0x013e9e4e4c2f3444LL)), ((u64)(0xac849a75a56f72fdULL)), ((u64)(0x018e45e1df3b0155LL)), ((u64)(0x17a5c1130ecb4fbdLL)), ((u64)(0x01f1d75a5709c1abLL)), ((u64)(0xeec798abe93f11d6ULL)), ((u64)(0x013726987666190aLL)), | |
| 3304 | +((u64)(0xaa797ed6e38ed64bULL)), ((u64)(0x0184f03e93ff9f4dLL)), ((u64)(0x1517de8c9c728bdeLL)), ((u64)(0x01e62c4e38ff8721LL)), ((u64)(0xad2eeb17e1c7976bULL)), ((u64)(0x012fdbb0e39fb474LL)), ((u64)(0xd87aa5ddda397d46ULL)), ((u64)(0x017bd29d1c87a191LL)), ((u64)(0x4e994f5550c7dc97LL)), ((u64)(0x01dac74463a989f6LL)), ((u64)(0xf11fd195527ce9deULL)), ((u64)(0x0128bc8abe49f639LL)), ((u64)(0x6d67c5faa71c2456LL)), ((u64)(0x0172ebad6ddc73c8LL)), ((u64)(0x88c1b77950e32d6cULL)), ((u64)(0x01cfa698c95390baLL)), | |
| 3305 | +((u64)(0x957912abd28dfc63ULL)), ((u64)(0x0121c81f7dd43a74LL)), ((u64)(0xbad75756c7317b7cULL)), ((u64)(0x016a3a275d494911LL)), ((u64)(0x298d2d2c78fdda5bLL)), ((u64)(0x01c4c8b1349b9b56LL)), ((u64)(0xd9f83c3bcb9ea879ULL)), ((u64)(0x011afd6ec0e14115LL)), ((u64)(0x50764b4abe865297LL)), ((u64)(0x0161bcca7119915bLL)), ((u64)(0x2493de1d6e27e73dLL)), ((u64)(0x01ba2bfd0d5ff5b2LL)), ((u64)(0x56dc6ad264d8f086LL)), ((u64)(0x01145b7e285bf98fLL)), ((u64)(0x2c938586fe0f2ca8LL)), ((u64)(0x0159725db272f7f3LL)), | |
| 3306 | +((u64)(0xf7b866e8bd92f7d2ULL)), ((u64)(0x01afcef51f0fb5efLL)), ((u64)(0xfad34051767bdae3ULL)), ((u64)(0x010de1593369d1b5LL)), ((u64)(0x79881065d41ad19cLL)), ((u64)(0x015159af80444623LL)), ((u64)(0x57ea147f49218603LL)), ((u64)(0x01a5b01b605557acLL)), ((u64)(0xb6f24ccf8db4f3c1ULL)), ((u64)(0x01078e111c3556cbLL)), ((u64)(0xa4aee003712230b2ULL)), ((u64)(0x014971956342ac7eLL)), ((u64)(0x4dda98044d6abcdfLL)), ((u64)(0x019bcdfabc13579eLL)), ((u64)(0xf0a89f02b062b60bULL)), ((u64)(0x010160bcb58c16c2LL)), | |
| 3307 | +((u64)(0xacd2c6c35c7b638eULL)), ((u64)(0x0141b8ebe2ef1c73LL)), ((u64)(0x98077874339a3c71ULL)), ((u64)(0x01922726dbaae390LL)), ((u64)(0xbe0956914080cb8eULL)), ((u64)(0x01f6b0f092959c74LL)), ((u64)(0xf6c5d61ac8507f38ULL)), ((u64)(0x013a2e965b9d81c8LL)), ((u64)(0x34774ba17a649f07LL)), ((u64)(0x0188ba3bf284e23bLL)), ((u64)(0x01951e89d8fdc6c8LL)), ((u64)(0x01eae8caef261acaLL)), ((u64)(0x40fd3316279e9c3dLL)), ((u64)(0x0132d17ed577d0beLL)), ((u64)(0xd13c7fdbb186434cULL)), ((u64)(0x017f85de8ad5c4edLL)), | |
| 3308 | +((u64)(0x458b9fd29de7d420LL)), ((u64)(0x01df67562d8b3629LL)), ((u64)(0xcb7743e3a2b0e494ULL)), ((u64)(0x012ba095dc7701d9LL)), ((u64)(0x3e5514dc8b5d1db9LL)), ((u64)(0x017688bb5394c250LL)), ((u64)(0x4dea5a13ae346527LL)), ((u64)(0x01d42aea2879f2e4LL)), ((u64)(0xb0b2784c4ce0bf38ULL)), ((u64)(0x01249ad2594c37ceLL)), ((u64)(0x5cdf165f6018ef06LL)), ((u64)(0x016dc186ef9f45c2LL)), ((u64)(0xf416dbf7381f2ac8ULL)), ((u64)(0x01c931e8ab871732LL)), ((u64)(0xd88e497a83137abdULL)), ((u64)(0x011dbf316b346e7fLL)), | |
| 3309 | +((u64)(0xceb1dbd923d8596cULL)), ((u64)(0x01652efdc6018a1fLL)), ((u64)(0xc25e52cf6cce6fc7ULL)), ((u64)(0x01be7abd3781eca7LL)), ((u64)(0xd97af3c1a40105dcULL)), ((u64)(0x01170cb642b133e8LL)), ((u64)(0x0fd9b0b20d014754LL)), ((u64)(0x015ccfe3d35d80e3LL)), ((u64)(0xd3d01cde90419929ULL)), ((u64)(0x01b403dcc834e11bLL)), ((u64)(0x6462120b1a28ffb9LL)), ((u64)(0x01108269fd210cb1LL)), ((u64)(0xbd7a968de0b33fa8ULL)), ((u64)(0x0154a3047c694fddLL)), ((u64)(0x2cd93c3158e00f92LL)), ((u64)(0x01a9cbc59b83a3d5LL)), | |
| 3310 | +((u64)(0x3c07c59ed78c09bbLL)), ((u64)(0x010a1f5b81324665LL)), ((u64)(0x8b09b7068d6f0c2aULL)), ((u64)(0x014ca732617ed7feLL)), ((u64)(0x2dcc24c830cacf34LL)), ((u64)(0x019fd0fef9de8dfeLL)), ((u64)(0xdc9f96fd1e7ec180ULL)), ((u64)(0x0103e29f5c2b18beLL)), ((u64)(0x93c77cbc661e71e1ULL)), ((u64)(0x0144db473335deeeLL)), ((u64)(0x38b95beb7fa60e59LL)), ((u64)(0x01961219000356aaLL)), ((u64)(0xc6e7b2e65f8f91efULL)), ((u64)(0x01fb969f40042c54LL)), ((u64)(0xfc50cfcffbb9bb35ULL)), ((u64)(0x013d3e2388029bb4LL)), | |
| 3311 | +((u64)(0x3b6503c3faa82a03LL)), ((u64)(0x018c8dac6a0342a2LL)), ((u64)(0xca3e44b4f9523484ULL)), ((u64)(0x01efb1178484134aLL)), ((u64)(0xbe66eaf11bd360d2ULL)), ((u64)(0x0135ceaeb2d28c0eLL)), ((u64)(0x6e00a5ad62c83907LL)), ((u64)(0x0183425a5f872f12LL)), ((u64)(0x0980cf18bb7a4749LL)), ((u64)(0x01e412f0f768fad7LL)), ((u64)(0x65f0816f752c6c8dLL)), ((u64)(0x012e8bd69aa19cc6LL)), ((u64)(0xff6ca1cb527787b1ULL)), ((u64)(0x017a2ecc414a03f7LL)), ((u64)(0xff47ca3e2715699dULL)), ((u64)(0x01d8ba7f519c84f5LL)), | |
| 3312 | +((u64)(0xbf8cde66d86d6202ULL)), ((u64)(0x0127748f9301d319LL)), ((u64)(0x2f7016008e88ba83LL)), ((u64)(0x017151b377c247e0LL)), ((u64)(0x3b4c1b80b22ae923LL)), ((u64)(0x01cda62055b2d9d8LL)), ((u64)(0x250f91306f5ad1b6LL)), ((u64)(0x012087d4358fc827LL)), ((u64)(0xee53757c8b318623ULL)), ((u64)(0x0168a9c942f3ba30LL)), ((u64)(0x29e852dbadfde7acLL)), ((u64)(0x01c2d43b93b0a8bdLL)), ((u64)(0x3a3133c94cbeb0ccLL)), ((u64)(0x0119c4a53c4e6976LL)), ((u64)(0xc8bd80bb9fee5cffULL)), ((u64)(0x016035ce8b6203d3LL)), | |
| 3313 | +((u64)(0xbaece0ea87e9f43eULL)), ((u64)(0x01b843422e3a84c8LL)), ((u64)(0x74d40c9294f238a7LL)), ((u64)(0x01132a095ce492fdLL)), ((u64)(0xd2090fb73a2ec6d1ULL)), ((u64)(0x0157f48bb41db7bcLL)), ((u64)(0x068b53a508ba7885LL)), ((u64)(0x01adf1aea12525acLL)), ((u64)(0x8417144725748b53ULL)), ((u64)(0x010cb70d24b7378bLL)), ((u64)(0x651cd958eed1ae28LL)), ((u64)(0x014fe4d06de5056eLL)), ((u64)(0xfe640faf2a8619b2ULL)), ((u64)(0x01a3de04895e46c9LL)), ((u64)(0x3efe89cd7a93d00fLL)), ((u64)(0x01066ac2d5daec3eLL)), | |
| 3314 | +((u64)(0xcebe2c40d938c413ULL)), ((u64)(0x014805738b51a74dLL)), ((u64)(0x426db7510f86f518LL)), ((u64)(0x019a06d06e261121LL)), ((u64)(0xc9849292a9b4592fULL)), ((u64)(0x0100444244d7cab4LL)), ((u64)(0xfbe5b73754216f7aULL)), ((u64)(0x01405552d60dbd61LL)), ((u64)(0x7adf25052929cb59LL)), ((u64)(0x01906aa78b912cbaLL)), ((u64)(0x1996ee4673743e2fLL)), ((u64)(0x01f485516e7577e9LL)), ((u64)(0xaffe54ec0828a6ddULL)), ((u64)(0x0138d352e5096af1LL)), ((u64)(0x1bfdea270a32d095LL)), ((u64)(0x018708279e4bc5aeLL)), | |
| 3315 | +((u64)(0xa2fd64b0ccbf84baULL)), ((u64)(0x01e8ca3185deb719LL)), ((u64)(0x05de5eee7ff7b2f4LL)), ((u64)(0x01317e5ef3ab3270LL)), ((u64)(0x0755f6aa1ff59fb1LL)), ((u64)(0x017dddf6b095ff0cLL)), ((u64)(0x092b7454a7f3079eLL)), ((u64)(0x01dd55745cbb7ecfLL)), ((u64)(0x65bb28b4e8f7e4c3LL)), ((u64)(0x012a5568b9f52f41LL)), ((u64)(0xbf29f2e22335ddf3ULL)), ((u64)(0x0174eac2e8727b11LL)), ((u64)(0x2ef46f9aac035570LL)), ((u64)(0x01d22573a28f19d6LL)), ((u64)(0xdd58c5c0ab821566ULL)), ((u64)(0x0123576845997025LL)), | |
| 3316 | +((u64)(0x54aef730d6629ac0LL)), ((u64)(0x016c2d4256ffcc2fLL)), ((u64)(0x29dab4fd0bfb4170LL)), ((u64)(0x01c73892ecbfbf3bLL)), ((u64)(0xfa28b11e277d08e6ULL)), ((u64)(0x011c835bd3f7d784LL)), ((u64)(0x38b2dd65b15c4b1fLL)), ((u64)(0x0163a432c8f5cd66LL)), ((u64)(0xc6df94bf1db35de7ULL)), ((u64)(0x01bc8d3f7b3340bfLL)), ((u64)(0xdc4bbcf772901ab0ULL)), ((u64)(0x0115d847ad000877LL)), ((u64)(0xd35eac354f34215cULL)), ((u64)(0x015b4e5998400a95LL)), ((u64)(0x48365742a30129b4LL)), ((u64)(0x01b221effe500d3bLL)), | |
| 3317 | +((u64)(0x0d21f689a5e0ba10LL)), ((u64)(0x010f5535fef20845LL)), ((u64)(0x506a742c0f58e894LL)), ((u64)(0x01532a837eae8a56LL)), ((u64)(0xe4851137132f22b9ULL)), ((u64)(0x01a7f5245e5a2cebLL)), ((u64)(0x6ed32ac26bfd75b4LL)), ((u64)(0x0108f936baf85c13LL)), ((u64)(0x4a87f57306fcd321LL)), ((u64)(0x014b378469b67318LL)), ((u64)(0x5d29f2cfc8bc07e9LL)), ((u64)(0x019e056584240fdeLL)), ((u64)(0xfa3a37c1dd7584f1ULL)), ((u64)(0x0102c35f729689eaLL)), ((u64)(0xb8c8c5b254d2e62eULL)), ((u64)(0x014374374f3c2c65LL)), | |
| 3318 | +((u64)(0x26faf71eea079fb9LL)), ((u64)(0x01945145230b377fLL)), ((u64)(0xf0b9b4e6a48987a8ULL)), ((u64)(0x01f965966bce055eLL)), ((u64)(0x5674111026d5f4c9LL)), ((u64)(0x013bdf7e0360c35bLL)), ((u64)(0x2c111554308b71fbLL)), ((u64)(0x018ad75d8438f432LL)), ((u64)(0xb7155aa93cae4e7aULL)), ((u64)(0x01ed8d34e547313eLL)), ((u64)(0x326d58a9c5ecf10cLL)), ((u64)(0x013478410f4c7ec7LL)), ((u64)(0xff08aed437682d4fULL)), ((u64)(0x01819651531f9e78LL)), ((u64)(0x3ecada89454238a3LL)), ((u64)(0x01e1fbe5a7e78617LL)), | |
| 3319 | +((u64)(0x873ec895cb496366ULL)), ((u64)(0x012d3d6f88f0b3ceLL)), ((u64)(0x290e7abb3e1bbc3fLL)), ((u64)(0x01788ccb6b2ce0c2LL)), ((u64)(0xb352196a0da2ab4fULL)), ((u64)(0x01d6affe45f818f2LL)), ((u64)(0xb0134fe24885ab11ULL)), ((u64)(0x01262dfeebbb0f97LL)), ((u64)(0x9c1823dadaa715d6ULL)), ((u64)(0x016fb97ea6a9d37dLL)), ((u64)(0x031e2cd19150db4bLL)), ((u64)(0x01cba7de5054485dLL)), ((u64)(0x21f2dc02fad2890fLL)), ((u64)(0x011f48eaf234ad3aLL)), ((u64)(0xaa6f9303b9872b53ULL)), ((u64)(0x01671b25aec1d888LL)), | |
| 3320 | +((u64)(0xd50b77c4a7e8f628ULL)), ((u64)(0x01c0e1ef1a724eaaLL)), ((u64)(0xc5272adae8f199d9ULL)), ((u64)(0x01188d357087712aLL)), ((u64)(0x7670f591a32e004fLL)), ((u64)(0x015eb082cca94d75LL)), ((u64)(0xd40d32f60bf98063ULL)), ((u64)(0x01b65ca37fd3a0d2LL)), ((u64)(0xc4883fd9c77bf03eULL)), ((u64)(0x0111f9e62fe44483LL)), ((u64)(0xb5aa4fd0395aec4dULL)), ((u64)(0x0156785fbbdd55a4LL)), ((u64)(0xe314e3c447b1a760ULL)), ((u64)(0x01ac1677aad4ab0dLL)), ((u64)(0xaded0e5aaccf089cULL)), ((u64)(0x010b8e0acac4eae8LL)), | |
| 3321 | +((u64)(0xd96851f15802cac3ULL)), ((u64)(0x014e718d7d7625a2LL)), ((u64)(0x8fc2666dae037d74ULL)), ((u64)(0x01a20df0dcd3af0bLL)), ((u64)(0x39d980048cc22e68LL)), ((u64)(0x010548b68a044d67LL)), ((u64)(0x084fe005aff2ba03LL)), ((u64)(0x01469ae42c8560c1LL)), ((u64)(0x4a63d8071bef6883LL)), ((u64)(0x0198419d37a6b8f1LL)), ((u64)(0x9cfcce08e2eb42a4ULL)), ((u64)(0x01fe52048590672dLL)), ((u64)(0x821e00c58dd309a7ULL)), ((u64)(0x013ef342d37a407cLL)), ((u64)(0xa2a580f6f147cc10ULL)), ((u64)(0x018eb0138858d09bLL)), | |
| 3322 | +((u64)(0x8b4ee134ad99bf15ULL)), ((u64)(0x01f25c186a6f04c2LL)), ((u64)(0x97114cc0ec80176dULL)), ((u64)(0x0137798f428562f9LL)), ((u64)(0xfcd59ff127a01d48ULL)), ((u64)(0x018557f31326bbb7LL)), ((u64)(0xfc0b07ed7188249aULL)), ((u64)(0x01e6adefd7f06aa5LL)), ((u64)(0xbd86e4f466f516e0ULL)), ((u64)(0x01302cb5e6f642a7LL)), ((u64)(0xace89e3180b25c98ULL)), ((u64)(0x017c37e360b3d351LL)), ((u64)(0x1822c5bde0def3beLL)), ((u64)(0x01db45dc38e0c826LL)), ((u64)(0xcf15bb96ac8b5857ULL)), ((u64)(0x01290ba9a38c7d17LL)), | |
| 3323 | +((u64)(0xc2db2a7c57ae2e6dULL)), ((u64)(0x01734e940c6f9c5dLL)), ((u64)(0x3391f51b6d99ba08LL)), ((u64)(0x01d022390f8b8375LL)), ((u64)(0x403b393124801445LL)), ((u64)(0x01221563a9b73229LL)), ((u64)(0x904a077d6da01956ULL)), ((u64)(0x016a9abc9424feb3LL)), ((u64)(0x745c895cc9081facLL)), ((u64)(0x01c5416bb92e3e60LL)), ((u64)(0x48b9d5d9fda513cbLL)), ((u64)(0x011b48e353bce6fcLL)), ((u64)(0x5ae84b507d0e58beLL)), ((u64)(0x01621b1c28ac20bbLL)), ((u64)(0x31a25e249c51eeeeLL)), ((u64)(0x01baa1e332d728eaLL)), | |
| 3324 | +((u64)(0x5f057ad6e1b33554LL)), ((u64)(0x0114a52dffc67992LL)), ((u64)(0xf6c6d98c9a2002aaULL)), ((u64)(0x0159ce797fb817f6LL)), ((u64)(0xb4788fefc0a80354ULL)), ((u64)(0x01b04217dfa61df4LL)), ((u64)(0xf0cb59f5d8690214ULL)), ((u64)(0x010e294eebc7d2b8LL)), ((u64)(0x2cfe30734e83429aLL)), ((u64)(0x0151b3a2a6b9c767LL)), ((u64)(0xf83dbc9022241340ULL)), ((u64)(0x01a6208b50683940LL)), ((u64)(0x9b2695da15568c08ULL)), ((u64)(0x0107d457124123c8LL)), ((u64)(0xc1f03b509aac2f0aULL)), ((u64)(0x0149c96cd6d16cbaLL)), | |
| 3325 | +((u64)(0x726c4a24c1573acdLL)), ((u64)(0x019c3bc80c85c7e9LL)), ((u64)(0xe783ae56f8d684c0ULL)), ((u64)(0x0101a55d07d39cf1LL)), ((u64)(0x616499ecb70c25f0LL)), ((u64)(0x01420eb449c8842eLL)), ((u64)(0xf9bdc067e4cf2f6cULL)), ((u64)(0x019292615c3aa539LL)), ((u64)(0x782d3081de02fb47LL)), ((u64)(0x01f736f9b3494e88LL)), ((u64)(0x4b1c3e512ac1dd0cLL)), ((u64)(0x013a825c100dd115LL)), ((u64)(0x9de34de57572544fULL)), ((u64)(0x018922f31411455aLL)), ((u64)(0x455c215ed2cee963LL)), ((u64)(0x01eb6bafd91596b1LL)), | |
| 3326 | +((u64)(0xcb5994db43c151deULL)), ((u64)(0x0133234de7ad7e2eLL)), ((u64)(0x7e2ffa1214b1a655LL)), ((u64)(0x017fec216198ddbaLL)), ((u64)(0x1dbbf89699de0febLL)), ((u64)(0x01dfe729b9ff1529LL)), ((u64)(0xb2957b5e202ac9f3ULL)), ((u64)(0x012bf07a143f6d39LL)), ((u64)(0x1f3ada35a8357c6fLL)), ((u64)(0x0176ec98994f4888LL)), ((u64)(0x270990c31242db8bLL)), ((u64)(0x01d4a7bebfa31aaaLL)), ((u64)(0x5865fa79eb69c937LL)), ((u64)(0x0124e8d737c5f0aaLL)), ((u64)(0xee7f791866443b85ULL)), ((u64)(0x016e230d05b76cd4LL)), | |
| 3327 | +((u64)(0x2a1f575e7fd54a66LL)), ((u64)(0x01c9abd04725480aLL)), ((u64)(0x5a53969b0fe54e80LL)), ((u64)(0x011e0b622c774d06LL)), ((u64)(0xf0e87c41d3dea220ULL)), ((u64)(0x01658e3ab7952047LL)), ((u64)(0xed229b5248d64aa8ULL)), ((u64)(0x01bef1c9657a6859LL)), ((u64)(0x3435a1136d85eea9LL)), ((u64)(0x0117571ddf6c8138LL)), ((u64)(0x4143095848e76a53LL)), ((u64)(0x015d2ce55747a186LL)), ((u64)(0xd193cbae5b2144e8ULL)), ((u64)(0x01b4781ead1989e7LL)), ((u64)(0xe2fc5f4cf8f4cb11ULL)), ((u64)(0x0110cb132c2ff630LL)), | |
| 3328 | +((u64)(0x1bbb77203731fdd5LL)), ((u64)(0x0154fdd7f73bf3bdLL)), ((u64)(0x62aa54e844fe7d4aLL)), ((u64)(0x01aa3d4df50af0acLL)), ((u64)(0xbdaa75112b1f0e4eULL)), ((u64)(0x010a6650b926d66bLL)), ((u64)(0xad15125575e6d1e2ULL)), ((u64)(0x014cffe4e7708c06LL)), ((u64)(0x585a56ead360865bLL)), ((u64)(0x01a03fde214caf08LL)), ((u64)(0x37387652c41c53f8LL)), ((u64)(0x010427ead4cfed65LL)), ((u64)(0x850693e7752368f7ULL)), ((u64)(0x014531e58a03e8beLL)), ((u64)(0x264838e1526c4334LL)), ((u64)(0x01967e5eec84e2eeLL)), | |
| 3329 | +((u64)(0xafda4719a7075402ULL)), ((u64)(0x01fc1df6a7a61ba9LL)), ((u64)(0x0de86c7008649481LL)), ((u64)(0x013d92ba28c7d14aLL)), ((u64)(0x9162878c0a7db9a1ULL)), ((u64)(0x018cf768b2f9c59cLL)), ((u64)(0xb5bb296f0d1d280aULL)), ((u64)(0x01f03542dfb83703LL)), ((u64)(0x5194f9e568323906LL)), ((u64)(0x01362149cbd32262LL)), ((u64)(0xe5fa385ec23ec747ULL)), ((u64)(0x0183a99c3ec7eafaLL)), ((u64)(0x9f78c67672ce7919ULL)), ((u64)(0x01e494034e79e5b9LL)), ((u64)(0x03ab7c0a07c10bb0LL)), ((u64)(0x012edc82110c2f94LL)), | |
| 3330 | +((u64)(0x04965b0c89b14e9cLL)), ((u64)(0x017a93a2954f3b79LL)), ((u64)(0x45bbf1cfac1da243LL)), ((u64)(0x01d9388b3aa30a57LL)), ((u64)(0x8b957721cb92856aULL)), ((u64)(0x0127c35704a5e676LL)), ((u64)(0x2e7ad4ea3e7726c4LL)), ((u64)(0x0171b42cc5cf6014LL)), ((u64)(0x3a198a24ce14f075LL)), ((u64)(0x01ce2137f7433819LL)), ((u64)(0xc44ff65700cd1649ULL)), ((u64)(0x0120d4c2fa8a030fLL)), ((u64)(0xb563f3ecc1005bdbULL)), ((u64)(0x016909f3b92c83d3LL)), ((u64)(0xa2bcf0e7f14072d2ULL)), ((u64)(0x01c34c70a777a4c8LL)), | |
| 3331 | +((u64)(0x65b61690f6c847c3LL)), ((u64)(0x011a0fc668aac6fdLL)), ((u64)(0xbf239c35347a59b4ULL)), ((u64)(0x016093b802d578bcLL)), ((u64)(0xeeec83428198f021ULL)), ((u64)(0x01b8b8a6038ad6ebLL)), ((u64)(0x7553d20990ff9615LL)), ((u64)(0x01137367c236c653LL)), ((u64)(0x52a8c68bf53f7b9aLL)), ((u64)(0x01585041b2c477e8LL)), ((u64)(0x6752f82ef28f5a81LL)), ((u64)(0x01ae64521f7595e2LL)), ((u64)(0x8093db1d57999890ULL)), ((u64)(0x010cfeb353a97dadLL)), ((u64)(0xe0b8d1e4ad7ffeb4ULL)), ((u64)(0x01503e602893dd18LL)), | |
| 3332 | +((u64)(0x18e7065dd8dffe62LL)), ((u64)(0x01a44df832b8d45fLL)), ((u64)(0x6f9063faa78bfefdLL)), ((u64)(0x0106b0bb1fb384bbLL)), ((u64)(0x4b747cf9516efebcLL)), ((u64)(0x01485ce9e7a065eaLL)), ((u64)(0xde519c37a5cabe6bULL)), ((u64)(0x019a742461887f64LL)), ((u64)(0x0af301a2c79eb703LL)), ((u64)(0x01008896bcf54f9fLL)), ((u64)(0xcdafc20b798664c4ULL)), ((u64)(0x0140aabc6c32a386LL)), ((u64)(0x811bb28e57e7fdf5ULL)), ((u64)(0x0190d56b873f4c68LL)), ((u64)(0xa1629f31ede1fd72ULL)), ((u64)(0x01f50ac6690f1f82LL)), | |
| 3333 | +((u64)(0xa4dda37f34ad3e67ULL)), ((u64)(0x013926bc01a973b1LL)), ((u64)(0x0e150c5f01d88e01LL)), ((u64)(0x0187706b0213d09eLL)), ((u64)(0x919a4f76c24eb181ULL)), ((u64)(0x01e94c85c298c4c5LL)), ((u64)(0x7b0071aa39712ef1LL)), ((u64)(0x0131cfd3999f7afbLL)), ((u64)(0x59c08e14c7cd7aadLL)), ((u64)(0x017e43c8800759baLL)), ((u64)(0xf030b199f9c0d958ULL)), ((u64)(0x01ddd4baa0093028LL)), ((u64)(0x961e6f003c1887d7ULL)), ((u64)(0x012aa4f4a405be19LL)), ((u64)(0xfba60ac04b1ea9cdULL)), ((u64)(0x01754e31cd072d9fLL)), | |
| 3334 | +((u64)(0xfa8f8d705de65440ULL)), ((u64)(0x01d2a1be4048f907LL)), ((u64)(0xfc99b8663aaff4a8ULL)), ((u64)(0x0123a516e82d9ba4LL)), ((u64)(0x3bc0267fc95bf1d2LL)), ((u64)(0x016c8e5ca239028eLL)), ((u64)(0xcab0301fbbb2ee47ULL)), ((u64)(0x01c7b1f3cac74331LL)), ((u64)(0x1eae1e13d54fd4ecLL)), ((u64)(0x011ccf385ebc89ffLL)), ((u64)(0xe659a598caa3ca27ULL)), ((u64)(0x01640306766bac7eLL)), ((u64)(0x9ff00efefd4cbcb1ULL)), ((u64)(0x01bd03c81406979eLL)), ((u64)(0x23f6095f5e4ff5efLL)), ((u64)(0x0116225d0c841ec3LL)), | |
| 3335 | +((u64)(0xecf38bb735e3f36aULL)), ((u64)(0x015baaf44fa52673LL)), ((u64)(0xe8306ea5035cf045ULL)), ((u64)(0x01b295b1638e7010LL)), ((u64)(0x911e4527221a162bULL)), ((u64)(0x010f9d8ede39060aLL)), ((u64)(0x3565d670eaa09bb6LL)), ((u64)(0x015384f295c7478dLL)), ((u64)(0x82bf4c0d2548c2a3ULL)), ((u64)(0x01a8662f3b391970LL)), ((u64)(0x51b78f88374d79a6LL)), ((u64)(0x01093fdd8503afe6LL)), ((u64)(0xe625736a4520d810ULL)), ((u64)(0x014b8fd4e6449bdfLL)), ((u64)(0xdfaed044d6690e14ULL)), ((u64)(0x019e73ca1fd5c2d7LL)), ((u64)(0xebcd422b0601a8ccULL)), ((u64)(0x0103085e53e599c6LL)), ((u64)(0xa6c092b5c78212ffULL)), ((u64)(0x0143ca75e8df0038LL)), ((u64)(0xd070b763396297bfULL)), ((u64)(0x0194bd136316c046LL)), ((u64)(0x848ce53c07bb3dafULL)), ((u64)(0x01f9ec583bdc7058LL)), ((u64)(0x52d80f4584d5068dLL)), ((u64)(0x013c33b72569c637LL)), ((u64)(0x278e1316e60a4831LL)), ((u64)(0x018b40a4eec437c5LL))}; // fixed array const | |
| 3336 | +static Array_fixed_u64_584 _const_strconv__pow5_inv_split_64_x = {((u64)(0x0000000000000001)), ((u64)(0x0400000000000000LL)), ((u64)(0x3333333333333334LL)), ((u64)(0x0333333333333333LL)), ((u64)(0x28f5c28f5c28f5c3LL)), ((u64)(0x028f5c28f5c28f5cLL)), ((u64)(0xed916872b020c49cULL)), ((u64)(0x020c49ba5e353f7cLL)), ((u64)(0xaf4f0d844d013a93ULL)), ((u64)(0x0346dc5d63886594LL)), ((u64)(0x8c3f3e0370cdc876ULL)), ((u64)(0x029f16b11c6d1e10LL)), ((u64)(0xd698fe69270b06c5ULL)), ((u64)(0x0218def416bdb1a6LL)), ((u64)(0xf0f4ca41d811a46eULL)), ((u64)(0x035afe535795e90aLL)), | |
| 3337 | +((u64)(0xf3f70834acdae9f1ULL)), ((u64)(0x02af31dc4611873bLL)), ((u64)(0x5cc5a02a23e254c1LL)), ((u64)(0x0225c17d04dad296LL)), ((u64)(0xfad5cd10396a2135ULL)), ((u64)(0x036f9bfb3af7b756LL)), ((u64)(0xfbde3da69454e75eULL)), ((u64)(0x02bfaffc2f2c92abLL)), ((u64)(0x2fe4fe1edd10b918LL)), ((u64)(0x0232f33025bd4223LL)), ((u64)(0x4ca19697c81ac1bfLL)), ((u64)(0x0384b84d092ed038LL)), ((u64)(0x3d4e1213067bce33LL)), ((u64)(0x02d09370d4257360LL)), ((u64)(0x643e74dc052fd829LL)), ((u64)(0x024075f3dceac2b3LL)), | |
| 3338 | +((u64)(0x6d30baf9a1e626a7LL)), ((u64)(0x039a5652fb113785LL)), ((u64)(0x2426fbfae7eb5220LL)), ((u64)(0x02e1dea8c8da92d1LL)), ((u64)(0x1cebfcc8b9890e80LL)), ((u64)(0x024e4bba3a487574LL)), ((u64)(0x94acc7a78f41b0ccULL)), ((u64)(0x03b07929f6da5586LL)), ((u64)(0xaa23d2ec729af3d7ULL)), ((u64)(0x02f394219248446bLL)), ((u64)(0xbb4fdbf05baf2979ULL)), ((u64)(0x025c768141d369efLL)), ((u64)(0xc54c931a2c4b758dULL)), ((u64)(0x03c7240202ebdcb2LL)), ((u64)(0x9dd6dc14f03c5e0bULL)), ((u64)(0x0305b66802564a28LL)), | |
| 3339 | +((u64)(0x4b1249aa59c9e4d6LL)), ((u64)(0x026af8533511d4edLL)), ((u64)(0x44ea0f76f60fd489LL)), ((u64)(0x03de5a1ebb4fbb15LL)), ((u64)(0x6a54d92bf80caa07LL)), ((u64)(0x0318481895d96277LL)), ((u64)(0x21dd7a89933d54d2LL)), ((u64)(0x0279d346de4781f9LL)), ((u64)(0x362f2a75b8622150LL)), ((u64)(0x03f61ed7ca0c0328LL)), ((u64)(0xf825bb91604e810dULL)), ((u64)(0x032b4bdfd4d668ecLL)), ((u64)(0xc684960de6a5340bULL)), ((u64)(0x0289097fdd7853f0LL)), ((u64)(0xd203ab3e521dc33cULL)), ((u64)(0x02073accb12d0ff3LL)), | |
| 3340 | +((u64)(0xe99f7863b696052cULL)), ((u64)(0x033ec47ab514e652LL)), ((u64)(0x87b2c6b62bab3757ULL)), ((u64)(0x02989d2ef743eb75LL)), ((u64)(0xd2f56bc4efbc2c45ULL)), ((u64)(0x0213b0f25f69892aLL)), ((u64)(0x1e55793b192d13a2LL)), ((u64)(0x0352b4b6ff0f41deLL)), ((u64)(0x4b77942f475742e8LL)), ((u64)(0x02a8909265a5ce4bLL)), ((u64)(0xd5f9435905df68baULL)), ((u64)(0x022073a8515171d5LL)), ((u64)(0x565b9ef4d6324129LL)), ((u64)(0x03671f73b54f1c89LL)), ((u64)(0xdeafb25d78283421ULL)), ((u64)(0x02b8e5f62aa5b06dLL)), | |
| 3341 | +((u64)(0x188c8eb12cecf681LL)), ((u64)(0x022d84c4eeeaf38bLL)), ((u64)(0x8dadb11b7b14bd9bULL)), ((u64)(0x037c07a17e44b8deLL)), ((u64)(0x7157c0e2c8dd647cLL)), ((u64)(0x02c99fb46503c718LL)), ((u64)(0x8ddfcd823a4ab6caULL)), ((u64)(0x023ae629ea696c13LL)), ((u64)(0x1632e269f6ddf142LL)), ((u64)(0x0391704310a8acecLL)), ((u64)(0x44f581ee5f17f435LL)), ((u64)(0x02dac035a6ed5723LL)), ((u64)(0x372ace584c1329c4LL)), ((u64)(0x024899c4858aac1cLL)), ((u64)(0xbeaae3c079b842d3ULL)), ((u64)(0x03a75c6da27779c6LL)), | |
| 3342 | +((u64)(0x6555830061603576LL)), ((u64)(0x02ec49f14ec5fb05LL)), ((u64)(0xb7779c004de6912bULL)), ((u64)(0x0256a18dd89e626aLL)), ((u64)(0xf258f99a163db512ULL)), ((u64)(0x03bdcf495a9703ddLL)), ((u64)(0x5b7a614811caf741LL)), ((u64)(0x02fe3f6de212697eLL)), ((u64)(0xaf951aa00e3bf901ULL)), ((u64)(0x0264ff8b1b41edfeLL)), ((u64)(0x7f54f7667d2cc19bLL)), ((u64)(0x03d4cc11c5364997LL)), ((u64)(0x32aa5f8530f09ae3LL)), ((u64)(0x0310a3416a91d479LL)), ((u64)(0xf55519375a5a1582ULL)), ((u64)(0x0273b5cdeedb1060LL)), | |
| 3343 | +((u64)(0xbbbb5b8bc3c3559dULL)), ((u64)(0x03ec56164af81a34LL)), ((u64)(0x2fc916096969114aLL)), ((u64)(0x03237811d593482aLL)), ((u64)(0x596dab3ababa743cLL)), ((u64)(0x0282c674aadc39bbLL)), ((u64)(0x478aef622efb9030LL)), ((u64)(0x0202385d557cfafcLL)), ((u64)(0xd8de4bd04b2c19e6ULL)), ((u64)(0x0336c0955594c4c6LL)), ((u64)(0xad7ea30d08f014b8ULL)), ((u64)(0x029233aaaadd6a38LL)), ((u64)(0x24654f3da0c01093LL)), ((u64)(0x020e8fbbbbe454faLL)), ((u64)(0x3a3bb1fc346680ebLL)), ((u64)(0x034a7f92c63a2190LL)), | |
| 3344 | +((u64)(0x94fc8e635d1ecd89ULL)), ((u64)(0x02a1ffa89e94e7a6LL)), ((u64)(0xaa63a51c4a7f0ad4ULL)), ((u64)(0x021b32ed4baa52ebLL)), ((u64)(0xdd6c3b607731aaedULL)), ((u64)(0x035eb7e212aa1e45LL)), ((u64)(0x1789c919f8f488bdLL)), ((u64)(0x02b22cb4dbbb4b6bLL)), ((u64)(0xac6e3a7b2d906d64ULL)), ((u64)(0x022823c3e2fc3c55LL)), ((u64)(0x13e390c515b3e23aLL)), ((u64)(0x03736c6c9e606089LL)), ((u64)(0xdcb60d6a77c31b62ULL)), ((u64)(0x02c2bd23b1e6b3a0LL)), ((u64)(0x7d5e7121f968e2b5LL)), ((u64)(0x0235641c8e52294dLL)), | |
| 3345 | +((u64)(0xc8971b698f0e3787ULL)), ((u64)(0x0388a02db0837548LL)), ((u64)(0xa078e2bad8d82c6cULL)), ((u64)(0x02d3b357c0692aa0LL)), ((u64)(0xe6c71bc8ad79bd24ULL)), ((u64)(0x0242f5dfcd20eee6LL)), ((u64)(0x0ad82c7448c2c839LL)), ((u64)(0x039e5632e1ce4b0bLL)), ((u64)(0x3be023903a356cfaLL)), ((u64)(0x02e511c24e3ea26fLL)), ((u64)(0x2fe682d9c82abd95LL)), ((u64)(0x0250db01d8321b8cLL)), ((u64)(0x4ca4048fa6aac8eeLL)), ((u64)(0x03b4919c8d1cf8e0LL)), ((u64)(0x3d5003a61eef0725LL)), ((u64)(0x02f6dae3a4172d80LL)), | |
| 3346 | +((u64)(0x9773361e7f259f51ULL)), ((u64)(0x025f1582e9ac2466LL)), ((u64)(0x8beb89ca6508fee8ULL)), ((u64)(0x03cb559e42ad070aLL)), ((u64)(0x6fefa16eb73a6586LL)), ((u64)(0x0309114b688a6c08LL)), ((u64)(0xf3261abef8fb846bULL)), ((u64)(0x026da76f86d52339LL)), ((u64)(0x51d691318e5f3a45LL)), ((u64)(0x03e2a57f3e21d1f6LL)), ((u64)(0x0e4540f471e5c837LL)), ((u64)(0x031bb798fe8174c5LL)), ((u64)(0xd8376729f4b7d360ULL)), ((u64)(0x027c92e0cb9ac3d0LL)), ((u64)(0xf38bd84321261effULL)), ((u64)(0x03fa849adf5e061aLL)), | |
| 3347 | +((u64)(0x293cad0280eb4bffLL)), ((u64)(0x032ed07be5e4d1afLL)), ((u64)(0xedca240200bc3cccULL)), ((u64)(0x028bd9fcb7ea4158LL)), ((u64)(0xbe3b50019a3030a4ULL)), ((u64)(0x02097b309321cde0LL)), ((u64)(0xc9f88002904d1a9fULL)), ((u64)(0x03425eb41e9c7c9aLL)), ((u64)(0x3b2d3335403daee6LL)), ((u64)(0x029b7ef67ee396e2LL)), ((u64)(0x95bdc291003158b8ULL)), ((u64)(0x0215ff2b98b6124eLL)), ((u64)(0x892f9db4cd1bc126ULL)), ((u64)(0x035665128df01d4aLL)), ((u64)(0x07594af70a7c9a85LL)), ((u64)(0x02ab840ed7f34aa2LL)), | |
| 3348 | +((u64)(0x6c476f2c0863aed1LL)), ((u64)(0x0222d00bdff5d54eLL)), ((u64)(0x13a57eacda3917b4LL)), ((u64)(0x036ae67966562217LL)), ((u64)(0x0fb7988a482dac90LL)), ((u64)(0x02bbeb9451de81acLL)), ((u64)(0xd95fad3b6cf156daULL)), ((u64)(0x022fefa9db1867bcLL)), ((u64)(0xf565e1f8ae4ef15cULL)), ((u64)(0x037fe5dc91c0a5faLL)), ((u64)(0x911e4e608b725ab0ULL)), ((u64)(0x02ccb7e3a7cd5195LL)), ((u64)(0xda7ea51a0928488dULL)), ((u64)(0x023d5fe9530aa7aaLL)), ((u64)(0xf7310829a8407415ULL)), ((u64)(0x039566421e7772aaLL)), | |
| 3349 | +((u64)(0x2c2739baed005cdeLL)), ((u64)(0x02ddeb68185f8eefLL)), ((u64)(0xbcec2e2f24004a4bULL)), ((u64)(0x024b22b9ad193f25LL)), ((u64)(0x94ad16b1d333aa11ULL)), ((u64)(0x03ab6ac2ae8ecb6fLL)), ((u64)(0xaa241227dc2954dbULL)), ((u64)(0x02ef889bbed8a2bfLL)), ((u64)(0x54e9a81fe35443e2LL)), ((u64)(0x02593a163246e899LL)), ((u64)(0x2175d9cc9eed396aLL)), ((u64)(0x03c1f689ea0b0dc2LL)), ((u64)(0xe7917b0a18bdc788ULL)), ((u64)(0x03019207ee6f3e34LL)), ((u64)(0xb9412f3b46fe393aULL)), ((u64)(0x0267a8065858fe90LL)), | |
| 3350 | +((u64)(0xf535185ed7fd285cULL)), ((u64)(0x03d90cd6f3c1974dLL)), ((u64)(0xc42a79e57997537dULL)), ((u64)(0x03140a458fce12a4LL)), ((u64)(0x03552e512e12a931LL)), ((u64)(0x02766e9e0ca4dbb7LL)), ((u64)(0x9eeeb081e3510eb4ULL)), ((u64)(0x03f0b0fce107c5f1LL)), ((u64)(0x4bf226ce4f740bc3LL)), ((u64)(0x0326f3fd80d304c1LL)), ((u64)(0xa3281f0b72c33c9cULL)), ((u64)(0x02858ffe00a8d09aLL)), ((u64)(0x1c2018d5f568fd4aLL)), ((u64)(0x020473319a20a6e2LL)), ((u64)(0xf9ccf48988a7fba9ULL)), ((u64)(0x033a51e8f69aa49cLL)), | |
| 3351 | +((u64)(0xfb0a5d3ad3b99621ULL)), ((u64)(0x02950e53f87bb6e3LL)), ((u64)(0x2f3b7dc8a96144e7LL)), ((u64)(0x0210d8432d2fc583LL)), ((u64)(0xe52bfc7442353b0cULL)), ((u64)(0x034e26d1e1e608d1LL)), ((u64)(0xb756639034f76270ULL)), ((u64)(0x02a4ebdb1b1e6d74LL)), ((u64)(0x2c451c735d92b526LL)), ((u64)(0x021d897c15b1f12aLL)), ((u64)(0x13a1c71efc1deea3LL)), ((u64)(0x0362759355e981ddLL)), ((u64)(0x761b05b2634b2550LL)), ((u64)(0x02b52adc44bace4aLL)), ((u64)(0x91af37c1e908eaa6ULL)), ((u64)(0x022a88b036fbd83bLL)), | |
| 3352 | +((u64)(0x82b1f2cfdb417770ULL)), ((u64)(0x03774119f192f392LL)), ((u64)(0xcef4c23fe29ac5f3ULL)), ((u64)(0x02c5cdae5adbf60eLL)), ((u64)(0x3f2a34ffe87bd190LL)), ((u64)(0x0237d7beaf165e72LL)), ((u64)(0x984387ffda5fb5b2ULL)), ((u64)(0x038c8c644b56fd83LL)), ((u64)(0xe0360666484c915bULL)), ((u64)(0x02d6d6b6a2abfe02LL)), ((u64)(0x802b3851d3707449ULL)), ((u64)(0x024578921bbccb35LL)), ((u64)(0x99dec082ebe72075ULL)), ((u64)(0x03a25a835f947855LL)), ((u64)(0xae4bcd358985b391ULL)), ((u64)(0x02e8486919439377LL)), | |
| 3353 | +((u64)(0xbea30a913ad15c74ULL)), ((u64)(0x02536d20e102dc5fLL)), ((u64)(0xfdd1aa81f7b560b9ULL)), ((u64)(0x03b8ae9b019e2d65LL)), ((u64)(0x97daeece5fc44d61ULL)), ((u64)(0x02fa2548ce182451LL)), ((u64)(0xdfe258a51969d781ULL)), ((u64)(0x0261b76d71ace9daLL)), ((u64)(0x996a276e8f0fbf34ULL)), ((u64)(0x03cf8be24f7b0fc4LL)), ((u64)(0xe121b9253f3fcc2aULL)), ((u64)(0x030c6fe83f95a636LL)), ((u64)(0xb41afa8432997022ULL)), ((u64)(0x02705986994484f8LL)), ((u64)(0xecf7f739ea8f19cfULL)), ((u64)(0x03e6f5a4286da18dLL)), | |
| 3354 | +((u64)(0x23f99294bba5ae40LL)), ((u64)(0x031f2ae9b9f14e0bLL)), ((u64)(0x4ffadbaa2fb7be99LL)), ((u64)(0x027f5587c7f43e6fLL)), ((u64)(0x7ff7c5dd1925fdc2LL)), ((u64)(0x03feef3fa6539718LL)), ((u64)(0xccc637e4141e649bULL)), ((u64)(0x033258ffb842df46LL)), ((u64)(0xd704f983434b83afULL)), ((u64)(0x028ead9960357f6bLL)), ((u64)(0x126a6135cf6f9c8cLL)), ((u64)(0x020bbe144cf79923LL)), ((u64)(0x83dd685618b29414ULL)), ((u64)(0x0345fced47f28e9eLL)), ((u64)(0x9cb12044e08edcddULL)), ((u64)(0x029e63f1065ba54bLL)), | |
| 3355 | +((u64)(0x16f419d0b3a57d7dLL)), ((u64)(0x02184ff405161dd6LL)), ((u64)(0x8b20294dec3bfbfbULL)), ((u64)(0x035a19866e89c956LL)), ((u64)(0x3c19baa4bcfcc996LL)), ((u64)(0x02ae7ad1f207d445LL)), ((u64)(0xc9ae2eea30ca3adfULL)), ((u64)(0x02252f0e5b39769dLL)), ((u64)(0x0f7d17dd1add2afdLL)), ((u64)(0x036eb1b091f58a96LL)), ((u64)(0x3f97464a7be42264LL)), ((u64)(0x02bef48d41913babLL)), ((u64)(0xcc790508631ce850ULL)), ((u64)(0x02325d3dce0dc955LL)), ((u64)(0xe0c1a1a704fb0d4dULL)), ((u64)(0x0383c862e3494222LL)), | |
| 3356 | +((u64)(0x4d67b4859d95a43eLL)), ((u64)(0x02cfd3824f6dce82LL)), ((u64)(0x711fc39e17aae9cbLL)), ((u64)(0x023fdc683f8b0b9bLL)), ((u64)(0xe832d2968c44a945ULL)), ((u64)(0x039960a6cc11ac2bLL)), ((u64)(0xecf575453d03ba9eULL)), ((u64)(0x02e11a1f09a7bcefLL)), ((u64)(0x572ac4376402fbb1LL)), ((u64)(0x024dae7f3aec9726LL)), ((u64)(0x58446d256cd192b5LL)), ((u64)(0x03af7d985e47583dLL)), ((u64)(0x79d0575123dadbc4LL)), ((u64)(0x02f2cae04b6c4697LL)), ((u64)(0x94a6ac40e97be303ULL)), ((u64)(0x025bd5803c569edfLL)), | |
| 3357 | +((u64)(0x8771139b0f2c9e6cULL)), ((u64)(0x03c62266c6f0fe32LL)), ((u64)(0x9f8da948d8f07ebdULL)), ((u64)(0x0304e85238c0cb5bLL)), ((u64)(0xe60aedd3e0c06564ULL)), ((u64)(0x026a5374fa33d5e2LL)), ((u64)(0xa344afb9679a3bd2ULL)), ((u64)(0x03dd5254c3862304LL)), ((u64)(0xe903bfc78614fca8ULL)), ((u64)(0x031775109c6b4f36LL)), ((u64)(0xba6966393810ca20ULL)), ((u64)(0x02792a73b055d8f8LL)), ((u64)(0x2a423d2859b4769aLL)), ((u64)(0x03f510b91a22f4c1LL)), ((u64)(0xee9b642047c39215ULL)), ((u64)(0x032a73c7481bf700LL)), | |
| 3358 | +((u64)(0xbee2b680396941aaULL)), ((u64)(0x02885c9f6ce32c00LL)), ((u64)(0xff1bc53361210155ULL)), ((u64)(0x0206b07f8a4f5666LL)), ((u64)(0x31c6085235019bbbLL)), ((u64)(0x033de73276e5570bLL)), ((u64)(0x27d1a041c4014963LL)), ((u64)(0x0297ec285f1ddf3cLL)), ((u64)(0xeca7b367d0010782ULL)), ((u64)(0x021323537f4b18fcLL)), ((u64)(0xadd91f0c8001a59dULL)), ((u64)(0x0351d21f3211c194LL)), ((u64)(0xf17a7f3d3334847eULL)), ((u64)(0x02a7db4c280e3476LL)), ((u64)(0x279532975c2a0398LL)), ((u64)(0x021fe2a3533e905fLL)), | |
| 3359 | +((u64)(0xd8eeb75893766c26ULL)), ((u64)(0x0366376bb8641a31LL)), ((u64)(0x7a5892ad42c52352LL)), ((u64)(0x02b82c562d1ce1c1LL)), ((u64)(0xfb7a0ef102374f75ULL)), ((u64)(0x022cf044f0e3e7cdLL)), ((u64)(0xc59017e8038bb254ULL)), ((u64)(0x037b1a07e7d30c7cLL)), ((u64)(0x37a67986693c8eaaLL)), ((u64)(0x02c8e19feca8d6caLL)), ((u64)(0xf951fad1edca0bbbULL)), ((u64)(0x023a4e198a20abd4LL)), ((u64)(0x28832ae97c76792bLL)), ((u64)(0x03907cf5a9cddfbbLL)), ((u64)(0x2068ef21305ec756LL)), ((u64)(0x02d9fd9154a4b2fcLL)), | |
| 3360 | +((u64)(0x19ed8c1a8d189f78LL)), ((u64)(0x0247fe0ddd508f30LL)), ((u64)(0x5caf4690e1c0ff26LL)), ((u64)(0x03a66349621a7eb3LL)), ((u64)(0x4a25d20d81673285LL)), ((u64)(0x02eb82a11b48655cLL)), ((u64)(0x3b5174d79ab8f537LL)), ((u64)(0x0256021a7c39eab0LL)), ((u64)(0x921bee25c45b21f1ULL)), ((u64)(0x03bcd02a605caab3LL)), ((u64)(0xdb498b5169e2818eULL)), ((u64)(0x02fd735519e3bbc2LL)), ((u64)(0x15d46f7454b53472LL)), ((u64)(0x02645c4414b62fcfLL)), ((u64)(0xefba4bed545520b6ULL)), ((u64)(0x03d3c6d35456b2e4LL)), | |
| 3361 | +((u64)(0xf2fb6ff110441a2bULL)), ((u64)(0x030fd242a9def583LL)), ((u64)(0x8f2f8cc0d9d014efULL)), ((u64)(0x02730e9bbb18c469LL)), ((u64)(0xb1e5ae015c80217fULL)), ((u64)(0x03eb4a92c4f46d75LL)), ((u64)(0xc1848b344a001accULL)), ((u64)(0x0322a20f03f6bdf7LL)), ((u64)(0xce03a2903b3348a3ULL)), ((u64)(0x02821b3f365efe5fLL)), ((u64)(0xd802e873628f6d4fULL)), ((u64)(0x0201af65c518cb7fLL)), ((u64)(0x599e40b89db2487fLL)), ((u64)(0x0335e56fa1c14599LL)), ((u64)(0xe14b66fa17c1d399ULL)), ((u64)(0x029184594e3437adLL)), | |
| 3362 | +((u64)(0x81091f2e7967dc7aULL)), ((u64)(0x020e037aa4f692f1LL)), ((u64)(0x9b41cb7d8f0c93f6ULL)), ((u64)(0x03499f2aa18a84b5LL)), ((u64)(0xaf67d5fe0c0a0ff8ULL)), ((u64)(0x02a14c221ad536f7LL)), ((u64)(0xf2b977fe70080cc7ULL)), ((u64)(0x021aa34e7bddc592LL)), ((u64)(0x1df58cca4cd9ae0bLL)), ((u64)(0x035dd2172c9608ebLL)), ((u64)(0xe4c470a1d7148b3cULL)), ((u64)(0x02b174df56de6d88LL)), ((u64)(0x83d05a1b1276d5caULL)), ((u64)(0x022790b2abe5246dLL)), ((u64)(0x9fb3c35e83f1560fULL)), ((u64)(0x0372811ddfd50715LL)), | |
| 3363 | +((u64)(0xb2f635e5365aab3fULL)), ((u64)(0x02c200e4b310d277LL)), ((u64)(0xf591c4b75eaeef66ULL)), ((u64)(0x0234cd83c273db92LL)), ((u64)(0xef4fa125644b18a3ULL)), ((u64)(0x0387af39371fc5b7LL)), ((u64)(0x8c3fb41de9d5ad4fULL)), ((u64)(0x02d2f2942c196af9LL)), ((u64)(0x3cffc34b2177bdd9LL)), ((u64)(0x02425ba9bce12261LL)), ((u64)(0x94cc6bab68bf9628ULL)), ((u64)(0x039d5f75fb01d09bLL)), ((u64)(0x10a38955ed6611b9LL)), ((u64)(0x02e44c5e6267da16LL)), ((u64)(0xda1c6dde5784dafbULL)), ((u64)(0x02503d184eb97b44LL)), | |
| 3364 | +((u64)(0xf693e2fd58d49191ULL)), ((u64)(0x03b394f3b128c53aLL)), ((u64)(0xc5431bfde0aa0e0eULL)), ((u64)(0x02f610c2f4209dc8LL)), ((u64)(0x6a9c1664b3bb3e72LL)), ((u64)(0x025e73cf29b3b16dLL)), ((u64)(0x10f9bd6dec5eca4fLL)), ((u64)(0x03ca52e50f85e8afLL)), ((u64)(0xda616457f04bd50cULL)), ((u64)(0x03084250d937ed58LL)), ((u64)(0xe1e783798d09773dULL)), ((u64)(0x026d01da475ff113LL)), ((u64)(0x030c058f480f252eLL)), ((u64)(0x03e19c9072331b53LL)), ((u64)(0x68d66ad906728425LL)), ((u64)(0x031ae3a6c1c27c42LL)), | |
| 3365 | +((u64)(0x8711ef14052869b7ULL)), ((u64)(0x027be952349b969bLL)), ((u64)(0x0b4fe4ecd50d75f2LL)), ((u64)(0x03f97550542c242cLL)), ((u64)(0xa2a650bd773df7f5ULL)), ((u64)(0x032df7737689b689LL)), ((u64)(0xb551da312c31932aULL)), ((u64)(0x028b2c5c5ed49207LL)), ((u64)(0x5ddb14f4235adc22LL)), ((u64)(0x0208f049e576db39LL)), ((u64)(0x2fc4ee536bc49369LL)), ((u64)(0x034180763bf15ec2LL)), ((u64)(0xbfd0bea92303a921ULL)), ((u64)(0x029acd2b63277f01LL)), ((u64)(0x9973cbba8269541aULL)), ((u64)(0x021570ef8285ff34LL)), | |
| 3366 | +((u64)(0x5bec792a6a42202aLL)), ((u64)(0x0355817f373ccb87LL)), ((u64)(0xe3239421ee9b4cefULL)), ((u64)(0x02aacdff5f63d605LL)), ((u64)(0xb5b6101b25490a59ULL)), ((u64)(0x02223e65e5e97804LL)), ((u64)(0x22bce691d541aa27LL)), ((u64)(0x0369fd6fd64259a1LL)), ((u64)(0xb563eba7ddce21b9ULL)), ((u64)(0x02bb31264501e14dLL)), ((u64)(0xf78322ecb171b494ULL)), ((u64)(0x022f5a850401810aLL)), ((u64)(0x259e9e47824f8753LL)), ((u64)(0x037ef73b399c01abLL)), ((u64)(0x1e187e9f9b72d2a9LL)), ((u64)(0x02cbf8fc2e1667bcLL)), | |
| 3367 | +((u64)(0x4b46cbb2e2c24221LL)), ((u64)(0x023cc73024deb963LL)), ((u64)(0x120adf849e039d01LL)), ((u64)(0x039471e6a1645bd2LL)), ((u64)(0xdb3be603b19c7d9aULL)), ((u64)(0x02dd27ebb4504974LL)), ((u64)(0x7c2feb3627b0647cLL)), ((u64)(0x024a865629d9d45dLL)), ((u64)(0x2d197856a5e7072cLL)), ((u64)(0x03aa7089dc8fba2fLL)), ((u64)(0x8a7ac6abb7ec05bdULL)), ((u64)(0x02eec06e4a0c94f2LL)), ((u64)(0xd52f05562cbcd164ULL)), ((u64)(0x025899f1d4d6dd8eLL)), ((u64)(0x21e4d556adfae8a0LL)), ((u64)(0x03c0f64fbaf1627eLL)), | |
| 3368 | +((u64)(0xe7ea444557fbed4dULL)), ((u64)(0x0300c50c958de864LL)), ((u64)(0xecbb69d1132ff10aULL)), ((u64)(0x0267040a113e5383LL)), ((u64)(0xadf8a94e851981aaULL)), ((u64)(0x03d8067681fd526cLL)), ((u64)(0x8b2d543ed0e13488ULL)), ((u64)(0x0313385ece6441f0LL)), ((u64)(0xd5bddcff0d80f6d3ULL)), ((u64)(0x0275c6b23eb69b26LL)), ((u64)(0x892fc7fe7c018aebULL)), ((u64)(0x03efa45064575ea4LL)), ((u64)(0x3a8c9ffec99ad589LL)), ((u64)(0x03261d0d1d12b21dLL)), ((u64)(0xc8707fff07af113bULL)), ((u64)(0x0284e40a7da88e7dLL)), | |
| 3369 | +((u64)(0x39f39998d2f2742fLL)), ((u64)(0x0203e9a1fe2071feLL)), ((u64)(0x8fec28f484b7204bULL)), ((u64)(0x033975cffd00b663LL)), ((u64)(0xd989ba5d36f8e6a2ULL)), ((u64)(0x02945e3ffd9a2b82LL)), ((u64)(0x47a161e42bfa521cLL)), ((u64)(0x02104b66647b5602LL)), ((u64)(0x0c35696d132a1cf9LL)), ((u64)(0x034d4570a0c5566aLL)), ((u64)(0x09c454574288172dLL)), ((u64)(0x02a4378d4d6aab88LL)), ((u64)(0xa169dd129ba0128bULL)), ((u64)(0x021cf93dd7888939LL)), ((u64)(0x0242fb50f9001dabLL)), ((u64)(0x03618ec958da7529LL)), | |
| 3370 | +((u64)(0x9b68c90d940017bcULL)), ((u64)(0x02b4723aad7b90edLL)), ((u64)(0x4920a0d7a999ac96LL)), ((u64)(0x0229f4fbbdfc73f1LL)), ((u64)(0x750101590f5c4757LL)), ((u64)(0x037654c5fcc71fe8LL)), ((u64)(0x2a6734473f7d05dfLL)), ((u64)(0x02c5109e63d27fedLL)), ((u64)(0xeeb8f69f65fd9e4cULL)), ((u64)(0x0237407eb641fff0LL)), ((u64)(0xe45b24323cc8fd46ULL)), ((u64)(0x038b9a6456cfffe7LL)), ((u64)(0xb6af502830a0ca9fULL)), ((u64)(0x02d6151d123fffecLL)), ((u64)(0xf88c402026e7087fULL)), ((u64)(0x0244ddb0db666656LL)), | |
| 3371 | +((u64)(0x2746cd003e3e73feLL)), ((u64)(0x03a162b4923d708bLL)), ((u64)(0x1f6bd73364fec332LL)), ((u64)(0x02e7822a0e978d3cLL)), ((u64)(0xe5efdf5c50cbcf5bULL)), ((u64)(0x0252ce880bac70fcLL)), ((u64)(0x3cb2fefa1adfb22bLL)), ((u64)(0x03b7b0d9ac471b2eLL)), ((u64)(0x308f3261af195b56LL)), ((u64)(0x02f95a47bd05af58LL)), ((u64)(0x5a0c284e25ade2abLL)), ((u64)(0x0261150630d15913LL)), ((u64)(0x29ad0d49d5e30445LL)), ((u64)(0x03ce8809e7b55b52LL)), ((u64)(0x548a7107de4f369dLL)), ((u64)(0x030ba007ec9115dbLL)), ((u64)(0xdd3b8d9fe50c2bb1ULL)), ((u64)(0x026fb3398a0dab15LL)), ((u64)(0x952c15cca1ad12b5ULL)), ((u64)(0x03e5eb8f434911bcLL)), ((u64)(0x775677d6e7bda891LL)), ((u64)(0x031e560c35d40e30LL)), ((u64)(0xc5dec645863153a7ULL)), ((u64)(0x027eab3cf7dcd826LL))}; // fixed array const | |
| 3372 | +bool v_memory_panic = false; // global 6 | |
| 3373 | + | |
| 3374 | +int_literal g_autostr_type_stack_len = 0; // global 6 | |
| 3375 | + | |
| 3376 | +int_literal g_autostr_addr_stack_len = 0; // global 6 | |
| 3377 | + | |
| 3378 | +int g_main_argc = ((int)(0)); // global 6 | |
| 3379 | + | |
| 3380 | +voidptr g_main_argv = ((void*)0); // global 6 | |
| 3381 | + | |
| 3382 | +voidptr g_live_reload_info; // global 6 | |
| 3383 | + | |
| 3384 | +/* skip C global: stdout */ | |
| 3385 | + | |
| 3386 | +/* skip C global: stderr */ | |
| 3387 | + | |
| 3388 | +/* skip C global: _wyp */ | |
| 3389 | + | |
| 3390 | +static IError _const_error_sentinel; // inited later | |
| 3391 | +static IError _const_none__; // inited later | |
| 3392 | +static const i8 _const_min_i8 = -128; // precomputed2 | |
| 3393 | +static const i8 _const_max_i8 = 127; // precomputed2 | |
| 3394 | +static const i16 _const_min_i16 = -32768; // precomputed2 | |
| 3395 | +static const i16 _const_max_i16 = 32767; // precomputed2 | |
| 3396 | +static const i32 _const_min_i32 = -2147483648; // precomputed2 | |
| 3397 | +static const i32 _const_max_i32 = 2147483647; // precomputed2 | |
| 3398 | +static i64 _const_min_i64; // inited later | |
| 3399 | +static i64 _const_max_i64; // inited later | |
| 3400 | +static const u8 _const_min_u8 = 0; // precomputed2 | |
| 3401 | +static const u8 _const_max_u8 = 255; // precomputed2 | |
| 3402 | +static const u16 _const_min_u16 = 0; // precomputed2 | |
| 3403 | +static const u16 _const_max_u16 = 65535; // precomputed2 | |
| 3404 | +static const u32 _const_min_u32 = 0; // precomputed2 | |
| 3405 | +static const u32 _const_max_u32 = 4294967295; // precomputed2 | |
| 3406 | +static const u64 _const_min_u64 = 0U; // precomputed2 | |
| 3407 | +static const u64 _const_max_u64 = 18446744073709551615U; // precomputed2 | |
| 3408 | +static const u32 _const_hash_mask = 16777215; // precomputed2 | |
| 3409 | +static const u32 _const_probe_inc = 16777216; // precomputed2 | |
| 3410 | +static Array_fixed_i32_1264 _const_rune_maps = {((i32)(0xB5)), 0xB5, 743, 0, 0xC0, 0xD6, 0, 32, 0xD8, 0xDE, 0, 32, 0xE0, 0xF6, -32, 0, | |
| 3411 | +0xF8, 0xFE, -32, 0, 0xFF, 0xFF, 121, 0, 0x100, 0x12F, -3, -3, 0x130, 0x130, 0, -199, | |
| 3412 | +0x131, 0x131, -232, 0, 0x132, 0x137, -3, -3, 0x139, 0x148, -3, -3, 0x14A, 0x177, -3, -3, | |
| 3413 | +0x178, 0x178, 0, -121, 0x179, 0x17E, -3, -3, 0x17F, 0x17F, -300, 0, 0x180, 0x180, 195, 0, | |
| 3414 | +0x181, 0x181, 0, 210, 0x182, 0x185, -3, -3, 0x186, 0x186, 0, 206, 0x187, 0x188, -3, -3, | |
| 3415 | +0x189, 0x18A, 0, 205, 0x18B, 0x18C, -3, -3, 0x18E, 0x18E, 0, 79, 0x18F, 0x18F, 0, 202, | |
| 3416 | +0x190, 0x190, 0, 203, 0x191, 0x192, -3, -3, 0x193, 0x193, 0, 205, 0x194, 0x194, 0, 207, | |
| 3417 | +0x195, 0x195, 97, 0, 0x196, 0x196, 0, 211, 0x197, 0x197, 0, 209, 0x198, 0x199, -3, -3, | |
| 3418 | +0x19A, 0x19A, 163, 0, 0x19C, 0x19C, 0, 211, 0x19D, 0x19D, 0, 213, 0x19E, 0x19E, 130, 0, | |
| 3419 | +0x19F, 0x19F, 0, 214, 0x1A0, 0x1A5, -3, -3, 0x1A6, 0x1A6, 0, 218, 0x1A7, 0x1A8, -3, -3, | |
| 3420 | +0x1A9, 0x1A9, 0, 218, 0x1AC, 0x1AD, -3, -3, 0x1AE, 0x1AE, 0, 218, 0x1AF, 0x1B0, -3, -3, | |
| 3421 | +0x1B1, 0x1B2, 0, 217, 0x1B3, 0x1B6, -3, -3, 0x1B7, 0x1B7, 0, 219, 0x1B8, 0x1B9, -3, -3, | |
| 3422 | +0x1BC, 0x1BD, -3, -3, 0x1BF, 0x1BF, 56, 0, 0x1C4, 0x1CC, -2, -2, 0x1CD, 0x1DC, -3, -3, | |
| 3423 | +0x1DD, 0x1DD, -79, 0, 0x1DE, 0x1EF, -3, -3, 0x1F1, 0x1F3, -2, -2, 0x1F4, 0x1F5, -3, -3, | |
| 3424 | +0x1F6, 0x1F6, 0, -97, 0x1F7, 0x1F7, 0, -56, 0x1F8, 0x21F, -3, -3, 0x220, 0x220, 0, -130, | |
| 3425 | +0x222, 0x233, -3, -3, 0x23A, 0x23A, 0, 10795, 0x23B, 0x23C, -3, -3, 0x23D, 0x23D, 0, -163, | |
| 3426 | +0x23E, 0x23E, 0, 10792, 0x23F, 0x240, 10815, 0, 0x241, 0x242, -3, -3, 0x243, 0x243, 0, -195, | |
| 3427 | +0x244, 0x244, 0, 69, 0x245, 0x245, 0, 71, 0x246, 0x24F, -3, -3, 0x250, 0x250, 10783, 0, | |
| 3428 | +0x251, 0x251, 10780, 0, 0x252, 0x252, 10782, 0, 0x253, 0x253, -210, 0, 0x254, 0x254, -206, 0, | |
| 3429 | +0x256, 0x257, -205, 0, 0x259, 0x259, -202, 0, 0x25B, 0x25B, -203, 0, 0x25C, 0x25C, 42319, 0, | |
| 3430 | +0x260, 0x260, -205, 0, 0x261, 0x261, 42315, 0, 0x263, 0x263, -207, 0, 0x265, 0x265, 42280, 0, | |
| 3431 | +0x266, 0x266, 42308, 0, 0x268, 0x268, -209, 0, 0x269, 0x269, -211, 0, 0x26A, 0x26A, 42308, 0, | |
| 3432 | +0x26B, 0x26B, 10743, 0, 0x26C, 0x26C, 42305, 0, 0x26F, 0x26F, -211, 0, 0x271, 0x271, 10749, 0, | |
| 3433 | +0x272, 0x272, -213, 0, 0x275, 0x275, -214, 0, 0x27D, 0x27D, 10727, 0, 0x280, 0x280, -218, 0, | |
| 3434 | +0x282, 0x282, 42307, 0, 0x283, 0x283, -218, 0, 0x287, 0x287, 42282, 0, 0x288, 0x288, -218, 0, | |
| 3435 | +0x289, 0x289, -69, 0, 0x28A, 0x28B, -217, 0, 0x28C, 0x28C, -71, 0, 0x292, 0x292, -219, 0, | |
| 3436 | +0x29D, 0x29D, 42261, 0, 0x29E, 0x29E, 42258, 0, 0x345, 0x345, 84, 0, 0x370, 0x373, -3, -3, | |
| 3437 | +0x376, 0x377, -3, -3, 0x37B, 0x37D, 130, 0, 0x37F, 0x37F, 0, 116, 0x386, 0x386, 0, 38, | |
| 3438 | +0x388, 0x38A, 0, 37, 0x38C, 0x38C, 0, 64, 0x38E, 0x38F, 0, 63, 0x391, 0x3A1, 0, 32, | |
| 3439 | +0x3A3, 0x3AB, 0, 32, 0x3AC, 0x3AC, -38, 0, 0x3AD, 0x3AF, -37, 0, 0x3B1, 0x3C1, -32, 0, | |
| 3440 | +0x3C2, 0x3C2, -31, 0, 0x3C3, 0x3CB, -32, 0, 0x3CC, 0x3CC, -64, 0, 0x3CD, 0x3CE, -63, 0, | |
| 3441 | +0x3CF, 0x3CF, 0, 8, 0x3D0, 0x3D0, -62, 0, 0x3D1, 0x3D1, -57, 0, 0x3D5, 0x3D5, -47, 0, | |
| 3442 | +0x3D6, 0x3D6, -54, 0, 0x3D7, 0x3D7, -8, 0, 0x3D8, 0x3EF, -3, -3, 0x3F0, 0x3F0, -86, 0, | |
| 3443 | +0x3F1, 0x3F1, -80, 0, 0x3F2, 0x3F2, 7, 0, 0x3F3, 0x3F3, -116, 0, 0x3F4, 0x3F4, 0, -60, | |
| 3444 | +0x3F5, 0x3F5, -96, 0, 0x3F7, 0x3F8, -3, -3, 0x3F9, 0x3F9, 0, -7, 0x3FA, 0x3FB, -3, -3, | |
| 3445 | +0x3FD, 0x3FF, 0, -130, 0x400, 0x40F, 0, 80, 0x410, 0x42F, 0, 32, 0x430, 0x44F, -32, 0, | |
| 3446 | +0x450, 0x45F, -80, 0, 0x460, 0x481, -3, -3, 0x48A, 0x4BF, -3, -3, 0x4C0, 0x4C0, 0, 15, | |
| 3447 | +0x4C1, 0x4CE, -3, -3, 0x4CF, 0x4CF, -15, 0, 0x4D0, 0x52F, -3, -3, 0x531, 0x556, 0, 48, | |
| 3448 | +0x561, 0x586, -48, 0, 0x10A0, 0x10C5, 0, 7264, 0x10C7, 0x10C7, 0, 7264, 0x10CD, 0x10CD, 0, 7264, | |
| 3449 | +0x10D0, 0x10FA, 3008, 0, 0x10FD, 0x10FF, 3008, 0, 0x13A0, 0x13EF, 0, 38864, 0x13F0, 0x13F5, 0, 8, | |
| 3450 | +0x13F8, 0x13FD, -8, 0, 0x1C80, 0x1C80, -6254, 0, 0x1C81, 0x1C81, -6253, 0, 0x1C82, 0x1C82, -6244, 0, | |
| 3451 | +0x1C83, 0x1C84, -6242, 0, 0x1C85, 0x1C85, -6243, 0, 0x1C86, 0x1C86, -6236, 0, 0x1C87, 0x1C87, -6181, 0, | |
| 3452 | +0x1C88, 0x1C88, 35266, 0, 0x1C90, 0x1CBA, 0, -3008, 0x1CBD, 0x1CBF, 0, -3008, 0x1D79, 0x1D79, 35332, 0, | |
| 3453 | +0x1D7D, 0x1D7D, 3814, 0, 0x1D8E, 0x1D8E, 35384, 0, 0x1E00, 0x1E95, -3, -3, 0x1E9B, 0x1E9B, -59, 0, | |
| 3454 | +0x1E9E, 0x1E9E, 0, -7615, 0x1EA0, 0x1EFF, -3, -3, 0x1F00, 0x1F07, 8, 0, 0x1F08, 0x1F0F, 0, -8, | |
| 3455 | +0x1F10, 0x1F15, 8, 0, 0x1F18, 0x1F1D, 0, -8, 0x1F20, 0x1F27, 8, 0, 0x1F28, 0x1F2F, 0, -8, | |
| 3456 | +0x1F30, 0x1F37, 8, 0, 0x1F38, 0x1F3F, 0, -8, 0x1F40, 0x1F45, 8, 0, 0x1F48, 0x1F4D, 0, -8, | |
| 3457 | +0x1F51, 0x1F51, 8, 0, 0x1F53, 0x1F53, 8, 0, 0x1F55, 0x1F55, 8, 0, 0x1F57, 0x1F57, 8, 0, | |
| 3458 | +0x1F59, 0x1F59, 0, -8, 0x1F5B, 0x1F5B, 0, -8, 0x1F5D, 0x1F5D, 0, -8, 0x1F5F, 0x1F5F, 0, -8, | |
| 3459 | +0x1F60, 0x1F67, 8, 0, 0x1F68, 0x1F6F, 0, -8, 0x1F70, 0x1F71, 74, 0, 0x1F72, 0x1F75, 86, 0, | |
| 3460 | +0x1F76, 0x1F77, 100, 0, 0x1F78, 0x1F79, 128, 0, 0x1F7A, 0x1F7B, 112, 0, 0x1F7C, 0x1F7D, 126, 0, | |
| 3461 | +0x1F80, 0x1F87, 8, 0, 0x1F88, 0x1F8F, 0, -8, 0x1F90, 0x1F97, 8, 0, 0x1F98, 0x1F9F, 0, -8, | |
| 3462 | +0x1FA0, 0x1FA7, 8, 0, 0x1FA8, 0x1FAF, 0, -8, 0x1FB0, 0x1FB1, 8, 0, 0x1FB3, 0x1FB3, 9, 0, | |
| 3463 | +0x1FB8, 0x1FB9, 0, -8, 0x1FBA, 0x1FBB, 0, -74, 0x1FBC, 0x1FBC, 0, -9, 0x1FBE, 0x1FBE, -7205, 0, | |
| 3464 | +0x1FC3, 0x1FC3, 9, 0, 0x1FC8, 0x1FCB, 0, -86, 0x1FCC, 0x1FCC, 0, -9, 0x1FD0, 0x1FD1, 8, 0, | |
| 3465 | +0x1FD8, 0x1FD9, 0, -8, 0x1FDA, 0x1FDB, 0, -100, 0x1FE0, 0x1FE1, 8, 0, 0x1FE5, 0x1FE5, 7, 0, | |
| 3466 | +0x1FE8, 0x1FE9, 0, -8, 0x1FEA, 0x1FEB, 0, -112, 0x1FEC, 0x1FEC, 0, -7, 0x1FF3, 0x1FF3, 9, 0, | |
| 3467 | +0x1FF8, 0x1FF9, 0, -128, 0x1FFA, 0x1FFB, 0, -126, 0x1FFC, 0x1FFC, 0, -9, 0x2126, 0x2126, 0, -7517, | |
| 3468 | +0x212A, 0x212A, 0, -8383, 0x212B, 0x212B, 0, -8262, 0x2132, 0x2132, 0, 28, 0x214E, 0x214E, -28, 0, | |
| 3469 | +0x2160, 0x216F, 0, 16, 0x2170, 0x217F, -16, 0, 0x2183, 0x2184, -3, -3, 0x24B6, 0x24CF, 0, 26, | |
| 3470 | +0x24D0, 0x24E9, -26, 0, 0x2C00, 0x2C2F, 0, 48, 0x2C30, 0x2C5F, -48, 0, 0x2C60, 0x2C61, -3, -3, | |
| 3471 | +0x2C62, 0x2C62, 0, -10743, 0x2C63, 0x2C63, 0, -3814, 0x2C64, 0x2C64, 0, -10727, 0x2C65, 0x2C65, -10795, 0, | |
| 3472 | +0x2C66, 0x2C66, -10792, 0, 0x2C67, 0x2C6C, -3, -3, 0x2C6D, 0x2C6D, 0, -10780, 0x2C6E, 0x2C6E, 0, -10749, | |
| 3473 | +0x2C6F, 0x2C6F, 0, -10783, 0x2C70, 0x2C70, 0, -10782, 0x2C72, 0x2C73, -3, -3, 0x2C75, 0x2C76, -3, -3, | |
| 3474 | +0x2C7E, 0x2C7F, 0, -10815, 0x2C80, 0x2CE3, -3, -3, 0x2CEB, 0x2CEE, -3, -3, 0x2CF2, 0x2CF3, -3, -3, | |
| 3475 | +0x2D00, 0x2D25, -7264, 0, 0x2D27, 0x2D27, -7264, 0, 0x2D2D, 0x2D2D, -7264, 0, 0xA640, 0xA66D, -3, -3, | |
| 3476 | +0xA680, 0xA69B, -3, -3, 0xA722, 0xA72F, -3, -3, 0xA732, 0xA76F, -3, -3, 0xA779, 0xA77C, -3, -3, | |
| 3477 | +0xA77D, 0xA77D, 0, -35332, 0xA77E, 0xA787, -3, -3, 0xA78B, 0xA78C, -3, -3, 0xA78D, 0xA78D, 0, -42280, | |
| 3478 | +0xA790, 0xA793, -3, -3, 0xA794, 0xA794, 48, 0, 0xA796, 0xA7A9, -3, -3, 0xA7AA, 0xA7AA, 0, -42308, | |
| 3479 | +0xA7AB, 0xA7AB, 0, -42319, 0xA7AC, 0xA7AC, 0, -42315, 0xA7AD, 0xA7AD, 0, -42305, 0xA7AE, 0xA7AE, 0, -42308, | |
| 3480 | +0xA7B0, 0xA7B0, 0, -42258, 0xA7B1, 0xA7B1, 0, -42282, 0xA7B2, 0xA7B2, 0, -42261, 0xA7B3, 0xA7B3, 0, 928, | |
| 3481 | +0xA7B4, 0xA7C3, -3, -3, 0xA7C4, 0xA7C4, 0, -48, 0xA7C5, 0xA7C5, 0, -42307, 0xA7C6, 0xA7C6, 0, -35384, | |
| 3482 | +0xA7C7, 0xA7CA, -3, -3, 0xA7D0, 0xA7D1, -3, -3, 0xA7D6, 0xA7D9, -3, -3, 0xA7F5, 0xA7F6, -3, -3, | |
| 3483 | +0xAB53, 0xAB53, -928, 0, 0xAB70, 0xABBF, -38864, 0, 0xFF21, 0xFF3A, 0, 32, 0xFF41, 0xFF5A, -32, 0, | |
| 3484 | +0x10400, 0x10427, 0, 40, 0x10428, 0x1044F, -40, 0, 0x104B0, 0x104D3, 0, 40, 0x104D8, 0x104FB, -40, 0, | |
| 3485 | +0x10570, 0x1057A, 0, 39, 0x1057C, 0x1058A, 0, 39, 0x1058C, 0x10592, 0, 39, 0x10594, 0x10595, 0, 39, | |
| 3486 | +0x10597, 0x105A1, -39, 0, 0x105A3, 0x105B1, -39, 0, 0x105B3, 0x105B9, -39, 0, 0x105BB, 0x105BC, -39, 0, | |
| 3487 | +0x10C80, 0x10CB2, 0, 64, 0x10CC0, 0x10CF2, -64, 0, 0x118A0, 0x118BF, 0, 32, 0x118C0, 0x118DF, -32, 0, | |
| 3488 | +0x16E40, 0x16E5F, 0, 32, 0x16E60, 0x16E7F, -32, 0, 0x1E900, 0x1E921, 0, 34, 0x1E922, 0x1E943, -34, 0}; // fixed array const | |
| 3489 | +static const u8 _const_str_intp_has_dynamic_width = 1; // precomputed2 | |
| 3490 | +static const u8 _const_str_intp_has_dynamic_precision = 2; // precomputed2 | |
| 3491 | +static rune _const_utf8_replacement_rune; // inited later | |
| 3492 | +static u32 _const_builtin__closure__closure_size_1; // inited later | |
| 3493 | +Array_fixed_int_64 g_autostr_type_stack = {0}; // global 6 | |
| 3494 | + | |
| 3495 | +Array_fixed_voidptr_64 g_autostr_addr_stack = {0}; // global 6 | |
| 3496 | + | |
| 3497 | +static int _const_builtin__closure__closure_size; // inited later | |
| 3498 | + | |
| 3499 | +// V interface table: | |
| 3500 | +static IError I_None___to_Interface_IError(None__* x); | |
| 3501 | +enum { _IError_None___index = 1 }; | |
| 3502 | +static IError I_voidptr_to_Interface_IError(voidptr* x); | |
| 3503 | +enum { _IError_voidptr_index = 2 }; | |
| 3504 | +static IError I_MessageError_to_Interface_IError(MessageError* x); | |
| 3505 | +enum { _IError_MessageError_index = 3 }; | |
| 3506 | +static IError I_Error_to_Interface_IError(Error* x); | |
| 3507 | +enum { _IError_Error_index = 4 }; | |
| 3508 | +// ^^^ number of types for interface IError: 4 | |
| 3509 | + | |
| 3510 | +// Methods wrapper for interface "IError" | |
| 3511 | +static inline int builtin__None___code_Interface_IError_method_wrapper(None__* err) { | |
| 3512 | + return builtin__Error_code(err->Error); | |
| 3513 | +} | |
| 3514 | +static inline int builtin__None___code_Interface_IError_method_adapter(void* _x) { | |
| 3515 | + return builtin__None___code_Interface_IError_method_wrapper((None__*)_x); | |
| 3516 | +} | |
| 3517 | +static inline string builtin__None___msg_Interface_IError_method_wrapper(None__* err) { | |
| 3518 | + return builtin__Error_msg(err->Error); | |
| 3519 | +} | |
| 3520 | +static inline string builtin__None___msg_Interface_IError_method_adapter(void* _x) { | |
| 3521 | + return builtin__None___msg_Interface_IError_method_wrapper((None__*)_x); | |
| 3522 | +} | |
| 3523 | +static inline int builtin__MessageError_code_Interface_IError_method_wrapper(MessageError* err) { | |
| 3524 | + return builtin__MessageError_code(*err); | |
| 3525 | +} | |
| 3526 | +static inline int builtin__MessageError_code_Interface_IError_method_adapter(void* _x) { | |
| 3527 | + return builtin__MessageError_code_Interface_IError_method_wrapper((MessageError*)_x); | |
| 3528 | +} | |
| 3529 | +static inline string builtin__MessageError_msg_Interface_IError_method_wrapper(MessageError* err) { | |
| 3530 | + return builtin__MessageError_msg(*err); | |
| 3531 | +} | |
| 3532 | +static inline string builtin__MessageError_msg_Interface_IError_method_adapter(void* _x) { | |
| 3533 | + return builtin__MessageError_msg_Interface_IError_method_wrapper((MessageError*)_x); | |
| 3534 | +} | |
| 3535 | +static inline int builtin__Error_code_Interface_IError_method_wrapper(Error* err) { | |
| 3536 | + return builtin__Error_code(*err); | |
| 3537 | +} | |
| 3538 | +static inline int builtin__Error_code_Interface_IError_method_adapter(void* _x) { | |
| 3539 | + return builtin__Error_code_Interface_IError_method_wrapper((Error*)_x); | |
| 3540 | +} | |
| 3541 | +static inline string builtin__Error_msg_Interface_IError_method_wrapper(Error* err) { | |
| 3542 | + return builtin__Error_msg(*err); | |
| 3543 | +} | |
| 3544 | +static inline string builtin__Error_msg_Interface_IError_method_adapter(void* _x) { | |
| 3545 | + return builtin__Error_msg_Interface_IError_method_wrapper((Error*)_x); | |
| 3546 | +} | |
| 3547 | + | |
| 3548 | +struct _IError_interface_methods { | |
| 3549 | + int (*_method_code)(void* _); | |
| 3550 | + string (*_method_msg)(void* _); | |
| 3551 | +}; | |
| 3552 | + | |
| 3553 | +struct _IError_interface_methods IError_name_table[5] = { | |
| 3554 | + {0}, | |
| 3555 | + { | |
| 3556 | + ._method_code = builtin__None___code_Interface_IError_method_adapter, | |
| 3557 | + ._method_msg = builtin__None___msg_Interface_IError_method_adapter, | |
| 3558 | + }, | |
| 3559 | + { | |
| 3560 | + ._method_code = (void*) 0, | |
| 3561 | + ._method_msg = (void*) 0, | |
| 3562 | + }, | |
| 3563 | + { | |
| 3564 | + ._method_code = builtin__MessageError_code_Interface_IError_method_adapter, | |
| 3565 | + ._method_msg = builtin__MessageError_msg_Interface_IError_method_adapter, | |
| 3566 | + }, | |
| 3567 | + { | |
| 3568 | + ._method_code = builtin__Error_code_Interface_IError_method_adapter, | |
| 3569 | + ._method_msg = builtin__Error_msg_Interface_IError_method_adapter, | |
| 3570 | + }, | |
| 3571 | +}; | |
| 3572 | + | |
| 3573 | + | |
| 3574 | +// Casting functions for converting "None__" to interface "IError" | |
| 3575 | + | |
| 3576 | +static inline IError I_None___to_Interface_IError(None__* x) { | |
| 3577 | +return (IError) { | |
| 3578 | + ._None__ = x, | |
| 3579 | + ._typ = _IError_None___index, | |
| 3580 | + ._methods = &IError_name_table[_IError_None___index], | |
| 3581 | + }; | |
| 3582 | +} | |
| 3583 | + | |
| 3584 | +// Casting functions for converting "voidptr" to interface "IError" | |
| 3585 | + | |
| 3586 | +static inline IError I_voidptr_to_Interface_IError(voidptr* x) { | |
| 3587 | +return (IError) { | |
| 3588 | + ._voidptr = x, | |
| 3589 | + ._typ = _IError_voidptr_index, | |
| 3590 | + ._methods = &IError_name_table[_IError_voidptr_index], | |
| 3591 | + }; | |
| 3592 | +} | |
| 3593 | + | |
| 3594 | +// Casting functions for converting "MessageError" to interface "IError" | |
| 3595 | + | |
| 3596 | +static inline IError I_MessageError_to_Interface_IError(MessageError* x) { | |
| 3597 | +return (IError) { | |
| 3598 | + ._MessageError = x, | |
| 3599 | + ._typ = _IError_MessageError_index, | |
| 3600 | + ._methods = &IError_name_table[_IError_MessageError_index], | |
| 3601 | + }; | |
| 3602 | +} | |
| 3603 | + | |
| 3604 | +// Casting functions for converting "Error" to interface "IError" | |
| 3605 | + | |
| 3606 | +static inline IError I_Error_to_Interface_IError(Error* x) { | |
| 3607 | +return (IError) { | |
| 3608 | + ._Error = x, | |
| 3609 | + ._typ = _IError_Error_index, | |
| 3610 | + ._methods = &IError_name_table[_IError_Error_index], | |
| 3611 | + }; | |
| 3612 | +} | |
| 3613 | + | |
| 3614 | + | |
| 3615 | +static inline IError __v_interface_clone_variant__IError__None__(void* x) { | |
| 3616 | +return I_None___to_Interface_IError((None__*)builtin__memdup(x, sizeof(None__))); | |
| 3617 | +} | |
| 3618 | + | |
| 3619 | +static inline IError __v_interface_clone_variant__IError__voidptr(void* x) { | |
| 3620 | +return I_voidptr_to_Interface_IError((voidptr*)builtin__memdup(x, sizeof(voidptr))); | |
| 3621 | +} | |
| 3622 | + | |
| 3623 | +static inline IError __v_interface_clone_variant__IError__MessageError(void* x) { | |
| 3624 | +return I_MessageError_to_Interface_IError((MessageError*)builtin__memdup(x, sizeof(MessageError))); | |
| 3625 | +} | |
| 3626 | + | |
| 3627 | +static inline IError __v_interface_clone_variant__IError__Error(void* x) { | |
| 3628 | +return I_Error_to_Interface_IError((Error*)builtin__memdup(x, sizeof(Error))); | |
| 3629 | +} | |
| 3630 | + | |
| 3631 | +static inline IError __v_interface_clone__IError(IError x) { | |
| 3632 | + if (x._object == 0) { | |
| 3633 | + return x; | |
| 3634 | + } | |
| 3635 | + if (x._typ == _IError_None___index) { | |
| 3636 | + return __v_interface_clone_variant__IError__None__(x._object); | |
| 3637 | + } | |
| 3638 | + if (x._typ == _IError_voidptr_index) { | |
| 3639 | + return __v_interface_clone_variant__IError__voidptr(x._object); | |
| 3640 | + } | |
| 3641 | + if (x._typ == _IError_MessageError_index) { | |
| 3642 | + return __v_interface_clone_variant__IError__MessageError(x._object); | |
| 3643 | + } | |
| 3644 | + if (x._typ == _IError_Error_index) { | |
| 3645 | + return __v_interface_clone_variant__IError__Error(x._object); | |
| 3646 | + } | |
| 3647 | + return x; | |
| 3648 | +} | |
| 3649 | + | |
| 3650 | + | |
| 3651 | +// V sort fn definitions: | |
| 3652 | +VV_LOC int compare_11734835982493514523_RepIndex_by_idx_expr_612e6964780a3c0a622e696478(RepIndex* a, RepIndex* b) { | |
| 3653 | + if (a->idx < b->idx) return -1; | |
| 3654 | + if (b->idx < a->idx) return 1; | |
| 3655 | + return 0; | |
| 3656 | +} | |
| 3657 | + | |
| 3658 | +VV_LOC int compare_11734835982493514523_RepIndex_by_idx_expr_612e6964780a3c0a622e696478_qsort_adapter(const void* a, const void* b) { | |
| 3659 | + return compare_11734835982493514523_RepIndex_by_idx_expr_612e6964780a3c0a622e696478((RepIndex*)a, (RepIndex*)b); | |
| 3660 | +} | |
| 3661 | + | |
| 3662 | +VV_LOC int builtin__compare_lower_strings_qsort_adapter(const void* a, const void* b) { | |
| 3663 | + return builtin__compare_lower_strings((string*)a, (string*)b); | |
| 3664 | +} | |
| 3665 | + | |
| 3666 | +VV_LOC int builtin__compare_strings_by_len_qsort_adapter(const void* a, const void* b) { | |
| 3667 | + return builtin__compare_strings_by_len((string*)a, (string*)b); | |
| 3668 | +} | |
| 3669 | + | |
| 3670 | +static inline u64 VSAFE_DIV_u64(u64 x, u64 y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("division by zero")); } return x / y; } | |
| 3671 | +static inline u64 VSAFE_MOD_u64(u64 x, u64 y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("modulo by zero")); } return x % y; } | |
| 3672 | +static inline int VSAFE_DIV_int(int x, int y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("division by zero")); } return x / y; } | |
| 3673 | +static inline usize VSAFE_MOD_usize(usize x, usize y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("modulo by zero")); } return x % y; } | |
| 3674 | +static inline u32 VSAFE_DIV_u32(u32 x, u32 y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("division by zero")); } return x / y; } | |
| 3675 | +static inline u32 VSAFE_MOD_u32(u32 x, u32 y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("modulo by zero")); } return x % y; } | |
| 3676 | +static inline i64 VSAFE_DIV_i64(i64 x, i64 y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("division by zero")); } return x / y; } | |
| 3677 | +static inline int VSAFE_MOD_int(int x, int y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("modulo by zero")); } return x % y; } | |
| 3678 | +static inline i64 VSAFE_MOD_i64(i64 x, i64 y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("modulo by zero")); } return x % y; } | |
| 3679 | +static inline rune VSAFE_MOD_rune(rune x, rune y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("modulo by zero")); } return x % y; } | |
| 3680 | + | |
| 3681 | +// end of V out (header) | |
| 3682 | + | |
| 3683 | +// V auto functions: | |
| 3684 | +static bool Array_u8_contains(Array_u8 a, u8 v) { | |
| 3685 | + for (int i = 0; i < a.len; ++i) { | |
| 3686 | + if (((u8*)a.data)[i] == v) { | |
| 3687 | + return true; | |
| 3688 | + } | |
| 3689 | + } | |
| 3690 | + return false; | |
| 3691 | +} | |
| 3692 | + | |
| 3693 | +static inline bool Array_rune_arr_eq(Array_rune a, Array_rune b) { | |
| 3694 | + if (a.len != b.len) { | |
| 3695 | + return false; | |
| 3696 | + } | |
| 3697 | + for (int i = 0; i < a.len; ++i) { | |
| 3698 | + if (*((rune*)((byte*)a.data+(i*a.element_size))) != *((rune*)((byte*)b.data+(i*b.element_size)))) { | |
| 3699 | + return false; | |
| 3700 | + } | |
| 3701 | + } | |
| 3702 | + return true; | |
| 3703 | +} | |
| 3704 | + | |
| 3705 | +static inline bool builtin__closure__ClosureLifetimeRecord_struct_eq(builtin__closure__ClosureLifetimeRecord a, builtin__closure__ClosureLifetimeRecord b) { | |
| 3706 | + return a.exec_ptr == b.exec_ptr | |
| 3707 | + && a.generation == b.generation; | |
| 3708 | +} | |
| 3709 | + | |
| 3710 | +static inline bool Array_builtin__closure__ClosureLifetimeRecord_arr_eq(Array_builtin__closure__ClosureLifetimeRecord a, Array_builtin__closure__ClosureLifetimeRecord b) { | |
| 3711 | + if (a.len != b.len) { | |
| 3712 | + return false; | |
| 3713 | + } | |
| 3714 | + for (int i = 0; i < a.len; ++i) { | |
| 3715 | + if (!builtin__closure__ClosureLifetimeRecord_struct_eq(((builtin__closure__ClosureLifetimeRecord*)a.data)[i], ((builtin__closure__ClosureLifetimeRecord*)b.data)[i])) { | |
| 3716 | + return false; | |
| 3717 | + } | |
| 3718 | + } | |
| 3719 | + return true; | |
| 3720 | +} | |
| 3721 | + | |
| 3722 | +static inline bool builtin__closure__ClosureLifetimeFrame_struct_eq(builtin__closure__ClosureLifetimeFrame a, builtin__closure__ClosureLifetimeFrame b) { | |
| 3723 | + return a.start == b.start | |
| 3724 | + && a.end == b.end; | |
| 3725 | +} | |
| 3726 | + | |
| 3727 | +static inline bool Array_builtin__closure__ClosureLifetimeFrame_arr_eq(Array_builtin__closure__ClosureLifetimeFrame a, Array_builtin__closure__ClosureLifetimeFrame b) { | |
| 3728 | + if (a.len != b.len) { | |
| 3729 | + return false; | |
| 3730 | + } | |
| 3731 | + for (int i = 0; i < a.len; ++i) { | |
| 3732 | + if (!builtin__closure__ClosureLifetimeFrame_struct_eq(((builtin__closure__ClosureLifetimeFrame*)a.data)[i], ((builtin__closure__ClosureLifetimeFrame*)b.data)[i])) { | |
| 3733 | + return false; | |
| 3734 | + } | |
| 3735 | + } | |
| 3736 | + return true; | |
| 3737 | +} | |
| 3738 | + | |
| 3739 | +static inline bool builtin__closure__ClosureLifetimeState_struct_eq(builtin__closure__ClosureLifetimeState a, builtin__closure__ClosureLifetimeState b) { | |
| 3740 | + return a.owner_thread == b.owner_thread | |
| 3741 | + && a.active == b.active | |
| 3742 | + && a.disposed == b.disposed | |
| 3743 | + && a.suspended == b.suspended | |
| 3744 | + && a.frame_start == b.frame_start | |
| 3745 | + && a.frame_gen == b.frame_gen | |
| 3746 | + && a.generation == b.generation | |
| 3747 | + && a.frame_generation == b.frame_generation | |
| 3748 | + && Array_builtin__closure__ClosureLifetimeRecord_arr_eq(a.records, b.records) | |
| 3749 | + && Array_builtin__closure__ClosureLifetimeFrame_arr_eq(a.frames, b.frames) | |
| 3750 | + && a.next_free == b.next_free; | |
| 3751 | +} | |
| 3752 | + | |
| 3753 | + | |
| 3754 | +// >> typeof() support for sum types / interfaces | |
| 3755 | +static char * v_typeof_interface_IError(u32 sidx) { | |
| 3756 | + if (sidx == _IError_None___index) return "None__"; | |
| 3757 | + if (sidx == _IError_voidptr_index) return "voidptr"; | |
| 3758 | + if (sidx == _IError_MessageError_index) return "MessageError"; | |
| 3759 | + if (sidx == _IError_Error_index) return "Error"; | |
| 3760 | + return "unknown IError"; | |
| 3761 | +} | |
| 3762 | + | |
| 3763 | +u32 v_typeof_interface_idx_IError(u32 sidx) { | |
| 3764 | + if (sidx == _IError_None___index) return 65; | |
| 3765 | + if (sidx == _IError_voidptr_index) return 2; | |
| 3766 | + if (sidx == _IError_MessageError_index) return 67; | |
| 3767 | + if (sidx == _IError_Error_index) return 66; | |
| 3768 | + return 30; | |
| 3769 | +} | |
| 3770 | +// << typeof() support for sum types | |
| 3771 | + | |
| 3772 | +strings__Builder strings__new_builder(int initial_size) { | |
| 3773 | + strings__Builder res = ((builtin____new_array_with_default(0, initial_size, sizeof(u8), 0))); | |
| 3774 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | |
| 3775 | + return res; | |
| 3776 | +} | |
| 3777 | +Array_u8 strings__Builder_reuse_as_plain_u8_array(strings__Builder* b) { | |
| 3778 | + builtin__ArrayFlags_clear(&b->flags, ArrayFlags__noslices); | |
| 3779 | + return *b; | |
| 3780 | +} | |
| 3781 | +void strings__Builder_write_ptr(strings__Builder* b, u8* ptr, int len) { | |
| 3782 | + if (len == 0) { | |
| 3783 | + return; | |
| 3784 | + } | |
| 3785 | + builtin__array_push_many(b, ptr, len); | |
| 3786 | +} | |
| 3787 | +void strings__Builder_write_rune(strings__Builder* b, rune r) { | |
| 3788 | + Array_fixed_u8_5 buffer = {0}; | |
| 3789 | + string res = builtin__utf32_to_str_no_malloc(((u32)(r)), &buffer[0]); | |
| 3790 | + if (res.len == 0) { | |
| 3791 | + return; | |
| 3792 | + } | |
| 3793 | + builtin__array_push_many(b, res.str, res.len); | |
| 3794 | +} | |
| 3795 | +void strings__Builder_write_runes(strings__Builder* b, Array_rune runes) { | |
| 3796 | + Array_fixed_u8_5 buffer = {0}; | |
| 3797 | + for (int _t1 = 0; _t1 < runes.len; ++_t1) { | |
| 3798 | + rune r = ((rune*)runes.data)[_t1]; | |
| 3799 | + string res = builtin__utf32_to_str_no_malloc(((u32)(r)), &buffer[0]); | |
| 3800 | + if (res.len == 0) { | |
| 3801 | + continue; | |
| 3802 | + } | |
| 3803 | + builtin__array_push_many(b, res.str, res.len); | |
| 3804 | + } | |
| 3805 | +} | |
| 3806 | +inline void strings__Builder_write_u8(strings__Builder* b, u8 data) { | |
| 3807 | + builtin__array_push((array*)b, _MOV((u8[]){ data })); | |
| 3808 | +} | |
| 3809 | +inline void strings__Builder_write_byte(strings__Builder* b, u8 data) { | |
| 3810 | + builtin__array_push((array*)b, _MOV((u8[]){ data })); | |
| 3811 | +} | |
| 3812 | +void strings__Builder_write_decimal(strings__Builder* b, i64 n) { | |
| 3813 | + if (n == 0) { | |
| 3814 | + strings__Builder_write_u8(b, 0x30); | |
| 3815 | + return; | |
| 3816 | + } | |
| 3817 | + u64 mag = ((u64)(n)); | |
| 3818 | + if (n < 0) { | |
| 3819 | + strings__Builder_write_u8(b, '-'); | |
| 3820 | + mag = ((u64)(0)) - mag; | |
| 3821 | + } | |
| 3822 | + strings__Builder_write_u_decimal(b, mag); | |
| 3823 | +} | |
| 3824 | +void strings__Builder_write_u_decimal(strings__Builder* b, u64 n) { | |
| 3825 | + if (n == 0) { | |
| 3826 | + strings__Builder_write_u8(b, 0x30); | |
| 3827 | + return; | |
| 3828 | + } | |
| 3829 | + Array_fixed_u8_20 buf = {0}; | |
| 3830 | + u64 x = n; | |
| 3831 | + int i = 19; | |
| 3832 | + for (;;) { | |
| 3833 | + if (!(x != 0)) break; | |
| 3834 | + u64 nextx = VSAFE_DIV_u64(x , 10); | |
| 3835 | + u64 r = VSAFE_MOD_u64(x , 10); | |
| 3836 | + buf[i] = (u8)(((u8)(r)) + 0x30); | |
| 3837 | + x = nextx; | |
| 3838 | + i--; | |
| 3839 | + } | |
| 3840 | + strings__Builder_write_ptr(b, &buf[i + 1], 19 - i); | |
| 3841 | +} | |
| 3842 | +_result_int strings__Builder_write(strings__Builder* b, Array_u8 data) { | |
| 3843 | + if (data.len == 0) { | |
| 3844 | + _result_int _t1; | |
| 3845 | + builtin___result_ok(&(int[]) { 0 }, (_result*)(&_t1), sizeof(int)); | |
| 3846 | + | |
| 3847 | + return _t1; | |
| 3848 | + } | |
| 3849 | + builtin__array_push_many(b, data.data, data.len); | |
| 3850 | + _result_int _t2; | |
| 3851 | + builtin___result_ok(&(int[]) { data.len }, (_result*)(&_t2), sizeof(int)); | |
| 3852 | + | |
| 3853 | + return _t2; | |
| 3854 | +} | |
| 3855 | +void strings__Builder_drain_builder(strings__Builder* b, strings__Builder* other, int other_new_cap) { | |
| 3856 | + if (other->len > 0) { | |
| 3857 | + _PUSH_MANY(b, (*other), _t1, strings__Builder); | |
| 3858 | + } | |
| 3859 | + strings__Builder_free(other); | |
| 3860 | + *other = strings__new_builder(other_new_cap); | |
| 3861 | +} | |
| 3862 | +inline u8 strings__Builder_byte_at(strings__Builder* b, int n) { | |
| 3863 | + return (*(u8*)builtin__array_get(*(((Array_u8*)(b))), n)); | |
| 3864 | +} | |
| 3865 | +inline void strings__Builder_write_string(strings__Builder* b, string s) { | |
| 3866 | + if (s.len == 0) { | |
| 3867 | + return; | |
| 3868 | + } | |
| 3869 | + builtin__array_push_many(b, s.str, s.len); | |
| 3870 | +} | |
| 3871 | +inline void strings__Builder_write_string2(strings__Builder* b, string s1, string s2) { | |
| 3872 | + if (s1.len != 0) { | |
| 3873 | + builtin__array_push_many(b, s1.str, s1.len); | |
| 3874 | + } | |
| 3875 | + if (s2.len != 0) { | |
| 3876 | + builtin__array_push_many(b, s2.str, s2.len); | |
| 3877 | + } | |
| 3878 | +} | |
| 3879 | +void strings__Builder_go_back(strings__Builder* b, int n) { | |
| 3880 | + builtin__array_trim(b, b->len - n); | |
| 3881 | +} | |
| 3882 | +inline string strings__Builder_spart(strings__Builder* b, int start_pos, int n) { | |
| 3883 | + { // Unsafe block | |
| 3884 | + u8* x = builtin__malloc_noscan(n + 1); | |
| 3885 | + builtin__vmemcpy(x, ((u8*)(b->data)) + start_pos, n); | |
| 3886 | + x[n] = 0; | |
| 3887 | + return builtin__tos(x, n); | |
| 3888 | + } | |
| 3889 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 3890 | +} | |
| 3891 | +string strings__Builder_cut_last(strings__Builder* b, int n) { | |
| 3892 | + int cut_pos = b->len - n; | |
| 3893 | + string res = strings__Builder_spart(b, cut_pos, n); | |
| 3894 | + builtin__array_trim(b, cut_pos); | |
| 3895 | + return res; | |
| 3896 | +} | |
| 3897 | +string strings__Builder_cut_to(strings__Builder* b, int pos) { | |
| 3898 | + if (pos > b->len) { | |
| 3899 | + return _S(""); | |
| 3900 | + } | |
| 3901 | + return strings__Builder_cut_last(b, b->len - pos); | |
| 3902 | +} | |
| 3903 | +void strings__Builder_go_back_to(strings__Builder* b, int pos) { | |
| 3904 | + builtin__array_trim(b, pos); | |
| 3905 | +} | |
| 3906 | +inline void strings__Builder_writeln(strings__Builder* b, string s) { | |
| 3907 | + if ((s).len != 0) { | |
| 3908 | + builtin__array_push_many(b, s.str, s.len); | |
| 3909 | + } | |
| 3910 | + builtin__array_push((array*)b, _MOV((u8[]){ ((u8)('\n')) })); | |
| 3911 | +} | |
| 3912 | +inline void strings__Builder_writeln2(strings__Builder* b, string s1, string s2) { | |
| 3913 | + if ((s1).len != 0) { | |
| 3914 | + builtin__array_push_many(b, s1.str, s1.len); | |
| 3915 | + } | |
| 3916 | + builtin__array_push((array*)b, _MOV((u8[]){ ((u8)('\n')) })); | |
| 3917 | + if ((s2).len != 0) { | |
| 3918 | + builtin__array_push_many(b, s2.str, s2.len); | |
| 3919 | + } | |
| 3920 | + builtin__array_push((array*)b, _MOV((u8[]){ ((u8)('\n')) })); | |
| 3921 | +} | |
| 3922 | +string strings__Builder_last_n(strings__Builder* b, int n) { | |
| 3923 | + if (n > b->len) { | |
| 3924 | + return _S(""); | |
| 3925 | + } | |
| 3926 | + return strings__Builder_spart(b, b->len - n, n); | |
| 3927 | +} | |
| 3928 | +string strings__Builder_after(strings__Builder* b, int n) { | |
| 3929 | + if (n >= b->len) { | |
| 3930 | + return _S(""); | |
| 3931 | + } | |
| 3932 | + return strings__Builder_spart(b, n, b->len - n); | |
| 3933 | +} | |
| 3934 | +string strings__Builder_str(strings__Builder* b) { | |
| 3935 | + builtin__array_push((array*)b, _MOV((u8[]){ ((u8)(0)) })); | |
| 3936 | + u8* bcopy = ((u8*)(builtin__memdup_noscan(b->data, b->len))); | |
| 3937 | + string s = builtin__u8_vstring_with_len(bcopy, b->len - 1); | |
| 3938 | + builtin__array_clear(b); | |
| 3939 | + return s; | |
| 3940 | +} | |
| 3941 | +void strings__Builder_ensure_cap(strings__Builder* b, int n) { | |
| 3942 | + Array_u8* arr = ((Array_u8*)(b)); | |
| 3943 | + builtin__array_ensure_cap(arr, n); | |
| 3944 | +} | |
| 3945 | +void strings__Builder_grow_len(strings__Builder* b, int n) { | |
| 3946 | + if (n <= 0) { | |
| 3947 | + return; | |
| 3948 | + } | |
| 3949 | + int new_len = b->len + n; | |
| 3950 | + strings__Builder_ensure_cap(b, new_len); | |
| 3951 | + { // Unsafe block | |
| 3952 | + b->len = new_len; | |
| 3953 | + } | |
| 3954 | +} | |
| 3955 | +void strings__Builder_free(strings__Builder* b) { | |
| 3956 | + if (b->data != 0) { | |
| 3957 | + Array_u8* arr = ((Array_u8*)(b)); | |
| 3958 | + builtin__array_free(arr); | |
| 3959 | + } | |
| 3960 | +} | |
| 3961 | +void strings__Builder_write_repeated_rune(strings__Builder* b, rune r, int count) { | |
| 3962 | + if (count <= 0) { | |
| 3963 | + return; | |
| 3964 | + } | |
| 3965 | + Array_fixed_u8_5 buffer = {0}; | |
| 3966 | + string res = builtin__utf32_to_str_no_malloc(((u32)(r)), &buffer[0]); | |
| 3967 | + if (res.len == 0) { | |
| 3968 | + return; | |
| 3969 | + } | |
| 3970 | + if (res.len == 1) { | |
| 3971 | + strings__Builder_ensure_cap(b, b->len + count); | |
| 3972 | + { // Unsafe block | |
| 3973 | + builtin__vmemset(((u8*)(b->data)) + b->len, buffer[0], count); | |
| 3974 | + b->len += count; | |
| 3975 | + } | |
| 3976 | + return; | |
| 3977 | + } else { | |
| 3978 | + int total_needed = count * res.len; | |
| 3979 | + strings__Builder_ensure_cap(b, b->len + total_needed); | |
| 3980 | + u8* dest = ((u8*)(b->data)) + b->len; | |
| 3981 | + for (int _t1 = 0; _t1 < count; ++_t1) { | |
| 3982 | + { // Unsafe block | |
| 3983 | + builtin__vmemcpy(dest, res.str, res.len); | |
| 3984 | + dest += res.len; | |
| 3985 | + } | |
| 3986 | + } | |
| 3987 | + { // Unsafe block | |
| 3988 | + b->len += total_needed; | |
| 3989 | + } | |
| 3990 | + } | |
| 3991 | +} | |
| 3992 | +void strings__Builder_indent(strings__Builder* b, string s, strings__IndentParam param) { | |
| 3993 | + if (s.len == 0) { | |
| 3994 | + return; | |
| 3995 | + } | |
| 3996 | + strings__IndentState state = strings__IndentState__normal; | |
| 3997 | + int indent_level = param.starting_level; | |
| 3998 | + rune string_char = '\0'; | |
| 3999 | + bool at_line_start = true; | |
| 4000 | + for (int i = 0; i < s.len; i++) { | |
| 4001 | + rune c = ((rune)(s.str[ i])); | |
| 4002 | + | |
| 4003 | + if (state == (strings__IndentState__normal)) { | |
| 4004 | + | |
| 4005 | + if (c == ('"') || c == ('\'')) { | |
| 4006 | + state = strings__IndentState__in_string; | |
| 4007 | + string_char = c; | |
| 4008 | + if (at_line_start) { | |
| 4009 | + strings__Builder_write_repeated_rune(b, param.indent_char, indent_level * param.indent_count); | |
| 4010 | + at_line_start = false; | |
| 4011 | + } | |
| 4012 | + strings__Builder_write_rune(b, c); | |
| 4013 | + } | |
| 4014 | + else if (c == (param.block_start)) { | |
| 4015 | + if (at_line_start) { | |
| 4016 | + strings__Builder_write_repeated_rune(b, param.indent_char, indent_level * param.indent_count); | |
| 4017 | + at_line_start = false; | |
| 4018 | + } | |
| 4019 | + strings__Builder_write_rune(b, c); | |
| 4020 | + if (i + 1 < s.len && s.str[ i + 1] == param.block_end) { | |
| 4021 | + strings__Builder_write_rune(b, param.block_end); | |
| 4022 | + i++; | |
| 4023 | + } else { | |
| 4024 | + indent_level++; | |
| 4025 | + strings__Builder_write_rune(b, '\n'); | |
| 4026 | + at_line_start = true; | |
| 4027 | + } | |
| 4028 | + } | |
| 4029 | + else if (c == (param.block_end)) { | |
| 4030 | + if (indent_level > 0) { | |
| 4031 | + indent_level--; | |
| 4032 | + } | |
| 4033 | + if (!at_line_start) { | |
| 4034 | + strings__Builder_write_rune(b, '\n'); | |
| 4035 | + } | |
| 4036 | + strings__Builder_write_repeated_rune(b, param.indent_char, indent_level * param.indent_count); | |
| 4037 | + at_line_start = false; | |
| 4038 | + strings__Builder_write_rune(b, c); | |
| 4039 | + } | |
| 4040 | + else if (c == (' ') || c == ('\t') || c == ('\r') || c == ('\n')) { | |
| 4041 | + if (!at_line_start) { | |
| 4042 | + strings__Builder_write_rune(b, c); | |
| 4043 | + } | |
| 4044 | + if (c == '\n') { | |
| 4045 | + at_line_start = true; | |
| 4046 | + } | |
| 4047 | + } | |
| 4048 | + else { | |
| 4049 | + if (at_line_start) { | |
| 4050 | + strings__Builder_write_repeated_rune(b, param.indent_char, indent_level * param.indent_count); | |
| 4051 | + at_line_start = false; | |
| 4052 | + } | |
| 4053 | + strings__Builder_write_rune(b, c); | |
| 4054 | + } | |
| 4055 | + } | |
| 4056 | + else if (state == (strings__IndentState__in_string)) { | |
| 4057 | + strings__Builder_write_rune(b, c); | |
| 4058 | + if (c == string_char) { | |
| 4059 | + if (s.str[ i - 1] != '\\') { | |
| 4060 | + state = strings__IndentState__normal; | |
| 4061 | + string_char = '\0'; | |
| 4062 | + } | |
| 4063 | + } | |
| 4064 | + } | |
| 4065 | + } | |
| 4066 | +} | |
| 4067 | +inline VV_LOC int strings__min(int a, int b, int c) { | |
| 4068 | + int m = a; | |
| 4069 | + if (b < m) { | |
| 4070 | + m = b; | |
| 4071 | + } | |
| 4072 | + if (c < m) { | |
| 4073 | + m = c; | |
| 4074 | + } | |
| 4075 | + return m; | |
| 4076 | +} | |
| 4077 | +inline VV_LOC int strings__max2(int a, int b) { | |
| 4078 | + if (a < b) { | |
| 4079 | + return b; | |
| 4080 | + } | |
| 4081 | + return a; | |
| 4082 | +} | |
| 4083 | +inline VV_LOC int strings__min2(int a, int b) { | |
| 4084 | + if (a < b) { | |
| 4085 | + return a; | |
| 4086 | + } | |
| 4087 | + return b; | |
| 4088 | +} | |
| 4089 | +inline VV_LOC int strings__abs2(int a, int b) { | |
| 4090 | + if (a < b) { | |
| 4091 | + return b - a; | |
| 4092 | + } | |
| 4093 | + return a - b; | |
| 4094 | +} | |
| 4095 | +int strings__levenshtein_distance(string a, string b) { | |
| 4096 | + if (a.len == 0) { | |
| 4097 | + return b.len; | |
| 4098 | + } | |
| 4099 | + if (b.len == 0) { | |
| 4100 | + return a.len; | |
| 4101 | + } | |
| 4102 | + if (builtin__string__eq(a, b)) { | |
| 4103 | + return 0; | |
| 4104 | + } | |
| 4105 | + Array_int row = builtin____new_array_with_default(a.len + 1, 0, sizeof(int), 0); | |
| 4106 | + { | |
| 4107 | + int* pelem = (int*)row.data; | |
| 4108 | + for (int index=0; index<row.len; index++, pelem++) { | |
| 4109 | + int it = index; | |
| 4110 | + *pelem = index; | |
| 4111 | + } | |
| 4112 | + } | |
| 4113 | + ; | |
| 4114 | + for (int i = 1; i < b.len + 1; i++) { | |
| 4115 | + int prev = i; | |
| 4116 | + for (int j = 1; j < a.len + 1; j++) { | |
| 4117 | + int current = ((int*)row.data)[j - 1]; | |
| 4118 | + if (b.str[ i - 1] != a.str[ j - 1]) { | |
| 4119 | + current = strings__min(((int*)row.data)[j - 1] + 1, prev + 1, ((int*)row.data)[j] + 1); | |
| 4120 | + } | |
| 4121 | + ((int*)row.data)[j - 1] = prev; | |
| 4122 | + prev = current; | |
| 4123 | + } | |
| 4124 | + ((int*)row.data)[a.len] = prev; | |
| 4125 | + } | |
| 4126 | + return ((int*)row.data)[a.len]; | |
| 4127 | +} | |
| 4128 | +f32 strings__levenshtein_distance_percentage(string a, string b) { | |
| 4129 | + int d = strings__levenshtein_distance(a, b); | |
| 4130 | + int l = (a.len >= b.len ? (a.len) : (b.len)); | |
| 4131 | + return (((f32)(1.00)) - ((f32)(d)) / ((f32)(l))) * ((f32)(100.00)); | |
| 4132 | +} | |
| 4133 | +f32 strings__dice_coefficient(string s1, string s2) { | |
| 4134 | + if (s1.len == 0 || s2.len == 0) { | |
| 4135 | + return 0.0; | |
| 4136 | + } | |
| 4137 | + if (builtin__string__eq(s1, s2)) { | |
| 4138 | + return 1.0; | |
| 4139 | + } | |
| 4140 | + if (s1.len < 2 || s2.len < 2) { | |
| 4141 | + return 0.0; | |
| 4142 | + } | |
| 4143 | + string a = (s1.len > s2.len ? (s1) : (s2)); | |
| 4144 | + string b = (builtin__string__eq(a, s1) ? (s2) : (s1)); | |
| 4145 | + Map_string_int first_bigrams = builtin__new_map(sizeof(string), sizeof(int), &builtin__map_hash_string, &builtin__map_eq_string, &builtin__map_clone_string, &builtin__map_free_string) | |
| 4146 | + ; | |
| 4147 | + for (int i = 0; i < a.len - 1; ++i) { | |
| 4148 | + string bigram = builtin__string_substr(a, i, i + 2); | |
| 4149 | + int q = (_IN_MAP(ADDR(string, bigram), ADDR(map, first_bigrams)) ? ((*(int*)builtin__map_get(ADDR(map, first_bigrams), &(string[]){bigram}, &(int[]){ 0 })) + 1) : (1)); | |
| 4150 | + builtin__map_set(&first_bigrams, &(string[]){bigram}, &(int[]) { q }); | |
| 4151 | + } | |
| 4152 | + int intersection_size = 0; | |
| 4153 | + for (int i = 0; i < b.len - 1; ++i) { | |
| 4154 | + string bigram = builtin__string_substr(b, i, i + 2); | |
| 4155 | + int count = (_IN_MAP(ADDR(string, bigram), ADDR(map, first_bigrams)) ? ((*(int*)builtin__map_get(ADDR(map, first_bigrams), &(string[]){bigram}, &(int[]){ 0 }))) : (0)); | |
| 4156 | + if (count > 0) { | |
| 4157 | + builtin__map_set(&first_bigrams, &(string[]){bigram}, &(int[]) { count - 1 }); | |
| 4158 | + intersection_size++; | |
| 4159 | + } | |
| 4160 | + } | |
| 4161 | + return (((f32)(2.0)) * ((f32)(intersection_size))) / (((f32)(a.len)) + ((f32)(b.len)) - 2); | |
| 4162 | +} | |
| 4163 | +int strings__hamming_distance(string a, string b) { | |
| 4164 | + if (a.len == 0 && b.len == 0) { | |
| 4165 | + return 0; | |
| 4166 | + } | |
| 4167 | + int match_len = strings__min2(a.len, b.len); | |
| 4168 | + int diff_count = strings__abs2(a.len, b.len); | |
| 4169 | + for (int i = 0; i < match_len; ++i) { | |
| 4170 | + if (a.str[ i] != b.str[ i]) { | |
| 4171 | + diff_count++; | |
| 4172 | + } | |
| 4173 | + } | |
| 4174 | + return diff_count; | |
| 4175 | +} | |
| 4176 | +f32 strings__hamming_similarity(string a, string b) { | |
| 4177 | + int l = strings__max2(a.len, b.len); | |
| 4178 | + if (l == 0) { | |
| 4179 | + return 1.0; | |
| 4180 | + } | |
| 4181 | + int d = strings__hamming_distance(a, b); | |
| 4182 | + return ((f32)(1.00)) - ((f32)(d)) / ((f32)(l)); | |
| 4183 | +} | |
| 4184 | +f64 strings__jaro_similarity(string a, string b) { | |
| 4185 | + int a_len = a.len; | |
| 4186 | + int b_len = b.len; | |
| 4187 | + if (a_len == 0 && b_len == 0) { | |
| 4188 | + return 1.0; | |
| 4189 | + } | |
| 4190 | + if (a_len == 0 || b_len == 0) { | |
| 4191 | + return 0; | |
| 4192 | + } | |
| 4193 | + int match_distance = strings__max2(VSAFE_DIV_int(strings__max2(a_len, b_len) , 2) - 1, 0); | |
| 4194 | + Array_bool a_matches = builtin____new_array_with_default(a_len, 0, sizeof(bool), 0); | |
| 4195 | + Array_bool b_matches = builtin____new_array_with_default(b_len, 0, sizeof(bool), 0); | |
| 4196 | + int matches = 0; | |
| 4197 | + f64 transpositions = 0.0; | |
| 4198 | + for (int i = 0; i < a_len; ++i) { | |
| 4199 | + int start = strings__max2(0, (int)(i - match_distance)); | |
| 4200 | + int end = strings__min2(b_len, (int)(i + match_distance) + 1); | |
| 4201 | + for (int k = start; k < end; ++k) { | |
| 4202 | + if (((bool*)b_matches.data)[k]) { | |
| 4203 | + continue; | |
| 4204 | + } | |
| 4205 | + if (a.str[ i] != b.str[ k]) { | |
| 4206 | + continue; | |
| 4207 | + } | |
| 4208 | + ((bool*)a_matches.data)[i] = true; | |
| 4209 | + ((bool*)b_matches.data)[k] = true; | |
| 4210 | + matches++; | |
| 4211 | + break; | |
| 4212 | + } | |
| 4213 | + } | |
| 4214 | + if (matches == 0) { | |
| 4215 | + return 0; | |
| 4216 | + } | |
| 4217 | + int k = 0; | |
| 4218 | + for (int i = 0; i < a_len; ++i) { | |
| 4219 | + if (!((bool*)a_matches.data)[i]) { | |
| 4220 | + continue; | |
| 4221 | + } | |
| 4222 | + for (;;) { | |
| 4223 | + if (!(!((bool*)b_matches.data)[k])) break; | |
| 4224 | + k++; | |
| 4225 | + } | |
| 4226 | + if (a.str[ i] != b.str[ k]) { | |
| 4227 | + transpositions++; | |
| 4228 | + } | |
| 4229 | + k++; | |
| 4230 | + } | |
| 4231 | + transpositions /= 2; | |
| 4232 | + return ((f64)(matches / ((f64)(a_len))) + (f64)(matches / ((f64)(b_len))) + (f64)(((f64)(matches - transpositions)) / matches)) / 3; | |
| 4233 | +} | |
| 4234 | +f64 strings__jaro_winkler_similarity(string a, string b) { | |
| 4235 | + int lmax = strings__min2(4, strings__min2(a.len, b.len)); | |
| 4236 | + int l = 0; | |
| 4237 | + for (int i = 0; i < lmax; ++i) { | |
| 4238 | + if (a.str[ i] == b.str[ i]) { | |
| 4239 | + l++; | |
| 4240 | + } | |
| 4241 | + } | |
| 4242 | + f64 js = strings__jaro_similarity(a, b); | |
| 4243 | + f64 p = 0.1; | |
| 4244 | + f64 ws = js + ((f64)(l)) * p * (1 - js); | |
| 4245 | + return ws; | |
| 4246 | +} | |
| 4247 | +string strings__repeat(u8 c, int n) { | |
| 4248 | + if (n <= 0) { | |
| 4249 | + return _S(""); | |
| 4250 | + } | |
| 4251 | + u8* bytes = builtin__malloc_noscan(n + 1); | |
| 4252 | + { // Unsafe block | |
| 4253 | + memset(bytes, c, n); | |
| 4254 | + bytes[n] = 0; | |
| 4255 | + } | |
| 4256 | + return builtin__u8_vstring_with_len(bytes, n); | |
| 4257 | +} | |
| 4258 | +string strings__repeat_string(string s, int n) { | |
| 4259 | + if (n <= 0 || s.len == 0) { | |
| 4260 | + return _S(""); | |
| 4261 | + } | |
| 4262 | + int slen = s.len; | |
| 4263 | + int blen = slen * n; | |
| 4264 | + u8* bytes = builtin__malloc_noscan(blen + 1); | |
| 4265 | + for (int bi = 0; bi < n; ++bi) { | |
| 4266 | + int bislen = (int)(bi * slen); | |
| 4267 | + for (int si = 0; si < slen; ++si) { | |
| 4268 | + { // Unsafe block | |
| 4269 | + bytes[(int)(bislen + si)] = s.str[ si]; | |
| 4270 | + } | |
| 4271 | + } | |
| 4272 | + } | |
| 4273 | + { // Unsafe block | |
| 4274 | + bytes[blen] = 0; | |
| 4275 | + } | |
| 4276 | + return builtin__u8_vstring_with_len(bytes, blen); | |
| 4277 | +} | |
| 4278 | +string strings__find_between_pair_u8(string input, u8 start, u8 end) { | |
| 4279 | + int marks = 0; | |
| 4280 | + int start_index = -1; | |
| 4281 | + for (int i = 0; i < input.len; ++i) { | |
| 4282 | + u8 b = input.str[i]; | |
| 4283 | + if (b == start) { | |
| 4284 | + if (start_index == -1) { | |
| 4285 | + start_index = i + 1; | |
| 4286 | + } | |
| 4287 | + marks++; | |
| 4288 | + continue; | |
| 4289 | + } | |
| 4290 | + if (start_index > 0) { | |
| 4291 | + if (b == end) { | |
| 4292 | + marks--; | |
| 4293 | + if (marks == 0) { | |
| 4294 | + return builtin__string_substr(input, start_index, i); | |
| 4295 | + } | |
| 4296 | + } | |
| 4297 | + } | |
| 4298 | + } | |
| 4299 | + return _S(""); | |
| 4300 | +} | |
| 4301 | +string strings__find_between_pair_rune(string input, rune start, rune end) { | |
| 4302 | + int marks = 0; | |
| 4303 | + int start_index = -1; | |
| 4304 | + Array_rune runes = builtin__string_runes(input); | |
| 4305 | + for (int i = 0; i < runes.len; ++i) { | |
| 4306 | + rune r = ((rune*)runes.data)[i]; | |
| 4307 | + if (r == start) { | |
| 4308 | + if (start_index == -1) { | |
| 4309 | + start_index = i + 1; | |
| 4310 | + } | |
| 4311 | + marks++; | |
| 4312 | + continue; | |
| 4313 | + } | |
| 4314 | + if (start_index > 0) { | |
| 4315 | + if (r == end) { | |
| 4316 | + marks--; | |
| 4317 | + if (marks == 0) { | |
| 4318 | + return Array_rune_string(builtin__array_slice(runes, start_index, i)); | |
| 4319 | + } | |
| 4320 | + } | |
| 4321 | + } | |
| 4322 | + } | |
| 4323 | + return _S(""); | |
| 4324 | +} | |
| 4325 | +string strings__find_between_pair_string(string input, string start, string end) { | |
| 4326 | + int start_index = -1; | |
| 4327 | + int marks = 0; | |
| 4328 | + Array_rune start_runes = builtin__string_runes(start); | |
| 4329 | + Array_rune end_runes = builtin__string_runes(end); | |
| 4330 | + Array_rune runes = builtin__string_runes(input); | |
| 4331 | + int i = 0; | |
| 4332 | + for (; i < runes.len; i++) { | |
| 4333 | + Array_rune start_slice = builtin__array_slice_ni(runes, i, i + start_runes.len); | |
| 4334 | + if (Array_rune_arr_eq(start_slice, start_runes)) { | |
| 4335 | + i = i + start_runes.len - 1; | |
| 4336 | + if (start_index < 0) { | |
| 4337 | + start_index = i + 1; | |
| 4338 | + } | |
| 4339 | + marks++; | |
| 4340 | + continue; | |
| 4341 | + } | |
| 4342 | + if (start_index > 0) { | |
| 4343 | + Array_rune end_slice = builtin__array_slice_ni(runes, i, i + end_runes.len); | |
| 4344 | + if (Array_rune_arr_eq(end_slice, end_runes)) { | |
| 4345 | + marks--; | |
| 4346 | + if (marks == 0) { | |
| 4347 | + return Array_rune_string(builtin__array_slice(runes, start_index, i)); | |
| 4348 | + } | |
| 4349 | + i = i + end_runes.len - 1; | |
| 4350 | + continue; | |
| 4351 | + } | |
| 4352 | + } | |
| 4353 | + } | |
| 4354 | + return _S(""); | |
| 4355 | +} | |
| 4356 | +Array_string strings__split_capital(string s) { | |
| 4357 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | |
| 4358 | + int word_start = 0; | |
| 4359 | + for (int idx = 0; idx < s.len; ++idx) { | |
| 4360 | + u8 c = s.str[idx]; | |
| 4361 | + if (builtin__u8_is_capital(c)) { | |
| 4362 | + if (word_start != idx) { | |
| 4363 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr_ni(s, word_start, idx) })); | |
| 4364 | + } | |
| 4365 | + word_start = idx; | |
| 4366 | + continue; | |
| 4367 | + } | |
| 4368 | + } | |
| 4369 | + if (word_start != s.len) { | |
| 4370 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr_ni(s, word_start, 2147483647) })); | |
| 4371 | + } | |
| 4372 | + return res; | |
| 4373 | +} | |
| 4374 | +inline VV_LOC bool builtin__closure__is_ppc64(void) { | |
| 4375 | + #if 0 | |
| 4376 | + { | |
| 4377 | + } | |
| 4378 | + #else | |
| 4379 | + { | |
| 4380 | + return false; | |
| 4381 | + } | |
| 4382 | + #endif | |
| 4383 | + return 0; | |
| 4384 | +} | |
| 4385 | +inline VV_LOC voidptr* builtin__closure__closure_slot_meta(voidptr exec_ptr) { | |
| 4386 | + return ((voidptr*)(((u8*)(exec_ptr)) - _const_builtin__closure__assumed_page_size)); | |
| 4387 | +} | |
| 4388 | +VV_LOC void builtin__closure__closure_register_page(voidptr exec_page_start) { | |
| 4389 | + { // Unsafe block | |
| 4390 | + builtin__closure__ClosurePage* node = ((builtin__closure__ClosurePage*)(builtin___v_malloc(sizeof(builtin__closure__ClosurePage)))); | |
| 4391 | + *node = ((builtin__closure__ClosurePage){.next = g_closure.pages,.exec_page_start = exec_page_start,}); | |
| 4392 | + g_closure.pages = node; | |
| 4393 | + } | |
| 4394 | +} | |
| 4395 | +VV_LOC bool builtin__closure__closure_is_managed(voidptr exec_ptr) { | |
| 4396 | + if (builtin__isnil(exec_ptr)) { | |
| 4397 | + return false; | |
| 4398 | + } | |
| 4399 | + usize exec_addr = ((usize)(exec_ptr)); | |
| 4400 | + builtin__closure__ClosurePage* page = g_closure.pages; | |
| 4401 | + for (;;) { | |
| 4402 | + if (!(page != ((void*)0))) break; | |
| 4403 | + usize page_addr = ((usize)(page->exec_page_start)); | |
| 4404 | + if (exec_addr >= page_addr && exec_addr < page_addr + ((usize)(g_closure.v_page_size))) { | |
| 4405 | + usize slot_offset = exec_addr - page_addr; | |
| 4406 | + return slot_offset >= ((usize)(_const_builtin__closure__closure_size)) && VSAFE_MOD_usize(slot_offset , ((usize)(_const_builtin__closure__closure_size))) == 0; | |
| 4407 | + } | |
| 4408 | + page = page->next; | |
| 4409 | + } | |
| 4410 | + return false; | |
| 4411 | +} | |
| 4412 | +VV_LOC builtin__closure__ClosureLiveInfo builtin__closure__closure_live_delete(voidptr exec_ptr) { | |
| 4413 | + builtin__closure__ClosureLiveInfo* _t2 = (builtin__closure__ClosureLiveInfo*)(builtin__map_get_check(ADDR(map, g_closure.live), &(voidptr[]){exec_ptr})); | |
| 4414 | + _option_builtin__closure__ClosureLiveInfo _t1 = {0}; | |
| 4415 | + if (_t2) { | |
| 4416 | + *((builtin__closure__ClosureLiveInfo*)&_t1.data) = *((builtin__closure__ClosureLiveInfo*)_t2); | |
| 4417 | + } else { | |
| 4418 | + _t1.state = 2; _t1.err = builtin___v_error(_S("map key does not exist")); | |
| 4419 | + } | |
| 4420 | + | |
| 4421 | + if (_t1.state == 0) { | |
| 4422 | + builtin__closure__ClosureLiveInfo info = (*(builtin__closure__ClosureLiveInfo*)_t1.data); | |
| 4423 | + (*(builtin__closure__ClosureLiveInfo*)builtin__map_get_and_set((map*)&g_closure.live, &(voidptr[]){exec_ptr}, &(builtin__closure__ClosureLiveInfo[]){ (builtin__closure__ClosureLiveInfo){.ctx = 0,.owns_data = 0,.generation = 0,} })) = ((builtin__closure__ClosureLiveInfo){.ctx = 0,.owns_data = 0,.generation = 0,}); | |
| 4424 | + builtin__map_delete(&g_closure.live, &(voidptr[]){exec_ptr}); | |
| 4425 | + return info; | |
| 4426 | + } | |
| 4427 | + if (_t1.state == 2 && _t1.err._object != _const_none__._object) { builtin___v_free(_t1.err._object); } | |
| 4428 | + return ((builtin__closure__ClosureLiveInfo){.ctx = 0,.owns_data = 0,.generation = 0,}); | |
| 4429 | +} | |
| 4430 | +VV_LOC builtin__closure__ClosureLifetimeState* builtin__closure__new_closure_lifetime_state_no_lock(void) { | |
| 4431 | + builtin__closure__ClosureLifetimeState* state = g_closure.free_lifetime_states; | |
| 4432 | + if (!builtin__isnil(state)) { | |
| 4433 | + g_closure.free_lifetime_states = state->next_free; | |
| 4434 | + } else { | |
| 4435 | + { // Unsafe block | |
| 4436 | + state = ((builtin__closure__ClosureLifetimeState*)(builtin___v_malloc(sizeof(builtin__closure__ClosureLifetimeState)))); | |
| 4437 | + } | |
| 4438 | + g_closure.lifetime_state_allocs++; | |
| 4439 | + } | |
| 4440 | + g_closure.next_lifetime_generation++; | |
| 4441 | + { // Unsafe block | |
| 4442 | + *state = ((builtin__closure__ClosureLifetimeState){.owner_thread = builtin__closure__closure_current_thread_id_platform(),.active = 0,.disposed = 0,.suspended = 0,.frame_start = 0,.frame_gen = 0,.generation = g_closure.next_lifetime_generation,.frame_generation = 0,.records = builtin____new_array(0, 0, sizeof(builtin__closure__ClosureLifetimeRecord)),.frames = builtin____new_array(0, 0, sizeof(builtin__closure__ClosureLifetimeFrame)),.next_free = ((void*)0),}); | |
| 4443 | + } | |
| 4444 | + return state; | |
| 4445 | +} | |
| 4446 | +VV_LOC builtin__closure__ClosureLifetimeState* builtin__closure__new_closure_lifetime_state(void) { | |
| 4447 | + builtin__closure__closure_mtx_lock_platform(); | |
| 4448 | + builtin__closure__ClosureLifetimeState* state = builtin__closure__new_closure_lifetime_state_no_lock(); | |
| 4449 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4450 | + return state; | |
| 4451 | +} | |
| 4452 | +VV_LOC void builtin__closure__closure_lifetime_recycle_state_no_lock(builtin__closure__ClosureLifetimeState** state) { | |
| 4453 | + (*state)->disposed = true; | |
| 4454 | + (*state)->active = false; | |
| 4455 | + (*state)->suspended = 0; | |
| 4456 | + (*state)->frame_start = 0; | |
| 4457 | + (*state)->frame_gen = 0; | |
| 4458 | + (*state)->frame_generation = 0; | |
| 4459 | + { // Unsafe block | |
| 4460 | + builtin__array_free(&(*state)->records); | |
| 4461 | + builtin__array_free(&(*state)->frames); | |
| 4462 | + } | |
| 4463 | + (*state)->records = builtin____new_array_with_default(0, 0, sizeof(builtin__closure__ClosureLifetimeRecord), 0); | |
| 4464 | + (*state)->frames = builtin____new_array_with_default(0, 0, sizeof(builtin__closure__ClosureLifetimeFrame), 0); | |
| 4465 | + (*state)->next_free = g_closure.free_lifetime_states; | |
| 4466 | + g_closure.free_lifetime_states = *state; | |
| 4467 | +} | |
| 4468 | +VV_LOC string builtin__closure__closure_lifetime_error(builtin__closure__ClosureLifetimeState* state, u64 generation, u64 thread_id) { | |
| 4469 | + if (state->disposed || state->generation != generation) { | |
| 4470 | + return _S("closure lifetime used after dispose"); | |
| 4471 | + } | |
| 4472 | + if (state->owner_thread != thread_id) { | |
| 4473 | + return _S("closure lifetime used from a different thread"); | |
| 4474 | + } | |
| 4475 | + return _S(""); | |
| 4476 | +} | |
| 4477 | +VV_LOC _result_builtin__closure__ClosureLifetimeState_ptr builtin__closure__Lifetime_ensure_state(builtin__closure__Lifetime* lifetime) { | |
| 4478 | + builtin__closure__closure_ensure_initialized(); | |
| 4479 | + if (builtin__isnil(lifetime->state)) { | |
| 4480 | + if (lifetime->disposed) { | |
| 4481 | + return (_result_builtin__closure__ClosureLifetimeState_ptr){ .is_error=true, .err=builtin___v_error(_S("closure lifetime used after dispose")), .data={E_STRUCT} }; | |
| 4482 | + } | |
| 4483 | + lifetime->state = builtin__closure__new_closure_lifetime_state(); | |
| 4484 | + lifetime->generation = lifetime->state->generation; | |
| 4485 | + _result_builtin__closure__ClosureLifetimeState_ptr _t2; | |
| 4486 | + builtin___result_ok(&(builtin__closure__ClosureLifetimeState*[]) { lifetime->state }, (_result*)(&_t2), sizeof(builtin__closure__ClosureLifetimeState*)); | |
| 4487 | + | |
| 4488 | + return _t2; | |
| 4489 | + } | |
| 4490 | + builtin__closure__closure_mtx_lock_platform(); | |
| 4491 | + builtin__closure__ClosureLifetimeState* state = lifetime->state; | |
| 4492 | + if (lifetime->disposed || state->disposed || state->generation != lifetime->generation) { | |
| 4493 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4494 | + return (_result_builtin__closure__ClosureLifetimeState_ptr){ .is_error=true, .err=builtin___v_error(_S("closure lifetime used after dispose")), .data={E_STRUCT} }; | |
| 4495 | + } | |
| 4496 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4497 | + _result_builtin__closure__ClosureLifetimeState_ptr _t4; | |
| 4498 | + builtin___result_ok(&(builtin__closure__ClosureLifetimeState*[]) { state }, (_result*)(&_t4), sizeof(builtin__closure__ClosureLifetimeState*)); | |
| 4499 | + | |
| 4500 | + return _t4; | |
| 4501 | +} | |
| 4502 | +VV_LOC voidptr builtin__closure__closure_slot_data(voidptr exec_ptr) { | |
| 4503 | + { // Unsafe block | |
| 4504 | + voidptr* p = builtin__closure__closure_slot_meta(exec_ptr); | |
| 4505 | + if (builtin__closure__is_ppc64()) { | |
| 4506 | + return p[2]; | |
| 4507 | + } | |
| 4508 | + return p[0]; | |
| 4509 | + } | |
| 4510 | + return 0; | |
| 4511 | +} | |
| 4512 | +VV_LOC bool builtin__closure__closure_release_no_lock(voidptr exec_ptr, u64 generation) { | |
| 4513 | + if (!builtin__closure__closure_is_managed(exec_ptr)) { | |
| 4514 | + return false; | |
| 4515 | + } | |
| 4516 | + builtin__closure__ClosureLiveInfo* _t3 = (builtin__closure__ClosureLiveInfo*)(builtin__map_get_check(ADDR(map, g_closure.live), &(voidptr[]){exec_ptr})); | |
| 4517 | + _option_builtin__closure__ClosureLiveInfo _t2 = {0}; | |
| 4518 | + if (_t3) { | |
| 4519 | + *((builtin__closure__ClosureLiveInfo*)&_t2.data) = *((builtin__closure__ClosureLiveInfo*)_t3); | |
| 4520 | + } else { | |
| 4521 | + _t2.state = 2; _t2.err = builtin___v_error(_S("map key does not exist")); | |
| 4522 | + } | |
| 4523 | + ; | |
| 4524 | + if (_t2.state != 0) { | |
| 4525 | + return false; | |
| 4526 | + } | |
| 4527 | + | |
| 4528 | + builtin__closure__ClosureLiveInfo info = (*(builtin__closure__ClosureLiveInfo*)_t2.data); | |
| 4529 | + if (generation != 0 && info.generation != generation) { | |
| 4530 | + return false; | |
| 4531 | + } | |
| 4532 | + voidptr data = builtin__closure__closure_slot_data(exec_ptr); | |
| 4533 | + builtin__closure__closure_live_delete(exec_ptr); | |
| 4534 | + if (info.owns_data && !builtin__isnil(data)) { | |
| 4535 | + builtin___v_free(data); | |
| 4536 | + } | |
| 4537 | + { // Unsafe block | |
| 4538 | + voidptr* p = builtin__closure__closure_slot_meta(exec_ptr); | |
| 4539 | + p[0] = g_closure.free_closure_ptr; | |
| 4540 | + if (builtin__closure__is_ppc64()) { | |
| 4541 | + p[1] = ((void*)0); | |
| 4542 | + p[2] = ((void*)0); | |
| 4543 | + p[3] = ((void*)0); | |
| 4544 | + } else { | |
| 4545 | + p[1] = ((void*)0); | |
| 4546 | + } | |
| 4547 | + g_closure.free_closure_ptr = exec_ptr; | |
| 4548 | + } | |
| 4549 | + return true; | |
| 4550 | +} | |
| 4551 | +VV_LOC void builtin__closure__closure_lifetime_release_records_no_lock(Array_builtin__closure__ClosureLifetimeRecord records, int start, int end) { | |
| 4552 | + for (int i = start; i < end; ++i) { | |
| 4553 | + builtin__closure__ClosureLifetimeRecord record = (*(builtin__closure__ClosureLifetimeRecord*)builtin__array_get(records, i)); | |
| 4554 | + builtin__closure__closure_release_no_lock(record.exec_ptr, record.generation); | |
| 4555 | + } | |
| 4556 | +} | |
| 4557 | +VV_LOC void builtin__closure__closure_lifetime_reclaim_no_lock(builtin__closure__ClosureLifetimeState* state, int retain) { | |
| 4558 | + int keep = (retain < 0 ? (0) : (retain)); | |
| 4559 | + if (state->frames.len <= keep) { | |
| 4560 | + return; | |
| 4561 | + } | |
| 4562 | + int reclaim_count = state->frames.len - keep; | |
| 4563 | + int cutoff = 0; | |
| 4564 | + for (int i = 0; i < reclaim_count; ++i) { | |
| 4565 | + builtin__closure__ClosureLifetimeFrame frame = (*(builtin__closure__ClosureLifetimeFrame*)builtin__array_get(state->frames, i)); | |
| 4566 | + builtin__closure__closure_lifetime_release_records_no_lock(state->records, frame.start, frame.end); | |
| 4567 | + cutoff = frame.end; | |
| 4568 | + } | |
| 4569 | + builtin__array_delete_many(&state->frames, 0, reclaim_count); | |
| 4570 | + if (cutoff > 0) { | |
| 4571 | + builtin__array_delete_many(&state->records, 0, cutoff); | |
| 4572 | + for (int _t1 = 0; _t1 < state->frames.len; ++_t1) { | |
| 4573 | + builtin__closure__ClosureLifetimeFrame* frame = ((builtin__closure__ClosureLifetimeFrame*)state->frames.data) + _t1; | |
| 4574 | + frame->start -= cutoff; | |
| 4575 | + frame->end -= cutoff; | |
| 4576 | + } | |
| 4577 | + } | |
| 4578 | +} | |
| 4579 | +VV_LOC void builtin__closure__closure_ensure_initialized(void) { | |
| 4580 | + builtin__closure__closure_init_once_platform(); | |
| 4581 | +} | |
| 4582 | +builtin__closure__Lifetime builtin__closure__new_lifetime(void) { | |
| 4583 | + builtin__closure__closure_ensure_initialized(); | |
| 4584 | + builtin__closure__ClosureLifetimeState* state = builtin__closure__new_closure_lifetime_state(); | |
| 4585 | + return ((builtin__closure__Lifetime){.state = state,.generation = state->generation,.disposed = 0,}); | |
| 4586 | +} | |
| 4587 | +VV_LOC _result_builtin__closure__FrameToken builtin__closure__Lifetime_begin_frame(builtin__closure__Lifetime* lifetime) { | |
| 4588 | + _result_builtin__closure__ClosureLifetimeState_ptr _t1 = builtin__closure__Lifetime_ensure_state(lifetime); | |
| 4589 | + if (_t1.is_error) { | |
| 4590 | + _result_builtin__closure__FrameToken _t2 = {0}; | |
| 4591 | + _t2.is_error = true; | |
| 4592 | + _t2.err = _t1.err; | |
| 4593 | + return _t2; | |
| 4594 | + } | |
| 4595 | + | |
| 4596 | + builtin__closure__ClosureLifetimeState* state = (*(builtin__closure__ClosureLifetimeState**)_t1.data); | |
| 4597 | + u64 thread_id = builtin__closure__closure_current_thread_id_platform(); | |
| 4598 | + builtin__closure__closure_mtx_lock_platform(); | |
| 4599 | + string err = builtin__closure__closure_lifetime_error(state, lifetime->generation, thread_id); | |
| 4600 | + if ((err).len != 0) { | |
| 4601 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4602 | + return (_result_builtin__closure__FrameToken){ .is_error=true, .err=builtin___v_error(err), .data={E_STRUCT} }; | |
| 4603 | + } | |
| 4604 | + if (state->active) { | |
| 4605 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4606 | + return (_result_builtin__closure__FrameToken){ .is_error=true, .err=builtin___v_error(_S("closure lifetime frames can not be nested")), .data={E_STRUCT} }; | |
| 4607 | + } | |
| 4608 | + if (state->suspended > 0) { | |
| 4609 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4610 | + return (_result_builtin__closure__FrameToken){ .is_error=true, .err=builtin___v_error(_S("closure lifetime frame while suspended")), .data={E_STRUCT} }; | |
| 4611 | + } | |
| 4612 | + builtin__closure__ClosureLifetimeState** _t7 = (builtin__closure__ClosureLifetimeState**)(builtin__map_get_check(ADDR(map, g_closure.active_lifetimes), &(u64[]){thread_id})); | |
| 4613 | + _option_builtin__closure__ClosureLifetimeState_ptr _t6 = {0}; | |
| 4614 | + if (_t7) { | |
| 4615 | + *((builtin__closure__ClosureLifetimeState**)&_t6.data) = *((builtin__closure__ClosureLifetimeState**)_t7); | |
| 4616 | + } else { | |
| 4617 | + _t6.state = 2; _t6.err = builtin___v_error(_S("map key does not exist")); | |
| 4618 | + } | |
| 4619 | + | |
| 4620 | + if (_t6.state == 0) { | |
| 4621 | + builtin__closure__ClosureLifetimeState* _dummy_6 = (*(builtin__closure__ClosureLifetimeState**)_t6.data); | |
| 4622 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4623 | + return (_result_builtin__closure__FrameToken){ .is_error=true, .err=builtin___v_error(_S("another closure lifetime is already active on this thread")), .data={E_STRUCT} }; | |
| 4624 | + } | |
| 4625 | + if (_t6.state == 2 && _t6.err._object != _const_none__._object) { builtin___v_free(_t6.err._object); } | |
| 4626 | + state->frame_generation++; | |
| 4627 | + state->active = true; | |
| 4628 | + state->frame_start = state->records.len; | |
| 4629 | + state->frame_gen = state->frame_generation; | |
| 4630 | + (*(builtin__closure__ClosureLifetimeState**)builtin__map_get_and_set((map*)&g_closure.active_lifetimes, &(u64[]){thread_id}, &(builtin__closure__ClosureLifetimeState*[]){ 0 })) = state; | |
| 4631 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4632 | + _result_builtin__closure__FrameToken _t9; | |
| 4633 | + builtin___result_ok(&(builtin__closure__FrameToken[]) { ((builtin__closure__FrameToken){.state = state,.thread_id = thread_id,.state_generation = lifetime->generation,.generation = state->frame_generation,}) }, (_result*)(&_t9), sizeof(builtin__closure__FrameToken)); | |
| 4634 | + | |
| 4635 | + return _t9; | |
| 4636 | +} | |
| 4637 | +VV_LOC _result_void builtin__closure__Lifetime_end_frame(builtin__closure__Lifetime* lifetime, builtin__closure__FrameToken token) { | |
| 4638 | + if (builtin__isnil(token.state)) { | |
| 4639 | + return (_result_void){ .is_error=true, .err=builtin___v_error(_S("invalid closure lifetime frame token")), .data={E_STRUCT} }; | |
| 4640 | + } | |
| 4641 | + builtin__closure__ClosureLifetimeState* state = token.state; | |
| 4642 | + u64 thread_id = builtin__closure__closure_current_thread_id_platform(); | |
| 4643 | + builtin__closure__closure_mtx_lock_platform(); | |
| 4644 | + string err = builtin__closure__closure_lifetime_error(state, token.state_generation, thread_id); | |
| 4645 | + if ((err).len != 0) { | |
| 4646 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4647 | + return (_result_void){ .is_error=true, .err=builtin___v_error(err), .data={E_STRUCT} }; | |
| 4648 | + } | |
| 4649 | + if (token.thread_id != thread_id || token.generation != state->frame_gen || !state->active) { | |
| 4650 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4651 | + return (_result_void){ .is_error=true, .err=builtin___v_error(_S("invalid closure lifetime frame token")), .data={E_STRUCT} }; | |
| 4652 | + } | |
| 4653 | + builtin__array_push((array*)&state->frames, _MOV((builtin__closure__ClosureLifetimeFrame[]){ ((builtin__closure__ClosureLifetimeFrame){.start = state->frame_start,.end = state->records.len,}) })); | |
| 4654 | + state->active = false; | |
| 4655 | + state->frame_start = 0; | |
| 4656 | + state->frame_gen = 0; | |
| 4657 | + (*(builtin__closure__ClosureLifetimeState**)builtin__map_get_and_set((map*)&g_closure.active_lifetimes, &(u64[]){thread_id}, &(builtin__closure__ClosureLifetimeState*[]){ 0 })) = ((void*)0); | |
| 4658 | + builtin__map_delete(&g_closure.active_lifetimes, &(u64[]){thread_id}); | |
| 4659 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4660 | + return (_result_void){0}; | |
| 4661 | +} | |
| 4662 | +_result_void builtin__closure__Lifetime_frame(builtin__closure__Lifetime* lifetime, void (*work)(void)) { | |
| 4663 | + _result_builtin__closure__FrameToken _t1 = builtin__closure__Lifetime_begin_frame(lifetime); | |
| 4664 | + if (_t1.is_error) { | |
| 4665 | + _result_void _t2 = {0}; | |
| 4666 | + _t2.is_error = true; | |
| 4667 | + _t2.err = _t1.err; | |
| 4668 | + return _t2; | |
| 4669 | + } | |
| 4670 | + | |
| 4671 | + builtin__closure__FrameToken token = (*(builtin__closure__FrameToken*)_t1.data); | |
| 4672 | + bool ended = false; | |
| 4673 | + work(); | |
| 4674 | + _result_void _t3 = builtin__closure__Lifetime_end_frame(lifetime, token); | |
| 4675 | + if (_t3.is_error) { | |
| 4676 | + { // defer begin | |
| 4677 | + if (!ended) { | |
| 4678 | + _result_void _t4 = builtin__closure__Lifetime_end_frame(lifetime, token); | |
| 4679 | + (void)_t4; | |
| 4680 | + ; | |
| 4681 | + } | |
| 4682 | + } // defer end | |
| 4683 | + _result_void _t5 = {0}; | |
| 4684 | + _t5.is_error = true; | |
| 4685 | + _t5.err = _t3.err; | |
| 4686 | + return _t5; | |
| 4687 | + } | |
| 4688 | + | |
| 4689 | + ; | |
| 4690 | + ended = true; | |
| 4691 | + { // defer begin | |
| 4692 | + if (!ended) { | |
| 4693 | + _result_void _t6 = builtin__closure__Lifetime_end_frame(lifetime, token); | |
| 4694 | + (void)_t6; | |
| 4695 | + ; | |
| 4696 | + } | |
| 4697 | + } // defer end | |
| 4698 | + return (_result_void){0}; | |
| 4699 | +} | |
| 4700 | +_result_void builtin__closure__Lifetime_reclaim(builtin__closure__Lifetime* lifetime, int retain) { | |
| 4701 | + _result_builtin__closure__ClosureLifetimeState_ptr _t1 = builtin__closure__Lifetime_ensure_state(lifetime); | |
| 4702 | + if (_t1.is_error) { | |
| 4703 | + _result_void _t2 = {0}; | |
| 4704 | + _t2.is_error = true; | |
| 4705 | + _t2.err = _t1.err; | |
| 4706 | + return _t2; | |
| 4707 | + } | |
| 4708 | + | |
| 4709 | + builtin__closure__ClosureLifetimeState* state = (*(builtin__closure__ClosureLifetimeState**)_t1.data); | |
| 4710 | + u64 thread_id = builtin__closure__closure_current_thread_id_platform(); | |
| 4711 | + builtin__closure__closure_mtx_lock_platform(); | |
| 4712 | + string err = builtin__closure__closure_lifetime_error(state, lifetime->generation, thread_id); | |
| 4713 | + if ((err).len != 0) { | |
| 4714 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4715 | + return (_result_void){ .is_error=true, .err=builtin___v_error(err), .data={E_STRUCT} }; | |
| 4716 | + } | |
| 4717 | + if (state->active) { | |
| 4718 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4719 | + return (_result_void){ .is_error=true, .err=builtin___v_error(_S("closure lifetime reclaim while a frame is active")), .data={E_STRUCT} }; | |
| 4720 | + } | |
| 4721 | + builtin__closure__closure_lifetime_reclaim_no_lock(state, retain); | |
| 4722 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4723 | + return (_result_void){0}; | |
| 4724 | +} | |
| 4725 | +_result_void builtin__closure__Lifetime_reclaim_all(builtin__closure__Lifetime* lifetime) { | |
| 4726 | + _result_void _t1 = builtin__closure__Lifetime_reclaim(lifetime, 0); | |
| 4727 | + if (_t1.is_error) { | |
| 4728 | + _result_void _t2 = {0}; | |
| 4729 | + _t2.is_error = true; | |
| 4730 | + _t2.err = _t1.err; | |
| 4731 | + return _t2; | |
| 4732 | + } | |
| 4733 | + | |
| 4734 | + ; | |
| 4735 | + return (_result_void){0}; | |
| 4736 | +} | |
| 4737 | +_result_void builtin__closure__Lifetime_dispose(builtin__closure__Lifetime* lifetime) { | |
| 4738 | + _result_builtin__closure__ClosureLifetimeState_ptr _t1 = builtin__closure__Lifetime_ensure_state(lifetime); | |
| 4739 | + if (_t1.is_error) { | |
| 4740 | + _result_void _t2 = {0}; | |
| 4741 | + _t2.is_error = true; | |
| 4742 | + _t2.err = _t1.err; | |
| 4743 | + return _t2; | |
| 4744 | + } | |
| 4745 | + | |
| 4746 | + builtin__closure__ClosureLifetimeState* state = (*(builtin__closure__ClosureLifetimeState**)_t1.data); | |
| 4747 | + u64 thread_id = builtin__closure__closure_current_thread_id_platform(); | |
| 4748 | + builtin__closure__closure_mtx_lock_platform(); | |
| 4749 | + string err = builtin__closure__closure_lifetime_error(state, lifetime->generation, thread_id); | |
| 4750 | + if ((err).len != 0) { | |
| 4751 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4752 | + return (_result_void){ .is_error=true, .err=builtin___v_error(err), .data={E_STRUCT} }; | |
| 4753 | + } | |
| 4754 | + if (state->active) { | |
| 4755 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4756 | + return (_result_void){ .is_error=true, .err=builtin___v_error(_S("closure lifetime dispose while a frame is active")), .data={E_STRUCT} }; | |
| 4757 | + } | |
| 4758 | + if (state->suspended > 0) { | |
| 4759 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4760 | + return (_result_void){ .is_error=true, .err=builtin___v_error(_S("closure lifetime dispose while suspended")), .data={E_STRUCT} }; | |
| 4761 | + } | |
| 4762 | + builtin__closure__closure_lifetime_reclaim_no_lock(state, 0); | |
| 4763 | + lifetime->state = ((void*)0); | |
| 4764 | + lifetime->disposed = true; | |
| 4765 | + builtin__closure__closure_lifetime_recycle_state_no_lock(&state); | |
| 4766 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4767 | + return (_result_void){0}; | |
| 4768 | +} | |
| 4769 | +_result_void builtin__closure__Lifetime_suspend(builtin__closure__Lifetime* lifetime, void (*work)(void)) { | |
| 4770 | + _result_builtin__closure__ClosureLifetimeState_ptr _t1 = builtin__closure__Lifetime_ensure_state(lifetime); | |
| 4771 | + if (_t1.is_error) { | |
| 4772 | + _result_void _t2 = {0}; | |
| 4773 | + _t2.is_error = true; | |
| 4774 | + _t2.err = _t1.err; | |
| 4775 | + return _t2; | |
| 4776 | + } | |
| 4777 | + | |
| 4778 | + builtin__closure__ClosureLifetimeState* state = (*(builtin__closure__ClosureLifetimeState**)_t1.data); | |
| 4779 | + u64 thread_id = builtin__closure__closure_current_thread_id_platform(); | |
| 4780 | + builtin__closure__closure_mtx_lock_platform(); | |
| 4781 | + string err = builtin__closure__closure_lifetime_error(state, lifetime->generation, thread_id); | |
| 4782 | + if ((err).len != 0) { | |
| 4783 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4784 | + return (_result_void){ .is_error=true, .err=builtin___v_error(err), .data={E_STRUCT} }; | |
| 4785 | + } | |
| 4786 | + builtin__closure__ClosureLifetimeState** _t5 = (builtin__closure__ClosureLifetimeState**)(builtin__map_get_check(ADDR(map, g_closure.active_lifetimes), &(u64[]){thread_id})); | |
| 4787 | + _option_builtin__closure__ClosureLifetimeState_ptr _t4 = {0}; | |
| 4788 | + if (_t5) { | |
| 4789 | + *((builtin__closure__ClosureLifetimeState**)&_t4.data) = *((builtin__closure__ClosureLifetimeState**)_t5); | |
| 4790 | + } else { | |
| 4791 | + _t4.state = 2; _t4.err = builtin___v_error(_S("map key does not exist")); | |
| 4792 | + } | |
| 4793 | + | |
| 4794 | + if (_t4.state == 0) { | |
| 4795 | + builtin__closure__ClosureLifetimeState* active = (*(builtin__closure__ClosureLifetimeState**)_t4.data); | |
| 4796 | + if (!(active == state || (active != 0 && state != 0 && builtin__closure__ClosureLifetimeState_struct_eq(*active, *state)))) { | |
| 4797 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4798 | + return (_result_void){ .is_error=true, .err=builtin___v_error(_S("another closure lifetime is already active on this thread")), .data={E_STRUCT} }; | |
| 4799 | + } | |
| 4800 | + } | |
| 4801 | + if (_t4.state == 2 && _t4.err._object != _const_none__._object) { builtin___v_free(_t4.err._object); } | |
| 4802 | + state->suspended++; | |
| 4803 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4804 | + work(); | |
| 4805 | + { // defer begin | |
| 4806 | + builtin__closure__closure_mtx_lock_platform(); | |
| 4807 | + state->suspended--; | |
| 4808 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4809 | + } // defer end | |
| 4810 | + return (_result_void){0}; | |
| 4811 | +} | |
| 4812 | +_result_void builtin__closure__Lifetime_untracked(builtin__closure__Lifetime* lifetime, void (*work)(void)) { | |
| 4813 | + _result_void _t1 = builtin__closure__Lifetime_suspend(lifetime, work); | |
| 4814 | + if (_t1.is_error) { | |
| 4815 | + _result_void _t2 = {0}; | |
| 4816 | + _t2.is_error = true; | |
| 4817 | + _t2.err = _t1.err; | |
| 4818 | + return _t2; | |
| 4819 | + } | |
| 4820 | + | |
| 4821 | + ; | |
| 4822 | + return (_result_void){0}; | |
| 4823 | +} | |
| 4824 | +VV_LOC void builtin__closure__closure_alloc(void) { | |
| 4825 | + u8* p = builtin__closure__closure_alloc_platform(); | |
| 4826 | + if (builtin__isnil(p)) { | |
| 4827 | + return; | |
| 4828 | + } | |
| 4829 | + u8* x = p + g_closure.v_page_size; | |
| 4830 | + int remaining = VSAFE_DIV_int(g_closure.v_page_size , _const_builtin__closure__closure_size); | |
| 4831 | + builtin__closure__closure_register_page(x); | |
| 4832 | + g_closure.closure_ptr = x; | |
| 4833 | + g_closure.closure_cap = remaining; | |
| 4834 | + for (;;) { | |
| 4835 | + if (!(remaining > 0)) break; | |
| 4836 | + builtin__vmemcpy(x, &_const_builtin__closure__closure_thunk[0], 15); | |
| 4837 | + remaining--; | |
| 4838 | + { // Unsafe block | |
| 4839 | + x += _const_builtin__closure__closure_size; | |
| 4840 | + } | |
| 4841 | + } | |
| 4842 | + builtin__closure__closure_memory_protect_platform(g_closure.closure_ptr, g_closure.v_page_size, builtin__closure__MemoryProtectAtrr__read_exec); | |
| 4843 | +} | |
| 4844 | +VV_LOC void builtin__closure__closure_init_body(void) { | |
| 4845 | + int page_size = builtin__closure__get_page_size_platform(); | |
| 4846 | + g_closure.v_page_size = page_size; | |
| 4847 | + g_closure.live = builtin__new_map(sizeof(voidptr), sizeof(builtin__closure__ClosureLiveInfo), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop) | |
| 4848 | + ; | |
| 4849 | + g_closure.active_lifetimes = builtin__new_map(sizeof(u64), sizeof(builtin__closure__ClosureLifetimeState*), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop) | |
| 4850 | + ; | |
| 4851 | + g_closure.next_generation = 0; | |
| 4852 | + g_closure.free_lifetime_states = ((void*)0); | |
| 4853 | + g_closure.next_lifetime_generation = 0; | |
| 4854 | + g_closure.lifetime_state_allocs = 0; | |
| 4855 | + builtin__closure__closure_mtx_lock_init_platform(); | |
| 4856 | + builtin__closure__closure_alloc(); | |
| 4857 | + { // Unsafe block | |
| 4858 | + builtin__closure__closure_memory_protect_platform(g_closure.closure_ptr, page_size, builtin__closure__MemoryProtectAtrr__read_write); | |
| 4859 | + builtin__vmemcpy(g_closure.closure_ptr, &_const_builtin__closure__closure_get_data_bytes[0], 6); | |
| 4860 | + builtin__closure__closure_memory_protect_platform(g_closure.closure_ptr, page_size, builtin__closure__MemoryProtectAtrr__read_exec); | |
| 4861 | + } | |
| 4862 | + if (builtin__closure__is_ppc64()) { | |
| 4863 | + voidptr* desc = ((voidptr*)(((u8*)(g_closure.closure_ptr)) - _const_builtin__closure__assumed_page_size)); | |
| 4864 | + { // Unsafe block | |
| 4865 | + desc[0] = g_closure.closure_ptr; | |
| 4866 | + desc[1] = ((void*)0); | |
| 4867 | + } | |
| 4868 | + g_closure.closure_get_data = ((builtin__closure__ClosureGetDataFn)(desc)); | |
| 4869 | + } else { | |
| 4870 | + g_closure.closure_get_data = g_closure.closure_ptr; | |
| 4871 | + } | |
| 4872 | + { // Unsafe block | |
| 4873 | + g_closure.closure_ptr = ((u8*)(g_closure.closure_ptr)) + _const_builtin__closure__closure_size; | |
| 4874 | + } | |
| 4875 | + g_closure.closure_cap--; | |
| 4876 | +} | |
| 4877 | +#if 1 | |
| 4878 | +#endif | |
| 4879 | +inline VV_LOC voidptr builtin__closure__closure_mtx_ptr_platform(void) { | |
| 4880 | + return ((voidptr)(&g_closure.ClosureMutex.closure_mtx[0])); | |
| 4881 | +} | |
| 4882 | +inline VV_LOC u8* builtin__closure__closure_alloc_platform(void) { | |
| 4883 | + u8* p = ((u8*)(((void*)0))); | |
| 4884 | + #if 0 | |
| 4885 | + { | |
| 4886 | + } | |
| 4887 | + #else | |
| 4888 | + { | |
| 4889 | + p = mmap(0, g_closure.v_page_size * 2, (PROT_READ | PROT_WRITE), (MAP_ANONYMOUS | MAP_PRIVATE), -1, 0); | |
| 4890 | + if (p == ((u8*)(MAP_FAILED))) { | |
| 4891 | + return ((void*)0); | |
| 4892 | + } | |
| 4893 | + } | |
| 4894 | + #endif | |
| 4895 | + return p; | |
| 4896 | +} | |
| 4897 | +inline VV_LOC void builtin__closure__closure_memory_protect_platform(voidptr ptr, isize size, builtin__closure__MemoryProtectAtrr attr) { | |
| 4898 | + #if 0 | |
| 4899 | + { | |
| 4900 | + } | |
| 4901 | + #else | |
| 4902 | + { | |
| 4903 | + | |
| 4904 | + if (attr == (builtin__closure__MemoryProtectAtrr__read_exec)) { | |
| 4905 | + mprotect(ptr, size, (PROT_READ | PROT_EXEC)); | |
| 4906 | + } | |
| 4907 | + else if (attr == (builtin__closure__MemoryProtectAtrr__read_write)) { | |
| 4908 | + mprotect(ptr, size, (PROT_READ | PROT_WRITE)); | |
| 4909 | + } | |
| 4910 | + } | |
| 4911 | + #endif | |
| 4912 | +} | |
| 4913 | +inline VV_LOC int builtin__closure__get_page_size_platform(void) { | |
| 4914 | + int page_size = 0x4000; | |
| 4915 | + #if 1 | |
| 4916 | + { | |
| 4917 | + page_size = ((int)(sysconf(_SC_PAGESIZE))); | |
| 4918 | + } | |
| 4919 | + #endif | |
| 4920 | + page_size = page_size * ((VSAFE_DIV_int((_const_builtin__closure__assumed_page_size - 1) , page_size)) + 1); | |
| 4921 | + return page_size; | |
| 4922 | +} | |
| 4923 | +inline VV_LOC void builtin__closure__closure_mtx_lock_init_platform(void) { | |
| 4924 | + #if 1 | |
| 4925 | + { | |
| 4926 | + pthread_mutex_init(builtin__closure__closure_mtx_ptr_platform(), 0); | |
| 4927 | + } | |
| 4928 | + #endif | |
| 4929 | +} | |
| 4930 | +inline VV_LOC void builtin__closure__closure_mtx_lock_platform(void) { | |
| 4931 | + #if 1 | |
| 4932 | + { | |
| 4933 | + pthread_mutex_lock(builtin__closure__closure_mtx_ptr_platform()); | |
| 4934 | + } | |
| 4935 | + #endif | |
| 4936 | +} | |
| 4937 | +inline VV_LOC void builtin__closure__closure_mtx_unlock_platform(void) { | |
| 4938 | + #if 1 | |
| 4939 | + { | |
| 4940 | + pthread_mutex_unlock(builtin__closure__closure_mtx_ptr_platform()); | |
| 4941 | + } | |
| 4942 | + #endif | |
| 4943 | +} | |
| 4944 | +inline VV_LOC u64 builtin__closure__closure_current_thread_id_platform(void) { | |
| 4945 | + #if 1 | |
| 4946 | + { | |
| 4947 | + return ((u64)(pthread_self())); | |
| 4948 | + } | |
| 4949 | + #endif | |
| 4950 | + return ((u64)(0)); | |
| 4951 | +} | |
| 4952 | +inline VV_LOC void builtin__closure__closure_init_once_platform(void) { | |
| 4953 | + #if 0 | |
| 4954 | + { | |
| 4955 | + } | |
| 4956 | + #else | |
| 4957 | + { | |
| 4958 | + v_closure_init_once(builtin__closure__closure_init_body); | |
| 4959 | + } | |
| 4960 | + #endif | |
| 4961 | +} | |
| 4962 | +inline multi_return_u64_u64 math__bits__mul_64(u64 x, u64 y) { | |
| 4963 | + u64 hi = ((u64)(0)); | |
| 4964 | + u64 lo = ((u64)(0)); | |
| 4965 | + #if defined(_MSC_VER) | |
| 4966 | + { | |
| 4967 | + } | |
| 4968 | + #elif defined(__V_amd64) | |
| 4969 | + { | |
| 4970 | + __asm__ ( | |
| 4971 | + "mulq %%rdx\n\t" | |
| 4972 | + : [lo] "=a" (lo), | |
| 4973 | + [hi] "=d" (hi) | |
| 4974 | + : [x] "a" (x), | |
| 4975 | + [y] "d" (y) | |
| 4976 | + : "cc" | |
| 4977 | + ); | |
| 4978 | + return (multi_return_u64_u64){.arg0=hi, .arg1=lo}; | |
| 4979 | + } | |
| 4980 | + #endif | |
| 4981 | + return math__bits__mul_64_default(x, y); | |
| 4982 | +} | |
| 4983 | +inline multi_return_u64_u64 math__bits__mul_add_64(u64 x, u64 y, u64 z) { | |
| 4984 | + u64 hi = ((u64)(0)); | |
| 4985 | + u64 lo = ((u64)(0)); | |
| 4986 | + #if defined(_MSC_VER) | |
| 4987 | + { | |
| 4988 | + } | |
| 4989 | + #elif defined(__V_amd64) | |
| 4990 | + { | |
| 4991 | + __asm__ ( | |
| 4992 | + "mulq %%rdx\n\t" | |
| 4993 | + "addq %[z], %%rax\n\t" | |
| 4994 | + "adcq $0, %%rdx\n\t" | |
| 4995 | + : [lo] "=a" (lo), | |
| 4996 | + [hi] "=d" (hi) | |
| 4997 | + : [x] "a" (x), | |
| 4998 | + [y] "d" (y), | |
| 4999 | + [z] "r" (z) | |
| 5000 | + : "cc" | |
| 5001 | + ); | |
| 5002 | + return (multi_return_u64_u64){.arg0=hi, .arg1=lo}; | |
| 5003 | + } | |
| 5004 | + #endif | |
| 5005 | + return math__bits__mul_add_64_default(x, y, z); | |
| 5006 | +} | |
| 5007 | +inline multi_return_u64_u64 math__bits__div_64(u64 hi, u64 lo, u64 y1) { | |
| 5008 | + u64 y = y1; | |
| 5009 | + if (y == 0) { | |
| 5010 | + builtin___v_panic(_const_math__bits__divide_error); | |
| 5011 | + VUNREACHABLE(); | |
| 5012 | + } | |
| 5013 | + if (y <= hi) { | |
| 5014 | + builtin___v_panic(_const_math__bits__overflow_error); | |
| 5015 | + VUNREACHABLE(); | |
| 5016 | + } | |
| 5017 | + u64 quo = ((u64)(0)); | |
| 5018 | + u64 rem = ((u64)(0)); | |
| 5019 | + #if defined(_MSC_VER) | |
| 5020 | + { | |
| 5021 | + } | |
| 5022 | + #elif defined(__V_amd64) | |
| 5023 | + { | |
| 5024 | + __asm__ ( | |
| 5025 | + "div %[y]\n\t" | |
| 5026 | + : [quo] "=a" (quo), | |
| 5027 | + [rem] "=d" (rem) | |
| 5028 | + : [hi] "d" (hi), | |
| 5029 | + [lo] "a" (lo), | |
| 5030 | + [y] "r" (y) | |
| 5031 | + : "cc" | |
| 5032 | + ); | |
| 5033 | + return (multi_return_u64_u64){.arg0=quo, .arg1=rem}; | |
| 5034 | + } | |
| 5035 | + #endif | |
| 5036 | + return math__bits__div_64_default(hi, lo, y1); | |
| 5037 | +} | |
| 5038 | +inline int math__bits__leading_zeros_8(u8 x) { | |
| 5039 | + if (x == 0) { | |
| 5040 | + return 8; | |
| 5041 | + } | |
| 5042 | + #if defined(_MSC_VER) | |
| 5043 | + { | |
| 5044 | + } | |
| 5045 | + #elif !defined(__TINYC__) | |
| 5046 | + { | |
| 5047 | + return __builtin_clz(((u32)(x))) - 24; | |
| 5048 | + } | |
| 5049 | + #endif | |
| 5050 | + return math__bits__leading_zeros_8_default(x); | |
| 5051 | +} | |
| 5052 | +inline int math__bits__leading_zeros_16(u16 x) { | |
| 5053 | + if (x == 0) { | |
| 5054 | + return 16; | |
| 5055 | + } | |
| 5056 | + #if defined(_MSC_VER) | |
| 5057 | + { | |
| 5058 | + } | |
| 5059 | + #elif !defined(__TINYC__) | |
| 5060 | + { | |
| 5061 | + return __builtin_clz(((u32)(x))) - 16; | |
| 5062 | + } | |
| 5063 | + #endif | |
| 5064 | + return math__bits__leading_zeros_16_default(x); | |
| 5065 | +} | |
| 5066 | +inline int math__bits__leading_zeros_32(u32 x) { | |
| 5067 | + if (x == 0) { | |
| 5068 | + return 32; | |
| 5069 | + } | |
| 5070 | + #if defined(_MSC_VER) | |
| 5071 | + { | |
| 5072 | + } | |
| 5073 | + #elif !defined(__TINYC__) | |
| 5074 | + { | |
| 5075 | + return __builtin_clz(x); | |
| 5076 | + } | |
| 5077 | + #endif | |
| 5078 | + return math__bits__leading_zeros_32_default(x); | |
| 5079 | +} | |
| 5080 | +inline int math__bits__leading_zeros_64(u64 x) { | |
| 5081 | + if (x == 0) { | |
| 5082 | + return 64; | |
| 5083 | + } | |
| 5084 | + #if defined(_MSC_VER) | |
| 5085 | + { | |
| 5086 | + } | |
| 5087 | + #elif !defined(__TINYC__) | |
| 5088 | + { | |
| 5089 | + return __builtin_clzll(x); | |
| 5090 | + } | |
| 5091 | + #endif | |
| 5092 | + return math__bits__leading_zeros_64_default(x); | |
| 5093 | +} | |
| 5094 | +inline int math__bits__trailing_zeros_8(u8 x) { | |
| 5095 | + if (x == 0) { | |
| 5096 | + return 8; | |
| 5097 | + } | |
| 5098 | + #if defined(_MSC_VER) | |
| 5099 | + { | |
| 5100 | + } | |
| 5101 | + #elif !defined(__TINYC__) | |
| 5102 | + { | |
| 5103 | + return __builtin_ctz(((u32)(x))); | |
| 5104 | + } | |
| 5105 | + #endif | |
| 5106 | + return math__bits__trailing_zeros_8_default(x); | |
| 5107 | +} | |
| 5108 | +inline int math__bits__trailing_zeros_16(u16 x) { | |
| 5109 | + if (x == 0) { | |
| 5110 | + return 16; | |
| 5111 | + } | |
| 5112 | + #if defined(_MSC_VER) | |
| 5113 | + { | |
| 5114 | + } | |
| 5115 | + #elif !defined(__TINYC__) | |
| 5116 | + { | |
| 5117 | + return __builtin_ctz(((u32)(x))); | |
| 5118 | + } | |
| 5119 | + #endif | |
| 5120 | + return math__bits__trailing_zeros_16_default(x); | |
| 5121 | +} | |
| 5122 | +inline int math__bits__trailing_zeros_32(u32 x) { | |
| 5123 | + if (x == 0) { | |
| 5124 | + return 32; | |
| 5125 | + } | |
| 5126 | + #if defined(_MSC_VER) | |
| 5127 | + { | |
| 5128 | + } | |
| 5129 | + #elif !defined(__TINYC__) | |
| 5130 | + { | |
| 5131 | + return __builtin_ctz(x); | |
| 5132 | + } | |
| 5133 | + #endif | |
| 5134 | + return math__bits__trailing_zeros_32_default(x); | |
| 5135 | +} | |
| 5136 | +inline int math__bits__trailing_zeros_64(u64 x) { | |
| 5137 | + if (x == 0) { | |
| 5138 | + return 64; | |
| 5139 | + } | |
| 5140 | + #if defined(_MSC_VER) | |
| 5141 | + { | |
| 5142 | + } | |
| 5143 | + #elif !defined(__TINYC__) | |
| 5144 | + { | |
| 5145 | + return __builtin_ctzll(x); | |
| 5146 | + } | |
| 5147 | + #endif | |
| 5148 | + return math__bits__trailing_zeros_64_default(x); | |
| 5149 | +} | |
| 5150 | +inline int math__bits__ones_count_8(u8 x) { | |
| 5151 | + #if defined(_MSC_VER) | |
| 5152 | + { | |
| 5153 | + } | |
| 5154 | + #elif !defined(__TINYC__) | |
| 5155 | + { | |
| 5156 | + return __builtin_popcount(((u32)(x))); | |
| 5157 | + } | |
| 5158 | + #endif | |
| 5159 | + return math__bits__ones_count_8_default(x); | |
| 5160 | +} | |
| 5161 | +inline int math__bits__ones_count_16(u16 x) { | |
| 5162 | + #if defined(_MSC_VER) | |
| 5163 | + { | |
| 5164 | + } | |
| 5165 | + #elif !defined(__TINYC__) | |
| 5166 | + { | |
| 5167 | + return __builtin_popcount(((u32)(x))); | |
| 5168 | + } | |
| 5169 | + #endif | |
| 5170 | + return math__bits__ones_count_16_default(x); | |
| 5171 | +} | |
| 5172 | +inline int math__bits__ones_count_32(u32 x) { | |
| 5173 | + #if defined(_MSC_VER) | |
| 5174 | + { | |
| 5175 | + } | |
| 5176 | + #elif !defined(__TINYC__) | |
| 5177 | + { | |
| 5178 | + return __builtin_popcount(x); | |
| 5179 | + } | |
| 5180 | + #endif | |
| 5181 | + return math__bits__ones_count_32_default(x); | |
| 5182 | +} | |
| 5183 | +inline int math__bits__ones_count_64(u64 x) { | |
| 5184 | + #if defined(_MSC_VER) | |
| 5185 | + { | |
| 5186 | + } | |
| 5187 | + #elif !defined(__TINYC__) | |
| 5188 | + { | |
| 5189 | + return __builtin_popcountll(x); | |
| 5190 | + } | |
| 5191 | + #endif | |
| 5192 | + return math__bits__ones_count_64_default(x); | |
| 5193 | +} | |
| 5194 | +inline int math__bits__pure_v_but_overridden_by_c_leading_zeros_8(u8 x) { | |
| 5195 | + return math__bits__leading_zeros_8_default(x); | |
| 5196 | +} | |
| 5197 | +inline VV_LOC int math__bits__leading_zeros_8_default(u8 x) { | |
| 5198 | + return 8 - math__bits__len_8(x); | |
| 5199 | +} | |
| 5200 | +inline int math__bits__pure_v_but_overridden_by_c_leading_zeros_16(u16 x) { | |
| 5201 | + return math__bits__leading_zeros_16_default(x); | |
| 5202 | +} | |
| 5203 | +inline VV_LOC int math__bits__leading_zeros_16_default(u16 x) { | |
| 5204 | + return 16 - math__bits__len_16(x); | |
| 5205 | +} | |
| 5206 | +inline int math__bits__pure_v_but_overridden_by_c_leading_zeros_32(u32 x) { | |
| 5207 | + return math__bits__leading_zeros_32_default(x); | |
| 5208 | +} | |
| 5209 | +inline VV_LOC int math__bits__leading_zeros_32_default(u32 x) { | |
| 5210 | + return 32 - math__bits__len_32(x); | |
| 5211 | +} | |
| 5212 | +inline int math__bits__pure_v_but_overridden_by_c_leading_zeros_64(u64 x) { | |
| 5213 | + return math__bits__leading_zeros_64_default(x); | |
| 5214 | +} | |
| 5215 | +inline VV_LOC int math__bits__leading_zeros_64_default(u64 x) { | |
| 5216 | + return 64 - math__bits__len_64(x); | |
| 5217 | +} | |
| 5218 | +inline int math__bits__pure_v_but_overridden_by_c_trailing_zeros_8(u8 x) { | |
| 5219 | + return math__bits__trailing_zeros_8_default(x); | |
| 5220 | +} | |
| 5221 | +inline VV_LOC int math__bits__trailing_zeros_8_default(u8 x) { | |
| 5222 | + return ((int)(_const_math__bits__ntz_8_tab[x])); | |
| 5223 | +} | |
| 5224 | +inline int math__bits__pure_v_but_overridden_by_c_trailing_zeros_16(u16 x) { | |
| 5225 | + return math__bits__trailing_zeros_16_default(x); | |
| 5226 | +} | |
| 5227 | +inline VV_LOC int math__bits__trailing_zeros_16_default(u16 x) { | |
| 5228 | + if (x == 0) { | |
| 5229 | + return 16; | |
| 5230 | + } | |
| 5231 | + return ((int)(_const_math__bits__de_bruijn32tab[v__rshift_u32(((u32)((x & -x))) * _const_math__bits__de_bruijn32, (u64)27)])); | |
| 5232 | +} | |
| 5233 | +inline int math__bits__pure_v_but_overridden_by_c_trailing_zeros_32(u32 x) { | |
| 5234 | + return math__bits__trailing_zeros_32_default(x); | |
| 5235 | +} | |
| 5236 | +inline VV_LOC int math__bits__trailing_zeros_32_default(u32 x) { | |
| 5237 | + if (x == 0) { | |
| 5238 | + return 32; | |
| 5239 | + } | |
| 5240 | + return ((int)(_const_math__bits__de_bruijn32tab[v__rshift_u32(((x & -x)) * _const_math__bits__de_bruijn32, (u64)27)])); | |
| 5241 | +} | |
| 5242 | +inline int math__bits__pure_v_but_overridden_by_c_trailing_zeros_64(u64 x) { | |
| 5243 | + return math__bits__trailing_zeros_64_default(x); | |
| 5244 | +} | |
| 5245 | +inline VV_LOC int math__bits__trailing_zeros_64_default(u64 x) { | |
| 5246 | + if (x == 0) { | |
| 5247 | + return 64; | |
| 5248 | + } | |
| 5249 | + return ((int)(_const_math__bits__de_bruijn64tab[((int)(v__rshift_u64(((x & -x)) * _const_math__bits__de_bruijn64, (u64)58)))])); | |
| 5250 | +} | |
| 5251 | +inline int math__bits__pure_v_but_overridden_by_c_ones_count_8(u8 x) { | |
| 5252 | + return math__bits__ones_count_8_default(x); | |
| 5253 | +} | |
| 5254 | +inline VV_LOC int math__bits__ones_count_8_default(u8 x) { | |
| 5255 | + return ((int)(_const_math__bits__pop_8_tab[x])); | |
| 5256 | +} | |
| 5257 | +inline int math__bits__pure_v_but_overridden_by_c_ones_count_16(u16 x) { | |
| 5258 | + return math__bits__ones_count_16_default(x); | |
| 5259 | +} | |
| 5260 | +inline VV_LOC int math__bits__ones_count_16_default(u16 x) { | |
| 5261 | + return ((int)((u8)(_const_math__bits__pop_8_tab[v__rshift_u16(x, (u64)8)] + _const_math__bits__pop_8_tab[(x & ((u16)(0xff)))]))); | |
| 5262 | +} | |
| 5263 | +inline int math__bits__pure_v_but_overridden_by_c_ones_count_32(u32 x) { | |
| 5264 | + return math__bits__ones_count_32_default(x); | |
| 5265 | +} | |
| 5266 | +inline VV_LOC int math__bits__ones_count_32_default(u32 x) { | |
| 5267 | + return ((int)((u8)((u8)((u8)(_const_math__bits__pop_8_tab[v__rshift_u32(x, (u64)24)] + _const_math__bits__pop_8_tab[((v__rshift_u32(x, (u64)16)) & 0xff)]) + _const_math__bits__pop_8_tab[((v__rshift_u32(x, (u64)8)) & 0xff)]) + _const_math__bits__pop_8_tab[(x & ((u32)(0xff)))]))); | |
| 5268 | +} | |
| 5269 | +inline int math__bits__pure_v_but_overridden_by_c_ones_count_64(u64 x) { | |
| 5270 | + return math__bits__ones_count_64_default(x); | |
| 5271 | +} | |
| 5272 | +inline VV_LOC int math__bits__ones_count_64_default(u64 x) { | |
| 5273 | + u64 y = (((v__rshift_u64(x, (u64)((u64)(1)))) & ((_const_math__bits__m0 & _const_max_u64)))) + ((x & ((_const_math__bits__m0 & _const_max_u64)))); | |
| 5274 | + y = (((v__rshift_u64(y, (u64)((u64)(2)))) & ((_const_math__bits__m1 & _const_max_u64)))) + ((y & ((_const_math__bits__m1 & _const_max_u64)))); | |
| 5275 | + y = (((v__rshift_u64(y, (u64)4)) + y) & ((_const_math__bits__m2 & _const_max_u64))); | |
| 5276 | + y += v__rshift_u64(y, (u64)8); | |
| 5277 | + y += v__rshift_u64(y, (u64)16); | |
| 5278 | + y += v__rshift_u64(y, (u64)32); | |
| 5279 | + return (((int)(y)) & 127); | |
| 5280 | +} | |
| 5281 | +inline u8 math__bits__rotate_left_8(u8 x, int k) { | |
| 5282 | + u8 s = (((u8)(k)) & ((u8)(_const_math__bits__n8 - ((u8)(1))))); | |
| 5283 | + return ((v__lshift_u8(x, (u64)s)) | (v__rshift_u8(x, (u64)((u8)(_const_math__bits__n8 - s))))); | |
| 5284 | +} | |
| 5285 | +inline u16 math__bits__rotate_left_16(u16 x, int k) { | |
| 5286 | + u16 s = (((u16)(k)) & ((u16)(_const_math__bits__n16 - ((u16)(1))))); | |
| 5287 | + return ((v__lshift_u16(x, (u64)s)) | (v__rshift_u16(x, (u64)((u16)(_const_math__bits__n16 - s))))); | |
| 5288 | +} | |
| 5289 | +inline u32 math__bits__rotate_left_32(u32 x, int k) { | |
| 5290 | + u32 s = (((u32)(k)) & (_const_math__bits__n32 - ((u32)(1)))); | |
| 5291 | + return ((v__lshift_u32(x, (u64)s)) | (v__rshift_u32(x, (u64)(_const_math__bits__n32 - s)))); | |
| 5292 | +} | |
| 5293 | +inline u64 math__bits__rotate_left_64(u64 x, int k) { | |
| 5294 | + u64 s = (((u64)(k)) & (_const_math__bits__n64 - ((u64)(1)))); | |
| 5295 | + return ((v__lshift_u64(x, (u64)s)) | (v__rshift_u64(x, (u64)(_const_math__bits__n64 - s)))); | |
| 5296 | +} | |
| 5297 | +inline u8 math__bits__reverse_8(u8 x) { | |
| 5298 | + return _const_math__bits__rev_8_tab[x]; | |
| 5299 | +} | |
| 5300 | +inline u16 math__bits__reverse_16(u16 x) { | |
| 5301 | + return (((u16)(_const_math__bits__rev_8_tab[v__rshift_u16(x, (u64)8)])) | (v__lshift_u16(((u16)(_const_math__bits__rev_8_tab[(x & ((u16)(0xff)))])), (u64)8))); | |
| 5302 | +} | |
| 5303 | +inline u32 math__bits__reverse_32(u32 x) { | |
| 5304 | + u64 y = (((((v__rshift_u32(x, (u64)((u32)(1)))) & ((_const_math__bits__m0 & _const_max_u32)))) | (v__lshift_u64(((x & ((_const_math__bits__m0 & _const_max_u32)))), (u64)1)))); | |
| 5305 | + y = (((((v__rshift_u64(y, (u64)((u32)(2)))) & ((_const_math__bits__m1 & _const_max_u32)))) | (v__lshift_u64(((y & ((_const_math__bits__m1 & _const_max_u32)))), (u64)((u32)(2)))))); | |
| 5306 | + y = (((((v__rshift_u64(y, (u64)((u32)(4)))) & ((_const_math__bits__m2 & _const_max_u32)))) | (v__lshift_u64(((y & ((_const_math__bits__m2 & _const_max_u32)))), (u64)((u32)(4)))))); | |
| 5307 | + return math__bits__reverse_bytes_32(((u32)(y))); | |
| 5308 | +} | |
| 5309 | +inline u64 math__bits__reverse_64(u64 x) { | |
| 5310 | + u64 y = (((((v__rshift_u64(x, (u64)((u64)(1)))) & ((_const_math__bits__m0 & _const_max_u64)))) | (v__lshift_u64(((x & ((_const_math__bits__m0 & _const_max_u64)))), (u64)1)))); | |
| 5311 | + y = (((((v__rshift_u64(y, (u64)((u64)(2)))) & ((_const_math__bits__m1 & _const_max_u64)))) | (v__lshift_u64(((y & ((_const_math__bits__m1 & _const_max_u64)))), (u64)2)))); | |
| 5312 | + y = (((((v__rshift_u64(y, (u64)((u64)(4)))) & ((_const_math__bits__m2 & _const_max_u64)))) | (v__lshift_u64(((y & ((_const_math__bits__m2 & _const_max_u64)))), (u64)4)))); | |
| 5313 | + return math__bits__reverse_bytes_64(y); | |
| 5314 | +} | |
| 5315 | +inline u16 math__bits__reverse_bytes_16(u16 x) { | |
| 5316 | + return ((v__rshift_u16(x, (u64)8)) | (v__lshift_u16(x, (u64)8))); | |
| 5317 | +} | |
| 5318 | +inline u32 math__bits__reverse_bytes_32(u32 x) { | |
| 5319 | + u64 y = (((((v__rshift_u32(x, (u64)((u32)(8)))) & ((_const_math__bits__m3 & _const_max_u32)))) | (v__lshift_u64(((x & ((_const_math__bits__m3 & _const_max_u32)))), (u64)((u32)(8)))))); | |
| 5320 | + return ((u32)(((v__rshift_u64(y, (u64)16)) | (v__lshift_u64(y, (u64)16))))); | |
| 5321 | +} | |
| 5322 | +inline u64 math__bits__reverse_bytes_64(u64 x) { | |
| 5323 | + u64 y = (((((v__rshift_u64(x, (u64)((u64)(8)))) & ((_const_math__bits__m3 & _const_max_u64)))) | (v__lshift_u64(((x & ((_const_math__bits__m3 & _const_max_u64)))), (u64)((u64)(8)))))); | |
| 5324 | + y = (((((v__rshift_u64(y, (u64)((u64)(16)))) & ((_const_math__bits__m4 & _const_max_u64)))) | (v__lshift_u64(((y & ((_const_math__bits__m4 & _const_max_u64)))), (u64)((u64)(16)))))); | |
| 5325 | + return ((v__rshift_u64(y, (u64)32)) | (v__lshift_u64(y, (u64)32))); | |
| 5326 | +} | |
| 5327 | +int math__bits__len_8(u8 x) { | |
| 5328 | + return ((int)(_const_math__bits__len_8_tab[x])); | |
| 5329 | +} | |
| 5330 | +int math__bits__len_16(u16 x) { | |
| 5331 | + u16 y = x; | |
| 5332 | + int n = 0; | |
| 5333 | + if (y >= 256) { | |
| 5334 | + y = v__rshift_u16(y, (u64)8); | |
| 5335 | + n = 8; | |
| 5336 | + } | |
| 5337 | + return n + ((int)(_const_math__bits__len_8_tab[((int)(y))])); | |
| 5338 | +} | |
| 5339 | +int math__bits__len_32(u32 x) { | |
| 5340 | + u32 y = x; | |
| 5341 | + int n = 0; | |
| 5342 | + if (y >= 65536) { | |
| 5343 | + y = v__rshift_u32(y, (u64)16); | |
| 5344 | + n = 16; | |
| 5345 | + } | |
| 5346 | + if (y >= 256) { | |
| 5347 | + y = v__rshift_u32(y, (u64)8); | |
| 5348 | + n += 8; | |
| 5349 | + } | |
| 5350 | + return n + ((int)(_const_math__bits__len_8_tab[((int)(y))])); | |
| 5351 | +} | |
| 5352 | +int math__bits__len_64(u64 x) { | |
| 5353 | + u64 y = x; | |
| 5354 | + int n = 0; | |
| 5355 | + if (y >= v__lshift_u64(((u64)(1)), (u64)((u64)(32)))) { | |
| 5356 | + y = v__rshift_u64(y, (u64)32); | |
| 5357 | + n = 32; | |
| 5358 | + } | |
| 5359 | + if (y >= v__lshift_u64(((u64)(1)), (u64)((u64)(16)))) { | |
| 5360 | + y = v__rshift_u64(y, (u64)16); | |
| 5361 | + n += 16; | |
| 5362 | + } | |
| 5363 | + if (y >= v__lshift_u64(((u64)(1)), (u64)((u64)(8)))) { | |
| 5364 | + y = v__rshift_u64(y, (u64)8); | |
| 5365 | + n += 8; | |
| 5366 | + } | |
| 5367 | + return n + ((int)(_const_math__bits__len_8_tab[((int)(y))])); | |
| 5368 | +} | |
| 5369 | +multi_return_u32_u32 math__bits__add_32(u32 x, u32 y, u32 carry) { | |
| 5370 | + u64 sum64 = ((u64)(x)) + ((u64)(y)) + ((u64)(carry)); | |
| 5371 | + u32 sum = ((u32)(sum64)); | |
| 5372 | + u32 carry_out = ((u32)(v__rshift_u64(sum64, (u64)32))); | |
| 5373 | + return (multi_return_u32_u32){.arg0=sum, .arg1=carry_out}; | |
| 5374 | +} | |
| 5375 | +multi_return_u64_u64 math__bits__add_64(u64 x, u64 y, u64 carry) { | |
| 5376 | + u64 sum = x + y + carry; | |
| 5377 | + u64 carry_out = v__rshift_u64(((((x & y)) | ((((x | y)) & ~sum)))), (u64)63); | |
| 5378 | + return (multi_return_u64_u64){.arg0=sum, .arg1=carry_out}; | |
| 5379 | +} | |
| 5380 | +multi_return_u32_u32 math__bits__sub_32(u32 x, u32 y, u32 borrow) { | |
| 5381 | + u32 diff = x - y - borrow; | |
| 5382 | + u32 borrow_out = v__rshift_u32(((((~x & y)) | ((~((x ^ y)) & diff)))), (u64)31); | |
| 5383 | + return (multi_return_u32_u32){.arg0=diff, .arg1=borrow_out}; | |
| 5384 | +} | |
| 5385 | +multi_return_u64_u64 math__bits__sub_64(u64 x, u64 y, u64 borrow) { | |
| 5386 | + u64 diff = x - y - borrow; | |
| 5387 | + u64 borrow_out = v__rshift_u64(((((~x & y)) | ((~((x ^ y)) & diff)))), (u64)63); | |
| 5388 | + return (multi_return_u64_u64){.arg0=diff, .arg1=borrow_out}; | |
| 5389 | +} | |
| 5390 | +inline multi_return_u32_u32 math__bits__mul_32(u32 x, u32 y) { | |
| 5391 | + return math__bits__mul_32_default(x, y); | |
| 5392 | +} | |
| 5393 | +inline VV_LOC multi_return_u32_u32 math__bits__mul_32_default(u32 x, u32 y) { | |
| 5394 | + u64 tmp = ((u64)(x)) * ((u64)(y)); | |
| 5395 | + u32 hi = ((u32)(v__rshift_u64(tmp, (u64)32))); | |
| 5396 | + u32 lo = ((u32)(tmp)); | |
| 5397 | + return (multi_return_u32_u32){.arg0=hi, .arg1=lo}; | |
| 5398 | +} | |
| 5399 | +inline multi_return_u64_u64 math__bits__pure_v_but_overridden_by_amd64_mul_64(u64 x, u64 y) { | |
| 5400 | + return math__bits__mul_64_default(x, y); | |
| 5401 | +} | |
| 5402 | +VV_LOC multi_return_u64_u64 math__bits__mul_64_default(u64 x, u64 y) { | |
| 5403 | + u64 x0 = (x & _const_math__bits__mask32); | |
| 5404 | + u64 x1 = v__rshift_u64(x, (u64)32); | |
| 5405 | + u64 y0 = (y & _const_math__bits__mask32); | |
| 5406 | + u64 y1 = v__rshift_u64(y, (u64)32); | |
| 5407 | + u64 w0 = x0 * y0; | |
| 5408 | + u64 t = x1 * y0 + (v__rshift_u64(w0, (u64)32)); | |
| 5409 | + u64 w1 = (t & _const_math__bits__mask32); | |
| 5410 | + u64 w2 = v__rshift_u64(t, (u64)32); | |
| 5411 | + w1 += x0 * y1; | |
| 5412 | + u64 hi = x1 * y1 + w2 + (v__rshift_u64(w1, (u64)32)); | |
| 5413 | + u64 lo = x * y; | |
| 5414 | + return (multi_return_u64_u64){.arg0=hi, .arg1=lo}; | |
| 5415 | +} | |
| 5416 | +inline multi_return_u32_u32 math__bits__mul_add_32(u32 x, u32 y, u32 z) { | |
| 5417 | + return math__bits__mul_add_32_default(x, y, z); | |
| 5418 | +} | |
| 5419 | +inline VV_LOC multi_return_u32_u32 math__bits__mul_add_32_default(u32 x, u32 y, u32 z) { | |
| 5420 | + u64 tmp = ((u64)(x)) * ((u64)(y)) + ((u64)(z)); | |
| 5421 | + u32 hi = ((u32)(v__rshift_u64(tmp, (u64)32))); | |
| 5422 | + u32 lo = ((u32)(tmp)); | |
| 5423 | + return (multi_return_u32_u32){.arg0=hi, .arg1=lo}; | |
| 5424 | +} | |
| 5425 | +inline multi_return_u64_u64 math__bits__pure_v_but_overridden_by_amd64_mul_add_64(u64 x, u64 y, u64 z) { | |
| 5426 | + return math__bits__mul_add_64_default(x, y, z); | |
| 5427 | +} | |
| 5428 | +inline VV_LOC multi_return_u64_u64 math__bits__mul_add_64_default(u64 x, u64 y, u64 z) { | |
| 5429 | + multi_return_u64_u64 mr_14968 = math__bits__mul_64(x, y); | |
| 5430 | + u64 h = mr_14968.arg0; | |
| 5431 | + u64 l = mr_14968.arg1; | |
| 5432 | + u64 lo = l + z; | |
| 5433 | + u64 hi = h + (u64[]){(lo < l)?1:0}[0]; | |
| 5434 | + return (multi_return_u64_u64){.arg0=hi, .arg1=lo}; | |
| 5435 | +} | |
| 5436 | +inline multi_return_u32_u32 math__bits__div_32(u32 hi, u32 lo, u32 y) { | |
| 5437 | + return math__bits__div_32_default(hi, lo, y); | |
| 5438 | +} | |
| 5439 | +VV_LOC multi_return_u32_u32 math__bits__div_32_default(u32 hi, u32 lo, u32 y) { | |
| 5440 | + if (y == 0) { | |
| 5441 | + builtin___v_panic(_const_math__bits__divide_error); | |
| 5442 | + VUNREACHABLE(); | |
| 5443 | + } | |
| 5444 | + if (y <= hi) { | |
| 5445 | + builtin___v_panic(_const_math__bits__overflow_error); | |
| 5446 | + VUNREACHABLE(); | |
| 5447 | + } | |
| 5448 | + u64 z = ((v__lshift_u64(((u64)(hi)), (u64)32)) | ((u64)(lo))); | |
| 5449 | + u32 quo = ((u32)(VSAFE_DIV_u64(z , ((u64)(y))))); | |
| 5450 | + u32 rem = ((u32)(VSAFE_MOD_u64(z , ((u64)(y))))); | |
| 5451 | + return (multi_return_u32_u32){.arg0=quo, .arg1=rem}; | |
| 5452 | +} | |
| 5453 | +inline multi_return_u64_u64 math__bits__pure_v_but_overridden_by_amd64_div_64(u64 hi, u64 lo, u64 y1) { | |
| 5454 | + return math__bits__div_64_default(hi, lo, y1); | |
| 5455 | +} | |
| 5456 | +VV_LOC multi_return_u64_u64 math__bits__div_64_default(u64 hi, u64 lo, u64 y1) { | |
| 5457 | + u64 y = y1; | |
| 5458 | + if (y == 0) { | |
| 5459 | + builtin___v_panic(_const_math__bits__divide_error); | |
| 5460 | + VUNREACHABLE(); | |
| 5461 | + } | |
| 5462 | + if (y <= hi) { | |
| 5463 | + builtin___v_panic(_const_math__bits__overflow_error); | |
| 5464 | + VUNREACHABLE(); | |
| 5465 | + } | |
| 5466 | + u32 s = ((u32)(math__bits__leading_zeros_64(y))); | |
| 5467 | + y = v__lshift_u64(y, (u64)s); | |
| 5468 | + u64 yn1 = v__rshift_u64(y, (u64)32); | |
| 5469 | + u64 yn0 = (y & _const_math__bits__mask32); | |
| 5470 | + u64 ss1 = (v__lshift_u64(hi, (u64)s)); | |
| 5471 | + u32 xxx = 64 - s; | |
| 5472 | + u64 ss2 = v__rshift_u64(lo, (u64)xxx); | |
| 5473 | + if (xxx == 64) { | |
| 5474 | + ss2 = 0; | |
| 5475 | + } | |
| 5476 | + u64 un32 = (ss1 | ss2); | |
| 5477 | + u64 un10 = v__lshift_u64(lo, (u64)s); | |
| 5478 | + u64 un1 = v__rshift_u64(un10, (u64)32); | |
| 5479 | + u64 un0 = (un10 & _const_math__bits__mask32); | |
| 5480 | + u64 q1 = VSAFE_DIV_u64(un32 , yn1); | |
| 5481 | + u64 rhat = un32 - (q1 * yn1); | |
| 5482 | + for (;;) { | |
| 5483 | + if (!(q1 >= _const_math__bits__two32 || (q1 * yn0) > ((_const_math__bits__two32 * rhat) + un1))) break; | |
| 5484 | + q1--; | |
| 5485 | + rhat += yn1; | |
| 5486 | + if (rhat >= _const_math__bits__two32) { | |
| 5487 | + break; | |
| 5488 | + } | |
| 5489 | + } | |
| 5490 | + u64 un21 = (un32 * _const_math__bits__two32) + (un1 - (q1 * y)); | |
| 5491 | + u64 q0 = VSAFE_DIV_u64(un21 , yn1); | |
| 5492 | + rhat = un21 - q0 * yn1; | |
| 5493 | + for (;;) { | |
| 5494 | + if (!(q0 >= _const_math__bits__two32 || (q0 * yn0) > ((_const_math__bits__two32 * rhat) + un0))) break; | |
| 5495 | + q0--; | |
| 5496 | + rhat += yn1; | |
| 5497 | + if (rhat >= _const_math__bits__two32) { | |
| 5498 | + break; | |
| 5499 | + } | |
| 5500 | + } | |
| 5501 | + u64 qq = ((q1 * _const_math__bits__two32) + q0); | |
| 5502 | + u64 rr = v__rshift_u64(((un21 * _const_math__bits__two32) + un0 - (q0 * y)), (u64)s); | |
| 5503 | + return (multi_return_u64_u64){.arg0=qq, .arg1=rr}; | |
| 5504 | +} | |
| 5505 | +inline u32 math__bits__rem_32(u32 hi, u32 lo, u32 y) { | |
| 5506 | + if (y == 0) { | |
| 5507 | + builtin___v_panic(_const_math__bits__divide_error); | |
| 5508 | + VUNREACHABLE(); | |
| 5509 | + } | |
| 5510 | + return ((u32)(VSAFE_MOD_u64((((v__lshift_u64(((u64)(hi)), (u64)32)) | ((u64)(lo)))) , ((u64)(y))))); | |
| 5511 | +} | |
| 5512 | +inline u64 math__bits__rem_64(u64 hi, u64 lo, u64 y) { | |
| 5513 | + if (y == 0) { | |
| 5514 | + builtin___v_panic(_const_math__bits__divide_error); | |
| 5515 | + VUNREACHABLE(); | |
| 5516 | + } | |
| 5517 | + multi_return_u64_u64 mr_18593 = math__bits__div_64(VSAFE_MOD_u64(hi , y), lo, y); | |
| 5518 | + u64 rem = mr_18593.arg1; | |
| 5519 | + return rem; | |
| 5520 | +} | |
| 5521 | +multi_return_f64_int math__bits__normalize(f64 x) { | |
| 5522 | + f64 smallest_normal = 2.2250738585072014e-308; | |
| 5523 | + if (((x > ((f64)(0.0)) ? (x) : (-x))) < smallest_normal) { | |
| 5524 | + return (multi_return_f64_int){.arg0=(f64)(x * (v__lshift_u64(((u64)(1)), (u64)((u64)(52))))), .arg1=-52}; | |
| 5525 | + } | |
| 5526 | + return (multi_return_f64_int){.arg0=x, .arg1=0}; | |
| 5527 | +} | |
| 5528 | +inline u32 math__bits__f32_bits(f32 f) { | |
| 5529 | + u32 p = *((u32*)(&f)); | |
| 5530 | + return p; | |
| 5531 | +} | |
| 5532 | +inline f32 math__bits__f32_from_bits(u32 b) { | |
| 5533 | + f32 p = *((f32*)(&b)); | |
| 5534 | + return p; | |
| 5535 | +} | |
| 5536 | +inline u64 math__bits__f64_bits(f64 f) { | |
| 5537 | + u64 p = *((u64*)(&f)); | |
| 5538 | + return p; | |
| 5539 | +} | |
| 5540 | +inline f64 math__bits__f64_from_bits(u64 b) { | |
| 5541 | + f64 p = *((f64*)(&b)); | |
| 5542 | + return p; | |
| 5543 | +} | |
| 5544 | +VV_LOC multi_return_u32_u32_u32 strconv__lsr96(u32 s2, u32 s1, u32 s0) { | |
| 5545 | + u32 r0 = ((u32)(0)); | |
| 5546 | + u32 r1 = ((u32)(0)); | |
| 5547 | + u32 r2 = ((u32)(0)); | |
| 5548 | + r0 = ((v__rshift_u32(s0, (u64)1)) | (v__lshift_u32(((s1 & ((u32)(1)))), (u64)31))); | |
| 5549 | + r1 = ((v__rshift_u32(s1, (u64)1)) | (v__lshift_u32(((s2 & ((u32)(1)))), (u64)31))); | |
| 5550 | + r2 = v__rshift_u32(s2, (u64)1); | |
| 5551 | + return (multi_return_u32_u32_u32){.arg0=r2, .arg1=r1, .arg2=r0}; | |
| 5552 | +} | |
| 5553 | +VV_LOC multi_return_u32_u32_u32 strconv__lsl96(u32 s2, u32 s1, u32 s0) { | |
| 5554 | + u32 r0 = ((u32)(0)); | |
| 5555 | + u32 r1 = ((u32)(0)); | |
| 5556 | + u32 r2 = ((u32)(0)); | |
| 5557 | + r2 = ((v__lshift_u32(s2, (u64)1)) | (v__rshift_u32(((s1 & (v__lshift_u32(((u32)(1)), (u64)31)))), (u64)31))); | |
| 5558 | + r1 = ((v__lshift_u32(s1, (u64)1)) | (v__rshift_u32(((s0 & (v__lshift_u32(((u32)(1)), (u64)31)))), (u64)31))); | |
| 5559 | + r0 = v__lshift_u32(s0, (u64)1); | |
| 5560 | + return (multi_return_u32_u32_u32){.arg0=r2, .arg1=r1, .arg2=r0}; | |
| 5561 | +} | |
| 5562 | +VV_LOC multi_return_u32_u32_u32 strconv__add96(u32 s2, u32 s1, u32 s0, u32 d2, u32 d1, u32 d0) { | |
| 5563 | + u64 w = ((u64)(0)); | |
| 5564 | + u32 r0 = ((u32)(0)); | |
| 5565 | + u32 r1 = ((u32)(0)); | |
| 5566 | + u32 r2 = ((u32)(0)); | |
| 5567 | + w = ((u64)(s0)) + ((u64)(d0)); | |
| 5568 | + r0 = ((u32)(w)); | |
| 5569 | + w = v__rshift_u64(w, (u64)32); | |
| 5570 | + w += ((u64)(s1)) + ((u64)(d1)); | |
| 5571 | + r1 = ((u32)(w)); | |
| 5572 | + w = v__rshift_u64(w, (u64)32); | |
| 5573 | + w += ((u64)(s2)) + ((u64)(d2)); | |
| 5574 | + r2 = ((u32)(w)); | |
| 5575 | + return (multi_return_u32_u32_u32){.arg0=r2, .arg1=r1, .arg2=r0}; | |
| 5576 | +} | |
| 5577 | +VV_LOC multi_return_strconv__ParserState_strconv__PrepNumber strconv__parser(string s) { | |
| 5578 | + int digx = 0; | |
| 5579 | + strconv__ParserState result = strconv__ParserState__ok; | |
| 5580 | + bool expneg = false; | |
| 5581 | + int expexp = 0; | |
| 5582 | + int i = 0; | |
| 5583 | + strconv__PrepNumber _t1 = ((strconv__PrepNumber){.negative = 0,.exponent = 0,.mantissa = 0,}); | |
| 5584 | + strconv__PrepNumber pn = _t1; | |
| 5585 | + for (;;) { | |
| 5586 | + if (!(i < s.len && builtin__u8_is_space(s.str[ i]))) break; | |
| 5587 | + i++; | |
| 5588 | + } | |
| 5589 | + if (s.str[ i] == '-') { | |
| 5590 | + pn.negative = true; | |
| 5591 | + i++; | |
| 5592 | + } | |
| 5593 | + if (s.str[ i] == '+') { | |
| 5594 | + i++; | |
| 5595 | + } | |
| 5596 | + for (;;) { | |
| 5597 | + if (!(i < s.len && builtin__u8_is_digit(s.str[ i]))) break; | |
| 5598 | + if (pn.mantissa == 0 && s.str[ i] == _const_strconv__c_zero) { | |
| 5599 | + i++; | |
| 5600 | + continue; | |
| 5601 | + } | |
| 5602 | + if (digx < 18) { | |
| 5603 | + pn.mantissa *= 10; | |
| 5604 | + pn.mantissa += ((u64)((rune)(s.str[ i] - _const_strconv__c_zero))); | |
| 5605 | + digx++; | |
| 5606 | + } else if (pn.exponent < 2147483647) { | |
| 5607 | + pn.exponent++; | |
| 5608 | + } | |
| 5609 | + i++; | |
| 5610 | + } | |
| 5611 | + if (i < s.len && s.str[ i] == '.') { | |
| 5612 | + i++; | |
| 5613 | + for (;;) { | |
| 5614 | + if (!(i < s.len && builtin__u8_is_digit(s.str[ i]))) break; | |
| 5615 | + if (pn.mantissa == 0 && s.str[ i] == _const_strconv__c_zero) { | |
| 5616 | + pn.exponent--; | |
| 5617 | + i++; | |
| 5618 | + continue; | |
| 5619 | + } | |
| 5620 | + if (digx < 18) { | |
| 5621 | + pn.mantissa *= 10; | |
| 5622 | + pn.mantissa += ((u64)((rune)(s.str[ i] - _const_strconv__c_zero))); | |
| 5623 | + pn.exponent--; | |
| 5624 | + digx++; | |
| 5625 | + } | |
| 5626 | + i++; | |
| 5627 | + } | |
| 5628 | + } | |
| 5629 | + if (i < s.len && (s.str[ i] == 'e' || s.str[ i] == 'E')) { | |
| 5630 | + i++; | |
| 5631 | + if (i < s.len) { | |
| 5632 | + if (s.str[ i] == _const_strconv__c_plus) { | |
| 5633 | + i++; | |
| 5634 | + } else if (s.str[ i] == _const_strconv__c_minus) { | |
| 5635 | + expneg = true; | |
| 5636 | + i++; | |
| 5637 | + } | |
| 5638 | + for (;;) { | |
| 5639 | + if (!(i < s.len && builtin__u8_is_digit(s.str[ i]))) break; | |
| 5640 | + if (expexp < 214748364) { | |
| 5641 | + expexp *= 10; | |
| 5642 | + expexp += ((int)((rune)(s.str[ i] - _const_strconv__c_zero))); | |
| 5643 | + } | |
| 5644 | + i++; | |
| 5645 | + } | |
| 5646 | + } | |
| 5647 | + } | |
| 5648 | + if (expneg) { | |
| 5649 | + expexp = -expexp; | |
| 5650 | + } | |
| 5651 | + pn.exponent += expexp; | |
| 5652 | + if (pn.mantissa == 0) { | |
| 5653 | + if (pn.negative) { | |
| 5654 | + result = strconv__ParserState__mzero; | |
| 5655 | + } else { | |
| 5656 | + result = strconv__ParserState__pzero; | |
| 5657 | + } | |
| 5658 | + } else if (pn.exponent > 309) { | |
| 5659 | + if (pn.negative) { | |
| 5660 | + result = strconv__ParserState__minf; | |
| 5661 | + } else { | |
| 5662 | + result = strconv__ParserState__pinf; | |
| 5663 | + } | |
| 5664 | + } else if (pn.exponent < -328) { | |
| 5665 | + if (pn.negative) { | |
| 5666 | + result = strconv__ParserState__mzero; | |
| 5667 | + } else { | |
| 5668 | + result = strconv__ParserState__pzero; | |
| 5669 | + } | |
| 5670 | + } | |
| 5671 | + if (i == 0 && s.len > 0) { | |
| 5672 | + return (multi_return_strconv__ParserState_strconv__PrepNumber){.arg0=strconv__ParserState__invalid_number, .arg1=pn}; | |
| 5673 | + } | |
| 5674 | + if (i != s.len) { | |
| 5675 | + return (multi_return_strconv__ParserState_strconv__PrepNumber){.arg0=strconv__ParserState__extra_char, .arg1=pn}; | |
| 5676 | + } | |
| 5677 | + return (multi_return_strconv__ParserState_strconv__PrepNumber){.arg0=result, .arg1=pn}; | |
| 5678 | +} | |
| 5679 | +VV_LOC u64 strconv__converter(strconv__PrepNumber* pn) { | |
| 5680 | + int binexp = 92; | |
| 5681 | + u32 s2 = ((u32)(0)); | |
| 5682 | + u32 s1 = ((u32)(0)); | |
| 5683 | + u32 s0 = ((u32)(0)); | |
| 5684 | + u32 q2 = ((u32)(0)); | |
| 5685 | + u32 q1 = ((u32)(0)); | |
| 5686 | + u32 q0 = ((u32)(0)); | |
| 5687 | + u32 r2 = ((u32)(0)); | |
| 5688 | + u32 r1 = ((u32)(0)); | |
| 5689 | + u32 r0 = ((u32)(0)); | |
| 5690 | + u32 mask28 = ((u32)(v__lshift_u64(((u64)(0xF)), (u64)28))); | |
| 5691 | + u64 result = ((u64)(0)); | |
| 5692 | + s0 = ((u32)((pn->mantissa & ((u64)(0x00000000FFFFFFFFU))))); | |
| 5693 | + s1 = ((u32)(v__rshift_u64(pn->mantissa, (u64)32))); | |
| 5694 | + s2 = ((u32)(0)); | |
| 5695 | + if (pn->mantissa == 0 && pn->exponent <= 0) { | |
| 5696 | + return (pn->negative ? (_const_strconv__double_minus_zero) : (_const_strconv__double_plus_zero)); | |
| 5697 | + } | |
| 5698 | + for (;;) { | |
| 5699 | + if (!(pn->exponent > 0)) break; | |
| 5700 | + multi_return_u32_u32_u32 mr_5881 = strconv__lsl96(s2, s1, s0); | |
| 5701 | + q2 = mr_5881.arg0; | |
| 5702 | + q1 = mr_5881.arg1; | |
| 5703 | + q0 = mr_5881.arg2; | |
| 5704 | + multi_return_u32_u32_u32 mr_5927 = strconv__lsl96(q2, q1, q0); | |
| 5705 | + r2 = mr_5927.arg0; | |
| 5706 | + r1 = mr_5927.arg1; | |
| 5707 | + r0 = mr_5927.arg2; | |
| 5708 | + multi_return_u32_u32_u32 mr_5983 = strconv__lsl96(r2, r1, r0); | |
| 5709 | + s2 = mr_5983.arg0; | |
| 5710 | + s1 = mr_5983.arg1; | |
| 5711 | + s0 = mr_5983.arg2; | |
| 5712 | + multi_return_u32_u32_u32 mr_6039 = strconv__add96(s2, s1, s0, q2, q1, q0); | |
| 5713 | + s2 = mr_6039.arg0; | |
| 5714 | + s1 = mr_6039.arg1; | |
| 5715 | + s0 = mr_6039.arg2; | |
| 5716 | + pn->exponent--; | |
| 5717 | + for (;;) { | |
| 5718 | + if (!(((s2 & mask28)) != 0)) break; | |
| 5719 | + multi_return_u32_u32_u32 mr_6162 = strconv__lsr96(s2, s1, s0); | |
| 5720 | + q2 = mr_6162.arg0; | |
| 5721 | + q1 = mr_6162.arg1; | |
| 5722 | + q0 = mr_6162.arg2; | |
| 5723 | + binexp++; | |
| 5724 | + s2 = q2; | |
| 5725 | + s1 = q1; | |
| 5726 | + s0 = q0; | |
| 5727 | + } | |
| 5728 | + } | |
| 5729 | + for (;;) { | |
| 5730 | + if (!(pn->exponent < 0)) break; | |
| 5731 | + for (;;) { | |
| 5732 | + if (!(!(((s2 & (v__lshift_u32(((u32)(1)), (u64)31)))) != 0))) break; | |
| 5733 | + multi_return_u32_u32_u32 mr_6309 = strconv__lsl96(s2, s1, s0); | |
| 5734 | + q2 = mr_6309.arg0; | |
| 5735 | + q1 = mr_6309.arg1; | |
| 5736 | + q0 = mr_6309.arg2; | |
| 5737 | + binexp--; | |
| 5738 | + s2 = q2; | |
| 5739 | + s1 = q1; | |
| 5740 | + s0 = q0; | |
| 5741 | + } | |
| 5742 | + q2 = VSAFE_DIV_u32(s2 , _const_strconv__c_ten); | |
| 5743 | + r1 = VSAFE_MOD_u32(s2 , _const_strconv__c_ten); | |
| 5744 | + r2 = ((v__rshift_u32(s1, (u64)8)) | (v__lshift_u32(r1, (u64)24))); | |
| 5745 | + q1 = VSAFE_DIV_u32(r2 , _const_strconv__c_ten); | |
| 5746 | + r1 = VSAFE_MOD_u32(r2 , _const_strconv__c_ten); | |
| 5747 | + r2 = (((v__lshift_u32(((s1 & ((u32)(0xFF)))), (u64)16)) | (v__rshift_u32(s0, (u64)16))) | (v__lshift_u32(r1, (u64)24))); | |
| 5748 | + r0 = VSAFE_DIV_u32(r2 , _const_strconv__c_ten); | |
| 5749 | + r1 = VSAFE_MOD_u32(r2 , _const_strconv__c_ten); | |
| 5750 | + q1 = ((v__lshift_u32(q1, (u64)8)) | (v__rshift_u32(((r0 & ((u32)(0x00FF0000)))), (u64)16))); | |
| 5751 | + q0 = v__lshift_u32(r0, (u64)16); | |
| 5752 | + r2 = (((s0 & ((u32)(0xFFFF)))) | (v__lshift_u32(r1, (u64)16))); | |
| 5753 | + q0 |= VSAFE_DIV_u32(r2 , _const_strconv__c_ten); | |
| 5754 | + s2 = q2; | |
| 5755 | + s1 = q1; | |
| 5756 | + s0 = q0; | |
| 5757 | + pn->exponent++; | |
| 5758 | + } | |
| 5759 | + if (s2 != 0 || s1 != 0 || s0 != 0) { | |
| 5760 | + for (;;) { | |
| 5761 | + if (!(((s2 & mask28)) == 0)) break; | |
| 5762 | + multi_return_u32_u32_u32 mr_6989 = strconv__lsl96(s2, s1, s0); | |
| 5763 | + q2 = mr_6989.arg0; | |
| 5764 | + q1 = mr_6989.arg1; | |
| 5765 | + q0 = mr_6989.arg2; | |
| 5766 | + binexp--; | |
| 5767 | + s2 = q2; | |
| 5768 | + s1 = q1; | |
| 5769 | + s0 = q0; | |
| 5770 | + } | |
| 5771 | + } | |
| 5772 | + if (binexp < -1022 && ((s2 | s1)) != 0) { | |
| 5773 | + int shift = -1022 - binexp; | |
| 5774 | + if (shift > 60) { | |
| 5775 | + return (pn->negative ? (_const_strconv__double_minus_zero) : (_const_strconv__double_plus_zero)); | |
| 5776 | + } | |
| 5777 | + u64 shifted = v__rshift_u64((((v__lshift_u64(((u64)(s2)), (u64)32)) | ((u64)(s1)))), (u64)((u32)(shift))); | |
| 5778 | + u64 q = (v__rshift_u64(shifted, (u64)8)) + (u64[]){(((v__rshift_u64(shifted, (u64)7)) & 1) != 0 && (((shifted & 0x7F)) != 0 || ((v__rshift_u64(shifted, (u64)8)) & 1) != 0))?1:0}[0]; | |
| 5779 | + return (((q & 0x000FFFFFFFFFFFFFLL)) | (v__lshift_u64((u64[]){(pn->negative)?1:0}[0], (u64)63))); | |
| 5780 | + } | |
| 5781 | + int nbit = 7; | |
| 5782 | + u32 check_round_bit = v__lshift_u32(((u32)(1)), (u64)((u32)(nbit))); | |
| 5783 | + u32 check_round_mask = v__lshift_u32(((u32)(0xFFFFFFFFU)), (u64)((u32)(nbit))); | |
| 5784 | + if (((s1 & check_round_bit)) != 0) { | |
| 5785 | + if (((s1 & ~check_round_mask)) != 0) { | |
| 5786 | + multi_return_u32_u32_u32 mr_9182 = strconv__add96(s2, s1, s0, 0, check_round_bit, 0); | |
| 5787 | + s2 = mr_9182.arg0; | |
| 5788 | + s1 = mr_9182.arg1; | |
| 5789 | + s0 = mr_9182.arg2; | |
| 5790 | + } else { | |
| 5791 | + if (((s1 & (v__lshift_u32(check_round_bit, (u64)((u32)(1)))))) != 0) { | |
| 5792 | + multi_return_u32_u32_u32 mr_9376 = strconv__add96(s2, s1, s0, 0, check_round_bit, 0); | |
| 5793 | + s2 = mr_9376.arg0; | |
| 5794 | + s1 = mr_9376.arg1; | |
| 5795 | + s0 = mr_9376.arg2; | |
| 5796 | + } | |
| 5797 | + } | |
| 5798 | + s1 = (s1 & check_round_mask); | |
| 5799 | + s0 = ((u32)(0)); | |
| 5800 | + if ((s2 & (v__lshift_u32(mask28, (u64)((u32)(1))))) != 0) { | |
| 5801 | + multi_return_u32_u32_u32 mr_9583 = strconv__lsr96(s2, s1, s0); | |
| 5802 | + q2 = mr_9583.arg0; | |
| 5803 | + q1 = mr_9583.arg1; | |
| 5804 | + q0 = mr_9583.arg2; | |
| 5805 | + binexp++; | |
| 5806 | + s2 = q2; | |
| 5807 | + s1 = q1; | |
| 5808 | + s0 = q0; | |
| 5809 | + } | |
| 5810 | + } | |
| 5811 | + binexp += 1023; | |
| 5812 | + if (binexp > 2046) { | |
| 5813 | + if (pn->negative) { | |
| 5814 | + result = _const_strconv__double_minus_infinity; | |
| 5815 | + } else { | |
| 5816 | + result = _const_strconv__double_plus_infinity; | |
| 5817 | + } | |
| 5818 | + } else if (binexp < 1) { | |
| 5819 | + if (pn->negative) { | |
| 5820 | + result = _const_strconv__double_minus_zero; | |
| 5821 | + } else { | |
| 5822 | + result = _const_strconv__double_plus_zero; | |
| 5823 | + } | |
| 5824 | + } else if (s2 != 0) { | |
| 5825 | + u64 q = ((u64)(0)); | |
| 5826 | + u64 binexs2 = v__lshift_u64(((u64)(binexp)), (u64)52); | |
| 5827 | + q = (((v__lshift_u64(((u64)((s2 & ~mask28))), (u64)24)) | (v__rshift_u64((((u64)(s1)) + ((u64)(128))), (u64)8))) | binexs2); | |
| 5828 | + if (pn->negative) { | |
| 5829 | + q |= (v__lshift_u64(((u64)(1)), (u64)63)); | |
| 5830 | + } | |
| 5831 | + result = q; | |
| 5832 | + } | |
| 5833 | + return result; | |
| 5834 | +} | |
| 5835 | +_result_f64 strconv__atof64(string s, strconv__AtoF64Param param) { | |
| 5836 | + if (s.len == 0) { | |
| 5837 | + return (_result_f64){ .is_error=true, .err=builtin___v_error(_S("expected a number found an empty string")), .data={E_STRUCT} }; | |
| 5838 | + } | |
| 5839 | + strconv__Float64u _t2 = ((strconv__Float64u){0}); | |
| 5840 | + strconv__Float64u res = _t2; | |
| 5841 | + multi_return_strconv__ParserState_strconv__PrepNumber mr_10868 = strconv__parser(s); | |
| 5842 | + strconv__ParserState res_parsing = mr_10868.arg0; | |
| 5843 | + strconv__PrepNumber pn = mr_10868.arg1; | |
| 5844 | + switch (res_parsing) { | |
| 5845 | + case strconv__ParserState__ok: { | |
| 5846 | + res.u = strconv__converter((voidptr)&pn); | |
| 5847 | + break; | |
| 5848 | + } | |
| 5849 | + case strconv__ParserState__pzero: { | |
| 5850 | + res.u = _const_strconv__double_plus_zero; | |
| 5851 | + break; | |
| 5852 | + } | |
| 5853 | + case strconv__ParserState__mzero: { | |
| 5854 | + res.u = _const_strconv__double_minus_zero; | |
| 5855 | + break; | |
| 5856 | + } | |
| 5857 | + case strconv__ParserState__pinf: { | |
| 5858 | + res.u = _const_strconv__double_plus_infinity; | |
| 5859 | + break; | |
| 5860 | + } | |
| 5861 | + case strconv__ParserState__minf: { | |
| 5862 | + res.u = _const_strconv__double_minus_infinity; | |
| 5863 | + break; | |
| 5864 | + } | |
| 5865 | + case strconv__ParserState__extra_char: { | |
| 5866 | + if (param.allow_extra_chars) { | |
| 5867 | + res.u = strconv__converter((voidptr)&pn); | |
| 5868 | + } else { | |
| 5869 | + return (_result_f64){ .is_error=true, .err=builtin___v_error(_S("extra char after number")), .data={E_STRUCT} }; | |
| 5870 | + } | |
| 5871 | + break; | |
| 5872 | + } | |
| 5873 | + case strconv__ParserState__invalid_number: { | |
| 5874 | + return (_result_f64){ .is_error=true, .err=builtin___v_error(_S("not a number")), .data={E_STRUCT} }; | |
| 5875 | + } | |
| 5876 | + } | |
| 5877 | + | |
| 5878 | + _result_f64 _t5; | |
| 5879 | + builtin___result_ok(&(f64[]) { res.f }, (_result*)(&_t5), sizeof(f64)); | |
| 5880 | + | |
| 5881 | + return _t5; | |
| 5882 | +} | |
| 5883 | +f64 strconv__atof_quick(string s) { | |
| 5884 | + strconv__Float64u _t1 = ((strconv__Float64u){0}); | |
| 5885 | + strconv__Float64u f = _t1; | |
| 5886 | + f64 sign = ((f64)(1.0)); | |
| 5887 | + int i = 0; | |
| 5888 | + for (;;) { | |
| 5889 | + if (!(i < s.len && s.str[ i] == ' ')) break; | |
| 5890 | + i++; | |
| 5891 | + } | |
| 5892 | + if (i < s.len) { | |
| 5893 | + if (s.str[ i] == '-') { | |
| 5894 | + sign = -1.0; | |
| 5895 | + i++; | |
| 5896 | + } else if (s.str[ i] == '+') { | |
| 5897 | + i++; | |
| 5898 | + } | |
| 5899 | + } | |
| 5900 | + if (s.str[ i] == 'i' && i + 2 < s.len && s.str[ i + 1] == 'n' && s.str[ i + 2] == 'f') { | |
| 5901 | + if (sign > ((f64)(0.0))) { | |
| 5902 | + f.u = _const_strconv__double_plus_infinity; | |
| 5903 | + } else { | |
| 5904 | + f.u = _const_strconv__double_minus_infinity; | |
| 5905 | + } | |
| 5906 | + return f.f; | |
| 5907 | + } | |
| 5908 | + for (;;) { | |
| 5909 | + if (!(i < s.len && s.str[ i] == '0')) break; | |
| 5910 | + i++; | |
| 5911 | + if (i >= s.len) { | |
| 5912 | + if (sign > ((f64)(0.0))) { | |
| 5913 | + f.u = _const_strconv__double_plus_zero; | |
| 5914 | + } else { | |
| 5915 | + f.u = _const_strconv__double_minus_zero; | |
| 5916 | + } | |
| 5917 | + return f.f; | |
| 5918 | + } | |
| 5919 | + } | |
| 5920 | + for (;;) { | |
| 5921 | + if (!(i < s.len && (s.str[ i] >= '0' && s.str[ i] <= '9'))) break; | |
| 5922 | + f.f *= ((f64)(10.0)); | |
| 5923 | + f.f += ((f64)((rune)(s.str[ i] - '0'))); | |
| 5924 | + i++; | |
| 5925 | + } | |
| 5926 | + if (i < s.len && s.str[ i] == '.') { | |
| 5927 | + i++; | |
| 5928 | + f64 frac_mul = ((f64)(0.1)); | |
| 5929 | + for (;;) { | |
| 5930 | + if (!(i < s.len && (s.str[ i] >= '0' && s.str[ i] <= '9'))) break; | |
| 5931 | + f.f += ((f64)((rune)(s.str[ i] - '0'))) * frac_mul; | |
| 5932 | + frac_mul *= ((f64)(0.1)); | |
| 5933 | + i++; | |
| 5934 | + } | |
| 5935 | + } | |
| 5936 | + if (i < s.len && (s.str[ i] == 'e' || s.str[ i] == 'E')) { | |
| 5937 | + i++; | |
| 5938 | + int exp = 0; | |
| 5939 | + int exp_sign = 1; | |
| 5940 | + if (i < s.len) { | |
| 5941 | + if (s.str[ i] == '-') { | |
| 5942 | + exp_sign = -1; | |
| 5943 | + i++; | |
| 5944 | + } else if (s.str[ i] == '+') { | |
| 5945 | + i++; | |
| 5946 | + } | |
| 5947 | + } | |
| 5948 | + for (;;) { | |
| 5949 | + if (!(i < s.len && s.str[ i] == '0')) break; | |
| 5950 | + i++; | |
| 5951 | + } | |
| 5952 | + for (;;) { | |
| 5953 | + if (!(i < s.len && (s.str[ i] >= '0' && s.str[ i] <= '9'))) break; | |
| 5954 | + exp *= 10; | |
| 5955 | + exp += ((int)((rune)(s.str[ i] - '0'))); | |
| 5956 | + i++; | |
| 5957 | + } | |
| 5958 | + if (exp_sign == 1) { | |
| 5959 | + if (exp > 309) { | |
| 5960 | + if (sign > 0) { | |
| 5961 | + f.u = _const_strconv__double_plus_infinity; | |
| 5962 | + } else { | |
| 5963 | + f.u = _const_strconv__double_minus_infinity; | |
| 5964 | + } | |
| 5965 | + return f.f; | |
| 5966 | + } | |
| 5967 | + strconv__Float64u _t5 = ((strconv__Float64u){.u = _const_strconv__pos_exp[exp],}); | |
| 5968 | + strconv__Float64u tmp_mul = _t5; | |
| 5969 | + f.f = f.f * tmp_mul.f; | |
| 5970 | + } else { | |
| 5971 | + if (exp > 324) { | |
| 5972 | + if (sign > 0) { | |
| 5973 | + f.u = _const_strconv__double_plus_zero; | |
| 5974 | + } else { | |
| 5975 | + f.u = _const_strconv__double_minus_zero; | |
| 5976 | + } | |
| 5977 | + return f.f; | |
| 5978 | + } | |
| 5979 | + strconv__Float64u _t7 = ((strconv__Float64u){.u = _const_strconv__neg_exp[exp],}); | |
| 5980 | + strconv__Float64u tmp_mul = _t7; | |
| 5981 | + f.f = f.f * tmp_mul.f; | |
| 5982 | + } | |
| 5983 | + } | |
| 5984 | + { // Unsafe block | |
| 5985 | + f.f = f.f * sign; | |
| 5986 | + return f.f; | |
| 5987 | + } | |
| 5988 | + return 0; | |
| 5989 | +} | |
| 5990 | +inline u8 strconv__byte_to_lower(u8 c) { | |
| 5991 | + return (c | 32); | |
| 5992 | +} | |
| 5993 | +_result_u64 strconv__common_parse_uint(string s, int _base, int _bit_size, bool error_on_non_digit, bool error_on_high_digit) { | |
| 5994 | + multi_return_u64_int mr_730 = strconv__common_parse_uint2(s, _base, _bit_size); | |
| 5995 | + u64 result = mr_730.arg0; | |
| 5996 | + int err = mr_730.arg1; | |
| 5997 | + if (err != 0 && (error_on_non_digit || error_on_high_digit)) { | |
| 5998 | + switch (err) { | |
| 5999 | + case -1: { | |
| 6000 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(4, _MOV((string[4]){_S("common_parse_uint: wrong base "), builtin__int_str(_base), _S(" for "), s}))), .data={E_STRUCT} }; | |
| 6001 | + } | |
| 6002 | + case -2: { | |
| 6003 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(4, _MOV((string[4]){_S("common_parse_uint: wrong bit size "), builtin__int_str(_bit_size), _S(" for "), s}))), .data={E_STRUCT} }; | |
| 6004 | + } | |
| 6005 | + case -3: { | |
| 6006 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(2, _MOV((string[2]){_S("common_parse_uint: integer overflow "), s}))), .data={E_STRUCT} }; | |
| 6007 | + } | |
| 6008 | + default: { | |
| 6009 | + { | |
| 6010 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(2, _MOV((string[2]){_S("common_parse_uint: syntax error "), s}))), .data={E_STRUCT} }; | |
| 6011 | + } | |
| 6012 | + } | |
| 6013 | + } | |
| 6014 | + | |
| 6015 | + } | |
| 6016 | + _result_u64 _t5; | |
| 6017 | + builtin___result_ok(&(u64[]) { result }, (_result*)(&_t5), sizeof(u64)); | |
| 6018 | + | |
| 6019 | + return _t5; | |
| 6020 | +} | |
| 6021 | +multi_return_u64_int strconv__common_parse_uint2(string s, int _base, int _bit_size) { | |
| 6022 | + if ((s).len == 0) { | |
| 6023 | + return (multi_return_u64_int){.arg0=((u64)(0)), .arg1=1}; | |
| 6024 | + } | |
| 6025 | + int bit_size = _bit_size; | |
| 6026 | + int base = _base; | |
| 6027 | + int start_index = 0; | |
| 6028 | + if (base == 0) { | |
| 6029 | + base = 10; | |
| 6030 | + if (s.str[ 0] == '0') { | |
| 6031 | + u8 ch = (s.len > 1 ? ((s.str[ 1] | 32)) : ('0')); | |
| 6032 | + if (s.len >= 3) { | |
| 6033 | + if (ch == 'b') { | |
| 6034 | + base = 2; | |
| 6035 | + start_index += 2; | |
| 6036 | + } else if (ch == 'o') { | |
| 6037 | + base = 8; | |
| 6038 | + start_index += 2; | |
| 6039 | + } else if (ch == 'x') { | |
| 6040 | + base = 16; | |
| 6041 | + start_index += 2; | |
| 6042 | + } | |
| 6043 | + if (s.str[ start_index] == '_') { | |
| 6044 | + start_index++; | |
| 6045 | + } | |
| 6046 | + } else if (s.len >= 2 && (s.str[ 1] >= '0' && s.str[ 1] <= '9')) { | |
| 6047 | + base = 10; | |
| 6048 | + start_index++; | |
| 6049 | + } else { | |
| 6050 | + base = 8; | |
| 6051 | + start_index++; | |
| 6052 | + } | |
| 6053 | + } | |
| 6054 | + } | |
| 6055 | + if (bit_size == 0) { | |
| 6056 | + bit_size = _const_strconv__int_size; | |
| 6057 | + } else if (bit_size < 0 || bit_size > 64) { | |
| 6058 | + return (multi_return_u64_int){.arg0=((u64)(0)), .arg1=-2}; | |
| 6059 | + } | |
| 6060 | + u64 cutoff = VSAFE_DIV_u64(_const_max_u64 , ((u64)(base))) + ((u64)(1)); | |
| 6061 | + u64 max_val = (bit_size == 64 ? (_const_max_u64) : ((v__lshift_u64(((u64)(1)), (u64)((u64)(bit_size)))) - ((u64)(1)))); | |
| 6062 | + int basem1 = base - 1; | |
| 6063 | + u64 n = ((u64)(0)); | |
| 6064 | + for (int i = start_index; i < s.len; ++i) { | |
| 6065 | + u8 c = s.str[ i]; | |
| 6066 | + if (c == '_') { | |
| 6067 | + if (i == start_index || i >= (s.len - 1)) { | |
| 6068 | + return (multi_return_u64_int){.arg0=((u64)(0)), .arg1=1}; | |
| 6069 | + } | |
| 6070 | + if (s.str[ i - 1] == '_' || s.str[ i + 1] == '_') { | |
| 6071 | + return (multi_return_u64_int){.arg0=((u64)(0)), .arg1=1}; | |
| 6072 | + } | |
| 6073 | + continue; | |
| 6074 | + } | |
| 6075 | + int sub_count = 0; | |
| 6076 | + c -= 48; | |
| 6077 | + if (c >= 17) { | |
| 6078 | + sub_count++; | |
| 6079 | + c -= 7; | |
| 6080 | + if (c >= 42) { | |
| 6081 | + sub_count++; | |
| 6082 | + c -= 32; | |
| 6083 | + } | |
| 6084 | + } | |
| 6085 | + if (c > basem1 || (sub_count == 0 && c > 9)) { | |
| 6086 | + return (multi_return_u64_int){.arg0=n, .arg1=i + 1}; | |
| 6087 | + } | |
| 6088 | + if (n >= cutoff) { | |
| 6089 | + return (multi_return_u64_int){.arg0=max_val, .arg1=-3}; | |
| 6090 | + } | |
| 6091 | + n *= ((u64)(base)); | |
| 6092 | + u64 n1 = n + ((u64)(c)); | |
| 6093 | + if (n1 < n || n1 > max_val) { | |
| 6094 | + return (multi_return_u64_int){.arg0=max_val, .arg1=-3}; | |
| 6095 | + } | |
| 6096 | + n = n1; | |
| 6097 | + } | |
| 6098 | + return (multi_return_u64_int){.arg0=n, .arg1=0}; | |
| 6099 | +} | |
| 6100 | +_result_u64 strconv__parse_uint(string s, int _base, int _bit_size) { | |
| 6101 | + return strconv__common_parse_uint(s, _base, _bit_size, true, true); | |
| 6102 | +} | |
| 6103 | +_result_i64 strconv__common_parse_int(string _s, int base, int _bit_size, bool error_on_non_digit, bool error_on_high_digit) { | |
| 6104 | + if ((_s).len == 0) { | |
| 6105 | + _result_i64 _t1; | |
| 6106 | + builtin___result_ok(&(i64[]) { ((i64)(0)) }, (_result*)(&_t1), sizeof(i64)); | |
| 6107 | + | |
| 6108 | + return _t1; | |
| 6109 | + } | |
| 6110 | + int bit_size = _bit_size; | |
| 6111 | + if (bit_size == 0) { | |
| 6112 | + bit_size = _const_strconv__int_size; | |
| 6113 | + } | |
| 6114 | + string s = _s; | |
| 6115 | + bool neg = false; | |
| 6116 | + if (s.str[ 0] == '+') { | |
| 6117 | + { // Unsafe block | |
| 6118 | + s = builtin__tos(s.str + 1, s.len - 1); | |
| 6119 | + } | |
| 6120 | + } else if (s.str[ 0] == '-') { | |
| 6121 | + neg = true; | |
| 6122 | + { // Unsafe block | |
| 6123 | + s = builtin__tos(s.str + 1, s.len - 1); | |
| 6124 | + } | |
| 6125 | + } | |
| 6126 | + _result_u64 _t2 = strconv__common_parse_uint(s, base, bit_size, error_on_non_digit, error_on_high_digit); | |
| 6127 | + if (_t2.is_error) { | |
| 6128 | + _result_i64 _t3 = {0}; | |
| 6129 | + _t3.is_error = true; | |
| 6130 | + _t3.err = _t2.err; | |
| 6131 | + return _t3; | |
| 6132 | + } | |
| 6133 | + | |
| 6134 | + u64 un = (*(u64*)_t2.data); | |
| 6135 | + if (un == 0) { | |
| 6136 | + _result_i64 _t4; | |
| 6137 | + builtin___result_ok(&(i64[]) { ((i64)(0)) }, (_result*)(&_t4), sizeof(i64)); | |
| 6138 | + | |
| 6139 | + return _t4; | |
| 6140 | + } | |
| 6141 | + u64 cutoff = v__lshift_u64(((u64)(1)), (u64)((u64)(bit_size - 1))); | |
| 6142 | + if (!neg && un >= cutoff) { | |
| 6143 | + if (error_on_high_digit) { | |
| 6144 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(2, _MOV((string[2]){_S("common_parse_int: integer overflow "), _s}))), .data={E_STRUCT} }; | |
| 6145 | + } | |
| 6146 | + _result_i64 _t6; | |
| 6147 | + builtin___result_ok(&(i64[]) { ((i64)(cutoff - ((u64)(1)))) }, (_result*)(&_t6), sizeof(i64)); | |
| 6148 | + | |
| 6149 | + return _t6; | |
| 6150 | + } | |
| 6151 | + if (neg && un > cutoff) { | |
| 6152 | + if (error_on_high_digit) { | |
| 6153 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(2, _MOV((string[2]){_S("common_parse_int: integer overflow "), _s}))), .data={E_STRUCT} }; | |
| 6154 | + } | |
| 6155 | + _result_i64 _t8; | |
| 6156 | + builtin___result_ok(&(i64[]) { -((i64)(cutoff)) }, (_result*)(&_t8), sizeof(i64)); | |
| 6157 | + | |
| 6158 | + return _t8; | |
| 6159 | + } | |
| 6160 | + _result_i64 _t10; /* if prepend */ | |
| 6161 | + if (neg) { | |
| 6162 | + builtin___result_ok(&(i64[]) { -((i64)(un)) }, (_result*)(&_t10), sizeof(i64)); | |
| 6163 | + goto _t11; | |
| 6164 | + }; | |
| 6165 | + { | |
| 6166 | + builtin___result_ok(&(i64[]) { ((i64)(un)) }, (_result*)(&_t10), sizeof(i64)); | |
| 6167 | + } | |
| 6168 | + _t11: {}; | |
| 6169 | + return _t10; | |
| 6170 | +} | |
| 6171 | +_result_i64 strconv__parse_int(string _s, int base, int _bit_size) { | |
| 6172 | + return strconv__common_parse_int(_s, base, _bit_size, true, false); | |
| 6173 | +} | |
| 6174 | +VV_LOC _result_multi_return_i64_int strconv__atoi_common_check(string s) { | |
| 6175 | + if ((s).len == 0) { | |
| 6176 | + return (_result_multi_return_i64_int){ .is_error=true, .err=builtin___v_error(_S("strconv.atoi: parsing \"\": empty string")), .data={E_STRUCT} }; | |
| 6177 | + } | |
| 6178 | + int start_idx = 0; | |
| 6179 | + i64 sign = ((i64)(1)); | |
| 6180 | + if (s.str[ 0] == '-' || s.str[ 0] == '+') { | |
| 6181 | + start_idx++; | |
| 6182 | + if (s.str[ 0] == '-') { | |
| 6183 | + sign = -1; | |
| 6184 | + } | |
| 6185 | + } | |
| 6186 | + if (s.len - start_idx < 1) { | |
| 6187 | + return (_result_multi_return_i64_int){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi: parsing \""), s, _S("\": no number after sign")}))), .data={E_STRUCT} }; | |
| 6188 | + } | |
| 6189 | + if (s.str[ start_idx] == '_' || s.str[ s.len - 1] == '_') { | |
| 6190 | + return (_result_multi_return_i64_int){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi: parsing \""), s, _S("\": values cannot start or end with underscores")}))), .data={E_STRUCT} }; | |
| 6191 | + } | |
| 6192 | + _result_multi_return_i64_int _t4; | |
| 6193 | + builtin___result_ok(&(multi_return_i64_int[]) { (multi_return_i64_int){.arg0=sign, .arg1=start_idx} }, (_result*)(&_t4), sizeof(multi_return_i64_int)); | |
| 6194 | + return _t4; | |
| 6195 | +} | |
| 6196 | +VV_LOC _result_i64 strconv__atoi_common(string s, i64 type_min, i64 type_max) { | |
| 6197 | + _result_multi_return_i64_int _t1 = strconv__atoi_common_check(s); | |
| 6198 | + if (_t1.is_error) { | |
| 6199 | + _result_i64 _t2 = {0}; | |
| 6200 | + _t2.is_error = true; | |
| 6201 | + _t2.err = _t1.err; | |
| 6202 | + return _t2; | |
| 6203 | + } | |
| 6204 | + | |
| 6205 | + multi_return_i64_int mr_7450 = (*(multi_return_i64_int*)_t1.data); | |
| 6206 | + i64 sign = mr_7450.arg0; | |
| 6207 | + int start_idx = mr_7450.arg1; | |
| 6208 | + i64 x = ((i64)(0)); | |
| 6209 | + bool underscored = false; | |
| 6210 | + for (int i = start_idx; i < s.len; ++i) { | |
| 6211 | + rune c = (rune)(s.str[ i] - '0'); | |
| 6212 | + if (c == 47) { | |
| 6213 | + if (underscored == true) { | |
| 6214 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi: parsing \""), s, _S("\": consecutives underscores are not allowed")}))), .data={E_STRUCT} }; | |
| 6215 | + } | |
| 6216 | + underscored = true; | |
| 6217 | + continue; | |
| 6218 | + } else { | |
| 6219 | + if (c > 9) { | |
| 6220 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi: parsing \""), s, _S("\": invalid radix 10 character")}))), .data={E_STRUCT} }; | |
| 6221 | + } | |
| 6222 | + underscored = false; | |
| 6223 | + x = (x * 10) + ((i64)(c * sign)); | |
| 6224 | + if (sign == 1 && x > type_max) { | |
| 6225 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi: parsing \""), s, _S("\": integer overflow")}))), .data={E_STRUCT} }; | |
| 6226 | + } else { | |
| 6227 | + if (x < type_min) { | |
| 6228 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi: parsing \""), s, _S("\": integer underflow")}))), .data={E_STRUCT} }; | |
| 6229 | + } | |
| 6230 | + } | |
| 6231 | + } | |
| 6232 | + } | |
| 6233 | + _result_i64 _t7; | |
| 6234 | + builtin___result_ok(&(i64[]) { x }, (_result*)(&_t7), sizeof(i64)); | |
| 6235 | + | |
| 6236 | + return _t7; | |
| 6237 | +} | |
| 6238 | +_result_int strconv__atoi(string s) { | |
| 6239 | + _result_i64 _t2 = strconv__atoi_common(s, _const_strconv__i64_min_int32, _const_strconv__i64_max_int32); | |
| 6240 | + if (_t2.is_error) { | |
| 6241 | + _result_int _t3 = {0}; | |
| 6242 | + _t3.is_error = true; | |
| 6243 | + _t3.err = _t2.err; | |
| 6244 | + return _t3; | |
| 6245 | + } | |
| 6246 | + | |
| 6247 | + _result_int _t1; | |
| 6248 | + builtin___result_ok(&(int[]) { ((int)((*(i64*)_t2.data))) }, (_result*)(&_t1), sizeof(int)); | |
| 6249 | + | |
| 6250 | + return _t1; | |
| 6251 | +} | |
| 6252 | +_result_i8 strconv__atoi8(string s) { | |
| 6253 | + _result_i64 _t2 = strconv__atoi_common(s, _const_min_i8, _const_max_i8); | |
| 6254 | + if (_t2.is_error) { | |
| 6255 | + _result_i8 _t3 = {0}; | |
| 6256 | + _t3.is_error = true; | |
| 6257 | + _t3.err = _t2.err; | |
| 6258 | + return _t3; | |
| 6259 | + } | |
| 6260 | + | |
| 6261 | + _result_i8 _t1; | |
| 6262 | + builtin___result_ok(&(i8[]) { ((i8)((*(i64*)_t2.data))) }, (_result*)(&_t1), sizeof(i8)); | |
| 6263 | + | |
| 6264 | + return _t1; | |
| 6265 | +} | |
| 6266 | +_result_i16 strconv__atoi16(string s) { | |
| 6267 | + _result_i64 _t2 = strconv__atoi_common(s, _const_min_i16, _const_max_i16); | |
| 6268 | + if (_t2.is_error) { | |
| 6269 | + _result_i16 _t3 = {0}; | |
| 6270 | + _t3.is_error = true; | |
| 6271 | + _t3.err = _t2.err; | |
| 6272 | + return _t3; | |
| 6273 | + } | |
| 6274 | + | |
| 6275 | + _result_i16 _t1; | |
| 6276 | + builtin___result_ok(&(i16[]) { ((i16)((*(i64*)_t2.data))) }, (_result*)(&_t1), sizeof(i16)); | |
| 6277 | + | |
| 6278 | + return _t1; | |
| 6279 | +} | |
| 6280 | +_result_i32 strconv__atoi32(string s) { | |
| 6281 | + _result_i64 _t2 = strconv__atoi_common(s, _const_min_i32, _const_max_i32); | |
| 6282 | + if (_t2.is_error) { | |
| 6283 | + _result_i32 _t3 = {0}; | |
| 6284 | + _t3.is_error = true; | |
| 6285 | + _t3.err = _t2.err; | |
| 6286 | + return _t3; | |
| 6287 | + } | |
| 6288 | + | |
| 6289 | + _result_i32 _t1; | |
| 6290 | + builtin___result_ok(&(i32[]) { ((i32)((*(i64*)_t2.data))) }, (_result*)(&_t1), sizeof(i32)); | |
| 6291 | + | |
| 6292 | + return _t1; | |
| 6293 | +} | |
| 6294 | +_result_i64 strconv__atoi64(string s) { | |
| 6295 | + _result_multi_return_i64_int _t1 = strconv__atoi_common_check(s); | |
| 6296 | + if (_t1.is_error) { | |
| 6297 | + _result_i64 _t2 = {0}; | |
| 6298 | + _t2.is_error = true; | |
| 6299 | + _t2.err = _t1.err; | |
| 6300 | + return _t2; | |
| 6301 | + } | |
| 6302 | + | |
| 6303 | + multi_return_i64_int mr_9202 = (*(multi_return_i64_int*)_t1.data); | |
| 6304 | + i64 sign = mr_9202.arg0; | |
| 6305 | + int start_idx = mr_9202.arg1; | |
| 6306 | + i64 x = ((i64)(0)); | |
| 6307 | + bool underscored = false; | |
| 6308 | + for (int i = start_idx; i < s.len; ++i) { | |
| 6309 | + rune c = (rune)(s.str[ i] - '0'); | |
| 6310 | + if (c == 47) { | |
| 6311 | + if (underscored == true) { | |
| 6312 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi64: parsing \""), s, _S("\": consecutives underscores are not allowed")}))), .data={E_STRUCT} }; | |
| 6313 | + } | |
| 6314 | + underscored = true; | |
| 6315 | + continue; | |
| 6316 | + } else { | |
| 6317 | + if (c > 9) { | |
| 6318 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi64: parsing \""), s, _S("\": invalid radix 10 character")}))), .data={E_STRUCT} }; | |
| 6319 | + } | |
| 6320 | + underscored = false; | |
| 6321 | + _result_i64 _t5 = strconv__safe_mul10_64bits(x); | |
| 6322 | + if (_t5.is_error) { | |
| 6323 | + IError _t6 = _t5.err; | |
| 6324 | + IError err = _t6; | |
| 6325 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__str_intp(3, _MOV((StrIntpData[]){{_S("strconv.atoi64: parsing \""), 0xfe10, {.d_s = s}, 0, 0, 0}, {_S("\": "), 0xfe10, {.d_s = builtin__IError_str(err)}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}))), .data={E_STRUCT} }; | |
| 6326 | + } | |
| 6327 | + | |
| 6328 | + x = (*(i64*)_t5.data); | |
| 6329 | + _result_i64 _t8 = strconv__safe_add_64bits(x, ((int)((i64)(c * sign)))); | |
| 6330 | + if (_t8.is_error) { | |
| 6331 | + IError _t9 = _t8.err; | |
| 6332 | + IError err = _t9; | |
| 6333 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__str_intp(3, _MOV((StrIntpData[]){{_S("strconv.atoi64: parsing \""), 0xfe10, {.d_s = s}, 0, 0, 0}, {_S("\": "), 0xfe10, {.d_s = builtin__IError_str(err)}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}))), .data={E_STRUCT} }; | |
| 6334 | + } | |
| 6335 | + | |
| 6336 | + x = (*(i64*)_t8.data); | |
| 6337 | + } | |
| 6338 | + } | |
| 6339 | + _result_i64 _t11; | |
| 6340 | + builtin___result_ok(&(i64[]) { x }, (_result*)(&_t11), sizeof(i64)); | |
| 6341 | + | |
| 6342 | + return _t11; | |
| 6343 | +} | |
| 6344 | +inline VV_LOC _result_i64 strconv__safe_add_64bits(i64 a, i64 b) { | |
| 6345 | + if (a > 0 && b > (_const_max_i64 - a)) { | |
| 6346 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(_S("integer overflow")), .data={E_STRUCT} }; | |
| 6347 | + } else if (a < 0 && b < (_const_min_i64 - a)) { | |
| 6348 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(_S("integer underflow")), .data={E_STRUCT} }; | |
| 6349 | + } | |
| 6350 | + _result_i64 _t3; | |
| 6351 | + builtin___result_ok(&(i64[]) { a + b }, (_result*)(&_t3), sizeof(i64)); | |
| 6352 | + | |
| 6353 | + return _t3; | |
| 6354 | +} | |
| 6355 | +inline VV_LOC _result_i64 strconv__safe_mul10_64bits(i64 a) { | |
| 6356 | + if (a > 0 && a > (VSAFE_DIV_i64(_const_max_i64 , 10))) { | |
| 6357 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(_S("integer overflow")), .data={E_STRUCT} }; | |
| 6358 | + } | |
| 6359 | + if (a < 0 && a < (VSAFE_DIV_i64(_const_min_i64 , 10))) { | |
| 6360 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(_S("integer underflow")), .data={E_STRUCT} }; | |
| 6361 | + } | |
| 6362 | + _result_i64 _t3; | |
| 6363 | + builtin___result_ok(&(i64[]) { a * 10 }, (_result*)(&_t3), sizeof(i64)); | |
| 6364 | + | |
| 6365 | + return _t3; | |
| 6366 | +} | |
| 6367 | +VV_LOC _result_int strconv__atou_common_check(string s) { | |
| 6368 | + if ((s).len == 0) { | |
| 6369 | + return (_result_int){ .is_error=true, .err=builtin___v_error(_S("strconv.atou: parsing \"\": empty string")), .data={E_STRUCT} }; | |
| 6370 | + } | |
| 6371 | + int start_idx = 0; | |
| 6372 | + if (s.str[ 0] == '-') { | |
| 6373 | + return (_result_int){ .is_error=true, .err=builtin___v_error(_S("strconv.atou: parsing \"{s}\" : negative value")), .data={E_STRUCT} }; | |
| 6374 | + } | |
| 6375 | + if (s.str[ 0] == '+') { | |
| 6376 | + start_idx++; | |
| 6377 | + } | |
| 6378 | + if (s.len - start_idx < 1) { | |
| 6379 | + return (_result_int){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atou: parsing \""), s, _S("\": no number after sign")}))), .data={E_STRUCT} }; | |
| 6380 | + } | |
| 6381 | + if (s.str[ start_idx] == '_' || s.str[ s.len - 1] == '_') { | |
| 6382 | + return (_result_int){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atou: parsing \""), s, _S("\": values cannot start or end with underscores")}))), .data={E_STRUCT} }; | |
| 6383 | + } | |
| 6384 | + _result_int _t5; | |
| 6385 | + builtin___result_ok(&(int[]) { start_idx }, (_result*)(&_t5), sizeof(int)); | |
| 6386 | + | |
| 6387 | + return _t5; | |
| 6388 | +} | |
| 6389 | +VV_LOC _result_u64 strconv__atou_common(string s, u64 type_max) { | |
| 6390 | + _result_int _t1 = strconv__atou_common_check(s); | |
| 6391 | + if (_t1.is_error) { | |
| 6392 | + _result_u64 _t2 = {0}; | |
| 6393 | + _t2.is_error = true; | |
| 6394 | + _t2.err = _t1.err; | |
| 6395 | + return _t2; | |
| 6396 | + } | |
| 6397 | + | |
| 6398 | + int start_idx = ((int)((*(int*)_t1.data))); | |
| 6399 | + u64 x = ((u64)(0)); | |
| 6400 | + bool underscored = false; | |
| 6401 | + for (int i = start_idx; i < s.len; ++i) { | |
| 6402 | + rune c = (rune)(s.str[ i] - '0'); | |
| 6403 | + if (c == 47) { | |
| 6404 | + if (underscored == true) { | |
| 6405 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atou: parsing \""), s, _S("\": consecutives underscores are not allowed")}))), .data={E_STRUCT} }; | |
| 6406 | + } | |
| 6407 | + underscored = true; | |
| 6408 | + continue; | |
| 6409 | + } else { | |
| 6410 | + if (c > 9) { | |
| 6411 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atou: parsing \""), s, _S("\": invalid radix 10 character")}))), .data={E_STRUCT} }; | |
| 6412 | + } | |
| 6413 | + underscored = false; | |
| 6414 | + if (x > VSAFE_DIV_u64(type_max , 10)) { | |
| 6415 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atou: parsing \""), s, _S("\": integer overflow")}))), .data={E_STRUCT} }; | |
| 6416 | + } | |
| 6417 | + x *= 10; | |
| 6418 | + if (x > type_max - ((u64)(c))) { | |
| 6419 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atou: parsing \""), s, _S("\": integer overflow")}))), .data={E_STRUCT} }; | |
| 6420 | + } | |
| 6421 | + x += ((u64)(c)); | |
| 6422 | + } | |
| 6423 | + } | |
| 6424 | + _result_u64 _t7; | |
| 6425 | + builtin___result_ok(&(u64[]) { x }, (_result*)(&_t7), sizeof(u64)); | |
| 6426 | + | |
| 6427 | + return _t7; | |
| 6428 | +} | |
| 6429 | +_result_u8 strconv__atou8(string s) { | |
| 6430 | + _result_u64 _t2 = strconv__atou_common(s, _const_max_u8); | |
| 6431 | + if (_t2.is_error) { | |
| 6432 | + _result_u8 _t3 = {0}; | |
| 6433 | + _t3.is_error = true; | |
| 6434 | + _t3.err = _t2.err; | |
| 6435 | + return _t3; | |
| 6436 | + } | |
| 6437 | + | |
| 6438 | + _result_u8 _t1; | |
| 6439 | + builtin___result_ok(&(u8[]) { ((u8)((*(u64*)_t2.data))) }, (_result*)(&_t1), sizeof(u8)); | |
| 6440 | + | |
| 6441 | + return _t1; | |
| 6442 | +} | |
| 6443 | +_result_u16 strconv__atou16(string s) { | |
| 6444 | + _result_u64 _t2 = strconv__atou_common(s, _const_max_u16); | |
| 6445 | + if (_t2.is_error) { | |
| 6446 | + _result_u16 _t3 = {0}; | |
| 6447 | + _t3.is_error = true; | |
| 6448 | + _t3.err = _t2.err; | |
| 6449 | + return _t3; | |
| 6450 | + } | |
| 6451 | + | |
| 6452 | + _result_u16 _t1; | |
| 6453 | + builtin___result_ok(&(u16[]) { ((u16)((*(u64*)_t2.data))) }, (_result*)(&_t1), sizeof(u16)); | |
| 6454 | + | |
| 6455 | + return _t1; | |
| 6456 | +} | |
| 6457 | +_result_u32 strconv__atou(string s) { | |
| 6458 | + _result_u64 _t2 = strconv__atou_common(s, _const_max_u32); | |
| 6459 | + if (_t2.is_error) { | |
| 6460 | + _result_u32 _t3 = {0}; | |
| 6461 | + _t3.is_error = true; | |
| 6462 | + _t3.err = _t2.err; | |
| 6463 | + return _t3; | |
| 6464 | + } | |
| 6465 | + | |
| 6466 | + _result_u32 _t1; | |
| 6467 | + builtin___result_ok(&(u32[]) { ((u32)((*(u64*)_t2.data))) }, (_result*)(&_t1), sizeof(u32)); | |
| 6468 | + | |
| 6469 | + return _t1; | |
| 6470 | +} | |
| 6471 | +_result_u32 strconv__atou32(string s) { | |
| 6472 | + _result_u64 _t2 = strconv__atou_common(s, _const_max_u32); | |
| 6473 | + if (_t2.is_error) { | |
| 6474 | + _result_u32 _t3 = {0}; | |
| 6475 | + _t3.is_error = true; | |
| 6476 | + _t3.err = _t2.err; | |
| 6477 | + return _t3; | |
| 6478 | + } | |
| 6479 | + | |
| 6480 | + _result_u32 _t1; | |
| 6481 | + builtin___result_ok(&(u32[]) { ((u32)((*(u64*)_t2.data))) }, (_result*)(&_t1), sizeof(u32)); | |
| 6482 | + | |
| 6483 | + return _t1; | |
| 6484 | +} | |
| 6485 | +_result_u64 strconv__atou64(string s) { | |
| 6486 | + _result_u64 _t2 = strconv__atou_common(s, _const_max_u64); | |
| 6487 | + if (_t2.is_error) { | |
| 6488 | + _result_u64 _t3 = {0}; | |
| 6489 | + _t3.is_error = true; | |
| 6490 | + _t3.err = _t2.err; | |
| 6491 | + return _t3; | |
| 6492 | + } | |
| 6493 | + | |
| 6494 | + _result_u64 _t1; | |
| 6495 | + builtin___result_ok(&(u64[]) { ((u64)((*(u64*)_t2.data))) }, (_result*)(&_t1), sizeof(u64)); | |
| 6496 | + | |
| 6497 | + return _t1; | |
| 6498 | +} | |
| 6499 | +string strconv__Dec32_get_string_32(strconv__Dec32 d, bool neg, int i_n_digit, int i_pad_digit) { | |
| 6500 | + int n_digit = i_n_digit + 1; | |
| 6501 | + int pad_digit = i_pad_digit + 1; | |
| 6502 | + u32 out = d.m; | |
| 6503 | + int out_len = strconv__dec_digits(out); | |
| 6504 | + int out_len_original = out_len; | |
| 6505 | + int fw_zeros = 0; | |
| 6506 | + if (pad_digit > out_len) { | |
| 6507 | + fw_zeros = pad_digit - out_len; | |
| 6508 | + } | |
| 6509 | + Array_u8 buf = builtin____new_array_with_default(((int)(out_len + 5 + 1 + 1)), 0, sizeof(u8), 0); | |
| 6510 | + int i = 0; | |
| 6511 | + if (neg) { | |
| 6512 | + if (buf.data != 0) { | |
| 6513 | + ((u8*)buf.data)[i] = '-'; | |
| 6514 | + } | |
| 6515 | + i++; | |
| 6516 | + } | |
| 6517 | + int disp = 0; | |
| 6518 | + if (out_len <= 1) { | |
| 6519 | + disp = 1; | |
| 6520 | + } | |
| 6521 | + if (n_digit < out_len) { | |
| 6522 | + out += _const_strconv__ten_pow_table_32[out_len - n_digit - 1] * 5; | |
| 6523 | + out = VSAFE_DIV_u32(out,_const_strconv__ten_pow_table_32[out_len - n_digit]); | |
| 6524 | + out_len = n_digit; | |
| 6525 | + } | |
| 6526 | + int y = i + out_len; | |
| 6527 | + int x = 0; | |
| 6528 | + for (;;) { | |
| 6529 | + if (!(x < (out_len - disp - 1))) break; | |
| 6530 | + ((u8*)buf.data)[y - x] = (rune)('0' + ((u8)(VSAFE_MOD_u32(out , 10)))); | |
| 6531 | + out = VSAFE_DIV_u32(out,10); | |
| 6532 | + i++; | |
| 6533 | + x++; | |
| 6534 | + } | |
| 6535 | + if (i_n_digit == 0) { | |
| 6536 | + { // Unsafe block | |
| 6537 | + ((u8*)buf.data)[i] = 0; | |
| 6538 | + return builtin__tos(builtin__memdup(&((u8*)buf.data)[0], i + 1), i); | |
| 6539 | + } | |
| 6540 | + } | |
| 6541 | + if (out_len > 1 || fw_zeros > 0) { | |
| 6542 | + ((u8*)buf.data)[y - x] = '.'; | |
| 6543 | + i++; | |
| 6544 | + } | |
| 6545 | + x++; | |
| 6546 | + if (y - x >= 0) { | |
| 6547 | + ((u8*)buf.data)[y - x] = (rune)('0' + ((u8)(VSAFE_MOD_u32(out , 10)))); | |
| 6548 | + i++; | |
| 6549 | + } | |
| 6550 | + for (;;) { | |
| 6551 | + if (!(fw_zeros > 0)) break; | |
| 6552 | + ((u8*)buf.data)[i] = '0'; | |
| 6553 | + i++; | |
| 6554 | + fw_zeros--; | |
| 6555 | + } | |
| 6556 | + ((u8*)buf.data)[i] = 'e'; | |
| 6557 | + i++; | |
| 6558 | + int exp = d.e + out_len_original - 1; | |
| 6559 | + if (exp < 0) { | |
| 6560 | + ((u8*)buf.data)[i] = '-'; | |
| 6561 | + i++; | |
| 6562 | + exp = -exp; | |
| 6563 | + } else { | |
| 6564 | + ((u8*)buf.data)[i] = '+'; | |
| 6565 | + i++; | |
| 6566 | + } | |
| 6567 | + int d1 = VSAFE_MOD_int(exp , 10); | |
| 6568 | + int d0 = VSAFE_DIV_int(exp , 10); | |
| 6569 | + ((u8*)buf.data)[i] = (rune)('0' + ((u8)(d0))); | |
| 6570 | + i++; | |
| 6571 | + ((u8*)buf.data)[i] = (rune)('0' + ((u8)(d1))); | |
| 6572 | + i++; | |
| 6573 | + ((u8*)buf.data)[i] = 0; | |
| 6574 | + return builtin__tos(builtin__memdup(&((u8*)buf.data)[0], i + 1), i); | |
| 6575 | +} | |
| 6576 | +VV_LOC multi_return_strconv__Dec32_bool strconv__f32_to_decimal_exact_int(u32 i_mant, u32 exp) { | |
| 6577 | + strconv__Dec32 _t1 = ((strconv__Dec32){.m = 0,.e = 0,}); | |
| 6578 | + strconv__Dec32 d = _t1; | |
| 6579 | + u32 e = exp - 127; | |
| 6580 | + if (e > _const_strconv__mantbits32) { | |
| 6581 | + return (multi_return_strconv__Dec32_bool){.arg0=d, .arg1=false}; | |
| 6582 | + } | |
| 6583 | + u32 shift = _const_strconv__mantbits32 - e; | |
| 6584 | + u32 mant = (i_mant | 0x00800000); | |
| 6585 | + d.m = v__rshift_u32(mant, (u64)shift); | |
| 6586 | + if ((v__lshift_u32(d.m, (u64)shift)) != mant) { | |
| 6587 | + return (multi_return_strconv__Dec32_bool){.arg0=d, .arg1=false}; | |
| 6588 | + } | |
| 6589 | + for (;;) { | |
| 6590 | + if (!((VSAFE_MOD_u32(d.m , 10)) == 0)) break; | |
| 6591 | + d.m = VSAFE_DIV_u32(d.m,10); | |
| 6592 | + d.e++; | |
| 6593 | + } | |
| 6594 | + return (multi_return_strconv__Dec32_bool){.arg0=d, .arg1=true}; | |
| 6595 | +} | |
| 6596 | +VV_LOC strconv__Dec32 strconv__f32_to_decimal(u32 mant, u32 exp) { | |
| 6597 | + int e2 = 0; | |
| 6598 | + u32 m2 = ((u32)(0)); | |
| 6599 | + if (exp == 0) { | |
| 6600 | + e2 = -126 - ((int)(_const_strconv__mantbits32)) - 2; | |
| 6601 | + m2 = mant; | |
| 6602 | + } else { | |
| 6603 | + e2 = ((int)(exp)) - 127 - ((int)(_const_strconv__mantbits32)) - 2; | |
| 6604 | + m2 = ((v__lshift_u32(((u32)(1)), (u64)_const_strconv__mantbits32)) | mant); | |
| 6605 | + } | |
| 6606 | + bool even = ((m2 & 1)) == 0; | |
| 6607 | + bool accept_bounds = even; | |
| 6608 | + u32 mv = ((u32)(4 * m2)); | |
| 6609 | + u32 mp = ((u32)(4 * m2 + 2)); | |
| 6610 | + u32 mm_shift = strconv__bool_to_u32(mant != 0 || exp <= 1); | |
| 6611 | + u32 mm = ((u32)(4 * m2 - 1 - mm_shift)); | |
| 6612 | + u32 vr = ((u32)(0)); | |
| 6613 | + u32 vp = ((u32)(0)); | |
| 6614 | + u32 vm = ((u32)(0)); | |
| 6615 | + int e10 = 0; | |
| 6616 | + bool vm_is_trailing_zeros = false; | |
| 6617 | + bool vr_is_trailing_zeros = false; | |
| 6618 | + u8 last_removed_digit = ((u8)(0)); | |
| 6619 | + if (e2 >= 0) { | |
| 6620 | + u32 q = strconv__log10_pow2(e2); | |
| 6621 | + e10 = ((int)(q)); | |
| 6622 | + int k = 59 + strconv__pow5_bits(((int)(q))) - 1; | |
| 6623 | + int i = -e2 + ((int)(q)) + k; | |
| 6624 | + vr = strconv__mul_pow5_invdiv_pow2(mv, q, i); | |
| 6625 | + vp = strconv__mul_pow5_invdiv_pow2(mp, q, i); | |
| 6626 | + vm = strconv__mul_pow5_invdiv_pow2(mm, q, i); | |
| 6627 | + if (q != 0 && VSAFE_DIV_u32((vp - 1) , 10) <= VSAFE_DIV_u32(vm , 10)) { | |
| 6628 | + int l = 59 + strconv__pow5_bits(((int)(q - 1))) - 1; | |
| 6629 | + last_removed_digit = ((u8)(VSAFE_MOD_u32(strconv__mul_pow5_invdiv_pow2(mv, q - 1, -e2 + ((int)(q - 1)) + l) , 10))); | |
| 6630 | + } | |
| 6631 | + if (q <= 9) { | |
| 6632 | + if (VSAFE_MOD_u32(mv , 5) == 0) { | |
| 6633 | + vr_is_trailing_zeros = strconv__multiple_of_power_of_five_32(mv, q); | |
| 6634 | + } else if (accept_bounds) { | |
| 6635 | + vm_is_trailing_zeros = strconv__multiple_of_power_of_five_32(mm, q); | |
| 6636 | + } else if (strconv__multiple_of_power_of_five_32(mp, q)) { | |
| 6637 | + vp--; | |
| 6638 | + } | |
| 6639 | + } | |
| 6640 | + } else { | |
| 6641 | + u32 q = strconv__log10_pow5(-e2); | |
| 6642 | + e10 = ((int)(q)) + e2; | |
| 6643 | + int i = -e2 - ((int)(q)); | |
| 6644 | + int k = strconv__pow5_bits(i) - 61; | |
| 6645 | + int j = ((int)(q)) - k; | |
| 6646 | + vr = strconv__mul_pow5_div_pow2(mv, ((u32)(i)), j); | |
| 6647 | + vp = strconv__mul_pow5_div_pow2(mp, ((u32)(i)), j); | |
| 6648 | + vm = strconv__mul_pow5_div_pow2(mm, ((u32)(i)), j); | |
| 6649 | + if (q != 0 && (VSAFE_DIV_u32((vp - 1) , 10)) <= VSAFE_DIV_u32(vm , 10)) { | |
| 6650 | + j = ((int)(q)) - 1 - (strconv__pow5_bits(i + 1) - 61); | |
| 6651 | + last_removed_digit = ((u8)(VSAFE_MOD_u32(strconv__mul_pow5_div_pow2(mv, ((u32)(i + 1)), j) , 10))); | |
| 6652 | + } | |
| 6653 | + if (q <= 1) { | |
| 6654 | + vr_is_trailing_zeros = true; | |
| 6655 | + if (accept_bounds) { | |
| 6656 | + vm_is_trailing_zeros = mm_shift == 1; | |
| 6657 | + } else { | |
| 6658 | + vp--; | |
| 6659 | + } | |
| 6660 | + } else if (q < 31) { | |
| 6661 | + vr_is_trailing_zeros = strconv__multiple_of_power_of_two_32(mv, q - 1); | |
| 6662 | + } | |
| 6663 | + } | |
| 6664 | + int removed = 0; | |
| 6665 | + u32 out = ((u32)(0)); | |
| 6666 | + if (vm_is_trailing_zeros || vr_is_trailing_zeros) { | |
| 6667 | + for (;;) { | |
| 6668 | + if (!(VSAFE_DIV_u32(vp , 10) > VSAFE_DIV_u32(vm , 10))) break; | |
| 6669 | + vm_is_trailing_zeros = vm_is_trailing_zeros && (VSAFE_MOD_u32(vm , 10)) == 0; | |
| 6670 | + vr_is_trailing_zeros = vr_is_trailing_zeros && last_removed_digit == 0; | |
| 6671 | + last_removed_digit = ((u8)(VSAFE_MOD_u32(vr , 10))); | |
| 6672 | + vr = VSAFE_DIV_u32(vr,10); | |
| 6673 | + vp = VSAFE_DIV_u32(vp,10); | |
| 6674 | + vm = VSAFE_DIV_u32(vm,10); | |
| 6675 | + removed++; | |
| 6676 | + } | |
| 6677 | + if (vm_is_trailing_zeros) { | |
| 6678 | + for (;;) { | |
| 6679 | + if (!(VSAFE_MOD_u32(vm , 10) == 0)) break; | |
| 6680 | + vr_is_trailing_zeros = vr_is_trailing_zeros && last_removed_digit == 0; | |
| 6681 | + last_removed_digit = ((u8)(VSAFE_MOD_u32(vr , 10))); | |
| 6682 | + vr = VSAFE_DIV_u32(vr,10); | |
| 6683 | + vp = VSAFE_DIV_u32(vp,10); | |
| 6684 | + vm = VSAFE_DIV_u32(vm,10); | |
| 6685 | + removed++; | |
| 6686 | + } | |
| 6687 | + } | |
| 6688 | + if (vr_is_trailing_zeros && last_removed_digit == 5 && (VSAFE_MOD_u32(vr , 2)) == 0) { | |
| 6689 | + last_removed_digit = 4; | |
| 6690 | + } | |
| 6691 | + out = vr; | |
| 6692 | + if ((vr == vm && (!accept_bounds || !vm_is_trailing_zeros)) || last_removed_digit >= 5) { | |
| 6693 | + out++; | |
| 6694 | + } | |
| 6695 | + } else { | |
| 6696 | + for (;;) { | |
| 6697 | + if (!(VSAFE_DIV_u32(vp , 10) > VSAFE_DIV_u32(vm , 10))) break; | |
| 6698 | + last_removed_digit = ((u8)(VSAFE_MOD_u32(vr , 10))); | |
| 6699 | + vr = VSAFE_DIV_u32(vr,10); | |
| 6700 | + vp = VSAFE_DIV_u32(vp,10); | |
| 6701 | + vm = VSAFE_DIV_u32(vm,10); | |
| 6702 | + removed++; | |
| 6703 | + } | |
| 6704 | + out = vr + strconv__bool_to_u32(vr == vm || last_removed_digit >= 5); | |
| 6705 | + } | |
| 6706 | + return ((strconv__Dec32){.m = out,.e = e10 + removed,}); | |
| 6707 | +} | |
| 6708 | +string strconv__f32_to_str(f32 f, int n_digit) { | |
| 6709 | + strconv__Uf32 _t1 = ((strconv__Uf32){0}); | |
| 6710 | + strconv__Uf32 u1 = _t1; | |
| 6711 | + u1.f = f; | |
| 6712 | + u32 u = u1.u; | |
| 6713 | + bool neg = (v__rshift_u32(u, (u64)(_const_strconv__mantbits32 + _const_strconv__expbits32))) != 0; | |
| 6714 | + u32 mant = (u & ((v__lshift_u32(((u32)(1)), (u64)_const_strconv__mantbits32)) - ((u32)(1)))); | |
| 6715 | + u32 exp = ((v__rshift_u32(u, (u64)_const_strconv__mantbits32)) & ((v__lshift_u32(((u32)(1)), (u64)_const_strconv__expbits32)) - ((u32)(1)))); | |
| 6716 | + if (exp == 255 || (exp == 0 && mant == 0)) { | |
| 6717 | + return strconv__get_string_special(neg, exp == 0, mant == 0); | |
| 6718 | + } | |
| 6719 | + multi_return_strconv__Dec32_bool mr_8600 = strconv__f32_to_decimal_exact_int(mant, exp); | |
| 6720 | + strconv__Dec32 d = mr_8600.arg0; | |
| 6721 | + bool ok = mr_8600.arg1; | |
| 6722 | + if (!ok) { | |
| 6723 | + d = strconv__f32_to_decimal(mant, exp); | |
| 6724 | + } | |
| 6725 | + return strconv__Dec32_get_string_32(d, neg, n_digit, 0); | |
| 6726 | +} | |
| 6727 | +string strconv__f32_to_str_pad(f32 f, int n_digit) { | |
| 6728 | + strconv__Uf32 _t1 = ((strconv__Uf32){0}); | |
| 6729 | + strconv__Uf32 u1 = _t1; | |
| 6730 | + u1.f = f; | |
| 6731 | + u32 u = u1.u; | |
| 6732 | + bool neg = (v__rshift_u32(u, (u64)(_const_strconv__mantbits32 + _const_strconv__expbits32))) != 0; | |
| 6733 | + u32 mant = (u & ((v__lshift_u32(((u32)(1)), (u64)_const_strconv__mantbits32)) - ((u32)(1)))); | |
| 6734 | + u32 exp = ((v__rshift_u32(u, (u64)_const_strconv__mantbits32)) & ((v__lshift_u32(((u32)(1)), (u64)_const_strconv__expbits32)) - ((u32)(1)))); | |
| 6735 | + if (exp == 255 || (exp == 0 && mant == 0)) { | |
| 6736 | + return strconv__get_string_special(neg, exp == 0, mant == 0); | |
| 6737 | + } | |
| 6738 | + multi_return_strconv__Dec32_bool mr_9334 = strconv__f32_to_decimal_exact_int(mant, exp); | |
| 6739 | + strconv__Dec32 d = mr_9334.arg0; | |
| 6740 | + bool ok = mr_9334.arg1; | |
| 6741 | + if (!ok) { | |
| 6742 | + d = strconv__f32_to_decimal(mant, exp); | |
| 6743 | + } | |
| 6744 | + return strconv__Dec32_get_string_32(d, neg, n_digit, n_digit); | |
| 6745 | +} | |
| 6746 | +VV_LOC string strconv__Dec64_get_string_64(strconv__Dec64 d, bool neg, int i_n_digit, int i_pad_digit) { | |
| 6747 | + int n_digit = (i_n_digit < 1 ? (1) : (i_n_digit + 1)); | |
| 6748 | + int pad_digit = i_pad_digit + 1; | |
| 6749 | + u64 out = d.m; | |
| 6750 | + int d_exp = d.e; | |
| 6751 | + int out_len = strconv__dec_digits(out); | |
| 6752 | + int out_len_original = out_len; | |
| 6753 | + int fw_zeros = 0; | |
| 6754 | + if (pad_digit > out_len) { | |
| 6755 | + fw_zeros = pad_digit - out_len; | |
| 6756 | + } | |
| 6757 | + Array_u8 buf = builtin____new_array_with_default((out_len + 6 + 1 + 1 + fw_zeros), 0, sizeof(u8), 0); | |
| 6758 | + int i = 0; | |
| 6759 | + if (neg) { | |
| 6760 | + ((u8*)buf.data)[i] = '-'; | |
| 6761 | + i++; | |
| 6762 | + } | |
| 6763 | + int disp = 0; | |
| 6764 | + if (out_len <= 1) { | |
| 6765 | + disp = 1; | |
| 6766 | + } | |
| 6767 | + if (n_digit < out_len) { | |
| 6768 | + out += _const_strconv__ten_pow_table_64[out_len - n_digit - 1] * 5; | |
| 6769 | + out = VSAFE_DIV_u64(out,_const_strconv__ten_pow_table_64[out_len - n_digit]); | |
| 6770 | + u64 out_div = VSAFE_DIV_u64(d.m , _const_strconv__ten_pow_table_64[out_len - n_digit]); | |
| 6771 | + if (out_div < out && strconv__dec_digits(out_div) < strconv__dec_digits(out)) { | |
| 6772 | + d_exp++; | |
| 6773 | + n_digit++; | |
| 6774 | + } | |
| 6775 | + out_len = n_digit; | |
| 6776 | + } | |
| 6777 | + int y = i + out_len; | |
| 6778 | + int x = 0; | |
| 6779 | + for (;;) { | |
| 6780 | + if (!(x < (out_len - disp - 1))) break; | |
| 6781 | + ((u8*)buf.data)[y - x] = (rune)('0' + ((u8)(VSAFE_MOD_u64(out , 10)))); | |
| 6782 | + out = VSAFE_DIV_u64(out,10); | |
| 6783 | + i++; | |
| 6784 | + x++; | |
| 6785 | + } | |
| 6786 | + if (out_len > 1 || fw_zeros > 0) { | |
| 6787 | + ((u8*)buf.data)[y - x] = '.'; | |
| 6788 | + i++; | |
| 6789 | + } | |
| 6790 | + x++; | |
| 6791 | + if (y - x >= 0) { | |
| 6792 | + ((u8*)buf.data)[y - x] = (rune)('0' + ((u8)(VSAFE_MOD_u64(out , 10)))); | |
| 6793 | + i++; | |
| 6794 | + } | |
| 6795 | + for (;;) { | |
| 6796 | + if (!(fw_zeros > 0)) break; | |
| 6797 | + ((u8*)buf.data)[i] = '0'; | |
| 6798 | + i++; | |
| 6799 | + fw_zeros--; | |
| 6800 | + } | |
| 6801 | + ((u8*)buf.data)[i] = 'e'; | |
| 6802 | + i++; | |
| 6803 | + int exp = d_exp + out_len_original - 1; | |
| 6804 | + if (exp < 0) { | |
| 6805 | + ((u8*)buf.data)[i] = '-'; | |
| 6806 | + i++; | |
| 6807 | + exp = -exp; | |
| 6808 | + } else { | |
| 6809 | + ((u8*)buf.data)[i] = '+'; | |
| 6810 | + i++; | |
| 6811 | + } | |
| 6812 | + int d2 = VSAFE_MOD_int(exp , 10); | |
| 6813 | + exp = VSAFE_DIV_int(exp,10); | |
| 6814 | + int d1 = VSAFE_MOD_int(exp , 10); | |
| 6815 | + int d0 = VSAFE_DIV_int(exp , 10); | |
| 6816 | + if (d0 > 0) { | |
| 6817 | + ((u8*)buf.data)[i] = (rune)('0' + ((u8)(d0))); | |
| 6818 | + i++; | |
| 6819 | + } | |
| 6820 | + ((u8*)buf.data)[i] = (rune)('0' + ((u8)(d1))); | |
| 6821 | + i++; | |
| 6822 | + ((u8*)buf.data)[i] = (rune)('0' + ((u8)(d2))); | |
| 6823 | + i++; | |
| 6824 | + ((u8*)buf.data)[i] = 0; | |
| 6825 | + return builtin__tos(builtin__memdup(&((u8*)buf.data)[0], i + 1), i); | |
| 6826 | +} | |
| 6827 | +VV_LOC multi_return_strconv__Dec64_bool strconv__f64_to_decimal_exact_int(u64 i_mant, u64 exp) { | |
| 6828 | + strconv__Dec64 _t1 = ((strconv__Dec64){.m = 0,.e = 0,}); | |
| 6829 | + strconv__Dec64 d = _t1; | |
| 6830 | + u64 e = exp - 1023; | |
| 6831 | + if (e > _const_strconv__mantbits64) { | |
| 6832 | + return (multi_return_strconv__Dec64_bool){.arg0=d, .arg1=false}; | |
| 6833 | + } | |
| 6834 | + u64 shift = (u64)(_const_strconv__mantbits64 - e); | |
| 6835 | + u64 mant = (i_mant | ((u64)(0x0010000000000000LL))); | |
| 6836 | + d.m = v__rshift_u64(mant, (u64)shift); | |
| 6837 | + if ((v__lshift_u64(d.m, (u64)shift)) != mant) { | |
| 6838 | + return (multi_return_strconv__Dec64_bool){.arg0=d, .arg1=false}; | |
| 6839 | + } | |
| 6840 | + for (;;) { | |
| 6841 | + if (!((VSAFE_MOD_u64(d.m , 10)) == 0)) break; | |
| 6842 | + d.m = VSAFE_DIV_u64(d.m,10); | |
| 6843 | + d.e++; | |
| 6844 | + } | |
| 6845 | + return (multi_return_strconv__Dec64_bool){.arg0=d, .arg1=true}; | |
| 6846 | +} | |
| 6847 | +VV_LOC strconv__Dec64 strconv__f64_to_decimal(u64 mant, u64 exp) { | |
| 6848 | + int e2 = 0; | |
| 6849 | + u64 m2 = ((u64)(0)); | |
| 6850 | + if (exp == 0) { | |
| 6851 | + e2 = -1022 - ((int)(_const_strconv__mantbits64)) - 2; | |
| 6852 | + m2 = mant; | |
| 6853 | + } else { | |
| 6854 | + e2 = ((int)(exp)) - 1023 - ((int)(_const_strconv__mantbits64)) - 2; | |
| 6855 | + m2 = ((v__lshift_u64(((u64)(1)), (u64)_const_strconv__mantbits64)) | mant); | |
| 6856 | + } | |
| 6857 | + bool even = ((m2 & 1)) == 0; | |
| 6858 | + bool accept_bounds = even; | |
| 6859 | + u64 mv = ((u64)(4 * m2)); | |
| 6860 | + u64 mm_shift = strconv__bool_to_u64(mant != 0 || exp <= 1); | |
| 6861 | + u64 vr = ((u64)(0)); | |
| 6862 | + u64 vp = ((u64)(0)); | |
| 6863 | + u64 vm = ((u64)(0)); | |
| 6864 | + int e10 = 0; | |
| 6865 | + bool vm_is_trailing_zeros = false; | |
| 6866 | + bool vr_is_trailing_zeros = false; | |
| 6867 | + if (e2 >= 0) { | |
| 6868 | + u32 q = strconv__log10_pow2(e2) - strconv__bool_to_u32(e2 > 3); | |
| 6869 | + e10 = ((int)(q)); | |
| 6870 | + int k = 122 + strconv__pow5_bits(((int)(q))) - 1; | |
| 6871 | + int i = -e2 + ((int)(q)) + k; | |
| 6872 | + strconv__Uint128 mul = *(((strconv__Uint128*)(&_const_strconv__pow5_inv_split_64_x[builtin__v_fixed_index(q * 2, 584)]))); | |
| 6873 | + vr = strconv__mul_shift_64(((u64)(4)) * m2, mul, i); | |
| 6874 | + vp = strconv__mul_shift_64(((u64)(4)) * m2 + ((u64)(2)), mul, i); | |
| 6875 | + vm = strconv__mul_shift_64(((u64)(4)) * m2 - ((u64)(1)) - mm_shift, mul, i); | |
| 6876 | + if (q <= 21) { | |
| 6877 | + if (VSAFE_MOD_u64(mv , 5) == 0) { | |
| 6878 | + vr_is_trailing_zeros = strconv__multiple_of_power_of_five_64(mv, q); | |
| 6879 | + } else if (accept_bounds) { | |
| 6880 | + vm_is_trailing_zeros = strconv__multiple_of_power_of_five_64(mv - 1 - mm_shift, q); | |
| 6881 | + } else if (strconv__multiple_of_power_of_five_64(mv + 2, q)) { | |
| 6882 | + vp--; | |
| 6883 | + } | |
| 6884 | + } | |
| 6885 | + } else { | |
| 6886 | + u32 q = strconv__log10_pow5(-e2) - strconv__bool_to_u32(-e2 > 1); | |
| 6887 | + e10 = ((int)(q)) + e2; | |
| 6888 | + int i = -e2 - ((int)(q)); | |
| 6889 | + int k = strconv__pow5_bits(i) - 121; | |
| 6890 | + int j = ((int)(q)) - k; | |
| 6891 | + strconv__Uint128 mul = *(((strconv__Uint128*)(&_const_strconv__pow5_split_64_x[builtin__v_fixed_index(i * 2, 652)]))); | |
| 6892 | + vr = strconv__mul_shift_64(((u64)(4)) * m2, mul, j); | |
| 6893 | + vp = strconv__mul_shift_64(((u64)(4)) * m2 + ((u64)(2)), mul, j); | |
| 6894 | + vm = strconv__mul_shift_64(((u64)(4)) * m2 - ((u64)(1)) - mm_shift, mul, j); | |
| 6895 | + if (q <= 1) { | |
| 6896 | + vr_is_trailing_zeros = true; | |
| 6897 | + if (accept_bounds) { | |
| 6898 | + vm_is_trailing_zeros = (mm_shift == 1); | |
| 6899 | + } else { | |
| 6900 | + vp--; | |
| 6901 | + } | |
| 6902 | + } else if (q < 63) { | |
| 6903 | + vr_is_trailing_zeros = strconv__multiple_of_power_of_two_64(mv, q - 1); | |
| 6904 | + } | |
| 6905 | + } | |
| 6906 | + int removed = 0; | |
| 6907 | + u8 last_removed_digit = ((u8)(0)); | |
| 6908 | + u64 out = ((u64)(0)); | |
| 6909 | + if (vm_is_trailing_zeros || vr_is_trailing_zeros) { | |
| 6910 | + for (;;) { | |
| 6911 | + u64 vp_div_10 = VSAFE_DIV_u64(vp , 10); | |
| 6912 | + u64 vm_div_10 = VSAFE_DIV_u64(vm , 10); | |
| 6913 | + if (vp_div_10 <= vm_div_10) { | |
| 6914 | + break; | |
| 6915 | + } | |
| 6916 | + u64 vm_mod_10 = VSAFE_MOD_u64(vm , 10); | |
| 6917 | + u64 vr_div_10 = VSAFE_DIV_u64(vr , 10); | |
| 6918 | + u64 vr_mod_10 = VSAFE_MOD_u64(vr , 10); | |
| 6919 | + vm_is_trailing_zeros = vm_is_trailing_zeros && vm_mod_10 == 0; | |
| 6920 | + vr_is_trailing_zeros = vr_is_trailing_zeros && last_removed_digit == 0; | |
| 6921 | + last_removed_digit = ((u8)(vr_mod_10)); | |
| 6922 | + vr = vr_div_10; | |
| 6923 | + vp = vp_div_10; | |
| 6924 | + vm = vm_div_10; | |
| 6925 | + removed++; | |
| 6926 | + } | |
| 6927 | + if (vm_is_trailing_zeros) { | |
| 6928 | + for (;;) { | |
| 6929 | + u64 vm_div_10 = VSAFE_DIV_u64(vm , 10); | |
| 6930 | + u64 vm_mod_10 = VSAFE_MOD_u64(vm , 10); | |
| 6931 | + if (vm_mod_10 != 0) { | |
| 6932 | + break; | |
| 6933 | + } | |
| 6934 | + u64 vp_div_10 = VSAFE_DIV_u64(vp , 10); | |
| 6935 | + u64 vr_div_10 = VSAFE_DIV_u64(vr , 10); | |
| 6936 | + u64 vr_mod_10 = VSAFE_MOD_u64(vr , 10); | |
| 6937 | + vr_is_trailing_zeros = vr_is_trailing_zeros && last_removed_digit == 0; | |
| 6938 | + last_removed_digit = ((u8)(vr_mod_10)); | |
| 6939 | + vr = vr_div_10; | |
| 6940 | + vp = vp_div_10; | |
| 6941 | + vm = vm_div_10; | |
| 6942 | + removed++; | |
| 6943 | + } | |
| 6944 | + } | |
| 6945 | + if (vr_is_trailing_zeros && last_removed_digit == 5 && (VSAFE_MOD_u64(vr , 2)) == 0) { | |
| 6946 | + last_removed_digit = 4; | |
| 6947 | + } | |
| 6948 | + out = vr; | |
| 6949 | + if ((vr == vm && (!accept_bounds || !vm_is_trailing_zeros)) || last_removed_digit >= 5) { | |
| 6950 | + out++; | |
| 6951 | + } | |
| 6952 | + } else { | |
| 6953 | + bool round_up = false; | |
| 6954 | + for (;;) { | |
| 6955 | + if (!(VSAFE_DIV_u64(vp , 100) > VSAFE_DIV_u64(vm , 100))) break; | |
| 6956 | + round_up = (VSAFE_MOD_u64(vr , 100)) >= 50; | |
| 6957 | + vr = VSAFE_DIV_u64(vr,100); | |
| 6958 | + vp = VSAFE_DIV_u64(vp,100); | |
| 6959 | + vm = VSAFE_DIV_u64(vm,100); | |
| 6960 | + removed += 2; | |
| 6961 | + } | |
| 6962 | + for (;;) { | |
| 6963 | + if (!(VSAFE_DIV_u64(vp , 10) > VSAFE_DIV_u64(vm , 10))) break; | |
| 6964 | + round_up = (VSAFE_MOD_u64(vr , 10)) >= 5; | |
| 6965 | + vr = VSAFE_DIV_u64(vr,10); | |
| 6966 | + vp = VSAFE_DIV_u64(vp,10); | |
| 6967 | + vm = VSAFE_DIV_u64(vm,10); | |
| 6968 | + removed++; | |
| 6969 | + } | |
| 6970 | + out = vr + strconv__bool_to_u64(vr == vm || round_up); | |
| 6971 | + } | |
| 6972 | + return ((strconv__Dec64){.m = out,.e = e10 + removed,}); | |
| 6973 | +} | |
| 6974 | +string strconv__f64_to_str(f64 f, int n_digit) { | |
| 6975 | + strconv__Uf64 _t1 = ((strconv__Uf64){0}); | |
| 6976 | + strconv__Uf64 u1 = _t1; | |
| 6977 | + u1.f = f; | |
| 6978 | + u64 u = u1.u; | |
| 6979 | + bool neg = (v__rshift_u64(u, (u64)(_const_strconv__mantbits64 + _const_strconv__expbits64))) != 0; | |
| 6980 | + u64 mant = (u & ((v__lshift_u64(((u64)(1)), (u64)_const_strconv__mantbits64)) - ((u64)(1)))); | |
| 6981 | + u64 exp = ((v__rshift_u64(u, (u64)_const_strconv__mantbits64)) & ((v__lshift_u64(((u64)(1)), (u64)_const_strconv__expbits64)) - ((u64)(1)))); | |
| 6982 | + if (exp == 2047 || (exp == 0 && mant == 0)) { | |
| 6983 | + return strconv__get_string_special(neg, exp == 0, mant == 0); | |
| 6984 | + } | |
| 6985 | + multi_return_strconv__Dec64_bool mr_9595 = strconv__f64_to_decimal_exact_int(mant, exp); | |
| 6986 | + strconv__Dec64 d = mr_9595.arg0; | |
| 6987 | + bool ok = mr_9595.arg1; | |
| 6988 | + if (!ok) { | |
| 6989 | + d = strconv__f64_to_decimal(mant, exp); | |
| 6990 | + } | |
| 6991 | + return strconv__Dec64_get_string_64(d, neg, n_digit, 0); | |
| 6992 | +} | |
| 6993 | +string strconv__f64_to_str_pad(f64 f, int n_digit) { | |
| 6994 | + strconv__Uf64 _t1 = ((strconv__Uf64){0}); | |
| 6995 | + strconv__Uf64 u1 = _t1; | |
| 6996 | + u1.f = f; | |
| 6997 | + u64 u = u1.u; | |
| 6998 | + bool neg = (v__rshift_u64(u, (u64)(_const_strconv__mantbits64 + _const_strconv__expbits64))) != 0; | |
| 6999 | + u64 mant = (u & ((v__lshift_u64(((u64)(1)), (u64)_const_strconv__mantbits64)) - ((u64)(1)))); | |
| 7000 | + u64 exp = ((v__rshift_u64(u, (u64)_const_strconv__mantbits64)) & ((v__lshift_u64(((u64)(1)), (u64)_const_strconv__expbits64)) - ((u64)(1)))); | |
| 7001 | + if (exp == 2047 || (exp == 0 && mant == 0)) { | |
| 7002 | + return strconv__get_string_special(neg, exp == 0, mant == 0); | |
| 7003 | + } | |
| 7004 | + multi_return_strconv__Dec64_bool mr_10376 = strconv__f64_to_decimal_exact_int(mant, exp); | |
| 7005 | + strconv__Dec64 d = mr_10376.arg0; | |
| 7006 | + bool ok = mr_10376.arg1; | |
| 7007 | + if (!ok) { | |
| 7008 | + d = strconv__f64_to_decimal(mant, exp); | |
| 7009 | + } | |
| 7010 | + return strconv__Dec64_get_string_64(d, neg, n_digit, n_digit); | |
| 7011 | +} | |
| 7012 | +string strconv__format_str(string s, strconv__BF_param p) { | |
| 7013 | + if (p.len0 <= 0) { | |
| 7014 | + return builtin__string_clone(s); | |
| 7015 | + } | |
| 7016 | + int dif = p.len0 - builtin__utf8_str_visible_length(s); | |
| 7017 | + if (dif <= 0) { | |
| 7018 | + return builtin__string_clone(s); | |
| 7019 | + } | |
| 7020 | + strings__Builder res = strings__new_builder(s.len + dif); | |
| 7021 | + if (p.align == strconv__Align_text__right) { | |
| 7022 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 7023 | + strings__Builder_write_u8(&res, p.pad_ch); | |
| 7024 | + } | |
| 7025 | + } | |
| 7026 | + strings__Builder_write_string(&res, s); | |
| 7027 | + if (p.align == strconv__Align_text__left) { | |
| 7028 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 7029 | + strings__Builder_write_u8(&res, p.pad_ch); | |
| 7030 | + } | |
| 7031 | + } | |
| 7032 | + string _t3 = strings__Builder_str(&res); | |
| 7033 | + { // defer begin | |
| 7034 | + strings__Builder_free(&res); | |
| 7035 | + } // defer end | |
| 7036 | + return _t3; | |
| 7037 | +} | |
| 7038 | +void strconv__format_str_sb(string s, strconv__BF_param p, strings__Builder* sb) { | |
| 7039 | + if (p.len0 <= 0) { | |
| 7040 | + strings__Builder_write_string(sb, s); | |
| 7041 | + return; | |
| 7042 | + } | |
| 7043 | + int dif = p.len0 - builtin__utf8_str_visible_length(s); | |
| 7044 | + if (dif <= 0) { | |
| 7045 | + strings__Builder_write_string(sb, s); | |
| 7046 | + return; | |
| 7047 | + } | |
| 7048 | + if (p.align == strconv__Align_text__right) { | |
| 7049 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 7050 | + strings__Builder_write_u8(sb, p.pad_ch); | |
| 7051 | + } | |
| 7052 | + } | |
| 7053 | + strings__Builder_write_string(sb, s); | |
| 7054 | + if (p.align == strconv__Align_text__left) { | |
| 7055 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 7056 | + strings__Builder_write_u8(sb, p.pad_ch); | |
| 7057 | + } | |
| 7058 | + } | |
| 7059 | +} | |
| 7060 | +void strconv__format_dec_sb(u64 d, strconv__BF_param p, strings__Builder* res) { | |
| 7061 | + int n_char = strconv__dec_digits(d); | |
| 7062 | + int sign_len = (!p.positive || p.sign_flag ? (1) : (0)); | |
| 7063 | + int number_len = sign_len + n_char; | |
| 7064 | + int dif = p.len0 - number_len; | |
| 7065 | + bool sign_written = false; | |
| 7066 | + if (p.align == strconv__Align_text__right) { | |
| 7067 | + if (p.pad_ch == '0') { | |
| 7068 | + if (p.positive) { | |
| 7069 | + if (p.sign_flag) { | |
| 7070 | + strings__Builder_write_u8(res, '+'); | |
| 7071 | + sign_written = true; | |
| 7072 | + } | |
| 7073 | + } else { | |
| 7074 | + strings__Builder_write_u8(res, '-'); | |
| 7075 | + sign_written = true; | |
| 7076 | + } | |
| 7077 | + } | |
| 7078 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 7079 | + strings__Builder_write_u8(res, p.pad_ch); | |
| 7080 | + } | |
| 7081 | + } | |
| 7082 | + if (!sign_written) { | |
| 7083 | + if (p.positive) { | |
| 7084 | + if (p.sign_flag) { | |
| 7085 | + strings__Builder_write_u8(res, '+'); | |
| 7086 | + } | |
| 7087 | + } else { | |
| 7088 | + strings__Builder_write_u8(res, '-'); | |
| 7089 | + } | |
| 7090 | + } | |
| 7091 | + Array_fixed_u8_32 buf = {0}; | |
| 7092 | + int i = 20; | |
| 7093 | + u64 n = d; | |
| 7094 | + u64 d_i = ((u64)(0)); | |
| 7095 | + if (n > 0) { | |
| 7096 | + for (;;) { | |
| 7097 | + if (!(n > 0)) break; | |
| 7098 | + u64 n1 = VSAFE_DIV_u64(n , 100); | |
| 7099 | + d_i = v__lshift_u64((n - (n1 * 100)), (u64)1); | |
| 7100 | + n = n1; | |
| 7101 | + { // Unsafe block | |
| 7102 | + buf[i] = _const_strconv__digit_pairs.str[d_i]; | |
| 7103 | + } | |
| 7104 | + i--; | |
| 7105 | + d_i++; | |
| 7106 | + { // Unsafe block | |
| 7107 | + buf[i] = _const_strconv__digit_pairs.str[d_i]; | |
| 7108 | + } | |
| 7109 | + i--; | |
| 7110 | + } | |
| 7111 | + i++; | |
| 7112 | + if (d_i < 20) { | |
| 7113 | + i++; | |
| 7114 | + } | |
| 7115 | + strings__Builder_write_ptr(res, &buf[i], n_char); | |
| 7116 | + } else { | |
| 7117 | + strings__Builder_write_u8(res, '0'); | |
| 7118 | + } | |
| 7119 | + if (p.align == strconv__Align_text__left) { | |
| 7120 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 7121 | + strings__Builder_write_u8(res, p.pad_ch); | |
| 7122 | + } | |
| 7123 | + } | |
| 7124 | + return; | |
| 7125 | +} | |
| 7126 | +string strconv__f64_to_str_lnd1(f64 f, int dec_digit) { | |
| 7127 | + { // Unsafe block | |
| 7128 | + int clamped_dec = (dec_digit >= 36 ? (36 - 1) : (dec_digit)); | |
| 7129 | + string s = strconv__f64_to_str(f + _const_strconv__dec_round[clamped_dec], 18); | |
| 7130 | + if (s.len > 2 && (s.str[ 0] == 'n' || s.str[ 1] == 'i')) { | |
| 7131 | + return s; | |
| 7132 | + } | |
| 7133 | + bool m_sgn_flag = false; | |
| 7134 | + int sgn = 1; | |
| 7135 | + Array_fixed_u8_26 b = {0}; | |
| 7136 | + int d_pos = 1; | |
| 7137 | + int i = 0; | |
| 7138 | + int i1 = 0; | |
| 7139 | + int exp = 0; | |
| 7140 | + int exp_sgn = 1; | |
| 7141 | + int dot_res_sp = -1; | |
| 7142 | + for (int _t2 = 0; _t2 < s.len; ++_t2) { | |
| 7143 | + u8 c = s.str[_t2]; | |
| 7144 | + | |
| 7145 | + if (c == ('-')) { | |
| 7146 | + sgn = -1; | |
| 7147 | + i++; | |
| 7148 | + } | |
| 7149 | + else if (c == ('+')) { | |
| 7150 | + sgn = 1; | |
| 7151 | + i++; | |
| 7152 | + } | |
| 7153 | + else if ((c >= '0' && c <= '9')) { | |
| 7154 | + b[i1] = c; | |
| 7155 | + i1++; | |
| 7156 | + i++; | |
| 7157 | + } | |
| 7158 | + else if (c == ('.')) { | |
| 7159 | + if (sgn > 0) { | |
| 7160 | + d_pos = i; | |
| 7161 | + } else { | |
| 7162 | + d_pos = i - 1; | |
| 7163 | + } | |
| 7164 | + i++; | |
| 7165 | + } | |
| 7166 | + else if (c == ('e')) { | |
| 7167 | + i++; | |
| 7168 | + break; | |
| 7169 | + } | |
| 7170 | + else { | |
| 7171 | + builtin__string_free(&s); | |
| 7172 | + return _S("[Float conversion error!!]"); | |
| 7173 | + } | |
| 7174 | + } | |
| 7175 | + b[i1] = 0; | |
| 7176 | + if (s.str[ i] == '-') { | |
| 7177 | + exp_sgn = -1; | |
| 7178 | + i++; | |
| 7179 | + } else if (s.str[ i] == '+') { | |
| 7180 | + exp_sgn = 1; | |
| 7181 | + i++; | |
| 7182 | + } | |
| 7183 | + int c = i; | |
| 7184 | + for (;;) { | |
| 7185 | + if (!(c < s.len)) break; | |
| 7186 | + exp = exp * 10 + ((int)((rune)(s.str[ c] - '0'))); | |
| 7187 | + c++; | |
| 7188 | + } | |
| 7189 | + int extra_frac_digits = (dec_digit > 0 ? (dec_digit) : (0)); | |
| 7190 | + int sign_len = (sgn < 0 ? (1) : (0)); | |
| 7191 | + Array_u8 res = builtin____new_array_with_default(sign_len + i1 + exp + extra_frac_digits + 4, 0, sizeof(u8), &(u8[]){0}); | |
| 7192 | + int r_i = 0; | |
| 7193 | + builtin__string_free(&s); | |
| 7194 | + if (sgn == 1) { | |
| 7195 | + if (m_sgn_flag) { | |
| 7196 | + ((u8*)res.data)[r_i] = '+'; | |
| 7197 | + r_i++; | |
| 7198 | + } | |
| 7199 | + } else { | |
| 7200 | + ((u8*)res.data)[r_i] = '-'; | |
| 7201 | + r_i++; | |
| 7202 | + } | |
| 7203 | + i = 0; | |
| 7204 | + if (exp_sgn >= 0) { | |
| 7205 | + for (;;) { | |
| 7206 | + if (!(b[i] != 0)) break; | |
| 7207 | + ((u8*)res.data)[r_i] = b[i]; | |
| 7208 | + r_i++; | |
| 7209 | + i++; | |
| 7210 | + if (i >= d_pos && exp >= 0) { | |
| 7211 | + if (exp == 0) { | |
| 7212 | + dot_res_sp = r_i; | |
| 7213 | + ((u8*)res.data)[r_i] = '.'; | |
| 7214 | + r_i++; | |
| 7215 | + } | |
| 7216 | + exp--; | |
| 7217 | + } | |
| 7218 | + } | |
| 7219 | + for (;;) { | |
| 7220 | + if (!(exp >= 0)) break; | |
| 7221 | + ((u8*)res.data)[r_i] = '0'; | |
| 7222 | + r_i++; | |
| 7223 | + exp--; | |
| 7224 | + } | |
| 7225 | + } else { | |
| 7226 | + bool dot_p = true; | |
| 7227 | + for (;;) { | |
| 7228 | + if (!(exp > 0)) break; | |
| 7229 | + ((u8*)res.data)[r_i] = '0'; | |
| 7230 | + r_i++; | |
| 7231 | + exp--; | |
| 7232 | + if (dot_p) { | |
| 7233 | + dot_res_sp = r_i; | |
| 7234 | + ((u8*)res.data)[r_i] = '.'; | |
| 7235 | + r_i++; | |
| 7236 | + dot_p = false; | |
| 7237 | + } | |
| 7238 | + } | |
| 7239 | + for (;;) { | |
| 7240 | + if (!(b[i] != 0)) break; | |
| 7241 | + ((u8*)res.data)[r_i] = b[i]; | |
| 7242 | + r_i++; | |
| 7243 | + i++; | |
| 7244 | + } | |
| 7245 | + } | |
| 7246 | + if (dec_digit <= 0) { | |
| 7247 | + if (dot_res_sp < 0) { | |
| 7248 | + dot_res_sp = i + 1; | |
| 7249 | + } | |
| 7250 | + string tmp_res = builtin__string_clone(builtin__tos(res.data, dot_res_sp)); | |
| 7251 | + builtin__array_free(&res); | |
| 7252 | + return tmp_res; | |
| 7253 | + } | |
| 7254 | + if (dot_res_sp >= 0) { | |
| 7255 | + r_i = dot_res_sp + dec_digit + 1; | |
| 7256 | + ((u8*)res.data)[r_i] = 0; | |
| 7257 | + for (int c1 = 1; c1 < dec_digit + 1; ++c1) { | |
| 7258 | + if (((u8*)res.data)[(int)(r_i - c1)] == 0) { | |
| 7259 | + ((u8*)res.data)[(int)(r_i - c1)] = '0'; | |
| 7260 | + } | |
| 7261 | + } | |
| 7262 | + string tmp_res = builtin__string_clone(builtin__tos(res.data, r_i)); | |
| 7263 | + builtin__array_free(&res); | |
| 7264 | + return tmp_res; | |
| 7265 | + } else { | |
| 7266 | + if (dec_digit > 0) { | |
| 7267 | + int c1 = 0; | |
| 7268 | + ((u8*)res.data)[r_i] = '.'; | |
| 7269 | + r_i++; | |
| 7270 | + for (;;) { | |
| 7271 | + if (!(c1 < dec_digit)) break; | |
| 7272 | + ((u8*)res.data)[r_i] = '0'; | |
| 7273 | + r_i++; | |
| 7274 | + c1++; | |
| 7275 | + } | |
| 7276 | + ((u8*)res.data)[r_i] = 0; | |
| 7277 | + } | |
| 7278 | + string tmp_res = builtin__string_clone(builtin__tos(res.data, r_i)); | |
| 7279 | + builtin__array_free(&res); | |
| 7280 | + return tmp_res; | |
| 7281 | + } | |
| 7282 | + } | |
| 7283 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 7284 | +} | |
| 7285 | +string strconv__format_fl(f64 f, strconv__BF_param p) { | |
| 7286 | + { // Unsafe block | |
| 7287 | + string fs = strconv__f64_to_str_lnd1((f >= ((f64)(0.0)) ? (f) : (-f)), p.len1); | |
| 7288 | + if (fs.str[ 0] == '[') { | |
| 7289 | + return fs; | |
| 7290 | + } | |
| 7291 | + if (p.rm_tail_zero) { | |
| 7292 | + string tmp = fs; | |
| 7293 | + fs = strconv__remove_tail_zeros(fs); | |
| 7294 | + builtin__string_free(&tmp); | |
| 7295 | + } | |
| 7296 | + Array_fixed_u8_512 buf = {0}; | |
| 7297 | + Array_fixed_u8_512 out = {0}; | |
| 7298 | + int buf_i = 0; | |
| 7299 | + int out_i = 0; | |
| 7300 | + int sign_len_diff = 0; | |
| 7301 | + if (p.pad_ch == '0') { | |
| 7302 | + if (p.positive) { | |
| 7303 | + if (p.sign_flag) { | |
| 7304 | + out[out_i] = '+'; | |
| 7305 | + out_i++; | |
| 7306 | + sign_len_diff = -1; | |
| 7307 | + } | |
| 7308 | + } else { | |
| 7309 | + out[out_i] = '-'; | |
| 7310 | + out_i++; | |
| 7311 | + sign_len_diff = -1; | |
| 7312 | + } | |
| 7313 | + } else { | |
| 7314 | + if (p.positive) { | |
| 7315 | + if (p.sign_flag) { | |
| 7316 | + buf[buf_i] = '+'; | |
| 7317 | + buf_i++; | |
| 7318 | + } | |
| 7319 | + } else { | |
| 7320 | + buf[buf_i] = '-'; | |
| 7321 | + buf_i++; | |
| 7322 | + } | |
| 7323 | + } | |
| 7324 | + builtin__vmemcpy(&buf[buf_i], fs.str, fs.len); | |
| 7325 | + buf_i += fs.len; | |
| 7326 | + int dif = p.len0 - buf_i + sign_len_diff; | |
| 7327 | + if (p.align == strconv__Align_text__right) { | |
| 7328 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 7329 | + out[out_i] = p.pad_ch; | |
| 7330 | + out_i++; | |
| 7331 | + } | |
| 7332 | + } | |
| 7333 | + builtin__vmemcpy(&out[out_i], &buf[0], buf_i); | |
| 7334 | + out_i += buf_i; | |
| 7335 | + if (p.align == strconv__Align_text__left) { | |
| 7336 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 7337 | + out[out_i] = p.pad_ch; | |
| 7338 | + out_i++; | |
| 7339 | + } | |
| 7340 | + } | |
| 7341 | + out[out_i] = 0; | |
| 7342 | + string tmp = fs; | |
| 7343 | + fs = builtin__tos_clone(&out[0]); | |
| 7344 | + builtin__string_free(&tmp); | |
| 7345 | + return fs; | |
| 7346 | + } | |
| 7347 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 7348 | +} | |
| 7349 | +string strconv__format_es(f64 f, strconv__BF_param p) { | |
| 7350 | + { // Unsafe block | |
| 7351 | + string fs = strconv__f64_to_str_pad((f > 0 ? (f) : (-f)), p.len1); | |
| 7352 | + if (p.rm_tail_zero) { | |
| 7353 | + string tmp = fs; | |
| 7354 | + fs = strconv__remove_tail_zeros(fs); | |
| 7355 | + builtin__string_free(&tmp); | |
| 7356 | + } | |
| 7357 | + Array_fixed_u8_512 buf = {0}; | |
| 7358 | + Array_fixed_u8_512 out = {0}; | |
| 7359 | + int buf_i = 0; | |
| 7360 | + int out_i = 0; | |
| 7361 | + int sign_len_diff = 0; | |
| 7362 | + if (p.pad_ch == '0') { | |
| 7363 | + if (p.positive) { | |
| 7364 | + if (p.sign_flag) { | |
| 7365 | + out[out_i] = '+'; | |
| 7366 | + out_i++; | |
| 7367 | + sign_len_diff = -1; | |
| 7368 | + } | |
| 7369 | + } else { | |
| 7370 | + out[out_i] = '-'; | |
| 7371 | + out_i++; | |
| 7372 | + sign_len_diff = -1; | |
| 7373 | + } | |
| 7374 | + } else { | |
| 7375 | + if (p.positive) { | |
| 7376 | + if (p.sign_flag) { | |
| 7377 | + buf[buf_i] = '+'; | |
| 7378 | + buf_i++; | |
| 7379 | + } | |
| 7380 | + } else { | |
| 7381 | + buf[buf_i] = '-'; | |
| 7382 | + buf_i++; | |
| 7383 | + } | |
| 7384 | + } | |
| 7385 | + builtin__vmemcpy(&buf[buf_i], fs.str, fs.len); | |
| 7386 | + buf_i += fs.len; | |
| 7387 | + int dif = p.len0 - buf_i + sign_len_diff; | |
| 7388 | + if (p.align == strconv__Align_text__right) { | |
| 7389 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 7390 | + out[out_i] = p.pad_ch; | |
| 7391 | + out_i++; | |
| 7392 | + } | |
| 7393 | + } | |
| 7394 | + builtin__vmemcpy(&out[out_i], &buf[0], buf_i); | |
| 7395 | + out_i += buf_i; | |
| 7396 | + if (p.align == strconv__Align_text__left) { | |
| 7397 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 7398 | + out[out_i] = p.pad_ch; | |
| 7399 | + out_i++; | |
| 7400 | + } | |
| 7401 | + } | |
| 7402 | + out[out_i] = 0; | |
| 7403 | + string tmp = fs; | |
| 7404 | + fs = builtin__tos_clone(&out[0]); | |
| 7405 | + builtin__string_free(&tmp); | |
| 7406 | + return fs; | |
| 7407 | + } | |
| 7408 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 7409 | +} | |
| 7410 | +string strconv__remove_tail_zeros(string s) { | |
| 7411 | + { // Unsafe block | |
| 7412 | + u8* buf = builtin__malloc_noscan(s.len + 1); | |
| 7413 | + int i_d = 0; | |
| 7414 | + int i_s = 0; | |
| 7415 | + for (;;) { | |
| 7416 | + if (!(i_s < s.len && !(s.str[ i_s] == '-' || s.str[ i_s] == '+') && (s.str[ i_s] > '9' || s.str[ i_s] < '0'))) break; | |
| 7417 | + buf[i_d] = s.str[ i_s]; | |
| 7418 | + i_s++; | |
| 7419 | + i_d++; | |
| 7420 | + } | |
| 7421 | + if (i_s < s.len && (s.str[ i_s] == '-' || s.str[ i_s] == '+')) { | |
| 7422 | + buf[i_d] = s.str[ i_s]; | |
| 7423 | + i_s++; | |
| 7424 | + i_d++; | |
| 7425 | + } | |
| 7426 | + for (;;) { | |
| 7427 | + if (!(i_s < s.len && s.str[ i_s] >= '0' && s.str[ i_s] <= '9')) break; | |
| 7428 | + buf[i_d] = s.str[ i_s]; | |
| 7429 | + i_s++; | |
| 7430 | + i_d++; | |
| 7431 | + } | |
| 7432 | + if (i_s < s.len && s.str[ i_s] == '.') { | |
| 7433 | + int i_s1 = i_s + 1; | |
| 7434 | + int sum = 0; | |
| 7435 | + int i_s2 = i_s1; | |
| 7436 | + for (;;) { | |
| 7437 | + if (!(i_s1 < s.len && s.str[ i_s1] >= '0' && s.str[ i_s1] <= '9')) break; | |
| 7438 | + sum += (s.str[ i_s1] - ((u8)('0'))); | |
| 7439 | + if (s.str[ i_s1] != '0') { | |
| 7440 | + i_s2 = i_s1; | |
| 7441 | + } | |
| 7442 | + i_s1++; | |
| 7443 | + } | |
| 7444 | + if (sum > 0) { | |
| 7445 | + for (int c_i = i_s; c_i < i_s2 + 1; ++c_i) { | |
| 7446 | + buf[i_d] = s.str[ c_i]; | |
| 7447 | + i_d++; | |
| 7448 | + } | |
| 7449 | + } | |
| 7450 | + i_s = i_s1; | |
| 7451 | + } | |
| 7452 | + if (i_s < s.len && s.str[ i_s] != '.') { | |
| 7453 | + for (;;) { | |
| 7454 | + buf[i_d] = s.str[ i_s]; | |
| 7455 | + i_s++; | |
| 7456 | + i_d++; | |
| 7457 | + if (i_s >= s.len) { | |
| 7458 | + break; | |
| 7459 | + } | |
| 7460 | + } | |
| 7461 | + } | |
| 7462 | + buf[i_d] = 0; | |
| 7463 | + return builtin__tos(buf, i_d); | |
| 7464 | + } | |
| 7465 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 7466 | +} | |
| 7467 | +inline string strconv__ftoa_64(f64 f) { | |
| 7468 | + return strconv__f64_to_str(f, 17); | |
| 7469 | +} | |
| 7470 | +inline string strconv__ftoa_long_64(f64 f) { | |
| 7471 | + return strconv__f64_to_str_l(f); | |
| 7472 | +} | |
| 7473 | +inline string strconv__ftoa_32(f32 f) { | |
| 7474 | + return strconv__f32_to_str(f, 8); | |
| 7475 | +} | |
| 7476 | +inline string strconv__ftoa_long_32(f32 f) { | |
| 7477 | + return strconv__f32_to_str_l(f); | |
| 7478 | +} | |
| 7479 | +string strconv__format_int(i64 n, int radix) { | |
| 7480 | + { // Unsafe block | |
| 7481 | + if (radix < 2 || radix > 36) { | |
| 7482 | + builtin__panic_n(_S("invalid radix, it should be => 2 and <= 36, actual:"), radix); | |
| 7483 | + VUNREACHABLE(); | |
| 7484 | + } | |
| 7485 | + if (n == 0) { | |
| 7486 | + return _S("0"); | |
| 7487 | + } | |
| 7488 | + i64 n_copy = n; | |
| 7489 | + bool have_minus = false; | |
| 7490 | + if (n < 0) { | |
| 7491 | + have_minus = true; | |
| 7492 | + n_copy = -n_copy; | |
| 7493 | + } | |
| 7494 | + string res = _S(""); | |
| 7495 | + for (;;) { | |
| 7496 | + if (!(n_copy != 0)) break; | |
| 7497 | + string tmp_0 = res; | |
| 7498 | + int bdx = ((int)((i64)(VSAFE_MOD_i64(n_copy , radix)))); | |
| 7499 | + string tmp_1 = builtin__u8_ascii_str(_const_strconv__base_digits.str[ bdx]); | |
| 7500 | + res = builtin__string__plus(tmp_1, res); | |
| 7501 | + builtin__string_free(&tmp_0); | |
| 7502 | + builtin__string_free(&tmp_1); | |
| 7503 | + n_copy = VSAFE_DIV_i64(n_copy,radix); | |
| 7504 | + } | |
| 7505 | + if (have_minus) { | |
| 7506 | + string final_res = builtin__string__plus(_S("-"), res); | |
| 7507 | + builtin__string_free(&res); | |
| 7508 | + return final_res; | |
| 7509 | + } | |
| 7510 | + return res; | |
| 7511 | + } | |
| 7512 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 7513 | +} | |
| 7514 | +string strconv__format_uint(u64 n, int radix) { | |
| 7515 | + { // Unsafe block | |
| 7516 | + if (radix < 2 || radix > 36) { | |
| 7517 | + builtin__panic_n(_S("invalid radix, it should be => 2 and <= 36, actual:"), radix); | |
| 7518 | + VUNREACHABLE(); | |
| 7519 | + } | |
| 7520 | + if (n == 0) { | |
| 7521 | + return _S("0"); | |
| 7522 | + } | |
| 7523 | + u64 n_copy = n; | |
| 7524 | + string res = _S(""); | |
| 7525 | + u64 uradix = ((u64)(radix)); | |
| 7526 | + for (;;) { | |
| 7527 | + if (!(n_copy != 0)) break; | |
| 7528 | + string tmp_0 = res; | |
| 7529 | + string tmp_1 = builtin__u8_ascii_str(_const_strconv__base_digits.str[ ((int)(VSAFE_MOD_u64(n_copy , uradix)))]); | |
| 7530 | + res = builtin__string__plus(tmp_1, res); | |
| 7531 | + builtin__string_free(&tmp_0); | |
| 7532 | + builtin__string_free(&tmp_1); | |
| 7533 | + n_copy = VSAFE_DIV_u64(n_copy,uradix); | |
| 7534 | + } | |
| 7535 | + return res; | |
| 7536 | + } | |
| 7537 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 7538 | +} | |
| 7539 | +string strconv__f32_to_str_l(f32 f) { | |
| 7540 | + string s = strconv__f32_to_str(f, 8); | |
| 7541 | + string res = strconv__fxx_to_str_l_parse(s); | |
| 7542 | + builtin__string_free(&s); | |
| 7543 | + return res; | |
| 7544 | +} | |
| 7545 | +string strconv__f32_to_str_l_with_dot(f32 f) { | |
| 7546 | + string s = strconv__f32_to_str(f, 8); | |
| 7547 | + string res = strconv__fxx_to_str_l_parse_with_dot(s); | |
| 7548 | + builtin__string_free(&s); | |
| 7549 | + return res; | |
| 7550 | +} | |
| 7551 | +string strconv__f64_to_str_l(f64 f) { | |
| 7552 | + string s = strconv__f64_to_str(f, 18); | |
| 7553 | + string res = strconv__fxx_to_str_l_parse(s); | |
| 7554 | + builtin__string_free(&s); | |
| 7555 | + return res; | |
| 7556 | +} | |
| 7557 | +string strconv__f64_to_str_l_with_dot(f64 f) { | |
| 7558 | + string s = strconv__f64_to_str(f, 18); | |
| 7559 | + string res = strconv__fxx_to_str_l_parse_with_dot(s); | |
| 7560 | + builtin__string_free(&s); | |
| 7561 | + return res; | |
| 7562 | +} | |
| 7563 | +string strconv__fxx_to_str_l_parse(string s) { | |
| 7564 | + if (s.len > 2 && (s.str[ 0] == 'n' || s.str[ 1] == 'i')) { | |
| 7565 | + return builtin__string_clone(s); | |
| 7566 | + } | |
| 7567 | + bool m_sgn_flag = false; | |
| 7568 | + int sgn = 1; | |
| 7569 | + Array_fixed_u8_26 b = {0}; | |
| 7570 | + int d_pos = 1; | |
| 7571 | + int i = 0; | |
| 7572 | + int i1 = 0; | |
| 7573 | + int exp = 0; | |
| 7574 | + int exp_sgn = 1; | |
| 7575 | + for (int _t2 = 0; _t2 < s.len; ++_t2) { | |
| 7576 | + u8 c = s.str[_t2]; | |
| 7577 | + if (c == '-') { | |
| 7578 | + sgn = -1; | |
| 7579 | + i++; | |
| 7580 | + } else if (c == '+') { | |
| 7581 | + sgn = 1; | |
| 7582 | + i++; | |
| 7583 | + } else if (c >= '0' && c <= '9') { | |
| 7584 | + b[i1] = c; | |
| 7585 | + i1++; | |
| 7586 | + i++; | |
| 7587 | + } else if (c == '.') { | |
| 7588 | + if (sgn > 0) { | |
| 7589 | + d_pos = i; | |
| 7590 | + } else { | |
| 7591 | + d_pos = i - 1; | |
| 7592 | + } | |
| 7593 | + i++; | |
| 7594 | + } else if (c == 'e') { | |
| 7595 | + i++; | |
| 7596 | + break; | |
| 7597 | + } else { | |
| 7598 | + return _S("Float conversion error!!"); | |
| 7599 | + } | |
| 7600 | + } | |
| 7601 | + b[i1] = 0; | |
| 7602 | + if (s.str[ i] == '-') { | |
| 7603 | + exp_sgn = -1; | |
| 7604 | + i++; | |
| 7605 | + } else if (s.str[ i] == '+') { | |
| 7606 | + exp_sgn = 1; | |
| 7607 | + i++; | |
| 7608 | + } | |
| 7609 | + int c = i; | |
| 7610 | + for (;;) { | |
| 7611 | + if (!(c < s.len)) break; | |
| 7612 | + exp = exp * 10 + ((int)((rune)(s.str[ c] - '0'))); | |
| 7613 | + c++; | |
| 7614 | + } | |
| 7615 | + Array_u8 res = builtin____new_array_with_default(exp + 32, 0, sizeof(u8), &(u8[]){0}); | |
| 7616 | + int r_i = 0; | |
| 7617 | + if (sgn == 1) { | |
| 7618 | + if (m_sgn_flag) { | |
| 7619 | + ((u8*)res.data)[r_i] = '+'; | |
| 7620 | + r_i++; | |
| 7621 | + } | |
| 7622 | + } else { | |
| 7623 | + ((u8*)res.data)[r_i] = '-'; | |
| 7624 | + r_i++; | |
| 7625 | + } | |
| 7626 | + i = 0; | |
| 7627 | + if (exp_sgn >= 0) { | |
| 7628 | + for (;;) { | |
| 7629 | + if (!(b[i] != 0)) break; | |
| 7630 | + ((u8*)res.data)[r_i] = b[i]; | |
| 7631 | + r_i++; | |
| 7632 | + i++; | |
| 7633 | + if (i >= d_pos && exp >= 0) { | |
| 7634 | + if (exp == 0) { | |
| 7635 | + ((u8*)res.data)[r_i] = '.'; | |
| 7636 | + r_i++; | |
| 7637 | + } | |
| 7638 | + exp--; | |
| 7639 | + } | |
| 7640 | + } | |
| 7641 | + for (;;) { | |
| 7642 | + if (!(exp >= 0)) break; | |
| 7643 | + ((u8*)res.data)[r_i] = '0'; | |
| 7644 | + r_i++; | |
| 7645 | + exp--; | |
| 7646 | + } | |
| 7647 | + } else { | |
| 7648 | + bool dot_p = true; | |
| 7649 | + for (;;) { | |
| 7650 | + if (!(exp > 0)) break; | |
| 7651 | + ((u8*)res.data)[r_i] = '0'; | |
| 7652 | + r_i++; | |
| 7653 | + exp--; | |
| 7654 | + if (dot_p) { | |
| 7655 | + ((u8*)res.data)[r_i] = '.'; | |
| 7656 | + r_i++; | |
| 7657 | + dot_p = false; | |
| 7658 | + } | |
| 7659 | + } | |
| 7660 | + for (;;) { | |
| 7661 | + if (!(b[i] != 0)) break; | |
| 7662 | + ((u8*)res.data)[r_i] = b[i]; | |
| 7663 | + r_i++; | |
| 7664 | + i++; | |
| 7665 | + } | |
| 7666 | + } | |
| 7667 | + if (r_i > 1 && ((u8*)res.data)[r_i - 1] == '.') { | |
| 7668 | + ((u8*)res.data)[r_i] = '0'; | |
| 7669 | + r_i++; | |
| 7670 | + } else if (!(Array_u8_contains(res, '.'))) { | |
| 7671 | + ((u8*)res.data)[r_i] = '.'; | |
| 7672 | + r_i++; | |
| 7673 | + ((u8*)res.data)[r_i] = '0'; | |
| 7674 | + r_i++; | |
| 7675 | + } | |
| 7676 | + ((u8*)res.data)[r_i] = 0; | |
| 7677 | + string tmp_res = builtin__string_clone(builtin__tos(res.data, r_i)); | |
| 7678 | + builtin__array_free(&res); | |
| 7679 | + return tmp_res; | |
| 7680 | +} | |
| 7681 | +string strconv__fxx_to_str_l_parse_with_dot(string s) { | |
| 7682 | + if (s.len > 2 && (s.str[ 0] == 'n' || s.str[ 1] == 'i')) { | |
| 7683 | + return builtin__string_clone(s); | |
| 7684 | + } | |
| 7685 | + bool m_sgn_flag = false; | |
| 7686 | + int sgn = 1; | |
| 7687 | + Array_fixed_u8_26 b = {0}; | |
| 7688 | + int d_pos = 1; | |
| 7689 | + int i = 0; | |
| 7690 | + int i1 = 0; | |
| 7691 | + int exp = 0; | |
| 7692 | + int exp_sgn = 1; | |
| 7693 | + for (int _t2 = 0; _t2 < s.len; ++_t2) { | |
| 7694 | + u8 c = s.str[_t2]; | |
| 7695 | + if (c == '-') { | |
| 7696 | + sgn = -1; | |
| 7697 | + i++; | |
| 7698 | + } else if (c == '+') { | |
| 7699 | + sgn = 1; | |
| 7700 | + i++; | |
| 7701 | + } else if (c >= '0' && c <= '9') { | |
| 7702 | + b[i1] = c; | |
| 7703 | + i1++; | |
| 7704 | + i++; | |
| 7705 | + } else if (c == '.') { | |
| 7706 | + if (sgn > 0) { | |
| 7707 | + d_pos = i; | |
| 7708 | + } else { | |
| 7709 | + d_pos = i - 1; | |
| 7710 | + } | |
| 7711 | + i++; | |
| 7712 | + } else if (c == 'e') { | |
| 7713 | + i++; | |
| 7714 | + break; | |
| 7715 | + } else { | |
| 7716 | + return _S("Float conversion error!!"); | |
| 7717 | + } | |
| 7718 | + } | |
| 7719 | + b[i1] = 0; | |
| 7720 | + if (s.str[ i] == '-') { | |
| 7721 | + exp_sgn = -1; | |
| 7722 | + i++; | |
| 7723 | + } else if (s.str[ i] == '+') { | |
| 7724 | + exp_sgn = 1; | |
| 7725 | + i++; | |
| 7726 | + } | |
| 7727 | + int c = i; | |
| 7728 | + for (;;) { | |
| 7729 | + if (!(c < s.len)) break; | |
| 7730 | + exp = exp * 10 + ((int)((rune)(s.str[ c] - '0'))); | |
| 7731 | + c++; | |
| 7732 | + } | |
| 7733 | + Array_u8 res = builtin____new_array_with_default(exp + 32, 0, sizeof(u8), &(u8[]){0}); | |
| 7734 | + int r_i = 0; | |
| 7735 | + if (sgn == 1) { | |
| 7736 | + if (m_sgn_flag) { | |
| 7737 | + ((u8*)res.data)[r_i] = '+'; | |
| 7738 | + r_i++; | |
| 7739 | + } | |
| 7740 | + } else { | |
| 7741 | + ((u8*)res.data)[r_i] = '-'; | |
| 7742 | + r_i++; | |
| 7743 | + } | |
| 7744 | + i = 0; | |
| 7745 | + if (exp_sgn >= 0) { | |
| 7746 | + for (;;) { | |
| 7747 | + if (!(b[i] != 0)) break; | |
| 7748 | + ((u8*)res.data)[r_i] = b[i]; | |
| 7749 | + r_i++; | |
| 7750 | + i++; | |
| 7751 | + if (i >= d_pos && exp >= 0) { | |
| 7752 | + if (exp == 0) { | |
| 7753 | + ((u8*)res.data)[r_i] = '.'; | |
| 7754 | + r_i++; | |
| 7755 | + } | |
| 7756 | + exp--; | |
| 7757 | + } | |
| 7758 | + } | |
| 7759 | + for (;;) { | |
| 7760 | + if (!(exp >= 0)) break; | |
| 7761 | + ((u8*)res.data)[r_i] = '0'; | |
| 7762 | + r_i++; | |
| 7763 | + exp--; | |
| 7764 | + } | |
| 7765 | + } else { | |
| 7766 | + bool dot_p = true; | |
| 7767 | + for (;;) { | |
| 7768 | + if (!(exp > 0)) break; | |
| 7769 | + ((u8*)res.data)[r_i] = '0'; | |
| 7770 | + r_i++; | |
| 7771 | + exp--; | |
| 7772 | + if (dot_p) { | |
| 7773 | + ((u8*)res.data)[r_i] = '.'; | |
| 7774 | + r_i++; | |
| 7775 | + dot_p = false; | |
| 7776 | + } | |
| 7777 | + } | |
| 7778 | + for (;;) { | |
| 7779 | + if (!(b[i] != 0)) break; | |
| 7780 | + ((u8*)res.data)[r_i] = b[i]; | |
| 7781 | + r_i++; | |
| 7782 | + i++; | |
| 7783 | + } | |
| 7784 | + } | |
| 7785 | + if (r_i > 1 && ((u8*)res.data)[r_i - 1] == '.') { | |
| 7786 | + ((u8*)res.data)[r_i] = '0'; | |
| 7787 | + r_i++; | |
| 7788 | + } else if (!(Array_u8_contains(res, '.'))) { | |
| 7789 | + ((u8*)res.data)[r_i] = '.'; | |
| 7790 | + r_i++; | |
| 7791 | + ((u8*)res.data)[r_i] = '0'; | |
| 7792 | + r_i++; | |
| 7793 | + } | |
| 7794 | + ((u8*)res.data)[r_i] = 0; | |
| 7795 | + string tmp_res = builtin__string_clone(builtin__tos(res.data, r_i)); | |
| 7796 | + builtin__array_free(&res); | |
| 7797 | + return tmp_res; | |
| 7798 | +} | |
| 7799 | +inline VV_LOC u32 strconv__bool_to_u32(bool b) { | |
| 7800 | + if (b) { | |
| 7801 | + return ((u32)(1)); | |
| 7802 | + } | |
| 7803 | + return ((u32)(0)); | |
| 7804 | +} | |
| 7805 | +inline VV_LOC u64 strconv__bool_to_u64(bool b) { | |
| 7806 | + if (b) { | |
| 7807 | + return ((u64)(1)); | |
| 7808 | + } | |
| 7809 | + return ((u64)(0)); | |
| 7810 | +} | |
| 7811 | +VV_LOC string strconv__get_string_special(bool neg, bool expZero, bool mantZero) { | |
| 7812 | + if (!mantZero) { | |
| 7813 | + return _S("nan"); | |
| 7814 | + } | |
| 7815 | + if (!expZero) { | |
| 7816 | + if (neg) { | |
| 7817 | + return _S("-inf"); | |
| 7818 | + } else { | |
| 7819 | + return _S("+inf"); | |
| 7820 | + } | |
| 7821 | + } | |
| 7822 | + if (neg) { | |
| 7823 | + return _S("-0e+00"); | |
| 7824 | + } | |
| 7825 | + return _S("0e+00"); | |
| 7826 | +} | |
| 7827 | +VV_LOC u32 strconv__mul_shift_32(u32 m, u64 mul, int ishift) { | |
| 7828 | + multi_return_u64_u64 mr_750 = math__bits__mul_64(((u64)(m)), mul); | |
| 7829 | + u64 hi = mr_750.arg0; | |
| 7830 | + u64 lo = mr_750.arg1; | |
| 7831 | + u64 shifted_sum = (v__rshift_u64(lo, (u64)((u64)(ishift)))) + (v__lshift_u64(hi, (u64)((u64)(64 - ishift)))); | |
| 7832 | + ; | |
| 7833 | + return ((u32)(shifted_sum)); | |
| 7834 | +} | |
| 7835 | +inline VV_LOC u32 strconv__mul_pow5_invdiv_pow2(u32 m, u32 q, int j) { | |
| 7836 | + ; | |
| 7837 | + return strconv__mul_shift_32(m, _const_strconv__pow5_inv_split_32[q], j); | |
| 7838 | +} | |
| 7839 | +inline VV_LOC u32 strconv__mul_pow5_div_pow2(u32 m, u32 i, int j) { | |
| 7840 | + ; | |
| 7841 | + return strconv__mul_shift_32(m, _const_strconv__pow5_split_32[i], j); | |
| 7842 | +} | |
| 7843 | +VV_LOC u32 strconv__pow5_factor_32(u32 i_v) { | |
| 7844 | + u32 v = i_v; | |
| 7845 | + for (u32 n = ((u32)(0)); true; n++) { | |
| 7846 | + u32 q = VSAFE_DIV_u32(v , 5); | |
| 7847 | + u32 r = VSAFE_MOD_u32(v , 5); | |
| 7848 | + if (r != 0) { | |
| 7849 | + return n; | |
| 7850 | + } | |
| 7851 | + v = q; | |
| 7852 | + } | |
| 7853 | + return v; | |
| 7854 | +} | |
| 7855 | +VV_LOC bool strconv__multiple_of_power_of_five_32(u32 v, u32 p) { | |
| 7856 | + return strconv__pow5_factor_32(v) >= p; | |
| 7857 | +} | |
| 7858 | +VV_LOC bool strconv__multiple_of_power_of_two_32(u32 v, u32 p) { | |
| 7859 | + return ((u32)(math__bits__trailing_zeros_32(v))) >= p; | |
| 7860 | +} | |
| 7861 | +VV_LOC u32 strconv__log10_pow2(int e) { | |
| 7862 | + ; | |
| 7863 | + ; | |
| 7864 | + return v__rshift_u32((((u32)(e)) * 78913), (u64)18); | |
| 7865 | +} | |
| 7866 | +VV_LOC u32 strconv__log10_pow5(int e) { | |
| 7867 | + ; | |
| 7868 | + ; | |
| 7869 | + return v__rshift_u32((((u32)(e)) * 732923), (u64)20); | |
| 7870 | +} | |
| 7871 | +VV_LOC int strconv__pow5_bits(int e) { | |
| 7872 | + ; | |
| 7873 | + ; | |
| 7874 | + return ((int)((v__rshift_u32((((u32)(e)) * 1217359), (u64)19)) + 1)); | |
| 7875 | +} | |
| 7876 | +VV_LOC u64 strconv__shift_right_128(strconv__Uint128 v, int shift) { | |
| 7877 | + ; | |
| 7878 | + return ((v__lshift_u64(v.hi, (u64)((u64)(64 - shift)))) | (v__rshift_u64(v.lo, (u64)((u32)(shift))))); | |
| 7879 | +} | |
| 7880 | +VV_LOC u64 strconv__mul_shift_64(u64 m, strconv__Uint128 mul, int shift) { | |
| 7881 | + multi_return_u64_u64 mr_3253 = math__bits__mul_64(m, mul.hi); | |
| 7882 | + u64 hihi = mr_3253.arg0; | |
| 7883 | + u64 hilo = mr_3253.arg1; | |
| 7884 | + multi_return_u64_u64 mr_3288 = math__bits__mul_64(m, mul.lo); | |
| 7885 | + u64 lohi = mr_3288.arg0; | |
| 7886 | + strconv__Uint128 sum = ((strconv__Uint128){.lo = lohi + hilo,.hi = hihi,}); | |
| 7887 | + if (sum.lo < lohi) { | |
| 7888 | + sum.hi++; | |
| 7889 | + } | |
| 7890 | + return strconv__shift_right_128(sum, shift - 64); | |
| 7891 | +} | |
| 7892 | +VV_LOC u32 strconv__pow5_factor_64(u64 v_i) { | |
| 7893 | + u64 v = v_i; | |
| 7894 | + for (u32 n = ((u32)(0)); true; n++) { | |
| 7895 | + u64 q = VSAFE_DIV_u64(v , 5); | |
| 7896 | + u64 r = VSAFE_MOD_u64(v , 5); | |
| 7897 | + if (r != 0) { | |
| 7898 | + return n; | |
| 7899 | + } | |
| 7900 | + v = q; | |
| 7901 | + } | |
| 7902 | + return ((u32)(0)); | |
| 7903 | +} | |
| 7904 | +VV_LOC bool strconv__multiple_of_power_of_five_64(u64 v, u32 p) { | |
| 7905 | + return strconv__pow5_factor_64(v) >= p; | |
| 7906 | +} | |
| 7907 | +VV_LOC bool strconv__multiple_of_power_of_two_64(u64 v, u32 p) { | |
| 7908 | + return ((u32)(math__bits__trailing_zeros_64(v))) >= p; | |
| 7909 | +} | |
| 7910 | +int strconv__dec_digits(u64 n) { | |
| 7911 | + if (n <= 9999999999LL) { | |
| 7912 | + if (n <= 99999) { | |
| 7913 | + if (n <= 99) { | |
| 7914 | + if (n <= 9) { | |
| 7915 | + return 1; | |
| 7916 | + } else { | |
| 7917 | + return 2; | |
| 7918 | + } | |
| 7919 | + } else { | |
| 7920 | + if (n <= 999) { | |
| 7921 | + return 3; | |
| 7922 | + } else { | |
| 7923 | + if (n <= 9999) { | |
| 7924 | + return 4; | |
| 7925 | + } else { | |
| 7926 | + return 5; | |
| 7927 | + } | |
| 7928 | + } | |
| 7929 | + } | |
| 7930 | + } else { | |
| 7931 | + if (n <= 9999999) { | |
| 7932 | + if (n <= 999999) { | |
| 7933 | + return 6; | |
| 7934 | + } else { | |
| 7935 | + return 7; | |
| 7936 | + } | |
| 7937 | + } else { | |
| 7938 | + if (n <= 99999999) { | |
| 7939 | + return 8; | |
| 7940 | + } else { | |
| 7941 | + if (n <= 999999999) { | |
| 7942 | + return 9; | |
| 7943 | + } | |
| 7944 | + return 10; | |
| 7945 | + } | |
| 7946 | + } | |
| 7947 | + } | |
| 7948 | + } else { | |
| 7949 | + if (n <= 999999999999999LL) { | |
| 7950 | + if (n <= 999999999999LL) { | |
| 7951 | + if (n <= 99999999999LL) { | |
| 7952 | + return 11; | |
| 7953 | + } else { | |
| 7954 | + return 12; | |
| 7955 | + } | |
| 7956 | + } else { | |
| 7957 | + if (n <= 9999999999999LL) { | |
| 7958 | + return 13; | |
| 7959 | + } else { | |
| 7960 | + if (n <= 99999999999999LL) { | |
| 7961 | + return 14; | |
| 7962 | + } else { | |
| 7963 | + return 15; | |
| 7964 | + } | |
| 7965 | + } | |
| 7966 | + } | |
| 7967 | + } else { | |
| 7968 | + if (n <= 99999999999999999LL) { | |
| 7969 | + if (n <= 9999999999999999LL) { | |
| 7970 | + return 16; | |
| 7971 | + } else { | |
| 7972 | + return 17; | |
| 7973 | + } | |
| 7974 | + } else { | |
| 7975 | + if (n <= 999999999999999999LL) { | |
| 7976 | + return 18; | |
| 7977 | + } else { | |
| 7978 | + if (n <= 9999999999999999999ULL) { | |
| 7979 | + return 19; | |
| 7980 | + } | |
| 7981 | + return 20; | |
| 7982 | + } | |
| 7983 | + } | |
| 7984 | + } | |
| 7985 | + } | |
| 7986 | + return 0; | |
| 7987 | +} | |
| 7988 | +void strconv__v_printf(string str, Array_voidptr pt) { | |
| 7989 | + Array_voidptr _t1 = pt; | |
| 7990 | + Array_voidptr _t2 = builtin____new_array(0, _t1.len, sizeof(voidptr)); | |
| 7991 | + for (int _t3 = 0; _t3 < _t1.len; ++_t3) { | |
| 7992 | + voidptr _t4 = (*(voidptr*)builtin__array_get(_t1, _t3)); | |
| 7993 | + builtin__array_push((array*)&_t2, &_t4); | |
| 7994 | + } | |
| 7995 | + builtin__print(strconv__v_sprintf(str,_t2)); | |
| 7996 | +} | |
| 7997 | +string strconv__v_sprintf(string str, Array_voidptr pt) { | |
| 7998 | + strings__Builder res = strings__new_builder(pt.len * 16); | |
| 7999 | + int i = 0; | |
| 8000 | + int p_index = 0; | |
| 8001 | + bool sign = false; | |
| 8002 | + strconv__Align_text align = strconv__Align_text__right; | |
| 8003 | + int len0 = -1; | |
| 8004 | + int len1 = -1; | |
| 8005 | + int def_len1 = 6; | |
| 8006 | + u8 pad_ch = ((u8)(' ')); | |
| 8007 | + rune ch1 = '0'; | |
| 8008 | + rune ch2 = '0'; | |
| 8009 | + strconv__Char_parse_state status = strconv__Char_parse_state__norm_char; | |
| 8010 | + for (;;) { | |
| 8011 | + if (!(i < str.len)) break; | |
| 8012 | + if (status == strconv__Char_parse_state__reset_params) { | |
| 8013 | + sign = false; | |
| 8014 | + align = strconv__Align_text__right; | |
| 8015 | + len0 = -1; | |
| 8016 | + len1 = -1; | |
| 8017 | + pad_ch = ' '; | |
| 8018 | + status = strconv__Char_parse_state__norm_char; | |
| 8019 | + ch1 = '0'; | |
| 8020 | + ch2 = '0'; | |
| 8021 | + continue; | |
| 8022 | + } | |
| 8023 | + u8 ch = str.str[ i]; | |
| 8024 | + if (ch != '%' && status == strconv__Char_parse_state__norm_char) { | |
| 8025 | + strings__Builder_write_u8(&res, ch); | |
| 8026 | + i++; | |
| 8027 | + continue; | |
| 8028 | + } | |
| 8029 | + if (ch == '%' && status == strconv__Char_parse_state__field_char) { | |
| 8030 | + status = strconv__Char_parse_state__norm_char; | |
| 8031 | + strings__Builder_write_u8(&res, ch); | |
| 8032 | + i++; | |
| 8033 | + continue; | |
| 8034 | + } | |
| 8035 | + if (ch == '%' && status == strconv__Char_parse_state__norm_char) { | |
| 8036 | + status = strconv__Char_parse_state__field_char; | |
| 8037 | + i++; | |
| 8038 | + continue; | |
| 8039 | + } | |
| 8040 | + if (ch == 'c' && status == strconv__Char_parse_state__field_char) { | |
| 8041 | + strconv__v_sprintf_panic(p_index, pt.len); | |
| 8042 | + u8 d1 = ((u8)(*(((int*)(((voidptr*)pt.data)[p_index]))))); | |
| 8043 | + strings__Builder_write_u8(&res, d1); | |
| 8044 | + status = strconv__Char_parse_state__reset_params; | |
| 8045 | + p_index++; | |
| 8046 | + i++; | |
| 8047 | + continue; | |
| 8048 | + } | |
| 8049 | + if (ch == 'p' && status == strconv__Char_parse_state__field_char) { | |
| 8050 | + strconv__v_sprintf_panic(p_index, pt.len); | |
| 8051 | + strings__Builder_write_string(&res, _S("0x")); | |
| 8052 | + strings__Builder_write_string(&res, builtin__ptr_str(((voidptr*)pt.data)[p_index])); | |
| 8053 | + status = strconv__Char_parse_state__reset_params; | |
| 8054 | + p_index++; | |
| 8055 | + i++; | |
| 8056 | + continue; | |
| 8057 | + } | |
| 8058 | + if (status == strconv__Char_parse_state__field_char) { | |
| 8059 | + rune fc_ch1 = '0'; | |
| 8060 | + rune fc_ch2 = '0'; | |
| 8061 | + if ((i + 1) < str.len) { | |
| 8062 | + fc_ch1 = str.str[ i + 1]; | |
| 8063 | + if ((i + 2) < str.len) { | |
| 8064 | + fc_ch2 = str.str[ i + 2]; | |
| 8065 | + } | |
| 8066 | + } | |
| 8067 | + if (ch == '+') { | |
| 8068 | + sign = true; | |
| 8069 | + i++; | |
| 8070 | + continue; | |
| 8071 | + } else if (ch == '-') { | |
| 8072 | + align = strconv__Align_text__left; | |
| 8073 | + i++; | |
| 8074 | + continue; | |
| 8075 | + } else if (ch == '0' || ch == ' ') { | |
| 8076 | + if (align == strconv__Align_text__right) { | |
| 8077 | + pad_ch = ch; | |
| 8078 | + } | |
| 8079 | + i++; | |
| 8080 | + continue; | |
| 8081 | + } else if (ch == '\'') { | |
| 8082 | + i++; | |
| 8083 | + continue; | |
| 8084 | + } else if (ch == '.' && fc_ch1 >= '1' && fc_ch1 <= '9') { | |
| 8085 | + status = strconv__Char_parse_state__check_float; | |
| 8086 | + i++; | |
| 8087 | + continue; | |
| 8088 | + } else if (ch == '.' && fc_ch1 == '*' && fc_ch2 == 's') { | |
| 8089 | + strconv__v_sprintf_panic(p_index, pt.len); | |
| 8090 | + int len = *(((int*)(((voidptr*)pt.data)[p_index]))); | |
| 8091 | + p_index++; | |
| 8092 | + strconv__v_sprintf_panic(p_index, pt.len); | |
| 8093 | + string s = *(((string*)(((voidptr*)pt.data)[p_index]))); | |
| 8094 | + s = builtin__string_substr(s, 0, len); | |
| 8095 | + p_index++; | |
| 8096 | + strings__Builder_write_string(&res, s); | |
| 8097 | + status = strconv__Char_parse_state__reset_params; | |
| 8098 | + i += 3; | |
| 8099 | + continue; | |
| 8100 | + } | |
| 8101 | + status = strconv__Char_parse_state__len_set_start; | |
| 8102 | + continue; | |
| 8103 | + } | |
| 8104 | + if (status == strconv__Char_parse_state__len_set_start) { | |
| 8105 | + if (ch >= '1' && ch <= '9') { | |
| 8106 | + len0 = ((int)((rune)(ch - '0'))); | |
| 8107 | + status = strconv__Char_parse_state__len_set_in; | |
| 8108 | + i++; | |
| 8109 | + continue; | |
| 8110 | + } | |
| 8111 | + if (ch == '.') { | |
| 8112 | + status = strconv__Char_parse_state__check_float; | |
| 8113 | + i++; | |
| 8114 | + continue; | |
| 8115 | + } | |
| 8116 | + status = strconv__Char_parse_state__check_type; | |
| 8117 | + continue; | |
| 8118 | + } | |
| 8119 | + if (status == strconv__Char_parse_state__len_set_in) { | |
| 8120 | + if (ch >= '0' && ch <= '9') { | |
| 8121 | + len0 *= 10; | |
| 8122 | + len0 += ((int)((rune)(ch - '0'))); | |
| 8123 | + i++; | |
| 8124 | + continue; | |
| 8125 | + } | |
| 8126 | + if (ch == '.') { | |
| 8127 | + status = strconv__Char_parse_state__check_float; | |
| 8128 | + i++; | |
| 8129 | + continue; | |
| 8130 | + } | |
| 8131 | + status = strconv__Char_parse_state__check_type; | |
| 8132 | + continue; | |
| 8133 | + } | |
| 8134 | + if (status == strconv__Char_parse_state__check_float) { | |
| 8135 | + if (ch >= '0' && ch <= '9') { | |
| 8136 | + len1 = ((int)((rune)(ch - '0'))); | |
| 8137 | + status = strconv__Char_parse_state__check_float_in; | |
| 8138 | + i++; | |
| 8139 | + continue; | |
| 8140 | + } | |
| 8141 | + status = strconv__Char_parse_state__check_type; | |
| 8142 | + continue; | |
| 8143 | + } | |
| 8144 | + if (status == strconv__Char_parse_state__check_float_in) { | |
| 8145 | + if (ch >= '0' && ch <= '9') { | |
| 8146 | + len1 *= 10; | |
| 8147 | + len1 += ((int)((rune)(ch - '0'))); | |
| 8148 | + i++; | |
| 8149 | + continue; | |
| 8150 | + } | |
| 8151 | + status = strconv__Char_parse_state__check_type; | |
| 8152 | + continue; | |
| 8153 | + } | |
| 8154 | + if (status == strconv__Char_parse_state__check_type) { | |
| 8155 | + if (ch == 'l') { | |
| 8156 | + if (ch1 == '0') { | |
| 8157 | + ch1 = 'l'; | |
| 8158 | + i++; | |
| 8159 | + continue; | |
| 8160 | + } else { | |
| 8161 | + ch2 = 'l'; | |
| 8162 | + i++; | |
| 8163 | + continue; | |
| 8164 | + } | |
| 8165 | + } else if (ch == 'h') { | |
| 8166 | + if (ch1 == '0') { | |
| 8167 | + ch1 = 'h'; | |
| 8168 | + i++; | |
| 8169 | + continue; | |
| 8170 | + } else { | |
| 8171 | + ch2 = 'h'; | |
| 8172 | + i++; | |
| 8173 | + continue; | |
| 8174 | + } | |
| 8175 | + } else if (ch == 'd' || ch == 'i') { | |
| 8176 | + u64 d1 = ((u64)(0)); | |
| 8177 | + bool positive = true; | |
| 8178 | + | |
| 8179 | + if (ch1 == ('h')) { | |
| 8180 | + strconv__v_sprintf_panic(p_index, pt.len); | |
| 8181 | + int x = *(((int*)(((voidptr*)pt.data)[p_index]))); | |
| 8182 | + if (ch2 == 'h') { | |
| 8183 | + i8 sx = ((i8)(x)); | |
| 8184 | + positive = (sx >= 0 ? (true) : (false)); | |
| 8185 | + d1 = (positive ? (((u64)(sx))) : (((u64)(-sx)))); | |
| 8186 | + } else { | |
| 8187 | + i16 sx = ((i16)(x)); | |
| 8188 | + positive = (sx >= 0 ? (true) : (false)); | |
| 8189 | + d1 = (positive ? (((u64)(sx))) : (((u64)(-sx)))); | |
| 8190 | + } | |
| 8191 | + } | |
| 8192 | + else if (ch1 == ('l')) { | |
| 8193 | + strconv__v_sprintf_panic(p_index, pt.len); | |
| 8194 | + i64 x = *(((i64*)(((voidptr*)pt.data)[p_index]))); | |
| 8195 | + positive = (x >= 0 ? (true) : (false)); | |
| 8196 | + d1 = (positive ? (((u64)(x))) : (((u64)(-x)))); | |
| 8197 | + } | |
| 8198 | + else { | |
| 8199 | + strconv__v_sprintf_panic(p_index, pt.len); | |
| 8200 | + int x = *(((int*)(((voidptr*)pt.data)[p_index]))); | |
| 8201 | + positive = (x >= 0 ? (true) : (false)); | |
| 8202 | + d1 = (positive ? (((u64)(x))) : (((u64)(-x)))); | |
| 8203 | + } | |
| 8204 | + string tmp = strconv__format_dec_old(d1, ((strconv__BF_param){ | |
| 8205 | + .pad_ch = pad_ch, | |
| 8206 | + .len0 = len0, | |
| 8207 | + .len1 = 0, | |
| 8208 | + .positive = positive, | |
| 8209 | + .sign_flag = sign, | |
| 8210 | + .align = align, | |
| 8211 | + .rm_tail_zero = 0, | |
| 8212 | + })); | |
| 8213 | + strings__Builder_write_string(&res, tmp); | |
| 8214 | + builtin__string_free(&tmp); | |
| 8215 | + status = strconv__Char_parse_state__reset_params; | |
| 8216 | + p_index++; | |
| 8217 | + i++; | |
| 8218 | + ch1 = '0'; | |
| 8219 | + ch2 = '0'; | |
| 8220 | + continue; | |
| 8221 | + } else if (ch == 'u') { | |
| 8222 | + u64 d1 = ((u64)(0)); | |
| 8223 | + bool positive = true; | |
| 8224 | + strconv__v_sprintf_panic(p_index, pt.len); | |
| 8225 | + | |
| 8226 | + if (ch1 == ('h')) { | |
| 8227 | + int x = *(((int*)(((voidptr*)pt.data)[p_index]))); | |
| 8228 | + if (ch2 == 'h') { | |
| 8229 | + d1 = ((u64)(((u8)(x)))); | |
| 8230 | + } else { | |
| 8231 | + d1 = ((u64)(((u16)(x)))); | |
| 8232 | + } | |
| 8233 | + } | |
| 8234 | + else if (ch1 == ('l')) { | |
| 8235 | + d1 = ((u64)(*(((u64*)(((voidptr*)pt.data)[p_index]))))); | |
| 8236 | + } | |
| 8237 | + else { | |
| 8238 | + d1 = ((u64)(((u32)(*(((int*)(((voidptr*)pt.data)[p_index]))))))); | |
| 8239 | + } | |
| 8240 | + string tmp = strconv__format_dec_old(d1, ((strconv__BF_param){ | |
| 8241 | + .pad_ch = pad_ch, | |
| 8242 | + .len0 = len0, | |
| 8243 | + .len1 = 0, | |
| 8244 | + .positive = positive, | |
| 8245 | + .sign_flag = sign, | |
| 8246 | + .align = align, | |
| 8247 | + .rm_tail_zero = 0, | |
| 8248 | + })); | |
| 8249 | + strings__Builder_write_string(&res, tmp); | |
| 8250 | + builtin__string_free(&tmp); | |
| 8251 | + status = strconv__Char_parse_state__reset_params; | |
| 8252 | + p_index++; | |
| 8253 | + i++; | |
| 8254 | + continue; | |
| 8255 | + } else if (ch == 'x' || ch == 'X') { | |
| 8256 | + strconv__v_sprintf_panic(p_index, pt.len); | |
| 8257 | + string s = _S(""); | |
| 8258 | + | |
| 8259 | + if (ch1 == ('h')) { | |
| 8260 | + int x = *(((int*)(((voidptr*)pt.data)[p_index]))); | |
| 8261 | + if (ch2 == 'h') { | |
| 8262 | + s = builtin__i8_hex(((i8)(x))); | |
| 8263 | + } else { | |
| 8264 | + s = builtin__i16_hex(((i16)(x))); | |
| 8265 | + } | |
| 8266 | + } | |
| 8267 | + else if (ch1 == ('l')) { | |
| 8268 | + i64 x = *(((i64*)(((voidptr*)pt.data)[p_index]))); | |
| 8269 | + s = builtin__i64_hex(x); | |
| 8270 | + } | |
| 8271 | + else { | |
| 8272 | + int x = *(((int*)(((voidptr*)pt.data)[p_index]))); | |
| 8273 | + s = builtin__int_hex(x); | |
| 8274 | + } | |
| 8275 | + if (ch == 'X') { | |
| 8276 | + string tmp = s; | |
| 8277 | + s = builtin__string_to_upper(s); | |
| 8278 | + builtin__string_free(&tmp); | |
| 8279 | + } | |
| 8280 | + string tmp = strconv__format_str(s, ((strconv__BF_param){ | |
| 8281 | + .pad_ch = pad_ch, | |
| 8282 | + .len0 = len0, | |
| 8283 | + .len1 = 0, | |
| 8284 | + .positive = true, | |
| 8285 | + .sign_flag = false, | |
| 8286 | + .align = align, | |
| 8287 | + .rm_tail_zero = 0, | |
| 8288 | + })); | |
| 8289 | + strings__Builder_write_string(&res, tmp); | |
| 8290 | + builtin__string_free(&tmp); | |
| 8291 | + builtin__string_free(&s); | |
| 8292 | + status = strconv__Char_parse_state__reset_params; | |
| 8293 | + p_index++; | |
| 8294 | + i++; | |
| 8295 | + continue; | |
| 8296 | + } | |
| 8297 | + if (ch == 'f' || ch == 'F') { | |
| 8298 | + #if !defined(CUSTOM_DEFINE_nofloat) | |
| 8299 | + { | |
| 8300 | + strconv__v_sprintf_panic(p_index, pt.len); | |
| 8301 | + f64 x = *(((f64*)(((voidptr*)pt.data)[p_index]))); | |
| 8302 | + bool positive = x >= ((f64)(0.0)); | |
| 8303 | + len1 = (len1 >= 0 ? (len1) : (def_len1)); | |
| 8304 | + string s = strconv__format_fl_old(((f64)(x)), ((strconv__BF_param){ | |
| 8305 | + .pad_ch = pad_ch, | |
| 8306 | + .len0 = len0, | |
| 8307 | + .len1 = len1, | |
| 8308 | + .positive = positive, | |
| 8309 | + .sign_flag = sign, | |
| 8310 | + .align = align, | |
| 8311 | + .rm_tail_zero = 0, | |
| 8312 | + })); | |
| 8313 | + if (ch == 'F') { | |
| 8314 | + string tmp = builtin__string_to_upper(s); | |
| 8315 | + strings__Builder_write_string(&res, tmp); | |
| 8316 | + builtin__string_free(&tmp); | |
| 8317 | + } else { | |
| 8318 | + strings__Builder_write_string(&res, s); | |
| 8319 | + } | |
| 8320 | + builtin__string_free(&s); | |
| 8321 | + } | |
| 8322 | + #endif | |
| 8323 | + status = strconv__Char_parse_state__reset_params; | |
| 8324 | + p_index++; | |
| 8325 | + i++; | |
| 8326 | + continue; | |
| 8327 | + } else if (ch == 'e' || ch == 'E') { | |
| 8328 | + #if !defined(CUSTOM_DEFINE_nofloat) | |
| 8329 | + { | |
| 8330 | + strconv__v_sprintf_panic(p_index, pt.len); | |
| 8331 | + f64 x = *(((f64*)(((voidptr*)pt.data)[p_index]))); | |
| 8332 | + bool positive = x >= ((f64)(0.0)); | |
| 8333 | + len1 = (len1 >= 0 ? (len1) : (def_len1)); | |
| 8334 | + string s = strconv__format_es_old(((f64)(x)), ((strconv__BF_param){ | |
| 8335 | + .pad_ch = pad_ch, | |
| 8336 | + .len0 = len0, | |
| 8337 | + .len1 = len1, | |
| 8338 | + .positive = positive, | |
| 8339 | + .sign_flag = sign, | |
| 8340 | + .align = align, | |
| 8341 | + .rm_tail_zero = 0, | |
| 8342 | + })); | |
| 8343 | + if (ch == 'E') { | |
| 8344 | + string tmp = builtin__string_to_upper(s); | |
| 8345 | + strings__Builder_write_string(&res, tmp); | |
| 8346 | + builtin__string_free(&tmp); | |
| 8347 | + } else { | |
| 8348 | + strings__Builder_write_string(&res, s); | |
| 8349 | + } | |
| 8350 | + builtin__string_free(&s); | |
| 8351 | + } | |
| 8352 | + #endif | |
| 8353 | + status = strconv__Char_parse_state__reset_params; | |
| 8354 | + p_index++; | |
| 8355 | + i++; | |
| 8356 | + continue; | |
| 8357 | + } else if (ch == 'g' || ch == 'G') { | |
| 8358 | + #if !defined(CUSTOM_DEFINE_nofloat) | |
| 8359 | + { | |
| 8360 | + strconv__v_sprintf_panic(p_index, pt.len); | |
| 8361 | + f64 x = *(((f64*)(((voidptr*)pt.data)[p_index]))); | |
| 8362 | + bool positive = x >= ((f64)(0.0)); | |
| 8363 | + string s = _S(""); | |
| 8364 | + f64 tx = strconv__fabs(x); | |
| 8365 | + if (tx < ((f64)(999999.0)) && tx >= ((f64)(0.00001))) { | |
| 8366 | + len1 = (len1 >= 0 ? (len1 + 1) : (def_len1)); | |
| 8367 | + string tmp = s; | |
| 8368 | + s = strconv__format_fl_old(x, ((strconv__BF_param){ | |
| 8369 | + .pad_ch = pad_ch, | |
| 8370 | + .len0 = len0, | |
| 8371 | + .len1 = len1, | |
| 8372 | + .positive = positive, | |
| 8373 | + .sign_flag = sign, | |
| 8374 | + .align = align, | |
| 8375 | + .rm_tail_zero = true, | |
| 8376 | + })); | |
| 8377 | + builtin__string_free(&tmp); | |
| 8378 | + } else { | |
| 8379 | + len1 = (len1 >= 0 ? (len1 + 1) : (def_len1)); | |
| 8380 | + string tmp = s; | |
| 8381 | + s = strconv__format_es_old(x, ((strconv__BF_param){ | |
| 8382 | + .pad_ch = pad_ch, | |
| 8383 | + .len0 = len0, | |
| 8384 | + .len1 = len1, | |
| 8385 | + .positive = positive, | |
| 8386 | + .sign_flag = sign, | |
| 8387 | + .align = align, | |
| 8388 | + .rm_tail_zero = true, | |
| 8389 | + })); | |
| 8390 | + builtin__string_free(&tmp); | |
| 8391 | + } | |
| 8392 | + if (ch == 'G') { | |
| 8393 | + string tmp = builtin__string_to_upper(s); | |
| 8394 | + strings__Builder_write_string(&res, tmp); | |
| 8395 | + builtin__string_free(&tmp); | |
| 8396 | + } else { | |
| 8397 | + strings__Builder_write_string(&res, s); | |
| 8398 | + } | |
| 8399 | + builtin__string_free(&s); | |
| 8400 | + } | |
| 8401 | + #endif | |
| 8402 | + status = strconv__Char_parse_state__reset_params; | |
| 8403 | + p_index++; | |
| 8404 | + i++; | |
| 8405 | + continue; | |
| 8406 | + } else if (ch == 's') { | |
| 8407 | + strconv__v_sprintf_panic(p_index, pt.len); | |
| 8408 | + string s1 = *(((string*)(((voidptr*)pt.data)[p_index]))); | |
| 8409 | + pad_ch = ' '; | |
| 8410 | + string tmp = strconv__format_str(s1, ((strconv__BF_param){ | |
| 8411 | + .pad_ch = pad_ch, | |
| 8412 | + .len0 = len0, | |
| 8413 | + .len1 = 0, | |
| 8414 | + .positive = true, | |
| 8415 | + .sign_flag = false, | |
| 8416 | + .align = align, | |
| 8417 | + .rm_tail_zero = 0, | |
| 8418 | + })); | |
| 8419 | + strings__Builder_write_string(&res, tmp); | |
| 8420 | + builtin__string_free(&tmp); | |
| 8421 | + status = strconv__Char_parse_state__reset_params; | |
| 8422 | + p_index++; | |
| 8423 | + i++; | |
| 8424 | + continue; | |
| 8425 | + } | |
| 8426 | + } | |
| 8427 | + status = strconv__Char_parse_state__reset_params; | |
| 8428 | + p_index++; | |
| 8429 | + i++; | |
| 8430 | + } | |
| 8431 | + if (p_index != pt.len) { | |
| 8432 | + builtin__panic_n2(_S("% conversion specifiers number mismatch (expected %, given args)"), p_index, pt.len); | |
| 8433 | + VUNREACHABLE(); | |
| 8434 | + } | |
| 8435 | + string _t4 = strings__Builder_str(&res); | |
| 8436 | + { // defer begin | |
| 8437 | + strings__Builder_free(&res); | |
| 8438 | + } // defer end | |
| 8439 | + return _t4; | |
| 8440 | +} | |
| 8441 | +inline VV_LOC void strconv__v_sprintf_panic(int idx, int len) { | |
| 8442 | + if (idx >= len) { | |
| 8443 | + builtin__panic_n2(_S("% conversion specifiers number mismatch (expected %, given args)"), idx + 1, len); | |
| 8444 | + VUNREACHABLE(); | |
| 8445 | + } | |
| 8446 | +} | |
| 8447 | +VV_LOC f64 strconv__fabs(f64 x) { | |
| 8448 | + if (x < ((f64)(0.0))) { | |
| 8449 | + return -x; | |
| 8450 | + } | |
| 8451 | + return x; | |
| 8452 | +} | |
| 8453 | +string strconv__format_fl_old(f64 f, strconv__BF_param p) { | |
| 8454 | + { // Unsafe block | |
| 8455 | + string s = _S(""); | |
| 8456 | + string fs = strconv__f64_to_str_lnd1((f >= ((f64)(0.0)) ? (f) : (-f)), p.len1); | |
| 8457 | + if (fs.str[ 0] == '[') { | |
| 8458 | + builtin__string_free(&s); | |
| 8459 | + return fs; | |
| 8460 | + } | |
| 8461 | + if (p.rm_tail_zero) { | |
| 8462 | + string tmp = fs; | |
| 8463 | + fs = strconv__remove_tail_zeros_old(fs); | |
| 8464 | + builtin__string_free(&tmp); | |
| 8465 | + } | |
| 8466 | + strings__Builder res = strings__new_builder((p.len0 > fs.len ? (p.len0) : (fs.len))); | |
| 8467 | + int sign_len_diff = 0; | |
| 8468 | + if (p.pad_ch == '0') { | |
| 8469 | + if (p.positive) { | |
| 8470 | + if (p.sign_flag) { | |
| 8471 | + strings__Builder_write_u8(&res, '+'); | |
| 8472 | + sign_len_diff = -1; | |
| 8473 | + } | |
| 8474 | + } else { | |
| 8475 | + strings__Builder_write_u8(&res, '-'); | |
| 8476 | + sign_len_diff = -1; | |
| 8477 | + } | |
| 8478 | + string tmp = s; | |
| 8479 | + s = builtin__string_clone(fs); | |
| 8480 | + builtin__string_free(&tmp); | |
| 8481 | + } else { | |
| 8482 | + if (p.positive) { | |
| 8483 | + if (p.sign_flag) { | |
| 8484 | + string tmp = s; | |
| 8485 | + s = builtin__string__plus(_S("+"), fs); | |
| 8486 | + builtin__string_free(&tmp); | |
| 8487 | + } else { | |
| 8488 | + string tmp = s; | |
| 8489 | + s = builtin__string_clone(fs); | |
| 8490 | + builtin__string_free(&tmp); | |
| 8491 | + } | |
| 8492 | + } else { | |
| 8493 | + string tmp = s; | |
| 8494 | + s = builtin__string__plus(_S("-"), fs); | |
| 8495 | + builtin__string_free(&tmp); | |
| 8496 | + } | |
| 8497 | + } | |
| 8498 | + int dif = p.len0 - s.len + sign_len_diff; | |
| 8499 | + if (p.align == strconv__Align_text__right) { | |
| 8500 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 8501 | + strings__Builder_write_u8(&res, p.pad_ch); | |
| 8502 | + } | |
| 8503 | + } | |
| 8504 | + strings__Builder_write_string(&res, s); | |
| 8505 | + if (p.align == strconv__Align_text__left) { | |
| 8506 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 8507 | + strings__Builder_write_u8(&res, p.pad_ch); | |
| 8508 | + } | |
| 8509 | + } | |
| 8510 | + builtin__string_free(&s); | |
| 8511 | + builtin__string_free(&fs); | |
| 8512 | + string _t2 = strings__Builder_str(&res); | |
| 8513 | + { // defer begin | |
| 8514 | + strings__Builder_free(&res); | |
| 8515 | + } // defer end | |
| 8516 | + return _t2; | |
| 8517 | + { // defer begin | |
| 8518 | + strings__Builder_free(&res); | |
| 8519 | + } // defer end | |
| 8520 | + } | |
| 8521 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 8522 | +} | |
| 8523 | +VV_LOC string strconv__format_es_old(f64 f, strconv__BF_param p) { | |
| 8524 | + { // Unsafe block | |
| 8525 | + string s = _S(""); | |
| 8526 | + string fs = strconv__f64_to_str_pad((f > 0 ? (f) : (-f)), p.len1); | |
| 8527 | + if (p.rm_tail_zero) { | |
| 8528 | + string tmp = fs; | |
| 8529 | + fs = strconv__remove_tail_zeros_old(fs); | |
| 8530 | + builtin__string_free(&tmp); | |
| 8531 | + } | |
| 8532 | + strings__Builder res = strings__new_builder((p.len0 > fs.len ? (p.len0) : (fs.len))); | |
| 8533 | + int sign_len_diff = 0; | |
| 8534 | + if (p.pad_ch == '0') { | |
| 8535 | + if (p.positive) { | |
| 8536 | + if (p.sign_flag) { | |
| 8537 | + strings__Builder_write_u8(&res, '+'); | |
| 8538 | + sign_len_diff = -1; | |
| 8539 | + } | |
| 8540 | + } else { | |
| 8541 | + strings__Builder_write_u8(&res, '-'); | |
| 8542 | + sign_len_diff = -1; | |
| 8543 | + } | |
| 8544 | + string tmp = s; | |
| 8545 | + s = builtin__string_clone(fs); | |
| 8546 | + builtin__string_free(&tmp); | |
| 8547 | + } else { | |
| 8548 | + if (p.positive) { | |
| 8549 | + if (p.sign_flag) { | |
| 8550 | + string tmp = s; | |
| 8551 | + s = builtin__string__plus(_S("+"), fs); | |
| 8552 | + builtin__string_free(&tmp); | |
| 8553 | + } else { | |
| 8554 | + string tmp = s; | |
| 8555 | + s = builtin__string_clone(fs); | |
| 8556 | + builtin__string_free(&tmp); | |
| 8557 | + } | |
| 8558 | + } else { | |
| 8559 | + string tmp = s; | |
| 8560 | + s = builtin__string__plus(_S("-"), fs); | |
| 8561 | + builtin__string_free(&tmp); | |
| 8562 | + } | |
| 8563 | + } | |
| 8564 | + int dif = p.len0 - s.len + sign_len_diff; | |
| 8565 | + if (p.align == strconv__Align_text__right) { | |
| 8566 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 8567 | + strings__Builder_write_u8(&res, p.pad_ch); | |
| 8568 | + } | |
| 8569 | + } | |
| 8570 | + strings__Builder_write_string(&res, s); | |
| 8571 | + if (p.align == strconv__Align_text__left) { | |
| 8572 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 8573 | + strings__Builder_write_u8(&res, p.pad_ch); | |
| 8574 | + } | |
| 8575 | + } | |
| 8576 | + string _t1 = strings__Builder_str(&res); | |
| 8577 | + { // defer begin | |
| 8578 | + strings__Builder_free(&res); | |
| 8579 | + builtin__string_free(&fs); | |
| 8580 | + builtin__string_free(&s); | |
| 8581 | + } // defer end | |
| 8582 | + return _t1; | |
| 8583 | + { // defer begin | |
| 8584 | + strings__Builder_free(&res); | |
| 8585 | + builtin__string_free(&fs); | |
| 8586 | + builtin__string_free(&s); | |
| 8587 | + } // defer end | |
| 8588 | + } | |
| 8589 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 8590 | +} | |
| 8591 | +VV_LOC string strconv__remove_tail_zeros_old(string s) { | |
| 8592 | + int i = 0; | |
| 8593 | + int last_zero_start = -1; | |
| 8594 | + int dot_pos = -1; | |
| 8595 | + bool in_decimal = false; | |
| 8596 | + u8 prev_ch = ((u8)(0)); | |
| 8597 | + for (;;) { | |
| 8598 | + if (!(i < s.len)) break; | |
| 8599 | + u8 ch = s.str[i]; | |
| 8600 | + if (ch == '.') { | |
| 8601 | + in_decimal = true; | |
| 8602 | + dot_pos = i; | |
| 8603 | + } else if (in_decimal) { | |
| 8604 | + if (ch == '0' && prev_ch != '0') { | |
| 8605 | + last_zero_start = i; | |
| 8606 | + } else if (ch >= '1' && ch <= '9') { | |
| 8607 | + last_zero_start = -1; | |
| 8608 | + } else if (ch == 'e') { | |
| 8609 | + break; | |
| 8610 | + } | |
| 8611 | + } | |
| 8612 | + prev_ch = ch; | |
| 8613 | + i++; | |
| 8614 | + } | |
| 8615 | + string tmp = _S(""); | |
| 8616 | + if (last_zero_start > 0) { | |
| 8617 | + if (last_zero_start == dot_pos + 1) { | |
| 8618 | + tmp = builtin__string__plus(builtin__string_substr(s, 0, dot_pos), builtin__string_substr(s, i, 2147483647)); | |
| 8619 | + } else { | |
| 8620 | + tmp = builtin__string__plus(builtin__string_substr(s, 0, last_zero_start), builtin__string_substr(s, i, 2147483647)); | |
| 8621 | + } | |
| 8622 | + } else { | |
| 8623 | + tmp = builtin__string_clone(s); | |
| 8624 | + } | |
| 8625 | + if (tmp.str[tmp.len - 1] == '.') { | |
| 8626 | + return builtin__string_substr(tmp, 0, tmp.len - 1); | |
| 8627 | + } | |
| 8628 | + return tmp; | |
| 8629 | +} | |
| 8630 | +string strconv__format_dec_old(u64 d, strconv__BF_param p) { | |
| 8631 | + string s = _S(""); | |
| 8632 | + strings__Builder res = strings__new_builder(20); | |
| 8633 | + int sign_len_diff = 0; | |
| 8634 | + if (p.pad_ch == '0') { | |
| 8635 | + if (p.positive) { | |
| 8636 | + if (p.sign_flag) { | |
| 8637 | + strings__Builder_write_u8(&res, '+'); | |
| 8638 | + sign_len_diff = -1; | |
| 8639 | + } | |
| 8640 | + } else { | |
| 8641 | + strings__Builder_write_u8(&res, '-'); | |
| 8642 | + sign_len_diff = -1; | |
| 8643 | + } | |
| 8644 | + string tmp = s; | |
| 8645 | + s = builtin__u64_str(d); | |
| 8646 | + builtin__string_free(&tmp); | |
| 8647 | + } else { | |
| 8648 | + if (p.positive) { | |
| 8649 | + if (p.sign_flag) { | |
| 8650 | + string tmp = s; | |
| 8651 | + s = builtin__string__plus(_S("+"), builtin__u64_str(d)); | |
| 8652 | + builtin__string_free(&tmp); | |
| 8653 | + } else { | |
| 8654 | + string tmp = s; | |
| 8655 | + s = builtin__u64_str(d); | |
| 8656 | + builtin__string_free(&tmp); | |
| 8657 | + } | |
| 8658 | + } else { | |
| 8659 | + string tmp = s; | |
| 8660 | + s = builtin__string__plus(_S("-"), builtin__u64_str(d)); | |
| 8661 | + builtin__string_free(&tmp); | |
| 8662 | + } | |
| 8663 | + } | |
| 8664 | + int dif = p.len0 - s.len + sign_len_diff; | |
| 8665 | + if (p.align == strconv__Align_text__right) { | |
| 8666 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 8667 | + strings__Builder_write_u8(&res, p.pad_ch); | |
| 8668 | + } | |
| 8669 | + } | |
| 8670 | + strings__Builder_write_string(&res, s); | |
| 8671 | + if (p.align == strconv__Align_text__left) { | |
| 8672 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 8673 | + strings__Builder_write_u8(&res, p.pad_ch); | |
| 8674 | + } | |
| 8675 | + } | |
| 8676 | + string _t1 = strings__Builder_str(&res); | |
| 8677 | + { // defer begin | |
| 8678 | + strings__Builder_free(&res); | |
| 8679 | + builtin__string_free(&s); | |
| 8680 | + } // defer end | |
| 8681 | + return _t1; | |
| 8682 | +} | |
| 8683 | +int strconv__write_dec(i64 n, Array_u8* buf) { | |
| 8684 | + u64 mag = ((u64)(n)); | |
| 8685 | + if (n < 0) { | |
| 8686 | + mag = ((u64)(0)) - mag; | |
| 8687 | + int ndigits = strconv__dec_digits(mag); | |
| 8688 | + if (buf->len < ndigits + 1) { | |
| 8689 | + return -1; | |
| 8690 | + } | |
| 8691 | + ((u8*)buf->data)[0] = '-'; | |
| 8692 | + strconv__write_dec_u_digits(mag, buf, 1, ndigits); | |
| 8693 | + return ndigits + 1; | |
| 8694 | + } | |
| 8695 | + int ndigits = strconv__dec_digits(mag); | |
| 8696 | + if (buf->len < ndigits) { | |
| 8697 | + return -1; | |
| 8698 | + } | |
| 8699 | + strconv__write_dec_u_digits(mag, buf, 0, ndigits); | |
| 8700 | + return ndigits; | |
| 8701 | +} | |
| 8702 | +int strconv__write_dec_u(u64 n, Array_u8* buf) { | |
| 8703 | + int ndigits = strconv__dec_digits(n); | |
| 8704 | + if (buf->len < ndigits) { | |
| 8705 | + return -1; | |
| 8706 | + } | |
| 8707 | + strconv__write_dec_u_digits(n, buf, 0, ndigits); | |
| 8708 | + return ndigits; | |
| 8709 | +} | |
| 8710 | +VV_LOC void strconv__write_dec_u_digits(u64 n, Array_u8* buf, int offset, int ndigits) { | |
| 8711 | + u64 x = n; | |
| 8712 | + int i = offset + ndigits; | |
| 8713 | + for (;;) { | |
| 8714 | + i--; | |
| 8715 | + ((u8*)buf->data)[i] = (rune)(((u8)(VSAFE_MOD_u64(x , 10))) + '0'); | |
| 8716 | + x = VSAFE_DIV_u64(x,10); | |
| 8717 | + if (x == 0) { | |
| 8718 | + break; | |
| 8719 | + } | |
| 8720 | + } | |
| 8721 | +} | |
| 8722 | +VNORETURN VV_LOC void builtin___memory_panic(string fname, isize size) { | |
| 8723 | + v_memory_panic = true; | |
| 8724 | + builtin__eprint(fname); | |
| 8725 | + builtin__eprint(_S("(")); | |
| 8726 | + #if 0 | |
| 8727 | + { | |
| 8728 | + } | |
| 8729 | + #else | |
| 8730 | + { | |
| 8731 | + fprintf(stderr, "%p", ((voidptr)(size))); | |
| 8732 | + } | |
| 8733 | + #endif | |
| 8734 | + if (size < 0) { | |
| 8735 | + builtin__eprint(_S(" < 0")); | |
| 8736 | + } | |
| 8737 | + builtin__eprintln(_S(")")); | |
| 8738 | + builtin___v_panic(_S("memory allocation failure")); | |
| 8739 | + VUNREACHABLE(); | |
| 8740 | + while(1); | |
| 8741 | +} | |
| 8742 | +u8* builtin___v_malloc(isize n) { | |
| 8743 | + if (n < 0) { | |
| 8744 | + builtin___memory_panic(_S("malloc"), n); | |
| 8745 | + VUNREACHABLE(); | |
| 8746 | + } else if (n == 0) { | |
| 8747 | + return ((u8*)(((void*)0))); | |
| 8748 | + } | |
| 8749 | + u8* res = ((u8*)(((void*)0))); | |
| 8750 | + #if 0 | |
| 8751 | + { | |
| 8752 | + } | |
| 8753 | + #elif defined(CUSTOM_DEFINE_vgc) | |
| 8754 | + { | |
| 8755 | + } | |
| 8756 | + #elif defined(CUSTOM_DEFINE_gcboehm) | |
| 8757 | + { | |
| 8758 | + } | |
| 8759 | + #elif 0 | |
| 8760 | + { | |
| 8761 | + } | |
| 8762 | + #else | |
| 8763 | + { | |
| 8764 | + #if 0 | |
| 8765 | + { | |
| 8766 | + } | |
| 8767 | + #else | |
| 8768 | + { | |
| 8769 | + res = malloc(n); | |
| 8770 | + } | |
| 8771 | + #endif | |
| 8772 | + } | |
| 8773 | + #endif | |
| 8774 | + if (res == 0) { | |
| 8775 | + builtin___memory_panic(_S("malloc"), n); | |
| 8776 | + VUNREACHABLE(); | |
| 8777 | + } | |
| 8778 | + ; | |
| 8779 | + return res; | |
| 8780 | +} | |
| 8781 | +u8* builtin__malloc_noscan(isize n) { | |
| 8782 | + if (n < 0) { | |
| 8783 | + builtin___memory_panic(_S("malloc_noscan"), n); | |
| 8784 | + VUNREACHABLE(); | |
| 8785 | + } | |
| 8786 | + u8* res = ((u8*)(((void*)0))); | |
| 8787 | + #if 0 | |
| 8788 | + { | |
| 8789 | + } | |
| 8790 | + #elif defined(CUSTOM_DEFINE_vgc) | |
| 8791 | + { | |
| 8792 | + } | |
| 8793 | + #elif defined(CUSTOM_DEFINE_gcboehm) | |
| 8794 | + { | |
| 8795 | + } | |
| 8796 | + #elif 0 | |
| 8797 | + { | |
| 8798 | + } | |
| 8799 | + #else | |
| 8800 | + { | |
| 8801 | + #if 0 | |
| 8802 | + { | |
| 8803 | + } | |
| 8804 | + #else | |
| 8805 | + { | |
| 8806 | + res = malloc(n); | |
| 8807 | + } | |
| 8808 | + #endif | |
| 8809 | + } | |
| 8810 | + #endif | |
| 8811 | + if (res == 0) { | |
| 8812 | + builtin___memory_panic(_S("malloc_noscan"), n); | |
| 8813 | + VUNREACHABLE(); | |
| 8814 | + } | |
| 8815 | + ; | |
| 8816 | + return res; | |
| 8817 | +} | |
| 8818 | +VV_LOC u8* builtin__malloc_uninit(isize n) { | |
| 8819 | + if (n < 0) { | |
| 8820 | + builtin___memory_panic(_S("malloc_uninit"), n); | |
| 8821 | + VUNREACHABLE(); | |
| 8822 | + } else if (n == 0) { | |
| 8823 | + return ((u8*)(((void*)0))); | |
| 8824 | + } | |
| 8825 | + return builtin___v_malloc(n); | |
| 8826 | +} | |
| 8827 | +inline VV_LOC u64 builtin____at_least_one(u64 how_many) { | |
| 8828 | + if (how_many == 0) { | |
| 8829 | + return 1; | |
| 8830 | + } | |
| 8831 | + return how_many; | |
| 8832 | +} | |
| 8833 | +u8* builtin__malloc_uncollectable(isize n) { | |
| 8834 | + if (n < 0) { | |
| 8835 | + builtin___memory_panic(_S("malloc_uncollectable"), n); | |
| 8836 | + VUNREACHABLE(); | |
| 8837 | + } | |
| 8838 | + u8* res = ((u8*)(((void*)0))); | |
| 8839 | + #if 0 | |
| 8840 | + { | |
| 8841 | + } | |
| 8842 | + #elif defined(CUSTOM_DEFINE_vgc) | |
| 8843 | + { | |
| 8844 | + } | |
| 8845 | + #elif defined(CUSTOM_DEFINE_gcboehm) | |
| 8846 | + { | |
| 8847 | + } | |
| 8848 | + #elif 0 | |
| 8849 | + { | |
| 8850 | + } | |
| 8851 | + #else | |
| 8852 | + { | |
| 8853 | + #if 0 | |
| 8854 | + { | |
| 8855 | + } | |
| 8856 | + #else | |
| 8857 | + { | |
| 8858 | + res = malloc(n); | |
| 8859 | + } | |
| 8860 | + #endif | |
| 8861 | + } | |
| 8862 | + #endif | |
| 8863 | + if (res == 0) { | |
| 8864 | + builtin___memory_panic(_S("malloc_uncollectable"), n); | |
| 8865 | + VUNREACHABLE(); | |
| 8866 | + } | |
| 8867 | + ; | |
| 8868 | + return res; | |
| 8869 | +} | |
| 8870 | +u8* builtin__v_realloc(u8* b, isize n) { | |
| 8871 | + u8* new_ptr = ((u8*)(((void*)0))); | |
| 8872 | + #if 0 | |
| 8873 | + { | |
| 8874 | + } | |
| 8875 | + #elif defined(CUSTOM_DEFINE_vgc) | |
| 8876 | + { | |
| 8877 | + } | |
| 8878 | + #elif defined(CUSTOM_DEFINE_gcboehm) | |
| 8879 | + { | |
| 8880 | + } | |
| 8881 | + #else | |
| 8882 | + { | |
| 8883 | + #if 0 | |
| 8884 | + { | |
| 8885 | + } | |
| 8886 | + #else | |
| 8887 | + { | |
| 8888 | + new_ptr = realloc(b, n); | |
| 8889 | + } | |
| 8890 | + #endif | |
| 8891 | + } | |
| 8892 | + #endif | |
| 8893 | + if (new_ptr == 0) { | |
| 8894 | + builtin___memory_panic(_S("v_realloc"), n); | |
| 8895 | + VUNREACHABLE(); | |
| 8896 | + } | |
| 8897 | + if (b != ((void*)0)) { | |
| 8898 | + ; | |
| 8899 | + } | |
| 8900 | + ; | |
| 8901 | + return new_ptr; | |
| 8902 | +} | |
| 8903 | +u8* builtin__realloc_data(u8* old_data, int old_size, int new_size) { | |
| 8904 | + u8* nptr = ((u8*)(((void*)0))); | |
| 8905 | + #if defined(CUSTOM_DEFINE_vgc) | |
| 8906 | + { | |
| 8907 | + } | |
| 8908 | + #elif defined(CUSTOM_DEFINE_gcboehm) | |
| 8909 | + { | |
| 8910 | + } | |
| 8911 | + #else | |
| 8912 | + { | |
| 8913 | + #if 0 | |
| 8914 | + { | |
| 8915 | + } | |
| 8916 | + #else | |
| 8917 | + { | |
| 8918 | + nptr = realloc(old_data, new_size); | |
| 8919 | + } | |
| 8920 | + #endif | |
| 8921 | + } | |
| 8922 | + #endif | |
| 8923 | + if (nptr == 0) { | |
| 8924 | + builtin___memory_panic(_S("realloc_data"), ((isize)(new_size))); | |
| 8925 | + VUNREACHABLE(); | |
| 8926 | + } | |
| 8927 | + if (old_data != ((void*)0)) { | |
| 8928 | + ; | |
| 8929 | + } | |
| 8930 | + ; | |
| 8931 | + return nptr; | |
| 8932 | +} | |
| 8933 | +u8* builtin__vcalloc(isize n) { | |
| 8934 | + if (n < 0) { | |
| 8935 | + builtin___memory_panic(_S("vcalloc"), n); | |
| 8936 | + VUNREACHABLE(); | |
| 8937 | + } else if (n == 0) { | |
| 8938 | + return ((u8*)(((void*)0))); | |
| 8939 | + } | |
| 8940 | + #if 0 | |
| 8941 | + { | |
| 8942 | + } | |
| 8943 | + #elif defined(CUSTOM_DEFINE_vgc) | |
| 8944 | + { | |
| 8945 | + } | |
| 8946 | + #elif defined(CUSTOM_DEFINE_gcboehm) | |
| 8947 | + { | |
| 8948 | + } | |
| 8949 | + #else | |
| 8950 | + { | |
| 8951 | + #if 0 | |
| 8952 | + { | |
| 8953 | + } | |
| 8954 | + #else | |
| 8955 | + { | |
| 8956 | + voidptr r = calloc(1, n); | |
| 8957 | + ; | |
| 8958 | + return r; | |
| 8959 | + } | |
| 8960 | + #endif | |
| 8961 | + } | |
| 8962 | + #endif | |
| 8963 | + return ((u8*)(((void*)0))); | |
| 8964 | +} | |
| 8965 | +u8* builtin__vcalloc_noscan(isize n) { | |
| 8966 | + #if 0 | |
| 8967 | + { | |
| 8968 | + } | |
| 8969 | + #elif defined(CUSTOM_DEFINE_vgc) | |
| 8970 | + { | |
| 8971 | + } | |
| 8972 | + #elif defined(CUSTOM_DEFINE_gcboehm) | |
| 8973 | + { | |
| 8974 | + } | |
| 8975 | + #else | |
| 8976 | + { | |
| 8977 | + return builtin__vcalloc(n); | |
| 8978 | + } | |
| 8979 | + #endif | |
| 8980 | + return ((u8*)(((void*)0))); | |
| 8981 | +} | |
| 8982 | +void builtin___v_free(voidptr ptr) { | |
| 8983 | + if (ptr == 0) { | |
| 8984 | + return; | |
| 8985 | + } | |
| 8986 | + IError* none_err = ((IError*)(&_const_none__)); | |
| 8987 | + if (ptr == none_err->_object) { | |
| 8988 | + return; | |
| 8989 | + } | |
| 8990 | + IError* sentinel_err = ((IError*)(&_const_error_sentinel)); | |
| 8991 | + if (ptr == sentinel_err->_object) { | |
| 8992 | + return; | |
| 8993 | + } | |
| 8994 | + #if 0 | |
| 8995 | + { | |
| 8996 | + } | |
| 8997 | + #elif defined(CUSTOM_DEFINE_vgc) | |
| 8998 | + { | |
| 8999 | + } | |
| 9000 | + #elif defined(CUSTOM_DEFINE_gcboehm) | |
| 9001 | + { | |
| 9002 | + } | |
| 9003 | + #else | |
| 9004 | + { | |
| 9005 | + ; | |
| 9006 | + #if 0 | |
| 9007 | + { | |
| 9008 | + } | |
| 9009 | + #else | |
| 9010 | + { | |
| 9011 | + free(ptr); | |
| 9012 | + } | |
| 9013 | + #endif | |
| 9014 | + } | |
| 9015 | + #endif | |
| 9016 | +} | |
| 9017 | +voidptr builtin__memdup(voidptr src, isize sz) { | |
| 9018 | + if (sz == 0) { | |
| 9019 | + return builtin__vcalloc(1); | |
| 9020 | + } | |
| 9021 | + { // Unsafe block | |
| 9022 | + u8* mem = builtin___v_malloc(sz); | |
| 9023 | + return memcpy(mem, src, sz); | |
| 9024 | + } | |
| 9025 | + return 0; | |
| 9026 | +} | |
| 9027 | +voidptr builtin__memdup_noscan(voidptr src, isize sz) { | |
| 9028 | + if (sz == 0) { | |
| 9029 | + return builtin__vcalloc_noscan(1); | |
| 9030 | + } | |
| 9031 | + { // Unsafe block | |
| 9032 | + u8* mem = builtin__malloc_noscan(sz); | |
| 9033 | + return memcpy(mem, src, sz); | |
| 9034 | + } | |
| 9035 | + return 0; | |
| 9036 | +} | |
| 9037 | +voidptr builtin__memdup_uncollectable(voidptr src, isize sz) { | |
| 9038 | + if (sz == 0) { | |
| 9039 | + return builtin__vcalloc(1); | |
| 9040 | + } | |
| 9041 | + { // Unsafe block | |
| 9042 | + u8* mem = builtin__malloc_uncollectable(sz); | |
| 9043 | + return memcpy(mem, src, sz); | |
| 9044 | + } | |
| 9045 | + return 0; | |
| 9046 | +} | |
| 9047 | +voidptr builtin__memdup_align(voidptr src, isize sz, isize align) { | |
| 9048 | + if (sz == 0) { | |
| 9049 | + return builtin__vcalloc(1); | |
| 9050 | + } | |
| 9051 | + isize n = sz; | |
| 9052 | + if (n < 0) { | |
| 9053 | + builtin___memory_panic(_S("memdup_align"), n); | |
| 9054 | + VUNREACHABLE(); | |
| 9055 | + } | |
| 9056 | + u8* res = ((u8*)(((void*)0))); | |
| 9057 | + #if 0 | |
| 9058 | + { | |
| 9059 | + } | |
| 9060 | + #elif defined(CUSTOM_DEFINE_gcboehm) | |
| 9061 | + { | |
| 9062 | + } | |
| 9063 | + #elif 0 | |
| 9064 | + { | |
| 9065 | + } | |
| 9066 | + #else | |
| 9067 | + { | |
| 9068 | + #if 0 | |
| 9069 | + { | |
| 9070 | + } | |
| 9071 | + #else | |
| 9072 | + { | |
| 9073 | + res = aligned_alloc(align, n); | |
| 9074 | + } | |
| 9075 | + #endif | |
| 9076 | + } | |
| 9077 | + #endif | |
| 9078 | + if (res == 0) { | |
| 9079 | + builtin___memory_panic(_S("memdup_align"), n); | |
| 9080 | + VUNREACHABLE(); | |
| 9081 | + } | |
| 9082 | + ; | |
| 9083 | + return memcpy(res, src, sz); | |
| 9084 | +} | |
| 9085 | +GCHeapUsage builtin__gc_heap_usage(void) { | |
| 9086 | + #if defined(CUSTOM_DEFINE_vgc) | |
| 9087 | + { | |
| 9088 | + } | |
| 9089 | + #elif defined(CUSTOM_DEFINE_gcboehm) | |
| 9090 | + { | |
| 9091 | + } | |
| 9092 | + #else | |
| 9093 | + { | |
| 9094 | + return ((GCHeapUsage){.heap_size = 0,.free_bytes = 0,.total_bytes = 0,.unmapped_bytes = 0,.bytes_since_gc = 0,}); | |
| 9095 | + } | |
| 9096 | + #endif | |
| 9097 | + return (GCHeapUsage){0}; | |
| 9098 | +} | |
| 9099 | +usize builtin__gc_memory_use(void) { | |
| 9100 | + #if defined(CUSTOM_DEFINE_vgc) | |
| 9101 | + { | |
| 9102 | + } | |
| 9103 | + #elif defined(CUSTOM_DEFINE_gcboehm) | |
| 9104 | + { | |
| 9105 | + } | |
| 9106 | + #else | |
| 9107 | + { | |
| 9108 | + return 0; | |
| 9109 | + } | |
| 9110 | + #endif | |
| 9111 | + return 0; | |
| 9112 | +} | |
| 9113 | +inline VV_LOC int builtin__array_data_header_size(void) { | |
| 9114 | + return ((int)(sizeof(voidptr))); | |
| 9115 | +} | |
| 9116 | +inline VV_LOC u64 builtin__array_data_allocation_size(u64 total_size) { | |
| 9117 | + return ((u64)(builtin__array_data_header_size())) + builtin____at_least_one(total_size); | |
| 9118 | +} | |
| 9119 | +inline VV_LOC voidptr builtin__alloc_array_data(u64 total_size) { | |
| 9120 | + u8* raw = builtin__vcalloc(builtin__array_data_allocation_size(total_size)); | |
| 9121 | + return ((u8*)(raw)) + builtin__array_data_header_size(); | |
| 9122 | +} | |
| 9123 | +inline VV_LOC voidptr builtin__alloc_array_data_uninit(u64 total_size) { | |
| 9124 | + u8* raw = builtin__malloc_uninit(builtin__array_data_allocation_size(total_size)); | |
| 9125 | + { // Unsafe block | |
| 9126 | + (((ArrayDataHeader*)(raw)))->has_slices = false; | |
| 9127 | + return ((u8*)(raw)) + builtin__array_data_header_size(); | |
| 9128 | + } | |
| 9129 | + return 0; | |
| 9130 | +} | |
| 9131 | +inline VV_LOC bool builtin__array_uses_noscan_data(array a) { | |
| 9132 | + return builtin__ArrayFlags_has(&a.flags, ArrayFlags__noscan_data); | |
| 9133 | +} | |
| 9134 | +inline VV_LOC voidptr builtin__array_alloc_array_data_like(array a, u64 total_size) { | |
| 9135 | + return builtin__alloc_array_data(total_size); | |
| 9136 | +} | |
| 9137 | +inline VV_LOC voidptr builtin__array_alloc_array_data_like_uninit(array a, u64 total_size) { | |
| 9138 | + return builtin__alloc_array_data_uninit(total_size); | |
| 9139 | +} | |
| 9140 | +inline VV_LOC ArrayDataHeader* builtin__array_data_header(array a) { | |
| 9141 | + if (!builtin__ArrayFlags_has(&a.flags, ArrayFlags__managed) || a.data == ((void*)0)) { | |
| 9142 | + return ((void*)0); | |
| 9143 | + } | |
| 9144 | + u8* base_data = ((u8*)(a.data)) - ((u64)(a.offset)); | |
| 9145 | + return ((ArrayDataHeader*)(base_data - builtin__array_data_header_size())); | |
| 9146 | +} | |
| 9147 | +inline VV_LOC bool builtin__array_buffer_has_slices(array a) { | |
| 9148 | + if (!builtin__ArrayFlags_has(&a.flags, ArrayFlags__managed) || a.data == ((void*)0)) { | |
| 9149 | + return false; | |
| 9150 | + } | |
| 9151 | + ArrayDataHeader* header = builtin__array_data_header(a); | |
| 9152 | + if (header == ((void*)0)) { | |
| 9153 | + return false; | |
| 9154 | + } | |
| 9155 | + return header->has_slices; | |
| 9156 | +} | |
| 9157 | +inline VV_LOC void builtin__array_mark_buffer_has_slices(array* a) { | |
| 9158 | + if (!builtin__ArrayFlags_has(&a->flags, ArrayFlags__managed) || a->data == ((void*)0)) { | |
| 9159 | + return; | |
| 9160 | + } | |
| 9161 | + { // Unsafe block | |
| 9162 | + u8* base_data = ((u8*)(a->data)) - ((u64)(a->offset)); | |
| 9163 | + ArrayDataHeader* header = ((ArrayDataHeader*)(base_data - builtin__array_data_header_size())); | |
| 9164 | + if (!header->has_slices) { | |
| 9165 | + header->has_slices = true; | |
| 9166 | + } | |
| 9167 | + } | |
| 9168 | +} | |
| 9169 | +inline VV_LOC void builtin__array_set_managed_flags(array* a, bool is_slice) { | |
| 9170 | + { // Unsafe block | |
| 9171 | + builtin__ArrayFlags_set(&a->flags, ArrayFlags__managed); | |
| 9172 | + if (is_slice) { | |
| 9173 | + builtin__ArrayFlags_set(&a->flags, ArrayFlags__is_slice); | |
| 9174 | + } else { | |
| 9175 | + builtin__ArrayFlags_clear(&a->flags, ArrayFlags__is_slice); | |
| 9176 | + } | |
| 9177 | + } | |
| 9178 | +} | |
| 9179 | +inline VV_LOC void builtin__array_clone_shallow_to_cap(array* a, int new_cap) { | |
| 9180 | + if (new_cap <= 0) { | |
| 9181 | + builtin__ArrayFlags_clear(&a->flags, ((ArrayFlags__managed | ArrayFlags__noscan_data) | ArrayFlags__is_slice)); | |
| 9182 | + a->data = ((void*)0); | |
| 9183 | + a->offset = 0; | |
| 9184 | + a->cap = 0; | |
| 9185 | + return; | |
| 9186 | + } | |
| 9187 | + bool use_noscan_data = builtin__array_uses_noscan_data(*a); | |
| 9188 | + u64 total_size = ((u64)(new_cap)) * ((u64)(a->element_size)); | |
| 9189 | + voidptr new_data = builtin__array_alloc_array_data_like_uninit(*a, total_size); | |
| 9190 | + u64 copy_size = ((u64)(a->len)) * ((u64)(a->element_size)); | |
| 9191 | + if (a->data != ((void*)0) && copy_size > 0) { | |
| 9192 | + builtin__vmemcpy(new_data, a->data, copy_size); | |
| 9193 | + } | |
| 9194 | + a->data = new_data; | |
| 9195 | + a->offset = 0; | |
| 9196 | + a->cap = new_cap; | |
| 9197 | + { // Unsafe block | |
| 9198 | + if (use_noscan_data) { | |
| 9199 | + builtin__ArrayFlags_set(&a->flags, ArrayFlags__noscan_data); | |
| 9200 | + } else { | |
| 9201 | + builtin__ArrayFlags_clear(&a->flags, ArrayFlags__noscan_data); | |
| 9202 | + } | |
| 9203 | + } | |
| 9204 | + builtin__array_set_managed_flags(a, false); | |
| 9205 | +} | |
| 9206 | +inline VV_LOC int builtin__v_ni_index(int i, int len) { | |
| 9207 | + return (i < 0 ? (len + i) : (i)); | |
| 9208 | +} | |
| 9209 | +VV_LOC array builtin____new_array(int mylen, int cap, int elm_size) { | |
| 9210 | + builtin__panic_on_negative_len(mylen); | |
| 9211 | + builtin__panic_on_negative_cap(cap); | |
| 9212 | + int cap_ = (cap < mylen ? (mylen) : (cap)); | |
| 9213 | + u64 total_size = ((u64)(cap_)) * ((u64)(elm_size)); | |
| 9214 | + voidptr data = ((void*)0); | |
| 9215 | + if (cap_ > 0 && mylen == 0) { | |
| 9216 | + data = builtin__alloc_array_data_uninit(total_size); | |
| 9217 | + } else if (cap_ > 0) { | |
| 9218 | + data = builtin__alloc_array_data(total_size); | |
| 9219 | + } | |
| 9220 | + array _t1 = ((array){.data = (voidptr)data,.offset = 0,.len = mylen,.cap = cap_,.flags = ArrayFlags__managed,.element_size = elm_size,}); | |
| 9221 | + array arr = _t1; | |
| 9222 | + return arr; | |
| 9223 | +} | |
| 9224 | +VV_LOC array builtin____new_array_with_default(int mylen, int cap, int elm_size, voidptr val) { | |
| 9225 | + builtin__panic_on_negative_len(mylen); | |
| 9226 | + builtin__panic_on_negative_cap(cap); | |
| 9227 | + int cap_ = (cap < mylen ? (mylen) : (cap)); | |
| 9228 | + array _t1 = ((array){.data = 0,.offset = 0,.len = mylen,.cap = cap_,.flags = ArrayFlags__managed,.element_size = elm_size,}); | |
| 9229 | + array arr = _t1; | |
| 9230 | + u64 total_size = ((u64)(cap_)) * ((u64)(elm_size)); | |
| 9231 | + if (cap_ > 0 && mylen == 0) { | |
| 9232 | + arr.data = builtin__alloc_array_data_uninit(total_size); | |
| 9233 | + } else if (cap_ > 0) { | |
| 9234 | + arr.data = builtin__alloc_array_data(total_size); | |
| 9235 | + } | |
| 9236 | + if (val != 0) { | |
| 9237 | + u8* eptr = ((u8*)(arr.data)); | |
| 9238 | + { // Unsafe block | |
| 9239 | + if (eptr != ((void*)0)) { | |
| 9240 | + if (arr.element_size == 1) { | |
| 9241 | + u8 byte_value = *(((u8*)(val))); | |
| 9242 | + for (int i = 0; i < arr.len; ++i) { | |
| 9243 | + eptr[i] = byte_value; | |
| 9244 | + } | |
| 9245 | + } else { | |
| 9246 | + for (int _t2 = 0; _t2 < arr.len; ++_t2) { | |
| 9247 | + builtin__vmemcpy(eptr, val, arr.element_size); | |
| 9248 | + eptr += arr.element_size; | |
| 9249 | + } | |
| 9250 | + } | |
| 9251 | + } | |
| 9252 | + } | |
| 9253 | + } | |
| 9254 | + return arr; | |
| 9255 | +} | |
| 9256 | +VV_LOC array builtin____new_array_with_multi_default(int mylen, int cap, int elm_size, voidptr val) { | |
| 9257 | + builtin__panic_on_negative_len(mylen); | |
| 9258 | + builtin__panic_on_negative_cap(cap); | |
| 9259 | + int cap_ = (cap < mylen ? (mylen) : (cap)); | |
| 9260 | + array _t1 = ((array){.data = 0,.offset = 0,.len = mylen,.cap = cap_,.flags = ArrayFlags__managed,.element_size = elm_size,}); | |
| 9261 | + array arr = _t1; | |
| 9262 | + u64 total_size = ((u64)(cap_)) * ((u64)(elm_size)); | |
| 9263 | + if (cap_ > 0) { | |
| 9264 | + arr.data = builtin__alloc_array_data(total_size); | |
| 9265 | + } | |
| 9266 | + if (val != 0) { | |
| 9267 | + u8* eptr = ((u8*)(arr.data)); | |
| 9268 | + { // Unsafe block | |
| 9269 | + if (eptr != ((void*)0)) { | |
| 9270 | + for (int i = 0; i < arr.len; ++i) { | |
| 9271 | + builtin__vmemcpy(eptr, ((charptr)(val)) + (int)(i * arr.element_size), arr.element_size); | |
| 9272 | + eptr += arr.element_size; | |
| 9273 | + } | |
| 9274 | + } | |
| 9275 | + } | |
| 9276 | + } | |
| 9277 | + return arr; | |
| 9278 | +} | |
| 9279 | +VV_LOC array builtin____new_array_with_array_default(int mylen, int cap, int elm_size, array val, int depth) { | |
| 9280 | + builtin__panic_on_negative_len(mylen); | |
| 9281 | + builtin__panic_on_negative_cap(cap); | |
| 9282 | + int cap_ = (cap < mylen ? (mylen) : (cap)); | |
| 9283 | + array _t1 = ((array){.data = 0,.offset = 0,.len = mylen,.cap = cap_,.flags = ArrayFlags__managed,.element_size = elm_size,}); | |
| 9284 | + array arr = _t1; | |
| 9285 | + if (cap_ > 0) { | |
| 9286 | + arr.data = builtin__alloc_array_data(((u64)(cap_)) * ((u64)(elm_size))); | |
| 9287 | + } | |
| 9288 | + u8* eptr = ((u8*)(arr.data)); | |
| 9289 | + { // Unsafe block | |
| 9290 | + if (eptr != ((void*)0)) { | |
| 9291 | + for (int _t2 = 0; _t2 < arr.len; ++_t2) { | |
| 9292 | + array val_clone = builtin__array_clone_to_depth(&val, depth); | |
| 9293 | + builtin__vmemcpy(eptr, &val_clone, arr.element_size); | |
| 9294 | + eptr += arr.element_size; | |
| 9295 | + } | |
| 9296 | + } | |
| 9297 | + } | |
| 9298 | + return arr; | |
| 9299 | +} | |
| 9300 | +VV_LOC array builtin__new_array_from_c_array(int len, int cap, int elm_size, voidptr c_array) { | |
| 9301 | + builtin__panic_on_negative_len(len); | |
| 9302 | + builtin__panic_on_negative_cap(cap); | |
| 9303 | + int cap_ = cap; | |
| 9304 | + if (cap < len) { | |
| 9305 | + cap_ = len; | |
| 9306 | + } | |
| 9307 | + array _t1 = ((array){.data = builtin__alloc_array_data(((u64)(cap_)) * ((u64)(elm_size))),.offset = 0,.len = len,.cap = cap_,.flags = ArrayFlags__managed,.element_size = elm_size,}); | |
| 9308 | + array arr = _t1; | |
| 9309 | + builtin__vmemcpy(arr.data, c_array, ((u64)(len)) * ((u64)(elm_size))); | |
| 9310 | + return arr; | |
| 9311 | +} | |
| 9312 | +void builtin__array_ensure_cap(array* a, int required) { | |
| 9313 | + if (required <= a->cap) { | |
| 9314 | + return; | |
| 9315 | + } | |
| 9316 | + if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__nogrow)) { | |
| 9317 | + builtin__panic_n(_S("array.ensure_cap: array with the flag `.nogrow` cannot grow in size, array required new size:"), required); | |
| 9318 | + VUNREACHABLE(); | |
| 9319 | + } | |
| 9320 | + i64 cap = (a->cap > 0 ? (((i64)(a->cap))) : (((i64)(2)))); | |
| 9321 | + for (;;) { | |
| 9322 | + if (!(required > cap)) break; | |
| 9323 | + cap *= 2; | |
| 9324 | + } | |
| 9325 | + if (cap > _const_max_int) { | |
| 9326 | + if (a->cap < _const_max_int) { | |
| 9327 | + cap = _const_max_int; | |
| 9328 | + } else { | |
| 9329 | + builtin__panic_n(_S("array.ensure_cap: array needs to grow to cap (which is > 2^31):"), cap); | |
| 9330 | + VUNREACHABLE(); | |
| 9331 | + } | |
| 9332 | + } | |
| 9333 | + u64 new_size = ((u64)(cap)) * ((u64)(a->element_size)); | |
| 9334 | + bool use_noscan_data = builtin__array_uses_noscan_data(*a); | |
| 9335 | + voidptr new_data = builtin__array_alloc_array_data_like_uninit(*a, new_size); | |
| 9336 | + if (a->data != ((void*)0)) { | |
| 9337 | + builtin__vmemcpy(new_data, a->data, ((u64)(a->len)) * ((u64)(a->element_size))); | |
| 9338 | + if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__noslices) && !builtin__ArrayFlags_has(&a->flags, ArrayFlags__is_slice) && !builtin__array_buffer_has_slices(*a)) { | |
| 9339 | + { // Unsafe block | |
| 9340 | + if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__managed)) { | |
| 9341 | + builtin___v_free(((u8*)(a->data)) - ((u64)(builtin__array_data_header_size()))); | |
| 9342 | + } else { | |
| 9343 | + builtin___v_free(a->data); | |
| 9344 | + } | |
| 9345 | + } | |
| 9346 | + } | |
| 9347 | + } | |
| 9348 | + a->data = new_data; | |
| 9349 | + a->offset = 0; | |
| 9350 | + a->cap = ((int)(cap)); | |
| 9351 | + { // Unsafe block | |
| 9352 | + if (use_noscan_data) { | |
| 9353 | + builtin__ArrayFlags_set(&a->flags, ArrayFlags__noscan_data); | |
| 9354 | + } else { | |
| 9355 | + builtin__ArrayFlags_clear(&a->flags, ArrayFlags__noscan_data); | |
| 9356 | + } | |
| 9357 | + } | |
| 9358 | + builtin__array_set_managed_flags(a, false); | |
| 9359 | +} | |
| 9360 | +array builtin__array_repeat(array a, int count) { | |
| 9361 | + return builtin__array_repeat_to_depth(a, count, 0); | |
| 9362 | +} | |
| 9363 | +array builtin__array_repeat_to_depth(array a, int count, int depth) { | |
| 9364 | + if (count < 0) { | |
| 9365 | + builtin__panic_n(_S("array.repeat: count is negative:"), count); | |
| 9366 | + VUNREACHABLE(); | |
| 9367 | + } | |
| 9368 | + u64 size = ((u64)(count)) * ((u64)(a.len)) * ((u64)(a.element_size)); | |
| 9369 | + if (size == 0) { | |
| 9370 | + size = ((u64)(a.element_size)); | |
| 9371 | + } | |
| 9372 | + bool use_noscan_data = depth == 0 && builtin__array_uses_noscan_data(a); | |
| 9373 | + voidptr data = ((void*)0); | |
| 9374 | + if (use_noscan_data) { | |
| 9375 | + data = builtin__array_alloc_array_data_like(a, size); | |
| 9376 | + } else { | |
| 9377 | + data = builtin__alloc_array_data(size); | |
| 9378 | + } | |
| 9379 | + array _t1 = ((array){.data = (voidptr)data,.offset = 0,.len = count * a.len,.cap = count * a.len,.flags = (use_noscan_data ? ((ArrayFlags__managed | ArrayFlags__noscan_data)) : (ArrayFlags__managed)),.element_size = a.element_size,}); | |
| 9380 | + array arr = _t1; | |
| 9381 | + if (a.len > 0) { | |
| 9382 | + u64 a_total_size = ((u64)(a.len)) * ((u64)(a.element_size)); | |
| 9383 | + u64 arr_step_size = ((u64)(a.len)) * ((u64)(arr.element_size)); | |
| 9384 | + u8* eptr = ((u8*)(arr.data)); | |
| 9385 | + { // Unsafe block | |
| 9386 | + if (eptr != ((void*)0)) { | |
| 9387 | + for (int _t2 = 0; _t2 < count; ++_t2) { | |
| 9388 | + if (depth > 0) { | |
| 9389 | + array ary_clone = builtin__array_clone_to_depth(&a, depth); | |
| 9390 | + builtin__vmemcpy(eptr, ary_clone.data, a_total_size); | |
| 9391 | + } else { | |
| 9392 | + builtin__vmemcpy(eptr, a.data, a_total_size); | |
| 9393 | + } | |
| 9394 | + eptr += arr_step_size; | |
| 9395 | + } | |
| 9396 | + } | |
| 9397 | + } | |
| 9398 | + } | |
| 9399 | + return arr; | |
| 9400 | +} | |
| 9401 | +inline VV_LOC bool builtin__array_needs_unique_shift(array a, int required) { | |
| 9402 | + return required <= a.cap && (builtin__ArrayFlags_has(&a.flags, ArrayFlags__is_slice) || builtin__array_buffer_has_slices(a)); | |
| 9403 | +} | |
| 9404 | +inline VV_LOC bool builtin__array_needs_unique_append(array a, int required) { | |
| 9405 | + return required <= a.cap && builtin__ArrayFlags_has(&a.flags, ArrayFlags__is_slice); | |
| 9406 | +} | |
| 9407 | +inline VV_LOC bool builtin__array_needs_unique_shrink(array a) { | |
| 9408 | + return builtin__ArrayFlags_has(&a.flags, ArrayFlags__is_slice) || builtin__array_buffer_has_slices(a); | |
| 9409 | +} | |
| 9410 | +void builtin__array_insert(array* a, int i, voidptr val) { | |
| 9411 | + if (i < 0 || i > a->len) { | |
| 9412 | + builtin__panic_n2(_S("array.insert: index out of range (i,a.len):"), i, a->len); | |
| 9413 | + VUNREACHABLE(); | |
| 9414 | + } | |
| 9415 | + if (a->len == _const_max_int) { | |
| 9416 | + builtin___v_panic(_S("array.insert: a.len reached max_int")); | |
| 9417 | + VUNREACHABLE(); | |
| 9418 | + } | |
| 9419 | + int required = a->len + 1; | |
| 9420 | + if (builtin__array_needs_unique_shift(*a, required)) { | |
| 9421 | + builtin__array_clone_shallow_to_cap(a, a->cap); | |
| 9422 | + } else if (required > a->cap) { | |
| 9423 | + builtin__array_ensure_cap(a, required); | |
| 9424 | + } | |
| 9425 | + { // Unsafe block | |
| 9426 | + builtin__vmemmove(builtin__array_get_unsafe(*a, i + 1), builtin__array_get_unsafe(*a, i), ((u64)((a->len - i))) * ((u64)(a->element_size))); | |
| 9427 | + builtin__array_set_unsafe(a, i, val); | |
| 9428 | + } | |
| 9429 | + a->len++; | |
| 9430 | +} | |
| 9431 | +void builtin__array_prepend(array* a, voidptr val) { | |
| 9432 | + builtin__array_insert(a, 0, val); | |
| 9433 | +} | |
| 9434 | +void builtin__array_delete(array* a, int i) { | |
| 9435 | + if (i < 0 || i >= a->len) { | |
| 9436 | + builtin__panic_n2(_S("array.delete: index out of range (i,a.len):"), i, a->len); | |
| 9437 | + VUNREACHABLE(); | |
| 9438 | + } | |
| 9439 | + if (i == a->len - 1 && !builtin__array_needs_unique_shrink(*a)) { | |
| 9440 | + a->len--; | |
| 9441 | + builtin__vmemset(((u8*)(a->data)) + ((u64)(a->len)) * ((u64)(a->element_size)), 0, ((u64)(a->element_size))); | |
| 9442 | + return; | |
| 9443 | + } | |
| 9444 | + builtin__array_delete_many(a, i, 1); | |
| 9445 | +} | |
| 9446 | +void builtin__array_delete_many(array* a, int i, int size) { | |
| 9447 | + if (i < 0 || ((i64)(i)) + ((i64)(size)) > ((i64)(a->len))) { | |
| 9448 | + if (size > 1) { | |
| 9449 | + builtin__panic_n3(_S("array.delete: index out of range (i,i+size,a.len):"), i, i + size, a->len); | |
| 9450 | + VUNREACHABLE(); | |
| 9451 | + } else { | |
| 9452 | + builtin__panic_n2(_S("array.delete: index out of range (i,a.len):"), i, a->len); | |
| 9453 | + VUNREACHABLE(); | |
| 9454 | + } | |
| 9455 | + } | |
| 9456 | + if (size == 0) { | |
| 9457 | + if (builtin__array_needs_unique_shrink(*a)) { | |
| 9458 | + builtin__array_clone_shallow_to_cap(a, a->len); | |
| 9459 | + } | |
| 9460 | + return; | |
| 9461 | + } | |
| 9462 | + if (!builtin__array_needs_unique_shrink(*a)) { | |
| 9463 | + int new_len = a->len - size; | |
| 9464 | + { // Unsafe block | |
| 9465 | + builtin__vmemmove(((u8*)(a->data)) + ((u64)(i)) * ((u64)(a->element_size)), ((u8*)(a->data)) + ((u64)(i + size)) * ((u64)(a->element_size)), ((u64)(a->len - i - size)) * ((u64)(a->element_size))); | |
| 9466 | + builtin__vmemset(((u8*)(a->data)) + ((u64)(new_len)) * ((u64)(a->element_size)), 0, ((u64)(size)) * ((u64)(a->element_size))); | |
| 9467 | + } | |
| 9468 | + a->len = new_len; | |
| 9469 | + return; | |
| 9470 | + } | |
| 9471 | + voidptr old_data = a->data; | |
| 9472 | + int new_size = a->len - size; | |
| 9473 | + if (new_size == 0) { | |
| 9474 | + builtin__ArrayFlags_clear(&a->flags, ((ArrayFlags__managed | ArrayFlags__noscan_data) | ArrayFlags__is_slice)); | |
| 9475 | + a->data = ((void*)0); | |
| 9476 | + a->offset = 0; | |
| 9477 | + a->len = 0; | |
| 9478 | + a->cap = 0; | |
| 9479 | + return; | |
| 9480 | + } | |
| 9481 | + int new_cap = new_size; | |
| 9482 | + bool use_noscan_data = builtin__array_uses_noscan_data(*a); | |
| 9483 | + a->data = builtin__array_alloc_array_data_like(*a, ((u64)(new_cap)) * ((u64)(a->element_size))); | |
| 9484 | + builtin__vmemcpy(a->data, old_data, ((u64)(i)) * ((u64)(a->element_size))); | |
| 9485 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(i)) * ((u64)(a->element_size)), ((u8*)(old_data)) + ((u64)(i + size)) * ((u64)(a->element_size)), ((u64)(a->len - i - size)) * ((u64)(a->element_size))); | |
| 9486 | + if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__noslices) && !builtin__ArrayFlags_has(&a->flags, ArrayFlags__managed)) { | |
| 9487 | + builtin___v_free(old_data); | |
| 9488 | + } | |
| 9489 | + a->len = new_size; | |
| 9490 | + a->cap = new_cap; | |
| 9491 | + a->offset = 0; | |
| 9492 | + { // Unsafe block | |
| 9493 | + if (use_noscan_data) { | |
| 9494 | + builtin__ArrayFlags_set(&a->flags, ArrayFlags__noscan_data); | |
| 9495 | + } else { | |
| 9496 | + builtin__ArrayFlags_clear(&a->flags, ArrayFlags__noscan_data); | |
| 9497 | + } | |
| 9498 | + } | |
| 9499 | + builtin__array_set_managed_flags(a, false); | |
| 9500 | +} | |
| 9501 | +void builtin__array_clear(array* a) { | |
| 9502 | + if (builtin__array_needs_unique_shrink(*a)) { | |
| 9503 | + builtin__ArrayFlags_clear(&a->flags, ((ArrayFlags__managed | ArrayFlags__noscan_data) | ArrayFlags__is_slice)); | |
| 9504 | + a->data = ((void*)0); | |
| 9505 | + a->offset = 0; | |
| 9506 | + a->cap = 0; | |
| 9507 | + } | |
| 9508 | + a->len = 0; | |
| 9509 | +} | |
| 9510 | +void builtin__array_reset(array* a) { | |
| 9511 | + builtin__vmemset(a->data, 0, a->len * a->element_size); | |
| 9512 | +} | |
| 9513 | +void builtin__array_trim(array* a, int index) { | |
| 9514 | + if (index < a->len) { | |
| 9515 | + if (index >= 0 && builtin__array_needs_unique_shrink(*a)) { | |
| 9516 | + builtin__array_delete_many(a, index, a->len - index); | |
| 9517 | + return; | |
| 9518 | + } | |
| 9519 | + a->len = index; | |
| 9520 | + } | |
| 9521 | +} | |
| 9522 | +void builtin__array_drop(array* a, int num) { | |
| 9523 | + if (num <= 0) { | |
| 9524 | + return; | |
| 9525 | + } | |
| 9526 | + int n = (num <= a->len ? (num) : (a->len)); | |
| 9527 | + u64 blen = ((u64)(n)) * ((u64)(a->element_size)); | |
| 9528 | + a->data = ((u8*)(a->data)) + blen; | |
| 9529 | + a->offset += ((int)(blen)); | |
| 9530 | + a->len -= n; | |
| 9531 | + a->cap -= n; | |
| 9532 | +} | |
| 9533 | +inline VV_LOC voidptr builtin__array_get_unsafe(array a, int i) { | |
| 9534 | + { // Unsafe block | |
| 9535 | + return ((u8*)(a.data)) + ((u64)(i)) * ((u64)(a.element_size)); | |
| 9536 | + } | |
| 9537 | + return 0; | |
| 9538 | +} | |
| 9539 | +VV_LOC voidptr builtin__array_get(array a, int i) { | |
| 9540 | + #if 1 | |
| 9541 | + { | |
| 9542 | + if (i < 0 || i >= a.len) { | |
| 9543 | + builtin__panic_n2(_S("array.get: index out of range (i,a.len):"), i, a.len); | |
| 9544 | + VUNREACHABLE(); | |
| 9545 | + } | |
| 9546 | + } | |
| 9547 | + #endif | |
| 9548 | + { // Unsafe block | |
| 9549 | + return ((u8*)(a.data)) + ((u64)(i)) * ((u64)(a.element_size)); | |
| 9550 | + } | |
| 9551 | + return 0; | |
| 9552 | +} | |
| 9553 | +VV_LOC voidptr builtin__array_get_i64(array a, i64 i) { | |
| 9554 | + #if 1 | |
| 9555 | + { | |
| 9556 | + if (i < 0 || i >= ((i64)(a.len))) { | |
| 9557 | + builtin__panic_n2(_S("array.get: index out of range (i,a.len):"), i, a.len); | |
| 9558 | + VUNREACHABLE(); | |
| 9559 | + } | |
| 9560 | + } | |
| 9561 | + #endif | |
| 9562 | + { // Unsafe block | |
| 9563 | + return ((u8*)(a.data)) + ((u64)(i)) * ((u64)(a.element_size)); | |
| 9564 | + } | |
| 9565 | + return 0; | |
| 9566 | +} | |
| 9567 | +VV_LOC voidptr builtin__array_get_u64(array a, u64 i) { | |
| 9568 | + #if 1 | |
| 9569 | + { | |
| 9570 | + if (i >= ((u64)(a.len))) { | |
| 9571 | + builtin___v_panic(builtin__string_plus_many(4, _MOV((string[4]){_S("array.get: index out of range (i,a.len): "), builtin__u64_str(i), _S(", "), builtin__impl_i64_to_string(a.len)}))); | |
| 9572 | + VUNREACHABLE(); | |
| 9573 | + } | |
| 9574 | + } | |
| 9575 | + #endif | |
| 9576 | + { // Unsafe block | |
| 9577 | + return ((u8*)(a.data)) + i * ((u64)(a.element_size)); | |
| 9578 | + } | |
| 9579 | + return 0; | |
| 9580 | +} | |
| 9581 | +VV_LOC voidptr builtin__array_get_ni(array a, int i) { | |
| 9582 | + return builtin__array_get(a, builtin__v_ni_index(i, a.len)); | |
| 9583 | +} | |
| 9584 | +VV_LOC voidptr builtin__array_get_with_check(array a, int i) { | |
| 9585 | + if (i < 0 || i >= a.len) { | |
| 9586 | + return 0; | |
| 9587 | + } | |
| 9588 | + { // Unsafe block | |
| 9589 | + return ((u8*)(a.data)) + ((u64)(i)) * ((u64)(a.element_size)); | |
| 9590 | + } | |
| 9591 | + return 0; | |
| 9592 | +} | |
| 9593 | +VV_LOC voidptr builtin__array_get_with_check_i64(array a, i64 i) { | |
| 9594 | + if (i < 0 || i >= ((i64)(a.len))) { | |
| 9595 | + return 0; | |
| 9596 | + } | |
| 9597 | + { // Unsafe block | |
| 9598 | + return ((u8*)(a.data)) + ((u64)(i)) * ((u64)(a.element_size)); | |
| 9599 | + } | |
| 9600 | + return 0; | |
| 9601 | +} | |
| 9602 | +VV_LOC voidptr builtin__array_get_with_check_u64(array a, u64 i) { | |
| 9603 | + if (i >= ((u64)(a.len))) { | |
| 9604 | + return 0; | |
| 9605 | + } | |
| 9606 | + { // Unsafe block | |
| 9607 | + return ((u8*)(a.data)) + i * ((u64)(a.element_size)); | |
| 9608 | + } | |
| 9609 | + return 0; | |
| 9610 | +} | |
| 9611 | +VV_LOC voidptr builtin__array_get_with_check_ni(array a, int i) { | |
| 9612 | + return builtin__array_get_with_check(a, builtin__v_ni_index(i, a.len)); | |
| 9613 | +} | |
| 9614 | +voidptr builtin__array_first(array a) { | |
| 9615 | + if (a.len == 0) { | |
| 9616 | + builtin___v_panic(_S("array.first: array is empty")); | |
| 9617 | + VUNREACHABLE(); | |
| 9618 | + } | |
| 9619 | + return a.data; | |
| 9620 | +} | |
| 9621 | +voidptr builtin__array_last(array a) { | |
| 9622 | + if (a.len == 0) { | |
| 9623 | + builtin___v_panic(_S("array.last: array is empty")); | |
| 9624 | + VUNREACHABLE(); | |
| 9625 | + } | |
| 9626 | + { // Unsafe block | |
| 9627 | + return ((u8*)(a.data)) + ((u64)(a.len - 1)) * ((u64)(a.element_size)); | |
| 9628 | + } | |
| 9629 | + return 0; | |
| 9630 | +} | |
| 9631 | +voidptr builtin__array_pop_left(array* a) { | |
| 9632 | + if (a->len == 0) { | |
| 9633 | + builtin___v_panic(_S("array.pop_left: array is empty")); | |
| 9634 | + VUNREACHABLE(); | |
| 9635 | + } | |
| 9636 | + voidptr first_elem = a->data; | |
| 9637 | + { // Unsafe block | |
| 9638 | + a->data = ((u8*)(a->data)) + ((u64)(a->element_size)); | |
| 9639 | + } | |
| 9640 | + a->offset += a->element_size; | |
| 9641 | + a->len--; | |
| 9642 | + a->cap--; | |
| 9643 | + return first_elem; | |
| 9644 | +} | |
| 9645 | +voidptr builtin__array_pop(array* a) { | |
| 9646 | + if (a->len == 0) { | |
| 9647 | + builtin___v_panic(_S("array.pop: array is empty")); | |
| 9648 | + VUNREACHABLE(); | |
| 9649 | + } | |
| 9650 | + int new_len = a->len - 1; | |
| 9651 | + u8* last_elem = ((u8*)(a->data)) + ((u64)(new_len)) * ((u64)(a->element_size)); | |
| 9652 | + if (builtin__array_needs_unique_shrink(*a)) { | |
| 9653 | + builtin__array_delete_many(a, new_len, 1); | |
| 9654 | + return last_elem; | |
| 9655 | + } | |
| 9656 | + a->len = new_len; | |
| 9657 | + return last_elem; | |
| 9658 | +} | |
| 9659 | +void builtin__array_delete_last(array* a) { | |
| 9660 | + if (a->len == 0) { | |
| 9661 | + builtin___v_panic(_S("array.delete_last: array is empty")); | |
| 9662 | + VUNREACHABLE(); | |
| 9663 | + } | |
| 9664 | + if (builtin__array_needs_unique_shrink(*a)) { | |
| 9665 | + builtin__array_delete_many(a, a->len - 1, 1); | |
| 9666 | + return; | |
| 9667 | + } | |
| 9668 | + a->len--; | |
| 9669 | + builtin__vmemset(((u8*)(a->data)) + ((u64)(a->len)) * ((u64)(a->element_size)), 0, ((u64)(a->element_size))); | |
| 9670 | +} | |
| 9671 | +VV_LOC array builtin__array_slice(array a, int start, int _end) { | |
| 9672 | + int end = (_end == _const_max_i64 || _end == _const_max_i32 ? (a.len) : (_end)); | |
| 9673 | + #if 1 | |
| 9674 | + { | |
| 9675 | + if (start > end) { | |
| 9676 | + builtin___v_panic(builtin__string_plus_many(4, _MOV((string[4]){_S("array.slice: invalid slice index (start>end):"), builtin__impl_i64_to_string(((i64)(start))), _S(", "), builtin__impl_i64_to_string(end)}))); | |
| 9677 | + VUNREACHABLE(); | |
| 9678 | + } | |
| 9679 | + if (end > a.len) { | |
| 9680 | + builtin___v_panic(builtin__string_plus_many(5, _MOV((string[5]){_S("array.slice: slice bounds out of range ("), builtin__impl_i64_to_string(end), _S(" >= "), builtin__impl_i64_to_string(a.len), _S(")")}))); | |
| 9681 | + VUNREACHABLE(); | |
| 9682 | + } | |
| 9683 | + if (start < 0) { | |
| 9684 | + builtin___v_panic(builtin__string__plus(_S("array.slice: slice bounds out of range (start<0):"), builtin__impl_i64_to_string(start))); | |
| 9685 | + VUNREACHABLE(); | |
| 9686 | + } | |
| 9687 | + } | |
| 9688 | + #endif | |
| 9689 | + builtin__array_mark_buffer_has_slices(&a); | |
| 9690 | + u64 offset = ((u64)(start)) * ((u64)(a.element_size)); | |
| 9691 | + u8* data = ((u8*)(a.data)) + offset; | |
| 9692 | + int l = end - start; | |
| 9693 | + ArrayFlags flags = ArrayFlags__is_slice; | |
| 9694 | + if (builtin__array_uses_noscan_data(a)) { | |
| 9695 | + builtin__ArrayFlags_set(&flags, ArrayFlags__noscan_data); | |
| 9696 | + } | |
| 9697 | + array res = ((array){ | |
| 9698 | + .data = (voidptr)data, | |
| 9699 | + .offset = a.offset + ((int)(offset)), | |
| 9700 | + .len = l, | |
| 9701 | + .cap = l, | |
| 9702 | + .flags = flags, | |
| 9703 | + .element_size = a.element_size, | |
| 9704 | + }); | |
| 9705 | + return res; | |
| 9706 | +} | |
| 9707 | +VV_LOC array builtin__array_slice_ni(array a, int _start, int _end) { | |
| 9708 | + builtin__array_mark_buffer_has_slices(&a); | |
| 9709 | + ArrayFlags flags = ArrayFlags__is_slice; | |
| 9710 | + if (builtin__array_uses_noscan_data(a)) { | |
| 9711 | + builtin__ArrayFlags_set(&flags, ArrayFlags__noscan_data); | |
| 9712 | + } | |
| 9713 | + int end = (_end == _const_max_i64 || _end == _const_max_i32 ? (a.len) : (_end)); | |
| 9714 | + int start = _start; | |
| 9715 | + if (start < 0) { | |
| 9716 | + start = a.len + start; | |
| 9717 | + if (start < 0) { | |
| 9718 | + start = 0; | |
| 9719 | + } | |
| 9720 | + } | |
| 9721 | + if (end < 0) { | |
| 9722 | + end = a.len + end; | |
| 9723 | + if (end < 0) { | |
| 9724 | + end = 0; | |
| 9725 | + } | |
| 9726 | + } | |
| 9727 | + if (end >= a.len) { | |
| 9728 | + end = a.len; | |
| 9729 | + } | |
| 9730 | + if (start >= a.len || start > end) { | |
| 9731 | + array res = ((array){ | |
| 9732 | + .data = a.data, | |
| 9733 | + .offset = 0, | |
| 9734 | + .len = 0, | |
| 9735 | + .cap = 0, | |
| 9736 | + .flags = flags, | |
| 9737 | + .element_size = a.element_size, | |
| 9738 | + }); | |
| 9739 | + return res; | |
| 9740 | + } | |
| 9741 | + u64 offset = ((u64)(start)) * ((u64)(a.element_size)); | |
| 9742 | + u8* data = ((u8*)(a.data)) + offset; | |
| 9743 | + int l = end - start; | |
| 9744 | + array res = ((array){ | |
| 9745 | + .data = (voidptr)data, | |
| 9746 | + .offset = a.offset + ((int)(offset)), | |
| 9747 | + .len = l, | |
| 9748 | + .cap = l, | |
| 9749 | + .flags = flags, | |
| 9750 | + .element_size = a.element_size, | |
| 9751 | + }); | |
| 9752 | + return res; | |
| 9753 | +} | |
| 9754 | +VV_LOC array builtin__array_clone_static_to_depth(array a, int depth) { | |
| 9755 | + return builtin__array_clone_to_depth(&a, depth); | |
| 9756 | +} | |
| 9757 | +array builtin__array_clone(array* a) { | |
| 9758 | + return builtin__array_clone_to_depth(a, 0); | |
| 9759 | +} | |
| 9760 | +array builtin__array_clone_to_depth(array* a, int depth) { | |
| 9761 | + u64 source_capacity_in_bytes = ((u64)(a->cap)) * ((u64)(a->element_size)); | |
| 9762 | + bool use_noscan_data = depth == 0 && builtin__array_uses_noscan_data(*a); | |
| 9763 | + voidptr data = ((void*)0); | |
| 9764 | + if (a->cap > 0) { | |
| 9765 | + if (use_noscan_data) { | |
| 9766 | + data = builtin__array_alloc_array_data_like(*a, source_capacity_in_bytes); | |
| 9767 | + } else { | |
| 9768 | + data = builtin__alloc_array_data(source_capacity_in_bytes); | |
| 9769 | + } | |
| 9770 | + } | |
| 9771 | + array _t1 = ((array){.data = (voidptr)data,.offset = 0,.len = a->len,.cap = a->cap,.flags = (use_noscan_data ? ((ArrayFlags__managed | ArrayFlags__noscan_data)) : (ArrayFlags__managed)),.element_size = a->element_size,}); | |
| 9772 | + array arr = _t1; | |
| 9773 | + if (depth > 0 && _us32_eq(sizeof(array),a->element_size) && a->len >= 0 && a->cap >= a->len) { | |
| 9774 | + array _t2 = ((array){.data = 0,.offset = 0,.len = 0,.cap = 0,.flags = 0,.element_size = 0,}); | |
| 9775 | + array ar = _t2; | |
| 9776 | + int asize = ((int)(sizeof(array))); | |
| 9777 | + for (int i = 0; i < a->len; ++i) { | |
| 9778 | + builtin__vmemcpy(&ar, builtin__array_get_unsafe(*a, i), asize); | |
| 9779 | + array ar_clone = builtin__array_clone_to_depth(&ar, depth - 1); | |
| 9780 | + builtin__array_set_unsafe(&arr, i, &ar_clone); | |
| 9781 | + } | |
| 9782 | + return arr; | |
| 9783 | + } else if (depth > 0 && _us32_eq(sizeof(string),a->element_size) && a->len >= 0 && a->cap >= a->len) { | |
| 9784 | + for (int i = 0; i < a->len; ++i) { | |
| 9785 | + string* str_ptr = ((string*)(builtin__array_get_unsafe(*a, i))); | |
| 9786 | + string str_clone = builtin__string_clone((*str_ptr)); | |
| 9787 | + builtin__array_set_unsafe(&arr, i, &str_clone); | |
| 9788 | + } | |
| 9789 | + return arr; | |
| 9790 | + } | |
| 9791 | + if (a->data != 0 && source_capacity_in_bytes > 0) { | |
| 9792 | + builtin__vmemcpy(arr.data, a->data, source_capacity_in_bytes); | |
| 9793 | + } | |
| 9794 | + return arr; | |
| 9795 | +} | |
| 9796 | +inline VV_LOC void builtin__array_set_unsafe(array* a, int i, voidptr val) { | |
| 9797 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(a->element_size)) * ((u64)(i)), val, a->element_size); | |
| 9798 | +} | |
| 9799 | +VV_LOC void builtin__array_set(array* a, int i, voidptr val) { | |
| 9800 | + #if 1 | |
| 9801 | + { | |
| 9802 | + if (i < 0 || i >= a->len) { | |
| 9803 | + builtin__panic_n2(_S("array.set: index out of range (i,a.len):"), i, a->len); | |
| 9804 | + VUNREACHABLE(); | |
| 9805 | + } | |
| 9806 | + } | |
| 9807 | + #endif | |
| 9808 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(a->element_size)) * ((u64)(i)), val, a->element_size); | |
| 9809 | +} | |
| 9810 | +VV_LOC void builtin__array_set_i64(array* a, i64 i, voidptr val) { | |
| 9811 | + #if 1 | |
| 9812 | + { | |
| 9813 | + if (i < 0 || i >= ((i64)(a->len))) { | |
| 9814 | + builtin__panic_n2(_S("array.set: index out of range (i,a.len):"), i, a->len); | |
| 9815 | + VUNREACHABLE(); | |
| 9816 | + } | |
| 9817 | + } | |
| 9818 | + #endif | |
| 9819 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(a->element_size)) * ((u64)(i)), val, a->element_size); | |
| 9820 | +} | |
| 9821 | +VV_LOC void builtin__array_set_u64(array* a, u64 i, voidptr val) { | |
| 9822 | + #if 1 | |
| 9823 | + { | |
| 9824 | + if (i >= ((u64)(a->len))) { | |
| 9825 | + builtin___v_panic(builtin__string_plus_many(4, _MOV((string[4]){_S("array.set: index out of range (i,a.len): "), builtin__u64_str(i), _S(", "), builtin__impl_i64_to_string(a->len)}))); | |
| 9826 | + VUNREACHABLE(); | |
| 9827 | + } | |
| 9828 | + } | |
| 9829 | + #endif | |
| 9830 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(a->element_size)) * i, val, a->element_size); | |
| 9831 | +} | |
| 9832 | +VV_LOC void builtin__array_set_ni(array* a, int i, voidptr val) { | |
| 9833 | + builtin__array_set(a, builtin__v_ni_index(i, a->len), val); | |
| 9834 | +} | |
| 9835 | +inline VV_LOC void builtin__copy_element_to(voidptr dest, voidptr src, int element_size) { | |
| 9836 | + { // Unsafe block | |
| 9837 | + switch (element_size) { | |
| 9838 | + case 1: { | |
| 9839 | + builtin__vmemcpy(dest, src, 1); | |
| 9840 | + break; | |
| 9841 | + } | |
| 9842 | + case 2: { | |
| 9843 | + builtin__vmemcpy(dest, src, 2); | |
| 9844 | + break; | |
| 9845 | + } | |
| 9846 | + case 4: { | |
| 9847 | + builtin__vmemcpy(dest, src, 4); | |
| 9848 | + break; | |
| 9849 | + } | |
| 9850 | + case 8: { | |
| 9851 | + builtin__vmemcpy(dest, src, 8); | |
| 9852 | + break; | |
| 9853 | + } | |
| 9854 | + case 16: { | |
| 9855 | + builtin__vmemcpy(dest, src, 16); | |
| 9856 | + break; | |
| 9857 | + } | |
| 9858 | + default: { | |
| 9859 | + { | |
| 9860 | + builtin__vmemcpy(dest, src, element_size); | |
| 9861 | + break; | |
| 9862 | + } | |
| 9863 | + } | |
| 9864 | + } | |
| 9865 | + | |
| 9866 | + } | |
| 9867 | +} | |
| 9868 | +VV_LOC void builtin__array_push(array* a, voidptr val) { | |
| 9869 | + #if 1 | |
| 9870 | + { | |
| 9871 | + if (a->len < 0) { | |
| 9872 | + builtin___v_panic(_S("array.push: negative len")); | |
| 9873 | + VUNREACHABLE(); | |
| 9874 | + } | |
| 9875 | + } | |
| 9876 | + #endif | |
| 9877 | + if (a->len >= _const_max_int) { | |
| 9878 | + builtin___v_panic(_S("array.push: len bigger than max_int")); | |
| 9879 | + VUNREACHABLE(); | |
| 9880 | + } | |
| 9881 | + int required = a->len + 1; | |
| 9882 | + if (required > a->cap) { | |
| 9883 | + builtin__array_ensure_cap(a, required); | |
| 9884 | + } else if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__is_slice)) { | |
| 9885 | + builtin__array_clone_shallow_to_cap(a, a->cap); | |
| 9886 | + } | |
| 9887 | + builtin__copy_element_to(((u8*)(a->data)) + ((u64)(a->element_size)) * ((u64)(a->len)), val, a->element_size); | |
| 9888 | + a->len++; | |
| 9889 | +} | |
| 9890 | +void builtin__array_push_many(array* a, voidptr val, int size) { | |
| 9891 | + if (size <= 0 || val == ((void*)0)) { | |
| 9892 | + return; | |
| 9893 | + } | |
| 9894 | + i64 new_len = ((i64)(a->len)) + ((i64)(size)); | |
| 9895 | + if (new_len > _const_max_int) { | |
| 9896 | + builtin___v_panic(_S("array.push_many: new len exceeds max_int")); | |
| 9897 | + VUNREACHABLE(); | |
| 9898 | + } | |
| 9899 | + if (builtin__array_needs_unique_append(*a, ((int)(new_len)))) { | |
| 9900 | + builtin__array_clone_shallow_to_cap(a, a->cap); | |
| 9901 | + } | |
| 9902 | + bool is_self_append = a->data == val && a->data != 0; | |
| 9903 | + if (((int)(new_len)) > a->cap) { | |
| 9904 | + builtin__array_ensure_cap(a, ((int)(new_len))); | |
| 9905 | + } | |
| 9906 | + if (is_self_append) { | |
| 9907 | + array cloned = builtin__array_clone(a); | |
| 9908 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(a->element_size)) * ((u64)(a->len)), cloned.data, ((u64)(a->element_size)) * ((u64)(size))); | |
| 9909 | + } else { | |
| 9910 | + if (a->data != 0 && val != 0) { | |
| 9911 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(a->element_size)) * ((u64)(a->len)), val, ((u64)(a->element_size)) * ((u64)(size))); | |
| 9912 | + } | |
| 9913 | + } | |
| 9914 | + a->len = ((int)(new_len)); | |
| 9915 | +} | |
| 9916 | +void builtin__array_reverse_in_place(array* a) { | |
| 9917 | + if (a->len < 2 || a->element_size == 0) { | |
| 9918 | + return; | |
| 9919 | + } | |
| 9920 | + { // Unsafe block | |
| 9921 | + u8* tmp_value = builtin___v_malloc(a->element_size); | |
| 9922 | + for (int i = 0; i < VSAFE_DIV_int(a->len , 2); ++i) { | |
| 9923 | + builtin__vmemcpy(tmp_value, ((u8*)(a->data)) + ((u64)(i)) * ((u64)(a->element_size)), a->element_size); | |
| 9924 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(i)) * ((u64)(a->element_size)), ((u8*)(a->data)) + ((u64)((int)(a->len - 1 - i))) * ((u64)(a->element_size)), a->element_size); | |
| 9925 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)((int)(a->len - 1 - i))) * ((u64)(a->element_size)), tmp_value, a->element_size); | |
| 9926 | + } | |
| 9927 | + builtin___v_free(tmp_value); | |
| 9928 | + } | |
| 9929 | +} | |
| 9930 | +array builtin__array_reverse(array a) { | |
| 9931 | + if (a.len < 2) { | |
| 9932 | + return a; | |
| 9933 | + } | |
| 9934 | + bool use_noscan_data = builtin__array_uses_noscan_data(a); | |
| 9935 | + array _t2 = ((array){.data = builtin__array_alloc_array_data_like(a, ((u64)(a.cap)) * ((u64)(a.element_size))),.offset = 0,.len = a.len,.cap = a.cap,.flags = (use_noscan_data ? ((ArrayFlags__managed | ArrayFlags__noscan_data)) : (ArrayFlags__managed)),.element_size = a.element_size,}); | |
| 9936 | + array arr = _t2; | |
| 9937 | + for (int i = 0; i < a.len; ++i) { | |
| 9938 | + builtin__array_set_unsafe(&arr, i, builtin__array_get_unsafe(a, (int)(a.len - 1 - i))); | |
| 9939 | + } | |
| 9940 | + return arr; | |
| 9941 | +} | |
| 9942 | +void builtin__array_free(array* a) { | |
| 9943 | + if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__nofree)) { | |
| 9944 | + return; | |
| 9945 | + } | |
| 9946 | + u8* mblock_ptr = ((u8*)(((u64)(a->data)) - ((u64)(a->offset)))); | |
| 9947 | + if (mblock_ptr != ((void*)0)) { | |
| 9948 | + { // Unsafe block | |
| 9949 | + if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__managed)) { | |
| 9950 | + builtin___v_free(mblock_ptr - builtin__array_data_header_size()); | |
| 9951 | + } else { | |
| 9952 | + builtin___v_free(mblock_ptr); | |
| 9953 | + } | |
| 9954 | + } | |
| 9955 | + } | |
| 9956 | + { // Unsafe block | |
| 9957 | + a->data = ((void*)0); | |
| 9958 | + a->offset = 0; | |
| 9959 | + a->len = 0; | |
| 9960 | + a->cap = 0; | |
| 9961 | + } | |
| 9962 | +} | |
| 9963 | +array builtin__array_filter(array a, bool (*predicate)(voidptr _d1)); | |
| 9964 | +bool builtin__array_any(array a, bool (*predicate)(voidptr _d1)); | |
| 9965 | +int builtin__array_count(array a, bool (*predicate)(voidptr _d1)); | |
| 9966 | +bool builtin__array_all(array a, bool (*predicate)(voidptr _d1)); | |
| 9967 | +array builtin__array_map(array a, voidptr (*callback)(voidptr _d1)); | |
| 9968 | +void builtin__array_sort(array* a, int (*callback)(voidptr _d1, voidptr _d2)); | |
| 9969 | +array builtin__array_sorted(array* a, int (*callback)(voidptr _d1, voidptr _d2)); | |
| 9970 | +void builtin__array_sort_with_compare(array* a, int (*callback)(const void* const_a, const void* const_b)) { | |
| 9971 | + #if 0 | |
| 9972 | + { | |
| 9973 | + } | |
| 9974 | + #else | |
| 9975 | + { | |
| 9976 | + builtin__vqsort(a->data, ((usize)(a->len)), ((usize)(a->element_size)), callback); | |
| 9977 | + } | |
| 9978 | + #endif | |
| 9979 | +} | |
| 9980 | +array builtin__array_sorted_with_compare(array* a, int (*callback)(const void* const_a, const void* const_b)) { | |
| 9981 | + array r = builtin__array_clone(a); | |
| 9982 | + builtin__vqsort(r.data, ((usize)(r.len)), ((usize)(r.element_size)), callback); | |
| 9983 | + return r; | |
| 9984 | +} | |
| 9985 | +bool builtin__array_contains(array a, voidptr value); | |
| 9986 | +int builtin__array_index(array a, voidptr value); | |
| 9987 | +int builtin__array_last_index(array a, voidptr value); | |
| 9988 | +void Array_string_free(Array_string* a) { | |
| 9989 | + for (int _t1 = 0; _t1 < a->len; ++_t1) { | |
| 9990 | + string* s = ((string*)a->data) + _t1; | |
| 9991 | + builtin__string_free(s); | |
| 9992 | + } | |
| 9993 | + array* arr = ((array*)(a)); | |
| 9994 | + builtin__array_free(arr); | |
| 9995 | +} | |
| 9996 | +string Array_string_str(Array_string a) { | |
| 9997 | + int sb_len = 4; | |
| 9998 | + if (a.len > 0) { | |
| 9999 | + sb_len += ((string*)a.data)[0].len; | |
| 10000 | + sb_len *= a.len; | |
| 10001 | + } | |
| 10002 | + sb_len += 2; | |
| 10003 | + strings__Builder sb = strings__new_builder(sb_len); | |
| 10004 | + strings__Builder_write_u8(&sb, '['); | |
| 10005 | + for (int i = 0; i < a.len; ++i) { | |
| 10006 | + string val = ((string*)a.data)[i]; | |
| 10007 | + strings__Builder_write_u8(&sb, '\''); | |
| 10008 | + strings__Builder_write_string(&sb, val); | |
| 10009 | + strings__Builder_write_u8(&sb, '\''); | |
| 10010 | + if (i < a.len - 1) { | |
| 10011 | + strings__Builder_write_string(&sb, _S(", ")); | |
| 10012 | + } | |
| 10013 | + } | |
| 10014 | + strings__Builder_write_u8(&sb, ']'); | |
| 10015 | + string res = strings__Builder_str(&sb); | |
| 10016 | + strings__Builder_free(&sb); | |
| 10017 | + return res; | |
| 10018 | +} | |
| 10019 | +string Array_u8_hex(Array_u8 b) { | |
| 10020 | + if (b.len == 0) { | |
| 10021 | + return _S(""); | |
| 10022 | + } | |
| 10023 | + return builtin__data_to_hex_string(b.data, b.len); | |
| 10024 | +} | |
| 10025 | +int builtin__copy(Array_u8* dst, Array_u8 src) { | |
| 10026 | + int min = (dst->len < src.len ? (dst->len) : (src.len)); | |
| 10027 | + if (min > 0) { | |
| 10028 | + builtin__vmemmove(dst->data, src.data, min); | |
| 10029 | + } | |
| 10030 | + return min; | |
| 10031 | +} | |
| 10032 | +void builtin__array_grow_cap(array* a, int amount) { | |
| 10033 | + i64 new_cap = ((i64)(amount)) + ((i64)(a->cap)); | |
| 10034 | + if (new_cap > _const_max_int) { | |
| 10035 | + builtin__panic_n(_S("array.grow_cap: max_int will be exceeded by new cap:"), new_cap); | |
| 10036 | + VUNREACHABLE(); | |
| 10037 | + } | |
| 10038 | + builtin__array_ensure_cap(a, ((int)(new_cap))); | |
| 10039 | +} | |
| 10040 | +void builtin__array_grow_len(array* a, int amount) { | |
| 10041 | + i64 new_len = ((i64)(amount)) + ((i64)(a->len)); | |
| 10042 | + if (new_len > _const_max_int) { | |
| 10043 | + builtin__panic_n(_S("array.grow_len: max_int will be exceeded by new len:"), new_len); | |
| 10044 | + VUNREACHABLE(); | |
| 10045 | + } | |
| 10046 | + builtin__array_ensure_cap(a, ((int)(new_len))); | |
| 10047 | + a->len = ((int)(new_len)); | |
| 10048 | +} | |
| 10049 | +Array_voidptr builtin__array_pointers(array a) { | |
| 10050 | + Array_voidptr res = builtin____new_array_with_default(0, 0, sizeof(voidptr), 0); | |
| 10051 | + for (int i = 0; i < a.len; ++i) { | |
| 10052 | + builtin__array_push((array*)&res, _MOV((voidptr[]){ builtin__array_get_unsafe(a, i) })); | |
| 10053 | + } | |
| 10054 | + return res; | |
| 10055 | +} | |
| 10056 | +Array_u8 builtin__voidptr_vbytes(voidptr data, int len) { | |
| 10057 | + array _t1 = ((array){.data = data,.offset = 0,.len = len,.cap = len,.flags = 0,.element_size = 1,}); | |
| 10058 | + array res = _t1; | |
| 10059 | + return res; | |
| 10060 | +} | |
| 10061 | +Array_u8 builtin__u8_vbytes(u8* data, int len) { | |
| 10062 | + return builtin__voidptr_vbytes(((voidptr)(data)), len); | |
| 10063 | +} | |
| 10064 | +void builtin__u8_free(u8* data) { | |
| 10065 | + builtin___v_free(data); | |
| 10066 | +} | |
| 10067 | +inline VV_LOC void builtin__panic_on_negative_len(int len) { | |
| 10068 | + if (len < 0) { | |
| 10069 | + builtin__panic_n(_S("negative .len:"), len); | |
| 10070 | + VUNREACHABLE(); | |
| 10071 | + } | |
| 10072 | +} | |
| 10073 | +inline VV_LOC void builtin__panic_on_negative_cap(int cap) { | |
| 10074 | + if (cap < 0) { | |
| 10075 | + builtin__panic_n(_S("negative .cap:"), cap); | |
| 10076 | + VUNREACHABLE(); | |
| 10077 | + } | |
| 10078 | +} | |
| 10079 | +VV_LOC array builtin____new_array_noscan(int mylen, int cap, int elm_size) { | |
| 10080 | + return builtin____new_array(mylen, cap, elm_size); | |
| 10081 | +} | |
| 10082 | +VV_LOC array builtin____new_array_with_default_noscan(int mylen, int cap, int elm_size, voidptr val) { | |
| 10083 | + return builtin____new_array_with_default(mylen, cap, elm_size, val); | |
| 10084 | +} | |
| 10085 | +VV_LOC array builtin____new_array_with_multi_default_noscan(int mylen, int cap, int elm_size, voidptr val) { | |
| 10086 | + return builtin____new_array_with_multi_default(mylen, cap, elm_size, val); | |
| 10087 | +} | |
| 10088 | +VV_LOC array builtin____new_array_with_array_default_noscan(int mylen, int cap, int elm_size, array val, int depth) { | |
| 10089 | + return builtin____new_array_with_array_default(mylen, cap, elm_size, val, depth); | |
| 10090 | +} | |
| 10091 | +VV_LOC void builtin__array_push_noscan(array* a, voidptr val) { | |
| 10092 | + builtin__array_push(a, val); | |
| 10093 | +} | |
| 10094 | +VV_LOC void builtin__array_push_many_noscan(array* a, voidptr val, int size) { | |
| 10095 | + builtin__array_push_many(a, val, size); | |
| 10096 | +} | |
| 10097 | +VV_LOC bool builtin__autostr_type_in_stack(int typ) { | |
| 10098 | + for (int i = 0; i < g_autostr_type_stack_len; i++) { | |
| 10099 | + if (g_autostr_type_stack[builtin__v_fixed_index(i, 64)] == typ) { | |
| 10100 | + return true; | |
| 10101 | + } | |
| 10102 | + } | |
| 10103 | + return false; | |
| 10104 | +} | |
| 10105 | +VV_LOC void builtin__autostr_type_push(int typ) { | |
| 10106 | + if (g_autostr_type_stack_len >= _const_autostr_type_stack_max_depth) { | |
| 10107 | + return; | |
| 10108 | + } | |
| 10109 | + g_autostr_type_stack[builtin__v_fixed_index(g_autostr_type_stack_len, 64)] = typ; | |
| 10110 | + g_autostr_type_stack_len++; | |
| 10111 | +} | |
| 10112 | +VV_LOC void builtin__autostr_type_pop(void) { | |
| 10113 | + if (g_autostr_type_stack_len > 0) { | |
| 10114 | + g_autostr_type_stack_len--; | |
| 10115 | + } | |
| 10116 | +} | |
| 10117 | +VV_LOC bool builtin__autostr_addr_in_stack(voidptr addr) { | |
| 10118 | + for (int i = 0; i < g_autostr_addr_stack_len; i++) { | |
| 10119 | + if (g_autostr_addr_stack[builtin__v_fixed_index(i, 64)] == addr) { | |
| 10120 | + return true; | |
| 10121 | + } | |
| 10122 | + } | |
| 10123 | + return false; | |
| 10124 | +} | |
| 10125 | +VV_LOC void builtin__autostr_addr_push(voidptr addr) { | |
| 10126 | + if (g_autostr_addr_stack_len >= _const_autostr_type_stack_max_depth) { | |
| 10127 | + return; | |
| 10128 | + } | |
| 10129 | + g_autostr_addr_stack[builtin__v_fixed_index(g_autostr_addr_stack_len, 64)] = addr; | |
| 10130 | + g_autostr_addr_stack_len++; | |
| 10131 | +} | |
| 10132 | +VV_LOC void builtin__autostr_addr_pop(void) { | |
| 10133 | + if (g_autostr_addr_stack_len > 0) { | |
| 10134 | + g_autostr_addr_stack_len--; | |
| 10135 | + } | |
| 10136 | +} | |
| 10137 | +VV_LOC string builtin__autostr_array_circular(int len) { | |
| 10138 | + if (len <= 0) { | |
| 10139 | + return _S("[]"); | |
| 10140 | + } | |
| 10141 | + strings__Builder sb = strings__new_builder(2 + len * 12); | |
| 10142 | + strings__Builder_write_string(&sb, _S("[")); | |
| 10143 | + for (int i = 0; i < len; ++i) { | |
| 10144 | + if (i > 0) { | |
| 10145 | + strings__Builder_write_string(&sb, _S(", ")); | |
| 10146 | + } | |
| 10147 | + strings__Builder_write_string(&sb, _S("<circular>")); | |
| 10148 | + } | |
| 10149 | + strings__Builder_write_string(&sb, _S("]")); | |
| 10150 | + string res = strings__Builder_str(&sb); | |
| 10151 | + strings__Builder_free(&sb); | |
| 10152 | + return res; | |
| 10153 | +} | |
| 10154 | +void builtin__print_backtrace(void) { | |
| 10155 | + #if !defined(CUSTOM_DEFINE_no_backtrace) | |
| 10156 | + { | |
| 10157 | + #if 0 | |
| 10158 | + { | |
| 10159 | + } | |
| 10160 | + #elif defined(__TINYC__) | |
| 10161 | + { | |
| 10162 | + } | |
| 10163 | + #elif defined(CUSTOM_DEFINE_use_libbacktrace) | |
| 10164 | + { | |
| 10165 | + } | |
| 10166 | + #else | |
| 10167 | + { | |
| 10168 | + builtin__print_backtrace_skipping_top_frames(2); | |
| 10169 | + } | |
| 10170 | + #endif | |
| 10171 | + } | |
| 10172 | + #endif | |
| 10173 | +} | |
| 10174 | +VV_LOC string builtin__demangle_v_symbol(string cname) { | |
| 10175 | + string name = cname; | |
| 10176 | + if (builtin__string_starts_with(name, _S("builtin__"))) { | |
| 10177 | + name = builtin__string_substr(name, 9, 2147483647); | |
| 10178 | + } | |
| 10179 | + name = builtin__string_replace(name, _S("__ptr__"), _S("&")); | |
| 10180 | + _option_int _t1 = builtin__string_index(name, _S("_T_")); | |
| 10181 | + if (_t1.state != 0) { | |
| 10182 | + *(int*) _t1.data = -1; | |
| 10183 | + } | |
| 10184 | + | |
| 10185 | + int t_pos = (*(int*)_t1.data); | |
| 10186 | + if (t_pos >= 0) { | |
| 10187 | + string base = builtin__string_replace(builtin__string_substr(name, 0, t_pos), _S("__"), _S(".")); | |
| 10188 | + string generic_suffix = builtin__string_substr(name, t_pos + 3, 2147483647); | |
| 10189 | + Array_string params = builtin__split_generic_params(generic_suffix); | |
| 10190 | + Array_string demangled_params = builtin____new_array_with_default(0, params.len, sizeof(string), 0); | |
| 10191 | + for (int _t2 = 0; _t2 < params.len; ++_t2) { | |
| 10192 | + string param = ((string*)params.data)[_t2]; | |
| 10193 | + builtin__array_push((array*)&demangled_params, _MOV((string[]){ builtin__string_replace(param, _S("__"), _S(".")) })); | |
| 10194 | + } | |
| 10195 | + return builtin__string_plus_many(4, _MOV((string[4]){base, _S("["), Array_string_join(demangled_params, _S(", ")), _S("]")})); | |
| 10196 | + } | |
| 10197 | + name = builtin__string_replace(name, _S("__"), _S(".")); | |
| 10198 | + if (_SLIT_EQ(name.str, name.len, "main.main")) { | |
| 10199 | + return _S("main"); | |
| 10200 | + } | |
| 10201 | + return name; | |
| 10202 | +} | |
| 10203 | +VV_LOC Array_string builtin__split_generic_params(string s) { | |
| 10204 | + Array_string params = builtin____new_array_with_default(0, 0, sizeof(string), 0); | |
| 10205 | + int start = 0; | |
| 10206 | + int i = 0; | |
| 10207 | + for (;;) { | |
| 10208 | + if (!(i < s.len)) break; | |
| 10209 | + if (s.str[ i] == '_') { | |
| 10210 | + if (i + 1 < s.len && s.str[ i + 1] == '_') { | |
| 10211 | + i += 2; | |
| 10212 | + } else { | |
| 10213 | + if (i > start) { | |
| 10214 | + builtin__array_push((array*)¶ms, _MOV((string[]){ builtin__string_substr(s, start, i) })); | |
| 10215 | + } | |
| 10216 | + i++; | |
| 10217 | + start = i; | |
| 10218 | + } | |
| 10219 | + } else { | |
| 10220 | + i++; | |
| 10221 | + } | |
| 10222 | + } | |
| 10223 | + if (start < s.len) { | |
| 10224 | + builtin__array_push((array*)¶ms, _MOV((string[]){ builtin__string_substr(s, start, 2147483647) })); | |
| 10225 | + } | |
| 10226 | + return params; | |
| 10227 | +} | |
| 10228 | +VV_LOC string builtin__demangle_backtrace_sym(string s) { | |
| 10229 | + _option_int _t1 = builtin__string_index(s, _S("(")); | |
| 10230 | + if (_t1.state != 0) { | |
| 10231 | + return s; | |
| 10232 | + } | |
| 10233 | + | |
| 10234 | + int paren_start = (*(int*)_t1.data); | |
| 10235 | + int plus_pos = builtin__string_index_after_(s, _S("+"), paren_start); | |
| 10236 | + if (plus_pos < 0) { | |
| 10237 | + return s; | |
| 10238 | + } | |
| 10239 | + string symbol = builtin__string_substr(s, paren_start + 1, plus_pos); | |
| 10240 | + if (symbol.len == 0) { | |
| 10241 | + return s; | |
| 10242 | + } | |
| 10243 | + return builtin__string_plus_many(3, _MOV((string[3]){builtin__string_substr(s, 0, paren_start + 1), builtin__demangle_v_symbol(symbol), builtin__string_substr(s, plus_pos, 2147483647)})); | |
| 10244 | +} | |
| 10245 | +VV_LOC void builtin__eprint_space_padding(string output, int max_len) { | |
| 10246 | + int padding_len = max_len - output.len; | |
| 10247 | + if (padding_len > 0) { | |
| 10248 | + for (int _t1 = 0; _t1 < padding_len; ++_t1) { | |
| 10249 | + builtin__eprint(_S(" ")); | |
| 10250 | + } | |
| 10251 | + } | |
| 10252 | +} | |
| 10253 | +bool builtin__print_backtrace_skipping_top_frames(int xskipframes) { | |
| 10254 | + #if defined(CUSTOM_DEFINE_no_backtrace) | |
| 10255 | + { | |
| 10256 | + } | |
| 10257 | + #else | |
| 10258 | + { | |
| 10259 | + int skipframes = xskipframes + 2; | |
| 10260 | + #if 0 | |
| 10261 | + { | |
| 10262 | + } | |
| 10263 | + #elif 1 | |
| 10264 | + { | |
| 10265 | + return builtin__print_backtrace_skipping_top_frames_linux(skipframes); | |
| 10266 | + } | |
| 10267 | + #else | |
| 10268 | + { | |
| 10269 | + } | |
| 10270 | + #endif | |
| 10271 | + } | |
| 10272 | + #endif | |
| 10273 | + return false; | |
| 10274 | +} | |
| 10275 | +VV_LOC string builtin__backtrace_current_executable_name(void) { | |
| 10276 | + Array_string args = builtin__arguments(); | |
| 10277 | + if (args.len == 0) { | |
| 10278 | + return _S(""); | |
| 10279 | + } | |
| 10280 | + return (*(string*)builtin__array_get(args, 0)); | |
| 10281 | +} | |
| 10282 | +VV_LOC string builtin__backtrace_addr2line_executable(string executable, string current_executable_name) { | |
| 10283 | + if (executable.len == 0) { | |
| 10284 | + return _S("/proc/self/exe"); | |
| 10285 | + } | |
| 10286 | + if (builtin__string_contains(executable, _S("/"))) { | |
| 10287 | + return executable; | |
| 10288 | + } | |
| 10289 | + if (current_executable_name.len > 0 && builtin__string__eq(builtin__string_all_after_last(executable, _S("/")), builtin__string_all_after_last(current_executable_name, _S("/")))) { | |
| 10290 | + return _S("/proc/self/exe"); | |
| 10291 | + } | |
| 10292 | + return executable; | |
| 10293 | +} | |
| 10294 | +VV_LOC string builtin__backtrace_shell_quote(string s) { | |
| 10295 | + string quoted = _S("'"); | |
| 10296 | + for (int i = 0; i < s.len; ++i) { | |
| 10297 | + if (builtin__string_at(s, i) == '\'') { | |
| 10298 | + quoted = builtin__string__plus(quoted, _S("'\\''")); | |
| 10299 | + } else { | |
| 10300 | + quoted = builtin__string__plus(quoted, builtin__u8_ascii_str(builtin__string_at(s, i))); | |
| 10301 | + } | |
| 10302 | + } | |
| 10303 | + return builtin__string__plus(quoted, _S("'")); | |
| 10304 | +} | |
| 10305 | +VV_LOC bool builtin__print_backtrace_skipping_top_frames_linux(int skipframes) { | |
| 10306 | + #if defined(CUSTOM_DEFINE_no_backtrace) | |
| 10307 | + { | |
| 10308 | + } | |
| 10309 | + #else | |
| 10310 | + { | |
| 10311 | + #if 1 | |
| 10312 | + { | |
| 10313 | + #if 0 | |
| 10314 | + { | |
| 10315 | + } | |
| 10316 | + #else | |
| 10317 | + { | |
| 10318 | + string current_executable_name = builtin__backtrace_current_executable_name(); | |
| 10319 | + Array_fixed_voidptr_100 buffer = {0}; | |
| 10320 | + i32 nr_ptrs = backtrace(&buffer[0], 100); | |
| 10321 | + if (nr_ptrs < 2) { | |
| 10322 | + builtin__eprintln(_S("C.backtrace returned less than 2 frames")); | |
| 10323 | + return false; | |
| 10324 | + } | |
| 10325 | + int nr_actual_frames = (int)(nr_ptrs - skipframes); | |
| 10326 | + char** csymbols = backtrace_symbols(((voidptr)(&buffer[skipframes])), nr_actual_frames); | |
| 10327 | + for (int i = 0; i < nr_actual_frames; ++i) { | |
| 10328 | + string sframe = builtin__tos2(((u8*)(csymbols[i]))); | |
| 10329 | + string executable = builtin__string_all_before(sframe, _S("(")); | |
| 10330 | + string addr2line_executable = builtin__backtrace_addr2line_executable(executable, current_executable_name); | |
| 10331 | + string addr = builtin__string_all_before(builtin__string_all_after(sframe, _S("[")), _S("]")); | |
| 10332 | + string beforeaddr = builtin__string_all_before(sframe, _S("[")); | |
| 10333 | + string cmd = builtin__string_plus_many(4, _MOV((string[4]){_S("addr2line -e "), builtin__backtrace_shell_quote(addr2line_executable), _S(" "), builtin__backtrace_shell_quote(addr)})); | |
| 10334 | + voidptr f = popen(((char*)(cmd.str)), "r"); | |
| 10335 | + if (f == ((void*)0)) { | |
| 10336 | + builtin__eprintln(sframe); | |
| 10337 | + continue; | |
| 10338 | + } | |
| 10339 | + Array_fixed_u8_1000 buf = {0}; | |
| 10340 | + string output = _S(""); | |
| 10341 | + { // Unsafe block | |
| 10342 | + u8* bp = ((u8*)(&buf[0])); | |
| 10343 | + for (;;) { | |
| 10344 | + if (!(fgets(((char*)(bp)), 1000, f) != 0)) break; | |
| 10345 | + output = builtin__string__plus(output, builtin__tos(bp, builtin__vstrlen(bp))); | |
| 10346 | + } | |
| 10347 | + } | |
| 10348 | + output = builtin__string__plus(builtin__string_trim_chars(output, _S(" \t\n"), TrimMode__trim_both), _S(":")); | |
| 10349 | + if (pclose(f) != 0) { | |
| 10350 | + builtin__eprintln(sframe); | |
| 10351 | + continue; | |
| 10352 | + } | |
| 10353 | + if (_SLIT_EQ(output.str, output.len, "??:0:") || _SLIT_EQ(output.str, output.len, "??:?:")) { | |
| 10354 | + output = _S(""); | |
| 10355 | + } | |
| 10356 | + output = builtin__string_replace(output, _S(" (discriminator"), _S(": (d.")); | |
| 10357 | + builtin__eprint(output); | |
| 10358 | + builtin__eprint_space_padding(output, 55); | |
| 10359 | + builtin__eprint(_S(" | ")); | |
| 10360 | + builtin__eprint(addr); | |
| 10361 | + builtin__eprint(_S(" | ")); | |
| 10362 | + builtin__eprintln(builtin__demangle_backtrace_sym(beforeaddr)); | |
| 10363 | + } | |
| 10364 | + if (nr_actual_frames > 0) { | |
| 10365 | + free(csymbols); | |
| 10366 | + } | |
| 10367 | + } | |
| 10368 | + #endif | |
| 10369 | + } | |
| 10370 | + #endif | |
| 10371 | + } | |
| 10372 | + #endif | |
| 10373 | + return true; | |
| 10374 | +} | |
| 10375 | +VNORETURN void builtin___v_exit(int code) { | |
| 10376 | + exit(code); | |
| 10377 | + VUNREACHABLE(); | |
| 10378 | + for (;;) { | |
| 10379 | + } | |
| 10380 | + while(1); | |
| 10381 | +} | |
| 10382 | +_result_void builtin__at_exit(void (*cb)(void)) { | |
| 10383 | + #if 0 | |
| 10384 | + { | |
| 10385 | + } | |
| 10386 | + #else | |
| 10387 | + { | |
| 10388 | + i32 res = atexit(cb); | |
| 10389 | + if (res != 0) { | |
| 10390 | + return (_result_void){ .is_error=true, .err=builtin__error_with_code(_S("at_exit failed"), res), .data={E_STRUCT} }; | |
| 10391 | + } | |
| 10392 | + } | |
| 10393 | + #endif | |
| 10394 | + return (_result_void){0}; | |
| 10395 | +} | |
| 10396 | +VV_LOC void builtin__v_segmentation_fault_handler(i32 signal_number) { | |
| 10397 | + #if defined(CUSTOM_DEFINE_v2_native_windows_pe_minimal) | |
| 10398 | + { | |
| 10399 | + } | |
| 10400 | + #else | |
| 10401 | + { | |
| 10402 | + #if 0 | |
| 10403 | + { | |
| 10404 | + } | |
| 10405 | + #else | |
| 10406 | + { | |
| 10407 | + fprintf(stderr, "signal %d: segmentation fault\n", signal_number); | |
| 10408 | + } | |
| 10409 | + #endif | |
| 10410 | + #if defined(CUSTOM_DEFINE_use_libbacktrace) && !defined(__TINYC__) | |
| 10411 | + { | |
| 10412 | + } | |
| 10413 | + #elif 0 | |
| 10414 | + { | |
| 10415 | + } | |
| 10416 | + #else | |
| 10417 | + { | |
| 10418 | + builtin__print_backtrace(); | |
| 10419 | + } | |
| 10420 | + #endif | |
| 10421 | + builtin___v_exit(128 + signal_number); | |
| 10422 | + VUNREACHABLE(); | |
| 10423 | + } | |
| 10424 | + #endif | |
| 10425 | +} | |
| 10426 | +inline VV_LOC int builtin__v_fixed_index(int i, int len) { | |
| 10427 | + #if 1 | |
| 10428 | + { | |
| 10429 | + if (i < 0 || i >= len) { | |
| 10430 | + builtin___v_panic(builtin__string_plus_many(5, _MOV((string[5]){_S("fixed array index out of range (index: "), builtin__i64_str(((i64)(i))), _S(", len: "), builtin__i64_str(((i64)(len))), _S(")")}))); | |
| 10431 | + VUNREACHABLE(); | |
| 10432 | + } | |
| 10433 | + } | |
| 10434 | + #endif | |
| 10435 | + return i; | |
| 10436 | +} | |
| 10437 | +inline VV_LOC int builtin__v_fixed_index_i64(i64 i, int len) { | |
| 10438 | + #if 1 | |
| 10439 | + { | |
| 10440 | + if (i < 0 || i >= ((i64)(len))) { | |
| 10441 | + builtin___v_panic(builtin__string_plus_many(5, _MOV((string[5]){_S("fixed array index out of range (index: "), builtin__i64_str(i), _S(", len: "), builtin__i64_str(((i64)(len))), _S(")")}))); | |
| 10442 | + VUNREACHABLE(); | |
| 10443 | + } | |
| 10444 | + } | |
| 10445 | + #endif | |
| 10446 | + return ((int)(i)); | |
| 10447 | +} | |
| 10448 | +inline VV_LOC int builtin__v_fixed_index_u64(u64 i, int len) { | |
| 10449 | + #if 1 | |
| 10450 | + { | |
| 10451 | + if (i >= ((u64)(len))) { | |
| 10452 | + builtin___v_panic(builtin__string_plus_many(5, _MOV((string[5]){_S("fixed array index out of range (index: "), builtin__u64_str(i), _S(", len: "), builtin__i64_str(((i64)(len))), _S(")")}))); | |
| 10453 | + VUNREACHABLE(); | |
| 10454 | + } | |
| 10455 | + } | |
| 10456 | + #endif | |
| 10457 | + return ((int)(i)); | |
| 10458 | +} | |
| 10459 | +inline VV_LOC int builtin__v_fixed_index_ni(int i, int len) { | |
| 10460 | + return builtin__v_fixed_index(builtin__v_ni_index(i, len), len); | |
| 10461 | +} | |
| 10462 | +inline VV_LOC int builtin__v_slice_index_i64(i64 i) { | |
| 10463 | + if (i < ((i64)(_const_min_int)) || i > ((i64)(_const_max_int))) { | |
| 10464 | + builtin___v_panic(builtin__string__plus(_S("slice index out of range for int: "), builtin__i64_str(i))); | |
| 10465 | + VUNREACHABLE(); | |
| 10466 | + } | |
| 10467 | + return ((int)(i)); | |
| 10468 | +} | |
| 10469 | +inline VV_LOC int builtin__v_slice_index_u64(u64 i) { | |
| 10470 | + if (i > ((u64)(_const_max_int))) { | |
| 10471 | + builtin___v_panic(builtin__string__plus(_S("slice index out of range for int: "), builtin__u64_str(i))); | |
| 10472 | + VUNREACHABLE(); | |
| 10473 | + } | |
| 10474 | + return ((int)(i)); | |
| 10475 | +} | |
| 10476 | +Array_string builtin__arguments(void) { | |
| 10477 | + u8** argv = ((u8**)(g_main_argv)); | |
| 10478 | + Array_string res = builtin____new_array_with_default(0, g_main_argc, sizeof(string), 0); | |
| 10479 | + for (int i = 0; i < g_main_argc; ++i) { | |
| 10480 | + #if 0 | |
| 10481 | + { | |
| 10482 | + } | |
| 10483 | + #else | |
| 10484 | + { | |
| 10485 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__tos_clone(argv[i]) })); | |
| 10486 | + } | |
| 10487 | + #endif | |
| 10488 | + } | |
| 10489 | + return res; | |
| 10490 | +} | |
| 10491 | +string builtin__vcurrent_hash(void) { | |
| 10492 | + return _S(""); | |
| 10493 | +} | |
| 10494 | +u64 builtin__v_getpid(void) { | |
| 10495 | + #if defined(CUSTOM_DEFINE_no_getpid) | |
| 10496 | + { | |
| 10497 | + } | |
| 10498 | + #elif 0 | |
| 10499 | + { | |
| 10500 | + } | |
| 10501 | + #else | |
| 10502 | + { | |
| 10503 | + return ((u64)(getpid())); | |
| 10504 | + } | |
| 10505 | + #endif | |
| 10506 | + return 0; | |
| 10507 | +} | |
| 10508 | +u64 builtin__v_gettid(void) { | |
| 10509 | + #if defined(CUSTOM_DEFINE_no_gettid) | |
| 10510 | + { | |
| 10511 | + } | |
| 10512 | + #elif 0 | |
| 10513 | + { | |
| 10514 | + } | |
| 10515 | + #elif 1 | |
| 10516 | + { | |
| 10517 | + return ((u64)(gettid())); | |
| 10518 | + } | |
| 10519 | + #elif 0 | |
| 10520 | + { | |
| 10521 | + } | |
| 10522 | + #else | |
| 10523 | + { | |
| 10524 | + } | |
| 10525 | + #endif | |
| 10526 | + return 0; | |
| 10527 | +} | |
| 10528 | +inline bool builtin__isnil(voidptr v) { | |
| 10529 | + return v == 0; | |
| 10530 | +} | |
| 10531 | +VV_LOC void builtin__builtin_init(void) { | |
| 10532 | + #if 1 | |
| 10533 | + { | |
| 10534 | + builtin__unbuffer_stdout(); | |
| 10535 | + } | |
| 10536 | + #endif | |
| 10537 | +} | |
| 10538 | +VNORETURN void builtin__panic_lasterr(string base) { | |
| 10539 | + builtin___v_panic(builtin__string__plus(base, _S(" unknown"))); | |
| 10540 | + VUNREACHABLE(); | |
| 10541 | + while(1); | |
| 10542 | +} | |
| 10543 | +void builtin__gc_check_leaks(void) { | |
| 10544 | +} | |
| 10545 | +bool builtin__gc_is_enabled(void) { | |
| 10546 | + return false; | |
| 10547 | +} | |
| 10548 | +void builtin__gc_enable(void) { | |
| 10549 | +} | |
| 10550 | +void builtin__gc_disable(void) { | |
| 10551 | +} | |
| 10552 | +void builtin__gc_collect(void) { | |
| 10553 | +} | |
| 10554 | +void builtin__gc_get_warn_proc(void) { | |
| 10555 | +} | |
| 10556 | +void builtin__gc_set_warn_proc(void (*cb)(char* msg, usize arg)) { | |
| 10557 | +} | |
| 10558 | +#if 0 | |
| 10559 | +#else | |
| 10560 | +#endif | |
| 10561 | +inline int builtin__vstrlen(u8* s) { | |
| 10562 | + return ((int)(strlen(((char*)(s))))); | |
| 10563 | +} | |
| 10564 | +inline int builtin__vstrlen_char(char* s) { | |
| 10565 | + return ((int)(strlen(s))); | |
| 10566 | +} | |
| 10567 | +inline voidptr builtin__vmemcpy(voidptr dest, const void* const_src, isize n) { | |
| 10568 | + if (n == 0 || ((u64)(dest)) <= 0xFFFF || ((u64)(const_src)) <= 0xFFFF) { | |
| 10569 | + return dest; | |
| 10570 | + } | |
| 10571 | + { // Unsafe block | |
| 10572 | + return memcpy(dest, const_src, n); | |
| 10573 | + } | |
| 10574 | + return 0; | |
| 10575 | +} | |
| 10576 | +inline voidptr builtin__vmemmove(voidptr dest, const void* const_src, isize n) { | |
| 10577 | + if (n == 0 || ((u64)(dest)) <= 0xFFFF || ((u64)(const_src)) <= 0xFFFF) { | |
| 10578 | + return dest; | |
| 10579 | + } | |
| 10580 | + { // Unsafe block | |
| 10581 | + return memmove(dest, const_src, n); | |
| 10582 | + } | |
| 10583 | + return 0; | |
| 10584 | +} | |
| 10585 | +inline int builtin__vmemcmp(const void* const_s1, const void* const_s2, isize n) { | |
| 10586 | + if (n == 0 || ((u64)(const_s1)) <= 0xFFFF || ((u64)(const_s2)) <= 0xFFFF) { | |
| 10587 | + return 0; | |
| 10588 | + } | |
| 10589 | + { // Unsafe block | |
| 10590 | + return memcmp(const_s1, const_s2, n); | |
| 10591 | + } | |
| 10592 | + return 0; | |
| 10593 | +} | |
| 10594 | +inline voidptr builtin__vmemset(voidptr s, int c, isize n) { | |
| 10595 | + if (n == 0 || ((u64)(s)) <= 0xFFFF) { | |
| 10596 | + return s; | |
| 10597 | + } | |
| 10598 | + { // Unsafe block | |
| 10599 | + return memset(s, c, n); | |
| 10600 | + } | |
| 10601 | + return 0; | |
| 10602 | +} | |
| 10603 | +inline VV_LOC voidptr builtin__vsort_ptr_at(voidptr base, usize index, usize size) { | |
| 10604 | + return ((voidptr)(((u8*)(base)) + index * size)); | |
| 10605 | +} | |
| 10606 | +VV_LOC void builtin__vstable_sort_merge(voidptr source, voidptr dest, usize left, usize mid, usize right, usize size, int (*sort_cb)(const void* const_a, const void* const_b)) { | |
| 10607 | + usize left_index = left; | |
| 10608 | + usize right_index = mid; | |
| 10609 | + usize dest_index = left; | |
| 10610 | + for (;;) { | |
| 10611 | + if (!(left_index < mid && right_index < right)) break; | |
| 10612 | + voidptr left_ptr = builtin__vsort_ptr_at(source, left_index, size); | |
| 10613 | + voidptr right_ptr = builtin__vsort_ptr_at(source, right_index, size); | |
| 10614 | + if (sort_cb(left_ptr, right_ptr) <= 0) { | |
| 10615 | + builtin__vmemcpy(builtin__vsort_ptr_at(dest, dest_index, size), left_ptr, ((isize)(size))); | |
| 10616 | + left_index++; | |
| 10617 | + } else { | |
| 10618 | + builtin__vmemcpy(builtin__vsort_ptr_at(dest, dest_index, size), right_ptr, ((isize)(size))); | |
| 10619 | + right_index++; | |
| 10620 | + } | |
| 10621 | + dest_index++; | |
| 10622 | + } | |
| 10623 | + if (left_index < mid) { | |
| 10624 | + builtin__vmemcpy(builtin__vsort_ptr_at(dest, dest_index, size), builtin__vsort_ptr_at(source, left_index, size), ((isize)((mid - left_index) * size))); | |
| 10625 | + } | |
| 10626 | + if (right_index < right) { | |
| 10627 | + builtin__vmemcpy(builtin__vsort_ptr_at(dest, dest_index, size), builtin__vsort_ptr_at(source, right_index, size), ((isize)((right - right_index) * size))); | |
| 10628 | + } | |
| 10629 | +} | |
| 10630 | +inline VV_LOC void builtin__vqsort(voidptr base, usize nmemb, usize size, int (*sort_cb)(const void* const_a, const void* const_b)) { | |
| 10631 | + if (nmemb < 2 || size == 0) { | |
| 10632 | + return; | |
| 10633 | + } | |
| 10634 | + isize total_size = ((isize)(nmemb * size)); | |
| 10635 | + u8* buffer = builtin___v_malloc(total_size); | |
| 10636 | + voidptr source = base; | |
| 10637 | + voidptr dest = ((voidptr)(buffer)); | |
| 10638 | + usize width = ((usize)(1)); | |
| 10639 | + for (;;) { | |
| 10640 | + if (!(width < nmemb)) break; | |
| 10641 | + usize left = ((usize)(0)); | |
| 10642 | + for (;;) { | |
| 10643 | + if (!(left < nmemb)) break; | |
| 10644 | + usize mid = (left + width < nmemb ? (left + width) : (nmemb)); | |
| 10645 | + usize right = (left + width + width < nmemb ? (left + width + width) : (nmemb)); | |
| 10646 | + builtin__vstable_sort_merge(source, dest, left, mid, right, size, sort_cb); | |
| 10647 | + left += width + width; | |
| 10648 | + } | |
| 10649 | + voidptr tmp = source; | |
| 10650 | + source = dest; | |
| 10651 | + dest = tmp; | |
| 10652 | + width += width; | |
| 10653 | + } | |
| 10654 | + if (source != base) { | |
| 10655 | + builtin__vmemcpy(base, source, total_size); | |
| 10656 | + } | |
| 10657 | + { // defer begin | |
| 10658 | + builtin___v_free(buffer); | |
| 10659 | + } // defer end | |
| 10660 | +} | |
| 10661 | +void builtin__chan_close(chan ch, Array_IError err) { | |
| 10662 | +} | |
| 10663 | +ChanState builtin__chan_try_pop(chan ch, voidptr obj) { | |
| 10664 | + return ChanState__success; | |
| 10665 | +} | |
| 10666 | +ChanState builtin__chan_try_push(chan ch, voidptr obj) { | |
| 10667 | + return ChanState__success; | |
| 10668 | +} | |
| 10669 | +VV_LOC void builtin___result_ok(voidptr data, _result* res, int size) { | |
| 10670 | + { // Unsafe block | |
| 10671 | + *res = ((_result){.is_error = 0,.err = _const_none__,}); | |
| 10672 | + builtin__vmemcpy(((u8*)(&res->err)) + sizeof(IError), data, size); | |
| 10673 | + } | |
| 10674 | +} | |
| 10675 | +VV_LOC void builtin___result_clone(_result* current, _result* res, int size) { | |
| 10676 | + { // Unsafe block | |
| 10677 | + *res = ((_result){.is_error = current->is_error,.err = current->err,}); | |
| 10678 | + builtin__vmemcpy(((u8*)(&res->err)) + sizeof(IError), ((u8*)(¤t->err)) + sizeof(IError), size); | |
| 10679 | + } | |
| 10680 | +} | |
| 10681 | +string builtin__IError_str(IError err) { | |
| 10682 | + if ((err)._typ == _IError_None___index) { | |
| 10683 | + return _S("none"); | |
| 10684 | + } | |
| 10685 | + int c = ((struct _IError_interface_methods*)(err._methods))->_method_code(err._object); | |
| 10686 | + if (c > 0) { | |
| 10687 | + return builtin__string_plus_many(3, _MOV((string[3]){((struct _IError_interface_methods*)(err._methods))->_method_msg(err._object), _S("; code: "), builtin__int_str(c)})); | |
| 10688 | + } | |
| 10689 | + return ((struct _IError_interface_methods*)(err._methods))->_method_msg(err._object); | |
| 10690 | +} | |
| 10691 | +string builtin__Error_msg(Error err) { | |
| 10692 | + return _S(""); | |
| 10693 | +} | |
| 10694 | +int builtin__Error_code(Error err) { | |
| 10695 | + return 0; | |
| 10696 | +} | |
| 10697 | +string builtin__MessageError_str(MessageError err) { | |
| 10698 | + if (err.code > 0) { | |
| 10699 | + return builtin__string_plus_many(3, _MOV((string[3]){err.msg, _S("; code: "), builtin__int_str(err.code)})); | |
| 10700 | + } | |
| 10701 | + return err.msg; | |
| 10702 | +} | |
| 10703 | +string builtin__MessageError_msg(MessageError err) { | |
| 10704 | + return err.msg; | |
| 10705 | +} | |
| 10706 | +int builtin__MessageError_code(MessageError err) { | |
| 10707 | + return err.code; | |
| 10708 | +} | |
| 10709 | +void builtin__MessageError_free(MessageError* err) { | |
| 10710 | + builtin__string_free(&err->msg); | |
| 10711 | +} | |
| 10712 | +inline IError builtin___v_error(string message) { | |
| 10713 | + ; | |
| 10714 | + return I_MessageError_to_Interface_IError((HEAP(MessageError, ((MessageError){.msg = message,.code = 0,})))); | |
| 10715 | +} | |
| 10716 | +inline IError builtin__error_with_code(string message, int code) { | |
| 10717 | + ; | |
| 10718 | + MessageError* _t2 = (MessageError*)builtin___v_malloc(sizeof(MessageError) == 0 ? 1 : sizeof(MessageError)); | |
| 10719 | + _t2->msg = message; | |
| 10720 | + _t2->code = code; | |
| 10721 | + return I_MessageError_to_Interface_IError( _t2); | |
| 10722 | +} | |
| 10723 | +VV_LOC void builtin___option_none(voidptr data, _option* option, int size) { | |
| 10724 | + { // Unsafe block | |
| 10725 | + *option = ((_option){.state = 2,.err = _const_none__,}); | |
| 10726 | + builtin__vmemcpy(((u8*)(&option->err)) + sizeof(IError), data, size); | |
| 10727 | + } | |
| 10728 | +} | |
| 10729 | +VV_LOC void builtin___option_ok(voidptr data, _option* option, int size) { | |
| 10730 | + { // Unsafe block | |
| 10731 | + *option = ((_option){.state = 0,.err = _const_none__,}); | |
| 10732 | + builtin__vmemcpy(((u8*)(&option->err)) + sizeof(IError), data, size); | |
| 10733 | + } | |
| 10734 | +} | |
| 10735 | +VV_LOC void builtin___option_clone(_option* current, _option* option, int size) { | |
| 10736 | + { // Unsafe block | |
| 10737 | + *option = ((_option){.state = current->state,.err = current->err,}); | |
| 10738 | + builtin__vmemcpy(((u8*)(&option->err)) + sizeof(IError), ((u8*)(¤t->err)) + sizeof(IError), size); | |
| 10739 | + } | |
| 10740 | +} | |
| 10741 | +VV_LOC void builtin___result_ok_markused(void) { | |
| 10742 | + _result _t1 = ((_result){.is_error = 0,.err = _const_none__,}); | |
| 10743 | + _result res = _t1; | |
| 10744 | + builtin___result_ok(((void*)0), (voidptr)&res, 0); | |
| 10745 | +} | |
| 10746 | +VV_LOC string builtin__None___str(None__ _d1) { | |
| 10747 | + return _S("none"); | |
| 10748 | +} | |
| 10749 | +string builtin__none_str(none _d1) { | |
| 10750 | + return _S("none"); | |
| 10751 | +} | |
| 10752 | +int builtin__input_character(void) { | |
| 10753 | + int ch = 0; | |
| 10754 | + #if 0 | |
| 10755 | + { | |
| 10756 | + } | |
| 10757 | + #elif 0 | |
| 10758 | + { | |
| 10759 | + } | |
| 10760 | + #else | |
| 10761 | + { | |
| 10762 | + ch = getchar(); | |
| 10763 | + if (ch == EOF) { | |
| 10764 | + return -1; | |
| 10765 | + } | |
| 10766 | + } | |
| 10767 | + #endif | |
| 10768 | + return ch; | |
| 10769 | +} | |
| 10770 | +int builtin__print_character(u8 ch) { | |
| 10771 | + #if 0 | |
| 10772 | + { | |
| 10773 | + } | |
| 10774 | + #elif 0 | |
| 10775 | + { | |
| 10776 | + } | |
| 10777 | + #elif 0 | |
| 10778 | + { | |
| 10779 | + } | |
| 10780 | + #else | |
| 10781 | + { | |
| 10782 | + i32 x = putchar(ch); | |
| 10783 | + if (x == EOF) { | |
| 10784 | + return -1; | |
| 10785 | + } | |
| 10786 | + } | |
| 10787 | + #endif | |
| 10788 | + return ch; | |
| 10789 | +} | |
| 10790 | +#if !defined(CUSTOM_DEFINE_nofloat) | |
| 10791 | +#endif | |
| 10792 | +inline string builtin__f64_str(f64 x) { | |
| 10793 | + { // Unsafe block | |
| 10794 | + strconv__Float64u _t1 = ((strconv__Float64u){.f = x,}); | |
| 10795 | + strconv__Float64u f = _t1; | |
| 10796 | + if (f.u == _const_strconv__double_minus_zero) { | |
| 10797 | + return _S("-0.0"); | |
| 10798 | + } | |
| 10799 | + if (f.u == _const_strconv__double_plus_zero) { | |
| 10800 | + return _S("0.0"); | |
| 10801 | + } | |
| 10802 | + } | |
| 10803 | + f64 abs_x = builtin__f64_abs(x); | |
| 10804 | + if (abs_x >= ((f64)(0.0001)) && abs_x < ((f64)(1.0e6))) { | |
| 10805 | + return strconv__f64_to_str_l(x); | |
| 10806 | + } else { | |
| 10807 | + return strconv__ftoa_64(x); | |
| 10808 | + } | |
| 10809 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 10810 | +} | |
| 10811 | +inline string builtin__f64_strg(f64 x) { | |
| 10812 | + { // Unsafe block | |
| 10813 | + strconv__Float64u _t1 = ((strconv__Float64u){.f = x,}); | |
| 10814 | + strconv__Float64u f = _t1; | |
| 10815 | + if (f.u == _const_strconv__double_minus_zero || f.u == _const_strconv__double_plus_zero) { | |
| 10816 | + return _S("0.0"); | |
| 10817 | + } | |
| 10818 | + } | |
| 10819 | + f64 abs_x = builtin__f64_abs(x); | |
| 10820 | + if (abs_x >= ((f64)(0.0001)) && abs_x < ((f64)(1.0e6))) { | |
| 10821 | + return strconv__f64_to_str_l_with_dot(x); | |
| 10822 | + } else { | |
| 10823 | + return strconv__ftoa_64(x); | |
| 10824 | + } | |
| 10825 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 10826 | +} | |
| 10827 | +inline string builtin__float_literal_str(float_literal d) { | |
| 10828 | + return builtin__f64_str(((f64)(d))); | |
| 10829 | +} | |
| 10830 | +inline string builtin__f64_strsci(f64 x, int digit_num) { | |
| 10831 | + int n_digit = digit_num; | |
| 10832 | + if (n_digit < 1) { | |
| 10833 | + n_digit = 1; | |
| 10834 | + } else if (n_digit > 17) { | |
| 10835 | + n_digit = 17; | |
| 10836 | + } | |
| 10837 | + return strconv__f64_to_str(x, n_digit); | |
| 10838 | +} | |
| 10839 | +inline string builtin__f64_strlong(f64 x) { | |
| 10840 | + return strconv__f64_to_str_l(x); | |
| 10841 | +} | |
| 10842 | +inline string builtin__f32_str(f32 x) { | |
| 10843 | + { // Unsafe block | |
| 10844 | + strconv__Float32u _t1 = ((strconv__Float32u){.f = x,}); | |
| 10845 | + strconv__Float32u f = _t1; | |
| 10846 | + if (f.u == _const_strconv__single_minus_zero) { | |
| 10847 | + return _S("-0.0"); | |
| 10848 | + } | |
| 10849 | + if (f.u == _const_strconv__single_plus_zero) { | |
| 10850 | + return _S("0.0"); | |
| 10851 | + } | |
| 10852 | + } | |
| 10853 | + f32 abs_x = builtin__f32_abs(x); | |
| 10854 | + if (abs_x >= ((f32)(0.0001)) && abs_x < ((f32)(1.0e6))) { | |
| 10855 | + return strconv__f32_to_str_l(x); | |
| 10856 | + } else { | |
| 10857 | + return strconv__ftoa_32(x); | |
| 10858 | + } | |
| 10859 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 10860 | +} | |
| 10861 | +inline string builtin__f32_strg(f32 x) { | |
| 10862 | + { // Unsafe block | |
| 10863 | + strconv__Float32u _t1 = ((strconv__Float32u){.f = x,}); | |
| 10864 | + strconv__Float32u f = _t1; | |
| 10865 | + if (f.u == _const_strconv__single_minus_zero || f.u == _const_strconv__single_plus_zero) { | |
| 10866 | + return _S("0.0"); | |
| 10867 | + } | |
| 10868 | + } | |
| 10869 | + f32 abs_x = builtin__f32_abs(x); | |
| 10870 | + if (abs_x >= ((f32)(0.0001)) && abs_x < ((f32)(1.0e6))) { | |
| 10871 | + return strconv__f32_to_str_l_with_dot(x); | |
| 10872 | + } else { | |
| 10873 | + return strconv__ftoa_32(x); | |
| 10874 | + } | |
| 10875 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 10876 | +} | |
| 10877 | +inline string builtin__f32_strsci(f32 x, int digit_num) { | |
| 10878 | + int n_digit = digit_num; | |
| 10879 | + if (n_digit < 1) { | |
| 10880 | + n_digit = 1; | |
| 10881 | + } else if (n_digit > 8) { | |
| 10882 | + n_digit = 8; | |
| 10883 | + } | |
| 10884 | + return strconv__f32_to_str(x, n_digit); | |
| 10885 | +} | |
| 10886 | +inline string builtin__f32_strlong(f32 x) { | |
| 10887 | + return strconv__f32_to_str_l(x); | |
| 10888 | +} | |
| 10889 | +inline f32 builtin__f32_abs(f32 a) { | |
| 10890 | + if (a < 0) { | |
| 10891 | + return -a; | |
| 10892 | + } | |
| 10893 | + return a; | |
| 10894 | +} | |
| 10895 | +inline f64 builtin__f64_abs(f64 a) { | |
| 10896 | + if (a < 0) { | |
| 10897 | + return -a; | |
| 10898 | + } | |
| 10899 | + return a; | |
| 10900 | +} | |
| 10901 | +inline f32 builtin__f32_min(f32 a, f32 b) { | |
| 10902 | + if (a < b) { | |
| 10903 | + return a; | |
| 10904 | + } | |
| 10905 | + return b; | |
| 10906 | +} | |
| 10907 | +inline f32 builtin__f32_max(f32 a, f32 b) { | |
| 10908 | + if (a > b) { | |
| 10909 | + return a; | |
| 10910 | + } | |
| 10911 | + return b; | |
| 10912 | +} | |
| 10913 | +inline f64 builtin__f64_min(f64 a, f64 b) { | |
| 10914 | + if (a < b) { | |
| 10915 | + return a; | |
| 10916 | + } | |
| 10917 | + return b; | |
| 10918 | +} | |
| 10919 | +inline f64 builtin__f64_max(f64 a, f64 b) { | |
| 10920 | + if (a > b) { | |
| 10921 | + return a; | |
| 10922 | + } | |
| 10923 | + return b; | |
| 10924 | +} | |
| 10925 | +inline bool builtin__f32_eq_epsilon(f32 a, f32 b) { | |
| 10926 | + f32 hi = builtin__f32_max(builtin__f32_abs(a), builtin__f32_abs(b)); | |
| 10927 | + f32 delta = builtin__f32_abs(a - b); | |
| 10928 | + if (hi > ((f32)(1.0))) { | |
| 10929 | + return delta <= hi * (4 * ((f32)(FLT_EPSILON))); | |
| 10930 | + } else { | |
| 10931 | + return (1 / (4 * ((f32)(FLT_EPSILON)))) * delta <= hi; | |
| 10932 | + } | |
| 10933 | + return 0; | |
| 10934 | +} | |
| 10935 | +inline bool builtin__f64_eq_epsilon(f64 a, f64 b) { | |
| 10936 | + f64 hi = builtin__f64_max(builtin__f64_abs(a), builtin__f64_abs(b)); | |
| 10937 | + f64 delta = builtin__f64_abs(a - b); | |
| 10938 | + if (hi > ((f64)(1.0))) { | |
| 10939 | + return delta <= hi * (4 * ((f64)(DBL_EPSILON))); | |
| 10940 | + } else { | |
| 10941 | + return (1 / (4 * ((f64)(DBL_EPSILON)))) * delta <= hi; | |
| 10942 | + } | |
| 10943 | + return 0; | |
| 10944 | +} | |
| 10945 | +inline VV_LOC u32 builtin__grapheme_hex_nibble(u8 c) { | |
| 10946 | + return (c <= '9' ? (((u32)((rune)(c - '0')))) : (((u32)((rune)(((c | 0x20)) - 'a') + 10)))); | |
| 10947 | +} | |
| 10948 | +inline VV_LOC u32 builtin__grapheme_hex_byte(string ranges, int i) { | |
| 10949 | + return ((v__lshift_u32(builtin__grapheme_hex_nibble(builtin__string_at(ranges, i)), (u64)4)) | builtin__grapheme_hex_nibble(builtin__string_at(ranges, i + 1))); | |
| 10950 | +} | |
| 10951 | +inline VV_LOC u32 builtin__grapheme_range_value(string ranges, int value_idx) { | |
| 10952 | + int i = value_idx * 8; | |
| 10953 | + u32 b0 = builtin__grapheme_hex_byte(ranges, i); | |
| 10954 | + u32 b1 = builtin__grapheme_hex_byte(ranges, i + 2); | |
| 10955 | + u32 b2 = builtin__grapheme_hex_byte(ranges, i + 4); | |
| 10956 | + u32 b3 = builtin__grapheme_hex_byte(ranges, i + 6); | |
| 10957 | + return (((b0 | (v__lshift_u32(b1, (u64)8))) | (v__lshift_u32(b2, (u64)16))) | (v__lshift_u32(b3, (u64)24))); | |
| 10958 | +} | |
| 10959 | +inline VV_LOC bool builtin__in_grapheme_ranges(rune r, string ranges) { | |
| 10960 | + u32 target = ((u32)(r)); | |
| 10961 | + int low = 0; | |
| 10962 | + int high = VSAFE_DIV_int(ranges.len , 16); | |
| 10963 | + for (;;) { | |
| 10964 | + if (!(low < high)) break; | |
| 10965 | + int mid = low + VSAFE_DIV_int((high - low) , 2); | |
| 10966 | + u32 lo = builtin__grapheme_range_value(ranges, mid * 2); | |
| 10967 | + u32 hi = builtin__grapheme_range_value(ranges, mid * 2 + 1); | |
| 10968 | + if (target < lo) { | |
| 10969 | + high = mid; | |
| 10970 | + } else if (target > hi) { | |
| 10971 | + low = mid + 1; | |
| 10972 | + } else { | |
| 10973 | + return true; | |
| 10974 | + } | |
| 10975 | + } | |
| 10976 | + return false; | |
| 10977 | +} | |
| 10978 | +inline VV_LOC GraphemeBreakProperty builtin__grapheme_break_property(rune r) { | |
| 10979 | + if (r == '\r') { | |
| 10980 | + return GraphemeBreakProperty__cr; | |
| 10981 | + } | |
| 10982 | + if (r == '\n') { | |
| 10983 | + return GraphemeBreakProperty__lf; | |
| 10984 | + } | |
| 10985 | + if (r == 0x200d) { | |
| 10986 | + return GraphemeBreakProperty__zwj; | |
| 10987 | + } | |
| 10988 | + if (r >= 0x1f1e6 && r <= 0x1f1ff) { | |
| 10989 | + return GraphemeBreakProperty__regional_indicator; | |
| 10990 | + } | |
| 10991 | + if (r >= 0xac00 && r <= 0xd7a3) { | |
| 10992 | + return (VSAFE_MOD_u32((((u32)(r)) - 0xac00) , 28) == 0 ? (GraphemeBreakProperty__lv) : (GraphemeBreakProperty__lvt)); | |
| 10993 | + } | |
| 10994 | + if ((r >= 0x1100 && r <= 0x115f) || (r >= 0xa960 && r <= 0xa97c)) { | |
| 10995 | + return GraphemeBreakProperty__l; | |
| 10996 | + } | |
| 10997 | + if ((r >= 0x1160 && r <= 0x11a7) || (r >= 0xd7b0 && r <= 0xd7c6)) { | |
| 10998 | + return GraphemeBreakProperty__v; | |
| 10999 | + } | |
| 11000 | + if ((r >= 0x11a8 && r <= 0x11ff) || (r >= 0xd7cb && r <= 0xd7fb)) { | |
| 11001 | + return GraphemeBreakProperty__t; | |
| 11002 | + } | |
| 11003 | + if (builtin__in_grapheme_ranges(r, _const_grapheme_control_ranges)) { | |
| 11004 | + return GraphemeBreakProperty__control; | |
| 11005 | + } | |
| 11006 | + if (builtin__in_grapheme_ranges(r, _const_grapheme_extend_ranges)) { | |
| 11007 | + return GraphemeBreakProperty__extend; | |
| 11008 | + } | |
| 11009 | + if (builtin__in_grapheme_ranges(r, _const_grapheme_spacing_mark_ranges)) { | |
| 11010 | + return GraphemeBreakProperty__spacing_mark; | |
| 11011 | + } | |
| 11012 | + if (builtin__in_grapheme_ranges(r, _const_grapheme_prepend_ranges)) { | |
| 11013 | + return GraphemeBreakProperty__prepend; | |
| 11014 | + } | |
| 11015 | + return GraphemeBreakProperty__other; | |
| 11016 | +} | |
| 11017 | +inline VV_LOC bool builtin__is_extended_pictographic(rune r) { | |
| 11018 | + return builtin__in_grapheme_ranges(r, _const_grapheme_extended_pictographic_ranges); | |
| 11019 | +} | |
| 11020 | +inline VV_LOC GraphemeState builtin__grapheme_state_from_rune(rune r, GraphemeBreakProperty prop) { | |
| 11021 | + return ((GraphemeState){.prev_prop = prop,.ri_count = (prop == GraphemeBreakProperty__regional_indicator ? (1) : (0)),.extended_pictographic_state = (builtin__is_extended_pictographic(r) ? (((u8)(1))) : (((u8)(0)))),}); | |
| 11022 | +} | |
| 11023 | +inline VV_LOC void builtin__GraphemeState_push(GraphemeState* gs, rune r, GraphemeBreakProperty prop) { | |
| 11024 | + gs->prev_prop = prop; | |
| 11025 | + gs->ri_count = (prop == GraphemeBreakProperty__regional_indicator ? (gs->ri_count + 1) : (0)); | |
| 11026 | + if (builtin__is_extended_pictographic(r)) { | |
| 11027 | + gs->extended_pictographic_state = 1; | |
| 11028 | + } else if (prop == GraphemeBreakProperty__extend && gs->extended_pictographic_state == 1) { | |
| 11029 | + } else if (prop == GraphemeBreakProperty__zwj && gs->extended_pictographic_state == 1) { | |
| 11030 | + gs->extended_pictographic_state = 2; | |
| 11031 | + } else { | |
| 11032 | + gs->extended_pictographic_state = 0; | |
| 11033 | + } | |
| 11034 | +} | |
| 11035 | +inline VV_LOC bool builtin__should_break_grapheme(GraphemeState gs, rune r, GraphemeBreakProperty prop) { | |
| 11036 | + switch (gs.prev_prop) { | |
| 11037 | + case GraphemeBreakProperty__cr: { | |
| 11038 | + if (prop == GraphemeBreakProperty__lf) { | |
| 11039 | + return false; | |
| 11040 | + } | |
| 11041 | + return true; | |
| 11042 | + } | |
| 11043 | + case GraphemeBreakProperty__lf: case GraphemeBreakProperty__control: { | |
| 11044 | + return true; | |
| 11045 | + } | |
| 11046 | + case GraphemeBreakProperty__l: { | |
| 11047 | + if (prop == GraphemeBreakProperty__l || prop == GraphemeBreakProperty__v || prop == GraphemeBreakProperty__lv || prop == GraphemeBreakProperty__lvt) { | |
| 11048 | + return false; | |
| 11049 | + } | |
| 11050 | + break; | |
| 11051 | + } | |
| 11052 | + case GraphemeBreakProperty__lv: case GraphemeBreakProperty__v: { | |
| 11053 | + if (prop == GraphemeBreakProperty__v || prop == GraphemeBreakProperty__t) { | |
| 11054 | + return false; | |
| 11055 | + } | |
| 11056 | + break; | |
| 11057 | + } | |
| 11058 | + case GraphemeBreakProperty__lvt: case GraphemeBreakProperty__t: { | |
| 11059 | + if (prop == GraphemeBreakProperty__t) { | |
| 11060 | + return false; | |
| 11061 | + } | |
| 11062 | + break; | |
| 11063 | + } | |
| 11064 | + case GraphemeBreakProperty__prepend: { | |
| 11065 | + return false; | |
| 11066 | + } | |
| 11067 | + case GraphemeBreakProperty__regional_indicator: { | |
| 11068 | + if (prop == GraphemeBreakProperty__regional_indicator && VSAFE_MOD_int(gs.ri_count , 2) == 1) { | |
| 11069 | + return false; | |
| 11070 | + } | |
| 11071 | + break; | |
| 11072 | + } | |
| 11073 | + case GraphemeBreakProperty__other: | |
| 11074 | + case GraphemeBreakProperty__extend: | |
| 11075 | + case GraphemeBreakProperty__spacing_mark: | |
| 11076 | + case GraphemeBreakProperty__zwj: | |
| 11077 | + default: { | |
| 11078 | + { | |
| 11079 | + break; | |
| 11080 | + } | |
| 11081 | + } | |
| 11082 | + } | |
| 11083 | + | |
| 11084 | + if (prop == GraphemeBreakProperty__cr || prop == GraphemeBreakProperty__lf || prop == GraphemeBreakProperty__control) { | |
| 11085 | + return true; | |
| 11086 | + } | |
| 11087 | + if (prop == GraphemeBreakProperty__extend || prop == GraphemeBreakProperty__zwj || prop == GraphemeBreakProperty__spacing_mark) { | |
| 11088 | + return false; | |
| 11089 | + } | |
| 11090 | + if (gs.extended_pictographic_state == 2 && builtin__is_extended_pictographic(r)) { | |
| 11091 | + return false; | |
| 11092 | + } | |
| 11093 | + return true; | |
| 11094 | +} | |
| 11095 | +inline VV_LOC int builtin__utf8_rune_visible_width(rune r, GraphemeBreakProperty prop) { | |
| 11096 | + if (prop == GraphemeBreakProperty__extend || prop == GraphemeBreakProperty__zwj || prop == GraphemeBreakProperty__spacing_mark || prop == GraphemeBreakProperty__prepend) { | |
| 11097 | + return 0; | |
| 11098 | + } | |
| 11099 | + if (r >= 0x1100 && (r <= 0x115f || r == 0x2329 || r == 0x232a || (r >= 0x2e80 && r <= 0xa4cf && r != 0x303f) || (r >= 0xac00 && r <= 0xd7a3) || (r >= 0xf900 && r <= 0xfaff) || (r >= 0xfe10 && r <= 0xfe19) || (r >= 0xfe30 && r <= 0xfe6f) || (r >= 0xff00 && r <= 0xff60) || (r >= 0xffe0 && r <= 0xffe6) || (r >= 0x1f300 && r <= 0x1f64f) || (r >= 0x1f680 && r <= 0x1f6ff) || (r >= 0x1f900 && r <= 0x1f9ff) || (r >= 0x1fa70 && r <= 0x1faff) || (r >= 0x20000 && r <= 0x3fffd))) { | |
| 11100 | + return 2; | |
| 11101 | + } | |
| 11102 | + return 1; | |
| 11103 | +} | |
| 11104 | +VV_LOC Array_string builtin__string_graphemes_impl(string s) { | |
| 11105 | + Array_rune runes = builtin__string_runes(s); | |
| 11106 | + if (runes.len == 0) { | |
| 11107 | + return builtin____new_array_with_default(0, 0, sizeof(string), 0); | |
| 11108 | + } | |
| 11109 | + Array_string res = builtin____new_array_with_default(0, runes.len, sizeof(string), 0); | |
| 11110 | + Array_rune cluster = builtin____new_array_with_default(0, 4, sizeof(rune), 0); | |
| 11111 | + GraphemeBreakProperty first_prop = builtin__grapheme_break_property((*(rune*)builtin__array_get(runes, 0))); | |
| 11112 | + GraphemeState state = builtin__grapheme_state_from_rune((*(rune*)builtin__array_get(runes, 0)), first_prop); | |
| 11113 | + builtin__array_push((array*)&cluster, _MOV((rune[]){ (*(rune*)builtin__array_get(runes, 0)) })); | |
| 11114 | + Array_rune _t3 = builtin__array_slice(runes, 1, 2147483647); | |
| 11115 | + for (int _t4 = 0; _t4 < _t3.len; ++_t4) { | |
| 11116 | + rune r = ((rune*)_t3.data)[_t4]; | |
| 11117 | + GraphemeBreakProperty prop = builtin__grapheme_break_property(r); | |
| 11118 | + if (builtin__should_break_grapheme(state, r, prop)) { | |
| 11119 | + builtin__array_push((array*)&res, _MOV((string[]){ Array_rune_string(cluster) })); | |
| 11120 | + cluster = builtin____new_array_with_default(0, 4, sizeof(rune), 0); | |
| 11121 | + builtin__array_push((array*)&cluster, _MOV((rune[]){ r })); | |
| 11122 | + state = builtin__grapheme_state_from_rune(r, prop); | |
| 11123 | + continue; | |
| 11124 | + } | |
| 11125 | + builtin__array_push((array*)&cluster, _MOV((rune[]){ r })); | |
| 11126 | + builtin__GraphemeState_push(&state, r, prop); | |
| 11127 | + } | |
| 11128 | + builtin__array_push((array*)&res, _MOV((string[]){ Array_rune_string(cluster) })); | |
| 11129 | + return res; | |
| 11130 | +} | |
| 11131 | +inline VV_LOC int builtin__utf8_grapheme_visible_length(string s) { | |
| 11132 | + Array_rune runes = builtin__string_runes(s); | |
| 11133 | + if (runes.len == 0) { | |
| 11134 | + return 0; | |
| 11135 | + } | |
| 11136 | + GraphemeBreakProperty first_prop = builtin__grapheme_break_property((*(rune*)builtin__array_get(runes, 0))); | |
| 11137 | + GraphemeState state = builtin__grapheme_state_from_rune((*(rune*)builtin__array_get(runes, 0)), first_prop); | |
| 11138 | + int total = 0; | |
| 11139 | + int cluster_width = builtin__utf8_rune_visible_width((*(rune*)builtin__array_get(runes, 0)), first_prop); | |
| 11140 | + Array_rune _t2 = builtin__array_slice(runes, 1, 2147483647); | |
| 11141 | + for (int _t3 = 0; _t3 < _t2.len; ++_t3) { | |
| 11142 | + rune r = ((rune*)_t2.data)[_t3]; | |
| 11143 | + GraphemeBreakProperty prop = builtin__grapheme_break_property(r); | |
| 11144 | + if (builtin__should_break_grapheme(state, r, prop)) { | |
| 11145 | + total += cluster_width; | |
| 11146 | + cluster_width = builtin__utf8_rune_visible_width(r, prop); | |
| 11147 | + state = builtin__grapheme_state_from_rune(r, prop); | |
| 11148 | + continue; | |
| 11149 | + } | |
| 11150 | + int rune_width = builtin__utf8_rune_visible_width(r, prop); | |
| 11151 | + if (rune_width > cluster_width) { | |
| 11152 | + cluster_width = rune_width; | |
| 11153 | + } | |
| 11154 | + builtin__GraphemeState_push(&state, r, prop); | |
| 11155 | + } | |
| 11156 | + return total + cluster_width; | |
| 11157 | +} | |
| 11158 | +_option_rune builtin__input_rune(void) { | |
| 11159 | + int x = builtin__input_character(); | |
| 11160 | + if (x <= 0) { | |
| 11161 | + return (_option_rune){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | |
| 11162 | + } | |
| 11163 | + int char_len = builtin__utf8_char_len(((u8)(x))); | |
| 11164 | + if (char_len == 1) { | |
| 11165 | + _option_rune _t2; | |
| 11166 | + builtin___option_ok(&(rune[]) { x }, (_option*)(&_t2), sizeof(rune)); | |
| 11167 | + | |
| 11168 | + return _t2; | |
| 11169 | + } | |
| 11170 | + u8 b = ((u8)(x)); | |
| 11171 | + b = v__lshift_u8(b, (u64)char_len); | |
| 11172 | + rune res = ((rune)(b)); | |
| 11173 | + int shift = 6 - char_len; | |
| 11174 | + for (int i = 1; i < char_len; i++) { | |
| 11175 | + rune c = ((rune)(builtin__input_character())); | |
| 11176 | + res = v__lshift_rune(((rune)(res)), (u64)shift); | |
| 11177 | + res |= (c & 63); | |
| 11178 | + shift = 6; | |
| 11179 | + } | |
| 11180 | + _option_rune _t3; | |
| 11181 | + builtin___option_ok(&(rune[]) { res }, (_option*)(&_t3), sizeof(rune)); | |
| 11182 | + | |
| 11183 | + return _t3; | |
| 11184 | +} | |
| 11185 | +_option_rune builtin__InputRuneIterator_next(InputRuneIterator* self) { | |
| 11186 | + return builtin__input_rune(); | |
| 11187 | +} | |
| 11188 | +InputRuneIterator builtin__input_rune_iterator(void) { | |
| 11189 | + return ((InputRuneIterator){E_STRUCT}); | |
| 11190 | +} | |
| 11191 | +string builtin__ptr_str(voidptr ptr) { | |
| 11192 | + string buf1 = builtin__u64_to_hex_no_leading_zeros(((u64)(ptr)), 16); | |
| 11193 | + return buf1; | |
| 11194 | +} | |
| 11195 | +string builtin__isize_str(isize x) { | |
| 11196 | + return builtin__i64_str(((i64)(x))); | |
| 11197 | +} | |
| 11198 | +string builtin__usize_str(usize x) { | |
| 11199 | + return builtin__u64_str(((u64)(x))); | |
| 11200 | +} | |
| 11201 | +string builtin__char_str(char* cptr) { | |
| 11202 | + return builtin__u64_hex(((u64)(cptr))); | |
| 11203 | +} | |
| 11204 | +inline VV_LOC string builtin__int_str_l(int nn, int max) { | |
| 11205 | + { // Unsafe block | |
| 11206 | + i64 n = ((i64)(nn)); | |
| 11207 | + int d = 0; | |
| 11208 | + if (n == 0) { | |
| 11209 | + return _S("0"); | |
| 11210 | + } | |
| 11211 | + #if 0 | |
| 11212 | + { | |
| 11213 | + } | |
| 11214 | + #else | |
| 11215 | + { | |
| 11216 | + if (n == _const_min_i32) { | |
| 11217 | + return _S("-2147483648"); | |
| 11218 | + } | |
| 11219 | + } | |
| 11220 | + #endif | |
| 11221 | + bool is_neg = false; | |
| 11222 | + if (n < 0) { | |
| 11223 | + n = -n; | |
| 11224 | + is_neg = true; | |
| 11225 | + } | |
| 11226 | + int index = max; | |
| 11227 | + u8* buf = builtin__malloc_noscan(max + 1); | |
| 11228 | + buf[index] = 0; | |
| 11229 | + index--; | |
| 11230 | + for (;;) { | |
| 11231 | + if (!(n > 0)) break; | |
| 11232 | + int n1 = ((int)(VSAFE_DIV_i64(n , 100))); | |
| 11233 | + d = ((int)(v__lshift_u32(((u32)(((int)(n)) - (n1 * 100))), (u64)1))); | |
| 11234 | + n = n1; | |
| 11235 | + buf[index] = _const_digit_pairs.str[d]; | |
| 11236 | + index--; | |
| 11237 | + d++; | |
| 11238 | + buf[index] = _const_digit_pairs.str[d]; | |
| 11239 | + index--; | |
| 11240 | + } | |
| 11241 | + index++; | |
| 11242 | + if (d < 20) { | |
| 11243 | + index++; | |
| 11244 | + } | |
| 11245 | + if (is_neg) { | |
| 11246 | + index--; | |
| 11247 | + buf[index] = '-'; | |
| 11248 | + } | |
| 11249 | + int diff = max - index; | |
| 11250 | + builtin__vmemmove(buf, ((voidptr)(buf + index)), diff + 1); | |
| 11251 | + return builtin__tos(buf, diff); | |
| 11252 | + } | |
| 11253 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 11254 | +} | |
| 11255 | +string builtin__i8_str(i8 n) { | |
| 11256 | + return builtin__int_str_l(((int)(n)), 4); | |
| 11257 | +} | |
| 11258 | +string builtin__i16_str(i16 n) { | |
| 11259 | + return builtin__int_str_l(((int)(n)), 6); | |
| 11260 | +} | |
| 11261 | +string builtin__u16_str(u16 n) { | |
| 11262 | + return builtin__int_str_l(((int)(n)), 6); | |
| 11263 | +} | |
| 11264 | +string builtin__i32_str(i32 n) { | |
| 11265 | + return builtin__int_str_l(((int)(n)), 11); | |
| 11266 | +} | |
| 11267 | +string builtin__int_hex_full(int nn) { | |
| 11268 | + return builtin__u64_to_hex(((u64)(nn)), 8); | |
| 11269 | +} | |
| 11270 | +string builtin__int_str(int n) { | |
| 11271 | + #if defined(CUSTOM_DEFINE_new_int) | |
| 11272 | + { | |
| 11273 | + } | |
| 11274 | + #else | |
| 11275 | + { | |
| 11276 | + return builtin__int_str_l(n, 11); | |
| 11277 | + } | |
| 11278 | + #endif | |
| 11279 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 11280 | +} | |
| 11281 | +inline string builtin__u32_str(u32 nn) { | |
| 11282 | + { // Unsafe block | |
| 11283 | + u32 n = nn; | |
| 11284 | + u32 d = ((u32)(0)); | |
| 11285 | + if (n == 0) { | |
| 11286 | + return _S("0"); | |
| 11287 | + } | |
| 11288 | + int max = 10; | |
| 11289 | + u8* buf = builtin__malloc_noscan(max + 1); | |
| 11290 | + int index = max; | |
| 11291 | + buf[index] = 0; | |
| 11292 | + index--; | |
| 11293 | + for (;;) { | |
| 11294 | + if (!(n > 0)) break; | |
| 11295 | + u32 n1 = VSAFE_DIV_u32(n , ((u32)(100))); | |
| 11296 | + d = (v__lshift_u32((n - (n1 * ((u32)(100)))), (u64)((u32)(1)))); | |
| 11297 | + n = n1; | |
| 11298 | + buf[index] = _const_digit_pairs.str[ ((int)(d))]; | |
| 11299 | + index--; | |
| 11300 | + d++; | |
| 11301 | + buf[index] = _const_digit_pairs.str[ ((int)(d))]; | |
| 11302 | + index--; | |
| 11303 | + } | |
| 11304 | + index++; | |
| 11305 | + if (d < ((u32)(20))) { | |
| 11306 | + index++; | |
| 11307 | + } | |
| 11308 | + int diff = max - index; | |
| 11309 | + builtin__vmemmove(buf, ((voidptr)(buf + index)), diff + 1); | |
| 11310 | + return builtin__tos(buf, diff); | |
| 11311 | + } | |
| 11312 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 11313 | +} | |
| 11314 | +inline string builtin__int_literal_str(int_literal n) { | |
| 11315 | + return builtin__impl_i64_to_string(n); | |
| 11316 | +} | |
| 11317 | +inline string builtin__i64_str(i64 nn) { | |
| 11318 | + return builtin__impl_i64_to_string(nn); | |
| 11319 | +} | |
| 11320 | +VV_LOC string builtin__impl_i64_to_string(i64 nn) { | |
| 11321 | + { // Unsafe block | |
| 11322 | + i64 n = nn; | |
| 11323 | + i64 d = ((i64)(0)); | |
| 11324 | + if (n == 0) { | |
| 11325 | + return _S("0"); | |
| 11326 | + } else if (n == _const_min_i64) { | |
| 11327 | + return _S("-9223372036854775808"); | |
| 11328 | + } | |
| 11329 | + int max = 20; | |
| 11330 | + u8* buf = builtin__malloc_noscan(max + 1); | |
| 11331 | + bool is_neg = false; | |
| 11332 | + if (n < 0) { | |
| 11333 | + n = -n; | |
| 11334 | + is_neg = true; | |
| 11335 | + } | |
| 11336 | + int index = max; | |
| 11337 | + buf[index] = 0; | |
| 11338 | + index--; | |
| 11339 | + for (;;) { | |
| 11340 | + if (!(n > 0)) break; | |
| 11341 | + i64 n1 = VSAFE_DIV_i64(n , ((i64)(100))); | |
| 11342 | + d = (v__lshift_u32(((u32)(n - (n1 * ((i64)(100))))), (u64)((i64)(1)))); | |
| 11343 | + n = n1; | |
| 11344 | + buf[index] = _const_digit_pairs.str[ ((int)(d))]; | |
| 11345 | + index--; | |
| 11346 | + d++; | |
| 11347 | + buf[index] = _const_digit_pairs.str[ ((int)(d))]; | |
| 11348 | + index--; | |
| 11349 | + } | |
| 11350 | + index++; | |
| 11351 | + if (d < ((i64)(20))) { | |
| 11352 | + index++; | |
| 11353 | + } | |
| 11354 | + if (is_neg) { | |
| 11355 | + index--; | |
| 11356 | + buf[index] = '-'; | |
| 11357 | + } | |
| 11358 | + int diff = max - index; | |
| 11359 | + builtin__vmemmove(buf, ((voidptr)(buf + index)), diff + 1); | |
| 11360 | + return builtin__tos(buf, diff); | |
| 11361 | + } | |
| 11362 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 11363 | +} | |
| 11364 | +inline string builtin__u64_str(u64 nn) { | |
| 11365 | + { // Unsafe block | |
| 11366 | + u64 n = nn; | |
| 11367 | + u64 d = ((u64)(0)); | |
| 11368 | + if (n == 0) { | |
| 11369 | + return _S("0"); | |
| 11370 | + } | |
| 11371 | + int max = 20; | |
| 11372 | + u8* buf = builtin__malloc_noscan(max + 1); | |
| 11373 | + int index = max; | |
| 11374 | + buf[index] = 0; | |
| 11375 | + index--; | |
| 11376 | + for (;;) { | |
| 11377 | + if (!(n > 0)) break; | |
| 11378 | + u64 n1 = VSAFE_DIV_u64(n , 100); | |
| 11379 | + d = (v__lshift_u64((n - (n1 * 100)), (u64)1)); | |
| 11380 | + n = n1; | |
| 11381 | + buf[index] = _const_digit_pairs.str[ ((int)(d))]; | |
| 11382 | + index--; | |
| 11383 | + d++; | |
| 11384 | + buf[index] = _const_digit_pairs.str[ ((int)(d))]; | |
| 11385 | + index--; | |
| 11386 | + } | |
| 11387 | + index++; | |
| 11388 | + if (d < 20) { | |
| 11389 | + index++; | |
| 11390 | + } | |
| 11391 | + int diff = max - index; | |
| 11392 | + builtin__vmemmove(buf, ((voidptr)(buf + index)), diff + 1); | |
| 11393 | + return builtin__tos(buf, diff); | |
| 11394 | + } | |
| 11395 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 11396 | +} | |
| 11397 | +string builtin__bool_str(bool b) { | |
| 11398 | + if (b) { | |
| 11399 | + return _S("true"); | |
| 11400 | + } | |
| 11401 | + return _S("false"); | |
| 11402 | +} | |
| 11403 | +inline VV_LOC string builtin__u64_to_hex(u64 nn, u8 len) { | |
| 11404 | + u64 n = nn; | |
| 11405 | + Array_fixed_u8_17 buf = {0}; | |
| 11406 | + buf[len] = 0; | |
| 11407 | + int i = 0; | |
| 11408 | + for (i = (len - 1); i >= 0; i--) { | |
| 11409 | + u8 d = ((u8)((n & 0xF))); | |
| 11410 | + buf[i] = (d < 10 ? ((rune)(d + '0')) : ((u8)(d + 87))); | |
| 11411 | + n = v__rshift_u64(n, (u64)4); | |
| 11412 | + } | |
| 11413 | + return builtin__tos(builtin__memdup(&buf[0], (len + 1)), len); | |
| 11414 | +} | |
| 11415 | +inline VV_LOC string builtin__u64_to_hex_no_leading_zeros(u64 nn, u8 len) { | |
| 11416 | + u64 n = nn; | |
| 11417 | + Array_fixed_u8_17 buf = {0}; | |
| 11418 | + buf[len] = 0; | |
| 11419 | + int i = 0; | |
| 11420 | + for (i = (len - 1); i >= 0; i--) { | |
| 11421 | + u8 d = ((u8)((n & 0xF))); | |
| 11422 | + buf[i] = (d < 10 ? ((rune)(d + '0')) : ((u8)(d + 87))); | |
| 11423 | + n = v__rshift_u64(n, (u64)4); | |
| 11424 | + if (n == 0) { | |
| 11425 | + break; | |
| 11426 | + } | |
| 11427 | + } | |
| 11428 | + int res_len = (int)(len - i); | |
| 11429 | + return builtin__tos(builtin__memdup(&buf[i], res_len + 1), res_len); | |
| 11430 | +} | |
| 11431 | +string builtin__u8_hex(u8 nn) { | |
| 11432 | + if (nn == 0) { | |
| 11433 | + return _S("00"); | |
| 11434 | + } | |
| 11435 | + return builtin__u64_to_hex(nn, 2); | |
| 11436 | +} | |
| 11437 | +string builtin__char_hex(char c) { | |
| 11438 | + return builtin__u8_hex(((u8)(c))); | |
| 11439 | +} | |
| 11440 | +string builtin__rune_hex(rune r) { | |
| 11441 | + return builtin__u32_hex(((u32)(r))); | |
| 11442 | +} | |
| 11443 | +string builtin__i8_hex(i8 nn) { | |
| 11444 | + if (nn == 0) { | |
| 11445 | + return _S("00"); | |
| 11446 | + } | |
| 11447 | + return builtin__u64_to_hex(((u64)(nn)), 2); | |
| 11448 | +} | |
| 11449 | +string builtin__u16_hex(u16 nn) { | |
| 11450 | + if (nn == 0) { | |
| 11451 | + return _S("0"); | |
| 11452 | + } | |
| 11453 | + return builtin__u64_to_hex_no_leading_zeros(nn, 4); | |
| 11454 | +} | |
| 11455 | +string builtin__i16_hex(i16 nn) { | |
| 11456 | + return builtin__u16_hex(((u16)(nn))); | |
| 11457 | +} | |
| 11458 | +string builtin__u32_hex(u32 nn) { | |
| 11459 | + if (nn == 0) { | |
| 11460 | + return _S("0"); | |
| 11461 | + } | |
| 11462 | + return builtin__u64_to_hex_no_leading_zeros(nn, 8); | |
| 11463 | +} | |
| 11464 | +string builtin__int_hex(int nn) { | |
| 11465 | + return builtin__u32_hex(((u32)(nn))); | |
| 11466 | +} | |
| 11467 | +string builtin__int_hex2(int n) { | |
| 11468 | + return builtin__string__plus(_S("0x"), builtin__int_hex(n)); | |
| 11469 | +} | |
| 11470 | +string builtin__u64_hex(u64 nn) { | |
| 11471 | + if (nn == 0) { | |
| 11472 | + return _S("0"); | |
| 11473 | + } | |
| 11474 | + return builtin__u64_to_hex_no_leading_zeros(nn, 16); | |
| 11475 | +} | |
| 11476 | +string builtin__i64_hex(i64 nn) { | |
| 11477 | + return builtin__u64_hex(((u64)(nn))); | |
| 11478 | +} | |
| 11479 | +string builtin__int_literal_hex(int_literal nn) { | |
| 11480 | + return builtin__u64_hex(((u64)(nn))); | |
| 11481 | +} | |
| 11482 | +string builtin__voidptr_str(voidptr nn) { | |
| 11483 | + return builtin__string__plus(_S("0x"), builtin__u64_hex(((u64)(nn)))); | |
| 11484 | +} | |
| 11485 | +string builtin__byteptr_str(byteptr nn) { | |
| 11486 | + return builtin__string__plus(_S("0x"), builtin__u64_hex(((u64)(nn)))); | |
| 11487 | +} | |
| 11488 | +string builtin__charptr_str(charptr nn) { | |
| 11489 | + return builtin__string__plus(_S("0x"), builtin__u64_hex(((u64)(nn)))); | |
| 11490 | +} | |
| 11491 | +string builtin__u8_hex_full(u8 nn) { | |
| 11492 | + return builtin__u64_to_hex(((u64)(nn)), 2); | |
| 11493 | +} | |
| 11494 | +string builtin__i8_hex_full(i8 nn) { | |
| 11495 | + return builtin__u64_to_hex(((u64)(nn)), 2); | |
| 11496 | +} | |
| 11497 | +string builtin__u16_hex_full(u16 nn) { | |
| 11498 | + return builtin__u64_to_hex(((u64)(nn)), 4); | |
| 11499 | +} | |
| 11500 | +string builtin__i16_hex_full(i16 nn) { | |
| 11501 | + return builtin__u64_to_hex(((u64)(nn)), 4); | |
| 11502 | +} | |
| 11503 | +string builtin__u32_hex_full(u32 nn) { | |
| 11504 | + return builtin__u64_to_hex(((u64)(nn)), 8); | |
| 11505 | +} | |
| 11506 | +string builtin__i64_hex_full(i64 nn) { | |
| 11507 | + return builtin__u64_to_hex(((u64)(nn)), 16); | |
| 11508 | +} | |
| 11509 | +string builtin__voidptr_hex_full(voidptr nn) { | |
| 11510 | + return builtin__u64_to_hex(((u64)(nn)), 16); | |
| 11511 | +} | |
| 11512 | +string builtin__int_literal_hex_full(int_literal nn) { | |
| 11513 | + return builtin__u64_to_hex(((u64)(nn)), 16); | |
| 11514 | +} | |
| 11515 | +string builtin__u64_hex_full(u64 nn) { | |
| 11516 | + return builtin__u64_to_hex(nn, 16); | |
| 11517 | +} | |
| 11518 | +string builtin__u8_str(u8 b) { | |
| 11519 | + return builtin__int_str_l(((int)(b)), 4); | |
| 11520 | +} | |
| 11521 | +string builtin__u8_ascii_str(u8 b) { | |
| 11522 | + string _t1 = ((string){.str = builtin__malloc_noscan(2), .len = 1}); | |
| 11523 | + string str = _t1; | |
| 11524 | + { // Unsafe block | |
| 11525 | + str.str[0] = b; | |
| 11526 | + str.str[1] = 0; | |
| 11527 | + } | |
| 11528 | + return str; | |
| 11529 | +} | |
| 11530 | +string builtin__u8_str_escaped(u8 b) { | |
| 11531 | + string _t1 = (string){.str=(byteptr)"", .is_lit=1}; | |
| 11532 | + | |
| 11533 | + if (b == (0)) { | |
| 11534 | + _t1 = _S("`\\0`"); | |
| 11535 | + } | |
| 11536 | + else if (b == (7)) { | |
| 11537 | + _t1 = _S("`\\a`"); | |
| 11538 | + } | |
| 11539 | + else if (b == (8)) { | |
| 11540 | + _t1 = _S("`\\b`"); | |
| 11541 | + } | |
| 11542 | + else if (b == (9)) { | |
| 11543 | + _t1 = _S("`\\t`"); | |
| 11544 | + } | |
| 11545 | + else if (b == (10)) { | |
| 11546 | + _t1 = _S("`\\n`"); | |
| 11547 | + } | |
| 11548 | + else if (b == (11)) { | |
| 11549 | + _t1 = _S("`\\v`"); | |
| 11550 | + } | |
| 11551 | + else if (b == (12)) { | |
| 11552 | + _t1 = _S("`\\f`"); | |
| 11553 | + } | |
| 11554 | + else if (b == (13)) { | |
| 11555 | + _t1 = _S("`\\r`"); | |
| 11556 | + } | |
| 11557 | + else if (b == (27)) { | |
| 11558 | + _t1 = _S("`\\e`"); | |
| 11559 | + } | |
| 11560 | + else if ((b >= 32 && b <= 126)) { | |
| 11561 | + _t1 = builtin__u8_ascii_str(b); | |
| 11562 | + } | |
| 11563 | + else { | |
| 11564 | + string xx = builtin__u8_hex(b); | |
| 11565 | + string yy = builtin__string__plus(_S("0x"), xx); | |
| 11566 | + builtin__string_free(&xx); | |
| 11567 | + _t1 = yy; | |
| 11568 | + }string str = _t1; | |
| 11569 | + return str; | |
| 11570 | +} | |
| 11571 | +inline bool builtin__u8_is_capital(u8 c) { | |
| 11572 | + return c >= 'A' && c <= 'Z'; | |
| 11573 | +} | |
| 11574 | +string Array_u8_bytestr(Array_u8 b) { | |
| 11575 | + { // Unsafe block | |
| 11576 | + u8* buf = builtin__malloc_noscan(b.len + 1); | |
| 11577 | + builtin__vmemcpy(buf, b.data, b.len); | |
| 11578 | + buf[b.len] = 0; | |
| 11579 | + return builtin__tos(buf, b.len); | |
| 11580 | + } | |
| 11581 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 11582 | +} | |
| 11583 | +_result_rune Array_u8_byterune(Array_u8 b) { | |
| 11584 | + _result_rune _t1 = Array_u8_utf8_to_utf32(b); | |
| 11585 | + if (_t1.is_error) { | |
| 11586 | + _result_rune _t2 = {0}; | |
| 11587 | + _t2.is_error = true; | |
| 11588 | + _t2.err = _t1.err; | |
| 11589 | + return _t2; | |
| 11590 | + } | |
| 11591 | + | |
| 11592 | + rune r = (*(rune*)_t1.data); | |
| 11593 | + _result_rune _t3; | |
| 11594 | + builtin___result_ok(&(rune[]) { ((rune)(r)) }, (_result*)(&_t3), sizeof(rune)); | |
| 11595 | + | |
| 11596 | + return _t3; | |
| 11597 | +} | |
| 11598 | +string builtin__u8_repeat(u8 b, int count) { | |
| 11599 | + if (count <= 0) { | |
| 11600 | + return _S(""); | |
| 11601 | + } else if (count == 1) { | |
| 11602 | + return builtin__u8_ascii_str(b); | |
| 11603 | + } | |
| 11604 | + u8* bytes = builtin__malloc_noscan(count + 1); | |
| 11605 | + { // Unsafe block | |
| 11606 | + builtin__vmemset(bytes, b, count); | |
| 11607 | + bytes[count] = 0; | |
| 11608 | + } | |
| 11609 | + return builtin__u8_vstring_with_len(bytes, count); | |
| 11610 | +} | |
| 11611 | +inline int builtin__int_min(int a, int b) { | |
| 11612 | + return (a < b ? (a) : (b)); | |
| 11613 | +} | |
| 11614 | +inline int builtin__int_max(int a, int b) { | |
| 11615 | + return (a > b ? (a) : (b)); | |
| 11616 | +} | |
| 11617 | +inline VV_LOC bool builtin__fast_string_eq(string a, string b) { | |
| 11618 | + if (a.len != b.len) { | |
| 11619 | + return false; | |
| 11620 | + } | |
| 11621 | + { // Unsafe block | |
| 11622 | + return memcmp(a.str, b.str, b.len) == 0; | |
| 11623 | + } | |
| 11624 | + return 0; | |
| 11625 | +} | |
| 11626 | +VV_LOC u64 builtin__map_hash_string(voidptr pkey) { | |
| 11627 | + string key = *((string*)(pkey)); | |
| 11628 | + return wyhash(key.str, ((u64)(key.len)), 0, ((u64*)(((voidptr)(_wyp))))); | |
| 11629 | +} | |
| 11630 | +VV_LOC u64 builtin__map_hash_int_1(voidptr pkey) { | |
| 11631 | + return wyhash64(*((u8*)(pkey)), 0); | |
| 11632 | +} | |
| 11633 | +VV_LOC u64 builtin__map_hash_int_2(voidptr pkey) { | |
| 11634 | + return wyhash64(*((u16*)(pkey)), 0); | |
| 11635 | +} | |
| 11636 | +VV_LOC u64 builtin__map_hash_int_4(voidptr pkey) { | |
| 11637 | + return wyhash64(*((u32*)(pkey)), 0); | |
| 11638 | +} | |
| 11639 | +VV_LOC u64 builtin__map_hash_int_8(voidptr pkey) { | |
| 11640 | + return wyhash64(*((u64*)(pkey)), 0); | |
| 11641 | +} | |
| 11642 | +VV_LOC voidptr builtin__map_enum_fn(int kind, int esize) { | |
| 11643 | + if (!(kind == 1 || kind == 2 || kind == 3)) { | |
| 11644 | + builtin___v_panic(_S("map_enum_fn: invalid kind")); | |
| 11645 | + VUNREACHABLE(); | |
| 11646 | + } | |
| 11647 | + if (esize > 8 || esize < 0) { | |
| 11648 | + builtin___v_panic(_S("map_enum_fn: invalid esize")); | |
| 11649 | + VUNREACHABLE(); | |
| 11650 | + } | |
| 11651 | + if (kind == 1) { | |
| 11652 | + if (esize > 4) { | |
| 11653 | + return ((voidptr)(builtin__map_hash_int_8)); | |
| 11654 | + } | |
| 11655 | + if (esize > 2) { | |
| 11656 | + return ((voidptr)(builtin__map_hash_int_4)); | |
| 11657 | + } | |
| 11658 | + if (esize > 1) { | |
| 11659 | + return ((voidptr)(builtin__map_hash_int_2)); | |
| 11660 | + } | |
| 11661 | + if (esize > 0) { | |
| 11662 | + return ((voidptr)(builtin__map_hash_int_1)); | |
| 11663 | + } | |
| 11664 | + } | |
| 11665 | + if (kind == 2) { | |
| 11666 | + if (esize > 4) { | |
| 11667 | + return ((voidptr)(builtin__map_eq_int_8)); | |
| 11668 | + } | |
| 11669 | + if (esize > 2) { | |
| 11670 | + return ((voidptr)(builtin__map_eq_int_4)); | |
| 11671 | + } | |
| 11672 | + if (esize > 1) { | |
| 11673 | + return ((voidptr)(builtin__map_eq_int_2)); | |
| 11674 | + } | |
| 11675 | + if (esize > 0) { | |
| 11676 | + return ((voidptr)(builtin__map_eq_int_1)); | |
| 11677 | + } | |
| 11678 | + } | |
| 11679 | + if (kind == 3) { | |
| 11680 | + if (esize > 4) { | |
| 11681 | + return ((voidptr)(builtin__map_clone_int_8)); | |
| 11682 | + } | |
| 11683 | + if (esize > 2) { | |
| 11684 | + return ((voidptr)(builtin__map_clone_int_4)); | |
| 11685 | + } | |
| 11686 | + if (esize > 1) { | |
| 11687 | + return ((voidptr)(builtin__map_clone_int_2)); | |
| 11688 | + } | |
| 11689 | + if (esize > 0) { | |
| 11690 | + return ((voidptr)(builtin__map_clone_int_1)); | |
| 11691 | + } | |
| 11692 | + } | |
| 11693 | + return ((void*)0); | |
| 11694 | +} | |
| 11695 | +VV_LOC void builtin__DenseArray_zeros_to_end(DenseArray* d) { | |
| 11696 | + u8* tmp_value = builtin___v_malloc(d->value_bytes); | |
| 11697 | + u8* tmp_key = builtin___v_malloc(d->key_bytes); | |
| 11698 | + int count = 0; | |
| 11699 | + for (int i = 0; i < d->len; ++i) { | |
| 11700 | + if (builtin__DenseArray_has_index(d, i)) { | |
| 11701 | + { // Unsafe block | |
| 11702 | + if (count != i) { | |
| 11703 | + memcpy(tmp_key, builtin__DenseArray_key(d, count), d->key_bytes); | |
| 11704 | + memcpy(builtin__DenseArray_key(d, count), builtin__DenseArray_key(d, i), d->key_bytes); | |
| 11705 | + memcpy(builtin__DenseArray_key(d, i), tmp_key, d->key_bytes); | |
| 11706 | + memcpy(tmp_value, builtin__DenseArray_value(d, count), d->value_bytes); | |
| 11707 | + memcpy(builtin__DenseArray_value(d, count), builtin__DenseArray_value(d, i), d->value_bytes); | |
| 11708 | + memcpy(builtin__DenseArray_value(d, i), tmp_value, d->value_bytes); | |
| 11709 | + } | |
| 11710 | + } | |
| 11711 | + count++; | |
| 11712 | + } | |
| 11713 | + } | |
| 11714 | + { // Unsafe block | |
| 11715 | + builtin___v_free(tmp_value); | |
| 11716 | + builtin___v_free(tmp_key); | |
| 11717 | + d->deletes = 0; | |
| 11718 | + builtin___v_free(d->all_deleted); | |
| 11719 | + d->all_deleted = ((void*)0); | |
| 11720 | + } | |
| 11721 | + d->len = count; | |
| 11722 | + int old_cap = d->cap; | |
| 11723 | + if (count < 8) { | |
| 11724 | + d->cap = 8; | |
| 11725 | + } else { | |
| 11726 | + d->cap = count; | |
| 11727 | + } | |
| 11728 | + { // Unsafe block | |
| 11729 | + d->values = builtin__realloc_data(d->values, d->value_bytes * old_cap, d->value_bytes * d->cap); | |
| 11730 | + d->keys = builtin__realloc_data(d->keys, d->key_bytes * old_cap, d->key_bytes * d->cap); | |
| 11731 | + } | |
| 11732 | +} | |
| 11733 | +inline VV_LOC DenseArray builtin__new_dense_array(int key_bytes, int value_bytes) { | |
| 11734 | + int cap = 8; | |
| 11735 | + return ((DenseArray){ | |
| 11736 | + .key_bytes = key_bytes, | |
| 11737 | + .value_bytes = value_bytes, | |
| 11738 | + .cap = cap, | |
| 11739 | + .len = 0, | |
| 11740 | + .deletes = 0, | |
| 11741 | + .all_deleted = ((void*)0), | |
| 11742 | + .keys = builtin___v_malloc(builtin____at_least_one(((u64)(cap)) * ((u64)(key_bytes)))), | |
| 11743 | + .values = builtin___v_malloc(builtin____at_least_one(((u64)(cap)) * ((u64)(value_bytes)))), | |
| 11744 | + }); | |
| 11745 | +} | |
| 11746 | +inline VV_LOC voidptr builtin__DenseArray_key(DenseArray* d, int i) { | |
| 11747 | + return ((voidptr)(d->keys + i * d->key_bytes)); | |
| 11748 | +} | |
| 11749 | +inline VV_LOC voidptr builtin__DenseArray_value(DenseArray* d, int i) { | |
| 11750 | + return ((voidptr)(d->values + i * d->value_bytes)); | |
| 11751 | +} | |
| 11752 | +inline VV_LOC bool builtin__DenseArray_has_index(DenseArray* d, int i) { | |
| 11753 | + return d->deletes == 0 || d->all_deleted[i] == 0; | |
| 11754 | +} | |
| 11755 | +inline VV_LOC void builtin__DenseArray_trim_deleted_tail(DenseArray* d) { | |
| 11756 | + if (d->deletes == 0) { | |
| 11757 | + return; | |
| 11758 | + } | |
| 11759 | + for (;;) { | |
| 11760 | + if (!(d->len > 0 && d->all_deleted[d->len - 1] != 0)) break; | |
| 11761 | + { // Unsafe block | |
| 11762 | + d->all_deleted[d->len - 1] = 0; | |
| 11763 | + } | |
| 11764 | + d->deletes--; | |
| 11765 | + d->len--; | |
| 11766 | + } | |
| 11767 | + if (d->deletes == 0) { | |
| 11768 | + { // Unsafe block | |
| 11769 | + builtin___v_free(d->all_deleted); | |
| 11770 | + d->all_deleted = ((void*)0); | |
| 11771 | + } | |
| 11772 | + } | |
| 11773 | +} | |
| 11774 | +inline VV_LOC int builtin__DenseArray_expand(DenseArray* d) { | |
| 11775 | + int old_cap = d->cap; | |
| 11776 | + int old_key_size = d->key_bytes * old_cap; | |
| 11777 | + int old_value_size = d->value_bytes * old_cap; | |
| 11778 | + if (d->cap == d->len) { | |
| 11779 | + d->cap += v__rshift_int(d->cap, (u64)3); | |
| 11780 | + { // Unsafe block | |
| 11781 | + d->keys = builtin__realloc_data(d->keys, old_key_size, d->key_bytes * d->cap); | |
| 11782 | + d->values = builtin__realloc_data(d->values, old_value_size, d->value_bytes * d->cap); | |
| 11783 | + if (d->deletes != 0) { | |
| 11784 | + d->all_deleted = builtin__realloc_data(d->all_deleted, old_cap, d->cap); | |
| 11785 | + builtin__vmemset(((voidptr)(d->all_deleted + d->len)), 0, d->cap - d->len); | |
| 11786 | + } | |
| 11787 | + } | |
| 11788 | + } | |
| 11789 | + int push_index = d->len; | |
| 11790 | + { // Unsafe block | |
| 11791 | + if (d->deletes != 0) { | |
| 11792 | + d->all_deleted[push_index] = 0; | |
| 11793 | + } | |
| 11794 | + } | |
| 11795 | + d->len++; | |
| 11796 | + return push_index; | |
| 11797 | +} | |
| 11798 | +inline VV_LOC bool builtin__map_eq_string(voidptr a, voidptr b) { | |
| 11799 | + return builtin__fast_string_eq(*((string*)(a)), *((string*)(b))); | |
| 11800 | +} | |
| 11801 | +inline VV_LOC bool builtin__map_eq_int_1(voidptr a, voidptr b) { | |
| 11802 | + return *((u8*)(a)) == *((u8*)(b)); | |
| 11803 | +} | |
| 11804 | +inline VV_LOC bool builtin__map_eq_int_2(voidptr a, voidptr b) { | |
| 11805 | + return *((u16*)(a)) == *((u16*)(b)); | |
| 11806 | +} | |
| 11807 | +inline VV_LOC bool builtin__map_eq_int_4(voidptr a, voidptr b) { | |
| 11808 | + return *((u32*)(a)) == *((u32*)(b)); | |
| 11809 | +} | |
| 11810 | +inline VV_LOC bool builtin__map_eq_int_8(voidptr a, voidptr b) { | |
| 11811 | + return *((u64*)(a)) == *((u64*)(b)); | |
| 11812 | +} | |
| 11813 | +VV_LOC bool builtin__map_map_eq(map a, map b) { | |
| 11814 | + if (a.len != b.len) { | |
| 11815 | + return false; | |
| 11816 | + } | |
| 11817 | + for (int i = 0; i < a.key_values.len; i++) { | |
| 11818 | + if (!builtin__DenseArray_has_index(&a.key_values, i)) { | |
| 11819 | + continue; | |
| 11820 | + } | |
| 11821 | + voidptr k = builtin__DenseArray_key(&a.key_values, i); | |
| 11822 | + if (!builtin__map_exists(&b, k)) { | |
| 11823 | + return false; | |
| 11824 | + } | |
| 11825 | + voidptr va = builtin__DenseArray_value(&a.key_values, i); | |
| 11826 | + voidptr vb = builtin__map_get(&b, k, va); | |
| 11827 | + if (builtin__vmemcmp(va, vb, a.value_bytes) != 0) { | |
| 11828 | + return false; | |
| 11829 | + } | |
| 11830 | + } | |
| 11831 | + return true; | |
| 11832 | +} | |
| 11833 | +inline VV_LOC void builtin__map_clone_string(voidptr dest, voidptr pkey) { | |
| 11834 | + { // Unsafe block | |
| 11835 | + string s = *((string*)(pkey)); | |
| 11836 | + string cloned = builtin__string_clone(s); | |
| 11837 | + builtin__vmemcpy(dest, ((voidptr)(&cloned)), sizeof(string)); | |
| 11838 | + } | |
| 11839 | +} | |
| 11840 | +inline VV_LOC void builtin__map_clone_int_1(voidptr dest, voidptr pkey) { | |
| 11841 | + { // Unsafe block | |
| 11842 | + *((u8*)(dest)) = *((u8*)(pkey)); | |
| 11843 | + } | |
| 11844 | +} | |
| 11845 | +inline VV_LOC void builtin__map_clone_int_2(voidptr dest, voidptr pkey) { | |
| 11846 | + { // Unsafe block | |
| 11847 | + *((u16*)(dest)) = *((u16*)(pkey)); | |
| 11848 | + } | |
| 11849 | +} | |
| 11850 | +inline VV_LOC void builtin__map_clone_int_4(voidptr dest, voidptr pkey) { | |
| 11851 | + { // Unsafe block | |
| 11852 | + *((u32*)(dest)) = *((u32*)(pkey)); | |
| 11853 | + } | |
| 11854 | +} | |
| 11855 | +inline VV_LOC void builtin__map_clone_int_8(voidptr dest, voidptr pkey) { | |
| 11856 | + { // Unsafe block | |
| 11857 | + *((u64*)(dest)) = *((u64*)(pkey)); | |
| 11858 | + } | |
| 11859 | +} | |
| 11860 | +inline VV_LOC void builtin__map_free_string(voidptr pkey) { | |
| 11861 | + builtin__string_free(ADDR(string, (*((string*)(pkey))))); | |
| 11862 | +} | |
| 11863 | +inline VV_LOC void builtin__map_free_nop(voidptr _d1) { | |
| 11864 | +} | |
| 11865 | +VV_LOC map builtin__new_map(int key_bytes, int value_bytes, u64 (*hash_fn)(voidptr _d1), bool (*key_eq_fn)(voidptr _d1, voidptr _d2), void (*clone_fn)(voidptr _d1, voidptr _d2), void (*free_fn)(voidptr _d1)) { | |
| 11866 | + int metasize = ((int)((u32)(sizeof(u32) * (_const_init_capicity + _const_extra_metas_inc)))); | |
| 11867 | + bool has_string_keys = key_bytes > ((int)(sizeof(voidptr))); | |
| 11868 | + return ((map){ | |
| 11869 | + .key_bytes = key_bytes, | |
| 11870 | + .value_bytes = value_bytes, | |
| 11871 | + .even_index = _const_init_even_index, | |
| 11872 | + .cached_hashbits = _const_max_cached_hashbits, | |
| 11873 | + .shift = _const_init_log_capicity, | |
| 11874 | + .key_values = builtin__new_dense_array(key_bytes, value_bytes), | |
| 11875 | + .metas = ((u32*)(builtin__vcalloc_noscan(metasize))), | |
| 11876 | + .extra_metas = _const_extra_metas_inc, | |
| 11877 | + .has_string_keys = has_string_keys, | |
| 11878 | + .hash_fn = hash_fn, | |
| 11879 | + .key_eq_fn = key_eq_fn, | |
| 11880 | + .clone_fn = clone_fn, | |
| 11881 | + .free_fn = free_fn, | |
| 11882 | + .len = 0, | |
| 11883 | + }); | |
| 11884 | +} | |
| 11885 | +VV_LOC map builtin__new_map_init(u64 (*hash_fn)(voidptr _d1), bool (*key_eq_fn)(voidptr _d1, voidptr _d2), void (*clone_fn)(voidptr _d1, voidptr _d2), void (*free_fn)(voidptr _d1), int n, int key_bytes, int value_bytes, voidptr keys, voidptr values) { | |
| 11886 | + map out = builtin__new_map(key_bytes, value_bytes, hash_fn, key_eq_fn, clone_fn, free_fn); | |
| 11887 | + u8* pkey = ((u8*)(keys)); | |
| 11888 | + u8* pval = ((u8*)(values)); | |
| 11889 | + for (int _t1 = 0; _t1 < n; ++_t1) { | |
| 11890 | + { // Unsafe block | |
| 11891 | + builtin__map_set(&out, pkey, pval); | |
| 11892 | + pkey = pkey + key_bytes; | |
| 11893 | + pval = pval + value_bytes; | |
| 11894 | + } | |
| 11895 | + } | |
| 11896 | + return out; | |
| 11897 | +} | |
| 11898 | +map builtin__map_move(map* m) { | |
| 11899 | + map r = *m; | |
| 11900 | + builtin__vmemset(m, 0, ((int)(sizeof(map)))); | |
| 11901 | + return r; | |
| 11902 | +} | |
| 11903 | +void builtin__map_clear(map* m) { | |
| 11904 | + { // Unsafe block | |
| 11905 | + if (m->key_values.all_deleted != 0) { | |
| 11906 | + builtin___v_free(m->key_values.all_deleted); | |
| 11907 | + m->key_values.all_deleted = ((void*)0); | |
| 11908 | + } | |
| 11909 | + builtin__vmemset(m->key_values.keys, 0, m->key_values.key_bytes * m->key_values.cap); | |
| 11910 | + builtin__vmemset(m->metas, 0, sizeof(u32) * (m->even_index + 2 + m->extra_metas)); | |
| 11911 | + } | |
| 11912 | + m->key_values.len = 0; | |
| 11913 | + m->key_values.deletes = 0; | |
| 11914 | + m->even_index = _const_init_even_index; | |
| 11915 | + m->cached_hashbits = _const_max_cached_hashbits; | |
| 11916 | + m->shift = _const_init_log_capicity; | |
| 11917 | + m->len = 0; | |
| 11918 | +} | |
| 11919 | +inline VV_LOC multi_return_u32_u32 builtin__map_key_to_index(map* m, voidptr pkey) { | |
| 11920 | + if (((voidptr)(m->hash_fn)) == ((void*)0)) { | |
| 11921 | + { // Unsafe block | |
| 11922 | + u64* p = ((u64*)(m)); | |
| 11923 | + u64 prev2 = (((u64*)(((usize)(m)) - ((usize)(16)))))[0]; | |
| 11924 | + u64 prev1 = (((u64*)(((usize)(m)) - ((usize)(8)))))[0]; | |
| 11925 | + builtin___v_panic(builtin__string_plus_many(34, _MOV((string[34]){_S("map.hash_fn is nil map_ptr="), builtin__usize_str(((usize)(m))), _S(" key_bytes="), builtin__int_str(m->key_bytes), _S(" value_bytes="), builtin__int_str(m->value_bytes), _S(" even_index="), builtin__u32_str(m->even_index), _S(" shift="), builtin__u8_str(m->shift), _S(" metas="), builtin__usize_str(((usize)(m->metas))), _S(" prev2="), builtin__u64_str(prev2), _S(" prev1="), builtin__u64_str(prev1), _S(" w0="), builtin__u64_str(p[0]), _S(" w1="), builtin__u64_str(p[1]), _S(" w2="), builtin__u64_str(p[2]), _S(" w3="), builtin__u64_str(p[3]), _S(" w4="), builtin__u64_str(p[4]), _S(" w5="), builtin__u64_str(p[5]), _S(" w6="), builtin__u64_str(p[6]), _S(" w7="), builtin__u64_str(p[7]), _S(" hash_fn="), builtin__usize_str(((usize)(((voidptr)(m->hash_fn)))))}))); | |
| 11926 | + VUNREACHABLE(); | |
| 11927 | + } | |
| 11928 | + } | |
| 11929 | + u64 hash = m->hash_fn(pkey); | |
| 11930 | + u64 index = (hash & m->even_index); | |
| 11931 | + u64 meta = ((((v__rshift_u64(hash, (u64)m->shift)) & _const_hash_mask)) | _const_probe_inc); | |
| 11932 | + return (multi_return_u32_u32){.arg0=((u32)(index)), .arg1=((u32)(meta))}; | |
| 11933 | +} | |
| 11934 | +inline VV_LOC multi_return_u32_u32 builtin__map_meta_less(map* m, u32 _index, u32 _metas) { | |
| 11935 | + u32 index = _index; | |
| 11936 | + u32 meta = _metas; | |
| 11937 | + for (;;) { | |
| 11938 | + if (!(meta < m->metas[index])) break; | |
| 11939 | + index += 2; | |
| 11940 | + meta += _const_probe_inc; | |
| 11941 | + } | |
| 11942 | + return (multi_return_u32_u32){.arg0=index, .arg1=meta}; | |
| 11943 | +} | |
| 11944 | +inline VV_LOC void builtin__map_meta_greater(map* m, u32 _index, u32 _metas, u32 kvi) { | |
| 11945 | + u32 meta = _metas; | |
| 11946 | + u32 index = _index; | |
| 11947 | + u32 kv_index = kvi; | |
| 11948 | + for (;;) { | |
| 11949 | + if (!(m->metas[index] != 0)) break; | |
| 11950 | + if (meta > m->metas[index]) { | |
| 11951 | + { // Unsafe block | |
| 11952 | + u32 tmp_meta = m->metas[index]; | |
| 11953 | + m->metas[index] = meta; | |
| 11954 | + meta = tmp_meta; | |
| 11955 | + u32 tmp_index = m->metas[index + 1]; | |
| 11956 | + m->metas[index + 1] = kv_index; | |
| 11957 | + kv_index = tmp_index; | |
| 11958 | + } | |
| 11959 | + } | |
| 11960 | + index += 2; | |
| 11961 | + meta += _const_probe_inc; | |
| 11962 | + if (index + 2 >= m->even_index + 2 + m->extra_metas) { | |
| 11963 | + builtin__map_ensure_extra_metas_grow(m); | |
| 11964 | + } | |
| 11965 | + } | |
| 11966 | + { // Unsafe block | |
| 11967 | + m->metas[index] = meta; | |
| 11968 | + m->metas[index + 1] = kv_index; | |
| 11969 | + } | |
| 11970 | + u32 probe_count = (v__rshift_u32(meta, (u64)_const_hashbits)) - 1; | |
| 11971 | + builtin__map_ensure_extra_metas(m, probe_count); | |
| 11972 | +} | |
| 11973 | +VV_LOC void builtin__map_ensure_extra_metas_grow(map* m) { | |
| 11974 | + u32 size_of_u32 = sizeof(u32); | |
| 11975 | + u32 old_mem_size = (m->even_index + 2 + m->extra_metas); | |
| 11976 | + m->extra_metas += _const_extra_metas_inc; | |
| 11977 | + u32 mem_size = (m->even_index + 2 + m->extra_metas); | |
| 11978 | + { // Unsafe block | |
| 11979 | + u8* x = builtin__realloc_data(((byteptr)(m->metas)), ((int)(size_of_u32 * old_mem_size)), ((int)(size_of_u32 * mem_size))); | |
| 11980 | + m->metas = ((u32*)(x)); | |
| 11981 | + builtin__vmemset(((byteptr)(m->metas)) + (mem_size - _const_extra_metas_inc) * size_of_u32, 0, ((int)(sizeof(u32) * _const_extra_metas_inc))); | |
| 11982 | + } | |
| 11983 | +} | |
| 11984 | +inline VV_LOC void builtin__map_ensure_extra_metas(map* m, u32 probe_count) { | |
| 11985 | + if ((v__lshift_u32(probe_count, (u64)1)) == m->extra_metas) { | |
| 11986 | + u32 size_of_u32 = sizeof(u32); | |
| 11987 | + u32 old_mem_size = (m->even_index + 2 + m->extra_metas); | |
| 11988 | + m->extra_metas += _const_extra_metas_inc; | |
| 11989 | + u32 mem_size = (m->even_index + 2 + m->extra_metas); | |
| 11990 | + { // Unsafe block | |
| 11991 | + u8* x = builtin__realloc_data(((byteptr)(m->metas)), ((int)(size_of_u32 * old_mem_size)), ((int)(size_of_u32 * mem_size))); | |
| 11992 | + m->metas = ((u32*)(x)); | |
| 11993 | + builtin__vmemset(((byteptr)(m->metas)) + (mem_size - _const_extra_metas_inc) * size_of_u32, 0, ((int)(sizeof(u32) * _const_extra_metas_inc))); | |
| 11994 | + } | |
| 11995 | + if (probe_count == 252) { | |
| 11996 | + builtin___v_panic(_S("Probe overflow")); | |
| 11997 | + VUNREACHABLE(); | |
| 11998 | + } | |
| 11999 | + } | |
| 12000 | +} | |
| 12001 | +VV_LOC void builtin__map_set(map* m, voidptr key, voidptr value) { | |
| 12002 | + if (((u32)(5)) * ((u32)(m->len)) > ((u32)(2)) * m->even_index) { | |
| 12003 | + builtin__map_expand(m); | |
| 12004 | + } | |
| 12005 | + multi_return_u32_u32 mr_14546 = builtin__map_key_to_index(m, key); | |
| 12006 | + u32 index = mr_14546.arg0; | |
| 12007 | + u32 meta = mr_14546.arg1; | |
| 12008 | + multi_return_u32_u32 mr_14582 = builtin__map_meta_less(m, index, meta); | |
| 12009 | + index = mr_14582.arg0; | |
| 12010 | + meta = mr_14582.arg1; | |
| 12011 | + for (;;) { | |
| 12012 | + if (!(meta == m->metas[index])) break; | |
| 12013 | + int kv_index = ((int)(m->metas[index + 1])); | |
| 12014 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | |
| 12015 | + if (m->key_eq_fn(key, pkey)) { | |
| 12016 | + { // Unsafe block | |
| 12017 | + voidptr pval = builtin__DenseArray_value(&m->key_values, kv_index); | |
| 12018 | + builtin__vmemcpy(pval, value, m->value_bytes); | |
| 12019 | + } | |
| 12020 | + return; | |
| 12021 | + } | |
| 12022 | + index += 2; | |
| 12023 | + meta += _const_probe_inc; | |
| 12024 | + } | |
| 12025 | + int kv_index = builtin__DenseArray_expand(&m->key_values); | |
| 12026 | + { // Unsafe block | |
| 12027 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | |
| 12028 | + voidptr pvalue = builtin__DenseArray_value(&m->key_values, kv_index); | |
| 12029 | + m->clone_fn(pkey, key); | |
| 12030 | + builtin__vmemcpy(pvalue, value, m->value_bytes); | |
| 12031 | + } | |
| 12032 | + builtin__map_meta_greater(m, index, meta, ((u32)(kv_index))); | |
| 12033 | + m->len++; | |
| 12034 | +} | |
| 12035 | +VV_LOC void builtin__map_expand(map* m) { | |
| 12036 | + u32 old_cap = m->even_index; | |
| 12037 | + m->even_index = (v__lshift_u32((m->even_index + 2), (u64)1)) - 2; | |
| 12038 | + if (m->cached_hashbits == 0) { | |
| 12039 | + m->shift += _const_max_cached_hashbits; | |
| 12040 | + m->cached_hashbits = _const_max_cached_hashbits; | |
| 12041 | + builtin__map_rehash(m); | |
| 12042 | + } else { | |
| 12043 | + builtin__map_cached_rehash(m, old_cap); | |
| 12044 | + m->cached_hashbits--; | |
| 12045 | + } | |
| 12046 | +} | |
| 12047 | +VV_LOC void builtin__map_rehash(map* m) { | |
| 12048 | + u32 meta_bytes = sizeof(u32) * (m->even_index + 2 + m->extra_metas); | |
| 12049 | + builtin__map_reserve_metas(m, meta_bytes); | |
| 12050 | +} | |
| 12051 | +VV_LOC void builtin__map_reserve_metas(map* m, u32 meta_bytes) { | |
| 12052 | + { // Unsafe block | |
| 12053 | + u8* x = builtin__v_realloc(((byteptr)(m->metas)), ((int)(meta_bytes))); | |
| 12054 | + m->metas = ((u32*)(x)); | |
| 12055 | + builtin__vmemset(m->metas, 0, ((int)(meta_bytes))); | |
| 12056 | + } | |
| 12057 | + for (int i = 0; i < m->key_values.len; i++) { | |
| 12058 | + if (!builtin__DenseArray_has_index(&m->key_values, i)) { | |
| 12059 | + continue; | |
| 12060 | + } | |
| 12061 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, i); | |
| 12062 | + multi_return_u32_u32 mr_16309 = builtin__map_key_to_index(m, pkey); | |
| 12063 | + u32 index = mr_16309.arg0; | |
| 12064 | + u32 meta = mr_16309.arg1; | |
| 12065 | + multi_return_u32_u32 mr_16347 = builtin__map_meta_less(m, index, meta); | |
| 12066 | + index = mr_16347.arg0; | |
| 12067 | + meta = mr_16347.arg1; | |
| 12068 | + builtin__map_meta_greater(m, index, meta, ((u32)(i))); | |
| 12069 | + } | |
| 12070 | +} | |
| 12071 | +void builtin__map_reserve(map* m, u32 n) { | |
| 12072 | + for (;;) { | |
| 12073 | + if (!(((u64)(n)) * 5 > ((u64)(m->even_index)) * 2)) break; | |
| 12074 | + builtin__map_expand(m); | |
| 12075 | + } | |
| 12076 | +} | |
| 12077 | +VV_LOC void builtin__map_cached_rehash(map* m, u32 old_cap) { | |
| 12078 | + u32* old_metas = m->metas; | |
| 12079 | + int metasize = ((int)(sizeof(u32) * (m->even_index + 2 + m->extra_metas))); | |
| 12080 | + m->metas = ((u32*)(builtin__vcalloc(metasize))); | |
| 12081 | + u32 old_extra_metas = m->extra_metas; | |
| 12082 | + for (u32 i = ((u32)(0)); i <= old_cap + old_extra_metas; i += 2) { | |
| 12083 | + if (old_metas[i] == 0) { | |
| 12084 | + continue; | |
| 12085 | + } | |
| 12086 | + u32 old_meta = old_metas[i]; | |
| 12087 | + u32 old_probe_count = v__lshift_u32(((v__rshift_u32(old_meta, (u64)_const_hashbits)) - 1), (u64)1); | |
| 12088 | + u32 old_index = ((i - old_probe_count) & (v__rshift_u32(m->even_index, (u64)1))); | |
| 12089 | + u32 index = (((old_index | (v__lshift_u32(old_meta, (u64)m->shift)))) & m->even_index); | |
| 12090 | + u32 meta = (((old_meta & _const_hash_mask)) | _const_probe_inc); | |
| 12091 | + u32 kv_index = old_metas[i + 1]; | |
| 12092 | + multi_return_u32_u32 mr_17370 = builtin__map_meta_less(m, index, meta); | |
| 12093 | + index = mr_17370.arg0; | |
| 12094 | + meta = mr_17370.arg1; | |
| 12095 | + builtin__map_meta_greater(m, index, meta, kv_index); | |
| 12096 | + } | |
| 12097 | + builtin___v_free(old_metas); | |
| 12098 | +} | |
| 12099 | +VV_LOC voidptr builtin__map_get_and_set(map* m, voidptr key, voidptr zero) { | |
| 12100 | + for (;;) { | |
| 12101 | + multi_return_u32_u32 mr_17776 = builtin__map_key_to_index(m, key); | |
| 12102 | + u32 index = mr_17776.arg0; | |
| 12103 | + u32 meta = mr_17776.arg1; | |
| 12104 | + for (;;) { | |
| 12105 | + if (meta == m->metas[index]) { | |
| 12106 | + int kv_index = ((int)(m->metas[index + 1])); | |
| 12107 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | |
| 12108 | + if (m->key_eq_fn(key, pkey)) { | |
| 12109 | + voidptr pval = builtin__DenseArray_value(&m->key_values, kv_index); | |
| 12110 | + return ((u8*)(pval)); | |
| 12111 | + } | |
| 12112 | + } | |
| 12113 | + index += 2; | |
| 12114 | + meta += _const_probe_inc; | |
| 12115 | + if (meta > m->metas[index]) { | |
| 12116 | + break; | |
| 12117 | + } | |
| 12118 | + } | |
| 12119 | + builtin__map_set(m, key, zero); | |
| 12120 | + } | |
| 12121 | + return ((void*)0); | |
| 12122 | +} | |
| 12123 | +VV_LOC voidptr builtin__map_get(map* m, voidptr key, voidptr zero) { | |
| 12124 | + if (m->len == 0) { | |
| 12125 | + return zero; | |
| 12126 | + } | |
| 12127 | + multi_return_u32_u32 mr_18537 = builtin__map_key_to_index(m, key); | |
| 12128 | + u32 index = mr_18537.arg0; | |
| 12129 | + u32 meta = mr_18537.arg1; | |
| 12130 | + for (;;) { | |
| 12131 | + if (meta == m->metas[index]) { | |
| 12132 | + int kv_index = ((int)(m->metas[index + 1])); | |
| 12133 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | |
| 12134 | + if (m->key_eq_fn(key, pkey)) { | |
| 12135 | + voidptr pval = builtin__DenseArray_value(&m->key_values, kv_index); | |
| 12136 | + return ((u8*)(pval)); | |
| 12137 | + } | |
| 12138 | + } | |
| 12139 | + index += 2; | |
| 12140 | + meta += _const_probe_inc; | |
| 12141 | + if (meta > m->metas[index]) { | |
| 12142 | + break; | |
| 12143 | + } | |
| 12144 | + } | |
| 12145 | + return zero; | |
| 12146 | +} | |
| 12147 | +VV_LOC voidptr builtin__map_get_check(map* m, voidptr key) { | |
| 12148 | + if (m->len == 0) { | |
| 12149 | + return 0; | |
| 12150 | + } | |
| 12151 | + multi_return_u32_u32 mr_19233 = builtin__map_key_to_index(m, key); | |
| 12152 | + u32 index = mr_19233.arg0; | |
| 12153 | + u32 meta = mr_19233.arg1; | |
| 12154 | + for (;;) { | |
| 12155 | + if (meta == m->metas[index]) { | |
| 12156 | + int kv_index = ((int)(m->metas[index + 1])); | |
| 12157 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | |
| 12158 | + if (m->key_eq_fn(key, pkey)) { | |
| 12159 | + voidptr pval = builtin__DenseArray_value(&m->key_values, kv_index); | |
| 12160 | + return ((u8*)(pval)); | |
| 12161 | + } | |
| 12162 | + } | |
| 12163 | + index += 2; | |
| 12164 | + meta += _const_probe_inc; | |
| 12165 | + if (meta > m->metas[index]) { | |
| 12166 | + break; | |
| 12167 | + } | |
| 12168 | + } | |
| 12169 | + return 0; | |
| 12170 | +} | |
| 12171 | +VV_LOC bool builtin__map_exists(map* m, voidptr key) { | |
| 12172 | + if (m->len == 0) { | |
| 12173 | + return false; | |
| 12174 | + } | |
| 12175 | + multi_return_u32_u32 mr_19778 = builtin__map_key_to_index(m, key); | |
| 12176 | + u32 index = mr_19778.arg0; | |
| 12177 | + u32 meta = mr_19778.arg1; | |
| 12178 | + for (;;) { | |
| 12179 | + if (meta == m->metas[index]) { | |
| 12180 | + int kv_index = ((int)(m->metas[index + 1])); | |
| 12181 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | |
| 12182 | + if (m->key_eq_fn(key, pkey)) { | |
| 12183 | + return true; | |
| 12184 | + } | |
| 12185 | + } | |
| 12186 | + index += 2; | |
| 12187 | + meta += _const_probe_inc; | |
| 12188 | + if (meta > m->metas[index]) { | |
| 12189 | + break; | |
| 12190 | + } | |
| 12191 | + } | |
| 12192 | + return false; | |
| 12193 | +} | |
| 12194 | +inline VV_LOC void builtin__DenseArray_delete(DenseArray* d, int i) { | |
| 12195 | + if (i == d->len - 1) { | |
| 12196 | + d->len--; | |
| 12197 | + builtin__DenseArray_trim_deleted_tail(d); | |
| 12198 | + return; | |
| 12199 | + } | |
| 12200 | + if (d->deletes == 0) { | |
| 12201 | + d->all_deleted = builtin__vcalloc(d->cap); | |
| 12202 | + } | |
| 12203 | + d->deletes++; | |
| 12204 | + { // Unsafe block | |
| 12205 | + d->all_deleted[i] = 1; | |
| 12206 | + } | |
| 12207 | +} | |
| 12208 | +void builtin__map_delete(map* m, voidptr key) { | |
| 12209 | + multi_return_u32_u32 mr_20483 = builtin__map_key_to_index(m, key); | |
| 12210 | + u32 index = mr_20483.arg0; | |
| 12211 | + u32 meta = mr_20483.arg1; | |
| 12212 | + multi_return_u32_u32 mr_20519 = builtin__map_meta_less(m, index, meta); | |
| 12213 | + index = mr_20519.arg0; | |
| 12214 | + meta = mr_20519.arg1; | |
| 12215 | + for (;;) { | |
| 12216 | + if (!(meta == m->metas[index])) break; | |
| 12217 | + int kv_index = ((int)(m->metas[index + 1])); | |
| 12218 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | |
| 12219 | + if (m->key_eq_fn(key, pkey)) { | |
| 12220 | + for (;;) { | |
| 12221 | + if (!((v__rshift_u32(m->metas[index + 2], (u64)_const_hashbits)) > 1)) break; | |
| 12222 | + { // Unsafe block | |
| 12223 | + m->metas[index] = m->metas[index + 2] - _const_probe_inc; | |
| 12224 | + m->metas[index + 1] = m->metas[index + 3]; | |
| 12225 | + } | |
| 12226 | + index += 2; | |
| 12227 | + } | |
| 12228 | + m->len--; | |
| 12229 | + builtin__DenseArray_delete(&m->key_values, kv_index); | |
| 12230 | + { // Unsafe block | |
| 12231 | + m->metas[index] = 0; | |
| 12232 | + m->free_fn(pkey); | |
| 12233 | + builtin__vmemset(pkey, 0, m->key_bytes); | |
| 12234 | + } | |
| 12235 | + if (m->key_values.len <= 32) { | |
| 12236 | + return; | |
| 12237 | + } | |
| 12238 | + if (_us32_ge(m->key_values.deletes,(v__rshift_int(m->key_values.len, (u64)1)))) { | |
| 12239 | + builtin__DenseArray_zeros_to_end(&m->key_values); | |
| 12240 | + builtin__map_rehash(m); | |
| 12241 | + } | |
| 12242 | + return; | |
| 12243 | + } | |
| 12244 | + index += 2; | |
| 12245 | + meta += _const_probe_inc; | |
| 12246 | + } | |
| 12247 | +} | |
| 12248 | +array builtin__map_keys(map* m) { | |
| 12249 | + array keys = builtin____new_array(m->len, 0, m->key_bytes); | |
| 12250 | + u8* item = ((u8*)(keys.data)); | |
| 12251 | + if (m->key_values.deletes == 0) { | |
| 12252 | + for (int i = 0; i < m->key_values.len; i++) { | |
| 12253 | + { // Unsafe block | |
| 12254 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, i); | |
| 12255 | + m->clone_fn(item, pkey); | |
| 12256 | + item = item + m->key_bytes; | |
| 12257 | + } | |
| 12258 | + } | |
| 12259 | + return keys; | |
| 12260 | + } | |
| 12261 | + for (int i = 0; i < m->key_values.len; i++) { | |
| 12262 | + if (!builtin__DenseArray_has_index(&m->key_values, i)) { | |
| 12263 | + continue; | |
| 12264 | + } | |
| 12265 | + { // Unsafe block | |
| 12266 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, i); | |
| 12267 | + m->clone_fn(item, pkey); | |
| 12268 | + item = item + m->key_bytes; | |
| 12269 | + } | |
| 12270 | + } | |
| 12271 | + return keys; | |
| 12272 | +} | |
| 12273 | +array builtin__map_values(map* m) { | |
| 12274 | + array values = builtin____new_array(m->len, 0, m->value_bytes); | |
| 12275 | + u8* item = ((u8*)(values.data)); | |
| 12276 | + if (m->key_values.deletes == 0) { | |
| 12277 | + builtin__vmemcpy(item, m->key_values.values, m->value_bytes * m->key_values.len); | |
| 12278 | + return values; | |
| 12279 | + } | |
| 12280 | + for (int i = 0; i < m->key_values.len; i++) { | |
| 12281 | + if (!builtin__DenseArray_has_index(&m->key_values, i)) { | |
| 12282 | + continue; | |
| 12283 | + } | |
| 12284 | + { // Unsafe block | |
| 12285 | + voidptr pvalue = builtin__DenseArray_value(&m->key_values, i); | |
| 12286 | + builtin__vmemcpy(item, pvalue, m->value_bytes); | |
| 12287 | + item = item + m->value_bytes; | |
| 12288 | + } | |
| 12289 | + } | |
| 12290 | + return values; | |
| 12291 | +} | |
| 12292 | +VV_LOC DenseArray builtin__DenseArray_clone(DenseArray* d) { | |
| 12293 | + DenseArray res = ((DenseArray){ | |
| 12294 | + .key_bytes = d->key_bytes, | |
| 12295 | + .value_bytes = d->value_bytes, | |
| 12296 | + .cap = d->cap, | |
| 12297 | + .len = d->len, | |
| 12298 | + .deletes = d->deletes, | |
| 12299 | + .all_deleted = ((void*)0), | |
| 12300 | + .keys = ((void*)0), | |
| 12301 | + .values = ((void*)0), | |
| 12302 | + }); | |
| 12303 | + { // Unsafe block | |
| 12304 | + if (d->deletes != 0) { | |
| 12305 | + res.all_deleted = builtin__memdup(d->all_deleted, d->cap); | |
| 12306 | + } | |
| 12307 | + res.keys = builtin__memdup(d->keys, d->cap * d->key_bytes); | |
| 12308 | + res.values = builtin__memdup(d->values, d->cap * d->value_bytes); | |
| 12309 | + } | |
| 12310 | + return res; | |
| 12311 | +} | |
| 12312 | +map builtin__map_clone(map* m) { | |
| 12313 | + int metasize = ((int)(sizeof(u32) * (m->even_index + 2 + m->extra_metas))); | |
| 12314 | + map res = ((map){ | |
| 12315 | + .key_bytes = m->key_bytes, | |
| 12316 | + .value_bytes = m->value_bytes, | |
| 12317 | + .even_index = m->even_index, | |
| 12318 | + .cached_hashbits = m->cached_hashbits, | |
| 12319 | + .shift = m->shift, | |
| 12320 | + .key_values = builtin__DenseArray_clone(&m->key_values), | |
| 12321 | + .metas = ((u32*)(builtin__malloc_noscan(metasize))), | |
| 12322 | + .extra_metas = m->extra_metas, | |
| 12323 | + .has_string_keys = m->has_string_keys, | |
| 12324 | + .hash_fn = m->hash_fn, | |
| 12325 | + .key_eq_fn = m->key_eq_fn, | |
| 12326 | + .clone_fn = m->clone_fn, | |
| 12327 | + .free_fn = m->free_fn, | |
| 12328 | + .len = m->len, | |
| 12329 | + }); | |
| 12330 | + builtin__vmemcpy(res.metas, m->metas, metasize); | |
| 12331 | + if (!m->has_string_keys) { | |
| 12332 | + return res; | |
| 12333 | + } | |
| 12334 | + for (int i = 0; i < m->key_values.len; ++i) { | |
| 12335 | + if (!builtin__DenseArray_has_index(&m->key_values, i)) { | |
| 12336 | + continue; | |
| 12337 | + } | |
| 12338 | + m->clone_fn(builtin__DenseArray_key(&res.key_values, i), builtin__DenseArray_key(&m->key_values, i)); | |
| 12339 | + } | |
| 12340 | + return res; | |
| 12341 | +} | |
| 12342 | +void builtin__map_free(map* m) { | |
| 12343 | + builtin___v_free(m->metas); | |
| 12344 | + { // Unsafe block | |
| 12345 | + m->metas = ((void*)0); | |
| 12346 | + } | |
| 12347 | + if (m->key_values.deletes == 0) { | |
| 12348 | + for (int i = 0; i < m->key_values.len; i++) { | |
| 12349 | + { // Unsafe block | |
| 12350 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, i); | |
| 12351 | + m->free_fn(pkey); | |
| 12352 | + builtin__vmemset(pkey, 0, m->key_bytes); | |
| 12353 | + } | |
| 12354 | + } | |
| 12355 | + } else { | |
| 12356 | + for (int i = 0; i < m->key_values.len; i++) { | |
| 12357 | + if (!builtin__DenseArray_has_index(&m->key_values, i)) { | |
| 12358 | + continue; | |
| 12359 | + } | |
| 12360 | + { // Unsafe block | |
| 12361 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, i); | |
| 12362 | + m->free_fn(pkey); | |
| 12363 | + builtin__vmemset(pkey, 0, m->key_bytes); | |
| 12364 | + } | |
| 12365 | + } | |
| 12366 | + } | |
| 12367 | + { // Unsafe block | |
| 12368 | + if (m->key_values.all_deleted != ((void*)0)) { | |
| 12369 | + builtin___v_free(m->key_values.all_deleted); | |
| 12370 | + m->key_values.all_deleted = ((void*)0); | |
| 12371 | + } | |
| 12372 | + if (m->key_values.keys != ((void*)0)) { | |
| 12373 | + builtin___v_free(m->key_values.keys); | |
| 12374 | + m->key_values.keys = ((void*)0); | |
| 12375 | + } | |
| 12376 | + if (m->key_values.values != ((void*)0)) { | |
| 12377 | + builtin___v_free(m->key_values.values); | |
| 12378 | + m->key_values.values = ((void*)0); | |
| 12379 | + } | |
| 12380 | + m->hash_fn = ((void*)0); | |
| 12381 | + m->key_eq_fn = ((void*)0); | |
| 12382 | + m->clone_fn = ((void*)0); | |
| 12383 | + m->free_fn = ((void*)0); | |
| 12384 | + m->key_values.cap = 0; | |
| 12385 | + m->key_values.len = 0; | |
| 12386 | + m->key_values.deletes = 0; | |
| 12387 | + m->even_index = 0; | |
| 12388 | + m->cached_hashbits = 0; | |
| 12389 | + m->shift = 0; | |
| 12390 | + m->extra_metas = 0; | |
| 12391 | + m->has_string_keys = false; | |
| 12392 | + m->len = 0; | |
| 12393 | + } | |
| 12394 | +} | |
| 12395 | +void builtin__VAssertMetaInfo_free(VAssertMetaInfo* ami) { | |
| 12396 | + { // Unsafe block | |
| 12397 | + builtin__string_free(&ami->fpath); | |
| 12398 | + builtin__string_free(&ami->fn_name); | |
| 12399 | + builtin__string_free(&ami->src); | |
| 12400 | + builtin__string_free(&ami->op); | |
| 12401 | + builtin__string_free(&ami->llabel); | |
| 12402 | + builtin__string_free(&ami->rlabel); | |
| 12403 | + builtin__string_free(&ami->lvalue); | |
| 12404 | + builtin__string_free(&ami->rvalue); | |
| 12405 | + builtin__string_free(&ami->message); | |
| 12406 | + } | |
| 12407 | +} | |
| 12408 | +void builtin__IError_free(IError* ie) { | |
| 12409 | + { // Unsafe block | |
| 12410 | + IError* cie = ((IError*)(ie)); | |
| 12411 | + builtin___v_free(cie->_object); | |
| 12412 | + } | |
| 12413 | +} | |
| 12414 | +VNORETURN void builtin__panic_option_not_set(string s) { | |
| 12415 | + builtin___v_panic(builtin__string_plus_many(3, _MOV((string[3]){_S("option not set ("), s, _S(")")}))); | |
| 12416 | + VUNREACHABLE(); | |
| 12417 | + while(1); | |
| 12418 | +} | |
| 12419 | +VNORETURN void builtin__panic_result_not_set(string s) { | |
| 12420 | + builtin___v_panic(builtin__string_plus_many(3, _MOV((string[3]){_S("result not set ("), s, _S(")")}))); | |
| 12421 | + VUNREACHABLE(); | |
| 12422 | + while(1); | |
| 12423 | +} | |
| 12424 | +VNORETURN void builtin___v_panic(string s) { | |
| 12425 | + #if 0 | |
| 12426 | + { | |
| 12427 | + } | |
| 12428 | + #elif defined(CUSTOM_DEFINE_v2_native_windows_pe_minimal) | |
| 12429 | + { | |
| 12430 | + } | |
| 12431 | + #else | |
| 12432 | + { | |
| 12433 | + builtin__flush_stdout(); | |
| 12434 | + builtin__eprint(_S("V panic: ")); | |
| 12435 | + builtin__eprintln(s); | |
| 12436 | + builtin__eprint(_S(" v hash: ")); | |
| 12437 | + builtin__eprintln(builtin__vcurrent_hash()); | |
| 12438 | + #if 1 | |
| 12439 | + { | |
| 12440 | + builtin__eprint(_S(" pid: ")); | |
| 12441 | + ; | |
| 12442 | + fprintf(stderr, "%p\n", ((voidptr)(builtin__v_getpid()))); | |
| 12443 | + builtin__eprint(_S(" tid: ")); | |
| 12444 | + ; | |
| 12445 | + fprintf(stderr, "%p\n", ((voidptr)(builtin__v_gettid()))); | |
| 12446 | + } | |
| 12447 | + #endif | |
| 12448 | + builtin__flush_stdout(); | |
| 12449 | + #if defined(CUSTOM_DEFINE_exit_after_panic_message) | |
| 12450 | + { | |
| 12451 | + } | |
| 12452 | + #elif defined(CUSTOM_DEFINE_no_backtrace) | |
| 12453 | + { | |
| 12454 | + } | |
| 12455 | + #elif 0 | |
| 12456 | + { | |
| 12457 | + } | |
| 12458 | + #else | |
| 12459 | + { | |
| 12460 | + #if defined(CUSTOM_DEFINE_use_libbacktrace) && !defined(__TINYC__) | |
| 12461 | + { | |
| 12462 | + } | |
| 12463 | + #else | |
| 12464 | + { | |
| 12465 | + builtin__print_backtrace_skipping_top_frames(1); | |
| 12466 | + } | |
| 12467 | + #endif | |
| 12468 | + exit(1); | |
| 12469 | + VUNREACHABLE(); | |
| 12470 | + } | |
| 12471 | + #endif | |
| 12472 | + } | |
| 12473 | + #endif | |
| 12474 | + exit(1); | |
| 12475 | + VUNREACHABLE(); | |
| 12476 | + for (;;) { | |
| 12477 | + } | |
| 12478 | + while(1); | |
| 12479 | +} | |
| 12480 | +string builtin__c_error_number_str(int errnum) { | |
| 12481 | + string err_msg = _S(""); | |
| 12482 | + #if 0 | |
| 12483 | + { | |
| 12484 | + } | |
| 12485 | + #else | |
| 12486 | + { | |
| 12487 | + #if 1 | |
| 12488 | + { | |
| 12489 | + char* c_msg = strerror(errnum); | |
| 12490 | + err_msg = ((string){.str = ((u8*)(c_msg)), .len = ((int)(strlen(c_msg))), .is_lit = 1}); | |
| 12491 | + } | |
| 12492 | + #endif | |
| 12493 | + } | |
| 12494 | + #endif | |
| 12495 | + return err_msg; | |
| 12496 | +} | |
| 12497 | +VNORETURN void builtin__panic_n(string s, i64 number1) { | |
| 12498 | + builtin___v_panic(builtin__string__plus(s, builtin__impl_i64_to_string(number1))); | |
| 12499 | + VUNREACHABLE(); | |
| 12500 | + while(1); | |
| 12501 | +} | |
| 12502 | +VNORETURN void builtin__panic_n2(string s, i64 number1, i64 number2) { | |
| 12503 | + builtin___v_panic(builtin__string_plus_many(4, _MOV((string[4]){s, builtin__impl_i64_to_string(number1), _S(", "), builtin__impl_i64_to_string(number2)}))); | |
| 12504 | + VUNREACHABLE(); | |
| 12505 | + while(1); | |
| 12506 | +} | |
| 12507 | +VNORETURN VV_LOC void builtin__panic_n3(string s, i64 number1, i64 number2, i64 number3) { | |
| 12508 | + builtin___v_panic(builtin__string_plus_many(6, _MOV((string[6]){s, builtin__impl_i64_to_string(number1), _S(", "), builtin__impl_i64_to_string(number2), _S(", "), builtin__impl_i64_to_string(number3)}))); | |
| 12509 | + VUNREACHABLE(); | |
| 12510 | + while(1); | |
| 12511 | +} | |
| 12512 | +VNORETURN void builtin__panic_error_number(string basestr, int errnum) { | |
| 12513 | + builtin___v_panic(builtin__string__plus(basestr, builtin__c_error_number_str(errnum))); | |
| 12514 | + VUNREACHABLE(); | |
| 12515 | + while(1); | |
| 12516 | +} | |
| 12517 | +VV_LOC void builtin__set_stream_unbuffered(FILE* stream) { | |
| 12518 | + setvbuf(stream, ((char*)(((void*)0))), _IONBF, ((usize)(0))); | |
| 12519 | +} | |
| 12520 | +void builtin__eprintln(string s) { | |
| 12521 | + #if 0 | |
| 12522 | + { | |
| 12523 | + } | |
| 12524 | + #elif 0 | |
| 12525 | + { | |
| 12526 | + } | |
| 12527 | + #else | |
| 12528 | + { | |
| 12529 | + builtin__flush_stdout(); | |
| 12530 | + builtin__flush_stderr(); | |
| 12531 | + builtin___writeln_to_fd(2, s); | |
| 12532 | + builtin__flush_stderr(); | |
| 12533 | + } | |
| 12534 | + #endif | |
| 12535 | +} | |
| 12536 | +void builtin__eprint(string s) { | |
| 12537 | + #if 0 | |
| 12538 | + { | |
| 12539 | + } | |
| 12540 | + #elif 0 | |
| 12541 | + { | |
| 12542 | + } | |
| 12543 | + #else | |
| 12544 | + { | |
| 12545 | + builtin__flush_stdout(); | |
| 12546 | + builtin__flush_stderr(); | |
| 12547 | + builtin___write_buf_to_fd(2, s.str, s.len); | |
| 12548 | + builtin__flush_stderr(); | |
| 12549 | + } | |
| 12550 | + #endif | |
| 12551 | +} | |
| 12552 | +void builtin__flush_stdout(void) { | |
| 12553 | + #if defined(CUSTOM_DEFINE_v2_native_windows_pe_minimal) | |
| 12554 | + { | |
| 12555 | + } | |
| 12556 | + #elif 0 | |
| 12557 | + { | |
| 12558 | + } | |
| 12559 | + #elif defined(CUSTOM_DEFINE_builtin_write_buf_to_fd_should_use_c_write) | |
| 12560 | + { | |
| 12561 | + } | |
| 12562 | + #else | |
| 12563 | + { | |
| 12564 | + fflush(stdout); | |
| 12565 | + } | |
| 12566 | + #endif | |
| 12567 | +} | |
| 12568 | +void builtin__flush_stderr(void) { | |
| 12569 | + #if defined(CUSTOM_DEFINE_v2_native_windows_pe_minimal) | |
| 12570 | + { | |
| 12571 | + } | |
| 12572 | + #elif 0 | |
| 12573 | + { | |
| 12574 | + } | |
| 12575 | + #elif defined(CUSTOM_DEFINE_builtin_write_buf_to_fd_should_use_c_write) | |
| 12576 | + { | |
| 12577 | + } | |
| 12578 | + #else | |
| 12579 | + { | |
| 12580 | + fflush(stderr); | |
| 12581 | + } | |
| 12582 | + #endif | |
| 12583 | +} | |
| 12584 | +void builtin__unbuffer_stdout(void) { | |
| 12585 | + #if 0 | |
| 12586 | + { | |
| 12587 | + } | |
| 12588 | + #elif 0 | |
| 12589 | + { | |
| 12590 | + } | |
| 12591 | + #elif defined(CUSTOM_DEFINE_builtin_write_buf_to_fd_should_use_c_write) | |
| 12592 | + { | |
| 12593 | + } | |
| 12594 | + #else | |
| 12595 | + { | |
| 12596 | + builtin__set_stream_unbuffered(stdout); | |
| 12597 | + } | |
| 12598 | + #endif | |
| 12599 | +} | |
| 12600 | +void builtin__print(string s) { | |
| 12601 | + #if 0 | |
| 12602 | + { | |
| 12603 | + } | |
| 12604 | + #elif 0 | |
| 12605 | + { | |
| 12606 | + } | |
| 12607 | + #elif 0 | |
| 12608 | + { | |
| 12609 | + } | |
| 12610 | + #else | |
| 12611 | + { | |
| 12612 | + builtin___write_buf_to_fd(1, s.str, s.len); | |
| 12613 | + } | |
| 12614 | + #endif | |
| 12615 | +} | |
| 12616 | +void builtin__println(string s) { | |
| 12617 | + #if 0 | |
| 12618 | + { | |
| 12619 | + } | |
| 12620 | + #elif 0 | |
| 12621 | + { | |
| 12622 | + } | |
| 12623 | + #elif 0 | |
| 12624 | + { | |
| 12625 | + } | |
| 12626 | + #else | |
| 12627 | + { | |
| 12628 | + builtin___writeln_to_fd(1, s); | |
| 12629 | + } | |
| 12630 | + #endif | |
| 12631 | +} | |
| 12632 | +VV_LOC void builtin___writeln_to_fd(int fd, string s) { | |
| 12633 | + #if defined(CUSTOM_DEFINE_builtin_writeln_should_write_at_once) | |
| 12634 | + { | |
| 12635 | + } | |
| 12636 | + #else | |
| 12637 | + { | |
| 12638 | + u8 lf = ((u8)('\n')); | |
| 12639 | + builtin___write_buf_to_fd(fd, s.str, s.len); | |
| 12640 | + builtin___write_buf_to_fd(fd, &lf, 1); | |
| 12641 | + } | |
| 12642 | + #endif | |
| 12643 | +} | |
| 12644 | +VV_LOC void builtin___write_buf_to_fd(int fd, u8* buf, int buf_len) { | |
| 12645 | + if (buf_len <= 0) { | |
| 12646 | + return; | |
| 12647 | + } | |
| 12648 | + #if 0 | |
| 12649 | + { | |
| 12650 | + } | |
| 12651 | + #else | |
| 12652 | + { | |
| 12653 | + u8* ptr = buf; | |
| 12654 | + isize remaining_bytes = ((isize)(buf_len)); | |
| 12655 | + isize x = ((isize)(0)); | |
| 12656 | + #if 0 | |
| 12657 | + { | |
| 12658 | + } | |
| 12659 | + #else | |
| 12660 | + { | |
| 12661 | + voidptr stream = ((voidptr)(stdout)); | |
| 12662 | + if (fd == 2) { | |
| 12663 | + stream = ((voidptr)(stderr)); | |
| 12664 | + } | |
| 12665 | + { // Unsafe block | |
| 12666 | + for (;;) { | |
| 12667 | + if (!(remaining_bytes > 0)) break; | |
| 12668 | + x = ((isize)(fwrite(ptr, 1, remaining_bytes, stream))); | |
| 12669 | + if (x <= 0) { | |
| 12670 | + break; | |
| 12671 | + } | |
| 12672 | + ptr += x; | |
| 12673 | + remaining_bytes -= x; | |
| 12674 | + } | |
| 12675 | + } | |
| 12676 | + } | |
| 12677 | + #endif | |
| 12678 | + } | |
| 12679 | + #endif | |
| 12680 | +} | |
| 12681 | +string builtin__reuse_data_as_string(Array_u8 buffer) { | |
| 12682 | + return ((string){.str = buffer.data, .len = buffer.len, .is_lit = 1}); | |
| 12683 | +} | |
| 12684 | +Array_u8 builtin__reuse_string_as_data(string s) { | |
| 12685 | + array res = ((array){.data = (voidptr)s.str,.offset = 0,.len = s.len,.cap = 0,.flags = ((ArrayFlags__nogrow | ArrayFlags__noshrink) | ArrayFlags__nofree),.element_size = 1,}); | |
| 12686 | + return res; | |
| 12687 | +} | |
| 12688 | +string builtin__rune_str(rune c) { | |
| 12689 | + return builtin__utf32_to_str(((u32)(c))); | |
| 12690 | +} | |
| 12691 | +string Array_rune_string(Array_rune ra) { | |
| 12692 | + strings__Builder sb = strings__new_builder(ra.len); | |
| 12693 | + strings__Builder_write_runes(&sb, ra); | |
| 12694 | + string res = strings__Builder_str(&sb); | |
| 12695 | + strings__Builder_free(&sb); | |
| 12696 | + return res; | |
| 12697 | +} | |
| 12698 | +string builtin__rune_repeat(rune c, int count) { | |
| 12699 | + if (count <= 0) { | |
| 12700 | + return _S(""); | |
| 12701 | + } else if (count == 1) { | |
| 12702 | + return builtin__rune_str(c); | |
| 12703 | + } | |
| 12704 | + Array_fixed_u8_5 buffer = {0}; | |
| 12705 | + string res = builtin__utf32_to_str_no_malloc(((u32)(c)), &buffer[0]); | |
| 12706 | + return builtin__string_repeat(res, count); | |
| 12707 | +} | |
| 12708 | +Array_u8 builtin__rune_bytes(rune c) { | |
| 12709 | + Array_u8 res = builtin____new_array_with_default(0, 5, sizeof(u8), 0); | |
| 12710 | + u8* buf = ((u8*)(res.data)); | |
| 12711 | + res.len = builtin__utf32_decode_to_buffer(((u32)(c)), buf); | |
| 12712 | + return res; | |
| 12713 | +} | |
| 12714 | +int builtin__rune_length_in_bytes(rune c) { | |
| 12715 | + u32 code = ((u32)(c)); | |
| 12716 | + if (code <= 0x7F) { | |
| 12717 | + return 1; | |
| 12718 | + } else if (code <= 0x7FF) { | |
| 12719 | + return 2; | |
| 12720 | + } else if (0xD800 <= code && code <= 0xDFFF) { | |
| 12721 | + return -1; | |
| 12722 | + } else if (code <= 0xFFFF) { | |
| 12723 | + return 3; | |
| 12724 | + } else if (code <= 0x10FFFF) { | |
| 12725 | + return 4; | |
| 12726 | + } | |
| 12727 | + return -1; | |
| 12728 | +} | |
| 12729 | +rune builtin__rune_to_upper(rune c) { | |
| 12730 | + if (c < 0x80) { | |
| 12731 | + if (c >= 'a' && c <= 'z') { | |
| 12732 | + return c - 32; | |
| 12733 | + } | |
| 12734 | + return c; | |
| 12735 | + } | |
| 12736 | + return builtin__rune_map_to(c, MapMode__to_upper); | |
| 12737 | +} | |
| 12738 | +rune builtin__rune_to_lower(rune c) { | |
| 12739 | + if (c < 0x80) { | |
| 12740 | + if (c >= 'A' && c <= 'Z') { | |
| 12741 | + return c + 32; | |
| 12742 | + } | |
| 12743 | + return c; | |
| 12744 | + } | |
| 12745 | + return builtin__rune_map_to(c, MapMode__to_lower); | |
| 12746 | +} | |
| 12747 | +rune builtin__rune_to_title(rune c) { | |
| 12748 | + if (c < 0x80) { | |
| 12749 | + if (c >= 'a' && c <= 'z') { | |
| 12750 | + return c - 32; | |
| 12751 | + } | |
| 12752 | + return c; | |
| 12753 | + } | |
| 12754 | + return builtin__rune_map_to(c, MapMode__to_title); | |
| 12755 | +} | |
| 12756 | +VV_LOC rune builtin__rune_map_to(rune c, MapMode mode) { | |
| 12757 | + int start = 0; | |
| 12758 | + int end = VSAFE_DIV_int(1264 , _const_rune_maps_columns_in_row); | |
| 12759 | + for (;;) { | |
| 12760 | + if (!(start < end)) break; | |
| 12761 | + int middle = VSAFE_DIV_int((start + end) , 2); | |
| 12762 | + i32* cur_map = &_const_rune_maps[middle * _const_rune_maps_columns_in_row]; | |
| 12763 | + if (c >= ((u32)(*cur_map)) && c <= ((u32)(*(cur_map + 1)))) { | |
| 12764 | + i32 offset = ((mode == MapMode__to_upper || mode == MapMode__to_title) ? (*(cur_map + 2)) : (*(cur_map + 3))); | |
| 12765 | + if (offset == _const_rune_maps_ul) { | |
| 12766 | + rune cnt = VSAFE_MOD_rune(((rune)(c - *cur_map)) , 2); | |
| 12767 | + if (mode == MapMode__to_lower) { | |
| 12768 | + return c + 1 - cnt; | |
| 12769 | + } | |
| 12770 | + return c - cnt; | |
| 12771 | + } else if (offset == _const_rune_maps_utl) { | |
| 12772 | + rune cnt = VSAFE_MOD_rune(((rune)(c - *cur_map)) , 3); | |
| 12773 | + if (mode == MapMode__to_upper) { | |
| 12774 | + return c - cnt; | |
| 12775 | + } else if (mode == MapMode__to_lower) { | |
| 12776 | + return c + 2 - cnt; | |
| 12777 | + } | |
| 12778 | + return c + 1 - cnt; | |
| 12779 | + } | |
| 12780 | + return (rune)(c + offset); | |
| 12781 | + } | |
| 12782 | + if (c < ((u32)(*cur_map))) { | |
| 12783 | + end = middle; | |
| 12784 | + } else { | |
| 12785 | + start = middle + 1; | |
| 12786 | + } | |
| 12787 | + } | |
| 12788 | + return c; | |
| 12789 | +} | |
| 12790 | +VV_LOC int builtin__mapnode_find_key(mapnode* n, string k) { | |
| 12791 | + int idx = 0; | |
| 12792 | + for (;;) { | |
| 12793 | + if (!(idx < n->len && builtin__string__lt(n->keys[builtin__v_fixed_index(idx, 11)], k))) break; | |
| 12794 | + idx++; | |
| 12795 | + } | |
| 12796 | + return idx; | |
| 12797 | +} | |
| 12798 | +VV_LOC bool builtin__mapnode_remove_key(mapnode* n, string k) { | |
| 12799 | + int idx = builtin__mapnode_find_key(n, k); | |
| 12800 | + if (idx < n->len && builtin__string__eq(n->keys[builtin__v_fixed_index(idx, 11)], k)) { | |
| 12801 | + if (n->children == ((void*)0)) { | |
| 12802 | + builtin__mapnode_remove_from_leaf(n, idx); | |
| 12803 | + } else { | |
| 12804 | + builtin__mapnode_remove_from_non_leaf(n, idx); | |
| 12805 | + } | |
| 12806 | + return true; | |
| 12807 | + } else { | |
| 12808 | + if (n->children == ((void*)0)) { | |
| 12809 | + return false; | |
| 12810 | + } | |
| 12811 | + bool flag = (idx == n->len ? (true) : (false)); | |
| 12812 | + if (((mapnode*)(n->children[idx]))->len < _const_degree) { | |
| 12813 | + builtin__mapnode_fill(n, idx); | |
| 12814 | + } | |
| 12815 | + mapnode* node = ((mapnode*)(((void*)0))); | |
| 12816 | + if (flag && idx > n->len) { | |
| 12817 | + node = ((mapnode*)(n->children[idx - 1])); | |
| 12818 | + } else { | |
| 12819 | + node = ((mapnode*)(n->children[idx])); | |
| 12820 | + } | |
| 12821 | + return builtin__mapnode_remove_key(node, k); | |
| 12822 | + } | |
| 12823 | + return 0; | |
| 12824 | +} | |
| 12825 | +VV_LOC void builtin__mapnode_remove_from_leaf(mapnode* n, int idx) { | |
| 12826 | + for (int i = idx + 1; i < n->len; i++) { | |
| 12827 | + n->keys[builtin__v_fixed_index(i - 1, 11)] = n->keys[builtin__v_fixed_index(i, 11)]; | |
| 12828 | + n->values[builtin__v_fixed_index(i - 1, 11)] = n->values[builtin__v_fixed_index(i, 11)]; | |
| 12829 | + } | |
| 12830 | + n->len--; | |
| 12831 | +} | |
| 12832 | +VV_LOC void builtin__mapnode_remove_from_non_leaf(mapnode* n, int idx) { | |
| 12833 | + string k = n->keys[builtin__v_fixed_index(idx, 11)]; | |
| 12834 | + if (((mapnode*)(n->children[idx]))->len >= _const_degree) { | |
| 12835 | + mapnode* current = ((mapnode*)(n->children[idx])); | |
| 12836 | + for (;;) { | |
| 12837 | + if (!(current->children != ((void*)0))) break; | |
| 12838 | + current = ((mapnode*)(current->children[current->len])); | |
| 12839 | + } | |
| 12840 | + string predecessor = current->keys[builtin__v_fixed_index(current->len - 1, 11)]; | |
| 12841 | + n->keys[builtin__v_fixed_index(idx, 11)] = predecessor; | |
| 12842 | + n->values[builtin__v_fixed_index(idx, 11)] = current->values[builtin__v_fixed_index(current->len - 1, 11)]; | |
| 12843 | + mapnode* node = ((mapnode*)(n->children[idx])); | |
| 12844 | + builtin__mapnode_remove_key(node, predecessor); | |
| 12845 | + } else if (((mapnode*)(n->children[idx + 1]))->len >= _const_degree) { | |
| 12846 | + mapnode* current = ((mapnode*)(n->children[idx + 1])); | |
| 12847 | + for (;;) { | |
| 12848 | + if (!(current->children != ((void*)0))) break; | |
| 12849 | + current = ((mapnode*)(current->children[0])); | |
| 12850 | + } | |
| 12851 | + string successor = current->keys[0]; | |
| 12852 | + n->keys[builtin__v_fixed_index(idx, 11)] = successor; | |
| 12853 | + n->values[builtin__v_fixed_index(idx, 11)] = current->values[0]; | |
| 12854 | + mapnode* node = ((mapnode*)(n->children[idx + 1])); | |
| 12855 | + builtin__mapnode_remove_key(node, successor); | |
| 12856 | + } else { | |
| 12857 | + builtin__mapnode_merge(n, idx); | |
| 12858 | + mapnode* node = ((mapnode*)(n->children[idx])); | |
| 12859 | + builtin__mapnode_remove_key(node, k); | |
| 12860 | + } | |
| 12861 | +} | |
| 12862 | +VV_LOC void builtin__mapnode_fill(mapnode* n, int idx) { | |
| 12863 | + if (idx != 0 && ((mapnode*)(n->children[idx - 1]))->len >= _const_degree) { | |
| 12864 | + builtin__mapnode_borrow_from_prev(n, idx); | |
| 12865 | + } else if (idx != n->len && ((mapnode*)(n->children[idx + 1]))->len >= _const_degree) { | |
| 12866 | + builtin__mapnode_borrow_from_next(n, idx); | |
| 12867 | + } else if (idx != n->len) { | |
| 12868 | + builtin__mapnode_merge(n, idx); | |
| 12869 | + } else { | |
| 12870 | + builtin__mapnode_merge(n, idx - 1); | |
| 12871 | + } | |
| 12872 | +} | |
| 12873 | +VV_LOC void builtin__mapnode_borrow_from_prev(mapnode* n, int idx) { | |
| 12874 | + mapnode* child = ((mapnode*)(n->children[idx])); | |
| 12875 | + mapnode* sibling = ((mapnode*)(n->children[idx - 1])); | |
| 12876 | + for (int i = child->len - 1; i >= 0; i--) { | |
| 12877 | + child->keys[builtin__v_fixed_index(i + 1, 11)] = child->keys[builtin__v_fixed_index(i, 11)]; | |
| 12878 | + child->values[builtin__v_fixed_index(i + 1, 11)] = child->values[builtin__v_fixed_index(i, 11)]; | |
| 12879 | + } | |
| 12880 | + if (child->children != ((void*)0)) { | |
| 12881 | + for (int i = child->len; i >= 0; i--) { | |
| 12882 | + { // Unsafe block | |
| 12883 | + child->children[i + 1] = child->children[i]; | |
| 12884 | + } | |
| 12885 | + } | |
| 12886 | + } | |
| 12887 | + child->keys[0] = n->keys[builtin__v_fixed_index(idx - 1, 11)]; | |
| 12888 | + child->values[0] = n->values[builtin__v_fixed_index(idx - 1, 11)]; | |
| 12889 | + if (child->children != ((void*)0)) { | |
| 12890 | + { // Unsafe block | |
| 12891 | + child->children[0] = sibling->children[sibling->len]; | |
| 12892 | + } | |
| 12893 | + } | |
| 12894 | + n->keys[builtin__v_fixed_index(idx - 1, 11)] = sibling->keys[builtin__v_fixed_index(sibling->len - 1, 11)]; | |
| 12895 | + n->values[builtin__v_fixed_index(idx - 1, 11)] = sibling->values[builtin__v_fixed_index(sibling->len - 1, 11)]; | |
| 12896 | + child->len++; | |
| 12897 | + sibling->len--; | |
| 12898 | +} | |
| 12899 | +VV_LOC void builtin__mapnode_borrow_from_next(mapnode* n, int idx) { | |
| 12900 | + mapnode* child = ((mapnode*)(n->children[idx])); | |
| 12901 | + mapnode* sibling = ((mapnode*)(n->children[idx + 1])); | |
| 12902 | + child->keys[builtin__v_fixed_index(child->len, 11)] = n->keys[builtin__v_fixed_index(idx, 11)]; | |
| 12903 | + child->values[builtin__v_fixed_index(child->len, 11)] = n->values[builtin__v_fixed_index(idx, 11)]; | |
| 12904 | + if (child->children != ((void*)0)) { | |
| 12905 | + { // Unsafe block | |
| 12906 | + child->children[child->len + 1] = sibling->children[0]; | |
| 12907 | + } | |
| 12908 | + } | |
| 12909 | + n->keys[builtin__v_fixed_index(idx, 11)] = sibling->keys[0]; | |
| 12910 | + n->values[builtin__v_fixed_index(idx, 11)] = sibling->values[0]; | |
| 12911 | + for (int i = 1; i < sibling->len; i++) { | |
| 12912 | + sibling->keys[builtin__v_fixed_index(i - 1, 11)] = sibling->keys[builtin__v_fixed_index(i, 11)]; | |
| 12913 | + sibling->values[builtin__v_fixed_index(i - 1, 11)] = sibling->values[builtin__v_fixed_index(i, 11)]; | |
| 12914 | + } | |
| 12915 | + if (sibling->children != ((void*)0)) { | |
| 12916 | + for (int i = 1; i <= sibling->len; i++) { | |
| 12917 | + { // Unsafe block | |
| 12918 | + sibling->children[i - 1] = sibling->children[i]; | |
| 12919 | + } | |
| 12920 | + } | |
| 12921 | + } | |
| 12922 | + child->len++; | |
| 12923 | + sibling->len--; | |
| 12924 | +} | |
| 12925 | +VV_LOC void builtin__mapnode_merge(mapnode* n, int idx) { | |
| 12926 | + mapnode* child = ((mapnode*)(n->children[idx])); | |
| 12927 | + mapnode* sibling = ((mapnode*)(n->children[idx + 1])); | |
| 12928 | + child->keys[builtin__v_fixed_index(_const_mid_index, 11)] = n->keys[builtin__v_fixed_index(idx, 11)]; | |
| 12929 | + child->values[builtin__v_fixed_index(_const_mid_index, 11)] = n->values[builtin__v_fixed_index(idx, 11)]; | |
| 12930 | + for (int i = 0; i < sibling->len; ++i) { | |
| 12931 | + child->keys[builtin__v_fixed_index(i + _const_degree, 11)] = sibling->keys[builtin__v_fixed_index(i, 11)]; | |
| 12932 | + child->values[builtin__v_fixed_index(i + _const_degree, 11)] = sibling->values[builtin__v_fixed_index(i, 11)]; | |
| 12933 | + } | |
| 12934 | + if (child->children != ((void*)0)) { | |
| 12935 | + for (int i = 0; i <= sibling->len; i++) { | |
| 12936 | + { // Unsafe block | |
| 12937 | + child->children[i + _const_degree] = sibling->children[i]; | |
| 12938 | + } | |
| 12939 | + } | |
| 12940 | + } | |
| 12941 | + for (int i = idx + 1; i < n->len; i++) { | |
| 12942 | + n->keys[builtin__v_fixed_index(i - 1, 11)] = n->keys[builtin__v_fixed_index(i, 11)]; | |
| 12943 | + n->values[builtin__v_fixed_index(i - 1, 11)] = n->values[builtin__v_fixed_index(i, 11)]; | |
| 12944 | + } | |
| 12945 | + for (int i = idx + 2; i <= n->len; i++) { | |
| 12946 | + { // Unsafe block | |
| 12947 | + n->children[i - 1] = n->children[i]; | |
| 12948 | + } | |
| 12949 | + } | |
| 12950 | + child->len += sibling->len + 1; | |
| 12951 | + n->len--; | |
| 12952 | +} | |
| 12953 | +void builtin__SortedMap_delete(SortedMap* m, string key) { | |
| 12954 | + if (m->root->len == 0) { | |
| 12955 | + return; | |
| 12956 | + } | |
| 12957 | + bool removed = builtin__mapnode_remove_key(m->root, key); | |
| 12958 | + if (removed) { | |
| 12959 | + m->len--; | |
| 12960 | + } | |
| 12961 | + if (m->root->len == 0) { | |
| 12962 | + if (m->root->children == ((void*)0)) { | |
| 12963 | + return; | |
| 12964 | + } else { | |
| 12965 | + m->root = ((mapnode*)(m->root->children[0])); | |
| 12966 | + } | |
| 12967 | + } | |
| 12968 | +} | |
| 12969 | +VV_LOC int builtin__mapnode_subkeys(mapnode* n, Array_string* keys, int at) { | |
| 12970 | + int position = at; | |
| 12971 | + if (n->children != ((void*)0)) { | |
| 12972 | + for (int i = 0; i < n->len; ++i) { | |
| 12973 | + mapnode* child = ((mapnode*)(n->children[i])); | |
| 12974 | + position += builtin__mapnode_subkeys(child, keys, position); | |
| 12975 | + builtin__array_set(keys, position, &(string[]) { n->keys[builtin__v_fixed_index(i, 11)] }); | |
| 12976 | + position++; | |
| 12977 | + } | |
| 12978 | + mapnode* child = ((mapnode*)(n->children[n->len])); | |
| 12979 | + position += builtin__mapnode_subkeys(child, keys, position); | |
| 12980 | + } else { | |
| 12981 | + for (int i = 0; i < n->len; ++i) { | |
| 12982 | + builtin__array_set(keys, (int)(position + i), &(string[]) { n->keys[builtin__v_fixed_index(i, 11)] }); | |
| 12983 | + } | |
| 12984 | + position += n->len; | |
| 12985 | + } | |
| 12986 | + return position - at; | |
| 12987 | +} | |
| 12988 | +Array_string builtin__SortedMap_keys(SortedMap* m) { | |
| 12989 | + Array_string keys = builtin____new_array_with_default(m->len, 0, sizeof(string), &(string[]){_S("")}); | |
| 12990 | + if (m->root == ((void*)0) || m->root->len == 0) { | |
| 12991 | + return keys; | |
| 12992 | + } | |
| 12993 | + builtin__mapnode_subkeys(m->root, &keys, 0); | |
| 12994 | + return keys; | |
| 12995 | +} | |
| 12996 | +VV_LOC void builtin__mapnode_free(mapnode* n) { | |
| 12997 | +} | |
| 12998 | +void builtin__SortedMap_free(SortedMap* m) { | |
| 12999 | + if (m->root == ((void*)0)) { | |
| 13000 | + return; | |
| 13001 | + } | |
| 13002 | + builtin__mapnode_free(m->root); | |
| 13003 | +} | |
| 13004 | +Array_rune builtin__string_runes(string s) { | |
| 13005 | + Array_rune runes = builtin____new_array_with_default(0, s.len, sizeof(rune), 0); | |
| 13006 | + for (int i = 0; i < s.len; i++) { | |
| 13007 | + multi_return_rune_int mr_2797 = builtin__utf8_decode_rune(&s.str[i], s.len - i); | |
| 13008 | + rune r = mr_2797.arg0; | |
| 13009 | + int char_len = mr_2797.arg1; | |
| 13010 | + builtin__array_push((array*)&runes, _MOV((rune[]){ r })); | |
| 13011 | + if (char_len > 1) { | |
| 13012 | + i += char_len - 1; | |
| 13013 | + } | |
| 13014 | + } | |
| 13015 | + return runes; | |
| 13016 | +} | |
| 13017 | +Array_string builtin__string_graphemes(string s) { | |
| 13018 | + return builtin__string_graphemes_impl(s); | |
| 13019 | +} | |
| 13020 | +string builtin__cstring_to_vstring(const char* const_s) { | |
| 13021 | + string s = builtin__tos2(((byteptr)(const_s))); | |
| 13022 | + return builtin__string_clone(s); | |
| 13023 | +} | |
| 13024 | +string builtin__tos_clone(const u8* const_s) { | |
| 13025 | + string s = builtin__tos2(((u8*)(const_s))); | |
| 13026 | + return builtin__string_clone(s); | |
| 13027 | +} | |
| 13028 | +string builtin__tos(u8* s, int len) { | |
| 13029 | + if (s == 0) { | |
| 13030 | + builtin___v_panic(_S("tos(): nil string")); | |
| 13031 | + VUNREACHABLE(); | |
| 13032 | + } | |
| 13033 | + return ((string){.str = s, .len = len}); | |
| 13034 | +} | |
| 13035 | +string builtin__tos2(u8* s) { | |
| 13036 | + if (s == 0) { | |
| 13037 | + builtin___v_panic(_S("tos2: nil string")); | |
| 13038 | + VUNREACHABLE(); | |
| 13039 | + } | |
| 13040 | + return ((string){.str = s, .len = builtin__vstrlen(s)}); | |
| 13041 | +} | |
| 13042 | +string builtin__tos3(char* s) { | |
| 13043 | + if (s == 0) { | |
| 13044 | + builtin___v_panic(_S("tos3: nil string")); | |
| 13045 | + VUNREACHABLE(); | |
| 13046 | + } | |
| 13047 | + return ((string){.str = ((u8*)(s)), .len = builtin__vstrlen_char(s)}); | |
| 13048 | +} | |
| 13049 | +string builtin__tos4(u8* s) { | |
| 13050 | + if (s == 0) { | |
| 13051 | + return _S(""); | |
| 13052 | + } | |
| 13053 | + return ((string){.str = s, .len = builtin__vstrlen(s)}); | |
| 13054 | +} | |
| 13055 | +string builtin__tos5(char* s) { | |
| 13056 | + if (s == 0) { | |
| 13057 | + return _S(""); | |
| 13058 | + } | |
| 13059 | + return ((string){.str = ((u8*)(s)), .len = builtin__vstrlen_char(s)}); | |
| 13060 | +} | |
| 13061 | +string builtin__u8_vstring(u8* bp) { | |
| 13062 | + return ((string){.str = bp, .len = builtin__vstrlen(bp)}); | |
| 13063 | +} | |
| 13064 | +string builtin__u8_vstring_with_len(u8* bp, int len) { | |
| 13065 | + return ((string){.str = bp, .len = len, .is_lit = 0}); | |
| 13066 | +} | |
| 13067 | +string builtin__char_vstring(char* cp) { | |
| 13068 | + return ((string){.str = ((u8*)(cp)), .len = builtin__vstrlen_char(cp), .is_lit = 0}); | |
| 13069 | +} | |
| 13070 | +string builtin__char_vstring_with_len(char* cp, int len) { | |
| 13071 | + return ((string){.str = ((u8*)(cp)), .len = len, .is_lit = 0}); | |
| 13072 | +} | |
| 13073 | +string builtin__u8_vstring_literal(u8* bp) { | |
| 13074 | + return ((string){.str = bp, .len = builtin__vstrlen(bp), .is_lit = 1}); | |
| 13075 | +} | |
| 13076 | +string builtin__u8_vstring_literal_with_len(u8* bp, int len) { | |
| 13077 | + return ((string){.str = bp, .len = len, .is_lit = 1}); | |
| 13078 | +} | |
| 13079 | +string builtin__char_vstring_literal(char* cp) { | |
| 13080 | + return ((string){.str = ((u8*)(cp)), .len = builtin__vstrlen_char(cp), .is_lit = 1}); | |
| 13081 | +} | |
| 13082 | +string builtin__char_vstring_literal_with_len(char* cp, int len) { | |
| 13083 | + return ((string){.str = ((u8*)(cp)), .len = len, .is_lit = 1}); | |
| 13084 | +} | |
| 13085 | +int builtin__string_len_utf8(string s) { | |
| 13086 | + int l = 0; | |
| 13087 | + int i = 0; | |
| 13088 | + for (;;) { | |
| 13089 | + if (!(i < s.len)) break; | |
| 13090 | + l++; | |
| 13091 | + i += ((int)((((v__rshift_u32(((u32)(0xe5000000U)), (u64)(((v__rshift_u8(s.str[i], (u64)3)) & 0x1e)))) & 3)) + 1)); | |
| 13092 | + } | |
| 13093 | + return l; | |
| 13094 | +} | |
| 13095 | +bool builtin__string_is_pure_ascii(string s) { | |
| 13096 | + for (int i = 0; i < s.len; ++i) { | |
| 13097 | + if (s.str[ i] >= 0x80) { | |
| 13098 | + return false; | |
| 13099 | + } | |
| 13100 | + } | |
| 13101 | + return true; | |
| 13102 | +} | |
| 13103 | +string builtin__string_clone(string a) { | |
| 13104 | + if (a.len <= 0) { | |
| 13105 | + return _S(""); | |
| 13106 | + } | |
| 13107 | + string _t2 = ((string){.str = builtin__malloc_noscan(a.len + 1), .len = a.len}); | |
| 13108 | + string b = _t2; | |
| 13109 | + { // Unsafe block | |
| 13110 | + builtin__vmemcpy(b.str, a.str, a.len); | |
| 13111 | + b.str[a.len] = 0; | |
| 13112 | + } | |
| 13113 | + return b; | |
| 13114 | +} | |
| 13115 | +string builtin__string_replace_once(string s, string rep, string with) { | |
| 13116 | + int idx = builtin__string_index_(s, rep); | |
| 13117 | + if (idx == -1) { | |
| 13118 | + return builtin__string_clone(s); | |
| 13119 | + } | |
| 13120 | + return builtin__string_plus_two(builtin__string_substr_unsafe(s, 0, idx), with, builtin__string_substr_unsafe(s, idx + rep.len, s.len)); | |
| 13121 | +} | |
| 13122 | +string builtin__string_replace(string s, string rep, string with) { | |
| 13123 | + if (s.len == 0 || rep.len == 0 || rep.len > s.len) { | |
| 13124 | + return builtin__string_clone(s); | |
| 13125 | + } | |
| 13126 | + if (!builtin__string_contains(s, rep)) { | |
| 13127 | + return builtin__string_clone(s); | |
| 13128 | + } | |
| 13129 | + int pidxs_len = 0; | |
| 13130 | + int pidxs_cap = VSAFE_DIV_int(s.len , rep.len); | |
| 13131 | + Array_fixed_int_10 stack_idxs = {0}; | |
| 13132 | + int* pidxs = &stack_idxs[0]; | |
| 13133 | + if (pidxs_cap > _const_replace_stack_buffer_size) { | |
| 13134 | + pidxs = ((int*)(builtin___v_malloc(((int)(sizeof(int))) * pidxs_cap))); | |
| 13135 | + } | |
| 13136 | + int idx = 0; | |
| 13137 | + for (;;) { | |
| 13138 | + idx = builtin__string_index_after_(s, rep, idx); | |
| 13139 | + if (idx == -1) { | |
| 13140 | + break; | |
| 13141 | + } | |
| 13142 | + { // Unsafe block | |
| 13143 | + pidxs[pidxs_len] = idx; | |
| 13144 | + pidxs_len++; | |
| 13145 | + } | |
| 13146 | + idx += rep.len; | |
| 13147 | + } | |
| 13148 | + if (pidxs_len == 0) { | |
| 13149 | + string _t3 = builtin__string_clone(s); | |
| 13150 | + { // defer begin | |
| 13151 | + if (pidxs_cap > _const_replace_stack_buffer_size) { | |
| 13152 | + builtin___v_free(pidxs); | |
| 13153 | + } | |
| 13154 | + } // defer end | |
| 13155 | + return _t3; | |
| 13156 | + } | |
| 13157 | + int new_len = s.len + pidxs_len * (with.len - rep.len); | |
| 13158 | + u8* b = builtin__malloc_noscan(new_len + 1); | |
| 13159 | + int b_i = 0; | |
| 13160 | + int s_idx = 0; | |
| 13161 | + for (int j = 0; j < pidxs_len; ++j) { | |
| 13162 | + int rep_pos = pidxs[j]; | |
| 13163 | + int before_len = rep_pos - s_idx; | |
| 13164 | + builtin__vmemcpy(&b[b_i], &s.str[s_idx], before_len); | |
| 13165 | + b_i += before_len; | |
| 13166 | + s_idx = rep_pos + rep.len; | |
| 13167 | + builtin__vmemcpy(&b[b_i], &with.str[0], with.len); | |
| 13168 | + b_i += with.len; | |
| 13169 | + } | |
| 13170 | + if (s_idx < s.len) { | |
| 13171 | + builtin__vmemcpy(&b[b_i], &s.str[s_idx], s.len - s_idx); | |
| 13172 | + } | |
| 13173 | + { // Unsafe block | |
| 13174 | + b[new_len] = 0; | |
| 13175 | + string _t4 = builtin__tos(b, new_len); | |
| 13176 | + { // defer begin | |
| 13177 | + if (pidxs_cap > _const_replace_stack_buffer_size) { | |
| 13178 | + builtin___v_free(pidxs); | |
| 13179 | + } | |
| 13180 | + } // defer end | |
| 13181 | + return _t4; | |
| 13182 | + } | |
| 13183 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 13184 | +} | |
| 13185 | +string builtin__string_replace_each(string s, Array_string vals) { | |
| 13186 | + if (s.len == 0 || vals.len == 0) { | |
| 13187 | + return builtin__string_clone(s); | |
| 13188 | + } | |
| 13189 | + if (VSAFE_MOD_int(vals.len , 2) != 0) { | |
| 13190 | + builtin__eprintln(_S("string.replace_each(): odd number of strings")); | |
| 13191 | + return builtin__string_clone(s); | |
| 13192 | + } | |
| 13193 | + int new_len = s.len; | |
| 13194 | + Array_RepIndex idxs = builtin____new_array_with_default(0, 6, sizeof(RepIndex), 0); | |
| 13195 | + int idx = 0; | |
| 13196 | + string s_ = builtin__string_clone(s); | |
| 13197 | + for (int rep_i = 0; rep_i < vals.len; rep_i += 2) { | |
| 13198 | + string rep = ((string*)vals.data)[rep_i]; | |
| 13199 | + string with = ((string*)vals.data)[rep_i + 1]; | |
| 13200 | + for (;;) { | |
| 13201 | + idx = builtin__string_index_after_(s_, rep, idx); | |
| 13202 | + if (idx == -1) { | |
| 13203 | + break; | |
| 13204 | + } | |
| 13205 | + for (int i = 0; i < rep.len; ++i) { | |
| 13206 | + { // Unsafe block | |
| 13207 | + s_.str[(int)(idx + i)] = 0; | |
| 13208 | + } | |
| 13209 | + } | |
| 13210 | + builtin__array_push((array*)&idxs, _MOV((RepIndex[]){ ((RepIndex){.idx = idx,.val_idx = rep_i,}) })); | |
| 13211 | + idx += rep.len; | |
| 13212 | + new_len += with.len - rep.len; | |
| 13213 | + } | |
| 13214 | + } | |
| 13215 | + if (idxs.len == 0) { | |
| 13216 | + string _t4 = builtin__string_clone(s); | |
| 13217 | + { // defer begin | |
| 13218 | + builtin__array_free(&idxs); | |
| 13219 | + } // defer end | |
| 13220 | + return _t4; | |
| 13221 | + } | |
| 13222 | + if (idxs.len > 0) { v_stable_sort(idxs.data, idxs.len, idxs.element_size, compare_11734835982493514523_RepIndex_by_idx_expr_612e6964780a3c0a622e696478_qsort_adapter); } | |
| 13223 | + ; | |
| 13224 | + u8* buf = builtin__malloc_noscan(new_len + 1); | |
| 13225 | + int idx_pos = 0; | |
| 13226 | + RepIndex cur_idx = ((RepIndex*)idxs.data)[idx_pos]; | |
| 13227 | + int buf_i = 0; | |
| 13228 | + for (int i = 0; i < s.len; i++) { | |
| 13229 | + if (i == cur_idx.idx) { | |
| 13230 | + string rep = ((string*)vals.data)[cur_idx.val_idx]; | |
| 13231 | + string with = ((string*)vals.data)[cur_idx.val_idx + 1]; | |
| 13232 | + for (int j = 0; j < with.len; ++j) { | |
| 13233 | + { // Unsafe block | |
| 13234 | + buf[buf_i] = with.str[ j]; | |
| 13235 | + } | |
| 13236 | + buf_i++; | |
| 13237 | + } | |
| 13238 | + i += rep.len - 1; | |
| 13239 | + idx_pos++; | |
| 13240 | + if (idx_pos < idxs.len) { | |
| 13241 | + cur_idx = ((RepIndex*)idxs.data)[idx_pos]; | |
| 13242 | + } | |
| 13243 | + } else { | |
| 13244 | + { // Unsafe block | |
| 13245 | + buf[buf_i] = s.str[i]; | |
| 13246 | + } | |
| 13247 | + buf_i++; | |
| 13248 | + } | |
| 13249 | + } | |
| 13250 | + { // Unsafe block | |
| 13251 | + buf[new_len] = 0; | |
| 13252 | + string _t5 = builtin__tos(buf, new_len); | |
| 13253 | + { // defer begin | |
| 13254 | + builtin__array_free(&idxs); | |
| 13255 | + } // defer end | |
| 13256 | + return _t5; | |
| 13257 | + } | |
| 13258 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 13259 | +} | |
| 13260 | +string builtin__string_format(string s, Array_string args) { | |
| 13261 | + if (s.len == 0) { | |
| 13262 | + return _S(""); | |
| 13263 | + } | |
| 13264 | + strings__Builder out = strings__new_builder(s.len); | |
| 13265 | + int i = 0; | |
| 13266 | + for (;;) { | |
| 13267 | + if (!(i < s.len)) break; | |
| 13268 | + u8 ch = s.str[ i]; | |
| 13269 | + if (ch == '{') { | |
| 13270 | + if (i + 1 < s.len && s.str[ i + 1] == '{') { | |
| 13271 | + strings__Builder_write_byte(&out, '{'); | |
| 13272 | + i += 2; | |
| 13273 | + continue; | |
| 13274 | + } | |
| 13275 | + int j = i + 1; | |
| 13276 | + if (j >= s.len || !builtin__u8_is_digit(s.str[ j])) { | |
| 13277 | + strings__Builder_write_byte(&out, ch); | |
| 13278 | + i++; | |
| 13279 | + continue; | |
| 13280 | + } | |
| 13281 | + int idx = 0; | |
| 13282 | + bool overflowed = false; | |
| 13283 | + for (;;) { | |
| 13284 | + if (!(j < s.len && builtin__u8_is_digit(s.str[ j]))) break; | |
| 13285 | + int digit = ((int)((rune)(s.str[ j] - '0'))); | |
| 13286 | + if (idx > VSAFE_DIV_int((_const_max_int - digit) , 10)) { | |
| 13287 | + overflowed = true; | |
| 13288 | + break; | |
| 13289 | + } | |
| 13290 | + idx = idx * 10 + digit; | |
| 13291 | + j++; | |
| 13292 | + } | |
| 13293 | + if (!overflowed && j < s.len && s.str[ j] == '}') { | |
| 13294 | + if (idx < args.len) { | |
| 13295 | + strings__Builder_write_string(&out, ((string*)args.data)[idx]); | |
| 13296 | + } else { | |
| 13297 | + strings__Builder_write_string(&out, builtin__string_substr(s, i, j + 1)); | |
| 13298 | + } | |
| 13299 | + i = j + 1; | |
| 13300 | + continue; | |
| 13301 | + } | |
| 13302 | + strings__Builder_write_byte(&out, ch); | |
| 13303 | + i++; | |
| 13304 | + continue; | |
| 13305 | + } | |
| 13306 | + if (ch == '}' && i + 1 < s.len && s.str[ i + 1] == '}') { | |
| 13307 | + strings__Builder_write_byte(&out, '}'); | |
| 13308 | + i += 2; | |
| 13309 | + continue; | |
| 13310 | + } | |
| 13311 | + strings__Builder_write_byte(&out, ch); | |
| 13312 | + i++; | |
| 13313 | + } | |
| 13314 | + return strings__Builder_str(&out); | |
| 13315 | +} | |
| 13316 | +string builtin__string_replace_char(string s, u8 rep, u8 with, int repeat) { | |
| 13317 | + #if 1 | |
| 13318 | + { | |
| 13319 | + if (repeat <= 0) { | |
| 13320 | + builtin___v_panic(_S("string.replace_char(): tab length too short")); | |
| 13321 | + VUNREACHABLE(); | |
| 13322 | + } | |
| 13323 | + } | |
| 13324 | + #endif | |
| 13325 | + if (s.len == 0) { | |
| 13326 | + return builtin__string_clone(s); | |
| 13327 | + } | |
| 13328 | + Array_int idxs = builtin____new_array_with_default(0, v__rshift_int(s.len, (u64)2), sizeof(int), 0); | |
| 13329 | + for (int i = 0; i < s.len; ++i) { | |
| 13330 | + u8 ch = s.str[i]; | |
| 13331 | + if (ch == rep) { | |
| 13332 | + builtin__array_push((array*)&idxs, _MOV((int[]){ i })); | |
| 13333 | + } | |
| 13334 | + } | |
| 13335 | + if (idxs.len == 0) { | |
| 13336 | + string _t4 = builtin__string_clone(s); | |
| 13337 | + { // defer begin | |
| 13338 | + builtin__array_free(&idxs); | |
| 13339 | + } // defer end | |
| 13340 | + return _t4; | |
| 13341 | + } | |
| 13342 | + int new_len = s.len + idxs.len * (repeat - 1); | |
| 13343 | + u8* b = builtin__malloc_noscan(new_len + 1); | |
| 13344 | + int b_i = 0; | |
| 13345 | + int s_idx = 0; | |
| 13346 | + for (int _t5 = 0; _t5 < idxs.len; ++_t5) { | |
| 13347 | + int rep_pos = ((int*)idxs.data)[_t5]; | |
| 13348 | + for (int i = s_idx; i < rep_pos; ++i) { | |
| 13349 | + { // Unsafe block | |
| 13350 | + b[b_i] = s.str[ i]; | |
| 13351 | + } | |
| 13352 | + b_i++; | |
| 13353 | + } | |
| 13354 | + s_idx = rep_pos + 1; | |
| 13355 | + for (int _t6 = 0; _t6 < repeat; ++_t6) { | |
| 13356 | + { // Unsafe block | |
| 13357 | + b[b_i] = with; | |
| 13358 | + } | |
| 13359 | + b_i++; | |
| 13360 | + } | |
| 13361 | + } | |
| 13362 | + if (s_idx < s.len) { | |
| 13363 | + for (int i = s_idx; i < s.len; ++i) { | |
| 13364 | + { // Unsafe block | |
| 13365 | + b[b_i] = s.str[ i]; | |
| 13366 | + } | |
| 13367 | + b_i++; | |
| 13368 | + } | |
| 13369 | + } | |
| 13370 | + { // Unsafe block | |
| 13371 | + b[new_len] = 0; | |
| 13372 | + string _t7 = builtin__tos(b, new_len); | |
| 13373 | + { // defer begin | |
| 13374 | + builtin__array_free(&idxs); | |
| 13375 | + } // defer end | |
| 13376 | + return _t7; | |
| 13377 | + } | |
| 13378 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 13379 | +} | |
| 13380 | +inline string builtin__string_normalize_tabs(string s, int tab_len) { | |
| 13381 | + return builtin__string_replace_char(s, '\t', ' ', tab_len); | |
| 13382 | +} | |
| 13383 | +string builtin__string_expand_tabs(string s, int tab_len) { | |
| 13384 | + if (tab_len <= 0) { | |
| 13385 | + return builtin__string_clone(s); | |
| 13386 | + } | |
| 13387 | + strings__Builder output = strings__new_builder(s.len); | |
| 13388 | + int column = 0; | |
| 13389 | + RunesIterator _t2 = builtin__string_runes_iterator(s); | |
| 13390 | + while (1) { | |
| 13391 | + _option_rune _t3 = builtin__RunesIterator_next(&_t2); | |
| 13392 | + if (_t3.state != 0) break; | |
| 13393 | + rune r = *(rune*)_t3.data; | |
| 13394 | + | |
| 13395 | + if (r == ('\t')) { | |
| 13396 | + int spaces = tab_len - (VSAFE_MOD_int(column , tab_len)); | |
| 13397 | + strings__Builder_write_string(&output, builtin__string_repeat(_S(" "), spaces)); | |
| 13398 | + column += spaces; | |
| 13399 | + } | |
| 13400 | + else if (r == ('\n') || r == ('\r')) { | |
| 13401 | + strings__Builder_write_rune(&output, r); | |
| 13402 | + column = 0; | |
| 13403 | + } | |
| 13404 | + else { | |
| 13405 | + strings__Builder_write_rune(&output, r); | |
| 13406 | + column++; | |
| 13407 | + } | |
| 13408 | + } | |
| 13409 | + return strings__Builder_str(&output); | |
| 13410 | +} | |
| 13411 | +inline bool builtin__string_bool(string s) { | |
| 13412 | + return _SLIT_EQ(s.str, s.len, "true") || _SLIT_EQ(s.str, s.len, "t"); | |
| 13413 | +} | |
| 13414 | +inline i8 builtin__string_i8(string s) { | |
| 13415 | + _result_i64 _t2 = strconv__common_parse_int(s, 0, 8, false, false); | |
| 13416 | + if (_t2.is_error) { | |
| 13417 | + *(i64*) _t2.data = 0; | |
| 13418 | + } | |
| 13419 | + | |
| 13420 | + return ((i8)((*(i64*)_t2.data))); | |
| 13421 | +} | |
| 13422 | +inline i16 builtin__string_i16(string s) { | |
| 13423 | + _result_i64 _t2 = strconv__common_parse_int(s, 0, 16, false, false); | |
| 13424 | + if (_t2.is_error) { | |
| 13425 | + *(i64*) _t2.data = 0; | |
| 13426 | + } | |
| 13427 | + | |
| 13428 | + return ((i16)((*(i64*)_t2.data))); | |
| 13429 | +} | |
| 13430 | +inline i32 builtin__string_i32(string s) { | |
| 13431 | + _result_i64 _t2 = strconv__common_parse_int(s, 0, 32, false, false); | |
| 13432 | + if (_t2.is_error) { | |
| 13433 | + *(i64*) _t2.data = 0; | |
| 13434 | + } | |
| 13435 | + | |
| 13436 | + return ((i32)((*(i64*)_t2.data))); | |
| 13437 | +} | |
| 13438 | +inline int builtin__string_int(string s) { | |
| 13439 | + _result_i64 _t2 = strconv__common_parse_int(s, 0, 32, false, false); | |
| 13440 | + if (_t2.is_error) { | |
| 13441 | + *(i64*) _t2.data = 0; | |
| 13442 | + } | |
| 13443 | + | |
| 13444 | + return ((int)((*(i64*)_t2.data))); | |
| 13445 | +} | |
| 13446 | +inline i64 builtin__string_i64(string s) { | |
| 13447 | + _result_i64 _t2 = strconv__common_parse_int(s, 0, 64, false, false); | |
| 13448 | + if (_t2.is_error) { | |
| 13449 | + *(i64*) _t2.data = 0; | |
| 13450 | + } | |
| 13451 | + | |
| 13452 | + return (*(i64*)_t2.data); | |
| 13453 | +} | |
| 13454 | +inline f32 builtin__string_f32(string s) { | |
| 13455 | + _result_f64 _t2 = strconv__atof64(s, ((strconv__AtoF64Param){.allow_extra_chars = true,})); | |
| 13456 | + if (_t2.is_error) { | |
| 13457 | + *(f64*) _t2.data = 0; | |
| 13458 | + } | |
| 13459 | + | |
| 13460 | + return ((f32)((*(f64*)_t2.data))); | |
| 13461 | +} | |
| 13462 | +inline f64 builtin__string_f64(string s) { | |
| 13463 | + _result_f64 _t2 = strconv__atof64(s, ((strconv__AtoF64Param){.allow_extra_chars = true,})); | |
| 13464 | + if (_t2.is_error) { | |
| 13465 | + *(f64*) _t2.data = 0; | |
| 13466 | + } | |
| 13467 | + | |
| 13468 | + return (*(f64*)_t2.data); | |
| 13469 | +} | |
| 13470 | +Array_u8 builtin__string_u8_array(string s) { | |
| 13471 | + string tmps = builtin__string_replace(s, _S("_"), _S("")); | |
| 13472 | + if (tmps.len == 0) { | |
| 13473 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | |
| 13474 | + } | |
| 13475 | + tmps = builtin__string_to_lower_ascii(tmps); | |
| 13476 | + if (builtin__string_starts_with(tmps, _S("0x"))) { | |
| 13477 | + tmps = builtin__string_substr(tmps, 2, 2147483647); | |
| 13478 | + if (tmps.len == 0) { | |
| 13479 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | |
| 13480 | + } | |
| 13481 | + if (!builtin__string_contains_only(tmps, _S("0123456789abcdef"))) { | |
| 13482 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | |
| 13483 | + } | |
| 13484 | + if (VSAFE_MOD_int(tmps.len , 2) == 1) { | |
| 13485 | + tmps = builtin__string__plus(_S("0"), tmps); | |
| 13486 | + } | |
| 13487 | + Array_u8 ret = builtin____new_array_with_default(VSAFE_DIV_int(tmps.len , 2), 0, sizeof(u8), 0); | |
| 13488 | + for (int i = 0; i < ret.len; ++i) { | |
| 13489 | + _result_u64 _t4 = builtin__string_parse_uint(builtin__string_substr(tmps, 2 * i, 2 * i + 2), 16, 8); | |
| 13490 | + if (_t4.is_error) { | |
| 13491 | + *(u64*) _t4.data = 0; | |
| 13492 | + } | |
| 13493 | + | |
| 13494 | + builtin__array_set(&ret, i, &(u8[]) { ((u8)((*(u64*)_t4.data))) }); | |
| 13495 | + } | |
| 13496 | + return ret; | |
| 13497 | + } else if (builtin__string_starts_with(tmps, _S("0b"))) { | |
| 13498 | + tmps = builtin__string_substr(tmps, 2, 2147483647); | |
| 13499 | + if (tmps.len == 0) { | |
| 13500 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | |
| 13501 | + } | |
| 13502 | + if (!builtin__string_contains_only(tmps, _S("01"))) { | |
| 13503 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | |
| 13504 | + } | |
| 13505 | + if (VSAFE_MOD_int(tmps.len , 8) != 0) { | |
| 13506 | + tmps = builtin__string__plus(builtin__string_repeat(_S("0"), 8 - VSAFE_MOD_int(tmps.len , 8)), tmps); | |
| 13507 | + } | |
| 13508 | + Array_u8 ret = builtin____new_array_with_default(VSAFE_DIV_int(tmps.len , 8), 0, sizeof(u8), 0); | |
| 13509 | + for (int i = 0; i < ret.len; ++i) { | |
| 13510 | + _result_u64 _t8 = builtin__string_parse_uint(builtin__string_substr(tmps, 8 * i, 8 * i + 8), 2, 8); | |
| 13511 | + if (_t8.is_error) { | |
| 13512 | + *(u64*) _t8.data = 0; | |
| 13513 | + } | |
| 13514 | + | |
| 13515 | + builtin__array_set(&ret, i, &(u8[]) { ((u8)((*(u64*)_t8.data))) }); | |
| 13516 | + } | |
| 13517 | + return ret; | |
| 13518 | + } | |
| 13519 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | |
| 13520 | +} | |
| 13521 | +inline u8 builtin__string_u8(string s) { | |
| 13522 | + _result_u64 _t2 = strconv__common_parse_uint(s, 0, 8, false, false); | |
| 13523 | + if (_t2.is_error) { | |
| 13524 | + *(u64*) _t2.data = 0; | |
| 13525 | + } | |
| 13526 | + | |
| 13527 | + return ((u8)((*(u64*)_t2.data))); | |
| 13528 | +} | |
| 13529 | +inline u16 builtin__string_u16(string s) { | |
| 13530 | + _result_u64 _t2 = strconv__common_parse_uint(s, 0, 16, false, false); | |
| 13531 | + if (_t2.is_error) { | |
| 13532 | + *(u64*) _t2.data = 0; | |
| 13533 | + } | |
| 13534 | + | |
| 13535 | + return ((u16)((*(u64*)_t2.data))); | |
| 13536 | +} | |
| 13537 | +inline u32 builtin__string_u32(string s) { | |
| 13538 | + _result_u64 _t2 = strconv__common_parse_uint(s, 0, 32, false, false); | |
| 13539 | + if (_t2.is_error) { | |
| 13540 | + *(u64*) _t2.data = 0; | |
| 13541 | + } | |
| 13542 | + | |
| 13543 | + return ((u32)((*(u64*)_t2.data))); | |
| 13544 | +} | |
| 13545 | +inline u64 builtin__string_u64(string s) { | |
| 13546 | + _result_u64 _t2 = strconv__common_parse_uint(s, 0, 64, false, false); | |
| 13547 | + if (_t2.is_error) { | |
| 13548 | + *(u64*) _t2.data = 0; | |
| 13549 | + } | |
| 13550 | + | |
| 13551 | + return (*(u64*)_t2.data); | |
| 13552 | +} | |
| 13553 | +inline _result_u64 builtin__string_parse_uint(string s, int _base, int _bit_size) { | |
| 13554 | + return strconv__parse_uint(s, _base, _bit_size); | |
| 13555 | +} | |
| 13556 | +inline _result_i64 builtin__string_parse_int(string s, int _base, int _bit_size) { | |
| 13557 | + return strconv__parse_int(s, _base, _bit_size); | |
| 13558 | +} | |
| 13559 | +VV_LOC bool builtin__string__eq(string s, string a) { | |
| 13560 | + if (s.str == 0) { | |
| 13561 | + return a.str == 0 || a.len == 0; | |
| 13562 | + } | |
| 13563 | + if (s.len != a.len) { | |
| 13564 | + return false; | |
| 13565 | + } | |
| 13566 | + { // Unsafe block | |
| 13567 | + return builtin__vmemcmp(s.str, a.str, a.len) == 0; | |
| 13568 | + } | |
| 13569 | + return 0; | |
| 13570 | +} | |
| 13571 | +int builtin__string_compare(string s, string a) { | |
| 13572 | + int min_len = (s.len < a.len ? (s.len) : (a.len)); | |
| 13573 | + for (int i = 0; i < min_len; ++i) { | |
| 13574 | + if (s.str[ i] < a.str[ i]) { | |
| 13575 | + return -1; | |
| 13576 | + } | |
| 13577 | + if (s.str[ i] > a.str[ i]) { | |
| 13578 | + return 1; | |
| 13579 | + } | |
| 13580 | + } | |
| 13581 | + if (s.len < a.len) { | |
| 13582 | + return -1; | |
| 13583 | + } | |
| 13584 | + if (s.len > a.len) { | |
| 13585 | + return 1; | |
| 13586 | + } | |
| 13587 | + return 0; | |
| 13588 | +} | |
| 13589 | +VV_LOC bool builtin__string__lt(string s, string a) { | |
| 13590 | + for (int i = 0; i < s.len; ++i) { | |
| 13591 | + if (i >= a.len || s.str[ i] > a.str[ i]) { | |
| 13592 | + return false; | |
| 13593 | + } else if (s.str[ i] < a.str[ i]) { | |
| 13594 | + return true; | |
| 13595 | + } | |
| 13596 | + } | |
| 13597 | + if (s.len < a.len) { | |
| 13598 | + return true; | |
| 13599 | + } | |
| 13600 | + return false; | |
| 13601 | +} | |
| 13602 | +VV_LOC string builtin__string__plus(string s, string a) { | |
| 13603 | + int slen = (s.len > 0 ? (s.len) : (0)); | |
| 13604 | + int alen = (a.len > 0 ? (a.len) : (0)); | |
| 13605 | + int new_len = alen + slen; | |
| 13606 | + string _t1 = ((string){.str = builtin__malloc_noscan(new_len + 1), .len = new_len}); | |
| 13607 | + string res = _t1; | |
| 13608 | + { // Unsafe block | |
| 13609 | + if (slen > 0) { | |
| 13610 | + builtin__vmemcpy(res.str, s.str, slen); | |
| 13611 | + } | |
| 13612 | + if (alen > 0) { | |
| 13613 | + builtin__vmemcpy(res.str + slen, a.str, alen); | |
| 13614 | + } | |
| 13615 | + res.str[new_len] = 0; | |
| 13616 | + } | |
| 13617 | + return res; | |
| 13618 | +} | |
| 13619 | +VV_LOC string builtin__string_plus_many(int data_len, string* input_base) { | |
| 13620 | + int new_len = 0; | |
| 13621 | + for (int i = 0; i < data_len; i++) { | |
| 13622 | + string part = input_base[i]; | |
| 13623 | + new_len += (part.len > 0 ? (part.len) : (0)); | |
| 13624 | + } | |
| 13625 | + string _t1 = ((string){.str = builtin__malloc_noscan(new_len + 1), .len = new_len}); | |
| 13626 | + string res = _t1; | |
| 13627 | + int offset = 0; | |
| 13628 | + { // Unsafe block | |
| 13629 | + for (int i = 0; i < data_len; i++) { | |
| 13630 | + string part = input_base[i]; | |
| 13631 | + int part_len = (part.len > 0 ? (part.len) : (0)); | |
| 13632 | + if (part_len > 0) { | |
| 13633 | + builtin__vmemcpy(res.str + offset, part.str, part_len); | |
| 13634 | + offset += part_len; | |
| 13635 | + } | |
| 13636 | + } | |
| 13637 | + res.str[new_len] = 0; | |
| 13638 | + } | |
| 13639 | + return res; | |
| 13640 | +} | |
| 13641 | +VV_LOC string builtin__string_plus_two(string s, string a, string b) { | |
| 13642 | + int slen = (s.len > 0 ? (s.len) : (0)); | |
| 13643 | + int alen = (a.len > 0 ? (a.len) : (0)); | |
| 13644 | + int blen = (b.len > 0 ? (b.len) : (0)); | |
| 13645 | + int new_len = alen + blen + slen; | |
| 13646 | + string _t1 = ((string){.str = builtin__malloc_noscan(new_len + 1), .len = new_len}); | |
| 13647 | + string res = _t1; | |
| 13648 | + { // Unsafe block | |
| 13649 | + if (slen > 0) { | |
| 13650 | + builtin__vmemcpy(res.str, s.str, slen); | |
| 13651 | + } | |
| 13652 | + if (alen > 0) { | |
| 13653 | + builtin__vmemcpy(res.str + slen, a.str, alen); | |
| 13654 | + } | |
| 13655 | + if (blen > 0) { | |
| 13656 | + builtin__vmemcpy(res.str + slen + alen, b.str, blen); | |
| 13657 | + } | |
| 13658 | + res.str[new_len] = 0; | |
| 13659 | + } | |
| 13660 | + return res; | |
| 13661 | +} | |
| 13662 | +Array_string builtin__string_split_any(string s, string delim) { | |
| 13663 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | |
| 13664 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | |
| 13665 | + int i = 0; | |
| 13666 | + if (s.len > 0) { | |
| 13667 | + if (delim.len <= 0) { | |
| 13668 | + Array_string _t1 = builtin__string_split(s, _S("")); | |
| 13669 | + { // defer begin | |
| 13670 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | |
| 13671 | + } // defer end | |
| 13672 | + return _t1; | |
| 13673 | + } | |
| 13674 | + for (int index = 0; index < s.len; ++index) { | |
| 13675 | + u8 ch = s.str[index]; | |
| 13676 | + for (int _t2 = 0; _t2 < delim.len; ++_t2) { | |
| 13677 | + u8 delim_ch = delim.str[_t2]; | |
| 13678 | + if (ch == delim_ch) { | |
| 13679 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, i, index) })); | |
| 13680 | + i = index + 1; | |
| 13681 | + break; | |
| 13682 | + } | |
| 13683 | + } | |
| 13684 | + } | |
| 13685 | + if (i < s.len) { | |
| 13686 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, i, 2147483647) })); | |
| 13687 | + } | |
| 13688 | + } | |
| 13689 | + Array_string _t5 = res; | |
| 13690 | + { // defer begin | |
| 13691 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | |
| 13692 | + } // defer end | |
| 13693 | + return _t5; | |
| 13694 | +} | |
| 13695 | +Array_string builtin__string_rsplit_any(string s, string delim) { | |
| 13696 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | |
| 13697 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | |
| 13698 | + int i = s.len - 1; | |
| 13699 | + if (s.len > 0) { | |
| 13700 | + if (delim.len <= 0) { | |
| 13701 | + Array_string _t1 = builtin__string_rsplit(s, _S("")); | |
| 13702 | + { // defer begin | |
| 13703 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | |
| 13704 | + } // defer end | |
| 13705 | + return _t1; | |
| 13706 | + } | |
| 13707 | + int rbound = s.len; | |
| 13708 | + for (;;) { | |
| 13709 | + if (!(i >= 0)) break; | |
| 13710 | + for (int _t2 = 0; _t2 < delim.len; ++_t2) { | |
| 13711 | + u8 delim_ch = delim.str[_t2]; | |
| 13712 | + if (s.str[ i] == delim_ch) { | |
| 13713 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, i + 1, rbound) })); | |
| 13714 | + rbound = i; | |
| 13715 | + break; | |
| 13716 | + } | |
| 13717 | + } | |
| 13718 | + i--; | |
| 13719 | + } | |
| 13720 | + if (rbound > 0) { | |
| 13721 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, 0, rbound) })); | |
| 13722 | + } | |
| 13723 | + } | |
| 13724 | + Array_string _t5 = res; | |
| 13725 | + { // defer begin | |
| 13726 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | |
| 13727 | + } // defer end | |
| 13728 | + return _t5; | |
| 13729 | +} | |
| 13730 | +inline Array_string builtin__string_split(string s, string delim) { | |
| 13731 | + return builtin__string_split_nth(s, delim, 0); | |
| 13732 | +} | |
| 13733 | +inline Array_string builtin__string_rsplit(string s, string delim) { | |
| 13734 | + return builtin__string_rsplit_nth(s, delim, 0); | |
| 13735 | +} | |
| 13736 | +_option_multi_return_string_string builtin__string_split_once(string s, string delim) { | |
| 13737 | + Array_string result = builtin__string_split_nth(s, delim, 2); | |
| 13738 | + if (result.len != 2) { | |
| 13739 | + _option_multi_return_string_string _t1 = (_option_multi_return_string_string){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | |
| 13740 | + return _t1; | |
| 13741 | + } | |
| 13742 | + _option_multi_return_string_string _t2; | |
| 13743 | + builtin___option_ok(&(multi_return_string_string[]) { (multi_return_string_string){.arg0=(*(string*)builtin__array_get(result, 0)), .arg1=(*(string*)builtin__array_get(result, 1))} }, (_option*)(&_t2), sizeof(multi_return_string_string)); | |
| 13744 | + return _t2; | |
| 13745 | +} | |
| 13746 | +_option_multi_return_string_string builtin__string_rsplit_once(string s, string delim) { | |
| 13747 | + Array_string result = builtin__string_rsplit_nth(s, delim, 2); | |
| 13748 | + if (result.len != 2) { | |
| 13749 | + _option_multi_return_string_string _t1 = (_option_multi_return_string_string){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | |
| 13750 | + return _t1; | |
| 13751 | + } | |
| 13752 | + _option_multi_return_string_string _t2; | |
| 13753 | + builtin___option_ok(&(multi_return_string_string[]) { (multi_return_string_string){.arg0=(*(string*)builtin__array_get(result, 1)), .arg1=(*(string*)builtin__array_get(result, 0))} }, (_option*)(&_t2), sizeof(multi_return_string_string)); | |
| 13754 | + return _t2; | |
| 13755 | +} | |
| 13756 | +Array_string builtin__string_split_n(string s, string delim, int n) { | |
| 13757 | + return builtin__string_split_nth(s, delim, n); | |
| 13758 | +} | |
| 13759 | +Array_string builtin__string_split_nth(string s, string delim, int nth) { | |
| 13760 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | |
| 13761 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | |
| 13762 | + switch (delim.len) { | |
| 13763 | + case 0: { | |
| 13764 | + for (int i = 0; i < s.len; ++i) { | |
| 13765 | + u8 ch = s.str[i]; | |
| 13766 | + if (nth > 0 && res.len == nth - 1) { | |
| 13767 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, i, 2147483647) })); | |
| 13768 | + break; | |
| 13769 | + } | |
| 13770 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__u8_ascii_str(ch) })); | |
| 13771 | + } | |
| 13772 | + break; | |
| 13773 | + } | |
| 13774 | + case 1: { | |
| 13775 | + u8 delim_byte = delim.str[ 0]; | |
| 13776 | + int start = 0; | |
| 13777 | + for (int i = 0; i < s.len; ++i) { | |
| 13778 | + u8 ch = s.str[i]; | |
| 13779 | + if (ch == delim_byte) { | |
| 13780 | + if (nth > 0 && res.len == nth - 1) { | |
| 13781 | + break; | |
| 13782 | + } | |
| 13783 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, start, i) })); | |
| 13784 | + start = i + 1; | |
| 13785 | + } | |
| 13786 | + } | |
| 13787 | + if (nth < 1 || res.len < nth) { | |
| 13788 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, start, 2147483647) })); | |
| 13789 | + } | |
| 13790 | + break; | |
| 13791 | + } | |
| 13792 | + default: { | |
| 13793 | + { | |
| 13794 | + int start = 0; | |
| 13795 | + for (int i = 0; i + delim.len <= s.len; ) { | |
| 13796 | + if (builtin__string__eq(builtin__string_substr_unsafe(s, i, i + delim.len), delim)) { | |
| 13797 | + if (nth > 0 && res.len == nth - 1) { | |
| 13798 | + break; | |
| 13799 | + } | |
| 13800 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, start, i) })); | |
| 13801 | + i += delim.len; | |
| 13802 | + start = i; | |
| 13803 | + } else { | |
| 13804 | + i++; | |
| 13805 | + } | |
| 13806 | + } | |
| 13807 | + if (nth < 1 || res.len < nth) { | |
| 13808 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, start, 2147483647) })); | |
| 13809 | + } | |
| 13810 | + break; | |
| 13811 | + } | |
| 13812 | + } | |
| 13813 | + } | |
| 13814 | + | |
| 13815 | + Array_string _t7 = res; | |
| 13816 | + { // defer begin | |
| 13817 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | |
| 13818 | + } // defer end | |
| 13819 | + return _t7; | |
| 13820 | +} | |
| 13821 | +Array_string builtin__string_rsplit_nth(string s, string delim, int nth) { | |
| 13822 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | |
| 13823 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | |
| 13824 | + switch (delim.len) { | |
| 13825 | + case 0: { | |
| 13826 | + for (int i = s.len - 1; i >= 0; i--) { | |
| 13827 | + if (nth > 0 && res.len == nth - 1) { | |
| 13828 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, 0, i + 1) })); | |
| 13829 | + break; | |
| 13830 | + } | |
| 13831 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__u8_ascii_str(s.str[ i]) })); | |
| 13832 | + } | |
| 13833 | + break; | |
| 13834 | + } | |
| 13835 | + case 1: { | |
| 13836 | + u8 delim_byte = delim.str[ 0]; | |
| 13837 | + int rbound = s.len; | |
| 13838 | + for (int i = s.len - 1; i >= 0; i--) { | |
| 13839 | + if (s.str[ i] == delim_byte) { | |
| 13840 | + if (nth > 0 && res.len == nth - 1) { | |
| 13841 | + break; | |
| 13842 | + } | |
| 13843 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, i + 1, rbound) })); | |
| 13844 | + rbound = i; | |
| 13845 | + } | |
| 13846 | + } | |
| 13847 | + if (nth < 1 || res.len < nth) { | |
| 13848 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, 0, rbound) })); | |
| 13849 | + } | |
| 13850 | + break; | |
| 13851 | + } | |
| 13852 | + default: { | |
| 13853 | + { | |
| 13854 | + int rbound = s.len; | |
| 13855 | + for (int i = s.len - 1; i >= 0; i--) { | |
| 13856 | + bool is_delim = i - delim.len >= 0 && builtin__string__eq(builtin__string_substr(s, i - delim.len, i), delim); | |
| 13857 | + if (is_delim) { | |
| 13858 | + if (nth > 0 && res.len == nth - 1) { | |
| 13859 | + break; | |
| 13860 | + } | |
| 13861 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, i, rbound) })); | |
| 13862 | + i -= delim.len; | |
| 13863 | + rbound = i; | |
| 13864 | + } | |
| 13865 | + } | |
| 13866 | + if (nth < 1 || res.len < nth) { | |
| 13867 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, 0, rbound) })); | |
| 13868 | + } | |
| 13869 | + break; | |
| 13870 | + } | |
| 13871 | + } | |
| 13872 | + } | |
| 13873 | + | |
| 13874 | + Array_string _t7 = res; | |
| 13875 | + { // defer begin | |
| 13876 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | |
| 13877 | + } // defer end | |
| 13878 | + return _t7; | |
| 13879 | +} | |
| 13880 | +Array_string builtin__string_split_into_lines(string s) { | |
| 13881 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | |
| 13882 | + if (s.len == 0) { | |
| 13883 | + return res; | |
| 13884 | + } | |
| 13885 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | |
| 13886 | + rune cr = '\r'; | |
| 13887 | + rune lf = '\n'; | |
| 13888 | + int line_start = 0; | |
| 13889 | + for (int i = 0; i < s.len; i++) { | |
| 13890 | + if (line_start <= i) { | |
| 13891 | + if (s.str[ i] == lf) { | |
| 13892 | + builtin__array_push((array*)&res, _MOV((string[]){ (line_start == i ? (_S("")) : (builtin__string_substr(s, line_start, i))) })); | |
| 13893 | + line_start = i + 1; | |
| 13894 | + } else if (s.str[ i] == cr) { | |
| 13895 | + builtin__array_push((array*)&res, _MOV((string[]){ (line_start == i ? (_S("")) : (builtin__string_substr(s, line_start, i))) })); | |
| 13896 | + if ((i + 1) < s.len && s.str[ i + 1] == lf) { | |
| 13897 | + line_start = i + 2; | |
| 13898 | + } else { | |
| 13899 | + line_start = i + 1; | |
| 13900 | + } | |
| 13901 | + } | |
| 13902 | + } | |
| 13903 | + } | |
| 13904 | + if (line_start < s.len) { | |
| 13905 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, line_start, 2147483647) })); | |
| 13906 | + } | |
| 13907 | + Array_string _t5 = res; | |
| 13908 | + { // defer begin | |
| 13909 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | |
| 13910 | + } // defer end | |
| 13911 | + return _t5; | |
| 13912 | +} | |
| 13913 | +Array_string builtin__string_split_by_space(string s) { | |
| 13914 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | |
| 13915 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | |
| 13916 | + Array_string _t1 = builtin__string_split_any(s, _S(" \n\t\v\f\r")); | |
| 13917 | + for (int _t2 = 0; _t2 < _t1.len; ++_t2) { | |
| 13918 | + string word = ((string*)_t1.data)[_t2]; | |
| 13919 | + if ((word).len != 0) { | |
| 13920 | + builtin__array_push((array*)&res, _MOV((string[]){ word })); | |
| 13921 | + } | |
| 13922 | + } | |
| 13923 | + Array_string _t4 = res; | |
| 13924 | + { // defer begin | |
| 13925 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | |
| 13926 | + } // defer end | |
| 13927 | + return _t4; | |
| 13928 | +} | |
| 13929 | +string builtin__string_substr(string s, int start, int _end) { | |
| 13930 | + int end = (_end == _const_max_i64 || _end == _const_max_i32 ? (s.len) : (_end)); | |
| 13931 | + #if 1 | |
| 13932 | + { | |
| 13933 | + if (start > end || start > s.len || end > s.len || start < 0 || end < 0) { | |
| 13934 | + builtin___v_panic(builtin__string_plus_many(8, _MOV((string[8]){_S("substr("), builtin__impl_i64_to_string(start), _S(", "), builtin__impl_i64_to_string(end), _S(") out of bounds (len="), builtin__impl_i64_to_string(s.len), _S(") s="), s}))); | |
| 13935 | + VUNREACHABLE(); | |
| 13936 | + } | |
| 13937 | + } | |
| 13938 | + #endif | |
| 13939 | + int len = end - start; | |
| 13940 | + if (len == s.len) { | |
| 13941 | + return builtin__string_clone(s); | |
| 13942 | + } | |
| 13943 | + string _t3 = ((string){.str = builtin__malloc_noscan(len + 1), .len = len}); | |
| 13944 | + string res = _t3; | |
| 13945 | + { // Unsafe block | |
| 13946 | + builtin__vmemcpy(res.str, s.str + start, len); | |
| 13947 | + res.str[len] = 0; | |
| 13948 | + } | |
| 13949 | + return res; | |
| 13950 | +} | |
| 13951 | +string builtin__string_substr_unsafe(string s, int start, int _end) { | |
| 13952 | + int end = (_end == 2147483647 ? (s.len) : (_end)); | |
| 13953 | + int len = end - start; | |
| 13954 | + if (len == s.len) { | |
| 13955 | + return s; | |
| 13956 | + } | |
| 13957 | + return ((string){.str = s.str + start, .len = len}); | |
| 13958 | +} | |
| 13959 | +string builtin__string_substr_or(string s, int start, int _end, string fallback) { | |
| 13960 | + int end = (_end == _const_max_i64 || _end == _const_max_i32 ? (s.len) : (_end)); | |
| 13961 | + if (start < 0 || start > end || end > s.len) { | |
| 13962 | + return fallback; | |
| 13963 | + } | |
| 13964 | + return builtin__string_substr(s, start, end); | |
| 13965 | +} | |
| 13966 | +_result_string builtin__string_substr_with_check(string s, int start, int _end) { | |
| 13967 | + int end = (_end == _const_max_i64 || _end == _const_max_i32 ? (s.len) : (_end)); | |
| 13968 | + if (start > end || start > s.len || end > s.len || start < 0 || end < 0) { | |
| 13969 | + return (_result_string){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(7, _MOV((string[7]){_S("substr("), builtin__impl_i64_to_string(start), _S(", "), builtin__impl_i64_to_string(end), _S(") out of bounds (len="), builtin__impl_i64_to_string(s.len), _S(")")}))), .data={E_STRUCT} }; | |
| 13970 | + } | |
| 13971 | + int len = end - start; | |
| 13972 | + if (len == s.len) { | |
| 13973 | + _result_string _t2; | |
| 13974 | + builtin___result_ok(&(string[]) { builtin__string_clone(s) }, (_result*)(&_t2), sizeof(string)); | |
| 13975 | + | |
| 13976 | + return _t2; | |
| 13977 | + } | |
| 13978 | + string _t3 = ((string){.str = builtin__malloc_noscan(len + 1), .len = len}); | |
| 13979 | + string res = _t3; | |
| 13980 | + { // Unsafe block | |
| 13981 | + builtin__vmemcpy(res.str, s.str + start, len); | |
| 13982 | + res.str[len] = 0; | |
| 13983 | + } | |
| 13984 | + _result_string _t4; | |
| 13985 | + builtin___result_ok(&(string[]) { res }, (_result*)(&_t4), sizeof(string)); | |
| 13986 | + | |
| 13987 | + return _t4; | |
| 13988 | +} | |
| 13989 | +string builtin__string_substr_ni(string s, int _start, int _end) { | |
| 13990 | + int start = _start; | |
| 13991 | + int end = (_end == _const_max_i64 || _end == _const_max_i32 ? (s.len) : (_end)); | |
| 13992 | + if (start < 0) { | |
| 13993 | + start = s.len + start; | |
| 13994 | + if (start < 0) { | |
| 13995 | + start = 0; | |
| 13996 | + } | |
| 13997 | + } | |
| 13998 | + if (end < 0) { | |
| 13999 | + end = s.len + end; | |
| 14000 | + if (end < 0) { | |
| 14001 | + end = 0; | |
| 14002 | + } | |
| 14003 | + } | |
| 14004 | + if (end >= s.len) { | |
| 14005 | + end = s.len; | |
| 14006 | + } | |
| 14007 | + if (start > s.len || end < start) { | |
| 14008 | + return _S(""); | |
| 14009 | + } | |
| 14010 | + int len = end - start; | |
| 14011 | + string _t2 = ((string){.str = builtin__malloc_noscan(len + 1), .len = len}); | |
| 14012 | + string res = _t2; | |
| 14013 | + { // Unsafe block | |
| 14014 | + builtin__vmemcpy(res.str, s.str + start, len); | |
| 14015 | + res.str[len] = 0; | |
| 14016 | + } | |
| 14017 | + return res; | |
| 14018 | +} | |
| 14019 | +int builtin__string_index_(string s, string p) { | |
| 14020 | + if (p.len > s.len || p.len == 0 || ((u64)(s.str)) <= 0xFFFF || ((u64)(p.str)) <= 0xFFFF) { | |
| 14021 | + return -1; | |
| 14022 | + } | |
| 14023 | + if (p.len > 2) { | |
| 14024 | + return builtin__string_index_kmp(s, p); | |
| 14025 | + } | |
| 14026 | + int i = 0; | |
| 14027 | + for (;;) { | |
| 14028 | + if (!(i < s.len)) break; | |
| 14029 | + int j = 0; | |
| 14030 | + for (;;) { | |
| 14031 | + if (!(j < p.len && s.str[i + j] == p.str[j])) break; | |
| 14032 | + j++; | |
| 14033 | + } | |
| 14034 | + if (j == p.len) { | |
| 14035 | + return i; | |
| 14036 | + } | |
| 14037 | + i++; | |
| 14038 | + } | |
| 14039 | + return -1; | |
| 14040 | +} | |
| 14041 | +_option_int builtin__string_index(string s, string p) { | |
| 14042 | + int idx = builtin__string_index_(s, p); | |
| 14043 | + if (idx == -1) { | |
| 14044 | + return (_option_int){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | |
| 14045 | + } | |
| 14046 | + _option_int _t2; | |
| 14047 | + builtin___option_ok(&(int[]) { idx }, (_option*)(&_t2), sizeof(int)); | |
| 14048 | + | |
| 14049 | + return _t2; | |
| 14050 | +} | |
| 14051 | +inline _option_int builtin__string_last_index(string s, string needle) { | |
| 14052 | + int idx = builtin__string_index_last_(s, needle); | |
| 14053 | + if (idx == -1) { | |
| 14054 | + return (_option_int){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | |
| 14055 | + } | |
| 14056 | + _option_int _t2; | |
| 14057 | + builtin___option_ok(&(int[]) { idx }, (_option*)(&_t2), sizeof(int)); | |
| 14058 | + | |
| 14059 | + return _t2; | |
| 14060 | +} | |
| 14061 | +VV_LOC int builtin__string_index_kmp(string s, string p) { | |
| 14062 | + if (p.len > s.len) { | |
| 14063 | + return -1; | |
| 14064 | + } | |
| 14065 | + Array_fixed_int_20 stack_prefixes = {0}; | |
| 14066 | + int* p_prefixes = &stack_prefixes[0]; | |
| 14067 | + if (p.len > _const_kmp_stack_buffer_size) { | |
| 14068 | + p_prefixes = ((int*)(builtin__vcalloc(p.len * ((int)(sizeof(int)))))); | |
| 14069 | + } | |
| 14070 | + int j = 0; | |
| 14071 | + for (int i = 1; i < p.len; i++) { | |
| 14072 | + for (;;) { | |
| 14073 | + if (!(p.str[j] != p.str[i] && j > 0)) break; | |
| 14074 | + j = p_prefixes[j - 1]; | |
| 14075 | + } | |
| 14076 | + if (p.str[j] == p.str[i]) { | |
| 14077 | + j++; | |
| 14078 | + } | |
| 14079 | + { // Unsafe block | |
| 14080 | + p_prefixes[i] = j; | |
| 14081 | + } | |
| 14082 | + } | |
| 14083 | + j = 0; | |
| 14084 | + for (int i = 0; i < s.len; ++i) { | |
| 14085 | + for (;;) { | |
| 14086 | + if (!(p.str[j] != s.str[i] && j > 0)) break; | |
| 14087 | + j = p_prefixes[j - 1]; | |
| 14088 | + } | |
| 14089 | + if (p.str[j] == s.str[i]) { | |
| 14090 | + j++; | |
| 14091 | + } | |
| 14092 | + if (j == p.len) { | |
| 14093 | + int _t2 = (int)(i - p.len) + 1; | |
| 14094 | + { // defer begin | |
| 14095 | + if (p.len > _const_kmp_stack_buffer_size) { | |
| 14096 | + builtin___v_free(p_prefixes); | |
| 14097 | + } | |
| 14098 | + } // defer end | |
| 14099 | + return _t2; | |
| 14100 | + } | |
| 14101 | + } | |
| 14102 | + int _t3 = -1; | |
| 14103 | + { // defer begin | |
| 14104 | + if (p.len > _const_kmp_stack_buffer_size) { | |
| 14105 | + builtin___v_free(p_prefixes); | |
| 14106 | + } | |
| 14107 | + } // defer end | |
| 14108 | + return _t3; | |
| 14109 | +} | |
| 14110 | +int builtin__string_index_any(string s, string chars) { | |
| 14111 | + for (int i = 0; i < s.len; ++i) { | |
| 14112 | + u8 ss = s.str[i]; | |
| 14113 | + for (int _t1 = 0; _t1 < chars.len; ++_t1) { | |
| 14114 | + u8 c = chars.str[_t1]; | |
| 14115 | + if (c == ss) { | |
| 14116 | + return i; | |
| 14117 | + } | |
| 14118 | + } | |
| 14119 | + } | |
| 14120 | + return -1; | |
| 14121 | +} | |
| 14122 | +VV_LOC int builtin__string_index_last_(string s, string p) { | |
| 14123 | + if (p.len > s.len || p.len == 0) { | |
| 14124 | + return -1; | |
| 14125 | + } | |
| 14126 | + int i = s.len - p.len; | |
| 14127 | + for (;;) { | |
| 14128 | + if (!(i >= 0)) break; | |
| 14129 | + int j = 0; | |
| 14130 | + for (;;) { | |
| 14131 | + if (!(j < p.len && s.str[i + j] == p.str[j])) break; | |
| 14132 | + j++; | |
| 14133 | + } | |
| 14134 | + if (j == p.len) { | |
| 14135 | + return i; | |
| 14136 | + } | |
| 14137 | + i--; | |
| 14138 | + } | |
| 14139 | + return -1; | |
| 14140 | +} | |
| 14141 | +_option_int builtin__string_index_after(string s, string p, int start) { | |
| 14142 | + if (p.len > s.len) { | |
| 14143 | + return (_option_int){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | |
| 14144 | + } | |
| 14145 | + int strt = start; | |
| 14146 | + if (start < 0) { | |
| 14147 | + strt = 0; | |
| 14148 | + } | |
| 14149 | + if (start >= s.len) { | |
| 14150 | + return (_option_int){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | |
| 14151 | + } | |
| 14152 | + int i = strt; | |
| 14153 | + for (;;) { | |
| 14154 | + if (!(i < s.len)) break; | |
| 14155 | + int j = 0; | |
| 14156 | + int ii = i; | |
| 14157 | + for (;;) { | |
| 14158 | + if (!(j < p.len && s.str[ii] == p.str[j])) break; | |
| 14159 | + j++; | |
| 14160 | + ii++; | |
| 14161 | + } | |
| 14162 | + if (j == p.len) { | |
| 14163 | + _option_int _t3; | |
| 14164 | + builtin___option_ok(&(int[]) { i }, (_option*)(&_t3), sizeof(int)); | |
| 14165 | + | |
| 14166 | + return _t3; | |
| 14167 | + } | |
| 14168 | + i++; | |
| 14169 | + } | |
| 14170 | + return (_option_int){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | |
| 14171 | +} | |
| 14172 | +int builtin__string_index_after_(string s, string p, int start) { | |
| 14173 | + if (p.len > s.len) { | |
| 14174 | + return -1; | |
| 14175 | + } | |
| 14176 | + int strt = start; | |
| 14177 | + if (start < 0) { | |
| 14178 | + strt = 0; | |
| 14179 | + } | |
| 14180 | + if (start >= s.len) { | |
| 14181 | + return -1; | |
| 14182 | + } | |
| 14183 | + int i = strt; | |
| 14184 | + for (;;) { | |
| 14185 | + if (!(i < s.len)) break; | |
| 14186 | + int j = 0; | |
| 14187 | + int ii = i; | |
| 14188 | + for (;;) { | |
| 14189 | + if (!(j < p.len && s.str[ii] == p.str[j])) break; | |
| 14190 | + j++; | |
| 14191 | + ii++; | |
| 14192 | + } | |
| 14193 | + if (j == p.len) { | |
| 14194 | + return i; | |
| 14195 | + } | |
| 14196 | + i++; | |
| 14197 | + } | |
| 14198 | + return -1; | |
| 14199 | +} | |
| 14200 | +int builtin__string_index_u8(string s, u8 c) { | |
| 14201 | + for (int i = 0; i < s.len; ++i) { | |
| 14202 | + u8 b = s.str[i]; | |
| 14203 | + if (b == c) { | |
| 14204 | + return i; | |
| 14205 | + } | |
| 14206 | + } | |
| 14207 | + return -1; | |
| 14208 | +} | |
| 14209 | +inline int builtin__string_last_index_u8(string s, u8 c) { | |
| 14210 | + for (int i = s.len - 1; i >= 0; i--) { | |
| 14211 | + if (s.str[ i] == c) { | |
| 14212 | + return i; | |
| 14213 | + } | |
| 14214 | + } | |
| 14215 | + return -1; | |
| 14216 | +} | |
| 14217 | +int builtin__string_count(string s, string substr) { | |
| 14218 | + if (s.len == 0 || substr.len == 0) { | |
| 14219 | + return 0; | |
| 14220 | + } | |
| 14221 | + if (substr.len > s.len) { | |
| 14222 | + return 0; | |
| 14223 | + } | |
| 14224 | + int n = 0; | |
| 14225 | + if (substr.len == 1) { | |
| 14226 | + u8 target = substr.str[ 0]; | |
| 14227 | + for (int _t3 = 0; _t3 < s.len; ++_t3) { | |
| 14228 | + u8 letter = s.str[_t3]; | |
| 14229 | + if (letter == target) { | |
| 14230 | + n++; | |
| 14231 | + } | |
| 14232 | + } | |
| 14233 | + return n; | |
| 14234 | + } | |
| 14235 | + int i = 0; | |
| 14236 | + for (;;) { | |
| 14237 | + i = builtin__string_index_after_(s, substr, i); | |
| 14238 | + if (i == -1) { | |
| 14239 | + return n; | |
| 14240 | + } | |
| 14241 | + i += substr.len; | |
| 14242 | + n++; | |
| 14243 | + } | |
| 14244 | + return 0; | |
| 14245 | +} | |
| 14246 | +bool builtin__string_contains_u8(string s, u8 x) { | |
| 14247 | + for (int _t1 = 0; _t1 < s.len; ++_t1) { | |
| 14248 | + u8 c = s.str[_t1]; | |
| 14249 | + if (x == c) { | |
| 14250 | + return true; | |
| 14251 | + } | |
| 14252 | + } | |
| 14253 | + return false; | |
| 14254 | +} | |
| 14255 | +bool builtin__string_contains(string s, string substr) { | |
| 14256 | + if (substr.len == 0) { | |
| 14257 | + return true; | |
| 14258 | + } | |
| 14259 | + if (substr.len == 1) { | |
| 14260 | + return builtin__string_contains_u8(s, substr.str[0]); | |
| 14261 | + } | |
| 14262 | + return builtin__string_index_(s, substr) != -1; | |
| 14263 | +} | |
| 14264 | +bool builtin__string_contains_any(string s, string chars) { | |
| 14265 | + for (int _t1 = 0; _t1 < chars.len; ++_t1) { | |
| 14266 | + u8 c = chars.str[_t1]; | |
| 14267 | + if (builtin__string_contains_u8(s, c)) { | |
| 14268 | + return true; | |
| 14269 | + } | |
| 14270 | + } | |
| 14271 | + return false; | |
| 14272 | +} | |
| 14273 | +bool builtin__string_contains_only(string s, string chars) { | |
| 14274 | + if (chars.len == 0) { | |
| 14275 | + return false; | |
| 14276 | + } | |
| 14277 | + for (int _t2 = 0; _t2 < s.len; ++_t2) { | |
| 14278 | + u8 ch = s.str[_t2]; | |
| 14279 | + int res = 0; | |
| 14280 | + for (int i = 0; i < chars.len && res == 0; i++) { | |
| 14281 | + res += (int[]){(ch == chars.str[i])?1:0}[0]; | |
| 14282 | + } | |
| 14283 | + if (res == 0) { | |
| 14284 | + return false; | |
| 14285 | + } | |
| 14286 | + } | |
| 14287 | + return true; | |
| 14288 | +} | |
| 14289 | +bool builtin__string_contains_any_substr(string s, Array_string substrs) { | |
| 14290 | + if (substrs.len == 0) { | |
| 14291 | + return true; | |
| 14292 | + } | |
| 14293 | + for (int _t2 = 0; _t2 < substrs.len; ++_t2) { | |
| 14294 | + string sub = ((string*)substrs.data)[_t2]; | |
| 14295 | + if (builtin__string_contains(s, sub)) { | |
| 14296 | + return true; | |
| 14297 | + } | |
| 14298 | + } | |
| 14299 | + return false; | |
| 14300 | +} | |
| 14301 | +bool builtin__string_starts_with(string s, string p) { | |
| 14302 | + if (p.len > s.len || ((u64)(s.str)) <= 0xFFFF || ((u64)(p.str)) <= 0xFFFF) { | |
| 14303 | + return false; | |
| 14304 | + } else if (builtin__vmemcmp(s.str, p.str, p.len) == 0) { | |
| 14305 | + return true; | |
| 14306 | + } | |
| 14307 | + return false; | |
| 14308 | +} | |
| 14309 | +bool builtin__string_ends_with(string s, string p) { | |
| 14310 | + if (p.len > s.len || ((u64)(s.str)) <= 0xFFFF || ((u64)(p.str)) <= 0xFFFF) { | |
| 14311 | + return false; | |
| 14312 | + } else if (builtin__vmemcmp(s.str + s.len - p.len, p.str, p.len) == 0) { | |
| 14313 | + return true; | |
| 14314 | + } | |
| 14315 | + return false; | |
| 14316 | +} | |
| 14317 | +string builtin__string_to_lower_ascii(string s) { | |
| 14318 | + { // Unsafe block | |
| 14319 | + u8* b = builtin__malloc_noscan(s.len + 1); | |
| 14320 | + for (int i = 0; i < s.len; ++i) { | |
| 14321 | + if (s.str[i] >= 'A' && s.str[i] <= 'Z') { | |
| 14322 | + b[i] = (u8)(s.str[i] + 32); | |
| 14323 | + } else { | |
| 14324 | + b[i] = s.str[i]; | |
| 14325 | + } | |
| 14326 | + } | |
| 14327 | + b[s.len] = 0; | |
| 14328 | + return builtin__tos(b, s.len); | |
| 14329 | + } | |
| 14330 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 14331 | +} | |
| 14332 | +string builtin__string_to_lower(string s) { | |
| 14333 | + if (builtin__string_is_pure_ascii(s)) { | |
| 14334 | + return builtin__string_to_lower_ascii(s); | |
| 14335 | + } | |
| 14336 | + Array_rune runes = builtin__string_runes(s); | |
| 14337 | + for (int i = 0; i < runes.len; ++i) { | |
| 14338 | + ((rune*)runes.data)[i] = builtin__rune_to_lower(((rune*)runes.data)[i]); | |
| 14339 | + } | |
| 14340 | + return Array_rune_string(runes); | |
| 14341 | +} | |
| 14342 | +bool builtin__string_is_lower(string s) { | |
| 14343 | + if ((s).len == 0 || builtin__u8_is_digit(s.str[ 0])) { | |
| 14344 | + return false; | |
| 14345 | + } | |
| 14346 | + for (int i = 0; i < s.len; ++i) { | |
| 14347 | + if (s.str[ i] >= 'A' && s.str[ i] <= 'Z') { | |
| 14348 | + return false; | |
| 14349 | + } | |
| 14350 | + } | |
| 14351 | + return true; | |
| 14352 | +} | |
| 14353 | +string builtin__string_to_upper_ascii(string s) { | |
| 14354 | + { // Unsafe block | |
| 14355 | + u8* b = builtin__malloc_noscan(s.len + 1); | |
| 14356 | + for (int i = 0; i < s.len; ++i) { | |
| 14357 | + if (s.str[i] >= 'a' && s.str[i] <= 'z') { | |
| 14358 | + b[i] = (u8)(s.str[i] - 32); | |
| 14359 | + } else { | |
| 14360 | + b[i] = s.str[i]; | |
| 14361 | + } | |
| 14362 | + } | |
| 14363 | + b[s.len] = 0; | |
| 14364 | + return builtin__tos(b, s.len); | |
| 14365 | + } | |
| 14366 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 14367 | +} | |
| 14368 | +string builtin__string_to_upper(string s) { | |
| 14369 | + if (builtin__string_is_pure_ascii(s)) { | |
| 14370 | + return builtin__string_to_upper_ascii(s); | |
| 14371 | + } | |
| 14372 | + Array_rune runes = builtin__string_runes(s); | |
| 14373 | + for (int i = 0; i < runes.len; ++i) { | |
| 14374 | + ((rune*)runes.data)[i] = builtin__rune_to_upper(((rune*)runes.data)[i]); | |
| 14375 | + } | |
| 14376 | + return Array_rune_string(runes); | |
| 14377 | +} | |
| 14378 | +bool builtin__string_is_upper(string s) { | |
| 14379 | + if ((s).len == 0) { | |
| 14380 | + return false; | |
| 14381 | + } | |
| 14382 | + bool has_upper = false; | |
| 14383 | + for (int i = 0; i < s.len; ++i) { | |
| 14384 | + if (s.str[ i] >= 'a' && s.str[ i] <= 'z') { | |
| 14385 | + return false; | |
| 14386 | + } | |
| 14387 | + if (s.str[ i] >= 'A' && s.str[ i] <= 'Z') { | |
| 14388 | + has_upper = true; | |
| 14389 | + } | |
| 14390 | + } | |
| 14391 | + return has_upper; | |
| 14392 | +} | |
| 14393 | +string builtin__string_capitalize(string s) { | |
| 14394 | + if (s.len == 0) { | |
| 14395 | + return _S(""); | |
| 14396 | + } | |
| 14397 | + if (s.len == 1) { | |
| 14398 | + return builtin__string_to_upper(builtin__u8_ascii_str(s.str[ 0])); | |
| 14399 | + } | |
| 14400 | + Array_rune r = builtin__string_runes(s); | |
| 14401 | + string letter = builtin__rune_str(((rune*)r.data)[0]); | |
| 14402 | + string uletter = builtin__string_to_upper(letter); | |
| 14403 | + Array_rune rrest = builtin__array_slice(r, 1, 2147483647); | |
| 14404 | + string srest = Array_rune_string(rrest); | |
| 14405 | + string res = builtin__string__plus(uletter, srest); | |
| 14406 | + return res; | |
| 14407 | +} | |
| 14408 | +string builtin__string_uncapitalize(string s) { | |
| 14409 | + if (s.len == 0) { | |
| 14410 | + return _S(""); | |
| 14411 | + } | |
| 14412 | + if (s.len == 1) { | |
| 14413 | + return builtin__string_to_lower(builtin__u8_ascii_str(s.str[ 0])); | |
| 14414 | + } | |
| 14415 | + Array_rune r = builtin__string_runes(s); | |
| 14416 | + string letter = builtin__rune_str(((rune*)r.data)[0]); | |
| 14417 | + string lletter = builtin__string_to_lower(letter); | |
| 14418 | + Array_rune rrest = builtin__array_slice(r, 1, 2147483647); | |
| 14419 | + string srest = Array_rune_string(rrest); | |
| 14420 | + string res = builtin__string__plus(lletter, srest); | |
| 14421 | + return res; | |
| 14422 | +} | |
| 14423 | +bool builtin__string_is_capital(string s) { | |
| 14424 | + if (s.len == 0 || !(s.str[ 0] >= 'A' && s.str[ 0] <= 'Z')) { | |
| 14425 | + return false; | |
| 14426 | + } | |
| 14427 | + for (int i = 1; i < s.len; ++i) { | |
| 14428 | + if (s.str[ i] >= 'A' && s.str[ i] <= 'Z') { | |
| 14429 | + return false; | |
| 14430 | + } | |
| 14431 | + } | |
| 14432 | + return true; | |
| 14433 | +} | |
| 14434 | +bool builtin__string_starts_with_capital(string s) { | |
| 14435 | + if (s.len == 0 || !builtin__u8_is_capital(s.str[ 0])) { | |
| 14436 | + return false; | |
| 14437 | + } | |
| 14438 | + return true; | |
| 14439 | +} | |
| 14440 | +string builtin__string_title(string s) { | |
| 14441 | + Array_string words = builtin__string_split(s, _S(" ")); | |
| 14442 | + Array_string tit = builtin____new_array_with_default(0, 0, sizeof(string), 0); | |
| 14443 | + for (int _t1 = 0; _t1 < words.len; ++_t1) { | |
| 14444 | + string word = ((string*)words.data)[_t1]; | |
| 14445 | + builtin__array_push((array*)&tit, _MOV((string[]){ builtin__string_capitalize(word) })); | |
| 14446 | + } | |
| 14447 | + string title = Array_string_join(tit, _S(" ")); | |
| 14448 | + return title; | |
| 14449 | +} | |
| 14450 | +bool builtin__string_is_title(string s) { | |
| 14451 | + Array_string words = builtin__string_split(s, _S(" ")); | |
| 14452 | + for (int _t1 = 0; _t1 < words.len; ++_t1) { | |
| 14453 | + string word = ((string*)words.data)[_t1]; | |
| 14454 | + if (!builtin__string_is_capital(word)) { | |
| 14455 | + return false; | |
| 14456 | + } | |
| 14457 | + } | |
| 14458 | + return true; | |
| 14459 | +} | |
| 14460 | +string builtin__string_find_between(string s, string start, string end) { | |
| 14461 | + int start_pos = builtin__string_index_(s, start); | |
| 14462 | + if (start_pos == -1) { | |
| 14463 | + return _S(""); | |
| 14464 | + } | |
| 14465 | + string val = builtin__string_substr(s, start_pos + start.len, 2147483647); | |
| 14466 | + int end_pos = builtin__string_index_(val, end); | |
| 14467 | + if (end_pos == -1) { | |
| 14468 | + return _S(""); | |
| 14469 | + } | |
| 14470 | + return builtin__string_substr(val, 0, end_pos); | |
| 14471 | +} | |
| 14472 | +inline string builtin__string_trim_space(string s) { | |
| 14473 | + return builtin__string_trim(s, _S(" \n\t\v\f\r")); | |
| 14474 | +} | |
| 14475 | +inline string builtin__string_trim_space_left(string s) { | |
| 14476 | + return builtin__string_trim_left(s, _S(" \n\t\v\f\r")); | |
| 14477 | +} | |
| 14478 | +inline string builtin__string_trim_space_right(string s) { | |
| 14479 | + return builtin__string_trim_right(s, _S(" \n\t\v\f\r")); | |
| 14480 | +} | |
| 14481 | +string builtin__string_trim(string s, string cutset) { | |
| 14482 | + if ((s).len == 0 || (cutset).len == 0) { | |
| 14483 | + return builtin__string_clone(s); | |
| 14484 | + } | |
| 14485 | + if (builtin__string_is_pure_ascii(cutset)) { | |
| 14486 | + return builtin__string_trim_chars(s, cutset, TrimMode__trim_both); | |
| 14487 | + } else { | |
| 14488 | + return builtin__string_trim_runes(s, cutset, TrimMode__trim_both); | |
| 14489 | + } | |
| 14490 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 14491 | +} | |
| 14492 | +multi_return_int_int builtin__string_trim_indexes(string s, string cutset) { | |
| 14493 | + int pos_left = 0; | |
| 14494 | + int pos_right = s.len - 1; | |
| 14495 | + bool cs_match = true; | |
| 14496 | + for (;;) { | |
| 14497 | + if (!(pos_left <= s.len && pos_right >= -1 && cs_match)) break; | |
| 14498 | + cs_match = false; | |
| 14499 | + for (int _t1 = 0; _t1 < cutset.len; ++_t1) { | |
| 14500 | + u8 cs = cutset.str[_t1]; | |
| 14501 | + if (s.str[ pos_left] == cs) { | |
| 14502 | + pos_left++; | |
| 14503 | + cs_match = true; | |
| 14504 | + break; | |
| 14505 | + } | |
| 14506 | + } | |
| 14507 | + for (int _t2 = 0; _t2 < cutset.len; ++_t2) { | |
| 14508 | + u8 cs = cutset.str[_t2]; | |
| 14509 | + if (s.str[ pos_right] == cs) { | |
| 14510 | + pos_right--; | |
| 14511 | + cs_match = true; | |
| 14512 | + break; | |
| 14513 | + } | |
| 14514 | + } | |
| 14515 | + if (pos_left > pos_right) { | |
| 14516 | + return (multi_return_int_int){.arg0=0, .arg1=0}; | |
| 14517 | + } | |
| 14518 | + } | |
| 14519 | + return (multi_return_int_int){.arg0=pos_left, .arg1=pos_right + 1}; | |
| 14520 | +} | |
| 14521 | +VV_LOC string builtin__string_trim_chars(string s, string cutset, TrimMode mode) { | |
| 14522 | + int pos_left = 0; | |
| 14523 | + int pos_right = s.len - 1; | |
| 14524 | + bool cs_match = true; | |
| 14525 | + for (;;) { | |
| 14526 | + if (!(pos_left <= s.len && pos_right >= -1 && cs_match)) break; | |
| 14527 | + cs_match = false; | |
| 14528 | + if (mode == TrimMode__trim_left || mode == TrimMode__trim_both) { | |
| 14529 | + for (int _t1 = 0; _t1 < cutset.len; ++_t1) { | |
| 14530 | + u8 cs = cutset.str[_t1]; | |
| 14531 | + if (s.str[ pos_left] == cs) { | |
| 14532 | + pos_left++; | |
| 14533 | + cs_match = true; | |
| 14534 | + break; | |
| 14535 | + } | |
| 14536 | + } | |
| 14537 | + } | |
| 14538 | + if (mode == TrimMode__trim_right || mode == TrimMode__trim_both) { | |
| 14539 | + for (int _t2 = 0; _t2 < cutset.len; ++_t2) { | |
| 14540 | + u8 cs = cutset.str[_t2]; | |
| 14541 | + if (s.str[ pos_right] == cs) { | |
| 14542 | + pos_right--; | |
| 14543 | + cs_match = true; | |
| 14544 | + break; | |
| 14545 | + } | |
| 14546 | + } | |
| 14547 | + } | |
| 14548 | + if (pos_left > pos_right) { | |
| 14549 | + return _S(""); | |
| 14550 | + } | |
| 14551 | + } | |
| 14552 | + return builtin__string_substr(s, pos_left, pos_right + 1); | |
| 14553 | +} | |
| 14554 | +VV_LOC string builtin__string_trim_runes(string s, string cutset, TrimMode mode) { | |
| 14555 | + Array_rune s_runes = builtin__string_runes(s); | |
| 14556 | + Array_rune cs_runes = builtin__string_runes(cutset); | |
| 14557 | + int pos_left = 0; | |
| 14558 | + int pos_right = s_runes.len - 1; | |
| 14559 | + bool cs_match = true; | |
| 14560 | + for (;;) { | |
| 14561 | + if (!(pos_left <= s_runes.len && pos_right >= -1 && cs_match)) break; | |
| 14562 | + cs_match = false; | |
| 14563 | + if (mode == TrimMode__trim_left || mode == TrimMode__trim_both) { | |
| 14564 | + for (int _t1 = 0; _t1 < cs_runes.len; ++_t1) { | |
| 14565 | + rune cs = ((rune*)cs_runes.data)[_t1]; | |
| 14566 | + if (((rune*)s_runes.data)[pos_left] == cs) { | |
| 14567 | + pos_left++; | |
| 14568 | + cs_match = true; | |
| 14569 | + break; | |
| 14570 | + } | |
| 14571 | + } | |
| 14572 | + } | |
| 14573 | + if (mode == TrimMode__trim_right || mode == TrimMode__trim_both) { | |
| 14574 | + for (int _t2 = 0; _t2 < cs_runes.len; ++_t2) { | |
| 14575 | + rune cs = ((rune*)cs_runes.data)[_t2]; | |
| 14576 | + if (((rune*)s_runes.data)[pos_right] == cs) { | |
| 14577 | + pos_right--; | |
| 14578 | + cs_match = true; | |
| 14579 | + break; | |
| 14580 | + } | |
| 14581 | + } | |
| 14582 | + } | |
| 14583 | + if (pos_left > pos_right) { | |
| 14584 | + return _S(""); | |
| 14585 | + } | |
| 14586 | + } | |
| 14587 | + return Array_rune_string(builtin__array_slice(s_runes, pos_left, pos_right + 1)); | |
| 14588 | +} | |
| 14589 | +string builtin__string_trim_left(string s, string cutset) { | |
| 14590 | + if ((s).len == 0 || (cutset).len == 0) { | |
| 14591 | + return builtin__string_clone(s); | |
| 14592 | + } | |
| 14593 | + if (builtin__string_is_pure_ascii(cutset)) { | |
| 14594 | + return builtin__string_trim_chars(s, cutset, TrimMode__trim_left); | |
| 14595 | + } else { | |
| 14596 | + return builtin__string_trim_runes(s, cutset, TrimMode__trim_left); | |
| 14597 | + } | |
| 14598 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 14599 | +} | |
| 14600 | +string builtin__string_trim_right(string s, string cutset) { | |
| 14601 | + if (s.len < 1 || cutset.len < 1) { | |
| 14602 | + return builtin__string_clone(s); | |
| 14603 | + } | |
| 14604 | + if (cutset.len == 1) { | |
| 14605 | + u8 cut = cutset.str[ 0]; | |
| 14606 | + int pos_right = s.len - 1; | |
| 14607 | + for (;;) { | |
| 14608 | + if (!(pos_right >= 0 && s.str[ pos_right] == cut)) break; | |
| 14609 | + pos_right--; | |
| 14610 | + } | |
| 14611 | + if (pos_right < 0) { | |
| 14612 | + return _S(""); | |
| 14613 | + } | |
| 14614 | + return builtin__string_substr(s, 0, pos_right + 1); | |
| 14615 | + } | |
| 14616 | + if (cutset.len == 2 && builtin__string_is_pure_ascii(cutset)) { | |
| 14617 | + u8 cut0 = cutset.str[ 0]; | |
| 14618 | + u8 cut1 = cutset.str[ 1]; | |
| 14619 | + int pos_right = s.len - 1; | |
| 14620 | + for (;;) { | |
| 14621 | + if (!(pos_right >= 0 && (s.str[ pos_right] == cut0 || s.str[ pos_right] == cut1))) break; | |
| 14622 | + pos_right--; | |
| 14623 | + } | |
| 14624 | + if (pos_right < 0) { | |
| 14625 | + return _S(""); | |
| 14626 | + } | |
| 14627 | + return builtin__string_substr(s, 0, pos_right + 1); | |
| 14628 | + } | |
| 14629 | + if (builtin__string_is_pure_ascii(cutset)) { | |
| 14630 | + return builtin__string_trim_chars(s, cutset, TrimMode__trim_right); | |
| 14631 | + } else { | |
| 14632 | + return builtin__string_trim_runes(s, cutset, TrimMode__trim_right); | |
| 14633 | + } | |
| 14634 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 14635 | +} | |
| 14636 | +string builtin__string_trim_string_left(string s, string str) { | |
| 14637 | + if (builtin__string_starts_with(s, str)) { | |
| 14638 | + return builtin__string_substr(s, str.len, 2147483647); | |
| 14639 | + } | |
| 14640 | + return builtin__string_clone(s); | |
| 14641 | +} | |
| 14642 | +string builtin__string_trim_string_right(string s, string str) { | |
| 14643 | + if (builtin__string_ends_with(s, str)) { | |
| 14644 | + return builtin__string_substr(s, 0, s.len - str.len); | |
| 14645 | + } | |
| 14646 | + return builtin__string_clone(s); | |
| 14647 | +} | |
| 14648 | +int builtin__compare_strings(string* a, string* b) { | |
| 14649 | + bool _t2 = true; | |
| 14650 | + int_literal _t3 = 0; | |
| 14651 | + | |
| 14652 | + if (_t2 == (builtin__string__lt(*a, *b))) { | |
| 14653 | + _t3 = -1; | |
| 14654 | + } | |
| 14655 | + else if (_t2 == (builtin__string__lt(*b, *a))) { | |
| 14656 | + _t3 = 1; | |
| 14657 | + } | |
| 14658 | + else { | |
| 14659 | + _t3 = 0; | |
| 14660 | + }return _t3; | |
| 14661 | +} | |
| 14662 | +VV_LOC int builtin__compare_strings_by_len(string* a, string* b) { | |
| 14663 | + bool _t2 = true; | |
| 14664 | + int_literal _t3 = 0; | |
| 14665 | + | |
| 14666 | + if (_t2 == (a->len < b->len)) { | |
| 14667 | + _t3 = -1; | |
| 14668 | + } | |
| 14669 | + else if (_t2 == (a->len > b->len)) { | |
| 14670 | + _t3 = 1; | |
| 14671 | + } | |
| 14672 | + else { | |
| 14673 | + _t3 = 0; | |
| 14674 | + }return _t3; | |
| 14675 | +} | |
| 14676 | +VV_LOC int builtin__compare_lower_strings(string* a, string* b) { | |
| 14677 | + string aa = builtin__string_to_lower(*a); | |
| 14678 | + string bb = builtin__string_to_lower(*b); | |
| 14679 | + return builtin__compare_strings(&aa, &bb); | |
| 14680 | +} | |
| 14681 | +inline void Array_string_sort_ignore_case(Array_string* s) { | |
| 14682 | + if (s->len > 0) { v_stable_sort(s->data, s->len, s->element_size, builtin__compare_lower_strings_qsort_adapter); } | |
| 14683 | + ; | |
| 14684 | +} | |
| 14685 | +inline void Array_string_sort_by_len(Array_string* s) { | |
| 14686 | + if (s->len > 0) { v_stable_sort(s->data, s->len, s->element_size, builtin__compare_strings_by_len_qsort_adapter); } | |
| 14687 | + ; | |
| 14688 | +} | |
| 14689 | +inline string builtin__string_str(string s) { | |
| 14690 | + return builtin__string_clone(s); | |
| 14691 | +} | |
| 14692 | +VV_LOC u8 builtin__string_at(string s, int idx) { | |
| 14693 | + #if 1 | |
| 14694 | + { | |
| 14695 | + if (idx < 0 || idx >= s.len) { | |
| 14696 | + builtin__panic_n2(_S("string index out of range(idx,s.len):"), idx, s.len); | |
| 14697 | + VUNREACHABLE(); | |
| 14698 | + } | |
| 14699 | + } | |
| 14700 | + #endif | |
| 14701 | + return s.str[idx]; | |
| 14702 | +} | |
| 14703 | +VV_LOC u8 builtin__string_at_i64(string s, i64 idx) { | |
| 14704 | + #if 1 | |
| 14705 | + { | |
| 14706 | + if (idx < 0 || idx >= ((i64)(s.len))) { | |
| 14707 | + builtin__panic_n2(_S("string index out of range(idx,s.len):"), idx, s.len); | |
| 14708 | + VUNREACHABLE(); | |
| 14709 | + } | |
| 14710 | + } | |
| 14711 | + #endif | |
| 14712 | + return s.str[((int)(idx))]; | |
| 14713 | +} | |
| 14714 | +VV_LOC u8 builtin__string_at_u64(string s, u64 idx) { | |
| 14715 | + #if 1 | |
| 14716 | + { | |
| 14717 | + if (idx >= ((u64)(s.len))) { | |
| 14718 | + builtin___v_panic(builtin__string_plus_many(4, _MOV((string[4]){_S("string index out of range(idx,s.len): "), builtin__u64_str(idx), _S(", "), builtin__impl_i64_to_string(s.len)}))); | |
| 14719 | + VUNREACHABLE(); | |
| 14720 | + } | |
| 14721 | + } | |
| 14722 | + #endif | |
| 14723 | + return s.str[((int)(idx))]; | |
| 14724 | +} | |
| 14725 | +VV_LOC u8 builtin__string_at_ni(string s, int idx) { | |
| 14726 | + return builtin__string_at(s, builtin__v_ni_index(idx, s.len)); | |
| 14727 | +} | |
| 14728 | +VV_LOC _option_u8 builtin__string_at_with_check(string s, int idx) { | |
| 14729 | + if (idx < 0 || idx >= s.len) { | |
| 14730 | + return (_option_u8){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | |
| 14731 | + } | |
| 14732 | + { // Unsafe block | |
| 14733 | + _option_u8 _t2; | |
| 14734 | + builtin___option_ok(&(u8[]) { s.str[idx] }, (_option*)(&_t2), sizeof(u8)); | |
| 14735 | + | |
| 14736 | + return _t2; | |
| 14737 | + } | |
| 14738 | + return (_option_u8){.state=2, .err=_const_none__, .data={E_STRUCT}}; | |
| 14739 | +} | |
| 14740 | +VV_LOC _option_u8 builtin__string_at_with_check_i64(string s, i64 idx) { | |
| 14741 | + if (idx < 0 || idx >= ((i64)(s.len))) { | |
| 14742 | + return (_option_u8){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | |
| 14743 | + } | |
| 14744 | + { // Unsafe block | |
| 14745 | + _option_u8 _t2; | |
| 14746 | + builtin___option_ok(&(u8[]) { s.str[((int)(idx))] }, (_option*)(&_t2), sizeof(u8)); | |
| 14747 | + | |
| 14748 | + return _t2; | |
| 14749 | + } | |
| 14750 | + return (_option_u8){.state=2, .err=_const_none__, .data={E_STRUCT}}; | |
| 14751 | +} | |
| 14752 | +VV_LOC _option_u8 builtin__string_at_with_check_u64(string s, u64 idx) { | |
| 14753 | + if (idx >= ((u64)(s.len))) { | |
| 14754 | + return (_option_u8){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | |
| 14755 | + } | |
| 14756 | + { // Unsafe block | |
| 14757 | + _option_u8 _t2; | |
| 14758 | + builtin___option_ok(&(u8[]) { s.str[((int)(idx))] }, (_option*)(&_t2), sizeof(u8)); | |
| 14759 | + | |
| 14760 | + return _t2; | |
| 14761 | + } | |
| 14762 | + return (_option_u8){.state=2, .err=_const_none__, .data={E_STRUCT}}; | |
| 14763 | +} | |
| 14764 | +VV_LOC _option_u8 builtin__string_at_with_check_ni(string s, int idx) { | |
| 14765 | + return builtin__string_at_with_check(s, builtin__v_ni_index(idx, s.len)); | |
| 14766 | +} | |
| 14767 | +bool builtin__string_is_oct(string str) { | |
| 14768 | + int i = 0; | |
| 14769 | + if (str.len == 0) { | |
| 14770 | + return false; | |
| 14771 | + } | |
| 14772 | + if (str.str[ i] == '0') { | |
| 14773 | + i++; | |
| 14774 | + } else if (str.str[ i] == '-' || str.str[ i] == '+') { | |
| 14775 | + i++; | |
| 14776 | + if (i < str.len && str.str[ i] == '0') { | |
| 14777 | + i++; | |
| 14778 | + } else { | |
| 14779 | + return false; | |
| 14780 | + } | |
| 14781 | + } else { | |
| 14782 | + return false; | |
| 14783 | + } | |
| 14784 | + if (i < str.len && str.str[ i] == 'o') { | |
| 14785 | + i++; | |
| 14786 | + } else { | |
| 14787 | + return false; | |
| 14788 | + } | |
| 14789 | + if (i == str.len) { | |
| 14790 | + return false; | |
| 14791 | + } | |
| 14792 | + for (;;) { | |
| 14793 | + if (!(i < str.len)) break; | |
| 14794 | + if (str.str[ i] < '0' || str.str[ i] > '7') { | |
| 14795 | + return false; | |
| 14796 | + } | |
| 14797 | + i++; | |
| 14798 | + } | |
| 14799 | + return true; | |
| 14800 | +} | |
| 14801 | +bool builtin__string_is_bin(string str) { | |
| 14802 | + int i = 0; | |
| 14803 | + if (str.len == 0) { | |
| 14804 | + return false; | |
| 14805 | + } | |
| 14806 | + if (str.str[ i] == '0') { | |
| 14807 | + i++; | |
| 14808 | + } else if (str.str[ i] == '-' || str.str[ i] == '+') { | |
| 14809 | + i++; | |
| 14810 | + if (i < str.len && str.str[ i] == '0') { | |
| 14811 | + i++; | |
| 14812 | + } else { | |
| 14813 | + return false; | |
| 14814 | + } | |
| 14815 | + } else { | |
| 14816 | + return false; | |
| 14817 | + } | |
| 14818 | + if (i < str.len && str.str[ i] == 'b') { | |
| 14819 | + i++; | |
| 14820 | + } else { | |
| 14821 | + return false; | |
| 14822 | + } | |
| 14823 | + if (i == str.len) { | |
| 14824 | + return false; | |
| 14825 | + } | |
| 14826 | + for (;;) { | |
| 14827 | + if (!(i < str.len)) break; | |
| 14828 | + if (str.str[ i] < '0' || str.str[ i] > '1') { | |
| 14829 | + return false; | |
| 14830 | + } | |
| 14831 | + i++; | |
| 14832 | + } | |
| 14833 | + return true; | |
| 14834 | +} | |
| 14835 | +bool builtin__string_is_hex(string str) { | |
| 14836 | + int i = 0; | |
| 14837 | + if (str.len == 0) { | |
| 14838 | + return false; | |
| 14839 | + } | |
| 14840 | + if (str.str[ i] == '0') { | |
| 14841 | + i++; | |
| 14842 | + } else if (str.str[ i] == '-' || str.str[ i] == '+') { | |
| 14843 | + i++; | |
| 14844 | + if (i < str.len && str.str[ i] == '0') { | |
| 14845 | + i++; | |
| 14846 | + } else { | |
| 14847 | + return false; | |
| 14848 | + } | |
| 14849 | + } else { | |
| 14850 | + return false; | |
| 14851 | + } | |
| 14852 | + if (i < str.len && str.str[ i] == 'x') { | |
| 14853 | + i++; | |
| 14854 | + } else { | |
| 14855 | + return false; | |
| 14856 | + } | |
| 14857 | + if (i == str.len) { | |
| 14858 | + return false; | |
| 14859 | + } | |
| 14860 | + for (;;) { | |
| 14861 | + if (!(i < str.len)) break; | |
| 14862 | + if ((str.str[ i] < '0' || str.str[ i] > '9') && ((str.str[ i] < 'a' || str.str[ i] > 'f') && (str.str[ i] < 'A' || str.str[ i] > 'F'))) { | |
| 14863 | + return false; | |
| 14864 | + } | |
| 14865 | + i++; | |
| 14866 | + } | |
| 14867 | + return true; | |
| 14868 | +} | |
| 14869 | +bool builtin__string_is_int(string str) { | |
| 14870 | + int i = 0; | |
| 14871 | + if (str.len == 0) { | |
| 14872 | + return false; | |
| 14873 | + } | |
| 14874 | + if ((str.str[ i] != '-' && str.str[ i] != '+') && (!builtin__u8_is_digit(str.str[ i]))) { | |
| 14875 | + return false; | |
| 14876 | + } else { | |
| 14877 | + i++; | |
| 14878 | + } | |
| 14879 | + if (i == str.len && (!builtin__u8_is_digit(str.str[ i - 1]))) { | |
| 14880 | + return false; | |
| 14881 | + } | |
| 14882 | + for (;;) { | |
| 14883 | + if (!(i < str.len)) break; | |
| 14884 | + if (str.str[ i] < '0' || str.str[ i] > '9') { | |
| 14885 | + return false; | |
| 14886 | + } | |
| 14887 | + i++; | |
| 14888 | + } | |
| 14889 | + return true; | |
| 14890 | +} | |
| 14891 | +inline bool builtin__u8_is_space(u8 c) { | |
| 14892 | + return c == 32 || (c > 8 && c < 14) || c == 0x85 || c == 0xa0; | |
| 14893 | +} | |
| 14894 | +inline bool builtin__u8_is_digit(u8 c) { | |
| 14895 | + return c >= '0' && c <= '9'; | |
| 14896 | +} | |
| 14897 | +inline bool builtin__u8_is_hex_digit(u8 c) { | |
| 14898 | + return builtin__u8_is_digit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); | |
| 14899 | +} | |
| 14900 | +inline bool builtin__u8_is_oct_digit(u8 c) { | |
| 14901 | + return c >= '0' && c <= '7'; | |
| 14902 | +} | |
| 14903 | +inline bool builtin__u8_is_bin_digit(u8 c) { | |
| 14904 | + return c == '0' || c == '1'; | |
| 14905 | +} | |
| 14906 | +inline bool builtin__u8_is_letter(u8 c) { | |
| 14907 | + return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); | |
| 14908 | +} | |
| 14909 | +inline bool builtin__u8_is_alnum(u8 c) { | |
| 14910 | + return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'); | |
| 14911 | +} | |
| 14912 | +void builtin__string_free(string* s) { | |
| 14913 | + if (s->is_lit == -98761234) { | |
| 14914 | + u8* double_free_msg = ((u8*)("double string.free() detected\n")); | |
| 14915 | + int double_free_msg_len = builtin__vstrlen(double_free_msg); | |
| 14916 | + #if 0 | |
| 14917 | + { | |
| 14918 | + } | |
| 14919 | + #else | |
| 14920 | + { | |
| 14921 | + builtin___write_buf_to_fd(1, double_free_msg, double_free_msg_len); | |
| 14922 | + } | |
| 14923 | + #endif | |
| 14924 | + return; | |
| 14925 | + } | |
| 14926 | + if (s->is_lit == 1 || s->str == 0) { | |
| 14927 | + return; | |
| 14928 | + } | |
| 14929 | + { // Unsafe block | |
| 14930 | + builtin___v_free(s->str); | |
| 14931 | + s->str = ((void*)0); | |
| 14932 | + } | |
| 14933 | + s->len = 0; | |
| 14934 | + s->is_lit = -98761234; | |
| 14935 | +} | |
| 14936 | +string builtin__string_before(string s, string sub) { | |
| 14937 | + int pos = builtin__string_index_(s, sub); | |
| 14938 | + if (pos == -1) { | |
| 14939 | + return builtin__string_clone(s); | |
| 14940 | + } | |
| 14941 | + return builtin__string_substr(s, 0, pos); | |
| 14942 | +} | |
| 14943 | +string builtin__string_all_before(string s, string sub) { | |
| 14944 | + int pos = builtin__string_index_(s, sub); | |
| 14945 | + if (pos == -1) { | |
| 14946 | + return builtin__string_clone(s); | |
| 14947 | + } | |
| 14948 | + return builtin__string_substr(s, 0, pos); | |
| 14949 | +} | |
| 14950 | +string builtin__string_all_before_last(string s, string sub) { | |
| 14951 | + int pos = builtin__string_index_last_(s, sub); | |
| 14952 | + if (pos == -1) { | |
| 14953 | + return builtin__string_clone(s); | |
| 14954 | + } | |
| 14955 | + return builtin__string_substr(s, 0, pos); | |
| 14956 | +} | |
| 14957 | +string builtin__string_all_after(string s, string sub) { | |
| 14958 | + int pos = builtin__string_index_(s, sub); | |
| 14959 | + if (pos == -1) { | |
| 14960 | + return builtin__string_clone(s); | |
| 14961 | + } | |
| 14962 | + return builtin__string_substr(s, pos + sub.len, 2147483647); | |
| 14963 | +} | |
| 14964 | +string builtin__string_all_after_last(string s, string sub) { | |
| 14965 | + int pos = builtin__string_index_last_(s, sub); | |
| 14966 | + if (pos == -1) { | |
| 14967 | + return builtin__string_clone(s); | |
| 14968 | + } | |
| 14969 | + return builtin__string_substr(s, pos + sub.len, 2147483647); | |
| 14970 | +} | |
| 14971 | +string builtin__string_all_after_first(string s, string sub) { | |
| 14972 | + int pos = builtin__string_index_(s, sub); | |
| 14973 | + if (pos == -1) { | |
| 14974 | + return builtin__string_clone(s); | |
| 14975 | + } | |
| 14976 | + return builtin__string_substr(s, pos + sub.len, 2147483647); | |
| 14977 | +} | |
| 14978 | +inline string builtin__string_after(string s, string sub) { | |
| 14979 | + return builtin__string_all_after_last(s, sub); | |
| 14980 | +} | |
| 14981 | +string builtin__string_after_char(string s, u8 sub) { | |
| 14982 | + int pos = -1; | |
| 14983 | + for (int i = 0; i < s.len; ++i) { | |
| 14984 | + u8 c = s.str[i]; | |
| 14985 | + if (c == sub) { | |
| 14986 | + pos = i; | |
| 14987 | + break; | |
| 14988 | + } | |
| 14989 | + } | |
| 14990 | + if (pos == -1) { | |
| 14991 | + return builtin__string_clone(s); | |
| 14992 | + } | |
| 14993 | + return builtin__string_substr(s, pos + 1, 2147483647); | |
| 14994 | +} | |
| 14995 | +string Array_string_join(Array_string a, string sep) { | |
| 14996 | + if (a.len == 0) { | |
| 14997 | + return _S(""); | |
| 14998 | + } | |
| 14999 | + int len = 0; | |
| 15000 | + for (int _t2 = 0; _t2 < a.len; ++_t2) { | |
| 15001 | + string val = ((string*)a.data)[_t2]; | |
| 15002 | + len += val.len + sep.len; | |
| 15003 | + } | |
| 15004 | + len -= sep.len; | |
| 15005 | + string _t3 = ((string){.str = builtin__malloc_noscan(len + 1), .len = len}); | |
| 15006 | + string res = _t3; | |
| 15007 | + int idx = 0; | |
| 15008 | + for (int i = 0; i < a.len; ++i) { | |
| 15009 | + string val = ((string*)a.data)[i]; | |
| 15010 | + { // Unsafe block | |
| 15011 | + builtin__vmemcpy(((voidptr)(res.str + idx)), val.str, val.len); | |
| 15012 | + idx += val.len; | |
| 15013 | + } | |
| 15014 | + if (i != a.len - 1) { | |
| 15015 | + { // Unsafe block | |
| 15016 | + builtin__vmemcpy(((voidptr)(res.str + idx)), sep.str, sep.len); | |
| 15017 | + idx += sep.len; | |
| 15018 | + } | |
| 15019 | + } | |
| 15020 | + } | |
| 15021 | + { // Unsafe block | |
| 15022 | + res.str[res.len] = 0; | |
| 15023 | + } | |
| 15024 | + return res; | |
| 15025 | +} | |
| 15026 | +inline string Array_string_join_lines(Array_string s) { | |
| 15027 | + return Array_string_join(s, _S("\n")); | |
| 15028 | +} | |
| 15029 | +string builtin__string_reverse(string s) { | |
| 15030 | + if (s.len == 0 || s.len == 1) { | |
| 15031 | + return builtin__string_clone(s); | |
| 15032 | + } | |
| 15033 | + string _t2 = ((string){.str = builtin__malloc_noscan(s.len + 1), .len = s.len}); | |
| 15034 | + string res = _t2; | |
| 15035 | + for (int i = s.len - 1; i >= 0; i--) { | |
| 15036 | + { // Unsafe block | |
| 15037 | + res.str[s.len - i - 1] = s.str[ i]; | |
| 15038 | + } | |
| 15039 | + } | |
| 15040 | + { // Unsafe block | |
| 15041 | + res.str[res.len] = 0; | |
| 15042 | + } | |
| 15043 | + return res; | |
| 15044 | +} | |
| 15045 | +string builtin__string_limit(string s, int max) { | |
| 15046 | + Array_rune u = builtin__string_runes(s); | |
| 15047 | + if (u.len <= max) { | |
| 15048 | + return builtin__string_clone(s); | |
| 15049 | + } | |
| 15050 | + return Array_rune_string(builtin__array_slice(u, 0, max)); | |
| 15051 | +} | |
| 15052 | +int builtin__string_hash(string s) { | |
| 15053 | + u32 h = ((u32)(0)); | |
| 15054 | + if (h == 0 && s.len > 0) { | |
| 15055 | + for (int _t1 = 0; _t1 < s.len; ++_t1) { | |
| 15056 | + u8 c = s.str[_t1]; | |
| 15057 | + h = h * 31 + ((u32)(c)); | |
| 15058 | + } | |
| 15059 | + } | |
| 15060 | + return ((int)(h)); | |
| 15061 | +} | |
| 15062 | +Array_u8 builtin__string_bytes(string s) { | |
| 15063 | + if (s.len == 0) { | |
| 15064 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | |
| 15065 | + } | |
| 15066 | + Array_u8 buf = builtin____new_array_with_default(s.len, 0, sizeof(u8), 0); | |
| 15067 | + builtin__vmemcpy(buf.data, s.str, s.len); | |
| 15068 | + return buf; | |
| 15069 | +} | |
| 15070 | +string builtin__string_repeat(string s, int count) { | |
| 15071 | + if (count <= 0) { | |
| 15072 | + return _S(""); | |
| 15073 | + } else if (count == 1) { | |
| 15074 | + return builtin__string_clone(s); | |
| 15075 | + } | |
| 15076 | + u8* ret = builtin__malloc_noscan(s.len * count + 1); | |
| 15077 | + for (int i = 0; i < count; ++i) { | |
| 15078 | + builtin__vmemcpy(ret + (int)(i * s.len), s.str, s.len); | |
| 15079 | + } | |
| 15080 | + int new_len = s.len * count; | |
| 15081 | + { // Unsafe block | |
| 15082 | + ret[new_len] = 0; | |
| 15083 | + } | |
| 15084 | + return builtin__u8_vstring_with_len(ret, new_len); | |
| 15085 | +} | |
| 15086 | +Array_string builtin__string_fields(string s) { | |
| 15087 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | |
| 15088 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | |
| 15089 | + int word_start = 0; | |
| 15090 | + int word_len = 0; | |
| 15091 | + bool is_in_word = false; | |
| 15092 | + bool is_space = false; | |
| 15093 | + for (int i = 0; i < s.len; ++i) { | |
| 15094 | + u8 c = s.str[i]; | |
| 15095 | + is_space = (c == 32 || c == 9 || c == 10); | |
| 15096 | + if (!is_space) { | |
| 15097 | + word_len++; | |
| 15098 | + } | |
| 15099 | + if (!is_in_word && !is_space) { | |
| 15100 | + word_start = i; | |
| 15101 | + is_in_word = true; | |
| 15102 | + continue; | |
| 15103 | + } | |
| 15104 | + if (is_space && is_in_word) { | |
| 15105 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, word_start, word_start + word_len) })); | |
| 15106 | + is_in_word = false; | |
| 15107 | + word_len = 0; | |
| 15108 | + word_start = 0; | |
| 15109 | + continue; | |
| 15110 | + } | |
| 15111 | + } | |
| 15112 | + if (is_in_word && word_len > 0) { | |
| 15113 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, word_start, s.len) })); | |
| 15114 | + } | |
| 15115 | + Array_string _t3 = res; | |
| 15116 | + { // defer begin | |
| 15117 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | |
| 15118 | + } // defer end | |
| 15119 | + return _t3; | |
| 15120 | +} | |
| 15121 | +inline string builtin__string_strip_margin(string s) { | |
| 15122 | + return builtin__string_strip_margin_custom(s, '|'); | |
| 15123 | +} | |
| 15124 | +string builtin__string_strip_margin_custom(string s, u8 del) { | |
| 15125 | + u8 sep = del; | |
| 15126 | + if (builtin__u8_is_space(sep)) { | |
| 15127 | + builtin__println(_S("Warning: `strip_margin` cannot use white-space as a delimiter")); | |
| 15128 | + builtin__println(_S(" Defaulting to `|`")); | |
| 15129 | + sep = '|'; | |
| 15130 | + } | |
| 15131 | + u8* ret = builtin__malloc_noscan(s.len + 1); | |
| 15132 | + int count = 0; | |
| 15133 | + for (int i = 0; i < s.len; i++) { | |
| 15134 | + if (s.str[ i] == 10 || s.str[ i] == 13) { | |
| 15135 | + { // Unsafe block | |
| 15136 | + ret[count] = s.str[ i]; | |
| 15137 | + } | |
| 15138 | + count++; | |
| 15139 | + if (s.str[ i] == 13 && i < s.len - 1 && s.str[ i + 1] == 10) { | |
| 15140 | + { // Unsafe block | |
| 15141 | + ret[count] = s.str[ i + 1]; | |
| 15142 | + } | |
| 15143 | + count++; | |
| 15144 | + i++; | |
| 15145 | + } | |
| 15146 | + for (;;) { | |
| 15147 | + if (!(s.str[ i] != sep)) break; | |
| 15148 | + i++; | |
| 15149 | + if (i >= s.len) { | |
| 15150 | + break; | |
| 15151 | + } | |
| 15152 | + } | |
| 15153 | + } else { | |
| 15154 | + { // Unsafe block | |
| 15155 | + ret[count] = s.str[ i]; | |
| 15156 | + } | |
| 15157 | + count++; | |
| 15158 | + } | |
| 15159 | + } | |
| 15160 | + { // Unsafe block | |
| 15161 | + ret[count] = 0; | |
| 15162 | + return builtin__u8_vstring_with_len(ret, count); | |
| 15163 | + } | |
| 15164 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 15165 | +} | |
| 15166 | +string builtin__string_trim_indent(string s) { | |
| 15167 | + Array_string lines = builtin__string_split_into_lines(s); | |
| 15168 | + int min_common_indent = ((int)(_const_max_int)); | |
| 15169 | + for (int _t1 = 0; _t1 < lines.len; ++_t1) { | |
| 15170 | + string line = ((string*)lines.data)[_t1]; | |
| 15171 | + if (builtin__string_is_blank(line)) { | |
| 15172 | + continue; | |
| 15173 | + } | |
| 15174 | + int line_indent = builtin__string_indent_width(line); | |
| 15175 | + if (line_indent < min_common_indent) { | |
| 15176 | + min_common_indent = line_indent; | |
| 15177 | + } | |
| 15178 | + } | |
| 15179 | + if (lines.len > 0 && builtin__string_is_blank((*(string*)builtin__array_first(lines)))) { | |
| 15180 | + lines = builtin__array_slice(lines, 1, 2147483647); | |
| 15181 | + } | |
| 15182 | + if (lines.len > 0 && builtin__string_is_blank((*(string*)builtin__array_last(lines)))) { | |
| 15183 | + lines = builtin__array_slice(lines, 0, lines.len - 1); | |
| 15184 | + } | |
| 15185 | + Array_string trimmed_lines = builtin____new_array_with_default(0, lines.len, sizeof(string), 0); | |
| 15186 | + for (int _t2 = 0; _t2 < lines.len; ++_t2) { | |
| 15187 | + string line = ((string*)lines.data)[_t2]; | |
| 15188 | + if (builtin__string_is_blank(line)) { | |
| 15189 | + builtin__array_push((array*)&trimmed_lines, _MOV((string[]){ line })); | |
| 15190 | + continue; | |
| 15191 | + } | |
| 15192 | + builtin__array_push((array*)&trimmed_lines, _MOV((string[]){ builtin__string_substr(line, min_common_indent, 2147483647) })); | |
| 15193 | + } | |
| 15194 | + return Array_string_join(trimmed_lines, _S("\n")); | |
| 15195 | +} | |
| 15196 | +int builtin__string_indent_width(string s) { | |
| 15197 | + for (int i = 0; i < s.len; ++i) { | |
| 15198 | + u8 c = s.str[i]; | |
| 15199 | + if (!builtin__u8_is_space(c)) { | |
| 15200 | + return i; | |
| 15201 | + } | |
| 15202 | + } | |
| 15203 | + return 0; | |
| 15204 | +} | |
| 15205 | +bool builtin__string_is_blank(string s) { | |
| 15206 | + if (s.len == 0) { | |
| 15207 | + return true; | |
| 15208 | + } | |
| 15209 | + for (int _t2 = 0; _t2 < s.len; ++_t2) { | |
| 15210 | + u8 c = s.str[_t2]; | |
| 15211 | + if (!builtin__u8_is_space(c)) { | |
| 15212 | + return false; | |
| 15213 | + } | |
| 15214 | + } | |
| 15215 | + return true; | |
| 15216 | +} | |
| 15217 | +bool builtin__string_match_glob(string name, string pattern) { | |
| 15218 | + int px = 0; | |
| 15219 | + int nx = 0; | |
| 15220 | + int next_px = 0; | |
| 15221 | + int next_nx = 0; | |
| 15222 | + int plen = pattern.len; | |
| 15223 | + int nlen = name.len; | |
| 15224 | + for (;;) { | |
| 15225 | + if (!(px < plen || nx < nlen)) break; | |
| 15226 | + if (px < plen) { | |
| 15227 | + u8 c = pattern.str[ px]; | |
| 15228 | + | |
| 15229 | + if (c == ('?')) { | |
| 15230 | + if (nx < nlen) { | |
| 15231 | + px++; | |
| 15232 | + nx++; | |
| 15233 | + continue; | |
| 15234 | + } | |
| 15235 | + } | |
| 15236 | + else if (c == ('*')) { | |
| 15237 | + next_px = px; | |
| 15238 | + next_nx = nx + 1; | |
| 15239 | + px++; | |
| 15240 | + continue; | |
| 15241 | + } | |
| 15242 | + else if (c == ('[')) { | |
| 15243 | + if (nx < nlen) { | |
| 15244 | + u8 wanted_c = name.str[ nx]; | |
| 15245 | + bool is_inverted = false; | |
| 15246 | + bool inner_match = false; | |
| 15247 | + int inner_idx = px + 1; | |
| 15248 | + if (inner_idx < plen && pattern.str[ inner_idx] == '^') { | |
| 15249 | + is_inverted = true; | |
| 15250 | + inner_idx++; | |
| 15251 | + } | |
| 15252 | + for (; inner_idx < plen && pattern.str[ inner_idx] != ']'; inner_idx++) { | |
| 15253 | + if (pattern.str[ inner_idx] == wanted_c) { | |
| 15254 | + inner_match = true; | |
| 15255 | + } | |
| 15256 | + } | |
| 15257 | + if (inner_idx < plen && ((inner_match && !is_inverted) || (!inner_match && is_inverted))) { | |
| 15258 | + px = inner_idx + 1; | |
| 15259 | + nx++; | |
| 15260 | + continue; | |
| 15261 | + } | |
| 15262 | + } | |
| 15263 | + } | |
| 15264 | + else { | |
| 15265 | + if (nx < nlen && name.str[ nx] == c) { | |
| 15266 | + px++; | |
| 15267 | + nx++; | |
| 15268 | + continue; | |
| 15269 | + } | |
| 15270 | + } | |
| 15271 | + } | |
| 15272 | + if (0 < next_nx && next_nx <= nlen) { | |
| 15273 | + px = next_px; | |
| 15274 | + nx = next_nx; | |
| 15275 | + continue; | |
| 15276 | + } | |
| 15277 | + return false; | |
| 15278 | + } | |
| 15279 | + return true; | |
| 15280 | +} | |
| 15281 | +inline bool builtin__string_is_ascii(string s) { | |
| 15282 | + for (int i = 0; i < s.len; i++) { | |
| 15283 | + if (s.str[ i] < ((u8)(' ')) || s.str[ i] > ((u8)('~'))) { | |
| 15284 | + return false; | |
| 15285 | + } | |
| 15286 | + } | |
| 15287 | + return true; | |
| 15288 | +} | |
| 15289 | +bool builtin__string_is_identifier(string s) { | |
| 15290 | + if (s.len == 0) { | |
| 15291 | + return false; | |
| 15292 | + } | |
| 15293 | + if (!(builtin__u8_is_letter(s.str[ 0]) || s.str[ 0] == '_')) { | |
| 15294 | + return false; | |
| 15295 | + } | |
| 15296 | + for (int i = 1; i < s.len; i++) { | |
| 15297 | + u8 c = s.str[ i]; | |
| 15298 | + if (!(builtin__u8_is_letter(c) || builtin__u8_is_digit(c) || c == '_')) { | |
| 15299 | + return false; | |
| 15300 | + } | |
| 15301 | + } | |
| 15302 | + return true; | |
| 15303 | +} | |
| 15304 | +string builtin__string_camel_to_snake(string s) { | |
| 15305 | + if (s.len == 0) { | |
| 15306 | + return _S(""); | |
| 15307 | + } | |
| 15308 | + if (s.len == 1) { | |
| 15309 | + return builtin__string_to_lower_ascii(s); | |
| 15310 | + } | |
| 15311 | + u8* b = builtin__malloc_noscan(2 * s.len + 1); | |
| 15312 | + int pos = 2; | |
| 15313 | + bool prev_is_upper = false; | |
| 15314 | + bool prev_inserted_boundary = false; | |
| 15315 | + { // Unsafe block | |
| 15316 | + if (builtin__u8_is_capital(s.str[ 0])) { | |
| 15317 | + b[0] = (u8)(s.str[ 0] + 32); | |
| 15318 | + u8 _t3; /* if prepend */ | |
| 15319 | + if (builtin__u8_is_capital(s.str[ 1])) { | |
| 15320 | + prev_is_upper = true; | |
| 15321 | + _t3 = (u8)(s.str[ 1] + 32); | |
| 15322 | + goto _t4; | |
| 15323 | + }; | |
| 15324 | + { | |
| 15325 | + _t3 = s.str[ 1]; | |
| 15326 | + } | |
| 15327 | + _t4: {}; | |
| 15328 | + b[1] = _t3; | |
| 15329 | + } else { | |
| 15330 | + b[0] = s.str[ 0]; | |
| 15331 | + if (builtin__u8_is_capital(s.str[ 1])) { | |
| 15332 | + prev_is_upper = true; | |
| 15333 | + if (s.str[ 0] != '_' && s.len > 2 && !builtin__u8_is_capital(s.str[ 2])) { | |
| 15334 | + b[1] = '_'; | |
| 15335 | + b[2] = (u8)(s.str[ 1] + 32); | |
| 15336 | + pos = 3; | |
| 15337 | + } else { | |
| 15338 | + b[1] = (u8)(s.str[ 1] + 32); | |
| 15339 | + } | |
| 15340 | + } else { | |
| 15341 | + b[1] = s.str[ 1]; | |
| 15342 | + } | |
| 15343 | + } | |
| 15344 | + } | |
| 15345 | + for (int i = 2; i < s.len; i++) { | |
| 15346 | + bool has_boundary_before_upper = false; | |
| 15347 | + u8 c = s.str[ i]; | |
| 15348 | + bool c_is_upper = builtin__u8_is_capital(c); | |
| 15349 | + bool c_is_number = builtin__u8_is_digit(c); | |
| 15350 | + bool next_is_lower = i + 1 < s.len && builtin__u8_is_letter(s.str[ i + 1]) && !builtin__u8_is_capital(s.str[ i + 1]); | |
| 15351 | + bool next2_is_lower = i + 2 < s.len && builtin__u8_is_letter(s.str[ i + 2]) && !builtin__u8_is_capital(s.str[ i + 2]); | |
| 15352 | + bool skip_digit = c_is_number && prev_is_upper && !next_is_lower && next2_is_lower; | |
| 15353 | + if (c_is_upper && prev_is_upper && i >= 2 && builtin__u8_is_capital(s.str[ i - 2]) && next_is_lower && c != '_') { | |
| 15354 | + { // Unsafe block | |
| 15355 | + if (b[pos - 1] != '_') { | |
| 15356 | + b[pos] = '_'; | |
| 15357 | + pos++; | |
| 15358 | + } | |
| 15359 | + } | |
| 15360 | + has_boundary_before_upper = true; | |
| 15361 | + } | |
| 15362 | + if (((c_is_upper && !prev_is_upper) || (!c_is_upper && prev_is_upper && builtin__u8_is_capital(s.str[ i - 2]) && !prev_inserted_boundary && !skip_digit)) && c != '_') { | |
| 15363 | + { // Unsafe block | |
| 15364 | + if (b[pos - 1] != '_') { | |
| 15365 | + b[pos] = '_'; | |
| 15366 | + pos++; | |
| 15367 | + } | |
| 15368 | + } | |
| 15369 | + } | |
| 15370 | + u8 lower_c = (c_is_upper ? ((u8)(c + 32)) : (c)); | |
| 15371 | + { // Unsafe block | |
| 15372 | + b[pos] = lower_c; | |
| 15373 | + } | |
| 15374 | + prev_is_upper = c_is_upper; | |
| 15375 | + prev_inserted_boundary = has_boundary_before_upper; | |
| 15376 | + pos++; | |
| 15377 | + } | |
| 15378 | + { // Unsafe block | |
| 15379 | + b[pos] = 0; | |
| 15380 | + } | |
| 15381 | + return builtin__tos(b, pos); | |
| 15382 | +} | |
| 15383 | +string builtin__string_snake_to_camel(string s) { | |
| 15384 | + if (s.len == 0) { | |
| 15385 | + return _S(""); | |
| 15386 | + } | |
| 15387 | + if (s.len == 1) { | |
| 15388 | + return s; | |
| 15389 | + } | |
| 15390 | + bool need_upper = true; | |
| 15391 | + rune upper_c = '_'; | |
| 15392 | + u8* b = builtin__malloc_noscan(s.len + 1); | |
| 15393 | + int i = 0; | |
| 15394 | + for (int _t3 = 0; _t3 < s.len; ++_t3) { | |
| 15395 | + u8 c = s.str[_t3]; | |
| 15396 | + upper_c = (c >= 'a' && c <= 'z' ? ((u8)(c - 32)) : (c)); | |
| 15397 | + if (c == '_') { | |
| 15398 | + need_upper = true; | |
| 15399 | + } else if (need_upper) { | |
| 15400 | + { // Unsafe block | |
| 15401 | + b[i] = upper_c; | |
| 15402 | + } | |
| 15403 | + i++; | |
| 15404 | + need_upper = false; | |
| 15405 | + } else { | |
| 15406 | + { // Unsafe block | |
| 15407 | + b[i] = c; | |
| 15408 | + } | |
| 15409 | + i++; | |
| 15410 | + } | |
| 15411 | + } | |
| 15412 | + { // Unsafe block | |
| 15413 | + b[i] = 0; | |
| 15414 | + } | |
| 15415 | + return builtin__tos(b, i); | |
| 15416 | +} | |
| 15417 | +string builtin__string_wrap(string s, WrapConfig config) { | |
| 15418 | + if (config.width <= 0) { | |
| 15419 | + return _S(""); | |
| 15420 | + } | |
| 15421 | + Array_string words = builtin__string_fields(s); | |
| 15422 | + if (words.len == 0) { | |
| 15423 | + return _S(""); | |
| 15424 | + } | |
| 15425 | + strings__Builder sb = strings__new_builder(s.len); | |
| 15426 | + strings__Builder_write_string(&sb, (*(string*)builtin__array_get(words, 0))); | |
| 15427 | + int space_left = config.width - (*(string*)builtin__array_get(words, 0)).len; | |
| 15428 | + for (int i = 1; i < words.len; ++i) { | |
| 15429 | + string word = (*(string*)builtin__array_get(words, i)); | |
| 15430 | + if (word.len + 1 > space_left) { | |
| 15431 | + strings__Builder_write_string(&sb, config.end); | |
| 15432 | + strings__Builder_write_string(&sb, word); | |
| 15433 | + space_left = config.width - word.len; | |
| 15434 | + } else { | |
| 15435 | + strings__Builder_write_string(&sb, _S(" ")); | |
| 15436 | + strings__Builder_write_string(&sb, word); | |
| 15437 | + space_left -= 1 + word.len; | |
| 15438 | + } | |
| 15439 | + } | |
| 15440 | + return strings__Builder_str(&sb); | |
| 15441 | +} | |
| 15442 | +string builtin__string_hex(string s) { | |
| 15443 | + if ((s).len == 0) { | |
| 15444 | + return _S(""); | |
| 15445 | + } | |
| 15446 | + return builtin__data_to_hex_string(s.str, s.len); | |
| 15447 | +} | |
| 15448 | +VV_LOC string builtin__data_to_hex_string(u8* data, int len) { | |
| 15449 | + u8* hex = builtin__malloc_noscan(((u64)(len)) * 2 + 1); | |
| 15450 | + int dst = 0; | |
| 15451 | + for (int c = 0; c < len; ++c) { | |
| 15452 | + u8 b = data[c]; | |
| 15453 | + u8 n0 = v__rshift_u8(b, (u64)4); | |
| 15454 | + u8 n1 = (b & 0xF); | |
| 15455 | + hex[dst] = (n0 < 10 ? ((rune)(n0 + '0')) : ((rune)(n0 + 'W'))); | |
| 15456 | + hex[dst + 1] = (n1 < 10 ? ((rune)(n1 + '0')) : ((rune)(n1 + 'W'))); | |
| 15457 | + dst += 2; | |
| 15458 | + } | |
| 15459 | + hex[dst] = 0; | |
| 15460 | + return builtin__tos(hex, dst); | |
| 15461 | +} | |
| 15462 | +RunesIterator builtin__string_runes_iterator(string s) { | |
| 15463 | + return ((RunesIterator){.s = s,.i = 0,}); | |
| 15464 | +} | |
| 15465 | +_option_rune builtin__RunesIterator_next(RunesIterator* ri) { | |
| 15466 | + if (ri->i >= ri->s.len) { | |
| 15467 | + return (_option_rune){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | |
| 15468 | + } | |
| 15469 | + multi_return_rune_int mr_82852 = builtin__utf8_decode_rune(&ri->s.str[ri->i], ri->s.len - ri->i); | |
| 15470 | + rune r = mr_82852.arg0; | |
| 15471 | + int char_len = mr_82852.arg1; | |
| 15472 | + ri->i += (char_len > 0 ? (char_len) : (1)); | |
| 15473 | + _option_rune _t2; | |
| 15474 | + builtin___option_ok(&(rune[]) { r }, (_option*)(&_t2), sizeof(rune)); | |
| 15475 | + | |
| 15476 | + return _t2; | |
| 15477 | +} | |
| 15478 | +Array_u8 builtin__byteptr_vbytes(byteptr data, int len) { | |
| 15479 | + return builtin__voidptr_vbytes(((voidptr)(data)), len); | |
| 15480 | +} | |
| 15481 | +string builtin__byteptr_vstring(byteptr bp) { | |
| 15482 | + return ((string){.str = bp, .len = builtin__vstrlen(bp)}); | |
| 15483 | +} | |
| 15484 | +string builtin__byteptr_vstring_with_len(byteptr bp, int len) { | |
| 15485 | + return ((string){.str = bp, .len = len, .is_lit = 0}); | |
| 15486 | +} | |
| 15487 | +string builtin__charptr_vstring(charptr cp) { | |
| 15488 | + return ((string){.str = ((byteptr)(cp)), .len = builtin__vstrlen_char(cp), .is_lit = 0}); | |
| 15489 | +} | |
| 15490 | +string builtin__charptr_vstring_with_len(charptr cp, int len) { | |
| 15491 | + return ((string){.str = ((byteptr)(cp)), .len = len, .is_lit = 0}); | |
| 15492 | +} | |
| 15493 | +string builtin__byteptr_vstring_literal(byteptr bp) { | |
| 15494 | + return ((string){.str = bp, .len = builtin__vstrlen(bp), .is_lit = 1}); | |
| 15495 | +} | |
| 15496 | +string builtin__byteptr_vstring_literal_with_len(byteptr bp, int len) { | |
| 15497 | + return ((string){.str = bp, .len = len, .is_lit = 1}); | |
| 15498 | +} | |
| 15499 | +string builtin__charptr_vstring_literal(charptr cp) { | |
| 15500 | + return ((string){.str = ((byteptr)(cp)), .len = builtin__vstrlen_char(cp), .is_lit = 1}); | |
| 15501 | +} | |
| 15502 | +string builtin__charptr_vstring_literal_with_len(charptr cp, int len) { | |
| 15503 | + return ((string){.str = ((byteptr)(cp)), .len = len, .is_lit = 1}); | |
| 15504 | +} | |
| 15505 | +string builtin__StrIntpType_str(StrIntpType x) { | |
| 15506 | + string _t2 = (string){.str=(byteptr)"", .is_lit=1}; | |
| 15507 | + switch (x) { | |
| 15508 | + case StrIntpType__si_no_str: { | |
| 15509 | + _t2 = _S("no_str"); | |
| 15510 | + break; | |
| 15511 | + } | |
| 15512 | + case StrIntpType__si_c: { | |
| 15513 | + _t2 = _S("c"); | |
| 15514 | + break; | |
| 15515 | + } | |
| 15516 | + case StrIntpType__si_u8: { | |
| 15517 | + _t2 = _S("u8"); | |
| 15518 | + break; | |
| 15519 | + } | |
| 15520 | + case StrIntpType__si_i8: { | |
| 15521 | + _t2 = _S("i8"); | |
| 15522 | + break; | |
| 15523 | + } | |
| 15524 | + case StrIntpType__si_u16: { | |
| 15525 | + _t2 = _S("u16"); | |
| 15526 | + break; | |
| 15527 | + } | |
| 15528 | + case StrIntpType__si_i16: { | |
| 15529 | + _t2 = _S("i16"); | |
| 15530 | + break; | |
| 15531 | + } | |
| 15532 | + case StrIntpType__si_u32: { | |
| 15533 | + _t2 = _S("u32"); | |
| 15534 | + break; | |
| 15535 | + } | |
| 15536 | + case StrIntpType__si_i32: { | |
| 15537 | + _t2 = _S("i32"); | |
| 15538 | + break; | |
| 15539 | + } | |
| 15540 | + case StrIntpType__si_u64: { | |
| 15541 | + _t2 = _S("u64"); | |
| 15542 | + break; | |
| 15543 | + } | |
| 15544 | + case StrIntpType__si_i64: { | |
| 15545 | + _t2 = _S("i64"); | |
| 15546 | + break; | |
| 15547 | + } | |
| 15548 | + case StrIntpType__si_f32: { | |
| 15549 | + _t2 = _S("f32"); | |
| 15550 | + break; | |
| 15551 | + } | |
| 15552 | + case StrIntpType__si_f64: { | |
| 15553 | + _t2 = _S("f64"); | |
| 15554 | + break; | |
| 15555 | + } | |
| 15556 | + case StrIntpType__si_g32: { | |
| 15557 | + _t2 = _S("f32"); | |
| 15558 | + break; | |
| 15559 | + } | |
| 15560 | + case StrIntpType__si_g64: { | |
| 15561 | + _t2 = _S("f64"); | |
| 15562 | + break; | |
| 15563 | + } | |
| 15564 | + case StrIntpType__si_e32: { | |
| 15565 | + _t2 = _S("f32"); | |
| 15566 | + break; | |
| 15567 | + } | |
| 15568 | + case StrIntpType__si_e64: { | |
| 15569 | + _t2 = _S("f64"); | |
| 15570 | + break; | |
| 15571 | + } | |
| 15572 | + case StrIntpType__si_s: { | |
| 15573 | + _t2 = _S("s"); | |
| 15574 | + break; | |
| 15575 | + } | |
| 15576 | + case StrIntpType__si_p: { | |
| 15577 | + _t2 = _S("p"); | |
| 15578 | + break; | |
| 15579 | + } | |
| 15580 | + case StrIntpType__si_r: { | |
| 15581 | + _t2 = _S("r"); | |
| 15582 | + break; | |
| 15583 | + } | |
| 15584 | + case StrIntpType__si_vp: { | |
| 15585 | + _t2 = _S("vp"); | |
| 15586 | + break; | |
| 15587 | + } | |
| 15588 | + } | |
| 15589 | + return _t2; | |
| 15590 | +} | |
| 15591 | +inline VV_LOC f32 builtin__fabs32(f32 x) { | |
| 15592 | + return (x < 0 ? (-x) : (x)); | |
| 15593 | +} | |
| 15594 | +inline VV_LOC f64 builtin__fabs64(f64 x) { | |
| 15595 | + return (x < 0 ? (-x) : (x)); | |
| 15596 | +} | |
| 15597 | +inline VV_LOC u64 builtin__abs64(i64 x) { | |
| 15598 | + return (x < 0 ? (((u64)(-x))) : (((u64)(x)))); | |
| 15599 | +} | |
| 15600 | +u64 builtin__get_str_intp_u64_format(StrIntpType fmt_type, int in_width, int in_precision, bool in_tail_zeros, bool in_sign, u8 in_pad_ch, int in_base, bool in_upper_case) { | |
| 15601 | + u64 width = (in_width != 0 ? (builtin__abs64(in_width)) : (((u64)(0)))); | |
| 15602 | + u64 align = (in_width > 0 ? (((u64)(32))) : (((u64)(0)))); | |
| 15603 | + u64 upper_case = (in_upper_case ? (((u64)(128))) : (((u64)(0)))); | |
| 15604 | + u64 sign = (in_sign ? (((u64)(256))) : (((u64)(0)))); | |
| 15605 | + u64 precision = (in_precision != 987698 ? ((v__lshift_u64(((u64)((in_precision & 0x7F))), (u64)9))) : (v__lshift_u64(((u64)(0x7F)), (u64)9))); | |
| 15606 | + u32 tail_zeros = (in_tail_zeros ? (v__lshift_u32(((u32)(1)), (u64)16)) : (((u32)(0)))); | |
| 15607 | + u64 base = ((u64)(v__lshift_u32(((u32)((in_base & 0xf))), (u64)27))); | |
| 15608 | + u64 res = ((u64)(((((((((((((u64)(fmt_type)) & 0x1F)) | align) | upper_case) | sign) | precision) | tail_zeros) | (v__lshift_u64(((u64)((width & 0x3FF))), (u64)17))) | base) | (v__lshift_u64(((u64)(in_pad_ch)), (u64)31))))); | |
| 15609 | + return res; | |
| 15610 | +} | |
| 15611 | +u32 builtin__get_str_intp_u32_format(StrIntpType fmt_type, int in_width, int in_precision, bool in_tail_zeros, bool in_sign, u8 in_pad_ch, int in_base, bool in_upper_case) { | |
| 15612 | + u64 width = (in_width != 0 ? (builtin__abs64(in_width)) : (((u32)(0)))); | |
| 15613 | + u32 align = (in_width > 0 ? (((u32)(32))) : (((u32)(0)))); | |
| 15614 | + u32 upper_case = (in_upper_case ? (((u32)(128))) : (((u32)(0)))); | |
| 15615 | + u32 sign = (in_sign ? (((u32)(256))) : (((u32)(0)))); | |
| 15616 | + u32 precision = (in_precision != 987698 ? ((v__lshift_u32(((u32)((in_precision & 0x7F))), (u64)9))) : (v__lshift_u32(((u32)(0x7F)), (u64)9))); | |
| 15617 | + u32 tail_zeros = (in_tail_zeros ? (v__lshift_u32(((u32)(1)), (u64)16)) : (((u32)(0)))); | |
| 15618 | + u32 base = ((u32)(v__lshift_u32(((u32)((in_base & 0xf))), (u64)27))); | |
| 15619 | + u32 res = ((u32)(((((((((((((u32)(fmt_type)) & 0x1F)) | align) | upper_case) | sign) | precision) | tail_zeros) | (v__lshift_u32(((u32)((width & 0x3FF))), (u64)17))) | base) | (v__lshift_u32(((u32)((in_pad_ch & 1))), (u64)31))))); | |
| 15620 | + return res; | |
| 15621 | +} | |
| 15622 | +VV_LOC void builtin__StrIntpData_process_str_intp_data(StrIntpData* data, strings__Builder* sb) { | |
| 15623 | + u32 x = data->fmt; | |
| 15624 | + StrIntpType typ = ((StrIntpType)((x & 0x1F))); | |
| 15625 | + int align = ((int)(((v__rshift_u32(x, (u64)5)) & 0x01))); | |
| 15626 | + bool upper_case = (((v__rshift_u32(x, (u64)7)) & 0x01)) > 0; | |
| 15627 | + int sign = ((int)(((v__rshift_u32(x, (u64)8)) & 0x01))); | |
| 15628 | + int precision = ((int)(((v__rshift_u32(x, (u64)9)) & 0x7F))); | |
| 15629 | + bool tail_zeros = (((v__rshift_u32(x, (u64)16)) & 0x01)) > 0; | |
| 15630 | + int width = ((int)(((i16)(((v__rshift_u32(x, (u64)17)) & 0x3FF))))); | |
| 15631 | + int base = (((int)(v__rshift_u32(x, (u64)27))) & 0xF); | |
| 15632 | + u8 fmt_pad_ch = ((u8)(((v__rshift_u32(x, (u64)31)) & 0xFF))); | |
| 15633 | + bool has_dynamic_width = ((data->dyn_flags & _const_str_intp_has_dynamic_width)) != 0; | |
| 15634 | + bool has_dynamic_precision = ((data->dyn_flags & _const_str_intp_has_dynamic_precision)) != 0; | |
| 15635 | + if (typ == StrIntpType__si_no_str) { | |
| 15636 | + return; | |
| 15637 | + } | |
| 15638 | + if (base > 0) { | |
| 15639 | + base += 2; | |
| 15640 | + } | |
| 15641 | + if (has_dynamic_width) { | |
| 15642 | + width = data->dyn_width; | |
| 15643 | + if (width < 0) { | |
| 15644 | + width = -width; | |
| 15645 | + align = 0; | |
| 15646 | + } else if (width > 0) { | |
| 15647 | + align = 1; | |
| 15648 | + } | |
| 15649 | + } | |
| 15650 | + if (has_dynamic_precision) { | |
| 15651 | + precision = data->dyn_precision; | |
| 15652 | + } | |
| 15653 | + u8 pad_ch = ((u8)(' ')); | |
| 15654 | + if (fmt_pad_ch > 0) { | |
| 15655 | + pad_ch = '0'; | |
| 15656 | + } | |
| 15657 | + int len0_set = (width > 0 ? (width) : (-1)); | |
| 15658 | + int len1_set = (has_dynamic_precision ? ((precision >= 0 ? (precision) : (-1))) : precision == 0x7F ? (-1) : (precision)); | |
| 15659 | + bool sign_set = sign == 1; | |
| 15660 | + strconv__BF_param bf = ((strconv__BF_param){ | |
| 15661 | + .pad_ch = pad_ch, | |
| 15662 | + .len0 = len0_set, | |
| 15663 | + .len1 = len1_set, | |
| 15664 | + .positive = true, | |
| 15665 | + .sign_flag = sign_set, | |
| 15666 | + .align = strconv__Align_text__left, | |
| 15667 | + .rm_tail_zero = tail_zeros, | |
| 15668 | + }); | |
| 15669 | + if (fmt_pad_ch == 0 || pad_ch == '0') { | |
| 15670 | + switch (align) { | |
| 15671 | + case 0: { | |
| 15672 | + bf.align = strconv__Align_text__left; | |
| 15673 | + break; | |
| 15674 | + } | |
| 15675 | + case 1: { | |
| 15676 | + bf.align = strconv__Align_text__right; | |
| 15677 | + break; | |
| 15678 | + } | |
| 15679 | + default: { | |
| 15680 | + { | |
| 15681 | + bf.align = strconv__Align_text__left; | |
| 15682 | + break; | |
| 15683 | + } | |
| 15684 | + } | |
| 15685 | + } | |
| 15686 | + | |
| 15687 | + } else { | |
| 15688 | + bf.align = strconv__Align_text__right; | |
| 15689 | + } | |
| 15690 | + { // Unsafe block | |
| 15691 | + if (typ == StrIntpType__si_s) { | |
| 15692 | + if (upper_case) { | |
| 15693 | + string s = builtin__string_to_upper(data->d.d_s); | |
| 15694 | + if (width == 0) { | |
| 15695 | + strings__Builder_write_string(sb, s); | |
| 15696 | + } else { | |
| 15697 | + strconv__format_str_sb(s, bf, sb); | |
| 15698 | + } | |
| 15699 | + builtin__string_free(&s); | |
| 15700 | + } else { | |
| 15701 | + if (width == 0) { | |
| 15702 | + strings__Builder_write_string(sb, data->d.d_s); | |
| 15703 | + } else { | |
| 15704 | + strconv__format_str_sb(data->d.d_s, bf, sb); | |
| 15705 | + } | |
| 15706 | + } | |
| 15707 | + return; | |
| 15708 | + } | |
| 15709 | + if (typ == StrIntpType__si_r) { | |
| 15710 | + if (width > 0) { | |
| 15711 | + if (upper_case) { | |
| 15712 | + string s = builtin__string_to_upper(data->d.d_s); | |
| 15713 | + for (int _t1 = 1; _t1 < (1 + ((width > 0 ? (width) : (0)))); ++_t1) { | |
| 15714 | + strings__Builder_write_string(sb, s); | |
| 15715 | + } | |
| 15716 | + builtin__string_free(&s); | |
| 15717 | + } else { | |
| 15718 | + for (int _t2 = 1; _t2 < (1 + ((width > 0 ? (width) : (0)))); ++_t2) { | |
| 15719 | + strings__Builder_write_string(sb, data->d.d_s); | |
| 15720 | + } | |
| 15721 | + } | |
| 15722 | + } | |
| 15723 | + return; | |
| 15724 | + } | |
| 15725 | + if (typ == StrIntpType__si_i8 || typ == StrIntpType__si_i16 || typ == StrIntpType__si_i32 || typ == StrIntpType__si_i64) { | |
| 15726 | + i64 d = data->d.d_i64; | |
| 15727 | + if (typ == StrIntpType__si_i8) { | |
| 15728 | + d = ((i64)(data->d.d_i8)); | |
| 15729 | + } else if (typ == StrIntpType__si_i16) { | |
| 15730 | + d = ((i64)(data->d.d_i16)); | |
| 15731 | + } else if (typ == StrIntpType__si_i32) { | |
| 15732 | + d = ((i64)(data->d.d_i32)); | |
| 15733 | + } | |
| 15734 | + if (base == 0) { | |
| 15735 | + if (d < 0) { | |
| 15736 | + bf.positive = false; | |
| 15737 | + } | |
| 15738 | + strconv__format_dec_sb(builtin__abs64(d), bf, sb); | |
| 15739 | + } else { | |
| 15740 | + if (base == 3) { | |
| 15741 | + base = 2; | |
| 15742 | + } | |
| 15743 | + i64 absd = d; | |
| 15744 | + bool write_minus = false; | |
| 15745 | + if (d < 0 && pad_ch != ' ') { | |
| 15746 | + absd = -d; | |
| 15747 | + write_minus = true; | |
| 15748 | + } | |
| 15749 | + string hx = strconv__format_int(absd, base); | |
| 15750 | + if (upper_case) { | |
| 15751 | + string tmp = hx; | |
| 15752 | + hx = builtin__string_to_upper(hx); | |
| 15753 | + builtin__string_free(&tmp); | |
| 15754 | + } | |
| 15755 | + if (write_minus) { | |
| 15756 | + strings__Builder_write_u8(sb, '-'); | |
| 15757 | + bf.len0--; | |
| 15758 | + } | |
| 15759 | + if (width == 0) { | |
| 15760 | + strings__Builder_write_string(sb, hx); | |
| 15761 | + } else { | |
| 15762 | + strconv__format_str_sb(hx, bf, sb); | |
| 15763 | + } | |
| 15764 | + builtin__string_free(&hx); | |
| 15765 | + } | |
| 15766 | + return; | |
| 15767 | + } | |
| 15768 | + if (typ == StrIntpType__si_u8 || typ == StrIntpType__si_u16 || typ == StrIntpType__si_u32 || typ == StrIntpType__si_u64) { | |
| 15769 | + u64 d = data->d.d_u64; | |
| 15770 | + if (typ == StrIntpType__si_u8) { | |
| 15771 | + d = ((u64)(data->d.d_u8)); | |
| 15772 | + } else if (typ == StrIntpType__si_u16) { | |
| 15773 | + d = ((u64)(data->d.d_u16)); | |
| 15774 | + } else if (typ == StrIntpType__si_u32) { | |
| 15775 | + d = ((u64)(data->d.d_u32)); | |
| 15776 | + } | |
| 15777 | + if (base == 0) { | |
| 15778 | + strconv__format_dec_sb(d, bf, sb); | |
| 15779 | + } else { | |
| 15780 | + if (base == 3) { | |
| 15781 | + base = 2; | |
| 15782 | + } | |
| 15783 | + string hx = strconv__format_uint(d, base); | |
| 15784 | + if (upper_case) { | |
| 15785 | + string tmp = hx; | |
| 15786 | + hx = builtin__string_to_upper(hx); | |
| 15787 | + builtin__string_free(&tmp); | |
| 15788 | + } | |
| 15789 | + if (width == 0) { | |
| 15790 | + strings__Builder_write_string(sb, hx); | |
| 15791 | + } else { | |
| 15792 | + strconv__format_str_sb(hx, bf, sb); | |
| 15793 | + } | |
| 15794 | + builtin__string_free(&hx); | |
| 15795 | + } | |
| 15796 | + return; | |
| 15797 | + } | |
| 15798 | + if (typ == StrIntpType__si_p) { | |
| 15799 | + u64 d = ((u64)(data->d.d_p)); | |
| 15800 | + base = 16; | |
| 15801 | + if (base == 0) { | |
| 15802 | + if (width == 0) { | |
| 15803 | + string d_str = builtin__u64_str(d); | |
| 15804 | + strings__Builder_write_string(sb, d_str); | |
| 15805 | + builtin__string_free(&d_str); | |
| 15806 | + return; | |
| 15807 | + } | |
| 15808 | + strconv__format_dec_sb(d, bf, sb); | |
| 15809 | + } else { | |
| 15810 | + string hx = strconv__format_uint(d, base); | |
| 15811 | + if (upper_case) { | |
| 15812 | + string tmp = hx; | |
| 15813 | + hx = builtin__string_to_upper(hx); | |
| 15814 | + builtin__string_free(&tmp); | |
| 15815 | + } | |
| 15816 | + if (width == 0) { | |
| 15817 | + strings__Builder_write_string(sb, hx); | |
| 15818 | + } else { | |
| 15819 | + strconv__format_str_sb(hx, bf, sb); | |
| 15820 | + } | |
| 15821 | + builtin__string_free(&hx); | |
| 15822 | + } | |
| 15823 | + return; | |
| 15824 | + } | |
| 15825 | + bool use_default_str = false; | |
| 15826 | + if (width == 0 && precision == 0x7F) { | |
| 15827 | + bf.len1 = 3; | |
| 15828 | + use_default_str = true; | |
| 15829 | + } | |
| 15830 | + if (bf.len1 < 0) { | |
| 15831 | + bf.len1 = 3; | |
| 15832 | + } | |
| 15833 | + switch (typ) { | |
| 15834 | + case StrIntpType__si_f32: { | |
| 15835 | + #if !defined(CUSTOM_DEFINE_nofloat) | |
| 15836 | + { | |
| 15837 | + if (use_default_str) { | |
| 15838 | + string f = builtin__f32_str(data->d.d_f32); | |
| 15839 | + if (upper_case) { | |
| 15840 | + string tmp = f; | |
| 15841 | + f = builtin__string_to_upper(f); | |
| 15842 | + builtin__string_free(&tmp); | |
| 15843 | + } | |
| 15844 | + strings__Builder_write_string(sb, f); | |
| 15845 | + builtin__string_free(&f); | |
| 15846 | + } else { | |
| 15847 | + if (data->d.d_f32 < 0) { | |
| 15848 | + bf.positive = false; | |
| 15849 | + } | |
| 15850 | + string f = strconv__format_fl(data->d.d_f32, bf); | |
| 15851 | + if (upper_case) { | |
| 15852 | + string tmp = f; | |
| 15853 | + f = builtin__string_to_upper(f); | |
| 15854 | + builtin__string_free(&tmp); | |
| 15855 | + } | |
| 15856 | + strings__Builder_write_string(sb, f); | |
| 15857 | + builtin__string_free(&f); | |
| 15858 | + } | |
| 15859 | + } | |
| 15860 | + #endif | |
| 15861 | + break; | |
| 15862 | + } | |
| 15863 | + case StrIntpType__si_f64: { | |
| 15864 | + #if !defined(CUSTOM_DEFINE_nofloat) | |
| 15865 | + { | |
| 15866 | + if (use_default_str) { | |
| 15867 | + string f = builtin__f64_str(data->d.d_f64); | |
| 15868 | + if (upper_case) { | |
| 15869 | + string tmp = f; | |
| 15870 | + f = builtin__string_to_upper(f); | |
| 15871 | + builtin__string_free(&tmp); | |
| 15872 | + } | |
| 15873 | + strings__Builder_write_string(sb, f); | |
| 15874 | + builtin__string_free(&f); | |
| 15875 | + } else { | |
| 15876 | + if (data->d.d_f64 < 0) { | |
| 15877 | + bf.positive = false; | |
| 15878 | + } | |
| 15879 | + strconv__Float64u _t5 = ((strconv__Float64u){.f = data->d.d_f64,}); | |
| 15880 | + strconv__Float64u f_union = _t5; | |
| 15881 | + if (f_union.u == _const_strconv__double_minus_zero) { | |
| 15882 | + bf.positive = false; | |
| 15883 | + } | |
| 15884 | + string f = strconv__format_fl(data->d.d_f64, bf); | |
| 15885 | + if (upper_case) { | |
| 15886 | + string tmp = f; | |
| 15887 | + f = builtin__string_to_upper(f); | |
| 15888 | + builtin__string_free(&tmp); | |
| 15889 | + } | |
| 15890 | + strings__Builder_write_string(sb, f); | |
| 15891 | + builtin__string_free(&f); | |
| 15892 | + } | |
| 15893 | + } | |
| 15894 | + #endif | |
| 15895 | + break; | |
| 15896 | + } | |
| 15897 | + case StrIntpType__si_g32: { | |
| 15898 | + if (use_default_str) { | |
| 15899 | + #if !defined(CUSTOM_DEFINE_nofloat) | |
| 15900 | + { | |
| 15901 | + string f = builtin__f32_strg(data->d.d_f32); | |
| 15902 | + if (upper_case) { | |
| 15903 | + string tmp = f; | |
| 15904 | + f = builtin__string_to_upper(f); | |
| 15905 | + builtin__string_free(&tmp); | |
| 15906 | + } | |
| 15907 | + strings__Builder_write_string(sb, f); | |
| 15908 | + builtin__string_free(&f); | |
| 15909 | + } | |
| 15910 | + #endif | |
| 15911 | + } else { | |
| 15912 | + if (data->d.d_f32 == _const_strconv__single_plus_zero) { | |
| 15913 | + string tmp_str = _S("0"); | |
| 15914 | + strconv__format_str_sb(tmp_str, bf, sb); | |
| 15915 | + builtin__string_free(&tmp_str); | |
| 15916 | + return; | |
| 15917 | + } | |
| 15918 | + if (data->d.d_f32 == _const_strconv__single_minus_zero) { | |
| 15919 | + string tmp_str = _S("-0"); | |
| 15920 | + strconv__format_str_sb(tmp_str, bf, sb); | |
| 15921 | + builtin__string_free(&tmp_str); | |
| 15922 | + return; | |
| 15923 | + } | |
| 15924 | + if (data->d.d_f32 == _const_strconv__single_plus_infinity) { | |
| 15925 | + string tmp_str = _S("+inf"); | |
| 15926 | + if (upper_case) { | |
| 15927 | + tmp_str = _S("+INF"); | |
| 15928 | + } | |
| 15929 | + strconv__format_str_sb(tmp_str, bf, sb); | |
| 15930 | + builtin__string_free(&tmp_str); | |
| 15931 | + } | |
| 15932 | + if (data->d.d_f32 == _const_strconv__single_minus_infinity) { | |
| 15933 | + string tmp_str = _S("-inf"); | |
| 15934 | + if (upper_case) { | |
| 15935 | + tmp_str = _S("-INF"); | |
| 15936 | + } | |
| 15937 | + strconv__format_str_sb(tmp_str, bf, sb); | |
| 15938 | + builtin__string_free(&tmp_str); | |
| 15939 | + } | |
| 15940 | + if (data->d.d_f32 < 0) { | |
| 15941 | + bf.positive = false; | |
| 15942 | + } | |
| 15943 | + f32 d = builtin__fabs32(data->d.d_f32); | |
| 15944 | + if (d < ((f32)(999999.0)) && d >= ((f32)(0.00001))) { | |
| 15945 | + string f = strconv__format_fl(data->d.d_f32, bf); | |
| 15946 | + if (upper_case) { | |
| 15947 | + string tmp = f; | |
| 15948 | + f = builtin__string_to_upper(f); | |
| 15949 | + builtin__string_free(&tmp); | |
| 15950 | + } | |
| 15951 | + strings__Builder_write_string(sb, f); | |
| 15952 | + builtin__string_free(&f); | |
| 15953 | + return; | |
| 15954 | + } | |
| 15955 | + bf.len1--; | |
| 15956 | + string f = strconv__format_es(data->d.d_f32, bf); | |
| 15957 | + if (upper_case) { | |
| 15958 | + string tmp = f; | |
| 15959 | + f = builtin__string_to_upper(f); | |
| 15960 | + builtin__string_free(&tmp); | |
| 15961 | + } | |
| 15962 | + strings__Builder_write_string(sb, f); | |
| 15963 | + builtin__string_free(&f); | |
| 15964 | + } | |
| 15965 | + break; | |
| 15966 | + } | |
| 15967 | + case StrIntpType__si_g64: { | |
| 15968 | + if (use_default_str) { | |
| 15969 | + #if !defined(CUSTOM_DEFINE_nofloat) | |
| 15970 | + { | |
| 15971 | + string f = builtin__f64_strg(data->d.d_f64); | |
| 15972 | + if (upper_case) { | |
| 15973 | + string tmp = f; | |
| 15974 | + f = builtin__string_to_upper(f); | |
| 15975 | + builtin__string_free(&tmp); | |
| 15976 | + } | |
| 15977 | + strings__Builder_write_string(sb, f); | |
| 15978 | + builtin__string_free(&f); | |
| 15979 | + } | |
| 15980 | + #endif | |
| 15981 | + } else { | |
| 15982 | + if (data->d.d_f64 == _const_strconv__double_plus_zero) { | |
| 15983 | + string tmp_str = _S("0"); | |
| 15984 | + strconv__format_str_sb(tmp_str, bf, sb); | |
| 15985 | + builtin__string_free(&tmp_str); | |
| 15986 | + return; | |
| 15987 | + } | |
| 15988 | + if (data->d.d_f64 == _const_strconv__double_minus_zero) { | |
| 15989 | + string tmp_str = _S("-0"); | |
| 15990 | + strconv__format_str_sb(tmp_str, bf, sb); | |
| 15991 | + builtin__string_free(&tmp_str); | |
| 15992 | + return; | |
| 15993 | + } | |
| 15994 | + if (data->d.d_f64 == _const_strconv__double_plus_infinity) { | |
| 15995 | + string tmp_str = _S("+inf"); | |
| 15996 | + if (upper_case) { | |
| 15997 | + tmp_str = _S("+INF"); | |
| 15998 | + } | |
| 15999 | + strconv__format_str_sb(tmp_str, bf, sb); | |
| 16000 | + builtin__string_free(&tmp_str); | |
| 16001 | + } | |
| 16002 | + if (data->d.d_f64 == _const_strconv__double_minus_infinity) { | |
| 16003 | + string tmp_str = _S("-inf"); | |
| 16004 | + if (upper_case) { | |
| 16005 | + tmp_str = _S("-INF"); | |
| 16006 | + } | |
| 16007 | + strconv__format_str_sb(tmp_str, bf, sb); | |
| 16008 | + builtin__string_free(&tmp_str); | |
| 16009 | + } | |
| 16010 | + if (data->d.d_f64 < 0) { | |
| 16011 | + bf.positive = false; | |
| 16012 | + } | |
| 16013 | + f64 d = builtin__fabs64(data->d.d_f64); | |
| 16014 | + if (d < ((f64)(999999.0)) && d >= ((f64)(0.00001))) { | |
| 16015 | + string f = strconv__format_fl(data->d.d_f64, bf); | |
| 16016 | + if (upper_case) { | |
| 16017 | + string tmp = f; | |
| 16018 | + f = builtin__string_to_upper(f); | |
| 16019 | + builtin__string_free(&tmp); | |
| 16020 | + } | |
| 16021 | + strings__Builder_write_string(sb, f); | |
| 16022 | + builtin__string_free(&f); | |
| 16023 | + return; | |
| 16024 | + } | |
| 16025 | + bf.len1--; | |
| 16026 | + string f = strconv__format_es(data->d.d_f64, bf); | |
| 16027 | + if (upper_case) { | |
| 16028 | + string tmp = f; | |
| 16029 | + f = builtin__string_to_upper(f); | |
| 16030 | + builtin__string_free(&tmp); | |
| 16031 | + } | |
| 16032 | + strings__Builder_write_string(sb, f); | |
| 16033 | + builtin__string_free(&f); | |
| 16034 | + } | |
| 16035 | + break; | |
| 16036 | + } | |
| 16037 | + case StrIntpType__si_e32: { | |
| 16038 | + #if !defined(CUSTOM_DEFINE_nofloat) | |
| 16039 | + { | |
| 16040 | + if (use_default_str) { | |
| 16041 | + string f = builtin__f32_str(data->d.d_f32); | |
| 16042 | + if (upper_case) { | |
| 16043 | + string tmp = f; | |
| 16044 | + f = builtin__string_to_upper(f); | |
| 16045 | + builtin__string_free(&tmp); | |
| 16046 | + } | |
| 16047 | + strings__Builder_write_string(sb, f); | |
| 16048 | + builtin__string_free(&f); | |
| 16049 | + } else { | |
| 16050 | + if (data->d.d_f32 < 0) { | |
| 16051 | + bf.positive = false; | |
| 16052 | + } | |
| 16053 | + string f = strconv__format_es(data->d.d_f32, bf); | |
| 16054 | + if (upper_case) { | |
| 16055 | + string tmp = f; | |
| 16056 | + f = builtin__string_to_upper(f); | |
| 16057 | + builtin__string_free(&tmp); | |
| 16058 | + } | |
| 16059 | + strings__Builder_write_string(sb, f); | |
| 16060 | + builtin__string_free(&f); | |
| 16061 | + } | |
| 16062 | + } | |
| 16063 | + #endif | |
| 16064 | + break; | |
| 16065 | + } | |
| 16066 | + case StrIntpType__si_e64: { | |
| 16067 | + #if !defined(CUSTOM_DEFINE_nofloat) | |
| 16068 | + { | |
| 16069 | + if (use_default_str) { | |
| 16070 | + string f = builtin__f64_str(data->d.d_f64); | |
| 16071 | + if (upper_case) { | |
| 16072 | + string tmp = f; | |
| 16073 | + f = builtin__string_to_upper(f); | |
| 16074 | + builtin__string_free(&tmp); | |
| 16075 | + } | |
| 16076 | + strings__Builder_write_string(sb, f); | |
| 16077 | + builtin__string_free(&f); | |
| 16078 | + } else { | |
| 16079 | + if (data->d.d_f64 < 0) { | |
| 16080 | + bf.positive = false; | |
| 16081 | + } | |
| 16082 | + string f = strconv__format_es(data->d.d_f64, bf); | |
| 16083 | + if (upper_case) { | |
| 16084 | + string tmp = f; | |
| 16085 | + f = builtin__string_to_upper(f); | |
| 16086 | + builtin__string_free(&tmp); | |
| 16087 | + } | |
| 16088 | + strings__Builder_write_string(sb, f); | |
| 16089 | + builtin__string_free(&f); | |
| 16090 | + } | |
| 16091 | + } | |
| 16092 | + #endif | |
| 16093 | + break; | |
| 16094 | + } | |
| 16095 | + case StrIntpType__si_c: { | |
| 16096 | + string ss = builtin__utf32_to_str(data->d.d_c); | |
| 16097 | + strings__Builder_write_string(sb, ss); | |
| 16098 | + builtin__string_free(&ss); | |
| 16099 | + break; | |
| 16100 | + } | |
| 16101 | + case StrIntpType__si_vp: { | |
| 16102 | + string ss = builtin__u64_hex(((u64)(data->d.d_vp))); | |
| 16103 | + strings__Builder_write_string(sb, ss); | |
| 16104 | + builtin__string_free(&ss); | |
| 16105 | + break; | |
| 16106 | + } | |
| 16107 | + case StrIntpType__si_no_str: | |
| 16108 | + case StrIntpType__si_u8: | |
| 16109 | + case StrIntpType__si_i8: | |
| 16110 | + case StrIntpType__si_u16: | |
| 16111 | + case StrIntpType__si_i16: | |
| 16112 | + case StrIntpType__si_u32: | |
| 16113 | + case StrIntpType__si_i32: | |
| 16114 | + case StrIntpType__si_u64: | |
| 16115 | + case StrIntpType__si_i64: | |
| 16116 | + case StrIntpType__si_s: | |
| 16117 | + case StrIntpType__si_p: | |
| 16118 | + case StrIntpType__si_r: | |
| 16119 | + default: { | |
| 16120 | + { | |
| 16121 | + strings__Builder_write_string(sb, _S("***ERROR!***")); | |
| 16122 | + break; | |
| 16123 | + } | |
| 16124 | + } | |
| 16125 | + } | |
| 16126 | + | |
| 16127 | + } | |
| 16128 | +} | |
| 16129 | +string builtin__str_intp(int data_len, StrIntpData* input_base) { | |
| 16130 | + strings__Builder res = strings__new_builder(64); | |
| 16131 | + for (int i = 0; i < data_len; i++) { | |
| 16132 | + StrIntpData* data = &input_base[i]; | |
| 16133 | + if (data->str.len != 0) { | |
| 16134 | + strings__Builder_write_string(&res, data->str); | |
| 16135 | + } | |
| 16136 | + if (data->fmt != 0) { | |
| 16137 | + builtin__StrIntpData_process_str_intp_data(data, (voidptr)&res); | |
| 16138 | + } | |
| 16139 | + } | |
| 16140 | + string ret = strings__Builder_str(&res); | |
| 16141 | + strings__Builder_free(&res); | |
| 16142 | + return ret; | |
| 16143 | +} | |
| 16144 | +inline string builtin__str_intp_sq(string in_str) { | |
| 16145 | + return builtin__string_plus_many(5, _MOV((string[5]){_S("builtin__str_intp(2, _MOV((StrIntpData[]){{_S(\"\'\"), "), _const_si_s_code, _S(", {.d_s = "), in_str, _S("}, 0, 0, 0},{_S(\"\'\"), 0, {0}, 0, 0, 0}}))")})); | |
| 16146 | +} | |
| 16147 | +inline string builtin__str_intp_rune(string in_str) { | |
| 16148 | + return builtin__string_plus_many(5, _MOV((string[5]){_S("builtin__str_intp(2, _MOV((StrIntpData[]){{_S(\"`\"), "), _const_si_s_code, _S(", {.d_s = "), in_str, _S("}, 0, 0, 0},{_S(\"`\"), 0, {0}, 0, 0, 0}}))")})); | |
| 16149 | +} | |
| 16150 | +inline string builtin__str_intp_g32(string in_str) { | |
| 16151 | + return builtin__string_plus_many(5, _MOV((string[5]){_S("builtin__str_intp(1, _MOV((StrIntpData[]){{_SLIT0, "), _const_si_g32_code, _S(", {.d_f32 = "), in_str, _S(" }, 0, 0, 0}}))")})); | |
| 16152 | +} | |
| 16153 | +inline string builtin__str_intp_g64(string in_str) { | |
| 16154 | + return builtin__string_plus_many(5, _MOV((string[5]){_S("builtin__str_intp(1, _MOV((StrIntpData[]){{_SLIT0, "), _const_si_g64_code, _S(", {.d_f64 = "), in_str, _S(" }, 0, 0, 0}}))")})); | |
| 16155 | +} | |
| 16156 | +string builtin__str_intp_sub(string base_str, string in_str) { | |
| 16157 | + _option_int _t1 = builtin__string_index(base_str, _S("%%")); | |
| 16158 | + if (_t1.state != 0) { | |
| 16159 | + builtin__eprintln(_S("No string interpolation %% parameters")); | |
| 16160 | + builtin___v_exit(1); | |
| 16161 | + VUNREACHABLE(); | |
| 16162 | + ; | |
| 16163 | + } | |
| 16164 | + | |
| 16165 | + int index = (*(int*)_t1.data); | |
| 16166 | + { // Unsafe block | |
| 16167 | + string st_str = builtin__string_substr(base_str, 0, index); | |
| 16168 | + if (index + 2 < base_str.len) { | |
| 16169 | + string en_str = builtin__string_substr(base_str, index + 2, 2147483647); | |
| 16170 | + string res_str = builtin__string_plus_many(9, _MOV((string[9]){_S("builtin__str_intp(2, _MOV((StrIntpData[]){{_S(\""), st_str, _S("\"), "), _const_si_s_code, _S(", {.d_s = "), in_str, _S(" }, 0, 0, 0},{_S(\""), en_str, _S("\"), 0, {0}, 0, 0, 0}}))")})); | |
| 16171 | + builtin__string_free(&st_str); | |
| 16172 | + builtin__string_free(&en_str); | |
| 16173 | + return res_str; | |
| 16174 | + } | |
| 16175 | + string res2_str = builtin__string_plus_many(7, _MOV((string[7]){_S("builtin__str_intp(1, _MOV((StrIntpData[]){{_S(\""), st_str, _S("\"), "), _const_si_s_code, _S(", {.d_s = "), in_str, _S(" }, 0, 0, 0}}))")})); | |
| 16176 | + builtin__string_free(&st_str); | |
| 16177 | + return res2_str; | |
| 16178 | + } | |
| 16179 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 16180 | +} | |
| 16181 | +u16* builtin__string_to_wide(string _str, ToWideConfig param) { | |
| 16182 | + #if 0 | |
| 16183 | + { | |
| 16184 | + } | |
| 16185 | + #else | |
| 16186 | + { | |
| 16187 | + Array_rune srunes = builtin__string_runes(_str); | |
| 16188 | + { // Unsafe block | |
| 16189 | + u16* result = ((u16*)(builtin__vcalloc_noscan((srunes.len + 1) * 2))); | |
| 16190 | + for (int i = 0; i < srunes.len; ++i) { | |
| 16191 | + rune r = ((rune*)srunes.data)[i]; | |
| 16192 | + result[i] = ((u16)(r)); | |
| 16193 | + } | |
| 16194 | + result[srunes.len] = 0; | |
| 16195 | + return result; | |
| 16196 | + } | |
| 16197 | + } | |
| 16198 | + #endif | |
| 16199 | + return 0; | |
| 16200 | +} | |
| 16201 | +string builtin__string_from_wide(u16* _wstr) { | |
| 16202 | + #if 0 | |
| 16203 | + { | |
| 16204 | + } | |
| 16205 | + #else | |
| 16206 | + { | |
| 16207 | + int i = 0; | |
| 16208 | + for (;;) { | |
| 16209 | + if (!(_wstr[i] != 0)) break; | |
| 16210 | + i++; | |
| 16211 | + } | |
| 16212 | + return builtin__string_from_wide2(_wstr, i); | |
| 16213 | + } | |
| 16214 | + #endif | |
| 16215 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 16216 | +} | |
| 16217 | +string builtin__string_from_wide2(u16* _wstr, int len) { | |
| 16218 | + #if 0 | |
| 16219 | + { | |
| 16220 | + } | |
| 16221 | + #else | |
| 16222 | + { | |
| 16223 | + strings__Builder sb = strings__new_builder(len); | |
| 16224 | + for (int i = 0; i < len; i++) { | |
| 16225 | + rune u = ((rune)(_wstr[i])); | |
| 16226 | + strings__Builder_write_rune(&sb, u); | |
| 16227 | + } | |
| 16228 | + string res = strings__Builder_str(&sb); | |
| 16229 | + strings__Builder_free(&sb); | |
| 16230 | + return res; | |
| 16231 | + } | |
| 16232 | + #endif | |
| 16233 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 16234 | +} | |
| 16235 | +Array_u8 builtin__wide_to_ansi(u16* _wstr) { | |
| 16236 | + #if 0 | |
| 16237 | + { | |
| 16238 | + } | |
| 16239 | + #else | |
| 16240 | + { | |
| 16241 | + string s = builtin__string_from_wide(_wstr); | |
| 16242 | + Array_u8 str_to = builtin____new_array_with_default(s.len + 1, 0, sizeof(u8), 0); | |
| 16243 | + builtin__vmemcpy(str_to.data, s.str, s.len); | |
| 16244 | + return str_to; | |
| 16245 | + } | |
| 16246 | + #endif | |
| 16247 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | |
| 16248 | +} | |
| 16249 | +int builtin__utf8_char_len(u8 b) { | |
| 16250 | + return ((int)((((v__rshift_u32(((u32)(0xe5000000U)), (u64)(((v__rshift_u8(b, (u64)3)) & 0x1e)))) & 3)) + 1)); | |
| 16251 | +} | |
| 16252 | +string builtin__utf32_to_str(u32 code) { | |
| 16253 | + { // Unsafe block | |
| 16254 | + u8* buffer = builtin__malloc_noscan(5); | |
| 16255 | + string res = builtin__utf32_to_str_no_malloc(code, buffer); | |
| 16256 | + if (res.len == 0) { | |
| 16257 | + builtin___v_free(buffer); | |
| 16258 | + } | |
| 16259 | + return res; | |
| 16260 | + } | |
| 16261 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 16262 | +} | |
| 16263 | +string builtin__utf32_to_str_no_malloc(u32 code, u8* buf) { | |
| 16264 | + { // Unsafe block | |
| 16265 | + int len = builtin__utf32_decode_to_buffer(code, buf); | |
| 16266 | + if (len == 0) { | |
| 16267 | + return _S(""); | |
| 16268 | + } | |
| 16269 | + buf[len] = 0; | |
| 16270 | + return builtin__tos(buf, len); | |
| 16271 | + } | |
| 16272 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 16273 | +} | |
| 16274 | +int builtin__utf32_decode_to_buffer(u32 code, u8* buf) { | |
| 16275 | + { // Unsafe block | |
| 16276 | + int icode = ((int)(code)); | |
| 16277 | + u8* buffer = ((u8*)(buf)); | |
| 16278 | + if (icode <= 127) { | |
| 16279 | + buffer[0] = ((u8)(icode)); | |
| 16280 | + return 1; | |
| 16281 | + } else if (icode <= 2047) { | |
| 16282 | + buffer[0] = (192 | ((u8)(v__rshift_int(icode, (u64)6)))); | |
| 16283 | + buffer[1] = (128 | ((u8)((icode & 63)))); | |
| 16284 | + return 2; | |
| 16285 | + } else if (icode <= 65535) { | |
| 16286 | + buffer[0] = (224 | ((u8)(v__rshift_int(icode, (u64)12)))); | |
| 16287 | + buffer[1] = (128 | ((((u8)(v__rshift_int(icode, (u64)6))) & 63))); | |
| 16288 | + buffer[2] = (128 | ((u8)((icode & 63)))); | |
| 16289 | + return 3; | |
| 16290 | + } else if (icode <= 1114111) { | |
| 16291 | + buffer[0] = (240 | ((u8)(v__rshift_int(icode, (u64)18)))); | |
| 16292 | + buffer[1] = (128 | ((((u8)(v__rshift_int(icode, (u64)12))) & 63))); | |
| 16293 | + buffer[2] = (128 | ((((u8)(v__rshift_int(icode, (u64)6))) & 63))); | |
| 16294 | + buffer[3] = (128 | ((u8)((icode & 63)))); | |
| 16295 | + return 4; | |
| 16296 | + } | |
| 16297 | + } | |
| 16298 | + return 0; | |
| 16299 | +} | |
| 16300 | +int builtin__string_utf32_code(string _rune) { | |
| 16301 | + if (_rune.len > 4) { | |
| 16302 | + return 0; | |
| 16303 | + } | |
| 16304 | + return ((int)(builtin__impl_utf8_to_utf32(_rune.str, _rune.len))); | |
| 16305 | +} | |
| 16306 | +_result_rune Array_u8_utf8_to_utf32(Array_u8 _bytes) { | |
| 16307 | + if (_bytes.len > 4) { | |
| 16308 | + return (_result_rune){ .is_error=true, .err=builtin___v_error(_S("attempted to decode too many bytes, utf-8 is limited to four bytes maximum")), .data={E_STRUCT} }; | |
| 16309 | + } | |
| 16310 | + _result_rune _t2; | |
| 16311 | + builtin___result_ok(&(rune[]) { builtin__impl_utf8_to_utf32(_bytes.data, _bytes.len) }, (_result*)(&_t2), sizeof(rune)); | |
| 16312 | + | |
| 16313 | + return _t2; | |
| 16314 | +} | |
| 16315 | +inline VV_LOC bool builtin__utf8_is_continuation(u8 b) { | |
| 16316 | + return ((b & 0xc0)) == 0x80; | |
| 16317 | +} | |
| 16318 | +VV_LOC multi_return_rune_int builtin__utf8_decode_rune(u8* _bytes, int available_len) { | |
| 16319 | + if (available_len <= 0) { | |
| 16320 | + return (multi_return_rune_int){.arg0=0, .arg1=0}; | |
| 16321 | + } | |
| 16322 | + u8 b0 = _bytes[0]; | |
| 16323 | + if (b0 < 0x80) { | |
| 16324 | + return (multi_return_rune_int){.arg0=((rune)(b0)), .arg1=1}; | |
| 16325 | + } | |
| 16326 | + if (b0 < 0xc2) { | |
| 16327 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | |
| 16328 | + } | |
| 16329 | + int _t4; /* if prepend */ | |
| 16330 | + if (b0 < 0xe0) { | |
| 16331 | + _t4 = 2; | |
| 16332 | + goto _t5; | |
| 16333 | + }; | |
| 16334 | + { | |
| 16335 | + if (b0 < 0xf0) { | |
| 16336 | + _t4 = 3; | |
| 16337 | + goto _t5; | |
| 16338 | + }; | |
| 16339 | + { | |
| 16340 | + if (b0 < 0xf5) { | |
| 16341 | + _t4 = 4; | |
| 16342 | + goto _t5; | |
| 16343 | + }; | |
| 16344 | + { | |
| 16345 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | |
| 16346 | + } | |
| 16347 | + } | |
| 16348 | + } | |
| 16349 | + _t5: {}; | |
| 16350 | + int char_len = _t4; | |
| 16351 | + if (available_len < char_len) { | |
| 16352 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | |
| 16353 | + } | |
| 16354 | + u8 b1 = _bytes[1]; | |
| 16355 | + if (!builtin__utf8_is_continuation(b1)) { | |
| 16356 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | |
| 16357 | + } | |
| 16358 | + if (char_len == 2) { | |
| 16359 | + return (multi_return_rune_int){.arg0=((v__lshift_rune(((((rune)(b0)) & 0x1f)), (u64)6)) | ((((rune)(b1)) & 0x3f))), .arg1=2}; | |
| 16360 | + } | |
| 16361 | + if (b0 == 0xe0 && b1 < 0xa0) { | |
| 16362 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | |
| 16363 | + } | |
| 16364 | + if (b0 == 0xed && b1 >= 0xa0) { | |
| 16365 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | |
| 16366 | + } | |
| 16367 | + u8 b2 = _bytes[2]; | |
| 16368 | + if (!builtin__utf8_is_continuation(b2)) { | |
| 16369 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | |
| 16370 | + } | |
| 16371 | + if (char_len == 3) { | |
| 16372 | + return (multi_return_rune_int){.arg0=(((v__lshift_rune(((((rune)(b0)) & 0x0f)), (u64)12)) | (v__lshift_rune(((((rune)(b1)) & 0x3f)), (u64)6))) | ((((rune)(b2)) & 0x3f))), .arg1=3}; | |
| 16373 | + } | |
| 16374 | + if (b0 == 0xf0 && b1 < 0x90) { | |
| 16375 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | |
| 16376 | + } | |
| 16377 | + if (b0 == 0xf4 && b1 > 0x8f) { | |
| 16378 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | |
| 16379 | + } | |
| 16380 | + u8 b3 = _bytes[3]; | |
| 16381 | + if (!builtin__utf8_is_continuation(b3)) { | |
| 16382 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | |
| 16383 | + } | |
| 16384 | + return (multi_return_rune_int){.arg0=((((v__lshift_rune(((((rune)(b0)) & 0x07)), (u64)18)) | (v__lshift_rune(((((rune)(b1)) & 0x3f)), (u64)12))) | (v__lshift_rune(((((rune)(b2)) & 0x3f)), (u64)6))) | ((((rune)(b3)) & 0x3f))), .arg1=4}; | |
| 16385 | +} | |
| 16386 | +VV_LOC rune builtin__impl_utf8_to_utf32(u8* _bytes, int _bytes_len) { | |
| 16387 | + if (_bytes_len == 0 || _bytes_len > 4) { | |
| 16388 | + return 0; | |
| 16389 | + } | |
| 16390 | + multi_return_rune_int mr_4267 = builtin__utf8_decode_rune(_bytes, _bytes_len); | |
| 16391 | + rune r = mr_4267.arg0; | |
| 16392 | + int len = mr_4267.arg1; | |
| 16393 | + if (len != _bytes_len) { | |
| 16394 | + return _const_utf8_replacement_rune; | |
| 16395 | + } | |
| 16396 | + return r; | |
| 16397 | +} | |
| 16398 | +int builtin__utf8_str_visible_length(string s) { | |
| 16399 | + return builtin__utf8_grapheme_visible_length(s); | |
| 16400 | +} | |
| 16401 | +Array_u8 builtin__string_to_ansi_not_null_terminated(string _str) { | |
| 16402 | + u16* wstr = builtin__string_to_wide(_str, ((ToWideConfig){.from_ansi = 0,})); | |
| 16403 | + Array_u8 ansi = builtin__wide_to_ansi(wstr); | |
| 16404 | + if (ansi.len > 0) { | |
| 16405 | + ansi.len--; | |
| 16406 | + } | |
| 16407 | + return ansi; | |
| 16408 | +} | |
| 16409 | +inline bool builtin__ArrayFlags_is_empty(ArrayFlags* e) { | |
| 16410 | + return ((int)(*e)) == 0; | |
| 16411 | +} | |
| 16412 | +inline bool builtin__ArrayFlags_has(ArrayFlags* e, ArrayFlags flag_) { | |
| 16413 | + return ((((int)(*e)) & (((int)(flag_))))) != 0; | |
| 16414 | +} | |
| 16415 | +inline bool builtin__ArrayFlags_all(ArrayFlags* e, ArrayFlags flag_) { | |
| 16416 | + return ((((int)(*e)) & (((int)(flag_))))) == ((int)(flag_)); | |
| 16417 | +} | |
| 16418 | +inline void builtin__ArrayFlags_set(ArrayFlags* e, ArrayFlags flag_) { | |
| 16419 | + { // Unsafe block | |
| 16420 | + *e = ((ArrayFlags)((((int)(*e)) | (((int)(flag_)))))); | |
| 16421 | + } | |
| 16422 | +} | |
| 16423 | +inline void builtin__ArrayFlags_set_all(ArrayFlags* e) { | |
| 16424 | + { // Unsafe block | |
| 16425 | + *e = ((ArrayFlags)(0b1111111)); | |
| 16426 | + } | |
| 16427 | +} | |
| 16428 | +inline void builtin__ArrayFlags_clear(ArrayFlags* e, ArrayFlags flag_) { | |
| 16429 | + { // Unsafe block | |
| 16430 | + *e = ((ArrayFlags)((((int)(*e)) & ~(((int)(flag_)))))); | |
| 16431 | + } | |
| 16432 | +} | |
| 16433 | +inline void builtin__ArrayFlags_clear_all(ArrayFlags* e) { | |
| 16434 | + { // Unsafe block | |
| 16435 | + *e = ((ArrayFlags)(0)); | |
| 16436 | + } | |
| 16437 | +} | |
| 16438 | +inline void builtin__ArrayFlags_toggle(ArrayFlags* e, ArrayFlags flag_) { | |
| 16439 | + { // Unsafe block | |
| 16440 | + *e = ((ArrayFlags)((((int)(*e)) ^ (((int)(flag_)))))); | |
| 16441 | + } | |
| 16442 | +} | |
| 16443 | +inline ArrayFlags builtin__ArrayFlags__static__zero(void) { | |
| 16444 | + return ((ArrayFlags)(0)); | |
| 16445 | +} | |
| 16446 | +VV_LOC void main__vf_init(void) { | |
| 16447 | + string probe = _S("vf"); | |
| 16448 | + {int _ = probe.len;} | |
| 16449 | + ; | |
| 16450 | +} | |
| 16451 | +// export alias: vf_init -> main__vf_init | |
| 16452 | +void vf_init(void) { | |
| 16453 | + return main__vf_init(); | |
| 16454 | +} | |
| 16455 | +VV_LOC int main__vf_add(int a, int b) { | |
| 16456 | + return a + b; | |
| 16457 | +} | |
| 16458 | +// export alias: vf_add -> main__vf_add | |
| 16459 | +int vf_add(int a, int b) { | |
| 16460 | + return main__vf_add(a, b); | |
| 16461 | +} | |
| 16462 | +VV_LOC char* main__vf_greet(char* name) { | |
| 16463 | + string n = builtin__cstring_to_vstring(name); | |
| 16464 | + string res = builtin__string_plus_many(3, _MOV((string[3]){_S("Hello, "), n, _S(", from V!")})); | |
| 16465 | + u8* out = res.str; | |
| 16466 | + builtin__string_free(&n); | |
| 16467 | + return out; | |
| 16468 | +} | |
| 16469 | +// export alias: vf_greet -> main__vf_greet | |
| 16470 | +char* vf_greet(char* name) { | |
| 16471 | + return main__vf_greet(name); | |
| 16472 | +} | |
| 16473 | +VV_LOC void main__vf_free(voidptr p) { | |
| 16474 | + builtin___v_free(p); | |
| 16475 | +} | |
| 16476 | +// export alias: vf_free -> main__vf_free | |
| 16477 | +void vf_free(voidptr p) { | |
| 16478 | + return main__vf_free(p); | |
| 16479 | +} | |
| 16480 | +VV_LOC void main__main(void) { | |
| 16481 | +} | |
| 16482 | +void _vinit(int ___argc, voidptr ___argv) { | |
| 16483 | + static bool once = false; if (once) {return;} once = true; | |
| 16484 | + // Initializations of consts for module builtin.closure | |
| 16485 | + g_closure = ((builtin__closure__Closure){.ClosureMutex = ((builtin__closure__ClosureMutex){.closure_mtx = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}),.closure_ptr = 0,.closure_get_data = ((void*)0),.closure_cap = 0,.free_closure_ptr = 0,.pages = ((void*)0),.v_page_size = ((int)(0x4000)),.live = builtin__new_map(sizeof(voidptr), sizeof(builtin__closure__ClosureLiveInfo), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop),.active_lifetimes = builtin__new_map(sizeof(u64), sizeof(builtin__closure__ClosureLifetimeState*), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop),.next_generation = 0,.free_lifetime_states = ((void*)0),.next_lifetime_generation = 0,.lifetime_state_allocs = 0,}); // global 3 | |
| 16486 | +{ | |
| 16487 | +{ | |
| 16488 | +Array_fixed_u8_15 _t1; | |
| 16489 | +#if defined(__V_ppc64le) | |
| 16490 | +#elif !defined(__V_ppc64le) && !defined(__V_amd64) && !defined(__V_x86) && !defined(__V_arm64) && !defined(__V_arm32) && !defined(__V_rv64) && !defined(__V_rv32) && !defined(__V_s390x) && !defined(__V_loongarch64) | |
| 16491 | +#elif defined(__V_amd64) | |
| 16492 | + { Array_fixed_u8_15 _t2 = {((u8)(0xF3)), 0x44, 0x0F, 0x7E, 0x3D, 0xF7, 0xBF, 0xFF, 0xFF, 0xFF, 0x25, 0xF9, 0xBF, 0xFF, 0xFF} ; | |
| 16493 | + memcpy(&_t1, &_t2, sizeof(Array_fixed_u8_15)); | |
| 16494 | + } | |
| 16495 | + ; | |
| 16496 | +#elif defined(__V_x86) | |
| 16497 | +#elif defined(__V_arm64) | |
| 16498 | +#elif defined(__V_arm32) | |
| 16499 | +#elif defined(__V_rv64) | |
| 16500 | +#elif defined(__V_rv32) | |
| 16501 | +#elif defined(__V_s390x) | |
| 16502 | +#elif defined(__V_loongarch64) | |
| 16503 | +#elif defined(__V_sparc64) | |
| 16504 | +#elif 0 | |
| 16505 | +#else | |
| 16506 | +#endif | |
| 16507 | + memcpy(&_const_builtin__closure__closure_thunk, &_t1, sizeof(Array_fixed_u8_15)); | |
| 16508 | +} | |
| 16509 | +} | |
| 16510 | +{ | |
| 16511 | +{ | |
| 16512 | +Array_fixed_u8_6 _t3; | |
| 16513 | +#if !defined(__V_ppc64le) && !defined(__V_amd64) && !defined(__V_x86) && !defined(__V_arm64) && !defined(__V_arm32) && !defined(__V_rv64) && !defined(__V_rv32) && !defined(__V_s390x) && !defined(__V_loongarch64) | |
| 16514 | +#elif defined(__V_arm32) | |
| 16515 | +#elif defined(__V_amd64) | |
| 16516 | + { Array_fixed_u8_6 _t4 = {((u8)(0x66)), 0x4C, 0x0F, 0x7E, 0xF8, 0xC3} ; | |
| 16517 | + memcpy(&_t3, &_t4, sizeof(Array_fixed_u8_6)); | |
| 16518 | + } | |
| 16519 | + ; | |
| 16520 | +#elif defined(__V_x86) | |
| 16521 | +#elif defined(__V_arm64) | |
| 16522 | +#elif defined(__V_rv64) | |
| 16523 | +#elif defined(__V_rv32) | |
| 16524 | +#elif defined(__V_s390x) | |
| 16525 | +#elif defined(__V_ppc64le) | |
| 16526 | +#elif defined(__V_loongarch64) | |
| 16527 | +#elif defined(__V_sparc64) | |
| 16528 | +#elif 0 | |
| 16529 | +#else | |
| 16530 | +#endif | |
| 16531 | + memcpy(&_const_builtin__closure__closure_get_data_bytes, &_t3, sizeof(Array_fixed_u8_6)); | |
| 16532 | +} | |
| 16533 | +} | |
| 16534 | +{ | |
| 16535 | +{ | |
| 16536 | + _const_builtin__closure__closure_size_1 = (2 * ((u32)(sizeof(voidptr))) > ((u32)(15)) ? (2 * ((u32)(sizeof(voidptr)))) : (((u32)(15)) + ((u32)(sizeof(voidptr))) - 1)); | |
| 16537 | +} | |
| 16538 | +} | |
| 16539 | + _const_builtin__closure__closure_size = ((int)((_const_builtin__closure__closure_size_1 & ~(((u32)(sizeof(voidptr))) - 1)))); | |
| 16540 | + // Initializations of consts for module math.bits | |
| 16541 | + _const_math__bits__overflow_error = _S("Overflow Error"); | |
| 16542 | + _const_math__bits__divide_error = _S("Divide by Zero Error"); | |
| 16543 | + // Initializations of consts for module strconv | |
| 16544 | + _const_strconv__digit_pairs = _S("00102030405060708090011121314151617181910212223242526272829203132333435363738393041424344454647484940515253545556575859506162636465666768696071727374757677787970818283848586878889809192939495969798999"); | |
| 16545 | + _const_strconv__base_digits = _S("0123456789abcdefghijklmnopqrstuvwxyz"); | |
| 16546 | + _const_strconv__i64_min_int32 = ((i64)(-2147483647)) - 1; | |
| 16547 | + _const_strconv__i64_max_int32 = ((i64)(2147483646)) + 1; | |
| 16548 | + // Initializations of consts for module builtin | |
| 16549 | + _const_grapheme_control_ranges = _S("00000000090000000b0000000c0000000e0000001f0000007f0000009f000000ad000000ad0000001c0600001c0600000e1800000e1800000b2000000b2000000e2000000f200000282000002820000029200000292000002a2000002e20000060200000642000006520000065200000662000006f200000fffe0000fffe0000f0ff0000f8ff0000f9ff0000fbff00003034010038340100a0bc0100a3bc010073d101007ad1010000000e0000000e0001000e0001000e0002000e001f000e0080000e00ff000e00f0010e00ff0f0e00"); | |
| 16550 | + _const_grapheme_extend_ranges = _S("000300006f0300008304000087040000880400008904000091050000bd050000bf050000bf050000c1050000c2050000c4050000c5050000c7050000c7050000100600001a0600004b0600005f0600007006000070060000d6060000dc060000df060000e4060000e7060000e8060000ea060000ed0600001107000011070000300700004a070000a6070000b0070000eb070000f3070000fd070000fd07000016080000190800001b080000230800002508000027080000290800002d080000590800005b080000d3080000e1080000e3080000020900003a0900003a0900003c0900003c09000041090000480900004d0900004d090000510900005709000062090000630900008109000081090000bc090000bc090000be090000be090000c1090000c4090000cd090000cd090000d7090000d7090000e2090000e3090000fe090000fe090000010a0000020a00003c0a00003c0a0000410a0000420a0000470a0000480a00004b0a00004d0a0000510a0000510a0000700a0000710a0000750a0000750a0000810a0000820a0000bc0a0000bc0a0000c10a0000c50a0000c70a0000c80a0000cd0a0000cd0a0000e20a0000e30a0000fa0a0000ff0a0000010b0000010b00003c0b00003c0b00003e0b00003e0b00003f0b00003f0b0000410b0000440b00004d0b00004d0b0000550b0000560b0000570b0000570b0000620b0000630b0000820b0000820b0000be0b0000be0b0000c00b0000c00b0000cd0b0000cd0b0000d70b0000d70b0000000c0000000c0000040c0000040c00003e0c0000400c0000460c0000480c00004a0c00004d0c0000550c0000560c0000620c0000630c0000810c0000810c0000bc0c0000bc0c0000bf0c0000bf0c0000c20c0000c20c0000c60c0000c60c0000cc0c0000cd0c0000d50c0000d60c0000e20c0000e30c0000000d0000010d00003b0d00003c0d00003e0d00003e0d0000410d0000440d00004d0d00004d0d0000570d0000570d0000620d0000630d0000810d0000810d0000ca0d0000ca0d0000cf0d0000cf0d0000d20d0000d40d0000d60d0000d60d0000df0d0000df0d0000310e0000310e0000340e00003a0e0000470e00004e0e0000b10e0000b10e0000b40e0000bc0e0000c80e0000cd0e0000180f0000190f0000350f0000350f0000370f0000370f0000390f0000390f0000710f00007e0f0000800f0000840f0000860f0000870f00008d0f0000970f0000990f0000bc0f0000c60f0000c60f00002d100000301000003210000037100000391000003a1000003d1000003e10000058100000591000005e100000601000007110000074100000821000008210000085100000861000008d1000008d1000009d1000009d1000005d1300005f1300001217000014170000321700003417000052170000531700007217000073170000b4170000b5170000b7170000bd170000c6170000c6170000c9170000d3170000dd170000dd1700000b1800000d1800008518000086180000a9180000a9180000201900002219000027190000281900003219000032190000391900003b190000171a0000181a00001b1a00001b1a0000561a0000561a0000581a00005e1a0000601a0000601a0000621a0000621a0000651a00006c1a0000731a00007c1a00007f1a00007f1a0000b01a0000bd1a0000be1a0000be1a0000bf1a0000c01a0000001b0000031b0000341b0000341b0000351b0000351b0000361b00003a1b00003c1b00003c1b0000421b0000421b00006b1b0000731b0000801b0000811b0000a21b0000a51b0000a81b0000a91b0000ab1b0000ad1b0000e61b0000e61b0000e81b0000e91b0000ed1b0000ed1b0000ef1b0000f11b00002c1c0000331c0000361c0000371c0000d01c0000d21c0000d41c0000e01c0000e21c0000e81c0000ed1c0000ed1c0000f41c0000f41c0000f81c0000f91c0000c01d0000f91d0000fb1d0000ff1d00000c2000000c200000d0200000dc200000dd200000e0200000e1200000e1200000e2200000e4200000e5200000f0200000ef2c0000f12c00007f2d00007f2d0000e02d0000ff2d00002a3000002d3000002e3000002f300000993000009a3000006fa600006fa6000070a6000072a6000074a600007da600009ea600009fa60000f0a60000f1a6000002a8000002a8000006a8000006a800000ba800000ba8000025a8000026a800002ca800002ca80000c4a80000c5a80000e0a80000f1a80000ffa80000ffa8000026a900002da9000047a9000051a9000080a9000082a90000b3a90000b3a90000b6a90000b9a90000bca90000bda90000e5a90000e5a9000029aa00002eaa000031aa000032aa000035aa000036aa000043aa000043aa00004caa00004caa00007caa00007caa0000b0aa0000b0aa0000b2aa0000b4aa0000b7aa0000b8aa0000beaa0000bfaa0000c1aa0000c1aa0000ecaa0000edaa0000f6aa0000f6aa0000e5ab0000e5ab0000e8ab0000e8ab0000edab0000edab00001efb00001efb000000fe00000ffe000020fe00002ffe00009eff00009fff0000fd010100fd010100e0020100e0020100760301007a030100010a0100030a0100050a0100060a01000c0a01000f0a0100380a01003a0a01003f0a01003f0a0100e50a0100e60a0100240d0100270d0100ab0e0100ac0e0100460f0100500f0100011001000110010038100100461001007f10010081100100b3100100b6100100b9100100ba1001000011010002110100271101002b1101002d1101003411010073110100731101008011010081110100b6110100be110100c9110100cc110100cf110100cf1101002f12010031120100341201003412010036120100371201003e1201003e120100df120100df120100e3120100ea12010000130100011301003b1301003c1301003e1301003e13010040130100401301005713010057130100661301006c1301007013010074130100381401003f140100421401004414010046140100461401005e1401005e140100b0140100b0140100b3140100b8140100ba140100ba140100bd140100bd140100bf140100c0140100c2140100c3140100af150100af150100b2150100b5150100bc150100bd150100bf150100c0150100dc150100dd150100331601003a1601003d1601003d1601003f16010040160100ab160100ab160100ad160100ad160100b0160100b5160100b7160100b71601001d1701001f1701002217010025170100271701002b1701002f18010037180100391801003a18010030190100301901003b1901003c1901003e1901003e1901004319010043190100d4190100d7190100da190100db190100e0190100e0190100011a01000a1a0100331a0100381a01003b1a01003e1a0100471a0100471a0100511a0100561a0100591a01005b1a01008a1a0100961a0100981a0100991a0100301c0100361c0100381c01003d1c01003f1c01003f1c0100921c0100a71c0100aa1c0100b01c0100b21c0100b31c0100b51c0100b61c0100311d0100361d01003a1d01003a1d01003c1d01003d1d01003f1d0100451d0100471d0100471d0100901d0100911d0100951d0100951d0100971d0100971d0100f31e0100f41e0100f06a0100f46a0100306b0100366b01004f6f01004f6f01008f6f0100926f0100e46f0100e46f01009dbc01009ebc010065d1010065d1010067d1010069d101006ed1010072d101007bd1010082d1010085d101008bd10100aad10100add1010042d2010044d2010000da010036da01003bda01006cda010075da010075da010084da010084da01009bda01009fda0100a1da0100afda010000e0010006e0010008e0010018e001001be0010021e0010023e0010024e0010026e001002ae0010030e1010036e10100ece20100efe20100d0e80100d6e8010044e901004ae90100fbf30100fff3010020000e007f000e0000010e00ef010e00"); | |
| 16551 | + _const_grapheme_spacing_mark_ranges = _S("03090000030900003b0900003b0900003e09000040090000490900004c0900004e0900004f0900008209000083090000bf090000c0090000c7090000c8090000cb090000cc090000030a0000030a00003e0a0000400a0000830a0000830a0000be0a0000c00a0000c90a0000c90a0000cb0a0000cc0a0000020b0000030b0000400b0000400b0000470b0000480b00004b0b00004c0b0000bf0b0000bf0b0000c10b0000c20b0000c60b0000c80b0000ca0b0000cc0b0000010c0000030c0000410c0000440c0000820c0000830c0000be0c0000be0c0000c00c0000c10c0000c30c0000c40c0000c70c0000c80c0000ca0c0000cb0c0000020d0000030d00003f0d0000400d0000460d0000480d00004a0d00004c0d0000820d0000830d0000d00d0000d10d0000d80d0000de0d0000f20d0000f30d0000330e0000330e0000b30e0000b30e00003e0f00003f0f00007f0f00007f0f000031100000311000003b1000003c10000056100000571000008410000084100000b6170000b6170000be170000c5170000c7170000c81700002319000026190000291900002b19000030190000311900003319000038190000191a00001a1a0000551a0000551a0000571a0000571a00006d1a0000721a0000041b0000041b00003b1b00003b1b00003d1b0000411b0000431b0000441b0000821b0000821b0000a11b0000a11b0000a61b0000a71b0000aa1b0000aa1b0000e71b0000e71b0000ea1b0000ec1b0000ee1b0000ee1b0000f21b0000f31b0000241c00002b1c0000341c0000351c0000e11c0000e11c0000f71c0000f71c000023a8000024a8000027a8000027a8000080a8000081a80000b4a80000c3a8000052a9000053a9000083a9000083a90000b4a90000b5a90000baa90000bba90000bea90000c0a900002faa000030aa000033aa000034aa00004daa00004daa0000ebaa0000ebaa0000eeaa0000efaa0000f5aa0000f5aa0000e3ab0000e4ab0000e6ab0000e7ab0000e9ab0000eaab0000ecab0000ecab0000001001000010010002100100021001008210010082100100b0100100b2100100b7100100b81001002c1101002c11010045110100461101008211010082110100b3110100b5110100bf110100c0110100ce110100ce1101002c1201002e12010032120100331201003512010035120100e0120100e212010002130100031301003f1301003f130100411301004413010047130100481301004b1301004d1301006213010063130100351401003714010040140100411401004514010045140100b1140100b2140100b9140100b9140100bb140100bc140100be140100be140100c1140100c1140100b0150100b1150100b8150100bb150100be150100be15010030160100321601003b1601003c1601003e1601003e160100ac160100ac160100ae160100af160100b6160100b6160100201701002117010026170100261701002c1801002e1801003818010038180100311901003519010037190100381901003d1901003d19010040190100401901004219010042190100d1190100d3190100dc190100df190100e4190100e4190100391a0100391a0100571a0100581a0100971a0100971a01002f1c01002f1c01003e1c01003e1c0100a91c0100a91c0100b11c0100b11c0100b41c0100b41c01008a1d01008e1d0100931d0100941d0100961d0100961d0100f51e0100f61e0100516f0100876f0100f06f0100f16f010066d1010066d101006dd101006dd10100"); | |
| 16552 | + _const_grapheme_prepend_ranges = _S("0006000005060000dd060000dd0600000f0700000f070000e2080000e20800004e0d00004e0d0000bd100100bd100100cd100100cd100100c2110100c31101003f1901003f19010041190100411901003a1a01003a1a0100841a0100891a0100461d0100461d0100"); | |
| 16553 | + _const_grapheme_extended_pictographic_ranges = _S("a9000000a9000000ae000000ae0000003c2000003c2000004920000049200000222100002221000039210000392100009421000099210000a9210000aa2100001a2300001b23000028230000282300008823000088230000cf230000cf230000e9230000ec230000ed230000ee230000ef230000ef230000f0230000f0230000f1230000f2230000f3230000f3230000f8230000fa230000c2240000c2240000aa250000ab250000b6250000b6250000c0250000c0250000fb250000fe2500000026000001260000022600000326000004260000042600000526000005260000072600000d2600000e2600000e2600000f2600001026000011260000112600001226000012260000142600001526000016260000172600001826000018260000192600001c2600001d2600001d2600001e2600001f2600002026000020260000212600002126000022260000232600002426000025260000262600002626000027260000292600002a2600002a2600002b2600002d2600002e2600002e2600002f2600002f260000302600003726000038260000392600003a2600003a2600003b2600003f26000040260000402600004126000041260000422600004226000043260000472600004826000053260000542600005e2600005f2600005f2600006026000060260000612600006226000063260000632600006426000064260000652600006626000067260000672600006826000068260000692600007a2600007b2600007b2600007c2600007d2600007e2600007e2600007f2600007f2600008026000085260000902600009126000092260000922600009326000093260000942600009426000095260000952600009626000097260000982600009826000099260000992600009a2600009a2600009b2600009c2600009d2600009f260000a0260000a1260000a2260000a6260000a7260000a7260000a8260000a9260000aa260000ab260000ac260000af260000b0260000b1260000b2260000bc260000bd260000be260000bf260000c3260000c4260000c5260000c6260000c7260000c8260000c8260000c9260000cd260000ce260000ce260000cf260000cf260000d0260000d0260000d1260000d1260000d2260000d2260000d3260000d3260000d4260000d4260000d5260000e8260000e9260000e9260000ea260000ea260000eb260000ef260000f0260000f1260000f2260000f3260000f4260000f4260000f5260000f5260000f6260000f6260000f7260000f9260000fa260000fa260000fb260000fc260000fd260000fd260000fe26000001270000022700000227000003270000042700000527000005270000082700000c2700000d2700000d2700000e2700000e2700000f2700000f27000010270000112700001227000012270000142700001427000016270000162700001d2700001d270000212700002127000028270000282700003327000034270000442700004427000047270000472700004c2700004c2700004e2700004e270000532700005527000057270000572700006327000063270000642700006427000065270000672700009527000097270000a1270000a1270000b0270000b0270000bf270000bf2700003429000035290000052b0000072b00001b2b00001c2b0000502b0000502b0000552b0000552b000030300000303000003d3000003d3000009732000097320000993200009932000000f0010003f0010004f0010004f0010005f00100cef00100cff00100cff00100d0f00100fff001000df101000ff101002ff101002ff101006cf101006ff1010070f1010071f101007ef101007ff101008ef101008ef1010091f101009af10100adf10100e5f1010001f2010002f2010003f201000ff201001af201001af201002ff201002ff2010032f201003af201003cf201003ff2010049f201004ff2010050f2010051f2010052f20100fff2010000f301000cf301000df301000ef301000ff301000ff3010010f3010010f3010011f3010011f3010012f3010012f3010013f3010015f3010016f3010018f3010019f3010019f301001af301001af301001bf301001bf301001cf301001cf301001df301001ef301001ff3010020f3010021f3010021f3010022f3010023f3010024f301002cf301002df301002ff3010030f3010031f3010032f3010033f3010034f3010035f3010036f3010036f3010037f301004af301004bf301004bf301004cf301004ff3010050f3010050f3010051f301007bf301007cf301007cf301007df301007df301007ef301007ff3010080f3010093f3010094f3010095f3010096f3010097f3010098f3010098f3010099f301009bf301009cf301009df301009ef301009ff30100a0f30100c4f30100c5f30100c5f30100c6f30100c6f30100c7f30100c7f30100c8f30100c8f30100c9f30100c9f30100caf30100caf30100cbf30100cef30100cff30100d3f30100d4f30100dff30100e0f30100e3f30100e4f30100e4f30100e5f30100f0f30100f1f30100f2f30100f3f30100f3f30100f4f30100f4f30100f5f30100f5f30100f6f30100f6f30100f7f30100f7f30100f8f30100faf3010000f4010007f4010008f4010008f4010009f401000bf401000cf401000ef401000ff4010010f4010011f4010012f4010013f4010013f4010014f4010014f4010015f4010015f4010016f4010016f4010017f4010029f401002af401002af401002bf401003ef401003ff401003ff4010040f4010040f4010041f4010041f4010042f4010064f4010065f4010065f4010066f401006bf401006cf401006df401006ef40100acf40100adf40100adf40100aef40100b5f40100b6f40100b7f40100b8f40100ebf40100ecf40100edf40100eef40100eef40100eff40100eff40100f0f40100f4f40100f5f40100f5f40100f6f40100f7f40100f8f40100f8f40100f9f40100fcf40100fdf40100fdf40100fef40100fef40100fff4010002f5010003f5010003f5010004f5010007f5010008f5010008f5010009f5010009f501000af5010014f5010015f5010015f5010016f501002bf501002cf501002df501002ef501003df5010046f5010048f5010049f501004af501004bf501004ef501004ff501004ff5010050f501005bf501005cf5010067f5010068f501006ef501006ff5010070f5010071f5010072f5010073f5010079f501007af501007af501007bf5010086f5010087f5010087f5010088f5010089f501008af501008df501008ef501008ff5010090f5010090f5010091f5010094f5010095f5010096f5010097f50100a3f50100a4f50100a4f50100a5f50100a5f50100a6f50100a7f50100a8f50100a8f50100a9f50100b0f50100b1f50100b2f50100b3f50100bbf50100bcf50100bcf50100bdf50100c1f50100c2f50100c4f50100c5f50100d0f50100d1f50100d3f50100d4f50100dbf50100dcf50100def50100dff50100e0f50100e1f50100e1f50100e2f50100e2f50100e3f50100e3f50100e4f50100e7f50100e8f50100e8f50100e9f50100eef50100eff50100eff50100f0f50100f2f50100f3f50100f3f50100f4f50100f9f50100faf50100faf50100fbf50100fff5010000f6010000f6010001f6010006f6010007f6010008f6010009f601000df601000ef601000ef601000ff601000ff6010010f6010010f6010011f6010011f6010012f6010014f6010015f6010015f6010016f6010016f6010017f6010017f6010018f6010018f6010019f6010019f601001af601001af601001bf601001bf601001cf601001ef601001ff601001ff6010020f6010025f6010026f6010027f6010028f601002bf601002cf601002cf601002df601002df601002ef601002ff6010030f6010033f6010034f6010034f6010035f6010035f6010036f6010036f6010037f6010040f6010041f6010044f6010045f601004ff6010080f6010080f6010081f6010082f6010083f6010085f6010086f6010086f6010087f6010087f6010088f6010088f6010089f6010089f601008af601008bf601008cf601008cf601008df601008df601008ef601008ef601008ff601008ff6010090f6010090f6010091f6010093f6010094f6010094f6010095f6010095f6010096f6010096f6010097f6010097f6010098f6010098f6010099f601009af601009bf60100a1f60100a2f60100a2f60100a3f60100a3f60100a4f60100a5f60100a6f60100a6f60100a7f60100adf60100aef60100b1f60100b2f60100b2f60100b3f60100b5f60100b6f60100b6f60100b7f60100b8f60100b9f60100bef60100bff60100bff60100c0f60100c0f60100c1f60100c5f60100c6f60100caf60100cbf60100cbf60100ccf60100ccf60100cdf60100cff60100d0f60100d0f60100d1f60100d2f60100d3f60100d4f60100d5f60100d5f60100d6f60100d7f60100d8f60100dff60100e0f60100e5f60100e6f60100e8f60100e9f60100e9f60100eaf60100eaf60100ebf60100ecf60100edf60100eff60100f0f60100f0f60100f1f60100f2f60100f3f60100f3f60100f4f60100f6f60100f7f60100f8f60100f9f60100f9f60100faf60100faf60100fbf60100fcf60100fdf60100fff6010074f701007ff70100d5f70100dff70100e0f70100ebf70100ecf70100fff701000cf801000ff8010048f801004ff801005af801005ff8010088f801008ff80100aef80100fff801000cf901000cf901000df901000ff9010010f9010018f9010019f901001ef901001ff901001ff9010020f9010027f9010028f901002ff9010030f9010030f9010031f9010032f9010033f901003af901003cf901003ef901003ff901003ff9010040f9010045f9010047f901004bf901004cf901004cf901004df901004ff9010050f901005ef901005ff901006bf901006cf9010070f9010071f9010071f9010072f9010072f9010073f9010076f9010077f9010078f9010079f9010079f901007af901007af901007bf901007bf901007cf901007ff9010080f9010084f9010085f9010091f9010092f9010097f9010098f90100a2f90100a3f90100a4f90100a5f90100aaf90100abf90100adf90100aef90100aff90100b0f90100b9f90100baf90100bff90100c0f90100c0f90100c1f90100c2f90100c3f90100caf90100cbf90100cbf90100ccf90100ccf90100cdf90100cff90100d0f90100e6f90100e7f90100fff9010000fa01006ffa010070fa010073fa010074fa010074fa010075fa010077fa010078fa01007afa01007bfa01007ffa010080fa010082fa010083fa010086fa010087fa01008ffa010090fa010095fa010096fa0100a8fa0100a9fa0100affa0100b0fa0100b6fa0100b7fa0100bffa0100c0fa0100c2fa0100c3fa0100cffa0100d0fa0100d6fa0100d7fa0100fffa010000fc0100fdff0100"); | |
| 16554 | + _const_digit_pairs = _S("00102030405060708090011121314151617181910212223242526272829203132333435363738393041424344454647484940515253545556575859506162636465666768696071727374757677787970818283848586878889809192939495969798999"); | |
| 16555 | + _const_si_s_code = _S("0xfe10"); | |
| 16556 | + _const_si_g32_code = _S("0xfe0e"); | |
| 16557 | + _const_si_g64_code = _S("0xfe0f"); | |
| 16558 | + g_live_reload_info = *(voidptr*)&((voidptr[]){0}[0]); // global 5 | |
| 16559 | + _const_error_sentinel = I_MessageError_to_Interface_IError((HEAP(MessageError, ((MessageError){.msg = _S("error"),.code = 0,})))); | |
| 16560 | + _const_none__ = I_None___to_Interface_IError((HEAP(None__, ((None__){.Error = ((Error){E_STRUCT}),})))); | |
| 16561 | + _const_min_i64 = ((i64)(-9223372036854775807LL - 1)); | |
| 16562 | + _const_max_i64 = ((i64)(9223372036854775807LL)); | |
| 16563 | + _const_utf8_replacement_rune = ((rune)(0xfffd)); | |
| 16564 | +} | |
| 16565 | +void _vcleanup(void) { | |
| 16566 | + static bool once = false; if (once) {return;} once = true; | |
| 16567 | +} | |
| 16568 | +__attribute__ ((constructor)) | |
| 16569 | +void _vinit_caller() { | |
| 16570 | + static bool once = false; if (once) {return;} once = true; | |
| 16571 | + _vinit(0,0); | |
| 16572 | +} | |
| 16573 | +__attribute__ ((destructor)) | |
| 16574 | +void _vcleanup_caller() { | |
| 16575 | + static bool once = false; if (once) {return;} once = true; | |
| 16576 | + _vcleanup(); | |
| 16577 | +} | |
| 16578 | + | |
| 16579 | +int main(int ___argc, char** ___argv){ | |
| 16580 | + g_main_argc = ___argc; | |
| 16581 | + g_main_argv = ___argv; | |
| 16582 | + _vinit(___argc, (voidptr)___argv); | |
| 16583 | + main__main(); | |
| 16584 | + _vcleanup(); | |
| 16585 | + return 0; | |
| 16586 | +} | |
| 16587 | +// THE END. | |
| new file mode 100644 | |||
| @@ -0,0 +1,16587 @@ | |||
| 1 | + | ||
| 2 | +#ifndef V_COMMIT_HASH | ||
| 3 | + #define V_COMMIT_HASH "45ae01d23168b6372f734eeb38a77360bbcf184a" | ||
| 4 | +#endif | ||
| 5 | + | ||
| 6 | +#define V_USE_SIGNAL_H | ||
| 7 | + | ||
| 8 | +// V comptime_definitions: | ||
| 9 | +// V compile time defines by -d or -define flags: | ||
| 10 | +// All custom defines : linux | ||
| 11 | +// Turned ON custom defines: linux | ||
| 12 | +#define CUSTOM_DEFINE_linux | ||
| 13 | + | ||
| 14 | + | ||
| 15 | +// V typedefs: | ||
| 16 | +typedef struct IError IError; | ||
| 17 | +typedef struct none none; | ||
| 18 | + | ||
| 19 | +// BEGIN_array_fixed_return_typedefs | ||
| 20 | +typedef struct _v_Array_fixed_string_11 _v_Array_fixed_string_11; | ||
| 21 | +typedef struct _v_Array_fixed_voidptr_11 _v_Array_fixed_voidptr_11; | ||
| 22 | +typedef struct _v_Array_fixed_u8_128 _v_Array_fixed_u8_128; | ||
| 23 | +typedef struct _v_Array_fixed_u8_32 _v_Array_fixed_u8_32; | ||
| 24 | +typedef struct _v_Array_fixed_u8_64 _v_Array_fixed_u8_64; | ||
| 25 | +typedef struct _v_Array_fixed_u8_5 _v_Array_fixed_u8_5; | ||
| 26 | +typedef struct _v_Array_fixed_u8_20 _v_Array_fixed_u8_20; | ||
| 27 | +typedef struct _v_Array_fixed_u8_15 _v_Array_fixed_u8_15; | ||
| 28 | +typedef struct _v_Array_fixed_u8_6 _v_Array_fixed_u8_6; | ||
| 29 | +typedef struct _v_Array_fixed_u8_256 _v_Array_fixed_u8_256; | ||
| 30 | +typedef struct _v_Array_fixed_u64_309 _v_Array_fixed_u64_309; | ||
| 31 | +typedef struct _v_Array_fixed_u64_324 _v_Array_fixed_u64_324; | ||
| 32 | +typedef struct _v_Array_fixed_u32_10 _v_Array_fixed_u32_10; | ||
| 33 | +typedef struct _v_Array_fixed_u64_20 _v_Array_fixed_u64_20; | ||
| 34 | +typedef struct _v_Array_fixed_u64_584 _v_Array_fixed_u64_584; | ||
| 35 | +typedef struct _v_Array_fixed_u64_652 _v_Array_fixed_u64_652; | ||
| 36 | +typedef struct _v_Array_fixed_f64_36 _v_Array_fixed_f64_36; | ||
| 37 | +typedef struct _v_Array_fixed_u8_26 _v_Array_fixed_u8_26; | ||
| 38 | +typedef struct _v_Array_fixed_u8_512 _v_Array_fixed_u8_512; | ||
| 39 | +typedef struct _v_Array_fixed_u64_47 _v_Array_fixed_u64_47; | ||
| 40 | +typedef struct _v_Array_fixed_u64_31 _v_Array_fixed_u64_31; | ||
| 41 | +typedef struct _v_Array_fixed_int_64 _v_Array_fixed_int_64; | ||
| 42 | +typedef struct _v_Array_fixed_voidptr_64 _v_Array_fixed_voidptr_64; | ||
| 43 | +typedef struct _v_Array_fixed_voidptr_100 _v_Array_fixed_voidptr_100; | ||
| 44 | +typedef struct _v_Array_fixed_u8_1000 _v_Array_fixed_u8_1000; | ||
| 45 | +typedef struct _v_Array_fixed_u8_17 _v_Array_fixed_u8_17; | ||
| 46 | +typedef struct _v_Array_fixed_i32_1264 _v_Array_fixed_i32_1264; | ||
| 47 | +typedef struct _v_Array_fixed_int_10 _v_Array_fixed_int_10; | ||
| 48 | +typedef struct _v_Array_fixed_int_20 _v_Array_fixed_int_20; | ||
| 49 | +// END_array_fixed_return_typedefs | ||
| 50 | + | ||
| 51 | + | ||
| 52 | +// BEGIN_multi_return_typedefs | ||
| 53 | +typedef struct multi_return_u32_u32 multi_return_u32_u32; | ||
| 54 | +typedef struct multi_return_string_string multi_return_string_string; | ||
| 55 | +typedef struct multi_return_int_int multi_return_int_int; | ||
| 56 | +typedef struct multi_return_rune_int multi_return_rune_int; | ||
| 57 | +typedef struct multi_return_u32_u32_u32 multi_return_u32_u32_u32; | ||
| 58 | +typedef struct multi_return_strconv__ParserState_strconv__PrepNumber multi_return_strconv__ParserState_strconv__PrepNumber; | ||
| 59 | +typedef struct multi_return_u64_int multi_return_u64_int; | ||
| 60 | +typedef struct multi_return_i64_int multi_return_i64_int; | ||
| 61 | +typedef struct multi_return_strconv__Dec32_bool multi_return_strconv__Dec32_bool; | ||
| 62 | +typedef struct multi_return_strconv__Dec64_bool multi_return_strconv__Dec64_bool; | ||
| 63 | +typedef struct multi_return_u64_u64 multi_return_u64_u64; | ||
| 64 | +typedef struct multi_return_f64_int multi_return_f64_int; | ||
| 65 | +// END_multi_return_typedefs | ||
| 66 | + | ||
| 67 | +typedef struct strings__IndentParam strings__IndentParam; | ||
| 68 | +typedef struct builtin__closure__ClosurePage builtin__closure__ClosurePage; | ||
| 69 | +typedef struct builtin__closure__ClosureLiveInfo builtin__closure__ClosureLiveInfo; | ||
| 70 | +typedef struct builtin__closure__ClosureLifetimeRecord builtin__closure__ClosureLifetimeRecord; | ||
| 71 | +typedef struct builtin__closure__ClosureLifetimeFrame builtin__closure__ClosureLifetimeFrame; | ||
| 72 | +typedef struct builtin__closure__ClosureLifetimeState builtin__closure__ClosureLifetimeState; | ||
| 73 | +typedef struct builtin__closure__Lifetime builtin__closure__Lifetime; | ||
| 74 | +typedef struct builtin__closure__FrameToken builtin__closure__FrameToken; | ||
| 75 | +typedef struct builtin__closure__Closure builtin__closure__Closure; | ||
| 76 | +typedef struct builtin__closure__ClosureMutex builtin__closure__ClosureMutex; | ||
| 77 | +typedef struct strconv__AtoF64Param strconv__AtoF64Param; | ||
| 78 | +typedef struct strconv__BF_param strconv__BF_param; | ||
| 79 | +typedef struct strconv__PrepNumber strconv__PrepNumber; | ||
| 80 | +typedef struct strconv__Dec32 strconv__Dec32; | ||
| 81 | +typedef struct strconv__Dec64 strconv__Dec64; | ||
| 82 | +typedef struct strconv__Uint128 strconv__Uint128; | ||
| 83 | +typedef union strconv__Uf32 strconv__Uf32; | ||
| 84 | +typedef union strconv__Uf64 strconv__Uf64; | ||
| 85 | +typedef union strconv__Float64u strconv__Float64u; | ||
| 86 | +typedef union strconv__Float32u strconv__Float32u; | ||
| 87 | +typedef struct GCHeapUsage GCHeapUsage; | ||
| 88 | +typedef struct array array; | ||
| 89 | +typedef struct ArrayDataHeader ArrayDataHeader; | ||
| 90 | +typedef struct _result _result; | ||
| 91 | +typedef struct Error Error; | ||
| 92 | +typedef struct MessageError MessageError; | ||
| 93 | +typedef struct _option _option; | ||
| 94 | +typedef struct None__ None__; | ||
| 95 | +typedef struct GraphemeState GraphemeState; | ||
| 96 | +typedef struct InputRuneIterator InputRuneIterator; | ||
| 97 | +typedef struct DenseArray DenseArray; | ||
| 98 | +typedef struct map map; | ||
| 99 | +typedef struct VAssertMetaInfo VAssertMetaInfo; | ||
| 100 | +typedef struct SortedMap SortedMap; | ||
| 101 | +typedef struct mapnode mapnode; | ||
| 102 | +typedef struct string string; | ||
| 103 | +typedef struct RepIndex RepIndex; | ||
| 104 | +typedef struct WrapConfig WrapConfig; | ||
| 105 | +typedef struct RunesIterator RunesIterator; | ||
| 106 | +typedef union StrIntpMem StrIntpMem; | ||
| 107 | +typedef struct StrIntpData StrIntpData; | ||
| 108 | +typedef struct ToWideConfig ToWideConfig; | ||
| 109 | +typedef struct _result_int _result_int; | ||
| 110 | +typedef struct _result_builtin__closure__ClosureLifetimeState_ptr _result_builtin__closure__ClosureLifetimeState_ptr; | ||
| 111 | +typedef struct _result_builtin__closure__FrameToken _result_builtin__closure__FrameToken; | ||
| 112 | +typedef struct _result_void _result_void; | ||
| 113 | +typedef struct _result_f64 _result_f64; | ||
| 114 | +typedef struct _result_u64 _result_u64; | ||
| 115 | +typedef struct _result_i64 _result_i64; | ||
| 116 | +typedef struct _result_multi_return_i64_int _result_multi_return_i64_int; | ||
| 117 | +typedef struct _result_i8 _result_i8; | ||
| 118 | +typedef struct _result_i16 _result_i16; | ||
| 119 | +typedef struct _result_i32 _result_i32; | ||
| 120 | +typedef struct _result_u8 _result_u8; | ||
| 121 | +typedef struct _result_u16 _result_u16; | ||
| 122 | +typedef struct _result_u32 _result_u32; | ||
| 123 | +typedef struct _result_rune _result_rune; | ||
| 124 | +typedef struct _result_string _result_string; | ||
| 125 | +typedef struct _option_builtin__closure__ClosureLiveInfo _option_builtin__closure__ClosureLiveInfo; | ||
| 126 | +typedef struct _option_builtin__closure__ClosureLifetimeState_ptr _option_builtin__closure__ClosureLifetimeState_ptr; | ||
| 127 | +typedef struct _option_int _option_int; | ||
| 128 | +typedef struct _option_rune _option_rune; | ||
| 129 | +typedef struct _option_multi_return_string_string _option_multi_return_string_string; | ||
| 130 | +typedef struct _option_u8 _option_u8; | ||
| 131 | + | ||
| 132 | + // V preincludes: | ||
| 133 | +#define _GNU_SOURCE | ||
| 134 | + | ||
| 135 | +#if defined(__TINYC__) && defined(__has_include) // tcc does not support has_include properly yet, turn it off completely | ||
| 136 | +#undef __has_include | ||
| 137 | +#endif | ||
| 138 | + | ||
| 139 | +#if defined(__TINYC__) && defined(__BIONIC__) | ||
| 140 | + #define __builtin_nanf(ignored_string) (0.0F / 0.0F) | ||
| 141 | + #define __builtin_nan(ignored_string) (0.0 / 0.0) | ||
| 142 | + #define __builtin_nanl(ignored_string) (0.0L / 0.0L) | ||
| 143 | + #define __builtin_inff() (1.0F / 0.0F) | ||
| 144 | + #define __builtin_inf() (1.0 / 0.0) | ||
| 145 | + #define __builtin_infl() (1.0L / 0.0L) | ||
| 146 | + #define __builtin_huge_valf() (1.0F / 0.0F) | ||
| 147 | + #define __builtin_huge_val() (1.0 / 0.0) | ||
| 148 | + #define __builtin_huge_vall() (1.0L / 0.0L) | ||
| 149 | +#endif | ||
| 150 | + | ||
| 151 | +// V cheaders: | ||
| 152 | +// Generated by the V compiler | ||
| 153 | + | ||
| 154 | +#if defined __GNUC__ && __GNUC__ >= 14 | ||
| 155 | +#pragma GCC diagnostic warning "-Wimplicit-function-declaration" | ||
| 156 | +#pragma GCC diagnostic warning "-Wincompatible-pointer-types" | ||
| 157 | +#pragma GCC diagnostic warning "-Wint-conversion" | ||
| 158 | +#pragma GCC diagnostic warning "-Wreturn-mismatch" | ||
| 159 | +#endif | ||
| 160 | + | ||
| 161 | + | ||
| 162 | +#if defined(__TINYC__) && defined(__has_include) // tcc does not support has_include properly yet, turn it off completely | ||
| 163 | +#undef __has_include | ||
| 164 | +#endif | ||
| 165 | + | ||
| 166 | +#if defined(__TINYC__) && defined(__BIONIC__) | ||
| 167 | + #define __builtin_nanf(ignored_string) (0.0F / 0.0F) | ||
| 168 | + #define __builtin_nan(ignored_string) (0.0 / 0.0) | ||
| 169 | + #define __builtin_nanl(ignored_string) (0.0L / 0.0L) | ||
| 170 | + #define __builtin_inff() (1.0F / 0.0F) | ||
| 171 | + #define __builtin_inf() (1.0 / 0.0) | ||
| 172 | + #define __builtin_infl() (1.0L / 0.0L) | ||
| 173 | + #define __builtin_huge_valf() (1.0F / 0.0F) | ||
| 174 | + #define __builtin_huge_val() (1.0 / 0.0) | ||
| 175 | + #define __builtin_huge_vall() (1.0L / 0.0L) | ||
| 176 | +#endif | ||
| 177 | + | ||
| 178 | +#ifdef __TINYC__ | ||
| 179 | +#include <inttypes.h> | ||
| 180 | +#else | ||
| 181 | +#if defined(__has_include) | ||
| 182 | +#if __has_include(<inttypes.h>) | ||
| 183 | +#include <inttypes.h> | ||
| 184 | +#elif __has_include(<stdint.h>) | ||
| 185 | +#include <stdint.h> | ||
| 186 | +#else | ||
| 187 | +#error VERROR_MESSAGE The C compiler can not find <stdint.h>. Please install the package `build-essential`. | ||
| 188 | +#endif | ||
| 189 | +#else | ||
| 190 | +#include <stdint.h> | ||
| 191 | +#endif | ||
| 192 | +#endif | ||
| 193 | + | ||
| 194 | + | ||
| 195 | +#ifdef __TINYC__ | ||
| 196 | +#include <stddef.h> | ||
| 197 | +#else | ||
| 198 | +#if defined(__has_include) | ||
| 199 | +#if __has_include(<stddef.h>) | ||
| 200 | +#include <stddef.h> | ||
| 201 | +#else | ||
| 202 | +#error VERROR_MESSAGE The C compiler can not find <stddef.h>. Please install the package `build-essential`. | ||
| 203 | +#endif | ||
| 204 | +#else | ||
| 205 | +#include <stddef.h> | ||
| 206 | +#endif | ||
| 207 | +#endif | ||
| 208 | + | ||
| 209 | + | ||
| 210 | +//================================== builtin types ================================*/ | ||
| 211 | +#if defined(__x86_64__) || defined(_M_AMD64) || defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64) || (defined(__riscv_xlen) && __riscv_xlen == 64) || defined(__s390x__) || (defined(__powerpc64__) && defined(__LITTLE_ENDIAN__)) || defined(__loongarch64) || defined(__sparc__) || (defined(__powerpc64__) && defined(__BIG_ENDIAN__)) | ||
| 212 | +typedef int64_t vint_t; | ||
| 213 | +#else | ||
| 214 | +typedef int32_t vint_t; | ||
| 215 | +#endif | ||
| 216 | +typedef int64_t i64; | ||
| 217 | +typedef int16_t i16; | ||
| 218 | +typedef int8_t i8; | ||
| 219 | +typedef uint64_t u64; | ||
| 220 | +typedef uint32_t u32; | ||
| 221 | +typedef uint8_t u8; | ||
| 222 | +typedef uint16_t u16; | ||
| 223 | +typedef u8 byte; | ||
| 224 | +typedef int32_t i32; | ||
| 225 | +typedef uint32_t rune; | ||
| 226 | +typedef size_t usize; | ||
| 227 | +typedef ptrdiff_t isize; | ||
| 228 | +#ifndef VNOFLOAT | ||
| 229 | +typedef float f32; | ||
| 230 | +typedef double f64; | ||
| 231 | +#else | ||
| 232 | +typedef int32_t f32; | ||
| 233 | +typedef int64_t f64; | ||
| 234 | +#endif | ||
| 235 | +typedef int64_t int_literal; | ||
| 236 | +#ifndef VNOFLOAT | ||
| 237 | +typedef double float_literal; | ||
| 238 | +#else | ||
| 239 | +typedef int64_t float_literal; | ||
| 240 | +#endif | ||
| 241 | +typedef unsigned char* byteptr; | ||
| 242 | +typedef void* voidptr; | ||
| 243 | +typedef char* charptr; | ||
| 244 | +typedef u8 array_fixed_byte_300 [300]; | ||
| 245 | +typedef struct sync__Channel* chan; | ||
| 246 | +#ifndef CUSTOM_DEFINE_no_bool | ||
| 247 | + #ifndef __cplusplus | ||
| 248 | + #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 202311L | ||
| 249 | + #ifndef bool | ||
| 250 | + #ifdef CUSTOM_DEFINE_4bytebool | ||
| 251 | + typedef int bool; | ||
| 252 | + #else | ||
| 253 | + typedef u8 bool; | ||
| 254 | + #endif | ||
| 255 | + #define true 1 | ||
| 256 | + #define false 0 | ||
| 257 | + #endif | ||
| 258 | + #endif | ||
| 259 | + #endif | ||
| 260 | +#endif | ||
| 261 | + | ||
| 262 | + | ||
| 263 | +#define V_SAFE_SHIFT_BITS(type) ((u64)(sizeof(type) * 8)) | ||
| 264 | +#define V_SAFE_LSHIFT_UNSIGNED(name, type) static inline type name(type x, u64 y) { return y >= V_SAFE_SHIFT_BITS(type) ? (type)0 : (type)(x << y); } | ||
| 265 | +#define V_SAFE_LSHIFT_SIGNED(name, type, unsigned_type) static inline type name(type x, u64 y) { return y >= V_SAFE_SHIFT_BITS(type) ? (type)0 : (type)(((unsigned_type)x) << y); } | ||
| 266 | +#define V_SAFE_RSHIFT_UNSIGNED(name, type) static inline type name(type x, u64 y) { return y >= V_SAFE_SHIFT_BITS(type) ? (type)0 : (type)(x >> y); } | ||
| 267 | +#define V_SAFE_RSHIFT_SIGNED(name, type) static inline type name(type x, u64 y) { return y >= V_SAFE_SHIFT_BITS(type) ? (type)(x < 0 ? -1 : 0) : (type)(x >> y); } | ||
| 268 | +V_SAFE_LSHIFT_SIGNED(v__lshift_char, char, u8) | ||
| 269 | +V_SAFE_RSHIFT_SIGNED(v__rshift_char, char) | ||
| 270 | +V_SAFE_LSHIFT_SIGNED(v__lshift_i8, i8, u8) | ||
| 271 | +V_SAFE_RSHIFT_SIGNED(v__rshift_i8, i8) | ||
| 272 | +V_SAFE_LSHIFT_SIGNED(v__lshift_i16, i16, u16) | ||
| 273 | +V_SAFE_RSHIFT_SIGNED(v__rshift_i16, i16) | ||
| 274 | +V_SAFE_LSHIFT_SIGNED(v__lshift_i32, i32, u32) | ||
| 275 | +V_SAFE_RSHIFT_SIGNED(v__rshift_i32, i32) | ||
| 276 | +V_SAFE_LSHIFT_SIGNED(v__lshift_int, int, unsigned int) | ||
| 277 | +V_SAFE_RSHIFT_SIGNED(v__rshift_int, int) | ||
| 278 | +V_SAFE_LSHIFT_SIGNED(v__lshift_vint_t, vint_t, u64) | ||
| 279 | +V_SAFE_RSHIFT_SIGNED(v__rshift_vint_t, vint_t) | ||
| 280 | +V_SAFE_LSHIFT_SIGNED(v__lshift_i64, i64, u64) | ||
| 281 | +V_SAFE_RSHIFT_SIGNED(v__rshift_i64, i64) | ||
| 282 | +V_SAFE_LSHIFT_SIGNED(v__lshift_isize, isize, usize) | ||
| 283 | +V_SAFE_RSHIFT_SIGNED(v__rshift_isize, isize) | ||
| 284 | +V_SAFE_LSHIFT_UNSIGNED(v__lshift_u8, u8) | ||
| 285 | +V_SAFE_RSHIFT_UNSIGNED(v__rshift_u8, u8) | ||
| 286 | +V_SAFE_LSHIFT_UNSIGNED(v__lshift_u16, u16) | ||
| 287 | +V_SAFE_RSHIFT_UNSIGNED(v__rshift_u16, u16) | ||
| 288 | +V_SAFE_LSHIFT_UNSIGNED(v__lshift_u32, u32) | ||
| 289 | +V_SAFE_RSHIFT_UNSIGNED(v__rshift_u32, u32) | ||
| 290 | +V_SAFE_LSHIFT_UNSIGNED(v__lshift_u64, u64) | ||
| 291 | +V_SAFE_RSHIFT_UNSIGNED(v__rshift_u64, u64) | ||
| 292 | +V_SAFE_LSHIFT_UNSIGNED(v__lshift_usize, usize) | ||
| 293 | +V_SAFE_RSHIFT_UNSIGNED(v__rshift_usize, usize) | ||
| 294 | +V_SAFE_LSHIFT_UNSIGNED(v__lshift_rune, rune) | ||
| 295 | +V_SAFE_RSHIFT_UNSIGNED(v__rshift_rune, rune) | ||
| 296 | +V_SAFE_LSHIFT_SIGNED(v__lshift_int_literal, int_literal, u64) | ||
| 297 | +V_SAFE_RSHIFT_SIGNED(v__rshift_int_literal, int_literal) | ||
| 298 | +#undef V_SAFE_RSHIFT_SIGNED | ||
| 299 | +#undef V_SAFE_RSHIFT_UNSIGNED | ||
| 300 | +#undef V_SAFE_LSHIFT_SIGNED | ||
| 301 | +#undef V_SAFE_LSHIFT_UNSIGNED | ||
| 302 | +#undef V_SAFE_SHIFT_BITS | ||
| 303 | + | ||
| 304 | + | ||
| 305 | +typedef u64 (*MapHashFn)(voidptr); | ||
| 306 | +typedef bool (*MapEqFn)(voidptr, voidptr); | ||
| 307 | +typedef void (*MapCloneFn)(voidptr, voidptr); | ||
| 308 | +typedef void (*MapFreeFn)(voidptr); | ||
| 309 | + | ||
| 310 | +//============================== HELPER C MACROS =============================*/ | ||
| 311 | +// _SLIT0 is used as NULL string for literal arguments | ||
| 312 | +// `"" s` is used to enforce a string literal argument | ||
| 313 | +#define _SLIT0 (string){.str=(byteptr)(""), .len=0, .is_lit=1} | ||
| 314 | +#define _S(s) ((string){.str=(byteptr)("" s), .len=(sizeof(s)-1), .is_lit=1}) | ||
| 315 | +#define _SLEN(s, n) ((string){.str=(byteptr)("" s), .len=n, .is_lit=1}) | ||
| 316 | +// optimized way to compare literal strings | ||
| 317 | +#define _SLIT_EQ(sptr, slen, lit) (slen == sizeof("" lit)-1 && !builtin__vmemcmp(sptr, "" lit, slen)) | ||
| 318 | +#define _SLIT_NE(sptr, slen, lit) (slen != sizeof("" lit)-1 || builtin__vmemcmp(sptr, "" lit, slen)) | ||
| 319 | +// take the address of an rvalue | ||
| 320 | +#define ADDR(type, expr) (&((type[]){expr}[0])) | ||
| 321 | +// copy something to the heap | ||
| 322 | +#define HEAP(type, expr) ((type*)builtin__memdup((void*)&((type[]){expr}[0]), sizeof(type))) | ||
| 323 | +#define HEAP_noscan(type, expr) ((type*)builtin__memdup_noscan((void*)&((type[]){expr}[0]), sizeof(type))) | ||
| 324 | +#define HEAP_align(type, expr, align) ((type*)builtin__memdup_align((void*)&((type[]){expr}[0]), sizeof(type), align)) | ||
| 325 | +#define HEAP_vgc(type, expr, ptrmap, nptrs) ((type*)builtin__vgc_memdup_typed((void*)&((type[]){expr}[0]), sizeof(type), (ptrmap), (nptrs))) | ||
| 326 | +#define _PUSH_MANY(arr, val, tmp, tmp_typ) {tmp_typ tmp = (val); builtin__array_push_many(arr, tmp.data, tmp.len);} | ||
| 327 | +#define _PUSH_MANY_noscan(arr, val, tmp, tmp_typ) {tmp_typ tmp = (val); builtin__array_push_many_noscan(arr, tmp.data, tmp.len);} | ||
| 328 | + | ||
| 329 | +#define E_STRUCT_DECL | ||
| 330 | +#define E_STRUCT | ||
| 331 | +#define __NOINLINE __attribute__((noinline)) | ||
| 332 | +#define __IRQHANDLER __attribute__((interrupt)) | ||
| 333 | +#define __V_architecture 0 | ||
| 334 | +#if defined(__x86_64__) || defined(_M_AMD64) | ||
| 335 | + #define __V_amd64 1 | ||
| 336 | + #undef __V_architecture | ||
| 337 | + #define __V_architecture 1 | ||
| 338 | +#endif | ||
| 339 | +#if defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64) | ||
| 340 | + #define __V_arm64 1 | ||
| 341 | + #undef __V_architecture | ||
| 342 | + #define __V_architecture 2 | ||
| 343 | +#endif | ||
| 344 | +#if defined(__arm__) || defined(_M_ARM) | ||
| 345 | + #define __V_arm32 1 | ||
| 346 | + #undef __V_architecture | ||
| 347 | + #define __V_architecture 3 | ||
| 348 | +#endif | ||
| 349 | +#if defined(__riscv) && __riscv_xlen == 64 | ||
| 350 | + #define __V_rv64 1 | ||
| 351 | + #undef __V_architecture | ||
| 352 | + #define __V_architecture 4 | ||
| 353 | +#endif | ||
| 354 | +#if defined(__riscv) && __riscv_xlen == 32 | ||
| 355 | + #define __V_rv32 1 | ||
| 356 | + #undef __V_architecture | ||
| 357 | + #define __V_architecture 5 | ||
| 358 | +#endif | ||
| 359 | +#if defined(__i386__) || defined(_M_IX86) | ||
| 360 | + #define __V_x86 1 | ||
| 361 | + #undef __V_architecture | ||
| 362 | + #define __V_architecture 6 | ||
| 363 | +#endif | ||
| 364 | +#if defined(__s390x__) | ||
| 365 | + #define __V_s390x 1 | ||
| 366 | + #undef __V_architecture | ||
| 367 | + #define __V_architecture 7 | ||
| 368 | +#endif | ||
| 369 | +#if defined(__powerpc64__) && defined(__LITTLE_ENDIAN__) | ||
| 370 | + #define __V_ppc64le 1 | ||
| 371 | + #undef __V_architecture | ||
| 372 | + #define __V_architecture 8 | ||
| 373 | +#endif | ||
| 374 | +#if defined(__loongarch64) | ||
| 375 | + #define __V_loongarch64 1 | ||
| 376 | + #undef __V_architecture | ||
| 377 | + #define __V_architecture 9 | ||
| 378 | +#endif | ||
| 379 | +#if defined(__sparc__) | ||
| 380 | + #define __V_sparc64 1 | ||
| 381 | + #undef __V_architecture | ||
| 382 | + #define __V_architecture 10 | ||
| 383 | +#endif | ||
| 384 | +#if defined(__powerpc64__) && defined(__BIG_ENDIAN__) | ||
| 385 | + #define __V_ppc64 1 | ||
| 386 | + #undef __V_architecture | ||
| 387 | + #define __V_architecture 11 | ||
| 388 | +#endif | ||
| 389 | +#if (defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) || defined(__ppc__) || defined(__ppc) || defined(__PPC__)) && !defined(__powerpc64__) && !defined(__ppc64__) && !defined(__PPC64__) | ||
| 390 | + #define __V_ppc 1 | ||
| 391 | + #undef __V_architecture | ||
| 392 | + #define __V_architecture 12 | ||
| 393 | +#endif | ||
| 394 | +// Using just __GNUC__ for detecting gcc, is not reliable because other compilers define it too: | ||
| 395 | +#ifdef __GNUC__ | ||
| 396 | + #define __V_GCC__ | ||
| 397 | +#endif | ||
| 398 | +#ifdef __TINYC__ | ||
| 399 | + #undef __V_GCC__ | ||
| 400 | +#endif | ||
| 401 | +#ifdef __cplusplus | ||
| 402 | + #undef __V_GCC__ | ||
| 403 | +#endif | ||
| 404 | +#ifdef __clang__ | ||
| 405 | + #undef __V_GCC__ | ||
| 406 | +#endif | ||
| 407 | +#ifdef _MSC_VER | ||
| 408 | + #undef __V_GCC__ | ||
| 409 | + #undef E_STRUCT_DECL | ||
| 410 | + #undef E_STRUCT | ||
| 411 | + #define E_STRUCT_DECL unsigned char _dummy_pad | ||
| 412 | + #define E_STRUCT 0 | ||
| 413 | +#endif | ||
| 414 | +#if defined(__has_include) && !defined(__TINYC__) | ||
| 415 | + #if __has_include(<execinfo.h>) && !defined(_WIN32) | ||
| 416 | + #define __V_HAVE_EXECINFO_H 1 | ||
| 417 | + #include <execinfo.h> | ||
| 418 | + #else | ||
| 419 | + // On linux: int backtrace(void **__array, int __size); | ||
| 420 | + // On BSD: size_t backtrace(void **, size_t); | ||
| 421 | + #endif | ||
| 422 | +#elif (defined(__linux__) && (defined(__GLIBC__) || defined(__GNU_LIBRARY__))) || defined(__APPLE__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) | ||
| 423 | + #define __V_HAVE_EXECINFO_H 1 | ||
| 424 | + #include <execinfo.h> | ||
| 425 | +#else | ||
| 426 | + // On linux: int backtrace(void **__array, int __size); | ||
| 427 | + // On BSD: size_t backtrace(void **, size_t); | ||
| 428 | +#endif | ||
| 429 | +#ifndef __V_HAVE_EXECINFO_H | ||
| 430 | + #ifdef __cplusplus | ||
| 431 | + extern "C" { | ||
| 432 | + #endif | ||
| 433 | + int backtrace(void **__array, int __size); | ||
| 434 | + char **backtrace_symbols(void *const *__array, int __size); | ||
| 435 | + void backtrace_symbols_fd(void *const *__array, int __size, int __fd); | ||
| 436 | + #ifdef __cplusplus | ||
| 437 | + } | ||
| 438 | + #endif | ||
| 439 | +#endif | ||
| 440 | +#ifdef __TINYC__ | ||
| 441 | + #define _Atomic volatile | ||
| 442 | + #undef E_STRUCT_DECL | ||
| 443 | + #undef E_STRUCT | ||
| 444 | + #define E_STRUCT_DECL unsigned char _dummy_pad | ||
| 445 | + #define E_STRUCT 0 | ||
| 446 | + #undef __NOINLINE | ||
| 447 | + #undef __IRQHANDLER | ||
| 448 | + // tcc does not support inlining at all | ||
| 449 | + #define __NOINLINE | ||
| 450 | + #define __IRQHANDLER | ||
| 451 | + // #include <byteswap.h> | ||
| 452 | + int tcc_backtrace(const char *fmt, ...); | ||
| 453 | +#endif | ||
| 454 | +// Use __offsetof_ptr instead of __offset_of, when you *do* have a valid pointer, to avoid UB: | ||
| 455 | +#ifndef __offsetof_ptr | ||
| 456 | + #define __offsetof_ptr(ptr,PTYPE,FIELDNAME) ((size_t)((byte *)&((PTYPE *)ptr)->FIELDNAME - (byte *)ptr)) | ||
| 457 | +#endif | ||
| 458 | +// for __offset_of | ||
| 459 | +#ifndef __offsetof | ||
| 460 | +#if defined(__TINYC__) || defined(_MSC_VER) | ||
| 461 | + #define __offsetof(PTYPE,FIELDNAME) ((size_t)(&((PTYPE *)0)->FIELDNAME)) | ||
| 462 | +#else | ||
| 463 | + #define __offsetof(st, m) __builtin_offsetof(st, m) | ||
| 464 | +#endif | ||
| 465 | +#endif | ||
| 466 | +#if defined(_WIN32) || defined(__CYGWIN__) | ||
| 467 | + #define VV_EXP extern __declspec(dllexport) | ||
| 468 | + #ifdef _VPARALLELCC | ||
| 469 | + #define VV_LOC | ||
| 470 | + #else | ||
| 471 | + #define VV_LOC static | ||
| 472 | + #endif | ||
| 473 | +#else | ||
| 474 | + // 4 < gcc < 5 is used by some older Ubuntu LTS and Centos versions, | ||
| 475 | + // and does not support __has_attribute(visibility) ... | ||
| 476 | + #ifndef __has_attribute | ||
| 477 | + #define __has_attribute(x) 0 // Compatibility with non-clang compilers. | ||
| 478 | + #endif | ||
| 479 | + #if (defined(__GNUC__) && (__GNUC__ >= 4)) || (defined(__clang__) && __has_attribute(visibility)) | ||
| 480 | + #ifdef ARM | ||
| 481 | + #define VV_EXP extern __attribute__((externally_visible,visibility("default"))) | ||
| 482 | + #else | ||
| 483 | + #define VV_EXP extern __attribute__((visibility("default"))) | ||
| 484 | + #endif | ||
| 485 | + #if defined(_VOBJECTFILE) || (defined(__clang__) && (defined(_VUSECACHE) || defined(_VBUILDMODULE))) | ||
| 486 | + #define VV_LOC static | ||
| 487 | + #else | ||
| 488 | + #define VV_LOC __attribute__ ((visibility ("hidden"))) | ||
| 489 | + #endif | ||
| 490 | + #else | ||
| 491 | + #define VV_EXP extern | ||
| 492 | + #ifdef _VPARALLELCC | ||
| 493 | + #define VV_LOC | ||
| 494 | + #else | ||
| 495 | + #define VV_LOC static | ||
| 496 | + #endif | ||
| 497 | + #endif | ||
| 498 | +#endif | ||
| 499 | +#ifdef __cplusplus | ||
| 500 | + #include <utility> | ||
| 501 | + #define _MOV std::move | ||
| 502 | +#else | ||
| 503 | + #define _MOV | ||
| 504 | +#endif | ||
| 505 | +#if defined(__TINYC__) && defined(__has_include) // tcc does not support has_include properly yet, turn it off completely | ||
| 506 | +#undef __has_include | ||
| 507 | +#endif | ||
| 508 | +//likely and unlikely macros | ||
| 509 | +#if defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__clang__) | ||
| 510 | + #define _likely_(x) __builtin_expect(x,1) | ||
| 511 | + #define _unlikely_(x) __builtin_expect(x,0) | ||
| 512 | +#else | ||
| 513 | + #define _likely_(x) (x) | ||
| 514 | + #define _unlikely_(x) (x) | ||
| 515 | +#endif | ||
| 516 | + | ||
| 517 | +#if !defined(VCALLCONV) | ||
| 518 | + #ifdef _MSC_VER | ||
| 519 | + #define VCALLCONV(name) __##name | ||
| 520 | + #else | ||
| 521 | + #define VCALLCONV(name) __attribute__((name)) | ||
| 522 | + #endif | ||
| 523 | +#endif | ||
| 524 | + | ||
| 525 | +// c_headers | ||
| 526 | +typedef int (*qsort_callback_func)(const void*, const void*); | ||
| 527 | +#if defined(_MSC_VER) && !defined(__clang__) | ||
| 528 | + #define V_CRT_LINKAGE __declspec(dllimport) | ||
| 529 | + #define V_CRT_CALL VCALLCONV(cdecl) | ||
| 530 | +#else | ||
| 531 | + #define V_CRT_LINKAGE | ||
| 532 | + #define V_CRT_CALL | ||
| 533 | +#endif | ||
| 534 | +#if (defined(_MSC_VER) && !defined(__clang__)) || defined(__cplusplus) | ||
| 535 | +// Under C++ (g++/clang++), let libc declare FILE/stdio/string/stdlib to keep | ||
| 536 | +// noexcept specifiers consistent — the manual extern "C" prototypes below | ||
| 537 | +// would otherwise conflict with system headers under -std=c++NN. | ||
| 538 | +#include <stdarg.h> | ||
| 539 | +#include <stdio.h> | ||
| 540 | +#include <stdlib.h> | ||
| 541 | +#include <string.h> | ||
| 542 | +#ifndef va_copy | ||
| 543 | + #define va_copy(dest, src) ((dest) = (src)) | ||
| 544 | +#endif | ||
| 545 | +#ifndef _TRUNCATE | ||
| 546 | + #define _TRUNCATE ((size_t)-1) | ||
| 547 | +#endif | ||
| 548 | +#elif defined(__NetBSD__) | ||
| 549 | +// NetBSD exposes stdin/stdout/stderr as macros into a single `__sF[3]` | ||
| 550 | +// array whose element size (sizeof(FILE)) depends on the platform and libc | ||
| 551 | +// version, so we cannot forward-declare them. The FreeBSD-style | ||
| 552 | +// `__stdinp/__stdoutp/__stderrp` symbols also do not exist on NetBSD (see | ||
| 553 | +// vlang/v#27190). Defer to the system headers for FILE, the stdio streams, | ||
| 554 | +// and the libc prototypes that would otherwise clash with the | ||
| 555 | +// `__restrict`-qualified declarations in NetBSD libc. | ||
| 556 | +#include <stdarg.h> | ||
| 557 | +#include <stdio.h> | ||
| 558 | +#include <stdlib.h> | ||
| 559 | +#include <string.h> | ||
| 560 | +#elif defined(__TINYC__) && (defined(__FreeBSD__) || defined(__OpenBSD__)) | ||
| 561 | +// TinyCC reports a hard redefinition error if system OpenSSL pulls in | ||
| 562 | +// <stdarg.h> after V has provided its own va_start macro. Include it first, | ||
| 563 | +// but keep V manual FILE declarations on these BSD libc variants. | ||
| 564 | +#include <stdarg.h> | ||
| 565 | +#if defined(__FreeBSD__) | ||
| 566 | +typedef struct __sFILE FILE; | ||
| 567 | +extern FILE* __stdinp; | ||
| 568 | +extern FILE* __stdoutp; | ||
| 569 | +extern FILE* __stderrp; | ||
| 570 | +#define stdin __stdinp | ||
| 571 | +#define stdout __stdoutp | ||
| 572 | +#define stderr __stderrp | ||
| 573 | +#else | ||
| 574 | +typedef struct __sFILE FILE; | ||
| 575 | +#ifndef _STDFILES_DECLARED | ||
| 576 | + #define _STDFILES_DECLARED | ||
| 577 | +struct __sFstub { long _stub; }; | ||
| 578 | +extern struct __sFstub __stdin[]; | ||
| 579 | +extern struct __sFstub __stdout[]; | ||
| 580 | +extern struct __sFstub __stderr[]; | ||
| 581 | +#endif | ||
| 582 | +#define stdin ((struct __sFILE *)__stdin) | ||
| 583 | +#define stdout ((struct __sFILE *)__stdout) | ||
| 584 | +#define stderr ((struct __sFILE *)__stderr) | ||
| 585 | +#endif | ||
| 586 | +#elif (defined(__MINGW32__) || defined(__MINGW64__)) && defined(__V_GCC__) | ||
| 587 | +// mingw-w64 stdio.h provides fprintf/vfprintf as static inline overrides | ||
| 588 | +// when __USE_MINGW_ANSI_STDIO is enabled, so use the system declarations | ||
| 589 | +// instead of the manual formatted-stdio prototypes below. | ||
| 590 | +#include <stdarg.h> | ||
| 591 | +#include <stdio.h> | ||
| 592 | +#elif defined(__MINGW32__) || defined(__MINGW64__) || (defined(__clang__) && (defined(_WIN32) || defined(_WIN64))) | ||
| 593 | +typedef struct _iobuf FILE; | ||
| 594 | +FILE* __cdecl __acrt_iob_func(unsigned index); | ||
| 595 | +#define stdin (__acrt_iob_func(0)) | ||
| 596 | +#define stdout (__acrt_iob_func(1)) | ||
| 597 | +#define stderr (__acrt_iob_func(2)) | ||
| 598 | +#elif defined(__TINYC__) && (defined(_WIN32) || defined(_WIN64)) | ||
| 599 | +#ifndef _FILE_DEFINED | ||
| 600 | +struct _iobuf { | ||
| 601 | + char *_ptr; | ||
| 602 | + int _cnt; | ||
| 603 | + char *_base; | ||
| 604 | + int _flag; | ||
| 605 | + int _file; | ||
| 606 | + int _charbuf; | ||
| 607 | + int _bufsiz; | ||
| 608 | + char *_tmpfname; | ||
| 609 | +}; | ||
| 610 | +typedef struct _iobuf FILE; | ||
| 611 | +#define _FILE_DEFINED | ||
| 612 | +#endif | ||
| 613 | + #if defined(_WIN64) | ||
| 614 | +FILE* __cdecl __iob_func(void); | ||
| 615 | + #else | ||
| 616 | + #ifdef _MSVCRT_ | ||
| 617 | +extern FILE _iob[]; | ||
| 618 | + #define __iob_func() (_iob) | ||
| 619 | + #else | ||
| 620 | +extern FILE (*_imp___iob)[]; | ||
| 621 | + #define __iob_func() (*_imp___iob) | ||
| 622 | + #define _iob __iob_func() | ||
| 623 | + #endif | ||
| 624 | + #endif | ||
| 625 | +#define stdin (&__iob_func()[0]) | ||
| 626 | +#define stdout (&__iob_func()[1]) | ||
| 627 | +#define stderr (&__iob_func()[2]) | ||
| 628 | +#elif defined(__vinix__) | ||
| 629 | +typedef struct __file FILE; | ||
| 630 | +extern FILE* stdin; | ||
| 631 | +extern FILE* stdout; | ||
| 632 | +extern FILE* stderr; | ||
| 633 | +struct __thread_data; | ||
| 634 | +struct __threadattr; | ||
| 635 | +// pthread_t handling for vinix builds: | ||
| 636 | +// - Vinix kernel (freestanding, __STDC_HOSTED__=0): no libc, define | ||
| 637 | +// pthread_t ourselves so V code that references it compiles. | ||
| 638 | +// - util-vinix cross-compiled on a libc-providing host (hosted, e.g. | ||
| 639 | +// glibc on Linux or macOS with -D__vinix__): pull pthread_t from | ||
| 640 | +// libc to avoid colliding with the libc typedef. | ||
| 641 | +#if defined(__STDC_HOSTED__) && __STDC_HOSTED__ && defined(__has_include) && __has_include(<pthread.h>) | ||
| 642 | +#include <pthread.h> | ||
| 643 | +#else | ||
| 644 | +typedef struct __thread_data *pthread_t; | ||
| 645 | +#endif | ||
| 646 | +typedef __builtin_va_list va_list; | ||
| 647 | +#ifndef va_start | ||
| 648 | + #define va_start(ap, v) __builtin_va_start(ap, v) | ||
| 649 | +#endif | ||
| 650 | +#ifndef va_arg | ||
| 651 | + #define va_arg(ap, t) __builtin_va_arg(ap, t) | ||
| 652 | +#endif | ||
| 653 | +#ifndef va_end | ||
| 654 | + #define va_end(ap) __builtin_va_end(ap) | ||
| 655 | +#endif | ||
| 656 | +#ifndef va_copy | ||
| 657 | + #define va_copy(dest, src) __builtin_va_copy(dest, src) | ||
| 658 | +#endif | ||
| 659 | +#else | ||
| 660 | + #if defined(__APPLE__) || defined(__FreeBSD__) | ||
| 661 | +typedef struct __sFILE FILE; | ||
| 662 | +extern FILE* __stdinp; | ||
| 663 | +extern FILE* __stdoutp; | ||
| 664 | +extern FILE* __stderrp; | ||
| 665 | +#define stdin __stdinp | ||
| 666 | +#define stdout __stdoutp | ||
| 667 | +#define stderr __stderrp | ||
| 668 | + #elif defined(__DragonFly__) | ||
| 669 | +typedef struct __sFILE FILE; | ||
| 670 | +extern FILE* __stdinp; | ||
| 671 | +extern FILE* __stdoutp; | ||
| 672 | +extern FILE* __stderrp; | ||
| 673 | +#define stdin __stdinp | ||
| 674 | +#define stdout __stdoutp | ||
| 675 | +#define stderr __stderrp | ||
| 676 | + #elif defined(__OpenBSD__) | ||
| 677 | +typedef struct __sFILE FILE; | ||
| 678 | +#ifndef _STDFILES_DECLARED | ||
| 679 | + #define _STDFILES_DECLARED | ||
| 680 | +struct __sFstub { long _stub; }; | ||
| 681 | +extern struct __sFstub __stdin[]; | ||
| 682 | +extern struct __sFstub __stdout[]; | ||
| 683 | +extern struct __sFstub __stderr[]; | ||
| 684 | +#endif | ||
| 685 | +#define stdin ((struct __sFILE *)__stdin) | ||
| 686 | +#define stdout ((struct __sFILE *)__stdout) | ||
| 687 | +#define stderr ((struct __sFILE *)__stderr) | ||
| 688 | + #elif defined(__BIONIC__) | ||
| 689 | +struct __sFILE; | ||
| 690 | +typedef struct __sFILE FILE; | ||
| 691 | +extern FILE* stdin; | ||
| 692 | +extern FILE* stdout; | ||
| 693 | +extern FILE* stderr; | ||
| 694 | + #elif defined(__linux__) && !defined(__GLIBC__) && !defined(__GNU_LIBRARY__) && !defined(__BIONIC__) && !defined(__UCLIBC__) | ||
| 695 | +typedef struct _IO_FILE FILE; | ||
| 696 | +// musl exposes the stdio streams as `FILE *const`, so match that to stay | ||
| 697 | +// compatible with later <stdio.h> includes from headers like miniz.h. | ||
| 698 | +extern FILE* const stdin; | ||
| 699 | +extern FILE* const stdout; | ||
| 700 | +extern FILE* const stderr; | ||
| 701 | + #else | ||
| 702 | +typedef struct _IO_FILE FILE; | ||
| 703 | +extern FILE* stdin; | ||
| 704 | +extern FILE* stdout; | ||
| 705 | +extern FILE* stderr; | ||
| 706 | + #endif | ||
| 707 | +typedef __builtin_va_list va_list; | ||
| 708 | +#ifndef va_start | ||
| 709 | + #define va_start(ap, v) __builtin_va_start(ap, v) | ||
| 710 | +#endif | ||
| 711 | +#ifndef va_arg | ||
| 712 | + #define va_arg(ap, t) __builtin_va_arg(ap, t) | ||
| 713 | +#endif | ||
| 714 | +#ifndef va_end | ||
| 715 | + #define va_end(ap) __builtin_va_end(ap) | ||
| 716 | +#endif | ||
| 717 | +#ifndef va_copy | ||
| 718 | + #define va_copy(dest, src) __builtin_va_copy(dest, src) | ||
| 719 | +#endif | ||
| 720 | +#endif | ||
| 721 | +#if (!defined(_MSC_VER) || defined(__clang__)) && !defined(__cplusplus) && !defined(__NetBSD__) | ||
| 722 | +// mingw-w64 stdio.h declares these as static __mingw_ovr inline overrides | ||
| 723 | +// when __USE_MINGW_ANSI_STDIO is on. Skip them under gcc+mingw to avoid | ||
| 724 | +// static-after-extern conflicts; clang+mingw needs them because it builds | ||
| 725 | +// with -Werror=implicit-function-declaration and does not hit the conflict. | ||
| 726 | +// NetBSD pulls these prototypes from <stdio.h>/<stdlib.h>/<string.h> via | ||
| 727 | +// the include block above to avoid `__restrict` qualifier conflicts. | ||
| 728 | +#if !((defined(__MINGW32__) || defined(__MINGW64__)) && !defined(__clang__)) | ||
| 729 | +V_CRT_LINKAGE int V_CRT_CALL vfprintf(FILE *stream, const char *format, va_list ap); | ||
| 730 | +V_CRT_LINKAGE int V_CRT_CALL vsnprintf(char *str, size_t size, const char *format, va_list ap); | ||
| 731 | +V_CRT_LINKAGE int V_CRT_CALL fprintf(FILE *stream, const char *format, ...); | ||
| 732 | +V_CRT_LINKAGE int V_CRT_CALL printf(const char *format, ...); | ||
| 733 | +V_CRT_LINKAGE int V_CRT_CALL snprintf(char *str, size_t size, const char *format, ...); | ||
| 734 | +V_CRT_LINKAGE int V_CRT_CALL sprintf(char *str, const char *format, ...); | ||
| 735 | +V_CRT_LINKAGE int V_CRT_CALL sscanf(const char *str, const char *format, ...); | ||
| 736 | +V_CRT_LINKAGE int V_CRT_CALL scanf(const char *format, ...); | ||
| 737 | +#endif | ||
| 738 | +V_CRT_LINKAGE int V_CRT_CALL puts(const char *str); | ||
| 739 | +V_CRT_LINKAGE void V_CRT_CALL perror(const char *str); | ||
| 740 | +V_CRT_LINKAGE int V_CRT_CALL fputs(const char *str, FILE *stream); | ||
| 741 | +V_CRT_LINKAGE int V_CRT_CALL getchar(void); | ||
| 742 | +V_CRT_LINKAGE int V_CRT_CALL putchar(int ch); | ||
| 743 | +V_CRT_LINKAGE int V_CRT_CALL getc(FILE *stream); | ||
| 744 | +V_CRT_LINKAGE int V_CRT_CALL fgetc(FILE *stream); | ||
| 745 | +V_CRT_LINKAGE int V_CRT_CALL ungetc(int ch, FILE *stream); | ||
| 746 | +V_CRT_LINKAGE int V_CRT_CALL fflush(FILE *stream); | ||
| 747 | +V_CRT_LINKAGE int V_CRT_CALL feof(FILE *stream); | ||
| 748 | +V_CRT_LINKAGE int V_CRT_CALL ferror(FILE *stream); | ||
| 749 | +V_CRT_LINKAGE void V_CRT_CALL clearerr(FILE *stream); | ||
| 750 | +V_CRT_LINKAGE int V_CRT_CALL setvbuf(FILE *stream, char *buf, int mode, size_t size); | ||
| 751 | +V_CRT_LINKAGE long V_CRT_CALL ftell(FILE *stream); | ||
| 752 | +V_CRT_LINKAGE void V_CRT_CALL rewind(FILE *stream); | ||
| 753 | +V_CRT_LINKAGE FILE * V_CRT_CALL fopen(const char *filename, const char *mode); | ||
| 754 | +V_CRT_LINKAGE FILE * V_CRT_CALL fdopen(int fd, const char *mode); | ||
| 755 | +V_CRT_LINKAGE FILE * V_CRT_CALL freopen(const char *filename, const char *mode, FILE *stream); | ||
| 756 | +V_CRT_LINKAGE int V_CRT_CALL fileno(FILE *stream); | ||
| 757 | +V_CRT_LINKAGE size_t V_CRT_CALL fread(void *ptr, size_t size, size_t items, FILE *stream); | ||
| 758 | +V_CRT_LINKAGE size_t V_CRT_CALL fwrite(const void *ptr, size_t size, size_t items, FILE *stream); | ||
| 759 | +#if defined(__vinix__) | ||
| 760 | +V_CRT_LINKAGE char * V_CRT_CALL fgets(char *str, size_t size, FILE *stream); | ||
| 761 | +#else | ||
| 762 | +V_CRT_LINKAGE char * V_CRT_CALL fgets(char *str, int size, FILE *stream); | ||
| 763 | +#endif | ||
| 764 | +V_CRT_LINKAGE int V_CRT_CALL fclose(FILE *stream); | ||
| 765 | +#if defined(__vinix__) | ||
| 766 | +V_CRT_LINKAGE FILE * V_CRT_CALL popen(char *command, char *mode); | ||
| 767 | +#else | ||
| 768 | +V_CRT_LINKAGE FILE * V_CRT_CALL popen(const char *command, const char *mode); | ||
| 769 | +#endif | ||
| 770 | +V_CRT_LINKAGE int V_CRT_CALL pclose(FILE *stream); | ||
| 771 | +V_CRT_LINKAGE void * V_CRT_CALL malloc(size_t size); | ||
| 772 | +V_CRT_LINKAGE void * V_CRT_CALL calloc(size_t nitems, size_t size); | ||
| 773 | +V_CRT_LINKAGE void * V_CRT_CALL realloc(void *ptr, size_t size); | ||
| 774 | +V_CRT_LINKAGE void * V_CRT_CALL aligned_alloc(size_t alignment, size_t size); | ||
| 775 | +V_CRT_LINKAGE int V_CRT_CALL posix_memalign(void **memptr, size_t alignment, size_t size); | ||
| 776 | +V_CRT_LINKAGE void V_CRT_CALL free(void *ptr); | ||
| 777 | +V_CRT_LINKAGE int V_CRT_CALL rand(void); | ||
| 778 | +V_CRT_LINKAGE void V_CRT_CALL srand(unsigned int seed); | ||
| 779 | +V_CRT_LINKAGE int V_CRT_CALL atexit(void (*cb)(void)); | ||
| 780 | +V_CRT_LINKAGE void V_CRT_CALL exit(int status); | ||
| 781 | +V_CRT_LINKAGE int V_CRT_CALL abs(int n); | ||
| 782 | +V_CRT_LINKAGE int V_CRT_CALL atoi(const char *str); | ||
| 783 | +V_CRT_LINKAGE double V_CRT_CALL atof(const char *str); | ||
| 784 | +V_CRT_LINKAGE char * V_CRT_CALL getenv(const char *name); | ||
| 785 | +V_CRT_LINKAGE int V_CRT_CALL setenv(const char *name, const char *value, int overwrite); | ||
| 786 | +V_CRT_LINKAGE int V_CRT_CALL unsetenv(const char *name); | ||
| 787 | +V_CRT_LINKAGE int V_CRT_CALL system(const char *command); | ||
| 788 | +V_CRT_LINKAGE int V_CRT_CALL remove(const char *path); | ||
| 789 | +V_CRT_LINKAGE int V_CRT_CALL rename(const char *old_path, const char *new_path); | ||
| 790 | +V_CRT_LINKAGE char * V_CRT_CALL realpath(const char *path, char *resolved_path); | ||
| 791 | +V_CRT_LINKAGE int V_CRT_CALL mkstemp(char *stemplate); | ||
| 792 | +V_CRT_LINKAGE void V_CRT_CALL qsort(void *base, size_t items, size_t item_size, qsort_callback_func cb); | ||
| 793 | +#if defined(__vinix__) | ||
| 794 | +V_CRT_LINKAGE int V_CRT_CALL strcmp(char *left, char *right); | ||
| 795 | +V_CRT_LINKAGE int V_CRT_CALL strncmp(char *left, char *right, size_t n); | ||
| 796 | +#else | ||
| 797 | +V_CRT_LINKAGE int V_CRT_CALL strcmp(const char *left, const char *right); | ||
| 798 | +V_CRT_LINKAGE int V_CRT_CALL strncmp(const char *left, const char *right, size_t n); | ||
| 799 | +#endif | ||
| 800 | +#if !defined(_WIN32) && !defined(_WIN64) && !defined(__BIONIC__) | ||
| 801 | +V_CRT_LINKAGE char * V_CRT_CALL strdup(const char *str); | ||
| 802 | +#endif | ||
| 803 | +#if !defined(_WIN32) && !defined(_WIN64) | ||
| 804 | +V_CRT_LINKAGE int V_CRT_CALL strcasecmp(const char *left, const char *right); | ||
| 805 | +V_CRT_LINKAGE int V_CRT_CALL strncasecmp(const char *left, const char *right, size_t n); | ||
| 806 | +#endif | ||
| 807 | +#if defined(__vinix__) | ||
| 808 | +V_CRT_LINKAGE size_t V_CRT_CALL strlen(char *str); | ||
| 809 | +#else | ||
| 810 | +V_CRT_LINKAGE size_t V_CRT_CALL strlen(const char *str); | ||
| 811 | +#endif | ||
| 812 | +V_CRT_LINKAGE char * V_CRT_CALL strerror(int errnum); | ||
| 813 | +V_CRT_LINKAGE void * V_CRT_CALL memcpy(void *dest, const void *src, size_t n); | ||
| 814 | +V_CRT_LINKAGE void * V_CRT_CALL memmove(void *dest, const void *src, size_t n); | ||
| 815 | +V_CRT_LINKAGE void * V_CRT_CALL memset(void *dest, int ch, size_t n); | ||
| 816 | +V_CRT_LINKAGE int V_CRT_CALL memcmp(const void *left, const void *right, size_t n); | ||
| 817 | +V_CRT_LINKAGE void * V_CRT_CALL memchr(const void *str, int c, size_t n); | ||
| 818 | +V_CRT_LINKAGE char * V_CRT_CALL strchr(const char *str, int c); | ||
| 819 | +V_CRT_LINKAGE char * V_CRT_CALL strrchr(const char *str, int c); | ||
| 820 | +V_CRT_LINKAGE char * V_CRT_CALL strstr(const char *haystack, const char *needle); | ||
| 821 | +V_CRT_LINKAGE int V_CRT_CALL fseek(FILE *stream, long offset, int whence); | ||
| 822 | +V_CRT_LINKAGE isize V_CRT_CALL getline(char **lineptr, size_t *n, FILE *stream); | ||
| 823 | +#if defined(_WIN32) || defined(_WIN64) | ||
| 824 | +V_CRT_LINKAGE int V_CRT_CALL _fileno(FILE *stream); | ||
| 825 | +V_CRT_LINKAGE FILE * V_CRT_CALL _wfopen(const unsigned short *filename, const unsigned short *mode); | ||
| 826 | +V_CRT_LINKAGE int V_CRT_CALL _wremove(const unsigned short *path); | ||
| 827 | +V_CRT_LINKAGE void * V_CRT_CALL _aligned_malloc(size_t size, size_t alignment); | ||
| 828 | +V_CRT_LINKAGE void * V_CRT_CALL _aligned_realloc(void *memory, size_t size, size_t alignment); | ||
| 829 | +V_CRT_LINKAGE void V_CRT_CALL _aligned_free(void *memory); | ||
| 830 | +V_CRT_LINKAGE unsigned short * V_CRT_CALL _wgetenv(const unsigned short *varname); | ||
| 831 | +V_CRT_LINKAGE int V_CRT_CALL _wputenv(const unsigned short *envstring); | ||
| 832 | +#endif | ||
| 833 | +#if defined(_MSC_VER) && !defined(__clang__) | ||
| 834 | +#ifndef _TRUNCATE | ||
| 835 | + #define _TRUNCATE ((size_t)-1) | ||
| 836 | +#endif | ||
| 837 | +V_CRT_LINKAGE int V_CRT_CALL _vscprintf(const char *format, va_list ap); | ||
| 838 | +V_CRT_LINKAGE int V_CRT_CALL _vsnprintf_s(char *buffer, size_t size, size_t count, const char *format, va_list ap); | ||
| 839 | +#endif | ||
| 840 | +#endif | ||
| 841 | +#ifndef _IOFBF | ||
| 842 | + #define _IOFBF 0 | ||
| 843 | +#endif | ||
| 844 | +#ifndef _IOLBF | ||
| 845 | + #define _IOLBF 1 | ||
| 846 | +#endif | ||
| 847 | +#ifndef _IONBF | ||
| 848 | + #define _IONBF 2 | ||
| 849 | +#endif | ||
| 850 | +#ifndef EOF | ||
| 851 | + #define EOF (-1) | ||
| 852 | +#endif | ||
| 853 | +#ifndef SEEK_SET | ||
| 854 | + #define SEEK_SET 0 | ||
| 855 | +#endif | ||
| 856 | +#ifndef SEEK_CUR | ||
| 857 | + #define SEEK_CUR 1 | ||
| 858 | +#endif | ||
| 859 | +#ifndef SEEK_END | ||
| 860 | + #define SEEK_END 2 | ||
| 861 | +#endif | ||
| 862 | +#ifndef RAND_MAX | ||
| 863 | +enum { | ||
| 864 | + #if defined(_MSC_VER) | ||
| 865 | + RAND_MAX = 0x7fff | ||
| 866 | + #else | ||
| 867 | + RAND_MAX = 2147483647 | ||
| 868 | + #endif | ||
| 869 | +}; | ||
| 870 | +#endif | ||
| 871 | +#undef V_CRT_LINKAGE | ||
| 872 | +#undef V_CRT_CALL | ||
| 873 | +static void v_stable_sort(void *base, size_t items, size_t item_size, qsort_callback_func cb) { | ||
| 874 | + if (items < 2 || item_size == 0) { | ||
| 875 | + return; | ||
| 876 | + } | ||
| 877 | + if (items > ((size_t)-1) / item_size) { | ||
| 878 | + qsort(base, items, item_size, cb); | ||
| 879 | + return; | ||
| 880 | + } | ||
| 881 | + const size_t bytes = items * item_size; | ||
| 882 | + char *base_bytes = (char*)base; | ||
| 883 | + char *tmp = (char*)malloc(bytes); | ||
| 884 | + if (tmp == 0) { | ||
| 885 | + qsort(base, items, item_size, cb); | ||
| 886 | + return; | ||
| 887 | + } | ||
| 888 | + char *src = base_bytes; | ||
| 889 | + char *dst = tmp; | ||
| 890 | + for (size_t width = 1; width < items;) { | ||
| 891 | + for (size_t left = 0; left < items;) { | ||
| 892 | + size_t mid = left; | ||
| 893 | + mid += width; | ||
| 894 | + if (mid > items) { | ||
| 895 | + mid = items; | ||
| 896 | + } | ||
| 897 | + size_t right = mid; | ||
| 898 | + right += width; | ||
| 899 | + if (right > items || right < mid) { | ||
| 900 | + right = items; | ||
| 901 | + } | ||
| 902 | + size_t i = left; | ||
| 903 | + size_t j = mid; | ||
| 904 | + size_t k = left; | ||
| 905 | + while (i < mid && j < right) { | ||
| 906 | + char *leftp = src; | ||
| 907 | + leftp += i * item_size; | ||
| 908 | + char *rightp = src; | ||
| 909 | + rightp += j * item_size; | ||
| 910 | + char *dstp = dst; | ||
| 911 | + dstp += k * item_size; | ||
| 912 | + if (cb(leftp, rightp) <= 0) { | ||
| 913 | + memcpy(dstp, leftp, item_size); | ||
| 914 | + i++; | ||
| 915 | + } else { | ||
| 916 | + memcpy(dstp, rightp, item_size); | ||
| 917 | + j++; | ||
| 918 | + } | ||
| 919 | + k++; | ||
| 920 | + } | ||
| 921 | + while (i < mid) { | ||
| 922 | + char *dstp = dst; | ||
| 923 | + dstp += k * item_size; | ||
| 924 | + char *srcp = src; | ||
| 925 | + srcp += i * item_size; | ||
| 926 | + memcpy(dstp, srcp, item_size); | ||
| 927 | + i++; | ||
| 928 | + k++; | ||
| 929 | + } | ||
| 930 | + while (j < right) { | ||
| 931 | + char *dstp = dst; | ||
| 932 | + dstp += k * item_size; | ||
| 933 | + char *srcp = src; | ||
| 934 | + srcp += j * item_size; | ||
| 935 | + memcpy(dstp, srcp, item_size); | ||
| 936 | + j++; | ||
| 937 | + k++; | ||
| 938 | + } | ||
| 939 | + left = right; | ||
| 940 | + } | ||
| 941 | + char *next_src = dst; | ||
| 942 | + dst = src; | ||
| 943 | + src = next_src; | ||
| 944 | + if (width > items / 2) { | ||
| 945 | + width = items; | ||
| 946 | + } else { | ||
| 947 | + width *= 2; | ||
| 948 | + } | ||
| 949 | + } | ||
| 950 | + if (src != base_bytes) { | ||
| 951 | + memcpy(base_bytes, src, bytes); | ||
| 952 | + } | ||
| 953 | + free(tmp); | ||
| 954 | +} | ||
| 955 | +#if defined(__TINYC__) | ||
| 956 | +// https://lists.nongnu.org/archive/html/tinycc-devel/2025-10/msg00007.html | ||
| 957 | +// gnu headers use to #define __attribute__ to empty for non-gcc compilers | ||
| 958 | +#undef __attribute__ | ||
| 959 | +#endif | ||
| 960 | +#if defined(_MSC_VER) && !defined(__clang__) | ||
| 961 | +// Ensure C99-like return semantics and NUL-termination for MSVC snprintf/vsnprintf. | ||
| 962 | +static int v__vsnprintf(char *s, size_t n, const char *fmt, va_list ap) { | ||
| 963 | + va_list ap_copy; | ||
| 964 | + va_copy(ap_copy, ap); | ||
| 965 | + const int needed = _vscprintf(fmt, ap_copy); | ||
| 966 | + va_end(ap_copy); | ||
| 967 | + if (n > 0) { | ||
| 968 | + const int written = _vsnprintf_s(s, n, _TRUNCATE, fmt, ap); | ||
| 969 | + if (written < 0) { | ||
| 970 | + s[n - | ||
| 971 | + 1] = 0; | ||
| 972 | + } | ||
| 973 | + } | ||
| 974 | + return needed; | ||
| 975 | +} | ||
| 976 | +static int v__snprintf(char *s, size_t n, const char *fmt, ...) { | ||
| 977 | + va_list ap; | ||
| 978 | + va_start(ap, fmt); | ||
| 979 | + const int needed = v__vsnprintf(s, n, fmt, ap); | ||
| 980 | + va_end(ap); | ||
| 981 | + return needed; | ||
| 982 | +} | ||
| 983 | +#define vsnprintf v__vsnprintf | ||
| 984 | +#define snprintf v__snprintf | ||
| 985 | +#endif | ||
| 986 | +//================================== GLOBALS =================================*/ | ||
| 987 | +#ifdef _VOBJECTFILE | ||
| 988 | +static void _vinit(int ___argc, voidptr ___argv); | ||
| 989 | +static void _vcleanup(void); | ||
| 990 | +#else | ||
| 991 | +void _vinit(int ___argc, voidptr ___argv); | ||
| 992 | +void _vcleanup(void); | ||
| 993 | +#endif | ||
| 994 | +#ifdef _WIN32 | ||
| 995 | + // Export helpers so the autogenerated DllMain, or a user-defined one, | ||
| 996 | + // can reuse the default V shared-library init/cleanup path. | ||
| 997 | + #ifdef _VOBJECTFILE | ||
| 998 | + static void _vinit_caller(); | ||
| 999 | + static void _vcleanup_caller(); | ||
| 1000 | + #else | ||
| 1001 | + VV_EXP void _vinit_caller(); | ||
| 1002 | + VV_EXP void _vcleanup_caller(); | ||
| 1003 | + #endif | ||
| 1004 | +#endif | ||
| 1005 | +#if !defined(_WIN32) | ||
| 1006 | +#define sigaction_size sizeof(sigaction); | ||
| 1007 | +#endif | ||
| 1008 | +#define _ARR_LEN(a) ( (sizeof(a)) / (sizeof(a[0])) ) | ||
| 1009 | +#if INTPTR_MAX == INT32_MAX | ||
| 1010 | + #define TARGET_IS_32BIT 1 | ||
| 1011 | +#elif INTPTR_MAX == INT64_MAX | ||
| 1012 | + #define TARGET_IS_64BIT 1 | ||
| 1013 | +#else | ||
| 1014 | + #error "The environment is not 32 or 64-bit." | ||
| 1015 | +#endif | ||
| 1016 | +#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ || defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN || defined(__BIG_ENDIAN__) || defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || defined(_MIBSEB) || defined(__MIBSEB) || defined(__MIBSEB__) | ||
| 1017 | + #define TARGET_ORDER_IS_BIG 1 | ||
| 1018 | +#elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ || defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN || defined(__LITTLE_ENDIAN__) || defined(__ARMEL__) || defined(__THUMBEL__) || defined(__AARCH64EL__) || defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__) || defined(_M_AMD64) || defined(_M_ARM64) || defined(_M_X64) || defined(_M_IX86) | ||
| 1019 | + #define TARGET_ORDER_IS_LITTLE 1 | ||
| 1020 | +#else | ||
| 1021 | + #error "Unknown architecture endianness" | ||
| 1022 | +#endif | ||
| 1023 | +#if !defined(_WIN32) && !defined(__vinix__) | ||
| 1024 | + #include <ctype.h> | ||
| 1025 | + #include <locale.h> // tolower | ||
| 1026 | + #include <sys/time.h> | ||
| 1027 | + #include <unistd.h> // sleep | ||
| 1028 | + extern char **environ; | ||
| 1029 | + #include <pthread.h> | ||
| 1030 | + #ifndef PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP | ||
| 1031 | + // musl does not have that | ||
| 1032 | + #define pthread_rwlockattr_setkind_np(a, b) | ||
| 1033 | + #endif | ||
| 1034 | +#endif | ||
| 1035 | +#if (defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__serenity__) || defined(__sun) || defined(__plan9__) || defined(__OpenBSD__)) && !defined(__vinix__) | ||
| 1036 | + #include <sys/types.h> | ||
| 1037 | + #include <sys/wait.h> // for os__wait | ||
| 1038 | +#endif | ||
| 1039 | +#ifdef __OpenBSD__ | ||
| 1040 | + #include <sys/resource.h> | ||
| 1041 | +#endif | ||
| 1042 | +#ifdef __FreeBSD__ | ||
| 1043 | + #include <signal.h> | ||
| 1044 | + #include <execinfo.h> | ||
| 1045 | +#endif | ||
| 1046 | +#ifdef __NetBSD__ | ||
| 1047 | + #include <sys/wait.h> // for os__wait | ||
| 1048 | +#endif | ||
| 1049 | +#ifdef __TERMUX__ | ||
| 1050 | +#if !defined(__BIONIC_AVAILABILITY_GUARD) | ||
| 1051 | + #define __BIONIC_AVAILABILITY_GUARD(api_level) 0 | ||
| 1052 | +#endif | ||
| 1053 | +#if __BIONIC_AVAILABILITY_GUARD(28) | ||
| 1054 | +#else | ||
| 1055 | +void * aligned_alloc(size_t alignment, size_t size) { return malloc(size); } | ||
| 1056 | +#endif | ||
| 1057 | +#endif | ||
| 1058 | +#ifdef __APPLE__ | ||
| 1059 | + // macOS only exports aligned_alloc starting with 10.15. | ||
| 1060 | + #if !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500 | ||
| 1061 | +static void *v__aligned_alloc_fallback(size_t alignment, size_t size) { | ||
| 1062 | + void *res = 0; | ||
| 1063 | + if (alignment < sizeof(void *)) { | ||
| 1064 | + alignment = sizeof(void *); | ||
| 1065 | + } | ||
| 1066 | + if (posix_memalign(&res, alignment, size) != 0) { | ||
| 1067 | + return 0; | ||
| 1068 | + } | ||
| 1069 | + return res; | ||
| 1070 | +} | ||
| 1071 | + #define aligned_alloc v__aligned_alloc_fallback | ||
| 1072 | + #endif | ||
| 1073 | +#endif | ||
| 1074 | +#ifdef _WIN32 | ||
| 1075 | + #ifdef WINVER | ||
| 1076 | + #undef WINVER | ||
| 1077 | + #endif | ||
| 1078 | + #define WINVER 0x0600 | ||
| 1079 | + #ifdef _WIN32_WINNT | ||
| 1080 | + #undef _WIN32_WINNT | ||
| 1081 | + #endif | ||
| 1082 | + #define _WIN32_WINNT 0x0600 | ||
| 1083 | + #ifndef WIN32_FULL | ||
| 1084 | + #define WIN32_LEAN_AND_MEAN | ||
| 1085 | + #endif | ||
| 1086 | + #ifndef _UNICODE | ||
| 1087 | + #define _UNICODE | ||
| 1088 | + #endif | ||
| 1089 | + #ifndef UNICODE | ||
| 1090 | + #define UNICODE | ||
| 1091 | + #endif | ||
| 1092 | + #include <windows.h> | ||
| 1093 | + #include <io.h> // _waccess | ||
| 1094 | + #include <direct.h> // _wgetcwd | ||
| 1095 | + #ifdef V_USE_SIGNAL_H | ||
| 1096 | + #include <signal.h> // signal and SIGSEGV for segmentation fault handler | ||
| 1097 | + #endif | ||
| 1098 | + #ifdef _MSC_VER | ||
| 1099 | + // On MSVC these are the same (as long as /volatile:ms is passed) | ||
| 1100 | + #define _Atomic volatile | ||
| 1101 | + // MSVC cannot parse some things properly | ||
| 1102 | + #undef __NOINLINE | ||
| 1103 | + #undef __IRQHANDLER | ||
| 1104 | + #define __NOINLINE __declspec(noinline) | ||
| 1105 | + #define __IRQHANDLER __declspec(naked) | ||
| 1106 | + #include <dbghelp.h> | ||
| 1107 | + #pragma comment(lib, "Dbghelp") | ||
| 1108 | + #endif | ||
| 1109 | +#endif | ||
| 1110 | +#if defined(__CYGWIN__) && !defined(_WIN32) | ||
| 1111 | + #error Cygwin is not supported, please use MinGW or Visual Studio. | ||
| 1112 | +#endif | ||
| 1113 | +#if defined(__MINGW32__) || defined(__MINGW64__) || (defined(_WIN32) && defined(__TINYC__)) || defined(_MSC_VER) | ||
| 1114 | + #undef PRId64 | ||
| 1115 | + #undef PRIi64 | ||
| 1116 | + #undef PRIo64 | ||
| 1117 | + #undef PRIu64 | ||
| 1118 | + #undef PRIx64 | ||
| 1119 | + #undef PRIX64 | ||
| 1120 | + #define PRId64 "lld" | ||
| 1121 | + #define PRIi64 "lli" | ||
| 1122 | + #define PRIo64 "llo" | ||
| 1123 | + #define PRIu64 "llu" | ||
| 1124 | + #define PRIx64 "llx" | ||
| 1125 | + #define PRIX64 "llX" | ||
| 1126 | +#endif | ||
| 1127 | +#ifdef _VFREESTANDING | ||
| 1128 | +#undef _VFREESTANDING | ||
| 1129 | +#endif | ||
| 1130 | + | ||
| 1131 | + | ||
| 1132 | +// deterministic float -> u64 conversions for explicit V casts | ||
| 1133 | +// direct C casts are undefined for out-of-range values | ||
| 1134 | +static inline uint64_t _v_f64_to_u64(double x) { | ||
| 1135 | + if (!(x >= 0.0)) { | ||
| 1136 | + return 0; | ||
| 1137 | + } | ||
| 1138 | + if (x >= 18446744073709551616.0) { | ||
| 1139 | + return UINT64_MAX; | ||
| 1140 | + } | ||
| 1141 | + return (uint64_t)x; | ||
| 1142 | +} | ||
| 1143 | + | ||
| 1144 | + | ||
| 1145 | +// unsigned/signed comparisons | ||
| 1146 | +static inline bool _us32_gt(uint32_t a, int32_t b) { return a > INT32_MAX || (int32_t)a > b; } | ||
| 1147 | +static inline bool _us32_ge(uint32_t a, int32_t b) { return a >= INT32_MAX || (int32_t)a >= b; } | ||
| 1148 | +static inline bool _us32_eq(uint32_t a, int32_t b) { return a <= INT32_MAX && (int32_t)a == b; } | ||
| 1149 | +static inline bool _us32_ne(uint32_t a, int32_t b) { return a > INT32_MAX || (int32_t)a != b; } | ||
| 1150 | +static inline bool _us32_le(uint32_t a, int32_t b) { return a <= INT32_MAX && (int32_t)a <= b; } | ||
| 1151 | +static inline bool _us32_lt(uint32_t a, int32_t b) { return a < INT32_MAX && (int32_t)a < b; } | ||
| 1152 | +static inline bool _us64_gt(uint64_t a, int64_t b) { return a > INT64_MAX || (int64_t)a > b; } | ||
| 1153 | +static inline bool _us64_ge(uint64_t a, int64_t b) { return a >= INT64_MAX || (int64_t)a >= b; } | ||
| 1154 | +static inline bool _us64_eq(uint64_t a, int64_t b) { return a <= INT64_MAX && (int64_t)a == b; } | ||
| 1155 | +static inline bool _us64_ne(uint64_t a, int64_t b) { return a > INT64_MAX || (int64_t)a != b; } | ||
| 1156 | +static inline bool _us64_le(uint64_t a, int64_t b) { return a <= INT64_MAX && (int64_t)a <= b; } | ||
| 1157 | +static inline bool _us64_lt(uint64_t a, int64_t b) { return a < INT64_MAX && (int64_t)a < b; } | ||
| 1158 | + | ||
| 1159 | + | ||
| 1160 | +#if !defined(VNORETURN) | ||
| 1161 | + #if defined(__TINYC__) | ||
| 1162 | + #define VNORETURN __attribute__((noreturn)) | ||
| 1163 | + # elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L | ||
| 1164 | + # define VNORETURN _Noreturn | ||
| 1165 | + # elif !defined(VNORETURN) && defined(__GNUC__) && __GNUC__ >= 2 | ||
| 1166 | + # define VNORETURN __attribute__((noreturn)) | ||
| 1167 | + # endif | ||
| 1168 | + #ifndef VNORETURN | ||
| 1169 | + #define VNORETURN | ||
| 1170 | + #endif | ||
| 1171 | +#endif | ||
| 1172 | + | ||
| 1173 | + | ||
| 1174 | +#if !defined(VUNREACHABLE) | ||
| 1175 | + #if defined(__GNUC__) && !defined(__clang__) | ||
| 1176 | + #define V_GCC_VERSION (__GNUC__ * 10000L + __GNUC_MINOR__ * 100L + __GNUC_PATCHLEVEL__) | ||
| 1177 | + #if (V_GCC_VERSION >= 40500L) && !defined(__TINYC__) | ||
| 1178 | + #define VUNREACHABLE() do { __builtin_unreachable(); } while (0) | ||
| 1179 | + #endif | ||
| 1180 | + #endif | ||
| 1181 | + #if defined(__clang__) && defined(__has_builtin) && !defined(__TINYC__) | ||
| 1182 | + #if __has_builtin(__builtin_unreachable) | ||
| 1183 | + #define VUNREACHABLE() do { __builtin_unreachable(); } while (0) | ||
| 1184 | + #endif | ||
| 1185 | + #endif | ||
| 1186 | + #ifndef VUNREACHABLE | ||
| 1187 | + #define VUNREACHABLE() do { } while (0) | ||
| 1188 | + #endif | ||
| 1189 | +#endif | ||
| 1190 | + | ||
| 1191 | + | ||
| 1192 | +#ifndef wyhash_final_version_4_2 | ||
| 1193 | +#define wyhash_final_version_4_2 | ||
| 1194 | +#ifndef WYHASH_CONDOM | ||
| 1195 | +// protections that produce different results: | ||
| 1196 | +// 1: normal valid behavior | ||
| 1197 | +// 2: extra protection against entropy loss (probability=2^-63), aka. "blind multiplication" | ||
| 1198 | +#define WYHASH_CONDOM 1 | ||
| 1199 | +#endif | ||
| 1200 | +#ifndef WYHASH_32BIT_MUM | ||
| 1201 | +// 0: normal version, slow on 32 bit systems | ||
| 1202 | +// 1: faster on 32 bit systems but produces different results, incompatible with wy2u0k function | ||
| 1203 | +#define WYHASH_32BIT_MUM 0 | ||
| 1204 | +#endif | ||
| 1205 | +// includes | ||
| 1206 | +#include <stdint.h> | ||
| 1207 | +#if defined(_MSC_VER) && defined(_M_X64) | ||
| 1208 | + #include <intrin.h> | ||
| 1209 | + #pragma intrinsic(_umul128) | ||
| 1210 | +#endif | ||
| 1211 | +// 128bit multiply function | ||
| 1212 | +static inline uint64_t _wyrot(uint64_t x) { return (x>>32)|(x<<32); } | ||
| 1213 | +static inline void _wymum(uint64_t *A, uint64_t *B){ | ||
| 1214 | +#if(WYHASH_32BIT_MUM) | ||
| 1215 | + uint64_t hh=(*A>>32)*(*B>>32), hl=(*A>>32)*(uint32_t)*B, lh=(uint32_t)*A*(*B>>32), ll=(uint64_t)(uint32_t)*A*(uint32_t)*B; | ||
| 1216 | + #if(WYHASH_CONDOM>1) | ||
| 1217 | + *A^=_wyrot(hl)^hh; *B^=_wyrot(lh)^ll; | ||
| 1218 | + #else | ||
| 1219 | + *A=_wyrot(hl)^hh; *B=_wyrot(lh)^ll; | ||
| 1220 | + #endif | ||
| 1221 | +#elif defined(__SIZEOF_INT128__) && !defined(VWASM) | ||
| 1222 | + __uint128_t r=*A; r*=*B; | ||
| 1223 | + #if(WYHASH_CONDOM>1) | ||
| 1224 | + *A^=(uint64_t)r; *B^=(uint64_t)(r>>64); | ||
| 1225 | + #else | ||
| 1226 | + *A=(uint64_t)r; *B=(uint64_t)(r>>64); | ||
| 1227 | + #endif | ||
| 1228 | +#elif defined(_MSC_VER) && defined(_M_X64) | ||
| 1229 | + #if(WYHASH_CONDOM>1) | ||
| 1230 | + uint64_t a, b; | ||
| 1231 | + a=_umul128(*A,*B,&b); | ||
| 1232 | + *A^=a; *B^=b; | ||
| 1233 | + #else | ||
| 1234 | + *A=_umul128(*A,*B,B); | ||
| 1235 | + #endif | ||
| 1236 | +#else | ||
| 1237 | + uint64_t ha=*A>>32, hb=*B>>32, la=(uint32_t)*A, lb=(uint32_t)*B, hi, lo; | ||
| 1238 | + uint64_t rh=ha*hb, rm0=ha*lb, rm1=hb*la, rl=la*lb, t=rl+(rm0<<32), c=t<rl; | ||
| 1239 | + lo=t+(rm1<<32); c+=lo<t; hi=rh+(rm0>>32)+(rm1>>32)+c; | ||
| 1240 | + #if(WYHASH_CONDOM>1) | ||
| 1241 | + *A^=lo; *B^=hi; | ||
| 1242 | + #else | ||
| 1243 | + *A=lo; *B=hi; | ||
| 1244 | + #endif | ||
| 1245 | +#endif | ||
| 1246 | +} | ||
| 1247 | +// multiply and xor mix function, aka MUM | ||
| 1248 | +static inline uint64_t _wymix(uint64_t A, uint64_t B){ _wymum(&A,&B); return A^B; } | ||
| 1249 | +// endian macros | ||
| 1250 | +#ifndef WYHASH_LITTLE_ENDIAN | ||
| 1251 | + #ifdef TARGET_ORDER_IS_LITTLE | ||
| 1252 | + #define WYHASH_LITTLE_ENDIAN 1 | ||
| 1253 | + #else | ||
| 1254 | + #define WYHASH_LITTLE_ENDIAN 0 | ||
| 1255 | + #endif | ||
| 1256 | +#endif | ||
| 1257 | +// read functions | ||
| 1258 | +#if (WYHASH_LITTLE_ENDIAN) | ||
| 1259 | + static inline uint64_t _wyr8(const uint8_t *p) { uint64_t v; memcpy(&v, p, 8); return v;} | ||
| 1260 | + static inline uint64_t _wyr4(const uint8_t *p) { uint32_t v; memcpy(&v, p, 4); return v;} | ||
| 1261 | +#elif !defined(__TINYC__) && (defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__clang__)) | ||
| 1262 | + static inline uint64_t _wyr8(const uint8_t *p) { uint64_t v; memcpy(&v, p, 8); return __builtin_bswap64(v);} | ||
| 1263 | + static inline uint64_t _wyr4(const uint8_t *p) { uint32_t v; memcpy(&v, p, 4); return __builtin_bswap32(v);} | ||
| 1264 | +#elif defined(_MSC_VER) | ||
| 1265 | + static inline uint64_t _wyr8(const uint8_t *p) { uint64_t v; memcpy(&v, p, 8); return _byteswap_uint64(v);} | ||
| 1266 | + static inline uint64_t _wyr4(const uint8_t *p) { uint32_t v; memcpy(&v, p, 4); return _byteswap_ulong(v);} | ||
| 1267 | +#else | ||
| 1268 | + static inline uint64_t _wyr8(const uint8_t *p) { | ||
| 1269 | + uint64_t v; memcpy(&v, p, 8); | ||
| 1270 | + return (((v >> 56) & 0xff)| ((v >> 40) & 0xff00)| ((v >> 24) & 0xff0000)| ((v >> 8) & 0xff000000)| ((v << 8) & 0xff00000000)| ((v << 24) & 0xff0000000000)| ((v << 40) & 0xff000000000000)| ((v << 56) & 0xff00000000000000)); | ||
| 1271 | + } | ||
| 1272 | + static inline uint64_t _wyr4(const uint8_t *p) { | ||
| 1273 | + uint32_t v; memcpy(&v, p, 4); | ||
| 1274 | + return (((v >> 24) & 0xff)| ((v >> 8) & 0xff00)| ((v << 8) & 0xff0000)| ((v << 24) & 0xff000000)); | ||
| 1275 | + } | ||
| 1276 | +#endif | ||
| 1277 | +static inline uint64_t _wyr3(const uint8_t *p, size_t k) { return (((uint64_t)p[0])<<16)|(((uint64_t)p[k>>1])<<8)|p[k-1];} | ||
| 1278 | +// wyhash main function | ||
| 1279 | +static inline uint64_t wyhash(const void *key, size_t len, uint64_t seed, const uint64_t *secret){ | ||
| 1280 | + const uint8_t *p=(const uint8_t *)key; seed^=_wymix(seed^secret[0]^len,secret[1]); uint64_t a, b; | ||
| 1281 | + if (_likely_(len<=16)) { | ||
| 1282 | + if (_likely_(len>=4)) { a=(_wyr4(p)<<32)|_wyr4(p+((len>>3)<<2)); b=(_wyr4(p+len-4)<<32)|_wyr4(p+len-4-((len>>3)<<2)); } | ||
| 1283 | + else if (_likely_(len>0)) { a=_wyr3(p,len); b=0; } | ||
| 1284 | + else a=b=0; | ||
| 1285 | + } else { | ||
| 1286 | + size_t i=len; | ||
| 1287 | + if (_unlikely_(i>=48)) { | ||
| 1288 | + uint64_t see1=seed, see2=seed; | ||
| 1289 | + do { | ||
| 1290 | + seed=_wymix(_wyr8(p)^secret[1],_wyr8(p+8)^seed); | ||
| 1291 | + see1=_wymix(_wyr8(p+16)^secret[2],_wyr8(p+24)^see1); | ||
| 1292 | + see2=_wymix(_wyr8(p+32)^secret[3],_wyr8(p+40)^see2); | ||
| 1293 | + p+=48; i-=48; | ||
| 1294 | + } while(_likely_(i>=48)); | ||
| 1295 | + seed^=see1^see2; | ||
| 1296 | + } | ||
| 1297 | + while(_unlikely_(i>16)) { seed=_wymix(_wyr8(p)^secret[1],_wyr8(p+8)^seed); i-=16; p+=16; } | ||
| 1298 | + a=_wyr8(p+i-16); b=_wyr8(p+i-8); | ||
| 1299 | + } | ||
| 1300 | + a^=secret[1]; b^=seed; _wymum(&a,&b); | ||
| 1301 | + return _wymix(a^secret[0]^len,b^secret[1]); | ||
| 1302 | +} | ||
| 1303 | +// the default secret parameters | ||
| 1304 | +static const uint64_t _wyp[4] = {0x2d358dccaa6c78a5ull, 0x8bb84b93962eacc9ull, 0x4b33a62ed433d4a3ull, 0x4d5a2da51de1aa47ull}; | ||
| 1305 | +// a useful 64bit-64bit mix function to produce deterministic pseudo random numbers that can pass BigCrush and PractRand | ||
| 1306 | +static inline uint64_t wyhash64(uint64_t A, uint64_t B){ A^=0x2d358dccaa6c78a5ull; B^=0x8bb84b93962eacc9ull; _wymum(&A,&B); return _wymix(A^0x2d358dccaa6c78a5ull,B^0x8bb84b93962eacc9ull);} | ||
| 1307 | +// the wyrand PRNG that pass BigCrush and PractRand | ||
| 1308 | +static inline uint64_t wyrand(uint64_t *seed){ *seed+=0x2d358dccaa6c78a5ull; return _wymix(*seed,*seed^0x8bb84b93962eacc9ull);} | ||
| 1309 | +#ifndef __vinix__ | ||
| 1310 | +// convert any 64 bit pseudo random numbers to uniform distribution [0,1). It can be combined with wyrand, wyhash64 or wyhash. | ||
| 1311 | +static inline double wy2u01(uint64_t r){ const double _wynorm=1.0/(1ull<<52); return (r>>12)*_wynorm;} | ||
| 1312 | +// convert any 64 bit pseudo random numbers to APPROXIMATE Gaussian distribution. It can be combined with wyrand, wyhash64 or wyhash. | ||
| 1313 | +static inline double wy2gau(uint64_t r){ const double _wynorm=1.0/(1ull<<20); return ((r&0x1fffff)+((r>>21)&0x1fffff)+((r>>42)&0x1fffff))*_wynorm-3.0;} | ||
| 1314 | +#endif | ||
| 1315 | +#if(!WYHASH_32BIT_MUM) | ||
| 1316 | +// fast range integer random number generation on [0,k) credit to Daniel Lemire. May not work when WYHASH_32BIT_MUM=1. It can be combined with wyrand, wyhash64 or wyhash. | ||
| 1317 | +static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; } | ||
| 1318 | +#endif | ||
| 1319 | +#endif | ||
| 1320 | +#define _IN_MAP(val, m) builtin__map_exists(m, val) | ||
| 1321 | + | ||
| 1322 | +#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 30 | ||
| 1323 | +#include <sys/syscall.h> | ||
| 1324 | +#define gettid() syscall(SYS_gettid) | ||
| 1325 | +#endif | ||
| 1326 | + | ||
| 1327 | +// V includes: | ||
| 1328 | + | ||
| 1329 | +#if defined(__TINYC__) && defined(__has_include) // tcc does not support has_include properly yet, turn it off completely | ||
| 1330 | +#undef __has_include | ||
| 1331 | +#endif | ||
| 1332 | + | ||
| 1333 | +#if defined(__TINYC__) && defined(__BIONIC__) | ||
| 1334 | + #define __builtin_nanf(ignored_string) (0.0F / 0.0F) | ||
| 1335 | + #define __builtin_nan(ignored_string) (0.0 / 0.0) | ||
| 1336 | + #define __builtin_nanl(ignored_string) (0.0L / 0.0L) | ||
| 1337 | + #define __builtin_inff() (1.0F / 0.0F) | ||
| 1338 | + #define __builtin_inf() (1.0 / 0.0) | ||
| 1339 | + #define __builtin_infl() (1.0L / 0.0L) | ||
| 1340 | + #define __builtin_huge_valf() (1.0F / 0.0F) | ||
| 1341 | + #define __builtin_huge_val() (1.0 / 0.0) | ||
| 1342 | + #define __builtin_huge_vall() (1.0L / 0.0L) | ||
| 1343 | +#endif | ||
| 1344 | + | ||
| 1345 | +#if 1 | ||
| 1346 | + | ||
| 1347 | +// added by module `builtin.closure`, file: closure_nix.c.v:4: | ||
| 1348 | + | ||
| 1349 | +#ifdef __TINYC__ | ||
| 1350 | +#include <sys/mman.h> | ||
| 1351 | +#else | ||
| 1352 | +#if defined(__has_include) | ||
| 1353 | +#if __has_include(<sys/mman.h>) | ||
| 1354 | +#include <sys/mman.h> | ||
| 1355 | +#else | ||
| 1356 | +#error VERROR_MESSAGE Header file <sys/mman.h>, needed for module `builtin.closure` was not found. Please install the corresponding development headers. | ||
| 1357 | +#endif | ||
| 1358 | +#else | ||
| 1359 | +#include <sys/mman.h> | ||
| 1360 | +#endif | ||
| 1361 | +#endif | ||
| 1362 | + | ||
| 1363 | + | ||
| 1364 | +// inserted by module `builtin.closure`, file: closure_nix.c.v:5: | ||
| 1365 | +#ifndef V_CLOSURE_ONCE_NIX_H | ||
| 1366 | +#define V_CLOSURE_ONCE_NIX_H | ||
| 1367 | + | ||
| 1368 | +#include <pthread.h> | ||
| 1369 | + | ||
| 1370 | +typedef void (*v_closure_init_fn)(void); | ||
| 1371 | + | ||
| 1372 | +#ifndef V_CLOSURE_STATIC_INLINE | ||
| 1373 | +# ifdef _MSC_VER | ||
| 1374 | +# define V_CLOSURE_STATIC_INLINE static __inline | ||
| 1375 | +# else | ||
| 1376 | +# define V_CLOSURE_STATIC_INLINE static inline | ||
| 1377 | +# endif | ||
| 1378 | +#endif | ||
| 1379 | + | ||
| 1380 | +static pthread_mutex_t v_closure_once_mutex = PTHREAD_MUTEX_INITIALIZER; | ||
| 1381 | +static int v_closure_once_done = 0; | ||
| 1382 | + | ||
| 1383 | +V_CLOSURE_STATIC_INLINE void v_closure_init_once(v_closure_init_fn init_fn) { | ||
| 1384 | + pthread_mutex_lock(&v_closure_once_mutex); | ||
| 1385 | + if (!v_closure_once_done) { | ||
| 1386 | + init_fn(); | ||
| 1387 | + v_closure_once_done = 1; | ||
| 1388 | + } | ||
| 1389 | + pthread_mutex_unlock(&v_closure_once_mutex); | ||
| 1390 | +} | ||
| 1391 | + | ||
| 1392 | +#endif | ||
| 1393 | + | ||
| 1394 | +#endif | ||
| 1395 | + | ||
| 1396 | +#if 1 | ||
| 1397 | + | ||
| 1398 | +// added by module `builtin.closure`, file: closure_nix.c.v:4: | ||
| 1399 | + | ||
| 1400 | +#ifdef __TINYC__ | ||
| 1401 | +#include <sys/mman.h> | ||
| 1402 | +#else | ||
| 1403 | +#if defined(__has_include) | ||
| 1404 | +#if __has_include(<sys/mman.h>) | ||
| 1405 | +#include <sys/mman.h> | ||
| 1406 | +#else | ||
| 1407 | +#error VERROR_MESSAGE Header file <sys/mman.h>, needed for module `builtin.closure` was not found. Please install the corresponding development headers. | ||
| 1408 | +#endif | ||
| 1409 | +#else | ||
| 1410 | +#include <sys/mman.h> | ||
| 1411 | +#endif | ||
| 1412 | +#endif | ||
| 1413 | + | ||
| 1414 | + | ||
| 1415 | +// inserted by module `builtin.closure`, file: closure_nix.c.v:5: | ||
| 1416 | +#ifndef V_CLOSURE_ONCE_NIX_H | ||
| 1417 | +#define V_CLOSURE_ONCE_NIX_H | ||
| 1418 | + | ||
| 1419 | +#include <pthread.h> | ||
| 1420 | + | ||
| 1421 | +typedef void (*v_closure_init_fn)(void); | ||
| 1422 | + | ||
| 1423 | +#ifndef V_CLOSURE_STATIC_INLINE | ||
| 1424 | +# ifdef _MSC_VER | ||
| 1425 | +# define V_CLOSURE_STATIC_INLINE static __inline | ||
| 1426 | +# else | ||
| 1427 | +# define V_CLOSURE_STATIC_INLINE static inline | ||
| 1428 | +# endif | ||
| 1429 | +#endif | ||
| 1430 | + | ||
| 1431 | +static pthread_mutex_t v_closure_once_mutex = PTHREAD_MUTEX_INITIALIZER; | ||
| 1432 | +static int v_closure_once_done = 0; | ||
| 1433 | + | ||
| 1434 | +V_CLOSURE_STATIC_INLINE void v_closure_init_once(v_closure_init_fn init_fn) { | ||
| 1435 | + pthread_mutex_lock(&v_closure_once_mutex); | ||
| 1436 | + if (!v_closure_once_done) { | ||
| 1437 | + init_fn(); | ||
| 1438 | + v_closure_once_done = 1; | ||
| 1439 | + } | ||
| 1440 | + pthread_mutex_unlock(&v_closure_once_mutex); | ||
| 1441 | +} | ||
| 1442 | + | ||
| 1443 | +#endif | ||
| 1444 | + | ||
| 1445 | +#endif | ||
| 1446 | + | ||
| 1447 | +// inserted by module `builtin`, file: allocation.c.v:43: | ||
| 1448 | +#ifndef V_TRACK_HEAP_CHECKS_H | ||
| 1449 | +#define V_TRACK_HEAP_CHECKS_H | ||
| 1450 | + | ||
| 1451 | +#if defined(CUSTOM_DEFINE_track_heap) && (defined(_VGCBOEHM) || defined(CUSTOM_DEFINE_gcboehm)) | ||
| 1452 | +#error "-d track_heap requires manual memory management; rebuild with -gc none" | ||
| 1453 | +#endif | ||
| 1454 | + | ||
| 1455 | +#if defined(CUSTOM_DEFINE_track_heap) && defined(CUSTOM_DEFINE_vgc) | ||
| 1456 | +#error "-d track_heap requires manual memory management; rebuild with -gc none" | ||
| 1457 | +#endif | ||
| 1458 | + | ||
| 1459 | +#if defined(CUSTOM_DEFINE_track_heap) && defined(_VPREALLOC) | ||
| 1460 | +#error "-d track_heap requires manual memory management; rebuild with -gc none (not -prealloc)" | ||
| 1461 | +#endif | ||
| 1462 | + | ||
| 1463 | +#endif | ||
| 1464 | + | ||
| 1465 | + | ||
| 1466 | +// added by module `builtin`, file: float.c.v:9: | ||
| 1467 | + | ||
| 1468 | +#ifdef __TINYC__ | ||
| 1469 | +#include <float.h> | ||
| 1470 | +#else | ||
| 1471 | +#if defined(__has_include) | ||
| 1472 | +#if __has_include(<float.h>) | ||
| 1473 | +#include <float.h> | ||
| 1474 | +#else | ||
| 1475 | +#error VERROR_MESSAGE Header file <float.h>, needed for module `builtin` was not found. Please install the corresponding development headers. | ||
| 1476 | +#endif | ||
| 1477 | +#else | ||
| 1478 | +#include <float.h> | ||
| 1479 | +#endif | ||
| 1480 | +#endif | ||
| 1481 | + | ||
| 1482 | +#if !defined(__cplusplus) && !defined(CUSTOM_DEFINE_no_bool) | ||
| 1483 | +#ifdef bool | ||
| 1484 | +#undef bool | ||
| 1485 | +#endif | ||
| 1486 | +#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 202311L | ||
| 1487 | +#ifdef CUSTOM_DEFINE_4bytebool | ||
| 1488 | +typedef int bool; | ||
| 1489 | +#else | ||
| 1490 | +typedef u8 bool; | ||
| 1491 | +#endif | ||
| 1492 | +#endif | ||
| 1493 | +#endif | ||
| 1494 | + | ||
| 1495 | +// V global/const #define ... : | ||
| 1496 | +#define _const_builtin__closure__assumed_page_size 16384 | ||
| 1497 | +#define _const_strconv__digits 18 | ||
| 1498 | +#define _const_strconv__c_dpoint '.' | ||
| 1499 | +#define _const_strconv__c_plus '+' | ||
| 1500 | +#define _const_strconv__c_minus '-' | ||
| 1501 | +#define _const_strconv__c_zero '0' | ||
| 1502 | +#define _const_strconv__c_nine '9' | ||
| 1503 | +#define _const_strconv__int_size 32 | ||
| 1504 | +#define _const_strconv__max_size_f64_char 512 | ||
| 1505 | +#define _const_autostr_type_stack_max_depth 64 | ||
| 1506 | +#define _const_min_int -2147483648 | ||
| 1507 | +#define _const_max_int 2147483647 | ||
| 1508 | +#define _const_hashbits 24 | ||
| 1509 | +#define _const_max_cached_hashbits 16 | ||
| 1510 | +#define _const_init_log_capicity 5 | ||
| 1511 | +#define _const_init_capicity 32 | ||
| 1512 | +#define _const_init_even_index 30 | ||
| 1513 | +#define _const_extra_metas_inc 4 | ||
| 1514 | +#define _const_rune_maps_columns_in_row 4 | ||
| 1515 | +#define _const_rune_maps_ul -3 | ||
| 1516 | +#define _const_rune_maps_utl -2 | ||
| 1517 | +#define _const_degree 6 | ||
| 1518 | +#define _const_mid_index 5 | ||
| 1519 | +#define _const_max_len 11 | ||
| 1520 | +#define _const_replace_stack_buffer_size 10 | ||
| 1521 | +#define _const_kmp_stack_buffer_size 20 | ||
| 1522 | + | ||
| 1523 | +// Enum definitions: | ||
| 1524 | + | ||
| 1525 | +typedef enum { | ||
| 1526 | + strings__IndentState__normal, // | ||
| 1527 | + strings__IndentState__in_string, // +1 | ||
| 1528 | +} strings__IndentState; | ||
| 1529 | + | ||
| 1530 | +typedef enum { | ||
| 1531 | + builtin__closure__MemoryProtectAtrr__read_exec, // | ||
| 1532 | + builtin__closure__MemoryProtectAtrr__read_write, // +1 | ||
| 1533 | +} builtin__closure__MemoryProtectAtrr; | ||
| 1534 | + | ||
| 1535 | +typedef enum { | ||
| 1536 | + strconv__ParserState__ok, // | ||
| 1537 | + strconv__ParserState__pzero, // +1 | ||
| 1538 | + strconv__ParserState__mzero, // +2 | ||
| 1539 | + strconv__ParserState__pinf, // +3 | ||
| 1540 | + strconv__ParserState__minf, // +4 | ||
| 1541 | + strconv__ParserState__invalid_number, // +5 | ||
| 1542 | + strconv__ParserState__extra_char, // +6 | ||
| 1543 | +} strconv__ParserState; | ||
| 1544 | + | ||
| 1545 | +typedef enum { | ||
| 1546 | + strconv__Align_text__right = 0, // 0 | ||
| 1547 | + strconv__Align_text__left, // 0+1 | ||
| 1548 | + strconv__Align_text__center, // 0+2 | ||
| 1549 | +} strconv__Align_text; | ||
| 1550 | + | ||
| 1551 | +typedef enum { | ||
| 1552 | + strconv__Char_parse_state__start, // | ||
| 1553 | + strconv__Char_parse_state__norm_char, // +1 | ||
| 1554 | + strconv__Char_parse_state__field_char, // +2 | ||
| 1555 | + strconv__Char_parse_state__pad_ch, // +3 | ||
| 1556 | + strconv__Char_parse_state__len_set_start, // +4 | ||
| 1557 | + strconv__Char_parse_state__len_set_in, // +5 | ||
| 1558 | + strconv__Char_parse_state__check_type, // +6 | ||
| 1559 | + strconv__Char_parse_state__check_float, // +7 | ||
| 1560 | + strconv__Char_parse_state__check_float_in, // +8 | ||
| 1561 | + strconv__Char_parse_state__reset_params, // +9 | ||
| 1562 | +} strconv__Char_parse_state; | ||
| 1563 | + | ||
| 1564 | +typedef enum { | ||
| 1565 | + ArrayFlags__noslices = 1U, // u64(1) << 0 | ||
| 1566 | + ArrayFlags__noshrink = 2U, // u64(1) << 1 | ||
| 1567 | + ArrayFlags__nogrow = 4U, // u64(1) << 2 | ||
| 1568 | + ArrayFlags__nofree = 8U, // u64(1) << 3 | ||
| 1569 | + ArrayFlags__managed = 16U, // u64(1) << 4 | ||
| 1570 | + ArrayFlags__noscan_data = 32U, // u64(1) << 5 | ||
| 1571 | + ArrayFlags__is_slice = 64U, // u64(1) << 6 | ||
| 1572 | +} ArrayFlags; | ||
| 1573 | + | ||
| 1574 | +typedef enum { | ||
| 1575 | + ChanState__success, // | ||
| 1576 | + ChanState__not_ready, // +1 | ||
| 1577 | + ChanState__closed, // +2 | ||
| 1578 | +} ChanState; | ||
| 1579 | + | ||
| 1580 | +typedef enum { | ||
| 1581 | + GraphemeBreakProperty__other, // | ||
| 1582 | + GraphemeBreakProperty__cr, // +1 | ||
| 1583 | + GraphemeBreakProperty__lf, // +2 | ||
| 1584 | + GraphemeBreakProperty__control, // +3 | ||
| 1585 | + GraphemeBreakProperty__extend, // +4 | ||
| 1586 | + GraphemeBreakProperty__regional_indicator, // +5 | ||
| 1587 | + GraphemeBreakProperty__prepend, // +6 | ||
| 1588 | + GraphemeBreakProperty__spacing_mark, // +7 | ||
| 1589 | + GraphemeBreakProperty__l, // +8 | ||
| 1590 | + GraphemeBreakProperty__v, // +9 | ||
| 1591 | + GraphemeBreakProperty__t, // +10 | ||
| 1592 | + GraphemeBreakProperty__lv, // +11 | ||
| 1593 | + GraphemeBreakProperty__lvt, // +12 | ||
| 1594 | + GraphemeBreakProperty__zwj, // +13 | ||
| 1595 | +} GraphemeBreakProperty; | ||
| 1596 | + | ||
| 1597 | +typedef enum { | ||
| 1598 | + AttributeKind__plain, // | ||
| 1599 | + AttributeKind__string, // +1 | ||
| 1600 | + AttributeKind__number, // +2 | ||
| 1601 | + AttributeKind__bool, // +3 | ||
| 1602 | + AttributeKind__comptime_define, // +4 | ||
| 1603 | +} AttributeKind; | ||
| 1604 | + | ||
| 1605 | +typedef enum { | ||
| 1606 | + MapMode__to_upper, // | ||
| 1607 | + MapMode__to_lower, // +1 | ||
| 1608 | + MapMode__to_title, // +2 | ||
| 1609 | +} MapMode; | ||
| 1610 | + | ||
| 1611 | +typedef enum { | ||
| 1612 | + TrimMode__trim_left, // | ||
| 1613 | + TrimMode__trim_right, // +1 | ||
| 1614 | + TrimMode__trim_both, // +2 | ||
| 1615 | +} TrimMode; | ||
| 1616 | + | ||
| 1617 | +typedef enum { | ||
| 1618 | + StrIntpType__si_no_str = 0, // 0 | ||
| 1619 | + StrIntpType__si_c, // 0+1 | ||
| 1620 | + StrIntpType__si_u8, // 0+2 | ||
| 1621 | + StrIntpType__si_i8, // 0+3 | ||
| 1622 | + StrIntpType__si_u16, // 0+4 | ||
| 1623 | + StrIntpType__si_i16, // 0+5 | ||
| 1624 | + StrIntpType__si_u32, // 0+6 | ||
| 1625 | + StrIntpType__si_i32, // 0+7 | ||
| 1626 | + StrIntpType__si_u64, // 0+8 | ||
| 1627 | + StrIntpType__si_i64, // 0+9 | ||
| 1628 | + StrIntpType__si_e32, // 0+10 | ||
| 1629 | + StrIntpType__si_e64, // 0+11 | ||
| 1630 | + StrIntpType__si_f32, // 0+12 | ||
| 1631 | + StrIntpType__si_f64, // 0+13 | ||
| 1632 | + StrIntpType__si_g32, // 0+14 | ||
| 1633 | + StrIntpType__si_g64, // 0+15 | ||
| 1634 | + StrIntpType__si_s, // 0+16 | ||
| 1635 | + StrIntpType__si_p, // 0+17 | ||
| 1636 | + StrIntpType__si_r, // 0+18 | ||
| 1637 | + StrIntpType__si_vp, // 0+19 | ||
| 1638 | +} StrIntpType; | ||
| 1639 | + | ||
| 1640 | +// V type definitions: | ||
| 1641 | +struct IError { | ||
| 1642 | + union { | ||
| 1643 | + void* _object; | ||
| 1644 | + None__* _None__; | ||
| 1645 | + voidptr* _voidptr; | ||
| 1646 | + MessageError* _MessageError; | ||
| 1647 | + Error* _Error; | ||
| 1648 | + }; | ||
| 1649 | + u32 _typ; | ||
| 1650 | + void* _methods; | ||
| 1651 | +}; | ||
| 1652 | + | ||
| 1653 | +struct string { | ||
| 1654 | + u8* str; | ||
| 1655 | + int len; | ||
| 1656 | + int is_lit; | ||
| 1657 | +}; | ||
| 1658 | + | ||
| 1659 | +struct array { | ||
| 1660 | + voidptr data; | ||
| 1661 | + int offset; | ||
| 1662 | + int len; | ||
| 1663 | + int cap; | ||
| 1664 | + ArrayFlags flags; | ||
| 1665 | + int element_size; | ||
| 1666 | +}; | ||
| 1667 | + | ||
| 1668 | +struct DenseArray { | ||
| 1669 | + int key_bytes; | ||
| 1670 | + int value_bytes; | ||
| 1671 | + int cap; | ||
| 1672 | + int len; | ||
| 1673 | + u32 deletes; | ||
| 1674 | + u8* all_deleted; | ||
| 1675 | + u8* keys; | ||
| 1676 | + u8* values; | ||
| 1677 | +}; | ||
| 1678 | + | ||
| 1679 | +struct map { | ||
| 1680 | + int key_bytes; | ||
| 1681 | + int value_bytes; | ||
| 1682 | + u32 even_index; | ||
| 1683 | + u8 cached_hashbits; | ||
| 1684 | + u8 shift; | ||
| 1685 | + DenseArray key_values; | ||
| 1686 | + u32* metas; | ||
| 1687 | + u32 extra_metas; | ||
| 1688 | + bool has_string_keys; | ||
| 1689 | + MapHashFn hash_fn; | ||
| 1690 | + MapEqFn key_eq_fn; | ||
| 1691 | + MapCloneFn clone_fn; | ||
| 1692 | + MapFreeFn free_fn; | ||
| 1693 | + int len; | ||
| 1694 | +}; | ||
| 1695 | + | ||
| 1696 | +struct Error { | ||
| 1697 | + E_STRUCT_DECL; | ||
| 1698 | +}; | ||
| 1699 | + | ||
| 1700 | +struct _option { | ||
| 1701 | + u8 state; | ||
| 1702 | + IError err; | ||
| 1703 | +}; | ||
| 1704 | + | ||
| 1705 | +struct _result { | ||
| 1706 | + bool is_error; | ||
| 1707 | + IError err; | ||
| 1708 | +}; | ||
| 1709 | +typedef array Array_string; | ||
| 1710 | +typedef array Array_u8; | ||
| 1711 | +typedef array Array_voidptr; | ||
| 1712 | +typedef array Array_int; | ||
| 1713 | +typedef array Array_IError; | ||
| 1714 | +typedef array Array_rune; | ||
| 1715 | +typedef string Array_fixed_string_11 [11]; | ||
| 1716 | +typedef voidptr Array_fixed_voidptr_11 [11]; | ||
| 1717 | +typedef array Array_RepIndex; | ||
| 1718 | +typedef map Map_string_int; | ||
| 1719 | +typedef array Array_bool; | ||
| 1720 | +typedef array Array_builtin__closure__ClosureLifetimeRecord; | ||
| 1721 | +typedef array Array_builtin__closure__ClosureLifetimeFrame; | ||
| 1722 | +typedef map Map_voidptr_builtin__closure__ClosureLiveInfo; | ||
| 1723 | +typedef map Map_u64_builtin__closure__ClosureLifetimeState_ptr; | ||
| 1724 | +typedef u8 Array_fixed_u8_128 [128]; | ||
| 1725 | +typedef u8 Array_fixed_u8_32 [32]; | ||
| 1726 | +typedef u8 Array_fixed_u8_64 [64]; | ||
| 1727 | +typedef u8 Array_fixed_u8_5 [5]; | ||
| 1728 | +typedef u8 Array_fixed_u8_20 [20]; | ||
| 1729 | +typedef u8 Array_fixed_u8_15 [15]; | ||
| 1730 | +typedef u8 Array_fixed_u8_6 [6]; | ||
| 1731 | +typedef u8 Array_fixed_u8_256 [256]; | ||
| 1732 | +typedef u64 Array_fixed_u64_309 [309]; | ||
| 1733 | +typedef u64 Array_fixed_u64_324 [324]; | ||
| 1734 | +typedef u32 Array_fixed_u32_10 [10]; | ||
| 1735 | +typedef u64 Array_fixed_u64_20 [20]; | ||
| 1736 | +typedef u64 Array_fixed_u64_584 [584]; | ||
| 1737 | +typedef u64 Array_fixed_u64_652 [652]; | ||
| 1738 | +typedef f64 Array_fixed_f64_36 [36]; | ||
| 1739 | +typedef u8 Array_fixed_u8_26 [26]; | ||
| 1740 | +typedef u8 Array_fixed_u8_512 [512]; | ||
| 1741 | +typedef u64 Array_fixed_u64_47 [47]; | ||
| 1742 | +typedef u64 Array_fixed_u64_31 [31]; | ||
| 1743 | +typedef int Array_fixed_int_64 [64]; | ||
| 1744 | +typedef voidptr Array_fixed_voidptr_64 [64]; | ||
| 1745 | +typedef voidptr Array_fixed_voidptr_100 [100]; | ||
| 1746 | +typedef u8 Array_fixed_u8_1000 [1000]; | ||
| 1747 | +typedef array Array_GraphemeBreakProperty; | ||
| 1748 | +typedef u8 Array_fixed_u8_17 [17]; | ||
| 1749 | +typedef i32 Array_fixed_i32_1264 [1264]; | ||
| 1750 | +typedef int Array_fixed_int_10 [10]; | ||
| 1751 | +typedef int Array_fixed_int_20 [20]; | ||
| 1752 | +typedef array Array_StrIntpType; | ||
| 1753 | +typedef Array_u8 strings__Builder; | ||
| 1754 | +typedef bool (*anon_fn_voidptr__bool)(voidptr); | ||
| 1755 | +typedef voidptr (*anon_fn_voidptr__voidptr)(voidptr); | ||
| 1756 | +typedef int (*anon_fn_voidptr_voidptr__int)(voidptr,voidptr); | ||
| 1757 | +typedef int (*FnSortCB)(const void*,const void*); | ||
| 1758 | +typedef void (*FnExitCb)(); | ||
| 1759 | +typedef void (*FnGC_WarnCB)(char*,usize); | ||
| 1760 | +typedef voidptr (*builtin__closure__ClosureGetDataFn)(); | ||
| 1761 | +typedef void (*builtin__closure__ClosureInitFn)(); | ||
| 1762 | +typedef void (*anon_fn_)(); | ||
| 1763 | +// #start sorted_symbols | ||
| 1764 | +struct none { | ||
| 1765 | + E_STRUCT_DECL; | ||
| 1766 | +}; | ||
| 1767 | + | ||
| 1768 | +struct None__ { | ||
| 1769 | + Error Error; | ||
| 1770 | +}; | ||
| 1771 | + | ||
| 1772 | +struct InputRuneIterator { | ||
| 1773 | + E_STRUCT_DECL; | ||
| 1774 | +}; | ||
| 1775 | + | ||
| 1776 | +struct GCHeapUsage { | ||
| 1777 | + usize heap_size; | ||
| 1778 | + usize free_bytes; | ||
| 1779 | + usize total_bytes; | ||
| 1780 | + usize unmapped_bytes; | ||
| 1781 | + usize bytes_since_gc; | ||
| 1782 | +}; | ||
| 1783 | + | ||
| 1784 | +struct ArrayDataHeader { | ||
| 1785 | + bool has_slices; | ||
| 1786 | +}; | ||
| 1787 | + | ||
| 1788 | +struct MessageError { | ||
| 1789 | + string msg; | ||
| 1790 | + int code; | ||
| 1791 | +}; | ||
| 1792 | + | ||
| 1793 | +union strconv__Float64u { | ||
| 1794 | + f64 f; | ||
| 1795 | + u64 u; | ||
| 1796 | +}; | ||
| 1797 | + | ||
| 1798 | +union strconv__Float32u { | ||
| 1799 | + f32 f; | ||
| 1800 | + u32 u; | ||
| 1801 | +}; | ||
| 1802 | + | ||
| 1803 | +struct GraphemeState { | ||
| 1804 | + GraphemeBreakProperty prev_prop; | ||
| 1805 | + int ri_count; | ||
| 1806 | + u8 extended_pictographic_state; | ||
| 1807 | +}; | ||
| 1808 | + | ||
| 1809 | +struct VAssertMetaInfo { | ||
| 1810 | + string fpath; | ||
| 1811 | + int line_nr; | ||
| 1812 | + string fn_name; | ||
| 1813 | + string src; | ||
| 1814 | + string op; | ||
| 1815 | + string llabel; | ||
| 1816 | + string rlabel; | ||
| 1817 | + string lvalue; | ||
| 1818 | + string rvalue; | ||
| 1819 | + string message; | ||
| 1820 | + bool has_msg; | ||
| 1821 | +}; | ||
| 1822 | + | ||
| 1823 | +struct SortedMap { | ||
| 1824 | + int value_bytes; | ||
| 1825 | + mapnode* root; | ||
| 1826 | + int len; | ||
| 1827 | +}; | ||
| 1828 | + | ||
| 1829 | +struct RepIndex { | ||
| 1830 | + int idx; | ||
| 1831 | + int val_idx; | ||
| 1832 | +}; | ||
| 1833 | + | ||
| 1834 | +struct WrapConfig { | ||
| 1835 | + int width; | ||
| 1836 | + string end; | ||
| 1837 | +}; | ||
| 1838 | + | ||
| 1839 | +struct RunesIterator { | ||
| 1840 | + string s; | ||
| 1841 | + int i; | ||
| 1842 | +}; | ||
| 1843 | + | ||
| 1844 | +union StrIntpMem { | ||
| 1845 | + u32 d_c; | ||
| 1846 | + u8 d_u8; | ||
| 1847 | + i8 d_i8; | ||
| 1848 | + u16 d_u16; | ||
| 1849 | + i16 d_i16; | ||
| 1850 | + u32 d_u32; | ||
| 1851 | + i32 d_i32; | ||
| 1852 | + u64 d_u64; | ||
| 1853 | + i64 d_i64; | ||
| 1854 | + f32 d_f32; | ||
| 1855 | + f64 d_f64; | ||
| 1856 | + string d_s; | ||
| 1857 | + string d_r; | ||
| 1858 | + voidptr d_p; | ||
| 1859 | + voidptr d_vp; | ||
| 1860 | +}; | ||
| 1861 | + | ||
| 1862 | +struct strconv__BF_param { | ||
| 1863 | + u8 pad_ch; | ||
| 1864 | + int len0; | ||
| 1865 | + int len1; | ||
| 1866 | + bool positive; | ||
| 1867 | + bool sign_flag; | ||
| 1868 | + strconv__Align_text align; | ||
| 1869 | + bool rm_tail_zero; | ||
| 1870 | +}; | ||
| 1871 | + | ||
| 1872 | +struct ToWideConfig { | ||
| 1873 | + bool from_ansi; | ||
| 1874 | +}; | ||
| 1875 | + | ||
| 1876 | +struct strings__IndentParam { | ||
| 1877 | + rune block_start; | ||
| 1878 | + rune block_end; | ||
| 1879 | + rune indent_char; | ||
| 1880 | + int indent_count; | ||
| 1881 | + int starting_level; | ||
| 1882 | +}; | ||
| 1883 | + | ||
| 1884 | +struct strconv__PrepNumber { | ||
| 1885 | + bool negative; | ||
| 1886 | + int exponent; | ||
| 1887 | + u64 mantissa; | ||
| 1888 | +}; | ||
| 1889 | + | ||
| 1890 | +struct strconv__AtoF64Param { | ||
| 1891 | + bool allow_extra_chars; | ||
| 1892 | +}; | ||
| 1893 | + | ||
| 1894 | +struct strconv__Dec32 { | ||
| 1895 | + u32 m; | ||
| 1896 | + int e; | ||
| 1897 | +}; | ||
| 1898 | + | ||
| 1899 | +union strconv__Uf32 { | ||
| 1900 | + f32 f; | ||
| 1901 | + u32 u; | ||
| 1902 | +}; | ||
| 1903 | + | ||
| 1904 | +struct strconv__Dec64 { | ||
| 1905 | + u64 m; | ||
| 1906 | + int e; | ||
| 1907 | +}; | ||
| 1908 | + | ||
| 1909 | +struct strconv__Uint128 { | ||
| 1910 | + u64 lo; | ||
| 1911 | + u64 hi; | ||
| 1912 | +}; | ||
| 1913 | + | ||
| 1914 | +union strconv__Uf64 { | ||
| 1915 | + f64 f; | ||
| 1916 | + u64 u; | ||
| 1917 | +}; | ||
| 1918 | + | ||
| 1919 | +struct builtin__closure__ClosurePage { | ||
| 1920 | + builtin__closure__ClosurePage* next; | ||
| 1921 | + voidptr exec_page_start; | ||
| 1922 | +}; | ||
| 1923 | + | ||
| 1924 | +struct builtin__closure__ClosureLiveInfo { | ||
| 1925 | + voidptr ctx; | ||
| 1926 | + bool owns_data; | ||
| 1927 | + u64 generation; | ||
| 1928 | +}; | ||
| 1929 | + | ||
| 1930 | +struct builtin__closure__ClosureLifetimeRecord { | ||
| 1931 | + voidptr exec_ptr; | ||
| 1932 | + u64 generation; | ||
| 1933 | +}; | ||
| 1934 | + | ||
| 1935 | +struct builtin__closure__ClosureLifetimeFrame { | ||
| 1936 | + int start; | ||
| 1937 | + int end; | ||
| 1938 | +}; | ||
| 1939 | + | ||
| 1940 | +struct builtin__closure__ClosureLifetimeState { | ||
| 1941 | + u64 owner_thread; | ||
| 1942 | + bool active; | ||
| 1943 | + bool disposed; | ||
| 1944 | + int suspended; | ||
| 1945 | + int frame_start; | ||
| 1946 | + u64 frame_gen; | ||
| 1947 | + u64 generation; | ||
| 1948 | + u64 frame_generation; | ||
| 1949 | + Array_builtin__closure__ClosureLifetimeRecord records; | ||
| 1950 | + Array_builtin__closure__ClosureLifetimeFrame frames; | ||
| 1951 | + builtin__closure__ClosureLifetimeState* next_free; | ||
| 1952 | +}; | ||
| 1953 | + | ||
| 1954 | +struct builtin__closure__Lifetime { | ||
| 1955 | + builtin__closure__ClosureLifetimeState* state; | ||
| 1956 | + u64 generation; | ||
| 1957 | + bool disposed; | ||
| 1958 | +}; | ||
| 1959 | + | ||
| 1960 | +struct builtin__closure__FrameToken { | ||
| 1961 | + builtin__closure__ClosureLifetimeState* state; | ||
| 1962 | + u64 thread_id; | ||
| 1963 | + u64 state_generation; | ||
| 1964 | + u64 generation; | ||
| 1965 | +}; | ||
| 1966 | + | ||
| 1967 | +struct mapnode { | ||
| 1968 | + voidptr* children; | ||
| 1969 | + int len; | ||
| 1970 | + Array_fixed_string_11 keys; | ||
| 1971 | + Array_fixed_voidptr_11 values; | ||
| 1972 | +}; | ||
| 1973 | + | ||
| 1974 | +struct StrIntpData { | ||
| 1975 | + string str; | ||
| 1976 | + u32 fmt; | ||
| 1977 | + StrIntpMem d; | ||
| 1978 | + int dyn_width; | ||
| 1979 | + int dyn_precision; | ||
| 1980 | + u8 dyn_flags; | ||
| 1981 | +}; | ||
| 1982 | + | ||
| 1983 | +struct builtin__closure__ClosureMutex { | ||
| 1984 | + Array_fixed_u8_128 closure_mtx; | ||
| 1985 | +}; | ||
| 1986 | + | ||
| 1987 | +struct builtin__closure__Closure { | ||
| 1988 | + builtin__closure__ClosureMutex ClosureMutex; | ||
| 1989 | + voidptr closure_ptr; | ||
| 1990 | + builtin__closure__ClosureGetDataFn closure_get_data; | ||
| 1991 | + int closure_cap; | ||
| 1992 | + voidptr free_closure_ptr; | ||
| 1993 | + builtin__closure__ClosurePage* pages; | ||
| 1994 | + int v_page_size; | ||
| 1995 | + Map_voidptr_builtin__closure__ClosureLiveInfo live; | ||
| 1996 | + Map_u64_builtin__closure__ClosureLifetimeState_ptr active_lifetimes; | ||
| 1997 | + u64 next_generation; | ||
| 1998 | + builtin__closure__ClosureLifetimeState* free_lifetime_states; | ||
| 1999 | + u64 next_lifetime_generation; | ||
| 2000 | + u64 lifetime_state_allocs; | ||
| 2001 | +}; | ||
| 2002 | +// #end sorted_symbols | ||
| 2003 | + | ||
| 2004 | +// BEGIN_array_fixed_return_structs | ||
| 2005 | +struct _v_Array_fixed_string_11 { | ||
| 2006 | + string ret_arr[11]; | ||
| 2007 | +}; | ||
| 2008 | +struct _v_Array_fixed_voidptr_11 { | ||
| 2009 | + voidptr ret_arr[11]; | ||
| 2010 | +}; | ||
| 2011 | +struct _v_Array_fixed_u8_128 { | ||
| 2012 | + u8 ret_arr[128]; | ||
| 2013 | +}; | ||
| 2014 | +struct _v_Array_fixed_u8_32 { | ||
| 2015 | + u8 ret_arr[32]; | ||
| 2016 | +}; | ||
| 2017 | +struct _v_Array_fixed_u8_64 { | ||
| 2018 | + u8 ret_arr[64]; | ||
| 2019 | +}; | ||
| 2020 | +struct _v_Array_fixed_u8_5 { | ||
| 2021 | + u8 ret_arr[5]; | ||
| 2022 | +}; | ||
| 2023 | +struct _v_Array_fixed_u8_20 { | ||
| 2024 | + u8 ret_arr[20]; | ||
| 2025 | +}; | ||
| 2026 | +struct _v_Array_fixed_u8_15 { | ||
| 2027 | + u8 ret_arr[15]; | ||
| 2028 | +}; | ||
| 2029 | +struct _v_Array_fixed_u8_6 { | ||
| 2030 | + u8 ret_arr[6]; | ||
| 2031 | +}; | ||
| 2032 | +struct _v_Array_fixed_u8_256 { | ||
| 2033 | + u8 ret_arr[256]; | ||
| 2034 | +}; | ||
| 2035 | +struct _v_Array_fixed_u64_309 { | ||
| 2036 | + u64 ret_arr[309]; | ||
| 2037 | +}; | ||
| 2038 | +struct _v_Array_fixed_u64_324 { | ||
| 2039 | + u64 ret_arr[324]; | ||
| 2040 | +}; | ||
| 2041 | +struct _v_Array_fixed_u32_10 { | ||
| 2042 | + u32 ret_arr[10]; | ||
| 2043 | +}; | ||
| 2044 | +struct _v_Array_fixed_u64_20 { | ||
| 2045 | + u64 ret_arr[20]; | ||
| 2046 | +}; | ||
| 2047 | +struct _v_Array_fixed_u64_584 { | ||
| 2048 | + u64 ret_arr[584]; | ||
| 2049 | +}; | ||
| 2050 | +struct _v_Array_fixed_u64_652 { | ||
| 2051 | + u64 ret_arr[652]; | ||
| 2052 | +}; | ||
| 2053 | +struct _v_Array_fixed_f64_36 { | ||
| 2054 | + f64 ret_arr[36]; | ||
| 2055 | +}; | ||
| 2056 | +struct _v_Array_fixed_u8_26 { | ||
| 2057 | + u8 ret_arr[26]; | ||
| 2058 | +}; | ||
| 2059 | +struct _v_Array_fixed_u8_512 { | ||
| 2060 | + u8 ret_arr[512]; | ||
| 2061 | +}; | ||
| 2062 | +struct _v_Array_fixed_u64_47 { | ||
| 2063 | + u64 ret_arr[47]; | ||
| 2064 | +}; | ||
| 2065 | +struct _v_Array_fixed_u64_31 { | ||
| 2066 | + u64 ret_arr[31]; | ||
| 2067 | +}; | ||
| 2068 | +struct _v_Array_fixed_int_64 { | ||
| 2069 | + int ret_arr[64]; | ||
| 2070 | +}; | ||
| 2071 | +struct _v_Array_fixed_voidptr_64 { | ||
| 2072 | + voidptr ret_arr[64]; | ||
| 2073 | +}; | ||
| 2074 | +struct _v_Array_fixed_voidptr_100 { | ||
| 2075 | + voidptr ret_arr[100]; | ||
| 2076 | +}; | ||
| 2077 | +struct _v_Array_fixed_u8_1000 { | ||
| 2078 | + u8 ret_arr[1000]; | ||
| 2079 | +}; | ||
| 2080 | +struct _v_Array_fixed_u8_17 { | ||
| 2081 | + u8 ret_arr[17]; | ||
| 2082 | +}; | ||
| 2083 | +struct _v_Array_fixed_i32_1264 { | ||
| 2084 | + i32 ret_arr[1264]; | ||
| 2085 | +}; | ||
| 2086 | +struct _v_Array_fixed_int_10 { | ||
| 2087 | + int ret_arr[10]; | ||
| 2088 | +}; | ||
| 2089 | +struct _v_Array_fixed_int_20 { | ||
| 2090 | + int ret_arr[20]; | ||
| 2091 | +}; | ||
| 2092 | +// END_array_fixed_return_structs | ||
| 2093 | + | ||
| 2094 | + | ||
| 2095 | +// BEGIN_multi_return_structs | ||
| 2096 | +struct multi_return_u32_u32 { | ||
| 2097 | + u32 arg0; | ||
| 2098 | + u32 arg1; | ||
| 2099 | +}; | ||
| 2100 | + | ||
| 2101 | +struct multi_return_string_string { | ||
| 2102 | + string arg0; | ||
| 2103 | + string arg1; | ||
| 2104 | +}; | ||
| 2105 | + | ||
| 2106 | +struct multi_return_int_int { | ||
| 2107 | + int arg0; | ||
| 2108 | + int arg1; | ||
| 2109 | +}; | ||
| 2110 | + | ||
| 2111 | +struct multi_return_rune_int { | ||
| 2112 | + rune arg0; | ||
| 2113 | + int arg1; | ||
| 2114 | +}; | ||
| 2115 | + | ||
| 2116 | +struct multi_return_u32_u32_u32 { | ||
| 2117 | + u32 arg0; | ||
| 2118 | + u32 arg1; | ||
| 2119 | + u32 arg2; | ||
| 2120 | +}; | ||
| 2121 | + | ||
| 2122 | +struct multi_return_strconv__ParserState_strconv__PrepNumber { | ||
| 2123 | + strconv__ParserState arg0; | ||
| 2124 | + strconv__PrepNumber arg1; | ||
| 2125 | +}; | ||
| 2126 | + | ||
| 2127 | +struct multi_return_u64_int { | ||
| 2128 | + u64 arg0; | ||
| 2129 | + int arg1; | ||
| 2130 | +}; | ||
| 2131 | + | ||
| 2132 | +struct multi_return_i64_int { | ||
| 2133 | + i64 arg0; | ||
| 2134 | + int arg1; | ||
| 2135 | +}; | ||
| 2136 | + | ||
| 2137 | +struct multi_return_strconv__Dec32_bool { | ||
| 2138 | + strconv__Dec32 arg0; | ||
| 2139 | + bool arg1; | ||
| 2140 | +}; | ||
| 2141 | + | ||
| 2142 | +struct multi_return_strconv__Dec64_bool { | ||
| 2143 | + strconv__Dec64 arg0; | ||
| 2144 | + bool arg1; | ||
| 2145 | +}; | ||
| 2146 | + | ||
| 2147 | +struct multi_return_u64_u64 { | ||
| 2148 | + u64 arg0; | ||
| 2149 | + u64 arg1; | ||
| 2150 | +}; | ||
| 2151 | + | ||
| 2152 | +struct multi_return_f64_int { | ||
| 2153 | + f64 arg0; | ||
| 2154 | + int arg1; | ||
| 2155 | +}; | ||
| 2156 | + | ||
| 2157 | +// END_multi_return_structs | ||
| 2158 | + | ||
| 2159 | +static bool Array_u8_contains(Array_u8 a, u8 v); | ||
| 2160 | + | ||
| 2161 | +// V Option_xxx definitions: | ||
| 2162 | +struct _option_builtin__closure__ClosureLiveInfo { | ||
| 2163 | + byte state; | ||
| 2164 | + IError err; | ||
| 2165 | + byte data[sizeof(builtin__closure__ClosureLiveInfo) > 1 ? sizeof(builtin__closure__ClosureLiveInfo) : 1]; | ||
| 2166 | +}; | ||
| 2167 | + | ||
| 2168 | +struct _option_builtin__closure__ClosureLifetimeState_ptr { | ||
| 2169 | + byte state; | ||
| 2170 | + IError err; | ||
| 2171 | + byte data[sizeof(builtin__closure__ClosureLifetimeState*) > 1 ? sizeof(builtin__closure__ClosureLifetimeState*) : 1]; | ||
| 2172 | +}; | ||
| 2173 | + | ||
| 2174 | +struct _option_int { | ||
| 2175 | + byte state; | ||
| 2176 | + IError err; | ||
| 2177 | + byte data[sizeof(int) > 1 ? sizeof(int) : 1]; | ||
| 2178 | +}; | ||
| 2179 | + | ||
| 2180 | +struct _option_rune { | ||
| 2181 | + byte state; | ||
| 2182 | + IError err; | ||
| 2183 | + byte data[sizeof(rune) > 1 ? sizeof(rune) : 1]; | ||
| 2184 | +}; | ||
| 2185 | + | ||
| 2186 | +struct _option_multi_return_string_string { | ||
| 2187 | + byte state; | ||
| 2188 | + IError err; | ||
| 2189 | + byte data[sizeof(multi_return_string_string) > 1 ? sizeof(multi_return_string_string) : 1]; | ||
| 2190 | +}; | ||
| 2191 | + | ||
| 2192 | +struct _option_u8 { | ||
| 2193 | + byte state; | ||
| 2194 | + IError err; | ||
| 2195 | + byte data[sizeof(u8) > 1 ? sizeof(u8) : 1]; | ||
| 2196 | +}; | ||
| 2197 | + | ||
| 2198 | + | ||
| 2199 | +// V result_xxx definitions: | ||
| 2200 | +struct _result_int { | ||
| 2201 | + bool is_error; | ||
| 2202 | + IError err; | ||
| 2203 | + byte data[sizeof(int) > 1 ? sizeof(int) : 1]; | ||
| 2204 | +}; | ||
| 2205 | + | ||
| 2206 | +struct _result_builtin__closure__ClosureLifetimeState_ptr { | ||
| 2207 | + bool is_error; | ||
| 2208 | + IError err; | ||
| 2209 | + byte data[sizeof(builtin__closure__ClosureLifetimeState*) > 1 ? sizeof(builtin__closure__ClosureLifetimeState*) : 1]; | ||
| 2210 | +}; | ||
| 2211 | + | ||
| 2212 | +struct _result_builtin__closure__FrameToken { | ||
| 2213 | + bool is_error; | ||
| 2214 | + IError err; | ||
| 2215 | + byte data[sizeof(builtin__closure__FrameToken) > 1 ? sizeof(builtin__closure__FrameToken) : 1]; | ||
| 2216 | +}; | ||
| 2217 | + | ||
| 2218 | +struct _result_void { | ||
| 2219 | + bool is_error; | ||
| 2220 | + IError err; | ||
| 2221 | + byte data[sizeof(u8) > 1 ? sizeof(u8) : 1]; | ||
| 2222 | +}; | ||
| 2223 | + | ||
| 2224 | +struct _result_f64 { | ||
| 2225 | + bool is_error; | ||
| 2226 | + IError err; | ||
| 2227 | + byte data[sizeof(f64) > 1 ? sizeof(f64) : 1]; | ||
| 2228 | +}; | ||
| 2229 | + | ||
| 2230 | +struct _result_u64 { | ||
| 2231 | + bool is_error; | ||
| 2232 | + IError err; | ||
| 2233 | + byte data[sizeof(u64) > 1 ? sizeof(u64) : 1]; | ||
| 2234 | +}; | ||
| 2235 | + | ||
| 2236 | +struct _result_i64 { | ||
| 2237 | + bool is_error; | ||
| 2238 | + IError err; | ||
| 2239 | + byte data[sizeof(i64) > 1 ? sizeof(i64) : 1]; | ||
| 2240 | +}; | ||
| 2241 | + | ||
| 2242 | +struct _result_multi_return_i64_int { | ||
| 2243 | + bool is_error; | ||
| 2244 | + IError err; | ||
| 2245 | + byte data[sizeof(multi_return_i64_int) > 1 ? sizeof(multi_return_i64_int) : 1]; | ||
| 2246 | +}; | ||
| 2247 | + | ||
| 2248 | +struct _result_i8 { | ||
| 2249 | + bool is_error; | ||
| 2250 | + IError err; | ||
| 2251 | + byte data[sizeof(i8) > 1 ? sizeof(i8) : 1]; | ||
| 2252 | +}; | ||
| 2253 | + | ||
| 2254 | +struct _result_i16 { | ||
| 2255 | + bool is_error; | ||
| 2256 | + IError err; | ||
| 2257 | + byte data[sizeof(i16) > 1 ? sizeof(i16) : 1]; | ||
| 2258 | +}; | ||
| 2259 | + | ||
| 2260 | +struct _result_i32 { | ||
| 2261 | + bool is_error; | ||
| 2262 | + IError err; | ||
| 2263 | + byte data[sizeof(i32) > 1 ? sizeof(i32) : 1]; | ||
| 2264 | +}; | ||
| 2265 | + | ||
| 2266 | +struct _result_u8 { | ||
| 2267 | + bool is_error; | ||
| 2268 | + IError err; | ||
| 2269 | + byte data[sizeof(u8) > 1 ? sizeof(u8) : 1]; | ||
| 2270 | +}; | ||
| 2271 | + | ||
| 2272 | +struct _result_u16 { | ||
| 2273 | + bool is_error; | ||
| 2274 | + IError err; | ||
| 2275 | + byte data[sizeof(u16) > 1 ? sizeof(u16) : 1]; | ||
| 2276 | +}; | ||
| 2277 | + | ||
| 2278 | +struct _result_u32 { | ||
| 2279 | + bool is_error; | ||
| 2280 | + IError err; | ||
| 2281 | + byte data[sizeof(u32) > 1 ? sizeof(u32) : 1]; | ||
| 2282 | +}; | ||
| 2283 | + | ||
| 2284 | +struct _result_rune { | ||
| 2285 | + bool is_error; | ||
| 2286 | + IError err; | ||
| 2287 | + byte data[sizeof(rune) > 1 ? sizeof(rune) : 1]; | ||
| 2288 | +}; | ||
| 2289 | + | ||
| 2290 | +struct _result_string { | ||
| 2291 | + bool is_error; | ||
| 2292 | + IError err; | ||
| 2293 | + byte data[sizeof(string) > 1 ? sizeof(string) : 1]; | ||
| 2294 | +}; | ||
| 2295 | + | ||
| 2296 | + | ||
| 2297 | +// V definitions: | ||
| 2298 | +static char * v_typeof_interface_IError(u32 sidx); | ||
| 2299 | +u32 v_typeof_interface_idx_IError(u32 sidx); | ||
| 2300 | +// end of definitions #endif | ||
| 2301 | +strings__Builder strings__new_builder(int initial_size); | ||
| 2302 | +Array_u8 strings__Builder_reuse_as_plain_u8_array(strings__Builder* b); | ||
| 2303 | +void strings__Builder_write_ptr(strings__Builder* b, u8* ptr, int len); | ||
| 2304 | +void strings__Builder_write_rune(strings__Builder* b, rune r); | ||
| 2305 | +void strings__Builder_write_runes(strings__Builder* b, Array_rune runes); | ||
| 2306 | +void strings__Builder_write_u8(strings__Builder* b, u8 data); | ||
| 2307 | +void strings__Builder_write_byte(strings__Builder* b, u8 data); | ||
| 2308 | +void strings__Builder_write_decimal(strings__Builder* b, i64 n); | ||
| 2309 | +void strings__Builder_write_u_decimal(strings__Builder* b, u64 n); | ||
| 2310 | +_result_int strings__Builder_write(strings__Builder* b, Array_u8 data); | ||
| 2311 | +void strings__Builder_drain_builder(strings__Builder* b, strings__Builder* other, int other_new_cap); | ||
| 2312 | +u8 strings__Builder_byte_at(strings__Builder* b, int n); | ||
| 2313 | +void strings__Builder_write_string(strings__Builder* b, string s); | ||
| 2314 | +void strings__Builder_write_string2(strings__Builder* b, string s1, string s2); | ||
| 2315 | +void strings__Builder_go_back(strings__Builder* b, int n); | ||
| 2316 | +string strings__Builder_spart(strings__Builder* b, int start_pos, int n); | ||
| 2317 | +string strings__Builder_cut_last(strings__Builder* b, int n); | ||
| 2318 | +string strings__Builder_cut_to(strings__Builder* b, int pos); | ||
| 2319 | +void strings__Builder_go_back_to(strings__Builder* b, int pos); | ||
| 2320 | +void strings__Builder_writeln(strings__Builder* b, string s); | ||
| 2321 | +void strings__Builder_writeln2(strings__Builder* b, string s1, string s2); | ||
| 2322 | +string strings__Builder_last_n(strings__Builder* b, int n); | ||
| 2323 | +string strings__Builder_after(strings__Builder* b, int n); | ||
| 2324 | +string strings__Builder_str(strings__Builder* b); | ||
| 2325 | +void strings__Builder_ensure_cap(strings__Builder* b, int n); | ||
| 2326 | +void strings__Builder_grow_len(strings__Builder* b, int n); | ||
| 2327 | +void strings__Builder_free(strings__Builder* b); | ||
| 2328 | +void strings__Builder_write_repeated_rune(strings__Builder* b, rune r, int count); | ||
| 2329 | +void strings__Builder_indent(strings__Builder* b, string s, strings__IndentParam param); | ||
| 2330 | +VV_LOC int strings__min(int a, int b, int c); | ||
| 2331 | +VV_LOC int strings__max2(int a, int b); | ||
| 2332 | +VV_LOC int strings__min2(int a, int b); | ||
| 2333 | +VV_LOC int strings__abs2(int a, int b); | ||
| 2334 | +int strings__levenshtein_distance(string a, string b); | ||
| 2335 | +f32 strings__levenshtein_distance_percentage(string a, string b); | ||
| 2336 | +f32 strings__dice_coefficient(string s1, string s2); | ||
| 2337 | +int strings__hamming_distance(string a, string b); | ||
| 2338 | +f32 strings__hamming_similarity(string a, string b); | ||
| 2339 | +f64 strings__jaro_similarity(string a, string b); | ||
| 2340 | +f64 strings__jaro_winkler_similarity(string a, string b); | ||
| 2341 | +string strings__repeat(u8 c, int n); | ||
| 2342 | +string strings__repeat_string(string s, int n); | ||
| 2343 | +string strings__find_between_pair_u8(string input, u8 start, u8 end); | ||
| 2344 | +string strings__find_between_pair_rune(string input, rune start, rune end); | ||
| 2345 | +string strings__find_between_pair_string(string input, string start, string end); | ||
| 2346 | +Array_string strings__split_capital(string s); | ||
| 2347 | +VV_LOC bool builtin__closure__is_ppc64(void); | ||
| 2348 | +VV_LOC voidptr* builtin__closure__closure_slot_meta(voidptr exec_ptr); | ||
| 2349 | +VV_LOC void builtin__closure__closure_register_page(voidptr exec_page_start); | ||
| 2350 | +VV_LOC bool builtin__closure__closure_is_managed(voidptr exec_ptr); | ||
| 2351 | +VV_LOC builtin__closure__ClosureLiveInfo builtin__closure__closure_live_delete(voidptr exec_ptr); | ||
| 2352 | +VV_LOC builtin__closure__ClosureLifetimeState* builtin__closure__new_closure_lifetime_state_no_lock(void); | ||
| 2353 | +VV_LOC builtin__closure__ClosureLifetimeState* builtin__closure__new_closure_lifetime_state(void); | ||
| 2354 | +VV_LOC void builtin__closure__closure_lifetime_recycle_state_no_lock(builtin__closure__ClosureLifetimeState** state); | ||
| 2355 | +VV_LOC string builtin__closure__closure_lifetime_error(builtin__closure__ClosureLifetimeState* state, u64 generation, u64 thread_id); | ||
| 2356 | +VV_LOC _result_builtin__closure__ClosureLifetimeState_ptr builtin__closure__Lifetime_ensure_state(builtin__closure__Lifetime* lifetime); | ||
| 2357 | +VV_LOC voidptr builtin__closure__closure_slot_data(voidptr exec_ptr); | ||
| 2358 | +VV_LOC bool builtin__closure__closure_release_no_lock(voidptr exec_ptr, u64 generation); | ||
| 2359 | +VV_LOC void builtin__closure__closure_lifetime_release_records_no_lock(Array_builtin__closure__ClosureLifetimeRecord records, int start, int end); | ||
| 2360 | +VV_LOC void builtin__closure__closure_lifetime_reclaim_no_lock(builtin__closure__ClosureLifetimeState* state, int retain); | ||
| 2361 | +VV_LOC void builtin__closure__closure_ensure_initialized(void); | ||
| 2362 | +builtin__closure__Lifetime builtin__closure__new_lifetime(void); | ||
| 2363 | +VV_LOC _result_builtin__closure__FrameToken builtin__closure__Lifetime_begin_frame(builtin__closure__Lifetime* lifetime); | ||
| 2364 | +VV_LOC _result_void builtin__closure__Lifetime_end_frame(builtin__closure__Lifetime* lifetime, builtin__closure__FrameToken token); | ||
| 2365 | +_result_void builtin__closure__Lifetime_frame(builtin__closure__Lifetime* lifetime, void (*work)()); | ||
| 2366 | +_result_void builtin__closure__Lifetime_reclaim(builtin__closure__Lifetime* lifetime, int retain); | ||
| 2367 | +_result_void builtin__closure__Lifetime_reclaim_all(builtin__closure__Lifetime* lifetime); | ||
| 2368 | +_result_void builtin__closure__Lifetime_dispose(builtin__closure__Lifetime* lifetime); | ||
| 2369 | +_result_void builtin__closure__Lifetime_suspend(builtin__closure__Lifetime* lifetime, void (*work)()); | ||
| 2370 | +_result_void builtin__closure__Lifetime_untracked(builtin__closure__Lifetime* lifetime, void (*work)()); | ||
| 2371 | +VV_LOC void builtin__closure__closure_alloc(void); | ||
| 2372 | +VV_LOC void builtin__closure__closure_init_body(void); | ||
| 2373 | +VV_LOC voidptr builtin__closure__closure_mtx_ptr_platform(void); | ||
| 2374 | +VV_LOC u8* builtin__closure__closure_alloc_platform(void); | ||
| 2375 | +VV_LOC void builtin__closure__closure_memory_protect_platform(voidptr ptr, isize size, builtin__closure__MemoryProtectAtrr attr); | ||
| 2376 | +VV_LOC int builtin__closure__get_page_size_platform(void); | ||
| 2377 | +VV_LOC void builtin__closure__closure_mtx_lock_init_platform(void); | ||
| 2378 | +VV_LOC void builtin__closure__closure_mtx_lock_platform(void); | ||
| 2379 | +VV_LOC void builtin__closure__closure_mtx_unlock_platform(void); | ||
| 2380 | +VV_LOC u64 builtin__closure__closure_current_thread_id_platform(void); | ||
| 2381 | +VV_LOC void builtin__closure__closure_init_once_platform(void); | ||
| 2382 | +multi_return_u64_u64 math__bits__mul_64(u64 x, u64 y); | ||
| 2383 | +multi_return_u64_u64 math__bits__mul_add_64(u64 x, u64 y, u64 z); | ||
| 2384 | +multi_return_u64_u64 math__bits__div_64(u64 hi, u64 lo, u64 y1); | ||
| 2385 | +int math__bits__leading_zeros_8(u8 x); | ||
| 2386 | +int math__bits__leading_zeros_16(u16 x); | ||
| 2387 | +int math__bits__leading_zeros_32(u32 x); | ||
| 2388 | +int math__bits__leading_zeros_64(u64 x); | ||
| 2389 | +int math__bits__trailing_zeros_8(u8 x); | ||
| 2390 | +int math__bits__trailing_zeros_16(u16 x); | ||
| 2391 | +int math__bits__trailing_zeros_32(u32 x); | ||
| 2392 | +int math__bits__trailing_zeros_64(u64 x); | ||
| 2393 | +int math__bits__ones_count_8(u8 x); | ||
| 2394 | +int math__bits__ones_count_16(u16 x); | ||
| 2395 | +int math__bits__ones_count_32(u32 x); | ||
| 2396 | +int math__bits__ones_count_64(u64 x); | ||
| 2397 | +int math__bits__pure_v_but_overridden_by_c_leading_zeros_8(u8 x); | ||
| 2398 | +VV_LOC int math__bits__leading_zeros_8_default(u8 x); | ||
| 2399 | +int math__bits__pure_v_but_overridden_by_c_leading_zeros_16(u16 x); | ||
| 2400 | +VV_LOC int math__bits__leading_zeros_16_default(u16 x); | ||
| 2401 | +int math__bits__pure_v_but_overridden_by_c_leading_zeros_32(u32 x); | ||
| 2402 | +VV_LOC int math__bits__leading_zeros_32_default(u32 x); | ||
| 2403 | +int math__bits__pure_v_but_overridden_by_c_leading_zeros_64(u64 x); | ||
| 2404 | +VV_LOC int math__bits__leading_zeros_64_default(u64 x); | ||
| 2405 | +int math__bits__pure_v_but_overridden_by_c_trailing_zeros_8(u8 x); | ||
| 2406 | +VV_LOC int math__bits__trailing_zeros_8_default(u8 x); | ||
| 2407 | +int math__bits__pure_v_but_overridden_by_c_trailing_zeros_16(u16 x); | ||
| 2408 | +VV_LOC int math__bits__trailing_zeros_16_default(u16 x); | ||
| 2409 | +int math__bits__pure_v_but_overridden_by_c_trailing_zeros_32(u32 x); | ||
| 2410 | +VV_LOC int math__bits__trailing_zeros_32_default(u32 x); | ||
| 2411 | +int math__bits__pure_v_but_overridden_by_c_trailing_zeros_64(u64 x); | ||
| 2412 | +VV_LOC int math__bits__trailing_zeros_64_default(u64 x); | ||
| 2413 | +int math__bits__pure_v_but_overridden_by_c_ones_count_8(u8 x); | ||
| 2414 | +VV_LOC int math__bits__ones_count_8_default(u8 x); | ||
| 2415 | +int math__bits__pure_v_but_overridden_by_c_ones_count_16(u16 x); | ||
| 2416 | +VV_LOC int math__bits__ones_count_16_default(u16 x); | ||
| 2417 | +int math__bits__pure_v_but_overridden_by_c_ones_count_32(u32 x); | ||
| 2418 | +VV_LOC int math__bits__ones_count_32_default(u32 x); | ||
| 2419 | +int math__bits__pure_v_but_overridden_by_c_ones_count_64(u64 x); | ||
| 2420 | +VV_LOC int math__bits__ones_count_64_default(u64 x); | ||
| 2421 | +u8 math__bits__rotate_left_8(u8 x, int k); | ||
| 2422 | +u16 math__bits__rotate_left_16(u16 x, int k); | ||
| 2423 | +u32 math__bits__rotate_left_32(u32 x, int k); | ||
| 2424 | +u64 math__bits__rotate_left_64(u64 x, int k); | ||
| 2425 | +u8 math__bits__reverse_8(u8 x); | ||
| 2426 | +u16 math__bits__reverse_16(u16 x); | ||
| 2427 | +u32 math__bits__reverse_32(u32 x); | ||
| 2428 | +u64 math__bits__reverse_64(u64 x); | ||
| 2429 | +u16 math__bits__reverse_bytes_16(u16 x); | ||
| 2430 | +u32 math__bits__reverse_bytes_32(u32 x); | ||
| 2431 | +u64 math__bits__reverse_bytes_64(u64 x); | ||
| 2432 | +int math__bits__len_8(u8 x); | ||
| 2433 | +int math__bits__len_16(u16 x); | ||
| 2434 | +int math__bits__len_32(u32 x); | ||
| 2435 | +int math__bits__len_64(u64 x); | ||
| 2436 | +multi_return_u32_u32 math__bits__add_32(u32 x, u32 y, u32 carry); | ||
| 2437 | +multi_return_u64_u64 math__bits__add_64(u64 x, u64 y, u64 carry); | ||
| 2438 | +multi_return_u32_u32 math__bits__sub_32(u32 x, u32 y, u32 borrow); | ||
| 2439 | +multi_return_u64_u64 math__bits__sub_64(u64 x, u64 y, u64 borrow); | ||
| 2440 | +multi_return_u32_u32 math__bits__mul_32(u32 x, u32 y); | ||
| 2441 | +VV_LOC multi_return_u32_u32 math__bits__mul_32_default(u32 x, u32 y); | ||
| 2442 | +multi_return_u64_u64 math__bits__pure_v_but_overridden_by_amd64_mul_64(u64 x, u64 y); | ||
| 2443 | +VV_LOC multi_return_u64_u64 math__bits__mul_64_default(u64 x, u64 y); | ||
| 2444 | +multi_return_u32_u32 math__bits__mul_add_32(u32 x, u32 y, u32 z); | ||
| 2445 | +VV_LOC multi_return_u32_u32 math__bits__mul_add_32_default(u32 x, u32 y, u32 z); | ||
| 2446 | +multi_return_u64_u64 math__bits__pure_v_but_overridden_by_amd64_mul_add_64(u64 x, u64 y, u64 z); | ||
| 2447 | +VV_LOC multi_return_u64_u64 math__bits__mul_add_64_default(u64 x, u64 y, u64 z); | ||
| 2448 | +multi_return_u32_u32 math__bits__div_32(u32 hi, u32 lo, u32 y); | ||
| 2449 | +VV_LOC multi_return_u32_u32 math__bits__div_32_default(u32 hi, u32 lo, u32 y); | ||
| 2450 | +multi_return_u64_u64 math__bits__pure_v_but_overridden_by_amd64_div_64(u64 hi, u64 lo, u64 y1); | ||
| 2451 | +VV_LOC multi_return_u64_u64 math__bits__div_64_default(u64 hi, u64 lo, u64 y1); | ||
| 2452 | +u32 math__bits__rem_32(u32 hi, u32 lo, u32 y); | ||
| 2453 | +u64 math__bits__rem_64(u64 hi, u64 lo, u64 y); | ||
| 2454 | +multi_return_f64_int math__bits__normalize(f64 x); | ||
| 2455 | +u32 math__bits__f32_bits(f32 f); | ||
| 2456 | +f32 math__bits__f32_from_bits(u32 b); | ||
| 2457 | +u64 math__bits__f64_bits(f64 f); | ||
| 2458 | +f64 math__bits__f64_from_bits(u64 b); | ||
| 2459 | +VV_LOC multi_return_u32_u32_u32 strconv__lsr96(u32 s2, u32 s1, u32 s0); | ||
| 2460 | +VV_LOC multi_return_u32_u32_u32 strconv__lsl96(u32 s2, u32 s1, u32 s0); | ||
| 2461 | +VV_LOC multi_return_u32_u32_u32 strconv__add96(u32 s2, u32 s1, u32 s0, u32 d2, u32 d1, u32 d0); | ||
| 2462 | +VV_LOC multi_return_strconv__ParserState_strconv__PrepNumber strconv__parser(string s); | ||
| 2463 | +VV_LOC u64 strconv__converter(strconv__PrepNumber* pn); | ||
| 2464 | +_result_f64 strconv__atof64(string s, strconv__AtoF64Param param); | ||
| 2465 | +f64 strconv__atof_quick(string s); | ||
| 2466 | +u8 strconv__byte_to_lower(u8 c); | ||
| 2467 | +_result_u64 strconv__common_parse_uint(string s, int _base, int _bit_size, bool error_on_non_digit, bool error_on_high_digit); | ||
| 2468 | +multi_return_u64_int strconv__common_parse_uint2(string s, int _base, int _bit_size); | ||
| 2469 | +_result_u64 strconv__parse_uint(string s, int _base, int _bit_size); | ||
| 2470 | +_result_i64 strconv__common_parse_int(string _s, int base, int _bit_size, bool error_on_non_digit, bool error_on_high_digit); | ||
| 2471 | +_result_i64 strconv__parse_int(string _s, int base, int _bit_size); | ||
| 2472 | +VV_LOC _result_multi_return_i64_int strconv__atoi_common_check(string s); | ||
| 2473 | +VV_LOC _result_i64 strconv__atoi_common(string s, i64 type_min, i64 type_max); | ||
| 2474 | +_result_int strconv__atoi(string s); | ||
| 2475 | +_result_i8 strconv__atoi8(string s); | ||
| 2476 | +_result_i16 strconv__atoi16(string s); | ||
| 2477 | +_result_i32 strconv__atoi32(string s); | ||
| 2478 | +_result_i64 strconv__atoi64(string s); | ||
| 2479 | +VV_LOC _result_i64 strconv__safe_add_64bits(i64 a, i64 b); | ||
| 2480 | +VV_LOC _result_i64 strconv__safe_mul10_64bits(i64 a); | ||
| 2481 | +VV_LOC _result_int strconv__atou_common_check(string s); | ||
| 2482 | +VV_LOC _result_u64 strconv__atou_common(string s, u64 type_max); | ||
| 2483 | +_result_u8 strconv__atou8(string s); | ||
| 2484 | +_result_u16 strconv__atou16(string s); | ||
| 2485 | +_result_u32 strconv__atou(string s); | ||
| 2486 | +_result_u32 strconv__atou32(string s); | ||
| 2487 | +_result_u64 strconv__atou64(string s); | ||
| 2488 | +string strconv__Dec32_get_string_32(strconv__Dec32 d, bool neg, int i_n_digit, int i_pad_digit); | ||
| 2489 | +VV_LOC multi_return_strconv__Dec32_bool strconv__f32_to_decimal_exact_int(u32 i_mant, u32 exp); | ||
| 2490 | +VV_LOC strconv__Dec32 strconv__f32_to_decimal(u32 mant, u32 exp); | ||
| 2491 | +string strconv__f32_to_str(f32 f, int n_digit); | ||
| 2492 | +string strconv__f32_to_str_pad(f32 f, int n_digit); | ||
| 2493 | +VV_LOC string strconv__Dec64_get_string_64(strconv__Dec64 d, bool neg, int i_n_digit, int i_pad_digit); | ||
| 2494 | +VV_LOC multi_return_strconv__Dec64_bool strconv__f64_to_decimal_exact_int(u64 i_mant, u64 exp); | ||
| 2495 | +VV_LOC strconv__Dec64 strconv__f64_to_decimal(u64 mant, u64 exp); | ||
| 2496 | +string strconv__f64_to_str(f64 f, int n_digit); | ||
| 2497 | +string strconv__f64_to_str_pad(f64 f, int n_digit); | ||
| 2498 | +string strconv__format_str(string s, strconv__BF_param p); | ||
| 2499 | +void strconv__format_str_sb(string s, strconv__BF_param p, strings__Builder* sb); | ||
| 2500 | +void strconv__format_dec_sb(u64 d, strconv__BF_param p, strings__Builder* res); | ||
| 2501 | +string strconv__f64_to_str_lnd1(f64 f, int dec_digit); | ||
| 2502 | +string strconv__format_fl(f64 f, strconv__BF_param p); | ||
| 2503 | +string strconv__format_es(f64 f, strconv__BF_param p); | ||
| 2504 | +string strconv__remove_tail_zeros(string s); | ||
| 2505 | +string strconv__ftoa_64(f64 f); | ||
| 2506 | +string strconv__ftoa_long_64(f64 f); | ||
| 2507 | +string strconv__ftoa_32(f32 f); | ||
| 2508 | +string strconv__ftoa_long_32(f32 f); | ||
| 2509 | +string strconv__format_int(i64 n, int radix); | ||
| 2510 | +string strconv__format_uint(u64 n, int radix); | ||
| 2511 | +string strconv__f32_to_str_l(f32 f); | ||
| 2512 | +string strconv__f32_to_str_l_with_dot(f32 f); | ||
| 2513 | +string strconv__f64_to_str_l(f64 f); | ||
| 2514 | +string strconv__f64_to_str_l_with_dot(f64 f); | ||
| 2515 | +string strconv__fxx_to_str_l_parse(string s); | ||
| 2516 | +string strconv__fxx_to_str_l_parse_with_dot(string s); | ||
| 2517 | +VV_LOC u32 strconv__bool_to_u32(bool b); | ||
| 2518 | +VV_LOC u64 strconv__bool_to_u64(bool b); | ||
| 2519 | +VV_LOC string strconv__get_string_special(bool neg, bool expZero, bool mantZero); | ||
| 2520 | +VV_LOC u32 strconv__mul_shift_32(u32 m, u64 mul, int ishift); | ||
| 2521 | +VV_LOC u32 strconv__mul_pow5_invdiv_pow2(u32 m, u32 q, int j); | ||
| 2522 | +VV_LOC u32 strconv__mul_pow5_div_pow2(u32 m, u32 i, int j); | ||
| 2523 | +VV_LOC u32 strconv__pow5_factor_32(u32 i_v); | ||
| 2524 | +VV_LOC bool strconv__multiple_of_power_of_five_32(u32 v, u32 p); | ||
| 2525 | +VV_LOC bool strconv__multiple_of_power_of_two_32(u32 v, u32 p); | ||
| 2526 | +VV_LOC u32 strconv__log10_pow2(int e); | ||
| 2527 | +VV_LOC u32 strconv__log10_pow5(int e); | ||
| 2528 | +VV_LOC int strconv__pow5_bits(int e); | ||
| 2529 | +VV_LOC u64 strconv__shift_right_128(strconv__Uint128 v, int shift); | ||
| 2530 | +VV_LOC u64 strconv__mul_shift_64(u64 m, strconv__Uint128 mul, int shift); | ||
| 2531 | +VV_LOC u32 strconv__pow5_factor_64(u64 v_i); | ||
| 2532 | +VV_LOC bool strconv__multiple_of_power_of_five_64(u64 v, u32 p); | ||
| 2533 | +VV_LOC bool strconv__multiple_of_power_of_two_64(u64 v, u32 p); | ||
| 2534 | +int strconv__dec_digits(u64 n); | ||
| 2535 | +void strconv__v_printf(string str, Array_voidptr pt); | ||
| 2536 | +string strconv__v_sprintf(string str, Array_voidptr pt); | ||
| 2537 | +VV_LOC void strconv__v_sprintf_panic(int idx, int len); | ||
| 2538 | +VV_LOC f64 strconv__fabs(f64 x); | ||
| 2539 | +string strconv__format_fl_old(f64 f, strconv__BF_param p); | ||
| 2540 | +VV_LOC string strconv__format_es_old(f64 f, strconv__BF_param p); | ||
| 2541 | +VV_LOC string strconv__remove_tail_zeros_old(string s); | ||
| 2542 | +string strconv__format_dec_old(u64 d, strconv__BF_param p); | ||
| 2543 | +int strconv__write_dec(i64 n, Array_u8* buf); | ||
| 2544 | +int strconv__write_dec_u(u64 n, Array_u8* buf); | ||
| 2545 | +VV_LOC void strconv__write_dec_u_digits(u64 n, Array_u8* buf, int offset, int ndigits); | ||
| 2546 | +VV_LOC void builtin___memory_panic(string fname, isize size); | ||
| 2547 | +u8* builtin___v_malloc(isize n); | ||
| 2548 | +u8* builtin__malloc_noscan(isize n); | ||
| 2549 | +VV_LOC u8* builtin__malloc_uninit(isize n); | ||
| 2550 | +VV_LOC u64 builtin____at_least_one(u64 how_many); | ||
| 2551 | +u8* builtin__malloc_uncollectable(isize n); | ||
| 2552 | +u8* builtin__v_realloc(u8* b, isize n); | ||
| 2553 | +u8* builtin__realloc_data(u8* old_data, int old_size, int new_size); | ||
| 2554 | +u8* builtin__vcalloc(isize n); | ||
| 2555 | +u8* builtin__vcalloc_noscan(isize n); | ||
| 2556 | +void builtin___v_free(voidptr ptr); | ||
| 2557 | +voidptr builtin__memdup(voidptr src, isize sz); | ||
| 2558 | +voidptr builtin__memdup_noscan(voidptr src, isize sz); | ||
| 2559 | +voidptr builtin__memdup_uncollectable(voidptr src, isize sz); | ||
| 2560 | +voidptr builtin__memdup_align(voidptr src, isize sz, isize align); | ||
| 2561 | +GCHeapUsage builtin__gc_heap_usage(void); | ||
| 2562 | +usize builtin__gc_memory_use(void); | ||
| 2563 | +VV_LOC int builtin__array_data_header_size(void); | ||
| 2564 | +VV_LOC u64 builtin__array_data_allocation_size(u64 total_size); | ||
| 2565 | +VV_LOC voidptr builtin__alloc_array_data(u64 total_size); | ||
| 2566 | +VV_LOC voidptr builtin__alloc_array_data_uninit(u64 total_size); | ||
| 2567 | +VV_LOC bool builtin__array_uses_noscan_data(array a); | ||
| 2568 | +VV_LOC voidptr builtin__array_alloc_array_data_like(array a, u64 total_size); | ||
| 2569 | +VV_LOC voidptr builtin__array_alloc_array_data_like_uninit(array a, u64 total_size); | ||
| 2570 | +VV_LOC ArrayDataHeader* builtin__array_data_header(array a); | ||
| 2571 | +VV_LOC bool builtin__array_buffer_has_slices(array a); | ||
| 2572 | +VV_LOC void builtin__array_mark_buffer_has_slices(array* a); | ||
| 2573 | +VV_LOC void builtin__array_set_managed_flags(array* a, bool is_slice); | ||
| 2574 | +VV_LOC void builtin__array_clone_shallow_to_cap(array* a, int new_cap); | ||
| 2575 | +VV_LOC int builtin__v_ni_index(int i, int len); | ||
| 2576 | +VV_LOC array builtin____new_array(int mylen, int cap, int elm_size); | ||
| 2577 | +VV_LOC array builtin____new_array_with_default(int mylen, int cap, int elm_size, voidptr val); | ||
| 2578 | +VV_LOC array builtin____new_array_with_multi_default(int mylen, int cap, int elm_size, voidptr val); | ||
| 2579 | +VV_LOC array builtin____new_array_with_array_default(int mylen, int cap, int elm_size, array val, int depth); | ||
| 2580 | +VV_LOC array builtin__new_array_from_c_array(int len, int cap, int elm_size, voidptr c_array); | ||
| 2581 | +void builtin__array_ensure_cap(array* a, int required); | ||
| 2582 | +array builtin__array_repeat(array a, int count); | ||
| 2583 | +array builtin__array_repeat_to_depth(array a, int count, int depth); | ||
| 2584 | +VV_LOC bool builtin__array_needs_unique_shift(array a, int required); | ||
| 2585 | +VV_LOC bool builtin__array_needs_unique_append(array a, int required); | ||
| 2586 | +VV_LOC bool builtin__array_needs_unique_shrink(array a); | ||
| 2587 | +void builtin__array_insert(array* a, int i, voidptr val); | ||
| 2588 | +void builtin__array_prepend(array* a, voidptr val); | ||
| 2589 | +void builtin__array_delete(array* a, int i); | ||
| 2590 | +void builtin__array_delete_many(array* a, int i, int size); | ||
| 2591 | +void builtin__array_clear(array* a); | ||
| 2592 | +void builtin__array_reset(array* a); | ||
| 2593 | +void builtin__array_trim(array* a, int index); | ||
| 2594 | +void builtin__array_drop(array* a, int num); | ||
| 2595 | +VV_LOC voidptr builtin__array_get_unsafe(array a, int i); | ||
| 2596 | +VV_LOC voidptr builtin__array_get(array a, int i); | ||
| 2597 | +VV_LOC voidptr builtin__array_get_i64(array a, i64 i); | ||
| 2598 | +VV_LOC voidptr builtin__array_get_u64(array a, u64 i); | ||
| 2599 | +VV_LOC voidptr builtin__array_get_ni(array a, int i); | ||
| 2600 | +VV_LOC voidptr builtin__array_get_with_check(array a, int i); | ||
| 2601 | +VV_LOC voidptr builtin__array_get_with_check_i64(array a, i64 i); | ||
| 2602 | +VV_LOC voidptr builtin__array_get_with_check_u64(array a, u64 i); | ||
| 2603 | +VV_LOC voidptr builtin__array_get_with_check_ni(array a, int i); | ||
| 2604 | +voidptr builtin__array_first(array a); | ||
| 2605 | +voidptr builtin__array_last(array a); | ||
| 2606 | +voidptr builtin__array_pop_left(array* a); | ||
| 2607 | +voidptr builtin__array_pop(array* a); | ||
| 2608 | +void builtin__array_delete_last(array* a); | ||
| 2609 | +VV_LOC array builtin__array_slice(array a, int start, int _end); | ||
| 2610 | +VV_LOC array builtin__array_slice_ni(array a, int _start, int _end); | ||
| 2611 | +VV_LOC array builtin__array_clone_static_to_depth(array a, int depth); | ||
| 2612 | +array builtin__array_clone(array* a); | ||
| 2613 | +array builtin__array_clone_to_depth(array* a, int depth); | ||
| 2614 | +VV_LOC void builtin__array_set_unsafe(array* a, int i, voidptr val); | ||
| 2615 | +VV_LOC void builtin__array_set(array* a, int i, voidptr val); | ||
| 2616 | +VV_LOC void builtin__array_set_i64(array* a, i64 i, voidptr val); | ||
| 2617 | +VV_LOC void builtin__array_set_u64(array* a, u64 i, voidptr val); | ||
| 2618 | +VV_LOC void builtin__array_set_ni(array* a, int i, voidptr val); | ||
| 2619 | +VV_LOC void builtin__copy_element_to(voidptr dest, voidptr src, int element_size); | ||
| 2620 | +VV_LOC void builtin__array_push(array* a, voidptr val); | ||
| 2621 | +void builtin__array_push_many(array* a, voidptr val, int size); | ||
| 2622 | +void builtin__array_reverse_in_place(array* a); | ||
| 2623 | +array builtin__array_reverse(array a); | ||
| 2624 | +void builtin__array_free(array* a); | ||
| 2625 | +array builtin__array_filter(array a, bool (*predicate)(voidptr _d1)); | ||
| 2626 | +bool builtin__array_any(array a, bool (*predicate)(voidptr _d1)); | ||
| 2627 | +int builtin__array_count(array a, bool (*predicate)(voidptr _d1)); | ||
| 2628 | +bool builtin__array_all(array a, bool (*predicate)(voidptr _d1)); | ||
| 2629 | +array builtin__array_map(array a, voidptr (*callback)(voidptr _d1)); | ||
| 2630 | +void builtin__array_sort(array* a, int (*callback)(voidptr _d1, voidptr _d2)); | ||
| 2631 | +array builtin__array_sorted(array* a, int (*callback)(voidptr _d1, voidptr _d2)); | ||
| 2632 | +void builtin__array_sort_with_compare(array* a, int (*callback)(const void* const_a, const void* const_b)); | ||
| 2633 | +array builtin__array_sorted_with_compare(array* a, int (*callback)(const void* const_a, const void* const_b)); | ||
| 2634 | +bool builtin__array_contains(array a, voidptr value); | ||
| 2635 | +int builtin__array_index(array a, voidptr value); | ||
| 2636 | +int builtin__array_last_index(array a, voidptr value); | ||
| 2637 | +void Array_string_free(Array_string* a); | ||
| 2638 | +string Array_string_str(Array_string a); | ||
| 2639 | +string Array_u8_hex(Array_u8 b); | ||
| 2640 | +int builtin__copy(Array_u8* dst, Array_u8 src); | ||
| 2641 | +void builtin__array_grow_cap(array* a, int amount); | ||
| 2642 | +void builtin__array_grow_len(array* a, int amount); | ||
| 2643 | +Array_voidptr builtin__array_pointers(array a); | ||
| 2644 | +Array_u8 builtin__voidptr_vbytes(voidptr data, int len); | ||
| 2645 | +Array_u8 builtin__u8_vbytes(u8* data, int len); | ||
| 2646 | +void builtin__u8_free(u8* data); | ||
| 2647 | +VV_LOC void builtin__panic_on_negative_len(int len); | ||
| 2648 | +VV_LOC void builtin__panic_on_negative_cap(int cap); | ||
| 2649 | +VV_LOC array builtin____new_array_noscan(int mylen, int cap, int elm_size); | ||
| 2650 | +VV_LOC array builtin____new_array_with_default_noscan(int mylen, int cap, int elm_size, voidptr val); | ||
| 2651 | +VV_LOC array builtin____new_array_with_multi_default_noscan(int mylen, int cap, int elm_size, voidptr val); | ||
| 2652 | +VV_LOC array builtin____new_array_with_array_default_noscan(int mylen, int cap, int elm_size, array val, int depth); | ||
| 2653 | +VV_LOC void builtin__array_push_noscan(array* a, voidptr val); | ||
| 2654 | +VV_LOC void builtin__array_push_many_noscan(array* a, voidptr val, int size); | ||
| 2655 | +VV_LOC bool builtin__autostr_type_in_stack(int typ); | ||
| 2656 | +VV_LOC void builtin__autostr_type_push(int typ); | ||
| 2657 | +VV_LOC void builtin__autostr_type_pop(void); | ||
| 2658 | +VV_LOC bool builtin__autostr_addr_in_stack(voidptr addr); | ||
| 2659 | +VV_LOC void builtin__autostr_addr_push(voidptr addr); | ||
| 2660 | +VV_LOC void builtin__autostr_addr_pop(void); | ||
| 2661 | +VV_LOC string builtin__autostr_array_circular(int len); | ||
| 2662 | +void builtin__print_backtrace(void); | ||
| 2663 | +VV_LOC string builtin__demangle_v_symbol(string cname); | ||
| 2664 | +VV_LOC Array_string builtin__split_generic_params(string s); | ||
| 2665 | +VV_LOC string builtin__demangle_backtrace_sym(string s); | ||
| 2666 | +VV_LOC void builtin__eprint_space_padding(string output, int max_len); | ||
| 2667 | +bool builtin__print_backtrace_skipping_top_frames(int xskipframes); | ||
| 2668 | +VV_LOC string builtin__backtrace_current_executable_name(void); | ||
| 2669 | +VV_LOC string builtin__backtrace_addr2line_executable(string executable, string current_executable_name); | ||
| 2670 | +VV_LOC string builtin__backtrace_shell_quote(string s); | ||
| 2671 | +VV_LOC bool builtin__print_backtrace_skipping_top_frames_linux(int skipframes); | ||
| 2672 | +void builtin___v_exit(int code); | ||
| 2673 | +_result_void builtin__at_exit(void (*cb)()); | ||
| 2674 | +VV_LOC void builtin__v_segmentation_fault_handler(i32 signal_number); | ||
| 2675 | +VV_LOC int builtin__v_fixed_index(int i, int len); | ||
| 2676 | +VV_LOC int builtin__v_fixed_index_i64(i64 i, int len); | ||
| 2677 | +VV_LOC int builtin__v_fixed_index_u64(u64 i, int len); | ||
| 2678 | +VV_LOC int builtin__v_fixed_index_ni(int i, int len); | ||
| 2679 | +VV_LOC int builtin__v_slice_index_i64(i64 i); | ||
| 2680 | +VV_LOC int builtin__v_slice_index_u64(u64 i); | ||
| 2681 | +Array_string builtin__arguments(void); | ||
| 2682 | +string builtin__vcurrent_hash(void); | ||
| 2683 | +u64 builtin__v_getpid(void); | ||
| 2684 | +u64 builtin__v_gettid(void); | ||
| 2685 | +bool builtin__isnil(voidptr v); | ||
| 2686 | +VV_LOC void builtin__builtin_init(void); | ||
| 2687 | +void builtin__panic_lasterr(string base); | ||
| 2688 | +void builtin__gc_check_leaks(void); | ||
| 2689 | +bool builtin__gc_is_enabled(void); | ||
| 2690 | +void builtin__gc_enable(void); | ||
| 2691 | +void builtin__gc_disable(void); | ||
| 2692 | +void builtin__gc_collect(void); | ||
| 2693 | +void builtin__gc_get_warn_proc(void); | ||
| 2694 | +void builtin__gc_set_warn_proc(void (*cb)(char* msg, usize arg)); | ||
| 2695 | +int builtin__vstrlen(u8* s); | ||
| 2696 | +int builtin__vstrlen_char(char* s); | ||
| 2697 | +voidptr builtin__vmemcpy(voidptr dest, const void* const_src, isize n); | ||
| 2698 | +voidptr builtin__vmemmove(voidptr dest, const void* const_src, isize n); | ||
| 2699 | +int builtin__vmemcmp(const void* const_s1, const void* const_s2, isize n); | ||
| 2700 | +voidptr builtin__vmemset(voidptr s, int c, isize n); | ||
| 2701 | +VV_LOC voidptr builtin__vsort_ptr_at(voidptr base, usize index, usize size); | ||
| 2702 | +VV_LOC void builtin__vstable_sort_merge(voidptr source, voidptr dest, usize left, usize mid, usize right, usize size, int (*sort_cb)(const void* const_a, const void* const_b)); | ||
| 2703 | +VV_LOC void builtin__vqsort(voidptr base, usize nmemb, usize size, int (*sort_cb)(const void* const_a, const void* const_b)); | ||
| 2704 | +void builtin__chan_close(chan ch, Array_IError err); | ||
| 2705 | +ChanState builtin__chan_try_pop(chan ch, voidptr obj); | ||
| 2706 | +ChanState builtin__chan_try_push(chan ch, voidptr obj); | ||
| 2707 | +VV_LOC void builtin___result_ok(voidptr data, _result* res, int size); | ||
| 2708 | +VV_LOC void builtin___result_clone(_result* current, _result* res, int size); | ||
| 2709 | +string builtin__IError_str(IError err); | ||
| 2710 | +string builtin__Error_msg(Error err); | ||
| 2711 | +int builtin__Error_code(Error err); | ||
| 2712 | +string builtin__MessageError_str(MessageError err); | ||
| 2713 | +string builtin__MessageError_msg(MessageError err); | ||
| 2714 | +int builtin__MessageError_code(MessageError err); | ||
| 2715 | +void builtin__MessageError_free(MessageError* err); | ||
| 2716 | +IError builtin___v_error(string message); | ||
| 2717 | +IError builtin__error_with_code(string message, int code); | ||
| 2718 | +VV_LOC void builtin___option_none(voidptr data, _option* option, int size); | ||
| 2719 | +VV_LOC void builtin___option_ok(voidptr data, _option* option, int size); | ||
| 2720 | +VV_LOC void builtin___option_clone(_option* current, _option* option, int size); | ||
| 2721 | +VV_LOC void builtin___result_ok_markused(void); | ||
| 2722 | +VV_LOC string builtin__None___str(None__ _d1); | ||
| 2723 | +string builtin__none_str(none _d1); | ||
| 2724 | +int builtin__input_character(void); | ||
| 2725 | +int builtin__print_character(u8 ch); | ||
| 2726 | +string builtin__f64_str(f64 x); | ||
| 2727 | +string builtin__f64_strg(f64 x); | ||
| 2728 | +string builtin__float_literal_str(float_literal d); | ||
| 2729 | +string builtin__f64_strsci(f64 x, int digit_num); | ||
| 2730 | +string builtin__f64_strlong(f64 x); | ||
| 2731 | +string builtin__f32_str(f32 x); | ||
| 2732 | +string builtin__f32_strg(f32 x); | ||
| 2733 | +string builtin__f32_strsci(f32 x, int digit_num); | ||
| 2734 | +string builtin__f32_strlong(f32 x); | ||
| 2735 | +f32 builtin__f32_abs(f32 a); | ||
| 2736 | +f64 builtin__f64_abs(f64 a); | ||
| 2737 | +f32 builtin__f32_min(f32 a, f32 b); | ||
| 2738 | +f32 builtin__f32_max(f32 a, f32 b); | ||
| 2739 | +f64 builtin__f64_min(f64 a, f64 b); | ||
| 2740 | +f64 builtin__f64_max(f64 a, f64 b); | ||
| 2741 | +bool builtin__f32_eq_epsilon(f32 a, f32 b); | ||
| 2742 | +bool builtin__f64_eq_epsilon(f64 a, f64 b); | ||
| 2743 | +VV_LOC u32 builtin__grapheme_hex_nibble(u8 c); | ||
| 2744 | +VV_LOC u32 builtin__grapheme_hex_byte(string ranges, int i); | ||
| 2745 | +VV_LOC u32 builtin__grapheme_range_value(string ranges, int value_idx); | ||
| 2746 | +VV_LOC bool builtin__in_grapheme_ranges(rune r, string ranges); | ||
| 2747 | +VV_LOC GraphemeBreakProperty builtin__grapheme_break_property(rune r); | ||
| 2748 | +VV_LOC bool builtin__is_extended_pictographic(rune r); | ||
| 2749 | +VV_LOC GraphemeState builtin__grapheme_state_from_rune(rune r, GraphemeBreakProperty prop); | ||
| 2750 | +VV_LOC void builtin__GraphemeState_push(GraphemeState* gs, rune r, GraphemeBreakProperty prop); | ||
| 2751 | +VV_LOC bool builtin__should_break_grapheme(GraphemeState gs, rune r, GraphemeBreakProperty prop); | ||
| 2752 | +VV_LOC int builtin__utf8_rune_visible_width(rune r, GraphemeBreakProperty prop); | ||
| 2753 | +VV_LOC Array_string builtin__string_graphemes_impl(string s); | ||
| 2754 | +VV_LOC int builtin__utf8_grapheme_visible_length(string s); | ||
| 2755 | +_option_rune builtin__input_rune(void); | ||
| 2756 | +_option_rune builtin__InputRuneIterator_next(InputRuneIterator* self); | ||
| 2757 | +InputRuneIterator builtin__input_rune_iterator(void); | ||
| 2758 | +string builtin__ptr_str(voidptr ptr); | ||
| 2759 | +string builtin__isize_str(isize x); | ||
| 2760 | +string builtin__usize_str(usize x); | ||
| 2761 | +string builtin__char_str(char* cptr); | ||
| 2762 | +VV_LOC string builtin__int_str_l(int nn, int max); | ||
| 2763 | +string builtin__i8_str(i8 n); | ||
| 2764 | +string builtin__i16_str(i16 n); | ||
| 2765 | +string builtin__u16_str(u16 n); | ||
| 2766 | +string builtin__i32_str(i32 n); | ||
| 2767 | +string builtin__int_hex_full(int nn); | ||
| 2768 | +string builtin__int_str(int n); | ||
| 2769 | +string builtin__u32_str(u32 nn); | ||
| 2770 | +string builtin__int_literal_str(int_literal n); | ||
| 2771 | +string builtin__i64_str(i64 nn); | ||
| 2772 | +VV_LOC string builtin__impl_i64_to_string(i64 nn); | ||
| 2773 | +string builtin__u64_str(u64 nn); | ||
| 2774 | +string builtin__bool_str(bool b); | ||
| 2775 | +VV_LOC string builtin__u64_to_hex(u64 nn, u8 len); | ||
| 2776 | +VV_LOC string builtin__u64_to_hex_no_leading_zeros(u64 nn, u8 len); | ||
| 2777 | +string builtin__u8_hex(u8 nn); | ||
| 2778 | +string builtin__char_hex(char c); | ||
| 2779 | +string builtin__rune_hex(rune r); | ||
| 2780 | +string builtin__i8_hex(i8 nn); | ||
| 2781 | +string builtin__u16_hex(u16 nn); | ||
| 2782 | +string builtin__i16_hex(i16 nn); | ||
| 2783 | +string builtin__u32_hex(u32 nn); | ||
| 2784 | +string builtin__int_hex(int nn); | ||
| 2785 | +string builtin__int_hex2(int n); | ||
| 2786 | +string builtin__u64_hex(u64 nn); | ||
| 2787 | +string builtin__i64_hex(i64 nn); | ||
| 2788 | +string builtin__int_literal_hex(int_literal nn); | ||
| 2789 | +string builtin__voidptr_str(voidptr nn); | ||
| 2790 | +string builtin__byteptr_str(byteptr nn); | ||
| 2791 | +string builtin__charptr_str(charptr nn); | ||
| 2792 | +string builtin__u8_hex_full(u8 nn); | ||
| 2793 | +string builtin__i8_hex_full(i8 nn); | ||
| 2794 | +string builtin__u16_hex_full(u16 nn); | ||
| 2795 | +string builtin__i16_hex_full(i16 nn); | ||
| 2796 | +string builtin__u32_hex_full(u32 nn); | ||
| 2797 | +string builtin__i64_hex_full(i64 nn); | ||
| 2798 | +string builtin__voidptr_hex_full(voidptr nn); | ||
| 2799 | +string builtin__int_literal_hex_full(int_literal nn); | ||
| 2800 | +string builtin__u64_hex_full(u64 nn); | ||
| 2801 | +string builtin__u8_str(u8 b); | ||
| 2802 | +string builtin__u8_ascii_str(u8 b); | ||
| 2803 | +string builtin__u8_str_escaped(u8 b); | ||
| 2804 | +bool builtin__u8_is_capital(u8 c); | ||
| 2805 | +string Array_u8_bytestr(Array_u8 b); | ||
| 2806 | +_result_rune Array_u8_byterune(Array_u8 b); | ||
| 2807 | +string builtin__u8_repeat(u8 b, int count); | ||
| 2808 | +int builtin__int_min(int a, int b); | ||
| 2809 | +int builtin__int_max(int a, int b); | ||
| 2810 | +VV_LOC bool builtin__fast_string_eq(string a, string b); | ||
| 2811 | +VV_LOC u64 builtin__map_hash_string(voidptr pkey); | ||
| 2812 | +VV_LOC u64 builtin__map_hash_int_1(voidptr pkey); | ||
| 2813 | +VV_LOC u64 builtin__map_hash_int_2(voidptr pkey); | ||
| 2814 | +VV_LOC u64 builtin__map_hash_int_4(voidptr pkey); | ||
| 2815 | +VV_LOC u64 builtin__map_hash_int_8(voidptr pkey); | ||
| 2816 | +VV_LOC voidptr builtin__map_enum_fn(int kind, int esize); | ||
| 2817 | +VV_LOC void builtin__DenseArray_zeros_to_end(DenseArray* d); | ||
| 2818 | +VV_LOC DenseArray builtin__new_dense_array(int key_bytes, int value_bytes); | ||
| 2819 | +VV_LOC voidptr builtin__DenseArray_key(DenseArray* d, int i); | ||
| 2820 | +VV_LOC voidptr builtin__DenseArray_value(DenseArray* d, int i); | ||
| 2821 | +VV_LOC bool builtin__DenseArray_has_index(DenseArray* d, int i); | ||
| 2822 | +VV_LOC void builtin__DenseArray_trim_deleted_tail(DenseArray* d); | ||
| 2823 | +VV_LOC int builtin__DenseArray_expand(DenseArray* d); | ||
| 2824 | +VV_LOC bool builtin__map_eq_string(voidptr a, voidptr b); | ||
| 2825 | +VV_LOC bool builtin__map_eq_int_1(voidptr a, voidptr b); | ||
| 2826 | +VV_LOC bool builtin__map_eq_int_2(voidptr a, voidptr b); | ||
| 2827 | +VV_LOC bool builtin__map_eq_int_4(voidptr a, voidptr b); | ||
| 2828 | +VV_LOC bool builtin__map_eq_int_8(voidptr a, voidptr b); | ||
| 2829 | +VV_LOC bool builtin__map_map_eq(map a, map b); | ||
| 2830 | +VV_LOC void builtin__map_clone_string(voidptr dest, voidptr pkey); | ||
| 2831 | +VV_LOC void builtin__map_clone_int_1(voidptr dest, voidptr pkey); | ||
| 2832 | +VV_LOC void builtin__map_clone_int_2(voidptr dest, voidptr pkey); | ||
| 2833 | +VV_LOC void builtin__map_clone_int_4(voidptr dest, voidptr pkey); | ||
| 2834 | +VV_LOC void builtin__map_clone_int_8(voidptr dest, voidptr pkey); | ||
| 2835 | +VV_LOC void builtin__map_free_string(voidptr pkey); | ||
| 2836 | +VV_LOC void builtin__map_free_nop(voidptr _d1); | ||
| 2837 | +VV_LOC map builtin__new_map(int key_bytes, int value_bytes, u64 (*hash_fn)(voidptr _d1), bool (*key_eq_fn)(voidptr _d1, voidptr _d2), void (*clone_fn)(voidptr _d1, voidptr _d2), void (*free_fn)(voidptr _d1)); | ||
| 2838 | +VV_LOC map builtin__new_map_init(u64 (*hash_fn)(voidptr _d1), bool (*key_eq_fn)(voidptr _d1, voidptr _d2), void (*clone_fn)(voidptr _d1, voidptr _d2), void (*free_fn)(voidptr _d1), int n, int key_bytes, int value_bytes, voidptr keys, voidptr values); | ||
| 2839 | +map builtin__map_move(map* m); | ||
| 2840 | +void builtin__map_clear(map* m); | ||
| 2841 | +VV_LOC multi_return_u32_u32 builtin__map_key_to_index(map* m, voidptr pkey); | ||
| 2842 | +VV_LOC multi_return_u32_u32 builtin__map_meta_less(map* m, u32 _index, u32 _metas); | ||
| 2843 | +VV_LOC void builtin__map_meta_greater(map* m, u32 _index, u32 _metas, u32 kvi); | ||
| 2844 | +VV_LOC void builtin__map_ensure_extra_metas_grow(map* m); | ||
| 2845 | +VV_LOC void builtin__map_ensure_extra_metas(map* m, u32 probe_count); | ||
| 2846 | +VV_LOC void builtin__map_set(map* m, voidptr key, voidptr value); | ||
| 2847 | +VV_LOC void builtin__map_expand(map* m); | ||
| 2848 | +VV_LOC void builtin__map_rehash(map* m); | ||
| 2849 | +VV_LOC void builtin__map_reserve_metas(map* m, u32 meta_bytes); | ||
| 2850 | +void builtin__map_reserve(map* m, u32 n); | ||
| 2851 | +VV_LOC void builtin__map_cached_rehash(map* m, u32 old_cap); | ||
| 2852 | +VV_LOC voidptr builtin__map_get_and_set(map* m, voidptr key, voidptr zero); | ||
| 2853 | +VV_LOC voidptr builtin__map_get(map* m, voidptr key, voidptr zero); | ||
| 2854 | +VV_LOC voidptr builtin__map_get_check(map* m, voidptr key); | ||
| 2855 | +VV_LOC bool builtin__map_exists(map* m, voidptr key); | ||
| 2856 | +VV_LOC void builtin__DenseArray_delete(DenseArray* d, int i); | ||
| 2857 | +void builtin__map_delete(map* m, voidptr key); | ||
| 2858 | +array builtin__map_keys(map* m); | ||
| 2859 | +array builtin__map_values(map* m); | ||
| 2860 | +VV_LOC DenseArray builtin__DenseArray_clone(DenseArray* d); | ||
| 2861 | +map builtin__map_clone(map* m); | ||
| 2862 | +void builtin__map_free(map* m); | ||
| 2863 | +void builtin__VAssertMetaInfo_free(VAssertMetaInfo* ami); | ||
| 2864 | +void builtin__IError_free(IError* ie); | ||
| 2865 | +void builtin__panic_option_not_set(string s); | ||
| 2866 | +void builtin__panic_result_not_set(string s); | ||
| 2867 | +void builtin___v_panic(string s); | ||
| 2868 | +string builtin__c_error_number_str(int errnum); | ||
| 2869 | +void builtin__panic_n(string s, i64 number1); | ||
| 2870 | +void builtin__panic_n2(string s, i64 number1, i64 number2); | ||
| 2871 | +VV_LOC void builtin__panic_n3(string s, i64 number1, i64 number2, i64 number3); | ||
| 2872 | +void builtin__panic_error_number(string basestr, int errnum); | ||
| 2873 | +VV_LOC void builtin__set_stream_unbuffered(FILE* stream); | ||
| 2874 | +void builtin__eprintln(string s); | ||
| 2875 | +void builtin__eprint(string s); | ||
| 2876 | +void builtin__flush_stdout(void); | ||
| 2877 | +void builtin__flush_stderr(void); | ||
| 2878 | +void builtin__unbuffer_stdout(void); | ||
| 2879 | +void builtin__print(string s); | ||
| 2880 | +void builtin__println(string s); | ||
| 2881 | +VV_LOC void builtin___writeln_to_fd(int fd, string s); | ||
| 2882 | +VV_LOC void builtin___write_buf_to_fd(int fd, u8* buf, int buf_len); | ||
| 2883 | +string builtin__reuse_data_as_string(Array_u8 buffer); | ||
| 2884 | +Array_u8 builtin__reuse_string_as_data(string s); | ||
| 2885 | +string builtin__rune_str(rune c); | ||
| 2886 | +string Array_rune_string(Array_rune ra); | ||
| 2887 | +string builtin__rune_repeat(rune c, int count); | ||
| 2888 | +Array_u8 builtin__rune_bytes(rune c); | ||
| 2889 | +int builtin__rune_length_in_bytes(rune c); | ||
| 2890 | +rune builtin__rune_to_upper(rune c); | ||
| 2891 | +rune builtin__rune_to_lower(rune c); | ||
| 2892 | +rune builtin__rune_to_title(rune c); | ||
| 2893 | +VV_LOC rune builtin__rune_map_to(rune c, MapMode mode); | ||
| 2894 | +VV_LOC int builtin__mapnode_find_key(mapnode* n, string k); | ||
| 2895 | +VV_LOC bool builtin__mapnode_remove_key(mapnode* n, string k); | ||
| 2896 | +VV_LOC void builtin__mapnode_remove_from_leaf(mapnode* n, int idx); | ||
| 2897 | +VV_LOC void builtin__mapnode_remove_from_non_leaf(mapnode* n, int idx); | ||
| 2898 | +VV_LOC void builtin__mapnode_fill(mapnode* n, int idx); | ||
| 2899 | +VV_LOC void builtin__mapnode_borrow_from_prev(mapnode* n, int idx); | ||
| 2900 | +VV_LOC void builtin__mapnode_borrow_from_next(mapnode* n, int idx); | ||
| 2901 | +VV_LOC void builtin__mapnode_merge(mapnode* n, int idx); | ||
| 2902 | +void builtin__SortedMap_delete(SortedMap* m, string key); | ||
| 2903 | +VV_LOC int builtin__mapnode_subkeys(mapnode* n, Array_string* keys, int at); | ||
| 2904 | +Array_string builtin__SortedMap_keys(SortedMap* m); | ||
| 2905 | +VV_LOC void builtin__mapnode_free(mapnode* n); | ||
| 2906 | +void builtin__SortedMap_free(SortedMap* m); | ||
| 2907 | +Array_rune builtin__string_runes(string s); | ||
| 2908 | +Array_string builtin__string_graphemes(string s); | ||
| 2909 | +string builtin__cstring_to_vstring(const char* const_s); | ||
| 2910 | +string builtin__tos_clone(const u8* const_s); | ||
| 2911 | +string builtin__tos(u8* s, int len); | ||
| 2912 | +string builtin__tos2(u8* s); | ||
| 2913 | +string builtin__tos3(char* s); | ||
| 2914 | +string builtin__tos4(u8* s); | ||
| 2915 | +string builtin__tos5(char* s); | ||
| 2916 | +string builtin__u8_vstring(u8* bp); | ||
| 2917 | +string builtin__u8_vstring_with_len(u8* bp, int len); | ||
| 2918 | +string builtin__char_vstring(char* cp); | ||
| 2919 | +string builtin__char_vstring_with_len(char* cp, int len); | ||
| 2920 | +string builtin__u8_vstring_literal(u8* bp); | ||
| 2921 | +string builtin__u8_vstring_literal_with_len(u8* bp, int len); | ||
| 2922 | +string builtin__char_vstring_literal(char* cp); | ||
| 2923 | +string builtin__char_vstring_literal_with_len(char* cp, int len); | ||
| 2924 | +int builtin__string_len_utf8(string s); | ||
| 2925 | +bool builtin__string_is_pure_ascii(string s); | ||
| 2926 | +string builtin__string_clone(string a); | ||
| 2927 | +string builtin__string_replace_once(string s, string rep, string with); | ||
| 2928 | +string builtin__string_replace(string s, string rep, string with); | ||
| 2929 | +string builtin__string_replace_each(string s, Array_string vals); | ||
| 2930 | +string builtin__string_format(string s, Array_string args); | ||
| 2931 | +string builtin__string_replace_char(string s, u8 rep, u8 with, int repeat); | ||
| 2932 | +string builtin__string_normalize_tabs(string s, int tab_len); | ||
| 2933 | +string builtin__string_expand_tabs(string s, int tab_len); | ||
| 2934 | +bool builtin__string_bool(string s); | ||
| 2935 | +i8 builtin__string_i8(string s); | ||
| 2936 | +i16 builtin__string_i16(string s); | ||
| 2937 | +i32 builtin__string_i32(string s); | ||
| 2938 | +int builtin__string_int(string s); | ||
| 2939 | +i64 builtin__string_i64(string s); | ||
| 2940 | +f32 builtin__string_f32(string s); | ||
| 2941 | +f64 builtin__string_f64(string s); | ||
| 2942 | +Array_u8 builtin__string_u8_array(string s); | ||
| 2943 | +u8 builtin__string_u8(string s); | ||
| 2944 | +u16 builtin__string_u16(string s); | ||
| 2945 | +u32 builtin__string_u32(string s); | ||
| 2946 | +u64 builtin__string_u64(string s); | ||
| 2947 | +_result_u64 builtin__string_parse_uint(string s, int _base, int _bit_size); | ||
| 2948 | +_result_i64 builtin__string_parse_int(string s, int _base, int _bit_size); | ||
| 2949 | +VV_LOC bool builtin__string__eq(string s, string a); | ||
| 2950 | +int builtin__string_compare(string s, string a); | ||
| 2951 | +VV_LOC bool builtin__string__lt(string s, string a); | ||
| 2952 | +VV_LOC string builtin__string__plus(string s, string a); | ||
| 2953 | +VV_LOC string builtin__string_plus_many(int data_len, string* input_base); | ||
| 2954 | +VV_LOC string builtin__string_plus_two(string s, string a, string b); | ||
| 2955 | +Array_string builtin__string_split_any(string s, string delim); | ||
| 2956 | +Array_string builtin__string_rsplit_any(string s, string delim); | ||
| 2957 | +Array_string builtin__string_split(string s, string delim); | ||
| 2958 | +Array_string builtin__string_rsplit(string s, string delim); | ||
| 2959 | +_option_multi_return_string_string builtin__string_split_once(string s, string delim); | ||
| 2960 | +_option_multi_return_string_string builtin__string_rsplit_once(string s, string delim); | ||
| 2961 | +Array_string builtin__string_split_n(string s, string delim, int n); | ||
| 2962 | +Array_string builtin__string_split_nth(string s, string delim, int nth); | ||
| 2963 | +Array_string builtin__string_rsplit_nth(string s, string delim, int nth); | ||
| 2964 | +Array_string builtin__string_split_into_lines(string s); | ||
| 2965 | +Array_string builtin__string_split_by_space(string s); | ||
| 2966 | +string builtin__string_substr(string s, int start, int _end); | ||
| 2967 | +string builtin__string_substr_unsafe(string s, int start, int _end); | ||
| 2968 | +string builtin__string_substr_or(string s, int start, int _end, string fallback); | ||
| 2969 | +_result_string builtin__string_substr_with_check(string s, int start, int _end); | ||
| 2970 | +string builtin__string_substr_ni(string s, int _start, int _end); | ||
| 2971 | +int builtin__string_index_(string s, string p); | ||
| 2972 | +_option_int builtin__string_index(string s, string p); | ||
| 2973 | +_option_int builtin__string_last_index(string s, string needle); | ||
| 2974 | +VV_LOC int builtin__string_index_kmp(string s, string p); | ||
| 2975 | +int builtin__string_index_any(string s, string chars); | ||
| 2976 | +VV_LOC int builtin__string_index_last_(string s, string p); | ||
| 2977 | +_option_int builtin__string_index_after(string s, string p, int start); | ||
| 2978 | +int builtin__string_index_after_(string s, string p, int start); | ||
| 2979 | +int builtin__string_index_u8(string s, u8 c); | ||
| 2980 | +int builtin__string_last_index_u8(string s, u8 c); | ||
| 2981 | +int builtin__string_count(string s, string substr); | ||
| 2982 | +bool builtin__string_contains_u8(string s, u8 x); | ||
| 2983 | +bool builtin__string_contains(string s, string substr); | ||
| 2984 | +bool builtin__string_contains_any(string s, string chars); | ||
| 2985 | +bool builtin__string_contains_only(string s, string chars); | ||
| 2986 | +bool builtin__string_contains_any_substr(string s, Array_string substrs); | ||
| 2987 | +bool builtin__string_starts_with(string s, string p); | ||
| 2988 | +bool builtin__string_ends_with(string s, string p); | ||
| 2989 | +string builtin__string_to_lower_ascii(string s); | ||
| 2990 | +string builtin__string_to_lower(string s); | ||
| 2991 | +bool builtin__string_is_lower(string s); | ||
| 2992 | +string builtin__string_to_upper_ascii(string s); | ||
| 2993 | +string builtin__string_to_upper(string s); | ||
| 2994 | +bool builtin__string_is_upper(string s); | ||
| 2995 | +string builtin__string_capitalize(string s); | ||
| 2996 | +string builtin__string_uncapitalize(string s); | ||
| 2997 | +bool builtin__string_is_capital(string s); | ||
| 2998 | +bool builtin__string_starts_with_capital(string s); | ||
| 2999 | +string builtin__string_title(string s); | ||
| 3000 | +bool builtin__string_is_title(string s); | ||
| 3001 | +string builtin__string_find_between(string s, string start, string end); | ||
| 3002 | +string builtin__string_trim_space(string s); | ||
| 3003 | +string builtin__string_trim_space_left(string s); | ||
| 3004 | +string builtin__string_trim_space_right(string s); | ||
| 3005 | +string builtin__string_trim(string s, string cutset); | ||
| 3006 | +multi_return_int_int builtin__string_trim_indexes(string s, string cutset); | ||
| 3007 | +VV_LOC string builtin__string_trim_chars(string s, string cutset, TrimMode mode); | ||
| 3008 | +VV_LOC string builtin__string_trim_runes(string s, string cutset, TrimMode mode); | ||
| 3009 | +string builtin__string_trim_left(string s, string cutset); | ||
| 3010 | +string builtin__string_trim_right(string s, string cutset); | ||
| 3011 | +string builtin__string_trim_string_left(string s, string str); | ||
| 3012 | +string builtin__string_trim_string_right(string s, string str); | ||
| 3013 | +int builtin__compare_strings(string* a, string* b); | ||
| 3014 | +VV_LOC int builtin__compare_strings_by_len(string* a, string* b); | ||
| 3015 | +VV_LOC int builtin__compare_lower_strings(string* a, string* b); | ||
| 3016 | +void Array_string_sort_ignore_case(Array_string* s); | ||
| 3017 | +void Array_string_sort_by_len(Array_string* s); | ||
| 3018 | +string builtin__string_str(string s); | ||
| 3019 | +VV_LOC u8 builtin__string_at(string s, int idx); | ||
| 3020 | +VV_LOC u8 builtin__string_at_i64(string s, i64 idx); | ||
| 3021 | +VV_LOC u8 builtin__string_at_u64(string s, u64 idx); | ||
| 3022 | +VV_LOC u8 builtin__string_at_ni(string s, int idx); | ||
| 3023 | +VV_LOC _option_u8 builtin__string_at_with_check(string s, int idx); | ||
| 3024 | +VV_LOC _option_u8 builtin__string_at_with_check_i64(string s, i64 idx); | ||
| 3025 | +VV_LOC _option_u8 builtin__string_at_with_check_u64(string s, u64 idx); | ||
| 3026 | +VV_LOC _option_u8 builtin__string_at_with_check_ni(string s, int idx); | ||
| 3027 | +bool builtin__string_is_oct(string str); | ||
| 3028 | +bool builtin__string_is_bin(string str); | ||
| 3029 | +bool builtin__string_is_hex(string str); | ||
| 3030 | +bool builtin__string_is_int(string str); | ||
| 3031 | +bool builtin__u8_is_space(u8 c); | ||
| 3032 | +bool builtin__u8_is_digit(u8 c); | ||
| 3033 | +bool builtin__u8_is_hex_digit(u8 c); | ||
| 3034 | +bool builtin__u8_is_oct_digit(u8 c); | ||
| 3035 | +bool builtin__u8_is_bin_digit(u8 c); | ||
| 3036 | +bool builtin__u8_is_letter(u8 c); | ||
| 3037 | +bool builtin__u8_is_alnum(u8 c); | ||
| 3038 | +void builtin__string_free(string* s); | ||
| 3039 | +string builtin__string_before(string s, string sub); | ||
| 3040 | +string builtin__string_all_before(string s, string sub); | ||
| 3041 | +string builtin__string_all_before_last(string s, string sub); | ||
| 3042 | +string builtin__string_all_after(string s, string sub); | ||
| 3043 | +string builtin__string_all_after_last(string s, string sub); | ||
| 3044 | +string builtin__string_all_after_first(string s, string sub); | ||
| 3045 | +string builtin__string_after(string s, string sub); | ||
| 3046 | +string builtin__string_after_char(string s, u8 sub); | ||
| 3047 | +string Array_string_join(Array_string a, string sep); | ||
| 3048 | +string Array_string_join_lines(Array_string s); | ||
| 3049 | +string builtin__string_reverse(string s); | ||
| 3050 | +string builtin__string_limit(string s, int max); | ||
| 3051 | +int builtin__string_hash(string s); | ||
| 3052 | +Array_u8 builtin__string_bytes(string s); | ||
| 3053 | +string builtin__string_repeat(string s, int count); | ||
| 3054 | +Array_string builtin__string_fields(string s); | ||
| 3055 | +string builtin__string_strip_margin(string s); | ||
| 3056 | +string builtin__string_strip_margin_custom(string s, u8 del); | ||
| 3057 | +string builtin__string_trim_indent(string s); | ||
| 3058 | +int builtin__string_indent_width(string s); | ||
| 3059 | +bool builtin__string_is_blank(string s); | ||
| 3060 | +bool builtin__string_match_glob(string name, string pattern); | ||
| 3061 | +bool builtin__string_is_ascii(string s); | ||
| 3062 | +bool builtin__string_is_identifier(string s); | ||
| 3063 | +string builtin__string_camel_to_snake(string s); | ||
| 3064 | +string builtin__string_snake_to_camel(string s); | ||
| 3065 | +string builtin__string_wrap(string s, WrapConfig config); | ||
| 3066 | +string builtin__string_hex(string s); | ||
| 3067 | +VV_LOC string builtin__data_to_hex_string(u8* data, int len); | ||
| 3068 | +RunesIterator builtin__string_runes_iterator(string s); | ||
| 3069 | +_option_rune builtin__RunesIterator_next(RunesIterator* ri); | ||
| 3070 | +Array_u8 builtin__byteptr_vbytes(byteptr data, int len); | ||
| 3071 | +string builtin__byteptr_vstring(byteptr bp); | ||
| 3072 | +string builtin__byteptr_vstring_with_len(byteptr bp, int len); | ||
| 3073 | +string builtin__charptr_vstring(charptr cp); | ||
| 3074 | +string builtin__charptr_vstring_with_len(charptr cp, int len); | ||
| 3075 | +string builtin__byteptr_vstring_literal(byteptr bp); | ||
| 3076 | +string builtin__byteptr_vstring_literal_with_len(byteptr bp, int len); | ||
| 3077 | +string builtin__charptr_vstring_literal(charptr cp); | ||
| 3078 | +string builtin__charptr_vstring_literal_with_len(charptr cp, int len); | ||
| 3079 | +string builtin__StrIntpType_str(StrIntpType x); | ||
| 3080 | +VV_LOC f32 builtin__fabs32(f32 x); | ||
| 3081 | +VV_LOC f64 builtin__fabs64(f64 x); | ||
| 3082 | +VV_LOC u64 builtin__abs64(i64 x); | ||
| 3083 | +u64 builtin__get_str_intp_u64_format(StrIntpType fmt_type, int in_width, int in_precision, bool in_tail_zeros, bool in_sign, u8 in_pad_ch, int in_base, bool in_upper_case); | ||
| 3084 | +u32 builtin__get_str_intp_u32_format(StrIntpType fmt_type, int in_width, int in_precision, bool in_tail_zeros, bool in_sign, u8 in_pad_ch, int in_base, bool in_upper_case); | ||
| 3085 | +VV_LOC void builtin__StrIntpData_process_str_intp_data(StrIntpData* data, strings__Builder* sb); | ||
| 3086 | +string builtin__str_intp(int data_len, StrIntpData* input_base); | ||
| 3087 | +string builtin__str_intp_sq(string in_str); | ||
| 3088 | +string builtin__str_intp_rune(string in_str); | ||
| 3089 | +string builtin__str_intp_g32(string in_str); | ||
| 3090 | +string builtin__str_intp_g64(string in_str); | ||
| 3091 | +string builtin__str_intp_sub(string base_str, string in_str); | ||
| 3092 | +u16* builtin__string_to_wide(string _str, ToWideConfig param); | ||
| 3093 | +string builtin__string_from_wide(u16* _wstr); | ||
| 3094 | +string builtin__string_from_wide2(u16* _wstr, int len); | ||
| 3095 | +Array_u8 builtin__wide_to_ansi(u16* _wstr); | ||
| 3096 | +int builtin__utf8_char_len(u8 b); | ||
| 3097 | +string builtin__utf32_to_str(u32 code); | ||
| 3098 | +string builtin__utf32_to_str_no_malloc(u32 code, u8* buf); | ||
| 3099 | +int builtin__utf32_decode_to_buffer(u32 code, u8* buf); | ||
| 3100 | +int builtin__string_utf32_code(string _rune); | ||
| 3101 | +_result_rune Array_u8_utf8_to_utf32(Array_u8 _bytes); | ||
| 3102 | +VV_LOC bool builtin__utf8_is_continuation(u8 b); | ||
| 3103 | +VV_LOC multi_return_rune_int builtin__utf8_decode_rune(u8* _bytes, int available_len); | ||
| 3104 | +VV_LOC rune builtin__impl_utf8_to_utf32(u8* _bytes, int _bytes_len); | ||
| 3105 | +int builtin__utf8_str_visible_length(string s); | ||
| 3106 | +Array_u8 builtin__string_to_ansi_not_null_terminated(string _str); | ||
| 3107 | +bool builtin__ArrayFlags_is_empty(ArrayFlags* e); | ||
| 3108 | +bool builtin__ArrayFlags_has(ArrayFlags* e, ArrayFlags flag_); | ||
| 3109 | +bool builtin__ArrayFlags_all(ArrayFlags* e, ArrayFlags flag_); | ||
| 3110 | +void builtin__ArrayFlags_set(ArrayFlags* e, ArrayFlags flag_); | ||
| 3111 | +void builtin__ArrayFlags_set_all(ArrayFlags* e); | ||
| 3112 | +void builtin__ArrayFlags_clear(ArrayFlags* e, ArrayFlags flag_); | ||
| 3113 | +void builtin__ArrayFlags_clear_all(ArrayFlags* e); | ||
| 3114 | +void builtin__ArrayFlags_toggle(ArrayFlags* e, ArrayFlags flag_); | ||
| 3115 | +ArrayFlags builtin__ArrayFlags__static__zero(void); | ||
| 3116 | +VV_LOC void main__vf_init(void); | ||
| 3117 | +VV_EXP void vf_init(void); // exported fn main.vf_init | ||
| 3118 | +VV_LOC int main__vf_add(int a, int b); | ||
| 3119 | +VV_EXP int vf_add(int a, int b); // exported fn main.vf_add | ||
| 3120 | +VV_LOC char* main__vf_greet(char* name); | ||
| 3121 | +VV_EXP char* vf_greet(char* name); // exported fn main.vf_greet | ||
| 3122 | +VV_LOC void main__vf_free(voidptr p); | ||
| 3123 | +VV_EXP void vf_free(voidptr p); // exported fn main.vf_free | ||
| 3124 | +VV_LOC void main__main(void); | ||
| 3125 | +static bool Array_rune_arr_eq(Array_rune a, Array_rune b); | ||
| 3126 | +static bool builtin__closure__ClosureLifetimeState_struct_eq(builtin__closure__ClosureLifetimeState a, builtin__closure__ClosureLifetimeState b); | ||
| 3127 | +static bool Array_builtin__closure__ClosureLifetimeRecord_arr_eq(Array_builtin__closure__ClosureLifetimeRecord a, Array_builtin__closure__ClosureLifetimeRecord b); | ||
| 3128 | +static bool builtin__closure__ClosureLifetimeRecord_struct_eq(builtin__closure__ClosureLifetimeRecord a, builtin__closure__ClosureLifetimeRecord b); | ||
| 3129 | +static bool Array_builtin__closure__ClosureLifetimeFrame_arr_eq(Array_builtin__closure__ClosureLifetimeFrame a, Array_builtin__closure__ClosureLifetimeFrame b); | ||
| 3130 | +static bool builtin__closure__ClosureLifetimeFrame_struct_eq(builtin__closure__ClosureLifetimeFrame a, builtin__closure__ClosureLifetimeFrame b); | ||
| 3131 | + | ||
| 3132 | +// V global/const non-precomputed definitions: | ||
| 3133 | +static string _const_math__bits__overflow_error; // a string literal, inited later | ||
| 3134 | +static string _const_math__bits__divide_error; // a string literal, inited later | ||
| 3135 | +static string _const_strconv__digit_pairs; // a string literal, inited later | ||
| 3136 | +static string _const_strconv__base_digits; // a string literal, inited later | ||
| 3137 | +static string _const_grapheme_control_ranges; // a string literal, inited later | ||
| 3138 | +static string _const_grapheme_extend_ranges; // a string literal, inited later | ||
| 3139 | +static string _const_grapheme_spacing_mark_ranges; // a string literal, inited later | ||
| 3140 | +static string _const_grapheme_prepend_ranges; // a string literal, inited later | ||
| 3141 | +static string _const_grapheme_extended_pictographic_ranges; // a string literal, inited later | ||
| 3142 | +static string _const_digit_pairs; // a string literal, inited later | ||
| 3143 | +static string _const_si_s_code; // a string literal, inited later | ||
| 3144 | +static string _const_si_g32_code; // a string literal, inited later | ||
| 3145 | +static string _const_si_g64_code; // a string literal, inited later | ||
| 3146 | +builtin__closure__Closure g_closure; // global 6 | ||
| 3147 | + | ||
| 3148 | +static Array_fixed_u8_15 _const_builtin__closure__closure_thunk; // inited later | ||
| 3149 | +static Array_fixed_u8_6 _const_builtin__closure__closure_get_data_bytes; // inited later | ||
| 3150 | +static const u32 _const_math__bits__de_bruijn32 = 125613361; // precomputed2 | ||
| 3151 | +static Array_fixed_u8_32 _const_math__bits__de_bruijn32tab = {((u8)(0)), 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, | ||
| 3152 | +31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9}; // fixed array const | ||
| 3153 | +static const u64 _const_math__bits__de_bruijn64 = 285870213051353865U; // precomputed2 | ||
| 3154 | +static Array_fixed_u8_64 _const_math__bits__de_bruijn64tab = {((u8)(0)), 1, 56, 2, 57, 49, 28, 3, 61, 58, 42, 50, 38, 29, 17, 4, | ||
| 3155 | +62, 47, 59, 36, 45, 43, 51, 22, 53, 39, 33, 30, 24, 18, 12, 5, | ||
| 3156 | +63, 55, 48, 27, 60, 41, 37, 16, 46, 35, 44, 21, 52, 32, 23, 11, | ||
| 3157 | +54, 26, 40, 15, 34, 20, 31, 10, 25, 14, 19, 9, 13, 8, 7, 6}; // fixed array const | ||
| 3158 | +static const u64 _const_math__bits__m0 = 6148914691236517205U; // precomputed2 | ||
| 3159 | +static const u64 _const_math__bits__m1 = 3689348814741910323U; // precomputed2 | ||
| 3160 | +static const u64 _const_math__bits__m2 = 1085102592571150095U; // precomputed2 | ||
| 3161 | +static const u64 _const_math__bits__m3 = 71777214294589695U; // precomputed2 | ||
| 3162 | +static const u64 _const_math__bits__m4 = 281470681808895U; // precomputed2 | ||
| 3163 | +static const u8 _const_math__bits__n8 = 8; // precomputed2 | ||
| 3164 | +static const u16 _const_math__bits__n16 = 16; // precomputed2 | ||
| 3165 | +static const u32 _const_math__bits__n32 = 32; // precomputed2 | ||
| 3166 | +static const u64 _const_math__bits__n64 = 64U; // precomputed2 | ||
| 3167 | +static const u64 _const_math__bits__two32 = 4294967296U; // precomputed2 | ||
| 3168 | +static const u64 _const_math__bits__mask32 = 4294967295U; // precomputed2 | ||
| 3169 | +static Array_fixed_u8_256 _const_math__bits__ntz_8_tab = {((u8)(0x08)), 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3170 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3171 | +0x05, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3172 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3173 | +0x06, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3174 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3175 | +0x05, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3176 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3177 | +0x07, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3178 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3179 | +0x05, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3180 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3181 | +0x06, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3182 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3183 | +0x05, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3184 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00}; // fixed array const | ||
| 3185 | +static Array_fixed_u8_256 _const_math__bits__pop_8_tab = {((u8)(0x00)), 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, 0x03, 0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04, | ||
| 3186 | +0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04, 0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, | ||
| 3187 | +0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04, 0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, | ||
| 3188 | +0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, | ||
| 3189 | +0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04, 0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, | ||
| 3190 | +0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, | ||
| 3191 | +0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, | ||
| 3192 | +0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, 0x04, 0x05, 0x05, 0x06, 0x05, 0x06, 0x06, 0x07, | ||
| 3193 | +0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04, 0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, | ||
| 3194 | +0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, | ||
| 3195 | +0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, | ||
| 3196 | +0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, 0x04, 0x05, 0x05, 0x06, 0x05, 0x06, 0x06, 0x07, | ||
| 3197 | +0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, | ||
| 3198 | +0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, 0x04, 0x05, 0x05, 0x06, 0x05, 0x06, 0x06, 0x07, | ||
| 3199 | +0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, 0x04, 0x05, 0x05, 0x06, 0x05, 0x06, 0x06, 0x07, | ||
| 3200 | +0x04, 0x05, 0x05, 0x06, 0x05, 0x06, 0x06, 0x07, 0x05, 0x06, 0x06, 0x07, 0x06, 0x07, 0x07, 0x08}; // fixed array const | ||
| 3201 | +static Array_fixed_u8_256 _const_math__bits__rev_8_tab = {((u8)(0x00)), 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, | ||
| 3202 | +0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, | ||
| 3203 | +0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, | ||
| 3204 | +0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, | ||
| 3205 | +0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, | ||
| 3206 | +0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, | ||
| 3207 | +0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, | ||
| 3208 | +0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, | ||
| 3209 | +0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, | ||
| 3210 | +0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, | ||
| 3211 | +0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, | ||
| 3212 | +0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, | ||
| 3213 | +0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, | ||
| 3214 | +0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, | ||
| 3215 | +0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, | ||
| 3216 | +0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff}; // fixed array const | ||
| 3217 | +static Array_fixed_u8_256 _const_math__bits__len_8_tab = {((u8)(0x00)), 0x01, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, | ||
| 3218 | +0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, | ||
| 3219 | +0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, | ||
| 3220 | +0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, | ||
| 3221 | +0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, | ||
| 3222 | +0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, | ||
| 3223 | +0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, | ||
| 3224 | +0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, | ||
| 3225 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | ||
| 3226 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | ||
| 3227 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | ||
| 3228 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | ||
| 3229 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | ||
| 3230 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | ||
| 3231 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | ||
| 3232 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08}; // fixed array const | ||
| 3233 | +static const u32 _const_strconv__single_plus_zero = 0; // precomputed2 | ||
| 3234 | +static const u32 _const_strconv__single_minus_zero = 2147483648; // precomputed2 | ||
| 3235 | +static const u32 _const_strconv__single_plus_infinity = 2139095040; // precomputed2 | ||
| 3236 | +static const u32 _const_strconv__single_minus_infinity = 4286578688; // precomputed2 | ||
| 3237 | +static const u64 _const_strconv__double_plus_zero = 0U; // precomputed2 | ||
| 3238 | +static const u64 _const_strconv__double_minus_zero = 9223372036854775808U; // precomputed2 | ||
| 3239 | +static const u64 _const_strconv__double_plus_infinity = 9218868437227405312U; // precomputed2 | ||
| 3240 | +static const u64 _const_strconv__double_minus_infinity = 18442240474082181120U; // precomputed2 | ||
| 3241 | +static const u32 _const_strconv__c_ten = 10; // precomputed2 | ||
| 3242 | +static Array_fixed_u64_309 _const_strconv__pos_exp = {((u64)(0x3ff0000000000000LL)), ((u64)(0x4024000000000000LL)), ((u64)(0x4059000000000000LL)), ((u64)(0x408f400000000000LL)), ((u64)(0x40c3880000000000LL)), ((u64)(0x40f86a0000000000LL)), ((u64)(0x412e848000000000LL)), ((u64)(0x416312d000000000LL)), ((u64)(0x4197d78400000000LL)), ((u64)(0x41cdcd6500000000LL)), ((u64)(0x4202a05f20000000LL)), ((u64)(0x42374876e8000000LL)), ((u64)(0x426d1a94a2000000LL)), ((u64)(0x42a2309ce5400000LL)), ((u64)(0x42d6bcc41e900000LL)), ((u64)(0x430c6bf526340000LL)), | ||
| 3243 | +((u64)(0x4341c37937e08000LL)), ((u64)(0x4376345785d8a000LL)), ((u64)(0x43abc16d674ec800LL)), ((u64)(0x43e158e460913d00LL)), ((u64)(0x4415af1d78b58c40LL)), ((u64)(0x444b1ae4d6e2ef50LL)), ((u64)(0x4480f0cf064dd592LL)), ((u64)(0x44b52d02c7e14af6LL)), ((u64)(0x44ea784379d99db4LL)), ((u64)(0x45208b2a2c280291LL)), ((u64)(0x4554adf4b7320335LL)), ((u64)(0x4589d971e4fe8402LL)), ((u64)(0x45c027e72f1f1281LL)), ((u64)(0x45f431e0fae6d721LL)), ((u64)(0x46293e5939a08ceaLL)), ((u64)(0x465f8def8808b024LL)), | ||
| 3244 | +((u64)(0x4693b8b5b5056e17LL)), ((u64)(0x46c8a6e32246c99cLL)), ((u64)(0x46fed09bead87c03LL)), ((u64)(0x4733426172c74d82LL)), ((u64)(0x476812f9cf7920e3LL)), ((u64)(0x479e17b84357691bLL)), ((u64)(0x47d2ced32a16a1b1LL)), ((u64)(0x48078287f49c4a1dLL)), ((u64)(0x483d6329f1c35ca5LL)), ((u64)(0x48725dfa371a19e7LL)), ((u64)(0x48a6f578c4e0a061LL)), ((u64)(0x48dcb2d6f618c879LL)), ((u64)(0x4911efc659cf7d4cLL)), ((u64)(0x49466bb7f0435c9eLL)), ((u64)(0x497c06a5ec5433c6LL)), ((u64)(0x49b18427b3b4a05cLL)), | ||
| 3245 | +((u64)(0x49e5e531a0a1c873LL)), ((u64)(0x4a1b5e7e08ca3a8fLL)), ((u64)(0x4a511b0ec57e649aLL)), ((u64)(0x4a8561d276ddfdc0LL)), ((u64)(0x4ababa4714957d30LL)), ((u64)(0x4af0b46c6cdd6e3eLL)), ((u64)(0x4b24e1878814c9ceLL)), ((u64)(0x4b5a19e96a19fc41LL)), ((u64)(0x4b905031e2503da9LL)), ((u64)(0x4bc4643e5ae44d13LL)), ((u64)(0x4bf97d4df19d6057LL)), ((u64)(0x4c2fdca16e04b86dLL)), ((u64)(0x4c63e9e4e4c2f344LL)), ((u64)(0x4c98e45e1df3b015LL)), ((u64)(0x4ccf1d75a5709c1bLL)), ((u64)(0x4d03726987666191LL)), | ||
| 3246 | +((u64)(0x4d384f03e93ff9f5LL)), ((u64)(0x4d6e62c4e38ff872LL)), ((u64)(0x4da2fdbb0e39fb47LL)), ((u64)(0x4dd7bd29d1c87a19LL)), ((u64)(0x4e0dac74463a989fLL)), ((u64)(0x4e428bc8abe49f64LL)), ((u64)(0x4e772ebad6ddc73dLL)), ((u64)(0x4eacfa698c95390cLL)), ((u64)(0x4ee21c81f7dd43a7LL)), ((u64)(0x4f16a3a275d49491LL)), ((u64)(0x4f4c4c8b1349b9b5LL)), ((u64)(0x4f81afd6ec0e1411LL)), ((u64)(0x4fb61bcca7119916LL)), ((u64)(0x4feba2bfd0d5ff5bLL)), ((u64)(0x502145b7e285bf99LL)), ((u64)(0x50559725db272f7fLL)), | ||
| 3247 | +((u64)(0x508afcef51f0fb5fLL)), ((u64)(0x50c0de1593369d1bLL)), ((u64)(0x50f5159af8044462LL)), ((u64)(0x512a5b01b605557bLL)), ((u64)(0x516078e111c3556dLL)), ((u64)(0x5194971956342ac8LL)), ((u64)(0x51c9bcdfabc1357aLL)), ((u64)(0x5200160bcb58c16cLL)), ((u64)(0x52341b8ebe2ef1c7LL)), ((u64)(0x526922726dbaae39LL)), ((u64)(0x529f6b0f092959c7LL)), ((u64)(0x52d3a2e965b9d81dLL)), ((u64)(0x53088ba3bf284e24LL)), ((u64)(0x533eae8caef261adLL)), ((u64)(0x53732d17ed577d0cLL)), ((u64)(0x53a7f85de8ad5c4fLL)), | ||
| 3248 | +((u64)(0x53ddf67562d8b363LL)), ((u64)(0x5412ba095dc7701eLL)), ((u64)(0x5447688bb5394c25LL)), ((u64)(0x547d42aea2879f2eLL)), ((u64)(0x54b249ad2594c37dLL)), ((u64)(0x54e6dc186ef9f45cLL)), ((u64)(0x551c931e8ab87173LL)), ((u64)(0x5551dbf316b346e8LL)), ((u64)(0x558652efdc6018a2LL)), ((u64)(0x55bbe7abd3781ecaLL)), ((u64)(0x55f170cb642b133fLL)), ((u64)(0x5625ccfe3d35d80eLL)), ((u64)(0x565b403dcc834e12LL)), ((u64)(0x569108269fd210cbLL)), ((u64)(0x56c54a3047c694feLL)), ((u64)(0x56fa9cbc59b83a3dLL)), | ||
| 3249 | +((u64)(0x5730a1f5b8132466LL)), ((u64)(0x5764ca732617ed80LL)), ((u64)(0x5799fd0fef9de8e0LL)), ((u64)(0x57d03e29f5c2b18cLL)), ((u64)(0x58044db473335defLL)), ((u64)(0x583961219000356bLL)), ((u64)(0x586fb969f40042c5LL)), ((u64)(0x58a3d3e2388029bbLL)), ((u64)(0x58d8c8dac6a0342aLL)), ((u64)(0x590efb1178484135LL)), ((u64)(0x59435ceaeb2d28c1LL)), ((u64)(0x59783425a5f872f1LL)), ((u64)(0x59ae412f0f768fadLL)), ((u64)(0x59e2e8bd69aa19ccLL)), ((u64)(0x5a17a2ecc414a03fLL)), ((u64)(0x5a4d8ba7f519c84fLL)), | ||
| 3250 | +((u64)(0x5a827748f9301d32LL)), ((u64)(0x5ab7151b377c247eLL)), ((u64)(0x5aecda62055b2d9eLL)), ((u64)(0x5b22087d4358fc82LL)), ((u64)(0x5b568a9c942f3ba3LL)), ((u64)(0x5b8c2d43b93b0a8cLL)), ((u64)(0x5bc19c4a53c4e697LL)), ((u64)(0x5bf6035ce8b6203dLL)), ((u64)(0x5c2b843422e3a84dLL)), ((u64)(0x5c6132a095ce4930LL)), ((u64)(0x5c957f48bb41db7cLL)), ((u64)(0x5ccadf1aea12525bLL)), ((u64)(0x5d00cb70d24b7379LL)), ((u64)(0x5d34fe4d06de5057LL)), ((u64)(0x5d6a3de04895e46dLL)), ((u64)(0x5da066ac2d5daec4LL)), | ||
| 3251 | +((u64)(0x5dd4805738b51a75LL)), ((u64)(0x5e09a06d06e26112LL)), ((u64)(0x5e400444244d7cabLL)), ((u64)(0x5e7405552d60dbd6LL)), ((u64)(0x5ea906aa78b912ccLL)), ((u64)(0x5edf485516e7577fLL)), ((u64)(0x5f138d352e5096afLL)), ((u64)(0x5f48708279e4bc5bLL)), ((u64)(0x5f7e8ca3185deb72LL)), ((u64)(0x5fb317e5ef3ab327LL)), ((u64)(0x5fe7dddf6b095ff1LL)), ((u64)(0x601dd55745cbb7edLL)), ((u64)(0x6052a5568b9f52f4LL)), ((u64)(0x60874eac2e8727b1LL)), ((u64)(0x60bd22573a28f19dLL)), ((u64)(0x60f2357684599702LL)), | ||
| 3252 | +((u64)(0x6126c2d4256ffcc3LL)), ((u64)(0x615c73892ecbfbf4LL)), ((u64)(0x6191c835bd3f7d78LL)), ((u64)(0x61c63a432c8f5cd6LL)), ((u64)(0x61fbc8d3f7b3340cLL)), ((u64)(0x62315d847ad00087LL)), ((u64)(0x6265b4e5998400a9LL)), ((u64)(0x629b221effe500d4LL)), ((u64)(0x62d0f5535fef2084LL)), ((u64)(0x630532a837eae8a5LL)), ((u64)(0x633a7f5245e5a2cfLL)), ((u64)(0x63708f936baf85c1LL)), ((u64)(0x63a4b378469b6732LL)), ((u64)(0x63d9e056584240feLL)), ((u64)(0x64102c35f729689fLL)), ((u64)(0x6444374374f3c2c6LL)), | ||
| 3253 | +((u64)(0x647945145230b378LL)), ((u64)(0x64af965966bce056LL)), ((u64)(0x64e3bdf7e0360c36LL)), ((u64)(0x6518ad75d8438f43LL)), ((u64)(0x654ed8d34e547314LL)), ((u64)(0x6583478410f4c7ecLL)), ((u64)(0x65b819651531f9e8LL)), ((u64)(0x65ee1fbe5a7e7861LL)), ((u64)(0x6622d3d6f88f0b3dLL)), ((u64)(0x665788ccb6b2ce0cLL)), ((u64)(0x668d6affe45f818fLL)), ((u64)(0x66c262dfeebbb0f9LL)), ((u64)(0x66f6fb97ea6a9d38LL)), ((u64)(0x672cba7de5054486LL)), ((u64)(0x6761f48eaf234ad4LL)), ((u64)(0x679671b25aec1d89LL)), | ||
| 3254 | +((u64)(0x67cc0e1ef1a724ebLL)), ((u64)(0x680188d357087713LL)), ((u64)(0x6835eb082cca94d7LL)), ((u64)(0x686b65ca37fd3a0dLL)), ((u64)(0x68a11f9e62fe4448LL)), ((u64)(0x68d56785fbbdd55aLL)), ((u64)(0x690ac1677aad4ab1LL)), ((u64)(0x6940b8e0acac4eafLL)), ((u64)(0x6974e718d7d7625aLL)), ((u64)(0x69aa20df0dcd3af1LL)), ((u64)(0x69e0548b68a044d6LL)), ((u64)(0x6a1469ae42c8560cLL)), ((u64)(0x6a498419d37a6b8fLL)), ((u64)(0x6a7fe52048590673LL)), ((u64)(0x6ab3ef342d37a408LL)), ((u64)(0x6ae8eb0138858d0aLL)), | ||
| 3255 | +((u64)(0x6b1f25c186a6f04cLL)), ((u64)(0x6b537798f4285630LL)), ((u64)(0x6b88557f31326bbbLL)), ((u64)(0x6bbe6adefd7f06aaLL)), ((u64)(0x6bf302cb5e6f642aLL)), ((u64)(0x6c27c37e360b3d35LL)), ((u64)(0x6c5db45dc38e0c82LL)), ((u64)(0x6c9290ba9a38c7d1LL)), ((u64)(0x6cc734e940c6f9c6LL)), ((u64)(0x6cfd022390f8b837LL)), ((u64)(0x6d3221563a9b7323LL)), ((u64)(0x6d66a9abc9424febLL)), ((u64)(0x6d9c5416bb92e3e6LL)), ((u64)(0x6dd1b48e353bce70LL)), ((u64)(0x6e0621b1c28ac20cLL)), ((u64)(0x6e3baa1e332d728fLL)), | ||
| 3256 | +((u64)(0x6e714a52dffc6799LL)), ((u64)(0x6ea59ce797fb817fLL)), ((u64)(0x6edb04217dfa61dfLL)), ((u64)(0x6f10e294eebc7d2cLL)), ((u64)(0x6f451b3a2a6b9c76LL)), ((u64)(0x6f7a6208b5068394LL)), ((u64)(0x6fb07d457124123dLL)), ((u64)(0x6fe49c96cd6d16ccLL)), ((u64)(0x7019c3bc80c85c7fLL)), ((u64)(0x70501a55d07d39cfLL)), ((u64)(0x708420eb449c8843LL)), ((u64)(0x70b9292615c3aa54LL)), ((u64)(0x70ef736f9b3494e9LL)), ((u64)(0x7123a825c100dd11LL)), ((u64)(0x7158922f31411456LL)), ((u64)(0x718eb6bafd91596bLL)), | ||
| 3257 | +((u64)(0x71c33234de7ad7e3LL)), ((u64)(0x71f7fec216198ddcLL)), ((u64)(0x722dfe729b9ff153LL)), ((u64)(0x7262bf07a143f6d4LL)), ((u64)(0x72976ec98994f489LL)), ((u64)(0x72cd4a7bebfa31abLL)), ((u64)(0x73024e8d737c5f0bLL)), ((u64)(0x7336e230d05b76cdLL)), ((u64)(0x736c9abd04725481LL)), ((u64)(0x73a1e0b622c774d0LL)), ((u64)(0x73d658e3ab795204LL)), ((u64)(0x740bef1c9657a686LL)), ((u64)(0x74417571ddf6c814LL)), ((u64)(0x7475d2ce55747a18LL)), ((u64)(0x74ab4781ead1989eLL)), ((u64)(0x74e10cb132c2ff63LL)), | ||
| 3258 | +((u64)(0x75154fdd7f73bf3cLL)), ((u64)(0x754aa3d4df50af0bLL)), ((u64)(0x7580a6650b926d67LL)), ((u64)(0x75b4cffe4e7708c0LL)), ((u64)(0x75ea03fde214caf1LL)), ((u64)(0x7620427ead4cfed6LL)), ((u64)(0x7654531e58a03e8cLL)), ((u64)(0x768967e5eec84e2fLL)), ((u64)(0x76bfc1df6a7a61bbLL)), ((u64)(0x76f3d92ba28c7d15LL)), ((u64)(0x7728cf768b2f9c5aLL)), ((u64)(0x775f03542dfb8370LL)), ((u64)(0x779362149cbd3226LL)), ((u64)(0x77c83a99c3ec7eb0LL)), ((u64)(0x77fe494034e79e5cLL)), ((u64)(0x7832edc82110c2f9LL)), | ||
| 3259 | +((u64)(0x7867a93a2954f3b8LL)), ((u64)(0x789d9388b3aa30a5LL)), ((u64)(0x78d27c35704a5e67LL)), ((u64)(0x79071b42cc5cf601LL)), ((u64)(0x793ce2137f743382LL)), ((u64)(0x79720d4c2fa8a031LL)), ((u64)(0x79a6909f3b92c83dLL)), ((u64)(0x79dc34c70a777a4dLL)), ((u64)(0x7a11a0fc668aac70LL)), ((u64)(0x7a46093b802d578cLL)), ((u64)(0x7a7b8b8a6038ad6fLL)), ((u64)(0x7ab137367c236c65LL)), ((u64)(0x7ae585041b2c477fLL)), ((u64)(0x7b1ae64521f7595eLL)), ((u64)(0x7b50cfeb353a97dbLL)), ((u64)(0x7b8503e602893dd2LL)), | ||
| 3260 | +((u64)(0x7bba44df832b8d46LL)), ((u64)(0x7bf06b0bb1fb384cLL)), ((u64)(0x7c2485ce9e7a065fLL)), ((u64)(0x7c59a742461887f6LL)), ((u64)(0x7c9008896bcf54faLL)), ((u64)(0x7cc40aabc6c32a38LL)), ((u64)(0x7cf90d56b873f4c7LL)), ((u64)(0x7d2f50ac6690f1f8LL)), ((u64)(0x7d63926bc01a973bLL)), ((u64)(0x7d987706b0213d0aLL)), ((u64)(0x7dce94c85c298c4cLL)), ((u64)(0x7e031cfd3999f7b0LL)), ((u64)(0x7e37e43c8800759cLL)), ((u64)(0x7e6ddd4baa009303LL)), ((u64)(0x7ea2aa4f4a405be2LL)), ((u64)(0x7ed754e31cd072daLL)), ((u64)(0x7f0d2a1be4048f90LL)), ((u64)(0x7f423a516e82d9baLL)), ((u64)(0x7f76c8e5ca239029LL)), ((u64)(0x7fac7b1f3cac7433LL)), ((u64)(0x7fe1ccf385ebc8a0LL))}; // fixed array const | ||
| 3261 | +static Array_fixed_u64_324 _const_strconv__neg_exp = {((u64)(0x3ff0000000000000LL)), ((u64)(0x3fb999999999999aLL)), ((u64)(0x3f847ae147ae147bLL)), ((u64)(0x3f50624dd2f1a9fcLL)), ((u64)(0x3f1a36e2eb1c432dLL)), ((u64)(0x3ee4f8b588e368f1LL)), ((u64)(0x3eb0c6f7a0b5ed8dLL)), ((u64)(0x3e7ad7f29abcaf48LL)), ((u64)(0x3e45798ee2308c3aLL)), ((u64)(0x3e112e0be826d695LL)), ((u64)(0x3ddb7cdfd9d7bdbbLL)), ((u64)(0x3da5fd7fe1796495LL)), ((u64)(0x3d719799812dea11LL)), ((u64)(0x3d3c25c268497682LL)), ((u64)(0x3d06849b86a12b9bLL)), ((u64)(0x3cd203af9ee75616LL)), | ||
| 3262 | +((u64)(0x3c9cd2b297d889bcLL)), ((u64)(0x3c670ef54646d497LL)), ((u64)(0x3c32725dd1d243acLL)), ((u64)(0x3bfd83c94fb6d2acLL)), ((u64)(0x3bc79ca10c924223LL)), ((u64)(0x3b92e3b40a0e9b4fLL)), ((u64)(0x3b5e392010175ee6LL)), ((u64)(0x3b282db34012b251LL)), ((u64)(0x3af357c299a88ea7LL)), ((u64)(0x3abef2d0f5da7dd9LL)), ((u64)(0x3a88c240c4aecb14LL)), ((u64)(0x3a53ce9a36f23c10LL)), ((u64)(0x3a1fb0f6be506019LL)), ((u64)(0x39e95a5efea6b347LL)), ((u64)(0x39b4484bfeebc2a0LL)), ((u64)(0x398039d665896880LL)), | ||
| 3263 | +((u64)(0x3949f623d5a8a733LL)), ((u64)(0x3914c4e977ba1f5cLL)), ((u64)(0x38e09d8792fb4c49LL)), ((u64)(0x38aa95a5b7f87a0fLL)), ((u64)(0x38754484932d2e72LL)), ((u64)(0x3841039d428a8b8fLL)), ((u64)(0x380b38fb9daa78e4LL)), ((u64)(0x37d5c72fb1552d83LL)), ((u64)(0x37a16c262777579cLL)), ((u64)(0x376be03d0bf225c7LL)), ((u64)(0x37364cfda3281e39LL)), ((u64)(0x3701d7314f534b61LL)), ((u64)(0x36cc8b8218854567LL)), ((u64)(0x3696d601ad376ab9LL)), ((u64)(0x366244ce242c5561LL)), ((u64)(0x362d3ae36d13bbceLL)), | ||
| 3264 | +((u64)(0x35f7624f8a762fd8LL)), ((u64)(0x35c2b50c6ec4f313LL)), ((u64)(0x358dee7a4ad4b81fLL)), ((u64)(0x3557f1fb6f10934cLL)), ((u64)(0x352327fc58da0f70LL)), ((u64)(0x34eea6608e29b24dLL)), ((u64)(0x34b8851a0b548ea4LL)), ((u64)(0x34839dae6f76d883LL)), ((u64)(0x344f62b0b257c0d2LL)), ((u64)(0x34191bc08eac9a41LL)), ((u64)(0x33e41633a556e1ceLL)), ((u64)(0x33b011c2eaabe7d8LL)), ((u64)(0x3379b604aaaca626LL)), ((u64)(0x3344919d5556eb52LL)), ((u64)(0x3310747ddddf22a8LL)), ((u64)(0x32da53fc9631d10dLL)), | ||
| 3265 | +((u64)(0x32a50ffd44f4a73dLL)), ((u64)(0x3270d9976a5d5297LL)), ((u64)(0x323af5bf109550f2LL)), ((u64)(0x32059165a6ddda5bLL)), ((u64)(0x31d1411e1f17e1e3LL)), ((u64)(0x319b9b6364f30304LL)), ((u64)(0x316615e91d8f359dLL)), ((u64)(0x3131ab20e472914aLL)), ((u64)(0x30fc45016d841baaLL)), ((u64)(0x30c69d9abe034955LL)), ((u64)(0x309217aefe690777LL)), ((u64)(0x305cf2b1970e7258LL)), ((u64)(0x3027288e1271f513LL)), ((u64)(0x2ff286d80ec190dcLL)), ((u64)(0x2fbda48ce468e7c7LL)), ((u64)(0x2f87b6d71d20b96cLL)), | ||
| 3266 | +((u64)(0x2f52f8ac174d6123LL)), ((u64)(0x2f1e5aacf2156838LL)), ((u64)(0x2ee8488a5b445360LL)), ((u64)(0x2eb36d3b7c36a91aLL)), ((u64)(0x2e7f152bf9f10e90LL)), ((u64)(0x2e48ddbcc7f40ba6LL)), ((u64)(0x2e13e497065cd61fLL)), ((u64)(0x2ddfd424d6faf031LL)), ((u64)(0x2da97683df2f268dLL)), ((u64)(0x2d745ecfe5bf520bLL)), ((u64)(0x2d404bd984990e6fLL)), ((u64)(0x2d0a12f5a0f4e3e5LL)), ((u64)(0x2cd4dbf7b3f71cb7LL)), ((u64)(0x2ca0aff95cc5b092LL)), ((u64)(0x2c6ab328946f80eaLL)), ((u64)(0x2c355c2076bf9a55LL)), | ||
| 3267 | +((u64)(0x2c0116805effaeaaLL)), ((u64)(0x2bcb5733cb32b111LL)), ((u64)(0x2b95df5ca28ef40dLL)), ((u64)(0x2b617f7d4ed8c33eLL)), ((u64)(0x2b2bff2ee48e0530LL)), ((u64)(0x2af665bf1d3e6a8dLL)), ((u64)(0x2ac1eaff4a98553dLL)), ((u64)(0x2a8cab3210f3bb95LL)), ((u64)(0x2a56ef5b40c2fc77LL)), ((u64)(0x2a225915cd68c9f9LL)), ((u64)(0x29ed5b561574765bLL)), ((u64)(0x29b77c44ddf6c516LL)), ((u64)(0x2982c9d0b1923745LL)), ((u64)(0x294e0fb44f50586eLL)), ((u64)(0x29180c903f7379f2LL)), ((u64)(0x28e33d4032c2c7f5LL)), | ||
| 3268 | +((u64)(0x28aec866b79e0cbaLL)), ((u64)(0x2878a0522c7e7095LL)), ((u64)(0x2843b374f06526deLL)), ((u64)(0x280f8587e7083e30LL)), ((u64)(0x27d9379fec069826LL)), ((u64)(0x27a42c7ff0054685LL)), ((u64)(0x277023998cd10537LL)), ((u64)(0x2739d28f47b4d525LL)), ((u64)(0x2704a8729fc3ddb7LL)), ((u64)(0x26d086c219697e2cLL)), ((u64)(0x269a71368f0f3047LL)), ((u64)(0x2665275ed8d8f36cLL)), ((u64)(0x2630ec4be0ad8f89LL)), ((u64)(0x25fb13ac9aaf4c0fLL)), ((u64)(0x25c5a956e225d672LL)), ((u64)(0x2591544581b7dec2LL)), | ||
| 3269 | +((u64)(0x255bba08cf8c979dLL)), ((u64)(0x25262e6d72d6dfb0LL)), ((u64)(0x24f1bebdf578b2f4LL)), ((u64)(0x24bc6463225ab7ecLL)), ((u64)(0x2486b6b5b5155ff0LL)), ((u64)(0x24522bc490dde65aLL)), ((u64)(0x241d12d41afca3c3LL)), ((u64)(0x23e7424348ca1c9cLL)), ((u64)(0x23b29b69070816e3LL)), ((u64)(0x237dc574d80cf16bLL)), ((u64)(0x2347d12a4670c123LL)), ((u64)(0x23130dbb6b8d674fLL)), ((u64)(0x22de7c5f127bd87eLL)), ((u64)(0x22a8637f41fcad32LL)), ((u64)(0x227382cc34ca2428LL)), ((u64)(0x223f37ad21436d0cLL)), | ||
| 3270 | +((u64)(0x2208f9574dcf8a70LL)), ((u64)(0x21d3faac3e3fa1f3LL)), ((u64)(0x219ff779fd329cb9LL)), ((u64)(0x216992c7fdc216faLL)), ((u64)(0x2134756ccb01abfbLL)), ((u64)(0x21005df0a267bcc9LL)), ((u64)(0x20ca2fe76a3f9475LL)), ((u64)(0x2094f31f8832dd2aLL)), ((u64)(0x2060c27fa028b0efLL)), ((u64)(0x202ad0cc33744e4bLL)), ((u64)(0x1ff573d68f903ea2LL)), ((u64)(0x1fc1297872d9cbb5LL)), ((u64)(0x1f8b758d848fac55LL)), ((u64)(0x1f55f7a46a0c89ddLL)), ((u64)(0x1f2192e9ee706e4bLL)), ((u64)(0x1eec1e43171a4a11LL)), | ||
| 3271 | +((u64)(0x1eb67e9c127b6e74LL)), ((u64)(0x1e81fee341fc585dLL)), ((u64)(0x1e4ccb0536608d61LL)), ((u64)(0x1e1708d0f84d3de7LL)), ((u64)(0x1de26d73f9d764b9LL)), ((u64)(0x1dad7becc2f23ac2LL)), ((u64)(0x1d779657025b6235LL)), ((u64)(0x1d42deac01e2b4f7LL)), ((u64)(0x1d0e3113363787f2LL)), ((u64)(0x1cd8274291c6065bLL)), ((u64)(0x1ca3529ba7d19eafLL)), ((u64)(0x1c6eea92a61c3118LL)), ((u64)(0x1c38bba884e35a7aLL)), ((u64)(0x1c03c9539d82aec8LL)), ((u64)(0x1bcfa885c8d117a6LL)), ((u64)(0x1b99539e3a40dfb8LL)), | ||
| 3272 | +((u64)(0x1b6442e4fb671960LL)), ((u64)(0x1b303583fc527ab3LL)), ((u64)(0x1af9ef3993b72ab8LL)), ((u64)(0x1ac4bf6142f8eefaLL)), ((u64)(0x1a90991a9bfa58c8LL)), ((u64)(0x1a5a8e90f9908e0dLL)), ((u64)(0x1a253eda614071a4LL)), ((u64)(0x19f0ff151a99f483LL)), ((u64)(0x19bb31bb5dc320d2LL)), ((u64)(0x1985c162b168e70eLL)), ((u64)(0x1951678227871f3eLL)), ((u64)(0x191bd8d03f3e9864LL)), ((u64)(0x18e6470cff6546b6LL)), ((u64)(0x18b1d270cc51055fLL)), ((u64)(0x187c83e7ad4e6efeLL)), ((u64)(0x1846cfec8aa52598LL)), | ||
| 3273 | +((u64)(0x18123ff06eea847aLL)), ((u64)(0x17dd331a4b10d3f6LL)), ((u64)(0x17a75c1508da432bLL)), ((u64)(0x1772b010d3e1cf56LL)), ((u64)(0x173de6815302e556LL)), ((u64)(0x1707eb9aa8cf1ddeLL)), ((u64)(0x16d322e220a5b17eLL)), ((u64)(0x169e9e369aa2b597LL)), ((u64)(0x16687e92154ef7acLL)), ((u64)(0x16339874ddd8c623LL)), ((u64)(0x15ff5a549627a36cLL)), ((u64)(0x15c91510781fb5f0LL)), ((u64)(0x159410d9f9b2f7f3LL)), ((u64)(0x15600d7b2e28c65cLL)), ((u64)(0x1529af2b7d0e0a2dLL)), ((u64)(0x14f48c22ca71a1bdLL)), | ||
| 3274 | +((u64)(0x14c0701bd527b498LL)), ((u64)(0x148a4cf9550c5426LL)), ((u64)(0x14550a6110d6a9b8LL)), ((u64)(0x1420d51a73deee2dLL)), ((u64)(0x13eaee90b964b047LL)), ((u64)(0x13b58ba6fab6f36cLL)), ((u64)(0x13813c85955f2923LL)), ((u64)(0x134b9408eefea839LL)), ((u64)(0x1316100725988694LL)), ((u64)(0x12e1a66c1e139eddLL)), ((u64)(0x12ac3d79c9b8fe2eLL)), ((u64)(0x12769794a160cb58LL)), ((u64)(0x124212dd4de70913LL)), ((u64)(0x120ceafbafd80e85LL)), ((u64)(0x11d72262f3133ed1LL)), ((u64)(0x11a281e8c275cbdaLL)), | ||
| 3275 | +((u64)(0x116d9ca79d89462aLL)), ((u64)(0x1137b08617a104eeLL)), ((u64)(0x1102f39e794d9d8bLL)), ((u64)(0x10ce5297287c2f45LL)), ((u64)(0x1098421286c9bf6bLL)), ((u64)(0x1063680ed23aff89LL)), ((u64)(0x102f0ce4839198dbLL)), ((u64)(0x0ff8d71d360e13e2LL)), ((u64)(0x0fc3df4a91a4dcb5LL)), ((u64)(0x0f8fcbaa82a16121LL)), ((u64)(0x0f596fbb9bb44db4LL)), ((u64)(0x0f245962e2f6a490LL)), ((u64)(0x0ef047824f2bb6daLL)), ((u64)(0x0eba0c03b1df8af6LL)), ((u64)(0x0e84d6695b193bf8LL)), ((u64)(0x0e50ab877c142ffaLL)), | ||
| 3276 | +((u64)(0x0e1aac0bf9b9e65cLL)), ((u64)(0x0de5566ffafb1eb0LL)), ((u64)(0x0db111f32f2f4bc0LL)), ((u64)(0x0d7b4feb7eb212cdLL)), ((u64)(0x0d45d98932280f0aLL)), ((u64)(0x0d117ad428200c08LL)), ((u64)(0x0cdbf7b9d9cce00dLL)), ((u64)(0x0ca65fc7e170b33eLL)), ((u64)(0x0c71e6398126f5cbLL)), ((u64)(0x0c3ca38f350b22dfLL)), ((u64)(0x0c06e93f5da2824cLL)), ((u64)(0x0bd25432b14ecea3LL)), ((u64)(0x0b9d53844ee47dd1LL)), ((u64)(0x0b677603725064a8LL)), ((u64)(0x0b32c4cf8ea6b6ecLL)), ((u64)(0x0afe07b27dd78b14LL)), | ||
| 3277 | +((u64)(0x0ac8062864ac6f43LL)), ((u64)(0x0a9338205089f29cLL)), ((u64)(0x0a5ec033b40fea93LL)), ((u64)(0x0a2899c2f6732210LL)), ((u64)(0x09f3ae3591f5b4d9LL)), ((u64)(0x09bf7d228322baf5LL)), ((u64)(0x098930e868e89591LL)), ((u64)(0x0954272053ed4474LL)), ((u64)(0x09201f4d0ff10390LL)), ((u64)(0x08e9cbae7fe805b3LL)), ((u64)(0x08b4a2f1ffecd15cLL)), ((u64)(0x0880825b3323dab0LL)), ((u64)(0x084a6a2b85062ab3LL)), ((u64)(0x081521bc6a6b555cLL)), ((u64)(0x07e0e7c9eebc444aLL)), ((u64)(0x07ab0c764ac6d3a9LL)), | ||
| 3278 | +((u64)(0x0775a391d56bdc87LL)), ((u64)(0x07414fa7ddefe3a0LL)), ((u64)(0x070bb2a62fe638ffLL)), ((u64)(0x06d62884f31e93ffLL)), ((u64)(0x06a1ba03f5b21000LL)), ((u64)(0x066c5cd322b67fffLL)), ((u64)(0x0636b0a8e891ffffLL)), ((u64)(0x060226ed86db3333LL)), ((u64)(0x05cd0b15a491eb84LL)), ((u64)(0x05973c115074bc6aLL)), ((u64)(0x05629674405d6388LL)), ((u64)(0x052dbd86cd6238d9LL)), ((u64)(0x04f7cad23de82d7bLL)), ((u64)(0x04c308a831868ac9LL)), ((u64)(0x048e74404f3daadbLL)), ((u64)(0x04585d003f6488afLL)), | ||
| 3279 | +((u64)(0x04237d99cc506d59LL)), ((u64)(0x03ef2f5c7a1a488eLL)), ((u64)(0x03b8f2b061aea072LL)), ((u64)(0x0383f559e7bee6c1LL)), ((u64)(0x034feef63f97d79cLL)), ((u64)(0x03198bf832dfdfb0LL)), ((u64)(0x02e46ff9c24cb2f3LL)), ((u64)(0x02b059949b708f29LL)), ((u64)(0x027a28edc580e50eLL)), ((u64)(0x0244ed8b04671da5LL)), ((u64)(0x0210be08d0527e1dLL)), ((u64)(0x01dac9a7b3b7302fLL)), ((u64)(0x01a56e1fc2f8f359LL)), ((u64)(0x017124e63593f5e1LL)), ((u64)(0x013b6e3d22865634LL)), ((u64)(0x0105f1ca820511c3LL)), | ||
| 3280 | +((u64)(0x00d18e3b9b374169LL)), ((u64)(0x009c16c5c5253575LL)), ((u64)(0x0066789e3750f791LL)), ((u64)(0x0031fa182c40c60dLL)), ((u64)(0x000730d67819e8d2LL)), ((u64)(0x0000b8157268fdafLL)), ((u64)(0x000012688b70e62bLL)), ((u64)(0x000001d74124e3d1LL)), ((u64)(0x0000002f201d49fbLL)), ((u64)(0x00000004b6695433LL)), ((u64)(0x0000000078a42205)), ((u64)(0x000000000c1069cd)), ((u64)(0x000000000134d761)), ((u64)(0x00000000001ee257)), ((u64)(0x00000000000316a2)), ((u64)(0x0000000000004f10)), ((u64)(0x00000000000007e8)), ((u64)(0x00000000000000ca)), ((u64)(0x0000000000000014)), ((u64)(0x0000000000000002))}; // fixed array const | ||
| 3281 | +static i64 _const_strconv__i64_min_int32; // inited later | ||
| 3282 | +static i64 _const_strconv__i64_max_int32; // inited later | ||
| 3283 | +static Array_fixed_u32_10 _const_strconv__ten_pow_table_32 = {((u32)(1)), ((u32)(10)), ((u32)(100)), ((u32)(1000)), ((u32)(10000)), ((u32)(100000)), ((u32)(1000000)), ((u32)(10000000)), ((u32)(100000000)), ((u32)(1000000000))}; // fixed array const | ||
| 3284 | +static const u32 _const_strconv__mantbits32 = 23; // precomputed2 | ||
| 3285 | +static const u32 _const_strconv__expbits32 = 8; // precomputed2 | ||
| 3286 | +static Array_fixed_u64_20 _const_strconv__ten_pow_table_64 = {((u64)(1)), ((u64)(10)), ((u64)(100)), ((u64)(1000)), ((u64)(10000)), ((u64)(100000)), ((u64)(1000000)), ((u64)(10000000)), ((u64)(100000000)), ((u64)(1000000000)), ((u64)(10000000000LL)), ((u64)(100000000000LL)), ((u64)(1000000000000LL)), ((u64)(10000000000000LL)), ((u64)(100000000000000LL)), ((u64)(1000000000000000LL)), ((u64)(10000000000000000LL)), ((u64)(100000000000000000LL)), ((u64)(1000000000000000000LL)), ((u64)(10000000000000000000ULL))}; // fixed array const | ||
| 3287 | +static const u32 _const_strconv__mantbits64 = 52; // precomputed2 | ||
| 3288 | +static const u32 _const_strconv__expbits64 = 11; // precomputed2 | ||
| 3289 | +static Array_fixed_f64_36 _const_strconv__dec_round = {((f64)(0.5)), 0.05, 0.005, 0.0005, 0.00005, 0.000005, 0.0000005, 0.00000005, 0.000000005, 0.0000000005, 0.00000000005, 0.000000000005, 0.0000000000005, 0.00000000000005, 0.000000000000005, 0.0000000000000005, | ||
| 3290 | +0.00000000000000005, 0.000000000000000005, 0.0000000000000000005, 0.00000000000000000005, 0.000000000000000000005, 0.0000000000000000000005, 0.00000000000000000000005, 0.000000000000000000000005, 0.0000000000000000000000005, 0.00000000000000000000000005, 0.000000000000000000000000005, 0.0000000000000000000000000005, 0.00000000000000000000000000005, 0.000000000000000000000000000005, 0.0000000000000000000000000000005, 0.00000000000000000000000000000005, 0.000000000000000000000000000000005, 0.0000000000000000000000000000000005, 0.00000000000000000000000000000000005, 0.000000000000000000000000000000000005}; // fixed array const | ||
| 3291 | +static Array_fixed_u64_47 _const_strconv__pow5_split_32 = {((u64)(1152921504606846976LL)), ((u64)(1441151880758558720LL)), ((u64)(1801439850948198400LL)), ((u64)(2251799813685248000LL)), ((u64)(1407374883553280000LL)), ((u64)(1759218604441600000LL)), ((u64)(2199023255552000000LL)), ((u64)(1374389534720000000LL)), ((u64)(1717986918400000000LL)), ((u64)(2147483648000000000LL)), ((u64)(1342177280000000000LL)), ((u64)(1677721600000000000LL)), ((u64)(2097152000000000000LL)), ((u64)(1310720000000000000LL)), ((u64)(1638400000000000000LL)), ((u64)(2048000000000000000LL)), | ||
| 3292 | +((u64)(1280000000000000000LL)), ((u64)(1600000000000000000LL)), ((u64)(2000000000000000000LL)), ((u64)(1250000000000000000LL)), ((u64)(1562500000000000000LL)), ((u64)(1953125000000000000LL)), ((u64)(1220703125000000000LL)), ((u64)(1525878906250000000LL)), ((u64)(1907348632812500000LL)), ((u64)(1192092895507812500LL)), ((u64)(1490116119384765625LL)), ((u64)(1862645149230957031LL)), ((u64)(1164153218269348144LL)), ((u64)(1455191522836685180LL)), ((u64)(1818989403545856475LL)), ((u64)(2273736754432320594LL)), | ||
| 3293 | +((u64)(1421085471520200371LL)), ((u64)(1776356839400250464LL)), ((u64)(2220446049250313080LL)), ((u64)(1387778780781445675LL)), ((u64)(1734723475976807094LL)), ((u64)(2168404344971008868LL)), ((u64)(1355252715606880542LL)), ((u64)(1694065894508600678LL)), ((u64)(2117582368135750847LL)), ((u64)(1323488980084844279LL)), ((u64)(1654361225106055349LL)), ((u64)(2067951531382569187LL)), ((u64)(1292469707114105741LL)), ((u64)(1615587133892632177LL)), ((u64)(2019483917365790221LL))}; // fixed array const | ||
| 3294 | +static Array_fixed_u64_31 _const_strconv__pow5_inv_split_32 = {((u64)(576460752303423489LL)), ((u64)(461168601842738791LL)), ((u64)(368934881474191033LL)), ((u64)(295147905179352826LL)), ((u64)(472236648286964522LL)), ((u64)(377789318629571618LL)), ((u64)(302231454903657294LL)), ((u64)(483570327845851670LL)), ((u64)(386856262276681336LL)), ((u64)(309485009821345069LL)), ((u64)(495176015714152110LL)), ((u64)(396140812571321688LL)), ((u64)(316912650057057351LL)), ((u64)(507060240091291761LL)), ((u64)(405648192073033409LL)), ((u64)(324518553658426727LL)), | ||
| 3295 | +((u64)(519229685853482763LL)), ((u64)(415383748682786211LL)), ((u64)(332306998946228969LL)), ((u64)(531691198313966350LL)), ((u64)(425352958651173080LL)), ((u64)(340282366920938464LL)), ((u64)(544451787073501542LL)), ((u64)(435561429658801234LL)), ((u64)(348449143727040987LL)), ((u64)(557518629963265579LL)), ((u64)(446014903970612463LL)), ((u64)(356811923176489971LL)), ((u64)(570899077082383953LL)), ((u64)(456719261665907162LL)), ((u64)(365375409332725730LL))}; // fixed array const | ||
| 3296 | +static Array_fixed_u64_652 _const_strconv__pow5_split_64_x = {((u64)(0x0000000000000000)), ((u64)(0x0100000000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x0140000000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x0190000000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01f4000000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x0138800000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x0186a00000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01e8480000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01312d0000000000LL)), | ||
| 3297 | +((u64)(0x0000000000000000)), ((u64)(0x017d784000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01dcd65000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x012a05f200000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x0174876e80000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01d1a94a20000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x012309ce54000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x016bcc41e9000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01c6bf5263400000LL)), | ||
| 3298 | +((u64)(0x0000000000000000)), ((u64)(0x011c37937e080000LL)), ((u64)(0x0000000000000000)), ((u64)(0x016345785d8a0000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01bc16d674ec8000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01158e460913d000LL)), ((u64)(0x0000000000000000)), ((u64)(0x015af1d78b58c400LL)), ((u64)(0x0000000000000000)), ((u64)(0x01b1ae4d6e2ef500LL)), ((u64)(0x0000000000000000)), ((u64)(0x010f0cf064dd5920LL)), ((u64)(0x0000000000000000)), ((u64)(0x0152d02c7e14af68LL)), | ||
| 3299 | +((u64)(0x0000000000000000)), ((u64)(0x01a784379d99db42LL)), ((u64)(0x4000000000000000LL)), ((u64)(0x0108b2a2c2802909LL)), ((u64)(0x9000000000000000ULL)), ((u64)(0x014adf4b7320334bLL)), ((u64)(0x7400000000000000LL)), ((u64)(0x019d971e4fe8401eLL)), ((u64)(0x0880000000000000LL)), ((u64)(0x01027e72f1f12813LL)), ((u64)(0xcaa0000000000000ULL)), ((u64)(0x01431e0fae6d7217LL)), ((u64)(0xbd48000000000000ULL)), ((u64)(0x0193e5939a08ce9dLL)), ((u64)(0x2c9a000000000000LL)), ((u64)(0x01f8def8808b0245LL)), | ||
| 3300 | +((u64)(0x3be0400000000000LL)), ((u64)(0x013b8b5b5056e16bLL)), ((u64)(0x0ad8500000000000LL)), ((u64)(0x018a6e32246c99c6LL)), ((u64)(0x8d8e640000000000ULL)), ((u64)(0x01ed09bead87c037LL)), ((u64)(0xb878fe8000000000ULL)), ((u64)(0x013426172c74d822LL)), ((u64)(0x66973e2000000000LL)), ((u64)(0x01812f9cf7920e2bLL)), ((u64)(0x403d0da800000000LL)), ((u64)(0x01e17b84357691b6LL)), ((u64)(0xe826288900000000ULL)), ((u64)(0x012ced32a16a1b11LL)), ((u64)(0x622fb2ab40000000LL)), ((u64)(0x0178287f49c4a1d6LL)), | ||
| 3301 | +((u64)(0xfabb9f5610000000ULL)), ((u64)(0x01d6329f1c35ca4bLL)), ((u64)(0x7cb54395ca000000LL)), ((u64)(0x0125dfa371a19e6fLL)), ((u64)(0x5be2947b3c800000LL)), ((u64)(0x016f578c4e0a060bLL)), ((u64)(0x32db399a0ba00000LL)), ((u64)(0x01cb2d6f618c878eLL)), ((u64)(0xdfc9040047440000ULL)), ((u64)(0x011efc659cf7d4b8LL)), ((u64)(0x17bb450059150000LL)), ((u64)(0x0166bb7f0435c9e7LL)), ((u64)(0xddaa16406f5a4000ULL)), ((u64)(0x01c06a5ec5433c60LL)), ((u64)(0x8a8a4de845986800ULL)), ((u64)(0x0118427b3b4a05bcLL)), | ||
| 3302 | +((u64)(0xad2ce16256fe8200ULL)), ((u64)(0x015e531a0a1c872bLL)), ((u64)(0x987819baecbe2280ULL)), ((u64)(0x01b5e7e08ca3a8f6LL)), ((u64)(0x1f4b1014d3f6d590LL)), ((u64)(0x0111b0ec57e6499aLL)), ((u64)(0xa71dd41a08f48af4ULL)), ((u64)(0x01561d276ddfdc00LL)), ((u64)(0xd0e549208b31adb1ULL)), ((u64)(0x01aba4714957d300LL)), ((u64)(0x828f4db456ff0c8eULL)), ((u64)(0x010b46c6cdd6e3e0LL)), ((u64)(0xa33321216cbecfb2ULL)), ((u64)(0x014e1878814c9cd8LL)), ((u64)(0xcbffe969c7ee839eULL)), ((u64)(0x01a19e96a19fc40eLL)), | ||
| 3303 | +((u64)(0x3f7ff1e21cf51243LL)), ((u64)(0x0105031e2503da89LL)), ((u64)(0x8f5fee5aa43256d4ULL)), ((u64)(0x014643e5ae44d12bLL)), ((u64)(0x7337e9f14d3eec89LL)), ((u64)(0x0197d4df19d60576LL)), ((u64)(0x1005e46da08ea7abLL)), ((u64)(0x01fdca16e04b86d4LL)), ((u64)(0x8a03aec4845928cbULL)), ((u64)(0x013e9e4e4c2f3444LL)), ((u64)(0xac849a75a56f72fdULL)), ((u64)(0x018e45e1df3b0155LL)), ((u64)(0x17a5c1130ecb4fbdLL)), ((u64)(0x01f1d75a5709c1abLL)), ((u64)(0xeec798abe93f11d6ULL)), ((u64)(0x013726987666190aLL)), | ||
| 3304 | +((u64)(0xaa797ed6e38ed64bULL)), ((u64)(0x0184f03e93ff9f4dLL)), ((u64)(0x1517de8c9c728bdeLL)), ((u64)(0x01e62c4e38ff8721LL)), ((u64)(0xad2eeb17e1c7976bULL)), ((u64)(0x012fdbb0e39fb474LL)), ((u64)(0xd87aa5ddda397d46ULL)), ((u64)(0x017bd29d1c87a191LL)), ((u64)(0x4e994f5550c7dc97LL)), ((u64)(0x01dac74463a989f6LL)), ((u64)(0xf11fd195527ce9deULL)), ((u64)(0x0128bc8abe49f639LL)), ((u64)(0x6d67c5faa71c2456LL)), ((u64)(0x0172ebad6ddc73c8LL)), ((u64)(0x88c1b77950e32d6cULL)), ((u64)(0x01cfa698c95390baLL)), | ||
| 3305 | +((u64)(0x957912abd28dfc63ULL)), ((u64)(0x0121c81f7dd43a74LL)), ((u64)(0xbad75756c7317b7cULL)), ((u64)(0x016a3a275d494911LL)), ((u64)(0x298d2d2c78fdda5bLL)), ((u64)(0x01c4c8b1349b9b56LL)), ((u64)(0xd9f83c3bcb9ea879ULL)), ((u64)(0x011afd6ec0e14115LL)), ((u64)(0x50764b4abe865297LL)), ((u64)(0x0161bcca7119915bLL)), ((u64)(0x2493de1d6e27e73dLL)), ((u64)(0x01ba2bfd0d5ff5b2LL)), ((u64)(0x56dc6ad264d8f086LL)), ((u64)(0x01145b7e285bf98fLL)), ((u64)(0x2c938586fe0f2ca8LL)), ((u64)(0x0159725db272f7f3LL)), | ||
| 3306 | +((u64)(0xf7b866e8bd92f7d2ULL)), ((u64)(0x01afcef51f0fb5efLL)), ((u64)(0xfad34051767bdae3ULL)), ((u64)(0x010de1593369d1b5LL)), ((u64)(0x79881065d41ad19cLL)), ((u64)(0x015159af80444623LL)), ((u64)(0x57ea147f49218603LL)), ((u64)(0x01a5b01b605557acLL)), ((u64)(0xb6f24ccf8db4f3c1ULL)), ((u64)(0x01078e111c3556cbLL)), ((u64)(0xa4aee003712230b2ULL)), ((u64)(0x014971956342ac7eLL)), ((u64)(0x4dda98044d6abcdfLL)), ((u64)(0x019bcdfabc13579eLL)), ((u64)(0xf0a89f02b062b60bULL)), ((u64)(0x010160bcb58c16c2LL)), | ||
| 3307 | +((u64)(0xacd2c6c35c7b638eULL)), ((u64)(0x0141b8ebe2ef1c73LL)), ((u64)(0x98077874339a3c71ULL)), ((u64)(0x01922726dbaae390LL)), ((u64)(0xbe0956914080cb8eULL)), ((u64)(0x01f6b0f092959c74LL)), ((u64)(0xf6c5d61ac8507f38ULL)), ((u64)(0x013a2e965b9d81c8LL)), ((u64)(0x34774ba17a649f07LL)), ((u64)(0x0188ba3bf284e23bLL)), ((u64)(0x01951e89d8fdc6c8LL)), ((u64)(0x01eae8caef261acaLL)), ((u64)(0x40fd3316279e9c3dLL)), ((u64)(0x0132d17ed577d0beLL)), ((u64)(0xd13c7fdbb186434cULL)), ((u64)(0x017f85de8ad5c4edLL)), | ||
| 3308 | +((u64)(0x458b9fd29de7d420LL)), ((u64)(0x01df67562d8b3629LL)), ((u64)(0xcb7743e3a2b0e494ULL)), ((u64)(0x012ba095dc7701d9LL)), ((u64)(0x3e5514dc8b5d1db9LL)), ((u64)(0x017688bb5394c250LL)), ((u64)(0x4dea5a13ae346527LL)), ((u64)(0x01d42aea2879f2e4LL)), ((u64)(0xb0b2784c4ce0bf38ULL)), ((u64)(0x01249ad2594c37ceLL)), ((u64)(0x5cdf165f6018ef06LL)), ((u64)(0x016dc186ef9f45c2LL)), ((u64)(0xf416dbf7381f2ac8ULL)), ((u64)(0x01c931e8ab871732LL)), ((u64)(0xd88e497a83137abdULL)), ((u64)(0x011dbf316b346e7fLL)), | ||
| 3309 | +((u64)(0xceb1dbd923d8596cULL)), ((u64)(0x01652efdc6018a1fLL)), ((u64)(0xc25e52cf6cce6fc7ULL)), ((u64)(0x01be7abd3781eca7LL)), ((u64)(0xd97af3c1a40105dcULL)), ((u64)(0x01170cb642b133e8LL)), ((u64)(0x0fd9b0b20d014754LL)), ((u64)(0x015ccfe3d35d80e3LL)), ((u64)(0xd3d01cde90419929ULL)), ((u64)(0x01b403dcc834e11bLL)), ((u64)(0x6462120b1a28ffb9LL)), ((u64)(0x01108269fd210cb1LL)), ((u64)(0xbd7a968de0b33fa8ULL)), ((u64)(0x0154a3047c694fddLL)), ((u64)(0x2cd93c3158e00f92LL)), ((u64)(0x01a9cbc59b83a3d5LL)), | ||
| 3310 | +((u64)(0x3c07c59ed78c09bbLL)), ((u64)(0x010a1f5b81324665LL)), ((u64)(0x8b09b7068d6f0c2aULL)), ((u64)(0x014ca732617ed7feLL)), ((u64)(0x2dcc24c830cacf34LL)), ((u64)(0x019fd0fef9de8dfeLL)), ((u64)(0xdc9f96fd1e7ec180ULL)), ((u64)(0x0103e29f5c2b18beLL)), ((u64)(0x93c77cbc661e71e1ULL)), ((u64)(0x0144db473335deeeLL)), ((u64)(0x38b95beb7fa60e59LL)), ((u64)(0x01961219000356aaLL)), ((u64)(0xc6e7b2e65f8f91efULL)), ((u64)(0x01fb969f40042c54LL)), ((u64)(0xfc50cfcffbb9bb35ULL)), ((u64)(0x013d3e2388029bb4LL)), | ||
| 3311 | +((u64)(0x3b6503c3faa82a03LL)), ((u64)(0x018c8dac6a0342a2LL)), ((u64)(0xca3e44b4f9523484ULL)), ((u64)(0x01efb1178484134aLL)), ((u64)(0xbe66eaf11bd360d2ULL)), ((u64)(0x0135ceaeb2d28c0eLL)), ((u64)(0x6e00a5ad62c83907LL)), ((u64)(0x0183425a5f872f12LL)), ((u64)(0x0980cf18bb7a4749LL)), ((u64)(0x01e412f0f768fad7LL)), ((u64)(0x65f0816f752c6c8dLL)), ((u64)(0x012e8bd69aa19cc6LL)), ((u64)(0xff6ca1cb527787b1ULL)), ((u64)(0x017a2ecc414a03f7LL)), ((u64)(0xff47ca3e2715699dULL)), ((u64)(0x01d8ba7f519c84f5LL)), | ||
| 3312 | +((u64)(0xbf8cde66d86d6202ULL)), ((u64)(0x0127748f9301d319LL)), ((u64)(0x2f7016008e88ba83LL)), ((u64)(0x017151b377c247e0LL)), ((u64)(0x3b4c1b80b22ae923LL)), ((u64)(0x01cda62055b2d9d8LL)), ((u64)(0x250f91306f5ad1b6LL)), ((u64)(0x012087d4358fc827LL)), ((u64)(0xee53757c8b318623ULL)), ((u64)(0x0168a9c942f3ba30LL)), ((u64)(0x29e852dbadfde7acLL)), ((u64)(0x01c2d43b93b0a8bdLL)), ((u64)(0x3a3133c94cbeb0ccLL)), ((u64)(0x0119c4a53c4e6976LL)), ((u64)(0xc8bd80bb9fee5cffULL)), ((u64)(0x016035ce8b6203d3LL)), | ||
| 3313 | +((u64)(0xbaece0ea87e9f43eULL)), ((u64)(0x01b843422e3a84c8LL)), ((u64)(0x74d40c9294f238a7LL)), ((u64)(0x01132a095ce492fdLL)), ((u64)(0xd2090fb73a2ec6d1ULL)), ((u64)(0x0157f48bb41db7bcLL)), ((u64)(0x068b53a508ba7885LL)), ((u64)(0x01adf1aea12525acLL)), ((u64)(0x8417144725748b53ULL)), ((u64)(0x010cb70d24b7378bLL)), ((u64)(0x651cd958eed1ae28LL)), ((u64)(0x014fe4d06de5056eLL)), ((u64)(0xfe640faf2a8619b2ULL)), ((u64)(0x01a3de04895e46c9LL)), ((u64)(0x3efe89cd7a93d00fLL)), ((u64)(0x01066ac2d5daec3eLL)), | ||
| 3314 | +((u64)(0xcebe2c40d938c413ULL)), ((u64)(0x014805738b51a74dLL)), ((u64)(0x426db7510f86f518LL)), ((u64)(0x019a06d06e261121LL)), ((u64)(0xc9849292a9b4592fULL)), ((u64)(0x0100444244d7cab4LL)), ((u64)(0xfbe5b73754216f7aULL)), ((u64)(0x01405552d60dbd61LL)), ((u64)(0x7adf25052929cb59LL)), ((u64)(0x01906aa78b912cbaLL)), ((u64)(0x1996ee4673743e2fLL)), ((u64)(0x01f485516e7577e9LL)), ((u64)(0xaffe54ec0828a6ddULL)), ((u64)(0x0138d352e5096af1LL)), ((u64)(0x1bfdea270a32d095LL)), ((u64)(0x018708279e4bc5aeLL)), | ||
| 3315 | +((u64)(0xa2fd64b0ccbf84baULL)), ((u64)(0x01e8ca3185deb719LL)), ((u64)(0x05de5eee7ff7b2f4LL)), ((u64)(0x01317e5ef3ab3270LL)), ((u64)(0x0755f6aa1ff59fb1LL)), ((u64)(0x017dddf6b095ff0cLL)), ((u64)(0x092b7454a7f3079eLL)), ((u64)(0x01dd55745cbb7ecfLL)), ((u64)(0x65bb28b4e8f7e4c3LL)), ((u64)(0x012a5568b9f52f41LL)), ((u64)(0xbf29f2e22335ddf3ULL)), ((u64)(0x0174eac2e8727b11LL)), ((u64)(0x2ef46f9aac035570LL)), ((u64)(0x01d22573a28f19d6LL)), ((u64)(0xdd58c5c0ab821566ULL)), ((u64)(0x0123576845997025LL)), | ||
| 3316 | +((u64)(0x54aef730d6629ac0LL)), ((u64)(0x016c2d4256ffcc2fLL)), ((u64)(0x29dab4fd0bfb4170LL)), ((u64)(0x01c73892ecbfbf3bLL)), ((u64)(0xfa28b11e277d08e6ULL)), ((u64)(0x011c835bd3f7d784LL)), ((u64)(0x38b2dd65b15c4b1fLL)), ((u64)(0x0163a432c8f5cd66LL)), ((u64)(0xc6df94bf1db35de7ULL)), ((u64)(0x01bc8d3f7b3340bfLL)), ((u64)(0xdc4bbcf772901ab0ULL)), ((u64)(0x0115d847ad000877LL)), ((u64)(0xd35eac354f34215cULL)), ((u64)(0x015b4e5998400a95LL)), ((u64)(0x48365742a30129b4LL)), ((u64)(0x01b221effe500d3bLL)), | ||
| 3317 | +((u64)(0x0d21f689a5e0ba10LL)), ((u64)(0x010f5535fef20845LL)), ((u64)(0x506a742c0f58e894LL)), ((u64)(0x01532a837eae8a56LL)), ((u64)(0xe4851137132f22b9ULL)), ((u64)(0x01a7f5245e5a2cebLL)), ((u64)(0x6ed32ac26bfd75b4LL)), ((u64)(0x0108f936baf85c13LL)), ((u64)(0x4a87f57306fcd321LL)), ((u64)(0x014b378469b67318LL)), ((u64)(0x5d29f2cfc8bc07e9LL)), ((u64)(0x019e056584240fdeLL)), ((u64)(0xfa3a37c1dd7584f1ULL)), ((u64)(0x0102c35f729689eaLL)), ((u64)(0xb8c8c5b254d2e62eULL)), ((u64)(0x014374374f3c2c65LL)), | ||
| 3318 | +((u64)(0x26faf71eea079fb9LL)), ((u64)(0x01945145230b377fLL)), ((u64)(0xf0b9b4e6a48987a8ULL)), ((u64)(0x01f965966bce055eLL)), ((u64)(0x5674111026d5f4c9LL)), ((u64)(0x013bdf7e0360c35bLL)), ((u64)(0x2c111554308b71fbLL)), ((u64)(0x018ad75d8438f432LL)), ((u64)(0xb7155aa93cae4e7aULL)), ((u64)(0x01ed8d34e547313eLL)), ((u64)(0x326d58a9c5ecf10cLL)), ((u64)(0x013478410f4c7ec7LL)), ((u64)(0xff08aed437682d4fULL)), ((u64)(0x01819651531f9e78LL)), ((u64)(0x3ecada89454238a3LL)), ((u64)(0x01e1fbe5a7e78617LL)), | ||
| 3319 | +((u64)(0x873ec895cb496366ULL)), ((u64)(0x012d3d6f88f0b3ceLL)), ((u64)(0x290e7abb3e1bbc3fLL)), ((u64)(0x01788ccb6b2ce0c2LL)), ((u64)(0xb352196a0da2ab4fULL)), ((u64)(0x01d6affe45f818f2LL)), ((u64)(0xb0134fe24885ab11ULL)), ((u64)(0x01262dfeebbb0f97LL)), ((u64)(0x9c1823dadaa715d6ULL)), ((u64)(0x016fb97ea6a9d37dLL)), ((u64)(0x031e2cd19150db4bLL)), ((u64)(0x01cba7de5054485dLL)), ((u64)(0x21f2dc02fad2890fLL)), ((u64)(0x011f48eaf234ad3aLL)), ((u64)(0xaa6f9303b9872b53ULL)), ((u64)(0x01671b25aec1d888LL)), | ||
| 3320 | +((u64)(0xd50b77c4a7e8f628ULL)), ((u64)(0x01c0e1ef1a724eaaLL)), ((u64)(0xc5272adae8f199d9ULL)), ((u64)(0x01188d357087712aLL)), ((u64)(0x7670f591a32e004fLL)), ((u64)(0x015eb082cca94d75LL)), ((u64)(0xd40d32f60bf98063ULL)), ((u64)(0x01b65ca37fd3a0d2LL)), ((u64)(0xc4883fd9c77bf03eULL)), ((u64)(0x0111f9e62fe44483LL)), ((u64)(0xb5aa4fd0395aec4dULL)), ((u64)(0x0156785fbbdd55a4LL)), ((u64)(0xe314e3c447b1a760ULL)), ((u64)(0x01ac1677aad4ab0dLL)), ((u64)(0xaded0e5aaccf089cULL)), ((u64)(0x010b8e0acac4eae8LL)), | ||
| 3321 | +((u64)(0xd96851f15802cac3ULL)), ((u64)(0x014e718d7d7625a2LL)), ((u64)(0x8fc2666dae037d74ULL)), ((u64)(0x01a20df0dcd3af0bLL)), ((u64)(0x39d980048cc22e68LL)), ((u64)(0x010548b68a044d67LL)), ((u64)(0x084fe005aff2ba03LL)), ((u64)(0x01469ae42c8560c1LL)), ((u64)(0x4a63d8071bef6883LL)), ((u64)(0x0198419d37a6b8f1LL)), ((u64)(0x9cfcce08e2eb42a4ULL)), ((u64)(0x01fe52048590672dLL)), ((u64)(0x821e00c58dd309a7ULL)), ((u64)(0x013ef342d37a407cLL)), ((u64)(0xa2a580f6f147cc10ULL)), ((u64)(0x018eb0138858d09bLL)), | ||
| 3322 | +((u64)(0x8b4ee134ad99bf15ULL)), ((u64)(0x01f25c186a6f04c2LL)), ((u64)(0x97114cc0ec80176dULL)), ((u64)(0x0137798f428562f9LL)), ((u64)(0xfcd59ff127a01d48ULL)), ((u64)(0x018557f31326bbb7LL)), ((u64)(0xfc0b07ed7188249aULL)), ((u64)(0x01e6adefd7f06aa5LL)), ((u64)(0xbd86e4f466f516e0ULL)), ((u64)(0x01302cb5e6f642a7LL)), ((u64)(0xace89e3180b25c98ULL)), ((u64)(0x017c37e360b3d351LL)), ((u64)(0x1822c5bde0def3beLL)), ((u64)(0x01db45dc38e0c826LL)), ((u64)(0xcf15bb96ac8b5857ULL)), ((u64)(0x01290ba9a38c7d17LL)), | ||
| 3323 | +((u64)(0xc2db2a7c57ae2e6dULL)), ((u64)(0x01734e940c6f9c5dLL)), ((u64)(0x3391f51b6d99ba08LL)), ((u64)(0x01d022390f8b8375LL)), ((u64)(0x403b393124801445LL)), ((u64)(0x01221563a9b73229LL)), ((u64)(0x904a077d6da01956ULL)), ((u64)(0x016a9abc9424feb3LL)), ((u64)(0x745c895cc9081facLL)), ((u64)(0x01c5416bb92e3e60LL)), ((u64)(0x48b9d5d9fda513cbLL)), ((u64)(0x011b48e353bce6fcLL)), ((u64)(0x5ae84b507d0e58beLL)), ((u64)(0x01621b1c28ac20bbLL)), ((u64)(0x31a25e249c51eeeeLL)), ((u64)(0x01baa1e332d728eaLL)), | ||
| 3324 | +((u64)(0x5f057ad6e1b33554LL)), ((u64)(0x0114a52dffc67992LL)), ((u64)(0xf6c6d98c9a2002aaULL)), ((u64)(0x0159ce797fb817f6LL)), ((u64)(0xb4788fefc0a80354ULL)), ((u64)(0x01b04217dfa61df4LL)), ((u64)(0xf0cb59f5d8690214ULL)), ((u64)(0x010e294eebc7d2b8LL)), ((u64)(0x2cfe30734e83429aLL)), ((u64)(0x0151b3a2a6b9c767LL)), ((u64)(0xf83dbc9022241340ULL)), ((u64)(0x01a6208b50683940LL)), ((u64)(0x9b2695da15568c08ULL)), ((u64)(0x0107d457124123c8LL)), ((u64)(0xc1f03b509aac2f0aULL)), ((u64)(0x0149c96cd6d16cbaLL)), | ||
| 3325 | +((u64)(0x726c4a24c1573acdLL)), ((u64)(0x019c3bc80c85c7e9LL)), ((u64)(0xe783ae56f8d684c0ULL)), ((u64)(0x0101a55d07d39cf1LL)), ((u64)(0x616499ecb70c25f0LL)), ((u64)(0x01420eb449c8842eLL)), ((u64)(0xf9bdc067e4cf2f6cULL)), ((u64)(0x019292615c3aa539LL)), ((u64)(0x782d3081de02fb47LL)), ((u64)(0x01f736f9b3494e88LL)), ((u64)(0x4b1c3e512ac1dd0cLL)), ((u64)(0x013a825c100dd115LL)), ((u64)(0x9de34de57572544fULL)), ((u64)(0x018922f31411455aLL)), ((u64)(0x455c215ed2cee963LL)), ((u64)(0x01eb6bafd91596b1LL)), | ||
| 3326 | +((u64)(0xcb5994db43c151deULL)), ((u64)(0x0133234de7ad7e2eLL)), ((u64)(0x7e2ffa1214b1a655LL)), ((u64)(0x017fec216198ddbaLL)), ((u64)(0x1dbbf89699de0febLL)), ((u64)(0x01dfe729b9ff1529LL)), ((u64)(0xb2957b5e202ac9f3ULL)), ((u64)(0x012bf07a143f6d39LL)), ((u64)(0x1f3ada35a8357c6fLL)), ((u64)(0x0176ec98994f4888LL)), ((u64)(0x270990c31242db8bLL)), ((u64)(0x01d4a7bebfa31aaaLL)), ((u64)(0x5865fa79eb69c937LL)), ((u64)(0x0124e8d737c5f0aaLL)), ((u64)(0xee7f791866443b85ULL)), ((u64)(0x016e230d05b76cd4LL)), | ||
| 3327 | +((u64)(0x2a1f575e7fd54a66LL)), ((u64)(0x01c9abd04725480aLL)), ((u64)(0x5a53969b0fe54e80LL)), ((u64)(0x011e0b622c774d06LL)), ((u64)(0xf0e87c41d3dea220ULL)), ((u64)(0x01658e3ab7952047LL)), ((u64)(0xed229b5248d64aa8ULL)), ((u64)(0x01bef1c9657a6859LL)), ((u64)(0x3435a1136d85eea9LL)), ((u64)(0x0117571ddf6c8138LL)), ((u64)(0x4143095848e76a53LL)), ((u64)(0x015d2ce55747a186LL)), ((u64)(0xd193cbae5b2144e8ULL)), ((u64)(0x01b4781ead1989e7LL)), ((u64)(0xe2fc5f4cf8f4cb11ULL)), ((u64)(0x0110cb132c2ff630LL)), | ||
| 3328 | +((u64)(0x1bbb77203731fdd5LL)), ((u64)(0x0154fdd7f73bf3bdLL)), ((u64)(0x62aa54e844fe7d4aLL)), ((u64)(0x01aa3d4df50af0acLL)), ((u64)(0xbdaa75112b1f0e4eULL)), ((u64)(0x010a6650b926d66bLL)), ((u64)(0xad15125575e6d1e2ULL)), ((u64)(0x014cffe4e7708c06LL)), ((u64)(0x585a56ead360865bLL)), ((u64)(0x01a03fde214caf08LL)), ((u64)(0x37387652c41c53f8LL)), ((u64)(0x010427ead4cfed65LL)), ((u64)(0x850693e7752368f7ULL)), ((u64)(0x014531e58a03e8beLL)), ((u64)(0x264838e1526c4334LL)), ((u64)(0x01967e5eec84e2eeLL)), | ||
| 3329 | +((u64)(0xafda4719a7075402ULL)), ((u64)(0x01fc1df6a7a61ba9LL)), ((u64)(0x0de86c7008649481LL)), ((u64)(0x013d92ba28c7d14aLL)), ((u64)(0x9162878c0a7db9a1ULL)), ((u64)(0x018cf768b2f9c59cLL)), ((u64)(0xb5bb296f0d1d280aULL)), ((u64)(0x01f03542dfb83703LL)), ((u64)(0x5194f9e568323906LL)), ((u64)(0x01362149cbd32262LL)), ((u64)(0xe5fa385ec23ec747ULL)), ((u64)(0x0183a99c3ec7eafaLL)), ((u64)(0x9f78c67672ce7919ULL)), ((u64)(0x01e494034e79e5b9LL)), ((u64)(0x03ab7c0a07c10bb0LL)), ((u64)(0x012edc82110c2f94LL)), | ||
| 3330 | +((u64)(0x04965b0c89b14e9cLL)), ((u64)(0x017a93a2954f3b79LL)), ((u64)(0x45bbf1cfac1da243LL)), ((u64)(0x01d9388b3aa30a57LL)), ((u64)(0x8b957721cb92856aULL)), ((u64)(0x0127c35704a5e676LL)), ((u64)(0x2e7ad4ea3e7726c4LL)), ((u64)(0x0171b42cc5cf6014LL)), ((u64)(0x3a198a24ce14f075LL)), ((u64)(0x01ce2137f7433819LL)), ((u64)(0xc44ff65700cd1649ULL)), ((u64)(0x0120d4c2fa8a030fLL)), ((u64)(0xb563f3ecc1005bdbULL)), ((u64)(0x016909f3b92c83d3LL)), ((u64)(0xa2bcf0e7f14072d2ULL)), ((u64)(0x01c34c70a777a4c8LL)), | ||
| 3331 | +((u64)(0x65b61690f6c847c3LL)), ((u64)(0x011a0fc668aac6fdLL)), ((u64)(0xbf239c35347a59b4ULL)), ((u64)(0x016093b802d578bcLL)), ((u64)(0xeeec83428198f021ULL)), ((u64)(0x01b8b8a6038ad6ebLL)), ((u64)(0x7553d20990ff9615LL)), ((u64)(0x01137367c236c653LL)), ((u64)(0x52a8c68bf53f7b9aLL)), ((u64)(0x01585041b2c477e8LL)), ((u64)(0x6752f82ef28f5a81LL)), ((u64)(0x01ae64521f7595e2LL)), ((u64)(0x8093db1d57999890ULL)), ((u64)(0x010cfeb353a97dadLL)), ((u64)(0xe0b8d1e4ad7ffeb4ULL)), ((u64)(0x01503e602893dd18LL)), | ||
| 3332 | +((u64)(0x18e7065dd8dffe62LL)), ((u64)(0x01a44df832b8d45fLL)), ((u64)(0x6f9063faa78bfefdLL)), ((u64)(0x0106b0bb1fb384bbLL)), ((u64)(0x4b747cf9516efebcLL)), ((u64)(0x01485ce9e7a065eaLL)), ((u64)(0xde519c37a5cabe6bULL)), ((u64)(0x019a742461887f64LL)), ((u64)(0x0af301a2c79eb703LL)), ((u64)(0x01008896bcf54f9fLL)), ((u64)(0xcdafc20b798664c4ULL)), ((u64)(0x0140aabc6c32a386LL)), ((u64)(0x811bb28e57e7fdf5ULL)), ((u64)(0x0190d56b873f4c68LL)), ((u64)(0xa1629f31ede1fd72ULL)), ((u64)(0x01f50ac6690f1f82LL)), | ||
| 3333 | +((u64)(0xa4dda37f34ad3e67ULL)), ((u64)(0x013926bc01a973b1LL)), ((u64)(0x0e150c5f01d88e01LL)), ((u64)(0x0187706b0213d09eLL)), ((u64)(0x919a4f76c24eb181ULL)), ((u64)(0x01e94c85c298c4c5LL)), ((u64)(0x7b0071aa39712ef1LL)), ((u64)(0x0131cfd3999f7afbLL)), ((u64)(0x59c08e14c7cd7aadLL)), ((u64)(0x017e43c8800759baLL)), ((u64)(0xf030b199f9c0d958ULL)), ((u64)(0x01ddd4baa0093028LL)), ((u64)(0x961e6f003c1887d7ULL)), ((u64)(0x012aa4f4a405be19LL)), ((u64)(0xfba60ac04b1ea9cdULL)), ((u64)(0x01754e31cd072d9fLL)), | ||
| 3334 | +((u64)(0xfa8f8d705de65440ULL)), ((u64)(0x01d2a1be4048f907LL)), ((u64)(0xfc99b8663aaff4a8ULL)), ((u64)(0x0123a516e82d9ba4LL)), ((u64)(0x3bc0267fc95bf1d2LL)), ((u64)(0x016c8e5ca239028eLL)), ((u64)(0xcab0301fbbb2ee47ULL)), ((u64)(0x01c7b1f3cac74331LL)), ((u64)(0x1eae1e13d54fd4ecLL)), ((u64)(0x011ccf385ebc89ffLL)), ((u64)(0xe659a598caa3ca27ULL)), ((u64)(0x01640306766bac7eLL)), ((u64)(0x9ff00efefd4cbcb1ULL)), ((u64)(0x01bd03c81406979eLL)), ((u64)(0x23f6095f5e4ff5efLL)), ((u64)(0x0116225d0c841ec3LL)), | ||
| 3335 | +((u64)(0xecf38bb735e3f36aULL)), ((u64)(0x015baaf44fa52673LL)), ((u64)(0xe8306ea5035cf045ULL)), ((u64)(0x01b295b1638e7010LL)), ((u64)(0x911e4527221a162bULL)), ((u64)(0x010f9d8ede39060aLL)), ((u64)(0x3565d670eaa09bb6LL)), ((u64)(0x015384f295c7478dLL)), ((u64)(0x82bf4c0d2548c2a3ULL)), ((u64)(0x01a8662f3b391970LL)), ((u64)(0x51b78f88374d79a6LL)), ((u64)(0x01093fdd8503afe6LL)), ((u64)(0xe625736a4520d810ULL)), ((u64)(0x014b8fd4e6449bdfLL)), ((u64)(0xdfaed044d6690e14ULL)), ((u64)(0x019e73ca1fd5c2d7LL)), ((u64)(0xebcd422b0601a8ccULL)), ((u64)(0x0103085e53e599c6LL)), ((u64)(0xa6c092b5c78212ffULL)), ((u64)(0x0143ca75e8df0038LL)), ((u64)(0xd070b763396297bfULL)), ((u64)(0x0194bd136316c046LL)), ((u64)(0x848ce53c07bb3dafULL)), ((u64)(0x01f9ec583bdc7058LL)), ((u64)(0x52d80f4584d5068dLL)), ((u64)(0x013c33b72569c637LL)), ((u64)(0x278e1316e60a4831LL)), ((u64)(0x018b40a4eec437c5LL))}; // fixed array const | ||
| 3336 | +static Array_fixed_u64_584 _const_strconv__pow5_inv_split_64_x = {((u64)(0x0000000000000001)), ((u64)(0x0400000000000000LL)), ((u64)(0x3333333333333334LL)), ((u64)(0x0333333333333333LL)), ((u64)(0x28f5c28f5c28f5c3LL)), ((u64)(0x028f5c28f5c28f5cLL)), ((u64)(0xed916872b020c49cULL)), ((u64)(0x020c49ba5e353f7cLL)), ((u64)(0xaf4f0d844d013a93ULL)), ((u64)(0x0346dc5d63886594LL)), ((u64)(0x8c3f3e0370cdc876ULL)), ((u64)(0x029f16b11c6d1e10LL)), ((u64)(0xd698fe69270b06c5ULL)), ((u64)(0x0218def416bdb1a6LL)), ((u64)(0xf0f4ca41d811a46eULL)), ((u64)(0x035afe535795e90aLL)), | ||
| 3337 | +((u64)(0xf3f70834acdae9f1ULL)), ((u64)(0x02af31dc4611873bLL)), ((u64)(0x5cc5a02a23e254c1LL)), ((u64)(0x0225c17d04dad296LL)), ((u64)(0xfad5cd10396a2135ULL)), ((u64)(0x036f9bfb3af7b756LL)), ((u64)(0xfbde3da69454e75eULL)), ((u64)(0x02bfaffc2f2c92abLL)), ((u64)(0x2fe4fe1edd10b918LL)), ((u64)(0x0232f33025bd4223LL)), ((u64)(0x4ca19697c81ac1bfLL)), ((u64)(0x0384b84d092ed038LL)), ((u64)(0x3d4e1213067bce33LL)), ((u64)(0x02d09370d4257360LL)), ((u64)(0x643e74dc052fd829LL)), ((u64)(0x024075f3dceac2b3LL)), | ||
| 3338 | +((u64)(0x6d30baf9a1e626a7LL)), ((u64)(0x039a5652fb113785LL)), ((u64)(0x2426fbfae7eb5220LL)), ((u64)(0x02e1dea8c8da92d1LL)), ((u64)(0x1cebfcc8b9890e80LL)), ((u64)(0x024e4bba3a487574LL)), ((u64)(0x94acc7a78f41b0ccULL)), ((u64)(0x03b07929f6da5586LL)), ((u64)(0xaa23d2ec729af3d7ULL)), ((u64)(0x02f394219248446bLL)), ((u64)(0xbb4fdbf05baf2979ULL)), ((u64)(0x025c768141d369efLL)), ((u64)(0xc54c931a2c4b758dULL)), ((u64)(0x03c7240202ebdcb2LL)), ((u64)(0x9dd6dc14f03c5e0bULL)), ((u64)(0x0305b66802564a28LL)), | ||
| 3339 | +((u64)(0x4b1249aa59c9e4d6LL)), ((u64)(0x026af8533511d4edLL)), ((u64)(0x44ea0f76f60fd489LL)), ((u64)(0x03de5a1ebb4fbb15LL)), ((u64)(0x6a54d92bf80caa07LL)), ((u64)(0x0318481895d96277LL)), ((u64)(0x21dd7a89933d54d2LL)), ((u64)(0x0279d346de4781f9LL)), ((u64)(0x362f2a75b8622150LL)), ((u64)(0x03f61ed7ca0c0328LL)), ((u64)(0xf825bb91604e810dULL)), ((u64)(0x032b4bdfd4d668ecLL)), ((u64)(0xc684960de6a5340bULL)), ((u64)(0x0289097fdd7853f0LL)), ((u64)(0xd203ab3e521dc33cULL)), ((u64)(0x02073accb12d0ff3LL)), | ||
| 3340 | +((u64)(0xe99f7863b696052cULL)), ((u64)(0x033ec47ab514e652LL)), ((u64)(0x87b2c6b62bab3757ULL)), ((u64)(0x02989d2ef743eb75LL)), ((u64)(0xd2f56bc4efbc2c45ULL)), ((u64)(0x0213b0f25f69892aLL)), ((u64)(0x1e55793b192d13a2LL)), ((u64)(0x0352b4b6ff0f41deLL)), ((u64)(0x4b77942f475742e8LL)), ((u64)(0x02a8909265a5ce4bLL)), ((u64)(0xd5f9435905df68baULL)), ((u64)(0x022073a8515171d5LL)), ((u64)(0x565b9ef4d6324129LL)), ((u64)(0x03671f73b54f1c89LL)), ((u64)(0xdeafb25d78283421ULL)), ((u64)(0x02b8e5f62aa5b06dLL)), | ||
| 3341 | +((u64)(0x188c8eb12cecf681LL)), ((u64)(0x022d84c4eeeaf38bLL)), ((u64)(0x8dadb11b7b14bd9bULL)), ((u64)(0x037c07a17e44b8deLL)), ((u64)(0x7157c0e2c8dd647cLL)), ((u64)(0x02c99fb46503c718LL)), ((u64)(0x8ddfcd823a4ab6caULL)), ((u64)(0x023ae629ea696c13LL)), ((u64)(0x1632e269f6ddf142LL)), ((u64)(0x0391704310a8acecLL)), ((u64)(0x44f581ee5f17f435LL)), ((u64)(0x02dac035a6ed5723LL)), ((u64)(0x372ace584c1329c4LL)), ((u64)(0x024899c4858aac1cLL)), ((u64)(0xbeaae3c079b842d3ULL)), ((u64)(0x03a75c6da27779c6LL)), | ||
| 3342 | +((u64)(0x6555830061603576LL)), ((u64)(0x02ec49f14ec5fb05LL)), ((u64)(0xb7779c004de6912bULL)), ((u64)(0x0256a18dd89e626aLL)), ((u64)(0xf258f99a163db512ULL)), ((u64)(0x03bdcf495a9703ddLL)), ((u64)(0x5b7a614811caf741LL)), ((u64)(0x02fe3f6de212697eLL)), ((u64)(0xaf951aa00e3bf901ULL)), ((u64)(0x0264ff8b1b41edfeLL)), ((u64)(0x7f54f7667d2cc19bLL)), ((u64)(0x03d4cc11c5364997LL)), ((u64)(0x32aa5f8530f09ae3LL)), ((u64)(0x0310a3416a91d479LL)), ((u64)(0xf55519375a5a1582ULL)), ((u64)(0x0273b5cdeedb1060LL)), | ||
| 3343 | +((u64)(0xbbbb5b8bc3c3559dULL)), ((u64)(0x03ec56164af81a34LL)), ((u64)(0x2fc916096969114aLL)), ((u64)(0x03237811d593482aLL)), ((u64)(0x596dab3ababa743cLL)), ((u64)(0x0282c674aadc39bbLL)), ((u64)(0x478aef622efb9030LL)), ((u64)(0x0202385d557cfafcLL)), ((u64)(0xd8de4bd04b2c19e6ULL)), ((u64)(0x0336c0955594c4c6LL)), ((u64)(0xad7ea30d08f014b8ULL)), ((u64)(0x029233aaaadd6a38LL)), ((u64)(0x24654f3da0c01093LL)), ((u64)(0x020e8fbbbbe454faLL)), ((u64)(0x3a3bb1fc346680ebLL)), ((u64)(0x034a7f92c63a2190LL)), | ||
| 3344 | +((u64)(0x94fc8e635d1ecd89ULL)), ((u64)(0x02a1ffa89e94e7a6LL)), ((u64)(0xaa63a51c4a7f0ad4ULL)), ((u64)(0x021b32ed4baa52ebLL)), ((u64)(0xdd6c3b607731aaedULL)), ((u64)(0x035eb7e212aa1e45LL)), ((u64)(0x1789c919f8f488bdLL)), ((u64)(0x02b22cb4dbbb4b6bLL)), ((u64)(0xac6e3a7b2d906d64ULL)), ((u64)(0x022823c3e2fc3c55LL)), ((u64)(0x13e390c515b3e23aLL)), ((u64)(0x03736c6c9e606089LL)), ((u64)(0xdcb60d6a77c31b62ULL)), ((u64)(0x02c2bd23b1e6b3a0LL)), ((u64)(0x7d5e7121f968e2b5LL)), ((u64)(0x0235641c8e52294dLL)), | ||
| 3345 | +((u64)(0xc8971b698f0e3787ULL)), ((u64)(0x0388a02db0837548LL)), ((u64)(0xa078e2bad8d82c6cULL)), ((u64)(0x02d3b357c0692aa0LL)), ((u64)(0xe6c71bc8ad79bd24ULL)), ((u64)(0x0242f5dfcd20eee6LL)), ((u64)(0x0ad82c7448c2c839LL)), ((u64)(0x039e5632e1ce4b0bLL)), ((u64)(0x3be023903a356cfaLL)), ((u64)(0x02e511c24e3ea26fLL)), ((u64)(0x2fe682d9c82abd95LL)), ((u64)(0x0250db01d8321b8cLL)), ((u64)(0x4ca4048fa6aac8eeLL)), ((u64)(0x03b4919c8d1cf8e0LL)), ((u64)(0x3d5003a61eef0725LL)), ((u64)(0x02f6dae3a4172d80LL)), | ||
| 3346 | +((u64)(0x9773361e7f259f51ULL)), ((u64)(0x025f1582e9ac2466LL)), ((u64)(0x8beb89ca6508fee8ULL)), ((u64)(0x03cb559e42ad070aLL)), ((u64)(0x6fefa16eb73a6586LL)), ((u64)(0x0309114b688a6c08LL)), ((u64)(0xf3261abef8fb846bULL)), ((u64)(0x026da76f86d52339LL)), ((u64)(0x51d691318e5f3a45LL)), ((u64)(0x03e2a57f3e21d1f6LL)), ((u64)(0x0e4540f471e5c837LL)), ((u64)(0x031bb798fe8174c5LL)), ((u64)(0xd8376729f4b7d360ULL)), ((u64)(0x027c92e0cb9ac3d0LL)), ((u64)(0xf38bd84321261effULL)), ((u64)(0x03fa849adf5e061aLL)), | ||
| 3347 | +((u64)(0x293cad0280eb4bffLL)), ((u64)(0x032ed07be5e4d1afLL)), ((u64)(0xedca240200bc3cccULL)), ((u64)(0x028bd9fcb7ea4158LL)), ((u64)(0xbe3b50019a3030a4ULL)), ((u64)(0x02097b309321cde0LL)), ((u64)(0xc9f88002904d1a9fULL)), ((u64)(0x03425eb41e9c7c9aLL)), ((u64)(0x3b2d3335403daee6LL)), ((u64)(0x029b7ef67ee396e2LL)), ((u64)(0x95bdc291003158b8ULL)), ((u64)(0x0215ff2b98b6124eLL)), ((u64)(0x892f9db4cd1bc126ULL)), ((u64)(0x035665128df01d4aLL)), ((u64)(0x07594af70a7c9a85LL)), ((u64)(0x02ab840ed7f34aa2LL)), | ||
| 3348 | +((u64)(0x6c476f2c0863aed1LL)), ((u64)(0x0222d00bdff5d54eLL)), ((u64)(0x13a57eacda3917b4LL)), ((u64)(0x036ae67966562217LL)), ((u64)(0x0fb7988a482dac90LL)), ((u64)(0x02bbeb9451de81acLL)), ((u64)(0xd95fad3b6cf156daULL)), ((u64)(0x022fefa9db1867bcLL)), ((u64)(0xf565e1f8ae4ef15cULL)), ((u64)(0x037fe5dc91c0a5faLL)), ((u64)(0x911e4e608b725ab0ULL)), ((u64)(0x02ccb7e3a7cd5195LL)), ((u64)(0xda7ea51a0928488dULL)), ((u64)(0x023d5fe9530aa7aaLL)), ((u64)(0xf7310829a8407415ULL)), ((u64)(0x039566421e7772aaLL)), | ||
| 3349 | +((u64)(0x2c2739baed005cdeLL)), ((u64)(0x02ddeb68185f8eefLL)), ((u64)(0xbcec2e2f24004a4bULL)), ((u64)(0x024b22b9ad193f25LL)), ((u64)(0x94ad16b1d333aa11ULL)), ((u64)(0x03ab6ac2ae8ecb6fLL)), ((u64)(0xaa241227dc2954dbULL)), ((u64)(0x02ef889bbed8a2bfLL)), ((u64)(0x54e9a81fe35443e2LL)), ((u64)(0x02593a163246e899LL)), ((u64)(0x2175d9cc9eed396aLL)), ((u64)(0x03c1f689ea0b0dc2LL)), ((u64)(0xe7917b0a18bdc788ULL)), ((u64)(0x03019207ee6f3e34LL)), ((u64)(0xb9412f3b46fe393aULL)), ((u64)(0x0267a8065858fe90LL)), | ||
| 3350 | +((u64)(0xf535185ed7fd285cULL)), ((u64)(0x03d90cd6f3c1974dLL)), ((u64)(0xc42a79e57997537dULL)), ((u64)(0x03140a458fce12a4LL)), ((u64)(0x03552e512e12a931LL)), ((u64)(0x02766e9e0ca4dbb7LL)), ((u64)(0x9eeeb081e3510eb4ULL)), ((u64)(0x03f0b0fce107c5f1LL)), ((u64)(0x4bf226ce4f740bc3LL)), ((u64)(0x0326f3fd80d304c1LL)), ((u64)(0xa3281f0b72c33c9cULL)), ((u64)(0x02858ffe00a8d09aLL)), ((u64)(0x1c2018d5f568fd4aLL)), ((u64)(0x020473319a20a6e2LL)), ((u64)(0xf9ccf48988a7fba9ULL)), ((u64)(0x033a51e8f69aa49cLL)), | ||
| 3351 | +((u64)(0xfb0a5d3ad3b99621ULL)), ((u64)(0x02950e53f87bb6e3LL)), ((u64)(0x2f3b7dc8a96144e7LL)), ((u64)(0x0210d8432d2fc583LL)), ((u64)(0xe52bfc7442353b0cULL)), ((u64)(0x034e26d1e1e608d1LL)), ((u64)(0xb756639034f76270ULL)), ((u64)(0x02a4ebdb1b1e6d74LL)), ((u64)(0x2c451c735d92b526LL)), ((u64)(0x021d897c15b1f12aLL)), ((u64)(0x13a1c71efc1deea3LL)), ((u64)(0x0362759355e981ddLL)), ((u64)(0x761b05b2634b2550LL)), ((u64)(0x02b52adc44bace4aLL)), ((u64)(0x91af37c1e908eaa6ULL)), ((u64)(0x022a88b036fbd83bLL)), | ||
| 3352 | +((u64)(0x82b1f2cfdb417770ULL)), ((u64)(0x03774119f192f392LL)), ((u64)(0xcef4c23fe29ac5f3ULL)), ((u64)(0x02c5cdae5adbf60eLL)), ((u64)(0x3f2a34ffe87bd190LL)), ((u64)(0x0237d7beaf165e72LL)), ((u64)(0x984387ffda5fb5b2ULL)), ((u64)(0x038c8c644b56fd83LL)), ((u64)(0xe0360666484c915bULL)), ((u64)(0x02d6d6b6a2abfe02LL)), ((u64)(0x802b3851d3707449ULL)), ((u64)(0x024578921bbccb35LL)), ((u64)(0x99dec082ebe72075ULL)), ((u64)(0x03a25a835f947855LL)), ((u64)(0xae4bcd358985b391ULL)), ((u64)(0x02e8486919439377LL)), | ||
| 3353 | +((u64)(0xbea30a913ad15c74ULL)), ((u64)(0x02536d20e102dc5fLL)), ((u64)(0xfdd1aa81f7b560b9ULL)), ((u64)(0x03b8ae9b019e2d65LL)), ((u64)(0x97daeece5fc44d61ULL)), ((u64)(0x02fa2548ce182451LL)), ((u64)(0xdfe258a51969d781ULL)), ((u64)(0x0261b76d71ace9daLL)), ((u64)(0x996a276e8f0fbf34ULL)), ((u64)(0x03cf8be24f7b0fc4LL)), ((u64)(0xe121b9253f3fcc2aULL)), ((u64)(0x030c6fe83f95a636LL)), ((u64)(0xb41afa8432997022ULL)), ((u64)(0x02705986994484f8LL)), ((u64)(0xecf7f739ea8f19cfULL)), ((u64)(0x03e6f5a4286da18dLL)), | ||
| 3354 | +((u64)(0x23f99294bba5ae40LL)), ((u64)(0x031f2ae9b9f14e0bLL)), ((u64)(0x4ffadbaa2fb7be99LL)), ((u64)(0x027f5587c7f43e6fLL)), ((u64)(0x7ff7c5dd1925fdc2LL)), ((u64)(0x03feef3fa6539718LL)), ((u64)(0xccc637e4141e649bULL)), ((u64)(0x033258ffb842df46LL)), ((u64)(0xd704f983434b83afULL)), ((u64)(0x028ead9960357f6bLL)), ((u64)(0x126a6135cf6f9c8cLL)), ((u64)(0x020bbe144cf79923LL)), ((u64)(0x83dd685618b29414ULL)), ((u64)(0x0345fced47f28e9eLL)), ((u64)(0x9cb12044e08edcddULL)), ((u64)(0x029e63f1065ba54bLL)), | ||
| 3355 | +((u64)(0x16f419d0b3a57d7dLL)), ((u64)(0x02184ff405161dd6LL)), ((u64)(0x8b20294dec3bfbfbULL)), ((u64)(0x035a19866e89c956LL)), ((u64)(0x3c19baa4bcfcc996LL)), ((u64)(0x02ae7ad1f207d445LL)), ((u64)(0xc9ae2eea30ca3adfULL)), ((u64)(0x02252f0e5b39769dLL)), ((u64)(0x0f7d17dd1add2afdLL)), ((u64)(0x036eb1b091f58a96LL)), ((u64)(0x3f97464a7be42264LL)), ((u64)(0x02bef48d41913babLL)), ((u64)(0xcc790508631ce850ULL)), ((u64)(0x02325d3dce0dc955LL)), ((u64)(0xe0c1a1a704fb0d4dULL)), ((u64)(0x0383c862e3494222LL)), | ||
| 3356 | +((u64)(0x4d67b4859d95a43eLL)), ((u64)(0x02cfd3824f6dce82LL)), ((u64)(0x711fc39e17aae9cbLL)), ((u64)(0x023fdc683f8b0b9bLL)), ((u64)(0xe832d2968c44a945ULL)), ((u64)(0x039960a6cc11ac2bLL)), ((u64)(0xecf575453d03ba9eULL)), ((u64)(0x02e11a1f09a7bcefLL)), ((u64)(0x572ac4376402fbb1LL)), ((u64)(0x024dae7f3aec9726LL)), ((u64)(0x58446d256cd192b5LL)), ((u64)(0x03af7d985e47583dLL)), ((u64)(0x79d0575123dadbc4LL)), ((u64)(0x02f2cae04b6c4697LL)), ((u64)(0x94a6ac40e97be303ULL)), ((u64)(0x025bd5803c569edfLL)), | ||
| 3357 | +((u64)(0x8771139b0f2c9e6cULL)), ((u64)(0x03c62266c6f0fe32LL)), ((u64)(0x9f8da948d8f07ebdULL)), ((u64)(0x0304e85238c0cb5bLL)), ((u64)(0xe60aedd3e0c06564ULL)), ((u64)(0x026a5374fa33d5e2LL)), ((u64)(0xa344afb9679a3bd2ULL)), ((u64)(0x03dd5254c3862304LL)), ((u64)(0xe903bfc78614fca8ULL)), ((u64)(0x031775109c6b4f36LL)), ((u64)(0xba6966393810ca20ULL)), ((u64)(0x02792a73b055d8f8LL)), ((u64)(0x2a423d2859b4769aLL)), ((u64)(0x03f510b91a22f4c1LL)), ((u64)(0xee9b642047c39215ULL)), ((u64)(0x032a73c7481bf700LL)), | ||
| 3358 | +((u64)(0xbee2b680396941aaULL)), ((u64)(0x02885c9f6ce32c00LL)), ((u64)(0xff1bc53361210155ULL)), ((u64)(0x0206b07f8a4f5666LL)), ((u64)(0x31c6085235019bbbLL)), ((u64)(0x033de73276e5570bLL)), ((u64)(0x27d1a041c4014963LL)), ((u64)(0x0297ec285f1ddf3cLL)), ((u64)(0xeca7b367d0010782ULL)), ((u64)(0x021323537f4b18fcLL)), ((u64)(0xadd91f0c8001a59dULL)), ((u64)(0x0351d21f3211c194LL)), ((u64)(0xf17a7f3d3334847eULL)), ((u64)(0x02a7db4c280e3476LL)), ((u64)(0x279532975c2a0398LL)), ((u64)(0x021fe2a3533e905fLL)), | ||
| 3359 | +((u64)(0xd8eeb75893766c26ULL)), ((u64)(0x0366376bb8641a31LL)), ((u64)(0x7a5892ad42c52352LL)), ((u64)(0x02b82c562d1ce1c1LL)), ((u64)(0xfb7a0ef102374f75ULL)), ((u64)(0x022cf044f0e3e7cdLL)), ((u64)(0xc59017e8038bb254ULL)), ((u64)(0x037b1a07e7d30c7cLL)), ((u64)(0x37a67986693c8eaaLL)), ((u64)(0x02c8e19feca8d6caLL)), ((u64)(0xf951fad1edca0bbbULL)), ((u64)(0x023a4e198a20abd4LL)), ((u64)(0x28832ae97c76792bLL)), ((u64)(0x03907cf5a9cddfbbLL)), ((u64)(0x2068ef21305ec756LL)), ((u64)(0x02d9fd9154a4b2fcLL)), | ||
| 3360 | +((u64)(0x19ed8c1a8d189f78LL)), ((u64)(0x0247fe0ddd508f30LL)), ((u64)(0x5caf4690e1c0ff26LL)), ((u64)(0x03a66349621a7eb3LL)), ((u64)(0x4a25d20d81673285LL)), ((u64)(0x02eb82a11b48655cLL)), ((u64)(0x3b5174d79ab8f537LL)), ((u64)(0x0256021a7c39eab0LL)), ((u64)(0x921bee25c45b21f1ULL)), ((u64)(0x03bcd02a605caab3LL)), ((u64)(0xdb498b5169e2818eULL)), ((u64)(0x02fd735519e3bbc2LL)), ((u64)(0x15d46f7454b53472LL)), ((u64)(0x02645c4414b62fcfLL)), ((u64)(0xefba4bed545520b6ULL)), ((u64)(0x03d3c6d35456b2e4LL)), | ||
| 3361 | +((u64)(0xf2fb6ff110441a2bULL)), ((u64)(0x030fd242a9def583LL)), ((u64)(0x8f2f8cc0d9d014efULL)), ((u64)(0x02730e9bbb18c469LL)), ((u64)(0xb1e5ae015c80217fULL)), ((u64)(0x03eb4a92c4f46d75LL)), ((u64)(0xc1848b344a001accULL)), ((u64)(0x0322a20f03f6bdf7LL)), ((u64)(0xce03a2903b3348a3ULL)), ((u64)(0x02821b3f365efe5fLL)), ((u64)(0xd802e873628f6d4fULL)), ((u64)(0x0201af65c518cb7fLL)), ((u64)(0x599e40b89db2487fLL)), ((u64)(0x0335e56fa1c14599LL)), ((u64)(0xe14b66fa17c1d399ULL)), ((u64)(0x029184594e3437adLL)), | ||
| 3362 | +((u64)(0x81091f2e7967dc7aULL)), ((u64)(0x020e037aa4f692f1LL)), ((u64)(0x9b41cb7d8f0c93f6ULL)), ((u64)(0x03499f2aa18a84b5LL)), ((u64)(0xaf67d5fe0c0a0ff8ULL)), ((u64)(0x02a14c221ad536f7LL)), ((u64)(0xf2b977fe70080cc7ULL)), ((u64)(0x021aa34e7bddc592LL)), ((u64)(0x1df58cca4cd9ae0bLL)), ((u64)(0x035dd2172c9608ebLL)), ((u64)(0xe4c470a1d7148b3cULL)), ((u64)(0x02b174df56de6d88LL)), ((u64)(0x83d05a1b1276d5caULL)), ((u64)(0x022790b2abe5246dLL)), ((u64)(0x9fb3c35e83f1560fULL)), ((u64)(0x0372811ddfd50715LL)), | ||
| 3363 | +((u64)(0xb2f635e5365aab3fULL)), ((u64)(0x02c200e4b310d277LL)), ((u64)(0xf591c4b75eaeef66ULL)), ((u64)(0x0234cd83c273db92LL)), ((u64)(0xef4fa125644b18a3ULL)), ((u64)(0x0387af39371fc5b7LL)), ((u64)(0x8c3fb41de9d5ad4fULL)), ((u64)(0x02d2f2942c196af9LL)), ((u64)(0x3cffc34b2177bdd9LL)), ((u64)(0x02425ba9bce12261LL)), ((u64)(0x94cc6bab68bf9628ULL)), ((u64)(0x039d5f75fb01d09bLL)), ((u64)(0x10a38955ed6611b9LL)), ((u64)(0x02e44c5e6267da16LL)), ((u64)(0xda1c6dde5784dafbULL)), ((u64)(0x02503d184eb97b44LL)), | ||
| 3364 | +((u64)(0xf693e2fd58d49191ULL)), ((u64)(0x03b394f3b128c53aLL)), ((u64)(0xc5431bfde0aa0e0eULL)), ((u64)(0x02f610c2f4209dc8LL)), ((u64)(0x6a9c1664b3bb3e72LL)), ((u64)(0x025e73cf29b3b16dLL)), ((u64)(0x10f9bd6dec5eca4fLL)), ((u64)(0x03ca52e50f85e8afLL)), ((u64)(0xda616457f04bd50cULL)), ((u64)(0x03084250d937ed58LL)), ((u64)(0xe1e783798d09773dULL)), ((u64)(0x026d01da475ff113LL)), ((u64)(0x030c058f480f252eLL)), ((u64)(0x03e19c9072331b53LL)), ((u64)(0x68d66ad906728425LL)), ((u64)(0x031ae3a6c1c27c42LL)), | ||
| 3365 | +((u64)(0x8711ef14052869b7ULL)), ((u64)(0x027be952349b969bLL)), ((u64)(0x0b4fe4ecd50d75f2LL)), ((u64)(0x03f97550542c242cLL)), ((u64)(0xa2a650bd773df7f5ULL)), ((u64)(0x032df7737689b689LL)), ((u64)(0xb551da312c31932aULL)), ((u64)(0x028b2c5c5ed49207LL)), ((u64)(0x5ddb14f4235adc22LL)), ((u64)(0x0208f049e576db39LL)), ((u64)(0x2fc4ee536bc49369LL)), ((u64)(0x034180763bf15ec2LL)), ((u64)(0xbfd0bea92303a921ULL)), ((u64)(0x029acd2b63277f01LL)), ((u64)(0x9973cbba8269541aULL)), ((u64)(0x021570ef8285ff34LL)), | ||
| 3366 | +((u64)(0x5bec792a6a42202aLL)), ((u64)(0x0355817f373ccb87LL)), ((u64)(0xe3239421ee9b4cefULL)), ((u64)(0x02aacdff5f63d605LL)), ((u64)(0xb5b6101b25490a59ULL)), ((u64)(0x02223e65e5e97804LL)), ((u64)(0x22bce691d541aa27LL)), ((u64)(0x0369fd6fd64259a1LL)), ((u64)(0xb563eba7ddce21b9ULL)), ((u64)(0x02bb31264501e14dLL)), ((u64)(0xf78322ecb171b494ULL)), ((u64)(0x022f5a850401810aLL)), ((u64)(0x259e9e47824f8753LL)), ((u64)(0x037ef73b399c01abLL)), ((u64)(0x1e187e9f9b72d2a9LL)), ((u64)(0x02cbf8fc2e1667bcLL)), | ||
| 3367 | +((u64)(0x4b46cbb2e2c24221LL)), ((u64)(0x023cc73024deb963LL)), ((u64)(0x120adf849e039d01LL)), ((u64)(0x039471e6a1645bd2LL)), ((u64)(0xdb3be603b19c7d9aULL)), ((u64)(0x02dd27ebb4504974LL)), ((u64)(0x7c2feb3627b0647cLL)), ((u64)(0x024a865629d9d45dLL)), ((u64)(0x2d197856a5e7072cLL)), ((u64)(0x03aa7089dc8fba2fLL)), ((u64)(0x8a7ac6abb7ec05bdULL)), ((u64)(0x02eec06e4a0c94f2LL)), ((u64)(0xd52f05562cbcd164ULL)), ((u64)(0x025899f1d4d6dd8eLL)), ((u64)(0x21e4d556adfae8a0LL)), ((u64)(0x03c0f64fbaf1627eLL)), | ||
| 3368 | +((u64)(0xe7ea444557fbed4dULL)), ((u64)(0x0300c50c958de864LL)), ((u64)(0xecbb69d1132ff10aULL)), ((u64)(0x0267040a113e5383LL)), ((u64)(0xadf8a94e851981aaULL)), ((u64)(0x03d8067681fd526cLL)), ((u64)(0x8b2d543ed0e13488ULL)), ((u64)(0x0313385ece6441f0LL)), ((u64)(0xd5bddcff0d80f6d3ULL)), ((u64)(0x0275c6b23eb69b26LL)), ((u64)(0x892fc7fe7c018aebULL)), ((u64)(0x03efa45064575ea4LL)), ((u64)(0x3a8c9ffec99ad589LL)), ((u64)(0x03261d0d1d12b21dLL)), ((u64)(0xc8707fff07af113bULL)), ((u64)(0x0284e40a7da88e7dLL)), | ||
| 3369 | +((u64)(0x39f39998d2f2742fLL)), ((u64)(0x0203e9a1fe2071feLL)), ((u64)(0x8fec28f484b7204bULL)), ((u64)(0x033975cffd00b663LL)), ((u64)(0xd989ba5d36f8e6a2ULL)), ((u64)(0x02945e3ffd9a2b82LL)), ((u64)(0x47a161e42bfa521cLL)), ((u64)(0x02104b66647b5602LL)), ((u64)(0x0c35696d132a1cf9LL)), ((u64)(0x034d4570a0c5566aLL)), ((u64)(0x09c454574288172dLL)), ((u64)(0x02a4378d4d6aab88LL)), ((u64)(0xa169dd129ba0128bULL)), ((u64)(0x021cf93dd7888939LL)), ((u64)(0x0242fb50f9001dabLL)), ((u64)(0x03618ec958da7529LL)), | ||
| 3370 | +((u64)(0x9b68c90d940017bcULL)), ((u64)(0x02b4723aad7b90edLL)), ((u64)(0x4920a0d7a999ac96LL)), ((u64)(0x0229f4fbbdfc73f1LL)), ((u64)(0x750101590f5c4757LL)), ((u64)(0x037654c5fcc71fe8LL)), ((u64)(0x2a6734473f7d05dfLL)), ((u64)(0x02c5109e63d27fedLL)), ((u64)(0xeeb8f69f65fd9e4cULL)), ((u64)(0x0237407eb641fff0LL)), ((u64)(0xe45b24323cc8fd46ULL)), ((u64)(0x038b9a6456cfffe7LL)), ((u64)(0xb6af502830a0ca9fULL)), ((u64)(0x02d6151d123fffecLL)), ((u64)(0xf88c402026e7087fULL)), ((u64)(0x0244ddb0db666656LL)), | ||
| 3371 | +((u64)(0x2746cd003e3e73feLL)), ((u64)(0x03a162b4923d708bLL)), ((u64)(0x1f6bd73364fec332LL)), ((u64)(0x02e7822a0e978d3cLL)), ((u64)(0xe5efdf5c50cbcf5bULL)), ((u64)(0x0252ce880bac70fcLL)), ((u64)(0x3cb2fefa1adfb22bLL)), ((u64)(0x03b7b0d9ac471b2eLL)), ((u64)(0x308f3261af195b56LL)), ((u64)(0x02f95a47bd05af58LL)), ((u64)(0x5a0c284e25ade2abLL)), ((u64)(0x0261150630d15913LL)), ((u64)(0x29ad0d49d5e30445LL)), ((u64)(0x03ce8809e7b55b52LL)), ((u64)(0x548a7107de4f369dLL)), ((u64)(0x030ba007ec9115dbLL)), ((u64)(0xdd3b8d9fe50c2bb1ULL)), ((u64)(0x026fb3398a0dab15LL)), ((u64)(0x952c15cca1ad12b5ULL)), ((u64)(0x03e5eb8f434911bcLL)), ((u64)(0x775677d6e7bda891LL)), ((u64)(0x031e560c35d40e30LL)), ((u64)(0xc5dec645863153a7ULL)), ((u64)(0x027eab3cf7dcd826LL))}; // fixed array const | ||
| 3372 | +bool v_memory_panic = false; // global 6 | ||
| 3373 | + | ||
| 3374 | +int_literal g_autostr_type_stack_len = 0; // global 6 | ||
| 3375 | + | ||
| 3376 | +int_literal g_autostr_addr_stack_len = 0; // global 6 | ||
| 3377 | + | ||
| 3378 | +int g_main_argc = ((int)(0)); // global 6 | ||
| 3379 | + | ||
| 3380 | +voidptr g_main_argv = ((void*)0); // global 6 | ||
| 3381 | + | ||
| 3382 | +voidptr g_live_reload_info; // global 6 | ||
| 3383 | + | ||
| 3384 | +/* skip C global: stdout */ | ||
| 3385 | + | ||
| 3386 | +/* skip C global: stderr */ | ||
| 3387 | + | ||
| 3388 | +/* skip C global: _wyp */ | ||
| 3389 | + | ||
| 3390 | +static IError _const_error_sentinel; // inited later | ||
| 3391 | +static IError _const_none__; // inited later | ||
| 3392 | +static const i8 _const_min_i8 = -128; // precomputed2 | ||
| 3393 | +static const i8 _const_max_i8 = 127; // precomputed2 | ||
| 3394 | +static const i16 _const_min_i16 = -32768; // precomputed2 | ||
| 3395 | +static const i16 _const_max_i16 = 32767; // precomputed2 | ||
| 3396 | +static const i32 _const_min_i32 = -2147483648; // precomputed2 | ||
| 3397 | +static const i32 _const_max_i32 = 2147483647; // precomputed2 | ||
| 3398 | +static i64 _const_min_i64; // inited later | ||
| 3399 | +static i64 _const_max_i64; // inited later | ||
| 3400 | +static const u8 _const_min_u8 = 0; // precomputed2 | ||
| 3401 | +static const u8 _const_max_u8 = 255; // precomputed2 | ||
| 3402 | +static const u16 _const_min_u16 = 0; // precomputed2 | ||
| 3403 | +static const u16 _const_max_u16 = 65535; // precomputed2 | ||
| 3404 | +static const u32 _const_min_u32 = 0; // precomputed2 | ||
| 3405 | +static const u32 _const_max_u32 = 4294967295; // precomputed2 | ||
| 3406 | +static const u64 _const_min_u64 = 0U; // precomputed2 | ||
| 3407 | +static const u64 _const_max_u64 = 18446744073709551615U; // precomputed2 | ||
| 3408 | +static const u32 _const_hash_mask = 16777215; // precomputed2 | ||
| 3409 | +static const u32 _const_probe_inc = 16777216; // precomputed2 | ||
| 3410 | +static Array_fixed_i32_1264 _const_rune_maps = {((i32)(0xB5)), 0xB5, 743, 0, 0xC0, 0xD6, 0, 32, 0xD8, 0xDE, 0, 32, 0xE0, 0xF6, -32, 0, | ||
| 3411 | +0xF8, 0xFE, -32, 0, 0xFF, 0xFF, 121, 0, 0x100, 0x12F, -3, -3, 0x130, 0x130, 0, -199, | ||
| 3412 | +0x131, 0x131, -232, 0, 0x132, 0x137, -3, -3, 0x139, 0x148, -3, -3, 0x14A, 0x177, -3, -3, | ||
| 3413 | +0x178, 0x178, 0, -121, 0x179, 0x17E, -3, -3, 0x17F, 0x17F, -300, 0, 0x180, 0x180, 195, 0, | ||
| 3414 | +0x181, 0x181, 0, 210, 0x182, 0x185, -3, -3, 0x186, 0x186, 0, 206, 0x187, 0x188, -3, -3, | ||
| 3415 | +0x189, 0x18A, 0, 205, 0x18B, 0x18C, -3, -3, 0x18E, 0x18E, 0, 79, 0x18F, 0x18F, 0, 202, | ||
| 3416 | +0x190, 0x190, 0, 203, 0x191, 0x192, -3, -3, 0x193, 0x193, 0, 205, 0x194, 0x194, 0, 207, | ||
| 3417 | +0x195, 0x195, 97, 0, 0x196, 0x196, 0, 211, 0x197, 0x197, 0, 209, 0x198, 0x199, -3, -3, | ||
| 3418 | +0x19A, 0x19A, 163, 0, 0x19C, 0x19C, 0, 211, 0x19D, 0x19D, 0, 213, 0x19E, 0x19E, 130, 0, | ||
| 3419 | +0x19F, 0x19F, 0, 214, 0x1A0, 0x1A5, -3, -3, 0x1A6, 0x1A6, 0, 218, 0x1A7, 0x1A8, -3, -3, | ||
| 3420 | +0x1A9, 0x1A9, 0, 218, 0x1AC, 0x1AD, -3, -3, 0x1AE, 0x1AE, 0, 218, 0x1AF, 0x1B0, -3, -3, | ||
| 3421 | +0x1B1, 0x1B2, 0, 217, 0x1B3, 0x1B6, -3, -3, 0x1B7, 0x1B7, 0, 219, 0x1B8, 0x1B9, -3, -3, | ||
| 3422 | +0x1BC, 0x1BD, -3, -3, 0x1BF, 0x1BF, 56, 0, 0x1C4, 0x1CC, -2, -2, 0x1CD, 0x1DC, -3, -3, | ||
| 3423 | +0x1DD, 0x1DD, -79, 0, 0x1DE, 0x1EF, -3, -3, 0x1F1, 0x1F3, -2, -2, 0x1F4, 0x1F5, -3, -3, | ||
| 3424 | +0x1F6, 0x1F6, 0, -97, 0x1F7, 0x1F7, 0, -56, 0x1F8, 0x21F, -3, -3, 0x220, 0x220, 0, -130, | ||
| 3425 | +0x222, 0x233, -3, -3, 0x23A, 0x23A, 0, 10795, 0x23B, 0x23C, -3, -3, 0x23D, 0x23D, 0, -163, | ||
| 3426 | +0x23E, 0x23E, 0, 10792, 0x23F, 0x240, 10815, 0, 0x241, 0x242, -3, -3, 0x243, 0x243, 0, -195, | ||
| 3427 | +0x244, 0x244, 0, 69, 0x245, 0x245, 0, 71, 0x246, 0x24F, -3, -3, 0x250, 0x250, 10783, 0, | ||
| 3428 | +0x251, 0x251, 10780, 0, 0x252, 0x252, 10782, 0, 0x253, 0x253, -210, 0, 0x254, 0x254, -206, 0, | ||
| 3429 | +0x256, 0x257, -205, 0, 0x259, 0x259, -202, 0, 0x25B, 0x25B, -203, 0, 0x25C, 0x25C, 42319, 0, | ||
| 3430 | +0x260, 0x260, -205, 0, 0x261, 0x261, 42315, 0, 0x263, 0x263, -207, 0, 0x265, 0x265, 42280, 0, | ||
| 3431 | +0x266, 0x266, 42308, 0, 0x268, 0x268, -209, 0, 0x269, 0x269, -211, 0, 0x26A, 0x26A, 42308, 0, | ||
| 3432 | +0x26B, 0x26B, 10743, 0, 0x26C, 0x26C, 42305, 0, 0x26F, 0x26F, -211, 0, 0x271, 0x271, 10749, 0, | ||
| 3433 | +0x272, 0x272, -213, 0, 0x275, 0x275, -214, 0, 0x27D, 0x27D, 10727, 0, 0x280, 0x280, -218, 0, | ||
| 3434 | +0x282, 0x282, 42307, 0, 0x283, 0x283, -218, 0, 0x287, 0x287, 42282, 0, 0x288, 0x288, -218, 0, | ||
| 3435 | +0x289, 0x289, -69, 0, 0x28A, 0x28B, -217, 0, 0x28C, 0x28C, -71, 0, 0x292, 0x292, -219, 0, | ||
| 3436 | +0x29D, 0x29D, 42261, 0, 0x29E, 0x29E, 42258, 0, 0x345, 0x345, 84, 0, 0x370, 0x373, -3, -3, | ||
| 3437 | +0x376, 0x377, -3, -3, 0x37B, 0x37D, 130, 0, 0x37F, 0x37F, 0, 116, 0x386, 0x386, 0, 38, | ||
| 3438 | +0x388, 0x38A, 0, 37, 0x38C, 0x38C, 0, 64, 0x38E, 0x38F, 0, 63, 0x391, 0x3A1, 0, 32, | ||
| 3439 | +0x3A3, 0x3AB, 0, 32, 0x3AC, 0x3AC, -38, 0, 0x3AD, 0x3AF, -37, 0, 0x3B1, 0x3C1, -32, 0, | ||
| 3440 | +0x3C2, 0x3C2, -31, 0, 0x3C3, 0x3CB, -32, 0, 0x3CC, 0x3CC, -64, 0, 0x3CD, 0x3CE, -63, 0, | ||
| 3441 | +0x3CF, 0x3CF, 0, 8, 0x3D0, 0x3D0, -62, 0, 0x3D1, 0x3D1, -57, 0, 0x3D5, 0x3D5, -47, 0, | ||
| 3442 | +0x3D6, 0x3D6, -54, 0, 0x3D7, 0x3D7, -8, 0, 0x3D8, 0x3EF, -3, -3, 0x3F0, 0x3F0, -86, 0, | ||
| 3443 | +0x3F1, 0x3F1, -80, 0, 0x3F2, 0x3F2, 7, 0, 0x3F3, 0x3F3, -116, 0, 0x3F4, 0x3F4, 0, -60, | ||
| 3444 | +0x3F5, 0x3F5, -96, 0, 0x3F7, 0x3F8, -3, -3, 0x3F9, 0x3F9, 0, -7, 0x3FA, 0x3FB, -3, -3, | ||
| 3445 | +0x3FD, 0x3FF, 0, -130, 0x400, 0x40F, 0, 80, 0x410, 0x42F, 0, 32, 0x430, 0x44F, -32, 0, | ||
| 3446 | +0x450, 0x45F, -80, 0, 0x460, 0x481, -3, -3, 0x48A, 0x4BF, -3, -3, 0x4C0, 0x4C0, 0, 15, | ||
| 3447 | +0x4C1, 0x4CE, -3, -3, 0x4CF, 0x4CF, -15, 0, 0x4D0, 0x52F, -3, -3, 0x531, 0x556, 0, 48, | ||
| 3448 | +0x561, 0x586, -48, 0, 0x10A0, 0x10C5, 0, 7264, 0x10C7, 0x10C7, 0, 7264, 0x10CD, 0x10CD, 0, 7264, | ||
| 3449 | +0x10D0, 0x10FA, 3008, 0, 0x10FD, 0x10FF, 3008, 0, 0x13A0, 0x13EF, 0, 38864, 0x13F0, 0x13F5, 0, 8, | ||
| 3450 | +0x13F8, 0x13FD, -8, 0, 0x1C80, 0x1C80, -6254, 0, 0x1C81, 0x1C81, -6253, 0, 0x1C82, 0x1C82, -6244, 0, | ||
| 3451 | +0x1C83, 0x1C84, -6242, 0, 0x1C85, 0x1C85, -6243, 0, 0x1C86, 0x1C86, -6236, 0, 0x1C87, 0x1C87, -6181, 0, | ||
| 3452 | +0x1C88, 0x1C88, 35266, 0, 0x1C90, 0x1CBA, 0, -3008, 0x1CBD, 0x1CBF, 0, -3008, 0x1D79, 0x1D79, 35332, 0, | ||
| 3453 | +0x1D7D, 0x1D7D, 3814, 0, 0x1D8E, 0x1D8E, 35384, 0, 0x1E00, 0x1E95, -3, -3, 0x1E9B, 0x1E9B, -59, 0, | ||
| 3454 | +0x1E9E, 0x1E9E, 0, -7615, 0x1EA0, 0x1EFF, -3, -3, 0x1F00, 0x1F07, 8, 0, 0x1F08, 0x1F0F, 0, -8, | ||
| 3455 | +0x1F10, 0x1F15, 8, 0, 0x1F18, 0x1F1D, 0, -8, 0x1F20, 0x1F27, 8, 0, 0x1F28, 0x1F2F, 0, -8, | ||
| 3456 | +0x1F30, 0x1F37, 8, 0, 0x1F38, 0x1F3F, 0, -8, 0x1F40, 0x1F45, 8, 0, 0x1F48, 0x1F4D, 0, -8, | ||
| 3457 | +0x1F51, 0x1F51, 8, 0, 0x1F53, 0x1F53, 8, 0, 0x1F55, 0x1F55, 8, 0, 0x1F57, 0x1F57, 8, 0, | ||
| 3458 | +0x1F59, 0x1F59, 0, -8, 0x1F5B, 0x1F5B, 0, -8, 0x1F5D, 0x1F5D, 0, -8, 0x1F5F, 0x1F5F, 0, -8, | ||
| 3459 | +0x1F60, 0x1F67, 8, 0, 0x1F68, 0x1F6F, 0, -8, 0x1F70, 0x1F71, 74, 0, 0x1F72, 0x1F75, 86, 0, | ||
| 3460 | +0x1F76, 0x1F77, 100, 0, 0x1F78, 0x1F79, 128, 0, 0x1F7A, 0x1F7B, 112, 0, 0x1F7C, 0x1F7D, 126, 0, | ||
| 3461 | +0x1F80, 0x1F87, 8, 0, 0x1F88, 0x1F8F, 0, -8, 0x1F90, 0x1F97, 8, 0, 0x1F98, 0x1F9F, 0, -8, | ||
| 3462 | +0x1FA0, 0x1FA7, 8, 0, 0x1FA8, 0x1FAF, 0, -8, 0x1FB0, 0x1FB1, 8, 0, 0x1FB3, 0x1FB3, 9, 0, | ||
| 3463 | +0x1FB8, 0x1FB9, 0, -8, 0x1FBA, 0x1FBB, 0, -74, 0x1FBC, 0x1FBC, 0, -9, 0x1FBE, 0x1FBE, -7205, 0, | ||
| 3464 | +0x1FC3, 0x1FC3, 9, 0, 0x1FC8, 0x1FCB, 0, -86, 0x1FCC, 0x1FCC, 0, -9, 0x1FD0, 0x1FD1, 8, 0, | ||
| 3465 | +0x1FD8, 0x1FD9, 0, -8, 0x1FDA, 0x1FDB, 0, -100, 0x1FE0, 0x1FE1, 8, 0, 0x1FE5, 0x1FE5, 7, 0, | ||
| 3466 | +0x1FE8, 0x1FE9, 0, -8, 0x1FEA, 0x1FEB, 0, -112, 0x1FEC, 0x1FEC, 0, -7, 0x1FF3, 0x1FF3, 9, 0, | ||
| 3467 | +0x1FF8, 0x1FF9, 0, -128, 0x1FFA, 0x1FFB, 0, -126, 0x1FFC, 0x1FFC, 0, -9, 0x2126, 0x2126, 0, -7517, | ||
| 3468 | +0x212A, 0x212A, 0, -8383, 0x212B, 0x212B, 0, -8262, 0x2132, 0x2132, 0, 28, 0x214E, 0x214E, -28, 0, | ||
| 3469 | +0x2160, 0x216F, 0, 16, 0x2170, 0x217F, -16, 0, 0x2183, 0x2184, -3, -3, 0x24B6, 0x24CF, 0, 26, | ||
| 3470 | +0x24D0, 0x24E9, -26, 0, 0x2C00, 0x2C2F, 0, 48, 0x2C30, 0x2C5F, -48, 0, 0x2C60, 0x2C61, -3, -3, | ||
| 3471 | +0x2C62, 0x2C62, 0, -10743, 0x2C63, 0x2C63, 0, -3814, 0x2C64, 0x2C64, 0, -10727, 0x2C65, 0x2C65, -10795, 0, | ||
| 3472 | +0x2C66, 0x2C66, -10792, 0, 0x2C67, 0x2C6C, -3, -3, 0x2C6D, 0x2C6D, 0, -10780, 0x2C6E, 0x2C6E, 0, -10749, | ||
| 3473 | +0x2C6F, 0x2C6F, 0, -10783, 0x2C70, 0x2C70, 0, -10782, 0x2C72, 0x2C73, -3, -3, 0x2C75, 0x2C76, -3, -3, | ||
| 3474 | +0x2C7E, 0x2C7F, 0, -10815, 0x2C80, 0x2CE3, -3, -3, 0x2CEB, 0x2CEE, -3, -3, 0x2CF2, 0x2CF3, -3, -3, | ||
| 3475 | +0x2D00, 0x2D25, -7264, 0, 0x2D27, 0x2D27, -7264, 0, 0x2D2D, 0x2D2D, -7264, 0, 0xA640, 0xA66D, -3, -3, | ||
| 3476 | +0xA680, 0xA69B, -3, -3, 0xA722, 0xA72F, -3, -3, 0xA732, 0xA76F, -3, -3, 0xA779, 0xA77C, -3, -3, | ||
| 3477 | +0xA77D, 0xA77D, 0, -35332, 0xA77E, 0xA787, -3, -3, 0xA78B, 0xA78C, -3, -3, 0xA78D, 0xA78D, 0, -42280, | ||
| 3478 | +0xA790, 0xA793, -3, -3, 0xA794, 0xA794, 48, 0, 0xA796, 0xA7A9, -3, -3, 0xA7AA, 0xA7AA, 0, -42308, | ||
| 3479 | +0xA7AB, 0xA7AB, 0, -42319, 0xA7AC, 0xA7AC, 0, -42315, 0xA7AD, 0xA7AD, 0, -42305, 0xA7AE, 0xA7AE, 0, -42308, | ||
| 3480 | +0xA7B0, 0xA7B0, 0, -42258, 0xA7B1, 0xA7B1, 0, -42282, 0xA7B2, 0xA7B2, 0, -42261, 0xA7B3, 0xA7B3, 0, 928, | ||
| 3481 | +0xA7B4, 0xA7C3, -3, -3, 0xA7C4, 0xA7C4, 0, -48, 0xA7C5, 0xA7C5, 0, -42307, 0xA7C6, 0xA7C6, 0, -35384, | ||
| 3482 | +0xA7C7, 0xA7CA, -3, -3, 0xA7D0, 0xA7D1, -3, -3, 0xA7D6, 0xA7D9, -3, -3, 0xA7F5, 0xA7F6, -3, -3, | ||
| 3483 | +0xAB53, 0xAB53, -928, 0, 0xAB70, 0xABBF, -38864, 0, 0xFF21, 0xFF3A, 0, 32, 0xFF41, 0xFF5A, -32, 0, | ||
| 3484 | +0x10400, 0x10427, 0, 40, 0x10428, 0x1044F, -40, 0, 0x104B0, 0x104D3, 0, 40, 0x104D8, 0x104FB, -40, 0, | ||
| 3485 | +0x10570, 0x1057A, 0, 39, 0x1057C, 0x1058A, 0, 39, 0x1058C, 0x10592, 0, 39, 0x10594, 0x10595, 0, 39, | ||
| 3486 | +0x10597, 0x105A1, -39, 0, 0x105A3, 0x105B1, -39, 0, 0x105B3, 0x105B9, -39, 0, 0x105BB, 0x105BC, -39, 0, | ||
| 3487 | +0x10C80, 0x10CB2, 0, 64, 0x10CC0, 0x10CF2, -64, 0, 0x118A0, 0x118BF, 0, 32, 0x118C0, 0x118DF, -32, 0, | ||
| 3488 | +0x16E40, 0x16E5F, 0, 32, 0x16E60, 0x16E7F, -32, 0, 0x1E900, 0x1E921, 0, 34, 0x1E922, 0x1E943, -34, 0}; // fixed array const | ||
| 3489 | +static const u8 _const_str_intp_has_dynamic_width = 1; // precomputed2 | ||
| 3490 | +static const u8 _const_str_intp_has_dynamic_precision = 2; // precomputed2 | ||
| 3491 | +static rune _const_utf8_replacement_rune; // inited later | ||
| 3492 | +static u32 _const_builtin__closure__closure_size_1; // inited later | ||
| 3493 | +Array_fixed_int_64 g_autostr_type_stack = {0}; // global 6 | ||
| 3494 | + | ||
| 3495 | +Array_fixed_voidptr_64 g_autostr_addr_stack = {0}; // global 6 | ||
| 3496 | + | ||
| 3497 | +static int _const_builtin__closure__closure_size; // inited later | ||
| 3498 | + | ||
| 3499 | +// V interface table: | ||
| 3500 | +static IError I_None___to_Interface_IError(None__* x); | ||
| 3501 | +enum { _IError_None___index = 1 }; | ||
| 3502 | +static IError I_voidptr_to_Interface_IError(voidptr* x); | ||
| 3503 | +enum { _IError_voidptr_index = 2 }; | ||
| 3504 | +static IError I_MessageError_to_Interface_IError(MessageError* x); | ||
| 3505 | +enum { _IError_MessageError_index = 3 }; | ||
| 3506 | +static IError I_Error_to_Interface_IError(Error* x); | ||
| 3507 | +enum { _IError_Error_index = 4 }; | ||
| 3508 | +// ^^^ number of types for interface IError: 4 | ||
| 3509 | + | ||
| 3510 | +// Methods wrapper for interface "IError" | ||
| 3511 | +static inline int builtin__None___code_Interface_IError_method_wrapper(None__* err) { | ||
| 3512 | + return builtin__Error_code(err->Error); | ||
| 3513 | +} | ||
| 3514 | +static inline int builtin__None___code_Interface_IError_method_adapter(void* _x) { | ||
| 3515 | + return builtin__None___code_Interface_IError_method_wrapper((None__*)_x); | ||
| 3516 | +} | ||
| 3517 | +static inline string builtin__None___msg_Interface_IError_method_wrapper(None__* err) { | ||
| 3518 | + return builtin__Error_msg(err->Error); | ||
| 3519 | +} | ||
| 3520 | +static inline string builtin__None___msg_Interface_IError_method_adapter(void* _x) { | ||
| 3521 | + return builtin__None___msg_Interface_IError_method_wrapper((None__*)_x); | ||
| 3522 | +} | ||
| 3523 | +static inline int builtin__MessageError_code_Interface_IError_method_wrapper(MessageError* err) { | ||
| 3524 | + return builtin__MessageError_code(*err); | ||
| 3525 | +} | ||
| 3526 | +static inline int builtin__MessageError_code_Interface_IError_method_adapter(void* _x) { | ||
| 3527 | + return builtin__MessageError_code_Interface_IError_method_wrapper((MessageError*)_x); | ||
| 3528 | +} | ||
| 3529 | +static inline string builtin__MessageError_msg_Interface_IError_method_wrapper(MessageError* err) { | ||
| 3530 | + return builtin__MessageError_msg(*err); | ||
| 3531 | +} | ||
| 3532 | +static inline string builtin__MessageError_msg_Interface_IError_method_adapter(void* _x) { | ||
| 3533 | + return builtin__MessageError_msg_Interface_IError_method_wrapper((MessageError*)_x); | ||
| 3534 | +} | ||
| 3535 | +static inline int builtin__Error_code_Interface_IError_method_wrapper(Error* err) { | ||
| 3536 | + return builtin__Error_code(*err); | ||
| 3537 | +} | ||
| 3538 | +static inline int builtin__Error_code_Interface_IError_method_adapter(void* _x) { | ||
| 3539 | + return builtin__Error_code_Interface_IError_method_wrapper((Error*)_x); | ||
| 3540 | +} | ||
| 3541 | +static inline string builtin__Error_msg_Interface_IError_method_wrapper(Error* err) { | ||
| 3542 | + return builtin__Error_msg(*err); | ||
| 3543 | +} | ||
| 3544 | +static inline string builtin__Error_msg_Interface_IError_method_adapter(void* _x) { | ||
| 3545 | + return builtin__Error_msg_Interface_IError_method_wrapper((Error*)_x); | ||
| 3546 | +} | ||
| 3547 | + | ||
| 3548 | +struct _IError_interface_methods { | ||
| 3549 | + int (*_method_code)(void* _); | ||
| 3550 | + string (*_method_msg)(void* _); | ||
| 3551 | +}; | ||
| 3552 | + | ||
| 3553 | +struct _IError_interface_methods IError_name_table[5] = { | ||
| 3554 | + {0}, | ||
| 3555 | + { | ||
| 3556 | + ._method_code = builtin__None___code_Interface_IError_method_adapter, | ||
| 3557 | + ._method_msg = builtin__None___msg_Interface_IError_method_adapter, | ||
| 3558 | + }, | ||
| 3559 | + { | ||
| 3560 | + ._method_code = (void*) 0, | ||
| 3561 | + ._method_msg = (void*) 0, | ||
| 3562 | + }, | ||
| 3563 | + { | ||
| 3564 | + ._method_code = builtin__MessageError_code_Interface_IError_method_adapter, | ||
| 3565 | + ._method_msg = builtin__MessageError_msg_Interface_IError_method_adapter, | ||
| 3566 | + }, | ||
| 3567 | + { | ||
| 3568 | + ._method_code = builtin__Error_code_Interface_IError_method_adapter, | ||
| 3569 | + ._method_msg = builtin__Error_msg_Interface_IError_method_adapter, | ||
| 3570 | + }, | ||
| 3571 | +}; | ||
| 3572 | + | ||
| 3573 | + | ||
| 3574 | +// Casting functions for converting "None__" to interface "IError" | ||
| 3575 | + | ||
| 3576 | +static inline IError I_None___to_Interface_IError(None__* x) { | ||
| 3577 | +return (IError) { | ||
| 3578 | + ._None__ = x, | ||
| 3579 | + ._typ = _IError_None___index, | ||
| 3580 | + ._methods = &IError_name_table[_IError_None___index], | ||
| 3581 | + }; | ||
| 3582 | +} | ||
| 3583 | + | ||
| 3584 | +// Casting functions for converting "voidptr" to interface "IError" | ||
| 3585 | + | ||
| 3586 | +static inline IError I_voidptr_to_Interface_IError(voidptr* x) { | ||
| 3587 | +return (IError) { | ||
| 3588 | + ._voidptr = x, | ||
| 3589 | + ._typ = _IError_voidptr_index, | ||
| 3590 | + ._methods = &IError_name_table[_IError_voidptr_index], | ||
| 3591 | + }; | ||
| 3592 | +} | ||
| 3593 | + | ||
| 3594 | +// Casting functions for converting "MessageError" to interface "IError" | ||
| 3595 | + | ||
| 3596 | +static inline IError I_MessageError_to_Interface_IError(MessageError* x) { | ||
| 3597 | +return (IError) { | ||
| 3598 | + ._MessageError = x, | ||
| 3599 | + ._typ = _IError_MessageError_index, | ||
| 3600 | + ._methods = &IError_name_table[_IError_MessageError_index], | ||
| 3601 | + }; | ||
| 3602 | +} | ||
| 3603 | + | ||
| 3604 | +// Casting functions for converting "Error" to interface "IError" | ||
| 3605 | + | ||
| 3606 | +static inline IError I_Error_to_Interface_IError(Error* x) { | ||
| 3607 | +return (IError) { | ||
| 3608 | + ._Error = x, | ||
| 3609 | + ._typ = _IError_Error_index, | ||
| 3610 | + ._methods = &IError_name_table[_IError_Error_index], | ||
| 3611 | + }; | ||
| 3612 | +} | ||
| 3613 | + | ||
| 3614 | + | ||
| 3615 | +static inline IError __v_interface_clone_variant__IError__None__(void* x) { | ||
| 3616 | +return I_None___to_Interface_IError((None__*)builtin__memdup(x, sizeof(None__))); | ||
| 3617 | +} | ||
| 3618 | + | ||
| 3619 | +static inline IError __v_interface_clone_variant__IError__voidptr(void* x) { | ||
| 3620 | +return I_voidptr_to_Interface_IError((voidptr*)builtin__memdup(x, sizeof(voidptr))); | ||
| 3621 | +} | ||
| 3622 | + | ||
| 3623 | +static inline IError __v_interface_clone_variant__IError__MessageError(void* x) { | ||
| 3624 | +return I_MessageError_to_Interface_IError((MessageError*)builtin__memdup(x, sizeof(MessageError))); | ||
| 3625 | +} | ||
| 3626 | + | ||
| 3627 | +static inline IError __v_interface_clone_variant__IError__Error(void* x) { | ||
| 3628 | +return I_Error_to_Interface_IError((Error*)builtin__memdup(x, sizeof(Error))); | ||
| 3629 | +} | ||
| 3630 | + | ||
| 3631 | +static inline IError __v_interface_clone__IError(IError x) { | ||
| 3632 | + if (x._object == 0) { | ||
| 3633 | + return x; | ||
| 3634 | + } | ||
| 3635 | + if (x._typ == _IError_None___index) { | ||
| 3636 | + return __v_interface_clone_variant__IError__None__(x._object); | ||
| 3637 | + } | ||
| 3638 | + if (x._typ == _IError_voidptr_index) { | ||
| 3639 | + return __v_interface_clone_variant__IError__voidptr(x._object); | ||
| 3640 | + } | ||
| 3641 | + if (x._typ == _IError_MessageError_index) { | ||
| 3642 | + return __v_interface_clone_variant__IError__MessageError(x._object); | ||
| 3643 | + } | ||
| 3644 | + if (x._typ == _IError_Error_index) { | ||
| 3645 | + return __v_interface_clone_variant__IError__Error(x._object); | ||
| 3646 | + } | ||
| 3647 | + return x; | ||
| 3648 | +} | ||
| 3649 | + | ||
| 3650 | + | ||
| 3651 | +// V sort fn definitions: | ||
| 3652 | +VV_LOC int compare_11734835982493514523_RepIndex_by_idx_expr_612e6964780a3c0a622e696478(RepIndex* a, RepIndex* b) { | ||
| 3653 | + if (a->idx < b->idx) return -1; | ||
| 3654 | + if (b->idx < a->idx) return 1; | ||
| 3655 | + return 0; | ||
| 3656 | +} | ||
| 3657 | + | ||
| 3658 | +VV_LOC int compare_11734835982493514523_RepIndex_by_idx_expr_612e6964780a3c0a622e696478_qsort_adapter(const void* a, const void* b) { | ||
| 3659 | + return compare_11734835982493514523_RepIndex_by_idx_expr_612e6964780a3c0a622e696478((RepIndex*)a, (RepIndex*)b); | ||
| 3660 | +} | ||
| 3661 | + | ||
| 3662 | +VV_LOC int builtin__compare_lower_strings_qsort_adapter(const void* a, const void* b) { | ||
| 3663 | + return builtin__compare_lower_strings((string*)a, (string*)b); | ||
| 3664 | +} | ||
| 3665 | + | ||
| 3666 | +VV_LOC int builtin__compare_strings_by_len_qsort_adapter(const void* a, const void* b) { | ||
| 3667 | + return builtin__compare_strings_by_len((string*)a, (string*)b); | ||
| 3668 | +} | ||
| 3669 | + | ||
| 3670 | +static inline u64 VSAFE_DIV_u64(u64 x, u64 y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("division by zero")); } return x / y; } | ||
| 3671 | +static inline u64 VSAFE_MOD_u64(u64 x, u64 y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("modulo by zero")); } return x % y; } | ||
| 3672 | +static inline int VSAFE_DIV_int(int x, int y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("division by zero")); } return x / y; } | ||
| 3673 | +static inline usize VSAFE_MOD_usize(usize x, usize y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("modulo by zero")); } return x % y; } | ||
| 3674 | +static inline u32 VSAFE_DIV_u32(u32 x, u32 y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("division by zero")); } return x / y; } | ||
| 3675 | +static inline u32 VSAFE_MOD_u32(u32 x, u32 y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("modulo by zero")); } return x % y; } | ||
| 3676 | +static inline i64 VSAFE_DIV_i64(i64 x, i64 y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("division by zero")); } return x / y; } | ||
| 3677 | +static inline int VSAFE_MOD_int(int x, int y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("modulo by zero")); } return x % y; } | ||
| 3678 | +static inline i64 VSAFE_MOD_i64(i64 x, i64 y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("modulo by zero")); } return x % y; } | ||
| 3679 | +static inline rune VSAFE_MOD_rune(rune x, rune y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("modulo by zero")); } return x % y; } | ||
| 3680 | + | ||
| 3681 | +// end of V out (header) | ||
| 3682 | + | ||
| 3683 | +// V auto functions: | ||
| 3684 | +static bool Array_u8_contains(Array_u8 a, u8 v) { | ||
| 3685 | + for (int i = 0; i < a.len; ++i) { | ||
| 3686 | + if (((u8*)a.data)[i] == v) { | ||
| 3687 | + return true; | ||
| 3688 | + } | ||
| 3689 | + } | ||
| 3690 | + return false; | ||
| 3691 | +} | ||
| 3692 | + | ||
| 3693 | +static inline bool Array_rune_arr_eq(Array_rune a, Array_rune b) { | ||
| 3694 | + if (a.len != b.len) { | ||
| 3695 | + return false; | ||
| 3696 | + } | ||
| 3697 | + for (int i = 0; i < a.len; ++i) { | ||
| 3698 | + if (*((rune*)((byte*)a.data+(i*a.element_size))) != *((rune*)((byte*)b.data+(i*b.element_size)))) { | ||
| 3699 | + return false; | ||
| 3700 | + } | ||
| 3701 | + } | ||
| 3702 | + return true; | ||
| 3703 | +} | ||
| 3704 | + | ||
| 3705 | +static inline bool builtin__closure__ClosureLifetimeRecord_struct_eq(builtin__closure__ClosureLifetimeRecord a, builtin__closure__ClosureLifetimeRecord b) { | ||
| 3706 | + return a.exec_ptr == b.exec_ptr | ||
| 3707 | + && a.generation == b.generation; | ||
| 3708 | +} | ||
| 3709 | + | ||
| 3710 | +static inline bool Array_builtin__closure__ClosureLifetimeRecord_arr_eq(Array_builtin__closure__ClosureLifetimeRecord a, Array_builtin__closure__ClosureLifetimeRecord b) { | ||
| 3711 | + if (a.len != b.len) { | ||
| 3712 | + return false; | ||
| 3713 | + } | ||
| 3714 | + for (int i = 0; i < a.len; ++i) { | ||
| 3715 | + if (!builtin__closure__ClosureLifetimeRecord_struct_eq(((builtin__closure__ClosureLifetimeRecord*)a.data)[i], ((builtin__closure__ClosureLifetimeRecord*)b.data)[i])) { | ||
| 3716 | + return false; | ||
| 3717 | + } | ||
| 3718 | + } | ||
| 3719 | + return true; | ||
| 3720 | +} | ||
| 3721 | + | ||
| 3722 | +static inline bool builtin__closure__ClosureLifetimeFrame_struct_eq(builtin__closure__ClosureLifetimeFrame a, builtin__closure__ClosureLifetimeFrame b) { | ||
| 3723 | + return a.start == b.start | ||
| 3724 | + && a.end == b.end; | ||
| 3725 | +} | ||
| 3726 | + | ||
| 3727 | +static inline bool Array_builtin__closure__ClosureLifetimeFrame_arr_eq(Array_builtin__closure__ClosureLifetimeFrame a, Array_builtin__closure__ClosureLifetimeFrame b) { | ||
| 3728 | + if (a.len != b.len) { | ||
| 3729 | + return false; | ||
| 3730 | + } | ||
| 3731 | + for (int i = 0; i < a.len; ++i) { | ||
| 3732 | + if (!builtin__closure__ClosureLifetimeFrame_struct_eq(((builtin__closure__ClosureLifetimeFrame*)a.data)[i], ((builtin__closure__ClosureLifetimeFrame*)b.data)[i])) { | ||
| 3733 | + return false; | ||
| 3734 | + } | ||
| 3735 | + } | ||
| 3736 | + return true; | ||
| 3737 | +} | ||
| 3738 | + | ||
| 3739 | +static inline bool builtin__closure__ClosureLifetimeState_struct_eq(builtin__closure__ClosureLifetimeState a, builtin__closure__ClosureLifetimeState b) { | ||
| 3740 | + return a.owner_thread == b.owner_thread | ||
| 3741 | + && a.active == b.active | ||
| 3742 | + && a.disposed == b.disposed | ||
| 3743 | + && a.suspended == b.suspended | ||
| 3744 | + && a.frame_start == b.frame_start | ||
| 3745 | + && a.frame_gen == b.frame_gen | ||
| 3746 | + && a.generation == b.generation | ||
| 3747 | + && a.frame_generation == b.frame_generation | ||
| 3748 | + && Array_builtin__closure__ClosureLifetimeRecord_arr_eq(a.records, b.records) | ||
| 3749 | + && Array_builtin__closure__ClosureLifetimeFrame_arr_eq(a.frames, b.frames) | ||
| 3750 | + && a.next_free == b.next_free; | ||
| 3751 | +} | ||
| 3752 | + | ||
| 3753 | + | ||
| 3754 | +// >> typeof() support for sum types / interfaces | ||
| 3755 | +static char * v_typeof_interface_IError(u32 sidx) { | ||
| 3756 | + if (sidx == _IError_None___index) return "None__"; | ||
| 3757 | + if (sidx == _IError_voidptr_index) return "voidptr"; | ||
| 3758 | + if (sidx == _IError_MessageError_index) return "MessageError"; | ||
| 3759 | + if (sidx == _IError_Error_index) return "Error"; | ||
| 3760 | + return "unknown IError"; | ||
| 3761 | +} | ||
| 3762 | + | ||
| 3763 | +u32 v_typeof_interface_idx_IError(u32 sidx) { | ||
| 3764 | + if (sidx == _IError_None___index) return 65; | ||
| 3765 | + if (sidx == _IError_voidptr_index) return 2; | ||
| 3766 | + if (sidx == _IError_MessageError_index) return 67; | ||
| 3767 | + if (sidx == _IError_Error_index) return 66; | ||
| 3768 | + return 30; | ||
| 3769 | +} | ||
| 3770 | +// << typeof() support for sum types | ||
| 3771 | + | ||
| 3772 | +strings__Builder strings__new_builder(int initial_size) { | ||
| 3773 | + strings__Builder res = ((builtin____new_array_with_default(0, initial_size, sizeof(u8), 0))); | ||
| 3774 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | ||
| 3775 | + return res; | ||
| 3776 | +} | ||
| 3777 | +Array_u8 strings__Builder_reuse_as_plain_u8_array(strings__Builder* b) { | ||
| 3778 | + builtin__ArrayFlags_clear(&b->flags, ArrayFlags__noslices); | ||
| 3779 | + return *b; | ||
| 3780 | +} | ||
| 3781 | +void strings__Builder_write_ptr(strings__Builder* b, u8* ptr, int len) { | ||
| 3782 | + if (len == 0) { | ||
| 3783 | + return; | ||
| 3784 | + } | ||
| 3785 | + builtin__array_push_many(b, ptr, len); | ||
| 3786 | +} | ||
| 3787 | +void strings__Builder_write_rune(strings__Builder* b, rune r) { | ||
| 3788 | + Array_fixed_u8_5 buffer = {0}; | ||
| 3789 | + string res = builtin__utf32_to_str_no_malloc(((u32)(r)), &buffer[0]); | ||
| 3790 | + if (res.len == 0) { | ||
| 3791 | + return; | ||
| 3792 | + } | ||
| 3793 | + builtin__array_push_many(b, res.str, res.len); | ||
| 3794 | +} | ||
| 3795 | +void strings__Builder_write_runes(strings__Builder* b, Array_rune runes) { | ||
| 3796 | + Array_fixed_u8_5 buffer = {0}; | ||
| 3797 | + for (int _t1 = 0; _t1 < runes.len; ++_t1) { | ||
| 3798 | + rune r = ((rune*)runes.data)[_t1]; | ||
| 3799 | + string res = builtin__utf32_to_str_no_malloc(((u32)(r)), &buffer[0]); | ||
| 3800 | + if (res.len == 0) { | ||
| 3801 | + continue; | ||
| 3802 | + } | ||
| 3803 | + builtin__array_push_many(b, res.str, res.len); | ||
| 3804 | + } | ||
| 3805 | +} | ||
| 3806 | +inline void strings__Builder_write_u8(strings__Builder* b, u8 data) { | ||
| 3807 | + builtin__array_push((array*)b, _MOV((u8[]){ data })); | ||
| 3808 | +} | ||
| 3809 | +inline void strings__Builder_write_byte(strings__Builder* b, u8 data) { | ||
| 3810 | + builtin__array_push((array*)b, _MOV((u8[]){ data })); | ||
| 3811 | +} | ||
| 3812 | +void strings__Builder_write_decimal(strings__Builder* b, i64 n) { | ||
| 3813 | + if (n == 0) { | ||
| 3814 | + strings__Builder_write_u8(b, 0x30); | ||
| 3815 | + return; | ||
| 3816 | + } | ||
| 3817 | + u64 mag = ((u64)(n)); | ||
| 3818 | + if (n < 0) { | ||
| 3819 | + strings__Builder_write_u8(b, '-'); | ||
| 3820 | + mag = ((u64)(0)) - mag; | ||
| 3821 | + } | ||
| 3822 | + strings__Builder_write_u_decimal(b, mag); | ||
| 3823 | +} | ||
| 3824 | +void strings__Builder_write_u_decimal(strings__Builder* b, u64 n) { | ||
| 3825 | + if (n == 0) { | ||
| 3826 | + strings__Builder_write_u8(b, 0x30); | ||
| 3827 | + return; | ||
| 3828 | + } | ||
| 3829 | + Array_fixed_u8_20 buf = {0}; | ||
| 3830 | + u64 x = n; | ||
| 3831 | + int i = 19; | ||
| 3832 | + for (;;) { | ||
| 3833 | + if (!(x != 0)) break; | ||
| 3834 | + u64 nextx = VSAFE_DIV_u64(x , 10); | ||
| 3835 | + u64 r = VSAFE_MOD_u64(x , 10); | ||
| 3836 | + buf[i] = (u8)(((u8)(r)) + 0x30); | ||
| 3837 | + x = nextx; | ||
| 3838 | + i--; | ||
| 3839 | + } | ||
| 3840 | + strings__Builder_write_ptr(b, &buf[i + 1], 19 - i); | ||
| 3841 | +} | ||
| 3842 | +_result_int strings__Builder_write(strings__Builder* b, Array_u8 data) { | ||
| 3843 | + if (data.len == 0) { | ||
| 3844 | + _result_int _t1; | ||
| 3845 | + builtin___result_ok(&(int[]) { 0 }, (_result*)(&_t1), sizeof(int)); | ||
| 3846 | + | ||
| 3847 | + return _t1; | ||
| 3848 | + } | ||
| 3849 | + builtin__array_push_many(b, data.data, data.len); | ||
| 3850 | + _result_int _t2; | ||
| 3851 | + builtin___result_ok(&(int[]) { data.len }, (_result*)(&_t2), sizeof(int)); | ||
| 3852 | + | ||
| 3853 | + return _t2; | ||
| 3854 | +} | ||
| 3855 | +void strings__Builder_drain_builder(strings__Builder* b, strings__Builder* other, int other_new_cap) { | ||
| 3856 | + if (other->len > 0) { | ||
| 3857 | + _PUSH_MANY(b, (*other), _t1, strings__Builder); | ||
| 3858 | + } | ||
| 3859 | + strings__Builder_free(other); | ||
| 3860 | + *other = strings__new_builder(other_new_cap); | ||
| 3861 | +} | ||
| 3862 | +inline u8 strings__Builder_byte_at(strings__Builder* b, int n) { | ||
| 3863 | + return (*(u8*)builtin__array_get(*(((Array_u8*)(b))), n)); | ||
| 3864 | +} | ||
| 3865 | +inline void strings__Builder_write_string(strings__Builder* b, string s) { | ||
| 3866 | + if (s.len == 0) { | ||
| 3867 | + return; | ||
| 3868 | + } | ||
| 3869 | + builtin__array_push_many(b, s.str, s.len); | ||
| 3870 | +} | ||
| 3871 | +inline void strings__Builder_write_string2(strings__Builder* b, string s1, string s2) { | ||
| 3872 | + if (s1.len != 0) { | ||
| 3873 | + builtin__array_push_many(b, s1.str, s1.len); | ||
| 3874 | + } | ||
| 3875 | + if (s2.len != 0) { | ||
| 3876 | + builtin__array_push_many(b, s2.str, s2.len); | ||
| 3877 | + } | ||
| 3878 | +} | ||
| 3879 | +void strings__Builder_go_back(strings__Builder* b, int n) { | ||
| 3880 | + builtin__array_trim(b, b->len - n); | ||
| 3881 | +} | ||
| 3882 | +inline string strings__Builder_spart(strings__Builder* b, int start_pos, int n) { | ||
| 3883 | + { // Unsafe block | ||
| 3884 | + u8* x = builtin__malloc_noscan(n + 1); | ||
| 3885 | + builtin__vmemcpy(x, ((u8*)(b->data)) + start_pos, n); | ||
| 3886 | + x[n] = 0; | ||
| 3887 | + return builtin__tos(x, n); | ||
| 3888 | + } | ||
| 3889 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 3890 | +} | ||
| 3891 | +string strings__Builder_cut_last(strings__Builder* b, int n) { | ||
| 3892 | + int cut_pos = b->len - n; | ||
| 3893 | + string res = strings__Builder_spart(b, cut_pos, n); | ||
| 3894 | + builtin__array_trim(b, cut_pos); | ||
| 3895 | + return res; | ||
| 3896 | +} | ||
| 3897 | +string strings__Builder_cut_to(strings__Builder* b, int pos) { | ||
| 3898 | + if (pos > b->len) { | ||
| 3899 | + return _S(""); | ||
| 3900 | + } | ||
| 3901 | + return strings__Builder_cut_last(b, b->len - pos); | ||
| 3902 | +} | ||
| 3903 | +void strings__Builder_go_back_to(strings__Builder* b, int pos) { | ||
| 3904 | + builtin__array_trim(b, pos); | ||
| 3905 | +} | ||
| 3906 | +inline void strings__Builder_writeln(strings__Builder* b, string s) { | ||
| 3907 | + if ((s).len != 0) { | ||
| 3908 | + builtin__array_push_many(b, s.str, s.len); | ||
| 3909 | + } | ||
| 3910 | + builtin__array_push((array*)b, _MOV((u8[]){ ((u8)('\n')) })); | ||
| 3911 | +} | ||
| 3912 | +inline void strings__Builder_writeln2(strings__Builder* b, string s1, string s2) { | ||
| 3913 | + if ((s1).len != 0) { | ||
| 3914 | + builtin__array_push_many(b, s1.str, s1.len); | ||
| 3915 | + } | ||
| 3916 | + builtin__array_push((array*)b, _MOV((u8[]){ ((u8)('\n')) })); | ||
| 3917 | + if ((s2).len != 0) { | ||
| 3918 | + builtin__array_push_many(b, s2.str, s2.len); | ||
| 3919 | + } | ||
| 3920 | + builtin__array_push((array*)b, _MOV((u8[]){ ((u8)('\n')) })); | ||
| 3921 | +} | ||
| 3922 | +string strings__Builder_last_n(strings__Builder* b, int n) { | ||
| 3923 | + if (n > b->len) { | ||
| 3924 | + return _S(""); | ||
| 3925 | + } | ||
| 3926 | + return strings__Builder_spart(b, b->len - n, n); | ||
| 3927 | +} | ||
| 3928 | +string strings__Builder_after(strings__Builder* b, int n) { | ||
| 3929 | + if (n >= b->len) { | ||
| 3930 | + return _S(""); | ||
| 3931 | + } | ||
| 3932 | + return strings__Builder_spart(b, n, b->len - n); | ||
| 3933 | +} | ||
| 3934 | +string strings__Builder_str(strings__Builder* b) { | ||
| 3935 | + builtin__array_push((array*)b, _MOV((u8[]){ ((u8)(0)) })); | ||
| 3936 | + u8* bcopy = ((u8*)(builtin__memdup_noscan(b->data, b->len))); | ||
| 3937 | + string s = builtin__u8_vstring_with_len(bcopy, b->len - 1); | ||
| 3938 | + builtin__array_clear(b); | ||
| 3939 | + return s; | ||
| 3940 | +} | ||
| 3941 | +void strings__Builder_ensure_cap(strings__Builder* b, int n) { | ||
| 3942 | + Array_u8* arr = ((Array_u8*)(b)); | ||
| 3943 | + builtin__array_ensure_cap(arr, n); | ||
| 3944 | +} | ||
| 3945 | +void strings__Builder_grow_len(strings__Builder* b, int n) { | ||
| 3946 | + if (n <= 0) { | ||
| 3947 | + return; | ||
| 3948 | + } | ||
| 3949 | + int new_len = b->len + n; | ||
| 3950 | + strings__Builder_ensure_cap(b, new_len); | ||
| 3951 | + { // Unsafe block | ||
| 3952 | + b->len = new_len; | ||
| 3953 | + } | ||
| 3954 | +} | ||
| 3955 | +void strings__Builder_free(strings__Builder* b) { | ||
| 3956 | + if (b->data != 0) { | ||
| 3957 | + Array_u8* arr = ((Array_u8*)(b)); | ||
| 3958 | + builtin__array_free(arr); | ||
| 3959 | + } | ||
| 3960 | +} | ||
| 3961 | +void strings__Builder_write_repeated_rune(strings__Builder* b, rune r, int count) { | ||
| 3962 | + if (count <= 0) { | ||
| 3963 | + return; | ||
| 3964 | + } | ||
| 3965 | + Array_fixed_u8_5 buffer = {0}; | ||
| 3966 | + string res = builtin__utf32_to_str_no_malloc(((u32)(r)), &buffer[0]); | ||
| 3967 | + if (res.len == 0) { | ||
| 3968 | + return; | ||
| 3969 | + } | ||
| 3970 | + if (res.len == 1) { | ||
| 3971 | + strings__Builder_ensure_cap(b, b->len + count); | ||
| 3972 | + { // Unsafe block | ||
| 3973 | + builtin__vmemset(((u8*)(b->data)) + b->len, buffer[0], count); | ||
| 3974 | + b->len += count; | ||
| 3975 | + } | ||
| 3976 | + return; | ||
| 3977 | + } else { | ||
| 3978 | + int total_needed = count * res.len; | ||
| 3979 | + strings__Builder_ensure_cap(b, b->len + total_needed); | ||
| 3980 | + u8* dest = ((u8*)(b->data)) + b->len; | ||
| 3981 | + for (int _t1 = 0; _t1 < count; ++_t1) { | ||
| 3982 | + { // Unsafe block | ||
| 3983 | + builtin__vmemcpy(dest, res.str, res.len); | ||
| 3984 | + dest += res.len; | ||
| 3985 | + } | ||
| 3986 | + } | ||
| 3987 | + { // Unsafe block | ||
| 3988 | + b->len += total_needed; | ||
| 3989 | + } | ||
| 3990 | + } | ||
| 3991 | +} | ||
| 3992 | +void strings__Builder_indent(strings__Builder* b, string s, strings__IndentParam param) { | ||
| 3993 | + if (s.len == 0) { | ||
| 3994 | + return; | ||
| 3995 | + } | ||
| 3996 | + strings__IndentState state = strings__IndentState__normal; | ||
| 3997 | + int indent_level = param.starting_level; | ||
| 3998 | + rune string_char = '\0'; | ||
| 3999 | + bool at_line_start = true; | ||
| 4000 | + for (int i = 0; i < s.len; i++) { | ||
| 4001 | + rune c = ((rune)(s.str[ i])); | ||
| 4002 | + | ||
| 4003 | + if (state == (strings__IndentState__normal)) { | ||
| 4004 | + | ||
| 4005 | + if (c == ('"') || c == ('\'')) { | ||
| 4006 | + state = strings__IndentState__in_string; | ||
| 4007 | + string_char = c; | ||
| 4008 | + if (at_line_start) { | ||
| 4009 | + strings__Builder_write_repeated_rune(b, param.indent_char, indent_level * param.indent_count); | ||
| 4010 | + at_line_start = false; | ||
| 4011 | + } | ||
| 4012 | + strings__Builder_write_rune(b, c); | ||
| 4013 | + } | ||
| 4014 | + else if (c == (param.block_start)) { | ||
| 4015 | + if (at_line_start) { | ||
| 4016 | + strings__Builder_write_repeated_rune(b, param.indent_char, indent_level * param.indent_count); | ||
| 4017 | + at_line_start = false; | ||
| 4018 | + } | ||
| 4019 | + strings__Builder_write_rune(b, c); | ||
| 4020 | + if (i + 1 < s.len && s.str[ i + 1] == param.block_end) { | ||
| 4021 | + strings__Builder_write_rune(b, param.block_end); | ||
| 4022 | + i++; | ||
| 4023 | + } else { | ||
| 4024 | + indent_level++; | ||
| 4025 | + strings__Builder_write_rune(b, '\n'); | ||
| 4026 | + at_line_start = true; | ||
| 4027 | + } | ||
| 4028 | + } | ||
| 4029 | + else if (c == (param.block_end)) { | ||
| 4030 | + if (indent_level > 0) { | ||
| 4031 | + indent_level--; | ||
| 4032 | + } | ||
| 4033 | + if (!at_line_start) { | ||
| 4034 | + strings__Builder_write_rune(b, '\n'); | ||
| 4035 | + } | ||
| 4036 | + strings__Builder_write_repeated_rune(b, param.indent_char, indent_level * param.indent_count); | ||
| 4037 | + at_line_start = false; | ||
| 4038 | + strings__Builder_write_rune(b, c); | ||
| 4039 | + } | ||
| 4040 | + else if (c == (' ') || c == ('\t') || c == ('\r') || c == ('\n')) { | ||
| 4041 | + if (!at_line_start) { | ||
| 4042 | + strings__Builder_write_rune(b, c); | ||
| 4043 | + } | ||
| 4044 | + if (c == '\n') { | ||
| 4045 | + at_line_start = true; | ||
| 4046 | + } | ||
| 4047 | + } | ||
| 4048 | + else { | ||
| 4049 | + if (at_line_start) { | ||
| 4050 | + strings__Builder_write_repeated_rune(b, param.indent_char, indent_level * param.indent_count); | ||
| 4051 | + at_line_start = false; | ||
| 4052 | + } | ||
| 4053 | + strings__Builder_write_rune(b, c); | ||
| 4054 | + } | ||
| 4055 | + } | ||
| 4056 | + else if (state == (strings__IndentState__in_string)) { | ||
| 4057 | + strings__Builder_write_rune(b, c); | ||
| 4058 | + if (c == string_char) { | ||
| 4059 | + if (s.str[ i - 1] != '\\') { | ||
| 4060 | + state = strings__IndentState__normal; | ||
| 4061 | + string_char = '\0'; | ||
| 4062 | + } | ||
| 4063 | + } | ||
| 4064 | + } | ||
| 4065 | + } | ||
| 4066 | +} | ||
| 4067 | +inline VV_LOC int strings__min(int a, int b, int c) { | ||
| 4068 | + int m = a; | ||
| 4069 | + if (b < m) { | ||
| 4070 | + m = b; | ||
| 4071 | + } | ||
| 4072 | + if (c < m) { | ||
| 4073 | + m = c; | ||
| 4074 | + } | ||
| 4075 | + return m; | ||
| 4076 | +} | ||
| 4077 | +inline VV_LOC int strings__max2(int a, int b) { | ||
| 4078 | + if (a < b) { | ||
| 4079 | + return b; | ||
| 4080 | + } | ||
| 4081 | + return a; | ||
| 4082 | +} | ||
| 4083 | +inline VV_LOC int strings__min2(int a, int b) { | ||
| 4084 | + if (a < b) { | ||
| 4085 | + return a; | ||
| 4086 | + } | ||
| 4087 | + return b; | ||
| 4088 | +} | ||
| 4089 | +inline VV_LOC int strings__abs2(int a, int b) { | ||
| 4090 | + if (a < b) { | ||
| 4091 | + return b - a; | ||
| 4092 | + } | ||
| 4093 | + return a - b; | ||
| 4094 | +} | ||
| 4095 | +int strings__levenshtein_distance(string a, string b) { | ||
| 4096 | + if (a.len == 0) { | ||
| 4097 | + return b.len; | ||
| 4098 | + } | ||
| 4099 | + if (b.len == 0) { | ||
| 4100 | + return a.len; | ||
| 4101 | + } | ||
| 4102 | + if (builtin__string__eq(a, b)) { | ||
| 4103 | + return 0; | ||
| 4104 | + } | ||
| 4105 | + Array_int row = builtin____new_array_with_default(a.len + 1, 0, sizeof(int), 0); | ||
| 4106 | + { | ||
| 4107 | + int* pelem = (int*)row.data; | ||
| 4108 | + for (int index=0; index<row.len; index++, pelem++) { | ||
| 4109 | + int it = index; | ||
| 4110 | + *pelem = index; | ||
| 4111 | + } | ||
| 4112 | + } | ||
| 4113 | + ; | ||
| 4114 | + for (int i = 1; i < b.len + 1; i++) { | ||
| 4115 | + int prev = i; | ||
| 4116 | + for (int j = 1; j < a.len + 1; j++) { | ||
| 4117 | + int current = ((int*)row.data)[j - 1]; | ||
| 4118 | + if (b.str[ i - 1] != a.str[ j - 1]) { | ||
| 4119 | + current = strings__min(((int*)row.data)[j - 1] + 1, prev + 1, ((int*)row.data)[j] + 1); | ||
| 4120 | + } | ||
| 4121 | + ((int*)row.data)[j - 1] = prev; | ||
| 4122 | + prev = current; | ||
| 4123 | + } | ||
| 4124 | + ((int*)row.data)[a.len] = prev; | ||
| 4125 | + } | ||
| 4126 | + return ((int*)row.data)[a.len]; | ||
| 4127 | +} | ||
| 4128 | +f32 strings__levenshtein_distance_percentage(string a, string b) { | ||
| 4129 | + int d = strings__levenshtein_distance(a, b); | ||
| 4130 | + int l = (a.len >= b.len ? (a.len) : (b.len)); | ||
| 4131 | + return (((f32)(1.00)) - ((f32)(d)) / ((f32)(l))) * ((f32)(100.00)); | ||
| 4132 | +} | ||
| 4133 | +f32 strings__dice_coefficient(string s1, string s2) { | ||
| 4134 | + if (s1.len == 0 || s2.len == 0) { | ||
| 4135 | + return 0.0; | ||
| 4136 | + } | ||
| 4137 | + if (builtin__string__eq(s1, s2)) { | ||
| 4138 | + return 1.0; | ||
| 4139 | + } | ||
| 4140 | + if (s1.len < 2 || s2.len < 2) { | ||
| 4141 | + return 0.0; | ||
| 4142 | + } | ||
| 4143 | + string a = (s1.len > s2.len ? (s1) : (s2)); | ||
| 4144 | + string b = (builtin__string__eq(a, s1) ? (s2) : (s1)); | ||
| 4145 | + Map_string_int first_bigrams = builtin__new_map(sizeof(string), sizeof(int), &builtin__map_hash_string, &builtin__map_eq_string, &builtin__map_clone_string, &builtin__map_free_string) | ||
| 4146 | + ; | ||
| 4147 | + for (int i = 0; i < a.len - 1; ++i) { | ||
| 4148 | + string bigram = builtin__string_substr(a, i, i + 2); | ||
| 4149 | + int q = (_IN_MAP(ADDR(string, bigram), ADDR(map, first_bigrams)) ? ((*(int*)builtin__map_get(ADDR(map, first_bigrams), &(string[]){bigram}, &(int[]){ 0 })) + 1) : (1)); | ||
| 4150 | + builtin__map_set(&first_bigrams, &(string[]){bigram}, &(int[]) { q }); | ||
| 4151 | + } | ||
| 4152 | + int intersection_size = 0; | ||
| 4153 | + for (int i = 0; i < b.len - 1; ++i) { | ||
| 4154 | + string bigram = builtin__string_substr(b, i, i + 2); | ||
| 4155 | + int count = (_IN_MAP(ADDR(string, bigram), ADDR(map, first_bigrams)) ? ((*(int*)builtin__map_get(ADDR(map, first_bigrams), &(string[]){bigram}, &(int[]){ 0 }))) : (0)); | ||
| 4156 | + if (count > 0) { | ||
| 4157 | + builtin__map_set(&first_bigrams, &(string[]){bigram}, &(int[]) { count - 1 }); | ||
| 4158 | + intersection_size++; | ||
| 4159 | + } | ||
| 4160 | + } | ||
| 4161 | + return (((f32)(2.0)) * ((f32)(intersection_size))) / (((f32)(a.len)) + ((f32)(b.len)) - 2); | ||
| 4162 | +} | ||
| 4163 | +int strings__hamming_distance(string a, string b) { | ||
| 4164 | + if (a.len == 0 && b.len == 0) { | ||
| 4165 | + return 0; | ||
| 4166 | + } | ||
| 4167 | + int match_len = strings__min2(a.len, b.len); | ||
| 4168 | + int diff_count = strings__abs2(a.len, b.len); | ||
| 4169 | + for (int i = 0; i < match_len; ++i) { | ||
| 4170 | + if (a.str[ i] != b.str[ i]) { | ||
| 4171 | + diff_count++; | ||
| 4172 | + } | ||
| 4173 | + } | ||
| 4174 | + return diff_count; | ||
| 4175 | +} | ||
| 4176 | +f32 strings__hamming_similarity(string a, string b) { | ||
| 4177 | + int l = strings__max2(a.len, b.len); | ||
| 4178 | + if (l == 0) { | ||
| 4179 | + return 1.0; | ||
| 4180 | + } | ||
| 4181 | + int d = strings__hamming_distance(a, b); | ||
| 4182 | + return ((f32)(1.00)) - ((f32)(d)) / ((f32)(l)); | ||
| 4183 | +} | ||
| 4184 | +f64 strings__jaro_similarity(string a, string b) { | ||
| 4185 | + int a_len = a.len; | ||
| 4186 | + int b_len = b.len; | ||
| 4187 | + if (a_len == 0 && b_len == 0) { | ||
| 4188 | + return 1.0; | ||
| 4189 | + } | ||
| 4190 | + if (a_len == 0 || b_len == 0) { | ||
| 4191 | + return 0; | ||
| 4192 | + } | ||
| 4193 | + int match_distance = strings__max2(VSAFE_DIV_int(strings__max2(a_len, b_len) , 2) - 1, 0); | ||
| 4194 | + Array_bool a_matches = builtin____new_array_with_default(a_len, 0, sizeof(bool), 0); | ||
| 4195 | + Array_bool b_matches = builtin____new_array_with_default(b_len, 0, sizeof(bool), 0); | ||
| 4196 | + int matches = 0; | ||
| 4197 | + f64 transpositions = 0.0; | ||
| 4198 | + for (int i = 0; i < a_len; ++i) { | ||
| 4199 | + int start = strings__max2(0, (int)(i - match_distance)); | ||
| 4200 | + int end = strings__min2(b_len, (int)(i + match_distance) + 1); | ||
| 4201 | + for (int k = start; k < end; ++k) { | ||
| 4202 | + if (((bool*)b_matches.data)[k]) { | ||
| 4203 | + continue; | ||
| 4204 | + } | ||
| 4205 | + if (a.str[ i] != b.str[ k]) { | ||
| 4206 | + continue; | ||
| 4207 | + } | ||
| 4208 | + ((bool*)a_matches.data)[i] = true; | ||
| 4209 | + ((bool*)b_matches.data)[k] = true; | ||
| 4210 | + matches++; | ||
| 4211 | + break; | ||
| 4212 | + } | ||
| 4213 | + } | ||
| 4214 | + if (matches == 0) { | ||
| 4215 | + return 0; | ||
| 4216 | + } | ||
| 4217 | + int k = 0; | ||
| 4218 | + for (int i = 0; i < a_len; ++i) { | ||
| 4219 | + if (!((bool*)a_matches.data)[i]) { | ||
| 4220 | + continue; | ||
| 4221 | + } | ||
| 4222 | + for (;;) { | ||
| 4223 | + if (!(!((bool*)b_matches.data)[k])) break; | ||
| 4224 | + k++; | ||
| 4225 | + } | ||
| 4226 | + if (a.str[ i] != b.str[ k]) { | ||
| 4227 | + transpositions++; | ||
| 4228 | + } | ||
| 4229 | + k++; | ||
| 4230 | + } | ||
| 4231 | + transpositions /= 2; | ||
| 4232 | + return ((f64)(matches / ((f64)(a_len))) + (f64)(matches / ((f64)(b_len))) + (f64)(((f64)(matches - transpositions)) / matches)) / 3; | ||
| 4233 | +} | ||
| 4234 | +f64 strings__jaro_winkler_similarity(string a, string b) { | ||
| 4235 | + int lmax = strings__min2(4, strings__min2(a.len, b.len)); | ||
| 4236 | + int l = 0; | ||
| 4237 | + for (int i = 0; i < lmax; ++i) { | ||
| 4238 | + if (a.str[ i] == b.str[ i]) { | ||
| 4239 | + l++; | ||
| 4240 | + } | ||
| 4241 | + } | ||
| 4242 | + f64 js = strings__jaro_similarity(a, b); | ||
| 4243 | + f64 p = 0.1; | ||
| 4244 | + f64 ws = js + ((f64)(l)) * p * (1 - js); | ||
| 4245 | + return ws; | ||
| 4246 | +} | ||
| 4247 | +string strings__repeat(u8 c, int n) { | ||
| 4248 | + if (n <= 0) { | ||
| 4249 | + return _S(""); | ||
| 4250 | + } | ||
| 4251 | + u8* bytes = builtin__malloc_noscan(n + 1); | ||
| 4252 | + { // Unsafe block | ||
| 4253 | + memset(bytes, c, n); | ||
| 4254 | + bytes[n] = 0; | ||
| 4255 | + } | ||
| 4256 | + return builtin__u8_vstring_with_len(bytes, n); | ||
| 4257 | +} | ||
| 4258 | +string strings__repeat_string(string s, int n) { | ||
| 4259 | + if (n <= 0 || s.len == 0) { | ||
| 4260 | + return _S(""); | ||
| 4261 | + } | ||
| 4262 | + int slen = s.len; | ||
| 4263 | + int blen = slen * n; | ||
| 4264 | + u8* bytes = builtin__malloc_noscan(blen + 1); | ||
| 4265 | + for (int bi = 0; bi < n; ++bi) { | ||
| 4266 | + int bislen = (int)(bi * slen); | ||
| 4267 | + for (int si = 0; si < slen; ++si) { | ||
| 4268 | + { // Unsafe block | ||
| 4269 | + bytes[(int)(bislen + si)] = s.str[ si]; | ||
| 4270 | + } | ||
| 4271 | + } | ||
| 4272 | + } | ||
| 4273 | + { // Unsafe block | ||
| 4274 | + bytes[blen] = 0; | ||
| 4275 | + } | ||
| 4276 | + return builtin__u8_vstring_with_len(bytes, blen); | ||
| 4277 | +} | ||
| 4278 | +string strings__find_between_pair_u8(string input, u8 start, u8 end) { | ||
| 4279 | + int marks = 0; | ||
| 4280 | + int start_index = -1; | ||
| 4281 | + for (int i = 0; i < input.len; ++i) { | ||
| 4282 | + u8 b = input.str[i]; | ||
| 4283 | + if (b == start) { | ||
| 4284 | + if (start_index == -1) { | ||
| 4285 | + start_index = i + 1; | ||
| 4286 | + } | ||
| 4287 | + marks++; | ||
| 4288 | + continue; | ||
| 4289 | + } | ||
| 4290 | + if (start_index > 0) { | ||
| 4291 | + if (b == end) { | ||
| 4292 | + marks--; | ||
| 4293 | + if (marks == 0) { | ||
| 4294 | + return builtin__string_substr(input, start_index, i); | ||
| 4295 | + } | ||
| 4296 | + } | ||
| 4297 | + } | ||
| 4298 | + } | ||
| 4299 | + return _S(""); | ||
| 4300 | +} | ||
| 4301 | +string strings__find_between_pair_rune(string input, rune start, rune end) { | ||
| 4302 | + int marks = 0; | ||
| 4303 | + int start_index = -1; | ||
| 4304 | + Array_rune runes = builtin__string_runes(input); | ||
| 4305 | + for (int i = 0; i < runes.len; ++i) { | ||
| 4306 | + rune r = ((rune*)runes.data)[i]; | ||
| 4307 | + if (r == start) { | ||
| 4308 | + if (start_index == -1) { | ||
| 4309 | + start_index = i + 1; | ||
| 4310 | + } | ||
| 4311 | + marks++; | ||
| 4312 | + continue; | ||
| 4313 | + } | ||
| 4314 | + if (start_index > 0) { | ||
| 4315 | + if (r == end) { | ||
| 4316 | + marks--; | ||
| 4317 | + if (marks == 0) { | ||
| 4318 | + return Array_rune_string(builtin__array_slice(runes, start_index, i)); | ||
| 4319 | + } | ||
| 4320 | + } | ||
| 4321 | + } | ||
| 4322 | + } | ||
| 4323 | + return _S(""); | ||
| 4324 | +} | ||
| 4325 | +string strings__find_between_pair_string(string input, string start, string end) { | ||
| 4326 | + int start_index = -1; | ||
| 4327 | + int marks = 0; | ||
| 4328 | + Array_rune start_runes = builtin__string_runes(start); | ||
| 4329 | + Array_rune end_runes = builtin__string_runes(end); | ||
| 4330 | + Array_rune runes = builtin__string_runes(input); | ||
| 4331 | + int i = 0; | ||
| 4332 | + for (; i < runes.len; i++) { | ||
| 4333 | + Array_rune start_slice = builtin__array_slice_ni(runes, i, i + start_runes.len); | ||
| 4334 | + if (Array_rune_arr_eq(start_slice, start_runes)) { | ||
| 4335 | + i = i + start_runes.len - 1; | ||
| 4336 | + if (start_index < 0) { | ||
| 4337 | + start_index = i + 1; | ||
| 4338 | + } | ||
| 4339 | + marks++; | ||
| 4340 | + continue; | ||
| 4341 | + } | ||
| 4342 | + if (start_index > 0) { | ||
| 4343 | + Array_rune end_slice = builtin__array_slice_ni(runes, i, i + end_runes.len); | ||
| 4344 | + if (Array_rune_arr_eq(end_slice, end_runes)) { | ||
| 4345 | + marks--; | ||
| 4346 | + if (marks == 0) { | ||
| 4347 | + return Array_rune_string(builtin__array_slice(runes, start_index, i)); | ||
| 4348 | + } | ||
| 4349 | + i = i + end_runes.len - 1; | ||
| 4350 | + continue; | ||
| 4351 | + } | ||
| 4352 | + } | ||
| 4353 | + } | ||
| 4354 | + return _S(""); | ||
| 4355 | +} | ||
| 4356 | +Array_string strings__split_capital(string s) { | ||
| 4357 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | ||
| 4358 | + int word_start = 0; | ||
| 4359 | + for (int idx = 0; idx < s.len; ++idx) { | ||
| 4360 | + u8 c = s.str[idx]; | ||
| 4361 | + if (builtin__u8_is_capital(c)) { | ||
| 4362 | + if (word_start != idx) { | ||
| 4363 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr_ni(s, word_start, idx) })); | ||
| 4364 | + } | ||
| 4365 | + word_start = idx; | ||
| 4366 | + continue; | ||
| 4367 | + } | ||
| 4368 | + } | ||
| 4369 | + if (word_start != s.len) { | ||
| 4370 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr_ni(s, word_start, 2147483647) })); | ||
| 4371 | + } | ||
| 4372 | + return res; | ||
| 4373 | +} | ||
| 4374 | +inline VV_LOC bool builtin__closure__is_ppc64(void) { | ||
| 4375 | + #if 0 | ||
| 4376 | + { | ||
| 4377 | + } | ||
| 4378 | + #else | ||
| 4379 | + { | ||
| 4380 | + return false; | ||
| 4381 | + } | ||
| 4382 | + #endif | ||
| 4383 | + return 0; | ||
| 4384 | +} | ||
| 4385 | +inline VV_LOC voidptr* builtin__closure__closure_slot_meta(voidptr exec_ptr) { | ||
| 4386 | + return ((voidptr*)(((u8*)(exec_ptr)) - _const_builtin__closure__assumed_page_size)); | ||
| 4387 | +} | ||
| 4388 | +VV_LOC void builtin__closure__closure_register_page(voidptr exec_page_start) { | ||
| 4389 | + { // Unsafe block | ||
| 4390 | + builtin__closure__ClosurePage* node = ((builtin__closure__ClosurePage*)(builtin___v_malloc(sizeof(builtin__closure__ClosurePage)))); | ||
| 4391 | + *node = ((builtin__closure__ClosurePage){.next = g_closure.pages,.exec_page_start = exec_page_start,}); | ||
| 4392 | + g_closure.pages = node; | ||
| 4393 | + } | ||
| 4394 | +} | ||
| 4395 | +VV_LOC bool builtin__closure__closure_is_managed(voidptr exec_ptr) { | ||
| 4396 | + if (builtin__isnil(exec_ptr)) { | ||
| 4397 | + return false; | ||
| 4398 | + } | ||
| 4399 | + usize exec_addr = ((usize)(exec_ptr)); | ||
| 4400 | + builtin__closure__ClosurePage* page = g_closure.pages; | ||
| 4401 | + for (;;) { | ||
| 4402 | + if (!(page != ((void*)0))) break; | ||
| 4403 | + usize page_addr = ((usize)(page->exec_page_start)); | ||
| 4404 | + if (exec_addr >= page_addr && exec_addr < page_addr + ((usize)(g_closure.v_page_size))) { | ||
| 4405 | + usize slot_offset = exec_addr - page_addr; | ||
| 4406 | + return slot_offset >= ((usize)(_const_builtin__closure__closure_size)) && VSAFE_MOD_usize(slot_offset , ((usize)(_const_builtin__closure__closure_size))) == 0; | ||
| 4407 | + } | ||
| 4408 | + page = page->next; | ||
| 4409 | + } | ||
| 4410 | + return false; | ||
| 4411 | +} | ||
| 4412 | +VV_LOC builtin__closure__ClosureLiveInfo builtin__closure__closure_live_delete(voidptr exec_ptr) { | ||
| 4413 | + builtin__closure__ClosureLiveInfo* _t2 = (builtin__closure__ClosureLiveInfo*)(builtin__map_get_check(ADDR(map, g_closure.live), &(voidptr[]){exec_ptr})); | ||
| 4414 | + _option_builtin__closure__ClosureLiveInfo _t1 = {0}; | ||
| 4415 | + if (_t2) { | ||
| 4416 | + *((builtin__closure__ClosureLiveInfo*)&_t1.data) = *((builtin__closure__ClosureLiveInfo*)_t2); | ||
| 4417 | + } else { | ||
| 4418 | + _t1.state = 2; _t1.err = builtin___v_error(_S("map key does not exist")); | ||
| 4419 | + } | ||
| 4420 | + | ||
| 4421 | + if (_t1.state == 0) { | ||
| 4422 | + builtin__closure__ClosureLiveInfo info = (*(builtin__closure__ClosureLiveInfo*)_t1.data); | ||
| 4423 | + (*(builtin__closure__ClosureLiveInfo*)builtin__map_get_and_set((map*)&g_closure.live, &(voidptr[]){exec_ptr}, &(builtin__closure__ClosureLiveInfo[]){ (builtin__closure__ClosureLiveInfo){.ctx = 0,.owns_data = 0,.generation = 0,} })) = ((builtin__closure__ClosureLiveInfo){.ctx = 0,.owns_data = 0,.generation = 0,}); | ||
| 4424 | + builtin__map_delete(&g_closure.live, &(voidptr[]){exec_ptr}); | ||
| 4425 | + return info; | ||
| 4426 | + } | ||
| 4427 | + if (_t1.state == 2 && _t1.err._object != _const_none__._object) { builtin___v_free(_t1.err._object); } | ||
| 4428 | + return ((builtin__closure__ClosureLiveInfo){.ctx = 0,.owns_data = 0,.generation = 0,}); | ||
| 4429 | +} | ||
| 4430 | +VV_LOC builtin__closure__ClosureLifetimeState* builtin__closure__new_closure_lifetime_state_no_lock(void) { | ||
| 4431 | + builtin__closure__ClosureLifetimeState* state = g_closure.free_lifetime_states; | ||
| 4432 | + if (!builtin__isnil(state)) { | ||
| 4433 | + g_closure.free_lifetime_states = state->next_free; | ||
| 4434 | + } else { | ||
| 4435 | + { // Unsafe block | ||
| 4436 | + state = ((builtin__closure__ClosureLifetimeState*)(builtin___v_malloc(sizeof(builtin__closure__ClosureLifetimeState)))); | ||
| 4437 | + } | ||
| 4438 | + g_closure.lifetime_state_allocs++; | ||
| 4439 | + } | ||
| 4440 | + g_closure.next_lifetime_generation++; | ||
| 4441 | + { // Unsafe block | ||
| 4442 | + *state = ((builtin__closure__ClosureLifetimeState){.owner_thread = builtin__closure__closure_current_thread_id_platform(),.active = 0,.disposed = 0,.suspended = 0,.frame_start = 0,.frame_gen = 0,.generation = g_closure.next_lifetime_generation,.frame_generation = 0,.records = builtin____new_array(0, 0, sizeof(builtin__closure__ClosureLifetimeRecord)),.frames = builtin____new_array(0, 0, sizeof(builtin__closure__ClosureLifetimeFrame)),.next_free = ((void*)0),}); | ||
| 4443 | + } | ||
| 4444 | + return state; | ||
| 4445 | +} | ||
| 4446 | +VV_LOC builtin__closure__ClosureLifetimeState* builtin__closure__new_closure_lifetime_state(void) { | ||
| 4447 | + builtin__closure__closure_mtx_lock_platform(); | ||
| 4448 | + builtin__closure__ClosureLifetimeState* state = builtin__closure__new_closure_lifetime_state_no_lock(); | ||
| 4449 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4450 | + return state; | ||
| 4451 | +} | ||
| 4452 | +VV_LOC void builtin__closure__closure_lifetime_recycle_state_no_lock(builtin__closure__ClosureLifetimeState** state) { | ||
| 4453 | + (*state)->disposed = true; | ||
| 4454 | + (*state)->active = false; | ||
| 4455 | + (*state)->suspended = 0; | ||
| 4456 | + (*state)->frame_start = 0; | ||
| 4457 | + (*state)->frame_gen = 0; | ||
| 4458 | + (*state)->frame_generation = 0; | ||
| 4459 | + { // Unsafe block | ||
| 4460 | + builtin__array_free(&(*state)->records); | ||
| 4461 | + builtin__array_free(&(*state)->frames); | ||
| 4462 | + } | ||
| 4463 | + (*state)->records = builtin____new_array_with_default(0, 0, sizeof(builtin__closure__ClosureLifetimeRecord), 0); | ||
| 4464 | + (*state)->frames = builtin____new_array_with_default(0, 0, sizeof(builtin__closure__ClosureLifetimeFrame), 0); | ||
| 4465 | + (*state)->next_free = g_closure.free_lifetime_states; | ||
| 4466 | + g_closure.free_lifetime_states = *state; | ||
| 4467 | +} | ||
| 4468 | +VV_LOC string builtin__closure__closure_lifetime_error(builtin__closure__ClosureLifetimeState* state, u64 generation, u64 thread_id) { | ||
| 4469 | + if (state->disposed || state->generation != generation) { | ||
| 4470 | + return _S("closure lifetime used after dispose"); | ||
| 4471 | + } | ||
| 4472 | + if (state->owner_thread != thread_id) { | ||
| 4473 | + return _S("closure lifetime used from a different thread"); | ||
| 4474 | + } | ||
| 4475 | + return _S(""); | ||
| 4476 | +} | ||
| 4477 | +VV_LOC _result_builtin__closure__ClosureLifetimeState_ptr builtin__closure__Lifetime_ensure_state(builtin__closure__Lifetime* lifetime) { | ||
| 4478 | + builtin__closure__closure_ensure_initialized(); | ||
| 4479 | + if (builtin__isnil(lifetime->state)) { | ||
| 4480 | + if (lifetime->disposed) { | ||
| 4481 | + return (_result_builtin__closure__ClosureLifetimeState_ptr){ .is_error=true, .err=builtin___v_error(_S("closure lifetime used after dispose")), .data={E_STRUCT} }; | ||
| 4482 | + } | ||
| 4483 | + lifetime->state = builtin__closure__new_closure_lifetime_state(); | ||
| 4484 | + lifetime->generation = lifetime->state->generation; | ||
| 4485 | + _result_builtin__closure__ClosureLifetimeState_ptr _t2; | ||
| 4486 | + builtin___result_ok(&(builtin__closure__ClosureLifetimeState*[]) { lifetime->state }, (_result*)(&_t2), sizeof(builtin__closure__ClosureLifetimeState*)); | ||
| 4487 | + | ||
| 4488 | + return _t2; | ||
| 4489 | + } | ||
| 4490 | + builtin__closure__closure_mtx_lock_platform(); | ||
| 4491 | + builtin__closure__ClosureLifetimeState* state = lifetime->state; | ||
| 4492 | + if (lifetime->disposed || state->disposed || state->generation != lifetime->generation) { | ||
| 4493 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4494 | + return (_result_builtin__closure__ClosureLifetimeState_ptr){ .is_error=true, .err=builtin___v_error(_S("closure lifetime used after dispose")), .data={E_STRUCT} }; | ||
| 4495 | + } | ||
| 4496 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4497 | + _result_builtin__closure__ClosureLifetimeState_ptr _t4; | ||
| 4498 | + builtin___result_ok(&(builtin__closure__ClosureLifetimeState*[]) { state }, (_result*)(&_t4), sizeof(builtin__closure__ClosureLifetimeState*)); | ||
| 4499 | + | ||
| 4500 | + return _t4; | ||
| 4501 | +} | ||
| 4502 | +VV_LOC voidptr builtin__closure__closure_slot_data(voidptr exec_ptr) { | ||
| 4503 | + { // Unsafe block | ||
| 4504 | + voidptr* p = builtin__closure__closure_slot_meta(exec_ptr); | ||
| 4505 | + if (builtin__closure__is_ppc64()) { | ||
| 4506 | + return p[2]; | ||
| 4507 | + } | ||
| 4508 | + return p[0]; | ||
| 4509 | + } | ||
| 4510 | + return 0; | ||
| 4511 | +} | ||
| 4512 | +VV_LOC bool builtin__closure__closure_release_no_lock(voidptr exec_ptr, u64 generation) { | ||
| 4513 | + if (!builtin__closure__closure_is_managed(exec_ptr)) { | ||
| 4514 | + return false; | ||
| 4515 | + } | ||
| 4516 | + builtin__closure__ClosureLiveInfo* _t3 = (builtin__closure__ClosureLiveInfo*)(builtin__map_get_check(ADDR(map, g_closure.live), &(voidptr[]){exec_ptr})); | ||
| 4517 | + _option_builtin__closure__ClosureLiveInfo _t2 = {0}; | ||
| 4518 | + if (_t3) { | ||
| 4519 | + *((builtin__closure__ClosureLiveInfo*)&_t2.data) = *((builtin__closure__ClosureLiveInfo*)_t3); | ||
| 4520 | + } else { | ||
| 4521 | + _t2.state = 2; _t2.err = builtin___v_error(_S("map key does not exist")); | ||
| 4522 | + } | ||
| 4523 | + ; | ||
| 4524 | + if (_t2.state != 0) { | ||
| 4525 | + return false; | ||
| 4526 | + } | ||
| 4527 | + | ||
| 4528 | + builtin__closure__ClosureLiveInfo info = (*(builtin__closure__ClosureLiveInfo*)_t2.data); | ||
| 4529 | + if (generation != 0 && info.generation != generation) { | ||
| 4530 | + return false; | ||
| 4531 | + } | ||
| 4532 | + voidptr data = builtin__closure__closure_slot_data(exec_ptr); | ||
| 4533 | + builtin__closure__closure_live_delete(exec_ptr); | ||
| 4534 | + if (info.owns_data && !builtin__isnil(data)) { | ||
| 4535 | + builtin___v_free(data); | ||
| 4536 | + } | ||
| 4537 | + { // Unsafe block | ||
| 4538 | + voidptr* p = builtin__closure__closure_slot_meta(exec_ptr); | ||
| 4539 | + p[0] = g_closure.free_closure_ptr; | ||
| 4540 | + if (builtin__closure__is_ppc64()) { | ||
| 4541 | + p[1] = ((void*)0); | ||
| 4542 | + p[2] = ((void*)0); | ||
| 4543 | + p[3] = ((void*)0); | ||
| 4544 | + } else { | ||
| 4545 | + p[1] = ((void*)0); | ||
| 4546 | + } | ||
| 4547 | + g_closure.free_closure_ptr = exec_ptr; | ||
| 4548 | + } | ||
| 4549 | + return true; | ||
| 4550 | +} | ||
| 4551 | +VV_LOC void builtin__closure__closure_lifetime_release_records_no_lock(Array_builtin__closure__ClosureLifetimeRecord records, int start, int end) { | ||
| 4552 | + for (int i = start; i < end; ++i) { | ||
| 4553 | + builtin__closure__ClosureLifetimeRecord record = (*(builtin__closure__ClosureLifetimeRecord*)builtin__array_get(records, i)); | ||
| 4554 | + builtin__closure__closure_release_no_lock(record.exec_ptr, record.generation); | ||
| 4555 | + } | ||
| 4556 | +} | ||
| 4557 | +VV_LOC void builtin__closure__closure_lifetime_reclaim_no_lock(builtin__closure__ClosureLifetimeState* state, int retain) { | ||
| 4558 | + int keep = (retain < 0 ? (0) : (retain)); | ||
| 4559 | + if (state->frames.len <= keep) { | ||
| 4560 | + return; | ||
| 4561 | + } | ||
| 4562 | + int reclaim_count = state->frames.len - keep; | ||
| 4563 | + int cutoff = 0; | ||
| 4564 | + for (int i = 0; i < reclaim_count; ++i) { | ||
| 4565 | + builtin__closure__ClosureLifetimeFrame frame = (*(builtin__closure__ClosureLifetimeFrame*)builtin__array_get(state->frames, i)); | ||
| 4566 | + builtin__closure__closure_lifetime_release_records_no_lock(state->records, frame.start, frame.end); | ||
| 4567 | + cutoff = frame.end; | ||
| 4568 | + } | ||
| 4569 | + builtin__array_delete_many(&state->frames, 0, reclaim_count); | ||
| 4570 | + if (cutoff > 0) { | ||
| 4571 | + builtin__array_delete_many(&state->records, 0, cutoff); | ||
| 4572 | + for (int _t1 = 0; _t1 < state->frames.len; ++_t1) { | ||
| 4573 | + builtin__closure__ClosureLifetimeFrame* frame = ((builtin__closure__ClosureLifetimeFrame*)state->frames.data) + _t1; | ||
| 4574 | + frame->start -= cutoff; | ||
| 4575 | + frame->end -= cutoff; | ||
| 4576 | + } | ||
| 4577 | + } | ||
| 4578 | +} | ||
| 4579 | +VV_LOC void builtin__closure__closure_ensure_initialized(void) { | ||
| 4580 | + builtin__closure__closure_init_once_platform(); | ||
| 4581 | +} | ||
| 4582 | +builtin__closure__Lifetime builtin__closure__new_lifetime(void) { | ||
| 4583 | + builtin__closure__closure_ensure_initialized(); | ||
| 4584 | + builtin__closure__ClosureLifetimeState* state = builtin__closure__new_closure_lifetime_state(); | ||
| 4585 | + return ((builtin__closure__Lifetime){.state = state,.generation = state->generation,.disposed = 0,}); | ||
| 4586 | +} | ||
| 4587 | +VV_LOC _result_builtin__closure__FrameToken builtin__closure__Lifetime_begin_frame(builtin__closure__Lifetime* lifetime) { | ||
| 4588 | + _result_builtin__closure__ClosureLifetimeState_ptr _t1 = builtin__closure__Lifetime_ensure_state(lifetime); | ||
| 4589 | + if (_t1.is_error) { | ||
| 4590 | + _result_builtin__closure__FrameToken _t2 = {0}; | ||
| 4591 | + _t2.is_error = true; | ||
| 4592 | + _t2.err = _t1.err; | ||
| 4593 | + return _t2; | ||
| 4594 | + } | ||
| 4595 | + | ||
| 4596 | + builtin__closure__ClosureLifetimeState* state = (*(builtin__closure__ClosureLifetimeState**)_t1.data); | ||
| 4597 | + u64 thread_id = builtin__closure__closure_current_thread_id_platform(); | ||
| 4598 | + builtin__closure__closure_mtx_lock_platform(); | ||
| 4599 | + string err = builtin__closure__closure_lifetime_error(state, lifetime->generation, thread_id); | ||
| 4600 | + if ((err).len != 0) { | ||
| 4601 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4602 | + return (_result_builtin__closure__FrameToken){ .is_error=true, .err=builtin___v_error(err), .data={E_STRUCT} }; | ||
| 4603 | + } | ||
| 4604 | + if (state->active) { | ||
| 4605 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4606 | + return (_result_builtin__closure__FrameToken){ .is_error=true, .err=builtin___v_error(_S("closure lifetime frames can not be nested")), .data={E_STRUCT} }; | ||
| 4607 | + } | ||
| 4608 | + if (state->suspended > 0) { | ||
| 4609 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4610 | + return (_result_builtin__closure__FrameToken){ .is_error=true, .err=builtin___v_error(_S("closure lifetime frame while suspended")), .data={E_STRUCT} }; | ||
| 4611 | + } | ||
| 4612 | + builtin__closure__ClosureLifetimeState** _t7 = (builtin__closure__ClosureLifetimeState**)(builtin__map_get_check(ADDR(map, g_closure.active_lifetimes), &(u64[]){thread_id})); | ||
| 4613 | + _option_builtin__closure__ClosureLifetimeState_ptr _t6 = {0}; | ||
| 4614 | + if (_t7) { | ||
| 4615 | + *((builtin__closure__ClosureLifetimeState**)&_t6.data) = *((builtin__closure__ClosureLifetimeState**)_t7); | ||
| 4616 | + } else { | ||
| 4617 | + _t6.state = 2; _t6.err = builtin___v_error(_S("map key does not exist")); | ||
| 4618 | + } | ||
| 4619 | + | ||
| 4620 | + if (_t6.state == 0) { | ||
| 4621 | + builtin__closure__ClosureLifetimeState* _dummy_6 = (*(builtin__closure__ClosureLifetimeState**)_t6.data); | ||
| 4622 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4623 | + return (_result_builtin__closure__FrameToken){ .is_error=true, .err=builtin___v_error(_S("another closure lifetime is already active on this thread")), .data={E_STRUCT} }; | ||
| 4624 | + } | ||
| 4625 | + if (_t6.state == 2 && _t6.err._object != _const_none__._object) { builtin___v_free(_t6.err._object); } | ||
| 4626 | + state->frame_generation++; | ||
| 4627 | + state->active = true; | ||
| 4628 | + state->frame_start = state->records.len; | ||
| 4629 | + state->frame_gen = state->frame_generation; | ||
| 4630 | + (*(builtin__closure__ClosureLifetimeState**)builtin__map_get_and_set((map*)&g_closure.active_lifetimes, &(u64[]){thread_id}, &(builtin__closure__ClosureLifetimeState*[]){ 0 })) = state; | ||
| 4631 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4632 | + _result_builtin__closure__FrameToken _t9; | ||
| 4633 | + builtin___result_ok(&(builtin__closure__FrameToken[]) { ((builtin__closure__FrameToken){.state = state,.thread_id = thread_id,.state_generation = lifetime->generation,.generation = state->frame_generation,}) }, (_result*)(&_t9), sizeof(builtin__closure__FrameToken)); | ||
| 4634 | + | ||
| 4635 | + return _t9; | ||
| 4636 | +} | ||
| 4637 | +VV_LOC _result_void builtin__closure__Lifetime_end_frame(builtin__closure__Lifetime* lifetime, builtin__closure__FrameToken token) { | ||
| 4638 | + if (builtin__isnil(token.state)) { | ||
| 4639 | + return (_result_void){ .is_error=true, .err=builtin___v_error(_S("invalid closure lifetime frame token")), .data={E_STRUCT} }; | ||
| 4640 | + } | ||
| 4641 | + builtin__closure__ClosureLifetimeState* state = token.state; | ||
| 4642 | + u64 thread_id = builtin__closure__closure_current_thread_id_platform(); | ||
| 4643 | + builtin__closure__closure_mtx_lock_platform(); | ||
| 4644 | + string err = builtin__closure__closure_lifetime_error(state, token.state_generation, thread_id); | ||
| 4645 | + if ((err).len != 0) { | ||
| 4646 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4647 | + return (_result_void){ .is_error=true, .err=builtin___v_error(err), .data={E_STRUCT} }; | ||
| 4648 | + } | ||
| 4649 | + if (token.thread_id != thread_id || token.generation != state->frame_gen || !state->active) { | ||
| 4650 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4651 | + return (_result_void){ .is_error=true, .err=builtin___v_error(_S("invalid closure lifetime frame token")), .data={E_STRUCT} }; | ||
| 4652 | + } | ||
| 4653 | + builtin__array_push((array*)&state->frames, _MOV((builtin__closure__ClosureLifetimeFrame[]){ ((builtin__closure__ClosureLifetimeFrame){.start = state->frame_start,.end = state->records.len,}) })); | ||
| 4654 | + state->active = false; | ||
| 4655 | + state->frame_start = 0; | ||
| 4656 | + state->frame_gen = 0; | ||
| 4657 | + (*(builtin__closure__ClosureLifetimeState**)builtin__map_get_and_set((map*)&g_closure.active_lifetimes, &(u64[]){thread_id}, &(builtin__closure__ClosureLifetimeState*[]){ 0 })) = ((void*)0); | ||
| 4658 | + builtin__map_delete(&g_closure.active_lifetimes, &(u64[]){thread_id}); | ||
| 4659 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4660 | + return (_result_void){0}; | ||
| 4661 | +} | ||
| 4662 | +_result_void builtin__closure__Lifetime_frame(builtin__closure__Lifetime* lifetime, void (*work)(void)) { | ||
| 4663 | + _result_builtin__closure__FrameToken _t1 = builtin__closure__Lifetime_begin_frame(lifetime); | ||
| 4664 | + if (_t1.is_error) { | ||
| 4665 | + _result_void _t2 = {0}; | ||
| 4666 | + _t2.is_error = true; | ||
| 4667 | + _t2.err = _t1.err; | ||
| 4668 | + return _t2; | ||
| 4669 | + } | ||
| 4670 | + | ||
| 4671 | + builtin__closure__FrameToken token = (*(builtin__closure__FrameToken*)_t1.data); | ||
| 4672 | + bool ended = false; | ||
| 4673 | + work(); | ||
| 4674 | + _result_void _t3 = builtin__closure__Lifetime_end_frame(lifetime, token); | ||
| 4675 | + if (_t3.is_error) { | ||
| 4676 | + { // defer begin | ||
| 4677 | + if (!ended) { | ||
| 4678 | + _result_void _t4 = builtin__closure__Lifetime_end_frame(lifetime, token); | ||
| 4679 | + (void)_t4; | ||
| 4680 | + ; | ||
| 4681 | + } | ||
| 4682 | + } // defer end | ||
| 4683 | + _result_void _t5 = {0}; | ||
| 4684 | + _t5.is_error = true; | ||
| 4685 | + _t5.err = _t3.err; | ||
| 4686 | + return _t5; | ||
| 4687 | + } | ||
| 4688 | + | ||
| 4689 | + ; | ||
| 4690 | + ended = true; | ||
| 4691 | + { // defer begin | ||
| 4692 | + if (!ended) { | ||
| 4693 | + _result_void _t6 = builtin__closure__Lifetime_end_frame(lifetime, token); | ||
| 4694 | + (void)_t6; | ||
| 4695 | + ; | ||
| 4696 | + } | ||
| 4697 | + } // defer end | ||
| 4698 | + return (_result_void){0}; | ||
| 4699 | +} | ||
| 4700 | +_result_void builtin__closure__Lifetime_reclaim(builtin__closure__Lifetime* lifetime, int retain) { | ||
| 4701 | + _result_builtin__closure__ClosureLifetimeState_ptr _t1 = builtin__closure__Lifetime_ensure_state(lifetime); | ||
| 4702 | + if (_t1.is_error) { | ||
| 4703 | + _result_void _t2 = {0}; | ||
| 4704 | + _t2.is_error = true; | ||
| 4705 | + _t2.err = _t1.err; | ||
| 4706 | + return _t2; | ||
| 4707 | + } | ||
| 4708 | + | ||
| 4709 | + builtin__closure__ClosureLifetimeState* state = (*(builtin__closure__ClosureLifetimeState**)_t1.data); | ||
| 4710 | + u64 thread_id = builtin__closure__closure_current_thread_id_platform(); | ||
| 4711 | + builtin__closure__closure_mtx_lock_platform(); | ||
| 4712 | + string err = builtin__closure__closure_lifetime_error(state, lifetime->generation, thread_id); | ||
| 4713 | + if ((err).len != 0) { | ||
| 4714 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4715 | + return (_result_void){ .is_error=true, .err=builtin___v_error(err), .data={E_STRUCT} }; | ||
| 4716 | + } | ||
| 4717 | + if (state->active) { | ||
| 4718 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4719 | + return (_result_void){ .is_error=true, .err=builtin___v_error(_S("closure lifetime reclaim while a frame is active")), .data={E_STRUCT} }; | ||
| 4720 | + } | ||
| 4721 | + builtin__closure__closure_lifetime_reclaim_no_lock(state, retain); | ||
| 4722 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4723 | + return (_result_void){0}; | ||
| 4724 | +} | ||
| 4725 | +_result_void builtin__closure__Lifetime_reclaim_all(builtin__closure__Lifetime* lifetime) { | ||
| 4726 | + _result_void _t1 = builtin__closure__Lifetime_reclaim(lifetime, 0); | ||
| 4727 | + if (_t1.is_error) { | ||
| 4728 | + _result_void _t2 = {0}; | ||
| 4729 | + _t2.is_error = true; | ||
| 4730 | + _t2.err = _t1.err; | ||
| 4731 | + return _t2; | ||
| 4732 | + } | ||
| 4733 | + | ||
| 4734 | + ; | ||
| 4735 | + return (_result_void){0}; | ||
| 4736 | +} | ||
| 4737 | +_result_void builtin__closure__Lifetime_dispose(builtin__closure__Lifetime* lifetime) { | ||
| 4738 | + _result_builtin__closure__ClosureLifetimeState_ptr _t1 = builtin__closure__Lifetime_ensure_state(lifetime); | ||
| 4739 | + if (_t1.is_error) { | ||
| 4740 | + _result_void _t2 = {0}; | ||
| 4741 | + _t2.is_error = true; | ||
| 4742 | + _t2.err = _t1.err; | ||
| 4743 | + return _t2; | ||
| 4744 | + } | ||
| 4745 | + | ||
| 4746 | + builtin__closure__ClosureLifetimeState* state = (*(builtin__closure__ClosureLifetimeState**)_t1.data); | ||
| 4747 | + u64 thread_id = builtin__closure__closure_current_thread_id_platform(); | ||
| 4748 | + builtin__closure__closure_mtx_lock_platform(); | ||
| 4749 | + string err = builtin__closure__closure_lifetime_error(state, lifetime->generation, thread_id); | ||
| 4750 | + if ((err).len != 0) { | ||
| 4751 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4752 | + return (_result_void){ .is_error=true, .err=builtin___v_error(err), .data={E_STRUCT} }; | ||
| 4753 | + } | ||
| 4754 | + if (state->active) { | ||
| 4755 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4756 | + return (_result_void){ .is_error=true, .err=builtin___v_error(_S("closure lifetime dispose while a frame is active")), .data={E_STRUCT} }; | ||
| 4757 | + } | ||
| 4758 | + if (state->suspended > 0) { | ||
| 4759 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4760 | + return (_result_void){ .is_error=true, .err=builtin___v_error(_S("closure lifetime dispose while suspended")), .data={E_STRUCT} }; | ||
| 4761 | + } | ||
| 4762 | + builtin__closure__closure_lifetime_reclaim_no_lock(state, 0); | ||
| 4763 | + lifetime->state = ((void*)0); | ||
| 4764 | + lifetime->disposed = true; | ||
| 4765 | + builtin__closure__closure_lifetime_recycle_state_no_lock(&state); | ||
| 4766 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4767 | + return (_result_void){0}; | ||
| 4768 | +} | ||
| 4769 | +_result_void builtin__closure__Lifetime_suspend(builtin__closure__Lifetime* lifetime, void (*work)(void)) { | ||
| 4770 | + _result_builtin__closure__ClosureLifetimeState_ptr _t1 = builtin__closure__Lifetime_ensure_state(lifetime); | ||
| 4771 | + if (_t1.is_error) { | ||
| 4772 | + _result_void _t2 = {0}; | ||
| 4773 | + _t2.is_error = true; | ||
| 4774 | + _t2.err = _t1.err; | ||
| 4775 | + return _t2; | ||
| 4776 | + } | ||
| 4777 | + | ||
| 4778 | + builtin__closure__ClosureLifetimeState* state = (*(builtin__closure__ClosureLifetimeState**)_t1.data); | ||
| 4779 | + u64 thread_id = builtin__closure__closure_current_thread_id_platform(); | ||
| 4780 | + builtin__closure__closure_mtx_lock_platform(); | ||
| 4781 | + string err = builtin__closure__closure_lifetime_error(state, lifetime->generation, thread_id); | ||
| 4782 | + if ((err).len != 0) { | ||
| 4783 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4784 | + return (_result_void){ .is_error=true, .err=builtin___v_error(err), .data={E_STRUCT} }; | ||
| 4785 | + } | ||
| 4786 | + builtin__closure__ClosureLifetimeState** _t5 = (builtin__closure__ClosureLifetimeState**)(builtin__map_get_check(ADDR(map, g_closure.active_lifetimes), &(u64[]){thread_id})); | ||
| 4787 | + _option_builtin__closure__ClosureLifetimeState_ptr _t4 = {0}; | ||
| 4788 | + if (_t5) { | ||
| 4789 | + *((builtin__closure__ClosureLifetimeState**)&_t4.data) = *((builtin__closure__ClosureLifetimeState**)_t5); | ||
| 4790 | + } else { | ||
| 4791 | + _t4.state = 2; _t4.err = builtin___v_error(_S("map key does not exist")); | ||
| 4792 | + } | ||
| 4793 | + | ||
| 4794 | + if (_t4.state == 0) { | ||
| 4795 | + builtin__closure__ClosureLifetimeState* active = (*(builtin__closure__ClosureLifetimeState**)_t4.data); | ||
| 4796 | + if (!(active == state || (active != 0 && state != 0 && builtin__closure__ClosureLifetimeState_struct_eq(*active, *state)))) { | ||
| 4797 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4798 | + return (_result_void){ .is_error=true, .err=builtin___v_error(_S("another closure lifetime is already active on this thread")), .data={E_STRUCT} }; | ||
| 4799 | + } | ||
| 4800 | + } | ||
| 4801 | + if (_t4.state == 2 && _t4.err._object != _const_none__._object) { builtin___v_free(_t4.err._object); } | ||
| 4802 | + state->suspended++; | ||
| 4803 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4804 | + work(); | ||
| 4805 | + { // defer begin | ||
| 4806 | + builtin__closure__closure_mtx_lock_platform(); | ||
| 4807 | + state->suspended--; | ||
| 4808 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4809 | + } // defer end | ||
| 4810 | + return (_result_void){0}; | ||
| 4811 | +} | ||
| 4812 | +_result_void builtin__closure__Lifetime_untracked(builtin__closure__Lifetime* lifetime, void (*work)(void)) { | ||
| 4813 | + _result_void _t1 = builtin__closure__Lifetime_suspend(lifetime, work); | ||
| 4814 | + if (_t1.is_error) { | ||
| 4815 | + _result_void _t2 = {0}; | ||
| 4816 | + _t2.is_error = true; | ||
| 4817 | + _t2.err = _t1.err; | ||
| 4818 | + return _t2; | ||
| 4819 | + } | ||
| 4820 | + | ||
| 4821 | + ; | ||
| 4822 | + return (_result_void){0}; | ||
| 4823 | +} | ||
| 4824 | +VV_LOC void builtin__closure__closure_alloc(void) { | ||
| 4825 | + u8* p = builtin__closure__closure_alloc_platform(); | ||
| 4826 | + if (builtin__isnil(p)) { | ||
| 4827 | + return; | ||
| 4828 | + } | ||
| 4829 | + u8* x = p + g_closure.v_page_size; | ||
| 4830 | + int remaining = VSAFE_DIV_int(g_closure.v_page_size , _const_builtin__closure__closure_size); | ||
| 4831 | + builtin__closure__closure_register_page(x); | ||
| 4832 | + g_closure.closure_ptr = x; | ||
| 4833 | + g_closure.closure_cap = remaining; | ||
| 4834 | + for (;;) { | ||
| 4835 | + if (!(remaining > 0)) break; | ||
| 4836 | + builtin__vmemcpy(x, &_const_builtin__closure__closure_thunk[0], 15); | ||
| 4837 | + remaining--; | ||
| 4838 | + { // Unsafe block | ||
| 4839 | + x += _const_builtin__closure__closure_size; | ||
| 4840 | + } | ||
| 4841 | + } | ||
| 4842 | + builtin__closure__closure_memory_protect_platform(g_closure.closure_ptr, g_closure.v_page_size, builtin__closure__MemoryProtectAtrr__read_exec); | ||
| 4843 | +} | ||
| 4844 | +VV_LOC void builtin__closure__closure_init_body(void) { | ||
| 4845 | + int page_size = builtin__closure__get_page_size_platform(); | ||
| 4846 | + g_closure.v_page_size = page_size; | ||
| 4847 | + g_closure.live = builtin__new_map(sizeof(voidptr), sizeof(builtin__closure__ClosureLiveInfo), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop) | ||
| 4848 | + ; | ||
| 4849 | + g_closure.active_lifetimes = builtin__new_map(sizeof(u64), sizeof(builtin__closure__ClosureLifetimeState*), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop) | ||
| 4850 | + ; | ||
| 4851 | + g_closure.next_generation = 0; | ||
| 4852 | + g_closure.free_lifetime_states = ((void*)0); | ||
| 4853 | + g_closure.next_lifetime_generation = 0; | ||
| 4854 | + g_closure.lifetime_state_allocs = 0; | ||
| 4855 | + builtin__closure__closure_mtx_lock_init_platform(); | ||
| 4856 | + builtin__closure__closure_alloc(); | ||
| 4857 | + { // Unsafe block | ||
| 4858 | + builtin__closure__closure_memory_protect_platform(g_closure.closure_ptr, page_size, builtin__closure__MemoryProtectAtrr__read_write); | ||
| 4859 | + builtin__vmemcpy(g_closure.closure_ptr, &_const_builtin__closure__closure_get_data_bytes[0], 6); | ||
| 4860 | + builtin__closure__closure_memory_protect_platform(g_closure.closure_ptr, page_size, builtin__closure__MemoryProtectAtrr__read_exec); | ||
| 4861 | + } | ||
| 4862 | + if (builtin__closure__is_ppc64()) { | ||
| 4863 | + voidptr* desc = ((voidptr*)(((u8*)(g_closure.closure_ptr)) - _const_builtin__closure__assumed_page_size)); | ||
| 4864 | + { // Unsafe block | ||
| 4865 | + desc[0] = g_closure.closure_ptr; | ||
| 4866 | + desc[1] = ((void*)0); | ||
| 4867 | + } | ||
| 4868 | + g_closure.closure_get_data = ((builtin__closure__ClosureGetDataFn)(desc)); | ||
| 4869 | + } else { | ||
| 4870 | + g_closure.closure_get_data = g_closure.closure_ptr; | ||
| 4871 | + } | ||
| 4872 | + { // Unsafe block | ||
| 4873 | + g_closure.closure_ptr = ((u8*)(g_closure.closure_ptr)) + _const_builtin__closure__closure_size; | ||
| 4874 | + } | ||
| 4875 | + g_closure.closure_cap--; | ||
| 4876 | +} | ||
| 4877 | +#if 1 | ||
| 4878 | +#endif | ||
| 4879 | +inline VV_LOC voidptr builtin__closure__closure_mtx_ptr_platform(void) { | ||
| 4880 | + return ((voidptr)(&g_closure.ClosureMutex.closure_mtx[0])); | ||
| 4881 | +} | ||
| 4882 | +inline VV_LOC u8* builtin__closure__closure_alloc_platform(void) { | ||
| 4883 | + u8* p = ((u8*)(((void*)0))); | ||
| 4884 | + #if 0 | ||
| 4885 | + { | ||
| 4886 | + } | ||
| 4887 | + #else | ||
| 4888 | + { | ||
| 4889 | + p = mmap(0, g_closure.v_page_size * 2, (PROT_READ | PROT_WRITE), (MAP_ANONYMOUS | MAP_PRIVATE), -1, 0); | ||
| 4890 | + if (p == ((u8*)(MAP_FAILED))) { | ||
| 4891 | + return ((void*)0); | ||
| 4892 | + } | ||
| 4893 | + } | ||
| 4894 | + #endif | ||
| 4895 | + return p; | ||
| 4896 | +} | ||
| 4897 | +inline VV_LOC void builtin__closure__closure_memory_protect_platform(voidptr ptr, isize size, builtin__closure__MemoryProtectAtrr attr) { | ||
| 4898 | + #if 0 | ||
| 4899 | + { | ||
| 4900 | + } | ||
| 4901 | + #else | ||
| 4902 | + { | ||
| 4903 | + | ||
| 4904 | + if (attr == (builtin__closure__MemoryProtectAtrr__read_exec)) { | ||
| 4905 | + mprotect(ptr, size, (PROT_READ | PROT_EXEC)); | ||
| 4906 | + } | ||
| 4907 | + else if (attr == (builtin__closure__MemoryProtectAtrr__read_write)) { | ||
| 4908 | + mprotect(ptr, size, (PROT_READ | PROT_WRITE)); | ||
| 4909 | + } | ||
| 4910 | + } | ||
| 4911 | + #endif | ||
| 4912 | +} | ||
| 4913 | +inline VV_LOC int builtin__closure__get_page_size_platform(void) { | ||
| 4914 | + int page_size = 0x4000; | ||
| 4915 | + #if 1 | ||
| 4916 | + { | ||
| 4917 | + page_size = ((int)(sysconf(_SC_PAGESIZE))); | ||
| 4918 | + } | ||
| 4919 | + #endif | ||
| 4920 | + page_size = page_size * ((VSAFE_DIV_int((_const_builtin__closure__assumed_page_size - 1) , page_size)) + 1); | ||
| 4921 | + return page_size; | ||
| 4922 | +} | ||
| 4923 | +inline VV_LOC void builtin__closure__closure_mtx_lock_init_platform(void) { | ||
| 4924 | + #if 1 | ||
| 4925 | + { | ||
| 4926 | + pthread_mutex_init(builtin__closure__closure_mtx_ptr_platform(), 0); | ||
| 4927 | + } | ||
| 4928 | + #endif | ||
| 4929 | +} | ||
| 4930 | +inline VV_LOC void builtin__closure__closure_mtx_lock_platform(void) { | ||
| 4931 | + #if 1 | ||
| 4932 | + { | ||
| 4933 | + pthread_mutex_lock(builtin__closure__closure_mtx_ptr_platform()); | ||
| 4934 | + } | ||
| 4935 | + #endif | ||
| 4936 | +} | ||
| 4937 | +inline VV_LOC void builtin__closure__closure_mtx_unlock_platform(void) { | ||
| 4938 | + #if 1 | ||
| 4939 | + { | ||
| 4940 | + pthread_mutex_unlock(builtin__closure__closure_mtx_ptr_platform()); | ||
| 4941 | + } | ||
| 4942 | + #endif | ||
| 4943 | +} | ||
| 4944 | +inline VV_LOC u64 builtin__closure__closure_current_thread_id_platform(void) { | ||
| 4945 | + #if 1 | ||
| 4946 | + { | ||
| 4947 | + return ((u64)(pthread_self())); | ||
| 4948 | + } | ||
| 4949 | + #endif | ||
| 4950 | + return ((u64)(0)); | ||
| 4951 | +} | ||
| 4952 | +inline VV_LOC void builtin__closure__closure_init_once_platform(void) { | ||
| 4953 | + #if 0 | ||
| 4954 | + { | ||
| 4955 | + } | ||
| 4956 | + #else | ||
| 4957 | + { | ||
| 4958 | + v_closure_init_once(builtin__closure__closure_init_body); | ||
| 4959 | + } | ||
| 4960 | + #endif | ||
| 4961 | +} | ||
| 4962 | +inline multi_return_u64_u64 math__bits__mul_64(u64 x, u64 y) { | ||
| 4963 | + u64 hi = ((u64)(0)); | ||
| 4964 | + u64 lo = ((u64)(0)); | ||
| 4965 | + #if defined(_MSC_VER) | ||
| 4966 | + { | ||
| 4967 | + } | ||
| 4968 | + #elif defined(__V_amd64) | ||
| 4969 | + { | ||
| 4970 | + __asm__ ( | ||
| 4971 | + "mulq %%rdx\n\t" | ||
| 4972 | + : [lo] "=a" (lo), | ||
| 4973 | + [hi] "=d" (hi) | ||
| 4974 | + : [x] "a" (x), | ||
| 4975 | + [y] "d" (y) | ||
| 4976 | + : "cc" | ||
| 4977 | + ); | ||
| 4978 | + return (multi_return_u64_u64){.arg0=hi, .arg1=lo}; | ||
| 4979 | + } | ||
| 4980 | + #endif | ||
| 4981 | + return math__bits__mul_64_default(x, y); | ||
| 4982 | +} | ||
| 4983 | +inline multi_return_u64_u64 math__bits__mul_add_64(u64 x, u64 y, u64 z) { | ||
| 4984 | + u64 hi = ((u64)(0)); | ||
| 4985 | + u64 lo = ((u64)(0)); | ||
| 4986 | + #if defined(_MSC_VER) | ||
| 4987 | + { | ||
| 4988 | + } | ||
| 4989 | + #elif defined(__V_amd64) | ||
| 4990 | + { | ||
| 4991 | + __asm__ ( | ||
| 4992 | + "mulq %%rdx\n\t" | ||
| 4993 | + "addq %[z], %%rax\n\t" | ||
| 4994 | + "adcq $0, %%rdx\n\t" | ||
| 4995 | + : [lo] "=a" (lo), | ||
| 4996 | + [hi] "=d" (hi) | ||
| 4997 | + : [x] "a" (x), | ||
| 4998 | + [y] "d" (y), | ||
| 4999 | + [z] "r" (z) | ||
| 5000 | + : "cc" | ||
| 5001 | + ); | ||
| 5002 | + return (multi_return_u64_u64){.arg0=hi, .arg1=lo}; | ||
| 5003 | + } | ||
| 5004 | + #endif | ||
| 5005 | + return math__bits__mul_add_64_default(x, y, z); | ||
| 5006 | +} | ||
| 5007 | +inline multi_return_u64_u64 math__bits__div_64(u64 hi, u64 lo, u64 y1) { | ||
| 5008 | + u64 y = y1; | ||
| 5009 | + if (y == 0) { | ||
| 5010 | + builtin___v_panic(_const_math__bits__divide_error); | ||
| 5011 | + VUNREACHABLE(); | ||
| 5012 | + } | ||
| 5013 | + if (y <= hi) { | ||
| 5014 | + builtin___v_panic(_const_math__bits__overflow_error); | ||
| 5015 | + VUNREACHABLE(); | ||
| 5016 | + } | ||
| 5017 | + u64 quo = ((u64)(0)); | ||
| 5018 | + u64 rem = ((u64)(0)); | ||
| 5019 | + #if defined(_MSC_VER) | ||
| 5020 | + { | ||
| 5021 | + } | ||
| 5022 | + #elif defined(__V_amd64) | ||
| 5023 | + { | ||
| 5024 | + __asm__ ( | ||
| 5025 | + "div %[y]\n\t" | ||
| 5026 | + : [quo] "=a" (quo), | ||
| 5027 | + [rem] "=d" (rem) | ||
| 5028 | + : [hi] "d" (hi), | ||
| 5029 | + [lo] "a" (lo), | ||
| 5030 | + [y] "r" (y) | ||
| 5031 | + : "cc" | ||
| 5032 | + ); | ||
| 5033 | + return (multi_return_u64_u64){.arg0=quo, .arg1=rem}; | ||
| 5034 | + } | ||
| 5035 | + #endif | ||
| 5036 | + return math__bits__div_64_default(hi, lo, y1); | ||
| 5037 | +} | ||
| 5038 | +inline int math__bits__leading_zeros_8(u8 x) { | ||
| 5039 | + if (x == 0) { | ||
| 5040 | + return 8; | ||
| 5041 | + } | ||
| 5042 | + #if defined(_MSC_VER) | ||
| 5043 | + { | ||
| 5044 | + } | ||
| 5045 | + #elif !defined(__TINYC__) | ||
| 5046 | + { | ||
| 5047 | + return __builtin_clz(((u32)(x))) - 24; | ||
| 5048 | + } | ||
| 5049 | + #endif | ||
| 5050 | + return math__bits__leading_zeros_8_default(x); | ||
| 5051 | +} | ||
| 5052 | +inline int math__bits__leading_zeros_16(u16 x) { | ||
| 5053 | + if (x == 0) { | ||
| 5054 | + return 16; | ||
| 5055 | + } | ||
| 5056 | + #if defined(_MSC_VER) | ||
| 5057 | + { | ||
| 5058 | + } | ||
| 5059 | + #elif !defined(__TINYC__) | ||
| 5060 | + { | ||
| 5061 | + return __builtin_clz(((u32)(x))) - 16; | ||
| 5062 | + } | ||
| 5063 | + #endif | ||
| 5064 | + return math__bits__leading_zeros_16_default(x); | ||
| 5065 | +} | ||
| 5066 | +inline int math__bits__leading_zeros_32(u32 x) { | ||
| 5067 | + if (x == 0) { | ||
| 5068 | + return 32; | ||
| 5069 | + } | ||
| 5070 | + #if defined(_MSC_VER) | ||
| 5071 | + { | ||
| 5072 | + } | ||
| 5073 | + #elif !defined(__TINYC__) | ||
| 5074 | + { | ||
| 5075 | + return __builtin_clz(x); | ||
| 5076 | + } | ||
| 5077 | + #endif | ||
| 5078 | + return math__bits__leading_zeros_32_default(x); | ||
| 5079 | +} | ||
| 5080 | +inline int math__bits__leading_zeros_64(u64 x) { | ||
| 5081 | + if (x == 0) { | ||
| 5082 | + return 64; | ||
| 5083 | + } | ||
| 5084 | + #if defined(_MSC_VER) | ||
| 5085 | + { | ||
| 5086 | + } | ||
| 5087 | + #elif !defined(__TINYC__) | ||
| 5088 | + { | ||
| 5089 | + return __builtin_clzll(x); | ||
| 5090 | + } | ||
| 5091 | + #endif | ||
| 5092 | + return math__bits__leading_zeros_64_default(x); | ||
| 5093 | +} | ||
| 5094 | +inline int math__bits__trailing_zeros_8(u8 x) { | ||
| 5095 | + if (x == 0) { | ||
| 5096 | + return 8; | ||
| 5097 | + } | ||
| 5098 | + #if defined(_MSC_VER) | ||
| 5099 | + { | ||
| 5100 | + } | ||
| 5101 | + #elif !defined(__TINYC__) | ||
| 5102 | + { | ||
| 5103 | + return __builtin_ctz(((u32)(x))); | ||
| 5104 | + } | ||
| 5105 | + #endif | ||
| 5106 | + return math__bits__trailing_zeros_8_default(x); | ||
| 5107 | +} | ||
| 5108 | +inline int math__bits__trailing_zeros_16(u16 x) { | ||
| 5109 | + if (x == 0) { | ||
| 5110 | + return 16; | ||
| 5111 | + } | ||
| 5112 | + #if defined(_MSC_VER) | ||
| 5113 | + { | ||
| 5114 | + } | ||
| 5115 | + #elif !defined(__TINYC__) | ||
| 5116 | + { | ||
| 5117 | + return __builtin_ctz(((u32)(x))); | ||
| 5118 | + } | ||
| 5119 | + #endif | ||
| 5120 | + return math__bits__trailing_zeros_16_default(x); | ||
| 5121 | +} | ||
| 5122 | +inline int math__bits__trailing_zeros_32(u32 x) { | ||
| 5123 | + if (x == 0) { | ||
| 5124 | + return 32; | ||
| 5125 | + } | ||
| 5126 | + #if defined(_MSC_VER) | ||
| 5127 | + { | ||
| 5128 | + } | ||
| 5129 | + #elif !defined(__TINYC__) | ||
| 5130 | + { | ||
| 5131 | + return __builtin_ctz(x); | ||
| 5132 | + } | ||
| 5133 | + #endif | ||
| 5134 | + return math__bits__trailing_zeros_32_default(x); | ||
| 5135 | +} | ||
| 5136 | +inline int math__bits__trailing_zeros_64(u64 x) { | ||
| 5137 | + if (x == 0) { | ||
| 5138 | + return 64; | ||
| 5139 | + } | ||
| 5140 | + #if defined(_MSC_VER) | ||
| 5141 | + { | ||
| 5142 | + } | ||
| 5143 | + #elif !defined(__TINYC__) | ||
| 5144 | + { | ||
| 5145 | + return __builtin_ctzll(x); | ||
| 5146 | + } | ||
| 5147 | + #endif | ||
| 5148 | + return math__bits__trailing_zeros_64_default(x); | ||
| 5149 | +} | ||
| 5150 | +inline int math__bits__ones_count_8(u8 x) { | ||
| 5151 | + #if defined(_MSC_VER) | ||
| 5152 | + { | ||
| 5153 | + } | ||
| 5154 | + #elif !defined(__TINYC__) | ||
| 5155 | + { | ||
| 5156 | + return __builtin_popcount(((u32)(x))); | ||
| 5157 | + } | ||
| 5158 | + #endif | ||
| 5159 | + return math__bits__ones_count_8_default(x); | ||
| 5160 | +} | ||
| 5161 | +inline int math__bits__ones_count_16(u16 x) { | ||
| 5162 | + #if defined(_MSC_VER) | ||
| 5163 | + { | ||
| 5164 | + } | ||
| 5165 | + #elif !defined(__TINYC__) | ||
| 5166 | + { | ||
| 5167 | + return __builtin_popcount(((u32)(x))); | ||
| 5168 | + } | ||
| 5169 | + #endif | ||
| 5170 | + return math__bits__ones_count_16_default(x); | ||
| 5171 | +} | ||
| 5172 | +inline int math__bits__ones_count_32(u32 x) { | ||
| 5173 | + #if defined(_MSC_VER) | ||
| 5174 | + { | ||
| 5175 | + } | ||
| 5176 | + #elif !defined(__TINYC__) | ||
| 5177 | + { | ||
| 5178 | + return __builtin_popcount(x); | ||
| 5179 | + } | ||
| 5180 | + #endif | ||
| 5181 | + return math__bits__ones_count_32_default(x); | ||
| 5182 | +} | ||
| 5183 | +inline int math__bits__ones_count_64(u64 x) { | ||
| 5184 | + #if defined(_MSC_VER) | ||
| 5185 | + { | ||
| 5186 | + } | ||
| 5187 | + #elif !defined(__TINYC__) | ||
| 5188 | + { | ||
| 5189 | + return __builtin_popcountll(x); | ||
| 5190 | + } | ||
| 5191 | + #endif | ||
| 5192 | + return math__bits__ones_count_64_default(x); | ||
| 5193 | +} | ||
| 5194 | +inline int math__bits__pure_v_but_overridden_by_c_leading_zeros_8(u8 x) { | ||
| 5195 | + return math__bits__leading_zeros_8_default(x); | ||
| 5196 | +} | ||
| 5197 | +inline VV_LOC int math__bits__leading_zeros_8_default(u8 x) { | ||
| 5198 | + return 8 - math__bits__len_8(x); | ||
| 5199 | +} | ||
| 5200 | +inline int math__bits__pure_v_but_overridden_by_c_leading_zeros_16(u16 x) { | ||
| 5201 | + return math__bits__leading_zeros_16_default(x); | ||
| 5202 | +} | ||
| 5203 | +inline VV_LOC int math__bits__leading_zeros_16_default(u16 x) { | ||
| 5204 | + return 16 - math__bits__len_16(x); | ||
| 5205 | +} | ||
| 5206 | +inline int math__bits__pure_v_but_overridden_by_c_leading_zeros_32(u32 x) { | ||
| 5207 | + return math__bits__leading_zeros_32_default(x); | ||
| 5208 | +} | ||
| 5209 | +inline VV_LOC int math__bits__leading_zeros_32_default(u32 x) { | ||
| 5210 | + return 32 - math__bits__len_32(x); | ||
| 5211 | +} | ||
| 5212 | +inline int math__bits__pure_v_but_overridden_by_c_leading_zeros_64(u64 x) { | ||
| 5213 | + return math__bits__leading_zeros_64_default(x); | ||
| 5214 | +} | ||
| 5215 | +inline VV_LOC int math__bits__leading_zeros_64_default(u64 x) { | ||
| 5216 | + return 64 - math__bits__len_64(x); | ||
| 5217 | +} | ||
| 5218 | +inline int math__bits__pure_v_but_overridden_by_c_trailing_zeros_8(u8 x) { | ||
| 5219 | + return math__bits__trailing_zeros_8_default(x); | ||
| 5220 | +} | ||
| 5221 | +inline VV_LOC int math__bits__trailing_zeros_8_default(u8 x) { | ||
| 5222 | + return ((int)(_const_math__bits__ntz_8_tab[x])); | ||
| 5223 | +} | ||
| 5224 | +inline int math__bits__pure_v_but_overridden_by_c_trailing_zeros_16(u16 x) { | ||
| 5225 | + return math__bits__trailing_zeros_16_default(x); | ||
| 5226 | +} | ||
| 5227 | +inline VV_LOC int math__bits__trailing_zeros_16_default(u16 x) { | ||
| 5228 | + if (x == 0) { | ||
| 5229 | + return 16; | ||
| 5230 | + } | ||
| 5231 | + return ((int)(_const_math__bits__de_bruijn32tab[v__rshift_u32(((u32)((x & -x))) * _const_math__bits__de_bruijn32, (u64)27)])); | ||
| 5232 | +} | ||
| 5233 | +inline int math__bits__pure_v_but_overridden_by_c_trailing_zeros_32(u32 x) { | ||
| 5234 | + return math__bits__trailing_zeros_32_default(x); | ||
| 5235 | +} | ||
| 5236 | +inline VV_LOC int math__bits__trailing_zeros_32_default(u32 x) { | ||
| 5237 | + if (x == 0) { | ||
| 5238 | + return 32; | ||
| 5239 | + } | ||
| 5240 | + return ((int)(_const_math__bits__de_bruijn32tab[v__rshift_u32(((x & -x)) * _const_math__bits__de_bruijn32, (u64)27)])); | ||
| 5241 | +} | ||
| 5242 | +inline int math__bits__pure_v_but_overridden_by_c_trailing_zeros_64(u64 x) { | ||
| 5243 | + return math__bits__trailing_zeros_64_default(x); | ||
| 5244 | +} | ||
| 5245 | +inline VV_LOC int math__bits__trailing_zeros_64_default(u64 x) { | ||
| 5246 | + if (x == 0) { | ||
| 5247 | + return 64; | ||
| 5248 | + } | ||
| 5249 | + return ((int)(_const_math__bits__de_bruijn64tab[((int)(v__rshift_u64(((x & -x)) * _const_math__bits__de_bruijn64, (u64)58)))])); | ||
| 5250 | +} | ||
| 5251 | +inline int math__bits__pure_v_but_overridden_by_c_ones_count_8(u8 x) { | ||
| 5252 | + return math__bits__ones_count_8_default(x); | ||
| 5253 | +} | ||
| 5254 | +inline VV_LOC int math__bits__ones_count_8_default(u8 x) { | ||
| 5255 | + return ((int)(_const_math__bits__pop_8_tab[x])); | ||
| 5256 | +} | ||
| 5257 | +inline int math__bits__pure_v_but_overridden_by_c_ones_count_16(u16 x) { | ||
| 5258 | + return math__bits__ones_count_16_default(x); | ||
| 5259 | +} | ||
| 5260 | +inline VV_LOC int math__bits__ones_count_16_default(u16 x) { | ||
| 5261 | + return ((int)((u8)(_const_math__bits__pop_8_tab[v__rshift_u16(x, (u64)8)] + _const_math__bits__pop_8_tab[(x & ((u16)(0xff)))]))); | ||
| 5262 | +} | ||
| 5263 | +inline int math__bits__pure_v_but_overridden_by_c_ones_count_32(u32 x) { | ||
| 5264 | + return math__bits__ones_count_32_default(x); | ||
| 5265 | +} | ||
| 5266 | +inline VV_LOC int math__bits__ones_count_32_default(u32 x) { | ||
| 5267 | + return ((int)((u8)((u8)((u8)(_const_math__bits__pop_8_tab[v__rshift_u32(x, (u64)24)] + _const_math__bits__pop_8_tab[((v__rshift_u32(x, (u64)16)) & 0xff)]) + _const_math__bits__pop_8_tab[((v__rshift_u32(x, (u64)8)) & 0xff)]) + _const_math__bits__pop_8_tab[(x & ((u32)(0xff)))]))); | ||
| 5268 | +} | ||
| 5269 | +inline int math__bits__pure_v_but_overridden_by_c_ones_count_64(u64 x) { | ||
| 5270 | + return math__bits__ones_count_64_default(x); | ||
| 5271 | +} | ||
| 5272 | +inline VV_LOC int math__bits__ones_count_64_default(u64 x) { | ||
| 5273 | + u64 y = (((v__rshift_u64(x, (u64)((u64)(1)))) & ((_const_math__bits__m0 & _const_max_u64)))) + ((x & ((_const_math__bits__m0 & _const_max_u64)))); | ||
| 5274 | + y = (((v__rshift_u64(y, (u64)((u64)(2)))) & ((_const_math__bits__m1 & _const_max_u64)))) + ((y & ((_const_math__bits__m1 & _const_max_u64)))); | ||
| 5275 | + y = (((v__rshift_u64(y, (u64)4)) + y) & ((_const_math__bits__m2 & _const_max_u64))); | ||
| 5276 | + y += v__rshift_u64(y, (u64)8); | ||
| 5277 | + y += v__rshift_u64(y, (u64)16); | ||
| 5278 | + y += v__rshift_u64(y, (u64)32); | ||
| 5279 | + return (((int)(y)) & 127); | ||
| 5280 | +} | ||
| 5281 | +inline u8 math__bits__rotate_left_8(u8 x, int k) { | ||
| 5282 | + u8 s = (((u8)(k)) & ((u8)(_const_math__bits__n8 - ((u8)(1))))); | ||
| 5283 | + return ((v__lshift_u8(x, (u64)s)) | (v__rshift_u8(x, (u64)((u8)(_const_math__bits__n8 - s))))); | ||
| 5284 | +} | ||
| 5285 | +inline u16 math__bits__rotate_left_16(u16 x, int k) { | ||
| 5286 | + u16 s = (((u16)(k)) & ((u16)(_const_math__bits__n16 - ((u16)(1))))); | ||
| 5287 | + return ((v__lshift_u16(x, (u64)s)) | (v__rshift_u16(x, (u64)((u16)(_const_math__bits__n16 - s))))); | ||
| 5288 | +} | ||
| 5289 | +inline u32 math__bits__rotate_left_32(u32 x, int k) { | ||
| 5290 | + u32 s = (((u32)(k)) & (_const_math__bits__n32 - ((u32)(1)))); | ||
| 5291 | + return ((v__lshift_u32(x, (u64)s)) | (v__rshift_u32(x, (u64)(_const_math__bits__n32 - s)))); | ||
| 5292 | +} | ||
| 5293 | +inline u64 math__bits__rotate_left_64(u64 x, int k) { | ||
| 5294 | + u64 s = (((u64)(k)) & (_const_math__bits__n64 - ((u64)(1)))); | ||
| 5295 | + return ((v__lshift_u64(x, (u64)s)) | (v__rshift_u64(x, (u64)(_const_math__bits__n64 - s)))); | ||
| 5296 | +} | ||
| 5297 | +inline u8 math__bits__reverse_8(u8 x) { | ||
| 5298 | + return _const_math__bits__rev_8_tab[x]; | ||
| 5299 | +} | ||
| 5300 | +inline u16 math__bits__reverse_16(u16 x) { | ||
| 5301 | + return (((u16)(_const_math__bits__rev_8_tab[v__rshift_u16(x, (u64)8)])) | (v__lshift_u16(((u16)(_const_math__bits__rev_8_tab[(x & ((u16)(0xff)))])), (u64)8))); | ||
| 5302 | +} | ||
| 5303 | +inline u32 math__bits__reverse_32(u32 x) { | ||
| 5304 | + u64 y = (((((v__rshift_u32(x, (u64)((u32)(1)))) & ((_const_math__bits__m0 & _const_max_u32)))) | (v__lshift_u64(((x & ((_const_math__bits__m0 & _const_max_u32)))), (u64)1)))); | ||
| 5305 | + y = (((((v__rshift_u64(y, (u64)((u32)(2)))) & ((_const_math__bits__m1 & _const_max_u32)))) | (v__lshift_u64(((y & ((_const_math__bits__m1 & _const_max_u32)))), (u64)((u32)(2)))))); | ||
| 5306 | + y = (((((v__rshift_u64(y, (u64)((u32)(4)))) & ((_const_math__bits__m2 & _const_max_u32)))) | (v__lshift_u64(((y & ((_const_math__bits__m2 & _const_max_u32)))), (u64)((u32)(4)))))); | ||
| 5307 | + return math__bits__reverse_bytes_32(((u32)(y))); | ||
| 5308 | +} | ||
| 5309 | +inline u64 math__bits__reverse_64(u64 x) { | ||
| 5310 | + u64 y = (((((v__rshift_u64(x, (u64)((u64)(1)))) & ((_const_math__bits__m0 & _const_max_u64)))) | (v__lshift_u64(((x & ((_const_math__bits__m0 & _const_max_u64)))), (u64)1)))); | ||
| 5311 | + y = (((((v__rshift_u64(y, (u64)((u64)(2)))) & ((_const_math__bits__m1 & _const_max_u64)))) | (v__lshift_u64(((y & ((_const_math__bits__m1 & _const_max_u64)))), (u64)2)))); | ||
| 5312 | + y = (((((v__rshift_u64(y, (u64)((u64)(4)))) & ((_const_math__bits__m2 & _const_max_u64)))) | (v__lshift_u64(((y & ((_const_math__bits__m2 & _const_max_u64)))), (u64)4)))); | ||
| 5313 | + return math__bits__reverse_bytes_64(y); | ||
| 5314 | +} | ||
| 5315 | +inline u16 math__bits__reverse_bytes_16(u16 x) { | ||
| 5316 | + return ((v__rshift_u16(x, (u64)8)) | (v__lshift_u16(x, (u64)8))); | ||
| 5317 | +} | ||
| 5318 | +inline u32 math__bits__reverse_bytes_32(u32 x) { | ||
| 5319 | + u64 y = (((((v__rshift_u32(x, (u64)((u32)(8)))) & ((_const_math__bits__m3 & _const_max_u32)))) | (v__lshift_u64(((x & ((_const_math__bits__m3 & _const_max_u32)))), (u64)((u32)(8)))))); | ||
| 5320 | + return ((u32)(((v__rshift_u64(y, (u64)16)) | (v__lshift_u64(y, (u64)16))))); | ||
| 5321 | +} | ||
| 5322 | +inline u64 math__bits__reverse_bytes_64(u64 x) { | ||
| 5323 | + u64 y = (((((v__rshift_u64(x, (u64)((u64)(8)))) & ((_const_math__bits__m3 & _const_max_u64)))) | (v__lshift_u64(((x & ((_const_math__bits__m3 & _const_max_u64)))), (u64)((u64)(8)))))); | ||
| 5324 | + y = (((((v__rshift_u64(y, (u64)((u64)(16)))) & ((_const_math__bits__m4 & _const_max_u64)))) | (v__lshift_u64(((y & ((_const_math__bits__m4 & _const_max_u64)))), (u64)((u64)(16)))))); | ||
| 5325 | + return ((v__rshift_u64(y, (u64)32)) | (v__lshift_u64(y, (u64)32))); | ||
| 5326 | +} | ||
| 5327 | +int math__bits__len_8(u8 x) { | ||
| 5328 | + return ((int)(_const_math__bits__len_8_tab[x])); | ||
| 5329 | +} | ||
| 5330 | +int math__bits__len_16(u16 x) { | ||
| 5331 | + u16 y = x; | ||
| 5332 | + int n = 0; | ||
| 5333 | + if (y >= 256) { | ||
| 5334 | + y = v__rshift_u16(y, (u64)8); | ||
| 5335 | + n = 8; | ||
| 5336 | + } | ||
| 5337 | + return n + ((int)(_const_math__bits__len_8_tab[((int)(y))])); | ||
| 5338 | +} | ||
| 5339 | +int math__bits__len_32(u32 x) { | ||
| 5340 | + u32 y = x; | ||
| 5341 | + int n = 0; | ||
| 5342 | + if (y >= 65536) { | ||
| 5343 | + y = v__rshift_u32(y, (u64)16); | ||
| 5344 | + n = 16; | ||
| 5345 | + } | ||
| 5346 | + if (y >= 256) { | ||
| 5347 | + y = v__rshift_u32(y, (u64)8); | ||
| 5348 | + n += 8; | ||
| 5349 | + } | ||
| 5350 | + return n + ((int)(_const_math__bits__len_8_tab[((int)(y))])); | ||
| 5351 | +} | ||
| 5352 | +int math__bits__len_64(u64 x) { | ||
| 5353 | + u64 y = x; | ||
| 5354 | + int n = 0; | ||
| 5355 | + if (y >= v__lshift_u64(((u64)(1)), (u64)((u64)(32)))) { | ||
| 5356 | + y = v__rshift_u64(y, (u64)32); | ||
| 5357 | + n = 32; | ||
| 5358 | + } | ||
| 5359 | + if (y >= v__lshift_u64(((u64)(1)), (u64)((u64)(16)))) { | ||
| 5360 | + y = v__rshift_u64(y, (u64)16); | ||
| 5361 | + n += 16; | ||
| 5362 | + } | ||
| 5363 | + if (y >= v__lshift_u64(((u64)(1)), (u64)((u64)(8)))) { | ||
| 5364 | + y = v__rshift_u64(y, (u64)8); | ||
| 5365 | + n += 8; | ||
| 5366 | + } | ||
| 5367 | + return n + ((int)(_const_math__bits__len_8_tab[((int)(y))])); | ||
| 5368 | +} | ||
| 5369 | +multi_return_u32_u32 math__bits__add_32(u32 x, u32 y, u32 carry) { | ||
| 5370 | + u64 sum64 = ((u64)(x)) + ((u64)(y)) + ((u64)(carry)); | ||
| 5371 | + u32 sum = ((u32)(sum64)); | ||
| 5372 | + u32 carry_out = ((u32)(v__rshift_u64(sum64, (u64)32))); | ||
| 5373 | + return (multi_return_u32_u32){.arg0=sum, .arg1=carry_out}; | ||
| 5374 | +} | ||
| 5375 | +multi_return_u64_u64 math__bits__add_64(u64 x, u64 y, u64 carry) { | ||
| 5376 | + u64 sum = x + y + carry; | ||
| 5377 | + u64 carry_out = v__rshift_u64(((((x & y)) | ((((x | y)) & ~sum)))), (u64)63); | ||
| 5378 | + return (multi_return_u64_u64){.arg0=sum, .arg1=carry_out}; | ||
| 5379 | +} | ||
| 5380 | +multi_return_u32_u32 math__bits__sub_32(u32 x, u32 y, u32 borrow) { | ||
| 5381 | + u32 diff = x - y - borrow; | ||
| 5382 | + u32 borrow_out = v__rshift_u32(((((~x & y)) | ((~((x ^ y)) & diff)))), (u64)31); | ||
| 5383 | + return (multi_return_u32_u32){.arg0=diff, .arg1=borrow_out}; | ||
| 5384 | +} | ||
| 5385 | +multi_return_u64_u64 math__bits__sub_64(u64 x, u64 y, u64 borrow) { | ||
| 5386 | + u64 diff = x - y - borrow; | ||
| 5387 | + u64 borrow_out = v__rshift_u64(((((~x & y)) | ((~((x ^ y)) & diff)))), (u64)63); | ||
| 5388 | + return (multi_return_u64_u64){.arg0=diff, .arg1=borrow_out}; | ||
| 5389 | +} | ||
| 5390 | +inline multi_return_u32_u32 math__bits__mul_32(u32 x, u32 y) { | ||
| 5391 | + return math__bits__mul_32_default(x, y); | ||
| 5392 | +} | ||
| 5393 | +inline VV_LOC multi_return_u32_u32 math__bits__mul_32_default(u32 x, u32 y) { | ||
| 5394 | + u64 tmp = ((u64)(x)) * ((u64)(y)); | ||
| 5395 | + u32 hi = ((u32)(v__rshift_u64(tmp, (u64)32))); | ||
| 5396 | + u32 lo = ((u32)(tmp)); | ||
| 5397 | + return (multi_return_u32_u32){.arg0=hi, .arg1=lo}; | ||
| 5398 | +} | ||
| 5399 | +inline multi_return_u64_u64 math__bits__pure_v_but_overridden_by_amd64_mul_64(u64 x, u64 y) { | ||
| 5400 | + return math__bits__mul_64_default(x, y); | ||
| 5401 | +} | ||
| 5402 | +VV_LOC multi_return_u64_u64 math__bits__mul_64_default(u64 x, u64 y) { | ||
| 5403 | + u64 x0 = (x & _const_math__bits__mask32); | ||
| 5404 | + u64 x1 = v__rshift_u64(x, (u64)32); | ||
| 5405 | + u64 y0 = (y & _const_math__bits__mask32); | ||
| 5406 | + u64 y1 = v__rshift_u64(y, (u64)32); | ||
| 5407 | + u64 w0 = x0 * y0; | ||
| 5408 | + u64 t = x1 * y0 + (v__rshift_u64(w0, (u64)32)); | ||
| 5409 | + u64 w1 = (t & _const_math__bits__mask32); | ||
| 5410 | + u64 w2 = v__rshift_u64(t, (u64)32); | ||
| 5411 | + w1 += x0 * y1; | ||
| 5412 | + u64 hi = x1 * y1 + w2 + (v__rshift_u64(w1, (u64)32)); | ||
| 5413 | + u64 lo = x * y; | ||
| 5414 | + return (multi_return_u64_u64){.arg0=hi, .arg1=lo}; | ||
| 5415 | +} | ||
| 5416 | +inline multi_return_u32_u32 math__bits__mul_add_32(u32 x, u32 y, u32 z) { | ||
| 5417 | + return math__bits__mul_add_32_default(x, y, z); | ||
| 5418 | +} | ||
| 5419 | +inline VV_LOC multi_return_u32_u32 math__bits__mul_add_32_default(u32 x, u32 y, u32 z) { | ||
| 5420 | + u64 tmp = ((u64)(x)) * ((u64)(y)) + ((u64)(z)); | ||
| 5421 | + u32 hi = ((u32)(v__rshift_u64(tmp, (u64)32))); | ||
| 5422 | + u32 lo = ((u32)(tmp)); | ||
| 5423 | + return (multi_return_u32_u32){.arg0=hi, .arg1=lo}; | ||
| 5424 | +} | ||
| 5425 | +inline multi_return_u64_u64 math__bits__pure_v_but_overridden_by_amd64_mul_add_64(u64 x, u64 y, u64 z) { | ||
| 5426 | + return math__bits__mul_add_64_default(x, y, z); | ||
| 5427 | +} | ||
| 5428 | +inline VV_LOC multi_return_u64_u64 math__bits__mul_add_64_default(u64 x, u64 y, u64 z) { | ||
| 5429 | + multi_return_u64_u64 mr_14968 = math__bits__mul_64(x, y); | ||
| 5430 | + u64 h = mr_14968.arg0; | ||
| 5431 | + u64 l = mr_14968.arg1; | ||
| 5432 | + u64 lo = l + z; | ||
| 5433 | + u64 hi = h + (u64[]){(lo < l)?1:0}[0]; | ||
| 5434 | + return (multi_return_u64_u64){.arg0=hi, .arg1=lo}; | ||
| 5435 | +} | ||
| 5436 | +inline multi_return_u32_u32 math__bits__div_32(u32 hi, u32 lo, u32 y) { | ||
| 5437 | + return math__bits__div_32_default(hi, lo, y); | ||
| 5438 | +} | ||
| 5439 | +VV_LOC multi_return_u32_u32 math__bits__div_32_default(u32 hi, u32 lo, u32 y) { | ||
| 5440 | + if (y == 0) { | ||
| 5441 | + builtin___v_panic(_const_math__bits__divide_error); | ||
| 5442 | + VUNREACHABLE(); | ||
| 5443 | + } | ||
| 5444 | + if (y <= hi) { | ||
| 5445 | + builtin___v_panic(_const_math__bits__overflow_error); | ||
| 5446 | + VUNREACHABLE(); | ||
| 5447 | + } | ||
| 5448 | + u64 z = ((v__lshift_u64(((u64)(hi)), (u64)32)) | ((u64)(lo))); | ||
| 5449 | + u32 quo = ((u32)(VSAFE_DIV_u64(z , ((u64)(y))))); | ||
| 5450 | + u32 rem = ((u32)(VSAFE_MOD_u64(z , ((u64)(y))))); | ||
| 5451 | + return (multi_return_u32_u32){.arg0=quo, .arg1=rem}; | ||
| 5452 | +} | ||
| 5453 | +inline multi_return_u64_u64 math__bits__pure_v_but_overridden_by_amd64_div_64(u64 hi, u64 lo, u64 y1) { | ||
| 5454 | + return math__bits__div_64_default(hi, lo, y1); | ||
| 5455 | +} | ||
| 5456 | +VV_LOC multi_return_u64_u64 math__bits__div_64_default(u64 hi, u64 lo, u64 y1) { | ||
| 5457 | + u64 y = y1; | ||
| 5458 | + if (y == 0) { | ||
| 5459 | + builtin___v_panic(_const_math__bits__divide_error); | ||
| 5460 | + VUNREACHABLE(); | ||
| 5461 | + } | ||
| 5462 | + if (y <= hi) { | ||
| 5463 | + builtin___v_panic(_const_math__bits__overflow_error); | ||
| 5464 | + VUNREACHABLE(); | ||
| 5465 | + } | ||
| 5466 | + u32 s = ((u32)(math__bits__leading_zeros_64(y))); | ||
| 5467 | + y = v__lshift_u64(y, (u64)s); | ||
| 5468 | + u64 yn1 = v__rshift_u64(y, (u64)32); | ||
| 5469 | + u64 yn0 = (y & _const_math__bits__mask32); | ||
| 5470 | + u64 ss1 = (v__lshift_u64(hi, (u64)s)); | ||
| 5471 | + u32 xxx = 64 - s; | ||
| 5472 | + u64 ss2 = v__rshift_u64(lo, (u64)xxx); | ||
| 5473 | + if (xxx == 64) { | ||
| 5474 | + ss2 = 0; | ||
| 5475 | + } | ||
| 5476 | + u64 un32 = (ss1 | ss2); | ||
| 5477 | + u64 un10 = v__lshift_u64(lo, (u64)s); | ||
| 5478 | + u64 un1 = v__rshift_u64(un10, (u64)32); | ||
| 5479 | + u64 un0 = (un10 & _const_math__bits__mask32); | ||
| 5480 | + u64 q1 = VSAFE_DIV_u64(un32 , yn1); | ||
| 5481 | + u64 rhat = un32 - (q1 * yn1); | ||
| 5482 | + for (;;) { | ||
| 5483 | + if (!(q1 >= _const_math__bits__two32 || (q1 * yn0) > ((_const_math__bits__two32 * rhat) + un1))) break; | ||
| 5484 | + q1--; | ||
| 5485 | + rhat += yn1; | ||
| 5486 | + if (rhat >= _const_math__bits__two32) { | ||
| 5487 | + break; | ||
| 5488 | + } | ||
| 5489 | + } | ||
| 5490 | + u64 un21 = (un32 * _const_math__bits__two32) + (un1 - (q1 * y)); | ||
| 5491 | + u64 q0 = VSAFE_DIV_u64(un21 , yn1); | ||
| 5492 | + rhat = un21 - q0 * yn1; | ||
| 5493 | + for (;;) { | ||
| 5494 | + if (!(q0 >= _const_math__bits__two32 || (q0 * yn0) > ((_const_math__bits__two32 * rhat) + un0))) break; | ||
| 5495 | + q0--; | ||
| 5496 | + rhat += yn1; | ||
| 5497 | + if (rhat >= _const_math__bits__two32) { | ||
| 5498 | + break; | ||
| 5499 | + } | ||
| 5500 | + } | ||
| 5501 | + u64 qq = ((q1 * _const_math__bits__two32) + q0); | ||
| 5502 | + u64 rr = v__rshift_u64(((un21 * _const_math__bits__two32) + un0 - (q0 * y)), (u64)s); | ||
| 5503 | + return (multi_return_u64_u64){.arg0=qq, .arg1=rr}; | ||
| 5504 | +} | ||
| 5505 | +inline u32 math__bits__rem_32(u32 hi, u32 lo, u32 y) { | ||
| 5506 | + if (y == 0) { | ||
| 5507 | + builtin___v_panic(_const_math__bits__divide_error); | ||
| 5508 | + VUNREACHABLE(); | ||
| 5509 | + } | ||
| 5510 | + return ((u32)(VSAFE_MOD_u64((((v__lshift_u64(((u64)(hi)), (u64)32)) | ((u64)(lo)))) , ((u64)(y))))); | ||
| 5511 | +} | ||
| 5512 | +inline u64 math__bits__rem_64(u64 hi, u64 lo, u64 y) { | ||
| 5513 | + if (y == 0) { | ||
| 5514 | + builtin___v_panic(_const_math__bits__divide_error); | ||
| 5515 | + VUNREACHABLE(); | ||
| 5516 | + } | ||
| 5517 | + multi_return_u64_u64 mr_18593 = math__bits__div_64(VSAFE_MOD_u64(hi , y), lo, y); | ||
| 5518 | + u64 rem = mr_18593.arg1; | ||
| 5519 | + return rem; | ||
| 5520 | +} | ||
| 5521 | +multi_return_f64_int math__bits__normalize(f64 x) { | ||
| 5522 | + f64 smallest_normal = 2.2250738585072014e-308; | ||
| 5523 | + if (((x > ((f64)(0.0)) ? (x) : (-x))) < smallest_normal) { | ||
| 5524 | + return (multi_return_f64_int){.arg0=(f64)(x * (v__lshift_u64(((u64)(1)), (u64)((u64)(52))))), .arg1=-52}; | ||
| 5525 | + } | ||
| 5526 | + return (multi_return_f64_int){.arg0=x, .arg1=0}; | ||
| 5527 | +} | ||
| 5528 | +inline u32 math__bits__f32_bits(f32 f) { | ||
| 5529 | + u32 p = *((u32*)(&f)); | ||
| 5530 | + return p; | ||
| 5531 | +} | ||
| 5532 | +inline f32 math__bits__f32_from_bits(u32 b) { | ||
| 5533 | + f32 p = *((f32*)(&b)); | ||
| 5534 | + return p; | ||
| 5535 | +} | ||
| 5536 | +inline u64 math__bits__f64_bits(f64 f) { | ||
| 5537 | + u64 p = *((u64*)(&f)); | ||
| 5538 | + return p; | ||
| 5539 | +} | ||
| 5540 | +inline f64 math__bits__f64_from_bits(u64 b) { | ||
| 5541 | + f64 p = *((f64*)(&b)); | ||
| 5542 | + return p; | ||
| 5543 | +} | ||
| 5544 | +VV_LOC multi_return_u32_u32_u32 strconv__lsr96(u32 s2, u32 s1, u32 s0) { | ||
| 5545 | + u32 r0 = ((u32)(0)); | ||
| 5546 | + u32 r1 = ((u32)(0)); | ||
| 5547 | + u32 r2 = ((u32)(0)); | ||
| 5548 | + r0 = ((v__rshift_u32(s0, (u64)1)) | (v__lshift_u32(((s1 & ((u32)(1)))), (u64)31))); | ||
| 5549 | + r1 = ((v__rshift_u32(s1, (u64)1)) | (v__lshift_u32(((s2 & ((u32)(1)))), (u64)31))); | ||
| 5550 | + r2 = v__rshift_u32(s2, (u64)1); | ||
| 5551 | + return (multi_return_u32_u32_u32){.arg0=r2, .arg1=r1, .arg2=r0}; | ||
| 5552 | +} | ||
| 5553 | +VV_LOC multi_return_u32_u32_u32 strconv__lsl96(u32 s2, u32 s1, u32 s0) { | ||
| 5554 | + u32 r0 = ((u32)(0)); | ||
| 5555 | + u32 r1 = ((u32)(0)); | ||
| 5556 | + u32 r2 = ((u32)(0)); | ||
| 5557 | + r2 = ((v__lshift_u32(s2, (u64)1)) | (v__rshift_u32(((s1 & (v__lshift_u32(((u32)(1)), (u64)31)))), (u64)31))); | ||
| 5558 | + r1 = ((v__lshift_u32(s1, (u64)1)) | (v__rshift_u32(((s0 & (v__lshift_u32(((u32)(1)), (u64)31)))), (u64)31))); | ||
| 5559 | + r0 = v__lshift_u32(s0, (u64)1); | ||
| 5560 | + return (multi_return_u32_u32_u32){.arg0=r2, .arg1=r1, .arg2=r0}; | ||
| 5561 | +} | ||
| 5562 | +VV_LOC multi_return_u32_u32_u32 strconv__add96(u32 s2, u32 s1, u32 s0, u32 d2, u32 d1, u32 d0) { | ||
| 5563 | + u64 w = ((u64)(0)); | ||
| 5564 | + u32 r0 = ((u32)(0)); | ||
| 5565 | + u32 r1 = ((u32)(0)); | ||
| 5566 | + u32 r2 = ((u32)(0)); | ||
| 5567 | + w = ((u64)(s0)) + ((u64)(d0)); | ||
| 5568 | + r0 = ((u32)(w)); | ||
| 5569 | + w = v__rshift_u64(w, (u64)32); | ||
| 5570 | + w += ((u64)(s1)) + ((u64)(d1)); | ||
| 5571 | + r1 = ((u32)(w)); | ||
| 5572 | + w = v__rshift_u64(w, (u64)32); | ||
| 5573 | + w += ((u64)(s2)) + ((u64)(d2)); | ||
| 5574 | + r2 = ((u32)(w)); | ||
| 5575 | + return (multi_return_u32_u32_u32){.arg0=r2, .arg1=r1, .arg2=r0}; | ||
| 5576 | +} | ||
| 5577 | +VV_LOC multi_return_strconv__ParserState_strconv__PrepNumber strconv__parser(string s) { | ||
| 5578 | + int digx = 0; | ||
| 5579 | + strconv__ParserState result = strconv__ParserState__ok; | ||
| 5580 | + bool expneg = false; | ||
| 5581 | + int expexp = 0; | ||
| 5582 | + int i = 0; | ||
| 5583 | + strconv__PrepNumber _t1 = ((strconv__PrepNumber){.negative = 0,.exponent = 0,.mantissa = 0,}); | ||
| 5584 | + strconv__PrepNumber pn = _t1; | ||
| 5585 | + for (;;) { | ||
| 5586 | + if (!(i < s.len && builtin__u8_is_space(s.str[ i]))) break; | ||
| 5587 | + i++; | ||
| 5588 | + } | ||
| 5589 | + if (s.str[ i] == '-') { | ||
| 5590 | + pn.negative = true; | ||
| 5591 | + i++; | ||
| 5592 | + } | ||
| 5593 | + if (s.str[ i] == '+') { | ||
| 5594 | + i++; | ||
| 5595 | + } | ||
| 5596 | + for (;;) { | ||
| 5597 | + if (!(i < s.len && builtin__u8_is_digit(s.str[ i]))) break; | ||
| 5598 | + if (pn.mantissa == 0 && s.str[ i] == _const_strconv__c_zero) { | ||
| 5599 | + i++; | ||
| 5600 | + continue; | ||
| 5601 | + } | ||
| 5602 | + if (digx < 18) { | ||
| 5603 | + pn.mantissa *= 10; | ||
| 5604 | + pn.mantissa += ((u64)((rune)(s.str[ i] - _const_strconv__c_zero))); | ||
| 5605 | + digx++; | ||
| 5606 | + } else if (pn.exponent < 2147483647) { | ||
| 5607 | + pn.exponent++; | ||
| 5608 | + } | ||
| 5609 | + i++; | ||
| 5610 | + } | ||
| 5611 | + if (i < s.len && s.str[ i] == '.') { | ||
| 5612 | + i++; | ||
| 5613 | + for (;;) { | ||
| 5614 | + if (!(i < s.len && builtin__u8_is_digit(s.str[ i]))) break; | ||
| 5615 | + if (pn.mantissa == 0 && s.str[ i] == _const_strconv__c_zero) { | ||
| 5616 | + pn.exponent--; | ||
| 5617 | + i++; | ||
| 5618 | + continue; | ||
| 5619 | + } | ||
| 5620 | + if (digx < 18) { | ||
| 5621 | + pn.mantissa *= 10; | ||
| 5622 | + pn.mantissa += ((u64)((rune)(s.str[ i] - _const_strconv__c_zero))); | ||
| 5623 | + pn.exponent--; | ||
| 5624 | + digx++; | ||
| 5625 | + } | ||
| 5626 | + i++; | ||
| 5627 | + } | ||
| 5628 | + } | ||
| 5629 | + if (i < s.len && (s.str[ i] == 'e' || s.str[ i] == 'E')) { | ||
| 5630 | + i++; | ||
| 5631 | + if (i < s.len) { | ||
| 5632 | + if (s.str[ i] == _const_strconv__c_plus) { | ||
| 5633 | + i++; | ||
| 5634 | + } else if (s.str[ i] == _const_strconv__c_minus) { | ||
| 5635 | + expneg = true; | ||
| 5636 | + i++; | ||
| 5637 | + } | ||
| 5638 | + for (;;) { | ||
| 5639 | + if (!(i < s.len && builtin__u8_is_digit(s.str[ i]))) break; | ||
| 5640 | + if (expexp < 214748364) { | ||
| 5641 | + expexp *= 10; | ||
| 5642 | + expexp += ((int)((rune)(s.str[ i] - _const_strconv__c_zero))); | ||
| 5643 | + } | ||
| 5644 | + i++; | ||
| 5645 | + } | ||
| 5646 | + } | ||
| 5647 | + } | ||
| 5648 | + if (expneg) { | ||
| 5649 | + expexp = -expexp; | ||
| 5650 | + } | ||
| 5651 | + pn.exponent += expexp; | ||
| 5652 | + if (pn.mantissa == 0) { | ||
| 5653 | + if (pn.negative) { | ||
| 5654 | + result = strconv__ParserState__mzero; | ||
| 5655 | + } else { | ||
| 5656 | + result = strconv__ParserState__pzero; | ||
| 5657 | + } | ||
| 5658 | + } else if (pn.exponent > 309) { | ||
| 5659 | + if (pn.negative) { | ||
| 5660 | + result = strconv__ParserState__minf; | ||
| 5661 | + } else { | ||
| 5662 | + result = strconv__ParserState__pinf; | ||
| 5663 | + } | ||
| 5664 | + } else if (pn.exponent < -328) { | ||
| 5665 | + if (pn.negative) { | ||
| 5666 | + result = strconv__ParserState__mzero; | ||
| 5667 | + } else { | ||
| 5668 | + result = strconv__ParserState__pzero; | ||
| 5669 | + } | ||
| 5670 | + } | ||
| 5671 | + if (i == 0 && s.len > 0) { | ||
| 5672 | + return (multi_return_strconv__ParserState_strconv__PrepNumber){.arg0=strconv__ParserState__invalid_number, .arg1=pn}; | ||
| 5673 | + } | ||
| 5674 | + if (i != s.len) { | ||
| 5675 | + return (multi_return_strconv__ParserState_strconv__PrepNumber){.arg0=strconv__ParserState__extra_char, .arg1=pn}; | ||
| 5676 | + } | ||
| 5677 | + return (multi_return_strconv__ParserState_strconv__PrepNumber){.arg0=result, .arg1=pn}; | ||
| 5678 | +} | ||
| 5679 | +VV_LOC u64 strconv__converter(strconv__PrepNumber* pn) { | ||
| 5680 | + int binexp = 92; | ||
| 5681 | + u32 s2 = ((u32)(0)); | ||
| 5682 | + u32 s1 = ((u32)(0)); | ||
| 5683 | + u32 s0 = ((u32)(0)); | ||
| 5684 | + u32 q2 = ((u32)(0)); | ||
| 5685 | + u32 q1 = ((u32)(0)); | ||
| 5686 | + u32 q0 = ((u32)(0)); | ||
| 5687 | + u32 r2 = ((u32)(0)); | ||
| 5688 | + u32 r1 = ((u32)(0)); | ||
| 5689 | + u32 r0 = ((u32)(0)); | ||
| 5690 | + u32 mask28 = ((u32)(v__lshift_u64(((u64)(0xF)), (u64)28))); | ||
| 5691 | + u64 result = ((u64)(0)); | ||
| 5692 | + s0 = ((u32)((pn->mantissa & ((u64)(0x00000000FFFFFFFFU))))); | ||
| 5693 | + s1 = ((u32)(v__rshift_u64(pn->mantissa, (u64)32))); | ||
| 5694 | + s2 = ((u32)(0)); | ||
| 5695 | + if (pn->mantissa == 0 && pn->exponent <= 0) { | ||
| 5696 | + return (pn->negative ? (_const_strconv__double_minus_zero) : (_const_strconv__double_plus_zero)); | ||
| 5697 | + } | ||
| 5698 | + for (;;) { | ||
| 5699 | + if (!(pn->exponent > 0)) break; | ||
| 5700 | + multi_return_u32_u32_u32 mr_5881 = strconv__lsl96(s2, s1, s0); | ||
| 5701 | + q2 = mr_5881.arg0; | ||
| 5702 | + q1 = mr_5881.arg1; | ||
| 5703 | + q0 = mr_5881.arg2; | ||
| 5704 | + multi_return_u32_u32_u32 mr_5927 = strconv__lsl96(q2, q1, q0); | ||
| 5705 | + r2 = mr_5927.arg0; | ||
| 5706 | + r1 = mr_5927.arg1; | ||
| 5707 | + r0 = mr_5927.arg2; | ||
| 5708 | + multi_return_u32_u32_u32 mr_5983 = strconv__lsl96(r2, r1, r0); | ||
| 5709 | + s2 = mr_5983.arg0; | ||
| 5710 | + s1 = mr_5983.arg1; | ||
| 5711 | + s0 = mr_5983.arg2; | ||
| 5712 | + multi_return_u32_u32_u32 mr_6039 = strconv__add96(s2, s1, s0, q2, q1, q0); | ||
| 5713 | + s2 = mr_6039.arg0; | ||
| 5714 | + s1 = mr_6039.arg1; | ||
| 5715 | + s0 = mr_6039.arg2; | ||
| 5716 | + pn->exponent--; | ||
| 5717 | + for (;;) { | ||
| 5718 | + if (!(((s2 & mask28)) != 0)) break; | ||
| 5719 | + multi_return_u32_u32_u32 mr_6162 = strconv__lsr96(s2, s1, s0); | ||
| 5720 | + q2 = mr_6162.arg0; | ||
| 5721 | + q1 = mr_6162.arg1; | ||
| 5722 | + q0 = mr_6162.arg2; | ||
| 5723 | + binexp++; | ||
| 5724 | + s2 = q2; | ||
| 5725 | + s1 = q1; | ||
| 5726 | + s0 = q0; | ||
| 5727 | + } | ||
| 5728 | + } | ||
| 5729 | + for (;;) { | ||
| 5730 | + if (!(pn->exponent < 0)) break; | ||
| 5731 | + for (;;) { | ||
| 5732 | + if (!(!(((s2 & (v__lshift_u32(((u32)(1)), (u64)31)))) != 0))) break; | ||
| 5733 | + multi_return_u32_u32_u32 mr_6309 = strconv__lsl96(s2, s1, s0); | ||
| 5734 | + q2 = mr_6309.arg0; | ||
| 5735 | + q1 = mr_6309.arg1; | ||
| 5736 | + q0 = mr_6309.arg2; | ||
| 5737 | + binexp--; | ||
| 5738 | + s2 = q2; | ||
| 5739 | + s1 = q1; | ||
| 5740 | + s0 = q0; | ||
| 5741 | + } | ||
| 5742 | + q2 = VSAFE_DIV_u32(s2 , _const_strconv__c_ten); | ||
| 5743 | + r1 = VSAFE_MOD_u32(s2 , _const_strconv__c_ten); | ||
| 5744 | + r2 = ((v__rshift_u32(s1, (u64)8)) | (v__lshift_u32(r1, (u64)24))); | ||
| 5745 | + q1 = VSAFE_DIV_u32(r2 , _const_strconv__c_ten); | ||
| 5746 | + r1 = VSAFE_MOD_u32(r2 , _const_strconv__c_ten); | ||
| 5747 | + r2 = (((v__lshift_u32(((s1 & ((u32)(0xFF)))), (u64)16)) | (v__rshift_u32(s0, (u64)16))) | (v__lshift_u32(r1, (u64)24))); | ||
| 5748 | + r0 = VSAFE_DIV_u32(r2 , _const_strconv__c_ten); | ||
| 5749 | + r1 = VSAFE_MOD_u32(r2 , _const_strconv__c_ten); | ||
| 5750 | + q1 = ((v__lshift_u32(q1, (u64)8)) | (v__rshift_u32(((r0 & ((u32)(0x00FF0000)))), (u64)16))); | ||
| 5751 | + q0 = v__lshift_u32(r0, (u64)16); | ||
| 5752 | + r2 = (((s0 & ((u32)(0xFFFF)))) | (v__lshift_u32(r1, (u64)16))); | ||
| 5753 | + q0 |= VSAFE_DIV_u32(r2 , _const_strconv__c_ten); | ||
| 5754 | + s2 = q2; | ||
| 5755 | + s1 = q1; | ||
| 5756 | + s0 = q0; | ||
| 5757 | + pn->exponent++; | ||
| 5758 | + } | ||
| 5759 | + if (s2 != 0 || s1 != 0 || s0 != 0) { | ||
| 5760 | + for (;;) { | ||
| 5761 | + if (!(((s2 & mask28)) == 0)) break; | ||
| 5762 | + multi_return_u32_u32_u32 mr_6989 = strconv__lsl96(s2, s1, s0); | ||
| 5763 | + q2 = mr_6989.arg0; | ||
| 5764 | + q1 = mr_6989.arg1; | ||
| 5765 | + q0 = mr_6989.arg2; | ||
| 5766 | + binexp--; | ||
| 5767 | + s2 = q2; | ||
| 5768 | + s1 = q1; | ||
| 5769 | + s0 = q0; | ||
| 5770 | + } | ||
| 5771 | + } | ||
| 5772 | + if (binexp < -1022 && ((s2 | s1)) != 0) { | ||
| 5773 | + int shift = -1022 - binexp; | ||
| 5774 | + if (shift > 60) { | ||
| 5775 | + return (pn->negative ? (_const_strconv__double_minus_zero) : (_const_strconv__double_plus_zero)); | ||
| 5776 | + } | ||
| 5777 | + u64 shifted = v__rshift_u64((((v__lshift_u64(((u64)(s2)), (u64)32)) | ((u64)(s1)))), (u64)((u32)(shift))); | ||
| 5778 | + u64 q = (v__rshift_u64(shifted, (u64)8)) + (u64[]){(((v__rshift_u64(shifted, (u64)7)) & 1) != 0 && (((shifted & 0x7F)) != 0 || ((v__rshift_u64(shifted, (u64)8)) & 1) != 0))?1:0}[0]; | ||
| 5779 | + return (((q & 0x000FFFFFFFFFFFFFLL)) | (v__lshift_u64((u64[]){(pn->negative)?1:0}[0], (u64)63))); | ||
| 5780 | + } | ||
| 5781 | + int nbit = 7; | ||
| 5782 | + u32 check_round_bit = v__lshift_u32(((u32)(1)), (u64)((u32)(nbit))); | ||
| 5783 | + u32 check_round_mask = v__lshift_u32(((u32)(0xFFFFFFFFU)), (u64)((u32)(nbit))); | ||
| 5784 | + if (((s1 & check_round_bit)) != 0) { | ||
| 5785 | + if (((s1 & ~check_round_mask)) != 0) { | ||
| 5786 | + multi_return_u32_u32_u32 mr_9182 = strconv__add96(s2, s1, s0, 0, check_round_bit, 0); | ||
| 5787 | + s2 = mr_9182.arg0; | ||
| 5788 | + s1 = mr_9182.arg1; | ||
| 5789 | + s0 = mr_9182.arg2; | ||
| 5790 | + } else { | ||
| 5791 | + if (((s1 & (v__lshift_u32(check_round_bit, (u64)((u32)(1)))))) != 0) { | ||
| 5792 | + multi_return_u32_u32_u32 mr_9376 = strconv__add96(s2, s1, s0, 0, check_round_bit, 0); | ||
| 5793 | + s2 = mr_9376.arg0; | ||
| 5794 | + s1 = mr_9376.arg1; | ||
| 5795 | + s0 = mr_9376.arg2; | ||
| 5796 | + } | ||
| 5797 | + } | ||
| 5798 | + s1 = (s1 & check_round_mask); | ||
| 5799 | + s0 = ((u32)(0)); | ||
| 5800 | + if ((s2 & (v__lshift_u32(mask28, (u64)((u32)(1))))) != 0) { | ||
| 5801 | + multi_return_u32_u32_u32 mr_9583 = strconv__lsr96(s2, s1, s0); | ||
| 5802 | + q2 = mr_9583.arg0; | ||
| 5803 | + q1 = mr_9583.arg1; | ||
| 5804 | + q0 = mr_9583.arg2; | ||
| 5805 | + binexp++; | ||
| 5806 | + s2 = q2; | ||
| 5807 | + s1 = q1; | ||
| 5808 | + s0 = q0; | ||
| 5809 | + } | ||
| 5810 | + } | ||
| 5811 | + binexp += 1023; | ||
| 5812 | + if (binexp > 2046) { | ||
| 5813 | + if (pn->negative) { | ||
| 5814 | + result = _const_strconv__double_minus_infinity; | ||
| 5815 | + } else { | ||
| 5816 | + result = _const_strconv__double_plus_infinity; | ||
| 5817 | + } | ||
| 5818 | + } else if (binexp < 1) { | ||
| 5819 | + if (pn->negative) { | ||
| 5820 | + result = _const_strconv__double_minus_zero; | ||
| 5821 | + } else { | ||
| 5822 | + result = _const_strconv__double_plus_zero; | ||
| 5823 | + } | ||
| 5824 | + } else if (s2 != 0) { | ||
| 5825 | + u64 q = ((u64)(0)); | ||
| 5826 | + u64 binexs2 = v__lshift_u64(((u64)(binexp)), (u64)52); | ||
| 5827 | + q = (((v__lshift_u64(((u64)((s2 & ~mask28))), (u64)24)) | (v__rshift_u64((((u64)(s1)) + ((u64)(128))), (u64)8))) | binexs2); | ||
| 5828 | + if (pn->negative) { | ||
| 5829 | + q |= (v__lshift_u64(((u64)(1)), (u64)63)); | ||
| 5830 | + } | ||
| 5831 | + result = q; | ||
| 5832 | + } | ||
| 5833 | + return result; | ||
| 5834 | +} | ||
| 5835 | +_result_f64 strconv__atof64(string s, strconv__AtoF64Param param) { | ||
| 5836 | + if (s.len == 0) { | ||
| 5837 | + return (_result_f64){ .is_error=true, .err=builtin___v_error(_S("expected a number found an empty string")), .data={E_STRUCT} }; | ||
| 5838 | + } | ||
| 5839 | + strconv__Float64u _t2 = ((strconv__Float64u){0}); | ||
| 5840 | + strconv__Float64u res = _t2; | ||
| 5841 | + multi_return_strconv__ParserState_strconv__PrepNumber mr_10868 = strconv__parser(s); | ||
| 5842 | + strconv__ParserState res_parsing = mr_10868.arg0; | ||
| 5843 | + strconv__PrepNumber pn = mr_10868.arg1; | ||
| 5844 | + switch (res_parsing) { | ||
| 5845 | + case strconv__ParserState__ok: { | ||
| 5846 | + res.u = strconv__converter((voidptr)&pn); | ||
| 5847 | + break; | ||
| 5848 | + } | ||
| 5849 | + case strconv__ParserState__pzero: { | ||
| 5850 | + res.u = _const_strconv__double_plus_zero; | ||
| 5851 | + break; | ||
| 5852 | + } | ||
| 5853 | + case strconv__ParserState__mzero: { | ||
| 5854 | + res.u = _const_strconv__double_minus_zero; | ||
| 5855 | + break; | ||
| 5856 | + } | ||
| 5857 | + case strconv__ParserState__pinf: { | ||
| 5858 | + res.u = _const_strconv__double_plus_infinity; | ||
| 5859 | + break; | ||
| 5860 | + } | ||
| 5861 | + case strconv__ParserState__minf: { | ||
| 5862 | + res.u = _const_strconv__double_minus_infinity; | ||
| 5863 | + break; | ||
| 5864 | + } | ||
| 5865 | + case strconv__ParserState__extra_char: { | ||
| 5866 | + if (param.allow_extra_chars) { | ||
| 5867 | + res.u = strconv__converter((voidptr)&pn); | ||
| 5868 | + } else { | ||
| 5869 | + return (_result_f64){ .is_error=true, .err=builtin___v_error(_S("extra char after number")), .data={E_STRUCT} }; | ||
| 5870 | + } | ||
| 5871 | + break; | ||
| 5872 | + } | ||
| 5873 | + case strconv__ParserState__invalid_number: { | ||
| 5874 | + return (_result_f64){ .is_error=true, .err=builtin___v_error(_S("not a number")), .data={E_STRUCT} }; | ||
| 5875 | + } | ||
| 5876 | + } | ||
| 5877 | + | ||
| 5878 | + _result_f64 _t5; | ||
| 5879 | + builtin___result_ok(&(f64[]) { res.f }, (_result*)(&_t5), sizeof(f64)); | ||
| 5880 | + | ||
| 5881 | + return _t5; | ||
| 5882 | +} | ||
| 5883 | +f64 strconv__atof_quick(string s) { | ||
| 5884 | + strconv__Float64u _t1 = ((strconv__Float64u){0}); | ||
| 5885 | + strconv__Float64u f = _t1; | ||
| 5886 | + f64 sign = ((f64)(1.0)); | ||
| 5887 | + int i = 0; | ||
| 5888 | + for (;;) { | ||
| 5889 | + if (!(i < s.len && s.str[ i] == ' ')) break; | ||
| 5890 | + i++; | ||
| 5891 | + } | ||
| 5892 | + if (i < s.len) { | ||
| 5893 | + if (s.str[ i] == '-') { | ||
| 5894 | + sign = -1.0; | ||
| 5895 | + i++; | ||
| 5896 | + } else if (s.str[ i] == '+') { | ||
| 5897 | + i++; | ||
| 5898 | + } | ||
| 5899 | + } | ||
| 5900 | + if (s.str[ i] == 'i' && i + 2 < s.len && s.str[ i + 1] == 'n' && s.str[ i + 2] == 'f') { | ||
| 5901 | + if (sign > ((f64)(0.0))) { | ||
| 5902 | + f.u = _const_strconv__double_plus_infinity; | ||
| 5903 | + } else { | ||
| 5904 | + f.u = _const_strconv__double_minus_infinity; | ||
| 5905 | + } | ||
| 5906 | + return f.f; | ||
| 5907 | + } | ||
| 5908 | + for (;;) { | ||
| 5909 | + if (!(i < s.len && s.str[ i] == '0')) break; | ||
| 5910 | + i++; | ||
| 5911 | + if (i >= s.len) { | ||
| 5912 | + if (sign > ((f64)(0.0))) { | ||
| 5913 | + f.u = _const_strconv__double_plus_zero; | ||
| 5914 | + } else { | ||
| 5915 | + f.u = _const_strconv__double_minus_zero; | ||
| 5916 | + } | ||
| 5917 | + return f.f; | ||
| 5918 | + } | ||
| 5919 | + } | ||
| 5920 | + for (;;) { | ||
| 5921 | + if (!(i < s.len && (s.str[ i] >= '0' && s.str[ i] <= '9'))) break; | ||
| 5922 | + f.f *= ((f64)(10.0)); | ||
| 5923 | + f.f += ((f64)((rune)(s.str[ i] - '0'))); | ||
| 5924 | + i++; | ||
| 5925 | + } | ||
| 5926 | + if (i < s.len && s.str[ i] == '.') { | ||
| 5927 | + i++; | ||
| 5928 | + f64 frac_mul = ((f64)(0.1)); | ||
| 5929 | + for (;;) { | ||
| 5930 | + if (!(i < s.len && (s.str[ i] >= '0' && s.str[ i] <= '9'))) break; | ||
| 5931 | + f.f += ((f64)((rune)(s.str[ i] - '0'))) * frac_mul; | ||
| 5932 | + frac_mul *= ((f64)(0.1)); | ||
| 5933 | + i++; | ||
| 5934 | + } | ||
| 5935 | + } | ||
| 5936 | + if (i < s.len && (s.str[ i] == 'e' || s.str[ i] == 'E')) { | ||
| 5937 | + i++; | ||
| 5938 | + int exp = 0; | ||
| 5939 | + int exp_sign = 1; | ||
| 5940 | + if (i < s.len) { | ||
| 5941 | + if (s.str[ i] == '-') { | ||
| 5942 | + exp_sign = -1; | ||
| 5943 | + i++; | ||
| 5944 | + } else if (s.str[ i] == '+') { | ||
| 5945 | + i++; | ||
| 5946 | + } | ||
| 5947 | + } | ||
| 5948 | + for (;;) { | ||
| 5949 | + if (!(i < s.len && s.str[ i] == '0')) break; | ||
| 5950 | + i++; | ||
| 5951 | + } | ||
| 5952 | + for (;;) { | ||
| 5953 | + if (!(i < s.len && (s.str[ i] >= '0' && s.str[ i] <= '9'))) break; | ||
| 5954 | + exp *= 10; | ||
| 5955 | + exp += ((int)((rune)(s.str[ i] - '0'))); | ||
| 5956 | + i++; | ||
| 5957 | + } | ||
| 5958 | + if (exp_sign == 1) { | ||
| 5959 | + if (exp > 309) { | ||
| 5960 | + if (sign > 0) { | ||
| 5961 | + f.u = _const_strconv__double_plus_infinity; | ||
| 5962 | + } else { | ||
| 5963 | + f.u = _const_strconv__double_minus_infinity; | ||
| 5964 | + } | ||
| 5965 | + return f.f; | ||
| 5966 | + } | ||
| 5967 | + strconv__Float64u _t5 = ((strconv__Float64u){.u = _const_strconv__pos_exp[exp],}); | ||
| 5968 | + strconv__Float64u tmp_mul = _t5; | ||
| 5969 | + f.f = f.f * tmp_mul.f; | ||
| 5970 | + } else { | ||
| 5971 | + if (exp > 324) { | ||
| 5972 | + if (sign > 0) { | ||
| 5973 | + f.u = _const_strconv__double_plus_zero; | ||
| 5974 | + } else { | ||
| 5975 | + f.u = _const_strconv__double_minus_zero; | ||
| 5976 | + } | ||
| 5977 | + return f.f; | ||
| 5978 | + } | ||
| 5979 | + strconv__Float64u _t7 = ((strconv__Float64u){.u = _const_strconv__neg_exp[exp],}); | ||
| 5980 | + strconv__Float64u tmp_mul = _t7; | ||
| 5981 | + f.f = f.f * tmp_mul.f; | ||
| 5982 | + } | ||
| 5983 | + } | ||
| 5984 | + { // Unsafe block | ||
| 5985 | + f.f = f.f * sign; | ||
| 5986 | + return f.f; | ||
| 5987 | + } | ||
| 5988 | + return 0; | ||
| 5989 | +} | ||
| 5990 | +inline u8 strconv__byte_to_lower(u8 c) { | ||
| 5991 | + return (c | 32); | ||
| 5992 | +} | ||
| 5993 | +_result_u64 strconv__common_parse_uint(string s, int _base, int _bit_size, bool error_on_non_digit, bool error_on_high_digit) { | ||
| 5994 | + multi_return_u64_int mr_730 = strconv__common_parse_uint2(s, _base, _bit_size); | ||
| 5995 | + u64 result = mr_730.arg0; | ||
| 5996 | + int err = mr_730.arg1; | ||
| 5997 | + if (err != 0 && (error_on_non_digit || error_on_high_digit)) { | ||
| 5998 | + switch (err) { | ||
| 5999 | + case -1: { | ||
| 6000 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(4, _MOV((string[4]){_S("common_parse_uint: wrong base "), builtin__int_str(_base), _S(" for "), s}))), .data={E_STRUCT} }; | ||
| 6001 | + } | ||
| 6002 | + case -2: { | ||
| 6003 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(4, _MOV((string[4]){_S("common_parse_uint: wrong bit size "), builtin__int_str(_bit_size), _S(" for "), s}))), .data={E_STRUCT} }; | ||
| 6004 | + } | ||
| 6005 | + case -3: { | ||
| 6006 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(2, _MOV((string[2]){_S("common_parse_uint: integer overflow "), s}))), .data={E_STRUCT} }; | ||
| 6007 | + } | ||
| 6008 | + default: { | ||
| 6009 | + { | ||
| 6010 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(2, _MOV((string[2]){_S("common_parse_uint: syntax error "), s}))), .data={E_STRUCT} }; | ||
| 6011 | + } | ||
| 6012 | + } | ||
| 6013 | + } | ||
| 6014 | + | ||
| 6015 | + } | ||
| 6016 | + _result_u64 _t5; | ||
| 6017 | + builtin___result_ok(&(u64[]) { result }, (_result*)(&_t5), sizeof(u64)); | ||
| 6018 | + | ||
| 6019 | + return _t5; | ||
| 6020 | +} | ||
| 6021 | +multi_return_u64_int strconv__common_parse_uint2(string s, int _base, int _bit_size) { | ||
| 6022 | + if ((s).len == 0) { | ||
| 6023 | + return (multi_return_u64_int){.arg0=((u64)(0)), .arg1=1}; | ||
| 6024 | + } | ||
| 6025 | + int bit_size = _bit_size; | ||
| 6026 | + int base = _base; | ||
| 6027 | + int start_index = 0; | ||
| 6028 | + if (base == 0) { | ||
| 6029 | + base = 10; | ||
| 6030 | + if (s.str[ 0] == '0') { | ||
| 6031 | + u8 ch = (s.len > 1 ? ((s.str[ 1] | 32)) : ('0')); | ||
| 6032 | + if (s.len >= 3) { | ||
| 6033 | + if (ch == 'b') { | ||
| 6034 | + base = 2; | ||
| 6035 | + start_index += 2; | ||
| 6036 | + } else if (ch == 'o') { | ||
| 6037 | + base = 8; | ||
| 6038 | + start_index += 2; | ||
| 6039 | + } else if (ch == 'x') { | ||
| 6040 | + base = 16; | ||
| 6041 | + start_index += 2; | ||
| 6042 | + } | ||
| 6043 | + if (s.str[ start_index] == '_') { | ||
| 6044 | + start_index++; | ||
| 6045 | + } | ||
| 6046 | + } else if (s.len >= 2 && (s.str[ 1] >= '0' && s.str[ 1] <= '9')) { | ||
| 6047 | + base = 10; | ||
| 6048 | + start_index++; | ||
| 6049 | + } else { | ||
| 6050 | + base = 8; | ||
| 6051 | + start_index++; | ||
| 6052 | + } | ||
| 6053 | + } | ||
| 6054 | + } | ||
| 6055 | + if (bit_size == 0) { | ||
| 6056 | + bit_size = _const_strconv__int_size; | ||
| 6057 | + } else if (bit_size < 0 || bit_size > 64) { | ||
| 6058 | + return (multi_return_u64_int){.arg0=((u64)(0)), .arg1=-2}; | ||
| 6059 | + } | ||
| 6060 | + u64 cutoff = VSAFE_DIV_u64(_const_max_u64 , ((u64)(base))) + ((u64)(1)); | ||
| 6061 | + u64 max_val = (bit_size == 64 ? (_const_max_u64) : ((v__lshift_u64(((u64)(1)), (u64)((u64)(bit_size)))) - ((u64)(1)))); | ||
| 6062 | + int basem1 = base - 1; | ||
| 6063 | + u64 n = ((u64)(0)); | ||
| 6064 | + for (int i = start_index; i < s.len; ++i) { | ||
| 6065 | + u8 c = s.str[ i]; | ||
| 6066 | + if (c == '_') { | ||
| 6067 | + if (i == start_index || i >= (s.len - 1)) { | ||
| 6068 | + return (multi_return_u64_int){.arg0=((u64)(0)), .arg1=1}; | ||
| 6069 | + } | ||
| 6070 | + if (s.str[ i - 1] == '_' || s.str[ i + 1] == '_') { | ||
| 6071 | + return (multi_return_u64_int){.arg0=((u64)(0)), .arg1=1}; | ||
| 6072 | + } | ||
| 6073 | + continue; | ||
| 6074 | + } | ||
| 6075 | + int sub_count = 0; | ||
| 6076 | + c -= 48; | ||
| 6077 | + if (c >= 17) { | ||
| 6078 | + sub_count++; | ||
| 6079 | + c -= 7; | ||
| 6080 | + if (c >= 42) { | ||
| 6081 | + sub_count++; | ||
| 6082 | + c -= 32; | ||
| 6083 | + } | ||
| 6084 | + } | ||
| 6085 | + if (c > basem1 || (sub_count == 0 && c > 9)) { | ||
| 6086 | + return (multi_return_u64_int){.arg0=n, .arg1=i + 1}; | ||
| 6087 | + } | ||
| 6088 | + if (n >= cutoff) { | ||
| 6089 | + return (multi_return_u64_int){.arg0=max_val, .arg1=-3}; | ||
| 6090 | + } | ||
| 6091 | + n *= ((u64)(base)); | ||
| 6092 | + u64 n1 = n + ((u64)(c)); | ||
| 6093 | + if (n1 < n || n1 > max_val) { | ||
| 6094 | + return (multi_return_u64_int){.arg0=max_val, .arg1=-3}; | ||
| 6095 | + } | ||
| 6096 | + n = n1; | ||
| 6097 | + } | ||
| 6098 | + return (multi_return_u64_int){.arg0=n, .arg1=0}; | ||
| 6099 | +} | ||
| 6100 | +_result_u64 strconv__parse_uint(string s, int _base, int _bit_size) { | ||
| 6101 | + return strconv__common_parse_uint(s, _base, _bit_size, true, true); | ||
| 6102 | +} | ||
| 6103 | +_result_i64 strconv__common_parse_int(string _s, int base, int _bit_size, bool error_on_non_digit, bool error_on_high_digit) { | ||
| 6104 | + if ((_s).len == 0) { | ||
| 6105 | + _result_i64 _t1; | ||
| 6106 | + builtin___result_ok(&(i64[]) { ((i64)(0)) }, (_result*)(&_t1), sizeof(i64)); | ||
| 6107 | + | ||
| 6108 | + return _t1; | ||
| 6109 | + } | ||
| 6110 | + int bit_size = _bit_size; | ||
| 6111 | + if (bit_size == 0) { | ||
| 6112 | + bit_size = _const_strconv__int_size; | ||
| 6113 | + } | ||
| 6114 | + string s = _s; | ||
| 6115 | + bool neg = false; | ||
| 6116 | + if (s.str[ 0] == '+') { | ||
| 6117 | + { // Unsafe block | ||
| 6118 | + s = builtin__tos(s.str + 1, s.len - 1); | ||
| 6119 | + } | ||
| 6120 | + } else if (s.str[ 0] == '-') { | ||
| 6121 | + neg = true; | ||
| 6122 | + { // Unsafe block | ||
| 6123 | + s = builtin__tos(s.str + 1, s.len - 1); | ||
| 6124 | + } | ||
| 6125 | + } | ||
| 6126 | + _result_u64 _t2 = strconv__common_parse_uint(s, base, bit_size, error_on_non_digit, error_on_high_digit); | ||
| 6127 | + if (_t2.is_error) { | ||
| 6128 | + _result_i64 _t3 = {0}; | ||
| 6129 | + _t3.is_error = true; | ||
| 6130 | + _t3.err = _t2.err; | ||
| 6131 | + return _t3; | ||
| 6132 | + } | ||
| 6133 | + | ||
| 6134 | + u64 un = (*(u64*)_t2.data); | ||
| 6135 | + if (un == 0) { | ||
| 6136 | + _result_i64 _t4; | ||
| 6137 | + builtin___result_ok(&(i64[]) { ((i64)(0)) }, (_result*)(&_t4), sizeof(i64)); | ||
| 6138 | + | ||
| 6139 | + return _t4; | ||
| 6140 | + } | ||
| 6141 | + u64 cutoff = v__lshift_u64(((u64)(1)), (u64)((u64)(bit_size - 1))); | ||
| 6142 | + if (!neg && un >= cutoff) { | ||
| 6143 | + if (error_on_high_digit) { | ||
| 6144 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(2, _MOV((string[2]){_S("common_parse_int: integer overflow "), _s}))), .data={E_STRUCT} }; | ||
| 6145 | + } | ||
| 6146 | + _result_i64 _t6; | ||
| 6147 | + builtin___result_ok(&(i64[]) { ((i64)(cutoff - ((u64)(1)))) }, (_result*)(&_t6), sizeof(i64)); | ||
| 6148 | + | ||
| 6149 | + return _t6; | ||
| 6150 | + } | ||
| 6151 | + if (neg && un > cutoff) { | ||
| 6152 | + if (error_on_high_digit) { | ||
| 6153 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(2, _MOV((string[2]){_S("common_parse_int: integer overflow "), _s}))), .data={E_STRUCT} }; | ||
| 6154 | + } | ||
| 6155 | + _result_i64 _t8; | ||
| 6156 | + builtin___result_ok(&(i64[]) { -((i64)(cutoff)) }, (_result*)(&_t8), sizeof(i64)); | ||
| 6157 | + | ||
| 6158 | + return _t8; | ||
| 6159 | + } | ||
| 6160 | + _result_i64 _t10; /* if prepend */ | ||
| 6161 | + if (neg) { | ||
| 6162 | + builtin___result_ok(&(i64[]) { -((i64)(un)) }, (_result*)(&_t10), sizeof(i64)); | ||
| 6163 | + goto _t11; | ||
| 6164 | + }; | ||
| 6165 | + { | ||
| 6166 | + builtin___result_ok(&(i64[]) { ((i64)(un)) }, (_result*)(&_t10), sizeof(i64)); | ||
| 6167 | + } | ||
| 6168 | + _t11: {}; | ||
| 6169 | + return _t10; | ||
| 6170 | +} | ||
| 6171 | +_result_i64 strconv__parse_int(string _s, int base, int _bit_size) { | ||
| 6172 | + return strconv__common_parse_int(_s, base, _bit_size, true, false); | ||
| 6173 | +} | ||
| 6174 | +VV_LOC _result_multi_return_i64_int strconv__atoi_common_check(string s) { | ||
| 6175 | + if ((s).len == 0) { | ||
| 6176 | + return (_result_multi_return_i64_int){ .is_error=true, .err=builtin___v_error(_S("strconv.atoi: parsing \"\": empty string")), .data={E_STRUCT} }; | ||
| 6177 | + } | ||
| 6178 | + int start_idx = 0; | ||
| 6179 | + i64 sign = ((i64)(1)); | ||
| 6180 | + if (s.str[ 0] == '-' || s.str[ 0] == '+') { | ||
| 6181 | + start_idx++; | ||
| 6182 | + if (s.str[ 0] == '-') { | ||
| 6183 | + sign = -1; | ||
| 6184 | + } | ||
| 6185 | + } | ||
| 6186 | + if (s.len - start_idx < 1) { | ||
| 6187 | + return (_result_multi_return_i64_int){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi: parsing \""), s, _S("\": no number after sign")}))), .data={E_STRUCT} }; | ||
| 6188 | + } | ||
| 6189 | + if (s.str[ start_idx] == '_' || s.str[ s.len - 1] == '_') { | ||
| 6190 | + return (_result_multi_return_i64_int){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi: parsing \""), s, _S("\": values cannot start or end with underscores")}))), .data={E_STRUCT} }; | ||
| 6191 | + } | ||
| 6192 | + _result_multi_return_i64_int _t4; | ||
| 6193 | + builtin___result_ok(&(multi_return_i64_int[]) { (multi_return_i64_int){.arg0=sign, .arg1=start_idx} }, (_result*)(&_t4), sizeof(multi_return_i64_int)); | ||
| 6194 | + return _t4; | ||
| 6195 | +} | ||
| 6196 | +VV_LOC _result_i64 strconv__atoi_common(string s, i64 type_min, i64 type_max) { | ||
| 6197 | + _result_multi_return_i64_int _t1 = strconv__atoi_common_check(s); | ||
| 6198 | + if (_t1.is_error) { | ||
| 6199 | + _result_i64 _t2 = {0}; | ||
| 6200 | + _t2.is_error = true; | ||
| 6201 | + _t2.err = _t1.err; | ||
| 6202 | + return _t2; | ||
| 6203 | + } | ||
| 6204 | + | ||
| 6205 | + multi_return_i64_int mr_7450 = (*(multi_return_i64_int*)_t1.data); | ||
| 6206 | + i64 sign = mr_7450.arg0; | ||
| 6207 | + int start_idx = mr_7450.arg1; | ||
| 6208 | + i64 x = ((i64)(0)); | ||
| 6209 | + bool underscored = false; | ||
| 6210 | + for (int i = start_idx; i < s.len; ++i) { | ||
| 6211 | + rune c = (rune)(s.str[ i] - '0'); | ||
| 6212 | + if (c == 47) { | ||
| 6213 | + if (underscored == true) { | ||
| 6214 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi: parsing \""), s, _S("\": consecutives underscores are not allowed")}))), .data={E_STRUCT} }; | ||
| 6215 | + } | ||
| 6216 | + underscored = true; | ||
| 6217 | + continue; | ||
| 6218 | + } else { | ||
| 6219 | + if (c > 9) { | ||
| 6220 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi: parsing \""), s, _S("\": invalid radix 10 character")}))), .data={E_STRUCT} }; | ||
| 6221 | + } | ||
| 6222 | + underscored = false; | ||
| 6223 | + x = (x * 10) + ((i64)(c * sign)); | ||
| 6224 | + if (sign == 1 && x > type_max) { | ||
| 6225 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi: parsing \""), s, _S("\": integer overflow")}))), .data={E_STRUCT} }; | ||
| 6226 | + } else { | ||
| 6227 | + if (x < type_min) { | ||
| 6228 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi: parsing \""), s, _S("\": integer underflow")}))), .data={E_STRUCT} }; | ||
| 6229 | + } | ||
| 6230 | + } | ||
| 6231 | + } | ||
| 6232 | + } | ||
| 6233 | + _result_i64 _t7; | ||
| 6234 | + builtin___result_ok(&(i64[]) { x }, (_result*)(&_t7), sizeof(i64)); | ||
| 6235 | + | ||
| 6236 | + return _t7; | ||
| 6237 | +} | ||
| 6238 | +_result_int strconv__atoi(string s) { | ||
| 6239 | + _result_i64 _t2 = strconv__atoi_common(s, _const_strconv__i64_min_int32, _const_strconv__i64_max_int32); | ||
| 6240 | + if (_t2.is_error) { | ||
| 6241 | + _result_int _t3 = {0}; | ||
| 6242 | + _t3.is_error = true; | ||
| 6243 | + _t3.err = _t2.err; | ||
| 6244 | + return _t3; | ||
| 6245 | + } | ||
| 6246 | + | ||
| 6247 | + _result_int _t1; | ||
| 6248 | + builtin___result_ok(&(int[]) { ((int)((*(i64*)_t2.data))) }, (_result*)(&_t1), sizeof(int)); | ||
| 6249 | + | ||
| 6250 | + return _t1; | ||
| 6251 | +} | ||
| 6252 | +_result_i8 strconv__atoi8(string s) { | ||
| 6253 | + _result_i64 _t2 = strconv__atoi_common(s, _const_min_i8, _const_max_i8); | ||
| 6254 | + if (_t2.is_error) { | ||
| 6255 | + _result_i8 _t3 = {0}; | ||
| 6256 | + _t3.is_error = true; | ||
| 6257 | + _t3.err = _t2.err; | ||
| 6258 | + return _t3; | ||
| 6259 | + } | ||
| 6260 | + | ||
| 6261 | + _result_i8 _t1; | ||
| 6262 | + builtin___result_ok(&(i8[]) { ((i8)((*(i64*)_t2.data))) }, (_result*)(&_t1), sizeof(i8)); | ||
| 6263 | + | ||
| 6264 | + return _t1; | ||
| 6265 | +} | ||
| 6266 | +_result_i16 strconv__atoi16(string s) { | ||
| 6267 | + _result_i64 _t2 = strconv__atoi_common(s, _const_min_i16, _const_max_i16); | ||
| 6268 | + if (_t2.is_error) { | ||
| 6269 | + _result_i16 _t3 = {0}; | ||
| 6270 | + _t3.is_error = true; | ||
| 6271 | + _t3.err = _t2.err; | ||
| 6272 | + return _t3; | ||
| 6273 | + } | ||
| 6274 | + | ||
| 6275 | + _result_i16 _t1; | ||
| 6276 | + builtin___result_ok(&(i16[]) { ((i16)((*(i64*)_t2.data))) }, (_result*)(&_t1), sizeof(i16)); | ||
| 6277 | + | ||
| 6278 | + return _t1; | ||
| 6279 | +} | ||
| 6280 | +_result_i32 strconv__atoi32(string s) { | ||
| 6281 | + _result_i64 _t2 = strconv__atoi_common(s, _const_min_i32, _const_max_i32); | ||
| 6282 | + if (_t2.is_error) { | ||
| 6283 | + _result_i32 _t3 = {0}; | ||
| 6284 | + _t3.is_error = true; | ||
| 6285 | + _t3.err = _t2.err; | ||
| 6286 | + return _t3; | ||
| 6287 | + } | ||
| 6288 | + | ||
| 6289 | + _result_i32 _t1; | ||
| 6290 | + builtin___result_ok(&(i32[]) { ((i32)((*(i64*)_t2.data))) }, (_result*)(&_t1), sizeof(i32)); | ||
| 6291 | + | ||
| 6292 | + return _t1; | ||
| 6293 | +} | ||
| 6294 | +_result_i64 strconv__atoi64(string s) { | ||
| 6295 | + _result_multi_return_i64_int _t1 = strconv__atoi_common_check(s); | ||
| 6296 | + if (_t1.is_error) { | ||
| 6297 | + _result_i64 _t2 = {0}; | ||
| 6298 | + _t2.is_error = true; | ||
| 6299 | + _t2.err = _t1.err; | ||
| 6300 | + return _t2; | ||
| 6301 | + } | ||
| 6302 | + | ||
| 6303 | + multi_return_i64_int mr_9202 = (*(multi_return_i64_int*)_t1.data); | ||
| 6304 | + i64 sign = mr_9202.arg0; | ||
| 6305 | + int start_idx = mr_9202.arg1; | ||
| 6306 | + i64 x = ((i64)(0)); | ||
| 6307 | + bool underscored = false; | ||
| 6308 | + for (int i = start_idx; i < s.len; ++i) { | ||
| 6309 | + rune c = (rune)(s.str[ i] - '0'); | ||
| 6310 | + if (c == 47) { | ||
| 6311 | + if (underscored == true) { | ||
| 6312 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi64: parsing \""), s, _S("\": consecutives underscores are not allowed")}))), .data={E_STRUCT} }; | ||
| 6313 | + } | ||
| 6314 | + underscored = true; | ||
| 6315 | + continue; | ||
| 6316 | + } else { | ||
| 6317 | + if (c > 9) { | ||
| 6318 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi64: parsing \""), s, _S("\": invalid radix 10 character")}))), .data={E_STRUCT} }; | ||
| 6319 | + } | ||
| 6320 | + underscored = false; | ||
| 6321 | + _result_i64 _t5 = strconv__safe_mul10_64bits(x); | ||
| 6322 | + if (_t5.is_error) { | ||
| 6323 | + IError _t6 = _t5.err; | ||
| 6324 | + IError err = _t6; | ||
| 6325 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__str_intp(3, _MOV((StrIntpData[]){{_S("strconv.atoi64: parsing \""), 0xfe10, {.d_s = s}, 0, 0, 0}, {_S("\": "), 0xfe10, {.d_s = builtin__IError_str(err)}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}))), .data={E_STRUCT} }; | ||
| 6326 | + } | ||
| 6327 | + | ||
| 6328 | + x = (*(i64*)_t5.data); | ||
| 6329 | + _result_i64 _t8 = strconv__safe_add_64bits(x, ((int)((i64)(c * sign)))); | ||
| 6330 | + if (_t8.is_error) { | ||
| 6331 | + IError _t9 = _t8.err; | ||
| 6332 | + IError err = _t9; | ||
| 6333 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__str_intp(3, _MOV((StrIntpData[]){{_S("strconv.atoi64: parsing \""), 0xfe10, {.d_s = s}, 0, 0, 0}, {_S("\": "), 0xfe10, {.d_s = builtin__IError_str(err)}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}))), .data={E_STRUCT} }; | ||
| 6334 | + } | ||
| 6335 | + | ||
| 6336 | + x = (*(i64*)_t8.data); | ||
| 6337 | + } | ||
| 6338 | + } | ||
| 6339 | + _result_i64 _t11; | ||
| 6340 | + builtin___result_ok(&(i64[]) { x }, (_result*)(&_t11), sizeof(i64)); | ||
| 6341 | + | ||
| 6342 | + return _t11; | ||
| 6343 | +} | ||
| 6344 | +inline VV_LOC _result_i64 strconv__safe_add_64bits(i64 a, i64 b) { | ||
| 6345 | + if (a > 0 && b > (_const_max_i64 - a)) { | ||
| 6346 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(_S("integer overflow")), .data={E_STRUCT} }; | ||
| 6347 | + } else if (a < 0 && b < (_const_min_i64 - a)) { | ||
| 6348 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(_S("integer underflow")), .data={E_STRUCT} }; | ||
| 6349 | + } | ||
| 6350 | + _result_i64 _t3; | ||
| 6351 | + builtin___result_ok(&(i64[]) { a + b }, (_result*)(&_t3), sizeof(i64)); | ||
| 6352 | + | ||
| 6353 | + return _t3; | ||
| 6354 | +} | ||
| 6355 | +inline VV_LOC _result_i64 strconv__safe_mul10_64bits(i64 a) { | ||
| 6356 | + if (a > 0 && a > (VSAFE_DIV_i64(_const_max_i64 , 10))) { | ||
| 6357 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(_S("integer overflow")), .data={E_STRUCT} }; | ||
| 6358 | + } | ||
| 6359 | + if (a < 0 && a < (VSAFE_DIV_i64(_const_min_i64 , 10))) { | ||
| 6360 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(_S("integer underflow")), .data={E_STRUCT} }; | ||
| 6361 | + } | ||
| 6362 | + _result_i64 _t3; | ||
| 6363 | + builtin___result_ok(&(i64[]) { a * 10 }, (_result*)(&_t3), sizeof(i64)); | ||
| 6364 | + | ||
| 6365 | + return _t3; | ||
| 6366 | +} | ||
| 6367 | +VV_LOC _result_int strconv__atou_common_check(string s) { | ||
| 6368 | + if ((s).len == 0) { | ||
| 6369 | + return (_result_int){ .is_error=true, .err=builtin___v_error(_S("strconv.atou: parsing \"\": empty string")), .data={E_STRUCT} }; | ||
| 6370 | + } | ||
| 6371 | + int start_idx = 0; | ||
| 6372 | + if (s.str[ 0] == '-') { | ||
| 6373 | + return (_result_int){ .is_error=true, .err=builtin___v_error(_S("strconv.atou: parsing \"{s}\" : negative value")), .data={E_STRUCT} }; | ||
| 6374 | + } | ||
| 6375 | + if (s.str[ 0] == '+') { | ||
| 6376 | + start_idx++; | ||
| 6377 | + } | ||
| 6378 | + if (s.len - start_idx < 1) { | ||
| 6379 | + return (_result_int){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atou: parsing \""), s, _S("\": no number after sign")}))), .data={E_STRUCT} }; | ||
| 6380 | + } | ||
| 6381 | + if (s.str[ start_idx] == '_' || s.str[ s.len - 1] == '_') { | ||
| 6382 | + return (_result_int){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atou: parsing \""), s, _S("\": values cannot start or end with underscores")}))), .data={E_STRUCT} }; | ||
| 6383 | + } | ||
| 6384 | + _result_int _t5; | ||
| 6385 | + builtin___result_ok(&(int[]) { start_idx }, (_result*)(&_t5), sizeof(int)); | ||
| 6386 | + | ||
| 6387 | + return _t5; | ||
| 6388 | +} | ||
| 6389 | +VV_LOC _result_u64 strconv__atou_common(string s, u64 type_max) { | ||
| 6390 | + _result_int _t1 = strconv__atou_common_check(s); | ||
| 6391 | + if (_t1.is_error) { | ||
| 6392 | + _result_u64 _t2 = {0}; | ||
| 6393 | + _t2.is_error = true; | ||
| 6394 | + _t2.err = _t1.err; | ||
| 6395 | + return _t2; | ||
| 6396 | + } | ||
| 6397 | + | ||
| 6398 | + int start_idx = ((int)((*(int*)_t1.data))); | ||
| 6399 | + u64 x = ((u64)(0)); | ||
| 6400 | + bool underscored = false; | ||
| 6401 | + for (int i = start_idx; i < s.len; ++i) { | ||
| 6402 | + rune c = (rune)(s.str[ i] - '0'); | ||
| 6403 | + if (c == 47) { | ||
| 6404 | + if (underscored == true) { | ||
| 6405 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atou: parsing \""), s, _S("\": consecutives underscores are not allowed")}))), .data={E_STRUCT} }; | ||
| 6406 | + } | ||
| 6407 | + underscored = true; | ||
| 6408 | + continue; | ||
| 6409 | + } else { | ||
| 6410 | + if (c > 9) { | ||
| 6411 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atou: parsing \""), s, _S("\": invalid radix 10 character")}))), .data={E_STRUCT} }; | ||
| 6412 | + } | ||
| 6413 | + underscored = false; | ||
| 6414 | + if (x > VSAFE_DIV_u64(type_max , 10)) { | ||
| 6415 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atou: parsing \""), s, _S("\": integer overflow")}))), .data={E_STRUCT} }; | ||
| 6416 | + } | ||
| 6417 | + x *= 10; | ||
| 6418 | + if (x > type_max - ((u64)(c))) { | ||
| 6419 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atou: parsing \""), s, _S("\": integer overflow")}))), .data={E_STRUCT} }; | ||
| 6420 | + } | ||
| 6421 | + x += ((u64)(c)); | ||
| 6422 | + } | ||
| 6423 | + } | ||
| 6424 | + _result_u64 _t7; | ||
| 6425 | + builtin___result_ok(&(u64[]) { x }, (_result*)(&_t7), sizeof(u64)); | ||
| 6426 | + | ||
| 6427 | + return _t7; | ||
| 6428 | +} | ||
| 6429 | +_result_u8 strconv__atou8(string s) { | ||
| 6430 | + _result_u64 _t2 = strconv__atou_common(s, _const_max_u8); | ||
| 6431 | + if (_t2.is_error) { | ||
| 6432 | + _result_u8 _t3 = {0}; | ||
| 6433 | + _t3.is_error = true; | ||
| 6434 | + _t3.err = _t2.err; | ||
| 6435 | + return _t3; | ||
| 6436 | + } | ||
| 6437 | + | ||
| 6438 | + _result_u8 _t1; | ||
| 6439 | + builtin___result_ok(&(u8[]) { ((u8)((*(u64*)_t2.data))) }, (_result*)(&_t1), sizeof(u8)); | ||
| 6440 | + | ||
| 6441 | + return _t1; | ||
| 6442 | +} | ||
| 6443 | +_result_u16 strconv__atou16(string s) { | ||
| 6444 | + _result_u64 _t2 = strconv__atou_common(s, _const_max_u16); | ||
| 6445 | + if (_t2.is_error) { | ||
| 6446 | + _result_u16 _t3 = {0}; | ||
| 6447 | + _t3.is_error = true; | ||
| 6448 | + _t3.err = _t2.err; | ||
| 6449 | + return _t3; | ||
| 6450 | + } | ||
| 6451 | + | ||
| 6452 | + _result_u16 _t1; | ||
| 6453 | + builtin___result_ok(&(u16[]) { ((u16)((*(u64*)_t2.data))) }, (_result*)(&_t1), sizeof(u16)); | ||
| 6454 | + | ||
| 6455 | + return _t1; | ||
| 6456 | +} | ||
| 6457 | +_result_u32 strconv__atou(string s) { | ||
| 6458 | + _result_u64 _t2 = strconv__atou_common(s, _const_max_u32); | ||
| 6459 | + if (_t2.is_error) { | ||
| 6460 | + _result_u32 _t3 = {0}; | ||
| 6461 | + _t3.is_error = true; | ||
| 6462 | + _t3.err = _t2.err; | ||
| 6463 | + return _t3; | ||
| 6464 | + } | ||
| 6465 | + | ||
| 6466 | + _result_u32 _t1; | ||
| 6467 | + builtin___result_ok(&(u32[]) { ((u32)((*(u64*)_t2.data))) }, (_result*)(&_t1), sizeof(u32)); | ||
| 6468 | + | ||
| 6469 | + return _t1; | ||
| 6470 | +} | ||
| 6471 | +_result_u32 strconv__atou32(string s) { | ||
| 6472 | + _result_u64 _t2 = strconv__atou_common(s, _const_max_u32); | ||
| 6473 | + if (_t2.is_error) { | ||
| 6474 | + _result_u32 _t3 = {0}; | ||
| 6475 | + _t3.is_error = true; | ||
| 6476 | + _t3.err = _t2.err; | ||
| 6477 | + return _t3; | ||
| 6478 | + } | ||
| 6479 | + | ||
| 6480 | + _result_u32 _t1; | ||
| 6481 | + builtin___result_ok(&(u32[]) { ((u32)((*(u64*)_t2.data))) }, (_result*)(&_t1), sizeof(u32)); | ||
| 6482 | + | ||
| 6483 | + return _t1; | ||
| 6484 | +} | ||
| 6485 | +_result_u64 strconv__atou64(string s) { | ||
| 6486 | + _result_u64 _t2 = strconv__atou_common(s, _const_max_u64); | ||
| 6487 | + if (_t2.is_error) { | ||
| 6488 | + _result_u64 _t3 = {0}; | ||
| 6489 | + _t3.is_error = true; | ||
| 6490 | + _t3.err = _t2.err; | ||
| 6491 | + return _t3; | ||
| 6492 | + } | ||
| 6493 | + | ||
| 6494 | + _result_u64 _t1; | ||
| 6495 | + builtin___result_ok(&(u64[]) { ((u64)((*(u64*)_t2.data))) }, (_result*)(&_t1), sizeof(u64)); | ||
| 6496 | + | ||
| 6497 | + return _t1; | ||
| 6498 | +} | ||
| 6499 | +string strconv__Dec32_get_string_32(strconv__Dec32 d, bool neg, int i_n_digit, int i_pad_digit) { | ||
| 6500 | + int n_digit = i_n_digit + 1; | ||
| 6501 | + int pad_digit = i_pad_digit + 1; | ||
| 6502 | + u32 out = d.m; | ||
| 6503 | + int out_len = strconv__dec_digits(out); | ||
| 6504 | + int out_len_original = out_len; | ||
| 6505 | + int fw_zeros = 0; | ||
| 6506 | + if (pad_digit > out_len) { | ||
| 6507 | + fw_zeros = pad_digit - out_len; | ||
| 6508 | + } | ||
| 6509 | + Array_u8 buf = builtin____new_array_with_default(((int)(out_len + 5 + 1 + 1)), 0, sizeof(u8), 0); | ||
| 6510 | + int i = 0; | ||
| 6511 | + if (neg) { | ||
| 6512 | + if (buf.data != 0) { | ||
| 6513 | + ((u8*)buf.data)[i] = '-'; | ||
| 6514 | + } | ||
| 6515 | + i++; | ||
| 6516 | + } | ||
| 6517 | + int disp = 0; | ||
| 6518 | + if (out_len <= 1) { | ||
| 6519 | + disp = 1; | ||
| 6520 | + } | ||
| 6521 | + if (n_digit < out_len) { | ||
| 6522 | + out += _const_strconv__ten_pow_table_32[out_len - n_digit - 1] * 5; | ||
| 6523 | + out = VSAFE_DIV_u32(out,_const_strconv__ten_pow_table_32[out_len - n_digit]); | ||
| 6524 | + out_len = n_digit; | ||
| 6525 | + } | ||
| 6526 | + int y = i + out_len; | ||
| 6527 | + int x = 0; | ||
| 6528 | + for (;;) { | ||
| 6529 | + if (!(x < (out_len - disp - 1))) break; | ||
| 6530 | + ((u8*)buf.data)[y - x] = (rune)('0' + ((u8)(VSAFE_MOD_u32(out , 10)))); | ||
| 6531 | + out = VSAFE_DIV_u32(out,10); | ||
| 6532 | + i++; | ||
| 6533 | + x++; | ||
| 6534 | + } | ||
| 6535 | + if (i_n_digit == 0) { | ||
| 6536 | + { // Unsafe block | ||
| 6537 | + ((u8*)buf.data)[i] = 0; | ||
| 6538 | + return builtin__tos(builtin__memdup(&((u8*)buf.data)[0], i + 1), i); | ||
| 6539 | + } | ||
| 6540 | + } | ||
| 6541 | + if (out_len > 1 || fw_zeros > 0) { | ||
| 6542 | + ((u8*)buf.data)[y - x] = '.'; | ||
| 6543 | + i++; | ||
| 6544 | + } | ||
| 6545 | + x++; | ||
| 6546 | + if (y - x >= 0) { | ||
| 6547 | + ((u8*)buf.data)[y - x] = (rune)('0' + ((u8)(VSAFE_MOD_u32(out , 10)))); | ||
| 6548 | + i++; | ||
| 6549 | + } | ||
| 6550 | + for (;;) { | ||
| 6551 | + if (!(fw_zeros > 0)) break; | ||
| 6552 | + ((u8*)buf.data)[i] = '0'; | ||
| 6553 | + i++; | ||
| 6554 | + fw_zeros--; | ||
| 6555 | + } | ||
| 6556 | + ((u8*)buf.data)[i] = 'e'; | ||
| 6557 | + i++; | ||
| 6558 | + int exp = d.e + out_len_original - 1; | ||
| 6559 | + if (exp < 0) { | ||
| 6560 | + ((u8*)buf.data)[i] = '-'; | ||
| 6561 | + i++; | ||
| 6562 | + exp = -exp; | ||
| 6563 | + } else { | ||
| 6564 | + ((u8*)buf.data)[i] = '+'; | ||
| 6565 | + i++; | ||
| 6566 | + } | ||
| 6567 | + int d1 = VSAFE_MOD_int(exp , 10); | ||
| 6568 | + int d0 = VSAFE_DIV_int(exp , 10); | ||
| 6569 | + ((u8*)buf.data)[i] = (rune)('0' + ((u8)(d0))); | ||
| 6570 | + i++; | ||
| 6571 | + ((u8*)buf.data)[i] = (rune)('0' + ((u8)(d1))); | ||
| 6572 | + i++; | ||
| 6573 | + ((u8*)buf.data)[i] = 0; | ||
| 6574 | + return builtin__tos(builtin__memdup(&((u8*)buf.data)[0], i + 1), i); | ||
| 6575 | +} | ||
| 6576 | +VV_LOC multi_return_strconv__Dec32_bool strconv__f32_to_decimal_exact_int(u32 i_mant, u32 exp) { | ||
| 6577 | + strconv__Dec32 _t1 = ((strconv__Dec32){.m = 0,.e = 0,}); | ||
| 6578 | + strconv__Dec32 d = _t1; | ||
| 6579 | + u32 e = exp - 127; | ||
| 6580 | + if (e > _const_strconv__mantbits32) { | ||
| 6581 | + return (multi_return_strconv__Dec32_bool){.arg0=d, .arg1=false}; | ||
| 6582 | + } | ||
| 6583 | + u32 shift = _const_strconv__mantbits32 - e; | ||
| 6584 | + u32 mant = (i_mant | 0x00800000); | ||
| 6585 | + d.m = v__rshift_u32(mant, (u64)shift); | ||
| 6586 | + if ((v__lshift_u32(d.m, (u64)shift)) != mant) { | ||
| 6587 | + return (multi_return_strconv__Dec32_bool){.arg0=d, .arg1=false}; | ||
| 6588 | + } | ||
| 6589 | + for (;;) { | ||
| 6590 | + if (!((VSAFE_MOD_u32(d.m , 10)) == 0)) break; | ||
| 6591 | + d.m = VSAFE_DIV_u32(d.m,10); | ||
| 6592 | + d.e++; | ||
| 6593 | + } | ||
| 6594 | + return (multi_return_strconv__Dec32_bool){.arg0=d, .arg1=true}; | ||
| 6595 | +} | ||
| 6596 | +VV_LOC strconv__Dec32 strconv__f32_to_decimal(u32 mant, u32 exp) { | ||
| 6597 | + int e2 = 0; | ||
| 6598 | + u32 m2 = ((u32)(0)); | ||
| 6599 | + if (exp == 0) { | ||
| 6600 | + e2 = -126 - ((int)(_const_strconv__mantbits32)) - 2; | ||
| 6601 | + m2 = mant; | ||
| 6602 | + } else { | ||
| 6603 | + e2 = ((int)(exp)) - 127 - ((int)(_const_strconv__mantbits32)) - 2; | ||
| 6604 | + m2 = ((v__lshift_u32(((u32)(1)), (u64)_const_strconv__mantbits32)) | mant); | ||
| 6605 | + } | ||
| 6606 | + bool even = ((m2 & 1)) == 0; | ||
| 6607 | + bool accept_bounds = even; | ||
| 6608 | + u32 mv = ((u32)(4 * m2)); | ||
| 6609 | + u32 mp = ((u32)(4 * m2 + 2)); | ||
| 6610 | + u32 mm_shift = strconv__bool_to_u32(mant != 0 || exp <= 1); | ||
| 6611 | + u32 mm = ((u32)(4 * m2 - 1 - mm_shift)); | ||
| 6612 | + u32 vr = ((u32)(0)); | ||
| 6613 | + u32 vp = ((u32)(0)); | ||
| 6614 | + u32 vm = ((u32)(0)); | ||
| 6615 | + int e10 = 0; | ||
| 6616 | + bool vm_is_trailing_zeros = false; | ||
| 6617 | + bool vr_is_trailing_zeros = false; | ||
| 6618 | + u8 last_removed_digit = ((u8)(0)); | ||
| 6619 | + if (e2 >= 0) { | ||
| 6620 | + u32 q = strconv__log10_pow2(e2); | ||
| 6621 | + e10 = ((int)(q)); | ||
| 6622 | + int k = 59 + strconv__pow5_bits(((int)(q))) - 1; | ||
| 6623 | + int i = -e2 + ((int)(q)) + k; | ||
| 6624 | + vr = strconv__mul_pow5_invdiv_pow2(mv, q, i); | ||
| 6625 | + vp = strconv__mul_pow5_invdiv_pow2(mp, q, i); | ||
| 6626 | + vm = strconv__mul_pow5_invdiv_pow2(mm, q, i); | ||
| 6627 | + if (q != 0 && VSAFE_DIV_u32((vp - 1) , 10) <= VSAFE_DIV_u32(vm , 10)) { | ||
| 6628 | + int l = 59 + strconv__pow5_bits(((int)(q - 1))) - 1; | ||
| 6629 | + last_removed_digit = ((u8)(VSAFE_MOD_u32(strconv__mul_pow5_invdiv_pow2(mv, q - 1, -e2 + ((int)(q - 1)) + l) , 10))); | ||
| 6630 | + } | ||
| 6631 | + if (q <= 9) { | ||
| 6632 | + if (VSAFE_MOD_u32(mv , 5) == 0) { | ||
| 6633 | + vr_is_trailing_zeros = strconv__multiple_of_power_of_five_32(mv, q); | ||
| 6634 | + } else if (accept_bounds) { | ||
| 6635 | + vm_is_trailing_zeros = strconv__multiple_of_power_of_five_32(mm, q); | ||
| 6636 | + } else if (strconv__multiple_of_power_of_five_32(mp, q)) { | ||
| 6637 | + vp--; | ||
| 6638 | + } | ||
| 6639 | + } | ||
| 6640 | + } else { | ||
| 6641 | + u32 q = strconv__log10_pow5(-e2); | ||
| 6642 | + e10 = ((int)(q)) + e2; | ||
| 6643 | + int i = -e2 - ((int)(q)); | ||
| 6644 | + int k = strconv__pow5_bits(i) - 61; | ||
| 6645 | + int j = ((int)(q)) - k; | ||
| 6646 | + vr = strconv__mul_pow5_div_pow2(mv, ((u32)(i)), j); | ||
| 6647 | + vp = strconv__mul_pow5_div_pow2(mp, ((u32)(i)), j); | ||
| 6648 | + vm = strconv__mul_pow5_div_pow2(mm, ((u32)(i)), j); | ||
| 6649 | + if (q != 0 && (VSAFE_DIV_u32((vp - 1) , 10)) <= VSAFE_DIV_u32(vm , 10)) { | ||
| 6650 | + j = ((int)(q)) - 1 - (strconv__pow5_bits(i + 1) - 61); | ||
| 6651 | + last_removed_digit = ((u8)(VSAFE_MOD_u32(strconv__mul_pow5_div_pow2(mv, ((u32)(i + 1)), j) , 10))); | ||
| 6652 | + } | ||
| 6653 | + if (q <= 1) { | ||
| 6654 | + vr_is_trailing_zeros = true; | ||
| 6655 | + if (accept_bounds) { | ||
| 6656 | + vm_is_trailing_zeros = mm_shift == 1; | ||
| 6657 | + } else { | ||
| 6658 | + vp--; | ||
| 6659 | + } | ||
| 6660 | + } else if (q < 31) { | ||
| 6661 | + vr_is_trailing_zeros = strconv__multiple_of_power_of_two_32(mv, q - 1); | ||
| 6662 | + } | ||
| 6663 | + } | ||
| 6664 | + int removed = 0; | ||
| 6665 | + u32 out = ((u32)(0)); | ||
| 6666 | + if (vm_is_trailing_zeros || vr_is_trailing_zeros) { | ||
| 6667 | + for (;;) { | ||
| 6668 | + if (!(VSAFE_DIV_u32(vp , 10) > VSAFE_DIV_u32(vm , 10))) break; | ||
| 6669 | + vm_is_trailing_zeros = vm_is_trailing_zeros && (VSAFE_MOD_u32(vm , 10)) == 0; | ||
| 6670 | + vr_is_trailing_zeros = vr_is_trailing_zeros && last_removed_digit == 0; | ||
| 6671 | + last_removed_digit = ((u8)(VSAFE_MOD_u32(vr , 10))); | ||
| 6672 | + vr = VSAFE_DIV_u32(vr,10); | ||
| 6673 | + vp = VSAFE_DIV_u32(vp,10); | ||
| 6674 | + vm = VSAFE_DIV_u32(vm,10); | ||
| 6675 | + removed++; | ||
| 6676 | + } | ||
| 6677 | + if (vm_is_trailing_zeros) { | ||
| 6678 | + for (;;) { | ||
| 6679 | + if (!(VSAFE_MOD_u32(vm , 10) == 0)) break; | ||
| 6680 | + vr_is_trailing_zeros = vr_is_trailing_zeros && last_removed_digit == 0; | ||
| 6681 | + last_removed_digit = ((u8)(VSAFE_MOD_u32(vr , 10))); | ||
| 6682 | + vr = VSAFE_DIV_u32(vr,10); | ||
| 6683 | + vp = VSAFE_DIV_u32(vp,10); | ||
| 6684 | + vm = VSAFE_DIV_u32(vm,10); | ||
| 6685 | + removed++; | ||
| 6686 | + } | ||
| 6687 | + } | ||
| 6688 | + if (vr_is_trailing_zeros && last_removed_digit == 5 && (VSAFE_MOD_u32(vr , 2)) == 0) { | ||
| 6689 | + last_removed_digit = 4; | ||
| 6690 | + } | ||
| 6691 | + out = vr; | ||
| 6692 | + if ((vr == vm && (!accept_bounds || !vm_is_trailing_zeros)) || last_removed_digit >= 5) { | ||
| 6693 | + out++; | ||
| 6694 | + } | ||
| 6695 | + } else { | ||
| 6696 | + for (;;) { | ||
| 6697 | + if (!(VSAFE_DIV_u32(vp , 10) > VSAFE_DIV_u32(vm , 10))) break; | ||
| 6698 | + last_removed_digit = ((u8)(VSAFE_MOD_u32(vr , 10))); | ||
| 6699 | + vr = VSAFE_DIV_u32(vr,10); | ||
| 6700 | + vp = VSAFE_DIV_u32(vp,10); | ||
| 6701 | + vm = VSAFE_DIV_u32(vm,10); | ||
| 6702 | + removed++; | ||
| 6703 | + } | ||
| 6704 | + out = vr + strconv__bool_to_u32(vr == vm || last_removed_digit >= 5); | ||
| 6705 | + } | ||
| 6706 | + return ((strconv__Dec32){.m = out,.e = e10 + removed,}); | ||
| 6707 | +} | ||
| 6708 | +string strconv__f32_to_str(f32 f, int n_digit) { | ||
| 6709 | + strconv__Uf32 _t1 = ((strconv__Uf32){0}); | ||
| 6710 | + strconv__Uf32 u1 = _t1; | ||
| 6711 | + u1.f = f; | ||
| 6712 | + u32 u = u1.u; | ||
| 6713 | + bool neg = (v__rshift_u32(u, (u64)(_const_strconv__mantbits32 + _const_strconv__expbits32))) != 0; | ||
| 6714 | + u32 mant = (u & ((v__lshift_u32(((u32)(1)), (u64)_const_strconv__mantbits32)) - ((u32)(1)))); | ||
| 6715 | + u32 exp = ((v__rshift_u32(u, (u64)_const_strconv__mantbits32)) & ((v__lshift_u32(((u32)(1)), (u64)_const_strconv__expbits32)) - ((u32)(1)))); | ||
| 6716 | + if (exp == 255 || (exp == 0 && mant == 0)) { | ||
| 6717 | + return strconv__get_string_special(neg, exp == 0, mant == 0); | ||
| 6718 | + } | ||
| 6719 | + multi_return_strconv__Dec32_bool mr_8600 = strconv__f32_to_decimal_exact_int(mant, exp); | ||
| 6720 | + strconv__Dec32 d = mr_8600.arg0; | ||
| 6721 | + bool ok = mr_8600.arg1; | ||
| 6722 | + if (!ok) { | ||
| 6723 | + d = strconv__f32_to_decimal(mant, exp); | ||
| 6724 | + } | ||
| 6725 | + return strconv__Dec32_get_string_32(d, neg, n_digit, 0); | ||
| 6726 | +} | ||
| 6727 | +string strconv__f32_to_str_pad(f32 f, int n_digit) { | ||
| 6728 | + strconv__Uf32 _t1 = ((strconv__Uf32){0}); | ||
| 6729 | + strconv__Uf32 u1 = _t1; | ||
| 6730 | + u1.f = f; | ||
| 6731 | + u32 u = u1.u; | ||
| 6732 | + bool neg = (v__rshift_u32(u, (u64)(_const_strconv__mantbits32 + _const_strconv__expbits32))) != 0; | ||
| 6733 | + u32 mant = (u & ((v__lshift_u32(((u32)(1)), (u64)_const_strconv__mantbits32)) - ((u32)(1)))); | ||
| 6734 | + u32 exp = ((v__rshift_u32(u, (u64)_const_strconv__mantbits32)) & ((v__lshift_u32(((u32)(1)), (u64)_const_strconv__expbits32)) - ((u32)(1)))); | ||
| 6735 | + if (exp == 255 || (exp == 0 && mant == 0)) { | ||
| 6736 | + return strconv__get_string_special(neg, exp == 0, mant == 0); | ||
| 6737 | + } | ||
| 6738 | + multi_return_strconv__Dec32_bool mr_9334 = strconv__f32_to_decimal_exact_int(mant, exp); | ||
| 6739 | + strconv__Dec32 d = mr_9334.arg0; | ||
| 6740 | + bool ok = mr_9334.arg1; | ||
| 6741 | + if (!ok) { | ||
| 6742 | + d = strconv__f32_to_decimal(mant, exp); | ||
| 6743 | + } | ||
| 6744 | + return strconv__Dec32_get_string_32(d, neg, n_digit, n_digit); | ||
| 6745 | +} | ||
| 6746 | +VV_LOC string strconv__Dec64_get_string_64(strconv__Dec64 d, bool neg, int i_n_digit, int i_pad_digit) { | ||
| 6747 | + int n_digit = (i_n_digit < 1 ? (1) : (i_n_digit + 1)); | ||
| 6748 | + int pad_digit = i_pad_digit + 1; | ||
| 6749 | + u64 out = d.m; | ||
| 6750 | + int d_exp = d.e; | ||
| 6751 | + int out_len = strconv__dec_digits(out); | ||
| 6752 | + int out_len_original = out_len; | ||
| 6753 | + int fw_zeros = 0; | ||
| 6754 | + if (pad_digit > out_len) { | ||
| 6755 | + fw_zeros = pad_digit - out_len; | ||
| 6756 | + } | ||
| 6757 | + Array_u8 buf = builtin____new_array_with_default((out_len + 6 + 1 + 1 + fw_zeros), 0, sizeof(u8), 0); | ||
| 6758 | + int i = 0; | ||
| 6759 | + if (neg) { | ||
| 6760 | + ((u8*)buf.data)[i] = '-'; | ||
| 6761 | + i++; | ||
| 6762 | + } | ||
| 6763 | + int disp = 0; | ||
| 6764 | + if (out_len <= 1) { | ||
| 6765 | + disp = 1; | ||
| 6766 | + } | ||
| 6767 | + if (n_digit < out_len) { | ||
| 6768 | + out += _const_strconv__ten_pow_table_64[out_len - n_digit - 1] * 5; | ||
| 6769 | + out = VSAFE_DIV_u64(out,_const_strconv__ten_pow_table_64[out_len - n_digit]); | ||
| 6770 | + u64 out_div = VSAFE_DIV_u64(d.m , _const_strconv__ten_pow_table_64[out_len - n_digit]); | ||
| 6771 | + if (out_div < out && strconv__dec_digits(out_div) < strconv__dec_digits(out)) { | ||
| 6772 | + d_exp++; | ||
| 6773 | + n_digit++; | ||
| 6774 | + } | ||
| 6775 | + out_len = n_digit; | ||
| 6776 | + } | ||
| 6777 | + int y = i + out_len; | ||
| 6778 | + int x = 0; | ||
| 6779 | + for (;;) { | ||
| 6780 | + if (!(x < (out_len - disp - 1))) break; | ||
| 6781 | + ((u8*)buf.data)[y - x] = (rune)('0' + ((u8)(VSAFE_MOD_u64(out , 10)))); | ||
| 6782 | + out = VSAFE_DIV_u64(out,10); | ||
| 6783 | + i++; | ||
| 6784 | + x++; | ||
| 6785 | + } | ||
| 6786 | + if (out_len > 1 || fw_zeros > 0) { | ||
| 6787 | + ((u8*)buf.data)[y - x] = '.'; | ||
| 6788 | + i++; | ||
| 6789 | + } | ||
| 6790 | + x++; | ||
| 6791 | + if (y - x >= 0) { | ||
| 6792 | + ((u8*)buf.data)[y - x] = (rune)('0' + ((u8)(VSAFE_MOD_u64(out , 10)))); | ||
| 6793 | + i++; | ||
| 6794 | + } | ||
| 6795 | + for (;;) { | ||
| 6796 | + if (!(fw_zeros > 0)) break; | ||
| 6797 | + ((u8*)buf.data)[i] = '0'; | ||
| 6798 | + i++; | ||
| 6799 | + fw_zeros--; | ||
| 6800 | + } | ||
| 6801 | + ((u8*)buf.data)[i] = 'e'; | ||
| 6802 | + i++; | ||
| 6803 | + int exp = d_exp + out_len_original - 1; | ||
| 6804 | + if (exp < 0) { | ||
| 6805 | + ((u8*)buf.data)[i] = '-'; | ||
| 6806 | + i++; | ||
| 6807 | + exp = -exp; | ||
| 6808 | + } else { | ||
| 6809 | + ((u8*)buf.data)[i] = '+'; | ||
| 6810 | + i++; | ||
| 6811 | + } | ||
| 6812 | + int d2 = VSAFE_MOD_int(exp , 10); | ||
| 6813 | + exp = VSAFE_DIV_int(exp,10); | ||
| 6814 | + int d1 = VSAFE_MOD_int(exp , 10); | ||
| 6815 | + int d0 = VSAFE_DIV_int(exp , 10); | ||
| 6816 | + if (d0 > 0) { | ||
| 6817 | + ((u8*)buf.data)[i] = (rune)('0' + ((u8)(d0))); | ||
| 6818 | + i++; | ||
| 6819 | + } | ||
| 6820 | + ((u8*)buf.data)[i] = (rune)('0' + ((u8)(d1))); | ||
| 6821 | + i++; | ||
| 6822 | + ((u8*)buf.data)[i] = (rune)('0' + ((u8)(d2))); | ||
| 6823 | + i++; | ||
| 6824 | + ((u8*)buf.data)[i] = 0; | ||
| 6825 | + return builtin__tos(builtin__memdup(&((u8*)buf.data)[0], i + 1), i); | ||
| 6826 | +} | ||
| 6827 | +VV_LOC multi_return_strconv__Dec64_bool strconv__f64_to_decimal_exact_int(u64 i_mant, u64 exp) { | ||
| 6828 | + strconv__Dec64 _t1 = ((strconv__Dec64){.m = 0,.e = 0,}); | ||
| 6829 | + strconv__Dec64 d = _t1; | ||
| 6830 | + u64 e = exp - 1023; | ||
| 6831 | + if (e > _const_strconv__mantbits64) { | ||
| 6832 | + return (multi_return_strconv__Dec64_bool){.arg0=d, .arg1=false}; | ||
| 6833 | + } | ||
| 6834 | + u64 shift = (u64)(_const_strconv__mantbits64 - e); | ||
| 6835 | + u64 mant = (i_mant | ((u64)(0x0010000000000000LL))); | ||
| 6836 | + d.m = v__rshift_u64(mant, (u64)shift); | ||
| 6837 | + if ((v__lshift_u64(d.m, (u64)shift)) != mant) { | ||
| 6838 | + return (multi_return_strconv__Dec64_bool){.arg0=d, .arg1=false}; | ||
| 6839 | + } | ||
| 6840 | + for (;;) { | ||
| 6841 | + if (!((VSAFE_MOD_u64(d.m , 10)) == 0)) break; | ||
| 6842 | + d.m = VSAFE_DIV_u64(d.m,10); | ||
| 6843 | + d.e++; | ||
| 6844 | + } | ||
| 6845 | + return (multi_return_strconv__Dec64_bool){.arg0=d, .arg1=true}; | ||
| 6846 | +} | ||
| 6847 | +VV_LOC strconv__Dec64 strconv__f64_to_decimal(u64 mant, u64 exp) { | ||
| 6848 | + int e2 = 0; | ||
| 6849 | + u64 m2 = ((u64)(0)); | ||
| 6850 | + if (exp == 0) { | ||
| 6851 | + e2 = -1022 - ((int)(_const_strconv__mantbits64)) - 2; | ||
| 6852 | + m2 = mant; | ||
| 6853 | + } else { | ||
| 6854 | + e2 = ((int)(exp)) - 1023 - ((int)(_const_strconv__mantbits64)) - 2; | ||
| 6855 | + m2 = ((v__lshift_u64(((u64)(1)), (u64)_const_strconv__mantbits64)) | mant); | ||
| 6856 | + } | ||
| 6857 | + bool even = ((m2 & 1)) == 0; | ||
| 6858 | + bool accept_bounds = even; | ||
| 6859 | + u64 mv = ((u64)(4 * m2)); | ||
| 6860 | + u64 mm_shift = strconv__bool_to_u64(mant != 0 || exp <= 1); | ||
| 6861 | + u64 vr = ((u64)(0)); | ||
| 6862 | + u64 vp = ((u64)(0)); | ||
| 6863 | + u64 vm = ((u64)(0)); | ||
| 6864 | + int e10 = 0; | ||
| 6865 | + bool vm_is_trailing_zeros = false; | ||
| 6866 | + bool vr_is_trailing_zeros = false; | ||
| 6867 | + if (e2 >= 0) { | ||
| 6868 | + u32 q = strconv__log10_pow2(e2) - strconv__bool_to_u32(e2 > 3); | ||
| 6869 | + e10 = ((int)(q)); | ||
| 6870 | + int k = 122 + strconv__pow5_bits(((int)(q))) - 1; | ||
| 6871 | + int i = -e2 + ((int)(q)) + k; | ||
| 6872 | + strconv__Uint128 mul = *(((strconv__Uint128*)(&_const_strconv__pow5_inv_split_64_x[builtin__v_fixed_index(q * 2, 584)]))); | ||
| 6873 | + vr = strconv__mul_shift_64(((u64)(4)) * m2, mul, i); | ||
| 6874 | + vp = strconv__mul_shift_64(((u64)(4)) * m2 + ((u64)(2)), mul, i); | ||
| 6875 | + vm = strconv__mul_shift_64(((u64)(4)) * m2 - ((u64)(1)) - mm_shift, mul, i); | ||
| 6876 | + if (q <= 21) { | ||
| 6877 | + if (VSAFE_MOD_u64(mv , 5) == 0) { | ||
| 6878 | + vr_is_trailing_zeros = strconv__multiple_of_power_of_five_64(mv, q); | ||
| 6879 | + } else if (accept_bounds) { | ||
| 6880 | + vm_is_trailing_zeros = strconv__multiple_of_power_of_five_64(mv - 1 - mm_shift, q); | ||
| 6881 | + } else if (strconv__multiple_of_power_of_five_64(mv + 2, q)) { | ||
| 6882 | + vp--; | ||
| 6883 | + } | ||
| 6884 | + } | ||
| 6885 | + } else { | ||
| 6886 | + u32 q = strconv__log10_pow5(-e2) - strconv__bool_to_u32(-e2 > 1); | ||
| 6887 | + e10 = ((int)(q)) + e2; | ||
| 6888 | + int i = -e2 - ((int)(q)); | ||
| 6889 | + int k = strconv__pow5_bits(i) - 121; | ||
| 6890 | + int j = ((int)(q)) - k; | ||
| 6891 | + strconv__Uint128 mul = *(((strconv__Uint128*)(&_const_strconv__pow5_split_64_x[builtin__v_fixed_index(i * 2, 652)]))); | ||
| 6892 | + vr = strconv__mul_shift_64(((u64)(4)) * m2, mul, j); | ||
| 6893 | + vp = strconv__mul_shift_64(((u64)(4)) * m2 + ((u64)(2)), mul, j); | ||
| 6894 | + vm = strconv__mul_shift_64(((u64)(4)) * m2 - ((u64)(1)) - mm_shift, mul, j); | ||
| 6895 | + if (q <= 1) { | ||
| 6896 | + vr_is_trailing_zeros = true; | ||
| 6897 | + if (accept_bounds) { | ||
| 6898 | + vm_is_trailing_zeros = (mm_shift == 1); | ||
| 6899 | + } else { | ||
| 6900 | + vp--; | ||
| 6901 | + } | ||
| 6902 | + } else if (q < 63) { | ||
| 6903 | + vr_is_trailing_zeros = strconv__multiple_of_power_of_two_64(mv, q - 1); | ||
| 6904 | + } | ||
| 6905 | + } | ||
| 6906 | + int removed = 0; | ||
| 6907 | + u8 last_removed_digit = ((u8)(0)); | ||
| 6908 | + u64 out = ((u64)(0)); | ||
| 6909 | + if (vm_is_trailing_zeros || vr_is_trailing_zeros) { | ||
| 6910 | + for (;;) { | ||
| 6911 | + u64 vp_div_10 = VSAFE_DIV_u64(vp , 10); | ||
| 6912 | + u64 vm_div_10 = VSAFE_DIV_u64(vm , 10); | ||
| 6913 | + if (vp_div_10 <= vm_div_10) { | ||
| 6914 | + break; | ||
| 6915 | + } | ||
| 6916 | + u64 vm_mod_10 = VSAFE_MOD_u64(vm , 10); | ||
| 6917 | + u64 vr_div_10 = VSAFE_DIV_u64(vr , 10); | ||
| 6918 | + u64 vr_mod_10 = VSAFE_MOD_u64(vr , 10); | ||
| 6919 | + vm_is_trailing_zeros = vm_is_trailing_zeros && vm_mod_10 == 0; | ||
| 6920 | + vr_is_trailing_zeros = vr_is_trailing_zeros && last_removed_digit == 0; | ||
| 6921 | + last_removed_digit = ((u8)(vr_mod_10)); | ||
| 6922 | + vr = vr_div_10; | ||
| 6923 | + vp = vp_div_10; | ||
| 6924 | + vm = vm_div_10; | ||
| 6925 | + removed++; | ||
| 6926 | + } | ||
| 6927 | + if (vm_is_trailing_zeros) { | ||
| 6928 | + for (;;) { | ||
| 6929 | + u64 vm_div_10 = VSAFE_DIV_u64(vm , 10); | ||
| 6930 | + u64 vm_mod_10 = VSAFE_MOD_u64(vm , 10); | ||
| 6931 | + if (vm_mod_10 != 0) { | ||
| 6932 | + break; | ||
| 6933 | + } | ||
| 6934 | + u64 vp_div_10 = VSAFE_DIV_u64(vp , 10); | ||
| 6935 | + u64 vr_div_10 = VSAFE_DIV_u64(vr , 10); | ||
| 6936 | + u64 vr_mod_10 = VSAFE_MOD_u64(vr , 10); | ||
| 6937 | + vr_is_trailing_zeros = vr_is_trailing_zeros && last_removed_digit == 0; | ||
| 6938 | + last_removed_digit = ((u8)(vr_mod_10)); | ||
| 6939 | + vr = vr_div_10; | ||
| 6940 | + vp = vp_div_10; | ||
| 6941 | + vm = vm_div_10; | ||
| 6942 | + removed++; | ||
| 6943 | + } | ||
| 6944 | + } | ||
| 6945 | + if (vr_is_trailing_zeros && last_removed_digit == 5 && (VSAFE_MOD_u64(vr , 2)) == 0) { | ||
| 6946 | + last_removed_digit = 4; | ||
| 6947 | + } | ||
| 6948 | + out = vr; | ||
| 6949 | + if ((vr == vm && (!accept_bounds || !vm_is_trailing_zeros)) || last_removed_digit >= 5) { | ||
| 6950 | + out++; | ||
| 6951 | + } | ||
| 6952 | + } else { | ||
| 6953 | + bool round_up = false; | ||
| 6954 | + for (;;) { | ||
| 6955 | + if (!(VSAFE_DIV_u64(vp , 100) > VSAFE_DIV_u64(vm , 100))) break; | ||
| 6956 | + round_up = (VSAFE_MOD_u64(vr , 100)) >= 50; | ||
| 6957 | + vr = VSAFE_DIV_u64(vr,100); | ||
| 6958 | + vp = VSAFE_DIV_u64(vp,100); | ||
| 6959 | + vm = VSAFE_DIV_u64(vm,100); | ||
| 6960 | + removed += 2; | ||
| 6961 | + } | ||
| 6962 | + for (;;) { | ||
| 6963 | + if (!(VSAFE_DIV_u64(vp , 10) > VSAFE_DIV_u64(vm , 10))) break; | ||
| 6964 | + round_up = (VSAFE_MOD_u64(vr , 10)) >= 5; | ||
| 6965 | + vr = VSAFE_DIV_u64(vr,10); | ||
| 6966 | + vp = VSAFE_DIV_u64(vp,10); | ||
| 6967 | + vm = VSAFE_DIV_u64(vm,10); | ||
| 6968 | + removed++; | ||
| 6969 | + } | ||
| 6970 | + out = vr + strconv__bool_to_u64(vr == vm || round_up); | ||
| 6971 | + } | ||
| 6972 | + return ((strconv__Dec64){.m = out,.e = e10 + removed,}); | ||
| 6973 | +} | ||
| 6974 | +string strconv__f64_to_str(f64 f, int n_digit) { | ||
| 6975 | + strconv__Uf64 _t1 = ((strconv__Uf64){0}); | ||
| 6976 | + strconv__Uf64 u1 = _t1; | ||
| 6977 | + u1.f = f; | ||
| 6978 | + u64 u = u1.u; | ||
| 6979 | + bool neg = (v__rshift_u64(u, (u64)(_const_strconv__mantbits64 + _const_strconv__expbits64))) != 0; | ||
| 6980 | + u64 mant = (u & ((v__lshift_u64(((u64)(1)), (u64)_const_strconv__mantbits64)) - ((u64)(1)))); | ||
| 6981 | + u64 exp = ((v__rshift_u64(u, (u64)_const_strconv__mantbits64)) & ((v__lshift_u64(((u64)(1)), (u64)_const_strconv__expbits64)) - ((u64)(1)))); | ||
| 6982 | + if (exp == 2047 || (exp == 0 && mant == 0)) { | ||
| 6983 | + return strconv__get_string_special(neg, exp == 0, mant == 0); | ||
| 6984 | + } | ||
| 6985 | + multi_return_strconv__Dec64_bool mr_9595 = strconv__f64_to_decimal_exact_int(mant, exp); | ||
| 6986 | + strconv__Dec64 d = mr_9595.arg0; | ||
| 6987 | + bool ok = mr_9595.arg1; | ||
| 6988 | + if (!ok) { | ||
| 6989 | + d = strconv__f64_to_decimal(mant, exp); | ||
| 6990 | + } | ||
| 6991 | + return strconv__Dec64_get_string_64(d, neg, n_digit, 0); | ||
| 6992 | +} | ||
| 6993 | +string strconv__f64_to_str_pad(f64 f, int n_digit) { | ||
| 6994 | + strconv__Uf64 _t1 = ((strconv__Uf64){0}); | ||
| 6995 | + strconv__Uf64 u1 = _t1; | ||
| 6996 | + u1.f = f; | ||
| 6997 | + u64 u = u1.u; | ||
| 6998 | + bool neg = (v__rshift_u64(u, (u64)(_const_strconv__mantbits64 + _const_strconv__expbits64))) != 0; | ||
| 6999 | + u64 mant = (u & ((v__lshift_u64(((u64)(1)), (u64)_const_strconv__mantbits64)) - ((u64)(1)))); | ||
| 7000 | + u64 exp = ((v__rshift_u64(u, (u64)_const_strconv__mantbits64)) & ((v__lshift_u64(((u64)(1)), (u64)_const_strconv__expbits64)) - ((u64)(1)))); | ||
| 7001 | + if (exp == 2047 || (exp == 0 && mant == 0)) { | ||
| 7002 | + return strconv__get_string_special(neg, exp == 0, mant == 0); | ||
| 7003 | + } | ||
| 7004 | + multi_return_strconv__Dec64_bool mr_10376 = strconv__f64_to_decimal_exact_int(mant, exp); | ||
| 7005 | + strconv__Dec64 d = mr_10376.arg0; | ||
| 7006 | + bool ok = mr_10376.arg1; | ||
| 7007 | + if (!ok) { | ||
| 7008 | + d = strconv__f64_to_decimal(mant, exp); | ||
| 7009 | + } | ||
| 7010 | + return strconv__Dec64_get_string_64(d, neg, n_digit, n_digit); | ||
| 7011 | +} | ||
| 7012 | +string strconv__format_str(string s, strconv__BF_param p) { | ||
| 7013 | + if (p.len0 <= 0) { | ||
| 7014 | + return builtin__string_clone(s); | ||
| 7015 | + } | ||
| 7016 | + int dif = p.len0 - builtin__utf8_str_visible_length(s); | ||
| 7017 | + if (dif <= 0) { | ||
| 7018 | + return builtin__string_clone(s); | ||
| 7019 | + } | ||
| 7020 | + strings__Builder res = strings__new_builder(s.len + dif); | ||
| 7021 | + if (p.align == strconv__Align_text__right) { | ||
| 7022 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 7023 | + strings__Builder_write_u8(&res, p.pad_ch); | ||
| 7024 | + } | ||
| 7025 | + } | ||
| 7026 | + strings__Builder_write_string(&res, s); | ||
| 7027 | + if (p.align == strconv__Align_text__left) { | ||
| 7028 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 7029 | + strings__Builder_write_u8(&res, p.pad_ch); | ||
| 7030 | + } | ||
| 7031 | + } | ||
| 7032 | + string _t3 = strings__Builder_str(&res); | ||
| 7033 | + { // defer begin | ||
| 7034 | + strings__Builder_free(&res); | ||
| 7035 | + } // defer end | ||
| 7036 | + return _t3; | ||
| 7037 | +} | ||
| 7038 | +void strconv__format_str_sb(string s, strconv__BF_param p, strings__Builder* sb) { | ||
| 7039 | + if (p.len0 <= 0) { | ||
| 7040 | + strings__Builder_write_string(sb, s); | ||
| 7041 | + return; | ||
| 7042 | + } | ||
| 7043 | + int dif = p.len0 - builtin__utf8_str_visible_length(s); | ||
| 7044 | + if (dif <= 0) { | ||
| 7045 | + strings__Builder_write_string(sb, s); | ||
| 7046 | + return; | ||
| 7047 | + } | ||
| 7048 | + if (p.align == strconv__Align_text__right) { | ||
| 7049 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 7050 | + strings__Builder_write_u8(sb, p.pad_ch); | ||
| 7051 | + } | ||
| 7052 | + } | ||
| 7053 | + strings__Builder_write_string(sb, s); | ||
| 7054 | + if (p.align == strconv__Align_text__left) { | ||
| 7055 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 7056 | + strings__Builder_write_u8(sb, p.pad_ch); | ||
| 7057 | + } | ||
| 7058 | + } | ||
| 7059 | +} | ||
| 7060 | +void strconv__format_dec_sb(u64 d, strconv__BF_param p, strings__Builder* res) { | ||
| 7061 | + int n_char = strconv__dec_digits(d); | ||
| 7062 | + int sign_len = (!p.positive || p.sign_flag ? (1) : (0)); | ||
| 7063 | + int number_len = sign_len + n_char; | ||
| 7064 | + int dif = p.len0 - number_len; | ||
| 7065 | + bool sign_written = false; | ||
| 7066 | + if (p.align == strconv__Align_text__right) { | ||
| 7067 | + if (p.pad_ch == '0') { | ||
| 7068 | + if (p.positive) { | ||
| 7069 | + if (p.sign_flag) { | ||
| 7070 | + strings__Builder_write_u8(res, '+'); | ||
| 7071 | + sign_written = true; | ||
| 7072 | + } | ||
| 7073 | + } else { | ||
| 7074 | + strings__Builder_write_u8(res, '-'); | ||
| 7075 | + sign_written = true; | ||
| 7076 | + } | ||
| 7077 | + } | ||
| 7078 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 7079 | + strings__Builder_write_u8(res, p.pad_ch); | ||
| 7080 | + } | ||
| 7081 | + } | ||
| 7082 | + if (!sign_written) { | ||
| 7083 | + if (p.positive) { | ||
| 7084 | + if (p.sign_flag) { | ||
| 7085 | + strings__Builder_write_u8(res, '+'); | ||
| 7086 | + } | ||
| 7087 | + } else { | ||
| 7088 | + strings__Builder_write_u8(res, '-'); | ||
| 7089 | + } | ||
| 7090 | + } | ||
| 7091 | + Array_fixed_u8_32 buf = {0}; | ||
| 7092 | + int i = 20; | ||
| 7093 | + u64 n = d; | ||
| 7094 | + u64 d_i = ((u64)(0)); | ||
| 7095 | + if (n > 0) { | ||
| 7096 | + for (;;) { | ||
| 7097 | + if (!(n > 0)) break; | ||
| 7098 | + u64 n1 = VSAFE_DIV_u64(n , 100); | ||
| 7099 | + d_i = v__lshift_u64((n - (n1 * 100)), (u64)1); | ||
| 7100 | + n = n1; | ||
| 7101 | + { // Unsafe block | ||
| 7102 | + buf[i] = _const_strconv__digit_pairs.str[d_i]; | ||
| 7103 | + } | ||
| 7104 | + i--; | ||
| 7105 | + d_i++; | ||
| 7106 | + { // Unsafe block | ||
| 7107 | + buf[i] = _const_strconv__digit_pairs.str[d_i]; | ||
| 7108 | + } | ||
| 7109 | + i--; | ||
| 7110 | + } | ||
| 7111 | + i++; | ||
| 7112 | + if (d_i < 20) { | ||
| 7113 | + i++; | ||
| 7114 | + } | ||
| 7115 | + strings__Builder_write_ptr(res, &buf[i], n_char); | ||
| 7116 | + } else { | ||
| 7117 | + strings__Builder_write_u8(res, '0'); | ||
| 7118 | + } | ||
| 7119 | + if (p.align == strconv__Align_text__left) { | ||
| 7120 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 7121 | + strings__Builder_write_u8(res, p.pad_ch); | ||
| 7122 | + } | ||
| 7123 | + } | ||
| 7124 | + return; | ||
| 7125 | +} | ||
| 7126 | +string strconv__f64_to_str_lnd1(f64 f, int dec_digit) { | ||
| 7127 | + { // Unsafe block | ||
| 7128 | + int clamped_dec = (dec_digit >= 36 ? (36 - 1) : (dec_digit)); | ||
| 7129 | + string s = strconv__f64_to_str(f + _const_strconv__dec_round[clamped_dec], 18); | ||
| 7130 | + if (s.len > 2 && (s.str[ 0] == 'n' || s.str[ 1] == 'i')) { | ||
| 7131 | + return s; | ||
| 7132 | + } | ||
| 7133 | + bool m_sgn_flag = false; | ||
| 7134 | + int sgn = 1; | ||
| 7135 | + Array_fixed_u8_26 b = {0}; | ||
| 7136 | + int d_pos = 1; | ||
| 7137 | + int i = 0; | ||
| 7138 | + int i1 = 0; | ||
| 7139 | + int exp = 0; | ||
| 7140 | + int exp_sgn = 1; | ||
| 7141 | + int dot_res_sp = -1; | ||
| 7142 | + for (int _t2 = 0; _t2 < s.len; ++_t2) { | ||
| 7143 | + u8 c = s.str[_t2]; | ||
| 7144 | + | ||
| 7145 | + if (c == ('-')) { | ||
| 7146 | + sgn = -1; | ||
| 7147 | + i++; | ||
| 7148 | + } | ||
| 7149 | + else if (c == ('+')) { | ||
| 7150 | + sgn = 1; | ||
| 7151 | + i++; | ||
| 7152 | + } | ||
| 7153 | + else if ((c >= '0' && c <= '9')) { | ||
| 7154 | + b[i1] = c; | ||
| 7155 | + i1++; | ||
| 7156 | + i++; | ||
| 7157 | + } | ||
| 7158 | + else if (c == ('.')) { | ||
| 7159 | + if (sgn > 0) { | ||
| 7160 | + d_pos = i; | ||
| 7161 | + } else { | ||
| 7162 | + d_pos = i - 1; | ||
| 7163 | + } | ||
| 7164 | + i++; | ||
| 7165 | + } | ||
| 7166 | + else if (c == ('e')) { | ||
| 7167 | + i++; | ||
| 7168 | + break; | ||
| 7169 | + } | ||
| 7170 | + else { | ||
| 7171 | + builtin__string_free(&s); | ||
| 7172 | + return _S("[Float conversion error!!]"); | ||
| 7173 | + } | ||
| 7174 | + } | ||
| 7175 | + b[i1] = 0; | ||
| 7176 | + if (s.str[ i] == '-') { | ||
| 7177 | + exp_sgn = -1; | ||
| 7178 | + i++; | ||
| 7179 | + } else if (s.str[ i] == '+') { | ||
| 7180 | + exp_sgn = 1; | ||
| 7181 | + i++; | ||
| 7182 | + } | ||
| 7183 | + int c = i; | ||
| 7184 | + for (;;) { | ||
| 7185 | + if (!(c < s.len)) break; | ||
| 7186 | + exp = exp * 10 + ((int)((rune)(s.str[ c] - '0'))); | ||
| 7187 | + c++; | ||
| 7188 | + } | ||
| 7189 | + int extra_frac_digits = (dec_digit > 0 ? (dec_digit) : (0)); | ||
| 7190 | + int sign_len = (sgn < 0 ? (1) : (0)); | ||
| 7191 | + Array_u8 res = builtin____new_array_with_default(sign_len + i1 + exp + extra_frac_digits + 4, 0, sizeof(u8), &(u8[]){0}); | ||
| 7192 | + int r_i = 0; | ||
| 7193 | + builtin__string_free(&s); | ||
| 7194 | + if (sgn == 1) { | ||
| 7195 | + if (m_sgn_flag) { | ||
| 7196 | + ((u8*)res.data)[r_i] = '+'; | ||
| 7197 | + r_i++; | ||
| 7198 | + } | ||
| 7199 | + } else { | ||
| 7200 | + ((u8*)res.data)[r_i] = '-'; | ||
| 7201 | + r_i++; | ||
| 7202 | + } | ||
| 7203 | + i = 0; | ||
| 7204 | + if (exp_sgn >= 0) { | ||
| 7205 | + for (;;) { | ||
| 7206 | + if (!(b[i] != 0)) break; | ||
| 7207 | + ((u8*)res.data)[r_i] = b[i]; | ||
| 7208 | + r_i++; | ||
| 7209 | + i++; | ||
| 7210 | + if (i >= d_pos && exp >= 0) { | ||
| 7211 | + if (exp == 0) { | ||
| 7212 | + dot_res_sp = r_i; | ||
| 7213 | + ((u8*)res.data)[r_i] = '.'; | ||
| 7214 | + r_i++; | ||
| 7215 | + } | ||
| 7216 | + exp--; | ||
| 7217 | + } | ||
| 7218 | + } | ||
| 7219 | + for (;;) { | ||
| 7220 | + if (!(exp >= 0)) break; | ||
| 7221 | + ((u8*)res.data)[r_i] = '0'; | ||
| 7222 | + r_i++; | ||
| 7223 | + exp--; | ||
| 7224 | + } | ||
| 7225 | + } else { | ||
| 7226 | + bool dot_p = true; | ||
| 7227 | + for (;;) { | ||
| 7228 | + if (!(exp > 0)) break; | ||
| 7229 | + ((u8*)res.data)[r_i] = '0'; | ||
| 7230 | + r_i++; | ||
| 7231 | + exp--; | ||
| 7232 | + if (dot_p) { | ||
| 7233 | + dot_res_sp = r_i; | ||
| 7234 | + ((u8*)res.data)[r_i] = '.'; | ||
| 7235 | + r_i++; | ||
| 7236 | + dot_p = false; | ||
| 7237 | + } | ||
| 7238 | + } | ||
| 7239 | + for (;;) { | ||
| 7240 | + if (!(b[i] != 0)) break; | ||
| 7241 | + ((u8*)res.data)[r_i] = b[i]; | ||
| 7242 | + r_i++; | ||
| 7243 | + i++; | ||
| 7244 | + } | ||
| 7245 | + } | ||
| 7246 | + if (dec_digit <= 0) { | ||
| 7247 | + if (dot_res_sp < 0) { | ||
| 7248 | + dot_res_sp = i + 1; | ||
| 7249 | + } | ||
| 7250 | + string tmp_res = builtin__string_clone(builtin__tos(res.data, dot_res_sp)); | ||
| 7251 | + builtin__array_free(&res); | ||
| 7252 | + return tmp_res; | ||
| 7253 | + } | ||
| 7254 | + if (dot_res_sp >= 0) { | ||
| 7255 | + r_i = dot_res_sp + dec_digit + 1; | ||
| 7256 | + ((u8*)res.data)[r_i] = 0; | ||
| 7257 | + for (int c1 = 1; c1 < dec_digit + 1; ++c1) { | ||
| 7258 | + if (((u8*)res.data)[(int)(r_i - c1)] == 0) { | ||
| 7259 | + ((u8*)res.data)[(int)(r_i - c1)] = '0'; | ||
| 7260 | + } | ||
| 7261 | + } | ||
| 7262 | + string tmp_res = builtin__string_clone(builtin__tos(res.data, r_i)); | ||
| 7263 | + builtin__array_free(&res); | ||
| 7264 | + return tmp_res; | ||
| 7265 | + } else { | ||
| 7266 | + if (dec_digit > 0) { | ||
| 7267 | + int c1 = 0; | ||
| 7268 | + ((u8*)res.data)[r_i] = '.'; | ||
| 7269 | + r_i++; | ||
| 7270 | + for (;;) { | ||
| 7271 | + if (!(c1 < dec_digit)) break; | ||
| 7272 | + ((u8*)res.data)[r_i] = '0'; | ||
| 7273 | + r_i++; | ||
| 7274 | + c1++; | ||
| 7275 | + } | ||
| 7276 | + ((u8*)res.data)[r_i] = 0; | ||
| 7277 | + } | ||
| 7278 | + string tmp_res = builtin__string_clone(builtin__tos(res.data, r_i)); | ||
| 7279 | + builtin__array_free(&res); | ||
| 7280 | + return tmp_res; | ||
| 7281 | + } | ||
| 7282 | + } | ||
| 7283 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 7284 | +} | ||
| 7285 | +string strconv__format_fl(f64 f, strconv__BF_param p) { | ||
| 7286 | + { // Unsafe block | ||
| 7287 | + string fs = strconv__f64_to_str_lnd1((f >= ((f64)(0.0)) ? (f) : (-f)), p.len1); | ||
| 7288 | + if (fs.str[ 0] == '[') { | ||
| 7289 | + return fs; | ||
| 7290 | + } | ||
| 7291 | + if (p.rm_tail_zero) { | ||
| 7292 | + string tmp = fs; | ||
| 7293 | + fs = strconv__remove_tail_zeros(fs); | ||
| 7294 | + builtin__string_free(&tmp); | ||
| 7295 | + } | ||
| 7296 | + Array_fixed_u8_512 buf = {0}; | ||
| 7297 | + Array_fixed_u8_512 out = {0}; | ||
| 7298 | + int buf_i = 0; | ||
| 7299 | + int out_i = 0; | ||
| 7300 | + int sign_len_diff = 0; | ||
| 7301 | + if (p.pad_ch == '0') { | ||
| 7302 | + if (p.positive) { | ||
| 7303 | + if (p.sign_flag) { | ||
| 7304 | + out[out_i] = '+'; | ||
| 7305 | + out_i++; | ||
| 7306 | + sign_len_diff = -1; | ||
| 7307 | + } | ||
| 7308 | + } else { | ||
| 7309 | + out[out_i] = '-'; | ||
| 7310 | + out_i++; | ||
| 7311 | + sign_len_diff = -1; | ||
| 7312 | + } | ||
| 7313 | + } else { | ||
| 7314 | + if (p.positive) { | ||
| 7315 | + if (p.sign_flag) { | ||
| 7316 | + buf[buf_i] = '+'; | ||
| 7317 | + buf_i++; | ||
| 7318 | + } | ||
| 7319 | + } else { | ||
| 7320 | + buf[buf_i] = '-'; | ||
| 7321 | + buf_i++; | ||
| 7322 | + } | ||
| 7323 | + } | ||
| 7324 | + builtin__vmemcpy(&buf[buf_i], fs.str, fs.len); | ||
| 7325 | + buf_i += fs.len; | ||
| 7326 | + int dif = p.len0 - buf_i + sign_len_diff; | ||
| 7327 | + if (p.align == strconv__Align_text__right) { | ||
| 7328 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 7329 | + out[out_i] = p.pad_ch; | ||
| 7330 | + out_i++; | ||
| 7331 | + } | ||
| 7332 | + } | ||
| 7333 | + builtin__vmemcpy(&out[out_i], &buf[0], buf_i); | ||
| 7334 | + out_i += buf_i; | ||
| 7335 | + if (p.align == strconv__Align_text__left) { | ||
| 7336 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 7337 | + out[out_i] = p.pad_ch; | ||
| 7338 | + out_i++; | ||
| 7339 | + } | ||
| 7340 | + } | ||
| 7341 | + out[out_i] = 0; | ||
| 7342 | + string tmp = fs; | ||
| 7343 | + fs = builtin__tos_clone(&out[0]); | ||
| 7344 | + builtin__string_free(&tmp); | ||
| 7345 | + return fs; | ||
| 7346 | + } | ||
| 7347 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 7348 | +} | ||
| 7349 | +string strconv__format_es(f64 f, strconv__BF_param p) { | ||
| 7350 | + { // Unsafe block | ||
| 7351 | + string fs = strconv__f64_to_str_pad((f > 0 ? (f) : (-f)), p.len1); | ||
| 7352 | + if (p.rm_tail_zero) { | ||
| 7353 | + string tmp = fs; | ||
| 7354 | + fs = strconv__remove_tail_zeros(fs); | ||
| 7355 | + builtin__string_free(&tmp); | ||
| 7356 | + } | ||
| 7357 | + Array_fixed_u8_512 buf = {0}; | ||
| 7358 | + Array_fixed_u8_512 out = {0}; | ||
| 7359 | + int buf_i = 0; | ||
| 7360 | + int out_i = 0; | ||
| 7361 | + int sign_len_diff = 0; | ||
| 7362 | + if (p.pad_ch == '0') { | ||
| 7363 | + if (p.positive) { | ||
| 7364 | + if (p.sign_flag) { | ||
| 7365 | + out[out_i] = '+'; | ||
| 7366 | + out_i++; | ||
| 7367 | + sign_len_diff = -1; | ||
| 7368 | + } | ||
| 7369 | + } else { | ||
| 7370 | + out[out_i] = '-'; | ||
| 7371 | + out_i++; | ||
| 7372 | + sign_len_diff = -1; | ||
| 7373 | + } | ||
| 7374 | + } else { | ||
| 7375 | + if (p.positive) { | ||
| 7376 | + if (p.sign_flag) { | ||
| 7377 | + buf[buf_i] = '+'; | ||
| 7378 | + buf_i++; | ||
| 7379 | + } | ||
| 7380 | + } else { | ||
| 7381 | + buf[buf_i] = '-'; | ||
| 7382 | + buf_i++; | ||
| 7383 | + } | ||
| 7384 | + } | ||
| 7385 | + builtin__vmemcpy(&buf[buf_i], fs.str, fs.len); | ||
| 7386 | + buf_i += fs.len; | ||
| 7387 | + int dif = p.len0 - buf_i + sign_len_diff; | ||
| 7388 | + if (p.align == strconv__Align_text__right) { | ||
| 7389 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 7390 | + out[out_i] = p.pad_ch; | ||
| 7391 | + out_i++; | ||
| 7392 | + } | ||
| 7393 | + } | ||
| 7394 | + builtin__vmemcpy(&out[out_i], &buf[0], buf_i); | ||
| 7395 | + out_i += buf_i; | ||
| 7396 | + if (p.align == strconv__Align_text__left) { | ||
| 7397 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 7398 | + out[out_i] = p.pad_ch; | ||
| 7399 | + out_i++; | ||
| 7400 | + } | ||
| 7401 | + } | ||
| 7402 | + out[out_i] = 0; | ||
| 7403 | + string tmp = fs; | ||
| 7404 | + fs = builtin__tos_clone(&out[0]); | ||
| 7405 | + builtin__string_free(&tmp); | ||
| 7406 | + return fs; | ||
| 7407 | + } | ||
| 7408 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 7409 | +} | ||
| 7410 | +string strconv__remove_tail_zeros(string s) { | ||
| 7411 | + { // Unsafe block | ||
| 7412 | + u8* buf = builtin__malloc_noscan(s.len + 1); | ||
| 7413 | + int i_d = 0; | ||
| 7414 | + int i_s = 0; | ||
| 7415 | + for (;;) { | ||
| 7416 | + if (!(i_s < s.len && !(s.str[ i_s] == '-' || s.str[ i_s] == '+') && (s.str[ i_s] > '9' || s.str[ i_s] < '0'))) break; | ||
| 7417 | + buf[i_d] = s.str[ i_s]; | ||
| 7418 | + i_s++; | ||
| 7419 | + i_d++; | ||
| 7420 | + } | ||
| 7421 | + if (i_s < s.len && (s.str[ i_s] == '-' || s.str[ i_s] == '+')) { | ||
| 7422 | + buf[i_d] = s.str[ i_s]; | ||
| 7423 | + i_s++; | ||
| 7424 | + i_d++; | ||
| 7425 | + } | ||
| 7426 | + for (;;) { | ||
| 7427 | + if (!(i_s < s.len && s.str[ i_s] >= '0' && s.str[ i_s] <= '9')) break; | ||
| 7428 | + buf[i_d] = s.str[ i_s]; | ||
| 7429 | + i_s++; | ||
| 7430 | + i_d++; | ||
| 7431 | + } | ||
| 7432 | + if (i_s < s.len && s.str[ i_s] == '.') { | ||
| 7433 | + int i_s1 = i_s + 1; | ||
| 7434 | + int sum = 0; | ||
| 7435 | + int i_s2 = i_s1; | ||
| 7436 | + for (;;) { | ||
| 7437 | + if (!(i_s1 < s.len && s.str[ i_s1] >= '0' && s.str[ i_s1] <= '9')) break; | ||
| 7438 | + sum += (s.str[ i_s1] - ((u8)('0'))); | ||
| 7439 | + if (s.str[ i_s1] != '0') { | ||
| 7440 | + i_s2 = i_s1; | ||
| 7441 | + } | ||
| 7442 | + i_s1++; | ||
| 7443 | + } | ||
| 7444 | + if (sum > 0) { | ||
| 7445 | + for (int c_i = i_s; c_i < i_s2 + 1; ++c_i) { | ||
| 7446 | + buf[i_d] = s.str[ c_i]; | ||
| 7447 | + i_d++; | ||
| 7448 | + } | ||
| 7449 | + } | ||
| 7450 | + i_s = i_s1; | ||
| 7451 | + } | ||
| 7452 | + if (i_s < s.len && s.str[ i_s] != '.') { | ||
| 7453 | + for (;;) { | ||
| 7454 | + buf[i_d] = s.str[ i_s]; | ||
| 7455 | + i_s++; | ||
| 7456 | + i_d++; | ||
| 7457 | + if (i_s >= s.len) { | ||
| 7458 | + break; | ||
| 7459 | + } | ||
| 7460 | + } | ||
| 7461 | + } | ||
| 7462 | + buf[i_d] = 0; | ||
| 7463 | + return builtin__tos(buf, i_d); | ||
| 7464 | + } | ||
| 7465 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 7466 | +} | ||
| 7467 | +inline string strconv__ftoa_64(f64 f) { | ||
| 7468 | + return strconv__f64_to_str(f, 17); | ||
| 7469 | +} | ||
| 7470 | +inline string strconv__ftoa_long_64(f64 f) { | ||
| 7471 | + return strconv__f64_to_str_l(f); | ||
| 7472 | +} | ||
| 7473 | +inline string strconv__ftoa_32(f32 f) { | ||
| 7474 | + return strconv__f32_to_str(f, 8); | ||
| 7475 | +} | ||
| 7476 | +inline string strconv__ftoa_long_32(f32 f) { | ||
| 7477 | + return strconv__f32_to_str_l(f); | ||
| 7478 | +} | ||
| 7479 | +string strconv__format_int(i64 n, int radix) { | ||
| 7480 | + { // Unsafe block | ||
| 7481 | + if (radix < 2 || radix > 36) { | ||
| 7482 | + builtin__panic_n(_S("invalid radix, it should be => 2 and <= 36, actual:"), radix); | ||
| 7483 | + VUNREACHABLE(); | ||
| 7484 | + } | ||
| 7485 | + if (n == 0) { | ||
| 7486 | + return _S("0"); | ||
| 7487 | + } | ||
| 7488 | + i64 n_copy = n; | ||
| 7489 | + bool have_minus = false; | ||
| 7490 | + if (n < 0) { | ||
| 7491 | + have_minus = true; | ||
| 7492 | + n_copy = -n_copy; | ||
| 7493 | + } | ||
| 7494 | + string res = _S(""); | ||
| 7495 | + for (;;) { | ||
| 7496 | + if (!(n_copy != 0)) break; | ||
| 7497 | + string tmp_0 = res; | ||
| 7498 | + int bdx = ((int)((i64)(VSAFE_MOD_i64(n_copy , radix)))); | ||
| 7499 | + string tmp_1 = builtin__u8_ascii_str(_const_strconv__base_digits.str[ bdx]); | ||
| 7500 | + res = builtin__string__plus(tmp_1, res); | ||
| 7501 | + builtin__string_free(&tmp_0); | ||
| 7502 | + builtin__string_free(&tmp_1); | ||
| 7503 | + n_copy = VSAFE_DIV_i64(n_copy,radix); | ||
| 7504 | + } | ||
| 7505 | + if (have_minus) { | ||
| 7506 | + string final_res = builtin__string__plus(_S("-"), res); | ||
| 7507 | + builtin__string_free(&res); | ||
| 7508 | + return final_res; | ||
| 7509 | + } | ||
| 7510 | + return res; | ||
| 7511 | + } | ||
| 7512 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 7513 | +} | ||
| 7514 | +string strconv__format_uint(u64 n, int radix) { | ||
| 7515 | + { // Unsafe block | ||
| 7516 | + if (radix < 2 || radix > 36) { | ||
| 7517 | + builtin__panic_n(_S("invalid radix, it should be => 2 and <= 36, actual:"), radix); | ||
| 7518 | + VUNREACHABLE(); | ||
| 7519 | + } | ||
| 7520 | + if (n == 0) { | ||
| 7521 | + return _S("0"); | ||
| 7522 | + } | ||
| 7523 | + u64 n_copy = n; | ||
| 7524 | + string res = _S(""); | ||
| 7525 | + u64 uradix = ((u64)(radix)); | ||
| 7526 | + for (;;) { | ||
| 7527 | + if (!(n_copy != 0)) break; | ||
| 7528 | + string tmp_0 = res; | ||
| 7529 | + string tmp_1 = builtin__u8_ascii_str(_const_strconv__base_digits.str[ ((int)(VSAFE_MOD_u64(n_copy , uradix)))]); | ||
| 7530 | + res = builtin__string__plus(tmp_1, res); | ||
| 7531 | + builtin__string_free(&tmp_0); | ||
| 7532 | + builtin__string_free(&tmp_1); | ||
| 7533 | + n_copy = VSAFE_DIV_u64(n_copy,uradix); | ||
| 7534 | + } | ||
| 7535 | + return res; | ||
| 7536 | + } | ||
| 7537 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 7538 | +} | ||
| 7539 | +string strconv__f32_to_str_l(f32 f) { | ||
| 7540 | + string s = strconv__f32_to_str(f, 8); | ||
| 7541 | + string res = strconv__fxx_to_str_l_parse(s); | ||
| 7542 | + builtin__string_free(&s); | ||
| 7543 | + return res; | ||
| 7544 | +} | ||
| 7545 | +string strconv__f32_to_str_l_with_dot(f32 f) { | ||
| 7546 | + string s = strconv__f32_to_str(f, 8); | ||
| 7547 | + string res = strconv__fxx_to_str_l_parse_with_dot(s); | ||
| 7548 | + builtin__string_free(&s); | ||
| 7549 | + return res; | ||
| 7550 | +} | ||
| 7551 | +string strconv__f64_to_str_l(f64 f) { | ||
| 7552 | + string s = strconv__f64_to_str(f, 18); | ||
| 7553 | + string res = strconv__fxx_to_str_l_parse(s); | ||
| 7554 | + builtin__string_free(&s); | ||
| 7555 | + return res; | ||
| 7556 | +} | ||
| 7557 | +string strconv__f64_to_str_l_with_dot(f64 f) { | ||
| 7558 | + string s = strconv__f64_to_str(f, 18); | ||
| 7559 | + string res = strconv__fxx_to_str_l_parse_with_dot(s); | ||
| 7560 | + builtin__string_free(&s); | ||
| 7561 | + return res; | ||
| 7562 | +} | ||
| 7563 | +string strconv__fxx_to_str_l_parse(string s) { | ||
| 7564 | + if (s.len > 2 && (s.str[ 0] == 'n' || s.str[ 1] == 'i')) { | ||
| 7565 | + return builtin__string_clone(s); | ||
| 7566 | + } | ||
| 7567 | + bool m_sgn_flag = false; | ||
| 7568 | + int sgn = 1; | ||
| 7569 | + Array_fixed_u8_26 b = {0}; | ||
| 7570 | + int d_pos = 1; | ||
| 7571 | + int i = 0; | ||
| 7572 | + int i1 = 0; | ||
| 7573 | + int exp = 0; | ||
| 7574 | + int exp_sgn = 1; | ||
| 7575 | + for (int _t2 = 0; _t2 < s.len; ++_t2) { | ||
| 7576 | + u8 c = s.str[_t2]; | ||
| 7577 | + if (c == '-') { | ||
| 7578 | + sgn = -1; | ||
| 7579 | + i++; | ||
| 7580 | + } else if (c == '+') { | ||
| 7581 | + sgn = 1; | ||
| 7582 | + i++; | ||
| 7583 | + } else if (c >= '0' && c <= '9') { | ||
| 7584 | + b[i1] = c; | ||
| 7585 | + i1++; | ||
| 7586 | + i++; | ||
| 7587 | + } else if (c == '.') { | ||
| 7588 | + if (sgn > 0) { | ||
| 7589 | + d_pos = i; | ||
| 7590 | + } else { | ||
| 7591 | + d_pos = i - 1; | ||
| 7592 | + } | ||
| 7593 | + i++; | ||
| 7594 | + } else if (c == 'e') { | ||
| 7595 | + i++; | ||
| 7596 | + break; | ||
| 7597 | + } else { | ||
| 7598 | + return _S("Float conversion error!!"); | ||
| 7599 | + } | ||
| 7600 | + } | ||
| 7601 | + b[i1] = 0; | ||
| 7602 | + if (s.str[ i] == '-') { | ||
| 7603 | + exp_sgn = -1; | ||
| 7604 | + i++; | ||
| 7605 | + } else if (s.str[ i] == '+') { | ||
| 7606 | + exp_sgn = 1; | ||
| 7607 | + i++; | ||
| 7608 | + } | ||
| 7609 | + int c = i; | ||
| 7610 | + for (;;) { | ||
| 7611 | + if (!(c < s.len)) break; | ||
| 7612 | + exp = exp * 10 + ((int)((rune)(s.str[ c] - '0'))); | ||
| 7613 | + c++; | ||
| 7614 | + } | ||
| 7615 | + Array_u8 res = builtin____new_array_with_default(exp + 32, 0, sizeof(u8), &(u8[]){0}); | ||
| 7616 | + int r_i = 0; | ||
| 7617 | + if (sgn == 1) { | ||
| 7618 | + if (m_sgn_flag) { | ||
| 7619 | + ((u8*)res.data)[r_i] = '+'; | ||
| 7620 | + r_i++; | ||
| 7621 | + } | ||
| 7622 | + } else { | ||
| 7623 | + ((u8*)res.data)[r_i] = '-'; | ||
| 7624 | + r_i++; | ||
| 7625 | + } | ||
| 7626 | + i = 0; | ||
| 7627 | + if (exp_sgn >= 0) { | ||
| 7628 | + for (;;) { | ||
| 7629 | + if (!(b[i] != 0)) break; | ||
| 7630 | + ((u8*)res.data)[r_i] = b[i]; | ||
| 7631 | + r_i++; | ||
| 7632 | + i++; | ||
| 7633 | + if (i >= d_pos && exp >= 0) { | ||
| 7634 | + if (exp == 0) { | ||
| 7635 | + ((u8*)res.data)[r_i] = '.'; | ||
| 7636 | + r_i++; | ||
| 7637 | + } | ||
| 7638 | + exp--; | ||
| 7639 | + } | ||
| 7640 | + } | ||
| 7641 | + for (;;) { | ||
| 7642 | + if (!(exp >= 0)) break; | ||
| 7643 | + ((u8*)res.data)[r_i] = '0'; | ||
| 7644 | + r_i++; | ||
| 7645 | + exp--; | ||
| 7646 | + } | ||
| 7647 | + } else { | ||
| 7648 | + bool dot_p = true; | ||
| 7649 | + for (;;) { | ||
| 7650 | + if (!(exp > 0)) break; | ||
| 7651 | + ((u8*)res.data)[r_i] = '0'; | ||
| 7652 | + r_i++; | ||
| 7653 | + exp--; | ||
| 7654 | + if (dot_p) { | ||
| 7655 | + ((u8*)res.data)[r_i] = '.'; | ||
| 7656 | + r_i++; | ||
| 7657 | + dot_p = false; | ||
| 7658 | + } | ||
| 7659 | + } | ||
| 7660 | + for (;;) { | ||
| 7661 | + if (!(b[i] != 0)) break; | ||
| 7662 | + ((u8*)res.data)[r_i] = b[i]; | ||
| 7663 | + r_i++; | ||
| 7664 | + i++; | ||
| 7665 | + } | ||
| 7666 | + } | ||
| 7667 | + if (r_i > 1 && ((u8*)res.data)[r_i - 1] == '.') { | ||
| 7668 | + ((u8*)res.data)[r_i] = '0'; | ||
| 7669 | + r_i++; | ||
| 7670 | + } else if (!(Array_u8_contains(res, '.'))) { | ||
| 7671 | + ((u8*)res.data)[r_i] = '.'; | ||
| 7672 | + r_i++; | ||
| 7673 | + ((u8*)res.data)[r_i] = '0'; | ||
| 7674 | + r_i++; | ||
| 7675 | + } | ||
| 7676 | + ((u8*)res.data)[r_i] = 0; | ||
| 7677 | + string tmp_res = builtin__string_clone(builtin__tos(res.data, r_i)); | ||
| 7678 | + builtin__array_free(&res); | ||
| 7679 | + return tmp_res; | ||
| 7680 | +} | ||
| 7681 | +string strconv__fxx_to_str_l_parse_with_dot(string s) { | ||
| 7682 | + if (s.len > 2 && (s.str[ 0] == 'n' || s.str[ 1] == 'i')) { | ||
| 7683 | + return builtin__string_clone(s); | ||
| 7684 | + } | ||
| 7685 | + bool m_sgn_flag = false; | ||
| 7686 | + int sgn = 1; | ||
| 7687 | + Array_fixed_u8_26 b = {0}; | ||
| 7688 | + int d_pos = 1; | ||
| 7689 | + int i = 0; | ||
| 7690 | + int i1 = 0; | ||
| 7691 | + int exp = 0; | ||
| 7692 | + int exp_sgn = 1; | ||
| 7693 | + for (int _t2 = 0; _t2 < s.len; ++_t2) { | ||
| 7694 | + u8 c = s.str[_t2]; | ||
| 7695 | + if (c == '-') { | ||
| 7696 | + sgn = -1; | ||
| 7697 | + i++; | ||
| 7698 | + } else if (c == '+') { | ||
| 7699 | + sgn = 1; | ||
| 7700 | + i++; | ||
| 7701 | + } else if (c >= '0' && c <= '9') { | ||
| 7702 | + b[i1] = c; | ||
| 7703 | + i1++; | ||
| 7704 | + i++; | ||
| 7705 | + } else if (c == '.') { | ||
| 7706 | + if (sgn > 0) { | ||
| 7707 | + d_pos = i; | ||
| 7708 | + } else { | ||
| 7709 | + d_pos = i - 1; | ||
| 7710 | + } | ||
| 7711 | + i++; | ||
| 7712 | + } else if (c == 'e') { | ||
| 7713 | + i++; | ||
| 7714 | + break; | ||
| 7715 | + } else { | ||
| 7716 | + return _S("Float conversion error!!"); | ||
| 7717 | + } | ||
| 7718 | + } | ||
| 7719 | + b[i1] = 0; | ||
| 7720 | + if (s.str[ i] == '-') { | ||
| 7721 | + exp_sgn = -1; | ||
| 7722 | + i++; | ||
| 7723 | + } else if (s.str[ i] == '+') { | ||
| 7724 | + exp_sgn = 1; | ||
| 7725 | + i++; | ||
| 7726 | + } | ||
| 7727 | + int c = i; | ||
| 7728 | + for (;;) { | ||
| 7729 | + if (!(c < s.len)) break; | ||
| 7730 | + exp = exp * 10 + ((int)((rune)(s.str[ c] - '0'))); | ||
| 7731 | + c++; | ||
| 7732 | + } | ||
| 7733 | + Array_u8 res = builtin____new_array_with_default(exp + 32, 0, sizeof(u8), &(u8[]){0}); | ||
| 7734 | + int r_i = 0; | ||
| 7735 | + if (sgn == 1) { | ||
| 7736 | + if (m_sgn_flag) { | ||
| 7737 | + ((u8*)res.data)[r_i] = '+'; | ||
| 7738 | + r_i++; | ||
| 7739 | + } | ||
| 7740 | + } else { | ||
| 7741 | + ((u8*)res.data)[r_i] = '-'; | ||
| 7742 | + r_i++; | ||
| 7743 | + } | ||
| 7744 | + i = 0; | ||
| 7745 | + if (exp_sgn >= 0) { | ||
| 7746 | + for (;;) { | ||
| 7747 | + if (!(b[i] != 0)) break; | ||
| 7748 | + ((u8*)res.data)[r_i] = b[i]; | ||
| 7749 | + r_i++; | ||
| 7750 | + i++; | ||
| 7751 | + if (i >= d_pos && exp >= 0) { | ||
| 7752 | + if (exp == 0) { | ||
| 7753 | + ((u8*)res.data)[r_i] = '.'; | ||
| 7754 | + r_i++; | ||
| 7755 | + } | ||
| 7756 | + exp--; | ||
| 7757 | + } | ||
| 7758 | + } | ||
| 7759 | + for (;;) { | ||
| 7760 | + if (!(exp >= 0)) break; | ||
| 7761 | + ((u8*)res.data)[r_i] = '0'; | ||
| 7762 | + r_i++; | ||
| 7763 | + exp--; | ||
| 7764 | + } | ||
| 7765 | + } else { | ||
| 7766 | + bool dot_p = true; | ||
| 7767 | + for (;;) { | ||
| 7768 | + if (!(exp > 0)) break; | ||
| 7769 | + ((u8*)res.data)[r_i] = '0'; | ||
| 7770 | + r_i++; | ||
| 7771 | + exp--; | ||
| 7772 | + if (dot_p) { | ||
| 7773 | + ((u8*)res.data)[r_i] = '.'; | ||
| 7774 | + r_i++; | ||
| 7775 | + dot_p = false; | ||
| 7776 | + } | ||
| 7777 | + } | ||
| 7778 | + for (;;) { | ||
| 7779 | + if (!(b[i] != 0)) break; | ||
| 7780 | + ((u8*)res.data)[r_i] = b[i]; | ||
| 7781 | + r_i++; | ||
| 7782 | + i++; | ||
| 7783 | + } | ||
| 7784 | + } | ||
| 7785 | + if (r_i > 1 && ((u8*)res.data)[r_i - 1] == '.') { | ||
| 7786 | + ((u8*)res.data)[r_i] = '0'; | ||
| 7787 | + r_i++; | ||
| 7788 | + } else if (!(Array_u8_contains(res, '.'))) { | ||
| 7789 | + ((u8*)res.data)[r_i] = '.'; | ||
| 7790 | + r_i++; | ||
| 7791 | + ((u8*)res.data)[r_i] = '0'; | ||
| 7792 | + r_i++; | ||
| 7793 | + } | ||
| 7794 | + ((u8*)res.data)[r_i] = 0; | ||
| 7795 | + string tmp_res = builtin__string_clone(builtin__tos(res.data, r_i)); | ||
| 7796 | + builtin__array_free(&res); | ||
| 7797 | + return tmp_res; | ||
| 7798 | +} | ||
| 7799 | +inline VV_LOC u32 strconv__bool_to_u32(bool b) { | ||
| 7800 | + if (b) { | ||
| 7801 | + return ((u32)(1)); | ||
| 7802 | + } | ||
| 7803 | + return ((u32)(0)); | ||
| 7804 | +} | ||
| 7805 | +inline VV_LOC u64 strconv__bool_to_u64(bool b) { | ||
| 7806 | + if (b) { | ||
| 7807 | + return ((u64)(1)); | ||
| 7808 | + } | ||
| 7809 | + return ((u64)(0)); | ||
| 7810 | +} | ||
| 7811 | +VV_LOC string strconv__get_string_special(bool neg, bool expZero, bool mantZero) { | ||
| 7812 | + if (!mantZero) { | ||
| 7813 | + return _S("nan"); | ||
| 7814 | + } | ||
| 7815 | + if (!expZero) { | ||
| 7816 | + if (neg) { | ||
| 7817 | + return _S("-inf"); | ||
| 7818 | + } else { | ||
| 7819 | + return _S("+inf"); | ||
| 7820 | + } | ||
| 7821 | + } | ||
| 7822 | + if (neg) { | ||
| 7823 | + return _S("-0e+00"); | ||
| 7824 | + } | ||
| 7825 | + return _S("0e+00"); | ||
| 7826 | +} | ||
| 7827 | +VV_LOC u32 strconv__mul_shift_32(u32 m, u64 mul, int ishift) { | ||
| 7828 | + multi_return_u64_u64 mr_750 = math__bits__mul_64(((u64)(m)), mul); | ||
| 7829 | + u64 hi = mr_750.arg0; | ||
| 7830 | + u64 lo = mr_750.arg1; | ||
| 7831 | + u64 shifted_sum = (v__rshift_u64(lo, (u64)((u64)(ishift)))) + (v__lshift_u64(hi, (u64)((u64)(64 - ishift)))); | ||
| 7832 | + ; | ||
| 7833 | + return ((u32)(shifted_sum)); | ||
| 7834 | +} | ||
| 7835 | +inline VV_LOC u32 strconv__mul_pow5_invdiv_pow2(u32 m, u32 q, int j) { | ||
| 7836 | + ; | ||
| 7837 | + return strconv__mul_shift_32(m, _const_strconv__pow5_inv_split_32[q], j); | ||
| 7838 | +} | ||
| 7839 | +inline VV_LOC u32 strconv__mul_pow5_div_pow2(u32 m, u32 i, int j) { | ||
| 7840 | + ; | ||
| 7841 | + return strconv__mul_shift_32(m, _const_strconv__pow5_split_32[i], j); | ||
| 7842 | +} | ||
| 7843 | +VV_LOC u32 strconv__pow5_factor_32(u32 i_v) { | ||
| 7844 | + u32 v = i_v; | ||
| 7845 | + for (u32 n = ((u32)(0)); true; n++) { | ||
| 7846 | + u32 q = VSAFE_DIV_u32(v , 5); | ||
| 7847 | + u32 r = VSAFE_MOD_u32(v , 5); | ||
| 7848 | + if (r != 0) { | ||
| 7849 | + return n; | ||
| 7850 | + } | ||
| 7851 | + v = q; | ||
| 7852 | + } | ||
| 7853 | + return v; | ||
| 7854 | +} | ||
| 7855 | +VV_LOC bool strconv__multiple_of_power_of_five_32(u32 v, u32 p) { | ||
| 7856 | + return strconv__pow5_factor_32(v) >= p; | ||
| 7857 | +} | ||
| 7858 | +VV_LOC bool strconv__multiple_of_power_of_two_32(u32 v, u32 p) { | ||
| 7859 | + return ((u32)(math__bits__trailing_zeros_32(v))) >= p; | ||
| 7860 | +} | ||
| 7861 | +VV_LOC u32 strconv__log10_pow2(int e) { | ||
| 7862 | + ; | ||
| 7863 | + ; | ||
| 7864 | + return v__rshift_u32((((u32)(e)) * 78913), (u64)18); | ||
| 7865 | +} | ||
| 7866 | +VV_LOC u32 strconv__log10_pow5(int e) { | ||
| 7867 | + ; | ||
| 7868 | + ; | ||
| 7869 | + return v__rshift_u32((((u32)(e)) * 732923), (u64)20); | ||
| 7870 | +} | ||
| 7871 | +VV_LOC int strconv__pow5_bits(int e) { | ||
| 7872 | + ; | ||
| 7873 | + ; | ||
| 7874 | + return ((int)((v__rshift_u32((((u32)(e)) * 1217359), (u64)19)) + 1)); | ||
| 7875 | +} | ||
| 7876 | +VV_LOC u64 strconv__shift_right_128(strconv__Uint128 v, int shift) { | ||
| 7877 | + ; | ||
| 7878 | + return ((v__lshift_u64(v.hi, (u64)((u64)(64 - shift)))) | (v__rshift_u64(v.lo, (u64)((u32)(shift))))); | ||
| 7879 | +} | ||
| 7880 | +VV_LOC u64 strconv__mul_shift_64(u64 m, strconv__Uint128 mul, int shift) { | ||
| 7881 | + multi_return_u64_u64 mr_3253 = math__bits__mul_64(m, mul.hi); | ||
| 7882 | + u64 hihi = mr_3253.arg0; | ||
| 7883 | + u64 hilo = mr_3253.arg1; | ||
| 7884 | + multi_return_u64_u64 mr_3288 = math__bits__mul_64(m, mul.lo); | ||
| 7885 | + u64 lohi = mr_3288.arg0; | ||
| 7886 | + strconv__Uint128 sum = ((strconv__Uint128){.lo = lohi + hilo,.hi = hihi,}); | ||
| 7887 | + if (sum.lo < lohi) { | ||
| 7888 | + sum.hi++; | ||
| 7889 | + } | ||
| 7890 | + return strconv__shift_right_128(sum, shift - 64); | ||
| 7891 | +} | ||
| 7892 | +VV_LOC u32 strconv__pow5_factor_64(u64 v_i) { | ||
| 7893 | + u64 v = v_i; | ||
| 7894 | + for (u32 n = ((u32)(0)); true; n++) { | ||
| 7895 | + u64 q = VSAFE_DIV_u64(v , 5); | ||
| 7896 | + u64 r = VSAFE_MOD_u64(v , 5); | ||
| 7897 | + if (r != 0) { | ||
| 7898 | + return n; | ||
| 7899 | + } | ||
| 7900 | + v = q; | ||
| 7901 | + } | ||
| 7902 | + return ((u32)(0)); | ||
| 7903 | +} | ||
| 7904 | +VV_LOC bool strconv__multiple_of_power_of_five_64(u64 v, u32 p) { | ||
| 7905 | + return strconv__pow5_factor_64(v) >= p; | ||
| 7906 | +} | ||
| 7907 | +VV_LOC bool strconv__multiple_of_power_of_two_64(u64 v, u32 p) { | ||
| 7908 | + return ((u32)(math__bits__trailing_zeros_64(v))) >= p; | ||
| 7909 | +} | ||
| 7910 | +int strconv__dec_digits(u64 n) { | ||
| 7911 | + if (n <= 9999999999LL) { | ||
| 7912 | + if (n <= 99999) { | ||
| 7913 | + if (n <= 99) { | ||
| 7914 | + if (n <= 9) { | ||
| 7915 | + return 1; | ||
| 7916 | + } else { | ||
| 7917 | + return 2; | ||
| 7918 | + } | ||
| 7919 | + } else { | ||
| 7920 | + if (n <= 999) { | ||
| 7921 | + return 3; | ||
| 7922 | + } else { | ||
| 7923 | + if (n <= 9999) { | ||
| 7924 | + return 4; | ||
| 7925 | + } else { | ||
| 7926 | + return 5; | ||
| 7927 | + } | ||
| 7928 | + } | ||
| 7929 | + } | ||
| 7930 | + } else { | ||
| 7931 | + if (n <= 9999999) { | ||
| 7932 | + if (n <= 999999) { | ||
| 7933 | + return 6; | ||
| 7934 | + } else { | ||
| 7935 | + return 7; | ||
| 7936 | + } | ||
| 7937 | + } else { | ||
| 7938 | + if (n <= 99999999) { | ||
| 7939 | + return 8; | ||
| 7940 | + } else { | ||
| 7941 | + if (n <= 999999999) { | ||
| 7942 | + return 9; | ||
| 7943 | + } | ||
| 7944 | + return 10; | ||
| 7945 | + } | ||
| 7946 | + } | ||
| 7947 | + } | ||
| 7948 | + } else { | ||
| 7949 | + if (n <= 999999999999999LL) { | ||
| 7950 | + if (n <= 999999999999LL) { | ||
| 7951 | + if (n <= 99999999999LL) { | ||
| 7952 | + return 11; | ||
| 7953 | + } else { | ||
| 7954 | + return 12; | ||
| 7955 | + } | ||
| 7956 | + } else { | ||
| 7957 | + if (n <= 9999999999999LL) { | ||
| 7958 | + return 13; | ||
| 7959 | + } else { | ||
| 7960 | + if (n <= 99999999999999LL) { | ||
| 7961 | + return 14; | ||
| 7962 | + } else { | ||
| 7963 | + return 15; | ||
| 7964 | + } | ||
| 7965 | + } | ||
| 7966 | + } | ||
| 7967 | + } else { | ||
| 7968 | + if (n <= 99999999999999999LL) { | ||
| 7969 | + if (n <= 9999999999999999LL) { | ||
| 7970 | + return 16; | ||
| 7971 | + } else { | ||
| 7972 | + return 17; | ||
| 7973 | + } | ||
| 7974 | + } else { | ||
| 7975 | + if (n <= 999999999999999999LL) { | ||
| 7976 | + return 18; | ||
| 7977 | + } else { | ||
| 7978 | + if (n <= 9999999999999999999ULL) { | ||
| 7979 | + return 19; | ||
| 7980 | + } | ||
| 7981 | + return 20; | ||
| 7982 | + } | ||
| 7983 | + } | ||
| 7984 | + } | ||
| 7985 | + } | ||
| 7986 | + return 0; | ||
| 7987 | +} | ||
| 7988 | +void strconv__v_printf(string str, Array_voidptr pt) { | ||
| 7989 | + Array_voidptr _t1 = pt; | ||
| 7990 | + Array_voidptr _t2 = builtin____new_array(0, _t1.len, sizeof(voidptr)); | ||
| 7991 | + for (int _t3 = 0; _t3 < _t1.len; ++_t3) { | ||
| 7992 | + voidptr _t4 = (*(voidptr*)builtin__array_get(_t1, _t3)); | ||
| 7993 | + builtin__array_push((array*)&_t2, &_t4); | ||
| 7994 | + } | ||
| 7995 | + builtin__print(strconv__v_sprintf(str,_t2)); | ||
| 7996 | +} | ||
| 7997 | +string strconv__v_sprintf(string str, Array_voidptr pt) { | ||
| 7998 | + strings__Builder res = strings__new_builder(pt.len * 16); | ||
| 7999 | + int i = 0; | ||
| 8000 | + int p_index = 0; | ||
| 8001 | + bool sign = false; | ||
| 8002 | + strconv__Align_text align = strconv__Align_text__right; | ||
| 8003 | + int len0 = -1; | ||
| 8004 | + int len1 = -1; | ||
| 8005 | + int def_len1 = 6; | ||
| 8006 | + u8 pad_ch = ((u8)(' ')); | ||
| 8007 | + rune ch1 = '0'; | ||
| 8008 | + rune ch2 = '0'; | ||
| 8009 | + strconv__Char_parse_state status = strconv__Char_parse_state__norm_char; | ||
| 8010 | + for (;;) { | ||
| 8011 | + if (!(i < str.len)) break; | ||
| 8012 | + if (status == strconv__Char_parse_state__reset_params) { | ||
| 8013 | + sign = false; | ||
| 8014 | + align = strconv__Align_text__right; | ||
| 8015 | + len0 = -1; | ||
| 8016 | + len1 = -1; | ||
| 8017 | + pad_ch = ' '; | ||
| 8018 | + status = strconv__Char_parse_state__norm_char; | ||
| 8019 | + ch1 = '0'; | ||
| 8020 | + ch2 = '0'; | ||
| 8021 | + continue; | ||
| 8022 | + } | ||
| 8023 | + u8 ch = str.str[ i]; | ||
| 8024 | + if (ch != '%' && status == strconv__Char_parse_state__norm_char) { | ||
| 8025 | + strings__Builder_write_u8(&res, ch); | ||
| 8026 | + i++; | ||
| 8027 | + continue; | ||
| 8028 | + } | ||
| 8029 | + if (ch == '%' && status == strconv__Char_parse_state__field_char) { | ||
| 8030 | + status = strconv__Char_parse_state__norm_char; | ||
| 8031 | + strings__Builder_write_u8(&res, ch); | ||
| 8032 | + i++; | ||
| 8033 | + continue; | ||
| 8034 | + } | ||
| 8035 | + if (ch == '%' && status == strconv__Char_parse_state__norm_char) { | ||
| 8036 | + status = strconv__Char_parse_state__field_char; | ||
| 8037 | + i++; | ||
| 8038 | + continue; | ||
| 8039 | + } | ||
| 8040 | + if (ch == 'c' && status == strconv__Char_parse_state__field_char) { | ||
| 8041 | + strconv__v_sprintf_panic(p_index, pt.len); | ||
| 8042 | + u8 d1 = ((u8)(*(((int*)(((voidptr*)pt.data)[p_index]))))); | ||
| 8043 | + strings__Builder_write_u8(&res, d1); | ||
| 8044 | + status = strconv__Char_parse_state__reset_params; | ||
| 8045 | + p_index++; | ||
| 8046 | + i++; | ||
| 8047 | + continue; | ||
| 8048 | + } | ||
| 8049 | + if (ch == 'p' && status == strconv__Char_parse_state__field_char) { | ||
| 8050 | + strconv__v_sprintf_panic(p_index, pt.len); | ||
| 8051 | + strings__Builder_write_string(&res, _S("0x")); | ||
| 8052 | + strings__Builder_write_string(&res, builtin__ptr_str(((voidptr*)pt.data)[p_index])); | ||
| 8053 | + status = strconv__Char_parse_state__reset_params; | ||
| 8054 | + p_index++; | ||
| 8055 | + i++; | ||
| 8056 | + continue; | ||
| 8057 | + } | ||
| 8058 | + if (status == strconv__Char_parse_state__field_char) { | ||
| 8059 | + rune fc_ch1 = '0'; | ||
| 8060 | + rune fc_ch2 = '0'; | ||
| 8061 | + if ((i + 1) < str.len) { | ||
| 8062 | + fc_ch1 = str.str[ i + 1]; | ||
| 8063 | + if ((i + 2) < str.len) { | ||
| 8064 | + fc_ch2 = str.str[ i + 2]; | ||
| 8065 | + } | ||
| 8066 | + } | ||
| 8067 | + if (ch == '+') { | ||
| 8068 | + sign = true; | ||
| 8069 | + i++; | ||
| 8070 | + continue; | ||
| 8071 | + } else if (ch == '-') { | ||
| 8072 | + align = strconv__Align_text__left; | ||
| 8073 | + i++; | ||
| 8074 | + continue; | ||
| 8075 | + } else if (ch == '0' || ch == ' ') { | ||
| 8076 | + if (align == strconv__Align_text__right) { | ||
| 8077 | + pad_ch = ch; | ||
| 8078 | + } | ||
| 8079 | + i++; | ||
| 8080 | + continue; | ||
| 8081 | + } else if (ch == '\'') { | ||
| 8082 | + i++; | ||
| 8083 | + continue; | ||
| 8084 | + } else if (ch == '.' && fc_ch1 >= '1' && fc_ch1 <= '9') { | ||
| 8085 | + status = strconv__Char_parse_state__check_float; | ||
| 8086 | + i++; | ||
| 8087 | + continue; | ||
| 8088 | + } else if (ch == '.' && fc_ch1 == '*' && fc_ch2 == 's') { | ||
| 8089 | + strconv__v_sprintf_panic(p_index, pt.len); | ||
| 8090 | + int len = *(((int*)(((voidptr*)pt.data)[p_index]))); | ||
| 8091 | + p_index++; | ||
| 8092 | + strconv__v_sprintf_panic(p_index, pt.len); | ||
| 8093 | + string s = *(((string*)(((voidptr*)pt.data)[p_index]))); | ||
| 8094 | + s = builtin__string_substr(s, 0, len); | ||
| 8095 | + p_index++; | ||
| 8096 | + strings__Builder_write_string(&res, s); | ||
| 8097 | + status = strconv__Char_parse_state__reset_params; | ||
| 8098 | + i += 3; | ||
| 8099 | + continue; | ||
| 8100 | + } | ||
| 8101 | + status = strconv__Char_parse_state__len_set_start; | ||
| 8102 | + continue; | ||
| 8103 | + } | ||
| 8104 | + if (status == strconv__Char_parse_state__len_set_start) { | ||
| 8105 | + if (ch >= '1' && ch <= '9') { | ||
| 8106 | + len0 = ((int)((rune)(ch - '0'))); | ||
| 8107 | + status = strconv__Char_parse_state__len_set_in; | ||
| 8108 | + i++; | ||
| 8109 | + continue; | ||
| 8110 | + } | ||
| 8111 | + if (ch == '.') { | ||
| 8112 | + status = strconv__Char_parse_state__check_float; | ||
| 8113 | + i++; | ||
| 8114 | + continue; | ||
| 8115 | + } | ||
| 8116 | + status = strconv__Char_parse_state__check_type; | ||
| 8117 | + continue; | ||
| 8118 | + } | ||
| 8119 | + if (status == strconv__Char_parse_state__len_set_in) { | ||
| 8120 | + if (ch >= '0' && ch <= '9') { | ||
| 8121 | + len0 *= 10; | ||
| 8122 | + len0 += ((int)((rune)(ch - '0'))); | ||
| 8123 | + i++; | ||
| 8124 | + continue; | ||
| 8125 | + } | ||
| 8126 | + if (ch == '.') { | ||
| 8127 | + status = strconv__Char_parse_state__check_float; | ||
| 8128 | + i++; | ||
| 8129 | + continue; | ||
| 8130 | + } | ||
| 8131 | + status = strconv__Char_parse_state__check_type; | ||
| 8132 | + continue; | ||
| 8133 | + } | ||
| 8134 | + if (status == strconv__Char_parse_state__check_float) { | ||
| 8135 | + if (ch >= '0' && ch <= '9') { | ||
| 8136 | + len1 = ((int)((rune)(ch - '0'))); | ||
| 8137 | + status = strconv__Char_parse_state__check_float_in; | ||
| 8138 | + i++; | ||
| 8139 | + continue; | ||
| 8140 | + } | ||
| 8141 | + status = strconv__Char_parse_state__check_type; | ||
| 8142 | + continue; | ||
| 8143 | + } | ||
| 8144 | + if (status == strconv__Char_parse_state__check_float_in) { | ||
| 8145 | + if (ch >= '0' && ch <= '9') { | ||
| 8146 | + len1 *= 10; | ||
| 8147 | + len1 += ((int)((rune)(ch - '0'))); | ||
| 8148 | + i++; | ||
| 8149 | + continue; | ||
| 8150 | + } | ||
| 8151 | + status = strconv__Char_parse_state__check_type; | ||
| 8152 | + continue; | ||
| 8153 | + } | ||
| 8154 | + if (status == strconv__Char_parse_state__check_type) { | ||
| 8155 | + if (ch == 'l') { | ||
| 8156 | + if (ch1 == '0') { | ||
| 8157 | + ch1 = 'l'; | ||
| 8158 | + i++; | ||
| 8159 | + continue; | ||
| 8160 | + } else { | ||
| 8161 | + ch2 = 'l'; | ||
| 8162 | + i++; | ||
| 8163 | + continue; | ||
| 8164 | + } | ||
| 8165 | + } else if (ch == 'h') { | ||
| 8166 | + if (ch1 == '0') { | ||
| 8167 | + ch1 = 'h'; | ||
| 8168 | + i++; | ||
| 8169 | + continue; | ||
| 8170 | + } else { | ||
| 8171 | + ch2 = 'h'; | ||
| 8172 | + i++; | ||
| 8173 | + continue; | ||
| 8174 | + } | ||
| 8175 | + } else if (ch == 'd' || ch == 'i') { | ||
| 8176 | + u64 d1 = ((u64)(0)); | ||
| 8177 | + bool positive = true; | ||
| 8178 | + | ||
| 8179 | + if (ch1 == ('h')) { | ||
| 8180 | + strconv__v_sprintf_panic(p_index, pt.len); | ||
| 8181 | + int x = *(((int*)(((voidptr*)pt.data)[p_index]))); | ||
| 8182 | + if (ch2 == 'h') { | ||
| 8183 | + i8 sx = ((i8)(x)); | ||
| 8184 | + positive = (sx >= 0 ? (true) : (false)); | ||
| 8185 | + d1 = (positive ? (((u64)(sx))) : (((u64)(-sx)))); | ||
| 8186 | + } else { | ||
| 8187 | + i16 sx = ((i16)(x)); | ||
| 8188 | + positive = (sx >= 0 ? (true) : (false)); | ||
| 8189 | + d1 = (positive ? (((u64)(sx))) : (((u64)(-sx)))); | ||
| 8190 | + } | ||
| 8191 | + } | ||
| 8192 | + else if (ch1 == ('l')) { | ||
| 8193 | + strconv__v_sprintf_panic(p_index, pt.len); | ||
| 8194 | + i64 x = *(((i64*)(((voidptr*)pt.data)[p_index]))); | ||
| 8195 | + positive = (x >= 0 ? (true) : (false)); | ||
| 8196 | + d1 = (positive ? (((u64)(x))) : (((u64)(-x)))); | ||
| 8197 | + } | ||
| 8198 | + else { | ||
| 8199 | + strconv__v_sprintf_panic(p_index, pt.len); | ||
| 8200 | + int x = *(((int*)(((voidptr*)pt.data)[p_index]))); | ||
| 8201 | + positive = (x >= 0 ? (true) : (false)); | ||
| 8202 | + d1 = (positive ? (((u64)(x))) : (((u64)(-x)))); | ||
| 8203 | + } | ||
| 8204 | + string tmp = strconv__format_dec_old(d1, ((strconv__BF_param){ | ||
| 8205 | + .pad_ch = pad_ch, | ||
| 8206 | + .len0 = len0, | ||
| 8207 | + .len1 = 0, | ||
| 8208 | + .positive = positive, | ||
| 8209 | + .sign_flag = sign, | ||
| 8210 | + .align = align, | ||
| 8211 | + .rm_tail_zero = 0, | ||
| 8212 | + })); | ||
| 8213 | + strings__Builder_write_string(&res, tmp); | ||
| 8214 | + builtin__string_free(&tmp); | ||
| 8215 | + status = strconv__Char_parse_state__reset_params; | ||
| 8216 | + p_index++; | ||
| 8217 | + i++; | ||
| 8218 | + ch1 = '0'; | ||
| 8219 | + ch2 = '0'; | ||
| 8220 | + continue; | ||
| 8221 | + } else if (ch == 'u') { | ||
| 8222 | + u64 d1 = ((u64)(0)); | ||
| 8223 | + bool positive = true; | ||
| 8224 | + strconv__v_sprintf_panic(p_index, pt.len); | ||
| 8225 | + | ||
| 8226 | + if (ch1 == ('h')) { | ||
| 8227 | + int x = *(((int*)(((voidptr*)pt.data)[p_index]))); | ||
| 8228 | + if (ch2 == 'h') { | ||
| 8229 | + d1 = ((u64)(((u8)(x)))); | ||
| 8230 | + } else { | ||
| 8231 | + d1 = ((u64)(((u16)(x)))); | ||
| 8232 | + } | ||
| 8233 | + } | ||
| 8234 | + else if (ch1 == ('l')) { | ||
| 8235 | + d1 = ((u64)(*(((u64*)(((voidptr*)pt.data)[p_index]))))); | ||
| 8236 | + } | ||
| 8237 | + else { | ||
| 8238 | + d1 = ((u64)(((u32)(*(((int*)(((voidptr*)pt.data)[p_index]))))))); | ||
| 8239 | + } | ||
| 8240 | + string tmp = strconv__format_dec_old(d1, ((strconv__BF_param){ | ||
| 8241 | + .pad_ch = pad_ch, | ||
| 8242 | + .len0 = len0, | ||
| 8243 | + .len1 = 0, | ||
| 8244 | + .positive = positive, | ||
| 8245 | + .sign_flag = sign, | ||
| 8246 | + .align = align, | ||
| 8247 | + .rm_tail_zero = 0, | ||
| 8248 | + })); | ||
| 8249 | + strings__Builder_write_string(&res, tmp); | ||
| 8250 | + builtin__string_free(&tmp); | ||
| 8251 | + status = strconv__Char_parse_state__reset_params; | ||
| 8252 | + p_index++; | ||
| 8253 | + i++; | ||
| 8254 | + continue; | ||
| 8255 | + } else if (ch == 'x' || ch == 'X') { | ||
| 8256 | + strconv__v_sprintf_panic(p_index, pt.len); | ||
| 8257 | + string s = _S(""); | ||
| 8258 | + | ||
| 8259 | + if (ch1 == ('h')) { | ||
| 8260 | + int x = *(((int*)(((voidptr*)pt.data)[p_index]))); | ||
| 8261 | + if (ch2 == 'h') { | ||
| 8262 | + s = builtin__i8_hex(((i8)(x))); | ||
| 8263 | + } else { | ||
| 8264 | + s = builtin__i16_hex(((i16)(x))); | ||
| 8265 | + } | ||
| 8266 | + } | ||
| 8267 | + else if (ch1 == ('l')) { | ||
| 8268 | + i64 x = *(((i64*)(((voidptr*)pt.data)[p_index]))); | ||
| 8269 | + s = builtin__i64_hex(x); | ||
| 8270 | + } | ||
| 8271 | + else { | ||
| 8272 | + int x = *(((int*)(((voidptr*)pt.data)[p_index]))); | ||
| 8273 | + s = builtin__int_hex(x); | ||
| 8274 | + } | ||
| 8275 | + if (ch == 'X') { | ||
| 8276 | + string tmp = s; | ||
| 8277 | + s = builtin__string_to_upper(s); | ||
| 8278 | + builtin__string_free(&tmp); | ||
| 8279 | + } | ||
| 8280 | + string tmp = strconv__format_str(s, ((strconv__BF_param){ | ||
| 8281 | + .pad_ch = pad_ch, | ||
| 8282 | + .len0 = len0, | ||
| 8283 | + .len1 = 0, | ||
| 8284 | + .positive = true, | ||
| 8285 | + .sign_flag = false, | ||
| 8286 | + .align = align, | ||
| 8287 | + .rm_tail_zero = 0, | ||
| 8288 | + })); | ||
| 8289 | + strings__Builder_write_string(&res, tmp); | ||
| 8290 | + builtin__string_free(&tmp); | ||
| 8291 | + builtin__string_free(&s); | ||
| 8292 | + status = strconv__Char_parse_state__reset_params; | ||
| 8293 | + p_index++; | ||
| 8294 | + i++; | ||
| 8295 | + continue; | ||
| 8296 | + } | ||
| 8297 | + if (ch == 'f' || ch == 'F') { | ||
| 8298 | + #if !defined(CUSTOM_DEFINE_nofloat) | ||
| 8299 | + { | ||
| 8300 | + strconv__v_sprintf_panic(p_index, pt.len); | ||
| 8301 | + f64 x = *(((f64*)(((voidptr*)pt.data)[p_index]))); | ||
| 8302 | + bool positive = x >= ((f64)(0.0)); | ||
| 8303 | + len1 = (len1 >= 0 ? (len1) : (def_len1)); | ||
| 8304 | + string s = strconv__format_fl_old(((f64)(x)), ((strconv__BF_param){ | ||
| 8305 | + .pad_ch = pad_ch, | ||
| 8306 | + .len0 = len0, | ||
| 8307 | + .len1 = len1, | ||
| 8308 | + .positive = positive, | ||
| 8309 | + .sign_flag = sign, | ||
| 8310 | + .align = align, | ||
| 8311 | + .rm_tail_zero = 0, | ||
| 8312 | + })); | ||
| 8313 | + if (ch == 'F') { | ||
| 8314 | + string tmp = builtin__string_to_upper(s); | ||
| 8315 | + strings__Builder_write_string(&res, tmp); | ||
| 8316 | + builtin__string_free(&tmp); | ||
| 8317 | + } else { | ||
| 8318 | + strings__Builder_write_string(&res, s); | ||
| 8319 | + } | ||
| 8320 | + builtin__string_free(&s); | ||
| 8321 | + } | ||
| 8322 | + #endif | ||
| 8323 | + status = strconv__Char_parse_state__reset_params; | ||
| 8324 | + p_index++; | ||
| 8325 | + i++; | ||
| 8326 | + continue; | ||
| 8327 | + } else if (ch == 'e' || ch == 'E') { | ||
| 8328 | + #if !defined(CUSTOM_DEFINE_nofloat) | ||
| 8329 | + { | ||
| 8330 | + strconv__v_sprintf_panic(p_index, pt.len); | ||
| 8331 | + f64 x = *(((f64*)(((voidptr*)pt.data)[p_index]))); | ||
| 8332 | + bool positive = x >= ((f64)(0.0)); | ||
| 8333 | + len1 = (len1 >= 0 ? (len1) : (def_len1)); | ||
| 8334 | + string s = strconv__format_es_old(((f64)(x)), ((strconv__BF_param){ | ||
| 8335 | + .pad_ch = pad_ch, | ||
| 8336 | + .len0 = len0, | ||
| 8337 | + .len1 = len1, | ||
| 8338 | + .positive = positive, | ||
| 8339 | + .sign_flag = sign, | ||
| 8340 | + .align = align, | ||
| 8341 | + .rm_tail_zero = 0, | ||
| 8342 | + })); | ||
| 8343 | + if (ch == 'E') { | ||
| 8344 | + string tmp = builtin__string_to_upper(s); | ||
| 8345 | + strings__Builder_write_string(&res, tmp); | ||
| 8346 | + builtin__string_free(&tmp); | ||
| 8347 | + } else { | ||
| 8348 | + strings__Builder_write_string(&res, s); | ||
| 8349 | + } | ||
| 8350 | + builtin__string_free(&s); | ||
| 8351 | + } | ||
| 8352 | + #endif | ||
| 8353 | + status = strconv__Char_parse_state__reset_params; | ||
| 8354 | + p_index++; | ||
| 8355 | + i++; | ||
| 8356 | + continue; | ||
| 8357 | + } else if (ch == 'g' || ch == 'G') { | ||
| 8358 | + #if !defined(CUSTOM_DEFINE_nofloat) | ||
| 8359 | + { | ||
| 8360 | + strconv__v_sprintf_panic(p_index, pt.len); | ||
| 8361 | + f64 x = *(((f64*)(((voidptr*)pt.data)[p_index]))); | ||
| 8362 | + bool positive = x >= ((f64)(0.0)); | ||
| 8363 | + string s = _S(""); | ||
| 8364 | + f64 tx = strconv__fabs(x); | ||
| 8365 | + if (tx < ((f64)(999999.0)) && tx >= ((f64)(0.00001))) { | ||
| 8366 | + len1 = (len1 >= 0 ? (len1 + 1) : (def_len1)); | ||
| 8367 | + string tmp = s; | ||
| 8368 | + s = strconv__format_fl_old(x, ((strconv__BF_param){ | ||
| 8369 | + .pad_ch = pad_ch, | ||
| 8370 | + .len0 = len0, | ||
| 8371 | + .len1 = len1, | ||
| 8372 | + .positive = positive, | ||
| 8373 | + .sign_flag = sign, | ||
| 8374 | + .align = align, | ||
| 8375 | + .rm_tail_zero = true, | ||
| 8376 | + })); | ||
| 8377 | + builtin__string_free(&tmp); | ||
| 8378 | + } else { | ||
| 8379 | + len1 = (len1 >= 0 ? (len1 + 1) : (def_len1)); | ||
| 8380 | + string tmp = s; | ||
| 8381 | + s = strconv__format_es_old(x, ((strconv__BF_param){ | ||
| 8382 | + .pad_ch = pad_ch, | ||
| 8383 | + .len0 = len0, | ||
| 8384 | + .len1 = len1, | ||
| 8385 | + .positive = positive, | ||
| 8386 | + .sign_flag = sign, | ||
| 8387 | + .align = align, | ||
| 8388 | + .rm_tail_zero = true, | ||
| 8389 | + })); | ||
| 8390 | + builtin__string_free(&tmp); | ||
| 8391 | + } | ||
| 8392 | + if (ch == 'G') { | ||
| 8393 | + string tmp = builtin__string_to_upper(s); | ||
| 8394 | + strings__Builder_write_string(&res, tmp); | ||
| 8395 | + builtin__string_free(&tmp); | ||
| 8396 | + } else { | ||
| 8397 | + strings__Builder_write_string(&res, s); | ||
| 8398 | + } | ||
| 8399 | + builtin__string_free(&s); | ||
| 8400 | + } | ||
| 8401 | + #endif | ||
| 8402 | + status = strconv__Char_parse_state__reset_params; | ||
| 8403 | + p_index++; | ||
| 8404 | + i++; | ||
| 8405 | + continue; | ||
| 8406 | + } else if (ch == 's') { | ||
| 8407 | + strconv__v_sprintf_panic(p_index, pt.len); | ||
| 8408 | + string s1 = *(((string*)(((voidptr*)pt.data)[p_index]))); | ||
| 8409 | + pad_ch = ' '; | ||
| 8410 | + string tmp = strconv__format_str(s1, ((strconv__BF_param){ | ||
| 8411 | + .pad_ch = pad_ch, | ||
| 8412 | + .len0 = len0, | ||
| 8413 | + .len1 = 0, | ||
| 8414 | + .positive = true, | ||
| 8415 | + .sign_flag = false, | ||
| 8416 | + .align = align, | ||
| 8417 | + .rm_tail_zero = 0, | ||
| 8418 | + })); | ||
| 8419 | + strings__Builder_write_string(&res, tmp); | ||
| 8420 | + builtin__string_free(&tmp); | ||
| 8421 | + status = strconv__Char_parse_state__reset_params; | ||
| 8422 | + p_index++; | ||
| 8423 | + i++; | ||
| 8424 | + continue; | ||
| 8425 | + } | ||
| 8426 | + } | ||
| 8427 | + status = strconv__Char_parse_state__reset_params; | ||
| 8428 | + p_index++; | ||
| 8429 | + i++; | ||
| 8430 | + } | ||
| 8431 | + if (p_index != pt.len) { | ||
| 8432 | + builtin__panic_n2(_S("% conversion specifiers number mismatch (expected %, given args)"), p_index, pt.len); | ||
| 8433 | + VUNREACHABLE(); | ||
| 8434 | + } | ||
| 8435 | + string _t4 = strings__Builder_str(&res); | ||
| 8436 | + { // defer begin | ||
| 8437 | + strings__Builder_free(&res); | ||
| 8438 | + } // defer end | ||
| 8439 | + return _t4; | ||
| 8440 | +} | ||
| 8441 | +inline VV_LOC void strconv__v_sprintf_panic(int idx, int len) { | ||
| 8442 | + if (idx >= len) { | ||
| 8443 | + builtin__panic_n2(_S("% conversion specifiers number mismatch (expected %, given args)"), idx + 1, len); | ||
| 8444 | + VUNREACHABLE(); | ||
| 8445 | + } | ||
| 8446 | +} | ||
| 8447 | +VV_LOC f64 strconv__fabs(f64 x) { | ||
| 8448 | + if (x < ((f64)(0.0))) { | ||
| 8449 | + return -x; | ||
| 8450 | + } | ||
| 8451 | + return x; | ||
| 8452 | +} | ||
| 8453 | +string strconv__format_fl_old(f64 f, strconv__BF_param p) { | ||
| 8454 | + { // Unsafe block | ||
| 8455 | + string s = _S(""); | ||
| 8456 | + string fs = strconv__f64_to_str_lnd1((f >= ((f64)(0.0)) ? (f) : (-f)), p.len1); | ||
| 8457 | + if (fs.str[ 0] == '[') { | ||
| 8458 | + builtin__string_free(&s); | ||
| 8459 | + return fs; | ||
| 8460 | + } | ||
| 8461 | + if (p.rm_tail_zero) { | ||
| 8462 | + string tmp = fs; | ||
| 8463 | + fs = strconv__remove_tail_zeros_old(fs); | ||
| 8464 | + builtin__string_free(&tmp); | ||
| 8465 | + } | ||
| 8466 | + strings__Builder res = strings__new_builder((p.len0 > fs.len ? (p.len0) : (fs.len))); | ||
| 8467 | + int sign_len_diff = 0; | ||
| 8468 | + if (p.pad_ch == '0') { | ||
| 8469 | + if (p.positive) { | ||
| 8470 | + if (p.sign_flag) { | ||
| 8471 | + strings__Builder_write_u8(&res, '+'); | ||
| 8472 | + sign_len_diff = -1; | ||
| 8473 | + } | ||
| 8474 | + } else { | ||
| 8475 | + strings__Builder_write_u8(&res, '-'); | ||
| 8476 | + sign_len_diff = -1; | ||
| 8477 | + } | ||
| 8478 | + string tmp = s; | ||
| 8479 | + s = builtin__string_clone(fs); | ||
| 8480 | + builtin__string_free(&tmp); | ||
| 8481 | + } else { | ||
| 8482 | + if (p.positive) { | ||
| 8483 | + if (p.sign_flag) { | ||
| 8484 | + string tmp = s; | ||
| 8485 | + s = builtin__string__plus(_S("+"), fs); | ||
| 8486 | + builtin__string_free(&tmp); | ||
| 8487 | + } else { | ||
| 8488 | + string tmp = s; | ||
| 8489 | + s = builtin__string_clone(fs); | ||
| 8490 | + builtin__string_free(&tmp); | ||
| 8491 | + } | ||
| 8492 | + } else { | ||
| 8493 | + string tmp = s; | ||
| 8494 | + s = builtin__string__plus(_S("-"), fs); | ||
| 8495 | + builtin__string_free(&tmp); | ||
| 8496 | + } | ||
| 8497 | + } | ||
| 8498 | + int dif = p.len0 - s.len + sign_len_diff; | ||
| 8499 | + if (p.align == strconv__Align_text__right) { | ||
| 8500 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 8501 | + strings__Builder_write_u8(&res, p.pad_ch); | ||
| 8502 | + } | ||
| 8503 | + } | ||
| 8504 | + strings__Builder_write_string(&res, s); | ||
| 8505 | + if (p.align == strconv__Align_text__left) { | ||
| 8506 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 8507 | + strings__Builder_write_u8(&res, p.pad_ch); | ||
| 8508 | + } | ||
| 8509 | + } | ||
| 8510 | + builtin__string_free(&s); | ||
| 8511 | + builtin__string_free(&fs); | ||
| 8512 | + string _t2 = strings__Builder_str(&res); | ||
| 8513 | + { // defer begin | ||
| 8514 | + strings__Builder_free(&res); | ||
| 8515 | + } // defer end | ||
| 8516 | + return _t2; | ||
| 8517 | + { // defer begin | ||
| 8518 | + strings__Builder_free(&res); | ||
| 8519 | + } // defer end | ||
| 8520 | + } | ||
| 8521 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 8522 | +} | ||
| 8523 | +VV_LOC string strconv__format_es_old(f64 f, strconv__BF_param p) { | ||
| 8524 | + { // Unsafe block | ||
| 8525 | + string s = _S(""); | ||
| 8526 | + string fs = strconv__f64_to_str_pad((f > 0 ? (f) : (-f)), p.len1); | ||
| 8527 | + if (p.rm_tail_zero) { | ||
| 8528 | + string tmp = fs; | ||
| 8529 | + fs = strconv__remove_tail_zeros_old(fs); | ||
| 8530 | + builtin__string_free(&tmp); | ||
| 8531 | + } | ||
| 8532 | + strings__Builder res = strings__new_builder((p.len0 > fs.len ? (p.len0) : (fs.len))); | ||
| 8533 | + int sign_len_diff = 0; | ||
| 8534 | + if (p.pad_ch == '0') { | ||
| 8535 | + if (p.positive) { | ||
| 8536 | + if (p.sign_flag) { | ||
| 8537 | + strings__Builder_write_u8(&res, '+'); | ||
| 8538 | + sign_len_diff = -1; | ||
| 8539 | + } | ||
| 8540 | + } else { | ||
| 8541 | + strings__Builder_write_u8(&res, '-'); | ||
| 8542 | + sign_len_diff = -1; | ||
| 8543 | + } | ||
| 8544 | + string tmp = s; | ||
| 8545 | + s = builtin__string_clone(fs); | ||
| 8546 | + builtin__string_free(&tmp); | ||
| 8547 | + } else { | ||
| 8548 | + if (p.positive) { | ||
| 8549 | + if (p.sign_flag) { | ||
| 8550 | + string tmp = s; | ||
| 8551 | + s = builtin__string__plus(_S("+"), fs); | ||
| 8552 | + builtin__string_free(&tmp); | ||
| 8553 | + } else { | ||
| 8554 | + string tmp = s; | ||
| 8555 | + s = builtin__string_clone(fs); | ||
| 8556 | + builtin__string_free(&tmp); | ||
| 8557 | + } | ||
| 8558 | + } else { | ||
| 8559 | + string tmp = s; | ||
| 8560 | + s = builtin__string__plus(_S("-"), fs); | ||
| 8561 | + builtin__string_free(&tmp); | ||
| 8562 | + } | ||
| 8563 | + } | ||
| 8564 | + int dif = p.len0 - s.len + sign_len_diff; | ||
| 8565 | + if (p.align == strconv__Align_text__right) { | ||
| 8566 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 8567 | + strings__Builder_write_u8(&res, p.pad_ch); | ||
| 8568 | + } | ||
| 8569 | + } | ||
| 8570 | + strings__Builder_write_string(&res, s); | ||
| 8571 | + if (p.align == strconv__Align_text__left) { | ||
| 8572 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 8573 | + strings__Builder_write_u8(&res, p.pad_ch); | ||
| 8574 | + } | ||
| 8575 | + } | ||
| 8576 | + string _t1 = strings__Builder_str(&res); | ||
| 8577 | + { // defer begin | ||
| 8578 | + strings__Builder_free(&res); | ||
| 8579 | + builtin__string_free(&fs); | ||
| 8580 | + builtin__string_free(&s); | ||
| 8581 | + } // defer end | ||
| 8582 | + return _t1; | ||
| 8583 | + { // defer begin | ||
| 8584 | + strings__Builder_free(&res); | ||
| 8585 | + builtin__string_free(&fs); | ||
| 8586 | + builtin__string_free(&s); | ||
| 8587 | + } // defer end | ||
| 8588 | + } | ||
| 8589 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 8590 | +} | ||
| 8591 | +VV_LOC string strconv__remove_tail_zeros_old(string s) { | ||
| 8592 | + int i = 0; | ||
| 8593 | + int last_zero_start = -1; | ||
| 8594 | + int dot_pos = -1; | ||
| 8595 | + bool in_decimal = false; | ||
| 8596 | + u8 prev_ch = ((u8)(0)); | ||
| 8597 | + for (;;) { | ||
| 8598 | + if (!(i < s.len)) break; | ||
| 8599 | + u8 ch = s.str[i]; | ||
| 8600 | + if (ch == '.') { | ||
| 8601 | + in_decimal = true; | ||
| 8602 | + dot_pos = i; | ||
| 8603 | + } else if (in_decimal) { | ||
| 8604 | + if (ch == '0' && prev_ch != '0') { | ||
| 8605 | + last_zero_start = i; | ||
| 8606 | + } else if (ch >= '1' && ch <= '9') { | ||
| 8607 | + last_zero_start = -1; | ||
| 8608 | + } else if (ch == 'e') { | ||
| 8609 | + break; | ||
| 8610 | + } | ||
| 8611 | + } | ||
| 8612 | + prev_ch = ch; | ||
| 8613 | + i++; | ||
| 8614 | + } | ||
| 8615 | + string tmp = _S(""); | ||
| 8616 | + if (last_zero_start > 0) { | ||
| 8617 | + if (last_zero_start == dot_pos + 1) { | ||
| 8618 | + tmp = builtin__string__plus(builtin__string_substr(s, 0, dot_pos), builtin__string_substr(s, i, 2147483647)); | ||
| 8619 | + } else { | ||
| 8620 | + tmp = builtin__string__plus(builtin__string_substr(s, 0, last_zero_start), builtin__string_substr(s, i, 2147483647)); | ||
| 8621 | + } | ||
| 8622 | + } else { | ||
| 8623 | + tmp = builtin__string_clone(s); | ||
| 8624 | + } | ||
| 8625 | + if (tmp.str[tmp.len - 1] == '.') { | ||
| 8626 | + return builtin__string_substr(tmp, 0, tmp.len - 1); | ||
| 8627 | + } | ||
| 8628 | + return tmp; | ||
| 8629 | +} | ||
| 8630 | +string strconv__format_dec_old(u64 d, strconv__BF_param p) { | ||
| 8631 | + string s = _S(""); | ||
| 8632 | + strings__Builder res = strings__new_builder(20); | ||
| 8633 | + int sign_len_diff = 0; | ||
| 8634 | + if (p.pad_ch == '0') { | ||
| 8635 | + if (p.positive) { | ||
| 8636 | + if (p.sign_flag) { | ||
| 8637 | + strings__Builder_write_u8(&res, '+'); | ||
| 8638 | + sign_len_diff = -1; | ||
| 8639 | + } | ||
| 8640 | + } else { | ||
| 8641 | + strings__Builder_write_u8(&res, '-'); | ||
| 8642 | + sign_len_diff = -1; | ||
| 8643 | + } | ||
| 8644 | + string tmp = s; | ||
| 8645 | + s = builtin__u64_str(d); | ||
| 8646 | + builtin__string_free(&tmp); | ||
| 8647 | + } else { | ||
| 8648 | + if (p.positive) { | ||
| 8649 | + if (p.sign_flag) { | ||
| 8650 | + string tmp = s; | ||
| 8651 | + s = builtin__string__plus(_S("+"), builtin__u64_str(d)); | ||
| 8652 | + builtin__string_free(&tmp); | ||
| 8653 | + } else { | ||
| 8654 | + string tmp = s; | ||
| 8655 | + s = builtin__u64_str(d); | ||
| 8656 | + builtin__string_free(&tmp); | ||
| 8657 | + } | ||
| 8658 | + } else { | ||
| 8659 | + string tmp = s; | ||
| 8660 | + s = builtin__string__plus(_S("-"), builtin__u64_str(d)); | ||
| 8661 | + builtin__string_free(&tmp); | ||
| 8662 | + } | ||
| 8663 | + } | ||
| 8664 | + int dif = p.len0 - s.len + sign_len_diff; | ||
| 8665 | + if (p.align == strconv__Align_text__right) { | ||
| 8666 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 8667 | + strings__Builder_write_u8(&res, p.pad_ch); | ||
| 8668 | + } | ||
| 8669 | + } | ||
| 8670 | + strings__Builder_write_string(&res, s); | ||
| 8671 | + if (p.align == strconv__Align_text__left) { | ||
| 8672 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 8673 | + strings__Builder_write_u8(&res, p.pad_ch); | ||
| 8674 | + } | ||
| 8675 | + } | ||
| 8676 | + string _t1 = strings__Builder_str(&res); | ||
| 8677 | + { // defer begin | ||
| 8678 | + strings__Builder_free(&res); | ||
| 8679 | + builtin__string_free(&s); | ||
| 8680 | + } // defer end | ||
| 8681 | + return _t1; | ||
| 8682 | +} | ||
| 8683 | +int strconv__write_dec(i64 n, Array_u8* buf) { | ||
| 8684 | + u64 mag = ((u64)(n)); | ||
| 8685 | + if (n < 0) { | ||
| 8686 | + mag = ((u64)(0)) - mag; | ||
| 8687 | + int ndigits = strconv__dec_digits(mag); | ||
| 8688 | + if (buf->len < ndigits + 1) { | ||
| 8689 | + return -1; | ||
| 8690 | + } | ||
| 8691 | + ((u8*)buf->data)[0] = '-'; | ||
| 8692 | + strconv__write_dec_u_digits(mag, buf, 1, ndigits); | ||
| 8693 | + return ndigits + 1; | ||
| 8694 | + } | ||
| 8695 | + int ndigits = strconv__dec_digits(mag); | ||
| 8696 | + if (buf->len < ndigits) { | ||
| 8697 | + return -1; | ||
| 8698 | + } | ||
| 8699 | + strconv__write_dec_u_digits(mag, buf, 0, ndigits); | ||
| 8700 | + return ndigits; | ||
| 8701 | +} | ||
| 8702 | +int strconv__write_dec_u(u64 n, Array_u8* buf) { | ||
| 8703 | + int ndigits = strconv__dec_digits(n); | ||
| 8704 | + if (buf->len < ndigits) { | ||
| 8705 | + return -1; | ||
| 8706 | + } | ||
| 8707 | + strconv__write_dec_u_digits(n, buf, 0, ndigits); | ||
| 8708 | + return ndigits; | ||
| 8709 | +} | ||
| 8710 | +VV_LOC void strconv__write_dec_u_digits(u64 n, Array_u8* buf, int offset, int ndigits) { | ||
| 8711 | + u64 x = n; | ||
| 8712 | + int i = offset + ndigits; | ||
| 8713 | + for (;;) { | ||
| 8714 | + i--; | ||
| 8715 | + ((u8*)buf->data)[i] = (rune)(((u8)(VSAFE_MOD_u64(x , 10))) + '0'); | ||
| 8716 | + x = VSAFE_DIV_u64(x,10); | ||
| 8717 | + if (x == 0) { | ||
| 8718 | + break; | ||
| 8719 | + } | ||
| 8720 | + } | ||
| 8721 | +} | ||
| 8722 | +VNORETURN VV_LOC void builtin___memory_panic(string fname, isize size) { | ||
| 8723 | + v_memory_panic = true; | ||
| 8724 | + builtin__eprint(fname); | ||
| 8725 | + builtin__eprint(_S("(")); | ||
| 8726 | + #if 0 | ||
| 8727 | + { | ||
| 8728 | + } | ||
| 8729 | + #else | ||
| 8730 | + { | ||
| 8731 | + fprintf(stderr, "%p", ((voidptr)(size))); | ||
| 8732 | + } | ||
| 8733 | + #endif | ||
| 8734 | + if (size < 0) { | ||
| 8735 | + builtin__eprint(_S(" < 0")); | ||
| 8736 | + } | ||
| 8737 | + builtin__eprintln(_S(")")); | ||
| 8738 | + builtin___v_panic(_S("memory allocation failure")); | ||
| 8739 | + VUNREACHABLE(); | ||
| 8740 | + while(1); | ||
| 8741 | +} | ||
| 8742 | +u8* builtin___v_malloc(isize n) { | ||
| 8743 | + if (n < 0) { | ||
| 8744 | + builtin___memory_panic(_S("malloc"), n); | ||
| 8745 | + VUNREACHABLE(); | ||
| 8746 | + } else if (n == 0) { | ||
| 8747 | + return ((u8*)(((void*)0))); | ||
| 8748 | + } | ||
| 8749 | + u8* res = ((u8*)(((void*)0))); | ||
| 8750 | + #if 0 | ||
| 8751 | + { | ||
| 8752 | + } | ||
| 8753 | + #elif defined(CUSTOM_DEFINE_vgc) | ||
| 8754 | + { | ||
| 8755 | + } | ||
| 8756 | + #elif defined(CUSTOM_DEFINE_gcboehm) | ||
| 8757 | + { | ||
| 8758 | + } | ||
| 8759 | + #elif 0 | ||
| 8760 | + { | ||
| 8761 | + } | ||
| 8762 | + #else | ||
| 8763 | + { | ||
| 8764 | + #if 0 | ||
| 8765 | + { | ||
| 8766 | + } | ||
| 8767 | + #else | ||
| 8768 | + { | ||
| 8769 | + res = malloc(n); | ||
| 8770 | + } | ||
| 8771 | + #endif | ||
| 8772 | + } | ||
| 8773 | + #endif | ||
| 8774 | + if (res == 0) { | ||
| 8775 | + builtin___memory_panic(_S("malloc"), n); | ||
| 8776 | + VUNREACHABLE(); | ||
| 8777 | + } | ||
| 8778 | + ; | ||
| 8779 | + return res; | ||
| 8780 | +} | ||
| 8781 | +u8* builtin__malloc_noscan(isize n) { | ||
| 8782 | + if (n < 0) { | ||
| 8783 | + builtin___memory_panic(_S("malloc_noscan"), n); | ||
| 8784 | + VUNREACHABLE(); | ||
| 8785 | + } | ||
| 8786 | + u8* res = ((u8*)(((void*)0))); | ||
| 8787 | + #if 0 | ||
| 8788 | + { | ||
| 8789 | + } | ||
| 8790 | + #elif defined(CUSTOM_DEFINE_vgc) | ||
| 8791 | + { | ||
| 8792 | + } | ||
| 8793 | + #elif defined(CUSTOM_DEFINE_gcboehm) | ||
| 8794 | + { | ||
| 8795 | + } | ||
| 8796 | + #elif 0 | ||
| 8797 | + { | ||
| 8798 | + } | ||
| 8799 | + #else | ||
| 8800 | + { | ||
| 8801 | + #if 0 | ||
| 8802 | + { | ||
| 8803 | + } | ||
| 8804 | + #else | ||
| 8805 | + { | ||
| 8806 | + res = malloc(n); | ||
| 8807 | + } | ||
| 8808 | + #endif | ||
| 8809 | + } | ||
| 8810 | + #endif | ||
| 8811 | + if (res == 0) { | ||
| 8812 | + builtin___memory_panic(_S("malloc_noscan"), n); | ||
| 8813 | + VUNREACHABLE(); | ||
| 8814 | + } | ||
| 8815 | + ; | ||
| 8816 | + return res; | ||
| 8817 | +} | ||
| 8818 | +VV_LOC u8* builtin__malloc_uninit(isize n) { | ||
| 8819 | + if (n < 0) { | ||
| 8820 | + builtin___memory_panic(_S("malloc_uninit"), n); | ||
| 8821 | + VUNREACHABLE(); | ||
| 8822 | + } else if (n == 0) { | ||
| 8823 | + return ((u8*)(((void*)0))); | ||
| 8824 | + } | ||
| 8825 | + return builtin___v_malloc(n); | ||
| 8826 | +} | ||
| 8827 | +inline VV_LOC u64 builtin____at_least_one(u64 how_many) { | ||
| 8828 | + if (how_many == 0) { | ||
| 8829 | + return 1; | ||
| 8830 | + } | ||
| 8831 | + return how_many; | ||
| 8832 | +} | ||
| 8833 | +u8* builtin__malloc_uncollectable(isize n) { | ||
| 8834 | + if (n < 0) { | ||
| 8835 | + builtin___memory_panic(_S("malloc_uncollectable"), n); | ||
| 8836 | + VUNREACHABLE(); | ||
| 8837 | + } | ||
| 8838 | + u8* res = ((u8*)(((void*)0))); | ||
| 8839 | + #if 0 | ||
| 8840 | + { | ||
| 8841 | + } | ||
| 8842 | + #elif defined(CUSTOM_DEFINE_vgc) | ||
| 8843 | + { | ||
| 8844 | + } | ||
| 8845 | + #elif defined(CUSTOM_DEFINE_gcboehm) | ||
| 8846 | + { | ||
| 8847 | + } | ||
| 8848 | + #elif 0 | ||
| 8849 | + { | ||
| 8850 | + } | ||
| 8851 | + #else | ||
| 8852 | + { | ||
| 8853 | + #if 0 | ||
| 8854 | + { | ||
| 8855 | + } | ||
| 8856 | + #else | ||
| 8857 | + { | ||
| 8858 | + res = malloc(n); | ||
| 8859 | + } | ||
| 8860 | + #endif | ||
| 8861 | + } | ||
| 8862 | + #endif | ||
| 8863 | + if (res == 0) { | ||
| 8864 | + builtin___memory_panic(_S("malloc_uncollectable"), n); | ||
| 8865 | + VUNREACHABLE(); | ||
| 8866 | + } | ||
| 8867 | + ; | ||
| 8868 | + return res; | ||
| 8869 | +} | ||
| 8870 | +u8* builtin__v_realloc(u8* b, isize n) { | ||
| 8871 | + u8* new_ptr = ((u8*)(((void*)0))); | ||
| 8872 | + #if 0 | ||
| 8873 | + { | ||
| 8874 | + } | ||
| 8875 | + #elif defined(CUSTOM_DEFINE_vgc) | ||
| 8876 | + { | ||
| 8877 | + } | ||
| 8878 | + #elif defined(CUSTOM_DEFINE_gcboehm) | ||
| 8879 | + { | ||
| 8880 | + } | ||
| 8881 | + #else | ||
| 8882 | + { | ||
| 8883 | + #if 0 | ||
| 8884 | + { | ||
| 8885 | + } | ||
| 8886 | + #else | ||
| 8887 | + { | ||
| 8888 | + new_ptr = realloc(b, n); | ||
| 8889 | + } | ||
| 8890 | + #endif | ||
| 8891 | + } | ||
| 8892 | + #endif | ||
| 8893 | + if (new_ptr == 0) { | ||
| 8894 | + builtin___memory_panic(_S("v_realloc"), n); | ||
| 8895 | + VUNREACHABLE(); | ||
| 8896 | + } | ||
| 8897 | + if (b != ((void*)0)) { | ||
| 8898 | + ; | ||
| 8899 | + } | ||
| 8900 | + ; | ||
| 8901 | + return new_ptr; | ||
| 8902 | +} | ||
| 8903 | +u8* builtin__realloc_data(u8* old_data, int old_size, int new_size) { | ||
| 8904 | + u8* nptr = ((u8*)(((void*)0))); | ||
| 8905 | + #if defined(CUSTOM_DEFINE_vgc) | ||
| 8906 | + { | ||
| 8907 | + } | ||
| 8908 | + #elif defined(CUSTOM_DEFINE_gcboehm) | ||
| 8909 | + { | ||
| 8910 | + } | ||
| 8911 | + #else | ||
| 8912 | + { | ||
| 8913 | + #if 0 | ||
| 8914 | + { | ||
| 8915 | + } | ||
| 8916 | + #else | ||
| 8917 | + { | ||
| 8918 | + nptr = realloc(old_data, new_size); | ||
| 8919 | + } | ||
| 8920 | + #endif | ||
| 8921 | + } | ||
| 8922 | + #endif | ||
| 8923 | + if (nptr == 0) { | ||
| 8924 | + builtin___memory_panic(_S("realloc_data"), ((isize)(new_size))); | ||
| 8925 | + VUNREACHABLE(); | ||
| 8926 | + } | ||
| 8927 | + if (old_data != ((void*)0)) { | ||
| 8928 | + ; | ||
| 8929 | + } | ||
| 8930 | + ; | ||
| 8931 | + return nptr; | ||
| 8932 | +} | ||
| 8933 | +u8* builtin__vcalloc(isize n) { | ||
| 8934 | + if (n < 0) { | ||
| 8935 | + builtin___memory_panic(_S("vcalloc"), n); | ||
| 8936 | + VUNREACHABLE(); | ||
| 8937 | + } else if (n == 0) { | ||
| 8938 | + return ((u8*)(((void*)0))); | ||
| 8939 | + } | ||
| 8940 | + #if 0 | ||
| 8941 | + { | ||
| 8942 | + } | ||
| 8943 | + #elif defined(CUSTOM_DEFINE_vgc) | ||
| 8944 | + { | ||
| 8945 | + } | ||
| 8946 | + #elif defined(CUSTOM_DEFINE_gcboehm) | ||
| 8947 | + { | ||
| 8948 | + } | ||
| 8949 | + #else | ||
| 8950 | + { | ||
| 8951 | + #if 0 | ||
| 8952 | + { | ||
| 8953 | + } | ||
| 8954 | + #else | ||
| 8955 | + { | ||
| 8956 | + voidptr r = calloc(1, n); | ||
| 8957 | + ; | ||
| 8958 | + return r; | ||
| 8959 | + } | ||
| 8960 | + #endif | ||
| 8961 | + } | ||
| 8962 | + #endif | ||
| 8963 | + return ((u8*)(((void*)0))); | ||
| 8964 | +} | ||
| 8965 | +u8* builtin__vcalloc_noscan(isize n) { | ||
| 8966 | + #if 0 | ||
| 8967 | + { | ||
| 8968 | + } | ||
| 8969 | + #elif defined(CUSTOM_DEFINE_vgc) | ||
| 8970 | + { | ||
| 8971 | + } | ||
| 8972 | + #elif defined(CUSTOM_DEFINE_gcboehm) | ||
| 8973 | + { | ||
| 8974 | + } | ||
| 8975 | + #else | ||
| 8976 | + { | ||
| 8977 | + return builtin__vcalloc(n); | ||
| 8978 | + } | ||
| 8979 | + #endif | ||
| 8980 | + return ((u8*)(((void*)0))); | ||
| 8981 | +} | ||
| 8982 | +void builtin___v_free(voidptr ptr) { | ||
| 8983 | + if (ptr == 0) { | ||
| 8984 | + return; | ||
| 8985 | + } | ||
| 8986 | + IError* none_err = ((IError*)(&_const_none__)); | ||
| 8987 | + if (ptr == none_err->_object) { | ||
| 8988 | + return; | ||
| 8989 | + } | ||
| 8990 | + IError* sentinel_err = ((IError*)(&_const_error_sentinel)); | ||
| 8991 | + if (ptr == sentinel_err->_object) { | ||
| 8992 | + return; | ||
| 8993 | + } | ||
| 8994 | + #if 0 | ||
| 8995 | + { | ||
| 8996 | + } | ||
| 8997 | + #elif defined(CUSTOM_DEFINE_vgc) | ||
| 8998 | + { | ||
| 8999 | + } | ||
| 9000 | + #elif defined(CUSTOM_DEFINE_gcboehm) | ||
| 9001 | + { | ||
| 9002 | + } | ||
| 9003 | + #else | ||
| 9004 | + { | ||
| 9005 | + ; | ||
| 9006 | + #if 0 | ||
| 9007 | + { | ||
| 9008 | + } | ||
| 9009 | + #else | ||
| 9010 | + { | ||
| 9011 | + free(ptr); | ||
| 9012 | + } | ||
| 9013 | + #endif | ||
| 9014 | + } | ||
| 9015 | + #endif | ||
| 9016 | +} | ||
| 9017 | +voidptr builtin__memdup(voidptr src, isize sz) { | ||
| 9018 | + if (sz == 0) { | ||
| 9019 | + return builtin__vcalloc(1); | ||
| 9020 | + } | ||
| 9021 | + { // Unsafe block | ||
| 9022 | + u8* mem = builtin___v_malloc(sz); | ||
| 9023 | + return memcpy(mem, src, sz); | ||
| 9024 | + } | ||
| 9025 | + return 0; | ||
| 9026 | +} | ||
| 9027 | +voidptr builtin__memdup_noscan(voidptr src, isize sz) { | ||
| 9028 | + if (sz == 0) { | ||
| 9029 | + return builtin__vcalloc_noscan(1); | ||
| 9030 | + } | ||
| 9031 | + { // Unsafe block | ||
| 9032 | + u8* mem = builtin__malloc_noscan(sz); | ||
| 9033 | + return memcpy(mem, src, sz); | ||
| 9034 | + } | ||
| 9035 | + return 0; | ||
| 9036 | +} | ||
| 9037 | +voidptr builtin__memdup_uncollectable(voidptr src, isize sz) { | ||
| 9038 | + if (sz == 0) { | ||
| 9039 | + return builtin__vcalloc(1); | ||
| 9040 | + } | ||
| 9041 | + { // Unsafe block | ||
| 9042 | + u8* mem = builtin__malloc_uncollectable(sz); | ||
| 9043 | + return memcpy(mem, src, sz); | ||
| 9044 | + } | ||
| 9045 | + return 0; | ||
| 9046 | +} | ||
| 9047 | +voidptr builtin__memdup_align(voidptr src, isize sz, isize align) { | ||
| 9048 | + if (sz == 0) { | ||
| 9049 | + return builtin__vcalloc(1); | ||
| 9050 | + } | ||
| 9051 | + isize n = sz; | ||
| 9052 | + if (n < 0) { | ||
| 9053 | + builtin___memory_panic(_S("memdup_align"), n); | ||
| 9054 | + VUNREACHABLE(); | ||
| 9055 | + } | ||
| 9056 | + u8* res = ((u8*)(((void*)0))); | ||
| 9057 | + #if 0 | ||
| 9058 | + { | ||
| 9059 | + } | ||
| 9060 | + #elif defined(CUSTOM_DEFINE_gcboehm) | ||
| 9061 | + { | ||
| 9062 | + } | ||
| 9063 | + #elif 0 | ||
| 9064 | + { | ||
| 9065 | + } | ||
| 9066 | + #else | ||
| 9067 | + { | ||
| 9068 | + #if 0 | ||
| 9069 | + { | ||
| 9070 | + } | ||
| 9071 | + #else | ||
| 9072 | + { | ||
| 9073 | + res = aligned_alloc(align, n); | ||
| 9074 | + } | ||
| 9075 | + #endif | ||
| 9076 | + } | ||
| 9077 | + #endif | ||
| 9078 | + if (res == 0) { | ||
| 9079 | + builtin___memory_panic(_S("memdup_align"), n); | ||
| 9080 | + VUNREACHABLE(); | ||
| 9081 | + } | ||
| 9082 | + ; | ||
| 9083 | + return memcpy(res, src, sz); | ||
| 9084 | +} | ||
| 9085 | +GCHeapUsage builtin__gc_heap_usage(void) { | ||
| 9086 | + #if defined(CUSTOM_DEFINE_vgc) | ||
| 9087 | + { | ||
| 9088 | + } | ||
| 9089 | + #elif defined(CUSTOM_DEFINE_gcboehm) | ||
| 9090 | + { | ||
| 9091 | + } | ||
| 9092 | + #else | ||
| 9093 | + { | ||
| 9094 | + return ((GCHeapUsage){.heap_size = 0,.free_bytes = 0,.total_bytes = 0,.unmapped_bytes = 0,.bytes_since_gc = 0,}); | ||
| 9095 | + } | ||
| 9096 | + #endif | ||
| 9097 | + return (GCHeapUsage){0}; | ||
| 9098 | +} | ||
| 9099 | +usize builtin__gc_memory_use(void) { | ||
| 9100 | + #if defined(CUSTOM_DEFINE_vgc) | ||
| 9101 | + { | ||
| 9102 | + } | ||
| 9103 | + #elif defined(CUSTOM_DEFINE_gcboehm) | ||
| 9104 | + { | ||
| 9105 | + } | ||
| 9106 | + #else | ||
| 9107 | + { | ||
| 9108 | + return 0; | ||
| 9109 | + } | ||
| 9110 | + #endif | ||
| 9111 | + return 0; | ||
| 9112 | +} | ||
| 9113 | +inline VV_LOC int builtin__array_data_header_size(void) { | ||
| 9114 | + return ((int)(sizeof(voidptr))); | ||
| 9115 | +} | ||
| 9116 | +inline VV_LOC u64 builtin__array_data_allocation_size(u64 total_size) { | ||
| 9117 | + return ((u64)(builtin__array_data_header_size())) + builtin____at_least_one(total_size); | ||
| 9118 | +} | ||
| 9119 | +inline VV_LOC voidptr builtin__alloc_array_data(u64 total_size) { | ||
| 9120 | + u8* raw = builtin__vcalloc(builtin__array_data_allocation_size(total_size)); | ||
| 9121 | + return ((u8*)(raw)) + builtin__array_data_header_size(); | ||
| 9122 | +} | ||
| 9123 | +inline VV_LOC voidptr builtin__alloc_array_data_uninit(u64 total_size) { | ||
| 9124 | + u8* raw = builtin__malloc_uninit(builtin__array_data_allocation_size(total_size)); | ||
| 9125 | + { // Unsafe block | ||
| 9126 | + (((ArrayDataHeader*)(raw)))->has_slices = false; | ||
| 9127 | + return ((u8*)(raw)) + builtin__array_data_header_size(); | ||
| 9128 | + } | ||
| 9129 | + return 0; | ||
| 9130 | +} | ||
| 9131 | +inline VV_LOC bool builtin__array_uses_noscan_data(array a) { | ||
| 9132 | + return builtin__ArrayFlags_has(&a.flags, ArrayFlags__noscan_data); | ||
| 9133 | +} | ||
| 9134 | +inline VV_LOC voidptr builtin__array_alloc_array_data_like(array a, u64 total_size) { | ||
| 9135 | + return builtin__alloc_array_data(total_size); | ||
| 9136 | +} | ||
| 9137 | +inline VV_LOC voidptr builtin__array_alloc_array_data_like_uninit(array a, u64 total_size) { | ||
| 9138 | + return builtin__alloc_array_data_uninit(total_size); | ||
| 9139 | +} | ||
| 9140 | +inline VV_LOC ArrayDataHeader* builtin__array_data_header(array a) { | ||
| 9141 | + if (!builtin__ArrayFlags_has(&a.flags, ArrayFlags__managed) || a.data == ((void*)0)) { | ||
| 9142 | + return ((void*)0); | ||
| 9143 | + } | ||
| 9144 | + u8* base_data = ((u8*)(a.data)) - ((u64)(a.offset)); | ||
| 9145 | + return ((ArrayDataHeader*)(base_data - builtin__array_data_header_size())); | ||
| 9146 | +} | ||
| 9147 | +inline VV_LOC bool builtin__array_buffer_has_slices(array a) { | ||
| 9148 | + if (!builtin__ArrayFlags_has(&a.flags, ArrayFlags__managed) || a.data == ((void*)0)) { | ||
| 9149 | + return false; | ||
| 9150 | + } | ||
| 9151 | + ArrayDataHeader* header = builtin__array_data_header(a); | ||
| 9152 | + if (header == ((void*)0)) { | ||
| 9153 | + return false; | ||
| 9154 | + } | ||
| 9155 | + return header->has_slices; | ||
| 9156 | +} | ||
| 9157 | +inline VV_LOC void builtin__array_mark_buffer_has_slices(array* a) { | ||
| 9158 | + if (!builtin__ArrayFlags_has(&a->flags, ArrayFlags__managed) || a->data == ((void*)0)) { | ||
| 9159 | + return; | ||
| 9160 | + } | ||
| 9161 | + { // Unsafe block | ||
| 9162 | + u8* base_data = ((u8*)(a->data)) - ((u64)(a->offset)); | ||
| 9163 | + ArrayDataHeader* header = ((ArrayDataHeader*)(base_data - builtin__array_data_header_size())); | ||
| 9164 | + if (!header->has_slices) { | ||
| 9165 | + header->has_slices = true; | ||
| 9166 | + } | ||
| 9167 | + } | ||
| 9168 | +} | ||
| 9169 | +inline VV_LOC void builtin__array_set_managed_flags(array* a, bool is_slice) { | ||
| 9170 | + { // Unsafe block | ||
| 9171 | + builtin__ArrayFlags_set(&a->flags, ArrayFlags__managed); | ||
| 9172 | + if (is_slice) { | ||
| 9173 | + builtin__ArrayFlags_set(&a->flags, ArrayFlags__is_slice); | ||
| 9174 | + } else { | ||
| 9175 | + builtin__ArrayFlags_clear(&a->flags, ArrayFlags__is_slice); | ||
| 9176 | + } | ||
| 9177 | + } | ||
| 9178 | +} | ||
| 9179 | +inline VV_LOC void builtin__array_clone_shallow_to_cap(array* a, int new_cap) { | ||
| 9180 | + if (new_cap <= 0) { | ||
| 9181 | + builtin__ArrayFlags_clear(&a->flags, ((ArrayFlags__managed | ArrayFlags__noscan_data) | ArrayFlags__is_slice)); | ||
| 9182 | + a->data = ((void*)0); | ||
| 9183 | + a->offset = 0; | ||
| 9184 | + a->cap = 0; | ||
| 9185 | + return; | ||
| 9186 | + } | ||
| 9187 | + bool use_noscan_data = builtin__array_uses_noscan_data(*a); | ||
| 9188 | + u64 total_size = ((u64)(new_cap)) * ((u64)(a->element_size)); | ||
| 9189 | + voidptr new_data = builtin__array_alloc_array_data_like_uninit(*a, total_size); | ||
| 9190 | + u64 copy_size = ((u64)(a->len)) * ((u64)(a->element_size)); | ||
| 9191 | + if (a->data != ((void*)0) && copy_size > 0) { | ||
| 9192 | + builtin__vmemcpy(new_data, a->data, copy_size); | ||
| 9193 | + } | ||
| 9194 | + a->data = new_data; | ||
| 9195 | + a->offset = 0; | ||
| 9196 | + a->cap = new_cap; | ||
| 9197 | + { // Unsafe block | ||
| 9198 | + if (use_noscan_data) { | ||
| 9199 | + builtin__ArrayFlags_set(&a->flags, ArrayFlags__noscan_data); | ||
| 9200 | + } else { | ||
| 9201 | + builtin__ArrayFlags_clear(&a->flags, ArrayFlags__noscan_data); | ||
| 9202 | + } | ||
| 9203 | + } | ||
| 9204 | + builtin__array_set_managed_flags(a, false); | ||
| 9205 | +} | ||
| 9206 | +inline VV_LOC int builtin__v_ni_index(int i, int len) { | ||
| 9207 | + return (i < 0 ? (len + i) : (i)); | ||
| 9208 | +} | ||
| 9209 | +VV_LOC array builtin____new_array(int mylen, int cap, int elm_size) { | ||
| 9210 | + builtin__panic_on_negative_len(mylen); | ||
| 9211 | + builtin__panic_on_negative_cap(cap); | ||
| 9212 | + int cap_ = (cap < mylen ? (mylen) : (cap)); | ||
| 9213 | + u64 total_size = ((u64)(cap_)) * ((u64)(elm_size)); | ||
| 9214 | + voidptr data = ((void*)0); | ||
| 9215 | + if (cap_ > 0 && mylen == 0) { | ||
| 9216 | + data = builtin__alloc_array_data_uninit(total_size); | ||
| 9217 | + } else if (cap_ > 0) { | ||
| 9218 | + data = builtin__alloc_array_data(total_size); | ||
| 9219 | + } | ||
| 9220 | + array _t1 = ((array){.data = (voidptr)data,.offset = 0,.len = mylen,.cap = cap_,.flags = ArrayFlags__managed,.element_size = elm_size,}); | ||
| 9221 | + array arr = _t1; | ||
| 9222 | + return arr; | ||
| 9223 | +} | ||
| 9224 | +VV_LOC array builtin____new_array_with_default(int mylen, int cap, int elm_size, voidptr val) { | ||
| 9225 | + builtin__panic_on_negative_len(mylen); | ||
| 9226 | + builtin__panic_on_negative_cap(cap); | ||
| 9227 | + int cap_ = (cap < mylen ? (mylen) : (cap)); | ||
| 9228 | + array _t1 = ((array){.data = 0,.offset = 0,.len = mylen,.cap = cap_,.flags = ArrayFlags__managed,.element_size = elm_size,}); | ||
| 9229 | + array arr = _t1; | ||
| 9230 | + u64 total_size = ((u64)(cap_)) * ((u64)(elm_size)); | ||
| 9231 | + if (cap_ > 0 && mylen == 0) { | ||
| 9232 | + arr.data = builtin__alloc_array_data_uninit(total_size); | ||
| 9233 | + } else if (cap_ > 0) { | ||
| 9234 | + arr.data = builtin__alloc_array_data(total_size); | ||
| 9235 | + } | ||
| 9236 | + if (val != 0) { | ||
| 9237 | + u8* eptr = ((u8*)(arr.data)); | ||
| 9238 | + { // Unsafe block | ||
| 9239 | + if (eptr != ((void*)0)) { | ||
| 9240 | + if (arr.element_size == 1) { | ||
| 9241 | + u8 byte_value = *(((u8*)(val))); | ||
| 9242 | + for (int i = 0; i < arr.len; ++i) { | ||
| 9243 | + eptr[i] = byte_value; | ||
| 9244 | + } | ||
| 9245 | + } else { | ||
| 9246 | + for (int _t2 = 0; _t2 < arr.len; ++_t2) { | ||
| 9247 | + builtin__vmemcpy(eptr, val, arr.element_size); | ||
| 9248 | + eptr += arr.element_size; | ||
| 9249 | + } | ||
| 9250 | + } | ||
| 9251 | + } | ||
| 9252 | + } | ||
| 9253 | + } | ||
| 9254 | + return arr; | ||
| 9255 | +} | ||
| 9256 | +VV_LOC array builtin____new_array_with_multi_default(int mylen, int cap, int elm_size, voidptr val) { | ||
| 9257 | + builtin__panic_on_negative_len(mylen); | ||
| 9258 | + builtin__panic_on_negative_cap(cap); | ||
| 9259 | + int cap_ = (cap < mylen ? (mylen) : (cap)); | ||
| 9260 | + array _t1 = ((array){.data = 0,.offset = 0,.len = mylen,.cap = cap_,.flags = ArrayFlags__managed,.element_size = elm_size,}); | ||
| 9261 | + array arr = _t1; | ||
| 9262 | + u64 total_size = ((u64)(cap_)) * ((u64)(elm_size)); | ||
| 9263 | + if (cap_ > 0) { | ||
| 9264 | + arr.data = builtin__alloc_array_data(total_size); | ||
| 9265 | + } | ||
| 9266 | + if (val != 0) { | ||
| 9267 | + u8* eptr = ((u8*)(arr.data)); | ||
| 9268 | + { // Unsafe block | ||
| 9269 | + if (eptr != ((void*)0)) { | ||
| 9270 | + for (int i = 0; i < arr.len; ++i) { | ||
| 9271 | + builtin__vmemcpy(eptr, ((charptr)(val)) + (int)(i * arr.element_size), arr.element_size); | ||
| 9272 | + eptr += arr.element_size; | ||
| 9273 | + } | ||
| 9274 | + } | ||
| 9275 | + } | ||
| 9276 | + } | ||
| 9277 | + return arr; | ||
| 9278 | +} | ||
| 9279 | +VV_LOC array builtin____new_array_with_array_default(int mylen, int cap, int elm_size, array val, int depth) { | ||
| 9280 | + builtin__panic_on_negative_len(mylen); | ||
| 9281 | + builtin__panic_on_negative_cap(cap); | ||
| 9282 | + int cap_ = (cap < mylen ? (mylen) : (cap)); | ||
| 9283 | + array _t1 = ((array){.data = 0,.offset = 0,.len = mylen,.cap = cap_,.flags = ArrayFlags__managed,.element_size = elm_size,}); | ||
| 9284 | + array arr = _t1; | ||
| 9285 | + if (cap_ > 0) { | ||
| 9286 | + arr.data = builtin__alloc_array_data(((u64)(cap_)) * ((u64)(elm_size))); | ||
| 9287 | + } | ||
| 9288 | + u8* eptr = ((u8*)(arr.data)); | ||
| 9289 | + { // Unsafe block | ||
| 9290 | + if (eptr != ((void*)0)) { | ||
| 9291 | + for (int _t2 = 0; _t2 < arr.len; ++_t2) { | ||
| 9292 | + array val_clone = builtin__array_clone_to_depth(&val, depth); | ||
| 9293 | + builtin__vmemcpy(eptr, &val_clone, arr.element_size); | ||
| 9294 | + eptr += arr.element_size; | ||
| 9295 | + } | ||
| 9296 | + } | ||
| 9297 | + } | ||
| 9298 | + return arr; | ||
| 9299 | +} | ||
| 9300 | +VV_LOC array builtin__new_array_from_c_array(int len, int cap, int elm_size, voidptr c_array) { | ||
| 9301 | + builtin__panic_on_negative_len(len); | ||
| 9302 | + builtin__panic_on_negative_cap(cap); | ||
| 9303 | + int cap_ = cap; | ||
| 9304 | + if (cap < len) { | ||
| 9305 | + cap_ = len; | ||
| 9306 | + } | ||
| 9307 | + array _t1 = ((array){.data = builtin__alloc_array_data(((u64)(cap_)) * ((u64)(elm_size))),.offset = 0,.len = len,.cap = cap_,.flags = ArrayFlags__managed,.element_size = elm_size,}); | ||
| 9308 | + array arr = _t1; | ||
| 9309 | + builtin__vmemcpy(arr.data, c_array, ((u64)(len)) * ((u64)(elm_size))); | ||
| 9310 | + return arr; | ||
| 9311 | +} | ||
| 9312 | +void builtin__array_ensure_cap(array* a, int required) { | ||
| 9313 | + if (required <= a->cap) { | ||
| 9314 | + return; | ||
| 9315 | + } | ||
| 9316 | + if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__nogrow)) { | ||
| 9317 | + builtin__panic_n(_S("array.ensure_cap: array with the flag `.nogrow` cannot grow in size, array required new size:"), required); | ||
| 9318 | + VUNREACHABLE(); | ||
| 9319 | + } | ||
| 9320 | + i64 cap = (a->cap > 0 ? (((i64)(a->cap))) : (((i64)(2)))); | ||
| 9321 | + for (;;) { | ||
| 9322 | + if (!(required > cap)) break; | ||
| 9323 | + cap *= 2; | ||
| 9324 | + } | ||
| 9325 | + if (cap > _const_max_int) { | ||
| 9326 | + if (a->cap < _const_max_int) { | ||
| 9327 | + cap = _const_max_int; | ||
| 9328 | + } else { | ||
| 9329 | + builtin__panic_n(_S("array.ensure_cap: array needs to grow to cap (which is > 2^31):"), cap); | ||
| 9330 | + VUNREACHABLE(); | ||
| 9331 | + } | ||
| 9332 | + } | ||
| 9333 | + u64 new_size = ((u64)(cap)) * ((u64)(a->element_size)); | ||
| 9334 | + bool use_noscan_data = builtin__array_uses_noscan_data(*a); | ||
| 9335 | + voidptr new_data = builtin__array_alloc_array_data_like_uninit(*a, new_size); | ||
| 9336 | + if (a->data != ((void*)0)) { | ||
| 9337 | + builtin__vmemcpy(new_data, a->data, ((u64)(a->len)) * ((u64)(a->element_size))); | ||
| 9338 | + if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__noslices) && !builtin__ArrayFlags_has(&a->flags, ArrayFlags__is_slice) && !builtin__array_buffer_has_slices(*a)) { | ||
| 9339 | + { // Unsafe block | ||
| 9340 | + if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__managed)) { | ||
| 9341 | + builtin___v_free(((u8*)(a->data)) - ((u64)(builtin__array_data_header_size()))); | ||
| 9342 | + } else { | ||
| 9343 | + builtin___v_free(a->data); | ||
| 9344 | + } | ||
| 9345 | + } | ||
| 9346 | + } | ||
| 9347 | + } | ||
| 9348 | + a->data = new_data; | ||
| 9349 | + a->offset = 0; | ||
| 9350 | + a->cap = ((int)(cap)); | ||
| 9351 | + { // Unsafe block | ||
| 9352 | + if (use_noscan_data) { | ||
| 9353 | + builtin__ArrayFlags_set(&a->flags, ArrayFlags__noscan_data); | ||
| 9354 | + } else { | ||
| 9355 | + builtin__ArrayFlags_clear(&a->flags, ArrayFlags__noscan_data); | ||
| 9356 | + } | ||
| 9357 | + } | ||
| 9358 | + builtin__array_set_managed_flags(a, false); | ||
| 9359 | +} | ||
| 9360 | +array builtin__array_repeat(array a, int count) { | ||
| 9361 | + return builtin__array_repeat_to_depth(a, count, 0); | ||
| 9362 | +} | ||
| 9363 | +array builtin__array_repeat_to_depth(array a, int count, int depth) { | ||
| 9364 | + if (count < 0) { | ||
| 9365 | + builtin__panic_n(_S("array.repeat: count is negative:"), count); | ||
| 9366 | + VUNREACHABLE(); | ||
| 9367 | + } | ||
| 9368 | + u64 size = ((u64)(count)) * ((u64)(a.len)) * ((u64)(a.element_size)); | ||
| 9369 | + if (size == 0) { | ||
| 9370 | + size = ((u64)(a.element_size)); | ||
| 9371 | + } | ||
| 9372 | + bool use_noscan_data = depth == 0 && builtin__array_uses_noscan_data(a); | ||
| 9373 | + voidptr data = ((void*)0); | ||
| 9374 | + if (use_noscan_data) { | ||
| 9375 | + data = builtin__array_alloc_array_data_like(a, size); | ||
| 9376 | + } else { | ||
| 9377 | + data = builtin__alloc_array_data(size); | ||
| 9378 | + } | ||
| 9379 | + array _t1 = ((array){.data = (voidptr)data,.offset = 0,.len = count * a.len,.cap = count * a.len,.flags = (use_noscan_data ? ((ArrayFlags__managed | ArrayFlags__noscan_data)) : (ArrayFlags__managed)),.element_size = a.element_size,}); | ||
| 9380 | + array arr = _t1; | ||
| 9381 | + if (a.len > 0) { | ||
| 9382 | + u64 a_total_size = ((u64)(a.len)) * ((u64)(a.element_size)); | ||
| 9383 | + u64 arr_step_size = ((u64)(a.len)) * ((u64)(arr.element_size)); | ||
| 9384 | + u8* eptr = ((u8*)(arr.data)); | ||
| 9385 | + { // Unsafe block | ||
| 9386 | + if (eptr != ((void*)0)) { | ||
| 9387 | + for (int _t2 = 0; _t2 < count; ++_t2) { | ||
| 9388 | + if (depth > 0) { | ||
| 9389 | + array ary_clone = builtin__array_clone_to_depth(&a, depth); | ||
| 9390 | + builtin__vmemcpy(eptr, ary_clone.data, a_total_size); | ||
| 9391 | + } else { | ||
| 9392 | + builtin__vmemcpy(eptr, a.data, a_total_size); | ||
| 9393 | + } | ||
| 9394 | + eptr += arr_step_size; | ||
| 9395 | + } | ||
| 9396 | + } | ||
| 9397 | + } | ||
| 9398 | + } | ||
| 9399 | + return arr; | ||
| 9400 | +} | ||
| 9401 | +inline VV_LOC bool builtin__array_needs_unique_shift(array a, int required) { | ||
| 9402 | + return required <= a.cap && (builtin__ArrayFlags_has(&a.flags, ArrayFlags__is_slice) || builtin__array_buffer_has_slices(a)); | ||
| 9403 | +} | ||
| 9404 | +inline VV_LOC bool builtin__array_needs_unique_append(array a, int required) { | ||
| 9405 | + return required <= a.cap && builtin__ArrayFlags_has(&a.flags, ArrayFlags__is_slice); | ||
| 9406 | +} | ||
| 9407 | +inline VV_LOC bool builtin__array_needs_unique_shrink(array a) { | ||
| 9408 | + return builtin__ArrayFlags_has(&a.flags, ArrayFlags__is_slice) || builtin__array_buffer_has_slices(a); | ||
| 9409 | +} | ||
| 9410 | +void builtin__array_insert(array* a, int i, voidptr val) { | ||
| 9411 | + if (i < 0 || i > a->len) { | ||
| 9412 | + builtin__panic_n2(_S("array.insert: index out of range (i,a.len):"), i, a->len); | ||
| 9413 | + VUNREACHABLE(); | ||
| 9414 | + } | ||
| 9415 | + if (a->len == _const_max_int) { | ||
| 9416 | + builtin___v_panic(_S("array.insert: a.len reached max_int")); | ||
| 9417 | + VUNREACHABLE(); | ||
| 9418 | + } | ||
| 9419 | + int required = a->len + 1; | ||
| 9420 | + if (builtin__array_needs_unique_shift(*a, required)) { | ||
| 9421 | + builtin__array_clone_shallow_to_cap(a, a->cap); | ||
| 9422 | + } else if (required > a->cap) { | ||
| 9423 | + builtin__array_ensure_cap(a, required); | ||
| 9424 | + } | ||
| 9425 | + { // Unsafe block | ||
| 9426 | + builtin__vmemmove(builtin__array_get_unsafe(*a, i + 1), builtin__array_get_unsafe(*a, i), ((u64)((a->len - i))) * ((u64)(a->element_size))); | ||
| 9427 | + builtin__array_set_unsafe(a, i, val); | ||
| 9428 | + } | ||
| 9429 | + a->len++; | ||
| 9430 | +} | ||
| 9431 | +void builtin__array_prepend(array* a, voidptr val) { | ||
| 9432 | + builtin__array_insert(a, 0, val); | ||
| 9433 | +} | ||
| 9434 | +void builtin__array_delete(array* a, int i) { | ||
| 9435 | + if (i < 0 || i >= a->len) { | ||
| 9436 | + builtin__panic_n2(_S("array.delete: index out of range (i,a.len):"), i, a->len); | ||
| 9437 | + VUNREACHABLE(); | ||
| 9438 | + } | ||
| 9439 | + if (i == a->len - 1 && !builtin__array_needs_unique_shrink(*a)) { | ||
| 9440 | + a->len--; | ||
| 9441 | + builtin__vmemset(((u8*)(a->data)) + ((u64)(a->len)) * ((u64)(a->element_size)), 0, ((u64)(a->element_size))); | ||
| 9442 | + return; | ||
| 9443 | + } | ||
| 9444 | + builtin__array_delete_many(a, i, 1); | ||
| 9445 | +} | ||
| 9446 | +void builtin__array_delete_many(array* a, int i, int size) { | ||
| 9447 | + if (i < 0 || ((i64)(i)) + ((i64)(size)) > ((i64)(a->len))) { | ||
| 9448 | + if (size > 1) { | ||
| 9449 | + builtin__panic_n3(_S("array.delete: index out of range (i,i+size,a.len):"), i, i + size, a->len); | ||
| 9450 | + VUNREACHABLE(); | ||
| 9451 | + } else { | ||
| 9452 | + builtin__panic_n2(_S("array.delete: index out of range (i,a.len):"), i, a->len); | ||
| 9453 | + VUNREACHABLE(); | ||
| 9454 | + } | ||
| 9455 | + } | ||
| 9456 | + if (size == 0) { | ||
| 9457 | + if (builtin__array_needs_unique_shrink(*a)) { | ||
| 9458 | + builtin__array_clone_shallow_to_cap(a, a->len); | ||
| 9459 | + } | ||
| 9460 | + return; | ||
| 9461 | + } | ||
| 9462 | + if (!builtin__array_needs_unique_shrink(*a)) { | ||
| 9463 | + int new_len = a->len - size; | ||
| 9464 | + { // Unsafe block | ||
| 9465 | + builtin__vmemmove(((u8*)(a->data)) + ((u64)(i)) * ((u64)(a->element_size)), ((u8*)(a->data)) + ((u64)(i + size)) * ((u64)(a->element_size)), ((u64)(a->len - i - size)) * ((u64)(a->element_size))); | ||
| 9466 | + builtin__vmemset(((u8*)(a->data)) + ((u64)(new_len)) * ((u64)(a->element_size)), 0, ((u64)(size)) * ((u64)(a->element_size))); | ||
| 9467 | + } | ||
| 9468 | + a->len = new_len; | ||
| 9469 | + return; | ||
| 9470 | + } | ||
| 9471 | + voidptr old_data = a->data; | ||
| 9472 | + int new_size = a->len - size; | ||
| 9473 | + if (new_size == 0) { | ||
| 9474 | + builtin__ArrayFlags_clear(&a->flags, ((ArrayFlags__managed | ArrayFlags__noscan_data) | ArrayFlags__is_slice)); | ||
| 9475 | + a->data = ((void*)0); | ||
| 9476 | + a->offset = 0; | ||
| 9477 | + a->len = 0; | ||
| 9478 | + a->cap = 0; | ||
| 9479 | + return; | ||
| 9480 | + } | ||
| 9481 | + int new_cap = new_size; | ||
| 9482 | + bool use_noscan_data = builtin__array_uses_noscan_data(*a); | ||
| 9483 | + a->data = builtin__array_alloc_array_data_like(*a, ((u64)(new_cap)) * ((u64)(a->element_size))); | ||
| 9484 | + builtin__vmemcpy(a->data, old_data, ((u64)(i)) * ((u64)(a->element_size))); | ||
| 9485 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(i)) * ((u64)(a->element_size)), ((u8*)(old_data)) + ((u64)(i + size)) * ((u64)(a->element_size)), ((u64)(a->len - i - size)) * ((u64)(a->element_size))); | ||
| 9486 | + if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__noslices) && !builtin__ArrayFlags_has(&a->flags, ArrayFlags__managed)) { | ||
| 9487 | + builtin___v_free(old_data); | ||
| 9488 | + } | ||
| 9489 | + a->len = new_size; | ||
| 9490 | + a->cap = new_cap; | ||
| 9491 | + a->offset = 0; | ||
| 9492 | + { // Unsafe block | ||
| 9493 | + if (use_noscan_data) { | ||
| 9494 | + builtin__ArrayFlags_set(&a->flags, ArrayFlags__noscan_data); | ||
| 9495 | + } else { | ||
| 9496 | + builtin__ArrayFlags_clear(&a->flags, ArrayFlags__noscan_data); | ||
| 9497 | + } | ||
| 9498 | + } | ||
| 9499 | + builtin__array_set_managed_flags(a, false); | ||
| 9500 | +} | ||
| 9501 | +void builtin__array_clear(array* a) { | ||
| 9502 | + if (builtin__array_needs_unique_shrink(*a)) { | ||
| 9503 | + builtin__ArrayFlags_clear(&a->flags, ((ArrayFlags__managed | ArrayFlags__noscan_data) | ArrayFlags__is_slice)); | ||
| 9504 | + a->data = ((void*)0); | ||
| 9505 | + a->offset = 0; | ||
| 9506 | + a->cap = 0; | ||
| 9507 | + } | ||
| 9508 | + a->len = 0; | ||
| 9509 | +} | ||
| 9510 | +void builtin__array_reset(array* a) { | ||
| 9511 | + builtin__vmemset(a->data, 0, a->len * a->element_size); | ||
| 9512 | +} | ||
| 9513 | +void builtin__array_trim(array* a, int index) { | ||
| 9514 | + if (index < a->len) { | ||
| 9515 | + if (index >= 0 && builtin__array_needs_unique_shrink(*a)) { | ||
| 9516 | + builtin__array_delete_many(a, index, a->len - index); | ||
| 9517 | + return; | ||
| 9518 | + } | ||
| 9519 | + a->len = index; | ||
| 9520 | + } | ||
| 9521 | +} | ||
| 9522 | +void builtin__array_drop(array* a, int num) { | ||
| 9523 | + if (num <= 0) { | ||
| 9524 | + return; | ||
| 9525 | + } | ||
| 9526 | + int n = (num <= a->len ? (num) : (a->len)); | ||
| 9527 | + u64 blen = ((u64)(n)) * ((u64)(a->element_size)); | ||
| 9528 | + a->data = ((u8*)(a->data)) + blen; | ||
| 9529 | + a->offset += ((int)(blen)); | ||
| 9530 | + a->len -= n; | ||
| 9531 | + a->cap -= n; | ||
| 9532 | +} | ||
| 9533 | +inline VV_LOC voidptr builtin__array_get_unsafe(array a, int i) { | ||
| 9534 | + { // Unsafe block | ||
| 9535 | + return ((u8*)(a.data)) + ((u64)(i)) * ((u64)(a.element_size)); | ||
| 9536 | + } | ||
| 9537 | + return 0; | ||
| 9538 | +} | ||
| 9539 | +VV_LOC voidptr builtin__array_get(array a, int i) { | ||
| 9540 | + #if 1 | ||
| 9541 | + { | ||
| 9542 | + if (i < 0 || i >= a.len) { | ||
| 9543 | + builtin__panic_n2(_S("array.get: index out of range (i,a.len):"), i, a.len); | ||
| 9544 | + VUNREACHABLE(); | ||
| 9545 | + } | ||
| 9546 | + } | ||
| 9547 | + #endif | ||
| 9548 | + { // Unsafe block | ||
| 9549 | + return ((u8*)(a.data)) + ((u64)(i)) * ((u64)(a.element_size)); | ||
| 9550 | + } | ||
| 9551 | + return 0; | ||
| 9552 | +} | ||
| 9553 | +VV_LOC voidptr builtin__array_get_i64(array a, i64 i) { | ||
| 9554 | + #if 1 | ||
| 9555 | + { | ||
| 9556 | + if (i < 0 || i >= ((i64)(a.len))) { | ||
| 9557 | + builtin__panic_n2(_S("array.get: index out of range (i,a.len):"), i, a.len); | ||
| 9558 | + VUNREACHABLE(); | ||
| 9559 | + } | ||
| 9560 | + } | ||
| 9561 | + #endif | ||
| 9562 | + { // Unsafe block | ||
| 9563 | + return ((u8*)(a.data)) + ((u64)(i)) * ((u64)(a.element_size)); | ||
| 9564 | + } | ||
| 9565 | + return 0; | ||
| 9566 | +} | ||
| 9567 | +VV_LOC voidptr builtin__array_get_u64(array a, u64 i) { | ||
| 9568 | + #if 1 | ||
| 9569 | + { | ||
| 9570 | + if (i >= ((u64)(a.len))) { | ||
| 9571 | + builtin___v_panic(builtin__string_plus_many(4, _MOV((string[4]){_S("array.get: index out of range (i,a.len): "), builtin__u64_str(i), _S(", "), builtin__impl_i64_to_string(a.len)}))); | ||
| 9572 | + VUNREACHABLE(); | ||
| 9573 | + } | ||
| 9574 | + } | ||
| 9575 | + #endif | ||
| 9576 | + { // Unsafe block | ||
| 9577 | + return ((u8*)(a.data)) + i * ((u64)(a.element_size)); | ||
| 9578 | + } | ||
| 9579 | + return 0; | ||
| 9580 | +} | ||
| 9581 | +VV_LOC voidptr builtin__array_get_ni(array a, int i) { | ||
| 9582 | + return builtin__array_get(a, builtin__v_ni_index(i, a.len)); | ||
| 9583 | +} | ||
| 9584 | +VV_LOC voidptr builtin__array_get_with_check(array a, int i) { | ||
| 9585 | + if (i < 0 || i >= a.len) { | ||
| 9586 | + return 0; | ||
| 9587 | + } | ||
| 9588 | + { // Unsafe block | ||
| 9589 | + return ((u8*)(a.data)) + ((u64)(i)) * ((u64)(a.element_size)); | ||
| 9590 | + } | ||
| 9591 | + return 0; | ||
| 9592 | +} | ||
| 9593 | +VV_LOC voidptr builtin__array_get_with_check_i64(array a, i64 i) { | ||
| 9594 | + if (i < 0 || i >= ((i64)(a.len))) { | ||
| 9595 | + return 0; | ||
| 9596 | + } | ||
| 9597 | + { // Unsafe block | ||
| 9598 | + return ((u8*)(a.data)) + ((u64)(i)) * ((u64)(a.element_size)); | ||
| 9599 | + } | ||
| 9600 | + return 0; | ||
| 9601 | +} | ||
| 9602 | +VV_LOC voidptr builtin__array_get_with_check_u64(array a, u64 i) { | ||
| 9603 | + if (i >= ((u64)(a.len))) { | ||
| 9604 | + return 0; | ||
| 9605 | + } | ||
| 9606 | + { // Unsafe block | ||
| 9607 | + return ((u8*)(a.data)) + i * ((u64)(a.element_size)); | ||
| 9608 | + } | ||
| 9609 | + return 0; | ||
| 9610 | +} | ||
| 9611 | +VV_LOC voidptr builtin__array_get_with_check_ni(array a, int i) { | ||
| 9612 | + return builtin__array_get_with_check(a, builtin__v_ni_index(i, a.len)); | ||
| 9613 | +} | ||
| 9614 | +voidptr builtin__array_first(array a) { | ||
| 9615 | + if (a.len == 0) { | ||
| 9616 | + builtin___v_panic(_S("array.first: array is empty")); | ||
| 9617 | + VUNREACHABLE(); | ||
| 9618 | + } | ||
| 9619 | + return a.data; | ||
| 9620 | +} | ||
| 9621 | +voidptr builtin__array_last(array a) { | ||
| 9622 | + if (a.len == 0) { | ||
| 9623 | + builtin___v_panic(_S("array.last: array is empty")); | ||
| 9624 | + VUNREACHABLE(); | ||
| 9625 | + } | ||
| 9626 | + { // Unsafe block | ||
| 9627 | + return ((u8*)(a.data)) + ((u64)(a.len - 1)) * ((u64)(a.element_size)); | ||
| 9628 | + } | ||
| 9629 | + return 0; | ||
| 9630 | +} | ||
| 9631 | +voidptr builtin__array_pop_left(array* a) { | ||
| 9632 | + if (a->len == 0) { | ||
| 9633 | + builtin___v_panic(_S("array.pop_left: array is empty")); | ||
| 9634 | + VUNREACHABLE(); | ||
| 9635 | + } | ||
| 9636 | + voidptr first_elem = a->data; | ||
| 9637 | + { // Unsafe block | ||
| 9638 | + a->data = ((u8*)(a->data)) + ((u64)(a->element_size)); | ||
| 9639 | + } | ||
| 9640 | + a->offset += a->element_size; | ||
| 9641 | + a->len--; | ||
| 9642 | + a->cap--; | ||
| 9643 | + return first_elem; | ||
| 9644 | +} | ||
| 9645 | +voidptr builtin__array_pop(array* a) { | ||
| 9646 | + if (a->len == 0) { | ||
| 9647 | + builtin___v_panic(_S("array.pop: array is empty")); | ||
| 9648 | + VUNREACHABLE(); | ||
| 9649 | + } | ||
| 9650 | + int new_len = a->len - 1; | ||
| 9651 | + u8* last_elem = ((u8*)(a->data)) + ((u64)(new_len)) * ((u64)(a->element_size)); | ||
| 9652 | + if (builtin__array_needs_unique_shrink(*a)) { | ||
| 9653 | + builtin__array_delete_many(a, new_len, 1); | ||
| 9654 | + return last_elem; | ||
| 9655 | + } | ||
| 9656 | + a->len = new_len; | ||
| 9657 | + return last_elem; | ||
| 9658 | +} | ||
| 9659 | +void builtin__array_delete_last(array* a) { | ||
| 9660 | + if (a->len == 0) { | ||
| 9661 | + builtin___v_panic(_S("array.delete_last: array is empty")); | ||
| 9662 | + VUNREACHABLE(); | ||
| 9663 | + } | ||
| 9664 | + if (builtin__array_needs_unique_shrink(*a)) { | ||
| 9665 | + builtin__array_delete_many(a, a->len - 1, 1); | ||
| 9666 | + return; | ||
| 9667 | + } | ||
| 9668 | + a->len--; | ||
| 9669 | + builtin__vmemset(((u8*)(a->data)) + ((u64)(a->len)) * ((u64)(a->element_size)), 0, ((u64)(a->element_size))); | ||
| 9670 | +} | ||
| 9671 | +VV_LOC array builtin__array_slice(array a, int start, int _end) { | ||
| 9672 | + int end = (_end == _const_max_i64 || _end == _const_max_i32 ? (a.len) : (_end)); | ||
| 9673 | + #if 1 | ||
| 9674 | + { | ||
| 9675 | + if (start > end) { | ||
| 9676 | + builtin___v_panic(builtin__string_plus_many(4, _MOV((string[4]){_S("array.slice: invalid slice index (start>end):"), builtin__impl_i64_to_string(((i64)(start))), _S(", "), builtin__impl_i64_to_string(end)}))); | ||
| 9677 | + VUNREACHABLE(); | ||
| 9678 | + } | ||
| 9679 | + if (end > a.len) { | ||
| 9680 | + builtin___v_panic(builtin__string_plus_many(5, _MOV((string[5]){_S("array.slice: slice bounds out of range ("), builtin__impl_i64_to_string(end), _S(" >= "), builtin__impl_i64_to_string(a.len), _S(")")}))); | ||
| 9681 | + VUNREACHABLE(); | ||
| 9682 | + } | ||
| 9683 | + if (start < 0) { | ||
| 9684 | + builtin___v_panic(builtin__string__plus(_S("array.slice: slice bounds out of range (start<0):"), builtin__impl_i64_to_string(start))); | ||
| 9685 | + VUNREACHABLE(); | ||
| 9686 | + } | ||
| 9687 | + } | ||
| 9688 | + #endif | ||
| 9689 | + builtin__array_mark_buffer_has_slices(&a); | ||
| 9690 | + u64 offset = ((u64)(start)) * ((u64)(a.element_size)); | ||
| 9691 | + u8* data = ((u8*)(a.data)) + offset; | ||
| 9692 | + int l = end - start; | ||
| 9693 | + ArrayFlags flags = ArrayFlags__is_slice; | ||
| 9694 | + if (builtin__array_uses_noscan_data(a)) { | ||
| 9695 | + builtin__ArrayFlags_set(&flags, ArrayFlags__noscan_data); | ||
| 9696 | + } | ||
| 9697 | + array res = ((array){ | ||
| 9698 | + .data = (voidptr)data, | ||
| 9699 | + .offset = a.offset + ((int)(offset)), | ||
| 9700 | + .len = l, | ||
| 9701 | + .cap = l, | ||
| 9702 | + .flags = flags, | ||
| 9703 | + .element_size = a.element_size, | ||
| 9704 | + }); | ||
| 9705 | + return res; | ||
| 9706 | +} | ||
| 9707 | +VV_LOC array builtin__array_slice_ni(array a, int _start, int _end) { | ||
| 9708 | + builtin__array_mark_buffer_has_slices(&a); | ||
| 9709 | + ArrayFlags flags = ArrayFlags__is_slice; | ||
| 9710 | + if (builtin__array_uses_noscan_data(a)) { | ||
| 9711 | + builtin__ArrayFlags_set(&flags, ArrayFlags__noscan_data); | ||
| 9712 | + } | ||
| 9713 | + int end = (_end == _const_max_i64 || _end == _const_max_i32 ? (a.len) : (_end)); | ||
| 9714 | + int start = _start; | ||
| 9715 | + if (start < 0) { | ||
| 9716 | + start = a.len + start; | ||
| 9717 | + if (start < 0) { | ||
| 9718 | + start = 0; | ||
| 9719 | + } | ||
| 9720 | + } | ||
| 9721 | + if (end < 0) { | ||
| 9722 | + end = a.len + end; | ||
| 9723 | + if (end < 0) { | ||
| 9724 | + end = 0; | ||
| 9725 | + } | ||
| 9726 | + } | ||
| 9727 | + if (end >= a.len) { | ||
| 9728 | + end = a.len; | ||
| 9729 | + } | ||
| 9730 | + if (start >= a.len || start > end) { | ||
| 9731 | + array res = ((array){ | ||
| 9732 | + .data = a.data, | ||
| 9733 | + .offset = 0, | ||
| 9734 | + .len = 0, | ||
| 9735 | + .cap = 0, | ||
| 9736 | + .flags = flags, | ||
| 9737 | + .element_size = a.element_size, | ||
| 9738 | + }); | ||
| 9739 | + return res; | ||
| 9740 | + } | ||
| 9741 | + u64 offset = ((u64)(start)) * ((u64)(a.element_size)); | ||
| 9742 | + u8* data = ((u8*)(a.data)) + offset; | ||
| 9743 | + int l = end - start; | ||
| 9744 | + array res = ((array){ | ||
| 9745 | + .data = (voidptr)data, | ||
| 9746 | + .offset = a.offset + ((int)(offset)), | ||
| 9747 | + .len = l, | ||
| 9748 | + .cap = l, | ||
| 9749 | + .flags = flags, | ||
| 9750 | + .element_size = a.element_size, | ||
| 9751 | + }); | ||
| 9752 | + return res; | ||
| 9753 | +} | ||
| 9754 | +VV_LOC array builtin__array_clone_static_to_depth(array a, int depth) { | ||
| 9755 | + return builtin__array_clone_to_depth(&a, depth); | ||
| 9756 | +} | ||
| 9757 | +array builtin__array_clone(array* a) { | ||
| 9758 | + return builtin__array_clone_to_depth(a, 0); | ||
| 9759 | +} | ||
| 9760 | +array builtin__array_clone_to_depth(array* a, int depth) { | ||
| 9761 | + u64 source_capacity_in_bytes = ((u64)(a->cap)) * ((u64)(a->element_size)); | ||
| 9762 | + bool use_noscan_data = depth == 0 && builtin__array_uses_noscan_data(*a); | ||
| 9763 | + voidptr data = ((void*)0); | ||
| 9764 | + if (a->cap > 0) { | ||
| 9765 | + if (use_noscan_data) { | ||
| 9766 | + data = builtin__array_alloc_array_data_like(*a, source_capacity_in_bytes); | ||
| 9767 | + } else { | ||
| 9768 | + data = builtin__alloc_array_data(source_capacity_in_bytes); | ||
| 9769 | + } | ||
| 9770 | + } | ||
| 9771 | + array _t1 = ((array){.data = (voidptr)data,.offset = 0,.len = a->len,.cap = a->cap,.flags = (use_noscan_data ? ((ArrayFlags__managed | ArrayFlags__noscan_data)) : (ArrayFlags__managed)),.element_size = a->element_size,}); | ||
| 9772 | + array arr = _t1; | ||
| 9773 | + if (depth > 0 && _us32_eq(sizeof(array),a->element_size) && a->len >= 0 && a->cap >= a->len) { | ||
| 9774 | + array _t2 = ((array){.data = 0,.offset = 0,.len = 0,.cap = 0,.flags = 0,.element_size = 0,}); | ||
| 9775 | + array ar = _t2; | ||
| 9776 | + int asize = ((int)(sizeof(array))); | ||
| 9777 | + for (int i = 0; i < a->len; ++i) { | ||
| 9778 | + builtin__vmemcpy(&ar, builtin__array_get_unsafe(*a, i), asize); | ||
| 9779 | + array ar_clone = builtin__array_clone_to_depth(&ar, depth - 1); | ||
| 9780 | + builtin__array_set_unsafe(&arr, i, &ar_clone); | ||
| 9781 | + } | ||
| 9782 | + return arr; | ||
| 9783 | + } else if (depth > 0 && _us32_eq(sizeof(string),a->element_size) && a->len >= 0 && a->cap >= a->len) { | ||
| 9784 | + for (int i = 0; i < a->len; ++i) { | ||
| 9785 | + string* str_ptr = ((string*)(builtin__array_get_unsafe(*a, i))); | ||
| 9786 | + string str_clone = builtin__string_clone((*str_ptr)); | ||
| 9787 | + builtin__array_set_unsafe(&arr, i, &str_clone); | ||
| 9788 | + } | ||
| 9789 | + return arr; | ||
| 9790 | + } | ||
| 9791 | + if (a->data != 0 && source_capacity_in_bytes > 0) { | ||
| 9792 | + builtin__vmemcpy(arr.data, a->data, source_capacity_in_bytes); | ||
| 9793 | + } | ||
| 9794 | + return arr; | ||
| 9795 | +} | ||
| 9796 | +inline VV_LOC void builtin__array_set_unsafe(array* a, int i, voidptr val) { | ||
| 9797 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(a->element_size)) * ((u64)(i)), val, a->element_size); | ||
| 9798 | +} | ||
| 9799 | +VV_LOC void builtin__array_set(array* a, int i, voidptr val) { | ||
| 9800 | + #if 1 | ||
| 9801 | + { | ||
| 9802 | + if (i < 0 || i >= a->len) { | ||
| 9803 | + builtin__panic_n2(_S("array.set: index out of range (i,a.len):"), i, a->len); | ||
| 9804 | + VUNREACHABLE(); | ||
| 9805 | + } | ||
| 9806 | + } | ||
| 9807 | + #endif | ||
| 9808 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(a->element_size)) * ((u64)(i)), val, a->element_size); | ||
| 9809 | +} | ||
| 9810 | +VV_LOC void builtin__array_set_i64(array* a, i64 i, voidptr val) { | ||
| 9811 | + #if 1 | ||
| 9812 | + { | ||
| 9813 | + if (i < 0 || i >= ((i64)(a->len))) { | ||
| 9814 | + builtin__panic_n2(_S("array.set: index out of range (i,a.len):"), i, a->len); | ||
| 9815 | + VUNREACHABLE(); | ||
| 9816 | + } | ||
| 9817 | + } | ||
| 9818 | + #endif | ||
| 9819 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(a->element_size)) * ((u64)(i)), val, a->element_size); | ||
| 9820 | +} | ||
| 9821 | +VV_LOC void builtin__array_set_u64(array* a, u64 i, voidptr val) { | ||
| 9822 | + #if 1 | ||
| 9823 | + { | ||
| 9824 | + if (i >= ((u64)(a->len))) { | ||
| 9825 | + builtin___v_panic(builtin__string_plus_many(4, _MOV((string[4]){_S("array.set: index out of range (i,a.len): "), builtin__u64_str(i), _S(", "), builtin__impl_i64_to_string(a->len)}))); | ||
| 9826 | + VUNREACHABLE(); | ||
| 9827 | + } | ||
| 9828 | + } | ||
| 9829 | + #endif | ||
| 9830 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(a->element_size)) * i, val, a->element_size); | ||
| 9831 | +} | ||
| 9832 | +VV_LOC void builtin__array_set_ni(array* a, int i, voidptr val) { | ||
| 9833 | + builtin__array_set(a, builtin__v_ni_index(i, a->len), val); | ||
| 9834 | +} | ||
| 9835 | +inline VV_LOC void builtin__copy_element_to(voidptr dest, voidptr src, int element_size) { | ||
| 9836 | + { // Unsafe block | ||
| 9837 | + switch (element_size) { | ||
| 9838 | + case 1: { | ||
| 9839 | + builtin__vmemcpy(dest, src, 1); | ||
| 9840 | + break; | ||
| 9841 | + } | ||
| 9842 | + case 2: { | ||
| 9843 | + builtin__vmemcpy(dest, src, 2); | ||
| 9844 | + break; | ||
| 9845 | + } | ||
| 9846 | + case 4: { | ||
| 9847 | + builtin__vmemcpy(dest, src, 4); | ||
| 9848 | + break; | ||
| 9849 | + } | ||
| 9850 | + case 8: { | ||
| 9851 | + builtin__vmemcpy(dest, src, 8); | ||
| 9852 | + break; | ||
| 9853 | + } | ||
| 9854 | + case 16: { | ||
| 9855 | + builtin__vmemcpy(dest, src, 16); | ||
| 9856 | + break; | ||
| 9857 | + } | ||
| 9858 | + default: { | ||
| 9859 | + { | ||
| 9860 | + builtin__vmemcpy(dest, src, element_size); | ||
| 9861 | + break; | ||
| 9862 | + } | ||
| 9863 | + } | ||
| 9864 | + } | ||
| 9865 | + | ||
| 9866 | + } | ||
| 9867 | +} | ||
| 9868 | +VV_LOC void builtin__array_push(array* a, voidptr val) { | ||
| 9869 | + #if 1 | ||
| 9870 | + { | ||
| 9871 | + if (a->len < 0) { | ||
| 9872 | + builtin___v_panic(_S("array.push: negative len")); | ||
| 9873 | + VUNREACHABLE(); | ||
| 9874 | + } | ||
| 9875 | + } | ||
| 9876 | + #endif | ||
| 9877 | + if (a->len >= _const_max_int) { | ||
| 9878 | + builtin___v_panic(_S("array.push: len bigger than max_int")); | ||
| 9879 | + VUNREACHABLE(); | ||
| 9880 | + } | ||
| 9881 | + int required = a->len + 1; | ||
| 9882 | + if (required > a->cap) { | ||
| 9883 | + builtin__array_ensure_cap(a, required); | ||
| 9884 | + } else if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__is_slice)) { | ||
| 9885 | + builtin__array_clone_shallow_to_cap(a, a->cap); | ||
| 9886 | + } | ||
| 9887 | + builtin__copy_element_to(((u8*)(a->data)) + ((u64)(a->element_size)) * ((u64)(a->len)), val, a->element_size); | ||
| 9888 | + a->len++; | ||
| 9889 | +} | ||
| 9890 | +void builtin__array_push_many(array* a, voidptr val, int size) { | ||
| 9891 | + if (size <= 0 || val == ((void*)0)) { | ||
| 9892 | + return; | ||
| 9893 | + } | ||
| 9894 | + i64 new_len = ((i64)(a->len)) + ((i64)(size)); | ||
| 9895 | + if (new_len > _const_max_int) { | ||
| 9896 | + builtin___v_panic(_S("array.push_many: new len exceeds max_int")); | ||
| 9897 | + VUNREACHABLE(); | ||
| 9898 | + } | ||
| 9899 | + if (builtin__array_needs_unique_append(*a, ((int)(new_len)))) { | ||
| 9900 | + builtin__array_clone_shallow_to_cap(a, a->cap); | ||
| 9901 | + } | ||
| 9902 | + bool is_self_append = a->data == val && a->data != 0; | ||
| 9903 | + if (((int)(new_len)) > a->cap) { | ||
| 9904 | + builtin__array_ensure_cap(a, ((int)(new_len))); | ||
| 9905 | + } | ||
| 9906 | + if (is_self_append) { | ||
| 9907 | + array cloned = builtin__array_clone(a); | ||
| 9908 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(a->element_size)) * ((u64)(a->len)), cloned.data, ((u64)(a->element_size)) * ((u64)(size))); | ||
| 9909 | + } else { | ||
| 9910 | + if (a->data != 0 && val != 0) { | ||
| 9911 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(a->element_size)) * ((u64)(a->len)), val, ((u64)(a->element_size)) * ((u64)(size))); | ||
| 9912 | + } | ||
| 9913 | + } | ||
| 9914 | + a->len = ((int)(new_len)); | ||
| 9915 | +} | ||
| 9916 | +void builtin__array_reverse_in_place(array* a) { | ||
| 9917 | + if (a->len < 2 || a->element_size == 0) { | ||
| 9918 | + return; | ||
| 9919 | + } | ||
| 9920 | + { // Unsafe block | ||
| 9921 | + u8* tmp_value = builtin___v_malloc(a->element_size); | ||
| 9922 | + for (int i = 0; i < VSAFE_DIV_int(a->len , 2); ++i) { | ||
| 9923 | + builtin__vmemcpy(tmp_value, ((u8*)(a->data)) + ((u64)(i)) * ((u64)(a->element_size)), a->element_size); | ||
| 9924 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(i)) * ((u64)(a->element_size)), ((u8*)(a->data)) + ((u64)((int)(a->len - 1 - i))) * ((u64)(a->element_size)), a->element_size); | ||
| 9925 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)((int)(a->len - 1 - i))) * ((u64)(a->element_size)), tmp_value, a->element_size); | ||
| 9926 | + } | ||
| 9927 | + builtin___v_free(tmp_value); | ||
| 9928 | + } | ||
| 9929 | +} | ||
| 9930 | +array builtin__array_reverse(array a) { | ||
| 9931 | + if (a.len < 2) { | ||
| 9932 | + return a; | ||
| 9933 | + } | ||
| 9934 | + bool use_noscan_data = builtin__array_uses_noscan_data(a); | ||
| 9935 | + array _t2 = ((array){.data = builtin__array_alloc_array_data_like(a, ((u64)(a.cap)) * ((u64)(a.element_size))),.offset = 0,.len = a.len,.cap = a.cap,.flags = (use_noscan_data ? ((ArrayFlags__managed | ArrayFlags__noscan_data)) : (ArrayFlags__managed)),.element_size = a.element_size,}); | ||
| 9936 | + array arr = _t2; | ||
| 9937 | + for (int i = 0; i < a.len; ++i) { | ||
| 9938 | + builtin__array_set_unsafe(&arr, i, builtin__array_get_unsafe(a, (int)(a.len - 1 - i))); | ||
| 9939 | + } | ||
| 9940 | + return arr; | ||
| 9941 | +} | ||
| 9942 | +void builtin__array_free(array* a) { | ||
| 9943 | + if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__nofree)) { | ||
| 9944 | + return; | ||
| 9945 | + } | ||
| 9946 | + u8* mblock_ptr = ((u8*)(((u64)(a->data)) - ((u64)(a->offset)))); | ||
| 9947 | + if (mblock_ptr != ((void*)0)) { | ||
| 9948 | + { // Unsafe block | ||
| 9949 | + if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__managed)) { | ||
| 9950 | + builtin___v_free(mblock_ptr - builtin__array_data_header_size()); | ||
| 9951 | + } else { | ||
| 9952 | + builtin___v_free(mblock_ptr); | ||
| 9953 | + } | ||
| 9954 | + } | ||
| 9955 | + } | ||
| 9956 | + { // Unsafe block | ||
| 9957 | + a->data = ((void*)0); | ||
| 9958 | + a->offset = 0; | ||
| 9959 | + a->len = 0; | ||
| 9960 | + a->cap = 0; | ||
| 9961 | + } | ||
| 9962 | +} | ||
| 9963 | +array builtin__array_filter(array a, bool (*predicate)(voidptr _d1)); | ||
| 9964 | +bool builtin__array_any(array a, bool (*predicate)(voidptr _d1)); | ||
| 9965 | +int builtin__array_count(array a, bool (*predicate)(voidptr _d1)); | ||
| 9966 | +bool builtin__array_all(array a, bool (*predicate)(voidptr _d1)); | ||
| 9967 | +array builtin__array_map(array a, voidptr (*callback)(voidptr _d1)); | ||
| 9968 | +void builtin__array_sort(array* a, int (*callback)(voidptr _d1, voidptr _d2)); | ||
| 9969 | +array builtin__array_sorted(array* a, int (*callback)(voidptr _d1, voidptr _d2)); | ||
| 9970 | +void builtin__array_sort_with_compare(array* a, int (*callback)(const void* const_a, const void* const_b)) { | ||
| 9971 | + #if 0 | ||
| 9972 | + { | ||
| 9973 | + } | ||
| 9974 | + #else | ||
| 9975 | + { | ||
| 9976 | + builtin__vqsort(a->data, ((usize)(a->len)), ((usize)(a->element_size)), callback); | ||
| 9977 | + } | ||
| 9978 | + #endif | ||
| 9979 | +} | ||
| 9980 | +array builtin__array_sorted_with_compare(array* a, int (*callback)(const void* const_a, const void* const_b)) { | ||
| 9981 | + array r = builtin__array_clone(a); | ||
| 9982 | + builtin__vqsort(r.data, ((usize)(r.len)), ((usize)(r.element_size)), callback); | ||
| 9983 | + return r; | ||
| 9984 | +} | ||
| 9985 | +bool builtin__array_contains(array a, voidptr value); | ||
| 9986 | +int builtin__array_index(array a, voidptr value); | ||
| 9987 | +int builtin__array_last_index(array a, voidptr value); | ||
| 9988 | +void Array_string_free(Array_string* a) { | ||
| 9989 | + for (int _t1 = 0; _t1 < a->len; ++_t1) { | ||
| 9990 | + string* s = ((string*)a->data) + _t1; | ||
| 9991 | + builtin__string_free(s); | ||
| 9992 | + } | ||
| 9993 | + array* arr = ((array*)(a)); | ||
| 9994 | + builtin__array_free(arr); | ||
| 9995 | +} | ||
| 9996 | +string Array_string_str(Array_string a) { | ||
| 9997 | + int sb_len = 4; | ||
| 9998 | + if (a.len > 0) { | ||
| 9999 | + sb_len += ((string*)a.data)[0].len; | ||
| 10000 | + sb_len *= a.len; | ||
| 10001 | + } | ||
| 10002 | + sb_len += 2; | ||
| 10003 | + strings__Builder sb = strings__new_builder(sb_len); | ||
| 10004 | + strings__Builder_write_u8(&sb, '['); | ||
| 10005 | + for (int i = 0; i < a.len; ++i) { | ||
| 10006 | + string val = ((string*)a.data)[i]; | ||
| 10007 | + strings__Builder_write_u8(&sb, '\''); | ||
| 10008 | + strings__Builder_write_string(&sb, val); | ||
| 10009 | + strings__Builder_write_u8(&sb, '\''); | ||
| 10010 | + if (i < a.len - 1) { | ||
| 10011 | + strings__Builder_write_string(&sb, _S(", ")); | ||
| 10012 | + } | ||
| 10013 | + } | ||
| 10014 | + strings__Builder_write_u8(&sb, ']'); | ||
| 10015 | + string res = strings__Builder_str(&sb); | ||
| 10016 | + strings__Builder_free(&sb); | ||
| 10017 | + return res; | ||
| 10018 | +} | ||
| 10019 | +string Array_u8_hex(Array_u8 b) { | ||
| 10020 | + if (b.len == 0) { | ||
| 10021 | + return _S(""); | ||
| 10022 | + } | ||
| 10023 | + return builtin__data_to_hex_string(b.data, b.len); | ||
| 10024 | +} | ||
| 10025 | +int builtin__copy(Array_u8* dst, Array_u8 src) { | ||
| 10026 | + int min = (dst->len < src.len ? (dst->len) : (src.len)); | ||
| 10027 | + if (min > 0) { | ||
| 10028 | + builtin__vmemmove(dst->data, src.data, min); | ||
| 10029 | + } | ||
| 10030 | + return min; | ||
| 10031 | +} | ||
| 10032 | +void builtin__array_grow_cap(array* a, int amount) { | ||
| 10033 | + i64 new_cap = ((i64)(amount)) + ((i64)(a->cap)); | ||
| 10034 | + if (new_cap > _const_max_int) { | ||
| 10035 | + builtin__panic_n(_S("array.grow_cap: max_int will be exceeded by new cap:"), new_cap); | ||
| 10036 | + VUNREACHABLE(); | ||
| 10037 | + } | ||
| 10038 | + builtin__array_ensure_cap(a, ((int)(new_cap))); | ||
| 10039 | +} | ||
| 10040 | +void builtin__array_grow_len(array* a, int amount) { | ||
| 10041 | + i64 new_len = ((i64)(amount)) + ((i64)(a->len)); | ||
| 10042 | + if (new_len > _const_max_int) { | ||
| 10043 | + builtin__panic_n(_S("array.grow_len: max_int will be exceeded by new len:"), new_len); | ||
| 10044 | + VUNREACHABLE(); | ||
| 10045 | + } | ||
| 10046 | + builtin__array_ensure_cap(a, ((int)(new_len))); | ||
| 10047 | + a->len = ((int)(new_len)); | ||
| 10048 | +} | ||
| 10049 | +Array_voidptr builtin__array_pointers(array a) { | ||
| 10050 | + Array_voidptr res = builtin____new_array_with_default(0, 0, sizeof(voidptr), 0); | ||
| 10051 | + for (int i = 0; i < a.len; ++i) { | ||
| 10052 | + builtin__array_push((array*)&res, _MOV((voidptr[]){ builtin__array_get_unsafe(a, i) })); | ||
| 10053 | + } | ||
| 10054 | + return res; | ||
| 10055 | +} | ||
| 10056 | +Array_u8 builtin__voidptr_vbytes(voidptr data, int len) { | ||
| 10057 | + array _t1 = ((array){.data = data,.offset = 0,.len = len,.cap = len,.flags = 0,.element_size = 1,}); | ||
| 10058 | + array res = _t1; | ||
| 10059 | + return res; | ||
| 10060 | +} | ||
| 10061 | +Array_u8 builtin__u8_vbytes(u8* data, int len) { | ||
| 10062 | + return builtin__voidptr_vbytes(((voidptr)(data)), len); | ||
| 10063 | +} | ||
| 10064 | +void builtin__u8_free(u8* data) { | ||
| 10065 | + builtin___v_free(data); | ||
| 10066 | +} | ||
| 10067 | +inline VV_LOC void builtin__panic_on_negative_len(int len) { | ||
| 10068 | + if (len < 0) { | ||
| 10069 | + builtin__panic_n(_S("negative .len:"), len); | ||
| 10070 | + VUNREACHABLE(); | ||
| 10071 | + } | ||
| 10072 | +} | ||
| 10073 | +inline VV_LOC void builtin__panic_on_negative_cap(int cap) { | ||
| 10074 | + if (cap < 0) { | ||
| 10075 | + builtin__panic_n(_S("negative .cap:"), cap); | ||
| 10076 | + VUNREACHABLE(); | ||
| 10077 | + } | ||
| 10078 | +} | ||
| 10079 | +VV_LOC array builtin____new_array_noscan(int mylen, int cap, int elm_size) { | ||
| 10080 | + return builtin____new_array(mylen, cap, elm_size); | ||
| 10081 | +} | ||
| 10082 | +VV_LOC array builtin____new_array_with_default_noscan(int mylen, int cap, int elm_size, voidptr val) { | ||
| 10083 | + return builtin____new_array_with_default(mylen, cap, elm_size, val); | ||
| 10084 | +} | ||
| 10085 | +VV_LOC array builtin____new_array_with_multi_default_noscan(int mylen, int cap, int elm_size, voidptr val) { | ||
| 10086 | + return builtin____new_array_with_multi_default(mylen, cap, elm_size, val); | ||
| 10087 | +} | ||
| 10088 | +VV_LOC array builtin____new_array_with_array_default_noscan(int mylen, int cap, int elm_size, array val, int depth) { | ||
| 10089 | + return builtin____new_array_with_array_default(mylen, cap, elm_size, val, depth); | ||
| 10090 | +} | ||
| 10091 | +VV_LOC void builtin__array_push_noscan(array* a, voidptr val) { | ||
| 10092 | + builtin__array_push(a, val); | ||
| 10093 | +} | ||
| 10094 | +VV_LOC void builtin__array_push_many_noscan(array* a, voidptr val, int size) { | ||
| 10095 | + builtin__array_push_many(a, val, size); | ||
| 10096 | +} | ||
| 10097 | +VV_LOC bool builtin__autostr_type_in_stack(int typ) { | ||
| 10098 | + for (int i = 0; i < g_autostr_type_stack_len; i++) { | ||
| 10099 | + if (g_autostr_type_stack[builtin__v_fixed_index(i, 64)] == typ) { | ||
| 10100 | + return true; | ||
| 10101 | + } | ||
| 10102 | + } | ||
| 10103 | + return false; | ||
| 10104 | +} | ||
| 10105 | +VV_LOC void builtin__autostr_type_push(int typ) { | ||
| 10106 | + if (g_autostr_type_stack_len >= _const_autostr_type_stack_max_depth) { | ||
| 10107 | + return; | ||
| 10108 | + } | ||
| 10109 | + g_autostr_type_stack[builtin__v_fixed_index(g_autostr_type_stack_len, 64)] = typ; | ||
| 10110 | + g_autostr_type_stack_len++; | ||
| 10111 | +} | ||
| 10112 | +VV_LOC void builtin__autostr_type_pop(void) { | ||
| 10113 | + if (g_autostr_type_stack_len > 0) { | ||
| 10114 | + g_autostr_type_stack_len--; | ||
| 10115 | + } | ||
| 10116 | +} | ||
| 10117 | +VV_LOC bool builtin__autostr_addr_in_stack(voidptr addr) { | ||
| 10118 | + for (int i = 0; i < g_autostr_addr_stack_len; i++) { | ||
| 10119 | + if (g_autostr_addr_stack[builtin__v_fixed_index(i, 64)] == addr) { | ||
| 10120 | + return true; | ||
| 10121 | + } | ||
| 10122 | + } | ||
| 10123 | + return false; | ||
| 10124 | +} | ||
| 10125 | +VV_LOC void builtin__autostr_addr_push(voidptr addr) { | ||
| 10126 | + if (g_autostr_addr_stack_len >= _const_autostr_type_stack_max_depth) { | ||
| 10127 | + return; | ||
| 10128 | + } | ||
| 10129 | + g_autostr_addr_stack[builtin__v_fixed_index(g_autostr_addr_stack_len, 64)] = addr; | ||
| 10130 | + g_autostr_addr_stack_len++; | ||
| 10131 | +} | ||
| 10132 | +VV_LOC void builtin__autostr_addr_pop(void) { | ||
| 10133 | + if (g_autostr_addr_stack_len > 0) { | ||
| 10134 | + g_autostr_addr_stack_len--; | ||
| 10135 | + } | ||
| 10136 | +} | ||
| 10137 | +VV_LOC string builtin__autostr_array_circular(int len) { | ||
| 10138 | + if (len <= 0) { | ||
| 10139 | + return _S("[]"); | ||
| 10140 | + } | ||
| 10141 | + strings__Builder sb = strings__new_builder(2 + len * 12); | ||
| 10142 | + strings__Builder_write_string(&sb, _S("[")); | ||
| 10143 | + for (int i = 0; i < len; ++i) { | ||
| 10144 | + if (i > 0) { | ||
| 10145 | + strings__Builder_write_string(&sb, _S(", ")); | ||
| 10146 | + } | ||
| 10147 | + strings__Builder_write_string(&sb, _S("<circular>")); | ||
| 10148 | + } | ||
| 10149 | + strings__Builder_write_string(&sb, _S("]")); | ||
| 10150 | + string res = strings__Builder_str(&sb); | ||
| 10151 | + strings__Builder_free(&sb); | ||
| 10152 | + return res; | ||
| 10153 | +} | ||
| 10154 | +void builtin__print_backtrace(void) { | ||
| 10155 | + #if !defined(CUSTOM_DEFINE_no_backtrace) | ||
| 10156 | + { | ||
| 10157 | + #if 0 | ||
| 10158 | + { | ||
| 10159 | + } | ||
| 10160 | + #elif defined(__TINYC__) | ||
| 10161 | + { | ||
| 10162 | + } | ||
| 10163 | + #elif defined(CUSTOM_DEFINE_use_libbacktrace) | ||
| 10164 | + { | ||
| 10165 | + } | ||
| 10166 | + #else | ||
| 10167 | + { | ||
| 10168 | + builtin__print_backtrace_skipping_top_frames(2); | ||
| 10169 | + } | ||
| 10170 | + #endif | ||
| 10171 | + } | ||
| 10172 | + #endif | ||
| 10173 | +} | ||
| 10174 | +VV_LOC string builtin__demangle_v_symbol(string cname) { | ||
| 10175 | + string name = cname; | ||
| 10176 | + if (builtin__string_starts_with(name, _S("builtin__"))) { | ||
| 10177 | + name = builtin__string_substr(name, 9, 2147483647); | ||
| 10178 | + } | ||
| 10179 | + name = builtin__string_replace(name, _S("__ptr__"), _S("&")); | ||
| 10180 | + _option_int _t1 = builtin__string_index(name, _S("_T_")); | ||
| 10181 | + if (_t1.state != 0) { | ||
| 10182 | + *(int*) _t1.data = -1; | ||
| 10183 | + } | ||
| 10184 | + | ||
| 10185 | + int t_pos = (*(int*)_t1.data); | ||
| 10186 | + if (t_pos >= 0) { | ||
| 10187 | + string base = builtin__string_replace(builtin__string_substr(name, 0, t_pos), _S("__"), _S(".")); | ||
| 10188 | + string generic_suffix = builtin__string_substr(name, t_pos + 3, 2147483647); | ||
| 10189 | + Array_string params = builtin__split_generic_params(generic_suffix); | ||
| 10190 | + Array_string demangled_params = builtin____new_array_with_default(0, params.len, sizeof(string), 0); | ||
| 10191 | + for (int _t2 = 0; _t2 < params.len; ++_t2) { | ||
| 10192 | + string param = ((string*)params.data)[_t2]; | ||
| 10193 | + builtin__array_push((array*)&demangled_params, _MOV((string[]){ builtin__string_replace(param, _S("__"), _S(".")) })); | ||
| 10194 | + } | ||
| 10195 | + return builtin__string_plus_many(4, _MOV((string[4]){base, _S("["), Array_string_join(demangled_params, _S(", ")), _S("]")})); | ||
| 10196 | + } | ||
| 10197 | + name = builtin__string_replace(name, _S("__"), _S(".")); | ||
| 10198 | + if (_SLIT_EQ(name.str, name.len, "main.main")) { | ||
| 10199 | + return _S("main"); | ||
| 10200 | + } | ||
| 10201 | + return name; | ||
| 10202 | +} | ||
| 10203 | +VV_LOC Array_string builtin__split_generic_params(string s) { | ||
| 10204 | + Array_string params = builtin____new_array_with_default(0, 0, sizeof(string), 0); | ||
| 10205 | + int start = 0; | ||
| 10206 | + int i = 0; | ||
| 10207 | + for (;;) { | ||
| 10208 | + if (!(i < s.len)) break; | ||
| 10209 | + if (s.str[ i] == '_') { | ||
| 10210 | + if (i + 1 < s.len && s.str[ i + 1] == '_') { | ||
| 10211 | + i += 2; | ||
| 10212 | + } else { | ||
| 10213 | + if (i > start) { | ||
| 10214 | + builtin__array_push((array*)¶ms, _MOV((string[]){ builtin__string_substr(s, start, i) })); | ||
| 10215 | + } | ||
| 10216 | + i++; | ||
| 10217 | + start = i; | ||
| 10218 | + } | ||
| 10219 | + } else { | ||
| 10220 | + i++; | ||
| 10221 | + } | ||
| 10222 | + } | ||
| 10223 | + if (start < s.len) { | ||
| 10224 | + builtin__array_push((array*)¶ms, _MOV((string[]){ builtin__string_substr(s, start, 2147483647) })); | ||
| 10225 | + } | ||
| 10226 | + return params; | ||
| 10227 | +} | ||
| 10228 | +VV_LOC string builtin__demangle_backtrace_sym(string s) { | ||
| 10229 | + _option_int _t1 = builtin__string_index(s, _S("(")); | ||
| 10230 | + if (_t1.state != 0) { | ||
| 10231 | + return s; | ||
| 10232 | + } | ||
| 10233 | + | ||
| 10234 | + int paren_start = (*(int*)_t1.data); | ||
| 10235 | + int plus_pos = builtin__string_index_after_(s, _S("+"), paren_start); | ||
| 10236 | + if (plus_pos < 0) { | ||
| 10237 | + return s; | ||
| 10238 | + } | ||
| 10239 | + string symbol = builtin__string_substr(s, paren_start + 1, plus_pos); | ||
| 10240 | + if (symbol.len == 0) { | ||
| 10241 | + return s; | ||
| 10242 | + } | ||
| 10243 | + return builtin__string_plus_many(3, _MOV((string[3]){builtin__string_substr(s, 0, paren_start + 1), builtin__demangle_v_symbol(symbol), builtin__string_substr(s, plus_pos, 2147483647)})); | ||
| 10244 | +} | ||
| 10245 | +VV_LOC void builtin__eprint_space_padding(string output, int max_len) { | ||
| 10246 | + int padding_len = max_len - output.len; | ||
| 10247 | + if (padding_len > 0) { | ||
| 10248 | + for (int _t1 = 0; _t1 < padding_len; ++_t1) { | ||
| 10249 | + builtin__eprint(_S(" ")); | ||
| 10250 | + } | ||
| 10251 | + } | ||
| 10252 | +} | ||
| 10253 | +bool builtin__print_backtrace_skipping_top_frames(int xskipframes) { | ||
| 10254 | + #if defined(CUSTOM_DEFINE_no_backtrace) | ||
| 10255 | + { | ||
| 10256 | + } | ||
| 10257 | + #else | ||
| 10258 | + { | ||
| 10259 | + int skipframes = xskipframes + 2; | ||
| 10260 | + #if 0 | ||
| 10261 | + { | ||
| 10262 | + } | ||
| 10263 | + #elif 1 | ||
| 10264 | + { | ||
| 10265 | + return builtin__print_backtrace_skipping_top_frames_linux(skipframes); | ||
| 10266 | + } | ||
| 10267 | + #else | ||
| 10268 | + { | ||
| 10269 | + } | ||
| 10270 | + #endif | ||
| 10271 | + } | ||
| 10272 | + #endif | ||
| 10273 | + return false; | ||
| 10274 | +} | ||
| 10275 | +VV_LOC string builtin__backtrace_current_executable_name(void) { | ||
| 10276 | + Array_string args = builtin__arguments(); | ||
| 10277 | + if (args.len == 0) { | ||
| 10278 | + return _S(""); | ||
| 10279 | + } | ||
| 10280 | + return (*(string*)builtin__array_get(args, 0)); | ||
| 10281 | +} | ||
| 10282 | +VV_LOC string builtin__backtrace_addr2line_executable(string executable, string current_executable_name) { | ||
| 10283 | + if (executable.len == 0) { | ||
| 10284 | + return _S("/proc/self/exe"); | ||
| 10285 | + } | ||
| 10286 | + if (builtin__string_contains(executable, _S("/"))) { | ||
| 10287 | + return executable; | ||
| 10288 | + } | ||
| 10289 | + if (current_executable_name.len > 0 && builtin__string__eq(builtin__string_all_after_last(executable, _S("/")), builtin__string_all_after_last(current_executable_name, _S("/")))) { | ||
| 10290 | + return _S("/proc/self/exe"); | ||
| 10291 | + } | ||
| 10292 | + return executable; | ||
| 10293 | +} | ||
| 10294 | +VV_LOC string builtin__backtrace_shell_quote(string s) { | ||
| 10295 | + string quoted = _S("'"); | ||
| 10296 | + for (int i = 0; i < s.len; ++i) { | ||
| 10297 | + if (builtin__string_at(s, i) == '\'') { | ||
| 10298 | + quoted = builtin__string__plus(quoted, _S("'\\''")); | ||
| 10299 | + } else { | ||
| 10300 | + quoted = builtin__string__plus(quoted, builtin__u8_ascii_str(builtin__string_at(s, i))); | ||
| 10301 | + } | ||
| 10302 | + } | ||
| 10303 | + return builtin__string__plus(quoted, _S("'")); | ||
| 10304 | +} | ||
| 10305 | +VV_LOC bool builtin__print_backtrace_skipping_top_frames_linux(int skipframes) { | ||
| 10306 | + #if defined(CUSTOM_DEFINE_no_backtrace) | ||
| 10307 | + { | ||
| 10308 | + } | ||
| 10309 | + #else | ||
| 10310 | + { | ||
| 10311 | + #if 1 | ||
| 10312 | + { | ||
| 10313 | + #if 0 | ||
| 10314 | + { | ||
| 10315 | + } | ||
| 10316 | + #else | ||
| 10317 | + { | ||
| 10318 | + string current_executable_name = builtin__backtrace_current_executable_name(); | ||
| 10319 | + Array_fixed_voidptr_100 buffer = {0}; | ||
| 10320 | + i32 nr_ptrs = backtrace(&buffer[0], 100); | ||
| 10321 | + if (nr_ptrs < 2) { | ||
| 10322 | + builtin__eprintln(_S("C.backtrace returned less than 2 frames")); | ||
| 10323 | + return false; | ||
| 10324 | + } | ||
| 10325 | + int nr_actual_frames = (int)(nr_ptrs - skipframes); | ||
| 10326 | + char** csymbols = backtrace_symbols(((voidptr)(&buffer[skipframes])), nr_actual_frames); | ||
| 10327 | + for (int i = 0; i < nr_actual_frames; ++i) { | ||
| 10328 | + string sframe = builtin__tos2(((u8*)(csymbols[i]))); | ||
| 10329 | + string executable = builtin__string_all_before(sframe, _S("(")); | ||
| 10330 | + string addr2line_executable = builtin__backtrace_addr2line_executable(executable, current_executable_name); | ||
| 10331 | + string addr = builtin__string_all_before(builtin__string_all_after(sframe, _S("[")), _S("]")); | ||
| 10332 | + string beforeaddr = builtin__string_all_before(sframe, _S("[")); | ||
| 10333 | + string cmd = builtin__string_plus_many(4, _MOV((string[4]){_S("addr2line -e "), builtin__backtrace_shell_quote(addr2line_executable), _S(" "), builtin__backtrace_shell_quote(addr)})); | ||
| 10334 | + voidptr f = popen(((char*)(cmd.str)), "r"); | ||
| 10335 | + if (f == ((void*)0)) { | ||
| 10336 | + builtin__eprintln(sframe); | ||
| 10337 | + continue; | ||
| 10338 | + } | ||
| 10339 | + Array_fixed_u8_1000 buf = {0}; | ||
| 10340 | + string output = _S(""); | ||
| 10341 | + { // Unsafe block | ||
| 10342 | + u8* bp = ((u8*)(&buf[0])); | ||
| 10343 | + for (;;) { | ||
| 10344 | + if (!(fgets(((char*)(bp)), 1000, f) != 0)) break; | ||
| 10345 | + output = builtin__string__plus(output, builtin__tos(bp, builtin__vstrlen(bp))); | ||
| 10346 | + } | ||
| 10347 | + } | ||
| 10348 | + output = builtin__string__plus(builtin__string_trim_chars(output, _S(" \t\n"), TrimMode__trim_both), _S(":")); | ||
| 10349 | + if (pclose(f) != 0) { | ||
| 10350 | + builtin__eprintln(sframe); | ||
| 10351 | + continue; | ||
| 10352 | + } | ||
| 10353 | + if (_SLIT_EQ(output.str, output.len, "??:0:") || _SLIT_EQ(output.str, output.len, "??:?:")) { | ||
| 10354 | + output = _S(""); | ||
| 10355 | + } | ||
| 10356 | + output = builtin__string_replace(output, _S(" (discriminator"), _S(": (d.")); | ||
| 10357 | + builtin__eprint(output); | ||
| 10358 | + builtin__eprint_space_padding(output, 55); | ||
| 10359 | + builtin__eprint(_S(" | ")); | ||
| 10360 | + builtin__eprint(addr); | ||
| 10361 | + builtin__eprint(_S(" | ")); | ||
| 10362 | + builtin__eprintln(builtin__demangle_backtrace_sym(beforeaddr)); | ||
| 10363 | + } | ||
| 10364 | + if (nr_actual_frames > 0) { | ||
| 10365 | + free(csymbols); | ||
| 10366 | + } | ||
| 10367 | + } | ||
| 10368 | + #endif | ||
| 10369 | + } | ||
| 10370 | + #endif | ||
| 10371 | + } | ||
| 10372 | + #endif | ||
| 10373 | + return true; | ||
| 10374 | +} | ||
| 10375 | +VNORETURN void builtin___v_exit(int code) { | ||
| 10376 | + exit(code); | ||
| 10377 | + VUNREACHABLE(); | ||
| 10378 | + for (;;) { | ||
| 10379 | + } | ||
| 10380 | + while(1); | ||
| 10381 | +} | ||
| 10382 | +_result_void builtin__at_exit(void (*cb)(void)) { | ||
| 10383 | + #if 0 | ||
| 10384 | + { | ||
| 10385 | + } | ||
| 10386 | + #else | ||
| 10387 | + { | ||
| 10388 | + i32 res = atexit(cb); | ||
| 10389 | + if (res != 0) { | ||
| 10390 | + return (_result_void){ .is_error=true, .err=builtin__error_with_code(_S("at_exit failed"), res), .data={E_STRUCT} }; | ||
| 10391 | + } | ||
| 10392 | + } | ||
| 10393 | + #endif | ||
| 10394 | + return (_result_void){0}; | ||
| 10395 | +} | ||
| 10396 | +VV_LOC void builtin__v_segmentation_fault_handler(i32 signal_number) { | ||
| 10397 | + #if defined(CUSTOM_DEFINE_v2_native_windows_pe_minimal) | ||
| 10398 | + { | ||
| 10399 | + } | ||
| 10400 | + #else | ||
| 10401 | + { | ||
| 10402 | + #if 0 | ||
| 10403 | + { | ||
| 10404 | + } | ||
| 10405 | + #else | ||
| 10406 | + { | ||
| 10407 | + fprintf(stderr, "signal %d: segmentation fault\n", signal_number); | ||
| 10408 | + } | ||
| 10409 | + #endif | ||
| 10410 | + #if defined(CUSTOM_DEFINE_use_libbacktrace) && !defined(__TINYC__) | ||
| 10411 | + { | ||
| 10412 | + } | ||
| 10413 | + #elif 0 | ||
| 10414 | + { | ||
| 10415 | + } | ||
| 10416 | + #else | ||
| 10417 | + { | ||
| 10418 | + builtin__print_backtrace(); | ||
| 10419 | + } | ||
| 10420 | + #endif | ||
| 10421 | + builtin___v_exit(128 + signal_number); | ||
| 10422 | + VUNREACHABLE(); | ||
| 10423 | + } | ||
| 10424 | + #endif | ||
| 10425 | +} | ||
| 10426 | +inline VV_LOC int builtin__v_fixed_index(int i, int len) { | ||
| 10427 | + #if 1 | ||
| 10428 | + { | ||
| 10429 | + if (i < 0 || i >= len) { | ||
| 10430 | + builtin___v_panic(builtin__string_plus_many(5, _MOV((string[5]){_S("fixed array index out of range (index: "), builtin__i64_str(((i64)(i))), _S(", len: "), builtin__i64_str(((i64)(len))), _S(")")}))); | ||
| 10431 | + VUNREACHABLE(); | ||
| 10432 | + } | ||
| 10433 | + } | ||
| 10434 | + #endif | ||
| 10435 | + return i; | ||
| 10436 | +} | ||
| 10437 | +inline VV_LOC int builtin__v_fixed_index_i64(i64 i, int len) { | ||
| 10438 | + #if 1 | ||
| 10439 | + { | ||
| 10440 | + if (i < 0 || i >= ((i64)(len))) { | ||
| 10441 | + builtin___v_panic(builtin__string_plus_many(5, _MOV((string[5]){_S("fixed array index out of range (index: "), builtin__i64_str(i), _S(", len: "), builtin__i64_str(((i64)(len))), _S(")")}))); | ||
| 10442 | + VUNREACHABLE(); | ||
| 10443 | + } | ||
| 10444 | + } | ||
| 10445 | + #endif | ||
| 10446 | + return ((int)(i)); | ||
| 10447 | +} | ||
| 10448 | +inline VV_LOC int builtin__v_fixed_index_u64(u64 i, int len) { | ||
| 10449 | + #if 1 | ||
| 10450 | + { | ||
| 10451 | + if (i >= ((u64)(len))) { | ||
| 10452 | + builtin___v_panic(builtin__string_plus_many(5, _MOV((string[5]){_S("fixed array index out of range (index: "), builtin__u64_str(i), _S(", len: "), builtin__i64_str(((i64)(len))), _S(")")}))); | ||
| 10453 | + VUNREACHABLE(); | ||
| 10454 | + } | ||
| 10455 | + } | ||
| 10456 | + #endif | ||
| 10457 | + return ((int)(i)); | ||
| 10458 | +} | ||
| 10459 | +inline VV_LOC int builtin__v_fixed_index_ni(int i, int len) { | ||
| 10460 | + return builtin__v_fixed_index(builtin__v_ni_index(i, len), len); | ||
| 10461 | +} | ||
| 10462 | +inline VV_LOC int builtin__v_slice_index_i64(i64 i) { | ||
| 10463 | + if (i < ((i64)(_const_min_int)) || i > ((i64)(_const_max_int))) { | ||
| 10464 | + builtin___v_panic(builtin__string__plus(_S("slice index out of range for int: "), builtin__i64_str(i))); | ||
| 10465 | + VUNREACHABLE(); | ||
| 10466 | + } | ||
| 10467 | + return ((int)(i)); | ||
| 10468 | +} | ||
| 10469 | +inline VV_LOC int builtin__v_slice_index_u64(u64 i) { | ||
| 10470 | + if (i > ((u64)(_const_max_int))) { | ||
| 10471 | + builtin___v_panic(builtin__string__plus(_S("slice index out of range for int: "), builtin__u64_str(i))); | ||
| 10472 | + VUNREACHABLE(); | ||
| 10473 | + } | ||
| 10474 | + return ((int)(i)); | ||
| 10475 | +} | ||
| 10476 | +Array_string builtin__arguments(void) { | ||
| 10477 | + u8** argv = ((u8**)(g_main_argv)); | ||
| 10478 | + Array_string res = builtin____new_array_with_default(0, g_main_argc, sizeof(string), 0); | ||
| 10479 | + for (int i = 0; i < g_main_argc; ++i) { | ||
| 10480 | + #if 0 | ||
| 10481 | + { | ||
| 10482 | + } | ||
| 10483 | + #else | ||
| 10484 | + { | ||
| 10485 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__tos_clone(argv[i]) })); | ||
| 10486 | + } | ||
| 10487 | + #endif | ||
| 10488 | + } | ||
| 10489 | + return res; | ||
| 10490 | +} | ||
| 10491 | +string builtin__vcurrent_hash(void) { | ||
| 10492 | + return _S(""); | ||
| 10493 | +} | ||
| 10494 | +u64 builtin__v_getpid(void) { | ||
| 10495 | + #if defined(CUSTOM_DEFINE_no_getpid) | ||
| 10496 | + { | ||
| 10497 | + } | ||
| 10498 | + #elif 0 | ||
| 10499 | + { | ||
| 10500 | + } | ||
| 10501 | + #else | ||
| 10502 | + { | ||
| 10503 | + return ((u64)(getpid())); | ||
| 10504 | + } | ||
| 10505 | + #endif | ||
| 10506 | + return 0; | ||
| 10507 | +} | ||
| 10508 | +u64 builtin__v_gettid(void) { | ||
| 10509 | + #if defined(CUSTOM_DEFINE_no_gettid) | ||
| 10510 | + { | ||
| 10511 | + } | ||
| 10512 | + #elif 0 | ||
| 10513 | + { | ||
| 10514 | + } | ||
| 10515 | + #elif 1 | ||
| 10516 | + { | ||
| 10517 | + return ((u64)(gettid())); | ||
| 10518 | + } | ||
| 10519 | + #elif 0 | ||
| 10520 | + { | ||
| 10521 | + } | ||
| 10522 | + #else | ||
| 10523 | + { | ||
| 10524 | + } | ||
| 10525 | + #endif | ||
| 10526 | + return 0; | ||
| 10527 | +} | ||
| 10528 | +inline bool builtin__isnil(voidptr v) { | ||
| 10529 | + return v == 0; | ||
| 10530 | +} | ||
| 10531 | +VV_LOC void builtin__builtin_init(void) { | ||
| 10532 | + #if 1 | ||
| 10533 | + { | ||
| 10534 | + builtin__unbuffer_stdout(); | ||
| 10535 | + } | ||
| 10536 | + #endif | ||
| 10537 | +} | ||
| 10538 | +VNORETURN void builtin__panic_lasterr(string base) { | ||
| 10539 | + builtin___v_panic(builtin__string__plus(base, _S(" unknown"))); | ||
| 10540 | + VUNREACHABLE(); | ||
| 10541 | + while(1); | ||
| 10542 | +} | ||
| 10543 | +void builtin__gc_check_leaks(void) { | ||
| 10544 | +} | ||
| 10545 | +bool builtin__gc_is_enabled(void) { | ||
| 10546 | + return false; | ||
| 10547 | +} | ||
| 10548 | +void builtin__gc_enable(void) { | ||
| 10549 | +} | ||
| 10550 | +void builtin__gc_disable(void) { | ||
| 10551 | +} | ||
| 10552 | +void builtin__gc_collect(void) { | ||
| 10553 | +} | ||
| 10554 | +void builtin__gc_get_warn_proc(void) { | ||
| 10555 | +} | ||
| 10556 | +void builtin__gc_set_warn_proc(void (*cb)(char* msg, usize arg)) { | ||
| 10557 | +} | ||
| 10558 | +#if 0 | ||
| 10559 | +#else | ||
| 10560 | +#endif | ||
| 10561 | +inline int builtin__vstrlen(u8* s) { | ||
| 10562 | + return ((int)(strlen(((char*)(s))))); | ||
| 10563 | +} | ||
| 10564 | +inline int builtin__vstrlen_char(char* s) { | ||
| 10565 | + return ((int)(strlen(s))); | ||
| 10566 | +} | ||
| 10567 | +inline voidptr builtin__vmemcpy(voidptr dest, const void* const_src, isize n) { | ||
| 10568 | + if (n == 0 || ((u64)(dest)) <= 0xFFFF || ((u64)(const_src)) <= 0xFFFF) { | ||
| 10569 | + return dest; | ||
| 10570 | + } | ||
| 10571 | + { // Unsafe block | ||
| 10572 | + return memcpy(dest, const_src, n); | ||
| 10573 | + } | ||
| 10574 | + return 0; | ||
| 10575 | +} | ||
| 10576 | +inline voidptr builtin__vmemmove(voidptr dest, const void* const_src, isize n) { | ||
| 10577 | + if (n == 0 || ((u64)(dest)) <= 0xFFFF || ((u64)(const_src)) <= 0xFFFF) { | ||
| 10578 | + return dest; | ||
| 10579 | + } | ||
| 10580 | + { // Unsafe block | ||
| 10581 | + return memmove(dest, const_src, n); | ||
| 10582 | + } | ||
| 10583 | + return 0; | ||
| 10584 | +} | ||
| 10585 | +inline int builtin__vmemcmp(const void* const_s1, const void* const_s2, isize n) { | ||
| 10586 | + if (n == 0 || ((u64)(const_s1)) <= 0xFFFF || ((u64)(const_s2)) <= 0xFFFF) { | ||
| 10587 | + return 0; | ||
| 10588 | + } | ||
| 10589 | + { // Unsafe block | ||
| 10590 | + return memcmp(const_s1, const_s2, n); | ||
| 10591 | + } | ||
| 10592 | + return 0; | ||
| 10593 | +} | ||
| 10594 | +inline voidptr builtin__vmemset(voidptr s, int c, isize n) { | ||
| 10595 | + if (n == 0 || ((u64)(s)) <= 0xFFFF) { | ||
| 10596 | + return s; | ||
| 10597 | + } | ||
| 10598 | + { // Unsafe block | ||
| 10599 | + return memset(s, c, n); | ||
| 10600 | + } | ||
| 10601 | + return 0; | ||
| 10602 | +} | ||
| 10603 | +inline VV_LOC voidptr builtin__vsort_ptr_at(voidptr base, usize index, usize size) { | ||
| 10604 | + return ((voidptr)(((u8*)(base)) + index * size)); | ||
| 10605 | +} | ||
| 10606 | +VV_LOC void builtin__vstable_sort_merge(voidptr source, voidptr dest, usize left, usize mid, usize right, usize size, int (*sort_cb)(const void* const_a, const void* const_b)) { | ||
| 10607 | + usize left_index = left; | ||
| 10608 | + usize right_index = mid; | ||
| 10609 | + usize dest_index = left; | ||
| 10610 | + for (;;) { | ||
| 10611 | + if (!(left_index < mid && right_index < right)) break; | ||
| 10612 | + voidptr left_ptr = builtin__vsort_ptr_at(source, left_index, size); | ||
| 10613 | + voidptr right_ptr = builtin__vsort_ptr_at(source, right_index, size); | ||
| 10614 | + if (sort_cb(left_ptr, right_ptr) <= 0) { | ||
| 10615 | + builtin__vmemcpy(builtin__vsort_ptr_at(dest, dest_index, size), left_ptr, ((isize)(size))); | ||
| 10616 | + left_index++; | ||
| 10617 | + } else { | ||
| 10618 | + builtin__vmemcpy(builtin__vsort_ptr_at(dest, dest_index, size), right_ptr, ((isize)(size))); | ||
| 10619 | + right_index++; | ||
| 10620 | + } | ||
| 10621 | + dest_index++; | ||
| 10622 | + } | ||
| 10623 | + if (left_index < mid) { | ||
| 10624 | + builtin__vmemcpy(builtin__vsort_ptr_at(dest, dest_index, size), builtin__vsort_ptr_at(source, left_index, size), ((isize)((mid - left_index) * size))); | ||
| 10625 | + } | ||
| 10626 | + if (right_index < right) { | ||
| 10627 | + builtin__vmemcpy(builtin__vsort_ptr_at(dest, dest_index, size), builtin__vsort_ptr_at(source, right_index, size), ((isize)((right - right_index) * size))); | ||
| 10628 | + } | ||
| 10629 | +} | ||
| 10630 | +inline VV_LOC void builtin__vqsort(voidptr base, usize nmemb, usize size, int (*sort_cb)(const void* const_a, const void* const_b)) { | ||
| 10631 | + if (nmemb < 2 || size == 0) { | ||
| 10632 | + return; | ||
| 10633 | + } | ||
| 10634 | + isize total_size = ((isize)(nmemb * size)); | ||
| 10635 | + u8* buffer = builtin___v_malloc(total_size); | ||
| 10636 | + voidptr source = base; | ||
| 10637 | + voidptr dest = ((voidptr)(buffer)); | ||
| 10638 | + usize width = ((usize)(1)); | ||
| 10639 | + for (;;) { | ||
| 10640 | + if (!(width < nmemb)) break; | ||
| 10641 | + usize left = ((usize)(0)); | ||
| 10642 | + for (;;) { | ||
| 10643 | + if (!(left < nmemb)) break; | ||
| 10644 | + usize mid = (left + width < nmemb ? (left + width) : (nmemb)); | ||
| 10645 | + usize right = (left + width + width < nmemb ? (left + width + width) : (nmemb)); | ||
| 10646 | + builtin__vstable_sort_merge(source, dest, left, mid, right, size, sort_cb); | ||
| 10647 | + left += width + width; | ||
| 10648 | + } | ||
| 10649 | + voidptr tmp = source; | ||
| 10650 | + source = dest; | ||
| 10651 | + dest = tmp; | ||
| 10652 | + width += width; | ||
| 10653 | + } | ||
| 10654 | + if (source != base) { | ||
| 10655 | + builtin__vmemcpy(base, source, total_size); | ||
| 10656 | + } | ||
| 10657 | + { // defer begin | ||
| 10658 | + builtin___v_free(buffer); | ||
| 10659 | + } // defer end | ||
| 10660 | +} | ||
| 10661 | +void builtin__chan_close(chan ch, Array_IError err) { | ||
| 10662 | +} | ||
| 10663 | +ChanState builtin__chan_try_pop(chan ch, voidptr obj) { | ||
| 10664 | + return ChanState__success; | ||
| 10665 | +} | ||
| 10666 | +ChanState builtin__chan_try_push(chan ch, voidptr obj) { | ||
| 10667 | + return ChanState__success; | ||
| 10668 | +} | ||
| 10669 | +VV_LOC void builtin___result_ok(voidptr data, _result* res, int size) { | ||
| 10670 | + { // Unsafe block | ||
| 10671 | + *res = ((_result){.is_error = 0,.err = _const_none__,}); | ||
| 10672 | + builtin__vmemcpy(((u8*)(&res->err)) + sizeof(IError), data, size); | ||
| 10673 | + } | ||
| 10674 | +} | ||
| 10675 | +VV_LOC void builtin___result_clone(_result* current, _result* res, int size) { | ||
| 10676 | + { // Unsafe block | ||
| 10677 | + *res = ((_result){.is_error = current->is_error,.err = current->err,}); | ||
| 10678 | + builtin__vmemcpy(((u8*)(&res->err)) + sizeof(IError), ((u8*)(¤t->err)) + sizeof(IError), size); | ||
| 10679 | + } | ||
| 10680 | +} | ||
| 10681 | +string builtin__IError_str(IError err) { | ||
| 10682 | + if ((err)._typ == _IError_None___index) { | ||
| 10683 | + return _S("none"); | ||
| 10684 | + } | ||
| 10685 | + int c = ((struct _IError_interface_methods*)(err._methods))->_method_code(err._object); | ||
| 10686 | + if (c > 0) { | ||
| 10687 | + return builtin__string_plus_many(3, _MOV((string[3]){((struct _IError_interface_methods*)(err._methods))->_method_msg(err._object), _S("; code: "), builtin__int_str(c)})); | ||
| 10688 | + } | ||
| 10689 | + return ((struct _IError_interface_methods*)(err._methods))->_method_msg(err._object); | ||
| 10690 | +} | ||
| 10691 | +string builtin__Error_msg(Error err) { | ||
| 10692 | + return _S(""); | ||
| 10693 | +} | ||
| 10694 | +int builtin__Error_code(Error err) { | ||
| 10695 | + return 0; | ||
| 10696 | +} | ||
| 10697 | +string builtin__MessageError_str(MessageError err) { | ||
| 10698 | + if (err.code > 0) { | ||
| 10699 | + return builtin__string_plus_many(3, _MOV((string[3]){err.msg, _S("; code: "), builtin__int_str(err.code)})); | ||
| 10700 | + } | ||
| 10701 | + return err.msg; | ||
| 10702 | +} | ||
| 10703 | +string builtin__MessageError_msg(MessageError err) { | ||
| 10704 | + return err.msg; | ||
| 10705 | +} | ||
| 10706 | +int builtin__MessageError_code(MessageError err) { | ||
| 10707 | + return err.code; | ||
| 10708 | +} | ||
| 10709 | +void builtin__MessageError_free(MessageError* err) { | ||
| 10710 | + builtin__string_free(&err->msg); | ||
| 10711 | +} | ||
| 10712 | +inline IError builtin___v_error(string message) { | ||
| 10713 | + ; | ||
| 10714 | + return I_MessageError_to_Interface_IError((HEAP(MessageError, ((MessageError){.msg = message,.code = 0,})))); | ||
| 10715 | +} | ||
| 10716 | +inline IError builtin__error_with_code(string message, int code) { | ||
| 10717 | + ; | ||
| 10718 | + MessageError* _t2 = (MessageError*)builtin___v_malloc(sizeof(MessageError) == 0 ? 1 : sizeof(MessageError)); | ||
| 10719 | + _t2->msg = message; | ||
| 10720 | + _t2->code = code; | ||
| 10721 | + return I_MessageError_to_Interface_IError( _t2); | ||
| 10722 | +} | ||
| 10723 | +VV_LOC void builtin___option_none(voidptr data, _option* option, int size) { | ||
| 10724 | + { // Unsafe block | ||
| 10725 | + *option = ((_option){.state = 2,.err = _const_none__,}); | ||
| 10726 | + builtin__vmemcpy(((u8*)(&option->err)) + sizeof(IError), data, size); | ||
| 10727 | + } | ||
| 10728 | +} | ||
| 10729 | +VV_LOC void builtin___option_ok(voidptr data, _option* option, int size) { | ||
| 10730 | + { // Unsafe block | ||
| 10731 | + *option = ((_option){.state = 0,.err = _const_none__,}); | ||
| 10732 | + builtin__vmemcpy(((u8*)(&option->err)) + sizeof(IError), data, size); | ||
| 10733 | + } | ||
| 10734 | +} | ||
| 10735 | +VV_LOC void builtin___option_clone(_option* current, _option* option, int size) { | ||
| 10736 | + { // Unsafe block | ||
| 10737 | + *option = ((_option){.state = current->state,.err = current->err,}); | ||
| 10738 | + builtin__vmemcpy(((u8*)(&option->err)) + sizeof(IError), ((u8*)(¤t->err)) + sizeof(IError), size); | ||
| 10739 | + } | ||
| 10740 | +} | ||
| 10741 | +VV_LOC void builtin___result_ok_markused(void) { | ||
| 10742 | + _result _t1 = ((_result){.is_error = 0,.err = _const_none__,}); | ||
| 10743 | + _result res = _t1; | ||
| 10744 | + builtin___result_ok(((void*)0), (voidptr)&res, 0); | ||
| 10745 | +} | ||
| 10746 | +VV_LOC string builtin__None___str(None__ _d1) { | ||
| 10747 | + return _S("none"); | ||
| 10748 | +} | ||
| 10749 | +string builtin__none_str(none _d1) { | ||
| 10750 | + return _S("none"); | ||
| 10751 | +} | ||
| 10752 | +int builtin__input_character(void) { | ||
| 10753 | + int ch = 0; | ||
| 10754 | + #if 0 | ||
| 10755 | + { | ||
| 10756 | + } | ||
| 10757 | + #elif 0 | ||
| 10758 | + { | ||
| 10759 | + } | ||
| 10760 | + #else | ||
| 10761 | + { | ||
| 10762 | + ch = getchar(); | ||
| 10763 | + if (ch == EOF) { | ||
| 10764 | + return -1; | ||
| 10765 | + } | ||
| 10766 | + } | ||
| 10767 | + #endif | ||
| 10768 | + return ch; | ||
| 10769 | +} | ||
| 10770 | +int builtin__print_character(u8 ch) { | ||
| 10771 | + #if 0 | ||
| 10772 | + { | ||
| 10773 | + } | ||
| 10774 | + #elif 0 | ||
| 10775 | + { | ||
| 10776 | + } | ||
| 10777 | + #elif 0 | ||
| 10778 | + { | ||
| 10779 | + } | ||
| 10780 | + #else | ||
| 10781 | + { | ||
| 10782 | + i32 x = putchar(ch); | ||
| 10783 | + if (x == EOF) { | ||
| 10784 | + return -1; | ||
| 10785 | + } | ||
| 10786 | + } | ||
| 10787 | + #endif | ||
| 10788 | + return ch; | ||
| 10789 | +} | ||
| 10790 | +#if !defined(CUSTOM_DEFINE_nofloat) | ||
| 10791 | +#endif | ||
| 10792 | +inline string builtin__f64_str(f64 x) { | ||
| 10793 | + { // Unsafe block | ||
| 10794 | + strconv__Float64u _t1 = ((strconv__Float64u){.f = x,}); | ||
| 10795 | + strconv__Float64u f = _t1; | ||
| 10796 | + if (f.u == _const_strconv__double_minus_zero) { | ||
| 10797 | + return _S("-0.0"); | ||
| 10798 | + } | ||
| 10799 | + if (f.u == _const_strconv__double_plus_zero) { | ||
| 10800 | + return _S("0.0"); | ||
| 10801 | + } | ||
| 10802 | + } | ||
| 10803 | + f64 abs_x = builtin__f64_abs(x); | ||
| 10804 | + if (abs_x >= ((f64)(0.0001)) && abs_x < ((f64)(1.0e6))) { | ||
| 10805 | + return strconv__f64_to_str_l(x); | ||
| 10806 | + } else { | ||
| 10807 | + return strconv__ftoa_64(x); | ||
| 10808 | + } | ||
| 10809 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 10810 | +} | ||
| 10811 | +inline string builtin__f64_strg(f64 x) { | ||
| 10812 | + { // Unsafe block | ||
| 10813 | + strconv__Float64u _t1 = ((strconv__Float64u){.f = x,}); | ||
| 10814 | + strconv__Float64u f = _t1; | ||
| 10815 | + if (f.u == _const_strconv__double_minus_zero || f.u == _const_strconv__double_plus_zero) { | ||
| 10816 | + return _S("0.0"); | ||
| 10817 | + } | ||
| 10818 | + } | ||
| 10819 | + f64 abs_x = builtin__f64_abs(x); | ||
| 10820 | + if (abs_x >= ((f64)(0.0001)) && abs_x < ((f64)(1.0e6))) { | ||
| 10821 | + return strconv__f64_to_str_l_with_dot(x); | ||
| 10822 | + } else { | ||
| 10823 | + return strconv__ftoa_64(x); | ||
| 10824 | + } | ||
| 10825 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 10826 | +} | ||
| 10827 | +inline string builtin__float_literal_str(float_literal d) { | ||
| 10828 | + return builtin__f64_str(((f64)(d))); | ||
| 10829 | +} | ||
| 10830 | +inline string builtin__f64_strsci(f64 x, int digit_num) { | ||
| 10831 | + int n_digit = digit_num; | ||
| 10832 | + if (n_digit < 1) { | ||
| 10833 | + n_digit = 1; | ||
| 10834 | + } else if (n_digit > 17) { | ||
| 10835 | + n_digit = 17; | ||
| 10836 | + } | ||
| 10837 | + return strconv__f64_to_str(x, n_digit); | ||
| 10838 | +} | ||
| 10839 | +inline string builtin__f64_strlong(f64 x) { | ||
| 10840 | + return strconv__f64_to_str_l(x); | ||
| 10841 | +} | ||
| 10842 | +inline string builtin__f32_str(f32 x) { | ||
| 10843 | + { // Unsafe block | ||
| 10844 | + strconv__Float32u _t1 = ((strconv__Float32u){.f = x,}); | ||
| 10845 | + strconv__Float32u f = _t1; | ||
| 10846 | + if (f.u == _const_strconv__single_minus_zero) { | ||
| 10847 | + return _S("-0.0"); | ||
| 10848 | + } | ||
| 10849 | + if (f.u == _const_strconv__single_plus_zero) { | ||
| 10850 | + return _S("0.0"); | ||
| 10851 | + } | ||
| 10852 | + } | ||
| 10853 | + f32 abs_x = builtin__f32_abs(x); | ||
| 10854 | + if (abs_x >= ((f32)(0.0001)) && abs_x < ((f32)(1.0e6))) { | ||
| 10855 | + return strconv__f32_to_str_l(x); | ||
| 10856 | + } else { | ||
| 10857 | + return strconv__ftoa_32(x); | ||
| 10858 | + } | ||
| 10859 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 10860 | +} | ||
| 10861 | +inline string builtin__f32_strg(f32 x) { | ||
| 10862 | + { // Unsafe block | ||
| 10863 | + strconv__Float32u _t1 = ((strconv__Float32u){.f = x,}); | ||
| 10864 | + strconv__Float32u f = _t1; | ||
| 10865 | + if (f.u == _const_strconv__single_minus_zero || f.u == _const_strconv__single_plus_zero) { | ||
| 10866 | + return _S("0.0"); | ||
| 10867 | + } | ||
| 10868 | + } | ||
| 10869 | + f32 abs_x = builtin__f32_abs(x); | ||
| 10870 | + if (abs_x >= ((f32)(0.0001)) && abs_x < ((f32)(1.0e6))) { | ||
| 10871 | + return strconv__f32_to_str_l_with_dot(x); | ||
| 10872 | + } else { | ||
| 10873 | + return strconv__ftoa_32(x); | ||
| 10874 | + } | ||
| 10875 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 10876 | +} | ||
| 10877 | +inline string builtin__f32_strsci(f32 x, int digit_num) { | ||
| 10878 | + int n_digit = digit_num; | ||
| 10879 | + if (n_digit < 1) { | ||
| 10880 | + n_digit = 1; | ||
| 10881 | + } else if (n_digit > 8) { | ||
| 10882 | + n_digit = 8; | ||
| 10883 | + } | ||
| 10884 | + return strconv__f32_to_str(x, n_digit); | ||
| 10885 | +} | ||
| 10886 | +inline string builtin__f32_strlong(f32 x) { | ||
| 10887 | + return strconv__f32_to_str_l(x); | ||
| 10888 | +} | ||
| 10889 | +inline f32 builtin__f32_abs(f32 a) { | ||
| 10890 | + if (a < 0) { | ||
| 10891 | + return -a; | ||
| 10892 | + } | ||
| 10893 | + return a; | ||
| 10894 | +} | ||
| 10895 | +inline f64 builtin__f64_abs(f64 a) { | ||
| 10896 | + if (a < 0) { | ||
| 10897 | + return -a; | ||
| 10898 | + } | ||
| 10899 | + return a; | ||
| 10900 | +} | ||
| 10901 | +inline f32 builtin__f32_min(f32 a, f32 b) { | ||
| 10902 | + if (a < b) { | ||
| 10903 | + return a; | ||
| 10904 | + } | ||
| 10905 | + return b; | ||
| 10906 | +} | ||
| 10907 | +inline f32 builtin__f32_max(f32 a, f32 b) { | ||
| 10908 | + if (a > b) { | ||
| 10909 | + return a; | ||
| 10910 | + } | ||
| 10911 | + return b; | ||
| 10912 | +} | ||
| 10913 | +inline f64 builtin__f64_min(f64 a, f64 b) { | ||
| 10914 | + if (a < b) { | ||
| 10915 | + return a; | ||
| 10916 | + } | ||
| 10917 | + return b; | ||
| 10918 | +} | ||
| 10919 | +inline f64 builtin__f64_max(f64 a, f64 b) { | ||
| 10920 | + if (a > b) { | ||
| 10921 | + return a; | ||
| 10922 | + } | ||
| 10923 | + return b; | ||
| 10924 | +} | ||
| 10925 | +inline bool builtin__f32_eq_epsilon(f32 a, f32 b) { | ||
| 10926 | + f32 hi = builtin__f32_max(builtin__f32_abs(a), builtin__f32_abs(b)); | ||
| 10927 | + f32 delta = builtin__f32_abs(a - b); | ||
| 10928 | + if (hi > ((f32)(1.0))) { | ||
| 10929 | + return delta <= hi * (4 * ((f32)(FLT_EPSILON))); | ||
| 10930 | + } else { | ||
| 10931 | + return (1 / (4 * ((f32)(FLT_EPSILON)))) * delta <= hi; | ||
| 10932 | + } | ||
| 10933 | + return 0; | ||
| 10934 | +} | ||
| 10935 | +inline bool builtin__f64_eq_epsilon(f64 a, f64 b) { | ||
| 10936 | + f64 hi = builtin__f64_max(builtin__f64_abs(a), builtin__f64_abs(b)); | ||
| 10937 | + f64 delta = builtin__f64_abs(a - b); | ||
| 10938 | + if (hi > ((f64)(1.0))) { | ||
| 10939 | + return delta <= hi * (4 * ((f64)(DBL_EPSILON))); | ||
| 10940 | + } else { | ||
| 10941 | + return (1 / (4 * ((f64)(DBL_EPSILON)))) * delta <= hi; | ||
| 10942 | + } | ||
| 10943 | + return 0; | ||
| 10944 | +} | ||
| 10945 | +inline VV_LOC u32 builtin__grapheme_hex_nibble(u8 c) { | ||
| 10946 | + return (c <= '9' ? (((u32)((rune)(c - '0')))) : (((u32)((rune)(((c | 0x20)) - 'a') + 10)))); | ||
| 10947 | +} | ||
| 10948 | +inline VV_LOC u32 builtin__grapheme_hex_byte(string ranges, int i) { | ||
| 10949 | + return ((v__lshift_u32(builtin__grapheme_hex_nibble(builtin__string_at(ranges, i)), (u64)4)) | builtin__grapheme_hex_nibble(builtin__string_at(ranges, i + 1))); | ||
| 10950 | +} | ||
| 10951 | +inline VV_LOC u32 builtin__grapheme_range_value(string ranges, int value_idx) { | ||
| 10952 | + int i = value_idx * 8; | ||
| 10953 | + u32 b0 = builtin__grapheme_hex_byte(ranges, i); | ||
| 10954 | + u32 b1 = builtin__grapheme_hex_byte(ranges, i + 2); | ||
| 10955 | + u32 b2 = builtin__grapheme_hex_byte(ranges, i + 4); | ||
| 10956 | + u32 b3 = builtin__grapheme_hex_byte(ranges, i + 6); | ||
| 10957 | + return (((b0 | (v__lshift_u32(b1, (u64)8))) | (v__lshift_u32(b2, (u64)16))) | (v__lshift_u32(b3, (u64)24))); | ||
| 10958 | +} | ||
| 10959 | +inline VV_LOC bool builtin__in_grapheme_ranges(rune r, string ranges) { | ||
| 10960 | + u32 target = ((u32)(r)); | ||
| 10961 | + int low = 0; | ||
| 10962 | + int high = VSAFE_DIV_int(ranges.len , 16); | ||
| 10963 | + for (;;) { | ||
| 10964 | + if (!(low < high)) break; | ||
| 10965 | + int mid = low + VSAFE_DIV_int((high - low) , 2); | ||
| 10966 | + u32 lo = builtin__grapheme_range_value(ranges, mid * 2); | ||
| 10967 | + u32 hi = builtin__grapheme_range_value(ranges, mid * 2 + 1); | ||
| 10968 | + if (target < lo) { | ||
| 10969 | + high = mid; | ||
| 10970 | + } else if (target > hi) { | ||
| 10971 | + low = mid + 1; | ||
| 10972 | + } else { | ||
| 10973 | + return true; | ||
| 10974 | + } | ||
| 10975 | + } | ||
| 10976 | + return false; | ||
| 10977 | +} | ||
| 10978 | +inline VV_LOC GraphemeBreakProperty builtin__grapheme_break_property(rune r) { | ||
| 10979 | + if (r == '\r') { | ||
| 10980 | + return GraphemeBreakProperty__cr; | ||
| 10981 | + } | ||
| 10982 | + if (r == '\n') { | ||
| 10983 | + return GraphemeBreakProperty__lf; | ||
| 10984 | + } | ||
| 10985 | + if (r == 0x200d) { | ||
| 10986 | + return GraphemeBreakProperty__zwj; | ||
| 10987 | + } | ||
| 10988 | + if (r >= 0x1f1e6 && r <= 0x1f1ff) { | ||
| 10989 | + return GraphemeBreakProperty__regional_indicator; | ||
| 10990 | + } | ||
| 10991 | + if (r >= 0xac00 && r <= 0xd7a3) { | ||
| 10992 | + return (VSAFE_MOD_u32((((u32)(r)) - 0xac00) , 28) == 0 ? (GraphemeBreakProperty__lv) : (GraphemeBreakProperty__lvt)); | ||
| 10993 | + } | ||
| 10994 | + if ((r >= 0x1100 && r <= 0x115f) || (r >= 0xa960 && r <= 0xa97c)) { | ||
| 10995 | + return GraphemeBreakProperty__l; | ||
| 10996 | + } | ||
| 10997 | + if ((r >= 0x1160 && r <= 0x11a7) || (r >= 0xd7b0 && r <= 0xd7c6)) { | ||
| 10998 | + return GraphemeBreakProperty__v; | ||
| 10999 | + } | ||
| 11000 | + if ((r >= 0x11a8 && r <= 0x11ff) || (r >= 0xd7cb && r <= 0xd7fb)) { | ||
| 11001 | + return GraphemeBreakProperty__t; | ||
| 11002 | + } | ||
| 11003 | + if (builtin__in_grapheme_ranges(r, _const_grapheme_control_ranges)) { | ||
| 11004 | + return GraphemeBreakProperty__control; | ||
| 11005 | + } | ||
| 11006 | + if (builtin__in_grapheme_ranges(r, _const_grapheme_extend_ranges)) { | ||
| 11007 | + return GraphemeBreakProperty__extend; | ||
| 11008 | + } | ||
| 11009 | + if (builtin__in_grapheme_ranges(r, _const_grapheme_spacing_mark_ranges)) { | ||
| 11010 | + return GraphemeBreakProperty__spacing_mark; | ||
| 11011 | + } | ||
| 11012 | + if (builtin__in_grapheme_ranges(r, _const_grapheme_prepend_ranges)) { | ||
| 11013 | + return GraphemeBreakProperty__prepend; | ||
| 11014 | + } | ||
| 11015 | + return GraphemeBreakProperty__other; | ||
| 11016 | +} | ||
| 11017 | +inline VV_LOC bool builtin__is_extended_pictographic(rune r) { | ||
| 11018 | + return builtin__in_grapheme_ranges(r, _const_grapheme_extended_pictographic_ranges); | ||
| 11019 | +} | ||
| 11020 | +inline VV_LOC GraphemeState builtin__grapheme_state_from_rune(rune r, GraphemeBreakProperty prop) { | ||
| 11021 | + return ((GraphemeState){.prev_prop = prop,.ri_count = (prop == GraphemeBreakProperty__regional_indicator ? (1) : (0)),.extended_pictographic_state = (builtin__is_extended_pictographic(r) ? (((u8)(1))) : (((u8)(0)))),}); | ||
| 11022 | +} | ||
| 11023 | +inline VV_LOC void builtin__GraphemeState_push(GraphemeState* gs, rune r, GraphemeBreakProperty prop) { | ||
| 11024 | + gs->prev_prop = prop; | ||
| 11025 | + gs->ri_count = (prop == GraphemeBreakProperty__regional_indicator ? (gs->ri_count + 1) : (0)); | ||
| 11026 | + if (builtin__is_extended_pictographic(r)) { | ||
| 11027 | + gs->extended_pictographic_state = 1; | ||
| 11028 | + } else if (prop == GraphemeBreakProperty__extend && gs->extended_pictographic_state == 1) { | ||
| 11029 | + } else if (prop == GraphemeBreakProperty__zwj && gs->extended_pictographic_state == 1) { | ||
| 11030 | + gs->extended_pictographic_state = 2; | ||
| 11031 | + } else { | ||
| 11032 | + gs->extended_pictographic_state = 0; | ||
| 11033 | + } | ||
| 11034 | +} | ||
| 11035 | +inline VV_LOC bool builtin__should_break_grapheme(GraphemeState gs, rune r, GraphemeBreakProperty prop) { | ||
| 11036 | + switch (gs.prev_prop) { | ||
| 11037 | + case GraphemeBreakProperty__cr: { | ||
| 11038 | + if (prop == GraphemeBreakProperty__lf) { | ||
| 11039 | + return false; | ||
| 11040 | + } | ||
| 11041 | + return true; | ||
| 11042 | + } | ||
| 11043 | + case GraphemeBreakProperty__lf: case GraphemeBreakProperty__control: { | ||
| 11044 | + return true; | ||
| 11045 | + } | ||
| 11046 | + case GraphemeBreakProperty__l: { | ||
| 11047 | + if (prop == GraphemeBreakProperty__l || prop == GraphemeBreakProperty__v || prop == GraphemeBreakProperty__lv || prop == GraphemeBreakProperty__lvt) { | ||
| 11048 | + return false; | ||
| 11049 | + } | ||
| 11050 | + break; | ||
| 11051 | + } | ||
| 11052 | + case GraphemeBreakProperty__lv: case GraphemeBreakProperty__v: { | ||
| 11053 | + if (prop == GraphemeBreakProperty__v || prop == GraphemeBreakProperty__t) { | ||
| 11054 | + return false; | ||
| 11055 | + } | ||
| 11056 | + break; | ||
| 11057 | + } | ||
| 11058 | + case GraphemeBreakProperty__lvt: case GraphemeBreakProperty__t: { | ||
| 11059 | + if (prop == GraphemeBreakProperty__t) { | ||
| 11060 | + return false; | ||
| 11061 | + } | ||
| 11062 | + break; | ||
| 11063 | + } | ||
| 11064 | + case GraphemeBreakProperty__prepend: { | ||
| 11065 | + return false; | ||
| 11066 | + } | ||
| 11067 | + case GraphemeBreakProperty__regional_indicator: { | ||
| 11068 | + if (prop == GraphemeBreakProperty__regional_indicator && VSAFE_MOD_int(gs.ri_count , 2) == 1) { | ||
| 11069 | + return false; | ||
| 11070 | + } | ||
| 11071 | + break; | ||
| 11072 | + } | ||
| 11073 | + case GraphemeBreakProperty__other: | ||
| 11074 | + case GraphemeBreakProperty__extend: | ||
| 11075 | + case GraphemeBreakProperty__spacing_mark: | ||
| 11076 | + case GraphemeBreakProperty__zwj: | ||
| 11077 | + default: { | ||
| 11078 | + { | ||
| 11079 | + break; | ||
| 11080 | + } | ||
| 11081 | + } | ||
| 11082 | + } | ||
| 11083 | + | ||
| 11084 | + if (prop == GraphemeBreakProperty__cr || prop == GraphemeBreakProperty__lf || prop == GraphemeBreakProperty__control) { | ||
| 11085 | + return true; | ||
| 11086 | + } | ||
| 11087 | + if (prop == GraphemeBreakProperty__extend || prop == GraphemeBreakProperty__zwj || prop == GraphemeBreakProperty__spacing_mark) { | ||
| 11088 | + return false; | ||
| 11089 | + } | ||
| 11090 | + if (gs.extended_pictographic_state == 2 && builtin__is_extended_pictographic(r)) { | ||
| 11091 | + return false; | ||
| 11092 | + } | ||
| 11093 | + return true; | ||
| 11094 | +} | ||
| 11095 | +inline VV_LOC int builtin__utf8_rune_visible_width(rune r, GraphemeBreakProperty prop) { | ||
| 11096 | + if (prop == GraphemeBreakProperty__extend || prop == GraphemeBreakProperty__zwj || prop == GraphemeBreakProperty__spacing_mark || prop == GraphemeBreakProperty__prepend) { | ||
| 11097 | + return 0; | ||
| 11098 | + } | ||
| 11099 | + if (r >= 0x1100 && (r <= 0x115f || r == 0x2329 || r == 0x232a || (r >= 0x2e80 && r <= 0xa4cf && r != 0x303f) || (r >= 0xac00 && r <= 0xd7a3) || (r >= 0xf900 && r <= 0xfaff) || (r >= 0xfe10 && r <= 0xfe19) || (r >= 0xfe30 && r <= 0xfe6f) || (r >= 0xff00 && r <= 0xff60) || (r >= 0xffe0 && r <= 0xffe6) || (r >= 0x1f300 && r <= 0x1f64f) || (r >= 0x1f680 && r <= 0x1f6ff) || (r >= 0x1f900 && r <= 0x1f9ff) || (r >= 0x1fa70 && r <= 0x1faff) || (r >= 0x20000 && r <= 0x3fffd))) { | ||
| 11100 | + return 2; | ||
| 11101 | + } | ||
| 11102 | + return 1; | ||
| 11103 | +} | ||
| 11104 | +VV_LOC Array_string builtin__string_graphemes_impl(string s) { | ||
| 11105 | + Array_rune runes = builtin__string_runes(s); | ||
| 11106 | + if (runes.len == 0) { | ||
| 11107 | + return builtin____new_array_with_default(0, 0, sizeof(string), 0); | ||
| 11108 | + } | ||
| 11109 | + Array_string res = builtin____new_array_with_default(0, runes.len, sizeof(string), 0); | ||
| 11110 | + Array_rune cluster = builtin____new_array_with_default(0, 4, sizeof(rune), 0); | ||
| 11111 | + GraphemeBreakProperty first_prop = builtin__grapheme_break_property((*(rune*)builtin__array_get(runes, 0))); | ||
| 11112 | + GraphemeState state = builtin__grapheme_state_from_rune((*(rune*)builtin__array_get(runes, 0)), first_prop); | ||
| 11113 | + builtin__array_push((array*)&cluster, _MOV((rune[]){ (*(rune*)builtin__array_get(runes, 0)) })); | ||
| 11114 | + Array_rune _t3 = builtin__array_slice(runes, 1, 2147483647); | ||
| 11115 | + for (int _t4 = 0; _t4 < _t3.len; ++_t4) { | ||
| 11116 | + rune r = ((rune*)_t3.data)[_t4]; | ||
| 11117 | + GraphemeBreakProperty prop = builtin__grapheme_break_property(r); | ||
| 11118 | + if (builtin__should_break_grapheme(state, r, prop)) { | ||
| 11119 | + builtin__array_push((array*)&res, _MOV((string[]){ Array_rune_string(cluster) })); | ||
| 11120 | + cluster = builtin____new_array_with_default(0, 4, sizeof(rune), 0); | ||
| 11121 | + builtin__array_push((array*)&cluster, _MOV((rune[]){ r })); | ||
| 11122 | + state = builtin__grapheme_state_from_rune(r, prop); | ||
| 11123 | + continue; | ||
| 11124 | + } | ||
| 11125 | + builtin__array_push((array*)&cluster, _MOV((rune[]){ r })); | ||
| 11126 | + builtin__GraphemeState_push(&state, r, prop); | ||
| 11127 | + } | ||
| 11128 | + builtin__array_push((array*)&res, _MOV((string[]){ Array_rune_string(cluster) })); | ||
| 11129 | + return res; | ||
| 11130 | +} | ||
| 11131 | +inline VV_LOC int builtin__utf8_grapheme_visible_length(string s) { | ||
| 11132 | + Array_rune runes = builtin__string_runes(s); | ||
| 11133 | + if (runes.len == 0) { | ||
| 11134 | + return 0; | ||
| 11135 | + } | ||
| 11136 | + GraphemeBreakProperty first_prop = builtin__grapheme_break_property((*(rune*)builtin__array_get(runes, 0))); | ||
| 11137 | + GraphemeState state = builtin__grapheme_state_from_rune((*(rune*)builtin__array_get(runes, 0)), first_prop); | ||
| 11138 | + int total = 0; | ||
| 11139 | + int cluster_width = builtin__utf8_rune_visible_width((*(rune*)builtin__array_get(runes, 0)), first_prop); | ||
| 11140 | + Array_rune _t2 = builtin__array_slice(runes, 1, 2147483647); | ||
| 11141 | + for (int _t3 = 0; _t3 < _t2.len; ++_t3) { | ||
| 11142 | + rune r = ((rune*)_t2.data)[_t3]; | ||
| 11143 | + GraphemeBreakProperty prop = builtin__grapheme_break_property(r); | ||
| 11144 | + if (builtin__should_break_grapheme(state, r, prop)) { | ||
| 11145 | + total += cluster_width; | ||
| 11146 | + cluster_width = builtin__utf8_rune_visible_width(r, prop); | ||
| 11147 | + state = builtin__grapheme_state_from_rune(r, prop); | ||
| 11148 | + continue; | ||
| 11149 | + } | ||
| 11150 | + int rune_width = builtin__utf8_rune_visible_width(r, prop); | ||
| 11151 | + if (rune_width > cluster_width) { | ||
| 11152 | + cluster_width = rune_width; | ||
| 11153 | + } | ||
| 11154 | + builtin__GraphemeState_push(&state, r, prop); | ||
| 11155 | + } | ||
| 11156 | + return total + cluster_width; | ||
| 11157 | +} | ||
| 11158 | +_option_rune builtin__input_rune(void) { | ||
| 11159 | + int x = builtin__input_character(); | ||
| 11160 | + if (x <= 0) { | ||
| 11161 | + return (_option_rune){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | ||
| 11162 | + } | ||
| 11163 | + int char_len = builtin__utf8_char_len(((u8)(x))); | ||
| 11164 | + if (char_len == 1) { | ||
| 11165 | + _option_rune _t2; | ||
| 11166 | + builtin___option_ok(&(rune[]) { x }, (_option*)(&_t2), sizeof(rune)); | ||
| 11167 | + | ||
| 11168 | + return _t2; | ||
| 11169 | + } | ||
| 11170 | + u8 b = ((u8)(x)); | ||
| 11171 | + b = v__lshift_u8(b, (u64)char_len); | ||
| 11172 | + rune res = ((rune)(b)); | ||
| 11173 | + int shift = 6 - char_len; | ||
| 11174 | + for (int i = 1; i < char_len; i++) { | ||
| 11175 | + rune c = ((rune)(builtin__input_character())); | ||
| 11176 | + res = v__lshift_rune(((rune)(res)), (u64)shift); | ||
| 11177 | + res |= (c & 63); | ||
| 11178 | + shift = 6; | ||
| 11179 | + } | ||
| 11180 | + _option_rune _t3; | ||
| 11181 | + builtin___option_ok(&(rune[]) { res }, (_option*)(&_t3), sizeof(rune)); | ||
| 11182 | + | ||
| 11183 | + return _t3; | ||
| 11184 | +} | ||
| 11185 | +_option_rune builtin__InputRuneIterator_next(InputRuneIterator* self) { | ||
| 11186 | + return builtin__input_rune(); | ||
| 11187 | +} | ||
| 11188 | +InputRuneIterator builtin__input_rune_iterator(void) { | ||
| 11189 | + return ((InputRuneIterator){E_STRUCT}); | ||
| 11190 | +} | ||
| 11191 | +string builtin__ptr_str(voidptr ptr) { | ||
| 11192 | + string buf1 = builtin__u64_to_hex_no_leading_zeros(((u64)(ptr)), 16); | ||
| 11193 | + return buf1; | ||
| 11194 | +} | ||
| 11195 | +string builtin__isize_str(isize x) { | ||
| 11196 | + return builtin__i64_str(((i64)(x))); | ||
| 11197 | +} | ||
| 11198 | +string builtin__usize_str(usize x) { | ||
| 11199 | + return builtin__u64_str(((u64)(x))); | ||
| 11200 | +} | ||
| 11201 | +string builtin__char_str(char* cptr) { | ||
| 11202 | + return builtin__u64_hex(((u64)(cptr))); | ||
| 11203 | +} | ||
| 11204 | +inline VV_LOC string builtin__int_str_l(int nn, int max) { | ||
| 11205 | + { // Unsafe block | ||
| 11206 | + i64 n = ((i64)(nn)); | ||
| 11207 | + int d = 0; | ||
| 11208 | + if (n == 0) { | ||
| 11209 | + return _S("0"); | ||
| 11210 | + } | ||
| 11211 | + #if 0 | ||
| 11212 | + { | ||
| 11213 | + } | ||
| 11214 | + #else | ||
| 11215 | + { | ||
| 11216 | + if (n == _const_min_i32) { | ||
| 11217 | + return _S("-2147483648"); | ||
| 11218 | + } | ||
| 11219 | + } | ||
| 11220 | + #endif | ||
| 11221 | + bool is_neg = false; | ||
| 11222 | + if (n < 0) { | ||
| 11223 | + n = -n; | ||
| 11224 | + is_neg = true; | ||
| 11225 | + } | ||
| 11226 | + int index = max; | ||
| 11227 | + u8* buf = builtin__malloc_noscan(max + 1); | ||
| 11228 | + buf[index] = 0; | ||
| 11229 | + index--; | ||
| 11230 | + for (;;) { | ||
| 11231 | + if (!(n > 0)) break; | ||
| 11232 | + int n1 = ((int)(VSAFE_DIV_i64(n , 100))); | ||
| 11233 | + d = ((int)(v__lshift_u32(((u32)(((int)(n)) - (n1 * 100))), (u64)1))); | ||
| 11234 | + n = n1; | ||
| 11235 | + buf[index] = _const_digit_pairs.str[d]; | ||
| 11236 | + index--; | ||
| 11237 | + d++; | ||
| 11238 | + buf[index] = _const_digit_pairs.str[d]; | ||
| 11239 | + index--; | ||
| 11240 | + } | ||
| 11241 | + index++; | ||
| 11242 | + if (d < 20) { | ||
| 11243 | + index++; | ||
| 11244 | + } | ||
| 11245 | + if (is_neg) { | ||
| 11246 | + index--; | ||
| 11247 | + buf[index] = '-'; | ||
| 11248 | + } | ||
| 11249 | + int diff = max - index; | ||
| 11250 | + builtin__vmemmove(buf, ((voidptr)(buf + index)), diff + 1); | ||
| 11251 | + return builtin__tos(buf, diff); | ||
| 11252 | + } | ||
| 11253 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 11254 | +} | ||
| 11255 | +string builtin__i8_str(i8 n) { | ||
| 11256 | + return builtin__int_str_l(((int)(n)), 4); | ||
| 11257 | +} | ||
| 11258 | +string builtin__i16_str(i16 n) { | ||
| 11259 | + return builtin__int_str_l(((int)(n)), 6); | ||
| 11260 | +} | ||
| 11261 | +string builtin__u16_str(u16 n) { | ||
| 11262 | + return builtin__int_str_l(((int)(n)), 6); | ||
| 11263 | +} | ||
| 11264 | +string builtin__i32_str(i32 n) { | ||
| 11265 | + return builtin__int_str_l(((int)(n)), 11); | ||
| 11266 | +} | ||
| 11267 | +string builtin__int_hex_full(int nn) { | ||
| 11268 | + return builtin__u64_to_hex(((u64)(nn)), 8); | ||
| 11269 | +} | ||
| 11270 | +string builtin__int_str(int n) { | ||
| 11271 | + #if defined(CUSTOM_DEFINE_new_int) | ||
| 11272 | + { | ||
| 11273 | + } | ||
| 11274 | + #else | ||
| 11275 | + { | ||
| 11276 | + return builtin__int_str_l(n, 11); | ||
| 11277 | + } | ||
| 11278 | + #endif | ||
| 11279 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 11280 | +} | ||
| 11281 | +inline string builtin__u32_str(u32 nn) { | ||
| 11282 | + { // Unsafe block | ||
| 11283 | + u32 n = nn; | ||
| 11284 | + u32 d = ((u32)(0)); | ||
| 11285 | + if (n == 0) { | ||
| 11286 | + return _S("0"); | ||
| 11287 | + } | ||
| 11288 | + int max = 10; | ||
| 11289 | + u8* buf = builtin__malloc_noscan(max + 1); | ||
| 11290 | + int index = max; | ||
| 11291 | + buf[index] = 0; | ||
| 11292 | + index--; | ||
| 11293 | + for (;;) { | ||
| 11294 | + if (!(n > 0)) break; | ||
| 11295 | + u32 n1 = VSAFE_DIV_u32(n , ((u32)(100))); | ||
| 11296 | + d = (v__lshift_u32((n - (n1 * ((u32)(100)))), (u64)((u32)(1)))); | ||
| 11297 | + n = n1; | ||
| 11298 | + buf[index] = _const_digit_pairs.str[ ((int)(d))]; | ||
| 11299 | + index--; | ||
| 11300 | + d++; | ||
| 11301 | + buf[index] = _const_digit_pairs.str[ ((int)(d))]; | ||
| 11302 | + index--; | ||
| 11303 | + } | ||
| 11304 | + index++; | ||
| 11305 | + if (d < ((u32)(20))) { | ||
| 11306 | + index++; | ||
| 11307 | + } | ||
| 11308 | + int diff = max - index; | ||
| 11309 | + builtin__vmemmove(buf, ((voidptr)(buf + index)), diff + 1); | ||
| 11310 | + return builtin__tos(buf, diff); | ||
| 11311 | + } | ||
| 11312 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 11313 | +} | ||
| 11314 | +inline string builtin__int_literal_str(int_literal n) { | ||
| 11315 | + return builtin__impl_i64_to_string(n); | ||
| 11316 | +} | ||
| 11317 | +inline string builtin__i64_str(i64 nn) { | ||
| 11318 | + return builtin__impl_i64_to_string(nn); | ||
| 11319 | +} | ||
| 11320 | +VV_LOC string builtin__impl_i64_to_string(i64 nn) { | ||
| 11321 | + { // Unsafe block | ||
| 11322 | + i64 n = nn; | ||
| 11323 | + i64 d = ((i64)(0)); | ||
| 11324 | + if (n == 0) { | ||
| 11325 | + return _S("0"); | ||
| 11326 | + } else if (n == _const_min_i64) { | ||
| 11327 | + return _S("-9223372036854775808"); | ||
| 11328 | + } | ||
| 11329 | + int max = 20; | ||
| 11330 | + u8* buf = builtin__malloc_noscan(max + 1); | ||
| 11331 | + bool is_neg = false; | ||
| 11332 | + if (n < 0) { | ||
| 11333 | + n = -n; | ||
| 11334 | + is_neg = true; | ||
| 11335 | + } | ||
| 11336 | + int index = max; | ||
| 11337 | + buf[index] = 0; | ||
| 11338 | + index--; | ||
| 11339 | + for (;;) { | ||
| 11340 | + if (!(n > 0)) break; | ||
| 11341 | + i64 n1 = VSAFE_DIV_i64(n , ((i64)(100))); | ||
| 11342 | + d = (v__lshift_u32(((u32)(n - (n1 * ((i64)(100))))), (u64)((i64)(1)))); | ||
| 11343 | + n = n1; | ||
| 11344 | + buf[index] = _const_digit_pairs.str[ ((int)(d))]; | ||
| 11345 | + index--; | ||
| 11346 | + d++; | ||
| 11347 | + buf[index] = _const_digit_pairs.str[ ((int)(d))]; | ||
| 11348 | + index--; | ||
| 11349 | + } | ||
| 11350 | + index++; | ||
| 11351 | + if (d < ((i64)(20))) { | ||
| 11352 | + index++; | ||
| 11353 | + } | ||
| 11354 | + if (is_neg) { | ||
| 11355 | + index--; | ||
| 11356 | + buf[index] = '-'; | ||
| 11357 | + } | ||
| 11358 | + int diff = max - index; | ||
| 11359 | + builtin__vmemmove(buf, ((voidptr)(buf + index)), diff + 1); | ||
| 11360 | + return builtin__tos(buf, diff); | ||
| 11361 | + } | ||
| 11362 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 11363 | +} | ||
| 11364 | +inline string builtin__u64_str(u64 nn) { | ||
| 11365 | + { // Unsafe block | ||
| 11366 | + u64 n = nn; | ||
| 11367 | + u64 d = ((u64)(0)); | ||
| 11368 | + if (n == 0) { | ||
| 11369 | + return _S("0"); | ||
| 11370 | + } | ||
| 11371 | + int max = 20; | ||
| 11372 | + u8* buf = builtin__malloc_noscan(max + 1); | ||
| 11373 | + int index = max; | ||
| 11374 | + buf[index] = 0; | ||
| 11375 | + index--; | ||
| 11376 | + for (;;) { | ||
| 11377 | + if (!(n > 0)) break; | ||
| 11378 | + u64 n1 = VSAFE_DIV_u64(n , 100); | ||
| 11379 | + d = (v__lshift_u64((n - (n1 * 100)), (u64)1)); | ||
| 11380 | + n = n1; | ||
| 11381 | + buf[index] = _const_digit_pairs.str[ ((int)(d))]; | ||
| 11382 | + index--; | ||
| 11383 | + d++; | ||
| 11384 | + buf[index] = _const_digit_pairs.str[ ((int)(d))]; | ||
| 11385 | + index--; | ||
| 11386 | + } | ||
| 11387 | + index++; | ||
| 11388 | + if (d < 20) { | ||
| 11389 | + index++; | ||
| 11390 | + } | ||
| 11391 | + int diff = max - index; | ||
| 11392 | + builtin__vmemmove(buf, ((voidptr)(buf + index)), diff + 1); | ||
| 11393 | + return builtin__tos(buf, diff); | ||
| 11394 | + } | ||
| 11395 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 11396 | +} | ||
| 11397 | +string builtin__bool_str(bool b) { | ||
| 11398 | + if (b) { | ||
| 11399 | + return _S("true"); | ||
| 11400 | + } | ||
| 11401 | + return _S("false"); | ||
| 11402 | +} | ||
| 11403 | +inline VV_LOC string builtin__u64_to_hex(u64 nn, u8 len) { | ||
| 11404 | + u64 n = nn; | ||
| 11405 | + Array_fixed_u8_17 buf = {0}; | ||
| 11406 | + buf[len] = 0; | ||
| 11407 | + int i = 0; | ||
| 11408 | + for (i = (len - 1); i >= 0; i--) { | ||
| 11409 | + u8 d = ((u8)((n & 0xF))); | ||
| 11410 | + buf[i] = (d < 10 ? ((rune)(d + '0')) : ((u8)(d + 87))); | ||
| 11411 | + n = v__rshift_u64(n, (u64)4); | ||
| 11412 | + } | ||
| 11413 | + return builtin__tos(builtin__memdup(&buf[0], (len + 1)), len); | ||
| 11414 | +} | ||
| 11415 | +inline VV_LOC string builtin__u64_to_hex_no_leading_zeros(u64 nn, u8 len) { | ||
| 11416 | + u64 n = nn; | ||
| 11417 | + Array_fixed_u8_17 buf = {0}; | ||
| 11418 | + buf[len] = 0; | ||
| 11419 | + int i = 0; | ||
| 11420 | + for (i = (len - 1); i >= 0; i--) { | ||
| 11421 | + u8 d = ((u8)((n & 0xF))); | ||
| 11422 | + buf[i] = (d < 10 ? ((rune)(d + '0')) : ((u8)(d + 87))); | ||
| 11423 | + n = v__rshift_u64(n, (u64)4); | ||
| 11424 | + if (n == 0) { | ||
| 11425 | + break; | ||
| 11426 | + } | ||
| 11427 | + } | ||
| 11428 | + int res_len = (int)(len - i); | ||
| 11429 | + return builtin__tos(builtin__memdup(&buf[i], res_len + 1), res_len); | ||
| 11430 | +} | ||
| 11431 | +string builtin__u8_hex(u8 nn) { | ||
| 11432 | + if (nn == 0) { | ||
| 11433 | + return _S("00"); | ||
| 11434 | + } | ||
| 11435 | + return builtin__u64_to_hex(nn, 2); | ||
| 11436 | +} | ||
| 11437 | +string builtin__char_hex(char c) { | ||
| 11438 | + return builtin__u8_hex(((u8)(c))); | ||
| 11439 | +} | ||
| 11440 | +string builtin__rune_hex(rune r) { | ||
| 11441 | + return builtin__u32_hex(((u32)(r))); | ||
| 11442 | +} | ||
| 11443 | +string builtin__i8_hex(i8 nn) { | ||
| 11444 | + if (nn == 0) { | ||
| 11445 | + return _S("00"); | ||
| 11446 | + } | ||
| 11447 | + return builtin__u64_to_hex(((u64)(nn)), 2); | ||
| 11448 | +} | ||
| 11449 | +string builtin__u16_hex(u16 nn) { | ||
| 11450 | + if (nn == 0) { | ||
| 11451 | + return _S("0"); | ||
| 11452 | + } | ||
| 11453 | + return builtin__u64_to_hex_no_leading_zeros(nn, 4); | ||
| 11454 | +} | ||
| 11455 | +string builtin__i16_hex(i16 nn) { | ||
| 11456 | + return builtin__u16_hex(((u16)(nn))); | ||
| 11457 | +} | ||
| 11458 | +string builtin__u32_hex(u32 nn) { | ||
| 11459 | + if (nn == 0) { | ||
| 11460 | + return _S("0"); | ||
| 11461 | + } | ||
| 11462 | + return builtin__u64_to_hex_no_leading_zeros(nn, 8); | ||
| 11463 | +} | ||
| 11464 | +string builtin__int_hex(int nn) { | ||
| 11465 | + return builtin__u32_hex(((u32)(nn))); | ||
| 11466 | +} | ||
| 11467 | +string builtin__int_hex2(int n) { | ||
| 11468 | + return builtin__string__plus(_S("0x"), builtin__int_hex(n)); | ||
| 11469 | +} | ||
| 11470 | +string builtin__u64_hex(u64 nn) { | ||
| 11471 | + if (nn == 0) { | ||
| 11472 | + return _S("0"); | ||
| 11473 | + } | ||
| 11474 | + return builtin__u64_to_hex_no_leading_zeros(nn, 16); | ||
| 11475 | +} | ||
| 11476 | +string builtin__i64_hex(i64 nn) { | ||
| 11477 | + return builtin__u64_hex(((u64)(nn))); | ||
| 11478 | +} | ||
| 11479 | +string builtin__int_literal_hex(int_literal nn) { | ||
| 11480 | + return builtin__u64_hex(((u64)(nn))); | ||
| 11481 | +} | ||
| 11482 | +string builtin__voidptr_str(voidptr nn) { | ||
| 11483 | + return builtin__string__plus(_S("0x"), builtin__u64_hex(((u64)(nn)))); | ||
| 11484 | +} | ||
| 11485 | +string builtin__byteptr_str(byteptr nn) { | ||
| 11486 | + return builtin__string__plus(_S("0x"), builtin__u64_hex(((u64)(nn)))); | ||
| 11487 | +} | ||
| 11488 | +string builtin__charptr_str(charptr nn) { | ||
| 11489 | + return builtin__string__plus(_S("0x"), builtin__u64_hex(((u64)(nn)))); | ||
| 11490 | +} | ||
| 11491 | +string builtin__u8_hex_full(u8 nn) { | ||
| 11492 | + return builtin__u64_to_hex(((u64)(nn)), 2); | ||
| 11493 | +} | ||
| 11494 | +string builtin__i8_hex_full(i8 nn) { | ||
| 11495 | + return builtin__u64_to_hex(((u64)(nn)), 2); | ||
| 11496 | +} | ||
| 11497 | +string builtin__u16_hex_full(u16 nn) { | ||
| 11498 | + return builtin__u64_to_hex(((u64)(nn)), 4); | ||
| 11499 | +} | ||
| 11500 | +string builtin__i16_hex_full(i16 nn) { | ||
| 11501 | + return builtin__u64_to_hex(((u64)(nn)), 4); | ||
| 11502 | +} | ||
| 11503 | +string builtin__u32_hex_full(u32 nn) { | ||
| 11504 | + return builtin__u64_to_hex(((u64)(nn)), 8); | ||
| 11505 | +} | ||
| 11506 | +string builtin__i64_hex_full(i64 nn) { | ||
| 11507 | + return builtin__u64_to_hex(((u64)(nn)), 16); | ||
| 11508 | +} | ||
| 11509 | +string builtin__voidptr_hex_full(voidptr nn) { | ||
| 11510 | + return builtin__u64_to_hex(((u64)(nn)), 16); | ||
| 11511 | +} | ||
| 11512 | +string builtin__int_literal_hex_full(int_literal nn) { | ||
| 11513 | + return builtin__u64_to_hex(((u64)(nn)), 16); | ||
| 11514 | +} | ||
| 11515 | +string builtin__u64_hex_full(u64 nn) { | ||
| 11516 | + return builtin__u64_to_hex(nn, 16); | ||
| 11517 | +} | ||
| 11518 | +string builtin__u8_str(u8 b) { | ||
| 11519 | + return builtin__int_str_l(((int)(b)), 4); | ||
| 11520 | +} | ||
| 11521 | +string builtin__u8_ascii_str(u8 b) { | ||
| 11522 | + string _t1 = ((string){.str = builtin__malloc_noscan(2), .len = 1}); | ||
| 11523 | + string str = _t1; | ||
| 11524 | + { // Unsafe block | ||
| 11525 | + str.str[0] = b; | ||
| 11526 | + str.str[1] = 0; | ||
| 11527 | + } | ||
| 11528 | + return str; | ||
| 11529 | +} | ||
| 11530 | +string builtin__u8_str_escaped(u8 b) { | ||
| 11531 | + string _t1 = (string){.str=(byteptr)"", .is_lit=1}; | ||
| 11532 | + | ||
| 11533 | + if (b == (0)) { | ||
| 11534 | + _t1 = _S("`\\0`"); | ||
| 11535 | + } | ||
| 11536 | + else if (b == (7)) { | ||
| 11537 | + _t1 = _S("`\\a`"); | ||
| 11538 | + } | ||
| 11539 | + else if (b == (8)) { | ||
| 11540 | + _t1 = _S("`\\b`"); | ||
| 11541 | + } | ||
| 11542 | + else if (b == (9)) { | ||
| 11543 | + _t1 = _S("`\\t`"); | ||
| 11544 | + } | ||
| 11545 | + else if (b == (10)) { | ||
| 11546 | + _t1 = _S("`\\n`"); | ||
| 11547 | + } | ||
| 11548 | + else if (b == (11)) { | ||
| 11549 | + _t1 = _S("`\\v`"); | ||
| 11550 | + } | ||
| 11551 | + else if (b == (12)) { | ||
| 11552 | + _t1 = _S("`\\f`"); | ||
| 11553 | + } | ||
| 11554 | + else if (b == (13)) { | ||
| 11555 | + _t1 = _S("`\\r`"); | ||
| 11556 | + } | ||
| 11557 | + else if (b == (27)) { | ||
| 11558 | + _t1 = _S("`\\e`"); | ||
| 11559 | + } | ||
| 11560 | + else if ((b >= 32 && b <= 126)) { | ||
| 11561 | + _t1 = builtin__u8_ascii_str(b); | ||
| 11562 | + } | ||
| 11563 | + else { | ||
| 11564 | + string xx = builtin__u8_hex(b); | ||
| 11565 | + string yy = builtin__string__plus(_S("0x"), xx); | ||
| 11566 | + builtin__string_free(&xx); | ||
| 11567 | + _t1 = yy; | ||
| 11568 | + }string str = _t1; | ||
| 11569 | + return str; | ||
| 11570 | +} | ||
| 11571 | +inline bool builtin__u8_is_capital(u8 c) { | ||
| 11572 | + return c >= 'A' && c <= 'Z'; | ||
| 11573 | +} | ||
| 11574 | +string Array_u8_bytestr(Array_u8 b) { | ||
| 11575 | + { // Unsafe block | ||
| 11576 | + u8* buf = builtin__malloc_noscan(b.len + 1); | ||
| 11577 | + builtin__vmemcpy(buf, b.data, b.len); | ||
| 11578 | + buf[b.len] = 0; | ||
| 11579 | + return builtin__tos(buf, b.len); | ||
| 11580 | + } | ||
| 11581 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 11582 | +} | ||
| 11583 | +_result_rune Array_u8_byterune(Array_u8 b) { | ||
| 11584 | + _result_rune _t1 = Array_u8_utf8_to_utf32(b); | ||
| 11585 | + if (_t1.is_error) { | ||
| 11586 | + _result_rune _t2 = {0}; | ||
| 11587 | + _t2.is_error = true; | ||
| 11588 | + _t2.err = _t1.err; | ||
| 11589 | + return _t2; | ||
| 11590 | + } | ||
| 11591 | + | ||
| 11592 | + rune r = (*(rune*)_t1.data); | ||
| 11593 | + _result_rune _t3; | ||
| 11594 | + builtin___result_ok(&(rune[]) { ((rune)(r)) }, (_result*)(&_t3), sizeof(rune)); | ||
| 11595 | + | ||
| 11596 | + return _t3; | ||
| 11597 | +} | ||
| 11598 | +string builtin__u8_repeat(u8 b, int count) { | ||
| 11599 | + if (count <= 0) { | ||
| 11600 | + return _S(""); | ||
| 11601 | + } else if (count == 1) { | ||
| 11602 | + return builtin__u8_ascii_str(b); | ||
| 11603 | + } | ||
| 11604 | + u8* bytes = builtin__malloc_noscan(count + 1); | ||
| 11605 | + { // Unsafe block | ||
| 11606 | + builtin__vmemset(bytes, b, count); | ||
| 11607 | + bytes[count] = 0; | ||
| 11608 | + } | ||
| 11609 | + return builtin__u8_vstring_with_len(bytes, count); | ||
| 11610 | +} | ||
| 11611 | +inline int builtin__int_min(int a, int b) { | ||
| 11612 | + return (a < b ? (a) : (b)); | ||
| 11613 | +} | ||
| 11614 | +inline int builtin__int_max(int a, int b) { | ||
| 11615 | + return (a > b ? (a) : (b)); | ||
| 11616 | +} | ||
| 11617 | +inline VV_LOC bool builtin__fast_string_eq(string a, string b) { | ||
| 11618 | + if (a.len != b.len) { | ||
| 11619 | + return false; | ||
| 11620 | + } | ||
| 11621 | + { // Unsafe block | ||
| 11622 | + return memcmp(a.str, b.str, b.len) == 0; | ||
| 11623 | + } | ||
| 11624 | + return 0; | ||
| 11625 | +} | ||
| 11626 | +VV_LOC u64 builtin__map_hash_string(voidptr pkey) { | ||
| 11627 | + string key = *((string*)(pkey)); | ||
| 11628 | + return wyhash(key.str, ((u64)(key.len)), 0, ((u64*)(((voidptr)(_wyp))))); | ||
| 11629 | +} | ||
| 11630 | +VV_LOC u64 builtin__map_hash_int_1(voidptr pkey) { | ||
| 11631 | + return wyhash64(*((u8*)(pkey)), 0); | ||
| 11632 | +} | ||
| 11633 | +VV_LOC u64 builtin__map_hash_int_2(voidptr pkey) { | ||
| 11634 | + return wyhash64(*((u16*)(pkey)), 0); | ||
| 11635 | +} | ||
| 11636 | +VV_LOC u64 builtin__map_hash_int_4(voidptr pkey) { | ||
| 11637 | + return wyhash64(*((u32*)(pkey)), 0); | ||
| 11638 | +} | ||
| 11639 | +VV_LOC u64 builtin__map_hash_int_8(voidptr pkey) { | ||
| 11640 | + return wyhash64(*((u64*)(pkey)), 0); | ||
| 11641 | +} | ||
| 11642 | +VV_LOC voidptr builtin__map_enum_fn(int kind, int esize) { | ||
| 11643 | + if (!(kind == 1 || kind == 2 || kind == 3)) { | ||
| 11644 | + builtin___v_panic(_S("map_enum_fn: invalid kind")); | ||
| 11645 | + VUNREACHABLE(); | ||
| 11646 | + } | ||
| 11647 | + if (esize > 8 || esize < 0) { | ||
| 11648 | + builtin___v_panic(_S("map_enum_fn: invalid esize")); | ||
| 11649 | + VUNREACHABLE(); | ||
| 11650 | + } | ||
| 11651 | + if (kind == 1) { | ||
| 11652 | + if (esize > 4) { | ||
| 11653 | + return ((voidptr)(builtin__map_hash_int_8)); | ||
| 11654 | + } | ||
| 11655 | + if (esize > 2) { | ||
| 11656 | + return ((voidptr)(builtin__map_hash_int_4)); | ||
| 11657 | + } | ||
| 11658 | + if (esize > 1) { | ||
| 11659 | + return ((voidptr)(builtin__map_hash_int_2)); | ||
| 11660 | + } | ||
| 11661 | + if (esize > 0) { | ||
| 11662 | + return ((voidptr)(builtin__map_hash_int_1)); | ||
| 11663 | + } | ||
| 11664 | + } | ||
| 11665 | + if (kind == 2) { | ||
| 11666 | + if (esize > 4) { | ||
| 11667 | + return ((voidptr)(builtin__map_eq_int_8)); | ||
| 11668 | + } | ||
| 11669 | + if (esize > 2) { | ||
| 11670 | + return ((voidptr)(builtin__map_eq_int_4)); | ||
| 11671 | + } | ||
| 11672 | + if (esize > 1) { | ||
| 11673 | + return ((voidptr)(builtin__map_eq_int_2)); | ||
| 11674 | + } | ||
| 11675 | + if (esize > 0) { | ||
| 11676 | + return ((voidptr)(builtin__map_eq_int_1)); | ||
| 11677 | + } | ||
| 11678 | + } | ||
| 11679 | + if (kind == 3) { | ||
| 11680 | + if (esize > 4) { | ||
| 11681 | + return ((voidptr)(builtin__map_clone_int_8)); | ||
| 11682 | + } | ||
| 11683 | + if (esize > 2) { | ||
| 11684 | + return ((voidptr)(builtin__map_clone_int_4)); | ||
| 11685 | + } | ||
| 11686 | + if (esize > 1) { | ||
| 11687 | + return ((voidptr)(builtin__map_clone_int_2)); | ||
| 11688 | + } | ||
| 11689 | + if (esize > 0) { | ||
| 11690 | + return ((voidptr)(builtin__map_clone_int_1)); | ||
| 11691 | + } | ||
| 11692 | + } | ||
| 11693 | + return ((void*)0); | ||
| 11694 | +} | ||
| 11695 | +VV_LOC void builtin__DenseArray_zeros_to_end(DenseArray* d) { | ||
| 11696 | + u8* tmp_value = builtin___v_malloc(d->value_bytes); | ||
| 11697 | + u8* tmp_key = builtin___v_malloc(d->key_bytes); | ||
| 11698 | + int count = 0; | ||
| 11699 | + for (int i = 0; i < d->len; ++i) { | ||
| 11700 | + if (builtin__DenseArray_has_index(d, i)) { | ||
| 11701 | + { // Unsafe block | ||
| 11702 | + if (count != i) { | ||
| 11703 | + memcpy(tmp_key, builtin__DenseArray_key(d, count), d->key_bytes); | ||
| 11704 | + memcpy(builtin__DenseArray_key(d, count), builtin__DenseArray_key(d, i), d->key_bytes); | ||
| 11705 | + memcpy(builtin__DenseArray_key(d, i), tmp_key, d->key_bytes); | ||
| 11706 | + memcpy(tmp_value, builtin__DenseArray_value(d, count), d->value_bytes); | ||
| 11707 | + memcpy(builtin__DenseArray_value(d, count), builtin__DenseArray_value(d, i), d->value_bytes); | ||
| 11708 | + memcpy(builtin__DenseArray_value(d, i), tmp_value, d->value_bytes); | ||
| 11709 | + } | ||
| 11710 | + } | ||
| 11711 | + count++; | ||
| 11712 | + } | ||
| 11713 | + } | ||
| 11714 | + { // Unsafe block | ||
| 11715 | + builtin___v_free(tmp_value); | ||
| 11716 | + builtin___v_free(tmp_key); | ||
| 11717 | + d->deletes = 0; | ||
| 11718 | + builtin___v_free(d->all_deleted); | ||
| 11719 | + d->all_deleted = ((void*)0); | ||
| 11720 | + } | ||
| 11721 | + d->len = count; | ||
| 11722 | + int old_cap = d->cap; | ||
| 11723 | + if (count < 8) { | ||
| 11724 | + d->cap = 8; | ||
| 11725 | + } else { | ||
| 11726 | + d->cap = count; | ||
| 11727 | + } | ||
| 11728 | + { // Unsafe block | ||
| 11729 | + d->values = builtin__realloc_data(d->values, d->value_bytes * old_cap, d->value_bytes * d->cap); | ||
| 11730 | + d->keys = builtin__realloc_data(d->keys, d->key_bytes * old_cap, d->key_bytes * d->cap); | ||
| 11731 | + } | ||
| 11732 | +} | ||
| 11733 | +inline VV_LOC DenseArray builtin__new_dense_array(int key_bytes, int value_bytes) { | ||
| 11734 | + int cap = 8; | ||
| 11735 | + return ((DenseArray){ | ||
| 11736 | + .key_bytes = key_bytes, | ||
| 11737 | + .value_bytes = value_bytes, | ||
| 11738 | + .cap = cap, | ||
| 11739 | + .len = 0, | ||
| 11740 | + .deletes = 0, | ||
| 11741 | + .all_deleted = ((void*)0), | ||
| 11742 | + .keys = builtin___v_malloc(builtin____at_least_one(((u64)(cap)) * ((u64)(key_bytes)))), | ||
| 11743 | + .values = builtin___v_malloc(builtin____at_least_one(((u64)(cap)) * ((u64)(value_bytes)))), | ||
| 11744 | + }); | ||
| 11745 | +} | ||
| 11746 | +inline VV_LOC voidptr builtin__DenseArray_key(DenseArray* d, int i) { | ||
| 11747 | + return ((voidptr)(d->keys + i * d->key_bytes)); | ||
| 11748 | +} | ||
| 11749 | +inline VV_LOC voidptr builtin__DenseArray_value(DenseArray* d, int i) { | ||
| 11750 | + return ((voidptr)(d->values + i * d->value_bytes)); | ||
| 11751 | +} | ||
| 11752 | +inline VV_LOC bool builtin__DenseArray_has_index(DenseArray* d, int i) { | ||
| 11753 | + return d->deletes == 0 || d->all_deleted[i] == 0; | ||
| 11754 | +} | ||
| 11755 | +inline VV_LOC void builtin__DenseArray_trim_deleted_tail(DenseArray* d) { | ||
| 11756 | + if (d->deletes == 0) { | ||
| 11757 | + return; | ||
| 11758 | + } | ||
| 11759 | + for (;;) { | ||
| 11760 | + if (!(d->len > 0 && d->all_deleted[d->len - 1] != 0)) break; | ||
| 11761 | + { // Unsafe block | ||
| 11762 | + d->all_deleted[d->len - 1] = 0; | ||
| 11763 | + } | ||
| 11764 | + d->deletes--; | ||
| 11765 | + d->len--; | ||
| 11766 | + } | ||
| 11767 | + if (d->deletes == 0) { | ||
| 11768 | + { // Unsafe block | ||
| 11769 | + builtin___v_free(d->all_deleted); | ||
| 11770 | + d->all_deleted = ((void*)0); | ||
| 11771 | + } | ||
| 11772 | + } | ||
| 11773 | +} | ||
| 11774 | +inline VV_LOC int builtin__DenseArray_expand(DenseArray* d) { | ||
| 11775 | + int old_cap = d->cap; | ||
| 11776 | + int old_key_size = d->key_bytes * old_cap; | ||
| 11777 | + int old_value_size = d->value_bytes * old_cap; | ||
| 11778 | + if (d->cap == d->len) { | ||
| 11779 | + d->cap += v__rshift_int(d->cap, (u64)3); | ||
| 11780 | + { // Unsafe block | ||
| 11781 | + d->keys = builtin__realloc_data(d->keys, old_key_size, d->key_bytes * d->cap); | ||
| 11782 | + d->values = builtin__realloc_data(d->values, old_value_size, d->value_bytes * d->cap); | ||
| 11783 | + if (d->deletes != 0) { | ||
| 11784 | + d->all_deleted = builtin__realloc_data(d->all_deleted, old_cap, d->cap); | ||
| 11785 | + builtin__vmemset(((voidptr)(d->all_deleted + d->len)), 0, d->cap - d->len); | ||
| 11786 | + } | ||
| 11787 | + } | ||
| 11788 | + } | ||
| 11789 | + int push_index = d->len; | ||
| 11790 | + { // Unsafe block | ||
| 11791 | + if (d->deletes != 0) { | ||
| 11792 | + d->all_deleted[push_index] = 0; | ||
| 11793 | + } | ||
| 11794 | + } | ||
| 11795 | + d->len++; | ||
| 11796 | + return push_index; | ||
| 11797 | +} | ||
| 11798 | +inline VV_LOC bool builtin__map_eq_string(voidptr a, voidptr b) { | ||
| 11799 | + return builtin__fast_string_eq(*((string*)(a)), *((string*)(b))); | ||
| 11800 | +} | ||
| 11801 | +inline VV_LOC bool builtin__map_eq_int_1(voidptr a, voidptr b) { | ||
| 11802 | + return *((u8*)(a)) == *((u8*)(b)); | ||
| 11803 | +} | ||
| 11804 | +inline VV_LOC bool builtin__map_eq_int_2(voidptr a, voidptr b) { | ||
| 11805 | + return *((u16*)(a)) == *((u16*)(b)); | ||
| 11806 | +} | ||
| 11807 | +inline VV_LOC bool builtin__map_eq_int_4(voidptr a, voidptr b) { | ||
| 11808 | + return *((u32*)(a)) == *((u32*)(b)); | ||
| 11809 | +} | ||
| 11810 | +inline VV_LOC bool builtin__map_eq_int_8(voidptr a, voidptr b) { | ||
| 11811 | + return *((u64*)(a)) == *((u64*)(b)); | ||
| 11812 | +} | ||
| 11813 | +VV_LOC bool builtin__map_map_eq(map a, map b) { | ||
| 11814 | + if (a.len != b.len) { | ||
| 11815 | + return false; | ||
| 11816 | + } | ||
| 11817 | + for (int i = 0; i < a.key_values.len; i++) { | ||
| 11818 | + if (!builtin__DenseArray_has_index(&a.key_values, i)) { | ||
| 11819 | + continue; | ||
| 11820 | + } | ||
| 11821 | + voidptr k = builtin__DenseArray_key(&a.key_values, i); | ||
| 11822 | + if (!builtin__map_exists(&b, k)) { | ||
| 11823 | + return false; | ||
| 11824 | + } | ||
| 11825 | + voidptr va = builtin__DenseArray_value(&a.key_values, i); | ||
| 11826 | + voidptr vb = builtin__map_get(&b, k, va); | ||
| 11827 | + if (builtin__vmemcmp(va, vb, a.value_bytes) != 0) { | ||
| 11828 | + return false; | ||
| 11829 | + } | ||
| 11830 | + } | ||
| 11831 | + return true; | ||
| 11832 | +} | ||
| 11833 | +inline VV_LOC void builtin__map_clone_string(voidptr dest, voidptr pkey) { | ||
| 11834 | + { // Unsafe block | ||
| 11835 | + string s = *((string*)(pkey)); | ||
| 11836 | + string cloned = builtin__string_clone(s); | ||
| 11837 | + builtin__vmemcpy(dest, ((voidptr)(&cloned)), sizeof(string)); | ||
| 11838 | + } | ||
| 11839 | +} | ||
| 11840 | +inline VV_LOC void builtin__map_clone_int_1(voidptr dest, voidptr pkey) { | ||
| 11841 | + { // Unsafe block | ||
| 11842 | + *((u8*)(dest)) = *((u8*)(pkey)); | ||
| 11843 | + } | ||
| 11844 | +} | ||
| 11845 | +inline VV_LOC void builtin__map_clone_int_2(voidptr dest, voidptr pkey) { | ||
| 11846 | + { // Unsafe block | ||
| 11847 | + *((u16*)(dest)) = *((u16*)(pkey)); | ||
| 11848 | + } | ||
| 11849 | +} | ||
| 11850 | +inline VV_LOC void builtin__map_clone_int_4(voidptr dest, voidptr pkey) { | ||
| 11851 | + { // Unsafe block | ||
| 11852 | + *((u32*)(dest)) = *((u32*)(pkey)); | ||
| 11853 | + } | ||
| 11854 | +} | ||
| 11855 | +inline VV_LOC void builtin__map_clone_int_8(voidptr dest, voidptr pkey) { | ||
| 11856 | + { // Unsafe block | ||
| 11857 | + *((u64*)(dest)) = *((u64*)(pkey)); | ||
| 11858 | + } | ||
| 11859 | +} | ||
| 11860 | +inline VV_LOC void builtin__map_free_string(voidptr pkey) { | ||
| 11861 | + builtin__string_free(ADDR(string, (*((string*)(pkey))))); | ||
| 11862 | +} | ||
| 11863 | +inline VV_LOC void builtin__map_free_nop(voidptr _d1) { | ||
| 11864 | +} | ||
| 11865 | +VV_LOC map builtin__new_map(int key_bytes, int value_bytes, u64 (*hash_fn)(voidptr _d1), bool (*key_eq_fn)(voidptr _d1, voidptr _d2), void (*clone_fn)(voidptr _d1, voidptr _d2), void (*free_fn)(voidptr _d1)) { | ||
| 11866 | + int metasize = ((int)((u32)(sizeof(u32) * (_const_init_capicity + _const_extra_metas_inc)))); | ||
| 11867 | + bool has_string_keys = key_bytes > ((int)(sizeof(voidptr))); | ||
| 11868 | + return ((map){ | ||
| 11869 | + .key_bytes = key_bytes, | ||
| 11870 | + .value_bytes = value_bytes, | ||
| 11871 | + .even_index = _const_init_even_index, | ||
| 11872 | + .cached_hashbits = _const_max_cached_hashbits, | ||
| 11873 | + .shift = _const_init_log_capicity, | ||
| 11874 | + .key_values = builtin__new_dense_array(key_bytes, value_bytes), | ||
| 11875 | + .metas = ((u32*)(builtin__vcalloc_noscan(metasize))), | ||
| 11876 | + .extra_metas = _const_extra_metas_inc, | ||
| 11877 | + .has_string_keys = has_string_keys, | ||
| 11878 | + .hash_fn = hash_fn, | ||
| 11879 | + .key_eq_fn = key_eq_fn, | ||
| 11880 | + .clone_fn = clone_fn, | ||
| 11881 | + .free_fn = free_fn, | ||
| 11882 | + .len = 0, | ||
| 11883 | + }); | ||
| 11884 | +} | ||
| 11885 | +VV_LOC map builtin__new_map_init(u64 (*hash_fn)(voidptr _d1), bool (*key_eq_fn)(voidptr _d1, voidptr _d2), void (*clone_fn)(voidptr _d1, voidptr _d2), void (*free_fn)(voidptr _d1), int n, int key_bytes, int value_bytes, voidptr keys, voidptr values) { | ||
| 11886 | + map out = builtin__new_map(key_bytes, value_bytes, hash_fn, key_eq_fn, clone_fn, free_fn); | ||
| 11887 | + u8* pkey = ((u8*)(keys)); | ||
| 11888 | + u8* pval = ((u8*)(values)); | ||
| 11889 | + for (int _t1 = 0; _t1 < n; ++_t1) { | ||
| 11890 | + { // Unsafe block | ||
| 11891 | + builtin__map_set(&out, pkey, pval); | ||
| 11892 | + pkey = pkey + key_bytes; | ||
| 11893 | + pval = pval + value_bytes; | ||
| 11894 | + } | ||
| 11895 | + } | ||
| 11896 | + return out; | ||
| 11897 | +} | ||
| 11898 | +map builtin__map_move(map* m) { | ||
| 11899 | + map r = *m; | ||
| 11900 | + builtin__vmemset(m, 0, ((int)(sizeof(map)))); | ||
| 11901 | + return r; | ||
| 11902 | +} | ||
| 11903 | +void builtin__map_clear(map* m) { | ||
| 11904 | + { // Unsafe block | ||
| 11905 | + if (m->key_values.all_deleted != 0) { | ||
| 11906 | + builtin___v_free(m->key_values.all_deleted); | ||
| 11907 | + m->key_values.all_deleted = ((void*)0); | ||
| 11908 | + } | ||
| 11909 | + builtin__vmemset(m->key_values.keys, 0, m->key_values.key_bytes * m->key_values.cap); | ||
| 11910 | + builtin__vmemset(m->metas, 0, sizeof(u32) * (m->even_index + 2 + m->extra_metas)); | ||
| 11911 | + } | ||
| 11912 | + m->key_values.len = 0; | ||
| 11913 | + m->key_values.deletes = 0; | ||
| 11914 | + m->even_index = _const_init_even_index; | ||
| 11915 | + m->cached_hashbits = _const_max_cached_hashbits; | ||
| 11916 | + m->shift = _const_init_log_capicity; | ||
| 11917 | + m->len = 0; | ||
| 11918 | +} | ||
| 11919 | +inline VV_LOC multi_return_u32_u32 builtin__map_key_to_index(map* m, voidptr pkey) { | ||
| 11920 | + if (((voidptr)(m->hash_fn)) == ((void*)0)) { | ||
| 11921 | + { // Unsafe block | ||
| 11922 | + u64* p = ((u64*)(m)); | ||
| 11923 | + u64 prev2 = (((u64*)(((usize)(m)) - ((usize)(16)))))[0]; | ||
| 11924 | + u64 prev1 = (((u64*)(((usize)(m)) - ((usize)(8)))))[0]; | ||
| 11925 | + builtin___v_panic(builtin__string_plus_many(34, _MOV((string[34]){_S("map.hash_fn is nil map_ptr="), builtin__usize_str(((usize)(m))), _S(" key_bytes="), builtin__int_str(m->key_bytes), _S(" value_bytes="), builtin__int_str(m->value_bytes), _S(" even_index="), builtin__u32_str(m->even_index), _S(" shift="), builtin__u8_str(m->shift), _S(" metas="), builtin__usize_str(((usize)(m->metas))), _S(" prev2="), builtin__u64_str(prev2), _S(" prev1="), builtin__u64_str(prev1), _S(" w0="), builtin__u64_str(p[0]), _S(" w1="), builtin__u64_str(p[1]), _S(" w2="), builtin__u64_str(p[2]), _S(" w3="), builtin__u64_str(p[3]), _S(" w4="), builtin__u64_str(p[4]), _S(" w5="), builtin__u64_str(p[5]), _S(" w6="), builtin__u64_str(p[6]), _S(" w7="), builtin__u64_str(p[7]), _S(" hash_fn="), builtin__usize_str(((usize)(((voidptr)(m->hash_fn)))))}))); | ||
| 11926 | + VUNREACHABLE(); | ||
| 11927 | + } | ||
| 11928 | + } | ||
| 11929 | + u64 hash = m->hash_fn(pkey); | ||
| 11930 | + u64 index = (hash & m->even_index); | ||
| 11931 | + u64 meta = ((((v__rshift_u64(hash, (u64)m->shift)) & _const_hash_mask)) | _const_probe_inc); | ||
| 11932 | + return (multi_return_u32_u32){.arg0=((u32)(index)), .arg1=((u32)(meta))}; | ||
| 11933 | +} | ||
| 11934 | +inline VV_LOC multi_return_u32_u32 builtin__map_meta_less(map* m, u32 _index, u32 _metas) { | ||
| 11935 | + u32 index = _index; | ||
| 11936 | + u32 meta = _metas; | ||
| 11937 | + for (;;) { | ||
| 11938 | + if (!(meta < m->metas[index])) break; | ||
| 11939 | + index += 2; | ||
| 11940 | + meta += _const_probe_inc; | ||
| 11941 | + } | ||
| 11942 | + return (multi_return_u32_u32){.arg0=index, .arg1=meta}; | ||
| 11943 | +} | ||
| 11944 | +inline VV_LOC void builtin__map_meta_greater(map* m, u32 _index, u32 _metas, u32 kvi) { | ||
| 11945 | + u32 meta = _metas; | ||
| 11946 | + u32 index = _index; | ||
| 11947 | + u32 kv_index = kvi; | ||
| 11948 | + for (;;) { | ||
| 11949 | + if (!(m->metas[index] != 0)) break; | ||
| 11950 | + if (meta > m->metas[index]) { | ||
| 11951 | + { // Unsafe block | ||
| 11952 | + u32 tmp_meta = m->metas[index]; | ||
| 11953 | + m->metas[index] = meta; | ||
| 11954 | + meta = tmp_meta; | ||
| 11955 | + u32 tmp_index = m->metas[index + 1]; | ||
| 11956 | + m->metas[index + 1] = kv_index; | ||
| 11957 | + kv_index = tmp_index; | ||
| 11958 | + } | ||
| 11959 | + } | ||
| 11960 | + index += 2; | ||
| 11961 | + meta += _const_probe_inc; | ||
| 11962 | + if (index + 2 >= m->even_index + 2 + m->extra_metas) { | ||
| 11963 | + builtin__map_ensure_extra_metas_grow(m); | ||
| 11964 | + } | ||
| 11965 | + } | ||
| 11966 | + { // Unsafe block | ||
| 11967 | + m->metas[index] = meta; | ||
| 11968 | + m->metas[index + 1] = kv_index; | ||
| 11969 | + } | ||
| 11970 | + u32 probe_count = (v__rshift_u32(meta, (u64)_const_hashbits)) - 1; | ||
| 11971 | + builtin__map_ensure_extra_metas(m, probe_count); | ||
| 11972 | +} | ||
| 11973 | +VV_LOC void builtin__map_ensure_extra_metas_grow(map* m) { | ||
| 11974 | + u32 size_of_u32 = sizeof(u32); | ||
| 11975 | + u32 old_mem_size = (m->even_index + 2 + m->extra_metas); | ||
| 11976 | + m->extra_metas += _const_extra_metas_inc; | ||
| 11977 | + u32 mem_size = (m->even_index + 2 + m->extra_metas); | ||
| 11978 | + { // Unsafe block | ||
| 11979 | + u8* x = builtin__realloc_data(((byteptr)(m->metas)), ((int)(size_of_u32 * old_mem_size)), ((int)(size_of_u32 * mem_size))); | ||
| 11980 | + m->metas = ((u32*)(x)); | ||
| 11981 | + builtin__vmemset(((byteptr)(m->metas)) + (mem_size - _const_extra_metas_inc) * size_of_u32, 0, ((int)(sizeof(u32) * _const_extra_metas_inc))); | ||
| 11982 | + } | ||
| 11983 | +} | ||
| 11984 | +inline VV_LOC void builtin__map_ensure_extra_metas(map* m, u32 probe_count) { | ||
| 11985 | + if ((v__lshift_u32(probe_count, (u64)1)) == m->extra_metas) { | ||
| 11986 | + u32 size_of_u32 = sizeof(u32); | ||
| 11987 | + u32 old_mem_size = (m->even_index + 2 + m->extra_metas); | ||
| 11988 | + m->extra_metas += _const_extra_metas_inc; | ||
| 11989 | + u32 mem_size = (m->even_index + 2 + m->extra_metas); | ||
| 11990 | + { // Unsafe block | ||
| 11991 | + u8* x = builtin__realloc_data(((byteptr)(m->metas)), ((int)(size_of_u32 * old_mem_size)), ((int)(size_of_u32 * mem_size))); | ||
| 11992 | + m->metas = ((u32*)(x)); | ||
| 11993 | + builtin__vmemset(((byteptr)(m->metas)) + (mem_size - _const_extra_metas_inc) * size_of_u32, 0, ((int)(sizeof(u32) * _const_extra_metas_inc))); | ||
| 11994 | + } | ||
| 11995 | + if (probe_count == 252) { | ||
| 11996 | + builtin___v_panic(_S("Probe overflow")); | ||
| 11997 | + VUNREACHABLE(); | ||
| 11998 | + } | ||
| 11999 | + } | ||
| 12000 | +} | ||
| 12001 | +VV_LOC void builtin__map_set(map* m, voidptr key, voidptr value) { | ||
| 12002 | + if (((u32)(5)) * ((u32)(m->len)) > ((u32)(2)) * m->even_index) { | ||
| 12003 | + builtin__map_expand(m); | ||
| 12004 | + } | ||
| 12005 | + multi_return_u32_u32 mr_14546 = builtin__map_key_to_index(m, key); | ||
| 12006 | + u32 index = mr_14546.arg0; | ||
| 12007 | + u32 meta = mr_14546.arg1; | ||
| 12008 | + multi_return_u32_u32 mr_14582 = builtin__map_meta_less(m, index, meta); | ||
| 12009 | + index = mr_14582.arg0; | ||
| 12010 | + meta = mr_14582.arg1; | ||
| 12011 | + for (;;) { | ||
| 12012 | + if (!(meta == m->metas[index])) break; | ||
| 12013 | + int kv_index = ((int)(m->metas[index + 1])); | ||
| 12014 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | ||
| 12015 | + if (m->key_eq_fn(key, pkey)) { | ||
| 12016 | + { // Unsafe block | ||
| 12017 | + voidptr pval = builtin__DenseArray_value(&m->key_values, kv_index); | ||
| 12018 | + builtin__vmemcpy(pval, value, m->value_bytes); | ||
| 12019 | + } | ||
| 12020 | + return; | ||
| 12021 | + } | ||
| 12022 | + index += 2; | ||
| 12023 | + meta += _const_probe_inc; | ||
| 12024 | + } | ||
| 12025 | + int kv_index = builtin__DenseArray_expand(&m->key_values); | ||
| 12026 | + { // Unsafe block | ||
| 12027 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | ||
| 12028 | + voidptr pvalue = builtin__DenseArray_value(&m->key_values, kv_index); | ||
| 12029 | + m->clone_fn(pkey, key); | ||
| 12030 | + builtin__vmemcpy(pvalue, value, m->value_bytes); | ||
| 12031 | + } | ||
| 12032 | + builtin__map_meta_greater(m, index, meta, ((u32)(kv_index))); | ||
| 12033 | + m->len++; | ||
| 12034 | +} | ||
| 12035 | +VV_LOC void builtin__map_expand(map* m) { | ||
| 12036 | + u32 old_cap = m->even_index; | ||
| 12037 | + m->even_index = (v__lshift_u32((m->even_index + 2), (u64)1)) - 2; | ||
| 12038 | + if (m->cached_hashbits == 0) { | ||
| 12039 | + m->shift += _const_max_cached_hashbits; | ||
| 12040 | + m->cached_hashbits = _const_max_cached_hashbits; | ||
| 12041 | + builtin__map_rehash(m); | ||
| 12042 | + } else { | ||
| 12043 | + builtin__map_cached_rehash(m, old_cap); | ||
| 12044 | + m->cached_hashbits--; | ||
| 12045 | + } | ||
| 12046 | +} | ||
| 12047 | +VV_LOC void builtin__map_rehash(map* m) { | ||
| 12048 | + u32 meta_bytes = sizeof(u32) * (m->even_index + 2 + m->extra_metas); | ||
| 12049 | + builtin__map_reserve_metas(m, meta_bytes); | ||
| 12050 | +} | ||
| 12051 | +VV_LOC void builtin__map_reserve_metas(map* m, u32 meta_bytes) { | ||
| 12052 | + { // Unsafe block | ||
| 12053 | + u8* x = builtin__v_realloc(((byteptr)(m->metas)), ((int)(meta_bytes))); | ||
| 12054 | + m->metas = ((u32*)(x)); | ||
| 12055 | + builtin__vmemset(m->metas, 0, ((int)(meta_bytes))); | ||
| 12056 | + } | ||
| 12057 | + for (int i = 0; i < m->key_values.len; i++) { | ||
| 12058 | + if (!builtin__DenseArray_has_index(&m->key_values, i)) { | ||
| 12059 | + continue; | ||
| 12060 | + } | ||
| 12061 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, i); | ||
| 12062 | + multi_return_u32_u32 mr_16309 = builtin__map_key_to_index(m, pkey); | ||
| 12063 | + u32 index = mr_16309.arg0; | ||
| 12064 | + u32 meta = mr_16309.arg1; | ||
| 12065 | + multi_return_u32_u32 mr_16347 = builtin__map_meta_less(m, index, meta); | ||
| 12066 | + index = mr_16347.arg0; | ||
| 12067 | + meta = mr_16347.arg1; | ||
| 12068 | + builtin__map_meta_greater(m, index, meta, ((u32)(i))); | ||
| 12069 | + } | ||
| 12070 | +} | ||
| 12071 | +void builtin__map_reserve(map* m, u32 n) { | ||
| 12072 | + for (;;) { | ||
| 12073 | + if (!(((u64)(n)) * 5 > ((u64)(m->even_index)) * 2)) break; | ||
| 12074 | + builtin__map_expand(m); | ||
| 12075 | + } | ||
| 12076 | +} | ||
| 12077 | +VV_LOC void builtin__map_cached_rehash(map* m, u32 old_cap) { | ||
| 12078 | + u32* old_metas = m->metas; | ||
| 12079 | + int metasize = ((int)(sizeof(u32) * (m->even_index + 2 + m->extra_metas))); | ||
| 12080 | + m->metas = ((u32*)(builtin__vcalloc(metasize))); | ||
| 12081 | + u32 old_extra_metas = m->extra_metas; | ||
| 12082 | + for (u32 i = ((u32)(0)); i <= old_cap + old_extra_metas; i += 2) { | ||
| 12083 | + if (old_metas[i] == 0) { | ||
| 12084 | + continue; | ||
| 12085 | + } | ||
| 12086 | + u32 old_meta = old_metas[i]; | ||
| 12087 | + u32 old_probe_count = v__lshift_u32(((v__rshift_u32(old_meta, (u64)_const_hashbits)) - 1), (u64)1); | ||
| 12088 | + u32 old_index = ((i - old_probe_count) & (v__rshift_u32(m->even_index, (u64)1))); | ||
| 12089 | + u32 index = (((old_index | (v__lshift_u32(old_meta, (u64)m->shift)))) & m->even_index); | ||
| 12090 | + u32 meta = (((old_meta & _const_hash_mask)) | _const_probe_inc); | ||
| 12091 | + u32 kv_index = old_metas[i + 1]; | ||
| 12092 | + multi_return_u32_u32 mr_17370 = builtin__map_meta_less(m, index, meta); | ||
| 12093 | + index = mr_17370.arg0; | ||
| 12094 | + meta = mr_17370.arg1; | ||
| 12095 | + builtin__map_meta_greater(m, index, meta, kv_index); | ||
| 12096 | + } | ||
| 12097 | + builtin___v_free(old_metas); | ||
| 12098 | +} | ||
| 12099 | +VV_LOC voidptr builtin__map_get_and_set(map* m, voidptr key, voidptr zero) { | ||
| 12100 | + for (;;) { | ||
| 12101 | + multi_return_u32_u32 mr_17776 = builtin__map_key_to_index(m, key); | ||
| 12102 | + u32 index = mr_17776.arg0; | ||
| 12103 | + u32 meta = mr_17776.arg1; | ||
| 12104 | + for (;;) { | ||
| 12105 | + if (meta == m->metas[index]) { | ||
| 12106 | + int kv_index = ((int)(m->metas[index + 1])); | ||
| 12107 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | ||
| 12108 | + if (m->key_eq_fn(key, pkey)) { | ||
| 12109 | + voidptr pval = builtin__DenseArray_value(&m->key_values, kv_index); | ||
| 12110 | + return ((u8*)(pval)); | ||
| 12111 | + } | ||
| 12112 | + } | ||
| 12113 | + index += 2; | ||
| 12114 | + meta += _const_probe_inc; | ||
| 12115 | + if (meta > m->metas[index]) { | ||
| 12116 | + break; | ||
| 12117 | + } | ||
| 12118 | + } | ||
| 12119 | + builtin__map_set(m, key, zero); | ||
| 12120 | + } | ||
| 12121 | + return ((void*)0); | ||
| 12122 | +} | ||
| 12123 | +VV_LOC voidptr builtin__map_get(map* m, voidptr key, voidptr zero) { | ||
| 12124 | + if (m->len == 0) { | ||
| 12125 | + return zero; | ||
| 12126 | + } | ||
| 12127 | + multi_return_u32_u32 mr_18537 = builtin__map_key_to_index(m, key); | ||
| 12128 | + u32 index = mr_18537.arg0; | ||
| 12129 | + u32 meta = mr_18537.arg1; | ||
| 12130 | + for (;;) { | ||
| 12131 | + if (meta == m->metas[index]) { | ||
| 12132 | + int kv_index = ((int)(m->metas[index + 1])); | ||
| 12133 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | ||
| 12134 | + if (m->key_eq_fn(key, pkey)) { | ||
| 12135 | + voidptr pval = builtin__DenseArray_value(&m->key_values, kv_index); | ||
| 12136 | + return ((u8*)(pval)); | ||
| 12137 | + } | ||
| 12138 | + } | ||
| 12139 | + index += 2; | ||
| 12140 | + meta += _const_probe_inc; | ||
| 12141 | + if (meta > m->metas[index]) { | ||
| 12142 | + break; | ||
| 12143 | + } | ||
| 12144 | + } | ||
| 12145 | + return zero; | ||
| 12146 | +} | ||
| 12147 | +VV_LOC voidptr builtin__map_get_check(map* m, voidptr key) { | ||
| 12148 | + if (m->len == 0) { | ||
| 12149 | + return 0; | ||
| 12150 | + } | ||
| 12151 | + multi_return_u32_u32 mr_19233 = builtin__map_key_to_index(m, key); | ||
| 12152 | + u32 index = mr_19233.arg0; | ||
| 12153 | + u32 meta = mr_19233.arg1; | ||
| 12154 | + for (;;) { | ||
| 12155 | + if (meta == m->metas[index]) { | ||
| 12156 | + int kv_index = ((int)(m->metas[index + 1])); | ||
| 12157 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | ||
| 12158 | + if (m->key_eq_fn(key, pkey)) { | ||
| 12159 | + voidptr pval = builtin__DenseArray_value(&m->key_values, kv_index); | ||
| 12160 | + return ((u8*)(pval)); | ||
| 12161 | + } | ||
| 12162 | + } | ||
| 12163 | + index += 2; | ||
| 12164 | + meta += _const_probe_inc; | ||
| 12165 | + if (meta > m->metas[index]) { | ||
| 12166 | + break; | ||
| 12167 | + } | ||
| 12168 | + } | ||
| 12169 | + return 0; | ||
| 12170 | +} | ||
| 12171 | +VV_LOC bool builtin__map_exists(map* m, voidptr key) { | ||
| 12172 | + if (m->len == 0) { | ||
| 12173 | + return false; | ||
| 12174 | + } | ||
| 12175 | + multi_return_u32_u32 mr_19778 = builtin__map_key_to_index(m, key); | ||
| 12176 | + u32 index = mr_19778.arg0; | ||
| 12177 | + u32 meta = mr_19778.arg1; | ||
| 12178 | + for (;;) { | ||
| 12179 | + if (meta == m->metas[index]) { | ||
| 12180 | + int kv_index = ((int)(m->metas[index + 1])); | ||
| 12181 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | ||
| 12182 | + if (m->key_eq_fn(key, pkey)) { | ||
| 12183 | + return true; | ||
| 12184 | + } | ||
| 12185 | + } | ||
| 12186 | + index += 2; | ||
| 12187 | + meta += _const_probe_inc; | ||
| 12188 | + if (meta > m->metas[index]) { | ||
| 12189 | + break; | ||
| 12190 | + } | ||
| 12191 | + } | ||
| 12192 | + return false; | ||
| 12193 | +} | ||
| 12194 | +inline VV_LOC void builtin__DenseArray_delete(DenseArray* d, int i) { | ||
| 12195 | + if (i == d->len - 1) { | ||
| 12196 | + d->len--; | ||
| 12197 | + builtin__DenseArray_trim_deleted_tail(d); | ||
| 12198 | + return; | ||
| 12199 | + } | ||
| 12200 | + if (d->deletes == 0) { | ||
| 12201 | + d->all_deleted = builtin__vcalloc(d->cap); | ||
| 12202 | + } | ||
| 12203 | + d->deletes++; | ||
| 12204 | + { // Unsafe block | ||
| 12205 | + d->all_deleted[i] = 1; | ||
| 12206 | + } | ||
| 12207 | +} | ||
| 12208 | +void builtin__map_delete(map* m, voidptr key) { | ||
| 12209 | + multi_return_u32_u32 mr_20483 = builtin__map_key_to_index(m, key); | ||
| 12210 | + u32 index = mr_20483.arg0; | ||
| 12211 | + u32 meta = mr_20483.arg1; | ||
| 12212 | + multi_return_u32_u32 mr_20519 = builtin__map_meta_less(m, index, meta); | ||
| 12213 | + index = mr_20519.arg0; | ||
| 12214 | + meta = mr_20519.arg1; | ||
| 12215 | + for (;;) { | ||
| 12216 | + if (!(meta == m->metas[index])) break; | ||
| 12217 | + int kv_index = ((int)(m->metas[index + 1])); | ||
| 12218 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | ||
| 12219 | + if (m->key_eq_fn(key, pkey)) { | ||
| 12220 | + for (;;) { | ||
| 12221 | + if (!((v__rshift_u32(m->metas[index + 2], (u64)_const_hashbits)) > 1)) break; | ||
| 12222 | + { // Unsafe block | ||
| 12223 | + m->metas[index] = m->metas[index + 2] - _const_probe_inc; | ||
| 12224 | + m->metas[index + 1] = m->metas[index + 3]; | ||
| 12225 | + } | ||
| 12226 | + index += 2; | ||
| 12227 | + } | ||
| 12228 | + m->len--; | ||
| 12229 | + builtin__DenseArray_delete(&m->key_values, kv_index); | ||
| 12230 | + { // Unsafe block | ||
| 12231 | + m->metas[index] = 0; | ||
| 12232 | + m->free_fn(pkey); | ||
| 12233 | + builtin__vmemset(pkey, 0, m->key_bytes); | ||
| 12234 | + } | ||
| 12235 | + if (m->key_values.len <= 32) { | ||
| 12236 | + return; | ||
| 12237 | + } | ||
| 12238 | + if (_us32_ge(m->key_values.deletes,(v__rshift_int(m->key_values.len, (u64)1)))) { | ||
| 12239 | + builtin__DenseArray_zeros_to_end(&m->key_values); | ||
| 12240 | + builtin__map_rehash(m); | ||
| 12241 | + } | ||
| 12242 | + return; | ||
| 12243 | + } | ||
| 12244 | + index += 2; | ||
| 12245 | + meta += _const_probe_inc; | ||
| 12246 | + } | ||
| 12247 | +} | ||
| 12248 | +array builtin__map_keys(map* m) { | ||
| 12249 | + array keys = builtin____new_array(m->len, 0, m->key_bytes); | ||
| 12250 | + u8* item = ((u8*)(keys.data)); | ||
| 12251 | + if (m->key_values.deletes == 0) { | ||
| 12252 | + for (int i = 0; i < m->key_values.len; i++) { | ||
| 12253 | + { // Unsafe block | ||
| 12254 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, i); | ||
| 12255 | + m->clone_fn(item, pkey); | ||
| 12256 | + item = item + m->key_bytes; | ||
| 12257 | + } | ||
| 12258 | + } | ||
| 12259 | + return keys; | ||
| 12260 | + } | ||
| 12261 | + for (int i = 0; i < m->key_values.len; i++) { | ||
| 12262 | + if (!builtin__DenseArray_has_index(&m->key_values, i)) { | ||
| 12263 | + continue; | ||
| 12264 | + } | ||
| 12265 | + { // Unsafe block | ||
| 12266 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, i); | ||
| 12267 | + m->clone_fn(item, pkey); | ||
| 12268 | + item = item + m->key_bytes; | ||
| 12269 | + } | ||
| 12270 | + } | ||
| 12271 | + return keys; | ||
| 12272 | +} | ||
| 12273 | +array builtin__map_values(map* m) { | ||
| 12274 | + array values = builtin____new_array(m->len, 0, m->value_bytes); | ||
| 12275 | + u8* item = ((u8*)(values.data)); | ||
| 12276 | + if (m->key_values.deletes == 0) { | ||
| 12277 | + builtin__vmemcpy(item, m->key_values.values, m->value_bytes * m->key_values.len); | ||
| 12278 | + return values; | ||
| 12279 | + } | ||
| 12280 | + for (int i = 0; i < m->key_values.len; i++) { | ||
| 12281 | + if (!builtin__DenseArray_has_index(&m->key_values, i)) { | ||
| 12282 | + continue; | ||
| 12283 | + } | ||
| 12284 | + { // Unsafe block | ||
| 12285 | + voidptr pvalue = builtin__DenseArray_value(&m->key_values, i); | ||
| 12286 | + builtin__vmemcpy(item, pvalue, m->value_bytes); | ||
| 12287 | + item = item + m->value_bytes; | ||
| 12288 | + } | ||
| 12289 | + } | ||
| 12290 | + return values; | ||
| 12291 | +} | ||
| 12292 | +VV_LOC DenseArray builtin__DenseArray_clone(DenseArray* d) { | ||
| 12293 | + DenseArray res = ((DenseArray){ | ||
| 12294 | + .key_bytes = d->key_bytes, | ||
| 12295 | + .value_bytes = d->value_bytes, | ||
| 12296 | + .cap = d->cap, | ||
| 12297 | + .len = d->len, | ||
| 12298 | + .deletes = d->deletes, | ||
| 12299 | + .all_deleted = ((void*)0), | ||
| 12300 | + .keys = ((void*)0), | ||
| 12301 | + .values = ((void*)0), | ||
| 12302 | + }); | ||
| 12303 | + { // Unsafe block | ||
| 12304 | + if (d->deletes != 0) { | ||
| 12305 | + res.all_deleted = builtin__memdup(d->all_deleted, d->cap); | ||
| 12306 | + } | ||
| 12307 | + res.keys = builtin__memdup(d->keys, d->cap * d->key_bytes); | ||
| 12308 | + res.values = builtin__memdup(d->values, d->cap * d->value_bytes); | ||
| 12309 | + } | ||
| 12310 | + return res; | ||
| 12311 | +} | ||
| 12312 | +map builtin__map_clone(map* m) { | ||
| 12313 | + int metasize = ((int)(sizeof(u32) * (m->even_index + 2 + m->extra_metas))); | ||
| 12314 | + map res = ((map){ | ||
| 12315 | + .key_bytes = m->key_bytes, | ||
| 12316 | + .value_bytes = m->value_bytes, | ||
| 12317 | + .even_index = m->even_index, | ||
| 12318 | + .cached_hashbits = m->cached_hashbits, | ||
| 12319 | + .shift = m->shift, | ||
| 12320 | + .key_values = builtin__DenseArray_clone(&m->key_values), | ||
| 12321 | + .metas = ((u32*)(builtin__malloc_noscan(metasize))), | ||
| 12322 | + .extra_metas = m->extra_metas, | ||
| 12323 | + .has_string_keys = m->has_string_keys, | ||
| 12324 | + .hash_fn = m->hash_fn, | ||
| 12325 | + .key_eq_fn = m->key_eq_fn, | ||
| 12326 | + .clone_fn = m->clone_fn, | ||
| 12327 | + .free_fn = m->free_fn, | ||
| 12328 | + .len = m->len, | ||
| 12329 | + }); | ||
| 12330 | + builtin__vmemcpy(res.metas, m->metas, metasize); | ||
| 12331 | + if (!m->has_string_keys) { | ||
| 12332 | + return res; | ||
| 12333 | + } | ||
| 12334 | + for (int i = 0; i < m->key_values.len; ++i) { | ||
| 12335 | + if (!builtin__DenseArray_has_index(&m->key_values, i)) { | ||
| 12336 | + continue; | ||
| 12337 | + } | ||
| 12338 | + m->clone_fn(builtin__DenseArray_key(&res.key_values, i), builtin__DenseArray_key(&m->key_values, i)); | ||
| 12339 | + } | ||
| 12340 | + return res; | ||
| 12341 | +} | ||
| 12342 | +void builtin__map_free(map* m) { | ||
| 12343 | + builtin___v_free(m->metas); | ||
| 12344 | + { // Unsafe block | ||
| 12345 | + m->metas = ((void*)0); | ||
| 12346 | + } | ||
| 12347 | + if (m->key_values.deletes == 0) { | ||
| 12348 | + for (int i = 0; i < m->key_values.len; i++) { | ||
| 12349 | + { // Unsafe block | ||
| 12350 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, i); | ||
| 12351 | + m->free_fn(pkey); | ||
| 12352 | + builtin__vmemset(pkey, 0, m->key_bytes); | ||
| 12353 | + } | ||
| 12354 | + } | ||
| 12355 | + } else { | ||
| 12356 | + for (int i = 0; i < m->key_values.len; i++) { | ||
| 12357 | + if (!builtin__DenseArray_has_index(&m->key_values, i)) { | ||
| 12358 | + continue; | ||
| 12359 | + } | ||
| 12360 | + { // Unsafe block | ||
| 12361 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, i); | ||
| 12362 | + m->free_fn(pkey); | ||
| 12363 | + builtin__vmemset(pkey, 0, m->key_bytes); | ||
| 12364 | + } | ||
| 12365 | + } | ||
| 12366 | + } | ||
| 12367 | + { // Unsafe block | ||
| 12368 | + if (m->key_values.all_deleted != ((void*)0)) { | ||
| 12369 | + builtin___v_free(m->key_values.all_deleted); | ||
| 12370 | + m->key_values.all_deleted = ((void*)0); | ||
| 12371 | + } | ||
| 12372 | + if (m->key_values.keys != ((void*)0)) { | ||
| 12373 | + builtin___v_free(m->key_values.keys); | ||
| 12374 | + m->key_values.keys = ((void*)0); | ||
| 12375 | + } | ||
| 12376 | + if (m->key_values.values != ((void*)0)) { | ||
| 12377 | + builtin___v_free(m->key_values.values); | ||
| 12378 | + m->key_values.values = ((void*)0); | ||
| 12379 | + } | ||
| 12380 | + m->hash_fn = ((void*)0); | ||
| 12381 | + m->key_eq_fn = ((void*)0); | ||
| 12382 | + m->clone_fn = ((void*)0); | ||
| 12383 | + m->free_fn = ((void*)0); | ||
| 12384 | + m->key_values.cap = 0; | ||
| 12385 | + m->key_values.len = 0; | ||
| 12386 | + m->key_values.deletes = 0; | ||
| 12387 | + m->even_index = 0; | ||
| 12388 | + m->cached_hashbits = 0; | ||
| 12389 | + m->shift = 0; | ||
| 12390 | + m->extra_metas = 0; | ||
| 12391 | + m->has_string_keys = false; | ||
| 12392 | + m->len = 0; | ||
| 12393 | + } | ||
| 12394 | +} | ||
| 12395 | +void builtin__VAssertMetaInfo_free(VAssertMetaInfo* ami) { | ||
| 12396 | + { // Unsafe block | ||
| 12397 | + builtin__string_free(&ami->fpath); | ||
| 12398 | + builtin__string_free(&ami->fn_name); | ||
| 12399 | + builtin__string_free(&ami->src); | ||
| 12400 | + builtin__string_free(&ami->op); | ||
| 12401 | + builtin__string_free(&ami->llabel); | ||
| 12402 | + builtin__string_free(&ami->rlabel); | ||
| 12403 | + builtin__string_free(&ami->lvalue); | ||
| 12404 | + builtin__string_free(&ami->rvalue); | ||
| 12405 | + builtin__string_free(&ami->message); | ||
| 12406 | + } | ||
| 12407 | +} | ||
| 12408 | +void builtin__IError_free(IError* ie) { | ||
| 12409 | + { // Unsafe block | ||
| 12410 | + IError* cie = ((IError*)(ie)); | ||
| 12411 | + builtin___v_free(cie->_object); | ||
| 12412 | + } | ||
| 12413 | +} | ||
| 12414 | +VNORETURN void builtin__panic_option_not_set(string s) { | ||
| 12415 | + builtin___v_panic(builtin__string_plus_many(3, _MOV((string[3]){_S("option not set ("), s, _S(")")}))); | ||
| 12416 | + VUNREACHABLE(); | ||
| 12417 | + while(1); | ||
| 12418 | +} | ||
| 12419 | +VNORETURN void builtin__panic_result_not_set(string s) { | ||
| 12420 | + builtin___v_panic(builtin__string_plus_many(3, _MOV((string[3]){_S("result not set ("), s, _S(")")}))); | ||
| 12421 | + VUNREACHABLE(); | ||
| 12422 | + while(1); | ||
| 12423 | +} | ||
| 12424 | +VNORETURN void builtin___v_panic(string s) { | ||
| 12425 | + #if 0 | ||
| 12426 | + { | ||
| 12427 | + } | ||
| 12428 | + #elif defined(CUSTOM_DEFINE_v2_native_windows_pe_minimal) | ||
| 12429 | + { | ||
| 12430 | + } | ||
| 12431 | + #else | ||
| 12432 | + { | ||
| 12433 | + builtin__flush_stdout(); | ||
| 12434 | + builtin__eprint(_S("V panic: ")); | ||
| 12435 | + builtin__eprintln(s); | ||
| 12436 | + builtin__eprint(_S(" v hash: ")); | ||
| 12437 | + builtin__eprintln(builtin__vcurrent_hash()); | ||
| 12438 | + #if 1 | ||
| 12439 | + { | ||
| 12440 | + builtin__eprint(_S(" pid: ")); | ||
| 12441 | + ; | ||
| 12442 | + fprintf(stderr, "%p\n", ((voidptr)(builtin__v_getpid()))); | ||
| 12443 | + builtin__eprint(_S(" tid: ")); | ||
| 12444 | + ; | ||
| 12445 | + fprintf(stderr, "%p\n", ((voidptr)(builtin__v_gettid()))); | ||
| 12446 | + } | ||
| 12447 | + #endif | ||
| 12448 | + builtin__flush_stdout(); | ||
| 12449 | + #if defined(CUSTOM_DEFINE_exit_after_panic_message) | ||
| 12450 | + { | ||
| 12451 | + } | ||
| 12452 | + #elif defined(CUSTOM_DEFINE_no_backtrace) | ||
| 12453 | + { | ||
| 12454 | + } | ||
| 12455 | + #elif 0 | ||
| 12456 | + { | ||
| 12457 | + } | ||
| 12458 | + #else | ||
| 12459 | + { | ||
| 12460 | + #if defined(CUSTOM_DEFINE_use_libbacktrace) && !defined(__TINYC__) | ||
| 12461 | + { | ||
| 12462 | + } | ||
| 12463 | + #else | ||
| 12464 | + { | ||
| 12465 | + builtin__print_backtrace_skipping_top_frames(1); | ||
| 12466 | + } | ||
| 12467 | + #endif | ||
| 12468 | + exit(1); | ||
| 12469 | + VUNREACHABLE(); | ||
| 12470 | + } | ||
| 12471 | + #endif | ||
| 12472 | + } | ||
| 12473 | + #endif | ||
| 12474 | + exit(1); | ||
| 12475 | + VUNREACHABLE(); | ||
| 12476 | + for (;;) { | ||
| 12477 | + } | ||
| 12478 | + while(1); | ||
| 12479 | +} | ||
| 12480 | +string builtin__c_error_number_str(int errnum) { | ||
| 12481 | + string err_msg = _S(""); | ||
| 12482 | + #if 0 | ||
| 12483 | + { | ||
| 12484 | + } | ||
| 12485 | + #else | ||
| 12486 | + { | ||
| 12487 | + #if 1 | ||
| 12488 | + { | ||
| 12489 | + char* c_msg = strerror(errnum); | ||
| 12490 | + err_msg = ((string){.str = ((u8*)(c_msg)), .len = ((int)(strlen(c_msg))), .is_lit = 1}); | ||
| 12491 | + } | ||
| 12492 | + #endif | ||
| 12493 | + } | ||
| 12494 | + #endif | ||
| 12495 | + return err_msg; | ||
| 12496 | +} | ||
| 12497 | +VNORETURN void builtin__panic_n(string s, i64 number1) { | ||
| 12498 | + builtin___v_panic(builtin__string__plus(s, builtin__impl_i64_to_string(number1))); | ||
| 12499 | + VUNREACHABLE(); | ||
| 12500 | + while(1); | ||
| 12501 | +} | ||
| 12502 | +VNORETURN void builtin__panic_n2(string s, i64 number1, i64 number2) { | ||
| 12503 | + builtin___v_panic(builtin__string_plus_many(4, _MOV((string[4]){s, builtin__impl_i64_to_string(number1), _S(", "), builtin__impl_i64_to_string(number2)}))); | ||
| 12504 | + VUNREACHABLE(); | ||
| 12505 | + while(1); | ||
| 12506 | +} | ||
| 12507 | +VNORETURN VV_LOC void builtin__panic_n3(string s, i64 number1, i64 number2, i64 number3) { | ||
| 12508 | + builtin___v_panic(builtin__string_plus_many(6, _MOV((string[6]){s, builtin__impl_i64_to_string(number1), _S(", "), builtin__impl_i64_to_string(number2), _S(", "), builtin__impl_i64_to_string(number3)}))); | ||
| 12509 | + VUNREACHABLE(); | ||
| 12510 | + while(1); | ||
| 12511 | +} | ||
| 12512 | +VNORETURN void builtin__panic_error_number(string basestr, int errnum) { | ||
| 12513 | + builtin___v_panic(builtin__string__plus(basestr, builtin__c_error_number_str(errnum))); | ||
| 12514 | + VUNREACHABLE(); | ||
| 12515 | + while(1); | ||
| 12516 | +} | ||
| 12517 | +VV_LOC void builtin__set_stream_unbuffered(FILE* stream) { | ||
| 12518 | + setvbuf(stream, ((char*)(((void*)0))), _IONBF, ((usize)(0))); | ||
| 12519 | +} | ||
| 12520 | +void builtin__eprintln(string s) { | ||
| 12521 | + #if 0 | ||
| 12522 | + { | ||
| 12523 | + } | ||
| 12524 | + #elif 0 | ||
| 12525 | + { | ||
| 12526 | + } | ||
| 12527 | + #else | ||
| 12528 | + { | ||
| 12529 | + builtin__flush_stdout(); | ||
| 12530 | + builtin__flush_stderr(); | ||
| 12531 | + builtin___writeln_to_fd(2, s); | ||
| 12532 | + builtin__flush_stderr(); | ||
| 12533 | + } | ||
| 12534 | + #endif | ||
| 12535 | +} | ||
| 12536 | +void builtin__eprint(string s) { | ||
| 12537 | + #if 0 | ||
| 12538 | + { | ||
| 12539 | + } | ||
| 12540 | + #elif 0 | ||
| 12541 | + { | ||
| 12542 | + } | ||
| 12543 | + #else | ||
| 12544 | + { | ||
| 12545 | + builtin__flush_stdout(); | ||
| 12546 | + builtin__flush_stderr(); | ||
| 12547 | + builtin___write_buf_to_fd(2, s.str, s.len); | ||
| 12548 | + builtin__flush_stderr(); | ||
| 12549 | + } | ||
| 12550 | + #endif | ||
| 12551 | +} | ||
| 12552 | +void builtin__flush_stdout(void) { | ||
| 12553 | + #if defined(CUSTOM_DEFINE_v2_native_windows_pe_minimal) | ||
| 12554 | + { | ||
| 12555 | + } | ||
| 12556 | + #elif 0 | ||
| 12557 | + { | ||
| 12558 | + } | ||
| 12559 | + #elif defined(CUSTOM_DEFINE_builtin_write_buf_to_fd_should_use_c_write) | ||
| 12560 | + { | ||
| 12561 | + } | ||
| 12562 | + #else | ||
| 12563 | + { | ||
| 12564 | + fflush(stdout); | ||
| 12565 | + } | ||
| 12566 | + #endif | ||
| 12567 | +} | ||
| 12568 | +void builtin__flush_stderr(void) { | ||
| 12569 | + #if defined(CUSTOM_DEFINE_v2_native_windows_pe_minimal) | ||
| 12570 | + { | ||
| 12571 | + } | ||
| 12572 | + #elif 0 | ||
| 12573 | + { | ||
| 12574 | + } | ||
| 12575 | + #elif defined(CUSTOM_DEFINE_builtin_write_buf_to_fd_should_use_c_write) | ||
| 12576 | + { | ||
| 12577 | + } | ||
| 12578 | + #else | ||
| 12579 | + { | ||
| 12580 | + fflush(stderr); | ||
| 12581 | + } | ||
| 12582 | + #endif | ||
| 12583 | +} | ||
| 12584 | +void builtin__unbuffer_stdout(void) { | ||
| 12585 | + #if 0 | ||
| 12586 | + { | ||
| 12587 | + } | ||
| 12588 | + #elif 0 | ||
| 12589 | + { | ||
| 12590 | + } | ||
| 12591 | + #elif defined(CUSTOM_DEFINE_builtin_write_buf_to_fd_should_use_c_write) | ||
| 12592 | + { | ||
| 12593 | + } | ||
| 12594 | + #else | ||
| 12595 | + { | ||
| 12596 | + builtin__set_stream_unbuffered(stdout); | ||
| 12597 | + } | ||
| 12598 | + #endif | ||
| 12599 | +} | ||
| 12600 | +void builtin__print(string s) { | ||
| 12601 | + #if 0 | ||
| 12602 | + { | ||
| 12603 | + } | ||
| 12604 | + #elif 0 | ||
| 12605 | + { | ||
| 12606 | + } | ||
| 12607 | + #elif 0 | ||
| 12608 | + { | ||
| 12609 | + } | ||
| 12610 | + #else | ||
| 12611 | + { | ||
| 12612 | + builtin___write_buf_to_fd(1, s.str, s.len); | ||
| 12613 | + } | ||
| 12614 | + #endif | ||
| 12615 | +} | ||
| 12616 | +void builtin__println(string s) { | ||
| 12617 | + #if 0 | ||
| 12618 | + { | ||
| 12619 | + } | ||
| 12620 | + #elif 0 | ||
| 12621 | + { | ||
| 12622 | + } | ||
| 12623 | + #elif 0 | ||
| 12624 | + { | ||
| 12625 | + } | ||
| 12626 | + #else | ||
| 12627 | + { | ||
| 12628 | + builtin___writeln_to_fd(1, s); | ||
| 12629 | + } | ||
| 12630 | + #endif | ||
| 12631 | +} | ||
| 12632 | +VV_LOC void builtin___writeln_to_fd(int fd, string s) { | ||
| 12633 | + #if defined(CUSTOM_DEFINE_builtin_writeln_should_write_at_once) | ||
| 12634 | + { | ||
| 12635 | + } | ||
| 12636 | + #else | ||
| 12637 | + { | ||
| 12638 | + u8 lf = ((u8)('\n')); | ||
| 12639 | + builtin___write_buf_to_fd(fd, s.str, s.len); | ||
| 12640 | + builtin___write_buf_to_fd(fd, &lf, 1); | ||
| 12641 | + } | ||
| 12642 | + #endif | ||
| 12643 | +} | ||
| 12644 | +VV_LOC void builtin___write_buf_to_fd(int fd, u8* buf, int buf_len) { | ||
| 12645 | + if (buf_len <= 0) { | ||
| 12646 | + return; | ||
| 12647 | + } | ||
| 12648 | + #if 0 | ||
| 12649 | + { | ||
| 12650 | + } | ||
| 12651 | + #else | ||
| 12652 | + { | ||
| 12653 | + u8* ptr = buf; | ||
| 12654 | + isize remaining_bytes = ((isize)(buf_len)); | ||
| 12655 | + isize x = ((isize)(0)); | ||
| 12656 | + #if 0 | ||
| 12657 | + { | ||
| 12658 | + } | ||
| 12659 | + #else | ||
| 12660 | + { | ||
| 12661 | + voidptr stream = ((voidptr)(stdout)); | ||
| 12662 | + if (fd == 2) { | ||
| 12663 | + stream = ((voidptr)(stderr)); | ||
| 12664 | + } | ||
| 12665 | + { // Unsafe block | ||
| 12666 | + for (;;) { | ||
| 12667 | + if (!(remaining_bytes > 0)) break; | ||
| 12668 | + x = ((isize)(fwrite(ptr, 1, remaining_bytes, stream))); | ||
| 12669 | + if (x <= 0) { | ||
| 12670 | + break; | ||
| 12671 | + } | ||
| 12672 | + ptr += x; | ||
| 12673 | + remaining_bytes -= x; | ||
| 12674 | + } | ||
| 12675 | + } | ||
| 12676 | + } | ||
| 12677 | + #endif | ||
| 12678 | + } | ||
| 12679 | + #endif | ||
| 12680 | +} | ||
| 12681 | +string builtin__reuse_data_as_string(Array_u8 buffer) { | ||
| 12682 | + return ((string){.str = buffer.data, .len = buffer.len, .is_lit = 1}); | ||
| 12683 | +} | ||
| 12684 | +Array_u8 builtin__reuse_string_as_data(string s) { | ||
| 12685 | + array res = ((array){.data = (voidptr)s.str,.offset = 0,.len = s.len,.cap = 0,.flags = ((ArrayFlags__nogrow | ArrayFlags__noshrink) | ArrayFlags__nofree),.element_size = 1,}); | ||
| 12686 | + return res; | ||
| 12687 | +} | ||
| 12688 | +string builtin__rune_str(rune c) { | ||
| 12689 | + return builtin__utf32_to_str(((u32)(c))); | ||
| 12690 | +} | ||
| 12691 | +string Array_rune_string(Array_rune ra) { | ||
| 12692 | + strings__Builder sb = strings__new_builder(ra.len); | ||
| 12693 | + strings__Builder_write_runes(&sb, ra); | ||
| 12694 | + string res = strings__Builder_str(&sb); | ||
| 12695 | + strings__Builder_free(&sb); | ||
| 12696 | + return res; | ||
| 12697 | +} | ||
| 12698 | +string builtin__rune_repeat(rune c, int count) { | ||
| 12699 | + if (count <= 0) { | ||
| 12700 | + return _S(""); | ||
| 12701 | + } else if (count == 1) { | ||
| 12702 | + return builtin__rune_str(c); | ||
| 12703 | + } | ||
| 12704 | + Array_fixed_u8_5 buffer = {0}; | ||
| 12705 | + string res = builtin__utf32_to_str_no_malloc(((u32)(c)), &buffer[0]); | ||
| 12706 | + return builtin__string_repeat(res, count); | ||
| 12707 | +} | ||
| 12708 | +Array_u8 builtin__rune_bytes(rune c) { | ||
| 12709 | + Array_u8 res = builtin____new_array_with_default(0, 5, sizeof(u8), 0); | ||
| 12710 | + u8* buf = ((u8*)(res.data)); | ||
| 12711 | + res.len = builtin__utf32_decode_to_buffer(((u32)(c)), buf); | ||
| 12712 | + return res; | ||
| 12713 | +} | ||
| 12714 | +int builtin__rune_length_in_bytes(rune c) { | ||
| 12715 | + u32 code = ((u32)(c)); | ||
| 12716 | + if (code <= 0x7F) { | ||
| 12717 | + return 1; | ||
| 12718 | + } else if (code <= 0x7FF) { | ||
| 12719 | + return 2; | ||
| 12720 | + } else if (0xD800 <= code && code <= 0xDFFF) { | ||
| 12721 | + return -1; | ||
| 12722 | + } else if (code <= 0xFFFF) { | ||
| 12723 | + return 3; | ||
| 12724 | + } else if (code <= 0x10FFFF) { | ||
| 12725 | + return 4; | ||
| 12726 | + } | ||
| 12727 | + return -1; | ||
| 12728 | +} | ||
| 12729 | +rune builtin__rune_to_upper(rune c) { | ||
| 12730 | + if (c < 0x80) { | ||
| 12731 | + if (c >= 'a' && c <= 'z') { | ||
| 12732 | + return c - 32; | ||
| 12733 | + } | ||
| 12734 | + return c; | ||
| 12735 | + } | ||
| 12736 | + return builtin__rune_map_to(c, MapMode__to_upper); | ||
| 12737 | +} | ||
| 12738 | +rune builtin__rune_to_lower(rune c) { | ||
| 12739 | + if (c < 0x80) { | ||
| 12740 | + if (c >= 'A' && c <= 'Z') { | ||
| 12741 | + return c + 32; | ||
| 12742 | + } | ||
| 12743 | + return c; | ||
| 12744 | + } | ||
| 12745 | + return builtin__rune_map_to(c, MapMode__to_lower); | ||
| 12746 | +} | ||
| 12747 | +rune builtin__rune_to_title(rune c) { | ||
| 12748 | + if (c < 0x80) { | ||
| 12749 | + if (c >= 'a' && c <= 'z') { | ||
| 12750 | + return c - 32; | ||
| 12751 | + } | ||
| 12752 | + return c; | ||
| 12753 | + } | ||
| 12754 | + return builtin__rune_map_to(c, MapMode__to_title); | ||
| 12755 | +} | ||
| 12756 | +VV_LOC rune builtin__rune_map_to(rune c, MapMode mode) { | ||
| 12757 | + int start = 0; | ||
| 12758 | + int end = VSAFE_DIV_int(1264 , _const_rune_maps_columns_in_row); | ||
| 12759 | + for (;;) { | ||
| 12760 | + if (!(start < end)) break; | ||
| 12761 | + int middle = VSAFE_DIV_int((start + end) , 2); | ||
| 12762 | + i32* cur_map = &_const_rune_maps[middle * _const_rune_maps_columns_in_row]; | ||
| 12763 | + if (c >= ((u32)(*cur_map)) && c <= ((u32)(*(cur_map + 1)))) { | ||
| 12764 | + i32 offset = ((mode == MapMode__to_upper || mode == MapMode__to_title) ? (*(cur_map + 2)) : (*(cur_map + 3))); | ||
| 12765 | + if (offset == _const_rune_maps_ul) { | ||
| 12766 | + rune cnt = VSAFE_MOD_rune(((rune)(c - *cur_map)) , 2); | ||
| 12767 | + if (mode == MapMode__to_lower) { | ||
| 12768 | + return c + 1 - cnt; | ||
| 12769 | + } | ||
| 12770 | + return c - cnt; | ||
| 12771 | + } else if (offset == _const_rune_maps_utl) { | ||
| 12772 | + rune cnt = VSAFE_MOD_rune(((rune)(c - *cur_map)) , 3); | ||
| 12773 | + if (mode == MapMode__to_upper) { | ||
| 12774 | + return c - cnt; | ||
| 12775 | + } else if (mode == MapMode__to_lower) { | ||
| 12776 | + return c + 2 - cnt; | ||
| 12777 | + } | ||
| 12778 | + return c + 1 - cnt; | ||
| 12779 | + } | ||
| 12780 | + return (rune)(c + offset); | ||
| 12781 | + } | ||
| 12782 | + if (c < ((u32)(*cur_map))) { | ||
| 12783 | + end = middle; | ||
| 12784 | + } else { | ||
| 12785 | + start = middle + 1; | ||
| 12786 | + } | ||
| 12787 | + } | ||
| 12788 | + return c; | ||
| 12789 | +} | ||
| 12790 | +VV_LOC int builtin__mapnode_find_key(mapnode* n, string k) { | ||
| 12791 | + int idx = 0; | ||
| 12792 | + for (;;) { | ||
| 12793 | + if (!(idx < n->len && builtin__string__lt(n->keys[builtin__v_fixed_index(idx, 11)], k))) break; | ||
| 12794 | + idx++; | ||
| 12795 | + } | ||
| 12796 | + return idx; | ||
| 12797 | +} | ||
| 12798 | +VV_LOC bool builtin__mapnode_remove_key(mapnode* n, string k) { | ||
| 12799 | + int idx = builtin__mapnode_find_key(n, k); | ||
| 12800 | + if (idx < n->len && builtin__string__eq(n->keys[builtin__v_fixed_index(idx, 11)], k)) { | ||
| 12801 | + if (n->children == ((void*)0)) { | ||
| 12802 | + builtin__mapnode_remove_from_leaf(n, idx); | ||
| 12803 | + } else { | ||
| 12804 | + builtin__mapnode_remove_from_non_leaf(n, idx); | ||
| 12805 | + } | ||
| 12806 | + return true; | ||
| 12807 | + } else { | ||
| 12808 | + if (n->children == ((void*)0)) { | ||
| 12809 | + return false; | ||
| 12810 | + } | ||
| 12811 | + bool flag = (idx == n->len ? (true) : (false)); | ||
| 12812 | + if (((mapnode*)(n->children[idx]))->len < _const_degree) { | ||
| 12813 | + builtin__mapnode_fill(n, idx); | ||
| 12814 | + } | ||
| 12815 | + mapnode* node = ((mapnode*)(((void*)0))); | ||
| 12816 | + if (flag && idx > n->len) { | ||
| 12817 | + node = ((mapnode*)(n->children[idx - 1])); | ||
| 12818 | + } else { | ||
| 12819 | + node = ((mapnode*)(n->children[idx])); | ||
| 12820 | + } | ||
| 12821 | + return builtin__mapnode_remove_key(node, k); | ||
| 12822 | + } | ||
| 12823 | + return 0; | ||
| 12824 | +} | ||
| 12825 | +VV_LOC void builtin__mapnode_remove_from_leaf(mapnode* n, int idx) { | ||
| 12826 | + for (int i = idx + 1; i < n->len; i++) { | ||
| 12827 | + n->keys[builtin__v_fixed_index(i - 1, 11)] = n->keys[builtin__v_fixed_index(i, 11)]; | ||
| 12828 | + n->values[builtin__v_fixed_index(i - 1, 11)] = n->values[builtin__v_fixed_index(i, 11)]; | ||
| 12829 | + } | ||
| 12830 | + n->len--; | ||
| 12831 | +} | ||
| 12832 | +VV_LOC void builtin__mapnode_remove_from_non_leaf(mapnode* n, int idx) { | ||
| 12833 | + string k = n->keys[builtin__v_fixed_index(idx, 11)]; | ||
| 12834 | + if (((mapnode*)(n->children[idx]))->len >= _const_degree) { | ||
| 12835 | + mapnode* current = ((mapnode*)(n->children[idx])); | ||
| 12836 | + for (;;) { | ||
| 12837 | + if (!(current->children != ((void*)0))) break; | ||
| 12838 | + current = ((mapnode*)(current->children[current->len])); | ||
| 12839 | + } | ||
| 12840 | + string predecessor = current->keys[builtin__v_fixed_index(current->len - 1, 11)]; | ||
| 12841 | + n->keys[builtin__v_fixed_index(idx, 11)] = predecessor; | ||
| 12842 | + n->values[builtin__v_fixed_index(idx, 11)] = current->values[builtin__v_fixed_index(current->len - 1, 11)]; | ||
| 12843 | + mapnode* node = ((mapnode*)(n->children[idx])); | ||
| 12844 | + builtin__mapnode_remove_key(node, predecessor); | ||
| 12845 | + } else if (((mapnode*)(n->children[idx + 1]))->len >= _const_degree) { | ||
| 12846 | + mapnode* current = ((mapnode*)(n->children[idx + 1])); | ||
| 12847 | + for (;;) { | ||
| 12848 | + if (!(current->children != ((void*)0))) break; | ||
| 12849 | + current = ((mapnode*)(current->children[0])); | ||
| 12850 | + } | ||
| 12851 | + string successor = current->keys[0]; | ||
| 12852 | + n->keys[builtin__v_fixed_index(idx, 11)] = successor; | ||
| 12853 | + n->values[builtin__v_fixed_index(idx, 11)] = current->values[0]; | ||
| 12854 | + mapnode* node = ((mapnode*)(n->children[idx + 1])); | ||
| 12855 | + builtin__mapnode_remove_key(node, successor); | ||
| 12856 | + } else { | ||
| 12857 | + builtin__mapnode_merge(n, idx); | ||
| 12858 | + mapnode* node = ((mapnode*)(n->children[idx])); | ||
| 12859 | + builtin__mapnode_remove_key(node, k); | ||
| 12860 | + } | ||
| 12861 | +} | ||
| 12862 | +VV_LOC void builtin__mapnode_fill(mapnode* n, int idx) { | ||
| 12863 | + if (idx != 0 && ((mapnode*)(n->children[idx - 1]))->len >= _const_degree) { | ||
| 12864 | + builtin__mapnode_borrow_from_prev(n, idx); | ||
| 12865 | + } else if (idx != n->len && ((mapnode*)(n->children[idx + 1]))->len >= _const_degree) { | ||
| 12866 | + builtin__mapnode_borrow_from_next(n, idx); | ||
| 12867 | + } else if (idx != n->len) { | ||
| 12868 | + builtin__mapnode_merge(n, idx); | ||
| 12869 | + } else { | ||
| 12870 | + builtin__mapnode_merge(n, idx - 1); | ||
| 12871 | + } | ||
| 12872 | +} | ||
| 12873 | +VV_LOC void builtin__mapnode_borrow_from_prev(mapnode* n, int idx) { | ||
| 12874 | + mapnode* child = ((mapnode*)(n->children[idx])); | ||
| 12875 | + mapnode* sibling = ((mapnode*)(n->children[idx - 1])); | ||
| 12876 | + for (int i = child->len - 1; i >= 0; i--) { | ||
| 12877 | + child->keys[builtin__v_fixed_index(i + 1, 11)] = child->keys[builtin__v_fixed_index(i, 11)]; | ||
| 12878 | + child->values[builtin__v_fixed_index(i + 1, 11)] = child->values[builtin__v_fixed_index(i, 11)]; | ||
| 12879 | + } | ||
| 12880 | + if (child->children != ((void*)0)) { | ||
| 12881 | + for (int i = child->len; i >= 0; i--) { | ||
| 12882 | + { // Unsafe block | ||
| 12883 | + child->children[i + 1] = child->children[i]; | ||
| 12884 | + } | ||
| 12885 | + } | ||
| 12886 | + } | ||
| 12887 | + child->keys[0] = n->keys[builtin__v_fixed_index(idx - 1, 11)]; | ||
| 12888 | + child->values[0] = n->values[builtin__v_fixed_index(idx - 1, 11)]; | ||
| 12889 | + if (child->children != ((void*)0)) { | ||
| 12890 | + { // Unsafe block | ||
| 12891 | + child->children[0] = sibling->children[sibling->len]; | ||
| 12892 | + } | ||
| 12893 | + } | ||
| 12894 | + n->keys[builtin__v_fixed_index(idx - 1, 11)] = sibling->keys[builtin__v_fixed_index(sibling->len - 1, 11)]; | ||
| 12895 | + n->values[builtin__v_fixed_index(idx - 1, 11)] = sibling->values[builtin__v_fixed_index(sibling->len - 1, 11)]; | ||
| 12896 | + child->len++; | ||
| 12897 | + sibling->len--; | ||
| 12898 | +} | ||
| 12899 | +VV_LOC void builtin__mapnode_borrow_from_next(mapnode* n, int idx) { | ||
| 12900 | + mapnode* child = ((mapnode*)(n->children[idx])); | ||
| 12901 | + mapnode* sibling = ((mapnode*)(n->children[idx + 1])); | ||
| 12902 | + child->keys[builtin__v_fixed_index(child->len, 11)] = n->keys[builtin__v_fixed_index(idx, 11)]; | ||
| 12903 | + child->values[builtin__v_fixed_index(child->len, 11)] = n->values[builtin__v_fixed_index(idx, 11)]; | ||
| 12904 | + if (child->children != ((void*)0)) { | ||
| 12905 | + { // Unsafe block | ||
| 12906 | + child->children[child->len + 1] = sibling->children[0]; | ||
| 12907 | + } | ||
| 12908 | + } | ||
| 12909 | + n->keys[builtin__v_fixed_index(idx, 11)] = sibling->keys[0]; | ||
| 12910 | + n->values[builtin__v_fixed_index(idx, 11)] = sibling->values[0]; | ||
| 12911 | + for (int i = 1; i < sibling->len; i++) { | ||
| 12912 | + sibling->keys[builtin__v_fixed_index(i - 1, 11)] = sibling->keys[builtin__v_fixed_index(i, 11)]; | ||
| 12913 | + sibling->values[builtin__v_fixed_index(i - 1, 11)] = sibling->values[builtin__v_fixed_index(i, 11)]; | ||
| 12914 | + } | ||
| 12915 | + if (sibling->children != ((void*)0)) { | ||
| 12916 | + for (int i = 1; i <= sibling->len; i++) { | ||
| 12917 | + { // Unsafe block | ||
| 12918 | + sibling->children[i - 1] = sibling->children[i]; | ||
| 12919 | + } | ||
| 12920 | + } | ||
| 12921 | + } | ||
| 12922 | + child->len++; | ||
| 12923 | + sibling->len--; | ||
| 12924 | +} | ||
| 12925 | +VV_LOC void builtin__mapnode_merge(mapnode* n, int idx) { | ||
| 12926 | + mapnode* child = ((mapnode*)(n->children[idx])); | ||
| 12927 | + mapnode* sibling = ((mapnode*)(n->children[idx + 1])); | ||
| 12928 | + child->keys[builtin__v_fixed_index(_const_mid_index, 11)] = n->keys[builtin__v_fixed_index(idx, 11)]; | ||
| 12929 | + child->values[builtin__v_fixed_index(_const_mid_index, 11)] = n->values[builtin__v_fixed_index(idx, 11)]; | ||
| 12930 | + for (int i = 0; i < sibling->len; ++i) { | ||
| 12931 | + child->keys[builtin__v_fixed_index(i + _const_degree, 11)] = sibling->keys[builtin__v_fixed_index(i, 11)]; | ||
| 12932 | + child->values[builtin__v_fixed_index(i + _const_degree, 11)] = sibling->values[builtin__v_fixed_index(i, 11)]; | ||
| 12933 | + } | ||
| 12934 | + if (child->children != ((void*)0)) { | ||
| 12935 | + for (int i = 0; i <= sibling->len; i++) { | ||
| 12936 | + { // Unsafe block | ||
| 12937 | + child->children[i + _const_degree] = sibling->children[i]; | ||
| 12938 | + } | ||
| 12939 | + } | ||
| 12940 | + } | ||
| 12941 | + for (int i = idx + 1; i < n->len; i++) { | ||
| 12942 | + n->keys[builtin__v_fixed_index(i - 1, 11)] = n->keys[builtin__v_fixed_index(i, 11)]; | ||
| 12943 | + n->values[builtin__v_fixed_index(i - 1, 11)] = n->values[builtin__v_fixed_index(i, 11)]; | ||
| 12944 | + } | ||
| 12945 | + for (int i = idx + 2; i <= n->len; i++) { | ||
| 12946 | + { // Unsafe block | ||
| 12947 | + n->children[i - 1] = n->children[i]; | ||
| 12948 | + } | ||
| 12949 | + } | ||
| 12950 | + child->len += sibling->len + 1; | ||
| 12951 | + n->len--; | ||
| 12952 | +} | ||
| 12953 | +void builtin__SortedMap_delete(SortedMap* m, string key) { | ||
| 12954 | + if (m->root->len == 0) { | ||
| 12955 | + return; | ||
| 12956 | + } | ||
| 12957 | + bool removed = builtin__mapnode_remove_key(m->root, key); | ||
| 12958 | + if (removed) { | ||
| 12959 | + m->len--; | ||
| 12960 | + } | ||
| 12961 | + if (m->root->len == 0) { | ||
| 12962 | + if (m->root->children == ((void*)0)) { | ||
| 12963 | + return; | ||
| 12964 | + } else { | ||
| 12965 | + m->root = ((mapnode*)(m->root->children[0])); | ||
| 12966 | + } | ||
| 12967 | + } | ||
| 12968 | +} | ||
| 12969 | +VV_LOC int builtin__mapnode_subkeys(mapnode* n, Array_string* keys, int at) { | ||
| 12970 | + int position = at; | ||
| 12971 | + if (n->children != ((void*)0)) { | ||
| 12972 | + for (int i = 0; i < n->len; ++i) { | ||
| 12973 | + mapnode* child = ((mapnode*)(n->children[i])); | ||
| 12974 | + position += builtin__mapnode_subkeys(child, keys, position); | ||
| 12975 | + builtin__array_set(keys, position, &(string[]) { n->keys[builtin__v_fixed_index(i, 11)] }); | ||
| 12976 | + position++; | ||
| 12977 | + } | ||
| 12978 | + mapnode* child = ((mapnode*)(n->children[n->len])); | ||
| 12979 | + position += builtin__mapnode_subkeys(child, keys, position); | ||
| 12980 | + } else { | ||
| 12981 | + for (int i = 0; i < n->len; ++i) { | ||
| 12982 | + builtin__array_set(keys, (int)(position + i), &(string[]) { n->keys[builtin__v_fixed_index(i, 11)] }); | ||
| 12983 | + } | ||
| 12984 | + position += n->len; | ||
| 12985 | + } | ||
| 12986 | + return position - at; | ||
| 12987 | +} | ||
| 12988 | +Array_string builtin__SortedMap_keys(SortedMap* m) { | ||
| 12989 | + Array_string keys = builtin____new_array_with_default(m->len, 0, sizeof(string), &(string[]){_S("")}); | ||
| 12990 | + if (m->root == ((void*)0) || m->root->len == 0) { | ||
| 12991 | + return keys; | ||
| 12992 | + } | ||
| 12993 | + builtin__mapnode_subkeys(m->root, &keys, 0); | ||
| 12994 | + return keys; | ||
| 12995 | +} | ||
| 12996 | +VV_LOC void builtin__mapnode_free(mapnode* n) { | ||
| 12997 | +} | ||
| 12998 | +void builtin__SortedMap_free(SortedMap* m) { | ||
| 12999 | + if (m->root == ((void*)0)) { | ||
| 13000 | + return; | ||
| 13001 | + } | ||
| 13002 | + builtin__mapnode_free(m->root); | ||
| 13003 | +} | ||
| 13004 | +Array_rune builtin__string_runes(string s) { | ||
| 13005 | + Array_rune runes = builtin____new_array_with_default(0, s.len, sizeof(rune), 0); | ||
| 13006 | + for (int i = 0; i < s.len; i++) { | ||
| 13007 | + multi_return_rune_int mr_2797 = builtin__utf8_decode_rune(&s.str[i], s.len - i); | ||
| 13008 | + rune r = mr_2797.arg0; | ||
| 13009 | + int char_len = mr_2797.arg1; | ||
| 13010 | + builtin__array_push((array*)&runes, _MOV((rune[]){ r })); | ||
| 13011 | + if (char_len > 1) { | ||
| 13012 | + i += char_len - 1; | ||
| 13013 | + } | ||
| 13014 | + } | ||
| 13015 | + return runes; | ||
| 13016 | +} | ||
| 13017 | +Array_string builtin__string_graphemes(string s) { | ||
| 13018 | + return builtin__string_graphemes_impl(s); | ||
| 13019 | +} | ||
| 13020 | +string builtin__cstring_to_vstring(const char* const_s) { | ||
| 13021 | + string s = builtin__tos2(((byteptr)(const_s))); | ||
| 13022 | + return builtin__string_clone(s); | ||
| 13023 | +} | ||
| 13024 | +string builtin__tos_clone(const u8* const_s) { | ||
| 13025 | + string s = builtin__tos2(((u8*)(const_s))); | ||
| 13026 | + return builtin__string_clone(s); | ||
| 13027 | +} | ||
| 13028 | +string builtin__tos(u8* s, int len) { | ||
| 13029 | + if (s == 0) { | ||
| 13030 | + builtin___v_panic(_S("tos(): nil string")); | ||
| 13031 | + VUNREACHABLE(); | ||
| 13032 | + } | ||
| 13033 | + return ((string){.str = s, .len = len}); | ||
| 13034 | +} | ||
| 13035 | +string builtin__tos2(u8* s) { | ||
| 13036 | + if (s == 0) { | ||
| 13037 | + builtin___v_panic(_S("tos2: nil string")); | ||
| 13038 | + VUNREACHABLE(); | ||
| 13039 | + } | ||
| 13040 | + return ((string){.str = s, .len = builtin__vstrlen(s)}); | ||
| 13041 | +} | ||
| 13042 | +string builtin__tos3(char* s) { | ||
| 13043 | + if (s == 0) { | ||
| 13044 | + builtin___v_panic(_S("tos3: nil string")); | ||
| 13045 | + VUNREACHABLE(); | ||
| 13046 | + } | ||
| 13047 | + return ((string){.str = ((u8*)(s)), .len = builtin__vstrlen_char(s)}); | ||
| 13048 | +} | ||
| 13049 | +string builtin__tos4(u8* s) { | ||
| 13050 | + if (s == 0) { | ||
| 13051 | + return _S(""); | ||
| 13052 | + } | ||
| 13053 | + return ((string){.str = s, .len = builtin__vstrlen(s)}); | ||
| 13054 | +} | ||
| 13055 | +string builtin__tos5(char* s) { | ||
| 13056 | + if (s == 0) { | ||
| 13057 | + return _S(""); | ||
| 13058 | + } | ||
| 13059 | + return ((string){.str = ((u8*)(s)), .len = builtin__vstrlen_char(s)}); | ||
| 13060 | +} | ||
| 13061 | +string builtin__u8_vstring(u8* bp) { | ||
| 13062 | + return ((string){.str = bp, .len = builtin__vstrlen(bp)}); | ||
| 13063 | +} | ||
| 13064 | +string builtin__u8_vstring_with_len(u8* bp, int len) { | ||
| 13065 | + return ((string){.str = bp, .len = len, .is_lit = 0}); | ||
| 13066 | +} | ||
| 13067 | +string builtin__char_vstring(char* cp) { | ||
| 13068 | + return ((string){.str = ((u8*)(cp)), .len = builtin__vstrlen_char(cp), .is_lit = 0}); | ||
| 13069 | +} | ||
| 13070 | +string builtin__char_vstring_with_len(char* cp, int len) { | ||
| 13071 | + return ((string){.str = ((u8*)(cp)), .len = len, .is_lit = 0}); | ||
| 13072 | +} | ||
| 13073 | +string builtin__u8_vstring_literal(u8* bp) { | ||
| 13074 | + return ((string){.str = bp, .len = builtin__vstrlen(bp), .is_lit = 1}); | ||
| 13075 | +} | ||
| 13076 | +string builtin__u8_vstring_literal_with_len(u8* bp, int len) { | ||
| 13077 | + return ((string){.str = bp, .len = len, .is_lit = 1}); | ||
| 13078 | +} | ||
| 13079 | +string builtin__char_vstring_literal(char* cp) { | ||
| 13080 | + return ((string){.str = ((u8*)(cp)), .len = builtin__vstrlen_char(cp), .is_lit = 1}); | ||
| 13081 | +} | ||
| 13082 | +string builtin__char_vstring_literal_with_len(char* cp, int len) { | ||
| 13083 | + return ((string){.str = ((u8*)(cp)), .len = len, .is_lit = 1}); | ||
| 13084 | +} | ||
| 13085 | +int builtin__string_len_utf8(string s) { | ||
| 13086 | + int l = 0; | ||
| 13087 | + int i = 0; | ||
| 13088 | + for (;;) { | ||
| 13089 | + if (!(i < s.len)) break; | ||
| 13090 | + l++; | ||
| 13091 | + i += ((int)((((v__rshift_u32(((u32)(0xe5000000U)), (u64)(((v__rshift_u8(s.str[i], (u64)3)) & 0x1e)))) & 3)) + 1)); | ||
| 13092 | + } | ||
| 13093 | + return l; | ||
| 13094 | +} | ||
| 13095 | +bool builtin__string_is_pure_ascii(string s) { | ||
| 13096 | + for (int i = 0; i < s.len; ++i) { | ||
| 13097 | + if (s.str[ i] >= 0x80) { | ||
| 13098 | + return false; | ||
| 13099 | + } | ||
| 13100 | + } | ||
| 13101 | + return true; | ||
| 13102 | +} | ||
| 13103 | +string builtin__string_clone(string a) { | ||
| 13104 | + if (a.len <= 0) { | ||
| 13105 | + return _S(""); | ||
| 13106 | + } | ||
| 13107 | + string _t2 = ((string){.str = builtin__malloc_noscan(a.len + 1), .len = a.len}); | ||
| 13108 | + string b = _t2; | ||
| 13109 | + { // Unsafe block | ||
| 13110 | + builtin__vmemcpy(b.str, a.str, a.len); | ||
| 13111 | + b.str[a.len] = 0; | ||
| 13112 | + } | ||
| 13113 | + return b; | ||
| 13114 | +} | ||
| 13115 | +string builtin__string_replace_once(string s, string rep, string with) { | ||
| 13116 | + int idx = builtin__string_index_(s, rep); | ||
| 13117 | + if (idx == -1) { | ||
| 13118 | + return builtin__string_clone(s); | ||
| 13119 | + } | ||
| 13120 | + return builtin__string_plus_two(builtin__string_substr_unsafe(s, 0, idx), with, builtin__string_substr_unsafe(s, idx + rep.len, s.len)); | ||
| 13121 | +} | ||
| 13122 | +string builtin__string_replace(string s, string rep, string with) { | ||
| 13123 | + if (s.len == 0 || rep.len == 0 || rep.len > s.len) { | ||
| 13124 | + return builtin__string_clone(s); | ||
| 13125 | + } | ||
| 13126 | + if (!builtin__string_contains(s, rep)) { | ||
| 13127 | + return builtin__string_clone(s); | ||
| 13128 | + } | ||
| 13129 | + int pidxs_len = 0; | ||
| 13130 | + int pidxs_cap = VSAFE_DIV_int(s.len , rep.len); | ||
| 13131 | + Array_fixed_int_10 stack_idxs = {0}; | ||
| 13132 | + int* pidxs = &stack_idxs[0]; | ||
| 13133 | + if (pidxs_cap > _const_replace_stack_buffer_size) { | ||
| 13134 | + pidxs = ((int*)(builtin___v_malloc(((int)(sizeof(int))) * pidxs_cap))); | ||
| 13135 | + } | ||
| 13136 | + int idx = 0; | ||
| 13137 | + for (;;) { | ||
| 13138 | + idx = builtin__string_index_after_(s, rep, idx); | ||
| 13139 | + if (idx == -1) { | ||
| 13140 | + break; | ||
| 13141 | + } | ||
| 13142 | + { // Unsafe block | ||
| 13143 | + pidxs[pidxs_len] = idx; | ||
| 13144 | + pidxs_len++; | ||
| 13145 | + } | ||
| 13146 | + idx += rep.len; | ||
| 13147 | + } | ||
| 13148 | + if (pidxs_len == 0) { | ||
| 13149 | + string _t3 = builtin__string_clone(s); | ||
| 13150 | + { // defer begin | ||
| 13151 | + if (pidxs_cap > _const_replace_stack_buffer_size) { | ||
| 13152 | + builtin___v_free(pidxs); | ||
| 13153 | + } | ||
| 13154 | + } // defer end | ||
| 13155 | + return _t3; | ||
| 13156 | + } | ||
| 13157 | + int new_len = s.len + pidxs_len * (with.len - rep.len); | ||
| 13158 | + u8* b = builtin__malloc_noscan(new_len + 1); | ||
| 13159 | + int b_i = 0; | ||
| 13160 | + int s_idx = 0; | ||
| 13161 | + for (int j = 0; j < pidxs_len; ++j) { | ||
| 13162 | + int rep_pos = pidxs[j]; | ||
| 13163 | + int before_len = rep_pos - s_idx; | ||
| 13164 | + builtin__vmemcpy(&b[b_i], &s.str[s_idx], before_len); | ||
| 13165 | + b_i += before_len; | ||
| 13166 | + s_idx = rep_pos + rep.len; | ||
| 13167 | + builtin__vmemcpy(&b[b_i], &with.str[0], with.len); | ||
| 13168 | + b_i += with.len; | ||
| 13169 | + } | ||
| 13170 | + if (s_idx < s.len) { | ||
| 13171 | + builtin__vmemcpy(&b[b_i], &s.str[s_idx], s.len - s_idx); | ||
| 13172 | + } | ||
| 13173 | + { // Unsafe block | ||
| 13174 | + b[new_len] = 0; | ||
| 13175 | + string _t4 = builtin__tos(b, new_len); | ||
| 13176 | + { // defer begin | ||
| 13177 | + if (pidxs_cap > _const_replace_stack_buffer_size) { | ||
| 13178 | + builtin___v_free(pidxs); | ||
| 13179 | + } | ||
| 13180 | + } // defer end | ||
| 13181 | + return _t4; | ||
| 13182 | + } | ||
| 13183 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 13184 | +} | ||
| 13185 | +string builtin__string_replace_each(string s, Array_string vals) { | ||
| 13186 | + if (s.len == 0 || vals.len == 0) { | ||
| 13187 | + return builtin__string_clone(s); | ||
| 13188 | + } | ||
| 13189 | + if (VSAFE_MOD_int(vals.len , 2) != 0) { | ||
| 13190 | + builtin__eprintln(_S("string.replace_each(): odd number of strings")); | ||
| 13191 | + return builtin__string_clone(s); | ||
| 13192 | + } | ||
| 13193 | + int new_len = s.len; | ||
| 13194 | + Array_RepIndex idxs = builtin____new_array_with_default(0, 6, sizeof(RepIndex), 0); | ||
| 13195 | + int idx = 0; | ||
| 13196 | + string s_ = builtin__string_clone(s); | ||
| 13197 | + for (int rep_i = 0; rep_i < vals.len; rep_i += 2) { | ||
| 13198 | + string rep = ((string*)vals.data)[rep_i]; | ||
| 13199 | + string with = ((string*)vals.data)[rep_i + 1]; | ||
| 13200 | + for (;;) { | ||
| 13201 | + idx = builtin__string_index_after_(s_, rep, idx); | ||
| 13202 | + if (idx == -1) { | ||
| 13203 | + break; | ||
| 13204 | + } | ||
| 13205 | + for (int i = 0; i < rep.len; ++i) { | ||
| 13206 | + { // Unsafe block | ||
| 13207 | + s_.str[(int)(idx + i)] = 0; | ||
| 13208 | + } | ||
| 13209 | + } | ||
| 13210 | + builtin__array_push((array*)&idxs, _MOV((RepIndex[]){ ((RepIndex){.idx = idx,.val_idx = rep_i,}) })); | ||
| 13211 | + idx += rep.len; | ||
| 13212 | + new_len += with.len - rep.len; | ||
| 13213 | + } | ||
| 13214 | + } | ||
| 13215 | + if (idxs.len == 0) { | ||
| 13216 | + string _t4 = builtin__string_clone(s); | ||
| 13217 | + { // defer begin | ||
| 13218 | + builtin__array_free(&idxs); | ||
| 13219 | + } // defer end | ||
| 13220 | + return _t4; | ||
| 13221 | + } | ||
| 13222 | + if (idxs.len > 0) { v_stable_sort(idxs.data, idxs.len, idxs.element_size, compare_11734835982493514523_RepIndex_by_idx_expr_612e6964780a3c0a622e696478_qsort_adapter); } | ||
| 13223 | + ; | ||
| 13224 | + u8* buf = builtin__malloc_noscan(new_len + 1); | ||
| 13225 | + int idx_pos = 0; | ||
| 13226 | + RepIndex cur_idx = ((RepIndex*)idxs.data)[idx_pos]; | ||
| 13227 | + int buf_i = 0; | ||
| 13228 | + for (int i = 0; i < s.len; i++) { | ||
| 13229 | + if (i == cur_idx.idx) { | ||
| 13230 | + string rep = ((string*)vals.data)[cur_idx.val_idx]; | ||
| 13231 | + string with = ((string*)vals.data)[cur_idx.val_idx + 1]; | ||
| 13232 | + for (int j = 0; j < with.len; ++j) { | ||
| 13233 | + { // Unsafe block | ||
| 13234 | + buf[buf_i] = with.str[ j]; | ||
| 13235 | + } | ||
| 13236 | + buf_i++; | ||
| 13237 | + } | ||
| 13238 | + i += rep.len - 1; | ||
| 13239 | + idx_pos++; | ||
| 13240 | + if (idx_pos < idxs.len) { | ||
| 13241 | + cur_idx = ((RepIndex*)idxs.data)[idx_pos]; | ||
| 13242 | + } | ||
| 13243 | + } else { | ||
| 13244 | + { // Unsafe block | ||
| 13245 | + buf[buf_i] = s.str[i]; | ||
| 13246 | + } | ||
| 13247 | + buf_i++; | ||
| 13248 | + } | ||
| 13249 | + } | ||
| 13250 | + { // Unsafe block | ||
| 13251 | + buf[new_len] = 0; | ||
| 13252 | + string _t5 = builtin__tos(buf, new_len); | ||
| 13253 | + { // defer begin | ||
| 13254 | + builtin__array_free(&idxs); | ||
| 13255 | + } // defer end | ||
| 13256 | + return _t5; | ||
| 13257 | + } | ||
| 13258 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 13259 | +} | ||
| 13260 | +string builtin__string_format(string s, Array_string args) { | ||
| 13261 | + if (s.len == 0) { | ||
| 13262 | + return _S(""); | ||
| 13263 | + } | ||
| 13264 | + strings__Builder out = strings__new_builder(s.len); | ||
| 13265 | + int i = 0; | ||
| 13266 | + for (;;) { | ||
| 13267 | + if (!(i < s.len)) break; | ||
| 13268 | + u8 ch = s.str[ i]; | ||
| 13269 | + if (ch == '{') { | ||
| 13270 | + if (i + 1 < s.len && s.str[ i + 1] == '{') { | ||
| 13271 | + strings__Builder_write_byte(&out, '{'); | ||
| 13272 | + i += 2; | ||
| 13273 | + continue; | ||
| 13274 | + } | ||
| 13275 | + int j = i + 1; | ||
| 13276 | + if (j >= s.len || !builtin__u8_is_digit(s.str[ j])) { | ||
| 13277 | + strings__Builder_write_byte(&out, ch); | ||
| 13278 | + i++; | ||
| 13279 | + continue; | ||
| 13280 | + } | ||
| 13281 | + int idx = 0; | ||
| 13282 | + bool overflowed = false; | ||
| 13283 | + for (;;) { | ||
| 13284 | + if (!(j < s.len && builtin__u8_is_digit(s.str[ j]))) break; | ||
| 13285 | + int digit = ((int)((rune)(s.str[ j] - '0'))); | ||
| 13286 | + if (idx > VSAFE_DIV_int((_const_max_int - digit) , 10)) { | ||
| 13287 | + overflowed = true; | ||
| 13288 | + break; | ||
| 13289 | + } | ||
| 13290 | + idx = idx * 10 + digit; | ||
| 13291 | + j++; | ||
| 13292 | + } | ||
| 13293 | + if (!overflowed && j < s.len && s.str[ j] == '}') { | ||
| 13294 | + if (idx < args.len) { | ||
| 13295 | + strings__Builder_write_string(&out, ((string*)args.data)[idx]); | ||
| 13296 | + } else { | ||
| 13297 | + strings__Builder_write_string(&out, builtin__string_substr(s, i, j + 1)); | ||
| 13298 | + } | ||
| 13299 | + i = j + 1; | ||
| 13300 | + continue; | ||
| 13301 | + } | ||
| 13302 | + strings__Builder_write_byte(&out, ch); | ||
| 13303 | + i++; | ||
| 13304 | + continue; | ||
| 13305 | + } | ||
| 13306 | + if (ch == '}' && i + 1 < s.len && s.str[ i + 1] == '}') { | ||
| 13307 | + strings__Builder_write_byte(&out, '}'); | ||
| 13308 | + i += 2; | ||
| 13309 | + continue; | ||
| 13310 | + } | ||
| 13311 | + strings__Builder_write_byte(&out, ch); | ||
| 13312 | + i++; | ||
| 13313 | + } | ||
| 13314 | + return strings__Builder_str(&out); | ||
| 13315 | +} | ||
| 13316 | +string builtin__string_replace_char(string s, u8 rep, u8 with, int repeat) { | ||
| 13317 | + #if 1 | ||
| 13318 | + { | ||
| 13319 | + if (repeat <= 0) { | ||
| 13320 | + builtin___v_panic(_S("string.replace_char(): tab length too short")); | ||
| 13321 | + VUNREACHABLE(); | ||
| 13322 | + } | ||
| 13323 | + } | ||
| 13324 | + #endif | ||
| 13325 | + if (s.len == 0) { | ||
| 13326 | + return builtin__string_clone(s); | ||
| 13327 | + } | ||
| 13328 | + Array_int idxs = builtin____new_array_with_default(0, v__rshift_int(s.len, (u64)2), sizeof(int), 0); | ||
| 13329 | + for (int i = 0; i < s.len; ++i) { | ||
| 13330 | + u8 ch = s.str[i]; | ||
| 13331 | + if (ch == rep) { | ||
| 13332 | + builtin__array_push((array*)&idxs, _MOV((int[]){ i })); | ||
| 13333 | + } | ||
| 13334 | + } | ||
| 13335 | + if (idxs.len == 0) { | ||
| 13336 | + string _t4 = builtin__string_clone(s); | ||
| 13337 | + { // defer begin | ||
| 13338 | + builtin__array_free(&idxs); | ||
| 13339 | + } // defer end | ||
| 13340 | + return _t4; | ||
| 13341 | + } | ||
| 13342 | + int new_len = s.len + idxs.len * (repeat - 1); | ||
| 13343 | + u8* b = builtin__malloc_noscan(new_len + 1); | ||
| 13344 | + int b_i = 0; | ||
| 13345 | + int s_idx = 0; | ||
| 13346 | + for (int _t5 = 0; _t5 < idxs.len; ++_t5) { | ||
| 13347 | + int rep_pos = ((int*)idxs.data)[_t5]; | ||
| 13348 | + for (int i = s_idx; i < rep_pos; ++i) { | ||
| 13349 | + { // Unsafe block | ||
| 13350 | + b[b_i] = s.str[ i]; | ||
| 13351 | + } | ||
| 13352 | + b_i++; | ||
| 13353 | + } | ||
| 13354 | + s_idx = rep_pos + 1; | ||
| 13355 | + for (int _t6 = 0; _t6 < repeat; ++_t6) { | ||
| 13356 | + { // Unsafe block | ||
| 13357 | + b[b_i] = with; | ||
| 13358 | + } | ||
| 13359 | + b_i++; | ||
| 13360 | + } | ||
| 13361 | + } | ||
| 13362 | + if (s_idx < s.len) { | ||
| 13363 | + for (int i = s_idx; i < s.len; ++i) { | ||
| 13364 | + { // Unsafe block | ||
| 13365 | + b[b_i] = s.str[ i]; | ||
| 13366 | + } | ||
| 13367 | + b_i++; | ||
| 13368 | + } | ||
| 13369 | + } | ||
| 13370 | + { // Unsafe block | ||
| 13371 | + b[new_len] = 0; | ||
| 13372 | + string _t7 = builtin__tos(b, new_len); | ||
| 13373 | + { // defer begin | ||
| 13374 | + builtin__array_free(&idxs); | ||
| 13375 | + } // defer end | ||
| 13376 | + return _t7; | ||
| 13377 | + } | ||
| 13378 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 13379 | +} | ||
| 13380 | +inline string builtin__string_normalize_tabs(string s, int tab_len) { | ||
| 13381 | + return builtin__string_replace_char(s, '\t', ' ', tab_len); | ||
| 13382 | +} | ||
| 13383 | +string builtin__string_expand_tabs(string s, int tab_len) { | ||
| 13384 | + if (tab_len <= 0) { | ||
| 13385 | + return builtin__string_clone(s); | ||
| 13386 | + } | ||
| 13387 | + strings__Builder output = strings__new_builder(s.len); | ||
| 13388 | + int column = 0; | ||
| 13389 | + RunesIterator _t2 = builtin__string_runes_iterator(s); | ||
| 13390 | + while (1) { | ||
| 13391 | + _option_rune _t3 = builtin__RunesIterator_next(&_t2); | ||
| 13392 | + if (_t3.state != 0) break; | ||
| 13393 | + rune r = *(rune*)_t3.data; | ||
| 13394 | + | ||
| 13395 | + if (r == ('\t')) { | ||
| 13396 | + int spaces = tab_len - (VSAFE_MOD_int(column , tab_len)); | ||
| 13397 | + strings__Builder_write_string(&output, builtin__string_repeat(_S(" "), spaces)); | ||
| 13398 | + column += spaces; | ||
| 13399 | + } | ||
| 13400 | + else if (r == ('\n') || r == ('\r')) { | ||
| 13401 | + strings__Builder_write_rune(&output, r); | ||
| 13402 | + column = 0; | ||
| 13403 | + } | ||
| 13404 | + else { | ||
| 13405 | + strings__Builder_write_rune(&output, r); | ||
| 13406 | + column++; | ||
| 13407 | + } | ||
| 13408 | + } | ||
| 13409 | + return strings__Builder_str(&output); | ||
| 13410 | +} | ||
| 13411 | +inline bool builtin__string_bool(string s) { | ||
| 13412 | + return _SLIT_EQ(s.str, s.len, "true") || _SLIT_EQ(s.str, s.len, "t"); | ||
| 13413 | +} | ||
| 13414 | +inline i8 builtin__string_i8(string s) { | ||
| 13415 | + _result_i64 _t2 = strconv__common_parse_int(s, 0, 8, false, false); | ||
| 13416 | + if (_t2.is_error) { | ||
| 13417 | + *(i64*) _t2.data = 0; | ||
| 13418 | + } | ||
| 13419 | + | ||
| 13420 | + return ((i8)((*(i64*)_t2.data))); | ||
| 13421 | +} | ||
| 13422 | +inline i16 builtin__string_i16(string s) { | ||
| 13423 | + _result_i64 _t2 = strconv__common_parse_int(s, 0, 16, false, false); | ||
| 13424 | + if (_t2.is_error) { | ||
| 13425 | + *(i64*) _t2.data = 0; | ||
| 13426 | + } | ||
| 13427 | + | ||
| 13428 | + return ((i16)((*(i64*)_t2.data))); | ||
| 13429 | +} | ||
| 13430 | +inline i32 builtin__string_i32(string s) { | ||
| 13431 | + _result_i64 _t2 = strconv__common_parse_int(s, 0, 32, false, false); | ||
| 13432 | + if (_t2.is_error) { | ||
| 13433 | + *(i64*) _t2.data = 0; | ||
| 13434 | + } | ||
| 13435 | + | ||
| 13436 | + return ((i32)((*(i64*)_t2.data))); | ||
| 13437 | +} | ||
| 13438 | +inline int builtin__string_int(string s) { | ||
| 13439 | + _result_i64 _t2 = strconv__common_parse_int(s, 0, 32, false, false); | ||
| 13440 | + if (_t2.is_error) { | ||
| 13441 | + *(i64*) _t2.data = 0; | ||
| 13442 | + } | ||
| 13443 | + | ||
| 13444 | + return ((int)((*(i64*)_t2.data))); | ||
| 13445 | +} | ||
| 13446 | +inline i64 builtin__string_i64(string s) { | ||
| 13447 | + _result_i64 _t2 = strconv__common_parse_int(s, 0, 64, false, false); | ||
| 13448 | + if (_t2.is_error) { | ||
| 13449 | + *(i64*) _t2.data = 0; | ||
| 13450 | + } | ||
| 13451 | + | ||
| 13452 | + return (*(i64*)_t2.data); | ||
| 13453 | +} | ||
| 13454 | +inline f32 builtin__string_f32(string s) { | ||
| 13455 | + _result_f64 _t2 = strconv__atof64(s, ((strconv__AtoF64Param){.allow_extra_chars = true,})); | ||
| 13456 | + if (_t2.is_error) { | ||
| 13457 | + *(f64*) _t2.data = 0; | ||
| 13458 | + } | ||
| 13459 | + | ||
| 13460 | + return ((f32)((*(f64*)_t2.data))); | ||
| 13461 | +} | ||
| 13462 | +inline f64 builtin__string_f64(string s) { | ||
| 13463 | + _result_f64 _t2 = strconv__atof64(s, ((strconv__AtoF64Param){.allow_extra_chars = true,})); | ||
| 13464 | + if (_t2.is_error) { | ||
| 13465 | + *(f64*) _t2.data = 0; | ||
| 13466 | + } | ||
| 13467 | + | ||
| 13468 | + return (*(f64*)_t2.data); | ||
| 13469 | +} | ||
| 13470 | +Array_u8 builtin__string_u8_array(string s) { | ||
| 13471 | + string tmps = builtin__string_replace(s, _S("_"), _S("")); | ||
| 13472 | + if (tmps.len == 0) { | ||
| 13473 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | ||
| 13474 | + } | ||
| 13475 | + tmps = builtin__string_to_lower_ascii(tmps); | ||
| 13476 | + if (builtin__string_starts_with(tmps, _S("0x"))) { | ||
| 13477 | + tmps = builtin__string_substr(tmps, 2, 2147483647); | ||
| 13478 | + if (tmps.len == 0) { | ||
| 13479 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | ||
| 13480 | + } | ||
| 13481 | + if (!builtin__string_contains_only(tmps, _S("0123456789abcdef"))) { | ||
| 13482 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | ||
| 13483 | + } | ||
| 13484 | + if (VSAFE_MOD_int(tmps.len , 2) == 1) { | ||
| 13485 | + tmps = builtin__string__plus(_S("0"), tmps); | ||
| 13486 | + } | ||
| 13487 | + Array_u8 ret = builtin____new_array_with_default(VSAFE_DIV_int(tmps.len , 2), 0, sizeof(u8), 0); | ||
| 13488 | + for (int i = 0; i < ret.len; ++i) { | ||
| 13489 | + _result_u64 _t4 = builtin__string_parse_uint(builtin__string_substr(tmps, 2 * i, 2 * i + 2), 16, 8); | ||
| 13490 | + if (_t4.is_error) { | ||
| 13491 | + *(u64*) _t4.data = 0; | ||
| 13492 | + } | ||
| 13493 | + | ||
| 13494 | + builtin__array_set(&ret, i, &(u8[]) { ((u8)((*(u64*)_t4.data))) }); | ||
| 13495 | + } | ||
| 13496 | + return ret; | ||
| 13497 | + } else if (builtin__string_starts_with(tmps, _S("0b"))) { | ||
| 13498 | + tmps = builtin__string_substr(tmps, 2, 2147483647); | ||
| 13499 | + if (tmps.len == 0) { | ||
| 13500 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | ||
| 13501 | + } | ||
| 13502 | + if (!builtin__string_contains_only(tmps, _S("01"))) { | ||
| 13503 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | ||
| 13504 | + } | ||
| 13505 | + if (VSAFE_MOD_int(tmps.len , 8) != 0) { | ||
| 13506 | + tmps = builtin__string__plus(builtin__string_repeat(_S("0"), 8 - VSAFE_MOD_int(tmps.len , 8)), tmps); | ||
| 13507 | + } | ||
| 13508 | + Array_u8 ret = builtin____new_array_with_default(VSAFE_DIV_int(tmps.len , 8), 0, sizeof(u8), 0); | ||
| 13509 | + for (int i = 0; i < ret.len; ++i) { | ||
| 13510 | + _result_u64 _t8 = builtin__string_parse_uint(builtin__string_substr(tmps, 8 * i, 8 * i + 8), 2, 8); | ||
| 13511 | + if (_t8.is_error) { | ||
| 13512 | + *(u64*) _t8.data = 0; | ||
| 13513 | + } | ||
| 13514 | + | ||
| 13515 | + builtin__array_set(&ret, i, &(u8[]) { ((u8)((*(u64*)_t8.data))) }); | ||
| 13516 | + } | ||
| 13517 | + return ret; | ||
| 13518 | + } | ||
| 13519 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | ||
| 13520 | +} | ||
| 13521 | +inline u8 builtin__string_u8(string s) { | ||
| 13522 | + _result_u64 _t2 = strconv__common_parse_uint(s, 0, 8, false, false); | ||
| 13523 | + if (_t2.is_error) { | ||
| 13524 | + *(u64*) _t2.data = 0; | ||
| 13525 | + } | ||
| 13526 | + | ||
| 13527 | + return ((u8)((*(u64*)_t2.data))); | ||
| 13528 | +} | ||
| 13529 | +inline u16 builtin__string_u16(string s) { | ||
| 13530 | + _result_u64 _t2 = strconv__common_parse_uint(s, 0, 16, false, false); | ||
| 13531 | + if (_t2.is_error) { | ||
| 13532 | + *(u64*) _t2.data = 0; | ||
| 13533 | + } | ||
| 13534 | + | ||
| 13535 | + return ((u16)((*(u64*)_t2.data))); | ||
| 13536 | +} | ||
| 13537 | +inline u32 builtin__string_u32(string s) { | ||
| 13538 | + _result_u64 _t2 = strconv__common_parse_uint(s, 0, 32, false, false); | ||
| 13539 | + if (_t2.is_error) { | ||
| 13540 | + *(u64*) _t2.data = 0; | ||
| 13541 | + } | ||
| 13542 | + | ||
| 13543 | + return ((u32)((*(u64*)_t2.data))); | ||
| 13544 | +} | ||
| 13545 | +inline u64 builtin__string_u64(string s) { | ||
| 13546 | + _result_u64 _t2 = strconv__common_parse_uint(s, 0, 64, false, false); | ||
| 13547 | + if (_t2.is_error) { | ||
| 13548 | + *(u64*) _t2.data = 0; | ||
| 13549 | + } | ||
| 13550 | + | ||
| 13551 | + return (*(u64*)_t2.data); | ||
| 13552 | +} | ||
| 13553 | +inline _result_u64 builtin__string_parse_uint(string s, int _base, int _bit_size) { | ||
| 13554 | + return strconv__parse_uint(s, _base, _bit_size); | ||
| 13555 | +} | ||
| 13556 | +inline _result_i64 builtin__string_parse_int(string s, int _base, int _bit_size) { | ||
| 13557 | + return strconv__parse_int(s, _base, _bit_size); | ||
| 13558 | +} | ||
| 13559 | +VV_LOC bool builtin__string__eq(string s, string a) { | ||
| 13560 | + if (s.str == 0) { | ||
| 13561 | + return a.str == 0 || a.len == 0; | ||
| 13562 | + } | ||
| 13563 | + if (s.len != a.len) { | ||
| 13564 | + return false; | ||
| 13565 | + } | ||
| 13566 | + { // Unsafe block | ||
| 13567 | + return builtin__vmemcmp(s.str, a.str, a.len) == 0; | ||
| 13568 | + } | ||
| 13569 | + return 0; | ||
| 13570 | +} | ||
| 13571 | +int builtin__string_compare(string s, string a) { | ||
| 13572 | + int min_len = (s.len < a.len ? (s.len) : (a.len)); | ||
| 13573 | + for (int i = 0; i < min_len; ++i) { | ||
| 13574 | + if (s.str[ i] < a.str[ i]) { | ||
| 13575 | + return -1; | ||
| 13576 | + } | ||
| 13577 | + if (s.str[ i] > a.str[ i]) { | ||
| 13578 | + return 1; | ||
| 13579 | + } | ||
| 13580 | + } | ||
| 13581 | + if (s.len < a.len) { | ||
| 13582 | + return -1; | ||
| 13583 | + } | ||
| 13584 | + if (s.len > a.len) { | ||
| 13585 | + return 1; | ||
| 13586 | + } | ||
| 13587 | + return 0; | ||
| 13588 | +} | ||
| 13589 | +VV_LOC bool builtin__string__lt(string s, string a) { | ||
| 13590 | + for (int i = 0; i < s.len; ++i) { | ||
| 13591 | + if (i >= a.len || s.str[ i] > a.str[ i]) { | ||
| 13592 | + return false; | ||
| 13593 | + } else if (s.str[ i] < a.str[ i]) { | ||
| 13594 | + return true; | ||
| 13595 | + } | ||
| 13596 | + } | ||
| 13597 | + if (s.len < a.len) { | ||
| 13598 | + return true; | ||
| 13599 | + } | ||
| 13600 | + return false; | ||
| 13601 | +} | ||
| 13602 | +VV_LOC string builtin__string__plus(string s, string a) { | ||
| 13603 | + int slen = (s.len > 0 ? (s.len) : (0)); | ||
| 13604 | + int alen = (a.len > 0 ? (a.len) : (0)); | ||
| 13605 | + int new_len = alen + slen; | ||
| 13606 | + string _t1 = ((string){.str = builtin__malloc_noscan(new_len + 1), .len = new_len}); | ||
| 13607 | + string res = _t1; | ||
| 13608 | + { // Unsafe block | ||
| 13609 | + if (slen > 0) { | ||
| 13610 | + builtin__vmemcpy(res.str, s.str, slen); | ||
| 13611 | + } | ||
| 13612 | + if (alen > 0) { | ||
| 13613 | + builtin__vmemcpy(res.str + slen, a.str, alen); | ||
| 13614 | + } | ||
| 13615 | + res.str[new_len] = 0; | ||
| 13616 | + } | ||
| 13617 | + return res; | ||
| 13618 | +} | ||
| 13619 | +VV_LOC string builtin__string_plus_many(int data_len, string* input_base) { | ||
| 13620 | + int new_len = 0; | ||
| 13621 | + for (int i = 0; i < data_len; i++) { | ||
| 13622 | + string part = input_base[i]; | ||
| 13623 | + new_len += (part.len > 0 ? (part.len) : (0)); | ||
| 13624 | + } | ||
| 13625 | + string _t1 = ((string){.str = builtin__malloc_noscan(new_len + 1), .len = new_len}); | ||
| 13626 | + string res = _t1; | ||
| 13627 | + int offset = 0; | ||
| 13628 | + { // Unsafe block | ||
| 13629 | + for (int i = 0; i < data_len; i++) { | ||
| 13630 | + string part = input_base[i]; | ||
| 13631 | + int part_len = (part.len > 0 ? (part.len) : (0)); | ||
| 13632 | + if (part_len > 0) { | ||
| 13633 | + builtin__vmemcpy(res.str + offset, part.str, part_len); | ||
| 13634 | + offset += part_len; | ||
| 13635 | + } | ||
| 13636 | + } | ||
| 13637 | + res.str[new_len] = 0; | ||
| 13638 | + } | ||
| 13639 | + return res; | ||
| 13640 | +} | ||
| 13641 | +VV_LOC string builtin__string_plus_two(string s, string a, string b) { | ||
| 13642 | + int slen = (s.len > 0 ? (s.len) : (0)); | ||
| 13643 | + int alen = (a.len > 0 ? (a.len) : (0)); | ||
| 13644 | + int blen = (b.len > 0 ? (b.len) : (0)); | ||
| 13645 | + int new_len = alen + blen + slen; | ||
| 13646 | + string _t1 = ((string){.str = builtin__malloc_noscan(new_len + 1), .len = new_len}); | ||
| 13647 | + string res = _t1; | ||
| 13648 | + { // Unsafe block | ||
| 13649 | + if (slen > 0) { | ||
| 13650 | + builtin__vmemcpy(res.str, s.str, slen); | ||
| 13651 | + } | ||
| 13652 | + if (alen > 0) { | ||
| 13653 | + builtin__vmemcpy(res.str + slen, a.str, alen); | ||
| 13654 | + } | ||
| 13655 | + if (blen > 0) { | ||
| 13656 | + builtin__vmemcpy(res.str + slen + alen, b.str, blen); | ||
| 13657 | + } | ||
| 13658 | + res.str[new_len] = 0; | ||
| 13659 | + } | ||
| 13660 | + return res; | ||
| 13661 | +} | ||
| 13662 | +Array_string builtin__string_split_any(string s, string delim) { | ||
| 13663 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | ||
| 13664 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | ||
| 13665 | + int i = 0; | ||
| 13666 | + if (s.len > 0) { | ||
| 13667 | + if (delim.len <= 0) { | ||
| 13668 | + Array_string _t1 = builtin__string_split(s, _S("")); | ||
| 13669 | + { // defer begin | ||
| 13670 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | ||
| 13671 | + } // defer end | ||
| 13672 | + return _t1; | ||
| 13673 | + } | ||
| 13674 | + for (int index = 0; index < s.len; ++index) { | ||
| 13675 | + u8 ch = s.str[index]; | ||
| 13676 | + for (int _t2 = 0; _t2 < delim.len; ++_t2) { | ||
| 13677 | + u8 delim_ch = delim.str[_t2]; | ||
| 13678 | + if (ch == delim_ch) { | ||
| 13679 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, i, index) })); | ||
| 13680 | + i = index + 1; | ||
| 13681 | + break; | ||
| 13682 | + } | ||
| 13683 | + } | ||
| 13684 | + } | ||
| 13685 | + if (i < s.len) { | ||
| 13686 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, i, 2147483647) })); | ||
| 13687 | + } | ||
| 13688 | + } | ||
| 13689 | + Array_string _t5 = res; | ||
| 13690 | + { // defer begin | ||
| 13691 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | ||
| 13692 | + } // defer end | ||
| 13693 | + return _t5; | ||
| 13694 | +} | ||
| 13695 | +Array_string builtin__string_rsplit_any(string s, string delim) { | ||
| 13696 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | ||
| 13697 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | ||
| 13698 | + int i = s.len - 1; | ||
| 13699 | + if (s.len > 0) { | ||
| 13700 | + if (delim.len <= 0) { | ||
| 13701 | + Array_string _t1 = builtin__string_rsplit(s, _S("")); | ||
| 13702 | + { // defer begin | ||
| 13703 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | ||
| 13704 | + } // defer end | ||
| 13705 | + return _t1; | ||
| 13706 | + } | ||
| 13707 | + int rbound = s.len; | ||
| 13708 | + for (;;) { | ||
| 13709 | + if (!(i >= 0)) break; | ||
| 13710 | + for (int _t2 = 0; _t2 < delim.len; ++_t2) { | ||
| 13711 | + u8 delim_ch = delim.str[_t2]; | ||
| 13712 | + if (s.str[ i] == delim_ch) { | ||
| 13713 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, i + 1, rbound) })); | ||
| 13714 | + rbound = i; | ||
| 13715 | + break; | ||
| 13716 | + } | ||
| 13717 | + } | ||
| 13718 | + i--; | ||
| 13719 | + } | ||
| 13720 | + if (rbound > 0) { | ||
| 13721 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, 0, rbound) })); | ||
| 13722 | + } | ||
| 13723 | + } | ||
| 13724 | + Array_string _t5 = res; | ||
| 13725 | + { // defer begin | ||
| 13726 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | ||
| 13727 | + } // defer end | ||
| 13728 | + return _t5; | ||
| 13729 | +} | ||
| 13730 | +inline Array_string builtin__string_split(string s, string delim) { | ||
| 13731 | + return builtin__string_split_nth(s, delim, 0); | ||
| 13732 | +} | ||
| 13733 | +inline Array_string builtin__string_rsplit(string s, string delim) { | ||
| 13734 | + return builtin__string_rsplit_nth(s, delim, 0); | ||
| 13735 | +} | ||
| 13736 | +_option_multi_return_string_string builtin__string_split_once(string s, string delim) { | ||
| 13737 | + Array_string result = builtin__string_split_nth(s, delim, 2); | ||
| 13738 | + if (result.len != 2) { | ||
| 13739 | + _option_multi_return_string_string _t1 = (_option_multi_return_string_string){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | ||
| 13740 | + return _t1; | ||
| 13741 | + } | ||
| 13742 | + _option_multi_return_string_string _t2; | ||
| 13743 | + builtin___option_ok(&(multi_return_string_string[]) { (multi_return_string_string){.arg0=(*(string*)builtin__array_get(result, 0)), .arg1=(*(string*)builtin__array_get(result, 1))} }, (_option*)(&_t2), sizeof(multi_return_string_string)); | ||
| 13744 | + return _t2; | ||
| 13745 | +} | ||
| 13746 | +_option_multi_return_string_string builtin__string_rsplit_once(string s, string delim) { | ||
| 13747 | + Array_string result = builtin__string_rsplit_nth(s, delim, 2); | ||
| 13748 | + if (result.len != 2) { | ||
| 13749 | + _option_multi_return_string_string _t1 = (_option_multi_return_string_string){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | ||
| 13750 | + return _t1; | ||
| 13751 | + } | ||
| 13752 | + _option_multi_return_string_string _t2; | ||
| 13753 | + builtin___option_ok(&(multi_return_string_string[]) { (multi_return_string_string){.arg0=(*(string*)builtin__array_get(result, 1)), .arg1=(*(string*)builtin__array_get(result, 0))} }, (_option*)(&_t2), sizeof(multi_return_string_string)); | ||
| 13754 | + return _t2; | ||
| 13755 | +} | ||
| 13756 | +Array_string builtin__string_split_n(string s, string delim, int n) { | ||
| 13757 | + return builtin__string_split_nth(s, delim, n); | ||
| 13758 | +} | ||
| 13759 | +Array_string builtin__string_split_nth(string s, string delim, int nth) { | ||
| 13760 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | ||
| 13761 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | ||
| 13762 | + switch (delim.len) { | ||
| 13763 | + case 0: { | ||
| 13764 | + for (int i = 0; i < s.len; ++i) { | ||
| 13765 | + u8 ch = s.str[i]; | ||
| 13766 | + if (nth > 0 && res.len == nth - 1) { | ||
| 13767 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, i, 2147483647) })); | ||
| 13768 | + break; | ||
| 13769 | + } | ||
| 13770 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__u8_ascii_str(ch) })); | ||
| 13771 | + } | ||
| 13772 | + break; | ||
| 13773 | + } | ||
| 13774 | + case 1: { | ||
| 13775 | + u8 delim_byte = delim.str[ 0]; | ||
| 13776 | + int start = 0; | ||
| 13777 | + for (int i = 0; i < s.len; ++i) { | ||
| 13778 | + u8 ch = s.str[i]; | ||
| 13779 | + if (ch == delim_byte) { | ||
| 13780 | + if (nth > 0 && res.len == nth - 1) { | ||
| 13781 | + break; | ||
| 13782 | + } | ||
| 13783 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, start, i) })); | ||
| 13784 | + start = i + 1; | ||
| 13785 | + } | ||
| 13786 | + } | ||
| 13787 | + if (nth < 1 || res.len < nth) { | ||
| 13788 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, start, 2147483647) })); | ||
| 13789 | + } | ||
| 13790 | + break; | ||
| 13791 | + } | ||
| 13792 | + default: { | ||
| 13793 | + { | ||
| 13794 | + int start = 0; | ||
| 13795 | + for (int i = 0; i + delim.len <= s.len; ) { | ||
| 13796 | + if (builtin__string__eq(builtin__string_substr_unsafe(s, i, i + delim.len), delim)) { | ||
| 13797 | + if (nth > 0 && res.len == nth - 1) { | ||
| 13798 | + break; | ||
| 13799 | + } | ||
| 13800 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, start, i) })); | ||
| 13801 | + i += delim.len; | ||
| 13802 | + start = i; | ||
| 13803 | + } else { | ||
| 13804 | + i++; | ||
| 13805 | + } | ||
| 13806 | + } | ||
| 13807 | + if (nth < 1 || res.len < nth) { | ||
| 13808 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, start, 2147483647) })); | ||
| 13809 | + } | ||
| 13810 | + break; | ||
| 13811 | + } | ||
| 13812 | + } | ||
| 13813 | + } | ||
| 13814 | + | ||
| 13815 | + Array_string _t7 = res; | ||
| 13816 | + { // defer begin | ||
| 13817 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | ||
| 13818 | + } // defer end | ||
| 13819 | + return _t7; | ||
| 13820 | +} | ||
| 13821 | +Array_string builtin__string_rsplit_nth(string s, string delim, int nth) { | ||
| 13822 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | ||
| 13823 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | ||
| 13824 | + switch (delim.len) { | ||
| 13825 | + case 0: { | ||
| 13826 | + for (int i = s.len - 1; i >= 0; i--) { | ||
| 13827 | + if (nth > 0 && res.len == nth - 1) { | ||
| 13828 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, 0, i + 1) })); | ||
| 13829 | + break; | ||
| 13830 | + } | ||
| 13831 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__u8_ascii_str(s.str[ i]) })); | ||
| 13832 | + } | ||
| 13833 | + break; | ||
| 13834 | + } | ||
| 13835 | + case 1: { | ||
| 13836 | + u8 delim_byte = delim.str[ 0]; | ||
| 13837 | + int rbound = s.len; | ||
| 13838 | + for (int i = s.len - 1; i >= 0; i--) { | ||
| 13839 | + if (s.str[ i] == delim_byte) { | ||
| 13840 | + if (nth > 0 && res.len == nth - 1) { | ||
| 13841 | + break; | ||
| 13842 | + } | ||
| 13843 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, i + 1, rbound) })); | ||
| 13844 | + rbound = i; | ||
| 13845 | + } | ||
| 13846 | + } | ||
| 13847 | + if (nth < 1 || res.len < nth) { | ||
| 13848 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, 0, rbound) })); | ||
| 13849 | + } | ||
| 13850 | + break; | ||
| 13851 | + } | ||
| 13852 | + default: { | ||
| 13853 | + { | ||
| 13854 | + int rbound = s.len; | ||
| 13855 | + for (int i = s.len - 1; i >= 0; i--) { | ||
| 13856 | + bool is_delim = i - delim.len >= 0 && builtin__string__eq(builtin__string_substr(s, i - delim.len, i), delim); | ||
| 13857 | + if (is_delim) { | ||
| 13858 | + if (nth > 0 && res.len == nth - 1) { | ||
| 13859 | + break; | ||
| 13860 | + } | ||
| 13861 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, i, rbound) })); | ||
| 13862 | + i -= delim.len; | ||
| 13863 | + rbound = i; | ||
| 13864 | + } | ||
| 13865 | + } | ||
| 13866 | + if (nth < 1 || res.len < nth) { | ||
| 13867 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, 0, rbound) })); | ||
| 13868 | + } | ||
| 13869 | + break; | ||
| 13870 | + } | ||
| 13871 | + } | ||
| 13872 | + } | ||
| 13873 | + | ||
| 13874 | + Array_string _t7 = res; | ||
| 13875 | + { // defer begin | ||
| 13876 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | ||
| 13877 | + } // defer end | ||
| 13878 | + return _t7; | ||
| 13879 | +} | ||
| 13880 | +Array_string builtin__string_split_into_lines(string s) { | ||
| 13881 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | ||
| 13882 | + if (s.len == 0) { | ||
| 13883 | + return res; | ||
| 13884 | + } | ||
| 13885 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | ||
| 13886 | + rune cr = '\r'; | ||
| 13887 | + rune lf = '\n'; | ||
| 13888 | + int line_start = 0; | ||
| 13889 | + for (int i = 0; i < s.len; i++) { | ||
| 13890 | + if (line_start <= i) { | ||
| 13891 | + if (s.str[ i] == lf) { | ||
| 13892 | + builtin__array_push((array*)&res, _MOV((string[]){ (line_start == i ? (_S("")) : (builtin__string_substr(s, line_start, i))) })); | ||
| 13893 | + line_start = i + 1; | ||
| 13894 | + } else if (s.str[ i] == cr) { | ||
| 13895 | + builtin__array_push((array*)&res, _MOV((string[]){ (line_start == i ? (_S("")) : (builtin__string_substr(s, line_start, i))) })); | ||
| 13896 | + if ((i + 1) < s.len && s.str[ i + 1] == lf) { | ||
| 13897 | + line_start = i + 2; | ||
| 13898 | + } else { | ||
| 13899 | + line_start = i + 1; | ||
| 13900 | + } | ||
| 13901 | + } | ||
| 13902 | + } | ||
| 13903 | + } | ||
| 13904 | + if (line_start < s.len) { | ||
| 13905 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, line_start, 2147483647) })); | ||
| 13906 | + } | ||
| 13907 | + Array_string _t5 = res; | ||
| 13908 | + { // defer begin | ||
| 13909 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | ||
| 13910 | + } // defer end | ||
| 13911 | + return _t5; | ||
| 13912 | +} | ||
| 13913 | +Array_string builtin__string_split_by_space(string s) { | ||
| 13914 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | ||
| 13915 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | ||
| 13916 | + Array_string _t1 = builtin__string_split_any(s, _S(" \n\t\v\f\r")); | ||
| 13917 | + for (int _t2 = 0; _t2 < _t1.len; ++_t2) { | ||
| 13918 | + string word = ((string*)_t1.data)[_t2]; | ||
| 13919 | + if ((word).len != 0) { | ||
| 13920 | + builtin__array_push((array*)&res, _MOV((string[]){ word })); | ||
| 13921 | + } | ||
| 13922 | + } | ||
| 13923 | + Array_string _t4 = res; | ||
| 13924 | + { // defer begin | ||
| 13925 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | ||
| 13926 | + } // defer end | ||
| 13927 | + return _t4; | ||
| 13928 | +} | ||
| 13929 | +string builtin__string_substr(string s, int start, int _end) { | ||
| 13930 | + int end = (_end == _const_max_i64 || _end == _const_max_i32 ? (s.len) : (_end)); | ||
| 13931 | + #if 1 | ||
| 13932 | + { | ||
| 13933 | + if (start > end || start > s.len || end > s.len || start < 0 || end < 0) { | ||
| 13934 | + builtin___v_panic(builtin__string_plus_many(8, _MOV((string[8]){_S("substr("), builtin__impl_i64_to_string(start), _S(", "), builtin__impl_i64_to_string(end), _S(") out of bounds (len="), builtin__impl_i64_to_string(s.len), _S(") s="), s}))); | ||
| 13935 | + VUNREACHABLE(); | ||
| 13936 | + } | ||
| 13937 | + } | ||
| 13938 | + #endif | ||
| 13939 | + int len = end - start; | ||
| 13940 | + if (len == s.len) { | ||
| 13941 | + return builtin__string_clone(s); | ||
| 13942 | + } | ||
| 13943 | + string _t3 = ((string){.str = builtin__malloc_noscan(len + 1), .len = len}); | ||
| 13944 | + string res = _t3; | ||
| 13945 | + { // Unsafe block | ||
| 13946 | + builtin__vmemcpy(res.str, s.str + start, len); | ||
| 13947 | + res.str[len] = 0; | ||
| 13948 | + } | ||
| 13949 | + return res; | ||
| 13950 | +} | ||
| 13951 | +string builtin__string_substr_unsafe(string s, int start, int _end) { | ||
| 13952 | + int end = (_end == 2147483647 ? (s.len) : (_end)); | ||
| 13953 | + int len = end - start; | ||
| 13954 | + if (len == s.len) { | ||
| 13955 | + return s; | ||
| 13956 | + } | ||
| 13957 | + return ((string){.str = s.str + start, .len = len}); | ||
| 13958 | +} | ||
| 13959 | +string builtin__string_substr_or(string s, int start, int _end, string fallback) { | ||
| 13960 | + int end = (_end == _const_max_i64 || _end == _const_max_i32 ? (s.len) : (_end)); | ||
| 13961 | + if (start < 0 || start > end || end > s.len) { | ||
| 13962 | + return fallback; | ||
| 13963 | + } | ||
| 13964 | + return builtin__string_substr(s, start, end); | ||
| 13965 | +} | ||
| 13966 | +_result_string builtin__string_substr_with_check(string s, int start, int _end) { | ||
| 13967 | + int end = (_end == _const_max_i64 || _end == _const_max_i32 ? (s.len) : (_end)); | ||
| 13968 | + if (start > end || start > s.len || end > s.len || start < 0 || end < 0) { | ||
| 13969 | + return (_result_string){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(7, _MOV((string[7]){_S("substr("), builtin__impl_i64_to_string(start), _S(", "), builtin__impl_i64_to_string(end), _S(") out of bounds (len="), builtin__impl_i64_to_string(s.len), _S(")")}))), .data={E_STRUCT} }; | ||
| 13970 | + } | ||
| 13971 | + int len = end - start; | ||
| 13972 | + if (len == s.len) { | ||
| 13973 | + _result_string _t2; | ||
| 13974 | + builtin___result_ok(&(string[]) { builtin__string_clone(s) }, (_result*)(&_t2), sizeof(string)); | ||
| 13975 | + | ||
| 13976 | + return _t2; | ||
| 13977 | + } | ||
| 13978 | + string _t3 = ((string){.str = builtin__malloc_noscan(len + 1), .len = len}); | ||
| 13979 | + string res = _t3; | ||
| 13980 | + { // Unsafe block | ||
| 13981 | + builtin__vmemcpy(res.str, s.str + start, len); | ||
| 13982 | + res.str[len] = 0; | ||
| 13983 | + } | ||
| 13984 | + _result_string _t4; | ||
| 13985 | + builtin___result_ok(&(string[]) { res }, (_result*)(&_t4), sizeof(string)); | ||
| 13986 | + | ||
| 13987 | + return _t4; | ||
| 13988 | +} | ||
| 13989 | +string builtin__string_substr_ni(string s, int _start, int _end) { | ||
| 13990 | + int start = _start; | ||
| 13991 | + int end = (_end == _const_max_i64 || _end == _const_max_i32 ? (s.len) : (_end)); | ||
| 13992 | + if (start < 0) { | ||
| 13993 | + start = s.len + start; | ||
| 13994 | + if (start < 0) { | ||
| 13995 | + start = 0; | ||
| 13996 | + } | ||
| 13997 | + } | ||
| 13998 | + if (end < 0) { | ||
| 13999 | + end = s.len + end; | ||
| 14000 | + if (end < 0) { | ||
| 14001 | + end = 0; | ||
| 14002 | + } | ||
| 14003 | + } | ||
| 14004 | + if (end >= s.len) { | ||
| 14005 | + end = s.len; | ||
| 14006 | + } | ||
| 14007 | + if (start > s.len || end < start) { | ||
| 14008 | + return _S(""); | ||
| 14009 | + } | ||
| 14010 | + int len = end - start; | ||
| 14011 | + string _t2 = ((string){.str = builtin__malloc_noscan(len + 1), .len = len}); | ||
| 14012 | + string res = _t2; | ||
| 14013 | + { // Unsafe block | ||
| 14014 | + builtin__vmemcpy(res.str, s.str + start, len); | ||
| 14015 | + res.str[len] = 0; | ||
| 14016 | + } | ||
| 14017 | + return res; | ||
| 14018 | +} | ||
| 14019 | +int builtin__string_index_(string s, string p) { | ||
| 14020 | + if (p.len > s.len || p.len == 0 || ((u64)(s.str)) <= 0xFFFF || ((u64)(p.str)) <= 0xFFFF) { | ||
| 14021 | + return -1; | ||
| 14022 | + } | ||
| 14023 | + if (p.len > 2) { | ||
| 14024 | + return builtin__string_index_kmp(s, p); | ||
| 14025 | + } | ||
| 14026 | + int i = 0; | ||
| 14027 | + for (;;) { | ||
| 14028 | + if (!(i < s.len)) break; | ||
| 14029 | + int j = 0; | ||
| 14030 | + for (;;) { | ||
| 14031 | + if (!(j < p.len && s.str[i + j] == p.str[j])) break; | ||
| 14032 | + j++; | ||
| 14033 | + } | ||
| 14034 | + if (j == p.len) { | ||
| 14035 | + return i; | ||
| 14036 | + } | ||
| 14037 | + i++; | ||
| 14038 | + } | ||
| 14039 | + return -1; | ||
| 14040 | +} | ||
| 14041 | +_option_int builtin__string_index(string s, string p) { | ||
| 14042 | + int idx = builtin__string_index_(s, p); | ||
| 14043 | + if (idx == -1) { | ||
| 14044 | + return (_option_int){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | ||
| 14045 | + } | ||
| 14046 | + _option_int _t2; | ||
| 14047 | + builtin___option_ok(&(int[]) { idx }, (_option*)(&_t2), sizeof(int)); | ||
| 14048 | + | ||
| 14049 | + return _t2; | ||
| 14050 | +} | ||
| 14051 | +inline _option_int builtin__string_last_index(string s, string needle) { | ||
| 14052 | + int idx = builtin__string_index_last_(s, needle); | ||
| 14053 | + if (idx == -1) { | ||
| 14054 | + return (_option_int){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | ||
| 14055 | + } | ||
| 14056 | + _option_int _t2; | ||
| 14057 | + builtin___option_ok(&(int[]) { idx }, (_option*)(&_t2), sizeof(int)); | ||
| 14058 | + | ||
| 14059 | + return _t2; | ||
| 14060 | +} | ||
| 14061 | +VV_LOC int builtin__string_index_kmp(string s, string p) { | ||
| 14062 | + if (p.len > s.len) { | ||
| 14063 | + return -1; | ||
| 14064 | + } | ||
| 14065 | + Array_fixed_int_20 stack_prefixes = {0}; | ||
| 14066 | + int* p_prefixes = &stack_prefixes[0]; | ||
| 14067 | + if (p.len > _const_kmp_stack_buffer_size) { | ||
| 14068 | + p_prefixes = ((int*)(builtin__vcalloc(p.len * ((int)(sizeof(int)))))); | ||
| 14069 | + } | ||
| 14070 | + int j = 0; | ||
| 14071 | + for (int i = 1; i < p.len; i++) { | ||
| 14072 | + for (;;) { | ||
| 14073 | + if (!(p.str[j] != p.str[i] && j > 0)) break; | ||
| 14074 | + j = p_prefixes[j - 1]; | ||
| 14075 | + } | ||
| 14076 | + if (p.str[j] == p.str[i]) { | ||
| 14077 | + j++; | ||
| 14078 | + } | ||
| 14079 | + { // Unsafe block | ||
| 14080 | + p_prefixes[i] = j; | ||
| 14081 | + } | ||
| 14082 | + } | ||
| 14083 | + j = 0; | ||
| 14084 | + for (int i = 0; i < s.len; ++i) { | ||
| 14085 | + for (;;) { | ||
| 14086 | + if (!(p.str[j] != s.str[i] && j > 0)) break; | ||
| 14087 | + j = p_prefixes[j - 1]; | ||
| 14088 | + } | ||
| 14089 | + if (p.str[j] == s.str[i]) { | ||
| 14090 | + j++; | ||
| 14091 | + } | ||
| 14092 | + if (j == p.len) { | ||
| 14093 | + int _t2 = (int)(i - p.len) + 1; | ||
| 14094 | + { // defer begin | ||
| 14095 | + if (p.len > _const_kmp_stack_buffer_size) { | ||
| 14096 | + builtin___v_free(p_prefixes); | ||
| 14097 | + } | ||
| 14098 | + } // defer end | ||
| 14099 | + return _t2; | ||
| 14100 | + } | ||
| 14101 | + } | ||
| 14102 | + int _t3 = -1; | ||
| 14103 | + { // defer begin | ||
| 14104 | + if (p.len > _const_kmp_stack_buffer_size) { | ||
| 14105 | + builtin___v_free(p_prefixes); | ||
| 14106 | + } | ||
| 14107 | + } // defer end | ||
| 14108 | + return _t3; | ||
| 14109 | +} | ||
| 14110 | +int builtin__string_index_any(string s, string chars) { | ||
| 14111 | + for (int i = 0; i < s.len; ++i) { | ||
| 14112 | + u8 ss = s.str[i]; | ||
| 14113 | + for (int _t1 = 0; _t1 < chars.len; ++_t1) { | ||
| 14114 | + u8 c = chars.str[_t1]; | ||
| 14115 | + if (c == ss) { | ||
| 14116 | + return i; | ||
| 14117 | + } | ||
| 14118 | + } | ||
| 14119 | + } | ||
| 14120 | + return -1; | ||
| 14121 | +} | ||
| 14122 | +VV_LOC int builtin__string_index_last_(string s, string p) { | ||
| 14123 | + if (p.len > s.len || p.len == 0) { | ||
| 14124 | + return -1; | ||
| 14125 | + } | ||
| 14126 | + int i = s.len - p.len; | ||
| 14127 | + for (;;) { | ||
| 14128 | + if (!(i >= 0)) break; | ||
| 14129 | + int j = 0; | ||
| 14130 | + for (;;) { | ||
| 14131 | + if (!(j < p.len && s.str[i + j] == p.str[j])) break; | ||
| 14132 | + j++; | ||
| 14133 | + } | ||
| 14134 | + if (j == p.len) { | ||
| 14135 | + return i; | ||
| 14136 | + } | ||
| 14137 | + i--; | ||
| 14138 | + } | ||
| 14139 | + return -1; | ||
| 14140 | +} | ||
| 14141 | +_option_int builtin__string_index_after(string s, string p, int start) { | ||
| 14142 | + if (p.len > s.len) { | ||
| 14143 | + return (_option_int){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | ||
| 14144 | + } | ||
| 14145 | + int strt = start; | ||
| 14146 | + if (start < 0) { | ||
| 14147 | + strt = 0; | ||
| 14148 | + } | ||
| 14149 | + if (start >= s.len) { | ||
| 14150 | + return (_option_int){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | ||
| 14151 | + } | ||
| 14152 | + int i = strt; | ||
| 14153 | + for (;;) { | ||
| 14154 | + if (!(i < s.len)) break; | ||
| 14155 | + int j = 0; | ||
| 14156 | + int ii = i; | ||
| 14157 | + for (;;) { | ||
| 14158 | + if (!(j < p.len && s.str[ii] == p.str[j])) break; | ||
| 14159 | + j++; | ||
| 14160 | + ii++; | ||
| 14161 | + } | ||
| 14162 | + if (j == p.len) { | ||
| 14163 | + _option_int _t3; | ||
| 14164 | + builtin___option_ok(&(int[]) { i }, (_option*)(&_t3), sizeof(int)); | ||
| 14165 | + | ||
| 14166 | + return _t3; | ||
| 14167 | + } | ||
| 14168 | + i++; | ||
| 14169 | + } | ||
| 14170 | + return (_option_int){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | ||
| 14171 | +} | ||
| 14172 | +int builtin__string_index_after_(string s, string p, int start) { | ||
| 14173 | + if (p.len > s.len) { | ||
| 14174 | + return -1; | ||
| 14175 | + } | ||
| 14176 | + int strt = start; | ||
| 14177 | + if (start < 0) { | ||
| 14178 | + strt = 0; | ||
| 14179 | + } | ||
| 14180 | + if (start >= s.len) { | ||
| 14181 | + return -1; | ||
| 14182 | + } | ||
| 14183 | + int i = strt; | ||
| 14184 | + for (;;) { | ||
| 14185 | + if (!(i < s.len)) break; | ||
| 14186 | + int j = 0; | ||
| 14187 | + int ii = i; | ||
| 14188 | + for (;;) { | ||
| 14189 | + if (!(j < p.len && s.str[ii] == p.str[j])) break; | ||
| 14190 | + j++; | ||
| 14191 | + ii++; | ||
| 14192 | + } | ||
| 14193 | + if (j == p.len) { | ||
| 14194 | + return i; | ||
| 14195 | + } | ||
| 14196 | + i++; | ||
| 14197 | + } | ||
| 14198 | + return -1; | ||
| 14199 | +} | ||
| 14200 | +int builtin__string_index_u8(string s, u8 c) { | ||
| 14201 | + for (int i = 0; i < s.len; ++i) { | ||
| 14202 | + u8 b = s.str[i]; | ||
| 14203 | + if (b == c) { | ||
| 14204 | + return i; | ||
| 14205 | + } | ||
| 14206 | + } | ||
| 14207 | + return -1; | ||
| 14208 | +} | ||
| 14209 | +inline int builtin__string_last_index_u8(string s, u8 c) { | ||
| 14210 | + for (int i = s.len - 1; i >= 0; i--) { | ||
| 14211 | + if (s.str[ i] == c) { | ||
| 14212 | + return i; | ||
| 14213 | + } | ||
| 14214 | + } | ||
| 14215 | + return -1; | ||
| 14216 | +} | ||
| 14217 | +int builtin__string_count(string s, string substr) { | ||
| 14218 | + if (s.len == 0 || substr.len == 0) { | ||
| 14219 | + return 0; | ||
| 14220 | + } | ||
| 14221 | + if (substr.len > s.len) { | ||
| 14222 | + return 0; | ||
| 14223 | + } | ||
| 14224 | + int n = 0; | ||
| 14225 | + if (substr.len == 1) { | ||
| 14226 | + u8 target = substr.str[ 0]; | ||
| 14227 | + for (int _t3 = 0; _t3 < s.len; ++_t3) { | ||
| 14228 | + u8 letter = s.str[_t3]; | ||
| 14229 | + if (letter == target) { | ||
| 14230 | + n++; | ||
| 14231 | + } | ||
| 14232 | + } | ||
| 14233 | + return n; | ||
| 14234 | + } | ||
| 14235 | + int i = 0; | ||
| 14236 | + for (;;) { | ||
| 14237 | + i = builtin__string_index_after_(s, substr, i); | ||
| 14238 | + if (i == -1) { | ||
| 14239 | + return n; | ||
| 14240 | + } | ||
| 14241 | + i += substr.len; | ||
| 14242 | + n++; | ||
| 14243 | + } | ||
| 14244 | + return 0; | ||
| 14245 | +} | ||
| 14246 | +bool builtin__string_contains_u8(string s, u8 x) { | ||
| 14247 | + for (int _t1 = 0; _t1 < s.len; ++_t1) { | ||
| 14248 | + u8 c = s.str[_t1]; | ||
| 14249 | + if (x == c) { | ||
| 14250 | + return true; | ||
| 14251 | + } | ||
| 14252 | + } | ||
| 14253 | + return false; | ||
| 14254 | +} | ||
| 14255 | +bool builtin__string_contains(string s, string substr) { | ||
| 14256 | + if (substr.len == 0) { | ||
| 14257 | + return true; | ||
| 14258 | + } | ||
| 14259 | + if (substr.len == 1) { | ||
| 14260 | + return builtin__string_contains_u8(s, substr.str[0]); | ||
| 14261 | + } | ||
| 14262 | + return builtin__string_index_(s, substr) != -1; | ||
| 14263 | +} | ||
| 14264 | +bool builtin__string_contains_any(string s, string chars) { | ||
| 14265 | + for (int _t1 = 0; _t1 < chars.len; ++_t1) { | ||
| 14266 | + u8 c = chars.str[_t1]; | ||
| 14267 | + if (builtin__string_contains_u8(s, c)) { | ||
| 14268 | + return true; | ||
| 14269 | + } | ||
| 14270 | + } | ||
| 14271 | + return false; | ||
| 14272 | +} | ||
| 14273 | +bool builtin__string_contains_only(string s, string chars) { | ||
| 14274 | + if (chars.len == 0) { | ||
| 14275 | + return false; | ||
| 14276 | + } | ||
| 14277 | + for (int _t2 = 0; _t2 < s.len; ++_t2) { | ||
| 14278 | + u8 ch = s.str[_t2]; | ||
| 14279 | + int res = 0; | ||
| 14280 | + for (int i = 0; i < chars.len && res == 0; i++) { | ||
| 14281 | + res += (int[]){(ch == chars.str[i])?1:0}[0]; | ||
| 14282 | + } | ||
| 14283 | + if (res == 0) { | ||
| 14284 | + return false; | ||
| 14285 | + } | ||
| 14286 | + } | ||
| 14287 | + return true; | ||
| 14288 | +} | ||
| 14289 | +bool builtin__string_contains_any_substr(string s, Array_string substrs) { | ||
| 14290 | + if (substrs.len == 0) { | ||
| 14291 | + return true; | ||
| 14292 | + } | ||
| 14293 | + for (int _t2 = 0; _t2 < substrs.len; ++_t2) { | ||
| 14294 | + string sub = ((string*)substrs.data)[_t2]; | ||
| 14295 | + if (builtin__string_contains(s, sub)) { | ||
| 14296 | + return true; | ||
| 14297 | + } | ||
| 14298 | + } | ||
| 14299 | + return false; | ||
| 14300 | +} | ||
| 14301 | +bool builtin__string_starts_with(string s, string p) { | ||
| 14302 | + if (p.len > s.len || ((u64)(s.str)) <= 0xFFFF || ((u64)(p.str)) <= 0xFFFF) { | ||
| 14303 | + return false; | ||
| 14304 | + } else if (builtin__vmemcmp(s.str, p.str, p.len) == 0) { | ||
| 14305 | + return true; | ||
| 14306 | + } | ||
| 14307 | + return false; | ||
| 14308 | +} | ||
| 14309 | +bool builtin__string_ends_with(string s, string p) { | ||
| 14310 | + if (p.len > s.len || ((u64)(s.str)) <= 0xFFFF || ((u64)(p.str)) <= 0xFFFF) { | ||
| 14311 | + return false; | ||
| 14312 | + } else if (builtin__vmemcmp(s.str + s.len - p.len, p.str, p.len) == 0) { | ||
| 14313 | + return true; | ||
| 14314 | + } | ||
| 14315 | + return false; | ||
| 14316 | +} | ||
| 14317 | +string builtin__string_to_lower_ascii(string s) { | ||
| 14318 | + { // Unsafe block | ||
| 14319 | + u8* b = builtin__malloc_noscan(s.len + 1); | ||
| 14320 | + for (int i = 0; i < s.len; ++i) { | ||
| 14321 | + if (s.str[i] >= 'A' && s.str[i] <= 'Z') { | ||
| 14322 | + b[i] = (u8)(s.str[i] + 32); | ||
| 14323 | + } else { | ||
| 14324 | + b[i] = s.str[i]; | ||
| 14325 | + } | ||
| 14326 | + } | ||
| 14327 | + b[s.len] = 0; | ||
| 14328 | + return builtin__tos(b, s.len); | ||
| 14329 | + } | ||
| 14330 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 14331 | +} | ||
| 14332 | +string builtin__string_to_lower(string s) { | ||
| 14333 | + if (builtin__string_is_pure_ascii(s)) { | ||
| 14334 | + return builtin__string_to_lower_ascii(s); | ||
| 14335 | + } | ||
| 14336 | + Array_rune runes = builtin__string_runes(s); | ||
| 14337 | + for (int i = 0; i < runes.len; ++i) { | ||
| 14338 | + ((rune*)runes.data)[i] = builtin__rune_to_lower(((rune*)runes.data)[i]); | ||
| 14339 | + } | ||
| 14340 | + return Array_rune_string(runes); | ||
| 14341 | +} | ||
| 14342 | +bool builtin__string_is_lower(string s) { | ||
| 14343 | + if ((s).len == 0 || builtin__u8_is_digit(s.str[ 0])) { | ||
| 14344 | + return false; | ||
| 14345 | + } | ||
| 14346 | + for (int i = 0; i < s.len; ++i) { | ||
| 14347 | + if (s.str[ i] >= 'A' && s.str[ i] <= 'Z') { | ||
| 14348 | + return false; | ||
| 14349 | + } | ||
| 14350 | + } | ||
| 14351 | + return true; | ||
| 14352 | +} | ||
| 14353 | +string builtin__string_to_upper_ascii(string s) { | ||
| 14354 | + { // Unsafe block | ||
| 14355 | + u8* b = builtin__malloc_noscan(s.len + 1); | ||
| 14356 | + for (int i = 0; i < s.len; ++i) { | ||
| 14357 | + if (s.str[i] >= 'a' && s.str[i] <= 'z') { | ||
| 14358 | + b[i] = (u8)(s.str[i] - 32); | ||
| 14359 | + } else { | ||
| 14360 | + b[i] = s.str[i]; | ||
| 14361 | + } | ||
| 14362 | + } | ||
| 14363 | + b[s.len] = 0; | ||
| 14364 | + return builtin__tos(b, s.len); | ||
| 14365 | + } | ||
| 14366 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 14367 | +} | ||
| 14368 | +string builtin__string_to_upper(string s) { | ||
| 14369 | + if (builtin__string_is_pure_ascii(s)) { | ||
| 14370 | + return builtin__string_to_upper_ascii(s); | ||
| 14371 | + } | ||
| 14372 | + Array_rune runes = builtin__string_runes(s); | ||
| 14373 | + for (int i = 0; i < runes.len; ++i) { | ||
| 14374 | + ((rune*)runes.data)[i] = builtin__rune_to_upper(((rune*)runes.data)[i]); | ||
| 14375 | + } | ||
| 14376 | + return Array_rune_string(runes); | ||
| 14377 | +} | ||
| 14378 | +bool builtin__string_is_upper(string s) { | ||
| 14379 | + if ((s).len == 0) { | ||
| 14380 | + return false; | ||
| 14381 | + } | ||
| 14382 | + bool has_upper = false; | ||
| 14383 | + for (int i = 0; i < s.len; ++i) { | ||
| 14384 | + if (s.str[ i] >= 'a' && s.str[ i] <= 'z') { | ||
| 14385 | + return false; | ||
| 14386 | + } | ||
| 14387 | + if (s.str[ i] >= 'A' && s.str[ i] <= 'Z') { | ||
| 14388 | + has_upper = true; | ||
| 14389 | + } | ||
| 14390 | + } | ||
| 14391 | + return has_upper; | ||
| 14392 | +} | ||
| 14393 | +string builtin__string_capitalize(string s) { | ||
| 14394 | + if (s.len == 0) { | ||
| 14395 | + return _S(""); | ||
| 14396 | + } | ||
| 14397 | + if (s.len == 1) { | ||
| 14398 | + return builtin__string_to_upper(builtin__u8_ascii_str(s.str[ 0])); | ||
| 14399 | + } | ||
| 14400 | + Array_rune r = builtin__string_runes(s); | ||
| 14401 | + string letter = builtin__rune_str(((rune*)r.data)[0]); | ||
| 14402 | + string uletter = builtin__string_to_upper(letter); | ||
| 14403 | + Array_rune rrest = builtin__array_slice(r, 1, 2147483647); | ||
| 14404 | + string srest = Array_rune_string(rrest); | ||
| 14405 | + string res = builtin__string__plus(uletter, srest); | ||
| 14406 | + return res; | ||
| 14407 | +} | ||
| 14408 | +string builtin__string_uncapitalize(string s) { | ||
| 14409 | + if (s.len == 0) { | ||
| 14410 | + return _S(""); | ||
| 14411 | + } | ||
| 14412 | + if (s.len == 1) { | ||
| 14413 | + return builtin__string_to_lower(builtin__u8_ascii_str(s.str[ 0])); | ||
| 14414 | + } | ||
| 14415 | + Array_rune r = builtin__string_runes(s); | ||
| 14416 | + string letter = builtin__rune_str(((rune*)r.data)[0]); | ||
| 14417 | + string lletter = builtin__string_to_lower(letter); | ||
| 14418 | + Array_rune rrest = builtin__array_slice(r, 1, 2147483647); | ||
| 14419 | + string srest = Array_rune_string(rrest); | ||
| 14420 | + string res = builtin__string__plus(lletter, srest); | ||
| 14421 | + return res; | ||
| 14422 | +} | ||
| 14423 | +bool builtin__string_is_capital(string s) { | ||
| 14424 | + if (s.len == 0 || !(s.str[ 0] >= 'A' && s.str[ 0] <= 'Z')) { | ||
| 14425 | + return false; | ||
| 14426 | + } | ||
| 14427 | + for (int i = 1; i < s.len; ++i) { | ||
| 14428 | + if (s.str[ i] >= 'A' && s.str[ i] <= 'Z') { | ||
| 14429 | + return false; | ||
| 14430 | + } | ||
| 14431 | + } | ||
| 14432 | + return true; | ||
| 14433 | +} | ||
| 14434 | +bool builtin__string_starts_with_capital(string s) { | ||
| 14435 | + if (s.len == 0 || !builtin__u8_is_capital(s.str[ 0])) { | ||
| 14436 | + return false; | ||
| 14437 | + } | ||
| 14438 | + return true; | ||
| 14439 | +} | ||
| 14440 | +string builtin__string_title(string s) { | ||
| 14441 | + Array_string words = builtin__string_split(s, _S(" ")); | ||
| 14442 | + Array_string tit = builtin____new_array_with_default(0, 0, sizeof(string), 0); | ||
| 14443 | + for (int _t1 = 0; _t1 < words.len; ++_t1) { | ||
| 14444 | + string word = ((string*)words.data)[_t1]; | ||
| 14445 | + builtin__array_push((array*)&tit, _MOV((string[]){ builtin__string_capitalize(word) })); | ||
| 14446 | + } | ||
| 14447 | + string title = Array_string_join(tit, _S(" ")); | ||
| 14448 | + return title; | ||
| 14449 | +} | ||
| 14450 | +bool builtin__string_is_title(string s) { | ||
| 14451 | + Array_string words = builtin__string_split(s, _S(" ")); | ||
| 14452 | + for (int _t1 = 0; _t1 < words.len; ++_t1) { | ||
| 14453 | + string word = ((string*)words.data)[_t1]; | ||
| 14454 | + if (!builtin__string_is_capital(word)) { | ||
| 14455 | + return false; | ||
| 14456 | + } | ||
| 14457 | + } | ||
| 14458 | + return true; | ||
| 14459 | +} | ||
| 14460 | +string builtin__string_find_between(string s, string start, string end) { | ||
| 14461 | + int start_pos = builtin__string_index_(s, start); | ||
| 14462 | + if (start_pos == -1) { | ||
| 14463 | + return _S(""); | ||
| 14464 | + } | ||
| 14465 | + string val = builtin__string_substr(s, start_pos + start.len, 2147483647); | ||
| 14466 | + int end_pos = builtin__string_index_(val, end); | ||
| 14467 | + if (end_pos == -1) { | ||
| 14468 | + return _S(""); | ||
| 14469 | + } | ||
| 14470 | + return builtin__string_substr(val, 0, end_pos); | ||
| 14471 | +} | ||
| 14472 | +inline string builtin__string_trim_space(string s) { | ||
| 14473 | + return builtin__string_trim(s, _S(" \n\t\v\f\r")); | ||
| 14474 | +} | ||
| 14475 | +inline string builtin__string_trim_space_left(string s) { | ||
| 14476 | + return builtin__string_trim_left(s, _S(" \n\t\v\f\r")); | ||
| 14477 | +} | ||
| 14478 | +inline string builtin__string_trim_space_right(string s) { | ||
| 14479 | + return builtin__string_trim_right(s, _S(" \n\t\v\f\r")); | ||
| 14480 | +} | ||
| 14481 | +string builtin__string_trim(string s, string cutset) { | ||
| 14482 | + if ((s).len == 0 || (cutset).len == 0) { | ||
| 14483 | + return builtin__string_clone(s); | ||
| 14484 | + } | ||
| 14485 | + if (builtin__string_is_pure_ascii(cutset)) { | ||
| 14486 | + return builtin__string_trim_chars(s, cutset, TrimMode__trim_both); | ||
| 14487 | + } else { | ||
| 14488 | + return builtin__string_trim_runes(s, cutset, TrimMode__trim_both); | ||
| 14489 | + } | ||
| 14490 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 14491 | +} | ||
| 14492 | +multi_return_int_int builtin__string_trim_indexes(string s, string cutset) { | ||
| 14493 | + int pos_left = 0; | ||
| 14494 | + int pos_right = s.len - 1; | ||
| 14495 | + bool cs_match = true; | ||
| 14496 | + for (;;) { | ||
| 14497 | + if (!(pos_left <= s.len && pos_right >= -1 && cs_match)) break; | ||
| 14498 | + cs_match = false; | ||
| 14499 | + for (int _t1 = 0; _t1 < cutset.len; ++_t1) { | ||
| 14500 | + u8 cs = cutset.str[_t1]; | ||
| 14501 | + if (s.str[ pos_left] == cs) { | ||
| 14502 | + pos_left++; | ||
| 14503 | + cs_match = true; | ||
| 14504 | + break; | ||
| 14505 | + } | ||
| 14506 | + } | ||
| 14507 | + for (int _t2 = 0; _t2 < cutset.len; ++_t2) { | ||
| 14508 | + u8 cs = cutset.str[_t2]; | ||
| 14509 | + if (s.str[ pos_right] == cs) { | ||
| 14510 | + pos_right--; | ||
| 14511 | + cs_match = true; | ||
| 14512 | + break; | ||
| 14513 | + } | ||
| 14514 | + } | ||
| 14515 | + if (pos_left > pos_right) { | ||
| 14516 | + return (multi_return_int_int){.arg0=0, .arg1=0}; | ||
| 14517 | + } | ||
| 14518 | + } | ||
| 14519 | + return (multi_return_int_int){.arg0=pos_left, .arg1=pos_right + 1}; | ||
| 14520 | +} | ||
| 14521 | +VV_LOC string builtin__string_trim_chars(string s, string cutset, TrimMode mode) { | ||
| 14522 | + int pos_left = 0; | ||
| 14523 | + int pos_right = s.len - 1; | ||
| 14524 | + bool cs_match = true; | ||
| 14525 | + for (;;) { | ||
| 14526 | + if (!(pos_left <= s.len && pos_right >= -1 && cs_match)) break; | ||
| 14527 | + cs_match = false; | ||
| 14528 | + if (mode == TrimMode__trim_left || mode == TrimMode__trim_both) { | ||
| 14529 | + for (int _t1 = 0; _t1 < cutset.len; ++_t1) { | ||
| 14530 | + u8 cs = cutset.str[_t1]; | ||
| 14531 | + if (s.str[ pos_left] == cs) { | ||
| 14532 | + pos_left++; | ||
| 14533 | + cs_match = true; | ||
| 14534 | + break; | ||
| 14535 | + } | ||
| 14536 | + } | ||
| 14537 | + } | ||
| 14538 | + if (mode == TrimMode__trim_right || mode == TrimMode__trim_both) { | ||
| 14539 | + for (int _t2 = 0; _t2 < cutset.len; ++_t2) { | ||
| 14540 | + u8 cs = cutset.str[_t2]; | ||
| 14541 | + if (s.str[ pos_right] == cs) { | ||
| 14542 | + pos_right--; | ||
| 14543 | + cs_match = true; | ||
| 14544 | + break; | ||
| 14545 | + } | ||
| 14546 | + } | ||
| 14547 | + } | ||
| 14548 | + if (pos_left > pos_right) { | ||
| 14549 | + return _S(""); | ||
| 14550 | + } | ||
| 14551 | + } | ||
| 14552 | + return builtin__string_substr(s, pos_left, pos_right + 1); | ||
| 14553 | +} | ||
| 14554 | +VV_LOC string builtin__string_trim_runes(string s, string cutset, TrimMode mode) { | ||
| 14555 | + Array_rune s_runes = builtin__string_runes(s); | ||
| 14556 | + Array_rune cs_runes = builtin__string_runes(cutset); | ||
| 14557 | + int pos_left = 0; | ||
| 14558 | + int pos_right = s_runes.len - 1; | ||
| 14559 | + bool cs_match = true; | ||
| 14560 | + for (;;) { | ||
| 14561 | + if (!(pos_left <= s_runes.len && pos_right >= -1 && cs_match)) break; | ||
| 14562 | + cs_match = false; | ||
| 14563 | + if (mode == TrimMode__trim_left || mode == TrimMode__trim_both) { | ||
| 14564 | + for (int _t1 = 0; _t1 < cs_runes.len; ++_t1) { | ||
| 14565 | + rune cs = ((rune*)cs_runes.data)[_t1]; | ||
| 14566 | + if (((rune*)s_runes.data)[pos_left] == cs) { | ||
| 14567 | + pos_left++; | ||
| 14568 | + cs_match = true; | ||
| 14569 | + break; | ||
| 14570 | + } | ||
| 14571 | + } | ||
| 14572 | + } | ||
| 14573 | + if (mode == TrimMode__trim_right || mode == TrimMode__trim_both) { | ||
| 14574 | + for (int _t2 = 0; _t2 < cs_runes.len; ++_t2) { | ||
| 14575 | + rune cs = ((rune*)cs_runes.data)[_t2]; | ||
| 14576 | + if (((rune*)s_runes.data)[pos_right] == cs) { | ||
| 14577 | + pos_right--; | ||
| 14578 | + cs_match = true; | ||
| 14579 | + break; | ||
| 14580 | + } | ||
| 14581 | + } | ||
| 14582 | + } | ||
| 14583 | + if (pos_left > pos_right) { | ||
| 14584 | + return _S(""); | ||
| 14585 | + } | ||
| 14586 | + } | ||
| 14587 | + return Array_rune_string(builtin__array_slice(s_runes, pos_left, pos_right + 1)); | ||
| 14588 | +} | ||
| 14589 | +string builtin__string_trim_left(string s, string cutset) { | ||
| 14590 | + if ((s).len == 0 || (cutset).len == 0) { | ||
| 14591 | + return builtin__string_clone(s); | ||
| 14592 | + } | ||
| 14593 | + if (builtin__string_is_pure_ascii(cutset)) { | ||
| 14594 | + return builtin__string_trim_chars(s, cutset, TrimMode__trim_left); | ||
| 14595 | + } else { | ||
| 14596 | + return builtin__string_trim_runes(s, cutset, TrimMode__trim_left); | ||
| 14597 | + } | ||
| 14598 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 14599 | +} | ||
| 14600 | +string builtin__string_trim_right(string s, string cutset) { | ||
| 14601 | + if (s.len < 1 || cutset.len < 1) { | ||
| 14602 | + return builtin__string_clone(s); | ||
| 14603 | + } | ||
| 14604 | + if (cutset.len == 1) { | ||
| 14605 | + u8 cut = cutset.str[ 0]; | ||
| 14606 | + int pos_right = s.len - 1; | ||
| 14607 | + for (;;) { | ||
| 14608 | + if (!(pos_right >= 0 && s.str[ pos_right] == cut)) break; | ||
| 14609 | + pos_right--; | ||
| 14610 | + } | ||
| 14611 | + if (pos_right < 0) { | ||
| 14612 | + return _S(""); | ||
| 14613 | + } | ||
| 14614 | + return builtin__string_substr(s, 0, pos_right + 1); | ||
| 14615 | + } | ||
| 14616 | + if (cutset.len == 2 && builtin__string_is_pure_ascii(cutset)) { | ||
| 14617 | + u8 cut0 = cutset.str[ 0]; | ||
| 14618 | + u8 cut1 = cutset.str[ 1]; | ||
| 14619 | + int pos_right = s.len - 1; | ||
| 14620 | + for (;;) { | ||
| 14621 | + if (!(pos_right >= 0 && (s.str[ pos_right] == cut0 || s.str[ pos_right] == cut1))) break; | ||
| 14622 | + pos_right--; | ||
| 14623 | + } | ||
| 14624 | + if (pos_right < 0) { | ||
| 14625 | + return _S(""); | ||
| 14626 | + } | ||
| 14627 | + return builtin__string_substr(s, 0, pos_right + 1); | ||
| 14628 | + } | ||
| 14629 | + if (builtin__string_is_pure_ascii(cutset)) { | ||
| 14630 | + return builtin__string_trim_chars(s, cutset, TrimMode__trim_right); | ||
| 14631 | + } else { | ||
| 14632 | + return builtin__string_trim_runes(s, cutset, TrimMode__trim_right); | ||
| 14633 | + } | ||
| 14634 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 14635 | +} | ||
| 14636 | +string builtin__string_trim_string_left(string s, string str) { | ||
| 14637 | + if (builtin__string_starts_with(s, str)) { | ||
| 14638 | + return builtin__string_substr(s, str.len, 2147483647); | ||
| 14639 | + } | ||
| 14640 | + return builtin__string_clone(s); | ||
| 14641 | +} | ||
| 14642 | +string builtin__string_trim_string_right(string s, string str) { | ||
| 14643 | + if (builtin__string_ends_with(s, str)) { | ||
| 14644 | + return builtin__string_substr(s, 0, s.len - str.len); | ||
| 14645 | + } | ||
| 14646 | + return builtin__string_clone(s); | ||
| 14647 | +} | ||
| 14648 | +int builtin__compare_strings(string* a, string* b) { | ||
| 14649 | + bool _t2 = true; | ||
| 14650 | + int_literal _t3 = 0; | ||
| 14651 | + | ||
| 14652 | + if (_t2 == (builtin__string__lt(*a, *b))) { | ||
| 14653 | + _t3 = -1; | ||
| 14654 | + } | ||
| 14655 | + else if (_t2 == (builtin__string__lt(*b, *a))) { | ||
| 14656 | + _t3 = 1; | ||
| 14657 | + } | ||
| 14658 | + else { | ||
| 14659 | + _t3 = 0; | ||
| 14660 | + }return _t3; | ||
| 14661 | +} | ||
| 14662 | +VV_LOC int builtin__compare_strings_by_len(string* a, string* b) { | ||
| 14663 | + bool _t2 = true; | ||
| 14664 | + int_literal _t3 = 0; | ||
| 14665 | + | ||
| 14666 | + if (_t2 == (a->len < b->len)) { | ||
| 14667 | + _t3 = -1; | ||
| 14668 | + } | ||
| 14669 | + else if (_t2 == (a->len > b->len)) { | ||
| 14670 | + _t3 = 1; | ||
| 14671 | + } | ||
| 14672 | + else { | ||
| 14673 | + _t3 = 0; | ||
| 14674 | + }return _t3; | ||
| 14675 | +} | ||
| 14676 | +VV_LOC int builtin__compare_lower_strings(string* a, string* b) { | ||
| 14677 | + string aa = builtin__string_to_lower(*a); | ||
| 14678 | + string bb = builtin__string_to_lower(*b); | ||
| 14679 | + return builtin__compare_strings(&aa, &bb); | ||
| 14680 | +} | ||
| 14681 | +inline void Array_string_sort_ignore_case(Array_string* s) { | ||
| 14682 | + if (s->len > 0) { v_stable_sort(s->data, s->len, s->element_size, builtin__compare_lower_strings_qsort_adapter); } | ||
| 14683 | + ; | ||
| 14684 | +} | ||
| 14685 | +inline void Array_string_sort_by_len(Array_string* s) { | ||
| 14686 | + if (s->len > 0) { v_stable_sort(s->data, s->len, s->element_size, builtin__compare_strings_by_len_qsort_adapter); } | ||
| 14687 | + ; | ||
| 14688 | +} | ||
| 14689 | +inline string builtin__string_str(string s) { | ||
| 14690 | + return builtin__string_clone(s); | ||
| 14691 | +} | ||
| 14692 | +VV_LOC u8 builtin__string_at(string s, int idx) { | ||
| 14693 | + #if 1 | ||
| 14694 | + { | ||
| 14695 | + if (idx < 0 || idx >= s.len) { | ||
| 14696 | + builtin__panic_n2(_S("string index out of range(idx,s.len):"), idx, s.len); | ||
| 14697 | + VUNREACHABLE(); | ||
| 14698 | + } | ||
| 14699 | + } | ||
| 14700 | + #endif | ||
| 14701 | + return s.str[idx]; | ||
| 14702 | +} | ||
| 14703 | +VV_LOC u8 builtin__string_at_i64(string s, i64 idx) { | ||
| 14704 | + #if 1 | ||
| 14705 | + { | ||
| 14706 | + if (idx < 0 || idx >= ((i64)(s.len))) { | ||
| 14707 | + builtin__panic_n2(_S("string index out of range(idx,s.len):"), idx, s.len); | ||
| 14708 | + VUNREACHABLE(); | ||
| 14709 | + } | ||
| 14710 | + } | ||
| 14711 | + #endif | ||
| 14712 | + return s.str[((int)(idx))]; | ||
| 14713 | +} | ||
| 14714 | +VV_LOC u8 builtin__string_at_u64(string s, u64 idx) { | ||
| 14715 | + #if 1 | ||
| 14716 | + { | ||
| 14717 | + if (idx >= ((u64)(s.len))) { | ||
| 14718 | + builtin___v_panic(builtin__string_plus_many(4, _MOV((string[4]){_S("string index out of range(idx,s.len): "), builtin__u64_str(idx), _S(", "), builtin__impl_i64_to_string(s.len)}))); | ||
| 14719 | + VUNREACHABLE(); | ||
| 14720 | + } | ||
| 14721 | + } | ||
| 14722 | + #endif | ||
| 14723 | + return s.str[((int)(idx))]; | ||
| 14724 | +} | ||
| 14725 | +VV_LOC u8 builtin__string_at_ni(string s, int idx) { | ||
| 14726 | + return builtin__string_at(s, builtin__v_ni_index(idx, s.len)); | ||
| 14727 | +} | ||
| 14728 | +VV_LOC _option_u8 builtin__string_at_with_check(string s, int idx) { | ||
| 14729 | + if (idx < 0 || idx >= s.len) { | ||
| 14730 | + return (_option_u8){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | ||
| 14731 | + } | ||
| 14732 | + { // Unsafe block | ||
| 14733 | + _option_u8 _t2; | ||
| 14734 | + builtin___option_ok(&(u8[]) { s.str[idx] }, (_option*)(&_t2), sizeof(u8)); | ||
| 14735 | + | ||
| 14736 | + return _t2; | ||
| 14737 | + } | ||
| 14738 | + return (_option_u8){.state=2, .err=_const_none__, .data={E_STRUCT}}; | ||
| 14739 | +} | ||
| 14740 | +VV_LOC _option_u8 builtin__string_at_with_check_i64(string s, i64 idx) { | ||
| 14741 | + if (idx < 0 || idx >= ((i64)(s.len))) { | ||
| 14742 | + return (_option_u8){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | ||
| 14743 | + } | ||
| 14744 | + { // Unsafe block | ||
| 14745 | + _option_u8 _t2; | ||
| 14746 | + builtin___option_ok(&(u8[]) { s.str[((int)(idx))] }, (_option*)(&_t2), sizeof(u8)); | ||
| 14747 | + | ||
| 14748 | + return _t2; | ||
| 14749 | + } | ||
| 14750 | + return (_option_u8){.state=2, .err=_const_none__, .data={E_STRUCT}}; | ||
| 14751 | +} | ||
| 14752 | +VV_LOC _option_u8 builtin__string_at_with_check_u64(string s, u64 idx) { | ||
| 14753 | + if (idx >= ((u64)(s.len))) { | ||
| 14754 | + return (_option_u8){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | ||
| 14755 | + } | ||
| 14756 | + { // Unsafe block | ||
| 14757 | + _option_u8 _t2; | ||
| 14758 | + builtin___option_ok(&(u8[]) { s.str[((int)(idx))] }, (_option*)(&_t2), sizeof(u8)); | ||
| 14759 | + | ||
| 14760 | + return _t2; | ||
| 14761 | + } | ||
| 14762 | + return (_option_u8){.state=2, .err=_const_none__, .data={E_STRUCT}}; | ||
| 14763 | +} | ||
| 14764 | +VV_LOC _option_u8 builtin__string_at_with_check_ni(string s, int idx) { | ||
| 14765 | + return builtin__string_at_with_check(s, builtin__v_ni_index(idx, s.len)); | ||
| 14766 | +} | ||
| 14767 | +bool builtin__string_is_oct(string str) { | ||
| 14768 | + int i = 0; | ||
| 14769 | + if (str.len == 0) { | ||
| 14770 | + return false; | ||
| 14771 | + } | ||
| 14772 | + if (str.str[ i] == '0') { | ||
| 14773 | + i++; | ||
| 14774 | + } else if (str.str[ i] == '-' || str.str[ i] == '+') { | ||
| 14775 | + i++; | ||
| 14776 | + if (i < str.len && str.str[ i] == '0') { | ||
| 14777 | + i++; | ||
| 14778 | + } else { | ||
| 14779 | + return false; | ||
| 14780 | + } | ||
| 14781 | + } else { | ||
| 14782 | + return false; | ||
| 14783 | + } | ||
| 14784 | + if (i < str.len && str.str[ i] == 'o') { | ||
| 14785 | + i++; | ||
| 14786 | + } else { | ||
| 14787 | + return false; | ||
| 14788 | + } | ||
| 14789 | + if (i == str.len) { | ||
| 14790 | + return false; | ||
| 14791 | + } | ||
| 14792 | + for (;;) { | ||
| 14793 | + if (!(i < str.len)) break; | ||
| 14794 | + if (str.str[ i] < '0' || str.str[ i] > '7') { | ||
| 14795 | + return false; | ||
| 14796 | + } | ||
| 14797 | + i++; | ||
| 14798 | + } | ||
| 14799 | + return true; | ||
| 14800 | +} | ||
| 14801 | +bool builtin__string_is_bin(string str) { | ||
| 14802 | + int i = 0; | ||
| 14803 | + if (str.len == 0) { | ||
| 14804 | + return false; | ||
| 14805 | + } | ||
| 14806 | + if (str.str[ i] == '0') { | ||
| 14807 | + i++; | ||
| 14808 | + } else if (str.str[ i] == '-' || str.str[ i] == '+') { | ||
| 14809 | + i++; | ||
| 14810 | + if (i < str.len && str.str[ i] == '0') { | ||
| 14811 | + i++; | ||
| 14812 | + } else { | ||
| 14813 | + return false; | ||
| 14814 | + } | ||
| 14815 | + } else { | ||
| 14816 | + return false; | ||
| 14817 | + } | ||
| 14818 | + if (i < str.len && str.str[ i] == 'b') { | ||
| 14819 | + i++; | ||
| 14820 | + } else { | ||
| 14821 | + return false; | ||
| 14822 | + } | ||
| 14823 | + if (i == str.len) { | ||
| 14824 | + return false; | ||
| 14825 | + } | ||
| 14826 | + for (;;) { | ||
| 14827 | + if (!(i < str.len)) break; | ||
| 14828 | + if (str.str[ i] < '0' || str.str[ i] > '1') { | ||
| 14829 | + return false; | ||
| 14830 | + } | ||
| 14831 | + i++; | ||
| 14832 | + } | ||
| 14833 | + return true; | ||
| 14834 | +} | ||
| 14835 | +bool builtin__string_is_hex(string str) { | ||
| 14836 | + int i = 0; | ||
| 14837 | + if (str.len == 0) { | ||
| 14838 | + return false; | ||
| 14839 | + } | ||
| 14840 | + if (str.str[ i] == '0') { | ||
| 14841 | + i++; | ||
| 14842 | + } else if (str.str[ i] == '-' || str.str[ i] == '+') { | ||
| 14843 | + i++; | ||
| 14844 | + if (i < str.len && str.str[ i] == '0') { | ||
| 14845 | + i++; | ||
| 14846 | + } else { | ||
| 14847 | + return false; | ||
| 14848 | + } | ||
| 14849 | + } else { | ||
| 14850 | + return false; | ||
| 14851 | + } | ||
| 14852 | + if (i < str.len && str.str[ i] == 'x') { | ||
| 14853 | + i++; | ||
| 14854 | + } else { | ||
| 14855 | + return false; | ||
| 14856 | + } | ||
| 14857 | + if (i == str.len) { | ||
| 14858 | + return false; | ||
| 14859 | + } | ||
| 14860 | + for (;;) { | ||
| 14861 | + if (!(i < str.len)) break; | ||
| 14862 | + if ((str.str[ i] < '0' || str.str[ i] > '9') && ((str.str[ i] < 'a' || str.str[ i] > 'f') && (str.str[ i] < 'A' || str.str[ i] > 'F'))) { | ||
| 14863 | + return false; | ||
| 14864 | + } | ||
| 14865 | + i++; | ||
| 14866 | + } | ||
| 14867 | + return true; | ||
| 14868 | +} | ||
| 14869 | +bool builtin__string_is_int(string str) { | ||
| 14870 | + int i = 0; | ||
| 14871 | + if (str.len == 0) { | ||
| 14872 | + return false; | ||
| 14873 | + } | ||
| 14874 | + if ((str.str[ i] != '-' && str.str[ i] != '+') && (!builtin__u8_is_digit(str.str[ i]))) { | ||
| 14875 | + return false; | ||
| 14876 | + } else { | ||
| 14877 | + i++; | ||
| 14878 | + } | ||
| 14879 | + if (i == str.len && (!builtin__u8_is_digit(str.str[ i - 1]))) { | ||
| 14880 | + return false; | ||
| 14881 | + } | ||
| 14882 | + for (;;) { | ||
| 14883 | + if (!(i < str.len)) break; | ||
| 14884 | + if (str.str[ i] < '0' || str.str[ i] > '9') { | ||
| 14885 | + return false; | ||
| 14886 | + } | ||
| 14887 | + i++; | ||
| 14888 | + } | ||
| 14889 | + return true; | ||
| 14890 | +} | ||
| 14891 | +inline bool builtin__u8_is_space(u8 c) { | ||
| 14892 | + return c == 32 || (c > 8 && c < 14) || c == 0x85 || c == 0xa0; | ||
| 14893 | +} | ||
| 14894 | +inline bool builtin__u8_is_digit(u8 c) { | ||
| 14895 | + return c >= '0' && c <= '9'; | ||
| 14896 | +} | ||
| 14897 | +inline bool builtin__u8_is_hex_digit(u8 c) { | ||
| 14898 | + return builtin__u8_is_digit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); | ||
| 14899 | +} | ||
| 14900 | +inline bool builtin__u8_is_oct_digit(u8 c) { | ||
| 14901 | + return c >= '0' && c <= '7'; | ||
| 14902 | +} | ||
| 14903 | +inline bool builtin__u8_is_bin_digit(u8 c) { | ||
| 14904 | + return c == '0' || c == '1'; | ||
| 14905 | +} | ||
| 14906 | +inline bool builtin__u8_is_letter(u8 c) { | ||
| 14907 | + return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); | ||
| 14908 | +} | ||
| 14909 | +inline bool builtin__u8_is_alnum(u8 c) { | ||
| 14910 | + return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'); | ||
| 14911 | +} | ||
| 14912 | +void builtin__string_free(string* s) { | ||
| 14913 | + if (s->is_lit == -98761234) { | ||
| 14914 | + u8* double_free_msg = ((u8*)("double string.free() detected\n")); | ||
| 14915 | + int double_free_msg_len = builtin__vstrlen(double_free_msg); | ||
| 14916 | + #if 0 | ||
| 14917 | + { | ||
| 14918 | + } | ||
| 14919 | + #else | ||
| 14920 | + { | ||
| 14921 | + builtin___write_buf_to_fd(1, double_free_msg, double_free_msg_len); | ||
| 14922 | + } | ||
| 14923 | + #endif | ||
| 14924 | + return; | ||
| 14925 | + } | ||
| 14926 | + if (s->is_lit == 1 || s->str == 0) { | ||
| 14927 | + return; | ||
| 14928 | + } | ||
| 14929 | + { // Unsafe block | ||
| 14930 | + builtin___v_free(s->str); | ||
| 14931 | + s->str = ((void*)0); | ||
| 14932 | + } | ||
| 14933 | + s->len = 0; | ||
| 14934 | + s->is_lit = -98761234; | ||
| 14935 | +} | ||
| 14936 | +string builtin__string_before(string s, string sub) { | ||
| 14937 | + int pos = builtin__string_index_(s, sub); | ||
| 14938 | + if (pos == -1) { | ||
| 14939 | + return builtin__string_clone(s); | ||
| 14940 | + } | ||
| 14941 | + return builtin__string_substr(s, 0, pos); | ||
| 14942 | +} | ||
| 14943 | +string builtin__string_all_before(string s, string sub) { | ||
| 14944 | + int pos = builtin__string_index_(s, sub); | ||
| 14945 | + if (pos == -1) { | ||
| 14946 | + return builtin__string_clone(s); | ||
| 14947 | + } | ||
| 14948 | + return builtin__string_substr(s, 0, pos); | ||
| 14949 | +} | ||
| 14950 | +string builtin__string_all_before_last(string s, string sub) { | ||
| 14951 | + int pos = builtin__string_index_last_(s, sub); | ||
| 14952 | + if (pos == -1) { | ||
| 14953 | + return builtin__string_clone(s); | ||
| 14954 | + } | ||
| 14955 | + return builtin__string_substr(s, 0, pos); | ||
| 14956 | +} | ||
| 14957 | +string builtin__string_all_after(string s, string sub) { | ||
| 14958 | + int pos = builtin__string_index_(s, sub); | ||
| 14959 | + if (pos == -1) { | ||
| 14960 | + return builtin__string_clone(s); | ||
| 14961 | + } | ||
| 14962 | + return builtin__string_substr(s, pos + sub.len, 2147483647); | ||
| 14963 | +} | ||
| 14964 | +string builtin__string_all_after_last(string s, string sub) { | ||
| 14965 | + int pos = builtin__string_index_last_(s, sub); | ||
| 14966 | + if (pos == -1) { | ||
| 14967 | + return builtin__string_clone(s); | ||
| 14968 | + } | ||
| 14969 | + return builtin__string_substr(s, pos + sub.len, 2147483647); | ||
| 14970 | +} | ||
| 14971 | +string builtin__string_all_after_first(string s, string sub) { | ||
| 14972 | + int pos = builtin__string_index_(s, sub); | ||
| 14973 | + if (pos == -1) { | ||
| 14974 | + return builtin__string_clone(s); | ||
| 14975 | + } | ||
| 14976 | + return builtin__string_substr(s, pos + sub.len, 2147483647); | ||
| 14977 | +} | ||
| 14978 | +inline string builtin__string_after(string s, string sub) { | ||
| 14979 | + return builtin__string_all_after_last(s, sub); | ||
| 14980 | +} | ||
| 14981 | +string builtin__string_after_char(string s, u8 sub) { | ||
| 14982 | + int pos = -1; | ||
| 14983 | + for (int i = 0; i < s.len; ++i) { | ||
| 14984 | + u8 c = s.str[i]; | ||
| 14985 | + if (c == sub) { | ||
| 14986 | + pos = i; | ||
| 14987 | + break; | ||
| 14988 | + } | ||
| 14989 | + } | ||
| 14990 | + if (pos == -1) { | ||
| 14991 | + return builtin__string_clone(s); | ||
| 14992 | + } | ||
| 14993 | + return builtin__string_substr(s, pos + 1, 2147483647); | ||
| 14994 | +} | ||
| 14995 | +string Array_string_join(Array_string a, string sep) { | ||
| 14996 | + if (a.len == 0) { | ||
| 14997 | + return _S(""); | ||
| 14998 | + } | ||
| 14999 | + int len = 0; | ||
| 15000 | + for (int _t2 = 0; _t2 < a.len; ++_t2) { | ||
| 15001 | + string val = ((string*)a.data)[_t2]; | ||
| 15002 | + len += val.len + sep.len; | ||
| 15003 | + } | ||
| 15004 | + len -= sep.len; | ||
| 15005 | + string _t3 = ((string){.str = builtin__malloc_noscan(len + 1), .len = len}); | ||
| 15006 | + string res = _t3; | ||
| 15007 | + int idx = 0; | ||
| 15008 | + for (int i = 0; i < a.len; ++i) { | ||
| 15009 | + string val = ((string*)a.data)[i]; | ||
| 15010 | + { // Unsafe block | ||
| 15011 | + builtin__vmemcpy(((voidptr)(res.str + idx)), val.str, val.len); | ||
| 15012 | + idx += val.len; | ||
| 15013 | + } | ||
| 15014 | + if (i != a.len - 1) { | ||
| 15015 | + { // Unsafe block | ||
| 15016 | + builtin__vmemcpy(((voidptr)(res.str + idx)), sep.str, sep.len); | ||
| 15017 | + idx += sep.len; | ||
| 15018 | + } | ||
| 15019 | + } | ||
| 15020 | + } | ||
| 15021 | + { // Unsafe block | ||
| 15022 | + res.str[res.len] = 0; | ||
| 15023 | + } | ||
| 15024 | + return res; | ||
| 15025 | +} | ||
| 15026 | +inline string Array_string_join_lines(Array_string s) { | ||
| 15027 | + return Array_string_join(s, _S("\n")); | ||
| 15028 | +} | ||
| 15029 | +string builtin__string_reverse(string s) { | ||
| 15030 | + if (s.len == 0 || s.len == 1) { | ||
| 15031 | + return builtin__string_clone(s); | ||
| 15032 | + } | ||
| 15033 | + string _t2 = ((string){.str = builtin__malloc_noscan(s.len + 1), .len = s.len}); | ||
| 15034 | + string res = _t2; | ||
| 15035 | + for (int i = s.len - 1; i >= 0; i--) { | ||
| 15036 | + { // Unsafe block | ||
| 15037 | + res.str[s.len - i - 1] = s.str[ i]; | ||
| 15038 | + } | ||
| 15039 | + } | ||
| 15040 | + { // Unsafe block | ||
| 15041 | + res.str[res.len] = 0; | ||
| 15042 | + } | ||
| 15043 | + return res; | ||
| 15044 | +} | ||
| 15045 | +string builtin__string_limit(string s, int max) { | ||
| 15046 | + Array_rune u = builtin__string_runes(s); | ||
| 15047 | + if (u.len <= max) { | ||
| 15048 | + return builtin__string_clone(s); | ||
| 15049 | + } | ||
| 15050 | + return Array_rune_string(builtin__array_slice(u, 0, max)); | ||
| 15051 | +} | ||
| 15052 | +int builtin__string_hash(string s) { | ||
| 15053 | + u32 h = ((u32)(0)); | ||
| 15054 | + if (h == 0 && s.len > 0) { | ||
| 15055 | + for (int _t1 = 0; _t1 < s.len; ++_t1) { | ||
| 15056 | + u8 c = s.str[_t1]; | ||
| 15057 | + h = h * 31 + ((u32)(c)); | ||
| 15058 | + } | ||
| 15059 | + } | ||
| 15060 | + return ((int)(h)); | ||
| 15061 | +} | ||
| 15062 | +Array_u8 builtin__string_bytes(string s) { | ||
| 15063 | + if (s.len == 0) { | ||
| 15064 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | ||
| 15065 | + } | ||
| 15066 | + Array_u8 buf = builtin____new_array_with_default(s.len, 0, sizeof(u8), 0); | ||
| 15067 | + builtin__vmemcpy(buf.data, s.str, s.len); | ||
| 15068 | + return buf; | ||
| 15069 | +} | ||
| 15070 | +string builtin__string_repeat(string s, int count) { | ||
| 15071 | + if (count <= 0) { | ||
| 15072 | + return _S(""); | ||
| 15073 | + } else if (count == 1) { | ||
| 15074 | + return builtin__string_clone(s); | ||
| 15075 | + } | ||
| 15076 | + u8* ret = builtin__malloc_noscan(s.len * count + 1); | ||
| 15077 | + for (int i = 0; i < count; ++i) { | ||
| 15078 | + builtin__vmemcpy(ret + (int)(i * s.len), s.str, s.len); | ||
| 15079 | + } | ||
| 15080 | + int new_len = s.len * count; | ||
| 15081 | + { // Unsafe block | ||
| 15082 | + ret[new_len] = 0; | ||
| 15083 | + } | ||
| 15084 | + return builtin__u8_vstring_with_len(ret, new_len); | ||
| 15085 | +} | ||
| 15086 | +Array_string builtin__string_fields(string s) { | ||
| 15087 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | ||
| 15088 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | ||
| 15089 | + int word_start = 0; | ||
| 15090 | + int word_len = 0; | ||
| 15091 | + bool is_in_word = false; | ||
| 15092 | + bool is_space = false; | ||
| 15093 | + for (int i = 0; i < s.len; ++i) { | ||
| 15094 | + u8 c = s.str[i]; | ||
| 15095 | + is_space = (c == 32 || c == 9 || c == 10); | ||
| 15096 | + if (!is_space) { | ||
| 15097 | + word_len++; | ||
| 15098 | + } | ||
| 15099 | + if (!is_in_word && !is_space) { | ||
| 15100 | + word_start = i; | ||
| 15101 | + is_in_word = true; | ||
| 15102 | + continue; | ||
| 15103 | + } | ||
| 15104 | + if (is_space && is_in_word) { | ||
| 15105 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, word_start, word_start + word_len) })); | ||
| 15106 | + is_in_word = false; | ||
| 15107 | + word_len = 0; | ||
| 15108 | + word_start = 0; | ||
| 15109 | + continue; | ||
| 15110 | + } | ||
| 15111 | + } | ||
| 15112 | + if (is_in_word && word_len > 0) { | ||
| 15113 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, word_start, s.len) })); | ||
| 15114 | + } | ||
| 15115 | + Array_string _t3 = res; | ||
| 15116 | + { // defer begin | ||
| 15117 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | ||
| 15118 | + } // defer end | ||
| 15119 | + return _t3; | ||
| 15120 | +} | ||
| 15121 | +inline string builtin__string_strip_margin(string s) { | ||
| 15122 | + return builtin__string_strip_margin_custom(s, '|'); | ||
| 15123 | +} | ||
| 15124 | +string builtin__string_strip_margin_custom(string s, u8 del) { | ||
| 15125 | + u8 sep = del; | ||
| 15126 | + if (builtin__u8_is_space(sep)) { | ||
| 15127 | + builtin__println(_S("Warning: `strip_margin` cannot use white-space as a delimiter")); | ||
| 15128 | + builtin__println(_S(" Defaulting to `|`")); | ||
| 15129 | + sep = '|'; | ||
| 15130 | + } | ||
| 15131 | + u8* ret = builtin__malloc_noscan(s.len + 1); | ||
| 15132 | + int count = 0; | ||
| 15133 | + for (int i = 0; i < s.len; i++) { | ||
| 15134 | + if (s.str[ i] == 10 || s.str[ i] == 13) { | ||
| 15135 | + { // Unsafe block | ||
| 15136 | + ret[count] = s.str[ i]; | ||
| 15137 | + } | ||
| 15138 | + count++; | ||
| 15139 | + if (s.str[ i] == 13 && i < s.len - 1 && s.str[ i + 1] == 10) { | ||
| 15140 | + { // Unsafe block | ||
| 15141 | + ret[count] = s.str[ i + 1]; | ||
| 15142 | + } | ||
| 15143 | + count++; | ||
| 15144 | + i++; | ||
| 15145 | + } | ||
| 15146 | + for (;;) { | ||
| 15147 | + if (!(s.str[ i] != sep)) break; | ||
| 15148 | + i++; | ||
| 15149 | + if (i >= s.len) { | ||
| 15150 | + break; | ||
| 15151 | + } | ||
| 15152 | + } | ||
| 15153 | + } else { | ||
| 15154 | + { // Unsafe block | ||
| 15155 | + ret[count] = s.str[ i]; | ||
| 15156 | + } | ||
| 15157 | + count++; | ||
| 15158 | + } | ||
| 15159 | + } | ||
| 15160 | + { // Unsafe block | ||
| 15161 | + ret[count] = 0; | ||
| 15162 | + return builtin__u8_vstring_with_len(ret, count); | ||
| 15163 | + } | ||
| 15164 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 15165 | +} | ||
| 15166 | +string builtin__string_trim_indent(string s) { | ||
| 15167 | + Array_string lines = builtin__string_split_into_lines(s); | ||
| 15168 | + int min_common_indent = ((int)(_const_max_int)); | ||
| 15169 | + for (int _t1 = 0; _t1 < lines.len; ++_t1) { | ||
| 15170 | + string line = ((string*)lines.data)[_t1]; | ||
| 15171 | + if (builtin__string_is_blank(line)) { | ||
| 15172 | + continue; | ||
| 15173 | + } | ||
| 15174 | + int line_indent = builtin__string_indent_width(line); | ||
| 15175 | + if (line_indent < min_common_indent) { | ||
| 15176 | + min_common_indent = line_indent; | ||
| 15177 | + } | ||
| 15178 | + } | ||
| 15179 | + if (lines.len > 0 && builtin__string_is_blank((*(string*)builtin__array_first(lines)))) { | ||
| 15180 | + lines = builtin__array_slice(lines, 1, 2147483647); | ||
| 15181 | + } | ||
| 15182 | + if (lines.len > 0 && builtin__string_is_blank((*(string*)builtin__array_last(lines)))) { | ||
| 15183 | + lines = builtin__array_slice(lines, 0, lines.len - 1); | ||
| 15184 | + } | ||
| 15185 | + Array_string trimmed_lines = builtin____new_array_with_default(0, lines.len, sizeof(string), 0); | ||
| 15186 | + for (int _t2 = 0; _t2 < lines.len; ++_t2) { | ||
| 15187 | + string line = ((string*)lines.data)[_t2]; | ||
| 15188 | + if (builtin__string_is_blank(line)) { | ||
| 15189 | + builtin__array_push((array*)&trimmed_lines, _MOV((string[]){ line })); | ||
| 15190 | + continue; | ||
| 15191 | + } | ||
| 15192 | + builtin__array_push((array*)&trimmed_lines, _MOV((string[]){ builtin__string_substr(line, min_common_indent, 2147483647) })); | ||
| 15193 | + } | ||
| 15194 | + return Array_string_join(trimmed_lines, _S("\n")); | ||
| 15195 | +} | ||
| 15196 | +int builtin__string_indent_width(string s) { | ||
| 15197 | + for (int i = 0; i < s.len; ++i) { | ||
| 15198 | + u8 c = s.str[i]; | ||
| 15199 | + if (!builtin__u8_is_space(c)) { | ||
| 15200 | + return i; | ||
| 15201 | + } | ||
| 15202 | + } | ||
| 15203 | + return 0; | ||
| 15204 | +} | ||
| 15205 | +bool builtin__string_is_blank(string s) { | ||
| 15206 | + if (s.len == 0) { | ||
| 15207 | + return true; | ||
| 15208 | + } | ||
| 15209 | + for (int _t2 = 0; _t2 < s.len; ++_t2) { | ||
| 15210 | + u8 c = s.str[_t2]; | ||
| 15211 | + if (!builtin__u8_is_space(c)) { | ||
| 15212 | + return false; | ||
| 15213 | + } | ||
| 15214 | + } | ||
| 15215 | + return true; | ||
| 15216 | +} | ||
| 15217 | +bool builtin__string_match_glob(string name, string pattern) { | ||
| 15218 | + int px = 0; | ||
| 15219 | + int nx = 0; | ||
| 15220 | + int next_px = 0; | ||
| 15221 | + int next_nx = 0; | ||
| 15222 | + int plen = pattern.len; | ||
| 15223 | + int nlen = name.len; | ||
| 15224 | + for (;;) { | ||
| 15225 | + if (!(px < plen || nx < nlen)) break; | ||
| 15226 | + if (px < plen) { | ||
| 15227 | + u8 c = pattern.str[ px]; | ||
| 15228 | + | ||
| 15229 | + if (c == ('?')) { | ||
| 15230 | + if (nx < nlen) { | ||
| 15231 | + px++; | ||
| 15232 | + nx++; | ||
| 15233 | + continue; | ||
| 15234 | + } | ||
| 15235 | + } | ||
| 15236 | + else if (c == ('*')) { | ||
| 15237 | + next_px = px; | ||
| 15238 | + next_nx = nx + 1; | ||
| 15239 | + px++; | ||
| 15240 | + continue; | ||
| 15241 | + } | ||
| 15242 | + else if (c == ('[')) { | ||
| 15243 | + if (nx < nlen) { | ||
| 15244 | + u8 wanted_c = name.str[ nx]; | ||
| 15245 | + bool is_inverted = false; | ||
| 15246 | + bool inner_match = false; | ||
| 15247 | + int inner_idx = px + 1; | ||
| 15248 | + if (inner_idx < plen && pattern.str[ inner_idx] == '^') { | ||
| 15249 | + is_inverted = true; | ||
| 15250 | + inner_idx++; | ||
| 15251 | + } | ||
| 15252 | + for (; inner_idx < plen && pattern.str[ inner_idx] != ']'; inner_idx++) { | ||
| 15253 | + if (pattern.str[ inner_idx] == wanted_c) { | ||
| 15254 | + inner_match = true; | ||
| 15255 | + } | ||
| 15256 | + } | ||
| 15257 | + if (inner_idx < plen && ((inner_match && !is_inverted) || (!inner_match && is_inverted))) { | ||
| 15258 | + px = inner_idx + 1; | ||
| 15259 | + nx++; | ||
| 15260 | + continue; | ||
| 15261 | + } | ||
| 15262 | + } | ||
| 15263 | + } | ||
| 15264 | + else { | ||
| 15265 | + if (nx < nlen && name.str[ nx] == c) { | ||
| 15266 | + px++; | ||
| 15267 | + nx++; | ||
| 15268 | + continue; | ||
| 15269 | + } | ||
| 15270 | + } | ||
| 15271 | + } | ||
| 15272 | + if (0 < next_nx && next_nx <= nlen) { | ||
| 15273 | + px = next_px; | ||
| 15274 | + nx = next_nx; | ||
| 15275 | + continue; | ||
| 15276 | + } | ||
| 15277 | + return false; | ||
| 15278 | + } | ||
| 15279 | + return true; | ||
| 15280 | +} | ||
| 15281 | +inline bool builtin__string_is_ascii(string s) { | ||
| 15282 | + for (int i = 0; i < s.len; i++) { | ||
| 15283 | + if (s.str[ i] < ((u8)(' ')) || s.str[ i] > ((u8)('~'))) { | ||
| 15284 | + return false; | ||
| 15285 | + } | ||
| 15286 | + } | ||
| 15287 | + return true; | ||
| 15288 | +} | ||
| 15289 | +bool builtin__string_is_identifier(string s) { | ||
| 15290 | + if (s.len == 0) { | ||
| 15291 | + return false; | ||
| 15292 | + } | ||
| 15293 | + if (!(builtin__u8_is_letter(s.str[ 0]) || s.str[ 0] == '_')) { | ||
| 15294 | + return false; | ||
| 15295 | + } | ||
| 15296 | + for (int i = 1; i < s.len; i++) { | ||
| 15297 | + u8 c = s.str[ i]; | ||
| 15298 | + if (!(builtin__u8_is_letter(c) || builtin__u8_is_digit(c) || c == '_')) { | ||
| 15299 | + return false; | ||
| 15300 | + } | ||
| 15301 | + } | ||
| 15302 | + return true; | ||
| 15303 | +} | ||
| 15304 | +string builtin__string_camel_to_snake(string s) { | ||
| 15305 | + if (s.len == 0) { | ||
| 15306 | + return _S(""); | ||
| 15307 | + } | ||
| 15308 | + if (s.len == 1) { | ||
| 15309 | + return builtin__string_to_lower_ascii(s); | ||
| 15310 | + } | ||
| 15311 | + u8* b = builtin__malloc_noscan(2 * s.len + 1); | ||
| 15312 | + int pos = 2; | ||
| 15313 | + bool prev_is_upper = false; | ||
| 15314 | + bool prev_inserted_boundary = false; | ||
| 15315 | + { // Unsafe block | ||
| 15316 | + if (builtin__u8_is_capital(s.str[ 0])) { | ||
| 15317 | + b[0] = (u8)(s.str[ 0] + 32); | ||
| 15318 | + u8 _t3; /* if prepend */ | ||
| 15319 | + if (builtin__u8_is_capital(s.str[ 1])) { | ||
| 15320 | + prev_is_upper = true; | ||
| 15321 | + _t3 = (u8)(s.str[ 1] + 32); | ||
| 15322 | + goto _t4; | ||
| 15323 | + }; | ||
| 15324 | + { | ||
| 15325 | + _t3 = s.str[ 1]; | ||
| 15326 | + } | ||
| 15327 | + _t4: {}; | ||
| 15328 | + b[1] = _t3; | ||
| 15329 | + } else { | ||
| 15330 | + b[0] = s.str[ 0]; | ||
| 15331 | + if (builtin__u8_is_capital(s.str[ 1])) { | ||
| 15332 | + prev_is_upper = true; | ||
| 15333 | + if (s.str[ 0] != '_' && s.len > 2 && !builtin__u8_is_capital(s.str[ 2])) { | ||
| 15334 | + b[1] = '_'; | ||
| 15335 | + b[2] = (u8)(s.str[ 1] + 32); | ||
| 15336 | + pos = 3; | ||
| 15337 | + } else { | ||
| 15338 | + b[1] = (u8)(s.str[ 1] + 32); | ||
| 15339 | + } | ||
| 15340 | + } else { | ||
| 15341 | + b[1] = s.str[ 1]; | ||
| 15342 | + } | ||
| 15343 | + } | ||
| 15344 | + } | ||
| 15345 | + for (int i = 2; i < s.len; i++) { | ||
| 15346 | + bool has_boundary_before_upper = false; | ||
| 15347 | + u8 c = s.str[ i]; | ||
| 15348 | + bool c_is_upper = builtin__u8_is_capital(c); | ||
| 15349 | + bool c_is_number = builtin__u8_is_digit(c); | ||
| 15350 | + bool next_is_lower = i + 1 < s.len && builtin__u8_is_letter(s.str[ i + 1]) && !builtin__u8_is_capital(s.str[ i + 1]); | ||
| 15351 | + bool next2_is_lower = i + 2 < s.len && builtin__u8_is_letter(s.str[ i + 2]) && !builtin__u8_is_capital(s.str[ i + 2]); | ||
| 15352 | + bool skip_digit = c_is_number && prev_is_upper && !next_is_lower && next2_is_lower; | ||
| 15353 | + if (c_is_upper && prev_is_upper && i >= 2 && builtin__u8_is_capital(s.str[ i - 2]) && next_is_lower && c != '_') { | ||
| 15354 | + { // Unsafe block | ||
| 15355 | + if (b[pos - 1] != '_') { | ||
| 15356 | + b[pos] = '_'; | ||
| 15357 | + pos++; | ||
| 15358 | + } | ||
| 15359 | + } | ||
| 15360 | + has_boundary_before_upper = true; | ||
| 15361 | + } | ||
| 15362 | + if (((c_is_upper && !prev_is_upper) || (!c_is_upper && prev_is_upper && builtin__u8_is_capital(s.str[ i - 2]) && !prev_inserted_boundary && !skip_digit)) && c != '_') { | ||
| 15363 | + { // Unsafe block | ||
| 15364 | + if (b[pos - 1] != '_') { | ||
| 15365 | + b[pos] = '_'; | ||
| 15366 | + pos++; | ||
| 15367 | + } | ||
| 15368 | + } | ||
| 15369 | + } | ||
| 15370 | + u8 lower_c = (c_is_upper ? ((u8)(c + 32)) : (c)); | ||
| 15371 | + { // Unsafe block | ||
| 15372 | + b[pos] = lower_c; | ||
| 15373 | + } | ||
| 15374 | + prev_is_upper = c_is_upper; | ||
| 15375 | + prev_inserted_boundary = has_boundary_before_upper; | ||
| 15376 | + pos++; | ||
| 15377 | + } | ||
| 15378 | + { // Unsafe block | ||
| 15379 | + b[pos] = 0; | ||
| 15380 | + } | ||
| 15381 | + return builtin__tos(b, pos); | ||
| 15382 | +} | ||
| 15383 | +string builtin__string_snake_to_camel(string s) { | ||
| 15384 | + if (s.len == 0) { | ||
| 15385 | + return _S(""); | ||
| 15386 | + } | ||
| 15387 | + if (s.len == 1) { | ||
| 15388 | + return s; | ||
| 15389 | + } | ||
| 15390 | + bool need_upper = true; | ||
| 15391 | + rune upper_c = '_'; | ||
| 15392 | + u8* b = builtin__malloc_noscan(s.len + 1); | ||
| 15393 | + int i = 0; | ||
| 15394 | + for (int _t3 = 0; _t3 < s.len; ++_t3) { | ||
| 15395 | + u8 c = s.str[_t3]; | ||
| 15396 | + upper_c = (c >= 'a' && c <= 'z' ? ((u8)(c - 32)) : (c)); | ||
| 15397 | + if (c == '_') { | ||
| 15398 | + need_upper = true; | ||
| 15399 | + } else if (need_upper) { | ||
| 15400 | + { // Unsafe block | ||
| 15401 | + b[i] = upper_c; | ||
| 15402 | + } | ||
| 15403 | + i++; | ||
| 15404 | + need_upper = false; | ||
| 15405 | + } else { | ||
| 15406 | + { // Unsafe block | ||
| 15407 | + b[i] = c; | ||
| 15408 | + } | ||
| 15409 | + i++; | ||
| 15410 | + } | ||
| 15411 | + } | ||
| 15412 | + { // Unsafe block | ||
| 15413 | + b[i] = 0; | ||
| 15414 | + } | ||
| 15415 | + return builtin__tos(b, i); | ||
| 15416 | +} | ||
| 15417 | +string builtin__string_wrap(string s, WrapConfig config) { | ||
| 15418 | + if (config.width <= 0) { | ||
| 15419 | + return _S(""); | ||
| 15420 | + } | ||
| 15421 | + Array_string words = builtin__string_fields(s); | ||
| 15422 | + if (words.len == 0) { | ||
| 15423 | + return _S(""); | ||
| 15424 | + } | ||
| 15425 | + strings__Builder sb = strings__new_builder(s.len); | ||
| 15426 | + strings__Builder_write_string(&sb, (*(string*)builtin__array_get(words, 0))); | ||
| 15427 | + int space_left = config.width - (*(string*)builtin__array_get(words, 0)).len; | ||
| 15428 | + for (int i = 1; i < words.len; ++i) { | ||
| 15429 | + string word = (*(string*)builtin__array_get(words, i)); | ||
| 15430 | + if (word.len + 1 > space_left) { | ||
| 15431 | + strings__Builder_write_string(&sb, config.end); | ||
| 15432 | + strings__Builder_write_string(&sb, word); | ||
| 15433 | + space_left = config.width - word.len; | ||
| 15434 | + } else { | ||
| 15435 | + strings__Builder_write_string(&sb, _S(" ")); | ||
| 15436 | + strings__Builder_write_string(&sb, word); | ||
| 15437 | + space_left -= 1 + word.len; | ||
| 15438 | + } | ||
| 15439 | + } | ||
| 15440 | + return strings__Builder_str(&sb); | ||
| 15441 | +} | ||
| 15442 | +string builtin__string_hex(string s) { | ||
| 15443 | + if ((s).len == 0) { | ||
| 15444 | + return _S(""); | ||
| 15445 | + } | ||
| 15446 | + return builtin__data_to_hex_string(s.str, s.len); | ||
| 15447 | +} | ||
| 15448 | +VV_LOC string builtin__data_to_hex_string(u8* data, int len) { | ||
| 15449 | + u8* hex = builtin__malloc_noscan(((u64)(len)) * 2 + 1); | ||
| 15450 | + int dst = 0; | ||
| 15451 | + for (int c = 0; c < len; ++c) { | ||
| 15452 | + u8 b = data[c]; | ||
| 15453 | + u8 n0 = v__rshift_u8(b, (u64)4); | ||
| 15454 | + u8 n1 = (b & 0xF); | ||
| 15455 | + hex[dst] = (n0 < 10 ? ((rune)(n0 + '0')) : ((rune)(n0 + 'W'))); | ||
| 15456 | + hex[dst + 1] = (n1 < 10 ? ((rune)(n1 + '0')) : ((rune)(n1 + 'W'))); | ||
| 15457 | + dst += 2; | ||
| 15458 | + } | ||
| 15459 | + hex[dst] = 0; | ||
| 15460 | + return builtin__tos(hex, dst); | ||
| 15461 | +} | ||
| 15462 | +RunesIterator builtin__string_runes_iterator(string s) { | ||
| 15463 | + return ((RunesIterator){.s = s,.i = 0,}); | ||
| 15464 | +} | ||
| 15465 | +_option_rune builtin__RunesIterator_next(RunesIterator* ri) { | ||
| 15466 | + if (ri->i >= ri->s.len) { | ||
| 15467 | + return (_option_rune){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | ||
| 15468 | + } | ||
| 15469 | + multi_return_rune_int mr_82852 = builtin__utf8_decode_rune(&ri->s.str[ri->i], ri->s.len - ri->i); | ||
| 15470 | + rune r = mr_82852.arg0; | ||
| 15471 | + int char_len = mr_82852.arg1; | ||
| 15472 | + ri->i += (char_len > 0 ? (char_len) : (1)); | ||
| 15473 | + _option_rune _t2; | ||
| 15474 | + builtin___option_ok(&(rune[]) { r }, (_option*)(&_t2), sizeof(rune)); | ||
| 15475 | + | ||
| 15476 | + return _t2; | ||
| 15477 | +} | ||
| 15478 | +Array_u8 builtin__byteptr_vbytes(byteptr data, int len) { | ||
| 15479 | + return builtin__voidptr_vbytes(((voidptr)(data)), len); | ||
| 15480 | +} | ||
| 15481 | +string builtin__byteptr_vstring(byteptr bp) { | ||
| 15482 | + return ((string){.str = bp, .len = builtin__vstrlen(bp)}); | ||
| 15483 | +} | ||
| 15484 | +string builtin__byteptr_vstring_with_len(byteptr bp, int len) { | ||
| 15485 | + return ((string){.str = bp, .len = len, .is_lit = 0}); | ||
| 15486 | +} | ||
| 15487 | +string builtin__charptr_vstring(charptr cp) { | ||
| 15488 | + return ((string){.str = ((byteptr)(cp)), .len = builtin__vstrlen_char(cp), .is_lit = 0}); | ||
| 15489 | +} | ||
| 15490 | +string builtin__charptr_vstring_with_len(charptr cp, int len) { | ||
| 15491 | + return ((string){.str = ((byteptr)(cp)), .len = len, .is_lit = 0}); | ||
| 15492 | +} | ||
| 15493 | +string builtin__byteptr_vstring_literal(byteptr bp) { | ||
| 15494 | + return ((string){.str = bp, .len = builtin__vstrlen(bp), .is_lit = 1}); | ||
| 15495 | +} | ||
| 15496 | +string builtin__byteptr_vstring_literal_with_len(byteptr bp, int len) { | ||
| 15497 | + return ((string){.str = bp, .len = len, .is_lit = 1}); | ||
| 15498 | +} | ||
| 15499 | +string builtin__charptr_vstring_literal(charptr cp) { | ||
| 15500 | + return ((string){.str = ((byteptr)(cp)), .len = builtin__vstrlen_char(cp), .is_lit = 1}); | ||
| 15501 | +} | ||
| 15502 | +string builtin__charptr_vstring_literal_with_len(charptr cp, int len) { | ||
| 15503 | + return ((string){.str = ((byteptr)(cp)), .len = len, .is_lit = 1}); | ||
| 15504 | +} | ||
| 15505 | +string builtin__StrIntpType_str(StrIntpType x) { | ||
| 15506 | + string _t2 = (string){.str=(byteptr)"", .is_lit=1}; | ||
| 15507 | + switch (x) { | ||
| 15508 | + case StrIntpType__si_no_str: { | ||
| 15509 | + _t2 = _S("no_str"); | ||
| 15510 | + break; | ||
| 15511 | + } | ||
| 15512 | + case StrIntpType__si_c: { | ||
| 15513 | + _t2 = _S("c"); | ||
| 15514 | + break; | ||
| 15515 | + } | ||
| 15516 | + case StrIntpType__si_u8: { | ||
| 15517 | + _t2 = _S("u8"); | ||
| 15518 | + break; | ||
| 15519 | + } | ||
| 15520 | + case StrIntpType__si_i8: { | ||
| 15521 | + _t2 = _S("i8"); | ||
| 15522 | + break; | ||
| 15523 | + } | ||
| 15524 | + case StrIntpType__si_u16: { | ||
| 15525 | + _t2 = _S("u16"); | ||
| 15526 | + break; | ||
| 15527 | + } | ||
| 15528 | + case StrIntpType__si_i16: { | ||
| 15529 | + _t2 = _S("i16"); | ||
| 15530 | + break; | ||
| 15531 | + } | ||
| 15532 | + case StrIntpType__si_u32: { | ||
| 15533 | + _t2 = _S("u32"); | ||
| 15534 | + break; | ||
| 15535 | + } | ||
| 15536 | + case StrIntpType__si_i32: { | ||
| 15537 | + _t2 = _S("i32"); | ||
| 15538 | + break; | ||
| 15539 | + } | ||
| 15540 | + case StrIntpType__si_u64: { | ||
| 15541 | + _t2 = _S("u64"); | ||
| 15542 | + break; | ||
| 15543 | + } | ||
| 15544 | + case StrIntpType__si_i64: { | ||
| 15545 | + _t2 = _S("i64"); | ||
| 15546 | + break; | ||
| 15547 | + } | ||
| 15548 | + case StrIntpType__si_f32: { | ||
| 15549 | + _t2 = _S("f32"); | ||
| 15550 | + break; | ||
| 15551 | + } | ||
| 15552 | + case StrIntpType__si_f64: { | ||
| 15553 | + _t2 = _S("f64"); | ||
| 15554 | + break; | ||
| 15555 | + } | ||
| 15556 | + case StrIntpType__si_g32: { | ||
| 15557 | + _t2 = _S("f32"); | ||
| 15558 | + break; | ||
| 15559 | + } | ||
| 15560 | + case StrIntpType__si_g64: { | ||
| 15561 | + _t2 = _S("f64"); | ||
| 15562 | + break; | ||
| 15563 | + } | ||
| 15564 | + case StrIntpType__si_e32: { | ||
| 15565 | + _t2 = _S("f32"); | ||
| 15566 | + break; | ||
| 15567 | + } | ||
| 15568 | + case StrIntpType__si_e64: { | ||
| 15569 | + _t2 = _S("f64"); | ||
| 15570 | + break; | ||
| 15571 | + } | ||
| 15572 | + case StrIntpType__si_s: { | ||
| 15573 | + _t2 = _S("s"); | ||
| 15574 | + break; | ||
| 15575 | + } | ||
| 15576 | + case StrIntpType__si_p: { | ||
| 15577 | + _t2 = _S("p"); | ||
| 15578 | + break; | ||
| 15579 | + } | ||
| 15580 | + case StrIntpType__si_r: { | ||
| 15581 | + _t2 = _S("r"); | ||
| 15582 | + break; | ||
| 15583 | + } | ||
| 15584 | + case StrIntpType__si_vp: { | ||
| 15585 | + _t2 = _S("vp"); | ||
| 15586 | + break; | ||
| 15587 | + } | ||
| 15588 | + } | ||
| 15589 | + return _t2; | ||
| 15590 | +} | ||
| 15591 | +inline VV_LOC f32 builtin__fabs32(f32 x) { | ||
| 15592 | + return (x < 0 ? (-x) : (x)); | ||
| 15593 | +} | ||
| 15594 | +inline VV_LOC f64 builtin__fabs64(f64 x) { | ||
| 15595 | + return (x < 0 ? (-x) : (x)); | ||
| 15596 | +} | ||
| 15597 | +inline VV_LOC u64 builtin__abs64(i64 x) { | ||
| 15598 | + return (x < 0 ? (((u64)(-x))) : (((u64)(x)))); | ||
| 15599 | +} | ||
| 15600 | +u64 builtin__get_str_intp_u64_format(StrIntpType fmt_type, int in_width, int in_precision, bool in_tail_zeros, bool in_sign, u8 in_pad_ch, int in_base, bool in_upper_case) { | ||
| 15601 | + u64 width = (in_width != 0 ? (builtin__abs64(in_width)) : (((u64)(0)))); | ||
| 15602 | + u64 align = (in_width > 0 ? (((u64)(32))) : (((u64)(0)))); | ||
| 15603 | + u64 upper_case = (in_upper_case ? (((u64)(128))) : (((u64)(0)))); | ||
| 15604 | + u64 sign = (in_sign ? (((u64)(256))) : (((u64)(0)))); | ||
| 15605 | + u64 precision = (in_precision != 987698 ? ((v__lshift_u64(((u64)((in_precision & 0x7F))), (u64)9))) : (v__lshift_u64(((u64)(0x7F)), (u64)9))); | ||
| 15606 | + u32 tail_zeros = (in_tail_zeros ? (v__lshift_u32(((u32)(1)), (u64)16)) : (((u32)(0)))); | ||
| 15607 | + u64 base = ((u64)(v__lshift_u32(((u32)((in_base & 0xf))), (u64)27))); | ||
| 15608 | + u64 res = ((u64)(((((((((((((u64)(fmt_type)) & 0x1F)) | align) | upper_case) | sign) | precision) | tail_zeros) | (v__lshift_u64(((u64)((width & 0x3FF))), (u64)17))) | base) | (v__lshift_u64(((u64)(in_pad_ch)), (u64)31))))); | ||
| 15609 | + return res; | ||
| 15610 | +} | ||
| 15611 | +u32 builtin__get_str_intp_u32_format(StrIntpType fmt_type, int in_width, int in_precision, bool in_tail_zeros, bool in_sign, u8 in_pad_ch, int in_base, bool in_upper_case) { | ||
| 15612 | + u64 width = (in_width != 0 ? (builtin__abs64(in_width)) : (((u32)(0)))); | ||
| 15613 | + u32 align = (in_width > 0 ? (((u32)(32))) : (((u32)(0)))); | ||
| 15614 | + u32 upper_case = (in_upper_case ? (((u32)(128))) : (((u32)(0)))); | ||
| 15615 | + u32 sign = (in_sign ? (((u32)(256))) : (((u32)(0)))); | ||
| 15616 | + u32 precision = (in_precision != 987698 ? ((v__lshift_u32(((u32)((in_precision & 0x7F))), (u64)9))) : (v__lshift_u32(((u32)(0x7F)), (u64)9))); | ||
| 15617 | + u32 tail_zeros = (in_tail_zeros ? (v__lshift_u32(((u32)(1)), (u64)16)) : (((u32)(0)))); | ||
| 15618 | + u32 base = ((u32)(v__lshift_u32(((u32)((in_base & 0xf))), (u64)27))); | ||
| 15619 | + u32 res = ((u32)(((((((((((((u32)(fmt_type)) & 0x1F)) | align) | upper_case) | sign) | precision) | tail_zeros) | (v__lshift_u32(((u32)((width & 0x3FF))), (u64)17))) | base) | (v__lshift_u32(((u32)((in_pad_ch & 1))), (u64)31))))); | ||
| 15620 | + return res; | ||
| 15621 | +} | ||
| 15622 | +VV_LOC void builtin__StrIntpData_process_str_intp_data(StrIntpData* data, strings__Builder* sb) { | ||
| 15623 | + u32 x = data->fmt; | ||
| 15624 | + StrIntpType typ = ((StrIntpType)((x & 0x1F))); | ||
| 15625 | + int align = ((int)(((v__rshift_u32(x, (u64)5)) & 0x01))); | ||
| 15626 | + bool upper_case = (((v__rshift_u32(x, (u64)7)) & 0x01)) > 0; | ||
| 15627 | + int sign = ((int)(((v__rshift_u32(x, (u64)8)) & 0x01))); | ||
| 15628 | + int precision = ((int)(((v__rshift_u32(x, (u64)9)) & 0x7F))); | ||
| 15629 | + bool tail_zeros = (((v__rshift_u32(x, (u64)16)) & 0x01)) > 0; | ||
| 15630 | + int width = ((int)(((i16)(((v__rshift_u32(x, (u64)17)) & 0x3FF))))); | ||
| 15631 | + int base = (((int)(v__rshift_u32(x, (u64)27))) & 0xF); | ||
| 15632 | + u8 fmt_pad_ch = ((u8)(((v__rshift_u32(x, (u64)31)) & 0xFF))); | ||
| 15633 | + bool has_dynamic_width = ((data->dyn_flags & _const_str_intp_has_dynamic_width)) != 0; | ||
| 15634 | + bool has_dynamic_precision = ((data->dyn_flags & _const_str_intp_has_dynamic_precision)) != 0; | ||
| 15635 | + if (typ == StrIntpType__si_no_str) { | ||
| 15636 | + return; | ||
| 15637 | + } | ||
| 15638 | + if (base > 0) { | ||
| 15639 | + base += 2; | ||
| 15640 | + } | ||
| 15641 | + if (has_dynamic_width) { | ||
| 15642 | + width = data->dyn_width; | ||
| 15643 | + if (width < 0) { | ||
| 15644 | + width = -width; | ||
| 15645 | + align = 0; | ||
| 15646 | + } else if (width > 0) { | ||
| 15647 | + align = 1; | ||
| 15648 | + } | ||
| 15649 | + } | ||
| 15650 | + if (has_dynamic_precision) { | ||
| 15651 | + precision = data->dyn_precision; | ||
| 15652 | + } | ||
| 15653 | + u8 pad_ch = ((u8)(' ')); | ||
| 15654 | + if (fmt_pad_ch > 0) { | ||
| 15655 | + pad_ch = '0'; | ||
| 15656 | + } | ||
| 15657 | + int len0_set = (width > 0 ? (width) : (-1)); | ||
| 15658 | + int len1_set = (has_dynamic_precision ? ((precision >= 0 ? (precision) : (-1))) : precision == 0x7F ? (-1) : (precision)); | ||
| 15659 | + bool sign_set = sign == 1; | ||
| 15660 | + strconv__BF_param bf = ((strconv__BF_param){ | ||
| 15661 | + .pad_ch = pad_ch, | ||
| 15662 | + .len0 = len0_set, | ||
| 15663 | + .len1 = len1_set, | ||
| 15664 | + .positive = true, | ||
| 15665 | + .sign_flag = sign_set, | ||
| 15666 | + .align = strconv__Align_text__left, | ||
| 15667 | + .rm_tail_zero = tail_zeros, | ||
| 15668 | + }); | ||
| 15669 | + if (fmt_pad_ch == 0 || pad_ch == '0') { | ||
| 15670 | + switch (align) { | ||
| 15671 | + case 0: { | ||
| 15672 | + bf.align = strconv__Align_text__left; | ||
| 15673 | + break; | ||
| 15674 | + } | ||
| 15675 | + case 1: { | ||
| 15676 | + bf.align = strconv__Align_text__right; | ||
| 15677 | + break; | ||
| 15678 | + } | ||
| 15679 | + default: { | ||
| 15680 | + { | ||
| 15681 | + bf.align = strconv__Align_text__left; | ||
| 15682 | + break; | ||
| 15683 | + } | ||
| 15684 | + } | ||
| 15685 | + } | ||
| 15686 | + | ||
| 15687 | + } else { | ||
| 15688 | + bf.align = strconv__Align_text__right; | ||
| 15689 | + } | ||
| 15690 | + { // Unsafe block | ||
| 15691 | + if (typ == StrIntpType__si_s) { | ||
| 15692 | + if (upper_case) { | ||
| 15693 | + string s = builtin__string_to_upper(data->d.d_s); | ||
| 15694 | + if (width == 0) { | ||
| 15695 | + strings__Builder_write_string(sb, s); | ||
| 15696 | + } else { | ||
| 15697 | + strconv__format_str_sb(s, bf, sb); | ||
| 15698 | + } | ||
| 15699 | + builtin__string_free(&s); | ||
| 15700 | + } else { | ||
| 15701 | + if (width == 0) { | ||
| 15702 | + strings__Builder_write_string(sb, data->d.d_s); | ||
| 15703 | + } else { | ||
| 15704 | + strconv__format_str_sb(data->d.d_s, bf, sb); | ||
| 15705 | + } | ||
| 15706 | + } | ||
| 15707 | + return; | ||
| 15708 | + } | ||
| 15709 | + if (typ == StrIntpType__si_r) { | ||
| 15710 | + if (width > 0) { | ||
| 15711 | + if (upper_case) { | ||
| 15712 | + string s = builtin__string_to_upper(data->d.d_s); | ||
| 15713 | + for (int _t1 = 1; _t1 < (1 + ((width > 0 ? (width) : (0)))); ++_t1) { | ||
| 15714 | + strings__Builder_write_string(sb, s); | ||
| 15715 | + } | ||
| 15716 | + builtin__string_free(&s); | ||
| 15717 | + } else { | ||
| 15718 | + for (int _t2 = 1; _t2 < (1 + ((width > 0 ? (width) : (0)))); ++_t2) { | ||
| 15719 | + strings__Builder_write_string(sb, data->d.d_s); | ||
| 15720 | + } | ||
| 15721 | + } | ||
| 15722 | + } | ||
| 15723 | + return; | ||
| 15724 | + } | ||
| 15725 | + if (typ == StrIntpType__si_i8 || typ == StrIntpType__si_i16 || typ == StrIntpType__si_i32 || typ == StrIntpType__si_i64) { | ||
| 15726 | + i64 d = data->d.d_i64; | ||
| 15727 | + if (typ == StrIntpType__si_i8) { | ||
| 15728 | + d = ((i64)(data->d.d_i8)); | ||
| 15729 | + } else if (typ == StrIntpType__si_i16) { | ||
| 15730 | + d = ((i64)(data->d.d_i16)); | ||
| 15731 | + } else if (typ == StrIntpType__si_i32) { | ||
| 15732 | + d = ((i64)(data->d.d_i32)); | ||
| 15733 | + } | ||
| 15734 | + if (base == 0) { | ||
| 15735 | + if (d < 0) { | ||
| 15736 | + bf.positive = false; | ||
| 15737 | + } | ||
| 15738 | + strconv__format_dec_sb(builtin__abs64(d), bf, sb); | ||
| 15739 | + } else { | ||
| 15740 | + if (base == 3) { | ||
| 15741 | + base = 2; | ||
| 15742 | + } | ||
| 15743 | + i64 absd = d; | ||
| 15744 | + bool write_minus = false; | ||
| 15745 | + if (d < 0 && pad_ch != ' ') { | ||
| 15746 | + absd = -d; | ||
| 15747 | + write_minus = true; | ||
| 15748 | + } | ||
| 15749 | + string hx = strconv__format_int(absd, base); | ||
| 15750 | + if (upper_case) { | ||
| 15751 | + string tmp = hx; | ||
| 15752 | + hx = builtin__string_to_upper(hx); | ||
| 15753 | + builtin__string_free(&tmp); | ||
| 15754 | + } | ||
| 15755 | + if (write_minus) { | ||
| 15756 | + strings__Builder_write_u8(sb, '-'); | ||
| 15757 | + bf.len0--; | ||
| 15758 | + } | ||
| 15759 | + if (width == 0) { | ||
| 15760 | + strings__Builder_write_string(sb, hx); | ||
| 15761 | + } else { | ||
| 15762 | + strconv__format_str_sb(hx, bf, sb); | ||
| 15763 | + } | ||
| 15764 | + builtin__string_free(&hx); | ||
| 15765 | + } | ||
| 15766 | + return; | ||
| 15767 | + } | ||
| 15768 | + if (typ == StrIntpType__si_u8 || typ == StrIntpType__si_u16 || typ == StrIntpType__si_u32 || typ == StrIntpType__si_u64) { | ||
| 15769 | + u64 d = data->d.d_u64; | ||
| 15770 | + if (typ == StrIntpType__si_u8) { | ||
| 15771 | + d = ((u64)(data->d.d_u8)); | ||
| 15772 | + } else if (typ == StrIntpType__si_u16) { | ||
| 15773 | + d = ((u64)(data->d.d_u16)); | ||
| 15774 | + } else if (typ == StrIntpType__si_u32) { | ||
| 15775 | + d = ((u64)(data->d.d_u32)); | ||
| 15776 | + } | ||
| 15777 | + if (base == 0) { | ||
| 15778 | + strconv__format_dec_sb(d, bf, sb); | ||
| 15779 | + } else { | ||
| 15780 | + if (base == 3) { | ||
| 15781 | + base = 2; | ||
| 15782 | + } | ||
| 15783 | + string hx = strconv__format_uint(d, base); | ||
| 15784 | + if (upper_case) { | ||
| 15785 | + string tmp = hx; | ||
| 15786 | + hx = builtin__string_to_upper(hx); | ||
| 15787 | + builtin__string_free(&tmp); | ||
| 15788 | + } | ||
| 15789 | + if (width == 0) { | ||
| 15790 | + strings__Builder_write_string(sb, hx); | ||
| 15791 | + } else { | ||
| 15792 | + strconv__format_str_sb(hx, bf, sb); | ||
| 15793 | + } | ||
| 15794 | + builtin__string_free(&hx); | ||
| 15795 | + } | ||
| 15796 | + return; | ||
| 15797 | + } | ||
| 15798 | + if (typ == StrIntpType__si_p) { | ||
| 15799 | + u64 d = ((u64)(data->d.d_p)); | ||
| 15800 | + base = 16; | ||
| 15801 | + if (base == 0) { | ||
| 15802 | + if (width == 0) { | ||
| 15803 | + string d_str = builtin__u64_str(d); | ||
| 15804 | + strings__Builder_write_string(sb, d_str); | ||
| 15805 | + builtin__string_free(&d_str); | ||
| 15806 | + return; | ||
| 15807 | + } | ||
| 15808 | + strconv__format_dec_sb(d, bf, sb); | ||
| 15809 | + } else { | ||
| 15810 | + string hx = strconv__format_uint(d, base); | ||
| 15811 | + if (upper_case) { | ||
| 15812 | + string tmp = hx; | ||
| 15813 | + hx = builtin__string_to_upper(hx); | ||
| 15814 | + builtin__string_free(&tmp); | ||
| 15815 | + } | ||
| 15816 | + if (width == 0) { | ||
| 15817 | + strings__Builder_write_string(sb, hx); | ||
| 15818 | + } else { | ||
| 15819 | + strconv__format_str_sb(hx, bf, sb); | ||
| 15820 | + } | ||
| 15821 | + builtin__string_free(&hx); | ||
| 15822 | + } | ||
| 15823 | + return; | ||
| 15824 | + } | ||
| 15825 | + bool use_default_str = false; | ||
| 15826 | + if (width == 0 && precision == 0x7F) { | ||
| 15827 | + bf.len1 = 3; | ||
| 15828 | + use_default_str = true; | ||
| 15829 | + } | ||
| 15830 | + if (bf.len1 < 0) { | ||
| 15831 | + bf.len1 = 3; | ||
| 15832 | + } | ||
| 15833 | + switch (typ) { | ||
| 15834 | + case StrIntpType__si_f32: { | ||
| 15835 | + #if !defined(CUSTOM_DEFINE_nofloat) | ||
| 15836 | + { | ||
| 15837 | + if (use_default_str) { | ||
| 15838 | + string f = builtin__f32_str(data->d.d_f32); | ||
| 15839 | + if (upper_case) { | ||
| 15840 | + string tmp = f; | ||
| 15841 | + f = builtin__string_to_upper(f); | ||
| 15842 | + builtin__string_free(&tmp); | ||
| 15843 | + } | ||
| 15844 | + strings__Builder_write_string(sb, f); | ||
| 15845 | + builtin__string_free(&f); | ||
| 15846 | + } else { | ||
| 15847 | + if (data->d.d_f32 < 0) { | ||
| 15848 | + bf.positive = false; | ||
| 15849 | + } | ||
| 15850 | + string f = strconv__format_fl(data->d.d_f32, bf); | ||
| 15851 | + if (upper_case) { | ||
| 15852 | + string tmp = f; | ||
| 15853 | + f = builtin__string_to_upper(f); | ||
| 15854 | + builtin__string_free(&tmp); | ||
| 15855 | + } | ||
| 15856 | + strings__Builder_write_string(sb, f); | ||
| 15857 | + builtin__string_free(&f); | ||
| 15858 | + } | ||
| 15859 | + } | ||
| 15860 | + #endif | ||
| 15861 | + break; | ||
| 15862 | + } | ||
| 15863 | + case StrIntpType__si_f64: { | ||
| 15864 | + #if !defined(CUSTOM_DEFINE_nofloat) | ||
| 15865 | + { | ||
| 15866 | + if (use_default_str) { | ||
| 15867 | + string f = builtin__f64_str(data->d.d_f64); | ||
| 15868 | + if (upper_case) { | ||
| 15869 | + string tmp = f; | ||
| 15870 | + f = builtin__string_to_upper(f); | ||
| 15871 | + builtin__string_free(&tmp); | ||
| 15872 | + } | ||
| 15873 | + strings__Builder_write_string(sb, f); | ||
| 15874 | + builtin__string_free(&f); | ||
| 15875 | + } else { | ||
| 15876 | + if (data->d.d_f64 < 0) { | ||
| 15877 | + bf.positive = false; | ||
| 15878 | + } | ||
| 15879 | + strconv__Float64u _t5 = ((strconv__Float64u){.f = data->d.d_f64,}); | ||
| 15880 | + strconv__Float64u f_union = _t5; | ||
| 15881 | + if (f_union.u == _const_strconv__double_minus_zero) { | ||
| 15882 | + bf.positive = false; | ||
| 15883 | + } | ||
| 15884 | + string f = strconv__format_fl(data->d.d_f64, bf); | ||
| 15885 | + if (upper_case) { | ||
| 15886 | + string tmp = f; | ||
| 15887 | + f = builtin__string_to_upper(f); | ||
| 15888 | + builtin__string_free(&tmp); | ||
| 15889 | + } | ||
| 15890 | + strings__Builder_write_string(sb, f); | ||
| 15891 | + builtin__string_free(&f); | ||
| 15892 | + } | ||
| 15893 | + } | ||
| 15894 | + #endif | ||
| 15895 | + break; | ||
| 15896 | + } | ||
| 15897 | + case StrIntpType__si_g32: { | ||
| 15898 | + if (use_default_str) { | ||
| 15899 | + #if !defined(CUSTOM_DEFINE_nofloat) | ||
| 15900 | + { | ||
| 15901 | + string f = builtin__f32_strg(data->d.d_f32); | ||
| 15902 | + if (upper_case) { | ||
| 15903 | + string tmp = f; | ||
| 15904 | + f = builtin__string_to_upper(f); | ||
| 15905 | + builtin__string_free(&tmp); | ||
| 15906 | + } | ||
| 15907 | + strings__Builder_write_string(sb, f); | ||
| 15908 | + builtin__string_free(&f); | ||
| 15909 | + } | ||
| 15910 | + #endif | ||
| 15911 | + } else { | ||
| 15912 | + if (data->d.d_f32 == _const_strconv__single_plus_zero) { | ||
| 15913 | + string tmp_str = _S("0"); | ||
| 15914 | + strconv__format_str_sb(tmp_str, bf, sb); | ||
| 15915 | + builtin__string_free(&tmp_str); | ||
| 15916 | + return; | ||
| 15917 | + } | ||
| 15918 | + if (data->d.d_f32 == _const_strconv__single_minus_zero) { | ||
| 15919 | + string tmp_str = _S("-0"); | ||
| 15920 | + strconv__format_str_sb(tmp_str, bf, sb); | ||
| 15921 | + builtin__string_free(&tmp_str); | ||
| 15922 | + return; | ||
| 15923 | + } | ||
| 15924 | + if (data->d.d_f32 == _const_strconv__single_plus_infinity) { | ||
| 15925 | + string tmp_str = _S("+inf"); | ||
| 15926 | + if (upper_case) { | ||
| 15927 | + tmp_str = _S("+INF"); | ||
| 15928 | + } | ||
| 15929 | + strconv__format_str_sb(tmp_str, bf, sb); | ||
| 15930 | + builtin__string_free(&tmp_str); | ||
| 15931 | + } | ||
| 15932 | + if (data->d.d_f32 == _const_strconv__single_minus_infinity) { | ||
| 15933 | + string tmp_str = _S("-inf"); | ||
| 15934 | + if (upper_case) { | ||
| 15935 | + tmp_str = _S("-INF"); | ||
| 15936 | + } | ||
| 15937 | + strconv__format_str_sb(tmp_str, bf, sb); | ||
| 15938 | + builtin__string_free(&tmp_str); | ||
| 15939 | + } | ||
| 15940 | + if (data->d.d_f32 < 0) { | ||
| 15941 | + bf.positive = false; | ||
| 15942 | + } | ||
| 15943 | + f32 d = builtin__fabs32(data->d.d_f32); | ||
| 15944 | + if (d < ((f32)(999999.0)) && d >= ((f32)(0.00001))) { | ||
| 15945 | + string f = strconv__format_fl(data->d.d_f32, bf); | ||
| 15946 | + if (upper_case) { | ||
| 15947 | + string tmp = f; | ||
| 15948 | + f = builtin__string_to_upper(f); | ||
| 15949 | + builtin__string_free(&tmp); | ||
| 15950 | + } | ||
| 15951 | + strings__Builder_write_string(sb, f); | ||
| 15952 | + builtin__string_free(&f); | ||
| 15953 | + return; | ||
| 15954 | + } | ||
| 15955 | + bf.len1--; | ||
| 15956 | + string f = strconv__format_es(data->d.d_f32, bf); | ||
| 15957 | + if (upper_case) { | ||
| 15958 | + string tmp = f; | ||
| 15959 | + f = builtin__string_to_upper(f); | ||
| 15960 | + builtin__string_free(&tmp); | ||
| 15961 | + } | ||
| 15962 | + strings__Builder_write_string(sb, f); | ||
| 15963 | + builtin__string_free(&f); | ||
| 15964 | + } | ||
| 15965 | + break; | ||
| 15966 | + } | ||
| 15967 | + case StrIntpType__si_g64: { | ||
| 15968 | + if (use_default_str) { | ||
| 15969 | + #if !defined(CUSTOM_DEFINE_nofloat) | ||
| 15970 | + { | ||
| 15971 | + string f = builtin__f64_strg(data->d.d_f64); | ||
| 15972 | + if (upper_case) { | ||
| 15973 | + string tmp = f; | ||
| 15974 | + f = builtin__string_to_upper(f); | ||
| 15975 | + builtin__string_free(&tmp); | ||
| 15976 | + } | ||
| 15977 | + strings__Builder_write_string(sb, f); | ||
| 15978 | + builtin__string_free(&f); | ||
| 15979 | + } | ||
| 15980 | + #endif | ||
| 15981 | + } else { | ||
| 15982 | + if (data->d.d_f64 == _const_strconv__double_plus_zero) { | ||
| 15983 | + string tmp_str = _S("0"); | ||
| 15984 | + strconv__format_str_sb(tmp_str, bf, sb); | ||
| 15985 | + builtin__string_free(&tmp_str); | ||
| 15986 | + return; | ||
| 15987 | + } | ||
| 15988 | + if (data->d.d_f64 == _const_strconv__double_minus_zero) { | ||
| 15989 | + string tmp_str = _S("-0"); | ||
| 15990 | + strconv__format_str_sb(tmp_str, bf, sb); | ||
| 15991 | + builtin__string_free(&tmp_str); | ||
| 15992 | + return; | ||
| 15993 | + } | ||
| 15994 | + if (data->d.d_f64 == _const_strconv__double_plus_infinity) { | ||
| 15995 | + string tmp_str = _S("+inf"); | ||
| 15996 | + if (upper_case) { | ||
| 15997 | + tmp_str = _S("+INF"); | ||
| 15998 | + } | ||
| 15999 | + strconv__format_str_sb(tmp_str, bf, sb); | ||
| 16000 | + builtin__string_free(&tmp_str); | ||
| 16001 | + } | ||
| 16002 | + if (data->d.d_f64 == _const_strconv__double_minus_infinity) { | ||
| 16003 | + string tmp_str = _S("-inf"); | ||
| 16004 | + if (upper_case) { | ||
| 16005 | + tmp_str = _S("-INF"); | ||
| 16006 | + } | ||
| 16007 | + strconv__format_str_sb(tmp_str, bf, sb); | ||
| 16008 | + builtin__string_free(&tmp_str); | ||
| 16009 | + } | ||
| 16010 | + if (data->d.d_f64 < 0) { | ||
| 16011 | + bf.positive = false; | ||
| 16012 | + } | ||
| 16013 | + f64 d = builtin__fabs64(data->d.d_f64); | ||
| 16014 | + if (d < ((f64)(999999.0)) && d >= ((f64)(0.00001))) { | ||
| 16015 | + string f = strconv__format_fl(data->d.d_f64, bf); | ||
| 16016 | + if (upper_case) { | ||
| 16017 | + string tmp = f; | ||
| 16018 | + f = builtin__string_to_upper(f); | ||
| 16019 | + builtin__string_free(&tmp); | ||
| 16020 | + } | ||
| 16021 | + strings__Builder_write_string(sb, f); | ||
| 16022 | + builtin__string_free(&f); | ||
| 16023 | + return; | ||
| 16024 | + } | ||
| 16025 | + bf.len1--; | ||
| 16026 | + string f = strconv__format_es(data->d.d_f64, bf); | ||
| 16027 | + if (upper_case) { | ||
| 16028 | + string tmp = f; | ||
| 16029 | + f = builtin__string_to_upper(f); | ||
| 16030 | + builtin__string_free(&tmp); | ||
| 16031 | + } | ||
| 16032 | + strings__Builder_write_string(sb, f); | ||
| 16033 | + builtin__string_free(&f); | ||
| 16034 | + } | ||
| 16035 | + break; | ||
| 16036 | + } | ||
| 16037 | + case StrIntpType__si_e32: { | ||
| 16038 | + #if !defined(CUSTOM_DEFINE_nofloat) | ||
| 16039 | + { | ||
| 16040 | + if (use_default_str) { | ||
| 16041 | + string f = builtin__f32_str(data->d.d_f32); | ||
| 16042 | + if (upper_case) { | ||
| 16043 | + string tmp = f; | ||
| 16044 | + f = builtin__string_to_upper(f); | ||
| 16045 | + builtin__string_free(&tmp); | ||
| 16046 | + } | ||
| 16047 | + strings__Builder_write_string(sb, f); | ||
| 16048 | + builtin__string_free(&f); | ||
| 16049 | + } else { | ||
| 16050 | + if (data->d.d_f32 < 0) { | ||
| 16051 | + bf.positive = false; | ||
| 16052 | + } | ||
| 16053 | + string f = strconv__format_es(data->d.d_f32, bf); | ||
| 16054 | + if (upper_case) { | ||
| 16055 | + string tmp = f; | ||
| 16056 | + f = builtin__string_to_upper(f); | ||
| 16057 | + builtin__string_free(&tmp); | ||
| 16058 | + } | ||
| 16059 | + strings__Builder_write_string(sb, f); | ||
| 16060 | + builtin__string_free(&f); | ||
| 16061 | + } | ||
| 16062 | + } | ||
| 16063 | + #endif | ||
| 16064 | + break; | ||
| 16065 | + } | ||
| 16066 | + case StrIntpType__si_e64: { | ||
| 16067 | + #if !defined(CUSTOM_DEFINE_nofloat) | ||
| 16068 | + { | ||
| 16069 | + if (use_default_str) { | ||
| 16070 | + string f = builtin__f64_str(data->d.d_f64); | ||
| 16071 | + if (upper_case) { | ||
| 16072 | + string tmp = f; | ||
| 16073 | + f = builtin__string_to_upper(f); | ||
| 16074 | + builtin__string_free(&tmp); | ||
| 16075 | + } | ||
| 16076 | + strings__Builder_write_string(sb, f); | ||
| 16077 | + builtin__string_free(&f); | ||
| 16078 | + } else { | ||
| 16079 | + if (data->d.d_f64 < 0) { | ||
| 16080 | + bf.positive = false; | ||
| 16081 | + } | ||
| 16082 | + string f = strconv__format_es(data->d.d_f64, bf); | ||
| 16083 | + if (upper_case) { | ||
| 16084 | + string tmp = f; | ||
| 16085 | + f = builtin__string_to_upper(f); | ||
| 16086 | + builtin__string_free(&tmp); | ||
| 16087 | + } | ||
| 16088 | + strings__Builder_write_string(sb, f); | ||
| 16089 | + builtin__string_free(&f); | ||
| 16090 | + } | ||
| 16091 | + } | ||
| 16092 | + #endif | ||
| 16093 | + break; | ||
| 16094 | + } | ||
| 16095 | + case StrIntpType__si_c: { | ||
| 16096 | + string ss = builtin__utf32_to_str(data->d.d_c); | ||
| 16097 | + strings__Builder_write_string(sb, ss); | ||
| 16098 | + builtin__string_free(&ss); | ||
| 16099 | + break; | ||
| 16100 | + } | ||
| 16101 | + case StrIntpType__si_vp: { | ||
| 16102 | + string ss = builtin__u64_hex(((u64)(data->d.d_vp))); | ||
| 16103 | + strings__Builder_write_string(sb, ss); | ||
| 16104 | + builtin__string_free(&ss); | ||
| 16105 | + break; | ||
| 16106 | + } | ||
| 16107 | + case StrIntpType__si_no_str: | ||
| 16108 | + case StrIntpType__si_u8: | ||
| 16109 | + case StrIntpType__si_i8: | ||
| 16110 | + case StrIntpType__si_u16: | ||
| 16111 | + case StrIntpType__si_i16: | ||
| 16112 | + case StrIntpType__si_u32: | ||
| 16113 | + case StrIntpType__si_i32: | ||
| 16114 | + case StrIntpType__si_u64: | ||
| 16115 | + case StrIntpType__si_i64: | ||
| 16116 | + case StrIntpType__si_s: | ||
| 16117 | + case StrIntpType__si_p: | ||
| 16118 | + case StrIntpType__si_r: | ||
| 16119 | + default: { | ||
| 16120 | + { | ||
| 16121 | + strings__Builder_write_string(sb, _S("***ERROR!***")); | ||
| 16122 | + break; | ||
| 16123 | + } | ||
| 16124 | + } | ||
| 16125 | + } | ||
| 16126 | + | ||
| 16127 | + } | ||
| 16128 | +} | ||
| 16129 | +string builtin__str_intp(int data_len, StrIntpData* input_base) { | ||
| 16130 | + strings__Builder res = strings__new_builder(64); | ||
| 16131 | + for (int i = 0; i < data_len; i++) { | ||
| 16132 | + StrIntpData* data = &input_base[i]; | ||
| 16133 | + if (data->str.len != 0) { | ||
| 16134 | + strings__Builder_write_string(&res, data->str); | ||
| 16135 | + } | ||
| 16136 | + if (data->fmt != 0) { | ||
| 16137 | + builtin__StrIntpData_process_str_intp_data(data, (voidptr)&res); | ||
| 16138 | + } | ||
| 16139 | + } | ||
| 16140 | + string ret = strings__Builder_str(&res); | ||
| 16141 | + strings__Builder_free(&res); | ||
| 16142 | + return ret; | ||
| 16143 | +} | ||
| 16144 | +inline string builtin__str_intp_sq(string in_str) { | ||
| 16145 | + return builtin__string_plus_many(5, _MOV((string[5]){_S("builtin__str_intp(2, _MOV((StrIntpData[]){{_S(\"\'\"), "), _const_si_s_code, _S(", {.d_s = "), in_str, _S("}, 0, 0, 0},{_S(\"\'\"), 0, {0}, 0, 0, 0}}))")})); | ||
| 16146 | +} | ||
| 16147 | +inline string builtin__str_intp_rune(string in_str) { | ||
| 16148 | + return builtin__string_plus_many(5, _MOV((string[5]){_S("builtin__str_intp(2, _MOV((StrIntpData[]){{_S(\"`\"), "), _const_si_s_code, _S(", {.d_s = "), in_str, _S("}, 0, 0, 0},{_S(\"`\"), 0, {0}, 0, 0, 0}}))")})); | ||
| 16149 | +} | ||
| 16150 | +inline string builtin__str_intp_g32(string in_str) { | ||
| 16151 | + return builtin__string_plus_many(5, _MOV((string[5]){_S("builtin__str_intp(1, _MOV((StrIntpData[]){{_SLIT0, "), _const_si_g32_code, _S(", {.d_f32 = "), in_str, _S(" }, 0, 0, 0}}))")})); | ||
| 16152 | +} | ||
| 16153 | +inline string builtin__str_intp_g64(string in_str) { | ||
| 16154 | + return builtin__string_plus_many(5, _MOV((string[5]){_S("builtin__str_intp(1, _MOV((StrIntpData[]){{_SLIT0, "), _const_si_g64_code, _S(", {.d_f64 = "), in_str, _S(" }, 0, 0, 0}}))")})); | ||
| 16155 | +} | ||
| 16156 | +string builtin__str_intp_sub(string base_str, string in_str) { | ||
| 16157 | + _option_int _t1 = builtin__string_index(base_str, _S("%%")); | ||
| 16158 | + if (_t1.state != 0) { | ||
| 16159 | + builtin__eprintln(_S("No string interpolation %% parameters")); | ||
| 16160 | + builtin___v_exit(1); | ||
| 16161 | + VUNREACHABLE(); | ||
| 16162 | + ; | ||
| 16163 | + } | ||
| 16164 | + | ||
| 16165 | + int index = (*(int*)_t1.data); | ||
| 16166 | + { // Unsafe block | ||
| 16167 | + string st_str = builtin__string_substr(base_str, 0, index); | ||
| 16168 | + if (index + 2 < base_str.len) { | ||
| 16169 | + string en_str = builtin__string_substr(base_str, index + 2, 2147483647); | ||
| 16170 | + string res_str = builtin__string_plus_many(9, _MOV((string[9]){_S("builtin__str_intp(2, _MOV((StrIntpData[]){{_S(\""), st_str, _S("\"), "), _const_si_s_code, _S(", {.d_s = "), in_str, _S(" }, 0, 0, 0},{_S(\""), en_str, _S("\"), 0, {0}, 0, 0, 0}}))")})); | ||
| 16171 | + builtin__string_free(&st_str); | ||
| 16172 | + builtin__string_free(&en_str); | ||
| 16173 | + return res_str; | ||
| 16174 | + } | ||
| 16175 | + string res2_str = builtin__string_plus_many(7, _MOV((string[7]){_S("builtin__str_intp(1, _MOV((StrIntpData[]){{_S(\""), st_str, _S("\"), "), _const_si_s_code, _S(", {.d_s = "), in_str, _S(" }, 0, 0, 0}}))")})); | ||
| 16176 | + builtin__string_free(&st_str); | ||
| 16177 | + return res2_str; | ||
| 16178 | + } | ||
| 16179 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 16180 | +} | ||
| 16181 | +u16* builtin__string_to_wide(string _str, ToWideConfig param) { | ||
| 16182 | + #if 0 | ||
| 16183 | + { | ||
| 16184 | + } | ||
| 16185 | + #else | ||
| 16186 | + { | ||
| 16187 | + Array_rune srunes = builtin__string_runes(_str); | ||
| 16188 | + { // Unsafe block | ||
| 16189 | + u16* result = ((u16*)(builtin__vcalloc_noscan((srunes.len + 1) * 2))); | ||
| 16190 | + for (int i = 0; i < srunes.len; ++i) { | ||
| 16191 | + rune r = ((rune*)srunes.data)[i]; | ||
| 16192 | + result[i] = ((u16)(r)); | ||
| 16193 | + } | ||
| 16194 | + result[srunes.len] = 0; | ||
| 16195 | + return result; | ||
| 16196 | + } | ||
| 16197 | + } | ||
| 16198 | + #endif | ||
| 16199 | + return 0; | ||
| 16200 | +} | ||
| 16201 | +string builtin__string_from_wide(u16* _wstr) { | ||
| 16202 | + #if 0 | ||
| 16203 | + { | ||
| 16204 | + } | ||
| 16205 | + #else | ||
| 16206 | + { | ||
| 16207 | + int i = 0; | ||
| 16208 | + for (;;) { | ||
| 16209 | + if (!(_wstr[i] != 0)) break; | ||
| 16210 | + i++; | ||
| 16211 | + } | ||
| 16212 | + return builtin__string_from_wide2(_wstr, i); | ||
| 16213 | + } | ||
| 16214 | + #endif | ||
| 16215 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 16216 | +} | ||
| 16217 | +string builtin__string_from_wide2(u16* _wstr, int len) { | ||
| 16218 | + #if 0 | ||
| 16219 | + { | ||
| 16220 | + } | ||
| 16221 | + #else | ||
| 16222 | + { | ||
| 16223 | + strings__Builder sb = strings__new_builder(len); | ||
| 16224 | + for (int i = 0; i < len; i++) { | ||
| 16225 | + rune u = ((rune)(_wstr[i])); | ||
| 16226 | + strings__Builder_write_rune(&sb, u); | ||
| 16227 | + } | ||
| 16228 | + string res = strings__Builder_str(&sb); | ||
| 16229 | + strings__Builder_free(&sb); | ||
| 16230 | + return res; | ||
| 16231 | + } | ||
| 16232 | + #endif | ||
| 16233 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 16234 | +} | ||
| 16235 | +Array_u8 builtin__wide_to_ansi(u16* _wstr) { | ||
| 16236 | + #if 0 | ||
| 16237 | + { | ||
| 16238 | + } | ||
| 16239 | + #else | ||
| 16240 | + { | ||
| 16241 | + string s = builtin__string_from_wide(_wstr); | ||
| 16242 | + Array_u8 str_to = builtin____new_array_with_default(s.len + 1, 0, sizeof(u8), 0); | ||
| 16243 | + builtin__vmemcpy(str_to.data, s.str, s.len); | ||
| 16244 | + return str_to; | ||
| 16245 | + } | ||
| 16246 | + #endif | ||
| 16247 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | ||
| 16248 | +} | ||
| 16249 | +int builtin__utf8_char_len(u8 b) { | ||
| 16250 | + return ((int)((((v__rshift_u32(((u32)(0xe5000000U)), (u64)(((v__rshift_u8(b, (u64)3)) & 0x1e)))) & 3)) + 1)); | ||
| 16251 | +} | ||
| 16252 | +string builtin__utf32_to_str(u32 code) { | ||
| 16253 | + { // Unsafe block | ||
| 16254 | + u8* buffer = builtin__malloc_noscan(5); | ||
| 16255 | + string res = builtin__utf32_to_str_no_malloc(code, buffer); | ||
| 16256 | + if (res.len == 0) { | ||
| 16257 | + builtin___v_free(buffer); | ||
| 16258 | + } | ||
| 16259 | + return res; | ||
| 16260 | + } | ||
| 16261 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 16262 | +} | ||
| 16263 | +string builtin__utf32_to_str_no_malloc(u32 code, u8* buf) { | ||
| 16264 | + { // Unsafe block | ||
| 16265 | + int len = builtin__utf32_decode_to_buffer(code, buf); | ||
| 16266 | + if (len == 0) { | ||
| 16267 | + return _S(""); | ||
| 16268 | + } | ||
| 16269 | + buf[len] = 0; | ||
| 16270 | + return builtin__tos(buf, len); | ||
| 16271 | + } | ||
| 16272 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 16273 | +} | ||
| 16274 | +int builtin__utf32_decode_to_buffer(u32 code, u8* buf) { | ||
| 16275 | + { // Unsafe block | ||
| 16276 | + int icode = ((int)(code)); | ||
| 16277 | + u8* buffer = ((u8*)(buf)); | ||
| 16278 | + if (icode <= 127) { | ||
| 16279 | + buffer[0] = ((u8)(icode)); | ||
| 16280 | + return 1; | ||
| 16281 | + } else if (icode <= 2047) { | ||
| 16282 | + buffer[0] = (192 | ((u8)(v__rshift_int(icode, (u64)6)))); | ||
| 16283 | + buffer[1] = (128 | ((u8)((icode & 63)))); | ||
| 16284 | + return 2; | ||
| 16285 | + } else if (icode <= 65535) { | ||
| 16286 | + buffer[0] = (224 | ((u8)(v__rshift_int(icode, (u64)12)))); | ||
| 16287 | + buffer[1] = (128 | ((((u8)(v__rshift_int(icode, (u64)6))) & 63))); | ||
| 16288 | + buffer[2] = (128 | ((u8)((icode & 63)))); | ||
| 16289 | + return 3; | ||
| 16290 | + } else if (icode <= 1114111) { | ||
| 16291 | + buffer[0] = (240 | ((u8)(v__rshift_int(icode, (u64)18)))); | ||
| 16292 | + buffer[1] = (128 | ((((u8)(v__rshift_int(icode, (u64)12))) & 63))); | ||
| 16293 | + buffer[2] = (128 | ((((u8)(v__rshift_int(icode, (u64)6))) & 63))); | ||
| 16294 | + buffer[3] = (128 | ((u8)((icode & 63)))); | ||
| 16295 | + return 4; | ||
| 16296 | + } | ||
| 16297 | + } | ||
| 16298 | + return 0; | ||
| 16299 | +} | ||
| 16300 | +int builtin__string_utf32_code(string _rune) { | ||
| 16301 | + if (_rune.len > 4) { | ||
| 16302 | + return 0; | ||
| 16303 | + } | ||
| 16304 | + return ((int)(builtin__impl_utf8_to_utf32(_rune.str, _rune.len))); | ||
| 16305 | +} | ||
| 16306 | +_result_rune Array_u8_utf8_to_utf32(Array_u8 _bytes) { | ||
| 16307 | + if (_bytes.len > 4) { | ||
| 16308 | + return (_result_rune){ .is_error=true, .err=builtin___v_error(_S("attempted to decode too many bytes, utf-8 is limited to four bytes maximum")), .data={E_STRUCT} }; | ||
| 16309 | + } | ||
| 16310 | + _result_rune _t2; | ||
| 16311 | + builtin___result_ok(&(rune[]) { builtin__impl_utf8_to_utf32(_bytes.data, _bytes.len) }, (_result*)(&_t2), sizeof(rune)); | ||
| 16312 | + | ||
| 16313 | + return _t2; | ||
| 16314 | +} | ||
| 16315 | +inline VV_LOC bool builtin__utf8_is_continuation(u8 b) { | ||
| 16316 | + return ((b & 0xc0)) == 0x80; | ||
| 16317 | +} | ||
| 16318 | +VV_LOC multi_return_rune_int builtin__utf8_decode_rune(u8* _bytes, int available_len) { | ||
| 16319 | + if (available_len <= 0) { | ||
| 16320 | + return (multi_return_rune_int){.arg0=0, .arg1=0}; | ||
| 16321 | + } | ||
| 16322 | + u8 b0 = _bytes[0]; | ||
| 16323 | + if (b0 < 0x80) { | ||
| 16324 | + return (multi_return_rune_int){.arg0=((rune)(b0)), .arg1=1}; | ||
| 16325 | + } | ||
| 16326 | + if (b0 < 0xc2) { | ||
| 16327 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | ||
| 16328 | + } | ||
| 16329 | + int _t4; /* if prepend */ | ||
| 16330 | + if (b0 < 0xe0) { | ||
| 16331 | + _t4 = 2; | ||
| 16332 | + goto _t5; | ||
| 16333 | + }; | ||
| 16334 | + { | ||
| 16335 | + if (b0 < 0xf0) { | ||
| 16336 | + _t4 = 3; | ||
| 16337 | + goto _t5; | ||
| 16338 | + }; | ||
| 16339 | + { | ||
| 16340 | + if (b0 < 0xf5) { | ||
| 16341 | + _t4 = 4; | ||
| 16342 | + goto _t5; | ||
| 16343 | + }; | ||
| 16344 | + { | ||
| 16345 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | ||
| 16346 | + } | ||
| 16347 | + } | ||
| 16348 | + } | ||
| 16349 | + _t5: {}; | ||
| 16350 | + int char_len = _t4; | ||
| 16351 | + if (available_len < char_len) { | ||
| 16352 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | ||
| 16353 | + } | ||
| 16354 | + u8 b1 = _bytes[1]; | ||
| 16355 | + if (!builtin__utf8_is_continuation(b1)) { | ||
| 16356 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | ||
| 16357 | + } | ||
| 16358 | + if (char_len == 2) { | ||
| 16359 | + return (multi_return_rune_int){.arg0=((v__lshift_rune(((((rune)(b0)) & 0x1f)), (u64)6)) | ((((rune)(b1)) & 0x3f))), .arg1=2}; | ||
| 16360 | + } | ||
| 16361 | + if (b0 == 0xe0 && b1 < 0xa0) { | ||
| 16362 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | ||
| 16363 | + } | ||
| 16364 | + if (b0 == 0xed && b1 >= 0xa0) { | ||
| 16365 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | ||
| 16366 | + } | ||
| 16367 | + u8 b2 = _bytes[2]; | ||
| 16368 | + if (!builtin__utf8_is_continuation(b2)) { | ||
| 16369 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | ||
| 16370 | + } | ||
| 16371 | + if (char_len == 3) { | ||
| 16372 | + return (multi_return_rune_int){.arg0=(((v__lshift_rune(((((rune)(b0)) & 0x0f)), (u64)12)) | (v__lshift_rune(((((rune)(b1)) & 0x3f)), (u64)6))) | ((((rune)(b2)) & 0x3f))), .arg1=3}; | ||
| 16373 | + } | ||
| 16374 | + if (b0 == 0xf0 && b1 < 0x90) { | ||
| 16375 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | ||
| 16376 | + } | ||
| 16377 | + if (b0 == 0xf4 && b1 > 0x8f) { | ||
| 16378 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | ||
| 16379 | + } | ||
| 16380 | + u8 b3 = _bytes[3]; | ||
| 16381 | + if (!builtin__utf8_is_continuation(b3)) { | ||
| 16382 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | ||
| 16383 | + } | ||
| 16384 | + return (multi_return_rune_int){.arg0=((((v__lshift_rune(((((rune)(b0)) & 0x07)), (u64)18)) | (v__lshift_rune(((((rune)(b1)) & 0x3f)), (u64)12))) | (v__lshift_rune(((((rune)(b2)) & 0x3f)), (u64)6))) | ((((rune)(b3)) & 0x3f))), .arg1=4}; | ||
| 16385 | +} | ||
| 16386 | +VV_LOC rune builtin__impl_utf8_to_utf32(u8* _bytes, int _bytes_len) { | ||
| 16387 | + if (_bytes_len == 0 || _bytes_len > 4) { | ||
| 16388 | + return 0; | ||
| 16389 | + } | ||
| 16390 | + multi_return_rune_int mr_4267 = builtin__utf8_decode_rune(_bytes, _bytes_len); | ||
| 16391 | + rune r = mr_4267.arg0; | ||
| 16392 | + int len = mr_4267.arg1; | ||
| 16393 | + if (len != _bytes_len) { | ||
| 16394 | + return _const_utf8_replacement_rune; | ||
| 16395 | + } | ||
| 16396 | + return r; | ||
| 16397 | +} | ||
| 16398 | +int builtin__utf8_str_visible_length(string s) { | ||
| 16399 | + return builtin__utf8_grapheme_visible_length(s); | ||
| 16400 | +} | ||
| 16401 | +Array_u8 builtin__string_to_ansi_not_null_terminated(string _str) { | ||
| 16402 | + u16* wstr = builtin__string_to_wide(_str, ((ToWideConfig){.from_ansi = 0,})); | ||
| 16403 | + Array_u8 ansi = builtin__wide_to_ansi(wstr); | ||
| 16404 | + if (ansi.len > 0) { | ||
| 16405 | + ansi.len--; | ||
| 16406 | + } | ||
| 16407 | + return ansi; | ||
| 16408 | +} | ||
| 16409 | +inline bool builtin__ArrayFlags_is_empty(ArrayFlags* e) { | ||
| 16410 | + return ((int)(*e)) == 0; | ||
| 16411 | +} | ||
| 16412 | +inline bool builtin__ArrayFlags_has(ArrayFlags* e, ArrayFlags flag_) { | ||
| 16413 | + return ((((int)(*e)) & (((int)(flag_))))) != 0; | ||
| 16414 | +} | ||
| 16415 | +inline bool builtin__ArrayFlags_all(ArrayFlags* e, ArrayFlags flag_) { | ||
| 16416 | + return ((((int)(*e)) & (((int)(flag_))))) == ((int)(flag_)); | ||
| 16417 | +} | ||
| 16418 | +inline void builtin__ArrayFlags_set(ArrayFlags* e, ArrayFlags flag_) { | ||
| 16419 | + { // Unsafe block | ||
| 16420 | + *e = ((ArrayFlags)((((int)(*e)) | (((int)(flag_)))))); | ||
| 16421 | + } | ||
| 16422 | +} | ||
| 16423 | +inline void builtin__ArrayFlags_set_all(ArrayFlags* e) { | ||
| 16424 | + { // Unsafe block | ||
| 16425 | + *e = ((ArrayFlags)(0b1111111)); | ||
| 16426 | + } | ||
| 16427 | +} | ||
| 16428 | +inline void builtin__ArrayFlags_clear(ArrayFlags* e, ArrayFlags flag_) { | ||
| 16429 | + { // Unsafe block | ||
| 16430 | + *e = ((ArrayFlags)((((int)(*e)) & ~(((int)(flag_)))))); | ||
| 16431 | + } | ||
| 16432 | +} | ||
| 16433 | +inline void builtin__ArrayFlags_clear_all(ArrayFlags* e) { | ||
| 16434 | + { // Unsafe block | ||
| 16435 | + *e = ((ArrayFlags)(0)); | ||
| 16436 | + } | ||
| 16437 | +} | ||
| 16438 | +inline void builtin__ArrayFlags_toggle(ArrayFlags* e, ArrayFlags flag_) { | ||
| 16439 | + { // Unsafe block | ||
| 16440 | + *e = ((ArrayFlags)((((int)(*e)) ^ (((int)(flag_)))))); | ||
| 16441 | + } | ||
| 16442 | +} | ||
| 16443 | +inline ArrayFlags builtin__ArrayFlags__static__zero(void) { | ||
| 16444 | + return ((ArrayFlags)(0)); | ||
| 16445 | +} | ||
| 16446 | +VV_LOC void main__vf_init(void) { | ||
| 16447 | + string probe = _S("vf"); | ||
| 16448 | + {int _ = probe.len;} | ||
| 16449 | + ; | ||
| 16450 | +} | ||
| 16451 | +// export alias: vf_init -> main__vf_init | ||
| 16452 | +void vf_init(void) { | ||
| 16453 | + return main__vf_init(); | ||
| 16454 | +} | ||
| 16455 | +VV_LOC int main__vf_add(int a, int b) { | ||
| 16456 | + return a + b; | ||
| 16457 | +} | ||
| 16458 | +// export alias: vf_add -> main__vf_add | ||
| 16459 | +int vf_add(int a, int b) { | ||
| 16460 | + return main__vf_add(a, b); | ||
| 16461 | +} | ||
| 16462 | +VV_LOC char* main__vf_greet(char* name) { | ||
| 16463 | + string n = builtin__cstring_to_vstring(name); | ||
| 16464 | + string res = builtin__string_plus_many(3, _MOV((string[3]){_S("Hello, "), n, _S(", from V!")})); | ||
| 16465 | + u8* out = res.str; | ||
| 16466 | + builtin__string_free(&n); | ||
| 16467 | + return out; | ||
| 16468 | +} | ||
| 16469 | +// export alias: vf_greet -> main__vf_greet | ||
| 16470 | +char* vf_greet(char* name) { | ||
| 16471 | + return main__vf_greet(name); | ||
| 16472 | +} | ||
| 16473 | +VV_LOC void main__vf_free(voidptr p) { | ||
| 16474 | + builtin___v_free(p); | ||
| 16475 | +} | ||
| 16476 | +// export alias: vf_free -> main__vf_free | ||
| 16477 | +void vf_free(voidptr p) { | ||
| 16478 | + return main__vf_free(p); | ||
| 16479 | +} | ||
| 16480 | +VV_LOC void main__main(void) { | ||
| 16481 | +} | ||
| 16482 | +void _vinit(int ___argc, voidptr ___argv) { | ||
| 16483 | + static bool once = false; if (once) {return;} once = true; | ||
| 16484 | + // Initializations of consts for module builtin.closure | ||
| 16485 | + g_closure = ((builtin__closure__Closure){.ClosureMutex = ((builtin__closure__ClosureMutex){.closure_mtx = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}),.closure_ptr = 0,.closure_get_data = ((void*)0),.closure_cap = 0,.free_closure_ptr = 0,.pages = ((void*)0),.v_page_size = ((int)(0x4000)),.live = builtin__new_map(sizeof(voidptr), sizeof(builtin__closure__ClosureLiveInfo), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop),.active_lifetimes = builtin__new_map(sizeof(u64), sizeof(builtin__closure__ClosureLifetimeState*), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop),.next_generation = 0,.free_lifetime_states = ((void*)0),.next_lifetime_generation = 0,.lifetime_state_allocs = 0,}); // global 3 | ||
| 16486 | +{ | ||
| 16487 | +{ | ||
| 16488 | +Array_fixed_u8_15 _t1; | ||
| 16489 | +#if defined(__V_ppc64le) | ||
| 16490 | +#elif !defined(__V_ppc64le) && !defined(__V_amd64) && !defined(__V_x86) && !defined(__V_arm64) && !defined(__V_arm32) && !defined(__V_rv64) && !defined(__V_rv32) && !defined(__V_s390x) && !defined(__V_loongarch64) | ||
| 16491 | +#elif defined(__V_amd64) | ||
| 16492 | + { Array_fixed_u8_15 _t2 = {((u8)(0xF3)), 0x44, 0x0F, 0x7E, 0x3D, 0xF7, 0xBF, 0xFF, 0xFF, 0xFF, 0x25, 0xF9, 0xBF, 0xFF, 0xFF} ; | ||
| 16493 | + memcpy(&_t1, &_t2, sizeof(Array_fixed_u8_15)); | ||
| 16494 | + } | ||
| 16495 | + ; | ||
| 16496 | +#elif defined(__V_x86) | ||
| 16497 | +#elif defined(__V_arm64) | ||
| 16498 | +#elif defined(__V_arm32) | ||
| 16499 | +#elif defined(__V_rv64) | ||
| 16500 | +#elif defined(__V_rv32) | ||
| 16501 | +#elif defined(__V_s390x) | ||
| 16502 | +#elif defined(__V_loongarch64) | ||
| 16503 | +#elif defined(__V_sparc64) | ||
| 16504 | +#elif 0 | ||
| 16505 | +#else | ||
| 16506 | +#endif | ||
| 16507 | + memcpy(&_const_builtin__closure__closure_thunk, &_t1, sizeof(Array_fixed_u8_15)); | ||
| 16508 | +} | ||
| 16509 | +} | ||
| 16510 | +{ | ||
| 16511 | +{ | ||
| 16512 | +Array_fixed_u8_6 _t3; | ||
| 16513 | +#if !defined(__V_ppc64le) && !defined(__V_amd64) && !defined(__V_x86) && !defined(__V_arm64) && !defined(__V_arm32) && !defined(__V_rv64) && !defined(__V_rv32) && !defined(__V_s390x) && !defined(__V_loongarch64) | ||
| 16514 | +#elif defined(__V_arm32) | ||
| 16515 | +#elif defined(__V_amd64) | ||
| 16516 | + { Array_fixed_u8_6 _t4 = {((u8)(0x66)), 0x4C, 0x0F, 0x7E, 0xF8, 0xC3} ; | ||
| 16517 | + memcpy(&_t3, &_t4, sizeof(Array_fixed_u8_6)); | ||
| 16518 | + } | ||
| 16519 | + ; | ||
| 16520 | +#elif defined(__V_x86) | ||
| 16521 | +#elif defined(__V_arm64) | ||
| 16522 | +#elif defined(__V_rv64) | ||
| 16523 | +#elif defined(__V_rv32) | ||
| 16524 | +#elif defined(__V_s390x) | ||
| 16525 | +#elif defined(__V_ppc64le) | ||
| 16526 | +#elif defined(__V_loongarch64) | ||
| 16527 | +#elif defined(__V_sparc64) | ||
| 16528 | +#elif 0 | ||
| 16529 | +#else | ||
| 16530 | +#endif | ||
| 16531 | + memcpy(&_const_builtin__closure__closure_get_data_bytes, &_t3, sizeof(Array_fixed_u8_6)); | ||
| 16532 | +} | ||
| 16533 | +} | ||
| 16534 | +{ | ||
| 16535 | +{ | ||
| 16536 | + _const_builtin__closure__closure_size_1 = (2 * ((u32)(sizeof(voidptr))) > ((u32)(15)) ? (2 * ((u32)(sizeof(voidptr)))) : (((u32)(15)) + ((u32)(sizeof(voidptr))) - 1)); | ||
| 16537 | +} | ||
| 16538 | +} | ||
| 16539 | + _const_builtin__closure__closure_size = ((int)((_const_builtin__closure__closure_size_1 & ~(((u32)(sizeof(voidptr))) - 1)))); | ||
| 16540 | + // Initializations of consts for module math.bits | ||
| 16541 | + _const_math__bits__overflow_error = _S("Overflow Error"); | ||
| 16542 | + _const_math__bits__divide_error = _S("Divide by Zero Error"); | ||
| 16543 | + // Initializations of consts for module strconv | ||
| 16544 | + _const_strconv__digit_pairs = _S("00102030405060708090011121314151617181910212223242526272829203132333435363738393041424344454647484940515253545556575859506162636465666768696071727374757677787970818283848586878889809192939495969798999"); | ||
| 16545 | + _const_strconv__base_digits = _S("0123456789abcdefghijklmnopqrstuvwxyz"); | ||
| 16546 | + _const_strconv__i64_min_int32 = ((i64)(-2147483647)) - 1; | ||
| 16547 | + _const_strconv__i64_max_int32 = ((i64)(2147483646)) + 1; | ||
| 16548 | + // Initializations of consts for module builtin | ||
| 16549 | + _const_grapheme_control_ranges = _S("00000000090000000b0000000c0000000e0000001f0000007f0000009f000000ad000000ad0000001c0600001c0600000e1800000e1800000b2000000b2000000e2000000f200000282000002820000029200000292000002a2000002e20000060200000642000006520000065200000662000006f200000fffe0000fffe0000f0ff0000f8ff0000f9ff0000fbff00003034010038340100a0bc0100a3bc010073d101007ad1010000000e0000000e0001000e0001000e0002000e001f000e0080000e00ff000e00f0010e00ff0f0e00"); | ||
| 16550 | + _const_grapheme_extend_ranges = _S("000300006f0300008304000087040000880400008904000091050000bd050000bf050000bf050000c1050000c2050000c4050000c5050000c7050000c7050000100600001a0600004b0600005f0600007006000070060000d6060000dc060000df060000e4060000e7060000e8060000ea060000ed0600001107000011070000300700004a070000a6070000b0070000eb070000f3070000fd070000fd07000016080000190800001b080000230800002508000027080000290800002d080000590800005b080000d3080000e1080000e3080000020900003a0900003a0900003c0900003c09000041090000480900004d0900004d090000510900005709000062090000630900008109000081090000bc090000bc090000be090000be090000c1090000c4090000cd090000cd090000d7090000d7090000e2090000e3090000fe090000fe090000010a0000020a00003c0a00003c0a0000410a0000420a0000470a0000480a00004b0a00004d0a0000510a0000510a0000700a0000710a0000750a0000750a0000810a0000820a0000bc0a0000bc0a0000c10a0000c50a0000c70a0000c80a0000cd0a0000cd0a0000e20a0000e30a0000fa0a0000ff0a0000010b0000010b00003c0b00003c0b00003e0b00003e0b00003f0b00003f0b0000410b0000440b00004d0b00004d0b0000550b0000560b0000570b0000570b0000620b0000630b0000820b0000820b0000be0b0000be0b0000c00b0000c00b0000cd0b0000cd0b0000d70b0000d70b0000000c0000000c0000040c0000040c00003e0c0000400c0000460c0000480c00004a0c00004d0c0000550c0000560c0000620c0000630c0000810c0000810c0000bc0c0000bc0c0000bf0c0000bf0c0000c20c0000c20c0000c60c0000c60c0000cc0c0000cd0c0000d50c0000d60c0000e20c0000e30c0000000d0000010d00003b0d00003c0d00003e0d00003e0d0000410d0000440d00004d0d00004d0d0000570d0000570d0000620d0000630d0000810d0000810d0000ca0d0000ca0d0000cf0d0000cf0d0000d20d0000d40d0000d60d0000d60d0000df0d0000df0d0000310e0000310e0000340e00003a0e0000470e00004e0e0000b10e0000b10e0000b40e0000bc0e0000c80e0000cd0e0000180f0000190f0000350f0000350f0000370f0000370f0000390f0000390f0000710f00007e0f0000800f0000840f0000860f0000870f00008d0f0000970f0000990f0000bc0f0000c60f0000c60f00002d100000301000003210000037100000391000003a1000003d1000003e10000058100000591000005e100000601000007110000074100000821000008210000085100000861000008d1000008d1000009d1000009d1000005d1300005f1300001217000014170000321700003417000052170000531700007217000073170000b4170000b5170000b7170000bd170000c6170000c6170000c9170000d3170000dd170000dd1700000b1800000d1800008518000086180000a9180000a9180000201900002219000027190000281900003219000032190000391900003b190000171a0000181a00001b1a00001b1a0000561a0000561a0000581a00005e1a0000601a0000601a0000621a0000621a0000651a00006c1a0000731a00007c1a00007f1a00007f1a0000b01a0000bd1a0000be1a0000be1a0000bf1a0000c01a0000001b0000031b0000341b0000341b0000351b0000351b0000361b00003a1b00003c1b00003c1b0000421b0000421b00006b1b0000731b0000801b0000811b0000a21b0000a51b0000a81b0000a91b0000ab1b0000ad1b0000e61b0000e61b0000e81b0000e91b0000ed1b0000ed1b0000ef1b0000f11b00002c1c0000331c0000361c0000371c0000d01c0000d21c0000d41c0000e01c0000e21c0000e81c0000ed1c0000ed1c0000f41c0000f41c0000f81c0000f91c0000c01d0000f91d0000fb1d0000ff1d00000c2000000c200000d0200000dc200000dd200000e0200000e1200000e1200000e2200000e4200000e5200000f0200000ef2c0000f12c00007f2d00007f2d0000e02d0000ff2d00002a3000002d3000002e3000002f300000993000009a3000006fa600006fa6000070a6000072a6000074a600007da600009ea600009fa60000f0a60000f1a6000002a8000002a8000006a8000006a800000ba800000ba8000025a8000026a800002ca800002ca80000c4a80000c5a80000e0a80000f1a80000ffa80000ffa8000026a900002da9000047a9000051a9000080a9000082a90000b3a90000b3a90000b6a90000b9a90000bca90000bda90000e5a90000e5a9000029aa00002eaa000031aa000032aa000035aa000036aa000043aa000043aa00004caa00004caa00007caa00007caa0000b0aa0000b0aa0000b2aa0000b4aa0000b7aa0000b8aa0000beaa0000bfaa0000c1aa0000c1aa0000ecaa0000edaa0000f6aa0000f6aa0000e5ab0000e5ab0000e8ab0000e8ab0000edab0000edab00001efb00001efb000000fe00000ffe000020fe00002ffe00009eff00009fff0000fd010100fd010100e0020100e0020100760301007a030100010a0100030a0100050a0100060a01000c0a01000f0a0100380a01003a0a01003f0a01003f0a0100e50a0100e60a0100240d0100270d0100ab0e0100ac0e0100460f0100500f0100011001000110010038100100461001007f10010081100100b3100100b6100100b9100100ba1001000011010002110100271101002b1101002d1101003411010073110100731101008011010081110100b6110100be110100c9110100cc110100cf110100cf1101002f12010031120100341201003412010036120100371201003e1201003e120100df120100df120100e3120100ea12010000130100011301003b1301003c1301003e1301003e13010040130100401301005713010057130100661301006c1301007013010074130100381401003f140100421401004414010046140100461401005e1401005e140100b0140100b0140100b3140100b8140100ba140100ba140100bd140100bd140100bf140100c0140100c2140100c3140100af150100af150100b2150100b5150100bc150100bd150100bf150100c0150100dc150100dd150100331601003a1601003d1601003d1601003f16010040160100ab160100ab160100ad160100ad160100b0160100b5160100b7160100b71601001d1701001f1701002217010025170100271701002b1701002f18010037180100391801003a18010030190100301901003b1901003c1901003e1901003e1901004319010043190100d4190100d7190100da190100db190100e0190100e0190100011a01000a1a0100331a0100381a01003b1a01003e1a0100471a0100471a0100511a0100561a0100591a01005b1a01008a1a0100961a0100981a0100991a0100301c0100361c0100381c01003d1c01003f1c01003f1c0100921c0100a71c0100aa1c0100b01c0100b21c0100b31c0100b51c0100b61c0100311d0100361d01003a1d01003a1d01003c1d01003d1d01003f1d0100451d0100471d0100471d0100901d0100911d0100951d0100951d0100971d0100971d0100f31e0100f41e0100f06a0100f46a0100306b0100366b01004f6f01004f6f01008f6f0100926f0100e46f0100e46f01009dbc01009ebc010065d1010065d1010067d1010069d101006ed1010072d101007bd1010082d1010085d101008bd10100aad10100add1010042d2010044d2010000da010036da01003bda01006cda010075da010075da010084da010084da01009bda01009fda0100a1da0100afda010000e0010006e0010008e0010018e001001be0010021e0010023e0010024e0010026e001002ae0010030e1010036e10100ece20100efe20100d0e80100d6e8010044e901004ae90100fbf30100fff3010020000e007f000e0000010e00ef010e00"); | ||
| 16551 | + _const_grapheme_spacing_mark_ranges = _S("03090000030900003b0900003b0900003e09000040090000490900004c0900004e0900004f0900008209000083090000bf090000c0090000c7090000c8090000cb090000cc090000030a0000030a00003e0a0000400a0000830a0000830a0000be0a0000c00a0000c90a0000c90a0000cb0a0000cc0a0000020b0000030b0000400b0000400b0000470b0000480b00004b0b00004c0b0000bf0b0000bf0b0000c10b0000c20b0000c60b0000c80b0000ca0b0000cc0b0000010c0000030c0000410c0000440c0000820c0000830c0000be0c0000be0c0000c00c0000c10c0000c30c0000c40c0000c70c0000c80c0000ca0c0000cb0c0000020d0000030d00003f0d0000400d0000460d0000480d00004a0d00004c0d0000820d0000830d0000d00d0000d10d0000d80d0000de0d0000f20d0000f30d0000330e0000330e0000b30e0000b30e00003e0f00003f0f00007f0f00007f0f000031100000311000003b1000003c10000056100000571000008410000084100000b6170000b6170000be170000c5170000c7170000c81700002319000026190000291900002b19000030190000311900003319000038190000191a00001a1a0000551a0000551a0000571a0000571a00006d1a0000721a0000041b0000041b00003b1b00003b1b00003d1b0000411b0000431b0000441b0000821b0000821b0000a11b0000a11b0000a61b0000a71b0000aa1b0000aa1b0000e71b0000e71b0000ea1b0000ec1b0000ee1b0000ee1b0000f21b0000f31b0000241c00002b1c0000341c0000351c0000e11c0000e11c0000f71c0000f71c000023a8000024a8000027a8000027a8000080a8000081a80000b4a80000c3a8000052a9000053a9000083a9000083a90000b4a90000b5a90000baa90000bba90000bea90000c0a900002faa000030aa000033aa000034aa00004daa00004daa0000ebaa0000ebaa0000eeaa0000efaa0000f5aa0000f5aa0000e3ab0000e4ab0000e6ab0000e7ab0000e9ab0000eaab0000ecab0000ecab0000001001000010010002100100021001008210010082100100b0100100b2100100b7100100b81001002c1101002c11010045110100461101008211010082110100b3110100b5110100bf110100c0110100ce110100ce1101002c1201002e12010032120100331201003512010035120100e0120100e212010002130100031301003f1301003f130100411301004413010047130100481301004b1301004d1301006213010063130100351401003714010040140100411401004514010045140100b1140100b2140100b9140100b9140100bb140100bc140100be140100be140100c1140100c1140100b0150100b1150100b8150100bb150100be150100be15010030160100321601003b1601003c1601003e1601003e160100ac160100ac160100ae160100af160100b6160100b6160100201701002117010026170100261701002c1801002e1801003818010038180100311901003519010037190100381901003d1901003d19010040190100401901004219010042190100d1190100d3190100dc190100df190100e4190100e4190100391a0100391a0100571a0100581a0100971a0100971a01002f1c01002f1c01003e1c01003e1c0100a91c0100a91c0100b11c0100b11c0100b41c0100b41c01008a1d01008e1d0100931d0100941d0100961d0100961d0100f51e0100f61e0100516f0100876f0100f06f0100f16f010066d1010066d101006dd101006dd10100"); | ||
| 16552 | + _const_grapheme_prepend_ranges = _S("0006000005060000dd060000dd0600000f0700000f070000e2080000e20800004e0d00004e0d0000bd100100bd100100cd100100cd100100c2110100c31101003f1901003f19010041190100411901003a1a01003a1a0100841a0100891a0100461d0100461d0100"); | ||
| 16553 | + _const_grapheme_extended_pictographic_ranges = _S("a9000000a9000000ae000000ae0000003c2000003c2000004920000049200000222100002221000039210000392100009421000099210000a9210000aa2100001a2300001b23000028230000282300008823000088230000cf230000cf230000e9230000ec230000ed230000ee230000ef230000ef230000f0230000f0230000f1230000f2230000f3230000f3230000f8230000fa230000c2240000c2240000aa250000ab250000b6250000b6250000c0250000c0250000fb250000fe2500000026000001260000022600000326000004260000042600000526000005260000072600000d2600000e2600000e2600000f2600001026000011260000112600001226000012260000142600001526000016260000172600001826000018260000192600001c2600001d2600001d2600001e2600001f2600002026000020260000212600002126000022260000232600002426000025260000262600002626000027260000292600002a2600002a2600002b2600002d2600002e2600002e2600002f2600002f260000302600003726000038260000392600003a2600003a2600003b2600003f26000040260000402600004126000041260000422600004226000043260000472600004826000053260000542600005e2600005f2600005f2600006026000060260000612600006226000063260000632600006426000064260000652600006626000067260000672600006826000068260000692600007a2600007b2600007b2600007c2600007d2600007e2600007e2600007f2600007f2600008026000085260000902600009126000092260000922600009326000093260000942600009426000095260000952600009626000097260000982600009826000099260000992600009a2600009a2600009b2600009c2600009d2600009f260000a0260000a1260000a2260000a6260000a7260000a7260000a8260000a9260000aa260000ab260000ac260000af260000b0260000b1260000b2260000bc260000bd260000be260000bf260000c3260000c4260000c5260000c6260000c7260000c8260000c8260000c9260000cd260000ce260000ce260000cf260000cf260000d0260000d0260000d1260000d1260000d2260000d2260000d3260000d3260000d4260000d4260000d5260000e8260000e9260000e9260000ea260000ea260000eb260000ef260000f0260000f1260000f2260000f3260000f4260000f4260000f5260000f5260000f6260000f6260000f7260000f9260000fa260000fa260000fb260000fc260000fd260000fd260000fe26000001270000022700000227000003270000042700000527000005270000082700000c2700000d2700000d2700000e2700000e2700000f2700000f27000010270000112700001227000012270000142700001427000016270000162700001d2700001d270000212700002127000028270000282700003327000034270000442700004427000047270000472700004c2700004c2700004e2700004e270000532700005527000057270000572700006327000063270000642700006427000065270000672700009527000097270000a1270000a1270000b0270000b0270000bf270000bf2700003429000035290000052b0000072b00001b2b00001c2b0000502b0000502b0000552b0000552b000030300000303000003d3000003d3000009732000097320000993200009932000000f0010003f0010004f0010004f0010005f00100cef00100cff00100cff00100d0f00100fff001000df101000ff101002ff101002ff101006cf101006ff1010070f1010071f101007ef101007ff101008ef101008ef1010091f101009af10100adf10100e5f1010001f2010002f2010003f201000ff201001af201001af201002ff201002ff2010032f201003af201003cf201003ff2010049f201004ff2010050f2010051f2010052f20100fff2010000f301000cf301000df301000ef301000ff301000ff3010010f3010010f3010011f3010011f3010012f3010012f3010013f3010015f3010016f3010018f3010019f3010019f301001af301001af301001bf301001bf301001cf301001cf301001df301001ef301001ff3010020f3010021f3010021f3010022f3010023f3010024f301002cf301002df301002ff3010030f3010031f3010032f3010033f3010034f3010035f3010036f3010036f3010037f301004af301004bf301004bf301004cf301004ff3010050f3010050f3010051f301007bf301007cf301007cf301007df301007df301007ef301007ff3010080f3010093f3010094f3010095f3010096f3010097f3010098f3010098f3010099f301009bf301009cf301009df301009ef301009ff30100a0f30100c4f30100c5f30100c5f30100c6f30100c6f30100c7f30100c7f30100c8f30100c8f30100c9f30100c9f30100caf30100caf30100cbf30100cef30100cff30100d3f30100d4f30100dff30100e0f30100e3f30100e4f30100e4f30100e5f30100f0f30100f1f30100f2f30100f3f30100f3f30100f4f30100f4f30100f5f30100f5f30100f6f30100f6f30100f7f30100f7f30100f8f30100faf3010000f4010007f4010008f4010008f4010009f401000bf401000cf401000ef401000ff4010010f4010011f4010012f4010013f4010013f4010014f4010014f4010015f4010015f4010016f4010016f4010017f4010029f401002af401002af401002bf401003ef401003ff401003ff4010040f4010040f4010041f4010041f4010042f4010064f4010065f4010065f4010066f401006bf401006cf401006df401006ef40100acf40100adf40100adf40100aef40100b5f40100b6f40100b7f40100b8f40100ebf40100ecf40100edf40100eef40100eef40100eff40100eff40100f0f40100f4f40100f5f40100f5f40100f6f40100f7f40100f8f40100f8f40100f9f40100fcf40100fdf40100fdf40100fef40100fef40100fff4010002f5010003f5010003f5010004f5010007f5010008f5010008f5010009f5010009f501000af5010014f5010015f5010015f5010016f501002bf501002cf501002df501002ef501003df5010046f5010048f5010049f501004af501004bf501004ef501004ff501004ff5010050f501005bf501005cf5010067f5010068f501006ef501006ff5010070f5010071f5010072f5010073f5010079f501007af501007af501007bf5010086f5010087f5010087f5010088f5010089f501008af501008df501008ef501008ff5010090f5010090f5010091f5010094f5010095f5010096f5010097f50100a3f50100a4f50100a4f50100a5f50100a5f50100a6f50100a7f50100a8f50100a8f50100a9f50100b0f50100b1f50100b2f50100b3f50100bbf50100bcf50100bcf50100bdf50100c1f50100c2f50100c4f50100c5f50100d0f50100d1f50100d3f50100d4f50100dbf50100dcf50100def50100dff50100e0f50100e1f50100e1f50100e2f50100e2f50100e3f50100e3f50100e4f50100e7f50100e8f50100e8f50100e9f50100eef50100eff50100eff50100f0f50100f2f50100f3f50100f3f50100f4f50100f9f50100faf50100faf50100fbf50100fff5010000f6010000f6010001f6010006f6010007f6010008f6010009f601000df601000ef601000ef601000ff601000ff6010010f6010010f6010011f6010011f6010012f6010014f6010015f6010015f6010016f6010016f6010017f6010017f6010018f6010018f6010019f6010019f601001af601001af601001bf601001bf601001cf601001ef601001ff601001ff6010020f6010025f6010026f6010027f6010028f601002bf601002cf601002cf601002df601002df601002ef601002ff6010030f6010033f6010034f6010034f6010035f6010035f6010036f6010036f6010037f6010040f6010041f6010044f6010045f601004ff6010080f6010080f6010081f6010082f6010083f6010085f6010086f6010086f6010087f6010087f6010088f6010088f6010089f6010089f601008af601008bf601008cf601008cf601008df601008df601008ef601008ef601008ff601008ff6010090f6010090f6010091f6010093f6010094f6010094f6010095f6010095f6010096f6010096f6010097f6010097f6010098f6010098f6010099f601009af601009bf60100a1f60100a2f60100a2f60100a3f60100a3f60100a4f60100a5f60100a6f60100a6f60100a7f60100adf60100aef60100b1f60100b2f60100b2f60100b3f60100b5f60100b6f60100b6f60100b7f60100b8f60100b9f60100bef60100bff60100bff60100c0f60100c0f60100c1f60100c5f60100c6f60100caf60100cbf60100cbf60100ccf60100ccf60100cdf60100cff60100d0f60100d0f60100d1f60100d2f60100d3f60100d4f60100d5f60100d5f60100d6f60100d7f60100d8f60100dff60100e0f60100e5f60100e6f60100e8f60100e9f60100e9f60100eaf60100eaf60100ebf60100ecf60100edf60100eff60100f0f60100f0f60100f1f60100f2f60100f3f60100f3f60100f4f60100f6f60100f7f60100f8f60100f9f60100f9f60100faf60100faf60100fbf60100fcf60100fdf60100fff6010074f701007ff70100d5f70100dff70100e0f70100ebf70100ecf70100fff701000cf801000ff8010048f801004ff801005af801005ff8010088f801008ff80100aef80100fff801000cf901000cf901000df901000ff9010010f9010018f9010019f901001ef901001ff901001ff9010020f9010027f9010028f901002ff9010030f9010030f9010031f9010032f9010033f901003af901003cf901003ef901003ff901003ff9010040f9010045f9010047f901004bf901004cf901004cf901004df901004ff9010050f901005ef901005ff901006bf901006cf9010070f9010071f9010071f9010072f9010072f9010073f9010076f9010077f9010078f9010079f9010079f901007af901007af901007bf901007bf901007cf901007ff9010080f9010084f9010085f9010091f9010092f9010097f9010098f90100a2f90100a3f90100a4f90100a5f90100aaf90100abf90100adf90100aef90100aff90100b0f90100b9f90100baf90100bff90100c0f90100c0f90100c1f90100c2f90100c3f90100caf90100cbf90100cbf90100ccf90100ccf90100cdf90100cff90100d0f90100e6f90100e7f90100fff9010000fa01006ffa010070fa010073fa010074fa010074fa010075fa010077fa010078fa01007afa01007bfa01007ffa010080fa010082fa010083fa010086fa010087fa01008ffa010090fa010095fa010096fa0100a8fa0100a9fa0100affa0100b0fa0100b6fa0100b7fa0100bffa0100c0fa0100c2fa0100c3fa0100cffa0100d0fa0100d6fa0100d7fa0100fffa010000fc0100fdff0100"); | ||
| 16554 | + _const_digit_pairs = _S("00102030405060708090011121314151617181910212223242526272829203132333435363738393041424344454647484940515253545556575859506162636465666768696071727374757677787970818283848586878889809192939495969798999"); | ||
| 16555 | + _const_si_s_code = _S("0xfe10"); | ||
| 16556 | + _const_si_g32_code = _S("0xfe0e"); | ||
| 16557 | + _const_si_g64_code = _S("0xfe0f"); | ||
| 16558 | + g_live_reload_info = *(voidptr*)&((voidptr[]){0}[0]); // global 5 | ||
| 16559 | + _const_error_sentinel = I_MessageError_to_Interface_IError((HEAP(MessageError, ((MessageError){.msg = _S("error"),.code = 0,})))); | ||
| 16560 | + _const_none__ = I_None___to_Interface_IError((HEAP(None__, ((None__){.Error = ((Error){E_STRUCT}),})))); | ||
| 16561 | + _const_min_i64 = ((i64)(-9223372036854775807LL - 1)); | ||
| 16562 | + _const_max_i64 = ((i64)(9223372036854775807LL)); | ||
| 16563 | + _const_utf8_replacement_rune = ((rune)(0xfffd)); | ||
| 16564 | +} | ||
| 16565 | +void _vcleanup(void) { | ||
| 16566 | + static bool once = false; if (once) {return;} once = true; | ||
| 16567 | +} | ||
| 16568 | +__attribute__ ((constructor)) | ||
| 16569 | +void _vinit_caller() { | ||
| 16570 | + static bool once = false; if (once) {return;} once = true; | ||
| 16571 | + _vinit(0,0); | ||
| 16572 | +} | ||
| 16573 | +__attribute__ ((destructor)) | ||
| 16574 | +void _vcleanup_caller() { | ||
| 16575 | + static bool once = false; if (once) {return;} once = true; | ||
| 16576 | + _vcleanup(); | ||
| 16577 | +} | ||
| 16578 | + | ||
| 16579 | +int main(int ___argc, char** ___argv){ | ||
| 16580 | + g_main_argc = ___argc; | ||
| 16581 | + g_main_argv = ___argv; | ||
| 16582 | + _vinit(___argc, (voidptr)___argv); | ||
| 16583 | + main__main(); | ||
| 16584 | + _vcleanup(); | ||
| 16585 | + return 0; | ||
| 16586 | +} | ||
| 16587 | +// THE END. | ||
added
ios/Classes/vflutter.h +30 -0 | new file mode 100644 | ||
| @@ -0,0 +1,30 @@ | ||
| 1 | +// C-ABI surface of the V library. Hand-maintained; ffigen parses this. | |
| 2 | +#ifndef VFLUTTER_H | |
| 3 | +#define VFLUTTER_H | |
| 4 | + | |
| 5 | +#ifdef __cplusplus | |
| 6 | +extern "C" { | |
| 7 | +#endif | |
| 8 | + | |
| 9 | +#if defined(_WIN32) | |
| 10 | + #define VF_API __declspec(dllexport) | |
| 11 | +#else | |
| 12 | + #define VF_API __attribute__((visibility("default"))) | |
| 13 | +#endif | |
| 14 | + | |
| 15 | +// Idempotent. Safe to call from any isolate; required only on platforms | |
| 16 | +// where the ELF/Mach-O constructor may not have run (iOS static archives). | |
| 17 | +VF_API void vf_init(void); | |
| 18 | + | |
| 19 | +VF_API int vf_add(int a, int b); | |
| 20 | + | |
| 21 | +// Returns a NUL-terminated string allocated by V. Caller MUST release it | |
| 22 | +// with vf_free. Never free it with Dart's calloc/malloc. | |
| 23 | +VF_API char *vf_greet(const char *name); | |
| 24 | + | |
| 25 | +VF_API void vf_free(void *p); | |
| 26 | + | |
| 27 | +#ifdef __cplusplus | |
| 28 | +} | |
| 29 | +#endif | |
| 30 | +#endif // VFLUTTER_H | |
| new file mode 100644 | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | +// C-ABI surface of the V library. Hand-maintained; ffigen parses this. | ||
| 2 | +#ifndef VFLUTTER_H | ||
| 3 | +#define VFLUTTER_H | ||
| 4 | + | ||
| 5 | +#ifdef __cplusplus | ||
| 6 | +extern "C" { | ||
| 7 | +#endif | ||
| 8 | + | ||
| 9 | +#if defined(_WIN32) | ||
| 10 | + #define VF_API __declspec(dllexport) | ||
| 11 | +#else | ||
| 12 | + #define VF_API __attribute__((visibility("default"))) | ||
| 13 | +#endif | ||
| 14 | + | ||
| 15 | +// Idempotent. Safe to call from any isolate; required only on platforms | ||
| 16 | +// where the ELF/Mach-O constructor may not have run (iOS static archives). | ||
| 17 | +VF_API void vf_init(void); | ||
| 18 | + | ||
| 19 | +VF_API int vf_add(int a, int b); | ||
| 20 | + | ||
| 21 | +// Returns a NUL-terminated string allocated by V. Caller MUST release it | ||
| 22 | +// with vf_free. Never free it with Dart's calloc/malloc. | ||
| 23 | +VF_API char *vf_greet(const char *name); | ||
| 24 | + | ||
| 25 | +VF_API void vf_free(void *p); | ||
| 26 | + | ||
| 27 | +#ifdef __cplusplus | ||
| 28 | +} | ||
| 29 | +#endif | ||
| 30 | +#endif // VFLUTTER_H | ||
added
ios/vflutter_ffi.podspec +24 -0 | new file mode 100644 | ||
| @@ -0,0 +1,24 @@ | ||
| 1 | +Pod::Spec.new do |s| | |
| 2 | + s.name = 'vflutter_ffi' | |
| 3 | + s.version = '0.1.0' | |
| 4 | + s.summary = 'V language runtime bridged to Flutter via dart:ffi.' | |
| 5 | + s.homepage = 'https://example.com' | |
| 6 | + s.license = { :file => '../LICENSE' } | |
| 7 | + s.author = { 'you' => 'you@example.com' } | |
| 8 | + s.source = { :path => '.' } | |
| 9 | + s.source_files = 'Classes/**/*' | |
| 10 | + s.dependency 'Flutter' | |
| 11 | + s.platform = :ios, '12.0' | |
| 12 | + | |
| 13 | + # V's generated C is machine output. | |
| 14 | + s.compiler_flags = '-w' | |
| 15 | + | |
| 16 | + # The V runtime initialises through __attribute__((constructor)). In a static | |
| 17 | + # archive the linker drops objects nothing references, which would silently | |
| 18 | + # skip that. -all_load keeps them, and vf_init() is the belt-and-braces path. | |
| 19 | + s.pod_target_xcconfig = { | |
| 20 | + 'DEFINES_MODULE' => 'YES', | |
| 21 | + 'OTHER_LDFLAGS' => '-all_load', | |
| 22 | + 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' | |
| 23 | + } | |
| 24 | +end | |
| new file mode 100644 | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | +Pod::Spec.new do |s| | ||
| 2 | + s.name = 'vflutter_ffi' | ||
| 3 | + s.version = '0.1.0' | ||
| 4 | + s.summary = 'V language runtime bridged to Flutter via dart:ffi.' | ||
| 5 | + s.homepage = 'https://example.com' | ||
| 6 | + s.license = { :file => '../LICENSE' } | ||
| 7 | + s.author = { 'you' => 'you@example.com' } | ||
| 8 | + s.source = { :path => '.' } | ||
| 9 | + s.source_files = 'Classes/**/*' | ||
| 10 | + s.dependency 'Flutter' | ||
| 11 | + s.platform = :ios, '12.0' | ||
| 12 | + | ||
| 13 | + # V's generated C is machine output. | ||
| 14 | + s.compiler_flags = '-w' | ||
| 15 | + | ||
| 16 | + # The V runtime initialises through __attribute__((constructor)). In a static | ||
| 17 | + # archive the linker drops objects nothing references, which would silently | ||
| 18 | + # skip that. -all_load keeps them, and vf_init() is the belt-and-braces path. | ||
| 19 | + s.pod_target_xcconfig = { | ||
| 20 | + 'DEFINES_MODULE' => 'YES', | ||
| 21 | + 'OTHER_LDFLAGS' => '-all_load', | ||
| 22 | + 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' | ||
| 23 | + } | ||
| 24 | +end | ||
added
lib/vflutter_ffi.dart +88 -0 | new file mode 100644 | ||
| @@ -0,0 +1,88 @@ | ||
| 1 | +/// Idiomatic Dart surface over the V library. | |
| 2 | +/// | |
| 3 | +/// Callers never see a Pointer, and never own V memory: every string that | |
| 4 | +/// crosses the boundary is copied into Dart and the V allocation is released | |
| 5 | +/// before the call returns. | |
| 6 | +library vflutter_ffi; | |
| 7 | + | |
| 8 | +import 'dart:ffi'; | |
| 9 | +import 'dart:io'; | |
| 10 | +import 'dart:isolate'; | |
| 11 | +import 'package:ffi/ffi.dart'; | |
| 12 | + | |
| 13 | +const String _libName = 'vflutter'; | |
| 14 | + | |
| 15 | +DynamicLibrary _open() { | |
| 16 | + if (Platform.isMacOS || Platform.isIOS) { | |
| 17 | + // Static archive linked into the app binary. | |
| 18 | + return DynamicLibrary.process(); | |
| 19 | + } | |
| 20 | + if (Platform.isAndroid || Platform.isLinux) { | |
| 21 | + return DynamicLibrary.open('lib$_libName.so'); | |
| 22 | + } | |
| 23 | + if (Platform.isWindows) { | |
| 24 | + return DynamicLibrary.open('$_libName.dll'); | |
| 25 | + } | |
| 26 | + throw UnsupportedError('vflutter_ffi: unsupported platform'); | |
| 27 | +} | |
| 28 | + | |
| 29 | +final DynamicLibrary _lib = _open(); | |
| 30 | + | |
| 31 | +final void Function() _vfInit = | |
| 32 | + _lib.lookupFunction<Void Function(), void Function()>('vf_init'); | |
| 33 | + | |
| 34 | +final int Function(int, int) _vfAdd = | |
| 35 | + _lib.lookupFunction<Int32 Function(Int32, Int32), int Function(int, int)>( | |
| 36 | + 'vf_add'); | |
| 37 | + | |
| 38 | +final Pointer<Utf8> Function(Pointer<Utf8>) _vfGreet = _lib.lookupFunction< | |
| 39 | + Pointer<Utf8> Function(Pointer<Utf8>), | |
| 40 | + Pointer<Utf8> Function(Pointer<Utf8>)>('vf_greet'); | |
| 41 | + | |
| 42 | +final void Function(Pointer<Void>) _vfFree = | |
| 43 | + _lib.lookupFunction<Void Function(Pointer<Void>), void Function(Pointer<Void>)>( | |
| 44 | + 'vf_free'); | |
| 45 | + | |
| 46 | +bool _ready = false; | |
| 47 | + | |
| 48 | +/// Initialises the V runtime. Idempotent and cheap; called automatically by | |
| 49 | +/// every API below, so you rarely need it directly. | |
| 50 | +void ensureInitialized() { | |
| 51 | + if (_ready) return; | |
| 52 | + _vfInit(); | |
| 53 | + _ready = true; | |
| 54 | +} | |
| 55 | + | |
| 56 | +/// Adds two integers in V. The trivial case, useful as a liveness check. | |
| 57 | +int add(int a, int b) { | |
| 58 | + ensureInitialized(); | |
| 59 | + return _vfAdd(a, b); | |
| 60 | +} | |
| 61 | + | |
| 62 | +/// Round-trips a string through V. | |
| 63 | +/// | |
| 64 | +/// V allocates the result; this function copies it into a Dart [String] and | |
| 65 | +/// frees the V allocation before returning, so there is nothing to release. | |
| 66 | +String greet(String name) { | |
| 67 | + ensureInitialized(); | |
| 68 | + final arg = name.toNativeUtf8(); | |
| 69 | + Pointer<Utf8> res = nullptr; | |
| 70 | + try { | |
| 71 | + res = _vfGreet(arg); | |
| 72 | + if (res == nullptr) { | |
| 73 | + throw StateError('vf_greet returned null'); | |
| 74 | + } | |
| 75 | + return res.toDartString(); | |
| 76 | + } finally { | |
| 77 | + calloc.free(arg); | |
| 78 | + if (res != nullptr) _vfFree(res.cast()); | |
| 79 | + } | |
| 80 | +} | |
| 81 | + | |
| 82 | +/// Runs [greet] on a helper isolate. | |
| 83 | +/// | |
| 84 | +/// V compiled with `-gc none` has no stop-the-world phase and no thread-local | |
| 85 | +/// runtime state, so calls are safe from any isolate. Use this for work long | |
| 86 | +/// enough to jank a frame. | |
| 87 | +Future<String> greetAsync(String name) => | |
| 88 | + Isolate.run(() => greet(name)); | |
| new file mode 100644 | |||
| @@ -0,0 +1,88 @@ | |||
| 1 | +/// Idiomatic Dart surface over the V library. | ||
| 2 | +/// | ||
| 3 | +/// Callers never see a Pointer, and never own V memory: every string that | ||
| 4 | +/// crosses the boundary is copied into Dart and the V allocation is released | ||
| 5 | +/// before the call returns. | ||
| 6 | +library vflutter_ffi; | ||
| 7 | + | ||
| 8 | +import 'dart:ffi'; | ||
| 9 | +import 'dart:io'; | ||
| 10 | +import 'dart:isolate'; | ||
| 11 | +import 'package:ffi/ffi.dart'; | ||
| 12 | + | ||
| 13 | +const String _libName = 'vflutter'; | ||
| 14 | + | ||
| 15 | +DynamicLibrary _open() { | ||
| 16 | + if (Platform.isMacOS || Platform.isIOS) { | ||
| 17 | + // Static archive linked into the app binary. | ||
| 18 | + return DynamicLibrary.process(); | ||
| 19 | + } | ||
| 20 | + if (Platform.isAndroid || Platform.isLinux) { | ||
| 21 | + return DynamicLibrary.open('lib$_libName.so'); | ||
| 22 | + } | ||
| 23 | + if (Platform.isWindows) { | ||
| 24 | + return DynamicLibrary.open('$_libName.dll'); | ||
| 25 | + } | ||
| 26 | + throw UnsupportedError('vflutter_ffi: unsupported platform'); | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +final DynamicLibrary _lib = _open(); | ||
| 30 | + | ||
| 31 | +final void Function() _vfInit = | ||
| 32 | + _lib.lookupFunction<Void Function(), void Function()>('vf_init'); | ||
| 33 | + | ||
| 34 | +final int Function(int, int) _vfAdd = | ||
| 35 | + _lib.lookupFunction<Int32 Function(Int32, Int32), int Function(int, int)>( | ||
| 36 | + 'vf_add'); | ||
| 37 | + | ||
| 38 | +final Pointer<Utf8> Function(Pointer<Utf8>) _vfGreet = _lib.lookupFunction< | ||
| 39 | + Pointer<Utf8> Function(Pointer<Utf8>), | ||
| 40 | + Pointer<Utf8> Function(Pointer<Utf8>)>('vf_greet'); | ||
| 41 | + | ||
| 42 | +final void Function(Pointer<Void>) _vfFree = | ||
| 43 | + _lib.lookupFunction<Void Function(Pointer<Void>), void Function(Pointer<Void>)>( | ||
| 44 | + 'vf_free'); | ||
| 45 | + | ||
| 46 | +bool _ready = false; | ||
| 47 | + | ||
| 48 | +/// Initialises the V runtime. Idempotent and cheap; called automatically by | ||
| 49 | +/// every API below, so you rarely need it directly. | ||
| 50 | +void ensureInitialized() { | ||
| 51 | + if (_ready) return; | ||
| 52 | + _vfInit(); | ||
| 53 | + _ready = true; | ||
| 54 | +} | ||
| 55 | + | ||
| 56 | +/// Adds two integers in V. The trivial case, useful as a liveness check. | ||
| 57 | +int add(int a, int b) { | ||
| 58 | + ensureInitialized(); | ||
| 59 | + return _vfAdd(a, b); | ||
| 60 | +} | ||
| 61 | + | ||
| 62 | +/// Round-trips a string through V. | ||
| 63 | +/// | ||
| 64 | +/// V allocates the result; this function copies it into a Dart [String] and | ||
| 65 | +/// frees the V allocation before returning, so there is nothing to release. | ||
| 66 | +String greet(String name) { | ||
| 67 | + ensureInitialized(); | ||
| 68 | + final arg = name.toNativeUtf8(); | ||
| 69 | + Pointer<Utf8> res = nullptr; | ||
| 70 | + try { | ||
| 71 | + res = _vfGreet(arg); | ||
| 72 | + if (res == nullptr) { | ||
| 73 | + throw StateError('vf_greet returned null'); | ||
| 74 | + } | ||
| 75 | + return res.toDartString(); | ||
| 76 | + } finally { | ||
| 77 | + calloc.free(arg); | ||
| 78 | + if (res != nullptr) _vfFree(res.cast()); | ||
| 79 | + } | ||
| 80 | +} | ||
| 81 | + | ||
| 82 | +/// Runs [greet] on a helper isolate. | ||
| 83 | +/// | ||
| 84 | +/// V compiled with `-gc none` has no stop-the-world phase and no thread-local | ||
| 85 | +/// runtime state, so calls are safe from any isolate. Use this for work long | ||
| 86 | +/// enough to jank a frame. | ||
| 87 | +Future<String> greetAsync(String name) => | ||
| 88 | + Isolate.run(() => greet(name)); | ||
added
linux/CMakeLists.txt +3 -0 | new file mode 100644 | ||
| @@ -0,0 +1,3 @@ | ||
| 1 | +cmake_minimum_required(VERSION 3.15) | |
| 2 | +add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../src" "${CMAKE_CURRENT_BINARY_DIR}/vf") | |
| 3 | +set(vflutter_ffi_bundled_libraries "$<TARGET_FILE:vflutter>" PARENT_SCOPE) | |
| new file mode 100644 | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | +cmake_minimum_required(VERSION 3.15) | ||
| 2 | +add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../src" "${CMAKE_CURRENT_BINARY_DIR}/vf") | ||
| 3 | +set(vflutter_ffi_bundled_libraries "$<TARGET_FILE:vflutter>" PARENT_SCOPE) | ||
added
macos/Classes/vflutter.gen.c +16587 -0 | new file mode 100644 | ||
| @@ -0,0 +1,16587 @@ | ||
| 1 | + | |
| 2 | +#ifndef V_COMMIT_HASH | |
| 3 | + #define V_COMMIT_HASH "45ae01d23168b6372f734eeb38a77360bbcf184a" | |
| 4 | +#endif | |
| 5 | + | |
| 6 | +#define V_USE_SIGNAL_H | |
| 7 | + | |
| 8 | +// V comptime_definitions: | |
| 9 | +// V compile time defines by -d or -define flags: | |
| 10 | +// All custom defines : linux | |
| 11 | +// Turned ON custom defines: linux | |
| 12 | +#define CUSTOM_DEFINE_linux | |
| 13 | + | |
| 14 | + | |
| 15 | +// V typedefs: | |
| 16 | +typedef struct IError IError; | |
| 17 | +typedef struct none none; | |
| 18 | + | |
| 19 | +// BEGIN_array_fixed_return_typedefs | |
| 20 | +typedef struct _v_Array_fixed_string_11 _v_Array_fixed_string_11; | |
| 21 | +typedef struct _v_Array_fixed_voidptr_11 _v_Array_fixed_voidptr_11; | |
| 22 | +typedef struct _v_Array_fixed_u8_128 _v_Array_fixed_u8_128; | |
| 23 | +typedef struct _v_Array_fixed_u8_32 _v_Array_fixed_u8_32; | |
| 24 | +typedef struct _v_Array_fixed_u8_64 _v_Array_fixed_u8_64; | |
| 25 | +typedef struct _v_Array_fixed_u8_5 _v_Array_fixed_u8_5; | |
| 26 | +typedef struct _v_Array_fixed_u8_20 _v_Array_fixed_u8_20; | |
| 27 | +typedef struct _v_Array_fixed_u8_15 _v_Array_fixed_u8_15; | |
| 28 | +typedef struct _v_Array_fixed_u8_6 _v_Array_fixed_u8_6; | |
| 29 | +typedef struct _v_Array_fixed_u8_256 _v_Array_fixed_u8_256; | |
| 30 | +typedef struct _v_Array_fixed_u64_309 _v_Array_fixed_u64_309; | |
| 31 | +typedef struct _v_Array_fixed_u64_324 _v_Array_fixed_u64_324; | |
| 32 | +typedef struct _v_Array_fixed_u32_10 _v_Array_fixed_u32_10; | |
| 33 | +typedef struct _v_Array_fixed_u64_20 _v_Array_fixed_u64_20; | |
| 34 | +typedef struct _v_Array_fixed_u64_584 _v_Array_fixed_u64_584; | |
| 35 | +typedef struct _v_Array_fixed_u64_652 _v_Array_fixed_u64_652; | |
| 36 | +typedef struct _v_Array_fixed_f64_36 _v_Array_fixed_f64_36; | |
| 37 | +typedef struct _v_Array_fixed_u8_26 _v_Array_fixed_u8_26; | |
| 38 | +typedef struct _v_Array_fixed_u8_512 _v_Array_fixed_u8_512; | |
| 39 | +typedef struct _v_Array_fixed_u64_47 _v_Array_fixed_u64_47; | |
| 40 | +typedef struct _v_Array_fixed_u64_31 _v_Array_fixed_u64_31; | |
| 41 | +typedef struct _v_Array_fixed_int_64 _v_Array_fixed_int_64; | |
| 42 | +typedef struct _v_Array_fixed_voidptr_64 _v_Array_fixed_voidptr_64; | |
| 43 | +typedef struct _v_Array_fixed_voidptr_100 _v_Array_fixed_voidptr_100; | |
| 44 | +typedef struct _v_Array_fixed_u8_1000 _v_Array_fixed_u8_1000; | |
| 45 | +typedef struct _v_Array_fixed_u8_17 _v_Array_fixed_u8_17; | |
| 46 | +typedef struct _v_Array_fixed_i32_1264 _v_Array_fixed_i32_1264; | |
| 47 | +typedef struct _v_Array_fixed_int_10 _v_Array_fixed_int_10; | |
| 48 | +typedef struct _v_Array_fixed_int_20 _v_Array_fixed_int_20; | |
| 49 | +// END_array_fixed_return_typedefs | |
| 50 | + | |
| 51 | + | |
| 52 | +// BEGIN_multi_return_typedefs | |
| 53 | +typedef struct multi_return_u32_u32 multi_return_u32_u32; | |
| 54 | +typedef struct multi_return_string_string multi_return_string_string; | |
| 55 | +typedef struct multi_return_int_int multi_return_int_int; | |
| 56 | +typedef struct multi_return_rune_int multi_return_rune_int; | |
| 57 | +typedef struct multi_return_u32_u32_u32 multi_return_u32_u32_u32; | |
| 58 | +typedef struct multi_return_strconv__ParserState_strconv__PrepNumber multi_return_strconv__ParserState_strconv__PrepNumber; | |
| 59 | +typedef struct multi_return_u64_int multi_return_u64_int; | |
| 60 | +typedef struct multi_return_i64_int multi_return_i64_int; | |
| 61 | +typedef struct multi_return_strconv__Dec32_bool multi_return_strconv__Dec32_bool; | |
| 62 | +typedef struct multi_return_strconv__Dec64_bool multi_return_strconv__Dec64_bool; | |
| 63 | +typedef struct multi_return_u64_u64 multi_return_u64_u64; | |
| 64 | +typedef struct multi_return_f64_int multi_return_f64_int; | |
| 65 | +// END_multi_return_typedefs | |
| 66 | + | |
| 67 | +typedef struct strings__IndentParam strings__IndentParam; | |
| 68 | +typedef struct builtin__closure__ClosurePage builtin__closure__ClosurePage; | |
| 69 | +typedef struct builtin__closure__ClosureLiveInfo builtin__closure__ClosureLiveInfo; | |
| 70 | +typedef struct builtin__closure__ClosureLifetimeRecord builtin__closure__ClosureLifetimeRecord; | |
| 71 | +typedef struct builtin__closure__ClosureLifetimeFrame builtin__closure__ClosureLifetimeFrame; | |
| 72 | +typedef struct builtin__closure__ClosureLifetimeState builtin__closure__ClosureLifetimeState; | |
| 73 | +typedef struct builtin__closure__Lifetime builtin__closure__Lifetime; | |
| 74 | +typedef struct builtin__closure__FrameToken builtin__closure__FrameToken; | |
| 75 | +typedef struct builtin__closure__Closure builtin__closure__Closure; | |
| 76 | +typedef struct builtin__closure__ClosureMutex builtin__closure__ClosureMutex; | |
| 77 | +typedef struct strconv__AtoF64Param strconv__AtoF64Param; | |
| 78 | +typedef struct strconv__BF_param strconv__BF_param; | |
| 79 | +typedef struct strconv__PrepNumber strconv__PrepNumber; | |
| 80 | +typedef struct strconv__Dec32 strconv__Dec32; | |
| 81 | +typedef struct strconv__Dec64 strconv__Dec64; | |
| 82 | +typedef struct strconv__Uint128 strconv__Uint128; | |
| 83 | +typedef union strconv__Uf32 strconv__Uf32; | |
| 84 | +typedef union strconv__Uf64 strconv__Uf64; | |
| 85 | +typedef union strconv__Float64u strconv__Float64u; | |
| 86 | +typedef union strconv__Float32u strconv__Float32u; | |
| 87 | +typedef struct GCHeapUsage GCHeapUsage; | |
| 88 | +typedef struct array array; | |
| 89 | +typedef struct ArrayDataHeader ArrayDataHeader; | |
| 90 | +typedef struct _result _result; | |
| 91 | +typedef struct Error Error; | |
| 92 | +typedef struct MessageError MessageError; | |
| 93 | +typedef struct _option _option; | |
| 94 | +typedef struct None__ None__; | |
| 95 | +typedef struct GraphemeState GraphemeState; | |
| 96 | +typedef struct InputRuneIterator InputRuneIterator; | |
| 97 | +typedef struct DenseArray DenseArray; | |
| 98 | +typedef struct map map; | |
| 99 | +typedef struct VAssertMetaInfo VAssertMetaInfo; | |
| 100 | +typedef struct SortedMap SortedMap; | |
| 101 | +typedef struct mapnode mapnode; | |
| 102 | +typedef struct string string; | |
| 103 | +typedef struct RepIndex RepIndex; | |
| 104 | +typedef struct WrapConfig WrapConfig; | |
| 105 | +typedef struct RunesIterator RunesIterator; | |
| 106 | +typedef union StrIntpMem StrIntpMem; | |
| 107 | +typedef struct StrIntpData StrIntpData; | |
| 108 | +typedef struct ToWideConfig ToWideConfig; | |
| 109 | +typedef struct _result_int _result_int; | |
| 110 | +typedef struct _result_builtin__closure__ClosureLifetimeState_ptr _result_builtin__closure__ClosureLifetimeState_ptr; | |
| 111 | +typedef struct _result_builtin__closure__FrameToken _result_builtin__closure__FrameToken; | |
| 112 | +typedef struct _result_void _result_void; | |
| 113 | +typedef struct _result_f64 _result_f64; | |
| 114 | +typedef struct _result_u64 _result_u64; | |
| 115 | +typedef struct _result_i64 _result_i64; | |
| 116 | +typedef struct _result_multi_return_i64_int _result_multi_return_i64_int; | |
| 117 | +typedef struct _result_i8 _result_i8; | |
| 118 | +typedef struct _result_i16 _result_i16; | |
| 119 | +typedef struct _result_i32 _result_i32; | |
| 120 | +typedef struct _result_u8 _result_u8; | |
| 121 | +typedef struct _result_u16 _result_u16; | |
| 122 | +typedef struct _result_u32 _result_u32; | |
| 123 | +typedef struct _result_rune _result_rune; | |
| 124 | +typedef struct _result_string _result_string; | |
| 125 | +typedef struct _option_builtin__closure__ClosureLiveInfo _option_builtin__closure__ClosureLiveInfo; | |
| 126 | +typedef struct _option_builtin__closure__ClosureLifetimeState_ptr _option_builtin__closure__ClosureLifetimeState_ptr; | |
| 127 | +typedef struct _option_int _option_int; | |
| 128 | +typedef struct _option_rune _option_rune; | |
| 129 | +typedef struct _option_multi_return_string_string _option_multi_return_string_string; | |
| 130 | +typedef struct _option_u8 _option_u8; | |
| 131 | + | |
| 132 | + // V preincludes: | |
| 133 | +#define _GNU_SOURCE | |
| 134 | + | |
| 135 | +#if defined(__TINYC__) && defined(__has_include) // tcc does not support has_include properly yet, turn it off completely | |
| 136 | +#undef __has_include | |
| 137 | +#endif | |
| 138 | + | |
| 139 | +#if defined(__TINYC__) && defined(__BIONIC__) | |
| 140 | + #define __builtin_nanf(ignored_string) (0.0F / 0.0F) | |
| 141 | + #define __builtin_nan(ignored_string) (0.0 / 0.0) | |
| 142 | + #define __builtin_nanl(ignored_string) (0.0L / 0.0L) | |
| 143 | + #define __builtin_inff() (1.0F / 0.0F) | |
| 144 | + #define __builtin_inf() (1.0 / 0.0) | |
| 145 | + #define __builtin_infl() (1.0L / 0.0L) | |
| 146 | + #define __builtin_huge_valf() (1.0F / 0.0F) | |
| 147 | + #define __builtin_huge_val() (1.0 / 0.0) | |
| 148 | + #define __builtin_huge_vall() (1.0L / 0.0L) | |
| 149 | +#endif | |
| 150 | + | |
| 151 | +// V cheaders: | |
| 152 | +// Generated by the V compiler | |
| 153 | + | |
| 154 | +#if defined __GNUC__ && __GNUC__ >= 14 | |
| 155 | +#pragma GCC diagnostic warning "-Wimplicit-function-declaration" | |
| 156 | +#pragma GCC diagnostic warning "-Wincompatible-pointer-types" | |
| 157 | +#pragma GCC diagnostic warning "-Wint-conversion" | |
| 158 | +#pragma GCC diagnostic warning "-Wreturn-mismatch" | |
| 159 | +#endif | |
| 160 | + | |
| 161 | + | |
| 162 | +#if defined(__TINYC__) && defined(__has_include) // tcc does not support has_include properly yet, turn it off completely | |
| 163 | +#undef __has_include | |
| 164 | +#endif | |
| 165 | + | |
| 166 | +#if defined(__TINYC__) && defined(__BIONIC__) | |
| 167 | + #define __builtin_nanf(ignored_string) (0.0F / 0.0F) | |
| 168 | + #define __builtin_nan(ignored_string) (0.0 / 0.0) | |
| 169 | + #define __builtin_nanl(ignored_string) (0.0L / 0.0L) | |
| 170 | + #define __builtin_inff() (1.0F / 0.0F) | |
| 171 | + #define __builtin_inf() (1.0 / 0.0) | |
| 172 | + #define __builtin_infl() (1.0L / 0.0L) | |
| 173 | + #define __builtin_huge_valf() (1.0F / 0.0F) | |
| 174 | + #define __builtin_huge_val() (1.0 / 0.0) | |
| 175 | + #define __builtin_huge_vall() (1.0L / 0.0L) | |
| 176 | +#endif | |
| 177 | + | |
| 178 | +#ifdef __TINYC__ | |
| 179 | +#include <inttypes.h> | |
| 180 | +#else | |
| 181 | +#if defined(__has_include) | |
| 182 | +#if __has_include(<inttypes.h>) | |
| 183 | +#include <inttypes.h> | |
| 184 | +#elif __has_include(<stdint.h>) | |
| 185 | +#include <stdint.h> | |
| 186 | +#else | |
| 187 | +#error VERROR_MESSAGE The C compiler can not find <stdint.h>. Please install the package `build-essential`. | |
| 188 | +#endif | |
| 189 | +#else | |
| 190 | +#include <stdint.h> | |
| 191 | +#endif | |
| 192 | +#endif | |
| 193 | + | |
| 194 | + | |
| 195 | +#ifdef __TINYC__ | |
| 196 | +#include <stddef.h> | |
| 197 | +#else | |
| 198 | +#if defined(__has_include) | |
| 199 | +#if __has_include(<stddef.h>) | |
| 200 | +#include <stddef.h> | |
| 201 | +#else | |
| 202 | +#error VERROR_MESSAGE The C compiler can not find <stddef.h>. Please install the package `build-essential`. | |
| 203 | +#endif | |
| 204 | +#else | |
| 205 | +#include <stddef.h> | |
| 206 | +#endif | |
| 207 | +#endif | |
| 208 | + | |
| 209 | + | |
| 210 | +//================================== builtin types ================================*/ | |
| 211 | +#if defined(__x86_64__) || defined(_M_AMD64) || defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64) || (defined(__riscv_xlen) && __riscv_xlen == 64) || defined(__s390x__) || (defined(__powerpc64__) && defined(__LITTLE_ENDIAN__)) || defined(__loongarch64) || defined(__sparc__) || (defined(__powerpc64__) && defined(__BIG_ENDIAN__)) | |
| 212 | +typedef int64_t vint_t; | |
| 213 | +#else | |
| 214 | +typedef int32_t vint_t; | |
| 215 | +#endif | |
| 216 | +typedef int64_t i64; | |
| 217 | +typedef int16_t i16; | |
| 218 | +typedef int8_t i8; | |
| 219 | +typedef uint64_t u64; | |
| 220 | +typedef uint32_t u32; | |
| 221 | +typedef uint8_t u8; | |
| 222 | +typedef uint16_t u16; | |
| 223 | +typedef u8 byte; | |
| 224 | +typedef int32_t i32; | |
| 225 | +typedef uint32_t rune; | |
| 226 | +typedef size_t usize; | |
| 227 | +typedef ptrdiff_t isize; | |
| 228 | +#ifndef VNOFLOAT | |
| 229 | +typedef float f32; | |
| 230 | +typedef double f64; | |
| 231 | +#else | |
| 232 | +typedef int32_t f32; | |
| 233 | +typedef int64_t f64; | |
| 234 | +#endif | |
| 235 | +typedef int64_t int_literal; | |
| 236 | +#ifndef VNOFLOAT | |
| 237 | +typedef double float_literal; | |
| 238 | +#else | |
| 239 | +typedef int64_t float_literal; | |
| 240 | +#endif | |
| 241 | +typedef unsigned char* byteptr; | |
| 242 | +typedef void* voidptr; | |
| 243 | +typedef char* charptr; | |
| 244 | +typedef u8 array_fixed_byte_300 [300]; | |
| 245 | +typedef struct sync__Channel* chan; | |
| 246 | +#ifndef CUSTOM_DEFINE_no_bool | |
| 247 | + #ifndef __cplusplus | |
| 248 | + #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 202311L | |
| 249 | + #ifndef bool | |
| 250 | + #ifdef CUSTOM_DEFINE_4bytebool | |
| 251 | + typedef int bool; | |
| 252 | + #else | |
| 253 | + typedef u8 bool; | |
| 254 | + #endif | |
| 255 | + #define true 1 | |
| 256 | + #define false 0 | |
| 257 | + #endif | |
| 258 | + #endif | |
| 259 | + #endif | |
| 260 | +#endif | |
| 261 | + | |
| 262 | + | |
| 263 | +#define V_SAFE_SHIFT_BITS(type) ((u64)(sizeof(type) * 8)) | |
| 264 | +#define V_SAFE_LSHIFT_UNSIGNED(name, type) static inline type name(type x, u64 y) { return y >= V_SAFE_SHIFT_BITS(type) ? (type)0 : (type)(x << y); } | |
| 265 | +#define V_SAFE_LSHIFT_SIGNED(name, type, unsigned_type) static inline type name(type x, u64 y) { return y >= V_SAFE_SHIFT_BITS(type) ? (type)0 : (type)(((unsigned_type)x) << y); } | |
| 266 | +#define V_SAFE_RSHIFT_UNSIGNED(name, type) static inline type name(type x, u64 y) { return y >= V_SAFE_SHIFT_BITS(type) ? (type)0 : (type)(x >> y); } | |
| 267 | +#define V_SAFE_RSHIFT_SIGNED(name, type) static inline type name(type x, u64 y) { return y >= V_SAFE_SHIFT_BITS(type) ? (type)(x < 0 ? -1 : 0) : (type)(x >> y); } | |
| 268 | +V_SAFE_LSHIFT_SIGNED(v__lshift_char, char, u8) | |
| 269 | +V_SAFE_RSHIFT_SIGNED(v__rshift_char, char) | |
| 270 | +V_SAFE_LSHIFT_SIGNED(v__lshift_i8, i8, u8) | |
| 271 | +V_SAFE_RSHIFT_SIGNED(v__rshift_i8, i8) | |
| 272 | +V_SAFE_LSHIFT_SIGNED(v__lshift_i16, i16, u16) | |
| 273 | +V_SAFE_RSHIFT_SIGNED(v__rshift_i16, i16) | |
| 274 | +V_SAFE_LSHIFT_SIGNED(v__lshift_i32, i32, u32) | |
| 275 | +V_SAFE_RSHIFT_SIGNED(v__rshift_i32, i32) | |
| 276 | +V_SAFE_LSHIFT_SIGNED(v__lshift_int, int, unsigned int) | |
| 277 | +V_SAFE_RSHIFT_SIGNED(v__rshift_int, int) | |
| 278 | +V_SAFE_LSHIFT_SIGNED(v__lshift_vint_t, vint_t, u64) | |
| 279 | +V_SAFE_RSHIFT_SIGNED(v__rshift_vint_t, vint_t) | |
| 280 | +V_SAFE_LSHIFT_SIGNED(v__lshift_i64, i64, u64) | |
| 281 | +V_SAFE_RSHIFT_SIGNED(v__rshift_i64, i64) | |
| 282 | +V_SAFE_LSHIFT_SIGNED(v__lshift_isize, isize, usize) | |
| 283 | +V_SAFE_RSHIFT_SIGNED(v__rshift_isize, isize) | |
| 284 | +V_SAFE_LSHIFT_UNSIGNED(v__lshift_u8, u8) | |
| 285 | +V_SAFE_RSHIFT_UNSIGNED(v__rshift_u8, u8) | |
| 286 | +V_SAFE_LSHIFT_UNSIGNED(v__lshift_u16, u16) | |
| 287 | +V_SAFE_RSHIFT_UNSIGNED(v__rshift_u16, u16) | |
| 288 | +V_SAFE_LSHIFT_UNSIGNED(v__lshift_u32, u32) | |
| 289 | +V_SAFE_RSHIFT_UNSIGNED(v__rshift_u32, u32) | |
| 290 | +V_SAFE_LSHIFT_UNSIGNED(v__lshift_u64, u64) | |
| 291 | +V_SAFE_RSHIFT_UNSIGNED(v__rshift_u64, u64) | |
| 292 | +V_SAFE_LSHIFT_UNSIGNED(v__lshift_usize, usize) | |
| 293 | +V_SAFE_RSHIFT_UNSIGNED(v__rshift_usize, usize) | |
| 294 | +V_SAFE_LSHIFT_UNSIGNED(v__lshift_rune, rune) | |
| 295 | +V_SAFE_RSHIFT_UNSIGNED(v__rshift_rune, rune) | |
| 296 | +V_SAFE_LSHIFT_SIGNED(v__lshift_int_literal, int_literal, u64) | |
| 297 | +V_SAFE_RSHIFT_SIGNED(v__rshift_int_literal, int_literal) | |
| 298 | +#undef V_SAFE_RSHIFT_SIGNED | |
| 299 | +#undef V_SAFE_RSHIFT_UNSIGNED | |
| 300 | +#undef V_SAFE_LSHIFT_SIGNED | |
| 301 | +#undef V_SAFE_LSHIFT_UNSIGNED | |
| 302 | +#undef V_SAFE_SHIFT_BITS | |
| 303 | + | |
| 304 | + | |
| 305 | +typedef u64 (*MapHashFn)(voidptr); | |
| 306 | +typedef bool (*MapEqFn)(voidptr, voidptr); | |
| 307 | +typedef void (*MapCloneFn)(voidptr, voidptr); | |
| 308 | +typedef void (*MapFreeFn)(voidptr); | |
| 309 | + | |
| 310 | +//============================== HELPER C MACROS =============================*/ | |
| 311 | +// _SLIT0 is used as NULL string for literal arguments | |
| 312 | +// `"" s` is used to enforce a string literal argument | |
| 313 | +#define _SLIT0 (string){.str=(byteptr)(""), .len=0, .is_lit=1} | |
| 314 | +#define _S(s) ((string){.str=(byteptr)("" s), .len=(sizeof(s)-1), .is_lit=1}) | |
| 315 | +#define _SLEN(s, n) ((string){.str=(byteptr)("" s), .len=n, .is_lit=1}) | |
| 316 | +// optimized way to compare literal strings | |
| 317 | +#define _SLIT_EQ(sptr, slen, lit) (slen == sizeof("" lit)-1 && !builtin__vmemcmp(sptr, "" lit, slen)) | |
| 318 | +#define _SLIT_NE(sptr, slen, lit) (slen != sizeof("" lit)-1 || builtin__vmemcmp(sptr, "" lit, slen)) | |
| 319 | +// take the address of an rvalue | |
| 320 | +#define ADDR(type, expr) (&((type[]){expr}[0])) | |
| 321 | +// copy something to the heap | |
| 322 | +#define HEAP(type, expr) ((type*)builtin__memdup((void*)&((type[]){expr}[0]), sizeof(type))) | |
| 323 | +#define HEAP_noscan(type, expr) ((type*)builtin__memdup_noscan((void*)&((type[]){expr}[0]), sizeof(type))) | |
| 324 | +#define HEAP_align(type, expr, align) ((type*)builtin__memdup_align((void*)&((type[]){expr}[0]), sizeof(type), align)) | |
| 325 | +#define HEAP_vgc(type, expr, ptrmap, nptrs) ((type*)builtin__vgc_memdup_typed((void*)&((type[]){expr}[0]), sizeof(type), (ptrmap), (nptrs))) | |
| 326 | +#define _PUSH_MANY(arr, val, tmp, tmp_typ) {tmp_typ tmp = (val); builtin__array_push_many(arr, tmp.data, tmp.len);} | |
| 327 | +#define _PUSH_MANY_noscan(arr, val, tmp, tmp_typ) {tmp_typ tmp = (val); builtin__array_push_many_noscan(arr, tmp.data, tmp.len);} | |
| 328 | + | |
| 329 | +#define E_STRUCT_DECL | |
| 330 | +#define E_STRUCT | |
| 331 | +#define __NOINLINE __attribute__((noinline)) | |
| 332 | +#define __IRQHANDLER __attribute__((interrupt)) | |
| 333 | +#define __V_architecture 0 | |
| 334 | +#if defined(__x86_64__) || defined(_M_AMD64) | |
| 335 | + #define __V_amd64 1 | |
| 336 | + #undef __V_architecture | |
| 337 | + #define __V_architecture 1 | |
| 338 | +#endif | |
| 339 | +#if defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64) | |
| 340 | + #define __V_arm64 1 | |
| 341 | + #undef __V_architecture | |
| 342 | + #define __V_architecture 2 | |
| 343 | +#endif | |
| 344 | +#if defined(__arm__) || defined(_M_ARM) | |
| 345 | + #define __V_arm32 1 | |
| 346 | + #undef __V_architecture | |
| 347 | + #define __V_architecture 3 | |
| 348 | +#endif | |
| 349 | +#if defined(__riscv) && __riscv_xlen == 64 | |
| 350 | + #define __V_rv64 1 | |
| 351 | + #undef __V_architecture | |
| 352 | + #define __V_architecture 4 | |
| 353 | +#endif | |
| 354 | +#if defined(__riscv) && __riscv_xlen == 32 | |
| 355 | + #define __V_rv32 1 | |
| 356 | + #undef __V_architecture | |
| 357 | + #define __V_architecture 5 | |
| 358 | +#endif | |
| 359 | +#if defined(__i386__) || defined(_M_IX86) | |
| 360 | + #define __V_x86 1 | |
| 361 | + #undef __V_architecture | |
| 362 | + #define __V_architecture 6 | |
| 363 | +#endif | |
| 364 | +#if defined(__s390x__) | |
| 365 | + #define __V_s390x 1 | |
| 366 | + #undef __V_architecture | |
| 367 | + #define __V_architecture 7 | |
| 368 | +#endif | |
| 369 | +#if defined(__powerpc64__) && defined(__LITTLE_ENDIAN__) | |
| 370 | + #define __V_ppc64le 1 | |
| 371 | + #undef __V_architecture | |
| 372 | + #define __V_architecture 8 | |
| 373 | +#endif | |
| 374 | +#if defined(__loongarch64) | |
| 375 | + #define __V_loongarch64 1 | |
| 376 | + #undef __V_architecture | |
| 377 | + #define __V_architecture 9 | |
| 378 | +#endif | |
| 379 | +#if defined(__sparc__) | |
| 380 | + #define __V_sparc64 1 | |
| 381 | + #undef __V_architecture | |
| 382 | + #define __V_architecture 10 | |
| 383 | +#endif | |
| 384 | +#if defined(__powerpc64__) && defined(__BIG_ENDIAN__) | |
| 385 | + #define __V_ppc64 1 | |
| 386 | + #undef __V_architecture | |
| 387 | + #define __V_architecture 11 | |
| 388 | +#endif | |
| 389 | +#if (defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) || defined(__ppc__) || defined(__ppc) || defined(__PPC__)) && !defined(__powerpc64__) && !defined(__ppc64__) && !defined(__PPC64__) | |
| 390 | + #define __V_ppc 1 | |
| 391 | + #undef __V_architecture | |
| 392 | + #define __V_architecture 12 | |
| 393 | +#endif | |
| 394 | +// Using just __GNUC__ for detecting gcc, is not reliable because other compilers define it too: | |
| 395 | +#ifdef __GNUC__ | |
| 396 | + #define __V_GCC__ | |
| 397 | +#endif | |
| 398 | +#ifdef __TINYC__ | |
| 399 | + #undef __V_GCC__ | |
| 400 | +#endif | |
| 401 | +#ifdef __cplusplus | |
| 402 | + #undef __V_GCC__ | |
| 403 | +#endif | |
| 404 | +#ifdef __clang__ | |
| 405 | + #undef __V_GCC__ | |
| 406 | +#endif | |
| 407 | +#ifdef _MSC_VER | |
| 408 | + #undef __V_GCC__ | |
| 409 | + #undef E_STRUCT_DECL | |
| 410 | + #undef E_STRUCT | |
| 411 | + #define E_STRUCT_DECL unsigned char _dummy_pad | |
| 412 | + #define E_STRUCT 0 | |
| 413 | +#endif | |
| 414 | +#if defined(__has_include) && !defined(__TINYC__) | |
| 415 | + #if __has_include(<execinfo.h>) && !defined(_WIN32) | |
| 416 | + #define __V_HAVE_EXECINFO_H 1 | |
| 417 | + #include <execinfo.h> | |
| 418 | + #else | |
| 419 | + // On linux: int backtrace(void **__array, int __size); | |
| 420 | + // On BSD: size_t backtrace(void **, size_t); | |
| 421 | + #endif | |
| 422 | +#elif (defined(__linux__) && (defined(__GLIBC__) || defined(__GNU_LIBRARY__))) || defined(__APPLE__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) | |
| 423 | + #define __V_HAVE_EXECINFO_H 1 | |
| 424 | + #include <execinfo.h> | |
| 425 | +#else | |
| 426 | + // On linux: int backtrace(void **__array, int __size); | |
| 427 | + // On BSD: size_t backtrace(void **, size_t); | |
| 428 | +#endif | |
| 429 | +#ifndef __V_HAVE_EXECINFO_H | |
| 430 | + #ifdef __cplusplus | |
| 431 | + extern "C" { | |
| 432 | + #endif | |
| 433 | + int backtrace(void **__array, int __size); | |
| 434 | + char **backtrace_symbols(void *const *__array, int __size); | |
| 435 | + void backtrace_symbols_fd(void *const *__array, int __size, int __fd); | |
| 436 | + #ifdef __cplusplus | |
| 437 | + } | |
| 438 | + #endif | |
| 439 | +#endif | |
| 440 | +#ifdef __TINYC__ | |
| 441 | + #define _Atomic volatile | |
| 442 | + #undef E_STRUCT_DECL | |
| 443 | + #undef E_STRUCT | |
| 444 | + #define E_STRUCT_DECL unsigned char _dummy_pad | |
| 445 | + #define E_STRUCT 0 | |
| 446 | + #undef __NOINLINE | |
| 447 | + #undef __IRQHANDLER | |
| 448 | + // tcc does not support inlining at all | |
| 449 | + #define __NOINLINE | |
| 450 | + #define __IRQHANDLER | |
| 451 | + // #include <byteswap.h> | |
| 452 | + int tcc_backtrace(const char *fmt, ...); | |
| 453 | +#endif | |
| 454 | +// Use __offsetof_ptr instead of __offset_of, when you *do* have a valid pointer, to avoid UB: | |
| 455 | +#ifndef __offsetof_ptr | |
| 456 | + #define __offsetof_ptr(ptr,PTYPE,FIELDNAME) ((size_t)((byte *)&((PTYPE *)ptr)->FIELDNAME - (byte *)ptr)) | |
| 457 | +#endif | |
| 458 | +// for __offset_of | |
| 459 | +#ifndef __offsetof | |
| 460 | +#if defined(__TINYC__) || defined(_MSC_VER) | |
| 461 | + #define __offsetof(PTYPE,FIELDNAME) ((size_t)(&((PTYPE *)0)->FIELDNAME)) | |
| 462 | +#else | |
| 463 | + #define __offsetof(st, m) __builtin_offsetof(st, m) | |
| 464 | +#endif | |
| 465 | +#endif | |
| 466 | +#if defined(_WIN32) || defined(__CYGWIN__) | |
| 467 | + #define VV_EXP extern __declspec(dllexport) | |
| 468 | + #ifdef _VPARALLELCC | |
| 469 | + #define VV_LOC | |
| 470 | + #else | |
| 471 | + #define VV_LOC static | |
| 472 | + #endif | |
| 473 | +#else | |
| 474 | + // 4 < gcc < 5 is used by some older Ubuntu LTS and Centos versions, | |
| 475 | + // and does not support __has_attribute(visibility) ... | |
| 476 | + #ifndef __has_attribute | |
| 477 | + #define __has_attribute(x) 0 // Compatibility with non-clang compilers. | |
| 478 | + #endif | |
| 479 | + #if (defined(__GNUC__) && (__GNUC__ >= 4)) || (defined(__clang__) && __has_attribute(visibility)) | |
| 480 | + #ifdef ARM | |
| 481 | + #define VV_EXP extern __attribute__((externally_visible,visibility("default"))) | |
| 482 | + #else | |
| 483 | + #define VV_EXP extern __attribute__((visibility("default"))) | |
| 484 | + #endif | |
| 485 | + #if defined(_VOBJECTFILE) || (defined(__clang__) && (defined(_VUSECACHE) || defined(_VBUILDMODULE))) | |
| 486 | + #define VV_LOC static | |
| 487 | + #else | |
| 488 | + #define VV_LOC __attribute__ ((visibility ("hidden"))) | |
| 489 | + #endif | |
| 490 | + #else | |
| 491 | + #define VV_EXP extern | |
| 492 | + #ifdef _VPARALLELCC | |
| 493 | + #define VV_LOC | |
| 494 | + #else | |
| 495 | + #define VV_LOC static | |
| 496 | + #endif | |
| 497 | + #endif | |
| 498 | +#endif | |
| 499 | +#ifdef __cplusplus | |
| 500 | + #include <utility> | |
| 501 | + #define _MOV std::move | |
| 502 | +#else | |
| 503 | + #define _MOV | |
| 504 | +#endif | |
| 505 | +#if defined(__TINYC__) && defined(__has_include) // tcc does not support has_include properly yet, turn it off completely | |
| 506 | +#undef __has_include | |
| 507 | +#endif | |
| 508 | +//likely and unlikely macros | |
| 509 | +#if defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__clang__) | |
| 510 | + #define _likely_(x) __builtin_expect(x,1) | |
| 511 | + #define _unlikely_(x) __builtin_expect(x,0) | |
| 512 | +#else | |
| 513 | + #define _likely_(x) (x) | |
| 514 | + #define _unlikely_(x) (x) | |
| 515 | +#endif | |
| 516 | + | |
| 517 | +#if !defined(VCALLCONV) | |
| 518 | + #ifdef _MSC_VER | |
| 519 | + #define VCALLCONV(name) __##name | |
| 520 | + #else | |
| 521 | + #define VCALLCONV(name) __attribute__((name)) | |
| 522 | + #endif | |
| 523 | +#endif | |
| 524 | + | |
| 525 | +// c_headers | |
| 526 | +typedef int (*qsort_callback_func)(const void*, const void*); | |
| 527 | +#if defined(_MSC_VER) && !defined(__clang__) | |
| 528 | + #define V_CRT_LINKAGE __declspec(dllimport) | |
| 529 | + #define V_CRT_CALL VCALLCONV(cdecl) | |
| 530 | +#else | |
| 531 | + #define V_CRT_LINKAGE | |
| 532 | + #define V_CRT_CALL | |
| 533 | +#endif | |
| 534 | +#if (defined(_MSC_VER) && !defined(__clang__)) || defined(__cplusplus) | |
| 535 | +// Under C++ (g++/clang++), let libc declare FILE/stdio/string/stdlib to keep | |
| 536 | +// noexcept specifiers consistent — the manual extern "C" prototypes below | |
| 537 | +// would otherwise conflict with system headers under -std=c++NN. | |
| 538 | +#include <stdarg.h> | |
| 539 | +#include <stdio.h> | |
| 540 | +#include <stdlib.h> | |
| 541 | +#include <string.h> | |
| 542 | +#ifndef va_copy | |
| 543 | + #define va_copy(dest, src) ((dest) = (src)) | |
| 544 | +#endif | |
| 545 | +#ifndef _TRUNCATE | |
| 546 | + #define _TRUNCATE ((size_t)-1) | |
| 547 | +#endif | |
| 548 | +#elif defined(__NetBSD__) | |
| 549 | +// NetBSD exposes stdin/stdout/stderr as macros into a single `__sF[3]` | |
| 550 | +// array whose element size (sizeof(FILE)) depends on the platform and libc | |
| 551 | +// version, so we cannot forward-declare them. The FreeBSD-style | |
| 552 | +// `__stdinp/__stdoutp/__stderrp` symbols also do not exist on NetBSD (see | |
| 553 | +// vlang/v#27190). Defer to the system headers for FILE, the stdio streams, | |
| 554 | +// and the libc prototypes that would otherwise clash with the | |
| 555 | +// `__restrict`-qualified declarations in NetBSD libc. | |
| 556 | +#include <stdarg.h> | |
| 557 | +#include <stdio.h> | |
| 558 | +#include <stdlib.h> | |
| 559 | +#include <string.h> | |
| 560 | +#elif defined(__TINYC__) && (defined(__FreeBSD__) || defined(__OpenBSD__)) | |
| 561 | +// TinyCC reports a hard redefinition error if system OpenSSL pulls in | |
| 562 | +// <stdarg.h> after V has provided its own va_start macro. Include it first, | |
| 563 | +// but keep V manual FILE declarations on these BSD libc variants. | |
| 564 | +#include <stdarg.h> | |
| 565 | +#if defined(__FreeBSD__) | |
| 566 | +typedef struct __sFILE FILE; | |
| 567 | +extern FILE* __stdinp; | |
| 568 | +extern FILE* __stdoutp; | |
| 569 | +extern FILE* __stderrp; | |
| 570 | +#define stdin __stdinp | |
| 571 | +#define stdout __stdoutp | |
| 572 | +#define stderr __stderrp | |
| 573 | +#else | |
| 574 | +typedef struct __sFILE FILE; | |
| 575 | +#ifndef _STDFILES_DECLARED | |
| 576 | + #define _STDFILES_DECLARED | |
| 577 | +struct __sFstub { long _stub; }; | |
| 578 | +extern struct __sFstub __stdin[]; | |
| 579 | +extern struct __sFstub __stdout[]; | |
| 580 | +extern struct __sFstub __stderr[]; | |
| 581 | +#endif | |
| 582 | +#define stdin ((struct __sFILE *)__stdin) | |
| 583 | +#define stdout ((struct __sFILE *)__stdout) | |
| 584 | +#define stderr ((struct __sFILE *)__stderr) | |
| 585 | +#endif | |
| 586 | +#elif (defined(__MINGW32__) || defined(__MINGW64__)) && defined(__V_GCC__) | |
| 587 | +// mingw-w64 stdio.h provides fprintf/vfprintf as static inline overrides | |
| 588 | +// when __USE_MINGW_ANSI_STDIO is enabled, so use the system declarations | |
| 589 | +// instead of the manual formatted-stdio prototypes below. | |
| 590 | +#include <stdarg.h> | |
| 591 | +#include <stdio.h> | |
| 592 | +#elif defined(__MINGW32__) || defined(__MINGW64__) || (defined(__clang__) && (defined(_WIN32) || defined(_WIN64))) | |
| 593 | +typedef struct _iobuf FILE; | |
| 594 | +FILE* __cdecl __acrt_iob_func(unsigned index); | |
| 595 | +#define stdin (__acrt_iob_func(0)) | |
| 596 | +#define stdout (__acrt_iob_func(1)) | |
| 597 | +#define stderr (__acrt_iob_func(2)) | |
| 598 | +#elif defined(__TINYC__) && (defined(_WIN32) || defined(_WIN64)) | |
| 599 | +#ifndef _FILE_DEFINED | |
| 600 | +struct _iobuf { | |
| 601 | + char *_ptr; | |
| 602 | + int _cnt; | |
| 603 | + char *_base; | |
| 604 | + int _flag; | |
| 605 | + int _file; | |
| 606 | + int _charbuf; | |
| 607 | + int _bufsiz; | |
| 608 | + char *_tmpfname; | |
| 609 | +}; | |
| 610 | +typedef struct _iobuf FILE; | |
| 611 | +#define _FILE_DEFINED | |
| 612 | +#endif | |
| 613 | + #if defined(_WIN64) | |
| 614 | +FILE* __cdecl __iob_func(void); | |
| 615 | + #else | |
| 616 | + #ifdef _MSVCRT_ | |
| 617 | +extern FILE _iob[]; | |
| 618 | + #define __iob_func() (_iob) | |
| 619 | + #else | |
| 620 | +extern FILE (*_imp___iob)[]; | |
| 621 | + #define __iob_func() (*_imp___iob) | |
| 622 | + #define _iob __iob_func() | |
| 623 | + #endif | |
| 624 | + #endif | |
| 625 | +#define stdin (&__iob_func()[0]) | |
| 626 | +#define stdout (&__iob_func()[1]) | |
| 627 | +#define stderr (&__iob_func()[2]) | |
| 628 | +#elif defined(__vinix__) | |
| 629 | +typedef struct __file FILE; | |
| 630 | +extern FILE* stdin; | |
| 631 | +extern FILE* stdout; | |
| 632 | +extern FILE* stderr; | |
| 633 | +struct __thread_data; | |
| 634 | +struct __threadattr; | |
| 635 | +// pthread_t handling for vinix builds: | |
| 636 | +// - Vinix kernel (freestanding, __STDC_HOSTED__=0): no libc, define | |
| 637 | +// pthread_t ourselves so V code that references it compiles. | |
| 638 | +// - util-vinix cross-compiled on a libc-providing host (hosted, e.g. | |
| 639 | +// glibc on Linux or macOS with -D__vinix__): pull pthread_t from | |
| 640 | +// libc to avoid colliding with the libc typedef. | |
| 641 | +#if defined(__STDC_HOSTED__) && __STDC_HOSTED__ && defined(__has_include) && __has_include(<pthread.h>) | |
| 642 | +#include <pthread.h> | |
| 643 | +#else | |
| 644 | +typedef struct __thread_data *pthread_t; | |
| 645 | +#endif | |
| 646 | +typedef __builtin_va_list va_list; | |
| 647 | +#ifndef va_start | |
| 648 | + #define va_start(ap, v) __builtin_va_start(ap, v) | |
| 649 | +#endif | |
| 650 | +#ifndef va_arg | |
| 651 | + #define va_arg(ap, t) __builtin_va_arg(ap, t) | |
| 652 | +#endif | |
| 653 | +#ifndef va_end | |
| 654 | + #define va_end(ap) __builtin_va_end(ap) | |
| 655 | +#endif | |
| 656 | +#ifndef va_copy | |
| 657 | + #define va_copy(dest, src) __builtin_va_copy(dest, src) | |
| 658 | +#endif | |
| 659 | +#else | |
| 660 | + #if defined(__APPLE__) || defined(__FreeBSD__) | |
| 661 | +typedef struct __sFILE FILE; | |
| 662 | +extern FILE* __stdinp; | |
| 663 | +extern FILE* __stdoutp; | |
| 664 | +extern FILE* __stderrp; | |
| 665 | +#define stdin __stdinp | |
| 666 | +#define stdout __stdoutp | |
| 667 | +#define stderr __stderrp | |
| 668 | + #elif defined(__DragonFly__) | |
| 669 | +typedef struct __sFILE FILE; | |
| 670 | +extern FILE* __stdinp; | |
| 671 | +extern FILE* __stdoutp; | |
| 672 | +extern FILE* __stderrp; | |
| 673 | +#define stdin __stdinp | |
| 674 | +#define stdout __stdoutp | |
| 675 | +#define stderr __stderrp | |
| 676 | + #elif defined(__OpenBSD__) | |
| 677 | +typedef struct __sFILE FILE; | |
| 678 | +#ifndef _STDFILES_DECLARED | |
| 679 | + #define _STDFILES_DECLARED | |
| 680 | +struct __sFstub { long _stub; }; | |
| 681 | +extern struct __sFstub __stdin[]; | |
| 682 | +extern struct __sFstub __stdout[]; | |
| 683 | +extern struct __sFstub __stderr[]; | |
| 684 | +#endif | |
| 685 | +#define stdin ((struct __sFILE *)__stdin) | |
| 686 | +#define stdout ((struct __sFILE *)__stdout) | |
| 687 | +#define stderr ((struct __sFILE *)__stderr) | |
| 688 | + #elif defined(__BIONIC__) | |
| 689 | +struct __sFILE; | |
| 690 | +typedef struct __sFILE FILE; | |
| 691 | +extern FILE* stdin; | |
| 692 | +extern FILE* stdout; | |
| 693 | +extern FILE* stderr; | |
| 694 | + #elif defined(__linux__) && !defined(__GLIBC__) && !defined(__GNU_LIBRARY__) && !defined(__BIONIC__) && !defined(__UCLIBC__) | |
| 695 | +typedef struct _IO_FILE FILE; | |
| 696 | +// musl exposes the stdio streams as `FILE *const`, so match that to stay | |
| 697 | +// compatible with later <stdio.h> includes from headers like miniz.h. | |
| 698 | +extern FILE* const stdin; | |
| 699 | +extern FILE* const stdout; | |
| 700 | +extern FILE* const stderr; | |
| 701 | + #else | |
| 702 | +typedef struct _IO_FILE FILE; | |
| 703 | +extern FILE* stdin; | |
| 704 | +extern FILE* stdout; | |
| 705 | +extern FILE* stderr; | |
| 706 | + #endif | |
| 707 | +typedef __builtin_va_list va_list; | |
| 708 | +#ifndef va_start | |
| 709 | + #define va_start(ap, v) __builtin_va_start(ap, v) | |
| 710 | +#endif | |
| 711 | +#ifndef va_arg | |
| 712 | + #define va_arg(ap, t) __builtin_va_arg(ap, t) | |
| 713 | +#endif | |
| 714 | +#ifndef va_end | |
| 715 | + #define va_end(ap) __builtin_va_end(ap) | |
| 716 | +#endif | |
| 717 | +#ifndef va_copy | |
| 718 | + #define va_copy(dest, src) __builtin_va_copy(dest, src) | |
| 719 | +#endif | |
| 720 | +#endif | |
| 721 | +#if (!defined(_MSC_VER) || defined(__clang__)) && !defined(__cplusplus) && !defined(__NetBSD__) | |
| 722 | +// mingw-w64 stdio.h declares these as static __mingw_ovr inline overrides | |
| 723 | +// when __USE_MINGW_ANSI_STDIO is on. Skip them under gcc+mingw to avoid | |
| 724 | +// static-after-extern conflicts; clang+mingw needs them because it builds | |
| 725 | +// with -Werror=implicit-function-declaration and does not hit the conflict. | |
| 726 | +// NetBSD pulls these prototypes from <stdio.h>/<stdlib.h>/<string.h> via | |
| 727 | +// the include block above to avoid `__restrict` qualifier conflicts. | |
| 728 | +#if !((defined(__MINGW32__) || defined(__MINGW64__)) && !defined(__clang__)) | |
| 729 | +V_CRT_LINKAGE int V_CRT_CALL vfprintf(FILE *stream, const char *format, va_list ap); | |
| 730 | +V_CRT_LINKAGE int V_CRT_CALL vsnprintf(char *str, size_t size, const char *format, va_list ap); | |
| 731 | +V_CRT_LINKAGE int V_CRT_CALL fprintf(FILE *stream, const char *format, ...); | |
| 732 | +V_CRT_LINKAGE int V_CRT_CALL printf(const char *format, ...); | |
| 733 | +V_CRT_LINKAGE int V_CRT_CALL snprintf(char *str, size_t size, const char *format, ...); | |
| 734 | +V_CRT_LINKAGE int V_CRT_CALL sprintf(char *str, const char *format, ...); | |
| 735 | +V_CRT_LINKAGE int V_CRT_CALL sscanf(const char *str, const char *format, ...); | |
| 736 | +V_CRT_LINKAGE int V_CRT_CALL scanf(const char *format, ...); | |
| 737 | +#endif | |
| 738 | +V_CRT_LINKAGE int V_CRT_CALL puts(const char *str); | |
| 739 | +V_CRT_LINKAGE void V_CRT_CALL perror(const char *str); | |
| 740 | +V_CRT_LINKAGE int V_CRT_CALL fputs(const char *str, FILE *stream); | |
| 741 | +V_CRT_LINKAGE int V_CRT_CALL getchar(void); | |
| 742 | +V_CRT_LINKAGE int V_CRT_CALL putchar(int ch); | |
| 743 | +V_CRT_LINKAGE int V_CRT_CALL getc(FILE *stream); | |
| 744 | +V_CRT_LINKAGE int V_CRT_CALL fgetc(FILE *stream); | |
| 745 | +V_CRT_LINKAGE int V_CRT_CALL ungetc(int ch, FILE *stream); | |
| 746 | +V_CRT_LINKAGE int V_CRT_CALL fflush(FILE *stream); | |
| 747 | +V_CRT_LINKAGE int V_CRT_CALL feof(FILE *stream); | |
| 748 | +V_CRT_LINKAGE int V_CRT_CALL ferror(FILE *stream); | |
| 749 | +V_CRT_LINKAGE void V_CRT_CALL clearerr(FILE *stream); | |
| 750 | +V_CRT_LINKAGE int V_CRT_CALL setvbuf(FILE *stream, char *buf, int mode, size_t size); | |
| 751 | +V_CRT_LINKAGE long V_CRT_CALL ftell(FILE *stream); | |
| 752 | +V_CRT_LINKAGE void V_CRT_CALL rewind(FILE *stream); | |
| 753 | +V_CRT_LINKAGE FILE * V_CRT_CALL fopen(const char *filename, const char *mode); | |
| 754 | +V_CRT_LINKAGE FILE * V_CRT_CALL fdopen(int fd, const char *mode); | |
| 755 | +V_CRT_LINKAGE FILE * V_CRT_CALL freopen(const char *filename, const char *mode, FILE *stream); | |
| 756 | +V_CRT_LINKAGE int V_CRT_CALL fileno(FILE *stream); | |
| 757 | +V_CRT_LINKAGE size_t V_CRT_CALL fread(void *ptr, size_t size, size_t items, FILE *stream); | |
| 758 | +V_CRT_LINKAGE size_t V_CRT_CALL fwrite(const void *ptr, size_t size, size_t items, FILE *stream); | |
| 759 | +#if defined(__vinix__) | |
| 760 | +V_CRT_LINKAGE char * V_CRT_CALL fgets(char *str, size_t size, FILE *stream); | |
| 761 | +#else | |
| 762 | +V_CRT_LINKAGE char * V_CRT_CALL fgets(char *str, int size, FILE *stream); | |
| 763 | +#endif | |
| 764 | +V_CRT_LINKAGE int V_CRT_CALL fclose(FILE *stream); | |
| 765 | +#if defined(__vinix__) | |
| 766 | +V_CRT_LINKAGE FILE * V_CRT_CALL popen(char *command, char *mode); | |
| 767 | +#else | |
| 768 | +V_CRT_LINKAGE FILE * V_CRT_CALL popen(const char *command, const char *mode); | |
| 769 | +#endif | |
| 770 | +V_CRT_LINKAGE int V_CRT_CALL pclose(FILE *stream); | |
| 771 | +V_CRT_LINKAGE void * V_CRT_CALL malloc(size_t size); | |
| 772 | +V_CRT_LINKAGE void * V_CRT_CALL calloc(size_t nitems, size_t size); | |
| 773 | +V_CRT_LINKAGE void * V_CRT_CALL realloc(void *ptr, size_t size); | |
| 774 | +V_CRT_LINKAGE void * V_CRT_CALL aligned_alloc(size_t alignment, size_t size); | |
| 775 | +V_CRT_LINKAGE int V_CRT_CALL posix_memalign(void **memptr, size_t alignment, size_t size); | |
| 776 | +V_CRT_LINKAGE void V_CRT_CALL free(void *ptr); | |
| 777 | +V_CRT_LINKAGE int V_CRT_CALL rand(void); | |
| 778 | +V_CRT_LINKAGE void V_CRT_CALL srand(unsigned int seed); | |
| 779 | +V_CRT_LINKAGE int V_CRT_CALL atexit(void (*cb)(void)); | |
| 780 | +V_CRT_LINKAGE void V_CRT_CALL exit(int status); | |
| 781 | +V_CRT_LINKAGE int V_CRT_CALL abs(int n); | |
| 782 | +V_CRT_LINKAGE int V_CRT_CALL atoi(const char *str); | |
| 783 | +V_CRT_LINKAGE double V_CRT_CALL atof(const char *str); | |
| 784 | +V_CRT_LINKAGE char * V_CRT_CALL getenv(const char *name); | |
| 785 | +V_CRT_LINKAGE int V_CRT_CALL setenv(const char *name, const char *value, int overwrite); | |
| 786 | +V_CRT_LINKAGE int V_CRT_CALL unsetenv(const char *name); | |
| 787 | +V_CRT_LINKAGE int V_CRT_CALL system(const char *command); | |
| 788 | +V_CRT_LINKAGE int V_CRT_CALL remove(const char *path); | |
| 789 | +V_CRT_LINKAGE int V_CRT_CALL rename(const char *old_path, const char *new_path); | |
| 790 | +V_CRT_LINKAGE char * V_CRT_CALL realpath(const char *path, char *resolved_path); | |
| 791 | +V_CRT_LINKAGE int V_CRT_CALL mkstemp(char *stemplate); | |
| 792 | +V_CRT_LINKAGE void V_CRT_CALL qsort(void *base, size_t items, size_t item_size, qsort_callback_func cb); | |
| 793 | +#if defined(__vinix__) | |
| 794 | +V_CRT_LINKAGE int V_CRT_CALL strcmp(char *left, char *right); | |
| 795 | +V_CRT_LINKAGE int V_CRT_CALL strncmp(char *left, char *right, size_t n); | |
| 796 | +#else | |
| 797 | +V_CRT_LINKAGE int V_CRT_CALL strcmp(const char *left, const char *right); | |
| 798 | +V_CRT_LINKAGE int V_CRT_CALL strncmp(const char *left, const char *right, size_t n); | |
| 799 | +#endif | |
| 800 | +#if !defined(_WIN32) && !defined(_WIN64) && !defined(__BIONIC__) | |
| 801 | +V_CRT_LINKAGE char * V_CRT_CALL strdup(const char *str); | |
| 802 | +#endif | |
| 803 | +#if !defined(_WIN32) && !defined(_WIN64) | |
| 804 | +V_CRT_LINKAGE int V_CRT_CALL strcasecmp(const char *left, const char *right); | |
| 805 | +V_CRT_LINKAGE int V_CRT_CALL strncasecmp(const char *left, const char *right, size_t n); | |
| 806 | +#endif | |
| 807 | +#if defined(__vinix__) | |
| 808 | +V_CRT_LINKAGE size_t V_CRT_CALL strlen(char *str); | |
| 809 | +#else | |
| 810 | +V_CRT_LINKAGE size_t V_CRT_CALL strlen(const char *str); | |
| 811 | +#endif | |
| 812 | +V_CRT_LINKAGE char * V_CRT_CALL strerror(int errnum); | |
| 813 | +V_CRT_LINKAGE void * V_CRT_CALL memcpy(void *dest, const void *src, size_t n); | |
| 814 | +V_CRT_LINKAGE void * V_CRT_CALL memmove(void *dest, const void *src, size_t n); | |
| 815 | +V_CRT_LINKAGE void * V_CRT_CALL memset(void *dest, int ch, size_t n); | |
| 816 | +V_CRT_LINKAGE int V_CRT_CALL memcmp(const void *left, const void *right, size_t n); | |
| 817 | +V_CRT_LINKAGE void * V_CRT_CALL memchr(const void *str, int c, size_t n); | |
| 818 | +V_CRT_LINKAGE char * V_CRT_CALL strchr(const char *str, int c); | |
| 819 | +V_CRT_LINKAGE char * V_CRT_CALL strrchr(const char *str, int c); | |
| 820 | +V_CRT_LINKAGE char * V_CRT_CALL strstr(const char *haystack, const char *needle); | |
| 821 | +V_CRT_LINKAGE int V_CRT_CALL fseek(FILE *stream, long offset, int whence); | |
| 822 | +V_CRT_LINKAGE isize V_CRT_CALL getline(char **lineptr, size_t *n, FILE *stream); | |
| 823 | +#if defined(_WIN32) || defined(_WIN64) | |
| 824 | +V_CRT_LINKAGE int V_CRT_CALL _fileno(FILE *stream); | |
| 825 | +V_CRT_LINKAGE FILE * V_CRT_CALL _wfopen(const unsigned short *filename, const unsigned short *mode); | |
| 826 | +V_CRT_LINKAGE int V_CRT_CALL _wremove(const unsigned short *path); | |
| 827 | +V_CRT_LINKAGE void * V_CRT_CALL _aligned_malloc(size_t size, size_t alignment); | |
| 828 | +V_CRT_LINKAGE void * V_CRT_CALL _aligned_realloc(void *memory, size_t size, size_t alignment); | |
| 829 | +V_CRT_LINKAGE void V_CRT_CALL _aligned_free(void *memory); | |
| 830 | +V_CRT_LINKAGE unsigned short * V_CRT_CALL _wgetenv(const unsigned short *varname); | |
| 831 | +V_CRT_LINKAGE int V_CRT_CALL _wputenv(const unsigned short *envstring); | |
| 832 | +#endif | |
| 833 | +#if defined(_MSC_VER) && !defined(__clang__) | |
| 834 | +#ifndef _TRUNCATE | |
| 835 | + #define _TRUNCATE ((size_t)-1) | |
| 836 | +#endif | |
| 837 | +V_CRT_LINKAGE int V_CRT_CALL _vscprintf(const char *format, va_list ap); | |
| 838 | +V_CRT_LINKAGE int V_CRT_CALL _vsnprintf_s(char *buffer, size_t size, size_t count, const char *format, va_list ap); | |
| 839 | +#endif | |
| 840 | +#endif | |
| 841 | +#ifndef _IOFBF | |
| 842 | + #define _IOFBF 0 | |
| 843 | +#endif | |
| 844 | +#ifndef _IOLBF | |
| 845 | + #define _IOLBF 1 | |
| 846 | +#endif | |
| 847 | +#ifndef _IONBF | |
| 848 | + #define _IONBF 2 | |
| 849 | +#endif | |
| 850 | +#ifndef EOF | |
| 851 | + #define EOF (-1) | |
| 852 | +#endif | |
| 853 | +#ifndef SEEK_SET | |
| 854 | + #define SEEK_SET 0 | |
| 855 | +#endif | |
| 856 | +#ifndef SEEK_CUR | |
| 857 | + #define SEEK_CUR 1 | |
| 858 | +#endif | |
| 859 | +#ifndef SEEK_END | |
| 860 | + #define SEEK_END 2 | |
| 861 | +#endif | |
| 862 | +#ifndef RAND_MAX | |
| 863 | +enum { | |
| 864 | + #if defined(_MSC_VER) | |
| 865 | + RAND_MAX = 0x7fff | |
| 866 | + #else | |
| 867 | + RAND_MAX = 2147483647 | |
| 868 | + #endif | |
| 869 | +}; | |
| 870 | +#endif | |
| 871 | +#undef V_CRT_LINKAGE | |
| 872 | +#undef V_CRT_CALL | |
| 873 | +static void v_stable_sort(void *base, size_t items, size_t item_size, qsort_callback_func cb) { | |
| 874 | + if (items < 2 || item_size == 0) { | |
| 875 | + return; | |
| 876 | + } | |
| 877 | + if (items > ((size_t)-1) / item_size) { | |
| 878 | + qsort(base, items, item_size, cb); | |
| 879 | + return; | |
| 880 | + } | |
| 881 | + const size_t bytes = items * item_size; | |
| 882 | + char *base_bytes = (char*)base; | |
| 883 | + char *tmp = (char*)malloc(bytes); | |
| 884 | + if (tmp == 0) { | |
| 885 | + qsort(base, items, item_size, cb); | |
| 886 | + return; | |
| 887 | + } | |
| 888 | + char *src = base_bytes; | |
| 889 | + char *dst = tmp; | |
| 890 | + for (size_t width = 1; width < items;) { | |
| 891 | + for (size_t left = 0; left < items;) { | |
| 892 | + size_t mid = left; | |
| 893 | + mid += width; | |
| 894 | + if (mid > items) { | |
| 895 | + mid = items; | |
| 896 | + } | |
| 897 | + size_t right = mid; | |
| 898 | + right += width; | |
| 899 | + if (right > items || right < mid) { | |
| 900 | + right = items; | |
| 901 | + } | |
| 902 | + size_t i = left; | |
| 903 | + size_t j = mid; | |
| 904 | + size_t k = left; | |
| 905 | + while (i < mid && j < right) { | |
| 906 | + char *leftp = src; | |
| 907 | + leftp += i * item_size; | |
| 908 | + char *rightp = src; | |
| 909 | + rightp += j * item_size; | |
| 910 | + char *dstp = dst; | |
| 911 | + dstp += k * item_size; | |
| 912 | + if (cb(leftp, rightp) <= 0) { | |
| 913 | + memcpy(dstp, leftp, item_size); | |
| 914 | + i++; | |
| 915 | + } else { | |
| 916 | + memcpy(dstp, rightp, item_size); | |
| 917 | + j++; | |
| 918 | + } | |
| 919 | + k++; | |
| 920 | + } | |
| 921 | + while (i < mid) { | |
| 922 | + char *dstp = dst; | |
| 923 | + dstp += k * item_size; | |
| 924 | + char *srcp = src; | |
| 925 | + srcp += i * item_size; | |
| 926 | + memcpy(dstp, srcp, item_size); | |
| 927 | + i++; | |
| 928 | + k++; | |
| 929 | + } | |
| 930 | + while (j < right) { | |
| 931 | + char *dstp = dst; | |
| 932 | + dstp += k * item_size; | |
| 933 | + char *srcp = src; | |
| 934 | + srcp += j * item_size; | |
| 935 | + memcpy(dstp, srcp, item_size); | |
| 936 | + j++; | |
| 937 | + k++; | |
| 938 | + } | |
| 939 | + left = right; | |
| 940 | + } | |
| 941 | + char *next_src = dst; | |
| 942 | + dst = src; | |
| 943 | + src = next_src; | |
| 944 | + if (width > items / 2) { | |
| 945 | + width = items; | |
| 946 | + } else { | |
| 947 | + width *= 2; | |
| 948 | + } | |
| 949 | + } | |
| 950 | + if (src != base_bytes) { | |
| 951 | + memcpy(base_bytes, src, bytes); | |
| 952 | + } | |
| 953 | + free(tmp); | |
| 954 | +} | |
| 955 | +#if defined(__TINYC__) | |
| 956 | +// https://lists.nongnu.org/archive/html/tinycc-devel/2025-10/msg00007.html | |
| 957 | +// gnu headers use to #define __attribute__ to empty for non-gcc compilers | |
| 958 | +#undef __attribute__ | |
| 959 | +#endif | |
| 960 | +#if defined(_MSC_VER) && !defined(__clang__) | |
| 961 | +// Ensure C99-like return semantics and NUL-termination for MSVC snprintf/vsnprintf. | |
| 962 | +static int v__vsnprintf(char *s, size_t n, const char *fmt, va_list ap) { | |
| 963 | + va_list ap_copy; | |
| 964 | + va_copy(ap_copy, ap); | |
| 965 | + const int needed = _vscprintf(fmt, ap_copy); | |
| 966 | + va_end(ap_copy); | |
| 967 | + if (n > 0) { | |
| 968 | + const int written = _vsnprintf_s(s, n, _TRUNCATE, fmt, ap); | |
| 969 | + if (written < 0) { | |
| 970 | + s[n - | |
| 971 | + 1] = 0; | |
| 972 | + } | |
| 973 | + } | |
| 974 | + return needed; | |
| 975 | +} | |
| 976 | +static int v__snprintf(char *s, size_t n, const char *fmt, ...) { | |
| 977 | + va_list ap; | |
| 978 | + va_start(ap, fmt); | |
| 979 | + const int needed = v__vsnprintf(s, n, fmt, ap); | |
| 980 | + va_end(ap); | |
| 981 | + return needed; | |
| 982 | +} | |
| 983 | +#define vsnprintf v__vsnprintf | |
| 984 | +#define snprintf v__snprintf | |
| 985 | +#endif | |
| 986 | +//================================== GLOBALS =================================*/ | |
| 987 | +#ifdef _VOBJECTFILE | |
| 988 | +static void _vinit(int ___argc, voidptr ___argv); | |
| 989 | +static void _vcleanup(void); | |
| 990 | +#else | |
| 991 | +void _vinit(int ___argc, voidptr ___argv); | |
| 992 | +void _vcleanup(void); | |
| 993 | +#endif | |
| 994 | +#ifdef _WIN32 | |
| 995 | + // Export helpers so the autogenerated DllMain, or a user-defined one, | |
| 996 | + // can reuse the default V shared-library init/cleanup path. | |
| 997 | + #ifdef _VOBJECTFILE | |
| 998 | + static void _vinit_caller(); | |
| 999 | + static void _vcleanup_caller(); | |
| 1000 | + #else | |
| 1001 | + VV_EXP void _vinit_caller(); | |
| 1002 | + VV_EXP void _vcleanup_caller(); | |
| 1003 | + #endif | |
| 1004 | +#endif | |
| 1005 | +#if !defined(_WIN32) | |
| 1006 | +#define sigaction_size sizeof(sigaction); | |
| 1007 | +#endif | |
| 1008 | +#define _ARR_LEN(a) ( (sizeof(a)) / (sizeof(a[0])) ) | |
| 1009 | +#if INTPTR_MAX == INT32_MAX | |
| 1010 | + #define TARGET_IS_32BIT 1 | |
| 1011 | +#elif INTPTR_MAX == INT64_MAX | |
| 1012 | + #define TARGET_IS_64BIT 1 | |
| 1013 | +#else | |
| 1014 | + #error "The environment is not 32 or 64-bit." | |
| 1015 | +#endif | |
| 1016 | +#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ || defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN || defined(__BIG_ENDIAN__) || defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || defined(_MIBSEB) || defined(__MIBSEB) || defined(__MIBSEB__) | |
| 1017 | + #define TARGET_ORDER_IS_BIG 1 | |
| 1018 | +#elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ || defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN || defined(__LITTLE_ENDIAN__) || defined(__ARMEL__) || defined(__THUMBEL__) || defined(__AARCH64EL__) || defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__) || defined(_M_AMD64) || defined(_M_ARM64) || defined(_M_X64) || defined(_M_IX86) | |
| 1019 | + #define TARGET_ORDER_IS_LITTLE 1 | |
| 1020 | +#else | |
| 1021 | + #error "Unknown architecture endianness" | |
| 1022 | +#endif | |
| 1023 | +#if !defined(_WIN32) && !defined(__vinix__) | |
| 1024 | + #include <ctype.h> | |
| 1025 | + #include <locale.h> // tolower | |
| 1026 | + #include <sys/time.h> | |
| 1027 | + #include <unistd.h> // sleep | |
| 1028 | + extern char **environ; | |
| 1029 | + #include <pthread.h> | |
| 1030 | + #ifndef PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP | |
| 1031 | + // musl does not have that | |
| 1032 | + #define pthread_rwlockattr_setkind_np(a, b) | |
| 1033 | + #endif | |
| 1034 | +#endif | |
| 1035 | +#if (defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__serenity__) || defined(__sun) || defined(__plan9__) || defined(__OpenBSD__)) && !defined(__vinix__) | |
| 1036 | + #include <sys/types.h> | |
| 1037 | + #include <sys/wait.h> // for os__wait | |
| 1038 | +#endif | |
| 1039 | +#ifdef __OpenBSD__ | |
| 1040 | + #include <sys/resource.h> | |
| 1041 | +#endif | |
| 1042 | +#ifdef __FreeBSD__ | |
| 1043 | + #include <signal.h> | |
| 1044 | + #include <execinfo.h> | |
| 1045 | +#endif | |
| 1046 | +#ifdef __NetBSD__ | |
| 1047 | + #include <sys/wait.h> // for os__wait | |
| 1048 | +#endif | |
| 1049 | +#ifdef __TERMUX__ | |
| 1050 | +#if !defined(__BIONIC_AVAILABILITY_GUARD) | |
| 1051 | + #define __BIONIC_AVAILABILITY_GUARD(api_level) 0 | |
| 1052 | +#endif | |
| 1053 | +#if __BIONIC_AVAILABILITY_GUARD(28) | |
| 1054 | +#else | |
| 1055 | +void * aligned_alloc(size_t alignment, size_t size) { return malloc(size); } | |
| 1056 | +#endif | |
| 1057 | +#endif | |
| 1058 | +#ifdef __APPLE__ | |
| 1059 | + // macOS only exports aligned_alloc starting with 10.15. | |
| 1060 | + #if !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500 | |
| 1061 | +static void *v__aligned_alloc_fallback(size_t alignment, size_t size) { | |
| 1062 | + void *res = 0; | |
| 1063 | + if (alignment < sizeof(void *)) { | |
| 1064 | + alignment = sizeof(void *); | |
| 1065 | + } | |
| 1066 | + if (posix_memalign(&res, alignment, size) != 0) { | |
| 1067 | + return 0; | |
| 1068 | + } | |
| 1069 | + return res; | |
| 1070 | +} | |
| 1071 | + #define aligned_alloc v__aligned_alloc_fallback | |
| 1072 | + #endif | |
| 1073 | +#endif | |
| 1074 | +#ifdef _WIN32 | |
| 1075 | + #ifdef WINVER | |
| 1076 | + #undef WINVER | |
| 1077 | + #endif | |
| 1078 | + #define WINVER 0x0600 | |
| 1079 | + #ifdef _WIN32_WINNT | |
| 1080 | + #undef _WIN32_WINNT | |
| 1081 | + #endif | |
| 1082 | + #define _WIN32_WINNT 0x0600 | |
| 1083 | + #ifndef WIN32_FULL | |
| 1084 | + #define WIN32_LEAN_AND_MEAN | |
| 1085 | + #endif | |
| 1086 | + #ifndef _UNICODE | |
| 1087 | + #define _UNICODE | |
| 1088 | + #endif | |
| 1089 | + #ifndef UNICODE | |
| 1090 | + #define UNICODE | |
| 1091 | + #endif | |
| 1092 | + #include <windows.h> | |
| 1093 | + #include <io.h> // _waccess | |
| 1094 | + #include <direct.h> // _wgetcwd | |
| 1095 | + #ifdef V_USE_SIGNAL_H | |
| 1096 | + #include <signal.h> // signal and SIGSEGV for segmentation fault handler | |
| 1097 | + #endif | |
| 1098 | + #ifdef _MSC_VER | |
| 1099 | + // On MSVC these are the same (as long as /volatile:ms is passed) | |
| 1100 | + #define _Atomic volatile | |
| 1101 | + // MSVC cannot parse some things properly | |
| 1102 | + #undef __NOINLINE | |
| 1103 | + #undef __IRQHANDLER | |
| 1104 | + #define __NOINLINE __declspec(noinline) | |
| 1105 | + #define __IRQHANDLER __declspec(naked) | |
| 1106 | + #include <dbghelp.h> | |
| 1107 | + #pragma comment(lib, "Dbghelp") | |
| 1108 | + #endif | |
| 1109 | +#endif | |
| 1110 | +#if defined(__CYGWIN__) && !defined(_WIN32) | |
| 1111 | + #error Cygwin is not supported, please use MinGW or Visual Studio. | |
| 1112 | +#endif | |
| 1113 | +#if defined(__MINGW32__) || defined(__MINGW64__) || (defined(_WIN32) && defined(__TINYC__)) || defined(_MSC_VER) | |
| 1114 | + #undef PRId64 | |
| 1115 | + #undef PRIi64 | |
| 1116 | + #undef PRIo64 | |
| 1117 | + #undef PRIu64 | |
| 1118 | + #undef PRIx64 | |
| 1119 | + #undef PRIX64 | |
| 1120 | + #define PRId64 "lld" | |
| 1121 | + #define PRIi64 "lli" | |
| 1122 | + #define PRIo64 "llo" | |
| 1123 | + #define PRIu64 "llu" | |
| 1124 | + #define PRIx64 "llx" | |
| 1125 | + #define PRIX64 "llX" | |
| 1126 | +#endif | |
| 1127 | +#ifdef _VFREESTANDING | |
| 1128 | +#undef _VFREESTANDING | |
| 1129 | +#endif | |
| 1130 | + | |
| 1131 | + | |
| 1132 | +// deterministic float -> u64 conversions for explicit V casts | |
| 1133 | +// direct C casts are undefined for out-of-range values | |
| 1134 | +static inline uint64_t _v_f64_to_u64(double x) { | |
| 1135 | + if (!(x >= 0.0)) { | |
| 1136 | + return 0; | |
| 1137 | + } | |
| 1138 | + if (x >= 18446744073709551616.0) { | |
| 1139 | + return UINT64_MAX; | |
| 1140 | + } | |
| 1141 | + return (uint64_t)x; | |
| 1142 | +} | |
| 1143 | + | |
| 1144 | + | |
| 1145 | +// unsigned/signed comparisons | |
| 1146 | +static inline bool _us32_gt(uint32_t a, int32_t b) { return a > INT32_MAX || (int32_t)a > b; } | |
| 1147 | +static inline bool _us32_ge(uint32_t a, int32_t b) { return a >= INT32_MAX || (int32_t)a >= b; } | |
| 1148 | +static inline bool _us32_eq(uint32_t a, int32_t b) { return a <= INT32_MAX && (int32_t)a == b; } | |
| 1149 | +static inline bool _us32_ne(uint32_t a, int32_t b) { return a > INT32_MAX || (int32_t)a != b; } | |
| 1150 | +static inline bool _us32_le(uint32_t a, int32_t b) { return a <= INT32_MAX && (int32_t)a <= b; } | |
| 1151 | +static inline bool _us32_lt(uint32_t a, int32_t b) { return a < INT32_MAX && (int32_t)a < b; } | |
| 1152 | +static inline bool _us64_gt(uint64_t a, int64_t b) { return a > INT64_MAX || (int64_t)a > b; } | |
| 1153 | +static inline bool _us64_ge(uint64_t a, int64_t b) { return a >= INT64_MAX || (int64_t)a >= b; } | |
| 1154 | +static inline bool _us64_eq(uint64_t a, int64_t b) { return a <= INT64_MAX && (int64_t)a == b; } | |
| 1155 | +static inline bool _us64_ne(uint64_t a, int64_t b) { return a > INT64_MAX || (int64_t)a != b; } | |
| 1156 | +static inline bool _us64_le(uint64_t a, int64_t b) { return a <= INT64_MAX && (int64_t)a <= b; } | |
| 1157 | +static inline bool _us64_lt(uint64_t a, int64_t b) { return a < INT64_MAX && (int64_t)a < b; } | |
| 1158 | + | |
| 1159 | + | |
| 1160 | +#if !defined(VNORETURN) | |
| 1161 | + #if defined(__TINYC__) | |
| 1162 | + #define VNORETURN __attribute__((noreturn)) | |
| 1163 | + # elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L | |
| 1164 | + # define VNORETURN _Noreturn | |
| 1165 | + # elif !defined(VNORETURN) && defined(__GNUC__) && __GNUC__ >= 2 | |
| 1166 | + # define VNORETURN __attribute__((noreturn)) | |
| 1167 | + # endif | |
| 1168 | + #ifndef VNORETURN | |
| 1169 | + #define VNORETURN | |
| 1170 | + #endif | |
| 1171 | +#endif | |
| 1172 | + | |
| 1173 | + | |
| 1174 | +#if !defined(VUNREACHABLE) | |
| 1175 | + #if defined(__GNUC__) && !defined(__clang__) | |
| 1176 | + #define V_GCC_VERSION (__GNUC__ * 10000L + __GNUC_MINOR__ * 100L + __GNUC_PATCHLEVEL__) | |
| 1177 | + #if (V_GCC_VERSION >= 40500L) && !defined(__TINYC__) | |
| 1178 | + #define VUNREACHABLE() do { __builtin_unreachable(); } while (0) | |
| 1179 | + #endif | |
| 1180 | + #endif | |
| 1181 | + #if defined(__clang__) && defined(__has_builtin) && !defined(__TINYC__) | |
| 1182 | + #if __has_builtin(__builtin_unreachable) | |
| 1183 | + #define VUNREACHABLE() do { __builtin_unreachable(); } while (0) | |
| 1184 | + #endif | |
| 1185 | + #endif | |
| 1186 | + #ifndef VUNREACHABLE | |
| 1187 | + #define VUNREACHABLE() do { } while (0) | |
| 1188 | + #endif | |
| 1189 | +#endif | |
| 1190 | + | |
| 1191 | + | |
| 1192 | +#ifndef wyhash_final_version_4_2 | |
| 1193 | +#define wyhash_final_version_4_2 | |
| 1194 | +#ifndef WYHASH_CONDOM | |
| 1195 | +// protections that produce different results: | |
| 1196 | +// 1: normal valid behavior | |
| 1197 | +// 2: extra protection against entropy loss (probability=2^-63), aka. "blind multiplication" | |
| 1198 | +#define WYHASH_CONDOM 1 | |
| 1199 | +#endif | |
| 1200 | +#ifndef WYHASH_32BIT_MUM | |
| 1201 | +// 0: normal version, slow on 32 bit systems | |
| 1202 | +// 1: faster on 32 bit systems but produces different results, incompatible with wy2u0k function | |
| 1203 | +#define WYHASH_32BIT_MUM 0 | |
| 1204 | +#endif | |
| 1205 | +// includes | |
| 1206 | +#include <stdint.h> | |
| 1207 | +#if defined(_MSC_VER) && defined(_M_X64) | |
| 1208 | + #include <intrin.h> | |
| 1209 | + #pragma intrinsic(_umul128) | |
| 1210 | +#endif | |
| 1211 | +// 128bit multiply function | |
| 1212 | +static inline uint64_t _wyrot(uint64_t x) { return (x>>32)|(x<<32); } | |
| 1213 | +static inline void _wymum(uint64_t *A, uint64_t *B){ | |
| 1214 | +#if(WYHASH_32BIT_MUM) | |
| 1215 | + uint64_t hh=(*A>>32)*(*B>>32), hl=(*A>>32)*(uint32_t)*B, lh=(uint32_t)*A*(*B>>32), ll=(uint64_t)(uint32_t)*A*(uint32_t)*B; | |
| 1216 | + #if(WYHASH_CONDOM>1) | |
| 1217 | + *A^=_wyrot(hl)^hh; *B^=_wyrot(lh)^ll; | |
| 1218 | + #else | |
| 1219 | + *A=_wyrot(hl)^hh; *B=_wyrot(lh)^ll; | |
| 1220 | + #endif | |
| 1221 | +#elif defined(__SIZEOF_INT128__) && !defined(VWASM) | |
| 1222 | + __uint128_t r=*A; r*=*B; | |
| 1223 | + #if(WYHASH_CONDOM>1) | |
| 1224 | + *A^=(uint64_t)r; *B^=(uint64_t)(r>>64); | |
| 1225 | + #else | |
| 1226 | + *A=(uint64_t)r; *B=(uint64_t)(r>>64); | |
| 1227 | + #endif | |
| 1228 | +#elif defined(_MSC_VER) && defined(_M_X64) | |
| 1229 | + #if(WYHASH_CONDOM>1) | |
| 1230 | + uint64_t a, b; | |
| 1231 | + a=_umul128(*A,*B,&b); | |
| 1232 | + *A^=a; *B^=b; | |
| 1233 | + #else | |
| 1234 | + *A=_umul128(*A,*B,B); | |
| 1235 | + #endif | |
| 1236 | +#else | |
| 1237 | + uint64_t ha=*A>>32, hb=*B>>32, la=(uint32_t)*A, lb=(uint32_t)*B, hi, lo; | |
| 1238 | + uint64_t rh=ha*hb, rm0=ha*lb, rm1=hb*la, rl=la*lb, t=rl+(rm0<<32), c=t<rl; | |
| 1239 | + lo=t+(rm1<<32); c+=lo<t; hi=rh+(rm0>>32)+(rm1>>32)+c; | |
| 1240 | + #if(WYHASH_CONDOM>1) | |
| 1241 | + *A^=lo; *B^=hi; | |
| 1242 | + #else | |
| 1243 | + *A=lo; *B=hi; | |
| 1244 | + #endif | |
| 1245 | +#endif | |
| 1246 | +} | |
| 1247 | +// multiply and xor mix function, aka MUM | |
| 1248 | +static inline uint64_t _wymix(uint64_t A, uint64_t B){ _wymum(&A,&B); return A^B; } | |
| 1249 | +// endian macros | |
| 1250 | +#ifndef WYHASH_LITTLE_ENDIAN | |
| 1251 | + #ifdef TARGET_ORDER_IS_LITTLE | |
| 1252 | + #define WYHASH_LITTLE_ENDIAN 1 | |
| 1253 | + #else | |
| 1254 | + #define WYHASH_LITTLE_ENDIAN 0 | |
| 1255 | + #endif | |
| 1256 | +#endif | |
| 1257 | +// read functions | |
| 1258 | +#if (WYHASH_LITTLE_ENDIAN) | |
| 1259 | + static inline uint64_t _wyr8(const uint8_t *p) { uint64_t v; memcpy(&v, p, 8); return v;} | |
| 1260 | + static inline uint64_t _wyr4(const uint8_t *p) { uint32_t v; memcpy(&v, p, 4); return v;} | |
| 1261 | +#elif !defined(__TINYC__) && (defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__clang__)) | |
| 1262 | + static inline uint64_t _wyr8(const uint8_t *p) { uint64_t v; memcpy(&v, p, 8); return __builtin_bswap64(v);} | |
| 1263 | + static inline uint64_t _wyr4(const uint8_t *p) { uint32_t v; memcpy(&v, p, 4); return __builtin_bswap32(v);} | |
| 1264 | +#elif defined(_MSC_VER) | |
| 1265 | + static inline uint64_t _wyr8(const uint8_t *p) { uint64_t v; memcpy(&v, p, 8); return _byteswap_uint64(v);} | |
| 1266 | + static inline uint64_t _wyr4(const uint8_t *p) { uint32_t v; memcpy(&v, p, 4); return _byteswap_ulong(v);} | |
| 1267 | +#else | |
| 1268 | + static inline uint64_t _wyr8(const uint8_t *p) { | |
| 1269 | + uint64_t v; memcpy(&v, p, 8); | |
| 1270 | + return (((v >> 56) & 0xff)| ((v >> 40) & 0xff00)| ((v >> 24) & 0xff0000)| ((v >> 8) & 0xff000000)| ((v << 8) & 0xff00000000)| ((v << 24) & 0xff0000000000)| ((v << 40) & 0xff000000000000)| ((v << 56) & 0xff00000000000000)); | |
| 1271 | + } | |
| 1272 | + static inline uint64_t _wyr4(const uint8_t *p) { | |
| 1273 | + uint32_t v; memcpy(&v, p, 4); | |
| 1274 | + return (((v >> 24) & 0xff)| ((v >> 8) & 0xff00)| ((v << 8) & 0xff0000)| ((v << 24) & 0xff000000)); | |
| 1275 | + } | |
| 1276 | +#endif | |
| 1277 | +static inline uint64_t _wyr3(const uint8_t *p, size_t k) { return (((uint64_t)p[0])<<16)|(((uint64_t)p[k>>1])<<8)|p[k-1];} | |
| 1278 | +// wyhash main function | |
| 1279 | +static inline uint64_t wyhash(const void *key, size_t len, uint64_t seed, const uint64_t *secret){ | |
| 1280 | + const uint8_t *p=(const uint8_t *)key; seed^=_wymix(seed^secret[0]^len,secret[1]); uint64_t a, b; | |
| 1281 | + if (_likely_(len<=16)) { | |
| 1282 | + if (_likely_(len>=4)) { a=(_wyr4(p)<<32)|_wyr4(p+((len>>3)<<2)); b=(_wyr4(p+len-4)<<32)|_wyr4(p+len-4-((len>>3)<<2)); } | |
| 1283 | + else if (_likely_(len>0)) { a=_wyr3(p,len); b=0; } | |
| 1284 | + else a=b=0; | |
| 1285 | + } else { | |
| 1286 | + size_t i=len; | |
| 1287 | + if (_unlikely_(i>=48)) { | |
| 1288 | + uint64_t see1=seed, see2=seed; | |
| 1289 | + do { | |
| 1290 | + seed=_wymix(_wyr8(p)^secret[1],_wyr8(p+8)^seed); | |
| 1291 | + see1=_wymix(_wyr8(p+16)^secret[2],_wyr8(p+24)^see1); | |
| 1292 | + see2=_wymix(_wyr8(p+32)^secret[3],_wyr8(p+40)^see2); | |
| 1293 | + p+=48; i-=48; | |
| 1294 | + } while(_likely_(i>=48)); | |
| 1295 | + seed^=see1^see2; | |
| 1296 | + } | |
| 1297 | + while(_unlikely_(i>16)) { seed=_wymix(_wyr8(p)^secret[1],_wyr8(p+8)^seed); i-=16; p+=16; } | |
| 1298 | + a=_wyr8(p+i-16); b=_wyr8(p+i-8); | |
| 1299 | + } | |
| 1300 | + a^=secret[1]; b^=seed; _wymum(&a,&b); | |
| 1301 | + return _wymix(a^secret[0]^len,b^secret[1]); | |
| 1302 | +} | |
| 1303 | +// the default secret parameters | |
| 1304 | +static const uint64_t _wyp[4] = {0x2d358dccaa6c78a5ull, 0x8bb84b93962eacc9ull, 0x4b33a62ed433d4a3ull, 0x4d5a2da51de1aa47ull}; | |
| 1305 | +// a useful 64bit-64bit mix function to produce deterministic pseudo random numbers that can pass BigCrush and PractRand | |
| 1306 | +static inline uint64_t wyhash64(uint64_t A, uint64_t B){ A^=0x2d358dccaa6c78a5ull; B^=0x8bb84b93962eacc9ull; _wymum(&A,&B); return _wymix(A^0x2d358dccaa6c78a5ull,B^0x8bb84b93962eacc9ull);} | |
| 1307 | +// the wyrand PRNG that pass BigCrush and PractRand | |
| 1308 | +static inline uint64_t wyrand(uint64_t *seed){ *seed+=0x2d358dccaa6c78a5ull; return _wymix(*seed,*seed^0x8bb84b93962eacc9ull);} | |
| 1309 | +#ifndef __vinix__ | |
| 1310 | +// convert any 64 bit pseudo random numbers to uniform distribution [0,1). It can be combined with wyrand, wyhash64 or wyhash. | |
| 1311 | +static inline double wy2u01(uint64_t r){ const double _wynorm=1.0/(1ull<<52); return (r>>12)*_wynorm;} | |
| 1312 | +// convert any 64 bit pseudo random numbers to APPROXIMATE Gaussian distribution. It can be combined with wyrand, wyhash64 or wyhash. | |
| 1313 | +static inline double wy2gau(uint64_t r){ const double _wynorm=1.0/(1ull<<20); return ((r&0x1fffff)+((r>>21)&0x1fffff)+((r>>42)&0x1fffff))*_wynorm-3.0;} | |
| 1314 | +#endif | |
| 1315 | +#if(!WYHASH_32BIT_MUM) | |
| 1316 | +// fast range integer random number generation on [0,k) credit to Daniel Lemire. May not work when WYHASH_32BIT_MUM=1. It can be combined with wyrand, wyhash64 or wyhash. | |
| 1317 | +static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; } | |
| 1318 | +#endif | |
| 1319 | +#endif | |
| 1320 | +#define _IN_MAP(val, m) builtin__map_exists(m, val) | |
| 1321 | + | |
| 1322 | +#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 30 | |
| 1323 | +#include <sys/syscall.h> | |
| 1324 | +#define gettid() syscall(SYS_gettid) | |
| 1325 | +#endif | |
| 1326 | + | |
| 1327 | +// V includes: | |
| 1328 | + | |
| 1329 | +#if defined(__TINYC__) && defined(__has_include) // tcc does not support has_include properly yet, turn it off completely | |
| 1330 | +#undef __has_include | |
| 1331 | +#endif | |
| 1332 | + | |
| 1333 | +#if defined(__TINYC__) && defined(__BIONIC__) | |
| 1334 | + #define __builtin_nanf(ignored_string) (0.0F / 0.0F) | |
| 1335 | + #define __builtin_nan(ignored_string) (0.0 / 0.0) | |
| 1336 | + #define __builtin_nanl(ignored_string) (0.0L / 0.0L) | |
| 1337 | + #define __builtin_inff() (1.0F / 0.0F) | |
| 1338 | + #define __builtin_inf() (1.0 / 0.0) | |
| 1339 | + #define __builtin_infl() (1.0L / 0.0L) | |
| 1340 | + #define __builtin_huge_valf() (1.0F / 0.0F) | |
| 1341 | + #define __builtin_huge_val() (1.0 / 0.0) | |
| 1342 | + #define __builtin_huge_vall() (1.0L / 0.0L) | |
| 1343 | +#endif | |
| 1344 | + | |
| 1345 | +#if 1 | |
| 1346 | + | |
| 1347 | +// added by module `builtin.closure`, file: closure_nix.c.v:4: | |
| 1348 | + | |
| 1349 | +#ifdef __TINYC__ | |
| 1350 | +#include <sys/mman.h> | |
| 1351 | +#else | |
| 1352 | +#if defined(__has_include) | |
| 1353 | +#if __has_include(<sys/mman.h>) | |
| 1354 | +#include <sys/mman.h> | |
| 1355 | +#else | |
| 1356 | +#error VERROR_MESSAGE Header file <sys/mman.h>, needed for module `builtin.closure` was not found. Please install the corresponding development headers. | |
| 1357 | +#endif | |
| 1358 | +#else | |
| 1359 | +#include <sys/mman.h> | |
| 1360 | +#endif | |
| 1361 | +#endif | |
| 1362 | + | |
| 1363 | + | |
| 1364 | +// inserted by module `builtin.closure`, file: closure_nix.c.v:5: | |
| 1365 | +#ifndef V_CLOSURE_ONCE_NIX_H | |
| 1366 | +#define V_CLOSURE_ONCE_NIX_H | |
| 1367 | + | |
| 1368 | +#include <pthread.h> | |
| 1369 | + | |
| 1370 | +typedef void (*v_closure_init_fn)(void); | |
| 1371 | + | |
| 1372 | +#ifndef V_CLOSURE_STATIC_INLINE | |
| 1373 | +# ifdef _MSC_VER | |
| 1374 | +# define V_CLOSURE_STATIC_INLINE static __inline | |
| 1375 | +# else | |
| 1376 | +# define V_CLOSURE_STATIC_INLINE static inline | |
| 1377 | +# endif | |
| 1378 | +#endif | |
| 1379 | + | |
| 1380 | +static pthread_mutex_t v_closure_once_mutex = PTHREAD_MUTEX_INITIALIZER; | |
| 1381 | +static int v_closure_once_done = 0; | |
| 1382 | + | |
| 1383 | +V_CLOSURE_STATIC_INLINE void v_closure_init_once(v_closure_init_fn init_fn) { | |
| 1384 | + pthread_mutex_lock(&v_closure_once_mutex); | |
| 1385 | + if (!v_closure_once_done) { | |
| 1386 | + init_fn(); | |
| 1387 | + v_closure_once_done = 1; | |
| 1388 | + } | |
| 1389 | + pthread_mutex_unlock(&v_closure_once_mutex); | |
| 1390 | +} | |
| 1391 | + | |
| 1392 | +#endif | |
| 1393 | + | |
| 1394 | +#endif | |
| 1395 | + | |
| 1396 | +#if 1 | |
| 1397 | + | |
| 1398 | +// added by module `builtin.closure`, file: closure_nix.c.v:4: | |
| 1399 | + | |
| 1400 | +#ifdef __TINYC__ | |
| 1401 | +#include <sys/mman.h> | |
| 1402 | +#else | |
| 1403 | +#if defined(__has_include) | |
| 1404 | +#if __has_include(<sys/mman.h>) | |
| 1405 | +#include <sys/mman.h> | |
| 1406 | +#else | |
| 1407 | +#error VERROR_MESSAGE Header file <sys/mman.h>, needed for module `builtin.closure` was not found. Please install the corresponding development headers. | |
| 1408 | +#endif | |
| 1409 | +#else | |
| 1410 | +#include <sys/mman.h> | |
| 1411 | +#endif | |
| 1412 | +#endif | |
| 1413 | + | |
| 1414 | + | |
| 1415 | +// inserted by module `builtin.closure`, file: closure_nix.c.v:5: | |
| 1416 | +#ifndef V_CLOSURE_ONCE_NIX_H | |
| 1417 | +#define V_CLOSURE_ONCE_NIX_H | |
| 1418 | + | |
| 1419 | +#include <pthread.h> | |
| 1420 | + | |
| 1421 | +typedef void (*v_closure_init_fn)(void); | |
| 1422 | + | |
| 1423 | +#ifndef V_CLOSURE_STATIC_INLINE | |
| 1424 | +# ifdef _MSC_VER | |
| 1425 | +# define V_CLOSURE_STATIC_INLINE static __inline | |
| 1426 | +# else | |
| 1427 | +# define V_CLOSURE_STATIC_INLINE static inline | |
| 1428 | +# endif | |
| 1429 | +#endif | |
| 1430 | + | |
| 1431 | +static pthread_mutex_t v_closure_once_mutex = PTHREAD_MUTEX_INITIALIZER; | |
| 1432 | +static int v_closure_once_done = 0; | |
| 1433 | + | |
| 1434 | +V_CLOSURE_STATIC_INLINE void v_closure_init_once(v_closure_init_fn init_fn) { | |
| 1435 | + pthread_mutex_lock(&v_closure_once_mutex); | |
| 1436 | + if (!v_closure_once_done) { | |
| 1437 | + init_fn(); | |
| 1438 | + v_closure_once_done = 1; | |
| 1439 | + } | |
| 1440 | + pthread_mutex_unlock(&v_closure_once_mutex); | |
| 1441 | +} | |
| 1442 | + | |
| 1443 | +#endif | |
| 1444 | + | |
| 1445 | +#endif | |
| 1446 | + | |
| 1447 | +// inserted by module `builtin`, file: allocation.c.v:43: | |
| 1448 | +#ifndef V_TRACK_HEAP_CHECKS_H | |
| 1449 | +#define V_TRACK_HEAP_CHECKS_H | |
| 1450 | + | |
| 1451 | +#if defined(CUSTOM_DEFINE_track_heap) && (defined(_VGCBOEHM) || defined(CUSTOM_DEFINE_gcboehm)) | |
| 1452 | +#error "-d track_heap requires manual memory management; rebuild with -gc none" | |
| 1453 | +#endif | |
| 1454 | + | |
| 1455 | +#if defined(CUSTOM_DEFINE_track_heap) && defined(CUSTOM_DEFINE_vgc) | |
| 1456 | +#error "-d track_heap requires manual memory management; rebuild with -gc none" | |
| 1457 | +#endif | |
| 1458 | + | |
| 1459 | +#if defined(CUSTOM_DEFINE_track_heap) && defined(_VPREALLOC) | |
| 1460 | +#error "-d track_heap requires manual memory management; rebuild with -gc none (not -prealloc)" | |
| 1461 | +#endif | |
| 1462 | + | |
| 1463 | +#endif | |
| 1464 | + | |
| 1465 | + | |
| 1466 | +// added by module `builtin`, file: float.c.v:9: | |
| 1467 | + | |
| 1468 | +#ifdef __TINYC__ | |
| 1469 | +#include <float.h> | |
| 1470 | +#else | |
| 1471 | +#if defined(__has_include) | |
| 1472 | +#if __has_include(<float.h>) | |
| 1473 | +#include <float.h> | |
| 1474 | +#else | |
| 1475 | +#error VERROR_MESSAGE Header file <float.h>, needed for module `builtin` was not found. Please install the corresponding development headers. | |
| 1476 | +#endif | |
| 1477 | +#else | |
| 1478 | +#include <float.h> | |
| 1479 | +#endif | |
| 1480 | +#endif | |
| 1481 | + | |
| 1482 | +#if !defined(__cplusplus) && !defined(CUSTOM_DEFINE_no_bool) | |
| 1483 | +#ifdef bool | |
| 1484 | +#undef bool | |
| 1485 | +#endif | |
| 1486 | +#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 202311L | |
| 1487 | +#ifdef CUSTOM_DEFINE_4bytebool | |
| 1488 | +typedef int bool; | |
| 1489 | +#else | |
| 1490 | +typedef u8 bool; | |
| 1491 | +#endif | |
| 1492 | +#endif | |
| 1493 | +#endif | |
| 1494 | + | |
| 1495 | +// V global/const #define ... : | |
| 1496 | +#define _const_builtin__closure__assumed_page_size 16384 | |
| 1497 | +#define _const_strconv__digits 18 | |
| 1498 | +#define _const_strconv__c_dpoint '.' | |
| 1499 | +#define _const_strconv__c_plus '+' | |
| 1500 | +#define _const_strconv__c_minus '-' | |
| 1501 | +#define _const_strconv__c_zero '0' | |
| 1502 | +#define _const_strconv__c_nine '9' | |
| 1503 | +#define _const_strconv__int_size 32 | |
| 1504 | +#define _const_strconv__max_size_f64_char 512 | |
| 1505 | +#define _const_autostr_type_stack_max_depth 64 | |
| 1506 | +#define _const_min_int -2147483648 | |
| 1507 | +#define _const_max_int 2147483647 | |
| 1508 | +#define _const_hashbits 24 | |
| 1509 | +#define _const_max_cached_hashbits 16 | |
| 1510 | +#define _const_init_log_capicity 5 | |
| 1511 | +#define _const_init_capicity 32 | |
| 1512 | +#define _const_init_even_index 30 | |
| 1513 | +#define _const_extra_metas_inc 4 | |
| 1514 | +#define _const_rune_maps_columns_in_row 4 | |
| 1515 | +#define _const_rune_maps_ul -3 | |
| 1516 | +#define _const_rune_maps_utl -2 | |
| 1517 | +#define _const_degree 6 | |
| 1518 | +#define _const_mid_index 5 | |
| 1519 | +#define _const_max_len 11 | |
| 1520 | +#define _const_replace_stack_buffer_size 10 | |
| 1521 | +#define _const_kmp_stack_buffer_size 20 | |
| 1522 | + | |
| 1523 | +// Enum definitions: | |
| 1524 | + | |
| 1525 | +typedef enum { | |
| 1526 | + strings__IndentState__normal, // | |
| 1527 | + strings__IndentState__in_string, // +1 | |
| 1528 | +} strings__IndentState; | |
| 1529 | + | |
| 1530 | +typedef enum { | |
| 1531 | + builtin__closure__MemoryProtectAtrr__read_exec, // | |
| 1532 | + builtin__closure__MemoryProtectAtrr__read_write, // +1 | |
| 1533 | +} builtin__closure__MemoryProtectAtrr; | |
| 1534 | + | |
| 1535 | +typedef enum { | |
| 1536 | + strconv__ParserState__ok, // | |
| 1537 | + strconv__ParserState__pzero, // +1 | |
| 1538 | + strconv__ParserState__mzero, // +2 | |
| 1539 | + strconv__ParserState__pinf, // +3 | |
| 1540 | + strconv__ParserState__minf, // +4 | |
| 1541 | + strconv__ParserState__invalid_number, // +5 | |
| 1542 | + strconv__ParserState__extra_char, // +6 | |
| 1543 | +} strconv__ParserState; | |
| 1544 | + | |
| 1545 | +typedef enum { | |
| 1546 | + strconv__Align_text__right = 0, // 0 | |
| 1547 | + strconv__Align_text__left, // 0+1 | |
| 1548 | + strconv__Align_text__center, // 0+2 | |
| 1549 | +} strconv__Align_text; | |
| 1550 | + | |
| 1551 | +typedef enum { | |
| 1552 | + strconv__Char_parse_state__start, // | |
| 1553 | + strconv__Char_parse_state__norm_char, // +1 | |
| 1554 | + strconv__Char_parse_state__field_char, // +2 | |
| 1555 | + strconv__Char_parse_state__pad_ch, // +3 | |
| 1556 | + strconv__Char_parse_state__len_set_start, // +4 | |
| 1557 | + strconv__Char_parse_state__len_set_in, // +5 | |
| 1558 | + strconv__Char_parse_state__check_type, // +6 | |
| 1559 | + strconv__Char_parse_state__check_float, // +7 | |
| 1560 | + strconv__Char_parse_state__check_float_in, // +8 | |
| 1561 | + strconv__Char_parse_state__reset_params, // +9 | |
| 1562 | +} strconv__Char_parse_state; | |
| 1563 | + | |
| 1564 | +typedef enum { | |
| 1565 | + ArrayFlags__noslices = 1U, // u64(1) << 0 | |
| 1566 | + ArrayFlags__noshrink = 2U, // u64(1) << 1 | |
| 1567 | + ArrayFlags__nogrow = 4U, // u64(1) << 2 | |
| 1568 | + ArrayFlags__nofree = 8U, // u64(1) << 3 | |
| 1569 | + ArrayFlags__managed = 16U, // u64(1) << 4 | |
| 1570 | + ArrayFlags__noscan_data = 32U, // u64(1) << 5 | |
| 1571 | + ArrayFlags__is_slice = 64U, // u64(1) << 6 | |
| 1572 | +} ArrayFlags; | |
| 1573 | + | |
| 1574 | +typedef enum { | |
| 1575 | + ChanState__success, // | |
| 1576 | + ChanState__not_ready, // +1 | |
| 1577 | + ChanState__closed, // +2 | |
| 1578 | +} ChanState; | |
| 1579 | + | |
| 1580 | +typedef enum { | |
| 1581 | + GraphemeBreakProperty__other, // | |
| 1582 | + GraphemeBreakProperty__cr, // +1 | |
| 1583 | + GraphemeBreakProperty__lf, // +2 | |
| 1584 | + GraphemeBreakProperty__control, // +3 | |
| 1585 | + GraphemeBreakProperty__extend, // +4 | |
| 1586 | + GraphemeBreakProperty__regional_indicator, // +5 | |
| 1587 | + GraphemeBreakProperty__prepend, // +6 | |
| 1588 | + GraphemeBreakProperty__spacing_mark, // +7 | |
| 1589 | + GraphemeBreakProperty__l, // +8 | |
| 1590 | + GraphemeBreakProperty__v, // +9 | |
| 1591 | + GraphemeBreakProperty__t, // +10 | |
| 1592 | + GraphemeBreakProperty__lv, // +11 | |
| 1593 | + GraphemeBreakProperty__lvt, // +12 | |
| 1594 | + GraphemeBreakProperty__zwj, // +13 | |
| 1595 | +} GraphemeBreakProperty; | |
| 1596 | + | |
| 1597 | +typedef enum { | |
| 1598 | + AttributeKind__plain, // | |
| 1599 | + AttributeKind__string, // +1 | |
| 1600 | + AttributeKind__number, // +2 | |
| 1601 | + AttributeKind__bool, // +3 | |
| 1602 | + AttributeKind__comptime_define, // +4 | |
| 1603 | +} AttributeKind; | |
| 1604 | + | |
| 1605 | +typedef enum { | |
| 1606 | + MapMode__to_upper, // | |
| 1607 | + MapMode__to_lower, // +1 | |
| 1608 | + MapMode__to_title, // +2 | |
| 1609 | +} MapMode; | |
| 1610 | + | |
| 1611 | +typedef enum { | |
| 1612 | + TrimMode__trim_left, // | |
| 1613 | + TrimMode__trim_right, // +1 | |
| 1614 | + TrimMode__trim_both, // +2 | |
| 1615 | +} TrimMode; | |
| 1616 | + | |
| 1617 | +typedef enum { | |
| 1618 | + StrIntpType__si_no_str = 0, // 0 | |
| 1619 | + StrIntpType__si_c, // 0+1 | |
| 1620 | + StrIntpType__si_u8, // 0+2 | |
| 1621 | + StrIntpType__si_i8, // 0+3 | |
| 1622 | + StrIntpType__si_u16, // 0+4 | |
| 1623 | + StrIntpType__si_i16, // 0+5 | |
| 1624 | + StrIntpType__si_u32, // 0+6 | |
| 1625 | + StrIntpType__si_i32, // 0+7 | |
| 1626 | + StrIntpType__si_u64, // 0+8 | |
| 1627 | + StrIntpType__si_i64, // 0+9 | |
| 1628 | + StrIntpType__si_e32, // 0+10 | |
| 1629 | + StrIntpType__si_e64, // 0+11 | |
| 1630 | + StrIntpType__si_f32, // 0+12 | |
| 1631 | + StrIntpType__si_f64, // 0+13 | |
| 1632 | + StrIntpType__si_g32, // 0+14 | |
| 1633 | + StrIntpType__si_g64, // 0+15 | |
| 1634 | + StrIntpType__si_s, // 0+16 | |
| 1635 | + StrIntpType__si_p, // 0+17 | |
| 1636 | + StrIntpType__si_r, // 0+18 | |
| 1637 | + StrIntpType__si_vp, // 0+19 | |
| 1638 | +} StrIntpType; | |
| 1639 | + | |
| 1640 | +// V type definitions: | |
| 1641 | +struct IError { | |
| 1642 | + union { | |
| 1643 | + void* _object; | |
| 1644 | + None__* _None__; | |
| 1645 | + voidptr* _voidptr; | |
| 1646 | + MessageError* _MessageError; | |
| 1647 | + Error* _Error; | |
| 1648 | + }; | |
| 1649 | + u32 _typ; | |
| 1650 | + void* _methods; | |
| 1651 | +}; | |
| 1652 | + | |
| 1653 | +struct string { | |
| 1654 | + u8* str; | |
| 1655 | + int len; | |
| 1656 | + int is_lit; | |
| 1657 | +}; | |
| 1658 | + | |
| 1659 | +struct array { | |
| 1660 | + voidptr data; | |
| 1661 | + int offset; | |
| 1662 | + int len; | |
| 1663 | + int cap; | |
| 1664 | + ArrayFlags flags; | |
| 1665 | + int element_size; | |
| 1666 | +}; | |
| 1667 | + | |
| 1668 | +struct DenseArray { | |
| 1669 | + int key_bytes; | |
| 1670 | + int value_bytes; | |
| 1671 | + int cap; | |
| 1672 | + int len; | |
| 1673 | + u32 deletes; | |
| 1674 | + u8* all_deleted; | |
| 1675 | + u8* keys; | |
| 1676 | + u8* values; | |
| 1677 | +}; | |
| 1678 | + | |
| 1679 | +struct map { | |
| 1680 | + int key_bytes; | |
| 1681 | + int value_bytes; | |
| 1682 | + u32 even_index; | |
| 1683 | + u8 cached_hashbits; | |
| 1684 | + u8 shift; | |
| 1685 | + DenseArray key_values; | |
| 1686 | + u32* metas; | |
| 1687 | + u32 extra_metas; | |
| 1688 | + bool has_string_keys; | |
| 1689 | + MapHashFn hash_fn; | |
| 1690 | + MapEqFn key_eq_fn; | |
| 1691 | + MapCloneFn clone_fn; | |
| 1692 | + MapFreeFn free_fn; | |
| 1693 | + int len; | |
| 1694 | +}; | |
| 1695 | + | |
| 1696 | +struct Error { | |
| 1697 | + E_STRUCT_DECL; | |
| 1698 | +}; | |
| 1699 | + | |
| 1700 | +struct _option { | |
| 1701 | + u8 state; | |
| 1702 | + IError err; | |
| 1703 | +}; | |
| 1704 | + | |
| 1705 | +struct _result { | |
| 1706 | + bool is_error; | |
| 1707 | + IError err; | |
| 1708 | +}; | |
| 1709 | +typedef array Array_string; | |
| 1710 | +typedef array Array_u8; | |
| 1711 | +typedef array Array_voidptr; | |
| 1712 | +typedef array Array_int; | |
| 1713 | +typedef array Array_IError; | |
| 1714 | +typedef array Array_rune; | |
| 1715 | +typedef string Array_fixed_string_11 [11]; | |
| 1716 | +typedef voidptr Array_fixed_voidptr_11 [11]; | |
| 1717 | +typedef array Array_RepIndex; | |
| 1718 | +typedef map Map_string_int; | |
| 1719 | +typedef array Array_bool; | |
| 1720 | +typedef array Array_builtin__closure__ClosureLifetimeRecord; | |
| 1721 | +typedef array Array_builtin__closure__ClosureLifetimeFrame; | |
| 1722 | +typedef map Map_voidptr_builtin__closure__ClosureLiveInfo; | |
| 1723 | +typedef map Map_u64_builtin__closure__ClosureLifetimeState_ptr; | |
| 1724 | +typedef u8 Array_fixed_u8_128 [128]; | |
| 1725 | +typedef u8 Array_fixed_u8_32 [32]; | |
| 1726 | +typedef u8 Array_fixed_u8_64 [64]; | |
| 1727 | +typedef u8 Array_fixed_u8_5 [5]; | |
| 1728 | +typedef u8 Array_fixed_u8_20 [20]; | |
| 1729 | +typedef u8 Array_fixed_u8_15 [15]; | |
| 1730 | +typedef u8 Array_fixed_u8_6 [6]; | |
| 1731 | +typedef u8 Array_fixed_u8_256 [256]; | |
| 1732 | +typedef u64 Array_fixed_u64_309 [309]; | |
| 1733 | +typedef u64 Array_fixed_u64_324 [324]; | |
| 1734 | +typedef u32 Array_fixed_u32_10 [10]; | |
| 1735 | +typedef u64 Array_fixed_u64_20 [20]; | |
| 1736 | +typedef u64 Array_fixed_u64_584 [584]; | |
| 1737 | +typedef u64 Array_fixed_u64_652 [652]; | |
| 1738 | +typedef f64 Array_fixed_f64_36 [36]; | |
| 1739 | +typedef u8 Array_fixed_u8_26 [26]; | |
| 1740 | +typedef u8 Array_fixed_u8_512 [512]; | |
| 1741 | +typedef u64 Array_fixed_u64_47 [47]; | |
| 1742 | +typedef u64 Array_fixed_u64_31 [31]; | |
| 1743 | +typedef int Array_fixed_int_64 [64]; | |
| 1744 | +typedef voidptr Array_fixed_voidptr_64 [64]; | |
| 1745 | +typedef voidptr Array_fixed_voidptr_100 [100]; | |
| 1746 | +typedef u8 Array_fixed_u8_1000 [1000]; | |
| 1747 | +typedef array Array_GraphemeBreakProperty; | |
| 1748 | +typedef u8 Array_fixed_u8_17 [17]; | |
| 1749 | +typedef i32 Array_fixed_i32_1264 [1264]; | |
| 1750 | +typedef int Array_fixed_int_10 [10]; | |
| 1751 | +typedef int Array_fixed_int_20 [20]; | |
| 1752 | +typedef array Array_StrIntpType; | |
| 1753 | +typedef Array_u8 strings__Builder; | |
| 1754 | +typedef bool (*anon_fn_voidptr__bool)(voidptr); | |
| 1755 | +typedef voidptr (*anon_fn_voidptr__voidptr)(voidptr); | |
| 1756 | +typedef int (*anon_fn_voidptr_voidptr__int)(voidptr,voidptr); | |
| 1757 | +typedef int (*FnSortCB)(const void*,const void*); | |
| 1758 | +typedef void (*FnExitCb)(); | |
| 1759 | +typedef void (*FnGC_WarnCB)(char*,usize); | |
| 1760 | +typedef voidptr (*builtin__closure__ClosureGetDataFn)(); | |
| 1761 | +typedef void (*builtin__closure__ClosureInitFn)(); | |
| 1762 | +typedef void (*anon_fn_)(); | |
| 1763 | +// #start sorted_symbols | |
| 1764 | +struct none { | |
| 1765 | + E_STRUCT_DECL; | |
| 1766 | +}; | |
| 1767 | + | |
| 1768 | +struct None__ { | |
| 1769 | + Error Error; | |
| 1770 | +}; | |
| 1771 | + | |
| 1772 | +struct InputRuneIterator { | |
| 1773 | + E_STRUCT_DECL; | |
| 1774 | +}; | |
| 1775 | + | |
| 1776 | +struct GCHeapUsage { | |
| 1777 | + usize heap_size; | |
| 1778 | + usize free_bytes; | |
| 1779 | + usize total_bytes; | |
| 1780 | + usize unmapped_bytes; | |
| 1781 | + usize bytes_since_gc; | |
| 1782 | +}; | |
| 1783 | + | |
| 1784 | +struct ArrayDataHeader { | |
| 1785 | + bool has_slices; | |
| 1786 | +}; | |
| 1787 | + | |
| 1788 | +struct MessageError { | |
| 1789 | + string msg; | |
| 1790 | + int code; | |
| 1791 | +}; | |
| 1792 | + | |
| 1793 | +union strconv__Float64u { | |
| 1794 | + f64 f; | |
| 1795 | + u64 u; | |
| 1796 | +}; | |
| 1797 | + | |
| 1798 | +union strconv__Float32u { | |
| 1799 | + f32 f; | |
| 1800 | + u32 u; | |
| 1801 | +}; | |
| 1802 | + | |
| 1803 | +struct GraphemeState { | |
| 1804 | + GraphemeBreakProperty prev_prop; | |
| 1805 | + int ri_count; | |
| 1806 | + u8 extended_pictographic_state; | |
| 1807 | +}; | |
| 1808 | + | |
| 1809 | +struct VAssertMetaInfo { | |
| 1810 | + string fpath; | |
| 1811 | + int line_nr; | |
| 1812 | + string fn_name; | |
| 1813 | + string src; | |
| 1814 | + string op; | |
| 1815 | + string llabel; | |
| 1816 | + string rlabel; | |
| 1817 | + string lvalue; | |
| 1818 | + string rvalue; | |
| 1819 | + string message; | |
| 1820 | + bool has_msg; | |
| 1821 | +}; | |
| 1822 | + | |
| 1823 | +struct SortedMap { | |
| 1824 | + int value_bytes; | |
| 1825 | + mapnode* root; | |
| 1826 | + int len; | |
| 1827 | +}; | |
| 1828 | + | |
| 1829 | +struct RepIndex { | |
| 1830 | + int idx; | |
| 1831 | + int val_idx; | |
| 1832 | +}; | |
| 1833 | + | |
| 1834 | +struct WrapConfig { | |
| 1835 | + int width; | |
| 1836 | + string end; | |
| 1837 | +}; | |
| 1838 | + | |
| 1839 | +struct RunesIterator { | |
| 1840 | + string s; | |
| 1841 | + int i; | |
| 1842 | +}; | |
| 1843 | + | |
| 1844 | +union StrIntpMem { | |
| 1845 | + u32 d_c; | |
| 1846 | + u8 d_u8; | |
| 1847 | + i8 d_i8; | |
| 1848 | + u16 d_u16; | |
| 1849 | + i16 d_i16; | |
| 1850 | + u32 d_u32; | |
| 1851 | + i32 d_i32; | |
| 1852 | + u64 d_u64; | |
| 1853 | + i64 d_i64; | |
| 1854 | + f32 d_f32; | |
| 1855 | + f64 d_f64; | |
| 1856 | + string d_s; | |
| 1857 | + string d_r; | |
| 1858 | + voidptr d_p; | |
| 1859 | + voidptr d_vp; | |
| 1860 | +}; | |
| 1861 | + | |
| 1862 | +struct strconv__BF_param { | |
| 1863 | + u8 pad_ch; | |
| 1864 | + int len0; | |
| 1865 | + int len1; | |
| 1866 | + bool positive; | |
| 1867 | + bool sign_flag; | |
| 1868 | + strconv__Align_text align; | |
| 1869 | + bool rm_tail_zero; | |
| 1870 | +}; | |
| 1871 | + | |
| 1872 | +struct ToWideConfig { | |
| 1873 | + bool from_ansi; | |
| 1874 | +}; | |
| 1875 | + | |
| 1876 | +struct strings__IndentParam { | |
| 1877 | + rune block_start; | |
| 1878 | + rune block_end; | |
| 1879 | + rune indent_char; | |
| 1880 | + int indent_count; | |
| 1881 | + int starting_level; | |
| 1882 | +}; | |
| 1883 | + | |
| 1884 | +struct strconv__PrepNumber { | |
| 1885 | + bool negative; | |
| 1886 | + int exponent; | |
| 1887 | + u64 mantissa; | |
| 1888 | +}; | |
| 1889 | + | |
| 1890 | +struct strconv__AtoF64Param { | |
| 1891 | + bool allow_extra_chars; | |
| 1892 | +}; | |
| 1893 | + | |
| 1894 | +struct strconv__Dec32 { | |
| 1895 | + u32 m; | |
| 1896 | + int e; | |
| 1897 | +}; | |
| 1898 | + | |
| 1899 | +union strconv__Uf32 { | |
| 1900 | + f32 f; | |
| 1901 | + u32 u; | |
| 1902 | +}; | |
| 1903 | + | |
| 1904 | +struct strconv__Dec64 { | |
| 1905 | + u64 m; | |
| 1906 | + int e; | |
| 1907 | +}; | |
| 1908 | + | |
| 1909 | +struct strconv__Uint128 { | |
| 1910 | + u64 lo; | |
| 1911 | + u64 hi; | |
| 1912 | +}; | |
| 1913 | + | |
| 1914 | +union strconv__Uf64 { | |
| 1915 | + f64 f; | |
| 1916 | + u64 u; | |
| 1917 | +}; | |
| 1918 | + | |
| 1919 | +struct builtin__closure__ClosurePage { | |
| 1920 | + builtin__closure__ClosurePage* next; | |
| 1921 | + voidptr exec_page_start; | |
| 1922 | +}; | |
| 1923 | + | |
| 1924 | +struct builtin__closure__ClosureLiveInfo { | |
| 1925 | + voidptr ctx; | |
| 1926 | + bool owns_data; | |
| 1927 | + u64 generation; | |
| 1928 | +}; | |
| 1929 | + | |
| 1930 | +struct builtin__closure__ClosureLifetimeRecord { | |
| 1931 | + voidptr exec_ptr; | |
| 1932 | + u64 generation; | |
| 1933 | +}; | |
| 1934 | + | |
| 1935 | +struct builtin__closure__ClosureLifetimeFrame { | |
| 1936 | + int start; | |
| 1937 | + int end; | |
| 1938 | +}; | |
| 1939 | + | |
| 1940 | +struct builtin__closure__ClosureLifetimeState { | |
| 1941 | + u64 owner_thread; | |
| 1942 | + bool active; | |
| 1943 | + bool disposed; | |
| 1944 | + int suspended; | |
| 1945 | + int frame_start; | |
| 1946 | + u64 frame_gen; | |
| 1947 | + u64 generation; | |
| 1948 | + u64 frame_generation; | |
| 1949 | + Array_builtin__closure__ClosureLifetimeRecord records; | |
| 1950 | + Array_builtin__closure__ClosureLifetimeFrame frames; | |
| 1951 | + builtin__closure__ClosureLifetimeState* next_free; | |
| 1952 | +}; | |
| 1953 | + | |
| 1954 | +struct builtin__closure__Lifetime { | |
| 1955 | + builtin__closure__ClosureLifetimeState* state; | |
| 1956 | + u64 generation; | |
| 1957 | + bool disposed; | |
| 1958 | +}; | |
| 1959 | + | |
| 1960 | +struct builtin__closure__FrameToken { | |
| 1961 | + builtin__closure__ClosureLifetimeState* state; | |
| 1962 | + u64 thread_id; | |
| 1963 | + u64 state_generation; | |
| 1964 | + u64 generation; | |
| 1965 | +}; | |
| 1966 | + | |
| 1967 | +struct mapnode { | |
| 1968 | + voidptr* children; | |
| 1969 | + int len; | |
| 1970 | + Array_fixed_string_11 keys; | |
| 1971 | + Array_fixed_voidptr_11 values; | |
| 1972 | +}; | |
| 1973 | + | |
| 1974 | +struct StrIntpData { | |
| 1975 | + string str; | |
| 1976 | + u32 fmt; | |
| 1977 | + StrIntpMem d; | |
| 1978 | + int dyn_width; | |
| 1979 | + int dyn_precision; | |
| 1980 | + u8 dyn_flags; | |
| 1981 | +}; | |
| 1982 | + | |
| 1983 | +struct builtin__closure__ClosureMutex { | |
| 1984 | + Array_fixed_u8_128 closure_mtx; | |
| 1985 | +}; | |
| 1986 | + | |
| 1987 | +struct builtin__closure__Closure { | |
| 1988 | + builtin__closure__ClosureMutex ClosureMutex; | |
| 1989 | + voidptr closure_ptr; | |
| 1990 | + builtin__closure__ClosureGetDataFn closure_get_data; | |
| 1991 | + int closure_cap; | |
| 1992 | + voidptr free_closure_ptr; | |
| 1993 | + builtin__closure__ClosurePage* pages; | |
| 1994 | + int v_page_size; | |
| 1995 | + Map_voidptr_builtin__closure__ClosureLiveInfo live; | |
| 1996 | + Map_u64_builtin__closure__ClosureLifetimeState_ptr active_lifetimes; | |
| 1997 | + u64 next_generation; | |
| 1998 | + builtin__closure__ClosureLifetimeState* free_lifetime_states; | |
| 1999 | + u64 next_lifetime_generation; | |
| 2000 | + u64 lifetime_state_allocs; | |
| 2001 | +}; | |
| 2002 | +// #end sorted_symbols | |
| 2003 | + | |
| 2004 | +// BEGIN_array_fixed_return_structs | |
| 2005 | +struct _v_Array_fixed_string_11 { | |
| 2006 | + string ret_arr[11]; | |
| 2007 | +}; | |
| 2008 | +struct _v_Array_fixed_voidptr_11 { | |
| 2009 | + voidptr ret_arr[11]; | |
| 2010 | +}; | |
| 2011 | +struct _v_Array_fixed_u8_128 { | |
| 2012 | + u8 ret_arr[128]; | |
| 2013 | +}; | |
| 2014 | +struct _v_Array_fixed_u8_32 { | |
| 2015 | + u8 ret_arr[32]; | |
| 2016 | +}; | |
| 2017 | +struct _v_Array_fixed_u8_64 { | |
| 2018 | + u8 ret_arr[64]; | |
| 2019 | +}; | |
| 2020 | +struct _v_Array_fixed_u8_5 { | |
| 2021 | + u8 ret_arr[5]; | |
| 2022 | +}; | |
| 2023 | +struct _v_Array_fixed_u8_20 { | |
| 2024 | + u8 ret_arr[20]; | |
| 2025 | +}; | |
| 2026 | +struct _v_Array_fixed_u8_15 { | |
| 2027 | + u8 ret_arr[15]; | |
| 2028 | +}; | |
| 2029 | +struct _v_Array_fixed_u8_6 { | |
| 2030 | + u8 ret_arr[6]; | |
| 2031 | +}; | |
| 2032 | +struct _v_Array_fixed_u8_256 { | |
| 2033 | + u8 ret_arr[256]; | |
| 2034 | +}; | |
| 2035 | +struct _v_Array_fixed_u64_309 { | |
| 2036 | + u64 ret_arr[309]; | |
| 2037 | +}; | |
| 2038 | +struct _v_Array_fixed_u64_324 { | |
| 2039 | + u64 ret_arr[324]; | |
| 2040 | +}; | |
| 2041 | +struct _v_Array_fixed_u32_10 { | |
| 2042 | + u32 ret_arr[10]; | |
| 2043 | +}; | |
| 2044 | +struct _v_Array_fixed_u64_20 { | |
| 2045 | + u64 ret_arr[20]; | |
| 2046 | +}; | |
| 2047 | +struct _v_Array_fixed_u64_584 { | |
| 2048 | + u64 ret_arr[584]; | |
| 2049 | +}; | |
| 2050 | +struct _v_Array_fixed_u64_652 { | |
| 2051 | + u64 ret_arr[652]; | |
| 2052 | +}; | |
| 2053 | +struct _v_Array_fixed_f64_36 { | |
| 2054 | + f64 ret_arr[36]; | |
| 2055 | +}; | |
| 2056 | +struct _v_Array_fixed_u8_26 { | |
| 2057 | + u8 ret_arr[26]; | |
| 2058 | +}; | |
| 2059 | +struct _v_Array_fixed_u8_512 { | |
| 2060 | + u8 ret_arr[512]; | |
| 2061 | +}; | |
| 2062 | +struct _v_Array_fixed_u64_47 { | |
| 2063 | + u64 ret_arr[47]; | |
| 2064 | +}; | |
| 2065 | +struct _v_Array_fixed_u64_31 { | |
| 2066 | + u64 ret_arr[31]; | |
| 2067 | +}; | |
| 2068 | +struct _v_Array_fixed_int_64 { | |
| 2069 | + int ret_arr[64]; | |
| 2070 | +}; | |
| 2071 | +struct _v_Array_fixed_voidptr_64 { | |
| 2072 | + voidptr ret_arr[64]; | |
| 2073 | +}; | |
| 2074 | +struct _v_Array_fixed_voidptr_100 { | |
| 2075 | + voidptr ret_arr[100]; | |
| 2076 | +}; | |
| 2077 | +struct _v_Array_fixed_u8_1000 { | |
| 2078 | + u8 ret_arr[1000]; | |
| 2079 | +}; | |
| 2080 | +struct _v_Array_fixed_u8_17 { | |
| 2081 | + u8 ret_arr[17]; | |
| 2082 | +}; | |
| 2083 | +struct _v_Array_fixed_i32_1264 { | |
| 2084 | + i32 ret_arr[1264]; | |
| 2085 | +}; | |
| 2086 | +struct _v_Array_fixed_int_10 { | |
| 2087 | + int ret_arr[10]; | |
| 2088 | +}; | |
| 2089 | +struct _v_Array_fixed_int_20 { | |
| 2090 | + int ret_arr[20]; | |
| 2091 | +}; | |
| 2092 | +// END_array_fixed_return_structs | |
| 2093 | + | |
| 2094 | + | |
| 2095 | +// BEGIN_multi_return_structs | |
| 2096 | +struct multi_return_u32_u32 { | |
| 2097 | + u32 arg0; | |
| 2098 | + u32 arg1; | |
| 2099 | +}; | |
| 2100 | + | |
| 2101 | +struct multi_return_string_string { | |
| 2102 | + string arg0; | |
| 2103 | + string arg1; | |
| 2104 | +}; | |
| 2105 | + | |
| 2106 | +struct multi_return_int_int { | |
| 2107 | + int arg0; | |
| 2108 | + int arg1; | |
| 2109 | +}; | |
| 2110 | + | |
| 2111 | +struct multi_return_rune_int { | |
| 2112 | + rune arg0; | |
| 2113 | + int arg1; | |
| 2114 | +}; | |
| 2115 | + | |
| 2116 | +struct multi_return_u32_u32_u32 { | |
| 2117 | + u32 arg0; | |
| 2118 | + u32 arg1; | |
| 2119 | + u32 arg2; | |
| 2120 | +}; | |
| 2121 | + | |
| 2122 | +struct multi_return_strconv__ParserState_strconv__PrepNumber { | |
| 2123 | + strconv__ParserState arg0; | |
| 2124 | + strconv__PrepNumber arg1; | |
| 2125 | +}; | |
| 2126 | + | |
| 2127 | +struct multi_return_u64_int { | |
| 2128 | + u64 arg0; | |
| 2129 | + int arg1; | |
| 2130 | +}; | |
| 2131 | + | |
| 2132 | +struct multi_return_i64_int { | |
| 2133 | + i64 arg0; | |
| 2134 | + int arg1; | |
| 2135 | +}; | |
| 2136 | + | |
| 2137 | +struct multi_return_strconv__Dec32_bool { | |
| 2138 | + strconv__Dec32 arg0; | |
| 2139 | + bool arg1; | |
| 2140 | +}; | |
| 2141 | + | |
| 2142 | +struct multi_return_strconv__Dec64_bool { | |
| 2143 | + strconv__Dec64 arg0; | |
| 2144 | + bool arg1; | |
| 2145 | +}; | |
| 2146 | + | |
| 2147 | +struct multi_return_u64_u64 { | |
| 2148 | + u64 arg0; | |
| 2149 | + u64 arg1; | |
| 2150 | +}; | |
| 2151 | + | |
| 2152 | +struct multi_return_f64_int { | |
| 2153 | + f64 arg0; | |
| 2154 | + int arg1; | |
| 2155 | +}; | |
| 2156 | + | |
| 2157 | +// END_multi_return_structs | |
| 2158 | + | |
| 2159 | +static bool Array_u8_contains(Array_u8 a, u8 v); | |
| 2160 | + | |
| 2161 | +// V Option_xxx definitions: | |
| 2162 | +struct _option_builtin__closure__ClosureLiveInfo { | |
| 2163 | + byte state; | |
| 2164 | + IError err; | |
| 2165 | + byte data[sizeof(builtin__closure__ClosureLiveInfo) > 1 ? sizeof(builtin__closure__ClosureLiveInfo) : 1]; | |
| 2166 | +}; | |
| 2167 | + | |
| 2168 | +struct _option_builtin__closure__ClosureLifetimeState_ptr { | |
| 2169 | + byte state; | |
| 2170 | + IError err; | |
| 2171 | + byte data[sizeof(builtin__closure__ClosureLifetimeState*) > 1 ? sizeof(builtin__closure__ClosureLifetimeState*) : 1]; | |
| 2172 | +}; | |
| 2173 | + | |
| 2174 | +struct _option_int { | |
| 2175 | + byte state; | |
| 2176 | + IError err; | |
| 2177 | + byte data[sizeof(int) > 1 ? sizeof(int) : 1]; | |
| 2178 | +}; | |
| 2179 | + | |
| 2180 | +struct _option_rune { | |
| 2181 | + byte state; | |
| 2182 | + IError err; | |
| 2183 | + byte data[sizeof(rune) > 1 ? sizeof(rune) : 1]; | |
| 2184 | +}; | |
| 2185 | + | |
| 2186 | +struct _option_multi_return_string_string { | |
| 2187 | + byte state; | |
| 2188 | + IError err; | |
| 2189 | + byte data[sizeof(multi_return_string_string) > 1 ? sizeof(multi_return_string_string) : 1]; | |
| 2190 | +}; | |
| 2191 | + | |
| 2192 | +struct _option_u8 { | |
| 2193 | + byte state; | |
| 2194 | + IError err; | |
| 2195 | + byte data[sizeof(u8) > 1 ? sizeof(u8) : 1]; | |
| 2196 | +}; | |
| 2197 | + | |
| 2198 | + | |
| 2199 | +// V result_xxx definitions: | |
| 2200 | +struct _result_int { | |
| 2201 | + bool is_error; | |
| 2202 | + IError err; | |
| 2203 | + byte data[sizeof(int) > 1 ? sizeof(int) : 1]; | |
| 2204 | +}; | |
| 2205 | + | |
| 2206 | +struct _result_builtin__closure__ClosureLifetimeState_ptr { | |
| 2207 | + bool is_error; | |
| 2208 | + IError err; | |
| 2209 | + byte data[sizeof(builtin__closure__ClosureLifetimeState*) > 1 ? sizeof(builtin__closure__ClosureLifetimeState*) : 1]; | |
| 2210 | +}; | |
| 2211 | + | |
| 2212 | +struct _result_builtin__closure__FrameToken { | |
| 2213 | + bool is_error; | |
| 2214 | + IError err; | |
| 2215 | + byte data[sizeof(builtin__closure__FrameToken) > 1 ? sizeof(builtin__closure__FrameToken) : 1]; | |
| 2216 | +}; | |
| 2217 | + | |
| 2218 | +struct _result_void { | |
| 2219 | + bool is_error; | |
| 2220 | + IError err; | |
| 2221 | + byte data[sizeof(u8) > 1 ? sizeof(u8) : 1]; | |
| 2222 | +}; | |
| 2223 | + | |
| 2224 | +struct _result_f64 { | |
| 2225 | + bool is_error; | |
| 2226 | + IError err; | |
| 2227 | + byte data[sizeof(f64) > 1 ? sizeof(f64) : 1]; | |
| 2228 | +}; | |
| 2229 | + | |
| 2230 | +struct _result_u64 { | |
| 2231 | + bool is_error; | |
| 2232 | + IError err; | |
| 2233 | + byte data[sizeof(u64) > 1 ? sizeof(u64) : 1]; | |
| 2234 | +}; | |
| 2235 | + | |
| 2236 | +struct _result_i64 { | |
| 2237 | + bool is_error; | |
| 2238 | + IError err; | |
| 2239 | + byte data[sizeof(i64) > 1 ? sizeof(i64) : 1]; | |
| 2240 | +}; | |
| 2241 | + | |
| 2242 | +struct _result_multi_return_i64_int { | |
| 2243 | + bool is_error; | |
| 2244 | + IError err; | |
| 2245 | + byte data[sizeof(multi_return_i64_int) > 1 ? sizeof(multi_return_i64_int) : 1]; | |
| 2246 | +}; | |
| 2247 | + | |
| 2248 | +struct _result_i8 { | |
| 2249 | + bool is_error; | |
| 2250 | + IError err; | |
| 2251 | + byte data[sizeof(i8) > 1 ? sizeof(i8) : 1]; | |
| 2252 | +}; | |
| 2253 | + | |
| 2254 | +struct _result_i16 { | |
| 2255 | + bool is_error; | |
| 2256 | + IError err; | |
| 2257 | + byte data[sizeof(i16) > 1 ? sizeof(i16) : 1]; | |
| 2258 | +}; | |
| 2259 | + | |
| 2260 | +struct _result_i32 { | |
| 2261 | + bool is_error; | |
| 2262 | + IError err; | |
| 2263 | + byte data[sizeof(i32) > 1 ? sizeof(i32) : 1]; | |
| 2264 | +}; | |
| 2265 | + | |
| 2266 | +struct _result_u8 { | |
| 2267 | + bool is_error; | |
| 2268 | + IError err; | |
| 2269 | + byte data[sizeof(u8) > 1 ? sizeof(u8) : 1]; | |
| 2270 | +}; | |
| 2271 | + | |
| 2272 | +struct _result_u16 { | |
| 2273 | + bool is_error; | |
| 2274 | + IError err; | |
| 2275 | + byte data[sizeof(u16) > 1 ? sizeof(u16) : 1]; | |
| 2276 | +}; | |
| 2277 | + | |
| 2278 | +struct _result_u32 { | |
| 2279 | + bool is_error; | |
| 2280 | + IError err; | |
| 2281 | + byte data[sizeof(u32) > 1 ? sizeof(u32) : 1]; | |
| 2282 | +}; | |
| 2283 | + | |
| 2284 | +struct _result_rune { | |
| 2285 | + bool is_error; | |
| 2286 | + IError err; | |
| 2287 | + byte data[sizeof(rune) > 1 ? sizeof(rune) : 1]; | |
| 2288 | +}; | |
| 2289 | + | |
| 2290 | +struct _result_string { | |
| 2291 | + bool is_error; | |
| 2292 | + IError err; | |
| 2293 | + byte data[sizeof(string) > 1 ? sizeof(string) : 1]; | |
| 2294 | +}; | |
| 2295 | + | |
| 2296 | + | |
| 2297 | +// V definitions: | |
| 2298 | +static char * v_typeof_interface_IError(u32 sidx); | |
| 2299 | +u32 v_typeof_interface_idx_IError(u32 sidx); | |
| 2300 | +// end of definitions #endif | |
| 2301 | +strings__Builder strings__new_builder(int initial_size); | |
| 2302 | +Array_u8 strings__Builder_reuse_as_plain_u8_array(strings__Builder* b); | |
| 2303 | +void strings__Builder_write_ptr(strings__Builder* b, u8* ptr, int len); | |
| 2304 | +void strings__Builder_write_rune(strings__Builder* b, rune r); | |
| 2305 | +void strings__Builder_write_runes(strings__Builder* b, Array_rune runes); | |
| 2306 | +void strings__Builder_write_u8(strings__Builder* b, u8 data); | |
| 2307 | +void strings__Builder_write_byte(strings__Builder* b, u8 data); | |
| 2308 | +void strings__Builder_write_decimal(strings__Builder* b, i64 n); | |
| 2309 | +void strings__Builder_write_u_decimal(strings__Builder* b, u64 n); | |
| 2310 | +_result_int strings__Builder_write(strings__Builder* b, Array_u8 data); | |
| 2311 | +void strings__Builder_drain_builder(strings__Builder* b, strings__Builder* other, int other_new_cap); | |
| 2312 | +u8 strings__Builder_byte_at(strings__Builder* b, int n); | |
| 2313 | +void strings__Builder_write_string(strings__Builder* b, string s); | |
| 2314 | +void strings__Builder_write_string2(strings__Builder* b, string s1, string s2); | |
| 2315 | +void strings__Builder_go_back(strings__Builder* b, int n); | |
| 2316 | +string strings__Builder_spart(strings__Builder* b, int start_pos, int n); | |
| 2317 | +string strings__Builder_cut_last(strings__Builder* b, int n); | |
| 2318 | +string strings__Builder_cut_to(strings__Builder* b, int pos); | |
| 2319 | +void strings__Builder_go_back_to(strings__Builder* b, int pos); | |
| 2320 | +void strings__Builder_writeln(strings__Builder* b, string s); | |
| 2321 | +void strings__Builder_writeln2(strings__Builder* b, string s1, string s2); | |
| 2322 | +string strings__Builder_last_n(strings__Builder* b, int n); | |
| 2323 | +string strings__Builder_after(strings__Builder* b, int n); | |
| 2324 | +string strings__Builder_str(strings__Builder* b); | |
| 2325 | +void strings__Builder_ensure_cap(strings__Builder* b, int n); | |
| 2326 | +void strings__Builder_grow_len(strings__Builder* b, int n); | |
| 2327 | +void strings__Builder_free(strings__Builder* b); | |
| 2328 | +void strings__Builder_write_repeated_rune(strings__Builder* b, rune r, int count); | |
| 2329 | +void strings__Builder_indent(strings__Builder* b, string s, strings__IndentParam param); | |
| 2330 | +VV_LOC int strings__min(int a, int b, int c); | |
| 2331 | +VV_LOC int strings__max2(int a, int b); | |
| 2332 | +VV_LOC int strings__min2(int a, int b); | |
| 2333 | +VV_LOC int strings__abs2(int a, int b); | |
| 2334 | +int strings__levenshtein_distance(string a, string b); | |
| 2335 | +f32 strings__levenshtein_distance_percentage(string a, string b); | |
| 2336 | +f32 strings__dice_coefficient(string s1, string s2); | |
| 2337 | +int strings__hamming_distance(string a, string b); | |
| 2338 | +f32 strings__hamming_similarity(string a, string b); | |
| 2339 | +f64 strings__jaro_similarity(string a, string b); | |
| 2340 | +f64 strings__jaro_winkler_similarity(string a, string b); | |
| 2341 | +string strings__repeat(u8 c, int n); | |
| 2342 | +string strings__repeat_string(string s, int n); | |
| 2343 | +string strings__find_between_pair_u8(string input, u8 start, u8 end); | |
| 2344 | +string strings__find_between_pair_rune(string input, rune start, rune end); | |
| 2345 | +string strings__find_between_pair_string(string input, string start, string end); | |
| 2346 | +Array_string strings__split_capital(string s); | |
| 2347 | +VV_LOC bool builtin__closure__is_ppc64(void); | |
| 2348 | +VV_LOC voidptr* builtin__closure__closure_slot_meta(voidptr exec_ptr); | |
| 2349 | +VV_LOC void builtin__closure__closure_register_page(voidptr exec_page_start); | |
| 2350 | +VV_LOC bool builtin__closure__closure_is_managed(voidptr exec_ptr); | |
| 2351 | +VV_LOC builtin__closure__ClosureLiveInfo builtin__closure__closure_live_delete(voidptr exec_ptr); | |
| 2352 | +VV_LOC builtin__closure__ClosureLifetimeState* builtin__closure__new_closure_lifetime_state_no_lock(void); | |
| 2353 | +VV_LOC builtin__closure__ClosureLifetimeState* builtin__closure__new_closure_lifetime_state(void); | |
| 2354 | +VV_LOC void builtin__closure__closure_lifetime_recycle_state_no_lock(builtin__closure__ClosureLifetimeState** state); | |
| 2355 | +VV_LOC string builtin__closure__closure_lifetime_error(builtin__closure__ClosureLifetimeState* state, u64 generation, u64 thread_id); | |
| 2356 | +VV_LOC _result_builtin__closure__ClosureLifetimeState_ptr builtin__closure__Lifetime_ensure_state(builtin__closure__Lifetime* lifetime); | |
| 2357 | +VV_LOC voidptr builtin__closure__closure_slot_data(voidptr exec_ptr); | |
| 2358 | +VV_LOC bool builtin__closure__closure_release_no_lock(voidptr exec_ptr, u64 generation); | |
| 2359 | +VV_LOC void builtin__closure__closure_lifetime_release_records_no_lock(Array_builtin__closure__ClosureLifetimeRecord records, int start, int end); | |
| 2360 | +VV_LOC void builtin__closure__closure_lifetime_reclaim_no_lock(builtin__closure__ClosureLifetimeState* state, int retain); | |
| 2361 | +VV_LOC void builtin__closure__closure_ensure_initialized(void); | |
| 2362 | +builtin__closure__Lifetime builtin__closure__new_lifetime(void); | |
| 2363 | +VV_LOC _result_builtin__closure__FrameToken builtin__closure__Lifetime_begin_frame(builtin__closure__Lifetime* lifetime); | |
| 2364 | +VV_LOC _result_void builtin__closure__Lifetime_end_frame(builtin__closure__Lifetime* lifetime, builtin__closure__FrameToken token); | |
| 2365 | +_result_void builtin__closure__Lifetime_frame(builtin__closure__Lifetime* lifetime, void (*work)()); | |
| 2366 | +_result_void builtin__closure__Lifetime_reclaim(builtin__closure__Lifetime* lifetime, int retain); | |
| 2367 | +_result_void builtin__closure__Lifetime_reclaim_all(builtin__closure__Lifetime* lifetime); | |
| 2368 | +_result_void builtin__closure__Lifetime_dispose(builtin__closure__Lifetime* lifetime); | |
| 2369 | +_result_void builtin__closure__Lifetime_suspend(builtin__closure__Lifetime* lifetime, void (*work)()); | |
| 2370 | +_result_void builtin__closure__Lifetime_untracked(builtin__closure__Lifetime* lifetime, void (*work)()); | |
| 2371 | +VV_LOC void builtin__closure__closure_alloc(void); | |
| 2372 | +VV_LOC void builtin__closure__closure_init_body(void); | |
| 2373 | +VV_LOC voidptr builtin__closure__closure_mtx_ptr_platform(void); | |
| 2374 | +VV_LOC u8* builtin__closure__closure_alloc_platform(void); | |
| 2375 | +VV_LOC void builtin__closure__closure_memory_protect_platform(voidptr ptr, isize size, builtin__closure__MemoryProtectAtrr attr); | |
| 2376 | +VV_LOC int builtin__closure__get_page_size_platform(void); | |
| 2377 | +VV_LOC void builtin__closure__closure_mtx_lock_init_platform(void); | |
| 2378 | +VV_LOC void builtin__closure__closure_mtx_lock_platform(void); | |
| 2379 | +VV_LOC void builtin__closure__closure_mtx_unlock_platform(void); | |
| 2380 | +VV_LOC u64 builtin__closure__closure_current_thread_id_platform(void); | |
| 2381 | +VV_LOC void builtin__closure__closure_init_once_platform(void); | |
| 2382 | +multi_return_u64_u64 math__bits__mul_64(u64 x, u64 y); | |
| 2383 | +multi_return_u64_u64 math__bits__mul_add_64(u64 x, u64 y, u64 z); | |
| 2384 | +multi_return_u64_u64 math__bits__div_64(u64 hi, u64 lo, u64 y1); | |
| 2385 | +int math__bits__leading_zeros_8(u8 x); | |
| 2386 | +int math__bits__leading_zeros_16(u16 x); | |
| 2387 | +int math__bits__leading_zeros_32(u32 x); | |
| 2388 | +int math__bits__leading_zeros_64(u64 x); | |
| 2389 | +int math__bits__trailing_zeros_8(u8 x); | |
| 2390 | +int math__bits__trailing_zeros_16(u16 x); | |
| 2391 | +int math__bits__trailing_zeros_32(u32 x); | |
| 2392 | +int math__bits__trailing_zeros_64(u64 x); | |
| 2393 | +int math__bits__ones_count_8(u8 x); | |
| 2394 | +int math__bits__ones_count_16(u16 x); | |
| 2395 | +int math__bits__ones_count_32(u32 x); | |
| 2396 | +int math__bits__ones_count_64(u64 x); | |
| 2397 | +int math__bits__pure_v_but_overridden_by_c_leading_zeros_8(u8 x); | |
| 2398 | +VV_LOC int math__bits__leading_zeros_8_default(u8 x); | |
| 2399 | +int math__bits__pure_v_but_overridden_by_c_leading_zeros_16(u16 x); | |
| 2400 | +VV_LOC int math__bits__leading_zeros_16_default(u16 x); | |
| 2401 | +int math__bits__pure_v_but_overridden_by_c_leading_zeros_32(u32 x); | |
| 2402 | +VV_LOC int math__bits__leading_zeros_32_default(u32 x); | |
| 2403 | +int math__bits__pure_v_but_overridden_by_c_leading_zeros_64(u64 x); | |
| 2404 | +VV_LOC int math__bits__leading_zeros_64_default(u64 x); | |
| 2405 | +int math__bits__pure_v_but_overridden_by_c_trailing_zeros_8(u8 x); | |
| 2406 | +VV_LOC int math__bits__trailing_zeros_8_default(u8 x); | |
| 2407 | +int math__bits__pure_v_but_overridden_by_c_trailing_zeros_16(u16 x); | |
| 2408 | +VV_LOC int math__bits__trailing_zeros_16_default(u16 x); | |
| 2409 | +int math__bits__pure_v_but_overridden_by_c_trailing_zeros_32(u32 x); | |
| 2410 | +VV_LOC int math__bits__trailing_zeros_32_default(u32 x); | |
| 2411 | +int math__bits__pure_v_but_overridden_by_c_trailing_zeros_64(u64 x); | |
| 2412 | +VV_LOC int math__bits__trailing_zeros_64_default(u64 x); | |
| 2413 | +int math__bits__pure_v_but_overridden_by_c_ones_count_8(u8 x); | |
| 2414 | +VV_LOC int math__bits__ones_count_8_default(u8 x); | |
| 2415 | +int math__bits__pure_v_but_overridden_by_c_ones_count_16(u16 x); | |
| 2416 | +VV_LOC int math__bits__ones_count_16_default(u16 x); | |
| 2417 | +int math__bits__pure_v_but_overridden_by_c_ones_count_32(u32 x); | |
| 2418 | +VV_LOC int math__bits__ones_count_32_default(u32 x); | |
| 2419 | +int math__bits__pure_v_but_overridden_by_c_ones_count_64(u64 x); | |
| 2420 | +VV_LOC int math__bits__ones_count_64_default(u64 x); | |
| 2421 | +u8 math__bits__rotate_left_8(u8 x, int k); | |
| 2422 | +u16 math__bits__rotate_left_16(u16 x, int k); | |
| 2423 | +u32 math__bits__rotate_left_32(u32 x, int k); | |
| 2424 | +u64 math__bits__rotate_left_64(u64 x, int k); | |
| 2425 | +u8 math__bits__reverse_8(u8 x); | |
| 2426 | +u16 math__bits__reverse_16(u16 x); | |
| 2427 | +u32 math__bits__reverse_32(u32 x); | |
| 2428 | +u64 math__bits__reverse_64(u64 x); | |
| 2429 | +u16 math__bits__reverse_bytes_16(u16 x); | |
| 2430 | +u32 math__bits__reverse_bytes_32(u32 x); | |
| 2431 | +u64 math__bits__reverse_bytes_64(u64 x); | |
| 2432 | +int math__bits__len_8(u8 x); | |
| 2433 | +int math__bits__len_16(u16 x); | |
| 2434 | +int math__bits__len_32(u32 x); | |
| 2435 | +int math__bits__len_64(u64 x); | |
| 2436 | +multi_return_u32_u32 math__bits__add_32(u32 x, u32 y, u32 carry); | |
| 2437 | +multi_return_u64_u64 math__bits__add_64(u64 x, u64 y, u64 carry); | |
| 2438 | +multi_return_u32_u32 math__bits__sub_32(u32 x, u32 y, u32 borrow); | |
| 2439 | +multi_return_u64_u64 math__bits__sub_64(u64 x, u64 y, u64 borrow); | |
| 2440 | +multi_return_u32_u32 math__bits__mul_32(u32 x, u32 y); | |
| 2441 | +VV_LOC multi_return_u32_u32 math__bits__mul_32_default(u32 x, u32 y); | |
| 2442 | +multi_return_u64_u64 math__bits__pure_v_but_overridden_by_amd64_mul_64(u64 x, u64 y); | |
| 2443 | +VV_LOC multi_return_u64_u64 math__bits__mul_64_default(u64 x, u64 y); | |
| 2444 | +multi_return_u32_u32 math__bits__mul_add_32(u32 x, u32 y, u32 z); | |
| 2445 | +VV_LOC multi_return_u32_u32 math__bits__mul_add_32_default(u32 x, u32 y, u32 z); | |
| 2446 | +multi_return_u64_u64 math__bits__pure_v_but_overridden_by_amd64_mul_add_64(u64 x, u64 y, u64 z); | |
| 2447 | +VV_LOC multi_return_u64_u64 math__bits__mul_add_64_default(u64 x, u64 y, u64 z); | |
| 2448 | +multi_return_u32_u32 math__bits__div_32(u32 hi, u32 lo, u32 y); | |
| 2449 | +VV_LOC multi_return_u32_u32 math__bits__div_32_default(u32 hi, u32 lo, u32 y); | |
| 2450 | +multi_return_u64_u64 math__bits__pure_v_but_overridden_by_amd64_div_64(u64 hi, u64 lo, u64 y1); | |
| 2451 | +VV_LOC multi_return_u64_u64 math__bits__div_64_default(u64 hi, u64 lo, u64 y1); | |
| 2452 | +u32 math__bits__rem_32(u32 hi, u32 lo, u32 y); | |
| 2453 | +u64 math__bits__rem_64(u64 hi, u64 lo, u64 y); | |
| 2454 | +multi_return_f64_int math__bits__normalize(f64 x); | |
| 2455 | +u32 math__bits__f32_bits(f32 f); | |
| 2456 | +f32 math__bits__f32_from_bits(u32 b); | |
| 2457 | +u64 math__bits__f64_bits(f64 f); | |
| 2458 | +f64 math__bits__f64_from_bits(u64 b); | |
| 2459 | +VV_LOC multi_return_u32_u32_u32 strconv__lsr96(u32 s2, u32 s1, u32 s0); | |
| 2460 | +VV_LOC multi_return_u32_u32_u32 strconv__lsl96(u32 s2, u32 s1, u32 s0); | |
| 2461 | +VV_LOC multi_return_u32_u32_u32 strconv__add96(u32 s2, u32 s1, u32 s0, u32 d2, u32 d1, u32 d0); | |
| 2462 | +VV_LOC multi_return_strconv__ParserState_strconv__PrepNumber strconv__parser(string s); | |
| 2463 | +VV_LOC u64 strconv__converter(strconv__PrepNumber* pn); | |
| 2464 | +_result_f64 strconv__atof64(string s, strconv__AtoF64Param param); | |
| 2465 | +f64 strconv__atof_quick(string s); | |
| 2466 | +u8 strconv__byte_to_lower(u8 c); | |
| 2467 | +_result_u64 strconv__common_parse_uint(string s, int _base, int _bit_size, bool error_on_non_digit, bool error_on_high_digit); | |
| 2468 | +multi_return_u64_int strconv__common_parse_uint2(string s, int _base, int _bit_size); | |
| 2469 | +_result_u64 strconv__parse_uint(string s, int _base, int _bit_size); | |
| 2470 | +_result_i64 strconv__common_parse_int(string _s, int base, int _bit_size, bool error_on_non_digit, bool error_on_high_digit); | |
| 2471 | +_result_i64 strconv__parse_int(string _s, int base, int _bit_size); | |
| 2472 | +VV_LOC _result_multi_return_i64_int strconv__atoi_common_check(string s); | |
| 2473 | +VV_LOC _result_i64 strconv__atoi_common(string s, i64 type_min, i64 type_max); | |
| 2474 | +_result_int strconv__atoi(string s); | |
| 2475 | +_result_i8 strconv__atoi8(string s); | |
| 2476 | +_result_i16 strconv__atoi16(string s); | |
| 2477 | +_result_i32 strconv__atoi32(string s); | |
| 2478 | +_result_i64 strconv__atoi64(string s); | |
| 2479 | +VV_LOC _result_i64 strconv__safe_add_64bits(i64 a, i64 b); | |
| 2480 | +VV_LOC _result_i64 strconv__safe_mul10_64bits(i64 a); | |
| 2481 | +VV_LOC _result_int strconv__atou_common_check(string s); | |
| 2482 | +VV_LOC _result_u64 strconv__atou_common(string s, u64 type_max); | |
| 2483 | +_result_u8 strconv__atou8(string s); | |
| 2484 | +_result_u16 strconv__atou16(string s); | |
| 2485 | +_result_u32 strconv__atou(string s); | |
| 2486 | +_result_u32 strconv__atou32(string s); | |
| 2487 | +_result_u64 strconv__atou64(string s); | |
| 2488 | +string strconv__Dec32_get_string_32(strconv__Dec32 d, bool neg, int i_n_digit, int i_pad_digit); | |
| 2489 | +VV_LOC multi_return_strconv__Dec32_bool strconv__f32_to_decimal_exact_int(u32 i_mant, u32 exp); | |
| 2490 | +VV_LOC strconv__Dec32 strconv__f32_to_decimal(u32 mant, u32 exp); | |
| 2491 | +string strconv__f32_to_str(f32 f, int n_digit); | |
| 2492 | +string strconv__f32_to_str_pad(f32 f, int n_digit); | |
| 2493 | +VV_LOC string strconv__Dec64_get_string_64(strconv__Dec64 d, bool neg, int i_n_digit, int i_pad_digit); | |
| 2494 | +VV_LOC multi_return_strconv__Dec64_bool strconv__f64_to_decimal_exact_int(u64 i_mant, u64 exp); | |
| 2495 | +VV_LOC strconv__Dec64 strconv__f64_to_decimal(u64 mant, u64 exp); | |
| 2496 | +string strconv__f64_to_str(f64 f, int n_digit); | |
| 2497 | +string strconv__f64_to_str_pad(f64 f, int n_digit); | |
| 2498 | +string strconv__format_str(string s, strconv__BF_param p); | |
| 2499 | +void strconv__format_str_sb(string s, strconv__BF_param p, strings__Builder* sb); | |
| 2500 | +void strconv__format_dec_sb(u64 d, strconv__BF_param p, strings__Builder* res); | |
| 2501 | +string strconv__f64_to_str_lnd1(f64 f, int dec_digit); | |
| 2502 | +string strconv__format_fl(f64 f, strconv__BF_param p); | |
| 2503 | +string strconv__format_es(f64 f, strconv__BF_param p); | |
| 2504 | +string strconv__remove_tail_zeros(string s); | |
| 2505 | +string strconv__ftoa_64(f64 f); | |
| 2506 | +string strconv__ftoa_long_64(f64 f); | |
| 2507 | +string strconv__ftoa_32(f32 f); | |
| 2508 | +string strconv__ftoa_long_32(f32 f); | |
| 2509 | +string strconv__format_int(i64 n, int radix); | |
| 2510 | +string strconv__format_uint(u64 n, int radix); | |
| 2511 | +string strconv__f32_to_str_l(f32 f); | |
| 2512 | +string strconv__f32_to_str_l_with_dot(f32 f); | |
| 2513 | +string strconv__f64_to_str_l(f64 f); | |
| 2514 | +string strconv__f64_to_str_l_with_dot(f64 f); | |
| 2515 | +string strconv__fxx_to_str_l_parse(string s); | |
| 2516 | +string strconv__fxx_to_str_l_parse_with_dot(string s); | |
| 2517 | +VV_LOC u32 strconv__bool_to_u32(bool b); | |
| 2518 | +VV_LOC u64 strconv__bool_to_u64(bool b); | |
| 2519 | +VV_LOC string strconv__get_string_special(bool neg, bool expZero, bool mantZero); | |
| 2520 | +VV_LOC u32 strconv__mul_shift_32(u32 m, u64 mul, int ishift); | |
| 2521 | +VV_LOC u32 strconv__mul_pow5_invdiv_pow2(u32 m, u32 q, int j); | |
| 2522 | +VV_LOC u32 strconv__mul_pow5_div_pow2(u32 m, u32 i, int j); | |
| 2523 | +VV_LOC u32 strconv__pow5_factor_32(u32 i_v); | |
| 2524 | +VV_LOC bool strconv__multiple_of_power_of_five_32(u32 v, u32 p); | |
| 2525 | +VV_LOC bool strconv__multiple_of_power_of_two_32(u32 v, u32 p); | |
| 2526 | +VV_LOC u32 strconv__log10_pow2(int e); | |
| 2527 | +VV_LOC u32 strconv__log10_pow5(int e); | |
| 2528 | +VV_LOC int strconv__pow5_bits(int e); | |
| 2529 | +VV_LOC u64 strconv__shift_right_128(strconv__Uint128 v, int shift); | |
| 2530 | +VV_LOC u64 strconv__mul_shift_64(u64 m, strconv__Uint128 mul, int shift); | |
| 2531 | +VV_LOC u32 strconv__pow5_factor_64(u64 v_i); | |
| 2532 | +VV_LOC bool strconv__multiple_of_power_of_five_64(u64 v, u32 p); | |
| 2533 | +VV_LOC bool strconv__multiple_of_power_of_two_64(u64 v, u32 p); | |
| 2534 | +int strconv__dec_digits(u64 n); | |
| 2535 | +void strconv__v_printf(string str, Array_voidptr pt); | |
| 2536 | +string strconv__v_sprintf(string str, Array_voidptr pt); | |
| 2537 | +VV_LOC void strconv__v_sprintf_panic(int idx, int len); | |
| 2538 | +VV_LOC f64 strconv__fabs(f64 x); | |
| 2539 | +string strconv__format_fl_old(f64 f, strconv__BF_param p); | |
| 2540 | +VV_LOC string strconv__format_es_old(f64 f, strconv__BF_param p); | |
| 2541 | +VV_LOC string strconv__remove_tail_zeros_old(string s); | |
| 2542 | +string strconv__format_dec_old(u64 d, strconv__BF_param p); | |
| 2543 | +int strconv__write_dec(i64 n, Array_u8* buf); | |
| 2544 | +int strconv__write_dec_u(u64 n, Array_u8* buf); | |
| 2545 | +VV_LOC void strconv__write_dec_u_digits(u64 n, Array_u8* buf, int offset, int ndigits); | |
| 2546 | +VV_LOC void builtin___memory_panic(string fname, isize size); | |
| 2547 | +u8* builtin___v_malloc(isize n); | |
| 2548 | +u8* builtin__malloc_noscan(isize n); | |
| 2549 | +VV_LOC u8* builtin__malloc_uninit(isize n); | |
| 2550 | +VV_LOC u64 builtin____at_least_one(u64 how_many); | |
| 2551 | +u8* builtin__malloc_uncollectable(isize n); | |
| 2552 | +u8* builtin__v_realloc(u8* b, isize n); | |
| 2553 | +u8* builtin__realloc_data(u8* old_data, int old_size, int new_size); | |
| 2554 | +u8* builtin__vcalloc(isize n); | |
| 2555 | +u8* builtin__vcalloc_noscan(isize n); | |
| 2556 | +void builtin___v_free(voidptr ptr); | |
| 2557 | +voidptr builtin__memdup(voidptr src, isize sz); | |
| 2558 | +voidptr builtin__memdup_noscan(voidptr src, isize sz); | |
| 2559 | +voidptr builtin__memdup_uncollectable(voidptr src, isize sz); | |
| 2560 | +voidptr builtin__memdup_align(voidptr src, isize sz, isize align); | |
| 2561 | +GCHeapUsage builtin__gc_heap_usage(void); | |
| 2562 | +usize builtin__gc_memory_use(void); | |
| 2563 | +VV_LOC int builtin__array_data_header_size(void); | |
| 2564 | +VV_LOC u64 builtin__array_data_allocation_size(u64 total_size); | |
| 2565 | +VV_LOC voidptr builtin__alloc_array_data(u64 total_size); | |
| 2566 | +VV_LOC voidptr builtin__alloc_array_data_uninit(u64 total_size); | |
| 2567 | +VV_LOC bool builtin__array_uses_noscan_data(array a); | |
| 2568 | +VV_LOC voidptr builtin__array_alloc_array_data_like(array a, u64 total_size); | |
| 2569 | +VV_LOC voidptr builtin__array_alloc_array_data_like_uninit(array a, u64 total_size); | |
| 2570 | +VV_LOC ArrayDataHeader* builtin__array_data_header(array a); | |
| 2571 | +VV_LOC bool builtin__array_buffer_has_slices(array a); | |
| 2572 | +VV_LOC void builtin__array_mark_buffer_has_slices(array* a); | |
| 2573 | +VV_LOC void builtin__array_set_managed_flags(array* a, bool is_slice); | |
| 2574 | +VV_LOC void builtin__array_clone_shallow_to_cap(array* a, int new_cap); | |
| 2575 | +VV_LOC int builtin__v_ni_index(int i, int len); | |
| 2576 | +VV_LOC array builtin____new_array(int mylen, int cap, int elm_size); | |
| 2577 | +VV_LOC array builtin____new_array_with_default(int mylen, int cap, int elm_size, voidptr val); | |
| 2578 | +VV_LOC array builtin____new_array_with_multi_default(int mylen, int cap, int elm_size, voidptr val); | |
| 2579 | +VV_LOC array builtin____new_array_with_array_default(int mylen, int cap, int elm_size, array val, int depth); | |
| 2580 | +VV_LOC array builtin__new_array_from_c_array(int len, int cap, int elm_size, voidptr c_array); | |
| 2581 | +void builtin__array_ensure_cap(array* a, int required); | |
| 2582 | +array builtin__array_repeat(array a, int count); | |
| 2583 | +array builtin__array_repeat_to_depth(array a, int count, int depth); | |
| 2584 | +VV_LOC bool builtin__array_needs_unique_shift(array a, int required); | |
| 2585 | +VV_LOC bool builtin__array_needs_unique_append(array a, int required); | |
| 2586 | +VV_LOC bool builtin__array_needs_unique_shrink(array a); | |
| 2587 | +void builtin__array_insert(array* a, int i, voidptr val); | |
| 2588 | +void builtin__array_prepend(array* a, voidptr val); | |
| 2589 | +void builtin__array_delete(array* a, int i); | |
| 2590 | +void builtin__array_delete_many(array* a, int i, int size); | |
| 2591 | +void builtin__array_clear(array* a); | |
| 2592 | +void builtin__array_reset(array* a); | |
| 2593 | +void builtin__array_trim(array* a, int index); | |
| 2594 | +void builtin__array_drop(array* a, int num); | |
| 2595 | +VV_LOC voidptr builtin__array_get_unsafe(array a, int i); | |
| 2596 | +VV_LOC voidptr builtin__array_get(array a, int i); | |
| 2597 | +VV_LOC voidptr builtin__array_get_i64(array a, i64 i); | |
| 2598 | +VV_LOC voidptr builtin__array_get_u64(array a, u64 i); | |
| 2599 | +VV_LOC voidptr builtin__array_get_ni(array a, int i); | |
| 2600 | +VV_LOC voidptr builtin__array_get_with_check(array a, int i); | |
| 2601 | +VV_LOC voidptr builtin__array_get_with_check_i64(array a, i64 i); | |
| 2602 | +VV_LOC voidptr builtin__array_get_with_check_u64(array a, u64 i); | |
| 2603 | +VV_LOC voidptr builtin__array_get_with_check_ni(array a, int i); | |
| 2604 | +voidptr builtin__array_first(array a); | |
| 2605 | +voidptr builtin__array_last(array a); | |
| 2606 | +voidptr builtin__array_pop_left(array* a); | |
| 2607 | +voidptr builtin__array_pop(array* a); | |
| 2608 | +void builtin__array_delete_last(array* a); | |
| 2609 | +VV_LOC array builtin__array_slice(array a, int start, int _end); | |
| 2610 | +VV_LOC array builtin__array_slice_ni(array a, int _start, int _end); | |
| 2611 | +VV_LOC array builtin__array_clone_static_to_depth(array a, int depth); | |
| 2612 | +array builtin__array_clone(array* a); | |
| 2613 | +array builtin__array_clone_to_depth(array* a, int depth); | |
| 2614 | +VV_LOC void builtin__array_set_unsafe(array* a, int i, voidptr val); | |
| 2615 | +VV_LOC void builtin__array_set(array* a, int i, voidptr val); | |
| 2616 | +VV_LOC void builtin__array_set_i64(array* a, i64 i, voidptr val); | |
| 2617 | +VV_LOC void builtin__array_set_u64(array* a, u64 i, voidptr val); | |
| 2618 | +VV_LOC void builtin__array_set_ni(array* a, int i, voidptr val); | |
| 2619 | +VV_LOC void builtin__copy_element_to(voidptr dest, voidptr src, int element_size); | |
| 2620 | +VV_LOC void builtin__array_push(array* a, voidptr val); | |
| 2621 | +void builtin__array_push_many(array* a, voidptr val, int size); | |
| 2622 | +void builtin__array_reverse_in_place(array* a); | |
| 2623 | +array builtin__array_reverse(array a); | |
| 2624 | +void builtin__array_free(array* a); | |
| 2625 | +array builtin__array_filter(array a, bool (*predicate)(voidptr _d1)); | |
| 2626 | +bool builtin__array_any(array a, bool (*predicate)(voidptr _d1)); | |
| 2627 | +int builtin__array_count(array a, bool (*predicate)(voidptr _d1)); | |
| 2628 | +bool builtin__array_all(array a, bool (*predicate)(voidptr _d1)); | |
| 2629 | +array builtin__array_map(array a, voidptr (*callback)(voidptr _d1)); | |
| 2630 | +void builtin__array_sort(array* a, int (*callback)(voidptr _d1, voidptr _d2)); | |
| 2631 | +array builtin__array_sorted(array* a, int (*callback)(voidptr _d1, voidptr _d2)); | |
| 2632 | +void builtin__array_sort_with_compare(array* a, int (*callback)(const void* const_a, const void* const_b)); | |
| 2633 | +array builtin__array_sorted_with_compare(array* a, int (*callback)(const void* const_a, const void* const_b)); | |
| 2634 | +bool builtin__array_contains(array a, voidptr value); | |
| 2635 | +int builtin__array_index(array a, voidptr value); | |
| 2636 | +int builtin__array_last_index(array a, voidptr value); | |
| 2637 | +void Array_string_free(Array_string* a); | |
| 2638 | +string Array_string_str(Array_string a); | |
| 2639 | +string Array_u8_hex(Array_u8 b); | |
| 2640 | +int builtin__copy(Array_u8* dst, Array_u8 src); | |
| 2641 | +void builtin__array_grow_cap(array* a, int amount); | |
| 2642 | +void builtin__array_grow_len(array* a, int amount); | |
| 2643 | +Array_voidptr builtin__array_pointers(array a); | |
| 2644 | +Array_u8 builtin__voidptr_vbytes(voidptr data, int len); | |
| 2645 | +Array_u8 builtin__u8_vbytes(u8* data, int len); | |
| 2646 | +void builtin__u8_free(u8* data); | |
| 2647 | +VV_LOC void builtin__panic_on_negative_len(int len); | |
| 2648 | +VV_LOC void builtin__panic_on_negative_cap(int cap); | |
| 2649 | +VV_LOC array builtin____new_array_noscan(int mylen, int cap, int elm_size); | |
| 2650 | +VV_LOC array builtin____new_array_with_default_noscan(int mylen, int cap, int elm_size, voidptr val); | |
| 2651 | +VV_LOC array builtin____new_array_with_multi_default_noscan(int mylen, int cap, int elm_size, voidptr val); | |
| 2652 | +VV_LOC array builtin____new_array_with_array_default_noscan(int mylen, int cap, int elm_size, array val, int depth); | |
| 2653 | +VV_LOC void builtin__array_push_noscan(array* a, voidptr val); | |
| 2654 | +VV_LOC void builtin__array_push_many_noscan(array* a, voidptr val, int size); | |
| 2655 | +VV_LOC bool builtin__autostr_type_in_stack(int typ); | |
| 2656 | +VV_LOC void builtin__autostr_type_push(int typ); | |
| 2657 | +VV_LOC void builtin__autostr_type_pop(void); | |
| 2658 | +VV_LOC bool builtin__autostr_addr_in_stack(voidptr addr); | |
| 2659 | +VV_LOC void builtin__autostr_addr_push(voidptr addr); | |
| 2660 | +VV_LOC void builtin__autostr_addr_pop(void); | |
| 2661 | +VV_LOC string builtin__autostr_array_circular(int len); | |
| 2662 | +void builtin__print_backtrace(void); | |
| 2663 | +VV_LOC string builtin__demangle_v_symbol(string cname); | |
| 2664 | +VV_LOC Array_string builtin__split_generic_params(string s); | |
| 2665 | +VV_LOC string builtin__demangle_backtrace_sym(string s); | |
| 2666 | +VV_LOC void builtin__eprint_space_padding(string output, int max_len); | |
| 2667 | +bool builtin__print_backtrace_skipping_top_frames(int xskipframes); | |
| 2668 | +VV_LOC string builtin__backtrace_current_executable_name(void); | |
| 2669 | +VV_LOC string builtin__backtrace_addr2line_executable(string executable, string current_executable_name); | |
| 2670 | +VV_LOC string builtin__backtrace_shell_quote(string s); | |
| 2671 | +VV_LOC bool builtin__print_backtrace_skipping_top_frames_linux(int skipframes); | |
| 2672 | +void builtin___v_exit(int code); | |
| 2673 | +_result_void builtin__at_exit(void (*cb)()); | |
| 2674 | +VV_LOC void builtin__v_segmentation_fault_handler(i32 signal_number); | |
| 2675 | +VV_LOC int builtin__v_fixed_index(int i, int len); | |
| 2676 | +VV_LOC int builtin__v_fixed_index_i64(i64 i, int len); | |
| 2677 | +VV_LOC int builtin__v_fixed_index_u64(u64 i, int len); | |
| 2678 | +VV_LOC int builtin__v_fixed_index_ni(int i, int len); | |
| 2679 | +VV_LOC int builtin__v_slice_index_i64(i64 i); | |
| 2680 | +VV_LOC int builtin__v_slice_index_u64(u64 i); | |
| 2681 | +Array_string builtin__arguments(void); | |
| 2682 | +string builtin__vcurrent_hash(void); | |
| 2683 | +u64 builtin__v_getpid(void); | |
| 2684 | +u64 builtin__v_gettid(void); | |
| 2685 | +bool builtin__isnil(voidptr v); | |
| 2686 | +VV_LOC void builtin__builtin_init(void); | |
| 2687 | +void builtin__panic_lasterr(string base); | |
| 2688 | +void builtin__gc_check_leaks(void); | |
| 2689 | +bool builtin__gc_is_enabled(void); | |
| 2690 | +void builtin__gc_enable(void); | |
| 2691 | +void builtin__gc_disable(void); | |
| 2692 | +void builtin__gc_collect(void); | |
| 2693 | +void builtin__gc_get_warn_proc(void); | |
| 2694 | +void builtin__gc_set_warn_proc(void (*cb)(char* msg, usize arg)); | |
| 2695 | +int builtin__vstrlen(u8* s); | |
| 2696 | +int builtin__vstrlen_char(char* s); | |
| 2697 | +voidptr builtin__vmemcpy(voidptr dest, const void* const_src, isize n); | |
| 2698 | +voidptr builtin__vmemmove(voidptr dest, const void* const_src, isize n); | |
| 2699 | +int builtin__vmemcmp(const void* const_s1, const void* const_s2, isize n); | |
| 2700 | +voidptr builtin__vmemset(voidptr s, int c, isize n); | |
| 2701 | +VV_LOC voidptr builtin__vsort_ptr_at(voidptr base, usize index, usize size); | |
| 2702 | +VV_LOC void builtin__vstable_sort_merge(voidptr source, voidptr dest, usize left, usize mid, usize right, usize size, int (*sort_cb)(const void* const_a, const void* const_b)); | |
| 2703 | +VV_LOC void builtin__vqsort(voidptr base, usize nmemb, usize size, int (*sort_cb)(const void* const_a, const void* const_b)); | |
| 2704 | +void builtin__chan_close(chan ch, Array_IError err); | |
| 2705 | +ChanState builtin__chan_try_pop(chan ch, voidptr obj); | |
| 2706 | +ChanState builtin__chan_try_push(chan ch, voidptr obj); | |
| 2707 | +VV_LOC void builtin___result_ok(voidptr data, _result* res, int size); | |
| 2708 | +VV_LOC void builtin___result_clone(_result* current, _result* res, int size); | |
| 2709 | +string builtin__IError_str(IError err); | |
| 2710 | +string builtin__Error_msg(Error err); | |
| 2711 | +int builtin__Error_code(Error err); | |
| 2712 | +string builtin__MessageError_str(MessageError err); | |
| 2713 | +string builtin__MessageError_msg(MessageError err); | |
| 2714 | +int builtin__MessageError_code(MessageError err); | |
| 2715 | +void builtin__MessageError_free(MessageError* err); | |
| 2716 | +IError builtin___v_error(string message); | |
| 2717 | +IError builtin__error_with_code(string message, int code); | |
| 2718 | +VV_LOC void builtin___option_none(voidptr data, _option* option, int size); | |
| 2719 | +VV_LOC void builtin___option_ok(voidptr data, _option* option, int size); | |
| 2720 | +VV_LOC void builtin___option_clone(_option* current, _option* option, int size); | |
| 2721 | +VV_LOC void builtin___result_ok_markused(void); | |
| 2722 | +VV_LOC string builtin__None___str(None__ _d1); | |
| 2723 | +string builtin__none_str(none _d1); | |
| 2724 | +int builtin__input_character(void); | |
| 2725 | +int builtin__print_character(u8 ch); | |
| 2726 | +string builtin__f64_str(f64 x); | |
| 2727 | +string builtin__f64_strg(f64 x); | |
| 2728 | +string builtin__float_literal_str(float_literal d); | |
| 2729 | +string builtin__f64_strsci(f64 x, int digit_num); | |
| 2730 | +string builtin__f64_strlong(f64 x); | |
| 2731 | +string builtin__f32_str(f32 x); | |
| 2732 | +string builtin__f32_strg(f32 x); | |
| 2733 | +string builtin__f32_strsci(f32 x, int digit_num); | |
| 2734 | +string builtin__f32_strlong(f32 x); | |
| 2735 | +f32 builtin__f32_abs(f32 a); | |
| 2736 | +f64 builtin__f64_abs(f64 a); | |
| 2737 | +f32 builtin__f32_min(f32 a, f32 b); | |
| 2738 | +f32 builtin__f32_max(f32 a, f32 b); | |
| 2739 | +f64 builtin__f64_min(f64 a, f64 b); | |
| 2740 | +f64 builtin__f64_max(f64 a, f64 b); | |
| 2741 | +bool builtin__f32_eq_epsilon(f32 a, f32 b); | |
| 2742 | +bool builtin__f64_eq_epsilon(f64 a, f64 b); | |
| 2743 | +VV_LOC u32 builtin__grapheme_hex_nibble(u8 c); | |
| 2744 | +VV_LOC u32 builtin__grapheme_hex_byte(string ranges, int i); | |
| 2745 | +VV_LOC u32 builtin__grapheme_range_value(string ranges, int value_idx); | |
| 2746 | +VV_LOC bool builtin__in_grapheme_ranges(rune r, string ranges); | |
| 2747 | +VV_LOC GraphemeBreakProperty builtin__grapheme_break_property(rune r); | |
| 2748 | +VV_LOC bool builtin__is_extended_pictographic(rune r); | |
| 2749 | +VV_LOC GraphemeState builtin__grapheme_state_from_rune(rune r, GraphemeBreakProperty prop); | |
| 2750 | +VV_LOC void builtin__GraphemeState_push(GraphemeState* gs, rune r, GraphemeBreakProperty prop); | |
| 2751 | +VV_LOC bool builtin__should_break_grapheme(GraphemeState gs, rune r, GraphemeBreakProperty prop); | |
| 2752 | +VV_LOC int builtin__utf8_rune_visible_width(rune r, GraphemeBreakProperty prop); | |
| 2753 | +VV_LOC Array_string builtin__string_graphemes_impl(string s); | |
| 2754 | +VV_LOC int builtin__utf8_grapheme_visible_length(string s); | |
| 2755 | +_option_rune builtin__input_rune(void); | |
| 2756 | +_option_rune builtin__InputRuneIterator_next(InputRuneIterator* self); | |
| 2757 | +InputRuneIterator builtin__input_rune_iterator(void); | |
| 2758 | +string builtin__ptr_str(voidptr ptr); | |
| 2759 | +string builtin__isize_str(isize x); | |
| 2760 | +string builtin__usize_str(usize x); | |
| 2761 | +string builtin__char_str(char* cptr); | |
| 2762 | +VV_LOC string builtin__int_str_l(int nn, int max); | |
| 2763 | +string builtin__i8_str(i8 n); | |
| 2764 | +string builtin__i16_str(i16 n); | |
| 2765 | +string builtin__u16_str(u16 n); | |
| 2766 | +string builtin__i32_str(i32 n); | |
| 2767 | +string builtin__int_hex_full(int nn); | |
| 2768 | +string builtin__int_str(int n); | |
| 2769 | +string builtin__u32_str(u32 nn); | |
| 2770 | +string builtin__int_literal_str(int_literal n); | |
| 2771 | +string builtin__i64_str(i64 nn); | |
| 2772 | +VV_LOC string builtin__impl_i64_to_string(i64 nn); | |
| 2773 | +string builtin__u64_str(u64 nn); | |
| 2774 | +string builtin__bool_str(bool b); | |
| 2775 | +VV_LOC string builtin__u64_to_hex(u64 nn, u8 len); | |
| 2776 | +VV_LOC string builtin__u64_to_hex_no_leading_zeros(u64 nn, u8 len); | |
| 2777 | +string builtin__u8_hex(u8 nn); | |
| 2778 | +string builtin__char_hex(char c); | |
| 2779 | +string builtin__rune_hex(rune r); | |
| 2780 | +string builtin__i8_hex(i8 nn); | |
| 2781 | +string builtin__u16_hex(u16 nn); | |
| 2782 | +string builtin__i16_hex(i16 nn); | |
| 2783 | +string builtin__u32_hex(u32 nn); | |
| 2784 | +string builtin__int_hex(int nn); | |
| 2785 | +string builtin__int_hex2(int n); | |
| 2786 | +string builtin__u64_hex(u64 nn); | |
| 2787 | +string builtin__i64_hex(i64 nn); | |
| 2788 | +string builtin__int_literal_hex(int_literal nn); | |
| 2789 | +string builtin__voidptr_str(voidptr nn); | |
| 2790 | +string builtin__byteptr_str(byteptr nn); | |
| 2791 | +string builtin__charptr_str(charptr nn); | |
| 2792 | +string builtin__u8_hex_full(u8 nn); | |
| 2793 | +string builtin__i8_hex_full(i8 nn); | |
| 2794 | +string builtin__u16_hex_full(u16 nn); | |
| 2795 | +string builtin__i16_hex_full(i16 nn); | |
| 2796 | +string builtin__u32_hex_full(u32 nn); | |
| 2797 | +string builtin__i64_hex_full(i64 nn); | |
| 2798 | +string builtin__voidptr_hex_full(voidptr nn); | |
| 2799 | +string builtin__int_literal_hex_full(int_literal nn); | |
| 2800 | +string builtin__u64_hex_full(u64 nn); | |
| 2801 | +string builtin__u8_str(u8 b); | |
| 2802 | +string builtin__u8_ascii_str(u8 b); | |
| 2803 | +string builtin__u8_str_escaped(u8 b); | |
| 2804 | +bool builtin__u8_is_capital(u8 c); | |
| 2805 | +string Array_u8_bytestr(Array_u8 b); | |
| 2806 | +_result_rune Array_u8_byterune(Array_u8 b); | |
| 2807 | +string builtin__u8_repeat(u8 b, int count); | |
| 2808 | +int builtin__int_min(int a, int b); | |
| 2809 | +int builtin__int_max(int a, int b); | |
| 2810 | +VV_LOC bool builtin__fast_string_eq(string a, string b); | |
| 2811 | +VV_LOC u64 builtin__map_hash_string(voidptr pkey); | |
| 2812 | +VV_LOC u64 builtin__map_hash_int_1(voidptr pkey); | |
| 2813 | +VV_LOC u64 builtin__map_hash_int_2(voidptr pkey); | |
| 2814 | +VV_LOC u64 builtin__map_hash_int_4(voidptr pkey); | |
| 2815 | +VV_LOC u64 builtin__map_hash_int_8(voidptr pkey); | |
| 2816 | +VV_LOC voidptr builtin__map_enum_fn(int kind, int esize); | |
| 2817 | +VV_LOC void builtin__DenseArray_zeros_to_end(DenseArray* d); | |
| 2818 | +VV_LOC DenseArray builtin__new_dense_array(int key_bytes, int value_bytes); | |
| 2819 | +VV_LOC voidptr builtin__DenseArray_key(DenseArray* d, int i); | |
| 2820 | +VV_LOC voidptr builtin__DenseArray_value(DenseArray* d, int i); | |
| 2821 | +VV_LOC bool builtin__DenseArray_has_index(DenseArray* d, int i); | |
| 2822 | +VV_LOC void builtin__DenseArray_trim_deleted_tail(DenseArray* d); | |
| 2823 | +VV_LOC int builtin__DenseArray_expand(DenseArray* d); | |
| 2824 | +VV_LOC bool builtin__map_eq_string(voidptr a, voidptr b); | |
| 2825 | +VV_LOC bool builtin__map_eq_int_1(voidptr a, voidptr b); | |
| 2826 | +VV_LOC bool builtin__map_eq_int_2(voidptr a, voidptr b); | |
| 2827 | +VV_LOC bool builtin__map_eq_int_4(voidptr a, voidptr b); | |
| 2828 | +VV_LOC bool builtin__map_eq_int_8(voidptr a, voidptr b); | |
| 2829 | +VV_LOC bool builtin__map_map_eq(map a, map b); | |
| 2830 | +VV_LOC void builtin__map_clone_string(voidptr dest, voidptr pkey); | |
| 2831 | +VV_LOC void builtin__map_clone_int_1(voidptr dest, voidptr pkey); | |
| 2832 | +VV_LOC void builtin__map_clone_int_2(voidptr dest, voidptr pkey); | |
| 2833 | +VV_LOC void builtin__map_clone_int_4(voidptr dest, voidptr pkey); | |
| 2834 | +VV_LOC void builtin__map_clone_int_8(voidptr dest, voidptr pkey); | |
| 2835 | +VV_LOC void builtin__map_free_string(voidptr pkey); | |
| 2836 | +VV_LOC void builtin__map_free_nop(voidptr _d1); | |
| 2837 | +VV_LOC map builtin__new_map(int key_bytes, int value_bytes, u64 (*hash_fn)(voidptr _d1), bool (*key_eq_fn)(voidptr _d1, voidptr _d2), void (*clone_fn)(voidptr _d1, voidptr _d2), void (*free_fn)(voidptr _d1)); | |
| 2838 | +VV_LOC map builtin__new_map_init(u64 (*hash_fn)(voidptr _d1), bool (*key_eq_fn)(voidptr _d1, voidptr _d2), void (*clone_fn)(voidptr _d1, voidptr _d2), void (*free_fn)(voidptr _d1), int n, int key_bytes, int value_bytes, voidptr keys, voidptr values); | |
| 2839 | +map builtin__map_move(map* m); | |
| 2840 | +void builtin__map_clear(map* m); | |
| 2841 | +VV_LOC multi_return_u32_u32 builtin__map_key_to_index(map* m, voidptr pkey); | |
| 2842 | +VV_LOC multi_return_u32_u32 builtin__map_meta_less(map* m, u32 _index, u32 _metas); | |
| 2843 | +VV_LOC void builtin__map_meta_greater(map* m, u32 _index, u32 _metas, u32 kvi); | |
| 2844 | +VV_LOC void builtin__map_ensure_extra_metas_grow(map* m); | |
| 2845 | +VV_LOC void builtin__map_ensure_extra_metas(map* m, u32 probe_count); | |
| 2846 | +VV_LOC void builtin__map_set(map* m, voidptr key, voidptr value); | |
| 2847 | +VV_LOC void builtin__map_expand(map* m); | |
| 2848 | +VV_LOC void builtin__map_rehash(map* m); | |
| 2849 | +VV_LOC void builtin__map_reserve_metas(map* m, u32 meta_bytes); | |
| 2850 | +void builtin__map_reserve(map* m, u32 n); | |
| 2851 | +VV_LOC void builtin__map_cached_rehash(map* m, u32 old_cap); | |
| 2852 | +VV_LOC voidptr builtin__map_get_and_set(map* m, voidptr key, voidptr zero); | |
| 2853 | +VV_LOC voidptr builtin__map_get(map* m, voidptr key, voidptr zero); | |
| 2854 | +VV_LOC voidptr builtin__map_get_check(map* m, voidptr key); | |
| 2855 | +VV_LOC bool builtin__map_exists(map* m, voidptr key); | |
| 2856 | +VV_LOC void builtin__DenseArray_delete(DenseArray* d, int i); | |
| 2857 | +void builtin__map_delete(map* m, voidptr key); | |
| 2858 | +array builtin__map_keys(map* m); | |
| 2859 | +array builtin__map_values(map* m); | |
| 2860 | +VV_LOC DenseArray builtin__DenseArray_clone(DenseArray* d); | |
| 2861 | +map builtin__map_clone(map* m); | |
| 2862 | +void builtin__map_free(map* m); | |
| 2863 | +void builtin__VAssertMetaInfo_free(VAssertMetaInfo* ami); | |
| 2864 | +void builtin__IError_free(IError* ie); | |
| 2865 | +void builtin__panic_option_not_set(string s); | |
| 2866 | +void builtin__panic_result_not_set(string s); | |
| 2867 | +void builtin___v_panic(string s); | |
| 2868 | +string builtin__c_error_number_str(int errnum); | |
| 2869 | +void builtin__panic_n(string s, i64 number1); | |
| 2870 | +void builtin__panic_n2(string s, i64 number1, i64 number2); | |
| 2871 | +VV_LOC void builtin__panic_n3(string s, i64 number1, i64 number2, i64 number3); | |
| 2872 | +void builtin__panic_error_number(string basestr, int errnum); | |
| 2873 | +VV_LOC void builtin__set_stream_unbuffered(FILE* stream); | |
| 2874 | +void builtin__eprintln(string s); | |
| 2875 | +void builtin__eprint(string s); | |
| 2876 | +void builtin__flush_stdout(void); | |
| 2877 | +void builtin__flush_stderr(void); | |
| 2878 | +void builtin__unbuffer_stdout(void); | |
| 2879 | +void builtin__print(string s); | |
| 2880 | +void builtin__println(string s); | |
| 2881 | +VV_LOC void builtin___writeln_to_fd(int fd, string s); | |
| 2882 | +VV_LOC void builtin___write_buf_to_fd(int fd, u8* buf, int buf_len); | |
| 2883 | +string builtin__reuse_data_as_string(Array_u8 buffer); | |
| 2884 | +Array_u8 builtin__reuse_string_as_data(string s); | |
| 2885 | +string builtin__rune_str(rune c); | |
| 2886 | +string Array_rune_string(Array_rune ra); | |
| 2887 | +string builtin__rune_repeat(rune c, int count); | |
| 2888 | +Array_u8 builtin__rune_bytes(rune c); | |
| 2889 | +int builtin__rune_length_in_bytes(rune c); | |
| 2890 | +rune builtin__rune_to_upper(rune c); | |
| 2891 | +rune builtin__rune_to_lower(rune c); | |
| 2892 | +rune builtin__rune_to_title(rune c); | |
| 2893 | +VV_LOC rune builtin__rune_map_to(rune c, MapMode mode); | |
| 2894 | +VV_LOC int builtin__mapnode_find_key(mapnode* n, string k); | |
| 2895 | +VV_LOC bool builtin__mapnode_remove_key(mapnode* n, string k); | |
| 2896 | +VV_LOC void builtin__mapnode_remove_from_leaf(mapnode* n, int idx); | |
| 2897 | +VV_LOC void builtin__mapnode_remove_from_non_leaf(mapnode* n, int idx); | |
| 2898 | +VV_LOC void builtin__mapnode_fill(mapnode* n, int idx); | |
| 2899 | +VV_LOC void builtin__mapnode_borrow_from_prev(mapnode* n, int idx); | |
| 2900 | +VV_LOC void builtin__mapnode_borrow_from_next(mapnode* n, int idx); | |
| 2901 | +VV_LOC void builtin__mapnode_merge(mapnode* n, int idx); | |
| 2902 | +void builtin__SortedMap_delete(SortedMap* m, string key); | |
| 2903 | +VV_LOC int builtin__mapnode_subkeys(mapnode* n, Array_string* keys, int at); | |
| 2904 | +Array_string builtin__SortedMap_keys(SortedMap* m); | |
| 2905 | +VV_LOC void builtin__mapnode_free(mapnode* n); | |
| 2906 | +void builtin__SortedMap_free(SortedMap* m); | |
| 2907 | +Array_rune builtin__string_runes(string s); | |
| 2908 | +Array_string builtin__string_graphemes(string s); | |
| 2909 | +string builtin__cstring_to_vstring(const char* const_s); | |
| 2910 | +string builtin__tos_clone(const u8* const_s); | |
| 2911 | +string builtin__tos(u8* s, int len); | |
| 2912 | +string builtin__tos2(u8* s); | |
| 2913 | +string builtin__tos3(char* s); | |
| 2914 | +string builtin__tos4(u8* s); | |
| 2915 | +string builtin__tos5(char* s); | |
| 2916 | +string builtin__u8_vstring(u8* bp); | |
| 2917 | +string builtin__u8_vstring_with_len(u8* bp, int len); | |
| 2918 | +string builtin__char_vstring(char* cp); | |
| 2919 | +string builtin__char_vstring_with_len(char* cp, int len); | |
| 2920 | +string builtin__u8_vstring_literal(u8* bp); | |
| 2921 | +string builtin__u8_vstring_literal_with_len(u8* bp, int len); | |
| 2922 | +string builtin__char_vstring_literal(char* cp); | |
| 2923 | +string builtin__char_vstring_literal_with_len(char* cp, int len); | |
| 2924 | +int builtin__string_len_utf8(string s); | |
| 2925 | +bool builtin__string_is_pure_ascii(string s); | |
| 2926 | +string builtin__string_clone(string a); | |
| 2927 | +string builtin__string_replace_once(string s, string rep, string with); | |
| 2928 | +string builtin__string_replace(string s, string rep, string with); | |
| 2929 | +string builtin__string_replace_each(string s, Array_string vals); | |
| 2930 | +string builtin__string_format(string s, Array_string args); | |
| 2931 | +string builtin__string_replace_char(string s, u8 rep, u8 with, int repeat); | |
| 2932 | +string builtin__string_normalize_tabs(string s, int tab_len); | |
| 2933 | +string builtin__string_expand_tabs(string s, int tab_len); | |
| 2934 | +bool builtin__string_bool(string s); | |
| 2935 | +i8 builtin__string_i8(string s); | |
| 2936 | +i16 builtin__string_i16(string s); | |
| 2937 | +i32 builtin__string_i32(string s); | |
| 2938 | +int builtin__string_int(string s); | |
| 2939 | +i64 builtin__string_i64(string s); | |
| 2940 | +f32 builtin__string_f32(string s); | |
| 2941 | +f64 builtin__string_f64(string s); | |
| 2942 | +Array_u8 builtin__string_u8_array(string s); | |
| 2943 | +u8 builtin__string_u8(string s); | |
| 2944 | +u16 builtin__string_u16(string s); | |
| 2945 | +u32 builtin__string_u32(string s); | |
| 2946 | +u64 builtin__string_u64(string s); | |
| 2947 | +_result_u64 builtin__string_parse_uint(string s, int _base, int _bit_size); | |
| 2948 | +_result_i64 builtin__string_parse_int(string s, int _base, int _bit_size); | |
| 2949 | +VV_LOC bool builtin__string__eq(string s, string a); | |
| 2950 | +int builtin__string_compare(string s, string a); | |
| 2951 | +VV_LOC bool builtin__string__lt(string s, string a); | |
| 2952 | +VV_LOC string builtin__string__plus(string s, string a); | |
| 2953 | +VV_LOC string builtin__string_plus_many(int data_len, string* input_base); | |
| 2954 | +VV_LOC string builtin__string_plus_two(string s, string a, string b); | |
| 2955 | +Array_string builtin__string_split_any(string s, string delim); | |
| 2956 | +Array_string builtin__string_rsplit_any(string s, string delim); | |
| 2957 | +Array_string builtin__string_split(string s, string delim); | |
| 2958 | +Array_string builtin__string_rsplit(string s, string delim); | |
| 2959 | +_option_multi_return_string_string builtin__string_split_once(string s, string delim); | |
| 2960 | +_option_multi_return_string_string builtin__string_rsplit_once(string s, string delim); | |
| 2961 | +Array_string builtin__string_split_n(string s, string delim, int n); | |
| 2962 | +Array_string builtin__string_split_nth(string s, string delim, int nth); | |
| 2963 | +Array_string builtin__string_rsplit_nth(string s, string delim, int nth); | |
| 2964 | +Array_string builtin__string_split_into_lines(string s); | |
| 2965 | +Array_string builtin__string_split_by_space(string s); | |
| 2966 | +string builtin__string_substr(string s, int start, int _end); | |
| 2967 | +string builtin__string_substr_unsafe(string s, int start, int _end); | |
| 2968 | +string builtin__string_substr_or(string s, int start, int _end, string fallback); | |
| 2969 | +_result_string builtin__string_substr_with_check(string s, int start, int _end); | |
| 2970 | +string builtin__string_substr_ni(string s, int _start, int _end); | |
| 2971 | +int builtin__string_index_(string s, string p); | |
| 2972 | +_option_int builtin__string_index(string s, string p); | |
| 2973 | +_option_int builtin__string_last_index(string s, string needle); | |
| 2974 | +VV_LOC int builtin__string_index_kmp(string s, string p); | |
| 2975 | +int builtin__string_index_any(string s, string chars); | |
| 2976 | +VV_LOC int builtin__string_index_last_(string s, string p); | |
| 2977 | +_option_int builtin__string_index_after(string s, string p, int start); | |
| 2978 | +int builtin__string_index_after_(string s, string p, int start); | |
| 2979 | +int builtin__string_index_u8(string s, u8 c); | |
| 2980 | +int builtin__string_last_index_u8(string s, u8 c); | |
| 2981 | +int builtin__string_count(string s, string substr); | |
| 2982 | +bool builtin__string_contains_u8(string s, u8 x); | |
| 2983 | +bool builtin__string_contains(string s, string substr); | |
| 2984 | +bool builtin__string_contains_any(string s, string chars); | |
| 2985 | +bool builtin__string_contains_only(string s, string chars); | |
| 2986 | +bool builtin__string_contains_any_substr(string s, Array_string substrs); | |
| 2987 | +bool builtin__string_starts_with(string s, string p); | |
| 2988 | +bool builtin__string_ends_with(string s, string p); | |
| 2989 | +string builtin__string_to_lower_ascii(string s); | |
| 2990 | +string builtin__string_to_lower(string s); | |
| 2991 | +bool builtin__string_is_lower(string s); | |
| 2992 | +string builtin__string_to_upper_ascii(string s); | |
| 2993 | +string builtin__string_to_upper(string s); | |
| 2994 | +bool builtin__string_is_upper(string s); | |
| 2995 | +string builtin__string_capitalize(string s); | |
| 2996 | +string builtin__string_uncapitalize(string s); | |
| 2997 | +bool builtin__string_is_capital(string s); | |
| 2998 | +bool builtin__string_starts_with_capital(string s); | |
| 2999 | +string builtin__string_title(string s); | |
| 3000 | +bool builtin__string_is_title(string s); | |
| 3001 | +string builtin__string_find_between(string s, string start, string end); | |
| 3002 | +string builtin__string_trim_space(string s); | |
| 3003 | +string builtin__string_trim_space_left(string s); | |
| 3004 | +string builtin__string_trim_space_right(string s); | |
| 3005 | +string builtin__string_trim(string s, string cutset); | |
| 3006 | +multi_return_int_int builtin__string_trim_indexes(string s, string cutset); | |
| 3007 | +VV_LOC string builtin__string_trim_chars(string s, string cutset, TrimMode mode); | |
| 3008 | +VV_LOC string builtin__string_trim_runes(string s, string cutset, TrimMode mode); | |
| 3009 | +string builtin__string_trim_left(string s, string cutset); | |
| 3010 | +string builtin__string_trim_right(string s, string cutset); | |
| 3011 | +string builtin__string_trim_string_left(string s, string str); | |
| 3012 | +string builtin__string_trim_string_right(string s, string str); | |
| 3013 | +int builtin__compare_strings(string* a, string* b); | |
| 3014 | +VV_LOC int builtin__compare_strings_by_len(string* a, string* b); | |
| 3015 | +VV_LOC int builtin__compare_lower_strings(string* a, string* b); | |
| 3016 | +void Array_string_sort_ignore_case(Array_string* s); | |
| 3017 | +void Array_string_sort_by_len(Array_string* s); | |
| 3018 | +string builtin__string_str(string s); | |
| 3019 | +VV_LOC u8 builtin__string_at(string s, int idx); | |
| 3020 | +VV_LOC u8 builtin__string_at_i64(string s, i64 idx); | |
| 3021 | +VV_LOC u8 builtin__string_at_u64(string s, u64 idx); | |
| 3022 | +VV_LOC u8 builtin__string_at_ni(string s, int idx); | |
| 3023 | +VV_LOC _option_u8 builtin__string_at_with_check(string s, int idx); | |
| 3024 | +VV_LOC _option_u8 builtin__string_at_with_check_i64(string s, i64 idx); | |
| 3025 | +VV_LOC _option_u8 builtin__string_at_with_check_u64(string s, u64 idx); | |
| 3026 | +VV_LOC _option_u8 builtin__string_at_with_check_ni(string s, int idx); | |
| 3027 | +bool builtin__string_is_oct(string str); | |
| 3028 | +bool builtin__string_is_bin(string str); | |
| 3029 | +bool builtin__string_is_hex(string str); | |
| 3030 | +bool builtin__string_is_int(string str); | |
| 3031 | +bool builtin__u8_is_space(u8 c); | |
| 3032 | +bool builtin__u8_is_digit(u8 c); | |
| 3033 | +bool builtin__u8_is_hex_digit(u8 c); | |
| 3034 | +bool builtin__u8_is_oct_digit(u8 c); | |
| 3035 | +bool builtin__u8_is_bin_digit(u8 c); | |
| 3036 | +bool builtin__u8_is_letter(u8 c); | |
| 3037 | +bool builtin__u8_is_alnum(u8 c); | |
| 3038 | +void builtin__string_free(string* s); | |
| 3039 | +string builtin__string_before(string s, string sub); | |
| 3040 | +string builtin__string_all_before(string s, string sub); | |
| 3041 | +string builtin__string_all_before_last(string s, string sub); | |
| 3042 | +string builtin__string_all_after(string s, string sub); | |
| 3043 | +string builtin__string_all_after_last(string s, string sub); | |
| 3044 | +string builtin__string_all_after_first(string s, string sub); | |
| 3045 | +string builtin__string_after(string s, string sub); | |
| 3046 | +string builtin__string_after_char(string s, u8 sub); | |
| 3047 | +string Array_string_join(Array_string a, string sep); | |
| 3048 | +string Array_string_join_lines(Array_string s); | |
| 3049 | +string builtin__string_reverse(string s); | |
| 3050 | +string builtin__string_limit(string s, int max); | |
| 3051 | +int builtin__string_hash(string s); | |
| 3052 | +Array_u8 builtin__string_bytes(string s); | |
| 3053 | +string builtin__string_repeat(string s, int count); | |
| 3054 | +Array_string builtin__string_fields(string s); | |
| 3055 | +string builtin__string_strip_margin(string s); | |
| 3056 | +string builtin__string_strip_margin_custom(string s, u8 del); | |
| 3057 | +string builtin__string_trim_indent(string s); | |
| 3058 | +int builtin__string_indent_width(string s); | |
| 3059 | +bool builtin__string_is_blank(string s); | |
| 3060 | +bool builtin__string_match_glob(string name, string pattern); | |
| 3061 | +bool builtin__string_is_ascii(string s); | |
| 3062 | +bool builtin__string_is_identifier(string s); | |
| 3063 | +string builtin__string_camel_to_snake(string s); | |
| 3064 | +string builtin__string_snake_to_camel(string s); | |
| 3065 | +string builtin__string_wrap(string s, WrapConfig config); | |
| 3066 | +string builtin__string_hex(string s); | |
| 3067 | +VV_LOC string builtin__data_to_hex_string(u8* data, int len); | |
| 3068 | +RunesIterator builtin__string_runes_iterator(string s); | |
| 3069 | +_option_rune builtin__RunesIterator_next(RunesIterator* ri); | |
| 3070 | +Array_u8 builtin__byteptr_vbytes(byteptr data, int len); | |
| 3071 | +string builtin__byteptr_vstring(byteptr bp); | |
| 3072 | +string builtin__byteptr_vstring_with_len(byteptr bp, int len); | |
| 3073 | +string builtin__charptr_vstring(charptr cp); | |
| 3074 | +string builtin__charptr_vstring_with_len(charptr cp, int len); | |
| 3075 | +string builtin__byteptr_vstring_literal(byteptr bp); | |
| 3076 | +string builtin__byteptr_vstring_literal_with_len(byteptr bp, int len); | |
| 3077 | +string builtin__charptr_vstring_literal(charptr cp); | |
| 3078 | +string builtin__charptr_vstring_literal_with_len(charptr cp, int len); | |
| 3079 | +string builtin__StrIntpType_str(StrIntpType x); | |
| 3080 | +VV_LOC f32 builtin__fabs32(f32 x); | |
| 3081 | +VV_LOC f64 builtin__fabs64(f64 x); | |
| 3082 | +VV_LOC u64 builtin__abs64(i64 x); | |
| 3083 | +u64 builtin__get_str_intp_u64_format(StrIntpType fmt_type, int in_width, int in_precision, bool in_tail_zeros, bool in_sign, u8 in_pad_ch, int in_base, bool in_upper_case); | |
| 3084 | +u32 builtin__get_str_intp_u32_format(StrIntpType fmt_type, int in_width, int in_precision, bool in_tail_zeros, bool in_sign, u8 in_pad_ch, int in_base, bool in_upper_case); | |
| 3085 | +VV_LOC void builtin__StrIntpData_process_str_intp_data(StrIntpData* data, strings__Builder* sb); | |
| 3086 | +string builtin__str_intp(int data_len, StrIntpData* input_base); | |
| 3087 | +string builtin__str_intp_sq(string in_str); | |
| 3088 | +string builtin__str_intp_rune(string in_str); | |
| 3089 | +string builtin__str_intp_g32(string in_str); | |
| 3090 | +string builtin__str_intp_g64(string in_str); | |
| 3091 | +string builtin__str_intp_sub(string base_str, string in_str); | |
| 3092 | +u16* builtin__string_to_wide(string _str, ToWideConfig param); | |
| 3093 | +string builtin__string_from_wide(u16* _wstr); | |
| 3094 | +string builtin__string_from_wide2(u16* _wstr, int len); | |
| 3095 | +Array_u8 builtin__wide_to_ansi(u16* _wstr); | |
| 3096 | +int builtin__utf8_char_len(u8 b); | |
| 3097 | +string builtin__utf32_to_str(u32 code); | |
| 3098 | +string builtin__utf32_to_str_no_malloc(u32 code, u8* buf); | |
| 3099 | +int builtin__utf32_decode_to_buffer(u32 code, u8* buf); | |
| 3100 | +int builtin__string_utf32_code(string _rune); | |
| 3101 | +_result_rune Array_u8_utf8_to_utf32(Array_u8 _bytes); | |
| 3102 | +VV_LOC bool builtin__utf8_is_continuation(u8 b); | |
| 3103 | +VV_LOC multi_return_rune_int builtin__utf8_decode_rune(u8* _bytes, int available_len); | |
| 3104 | +VV_LOC rune builtin__impl_utf8_to_utf32(u8* _bytes, int _bytes_len); | |
| 3105 | +int builtin__utf8_str_visible_length(string s); | |
| 3106 | +Array_u8 builtin__string_to_ansi_not_null_terminated(string _str); | |
| 3107 | +bool builtin__ArrayFlags_is_empty(ArrayFlags* e); | |
| 3108 | +bool builtin__ArrayFlags_has(ArrayFlags* e, ArrayFlags flag_); | |
| 3109 | +bool builtin__ArrayFlags_all(ArrayFlags* e, ArrayFlags flag_); | |
| 3110 | +void builtin__ArrayFlags_set(ArrayFlags* e, ArrayFlags flag_); | |
| 3111 | +void builtin__ArrayFlags_set_all(ArrayFlags* e); | |
| 3112 | +void builtin__ArrayFlags_clear(ArrayFlags* e, ArrayFlags flag_); | |
| 3113 | +void builtin__ArrayFlags_clear_all(ArrayFlags* e); | |
| 3114 | +void builtin__ArrayFlags_toggle(ArrayFlags* e, ArrayFlags flag_); | |
| 3115 | +ArrayFlags builtin__ArrayFlags__static__zero(void); | |
| 3116 | +VV_LOC void main__vf_init(void); | |
| 3117 | +VV_EXP void vf_init(void); // exported fn main.vf_init | |
| 3118 | +VV_LOC int main__vf_add(int a, int b); | |
| 3119 | +VV_EXP int vf_add(int a, int b); // exported fn main.vf_add | |
| 3120 | +VV_LOC char* main__vf_greet(char* name); | |
| 3121 | +VV_EXP char* vf_greet(char* name); // exported fn main.vf_greet | |
| 3122 | +VV_LOC void main__vf_free(voidptr p); | |
| 3123 | +VV_EXP void vf_free(voidptr p); // exported fn main.vf_free | |
| 3124 | +VV_LOC void main__main(void); | |
| 3125 | +static bool Array_rune_arr_eq(Array_rune a, Array_rune b); | |
| 3126 | +static bool builtin__closure__ClosureLifetimeState_struct_eq(builtin__closure__ClosureLifetimeState a, builtin__closure__ClosureLifetimeState b); | |
| 3127 | +static bool Array_builtin__closure__ClosureLifetimeRecord_arr_eq(Array_builtin__closure__ClosureLifetimeRecord a, Array_builtin__closure__ClosureLifetimeRecord b); | |
| 3128 | +static bool builtin__closure__ClosureLifetimeRecord_struct_eq(builtin__closure__ClosureLifetimeRecord a, builtin__closure__ClosureLifetimeRecord b); | |
| 3129 | +static bool Array_builtin__closure__ClosureLifetimeFrame_arr_eq(Array_builtin__closure__ClosureLifetimeFrame a, Array_builtin__closure__ClosureLifetimeFrame b); | |
| 3130 | +static bool builtin__closure__ClosureLifetimeFrame_struct_eq(builtin__closure__ClosureLifetimeFrame a, builtin__closure__ClosureLifetimeFrame b); | |
| 3131 | + | |
| 3132 | +// V global/const non-precomputed definitions: | |
| 3133 | +static string _const_math__bits__overflow_error; // a string literal, inited later | |
| 3134 | +static string _const_math__bits__divide_error; // a string literal, inited later | |
| 3135 | +static string _const_strconv__digit_pairs; // a string literal, inited later | |
| 3136 | +static string _const_strconv__base_digits; // a string literal, inited later | |
| 3137 | +static string _const_grapheme_control_ranges; // a string literal, inited later | |
| 3138 | +static string _const_grapheme_extend_ranges; // a string literal, inited later | |
| 3139 | +static string _const_grapheme_spacing_mark_ranges; // a string literal, inited later | |
| 3140 | +static string _const_grapheme_prepend_ranges; // a string literal, inited later | |
| 3141 | +static string _const_grapheme_extended_pictographic_ranges; // a string literal, inited later | |
| 3142 | +static string _const_digit_pairs; // a string literal, inited later | |
| 3143 | +static string _const_si_s_code; // a string literal, inited later | |
| 3144 | +static string _const_si_g32_code; // a string literal, inited later | |
| 3145 | +static string _const_si_g64_code; // a string literal, inited later | |
| 3146 | +builtin__closure__Closure g_closure; // global 6 | |
| 3147 | + | |
| 3148 | +static Array_fixed_u8_15 _const_builtin__closure__closure_thunk; // inited later | |
| 3149 | +static Array_fixed_u8_6 _const_builtin__closure__closure_get_data_bytes; // inited later | |
| 3150 | +static const u32 _const_math__bits__de_bruijn32 = 125613361; // precomputed2 | |
| 3151 | +static Array_fixed_u8_32 _const_math__bits__de_bruijn32tab = {((u8)(0)), 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, | |
| 3152 | +31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9}; // fixed array const | |
| 3153 | +static const u64 _const_math__bits__de_bruijn64 = 285870213051353865U; // precomputed2 | |
| 3154 | +static Array_fixed_u8_64 _const_math__bits__de_bruijn64tab = {((u8)(0)), 1, 56, 2, 57, 49, 28, 3, 61, 58, 42, 50, 38, 29, 17, 4, | |
| 3155 | +62, 47, 59, 36, 45, 43, 51, 22, 53, 39, 33, 30, 24, 18, 12, 5, | |
| 3156 | +63, 55, 48, 27, 60, 41, 37, 16, 46, 35, 44, 21, 52, 32, 23, 11, | |
| 3157 | +54, 26, 40, 15, 34, 20, 31, 10, 25, 14, 19, 9, 13, 8, 7, 6}; // fixed array const | |
| 3158 | +static const u64 _const_math__bits__m0 = 6148914691236517205U; // precomputed2 | |
| 3159 | +static const u64 _const_math__bits__m1 = 3689348814741910323U; // precomputed2 | |
| 3160 | +static const u64 _const_math__bits__m2 = 1085102592571150095U; // precomputed2 | |
| 3161 | +static const u64 _const_math__bits__m3 = 71777214294589695U; // precomputed2 | |
| 3162 | +static const u64 _const_math__bits__m4 = 281470681808895U; // precomputed2 | |
| 3163 | +static const u8 _const_math__bits__n8 = 8; // precomputed2 | |
| 3164 | +static const u16 _const_math__bits__n16 = 16; // precomputed2 | |
| 3165 | +static const u32 _const_math__bits__n32 = 32; // precomputed2 | |
| 3166 | +static const u64 _const_math__bits__n64 = 64U; // precomputed2 | |
| 3167 | +static const u64 _const_math__bits__two32 = 4294967296U; // precomputed2 | |
| 3168 | +static const u64 _const_math__bits__mask32 = 4294967295U; // precomputed2 | |
| 3169 | +static Array_fixed_u8_256 _const_math__bits__ntz_8_tab = {((u8)(0x08)), 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3170 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3171 | +0x05, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3172 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3173 | +0x06, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3174 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3175 | +0x05, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3176 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3177 | +0x07, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3178 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3179 | +0x05, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3180 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3181 | +0x06, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3182 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3183 | +0x05, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | |
| 3184 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00}; // fixed array const | |
| 3185 | +static Array_fixed_u8_256 _const_math__bits__pop_8_tab = {((u8)(0x00)), 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, 0x03, 0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04, | |
| 3186 | +0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04, 0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, | |
| 3187 | +0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04, 0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, | |
| 3188 | +0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, | |
| 3189 | +0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04, 0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, | |
| 3190 | +0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, | |
| 3191 | +0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, | |
| 3192 | +0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, 0x04, 0x05, 0x05, 0x06, 0x05, 0x06, 0x06, 0x07, | |
| 3193 | +0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04, 0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, | |
| 3194 | +0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, | |
| 3195 | +0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, | |
| 3196 | +0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, 0x04, 0x05, 0x05, 0x06, 0x05, 0x06, 0x06, 0x07, | |
| 3197 | +0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, | |
| 3198 | +0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, 0x04, 0x05, 0x05, 0x06, 0x05, 0x06, 0x06, 0x07, | |
| 3199 | +0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, 0x04, 0x05, 0x05, 0x06, 0x05, 0x06, 0x06, 0x07, | |
| 3200 | +0x04, 0x05, 0x05, 0x06, 0x05, 0x06, 0x06, 0x07, 0x05, 0x06, 0x06, 0x07, 0x06, 0x07, 0x07, 0x08}; // fixed array const | |
| 3201 | +static Array_fixed_u8_256 _const_math__bits__rev_8_tab = {((u8)(0x00)), 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, | |
| 3202 | +0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, | |
| 3203 | +0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, | |
| 3204 | +0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, | |
| 3205 | +0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, | |
| 3206 | +0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, | |
| 3207 | +0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, | |
| 3208 | +0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, | |
| 3209 | +0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, | |
| 3210 | +0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, | |
| 3211 | +0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, | |
| 3212 | +0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, | |
| 3213 | +0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, | |
| 3214 | +0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, | |
| 3215 | +0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, | |
| 3216 | +0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff}; // fixed array const | |
| 3217 | +static Array_fixed_u8_256 _const_math__bits__len_8_tab = {((u8)(0x00)), 0x01, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, | |
| 3218 | +0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, | |
| 3219 | +0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, | |
| 3220 | +0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, | |
| 3221 | +0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, | |
| 3222 | +0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, | |
| 3223 | +0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, | |
| 3224 | +0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, | |
| 3225 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | |
| 3226 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | |
| 3227 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | |
| 3228 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | |
| 3229 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | |
| 3230 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | |
| 3231 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | |
| 3232 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08}; // fixed array const | |
| 3233 | +static const u32 _const_strconv__single_plus_zero = 0; // precomputed2 | |
| 3234 | +static const u32 _const_strconv__single_minus_zero = 2147483648; // precomputed2 | |
| 3235 | +static const u32 _const_strconv__single_plus_infinity = 2139095040; // precomputed2 | |
| 3236 | +static const u32 _const_strconv__single_minus_infinity = 4286578688; // precomputed2 | |
| 3237 | +static const u64 _const_strconv__double_plus_zero = 0U; // precomputed2 | |
| 3238 | +static const u64 _const_strconv__double_minus_zero = 9223372036854775808U; // precomputed2 | |
| 3239 | +static const u64 _const_strconv__double_plus_infinity = 9218868437227405312U; // precomputed2 | |
| 3240 | +static const u64 _const_strconv__double_minus_infinity = 18442240474082181120U; // precomputed2 | |
| 3241 | +static const u32 _const_strconv__c_ten = 10; // precomputed2 | |
| 3242 | +static Array_fixed_u64_309 _const_strconv__pos_exp = {((u64)(0x3ff0000000000000LL)), ((u64)(0x4024000000000000LL)), ((u64)(0x4059000000000000LL)), ((u64)(0x408f400000000000LL)), ((u64)(0x40c3880000000000LL)), ((u64)(0x40f86a0000000000LL)), ((u64)(0x412e848000000000LL)), ((u64)(0x416312d000000000LL)), ((u64)(0x4197d78400000000LL)), ((u64)(0x41cdcd6500000000LL)), ((u64)(0x4202a05f20000000LL)), ((u64)(0x42374876e8000000LL)), ((u64)(0x426d1a94a2000000LL)), ((u64)(0x42a2309ce5400000LL)), ((u64)(0x42d6bcc41e900000LL)), ((u64)(0x430c6bf526340000LL)), | |
| 3243 | +((u64)(0x4341c37937e08000LL)), ((u64)(0x4376345785d8a000LL)), ((u64)(0x43abc16d674ec800LL)), ((u64)(0x43e158e460913d00LL)), ((u64)(0x4415af1d78b58c40LL)), ((u64)(0x444b1ae4d6e2ef50LL)), ((u64)(0x4480f0cf064dd592LL)), ((u64)(0x44b52d02c7e14af6LL)), ((u64)(0x44ea784379d99db4LL)), ((u64)(0x45208b2a2c280291LL)), ((u64)(0x4554adf4b7320335LL)), ((u64)(0x4589d971e4fe8402LL)), ((u64)(0x45c027e72f1f1281LL)), ((u64)(0x45f431e0fae6d721LL)), ((u64)(0x46293e5939a08ceaLL)), ((u64)(0x465f8def8808b024LL)), | |
| 3244 | +((u64)(0x4693b8b5b5056e17LL)), ((u64)(0x46c8a6e32246c99cLL)), ((u64)(0x46fed09bead87c03LL)), ((u64)(0x4733426172c74d82LL)), ((u64)(0x476812f9cf7920e3LL)), ((u64)(0x479e17b84357691bLL)), ((u64)(0x47d2ced32a16a1b1LL)), ((u64)(0x48078287f49c4a1dLL)), ((u64)(0x483d6329f1c35ca5LL)), ((u64)(0x48725dfa371a19e7LL)), ((u64)(0x48a6f578c4e0a061LL)), ((u64)(0x48dcb2d6f618c879LL)), ((u64)(0x4911efc659cf7d4cLL)), ((u64)(0x49466bb7f0435c9eLL)), ((u64)(0x497c06a5ec5433c6LL)), ((u64)(0x49b18427b3b4a05cLL)), | |
| 3245 | +((u64)(0x49e5e531a0a1c873LL)), ((u64)(0x4a1b5e7e08ca3a8fLL)), ((u64)(0x4a511b0ec57e649aLL)), ((u64)(0x4a8561d276ddfdc0LL)), ((u64)(0x4ababa4714957d30LL)), ((u64)(0x4af0b46c6cdd6e3eLL)), ((u64)(0x4b24e1878814c9ceLL)), ((u64)(0x4b5a19e96a19fc41LL)), ((u64)(0x4b905031e2503da9LL)), ((u64)(0x4bc4643e5ae44d13LL)), ((u64)(0x4bf97d4df19d6057LL)), ((u64)(0x4c2fdca16e04b86dLL)), ((u64)(0x4c63e9e4e4c2f344LL)), ((u64)(0x4c98e45e1df3b015LL)), ((u64)(0x4ccf1d75a5709c1bLL)), ((u64)(0x4d03726987666191LL)), | |
| 3246 | +((u64)(0x4d384f03e93ff9f5LL)), ((u64)(0x4d6e62c4e38ff872LL)), ((u64)(0x4da2fdbb0e39fb47LL)), ((u64)(0x4dd7bd29d1c87a19LL)), ((u64)(0x4e0dac74463a989fLL)), ((u64)(0x4e428bc8abe49f64LL)), ((u64)(0x4e772ebad6ddc73dLL)), ((u64)(0x4eacfa698c95390cLL)), ((u64)(0x4ee21c81f7dd43a7LL)), ((u64)(0x4f16a3a275d49491LL)), ((u64)(0x4f4c4c8b1349b9b5LL)), ((u64)(0x4f81afd6ec0e1411LL)), ((u64)(0x4fb61bcca7119916LL)), ((u64)(0x4feba2bfd0d5ff5bLL)), ((u64)(0x502145b7e285bf99LL)), ((u64)(0x50559725db272f7fLL)), | |
| 3247 | +((u64)(0x508afcef51f0fb5fLL)), ((u64)(0x50c0de1593369d1bLL)), ((u64)(0x50f5159af8044462LL)), ((u64)(0x512a5b01b605557bLL)), ((u64)(0x516078e111c3556dLL)), ((u64)(0x5194971956342ac8LL)), ((u64)(0x51c9bcdfabc1357aLL)), ((u64)(0x5200160bcb58c16cLL)), ((u64)(0x52341b8ebe2ef1c7LL)), ((u64)(0x526922726dbaae39LL)), ((u64)(0x529f6b0f092959c7LL)), ((u64)(0x52d3a2e965b9d81dLL)), ((u64)(0x53088ba3bf284e24LL)), ((u64)(0x533eae8caef261adLL)), ((u64)(0x53732d17ed577d0cLL)), ((u64)(0x53a7f85de8ad5c4fLL)), | |
| 3248 | +((u64)(0x53ddf67562d8b363LL)), ((u64)(0x5412ba095dc7701eLL)), ((u64)(0x5447688bb5394c25LL)), ((u64)(0x547d42aea2879f2eLL)), ((u64)(0x54b249ad2594c37dLL)), ((u64)(0x54e6dc186ef9f45cLL)), ((u64)(0x551c931e8ab87173LL)), ((u64)(0x5551dbf316b346e8LL)), ((u64)(0x558652efdc6018a2LL)), ((u64)(0x55bbe7abd3781ecaLL)), ((u64)(0x55f170cb642b133fLL)), ((u64)(0x5625ccfe3d35d80eLL)), ((u64)(0x565b403dcc834e12LL)), ((u64)(0x569108269fd210cbLL)), ((u64)(0x56c54a3047c694feLL)), ((u64)(0x56fa9cbc59b83a3dLL)), | |
| 3249 | +((u64)(0x5730a1f5b8132466LL)), ((u64)(0x5764ca732617ed80LL)), ((u64)(0x5799fd0fef9de8e0LL)), ((u64)(0x57d03e29f5c2b18cLL)), ((u64)(0x58044db473335defLL)), ((u64)(0x583961219000356bLL)), ((u64)(0x586fb969f40042c5LL)), ((u64)(0x58a3d3e2388029bbLL)), ((u64)(0x58d8c8dac6a0342aLL)), ((u64)(0x590efb1178484135LL)), ((u64)(0x59435ceaeb2d28c1LL)), ((u64)(0x59783425a5f872f1LL)), ((u64)(0x59ae412f0f768fadLL)), ((u64)(0x59e2e8bd69aa19ccLL)), ((u64)(0x5a17a2ecc414a03fLL)), ((u64)(0x5a4d8ba7f519c84fLL)), | |
| 3250 | +((u64)(0x5a827748f9301d32LL)), ((u64)(0x5ab7151b377c247eLL)), ((u64)(0x5aecda62055b2d9eLL)), ((u64)(0x5b22087d4358fc82LL)), ((u64)(0x5b568a9c942f3ba3LL)), ((u64)(0x5b8c2d43b93b0a8cLL)), ((u64)(0x5bc19c4a53c4e697LL)), ((u64)(0x5bf6035ce8b6203dLL)), ((u64)(0x5c2b843422e3a84dLL)), ((u64)(0x5c6132a095ce4930LL)), ((u64)(0x5c957f48bb41db7cLL)), ((u64)(0x5ccadf1aea12525bLL)), ((u64)(0x5d00cb70d24b7379LL)), ((u64)(0x5d34fe4d06de5057LL)), ((u64)(0x5d6a3de04895e46dLL)), ((u64)(0x5da066ac2d5daec4LL)), | |
| 3251 | +((u64)(0x5dd4805738b51a75LL)), ((u64)(0x5e09a06d06e26112LL)), ((u64)(0x5e400444244d7cabLL)), ((u64)(0x5e7405552d60dbd6LL)), ((u64)(0x5ea906aa78b912ccLL)), ((u64)(0x5edf485516e7577fLL)), ((u64)(0x5f138d352e5096afLL)), ((u64)(0x5f48708279e4bc5bLL)), ((u64)(0x5f7e8ca3185deb72LL)), ((u64)(0x5fb317e5ef3ab327LL)), ((u64)(0x5fe7dddf6b095ff1LL)), ((u64)(0x601dd55745cbb7edLL)), ((u64)(0x6052a5568b9f52f4LL)), ((u64)(0x60874eac2e8727b1LL)), ((u64)(0x60bd22573a28f19dLL)), ((u64)(0x60f2357684599702LL)), | |
| 3252 | +((u64)(0x6126c2d4256ffcc3LL)), ((u64)(0x615c73892ecbfbf4LL)), ((u64)(0x6191c835bd3f7d78LL)), ((u64)(0x61c63a432c8f5cd6LL)), ((u64)(0x61fbc8d3f7b3340cLL)), ((u64)(0x62315d847ad00087LL)), ((u64)(0x6265b4e5998400a9LL)), ((u64)(0x629b221effe500d4LL)), ((u64)(0x62d0f5535fef2084LL)), ((u64)(0x630532a837eae8a5LL)), ((u64)(0x633a7f5245e5a2cfLL)), ((u64)(0x63708f936baf85c1LL)), ((u64)(0x63a4b378469b6732LL)), ((u64)(0x63d9e056584240feLL)), ((u64)(0x64102c35f729689fLL)), ((u64)(0x6444374374f3c2c6LL)), | |
| 3253 | +((u64)(0x647945145230b378LL)), ((u64)(0x64af965966bce056LL)), ((u64)(0x64e3bdf7e0360c36LL)), ((u64)(0x6518ad75d8438f43LL)), ((u64)(0x654ed8d34e547314LL)), ((u64)(0x6583478410f4c7ecLL)), ((u64)(0x65b819651531f9e8LL)), ((u64)(0x65ee1fbe5a7e7861LL)), ((u64)(0x6622d3d6f88f0b3dLL)), ((u64)(0x665788ccb6b2ce0cLL)), ((u64)(0x668d6affe45f818fLL)), ((u64)(0x66c262dfeebbb0f9LL)), ((u64)(0x66f6fb97ea6a9d38LL)), ((u64)(0x672cba7de5054486LL)), ((u64)(0x6761f48eaf234ad4LL)), ((u64)(0x679671b25aec1d89LL)), | |
| 3254 | +((u64)(0x67cc0e1ef1a724ebLL)), ((u64)(0x680188d357087713LL)), ((u64)(0x6835eb082cca94d7LL)), ((u64)(0x686b65ca37fd3a0dLL)), ((u64)(0x68a11f9e62fe4448LL)), ((u64)(0x68d56785fbbdd55aLL)), ((u64)(0x690ac1677aad4ab1LL)), ((u64)(0x6940b8e0acac4eafLL)), ((u64)(0x6974e718d7d7625aLL)), ((u64)(0x69aa20df0dcd3af1LL)), ((u64)(0x69e0548b68a044d6LL)), ((u64)(0x6a1469ae42c8560cLL)), ((u64)(0x6a498419d37a6b8fLL)), ((u64)(0x6a7fe52048590673LL)), ((u64)(0x6ab3ef342d37a408LL)), ((u64)(0x6ae8eb0138858d0aLL)), | |
| 3255 | +((u64)(0x6b1f25c186a6f04cLL)), ((u64)(0x6b537798f4285630LL)), ((u64)(0x6b88557f31326bbbLL)), ((u64)(0x6bbe6adefd7f06aaLL)), ((u64)(0x6bf302cb5e6f642aLL)), ((u64)(0x6c27c37e360b3d35LL)), ((u64)(0x6c5db45dc38e0c82LL)), ((u64)(0x6c9290ba9a38c7d1LL)), ((u64)(0x6cc734e940c6f9c6LL)), ((u64)(0x6cfd022390f8b837LL)), ((u64)(0x6d3221563a9b7323LL)), ((u64)(0x6d66a9abc9424febLL)), ((u64)(0x6d9c5416bb92e3e6LL)), ((u64)(0x6dd1b48e353bce70LL)), ((u64)(0x6e0621b1c28ac20cLL)), ((u64)(0x6e3baa1e332d728fLL)), | |
| 3256 | +((u64)(0x6e714a52dffc6799LL)), ((u64)(0x6ea59ce797fb817fLL)), ((u64)(0x6edb04217dfa61dfLL)), ((u64)(0x6f10e294eebc7d2cLL)), ((u64)(0x6f451b3a2a6b9c76LL)), ((u64)(0x6f7a6208b5068394LL)), ((u64)(0x6fb07d457124123dLL)), ((u64)(0x6fe49c96cd6d16ccLL)), ((u64)(0x7019c3bc80c85c7fLL)), ((u64)(0x70501a55d07d39cfLL)), ((u64)(0x708420eb449c8843LL)), ((u64)(0x70b9292615c3aa54LL)), ((u64)(0x70ef736f9b3494e9LL)), ((u64)(0x7123a825c100dd11LL)), ((u64)(0x7158922f31411456LL)), ((u64)(0x718eb6bafd91596bLL)), | |
| 3257 | +((u64)(0x71c33234de7ad7e3LL)), ((u64)(0x71f7fec216198ddcLL)), ((u64)(0x722dfe729b9ff153LL)), ((u64)(0x7262bf07a143f6d4LL)), ((u64)(0x72976ec98994f489LL)), ((u64)(0x72cd4a7bebfa31abLL)), ((u64)(0x73024e8d737c5f0bLL)), ((u64)(0x7336e230d05b76cdLL)), ((u64)(0x736c9abd04725481LL)), ((u64)(0x73a1e0b622c774d0LL)), ((u64)(0x73d658e3ab795204LL)), ((u64)(0x740bef1c9657a686LL)), ((u64)(0x74417571ddf6c814LL)), ((u64)(0x7475d2ce55747a18LL)), ((u64)(0x74ab4781ead1989eLL)), ((u64)(0x74e10cb132c2ff63LL)), | |
| 3258 | +((u64)(0x75154fdd7f73bf3cLL)), ((u64)(0x754aa3d4df50af0bLL)), ((u64)(0x7580a6650b926d67LL)), ((u64)(0x75b4cffe4e7708c0LL)), ((u64)(0x75ea03fde214caf1LL)), ((u64)(0x7620427ead4cfed6LL)), ((u64)(0x7654531e58a03e8cLL)), ((u64)(0x768967e5eec84e2fLL)), ((u64)(0x76bfc1df6a7a61bbLL)), ((u64)(0x76f3d92ba28c7d15LL)), ((u64)(0x7728cf768b2f9c5aLL)), ((u64)(0x775f03542dfb8370LL)), ((u64)(0x779362149cbd3226LL)), ((u64)(0x77c83a99c3ec7eb0LL)), ((u64)(0x77fe494034e79e5cLL)), ((u64)(0x7832edc82110c2f9LL)), | |
| 3259 | +((u64)(0x7867a93a2954f3b8LL)), ((u64)(0x789d9388b3aa30a5LL)), ((u64)(0x78d27c35704a5e67LL)), ((u64)(0x79071b42cc5cf601LL)), ((u64)(0x793ce2137f743382LL)), ((u64)(0x79720d4c2fa8a031LL)), ((u64)(0x79a6909f3b92c83dLL)), ((u64)(0x79dc34c70a777a4dLL)), ((u64)(0x7a11a0fc668aac70LL)), ((u64)(0x7a46093b802d578cLL)), ((u64)(0x7a7b8b8a6038ad6fLL)), ((u64)(0x7ab137367c236c65LL)), ((u64)(0x7ae585041b2c477fLL)), ((u64)(0x7b1ae64521f7595eLL)), ((u64)(0x7b50cfeb353a97dbLL)), ((u64)(0x7b8503e602893dd2LL)), | |
| 3260 | +((u64)(0x7bba44df832b8d46LL)), ((u64)(0x7bf06b0bb1fb384cLL)), ((u64)(0x7c2485ce9e7a065fLL)), ((u64)(0x7c59a742461887f6LL)), ((u64)(0x7c9008896bcf54faLL)), ((u64)(0x7cc40aabc6c32a38LL)), ((u64)(0x7cf90d56b873f4c7LL)), ((u64)(0x7d2f50ac6690f1f8LL)), ((u64)(0x7d63926bc01a973bLL)), ((u64)(0x7d987706b0213d0aLL)), ((u64)(0x7dce94c85c298c4cLL)), ((u64)(0x7e031cfd3999f7b0LL)), ((u64)(0x7e37e43c8800759cLL)), ((u64)(0x7e6ddd4baa009303LL)), ((u64)(0x7ea2aa4f4a405be2LL)), ((u64)(0x7ed754e31cd072daLL)), ((u64)(0x7f0d2a1be4048f90LL)), ((u64)(0x7f423a516e82d9baLL)), ((u64)(0x7f76c8e5ca239029LL)), ((u64)(0x7fac7b1f3cac7433LL)), ((u64)(0x7fe1ccf385ebc8a0LL))}; // fixed array const | |
| 3261 | +static Array_fixed_u64_324 _const_strconv__neg_exp = {((u64)(0x3ff0000000000000LL)), ((u64)(0x3fb999999999999aLL)), ((u64)(0x3f847ae147ae147bLL)), ((u64)(0x3f50624dd2f1a9fcLL)), ((u64)(0x3f1a36e2eb1c432dLL)), ((u64)(0x3ee4f8b588e368f1LL)), ((u64)(0x3eb0c6f7a0b5ed8dLL)), ((u64)(0x3e7ad7f29abcaf48LL)), ((u64)(0x3e45798ee2308c3aLL)), ((u64)(0x3e112e0be826d695LL)), ((u64)(0x3ddb7cdfd9d7bdbbLL)), ((u64)(0x3da5fd7fe1796495LL)), ((u64)(0x3d719799812dea11LL)), ((u64)(0x3d3c25c268497682LL)), ((u64)(0x3d06849b86a12b9bLL)), ((u64)(0x3cd203af9ee75616LL)), | |
| 3262 | +((u64)(0x3c9cd2b297d889bcLL)), ((u64)(0x3c670ef54646d497LL)), ((u64)(0x3c32725dd1d243acLL)), ((u64)(0x3bfd83c94fb6d2acLL)), ((u64)(0x3bc79ca10c924223LL)), ((u64)(0x3b92e3b40a0e9b4fLL)), ((u64)(0x3b5e392010175ee6LL)), ((u64)(0x3b282db34012b251LL)), ((u64)(0x3af357c299a88ea7LL)), ((u64)(0x3abef2d0f5da7dd9LL)), ((u64)(0x3a88c240c4aecb14LL)), ((u64)(0x3a53ce9a36f23c10LL)), ((u64)(0x3a1fb0f6be506019LL)), ((u64)(0x39e95a5efea6b347LL)), ((u64)(0x39b4484bfeebc2a0LL)), ((u64)(0x398039d665896880LL)), | |
| 3263 | +((u64)(0x3949f623d5a8a733LL)), ((u64)(0x3914c4e977ba1f5cLL)), ((u64)(0x38e09d8792fb4c49LL)), ((u64)(0x38aa95a5b7f87a0fLL)), ((u64)(0x38754484932d2e72LL)), ((u64)(0x3841039d428a8b8fLL)), ((u64)(0x380b38fb9daa78e4LL)), ((u64)(0x37d5c72fb1552d83LL)), ((u64)(0x37a16c262777579cLL)), ((u64)(0x376be03d0bf225c7LL)), ((u64)(0x37364cfda3281e39LL)), ((u64)(0x3701d7314f534b61LL)), ((u64)(0x36cc8b8218854567LL)), ((u64)(0x3696d601ad376ab9LL)), ((u64)(0x366244ce242c5561LL)), ((u64)(0x362d3ae36d13bbceLL)), | |
| 3264 | +((u64)(0x35f7624f8a762fd8LL)), ((u64)(0x35c2b50c6ec4f313LL)), ((u64)(0x358dee7a4ad4b81fLL)), ((u64)(0x3557f1fb6f10934cLL)), ((u64)(0x352327fc58da0f70LL)), ((u64)(0x34eea6608e29b24dLL)), ((u64)(0x34b8851a0b548ea4LL)), ((u64)(0x34839dae6f76d883LL)), ((u64)(0x344f62b0b257c0d2LL)), ((u64)(0x34191bc08eac9a41LL)), ((u64)(0x33e41633a556e1ceLL)), ((u64)(0x33b011c2eaabe7d8LL)), ((u64)(0x3379b604aaaca626LL)), ((u64)(0x3344919d5556eb52LL)), ((u64)(0x3310747ddddf22a8LL)), ((u64)(0x32da53fc9631d10dLL)), | |
| 3265 | +((u64)(0x32a50ffd44f4a73dLL)), ((u64)(0x3270d9976a5d5297LL)), ((u64)(0x323af5bf109550f2LL)), ((u64)(0x32059165a6ddda5bLL)), ((u64)(0x31d1411e1f17e1e3LL)), ((u64)(0x319b9b6364f30304LL)), ((u64)(0x316615e91d8f359dLL)), ((u64)(0x3131ab20e472914aLL)), ((u64)(0x30fc45016d841baaLL)), ((u64)(0x30c69d9abe034955LL)), ((u64)(0x309217aefe690777LL)), ((u64)(0x305cf2b1970e7258LL)), ((u64)(0x3027288e1271f513LL)), ((u64)(0x2ff286d80ec190dcLL)), ((u64)(0x2fbda48ce468e7c7LL)), ((u64)(0x2f87b6d71d20b96cLL)), | |
| 3266 | +((u64)(0x2f52f8ac174d6123LL)), ((u64)(0x2f1e5aacf2156838LL)), ((u64)(0x2ee8488a5b445360LL)), ((u64)(0x2eb36d3b7c36a91aLL)), ((u64)(0x2e7f152bf9f10e90LL)), ((u64)(0x2e48ddbcc7f40ba6LL)), ((u64)(0x2e13e497065cd61fLL)), ((u64)(0x2ddfd424d6faf031LL)), ((u64)(0x2da97683df2f268dLL)), ((u64)(0x2d745ecfe5bf520bLL)), ((u64)(0x2d404bd984990e6fLL)), ((u64)(0x2d0a12f5a0f4e3e5LL)), ((u64)(0x2cd4dbf7b3f71cb7LL)), ((u64)(0x2ca0aff95cc5b092LL)), ((u64)(0x2c6ab328946f80eaLL)), ((u64)(0x2c355c2076bf9a55LL)), | |
| 3267 | +((u64)(0x2c0116805effaeaaLL)), ((u64)(0x2bcb5733cb32b111LL)), ((u64)(0x2b95df5ca28ef40dLL)), ((u64)(0x2b617f7d4ed8c33eLL)), ((u64)(0x2b2bff2ee48e0530LL)), ((u64)(0x2af665bf1d3e6a8dLL)), ((u64)(0x2ac1eaff4a98553dLL)), ((u64)(0x2a8cab3210f3bb95LL)), ((u64)(0x2a56ef5b40c2fc77LL)), ((u64)(0x2a225915cd68c9f9LL)), ((u64)(0x29ed5b561574765bLL)), ((u64)(0x29b77c44ddf6c516LL)), ((u64)(0x2982c9d0b1923745LL)), ((u64)(0x294e0fb44f50586eLL)), ((u64)(0x29180c903f7379f2LL)), ((u64)(0x28e33d4032c2c7f5LL)), | |
| 3268 | +((u64)(0x28aec866b79e0cbaLL)), ((u64)(0x2878a0522c7e7095LL)), ((u64)(0x2843b374f06526deLL)), ((u64)(0x280f8587e7083e30LL)), ((u64)(0x27d9379fec069826LL)), ((u64)(0x27a42c7ff0054685LL)), ((u64)(0x277023998cd10537LL)), ((u64)(0x2739d28f47b4d525LL)), ((u64)(0x2704a8729fc3ddb7LL)), ((u64)(0x26d086c219697e2cLL)), ((u64)(0x269a71368f0f3047LL)), ((u64)(0x2665275ed8d8f36cLL)), ((u64)(0x2630ec4be0ad8f89LL)), ((u64)(0x25fb13ac9aaf4c0fLL)), ((u64)(0x25c5a956e225d672LL)), ((u64)(0x2591544581b7dec2LL)), | |
| 3269 | +((u64)(0x255bba08cf8c979dLL)), ((u64)(0x25262e6d72d6dfb0LL)), ((u64)(0x24f1bebdf578b2f4LL)), ((u64)(0x24bc6463225ab7ecLL)), ((u64)(0x2486b6b5b5155ff0LL)), ((u64)(0x24522bc490dde65aLL)), ((u64)(0x241d12d41afca3c3LL)), ((u64)(0x23e7424348ca1c9cLL)), ((u64)(0x23b29b69070816e3LL)), ((u64)(0x237dc574d80cf16bLL)), ((u64)(0x2347d12a4670c123LL)), ((u64)(0x23130dbb6b8d674fLL)), ((u64)(0x22de7c5f127bd87eLL)), ((u64)(0x22a8637f41fcad32LL)), ((u64)(0x227382cc34ca2428LL)), ((u64)(0x223f37ad21436d0cLL)), | |
| 3270 | +((u64)(0x2208f9574dcf8a70LL)), ((u64)(0x21d3faac3e3fa1f3LL)), ((u64)(0x219ff779fd329cb9LL)), ((u64)(0x216992c7fdc216faLL)), ((u64)(0x2134756ccb01abfbLL)), ((u64)(0x21005df0a267bcc9LL)), ((u64)(0x20ca2fe76a3f9475LL)), ((u64)(0x2094f31f8832dd2aLL)), ((u64)(0x2060c27fa028b0efLL)), ((u64)(0x202ad0cc33744e4bLL)), ((u64)(0x1ff573d68f903ea2LL)), ((u64)(0x1fc1297872d9cbb5LL)), ((u64)(0x1f8b758d848fac55LL)), ((u64)(0x1f55f7a46a0c89ddLL)), ((u64)(0x1f2192e9ee706e4bLL)), ((u64)(0x1eec1e43171a4a11LL)), | |
| 3271 | +((u64)(0x1eb67e9c127b6e74LL)), ((u64)(0x1e81fee341fc585dLL)), ((u64)(0x1e4ccb0536608d61LL)), ((u64)(0x1e1708d0f84d3de7LL)), ((u64)(0x1de26d73f9d764b9LL)), ((u64)(0x1dad7becc2f23ac2LL)), ((u64)(0x1d779657025b6235LL)), ((u64)(0x1d42deac01e2b4f7LL)), ((u64)(0x1d0e3113363787f2LL)), ((u64)(0x1cd8274291c6065bLL)), ((u64)(0x1ca3529ba7d19eafLL)), ((u64)(0x1c6eea92a61c3118LL)), ((u64)(0x1c38bba884e35a7aLL)), ((u64)(0x1c03c9539d82aec8LL)), ((u64)(0x1bcfa885c8d117a6LL)), ((u64)(0x1b99539e3a40dfb8LL)), | |
| 3272 | +((u64)(0x1b6442e4fb671960LL)), ((u64)(0x1b303583fc527ab3LL)), ((u64)(0x1af9ef3993b72ab8LL)), ((u64)(0x1ac4bf6142f8eefaLL)), ((u64)(0x1a90991a9bfa58c8LL)), ((u64)(0x1a5a8e90f9908e0dLL)), ((u64)(0x1a253eda614071a4LL)), ((u64)(0x19f0ff151a99f483LL)), ((u64)(0x19bb31bb5dc320d2LL)), ((u64)(0x1985c162b168e70eLL)), ((u64)(0x1951678227871f3eLL)), ((u64)(0x191bd8d03f3e9864LL)), ((u64)(0x18e6470cff6546b6LL)), ((u64)(0x18b1d270cc51055fLL)), ((u64)(0x187c83e7ad4e6efeLL)), ((u64)(0x1846cfec8aa52598LL)), | |
| 3273 | +((u64)(0x18123ff06eea847aLL)), ((u64)(0x17dd331a4b10d3f6LL)), ((u64)(0x17a75c1508da432bLL)), ((u64)(0x1772b010d3e1cf56LL)), ((u64)(0x173de6815302e556LL)), ((u64)(0x1707eb9aa8cf1ddeLL)), ((u64)(0x16d322e220a5b17eLL)), ((u64)(0x169e9e369aa2b597LL)), ((u64)(0x16687e92154ef7acLL)), ((u64)(0x16339874ddd8c623LL)), ((u64)(0x15ff5a549627a36cLL)), ((u64)(0x15c91510781fb5f0LL)), ((u64)(0x159410d9f9b2f7f3LL)), ((u64)(0x15600d7b2e28c65cLL)), ((u64)(0x1529af2b7d0e0a2dLL)), ((u64)(0x14f48c22ca71a1bdLL)), | |
| 3274 | +((u64)(0x14c0701bd527b498LL)), ((u64)(0x148a4cf9550c5426LL)), ((u64)(0x14550a6110d6a9b8LL)), ((u64)(0x1420d51a73deee2dLL)), ((u64)(0x13eaee90b964b047LL)), ((u64)(0x13b58ba6fab6f36cLL)), ((u64)(0x13813c85955f2923LL)), ((u64)(0x134b9408eefea839LL)), ((u64)(0x1316100725988694LL)), ((u64)(0x12e1a66c1e139eddLL)), ((u64)(0x12ac3d79c9b8fe2eLL)), ((u64)(0x12769794a160cb58LL)), ((u64)(0x124212dd4de70913LL)), ((u64)(0x120ceafbafd80e85LL)), ((u64)(0x11d72262f3133ed1LL)), ((u64)(0x11a281e8c275cbdaLL)), | |
| 3275 | +((u64)(0x116d9ca79d89462aLL)), ((u64)(0x1137b08617a104eeLL)), ((u64)(0x1102f39e794d9d8bLL)), ((u64)(0x10ce5297287c2f45LL)), ((u64)(0x1098421286c9bf6bLL)), ((u64)(0x1063680ed23aff89LL)), ((u64)(0x102f0ce4839198dbLL)), ((u64)(0x0ff8d71d360e13e2LL)), ((u64)(0x0fc3df4a91a4dcb5LL)), ((u64)(0x0f8fcbaa82a16121LL)), ((u64)(0x0f596fbb9bb44db4LL)), ((u64)(0x0f245962e2f6a490LL)), ((u64)(0x0ef047824f2bb6daLL)), ((u64)(0x0eba0c03b1df8af6LL)), ((u64)(0x0e84d6695b193bf8LL)), ((u64)(0x0e50ab877c142ffaLL)), | |
| 3276 | +((u64)(0x0e1aac0bf9b9e65cLL)), ((u64)(0x0de5566ffafb1eb0LL)), ((u64)(0x0db111f32f2f4bc0LL)), ((u64)(0x0d7b4feb7eb212cdLL)), ((u64)(0x0d45d98932280f0aLL)), ((u64)(0x0d117ad428200c08LL)), ((u64)(0x0cdbf7b9d9cce00dLL)), ((u64)(0x0ca65fc7e170b33eLL)), ((u64)(0x0c71e6398126f5cbLL)), ((u64)(0x0c3ca38f350b22dfLL)), ((u64)(0x0c06e93f5da2824cLL)), ((u64)(0x0bd25432b14ecea3LL)), ((u64)(0x0b9d53844ee47dd1LL)), ((u64)(0x0b677603725064a8LL)), ((u64)(0x0b32c4cf8ea6b6ecLL)), ((u64)(0x0afe07b27dd78b14LL)), | |
| 3277 | +((u64)(0x0ac8062864ac6f43LL)), ((u64)(0x0a9338205089f29cLL)), ((u64)(0x0a5ec033b40fea93LL)), ((u64)(0x0a2899c2f6732210LL)), ((u64)(0x09f3ae3591f5b4d9LL)), ((u64)(0x09bf7d228322baf5LL)), ((u64)(0x098930e868e89591LL)), ((u64)(0x0954272053ed4474LL)), ((u64)(0x09201f4d0ff10390LL)), ((u64)(0x08e9cbae7fe805b3LL)), ((u64)(0x08b4a2f1ffecd15cLL)), ((u64)(0x0880825b3323dab0LL)), ((u64)(0x084a6a2b85062ab3LL)), ((u64)(0x081521bc6a6b555cLL)), ((u64)(0x07e0e7c9eebc444aLL)), ((u64)(0x07ab0c764ac6d3a9LL)), | |
| 3278 | +((u64)(0x0775a391d56bdc87LL)), ((u64)(0x07414fa7ddefe3a0LL)), ((u64)(0x070bb2a62fe638ffLL)), ((u64)(0x06d62884f31e93ffLL)), ((u64)(0x06a1ba03f5b21000LL)), ((u64)(0x066c5cd322b67fffLL)), ((u64)(0x0636b0a8e891ffffLL)), ((u64)(0x060226ed86db3333LL)), ((u64)(0x05cd0b15a491eb84LL)), ((u64)(0x05973c115074bc6aLL)), ((u64)(0x05629674405d6388LL)), ((u64)(0x052dbd86cd6238d9LL)), ((u64)(0x04f7cad23de82d7bLL)), ((u64)(0x04c308a831868ac9LL)), ((u64)(0x048e74404f3daadbLL)), ((u64)(0x04585d003f6488afLL)), | |
| 3279 | +((u64)(0x04237d99cc506d59LL)), ((u64)(0x03ef2f5c7a1a488eLL)), ((u64)(0x03b8f2b061aea072LL)), ((u64)(0x0383f559e7bee6c1LL)), ((u64)(0x034feef63f97d79cLL)), ((u64)(0x03198bf832dfdfb0LL)), ((u64)(0x02e46ff9c24cb2f3LL)), ((u64)(0x02b059949b708f29LL)), ((u64)(0x027a28edc580e50eLL)), ((u64)(0x0244ed8b04671da5LL)), ((u64)(0x0210be08d0527e1dLL)), ((u64)(0x01dac9a7b3b7302fLL)), ((u64)(0x01a56e1fc2f8f359LL)), ((u64)(0x017124e63593f5e1LL)), ((u64)(0x013b6e3d22865634LL)), ((u64)(0x0105f1ca820511c3LL)), | |
| 3280 | +((u64)(0x00d18e3b9b374169LL)), ((u64)(0x009c16c5c5253575LL)), ((u64)(0x0066789e3750f791LL)), ((u64)(0x0031fa182c40c60dLL)), ((u64)(0x000730d67819e8d2LL)), ((u64)(0x0000b8157268fdafLL)), ((u64)(0x000012688b70e62bLL)), ((u64)(0x000001d74124e3d1LL)), ((u64)(0x0000002f201d49fbLL)), ((u64)(0x00000004b6695433LL)), ((u64)(0x0000000078a42205)), ((u64)(0x000000000c1069cd)), ((u64)(0x000000000134d761)), ((u64)(0x00000000001ee257)), ((u64)(0x00000000000316a2)), ((u64)(0x0000000000004f10)), ((u64)(0x00000000000007e8)), ((u64)(0x00000000000000ca)), ((u64)(0x0000000000000014)), ((u64)(0x0000000000000002))}; // fixed array const | |
| 3281 | +static i64 _const_strconv__i64_min_int32; // inited later | |
| 3282 | +static i64 _const_strconv__i64_max_int32; // inited later | |
| 3283 | +static Array_fixed_u32_10 _const_strconv__ten_pow_table_32 = {((u32)(1)), ((u32)(10)), ((u32)(100)), ((u32)(1000)), ((u32)(10000)), ((u32)(100000)), ((u32)(1000000)), ((u32)(10000000)), ((u32)(100000000)), ((u32)(1000000000))}; // fixed array const | |
| 3284 | +static const u32 _const_strconv__mantbits32 = 23; // precomputed2 | |
| 3285 | +static const u32 _const_strconv__expbits32 = 8; // precomputed2 | |
| 3286 | +static Array_fixed_u64_20 _const_strconv__ten_pow_table_64 = {((u64)(1)), ((u64)(10)), ((u64)(100)), ((u64)(1000)), ((u64)(10000)), ((u64)(100000)), ((u64)(1000000)), ((u64)(10000000)), ((u64)(100000000)), ((u64)(1000000000)), ((u64)(10000000000LL)), ((u64)(100000000000LL)), ((u64)(1000000000000LL)), ((u64)(10000000000000LL)), ((u64)(100000000000000LL)), ((u64)(1000000000000000LL)), ((u64)(10000000000000000LL)), ((u64)(100000000000000000LL)), ((u64)(1000000000000000000LL)), ((u64)(10000000000000000000ULL))}; // fixed array const | |
| 3287 | +static const u32 _const_strconv__mantbits64 = 52; // precomputed2 | |
| 3288 | +static const u32 _const_strconv__expbits64 = 11; // precomputed2 | |
| 3289 | +static Array_fixed_f64_36 _const_strconv__dec_round = {((f64)(0.5)), 0.05, 0.005, 0.0005, 0.00005, 0.000005, 0.0000005, 0.00000005, 0.000000005, 0.0000000005, 0.00000000005, 0.000000000005, 0.0000000000005, 0.00000000000005, 0.000000000000005, 0.0000000000000005, | |
| 3290 | +0.00000000000000005, 0.000000000000000005, 0.0000000000000000005, 0.00000000000000000005, 0.000000000000000000005, 0.0000000000000000000005, 0.00000000000000000000005, 0.000000000000000000000005, 0.0000000000000000000000005, 0.00000000000000000000000005, 0.000000000000000000000000005, 0.0000000000000000000000000005, 0.00000000000000000000000000005, 0.000000000000000000000000000005, 0.0000000000000000000000000000005, 0.00000000000000000000000000000005, 0.000000000000000000000000000000005, 0.0000000000000000000000000000000005, 0.00000000000000000000000000000000005, 0.000000000000000000000000000000000005}; // fixed array const | |
| 3291 | +static Array_fixed_u64_47 _const_strconv__pow5_split_32 = {((u64)(1152921504606846976LL)), ((u64)(1441151880758558720LL)), ((u64)(1801439850948198400LL)), ((u64)(2251799813685248000LL)), ((u64)(1407374883553280000LL)), ((u64)(1759218604441600000LL)), ((u64)(2199023255552000000LL)), ((u64)(1374389534720000000LL)), ((u64)(1717986918400000000LL)), ((u64)(2147483648000000000LL)), ((u64)(1342177280000000000LL)), ((u64)(1677721600000000000LL)), ((u64)(2097152000000000000LL)), ((u64)(1310720000000000000LL)), ((u64)(1638400000000000000LL)), ((u64)(2048000000000000000LL)), | |
| 3292 | +((u64)(1280000000000000000LL)), ((u64)(1600000000000000000LL)), ((u64)(2000000000000000000LL)), ((u64)(1250000000000000000LL)), ((u64)(1562500000000000000LL)), ((u64)(1953125000000000000LL)), ((u64)(1220703125000000000LL)), ((u64)(1525878906250000000LL)), ((u64)(1907348632812500000LL)), ((u64)(1192092895507812500LL)), ((u64)(1490116119384765625LL)), ((u64)(1862645149230957031LL)), ((u64)(1164153218269348144LL)), ((u64)(1455191522836685180LL)), ((u64)(1818989403545856475LL)), ((u64)(2273736754432320594LL)), | |
| 3293 | +((u64)(1421085471520200371LL)), ((u64)(1776356839400250464LL)), ((u64)(2220446049250313080LL)), ((u64)(1387778780781445675LL)), ((u64)(1734723475976807094LL)), ((u64)(2168404344971008868LL)), ((u64)(1355252715606880542LL)), ((u64)(1694065894508600678LL)), ((u64)(2117582368135750847LL)), ((u64)(1323488980084844279LL)), ((u64)(1654361225106055349LL)), ((u64)(2067951531382569187LL)), ((u64)(1292469707114105741LL)), ((u64)(1615587133892632177LL)), ((u64)(2019483917365790221LL))}; // fixed array const | |
| 3294 | +static Array_fixed_u64_31 _const_strconv__pow5_inv_split_32 = {((u64)(576460752303423489LL)), ((u64)(461168601842738791LL)), ((u64)(368934881474191033LL)), ((u64)(295147905179352826LL)), ((u64)(472236648286964522LL)), ((u64)(377789318629571618LL)), ((u64)(302231454903657294LL)), ((u64)(483570327845851670LL)), ((u64)(386856262276681336LL)), ((u64)(309485009821345069LL)), ((u64)(495176015714152110LL)), ((u64)(396140812571321688LL)), ((u64)(316912650057057351LL)), ((u64)(507060240091291761LL)), ((u64)(405648192073033409LL)), ((u64)(324518553658426727LL)), | |
| 3295 | +((u64)(519229685853482763LL)), ((u64)(415383748682786211LL)), ((u64)(332306998946228969LL)), ((u64)(531691198313966350LL)), ((u64)(425352958651173080LL)), ((u64)(340282366920938464LL)), ((u64)(544451787073501542LL)), ((u64)(435561429658801234LL)), ((u64)(348449143727040987LL)), ((u64)(557518629963265579LL)), ((u64)(446014903970612463LL)), ((u64)(356811923176489971LL)), ((u64)(570899077082383953LL)), ((u64)(456719261665907162LL)), ((u64)(365375409332725730LL))}; // fixed array const | |
| 3296 | +static Array_fixed_u64_652 _const_strconv__pow5_split_64_x = {((u64)(0x0000000000000000)), ((u64)(0x0100000000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x0140000000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x0190000000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01f4000000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x0138800000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x0186a00000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01e8480000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01312d0000000000LL)), | |
| 3297 | +((u64)(0x0000000000000000)), ((u64)(0x017d784000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01dcd65000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x012a05f200000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x0174876e80000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01d1a94a20000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x012309ce54000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x016bcc41e9000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01c6bf5263400000LL)), | |
| 3298 | +((u64)(0x0000000000000000)), ((u64)(0x011c37937e080000LL)), ((u64)(0x0000000000000000)), ((u64)(0x016345785d8a0000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01bc16d674ec8000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01158e460913d000LL)), ((u64)(0x0000000000000000)), ((u64)(0x015af1d78b58c400LL)), ((u64)(0x0000000000000000)), ((u64)(0x01b1ae4d6e2ef500LL)), ((u64)(0x0000000000000000)), ((u64)(0x010f0cf064dd5920LL)), ((u64)(0x0000000000000000)), ((u64)(0x0152d02c7e14af68LL)), | |
| 3299 | +((u64)(0x0000000000000000)), ((u64)(0x01a784379d99db42LL)), ((u64)(0x4000000000000000LL)), ((u64)(0x0108b2a2c2802909LL)), ((u64)(0x9000000000000000ULL)), ((u64)(0x014adf4b7320334bLL)), ((u64)(0x7400000000000000LL)), ((u64)(0x019d971e4fe8401eLL)), ((u64)(0x0880000000000000LL)), ((u64)(0x01027e72f1f12813LL)), ((u64)(0xcaa0000000000000ULL)), ((u64)(0x01431e0fae6d7217LL)), ((u64)(0xbd48000000000000ULL)), ((u64)(0x0193e5939a08ce9dLL)), ((u64)(0x2c9a000000000000LL)), ((u64)(0x01f8def8808b0245LL)), | |
| 3300 | +((u64)(0x3be0400000000000LL)), ((u64)(0x013b8b5b5056e16bLL)), ((u64)(0x0ad8500000000000LL)), ((u64)(0x018a6e32246c99c6LL)), ((u64)(0x8d8e640000000000ULL)), ((u64)(0x01ed09bead87c037LL)), ((u64)(0xb878fe8000000000ULL)), ((u64)(0x013426172c74d822LL)), ((u64)(0x66973e2000000000LL)), ((u64)(0x01812f9cf7920e2bLL)), ((u64)(0x403d0da800000000LL)), ((u64)(0x01e17b84357691b6LL)), ((u64)(0xe826288900000000ULL)), ((u64)(0x012ced32a16a1b11LL)), ((u64)(0x622fb2ab40000000LL)), ((u64)(0x0178287f49c4a1d6LL)), | |
| 3301 | +((u64)(0xfabb9f5610000000ULL)), ((u64)(0x01d6329f1c35ca4bLL)), ((u64)(0x7cb54395ca000000LL)), ((u64)(0x0125dfa371a19e6fLL)), ((u64)(0x5be2947b3c800000LL)), ((u64)(0x016f578c4e0a060bLL)), ((u64)(0x32db399a0ba00000LL)), ((u64)(0x01cb2d6f618c878eLL)), ((u64)(0xdfc9040047440000ULL)), ((u64)(0x011efc659cf7d4b8LL)), ((u64)(0x17bb450059150000LL)), ((u64)(0x0166bb7f0435c9e7LL)), ((u64)(0xddaa16406f5a4000ULL)), ((u64)(0x01c06a5ec5433c60LL)), ((u64)(0x8a8a4de845986800ULL)), ((u64)(0x0118427b3b4a05bcLL)), | |
| 3302 | +((u64)(0xad2ce16256fe8200ULL)), ((u64)(0x015e531a0a1c872bLL)), ((u64)(0x987819baecbe2280ULL)), ((u64)(0x01b5e7e08ca3a8f6LL)), ((u64)(0x1f4b1014d3f6d590LL)), ((u64)(0x0111b0ec57e6499aLL)), ((u64)(0xa71dd41a08f48af4ULL)), ((u64)(0x01561d276ddfdc00LL)), ((u64)(0xd0e549208b31adb1ULL)), ((u64)(0x01aba4714957d300LL)), ((u64)(0x828f4db456ff0c8eULL)), ((u64)(0x010b46c6cdd6e3e0LL)), ((u64)(0xa33321216cbecfb2ULL)), ((u64)(0x014e1878814c9cd8LL)), ((u64)(0xcbffe969c7ee839eULL)), ((u64)(0x01a19e96a19fc40eLL)), | |
| 3303 | +((u64)(0x3f7ff1e21cf51243LL)), ((u64)(0x0105031e2503da89LL)), ((u64)(0x8f5fee5aa43256d4ULL)), ((u64)(0x014643e5ae44d12bLL)), ((u64)(0x7337e9f14d3eec89LL)), ((u64)(0x0197d4df19d60576LL)), ((u64)(0x1005e46da08ea7abLL)), ((u64)(0x01fdca16e04b86d4LL)), ((u64)(0x8a03aec4845928cbULL)), ((u64)(0x013e9e4e4c2f3444LL)), ((u64)(0xac849a75a56f72fdULL)), ((u64)(0x018e45e1df3b0155LL)), ((u64)(0x17a5c1130ecb4fbdLL)), ((u64)(0x01f1d75a5709c1abLL)), ((u64)(0xeec798abe93f11d6ULL)), ((u64)(0x013726987666190aLL)), | |
| 3304 | +((u64)(0xaa797ed6e38ed64bULL)), ((u64)(0x0184f03e93ff9f4dLL)), ((u64)(0x1517de8c9c728bdeLL)), ((u64)(0x01e62c4e38ff8721LL)), ((u64)(0xad2eeb17e1c7976bULL)), ((u64)(0x012fdbb0e39fb474LL)), ((u64)(0xd87aa5ddda397d46ULL)), ((u64)(0x017bd29d1c87a191LL)), ((u64)(0x4e994f5550c7dc97LL)), ((u64)(0x01dac74463a989f6LL)), ((u64)(0xf11fd195527ce9deULL)), ((u64)(0x0128bc8abe49f639LL)), ((u64)(0x6d67c5faa71c2456LL)), ((u64)(0x0172ebad6ddc73c8LL)), ((u64)(0x88c1b77950e32d6cULL)), ((u64)(0x01cfa698c95390baLL)), | |
| 3305 | +((u64)(0x957912abd28dfc63ULL)), ((u64)(0x0121c81f7dd43a74LL)), ((u64)(0xbad75756c7317b7cULL)), ((u64)(0x016a3a275d494911LL)), ((u64)(0x298d2d2c78fdda5bLL)), ((u64)(0x01c4c8b1349b9b56LL)), ((u64)(0xd9f83c3bcb9ea879ULL)), ((u64)(0x011afd6ec0e14115LL)), ((u64)(0x50764b4abe865297LL)), ((u64)(0x0161bcca7119915bLL)), ((u64)(0x2493de1d6e27e73dLL)), ((u64)(0x01ba2bfd0d5ff5b2LL)), ((u64)(0x56dc6ad264d8f086LL)), ((u64)(0x01145b7e285bf98fLL)), ((u64)(0x2c938586fe0f2ca8LL)), ((u64)(0x0159725db272f7f3LL)), | |
| 3306 | +((u64)(0xf7b866e8bd92f7d2ULL)), ((u64)(0x01afcef51f0fb5efLL)), ((u64)(0xfad34051767bdae3ULL)), ((u64)(0x010de1593369d1b5LL)), ((u64)(0x79881065d41ad19cLL)), ((u64)(0x015159af80444623LL)), ((u64)(0x57ea147f49218603LL)), ((u64)(0x01a5b01b605557acLL)), ((u64)(0xb6f24ccf8db4f3c1ULL)), ((u64)(0x01078e111c3556cbLL)), ((u64)(0xa4aee003712230b2ULL)), ((u64)(0x014971956342ac7eLL)), ((u64)(0x4dda98044d6abcdfLL)), ((u64)(0x019bcdfabc13579eLL)), ((u64)(0xf0a89f02b062b60bULL)), ((u64)(0x010160bcb58c16c2LL)), | |
| 3307 | +((u64)(0xacd2c6c35c7b638eULL)), ((u64)(0x0141b8ebe2ef1c73LL)), ((u64)(0x98077874339a3c71ULL)), ((u64)(0x01922726dbaae390LL)), ((u64)(0xbe0956914080cb8eULL)), ((u64)(0x01f6b0f092959c74LL)), ((u64)(0xf6c5d61ac8507f38ULL)), ((u64)(0x013a2e965b9d81c8LL)), ((u64)(0x34774ba17a649f07LL)), ((u64)(0x0188ba3bf284e23bLL)), ((u64)(0x01951e89d8fdc6c8LL)), ((u64)(0x01eae8caef261acaLL)), ((u64)(0x40fd3316279e9c3dLL)), ((u64)(0x0132d17ed577d0beLL)), ((u64)(0xd13c7fdbb186434cULL)), ((u64)(0x017f85de8ad5c4edLL)), | |
| 3308 | +((u64)(0x458b9fd29de7d420LL)), ((u64)(0x01df67562d8b3629LL)), ((u64)(0xcb7743e3a2b0e494ULL)), ((u64)(0x012ba095dc7701d9LL)), ((u64)(0x3e5514dc8b5d1db9LL)), ((u64)(0x017688bb5394c250LL)), ((u64)(0x4dea5a13ae346527LL)), ((u64)(0x01d42aea2879f2e4LL)), ((u64)(0xb0b2784c4ce0bf38ULL)), ((u64)(0x01249ad2594c37ceLL)), ((u64)(0x5cdf165f6018ef06LL)), ((u64)(0x016dc186ef9f45c2LL)), ((u64)(0xf416dbf7381f2ac8ULL)), ((u64)(0x01c931e8ab871732LL)), ((u64)(0xd88e497a83137abdULL)), ((u64)(0x011dbf316b346e7fLL)), | |
| 3309 | +((u64)(0xceb1dbd923d8596cULL)), ((u64)(0x01652efdc6018a1fLL)), ((u64)(0xc25e52cf6cce6fc7ULL)), ((u64)(0x01be7abd3781eca7LL)), ((u64)(0xd97af3c1a40105dcULL)), ((u64)(0x01170cb642b133e8LL)), ((u64)(0x0fd9b0b20d014754LL)), ((u64)(0x015ccfe3d35d80e3LL)), ((u64)(0xd3d01cde90419929ULL)), ((u64)(0x01b403dcc834e11bLL)), ((u64)(0x6462120b1a28ffb9LL)), ((u64)(0x01108269fd210cb1LL)), ((u64)(0xbd7a968de0b33fa8ULL)), ((u64)(0x0154a3047c694fddLL)), ((u64)(0x2cd93c3158e00f92LL)), ((u64)(0x01a9cbc59b83a3d5LL)), | |
| 3310 | +((u64)(0x3c07c59ed78c09bbLL)), ((u64)(0x010a1f5b81324665LL)), ((u64)(0x8b09b7068d6f0c2aULL)), ((u64)(0x014ca732617ed7feLL)), ((u64)(0x2dcc24c830cacf34LL)), ((u64)(0x019fd0fef9de8dfeLL)), ((u64)(0xdc9f96fd1e7ec180ULL)), ((u64)(0x0103e29f5c2b18beLL)), ((u64)(0x93c77cbc661e71e1ULL)), ((u64)(0x0144db473335deeeLL)), ((u64)(0x38b95beb7fa60e59LL)), ((u64)(0x01961219000356aaLL)), ((u64)(0xc6e7b2e65f8f91efULL)), ((u64)(0x01fb969f40042c54LL)), ((u64)(0xfc50cfcffbb9bb35ULL)), ((u64)(0x013d3e2388029bb4LL)), | |
| 3311 | +((u64)(0x3b6503c3faa82a03LL)), ((u64)(0x018c8dac6a0342a2LL)), ((u64)(0xca3e44b4f9523484ULL)), ((u64)(0x01efb1178484134aLL)), ((u64)(0xbe66eaf11bd360d2ULL)), ((u64)(0x0135ceaeb2d28c0eLL)), ((u64)(0x6e00a5ad62c83907LL)), ((u64)(0x0183425a5f872f12LL)), ((u64)(0x0980cf18bb7a4749LL)), ((u64)(0x01e412f0f768fad7LL)), ((u64)(0x65f0816f752c6c8dLL)), ((u64)(0x012e8bd69aa19cc6LL)), ((u64)(0xff6ca1cb527787b1ULL)), ((u64)(0x017a2ecc414a03f7LL)), ((u64)(0xff47ca3e2715699dULL)), ((u64)(0x01d8ba7f519c84f5LL)), | |
| 3312 | +((u64)(0xbf8cde66d86d6202ULL)), ((u64)(0x0127748f9301d319LL)), ((u64)(0x2f7016008e88ba83LL)), ((u64)(0x017151b377c247e0LL)), ((u64)(0x3b4c1b80b22ae923LL)), ((u64)(0x01cda62055b2d9d8LL)), ((u64)(0x250f91306f5ad1b6LL)), ((u64)(0x012087d4358fc827LL)), ((u64)(0xee53757c8b318623ULL)), ((u64)(0x0168a9c942f3ba30LL)), ((u64)(0x29e852dbadfde7acLL)), ((u64)(0x01c2d43b93b0a8bdLL)), ((u64)(0x3a3133c94cbeb0ccLL)), ((u64)(0x0119c4a53c4e6976LL)), ((u64)(0xc8bd80bb9fee5cffULL)), ((u64)(0x016035ce8b6203d3LL)), | |
| 3313 | +((u64)(0xbaece0ea87e9f43eULL)), ((u64)(0x01b843422e3a84c8LL)), ((u64)(0x74d40c9294f238a7LL)), ((u64)(0x01132a095ce492fdLL)), ((u64)(0xd2090fb73a2ec6d1ULL)), ((u64)(0x0157f48bb41db7bcLL)), ((u64)(0x068b53a508ba7885LL)), ((u64)(0x01adf1aea12525acLL)), ((u64)(0x8417144725748b53ULL)), ((u64)(0x010cb70d24b7378bLL)), ((u64)(0x651cd958eed1ae28LL)), ((u64)(0x014fe4d06de5056eLL)), ((u64)(0xfe640faf2a8619b2ULL)), ((u64)(0x01a3de04895e46c9LL)), ((u64)(0x3efe89cd7a93d00fLL)), ((u64)(0x01066ac2d5daec3eLL)), | |
| 3314 | +((u64)(0xcebe2c40d938c413ULL)), ((u64)(0x014805738b51a74dLL)), ((u64)(0x426db7510f86f518LL)), ((u64)(0x019a06d06e261121LL)), ((u64)(0xc9849292a9b4592fULL)), ((u64)(0x0100444244d7cab4LL)), ((u64)(0xfbe5b73754216f7aULL)), ((u64)(0x01405552d60dbd61LL)), ((u64)(0x7adf25052929cb59LL)), ((u64)(0x01906aa78b912cbaLL)), ((u64)(0x1996ee4673743e2fLL)), ((u64)(0x01f485516e7577e9LL)), ((u64)(0xaffe54ec0828a6ddULL)), ((u64)(0x0138d352e5096af1LL)), ((u64)(0x1bfdea270a32d095LL)), ((u64)(0x018708279e4bc5aeLL)), | |
| 3315 | +((u64)(0xa2fd64b0ccbf84baULL)), ((u64)(0x01e8ca3185deb719LL)), ((u64)(0x05de5eee7ff7b2f4LL)), ((u64)(0x01317e5ef3ab3270LL)), ((u64)(0x0755f6aa1ff59fb1LL)), ((u64)(0x017dddf6b095ff0cLL)), ((u64)(0x092b7454a7f3079eLL)), ((u64)(0x01dd55745cbb7ecfLL)), ((u64)(0x65bb28b4e8f7e4c3LL)), ((u64)(0x012a5568b9f52f41LL)), ((u64)(0xbf29f2e22335ddf3ULL)), ((u64)(0x0174eac2e8727b11LL)), ((u64)(0x2ef46f9aac035570LL)), ((u64)(0x01d22573a28f19d6LL)), ((u64)(0xdd58c5c0ab821566ULL)), ((u64)(0x0123576845997025LL)), | |
| 3316 | +((u64)(0x54aef730d6629ac0LL)), ((u64)(0x016c2d4256ffcc2fLL)), ((u64)(0x29dab4fd0bfb4170LL)), ((u64)(0x01c73892ecbfbf3bLL)), ((u64)(0xfa28b11e277d08e6ULL)), ((u64)(0x011c835bd3f7d784LL)), ((u64)(0x38b2dd65b15c4b1fLL)), ((u64)(0x0163a432c8f5cd66LL)), ((u64)(0xc6df94bf1db35de7ULL)), ((u64)(0x01bc8d3f7b3340bfLL)), ((u64)(0xdc4bbcf772901ab0ULL)), ((u64)(0x0115d847ad000877LL)), ((u64)(0xd35eac354f34215cULL)), ((u64)(0x015b4e5998400a95LL)), ((u64)(0x48365742a30129b4LL)), ((u64)(0x01b221effe500d3bLL)), | |
| 3317 | +((u64)(0x0d21f689a5e0ba10LL)), ((u64)(0x010f5535fef20845LL)), ((u64)(0x506a742c0f58e894LL)), ((u64)(0x01532a837eae8a56LL)), ((u64)(0xe4851137132f22b9ULL)), ((u64)(0x01a7f5245e5a2cebLL)), ((u64)(0x6ed32ac26bfd75b4LL)), ((u64)(0x0108f936baf85c13LL)), ((u64)(0x4a87f57306fcd321LL)), ((u64)(0x014b378469b67318LL)), ((u64)(0x5d29f2cfc8bc07e9LL)), ((u64)(0x019e056584240fdeLL)), ((u64)(0xfa3a37c1dd7584f1ULL)), ((u64)(0x0102c35f729689eaLL)), ((u64)(0xb8c8c5b254d2e62eULL)), ((u64)(0x014374374f3c2c65LL)), | |
| 3318 | +((u64)(0x26faf71eea079fb9LL)), ((u64)(0x01945145230b377fLL)), ((u64)(0xf0b9b4e6a48987a8ULL)), ((u64)(0x01f965966bce055eLL)), ((u64)(0x5674111026d5f4c9LL)), ((u64)(0x013bdf7e0360c35bLL)), ((u64)(0x2c111554308b71fbLL)), ((u64)(0x018ad75d8438f432LL)), ((u64)(0xb7155aa93cae4e7aULL)), ((u64)(0x01ed8d34e547313eLL)), ((u64)(0x326d58a9c5ecf10cLL)), ((u64)(0x013478410f4c7ec7LL)), ((u64)(0xff08aed437682d4fULL)), ((u64)(0x01819651531f9e78LL)), ((u64)(0x3ecada89454238a3LL)), ((u64)(0x01e1fbe5a7e78617LL)), | |
| 3319 | +((u64)(0x873ec895cb496366ULL)), ((u64)(0x012d3d6f88f0b3ceLL)), ((u64)(0x290e7abb3e1bbc3fLL)), ((u64)(0x01788ccb6b2ce0c2LL)), ((u64)(0xb352196a0da2ab4fULL)), ((u64)(0x01d6affe45f818f2LL)), ((u64)(0xb0134fe24885ab11ULL)), ((u64)(0x01262dfeebbb0f97LL)), ((u64)(0x9c1823dadaa715d6ULL)), ((u64)(0x016fb97ea6a9d37dLL)), ((u64)(0x031e2cd19150db4bLL)), ((u64)(0x01cba7de5054485dLL)), ((u64)(0x21f2dc02fad2890fLL)), ((u64)(0x011f48eaf234ad3aLL)), ((u64)(0xaa6f9303b9872b53ULL)), ((u64)(0x01671b25aec1d888LL)), | |
| 3320 | +((u64)(0xd50b77c4a7e8f628ULL)), ((u64)(0x01c0e1ef1a724eaaLL)), ((u64)(0xc5272adae8f199d9ULL)), ((u64)(0x01188d357087712aLL)), ((u64)(0x7670f591a32e004fLL)), ((u64)(0x015eb082cca94d75LL)), ((u64)(0xd40d32f60bf98063ULL)), ((u64)(0x01b65ca37fd3a0d2LL)), ((u64)(0xc4883fd9c77bf03eULL)), ((u64)(0x0111f9e62fe44483LL)), ((u64)(0xb5aa4fd0395aec4dULL)), ((u64)(0x0156785fbbdd55a4LL)), ((u64)(0xe314e3c447b1a760ULL)), ((u64)(0x01ac1677aad4ab0dLL)), ((u64)(0xaded0e5aaccf089cULL)), ((u64)(0x010b8e0acac4eae8LL)), | |
| 3321 | +((u64)(0xd96851f15802cac3ULL)), ((u64)(0x014e718d7d7625a2LL)), ((u64)(0x8fc2666dae037d74ULL)), ((u64)(0x01a20df0dcd3af0bLL)), ((u64)(0x39d980048cc22e68LL)), ((u64)(0x010548b68a044d67LL)), ((u64)(0x084fe005aff2ba03LL)), ((u64)(0x01469ae42c8560c1LL)), ((u64)(0x4a63d8071bef6883LL)), ((u64)(0x0198419d37a6b8f1LL)), ((u64)(0x9cfcce08e2eb42a4ULL)), ((u64)(0x01fe52048590672dLL)), ((u64)(0x821e00c58dd309a7ULL)), ((u64)(0x013ef342d37a407cLL)), ((u64)(0xa2a580f6f147cc10ULL)), ((u64)(0x018eb0138858d09bLL)), | |
| 3322 | +((u64)(0x8b4ee134ad99bf15ULL)), ((u64)(0x01f25c186a6f04c2LL)), ((u64)(0x97114cc0ec80176dULL)), ((u64)(0x0137798f428562f9LL)), ((u64)(0xfcd59ff127a01d48ULL)), ((u64)(0x018557f31326bbb7LL)), ((u64)(0xfc0b07ed7188249aULL)), ((u64)(0x01e6adefd7f06aa5LL)), ((u64)(0xbd86e4f466f516e0ULL)), ((u64)(0x01302cb5e6f642a7LL)), ((u64)(0xace89e3180b25c98ULL)), ((u64)(0x017c37e360b3d351LL)), ((u64)(0x1822c5bde0def3beLL)), ((u64)(0x01db45dc38e0c826LL)), ((u64)(0xcf15bb96ac8b5857ULL)), ((u64)(0x01290ba9a38c7d17LL)), | |
| 3323 | +((u64)(0xc2db2a7c57ae2e6dULL)), ((u64)(0x01734e940c6f9c5dLL)), ((u64)(0x3391f51b6d99ba08LL)), ((u64)(0x01d022390f8b8375LL)), ((u64)(0x403b393124801445LL)), ((u64)(0x01221563a9b73229LL)), ((u64)(0x904a077d6da01956ULL)), ((u64)(0x016a9abc9424feb3LL)), ((u64)(0x745c895cc9081facLL)), ((u64)(0x01c5416bb92e3e60LL)), ((u64)(0x48b9d5d9fda513cbLL)), ((u64)(0x011b48e353bce6fcLL)), ((u64)(0x5ae84b507d0e58beLL)), ((u64)(0x01621b1c28ac20bbLL)), ((u64)(0x31a25e249c51eeeeLL)), ((u64)(0x01baa1e332d728eaLL)), | |
| 3324 | +((u64)(0x5f057ad6e1b33554LL)), ((u64)(0x0114a52dffc67992LL)), ((u64)(0xf6c6d98c9a2002aaULL)), ((u64)(0x0159ce797fb817f6LL)), ((u64)(0xb4788fefc0a80354ULL)), ((u64)(0x01b04217dfa61df4LL)), ((u64)(0xf0cb59f5d8690214ULL)), ((u64)(0x010e294eebc7d2b8LL)), ((u64)(0x2cfe30734e83429aLL)), ((u64)(0x0151b3a2a6b9c767LL)), ((u64)(0xf83dbc9022241340ULL)), ((u64)(0x01a6208b50683940LL)), ((u64)(0x9b2695da15568c08ULL)), ((u64)(0x0107d457124123c8LL)), ((u64)(0xc1f03b509aac2f0aULL)), ((u64)(0x0149c96cd6d16cbaLL)), | |
| 3325 | +((u64)(0x726c4a24c1573acdLL)), ((u64)(0x019c3bc80c85c7e9LL)), ((u64)(0xe783ae56f8d684c0ULL)), ((u64)(0x0101a55d07d39cf1LL)), ((u64)(0x616499ecb70c25f0LL)), ((u64)(0x01420eb449c8842eLL)), ((u64)(0xf9bdc067e4cf2f6cULL)), ((u64)(0x019292615c3aa539LL)), ((u64)(0x782d3081de02fb47LL)), ((u64)(0x01f736f9b3494e88LL)), ((u64)(0x4b1c3e512ac1dd0cLL)), ((u64)(0x013a825c100dd115LL)), ((u64)(0x9de34de57572544fULL)), ((u64)(0x018922f31411455aLL)), ((u64)(0x455c215ed2cee963LL)), ((u64)(0x01eb6bafd91596b1LL)), | |
| 3326 | +((u64)(0xcb5994db43c151deULL)), ((u64)(0x0133234de7ad7e2eLL)), ((u64)(0x7e2ffa1214b1a655LL)), ((u64)(0x017fec216198ddbaLL)), ((u64)(0x1dbbf89699de0febLL)), ((u64)(0x01dfe729b9ff1529LL)), ((u64)(0xb2957b5e202ac9f3ULL)), ((u64)(0x012bf07a143f6d39LL)), ((u64)(0x1f3ada35a8357c6fLL)), ((u64)(0x0176ec98994f4888LL)), ((u64)(0x270990c31242db8bLL)), ((u64)(0x01d4a7bebfa31aaaLL)), ((u64)(0x5865fa79eb69c937LL)), ((u64)(0x0124e8d737c5f0aaLL)), ((u64)(0xee7f791866443b85ULL)), ((u64)(0x016e230d05b76cd4LL)), | |
| 3327 | +((u64)(0x2a1f575e7fd54a66LL)), ((u64)(0x01c9abd04725480aLL)), ((u64)(0x5a53969b0fe54e80LL)), ((u64)(0x011e0b622c774d06LL)), ((u64)(0xf0e87c41d3dea220ULL)), ((u64)(0x01658e3ab7952047LL)), ((u64)(0xed229b5248d64aa8ULL)), ((u64)(0x01bef1c9657a6859LL)), ((u64)(0x3435a1136d85eea9LL)), ((u64)(0x0117571ddf6c8138LL)), ((u64)(0x4143095848e76a53LL)), ((u64)(0x015d2ce55747a186LL)), ((u64)(0xd193cbae5b2144e8ULL)), ((u64)(0x01b4781ead1989e7LL)), ((u64)(0xe2fc5f4cf8f4cb11ULL)), ((u64)(0x0110cb132c2ff630LL)), | |
| 3328 | +((u64)(0x1bbb77203731fdd5LL)), ((u64)(0x0154fdd7f73bf3bdLL)), ((u64)(0x62aa54e844fe7d4aLL)), ((u64)(0x01aa3d4df50af0acLL)), ((u64)(0xbdaa75112b1f0e4eULL)), ((u64)(0x010a6650b926d66bLL)), ((u64)(0xad15125575e6d1e2ULL)), ((u64)(0x014cffe4e7708c06LL)), ((u64)(0x585a56ead360865bLL)), ((u64)(0x01a03fde214caf08LL)), ((u64)(0x37387652c41c53f8LL)), ((u64)(0x010427ead4cfed65LL)), ((u64)(0x850693e7752368f7ULL)), ((u64)(0x014531e58a03e8beLL)), ((u64)(0x264838e1526c4334LL)), ((u64)(0x01967e5eec84e2eeLL)), | |
| 3329 | +((u64)(0xafda4719a7075402ULL)), ((u64)(0x01fc1df6a7a61ba9LL)), ((u64)(0x0de86c7008649481LL)), ((u64)(0x013d92ba28c7d14aLL)), ((u64)(0x9162878c0a7db9a1ULL)), ((u64)(0x018cf768b2f9c59cLL)), ((u64)(0xb5bb296f0d1d280aULL)), ((u64)(0x01f03542dfb83703LL)), ((u64)(0x5194f9e568323906LL)), ((u64)(0x01362149cbd32262LL)), ((u64)(0xe5fa385ec23ec747ULL)), ((u64)(0x0183a99c3ec7eafaLL)), ((u64)(0x9f78c67672ce7919ULL)), ((u64)(0x01e494034e79e5b9LL)), ((u64)(0x03ab7c0a07c10bb0LL)), ((u64)(0x012edc82110c2f94LL)), | |
| 3330 | +((u64)(0x04965b0c89b14e9cLL)), ((u64)(0x017a93a2954f3b79LL)), ((u64)(0x45bbf1cfac1da243LL)), ((u64)(0x01d9388b3aa30a57LL)), ((u64)(0x8b957721cb92856aULL)), ((u64)(0x0127c35704a5e676LL)), ((u64)(0x2e7ad4ea3e7726c4LL)), ((u64)(0x0171b42cc5cf6014LL)), ((u64)(0x3a198a24ce14f075LL)), ((u64)(0x01ce2137f7433819LL)), ((u64)(0xc44ff65700cd1649ULL)), ((u64)(0x0120d4c2fa8a030fLL)), ((u64)(0xb563f3ecc1005bdbULL)), ((u64)(0x016909f3b92c83d3LL)), ((u64)(0xa2bcf0e7f14072d2ULL)), ((u64)(0x01c34c70a777a4c8LL)), | |
| 3331 | +((u64)(0x65b61690f6c847c3LL)), ((u64)(0x011a0fc668aac6fdLL)), ((u64)(0xbf239c35347a59b4ULL)), ((u64)(0x016093b802d578bcLL)), ((u64)(0xeeec83428198f021ULL)), ((u64)(0x01b8b8a6038ad6ebLL)), ((u64)(0x7553d20990ff9615LL)), ((u64)(0x01137367c236c653LL)), ((u64)(0x52a8c68bf53f7b9aLL)), ((u64)(0x01585041b2c477e8LL)), ((u64)(0x6752f82ef28f5a81LL)), ((u64)(0x01ae64521f7595e2LL)), ((u64)(0x8093db1d57999890ULL)), ((u64)(0x010cfeb353a97dadLL)), ((u64)(0xe0b8d1e4ad7ffeb4ULL)), ((u64)(0x01503e602893dd18LL)), | |
| 3332 | +((u64)(0x18e7065dd8dffe62LL)), ((u64)(0x01a44df832b8d45fLL)), ((u64)(0x6f9063faa78bfefdLL)), ((u64)(0x0106b0bb1fb384bbLL)), ((u64)(0x4b747cf9516efebcLL)), ((u64)(0x01485ce9e7a065eaLL)), ((u64)(0xde519c37a5cabe6bULL)), ((u64)(0x019a742461887f64LL)), ((u64)(0x0af301a2c79eb703LL)), ((u64)(0x01008896bcf54f9fLL)), ((u64)(0xcdafc20b798664c4ULL)), ((u64)(0x0140aabc6c32a386LL)), ((u64)(0x811bb28e57e7fdf5ULL)), ((u64)(0x0190d56b873f4c68LL)), ((u64)(0xa1629f31ede1fd72ULL)), ((u64)(0x01f50ac6690f1f82LL)), | |
| 3333 | +((u64)(0xa4dda37f34ad3e67ULL)), ((u64)(0x013926bc01a973b1LL)), ((u64)(0x0e150c5f01d88e01LL)), ((u64)(0x0187706b0213d09eLL)), ((u64)(0x919a4f76c24eb181ULL)), ((u64)(0x01e94c85c298c4c5LL)), ((u64)(0x7b0071aa39712ef1LL)), ((u64)(0x0131cfd3999f7afbLL)), ((u64)(0x59c08e14c7cd7aadLL)), ((u64)(0x017e43c8800759baLL)), ((u64)(0xf030b199f9c0d958ULL)), ((u64)(0x01ddd4baa0093028LL)), ((u64)(0x961e6f003c1887d7ULL)), ((u64)(0x012aa4f4a405be19LL)), ((u64)(0xfba60ac04b1ea9cdULL)), ((u64)(0x01754e31cd072d9fLL)), | |
| 3334 | +((u64)(0xfa8f8d705de65440ULL)), ((u64)(0x01d2a1be4048f907LL)), ((u64)(0xfc99b8663aaff4a8ULL)), ((u64)(0x0123a516e82d9ba4LL)), ((u64)(0x3bc0267fc95bf1d2LL)), ((u64)(0x016c8e5ca239028eLL)), ((u64)(0xcab0301fbbb2ee47ULL)), ((u64)(0x01c7b1f3cac74331LL)), ((u64)(0x1eae1e13d54fd4ecLL)), ((u64)(0x011ccf385ebc89ffLL)), ((u64)(0xe659a598caa3ca27ULL)), ((u64)(0x01640306766bac7eLL)), ((u64)(0x9ff00efefd4cbcb1ULL)), ((u64)(0x01bd03c81406979eLL)), ((u64)(0x23f6095f5e4ff5efLL)), ((u64)(0x0116225d0c841ec3LL)), | |
| 3335 | +((u64)(0xecf38bb735e3f36aULL)), ((u64)(0x015baaf44fa52673LL)), ((u64)(0xe8306ea5035cf045ULL)), ((u64)(0x01b295b1638e7010LL)), ((u64)(0x911e4527221a162bULL)), ((u64)(0x010f9d8ede39060aLL)), ((u64)(0x3565d670eaa09bb6LL)), ((u64)(0x015384f295c7478dLL)), ((u64)(0x82bf4c0d2548c2a3ULL)), ((u64)(0x01a8662f3b391970LL)), ((u64)(0x51b78f88374d79a6LL)), ((u64)(0x01093fdd8503afe6LL)), ((u64)(0xe625736a4520d810ULL)), ((u64)(0x014b8fd4e6449bdfLL)), ((u64)(0xdfaed044d6690e14ULL)), ((u64)(0x019e73ca1fd5c2d7LL)), ((u64)(0xebcd422b0601a8ccULL)), ((u64)(0x0103085e53e599c6LL)), ((u64)(0xa6c092b5c78212ffULL)), ((u64)(0x0143ca75e8df0038LL)), ((u64)(0xd070b763396297bfULL)), ((u64)(0x0194bd136316c046LL)), ((u64)(0x848ce53c07bb3dafULL)), ((u64)(0x01f9ec583bdc7058LL)), ((u64)(0x52d80f4584d5068dLL)), ((u64)(0x013c33b72569c637LL)), ((u64)(0x278e1316e60a4831LL)), ((u64)(0x018b40a4eec437c5LL))}; // fixed array const | |
| 3336 | +static Array_fixed_u64_584 _const_strconv__pow5_inv_split_64_x = {((u64)(0x0000000000000001)), ((u64)(0x0400000000000000LL)), ((u64)(0x3333333333333334LL)), ((u64)(0x0333333333333333LL)), ((u64)(0x28f5c28f5c28f5c3LL)), ((u64)(0x028f5c28f5c28f5cLL)), ((u64)(0xed916872b020c49cULL)), ((u64)(0x020c49ba5e353f7cLL)), ((u64)(0xaf4f0d844d013a93ULL)), ((u64)(0x0346dc5d63886594LL)), ((u64)(0x8c3f3e0370cdc876ULL)), ((u64)(0x029f16b11c6d1e10LL)), ((u64)(0xd698fe69270b06c5ULL)), ((u64)(0x0218def416bdb1a6LL)), ((u64)(0xf0f4ca41d811a46eULL)), ((u64)(0x035afe535795e90aLL)), | |
| 3337 | +((u64)(0xf3f70834acdae9f1ULL)), ((u64)(0x02af31dc4611873bLL)), ((u64)(0x5cc5a02a23e254c1LL)), ((u64)(0x0225c17d04dad296LL)), ((u64)(0xfad5cd10396a2135ULL)), ((u64)(0x036f9bfb3af7b756LL)), ((u64)(0xfbde3da69454e75eULL)), ((u64)(0x02bfaffc2f2c92abLL)), ((u64)(0x2fe4fe1edd10b918LL)), ((u64)(0x0232f33025bd4223LL)), ((u64)(0x4ca19697c81ac1bfLL)), ((u64)(0x0384b84d092ed038LL)), ((u64)(0x3d4e1213067bce33LL)), ((u64)(0x02d09370d4257360LL)), ((u64)(0x643e74dc052fd829LL)), ((u64)(0x024075f3dceac2b3LL)), | |
| 3338 | +((u64)(0x6d30baf9a1e626a7LL)), ((u64)(0x039a5652fb113785LL)), ((u64)(0x2426fbfae7eb5220LL)), ((u64)(0x02e1dea8c8da92d1LL)), ((u64)(0x1cebfcc8b9890e80LL)), ((u64)(0x024e4bba3a487574LL)), ((u64)(0x94acc7a78f41b0ccULL)), ((u64)(0x03b07929f6da5586LL)), ((u64)(0xaa23d2ec729af3d7ULL)), ((u64)(0x02f394219248446bLL)), ((u64)(0xbb4fdbf05baf2979ULL)), ((u64)(0x025c768141d369efLL)), ((u64)(0xc54c931a2c4b758dULL)), ((u64)(0x03c7240202ebdcb2LL)), ((u64)(0x9dd6dc14f03c5e0bULL)), ((u64)(0x0305b66802564a28LL)), | |
| 3339 | +((u64)(0x4b1249aa59c9e4d6LL)), ((u64)(0x026af8533511d4edLL)), ((u64)(0x44ea0f76f60fd489LL)), ((u64)(0x03de5a1ebb4fbb15LL)), ((u64)(0x6a54d92bf80caa07LL)), ((u64)(0x0318481895d96277LL)), ((u64)(0x21dd7a89933d54d2LL)), ((u64)(0x0279d346de4781f9LL)), ((u64)(0x362f2a75b8622150LL)), ((u64)(0x03f61ed7ca0c0328LL)), ((u64)(0xf825bb91604e810dULL)), ((u64)(0x032b4bdfd4d668ecLL)), ((u64)(0xc684960de6a5340bULL)), ((u64)(0x0289097fdd7853f0LL)), ((u64)(0xd203ab3e521dc33cULL)), ((u64)(0x02073accb12d0ff3LL)), | |
| 3340 | +((u64)(0xe99f7863b696052cULL)), ((u64)(0x033ec47ab514e652LL)), ((u64)(0x87b2c6b62bab3757ULL)), ((u64)(0x02989d2ef743eb75LL)), ((u64)(0xd2f56bc4efbc2c45ULL)), ((u64)(0x0213b0f25f69892aLL)), ((u64)(0x1e55793b192d13a2LL)), ((u64)(0x0352b4b6ff0f41deLL)), ((u64)(0x4b77942f475742e8LL)), ((u64)(0x02a8909265a5ce4bLL)), ((u64)(0xd5f9435905df68baULL)), ((u64)(0x022073a8515171d5LL)), ((u64)(0x565b9ef4d6324129LL)), ((u64)(0x03671f73b54f1c89LL)), ((u64)(0xdeafb25d78283421ULL)), ((u64)(0x02b8e5f62aa5b06dLL)), | |
| 3341 | +((u64)(0x188c8eb12cecf681LL)), ((u64)(0x022d84c4eeeaf38bLL)), ((u64)(0x8dadb11b7b14bd9bULL)), ((u64)(0x037c07a17e44b8deLL)), ((u64)(0x7157c0e2c8dd647cLL)), ((u64)(0x02c99fb46503c718LL)), ((u64)(0x8ddfcd823a4ab6caULL)), ((u64)(0x023ae629ea696c13LL)), ((u64)(0x1632e269f6ddf142LL)), ((u64)(0x0391704310a8acecLL)), ((u64)(0x44f581ee5f17f435LL)), ((u64)(0x02dac035a6ed5723LL)), ((u64)(0x372ace584c1329c4LL)), ((u64)(0x024899c4858aac1cLL)), ((u64)(0xbeaae3c079b842d3ULL)), ((u64)(0x03a75c6da27779c6LL)), | |
| 3342 | +((u64)(0x6555830061603576LL)), ((u64)(0x02ec49f14ec5fb05LL)), ((u64)(0xb7779c004de6912bULL)), ((u64)(0x0256a18dd89e626aLL)), ((u64)(0xf258f99a163db512ULL)), ((u64)(0x03bdcf495a9703ddLL)), ((u64)(0x5b7a614811caf741LL)), ((u64)(0x02fe3f6de212697eLL)), ((u64)(0xaf951aa00e3bf901ULL)), ((u64)(0x0264ff8b1b41edfeLL)), ((u64)(0x7f54f7667d2cc19bLL)), ((u64)(0x03d4cc11c5364997LL)), ((u64)(0x32aa5f8530f09ae3LL)), ((u64)(0x0310a3416a91d479LL)), ((u64)(0xf55519375a5a1582ULL)), ((u64)(0x0273b5cdeedb1060LL)), | |
| 3343 | +((u64)(0xbbbb5b8bc3c3559dULL)), ((u64)(0x03ec56164af81a34LL)), ((u64)(0x2fc916096969114aLL)), ((u64)(0x03237811d593482aLL)), ((u64)(0x596dab3ababa743cLL)), ((u64)(0x0282c674aadc39bbLL)), ((u64)(0x478aef622efb9030LL)), ((u64)(0x0202385d557cfafcLL)), ((u64)(0xd8de4bd04b2c19e6ULL)), ((u64)(0x0336c0955594c4c6LL)), ((u64)(0xad7ea30d08f014b8ULL)), ((u64)(0x029233aaaadd6a38LL)), ((u64)(0x24654f3da0c01093LL)), ((u64)(0x020e8fbbbbe454faLL)), ((u64)(0x3a3bb1fc346680ebLL)), ((u64)(0x034a7f92c63a2190LL)), | |
| 3344 | +((u64)(0x94fc8e635d1ecd89ULL)), ((u64)(0x02a1ffa89e94e7a6LL)), ((u64)(0xaa63a51c4a7f0ad4ULL)), ((u64)(0x021b32ed4baa52ebLL)), ((u64)(0xdd6c3b607731aaedULL)), ((u64)(0x035eb7e212aa1e45LL)), ((u64)(0x1789c919f8f488bdLL)), ((u64)(0x02b22cb4dbbb4b6bLL)), ((u64)(0xac6e3a7b2d906d64ULL)), ((u64)(0x022823c3e2fc3c55LL)), ((u64)(0x13e390c515b3e23aLL)), ((u64)(0x03736c6c9e606089LL)), ((u64)(0xdcb60d6a77c31b62ULL)), ((u64)(0x02c2bd23b1e6b3a0LL)), ((u64)(0x7d5e7121f968e2b5LL)), ((u64)(0x0235641c8e52294dLL)), | |
| 3345 | +((u64)(0xc8971b698f0e3787ULL)), ((u64)(0x0388a02db0837548LL)), ((u64)(0xa078e2bad8d82c6cULL)), ((u64)(0x02d3b357c0692aa0LL)), ((u64)(0xe6c71bc8ad79bd24ULL)), ((u64)(0x0242f5dfcd20eee6LL)), ((u64)(0x0ad82c7448c2c839LL)), ((u64)(0x039e5632e1ce4b0bLL)), ((u64)(0x3be023903a356cfaLL)), ((u64)(0x02e511c24e3ea26fLL)), ((u64)(0x2fe682d9c82abd95LL)), ((u64)(0x0250db01d8321b8cLL)), ((u64)(0x4ca4048fa6aac8eeLL)), ((u64)(0x03b4919c8d1cf8e0LL)), ((u64)(0x3d5003a61eef0725LL)), ((u64)(0x02f6dae3a4172d80LL)), | |
| 3346 | +((u64)(0x9773361e7f259f51ULL)), ((u64)(0x025f1582e9ac2466LL)), ((u64)(0x8beb89ca6508fee8ULL)), ((u64)(0x03cb559e42ad070aLL)), ((u64)(0x6fefa16eb73a6586LL)), ((u64)(0x0309114b688a6c08LL)), ((u64)(0xf3261abef8fb846bULL)), ((u64)(0x026da76f86d52339LL)), ((u64)(0x51d691318e5f3a45LL)), ((u64)(0x03e2a57f3e21d1f6LL)), ((u64)(0x0e4540f471e5c837LL)), ((u64)(0x031bb798fe8174c5LL)), ((u64)(0xd8376729f4b7d360ULL)), ((u64)(0x027c92e0cb9ac3d0LL)), ((u64)(0xf38bd84321261effULL)), ((u64)(0x03fa849adf5e061aLL)), | |
| 3347 | +((u64)(0x293cad0280eb4bffLL)), ((u64)(0x032ed07be5e4d1afLL)), ((u64)(0xedca240200bc3cccULL)), ((u64)(0x028bd9fcb7ea4158LL)), ((u64)(0xbe3b50019a3030a4ULL)), ((u64)(0x02097b309321cde0LL)), ((u64)(0xc9f88002904d1a9fULL)), ((u64)(0x03425eb41e9c7c9aLL)), ((u64)(0x3b2d3335403daee6LL)), ((u64)(0x029b7ef67ee396e2LL)), ((u64)(0x95bdc291003158b8ULL)), ((u64)(0x0215ff2b98b6124eLL)), ((u64)(0x892f9db4cd1bc126ULL)), ((u64)(0x035665128df01d4aLL)), ((u64)(0x07594af70a7c9a85LL)), ((u64)(0x02ab840ed7f34aa2LL)), | |
| 3348 | +((u64)(0x6c476f2c0863aed1LL)), ((u64)(0x0222d00bdff5d54eLL)), ((u64)(0x13a57eacda3917b4LL)), ((u64)(0x036ae67966562217LL)), ((u64)(0x0fb7988a482dac90LL)), ((u64)(0x02bbeb9451de81acLL)), ((u64)(0xd95fad3b6cf156daULL)), ((u64)(0x022fefa9db1867bcLL)), ((u64)(0xf565e1f8ae4ef15cULL)), ((u64)(0x037fe5dc91c0a5faLL)), ((u64)(0x911e4e608b725ab0ULL)), ((u64)(0x02ccb7e3a7cd5195LL)), ((u64)(0xda7ea51a0928488dULL)), ((u64)(0x023d5fe9530aa7aaLL)), ((u64)(0xf7310829a8407415ULL)), ((u64)(0x039566421e7772aaLL)), | |
| 3349 | +((u64)(0x2c2739baed005cdeLL)), ((u64)(0x02ddeb68185f8eefLL)), ((u64)(0xbcec2e2f24004a4bULL)), ((u64)(0x024b22b9ad193f25LL)), ((u64)(0x94ad16b1d333aa11ULL)), ((u64)(0x03ab6ac2ae8ecb6fLL)), ((u64)(0xaa241227dc2954dbULL)), ((u64)(0x02ef889bbed8a2bfLL)), ((u64)(0x54e9a81fe35443e2LL)), ((u64)(0x02593a163246e899LL)), ((u64)(0x2175d9cc9eed396aLL)), ((u64)(0x03c1f689ea0b0dc2LL)), ((u64)(0xe7917b0a18bdc788ULL)), ((u64)(0x03019207ee6f3e34LL)), ((u64)(0xb9412f3b46fe393aULL)), ((u64)(0x0267a8065858fe90LL)), | |
| 3350 | +((u64)(0xf535185ed7fd285cULL)), ((u64)(0x03d90cd6f3c1974dLL)), ((u64)(0xc42a79e57997537dULL)), ((u64)(0x03140a458fce12a4LL)), ((u64)(0x03552e512e12a931LL)), ((u64)(0x02766e9e0ca4dbb7LL)), ((u64)(0x9eeeb081e3510eb4ULL)), ((u64)(0x03f0b0fce107c5f1LL)), ((u64)(0x4bf226ce4f740bc3LL)), ((u64)(0x0326f3fd80d304c1LL)), ((u64)(0xa3281f0b72c33c9cULL)), ((u64)(0x02858ffe00a8d09aLL)), ((u64)(0x1c2018d5f568fd4aLL)), ((u64)(0x020473319a20a6e2LL)), ((u64)(0xf9ccf48988a7fba9ULL)), ((u64)(0x033a51e8f69aa49cLL)), | |
| 3351 | +((u64)(0xfb0a5d3ad3b99621ULL)), ((u64)(0x02950e53f87bb6e3LL)), ((u64)(0x2f3b7dc8a96144e7LL)), ((u64)(0x0210d8432d2fc583LL)), ((u64)(0xe52bfc7442353b0cULL)), ((u64)(0x034e26d1e1e608d1LL)), ((u64)(0xb756639034f76270ULL)), ((u64)(0x02a4ebdb1b1e6d74LL)), ((u64)(0x2c451c735d92b526LL)), ((u64)(0x021d897c15b1f12aLL)), ((u64)(0x13a1c71efc1deea3LL)), ((u64)(0x0362759355e981ddLL)), ((u64)(0x761b05b2634b2550LL)), ((u64)(0x02b52adc44bace4aLL)), ((u64)(0x91af37c1e908eaa6ULL)), ((u64)(0x022a88b036fbd83bLL)), | |
| 3352 | +((u64)(0x82b1f2cfdb417770ULL)), ((u64)(0x03774119f192f392LL)), ((u64)(0xcef4c23fe29ac5f3ULL)), ((u64)(0x02c5cdae5adbf60eLL)), ((u64)(0x3f2a34ffe87bd190LL)), ((u64)(0x0237d7beaf165e72LL)), ((u64)(0x984387ffda5fb5b2ULL)), ((u64)(0x038c8c644b56fd83LL)), ((u64)(0xe0360666484c915bULL)), ((u64)(0x02d6d6b6a2abfe02LL)), ((u64)(0x802b3851d3707449ULL)), ((u64)(0x024578921bbccb35LL)), ((u64)(0x99dec082ebe72075ULL)), ((u64)(0x03a25a835f947855LL)), ((u64)(0xae4bcd358985b391ULL)), ((u64)(0x02e8486919439377LL)), | |
| 3353 | +((u64)(0xbea30a913ad15c74ULL)), ((u64)(0x02536d20e102dc5fLL)), ((u64)(0xfdd1aa81f7b560b9ULL)), ((u64)(0x03b8ae9b019e2d65LL)), ((u64)(0x97daeece5fc44d61ULL)), ((u64)(0x02fa2548ce182451LL)), ((u64)(0xdfe258a51969d781ULL)), ((u64)(0x0261b76d71ace9daLL)), ((u64)(0x996a276e8f0fbf34ULL)), ((u64)(0x03cf8be24f7b0fc4LL)), ((u64)(0xe121b9253f3fcc2aULL)), ((u64)(0x030c6fe83f95a636LL)), ((u64)(0xb41afa8432997022ULL)), ((u64)(0x02705986994484f8LL)), ((u64)(0xecf7f739ea8f19cfULL)), ((u64)(0x03e6f5a4286da18dLL)), | |
| 3354 | +((u64)(0x23f99294bba5ae40LL)), ((u64)(0x031f2ae9b9f14e0bLL)), ((u64)(0x4ffadbaa2fb7be99LL)), ((u64)(0x027f5587c7f43e6fLL)), ((u64)(0x7ff7c5dd1925fdc2LL)), ((u64)(0x03feef3fa6539718LL)), ((u64)(0xccc637e4141e649bULL)), ((u64)(0x033258ffb842df46LL)), ((u64)(0xd704f983434b83afULL)), ((u64)(0x028ead9960357f6bLL)), ((u64)(0x126a6135cf6f9c8cLL)), ((u64)(0x020bbe144cf79923LL)), ((u64)(0x83dd685618b29414ULL)), ((u64)(0x0345fced47f28e9eLL)), ((u64)(0x9cb12044e08edcddULL)), ((u64)(0x029e63f1065ba54bLL)), | |
| 3355 | +((u64)(0x16f419d0b3a57d7dLL)), ((u64)(0x02184ff405161dd6LL)), ((u64)(0x8b20294dec3bfbfbULL)), ((u64)(0x035a19866e89c956LL)), ((u64)(0x3c19baa4bcfcc996LL)), ((u64)(0x02ae7ad1f207d445LL)), ((u64)(0xc9ae2eea30ca3adfULL)), ((u64)(0x02252f0e5b39769dLL)), ((u64)(0x0f7d17dd1add2afdLL)), ((u64)(0x036eb1b091f58a96LL)), ((u64)(0x3f97464a7be42264LL)), ((u64)(0x02bef48d41913babLL)), ((u64)(0xcc790508631ce850ULL)), ((u64)(0x02325d3dce0dc955LL)), ((u64)(0xe0c1a1a704fb0d4dULL)), ((u64)(0x0383c862e3494222LL)), | |
| 3356 | +((u64)(0x4d67b4859d95a43eLL)), ((u64)(0x02cfd3824f6dce82LL)), ((u64)(0x711fc39e17aae9cbLL)), ((u64)(0x023fdc683f8b0b9bLL)), ((u64)(0xe832d2968c44a945ULL)), ((u64)(0x039960a6cc11ac2bLL)), ((u64)(0xecf575453d03ba9eULL)), ((u64)(0x02e11a1f09a7bcefLL)), ((u64)(0x572ac4376402fbb1LL)), ((u64)(0x024dae7f3aec9726LL)), ((u64)(0x58446d256cd192b5LL)), ((u64)(0x03af7d985e47583dLL)), ((u64)(0x79d0575123dadbc4LL)), ((u64)(0x02f2cae04b6c4697LL)), ((u64)(0x94a6ac40e97be303ULL)), ((u64)(0x025bd5803c569edfLL)), | |
| 3357 | +((u64)(0x8771139b0f2c9e6cULL)), ((u64)(0x03c62266c6f0fe32LL)), ((u64)(0x9f8da948d8f07ebdULL)), ((u64)(0x0304e85238c0cb5bLL)), ((u64)(0xe60aedd3e0c06564ULL)), ((u64)(0x026a5374fa33d5e2LL)), ((u64)(0xa344afb9679a3bd2ULL)), ((u64)(0x03dd5254c3862304LL)), ((u64)(0xe903bfc78614fca8ULL)), ((u64)(0x031775109c6b4f36LL)), ((u64)(0xba6966393810ca20ULL)), ((u64)(0x02792a73b055d8f8LL)), ((u64)(0x2a423d2859b4769aLL)), ((u64)(0x03f510b91a22f4c1LL)), ((u64)(0xee9b642047c39215ULL)), ((u64)(0x032a73c7481bf700LL)), | |
| 3358 | +((u64)(0xbee2b680396941aaULL)), ((u64)(0x02885c9f6ce32c00LL)), ((u64)(0xff1bc53361210155ULL)), ((u64)(0x0206b07f8a4f5666LL)), ((u64)(0x31c6085235019bbbLL)), ((u64)(0x033de73276e5570bLL)), ((u64)(0x27d1a041c4014963LL)), ((u64)(0x0297ec285f1ddf3cLL)), ((u64)(0xeca7b367d0010782ULL)), ((u64)(0x021323537f4b18fcLL)), ((u64)(0xadd91f0c8001a59dULL)), ((u64)(0x0351d21f3211c194LL)), ((u64)(0xf17a7f3d3334847eULL)), ((u64)(0x02a7db4c280e3476LL)), ((u64)(0x279532975c2a0398LL)), ((u64)(0x021fe2a3533e905fLL)), | |
| 3359 | +((u64)(0xd8eeb75893766c26ULL)), ((u64)(0x0366376bb8641a31LL)), ((u64)(0x7a5892ad42c52352LL)), ((u64)(0x02b82c562d1ce1c1LL)), ((u64)(0xfb7a0ef102374f75ULL)), ((u64)(0x022cf044f0e3e7cdLL)), ((u64)(0xc59017e8038bb254ULL)), ((u64)(0x037b1a07e7d30c7cLL)), ((u64)(0x37a67986693c8eaaLL)), ((u64)(0x02c8e19feca8d6caLL)), ((u64)(0xf951fad1edca0bbbULL)), ((u64)(0x023a4e198a20abd4LL)), ((u64)(0x28832ae97c76792bLL)), ((u64)(0x03907cf5a9cddfbbLL)), ((u64)(0x2068ef21305ec756LL)), ((u64)(0x02d9fd9154a4b2fcLL)), | |
| 3360 | +((u64)(0x19ed8c1a8d189f78LL)), ((u64)(0x0247fe0ddd508f30LL)), ((u64)(0x5caf4690e1c0ff26LL)), ((u64)(0x03a66349621a7eb3LL)), ((u64)(0x4a25d20d81673285LL)), ((u64)(0x02eb82a11b48655cLL)), ((u64)(0x3b5174d79ab8f537LL)), ((u64)(0x0256021a7c39eab0LL)), ((u64)(0x921bee25c45b21f1ULL)), ((u64)(0x03bcd02a605caab3LL)), ((u64)(0xdb498b5169e2818eULL)), ((u64)(0x02fd735519e3bbc2LL)), ((u64)(0x15d46f7454b53472LL)), ((u64)(0x02645c4414b62fcfLL)), ((u64)(0xefba4bed545520b6ULL)), ((u64)(0x03d3c6d35456b2e4LL)), | |
| 3361 | +((u64)(0xf2fb6ff110441a2bULL)), ((u64)(0x030fd242a9def583LL)), ((u64)(0x8f2f8cc0d9d014efULL)), ((u64)(0x02730e9bbb18c469LL)), ((u64)(0xb1e5ae015c80217fULL)), ((u64)(0x03eb4a92c4f46d75LL)), ((u64)(0xc1848b344a001accULL)), ((u64)(0x0322a20f03f6bdf7LL)), ((u64)(0xce03a2903b3348a3ULL)), ((u64)(0x02821b3f365efe5fLL)), ((u64)(0xd802e873628f6d4fULL)), ((u64)(0x0201af65c518cb7fLL)), ((u64)(0x599e40b89db2487fLL)), ((u64)(0x0335e56fa1c14599LL)), ((u64)(0xe14b66fa17c1d399ULL)), ((u64)(0x029184594e3437adLL)), | |
| 3362 | +((u64)(0x81091f2e7967dc7aULL)), ((u64)(0x020e037aa4f692f1LL)), ((u64)(0x9b41cb7d8f0c93f6ULL)), ((u64)(0x03499f2aa18a84b5LL)), ((u64)(0xaf67d5fe0c0a0ff8ULL)), ((u64)(0x02a14c221ad536f7LL)), ((u64)(0xf2b977fe70080cc7ULL)), ((u64)(0x021aa34e7bddc592LL)), ((u64)(0x1df58cca4cd9ae0bLL)), ((u64)(0x035dd2172c9608ebLL)), ((u64)(0xe4c470a1d7148b3cULL)), ((u64)(0x02b174df56de6d88LL)), ((u64)(0x83d05a1b1276d5caULL)), ((u64)(0x022790b2abe5246dLL)), ((u64)(0x9fb3c35e83f1560fULL)), ((u64)(0x0372811ddfd50715LL)), | |
| 3363 | +((u64)(0xb2f635e5365aab3fULL)), ((u64)(0x02c200e4b310d277LL)), ((u64)(0xf591c4b75eaeef66ULL)), ((u64)(0x0234cd83c273db92LL)), ((u64)(0xef4fa125644b18a3ULL)), ((u64)(0x0387af39371fc5b7LL)), ((u64)(0x8c3fb41de9d5ad4fULL)), ((u64)(0x02d2f2942c196af9LL)), ((u64)(0x3cffc34b2177bdd9LL)), ((u64)(0x02425ba9bce12261LL)), ((u64)(0x94cc6bab68bf9628ULL)), ((u64)(0x039d5f75fb01d09bLL)), ((u64)(0x10a38955ed6611b9LL)), ((u64)(0x02e44c5e6267da16LL)), ((u64)(0xda1c6dde5784dafbULL)), ((u64)(0x02503d184eb97b44LL)), | |
| 3364 | +((u64)(0xf693e2fd58d49191ULL)), ((u64)(0x03b394f3b128c53aLL)), ((u64)(0xc5431bfde0aa0e0eULL)), ((u64)(0x02f610c2f4209dc8LL)), ((u64)(0x6a9c1664b3bb3e72LL)), ((u64)(0x025e73cf29b3b16dLL)), ((u64)(0x10f9bd6dec5eca4fLL)), ((u64)(0x03ca52e50f85e8afLL)), ((u64)(0xda616457f04bd50cULL)), ((u64)(0x03084250d937ed58LL)), ((u64)(0xe1e783798d09773dULL)), ((u64)(0x026d01da475ff113LL)), ((u64)(0x030c058f480f252eLL)), ((u64)(0x03e19c9072331b53LL)), ((u64)(0x68d66ad906728425LL)), ((u64)(0x031ae3a6c1c27c42LL)), | |
| 3365 | +((u64)(0x8711ef14052869b7ULL)), ((u64)(0x027be952349b969bLL)), ((u64)(0x0b4fe4ecd50d75f2LL)), ((u64)(0x03f97550542c242cLL)), ((u64)(0xa2a650bd773df7f5ULL)), ((u64)(0x032df7737689b689LL)), ((u64)(0xb551da312c31932aULL)), ((u64)(0x028b2c5c5ed49207LL)), ((u64)(0x5ddb14f4235adc22LL)), ((u64)(0x0208f049e576db39LL)), ((u64)(0x2fc4ee536bc49369LL)), ((u64)(0x034180763bf15ec2LL)), ((u64)(0xbfd0bea92303a921ULL)), ((u64)(0x029acd2b63277f01LL)), ((u64)(0x9973cbba8269541aULL)), ((u64)(0x021570ef8285ff34LL)), | |
| 3366 | +((u64)(0x5bec792a6a42202aLL)), ((u64)(0x0355817f373ccb87LL)), ((u64)(0xe3239421ee9b4cefULL)), ((u64)(0x02aacdff5f63d605LL)), ((u64)(0xb5b6101b25490a59ULL)), ((u64)(0x02223e65e5e97804LL)), ((u64)(0x22bce691d541aa27LL)), ((u64)(0x0369fd6fd64259a1LL)), ((u64)(0xb563eba7ddce21b9ULL)), ((u64)(0x02bb31264501e14dLL)), ((u64)(0xf78322ecb171b494ULL)), ((u64)(0x022f5a850401810aLL)), ((u64)(0x259e9e47824f8753LL)), ((u64)(0x037ef73b399c01abLL)), ((u64)(0x1e187e9f9b72d2a9LL)), ((u64)(0x02cbf8fc2e1667bcLL)), | |
| 3367 | +((u64)(0x4b46cbb2e2c24221LL)), ((u64)(0x023cc73024deb963LL)), ((u64)(0x120adf849e039d01LL)), ((u64)(0x039471e6a1645bd2LL)), ((u64)(0xdb3be603b19c7d9aULL)), ((u64)(0x02dd27ebb4504974LL)), ((u64)(0x7c2feb3627b0647cLL)), ((u64)(0x024a865629d9d45dLL)), ((u64)(0x2d197856a5e7072cLL)), ((u64)(0x03aa7089dc8fba2fLL)), ((u64)(0x8a7ac6abb7ec05bdULL)), ((u64)(0x02eec06e4a0c94f2LL)), ((u64)(0xd52f05562cbcd164ULL)), ((u64)(0x025899f1d4d6dd8eLL)), ((u64)(0x21e4d556adfae8a0LL)), ((u64)(0x03c0f64fbaf1627eLL)), | |
| 3368 | +((u64)(0xe7ea444557fbed4dULL)), ((u64)(0x0300c50c958de864LL)), ((u64)(0xecbb69d1132ff10aULL)), ((u64)(0x0267040a113e5383LL)), ((u64)(0xadf8a94e851981aaULL)), ((u64)(0x03d8067681fd526cLL)), ((u64)(0x8b2d543ed0e13488ULL)), ((u64)(0x0313385ece6441f0LL)), ((u64)(0xd5bddcff0d80f6d3ULL)), ((u64)(0x0275c6b23eb69b26LL)), ((u64)(0x892fc7fe7c018aebULL)), ((u64)(0x03efa45064575ea4LL)), ((u64)(0x3a8c9ffec99ad589LL)), ((u64)(0x03261d0d1d12b21dLL)), ((u64)(0xc8707fff07af113bULL)), ((u64)(0x0284e40a7da88e7dLL)), | |
| 3369 | +((u64)(0x39f39998d2f2742fLL)), ((u64)(0x0203e9a1fe2071feLL)), ((u64)(0x8fec28f484b7204bULL)), ((u64)(0x033975cffd00b663LL)), ((u64)(0xd989ba5d36f8e6a2ULL)), ((u64)(0x02945e3ffd9a2b82LL)), ((u64)(0x47a161e42bfa521cLL)), ((u64)(0x02104b66647b5602LL)), ((u64)(0x0c35696d132a1cf9LL)), ((u64)(0x034d4570a0c5566aLL)), ((u64)(0x09c454574288172dLL)), ((u64)(0x02a4378d4d6aab88LL)), ((u64)(0xa169dd129ba0128bULL)), ((u64)(0x021cf93dd7888939LL)), ((u64)(0x0242fb50f9001dabLL)), ((u64)(0x03618ec958da7529LL)), | |
| 3370 | +((u64)(0x9b68c90d940017bcULL)), ((u64)(0x02b4723aad7b90edLL)), ((u64)(0x4920a0d7a999ac96LL)), ((u64)(0x0229f4fbbdfc73f1LL)), ((u64)(0x750101590f5c4757LL)), ((u64)(0x037654c5fcc71fe8LL)), ((u64)(0x2a6734473f7d05dfLL)), ((u64)(0x02c5109e63d27fedLL)), ((u64)(0xeeb8f69f65fd9e4cULL)), ((u64)(0x0237407eb641fff0LL)), ((u64)(0xe45b24323cc8fd46ULL)), ((u64)(0x038b9a6456cfffe7LL)), ((u64)(0xb6af502830a0ca9fULL)), ((u64)(0x02d6151d123fffecLL)), ((u64)(0xf88c402026e7087fULL)), ((u64)(0x0244ddb0db666656LL)), | |
| 3371 | +((u64)(0x2746cd003e3e73feLL)), ((u64)(0x03a162b4923d708bLL)), ((u64)(0x1f6bd73364fec332LL)), ((u64)(0x02e7822a0e978d3cLL)), ((u64)(0xe5efdf5c50cbcf5bULL)), ((u64)(0x0252ce880bac70fcLL)), ((u64)(0x3cb2fefa1adfb22bLL)), ((u64)(0x03b7b0d9ac471b2eLL)), ((u64)(0x308f3261af195b56LL)), ((u64)(0x02f95a47bd05af58LL)), ((u64)(0x5a0c284e25ade2abLL)), ((u64)(0x0261150630d15913LL)), ((u64)(0x29ad0d49d5e30445LL)), ((u64)(0x03ce8809e7b55b52LL)), ((u64)(0x548a7107de4f369dLL)), ((u64)(0x030ba007ec9115dbLL)), ((u64)(0xdd3b8d9fe50c2bb1ULL)), ((u64)(0x026fb3398a0dab15LL)), ((u64)(0x952c15cca1ad12b5ULL)), ((u64)(0x03e5eb8f434911bcLL)), ((u64)(0x775677d6e7bda891LL)), ((u64)(0x031e560c35d40e30LL)), ((u64)(0xc5dec645863153a7ULL)), ((u64)(0x027eab3cf7dcd826LL))}; // fixed array const | |
| 3372 | +bool v_memory_panic = false; // global 6 | |
| 3373 | + | |
| 3374 | +int_literal g_autostr_type_stack_len = 0; // global 6 | |
| 3375 | + | |
| 3376 | +int_literal g_autostr_addr_stack_len = 0; // global 6 | |
| 3377 | + | |
| 3378 | +int g_main_argc = ((int)(0)); // global 6 | |
| 3379 | + | |
| 3380 | +voidptr g_main_argv = ((void*)0); // global 6 | |
| 3381 | + | |
| 3382 | +voidptr g_live_reload_info; // global 6 | |
| 3383 | + | |
| 3384 | +/* skip C global: stdout */ | |
| 3385 | + | |
| 3386 | +/* skip C global: stderr */ | |
| 3387 | + | |
| 3388 | +/* skip C global: _wyp */ | |
| 3389 | + | |
| 3390 | +static IError _const_error_sentinel; // inited later | |
| 3391 | +static IError _const_none__; // inited later | |
| 3392 | +static const i8 _const_min_i8 = -128; // precomputed2 | |
| 3393 | +static const i8 _const_max_i8 = 127; // precomputed2 | |
| 3394 | +static const i16 _const_min_i16 = -32768; // precomputed2 | |
| 3395 | +static const i16 _const_max_i16 = 32767; // precomputed2 | |
| 3396 | +static const i32 _const_min_i32 = -2147483648; // precomputed2 | |
| 3397 | +static const i32 _const_max_i32 = 2147483647; // precomputed2 | |
| 3398 | +static i64 _const_min_i64; // inited later | |
| 3399 | +static i64 _const_max_i64; // inited later | |
| 3400 | +static const u8 _const_min_u8 = 0; // precomputed2 | |
| 3401 | +static const u8 _const_max_u8 = 255; // precomputed2 | |
| 3402 | +static const u16 _const_min_u16 = 0; // precomputed2 | |
| 3403 | +static const u16 _const_max_u16 = 65535; // precomputed2 | |
| 3404 | +static const u32 _const_min_u32 = 0; // precomputed2 | |
| 3405 | +static const u32 _const_max_u32 = 4294967295; // precomputed2 | |
| 3406 | +static const u64 _const_min_u64 = 0U; // precomputed2 | |
| 3407 | +static const u64 _const_max_u64 = 18446744073709551615U; // precomputed2 | |
| 3408 | +static const u32 _const_hash_mask = 16777215; // precomputed2 | |
| 3409 | +static const u32 _const_probe_inc = 16777216; // precomputed2 | |
| 3410 | +static Array_fixed_i32_1264 _const_rune_maps = {((i32)(0xB5)), 0xB5, 743, 0, 0xC0, 0xD6, 0, 32, 0xD8, 0xDE, 0, 32, 0xE0, 0xF6, -32, 0, | |
| 3411 | +0xF8, 0xFE, -32, 0, 0xFF, 0xFF, 121, 0, 0x100, 0x12F, -3, -3, 0x130, 0x130, 0, -199, | |
| 3412 | +0x131, 0x131, -232, 0, 0x132, 0x137, -3, -3, 0x139, 0x148, -3, -3, 0x14A, 0x177, -3, -3, | |
| 3413 | +0x178, 0x178, 0, -121, 0x179, 0x17E, -3, -3, 0x17F, 0x17F, -300, 0, 0x180, 0x180, 195, 0, | |
| 3414 | +0x181, 0x181, 0, 210, 0x182, 0x185, -3, -3, 0x186, 0x186, 0, 206, 0x187, 0x188, -3, -3, | |
| 3415 | +0x189, 0x18A, 0, 205, 0x18B, 0x18C, -3, -3, 0x18E, 0x18E, 0, 79, 0x18F, 0x18F, 0, 202, | |
| 3416 | +0x190, 0x190, 0, 203, 0x191, 0x192, -3, -3, 0x193, 0x193, 0, 205, 0x194, 0x194, 0, 207, | |
| 3417 | +0x195, 0x195, 97, 0, 0x196, 0x196, 0, 211, 0x197, 0x197, 0, 209, 0x198, 0x199, -3, -3, | |
| 3418 | +0x19A, 0x19A, 163, 0, 0x19C, 0x19C, 0, 211, 0x19D, 0x19D, 0, 213, 0x19E, 0x19E, 130, 0, | |
| 3419 | +0x19F, 0x19F, 0, 214, 0x1A0, 0x1A5, -3, -3, 0x1A6, 0x1A6, 0, 218, 0x1A7, 0x1A8, -3, -3, | |
| 3420 | +0x1A9, 0x1A9, 0, 218, 0x1AC, 0x1AD, -3, -3, 0x1AE, 0x1AE, 0, 218, 0x1AF, 0x1B0, -3, -3, | |
| 3421 | +0x1B1, 0x1B2, 0, 217, 0x1B3, 0x1B6, -3, -3, 0x1B7, 0x1B7, 0, 219, 0x1B8, 0x1B9, -3, -3, | |
| 3422 | +0x1BC, 0x1BD, -3, -3, 0x1BF, 0x1BF, 56, 0, 0x1C4, 0x1CC, -2, -2, 0x1CD, 0x1DC, -3, -3, | |
| 3423 | +0x1DD, 0x1DD, -79, 0, 0x1DE, 0x1EF, -3, -3, 0x1F1, 0x1F3, -2, -2, 0x1F4, 0x1F5, -3, -3, | |
| 3424 | +0x1F6, 0x1F6, 0, -97, 0x1F7, 0x1F7, 0, -56, 0x1F8, 0x21F, -3, -3, 0x220, 0x220, 0, -130, | |
| 3425 | +0x222, 0x233, -3, -3, 0x23A, 0x23A, 0, 10795, 0x23B, 0x23C, -3, -3, 0x23D, 0x23D, 0, -163, | |
| 3426 | +0x23E, 0x23E, 0, 10792, 0x23F, 0x240, 10815, 0, 0x241, 0x242, -3, -3, 0x243, 0x243, 0, -195, | |
| 3427 | +0x244, 0x244, 0, 69, 0x245, 0x245, 0, 71, 0x246, 0x24F, -3, -3, 0x250, 0x250, 10783, 0, | |
| 3428 | +0x251, 0x251, 10780, 0, 0x252, 0x252, 10782, 0, 0x253, 0x253, -210, 0, 0x254, 0x254, -206, 0, | |
| 3429 | +0x256, 0x257, -205, 0, 0x259, 0x259, -202, 0, 0x25B, 0x25B, -203, 0, 0x25C, 0x25C, 42319, 0, | |
| 3430 | +0x260, 0x260, -205, 0, 0x261, 0x261, 42315, 0, 0x263, 0x263, -207, 0, 0x265, 0x265, 42280, 0, | |
| 3431 | +0x266, 0x266, 42308, 0, 0x268, 0x268, -209, 0, 0x269, 0x269, -211, 0, 0x26A, 0x26A, 42308, 0, | |
| 3432 | +0x26B, 0x26B, 10743, 0, 0x26C, 0x26C, 42305, 0, 0x26F, 0x26F, -211, 0, 0x271, 0x271, 10749, 0, | |
| 3433 | +0x272, 0x272, -213, 0, 0x275, 0x275, -214, 0, 0x27D, 0x27D, 10727, 0, 0x280, 0x280, -218, 0, | |
| 3434 | +0x282, 0x282, 42307, 0, 0x283, 0x283, -218, 0, 0x287, 0x287, 42282, 0, 0x288, 0x288, -218, 0, | |
| 3435 | +0x289, 0x289, -69, 0, 0x28A, 0x28B, -217, 0, 0x28C, 0x28C, -71, 0, 0x292, 0x292, -219, 0, | |
| 3436 | +0x29D, 0x29D, 42261, 0, 0x29E, 0x29E, 42258, 0, 0x345, 0x345, 84, 0, 0x370, 0x373, -3, -3, | |
| 3437 | +0x376, 0x377, -3, -3, 0x37B, 0x37D, 130, 0, 0x37F, 0x37F, 0, 116, 0x386, 0x386, 0, 38, | |
| 3438 | +0x388, 0x38A, 0, 37, 0x38C, 0x38C, 0, 64, 0x38E, 0x38F, 0, 63, 0x391, 0x3A1, 0, 32, | |
| 3439 | +0x3A3, 0x3AB, 0, 32, 0x3AC, 0x3AC, -38, 0, 0x3AD, 0x3AF, -37, 0, 0x3B1, 0x3C1, -32, 0, | |
| 3440 | +0x3C2, 0x3C2, -31, 0, 0x3C3, 0x3CB, -32, 0, 0x3CC, 0x3CC, -64, 0, 0x3CD, 0x3CE, -63, 0, | |
| 3441 | +0x3CF, 0x3CF, 0, 8, 0x3D0, 0x3D0, -62, 0, 0x3D1, 0x3D1, -57, 0, 0x3D5, 0x3D5, -47, 0, | |
| 3442 | +0x3D6, 0x3D6, -54, 0, 0x3D7, 0x3D7, -8, 0, 0x3D8, 0x3EF, -3, -3, 0x3F0, 0x3F0, -86, 0, | |
| 3443 | +0x3F1, 0x3F1, -80, 0, 0x3F2, 0x3F2, 7, 0, 0x3F3, 0x3F3, -116, 0, 0x3F4, 0x3F4, 0, -60, | |
| 3444 | +0x3F5, 0x3F5, -96, 0, 0x3F7, 0x3F8, -3, -3, 0x3F9, 0x3F9, 0, -7, 0x3FA, 0x3FB, -3, -3, | |
| 3445 | +0x3FD, 0x3FF, 0, -130, 0x400, 0x40F, 0, 80, 0x410, 0x42F, 0, 32, 0x430, 0x44F, -32, 0, | |
| 3446 | +0x450, 0x45F, -80, 0, 0x460, 0x481, -3, -3, 0x48A, 0x4BF, -3, -3, 0x4C0, 0x4C0, 0, 15, | |
| 3447 | +0x4C1, 0x4CE, -3, -3, 0x4CF, 0x4CF, -15, 0, 0x4D0, 0x52F, -3, -3, 0x531, 0x556, 0, 48, | |
| 3448 | +0x561, 0x586, -48, 0, 0x10A0, 0x10C5, 0, 7264, 0x10C7, 0x10C7, 0, 7264, 0x10CD, 0x10CD, 0, 7264, | |
| 3449 | +0x10D0, 0x10FA, 3008, 0, 0x10FD, 0x10FF, 3008, 0, 0x13A0, 0x13EF, 0, 38864, 0x13F0, 0x13F5, 0, 8, | |
| 3450 | +0x13F8, 0x13FD, -8, 0, 0x1C80, 0x1C80, -6254, 0, 0x1C81, 0x1C81, -6253, 0, 0x1C82, 0x1C82, -6244, 0, | |
| 3451 | +0x1C83, 0x1C84, -6242, 0, 0x1C85, 0x1C85, -6243, 0, 0x1C86, 0x1C86, -6236, 0, 0x1C87, 0x1C87, -6181, 0, | |
| 3452 | +0x1C88, 0x1C88, 35266, 0, 0x1C90, 0x1CBA, 0, -3008, 0x1CBD, 0x1CBF, 0, -3008, 0x1D79, 0x1D79, 35332, 0, | |
| 3453 | +0x1D7D, 0x1D7D, 3814, 0, 0x1D8E, 0x1D8E, 35384, 0, 0x1E00, 0x1E95, -3, -3, 0x1E9B, 0x1E9B, -59, 0, | |
| 3454 | +0x1E9E, 0x1E9E, 0, -7615, 0x1EA0, 0x1EFF, -3, -3, 0x1F00, 0x1F07, 8, 0, 0x1F08, 0x1F0F, 0, -8, | |
| 3455 | +0x1F10, 0x1F15, 8, 0, 0x1F18, 0x1F1D, 0, -8, 0x1F20, 0x1F27, 8, 0, 0x1F28, 0x1F2F, 0, -8, | |
| 3456 | +0x1F30, 0x1F37, 8, 0, 0x1F38, 0x1F3F, 0, -8, 0x1F40, 0x1F45, 8, 0, 0x1F48, 0x1F4D, 0, -8, | |
| 3457 | +0x1F51, 0x1F51, 8, 0, 0x1F53, 0x1F53, 8, 0, 0x1F55, 0x1F55, 8, 0, 0x1F57, 0x1F57, 8, 0, | |
| 3458 | +0x1F59, 0x1F59, 0, -8, 0x1F5B, 0x1F5B, 0, -8, 0x1F5D, 0x1F5D, 0, -8, 0x1F5F, 0x1F5F, 0, -8, | |
| 3459 | +0x1F60, 0x1F67, 8, 0, 0x1F68, 0x1F6F, 0, -8, 0x1F70, 0x1F71, 74, 0, 0x1F72, 0x1F75, 86, 0, | |
| 3460 | +0x1F76, 0x1F77, 100, 0, 0x1F78, 0x1F79, 128, 0, 0x1F7A, 0x1F7B, 112, 0, 0x1F7C, 0x1F7D, 126, 0, | |
| 3461 | +0x1F80, 0x1F87, 8, 0, 0x1F88, 0x1F8F, 0, -8, 0x1F90, 0x1F97, 8, 0, 0x1F98, 0x1F9F, 0, -8, | |
| 3462 | +0x1FA0, 0x1FA7, 8, 0, 0x1FA8, 0x1FAF, 0, -8, 0x1FB0, 0x1FB1, 8, 0, 0x1FB3, 0x1FB3, 9, 0, | |
| 3463 | +0x1FB8, 0x1FB9, 0, -8, 0x1FBA, 0x1FBB, 0, -74, 0x1FBC, 0x1FBC, 0, -9, 0x1FBE, 0x1FBE, -7205, 0, | |
| 3464 | +0x1FC3, 0x1FC3, 9, 0, 0x1FC8, 0x1FCB, 0, -86, 0x1FCC, 0x1FCC, 0, -9, 0x1FD0, 0x1FD1, 8, 0, | |
| 3465 | +0x1FD8, 0x1FD9, 0, -8, 0x1FDA, 0x1FDB, 0, -100, 0x1FE0, 0x1FE1, 8, 0, 0x1FE5, 0x1FE5, 7, 0, | |
| 3466 | +0x1FE8, 0x1FE9, 0, -8, 0x1FEA, 0x1FEB, 0, -112, 0x1FEC, 0x1FEC, 0, -7, 0x1FF3, 0x1FF3, 9, 0, | |
| 3467 | +0x1FF8, 0x1FF9, 0, -128, 0x1FFA, 0x1FFB, 0, -126, 0x1FFC, 0x1FFC, 0, -9, 0x2126, 0x2126, 0, -7517, | |
| 3468 | +0x212A, 0x212A, 0, -8383, 0x212B, 0x212B, 0, -8262, 0x2132, 0x2132, 0, 28, 0x214E, 0x214E, -28, 0, | |
| 3469 | +0x2160, 0x216F, 0, 16, 0x2170, 0x217F, -16, 0, 0x2183, 0x2184, -3, -3, 0x24B6, 0x24CF, 0, 26, | |
| 3470 | +0x24D0, 0x24E9, -26, 0, 0x2C00, 0x2C2F, 0, 48, 0x2C30, 0x2C5F, -48, 0, 0x2C60, 0x2C61, -3, -3, | |
| 3471 | +0x2C62, 0x2C62, 0, -10743, 0x2C63, 0x2C63, 0, -3814, 0x2C64, 0x2C64, 0, -10727, 0x2C65, 0x2C65, -10795, 0, | |
| 3472 | +0x2C66, 0x2C66, -10792, 0, 0x2C67, 0x2C6C, -3, -3, 0x2C6D, 0x2C6D, 0, -10780, 0x2C6E, 0x2C6E, 0, -10749, | |
| 3473 | +0x2C6F, 0x2C6F, 0, -10783, 0x2C70, 0x2C70, 0, -10782, 0x2C72, 0x2C73, -3, -3, 0x2C75, 0x2C76, -3, -3, | |
| 3474 | +0x2C7E, 0x2C7F, 0, -10815, 0x2C80, 0x2CE3, -3, -3, 0x2CEB, 0x2CEE, -3, -3, 0x2CF2, 0x2CF3, -3, -3, | |
| 3475 | +0x2D00, 0x2D25, -7264, 0, 0x2D27, 0x2D27, -7264, 0, 0x2D2D, 0x2D2D, -7264, 0, 0xA640, 0xA66D, -3, -3, | |
| 3476 | +0xA680, 0xA69B, -3, -3, 0xA722, 0xA72F, -3, -3, 0xA732, 0xA76F, -3, -3, 0xA779, 0xA77C, -3, -3, | |
| 3477 | +0xA77D, 0xA77D, 0, -35332, 0xA77E, 0xA787, -3, -3, 0xA78B, 0xA78C, -3, -3, 0xA78D, 0xA78D, 0, -42280, | |
| 3478 | +0xA790, 0xA793, -3, -3, 0xA794, 0xA794, 48, 0, 0xA796, 0xA7A9, -3, -3, 0xA7AA, 0xA7AA, 0, -42308, | |
| 3479 | +0xA7AB, 0xA7AB, 0, -42319, 0xA7AC, 0xA7AC, 0, -42315, 0xA7AD, 0xA7AD, 0, -42305, 0xA7AE, 0xA7AE, 0, -42308, | |
| 3480 | +0xA7B0, 0xA7B0, 0, -42258, 0xA7B1, 0xA7B1, 0, -42282, 0xA7B2, 0xA7B2, 0, -42261, 0xA7B3, 0xA7B3, 0, 928, | |
| 3481 | +0xA7B4, 0xA7C3, -3, -3, 0xA7C4, 0xA7C4, 0, -48, 0xA7C5, 0xA7C5, 0, -42307, 0xA7C6, 0xA7C6, 0, -35384, | |
| 3482 | +0xA7C7, 0xA7CA, -3, -3, 0xA7D0, 0xA7D1, -3, -3, 0xA7D6, 0xA7D9, -3, -3, 0xA7F5, 0xA7F6, -3, -3, | |
| 3483 | +0xAB53, 0xAB53, -928, 0, 0xAB70, 0xABBF, -38864, 0, 0xFF21, 0xFF3A, 0, 32, 0xFF41, 0xFF5A, -32, 0, | |
| 3484 | +0x10400, 0x10427, 0, 40, 0x10428, 0x1044F, -40, 0, 0x104B0, 0x104D3, 0, 40, 0x104D8, 0x104FB, -40, 0, | |
| 3485 | +0x10570, 0x1057A, 0, 39, 0x1057C, 0x1058A, 0, 39, 0x1058C, 0x10592, 0, 39, 0x10594, 0x10595, 0, 39, | |
| 3486 | +0x10597, 0x105A1, -39, 0, 0x105A3, 0x105B1, -39, 0, 0x105B3, 0x105B9, -39, 0, 0x105BB, 0x105BC, -39, 0, | |
| 3487 | +0x10C80, 0x10CB2, 0, 64, 0x10CC0, 0x10CF2, -64, 0, 0x118A0, 0x118BF, 0, 32, 0x118C0, 0x118DF, -32, 0, | |
| 3488 | +0x16E40, 0x16E5F, 0, 32, 0x16E60, 0x16E7F, -32, 0, 0x1E900, 0x1E921, 0, 34, 0x1E922, 0x1E943, -34, 0}; // fixed array const | |
| 3489 | +static const u8 _const_str_intp_has_dynamic_width = 1; // precomputed2 | |
| 3490 | +static const u8 _const_str_intp_has_dynamic_precision = 2; // precomputed2 | |
| 3491 | +static rune _const_utf8_replacement_rune; // inited later | |
| 3492 | +static u32 _const_builtin__closure__closure_size_1; // inited later | |
| 3493 | +Array_fixed_int_64 g_autostr_type_stack = {0}; // global 6 | |
| 3494 | + | |
| 3495 | +Array_fixed_voidptr_64 g_autostr_addr_stack = {0}; // global 6 | |
| 3496 | + | |
| 3497 | +static int _const_builtin__closure__closure_size; // inited later | |
| 3498 | + | |
| 3499 | +// V interface table: | |
| 3500 | +static IError I_None___to_Interface_IError(None__* x); | |
| 3501 | +enum { _IError_None___index = 1 }; | |
| 3502 | +static IError I_voidptr_to_Interface_IError(voidptr* x); | |
| 3503 | +enum { _IError_voidptr_index = 2 }; | |
| 3504 | +static IError I_MessageError_to_Interface_IError(MessageError* x); | |
| 3505 | +enum { _IError_MessageError_index = 3 }; | |
| 3506 | +static IError I_Error_to_Interface_IError(Error* x); | |
| 3507 | +enum { _IError_Error_index = 4 }; | |
| 3508 | +// ^^^ number of types for interface IError: 4 | |
| 3509 | + | |
| 3510 | +// Methods wrapper for interface "IError" | |
| 3511 | +static inline int builtin__None___code_Interface_IError_method_wrapper(None__* err) { | |
| 3512 | + return builtin__Error_code(err->Error); | |
| 3513 | +} | |
| 3514 | +static inline int builtin__None___code_Interface_IError_method_adapter(void* _x) { | |
| 3515 | + return builtin__None___code_Interface_IError_method_wrapper((None__*)_x); | |
| 3516 | +} | |
| 3517 | +static inline string builtin__None___msg_Interface_IError_method_wrapper(None__* err) { | |
| 3518 | + return builtin__Error_msg(err->Error); | |
| 3519 | +} | |
| 3520 | +static inline string builtin__None___msg_Interface_IError_method_adapter(void* _x) { | |
| 3521 | + return builtin__None___msg_Interface_IError_method_wrapper((None__*)_x); | |
| 3522 | +} | |
| 3523 | +static inline int builtin__MessageError_code_Interface_IError_method_wrapper(MessageError* err) { | |
| 3524 | + return builtin__MessageError_code(*err); | |
| 3525 | +} | |
| 3526 | +static inline int builtin__MessageError_code_Interface_IError_method_adapter(void* _x) { | |
| 3527 | + return builtin__MessageError_code_Interface_IError_method_wrapper((MessageError*)_x); | |
| 3528 | +} | |
| 3529 | +static inline string builtin__MessageError_msg_Interface_IError_method_wrapper(MessageError* err) { | |
| 3530 | + return builtin__MessageError_msg(*err); | |
| 3531 | +} | |
| 3532 | +static inline string builtin__MessageError_msg_Interface_IError_method_adapter(void* _x) { | |
| 3533 | + return builtin__MessageError_msg_Interface_IError_method_wrapper((MessageError*)_x); | |
| 3534 | +} | |
| 3535 | +static inline int builtin__Error_code_Interface_IError_method_wrapper(Error* err) { | |
| 3536 | + return builtin__Error_code(*err); | |
| 3537 | +} | |
| 3538 | +static inline int builtin__Error_code_Interface_IError_method_adapter(void* _x) { | |
| 3539 | + return builtin__Error_code_Interface_IError_method_wrapper((Error*)_x); | |
| 3540 | +} | |
| 3541 | +static inline string builtin__Error_msg_Interface_IError_method_wrapper(Error* err) { | |
| 3542 | + return builtin__Error_msg(*err); | |
| 3543 | +} | |
| 3544 | +static inline string builtin__Error_msg_Interface_IError_method_adapter(void* _x) { | |
| 3545 | + return builtin__Error_msg_Interface_IError_method_wrapper((Error*)_x); | |
| 3546 | +} | |
| 3547 | + | |
| 3548 | +struct _IError_interface_methods { | |
| 3549 | + int (*_method_code)(void* _); | |
| 3550 | + string (*_method_msg)(void* _); | |
| 3551 | +}; | |
| 3552 | + | |
| 3553 | +struct _IError_interface_methods IError_name_table[5] = { | |
| 3554 | + {0}, | |
| 3555 | + { | |
| 3556 | + ._method_code = builtin__None___code_Interface_IError_method_adapter, | |
| 3557 | + ._method_msg = builtin__None___msg_Interface_IError_method_adapter, | |
| 3558 | + }, | |
| 3559 | + { | |
| 3560 | + ._method_code = (void*) 0, | |
| 3561 | + ._method_msg = (void*) 0, | |
| 3562 | + }, | |
| 3563 | + { | |
| 3564 | + ._method_code = builtin__MessageError_code_Interface_IError_method_adapter, | |
| 3565 | + ._method_msg = builtin__MessageError_msg_Interface_IError_method_adapter, | |
| 3566 | + }, | |
| 3567 | + { | |
| 3568 | + ._method_code = builtin__Error_code_Interface_IError_method_adapter, | |
| 3569 | + ._method_msg = builtin__Error_msg_Interface_IError_method_adapter, | |
| 3570 | + }, | |
| 3571 | +}; | |
| 3572 | + | |
| 3573 | + | |
| 3574 | +// Casting functions for converting "None__" to interface "IError" | |
| 3575 | + | |
| 3576 | +static inline IError I_None___to_Interface_IError(None__* x) { | |
| 3577 | +return (IError) { | |
| 3578 | + ._None__ = x, | |
| 3579 | + ._typ = _IError_None___index, | |
| 3580 | + ._methods = &IError_name_table[_IError_None___index], | |
| 3581 | + }; | |
| 3582 | +} | |
| 3583 | + | |
| 3584 | +// Casting functions for converting "voidptr" to interface "IError" | |
| 3585 | + | |
| 3586 | +static inline IError I_voidptr_to_Interface_IError(voidptr* x) { | |
| 3587 | +return (IError) { | |
| 3588 | + ._voidptr = x, | |
| 3589 | + ._typ = _IError_voidptr_index, | |
| 3590 | + ._methods = &IError_name_table[_IError_voidptr_index], | |
| 3591 | + }; | |
| 3592 | +} | |
| 3593 | + | |
| 3594 | +// Casting functions for converting "MessageError" to interface "IError" | |
| 3595 | + | |
| 3596 | +static inline IError I_MessageError_to_Interface_IError(MessageError* x) { | |
| 3597 | +return (IError) { | |
| 3598 | + ._MessageError = x, | |
| 3599 | + ._typ = _IError_MessageError_index, | |
| 3600 | + ._methods = &IError_name_table[_IError_MessageError_index], | |
| 3601 | + }; | |
| 3602 | +} | |
| 3603 | + | |
| 3604 | +// Casting functions for converting "Error" to interface "IError" | |
| 3605 | + | |
| 3606 | +static inline IError I_Error_to_Interface_IError(Error* x) { | |
| 3607 | +return (IError) { | |
| 3608 | + ._Error = x, | |
| 3609 | + ._typ = _IError_Error_index, | |
| 3610 | + ._methods = &IError_name_table[_IError_Error_index], | |
| 3611 | + }; | |
| 3612 | +} | |
| 3613 | + | |
| 3614 | + | |
| 3615 | +static inline IError __v_interface_clone_variant__IError__None__(void* x) { | |
| 3616 | +return I_None___to_Interface_IError((None__*)builtin__memdup(x, sizeof(None__))); | |
| 3617 | +} | |
| 3618 | + | |
| 3619 | +static inline IError __v_interface_clone_variant__IError__voidptr(void* x) { | |
| 3620 | +return I_voidptr_to_Interface_IError((voidptr*)builtin__memdup(x, sizeof(voidptr))); | |
| 3621 | +} | |
| 3622 | + | |
| 3623 | +static inline IError __v_interface_clone_variant__IError__MessageError(void* x) { | |
| 3624 | +return I_MessageError_to_Interface_IError((MessageError*)builtin__memdup(x, sizeof(MessageError))); | |
| 3625 | +} | |
| 3626 | + | |
| 3627 | +static inline IError __v_interface_clone_variant__IError__Error(void* x) { | |
| 3628 | +return I_Error_to_Interface_IError((Error*)builtin__memdup(x, sizeof(Error))); | |
| 3629 | +} | |
| 3630 | + | |
| 3631 | +static inline IError __v_interface_clone__IError(IError x) { | |
| 3632 | + if (x._object == 0) { | |
| 3633 | + return x; | |
| 3634 | + } | |
| 3635 | + if (x._typ == _IError_None___index) { | |
| 3636 | + return __v_interface_clone_variant__IError__None__(x._object); | |
| 3637 | + } | |
| 3638 | + if (x._typ == _IError_voidptr_index) { | |
| 3639 | + return __v_interface_clone_variant__IError__voidptr(x._object); | |
| 3640 | + } | |
| 3641 | + if (x._typ == _IError_MessageError_index) { | |
| 3642 | + return __v_interface_clone_variant__IError__MessageError(x._object); | |
| 3643 | + } | |
| 3644 | + if (x._typ == _IError_Error_index) { | |
| 3645 | + return __v_interface_clone_variant__IError__Error(x._object); | |
| 3646 | + } | |
| 3647 | + return x; | |
| 3648 | +} | |
| 3649 | + | |
| 3650 | + | |
| 3651 | +// V sort fn definitions: | |
| 3652 | +VV_LOC int compare_11734835982493514523_RepIndex_by_idx_expr_612e6964780a3c0a622e696478(RepIndex* a, RepIndex* b) { | |
| 3653 | + if (a->idx < b->idx) return -1; | |
| 3654 | + if (b->idx < a->idx) return 1; | |
| 3655 | + return 0; | |
| 3656 | +} | |
| 3657 | + | |
| 3658 | +VV_LOC int compare_11734835982493514523_RepIndex_by_idx_expr_612e6964780a3c0a622e696478_qsort_adapter(const void* a, const void* b) { | |
| 3659 | + return compare_11734835982493514523_RepIndex_by_idx_expr_612e6964780a3c0a622e696478((RepIndex*)a, (RepIndex*)b); | |
| 3660 | +} | |
| 3661 | + | |
| 3662 | +VV_LOC int builtin__compare_lower_strings_qsort_adapter(const void* a, const void* b) { | |
| 3663 | + return builtin__compare_lower_strings((string*)a, (string*)b); | |
| 3664 | +} | |
| 3665 | + | |
| 3666 | +VV_LOC int builtin__compare_strings_by_len_qsort_adapter(const void* a, const void* b) { | |
| 3667 | + return builtin__compare_strings_by_len((string*)a, (string*)b); | |
| 3668 | +} | |
| 3669 | + | |
| 3670 | +static inline u64 VSAFE_DIV_u64(u64 x, u64 y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("division by zero")); } return x / y; } | |
| 3671 | +static inline u64 VSAFE_MOD_u64(u64 x, u64 y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("modulo by zero")); } return x % y; } | |
| 3672 | +static inline int VSAFE_DIV_int(int x, int y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("division by zero")); } return x / y; } | |
| 3673 | +static inline usize VSAFE_MOD_usize(usize x, usize y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("modulo by zero")); } return x % y; } | |
| 3674 | +static inline u32 VSAFE_DIV_u32(u32 x, u32 y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("division by zero")); } return x / y; } | |
| 3675 | +static inline u32 VSAFE_MOD_u32(u32 x, u32 y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("modulo by zero")); } return x % y; } | |
| 3676 | +static inline i64 VSAFE_DIV_i64(i64 x, i64 y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("division by zero")); } return x / y; } | |
| 3677 | +static inline int VSAFE_MOD_int(int x, int y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("modulo by zero")); } return x % y; } | |
| 3678 | +static inline i64 VSAFE_MOD_i64(i64 x, i64 y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("modulo by zero")); } return x % y; } | |
| 3679 | +static inline rune VSAFE_MOD_rune(rune x, rune y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("modulo by zero")); } return x % y; } | |
| 3680 | + | |
| 3681 | +// end of V out (header) | |
| 3682 | + | |
| 3683 | +// V auto functions: | |
| 3684 | +static bool Array_u8_contains(Array_u8 a, u8 v) { | |
| 3685 | + for (int i = 0; i < a.len; ++i) { | |
| 3686 | + if (((u8*)a.data)[i] == v) { | |
| 3687 | + return true; | |
| 3688 | + } | |
| 3689 | + } | |
| 3690 | + return false; | |
| 3691 | +} | |
| 3692 | + | |
| 3693 | +static inline bool Array_rune_arr_eq(Array_rune a, Array_rune b) { | |
| 3694 | + if (a.len != b.len) { | |
| 3695 | + return false; | |
| 3696 | + } | |
| 3697 | + for (int i = 0; i < a.len; ++i) { | |
| 3698 | + if (*((rune*)((byte*)a.data+(i*a.element_size))) != *((rune*)((byte*)b.data+(i*b.element_size)))) { | |
| 3699 | + return false; | |
| 3700 | + } | |
| 3701 | + } | |
| 3702 | + return true; | |
| 3703 | +} | |
| 3704 | + | |
| 3705 | +static inline bool builtin__closure__ClosureLifetimeRecord_struct_eq(builtin__closure__ClosureLifetimeRecord a, builtin__closure__ClosureLifetimeRecord b) { | |
| 3706 | + return a.exec_ptr == b.exec_ptr | |
| 3707 | + && a.generation == b.generation; | |
| 3708 | +} | |
| 3709 | + | |
| 3710 | +static inline bool Array_builtin__closure__ClosureLifetimeRecord_arr_eq(Array_builtin__closure__ClosureLifetimeRecord a, Array_builtin__closure__ClosureLifetimeRecord b) { | |
| 3711 | + if (a.len != b.len) { | |
| 3712 | + return false; | |
| 3713 | + } | |
| 3714 | + for (int i = 0; i < a.len; ++i) { | |
| 3715 | + if (!builtin__closure__ClosureLifetimeRecord_struct_eq(((builtin__closure__ClosureLifetimeRecord*)a.data)[i], ((builtin__closure__ClosureLifetimeRecord*)b.data)[i])) { | |
| 3716 | + return false; | |
| 3717 | + } | |
| 3718 | + } | |
| 3719 | + return true; | |
| 3720 | +} | |
| 3721 | + | |
| 3722 | +static inline bool builtin__closure__ClosureLifetimeFrame_struct_eq(builtin__closure__ClosureLifetimeFrame a, builtin__closure__ClosureLifetimeFrame b) { | |
| 3723 | + return a.start == b.start | |
| 3724 | + && a.end == b.end; | |
| 3725 | +} | |
| 3726 | + | |
| 3727 | +static inline bool Array_builtin__closure__ClosureLifetimeFrame_arr_eq(Array_builtin__closure__ClosureLifetimeFrame a, Array_builtin__closure__ClosureLifetimeFrame b) { | |
| 3728 | + if (a.len != b.len) { | |
| 3729 | + return false; | |
| 3730 | + } | |
| 3731 | + for (int i = 0; i < a.len; ++i) { | |
| 3732 | + if (!builtin__closure__ClosureLifetimeFrame_struct_eq(((builtin__closure__ClosureLifetimeFrame*)a.data)[i], ((builtin__closure__ClosureLifetimeFrame*)b.data)[i])) { | |
| 3733 | + return false; | |
| 3734 | + } | |
| 3735 | + } | |
| 3736 | + return true; | |
| 3737 | +} | |
| 3738 | + | |
| 3739 | +static inline bool builtin__closure__ClosureLifetimeState_struct_eq(builtin__closure__ClosureLifetimeState a, builtin__closure__ClosureLifetimeState b) { | |
| 3740 | + return a.owner_thread == b.owner_thread | |
| 3741 | + && a.active == b.active | |
| 3742 | + && a.disposed == b.disposed | |
| 3743 | + && a.suspended == b.suspended | |
| 3744 | + && a.frame_start == b.frame_start | |
| 3745 | + && a.frame_gen == b.frame_gen | |
| 3746 | + && a.generation == b.generation | |
| 3747 | + && a.frame_generation == b.frame_generation | |
| 3748 | + && Array_builtin__closure__ClosureLifetimeRecord_arr_eq(a.records, b.records) | |
| 3749 | + && Array_builtin__closure__ClosureLifetimeFrame_arr_eq(a.frames, b.frames) | |
| 3750 | + && a.next_free == b.next_free; | |
| 3751 | +} | |
| 3752 | + | |
| 3753 | + | |
| 3754 | +// >> typeof() support for sum types / interfaces | |
| 3755 | +static char * v_typeof_interface_IError(u32 sidx) { | |
| 3756 | + if (sidx == _IError_None___index) return "None__"; | |
| 3757 | + if (sidx == _IError_voidptr_index) return "voidptr"; | |
| 3758 | + if (sidx == _IError_MessageError_index) return "MessageError"; | |
| 3759 | + if (sidx == _IError_Error_index) return "Error"; | |
| 3760 | + return "unknown IError"; | |
| 3761 | +} | |
| 3762 | + | |
| 3763 | +u32 v_typeof_interface_idx_IError(u32 sidx) { | |
| 3764 | + if (sidx == _IError_None___index) return 65; | |
| 3765 | + if (sidx == _IError_voidptr_index) return 2; | |
| 3766 | + if (sidx == _IError_MessageError_index) return 67; | |
| 3767 | + if (sidx == _IError_Error_index) return 66; | |
| 3768 | + return 30; | |
| 3769 | +} | |
| 3770 | +// << typeof() support for sum types | |
| 3771 | + | |
| 3772 | +strings__Builder strings__new_builder(int initial_size) { | |
| 3773 | + strings__Builder res = ((builtin____new_array_with_default(0, initial_size, sizeof(u8), 0))); | |
| 3774 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | |
| 3775 | + return res; | |
| 3776 | +} | |
| 3777 | +Array_u8 strings__Builder_reuse_as_plain_u8_array(strings__Builder* b) { | |
| 3778 | + builtin__ArrayFlags_clear(&b->flags, ArrayFlags__noslices); | |
| 3779 | + return *b; | |
| 3780 | +} | |
| 3781 | +void strings__Builder_write_ptr(strings__Builder* b, u8* ptr, int len) { | |
| 3782 | + if (len == 0) { | |
| 3783 | + return; | |
| 3784 | + } | |
| 3785 | + builtin__array_push_many(b, ptr, len); | |
| 3786 | +} | |
| 3787 | +void strings__Builder_write_rune(strings__Builder* b, rune r) { | |
| 3788 | + Array_fixed_u8_5 buffer = {0}; | |
| 3789 | + string res = builtin__utf32_to_str_no_malloc(((u32)(r)), &buffer[0]); | |
| 3790 | + if (res.len == 0) { | |
| 3791 | + return; | |
| 3792 | + } | |
| 3793 | + builtin__array_push_many(b, res.str, res.len); | |
| 3794 | +} | |
| 3795 | +void strings__Builder_write_runes(strings__Builder* b, Array_rune runes) { | |
| 3796 | + Array_fixed_u8_5 buffer = {0}; | |
| 3797 | + for (int _t1 = 0; _t1 < runes.len; ++_t1) { | |
| 3798 | + rune r = ((rune*)runes.data)[_t1]; | |
| 3799 | + string res = builtin__utf32_to_str_no_malloc(((u32)(r)), &buffer[0]); | |
| 3800 | + if (res.len == 0) { | |
| 3801 | + continue; | |
| 3802 | + } | |
| 3803 | + builtin__array_push_many(b, res.str, res.len); | |
| 3804 | + } | |
| 3805 | +} | |
| 3806 | +inline void strings__Builder_write_u8(strings__Builder* b, u8 data) { | |
| 3807 | + builtin__array_push((array*)b, _MOV((u8[]){ data })); | |
| 3808 | +} | |
| 3809 | +inline void strings__Builder_write_byte(strings__Builder* b, u8 data) { | |
| 3810 | + builtin__array_push((array*)b, _MOV((u8[]){ data })); | |
| 3811 | +} | |
| 3812 | +void strings__Builder_write_decimal(strings__Builder* b, i64 n) { | |
| 3813 | + if (n == 0) { | |
| 3814 | + strings__Builder_write_u8(b, 0x30); | |
| 3815 | + return; | |
| 3816 | + } | |
| 3817 | + u64 mag = ((u64)(n)); | |
| 3818 | + if (n < 0) { | |
| 3819 | + strings__Builder_write_u8(b, '-'); | |
| 3820 | + mag = ((u64)(0)) - mag; | |
| 3821 | + } | |
| 3822 | + strings__Builder_write_u_decimal(b, mag); | |
| 3823 | +} | |
| 3824 | +void strings__Builder_write_u_decimal(strings__Builder* b, u64 n) { | |
| 3825 | + if (n == 0) { | |
| 3826 | + strings__Builder_write_u8(b, 0x30); | |
| 3827 | + return; | |
| 3828 | + } | |
| 3829 | + Array_fixed_u8_20 buf = {0}; | |
| 3830 | + u64 x = n; | |
| 3831 | + int i = 19; | |
| 3832 | + for (;;) { | |
| 3833 | + if (!(x != 0)) break; | |
| 3834 | + u64 nextx = VSAFE_DIV_u64(x , 10); | |
| 3835 | + u64 r = VSAFE_MOD_u64(x , 10); | |
| 3836 | + buf[i] = (u8)(((u8)(r)) + 0x30); | |
| 3837 | + x = nextx; | |
| 3838 | + i--; | |
| 3839 | + } | |
| 3840 | + strings__Builder_write_ptr(b, &buf[i + 1], 19 - i); | |
| 3841 | +} | |
| 3842 | +_result_int strings__Builder_write(strings__Builder* b, Array_u8 data) { | |
| 3843 | + if (data.len == 0) { | |
| 3844 | + _result_int _t1; | |
| 3845 | + builtin___result_ok(&(int[]) { 0 }, (_result*)(&_t1), sizeof(int)); | |
| 3846 | + | |
| 3847 | + return _t1; | |
| 3848 | + } | |
| 3849 | + builtin__array_push_many(b, data.data, data.len); | |
| 3850 | + _result_int _t2; | |
| 3851 | + builtin___result_ok(&(int[]) { data.len }, (_result*)(&_t2), sizeof(int)); | |
| 3852 | + | |
| 3853 | + return _t2; | |
| 3854 | +} | |
| 3855 | +void strings__Builder_drain_builder(strings__Builder* b, strings__Builder* other, int other_new_cap) { | |
| 3856 | + if (other->len > 0) { | |
| 3857 | + _PUSH_MANY(b, (*other), _t1, strings__Builder); | |
| 3858 | + } | |
| 3859 | + strings__Builder_free(other); | |
| 3860 | + *other = strings__new_builder(other_new_cap); | |
| 3861 | +} | |
| 3862 | +inline u8 strings__Builder_byte_at(strings__Builder* b, int n) { | |
| 3863 | + return (*(u8*)builtin__array_get(*(((Array_u8*)(b))), n)); | |
| 3864 | +} | |
| 3865 | +inline void strings__Builder_write_string(strings__Builder* b, string s) { | |
| 3866 | + if (s.len == 0) { | |
| 3867 | + return; | |
| 3868 | + } | |
| 3869 | + builtin__array_push_many(b, s.str, s.len); | |
| 3870 | +} | |
| 3871 | +inline void strings__Builder_write_string2(strings__Builder* b, string s1, string s2) { | |
| 3872 | + if (s1.len != 0) { | |
| 3873 | + builtin__array_push_many(b, s1.str, s1.len); | |
| 3874 | + } | |
| 3875 | + if (s2.len != 0) { | |
| 3876 | + builtin__array_push_many(b, s2.str, s2.len); | |
| 3877 | + } | |
| 3878 | +} | |
| 3879 | +void strings__Builder_go_back(strings__Builder* b, int n) { | |
| 3880 | + builtin__array_trim(b, b->len - n); | |
| 3881 | +} | |
| 3882 | +inline string strings__Builder_spart(strings__Builder* b, int start_pos, int n) { | |
| 3883 | + { // Unsafe block | |
| 3884 | + u8* x = builtin__malloc_noscan(n + 1); | |
| 3885 | + builtin__vmemcpy(x, ((u8*)(b->data)) + start_pos, n); | |
| 3886 | + x[n] = 0; | |
| 3887 | + return builtin__tos(x, n); | |
| 3888 | + } | |
| 3889 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 3890 | +} | |
| 3891 | +string strings__Builder_cut_last(strings__Builder* b, int n) { | |
| 3892 | + int cut_pos = b->len - n; | |
| 3893 | + string res = strings__Builder_spart(b, cut_pos, n); | |
| 3894 | + builtin__array_trim(b, cut_pos); | |
| 3895 | + return res; | |
| 3896 | +} | |
| 3897 | +string strings__Builder_cut_to(strings__Builder* b, int pos) { | |
| 3898 | + if (pos > b->len) { | |
| 3899 | + return _S(""); | |
| 3900 | + } | |
| 3901 | + return strings__Builder_cut_last(b, b->len - pos); | |
| 3902 | +} | |
| 3903 | +void strings__Builder_go_back_to(strings__Builder* b, int pos) { | |
| 3904 | + builtin__array_trim(b, pos); | |
| 3905 | +} | |
| 3906 | +inline void strings__Builder_writeln(strings__Builder* b, string s) { | |
| 3907 | + if ((s).len != 0) { | |
| 3908 | + builtin__array_push_many(b, s.str, s.len); | |
| 3909 | + } | |
| 3910 | + builtin__array_push((array*)b, _MOV((u8[]){ ((u8)('\n')) })); | |
| 3911 | +} | |
| 3912 | +inline void strings__Builder_writeln2(strings__Builder* b, string s1, string s2) { | |
| 3913 | + if ((s1).len != 0) { | |
| 3914 | + builtin__array_push_many(b, s1.str, s1.len); | |
| 3915 | + } | |
| 3916 | + builtin__array_push((array*)b, _MOV((u8[]){ ((u8)('\n')) })); | |
| 3917 | + if ((s2).len != 0) { | |
| 3918 | + builtin__array_push_many(b, s2.str, s2.len); | |
| 3919 | + } | |
| 3920 | + builtin__array_push((array*)b, _MOV((u8[]){ ((u8)('\n')) })); | |
| 3921 | +} | |
| 3922 | +string strings__Builder_last_n(strings__Builder* b, int n) { | |
| 3923 | + if (n > b->len) { | |
| 3924 | + return _S(""); | |
| 3925 | + } | |
| 3926 | + return strings__Builder_spart(b, b->len - n, n); | |
| 3927 | +} | |
| 3928 | +string strings__Builder_after(strings__Builder* b, int n) { | |
| 3929 | + if (n >= b->len) { | |
| 3930 | + return _S(""); | |
| 3931 | + } | |
| 3932 | + return strings__Builder_spart(b, n, b->len - n); | |
| 3933 | +} | |
| 3934 | +string strings__Builder_str(strings__Builder* b) { | |
| 3935 | + builtin__array_push((array*)b, _MOV((u8[]){ ((u8)(0)) })); | |
| 3936 | + u8* bcopy = ((u8*)(builtin__memdup_noscan(b->data, b->len))); | |
| 3937 | + string s = builtin__u8_vstring_with_len(bcopy, b->len - 1); | |
| 3938 | + builtin__array_clear(b); | |
| 3939 | + return s; | |
| 3940 | +} | |
| 3941 | +void strings__Builder_ensure_cap(strings__Builder* b, int n) { | |
| 3942 | + Array_u8* arr = ((Array_u8*)(b)); | |
| 3943 | + builtin__array_ensure_cap(arr, n); | |
| 3944 | +} | |
| 3945 | +void strings__Builder_grow_len(strings__Builder* b, int n) { | |
| 3946 | + if (n <= 0) { | |
| 3947 | + return; | |
| 3948 | + } | |
| 3949 | + int new_len = b->len + n; | |
| 3950 | + strings__Builder_ensure_cap(b, new_len); | |
| 3951 | + { // Unsafe block | |
| 3952 | + b->len = new_len; | |
| 3953 | + } | |
| 3954 | +} | |
| 3955 | +void strings__Builder_free(strings__Builder* b) { | |
| 3956 | + if (b->data != 0) { | |
| 3957 | + Array_u8* arr = ((Array_u8*)(b)); | |
| 3958 | + builtin__array_free(arr); | |
| 3959 | + } | |
| 3960 | +} | |
| 3961 | +void strings__Builder_write_repeated_rune(strings__Builder* b, rune r, int count) { | |
| 3962 | + if (count <= 0) { | |
| 3963 | + return; | |
| 3964 | + } | |
| 3965 | + Array_fixed_u8_5 buffer = {0}; | |
| 3966 | + string res = builtin__utf32_to_str_no_malloc(((u32)(r)), &buffer[0]); | |
| 3967 | + if (res.len == 0) { | |
| 3968 | + return; | |
| 3969 | + } | |
| 3970 | + if (res.len == 1) { | |
| 3971 | + strings__Builder_ensure_cap(b, b->len + count); | |
| 3972 | + { // Unsafe block | |
| 3973 | + builtin__vmemset(((u8*)(b->data)) + b->len, buffer[0], count); | |
| 3974 | + b->len += count; | |
| 3975 | + } | |
| 3976 | + return; | |
| 3977 | + } else { | |
| 3978 | + int total_needed = count * res.len; | |
| 3979 | + strings__Builder_ensure_cap(b, b->len + total_needed); | |
| 3980 | + u8* dest = ((u8*)(b->data)) + b->len; | |
| 3981 | + for (int _t1 = 0; _t1 < count; ++_t1) { | |
| 3982 | + { // Unsafe block | |
| 3983 | + builtin__vmemcpy(dest, res.str, res.len); | |
| 3984 | + dest += res.len; | |
| 3985 | + } | |
| 3986 | + } | |
| 3987 | + { // Unsafe block | |
| 3988 | + b->len += total_needed; | |
| 3989 | + } | |
| 3990 | + } | |
| 3991 | +} | |
| 3992 | +void strings__Builder_indent(strings__Builder* b, string s, strings__IndentParam param) { | |
| 3993 | + if (s.len == 0) { | |
| 3994 | + return; | |
| 3995 | + } | |
| 3996 | + strings__IndentState state = strings__IndentState__normal; | |
| 3997 | + int indent_level = param.starting_level; | |
| 3998 | + rune string_char = '\0'; | |
| 3999 | + bool at_line_start = true; | |
| 4000 | + for (int i = 0; i < s.len; i++) { | |
| 4001 | + rune c = ((rune)(s.str[ i])); | |
| 4002 | + | |
| 4003 | + if (state == (strings__IndentState__normal)) { | |
| 4004 | + | |
| 4005 | + if (c == ('"') || c == ('\'')) { | |
| 4006 | + state = strings__IndentState__in_string; | |
| 4007 | + string_char = c; | |
| 4008 | + if (at_line_start) { | |
| 4009 | + strings__Builder_write_repeated_rune(b, param.indent_char, indent_level * param.indent_count); | |
| 4010 | + at_line_start = false; | |
| 4011 | + } | |
| 4012 | + strings__Builder_write_rune(b, c); | |
| 4013 | + } | |
| 4014 | + else if (c == (param.block_start)) { | |
| 4015 | + if (at_line_start) { | |
| 4016 | + strings__Builder_write_repeated_rune(b, param.indent_char, indent_level * param.indent_count); | |
| 4017 | + at_line_start = false; | |
| 4018 | + } | |
| 4019 | + strings__Builder_write_rune(b, c); | |
| 4020 | + if (i + 1 < s.len && s.str[ i + 1] == param.block_end) { | |
| 4021 | + strings__Builder_write_rune(b, param.block_end); | |
| 4022 | + i++; | |
| 4023 | + } else { | |
| 4024 | + indent_level++; | |
| 4025 | + strings__Builder_write_rune(b, '\n'); | |
| 4026 | + at_line_start = true; | |
| 4027 | + } | |
| 4028 | + } | |
| 4029 | + else if (c == (param.block_end)) { | |
| 4030 | + if (indent_level > 0) { | |
| 4031 | + indent_level--; | |
| 4032 | + } | |
| 4033 | + if (!at_line_start) { | |
| 4034 | + strings__Builder_write_rune(b, '\n'); | |
| 4035 | + } | |
| 4036 | + strings__Builder_write_repeated_rune(b, param.indent_char, indent_level * param.indent_count); | |
| 4037 | + at_line_start = false; | |
| 4038 | + strings__Builder_write_rune(b, c); | |
| 4039 | + } | |
| 4040 | + else if (c == (' ') || c == ('\t') || c == ('\r') || c == ('\n')) { | |
| 4041 | + if (!at_line_start) { | |
| 4042 | + strings__Builder_write_rune(b, c); | |
| 4043 | + } | |
| 4044 | + if (c == '\n') { | |
| 4045 | + at_line_start = true; | |
| 4046 | + } | |
| 4047 | + } | |
| 4048 | + else { | |
| 4049 | + if (at_line_start) { | |
| 4050 | + strings__Builder_write_repeated_rune(b, param.indent_char, indent_level * param.indent_count); | |
| 4051 | + at_line_start = false; | |
| 4052 | + } | |
| 4053 | + strings__Builder_write_rune(b, c); | |
| 4054 | + } | |
| 4055 | + } | |
| 4056 | + else if (state == (strings__IndentState__in_string)) { | |
| 4057 | + strings__Builder_write_rune(b, c); | |
| 4058 | + if (c == string_char) { | |
| 4059 | + if (s.str[ i - 1] != '\\') { | |
| 4060 | + state = strings__IndentState__normal; | |
| 4061 | + string_char = '\0'; | |
| 4062 | + } | |
| 4063 | + } | |
| 4064 | + } | |
| 4065 | + } | |
| 4066 | +} | |
| 4067 | +inline VV_LOC int strings__min(int a, int b, int c) { | |
| 4068 | + int m = a; | |
| 4069 | + if (b < m) { | |
| 4070 | + m = b; | |
| 4071 | + } | |
| 4072 | + if (c < m) { | |
| 4073 | + m = c; | |
| 4074 | + } | |
| 4075 | + return m; | |
| 4076 | +} | |
| 4077 | +inline VV_LOC int strings__max2(int a, int b) { | |
| 4078 | + if (a < b) { | |
| 4079 | + return b; | |
| 4080 | + } | |
| 4081 | + return a; | |
| 4082 | +} | |
| 4083 | +inline VV_LOC int strings__min2(int a, int b) { | |
| 4084 | + if (a < b) { | |
| 4085 | + return a; | |
| 4086 | + } | |
| 4087 | + return b; | |
| 4088 | +} | |
| 4089 | +inline VV_LOC int strings__abs2(int a, int b) { | |
| 4090 | + if (a < b) { | |
| 4091 | + return b - a; | |
| 4092 | + } | |
| 4093 | + return a - b; | |
| 4094 | +} | |
| 4095 | +int strings__levenshtein_distance(string a, string b) { | |
| 4096 | + if (a.len == 0) { | |
| 4097 | + return b.len; | |
| 4098 | + } | |
| 4099 | + if (b.len == 0) { | |
| 4100 | + return a.len; | |
| 4101 | + } | |
| 4102 | + if (builtin__string__eq(a, b)) { | |
| 4103 | + return 0; | |
| 4104 | + } | |
| 4105 | + Array_int row = builtin____new_array_with_default(a.len + 1, 0, sizeof(int), 0); | |
| 4106 | + { | |
| 4107 | + int* pelem = (int*)row.data; | |
| 4108 | + for (int index=0; index<row.len; index++, pelem++) { | |
| 4109 | + int it = index; | |
| 4110 | + *pelem = index; | |
| 4111 | + } | |
| 4112 | + } | |
| 4113 | + ; | |
| 4114 | + for (int i = 1; i < b.len + 1; i++) { | |
| 4115 | + int prev = i; | |
| 4116 | + for (int j = 1; j < a.len + 1; j++) { | |
| 4117 | + int current = ((int*)row.data)[j - 1]; | |
| 4118 | + if (b.str[ i - 1] != a.str[ j - 1]) { | |
| 4119 | + current = strings__min(((int*)row.data)[j - 1] + 1, prev + 1, ((int*)row.data)[j] + 1); | |
| 4120 | + } | |
| 4121 | + ((int*)row.data)[j - 1] = prev; | |
| 4122 | + prev = current; | |
| 4123 | + } | |
| 4124 | + ((int*)row.data)[a.len] = prev; | |
| 4125 | + } | |
| 4126 | + return ((int*)row.data)[a.len]; | |
| 4127 | +} | |
| 4128 | +f32 strings__levenshtein_distance_percentage(string a, string b) { | |
| 4129 | + int d = strings__levenshtein_distance(a, b); | |
| 4130 | + int l = (a.len >= b.len ? (a.len) : (b.len)); | |
| 4131 | + return (((f32)(1.00)) - ((f32)(d)) / ((f32)(l))) * ((f32)(100.00)); | |
| 4132 | +} | |
| 4133 | +f32 strings__dice_coefficient(string s1, string s2) { | |
| 4134 | + if (s1.len == 0 || s2.len == 0) { | |
| 4135 | + return 0.0; | |
| 4136 | + } | |
| 4137 | + if (builtin__string__eq(s1, s2)) { | |
| 4138 | + return 1.0; | |
| 4139 | + } | |
| 4140 | + if (s1.len < 2 || s2.len < 2) { | |
| 4141 | + return 0.0; | |
| 4142 | + } | |
| 4143 | + string a = (s1.len > s2.len ? (s1) : (s2)); | |
| 4144 | + string b = (builtin__string__eq(a, s1) ? (s2) : (s1)); | |
| 4145 | + Map_string_int first_bigrams = builtin__new_map(sizeof(string), sizeof(int), &builtin__map_hash_string, &builtin__map_eq_string, &builtin__map_clone_string, &builtin__map_free_string) | |
| 4146 | + ; | |
| 4147 | + for (int i = 0; i < a.len - 1; ++i) { | |
| 4148 | + string bigram = builtin__string_substr(a, i, i + 2); | |
| 4149 | + int q = (_IN_MAP(ADDR(string, bigram), ADDR(map, first_bigrams)) ? ((*(int*)builtin__map_get(ADDR(map, first_bigrams), &(string[]){bigram}, &(int[]){ 0 })) + 1) : (1)); | |
| 4150 | + builtin__map_set(&first_bigrams, &(string[]){bigram}, &(int[]) { q }); | |
| 4151 | + } | |
| 4152 | + int intersection_size = 0; | |
| 4153 | + for (int i = 0; i < b.len - 1; ++i) { | |
| 4154 | + string bigram = builtin__string_substr(b, i, i + 2); | |
| 4155 | + int count = (_IN_MAP(ADDR(string, bigram), ADDR(map, first_bigrams)) ? ((*(int*)builtin__map_get(ADDR(map, first_bigrams), &(string[]){bigram}, &(int[]){ 0 }))) : (0)); | |
| 4156 | + if (count > 0) { | |
| 4157 | + builtin__map_set(&first_bigrams, &(string[]){bigram}, &(int[]) { count - 1 }); | |
| 4158 | + intersection_size++; | |
| 4159 | + } | |
| 4160 | + } | |
| 4161 | + return (((f32)(2.0)) * ((f32)(intersection_size))) / (((f32)(a.len)) + ((f32)(b.len)) - 2); | |
| 4162 | +} | |
| 4163 | +int strings__hamming_distance(string a, string b) { | |
| 4164 | + if (a.len == 0 && b.len == 0) { | |
| 4165 | + return 0; | |
| 4166 | + } | |
| 4167 | + int match_len = strings__min2(a.len, b.len); | |
| 4168 | + int diff_count = strings__abs2(a.len, b.len); | |
| 4169 | + for (int i = 0; i < match_len; ++i) { | |
| 4170 | + if (a.str[ i] != b.str[ i]) { | |
| 4171 | + diff_count++; | |
| 4172 | + } | |
| 4173 | + } | |
| 4174 | + return diff_count; | |
| 4175 | +} | |
| 4176 | +f32 strings__hamming_similarity(string a, string b) { | |
| 4177 | + int l = strings__max2(a.len, b.len); | |
| 4178 | + if (l == 0) { | |
| 4179 | + return 1.0; | |
| 4180 | + } | |
| 4181 | + int d = strings__hamming_distance(a, b); | |
| 4182 | + return ((f32)(1.00)) - ((f32)(d)) / ((f32)(l)); | |
| 4183 | +} | |
| 4184 | +f64 strings__jaro_similarity(string a, string b) { | |
| 4185 | + int a_len = a.len; | |
| 4186 | + int b_len = b.len; | |
| 4187 | + if (a_len == 0 && b_len == 0) { | |
| 4188 | + return 1.0; | |
| 4189 | + } | |
| 4190 | + if (a_len == 0 || b_len == 0) { | |
| 4191 | + return 0; | |
| 4192 | + } | |
| 4193 | + int match_distance = strings__max2(VSAFE_DIV_int(strings__max2(a_len, b_len) , 2) - 1, 0); | |
| 4194 | + Array_bool a_matches = builtin____new_array_with_default(a_len, 0, sizeof(bool), 0); | |
| 4195 | + Array_bool b_matches = builtin____new_array_with_default(b_len, 0, sizeof(bool), 0); | |
| 4196 | + int matches = 0; | |
| 4197 | + f64 transpositions = 0.0; | |
| 4198 | + for (int i = 0; i < a_len; ++i) { | |
| 4199 | + int start = strings__max2(0, (int)(i - match_distance)); | |
| 4200 | + int end = strings__min2(b_len, (int)(i + match_distance) + 1); | |
| 4201 | + for (int k = start; k < end; ++k) { | |
| 4202 | + if (((bool*)b_matches.data)[k]) { | |
| 4203 | + continue; | |
| 4204 | + } | |
| 4205 | + if (a.str[ i] != b.str[ k]) { | |
| 4206 | + continue; | |
| 4207 | + } | |
| 4208 | + ((bool*)a_matches.data)[i] = true; | |
| 4209 | + ((bool*)b_matches.data)[k] = true; | |
| 4210 | + matches++; | |
| 4211 | + break; | |
| 4212 | + } | |
| 4213 | + } | |
| 4214 | + if (matches == 0) { | |
| 4215 | + return 0; | |
| 4216 | + } | |
| 4217 | + int k = 0; | |
| 4218 | + for (int i = 0; i < a_len; ++i) { | |
| 4219 | + if (!((bool*)a_matches.data)[i]) { | |
| 4220 | + continue; | |
| 4221 | + } | |
| 4222 | + for (;;) { | |
| 4223 | + if (!(!((bool*)b_matches.data)[k])) break; | |
| 4224 | + k++; | |
| 4225 | + } | |
| 4226 | + if (a.str[ i] != b.str[ k]) { | |
| 4227 | + transpositions++; | |
| 4228 | + } | |
| 4229 | + k++; | |
| 4230 | + } | |
| 4231 | + transpositions /= 2; | |
| 4232 | + return ((f64)(matches / ((f64)(a_len))) + (f64)(matches / ((f64)(b_len))) + (f64)(((f64)(matches - transpositions)) / matches)) / 3; | |
| 4233 | +} | |
| 4234 | +f64 strings__jaro_winkler_similarity(string a, string b) { | |
| 4235 | + int lmax = strings__min2(4, strings__min2(a.len, b.len)); | |
| 4236 | + int l = 0; | |
| 4237 | + for (int i = 0; i < lmax; ++i) { | |
| 4238 | + if (a.str[ i] == b.str[ i]) { | |
| 4239 | + l++; | |
| 4240 | + } | |
| 4241 | + } | |
| 4242 | + f64 js = strings__jaro_similarity(a, b); | |
| 4243 | + f64 p = 0.1; | |
| 4244 | + f64 ws = js + ((f64)(l)) * p * (1 - js); | |
| 4245 | + return ws; | |
| 4246 | +} | |
| 4247 | +string strings__repeat(u8 c, int n) { | |
| 4248 | + if (n <= 0) { | |
| 4249 | + return _S(""); | |
| 4250 | + } | |
| 4251 | + u8* bytes = builtin__malloc_noscan(n + 1); | |
| 4252 | + { // Unsafe block | |
| 4253 | + memset(bytes, c, n); | |
| 4254 | + bytes[n] = 0; | |
| 4255 | + } | |
| 4256 | + return builtin__u8_vstring_with_len(bytes, n); | |
| 4257 | +} | |
| 4258 | +string strings__repeat_string(string s, int n) { | |
| 4259 | + if (n <= 0 || s.len == 0) { | |
| 4260 | + return _S(""); | |
| 4261 | + } | |
| 4262 | + int slen = s.len; | |
| 4263 | + int blen = slen * n; | |
| 4264 | + u8* bytes = builtin__malloc_noscan(blen + 1); | |
| 4265 | + for (int bi = 0; bi < n; ++bi) { | |
| 4266 | + int bislen = (int)(bi * slen); | |
| 4267 | + for (int si = 0; si < slen; ++si) { | |
| 4268 | + { // Unsafe block | |
| 4269 | + bytes[(int)(bislen + si)] = s.str[ si]; | |
| 4270 | + } | |
| 4271 | + } | |
| 4272 | + } | |
| 4273 | + { // Unsafe block | |
| 4274 | + bytes[blen] = 0; | |
| 4275 | + } | |
| 4276 | + return builtin__u8_vstring_with_len(bytes, blen); | |
| 4277 | +} | |
| 4278 | +string strings__find_between_pair_u8(string input, u8 start, u8 end) { | |
| 4279 | + int marks = 0; | |
| 4280 | + int start_index = -1; | |
| 4281 | + for (int i = 0; i < input.len; ++i) { | |
| 4282 | + u8 b = input.str[i]; | |
| 4283 | + if (b == start) { | |
| 4284 | + if (start_index == -1) { | |
| 4285 | + start_index = i + 1; | |
| 4286 | + } | |
| 4287 | + marks++; | |
| 4288 | + continue; | |
| 4289 | + } | |
| 4290 | + if (start_index > 0) { | |
| 4291 | + if (b == end) { | |
| 4292 | + marks--; | |
| 4293 | + if (marks == 0) { | |
| 4294 | + return builtin__string_substr(input, start_index, i); | |
| 4295 | + } | |
| 4296 | + } | |
| 4297 | + } | |
| 4298 | + } | |
| 4299 | + return _S(""); | |
| 4300 | +} | |
| 4301 | +string strings__find_between_pair_rune(string input, rune start, rune end) { | |
| 4302 | + int marks = 0; | |
| 4303 | + int start_index = -1; | |
| 4304 | + Array_rune runes = builtin__string_runes(input); | |
| 4305 | + for (int i = 0; i < runes.len; ++i) { | |
| 4306 | + rune r = ((rune*)runes.data)[i]; | |
| 4307 | + if (r == start) { | |
| 4308 | + if (start_index == -1) { | |
| 4309 | + start_index = i + 1; | |
| 4310 | + } | |
| 4311 | + marks++; | |
| 4312 | + continue; | |
| 4313 | + } | |
| 4314 | + if (start_index > 0) { | |
| 4315 | + if (r == end) { | |
| 4316 | + marks--; | |
| 4317 | + if (marks == 0) { | |
| 4318 | + return Array_rune_string(builtin__array_slice(runes, start_index, i)); | |
| 4319 | + } | |
| 4320 | + } | |
| 4321 | + } | |
| 4322 | + } | |
| 4323 | + return _S(""); | |
| 4324 | +} | |
| 4325 | +string strings__find_between_pair_string(string input, string start, string end) { | |
| 4326 | + int start_index = -1; | |
| 4327 | + int marks = 0; | |
| 4328 | + Array_rune start_runes = builtin__string_runes(start); | |
| 4329 | + Array_rune end_runes = builtin__string_runes(end); | |
| 4330 | + Array_rune runes = builtin__string_runes(input); | |
| 4331 | + int i = 0; | |
| 4332 | + for (; i < runes.len; i++) { | |
| 4333 | + Array_rune start_slice = builtin__array_slice_ni(runes, i, i + start_runes.len); | |
| 4334 | + if (Array_rune_arr_eq(start_slice, start_runes)) { | |
| 4335 | + i = i + start_runes.len - 1; | |
| 4336 | + if (start_index < 0) { | |
| 4337 | + start_index = i + 1; | |
| 4338 | + } | |
| 4339 | + marks++; | |
| 4340 | + continue; | |
| 4341 | + } | |
| 4342 | + if (start_index > 0) { | |
| 4343 | + Array_rune end_slice = builtin__array_slice_ni(runes, i, i + end_runes.len); | |
| 4344 | + if (Array_rune_arr_eq(end_slice, end_runes)) { | |
| 4345 | + marks--; | |
| 4346 | + if (marks == 0) { | |
| 4347 | + return Array_rune_string(builtin__array_slice(runes, start_index, i)); | |
| 4348 | + } | |
| 4349 | + i = i + end_runes.len - 1; | |
| 4350 | + continue; | |
| 4351 | + } | |
| 4352 | + } | |
| 4353 | + } | |
| 4354 | + return _S(""); | |
| 4355 | +} | |
| 4356 | +Array_string strings__split_capital(string s) { | |
| 4357 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | |
| 4358 | + int word_start = 0; | |
| 4359 | + for (int idx = 0; idx < s.len; ++idx) { | |
| 4360 | + u8 c = s.str[idx]; | |
| 4361 | + if (builtin__u8_is_capital(c)) { | |
| 4362 | + if (word_start != idx) { | |
| 4363 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr_ni(s, word_start, idx) })); | |
| 4364 | + } | |
| 4365 | + word_start = idx; | |
| 4366 | + continue; | |
| 4367 | + } | |
| 4368 | + } | |
| 4369 | + if (word_start != s.len) { | |
| 4370 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr_ni(s, word_start, 2147483647) })); | |
| 4371 | + } | |
| 4372 | + return res; | |
| 4373 | +} | |
| 4374 | +inline VV_LOC bool builtin__closure__is_ppc64(void) { | |
| 4375 | + #if 0 | |
| 4376 | + { | |
| 4377 | + } | |
| 4378 | + #else | |
| 4379 | + { | |
| 4380 | + return false; | |
| 4381 | + } | |
| 4382 | + #endif | |
| 4383 | + return 0; | |
| 4384 | +} | |
| 4385 | +inline VV_LOC voidptr* builtin__closure__closure_slot_meta(voidptr exec_ptr) { | |
| 4386 | + return ((voidptr*)(((u8*)(exec_ptr)) - _const_builtin__closure__assumed_page_size)); | |
| 4387 | +} | |
| 4388 | +VV_LOC void builtin__closure__closure_register_page(voidptr exec_page_start) { | |
| 4389 | + { // Unsafe block | |
| 4390 | + builtin__closure__ClosurePage* node = ((builtin__closure__ClosurePage*)(builtin___v_malloc(sizeof(builtin__closure__ClosurePage)))); | |
| 4391 | + *node = ((builtin__closure__ClosurePage){.next = g_closure.pages,.exec_page_start = exec_page_start,}); | |
| 4392 | + g_closure.pages = node; | |
| 4393 | + } | |
| 4394 | +} | |
| 4395 | +VV_LOC bool builtin__closure__closure_is_managed(voidptr exec_ptr) { | |
| 4396 | + if (builtin__isnil(exec_ptr)) { | |
| 4397 | + return false; | |
| 4398 | + } | |
| 4399 | + usize exec_addr = ((usize)(exec_ptr)); | |
| 4400 | + builtin__closure__ClosurePage* page = g_closure.pages; | |
| 4401 | + for (;;) { | |
| 4402 | + if (!(page != ((void*)0))) break; | |
| 4403 | + usize page_addr = ((usize)(page->exec_page_start)); | |
| 4404 | + if (exec_addr >= page_addr && exec_addr < page_addr + ((usize)(g_closure.v_page_size))) { | |
| 4405 | + usize slot_offset = exec_addr - page_addr; | |
| 4406 | + return slot_offset >= ((usize)(_const_builtin__closure__closure_size)) && VSAFE_MOD_usize(slot_offset , ((usize)(_const_builtin__closure__closure_size))) == 0; | |
| 4407 | + } | |
| 4408 | + page = page->next; | |
| 4409 | + } | |
| 4410 | + return false; | |
| 4411 | +} | |
| 4412 | +VV_LOC builtin__closure__ClosureLiveInfo builtin__closure__closure_live_delete(voidptr exec_ptr) { | |
| 4413 | + builtin__closure__ClosureLiveInfo* _t2 = (builtin__closure__ClosureLiveInfo*)(builtin__map_get_check(ADDR(map, g_closure.live), &(voidptr[]){exec_ptr})); | |
| 4414 | + _option_builtin__closure__ClosureLiveInfo _t1 = {0}; | |
| 4415 | + if (_t2) { | |
| 4416 | + *((builtin__closure__ClosureLiveInfo*)&_t1.data) = *((builtin__closure__ClosureLiveInfo*)_t2); | |
| 4417 | + } else { | |
| 4418 | + _t1.state = 2; _t1.err = builtin___v_error(_S("map key does not exist")); | |
| 4419 | + } | |
| 4420 | + | |
| 4421 | + if (_t1.state == 0) { | |
| 4422 | + builtin__closure__ClosureLiveInfo info = (*(builtin__closure__ClosureLiveInfo*)_t1.data); | |
| 4423 | + (*(builtin__closure__ClosureLiveInfo*)builtin__map_get_and_set((map*)&g_closure.live, &(voidptr[]){exec_ptr}, &(builtin__closure__ClosureLiveInfo[]){ (builtin__closure__ClosureLiveInfo){.ctx = 0,.owns_data = 0,.generation = 0,} })) = ((builtin__closure__ClosureLiveInfo){.ctx = 0,.owns_data = 0,.generation = 0,}); | |
| 4424 | + builtin__map_delete(&g_closure.live, &(voidptr[]){exec_ptr}); | |
| 4425 | + return info; | |
| 4426 | + } | |
| 4427 | + if (_t1.state == 2 && _t1.err._object != _const_none__._object) { builtin___v_free(_t1.err._object); } | |
| 4428 | + return ((builtin__closure__ClosureLiveInfo){.ctx = 0,.owns_data = 0,.generation = 0,}); | |
| 4429 | +} | |
| 4430 | +VV_LOC builtin__closure__ClosureLifetimeState* builtin__closure__new_closure_lifetime_state_no_lock(void) { | |
| 4431 | + builtin__closure__ClosureLifetimeState* state = g_closure.free_lifetime_states; | |
| 4432 | + if (!builtin__isnil(state)) { | |
| 4433 | + g_closure.free_lifetime_states = state->next_free; | |
| 4434 | + } else { | |
| 4435 | + { // Unsafe block | |
| 4436 | + state = ((builtin__closure__ClosureLifetimeState*)(builtin___v_malloc(sizeof(builtin__closure__ClosureLifetimeState)))); | |
| 4437 | + } | |
| 4438 | + g_closure.lifetime_state_allocs++; | |
| 4439 | + } | |
| 4440 | + g_closure.next_lifetime_generation++; | |
| 4441 | + { // Unsafe block | |
| 4442 | + *state = ((builtin__closure__ClosureLifetimeState){.owner_thread = builtin__closure__closure_current_thread_id_platform(),.active = 0,.disposed = 0,.suspended = 0,.frame_start = 0,.frame_gen = 0,.generation = g_closure.next_lifetime_generation,.frame_generation = 0,.records = builtin____new_array(0, 0, sizeof(builtin__closure__ClosureLifetimeRecord)),.frames = builtin____new_array(0, 0, sizeof(builtin__closure__ClosureLifetimeFrame)),.next_free = ((void*)0),}); | |
| 4443 | + } | |
| 4444 | + return state; | |
| 4445 | +} | |
| 4446 | +VV_LOC builtin__closure__ClosureLifetimeState* builtin__closure__new_closure_lifetime_state(void) { | |
| 4447 | + builtin__closure__closure_mtx_lock_platform(); | |
| 4448 | + builtin__closure__ClosureLifetimeState* state = builtin__closure__new_closure_lifetime_state_no_lock(); | |
| 4449 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4450 | + return state; | |
| 4451 | +} | |
| 4452 | +VV_LOC void builtin__closure__closure_lifetime_recycle_state_no_lock(builtin__closure__ClosureLifetimeState** state) { | |
| 4453 | + (*state)->disposed = true; | |
| 4454 | + (*state)->active = false; | |
| 4455 | + (*state)->suspended = 0; | |
| 4456 | + (*state)->frame_start = 0; | |
| 4457 | + (*state)->frame_gen = 0; | |
| 4458 | + (*state)->frame_generation = 0; | |
| 4459 | + { // Unsafe block | |
| 4460 | + builtin__array_free(&(*state)->records); | |
| 4461 | + builtin__array_free(&(*state)->frames); | |
| 4462 | + } | |
| 4463 | + (*state)->records = builtin____new_array_with_default(0, 0, sizeof(builtin__closure__ClosureLifetimeRecord), 0); | |
| 4464 | + (*state)->frames = builtin____new_array_with_default(0, 0, sizeof(builtin__closure__ClosureLifetimeFrame), 0); | |
| 4465 | + (*state)->next_free = g_closure.free_lifetime_states; | |
| 4466 | + g_closure.free_lifetime_states = *state; | |
| 4467 | +} | |
| 4468 | +VV_LOC string builtin__closure__closure_lifetime_error(builtin__closure__ClosureLifetimeState* state, u64 generation, u64 thread_id) { | |
| 4469 | + if (state->disposed || state->generation != generation) { | |
| 4470 | + return _S("closure lifetime used after dispose"); | |
| 4471 | + } | |
| 4472 | + if (state->owner_thread != thread_id) { | |
| 4473 | + return _S("closure lifetime used from a different thread"); | |
| 4474 | + } | |
| 4475 | + return _S(""); | |
| 4476 | +} | |
| 4477 | +VV_LOC _result_builtin__closure__ClosureLifetimeState_ptr builtin__closure__Lifetime_ensure_state(builtin__closure__Lifetime* lifetime) { | |
| 4478 | + builtin__closure__closure_ensure_initialized(); | |
| 4479 | + if (builtin__isnil(lifetime->state)) { | |
| 4480 | + if (lifetime->disposed) { | |
| 4481 | + return (_result_builtin__closure__ClosureLifetimeState_ptr){ .is_error=true, .err=builtin___v_error(_S("closure lifetime used after dispose")), .data={E_STRUCT} }; | |
| 4482 | + } | |
| 4483 | + lifetime->state = builtin__closure__new_closure_lifetime_state(); | |
| 4484 | + lifetime->generation = lifetime->state->generation; | |
| 4485 | + _result_builtin__closure__ClosureLifetimeState_ptr _t2; | |
| 4486 | + builtin___result_ok(&(builtin__closure__ClosureLifetimeState*[]) { lifetime->state }, (_result*)(&_t2), sizeof(builtin__closure__ClosureLifetimeState*)); | |
| 4487 | + | |
| 4488 | + return _t2; | |
| 4489 | + } | |
| 4490 | + builtin__closure__closure_mtx_lock_platform(); | |
| 4491 | + builtin__closure__ClosureLifetimeState* state = lifetime->state; | |
| 4492 | + if (lifetime->disposed || state->disposed || state->generation != lifetime->generation) { | |
| 4493 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4494 | + return (_result_builtin__closure__ClosureLifetimeState_ptr){ .is_error=true, .err=builtin___v_error(_S("closure lifetime used after dispose")), .data={E_STRUCT} }; | |
| 4495 | + } | |
| 4496 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4497 | + _result_builtin__closure__ClosureLifetimeState_ptr _t4; | |
| 4498 | + builtin___result_ok(&(builtin__closure__ClosureLifetimeState*[]) { state }, (_result*)(&_t4), sizeof(builtin__closure__ClosureLifetimeState*)); | |
| 4499 | + | |
| 4500 | + return _t4; | |
| 4501 | +} | |
| 4502 | +VV_LOC voidptr builtin__closure__closure_slot_data(voidptr exec_ptr) { | |
| 4503 | + { // Unsafe block | |
| 4504 | + voidptr* p = builtin__closure__closure_slot_meta(exec_ptr); | |
| 4505 | + if (builtin__closure__is_ppc64()) { | |
| 4506 | + return p[2]; | |
| 4507 | + } | |
| 4508 | + return p[0]; | |
| 4509 | + } | |
| 4510 | + return 0; | |
| 4511 | +} | |
| 4512 | +VV_LOC bool builtin__closure__closure_release_no_lock(voidptr exec_ptr, u64 generation) { | |
| 4513 | + if (!builtin__closure__closure_is_managed(exec_ptr)) { | |
| 4514 | + return false; | |
| 4515 | + } | |
| 4516 | + builtin__closure__ClosureLiveInfo* _t3 = (builtin__closure__ClosureLiveInfo*)(builtin__map_get_check(ADDR(map, g_closure.live), &(voidptr[]){exec_ptr})); | |
| 4517 | + _option_builtin__closure__ClosureLiveInfo _t2 = {0}; | |
| 4518 | + if (_t3) { | |
| 4519 | + *((builtin__closure__ClosureLiveInfo*)&_t2.data) = *((builtin__closure__ClosureLiveInfo*)_t3); | |
| 4520 | + } else { | |
| 4521 | + _t2.state = 2; _t2.err = builtin___v_error(_S("map key does not exist")); | |
| 4522 | + } | |
| 4523 | + ; | |
| 4524 | + if (_t2.state != 0) { | |
| 4525 | + return false; | |
| 4526 | + } | |
| 4527 | + | |
| 4528 | + builtin__closure__ClosureLiveInfo info = (*(builtin__closure__ClosureLiveInfo*)_t2.data); | |
| 4529 | + if (generation != 0 && info.generation != generation) { | |
| 4530 | + return false; | |
| 4531 | + } | |
| 4532 | + voidptr data = builtin__closure__closure_slot_data(exec_ptr); | |
| 4533 | + builtin__closure__closure_live_delete(exec_ptr); | |
| 4534 | + if (info.owns_data && !builtin__isnil(data)) { | |
| 4535 | + builtin___v_free(data); | |
| 4536 | + } | |
| 4537 | + { // Unsafe block | |
| 4538 | + voidptr* p = builtin__closure__closure_slot_meta(exec_ptr); | |
| 4539 | + p[0] = g_closure.free_closure_ptr; | |
| 4540 | + if (builtin__closure__is_ppc64()) { | |
| 4541 | + p[1] = ((void*)0); | |
| 4542 | + p[2] = ((void*)0); | |
| 4543 | + p[3] = ((void*)0); | |
| 4544 | + } else { | |
| 4545 | + p[1] = ((void*)0); | |
| 4546 | + } | |
| 4547 | + g_closure.free_closure_ptr = exec_ptr; | |
| 4548 | + } | |
| 4549 | + return true; | |
| 4550 | +} | |
| 4551 | +VV_LOC void builtin__closure__closure_lifetime_release_records_no_lock(Array_builtin__closure__ClosureLifetimeRecord records, int start, int end) { | |
| 4552 | + for (int i = start; i < end; ++i) { | |
| 4553 | + builtin__closure__ClosureLifetimeRecord record = (*(builtin__closure__ClosureLifetimeRecord*)builtin__array_get(records, i)); | |
| 4554 | + builtin__closure__closure_release_no_lock(record.exec_ptr, record.generation); | |
| 4555 | + } | |
| 4556 | +} | |
| 4557 | +VV_LOC void builtin__closure__closure_lifetime_reclaim_no_lock(builtin__closure__ClosureLifetimeState* state, int retain) { | |
| 4558 | + int keep = (retain < 0 ? (0) : (retain)); | |
| 4559 | + if (state->frames.len <= keep) { | |
| 4560 | + return; | |
| 4561 | + } | |
| 4562 | + int reclaim_count = state->frames.len - keep; | |
| 4563 | + int cutoff = 0; | |
| 4564 | + for (int i = 0; i < reclaim_count; ++i) { | |
| 4565 | + builtin__closure__ClosureLifetimeFrame frame = (*(builtin__closure__ClosureLifetimeFrame*)builtin__array_get(state->frames, i)); | |
| 4566 | + builtin__closure__closure_lifetime_release_records_no_lock(state->records, frame.start, frame.end); | |
| 4567 | + cutoff = frame.end; | |
| 4568 | + } | |
| 4569 | + builtin__array_delete_many(&state->frames, 0, reclaim_count); | |
| 4570 | + if (cutoff > 0) { | |
| 4571 | + builtin__array_delete_many(&state->records, 0, cutoff); | |
| 4572 | + for (int _t1 = 0; _t1 < state->frames.len; ++_t1) { | |
| 4573 | + builtin__closure__ClosureLifetimeFrame* frame = ((builtin__closure__ClosureLifetimeFrame*)state->frames.data) + _t1; | |
| 4574 | + frame->start -= cutoff; | |
| 4575 | + frame->end -= cutoff; | |
| 4576 | + } | |
| 4577 | + } | |
| 4578 | +} | |
| 4579 | +VV_LOC void builtin__closure__closure_ensure_initialized(void) { | |
| 4580 | + builtin__closure__closure_init_once_platform(); | |
| 4581 | +} | |
| 4582 | +builtin__closure__Lifetime builtin__closure__new_lifetime(void) { | |
| 4583 | + builtin__closure__closure_ensure_initialized(); | |
| 4584 | + builtin__closure__ClosureLifetimeState* state = builtin__closure__new_closure_lifetime_state(); | |
| 4585 | + return ((builtin__closure__Lifetime){.state = state,.generation = state->generation,.disposed = 0,}); | |
| 4586 | +} | |
| 4587 | +VV_LOC _result_builtin__closure__FrameToken builtin__closure__Lifetime_begin_frame(builtin__closure__Lifetime* lifetime) { | |
| 4588 | + _result_builtin__closure__ClosureLifetimeState_ptr _t1 = builtin__closure__Lifetime_ensure_state(lifetime); | |
| 4589 | + if (_t1.is_error) { | |
| 4590 | + _result_builtin__closure__FrameToken _t2 = {0}; | |
| 4591 | + _t2.is_error = true; | |
| 4592 | + _t2.err = _t1.err; | |
| 4593 | + return _t2; | |
| 4594 | + } | |
| 4595 | + | |
| 4596 | + builtin__closure__ClosureLifetimeState* state = (*(builtin__closure__ClosureLifetimeState**)_t1.data); | |
| 4597 | + u64 thread_id = builtin__closure__closure_current_thread_id_platform(); | |
| 4598 | + builtin__closure__closure_mtx_lock_platform(); | |
| 4599 | + string err = builtin__closure__closure_lifetime_error(state, lifetime->generation, thread_id); | |
| 4600 | + if ((err).len != 0) { | |
| 4601 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4602 | + return (_result_builtin__closure__FrameToken){ .is_error=true, .err=builtin___v_error(err), .data={E_STRUCT} }; | |
| 4603 | + } | |
| 4604 | + if (state->active) { | |
| 4605 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4606 | + return (_result_builtin__closure__FrameToken){ .is_error=true, .err=builtin___v_error(_S("closure lifetime frames can not be nested")), .data={E_STRUCT} }; | |
| 4607 | + } | |
| 4608 | + if (state->suspended > 0) { | |
| 4609 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4610 | + return (_result_builtin__closure__FrameToken){ .is_error=true, .err=builtin___v_error(_S("closure lifetime frame while suspended")), .data={E_STRUCT} }; | |
| 4611 | + } | |
| 4612 | + builtin__closure__ClosureLifetimeState** _t7 = (builtin__closure__ClosureLifetimeState**)(builtin__map_get_check(ADDR(map, g_closure.active_lifetimes), &(u64[]){thread_id})); | |
| 4613 | + _option_builtin__closure__ClosureLifetimeState_ptr _t6 = {0}; | |
| 4614 | + if (_t7) { | |
| 4615 | + *((builtin__closure__ClosureLifetimeState**)&_t6.data) = *((builtin__closure__ClosureLifetimeState**)_t7); | |
| 4616 | + } else { | |
| 4617 | + _t6.state = 2; _t6.err = builtin___v_error(_S("map key does not exist")); | |
| 4618 | + } | |
| 4619 | + | |
| 4620 | + if (_t6.state == 0) { | |
| 4621 | + builtin__closure__ClosureLifetimeState* _dummy_6 = (*(builtin__closure__ClosureLifetimeState**)_t6.data); | |
| 4622 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4623 | + return (_result_builtin__closure__FrameToken){ .is_error=true, .err=builtin___v_error(_S("another closure lifetime is already active on this thread")), .data={E_STRUCT} }; | |
| 4624 | + } | |
| 4625 | + if (_t6.state == 2 && _t6.err._object != _const_none__._object) { builtin___v_free(_t6.err._object); } | |
| 4626 | + state->frame_generation++; | |
| 4627 | + state->active = true; | |
| 4628 | + state->frame_start = state->records.len; | |
| 4629 | + state->frame_gen = state->frame_generation; | |
| 4630 | + (*(builtin__closure__ClosureLifetimeState**)builtin__map_get_and_set((map*)&g_closure.active_lifetimes, &(u64[]){thread_id}, &(builtin__closure__ClosureLifetimeState*[]){ 0 })) = state; | |
| 4631 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4632 | + _result_builtin__closure__FrameToken _t9; | |
| 4633 | + builtin___result_ok(&(builtin__closure__FrameToken[]) { ((builtin__closure__FrameToken){.state = state,.thread_id = thread_id,.state_generation = lifetime->generation,.generation = state->frame_generation,}) }, (_result*)(&_t9), sizeof(builtin__closure__FrameToken)); | |
| 4634 | + | |
| 4635 | + return _t9; | |
| 4636 | +} | |
| 4637 | +VV_LOC _result_void builtin__closure__Lifetime_end_frame(builtin__closure__Lifetime* lifetime, builtin__closure__FrameToken token) { | |
| 4638 | + if (builtin__isnil(token.state)) { | |
| 4639 | + return (_result_void){ .is_error=true, .err=builtin___v_error(_S("invalid closure lifetime frame token")), .data={E_STRUCT} }; | |
| 4640 | + } | |
| 4641 | + builtin__closure__ClosureLifetimeState* state = token.state; | |
| 4642 | + u64 thread_id = builtin__closure__closure_current_thread_id_platform(); | |
| 4643 | + builtin__closure__closure_mtx_lock_platform(); | |
| 4644 | + string err = builtin__closure__closure_lifetime_error(state, token.state_generation, thread_id); | |
| 4645 | + if ((err).len != 0) { | |
| 4646 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4647 | + return (_result_void){ .is_error=true, .err=builtin___v_error(err), .data={E_STRUCT} }; | |
| 4648 | + } | |
| 4649 | + if (token.thread_id != thread_id || token.generation != state->frame_gen || !state->active) { | |
| 4650 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4651 | + return (_result_void){ .is_error=true, .err=builtin___v_error(_S("invalid closure lifetime frame token")), .data={E_STRUCT} }; | |
| 4652 | + } | |
| 4653 | + builtin__array_push((array*)&state->frames, _MOV((builtin__closure__ClosureLifetimeFrame[]){ ((builtin__closure__ClosureLifetimeFrame){.start = state->frame_start,.end = state->records.len,}) })); | |
| 4654 | + state->active = false; | |
| 4655 | + state->frame_start = 0; | |
| 4656 | + state->frame_gen = 0; | |
| 4657 | + (*(builtin__closure__ClosureLifetimeState**)builtin__map_get_and_set((map*)&g_closure.active_lifetimes, &(u64[]){thread_id}, &(builtin__closure__ClosureLifetimeState*[]){ 0 })) = ((void*)0); | |
| 4658 | + builtin__map_delete(&g_closure.active_lifetimes, &(u64[]){thread_id}); | |
| 4659 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4660 | + return (_result_void){0}; | |
| 4661 | +} | |
| 4662 | +_result_void builtin__closure__Lifetime_frame(builtin__closure__Lifetime* lifetime, void (*work)(void)) { | |
| 4663 | + _result_builtin__closure__FrameToken _t1 = builtin__closure__Lifetime_begin_frame(lifetime); | |
| 4664 | + if (_t1.is_error) { | |
| 4665 | + _result_void _t2 = {0}; | |
| 4666 | + _t2.is_error = true; | |
| 4667 | + _t2.err = _t1.err; | |
| 4668 | + return _t2; | |
| 4669 | + } | |
| 4670 | + | |
| 4671 | + builtin__closure__FrameToken token = (*(builtin__closure__FrameToken*)_t1.data); | |
| 4672 | + bool ended = false; | |
| 4673 | + work(); | |
| 4674 | + _result_void _t3 = builtin__closure__Lifetime_end_frame(lifetime, token); | |
| 4675 | + if (_t3.is_error) { | |
| 4676 | + { // defer begin | |
| 4677 | + if (!ended) { | |
| 4678 | + _result_void _t4 = builtin__closure__Lifetime_end_frame(lifetime, token); | |
| 4679 | + (void)_t4; | |
| 4680 | + ; | |
| 4681 | + } | |
| 4682 | + } // defer end | |
| 4683 | + _result_void _t5 = {0}; | |
| 4684 | + _t5.is_error = true; | |
| 4685 | + _t5.err = _t3.err; | |
| 4686 | + return _t5; | |
| 4687 | + } | |
| 4688 | + | |
| 4689 | + ; | |
| 4690 | + ended = true; | |
| 4691 | + { // defer begin | |
| 4692 | + if (!ended) { | |
| 4693 | + _result_void _t6 = builtin__closure__Lifetime_end_frame(lifetime, token); | |
| 4694 | + (void)_t6; | |
| 4695 | + ; | |
| 4696 | + } | |
| 4697 | + } // defer end | |
| 4698 | + return (_result_void){0}; | |
| 4699 | +} | |
| 4700 | +_result_void builtin__closure__Lifetime_reclaim(builtin__closure__Lifetime* lifetime, int retain) { | |
| 4701 | + _result_builtin__closure__ClosureLifetimeState_ptr _t1 = builtin__closure__Lifetime_ensure_state(lifetime); | |
| 4702 | + if (_t1.is_error) { | |
| 4703 | + _result_void _t2 = {0}; | |
| 4704 | + _t2.is_error = true; | |
| 4705 | + _t2.err = _t1.err; | |
| 4706 | + return _t2; | |
| 4707 | + } | |
| 4708 | + | |
| 4709 | + builtin__closure__ClosureLifetimeState* state = (*(builtin__closure__ClosureLifetimeState**)_t1.data); | |
| 4710 | + u64 thread_id = builtin__closure__closure_current_thread_id_platform(); | |
| 4711 | + builtin__closure__closure_mtx_lock_platform(); | |
| 4712 | + string err = builtin__closure__closure_lifetime_error(state, lifetime->generation, thread_id); | |
| 4713 | + if ((err).len != 0) { | |
| 4714 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4715 | + return (_result_void){ .is_error=true, .err=builtin___v_error(err), .data={E_STRUCT} }; | |
| 4716 | + } | |
| 4717 | + if (state->active) { | |
| 4718 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4719 | + return (_result_void){ .is_error=true, .err=builtin___v_error(_S("closure lifetime reclaim while a frame is active")), .data={E_STRUCT} }; | |
| 4720 | + } | |
| 4721 | + builtin__closure__closure_lifetime_reclaim_no_lock(state, retain); | |
| 4722 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4723 | + return (_result_void){0}; | |
| 4724 | +} | |
| 4725 | +_result_void builtin__closure__Lifetime_reclaim_all(builtin__closure__Lifetime* lifetime) { | |
| 4726 | + _result_void _t1 = builtin__closure__Lifetime_reclaim(lifetime, 0); | |
| 4727 | + if (_t1.is_error) { | |
| 4728 | + _result_void _t2 = {0}; | |
| 4729 | + _t2.is_error = true; | |
| 4730 | + _t2.err = _t1.err; | |
| 4731 | + return _t2; | |
| 4732 | + } | |
| 4733 | + | |
| 4734 | + ; | |
| 4735 | + return (_result_void){0}; | |
| 4736 | +} | |
| 4737 | +_result_void builtin__closure__Lifetime_dispose(builtin__closure__Lifetime* lifetime) { | |
| 4738 | + _result_builtin__closure__ClosureLifetimeState_ptr _t1 = builtin__closure__Lifetime_ensure_state(lifetime); | |
| 4739 | + if (_t1.is_error) { | |
| 4740 | + _result_void _t2 = {0}; | |
| 4741 | + _t2.is_error = true; | |
| 4742 | + _t2.err = _t1.err; | |
| 4743 | + return _t2; | |
| 4744 | + } | |
| 4745 | + | |
| 4746 | + builtin__closure__ClosureLifetimeState* state = (*(builtin__closure__ClosureLifetimeState**)_t1.data); | |
| 4747 | + u64 thread_id = builtin__closure__closure_current_thread_id_platform(); | |
| 4748 | + builtin__closure__closure_mtx_lock_platform(); | |
| 4749 | + string err = builtin__closure__closure_lifetime_error(state, lifetime->generation, thread_id); | |
| 4750 | + if ((err).len != 0) { | |
| 4751 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4752 | + return (_result_void){ .is_error=true, .err=builtin___v_error(err), .data={E_STRUCT} }; | |
| 4753 | + } | |
| 4754 | + if (state->active) { | |
| 4755 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4756 | + return (_result_void){ .is_error=true, .err=builtin___v_error(_S("closure lifetime dispose while a frame is active")), .data={E_STRUCT} }; | |
| 4757 | + } | |
| 4758 | + if (state->suspended > 0) { | |
| 4759 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4760 | + return (_result_void){ .is_error=true, .err=builtin___v_error(_S("closure lifetime dispose while suspended")), .data={E_STRUCT} }; | |
| 4761 | + } | |
| 4762 | + builtin__closure__closure_lifetime_reclaim_no_lock(state, 0); | |
| 4763 | + lifetime->state = ((void*)0); | |
| 4764 | + lifetime->disposed = true; | |
| 4765 | + builtin__closure__closure_lifetime_recycle_state_no_lock(&state); | |
| 4766 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4767 | + return (_result_void){0}; | |
| 4768 | +} | |
| 4769 | +_result_void builtin__closure__Lifetime_suspend(builtin__closure__Lifetime* lifetime, void (*work)(void)) { | |
| 4770 | + _result_builtin__closure__ClosureLifetimeState_ptr _t1 = builtin__closure__Lifetime_ensure_state(lifetime); | |
| 4771 | + if (_t1.is_error) { | |
| 4772 | + _result_void _t2 = {0}; | |
| 4773 | + _t2.is_error = true; | |
| 4774 | + _t2.err = _t1.err; | |
| 4775 | + return _t2; | |
| 4776 | + } | |
| 4777 | + | |
| 4778 | + builtin__closure__ClosureLifetimeState* state = (*(builtin__closure__ClosureLifetimeState**)_t1.data); | |
| 4779 | + u64 thread_id = builtin__closure__closure_current_thread_id_platform(); | |
| 4780 | + builtin__closure__closure_mtx_lock_platform(); | |
| 4781 | + string err = builtin__closure__closure_lifetime_error(state, lifetime->generation, thread_id); | |
| 4782 | + if ((err).len != 0) { | |
| 4783 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4784 | + return (_result_void){ .is_error=true, .err=builtin___v_error(err), .data={E_STRUCT} }; | |
| 4785 | + } | |
| 4786 | + builtin__closure__ClosureLifetimeState** _t5 = (builtin__closure__ClosureLifetimeState**)(builtin__map_get_check(ADDR(map, g_closure.active_lifetimes), &(u64[]){thread_id})); | |
| 4787 | + _option_builtin__closure__ClosureLifetimeState_ptr _t4 = {0}; | |
| 4788 | + if (_t5) { | |
| 4789 | + *((builtin__closure__ClosureLifetimeState**)&_t4.data) = *((builtin__closure__ClosureLifetimeState**)_t5); | |
| 4790 | + } else { | |
| 4791 | + _t4.state = 2; _t4.err = builtin___v_error(_S("map key does not exist")); | |
| 4792 | + } | |
| 4793 | + | |
| 4794 | + if (_t4.state == 0) { | |
| 4795 | + builtin__closure__ClosureLifetimeState* active = (*(builtin__closure__ClosureLifetimeState**)_t4.data); | |
| 4796 | + if (!(active == state || (active != 0 && state != 0 && builtin__closure__ClosureLifetimeState_struct_eq(*active, *state)))) { | |
| 4797 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4798 | + return (_result_void){ .is_error=true, .err=builtin___v_error(_S("another closure lifetime is already active on this thread")), .data={E_STRUCT} }; | |
| 4799 | + } | |
| 4800 | + } | |
| 4801 | + if (_t4.state == 2 && _t4.err._object != _const_none__._object) { builtin___v_free(_t4.err._object); } | |
| 4802 | + state->suspended++; | |
| 4803 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4804 | + work(); | |
| 4805 | + { // defer begin | |
| 4806 | + builtin__closure__closure_mtx_lock_platform(); | |
| 4807 | + state->suspended--; | |
| 4808 | + builtin__closure__closure_mtx_unlock_platform(); | |
| 4809 | + } // defer end | |
| 4810 | + return (_result_void){0}; | |
| 4811 | +} | |
| 4812 | +_result_void builtin__closure__Lifetime_untracked(builtin__closure__Lifetime* lifetime, void (*work)(void)) { | |
| 4813 | + _result_void _t1 = builtin__closure__Lifetime_suspend(lifetime, work); | |
| 4814 | + if (_t1.is_error) { | |
| 4815 | + _result_void _t2 = {0}; | |
| 4816 | + _t2.is_error = true; | |
| 4817 | + _t2.err = _t1.err; | |
| 4818 | + return _t2; | |
| 4819 | + } | |
| 4820 | + | |
| 4821 | + ; | |
| 4822 | + return (_result_void){0}; | |
| 4823 | +} | |
| 4824 | +VV_LOC void builtin__closure__closure_alloc(void) { | |
| 4825 | + u8* p = builtin__closure__closure_alloc_platform(); | |
| 4826 | + if (builtin__isnil(p)) { | |
| 4827 | + return; | |
| 4828 | + } | |
| 4829 | + u8* x = p + g_closure.v_page_size; | |
| 4830 | + int remaining = VSAFE_DIV_int(g_closure.v_page_size , _const_builtin__closure__closure_size); | |
| 4831 | + builtin__closure__closure_register_page(x); | |
| 4832 | + g_closure.closure_ptr = x; | |
| 4833 | + g_closure.closure_cap = remaining; | |
| 4834 | + for (;;) { | |
| 4835 | + if (!(remaining > 0)) break; | |
| 4836 | + builtin__vmemcpy(x, &_const_builtin__closure__closure_thunk[0], 15); | |
| 4837 | + remaining--; | |
| 4838 | + { // Unsafe block | |
| 4839 | + x += _const_builtin__closure__closure_size; | |
| 4840 | + } | |
| 4841 | + } | |
| 4842 | + builtin__closure__closure_memory_protect_platform(g_closure.closure_ptr, g_closure.v_page_size, builtin__closure__MemoryProtectAtrr__read_exec); | |
| 4843 | +} | |
| 4844 | +VV_LOC void builtin__closure__closure_init_body(void) { | |
| 4845 | + int page_size = builtin__closure__get_page_size_platform(); | |
| 4846 | + g_closure.v_page_size = page_size; | |
| 4847 | + g_closure.live = builtin__new_map(sizeof(voidptr), sizeof(builtin__closure__ClosureLiveInfo), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop) | |
| 4848 | + ; | |
| 4849 | + g_closure.active_lifetimes = builtin__new_map(sizeof(u64), sizeof(builtin__closure__ClosureLifetimeState*), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop) | |
| 4850 | + ; | |
| 4851 | + g_closure.next_generation = 0; | |
| 4852 | + g_closure.free_lifetime_states = ((void*)0); | |
| 4853 | + g_closure.next_lifetime_generation = 0; | |
| 4854 | + g_closure.lifetime_state_allocs = 0; | |
| 4855 | + builtin__closure__closure_mtx_lock_init_platform(); | |
| 4856 | + builtin__closure__closure_alloc(); | |
| 4857 | + { // Unsafe block | |
| 4858 | + builtin__closure__closure_memory_protect_platform(g_closure.closure_ptr, page_size, builtin__closure__MemoryProtectAtrr__read_write); | |
| 4859 | + builtin__vmemcpy(g_closure.closure_ptr, &_const_builtin__closure__closure_get_data_bytes[0], 6); | |
| 4860 | + builtin__closure__closure_memory_protect_platform(g_closure.closure_ptr, page_size, builtin__closure__MemoryProtectAtrr__read_exec); | |
| 4861 | + } | |
| 4862 | + if (builtin__closure__is_ppc64()) { | |
| 4863 | + voidptr* desc = ((voidptr*)(((u8*)(g_closure.closure_ptr)) - _const_builtin__closure__assumed_page_size)); | |
| 4864 | + { // Unsafe block | |
| 4865 | + desc[0] = g_closure.closure_ptr; | |
| 4866 | + desc[1] = ((void*)0); | |
| 4867 | + } | |
| 4868 | + g_closure.closure_get_data = ((builtin__closure__ClosureGetDataFn)(desc)); | |
| 4869 | + } else { | |
| 4870 | + g_closure.closure_get_data = g_closure.closure_ptr; | |
| 4871 | + } | |
| 4872 | + { // Unsafe block | |
| 4873 | + g_closure.closure_ptr = ((u8*)(g_closure.closure_ptr)) + _const_builtin__closure__closure_size; | |
| 4874 | + } | |
| 4875 | + g_closure.closure_cap--; | |
| 4876 | +} | |
| 4877 | +#if 1 | |
| 4878 | +#endif | |
| 4879 | +inline VV_LOC voidptr builtin__closure__closure_mtx_ptr_platform(void) { | |
| 4880 | + return ((voidptr)(&g_closure.ClosureMutex.closure_mtx[0])); | |
| 4881 | +} | |
| 4882 | +inline VV_LOC u8* builtin__closure__closure_alloc_platform(void) { | |
| 4883 | + u8* p = ((u8*)(((void*)0))); | |
| 4884 | + #if 0 | |
| 4885 | + { | |
| 4886 | + } | |
| 4887 | + #else | |
| 4888 | + { | |
| 4889 | + p = mmap(0, g_closure.v_page_size * 2, (PROT_READ | PROT_WRITE), (MAP_ANONYMOUS | MAP_PRIVATE), -1, 0); | |
| 4890 | + if (p == ((u8*)(MAP_FAILED))) { | |
| 4891 | + return ((void*)0); | |
| 4892 | + } | |
| 4893 | + } | |
| 4894 | + #endif | |
| 4895 | + return p; | |
| 4896 | +} | |
| 4897 | +inline VV_LOC void builtin__closure__closure_memory_protect_platform(voidptr ptr, isize size, builtin__closure__MemoryProtectAtrr attr) { | |
| 4898 | + #if 0 | |
| 4899 | + { | |
| 4900 | + } | |
| 4901 | + #else | |
| 4902 | + { | |
| 4903 | + | |
| 4904 | + if (attr == (builtin__closure__MemoryProtectAtrr__read_exec)) { | |
| 4905 | + mprotect(ptr, size, (PROT_READ | PROT_EXEC)); | |
| 4906 | + } | |
| 4907 | + else if (attr == (builtin__closure__MemoryProtectAtrr__read_write)) { | |
| 4908 | + mprotect(ptr, size, (PROT_READ | PROT_WRITE)); | |
| 4909 | + } | |
| 4910 | + } | |
| 4911 | + #endif | |
| 4912 | +} | |
| 4913 | +inline VV_LOC int builtin__closure__get_page_size_platform(void) { | |
| 4914 | + int page_size = 0x4000; | |
| 4915 | + #if 1 | |
| 4916 | + { | |
| 4917 | + page_size = ((int)(sysconf(_SC_PAGESIZE))); | |
| 4918 | + } | |
| 4919 | + #endif | |
| 4920 | + page_size = page_size * ((VSAFE_DIV_int((_const_builtin__closure__assumed_page_size - 1) , page_size)) + 1); | |
| 4921 | + return page_size; | |
| 4922 | +} | |
| 4923 | +inline VV_LOC void builtin__closure__closure_mtx_lock_init_platform(void) { | |
| 4924 | + #if 1 | |
| 4925 | + { | |
| 4926 | + pthread_mutex_init(builtin__closure__closure_mtx_ptr_platform(), 0); | |
| 4927 | + } | |
| 4928 | + #endif | |
| 4929 | +} | |
| 4930 | +inline VV_LOC void builtin__closure__closure_mtx_lock_platform(void) { | |
| 4931 | + #if 1 | |
| 4932 | + { | |
| 4933 | + pthread_mutex_lock(builtin__closure__closure_mtx_ptr_platform()); | |
| 4934 | + } | |
| 4935 | + #endif | |
| 4936 | +} | |
| 4937 | +inline VV_LOC void builtin__closure__closure_mtx_unlock_platform(void) { | |
| 4938 | + #if 1 | |
| 4939 | + { | |
| 4940 | + pthread_mutex_unlock(builtin__closure__closure_mtx_ptr_platform()); | |
| 4941 | + } | |
| 4942 | + #endif | |
| 4943 | +} | |
| 4944 | +inline VV_LOC u64 builtin__closure__closure_current_thread_id_platform(void) { | |
| 4945 | + #if 1 | |
| 4946 | + { | |
| 4947 | + return ((u64)(pthread_self())); | |
| 4948 | + } | |
| 4949 | + #endif | |
| 4950 | + return ((u64)(0)); | |
| 4951 | +} | |
| 4952 | +inline VV_LOC void builtin__closure__closure_init_once_platform(void) { | |
| 4953 | + #if 0 | |
| 4954 | + { | |
| 4955 | + } | |
| 4956 | + #else | |
| 4957 | + { | |
| 4958 | + v_closure_init_once(builtin__closure__closure_init_body); | |
| 4959 | + } | |
| 4960 | + #endif | |
| 4961 | +} | |
| 4962 | +inline multi_return_u64_u64 math__bits__mul_64(u64 x, u64 y) { | |
| 4963 | + u64 hi = ((u64)(0)); | |
| 4964 | + u64 lo = ((u64)(0)); | |
| 4965 | + #if defined(_MSC_VER) | |
| 4966 | + { | |
| 4967 | + } | |
| 4968 | + #elif defined(__V_amd64) | |
| 4969 | + { | |
| 4970 | + __asm__ ( | |
| 4971 | + "mulq %%rdx\n\t" | |
| 4972 | + : [lo] "=a" (lo), | |
| 4973 | + [hi] "=d" (hi) | |
| 4974 | + : [x] "a" (x), | |
| 4975 | + [y] "d" (y) | |
| 4976 | + : "cc" | |
| 4977 | + ); | |
| 4978 | + return (multi_return_u64_u64){.arg0=hi, .arg1=lo}; | |
| 4979 | + } | |
| 4980 | + #endif | |
| 4981 | + return math__bits__mul_64_default(x, y); | |
| 4982 | +} | |
| 4983 | +inline multi_return_u64_u64 math__bits__mul_add_64(u64 x, u64 y, u64 z) { | |
| 4984 | + u64 hi = ((u64)(0)); | |
| 4985 | + u64 lo = ((u64)(0)); | |
| 4986 | + #if defined(_MSC_VER) | |
| 4987 | + { | |
| 4988 | + } | |
| 4989 | + #elif defined(__V_amd64) | |
| 4990 | + { | |
| 4991 | + __asm__ ( | |
| 4992 | + "mulq %%rdx\n\t" | |
| 4993 | + "addq %[z], %%rax\n\t" | |
| 4994 | + "adcq $0, %%rdx\n\t" | |
| 4995 | + : [lo] "=a" (lo), | |
| 4996 | + [hi] "=d" (hi) | |
| 4997 | + : [x] "a" (x), | |
| 4998 | + [y] "d" (y), | |
| 4999 | + [z] "r" (z) | |
| 5000 | + : "cc" | |
| 5001 | + ); | |
| 5002 | + return (multi_return_u64_u64){.arg0=hi, .arg1=lo}; | |
| 5003 | + } | |
| 5004 | + #endif | |
| 5005 | + return math__bits__mul_add_64_default(x, y, z); | |
| 5006 | +} | |
| 5007 | +inline multi_return_u64_u64 math__bits__div_64(u64 hi, u64 lo, u64 y1) { | |
| 5008 | + u64 y = y1; | |
| 5009 | + if (y == 0) { | |
| 5010 | + builtin___v_panic(_const_math__bits__divide_error); | |
| 5011 | + VUNREACHABLE(); | |
| 5012 | + } | |
| 5013 | + if (y <= hi) { | |
| 5014 | + builtin___v_panic(_const_math__bits__overflow_error); | |
| 5015 | + VUNREACHABLE(); | |
| 5016 | + } | |
| 5017 | + u64 quo = ((u64)(0)); | |
| 5018 | + u64 rem = ((u64)(0)); | |
| 5019 | + #if defined(_MSC_VER) | |
| 5020 | + { | |
| 5021 | + } | |
| 5022 | + #elif defined(__V_amd64) | |
| 5023 | + { | |
| 5024 | + __asm__ ( | |
| 5025 | + "div %[y]\n\t" | |
| 5026 | + : [quo] "=a" (quo), | |
| 5027 | + [rem] "=d" (rem) | |
| 5028 | + : [hi] "d" (hi), | |
| 5029 | + [lo] "a" (lo), | |
| 5030 | + [y] "r" (y) | |
| 5031 | + : "cc" | |
| 5032 | + ); | |
| 5033 | + return (multi_return_u64_u64){.arg0=quo, .arg1=rem}; | |
| 5034 | + } | |
| 5035 | + #endif | |
| 5036 | + return math__bits__div_64_default(hi, lo, y1); | |
| 5037 | +} | |
| 5038 | +inline int math__bits__leading_zeros_8(u8 x) { | |
| 5039 | + if (x == 0) { | |
| 5040 | + return 8; | |
| 5041 | + } | |
| 5042 | + #if defined(_MSC_VER) | |
| 5043 | + { | |
| 5044 | + } | |
| 5045 | + #elif !defined(__TINYC__) | |
| 5046 | + { | |
| 5047 | + return __builtin_clz(((u32)(x))) - 24; | |
| 5048 | + } | |
| 5049 | + #endif | |
| 5050 | + return math__bits__leading_zeros_8_default(x); | |
| 5051 | +} | |
| 5052 | +inline int math__bits__leading_zeros_16(u16 x) { | |
| 5053 | + if (x == 0) { | |
| 5054 | + return 16; | |
| 5055 | + } | |
| 5056 | + #if defined(_MSC_VER) | |
| 5057 | + { | |
| 5058 | + } | |
| 5059 | + #elif !defined(__TINYC__) | |
| 5060 | + { | |
| 5061 | + return __builtin_clz(((u32)(x))) - 16; | |
| 5062 | + } | |
| 5063 | + #endif | |
| 5064 | + return math__bits__leading_zeros_16_default(x); | |
| 5065 | +} | |
| 5066 | +inline int math__bits__leading_zeros_32(u32 x) { | |
| 5067 | + if (x == 0) { | |
| 5068 | + return 32; | |
| 5069 | + } | |
| 5070 | + #if defined(_MSC_VER) | |
| 5071 | + { | |
| 5072 | + } | |
| 5073 | + #elif !defined(__TINYC__) | |
| 5074 | + { | |
| 5075 | + return __builtin_clz(x); | |
| 5076 | + } | |
| 5077 | + #endif | |
| 5078 | + return math__bits__leading_zeros_32_default(x); | |
| 5079 | +} | |
| 5080 | +inline int math__bits__leading_zeros_64(u64 x) { | |
| 5081 | + if (x == 0) { | |
| 5082 | + return 64; | |
| 5083 | + } | |
| 5084 | + #if defined(_MSC_VER) | |
| 5085 | + { | |
| 5086 | + } | |
| 5087 | + #elif !defined(__TINYC__) | |
| 5088 | + { | |
| 5089 | + return __builtin_clzll(x); | |
| 5090 | + } | |
| 5091 | + #endif | |
| 5092 | + return math__bits__leading_zeros_64_default(x); | |
| 5093 | +} | |
| 5094 | +inline int math__bits__trailing_zeros_8(u8 x) { | |
| 5095 | + if (x == 0) { | |
| 5096 | + return 8; | |
| 5097 | + } | |
| 5098 | + #if defined(_MSC_VER) | |
| 5099 | + { | |
| 5100 | + } | |
| 5101 | + #elif !defined(__TINYC__) | |
| 5102 | + { | |
| 5103 | + return __builtin_ctz(((u32)(x))); | |
| 5104 | + } | |
| 5105 | + #endif | |
| 5106 | + return math__bits__trailing_zeros_8_default(x); | |
| 5107 | +} | |
| 5108 | +inline int math__bits__trailing_zeros_16(u16 x) { | |
| 5109 | + if (x == 0) { | |
| 5110 | + return 16; | |
| 5111 | + } | |
| 5112 | + #if defined(_MSC_VER) | |
| 5113 | + { | |
| 5114 | + } | |
| 5115 | + #elif !defined(__TINYC__) | |
| 5116 | + { | |
| 5117 | + return __builtin_ctz(((u32)(x))); | |
| 5118 | + } | |
| 5119 | + #endif | |
| 5120 | + return math__bits__trailing_zeros_16_default(x); | |
| 5121 | +} | |
| 5122 | +inline int math__bits__trailing_zeros_32(u32 x) { | |
| 5123 | + if (x == 0) { | |
| 5124 | + return 32; | |
| 5125 | + } | |
| 5126 | + #if defined(_MSC_VER) | |
| 5127 | + { | |
| 5128 | + } | |
| 5129 | + #elif !defined(__TINYC__) | |
| 5130 | + { | |
| 5131 | + return __builtin_ctz(x); | |
| 5132 | + } | |
| 5133 | + #endif | |
| 5134 | + return math__bits__trailing_zeros_32_default(x); | |
| 5135 | +} | |
| 5136 | +inline int math__bits__trailing_zeros_64(u64 x) { | |
| 5137 | + if (x == 0) { | |
| 5138 | + return 64; | |
| 5139 | + } | |
| 5140 | + #if defined(_MSC_VER) | |
| 5141 | + { | |
| 5142 | + } | |
| 5143 | + #elif !defined(__TINYC__) | |
| 5144 | + { | |
| 5145 | + return __builtin_ctzll(x); | |
| 5146 | + } | |
| 5147 | + #endif | |
| 5148 | + return math__bits__trailing_zeros_64_default(x); | |
| 5149 | +} | |
| 5150 | +inline int math__bits__ones_count_8(u8 x) { | |
| 5151 | + #if defined(_MSC_VER) | |
| 5152 | + { | |
| 5153 | + } | |
| 5154 | + #elif !defined(__TINYC__) | |
| 5155 | + { | |
| 5156 | + return __builtin_popcount(((u32)(x))); | |
| 5157 | + } | |
| 5158 | + #endif | |
| 5159 | + return math__bits__ones_count_8_default(x); | |
| 5160 | +} | |
| 5161 | +inline int math__bits__ones_count_16(u16 x) { | |
| 5162 | + #if defined(_MSC_VER) | |
| 5163 | + { | |
| 5164 | + } | |
| 5165 | + #elif !defined(__TINYC__) | |
| 5166 | + { | |
| 5167 | + return __builtin_popcount(((u32)(x))); | |
| 5168 | + } | |
| 5169 | + #endif | |
| 5170 | + return math__bits__ones_count_16_default(x); | |
| 5171 | +} | |
| 5172 | +inline int math__bits__ones_count_32(u32 x) { | |
| 5173 | + #if defined(_MSC_VER) | |
| 5174 | + { | |
| 5175 | + } | |
| 5176 | + #elif !defined(__TINYC__) | |
| 5177 | + { | |
| 5178 | + return __builtin_popcount(x); | |
| 5179 | + } | |
| 5180 | + #endif | |
| 5181 | + return math__bits__ones_count_32_default(x); | |
| 5182 | +} | |
| 5183 | +inline int math__bits__ones_count_64(u64 x) { | |
| 5184 | + #if defined(_MSC_VER) | |
| 5185 | + { | |
| 5186 | + } | |
| 5187 | + #elif !defined(__TINYC__) | |
| 5188 | + { | |
| 5189 | + return __builtin_popcountll(x); | |
| 5190 | + } | |
| 5191 | + #endif | |
| 5192 | + return math__bits__ones_count_64_default(x); | |
| 5193 | +} | |
| 5194 | +inline int math__bits__pure_v_but_overridden_by_c_leading_zeros_8(u8 x) { | |
| 5195 | + return math__bits__leading_zeros_8_default(x); | |
| 5196 | +} | |
| 5197 | +inline VV_LOC int math__bits__leading_zeros_8_default(u8 x) { | |
| 5198 | + return 8 - math__bits__len_8(x); | |
| 5199 | +} | |
| 5200 | +inline int math__bits__pure_v_but_overridden_by_c_leading_zeros_16(u16 x) { | |
| 5201 | + return math__bits__leading_zeros_16_default(x); | |
| 5202 | +} | |
| 5203 | +inline VV_LOC int math__bits__leading_zeros_16_default(u16 x) { | |
| 5204 | + return 16 - math__bits__len_16(x); | |
| 5205 | +} | |
| 5206 | +inline int math__bits__pure_v_but_overridden_by_c_leading_zeros_32(u32 x) { | |
| 5207 | + return math__bits__leading_zeros_32_default(x); | |
| 5208 | +} | |
| 5209 | +inline VV_LOC int math__bits__leading_zeros_32_default(u32 x) { | |
| 5210 | + return 32 - math__bits__len_32(x); | |
| 5211 | +} | |
| 5212 | +inline int math__bits__pure_v_but_overridden_by_c_leading_zeros_64(u64 x) { | |
| 5213 | + return math__bits__leading_zeros_64_default(x); | |
| 5214 | +} | |
| 5215 | +inline VV_LOC int math__bits__leading_zeros_64_default(u64 x) { | |
| 5216 | + return 64 - math__bits__len_64(x); | |
| 5217 | +} | |
| 5218 | +inline int math__bits__pure_v_but_overridden_by_c_trailing_zeros_8(u8 x) { | |
| 5219 | + return math__bits__trailing_zeros_8_default(x); | |
| 5220 | +} | |
| 5221 | +inline VV_LOC int math__bits__trailing_zeros_8_default(u8 x) { | |
| 5222 | + return ((int)(_const_math__bits__ntz_8_tab[x])); | |
| 5223 | +} | |
| 5224 | +inline int math__bits__pure_v_but_overridden_by_c_trailing_zeros_16(u16 x) { | |
| 5225 | + return math__bits__trailing_zeros_16_default(x); | |
| 5226 | +} | |
| 5227 | +inline VV_LOC int math__bits__trailing_zeros_16_default(u16 x) { | |
| 5228 | + if (x == 0) { | |
| 5229 | + return 16; | |
| 5230 | + } | |
| 5231 | + return ((int)(_const_math__bits__de_bruijn32tab[v__rshift_u32(((u32)((x & -x))) * _const_math__bits__de_bruijn32, (u64)27)])); | |
| 5232 | +} | |
| 5233 | +inline int math__bits__pure_v_but_overridden_by_c_trailing_zeros_32(u32 x) { | |
| 5234 | + return math__bits__trailing_zeros_32_default(x); | |
| 5235 | +} | |
| 5236 | +inline VV_LOC int math__bits__trailing_zeros_32_default(u32 x) { | |
| 5237 | + if (x == 0) { | |
| 5238 | + return 32; | |
| 5239 | + } | |
| 5240 | + return ((int)(_const_math__bits__de_bruijn32tab[v__rshift_u32(((x & -x)) * _const_math__bits__de_bruijn32, (u64)27)])); | |
| 5241 | +} | |
| 5242 | +inline int math__bits__pure_v_but_overridden_by_c_trailing_zeros_64(u64 x) { | |
| 5243 | + return math__bits__trailing_zeros_64_default(x); | |
| 5244 | +} | |
| 5245 | +inline VV_LOC int math__bits__trailing_zeros_64_default(u64 x) { | |
| 5246 | + if (x == 0) { | |
| 5247 | + return 64; | |
| 5248 | + } | |
| 5249 | + return ((int)(_const_math__bits__de_bruijn64tab[((int)(v__rshift_u64(((x & -x)) * _const_math__bits__de_bruijn64, (u64)58)))])); | |
| 5250 | +} | |
| 5251 | +inline int math__bits__pure_v_but_overridden_by_c_ones_count_8(u8 x) { | |
| 5252 | + return math__bits__ones_count_8_default(x); | |
| 5253 | +} | |
| 5254 | +inline VV_LOC int math__bits__ones_count_8_default(u8 x) { | |
| 5255 | + return ((int)(_const_math__bits__pop_8_tab[x])); | |
| 5256 | +} | |
| 5257 | +inline int math__bits__pure_v_but_overridden_by_c_ones_count_16(u16 x) { | |
| 5258 | + return math__bits__ones_count_16_default(x); | |
| 5259 | +} | |
| 5260 | +inline VV_LOC int math__bits__ones_count_16_default(u16 x) { | |
| 5261 | + return ((int)((u8)(_const_math__bits__pop_8_tab[v__rshift_u16(x, (u64)8)] + _const_math__bits__pop_8_tab[(x & ((u16)(0xff)))]))); | |
| 5262 | +} | |
| 5263 | +inline int math__bits__pure_v_but_overridden_by_c_ones_count_32(u32 x) { | |
| 5264 | + return math__bits__ones_count_32_default(x); | |
| 5265 | +} | |
| 5266 | +inline VV_LOC int math__bits__ones_count_32_default(u32 x) { | |
| 5267 | + return ((int)((u8)((u8)((u8)(_const_math__bits__pop_8_tab[v__rshift_u32(x, (u64)24)] + _const_math__bits__pop_8_tab[((v__rshift_u32(x, (u64)16)) & 0xff)]) + _const_math__bits__pop_8_tab[((v__rshift_u32(x, (u64)8)) & 0xff)]) + _const_math__bits__pop_8_tab[(x & ((u32)(0xff)))]))); | |
| 5268 | +} | |
| 5269 | +inline int math__bits__pure_v_but_overridden_by_c_ones_count_64(u64 x) { | |
| 5270 | + return math__bits__ones_count_64_default(x); | |
| 5271 | +} | |
| 5272 | +inline VV_LOC int math__bits__ones_count_64_default(u64 x) { | |
| 5273 | + u64 y = (((v__rshift_u64(x, (u64)((u64)(1)))) & ((_const_math__bits__m0 & _const_max_u64)))) + ((x & ((_const_math__bits__m0 & _const_max_u64)))); | |
| 5274 | + y = (((v__rshift_u64(y, (u64)((u64)(2)))) & ((_const_math__bits__m1 & _const_max_u64)))) + ((y & ((_const_math__bits__m1 & _const_max_u64)))); | |
| 5275 | + y = (((v__rshift_u64(y, (u64)4)) + y) & ((_const_math__bits__m2 & _const_max_u64))); | |
| 5276 | + y += v__rshift_u64(y, (u64)8); | |
| 5277 | + y += v__rshift_u64(y, (u64)16); | |
| 5278 | + y += v__rshift_u64(y, (u64)32); | |
| 5279 | + return (((int)(y)) & 127); | |
| 5280 | +} | |
| 5281 | +inline u8 math__bits__rotate_left_8(u8 x, int k) { | |
| 5282 | + u8 s = (((u8)(k)) & ((u8)(_const_math__bits__n8 - ((u8)(1))))); | |
| 5283 | + return ((v__lshift_u8(x, (u64)s)) | (v__rshift_u8(x, (u64)((u8)(_const_math__bits__n8 - s))))); | |
| 5284 | +} | |
| 5285 | +inline u16 math__bits__rotate_left_16(u16 x, int k) { | |
| 5286 | + u16 s = (((u16)(k)) & ((u16)(_const_math__bits__n16 - ((u16)(1))))); | |
| 5287 | + return ((v__lshift_u16(x, (u64)s)) | (v__rshift_u16(x, (u64)((u16)(_const_math__bits__n16 - s))))); | |
| 5288 | +} | |
| 5289 | +inline u32 math__bits__rotate_left_32(u32 x, int k) { | |
| 5290 | + u32 s = (((u32)(k)) & (_const_math__bits__n32 - ((u32)(1)))); | |
| 5291 | + return ((v__lshift_u32(x, (u64)s)) | (v__rshift_u32(x, (u64)(_const_math__bits__n32 - s)))); | |
| 5292 | +} | |
| 5293 | +inline u64 math__bits__rotate_left_64(u64 x, int k) { | |
| 5294 | + u64 s = (((u64)(k)) & (_const_math__bits__n64 - ((u64)(1)))); | |
| 5295 | + return ((v__lshift_u64(x, (u64)s)) | (v__rshift_u64(x, (u64)(_const_math__bits__n64 - s)))); | |
| 5296 | +} | |
| 5297 | +inline u8 math__bits__reverse_8(u8 x) { | |
| 5298 | + return _const_math__bits__rev_8_tab[x]; | |
| 5299 | +} | |
| 5300 | +inline u16 math__bits__reverse_16(u16 x) { | |
| 5301 | + return (((u16)(_const_math__bits__rev_8_tab[v__rshift_u16(x, (u64)8)])) | (v__lshift_u16(((u16)(_const_math__bits__rev_8_tab[(x & ((u16)(0xff)))])), (u64)8))); | |
| 5302 | +} | |
| 5303 | +inline u32 math__bits__reverse_32(u32 x) { | |
| 5304 | + u64 y = (((((v__rshift_u32(x, (u64)((u32)(1)))) & ((_const_math__bits__m0 & _const_max_u32)))) | (v__lshift_u64(((x & ((_const_math__bits__m0 & _const_max_u32)))), (u64)1)))); | |
| 5305 | + y = (((((v__rshift_u64(y, (u64)((u32)(2)))) & ((_const_math__bits__m1 & _const_max_u32)))) | (v__lshift_u64(((y & ((_const_math__bits__m1 & _const_max_u32)))), (u64)((u32)(2)))))); | |
| 5306 | + y = (((((v__rshift_u64(y, (u64)((u32)(4)))) & ((_const_math__bits__m2 & _const_max_u32)))) | (v__lshift_u64(((y & ((_const_math__bits__m2 & _const_max_u32)))), (u64)((u32)(4)))))); | |
| 5307 | + return math__bits__reverse_bytes_32(((u32)(y))); | |
| 5308 | +} | |
| 5309 | +inline u64 math__bits__reverse_64(u64 x) { | |
| 5310 | + u64 y = (((((v__rshift_u64(x, (u64)((u64)(1)))) & ((_const_math__bits__m0 & _const_max_u64)))) | (v__lshift_u64(((x & ((_const_math__bits__m0 & _const_max_u64)))), (u64)1)))); | |
| 5311 | + y = (((((v__rshift_u64(y, (u64)((u64)(2)))) & ((_const_math__bits__m1 & _const_max_u64)))) | (v__lshift_u64(((y & ((_const_math__bits__m1 & _const_max_u64)))), (u64)2)))); | |
| 5312 | + y = (((((v__rshift_u64(y, (u64)((u64)(4)))) & ((_const_math__bits__m2 & _const_max_u64)))) | (v__lshift_u64(((y & ((_const_math__bits__m2 & _const_max_u64)))), (u64)4)))); | |
| 5313 | + return math__bits__reverse_bytes_64(y); | |
| 5314 | +} | |
| 5315 | +inline u16 math__bits__reverse_bytes_16(u16 x) { | |
| 5316 | + return ((v__rshift_u16(x, (u64)8)) | (v__lshift_u16(x, (u64)8))); | |
| 5317 | +} | |
| 5318 | +inline u32 math__bits__reverse_bytes_32(u32 x) { | |
| 5319 | + u64 y = (((((v__rshift_u32(x, (u64)((u32)(8)))) & ((_const_math__bits__m3 & _const_max_u32)))) | (v__lshift_u64(((x & ((_const_math__bits__m3 & _const_max_u32)))), (u64)((u32)(8)))))); | |
| 5320 | + return ((u32)(((v__rshift_u64(y, (u64)16)) | (v__lshift_u64(y, (u64)16))))); | |
| 5321 | +} | |
| 5322 | +inline u64 math__bits__reverse_bytes_64(u64 x) { | |
| 5323 | + u64 y = (((((v__rshift_u64(x, (u64)((u64)(8)))) & ((_const_math__bits__m3 & _const_max_u64)))) | (v__lshift_u64(((x & ((_const_math__bits__m3 & _const_max_u64)))), (u64)((u64)(8)))))); | |
| 5324 | + y = (((((v__rshift_u64(y, (u64)((u64)(16)))) & ((_const_math__bits__m4 & _const_max_u64)))) | (v__lshift_u64(((y & ((_const_math__bits__m4 & _const_max_u64)))), (u64)((u64)(16)))))); | |
| 5325 | + return ((v__rshift_u64(y, (u64)32)) | (v__lshift_u64(y, (u64)32))); | |
| 5326 | +} | |
| 5327 | +int math__bits__len_8(u8 x) { | |
| 5328 | + return ((int)(_const_math__bits__len_8_tab[x])); | |
| 5329 | +} | |
| 5330 | +int math__bits__len_16(u16 x) { | |
| 5331 | + u16 y = x; | |
| 5332 | + int n = 0; | |
| 5333 | + if (y >= 256) { | |
| 5334 | + y = v__rshift_u16(y, (u64)8); | |
| 5335 | + n = 8; | |
| 5336 | + } | |
| 5337 | + return n + ((int)(_const_math__bits__len_8_tab[((int)(y))])); | |
| 5338 | +} | |
| 5339 | +int math__bits__len_32(u32 x) { | |
| 5340 | + u32 y = x; | |
| 5341 | + int n = 0; | |
| 5342 | + if (y >= 65536) { | |
| 5343 | + y = v__rshift_u32(y, (u64)16); | |
| 5344 | + n = 16; | |
| 5345 | + } | |
| 5346 | + if (y >= 256) { | |
| 5347 | + y = v__rshift_u32(y, (u64)8); | |
| 5348 | + n += 8; | |
| 5349 | + } | |
| 5350 | + return n + ((int)(_const_math__bits__len_8_tab[((int)(y))])); | |
| 5351 | +} | |
| 5352 | +int math__bits__len_64(u64 x) { | |
| 5353 | + u64 y = x; | |
| 5354 | + int n = 0; | |
| 5355 | + if (y >= v__lshift_u64(((u64)(1)), (u64)((u64)(32)))) { | |
| 5356 | + y = v__rshift_u64(y, (u64)32); | |
| 5357 | + n = 32; | |
| 5358 | + } | |
| 5359 | + if (y >= v__lshift_u64(((u64)(1)), (u64)((u64)(16)))) { | |
| 5360 | + y = v__rshift_u64(y, (u64)16); | |
| 5361 | + n += 16; | |
| 5362 | + } | |
| 5363 | + if (y >= v__lshift_u64(((u64)(1)), (u64)((u64)(8)))) { | |
| 5364 | + y = v__rshift_u64(y, (u64)8); | |
| 5365 | + n += 8; | |
| 5366 | + } | |
| 5367 | + return n + ((int)(_const_math__bits__len_8_tab[((int)(y))])); | |
| 5368 | +} | |
| 5369 | +multi_return_u32_u32 math__bits__add_32(u32 x, u32 y, u32 carry) { | |
| 5370 | + u64 sum64 = ((u64)(x)) + ((u64)(y)) + ((u64)(carry)); | |
| 5371 | + u32 sum = ((u32)(sum64)); | |
| 5372 | + u32 carry_out = ((u32)(v__rshift_u64(sum64, (u64)32))); | |
| 5373 | + return (multi_return_u32_u32){.arg0=sum, .arg1=carry_out}; | |
| 5374 | +} | |
| 5375 | +multi_return_u64_u64 math__bits__add_64(u64 x, u64 y, u64 carry) { | |
| 5376 | + u64 sum = x + y + carry; | |
| 5377 | + u64 carry_out = v__rshift_u64(((((x & y)) | ((((x | y)) & ~sum)))), (u64)63); | |
| 5378 | + return (multi_return_u64_u64){.arg0=sum, .arg1=carry_out}; | |
| 5379 | +} | |
| 5380 | +multi_return_u32_u32 math__bits__sub_32(u32 x, u32 y, u32 borrow) { | |
| 5381 | + u32 diff = x - y - borrow; | |
| 5382 | + u32 borrow_out = v__rshift_u32(((((~x & y)) | ((~((x ^ y)) & diff)))), (u64)31); | |
| 5383 | + return (multi_return_u32_u32){.arg0=diff, .arg1=borrow_out}; | |
| 5384 | +} | |
| 5385 | +multi_return_u64_u64 math__bits__sub_64(u64 x, u64 y, u64 borrow) { | |
| 5386 | + u64 diff = x - y - borrow; | |
| 5387 | + u64 borrow_out = v__rshift_u64(((((~x & y)) | ((~((x ^ y)) & diff)))), (u64)63); | |
| 5388 | + return (multi_return_u64_u64){.arg0=diff, .arg1=borrow_out}; | |
| 5389 | +} | |
| 5390 | +inline multi_return_u32_u32 math__bits__mul_32(u32 x, u32 y) { | |
| 5391 | + return math__bits__mul_32_default(x, y); | |
| 5392 | +} | |
| 5393 | +inline VV_LOC multi_return_u32_u32 math__bits__mul_32_default(u32 x, u32 y) { | |
| 5394 | + u64 tmp = ((u64)(x)) * ((u64)(y)); | |
| 5395 | + u32 hi = ((u32)(v__rshift_u64(tmp, (u64)32))); | |
| 5396 | + u32 lo = ((u32)(tmp)); | |
| 5397 | + return (multi_return_u32_u32){.arg0=hi, .arg1=lo}; | |
| 5398 | +} | |
| 5399 | +inline multi_return_u64_u64 math__bits__pure_v_but_overridden_by_amd64_mul_64(u64 x, u64 y) { | |
| 5400 | + return math__bits__mul_64_default(x, y); | |
| 5401 | +} | |
| 5402 | +VV_LOC multi_return_u64_u64 math__bits__mul_64_default(u64 x, u64 y) { | |
| 5403 | + u64 x0 = (x & _const_math__bits__mask32); | |
| 5404 | + u64 x1 = v__rshift_u64(x, (u64)32); | |
| 5405 | + u64 y0 = (y & _const_math__bits__mask32); | |
| 5406 | + u64 y1 = v__rshift_u64(y, (u64)32); | |
| 5407 | + u64 w0 = x0 * y0; | |
| 5408 | + u64 t = x1 * y0 + (v__rshift_u64(w0, (u64)32)); | |
| 5409 | + u64 w1 = (t & _const_math__bits__mask32); | |
| 5410 | + u64 w2 = v__rshift_u64(t, (u64)32); | |
| 5411 | + w1 += x0 * y1; | |
| 5412 | + u64 hi = x1 * y1 + w2 + (v__rshift_u64(w1, (u64)32)); | |
| 5413 | + u64 lo = x * y; | |
| 5414 | + return (multi_return_u64_u64){.arg0=hi, .arg1=lo}; | |
| 5415 | +} | |
| 5416 | +inline multi_return_u32_u32 math__bits__mul_add_32(u32 x, u32 y, u32 z) { | |
| 5417 | + return math__bits__mul_add_32_default(x, y, z); | |
| 5418 | +} | |
| 5419 | +inline VV_LOC multi_return_u32_u32 math__bits__mul_add_32_default(u32 x, u32 y, u32 z) { | |
| 5420 | + u64 tmp = ((u64)(x)) * ((u64)(y)) + ((u64)(z)); | |
| 5421 | + u32 hi = ((u32)(v__rshift_u64(tmp, (u64)32))); | |
| 5422 | + u32 lo = ((u32)(tmp)); | |
| 5423 | + return (multi_return_u32_u32){.arg0=hi, .arg1=lo}; | |
| 5424 | +} | |
| 5425 | +inline multi_return_u64_u64 math__bits__pure_v_but_overridden_by_amd64_mul_add_64(u64 x, u64 y, u64 z) { | |
| 5426 | + return math__bits__mul_add_64_default(x, y, z); | |
| 5427 | +} | |
| 5428 | +inline VV_LOC multi_return_u64_u64 math__bits__mul_add_64_default(u64 x, u64 y, u64 z) { | |
| 5429 | + multi_return_u64_u64 mr_14968 = math__bits__mul_64(x, y); | |
| 5430 | + u64 h = mr_14968.arg0; | |
| 5431 | + u64 l = mr_14968.arg1; | |
| 5432 | + u64 lo = l + z; | |
| 5433 | + u64 hi = h + (u64[]){(lo < l)?1:0}[0]; | |
| 5434 | + return (multi_return_u64_u64){.arg0=hi, .arg1=lo}; | |
| 5435 | +} | |
| 5436 | +inline multi_return_u32_u32 math__bits__div_32(u32 hi, u32 lo, u32 y) { | |
| 5437 | + return math__bits__div_32_default(hi, lo, y); | |
| 5438 | +} | |
| 5439 | +VV_LOC multi_return_u32_u32 math__bits__div_32_default(u32 hi, u32 lo, u32 y) { | |
| 5440 | + if (y == 0) { | |
| 5441 | + builtin___v_panic(_const_math__bits__divide_error); | |
| 5442 | + VUNREACHABLE(); | |
| 5443 | + } | |
| 5444 | + if (y <= hi) { | |
| 5445 | + builtin___v_panic(_const_math__bits__overflow_error); | |
| 5446 | + VUNREACHABLE(); | |
| 5447 | + } | |
| 5448 | + u64 z = ((v__lshift_u64(((u64)(hi)), (u64)32)) | ((u64)(lo))); | |
| 5449 | + u32 quo = ((u32)(VSAFE_DIV_u64(z , ((u64)(y))))); | |
| 5450 | + u32 rem = ((u32)(VSAFE_MOD_u64(z , ((u64)(y))))); | |
| 5451 | + return (multi_return_u32_u32){.arg0=quo, .arg1=rem}; | |
| 5452 | +} | |
| 5453 | +inline multi_return_u64_u64 math__bits__pure_v_but_overridden_by_amd64_div_64(u64 hi, u64 lo, u64 y1) { | |
| 5454 | + return math__bits__div_64_default(hi, lo, y1); | |
| 5455 | +} | |
| 5456 | +VV_LOC multi_return_u64_u64 math__bits__div_64_default(u64 hi, u64 lo, u64 y1) { | |
| 5457 | + u64 y = y1; | |
| 5458 | + if (y == 0) { | |
| 5459 | + builtin___v_panic(_const_math__bits__divide_error); | |
| 5460 | + VUNREACHABLE(); | |
| 5461 | + } | |
| 5462 | + if (y <= hi) { | |
| 5463 | + builtin___v_panic(_const_math__bits__overflow_error); | |
| 5464 | + VUNREACHABLE(); | |
| 5465 | + } | |
| 5466 | + u32 s = ((u32)(math__bits__leading_zeros_64(y))); | |
| 5467 | + y = v__lshift_u64(y, (u64)s); | |
| 5468 | + u64 yn1 = v__rshift_u64(y, (u64)32); | |
| 5469 | + u64 yn0 = (y & _const_math__bits__mask32); | |
| 5470 | + u64 ss1 = (v__lshift_u64(hi, (u64)s)); | |
| 5471 | + u32 xxx = 64 - s; | |
| 5472 | + u64 ss2 = v__rshift_u64(lo, (u64)xxx); | |
| 5473 | + if (xxx == 64) { | |
| 5474 | + ss2 = 0; | |
| 5475 | + } | |
| 5476 | + u64 un32 = (ss1 | ss2); | |
| 5477 | + u64 un10 = v__lshift_u64(lo, (u64)s); | |
| 5478 | + u64 un1 = v__rshift_u64(un10, (u64)32); | |
| 5479 | + u64 un0 = (un10 & _const_math__bits__mask32); | |
| 5480 | + u64 q1 = VSAFE_DIV_u64(un32 , yn1); | |
| 5481 | + u64 rhat = un32 - (q1 * yn1); | |
| 5482 | + for (;;) { | |
| 5483 | + if (!(q1 >= _const_math__bits__two32 || (q1 * yn0) > ((_const_math__bits__two32 * rhat) + un1))) break; | |
| 5484 | + q1--; | |
| 5485 | + rhat += yn1; | |
| 5486 | + if (rhat >= _const_math__bits__two32) { | |
| 5487 | + break; | |
| 5488 | + } | |
| 5489 | + } | |
| 5490 | + u64 un21 = (un32 * _const_math__bits__two32) + (un1 - (q1 * y)); | |
| 5491 | + u64 q0 = VSAFE_DIV_u64(un21 , yn1); | |
| 5492 | + rhat = un21 - q0 * yn1; | |
| 5493 | + for (;;) { | |
| 5494 | + if (!(q0 >= _const_math__bits__two32 || (q0 * yn0) > ((_const_math__bits__two32 * rhat) + un0))) break; | |
| 5495 | + q0--; | |
| 5496 | + rhat += yn1; | |
| 5497 | + if (rhat >= _const_math__bits__two32) { | |
| 5498 | + break; | |
| 5499 | + } | |
| 5500 | + } | |
| 5501 | + u64 qq = ((q1 * _const_math__bits__two32) + q0); | |
| 5502 | + u64 rr = v__rshift_u64(((un21 * _const_math__bits__two32) + un0 - (q0 * y)), (u64)s); | |
| 5503 | + return (multi_return_u64_u64){.arg0=qq, .arg1=rr}; | |
| 5504 | +} | |
| 5505 | +inline u32 math__bits__rem_32(u32 hi, u32 lo, u32 y) { | |
| 5506 | + if (y == 0) { | |
| 5507 | + builtin___v_panic(_const_math__bits__divide_error); | |
| 5508 | + VUNREACHABLE(); | |
| 5509 | + } | |
| 5510 | + return ((u32)(VSAFE_MOD_u64((((v__lshift_u64(((u64)(hi)), (u64)32)) | ((u64)(lo)))) , ((u64)(y))))); | |
| 5511 | +} | |
| 5512 | +inline u64 math__bits__rem_64(u64 hi, u64 lo, u64 y) { | |
| 5513 | + if (y == 0) { | |
| 5514 | + builtin___v_panic(_const_math__bits__divide_error); | |
| 5515 | + VUNREACHABLE(); | |
| 5516 | + } | |
| 5517 | + multi_return_u64_u64 mr_18593 = math__bits__div_64(VSAFE_MOD_u64(hi , y), lo, y); | |
| 5518 | + u64 rem = mr_18593.arg1; | |
| 5519 | + return rem; | |
| 5520 | +} | |
| 5521 | +multi_return_f64_int math__bits__normalize(f64 x) { | |
| 5522 | + f64 smallest_normal = 2.2250738585072014e-308; | |
| 5523 | + if (((x > ((f64)(0.0)) ? (x) : (-x))) < smallest_normal) { | |
| 5524 | + return (multi_return_f64_int){.arg0=(f64)(x * (v__lshift_u64(((u64)(1)), (u64)((u64)(52))))), .arg1=-52}; | |
| 5525 | + } | |
| 5526 | + return (multi_return_f64_int){.arg0=x, .arg1=0}; | |
| 5527 | +} | |
| 5528 | +inline u32 math__bits__f32_bits(f32 f) { | |
| 5529 | + u32 p = *((u32*)(&f)); | |
| 5530 | + return p; | |
| 5531 | +} | |
| 5532 | +inline f32 math__bits__f32_from_bits(u32 b) { | |
| 5533 | + f32 p = *((f32*)(&b)); | |
| 5534 | + return p; | |
| 5535 | +} | |
| 5536 | +inline u64 math__bits__f64_bits(f64 f) { | |
| 5537 | + u64 p = *((u64*)(&f)); | |
| 5538 | + return p; | |
| 5539 | +} | |
| 5540 | +inline f64 math__bits__f64_from_bits(u64 b) { | |
| 5541 | + f64 p = *((f64*)(&b)); | |
| 5542 | + return p; | |
| 5543 | +} | |
| 5544 | +VV_LOC multi_return_u32_u32_u32 strconv__lsr96(u32 s2, u32 s1, u32 s0) { | |
| 5545 | + u32 r0 = ((u32)(0)); | |
| 5546 | + u32 r1 = ((u32)(0)); | |
| 5547 | + u32 r2 = ((u32)(0)); | |
| 5548 | + r0 = ((v__rshift_u32(s0, (u64)1)) | (v__lshift_u32(((s1 & ((u32)(1)))), (u64)31))); | |
| 5549 | + r1 = ((v__rshift_u32(s1, (u64)1)) | (v__lshift_u32(((s2 & ((u32)(1)))), (u64)31))); | |
| 5550 | + r2 = v__rshift_u32(s2, (u64)1); | |
| 5551 | + return (multi_return_u32_u32_u32){.arg0=r2, .arg1=r1, .arg2=r0}; | |
| 5552 | +} | |
| 5553 | +VV_LOC multi_return_u32_u32_u32 strconv__lsl96(u32 s2, u32 s1, u32 s0) { | |
| 5554 | + u32 r0 = ((u32)(0)); | |
| 5555 | + u32 r1 = ((u32)(0)); | |
| 5556 | + u32 r2 = ((u32)(0)); | |
| 5557 | + r2 = ((v__lshift_u32(s2, (u64)1)) | (v__rshift_u32(((s1 & (v__lshift_u32(((u32)(1)), (u64)31)))), (u64)31))); | |
| 5558 | + r1 = ((v__lshift_u32(s1, (u64)1)) | (v__rshift_u32(((s0 & (v__lshift_u32(((u32)(1)), (u64)31)))), (u64)31))); | |
| 5559 | + r0 = v__lshift_u32(s0, (u64)1); | |
| 5560 | + return (multi_return_u32_u32_u32){.arg0=r2, .arg1=r1, .arg2=r0}; | |
| 5561 | +} | |
| 5562 | +VV_LOC multi_return_u32_u32_u32 strconv__add96(u32 s2, u32 s1, u32 s0, u32 d2, u32 d1, u32 d0) { | |
| 5563 | + u64 w = ((u64)(0)); | |
| 5564 | + u32 r0 = ((u32)(0)); | |
| 5565 | + u32 r1 = ((u32)(0)); | |
| 5566 | + u32 r2 = ((u32)(0)); | |
| 5567 | + w = ((u64)(s0)) + ((u64)(d0)); | |
| 5568 | + r0 = ((u32)(w)); | |
| 5569 | + w = v__rshift_u64(w, (u64)32); | |
| 5570 | + w += ((u64)(s1)) + ((u64)(d1)); | |
| 5571 | + r1 = ((u32)(w)); | |
| 5572 | + w = v__rshift_u64(w, (u64)32); | |
| 5573 | + w += ((u64)(s2)) + ((u64)(d2)); | |
| 5574 | + r2 = ((u32)(w)); | |
| 5575 | + return (multi_return_u32_u32_u32){.arg0=r2, .arg1=r1, .arg2=r0}; | |
| 5576 | +} | |
| 5577 | +VV_LOC multi_return_strconv__ParserState_strconv__PrepNumber strconv__parser(string s) { | |
| 5578 | + int digx = 0; | |
| 5579 | + strconv__ParserState result = strconv__ParserState__ok; | |
| 5580 | + bool expneg = false; | |
| 5581 | + int expexp = 0; | |
| 5582 | + int i = 0; | |
| 5583 | + strconv__PrepNumber _t1 = ((strconv__PrepNumber){.negative = 0,.exponent = 0,.mantissa = 0,}); | |
| 5584 | + strconv__PrepNumber pn = _t1; | |
| 5585 | + for (;;) { | |
| 5586 | + if (!(i < s.len && builtin__u8_is_space(s.str[ i]))) break; | |
| 5587 | + i++; | |
| 5588 | + } | |
| 5589 | + if (s.str[ i] == '-') { | |
| 5590 | + pn.negative = true; | |
| 5591 | + i++; | |
| 5592 | + } | |
| 5593 | + if (s.str[ i] == '+') { | |
| 5594 | + i++; | |
| 5595 | + } | |
| 5596 | + for (;;) { | |
| 5597 | + if (!(i < s.len && builtin__u8_is_digit(s.str[ i]))) break; | |
| 5598 | + if (pn.mantissa == 0 && s.str[ i] == _const_strconv__c_zero) { | |
| 5599 | + i++; | |
| 5600 | + continue; | |
| 5601 | + } | |
| 5602 | + if (digx < 18) { | |
| 5603 | + pn.mantissa *= 10; | |
| 5604 | + pn.mantissa += ((u64)((rune)(s.str[ i] - _const_strconv__c_zero))); | |
| 5605 | + digx++; | |
| 5606 | + } else if (pn.exponent < 2147483647) { | |
| 5607 | + pn.exponent++; | |
| 5608 | + } | |
| 5609 | + i++; | |
| 5610 | + } | |
| 5611 | + if (i < s.len && s.str[ i] == '.') { | |
| 5612 | + i++; | |
| 5613 | + for (;;) { | |
| 5614 | + if (!(i < s.len && builtin__u8_is_digit(s.str[ i]))) break; | |
| 5615 | + if (pn.mantissa == 0 && s.str[ i] == _const_strconv__c_zero) { | |
| 5616 | + pn.exponent--; | |
| 5617 | + i++; | |
| 5618 | + continue; | |
| 5619 | + } | |
| 5620 | + if (digx < 18) { | |
| 5621 | + pn.mantissa *= 10; | |
| 5622 | + pn.mantissa += ((u64)((rune)(s.str[ i] - _const_strconv__c_zero))); | |
| 5623 | + pn.exponent--; | |
| 5624 | + digx++; | |
| 5625 | + } | |
| 5626 | + i++; | |
| 5627 | + } | |
| 5628 | + } | |
| 5629 | + if (i < s.len && (s.str[ i] == 'e' || s.str[ i] == 'E')) { | |
| 5630 | + i++; | |
| 5631 | + if (i < s.len) { | |
| 5632 | + if (s.str[ i] == _const_strconv__c_plus) { | |
| 5633 | + i++; | |
| 5634 | + } else if (s.str[ i] == _const_strconv__c_minus) { | |
| 5635 | + expneg = true; | |
| 5636 | + i++; | |
| 5637 | + } | |
| 5638 | + for (;;) { | |
| 5639 | + if (!(i < s.len && builtin__u8_is_digit(s.str[ i]))) break; | |
| 5640 | + if (expexp < 214748364) { | |
| 5641 | + expexp *= 10; | |
| 5642 | + expexp += ((int)((rune)(s.str[ i] - _const_strconv__c_zero))); | |
| 5643 | + } | |
| 5644 | + i++; | |
| 5645 | + } | |
| 5646 | + } | |
| 5647 | + } | |
| 5648 | + if (expneg) { | |
| 5649 | + expexp = -expexp; | |
| 5650 | + } | |
| 5651 | + pn.exponent += expexp; | |
| 5652 | + if (pn.mantissa == 0) { | |
| 5653 | + if (pn.negative) { | |
| 5654 | + result = strconv__ParserState__mzero; | |
| 5655 | + } else { | |
| 5656 | + result = strconv__ParserState__pzero; | |
| 5657 | + } | |
| 5658 | + } else if (pn.exponent > 309) { | |
| 5659 | + if (pn.negative) { | |
| 5660 | + result = strconv__ParserState__minf; | |
| 5661 | + } else { | |
| 5662 | + result = strconv__ParserState__pinf; | |
| 5663 | + } | |
| 5664 | + } else if (pn.exponent < -328) { | |
| 5665 | + if (pn.negative) { | |
| 5666 | + result = strconv__ParserState__mzero; | |
| 5667 | + } else { | |
| 5668 | + result = strconv__ParserState__pzero; | |
| 5669 | + } | |
| 5670 | + } | |
| 5671 | + if (i == 0 && s.len > 0) { | |
| 5672 | + return (multi_return_strconv__ParserState_strconv__PrepNumber){.arg0=strconv__ParserState__invalid_number, .arg1=pn}; | |
| 5673 | + } | |
| 5674 | + if (i != s.len) { | |
| 5675 | + return (multi_return_strconv__ParserState_strconv__PrepNumber){.arg0=strconv__ParserState__extra_char, .arg1=pn}; | |
| 5676 | + } | |
| 5677 | + return (multi_return_strconv__ParserState_strconv__PrepNumber){.arg0=result, .arg1=pn}; | |
| 5678 | +} | |
| 5679 | +VV_LOC u64 strconv__converter(strconv__PrepNumber* pn) { | |
| 5680 | + int binexp = 92; | |
| 5681 | + u32 s2 = ((u32)(0)); | |
| 5682 | + u32 s1 = ((u32)(0)); | |
| 5683 | + u32 s0 = ((u32)(0)); | |
| 5684 | + u32 q2 = ((u32)(0)); | |
| 5685 | + u32 q1 = ((u32)(0)); | |
| 5686 | + u32 q0 = ((u32)(0)); | |
| 5687 | + u32 r2 = ((u32)(0)); | |
| 5688 | + u32 r1 = ((u32)(0)); | |
| 5689 | + u32 r0 = ((u32)(0)); | |
| 5690 | + u32 mask28 = ((u32)(v__lshift_u64(((u64)(0xF)), (u64)28))); | |
| 5691 | + u64 result = ((u64)(0)); | |
| 5692 | + s0 = ((u32)((pn->mantissa & ((u64)(0x00000000FFFFFFFFU))))); | |
| 5693 | + s1 = ((u32)(v__rshift_u64(pn->mantissa, (u64)32))); | |
| 5694 | + s2 = ((u32)(0)); | |
| 5695 | + if (pn->mantissa == 0 && pn->exponent <= 0) { | |
| 5696 | + return (pn->negative ? (_const_strconv__double_minus_zero) : (_const_strconv__double_plus_zero)); | |
| 5697 | + } | |
| 5698 | + for (;;) { | |
| 5699 | + if (!(pn->exponent > 0)) break; | |
| 5700 | + multi_return_u32_u32_u32 mr_5881 = strconv__lsl96(s2, s1, s0); | |
| 5701 | + q2 = mr_5881.arg0; | |
| 5702 | + q1 = mr_5881.arg1; | |
| 5703 | + q0 = mr_5881.arg2; | |
| 5704 | + multi_return_u32_u32_u32 mr_5927 = strconv__lsl96(q2, q1, q0); | |
| 5705 | + r2 = mr_5927.arg0; | |
| 5706 | + r1 = mr_5927.arg1; | |
| 5707 | + r0 = mr_5927.arg2; | |
| 5708 | + multi_return_u32_u32_u32 mr_5983 = strconv__lsl96(r2, r1, r0); | |
| 5709 | + s2 = mr_5983.arg0; | |
| 5710 | + s1 = mr_5983.arg1; | |
| 5711 | + s0 = mr_5983.arg2; | |
| 5712 | + multi_return_u32_u32_u32 mr_6039 = strconv__add96(s2, s1, s0, q2, q1, q0); | |
| 5713 | + s2 = mr_6039.arg0; | |
| 5714 | + s1 = mr_6039.arg1; | |
| 5715 | + s0 = mr_6039.arg2; | |
| 5716 | + pn->exponent--; | |
| 5717 | + for (;;) { | |
| 5718 | + if (!(((s2 & mask28)) != 0)) break; | |
| 5719 | + multi_return_u32_u32_u32 mr_6162 = strconv__lsr96(s2, s1, s0); | |
| 5720 | + q2 = mr_6162.arg0; | |
| 5721 | + q1 = mr_6162.arg1; | |
| 5722 | + q0 = mr_6162.arg2; | |
| 5723 | + binexp++; | |
| 5724 | + s2 = q2; | |
| 5725 | + s1 = q1; | |
| 5726 | + s0 = q0; | |
| 5727 | + } | |
| 5728 | + } | |
| 5729 | + for (;;) { | |
| 5730 | + if (!(pn->exponent < 0)) break; | |
| 5731 | + for (;;) { | |
| 5732 | + if (!(!(((s2 & (v__lshift_u32(((u32)(1)), (u64)31)))) != 0))) break; | |
| 5733 | + multi_return_u32_u32_u32 mr_6309 = strconv__lsl96(s2, s1, s0); | |
| 5734 | + q2 = mr_6309.arg0; | |
| 5735 | + q1 = mr_6309.arg1; | |
| 5736 | + q0 = mr_6309.arg2; | |
| 5737 | + binexp--; | |
| 5738 | + s2 = q2; | |
| 5739 | + s1 = q1; | |
| 5740 | + s0 = q0; | |
| 5741 | + } | |
| 5742 | + q2 = VSAFE_DIV_u32(s2 , _const_strconv__c_ten); | |
| 5743 | + r1 = VSAFE_MOD_u32(s2 , _const_strconv__c_ten); | |
| 5744 | + r2 = ((v__rshift_u32(s1, (u64)8)) | (v__lshift_u32(r1, (u64)24))); | |
| 5745 | + q1 = VSAFE_DIV_u32(r2 , _const_strconv__c_ten); | |
| 5746 | + r1 = VSAFE_MOD_u32(r2 , _const_strconv__c_ten); | |
| 5747 | + r2 = (((v__lshift_u32(((s1 & ((u32)(0xFF)))), (u64)16)) | (v__rshift_u32(s0, (u64)16))) | (v__lshift_u32(r1, (u64)24))); | |
| 5748 | + r0 = VSAFE_DIV_u32(r2 , _const_strconv__c_ten); | |
| 5749 | + r1 = VSAFE_MOD_u32(r2 , _const_strconv__c_ten); | |
| 5750 | + q1 = ((v__lshift_u32(q1, (u64)8)) | (v__rshift_u32(((r0 & ((u32)(0x00FF0000)))), (u64)16))); | |
| 5751 | + q0 = v__lshift_u32(r0, (u64)16); | |
| 5752 | + r2 = (((s0 & ((u32)(0xFFFF)))) | (v__lshift_u32(r1, (u64)16))); | |
| 5753 | + q0 |= VSAFE_DIV_u32(r2 , _const_strconv__c_ten); | |
| 5754 | + s2 = q2; | |
| 5755 | + s1 = q1; | |
| 5756 | + s0 = q0; | |
| 5757 | + pn->exponent++; | |
| 5758 | + } | |
| 5759 | + if (s2 != 0 || s1 != 0 || s0 != 0) { | |
| 5760 | + for (;;) { | |
| 5761 | + if (!(((s2 & mask28)) == 0)) break; | |
| 5762 | + multi_return_u32_u32_u32 mr_6989 = strconv__lsl96(s2, s1, s0); | |
| 5763 | + q2 = mr_6989.arg0; | |
| 5764 | + q1 = mr_6989.arg1; | |
| 5765 | + q0 = mr_6989.arg2; | |
| 5766 | + binexp--; | |
| 5767 | + s2 = q2; | |
| 5768 | + s1 = q1; | |
| 5769 | + s0 = q0; | |
| 5770 | + } | |
| 5771 | + } | |
| 5772 | + if (binexp < -1022 && ((s2 | s1)) != 0) { | |
| 5773 | + int shift = -1022 - binexp; | |
| 5774 | + if (shift > 60) { | |
| 5775 | + return (pn->negative ? (_const_strconv__double_minus_zero) : (_const_strconv__double_plus_zero)); | |
| 5776 | + } | |
| 5777 | + u64 shifted = v__rshift_u64((((v__lshift_u64(((u64)(s2)), (u64)32)) | ((u64)(s1)))), (u64)((u32)(shift))); | |
| 5778 | + u64 q = (v__rshift_u64(shifted, (u64)8)) + (u64[]){(((v__rshift_u64(shifted, (u64)7)) & 1) != 0 && (((shifted & 0x7F)) != 0 || ((v__rshift_u64(shifted, (u64)8)) & 1) != 0))?1:0}[0]; | |
| 5779 | + return (((q & 0x000FFFFFFFFFFFFFLL)) | (v__lshift_u64((u64[]){(pn->negative)?1:0}[0], (u64)63))); | |
| 5780 | + } | |
| 5781 | + int nbit = 7; | |
| 5782 | + u32 check_round_bit = v__lshift_u32(((u32)(1)), (u64)((u32)(nbit))); | |
| 5783 | + u32 check_round_mask = v__lshift_u32(((u32)(0xFFFFFFFFU)), (u64)((u32)(nbit))); | |
| 5784 | + if (((s1 & check_round_bit)) != 0) { | |
| 5785 | + if (((s1 & ~check_round_mask)) != 0) { | |
| 5786 | + multi_return_u32_u32_u32 mr_9182 = strconv__add96(s2, s1, s0, 0, check_round_bit, 0); | |
| 5787 | + s2 = mr_9182.arg0; | |
| 5788 | + s1 = mr_9182.arg1; | |
| 5789 | + s0 = mr_9182.arg2; | |
| 5790 | + } else { | |
| 5791 | + if (((s1 & (v__lshift_u32(check_round_bit, (u64)((u32)(1)))))) != 0) { | |
| 5792 | + multi_return_u32_u32_u32 mr_9376 = strconv__add96(s2, s1, s0, 0, check_round_bit, 0); | |
| 5793 | + s2 = mr_9376.arg0; | |
| 5794 | + s1 = mr_9376.arg1; | |
| 5795 | + s0 = mr_9376.arg2; | |
| 5796 | + } | |
| 5797 | + } | |
| 5798 | + s1 = (s1 & check_round_mask); | |
| 5799 | + s0 = ((u32)(0)); | |
| 5800 | + if ((s2 & (v__lshift_u32(mask28, (u64)((u32)(1))))) != 0) { | |
| 5801 | + multi_return_u32_u32_u32 mr_9583 = strconv__lsr96(s2, s1, s0); | |
| 5802 | + q2 = mr_9583.arg0; | |
| 5803 | + q1 = mr_9583.arg1; | |
| 5804 | + q0 = mr_9583.arg2; | |
| 5805 | + binexp++; | |
| 5806 | + s2 = q2; | |
| 5807 | + s1 = q1; | |
| 5808 | + s0 = q0; | |
| 5809 | + } | |
| 5810 | + } | |
| 5811 | + binexp += 1023; | |
| 5812 | + if (binexp > 2046) { | |
| 5813 | + if (pn->negative) { | |
| 5814 | + result = _const_strconv__double_minus_infinity; | |
| 5815 | + } else { | |
| 5816 | + result = _const_strconv__double_plus_infinity; | |
| 5817 | + } | |
| 5818 | + } else if (binexp < 1) { | |
| 5819 | + if (pn->negative) { | |
| 5820 | + result = _const_strconv__double_minus_zero; | |
| 5821 | + } else { | |
| 5822 | + result = _const_strconv__double_plus_zero; | |
| 5823 | + } | |
| 5824 | + } else if (s2 != 0) { | |
| 5825 | + u64 q = ((u64)(0)); | |
| 5826 | + u64 binexs2 = v__lshift_u64(((u64)(binexp)), (u64)52); | |
| 5827 | + q = (((v__lshift_u64(((u64)((s2 & ~mask28))), (u64)24)) | (v__rshift_u64((((u64)(s1)) + ((u64)(128))), (u64)8))) | binexs2); | |
| 5828 | + if (pn->negative) { | |
| 5829 | + q |= (v__lshift_u64(((u64)(1)), (u64)63)); | |
| 5830 | + } | |
| 5831 | + result = q; | |
| 5832 | + } | |
| 5833 | + return result; | |
| 5834 | +} | |
| 5835 | +_result_f64 strconv__atof64(string s, strconv__AtoF64Param param) { | |
| 5836 | + if (s.len == 0) { | |
| 5837 | + return (_result_f64){ .is_error=true, .err=builtin___v_error(_S("expected a number found an empty string")), .data={E_STRUCT} }; | |
| 5838 | + } | |
| 5839 | + strconv__Float64u _t2 = ((strconv__Float64u){0}); | |
| 5840 | + strconv__Float64u res = _t2; | |
| 5841 | + multi_return_strconv__ParserState_strconv__PrepNumber mr_10868 = strconv__parser(s); | |
| 5842 | + strconv__ParserState res_parsing = mr_10868.arg0; | |
| 5843 | + strconv__PrepNumber pn = mr_10868.arg1; | |
| 5844 | + switch (res_parsing) { | |
| 5845 | + case strconv__ParserState__ok: { | |
| 5846 | + res.u = strconv__converter((voidptr)&pn); | |
| 5847 | + break; | |
| 5848 | + } | |
| 5849 | + case strconv__ParserState__pzero: { | |
| 5850 | + res.u = _const_strconv__double_plus_zero; | |
| 5851 | + break; | |
| 5852 | + } | |
| 5853 | + case strconv__ParserState__mzero: { | |
| 5854 | + res.u = _const_strconv__double_minus_zero; | |
| 5855 | + break; | |
| 5856 | + } | |
| 5857 | + case strconv__ParserState__pinf: { | |
| 5858 | + res.u = _const_strconv__double_plus_infinity; | |
| 5859 | + break; | |
| 5860 | + } | |
| 5861 | + case strconv__ParserState__minf: { | |
| 5862 | + res.u = _const_strconv__double_minus_infinity; | |
| 5863 | + break; | |
| 5864 | + } | |
| 5865 | + case strconv__ParserState__extra_char: { | |
| 5866 | + if (param.allow_extra_chars) { | |
| 5867 | + res.u = strconv__converter((voidptr)&pn); | |
| 5868 | + } else { | |
| 5869 | + return (_result_f64){ .is_error=true, .err=builtin___v_error(_S("extra char after number")), .data={E_STRUCT} }; | |
| 5870 | + } | |
| 5871 | + break; | |
| 5872 | + } | |
| 5873 | + case strconv__ParserState__invalid_number: { | |
| 5874 | + return (_result_f64){ .is_error=true, .err=builtin___v_error(_S("not a number")), .data={E_STRUCT} }; | |
| 5875 | + } | |
| 5876 | + } | |
| 5877 | + | |
| 5878 | + _result_f64 _t5; | |
| 5879 | + builtin___result_ok(&(f64[]) { res.f }, (_result*)(&_t5), sizeof(f64)); | |
| 5880 | + | |
| 5881 | + return _t5; | |
| 5882 | +} | |
| 5883 | +f64 strconv__atof_quick(string s) { | |
| 5884 | + strconv__Float64u _t1 = ((strconv__Float64u){0}); | |
| 5885 | + strconv__Float64u f = _t1; | |
| 5886 | + f64 sign = ((f64)(1.0)); | |
| 5887 | + int i = 0; | |
| 5888 | + for (;;) { | |
| 5889 | + if (!(i < s.len && s.str[ i] == ' ')) break; | |
| 5890 | + i++; | |
| 5891 | + } | |
| 5892 | + if (i < s.len) { | |
| 5893 | + if (s.str[ i] == '-') { | |
| 5894 | + sign = -1.0; | |
| 5895 | + i++; | |
| 5896 | + } else if (s.str[ i] == '+') { | |
| 5897 | + i++; | |
| 5898 | + } | |
| 5899 | + } | |
| 5900 | + if (s.str[ i] == 'i' && i + 2 < s.len && s.str[ i + 1] == 'n' && s.str[ i + 2] == 'f') { | |
| 5901 | + if (sign > ((f64)(0.0))) { | |
| 5902 | + f.u = _const_strconv__double_plus_infinity; | |
| 5903 | + } else { | |
| 5904 | + f.u = _const_strconv__double_minus_infinity; | |
| 5905 | + } | |
| 5906 | + return f.f; | |
| 5907 | + } | |
| 5908 | + for (;;) { | |
| 5909 | + if (!(i < s.len && s.str[ i] == '0')) break; | |
| 5910 | + i++; | |
| 5911 | + if (i >= s.len) { | |
| 5912 | + if (sign > ((f64)(0.0))) { | |
| 5913 | + f.u = _const_strconv__double_plus_zero; | |
| 5914 | + } else { | |
| 5915 | + f.u = _const_strconv__double_minus_zero; | |
| 5916 | + } | |
| 5917 | + return f.f; | |
| 5918 | + } | |
| 5919 | + } | |
| 5920 | + for (;;) { | |
| 5921 | + if (!(i < s.len && (s.str[ i] >= '0' && s.str[ i] <= '9'))) break; | |
| 5922 | + f.f *= ((f64)(10.0)); | |
| 5923 | + f.f += ((f64)((rune)(s.str[ i] - '0'))); | |
| 5924 | + i++; | |
| 5925 | + } | |
| 5926 | + if (i < s.len && s.str[ i] == '.') { | |
| 5927 | + i++; | |
| 5928 | + f64 frac_mul = ((f64)(0.1)); | |
| 5929 | + for (;;) { | |
| 5930 | + if (!(i < s.len && (s.str[ i] >= '0' && s.str[ i] <= '9'))) break; | |
| 5931 | + f.f += ((f64)((rune)(s.str[ i] - '0'))) * frac_mul; | |
| 5932 | + frac_mul *= ((f64)(0.1)); | |
| 5933 | + i++; | |
| 5934 | + } | |
| 5935 | + } | |
| 5936 | + if (i < s.len && (s.str[ i] == 'e' || s.str[ i] == 'E')) { | |
| 5937 | + i++; | |
| 5938 | + int exp = 0; | |
| 5939 | + int exp_sign = 1; | |
| 5940 | + if (i < s.len) { | |
| 5941 | + if (s.str[ i] == '-') { | |
| 5942 | + exp_sign = -1; | |
| 5943 | + i++; | |
| 5944 | + } else if (s.str[ i] == '+') { | |
| 5945 | + i++; | |
| 5946 | + } | |
| 5947 | + } | |
| 5948 | + for (;;) { | |
| 5949 | + if (!(i < s.len && s.str[ i] == '0')) break; | |
| 5950 | + i++; | |
| 5951 | + } | |
| 5952 | + for (;;) { | |
| 5953 | + if (!(i < s.len && (s.str[ i] >= '0' && s.str[ i] <= '9'))) break; | |
| 5954 | + exp *= 10; | |
| 5955 | + exp += ((int)((rune)(s.str[ i] - '0'))); | |
| 5956 | + i++; | |
| 5957 | + } | |
| 5958 | + if (exp_sign == 1) { | |
| 5959 | + if (exp > 309) { | |
| 5960 | + if (sign > 0) { | |
| 5961 | + f.u = _const_strconv__double_plus_infinity; | |
| 5962 | + } else { | |
| 5963 | + f.u = _const_strconv__double_minus_infinity; | |
| 5964 | + } | |
| 5965 | + return f.f; | |
| 5966 | + } | |
| 5967 | + strconv__Float64u _t5 = ((strconv__Float64u){.u = _const_strconv__pos_exp[exp],}); | |
| 5968 | + strconv__Float64u tmp_mul = _t5; | |
| 5969 | + f.f = f.f * tmp_mul.f; | |
| 5970 | + } else { | |
| 5971 | + if (exp > 324) { | |
| 5972 | + if (sign > 0) { | |
| 5973 | + f.u = _const_strconv__double_plus_zero; | |
| 5974 | + } else { | |
| 5975 | + f.u = _const_strconv__double_minus_zero; | |
| 5976 | + } | |
| 5977 | + return f.f; | |
| 5978 | + } | |
| 5979 | + strconv__Float64u _t7 = ((strconv__Float64u){.u = _const_strconv__neg_exp[exp],}); | |
| 5980 | + strconv__Float64u tmp_mul = _t7; | |
| 5981 | + f.f = f.f * tmp_mul.f; | |
| 5982 | + } | |
| 5983 | + } | |
| 5984 | + { // Unsafe block | |
| 5985 | + f.f = f.f * sign; | |
| 5986 | + return f.f; | |
| 5987 | + } | |
| 5988 | + return 0; | |
| 5989 | +} | |
| 5990 | +inline u8 strconv__byte_to_lower(u8 c) { | |
| 5991 | + return (c | 32); | |
| 5992 | +} | |
| 5993 | +_result_u64 strconv__common_parse_uint(string s, int _base, int _bit_size, bool error_on_non_digit, bool error_on_high_digit) { | |
| 5994 | + multi_return_u64_int mr_730 = strconv__common_parse_uint2(s, _base, _bit_size); | |
| 5995 | + u64 result = mr_730.arg0; | |
| 5996 | + int err = mr_730.arg1; | |
| 5997 | + if (err != 0 && (error_on_non_digit || error_on_high_digit)) { | |
| 5998 | + switch (err) { | |
| 5999 | + case -1: { | |
| 6000 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(4, _MOV((string[4]){_S("common_parse_uint: wrong base "), builtin__int_str(_base), _S(" for "), s}))), .data={E_STRUCT} }; | |
| 6001 | + } | |
| 6002 | + case -2: { | |
| 6003 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(4, _MOV((string[4]){_S("common_parse_uint: wrong bit size "), builtin__int_str(_bit_size), _S(" for "), s}))), .data={E_STRUCT} }; | |
| 6004 | + } | |
| 6005 | + case -3: { | |
| 6006 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(2, _MOV((string[2]){_S("common_parse_uint: integer overflow "), s}))), .data={E_STRUCT} }; | |
| 6007 | + } | |
| 6008 | + default: { | |
| 6009 | + { | |
| 6010 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(2, _MOV((string[2]){_S("common_parse_uint: syntax error "), s}))), .data={E_STRUCT} }; | |
| 6011 | + } | |
| 6012 | + } | |
| 6013 | + } | |
| 6014 | + | |
| 6015 | + } | |
| 6016 | + _result_u64 _t5; | |
| 6017 | + builtin___result_ok(&(u64[]) { result }, (_result*)(&_t5), sizeof(u64)); | |
| 6018 | + | |
| 6019 | + return _t5; | |
| 6020 | +} | |
| 6021 | +multi_return_u64_int strconv__common_parse_uint2(string s, int _base, int _bit_size) { | |
| 6022 | + if ((s).len == 0) { | |
| 6023 | + return (multi_return_u64_int){.arg0=((u64)(0)), .arg1=1}; | |
| 6024 | + } | |
| 6025 | + int bit_size = _bit_size; | |
| 6026 | + int base = _base; | |
| 6027 | + int start_index = 0; | |
| 6028 | + if (base == 0) { | |
| 6029 | + base = 10; | |
| 6030 | + if (s.str[ 0] == '0') { | |
| 6031 | + u8 ch = (s.len > 1 ? ((s.str[ 1] | 32)) : ('0')); | |
| 6032 | + if (s.len >= 3) { | |
| 6033 | + if (ch == 'b') { | |
| 6034 | + base = 2; | |
| 6035 | + start_index += 2; | |
| 6036 | + } else if (ch == 'o') { | |
| 6037 | + base = 8; | |
| 6038 | + start_index += 2; | |
| 6039 | + } else if (ch == 'x') { | |
| 6040 | + base = 16; | |
| 6041 | + start_index += 2; | |
| 6042 | + } | |
| 6043 | + if (s.str[ start_index] == '_') { | |
| 6044 | + start_index++; | |
| 6045 | + } | |
| 6046 | + } else if (s.len >= 2 && (s.str[ 1] >= '0' && s.str[ 1] <= '9')) { | |
| 6047 | + base = 10; | |
| 6048 | + start_index++; | |
| 6049 | + } else { | |
| 6050 | + base = 8; | |
| 6051 | + start_index++; | |
| 6052 | + } | |
| 6053 | + } | |
| 6054 | + } | |
| 6055 | + if (bit_size == 0) { | |
| 6056 | + bit_size = _const_strconv__int_size; | |
| 6057 | + } else if (bit_size < 0 || bit_size > 64) { | |
| 6058 | + return (multi_return_u64_int){.arg0=((u64)(0)), .arg1=-2}; | |
| 6059 | + } | |
| 6060 | + u64 cutoff = VSAFE_DIV_u64(_const_max_u64 , ((u64)(base))) + ((u64)(1)); | |
| 6061 | + u64 max_val = (bit_size == 64 ? (_const_max_u64) : ((v__lshift_u64(((u64)(1)), (u64)((u64)(bit_size)))) - ((u64)(1)))); | |
| 6062 | + int basem1 = base - 1; | |
| 6063 | + u64 n = ((u64)(0)); | |
| 6064 | + for (int i = start_index; i < s.len; ++i) { | |
| 6065 | + u8 c = s.str[ i]; | |
| 6066 | + if (c == '_') { | |
| 6067 | + if (i == start_index || i >= (s.len - 1)) { | |
| 6068 | + return (multi_return_u64_int){.arg0=((u64)(0)), .arg1=1}; | |
| 6069 | + } | |
| 6070 | + if (s.str[ i - 1] == '_' || s.str[ i + 1] == '_') { | |
| 6071 | + return (multi_return_u64_int){.arg0=((u64)(0)), .arg1=1}; | |
| 6072 | + } | |
| 6073 | + continue; | |
| 6074 | + } | |
| 6075 | + int sub_count = 0; | |
| 6076 | + c -= 48; | |
| 6077 | + if (c >= 17) { | |
| 6078 | + sub_count++; | |
| 6079 | + c -= 7; | |
| 6080 | + if (c >= 42) { | |
| 6081 | + sub_count++; | |
| 6082 | + c -= 32; | |
| 6083 | + } | |
| 6084 | + } | |
| 6085 | + if (c > basem1 || (sub_count == 0 && c > 9)) { | |
| 6086 | + return (multi_return_u64_int){.arg0=n, .arg1=i + 1}; | |
| 6087 | + } | |
| 6088 | + if (n >= cutoff) { | |
| 6089 | + return (multi_return_u64_int){.arg0=max_val, .arg1=-3}; | |
| 6090 | + } | |
| 6091 | + n *= ((u64)(base)); | |
| 6092 | + u64 n1 = n + ((u64)(c)); | |
| 6093 | + if (n1 < n || n1 > max_val) { | |
| 6094 | + return (multi_return_u64_int){.arg0=max_val, .arg1=-3}; | |
| 6095 | + } | |
| 6096 | + n = n1; | |
| 6097 | + } | |
| 6098 | + return (multi_return_u64_int){.arg0=n, .arg1=0}; | |
| 6099 | +} | |
| 6100 | +_result_u64 strconv__parse_uint(string s, int _base, int _bit_size) { | |
| 6101 | + return strconv__common_parse_uint(s, _base, _bit_size, true, true); | |
| 6102 | +} | |
| 6103 | +_result_i64 strconv__common_parse_int(string _s, int base, int _bit_size, bool error_on_non_digit, bool error_on_high_digit) { | |
| 6104 | + if ((_s).len == 0) { | |
| 6105 | + _result_i64 _t1; | |
| 6106 | + builtin___result_ok(&(i64[]) { ((i64)(0)) }, (_result*)(&_t1), sizeof(i64)); | |
| 6107 | + | |
| 6108 | + return _t1; | |
| 6109 | + } | |
| 6110 | + int bit_size = _bit_size; | |
| 6111 | + if (bit_size == 0) { | |
| 6112 | + bit_size = _const_strconv__int_size; | |
| 6113 | + } | |
| 6114 | + string s = _s; | |
| 6115 | + bool neg = false; | |
| 6116 | + if (s.str[ 0] == '+') { | |
| 6117 | + { // Unsafe block | |
| 6118 | + s = builtin__tos(s.str + 1, s.len - 1); | |
| 6119 | + } | |
| 6120 | + } else if (s.str[ 0] == '-') { | |
| 6121 | + neg = true; | |
| 6122 | + { // Unsafe block | |
| 6123 | + s = builtin__tos(s.str + 1, s.len - 1); | |
| 6124 | + } | |
| 6125 | + } | |
| 6126 | + _result_u64 _t2 = strconv__common_parse_uint(s, base, bit_size, error_on_non_digit, error_on_high_digit); | |
| 6127 | + if (_t2.is_error) { | |
| 6128 | + _result_i64 _t3 = {0}; | |
| 6129 | + _t3.is_error = true; | |
| 6130 | + _t3.err = _t2.err; | |
| 6131 | + return _t3; | |
| 6132 | + } | |
| 6133 | + | |
| 6134 | + u64 un = (*(u64*)_t2.data); | |
| 6135 | + if (un == 0) { | |
| 6136 | + _result_i64 _t4; | |
| 6137 | + builtin___result_ok(&(i64[]) { ((i64)(0)) }, (_result*)(&_t4), sizeof(i64)); | |
| 6138 | + | |
| 6139 | + return _t4; | |
| 6140 | + } | |
| 6141 | + u64 cutoff = v__lshift_u64(((u64)(1)), (u64)((u64)(bit_size - 1))); | |
| 6142 | + if (!neg && un >= cutoff) { | |
| 6143 | + if (error_on_high_digit) { | |
| 6144 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(2, _MOV((string[2]){_S("common_parse_int: integer overflow "), _s}))), .data={E_STRUCT} }; | |
| 6145 | + } | |
| 6146 | + _result_i64 _t6; | |
| 6147 | + builtin___result_ok(&(i64[]) { ((i64)(cutoff - ((u64)(1)))) }, (_result*)(&_t6), sizeof(i64)); | |
| 6148 | + | |
| 6149 | + return _t6; | |
| 6150 | + } | |
| 6151 | + if (neg && un > cutoff) { | |
| 6152 | + if (error_on_high_digit) { | |
| 6153 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(2, _MOV((string[2]){_S("common_parse_int: integer overflow "), _s}))), .data={E_STRUCT} }; | |
| 6154 | + } | |
| 6155 | + _result_i64 _t8; | |
| 6156 | + builtin___result_ok(&(i64[]) { -((i64)(cutoff)) }, (_result*)(&_t8), sizeof(i64)); | |
| 6157 | + | |
| 6158 | + return _t8; | |
| 6159 | + } | |
| 6160 | + _result_i64 _t10; /* if prepend */ | |
| 6161 | + if (neg) { | |
| 6162 | + builtin___result_ok(&(i64[]) { -((i64)(un)) }, (_result*)(&_t10), sizeof(i64)); | |
| 6163 | + goto _t11; | |
| 6164 | + }; | |
| 6165 | + { | |
| 6166 | + builtin___result_ok(&(i64[]) { ((i64)(un)) }, (_result*)(&_t10), sizeof(i64)); | |
| 6167 | + } | |
| 6168 | + _t11: {}; | |
| 6169 | + return _t10; | |
| 6170 | +} | |
| 6171 | +_result_i64 strconv__parse_int(string _s, int base, int _bit_size) { | |
| 6172 | + return strconv__common_parse_int(_s, base, _bit_size, true, false); | |
| 6173 | +} | |
| 6174 | +VV_LOC _result_multi_return_i64_int strconv__atoi_common_check(string s) { | |
| 6175 | + if ((s).len == 0) { | |
| 6176 | + return (_result_multi_return_i64_int){ .is_error=true, .err=builtin___v_error(_S("strconv.atoi: parsing \"\": empty string")), .data={E_STRUCT} }; | |
| 6177 | + } | |
| 6178 | + int start_idx = 0; | |
| 6179 | + i64 sign = ((i64)(1)); | |
| 6180 | + if (s.str[ 0] == '-' || s.str[ 0] == '+') { | |
| 6181 | + start_idx++; | |
| 6182 | + if (s.str[ 0] == '-') { | |
| 6183 | + sign = -1; | |
| 6184 | + } | |
| 6185 | + } | |
| 6186 | + if (s.len - start_idx < 1) { | |
| 6187 | + return (_result_multi_return_i64_int){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi: parsing \""), s, _S("\": no number after sign")}))), .data={E_STRUCT} }; | |
| 6188 | + } | |
| 6189 | + if (s.str[ start_idx] == '_' || s.str[ s.len - 1] == '_') { | |
| 6190 | + return (_result_multi_return_i64_int){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi: parsing \""), s, _S("\": values cannot start or end with underscores")}))), .data={E_STRUCT} }; | |
| 6191 | + } | |
| 6192 | + _result_multi_return_i64_int _t4; | |
| 6193 | + builtin___result_ok(&(multi_return_i64_int[]) { (multi_return_i64_int){.arg0=sign, .arg1=start_idx} }, (_result*)(&_t4), sizeof(multi_return_i64_int)); | |
| 6194 | + return _t4; | |
| 6195 | +} | |
| 6196 | +VV_LOC _result_i64 strconv__atoi_common(string s, i64 type_min, i64 type_max) { | |
| 6197 | + _result_multi_return_i64_int _t1 = strconv__atoi_common_check(s); | |
| 6198 | + if (_t1.is_error) { | |
| 6199 | + _result_i64 _t2 = {0}; | |
| 6200 | + _t2.is_error = true; | |
| 6201 | + _t2.err = _t1.err; | |
| 6202 | + return _t2; | |
| 6203 | + } | |
| 6204 | + | |
| 6205 | + multi_return_i64_int mr_7450 = (*(multi_return_i64_int*)_t1.data); | |
| 6206 | + i64 sign = mr_7450.arg0; | |
| 6207 | + int start_idx = mr_7450.arg1; | |
| 6208 | + i64 x = ((i64)(0)); | |
| 6209 | + bool underscored = false; | |
| 6210 | + for (int i = start_idx; i < s.len; ++i) { | |
| 6211 | + rune c = (rune)(s.str[ i] - '0'); | |
| 6212 | + if (c == 47) { | |
| 6213 | + if (underscored == true) { | |
| 6214 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi: parsing \""), s, _S("\": consecutives underscores are not allowed")}))), .data={E_STRUCT} }; | |
| 6215 | + } | |
| 6216 | + underscored = true; | |
| 6217 | + continue; | |
| 6218 | + } else { | |
| 6219 | + if (c > 9) { | |
| 6220 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi: parsing \""), s, _S("\": invalid radix 10 character")}))), .data={E_STRUCT} }; | |
| 6221 | + } | |
| 6222 | + underscored = false; | |
| 6223 | + x = (x * 10) + ((i64)(c * sign)); | |
| 6224 | + if (sign == 1 && x > type_max) { | |
| 6225 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi: parsing \""), s, _S("\": integer overflow")}))), .data={E_STRUCT} }; | |
| 6226 | + } else { | |
| 6227 | + if (x < type_min) { | |
| 6228 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi: parsing \""), s, _S("\": integer underflow")}))), .data={E_STRUCT} }; | |
| 6229 | + } | |
| 6230 | + } | |
| 6231 | + } | |
| 6232 | + } | |
| 6233 | + _result_i64 _t7; | |
| 6234 | + builtin___result_ok(&(i64[]) { x }, (_result*)(&_t7), sizeof(i64)); | |
| 6235 | + | |
| 6236 | + return _t7; | |
| 6237 | +} | |
| 6238 | +_result_int strconv__atoi(string s) { | |
| 6239 | + _result_i64 _t2 = strconv__atoi_common(s, _const_strconv__i64_min_int32, _const_strconv__i64_max_int32); | |
| 6240 | + if (_t2.is_error) { | |
| 6241 | + _result_int _t3 = {0}; | |
| 6242 | + _t3.is_error = true; | |
| 6243 | + _t3.err = _t2.err; | |
| 6244 | + return _t3; | |
| 6245 | + } | |
| 6246 | + | |
| 6247 | + _result_int _t1; | |
| 6248 | + builtin___result_ok(&(int[]) { ((int)((*(i64*)_t2.data))) }, (_result*)(&_t1), sizeof(int)); | |
| 6249 | + | |
| 6250 | + return _t1; | |
| 6251 | +} | |
| 6252 | +_result_i8 strconv__atoi8(string s) { | |
| 6253 | + _result_i64 _t2 = strconv__atoi_common(s, _const_min_i8, _const_max_i8); | |
| 6254 | + if (_t2.is_error) { | |
| 6255 | + _result_i8 _t3 = {0}; | |
| 6256 | + _t3.is_error = true; | |
| 6257 | + _t3.err = _t2.err; | |
| 6258 | + return _t3; | |
| 6259 | + } | |
| 6260 | + | |
| 6261 | + _result_i8 _t1; | |
| 6262 | + builtin___result_ok(&(i8[]) { ((i8)((*(i64*)_t2.data))) }, (_result*)(&_t1), sizeof(i8)); | |
| 6263 | + | |
| 6264 | + return _t1; | |
| 6265 | +} | |
| 6266 | +_result_i16 strconv__atoi16(string s) { | |
| 6267 | + _result_i64 _t2 = strconv__atoi_common(s, _const_min_i16, _const_max_i16); | |
| 6268 | + if (_t2.is_error) { | |
| 6269 | + _result_i16 _t3 = {0}; | |
| 6270 | + _t3.is_error = true; | |
| 6271 | + _t3.err = _t2.err; | |
| 6272 | + return _t3; | |
| 6273 | + } | |
| 6274 | + | |
| 6275 | + _result_i16 _t1; | |
| 6276 | + builtin___result_ok(&(i16[]) { ((i16)((*(i64*)_t2.data))) }, (_result*)(&_t1), sizeof(i16)); | |
| 6277 | + | |
| 6278 | + return _t1; | |
| 6279 | +} | |
| 6280 | +_result_i32 strconv__atoi32(string s) { | |
| 6281 | + _result_i64 _t2 = strconv__atoi_common(s, _const_min_i32, _const_max_i32); | |
| 6282 | + if (_t2.is_error) { | |
| 6283 | + _result_i32 _t3 = {0}; | |
| 6284 | + _t3.is_error = true; | |
| 6285 | + _t3.err = _t2.err; | |
| 6286 | + return _t3; | |
| 6287 | + } | |
| 6288 | + | |
| 6289 | + _result_i32 _t1; | |
| 6290 | + builtin___result_ok(&(i32[]) { ((i32)((*(i64*)_t2.data))) }, (_result*)(&_t1), sizeof(i32)); | |
| 6291 | + | |
| 6292 | + return _t1; | |
| 6293 | +} | |
| 6294 | +_result_i64 strconv__atoi64(string s) { | |
| 6295 | + _result_multi_return_i64_int _t1 = strconv__atoi_common_check(s); | |
| 6296 | + if (_t1.is_error) { | |
| 6297 | + _result_i64 _t2 = {0}; | |
| 6298 | + _t2.is_error = true; | |
| 6299 | + _t2.err = _t1.err; | |
| 6300 | + return _t2; | |
| 6301 | + } | |
| 6302 | + | |
| 6303 | + multi_return_i64_int mr_9202 = (*(multi_return_i64_int*)_t1.data); | |
| 6304 | + i64 sign = mr_9202.arg0; | |
| 6305 | + int start_idx = mr_9202.arg1; | |
| 6306 | + i64 x = ((i64)(0)); | |
| 6307 | + bool underscored = false; | |
| 6308 | + for (int i = start_idx; i < s.len; ++i) { | |
| 6309 | + rune c = (rune)(s.str[ i] - '0'); | |
| 6310 | + if (c == 47) { | |
| 6311 | + if (underscored == true) { | |
| 6312 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi64: parsing \""), s, _S("\": consecutives underscores are not allowed")}))), .data={E_STRUCT} }; | |
| 6313 | + } | |
| 6314 | + underscored = true; | |
| 6315 | + continue; | |
| 6316 | + } else { | |
| 6317 | + if (c > 9) { | |
| 6318 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi64: parsing \""), s, _S("\": invalid radix 10 character")}))), .data={E_STRUCT} }; | |
| 6319 | + } | |
| 6320 | + underscored = false; | |
| 6321 | + _result_i64 _t5 = strconv__safe_mul10_64bits(x); | |
| 6322 | + if (_t5.is_error) { | |
| 6323 | + IError _t6 = _t5.err; | |
| 6324 | + IError err = _t6; | |
| 6325 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__str_intp(3, _MOV((StrIntpData[]){{_S("strconv.atoi64: parsing \""), 0xfe10, {.d_s = s}, 0, 0, 0}, {_S("\": "), 0xfe10, {.d_s = builtin__IError_str(err)}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}))), .data={E_STRUCT} }; | |
| 6326 | + } | |
| 6327 | + | |
| 6328 | + x = (*(i64*)_t5.data); | |
| 6329 | + _result_i64 _t8 = strconv__safe_add_64bits(x, ((int)((i64)(c * sign)))); | |
| 6330 | + if (_t8.is_error) { | |
| 6331 | + IError _t9 = _t8.err; | |
| 6332 | + IError err = _t9; | |
| 6333 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__str_intp(3, _MOV((StrIntpData[]){{_S("strconv.atoi64: parsing \""), 0xfe10, {.d_s = s}, 0, 0, 0}, {_S("\": "), 0xfe10, {.d_s = builtin__IError_str(err)}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}))), .data={E_STRUCT} }; | |
| 6334 | + } | |
| 6335 | + | |
| 6336 | + x = (*(i64*)_t8.data); | |
| 6337 | + } | |
| 6338 | + } | |
| 6339 | + _result_i64 _t11; | |
| 6340 | + builtin___result_ok(&(i64[]) { x }, (_result*)(&_t11), sizeof(i64)); | |
| 6341 | + | |
| 6342 | + return _t11; | |
| 6343 | +} | |
| 6344 | +inline VV_LOC _result_i64 strconv__safe_add_64bits(i64 a, i64 b) { | |
| 6345 | + if (a > 0 && b > (_const_max_i64 - a)) { | |
| 6346 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(_S("integer overflow")), .data={E_STRUCT} }; | |
| 6347 | + } else if (a < 0 && b < (_const_min_i64 - a)) { | |
| 6348 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(_S("integer underflow")), .data={E_STRUCT} }; | |
| 6349 | + } | |
| 6350 | + _result_i64 _t3; | |
| 6351 | + builtin___result_ok(&(i64[]) { a + b }, (_result*)(&_t3), sizeof(i64)); | |
| 6352 | + | |
| 6353 | + return _t3; | |
| 6354 | +} | |
| 6355 | +inline VV_LOC _result_i64 strconv__safe_mul10_64bits(i64 a) { | |
| 6356 | + if (a > 0 && a > (VSAFE_DIV_i64(_const_max_i64 , 10))) { | |
| 6357 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(_S("integer overflow")), .data={E_STRUCT} }; | |
| 6358 | + } | |
| 6359 | + if (a < 0 && a < (VSAFE_DIV_i64(_const_min_i64 , 10))) { | |
| 6360 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(_S("integer underflow")), .data={E_STRUCT} }; | |
| 6361 | + } | |
| 6362 | + _result_i64 _t3; | |
| 6363 | + builtin___result_ok(&(i64[]) { a * 10 }, (_result*)(&_t3), sizeof(i64)); | |
| 6364 | + | |
| 6365 | + return _t3; | |
| 6366 | +} | |
| 6367 | +VV_LOC _result_int strconv__atou_common_check(string s) { | |
| 6368 | + if ((s).len == 0) { | |
| 6369 | + return (_result_int){ .is_error=true, .err=builtin___v_error(_S("strconv.atou: parsing \"\": empty string")), .data={E_STRUCT} }; | |
| 6370 | + } | |
| 6371 | + int start_idx = 0; | |
| 6372 | + if (s.str[ 0] == '-') { | |
| 6373 | + return (_result_int){ .is_error=true, .err=builtin___v_error(_S("strconv.atou: parsing \"{s}\" : negative value")), .data={E_STRUCT} }; | |
| 6374 | + } | |
| 6375 | + if (s.str[ 0] == '+') { | |
| 6376 | + start_idx++; | |
| 6377 | + } | |
| 6378 | + if (s.len - start_idx < 1) { | |
| 6379 | + return (_result_int){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atou: parsing \""), s, _S("\": no number after sign")}))), .data={E_STRUCT} }; | |
| 6380 | + } | |
| 6381 | + if (s.str[ start_idx] == '_' || s.str[ s.len - 1] == '_') { | |
| 6382 | + return (_result_int){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atou: parsing \""), s, _S("\": values cannot start or end with underscores")}))), .data={E_STRUCT} }; | |
| 6383 | + } | |
| 6384 | + _result_int _t5; | |
| 6385 | + builtin___result_ok(&(int[]) { start_idx }, (_result*)(&_t5), sizeof(int)); | |
| 6386 | + | |
| 6387 | + return _t5; | |
| 6388 | +} | |
| 6389 | +VV_LOC _result_u64 strconv__atou_common(string s, u64 type_max) { | |
| 6390 | + _result_int _t1 = strconv__atou_common_check(s); | |
| 6391 | + if (_t1.is_error) { | |
| 6392 | + _result_u64 _t2 = {0}; | |
| 6393 | + _t2.is_error = true; | |
| 6394 | + _t2.err = _t1.err; | |
| 6395 | + return _t2; | |
| 6396 | + } | |
| 6397 | + | |
| 6398 | + int start_idx = ((int)((*(int*)_t1.data))); | |
| 6399 | + u64 x = ((u64)(0)); | |
| 6400 | + bool underscored = false; | |
| 6401 | + for (int i = start_idx; i < s.len; ++i) { | |
| 6402 | + rune c = (rune)(s.str[ i] - '0'); | |
| 6403 | + if (c == 47) { | |
| 6404 | + if (underscored == true) { | |
| 6405 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atou: parsing \""), s, _S("\": consecutives underscores are not allowed")}))), .data={E_STRUCT} }; | |
| 6406 | + } | |
| 6407 | + underscored = true; | |
| 6408 | + continue; | |
| 6409 | + } else { | |
| 6410 | + if (c > 9) { | |
| 6411 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atou: parsing \""), s, _S("\": invalid radix 10 character")}))), .data={E_STRUCT} }; | |
| 6412 | + } | |
| 6413 | + underscored = false; | |
| 6414 | + if (x > VSAFE_DIV_u64(type_max , 10)) { | |
| 6415 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atou: parsing \""), s, _S("\": integer overflow")}))), .data={E_STRUCT} }; | |
| 6416 | + } | |
| 6417 | + x *= 10; | |
| 6418 | + if (x > type_max - ((u64)(c))) { | |
| 6419 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atou: parsing \""), s, _S("\": integer overflow")}))), .data={E_STRUCT} }; | |
| 6420 | + } | |
| 6421 | + x += ((u64)(c)); | |
| 6422 | + } | |
| 6423 | + } | |
| 6424 | + _result_u64 _t7; | |
| 6425 | + builtin___result_ok(&(u64[]) { x }, (_result*)(&_t7), sizeof(u64)); | |
| 6426 | + | |
| 6427 | + return _t7; | |
| 6428 | +} | |
| 6429 | +_result_u8 strconv__atou8(string s) { | |
| 6430 | + _result_u64 _t2 = strconv__atou_common(s, _const_max_u8); | |
| 6431 | + if (_t2.is_error) { | |
| 6432 | + _result_u8 _t3 = {0}; | |
| 6433 | + _t3.is_error = true; | |
| 6434 | + _t3.err = _t2.err; | |
| 6435 | + return _t3; | |
| 6436 | + } | |
| 6437 | + | |
| 6438 | + _result_u8 _t1; | |
| 6439 | + builtin___result_ok(&(u8[]) { ((u8)((*(u64*)_t2.data))) }, (_result*)(&_t1), sizeof(u8)); | |
| 6440 | + | |
| 6441 | + return _t1; | |
| 6442 | +} | |
| 6443 | +_result_u16 strconv__atou16(string s) { | |
| 6444 | + _result_u64 _t2 = strconv__atou_common(s, _const_max_u16); | |
| 6445 | + if (_t2.is_error) { | |
| 6446 | + _result_u16 _t3 = {0}; | |
| 6447 | + _t3.is_error = true; | |
| 6448 | + _t3.err = _t2.err; | |
| 6449 | + return _t3; | |
| 6450 | + } | |
| 6451 | + | |
| 6452 | + _result_u16 _t1; | |
| 6453 | + builtin___result_ok(&(u16[]) { ((u16)((*(u64*)_t2.data))) }, (_result*)(&_t1), sizeof(u16)); | |
| 6454 | + | |
| 6455 | + return _t1; | |
| 6456 | +} | |
| 6457 | +_result_u32 strconv__atou(string s) { | |
| 6458 | + _result_u64 _t2 = strconv__atou_common(s, _const_max_u32); | |
| 6459 | + if (_t2.is_error) { | |
| 6460 | + _result_u32 _t3 = {0}; | |
| 6461 | + _t3.is_error = true; | |
| 6462 | + _t3.err = _t2.err; | |
| 6463 | + return _t3; | |
| 6464 | + } | |
| 6465 | + | |
| 6466 | + _result_u32 _t1; | |
| 6467 | + builtin___result_ok(&(u32[]) { ((u32)((*(u64*)_t2.data))) }, (_result*)(&_t1), sizeof(u32)); | |
| 6468 | + | |
| 6469 | + return _t1; | |
| 6470 | +} | |
| 6471 | +_result_u32 strconv__atou32(string s) { | |
| 6472 | + _result_u64 _t2 = strconv__atou_common(s, _const_max_u32); | |
| 6473 | + if (_t2.is_error) { | |
| 6474 | + _result_u32 _t3 = {0}; | |
| 6475 | + _t3.is_error = true; | |
| 6476 | + _t3.err = _t2.err; | |
| 6477 | + return _t3; | |
| 6478 | + } | |
| 6479 | + | |
| 6480 | + _result_u32 _t1; | |
| 6481 | + builtin___result_ok(&(u32[]) { ((u32)((*(u64*)_t2.data))) }, (_result*)(&_t1), sizeof(u32)); | |
| 6482 | + | |
| 6483 | + return _t1; | |
| 6484 | +} | |
| 6485 | +_result_u64 strconv__atou64(string s) { | |
| 6486 | + _result_u64 _t2 = strconv__atou_common(s, _const_max_u64); | |
| 6487 | + if (_t2.is_error) { | |
| 6488 | + _result_u64 _t3 = {0}; | |
| 6489 | + _t3.is_error = true; | |
| 6490 | + _t3.err = _t2.err; | |
| 6491 | + return _t3; | |
| 6492 | + } | |
| 6493 | + | |
| 6494 | + _result_u64 _t1; | |
| 6495 | + builtin___result_ok(&(u64[]) { ((u64)((*(u64*)_t2.data))) }, (_result*)(&_t1), sizeof(u64)); | |
| 6496 | + | |
| 6497 | + return _t1; | |
| 6498 | +} | |
| 6499 | +string strconv__Dec32_get_string_32(strconv__Dec32 d, bool neg, int i_n_digit, int i_pad_digit) { | |
| 6500 | + int n_digit = i_n_digit + 1; | |
| 6501 | + int pad_digit = i_pad_digit + 1; | |
| 6502 | + u32 out = d.m; | |
| 6503 | + int out_len = strconv__dec_digits(out); | |
| 6504 | + int out_len_original = out_len; | |
| 6505 | + int fw_zeros = 0; | |
| 6506 | + if (pad_digit > out_len) { | |
| 6507 | + fw_zeros = pad_digit - out_len; | |
| 6508 | + } | |
| 6509 | + Array_u8 buf = builtin____new_array_with_default(((int)(out_len + 5 + 1 + 1)), 0, sizeof(u8), 0); | |
| 6510 | + int i = 0; | |
| 6511 | + if (neg) { | |
| 6512 | + if (buf.data != 0) { | |
| 6513 | + ((u8*)buf.data)[i] = '-'; | |
| 6514 | + } | |
| 6515 | + i++; | |
| 6516 | + } | |
| 6517 | + int disp = 0; | |
| 6518 | + if (out_len <= 1) { | |
| 6519 | + disp = 1; | |
| 6520 | + } | |
| 6521 | + if (n_digit < out_len) { | |
| 6522 | + out += _const_strconv__ten_pow_table_32[out_len - n_digit - 1] * 5; | |
| 6523 | + out = VSAFE_DIV_u32(out,_const_strconv__ten_pow_table_32[out_len - n_digit]); | |
| 6524 | + out_len = n_digit; | |
| 6525 | + } | |
| 6526 | + int y = i + out_len; | |
| 6527 | + int x = 0; | |
| 6528 | + for (;;) { | |
| 6529 | + if (!(x < (out_len - disp - 1))) break; | |
| 6530 | + ((u8*)buf.data)[y - x] = (rune)('0' + ((u8)(VSAFE_MOD_u32(out , 10)))); | |
| 6531 | + out = VSAFE_DIV_u32(out,10); | |
| 6532 | + i++; | |
| 6533 | + x++; | |
| 6534 | + } | |
| 6535 | + if (i_n_digit == 0) { | |
| 6536 | + { // Unsafe block | |
| 6537 | + ((u8*)buf.data)[i] = 0; | |
| 6538 | + return builtin__tos(builtin__memdup(&((u8*)buf.data)[0], i + 1), i); | |
| 6539 | + } | |
| 6540 | + } | |
| 6541 | + if (out_len > 1 || fw_zeros > 0) { | |
| 6542 | + ((u8*)buf.data)[y - x] = '.'; | |
| 6543 | + i++; | |
| 6544 | + } | |
| 6545 | + x++; | |
| 6546 | + if (y - x >= 0) { | |
| 6547 | + ((u8*)buf.data)[y - x] = (rune)('0' + ((u8)(VSAFE_MOD_u32(out , 10)))); | |
| 6548 | + i++; | |
| 6549 | + } | |
| 6550 | + for (;;) { | |
| 6551 | + if (!(fw_zeros > 0)) break; | |
| 6552 | + ((u8*)buf.data)[i] = '0'; | |
| 6553 | + i++; | |
| 6554 | + fw_zeros--; | |
| 6555 | + } | |
| 6556 | + ((u8*)buf.data)[i] = 'e'; | |
| 6557 | + i++; | |
| 6558 | + int exp = d.e + out_len_original - 1; | |
| 6559 | + if (exp < 0) { | |
| 6560 | + ((u8*)buf.data)[i] = '-'; | |
| 6561 | + i++; | |
| 6562 | + exp = -exp; | |
| 6563 | + } else { | |
| 6564 | + ((u8*)buf.data)[i] = '+'; | |
| 6565 | + i++; | |
| 6566 | + } | |
| 6567 | + int d1 = VSAFE_MOD_int(exp , 10); | |
| 6568 | + int d0 = VSAFE_DIV_int(exp , 10); | |
| 6569 | + ((u8*)buf.data)[i] = (rune)('0' + ((u8)(d0))); | |
| 6570 | + i++; | |
| 6571 | + ((u8*)buf.data)[i] = (rune)('0' + ((u8)(d1))); | |
| 6572 | + i++; | |
| 6573 | + ((u8*)buf.data)[i] = 0; | |
| 6574 | + return builtin__tos(builtin__memdup(&((u8*)buf.data)[0], i + 1), i); | |
| 6575 | +} | |
| 6576 | +VV_LOC multi_return_strconv__Dec32_bool strconv__f32_to_decimal_exact_int(u32 i_mant, u32 exp) { | |
| 6577 | + strconv__Dec32 _t1 = ((strconv__Dec32){.m = 0,.e = 0,}); | |
| 6578 | + strconv__Dec32 d = _t1; | |
| 6579 | + u32 e = exp - 127; | |
| 6580 | + if (e > _const_strconv__mantbits32) { | |
| 6581 | + return (multi_return_strconv__Dec32_bool){.arg0=d, .arg1=false}; | |
| 6582 | + } | |
| 6583 | + u32 shift = _const_strconv__mantbits32 - e; | |
| 6584 | + u32 mant = (i_mant | 0x00800000); | |
| 6585 | + d.m = v__rshift_u32(mant, (u64)shift); | |
| 6586 | + if ((v__lshift_u32(d.m, (u64)shift)) != mant) { | |
| 6587 | + return (multi_return_strconv__Dec32_bool){.arg0=d, .arg1=false}; | |
| 6588 | + } | |
| 6589 | + for (;;) { | |
| 6590 | + if (!((VSAFE_MOD_u32(d.m , 10)) == 0)) break; | |
| 6591 | + d.m = VSAFE_DIV_u32(d.m,10); | |
| 6592 | + d.e++; | |
| 6593 | + } | |
| 6594 | + return (multi_return_strconv__Dec32_bool){.arg0=d, .arg1=true}; | |
| 6595 | +} | |
| 6596 | +VV_LOC strconv__Dec32 strconv__f32_to_decimal(u32 mant, u32 exp) { | |
| 6597 | + int e2 = 0; | |
| 6598 | + u32 m2 = ((u32)(0)); | |
| 6599 | + if (exp == 0) { | |
| 6600 | + e2 = -126 - ((int)(_const_strconv__mantbits32)) - 2; | |
| 6601 | + m2 = mant; | |
| 6602 | + } else { | |
| 6603 | + e2 = ((int)(exp)) - 127 - ((int)(_const_strconv__mantbits32)) - 2; | |
| 6604 | + m2 = ((v__lshift_u32(((u32)(1)), (u64)_const_strconv__mantbits32)) | mant); | |
| 6605 | + } | |
| 6606 | + bool even = ((m2 & 1)) == 0; | |
| 6607 | + bool accept_bounds = even; | |
| 6608 | + u32 mv = ((u32)(4 * m2)); | |
| 6609 | + u32 mp = ((u32)(4 * m2 + 2)); | |
| 6610 | + u32 mm_shift = strconv__bool_to_u32(mant != 0 || exp <= 1); | |
| 6611 | + u32 mm = ((u32)(4 * m2 - 1 - mm_shift)); | |
| 6612 | + u32 vr = ((u32)(0)); | |
| 6613 | + u32 vp = ((u32)(0)); | |
| 6614 | + u32 vm = ((u32)(0)); | |
| 6615 | + int e10 = 0; | |
| 6616 | + bool vm_is_trailing_zeros = false; | |
| 6617 | + bool vr_is_trailing_zeros = false; | |
| 6618 | + u8 last_removed_digit = ((u8)(0)); | |
| 6619 | + if (e2 >= 0) { | |
| 6620 | + u32 q = strconv__log10_pow2(e2); | |
| 6621 | + e10 = ((int)(q)); | |
| 6622 | + int k = 59 + strconv__pow5_bits(((int)(q))) - 1; | |
| 6623 | + int i = -e2 + ((int)(q)) + k; | |
| 6624 | + vr = strconv__mul_pow5_invdiv_pow2(mv, q, i); | |
| 6625 | + vp = strconv__mul_pow5_invdiv_pow2(mp, q, i); | |
| 6626 | + vm = strconv__mul_pow5_invdiv_pow2(mm, q, i); | |
| 6627 | + if (q != 0 && VSAFE_DIV_u32((vp - 1) , 10) <= VSAFE_DIV_u32(vm , 10)) { | |
| 6628 | + int l = 59 + strconv__pow5_bits(((int)(q - 1))) - 1; | |
| 6629 | + last_removed_digit = ((u8)(VSAFE_MOD_u32(strconv__mul_pow5_invdiv_pow2(mv, q - 1, -e2 + ((int)(q - 1)) + l) , 10))); | |
| 6630 | + } | |
| 6631 | + if (q <= 9) { | |
| 6632 | + if (VSAFE_MOD_u32(mv , 5) == 0) { | |
| 6633 | + vr_is_trailing_zeros = strconv__multiple_of_power_of_five_32(mv, q); | |
| 6634 | + } else if (accept_bounds) { | |
| 6635 | + vm_is_trailing_zeros = strconv__multiple_of_power_of_five_32(mm, q); | |
| 6636 | + } else if (strconv__multiple_of_power_of_five_32(mp, q)) { | |
| 6637 | + vp--; | |
| 6638 | + } | |
| 6639 | + } | |
| 6640 | + } else { | |
| 6641 | + u32 q = strconv__log10_pow5(-e2); | |
| 6642 | + e10 = ((int)(q)) + e2; | |
| 6643 | + int i = -e2 - ((int)(q)); | |
| 6644 | + int k = strconv__pow5_bits(i) - 61; | |
| 6645 | + int j = ((int)(q)) - k; | |
| 6646 | + vr = strconv__mul_pow5_div_pow2(mv, ((u32)(i)), j); | |
| 6647 | + vp = strconv__mul_pow5_div_pow2(mp, ((u32)(i)), j); | |
| 6648 | + vm = strconv__mul_pow5_div_pow2(mm, ((u32)(i)), j); | |
| 6649 | + if (q != 0 && (VSAFE_DIV_u32((vp - 1) , 10)) <= VSAFE_DIV_u32(vm , 10)) { | |
| 6650 | + j = ((int)(q)) - 1 - (strconv__pow5_bits(i + 1) - 61); | |
| 6651 | + last_removed_digit = ((u8)(VSAFE_MOD_u32(strconv__mul_pow5_div_pow2(mv, ((u32)(i + 1)), j) , 10))); | |
| 6652 | + } | |
| 6653 | + if (q <= 1) { | |
| 6654 | + vr_is_trailing_zeros = true; | |
| 6655 | + if (accept_bounds) { | |
| 6656 | + vm_is_trailing_zeros = mm_shift == 1; | |
| 6657 | + } else { | |
| 6658 | + vp--; | |
| 6659 | + } | |
| 6660 | + } else if (q < 31) { | |
| 6661 | + vr_is_trailing_zeros = strconv__multiple_of_power_of_two_32(mv, q - 1); | |
| 6662 | + } | |
| 6663 | + } | |
| 6664 | + int removed = 0; | |
| 6665 | + u32 out = ((u32)(0)); | |
| 6666 | + if (vm_is_trailing_zeros || vr_is_trailing_zeros) { | |
| 6667 | + for (;;) { | |
| 6668 | + if (!(VSAFE_DIV_u32(vp , 10) > VSAFE_DIV_u32(vm , 10))) break; | |
| 6669 | + vm_is_trailing_zeros = vm_is_trailing_zeros && (VSAFE_MOD_u32(vm , 10)) == 0; | |
| 6670 | + vr_is_trailing_zeros = vr_is_trailing_zeros && last_removed_digit == 0; | |
| 6671 | + last_removed_digit = ((u8)(VSAFE_MOD_u32(vr , 10))); | |
| 6672 | + vr = VSAFE_DIV_u32(vr,10); | |
| 6673 | + vp = VSAFE_DIV_u32(vp,10); | |
| 6674 | + vm = VSAFE_DIV_u32(vm,10); | |
| 6675 | + removed++; | |
| 6676 | + } | |
| 6677 | + if (vm_is_trailing_zeros) { | |
| 6678 | + for (;;) { | |
| 6679 | + if (!(VSAFE_MOD_u32(vm , 10) == 0)) break; | |
| 6680 | + vr_is_trailing_zeros = vr_is_trailing_zeros && last_removed_digit == 0; | |
| 6681 | + last_removed_digit = ((u8)(VSAFE_MOD_u32(vr , 10))); | |
| 6682 | + vr = VSAFE_DIV_u32(vr,10); | |
| 6683 | + vp = VSAFE_DIV_u32(vp,10); | |
| 6684 | + vm = VSAFE_DIV_u32(vm,10); | |
| 6685 | + removed++; | |
| 6686 | + } | |
| 6687 | + } | |
| 6688 | + if (vr_is_trailing_zeros && last_removed_digit == 5 && (VSAFE_MOD_u32(vr , 2)) == 0) { | |
| 6689 | + last_removed_digit = 4; | |
| 6690 | + } | |
| 6691 | + out = vr; | |
| 6692 | + if ((vr == vm && (!accept_bounds || !vm_is_trailing_zeros)) || last_removed_digit >= 5) { | |
| 6693 | + out++; | |
| 6694 | + } | |
| 6695 | + } else { | |
| 6696 | + for (;;) { | |
| 6697 | + if (!(VSAFE_DIV_u32(vp , 10) > VSAFE_DIV_u32(vm , 10))) break; | |
| 6698 | + last_removed_digit = ((u8)(VSAFE_MOD_u32(vr , 10))); | |
| 6699 | + vr = VSAFE_DIV_u32(vr,10); | |
| 6700 | + vp = VSAFE_DIV_u32(vp,10); | |
| 6701 | + vm = VSAFE_DIV_u32(vm,10); | |
| 6702 | + removed++; | |
| 6703 | + } | |
| 6704 | + out = vr + strconv__bool_to_u32(vr == vm || last_removed_digit >= 5); | |
| 6705 | + } | |
| 6706 | + return ((strconv__Dec32){.m = out,.e = e10 + removed,}); | |
| 6707 | +} | |
| 6708 | +string strconv__f32_to_str(f32 f, int n_digit) { | |
| 6709 | + strconv__Uf32 _t1 = ((strconv__Uf32){0}); | |
| 6710 | + strconv__Uf32 u1 = _t1; | |
| 6711 | + u1.f = f; | |
| 6712 | + u32 u = u1.u; | |
| 6713 | + bool neg = (v__rshift_u32(u, (u64)(_const_strconv__mantbits32 + _const_strconv__expbits32))) != 0; | |
| 6714 | + u32 mant = (u & ((v__lshift_u32(((u32)(1)), (u64)_const_strconv__mantbits32)) - ((u32)(1)))); | |
| 6715 | + u32 exp = ((v__rshift_u32(u, (u64)_const_strconv__mantbits32)) & ((v__lshift_u32(((u32)(1)), (u64)_const_strconv__expbits32)) - ((u32)(1)))); | |
| 6716 | + if (exp == 255 || (exp == 0 && mant == 0)) { | |
| 6717 | + return strconv__get_string_special(neg, exp == 0, mant == 0); | |
| 6718 | + } | |
| 6719 | + multi_return_strconv__Dec32_bool mr_8600 = strconv__f32_to_decimal_exact_int(mant, exp); | |
| 6720 | + strconv__Dec32 d = mr_8600.arg0; | |
| 6721 | + bool ok = mr_8600.arg1; | |
| 6722 | + if (!ok) { | |
| 6723 | + d = strconv__f32_to_decimal(mant, exp); | |
| 6724 | + } | |
| 6725 | + return strconv__Dec32_get_string_32(d, neg, n_digit, 0); | |
| 6726 | +} | |
| 6727 | +string strconv__f32_to_str_pad(f32 f, int n_digit) { | |
| 6728 | + strconv__Uf32 _t1 = ((strconv__Uf32){0}); | |
| 6729 | + strconv__Uf32 u1 = _t1; | |
| 6730 | + u1.f = f; | |
| 6731 | + u32 u = u1.u; | |
| 6732 | + bool neg = (v__rshift_u32(u, (u64)(_const_strconv__mantbits32 + _const_strconv__expbits32))) != 0; | |
| 6733 | + u32 mant = (u & ((v__lshift_u32(((u32)(1)), (u64)_const_strconv__mantbits32)) - ((u32)(1)))); | |
| 6734 | + u32 exp = ((v__rshift_u32(u, (u64)_const_strconv__mantbits32)) & ((v__lshift_u32(((u32)(1)), (u64)_const_strconv__expbits32)) - ((u32)(1)))); | |
| 6735 | + if (exp == 255 || (exp == 0 && mant == 0)) { | |
| 6736 | + return strconv__get_string_special(neg, exp == 0, mant == 0); | |
| 6737 | + } | |
| 6738 | + multi_return_strconv__Dec32_bool mr_9334 = strconv__f32_to_decimal_exact_int(mant, exp); | |
| 6739 | + strconv__Dec32 d = mr_9334.arg0; | |
| 6740 | + bool ok = mr_9334.arg1; | |
| 6741 | + if (!ok) { | |
| 6742 | + d = strconv__f32_to_decimal(mant, exp); | |
| 6743 | + } | |
| 6744 | + return strconv__Dec32_get_string_32(d, neg, n_digit, n_digit); | |
| 6745 | +} | |
| 6746 | +VV_LOC string strconv__Dec64_get_string_64(strconv__Dec64 d, bool neg, int i_n_digit, int i_pad_digit) { | |
| 6747 | + int n_digit = (i_n_digit < 1 ? (1) : (i_n_digit + 1)); | |
| 6748 | + int pad_digit = i_pad_digit + 1; | |
| 6749 | + u64 out = d.m; | |
| 6750 | + int d_exp = d.e; | |
| 6751 | + int out_len = strconv__dec_digits(out); | |
| 6752 | + int out_len_original = out_len; | |
| 6753 | + int fw_zeros = 0; | |
| 6754 | + if (pad_digit > out_len) { | |
| 6755 | + fw_zeros = pad_digit - out_len; | |
| 6756 | + } | |
| 6757 | + Array_u8 buf = builtin____new_array_with_default((out_len + 6 + 1 + 1 + fw_zeros), 0, sizeof(u8), 0); | |
| 6758 | + int i = 0; | |
| 6759 | + if (neg) { | |
| 6760 | + ((u8*)buf.data)[i] = '-'; | |
| 6761 | + i++; | |
| 6762 | + } | |
| 6763 | + int disp = 0; | |
| 6764 | + if (out_len <= 1) { | |
| 6765 | + disp = 1; | |
| 6766 | + } | |
| 6767 | + if (n_digit < out_len) { | |
| 6768 | + out += _const_strconv__ten_pow_table_64[out_len - n_digit - 1] * 5; | |
| 6769 | + out = VSAFE_DIV_u64(out,_const_strconv__ten_pow_table_64[out_len - n_digit]); | |
| 6770 | + u64 out_div = VSAFE_DIV_u64(d.m , _const_strconv__ten_pow_table_64[out_len - n_digit]); | |
| 6771 | + if (out_div < out && strconv__dec_digits(out_div) < strconv__dec_digits(out)) { | |
| 6772 | + d_exp++; | |
| 6773 | + n_digit++; | |
| 6774 | + } | |
| 6775 | + out_len = n_digit; | |
| 6776 | + } | |
| 6777 | + int y = i + out_len; | |
| 6778 | + int x = 0; | |
| 6779 | + for (;;) { | |
| 6780 | + if (!(x < (out_len - disp - 1))) break; | |
| 6781 | + ((u8*)buf.data)[y - x] = (rune)('0' + ((u8)(VSAFE_MOD_u64(out , 10)))); | |
| 6782 | + out = VSAFE_DIV_u64(out,10); | |
| 6783 | + i++; | |
| 6784 | + x++; | |
| 6785 | + } | |
| 6786 | + if (out_len > 1 || fw_zeros > 0) { | |
| 6787 | + ((u8*)buf.data)[y - x] = '.'; | |
| 6788 | + i++; | |
| 6789 | + } | |
| 6790 | + x++; | |
| 6791 | + if (y - x >= 0) { | |
| 6792 | + ((u8*)buf.data)[y - x] = (rune)('0' + ((u8)(VSAFE_MOD_u64(out , 10)))); | |
| 6793 | + i++; | |
| 6794 | + } | |
| 6795 | + for (;;) { | |
| 6796 | + if (!(fw_zeros > 0)) break; | |
| 6797 | + ((u8*)buf.data)[i] = '0'; | |
| 6798 | + i++; | |
| 6799 | + fw_zeros--; | |
| 6800 | + } | |
| 6801 | + ((u8*)buf.data)[i] = 'e'; | |
| 6802 | + i++; | |
| 6803 | + int exp = d_exp + out_len_original - 1; | |
| 6804 | + if (exp < 0) { | |
| 6805 | + ((u8*)buf.data)[i] = '-'; | |
| 6806 | + i++; | |
| 6807 | + exp = -exp; | |
| 6808 | + } else { | |
| 6809 | + ((u8*)buf.data)[i] = '+'; | |
| 6810 | + i++; | |
| 6811 | + } | |
| 6812 | + int d2 = VSAFE_MOD_int(exp , 10); | |
| 6813 | + exp = VSAFE_DIV_int(exp,10); | |
| 6814 | + int d1 = VSAFE_MOD_int(exp , 10); | |
| 6815 | + int d0 = VSAFE_DIV_int(exp , 10); | |
| 6816 | + if (d0 > 0) { | |
| 6817 | + ((u8*)buf.data)[i] = (rune)('0' + ((u8)(d0))); | |
| 6818 | + i++; | |
| 6819 | + } | |
| 6820 | + ((u8*)buf.data)[i] = (rune)('0' + ((u8)(d1))); | |
| 6821 | + i++; | |
| 6822 | + ((u8*)buf.data)[i] = (rune)('0' + ((u8)(d2))); | |
| 6823 | + i++; | |
| 6824 | + ((u8*)buf.data)[i] = 0; | |
| 6825 | + return builtin__tos(builtin__memdup(&((u8*)buf.data)[0], i + 1), i); | |
| 6826 | +} | |
| 6827 | +VV_LOC multi_return_strconv__Dec64_bool strconv__f64_to_decimal_exact_int(u64 i_mant, u64 exp) { | |
| 6828 | + strconv__Dec64 _t1 = ((strconv__Dec64){.m = 0,.e = 0,}); | |
| 6829 | + strconv__Dec64 d = _t1; | |
| 6830 | + u64 e = exp - 1023; | |
| 6831 | + if (e > _const_strconv__mantbits64) { | |
| 6832 | + return (multi_return_strconv__Dec64_bool){.arg0=d, .arg1=false}; | |
| 6833 | + } | |
| 6834 | + u64 shift = (u64)(_const_strconv__mantbits64 - e); | |
| 6835 | + u64 mant = (i_mant | ((u64)(0x0010000000000000LL))); | |
| 6836 | + d.m = v__rshift_u64(mant, (u64)shift); | |
| 6837 | + if ((v__lshift_u64(d.m, (u64)shift)) != mant) { | |
| 6838 | + return (multi_return_strconv__Dec64_bool){.arg0=d, .arg1=false}; | |
| 6839 | + } | |
| 6840 | + for (;;) { | |
| 6841 | + if (!((VSAFE_MOD_u64(d.m , 10)) == 0)) break; | |
| 6842 | + d.m = VSAFE_DIV_u64(d.m,10); | |
| 6843 | + d.e++; | |
| 6844 | + } | |
| 6845 | + return (multi_return_strconv__Dec64_bool){.arg0=d, .arg1=true}; | |
| 6846 | +} | |
| 6847 | +VV_LOC strconv__Dec64 strconv__f64_to_decimal(u64 mant, u64 exp) { | |
| 6848 | + int e2 = 0; | |
| 6849 | + u64 m2 = ((u64)(0)); | |
| 6850 | + if (exp == 0) { | |
| 6851 | + e2 = -1022 - ((int)(_const_strconv__mantbits64)) - 2; | |
| 6852 | + m2 = mant; | |
| 6853 | + } else { | |
| 6854 | + e2 = ((int)(exp)) - 1023 - ((int)(_const_strconv__mantbits64)) - 2; | |
| 6855 | + m2 = ((v__lshift_u64(((u64)(1)), (u64)_const_strconv__mantbits64)) | mant); | |
| 6856 | + } | |
| 6857 | + bool even = ((m2 & 1)) == 0; | |
| 6858 | + bool accept_bounds = even; | |
| 6859 | + u64 mv = ((u64)(4 * m2)); | |
| 6860 | + u64 mm_shift = strconv__bool_to_u64(mant != 0 || exp <= 1); | |
| 6861 | + u64 vr = ((u64)(0)); | |
| 6862 | + u64 vp = ((u64)(0)); | |
| 6863 | + u64 vm = ((u64)(0)); | |
| 6864 | + int e10 = 0; | |
| 6865 | + bool vm_is_trailing_zeros = false; | |
| 6866 | + bool vr_is_trailing_zeros = false; | |
| 6867 | + if (e2 >= 0) { | |
| 6868 | + u32 q = strconv__log10_pow2(e2) - strconv__bool_to_u32(e2 > 3); | |
| 6869 | + e10 = ((int)(q)); | |
| 6870 | + int k = 122 + strconv__pow5_bits(((int)(q))) - 1; | |
| 6871 | + int i = -e2 + ((int)(q)) + k; | |
| 6872 | + strconv__Uint128 mul = *(((strconv__Uint128*)(&_const_strconv__pow5_inv_split_64_x[builtin__v_fixed_index(q * 2, 584)]))); | |
| 6873 | + vr = strconv__mul_shift_64(((u64)(4)) * m2, mul, i); | |
| 6874 | + vp = strconv__mul_shift_64(((u64)(4)) * m2 + ((u64)(2)), mul, i); | |
| 6875 | + vm = strconv__mul_shift_64(((u64)(4)) * m2 - ((u64)(1)) - mm_shift, mul, i); | |
| 6876 | + if (q <= 21) { | |
| 6877 | + if (VSAFE_MOD_u64(mv , 5) == 0) { | |
| 6878 | + vr_is_trailing_zeros = strconv__multiple_of_power_of_five_64(mv, q); | |
| 6879 | + } else if (accept_bounds) { | |
| 6880 | + vm_is_trailing_zeros = strconv__multiple_of_power_of_five_64(mv - 1 - mm_shift, q); | |
| 6881 | + } else if (strconv__multiple_of_power_of_five_64(mv + 2, q)) { | |
| 6882 | + vp--; | |
| 6883 | + } | |
| 6884 | + } | |
| 6885 | + } else { | |
| 6886 | + u32 q = strconv__log10_pow5(-e2) - strconv__bool_to_u32(-e2 > 1); | |
| 6887 | + e10 = ((int)(q)) + e2; | |
| 6888 | + int i = -e2 - ((int)(q)); | |
| 6889 | + int k = strconv__pow5_bits(i) - 121; | |
| 6890 | + int j = ((int)(q)) - k; | |
| 6891 | + strconv__Uint128 mul = *(((strconv__Uint128*)(&_const_strconv__pow5_split_64_x[builtin__v_fixed_index(i * 2, 652)]))); | |
| 6892 | + vr = strconv__mul_shift_64(((u64)(4)) * m2, mul, j); | |
| 6893 | + vp = strconv__mul_shift_64(((u64)(4)) * m2 + ((u64)(2)), mul, j); | |
| 6894 | + vm = strconv__mul_shift_64(((u64)(4)) * m2 - ((u64)(1)) - mm_shift, mul, j); | |
| 6895 | + if (q <= 1) { | |
| 6896 | + vr_is_trailing_zeros = true; | |
| 6897 | + if (accept_bounds) { | |
| 6898 | + vm_is_trailing_zeros = (mm_shift == 1); | |
| 6899 | + } else { | |
| 6900 | + vp--; | |
| 6901 | + } | |
| 6902 | + } else if (q < 63) { | |
| 6903 | + vr_is_trailing_zeros = strconv__multiple_of_power_of_two_64(mv, q - 1); | |
| 6904 | + } | |
| 6905 | + } | |
| 6906 | + int removed = 0; | |
| 6907 | + u8 last_removed_digit = ((u8)(0)); | |
| 6908 | + u64 out = ((u64)(0)); | |
| 6909 | + if (vm_is_trailing_zeros || vr_is_trailing_zeros) { | |
| 6910 | + for (;;) { | |
| 6911 | + u64 vp_div_10 = VSAFE_DIV_u64(vp , 10); | |
| 6912 | + u64 vm_div_10 = VSAFE_DIV_u64(vm , 10); | |
| 6913 | + if (vp_div_10 <= vm_div_10) { | |
| 6914 | + break; | |
| 6915 | + } | |
| 6916 | + u64 vm_mod_10 = VSAFE_MOD_u64(vm , 10); | |
| 6917 | + u64 vr_div_10 = VSAFE_DIV_u64(vr , 10); | |
| 6918 | + u64 vr_mod_10 = VSAFE_MOD_u64(vr , 10); | |
| 6919 | + vm_is_trailing_zeros = vm_is_trailing_zeros && vm_mod_10 == 0; | |
| 6920 | + vr_is_trailing_zeros = vr_is_trailing_zeros && last_removed_digit == 0; | |
| 6921 | + last_removed_digit = ((u8)(vr_mod_10)); | |
| 6922 | + vr = vr_div_10; | |
| 6923 | + vp = vp_div_10; | |
| 6924 | + vm = vm_div_10; | |
| 6925 | + removed++; | |
| 6926 | + } | |
| 6927 | + if (vm_is_trailing_zeros) { | |
| 6928 | + for (;;) { | |
| 6929 | + u64 vm_div_10 = VSAFE_DIV_u64(vm , 10); | |
| 6930 | + u64 vm_mod_10 = VSAFE_MOD_u64(vm , 10); | |
| 6931 | + if (vm_mod_10 != 0) { | |
| 6932 | + break; | |
| 6933 | + } | |
| 6934 | + u64 vp_div_10 = VSAFE_DIV_u64(vp , 10); | |
| 6935 | + u64 vr_div_10 = VSAFE_DIV_u64(vr , 10); | |
| 6936 | + u64 vr_mod_10 = VSAFE_MOD_u64(vr , 10); | |
| 6937 | + vr_is_trailing_zeros = vr_is_trailing_zeros && last_removed_digit == 0; | |
| 6938 | + last_removed_digit = ((u8)(vr_mod_10)); | |
| 6939 | + vr = vr_div_10; | |
| 6940 | + vp = vp_div_10; | |
| 6941 | + vm = vm_div_10; | |
| 6942 | + removed++; | |
| 6943 | + } | |
| 6944 | + } | |
| 6945 | + if (vr_is_trailing_zeros && last_removed_digit == 5 && (VSAFE_MOD_u64(vr , 2)) == 0) { | |
| 6946 | + last_removed_digit = 4; | |
| 6947 | + } | |
| 6948 | + out = vr; | |
| 6949 | + if ((vr == vm && (!accept_bounds || !vm_is_trailing_zeros)) || last_removed_digit >= 5) { | |
| 6950 | + out++; | |
| 6951 | + } | |
| 6952 | + } else { | |
| 6953 | + bool round_up = false; | |
| 6954 | + for (;;) { | |
| 6955 | + if (!(VSAFE_DIV_u64(vp , 100) > VSAFE_DIV_u64(vm , 100))) break; | |
| 6956 | + round_up = (VSAFE_MOD_u64(vr , 100)) >= 50; | |
| 6957 | + vr = VSAFE_DIV_u64(vr,100); | |
| 6958 | + vp = VSAFE_DIV_u64(vp,100); | |
| 6959 | + vm = VSAFE_DIV_u64(vm,100); | |
| 6960 | + removed += 2; | |
| 6961 | + } | |
| 6962 | + for (;;) { | |
| 6963 | + if (!(VSAFE_DIV_u64(vp , 10) > VSAFE_DIV_u64(vm , 10))) break; | |
| 6964 | + round_up = (VSAFE_MOD_u64(vr , 10)) >= 5; | |
| 6965 | + vr = VSAFE_DIV_u64(vr,10); | |
| 6966 | + vp = VSAFE_DIV_u64(vp,10); | |
| 6967 | + vm = VSAFE_DIV_u64(vm,10); | |
| 6968 | + removed++; | |
| 6969 | + } | |
| 6970 | + out = vr + strconv__bool_to_u64(vr == vm || round_up); | |
| 6971 | + } | |
| 6972 | + return ((strconv__Dec64){.m = out,.e = e10 + removed,}); | |
| 6973 | +} | |
| 6974 | +string strconv__f64_to_str(f64 f, int n_digit) { | |
| 6975 | + strconv__Uf64 _t1 = ((strconv__Uf64){0}); | |
| 6976 | + strconv__Uf64 u1 = _t1; | |
| 6977 | + u1.f = f; | |
| 6978 | + u64 u = u1.u; | |
| 6979 | + bool neg = (v__rshift_u64(u, (u64)(_const_strconv__mantbits64 + _const_strconv__expbits64))) != 0; | |
| 6980 | + u64 mant = (u & ((v__lshift_u64(((u64)(1)), (u64)_const_strconv__mantbits64)) - ((u64)(1)))); | |
| 6981 | + u64 exp = ((v__rshift_u64(u, (u64)_const_strconv__mantbits64)) & ((v__lshift_u64(((u64)(1)), (u64)_const_strconv__expbits64)) - ((u64)(1)))); | |
| 6982 | + if (exp == 2047 || (exp == 0 && mant == 0)) { | |
| 6983 | + return strconv__get_string_special(neg, exp == 0, mant == 0); | |
| 6984 | + } | |
| 6985 | + multi_return_strconv__Dec64_bool mr_9595 = strconv__f64_to_decimal_exact_int(mant, exp); | |
| 6986 | + strconv__Dec64 d = mr_9595.arg0; | |
| 6987 | + bool ok = mr_9595.arg1; | |
| 6988 | + if (!ok) { | |
| 6989 | + d = strconv__f64_to_decimal(mant, exp); | |
| 6990 | + } | |
| 6991 | + return strconv__Dec64_get_string_64(d, neg, n_digit, 0); | |
| 6992 | +} | |
| 6993 | +string strconv__f64_to_str_pad(f64 f, int n_digit) { | |
| 6994 | + strconv__Uf64 _t1 = ((strconv__Uf64){0}); | |
| 6995 | + strconv__Uf64 u1 = _t1; | |
| 6996 | + u1.f = f; | |
| 6997 | + u64 u = u1.u; | |
| 6998 | + bool neg = (v__rshift_u64(u, (u64)(_const_strconv__mantbits64 + _const_strconv__expbits64))) != 0; | |
| 6999 | + u64 mant = (u & ((v__lshift_u64(((u64)(1)), (u64)_const_strconv__mantbits64)) - ((u64)(1)))); | |
| 7000 | + u64 exp = ((v__rshift_u64(u, (u64)_const_strconv__mantbits64)) & ((v__lshift_u64(((u64)(1)), (u64)_const_strconv__expbits64)) - ((u64)(1)))); | |
| 7001 | + if (exp == 2047 || (exp == 0 && mant == 0)) { | |
| 7002 | + return strconv__get_string_special(neg, exp == 0, mant == 0); | |
| 7003 | + } | |
| 7004 | + multi_return_strconv__Dec64_bool mr_10376 = strconv__f64_to_decimal_exact_int(mant, exp); | |
| 7005 | + strconv__Dec64 d = mr_10376.arg0; | |
| 7006 | + bool ok = mr_10376.arg1; | |
| 7007 | + if (!ok) { | |
| 7008 | + d = strconv__f64_to_decimal(mant, exp); | |
| 7009 | + } | |
| 7010 | + return strconv__Dec64_get_string_64(d, neg, n_digit, n_digit); | |
| 7011 | +} | |
| 7012 | +string strconv__format_str(string s, strconv__BF_param p) { | |
| 7013 | + if (p.len0 <= 0) { | |
| 7014 | + return builtin__string_clone(s); | |
| 7015 | + } | |
| 7016 | + int dif = p.len0 - builtin__utf8_str_visible_length(s); | |
| 7017 | + if (dif <= 0) { | |
| 7018 | + return builtin__string_clone(s); | |
| 7019 | + } | |
| 7020 | + strings__Builder res = strings__new_builder(s.len + dif); | |
| 7021 | + if (p.align == strconv__Align_text__right) { | |
| 7022 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 7023 | + strings__Builder_write_u8(&res, p.pad_ch); | |
| 7024 | + } | |
| 7025 | + } | |
| 7026 | + strings__Builder_write_string(&res, s); | |
| 7027 | + if (p.align == strconv__Align_text__left) { | |
| 7028 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 7029 | + strings__Builder_write_u8(&res, p.pad_ch); | |
| 7030 | + } | |
| 7031 | + } | |
| 7032 | + string _t3 = strings__Builder_str(&res); | |
| 7033 | + { // defer begin | |
| 7034 | + strings__Builder_free(&res); | |
| 7035 | + } // defer end | |
| 7036 | + return _t3; | |
| 7037 | +} | |
| 7038 | +void strconv__format_str_sb(string s, strconv__BF_param p, strings__Builder* sb) { | |
| 7039 | + if (p.len0 <= 0) { | |
| 7040 | + strings__Builder_write_string(sb, s); | |
| 7041 | + return; | |
| 7042 | + } | |
| 7043 | + int dif = p.len0 - builtin__utf8_str_visible_length(s); | |
| 7044 | + if (dif <= 0) { | |
| 7045 | + strings__Builder_write_string(sb, s); | |
| 7046 | + return; | |
| 7047 | + } | |
| 7048 | + if (p.align == strconv__Align_text__right) { | |
| 7049 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 7050 | + strings__Builder_write_u8(sb, p.pad_ch); | |
| 7051 | + } | |
| 7052 | + } | |
| 7053 | + strings__Builder_write_string(sb, s); | |
| 7054 | + if (p.align == strconv__Align_text__left) { | |
| 7055 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 7056 | + strings__Builder_write_u8(sb, p.pad_ch); | |
| 7057 | + } | |
| 7058 | + } | |
| 7059 | +} | |
| 7060 | +void strconv__format_dec_sb(u64 d, strconv__BF_param p, strings__Builder* res) { | |
| 7061 | + int n_char = strconv__dec_digits(d); | |
| 7062 | + int sign_len = (!p.positive || p.sign_flag ? (1) : (0)); | |
| 7063 | + int number_len = sign_len + n_char; | |
| 7064 | + int dif = p.len0 - number_len; | |
| 7065 | + bool sign_written = false; | |
| 7066 | + if (p.align == strconv__Align_text__right) { | |
| 7067 | + if (p.pad_ch == '0') { | |
| 7068 | + if (p.positive) { | |
| 7069 | + if (p.sign_flag) { | |
| 7070 | + strings__Builder_write_u8(res, '+'); | |
| 7071 | + sign_written = true; | |
| 7072 | + } | |
| 7073 | + } else { | |
| 7074 | + strings__Builder_write_u8(res, '-'); | |
| 7075 | + sign_written = true; | |
| 7076 | + } | |
| 7077 | + } | |
| 7078 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 7079 | + strings__Builder_write_u8(res, p.pad_ch); | |
| 7080 | + } | |
| 7081 | + } | |
| 7082 | + if (!sign_written) { | |
| 7083 | + if (p.positive) { | |
| 7084 | + if (p.sign_flag) { | |
| 7085 | + strings__Builder_write_u8(res, '+'); | |
| 7086 | + } | |
| 7087 | + } else { | |
| 7088 | + strings__Builder_write_u8(res, '-'); | |
| 7089 | + } | |
| 7090 | + } | |
| 7091 | + Array_fixed_u8_32 buf = {0}; | |
| 7092 | + int i = 20; | |
| 7093 | + u64 n = d; | |
| 7094 | + u64 d_i = ((u64)(0)); | |
| 7095 | + if (n > 0) { | |
| 7096 | + for (;;) { | |
| 7097 | + if (!(n > 0)) break; | |
| 7098 | + u64 n1 = VSAFE_DIV_u64(n , 100); | |
| 7099 | + d_i = v__lshift_u64((n - (n1 * 100)), (u64)1); | |
| 7100 | + n = n1; | |
| 7101 | + { // Unsafe block | |
| 7102 | + buf[i] = _const_strconv__digit_pairs.str[d_i]; | |
| 7103 | + } | |
| 7104 | + i--; | |
| 7105 | + d_i++; | |
| 7106 | + { // Unsafe block | |
| 7107 | + buf[i] = _const_strconv__digit_pairs.str[d_i]; | |
| 7108 | + } | |
| 7109 | + i--; | |
| 7110 | + } | |
| 7111 | + i++; | |
| 7112 | + if (d_i < 20) { | |
| 7113 | + i++; | |
| 7114 | + } | |
| 7115 | + strings__Builder_write_ptr(res, &buf[i], n_char); | |
| 7116 | + } else { | |
| 7117 | + strings__Builder_write_u8(res, '0'); | |
| 7118 | + } | |
| 7119 | + if (p.align == strconv__Align_text__left) { | |
| 7120 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 7121 | + strings__Builder_write_u8(res, p.pad_ch); | |
| 7122 | + } | |
| 7123 | + } | |
| 7124 | + return; | |
| 7125 | +} | |
| 7126 | +string strconv__f64_to_str_lnd1(f64 f, int dec_digit) { | |
| 7127 | + { // Unsafe block | |
| 7128 | + int clamped_dec = (dec_digit >= 36 ? (36 - 1) : (dec_digit)); | |
| 7129 | + string s = strconv__f64_to_str(f + _const_strconv__dec_round[clamped_dec], 18); | |
| 7130 | + if (s.len > 2 && (s.str[ 0] == 'n' || s.str[ 1] == 'i')) { | |
| 7131 | + return s; | |
| 7132 | + } | |
| 7133 | + bool m_sgn_flag = false; | |
| 7134 | + int sgn = 1; | |
| 7135 | + Array_fixed_u8_26 b = {0}; | |
| 7136 | + int d_pos = 1; | |
| 7137 | + int i = 0; | |
| 7138 | + int i1 = 0; | |
| 7139 | + int exp = 0; | |
| 7140 | + int exp_sgn = 1; | |
| 7141 | + int dot_res_sp = -1; | |
| 7142 | + for (int _t2 = 0; _t2 < s.len; ++_t2) { | |
| 7143 | + u8 c = s.str[_t2]; | |
| 7144 | + | |
| 7145 | + if (c == ('-')) { | |
| 7146 | + sgn = -1; | |
| 7147 | + i++; | |
| 7148 | + } | |
| 7149 | + else if (c == ('+')) { | |
| 7150 | + sgn = 1; | |
| 7151 | + i++; | |
| 7152 | + } | |
| 7153 | + else if ((c >= '0' && c <= '9')) { | |
| 7154 | + b[i1] = c; | |
| 7155 | + i1++; | |
| 7156 | + i++; | |
| 7157 | + } | |
| 7158 | + else if (c == ('.')) { | |
| 7159 | + if (sgn > 0) { | |
| 7160 | + d_pos = i; | |
| 7161 | + } else { | |
| 7162 | + d_pos = i - 1; | |
| 7163 | + } | |
| 7164 | + i++; | |
| 7165 | + } | |
| 7166 | + else if (c == ('e')) { | |
| 7167 | + i++; | |
| 7168 | + break; | |
| 7169 | + } | |
| 7170 | + else { | |
| 7171 | + builtin__string_free(&s); | |
| 7172 | + return _S("[Float conversion error!!]"); | |
| 7173 | + } | |
| 7174 | + } | |
| 7175 | + b[i1] = 0; | |
| 7176 | + if (s.str[ i] == '-') { | |
| 7177 | + exp_sgn = -1; | |
| 7178 | + i++; | |
| 7179 | + } else if (s.str[ i] == '+') { | |
| 7180 | + exp_sgn = 1; | |
| 7181 | + i++; | |
| 7182 | + } | |
| 7183 | + int c = i; | |
| 7184 | + for (;;) { | |
| 7185 | + if (!(c < s.len)) break; | |
| 7186 | + exp = exp * 10 + ((int)((rune)(s.str[ c] - '0'))); | |
| 7187 | + c++; | |
| 7188 | + } | |
| 7189 | + int extra_frac_digits = (dec_digit > 0 ? (dec_digit) : (0)); | |
| 7190 | + int sign_len = (sgn < 0 ? (1) : (0)); | |
| 7191 | + Array_u8 res = builtin____new_array_with_default(sign_len + i1 + exp + extra_frac_digits + 4, 0, sizeof(u8), &(u8[]){0}); | |
| 7192 | + int r_i = 0; | |
| 7193 | + builtin__string_free(&s); | |
| 7194 | + if (sgn == 1) { | |
| 7195 | + if (m_sgn_flag) { | |
| 7196 | + ((u8*)res.data)[r_i] = '+'; | |
| 7197 | + r_i++; | |
| 7198 | + } | |
| 7199 | + } else { | |
| 7200 | + ((u8*)res.data)[r_i] = '-'; | |
| 7201 | + r_i++; | |
| 7202 | + } | |
| 7203 | + i = 0; | |
| 7204 | + if (exp_sgn >= 0) { | |
| 7205 | + for (;;) { | |
| 7206 | + if (!(b[i] != 0)) break; | |
| 7207 | + ((u8*)res.data)[r_i] = b[i]; | |
| 7208 | + r_i++; | |
| 7209 | + i++; | |
| 7210 | + if (i >= d_pos && exp >= 0) { | |
| 7211 | + if (exp == 0) { | |
| 7212 | + dot_res_sp = r_i; | |
| 7213 | + ((u8*)res.data)[r_i] = '.'; | |
| 7214 | + r_i++; | |
| 7215 | + } | |
| 7216 | + exp--; | |
| 7217 | + } | |
| 7218 | + } | |
| 7219 | + for (;;) { | |
| 7220 | + if (!(exp >= 0)) break; | |
| 7221 | + ((u8*)res.data)[r_i] = '0'; | |
| 7222 | + r_i++; | |
| 7223 | + exp--; | |
| 7224 | + } | |
| 7225 | + } else { | |
| 7226 | + bool dot_p = true; | |
| 7227 | + for (;;) { | |
| 7228 | + if (!(exp > 0)) break; | |
| 7229 | + ((u8*)res.data)[r_i] = '0'; | |
| 7230 | + r_i++; | |
| 7231 | + exp--; | |
| 7232 | + if (dot_p) { | |
| 7233 | + dot_res_sp = r_i; | |
| 7234 | + ((u8*)res.data)[r_i] = '.'; | |
| 7235 | + r_i++; | |
| 7236 | + dot_p = false; | |
| 7237 | + } | |
| 7238 | + } | |
| 7239 | + for (;;) { | |
| 7240 | + if (!(b[i] != 0)) break; | |
| 7241 | + ((u8*)res.data)[r_i] = b[i]; | |
| 7242 | + r_i++; | |
| 7243 | + i++; | |
| 7244 | + } | |
| 7245 | + } | |
| 7246 | + if (dec_digit <= 0) { | |
| 7247 | + if (dot_res_sp < 0) { | |
| 7248 | + dot_res_sp = i + 1; | |
| 7249 | + } | |
| 7250 | + string tmp_res = builtin__string_clone(builtin__tos(res.data, dot_res_sp)); | |
| 7251 | + builtin__array_free(&res); | |
| 7252 | + return tmp_res; | |
| 7253 | + } | |
| 7254 | + if (dot_res_sp >= 0) { | |
| 7255 | + r_i = dot_res_sp + dec_digit + 1; | |
| 7256 | + ((u8*)res.data)[r_i] = 0; | |
| 7257 | + for (int c1 = 1; c1 < dec_digit + 1; ++c1) { | |
| 7258 | + if (((u8*)res.data)[(int)(r_i - c1)] == 0) { | |
| 7259 | + ((u8*)res.data)[(int)(r_i - c1)] = '0'; | |
| 7260 | + } | |
| 7261 | + } | |
| 7262 | + string tmp_res = builtin__string_clone(builtin__tos(res.data, r_i)); | |
| 7263 | + builtin__array_free(&res); | |
| 7264 | + return tmp_res; | |
| 7265 | + } else { | |
| 7266 | + if (dec_digit > 0) { | |
| 7267 | + int c1 = 0; | |
| 7268 | + ((u8*)res.data)[r_i] = '.'; | |
| 7269 | + r_i++; | |
| 7270 | + for (;;) { | |
| 7271 | + if (!(c1 < dec_digit)) break; | |
| 7272 | + ((u8*)res.data)[r_i] = '0'; | |
| 7273 | + r_i++; | |
| 7274 | + c1++; | |
| 7275 | + } | |
| 7276 | + ((u8*)res.data)[r_i] = 0; | |
| 7277 | + } | |
| 7278 | + string tmp_res = builtin__string_clone(builtin__tos(res.data, r_i)); | |
| 7279 | + builtin__array_free(&res); | |
| 7280 | + return tmp_res; | |
| 7281 | + } | |
| 7282 | + } | |
| 7283 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 7284 | +} | |
| 7285 | +string strconv__format_fl(f64 f, strconv__BF_param p) { | |
| 7286 | + { // Unsafe block | |
| 7287 | + string fs = strconv__f64_to_str_lnd1((f >= ((f64)(0.0)) ? (f) : (-f)), p.len1); | |
| 7288 | + if (fs.str[ 0] == '[') { | |
| 7289 | + return fs; | |
| 7290 | + } | |
| 7291 | + if (p.rm_tail_zero) { | |
| 7292 | + string tmp = fs; | |
| 7293 | + fs = strconv__remove_tail_zeros(fs); | |
| 7294 | + builtin__string_free(&tmp); | |
| 7295 | + } | |
| 7296 | + Array_fixed_u8_512 buf = {0}; | |
| 7297 | + Array_fixed_u8_512 out = {0}; | |
| 7298 | + int buf_i = 0; | |
| 7299 | + int out_i = 0; | |
| 7300 | + int sign_len_diff = 0; | |
| 7301 | + if (p.pad_ch == '0') { | |
| 7302 | + if (p.positive) { | |
| 7303 | + if (p.sign_flag) { | |
| 7304 | + out[out_i] = '+'; | |
| 7305 | + out_i++; | |
| 7306 | + sign_len_diff = -1; | |
| 7307 | + } | |
| 7308 | + } else { | |
| 7309 | + out[out_i] = '-'; | |
| 7310 | + out_i++; | |
| 7311 | + sign_len_diff = -1; | |
| 7312 | + } | |
| 7313 | + } else { | |
| 7314 | + if (p.positive) { | |
| 7315 | + if (p.sign_flag) { | |
| 7316 | + buf[buf_i] = '+'; | |
| 7317 | + buf_i++; | |
| 7318 | + } | |
| 7319 | + } else { | |
| 7320 | + buf[buf_i] = '-'; | |
| 7321 | + buf_i++; | |
| 7322 | + } | |
| 7323 | + } | |
| 7324 | + builtin__vmemcpy(&buf[buf_i], fs.str, fs.len); | |
| 7325 | + buf_i += fs.len; | |
| 7326 | + int dif = p.len0 - buf_i + sign_len_diff; | |
| 7327 | + if (p.align == strconv__Align_text__right) { | |
| 7328 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 7329 | + out[out_i] = p.pad_ch; | |
| 7330 | + out_i++; | |
| 7331 | + } | |
| 7332 | + } | |
| 7333 | + builtin__vmemcpy(&out[out_i], &buf[0], buf_i); | |
| 7334 | + out_i += buf_i; | |
| 7335 | + if (p.align == strconv__Align_text__left) { | |
| 7336 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 7337 | + out[out_i] = p.pad_ch; | |
| 7338 | + out_i++; | |
| 7339 | + } | |
| 7340 | + } | |
| 7341 | + out[out_i] = 0; | |
| 7342 | + string tmp = fs; | |
| 7343 | + fs = builtin__tos_clone(&out[0]); | |
| 7344 | + builtin__string_free(&tmp); | |
| 7345 | + return fs; | |
| 7346 | + } | |
| 7347 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 7348 | +} | |
| 7349 | +string strconv__format_es(f64 f, strconv__BF_param p) { | |
| 7350 | + { // Unsafe block | |
| 7351 | + string fs = strconv__f64_to_str_pad((f > 0 ? (f) : (-f)), p.len1); | |
| 7352 | + if (p.rm_tail_zero) { | |
| 7353 | + string tmp = fs; | |
| 7354 | + fs = strconv__remove_tail_zeros(fs); | |
| 7355 | + builtin__string_free(&tmp); | |
| 7356 | + } | |
| 7357 | + Array_fixed_u8_512 buf = {0}; | |
| 7358 | + Array_fixed_u8_512 out = {0}; | |
| 7359 | + int buf_i = 0; | |
| 7360 | + int out_i = 0; | |
| 7361 | + int sign_len_diff = 0; | |
| 7362 | + if (p.pad_ch == '0') { | |
| 7363 | + if (p.positive) { | |
| 7364 | + if (p.sign_flag) { | |
| 7365 | + out[out_i] = '+'; | |
| 7366 | + out_i++; | |
| 7367 | + sign_len_diff = -1; | |
| 7368 | + } | |
| 7369 | + } else { | |
| 7370 | + out[out_i] = '-'; | |
| 7371 | + out_i++; | |
| 7372 | + sign_len_diff = -1; | |
| 7373 | + } | |
| 7374 | + } else { | |
| 7375 | + if (p.positive) { | |
| 7376 | + if (p.sign_flag) { | |
| 7377 | + buf[buf_i] = '+'; | |
| 7378 | + buf_i++; | |
| 7379 | + } | |
| 7380 | + } else { | |
| 7381 | + buf[buf_i] = '-'; | |
| 7382 | + buf_i++; | |
| 7383 | + } | |
| 7384 | + } | |
| 7385 | + builtin__vmemcpy(&buf[buf_i], fs.str, fs.len); | |
| 7386 | + buf_i += fs.len; | |
| 7387 | + int dif = p.len0 - buf_i + sign_len_diff; | |
| 7388 | + if (p.align == strconv__Align_text__right) { | |
| 7389 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 7390 | + out[out_i] = p.pad_ch; | |
| 7391 | + out_i++; | |
| 7392 | + } | |
| 7393 | + } | |
| 7394 | + builtin__vmemcpy(&out[out_i], &buf[0], buf_i); | |
| 7395 | + out_i += buf_i; | |
| 7396 | + if (p.align == strconv__Align_text__left) { | |
| 7397 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 7398 | + out[out_i] = p.pad_ch; | |
| 7399 | + out_i++; | |
| 7400 | + } | |
| 7401 | + } | |
| 7402 | + out[out_i] = 0; | |
| 7403 | + string tmp = fs; | |
| 7404 | + fs = builtin__tos_clone(&out[0]); | |
| 7405 | + builtin__string_free(&tmp); | |
| 7406 | + return fs; | |
| 7407 | + } | |
| 7408 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 7409 | +} | |
| 7410 | +string strconv__remove_tail_zeros(string s) { | |
| 7411 | + { // Unsafe block | |
| 7412 | + u8* buf = builtin__malloc_noscan(s.len + 1); | |
| 7413 | + int i_d = 0; | |
| 7414 | + int i_s = 0; | |
| 7415 | + for (;;) { | |
| 7416 | + if (!(i_s < s.len && !(s.str[ i_s] == '-' || s.str[ i_s] == '+') && (s.str[ i_s] > '9' || s.str[ i_s] < '0'))) break; | |
| 7417 | + buf[i_d] = s.str[ i_s]; | |
| 7418 | + i_s++; | |
| 7419 | + i_d++; | |
| 7420 | + } | |
| 7421 | + if (i_s < s.len && (s.str[ i_s] == '-' || s.str[ i_s] == '+')) { | |
| 7422 | + buf[i_d] = s.str[ i_s]; | |
| 7423 | + i_s++; | |
| 7424 | + i_d++; | |
| 7425 | + } | |
| 7426 | + for (;;) { | |
| 7427 | + if (!(i_s < s.len && s.str[ i_s] >= '0' && s.str[ i_s] <= '9')) break; | |
| 7428 | + buf[i_d] = s.str[ i_s]; | |
| 7429 | + i_s++; | |
| 7430 | + i_d++; | |
| 7431 | + } | |
| 7432 | + if (i_s < s.len && s.str[ i_s] == '.') { | |
| 7433 | + int i_s1 = i_s + 1; | |
| 7434 | + int sum = 0; | |
| 7435 | + int i_s2 = i_s1; | |
| 7436 | + for (;;) { | |
| 7437 | + if (!(i_s1 < s.len && s.str[ i_s1] >= '0' && s.str[ i_s1] <= '9')) break; | |
| 7438 | + sum += (s.str[ i_s1] - ((u8)('0'))); | |
| 7439 | + if (s.str[ i_s1] != '0') { | |
| 7440 | + i_s2 = i_s1; | |
| 7441 | + } | |
| 7442 | + i_s1++; | |
| 7443 | + } | |
| 7444 | + if (sum > 0) { | |
| 7445 | + for (int c_i = i_s; c_i < i_s2 + 1; ++c_i) { | |
| 7446 | + buf[i_d] = s.str[ c_i]; | |
| 7447 | + i_d++; | |
| 7448 | + } | |
| 7449 | + } | |
| 7450 | + i_s = i_s1; | |
| 7451 | + } | |
| 7452 | + if (i_s < s.len && s.str[ i_s] != '.') { | |
| 7453 | + for (;;) { | |
| 7454 | + buf[i_d] = s.str[ i_s]; | |
| 7455 | + i_s++; | |
| 7456 | + i_d++; | |
| 7457 | + if (i_s >= s.len) { | |
| 7458 | + break; | |
| 7459 | + } | |
| 7460 | + } | |
| 7461 | + } | |
| 7462 | + buf[i_d] = 0; | |
| 7463 | + return builtin__tos(buf, i_d); | |
| 7464 | + } | |
| 7465 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 7466 | +} | |
| 7467 | +inline string strconv__ftoa_64(f64 f) { | |
| 7468 | + return strconv__f64_to_str(f, 17); | |
| 7469 | +} | |
| 7470 | +inline string strconv__ftoa_long_64(f64 f) { | |
| 7471 | + return strconv__f64_to_str_l(f); | |
| 7472 | +} | |
| 7473 | +inline string strconv__ftoa_32(f32 f) { | |
| 7474 | + return strconv__f32_to_str(f, 8); | |
| 7475 | +} | |
| 7476 | +inline string strconv__ftoa_long_32(f32 f) { | |
| 7477 | + return strconv__f32_to_str_l(f); | |
| 7478 | +} | |
| 7479 | +string strconv__format_int(i64 n, int radix) { | |
| 7480 | + { // Unsafe block | |
| 7481 | + if (radix < 2 || radix > 36) { | |
| 7482 | + builtin__panic_n(_S("invalid radix, it should be => 2 and <= 36, actual:"), radix); | |
| 7483 | + VUNREACHABLE(); | |
| 7484 | + } | |
| 7485 | + if (n == 0) { | |
| 7486 | + return _S("0"); | |
| 7487 | + } | |
| 7488 | + i64 n_copy = n; | |
| 7489 | + bool have_minus = false; | |
| 7490 | + if (n < 0) { | |
| 7491 | + have_minus = true; | |
| 7492 | + n_copy = -n_copy; | |
| 7493 | + } | |
| 7494 | + string res = _S(""); | |
| 7495 | + for (;;) { | |
| 7496 | + if (!(n_copy != 0)) break; | |
| 7497 | + string tmp_0 = res; | |
| 7498 | + int bdx = ((int)((i64)(VSAFE_MOD_i64(n_copy , radix)))); | |
| 7499 | + string tmp_1 = builtin__u8_ascii_str(_const_strconv__base_digits.str[ bdx]); | |
| 7500 | + res = builtin__string__plus(tmp_1, res); | |
| 7501 | + builtin__string_free(&tmp_0); | |
| 7502 | + builtin__string_free(&tmp_1); | |
| 7503 | + n_copy = VSAFE_DIV_i64(n_copy,radix); | |
| 7504 | + } | |
| 7505 | + if (have_minus) { | |
| 7506 | + string final_res = builtin__string__plus(_S("-"), res); | |
| 7507 | + builtin__string_free(&res); | |
| 7508 | + return final_res; | |
| 7509 | + } | |
| 7510 | + return res; | |
| 7511 | + } | |
| 7512 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 7513 | +} | |
| 7514 | +string strconv__format_uint(u64 n, int radix) { | |
| 7515 | + { // Unsafe block | |
| 7516 | + if (radix < 2 || radix > 36) { | |
| 7517 | + builtin__panic_n(_S("invalid radix, it should be => 2 and <= 36, actual:"), radix); | |
| 7518 | + VUNREACHABLE(); | |
| 7519 | + } | |
| 7520 | + if (n == 0) { | |
| 7521 | + return _S("0"); | |
| 7522 | + } | |
| 7523 | + u64 n_copy = n; | |
| 7524 | + string res = _S(""); | |
| 7525 | + u64 uradix = ((u64)(radix)); | |
| 7526 | + for (;;) { | |
| 7527 | + if (!(n_copy != 0)) break; | |
| 7528 | + string tmp_0 = res; | |
| 7529 | + string tmp_1 = builtin__u8_ascii_str(_const_strconv__base_digits.str[ ((int)(VSAFE_MOD_u64(n_copy , uradix)))]); | |
| 7530 | + res = builtin__string__plus(tmp_1, res); | |
| 7531 | + builtin__string_free(&tmp_0); | |
| 7532 | + builtin__string_free(&tmp_1); | |
| 7533 | + n_copy = VSAFE_DIV_u64(n_copy,uradix); | |
| 7534 | + } | |
| 7535 | + return res; | |
| 7536 | + } | |
| 7537 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 7538 | +} | |
| 7539 | +string strconv__f32_to_str_l(f32 f) { | |
| 7540 | + string s = strconv__f32_to_str(f, 8); | |
| 7541 | + string res = strconv__fxx_to_str_l_parse(s); | |
| 7542 | + builtin__string_free(&s); | |
| 7543 | + return res; | |
| 7544 | +} | |
| 7545 | +string strconv__f32_to_str_l_with_dot(f32 f) { | |
| 7546 | + string s = strconv__f32_to_str(f, 8); | |
| 7547 | + string res = strconv__fxx_to_str_l_parse_with_dot(s); | |
| 7548 | + builtin__string_free(&s); | |
| 7549 | + return res; | |
| 7550 | +} | |
| 7551 | +string strconv__f64_to_str_l(f64 f) { | |
| 7552 | + string s = strconv__f64_to_str(f, 18); | |
| 7553 | + string res = strconv__fxx_to_str_l_parse(s); | |
| 7554 | + builtin__string_free(&s); | |
| 7555 | + return res; | |
| 7556 | +} | |
| 7557 | +string strconv__f64_to_str_l_with_dot(f64 f) { | |
| 7558 | + string s = strconv__f64_to_str(f, 18); | |
| 7559 | + string res = strconv__fxx_to_str_l_parse_with_dot(s); | |
| 7560 | + builtin__string_free(&s); | |
| 7561 | + return res; | |
| 7562 | +} | |
| 7563 | +string strconv__fxx_to_str_l_parse(string s) { | |
| 7564 | + if (s.len > 2 && (s.str[ 0] == 'n' || s.str[ 1] == 'i')) { | |
| 7565 | + return builtin__string_clone(s); | |
| 7566 | + } | |
| 7567 | + bool m_sgn_flag = false; | |
| 7568 | + int sgn = 1; | |
| 7569 | + Array_fixed_u8_26 b = {0}; | |
| 7570 | + int d_pos = 1; | |
| 7571 | + int i = 0; | |
| 7572 | + int i1 = 0; | |
| 7573 | + int exp = 0; | |
| 7574 | + int exp_sgn = 1; | |
| 7575 | + for (int _t2 = 0; _t2 < s.len; ++_t2) { | |
| 7576 | + u8 c = s.str[_t2]; | |
| 7577 | + if (c == '-') { | |
| 7578 | + sgn = -1; | |
| 7579 | + i++; | |
| 7580 | + } else if (c == '+') { | |
| 7581 | + sgn = 1; | |
| 7582 | + i++; | |
| 7583 | + } else if (c >= '0' && c <= '9') { | |
| 7584 | + b[i1] = c; | |
| 7585 | + i1++; | |
| 7586 | + i++; | |
| 7587 | + } else if (c == '.') { | |
| 7588 | + if (sgn > 0) { | |
| 7589 | + d_pos = i; | |
| 7590 | + } else { | |
| 7591 | + d_pos = i - 1; | |
| 7592 | + } | |
| 7593 | + i++; | |
| 7594 | + } else if (c == 'e') { | |
| 7595 | + i++; | |
| 7596 | + break; | |
| 7597 | + } else { | |
| 7598 | + return _S("Float conversion error!!"); | |
| 7599 | + } | |
| 7600 | + } | |
| 7601 | + b[i1] = 0; | |
| 7602 | + if (s.str[ i] == '-') { | |
| 7603 | + exp_sgn = -1; | |
| 7604 | + i++; | |
| 7605 | + } else if (s.str[ i] == '+') { | |
| 7606 | + exp_sgn = 1; | |
| 7607 | + i++; | |
| 7608 | + } | |
| 7609 | + int c = i; | |
| 7610 | + for (;;) { | |
| 7611 | + if (!(c < s.len)) break; | |
| 7612 | + exp = exp * 10 + ((int)((rune)(s.str[ c] - '0'))); | |
| 7613 | + c++; | |
| 7614 | + } | |
| 7615 | + Array_u8 res = builtin____new_array_with_default(exp + 32, 0, sizeof(u8), &(u8[]){0}); | |
| 7616 | + int r_i = 0; | |
| 7617 | + if (sgn == 1) { | |
| 7618 | + if (m_sgn_flag) { | |
| 7619 | + ((u8*)res.data)[r_i] = '+'; | |
| 7620 | + r_i++; | |
| 7621 | + } | |
| 7622 | + } else { | |
| 7623 | + ((u8*)res.data)[r_i] = '-'; | |
| 7624 | + r_i++; | |
| 7625 | + } | |
| 7626 | + i = 0; | |
| 7627 | + if (exp_sgn >= 0) { | |
| 7628 | + for (;;) { | |
| 7629 | + if (!(b[i] != 0)) break; | |
| 7630 | + ((u8*)res.data)[r_i] = b[i]; | |
| 7631 | + r_i++; | |
| 7632 | + i++; | |
| 7633 | + if (i >= d_pos && exp >= 0) { | |
| 7634 | + if (exp == 0) { | |
| 7635 | + ((u8*)res.data)[r_i] = '.'; | |
| 7636 | + r_i++; | |
| 7637 | + } | |
| 7638 | + exp--; | |
| 7639 | + } | |
| 7640 | + } | |
| 7641 | + for (;;) { | |
| 7642 | + if (!(exp >= 0)) break; | |
| 7643 | + ((u8*)res.data)[r_i] = '0'; | |
| 7644 | + r_i++; | |
| 7645 | + exp--; | |
| 7646 | + } | |
| 7647 | + } else { | |
| 7648 | + bool dot_p = true; | |
| 7649 | + for (;;) { | |
| 7650 | + if (!(exp > 0)) break; | |
| 7651 | + ((u8*)res.data)[r_i] = '0'; | |
| 7652 | + r_i++; | |
| 7653 | + exp--; | |
| 7654 | + if (dot_p) { | |
| 7655 | + ((u8*)res.data)[r_i] = '.'; | |
| 7656 | + r_i++; | |
| 7657 | + dot_p = false; | |
| 7658 | + } | |
| 7659 | + } | |
| 7660 | + for (;;) { | |
| 7661 | + if (!(b[i] != 0)) break; | |
| 7662 | + ((u8*)res.data)[r_i] = b[i]; | |
| 7663 | + r_i++; | |
| 7664 | + i++; | |
| 7665 | + } | |
| 7666 | + } | |
| 7667 | + if (r_i > 1 && ((u8*)res.data)[r_i - 1] == '.') { | |
| 7668 | + ((u8*)res.data)[r_i] = '0'; | |
| 7669 | + r_i++; | |
| 7670 | + } else if (!(Array_u8_contains(res, '.'))) { | |
| 7671 | + ((u8*)res.data)[r_i] = '.'; | |
| 7672 | + r_i++; | |
| 7673 | + ((u8*)res.data)[r_i] = '0'; | |
| 7674 | + r_i++; | |
| 7675 | + } | |
| 7676 | + ((u8*)res.data)[r_i] = 0; | |
| 7677 | + string tmp_res = builtin__string_clone(builtin__tos(res.data, r_i)); | |
| 7678 | + builtin__array_free(&res); | |
| 7679 | + return tmp_res; | |
| 7680 | +} | |
| 7681 | +string strconv__fxx_to_str_l_parse_with_dot(string s) { | |
| 7682 | + if (s.len > 2 && (s.str[ 0] == 'n' || s.str[ 1] == 'i')) { | |
| 7683 | + return builtin__string_clone(s); | |
| 7684 | + } | |
| 7685 | + bool m_sgn_flag = false; | |
| 7686 | + int sgn = 1; | |
| 7687 | + Array_fixed_u8_26 b = {0}; | |
| 7688 | + int d_pos = 1; | |
| 7689 | + int i = 0; | |
| 7690 | + int i1 = 0; | |
| 7691 | + int exp = 0; | |
| 7692 | + int exp_sgn = 1; | |
| 7693 | + for (int _t2 = 0; _t2 < s.len; ++_t2) { | |
| 7694 | + u8 c = s.str[_t2]; | |
| 7695 | + if (c == '-') { | |
| 7696 | + sgn = -1; | |
| 7697 | + i++; | |
| 7698 | + } else if (c == '+') { | |
| 7699 | + sgn = 1; | |
| 7700 | + i++; | |
| 7701 | + } else if (c >= '0' && c <= '9') { | |
| 7702 | + b[i1] = c; | |
| 7703 | + i1++; | |
| 7704 | + i++; | |
| 7705 | + } else if (c == '.') { | |
| 7706 | + if (sgn > 0) { | |
| 7707 | + d_pos = i; | |
| 7708 | + } else { | |
| 7709 | + d_pos = i - 1; | |
| 7710 | + } | |
| 7711 | + i++; | |
| 7712 | + } else if (c == 'e') { | |
| 7713 | + i++; | |
| 7714 | + break; | |
| 7715 | + } else { | |
| 7716 | + return _S("Float conversion error!!"); | |
| 7717 | + } | |
| 7718 | + } | |
| 7719 | + b[i1] = 0; | |
| 7720 | + if (s.str[ i] == '-') { | |
| 7721 | + exp_sgn = -1; | |
| 7722 | + i++; | |
| 7723 | + } else if (s.str[ i] == '+') { | |
| 7724 | + exp_sgn = 1; | |
| 7725 | + i++; | |
| 7726 | + } | |
| 7727 | + int c = i; | |
| 7728 | + for (;;) { | |
| 7729 | + if (!(c < s.len)) break; | |
| 7730 | + exp = exp * 10 + ((int)((rune)(s.str[ c] - '0'))); | |
| 7731 | + c++; | |
| 7732 | + } | |
| 7733 | + Array_u8 res = builtin____new_array_with_default(exp + 32, 0, sizeof(u8), &(u8[]){0}); | |
| 7734 | + int r_i = 0; | |
| 7735 | + if (sgn == 1) { | |
| 7736 | + if (m_sgn_flag) { | |
| 7737 | + ((u8*)res.data)[r_i] = '+'; | |
| 7738 | + r_i++; | |
| 7739 | + } | |
| 7740 | + } else { | |
| 7741 | + ((u8*)res.data)[r_i] = '-'; | |
| 7742 | + r_i++; | |
| 7743 | + } | |
| 7744 | + i = 0; | |
| 7745 | + if (exp_sgn >= 0) { | |
| 7746 | + for (;;) { | |
| 7747 | + if (!(b[i] != 0)) break; | |
| 7748 | + ((u8*)res.data)[r_i] = b[i]; | |
| 7749 | + r_i++; | |
| 7750 | + i++; | |
| 7751 | + if (i >= d_pos && exp >= 0) { | |
| 7752 | + if (exp == 0) { | |
| 7753 | + ((u8*)res.data)[r_i] = '.'; | |
| 7754 | + r_i++; | |
| 7755 | + } | |
| 7756 | + exp--; | |
| 7757 | + } | |
| 7758 | + } | |
| 7759 | + for (;;) { | |
| 7760 | + if (!(exp >= 0)) break; | |
| 7761 | + ((u8*)res.data)[r_i] = '0'; | |
| 7762 | + r_i++; | |
| 7763 | + exp--; | |
| 7764 | + } | |
| 7765 | + } else { | |
| 7766 | + bool dot_p = true; | |
| 7767 | + for (;;) { | |
| 7768 | + if (!(exp > 0)) break; | |
| 7769 | + ((u8*)res.data)[r_i] = '0'; | |
| 7770 | + r_i++; | |
| 7771 | + exp--; | |
| 7772 | + if (dot_p) { | |
| 7773 | + ((u8*)res.data)[r_i] = '.'; | |
| 7774 | + r_i++; | |
| 7775 | + dot_p = false; | |
| 7776 | + } | |
| 7777 | + } | |
| 7778 | + for (;;) { | |
| 7779 | + if (!(b[i] != 0)) break; | |
| 7780 | + ((u8*)res.data)[r_i] = b[i]; | |
| 7781 | + r_i++; | |
| 7782 | + i++; | |
| 7783 | + } | |
| 7784 | + } | |
| 7785 | + if (r_i > 1 && ((u8*)res.data)[r_i - 1] == '.') { | |
| 7786 | + ((u8*)res.data)[r_i] = '0'; | |
| 7787 | + r_i++; | |
| 7788 | + } else if (!(Array_u8_contains(res, '.'))) { | |
| 7789 | + ((u8*)res.data)[r_i] = '.'; | |
| 7790 | + r_i++; | |
| 7791 | + ((u8*)res.data)[r_i] = '0'; | |
| 7792 | + r_i++; | |
| 7793 | + } | |
| 7794 | + ((u8*)res.data)[r_i] = 0; | |
| 7795 | + string tmp_res = builtin__string_clone(builtin__tos(res.data, r_i)); | |
| 7796 | + builtin__array_free(&res); | |
| 7797 | + return tmp_res; | |
| 7798 | +} | |
| 7799 | +inline VV_LOC u32 strconv__bool_to_u32(bool b) { | |
| 7800 | + if (b) { | |
| 7801 | + return ((u32)(1)); | |
| 7802 | + } | |
| 7803 | + return ((u32)(0)); | |
| 7804 | +} | |
| 7805 | +inline VV_LOC u64 strconv__bool_to_u64(bool b) { | |
| 7806 | + if (b) { | |
| 7807 | + return ((u64)(1)); | |
| 7808 | + } | |
| 7809 | + return ((u64)(0)); | |
| 7810 | +} | |
| 7811 | +VV_LOC string strconv__get_string_special(bool neg, bool expZero, bool mantZero) { | |
| 7812 | + if (!mantZero) { | |
| 7813 | + return _S("nan"); | |
| 7814 | + } | |
| 7815 | + if (!expZero) { | |
| 7816 | + if (neg) { | |
| 7817 | + return _S("-inf"); | |
| 7818 | + } else { | |
| 7819 | + return _S("+inf"); | |
| 7820 | + } | |
| 7821 | + } | |
| 7822 | + if (neg) { | |
| 7823 | + return _S("-0e+00"); | |
| 7824 | + } | |
| 7825 | + return _S("0e+00"); | |
| 7826 | +} | |
| 7827 | +VV_LOC u32 strconv__mul_shift_32(u32 m, u64 mul, int ishift) { | |
| 7828 | + multi_return_u64_u64 mr_750 = math__bits__mul_64(((u64)(m)), mul); | |
| 7829 | + u64 hi = mr_750.arg0; | |
| 7830 | + u64 lo = mr_750.arg1; | |
| 7831 | + u64 shifted_sum = (v__rshift_u64(lo, (u64)((u64)(ishift)))) + (v__lshift_u64(hi, (u64)((u64)(64 - ishift)))); | |
| 7832 | + ; | |
| 7833 | + return ((u32)(shifted_sum)); | |
| 7834 | +} | |
| 7835 | +inline VV_LOC u32 strconv__mul_pow5_invdiv_pow2(u32 m, u32 q, int j) { | |
| 7836 | + ; | |
| 7837 | + return strconv__mul_shift_32(m, _const_strconv__pow5_inv_split_32[q], j); | |
| 7838 | +} | |
| 7839 | +inline VV_LOC u32 strconv__mul_pow5_div_pow2(u32 m, u32 i, int j) { | |
| 7840 | + ; | |
| 7841 | + return strconv__mul_shift_32(m, _const_strconv__pow5_split_32[i], j); | |
| 7842 | +} | |
| 7843 | +VV_LOC u32 strconv__pow5_factor_32(u32 i_v) { | |
| 7844 | + u32 v = i_v; | |
| 7845 | + for (u32 n = ((u32)(0)); true; n++) { | |
| 7846 | + u32 q = VSAFE_DIV_u32(v , 5); | |
| 7847 | + u32 r = VSAFE_MOD_u32(v , 5); | |
| 7848 | + if (r != 0) { | |
| 7849 | + return n; | |
| 7850 | + } | |
| 7851 | + v = q; | |
| 7852 | + } | |
| 7853 | + return v; | |
| 7854 | +} | |
| 7855 | +VV_LOC bool strconv__multiple_of_power_of_five_32(u32 v, u32 p) { | |
| 7856 | + return strconv__pow5_factor_32(v) >= p; | |
| 7857 | +} | |
| 7858 | +VV_LOC bool strconv__multiple_of_power_of_two_32(u32 v, u32 p) { | |
| 7859 | + return ((u32)(math__bits__trailing_zeros_32(v))) >= p; | |
| 7860 | +} | |
| 7861 | +VV_LOC u32 strconv__log10_pow2(int e) { | |
| 7862 | + ; | |
| 7863 | + ; | |
| 7864 | + return v__rshift_u32((((u32)(e)) * 78913), (u64)18); | |
| 7865 | +} | |
| 7866 | +VV_LOC u32 strconv__log10_pow5(int e) { | |
| 7867 | + ; | |
| 7868 | + ; | |
| 7869 | + return v__rshift_u32((((u32)(e)) * 732923), (u64)20); | |
| 7870 | +} | |
| 7871 | +VV_LOC int strconv__pow5_bits(int e) { | |
| 7872 | + ; | |
| 7873 | + ; | |
| 7874 | + return ((int)((v__rshift_u32((((u32)(e)) * 1217359), (u64)19)) + 1)); | |
| 7875 | +} | |
| 7876 | +VV_LOC u64 strconv__shift_right_128(strconv__Uint128 v, int shift) { | |
| 7877 | + ; | |
| 7878 | + return ((v__lshift_u64(v.hi, (u64)((u64)(64 - shift)))) | (v__rshift_u64(v.lo, (u64)((u32)(shift))))); | |
| 7879 | +} | |
| 7880 | +VV_LOC u64 strconv__mul_shift_64(u64 m, strconv__Uint128 mul, int shift) { | |
| 7881 | + multi_return_u64_u64 mr_3253 = math__bits__mul_64(m, mul.hi); | |
| 7882 | + u64 hihi = mr_3253.arg0; | |
| 7883 | + u64 hilo = mr_3253.arg1; | |
| 7884 | + multi_return_u64_u64 mr_3288 = math__bits__mul_64(m, mul.lo); | |
| 7885 | + u64 lohi = mr_3288.arg0; | |
| 7886 | + strconv__Uint128 sum = ((strconv__Uint128){.lo = lohi + hilo,.hi = hihi,}); | |
| 7887 | + if (sum.lo < lohi) { | |
| 7888 | + sum.hi++; | |
| 7889 | + } | |
| 7890 | + return strconv__shift_right_128(sum, shift - 64); | |
| 7891 | +} | |
| 7892 | +VV_LOC u32 strconv__pow5_factor_64(u64 v_i) { | |
| 7893 | + u64 v = v_i; | |
| 7894 | + for (u32 n = ((u32)(0)); true; n++) { | |
| 7895 | + u64 q = VSAFE_DIV_u64(v , 5); | |
| 7896 | + u64 r = VSAFE_MOD_u64(v , 5); | |
| 7897 | + if (r != 0) { | |
| 7898 | + return n; | |
| 7899 | + } | |
| 7900 | + v = q; | |
| 7901 | + } | |
| 7902 | + return ((u32)(0)); | |
| 7903 | +} | |
| 7904 | +VV_LOC bool strconv__multiple_of_power_of_five_64(u64 v, u32 p) { | |
| 7905 | + return strconv__pow5_factor_64(v) >= p; | |
| 7906 | +} | |
| 7907 | +VV_LOC bool strconv__multiple_of_power_of_two_64(u64 v, u32 p) { | |
| 7908 | + return ((u32)(math__bits__trailing_zeros_64(v))) >= p; | |
| 7909 | +} | |
| 7910 | +int strconv__dec_digits(u64 n) { | |
| 7911 | + if (n <= 9999999999LL) { | |
| 7912 | + if (n <= 99999) { | |
| 7913 | + if (n <= 99) { | |
| 7914 | + if (n <= 9) { | |
| 7915 | + return 1; | |
| 7916 | + } else { | |
| 7917 | + return 2; | |
| 7918 | + } | |
| 7919 | + } else { | |
| 7920 | + if (n <= 999) { | |
| 7921 | + return 3; | |
| 7922 | + } else { | |
| 7923 | + if (n <= 9999) { | |
| 7924 | + return 4; | |
| 7925 | + } else { | |
| 7926 | + return 5; | |
| 7927 | + } | |
| 7928 | + } | |
| 7929 | + } | |
| 7930 | + } else { | |
| 7931 | + if (n <= 9999999) { | |
| 7932 | + if (n <= 999999) { | |
| 7933 | + return 6; | |
| 7934 | + } else { | |
| 7935 | + return 7; | |
| 7936 | + } | |
| 7937 | + } else { | |
| 7938 | + if (n <= 99999999) { | |
| 7939 | + return 8; | |
| 7940 | + } else { | |
| 7941 | + if (n <= 999999999) { | |
| 7942 | + return 9; | |
| 7943 | + } | |
| 7944 | + return 10; | |
| 7945 | + } | |
| 7946 | + } | |
| 7947 | + } | |
| 7948 | + } else { | |
| 7949 | + if (n <= 999999999999999LL) { | |
| 7950 | + if (n <= 999999999999LL) { | |
| 7951 | + if (n <= 99999999999LL) { | |
| 7952 | + return 11; | |
| 7953 | + } else { | |
| 7954 | + return 12; | |
| 7955 | + } | |
| 7956 | + } else { | |
| 7957 | + if (n <= 9999999999999LL) { | |
| 7958 | + return 13; | |
| 7959 | + } else { | |
| 7960 | + if (n <= 99999999999999LL) { | |
| 7961 | + return 14; | |
| 7962 | + } else { | |
| 7963 | + return 15; | |
| 7964 | + } | |
| 7965 | + } | |
| 7966 | + } | |
| 7967 | + } else { | |
| 7968 | + if (n <= 99999999999999999LL) { | |
| 7969 | + if (n <= 9999999999999999LL) { | |
| 7970 | + return 16; | |
| 7971 | + } else { | |
| 7972 | + return 17; | |
| 7973 | + } | |
| 7974 | + } else { | |
| 7975 | + if (n <= 999999999999999999LL) { | |
| 7976 | + return 18; | |
| 7977 | + } else { | |
| 7978 | + if (n <= 9999999999999999999ULL) { | |
| 7979 | + return 19; | |
| 7980 | + } | |
| 7981 | + return 20; | |
| 7982 | + } | |
| 7983 | + } | |
| 7984 | + } | |
| 7985 | + } | |
| 7986 | + return 0; | |
| 7987 | +} | |
| 7988 | +void strconv__v_printf(string str, Array_voidptr pt) { | |
| 7989 | + Array_voidptr _t1 = pt; | |
| 7990 | + Array_voidptr _t2 = builtin____new_array(0, _t1.len, sizeof(voidptr)); | |
| 7991 | + for (int _t3 = 0; _t3 < _t1.len; ++_t3) { | |
| 7992 | + voidptr _t4 = (*(voidptr*)builtin__array_get(_t1, _t3)); | |
| 7993 | + builtin__array_push((array*)&_t2, &_t4); | |
| 7994 | + } | |
| 7995 | + builtin__print(strconv__v_sprintf(str,_t2)); | |
| 7996 | +} | |
| 7997 | +string strconv__v_sprintf(string str, Array_voidptr pt) { | |
| 7998 | + strings__Builder res = strings__new_builder(pt.len * 16); | |
| 7999 | + int i = 0; | |
| 8000 | + int p_index = 0; | |
| 8001 | + bool sign = false; | |
| 8002 | + strconv__Align_text align = strconv__Align_text__right; | |
| 8003 | + int len0 = -1; | |
| 8004 | + int len1 = -1; | |
| 8005 | + int def_len1 = 6; | |
| 8006 | + u8 pad_ch = ((u8)(' ')); | |
| 8007 | + rune ch1 = '0'; | |
| 8008 | + rune ch2 = '0'; | |
| 8009 | + strconv__Char_parse_state status = strconv__Char_parse_state__norm_char; | |
| 8010 | + for (;;) { | |
| 8011 | + if (!(i < str.len)) break; | |
| 8012 | + if (status == strconv__Char_parse_state__reset_params) { | |
| 8013 | + sign = false; | |
| 8014 | + align = strconv__Align_text__right; | |
| 8015 | + len0 = -1; | |
| 8016 | + len1 = -1; | |
| 8017 | + pad_ch = ' '; | |
| 8018 | + status = strconv__Char_parse_state__norm_char; | |
| 8019 | + ch1 = '0'; | |
| 8020 | + ch2 = '0'; | |
| 8021 | + continue; | |
| 8022 | + } | |
| 8023 | + u8 ch = str.str[ i]; | |
| 8024 | + if (ch != '%' && status == strconv__Char_parse_state__norm_char) { | |
| 8025 | + strings__Builder_write_u8(&res, ch); | |
| 8026 | + i++; | |
| 8027 | + continue; | |
| 8028 | + } | |
| 8029 | + if (ch == '%' && status == strconv__Char_parse_state__field_char) { | |
| 8030 | + status = strconv__Char_parse_state__norm_char; | |
| 8031 | + strings__Builder_write_u8(&res, ch); | |
| 8032 | + i++; | |
| 8033 | + continue; | |
| 8034 | + } | |
| 8035 | + if (ch == '%' && status == strconv__Char_parse_state__norm_char) { | |
| 8036 | + status = strconv__Char_parse_state__field_char; | |
| 8037 | + i++; | |
| 8038 | + continue; | |
| 8039 | + } | |
| 8040 | + if (ch == 'c' && status == strconv__Char_parse_state__field_char) { | |
| 8041 | + strconv__v_sprintf_panic(p_index, pt.len); | |
| 8042 | + u8 d1 = ((u8)(*(((int*)(((voidptr*)pt.data)[p_index]))))); | |
| 8043 | + strings__Builder_write_u8(&res, d1); | |
| 8044 | + status = strconv__Char_parse_state__reset_params; | |
| 8045 | + p_index++; | |
| 8046 | + i++; | |
| 8047 | + continue; | |
| 8048 | + } | |
| 8049 | + if (ch == 'p' && status == strconv__Char_parse_state__field_char) { | |
| 8050 | + strconv__v_sprintf_panic(p_index, pt.len); | |
| 8051 | + strings__Builder_write_string(&res, _S("0x")); | |
| 8052 | + strings__Builder_write_string(&res, builtin__ptr_str(((voidptr*)pt.data)[p_index])); | |
| 8053 | + status = strconv__Char_parse_state__reset_params; | |
| 8054 | + p_index++; | |
| 8055 | + i++; | |
| 8056 | + continue; | |
| 8057 | + } | |
| 8058 | + if (status == strconv__Char_parse_state__field_char) { | |
| 8059 | + rune fc_ch1 = '0'; | |
| 8060 | + rune fc_ch2 = '0'; | |
| 8061 | + if ((i + 1) < str.len) { | |
| 8062 | + fc_ch1 = str.str[ i + 1]; | |
| 8063 | + if ((i + 2) < str.len) { | |
| 8064 | + fc_ch2 = str.str[ i + 2]; | |
| 8065 | + } | |
| 8066 | + } | |
| 8067 | + if (ch == '+') { | |
| 8068 | + sign = true; | |
| 8069 | + i++; | |
| 8070 | + continue; | |
| 8071 | + } else if (ch == '-') { | |
| 8072 | + align = strconv__Align_text__left; | |
| 8073 | + i++; | |
| 8074 | + continue; | |
| 8075 | + } else if (ch == '0' || ch == ' ') { | |
| 8076 | + if (align == strconv__Align_text__right) { | |
| 8077 | + pad_ch = ch; | |
| 8078 | + } | |
| 8079 | + i++; | |
| 8080 | + continue; | |
| 8081 | + } else if (ch == '\'') { | |
| 8082 | + i++; | |
| 8083 | + continue; | |
| 8084 | + } else if (ch == '.' && fc_ch1 >= '1' && fc_ch1 <= '9') { | |
| 8085 | + status = strconv__Char_parse_state__check_float; | |
| 8086 | + i++; | |
| 8087 | + continue; | |
| 8088 | + } else if (ch == '.' && fc_ch1 == '*' && fc_ch2 == 's') { | |
| 8089 | + strconv__v_sprintf_panic(p_index, pt.len); | |
| 8090 | + int len = *(((int*)(((voidptr*)pt.data)[p_index]))); | |
| 8091 | + p_index++; | |
| 8092 | + strconv__v_sprintf_panic(p_index, pt.len); | |
| 8093 | + string s = *(((string*)(((voidptr*)pt.data)[p_index]))); | |
| 8094 | + s = builtin__string_substr(s, 0, len); | |
| 8095 | + p_index++; | |
| 8096 | + strings__Builder_write_string(&res, s); | |
| 8097 | + status = strconv__Char_parse_state__reset_params; | |
| 8098 | + i += 3; | |
| 8099 | + continue; | |
| 8100 | + } | |
| 8101 | + status = strconv__Char_parse_state__len_set_start; | |
| 8102 | + continue; | |
| 8103 | + } | |
| 8104 | + if (status == strconv__Char_parse_state__len_set_start) { | |
| 8105 | + if (ch >= '1' && ch <= '9') { | |
| 8106 | + len0 = ((int)((rune)(ch - '0'))); | |
| 8107 | + status = strconv__Char_parse_state__len_set_in; | |
| 8108 | + i++; | |
| 8109 | + continue; | |
| 8110 | + } | |
| 8111 | + if (ch == '.') { | |
| 8112 | + status = strconv__Char_parse_state__check_float; | |
| 8113 | + i++; | |
| 8114 | + continue; | |
| 8115 | + } | |
| 8116 | + status = strconv__Char_parse_state__check_type; | |
| 8117 | + continue; | |
| 8118 | + } | |
| 8119 | + if (status == strconv__Char_parse_state__len_set_in) { | |
| 8120 | + if (ch >= '0' && ch <= '9') { | |
| 8121 | + len0 *= 10; | |
| 8122 | + len0 += ((int)((rune)(ch - '0'))); | |
| 8123 | + i++; | |
| 8124 | + continue; | |
| 8125 | + } | |
| 8126 | + if (ch == '.') { | |
| 8127 | + status = strconv__Char_parse_state__check_float; | |
| 8128 | + i++; | |
| 8129 | + continue; | |
| 8130 | + } | |
| 8131 | + status = strconv__Char_parse_state__check_type; | |
| 8132 | + continue; | |
| 8133 | + } | |
| 8134 | + if (status == strconv__Char_parse_state__check_float) { | |
| 8135 | + if (ch >= '0' && ch <= '9') { | |
| 8136 | + len1 = ((int)((rune)(ch - '0'))); | |
| 8137 | + status = strconv__Char_parse_state__check_float_in; | |
| 8138 | + i++; | |
| 8139 | + continue; | |
| 8140 | + } | |
| 8141 | + status = strconv__Char_parse_state__check_type; | |
| 8142 | + continue; | |
| 8143 | + } | |
| 8144 | + if (status == strconv__Char_parse_state__check_float_in) { | |
| 8145 | + if (ch >= '0' && ch <= '9') { | |
| 8146 | + len1 *= 10; | |
| 8147 | + len1 += ((int)((rune)(ch - '0'))); | |
| 8148 | + i++; | |
| 8149 | + continue; | |
| 8150 | + } | |
| 8151 | + status = strconv__Char_parse_state__check_type; | |
| 8152 | + continue; | |
| 8153 | + } | |
| 8154 | + if (status == strconv__Char_parse_state__check_type) { | |
| 8155 | + if (ch == 'l') { | |
| 8156 | + if (ch1 == '0') { | |
| 8157 | + ch1 = 'l'; | |
| 8158 | + i++; | |
| 8159 | + continue; | |
| 8160 | + } else { | |
| 8161 | + ch2 = 'l'; | |
| 8162 | + i++; | |
| 8163 | + continue; | |
| 8164 | + } | |
| 8165 | + } else if (ch == 'h') { | |
| 8166 | + if (ch1 == '0') { | |
| 8167 | + ch1 = 'h'; | |
| 8168 | + i++; | |
| 8169 | + continue; | |
| 8170 | + } else { | |
| 8171 | + ch2 = 'h'; | |
| 8172 | + i++; | |
| 8173 | + continue; | |
| 8174 | + } | |
| 8175 | + } else if (ch == 'd' || ch == 'i') { | |
| 8176 | + u64 d1 = ((u64)(0)); | |
| 8177 | + bool positive = true; | |
| 8178 | + | |
| 8179 | + if (ch1 == ('h')) { | |
| 8180 | + strconv__v_sprintf_panic(p_index, pt.len); | |
| 8181 | + int x = *(((int*)(((voidptr*)pt.data)[p_index]))); | |
| 8182 | + if (ch2 == 'h') { | |
| 8183 | + i8 sx = ((i8)(x)); | |
| 8184 | + positive = (sx >= 0 ? (true) : (false)); | |
| 8185 | + d1 = (positive ? (((u64)(sx))) : (((u64)(-sx)))); | |
| 8186 | + } else { | |
| 8187 | + i16 sx = ((i16)(x)); | |
| 8188 | + positive = (sx >= 0 ? (true) : (false)); | |
| 8189 | + d1 = (positive ? (((u64)(sx))) : (((u64)(-sx)))); | |
| 8190 | + } | |
| 8191 | + } | |
| 8192 | + else if (ch1 == ('l')) { | |
| 8193 | + strconv__v_sprintf_panic(p_index, pt.len); | |
| 8194 | + i64 x = *(((i64*)(((voidptr*)pt.data)[p_index]))); | |
| 8195 | + positive = (x >= 0 ? (true) : (false)); | |
| 8196 | + d1 = (positive ? (((u64)(x))) : (((u64)(-x)))); | |
| 8197 | + } | |
| 8198 | + else { | |
| 8199 | + strconv__v_sprintf_panic(p_index, pt.len); | |
| 8200 | + int x = *(((int*)(((voidptr*)pt.data)[p_index]))); | |
| 8201 | + positive = (x >= 0 ? (true) : (false)); | |
| 8202 | + d1 = (positive ? (((u64)(x))) : (((u64)(-x)))); | |
| 8203 | + } | |
| 8204 | + string tmp = strconv__format_dec_old(d1, ((strconv__BF_param){ | |
| 8205 | + .pad_ch = pad_ch, | |
| 8206 | + .len0 = len0, | |
| 8207 | + .len1 = 0, | |
| 8208 | + .positive = positive, | |
| 8209 | + .sign_flag = sign, | |
| 8210 | + .align = align, | |
| 8211 | + .rm_tail_zero = 0, | |
| 8212 | + })); | |
| 8213 | + strings__Builder_write_string(&res, tmp); | |
| 8214 | + builtin__string_free(&tmp); | |
| 8215 | + status = strconv__Char_parse_state__reset_params; | |
| 8216 | + p_index++; | |
| 8217 | + i++; | |
| 8218 | + ch1 = '0'; | |
| 8219 | + ch2 = '0'; | |
| 8220 | + continue; | |
| 8221 | + } else if (ch == 'u') { | |
| 8222 | + u64 d1 = ((u64)(0)); | |
| 8223 | + bool positive = true; | |
| 8224 | + strconv__v_sprintf_panic(p_index, pt.len); | |
| 8225 | + | |
| 8226 | + if (ch1 == ('h')) { | |
| 8227 | + int x = *(((int*)(((voidptr*)pt.data)[p_index]))); | |
| 8228 | + if (ch2 == 'h') { | |
| 8229 | + d1 = ((u64)(((u8)(x)))); | |
| 8230 | + } else { | |
| 8231 | + d1 = ((u64)(((u16)(x)))); | |
| 8232 | + } | |
| 8233 | + } | |
| 8234 | + else if (ch1 == ('l')) { | |
| 8235 | + d1 = ((u64)(*(((u64*)(((voidptr*)pt.data)[p_index]))))); | |
| 8236 | + } | |
| 8237 | + else { | |
| 8238 | + d1 = ((u64)(((u32)(*(((int*)(((voidptr*)pt.data)[p_index]))))))); | |
| 8239 | + } | |
| 8240 | + string tmp = strconv__format_dec_old(d1, ((strconv__BF_param){ | |
| 8241 | + .pad_ch = pad_ch, | |
| 8242 | + .len0 = len0, | |
| 8243 | + .len1 = 0, | |
| 8244 | + .positive = positive, | |
| 8245 | + .sign_flag = sign, | |
| 8246 | + .align = align, | |
| 8247 | + .rm_tail_zero = 0, | |
| 8248 | + })); | |
| 8249 | + strings__Builder_write_string(&res, tmp); | |
| 8250 | + builtin__string_free(&tmp); | |
| 8251 | + status = strconv__Char_parse_state__reset_params; | |
| 8252 | + p_index++; | |
| 8253 | + i++; | |
| 8254 | + continue; | |
| 8255 | + } else if (ch == 'x' || ch == 'X') { | |
| 8256 | + strconv__v_sprintf_panic(p_index, pt.len); | |
| 8257 | + string s = _S(""); | |
| 8258 | + | |
| 8259 | + if (ch1 == ('h')) { | |
| 8260 | + int x = *(((int*)(((voidptr*)pt.data)[p_index]))); | |
| 8261 | + if (ch2 == 'h') { | |
| 8262 | + s = builtin__i8_hex(((i8)(x))); | |
| 8263 | + } else { | |
| 8264 | + s = builtin__i16_hex(((i16)(x))); | |
| 8265 | + } | |
| 8266 | + } | |
| 8267 | + else if (ch1 == ('l')) { | |
| 8268 | + i64 x = *(((i64*)(((voidptr*)pt.data)[p_index]))); | |
| 8269 | + s = builtin__i64_hex(x); | |
| 8270 | + } | |
| 8271 | + else { | |
| 8272 | + int x = *(((int*)(((voidptr*)pt.data)[p_index]))); | |
| 8273 | + s = builtin__int_hex(x); | |
| 8274 | + } | |
| 8275 | + if (ch == 'X') { | |
| 8276 | + string tmp = s; | |
| 8277 | + s = builtin__string_to_upper(s); | |
| 8278 | + builtin__string_free(&tmp); | |
| 8279 | + } | |
| 8280 | + string tmp = strconv__format_str(s, ((strconv__BF_param){ | |
| 8281 | + .pad_ch = pad_ch, | |
| 8282 | + .len0 = len0, | |
| 8283 | + .len1 = 0, | |
| 8284 | + .positive = true, | |
| 8285 | + .sign_flag = false, | |
| 8286 | + .align = align, | |
| 8287 | + .rm_tail_zero = 0, | |
| 8288 | + })); | |
| 8289 | + strings__Builder_write_string(&res, tmp); | |
| 8290 | + builtin__string_free(&tmp); | |
| 8291 | + builtin__string_free(&s); | |
| 8292 | + status = strconv__Char_parse_state__reset_params; | |
| 8293 | + p_index++; | |
| 8294 | + i++; | |
| 8295 | + continue; | |
| 8296 | + } | |
| 8297 | + if (ch == 'f' || ch == 'F') { | |
| 8298 | + #if !defined(CUSTOM_DEFINE_nofloat) | |
| 8299 | + { | |
| 8300 | + strconv__v_sprintf_panic(p_index, pt.len); | |
| 8301 | + f64 x = *(((f64*)(((voidptr*)pt.data)[p_index]))); | |
| 8302 | + bool positive = x >= ((f64)(0.0)); | |
| 8303 | + len1 = (len1 >= 0 ? (len1) : (def_len1)); | |
| 8304 | + string s = strconv__format_fl_old(((f64)(x)), ((strconv__BF_param){ | |
| 8305 | + .pad_ch = pad_ch, | |
| 8306 | + .len0 = len0, | |
| 8307 | + .len1 = len1, | |
| 8308 | + .positive = positive, | |
| 8309 | + .sign_flag = sign, | |
| 8310 | + .align = align, | |
| 8311 | + .rm_tail_zero = 0, | |
| 8312 | + })); | |
| 8313 | + if (ch == 'F') { | |
| 8314 | + string tmp = builtin__string_to_upper(s); | |
| 8315 | + strings__Builder_write_string(&res, tmp); | |
| 8316 | + builtin__string_free(&tmp); | |
| 8317 | + } else { | |
| 8318 | + strings__Builder_write_string(&res, s); | |
| 8319 | + } | |
| 8320 | + builtin__string_free(&s); | |
| 8321 | + } | |
| 8322 | + #endif | |
| 8323 | + status = strconv__Char_parse_state__reset_params; | |
| 8324 | + p_index++; | |
| 8325 | + i++; | |
| 8326 | + continue; | |
| 8327 | + } else if (ch == 'e' || ch == 'E') { | |
| 8328 | + #if !defined(CUSTOM_DEFINE_nofloat) | |
| 8329 | + { | |
| 8330 | + strconv__v_sprintf_panic(p_index, pt.len); | |
| 8331 | + f64 x = *(((f64*)(((voidptr*)pt.data)[p_index]))); | |
| 8332 | + bool positive = x >= ((f64)(0.0)); | |
| 8333 | + len1 = (len1 >= 0 ? (len1) : (def_len1)); | |
| 8334 | + string s = strconv__format_es_old(((f64)(x)), ((strconv__BF_param){ | |
| 8335 | + .pad_ch = pad_ch, | |
| 8336 | + .len0 = len0, | |
| 8337 | + .len1 = len1, | |
| 8338 | + .positive = positive, | |
| 8339 | + .sign_flag = sign, | |
| 8340 | + .align = align, | |
| 8341 | + .rm_tail_zero = 0, | |
| 8342 | + })); | |
| 8343 | + if (ch == 'E') { | |
| 8344 | + string tmp = builtin__string_to_upper(s); | |
| 8345 | + strings__Builder_write_string(&res, tmp); | |
| 8346 | + builtin__string_free(&tmp); | |
| 8347 | + } else { | |
| 8348 | + strings__Builder_write_string(&res, s); | |
| 8349 | + } | |
| 8350 | + builtin__string_free(&s); | |
| 8351 | + } | |
| 8352 | + #endif | |
| 8353 | + status = strconv__Char_parse_state__reset_params; | |
| 8354 | + p_index++; | |
| 8355 | + i++; | |
| 8356 | + continue; | |
| 8357 | + } else if (ch == 'g' || ch == 'G') { | |
| 8358 | + #if !defined(CUSTOM_DEFINE_nofloat) | |
| 8359 | + { | |
| 8360 | + strconv__v_sprintf_panic(p_index, pt.len); | |
| 8361 | + f64 x = *(((f64*)(((voidptr*)pt.data)[p_index]))); | |
| 8362 | + bool positive = x >= ((f64)(0.0)); | |
| 8363 | + string s = _S(""); | |
| 8364 | + f64 tx = strconv__fabs(x); | |
| 8365 | + if (tx < ((f64)(999999.0)) && tx >= ((f64)(0.00001))) { | |
| 8366 | + len1 = (len1 >= 0 ? (len1 + 1) : (def_len1)); | |
| 8367 | + string tmp = s; | |
| 8368 | + s = strconv__format_fl_old(x, ((strconv__BF_param){ | |
| 8369 | + .pad_ch = pad_ch, | |
| 8370 | + .len0 = len0, | |
| 8371 | + .len1 = len1, | |
| 8372 | + .positive = positive, | |
| 8373 | + .sign_flag = sign, | |
| 8374 | + .align = align, | |
| 8375 | + .rm_tail_zero = true, | |
| 8376 | + })); | |
| 8377 | + builtin__string_free(&tmp); | |
| 8378 | + } else { | |
| 8379 | + len1 = (len1 >= 0 ? (len1 + 1) : (def_len1)); | |
| 8380 | + string tmp = s; | |
| 8381 | + s = strconv__format_es_old(x, ((strconv__BF_param){ | |
| 8382 | + .pad_ch = pad_ch, | |
| 8383 | + .len0 = len0, | |
| 8384 | + .len1 = len1, | |
| 8385 | + .positive = positive, | |
| 8386 | + .sign_flag = sign, | |
| 8387 | + .align = align, | |
| 8388 | + .rm_tail_zero = true, | |
| 8389 | + })); | |
| 8390 | + builtin__string_free(&tmp); | |
| 8391 | + } | |
| 8392 | + if (ch == 'G') { | |
| 8393 | + string tmp = builtin__string_to_upper(s); | |
| 8394 | + strings__Builder_write_string(&res, tmp); | |
| 8395 | + builtin__string_free(&tmp); | |
| 8396 | + } else { | |
| 8397 | + strings__Builder_write_string(&res, s); | |
| 8398 | + } | |
| 8399 | + builtin__string_free(&s); | |
| 8400 | + } | |
| 8401 | + #endif | |
| 8402 | + status = strconv__Char_parse_state__reset_params; | |
| 8403 | + p_index++; | |
| 8404 | + i++; | |
| 8405 | + continue; | |
| 8406 | + } else if (ch == 's') { | |
| 8407 | + strconv__v_sprintf_panic(p_index, pt.len); | |
| 8408 | + string s1 = *(((string*)(((voidptr*)pt.data)[p_index]))); | |
| 8409 | + pad_ch = ' '; | |
| 8410 | + string tmp = strconv__format_str(s1, ((strconv__BF_param){ | |
| 8411 | + .pad_ch = pad_ch, | |
| 8412 | + .len0 = len0, | |
| 8413 | + .len1 = 0, | |
| 8414 | + .positive = true, | |
| 8415 | + .sign_flag = false, | |
| 8416 | + .align = align, | |
| 8417 | + .rm_tail_zero = 0, | |
| 8418 | + })); | |
| 8419 | + strings__Builder_write_string(&res, tmp); | |
| 8420 | + builtin__string_free(&tmp); | |
| 8421 | + status = strconv__Char_parse_state__reset_params; | |
| 8422 | + p_index++; | |
| 8423 | + i++; | |
| 8424 | + continue; | |
| 8425 | + } | |
| 8426 | + } | |
| 8427 | + status = strconv__Char_parse_state__reset_params; | |
| 8428 | + p_index++; | |
| 8429 | + i++; | |
| 8430 | + } | |
| 8431 | + if (p_index != pt.len) { | |
| 8432 | + builtin__panic_n2(_S("% conversion specifiers number mismatch (expected %, given args)"), p_index, pt.len); | |
| 8433 | + VUNREACHABLE(); | |
| 8434 | + } | |
| 8435 | + string _t4 = strings__Builder_str(&res); | |
| 8436 | + { // defer begin | |
| 8437 | + strings__Builder_free(&res); | |
| 8438 | + } // defer end | |
| 8439 | + return _t4; | |
| 8440 | +} | |
| 8441 | +inline VV_LOC void strconv__v_sprintf_panic(int idx, int len) { | |
| 8442 | + if (idx >= len) { | |
| 8443 | + builtin__panic_n2(_S("% conversion specifiers number mismatch (expected %, given args)"), idx + 1, len); | |
| 8444 | + VUNREACHABLE(); | |
| 8445 | + } | |
| 8446 | +} | |
| 8447 | +VV_LOC f64 strconv__fabs(f64 x) { | |
| 8448 | + if (x < ((f64)(0.0))) { | |
| 8449 | + return -x; | |
| 8450 | + } | |
| 8451 | + return x; | |
| 8452 | +} | |
| 8453 | +string strconv__format_fl_old(f64 f, strconv__BF_param p) { | |
| 8454 | + { // Unsafe block | |
| 8455 | + string s = _S(""); | |
| 8456 | + string fs = strconv__f64_to_str_lnd1((f >= ((f64)(0.0)) ? (f) : (-f)), p.len1); | |
| 8457 | + if (fs.str[ 0] == '[') { | |
| 8458 | + builtin__string_free(&s); | |
| 8459 | + return fs; | |
| 8460 | + } | |
| 8461 | + if (p.rm_tail_zero) { | |
| 8462 | + string tmp = fs; | |
| 8463 | + fs = strconv__remove_tail_zeros_old(fs); | |
| 8464 | + builtin__string_free(&tmp); | |
| 8465 | + } | |
| 8466 | + strings__Builder res = strings__new_builder((p.len0 > fs.len ? (p.len0) : (fs.len))); | |
| 8467 | + int sign_len_diff = 0; | |
| 8468 | + if (p.pad_ch == '0') { | |
| 8469 | + if (p.positive) { | |
| 8470 | + if (p.sign_flag) { | |
| 8471 | + strings__Builder_write_u8(&res, '+'); | |
| 8472 | + sign_len_diff = -1; | |
| 8473 | + } | |
| 8474 | + } else { | |
| 8475 | + strings__Builder_write_u8(&res, '-'); | |
| 8476 | + sign_len_diff = -1; | |
| 8477 | + } | |
| 8478 | + string tmp = s; | |
| 8479 | + s = builtin__string_clone(fs); | |
| 8480 | + builtin__string_free(&tmp); | |
| 8481 | + } else { | |
| 8482 | + if (p.positive) { | |
| 8483 | + if (p.sign_flag) { | |
| 8484 | + string tmp = s; | |
| 8485 | + s = builtin__string__plus(_S("+"), fs); | |
| 8486 | + builtin__string_free(&tmp); | |
| 8487 | + } else { | |
| 8488 | + string tmp = s; | |
| 8489 | + s = builtin__string_clone(fs); | |
| 8490 | + builtin__string_free(&tmp); | |
| 8491 | + } | |
| 8492 | + } else { | |
| 8493 | + string tmp = s; | |
| 8494 | + s = builtin__string__plus(_S("-"), fs); | |
| 8495 | + builtin__string_free(&tmp); | |
| 8496 | + } | |
| 8497 | + } | |
| 8498 | + int dif = p.len0 - s.len + sign_len_diff; | |
| 8499 | + if (p.align == strconv__Align_text__right) { | |
| 8500 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 8501 | + strings__Builder_write_u8(&res, p.pad_ch); | |
| 8502 | + } | |
| 8503 | + } | |
| 8504 | + strings__Builder_write_string(&res, s); | |
| 8505 | + if (p.align == strconv__Align_text__left) { | |
| 8506 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 8507 | + strings__Builder_write_u8(&res, p.pad_ch); | |
| 8508 | + } | |
| 8509 | + } | |
| 8510 | + builtin__string_free(&s); | |
| 8511 | + builtin__string_free(&fs); | |
| 8512 | + string _t2 = strings__Builder_str(&res); | |
| 8513 | + { // defer begin | |
| 8514 | + strings__Builder_free(&res); | |
| 8515 | + } // defer end | |
| 8516 | + return _t2; | |
| 8517 | + { // defer begin | |
| 8518 | + strings__Builder_free(&res); | |
| 8519 | + } // defer end | |
| 8520 | + } | |
| 8521 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 8522 | +} | |
| 8523 | +VV_LOC string strconv__format_es_old(f64 f, strconv__BF_param p) { | |
| 8524 | + { // Unsafe block | |
| 8525 | + string s = _S(""); | |
| 8526 | + string fs = strconv__f64_to_str_pad((f > 0 ? (f) : (-f)), p.len1); | |
| 8527 | + if (p.rm_tail_zero) { | |
| 8528 | + string tmp = fs; | |
| 8529 | + fs = strconv__remove_tail_zeros_old(fs); | |
| 8530 | + builtin__string_free(&tmp); | |
| 8531 | + } | |
| 8532 | + strings__Builder res = strings__new_builder((p.len0 > fs.len ? (p.len0) : (fs.len))); | |
| 8533 | + int sign_len_diff = 0; | |
| 8534 | + if (p.pad_ch == '0') { | |
| 8535 | + if (p.positive) { | |
| 8536 | + if (p.sign_flag) { | |
| 8537 | + strings__Builder_write_u8(&res, '+'); | |
| 8538 | + sign_len_diff = -1; | |
| 8539 | + } | |
| 8540 | + } else { | |
| 8541 | + strings__Builder_write_u8(&res, '-'); | |
| 8542 | + sign_len_diff = -1; | |
| 8543 | + } | |
| 8544 | + string tmp = s; | |
| 8545 | + s = builtin__string_clone(fs); | |
| 8546 | + builtin__string_free(&tmp); | |
| 8547 | + } else { | |
| 8548 | + if (p.positive) { | |
| 8549 | + if (p.sign_flag) { | |
| 8550 | + string tmp = s; | |
| 8551 | + s = builtin__string__plus(_S("+"), fs); | |
| 8552 | + builtin__string_free(&tmp); | |
| 8553 | + } else { | |
| 8554 | + string tmp = s; | |
| 8555 | + s = builtin__string_clone(fs); | |
| 8556 | + builtin__string_free(&tmp); | |
| 8557 | + } | |
| 8558 | + } else { | |
| 8559 | + string tmp = s; | |
| 8560 | + s = builtin__string__plus(_S("-"), fs); | |
| 8561 | + builtin__string_free(&tmp); | |
| 8562 | + } | |
| 8563 | + } | |
| 8564 | + int dif = p.len0 - s.len + sign_len_diff; | |
| 8565 | + if (p.align == strconv__Align_text__right) { | |
| 8566 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 8567 | + strings__Builder_write_u8(&res, p.pad_ch); | |
| 8568 | + } | |
| 8569 | + } | |
| 8570 | + strings__Builder_write_string(&res, s); | |
| 8571 | + if (p.align == strconv__Align_text__left) { | |
| 8572 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 8573 | + strings__Builder_write_u8(&res, p.pad_ch); | |
| 8574 | + } | |
| 8575 | + } | |
| 8576 | + string _t1 = strings__Builder_str(&res); | |
| 8577 | + { // defer begin | |
| 8578 | + strings__Builder_free(&res); | |
| 8579 | + builtin__string_free(&fs); | |
| 8580 | + builtin__string_free(&s); | |
| 8581 | + } // defer end | |
| 8582 | + return _t1; | |
| 8583 | + { // defer begin | |
| 8584 | + strings__Builder_free(&res); | |
| 8585 | + builtin__string_free(&fs); | |
| 8586 | + builtin__string_free(&s); | |
| 8587 | + } // defer end | |
| 8588 | + } | |
| 8589 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 8590 | +} | |
| 8591 | +VV_LOC string strconv__remove_tail_zeros_old(string s) { | |
| 8592 | + int i = 0; | |
| 8593 | + int last_zero_start = -1; | |
| 8594 | + int dot_pos = -1; | |
| 8595 | + bool in_decimal = false; | |
| 8596 | + u8 prev_ch = ((u8)(0)); | |
| 8597 | + for (;;) { | |
| 8598 | + if (!(i < s.len)) break; | |
| 8599 | + u8 ch = s.str[i]; | |
| 8600 | + if (ch == '.') { | |
| 8601 | + in_decimal = true; | |
| 8602 | + dot_pos = i; | |
| 8603 | + } else if (in_decimal) { | |
| 8604 | + if (ch == '0' && prev_ch != '0') { | |
| 8605 | + last_zero_start = i; | |
| 8606 | + } else if (ch >= '1' && ch <= '9') { | |
| 8607 | + last_zero_start = -1; | |
| 8608 | + } else if (ch == 'e') { | |
| 8609 | + break; | |
| 8610 | + } | |
| 8611 | + } | |
| 8612 | + prev_ch = ch; | |
| 8613 | + i++; | |
| 8614 | + } | |
| 8615 | + string tmp = _S(""); | |
| 8616 | + if (last_zero_start > 0) { | |
| 8617 | + if (last_zero_start == dot_pos + 1) { | |
| 8618 | + tmp = builtin__string__plus(builtin__string_substr(s, 0, dot_pos), builtin__string_substr(s, i, 2147483647)); | |
| 8619 | + } else { | |
| 8620 | + tmp = builtin__string__plus(builtin__string_substr(s, 0, last_zero_start), builtin__string_substr(s, i, 2147483647)); | |
| 8621 | + } | |
| 8622 | + } else { | |
| 8623 | + tmp = builtin__string_clone(s); | |
| 8624 | + } | |
| 8625 | + if (tmp.str[tmp.len - 1] == '.') { | |
| 8626 | + return builtin__string_substr(tmp, 0, tmp.len - 1); | |
| 8627 | + } | |
| 8628 | + return tmp; | |
| 8629 | +} | |
| 8630 | +string strconv__format_dec_old(u64 d, strconv__BF_param p) { | |
| 8631 | + string s = _S(""); | |
| 8632 | + strings__Builder res = strings__new_builder(20); | |
| 8633 | + int sign_len_diff = 0; | |
| 8634 | + if (p.pad_ch == '0') { | |
| 8635 | + if (p.positive) { | |
| 8636 | + if (p.sign_flag) { | |
| 8637 | + strings__Builder_write_u8(&res, '+'); | |
| 8638 | + sign_len_diff = -1; | |
| 8639 | + } | |
| 8640 | + } else { | |
| 8641 | + strings__Builder_write_u8(&res, '-'); | |
| 8642 | + sign_len_diff = -1; | |
| 8643 | + } | |
| 8644 | + string tmp = s; | |
| 8645 | + s = builtin__u64_str(d); | |
| 8646 | + builtin__string_free(&tmp); | |
| 8647 | + } else { | |
| 8648 | + if (p.positive) { | |
| 8649 | + if (p.sign_flag) { | |
| 8650 | + string tmp = s; | |
| 8651 | + s = builtin__string__plus(_S("+"), builtin__u64_str(d)); | |
| 8652 | + builtin__string_free(&tmp); | |
| 8653 | + } else { | |
| 8654 | + string tmp = s; | |
| 8655 | + s = builtin__u64_str(d); | |
| 8656 | + builtin__string_free(&tmp); | |
| 8657 | + } | |
| 8658 | + } else { | |
| 8659 | + string tmp = s; | |
| 8660 | + s = builtin__string__plus(_S("-"), builtin__u64_str(d)); | |
| 8661 | + builtin__string_free(&tmp); | |
| 8662 | + } | |
| 8663 | + } | |
| 8664 | + int dif = p.len0 - s.len + sign_len_diff; | |
| 8665 | + if (p.align == strconv__Align_text__right) { | |
| 8666 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 8667 | + strings__Builder_write_u8(&res, p.pad_ch); | |
| 8668 | + } | |
| 8669 | + } | |
| 8670 | + strings__Builder_write_string(&res, s); | |
| 8671 | + if (p.align == strconv__Align_text__left) { | |
| 8672 | + for (int i1 = 0; i1 < dif; i1++) { | |
| 8673 | + strings__Builder_write_u8(&res, p.pad_ch); | |
| 8674 | + } | |
| 8675 | + } | |
| 8676 | + string _t1 = strings__Builder_str(&res); | |
| 8677 | + { // defer begin | |
| 8678 | + strings__Builder_free(&res); | |
| 8679 | + builtin__string_free(&s); | |
| 8680 | + } // defer end | |
| 8681 | + return _t1; | |
| 8682 | +} | |
| 8683 | +int strconv__write_dec(i64 n, Array_u8* buf) { | |
| 8684 | + u64 mag = ((u64)(n)); | |
| 8685 | + if (n < 0) { | |
| 8686 | + mag = ((u64)(0)) - mag; | |
| 8687 | + int ndigits = strconv__dec_digits(mag); | |
| 8688 | + if (buf->len < ndigits + 1) { | |
| 8689 | + return -1; | |
| 8690 | + } | |
| 8691 | + ((u8*)buf->data)[0] = '-'; | |
| 8692 | + strconv__write_dec_u_digits(mag, buf, 1, ndigits); | |
| 8693 | + return ndigits + 1; | |
| 8694 | + } | |
| 8695 | + int ndigits = strconv__dec_digits(mag); | |
| 8696 | + if (buf->len < ndigits) { | |
| 8697 | + return -1; | |
| 8698 | + } | |
| 8699 | + strconv__write_dec_u_digits(mag, buf, 0, ndigits); | |
| 8700 | + return ndigits; | |
| 8701 | +} | |
| 8702 | +int strconv__write_dec_u(u64 n, Array_u8* buf) { | |
| 8703 | + int ndigits = strconv__dec_digits(n); | |
| 8704 | + if (buf->len < ndigits) { | |
| 8705 | + return -1; | |
| 8706 | + } | |
| 8707 | + strconv__write_dec_u_digits(n, buf, 0, ndigits); | |
| 8708 | + return ndigits; | |
| 8709 | +} | |
| 8710 | +VV_LOC void strconv__write_dec_u_digits(u64 n, Array_u8* buf, int offset, int ndigits) { | |
| 8711 | + u64 x = n; | |
| 8712 | + int i = offset + ndigits; | |
| 8713 | + for (;;) { | |
| 8714 | + i--; | |
| 8715 | + ((u8*)buf->data)[i] = (rune)(((u8)(VSAFE_MOD_u64(x , 10))) + '0'); | |
| 8716 | + x = VSAFE_DIV_u64(x,10); | |
| 8717 | + if (x == 0) { | |
| 8718 | + break; | |
| 8719 | + } | |
| 8720 | + } | |
| 8721 | +} | |
| 8722 | +VNORETURN VV_LOC void builtin___memory_panic(string fname, isize size) { | |
| 8723 | + v_memory_panic = true; | |
| 8724 | + builtin__eprint(fname); | |
| 8725 | + builtin__eprint(_S("(")); | |
| 8726 | + #if 0 | |
| 8727 | + { | |
| 8728 | + } | |
| 8729 | + #else | |
| 8730 | + { | |
| 8731 | + fprintf(stderr, "%p", ((voidptr)(size))); | |
| 8732 | + } | |
| 8733 | + #endif | |
| 8734 | + if (size < 0) { | |
| 8735 | + builtin__eprint(_S(" < 0")); | |
| 8736 | + } | |
| 8737 | + builtin__eprintln(_S(")")); | |
| 8738 | + builtin___v_panic(_S("memory allocation failure")); | |
| 8739 | + VUNREACHABLE(); | |
| 8740 | + while(1); | |
| 8741 | +} | |
| 8742 | +u8* builtin___v_malloc(isize n) { | |
| 8743 | + if (n < 0) { | |
| 8744 | + builtin___memory_panic(_S("malloc"), n); | |
| 8745 | + VUNREACHABLE(); | |
| 8746 | + } else if (n == 0) { | |
| 8747 | + return ((u8*)(((void*)0))); | |
| 8748 | + } | |
| 8749 | + u8* res = ((u8*)(((void*)0))); | |
| 8750 | + #if 0 | |
| 8751 | + { | |
| 8752 | + } | |
| 8753 | + #elif defined(CUSTOM_DEFINE_vgc) | |
| 8754 | + { | |
| 8755 | + } | |
| 8756 | + #elif defined(CUSTOM_DEFINE_gcboehm) | |
| 8757 | + { | |
| 8758 | + } | |
| 8759 | + #elif 0 | |
| 8760 | + { | |
| 8761 | + } | |
| 8762 | + #else | |
| 8763 | + { | |
| 8764 | + #if 0 | |
| 8765 | + { | |
| 8766 | + } | |
| 8767 | + #else | |
| 8768 | + { | |
| 8769 | + res = malloc(n); | |
| 8770 | + } | |
| 8771 | + #endif | |
| 8772 | + } | |
| 8773 | + #endif | |
| 8774 | + if (res == 0) { | |
| 8775 | + builtin___memory_panic(_S("malloc"), n); | |
| 8776 | + VUNREACHABLE(); | |
| 8777 | + } | |
| 8778 | + ; | |
| 8779 | + return res; | |
| 8780 | +} | |
| 8781 | +u8* builtin__malloc_noscan(isize n) { | |
| 8782 | + if (n < 0) { | |
| 8783 | + builtin___memory_panic(_S("malloc_noscan"), n); | |
| 8784 | + VUNREACHABLE(); | |
| 8785 | + } | |
| 8786 | + u8* res = ((u8*)(((void*)0))); | |
| 8787 | + #if 0 | |
| 8788 | + { | |
| 8789 | + } | |
| 8790 | + #elif defined(CUSTOM_DEFINE_vgc) | |
| 8791 | + { | |
| 8792 | + } | |
| 8793 | + #elif defined(CUSTOM_DEFINE_gcboehm) | |
| 8794 | + { | |
| 8795 | + } | |
| 8796 | + #elif 0 | |
| 8797 | + { | |
| 8798 | + } | |
| 8799 | + #else | |
| 8800 | + { | |
| 8801 | + #if 0 | |
| 8802 | + { | |
| 8803 | + } | |
| 8804 | + #else | |
| 8805 | + { | |
| 8806 | + res = malloc(n); | |
| 8807 | + } | |
| 8808 | + #endif | |
| 8809 | + } | |
| 8810 | + #endif | |
| 8811 | + if (res == 0) { | |
| 8812 | + builtin___memory_panic(_S("malloc_noscan"), n); | |
| 8813 | + VUNREACHABLE(); | |
| 8814 | + } | |
| 8815 | + ; | |
| 8816 | + return res; | |
| 8817 | +} | |
| 8818 | +VV_LOC u8* builtin__malloc_uninit(isize n) { | |
| 8819 | + if (n < 0) { | |
| 8820 | + builtin___memory_panic(_S("malloc_uninit"), n); | |
| 8821 | + VUNREACHABLE(); | |
| 8822 | + } else if (n == 0) { | |
| 8823 | + return ((u8*)(((void*)0))); | |
| 8824 | + } | |
| 8825 | + return builtin___v_malloc(n); | |
| 8826 | +} | |
| 8827 | +inline VV_LOC u64 builtin____at_least_one(u64 how_many) { | |
| 8828 | + if (how_many == 0) { | |
| 8829 | + return 1; | |
| 8830 | + } | |
| 8831 | + return how_many; | |
| 8832 | +} | |
| 8833 | +u8* builtin__malloc_uncollectable(isize n) { | |
| 8834 | + if (n < 0) { | |
| 8835 | + builtin___memory_panic(_S("malloc_uncollectable"), n); | |
| 8836 | + VUNREACHABLE(); | |
| 8837 | + } | |
| 8838 | + u8* res = ((u8*)(((void*)0))); | |
| 8839 | + #if 0 | |
| 8840 | + { | |
| 8841 | + } | |
| 8842 | + #elif defined(CUSTOM_DEFINE_vgc) | |
| 8843 | + { | |
| 8844 | + } | |
| 8845 | + #elif defined(CUSTOM_DEFINE_gcboehm) | |
| 8846 | + { | |
| 8847 | + } | |
| 8848 | + #elif 0 | |
| 8849 | + { | |
| 8850 | + } | |
| 8851 | + #else | |
| 8852 | + { | |
| 8853 | + #if 0 | |
| 8854 | + { | |
| 8855 | + } | |
| 8856 | + #else | |
| 8857 | + { | |
| 8858 | + res = malloc(n); | |
| 8859 | + } | |
| 8860 | + #endif | |
| 8861 | + } | |
| 8862 | + #endif | |
| 8863 | + if (res == 0) { | |
| 8864 | + builtin___memory_panic(_S("malloc_uncollectable"), n); | |
| 8865 | + VUNREACHABLE(); | |
| 8866 | + } | |
| 8867 | + ; | |
| 8868 | + return res; | |
| 8869 | +} | |
| 8870 | +u8* builtin__v_realloc(u8* b, isize n) { | |
| 8871 | + u8* new_ptr = ((u8*)(((void*)0))); | |
| 8872 | + #if 0 | |
| 8873 | + { | |
| 8874 | + } | |
| 8875 | + #elif defined(CUSTOM_DEFINE_vgc) | |
| 8876 | + { | |
| 8877 | + } | |
| 8878 | + #elif defined(CUSTOM_DEFINE_gcboehm) | |
| 8879 | + { | |
| 8880 | + } | |
| 8881 | + #else | |
| 8882 | + { | |
| 8883 | + #if 0 | |
| 8884 | + { | |
| 8885 | + } | |
| 8886 | + #else | |
| 8887 | + { | |
| 8888 | + new_ptr = realloc(b, n); | |
| 8889 | + } | |
| 8890 | + #endif | |
| 8891 | + } | |
| 8892 | + #endif | |
| 8893 | + if (new_ptr == 0) { | |
| 8894 | + builtin___memory_panic(_S("v_realloc"), n); | |
| 8895 | + VUNREACHABLE(); | |
| 8896 | + } | |
| 8897 | + if (b != ((void*)0)) { | |
| 8898 | + ; | |
| 8899 | + } | |
| 8900 | + ; | |
| 8901 | + return new_ptr; | |
| 8902 | +} | |
| 8903 | +u8* builtin__realloc_data(u8* old_data, int old_size, int new_size) { | |
| 8904 | + u8* nptr = ((u8*)(((void*)0))); | |
| 8905 | + #if defined(CUSTOM_DEFINE_vgc) | |
| 8906 | + { | |
| 8907 | + } | |
| 8908 | + #elif defined(CUSTOM_DEFINE_gcboehm) | |
| 8909 | + { | |
| 8910 | + } | |
| 8911 | + #else | |
| 8912 | + { | |
| 8913 | + #if 0 | |
| 8914 | + { | |
| 8915 | + } | |
| 8916 | + #else | |
| 8917 | + { | |
| 8918 | + nptr = realloc(old_data, new_size); | |
| 8919 | + } | |
| 8920 | + #endif | |
| 8921 | + } | |
| 8922 | + #endif | |
| 8923 | + if (nptr == 0) { | |
| 8924 | + builtin___memory_panic(_S("realloc_data"), ((isize)(new_size))); | |
| 8925 | + VUNREACHABLE(); | |
| 8926 | + } | |
| 8927 | + if (old_data != ((void*)0)) { | |
| 8928 | + ; | |
| 8929 | + } | |
| 8930 | + ; | |
| 8931 | + return nptr; | |
| 8932 | +} | |
| 8933 | +u8* builtin__vcalloc(isize n) { | |
| 8934 | + if (n < 0) { | |
| 8935 | + builtin___memory_panic(_S("vcalloc"), n); | |
| 8936 | + VUNREACHABLE(); | |
| 8937 | + } else if (n == 0) { | |
| 8938 | + return ((u8*)(((void*)0))); | |
| 8939 | + } | |
| 8940 | + #if 0 | |
| 8941 | + { | |
| 8942 | + } | |
| 8943 | + #elif defined(CUSTOM_DEFINE_vgc) | |
| 8944 | + { | |
| 8945 | + } | |
| 8946 | + #elif defined(CUSTOM_DEFINE_gcboehm) | |
| 8947 | + { | |
| 8948 | + } | |
| 8949 | + #else | |
| 8950 | + { | |
| 8951 | + #if 0 | |
| 8952 | + { | |
| 8953 | + } | |
| 8954 | + #else | |
| 8955 | + { | |
| 8956 | + voidptr r = calloc(1, n); | |
| 8957 | + ; | |
| 8958 | + return r; | |
| 8959 | + } | |
| 8960 | + #endif | |
| 8961 | + } | |
| 8962 | + #endif | |
| 8963 | + return ((u8*)(((void*)0))); | |
| 8964 | +} | |
| 8965 | +u8* builtin__vcalloc_noscan(isize n) { | |
| 8966 | + #if 0 | |
| 8967 | + { | |
| 8968 | + } | |
| 8969 | + #elif defined(CUSTOM_DEFINE_vgc) | |
| 8970 | + { | |
| 8971 | + } | |
| 8972 | + #elif defined(CUSTOM_DEFINE_gcboehm) | |
| 8973 | + { | |
| 8974 | + } | |
| 8975 | + #else | |
| 8976 | + { | |
| 8977 | + return builtin__vcalloc(n); | |
| 8978 | + } | |
| 8979 | + #endif | |
| 8980 | + return ((u8*)(((void*)0))); | |
| 8981 | +} | |
| 8982 | +void builtin___v_free(voidptr ptr) { | |
| 8983 | + if (ptr == 0) { | |
| 8984 | + return; | |
| 8985 | + } | |
| 8986 | + IError* none_err = ((IError*)(&_const_none__)); | |
| 8987 | + if (ptr == none_err->_object) { | |
| 8988 | + return; | |
| 8989 | + } | |
| 8990 | + IError* sentinel_err = ((IError*)(&_const_error_sentinel)); | |
| 8991 | + if (ptr == sentinel_err->_object) { | |
| 8992 | + return; | |
| 8993 | + } | |
| 8994 | + #if 0 | |
| 8995 | + { | |
| 8996 | + } | |
| 8997 | + #elif defined(CUSTOM_DEFINE_vgc) | |
| 8998 | + { | |
| 8999 | + } | |
| 9000 | + #elif defined(CUSTOM_DEFINE_gcboehm) | |
| 9001 | + { | |
| 9002 | + } | |
| 9003 | + #else | |
| 9004 | + { | |
| 9005 | + ; | |
| 9006 | + #if 0 | |
| 9007 | + { | |
| 9008 | + } | |
| 9009 | + #else | |
| 9010 | + { | |
| 9011 | + free(ptr); | |
| 9012 | + } | |
| 9013 | + #endif | |
| 9014 | + } | |
| 9015 | + #endif | |
| 9016 | +} | |
| 9017 | +voidptr builtin__memdup(voidptr src, isize sz) { | |
| 9018 | + if (sz == 0) { | |
| 9019 | + return builtin__vcalloc(1); | |
| 9020 | + } | |
| 9021 | + { // Unsafe block | |
| 9022 | + u8* mem = builtin___v_malloc(sz); | |
| 9023 | + return memcpy(mem, src, sz); | |
| 9024 | + } | |
| 9025 | + return 0; | |
| 9026 | +} | |
| 9027 | +voidptr builtin__memdup_noscan(voidptr src, isize sz) { | |
| 9028 | + if (sz == 0) { | |
| 9029 | + return builtin__vcalloc_noscan(1); | |
| 9030 | + } | |
| 9031 | + { // Unsafe block | |
| 9032 | + u8* mem = builtin__malloc_noscan(sz); | |
| 9033 | + return memcpy(mem, src, sz); | |
| 9034 | + } | |
| 9035 | + return 0; | |
| 9036 | +} | |
| 9037 | +voidptr builtin__memdup_uncollectable(voidptr src, isize sz) { | |
| 9038 | + if (sz == 0) { | |
| 9039 | + return builtin__vcalloc(1); | |
| 9040 | + } | |
| 9041 | + { // Unsafe block | |
| 9042 | + u8* mem = builtin__malloc_uncollectable(sz); | |
| 9043 | + return memcpy(mem, src, sz); | |
| 9044 | + } | |
| 9045 | + return 0; | |
| 9046 | +} | |
| 9047 | +voidptr builtin__memdup_align(voidptr src, isize sz, isize align) { | |
| 9048 | + if (sz == 0) { | |
| 9049 | + return builtin__vcalloc(1); | |
| 9050 | + } | |
| 9051 | + isize n = sz; | |
| 9052 | + if (n < 0) { | |
| 9053 | + builtin___memory_panic(_S("memdup_align"), n); | |
| 9054 | + VUNREACHABLE(); | |
| 9055 | + } | |
| 9056 | + u8* res = ((u8*)(((void*)0))); | |
| 9057 | + #if 0 | |
| 9058 | + { | |
| 9059 | + } | |
| 9060 | + #elif defined(CUSTOM_DEFINE_gcboehm) | |
| 9061 | + { | |
| 9062 | + } | |
| 9063 | + #elif 0 | |
| 9064 | + { | |
| 9065 | + } | |
| 9066 | + #else | |
| 9067 | + { | |
| 9068 | + #if 0 | |
| 9069 | + { | |
| 9070 | + } | |
| 9071 | + #else | |
| 9072 | + { | |
| 9073 | + res = aligned_alloc(align, n); | |
| 9074 | + } | |
| 9075 | + #endif | |
| 9076 | + } | |
| 9077 | + #endif | |
| 9078 | + if (res == 0) { | |
| 9079 | + builtin___memory_panic(_S("memdup_align"), n); | |
| 9080 | + VUNREACHABLE(); | |
| 9081 | + } | |
| 9082 | + ; | |
| 9083 | + return memcpy(res, src, sz); | |
| 9084 | +} | |
| 9085 | +GCHeapUsage builtin__gc_heap_usage(void) { | |
| 9086 | + #if defined(CUSTOM_DEFINE_vgc) | |
| 9087 | + { | |
| 9088 | + } | |
| 9089 | + #elif defined(CUSTOM_DEFINE_gcboehm) | |
| 9090 | + { | |
| 9091 | + } | |
| 9092 | + #else | |
| 9093 | + { | |
| 9094 | + return ((GCHeapUsage){.heap_size = 0,.free_bytes = 0,.total_bytes = 0,.unmapped_bytes = 0,.bytes_since_gc = 0,}); | |
| 9095 | + } | |
| 9096 | + #endif | |
| 9097 | + return (GCHeapUsage){0}; | |
| 9098 | +} | |
| 9099 | +usize builtin__gc_memory_use(void) { | |
| 9100 | + #if defined(CUSTOM_DEFINE_vgc) | |
| 9101 | + { | |
| 9102 | + } | |
| 9103 | + #elif defined(CUSTOM_DEFINE_gcboehm) | |
| 9104 | + { | |
| 9105 | + } | |
| 9106 | + #else | |
| 9107 | + { | |
| 9108 | + return 0; | |
| 9109 | + } | |
| 9110 | + #endif | |
| 9111 | + return 0; | |
| 9112 | +} | |
| 9113 | +inline VV_LOC int builtin__array_data_header_size(void) { | |
| 9114 | + return ((int)(sizeof(voidptr))); | |
| 9115 | +} | |
| 9116 | +inline VV_LOC u64 builtin__array_data_allocation_size(u64 total_size) { | |
| 9117 | + return ((u64)(builtin__array_data_header_size())) + builtin____at_least_one(total_size); | |
| 9118 | +} | |
| 9119 | +inline VV_LOC voidptr builtin__alloc_array_data(u64 total_size) { | |
| 9120 | + u8* raw = builtin__vcalloc(builtin__array_data_allocation_size(total_size)); | |
| 9121 | + return ((u8*)(raw)) + builtin__array_data_header_size(); | |
| 9122 | +} | |
| 9123 | +inline VV_LOC voidptr builtin__alloc_array_data_uninit(u64 total_size) { | |
| 9124 | + u8* raw = builtin__malloc_uninit(builtin__array_data_allocation_size(total_size)); | |
| 9125 | + { // Unsafe block | |
| 9126 | + (((ArrayDataHeader*)(raw)))->has_slices = false; | |
| 9127 | + return ((u8*)(raw)) + builtin__array_data_header_size(); | |
| 9128 | + } | |
| 9129 | + return 0; | |
| 9130 | +} | |
| 9131 | +inline VV_LOC bool builtin__array_uses_noscan_data(array a) { | |
| 9132 | + return builtin__ArrayFlags_has(&a.flags, ArrayFlags__noscan_data); | |
| 9133 | +} | |
| 9134 | +inline VV_LOC voidptr builtin__array_alloc_array_data_like(array a, u64 total_size) { | |
| 9135 | + return builtin__alloc_array_data(total_size); | |
| 9136 | +} | |
| 9137 | +inline VV_LOC voidptr builtin__array_alloc_array_data_like_uninit(array a, u64 total_size) { | |
| 9138 | + return builtin__alloc_array_data_uninit(total_size); | |
| 9139 | +} | |
| 9140 | +inline VV_LOC ArrayDataHeader* builtin__array_data_header(array a) { | |
| 9141 | + if (!builtin__ArrayFlags_has(&a.flags, ArrayFlags__managed) || a.data == ((void*)0)) { | |
| 9142 | + return ((void*)0); | |
| 9143 | + } | |
| 9144 | + u8* base_data = ((u8*)(a.data)) - ((u64)(a.offset)); | |
| 9145 | + return ((ArrayDataHeader*)(base_data - builtin__array_data_header_size())); | |
| 9146 | +} | |
| 9147 | +inline VV_LOC bool builtin__array_buffer_has_slices(array a) { | |
| 9148 | + if (!builtin__ArrayFlags_has(&a.flags, ArrayFlags__managed) || a.data == ((void*)0)) { | |
| 9149 | + return false; | |
| 9150 | + } | |
| 9151 | + ArrayDataHeader* header = builtin__array_data_header(a); | |
| 9152 | + if (header == ((void*)0)) { | |
| 9153 | + return false; | |
| 9154 | + } | |
| 9155 | + return header->has_slices; | |
| 9156 | +} | |
| 9157 | +inline VV_LOC void builtin__array_mark_buffer_has_slices(array* a) { | |
| 9158 | + if (!builtin__ArrayFlags_has(&a->flags, ArrayFlags__managed) || a->data == ((void*)0)) { | |
| 9159 | + return; | |
| 9160 | + } | |
| 9161 | + { // Unsafe block | |
| 9162 | + u8* base_data = ((u8*)(a->data)) - ((u64)(a->offset)); | |
| 9163 | + ArrayDataHeader* header = ((ArrayDataHeader*)(base_data - builtin__array_data_header_size())); | |
| 9164 | + if (!header->has_slices) { | |
| 9165 | + header->has_slices = true; | |
| 9166 | + } | |
| 9167 | + } | |
| 9168 | +} | |
| 9169 | +inline VV_LOC void builtin__array_set_managed_flags(array* a, bool is_slice) { | |
| 9170 | + { // Unsafe block | |
| 9171 | + builtin__ArrayFlags_set(&a->flags, ArrayFlags__managed); | |
| 9172 | + if (is_slice) { | |
| 9173 | + builtin__ArrayFlags_set(&a->flags, ArrayFlags__is_slice); | |
| 9174 | + } else { | |
| 9175 | + builtin__ArrayFlags_clear(&a->flags, ArrayFlags__is_slice); | |
| 9176 | + } | |
| 9177 | + } | |
| 9178 | +} | |
| 9179 | +inline VV_LOC void builtin__array_clone_shallow_to_cap(array* a, int new_cap) { | |
| 9180 | + if (new_cap <= 0) { | |
| 9181 | + builtin__ArrayFlags_clear(&a->flags, ((ArrayFlags__managed | ArrayFlags__noscan_data) | ArrayFlags__is_slice)); | |
| 9182 | + a->data = ((void*)0); | |
| 9183 | + a->offset = 0; | |
| 9184 | + a->cap = 0; | |
| 9185 | + return; | |
| 9186 | + } | |
| 9187 | + bool use_noscan_data = builtin__array_uses_noscan_data(*a); | |
| 9188 | + u64 total_size = ((u64)(new_cap)) * ((u64)(a->element_size)); | |
| 9189 | + voidptr new_data = builtin__array_alloc_array_data_like_uninit(*a, total_size); | |
| 9190 | + u64 copy_size = ((u64)(a->len)) * ((u64)(a->element_size)); | |
| 9191 | + if (a->data != ((void*)0) && copy_size > 0) { | |
| 9192 | + builtin__vmemcpy(new_data, a->data, copy_size); | |
| 9193 | + } | |
| 9194 | + a->data = new_data; | |
| 9195 | + a->offset = 0; | |
| 9196 | + a->cap = new_cap; | |
| 9197 | + { // Unsafe block | |
| 9198 | + if (use_noscan_data) { | |
| 9199 | + builtin__ArrayFlags_set(&a->flags, ArrayFlags__noscan_data); | |
| 9200 | + } else { | |
| 9201 | + builtin__ArrayFlags_clear(&a->flags, ArrayFlags__noscan_data); | |
| 9202 | + } | |
| 9203 | + } | |
| 9204 | + builtin__array_set_managed_flags(a, false); | |
| 9205 | +} | |
| 9206 | +inline VV_LOC int builtin__v_ni_index(int i, int len) { | |
| 9207 | + return (i < 0 ? (len + i) : (i)); | |
| 9208 | +} | |
| 9209 | +VV_LOC array builtin____new_array(int mylen, int cap, int elm_size) { | |
| 9210 | + builtin__panic_on_negative_len(mylen); | |
| 9211 | + builtin__panic_on_negative_cap(cap); | |
| 9212 | + int cap_ = (cap < mylen ? (mylen) : (cap)); | |
| 9213 | + u64 total_size = ((u64)(cap_)) * ((u64)(elm_size)); | |
| 9214 | + voidptr data = ((void*)0); | |
| 9215 | + if (cap_ > 0 && mylen == 0) { | |
| 9216 | + data = builtin__alloc_array_data_uninit(total_size); | |
| 9217 | + } else if (cap_ > 0) { | |
| 9218 | + data = builtin__alloc_array_data(total_size); | |
| 9219 | + } | |
| 9220 | + array _t1 = ((array){.data = (voidptr)data,.offset = 0,.len = mylen,.cap = cap_,.flags = ArrayFlags__managed,.element_size = elm_size,}); | |
| 9221 | + array arr = _t1; | |
| 9222 | + return arr; | |
| 9223 | +} | |
| 9224 | +VV_LOC array builtin____new_array_with_default(int mylen, int cap, int elm_size, voidptr val) { | |
| 9225 | + builtin__panic_on_negative_len(mylen); | |
| 9226 | + builtin__panic_on_negative_cap(cap); | |
| 9227 | + int cap_ = (cap < mylen ? (mylen) : (cap)); | |
| 9228 | + array _t1 = ((array){.data = 0,.offset = 0,.len = mylen,.cap = cap_,.flags = ArrayFlags__managed,.element_size = elm_size,}); | |
| 9229 | + array arr = _t1; | |
| 9230 | + u64 total_size = ((u64)(cap_)) * ((u64)(elm_size)); | |
| 9231 | + if (cap_ > 0 && mylen == 0) { | |
| 9232 | + arr.data = builtin__alloc_array_data_uninit(total_size); | |
| 9233 | + } else if (cap_ > 0) { | |
| 9234 | + arr.data = builtin__alloc_array_data(total_size); | |
| 9235 | + } | |
| 9236 | + if (val != 0) { | |
| 9237 | + u8* eptr = ((u8*)(arr.data)); | |
| 9238 | + { // Unsafe block | |
| 9239 | + if (eptr != ((void*)0)) { | |
| 9240 | + if (arr.element_size == 1) { | |
| 9241 | + u8 byte_value = *(((u8*)(val))); | |
| 9242 | + for (int i = 0; i < arr.len; ++i) { | |
| 9243 | + eptr[i] = byte_value; | |
| 9244 | + } | |
| 9245 | + } else { | |
| 9246 | + for (int _t2 = 0; _t2 < arr.len; ++_t2) { | |
| 9247 | + builtin__vmemcpy(eptr, val, arr.element_size); | |
| 9248 | + eptr += arr.element_size; | |
| 9249 | + } | |
| 9250 | + } | |
| 9251 | + } | |
| 9252 | + } | |
| 9253 | + } | |
| 9254 | + return arr; | |
| 9255 | +} | |
| 9256 | +VV_LOC array builtin____new_array_with_multi_default(int mylen, int cap, int elm_size, voidptr val) { | |
| 9257 | + builtin__panic_on_negative_len(mylen); | |
| 9258 | + builtin__panic_on_negative_cap(cap); | |
| 9259 | + int cap_ = (cap < mylen ? (mylen) : (cap)); | |
| 9260 | + array _t1 = ((array){.data = 0,.offset = 0,.len = mylen,.cap = cap_,.flags = ArrayFlags__managed,.element_size = elm_size,}); | |
| 9261 | + array arr = _t1; | |
| 9262 | + u64 total_size = ((u64)(cap_)) * ((u64)(elm_size)); | |
| 9263 | + if (cap_ > 0) { | |
| 9264 | + arr.data = builtin__alloc_array_data(total_size); | |
| 9265 | + } | |
| 9266 | + if (val != 0) { | |
| 9267 | + u8* eptr = ((u8*)(arr.data)); | |
| 9268 | + { // Unsafe block | |
| 9269 | + if (eptr != ((void*)0)) { | |
| 9270 | + for (int i = 0; i < arr.len; ++i) { | |
| 9271 | + builtin__vmemcpy(eptr, ((charptr)(val)) + (int)(i * arr.element_size), arr.element_size); | |
| 9272 | + eptr += arr.element_size; | |
| 9273 | + } | |
| 9274 | + } | |
| 9275 | + } | |
| 9276 | + } | |
| 9277 | + return arr; | |
| 9278 | +} | |
| 9279 | +VV_LOC array builtin____new_array_with_array_default(int mylen, int cap, int elm_size, array val, int depth) { | |
| 9280 | + builtin__panic_on_negative_len(mylen); | |
| 9281 | + builtin__panic_on_negative_cap(cap); | |
| 9282 | + int cap_ = (cap < mylen ? (mylen) : (cap)); | |
| 9283 | + array _t1 = ((array){.data = 0,.offset = 0,.len = mylen,.cap = cap_,.flags = ArrayFlags__managed,.element_size = elm_size,}); | |
| 9284 | + array arr = _t1; | |
| 9285 | + if (cap_ > 0) { | |
| 9286 | + arr.data = builtin__alloc_array_data(((u64)(cap_)) * ((u64)(elm_size))); | |
| 9287 | + } | |
| 9288 | + u8* eptr = ((u8*)(arr.data)); | |
| 9289 | + { // Unsafe block | |
| 9290 | + if (eptr != ((void*)0)) { | |
| 9291 | + for (int _t2 = 0; _t2 < arr.len; ++_t2) { | |
| 9292 | + array val_clone = builtin__array_clone_to_depth(&val, depth); | |
| 9293 | + builtin__vmemcpy(eptr, &val_clone, arr.element_size); | |
| 9294 | + eptr += arr.element_size; | |
| 9295 | + } | |
| 9296 | + } | |
| 9297 | + } | |
| 9298 | + return arr; | |
| 9299 | +} | |
| 9300 | +VV_LOC array builtin__new_array_from_c_array(int len, int cap, int elm_size, voidptr c_array) { | |
| 9301 | + builtin__panic_on_negative_len(len); | |
| 9302 | + builtin__panic_on_negative_cap(cap); | |
| 9303 | + int cap_ = cap; | |
| 9304 | + if (cap < len) { | |
| 9305 | + cap_ = len; | |
| 9306 | + } | |
| 9307 | + array _t1 = ((array){.data = builtin__alloc_array_data(((u64)(cap_)) * ((u64)(elm_size))),.offset = 0,.len = len,.cap = cap_,.flags = ArrayFlags__managed,.element_size = elm_size,}); | |
| 9308 | + array arr = _t1; | |
| 9309 | + builtin__vmemcpy(arr.data, c_array, ((u64)(len)) * ((u64)(elm_size))); | |
| 9310 | + return arr; | |
| 9311 | +} | |
| 9312 | +void builtin__array_ensure_cap(array* a, int required) { | |
| 9313 | + if (required <= a->cap) { | |
| 9314 | + return; | |
| 9315 | + } | |
| 9316 | + if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__nogrow)) { | |
| 9317 | + builtin__panic_n(_S("array.ensure_cap: array with the flag `.nogrow` cannot grow in size, array required new size:"), required); | |
| 9318 | + VUNREACHABLE(); | |
| 9319 | + } | |
| 9320 | + i64 cap = (a->cap > 0 ? (((i64)(a->cap))) : (((i64)(2)))); | |
| 9321 | + for (;;) { | |
| 9322 | + if (!(required > cap)) break; | |
| 9323 | + cap *= 2; | |
| 9324 | + } | |
| 9325 | + if (cap > _const_max_int) { | |
| 9326 | + if (a->cap < _const_max_int) { | |
| 9327 | + cap = _const_max_int; | |
| 9328 | + } else { | |
| 9329 | + builtin__panic_n(_S("array.ensure_cap: array needs to grow to cap (which is > 2^31):"), cap); | |
| 9330 | + VUNREACHABLE(); | |
| 9331 | + } | |
| 9332 | + } | |
| 9333 | + u64 new_size = ((u64)(cap)) * ((u64)(a->element_size)); | |
| 9334 | + bool use_noscan_data = builtin__array_uses_noscan_data(*a); | |
| 9335 | + voidptr new_data = builtin__array_alloc_array_data_like_uninit(*a, new_size); | |
| 9336 | + if (a->data != ((void*)0)) { | |
| 9337 | + builtin__vmemcpy(new_data, a->data, ((u64)(a->len)) * ((u64)(a->element_size))); | |
| 9338 | + if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__noslices) && !builtin__ArrayFlags_has(&a->flags, ArrayFlags__is_slice) && !builtin__array_buffer_has_slices(*a)) { | |
| 9339 | + { // Unsafe block | |
| 9340 | + if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__managed)) { | |
| 9341 | + builtin___v_free(((u8*)(a->data)) - ((u64)(builtin__array_data_header_size()))); | |
| 9342 | + } else { | |
| 9343 | + builtin___v_free(a->data); | |
| 9344 | + } | |
| 9345 | + } | |
| 9346 | + } | |
| 9347 | + } | |
| 9348 | + a->data = new_data; | |
| 9349 | + a->offset = 0; | |
| 9350 | + a->cap = ((int)(cap)); | |
| 9351 | + { // Unsafe block | |
| 9352 | + if (use_noscan_data) { | |
| 9353 | + builtin__ArrayFlags_set(&a->flags, ArrayFlags__noscan_data); | |
| 9354 | + } else { | |
| 9355 | + builtin__ArrayFlags_clear(&a->flags, ArrayFlags__noscan_data); | |
| 9356 | + } | |
| 9357 | + } | |
| 9358 | + builtin__array_set_managed_flags(a, false); | |
| 9359 | +} | |
| 9360 | +array builtin__array_repeat(array a, int count) { | |
| 9361 | + return builtin__array_repeat_to_depth(a, count, 0); | |
| 9362 | +} | |
| 9363 | +array builtin__array_repeat_to_depth(array a, int count, int depth) { | |
| 9364 | + if (count < 0) { | |
| 9365 | + builtin__panic_n(_S("array.repeat: count is negative:"), count); | |
| 9366 | + VUNREACHABLE(); | |
| 9367 | + } | |
| 9368 | + u64 size = ((u64)(count)) * ((u64)(a.len)) * ((u64)(a.element_size)); | |
| 9369 | + if (size == 0) { | |
| 9370 | + size = ((u64)(a.element_size)); | |
| 9371 | + } | |
| 9372 | + bool use_noscan_data = depth == 0 && builtin__array_uses_noscan_data(a); | |
| 9373 | + voidptr data = ((void*)0); | |
| 9374 | + if (use_noscan_data) { | |
| 9375 | + data = builtin__array_alloc_array_data_like(a, size); | |
| 9376 | + } else { | |
| 9377 | + data = builtin__alloc_array_data(size); | |
| 9378 | + } | |
| 9379 | + array _t1 = ((array){.data = (voidptr)data,.offset = 0,.len = count * a.len,.cap = count * a.len,.flags = (use_noscan_data ? ((ArrayFlags__managed | ArrayFlags__noscan_data)) : (ArrayFlags__managed)),.element_size = a.element_size,}); | |
| 9380 | + array arr = _t1; | |
| 9381 | + if (a.len > 0) { | |
| 9382 | + u64 a_total_size = ((u64)(a.len)) * ((u64)(a.element_size)); | |
| 9383 | + u64 arr_step_size = ((u64)(a.len)) * ((u64)(arr.element_size)); | |
| 9384 | + u8* eptr = ((u8*)(arr.data)); | |
| 9385 | + { // Unsafe block | |
| 9386 | + if (eptr != ((void*)0)) { | |
| 9387 | + for (int _t2 = 0; _t2 < count; ++_t2) { | |
| 9388 | + if (depth > 0) { | |
| 9389 | + array ary_clone = builtin__array_clone_to_depth(&a, depth); | |
| 9390 | + builtin__vmemcpy(eptr, ary_clone.data, a_total_size); | |
| 9391 | + } else { | |
| 9392 | + builtin__vmemcpy(eptr, a.data, a_total_size); | |
| 9393 | + } | |
| 9394 | + eptr += arr_step_size; | |
| 9395 | + } | |
| 9396 | + } | |
| 9397 | + } | |
| 9398 | + } | |
| 9399 | + return arr; | |
| 9400 | +} | |
| 9401 | +inline VV_LOC bool builtin__array_needs_unique_shift(array a, int required) { | |
| 9402 | + return required <= a.cap && (builtin__ArrayFlags_has(&a.flags, ArrayFlags__is_slice) || builtin__array_buffer_has_slices(a)); | |
| 9403 | +} | |
| 9404 | +inline VV_LOC bool builtin__array_needs_unique_append(array a, int required) { | |
| 9405 | + return required <= a.cap && builtin__ArrayFlags_has(&a.flags, ArrayFlags__is_slice); | |
| 9406 | +} | |
| 9407 | +inline VV_LOC bool builtin__array_needs_unique_shrink(array a) { | |
| 9408 | + return builtin__ArrayFlags_has(&a.flags, ArrayFlags__is_slice) || builtin__array_buffer_has_slices(a); | |
| 9409 | +} | |
| 9410 | +void builtin__array_insert(array* a, int i, voidptr val) { | |
| 9411 | + if (i < 0 || i > a->len) { | |
| 9412 | + builtin__panic_n2(_S("array.insert: index out of range (i,a.len):"), i, a->len); | |
| 9413 | + VUNREACHABLE(); | |
| 9414 | + } | |
| 9415 | + if (a->len == _const_max_int) { | |
| 9416 | + builtin___v_panic(_S("array.insert: a.len reached max_int")); | |
| 9417 | + VUNREACHABLE(); | |
| 9418 | + } | |
| 9419 | + int required = a->len + 1; | |
| 9420 | + if (builtin__array_needs_unique_shift(*a, required)) { | |
| 9421 | + builtin__array_clone_shallow_to_cap(a, a->cap); | |
| 9422 | + } else if (required > a->cap) { | |
| 9423 | + builtin__array_ensure_cap(a, required); | |
| 9424 | + } | |
| 9425 | + { // Unsafe block | |
| 9426 | + builtin__vmemmove(builtin__array_get_unsafe(*a, i + 1), builtin__array_get_unsafe(*a, i), ((u64)((a->len - i))) * ((u64)(a->element_size))); | |
| 9427 | + builtin__array_set_unsafe(a, i, val); | |
| 9428 | + } | |
| 9429 | + a->len++; | |
| 9430 | +} | |
| 9431 | +void builtin__array_prepend(array* a, voidptr val) { | |
| 9432 | + builtin__array_insert(a, 0, val); | |
| 9433 | +} | |
| 9434 | +void builtin__array_delete(array* a, int i) { | |
| 9435 | + if (i < 0 || i >= a->len) { | |
| 9436 | + builtin__panic_n2(_S("array.delete: index out of range (i,a.len):"), i, a->len); | |
| 9437 | + VUNREACHABLE(); | |
| 9438 | + } | |
| 9439 | + if (i == a->len - 1 && !builtin__array_needs_unique_shrink(*a)) { | |
| 9440 | + a->len--; | |
| 9441 | + builtin__vmemset(((u8*)(a->data)) + ((u64)(a->len)) * ((u64)(a->element_size)), 0, ((u64)(a->element_size))); | |
| 9442 | + return; | |
| 9443 | + } | |
| 9444 | + builtin__array_delete_many(a, i, 1); | |
| 9445 | +} | |
| 9446 | +void builtin__array_delete_many(array* a, int i, int size) { | |
| 9447 | + if (i < 0 || ((i64)(i)) + ((i64)(size)) > ((i64)(a->len))) { | |
| 9448 | + if (size > 1) { | |
| 9449 | + builtin__panic_n3(_S("array.delete: index out of range (i,i+size,a.len):"), i, i + size, a->len); | |
| 9450 | + VUNREACHABLE(); | |
| 9451 | + } else { | |
| 9452 | + builtin__panic_n2(_S("array.delete: index out of range (i,a.len):"), i, a->len); | |
| 9453 | + VUNREACHABLE(); | |
| 9454 | + } | |
| 9455 | + } | |
| 9456 | + if (size == 0) { | |
| 9457 | + if (builtin__array_needs_unique_shrink(*a)) { | |
| 9458 | + builtin__array_clone_shallow_to_cap(a, a->len); | |
| 9459 | + } | |
| 9460 | + return; | |
| 9461 | + } | |
| 9462 | + if (!builtin__array_needs_unique_shrink(*a)) { | |
| 9463 | + int new_len = a->len - size; | |
| 9464 | + { // Unsafe block | |
| 9465 | + builtin__vmemmove(((u8*)(a->data)) + ((u64)(i)) * ((u64)(a->element_size)), ((u8*)(a->data)) + ((u64)(i + size)) * ((u64)(a->element_size)), ((u64)(a->len - i - size)) * ((u64)(a->element_size))); | |
| 9466 | + builtin__vmemset(((u8*)(a->data)) + ((u64)(new_len)) * ((u64)(a->element_size)), 0, ((u64)(size)) * ((u64)(a->element_size))); | |
| 9467 | + } | |
| 9468 | + a->len = new_len; | |
| 9469 | + return; | |
| 9470 | + } | |
| 9471 | + voidptr old_data = a->data; | |
| 9472 | + int new_size = a->len - size; | |
| 9473 | + if (new_size == 0) { | |
| 9474 | + builtin__ArrayFlags_clear(&a->flags, ((ArrayFlags__managed | ArrayFlags__noscan_data) | ArrayFlags__is_slice)); | |
| 9475 | + a->data = ((void*)0); | |
| 9476 | + a->offset = 0; | |
| 9477 | + a->len = 0; | |
| 9478 | + a->cap = 0; | |
| 9479 | + return; | |
| 9480 | + } | |
| 9481 | + int new_cap = new_size; | |
| 9482 | + bool use_noscan_data = builtin__array_uses_noscan_data(*a); | |
| 9483 | + a->data = builtin__array_alloc_array_data_like(*a, ((u64)(new_cap)) * ((u64)(a->element_size))); | |
| 9484 | + builtin__vmemcpy(a->data, old_data, ((u64)(i)) * ((u64)(a->element_size))); | |
| 9485 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(i)) * ((u64)(a->element_size)), ((u8*)(old_data)) + ((u64)(i + size)) * ((u64)(a->element_size)), ((u64)(a->len - i - size)) * ((u64)(a->element_size))); | |
| 9486 | + if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__noslices) && !builtin__ArrayFlags_has(&a->flags, ArrayFlags__managed)) { | |
| 9487 | + builtin___v_free(old_data); | |
| 9488 | + } | |
| 9489 | + a->len = new_size; | |
| 9490 | + a->cap = new_cap; | |
| 9491 | + a->offset = 0; | |
| 9492 | + { // Unsafe block | |
| 9493 | + if (use_noscan_data) { | |
| 9494 | + builtin__ArrayFlags_set(&a->flags, ArrayFlags__noscan_data); | |
| 9495 | + } else { | |
| 9496 | + builtin__ArrayFlags_clear(&a->flags, ArrayFlags__noscan_data); | |
| 9497 | + } | |
| 9498 | + } | |
| 9499 | + builtin__array_set_managed_flags(a, false); | |
| 9500 | +} | |
| 9501 | +void builtin__array_clear(array* a) { | |
| 9502 | + if (builtin__array_needs_unique_shrink(*a)) { | |
| 9503 | + builtin__ArrayFlags_clear(&a->flags, ((ArrayFlags__managed | ArrayFlags__noscan_data) | ArrayFlags__is_slice)); | |
| 9504 | + a->data = ((void*)0); | |
| 9505 | + a->offset = 0; | |
| 9506 | + a->cap = 0; | |
| 9507 | + } | |
| 9508 | + a->len = 0; | |
| 9509 | +} | |
| 9510 | +void builtin__array_reset(array* a) { | |
| 9511 | + builtin__vmemset(a->data, 0, a->len * a->element_size); | |
| 9512 | +} | |
| 9513 | +void builtin__array_trim(array* a, int index) { | |
| 9514 | + if (index < a->len) { | |
| 9515 | + if (index >= 0 && builtin__array_needs_unique_shrink(*a)) { | |
| 9516 | + builtin__array_delete_many(a, index, a->len - index); | |
| 9517 | + return; | |
| 9518 | + } | |
| 9519 | + a->len = index; | |
| 9520 | + } | |
| 9521 | +} | |
| 9522 | +void builtin__array_drop(array* a, int num) { | |
| 9523 | + if (num <= 0) { | |
| 9524 | + return; | |
| 9525 | + } | |
| 9526 | + int n = (num <= a->len ? (num) : (a->len)); | |
| 9527 | + u64 blen = ((u64)(n)) * ((u64)(a->element_size)); | |
| 9528 | + a->data = ((u8*)(a->data)) + blen; | |
| 9529 | + a->offset += ((int)(blen)); | |
| 9530 | + a->len -= n; | |
| 9531 | + a->cap -= n; | |
| 9532 | +} | |
| 9533 | +inline VV_LOC voidptr builtin__array_get_unsafe(array a, int i) { | |
| 9534 | + { // Unsafe block | |
| 9535 | + return ((u8*)(a.data)) + ((u64)(i)) * ((u64)(a.element_size)); | |
| 9536 | + } | |
| 9537 | + return 0; | |
| 9538 | +} | |
| 9539 | +VV_LOC voidptr builtin__array_get(array a, int i) { | |
| 9540 | + #if 1 | |
| 9541 | + { | |
| 9542 | + if (i < 0 || i >= a.len) { | |
| 9543 | + builtin__panic_n2(_S("array.get: index out of range (i,a.len):"), i, a.len); | |
| 9544 | + VUNREACHABLE(); | |
| 9545 | + } | |
| 9546 | + } | |
| 9547 | + #endif | |
| 9548 | + { // Unsafe block | |
| 9549 | + return ((u8*)(a.data)) + ((u64)(i)) * ((u64)(a.element_size)); | |
| 9550 | + } | |
| 9551 | + return 0; | |
| 9552 | +} | |
| 9553 | +VV_LOC voidptr builtin__array_get_i64(array a, i64 i) { | |
| 9554 | + #if 1 | |
| 9555 | + { | |
| 9556 | + if (i < 0 || i >= ((i64)(a.len))) { | |
| 9557 | + builtin__panic_n2(_S("array.get: index out of range (i,a.len):"), i, a.len); | |
| 9558 | + VUNREACHABLE(); | |
| 9559 | + } | |
| 9560 | + } | |
| 9561 | + #endif | |
| 9562 | + { // Unsafe block | |
| 9563 | + return ((u8*)(a.data)) + ((u64)(i)) * ((u64)(a.element_size)); | |
| 9564 | + } | |
| 9565 | + return 0; | |
| 9566 | +} | |
| 9567 | +VV_LOC voidptr builtin__array_get_u64(array a, u64 i) { | |
| 9568 | + #if 1 | |
| 9569 | + { | |
| 9570 | + if (i >= ((u64)(a.len))) { | |
| 9571 | + builtin___v_panic(builtin__string_plus_many(4, _MOV((string[4]){_S("array.get: index out of range (i,a.len): "), builtin__u64_str(i), _S(", "), builtin__impl_i64_to_string(a.len)}))); | |
| 9572 | + VUNREACHABLE(); | |
| 9573 | + } | |
| 9574 | + } | |
| 9575 | + #endif | |
| 9576 | + { // Unsafe block | |
| 9577 | + return ((u8*)(a.data)) + i * ((u64)(a.element_size)); | |
| 9578 | + } | |
| 9579 | + return 0; | |
| 9580 | +} | |
| 9581 | +VV_LOC voidptr builtin__array_get_ni(array a, int i) { | |
| 9582 | + return builtin__array_get(a, builtin__v_ni_index(i, a.len)); | |
| 9583 | +} | |
| 9584 | +VV_LOC voidptr builtin__array_get_with_check(array a, int i) { | |
| 9585 | + if (i < 0 || i >= a.len) { | |
| 9586 | + return 0; | |
| 9587 | + } | |
| 9588 | + { // Unsafe block | |
| 9589 | + return ((u8*)(a.data)) + ((u64)(i)) * ((u64)(a.element_size)); | |
| 9590 | + } | |
| 9591 | + return 0; | |
| 9592 | +} | |
| 9593 | +VV_LOC voidptr builtin__array_get_with_check_i64(array a, i64 i) { | |
| 9594 | + if (i < 0 || i >= ((i64)(a.len))) { | |
| 9595 | + return 0; | |
| 9596 | + } | |
| 9597 | + { // Unsafe block | |
| 9598 | + return ((u8*)(a.data)) + ((u64)(i)) * ((u64)(a.element_size)); | |
| 9599 | + } | |
| 9600 | + return 0; | |
| 9601 | +} | |
| 9602 | +VV_LOC voidptr builtin__array_get_with_check_u64(array a, u64 i) { | |
| 9603 | + if (i >= ((u64)(a.len))) { | |
| 9604 | + return 0; | |
| 9605 | + } | |
| 9606 | + { // Unsafe block | |
| 9607 | + return ((u8*)(a.data)) + i * ((u64)(a.element_size)); | |
| 9608 | + } | |
| 9609 | + return 0; | |
| 9610 | +} | |
| 9611 | +VV_LOC voidptr builtin__array_get_with_check_ni(array a, int i) { | |
| 9612 | + return builtin__array_get_with_check(a, builtin__v_ni_index(i, a.len)); | |
| 9613 | +} | |
| 9614 | +voidptr builtin__array_first(array a) { | |
| 9615 | + if (a.len == 0) { | |
| 9616 | + builtin___v_panic(_S("array.first: array is empty")); | |
| 9617 | + VUNREACHABLE(); | |
| 9618 | + } | |
| 9619 | + return a.data; | |
| 9620 | +} | |
| 9621 | +voidptr builtin__array_last(array a) { | |
| 9622 | + if (a.len == 0) { | |
| 9623 | + builtin___v_panic(_S("array.last: array is empty")); | |
| 9624 | + VUNREACHABLE(); | |
| 9625 | + } | |
| 9626 | + { // Unsafe block | |
| 9627 | + return ((u8*)(a.data)) + ((u64)(a.len - 1)) * ((u64)(a.element_size)); | |
| 9628 | + } | |
| 9629 | + return 0; | |
| 9630 | +} | |
| 9631 | +voidptr builtin__array_pop_left(array* a) { | |
| 9632 | + if (a->len == 0) { | |
| 9633 | + builtin___v_panic(_S("array.pop_left: array is empty")); | |
| 9634 | + VUNREACHABLE(); | |
| 9635 | + } | |
| 9636 | + voidptr first_elem = a->data; | |
| 9637 | + { // Unsafe block | |
| 9638 | + a->data = ((u8*)(a->data)) + ((u64)(a->element_size)); | |
| 9639 | + } | |
| 9640 | + a->offset += a->element_size; | |
| 9641 | + a->len--; | |
| 9642 | + a->cap--; | |
| 9643 | + return first_elem; | |
| 9644 | +} | |
| 9645 | +voidptr builtin__array_pop(array* a) { | |
| 9646 | + if (a->len == 0) { | |
| 9647 | + builtin___v_panic(_S("array.pop: array is empty")); | |
| 9648 | + VUNREACHABLE(); | |
| 9649 | + } | |
| 9650 | + int new_len = a->len - 1; | |
| 9651 | + u8* last_elem = ((u8*)(a->data)) + ((u64)(new_len)) * ((u64)(a->element_size)); | |
| 9652 | + if (builtin__array_needs_unique_shrink(*a)) { | |
| 9653 | + builtin__array_delete_many(a, new_len, 1); | |
| 9654 | + return last_elem; | |
| 9655 | + } | |
| 9656 | + a->len = new_len; | |
| 9657 | + return last_elem; | |
| 9658 | +} | |
| 9659 | +void builtin__array_delete_last(array* a) { | |
| 9660 | + if (a->len == 0) { | |
| 9661 | + builtin___v_panic(_S("array.delete_last: array is empty")); | |
| 9662 | + VUNREACHABLE(); | |
| 9663 | + } | |
| 9664 | + if (builtin__array_needs_unique_shrink(*a)) { | |
| 9665 | + builtin__array_delete_many(a, a->len - 1, 1); | |
| 9666 | + return; | |
| 9667 | + } | |
| 9668 | + a->len--; | |
| 9669 | + builtin__vmemset(((u8*)(a->data)) + ((u64)(a->len)) * ((u64)(a->element_size)), 0, ((u64)(a->element_size))); | |
| 9670 | +} | |
| 9671 | +VV_LOC array builtin__array_slice(array a, int start, int _end) { | |
| 9672 | + int end = (_end == _const_max_i64 || _end == _const_max_i32 ? (a.len) : (_end)); | |
| 9673 | + #if 1 | |
| 9674 | + { | |
| 9675 | + if (start > end) { | |
| 9676 | + builtin___v_panic(builtin__string_plus_many(4, _MOV((string[4]){_S("array.slice: invalid slice index (start>end):"), builtin__impl_i64_to_string(((i64)(start))), _S(", "), builtin__impl_i64_to_string(end)}))); | |
| 9677 | + VUNREACHABLE(); | |
| 9678 | + } | |
| 9679 | + if (end > a.len) { | |
| 9680 | + builtin___v_panic(builtin__string_plus_many(5, _MOV((string[5]){_S("array.slice: slice bounds out of range ("), builtin__impl_i64_to_string(end), _S(" >= "), builtin__impl_i64_to_string(a.len), _S(")")}))); | |
| 9681 | + VUNREACHABLE(); | |
| 9682 | + } | |
| 9683 | + if (start < 0) { | |
| 9684 | + builtin___v_panic(builtin__string__plus(_S("array.slice: slice bounds out of range (start<0):"), builtin__impl_i64_to_string(start))); | |
| 9685 | + VUNREACHABLE(); | |
| 9686 | + } | |
| 9687 | + } | |
| 9688 | + #endif | |
| 9689 | + builtin__array_mark_buffer_has_slices(&a); | |
| 9690 | + u64 offset = ((u64)(start)) * ((u64)(a.element_size)); | |
| 9691 | + u8* data = ((u8*)(a.data)) + offset; | |
| 9692 | + int l = end - start; | |
| 9693 | + ArrayFlags flags = ArrayFlags__is_slice; | |
| 9694 | + if (builtin__array_uses_noscan_data(a)) { | |
| 9695 | + builtin__ArrayFlags_set(&flags, ArrayFlags__noscan_data); | |
| 9696 | + } | |
| 9697 | + array res = ((array){ | |
| 9698 | + .data = (voidptr)data, | |
| 9699 | + .offset = a.offset + ((int)(offset)), | |
| 9700 | + .len = l, | |
| 9701 | + .cap = l, | |
| 9702 | + .flags = flags, | |
| 9703 | + .element_size = a.element_size, | |
| 9704 | + }); | |
| 9705 | + return res; | |
| 9706 | +} | |
| 9707 | +VV_LOC array builtin__array_slice_ni(array a, int _start, int _end) { | |
| 9708 | + builtin__array_mark_buffer_has_slices(&a); | |
| 9709 | + ArrayFlags flags = ArrayFlags__is_slice; | |
| 9710 | + if (builtin__array_uses_noscan_data(a)) { | |
| 9711 | + builtin__ArrayFlags_set(&flags, ArrayFlags__noscan_data); | |
| 9712 | + } | |
| 9713 | + int end = (_end == _const_max_i64 || _end == _const_max_i32 ? (a.len) : (_end)); | |
| 9714 | + int start = _start; | |
| 9715 | + if (start < 0) { | |
| 9716 | + start = a.len + start; | |
| 9717 | + if (start < 0) { | |
| 9718 | + start = 0; | |
| 9719 | + } | |
| 9720 | + } | |
| 9721 | + if (end < 0) { | |
| 9722 | + end = a.len + end; | |
| 9723 | + if (end < 0) { | |
| 9724 | + end = 0; | |
| 9725 | + } | |
| 9726 | + } | |
| 9727 | + if (end >= a.len) { | |
| 9728 | + end = a.len; | |
| 9729 | + } | |
| 9730 | + if (start >= a.len || start > end) { | |
| 9731 | + array res = ((array){ | |
| 9732 | + .data = a.data, | |
| 9733 | + .offset = 0, | |
| 9734 | + .len = 0, | |
| 9735 | + .cap = 0, | |
| 9736 | + .flags = flags, | |
| 9737 | + .element_size = a.element_size, | |
| 9738 | + }); | |
| 9739 | + return res; | |
| 9740 | + } | |
| 9741 | + u64 offset = ((u64)(start)) * ((u64)(a.element_size)); | |
| 9742 | + u8* data = ((u8*)(a.data)) + offset; | |
| 9743 | + int l = end - start; | |
| 9744 | + array res = ((array){ | |
| 9745 | + .data = (voidptr)data, | |
| 9746 | + .offset = a.offset + ((int)(offset)), | |
| 9747 | + .len = l, | |
| 9748 | + .cap = l, | |
| 9749 | + .flags = flags, | |
| 9750 | + .element_size = a.element_size, | |
| 9751 | + }); | |
| 9752 | + return res; | |
| 9753 | +} | |
| 9754 | +VV_LOC array builtin__array_clone_static_to_depth(array a, int depth) { | |
| 9755 | + return builtin__array_clone_to_depth(&a, depth); | |
| 9756 | +} | |
| 9757 | +array builtin__array_clone(array* a) { | |
| 9758 | + return builtin__array_clone_to_depth(a, 0); | |
| 9759 | +} | |
| 9760 | +array builtin__array_clone_to_depth(array* a, int depth) { | |
| 9761 | + u64 source_capacity_in_bytes = ((u64)(a->cap)) * ((u64)(a->element_size)); | |
| 9762 | + bool use_noscan_data = depth == 0 && builtin__array_uses_noscan_data(*a); | |
| 9763 | + voidptr data = ((void*)0); | |
| 9764 | + if (a->cap > 0) { | |
| 9765 | + if (use_noscan_data) { | |
| 9766 | + data = builtin__array_alloc_array_data_like(*a, source_capacity_in_bytes); | |
| 9767 | + } else { | |
| 9768 | + data = builtin__alloc_array_data(source_capacity_in_bytes); | |
| 9769 | + } | |
| 9770 | + } | |
| 9771 | + array _t1 = ((array){.data = (voidptr)data,.offset = 0,.len = a->len,.cap = a->cap,.flags = (use_noscan_data ? ((ArrayFlags__managed | ArrayFlags__noscan_data)) : (ArrayFlags__managed)),.element_size = a->element_size,}); | |
| 9772 | + array arr = _t1; | |
| 9773 | + if (depth > 0 && _us32_eq(sizeof(array),a->element_size) && a->len >= 0 && a->cap >= a->len) { | |
| 9774 | + array _t2 = ((array){.data = 0,.offset = 0,.len = 0,.cap = 0,.flags = 0,.element_size = 0,}); | |
| 9775 | + array ar = _t2; | |
| 9776 | + int asize = ((int)(sizeof(array))); | |
| 9777 | + for (int i = 0; i < a->len; ++i) { | |
| 9778 | + builtin__vmemcpy(&ar, builtin__array_get_unsafe(*a, i), asize); | |
| 9779 | + array ar_clone = builtin__array_clone_to_depth(&ar, depth - 1); | |
| 9780 | + builtin__array_set_unsafe(&arr, i, &ar_clone); | |
| 9781 | + } | |
| 9782 | + return arr; | |
| 9783 | + } else if (depth > 0 && _us32_eq(sizeof(string),a->element_size) && a->len >= 0 && a->cap >= a->len) { | |
| 9784 | + for (int i = 0; i < a->len; ++i) { | |
| 9785 | + string* str_ptr = ((string*)(builtin__array_get_unsafe(*a, i))); | |
| 9786 | + string str_clone = builtin__string_clone((*str_ptr)); | |
| 9787 | + builtin__array_set_unsafe(&arr, i, &str_clone); | |
| 9788 | + } | |
| 9789 | + return arr; | |
| 9790 | + } | |
| 9791 | + if (a->data != 0 && source_capacity_in_bytes > 0) { | |
| 9792 | + builtin__vmemcpy(arr.data, a->data, source_capacity_in_bytes); | |
| 9793 | + } | |
| 9794 | + return arr; | |
| 9795 | +} | |
| 9796 | +inline VV_LOC void builtin__array_set_unsafe(array* a, int i, voidptr val) { | |
| 9797 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(a->element_size)) * ((u64)(i)), val, a->element_size); | |
| 9798 | +} | |
| 9799 | +VV_LOC void builtin__array_set(array* a, int i, voidptr val) { | |
| 9800 | + #if 1 | |
| 9801 | + { | |
| 9802 | + if (i < 0 || i >= a->len) { | |
| 9803 | + builtin__panic_n2(_S("array.set: index out of range (i,a.len):"), i, a->len); | |
| 9804 | + VUNREACHABLE(); | |
| 9805 | + } | |
| 9806 | + } | |
| 9807 | + #endif | |
| 9808 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(a->element_size)) * ((u64)(i)), val, a->element_size); | |
| 9809 | +} | |
| 9810 | +VV_LOC void builtin__array_set_i64(array* a, i64 i, voidptr val) { | |
| 9811 | + #if 1 | |
| 9812 | + { | |
| 9813 | + if (i < 0 || i >= ((i64)(a->len))) { | |
| 9814 | + builtin__panic_n2(_S("array.set: index out of range (i,a.len):"), i, a->len); | |
| 9815 | + VUNREACHABLE(); | |
| 9816 | + } | |
| 9817 | + } | |
| 9818 | + #endif | |
| 9819 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(a->element_size)) * ((u64)(i)), val, a->element_size); | |
| 9820 | +} | |
| 9821 | +VV_LOC void builtin__array_set_u64(array* a, u64 i, voidptr val) { | |
| 9822 | + #if 1 | |
| 9823 | + { | |
| 9824 | + if (i >= ((u64)(a->len))) { | |
| 9825 | + builtin___v_panic(builtin__string_plus_many(4, _MOV((string[4]){_S("array.set: index out of range (i,a.len): "), builtin__u64_str(i), _S(", "), builtin__impl_i64_to_string(a->len)}))); | |
| 9826 | + VUNREACHABLE(); | |
| 9827 | + } | |
| 9828 | + } | |
| 9829 | + #endif | |
| 9830 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(a->element_size)) * i, val, a->element_size); | |
| 9831 | +} | |
| 9832 | +VV_LOC void builtin__array_set_ni(array* a, int i, voidptr val) { | |
| 9833 | + builtin__array_set(a, builtin__v_ni_index(i, a->len), val); | |
| 9834 | +} | |
| 9835 | +inline VV_LOC void builtin__copy_element_to(voidptr dest, voidptr src, int element_size) { | |
| 9836 | + { // Unsafe block | |
| 9837 | + switch (element_size) { | |
| 9838 | + case 1: { | |
| 9839 | + builtin__vmemcpy(dest, src, 1); | |
| 9840 | + break; | |
| 9841 | + } | |
| 9842 | + case 2: { | |
| 9843 | + builtin__vmemcpy(dest, src, 2); | |
| 9844 | + break; | |
| 9845 | + } | |
| 9846 | + case 4: { | |
| 9847 | + builtin__vmemcpy(dest, src, 4); | |
| 9848 | + break; | |
| 9849 | + } | |
| 9850 | + case 8: { | |
| 9851 | + builtin__vmemcpy(dest, src, 8); | |
| 9852 | + break; | |
| 9853 | + } | |
| 9854 | + case 16: { | |
| 9855 | + builtin__vmemcpy(dest, src, 16); | |
| 9856 | + break; | |
| 9857 | + } | |
| 9858 | + default: { | |
| 9859 | + { | |
| 9860 | + builtin__vmemcpy(dest, src, element_size); | |
| 9861 | + break; | |
| 9862 | + } | |
| 9863 | + } | |
| 9864 | + } | |
| 9865 | + | |
| 9866 | + } | |
| 9867 | +} | |
| 9868 | +VV_LOC void builtin__array_push(array* a, voidptr val) { | |
| 9869 | + #if 1 | |
| 9870 | + { | |
| 9871 | + if (a->len < 0) { | |
| 9872 | + builtin___v_panic(_S("array.push: negative len")); | |
| 9873 | + VUNREACHABLE(); | |
| 9874 | + } | |
| 9875 | + } | |
| 9876 | + #endif | |
| 9877 | + if (a->len >= _const_max_int) { | |
| 9878 | + builtin___v_panic(_S("array.push: len bigger than max_int")); | |
| 9879 | + VUNREACHABLE(); | |
| 9880 | + } | |
| 9881 | + int required = a->len + 1; | |
| 9882 | + if (required > a->cap) { | |
| 9883 | + builtin__array_ensure_cap(a, required); | |
| 9884 | + } else if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__is_slice)) { | |
| 9885 | + builtin__array_clone_shallow_to_cap(a, a->cap); | |
| 9886 | + } | |
| 9887 | + builtin__copy_element_to(((u8*)(a->data)) + ((u64)(a->element_size)) * ((u64)(a->len)), val, a->element_size); | |
| 9888 | + a->len++; | |
| 9889 | +} | |
| 9890 | +void builtin__array_push_many(array* a, voidptr val, int size) { | |
| 9891 | + if (size <= 0 || val == ((void*)0)) { | |
| 9892 | + return; | |
| 9893 | + } | |
| 9894 | + i64 new_len = ((i64)(a->len)) + ((i64)(size)); | |
| 9895 | + if (new_len > _const_max_int) { | |
| 9896 | + builtin___v_panic(_S("array.push_many: new len exceeds max_int")); | |
| 9897 | + VUNREACHABLE(); | |
| 9898 | + } | |
| 9899 | + if (builtin__array_needs_unique_append(*a, ((int)(new_len)))) { | |
| 9900 | + builtin__array_clone_shallow_to_cap(a, a->cap); | |
| 9901 | + } | |
| 9902 | + bool is_self_append = a->data == val && a->data != 0; | |
| 9903 | + if (((int)(new_len)) > a->cap) { | |
| 9904 | + builtin__array_ensure_cap(a, ((int)(new_len))); | |
| 9905 | + } | |
| 9906 | + if (is_self_append) { | |
| 9907 | + array cloned = builtin__array_clone(a); | |
| 9908 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(a->element_size)) * ((u64)(a->len)), cloned.data, ((u64)(a->element_size)) * ((u64)(size))); | |
| 9909 | + } else { | |
| 9910 | + if (a->data != 0 && val != 0) { | |
| 9911 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(a->element_size)) * ((u64)(a->len)), val, ((u64)(a->element_size)) * ((u64)(size))); | |
| 9912 | + } | |
| 9913 | + } | |
| 9914 | + a->len = ((int)(new_len)); | |
| 9915 | +} | |
| 9916 | +void builtin__array_reverse_in_place(array* a) { | |
| 9917 | + if (a->len < 2 || a->element_size == 0) { | |
| 9918 | + return; | |
| 9919 | + } | |
| 9920 | + { // Unsafe block | |
| 9921 | + u8* tmp_value = builtin___v_malloc(a->element_size); | |
| 9922 | + for (int i = 0; i < VSAFE_DIV_int(a->len , 2); ++i) { | |
| 9923 | + builtin__vmemcpy(tmp_value, ((u8*)(a->data)) + ((u64)(i)) * ((u64)(a->element_size)), a->element_size); | |
| 9924 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(i)) * ((u64)(a->element_size)), ((u8*)(a->data)) + ((u64)((int)(a->len - 1 - i))) * ((u64)(a->element_size)), a->element_size); | |
| 9925 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)((int)(a->len - 1 - i))) * ((u64)(a->element_size)), tmp_value, a->element_size); | |
| 9926 | + } | |
| 9927 | + builtin___v_free(tmp_value); | |
| 9928 | + } | |
| 9929 | +} | |
| 9930 | +array builtin__array_reverse(array a) { | |
| 9931 | + if (a.len < 2) { | |
| 9932 | + return a; | |
| 9933 | + } | |
| 9934 | + bool use_noscan_data = builtin__array_uses_noscan_data(a); | |
| 9935 | + array _t2 = ((array){.data = builtin__array_alloc_array_data_like(a, ((u64)(a.cap)) * ((u64)(a.element_size))),.offset = 0,.len = a.len,.cap = a.cap,.flags = (use_noscan_data ? ((ArrayFlags__managed | ArrayFlags__noscan_data)) : (ArrayFlags__managed)),.element_size = a.element_size,}); | |
| 9936 | + array arr = _t2; | |
| 9937 | + for (int i = 0; i < a.len; ++i) { | |
| 9938 | + builtin__array_set_unsafe(&arr, i, builtin__array_get_unsafe(a, (int)(a.len - 1 - i))); | |
| 9939 | + } | |
| 9940 | + return arr; | |
| 9941 | +} | |
| 9942 | +void builtin__array_free(array* a) { | |
| 9943 | + if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__nofree)) { | |
| 9944 | + return; | |
| 9945 | + } | |
| 9946 | + u8* mblock_ptr = ((u8*)(((u64)(a->data)) - ((u64)(a->offset)))); | |
| 9947 | + if (mblock_ptr != ((void*)0)) { | |
| 9948 | + { // Unsafe block | |
| 9949 | + if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__managed)) { | |
| 9950 | + builtin___v_free(mblock_ptr - builtin__array_data_header_size()); | |
| 9951 | + } else { | |
| 9952 | + builtin___v_free(mblock_ptr); | |
| 9953 | + } | |
| 9954 | + } | |
| 9955 | + } | |
| 9956 | + { // Unsafe block | |
| 9957 | + a->data = ((void*)0); | |
| 9958 | + a->offset = 0; | |
| 9959 | + a->len = 0; | |
| 9960 | + a->cap = 0; | |
| 9961 | + } | |
| 9962 | +} | |
| 9963 | +array builtin__array_filter(array a, bool (*predicate)(voidptr _d1)); | |
| 9964 | +bool builtin__array_any(array a, bool (*predicate)(voidptr _d1)); | |
| 9965 | +int builtin__array_count(array a, bool (*predicate)(voidptr _d1)); | |
| 9966 | +bool builtin__array_all(array a, bool (*predicate)(voidptr _d1)); | |
| 9967 | +array builtin__array_map(array a, voidptr (*callback)(voidptr _d1)); | |
| 9968 | +void builtin__array_sort(array* a, int (*callback)(voidptr _d1, voidptr _d2)); | |
| 9969 | +array builtin__array_sorted(array* a, int (*callback)(voidptr _d1, voidptr _d2)); | |
| 9970 | +void builtin__array_sort_with_compare(array* a, int (*callback)(const void* const_a, const void* const_b)) { | |
| 9971 | + #if 0 | |
| 9972 | + { | |
| 9973 | + } | |
| 9974 | + #else | |
| 9975 | + { | |
| 9976 | + builtin__vqsort(a->data, ((usize)(a->len)), ((usize)(a->element_size)), callback); | |
| 9977 | + } | |
| 9978 | + #endif | |
| 9979 | +} | |
| 9980 | +array builtin__array_sorted_with_compare(array* a, int (*callback)(const void* const_a, const void* const_b)) { | |
| 9981 | + array r = builtin__array_clone(a); | |
| 9982 | + builtin__vqsort(r.data, ((usize)(r.len)), ((usize)(r.element_size)), callback); | |
| 9983 | + return r; | |
| 9984 | +} | |
| 9985 | +bool builtin__array_contains(array a, voidptr value); | |
| 9986 | +int builtin__array_index(array a, voidptr value); | |
| 9987 | +int builtin__array_last_index(array a, voidptr value); | |
| 9988 | +void Array_string_free(Array_string* a) { | |
| 9989 | + for (int _t1 = 0; _t1 < a->len; ++_t1) { | |
| 9990 | + string* s = ((string*)a->data) + _t1; | |
| 9991 | + builtin__string_free(s); | |
| 9992 | + } | |
| 9993 | + array* arr = ((array*)(a)); | |
| 9994 | + builtin__array_free(arr); | |
| 9995 | +} | |
| 9996 | +string Array_string_str(Array_string a) { | |
| 9997 | + int sb_len = 4; | |
| 9998 | + if (a.len > 0) { | |
| 9999 | + sb_len += ((string*)a.data)[0].len; | |
| 10000 | + sb_len *= a.len; | |
| 10001 | + } | |
| 10002 | + sb_len += 2; | |
| 10003 | + strings__Builder sb = strings__new_builder(sb_len); | |
| 10004 | + strings__Builder_write_u8(&sb, '['); | |
| 10005 | + for (int i = 0; i < a.len; ++i) { | |
| 10006 | + string val = ((string*)a.data)[i]; | |
| 10007 | + strings__Builder_write_u8(&sb, '\''); | |
| 10008 | + strings__Builder_write_string(&sb, val); | |
| 10009 | + strings__Builder_write_u8(&sb, '\''); | |
| 10010 | + if (i < a.len - 1) { | |
| 10011 | + strings__Builder_write_string(&sb, _S(", ")); | |
| 10012 | + } | |
| 10013 | + } | |
| 10014 | + strings__Builder_write_u8(&sb, ']'); | |
| 10015 | + string res = strings__Builder_str(&sb); | |
| 10016 | + strings__Builder_free(&sb); | |
| 10017 | + return res; | |
| 10018 | +} | |
| 10019 | +string Array_u8_hex(Array_u8 b) { | |
| 10020 | + if (b.len == 0) { | |
| 10021 | + return _S(""); | |
| 10022 | + } | |
| 10023 | + return builtin__data_to_hex_string(b.data, b.len); | |
| 10024 | +} | |
| 10025 | +int builtin__copy(Array_u8* dst, Array_u8 src) { | |
| 10026 | + int min = (dst->len < src.len ? (dst->len) : (src.len)); | |
| 10027 | + if (min > 0) { | |
| 10028 | + builtin__vmemmove(dst->data, src.data, min); | |
| 10029 | + } | |
| 10030 | + return min; | |
| 10031 | +} | |
| 10032 | +void builtin__array_grow_cap(array* a, int amount) { | |
| 10033 | + i64 new_cap = ((i64)(amount)) + ((i64)(a->cap)); | |
| 10034 | + if (new_cap > _const_max_int) { | |
| 10035 | + builtin__panic_n(_S("array.grow_cap: max_int will be exceeded by new cap:"), new_cap); | |
| 10036 | + VUNREACHABLE(); | |
| 10037 | + } | |
| 10038 | + builtin__array_ensure_cap(a, ((int)(new_cap))); | |
| 10039 | +} | |
| 10040 | +void builtin__array_grow_len(array* a, int amount) { | |
| 10041 | + i64 new_len = ((i64)(amount)) + ((i64)(a->len)); | |
| 10042 | + if (new_len > _const_max_int) { | |
| 10043 | + builtin__panic_n(_S("array.grow_len: max_int will be exceeded by new len:"), new_len); | |
| 10044 | + VUNREACHABLE(); | |
| 10045 | + } | |
| 10046 | + builtin__array_ensure_cap(a, ((int)(new_len))); | |
| 10047 | + a->len = ((int)(new_len)); | |
| 10048 | +} | |
| 10049 | +Array_voidptr builtin__array_pointers(array a) { | |
| 10050 | + Array_voidptr res = builtin____new_array_with_default(0, 0, sizeof(voidptr), 0); | |
| 10051 | + for (int i = 0; i < a.len; ++i) { | |
| 10052 | + builtin__array_push((array*)&res, _MOV((voidptr[]){ builtin__array_get_unsafe(a, i) })); | |
| 10053 | + } | |
| 10054 | + return res; | |
| 10055 | +} | |
| 10056 | +Array_u8 builtin__voidptr_vbytes(voidptr data, int len) { | |
| 10057 | + array _t1 = ((array){.data = data,.offset = 0,.len = len,.cap = len,.flags = 0,.element_size = 1,}); | |
| 10058 | + array res = _t1; | |
| 10059 | + return res; | |
| 10060 | +} | |
| 10061 | +Array_u8 builtin__u8_vbytes(u8* data, int len) { | |
| 10062 | + return builtin__voidptr_vbytes(((voidptr)(data)), len); | |
| 10063 | +} | |
| 10064 | +void builtin__u8_free(u8* data) { | |
| 10065 | + builtin___v_free(data); | |
| 10066 | +} | |
| 10067 | +inline VV_LOC void builtin__panic_on_negative_len(int len) { | |
| 10068 | + if (len < 0) { | |
| 10069 | + builtin__panic_n(_S("negative .len:"), len); | |
| 10070 | + VUNREACHABLE(); | |
| 10071 | + } | |
| 10072 | +} | |
| 10073 | +inline VV_LOC void builtin__panic_on_negative_cap(int cap) { | |
| 10074 | + if (cap < 0) { | |
| 10075 | + builtin__panic_n(_S("negative .cap:"), cap); | |
| 10076 | + VUNREACHABLE(); | |
| 10077 | + } | |
| 10078 | +} | |
| 10079 | +VV_LOC array builtin____new_array_noscan(int mylen, int cap, int elm_size) { | |
| 10080 | + return builtin____new_array(mylen, cap, elm_size); | |
| 10081 | +} | |
| 10082 | +VV_LOC array builtin____new_array_with_default_noscan(int mylen, int cap, int elm_size, voidptr val) { | |
| 10083 | + return builtin____new_array_with_default(mylen, cap, elm_size, val); | |
| 10084 | +} | |
| 10085 | +VV_LOC array builtin____new_array_with_multi_default_noscan(int mylen, int cap, int elm_size, voidptr val) { | |
| 10086 | + return builtin____new_array_with_multi_default(mylen, cap, elm_size, val); | |
| 10087 | +} | |
| 10088 | +VV_LOC array builtin____new_array_with_array_default_noscan(int mylen, int cap, int elm_size, array val, int depth) { | |
| 10089 | + return builtin____new_array_with_array_default(mylen, cap, elm_size, val, depth); | |
| 10090 | +} | |
| 10091 | +VV_LOC void builtin__array_push_noscan(array* a, voidptr val) { | |
| 10092 | + builtin__array_push(a, val); | |
| 10093 | +} | |
| 10094 | +VV_LOC void builtin__array_push_many_noscan(array* a, voidptr val, int size) { | |
| 10095 | + builtin__array_push_many(a, val, size); | |
| 10096 | +} | |
| 10097 | +VV_LOC bool builtin__autostr_type_in_stack(int typ) { | |
| 10098 | + for (int i = 0; i < g_autostr_type_stack_len; i++) { | |
| 10099 | + if (g_autostr_type_stack[builtin__v_fixed_index(i, 64)] == typ) { | |
| 10100 | + return true; | |
| 10101 | + } | |
| 10102 | + } | |
| 10103 | + return false; | |
| 10104 | +} | |
| 10105 | +VV_LOC void builtin__autostr_type_push(int typ) { | |
| 10106 | + if (g_autostr_type_stack_len >= _const_autostr_type_stack_max_depth) { | |
| 10107 | + return; | |
| 10108 | + } | |
| 10109 | + g_autostr_type_stack[builtin__v_fixed_index(g_autostr_type_stack_len, 64)] = typ; | |
| 10110 | + g_autostr_type_stack_len++; | |
| 10111 | +} | |
| 10112 | +VV_LOC void builtin__autostr_type_pop(void) { | |
| 10113 | + if (g_autostr_type_stack_len > 0) { | |
| 10114 | + g_autostr_type_stack_len--; | |
| 10115 | + } | |
| 10116 | +} | |
| 10117 | +VV_LOC bool builtin__autostr_addr_in_stack(voidptr addr) { | |
| 10118 | + for (int i = 0; i < g_autostr_addr_stack_len; i++) { | |
| 10119 | + if (g_autostr_addr_stack[builtin__v_fixed_index(i, 64)] == addr) { | |
| 10120 | + return true; | |
| 10121 | + } | |
| 10122 | + } | |
| 10123 | + return false; | |
| 10124 | +} | |
| 10125 | +VV_LOC void builtin__autostr_addr_push(voidptr addr) { | |
| 10126 | + if (g_autostr_addr_stack_len >= _const_autostr_type_stack_max_depth) { | |
| 10127 | + return; | |
| 10128 | + } | |
| 10129 | + g_autostr_addr_stack[builtin__v_fixed_index(g_autostr_addr_stack_len, 64)] = addr; | |
| 10130 | + g_autostr_addr_stack_len++; | |
| 10131 | +} | |
| 10132 | +VV_LOC void builtin__autostr_addr_pop(void) { | |
| 10133 | + if (g_autostr_addr_stack_len > 0) { | |
| 10134 | + g_autostr_addr_stack_len--; | |
| 10135 | + } | |
| 10136 | +} | |
| 10137 | +VV_LOC string builtin__autostr_array_circular(int len) { | |
| 10138 | + if (len <= 0) { | |
| 10139 | + return _S("[]"); | |
| 10140 | + } | |
| 10141 | + strings__Builder sb = strings__new_builder(2 + len * 12); | |
| 10142 | + strings__Builder_write_string(&sb, _S("[")); | |
| 10143 | + for (int i = 0; i < len; ++i) { | |
| 10144 | + if (i > 0) { | |
| 10145 | + strings__Builder_write_string(&sb, _S(", ")); | |
| 10146 | + } | |
| 10147 | + strings__Builder_write_string(&sb, _S("<circular>")); | |
| 10148 | + } | |
| 10149 | + strings__Builder_write_string(&sb, _S("]")); | |
| 10150 | + string res = strings__Builder_str(&sb); | |
| 10151 | + strings__Builder_free(&sb); | |
| 10152 | + return res; | |
| 10153 | +} | |
| 10154 | +void builtin__print_backtrace(void) { | |
| 10155 | + #if !defined(CUSTOM_DEFINE_no_backtrace) | |
| 10156 | + { | |
| 10157 | + #if 0 | |
| 10158 | + { | |
| 10159 | + } | |
| 10160 | + #elif defined(__TINYC__) | |
| 10161 | + { | |
| 10162 | + } | |
| 10163 | + #elif defined(CUSTOM_DEFINE_use_libbacktrace) | |
| 10164 | + { | |
| 10165 | + } | |
| 10166 | + #else | |
| 10167 | + { | |
| 10168 | + builtin__print_backtrace_skipping_top_frames(2); | |
| 10169 | + } | |
| 10170 | + #endif | |
| 10171 | + } | |
| 10172 | + #endif | |
| 10173 | +} | |
| 10174 | +VV_LOC string builtin__demangle_v_symbol(string cname) { | |
| 10175 | + string name = cname; | |
| 10176 | + if (builtin__string_starts_with(name, _S("builtin__"))) { | |
| 10177 | + name = builtin__string_substr(name, 9, 2147483647); | |
| 10178 | + } | |
| 10179 | + name = builtin__string_replace(name, _S("__ptr__"), _S("&")); | |
| 10180 | + _option_int _t1 = builtin__string_index(name, _S("_T_")); | |
| 10181 | + if (_t1.state != 0) { | |
| 10182 | + *(int*) _t1.data = -1; | |
| 10183 | + } | |
| 10184 | + | |
| 10185 | + int t_pos = (*(int*)_t1.data); | |
| 10186 | + if (t_pos >= 0) { | |
| 10187 | + string base = builtin__string_replace(builtin__string_substr(name, 0, t_pos), _S("__"), _S(".")); | |
| 10188 | + string generic_suffix = builtin__string_substr(name, t_pos + 3, 2147483647); | |
| 10189 | + Array_string params = builtin__split_generic_params(generic_suffix); | |
| 10190 | + Array_string demangled_params = builtin____new_array_with_default(0, params.len, sizeof(string), 0); | |
| 10191 | + for (int _t2 = 0; _t2 < params.len; ++_t2) { | |
| 10192 | + string param = ((string*)params.data)[_t2]; | |
| 10193 | + builtin__array_push((array*)&demangled_params, _MOV((string[]){ builtin__string_replace(param, _S("__"), _S(".")) })); | |
| 10194 | + } | |
| 10195 | + return builtin__string_plus_many(4, _MOV((string[4]){base, _S("["), Array_string_join(demangled_params, _S(", ")), _S("]")})); | |
| 10196 | + } | |
| 10197 | + name = builtin__string_replace(name, _S("__"), _S(".")); | |
| 10198 | + if (_SLIT_EQ(name.str, name.len, "main.main")) { | |
| 10199 | + return _S("main"); | |
| 10200 | + } | |
| 10201 | + return name; | |
| 10202 | +} | |
| 10203 | +VV_LOC Array_string builtin__split_generic_params(string s) { | |
| 10204 | + Array_string params = builtin____new_array_with_default(0, 0, sizeof(string), 0); | |
| 10205 | + int start = 0; | |
| 10206 | + int i = 0; | |
| 10207 | + for (;;) { | |
| 10208 | + if (!(i < s.len)) break; | |
| 10209 | + if (s.str[ i] == '_') { | |
| 10210 | + if (i + 1 < s.len && s.str[ i + 1] == '_') { | |
| 10211 | + i += 2; | |
| 10212 | + } else { | |
| 10213 | + if (i > start) { | |
| 10214 | + builtin__array_push((array*)¶ms, _MOV((string[]){ builtin__string_substr(s, start, i) })); | |
| 10215 | + } | |
| 10216 | + i++; | |
| 10217 | + start = i; | |
| 10218 | + } | |
| 10219 | + } else { | |
| 10220 | + i++; | |
| 10221 | + } | |
| 10222 | + } | |
| 10223 | + if (start < s.len) { | |
| 10224 | + builtin__array_push((array*)¶ms, _MOV((string[]){ builtin__string_substr(s, start, 2147483647) })); | |
| 10225 | + } | |
| 10226 | + return params; | |
| 10227 | +} | |
| 10228 | +VV_LOC string builtin__demangle_backtrace_sym(string s) { | |
| 10229 | + _option_int _t1 = builtin__string_index(s, _S("(")); | |
| 10230 | + if (_t1.state != 0) { | |
| 10231 | + return s; | |
| 10232 | + } | |
| 10233 | + | |
| 10234 | + int paren_start = (*(int*)_t1.data); | |
| 10235 | + int plus_pos = builtin__string_index_after_(s, _S("+"), paren_start); | |
| 10236 | + if (plus_pos < 0) { | |
| 10237 | + return s; | |
| 10238 | + } | |
| 10239 | + string symbol = builtin__string_substr(s, paren_start + 1, plus_pos); | |
| 10240 | + if (symbol.len == 0) { | |
| 10241 | + return s; | |
| 10242 | + } | |
| 10243 | + return builtin__string_plus_many(3, _MOV((string[3]){builtin__string_substr(s, 0, paren_start + 1), builtin__demangle_v_symbol(symbol), builtin__string_substr(s, plus_pos, 2147483647)})); | |
| 10244 | +} | |
| 10245 | +VV_LOC void builtin__eprint_space_padding(string output, int max_len) { | |
| 10246 | + int padding_len = max_len - output.len; | |
| 10247 | + if (padding_len > 0) { | |
| 10248 | + for (int _t1 = 0; _t1 < padding_len; ++_t1) { | |
| 10249 | + builtin__eprint(_S(" ")); | |
| 10250 | + } | |
| 10251 | + } | |
| 10252 | +} | |
| 10253 | +bool builtin__print_backtrace_skipping_top_frames(int xskipframes) { | |
| 10254 | + #if defined(CUSTOM_DEFINE_no_backtrace) | |
| 10255 | + { | |
| 10256 | + } | |
| 10257 | + #else | |
| 10258 | + { | |
| 10259 | + int skipframes = xskipframes + 2; | |
| 10260 | + #if 0 | |
| 10261 | + { | |
| 10262 | + } | |
| 10263 | + #elif 1 | |
| 10264 | + { | |
| 10265 | + return builtin__print_backtrace_skipping_top_frames_linux(skipframes); | |
| 10266 | + } | |
| 10267 | + #else | |
| 10268 | + { | |
| 10269 | + } | |
| 10270 | + #endif | |
| 10271 | + } | |
| 10272 | + #endif | |
| 10273 | + return false; | |
| 10274 | +} | |
| 10275 | +VV_LOC string builtin__backtrace_current_executable_name(void) { | |
| 10276 | + Array_string args = builtin__arguments(); | |
| 10277 | + if (args.len == 0) { | |
| 10278 | + return _S(""); | |
| 10279 | + } | |
| 10280 | + return (*(string*)builtin__array_get(args, 0)); | |
| 10281 | +} | |
| 10282 | +VV_LOC string builtin__backtrace_addr2line_executable(string executable, string current_executable_name) { | |
| 10283 | + if (executable.len == 0) { | |
| 10284 | + return _S("/proc/self/exe"); | |
| 10285 | + } | |
| 10286 | + if (builtin__string_contains(executable, _S("/"))) { | |
| 10287 | + return executable; | |
| 10288 | + } | |
| 10289 | + if (current_executable_name.len > 0 && builtin__string__eq(builtin__string_all_after_last(executable, _S("/")), builtin__string_all_after_last(current_executable_name, _S("/")))) { | |
| 10290 | + return _S("/proc/self/exe"); | |
| 10291 | + } | |
| 10292 | + return executable; | |
| 10293 | +} | |
| 10294 | +VV_LOC string builtin__backtrace_shell_quote(string s) { | |
| 10295 | + string quoted = _S("'"); | |
| 10296 | + for (int i = 0; i < s.len; ++i) { | |
| 10297 | + if (builtin__string_at(s, i) == '\'') { | |
| 10298 | + quoted = builtin__string__plus(quoted, _S("'\\''")); | |
| 10299 | + } else { | |
| 10300 | + quoted = builtin__string__plus(quoted, builtin__u8_ascii_str(builtin__string_at(s, i))); | |
| 10301 | + } | |
| 10302 | + } | |
| 10303 | + return builtin__string__plus(quoted, _S("'")); | |
| 10304 | +} | |
| 10305 | +VV_LOC bool builtin__print_backtrace_skipping_top_frames_linux(int skipframes) { | |
| 10306 | + #if defined(CUSTOM_DEFINE_no_backtrace) | |
| 10307 | + { | |
| 10308 | + } | |
| 10309 | + #else | |
| 10310 | + { | |
| 10311 | + #if 1 | |
| 10312 | + { | |
| 10313 | + #if 0 | |
| 10314 | + { | |
| 10315 | + } | |
| 10316 | + #else | |
| 10317 | + { | |
| 10318 | + string current_executable_name = builtin__backtrace_current_executable_name(); | |
| 10319 | + Array_fixed_voidptr_100 buffer = {0}; | |
| 10320 | + i32 nr_ptrs = backtrace(&buffer[0], 100); | |
| 10321 | + if (nr_ptrs < 2) { | |
| 10322 | + builtin__eprintln(_S("C.backtrace returned less than 2 frames")); | |
| 10323 | + return false; | |
| 10324 | + } | |
| 10325 | + int nr_actual_frames = (int)(nr_ptrs - skipframes); | |
| 10326 | + char** csymbols = backtrace_symbols(((voidptr)(&buffer[skipframes])), nr_actual_frames); | |
| 10327 | + for (int i = 0; i < nr_actual_frames; ++i) { | |
| 10328 | + string sframe = builtin__tos2(((u8*)(csymbols[i]))); | |
| 10329 | + string executable = builtin__string_all_before(sframe, _S("(")); | |
| 10330 | + string addr2line_executable = builtin__backtrace_addr2line_executable(executable, current_executable_name); | |
| 10331 | + string addr = builtin__string_all_before(builtin__string_all_after(sframe, _S("[")), _S("]")); | |
| 10332 | + string beforeaddr = builtin__string_all_before(sframe, _S("[")); | |
| 10333 | + string cmd = builtin__string_plus_many(4, _MOV((string[4]){_S("addr2line -e "), builtin__backtrace_shell_quote(addr2line_executable), _S(" "), builtin__backtrace_shell_quote(addr)})); | |
| 10334 | + voidptr f = popen(((char*)(cmd.str)), "r"); | |
| 10335 | + if (f == ((void*)0)) { | |
| 10336 | + builtin__eprintln(sframe); | |
| 10337 | + continue; | |
| 10338 | + } | |
| 10339 | + Array_fixed_u8_1000 buf = {0}; | |
| 10340 | + string output = _S(""); | |
| 10341 | + { // Unsafe block | |
| 10342 | + u8* bp = ((u8*)(&buf[0])); | |
| 10343 | + for (;;) { | |
| 10344 | + if (!(fgets(((char*)(bp)), 1000, f) != 0)) break; | |
| 10345 | + output = builtin__string__plus(output, builtin__tos(bp, builtin__vstrlen(bp))); | |
| 10346 | + } | |
| 10347 | + } | |
| 10348 | + output = builtin__string__plus(builtin__string_trim_chars(output, _S(" \t\n"), TrimMode__trim_both), _S(":")); | |
| 10349 | + if (pclose(f) != 0) { | |
| 10350 | + builtin__eprintln(sframe); | |
| 10351 | + continue; | |
| 10352 | + } | |
| 10353 | + if (_SLIT_EQ(output.str, output.len, "??:0:") || _SLIT_EQ(output.str, output.len, "??:?:")) { | |
| 10354 | + output = _S(""); | |
| 10355 | + } | |
| 10356 | + output = builtin__string_replace(output, _S(" (discriminator"), _S(": (d.")); | |
| 10357 | + builtin__eprint(output); | |
| 10358 | + builtin__eprint_space_padding(output, 55); | |
| 10359 | + builtin__eprint(_S(" | ")); | |
| 10360 | + builtin__eprint(addr); | |
| 10361 | + builtin__eprint(_S(" | ")); | |
| 10362 | + builtin__eprintln(builtin__demangle_backtrace_sym(beforeaddr)); | |
| 10363 | + } | |
| 10364 | + if (nr_actual_frames > 0) { | |
| 10365 | + free(csymbols); | |
| 10366 | + } | |
| 10367 | + } | |
| 10368 | + #endif | |
| 10369 | + } | |
| 10370 | + #endif | |
| 10371 | + } | |
| 10372 | + #endif | |
| 10373 | + return true; | |
| 10374 | +} | |
| 10375 | +VNORETURN void builtin___v_exit(int code) { | |
| 10376 | + exit(code); | |
| 10377 | + VUNREACHABLE(); | |
| 10378 | + for (;;) { | |
| 10379 | + } | |
| 10380 | + while(1); | |
| 10381 | +} | |
| 10382 | +_result_void builtin__at_exit(void (*cb)(void)) { | |
| 10383 | + #if 0 | |
| 10384 | + { | |
| 10385 | + } | |
| 10386 | + #else | |
| 10387 | + { | |
| 10388 | + i32 res = atexit(cb); | |
| 10389 | + if (res != 0) { | |
| 10390 | + return (_result_void){ .is_error=true, .err=builtin__error_with_code(_S("at_exit failed"), res), .data={E_STRUCT} }; | |
| 10391 | + } | |
| 10392 | + } | |
| 10393 | + #endif | |
| 10394 | + return (_result_void){0}; | |
| 10395 | +} | |
| 10396 | +VV_LOC void builtin__v_segmentation_fault_handler(i32 signal_number) { | |
| 10397 | + #if defined(CUSTOM_DEFINE_v2_native_windows_pe_minimal) | |
| 10398 | + { | |
| 10399 | + } | |
| 10400 | + #else | |
| 10401 | + { | |
| 10402 | + #if 0 | |
| 10403 | + { | |
| 10404 | + } | |
| 10405 | + #else | |
| 10406 | + { | |
| 10407 | + fprintf(stderr, "signal %d: segmentation fault\n", signal_number); | |
| 10408 | + } | |
| 10409 | + #endif | |
| 10410 | + #if defined(CUSTOM_DEFINE_use_libbacktrace) && !defined(__TINYC__) | |
| 10411 | + { | |
| 10412 | + } | |
| 10413 | + #elif 0 | |
| 10414 | + { | |
| 10415 | + } | |
| 10416 | + #else | |
| 10417 | + { | |
| 10418 | + builtin__print_backtrace(); | |
| 10419 | + } | |
| 10420 | + #endif | |
| 10421 | + builtin___v_exit(128 + signal_number); | |
| 10422 | + VUNREACHABLE(); | |
| 10423 | + } | |
| 10424 | + #endif | |
| 10425 | +} | |
| 10426 | +inline VV_LOC int builtin__v_fixed_index(int i, int len) { | |
| 10427 | + #if 1 | |
| 10428 | + { | |
| 10429 | + if (i < 0 || i >= len) { | |
| 10430 | + builtin___v_panic(builtin__string_plus_many(5, _MOV((string[5]){_S("fixed array index out of range (index: "), builtin__i64_str(((i64)(i))), _S(", len: "), builtin__i64_str(((i64)(len))), _S(")")}))); | |
| 10431 | + VUNREACHABLE(); | |
| 10432 | + } | |
| 10433 | + } | |
| 10434 | + #endif | |
| 10435 | + return i; | |
| 10436 | +} | |
| 10437 | +inline VV_LOC int builtin__v_fixed_index_i64(i64 i, int len) { | |
| 10438 | + #if 1 | |
| 10439 | + { | |
| 10440 | + if (i < 0 || i >= ((i64)(len))) { | |
| 10441 | + builtin___v_panic(builtin__string_plus_many(5, _MOV((string[5]){_S("fixed array index out of range (index: "), builtin__i64_str(i), _S(", len: "), builtin__i64_str(((i64)(len))), _S(")")}))); | |
| 10442 | + VUNREACHABLE(); | |
| 10443 | + } | |
| 10444 | + } | |
| 10445 | + #endif | |
| 10446 | + return ((int)(i)); | |
| 10447 | +} | |
| 10448 | +inline VV_LOC int builtin__v_fixed_index_u64(u64 i, int len) { | |
| 10449 | + #if 1 | |
| 10450 | + { | |
| 10451 | + if (i >= ((u64)(len))) { | |
| 10452 | + builtin___v_panic(builtin__string_plus_many(5, _MOV((string[5]){_S("fixed array index out of range (index: "), builtin__u64_str(i), _S(", len: "), builtin__i64_str(((i64)(len))), _S(")")}))); | |
| 10453 | + VUNREACHABLE(); | |
| 10454 | + } | |
| 10455 | + } | |
| 10456 | + #endif | |
| 10457 | + return ((int)(i)); | |
| 10458 | +} | |
| 10459 | +inline VV_LOC int builtin__v_fixed_index_ni(int i, int len) { | |
| 10460 | + return builtin__v_fixed_index(builtin__v_ni_index(i, len), len); | |
| 10461 | +} | |
| 10462 | +inline VV_LOC int builtin__v_slice_index_i64(i64 i) { | |
| 10463 | + if (i < ((i64)(_const_min_int)) || i > ((i64)(_const_max_int))) { | |
| 10464 | + builtin___v_panic(builtin__string__plus(_S("slice index out of range for int: "), builtin__i64_str(i))); | |
| 10465 | + VUNREACHABLE(); | |
| 10466 | + } | |
| 10467 | + return ((int)(i)); | |
| 10468 | +} | |
| 10469 | +inline VV_LOC int builtin__v_slice_index_u64(u64 i) { | |
| 10470 | + if (i > ((u64)(_const_max_int))) { | |
| 10471 | + builtin___v_panic(builtin__string__plus(_S("slice index out of range for int: "), builtin__u64_str(i))); | |
| 10472 | + VUNREACHABLE(); | |
| 10473 | + } | |
| 10474 | + return ((int)(i)); | |
| 10475 | +} | |
| 10476 | +Array_string builtin__arguments(void) { | |
| 10477 | + u8** argv = ((u8**)(g_main_argv)); | |
| 10478 | + Array_string res = builtin____new_array_with_default(0, g_main_argc, sizeof(string), 0); | |
| 10479 | + for (int i = 0; i < g_main_argc; ++i) { | |
| 10480 | + #if 0 | |
| 10481 | + { | |
| 10482 | + } | |
| 10483 | + #else | |
| 10484 | + { | |
| 10485 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__tos_clone(argv[i]) })); | |
| 10486 | + } | |
| 10487 | + #endif | |
| 10488 | + } | |
| 10489 | + return res; | |
| 10490 | +} | |
| 10491 | +string builtin__vcurrent_hash(void) { | |
| 10492 | + return _S(""); | |
| 10493 | +} | |
| 10494 | +u64 builtin__v_getpid(void) { | |
| 10495 | + #if defined(CUSTOM_DEFINE_no_getpid) | |
| 10496 | + { | |
| 10497 | + } | |
| 10498 | + #elif 0 | |
| 10499 | + { | |
| 10500 | + } | |
| 10501 | + #else | |
| 10502 | + { | |
| 10503 | + return ((u64)(getpid())); | |
| 10504 | + } | |
| 10505 | + #endif | |
| 10506 | + return 0; | |
| 10507 | +} | |
| 10508 | +u64 builtin__v_gettid(void) { | |
| 10509 | + #if defined(CUSTOM_DEFINE_no_gettid) | |
| 10510 | + { | |
| 10511 | + } | |
| 10512 | + #elif 0 | |
| 10513 | + { | |
| 10514 | + } | |
| 10515 | + #elif 1 | |
| 10516 | + { | |
| 10517 | + return ((u64)(gettid())); | |
| 10518 | + } | |
| 10519 | + #elif 0 | |
| 10520 | + { | |
| 10521 | + } | |
| 10522 | + #else | |
| 10523 | + { | |
| 10524 | + } | |
| 10525 | + #endif | |
| 10526 | + return 0; | |
| 10527 | +} | |
| 10528 | +inline bool builtin__isnil(voidptr v) { | |
| 10529 | + return v == 0; | |
| 10530 | +} | |
| 10531 | +VV_LOC void builtin__builtin_init(void) { | |
| 10532 | + #if 1 | |
| 10533 | + { | |
| 10534 | + builtin__unbuffer_stdout(); | |
| 10535 | + } | |
| 10536 | + #endif | |
| 10537 | +} | |
| 10538 | +VNORETURN void builtin__panic_lasterr(string base) { | |
| 10539 | + builtin___v_panic(builtin__string__plus(base, _S(" unknown"))); | |
| 10540 | + VUNREACHABLE(); | |
| 10541 | + while(1); | |
| 10542 | +} | |
| 10543 | +void builtin__gc_check_leaks(void) { | |
| 10544 | +} | |
| 10545 | +bool builtin__gc_is_enabled(void) { | |
| 10546 | + return false; | |
| 10547 | +} | |
| 10548 | +void builtin__gc_enable(void) { | |
| 10549 | +} | |
| 10550 | +void builtin__gc_disable(void) { | |
| 10551 | +} | |
| 10552 | +void builtin__gc_collect(void) { | |
| 10553 | +} | |
| 10554 | +void builtin__gc_get_warn_proc(void) { | |
| 10555 | +} | |
| 10556 | +void builtin__gc_set_warn_proc(void (*cb)(char* msg, usize arg)) { | |
| 10557 | +} | |
| 10558 | +#if 0 | |
| 10559 | +#else | |
| 10560 | +#endif | |
| 10561 | +inline int builtin__vstrlen(u8* s) { | |
| 10562 | + return ((int)(strlen(((char*)(s))))); | |
| 10563 | +} | |
| 10564 | +inline int builtin__vstrlen_char(char* s) { | |
| 10565 | + return ((int)(strlen(s))); | |
| 10566 | +} | |
| 10567 | +inline voidptr builtin__vmemcpy(voidptr dest, const void* const_src, isize n) { | |
| 10568 | + if (n == 0 || ((u64)(dest)) <= 0xFFFF || ((u64)(const_src)) <= 0xFFFF) { | |
| 10569 | + return dest; | |
| 10570 | + } | |
| 10571 | + { // Unsafe block | |
| 10572 | + return memcpy(dest, const_src, n); | |
| 10573 | + } | |
| 10574 | + return 0; | |
| 10575 | +} | |
| 10576 | +inline voidptr builtin__vmemmove(voidptr dest, const void* const_src, isize n) { | |
| 10577 | + if (n == 0 || ((u64)(dest)) <= 0xFFFF || ((u64)(const_src)) <= 0xFFFF) { | |
| 10578 | + return dest; | |
| 10579 | + } | |
| 10580 | + { // Unsafe block | |
| 10581 | + return memmove(dest, const_src, n); | |
| 10582 | + } | |
| 10583 | + return 0; | |
| 10584 | +} | |
| 10585 | +inline int builtin__vmemcmp(const void* const_s1, const void* const_s2, isize n) { | |
| 10586 | + if (n == 0 || ((u64)(const_s1)) <= 0xFFFF || ((u64)(const_s2)) <= 0xFFFF) { | |
| 10587 | + return 0; | |
| 10588 | + } | |
| 10589 | + { // Unsafe block | |
| 10590 | + return memcmp(const_s1, const_s2, n); | |
| 10591 | + } | |
| 10592 | + return 0; | |
| 10593 | +} | |
| 10594 | +inline voidptr builtin__vmemset(voidptr s, int c, isize n) { | |
| 10595 | + if (n == 0 || ((u64)(s)) <= 0xFFFF) { | |
| 10596 | + return s; | |
| 10597 | + } | |
| 10598 | + { // Unsafe block | |
| 10599 | + return memset(s, c, n); | |
| 10600 | + } | |
| 10601 | + return 0; | |
| 10602 | +} | |
| 10603 | +inline VV_LOC voidptr builtin__vsort_ptr_at(voidptr base, usize index, usize size) { | |
| 10604 | + return ((voidptr)(((u8*)(base)) + index * size)); | |
| 10605 | +} | |
| 10606 | +VV_LOC void builtin__vstable_sort_merge(voidptr source, voidptr dest, usize left, usize mid, usize right, usize size, int (*sort_cb)(const void* const_a, const void* const_b)) { | |
| 10607 | + usize left_index = left; | |
| 10608 | + usize right_index = mid; | |
| 10609 | + usize dest_index = left; | |
| 10610 | + for (;;) { | |
| 10611 | + if (!(left_index < mid && right_index < right)) break; | |
| 10612 | + voidptr left_ptr = builtin__vsort_ptr_at(source, left_index, size); | |
| 10613 | + voidptr right_ptr = builtin__vsort_ptr_at(source, right_index, size); | |
| 10614 | + if (sort_cb(left_ptr, right_ptr) <= 0) { | |
| 10615 | + builtin__vmemcpy(builtin__vsort_ptr_at(dest, dest_index, size), left_ptr, ((isize)(size))); | |
| 10616 | + left_index++; | |
| 10617 | + } else { | |
| 10618 | + builtin__vmemcpy(builtin__vsort_ptr_at(dest, dest_index, size), right_ptr, ((isize)(size))); | |
| 10619 | + right_index++; | |
| 10620 | + } | |
| 10621 | + dest_index++; | |
| 10622 | + } | |
| 10623 | + if (left_index < mid) { | |
| 10624 | + builtin__vmemcpy(builtin__vsort_ptr_at(dest, dest_index, size), builtin__vsort_ptr_at(source, left_index, size), ((isize)((mid - left_index) * size))); | |
| 10625 | + } | |
| 10626 | + if (right_index < right) { | |
| 10627 | + builtin__vmemcpy(builtin__vsort_ptr_at(dest, dest_index, size), builtin__vsort_ptr_at(source, right_index, size), ((isize)((right - right_index) * size))); | |
| 10628 | + } | |
| 10629 | +} | |
| 10630 | +inline VV_LOC void builtin__vqsort(voidptr base, usize nmemb, usize size, int (*sort_cb)(const void* const_a, const void* const_b)) { | |
| 10631 | + if (nmemb < 2 || size == 0) { | |
| 10632 | + return; | |
| 10633 | + } | |
| 10634 | + isize total_size = ((isize)(nmemb * size)); | |
| 10635 | + u8* buffer = builtin___v_malloc(total_size); | |
| 10636 | + voidptr source = base; | |
| 10637 | + voidptr dest = ((voidptr)(buffer)); | |
| 10638 | + usize width = ((usize)(1)); | |
| 10639 | + for (;;) { | |
| 10640 | + if (!(width < nmemb)) break; | |
| 10641 | + usize left = ((usize)(0)); | |
| 10642 | + for (;;) { | |
| 10643 | + if (!(left < nmemb)) break; | |
| 10644 | + usize mid = (left + width < nmemb ? (left + width) : (nmemb)); | |
| 10645 | + usize right = (left + width + width < nmemb ? (left + width + width) : (nmemb)); | |
| 10646 | + builtin__vstable_sort_merge(source, dest, left, mid, right, size, sort_cb); | |
| 10647 | + left += width + width; | |
| 10648 | + } | |
| 10649 | + voidptr tmp = source; | |
| 10650 | + source = dest; | |
| 10651 | + dest = tmp; | |
| 10652 | + width += width; | |
| 10653 | + } | |
| 10654 | + if (source != base) { | |
| 10655 | + builtin__vmemcpy(base, source, total_size); | |
| 10656 | + } | |
| 10657 | + { // defer begin | |
| 10658 | + builtin___v_free(buffer); | |
| 10659 | + } // defer end | |
| 10660 | +} | |
| 10661 | +void builtin__chan_close(chan ch, Array_IError err) { | |
| 10662 | +} | |
| 10663 | +ChanState builtin__chan_try_pop(chan ch, voidptr obj) { | |
| 10664 | + return ChanState__success; | |
| 10665 | +} | |
| 10666 | +ChanState builtin__chan_try_push(chan ch, voidptr obj) { | |
| 10667 | + return ChanState__success; | |
| 10668 | +} | |
| 10669 | +VV_LOC void builtin___result_ok(voidptr data, _result* res, int size) { | |
| 10670 | + { // Unsafe block | |
| 10671 | + *res = ((_result){.is_error = 0,.err = _const_none__,}); | |
| 10672 | + builtin__vmemcpy(((u8*)(&res->err)) + sizeof(IError), data, size); | |
| 10673 | + } | |
| 10674 | +} | |
| 10675 | +VV_LOC void builtin___result_clone(_result* current, _result* res, int size) { | |
| 10676 | + { // Unsafe block | |
| 10677 | + *res = ((_result){.is_error = current->is_error,.err = current->err,}); | |
| 10678 | + builtin__vmemcpy(((u8*)(&res->err)) + sizeof(IError), ((u8*)(¤t->err)) + sizeof(IError), size); | |
| 10679 | + } | |
| 10680 | +} | |
| 10681 | +string builtin__IError_str(IError err) { | |
| 10682 | + if ((err)._typ == _IError_None___index) { | |
| 10683 | + return _S("none"); | |
| 10684 | + } | |
| 10685 | + int c = ((struct _IError_interface_methods*)(err._methods))->_method_code(err._object); | |
| 10686 | + if (c > 0) { | |
| 10687 | + return builtin__string_plus_many(3, _MOV((string[3]){((struct _IError_interface_methods*)(err._methods))->_method_msg(err._object), _S("; code: "), builtin__int_str(c)})); | |
| 10688 | + } | |
| 10689 | + return ((struct _IError_interface_methods*)(err._methods))->_method_msg(err._object); | |
| 10690 | +} | |
| 10691 | +string builtin__Error_msg(Error err) { | |
| 10692 | + return _S(""); | |
| 10693 | +} | |
| 10694 | +int builtin__Error_code(Error err) { | |
| 10695 | + return 0; | |
| 10696 | +} | |
| 10697 | +string builtin__MessageError_str(MessageError err) { | |
| 10698 | + if (err.code > 0) { | |
| 10699 | + return builtin__string_plus_many(3, _MOV((string[3]){err.msg, _S("; code: "), builtin__int_str(err.code)})); | |
| 10700 | + } | |
| 10701 | + return err.msg; | |
| 10702 | +} | |
| 10703 | +string builtin__MessageError_msg(MessageError err) { | |
| 10704 | + return err.msg; | |
| 10705 | +} | |
| 10706 | +int builtin__MessageError_code(MessageError err) { | |
| 10707 | + return err.code; | |
| 10708 | +} | |
| 10709 | +void builtin__MessageError_free(MessageError* err) { | |
| 10710 | + builtin__string_free(&err->msg); | |
| 10711 | +} | |
| 10712 | +inline IError builtin___v_error(string message) { | |
| 10713 | + ; | |
| 10714 | + return I_MessageError_to_Interface_IError((HEAP(MessageError, ((MessageError){.msg = message,.code = 0,})))); | |
| 10715 | +} | |
| 10716 | +inline IError builtin__error_with_code(string message, int code) { | |
| 10717 | + ; | |
| 10718 | + MessageError* _t2 = (MessageError*)builtin___v_malloc(sizeof(MessageError) == 0 ? 1 : sizeof(MessageError)); | |
| 10719 | + _t2->msg = message; | |
| 10720 | + _t2->code = code; | |
| 10721 | + return I_MessageError_to_Interface_IError( _t2); | |
| 10722 | +} | |
| 10723 | +VV_LOC void builtin___option_none(voidptr data, _option* option, int size) { | |
| 10724 | + { // Unsafe block | |
| 10725 | + *option = ((_option){.state = 2,.err = _const_none__,}); | |
| 10726 | + builtin__vmemcpy(((u8*)(&option->err)) + sizeof(IError), data, size); | |
| 10727 | + } | |
| 10728 | +} | |
| 10729 | +VV_LOC void builtin___option_ok(voidptr data, _option* option, int size) { | |
| 10730 | + { // Unsafe block | |
| 10731 | + *option = ((_option){.state = 0,.err = _const_none__,}); | |
| 10732 | + builtin__vmemcpy(((u8*)(&option->err)) + sizeof(IError), data, size); | |
| 10733 | + } | |
| 10734 | +} | |
| 10735 | +VV_LOC void builtin___option_clone(_option* current, _option* option, int size) { | |
| 10736 | + { // Unsafe block | |
| 10737 | + *option = ((_option){.state = current->state,.err = current->err,}); | |
| 10738 | + builtin__vmemcpy(((u8*)(&option->err)) + sizeof(IError), ((u8*)(¤t->err)) + sizeof(IError), size); | |
| 10739 | + } | |
| 10740 | +} | |
| 10741 | +VV_LOC void builtin___result_ok_markused(void) { | |
| 10742 | + _result _t1 = ((_result){.is_error = 0,.err = _const_none__,}); | |
| 10743 | + _result res = _t1; | |
| 10744 | + builtin___result_ok(((void*)0), (voidptr)&res, 0); | |
| 10745 | +} | |
| 10746 | +VV_LOC string builtin__None___str(None__ _d1) { | |
| 10747 | + return _S("none"); | |
| 10748 | +} | |
| 10749 | +string builtin__none_str(none _d1) { | |
| 10750 | + return _S("none"); | |
| 10751 | +} | |
| 10752 | +int builtin__input_character(void) { | |
| 10753 | + int ch = 0; | |
| 10754 | + #if 0 | |
| 10755 | + { | |
| 10756 | + } | |
| 10757 | + #elif 0 | |
| 10758 | + { | |
| 10759 | + } | |
| 10760 | + #else | |
| 10761 | + { | |
| 10762 | + ch = getchar(); | |
| 10763 | + if (ch == EOF) { | |
| 10764 | + return -1; | |
| 10765 | + } | |
| 10766 | + } | |
| 10767 | + #endif | |
| 10768 | + return ch; | |
| 10769 | +} | |
| 10770 | +int builtin__print_character(u8 ch) { | |
| 10771 | + #if 0 | |
| 10772 | + { | |
| 10773 | + } | |
| 10774 | + #elif 0 | |
| 10775 | + { | |
| 10776 | + } | |
| 10777 | + #elif 0 | |
| 10778 | + { | |
| 10779 | + } | |
| 10780 | + #else | |
| 10781 | + { | |
| 10782 | + i32 x = putchar(ch); | |
| 10783 | + if (x == EOF) { | |
| 10784 | + return -1; | |
| 10785 | + } | |
| 10786 | + } | |
| 10787 | + #endif | |
| 10788 | + return ch; | |
| 10789 | +} | |
| 10790 | +#if !defined(CUSTOM_DEFINE_nofloat) | |
| 10791 | +#endif | |
| 10792 | +inline string builtin__f64_str(f64 x) { | |
| 10793 | + { // Unsafe block | |
| 10794 | + strconv__Float64u _t1 = ((strconv__Float64u){.f = x,}); | |
| 10795 | + strconv__Float64u f = _t1; | |
| 10796 | + if (f.u == _const_strconv__double_minus_zero) { | |
| 10797 | + return _S("-0.0"); | |
| 10798 | + } | |
| 10799 | + if (f.u == _const_strconv__double_plus_zero) { | |
| 10800 | + return _S("0.0"); | |
| 10801 | + } | |
| 10802 | + } | |
| 10803 | + f64 abs_x = builtin__f64_abs(x); | |
| 10804 | + if (abs_x >= ((f64)(0.0001)) && abs_x < ((f64)(1.0e6))) { | |
| 10805 | + return strconv__f64_to_str_l(x); | |
| 10806 | + } else { | |
| 10807 | + return strconv__ftoa_64(x); | |
| 10808 | + } | |
| 10809 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 10810 | +} | |
| 10811 | +inline string builtin__f64_strg(f64 x) { | |
| 10812 | + { // Unsafe block | |
| 10813 | + strconv__Float64u _t1 = ((strconv__Float64u){.f = x,}); | |
| 10814 | + strconv__Float64u f = _t1; | |
| 10815 | + if (f.u == _const_strconv__double_minus_zero || f.u == _const_strconv__double_plus_zero) { | |
| 10816 | + return _S("0.0"); | |
| 10817 | + } | |
| 10818 | + } | |
| 10819 | + f64 abs_x = builtin__f64_abs(x); | |
| 10820 | + if (abs_x >= ((f64)(0.0001)) && abs_x < ((f64)(1.0e6))) { | |
| 10821 | + return strconv__f64_to_str_l_with_dot(x); | |
| 10822 | + } else { | |
| 10823 | + return strconv__ftoa_64(x); | |
| 10824 | + } | |
| 10825 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 10826 | +} | |
| 10827 | +inline string builtin__float_literal_str(float_literal d) { | |
| 10828 | + return builtin__f64_str(((f64)(d))); | |
| 10829 | +} | |
| 10830 | +inline string builtin__f64_strsci(f64 x, int digit_num) { | |
| 10831 | + int n_digit = digit_num; | |
| 10832 | + if (n_digit < 1) { | |
| 10833 | + n_digit = 1; | |
| 10834 | + } else if (n_digit > 17) { | |
| 10835 | + n_digit = 17; | |
| 10836 | + } | |
| 10837 | + return strconv__f64_to_str(x, n_digit); | |
| 10838 | +} | |
| 10839 | +inline string builtin__f64_strlong(f64 x) { | |
| 10840 | + return strconv__f64_to_str_l(x); | |
| 10841 | +} | |
| 10842 | +inline string builtin__f32_str(f32 x) { | |
| 10843 | + { // Unsafe block | |
| 10844 | + strconv__Float32u _t1 = ((strconv__Float32u){.f = x,}); | |
| 10845 | + strconv__Float32u f = _t1; | |
| 10846 | + if (f.u == _const_strconv__single_minus_zero) { | |
| 10847 | + return _S("-0.0"); | |
| 10848 | + } | |
| 10849 | + if (f.u == _const_strconv__single_plus_zero) { | |
| 10850 | + return _S("0.0"); | |
| 10851 | + } | |
| 10852 | + } | |
| 10853 | + f32 abs_x = builtin__f32_abs(x); | |
| 10854 | + if (abs_x >= ((f32)(0.0001)) && abs_x < ((f32)(1.0e6))) { | |
| 10855 | + return strconv__f32_to_str_l(x); | |
| 10856 | + } else { | |
| 10857 | + return strconv__ftoa_32(x); | |
| 10858 | + } | |
| 10859 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 10860 | +} | |
| 10861 | +inline string builtin__f32_strg(f32 x) { | |
| 10862 | + { // Unsafe block | |
| 10863 | + strconv__Float32u _t1 = ((strconv__Float32u){.f = x,}); | |
| 10864 | + strconv__Float32u f = _t1; | |
| 10865 | + if (f.u == _const_strconv__single_minus_zero || f.u == _const_strconv__single_plus_zero) { | |
| 10866 | + return _S("0.0"); | |
| 10867 | + } | |
| 10868 | + } | |
| 10869 | + f32 abs_x = builtin__f32_abs(x); | |
| 10870 | + if (abs_x >= ((f32)(0.0001)) && abs_x < ((f32)(1.0e6))) { | |
| 10871 | + return strconv__f32_to_str_l_with_dot(x); | |
| 10872 | + } else { | |
| 10873 | + return strconv__ftoa_32(x); | |
| 10874 | + } | |
| 10875 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 10876 | +} | |
| 10877 | +inline string builtin__f32_strsci(f32 x, int digit_num) { | |
| 10878 | + int n_digit = digit_num; | |
| 10879 | + if (n_digit < 1) { | |
| 10880 | + n_digit = 1; | |
| 10881 | + } else if (n_digit > 8) { | |
| 10882 | + n_digit = 8; | |
| 10883 | + } | |
| 10884 | + return strconv__f32_to_str(x, n_digit); | |
| 10885 | +} | |
| 10886 | +inline string builtin__f32_strlong(f32 x) { | |
| 10887 | + return strconv__f32_to_str_l(x); | |
| 10888 | +} | |
| 10889 | +inline f32 builtin__f32_abs(f32 a) { | |
| 10890 | + if (a < 0) { | |
| 10891 | + return -a; | |
| 10892 | + } | |
| 10893 | + return a; | |
| 10894 | +} | |
| 10895 | +inline f64 builtin__f64_abs(f64 a) { | |
| 10896 | + if (a < 0) { | |
| 10897 | + return -a; | |
| 10898 | + } | |
| 10899 | + return a; | |
| 10900 | +} | |
| 10901 | +inline f32 builtin__f32_min(f32 a, f32 b) { | |
| 10902 | + if (a < b) { | |
| 10903 | + return a; | |
| 10904 | + } | |
| 10905 | + return b; | |
| 10906 | +} | |
| 10907 | +inline f32 builtin__f32_max(f32 a, f32 b) { | |
| 10908 | + if (a > b) { | |
| 10909 | + return a; | |
| 10910 | + } | |
| 10911 | + return b; | |
| 10912 | +} | |
| 10913 | +inline f64 builtin__f64_min(f64 a, f64 b) { | |
| 10914 | + if (a < b) { | |
| 10915 | + return a; | |
| 10916 | + } | |
| 10917 | + return b; | |
| 10918 | +} | |
| 10919 | +inline f64 builtin__f64_max(f64 a, f64 b) { | |
| 10920 | + if (a > b) { | |
| 10921 | + return a; | |
| 10922 | + } | |
| 10923 | + return b; | |
| 10924 | +} | |
| 10925 | +inline bool builtin__f32_eq_epsilon(f32 a, f32 b) { | |
| 10926 | + f32 hi = builtin__f32_max(builtin__f32_abs(a), builtin__f32_abs(b)); | |
| 10927 | + f32 delta = builtin__f32_abs(a - b); | |
| 10928 | + if (hi > ((f32)(1.0))) { | |
| 10929 | + return delta <= hi * (4 * ((f32)(FLT_EPSILON))); | |
| 10930 | + } else { | |
| 10931 | + return (1 / (4 * ((f32)(FLT_EPSILON)))) * delta <= hi; | |
| 10932 | + } | |
| 10933 | + return 0; | |
| 10934 | +} | |
| 10935 | +inline bool builtin__f64_eq_epsilon(f64 a, f64 b) { | |
| 10936 | + f64 hi = builtin__f64_max(builtin__f64_abs(a), builtin__f64_abs(b)); | |
| 10937 | + f64 delta = builtin__f64_abs(a - b); | |
| 10938 | + if (hi > ((f64)(1.0))) { | |
| 10939 | + return delta <= hi * (4 * ((f64)(DBL_EPSILON))); | |
| 10940 | + } else { | |
| 10941 | + return (1 / (4 * ((f64)(DBL_EPSILON)))) * delta <= hi; | |
| 10942 | + } | |
| 10943 | + return 0; | |
| 10944 | +} | |
| 10945 | +inline VV_LOC u32 builtin__grapheme_hex_nibble(u8 c) { | |
| 10946 | + return (c <= '9' ? (((u32)((rune)(c - '0')))) : (((u32)((rune)(((c | 0x20)) - 'a') + 10)))); | |
| 10947 | +} | |
| 10948 | +inline VV_LOC u32 builtin__grapheme_hex_byte(string ranges, int i) { | |
| 10949 | + return ((v__lshift_u32(builtin__grapheme_hex_nibble(builtin__string_at(ranges, i)), (u64)4)) | builtin__grapheme_hex_nibble(builtin__string_at(ranges, i + 1))); | |
| 10950 | +} | |
| 10951 | +inline VV_LOC u32 builtin__grapheme_range_value(string ranges, int value_idx) { | |
| 10952 | + int i = value_idx * 8; | |
| 10953 | + u32 b0 = builtin__grapheme_hex_byte(ranges, i); | |
| 10954 | + u32 b1 = builtin__grapheme_hex_byte(ranges, i + 2); | |
| 10955 | + u32 b2 = builtin__grapheme_hex_byte(ranges, i + 4); | |
| 10956 | + u32 b3 = builtin__grapheme_hex_byte(ranges, i + 6); | |
| 10957 | + return (((b0 | (v__lshift_u32(b1, (u64)8))) | (v__lshift_u32(b2, (u64)16))) | (v__lshift_u32(b3, (u64)24))); | |
| 10958 | +} | |
| 10959 | +inline VV_LOC bool builtin__in_grapheme_ranges(rune r, string ranges) { | |
| 10960 | + u32 target = ((u32)(r)); | |
| 10961 | + int low = 0; | |
| 10962 | + int high = VSAFE_DIV_int(ranges.len , 16); | |
| 10963 | + for (;;) { | |
| 10964 | + if (!(low < high)) break; | |
| 10965 | + int mid = low + VSAFE_DIV_int((high - low) , 2); | |
| 10966 | + u32 lo = builtin__grapheme_range_value(ranges, mid * 2); | |
| 10967 | + u32 hi = builtin__grapheme_range_value(ranges, mid * 2 + 1); | |
| 10968 | + if (target < lo) { | |
| 10969 | + high = mid; | |
| 10970 | + } else if (target > hi) { | |
| 10971 | + low = mid + 1; | |
| 10972 | + } else { | |
| 10973 | + return true; | |
| 10974 | + } | |
| 10975 | + } | |
| 10976 | + return false; | |
| 10977 | +} | |
| 10978 | +inline VV_LOC GraphemeBreakProperty builtin__grapheme_break_property(rune r) { | |
| 10979 | + if (r == '\r') { | |
| 10980 | + return GraphemeBreakProperty__cr; | |
| 10981 | + } | |
| 10982 | + if (r == '\n') { | |
| 10983 | + return GraphemeBreakProperty__lf; | |
| 10984 | + } | |
| 10985 | + if (r == 0x200d) { | |
| 10986 | + return GraphemeBreakProperty__zwj; | |
| 10987 | + } | |
| 10988 | + if (r >= 0x1f1e6 && r <= 0x1f1ff) { | |
| 10989 | + return GraphemeBreakProperty__regional_indicator; | |
| 10990 | + } | |
| 10991 | + if (r >= 0xac00 && r <= 0xd7a3) { | |
| 10992 | + return (VSAFE_MOD_u32((((u32)(r)) - 0xac00) , 28) == 0 ? (GraphemeBreakProperty__lv) : (GraphemeBreakProperty__lvt)); | |
| 10993 | + } | |
| 10994 | + if ((r >= 0x1100 && r <= 0x115f) || (r >= 0xa960 && r <= 0xa97c)) { | |
| 10995 | + return GraphemeBreakProperty__l; | |
| 10996 | + } | |
| 10997 | + if ((r >= 0x1160 && r <= 0x11a7) || (r >= 0xd7b0 && r <= 0xd7c6)) { | |
| 10998 | + return GraphemeBreakProperty__v; | |
| 10999 | + } | |
| 11000 | + if ((r >= 0x11a8 && r <= 0x11ff) || (r >= 0xd7cb && r <= 0xd7fb)) { | |
| 11001 | + return GraphemeBreakProperty__t; | |
| 11002 | + } | |
| 11003 | + if (builtin__in_grapheme_ranges(r, _const_grapheme_control_ranges)) { | |
| 11004 | + return GraphemeBreakProperty__control; | |
| 11005 | + } | |
| 11006 | + if (builtin__in_grapheme_ranges(r, _const_grapheme_extend_ranges)) { | |
| 11007 | + return GraphemeBreakProperty__extend; | |
| 11008 | + } | |
| 11009 | + if (builtin__in_grapheme_ranges(r, _const_grapheme_spacing_mark_ranges)) { | |
| 11010 | + return GraphemeBreakProperty__spacing_mark; | |
| 11011 | + } | |
| 11012 | + if (builtin__in_grapheme_ranges(r, _const_grapheme_prepend_ranges)) { | |
| 11013 | + return GraphemeBreakProperty__prepend; | |
| 11014 | + } | |
| 11015 | + return GraphemeBreakProperty__other; | |
| 11016 | +} | |
| 11017 | +inline VV_LOC bool builtin__is_extended_pictographic(rune r) { | |
| 11018 | + return builtin__in_grapheme_ranges(r, _const_grapheme_extended_pictographic_ranges); | |
| 11019 | +} | |
| 11020 | +inline VV_LOC GraphemeState builtin__grapheme_state_from_rune(rune r, GraphemeBreakProperty prop) { | |
| 11021 | + return ((GraphemeState){.prev_prop = prop,.ri_count = (prop == GraphemeBreakProperty__regional_indicator ? (1) : (0)),.extended_pictographic_state = (builtin__is_extended_pictographic(r) ? (((u8)(1))) : (((u8)(0)))),}); | |
| 11022 | +} | |
| 11023 | +inline VV_LOC void builtin__GraphemeState_push(GraphemeState* gs, rune r, GraphemeBreakProperty prop) { | |
| 11024 | + gs->prev_prop = prop; | |
| 11025 | + gs->ri_count = (prop == GraphemeBreakProperty__regional_indicator ? (gs->ri_count + 1) : (0)); | |
| 11026 | + if (builtin__is_extended_pictographic(r)) { | |
| 11027 | + gs->extended_pictographic_state = 1; | |
| 11028 | + } else if (prop == GraphemeBreakProperty__extend && gs->extended_pictographic_state == 1) { | |
| 11029 | + } else if (prop == GraphemeBreakProperty__zwj && gs->extended_pictographic_state == 1) { | |
| 11030 | + gs->extended_pictographic_state = 2; | |
| 11031 | + } else { | |
| 11032 | + gs->extended_pictographic_state = 0; | |
| 11033 | + } | |
| 11034 | +} | |
| 11035 | +inline VV_LOC bool builtin__should_break_grapheme(GraphemeState gs, rune r, GraphemeBreakProperty prop) { | |
| 11036 | + switch (gs.prev_prop) { | |
| 11037 | + case GraphemeBreakProperty__cr: { | |
| 11038 | + if (prop == GraphemeBreakProperty__lf) { | |
| 11039 | + return false; | |
| 11040 | + } | |
| 11041 | + return true; | |
| 11042 | + } | |
| 11043 | + case GraphemeBreakProperty__lf: case GraphemeBreakProperty__control: { | |
| 11044 | + return true; | |
| 11045 | + } | |
| 11046 | + case GraphemeBreakProperty__l: { | |
| 11047 | + if (prop == GraphemeBreakProperty__l || prop == GraphemeBreakProperty__v || prop == GraphemeBreakProperty__lv || prop == GraphemeBreakProperty__lvt) { | |
| 11048 | + return false; | |
| 11049 | + } | |
| 11050 | + break; | |
| 11051 | + } | |
| 11052 | + case GraphemeBreakProperty__lv: case GraphemeBreakProperty__v: { | |
| 11053 | + if (prop == GraphemeBreakProperty__v || prop == GraphemeBreakProperty__t) { | |
| 11054 | + return false; | |
| 11055 | + } | |
| 11056 | + break; | |
| 11057 | + } | |
| 11058 | + case GraphemeBreakProperty__lvt: case GraphemeBreakProperty__t: { | |
| 11059 | + if (prop == GraphemeBreakProperty__t) { | |
| 11060 | + return false; | |
| 11061 | + } | |
| 11062 | + break; | |
| 11063 | + } | |
| 11064 | + case GraphemeBreakProperty__prepend: { | |
| 11065 | + return false; | |
| 11066 | + } | |
| 11067 | + case GraphemeBreakProperty__regional_indicator: { | |
| 11068 | + if (prop == GraphemeBreakProperty__regional_indicator && VSAFE_MOD_int(gs.ri_count , 2) == 1) { | |
| 11069 | + return false; | |
| 11070 | + } | |
| 11071 | + break; | |
| 11072 | + } | |
| 11073 | + case GraphemeBreakProperty__other: | |
| 11074 | + case GraphemeBreakProperty__extend: | |
| 11075 | + case GraphemeBreakProperty__spacing_mark: | |
| 11076 | + case GraphemeBreakProperty__zwj: | |
| 11077 | + default: { | |
| 11078 | + { | |
| 11079 | + break; | |
| 11080 | + } | |
| 11081 | + } | |
| 11082 | + } | |
| 11083 | + | |
| 11084 | + if (prop == GraphemeBreakProperty__cr || prop == GraphemeBreakProperty__lf || prop == GraphemeBreakProperty__control) { | |
| 11085 | + return true; | |
| 11086 | + } | |
| 11087 | + if (prop == GraphemeBreakProperty__extend || prop == GraphemeBreakProperty__zwj || prop == GraphemeBreakProperty__spacing_mark) { | |
| 11088 | + return false; | |
| 11089 | + } | |
| 11090 | + if (gs.extended_pictographic_state == 2 && builtin__is_extended_pictographic(r)) { | |
| 11091 | + return false; | |
| 11092 | + } | |
| 11093 | + return true; | |
| 11094 | +} | |
| 11095 | +inline VV_LOC int builtin__utf8_rune_visible_width(rune r, GraphemeBreakProperty prop) { | |
| 11096 | + if (prop == GraphemeBreakProperty__extend || prop == GraphemeBreakProperty__zwj || prop == GraphemeBreakProperty__spacing_mark || prop == GraphemeBreakProperty__prepend) { | |
| 11097 | + return 0; | |
| 11098 | + } | |
| 11099 | + if (r >= 0x1100 && (r <= 0x115f || r == 0x2329 || r == 0x232a || (r >= 0x2e80 && r <= 0xa4cf && r != 0x303f) || (r >= 0xac00 && r <= 0xd7a3) || (r >= 0xf900 && r <= 0xfaff) || (r >= 0xfe10 && r <= 0xfe19) || (r >= 0xfe30 && r <= 0xfe6f) || (r >= 0xff00 && r <= 0xff60) || (r >= 0xffe0 && r <= 0xffe6) || (r >= 0x1f300 && r <= 0x1f64f) || (r >= 0x1f680 && r <= 0x1f6ff) || (r >= 0x1f900 && r <= 0x1f9ff) || (r >= 0x1fa70 && r <= 0x1faff) || (r >= 0x20000 && r <= 0x3fffd))) { | |
| 11100 | + return 2; | |
| 11101 | + } | |
| 11102 | + return 1; | |
| 11103 | +} | |
| 11104 | +VV_LOC Array_string builtin__string_graphemes_impl(string s) { | |
| 11105 | + Array_rune runes = builtin__string_runes(s); | |
| 11106 | + if (runes.len == 0) { | |
| 11107 | + return builtin____new_array_with_default(0, 0, sizeof(string), 0); | |
| 11108 | + } | |
| 11109 | + Array_string res = builtin____new_array_with_default(0, runes.len, sizeof(string), 0); | |
| 11110 | + Array_rune cluster = builtin____new_array_with_default(0, 4, sizeof(rune), 0); | |
| 11111 | + GraphemeBreakProperty first_prop = builtin__grapheme_break_property((*(rune*)builtin__array_get(runes, 0))); | |
| 11112 | + GraphemeState state = builtin__grapheme_state_from_rune((*(rune*)builtin__array_get(runes, 0)), first_prop); | |
| 11113 | + builtin__array_push((array*)&cluster, _MOV((rune[]){ (*(rune*)builtin__array_get(runes, 0)) })); | |
| 11114 | + Array_rune _t3 = builtin__array_slice(runes, 1, 2147483647); | |
| 11115 | + for (int _t4 = 0; _t4 < _t3.len; ++_t4) { | |
| 11116 | + rune r = ((rune*)_t3.data)[_t4]; | |
| 11117 | + GraphemeBreakProperty prop = builtin__grapheme_break_property(r); | |
| 11118 | + if (builtin__should_break_grapheme(state, r, prop)) { | |
| 11119 | + builtin__array_push((array*)&res, _MOV((string[]){ Array_rune_string(cluster) })); | |
| 11120 | + cluster = builtin____new_array_with_default(0, 4, sizeof(rune), 0); | |
| 11121 | + builtin__array_push((array*)&cluster, _MOV((rune[]){ r })); | |
| 11122 | + state = builtin__grapheme_state_from_rune(r, prop); | |
| 11123 | + continue; | |
| 11124 | + } | |
| 11125 | + builtin__array_push((array*)&cluster, _MOV((rune[]){ r })); | |
| 11126 | + builtin__GraphemeState_push(&state, r, prop); | |
| 11127 | + } | |
| 11128 | + builtin__array_push((array*)&res, _MOV((string[]){ Array_rune_string(cluster) })); | |
| 11129 | + return res; | |
| 11130 | +} | |
| 11131 | +inline VV_LOC int builtin__utf8_grapheme_visible_length(string s) { | |
| 11132 | + Array_rune runes = builtin__string_runes(s); | |
| 11133 | + if (runes.len == 0) { | |
| 11134 | + return 0; | |
| 11135 | + } | |
| 11136 | + GraphemeBreakProperty first_prop = builtin__grapheme_break_property((*(rune*)builtin__array_get(runes, 0))); | |
| 11137 | + GraphemeState state = builtin__grapheme_state_from_rune((*(rune*)builtin__array_get(runes, 0)), first_prop); | |
| 11138 | + int total = 0; | |
| 11139 | + int cluster_width = builtin__utf8_rune_visible_width((*(rune*)builtin__array_get(runes, 0)), first_prop); | |
| 11140 | + Array_rune _t2 = builtin__array_slice(runes, 1, 2147483647); | |
| 11141 | + for (int _t3 = 0; _t3 < _t2.len; ++_t3) { | |
| 11142 | + rune r = ((rune*)_t2.data)[_t3]; | |
| 11143 | + GraphemeBreakProperty prop = builtin__grapheme_break_property(r); | |
| 11144 | + if (builtin__should_break_grapheme(state, r, prop)) { | |
| 11145 | + total += cluster_width; | |
| 11146 | + cluster_width = builtin__utf8_rune_visible_width(r, prop); | |
| 11147 | + state = builtin__grapheme_state_from_rune(r, prop); | |
| 11148 | + continue; | |
| 11149 | + } | |
| 11150 | + int rune_width = builtin__utf8_rune_visible_width(r, prop); | |
| 11151 | + if (rune_width > cluster_width) { | |
| 11152 | + cluster_width = rune_width; | |
| 11153 | + } | |
| 11154 | + builtin__GraphemeState_push(&state, r, prop); | |
| 11155 | + } | |
| 11156 | + return total + cluster_width; | |
| 11157 | +} | |
| 11158 | +_option_rune builtin__input_rune(void) { | |
| 11159 | + int x = builtin__input_character(); | |
| 11160 | + if (x <= 0) { | |
| 11161 | + return (_option_rune){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | |
| 11162 | + } | |
| 11163 | + int char_len = builtin__utf8_char_len(((u8)(x))); | |
| 11164 | + if (char_len == 1) { | |
| 11165 | + _option_rune _t2; | |
| 11166 | + builtin___option_ok(&(rune[]) { x }, (_option*)(&_t2), sizeof(rune)); | |
| 11167 | + | |
| 11168 | + return _t2; | |
| 11169 | + } | |
| 11170 | + u8 b = ((u8)(x)); | |
| 11171 | + b = v__lshift_u8(b, (u64)char_len); | |
| 11172 | + rune res = ((rune)(b)); | |
| 11173 | + int shift = 6 - char_len; | |
| 11174 | + for (int i = 1; i < char_len; i++) { | |
| 11175 | + rune c = ((rune)(builtin__input_character())); | |
| 11176 | + res = v__lshift_rune(((rune)(res)), (u64)shift); | |
| 11177 | + res |= (c & 63); | |
| 11178 | + shift = 6; | |
| 11179 | + } | |
| 11180 | + _option_rune _t3; | |
| 11181 | + builtin___option_ok(&(rune[]) { res }, (_option*)(&_t3), sizeof(rune)); | |
| 11182 | + | |
| 11183 | + return _t3; | |
| 11184 | +} | |
| 11185 | +_option_rune builtin__InputRuneIterator_next(InputRuneIterator* self) { | |
| 11186 | + return builtin__input_rune(); | |
| 11187 | +} | |
| 11188 | +InputRuneIterator builtin__input_rune_iterator(void) { | |
| 11189 | + return ((InputRuneIterator){E_STRUCT}); | |
| 11190 | +} | |
| 11191 | +string builtin__ptr_str(voidptr ptr) { | |
| 11192 | + string buf1 = builtin__u64_to_hex_no_leading_zeros(((u64)(ptr)), 16); | |
| 11193 | + return buf1; | |
| 11194 | +} | |
| 11195 | +string builtin__isize_str(isize x) { | |
| 11196 | + return builtin__i64_str(((i64)(x))); | |
| 11197 | +} | |
| 11198 | +string builtin__usize_str(usize x) { | |
| 11199 | + return builtin__u64_str(((u64)(x))); | |
| 11200 | +} | |
| 11201 | +string builtin__char_str(char* cptr) { | |
| 11202 | + return builtin__u64_hex(((u64)(cptr))); | |
| 11203 | +} | |
| 11204 | +inline VV_LOC string builtin__int_str_l(int nn, int max) { | |
| 11205 | + { // Unsafe block | |
| 11206 | + i64 n = ((i64)(nn)); | |
| 11207 | + int d = 0; | |
| 11208 | + if (n == 0) { | |
| 11209 | + return _S("0"); | |
| 11210 | + } | |
| 11211 | + #if 0 | |
| 11212 | + { | |
| 11213 | + } | |
| 11214 | + #else | |
| 11215 | + { | |
| 11216 | + if (n == _const_min_i32) { | |
| 11217 | + return _S("-2147483648"); | |
| 11218 | + } | |
| 11219 | + } | |
| 11220 | + #endif | |
| 11221 | + bool is_neg = false; | |
| 11222 | + if (n < 0) { | |
| 11223 | + n = -n; | |
| 11224 | + is_neg = true; | |
| 11225 | + } | |
| 11226 | + int index = max; | |
| 11227 | + u8* buf = builtin__malloc_noscan(max + 1); | |
| 11228 | + buf[index] = 0; | |
| 11229 | + index--; | |
| 11230 | + for (;;) { | |
| 11231 | + if (!(n > 0)) break; | |
| 11232 | + int n1 = ((int)(VSAFE_DIV_i64(n , 100))); | |
| 11233 | + d = ((int)(v__lshift_u32(((u32)(((int)(n)) - (n1 * 100))), (u64)1))); | |
| 11234 | + n = n1; | |
| 11235 | + buf[index] = _const_digit_pairs.str[d]; | |
| 11236 | + index--; | |
| 11237 | + d++; | |
| 11238 | + buf[index] = _const_digit_pairs.str[d]; | |
| 11239 | + index--; | |
| 11240 | + } | |
| 11241 | + index++; | |
| 11242 | + if (d < 20) { | |
| 11243 | + index++; | |
| 11244 | + } | |
| 11245 | + if (is_neg) { | |
| 11246 | + index--; | |
| 11247 | + buf[index] = '-'; | |
| 11248 | + } | |
| 11249 | + int diff = max - index; | |
| 11250 | + builtin__vmemmove(buf, ((voidptr)(buf + index)), diff + 1); | |
| 11251 | + return builtin__tos(buf, diff); | |
| 11252 | + } | |
| 11253 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 11254 | +} | |
| 11255 | +string builtin__i8_str(i8 n) { | |
| 11256 | + return builtin__int_str_l(((int)(n)), 4); | |
| 11257 | +} | |
| 11258 | +string builtin__i16_str(i16 n) { | |
| 11259 | + return builtin__int_str_l(((int)(n)), 6); | |
| 11260 | +} | |
| 11261 | +string builtin__u16_str(u16 n) { | |
| 11262 | + return builtin__int_str_l(((int)(n)), 6); | |
| 11263 | +} | |
| 11264 | +string builtin__i32_str(i32 n) { | |
| 11265 | + return builtin__int_str_l(((int)(n)), 11); | |
| 11266 | +} | |
| 11267 | +string builtin__int_hex_full(int nn) { | |
| 11268 | + return builtin__u64_to_hex(((u64)(nn)), 8); | |
| 11269 | +} | |
| 11270 | +string builtin__int_str(int n) { | |
| 11271 | + #if defined(CUSTOM_DEFINE_new_int) | |
| 11272 | + { | |
| 11273 | + } | |
| 11274 | + #else | |
| 11275 | + { | |
| 11276 | + return builtin__int_str_l(n, 11); | |
| 11277 | + } | |
| 11278 | + #endif | |
| 11279 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 11280 | +} | |
| 11281 | +inline string builtin__u32_str(u32 nn) { | |
| 11282 | + { // Unsafe block | |
| 11283 | + u32 n = nn; | |
| 11284 | + u32 d = ((u32)(0)); | |
| 11285 | + if (n == 0) { | |
| 11286 | + return _S("0"); | |
| 11287 | + } | |
| 11288 | + int max = 10; | |
| 11289 | + u8* buf = builtin__malloc_noscan(max + 1); | |
| 11290 | + int index = max; | |
| 11291 | + buf[index] = 0; | |
| 11292 | + index--; | |
| 11293 | + for (;;) { | |
| 11294 | + if (!(n > 0)) break; | |
| 11295 | + u32 n1 = VSAFE_DIV_u32(n , ((u32)(100))); | |
| 11296 | + d = (v__lshift_u32((n - (n1 * ((u32)(100)))), (u64)((u32)(1)))); | |
| 11297 | + n = n1; | |
| 11298 | + buf[index] = _const_digit_pairs.str[ ((int)(d))]; | |
| 11299 | + index--; | |
| 11300 | + d++; | |
| 11301 | + buf[index] = _const_digit_pairs.str[ ((int)(d))]; | |
| 11302 | + index--; | |
| 11303 | + } | |
| 11304 | + index++; | |
| 11305 | + if (d < ((u32)(20))) { | |
| 11306 | + index++; | |
| 11307 | + } | |
| 11308 | + int diff = max - index; | |
| 11309 | + builtin__vmemmove(buf, ((voidptr)(buf + index)), diff + 1); | |
| 11310 | + return builtin__tos(buf, diff); | |
| 11311 | + } | |
| 11312 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 11313 | +} | |
| 11314 | +inline string builtin__int_literal_str(int_literal n) { | |
| 11315 | + return builtin__impl_i64_to_string(n); | |
| 11316 | +} | |
| 11317 | +inline string builtin__i64_str(i64 nn) { | |
| 11318 | + return builtin__impl_i64_to_string(nn); | |
| 11319 | +} | |
| 11320 | +VV_LOC string builtin__impl_i64_to_string(i64 nn) { | |
| 11321 | + { // Unsafe block | |
| 11322 | + i64 n = nn; | |
| 11323 | + i64 d = ((i64)(0)); | |
| 11324 | + if (n == 0) { | |
| 11325 | + return _S("0"); | |
| 11326 | + } else if (n == _const_min_i64) { | |
| 11327 | + return _S("-9223372036854775808"); | |
| 11328 | + } | |
| 11329 | + int max = 20; | |
| 11330 | + u8* buf = builtin__malloc_noscan(max + 1); | |
| 11331 | + bool is_neg = false; | |
| 11332 | + if (n < 0) { | |
| 11333 | + n = -n; | |
| 11334 | + is_neg = true; | |
| 11335 | + } | |
| 11336 | + int index = max; | |
| 11337 | + buf[index] = 0; | |
| 11338 | + index--; | |
| 11339 | + for (;;) { | |
| 11340 | + if (!(n > 0)) break; | |
| 11341 | + i64 n1 = VSAFE_DIV_i64(n , ((i64)(100))); | |
| 11342 | + d = (v__lshift_u32(((u32)(n - (n1 * ((i64)(100))))), (u64)((i64)(1)))); | |
| 11343 | + n = n1; | |
| 11344 | + buf[index] = _const_digit_pairs.str[ ((int)(d))]; | |
| 11345 | + index--; | |
| 11346 | + d++; | |
| 11347 | + buf[index] = _const_digit_pairs.str[ ((int)(d))]; | |
| 11348 | + index--; | |
| 11349 | + } | |
| 11350 | + index++; | |
| 11351 | + if (d < ((i64)(20))) { | |
| 11352 | + index++; | |
| 11353 | + } | |
| 11354 | + if (is_neg) { | |
| 11355 | + index--; | |
| 11356 | + buf[index] = '-'; | |
| 11357 | + } | |
| 11358 | + int diff = max - index; | |
| 11359 | + builtin__vmemmove(buf, ((voidptr)(buf + index)), diff + 1); | |
| 11360 | + return builtin__tos(buf, diff); | |
| 11361 | + } | |
| 11362 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 11363 | +} | |
| 11364 | +inline string builtin__u64_str(u64 nn) { | |
| 11365 | + { // Unsafe block | |
| 11366 | + u64 n = nn; | |
| 11367 | + u64 d = ((u64)(0)); | |
| 11368 | + if (n == 0) { | |
| 11369 | + return _S("0"); | |
| 11370 | + } | |
| 11371 | + int max = 20; | |
| 11372 | + u8* buf = builtin__malloc_noscan(max + 1); | |
| 11373 | + int index = max; | |
| 11374 | + buf[index] = 0; | |
| 11375 | + index--; | |
| 11376 | + for (;;) { | |
| 11377 | + if (!(n > 0)) break; | |
| 11378 | + u64 n1 = VSAFE_DIV_u64(n , 100); | |
| 11379 | + d = (v__lshift_u64((n - (n1 * 100)), (u64)1)); | |
| 11380 | + n = n1; | |
| 11381 | + buf[index] = _const_digit_pairs.str[ ((int)(d))]; | |
| 11382 | + index--; | |
| 11383 | + d++; | |
| 11384 | + buf[index] = _const_digit_pairs.str[ ((int)(d))]; | |
| 11385 | + index--; | |
| 11386 | + } | |
| 11387 | + index++; | |
| 11388 | + if (d < 20) { | |
| 11389 | + index++; | |
| 11390 | + } | |
| 11391 | + int diff = max - index; | |
| 11392 | + builtin__vmemmove(buf, ((voidptr)(buf + index)), diff + 1); | |
| 11393 | + return builtin__tos(buf, diff); | |
| 11394 | + } | |
| 11395 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 11396 | +} | |
| 11397 | +string builtin__bool_str(bool b) { | |
| 11398 | + if (b) { | |
| 11399 | + return _S("true"); | |
| 11400 | + } | |
| 11401 | + return _S("false"); | |
| 11402 | +} | |
| 11403 | +inline VV_LOC string builtin__u64_to_hex(u64 nn, u8 len) { | |
| 11404 | + u64 n = nn; | |
| 11405 | + Array_fixed_u8_17 buf = {0}; | |
| 11406 | + buf[len] = 0; | |
| 11407 | + int i = 0; | |
| 11408 | + for (i = (len - 1); i >= 0; i--) { | |
| 11409 | + u8 d = ((u8)((n & 0xF))); | |
| 11410 | + buf[i] = (d < 10 ? ((rune)(d + '0')) : ((u8)(d + 87))); | |
| 11411 | + n = v__rshift_u64(n, (u64)4); | |
| 11412 | + } | |
| 11413 | + return builtin__tos(builtin__memdup(&buf[0], (len + 1)), len); | |
| 11414 | +} | |
| 11415 | +inline VV_LOC string builtin__u64_to_hex_no_leading_zeros(u64 nn, u8 len) { | |
| 11416 | + u64 n = nn; | |
| 11417 | + Array_fixed_u8_17 buf = {0}; | |
| 11418 | + buf[len] = 0; | |
| 11419 | + int i = 0; | |
| 11420 | + for (i = (len - 1); i >= 0; i--) { | |
| 11421 | + u8 d = ((u8)((n & 0xF))); | |
| 11422 | + buf[i] = (d < 10 ? ((rune)(d + '0')) : ((u8)(d + 87))); | |
| 11423 | + n = v__rshift_u64(n, (u64)4); | |
| 11424 | + if (n == 0) { | |
| 11425 | + break; | |
| 11426 | + } | |
| 11427 | + } | |
| 11428 | + int res_len = (int)(len - i); | |
| 11429 | + return builtin__tos(builtin__memdup(&buf[i], res_len + 1), res_len); | |
| 11430 | +} | |
| 11431 | +string builtin__u8_hex(u8 nn) { | |
| 11432 | + if (nn == 0) { | |
| 11433 | + return _S("00"); | |
| 11434 | + } | |
| 11435 | + return builtin__u64_to_hex(nn, 2); | |
| 11436 | +} | |
| 11437 | +string builtin__char_hex(char c) { | |
| 11438 | + return builtin__u8_hex(((u8)(c))); | |
| 11439 | +} | |
| 11440 | +string builtin__rune_hex(rune r) { | |
| 11441 | + return builtin__u32_hex(((u32)(r))); | |
| 11442 | +} | |
| 11443 | +string builtin__i8_hex(i8 nn) { | |
| 11444 | + if (nn == 0) { | |
| 11445 | + return _S("00"); | |
| 11446 | + } | |
| 11447 | + return builtin__u64_to_hex(((u64)(nn)), 2); | |
| 11448 | +} | |
| 11449 | +string builtin__u16_hex(u16 nn) { | |
| 11450 | + if (nn == 0) { | |
| 11451 | + return _S("0"); | |
| 11452 | + } | |
| 11453 | + return builtin__u64_to_hex_no_leading_zeros(nn, 4); | |
| 11454 | +} | |
| 11455 | +string builtin__i16_hex(i16 nn) { | |
| 11456 | + return builtin__u16_hex(((u16)(nn))); | |
| 11457 | +} | |
| 11458 | +string builtin__u32_hex(u32 nn) { | |
| 11459 | + if (nn == 0) { | |
| 11460 | + return _S("0"); | |
| 11461 | + } | |
| 11462 | + return builtin__u64_to_hex_no_leading_zeros(nn, 8); | |
| 11463 | +} | |
| 11464 | +string builtin__int_hex(int nn) { | |
| 11465 | + return builtin__u32_hex(((u32)(nn))); | |
| 11466 | +} | |
| 11467 | +string builtin__int_hex2(int n) { | |
| 11468 | + return builtin__string__plus(_S("0x"), builtin__int_hex(n)); | |
| 11469 | +} | |
| 11470 | +string builtin__u64_hex(u64 nn) { | |
| 11471 | + if (nn == 0) { | |
| 11472 | + return _S("0"); | |
| 11473 | + } | |
| 11474 | + return builtin__u64_to_hex_no_leading_zeros(nn, 16); | |
| 11475 | +} | |
| 11476 | +string builtin__i64_hex(i64 nn) { | |
| 11477 | + return builtin__u64_hex(((u64)(nn))); | |
| 11478 | +} | |
| 11479 | +string builtin__int_literal_hex(int_literal nn) { | |
| 11480 | + return builtin__u64_hex(((u64)(nn))); | |
| 11481 | +} | |
| 11482 | +string builtin__voidptr_str(voidptr nn) { | |
| 11483 | + return builtin__string__plus(_S("0x"), builtin__u64_hex(((u64)(nn)))); | |
| 11484 | +} | |
| 11485 | +string builtin__byteptr_str(byteptr nn) { | |
| 11486 | + return builtin__string__plus(_S("0x"), builtin__u64_hex(((u64)(nn)))); | |
| 11487 | +} | |
| 11488 | +string builtin__charptr_str(charptr nn) { | |
| 11489 | + return builtin__string__plus(_S("0x"), builtin__u64_hex(((u64)(nn)))); | |
| 11490 | +} | |
| 11491 | +string builtin__u8_hex_full(u8 nn) { | |
| 11492 | + return builtin__u64_to_hex(((u64)(nn)), 2); | |
| 11493 | +} | |
| 11494 | +string builtin__i8_hex_full(i8 nn) { | |
| 11495 | + return builtin__u64_to_hex(((u64)(nn)), 2); | |
| 11496 | +} | |
| 11497 | +string builtin__u16_hex_full(u16 nn) { | |
| 11498 | + return builtin__u64_to_hex(((u64)(nn)), 4); | |
| 11499 | +} | |
| 11500 | +string builtin__i16_hex_full(i16 nn) { | |
| 11501 | + return builtin__u64_to_hex(((u64)(nn)), 4); | |
| 11502 | +} | |
| 11503 | +string builtin__u32_hex_full(u32 nn) { | |
| 11504 | + return builtin__u64_to_hex(((u64)(nn)), 8); | |
| 11505 | +} | |
| 11506 | +string builtin__i64_hex_full(i64 nn) { | |
| 11507 | + return builtin__u64_to_hex(((u64)(nn)), 16); | |
| 11508 | +} | |
| 11509 | +string builtin__voidptr_hex_full(voidptr nn) { | |
| 11510 | + return builtin__u64_to_hex(((u64)(nn)), 16); | |
| 11511 | +} | |
| 11512 | +string builtin__int_literal_hex_full(int_literal nn) { | |
| 11513 | + return builtin__u64_to_hex(((u64)(nn)), 16); | |
| 11514 | +} | |
| 11515 | +string builtin__u64_hex_full(u64 nn) { | |
| 11516 | + return builtin__u64_to_hex(nn, 16); | |
| 11517 | +} | |
| 11518 | +string builtin__u8_str(u8 b) { | |
| 11519 | + return builtin__int_str_l(((int)(b)), 4); | |
| 11520 | +} | |
| 11521 | +string builtin__u8_ascii_str(u8 b) { | |
| 11522 | + string _t1 = ((string){.str = builtin__malloc_noscan(2), .len = 1}); | |
| 11523 | + string str = _t1; | |
| 11524 | + { // Unsafe block | |
| 11525 | + str.str[0] = b; | |
| 11526 | + str.str[1] = 0; | |
| 11527 | + } | |
| 11528 | + return str; | |
| 11529 | +} | |
| 11530 | +string builtin__u8_str_escaped(u8 b) { | |
| 11531 | + string _t1 = (string){.str=(byteptr)"", .is_lit=1}; | |
| 11532 | + | |
| 11533 | + if (b == (0)) { | |
| 11534 | + _t1 = _S("`\\0`"); | |
| 11535 | + } | |
| 11536 | + else if (b == (7)) { | |
| 11537 | + _t1 = _S("`\\a`"); | |
| 11538 | + } | |
| 11539 | + else if (b == (8)) { | |
| 11540 | + _t1 = _S("`\\b`"); | |
| 11541 | + } | |
| 11542 | + else if (b == (9)) { | |
| 11543 | + _t1 = _S("`\\t`"); | |
| 11544 | + } | |
| 11545 | + else if (b == (10)) { | |
| 11546 | + _t1 = _S("`\\n`"); | |
| 11547 | + } | |
| 11548 | + else if (b == (11)) { | |
| 11549 | + _t1 = _S("`\\v`"); | |
| 11550 | + } | |
| 11551 | + else if (b == (12)) { | |
| 11552 | + _t1 = _S("`\\f`"); | |
| 11553 | + } | |
| 11554 | + else if (b == (13)) { | |
| 11555 | + _t1 = _S("`\\r`"); | |
| 11556 | + } | |
| 11557 | + else if (b == (27)) { | |
| 11558 | + _t1 = _S("`\\e`"); | |
| 11559 | + } | |
| 11560 | + else if ((b >= 32 && b <= 126)) { | |
| 11561 | + _t1 = builtin__u8_ascii_str(b); | |
| 11562 | + } | |
| 11563 | + else { | |
| 11564 | + string xx = builtin__u8_hex(b); | |
| 11565 | + string yy = builtin__string__plus(_S("0x"), xx); | |
| 11566 | + builtin__string_free(&xx); | |
| 11567 | + _t1 = yy; | |
| 11568 | + }string str = _t1; | |
| 11569 | + return str; | |
| 11570 | +} | |
| 11571 | +inline bool builtin__u8_is_capital(u8 c) { | |
| 11572 | + return c >= 'A' && c <= 'Z'; | |
| 11573 | +} | |
| 11574 | +string Array_u8_bytestr(Array_u8 b) { | |
| 11575 | + { // Unsafe block | |
| 11576 | + u8* buf = builtin__malloc_noscan(b.len + 1); | |
| 11577 | + builtin__vmemcpy(buf, b.data, b.len); | |
| 11578 | + buf[b.len] = 0; | |
| 11579 | + return builtin__tos(buf, b.len); | |
| 11580 | + } | |
| 11581 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 11582 | +} | |
| 11583 | +_result_rune Array_u8_byterune(Array_u8 b) { | |
| 11584 | + _result_rune _t1 = Array_u8_utf8_to_utf32(b); | |
| 11585 | + if (_t1.is_error) { | |
| 11586 | + _result_rune _t2 = {0}; | |
| 11587 | + _t2.is_error = true; | |
| 11588 | + _t2.err = _t1.err; | |
| 11589 | + return _t2; | |
| 11590 | + } | |
| 11591 | + | |
| 11592 | + rune r = (*(rune*)_t1.data); | |
| 11593 | + _result_rune _t3; | |
| 11594 | + builtin___result_ok(&(rune[]) { ((rune)(r)) }, (_result*)(&_t3), sizeof(rune)); | |
| 11595 | + | |
| 11596 | + return _t3; | |
| 11597 | +} | |
| 11598 | +string builtin__u8_repeat(u8 b, int count) { | |
| 11599 | + if (count <= 0) { | |
| 11600 | + return _S(""); | |
| 11601 | + } else if (count == 1) { | |
| 11602 | + return builtin__u8_ascii_str(b); | |
| 11603 | + } | |
| 11604 | + u8* bytes = builtin__malloc_noscan(count + 1); | |
| 11605 | + { // Unsafe block | |
| 11606 | + builtin__vmemset(bytes, b, count); | |
| 11607 | + bytes[count] = 0; | |
| 11608 | + } | |
| 11609 | + return builtin__u8_vstring_with_len(bytes, count); | |
| 11610 | +} | |
| 11611 | +inline int builtin__int_min(int a, int b) { | |
| 11612 | + return (a < b ? (a) : (b)); | |
| 11613 | +} | |
| 11614 | +inline int builtin__int_max(int a, int b) { | |
| 11615 | + return (a > b ? (a) : (b)); | |
| 11616 | +} | |
| 11617 | +inline VV_LOC bool builtin__fast_string_eq(string a, string b) { | |
| 11618 | + if (a.len != b.len) { | |
| 11619 | + return false; | |
| 11620 | + } | |
| 11621 | + { // Unsafe block | |
| 11622 | + return memcmp(a.str, b.str, b.len) == 0; | |
| 11623 | + } | |
| 11624 | + return 0; | |
| 11625 | +} | |
| 11626 | +VV_LOC u64 builtin__map_hash_string(voidptr pkey) { | |
| 11627 | + string key = *((string*)(pkey)); | |
| 11628 | + return wyhash(key.str, ((u64)(key.len)), 0, ((u64*)(((voidptr)(_wyp))))); | |
| 11629 | +} | |
| 11630 | +VV_LOC u64 builtin__map_hash_int_1(voidptr pkey) { | |
| 11631 | + return wyhash64(*((u8*)(pkey)), 0); | |
| 11632 | +} | |
| 11633 | +VV_LOC u64 builtin__map_hash_int_2(voidptr pkey) { | |
| 11634 | + return wyhash64(*((u16*)(pkey)), 0); | |
| 11635 | +} | |
| 11636 | +VV_LOC u64 builtin__map_hash_int_4(voidptr pkey) { | |
| 11637 | + return wyhash64(*((u32*)(pkey)), 0); | |
| 11638 | +} | |
| 11639 | +VV_LOC u64 builtin__map_hash_int_8(voidptr pkey) { | |
| 11640 | + return wyhash64(*((u64*)(pkey)), 0); | |
| 11641 | +} | |
| 11642 | +VV_LOC voidptr builtin__map_enum_fn(int kind, int esize) { | |
| 11643 | + if (!(kind == 1 || kind == 2 || kind == 3)) { | |
| 11644 | + builtin___v_panic(_S("map_enum_fn: invalid kind")); | |
| 11645 | + VUNREACHABLE(); | |
| 11646 | + } | |
| 11647 | + if (esize > 8 || esize < 0) { | |
| 11648 | + builtin___v_panic(_S("map_enum_fn: invalid esize")); | |
| 11649 | + VUNREACHABLE(); | |
| 11650 | + } | |
| 11651 | + if (kind == 1) { | |
| 11652 | + if (esize > 4) { | |
| 11653 | + return ((voidptr)(builtin__map_hash_int_8)); | |
| 11654 | + } | |
| 11655 | + if (esize > 2) { | |
| 11656 | + return ((voidptr)(builtin__map_hash_int_4)); | |
| 11657 | + } | |
| 11658 | + if (esize > 1) { | |
| 11659 | + return ((voidptr)(builtin__map_hash_int_2)); | |
| 11660 | + } | |
| 11661 | + if (esize > 0) { | |
| 11662 | + return ((voidptr)(builtin__map_hash_int_1)); | |
| 11663 | + } | |
| 11664 | + } | |
| 11665 | + if (kind == 2) { | |
| 11666 | + if (esize > 4) { | |
| 11667 | + return ((voidptr)(builtin__map_eq_int_8)); | |
| 11668 | + } | |
| 11669 | + if (esize > 2) { | |
| 11670 | + return ((voidptr)(builtin__map_eq_int_4)); | |
| 11671 | + } | |
| 11672 | + if (esize > 1) { | |
| 11673 | + return ((voidptr)(builtin__map_eq_int_2)); | |
| 11674 | + } | |
| 11675 | + if (esize > 0) { | |
| 11676 | + return ((voidptr)(builtin__map_eq_int_1)); | |
| 11677 | + } | |
| 11678 | + } | |
| 11679 | + if (kind == 3) { | |
| 11680 | + if (esize > 4) { | |
| 11681 | + return ((voidptr)(builtin__map_clone_int_8)); | |
| 11682 | + } | |
| 11683 | + if (esize > 2) { | |
| 11684 | + return ((voidptr)(builtin__map_clone_int_4)); | |
| 11685 | + } | |
| 11686 | + if (esize > 1) { | |
| 11687 | + return ((voidptr)(builtin__map_clone_int_2)); | |
| 11688 | + } | |
| 11689 | + if (esize > 0) { | |
| 11690 | + return ((voidptr)(builtin__map_clone_int_1)); | |
| 11691 | + } | |
| 11692 | + } | |
| 11693 | + return ((void*)0); | |
| 11694 | +} | |
| 11695 | +VV_LOC void builtin__DenseArray_zeros_to_end(DenseArray* d) { | |
| 11696 | + u8* tmp_value = builtin___v_malloc(d->value_bytes); | |
| 11697 | + u8* tmp_key = builtin___v_malloc(d->key_bytes); | |
| 11698 | + int count = 0; | |
| 11699 | + for (int i = 0; i < d->len; ++i) { | |
| 11700 | + if (builtin__DenseArray_has_index(d, i)) { | |
| 11701 | + { // Unsafe block | |
| 11702 | + if (count != i) { | |
| 11703 | + memcpy(tmp_key, builtin__DenseArray_key(d, count), d->key_bytes); | |
| 11704 | + memcpy(builtin__DenseArray_key(d, count), builtin__DenseArray_key(d, i), d->key_bytes); | |
| 11705 | + memcpy(builtin__DenseArray_key(d, i), tmp_key, d->key_bytes); | |
| 11706 | + memcpy(tmp_value, builtin__DenseArray_value(d, count), d->value_bytes); | |
| 11707 | + memcpy(builtin__DenseArray_value(d, count), builtin__DenseArray_value(d, i), d->value_bytes); | |
| 11708 | + memcpy(builtin__DenseArray_value(d, i), tmp_value, d->value_bytes); | |
| 11709 | + } | |
| 11710 | + } | |
| 11711 | + count++; | |
| 11712 | + } | |
| 11713 | + } | |
| 11714 | + { // Unsafe block | |
| 11715 | + builtin___v_free(tmp_value); | |
| 11716 | + builtin___v_free(tmp_key); | |
| 11717 | + d->deletes = 0; | |
| 11718 | + builtin___v_free(d->all_deleted); | |
| 11719 | + d->all_deleted = ((void*)0); | |
| 11720 | + } | |
| 11721 | + d->len = count; | |
| 11722 | + int old_cap = d->cap; | |
| 11723 | + if (count < 8) { | |
| 11724 | + d->cap = 8; | |
| 11725 | + } else { | |
| 11726 | + d->cap = count; | |
| 11727 | + } | |
| 11728 | + { // Unsafe block | |
| 11729 | + d->values = builtin__realloc_data(d->values, d->value_bytes * old_cap, d->value_bytes * d->cap); | |
| 11730 | + d->keys = builtin__realloc_data(d->keys, d->key_bytes * old_cap, d->key_bytes * d->cap); | |
| 11731 | + } | |
| 11732 | +} | |
| 11733 | +inline VV_LOC DenseArray builtin__new_dense_array(int key_bytes, int value_bytes) { | |
| 11734 | + int cap = 8; | |
| 11735 | + return ((DenseArray){ | |
| 11736 | + .key_bytes = key_bytes, | |
| 11737 | + .value_bytes = value_bytes, | |
| 11738 | + .cap = cap, | |
| 11739 | + .len = 0, | |
| 11740 | + .deletes = 0, | |
| 11741 | + .all_deleted = ((void*)0), | |
| 11742 | + .keys = builtin___v_malloc(builtin____at_least_one(((u64)(cap)) * ((u64)(key_bytes)))), | |
| 11743 | + .values = builtin___v_malloc(builtin____at_least_one(((u64)(cap)) * ((u64)(value_bytes)))), | |
| 11744 | + }); | |
| 11745 | +} | |
| 11746 | +inline VV_LOC voidptr builtin__DenseArray_key(DenseArray* d, int i) { | |
| 11747 | + return ((voidptr)(d->keys + i * d->key_bytes)); | |
| 11748 | +} | |
| 11749 | +inline VV_LOC voidptr builtin__DenseArray_value(DenseArray* d, int i) { | |
| 11750 | + return ((voidptr)(d->values + i * d->value_bytes)); | |
| 11751 | +} | |
| 11752 | +inline VV_LOC bool builtin__DenseArray_has_index(DenseArray* d, int i) { | |
| 11753 | + return d->deletes == 0 || d->all_deleted[i] == 0; | |
| 11754 | +} | |
| 11755 | +inline VV_LOC void builtin__DenseArray_trim_deleted_tail(DenseArray* d) { | |
| 11756 | + if (d->deletes == 0) { | |
| 11757 | + return; | |
| 11758 | + } | |
| 11759 | + for (;;) { | |
| 11760 | + if (!(d->len > 0 && d->all_deleted[d->len - 1] != 0)) break; | |
| 11761 | + { // Unsafe block | |
| 11762 | + d->all_deleted[d->len - 1] = 0; | |
| 11763 | + } | |
| 11764 | + d->deletes--; | |
| 11765 | + d->len--; | |
| 11766 | + } | |
| 11767 | + if (d->deletes == 0) { | |
| 11768 | + { // Unsafe block | |
| 11769 | + builtin___v_free(d->all_deleted); | |
| 11770 | + d->all_deleted = ((void*)0); | |
| 11771 | + } | |
| 11772 | + } | |
| 11773 | +} | |
| 11774 | +inline VV_LOC int builtin__DenseArray_expand(DenseArray* d) { | |
| 11775 | + int old_cap = d->cap; | |
| 11776 | + int old_key_size = d->key_bytes * old_cap; | |
| 11777 | + int old_value_size = d->value_bytes * old_cap; | |
| 11778 | + if (d->cap == d->len) { | |
| 11779 | + d->cap += v__rshift_int(d->cap, (u64)3); | |
| 11780 | + { // Unsafe block | |
| 11781 | + d->keys = builtin__realloc_data(d->keys, old_key_size, d->key_bytes * d->cap); | |
| 11782 | + d->values = builtin__realloc_data(d->values, old_value_size, d->value_bytes * d->cap); | |
| 11783 | + if (d->deletes != 0) { | |
| 11784 | + d->all_deleted = builtin__realloc_data(d->all_deleted, old_cap, d->cap); | |
| 11785 | + builtin__vmemset(((voidptr)(d->all_deleted + d->len)), 0, d->cap - d->len); | |
| 11786 | + } | |
| 11787 | + } | |
| 11788 | + } | |
| 11789 | + int push_index = d->len; | |
| 11790 | + { // Unsafe block | |
| 11791 | + if (d->deletes != 0) { | |
| 11792 | + d->all_deleted[push_index] = 0; | |
| 11793 | + } | |
| 11794 | + } | |
| 11795 | + d->len++; | |
| 11796 | + return push_index; | |
| 11797 | +} | |
| 11798 | +inline VV_LOC bool builtin__map_eq_string(voidptr a, voidptr b) { | |
| 11799 | + return builtin__fast_string_eq(*((string*)(a)), *((string*)(b))); | |
| 11800 | +} | |
| 11801 | +inline VV_LOC bool builtin__map_eq_int_1(voidptr a, voidptr b) { | |
| 11802 | + return *((u8*)(a)) == *((u8*)(b)); | |
| 11803 | +} | |
| 11804 | +inline VV_LOC bool builtin__map_eq_int_2(voidptr a, voidptr b) { | |
| 11805 | + return *((u16*)(a)) == *((u16*)(b)); | |
| 11806 | +} | |
| 11807 | +inline VV_LOC bool builtin__map_eq_int_4(voidptr a, voidptr b) { | |
| 11808 | + return *((u32*)(a)) == *((u32*)(b)); | |
| 11809 | +} | |
| 11810 | +inline VV_LOC bool builtin__map_eq_int_8(voidptr a, voidptr b) { | |
| 11811 | + return *((u64*)(a)) == *((u64*)(b)); | |
| 11812 | +} | |
| 11813 | +VV_LOC bool builtin__map_map_eq(map a, map b) { | |
| 11814 | + if (a.len != b.len) { | |
| 11815 | + return false; | |
| 11816 | + } | |
| 11817 | + for (int i = 0; i < a.key_values.len; i++) { | |
| 11818 | + if (!builtin__DenseArray_has_index(&a.key_values, i)) { | |
| 11819 | + continue; | |
| 11820 | + } | |
| 11821 | + voidptr k = builtin__DenseArray_key(&a.key_values, i); | |
| 11822 | + if (!builtin__map_exists(&b, k)) { | |
| 11823 | + return false; | |
| 11824 | + } | |
| 11825 | + voidptr va = builtin__DenseArray_value(&a.key_values, i); | |
| 11826 | + voidptr vb = builtin__map_get(&b, k, va); | |
| 11827 | + if (builtin__vmemcmp(va, vb, a.value_bytes) != 0) { | |
| 11828 | + return false; | |
| 11829 | + } | |
| 11830 | + } | |
| 11831 | + return true; | |
| 11832 | +} | |
| 11833 | +inline VV_LOC void builtin__map_clone_string(voidptr dest, voidptr pkey) { | |
| 11834 | + { // Unsafe block | |
| 11835 | + string s = *((string*)(pkey)); | |
| 11836 | + string cloned = builtin__string_clone(s); | |
| 11837 | + builtin__vmemcpy(dest, ((voidptr)(&cloned)), sizeof(string)); | |
| 11838 | + } | |
| 11839 | +} | |
| 11840 | +inline VV_LOC void builtin__map_clone_int_1(voidptr dest, voidptr pkey) { | |
| 11841 | + { // Unsafe block | |
| 11842 | + *((u8*)(dest)) = *((u8*)(pkey)); | |
| 11843 | + } | |
| 11844 | +} | |
| 11845 | +inline VV_LOC void builtin__map_clone_int_2(voidptr dest, voidptr pkey) { | |
| 11846 | + { // Unsafe block | |
| 11847 | + *((u16*)(dest)) = *((u16*)(pkey)); | |
| 11848 | + } | |
| 11849 | +} | |
| 11850 | +inline VV_LOC void builtin__map_clone_int_4(voidptr dest, voidptr pkey) { | |
| 11851 | + { // Unsafe block | |
| 11852 | + *((u32*)(dest)) = *((u32*)(pkey)); | |
| 11853 | + } | |
| 11854 | +} | |
| 11855 | +inline VV_LOC void builtin__map_clone_int_8(voidptr dest, voidptr pkey) { | |
| 11856 | + { // Unsafe block | |
| 11857 | + *((u64*)(dest)) = *((u64*)(pkey)); | |
| 11858 | + } | |
| 11859 | +} | |
| 11860 | +inline VV_LOC void builtin__map_free_string(voidptr pkey) { | |
| 11861 | + builtin__string_free(ADDR(string, (*((string*)(pkey))))); | |
| 11862 | +} | |
| 11863 | +inline VV_LOC void builtin__map_free_nop(voidptr _d1) { | |
| 11864 | +} | |
| 11865 | +VV_LOC map builtin__new_map(int key_bytes, int value_bytes, u64 (*hash_fn)(voidptr _d1), bool (*key_eq_fn)(voidptr _d1, voidptr _d2), void (*clone_fn)(voidptr _d1, voidptr _d2), void (*free_fn)(voidptr _d1)) { | |
| 11866 | + int metasize = ((int)((u32)(sizeof(u32) * (_const_init_capicity + _const_extra_metas_inc)))); | |
| 11867 | + bool has_string_keys = key_bytes > ((int)(sizeof(voidptr))); | |
| 11868 | + return ((map){ | |
| 11869 | + .key_bytes = key_bytes, | |
| 11870 | + .value_bytes = value_bytes, | |
| 11871 | + .even_index = _const_init_even_index, | |
| 11872 | + .cached_hashbits = _const_max_cached_hashbits, | |
| 11873 | + .shift = _const_init_log_capicity, | |
| 11874 | + .key_values = builtin__new_dense_array(key_bytes, value_bytes), | |
| 11875 | + .metas = ((u32*)(builtin__vcalloc_noscan(metasize))), | |
| 11876 | + .extra_metas = _const_extra_metas_inc, | |
| 11877 | + .has_string_keys = has_string_keys, | |
| 11878 | + .hash_fn = hash_fn, | |
| 11879 | + .key_eq_fn = key_eq_fn, | |
| 11880 | + .clone_fn = clone_fn, | |
| 11881 | + .free_fn = free_fn, | |
| 11882 | + .len = 0, | |
| 11883 | + }); | |
| 11884 | +} | |
| 11885 | +VV_LOC map builtin__new_map_init(u64 (*hash_fn)(voidptr _d1), bool (*key_eq_fn)(voidptr _d1, voidptr _d2), void (*clone_fn)(voidptr _d1, voidptr _d2), void (*free_fn)(voidptr _d1), int n, int key_bytes, int value_bytes, voidptr keys, voidptr values) { | |
| 11886 | + map out = builtin__new_map(key_bytes, value_bytes, hash_fn, key_eq_fn, clone_fn, free_fn); | |
| 11887 | + u8* pkey = ((u8*)(keys)); | |
| 11888 | + u8* pval = ((u8*)(values)); | |
| 11889 | + for (int _t1 = 0; _t1 < n; ++_t1) { | |
| 11890 | + { // Unsafe block | |
| 11891 | + builtin__map_set(&out, pkey, pval); | |
| 11892 | + pkey = pkey + key_bytes; | |
| 11893 | + pval = pval + value_bytes; | |
| 11894 | + } | |
| 11895 | + } | |
| 11896 | + return out; | |
| 11897 | +} | |
| 11898 | +map builtin__map_move(map* m) { | |
| 11899 | + map r = *m; | |
| 11900 | + builtin__vmemset(m, 0, ((int)(sizeof(map)))); | |
| 11901 | + return r; | |
| 11902 | +} | |
| 11903 | +void builtin__map_clear(map* m) { | |
| 11904 | + { // Unsafe block | |
| 11905 | + if (m->key_values.all_deleted != 0) { | |
| 11906 | + builtin___v_free(m->key_values.all_deleted); | |
| 11907 | + m->key_values.all_deleted = ((void*)0); | |
| 11908 | + } | |
| 11909 | + builtin__vmemset(m->key_values.keys, 0, m->key_values.key_bytes * m->key_values.cap); | |
| 11910 | + builtin__vmemset(m->metas, 0, sizeof(u32) * (m->even_index + 2 + m->extra_metas)); | |
| 11911 | + } | |
| 11912 | + m->key_values.len = 0; | |
| 11913 | + m->key_values.deletes = 0; | |
| 11914 | + m->even_index = _const_init_even_index; | |
| 11915 | + m->cached_hashbits = _const_max_cached_hashbits; | |
| 11916 | + m->shift = _const_init_log_capicity; | |
| 11917 | + m->len = 0; | |
| 11918 | +} | |
| 11919 | +inline VV_LOC multi_return_u32_u32 builtin__map_key_to_index(map* m, voidptr pkey) { | |
| 11920 | + if (((voidptr)(m->hash_fn)) == ((void*)0)) { | |
| 11921 | + { // Unsafe block | |
| 11922 | + u64* p = ((u64*)(m)); | |
| 11923 | + u64 prev2 = (((u64*)(((usize)(m)) - ((usize)(16)))))[0]; | |
| 11924 | + u64 prev1 = (((u64*)(((usize)(m)) - ((usize)(8)))))[0]; | |
| 11925 | + builtin___v_panic(builtin__string_plus_many(34, _MOV((string[34]){_S("map.hash_fn is nil map_ptr="), builtin__usize_str(((usize)(m))), _S(" key_bytes="), builtin__int_str(m->key_bytes), _S(" value_bytes="), builtin__int_str(m->value_bytes), _S(" even_index="), builtin__u32_str(m->even_index), _S(" shift="), builtin__u8_str(m->shift), _S(" metas="), builtin__usize_str(((usize)(m->metas))), _S(" prev2="), builtin__u64_str(prev2), _S(" prev1="), builtin__u64_str(prev1), _S(" w0="), builtin__u64_str(p[0]), _S(" w1="), builtin__u64_str(p[1]), _S(" w2="), builtin__u64_str(p[2]), _S(" w3="), builtin__u64_str(p[3]), _S(" w4="), builtin__u64_str(p[4]), _S(" w5="), builtin__u64_str(p[5]), _S(" w6="), builtin__u64_str(p[6]), _S(" w7="), builtin__u64_str(p[7]), _S(" hash_fn="), builtin__usize_str(((usize)(((voidptr)(m->hash_fn)))))}))); | |
| 11926 | + VUNREACHABLE(); | |
| 11927 | + } | |
| 11928 | + } | |
| 11929 | + u64 hash = m->hash_fn(pkey); | |
| 11930 | + u64 index = (hash & m->even_index); | |
| 11931 | + u64 meta = ((((v__rshift_u64(hash, (u64)m->shift)) & _const_hash_mask)) | _const_probe_inc); | |
| 11932 | + return (multi_return_u32_u32){.arg0=((u32)(index)), .arg1=((u32)(meta))}; | |
| 11933 | +} | |
| 11934 | +inline VV_LOC multi_return_u32_u32 builtin__map_meta_less(map* m, u32 _index, u32 _metas) { | |
| 11935 | + u32 index = _index; | |
| 11936 | + u32 meta = _metas; | |
| 11937 | + for (;;) { | |
| 11938 | + if (!(meta < m->metas[index])) break; | |
| 11939 | + index += 2; | |
| 11940 | + meta += _const_probe_inc; | |
| 11941 | + } | |
| 11942 | + return (multi_return_u32_u32){.arg0=index, .arg1=meta}; | |
| 11943 | +} | |
| 11944 | +inline VV_LOC void builtin__map_meta_greater(map* m, u32 _index, u32 _metas, u32 kvi) { | |
| 11945 | + u32 meta = _metas; | |
| 11946 | + u32 index = _index; | |
| 11947 | + u32 kv_index = kvi; | |
| 11948 | + for (;;) { | |
| 11949 | + if (!(m->metas[index] != 0)) break; | |
| 11950 | + if (meta > m->metas[index]) { | |
| 11951 | + { // Unsafe block | |
| 11952 | + u32 tmp_meta = m->metas[index]; | |
| 11953 | + m->metas[index] = meta; | |
| 11954 | + meta = tmp_meta; | |
| 11955 | + u32 tmp_index = m->metas[index + 1]; | |
| 11956 | + m->metas[index + 1] = kv_index; | |
| 11957 | + kv_index = tmp_index; | |
| 11958 | + } | |
| 11959 | + } | |
| 11960 | + index += 2; | |
| 11961 | + meta += _const_probe_inc; | |
| 11962 | + if (index + 2 >= m->even_index + 2 + m->extra_metas) { | |
| 11963 | + builtin__map_ensure_extra_metas_grow(m); | |
| 11964 | + } | |
| 11965 | + } | |
| 11966 | + { // Unsafe block | |
| 11967 | + m->metas[index] = meta; | |
| 11968 | + m->metas[index + 1] = kv_index; | |
| 11969 | + } | |
| 11970 | + u32 probe_count = (v__rshift_u32(meta, (u64)_const_hashbits)) - 1; | |
| 11971 | + builtin__map_ensure_extra_metas(m, probe_count); | |
| 11972 | +} | |
| 11973 | +VV_LOC void builtin__map_ensure_extra_metas_grow(map* m) { | |
| 11974 | + u32 size_of_u32 = sizeof(u32); | |
| 11975 | + u32 old_mem_size = (m->even_index + 2 + m->extra_metas); | |
| 11976 | + m->extra_metas += _const_extra_metas_inc; | |
| 11977 | + u32 mem_size = (m->even_index + 2 + m->extra_metas); | |
| 11978 | + { // Unsafe block | |
| 11979 | + u8* x = builtin__realloc_data(((byteptr)(m->metas)), ((int)(size_of_u32 * old_mem_size)), ((int)(size_of_u32 * mem_size))); | |
| 11980 | + m->metas = ((u32*)(x)); | |
| 11981 | + builtin__vmemset(((byteptr)(m->metas)) + (mem_size - _const_extra_metas_inc) * size_of_u32, 0, ((int)(sizeof(u32) * _const_extra_metas_inc))); | |
| 11982 | + } | |
| 11983 | +} | |
| 11984 | +inline VV_LOC void builtin__map_ensure_extra_metas(map* m, u32 probe_count) { | |
| 11985 | + if ((v__lshift_u32(probe_count, (u64)1)) == m->extra_metas) { | |
| 11986 | + u32 size_of_u32 = sizeof(u32); | |
| 11987 | + u32 old_mem_size = (m->even_index + 2 + m->extra_metas); | |
| 11988 | + m->extra_metas += _const_extra_metas_inc; | |
| 11989 | + u32 mem_size = (m->even_index + 2 + m->extra_metas); | |
| 11990 | + { // Unsafe block | |
| 11991 | + u8* x = builtin__realloc_data(((byteptr)(m->metas)), ((int)(size_of_u32 * old_mem_size)), ((int)(size_of_u32 * mem_size))); | |
| 11992 | + m->metas = ((u32*)(x)); | |
| 11993 | + builtin__vmemset(((byteptr)(m->metas)) + (mem_size - _const_extra_metas_inc) * size_of_u32, 0, ((int)(sizeof(u32) * _const_extra_metas_inc))); | |
| 11994 | + } | |
| 11995 | + if (probe_count == 252) { | |
| 11996 | + builtin___v_panic(_S("Probe overflow")); | |
| 11997 | + VUNREACHABLE(); | |
| 11998 | + } | |
| 11999 | + } | |
| 12000 | +} | |
| 12001 | +VV_LOC void builtin__map_set(map* m, voidptr key, voidptr value) { | |
| 12002 | + if (((u32)(5)) * ((u32)(m->len)) > ((u32)(2)) * m->even_index) { | |
| 12003 | + builtin__map_expand(m); | |
| 12004 | + } | |
| 12005 | + multi_return_u32_u32 mr_14546 = builtin__map_key_to_index(m, key); | |
| 12006 | + u32 index = mr_14546.arg0; | |
| 12007 | + u32 meta = mr_14546.arg1; | |
| 12008 | + multi_return_u32_u32 mr_14582 = builtin__map_meta_less(m, index, meta); | |
| 12009 | + index = mr_14582.arg0; | |
| 12010 | + meta = mr_14582.arg1; | |
| 12011 | + for (;;) { | |
| 12012 | + if (!(meta == m->metas[index])) break; | |
| 12013 | + int kv_index = ((int)(m->metas[index + 1])); | |
| 12014 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | |
| 12015 | + if (m->key_eq_fn(key, pkey)) { | |
| 12016 | + { // Unsafe block | |
| 12017 | + voidptr pval = builtin__DenseArray_value(&m->key_values, kv_index); | |
| 12018 | + builtin__vmemcpy(pval, value, m->value_bytes); | |
| 12019 | + } | |
| 12020 | + return; | |
| 12021 | + } | |
| 12022 | + index += 2; | |
| 12023 | + meta += _const_probe_inc; | |
| 12024 | + } | |
| 12025 | + int kv_index = builtin__DenseArray_expand(&m->key_values); | |
| 12026 | + { // Unsafe block | |
| 12027 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | |
| 12028 | + voidptr pvalue = builtin__DenseArray_value(&m->key_values, kv_index); | |
| 12029 | + m->clone_fn(pkey, key); | |
| 12030 | + builtin__vmemcpy(pvalue, value, m->value_bytes); | |
| 12031 | + } | |
| 12032 | + builtin__map_meta_greater(m, index, meta, ((u32)(kv_index))); | |
| 12033 | + m->len++; | |
| 12034 | +} | |
| 12035 | +VV_LOC void builtin__map_expand(map* m) { | |
| 12036 | + u32 old_cap = m->even_index; | |
| 12037 | + m->even_index = (v__lshift_u32((m->even_index + 2), (u64)1)) - 2; | |
| 12038 | + if (m->cached_hashbits == 0) { | |
| 12039 | + m->shift += _const_max_cached_hashbits; | |
| 12040 | + m->cached_hashbits = _const_max_cached_hashbits; | |
| 12041 | + builtin__map_rehash(m); | |
| 12042 | + } else { | |
| 12043 | + builtin__map_cached_rehash(m, old_cap); | |
| 12044 | + m->cached_hashbits--; | |
| 12045 | + } | |
| 12046 | +} | |
| 12047 | +VV_LOC void builtin__map_rehash(map* m) { | |
| 12048 | + u32 meta_bytes = sizeof(u32) * (m->even_index + 2 + m->extra_metas); | |
| 12049 | + builtin__map_reserve_metas(m, meta_bytes); | |
| 12050 | +} | |
| 12051 | +VV_LOC void builtin__map_reserve_metas(map* m, u32 meta_bytes) { | |
| 12052 | + { // Unsafe block | |
| 12053 | + u8* x = builtin__v_realloc(((byteptr)(m->metas)), ((int)(meta_bytes))); | |
| 12054 | + m->metas = ((u32*)(x)); | |
| 12055 | + builtin__vmemset(m->metas, 0, ((int)(meta_bytes))); | |
| 12056 | + } | |
| 12057 | + for (int i = 0; i < m->key_values.len; i++) { | |
| 12058 | + if (!builtin__DenseArray_has_index(&m->key_values, i)) { | |
| 12059 | + continue; | |
| 12060 | + } | |
| 12061 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, i); | |
| 12062 | + multi_return_u32_u32 mr_16309 = builtin__map_key_to_index(m, pkey); | |
| 12063 | + u32 index = mr_16309.arg0; | |
| 12064 | + u32 meta = mr_16309.arg1; | |
| 12065 | + multi_return_u32_u32 mr_16347 = builtin__map_meta_less(m, index, meta); | |
| 12066 | + index = mr_16347.arg0; | |
| 12067 | + meta = mr_16347.arg1; | |
| 12068 | + builtin__map_meta_greater(m, index, meta, ((u32)(i))); | |
| 12069 | + } | |
| 12070 | +} | |
| 12071 | +void builtin__map_reserve(map* m, u32 n) { | |
| 12072 | + for (;;) { | |
| 12073 | + if (!(((u64)(n)) * 5 > ((u64)(m->even_index)) * 2)) break; | |
| 12074 | + builtin__map_expand(m); | |
| 12075 | + } | |
| 12076 | +} | |
| 12077 | +VV_LOC void builtin__map_cached_rehash(map* m, u32 old_cap) { | |
| 12078 | + u32* old_metas = m->metas; | |
| 12079 | + int metasize = ((int)(sizeof(u32) * (m->even_index + 2 + m->extra_metas))); | |
| 12080 | + m->metas = ((u32*)(builtin__vcalloc(metasize))); | |
| 12081 | + u32 old_extra_metas = m->extra_metas; | |
| 12082 | + for (u32 i = ((u32)(0)); i <= old_cap + old_extra_metas; i += 2) { | |
| 12083 | + if (old_metas[i] == 0) { | |
| 12084 | + continue; | |
| 12085 | + } | |
| 12086 | + u32 old_meta = old_metas[i]; | |
| 12087 | + u32 old_probe_count = v__lshift_u32(((v__rshift_u32(old_meta, (u64)_const_hashbits)) - 1), (u64)1); | |
| 12088 | + u32 old_index = ((i - old_probe_count) & (v__rshift_u32(m->even_index, (u64)1))); | |
| 12089 | + u32 index = (((old_index | (v__lshift_u32(old_meta, (u64)m->shift)))) & m->even_index); | |
| 12090 | + u32 meta = (((old_meta & _const_hash_mask)) | _const_probe_inc); | |
| 12091 | + u32 kv_index = old_metas[i + 1]; | |
| 12092 | + multi_return_u32_u32 mr_17370 = builtin__map_meta_less(m, index, meta); | |
| 12093 | + index = mr_17370.arg0; | |
| 12094 | + meta = mr_17370.arg1; | |
| 12095 | + builtin__map_meta_greater(m, index, meta, kv_index); | |
| 12096 | + } | |
| 12097 | + builtin___v_free(old_metas); | |
| 12098 | +} | |
| 12099 | +VV_LOC voidptr builtin__map_get_and_set(map* m, voidptr key, voidptr zero) { | |
| 12100 | + for (;;) { | |
| 12101 | + multi_return_u32_u32 mr_17776 = builtin__map_key_to_index(m, key); | |
| 12102 | + u32 index = mr_17776.arg0; | |
| 12103 | + u32 meta = mr_17776.arg1; | |
| 12104 | + for (;;) { | |
| 12105 | + if (meta == m->metas[index]) { | |
| 12106 | + int kv_index = ((int)(m->metas[index + 1])); | |
| 12107 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | |
| 12108 | + if (m->key_eq_fn(key, pkey)) { | |
| 12109 | + voidptr pval = builtin__DenseArray_value(&m->key_values, kv_index); | |
| 12110 | + return ((u8*)(pval)); | |
| 12111 | + } | |
| 12112 | + } | |
| 12113 | + index += 2; | |
| 12114 | + meta += _const_probe_inc; | |
| 12115 | + if (meta > m->metas[index]) { | |
| 12116 | + break; | |
| 12117 | + } | |
| 12118 | + } | |
| 12119 | + builtin__map_set(m, key, zero); | |
| 12120 | + } | |
| 12121 | + return ((void*)0); | |
| 12122 | +} | |
| 12123 | +VV_LOC voidptr builtin__map_get(map* m, voidptr key, voidptr zero) { | |
| 12124 | + if (m->len == 0) { | |
| 12125 | + return zero; | |
| 12126 | + } | |
| 12127 | + multi_return_u32_u32 mr_18537 = builtin__map_key_to_index(m, key); | |
| 12128 | + u32 index = mr_18537.arg0; | |
| 12129 | + u32 meta = mr_18537.arg1; | |
| 12130 | + for (;;) { | |
| 12131 | + if (meta == m->metas[index]) { | |
| 12132 | + int kv_index = ((int)(m->metas[index + 1])); | |
| 12133 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | |
| 12134 | + if (m->key_eq_fn(key, pkey)) { | |
| 12135 | + voidptr pval = builtin__DenseArray_value(&m->key_values, kv_index); | |
| 12136 | + return ((u8*)(pval)); | |
| 12137 | + } | |
| 12138 | + } | |
| 12139 | + index += 2; | |
| 12140 | + meta += _const_probe_inc; | |
| 12141 | + if (meta > m->metas[index]) { | |
| 12142 | + break; | |
| 12143 | + } | |
| 12144 | + } | |
| 12145 | + return zero; | |
| 12146 | +} | |
| 12147 | +VV_LOC voidptr builtin__map_get_check(map* m, voidptr key) { | |
| 12148 | + if (m->len == 0) { | |
| 12149 | + return 0; | |
| 12150 | + } | |
| 12151 | + multi_return_u32_u32 mr_19233 = builtin__map_key_to_index(m, key); | |
| 12152 | + u32 index = mr_19233.arg0; | |
| 12153 | + u32 meta = mr_19233.arg1; | |
| 12154 | + for (;;) { | |
| 12155 | + if (meta == m->metas[index]) { | |
| 12156 | + int kv_index = ((int)(m->metas[index + 1])); | |
| 12157 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | |
| 12158 | + if (m->key_eq_fn(key, pkey)) { | |
| 12159 | + voidptr pval = builtin__DenseArray_value(&m->key_values, kv_index); | |
| 12160 | + return ((u8*)(pval)); | |
| 12161 | + } | |
| 12162 | + } | |
| 12163 | + index += 2; | |
| 12164 | + meta += _const_probe_inc; | |
| 12165 | + if (meta > m->metas[index]) { | |
| 12166 | + break; | |
| 12167 | + } | |
| 12168 | + } | |
| 12169 | + return 0; | |
| 12170 | +} | |
| 12171 | +VV_LOC bool builtin__map_exists(map* m, voidptr key) { | |
| 12172 | + if (m->len == 0) { | |
| 12173 | + return false; | |
| 12174 | + } | |
| 12175 | + multi_return_u32_u32 mr_19778 = builtin__map_key_to_index(m, key); | |
| 12176 | + u32 index = mr_19778.arg0; | |
| 12177 | + u32 meta = mr_19778.arg1; | |
| 12178 | + for (;;) { | |
| 12179 | + if (meta == m->metas[index]) { | |
| 12180 | + int kv_index = ((int)(m->metas[index + 1])); | |
| 12181 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | |
| 12182 | + if (m->key_eq_fn(key, pkey)) { | |
| 12183 | + return true; | |
| 12184 | + } | |
| 12185 | + } | |
| 12186 | + index += 2; | |
| 12187 | + meta += _const_probe_inc; | |
| 12188 | + if (meta > m->metas[index]) { | |
| 12189 | + break; | |
| 12190 | + } | |
| 12191 | + } | |
| 12192 | + return false; | |
| 12193 | +} | |
| 12194 | +inline VV_LOC void builtin__DenseArray_delete(DenseArray* d, int i) { | |
| 12195 | + if (i == d->len - 1) { | |
| 12196 | + d->len--; | |
| 12197 | + builtin__DenseArray_trim_deleted_tail(d); | |
| 12198 | + return; | |
| 12199 | + } | |
| 12200 | + if (d->deletes == 0) { | |
| 12201 | + d->all_deleted = builtin__vcalloc(d->cap); | |
| 12202 | + } | |
| 12203 | + d->deletes++; | |
| 12204 | + { // Unsafe block | |
| 12205 | + d->all_deleted[i] = 1; | |
| 12206 | + } | |
| 12207 | +} | |
| 12208 | +void builtin__map_delete(map* m, voidptr key) { | |
| 12209 | + multi_return_u32_u32 mr_20483 = builtin__map_key_to_index(m, key); | |
| 12210 | + u32 index = mr_20483.arg0; | |
| 12211 | + u32 meta = mr_20483.arg1; | |
| 12212 | + multi_return_u32_u32 mr_20519 = builtin__map_meta_less(m, index, meta); | |
| 12213 | + index = mr_20519.arg0; | |
| 12214 | + meta = mr_20519.arg1; | |
| 12215 | + for (;;) { | |
| 12216 | + if (!(meta == m->metas[index])) break; | |
| 12217 | + int kv_index = ((int)(m->metas[index + 1])); | |
| 12218 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | |
| 12219 | + if (m->key_eq_fn(key, pkey)) { | |
| 12220 | + for (;;) { | |
| 12221 | + if (!((v__rshift_u32(m->metas[index + 2], (u64)_const_hashbits)) > 1)) break; | |
| 12222 | + { // Unsafe block | |
| 12223 | + m->metas[index] = m->metas[index + 2] - _const_probe_inc; | |
| 12224 | + m->metas[index + 1] = m->metas[index + 3]; | |
| 12225 | + } | |
| 12226 | + index += 2; | |
| 12227 | + } | |
| 12228 | + m->len--; | |
| 12229 | + builtin__DenseArray_delete(&m->key_values, kv_index); | |
| 12230 | + { // Unsafe block | |
| 12231 | + m->metas[index] = 0; | |
| 12232 | + m->free_fn(pkey); | |
| 12233 | + builtin__vmemset(pkey, 0, m->key_bytes); | |
| 12234 | + } | |
| 12235 | + if (m->key_values.len <= 32) { | |
| 12236 | + return; | |
| 12237 | + } | |
| 12238 | + if (_us32_ge(m->key_values.deletes,(v__rshift_int(m->key_values.len, (u64)1)))) { | |
| 12239 | + builtin__DenseArray_zeros_to_end(&m->key_values); | |
| 12240 | + builtin__map_rehash(m); | |
| 12241 | + } | |
| 12242 | + return; | |
| 12243 | + } | |
| 12244 | + index += 2; | |
| 12245 | + meta += _const_probe_inc; | |
| 12246 | + } | |
| 12247 | +} | |
| 12248 | +array builtin__map_keys(map* m) { | |
| 12249 | + array keys = builtin____new_array(m->len, 0, m->key_bytes); | |
| 12250 | + u8* item = ((u8*)(keys.data)); | |
| 12251 | + if (m->key_values.deletes == 0) { | |
| 12252 | + for (int i = 0; i < m->key_values.len; i++) { | |
| 12253 | + { // Unsafe block | |
| 12254 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, i); | |
| 12255 | + m->clone_fn(item, pkey); | |
| 12256 | + item = item + m->key_bytes; | |
| 12257 | + } | |
| 12258 | + } | |
| 12259 | + return keys; | |
| 12260 | + } | |
| 12261 | + for (int i = 0; i < m->key_values.len; i++) { | |
| 12262 | + if (!builtin__DenseArray_has_index(&m->key_values, i)) { | |
| 12263 | + continue; | |
| 12264 | + } | |
| 12265 | + { // Unsafe block | |
| 12266 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, i); | |
| 12267 | + m->clone_fn(item, pkey); | |
| 12268 | + item = item + m->key_bytes; | |
| 12269 | + } | |
| 12270 | + } | |
| 12271 | + return keys; | |
| 12272 | +} | |
| 12273 | +array builtin__map_values(map* m) { | |
| 12274 | + array values = builtin____new_array(m->len, 0, m->value_bytes); | |
| 12275 | + u8* item = ((u8*)(values.data)); | |
| 12276 | + if (m->key_values.deletes == 0) { | |
| 12277 | + builtin__vmemcpy(item, m->key_values.values, m->value_bytes * m->key_values.len); | |
| 12278 | + return values; | |
| 12279 | + } | |
| 12280 | + for (int i = 0; i < m->key_values.len; i++) { | |
| 12281 | + if (!builtin__DenseArray_has_index(&m->key_values, i)) { | |
| 12282 | + continue; | |
| 12283 | + } | |
| 12284 | + { // Unsafe block | |
| 12285 | + voidptr pvalue = builtin__DenseArray_value(&m->key_values, i); | |
| 12286 | + builtin__vmemcpy(item, pvalue, m->value_bytes); | |
| 12287 | + item = item + m->value_bytes; | |
| 12288 | + } | |
| 12289 | + } | |
| 12290 | + return values; | |
| 12291 | +} | |
| 12292 | +VV_LOC DenseArray builtin__DenseArray_clone(DenseArray* d) { | |
| 12293 | + DenseArray res = ((DenseArray){ | |
| 12294 | + .key_bytes = d->key_bytes, | |
| 12295 | + .value_bytes = d->value_bytes, | |
| 12296 | + .cap = d->cap, | |
| 12297 | + .len = d->len, | |
| 12298 | + .deletes = d->deletes, | |
| 12299 | + .all_deleted = ((void*)0), | |
| 12300 | + .keys = ((void*)0), | |
| 12301 | + .values = ((void*)0), | |
| 12302 | + }); | |
| 12303 | + { // Unsafe block | |
| 12304 | + if (d->deletes != 0) { | |
| 12305 | + res.all_deleted = builtin__memdup(d->all_deleted, d->cap); | |
| 12306 | + } | |
| 12307 | + res.keys = builtin__memdup(d->keys, d->cap * d->key_bytes); | |
| 12308 | + res.values = builtin__memdup(d->values, d->cap * d->value_bytes); | |
| 12309 | + } | |
| 12310 | + return res; | |
| 12311 | +} | |
| 12312 | +map builtin__map_clone(map* m) { | |
| 12313 | + int metasize = ((int)(sizeof(u32) * (m->even_index + 2 + m->extra_metas))); | |
| 12314 | + map res = ((map){ | |
| 12315 | + .key_bytes = m->key_bytes, | |
| 12316 | + .value_bytes = m->value_bytes, | |
| 12317 | + .even_index = m->even_index, | |
| 12318 | + .cached_hashbits = m->cached_hashbits, | |
| 12319 | + .shift = m->shift, | |
| 12320 | + .key_values = builtin__DenseArray_clone(&m->key_values), | |
| 12321 | + .metas = ((u32*)(builtin__malloc_noscan(metasize))), | |
| 12322 | + .extra_metas = m->extra_metas, | |
| 12323 | + .has_string_keys = m->has_string_keys, | |
| 12324 | + .hash_fn = m->hash_fn, | |
| 12325 | + .key_eq_fn = m->key_eq_fn, | |
| 12326 | + .clone_fn = m->clone_fn, | |
| 12327 | + .free_fn = m->free_fn, | |
| 12328 | + .len = m->len, | |
| 12329 | + }); | |
| 12330 | + builtin__vmemcpy(res.metas, m->metas, metasize); | |
| 12331 | + if (!m->has_string_keys) { | |
| 12332 | + return res; | |
| 12333 | + } | |
| 12334 | + for (int i = 0; i < m->key_values.len; ++i) { | |
| 12335 | + if (!builtin__DenseArray_has_index(&m->key_values, i)) { | |
| 12336 | + continue; | |
| 12337 | + } | |
| 12338 | + m->clone_fn(builtin__DenseArray_key(&res.key_values, i), builtin__DenseArray_key(&m->key_values, i)); | |
| 12339 | + } | |
| 12340 | + return res; | |
| 12341 | +} | |
| 12342 | +void builtin__map_free(map* m) { | |
| 12343 | + builtin___v_free(m->metas); | |
| 12344 | + { // Unsafe block | |
| 12345 | + m->metas = ((void*)0); | |
| 12346 | + } | |
| 12347 | + if (m->key_values.deletes == 0) { | |
| 12348 | + for (int i = 0; i < m->key_values.len; i++) { | |
| 12349 | + { // Unsafe block | |
| 12350 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, i); | |
| 12351 | + m->free_fn(pkey); | |
| 12352 | + builtin__vmemset(pkey, 0, m->key_bytes); | |
| 12353 | + } | |
| 12354 | + } | |
| 12355 | + } else { | |
| 12356 | + for (int i = 0; i < m->key_values.len; i++) { | |
| 12357 | + if (!builtin__DenseArray_has_index(&m->key_values, i)) { | |
| 12358 | + continue; | |
| 12359 | + } | |
| 12360 | + { // Unsafe block | |
| 12361 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, i); | |
| 12362 | + m->free_fn(pkey); | |
| 12363 | + builtin__vmemset(pkey, 0, m->key_bytes); | |
| 12364 | + } | |
| 12365 | + } | |
| 12366 | + } | |
| 12367 | + { // Unsafe block | |
| 12368 | + if (m->key_values.all_deleted != ((void*)0)) { | |
| 12369 | + builtin___v_free(m->key_values.all_deleted); | |
| 12370 | + m->key_values.all_deleted = ((void*)0); | |
| 12371 | + } | |
| 12372 | + if (m->key_values.keys != ((void*)0)) { | |
| 12373 | + builtin___v_free(m->key_values.keys); | |
| 12374 | + m->key_values.keys = ((void*)0); | |
| 12375 | + } | |
| 12376 | + if (m->key_values.values != ((void*)0)) { | |
| 12377 | + builtin___v_free(m->key_values.values); | |
| 12378 | + m->key_values.values = ((void*)0); | |
| 12379 | + } | |
| 12380 | + m->hash_fn = ((void*)0); | |
| 12381 | + m->key_eq_fn = ((void*)0); | |
| 12382 | + m->clone_fn = ((void*)0); | |
| 12383 | + m->free_fn = ((void*)0); | |
| 12384 | + m->key_values.cap = 0; | |
| 12385 | + m->key_values.len = 0; | |
| 12386 | + m->key_values.deletes = 0; | |
| 12387 | + m->even_index = 0; | |
| 12388 | + m->cached_hashbits = 0; | |
| 12389 | + m->shift = 0; | |
| 12390 | + m->extra_metas = 0; | |
| 12391 | + m->has_string_keys = false; | |
| 12392 | + m->len = 0; | |
| 12393 | + } | |
| 12394 | +} | |
| 12395 | +void builtin__VAssertMetaInfo_free(VAssertMetaInfo* ami) { | |
| 12396 | + { // Unsafe block | |
| 12397 | + builtin__string_free(&ami->fpath); | |
| 12398 | + builtin__string_free(&ami->fn_name); | |
| 12399 | + builtin__string_free(&ami->src); | |
| 12400 | + builtin__string_free(&ami->op); | |
| 12401 | + builtin__string_free(&ami->llabel); | |
| 12402 | + builtin__string_free(&ami->rlabel); | |
| 12403 | + builtin__string_free(&ami->lvalue); | |
| 12404 | + builtin__string_free(&ami->rvalue); | |
| 12405 | + builtin__string_free(&ami->message); | |
| 12406 | + } | |
| 12407 | +} | |
| 12408 | +void builtin__IError_free(IError* ie) { | |
| 12409 | + { // Unsafe block | |
| 12410 | + IError* cie = ((IError*)(ie)); | |
| 12411 | + builtin___v_free(cie->_object); | |
| 12412 | + } | |
| 12413 | +} | |
| 12414 | +VNORETURN void builtin__panic_option_not_set(string s) { | |
| 12415 | + builtin___v_panic(builtin__string_plus_many(3, _MOV((string[3]){_S("option not set ("), s, _S(")")}))); | |
| 12416 | + VUNREACHABLE(); | |
| 12417 | + while(1); | |
| 12418 | +} | |
| 12419 | +VNORETURN void builtin__panic_result_not_set(string s) { | |
| 12420 | + builtin___v_panic(builtin__string_plus_many(3, _MOV((string[3]){_S("result not set ("), s, _S(")")}))); | |
| 12421 | + VUNREACHABLE(); | |
| 12422 | + while(1); | |
| 12423 | +} | |
| 12424 | +VNORETURN void builtin___v_panic(string s) { | |
| 12425 | + #if 0 | |
| 12426 | + { | |
| 12427 | + } | |
| 12428 | + #elif defined(CUSTOM_DEFINE_v2_native_windows_pe_minimal) | |
| 12429 | + { | |
| 12430 | + } | |
| 12431 | + #else | |
| 12432 | + { | |
| 12433 | + builtin__flush_stdout(); | |
| 12434 | + builtin__eprint(_S("V panic: ")); | |
| 12435 | + builtin__eprintln(s); | |
| 12436 | + builtin__eprint(_S(" v hash: ")); | |
| 12437 | + builtin__eprintln(builtin__vcurrent_hash()); | |
| 12438 | + #if 1 | |
| 12439 | + { | |
| 12440 | + builtin__eprint(_S(" pid: ")); | |
| 12441 | + ; | |
| 12442 | + fprintf(stderr, "%p\n", ((voidptr)(builtin__v_getpid()))); | |
| 12443 | + builtin__eprint(_S(" tid: ")); | |
| 12444 | + ; | |
| 12445 | + fprintf(stderr, "%p\n", ((voidptr)(builtin__v_gettid()))); | |
| 12446 | + } | |
| 12447 | + #endif | |
| 12448 | + builtin__flush_stdout(); | |
| 12449 | + #if defined(CUSTOM_DEFINE_exit_after_panic_message) | |
| 12450 | + { | |
| 12451 | + } | |
| 12452 | + #elif defined(CUSTOM_DEFINE_no_backtrace) | |
| 12453 | + { | |
| 12454 | + } | |
| 12455 | + #elif 0 | |
| 12456 | + { | |
| 12457 | + } | |
| 12458 | + #else | |
| 12459 | + { | |
| 12460 | + #if defined(CUSTOM_DEFINE_use_libbacktrace) && !defined(__TINYC__) | |
| 12461 | + { | |
| 12462 | + } | |
| 12463 | + #else | |
| 12464 | + { | |
| 12465 | + builtin__print_backtrace_skipping_top_frames(1); | |
| 12466 | + } | |
| 12467 | + #endif | |
| 12468 | + exit(1); | |
| 12469 | + VUNREACHABLE(); | |
| 12470 | + } | |
| 12471 | + #endif | |
| 12472 | + } | |
| 12473 | + #endif | |
| 12474 | + exit(1); | |
| 12475 | + VUNREACHABLE(); | |
| 12476 | + for (;;) { | |
| 12477 | + } | |
| 12478 | + while(1); | |
| 12479 | +} | |
| 12480 | +string builtin__c_error_number_str(int errnum) { | |
| 12481 | + string err_msg = _S(""); | |
| 12482 | + #if 0 | |
| 12483 | + { | |
| 12484 | + } | |
| 12485 | + #else | |
| 12486 | + { | |
| 12487 | + #if 1 | |
| 12488 | + { | |
| 12489 | + char* c_msg = strerror(errnum); | |
| 12490 | + err_msg = ((string){.str = ((u8*)(c_msg)), .len = ((int)(strlen(c_msg))), .is_lit = 1}); | |
| 12491 | + } | |
| 12492 | + #endif | |
| 12493 | + } | |
| 12494 | + #endif | |
| 12495 | + return err_msg; | |
| 12496 | +} | |
| 12497 | +VNORETURN void builtin__panic_n(string s, i64 number1) { | |
| 12498 | + builtin___v_panic(builtin__string__plus(s, builtin__impl_i64_to_string(number1))); | |
| 12499 | + VUNREACHABLE(); | |
| 12500 | + while(1); | |
| 12501 | +} | |
| 12502 | +VNORETURN void builtin__panic_n2(string s, i64 number1, i64 number2) { | |
| 12503 | + builtin___v_panic(builtin__string_plus_many(4, _MOV((string[4]){s, builtin__impl_i64_to_string(number1), _S(", "), builtin__impl_i64_to_string(number2)}))); | |
| 12504 | + VUNREACHABLE(); | |
| 12505 | + while(1); | |
| 12506 | +} | |
| 12507 | +VNORETURN VV_LOC void builtin__panic_n3(string s, i64 number1, i64 number2, i64 number3) { | |
| 12508 | + builtin___v_panic(builtin__string_plus_many(6, _MOV((string[6]){s, builtin__impl_i64_to_string(number1), _S(", "), builtin__impl_i64_to_string(number2), _S(", "), builtin__impl_i64_to_string(number3)}))); | |
| 12509 | + VUNREACHABLE(); | |
| 12510 | + while(1); | |
| 12511 | +} | |
| 12512 | +VNORETURN void builtin__panic_error_number(string basestr, int errnum) { | |
| 12513 | + builtin___v_panic(builtin__string__plus(basestr, builtin__c_error_number_str(errnum))); | |
| 12514 | + VUNREACHABLE(); | |
| 12515 | + while(1); | |
| 12516 | +} | |
| 12517 | +VV_LOC void builtin__set_stream_unbuffered(FILE* stream) { | |
| 12518 | + setvbuf(stream, ((char*)(((void*)0))), _IONBF, ((usize)(0))); | |
| 12519 | +} | |
| 12520 | +void builtin__eprintln(string s) { | |
| 12521 | + #if 0 | |
| 12522 | + { | |
| 12523 | + } | |
| 12524 | + #elif 0 | |
| 12525 | + { | |
| 12526 | + } | |
| 12527 | + #else | |
| 12528 | + { | |
| 12529 | + builtin__flush_stdout(); | |
| 12530 | + builtin__flush_stderr(); | |
| 12531 | + builtin___writeln_to_fd(2, s); | |
| 12532 | + builtin__flush_stderr(); | |
| 12533 | + } | |
| 12534 | + #endif | |
| 12535 | +} | |
| 12536 | +void builtin__eprint(string s) { | |
| 12537 | + #if 0 | |
| 12538 | + { | |
| 12539 | + } | |
| 12540 | + #elif 0 | |
| 12541 | + { | |
| 12542 | + } | |
| 12543 | + #else | |
| 12544 | + { | |
| 12545 | + builtin__flush_stdout(); | |
| 12546 | + builtin__flush_stderr(); | |
| 12547 | + builtin___write_buf_to_fd(2, s.str, s.len); | |
| 12548 | + builtin__flush_stderr(); | |
| 12549 | + } | |
| 12550 | + #endif | |
| 12551 | +} | |
| 12552 | +void builtin__flush_stdout(void) { | |
| 12553 | + #if defined(CUSTOM_DEFINE_v2_native_windows_pe_minimal) | |
| 12554 | + { | |
| 12555 | + } | |
| 12556 | + #elif 0 | |
| 12557 | + { | |
| 12558 | + } | |
| 12559 | + #elif defined(CUSTOM_DEFINE_builtin_write_buf_to_fd_should_use_c_write) | |
| 12560 | + { | |
| 12561 | + } | |
| 12562 | + #else | |
| 12563 | + { | |
| 12564 | + fflush(stdout); | |
| 12565 | + } | |
| 12566 | + #endif | |
| 12567 | +} | |
| 12568 | +void builtin__flush_stderr(void) { | |
| 12569 | + #if defined(CUSTOM_DEFINE_v2_native_windows_pe_minimal) | |
| 12570 | + { | |
| 12571 | + } | |
| 12572 | + #elif 0 | |
| 12573 | + { | |
| 12574 | + } | |
| 12575 | + #elif defined(CUSTOM_DEFINE_builtin_write_buf_to_fd_should_use_c_write) | |
| 12576 | + { | |
| 12577 | + } | |
| 12578 | + #else | |
| 12579 | + { | |
| 12580 | + fflush(stderr); | |
| 12581 | + } | |
| 12582 | + #endif | |
| 12583 | +} | |
| 12584 | +void builtin__unbuffer_stdout(void) { | |
| 12585 | + #if 0 | |
| 12586 | + { | |
| 12587 | + } | |
| 12588 | + #elif 0 | |
| 12589 | + { | |
| 12590 | + } | |
| 12591 | + #elif defined(CUSTOM_DEFINE_builtin_write_buf_to_fd_should_use_c_write) | |
| 12592 | + { | |
| 12593 | + } | |
| 12594 | + #else | |
| 12595 | + { | |
| 12596 | + builtin__set_stream_unbuffered(stdout); | |
| 12597 | + } | |
| 12598 | + #endif | |
| 12599 | +} | |
| 12600 | +void builtin__print(string s) { | |
| 12601 | + #if 0 | |
| 12602 | + { | |
| 12603 | + } | |
| 12604 | + #elif 0 | |
| 12605 | + { | |
| 12606 | + } | |
| 12607 | + #elif 0 | |
| 12608 | + { | |
| 12609 | + } | |
| 12610 | + #else | |
| 12611 | + { | |
| 12612 | + builtin___write_buf_to_fd(1, s.str, s.len); | |
| 12613 | + } | |
| 12614 | + #endif | |
| 12615 | +} | |
| 12616 | +void builtin__println(string s) { | |
| 12617 | + #if 0 | |
| 12618 | + { | |
| 12619 | + } | |
| 12620 | + #elif 0 | |
| 12621 | + { | |
| 12622 | + } | |
| 12623 | + #elif 0 | |
| 12624 | + { | |
| 12625 | + } | |
| 12626 | + #else | |
| 12627 | + { | |
| 12628 | + builtin___writeln_to_fd(1, s); | |
| 12629 | + } | |
| 12630 | + #endif | |
| 12631 | +} | |
| 12632 | +VV_LOC void builtin___writeln_to_fd(int fd, string s) { | |
| 12633 | + #if defined(CUSTOM_DEFINE_builtin_writeln_should_write_at_once) | |
| 12634 | + { | |
| 12635 | + } | |
| 12636 | + #else | |
| 12637 | + { | |
| 12638 | + u8 lf = ((u8)('\n')); | |
| 12639 | + builtin___write_buf_to_fd(fd, s.str, s.len); | |
| 12640 | + builtin___write_buf_to_fd(fd, &lf, 1); | |
| 12641 | + } | |
| 12642 | + #endif | |
| 12643 | +} | |
| 12644 | +VV_LOC void builtin___write_buf_to_fd(int fd, u8* buf, int buf_len) { | |
| 12645 | + if (buf_len <= 0) { | |
| 12646 | + return; | |
| 12647 | + } | |
| 12648 | + #if 0 | |
| 12649 | + { | |
| 12650 | + } | |
| 12651 | + #else | |
| 12652 | + { | |
| 12653 | + u8* ptr = buf; | |
| 12654 | + isize remaining_bytes = ((isize)(buf_len)); | |
| 12655 | + isize x = ((isize)(0)); | |
| 12656 | + #if 0 | |
| 12657 | + { | |
| 12658 | + } | |
| 12659 | + #else | |
| 12660 | + { | |
| 12661 | + voidptr stream = ((voidptr)(stdout)); | |
| 12662 | + if (fd == 2) { | |
| 12663 | + stream = ((voidptr)(stderr)); | |
| 12664 | + } | |
| 12665 | + { // Unsafe block | |
| 12666 | + for (;;) { | |
| 12667 | + if (!(remaining_bytes > 0)) break; | |
| 12668 | + x = ((isize)(fwrite(ptr, 1, remaining_bytes, stream))); | |
| 12669 | + if (x <= 0) { | |
| 12670 | + break; | |
| 12671 | + } | |
| 12672 | + ptr += x; | |
| 12673 | + remaining_bytes -= x; | |
| 12674 | + } | |
| 12675 | + } | |
| 12676 | + } | |
| 12677 | + #endif | |
| 12678 | + } | |
| 12679 | + #endif | |
| 12680 | +} | |
| 12681 | +string builtin__reuse_data_as_string(Array_u8 buffer) { | |
| 12682 | + return ((string){.str = buffer.data, .len = buffer.len, .is_lit = 1}); | |
| 12683 | +} | |
| 12684 | +Array_u8 builtin__reuse_string_as_data(string s) { | |
| 12685 | + array res = ((array){.data = (voidptr)s.str,.offset = 0,.len = s.len,.cap = 0,.flags = ((ArrayFlags__nogrow | ArrayFlags__noshrink) | ArrayFlags__nofree),.element_size = 1,}); | |
| 12686 | + return res; | |
| 12687 | +} | |
| 12688 | +string builtin__rune_str(rune c) { | |
| 12689 | + return builtin__utf32_to_str(((u32)(c))); | |
| 12690 | +} | |
| 12691 | +string Array_rune_string(Array_rune ra) { | |
| 12692 | + strings__Builder sb = strings__new_builder(ra.len); | |
| 12693 | + strings__Builder_write_runes(&sb, ra); | |
| 12694 | + string res = strings__Builder_str(&sb); | |
| 12695 | + strings__Builder_free(&sb); | |
| 12696 | + return res; | |
| 12697 | +} | |
| 12698 | +string builtin__rune_repeat(rune c, int count) { | |
| 12699 | + if (count <= 0) { | |
| 12700 | + return _S(""); | |
| 12701 | + } else if (count == 1) { | |
| 12702 | + return builtin__rune_str(c); | |
| 12703 | + } | |
| 12704 | + Array_fixed_u8_5 buffer = {0}; | |
| 12705 | + string res = builtin__utf32_to_str_no_malloc(((u32)(c)), &buffer[0]); | |
| 12706 | + return builtin__string_repeat(res, count); | |
| 12707 | +} | |
| 12708 | +Array_u8 builtin__rune_bytes(rune c) { | |
| 12709 | + Array_u8 res = builtin____new_array_with_default(0, 5, sizeof(u8), 0); | |
| 12710 | + u8* buf = ((u8*)(res.data)); | |
| 12711 | + res.len = builtin__utf32_decode_to_buffer(((u32)(c)), buf); | |
| 12712 | + return res; | |
| 12713 | +} | |
| 12714 | +int builtin__rune_length_in_bytes(rune c) { | |
| 12715 | + u32 code = ((u32)(c)); | |
| 12716 | + if (code <= 0x7F) { | |
| 12717 | + return 1; | |
| 12718 | + } else if (code <= 0x7FF) { | |
| 12719 | + return 2; | |
| 12720 | + } else if (0xD800 <= code && code <= 0xDFFF) { | |
| 12721 | + return -1; | |
| 12722 | + } else if (code <= 0xFFFF) { | |
| 12723 | + return 3; | |
| 12724 | + } else if (code <= 0x10FFFF) { | |
| 12725 | + return 4; | |
| 12726 | + } | |
| 12727 | + return -1; | |
| 12728 | +} | |
| 12729 | +rune builtin__rune_to_upper(rune c) { | |
| 12730 | + if (c < 0x80) { | |
| 12731 | + if (c >= 'a' && c <= 'z') { | |
| 12732 | + return c - 32; | |
| 12733 | + } | |
| 12734 | + return c; | |
| 12735 | + } | |
| 12736 | + return builtin__rune_map_to(c, MapMode__to_upper); | |
| 12737 | +} | |
| 12738 | +rune builtin__rune_to_lower(rune c) { | |
| 12739 | + if (c < 0x80) { | |
| 12740 | + if (c >= 'A' && c <= 'Z') { | |
| 12741 | + return c + 32; | |
| 12742 | + } | |
| 12743 | + return c; | |
| 12744 | + } | |
| 12745 | + return builtin__rune_map_to(c, MapMode__to_lower); | |
| 12746 | +} | |
| 12747 | +rune builtin__rune_to_title(rune c) { | |
| 12748 | + if (c < 0x80) { | |
| 12749 | + if (c >= 'a' && c <= 'z') { | |
| 12750 | + return c - 32; | |
| 12751 | + } | |
| 12752 | + return c; | |
| 12753 | + } | |
| 12754 | + return builtin__rune_map_to(c, MapMode__to_title); | |
| 12755 | +} | |
| 12756 | +VV_LOC rune builtin__rune_map_to(rune c, MapMode mode) { | |
| 12757 | + int start = 0; | |
| 12758 | + int end = VSAFE_DIV_int(1264 , _const_rune_maps_columns_in_row); | |
| 12759 | + for (;;) { | |
| 12760 | + if (!(start < end)) break; | |
| 12761 | + int middle = VSAFE_DIV_int((start + end) , 2); | |
| 12762 | + i32* cur_map = &_const_rune_maps[middle * _const_rune_maps_columns_in_row]; | |
| 12763 | + if (c >= ((u32)(*cur_map)) && c <= ((u32)(*(cur_map + 1)))) { | |
| 12764 | + i32 offset = ((mode == MapMode__to_upper || mode == MapMode__to_title) ? (*(cur_map + 2)) : (*(cur_map + 3))); | |
| 12765 | + if (offset == _const_rune_maps_ul) { | |
| 12766 | + rune cnt = VSAFE_MOD_rune(((rune)(c - *cur_map)) , 2); | |
| 12767 | + if (mode == MapMode__to_lower) { | |
| 12768 | + return c + 1 - cnt; | |
| 12769 | + } | |
| 12770 | + return c - cnt; | |
| 12771 | + } else if (offset == _const_rune_maps_utl) { | |
| 12772 | + rune cnt = VSAFE_MOD_rune(((rune)(c - *cur_map)) , 3); | |
| 12773 | + if (mode == MapMode__to_upper) { | |
| 12774 | + return c - cnt; | |
| 12775 | + } else if (mode == MapMode__to_lower) { | |
| 12776 | + return c + 2 - cnt; | |
| 12777 | + } | |
| 12778 | + return c + 1 - cnt; | |
| 12779 | + } | |
| 12780 | + return (rune)(c + offset); | |
| 12781 | + } | |
| 12782 | + if (c < ((u32)(*cur_map))) { | |
| 12783 | + end = middle; | |
| 12784 | + } else { | |
| 12785 | + start = middle + 1; | |
| 12786 | + } | |
| 12787 | + } | |
| 12788 | + return c; | |
| 12789 | +} | |
| 12790 | +VV_LOC int builtin__mapnode_find_key(mapnode* n, string k) { | |
| 12791 | + int idx = 0; | |
| 12792 | + for (;;) { | |
| 12793 | + if (!(idx < n->len && builtin__string__lt(n->keys[builtin__v_fixed_index(idx, 11)], k))) break; | |
| 12794 | + idx++; | |
| 12795 | + } | |
| 12796 | + return idx; | |
| 12797 | +} | |
| 12798 | +VV_LOC bool builtin__mapnode_remove_key(mapnode* n, string k) { | |
| 12799 | + int idx = builtin__mapnode_find_key(n, k); | |
| 12800 | + if (idx < n->len && builtin__string__eq(n->keys[builtin__v_fixed_index(idx, 11)], k)) { | |
| 12801 | + if (n->children == ((void*)0)) { | |
| 12802 | + builtin__mapnode_remove_from_leaf(n, idx); | |
| 12803 | + } else { | |
| 12804 | + builtin__mapnode_remove_from_non_leaf(n, idx); | |
| 12805 | + } | |
| 12806 | + return true; | |
| 12807 | + } else { | |
| 12808 | + if (n->children == ((void*)0)) { | |
| 12809 | + return false; | |
| 12810 | + } | |
| 12811 | + bool flag = (idx == n->len ? (true) : (false)); | |
| 12812 | + if (((mapnode*)(n->children[idx]))->len < _const_degree) { | |
| 12813 | + builtin__mapnode_fill(n, idx); | |
| 12814 | + } | |
| 12815 | + mapnode* node = ((mapnode*)(((void*)0))); | |
| 12816 | + if (flag && idx > n->len) { | |
| 12817 | + node = ((mapnode*)(n->children[idx - 1])); | |
| 12818 | + } else { | |
| 12819 | + node = ((mapnode*)(n->children[idx])); | |
| 12820 | + } | |
| 12821 | + return builtin__mapnode_remove_key(node, k); | |
| 12822 | + } | |
| 12823 | + return 0; | |
| 12824 | +} | |
| 12825 | +VV_LOC void builtin__mapnode_remove_from_leaf(mapnode* n, int idx) { | |
| 12826 | + for (int i = idx + 1; i < n->len; i++) { | |
| 12827 | + n->keys[builtin__v_fixed_index(i - 1, 11)] = n->keys[builtin__v_fixed_index(i, 11)]; | |
| 12828 | + n->values[builtin__v_fixed_index(i - 1, 11)] = n->values[builtin__v_fixed_index(i, 11)]; | |
| 12829 | + } | |
| 12830 | + n->len--; | |
| 12831 | +} | |
| 12832 | +VV_LOC void builtin__mapnode_remove_from_non_leaf(mapnode* n, int idx) { | |
| 12833 | + string k = n->keys[builtin__v_fixed_index(idx, 11)]; | |
| 12834 | + if (((mapnode*)(n->children[idx]))->len >= _const_degree) { | |
| 12835 | + mapnode* current = ((mapnode*)(n->children[idx])); | |
| 12836 | + for (;;) { | |
| 12837 | + if (!(current->children != ((void*)0))) break; | |
| 12838 | + current = ((mapnode*)(current->children[current->len])); | |
| 12839 | + } | |
| 12840 | + string predecessor = current->keys[builtin__v_fixed_index(current->len - 1, 11)]; | |
| 12841 | + n->keys[builtin__v_fixed_index(idx, 11)] = predecessor; | |
| 12842 | + n->values[builtin__v_fixed_index(idx, 11)] = current->values[builtin__v_fixed_index(current->len - 1, 11)]; | |
| 12843 | + mapnode* node = ((mapnode*)(n->children[idx])); | |
| 12844 | + builtin__mapnode_remove_key(node, predecessor); | |
| 12845 | + } else if (((mapnode*)(n->children[idx + 1]))->len >= _const_degree) { | |
| 12846 | + mapnode* current = ((mapnode*)(n->children[idx + 1])); | |
| 12847 | + for (;;) { | |
| 12848 | + if (!(current->children != ((void*)0))) break; | |
| 12849 | + current = ((mapnode*)(current->children[0])); | |
| 12850 | + } | |
| 12851 | + string successor = current->keys[0]; | |
| 12852 | + n->keys[builtin__v_fixed_index(idx, 11)] = successor; | |
| 12853 | + n->values[builtin__v_fixed_index(idx, 11)] = current->values[0]; | |
| 12854 | + mapnode* node = ((mapnode*)(n->children[idx + 1])); | |
| 12855 | + builtin__mapnode_remove_key(node, successor); | |
| 12856 | + } else { | |
| 12857 | + builtin__mapnode_merge(n, idx); | |
| 12858 | + mapnode* node = ((mapnode*)(n->children[idx])); | |
| 12859 | + builtin__mapnode_remove_key(node, k); | |
| 12860 | + } | |
| 12861 | +} | |
| 12862 | +VV_LOC void builtin__mapnode_fill(mapnode* n, int idx) { | |
| 12863 | + if (idx != 0 && ((mapnode*)(n->children[idx - 1]))->len >= _const_degree) { | |
| 12864 | + builtin__mapnode_borrow_from_prev(n, idx); | |
| 12865 | + } else if (idx != n->len && ((mapnode*)(n->children[idx + 1]))->len >= _const_degree) { | |
| 12866 | + builtin__mapnode_borrow_from_next(n, idx); | |
| 12867 | + } else if (idx != n->len) { | |
| 12868 | + builtin__mapnode_merge(n, idx); | |
| 12869 | + } else { | |
| 12870 | + builtin__mapnode_merge(n, idx - 1); | |
| 12871 | + } | |
| 12872 | +} | |
| 12873 | +VV_LOC void builtin__mapnode_borrow_from_prev(mapnode* n, int idx) { | |
| 12874 | + mapnode* child = ((mapnode*)(n->children[idx])); | |
| 12875 | + mapnode* sibling = ((mapnode*)(n->children[idx - 1])); | |
| 12876 | + for (int i = child->len - 1; i >= 0; i--) { | |
| 12877 | + child->keys[builtin__v_fixed_index(i + 1, 11)] = child->keys[builtin__v_fixed_index(i, 11)]; | |
| 12878 | + child->values[builtin__v_fixed_index(i + 1, 11)] = child->values[builtin__v_fixed_index(i, 11)]; | |
| 12879 | + } | |
| 12880 | + if (child->children != ((void*)0)) { | |
| 12881 | + for (int i = child->len; i >= 0; i--) { | |
| 12882 | + { // Unsafe block | |
| 12883 | + child->children[i + 1] = child->children[i]; | |
| 12884 | + } | |
| 12885 | + } | |
| 12886 | + } | |
| 12887 | + child->keys[0] = n->keys[builtin__v_fixed_index(idx - 1, 11)]; | |
| 12888 | + child->values[0] = n->values[builtin__v_fixed_index(idx - 1, 11)]; | |
| 12889 | + if (child->children != ((void*)0)) { | |
| 12890 | + { // Unsafe block | |
| 12891 | + child->children[0] = sibling->children[sibling->len]; | |
| 12892 | + } | |
| 12893 | + } | |
| 12894 | + n->keys[builtin__v_fixed_index(idx - 1, 11)] = sibling->keys[builtin__v_fixed_index(sibling->len - 1, 11)]; | |
| 12895 | + n->values[builtin__v_fixed_index(idx - 1, 11)] = sibling->values[builtin__v_fixed_index(sibling->len - 1, 11)]; | |
| 12896 | + child->len++; | |
| 12897 | + sibling->len--; | |
| 12898 | +} | |
| 12899 | +VV_LOC void builtin__mapnode_borrow_from_next(mapnode* n, int idx) { | |
| 12900 | + mapnode* child = ((mapnode*)(n->children[idx])); | |
| 12901 | + mapnode* sibling = ((mapnode*)(n->children[idx + 1])); | |
| 12902 | + child->keys[builtin__v_fixed_index(child->len, 11)] = n->keys[builtin__v_fixed_index(idx, 11)]; | |
| 12903 | + child->values[builtin__v_fixed_index(child->len, 11)] = n->values[builtin__v_fixed_index(idx, 11)]; | |
| 12904 | + if (child->children != ((void*)0)) { | |
| 12905 | + { // Unsafe block | |
| 12906 | + child->children[child->len + 1] = sibling->children[0]; | |
| 12907 | + } | |
| 12908 | + } | |
| 12909 | + n->keys[builtin__v_fixed_index(idx, 11)] = sibling->keys[0]; | |
| 12910 | + n->values[builtin__v_fixed_index(idx, 11)] = sibling->values[0]; | |
| 12911 | + for (int i = 1; i < sibling->len; i++) { | |
| 12912 | + sibling->keys[builtin__v_fixed_index(i - 1, 11)] = sibling->keys[builtin__v_fixed_index(i, 11)]; | |
| 12913 | + sibling->values[builtin__v_fixed_index(i - 1, 11)] = sibling->values[builtin__v_fixed_index(i, 11)]; | |
| 12914 | + } | |
| 12915 | + if (sibling->children != ((void*)0)) { | |
| 12916 | + for (int i = 1; i <= sibling->len; i++) { | |
| 12917 | + { // Unsafe block | |
| 12918 | + sibling->children[i - 1] = sibling->children[i]; | |
| 12919 | + } | |
| 12920 | + } | |
| 12921 | + } | |
| 12922 | + child->len++; | |
| 12923 | + sibling->len--; | |
| 12924 | +} | |
| 12925 | +VV_LOC void builtin__mapnode_merge(mapnode* n, int idx) { | |
| 12926 | + mapnode* child = ((mapnode*)(n->children[idx])); | |
| 12927 | + mapnode* sibling = ((mapnode*)(n->children[idx + 1])); | |
| 12928 | + child->keys[builtin__v_fixed_index(_const_mid_index, 11)] = n->keys[builtin__v_fixed_index(idx, 11)]; | |
| 12929 | + child->values[builtin__v_fixed_index(_const_mid_index, 11)] = n->values[builtin__v_fixed_index(idx, 11)]; | |
| 12930 | + for (int i = 0; i < sibling->len; ++i) { | |
| 12931 | + child->keys[builtin__v_fixed_index(i + _const_degree, 11)] = sibling->keys[builtin__v_fixed_index(i, 11)]; | |
| 12932 | + child->values[builtin__v_fixed_index(i + _const_degree, 11)] = sibling->values[builtin__v_fixed_index(i, 11)]; | |
| 12933 | + } | |
| 12934 | + if (child->children != ((void*)0)) { | |
| 12935 | + for (int i = 0; i <= sibling->len; i++) { | |
| 12936 | + { // Unsafe block | |
| 12937 | + child->children[i + _const_degree] = sibling->children[i]; | |
| 12938 | + } | |
| 12939 | + } | |
| 12940 | + } | |
| 12941 | + for (int i = idx + 1; i < n->len; i++) { | |
| 12942 | + n->keys[builtin__v_fixed_index(i - 1, 11)] = n->keys[builtin__v_fixed_index(i, 11)]; | |
| 12943 | + n->values[builtin__v_fixed_index(i - 1, 11)] = n->values[builtin__v_fixed_index(i, 11)]; | |
| 12944 | + } | |
| 12945 | + for (int i = idx + 2; i <= n->len; i++) { | |
| 12946 | + { // Unsafe block | |
| 12947 | + n->children[i - 1] = n->children[i]; | |
| 12948 | + } | |
| 12949 | + } | |
| 12950 | + child->len += sibling->len + 1; | |
| 12951 | + n->len--; | |
| 12952 | +} | |
| 12953 | +void builtin__SortedMap_delete(SortedMap* m, string key) { | |
| 12954 | + if (m->root->len == 0) { | |
| 12955 | + return; | |
| 12956 | + } | |
| 12957 | + bool removed = builtin__mapnode_remove_key(m->root, key); | |
| 12958 | + if (removed) { | |
| 12959 | + m->len--; | |
| 12960 | + } | |
| 12961 | + if (m->root->len == 0) { | |
| 12962 | + if (m->root->children == ((void*)0)) { | |
| 12963 | + return; | |
| 12964 | + } else { | |
| 12965 | + m->root = ((mapnode*)(m->root->children[0])); | |
| 12966 | + } | |
| 12967 | + } | |
| 12968 | +} | |
| 12969 | +VV_LOC int builtin__mapnode_subkeys(mapnode* n, Array_string* keys, int at) { | |
| 12970 | + int position = at; | |
| 12971 | + if (n->children != ((void*)0)) { | |
| 12972 | + for (int i = 0; i < n->len; ++i) { | |
| 12973 | + mapnode* child = ((mapnode*)(n->children[i])); | |
| 12974 | + position += builtin__mapnode_subkeys(child, keys, position); | |
| 12975 | + builtin__array_set(keys, position, &(string[]) { n->keys[builtin__v_fixed_index(i, 11)] }); | |
| 12976 | + position++; | |
| 12977 | + } | |
| 12978 | + mapnode* child = ((mapnode*)(n->children[n->len])); | |
| 12979 | + position += builtin__mapnode_subkeys(child, keys, position); | |
| 12980 | + } else { | |
| 12981 | + for (int i = 0; i < n->len; ++i) { | |
| 12982 | + builtin__array_set(keys, (int)(position + i), &(string[]) { n->keys[builtin__v_fixed_index(i, 11)] }); | |
| 12983 | + } | |
| 12984 | + position += n->len; | |
| 12985 | + } | |
| 12986 | + return position - at; | |
| 12987 | +} | |
| 12988 | +Array_string builtin__SortedMap_keys(SortedMap* m) { | |
| 12989 | + Array_string keys = builtin____new_array_with_default(m->len, 0, sizeof(string), &(string[]){_S("")}); | |
| 12990 | + if (m->root == ((void*)0) || m->root->len == 0) { | |
| 12991 | + return keys; | |
| 12992 | + } | |
| 12993 | + builtin__mapnode_subkeys(m->root, &keys, 0); | |
| 12994 | + return keys; | |
| 12995 | +} | |
| 12996 | +VV_LOC void builtin__mapnode_free(mapnode* n) { | |
| 12997 | +} | |
| 12998 | +void builtin__SortedMap_free(SortedMap* m) { | |
| 12999 | + if (m->root == ((void*)0)) { | |
| 13000 | + return; | |
| 13001 | + } | |
| 13002 | + builtin__mapnode_free(m->root); | |
| 13003 | +} | |
| 13004 | +Array_rune builtin__string_runes(string s) { | |
| 13005 | + Array_rune runes = builtin____new_array_with_default(0, s.len, sizeof(rune), 0); | |
| 13006 | + for (int i = 0; i < s.len; i++) { | |
| 13007 | + multi_return_rune_int mr_2797 = builtin__utf8_decode_rune(&s.str[i], s.len - i); | |
| 13008 | + rune r = mr_2797.arg0; | |
| 13009 | + int char_len = mr_2797.arg1; | |
| 13010 | + builtin__array_push((array*)&runes, _MOV((rune[]){ r })); | |
| 13011 | + if (char_len > 1) { | |
| 13012 | + i += char_len - 1; | |
| 13013 | + } | |
| 13014 | + } | |
| 13015 | + return runes; | |
| 13016 | +} | |
| 13017 | +Array_string builtin__string_graphemes(string s) { | |
| 13018 | + return builtin__string_graphemes_impl(s); | |
| 13019 | +} | |
| 13020 | +string builtin__cstring_to_vstring(const char* const_s) { | |
| 13021 | + string s = builtin__tos2(((byteptr)(const_s))); | |
| 13022 | + return builtin__string_clone(s); | |
| 13023 | +} | |
| 13024 | +string builtin__tos_clone(const u8* const_s) { | |
| 13025 | + string s = builtin__tos2(((u8*)(const_s))); | |
| 13026 | + return builtin__string_clone(s); | |
| 13027 | +} | |
| 13028 | +string builtin__tos(u8* s, int len) { | |
| 13029 | + if (s == 0) { | |
| 13030 | + builtin___v_panic(_S("tos(): nil string")); | |
| 13031 | + VUNREACHABLE(); | |
| 13032 | + } | |
| 13033 | + return ((string){.str = s, .len = len}); | |
| 13034 | +} | |
| 13035 | +string builtin__tos2(u8* s) { | |
| 13036 | + if (s == 0) { | |
| 13037 | + builtin___v_panic(_S("tos2: nil string")); | |
| 13038 | + VUNREACHABLE(); | |
| 13039 | + } | |
| 13040 | + return ((string){.str = s, .len = builtin__vstrlen(s)}); | |
| 13041 | +} | |
| 13042 | +string builtin__tos3(char* s) { | |
| 13043 | + if (s == 0) { | |
| 13044 | + builtin___v_panic(_S("tos3: nil string")); | |
| 13045 | + VUNREACHABLE(); | |
| 13046 | + } | |
| 13047 | + return ((string){.str = ((u8*)(s)), .len = builtin__vstrlen_char(s)}); | |
| 13048 | +} | |
| 13049 | +string builtin__tos4(u8* s) { | |
| 13050 | + if (s == 0) { | |
| 13051 | + return _S(""); | |
| 13052 | + } | |
| 13053 | + return ((string){.str = s, .len = builtin__vstrlen(s)}); | |
| 13054 | +} | |
| 13055 | +string builtin__tos5(char* s) { | |
| 13056 | + if (s == 0) { | |
| 13057 | + return _S(""); | |
| 13058 | + } | |
| 13059 | + return ((string){.str = ((u8*)(s)), .len = builtin__vstrlen_char(s)}); | |
| 13060 | +} | |
| 13061 | +string builtin__u8_vstring(u8* bp) { | |
| 13062 | + return ((string){.str = bp, .len = builtin__vstrlen(bp)}); | |
| 13063 | +} | |
| 13064 | +string builtin__u8_vstring_with_len(u8* bp, int len) { | |
| 13065 | + return ((string){.str = bp, .len = len, .is_lit = 0}); | |
| 13066 | +} | |
| 13067 | +string builtin__char_vstring(char* cp) { | |
| 13068 | + return ((string){.str = ((u8*)(cp)), .len = builtin__vstrlen_char(cp), .is_lit = 0}); | |
| 13069 | +} | |
| 13070 | +string builtin__char_vstring_with_len(char* cp, int len) { | |
| 13071 | + return ((string){.str = ((u8*)(cp)), .len = len, .is_lit = 0}); | |
| 13072 | +} | |
| 13073 | +string builtin__u8_vstring_literal(u8* bp) { | |
| 13074 | + return ((string){.str = bp, .len = builtin__vstrlen(bp), .is_lit = 1}); | |
| 13075 | +} | |
| 13076 | +string builtin__u8_vstring_literal_with_len(u8* bp, int len) { | |
| 13077 | + return ((string){.str = bp, .len = len, .is_lit = 1}); | |
| 13078 | +} | |
| 13079 | +string builtin__char_vstring_literal(char* cp) { | |
| 13080 | + return ((string){.str = ((u8*)(cp)), .len = builtin__vstrlen_char(cp), .is_lit = 1}); | |
| 13081 | +} | |
| 13082 | +string builtin__char_vstring_literal_with_len(char* cp, int len) { | |
| 13083 | + return ((string){.str = ((u8*)(cp)), .len = len, .is_lit = 1}); | |
| 13084 | +} | |
| 13085 | +int builtin__string_len_utf8(string s) { | |
| 13086 | + int l = 0; | |
| 13087 | + int i = 0; | |
| 13088 | + for (;;) { | |
| 13089 | + if (!(i < s.len)) break; | |
| 13090 | + l++; | |
| 13091 | + i += ((int)((((v__rshift_u32(((u32)(0xe5000000U)), (u64)(((v__rshift_u8(s.str[i], (u64)3)) & 0x1e)))) & 3)) + 1)); | |
| 13092 | + } | |
| 13093 | + return l; | |
| 13094 | +} | |
| 13095 | +bool builtin__string_is_pure_ascii(string s) { | |
| 13096 | + for (int i = 0; i < s.len; ++i) { | |
| 13097 | + if (s.str[ i] >= 0x80) { | |
| 13098 | + return false; | |
| 13099 | + } | |
| 13100 | + } | |
| 13101 | + return true; | |
| 13102 | +} | |
| 13103 | +string builtin__string_clone(string a) { | |
| 13104 | + if (a.len <= 0) { | |
| 13105 | + return _S(""); | |
| 13106 | + } | |
| 13107 | + string _t2 = ((string){.str = builtin__malloc_noscan(a.len + 1), .len = a.len}); | |
| 13108 | + string b = _t2; | |
| 13109 | + { // Unsafe block | |
| 13110 | + builtin__vmemcpy(b.str, a.str, a.len); | |
| 13111 | + b.str[a.len] = 0; | |
| 13112 | + } | |
| 13113 | + return b; | |
| 13114 | +} | |
| 13115 | +string builtin__string_replace_once(string s, string rep, string with) { | |
| 13116 | + int idx = builtin__string_index_(s, rep); | |
| 13117 | + if (idx == -1) { | |
| 13118 | + return builtin__string_clone(s); | |
| 13119 | + } | |
| 13120 | + return builtin__string_plus_two(builtin__string_substr_unsafe(s, 0, idx), with, builtin__string_substr_unsafe(s, idx + rep.len, s.len)); | |
| 13121 | +} | |
| 13122 | +string builtin__string_replace(string s, string rep, string with) { | |
| 13123 | + if (s.len == 0 || rep.len == 0 || rep.len > s.len) { | |
| 13124 | + return builtin__string_clone(s); | |
| 13125 | + } | |
| 13126 | + if (!builtin__string_contains(s, rep)) { | |
| 13127 | + return builtin__string_clone(s); | |
| 13128 | + } | |
| 13129 | + int pidxs_len = 0; | |
| 13130 | + int pidxs_cap = VSAFE_DIV_int(s.len , rep.len); | |
| 13131 | + Array_fixed_int_10 stack_idxs = {0}; | |
| 13132 | + int* pidxs = &stack_idxs[0]; | |
| 13133 | + if (pidxs_cap > _const_replace_stack_buffer_size) { | |
| 13134 | + pidxs = ((int*)(builtin___v_malloc(((int)(sizeof(int))) * pidxs_cap))); | |
| 13135 | + } | |
| 13136 | + int idx = 0; | |
| 13137 | + for (;;) { | |
| 13138 | + idx = builtin__string_index_after_(s, rep, idx); | |
| 13139 | + if (idx == -1) { | |
| 13140 | + break; | |
| 13141 | + } | |
| 13142 | + { // Unsafe block | |
| 13143 | + pidxs[pidxs_len] = idx; | |
| 13144 | + pidxs_len++; | |
| 13145 | + } | |
| 13146 | + idx += rep.len; | |
| 13147 | + } | |
| 13148 | + if (pidxs_len == 0) { | |
| 13149 | + string _t3 = builtin__string_clone(s); | |
| 13150 | + { // defer begin | |
| 13151 | + if (pidxs_cap > _const_replace_stack_buffer_size) { | |
| 13152 | + builtin___v_free(pidxs); | |
| 13153 | + } | |
| 13154 | + } // defer end | |
| 13155 | + return _t3; | |
| 13156 | + } | |
| 13157 | + int new_len = s.len + pidxs_len * (with.len - rep.len); | |
| 13158 | + u8* b = builtin__malloc_noscan(new_len + 1); | |
| 13159 | + int b_i = 0; | |
| 13160 | + int s_idx = 0; | |
| 13161 | + for (int j = 0; j < pidxs_len; ++j) { | |
| 13162 | + int rep_pos = pidxs[j]; | |
| 13163 | + int before_len = rep_pos - s_idx; | |
| 13164 | + builtin__vmemcpy(&b[b_i], &s.str[s_idx], before_len); | |
| 13165 | + b_i += before_len; | |
| 13166 | + s_idx = rep_pos + rep.len; | |
| 13167 | + builtin__vmemcpy(&b[b_i], &with.str[0], with.len); | |
| 13168 | + b_i += with.len; | |
| 13169 | + } | |
| 13170 | + if (s_idx < s.len) { | |
| 13171 | + builtin__vmemcpy(&b[b_i], &s.str[s_idx], s.len - s_idx); | |
| 13172 | + } | |
| 13173 | + { // Unsafe block | |
| 13174 | + b[new_len] = 0; | |
| 13175 | + string _t4 = builtin__tos(b, new_len); | |
| 13176 | + { // defer begin | |
| 13177 | + if (pidxs_cap > _const_replace_stack_buffer_size) { | |
| 13178 | + builtin___v_free(pidxs); | |
| 13179 | + } | |
| 13180 | + } // defer end | |
| 13181 | + return _t4; | |
| 13182 | + } | |
| 13183 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 13184 | +} | |
| 13185 | +string builtin__string_replace_each(string s, Array_string vals) { | |
| 13186 | + if (s.len == 0 || vals.len == 0) { | |
| 13187 | + return builtin__string_clone(s); | |
| 13188 | + } | |
| 13189 | + if (VSAFE_MOD_int(vals.len , 2) != 0) { | |
| 13190 | + builtin__eprintln(_S("string.replace_each(): odd number of strings")); | |
| 13191 | + return builtin__string_clone(s); | |
| 13192 | + } | |
| 13193 | + int new_len = s.len; | |
| 13194 | + Array_RepIndex idxs = builtin____new_array_with_default(0, 6, sizeof(RepIndex), 0); | |
| 13195 | + int idx = 0; | |
| 13196 | + string s_ = builtin__string_clone(s); | |
| 13197 | + for (int rep_i = 0; rep_i < vals.len; rep_i += 2) { | |
| 13198 | + string rep = ((string*)vals.data)[rep_i]; | |
| 13199 | + string with = ((string*)vals.data)[rep_i + 1]; | |
| 13200 | + for (;;) { | |
| 13201 | + idx = builtin__string_index_after_(s_, rep, idx); | |
| 13202 | + if (idx == -1) { | |
| 13203 | + break; | |
| 13204 | + } | |
| 13205 | + for (int i = 0; i < rep.len; ++i) { | |
| 13206 | + { // Unsafe block | |
| 13207 | + s_.str[(int)(idx + i)] = 0; | |
| 13208 | + } | |
| 13209 | + } | |
| 13210 | + builtin__array_push((array*)&idxs, _MOV((RepIndex[]){ ((RepIndex){.idx = idx,.val_idx = rep_i,}) })); | |
| 13211 | + idx += rep.len; | |
| 13212 | + new_len += with.len - rep.len; | |
| 13213 | + } | |
| 13214 | + } | |
| 13215 | + if (idxs.len == 0) { | |
| 13216 | + string _t4 = builtin__string_clone(s); | |
| 13217 | + { // defer begin | |
| 13218 | + builtin__array_free(&idxs); | |
| 13219 | + } // defer end | |
| 13220 | + return _t4; | |
| 13221 | + } | |
| 13222 | + if (idxs.len > 0) { v_stable_sort(idxs.data, idxs.len, idxs.element_size, compare_11734835982493514523_RepIndex_by_idx_expr_612e6964780a3c0a622e696478_qsort_adapter); } | |
| 13223 | + ; | |
| 13224 | + u8* buf = builtin__malloc_noscan(new_len + 1); | |
| 13225 | + int idx_pos = 0; | |
| 13226 | + RepIndex cur_idx = ((RepIndex*)idxs.data)[idx_pos]; | |
| 13227 | + int buf_i = 0; | |
| 13228 | + for (int i = 0; i < s.len; i++) { | |
| 13229 | + if (i == cur_idx.idx) { | |
| 13230 | + string rep = ((string*)vals.data)[cur_idx.val_idx]; | |
| 13231 | + string with = ((string*)vals.data)[cur_idx.val_idx + 1]; | |
| 13232 | + for (int j = 0; j < with.len; ++j) { | |
| 13233 | + { // Unsafe block | |
| 13234 | + buf[buf_i] = with.str[ j]; | |
| 13235 | + } | |
| 13236 | + buf_i++; | |
| 13237 | + } | |
| 13238 | + i += rep.len - 1; | |
| 13239 | + idx_pos++; | |
| 13240 | + if (idx_pos < idxs.len) { | |
| 13241 | + cur_idx = ((RepIndex*)idxs.data)[idx_pos]; | |
| 13242 | + } | |
| 13243 | + } else { | |
| 13244 | + { // Unsafe block | |
| 13245 | + buf[buf_i] = s.str[i]; | |
| 13246 | + } | |
| 13247 | + buf_i++; | |
| 13248 | + } | |
| 13249 | + } | |
| 13250 | + { // Unsafe block | |
| 13251 | + buf[new_len] = 0; | |
| 13252 | + string _t5 = builtin__tos(buf, new_len); | |
| 13253 | + { // defer begin | |
| 13254 | + builtin__array_free(&idxs); | |
| 13255 | + } // defer end | |
| 13256 | + return _t5; | |
| 13257 | + } | |
| 13258 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 13259 | +} | |
| 13260 | +string builtin__string_format(string s, Array_string args) { | |
| 13261 | + if (s.len == 0) { | |
| 13262 | + return _S(""); | |
| 13263 | + } | |
| 13264 | + strings__Builder out = strings__new_builder(s.len); | |
| 13265 | + int i = 0; | |
| 13266 | + for (;;) { | |
| 13267 | + if (!(i < s.len)) break; | |
| 13268 | + u8 ch = s.str[ i]; | |
| 13269 | + if (ch == '{') { | |
| 13270 | + if (i + 1 < s.len && s.str[ i + 1] == '{') { | |
| 13271 | + strings__Builder_write_byte(&out, '{'); | |
| 13272 | + i += 2; | |
| 13273 | + continue; | |
| 13274 | + } | |
| 13275 | + int j = i + 1; | |
| 13276 | + if (j >= s.len || !builtin__u8_is_digit(s.str[ j])) { | |
| 13277 | + strings__Builder_write_byte(&out, ch); | |
| 13278 | + i++; | |
| 13279 | + continue; | |
| 13280 | + } | |
| 13281 | + int idx = 0; | |
| 13282 | + bool overflowed = false; | |
| 13283 | + for (;;) { | |
| 13284 | + if (!(j < s.len && builtin__u8_is_digit(s.str[ j]))) break; | |
| 13285 | + int digit = ((int)((rune)(s.str[ j] - '0'))); | |
| 13286 | + if (idx > VSAFE_DIV_int((_const_max_int - digit) , 10)) { | |
| 13287 | + overflowed = true; | |
| 13288 | + break; | |
| 13289 | + } | |
| 13290 | + idx = idx * 10 + digit; | |
| 13291 | + j++; | |
| 13292 | + } | |
| 13293 | + if (!overflowed && j < s.len && s.str[ j] == '}') { | |
| 13294 | + if (idx < args.len) { | |
| 13295 | + strings__Builder_write_string(&out, ((string*)args.data)[idx]); | |
| 13296 | + } else { | |
| 13297 | + strings__Builder_write_string(&out, builtin__string_substr(s, i, j + 1)); | |
| 13298 | + } | |
| 13299 | + i = j + 1; | |
| 13300 | + continue; | |
| 13301 | + } | |
| 13302 | + strings__Builder_write_byte(&out, ch); | |
| 13303 | + i++; | |
| 13304 | + continue; | |
| 13305 | + } | |
| 13306 | + if (ch == '}' && i + 1 < s.len && s.str[ i + 1] == '}') { | |
| 13307 | + strings__Builder_write_byte(&out, '}'); | |
| 13308 | + i += 2; | |
| 13309 | + continue; | |
| 13310 | + } | |
| 13311 | + strings__Builder_write_byte(&out, ch); | |
| 13312 | + i++; | |
| 13313 | + } | |
| 13314 | + return strings__Builder_str(&out); | |
| 13315 | +} | |
| 13316 | +string builtin__string_replace_char(string s, u8 rep, u8 with, int repeat) { | |
| 13317 | + #if 1 | |
| 13318 | + { | |
| 13319 | + if (repeat <= 0) { | |
| 13320 | + builtin___v_panic(_S("string.replace_char(): tab length too short")); | |
| 13321 | + VUNREACHABLE(); | |
| 13322 | + } | |
| 13323 | + } | |
| 13324 | + #endif | |
| 13325 | + if (s.len == 0) { | |
| 13326 | + return builtin__string_clone(s); | |
| 13327 | + } | |
| 13328 | + Array_int idxs = builtin____new_array_with_default(0, v__rshift_int(s.len, (u64)2), sizeof(int), 0); | |
| 13329 | + for (int i = 0; i < s.len; ++i) { | |
| 13330 | + u8 ch = s.str[i]; | |
| 13331 | + if (ch == rep) { | |
| 13332 | + builtin__array_push((array*)&idxs, _MOV((int[]){ i })); | |
| 13333 | + } | |
| 13334 | + } | |
| 13335 | + if (idxs.len == 0) { | |
| 13336 | + string _t4 = builtin__string_clone(s); | |
| 13337 | + { // defer begin | |
| 13338 | + builtin__array_free(&idxs); | |
| 13339 | + } // defer end | |
| 13340 | + return _t4; | |
| 13341 | + } | |
| 13342 | + int new_len = s.len + idxs.len * (repeat - 1); | |
| 13343 | + u8* b = builtin__malloc_noscan(new_len + 1); | |
| 13344 | + int b_i = 0; | |
| 13345 | + int s_idx = 0; | |
| 13346 | + for (int _t5 = 0; _t5 < idxs.len; ++_t5) { | |
| 13347 | + int rep_pos = ((int*)idxs.data)[_t5]; | |
| 13348 | + for (int i = s_idx; i < rep_pos; ++i) { | |
| 13349 | + { // Unsafe block | |
| 13350 | + b[b_i] = s.str[ i]; | |
| 13351 | + } | |
| 13352 | + b_i++; | |
| 13353 | + } | |
| 13354 | + s_idx = rep_pos + 1; | |
| 13355 | + for (int _t6 = 0; _t6 < repeat; ++_t6) { | |
| 13356 | + { // Unsafe block | |
| 13357 | + b[b_i] = with; | |
| 13358 | + } | |
| 13359 | + b_i++; | |
| 13360 | + } | |
| 13361 | + } | |
| 13362 | + if (s_idx < s.len) { | |
| 13363 | + for (int i = s_idx; i < s.len; ++i) { | |
| 13364 | + { // Unsafe block | |
| 13365 | + b[b_i] = s.str[ i]; | |
| 13366 | + } | |
| 13367 | + b_i++; | |
| 13368 | + } | |
| 13369 | + } | |
| 13370 | + { // Unsafe block | |
| 13371 | + b[new_len] = 0; | |
| 13372 | + string _t7 = builtin__tos(b, new_len); | |
| 13373 | + { // defer begin | |
| 13374 | + builtin__array_free(&idxs); | |
| 13375 | + } // defer end | |
| 13376 | + return _t7; | |
| 13377 | + } | |
| 13378 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 13379 | +} | |
| 13380 | +inline string builtin__string_normalize_tabs(string s, int tab_len) { | |
| 13381 | + return builtin__string_replace_char(s, '\t', ' ', tab_len); | |
| 13382 | +} | |
| 13383 | +string builtin__string_expand_tabs(string s, int tab_len) { | |
| 13384 | + if (tab_len <= 0) { | |
| 13385 | + return builtin__string_clone(s); | |
| 13386 | + } | |
| 13387 | + strings__Builder output = strings__new_builder(s.len); | |
| 13388 | + int column = 0; | |
| 13389 | + RunesIterator _t2 = builtin__string_runes_iterator(s); | |
| 13390 | + while (1) { | |
| 13391 | + _option_rune _t3 = builtin__RunesIterator_next(&_t2); | |
| 13392 | + if (_t3.state != 0) break; | |
| 13393 | + rune r = *(rune*)_t3.data; | |
| 13394 | + | |
| 13395 | + if (r == ('\t')) { | |
| 13396 | + int spaces = tab_len - (VSAFE_MOD_int(column , tab_len)); | |
| 13397 | + strings__Builder_write_string(&output, builtin__string_repeat(_S(" "), spaces)); | |
| 13398 | + column += spaces; | |
| 13399 | + } | |
| 13400 | + else if (r == ('\n') || r == ('\r')) { | |
| 13401 | + strings__Builder_write_rune(&output, r); | |
| 13402 | + column = 0; | |
| 13403 | + } | |
| 13404 | + else { | |
| 13405 | + strings__Builder_write_rune(&output, r); | |
| 13406 | + column++; | |
| 13407 | + } | |
| 13408 | + } | |
| 13409 | + return strings__Builder_str(&output); | |
| 13410 | +} | |
| 13411 | +inline bool builtin__string_bool(string s) { | |
| 13412 | + return _SLIT_EQ(s.str, s.len, "true") || _SLIT_EQ(s.str, s.len, "t"); | |
| 13413 | +} | |
| 13414 | +inline i8 builtin__string_i8(string s) { | |
| 13415 | + _result_i64 _t2 = strconv__common_parse_int(s, 0, 8, false, false); | |
| 13416 | + if (_t2.is_error) { | |
| 13417 | + *(i64*) _t2.data = 0; | |
| 13418 | + } | |
| 13419 | + | |
| 13420 | + return ((i8)((*(i64*)_t2.data))); | |
| 13421 | +} | |
| 13422 | +inline i16 builtin__string_i16(string s) { | |
| 13423 | + _result_i64 _t2 = strconv__common_parse_int(s, 0, 16, false, false); | |
| 13424 | + if (_t2.is_error) { | |
| 13425 | + *(i64*) _t2.data = 0; | |
| 13426 | + } | |
| 13427 | + | |
| 13428 | + return ((i16)((*(i64*)_t2.data))); | |
| 13429 | +} | |
| 13430 | +inline i32 builtin__string_i32(string s) { | |
| 13431 | + _result_i64 _t2 = strconv__common_parse_int(s, 0, 32, false, false); | |
| 13432 | + if (_t2.is_error) { | |
| 13433 | + *(i64*) _t2.data = 0; | |
| 13434 | + } | |
| 13435 | + | |
| 13436 | + return ((i32)((*(i64*)_t2.data))); | |
| 13437 | +} | |
| 13438 | +inline int builtin__string_int(string s) { | |
| 13439 | + _result_i64 _t2 = strconv__common_parse_int(s, 0, 32, false, false); | |
| 13440 | + if (_t2.is_error) { | |
| 13441 | + *(i64*) _t2.data = 0; | |
| 13442 | + } | |
| 13443 | + | |
| 13444 | + return ((int)((*(i64*)_t2.data))); | |
| 13445 | +} | |
| 13446 | +inline i64 builtin__string_i64(string s) { | |
| 13447 | + _result_i64 _t2 = strconv__common_parse_int(s, 0, 64, false, false); | |
| 13448 | + if (_t2.is_error) { | |
| 13449 | + *(i64*) _t2.data = 0; | |
| 13450 | + } | |
| 13451 | + | |
| 13452 | + return (*(i64*)_t2.data); | |
| 13453 | +} | |
| 13454 | +inline f32 builtin__string_f32(string s) { | |
| 13455 | + _result_f64 _t2 = strconv__atof64(s, ((strconv__AtoF64Param){.allow_extra_chars = true,})); | |
| 13456 | + if (_t2.is_error) { | |
| 13457 | + *(f64*) _t2.data = 0; | |
| 13458 | + } | |
| 13459 | + | |
| 13460 | + return ((f32)((*(f64*)_t2.data))); | |
| 13461 | +} | |
| 13462 | +inline f64 builtin__string_f64(string s) { | |
| 13463 | + _result_f64 _t2 = strconv__atof64(s, ((strconv__AtoF64Param){.allow_extra_chars = true,})); | |
| 13464 | + if (_t2.is_error) { | |
| 13465 | + *(f64*) _t2.data = 0; | |
| 13466 | + } | |
| 13467 | + | |
| 13468 | + return (*(f64*)_t2.data); | |
| 13469 | +} | |
| 13470 | +Array_u8 builtin__string_u8_array(string s) { | |
| 13471 | + string tmps = builtin__string_replace(s, _S("_"), _S("")); | |
| 13472 | + if (tmps.len == 0) { | |
| 13473 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | |
| 13474 | + } | |
| 13475 | + tmps = builtin__string_to_lower_ascii(tmps); | |
| 13476 | + if (builtin__string_starts_with(tmps, _S("0x"))) { | |
| 13477 | + tmps = builtin__string_substr(tmps, 2, 2147483647); | |
| 13478 | + if (tmps.len == 0) { | |
| 13479 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | |
| 13480 | + } | |
| 13481 | + if (!builtin__string_contains_only(tmps, _S("0123456789abcdef"))) { | |
| 13482 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | |
| 13483 | + } | |
| 13484 | + if (VSAFE_MOD_int(tmps.len , 2) == 1) { | |
| 13485 | + tmps = builtin__string__plus(_S("0"), tmps); | |
| 13486 | + } | |
| 13487 | + Array_u8 ret = builtin____new_array_with_default(VSAFE_DIV_int(tmps.len , 2), 0, sizeof(u8), 0); | |
| 13488 | + for (int i = 0; i < ret.len; ++i) { | |
| 13489 | + _result_u64 _t4 = builtin__string_parse_uint(builtin__string_substr(tmps, 2 * i, 2 * i + 2), 16, 8); | |
| 13490 | + if (_t4.is_error) { | |
| 13491 | + *(u64*) _t4.data = 0; | |
| 13492 | + } | |
| 13493 | + | |
| 13494 | + builtin__array_set(&ret, i, &(u8[]) { ((u8)((*(u64*)_t4.data))) }); | |
| 13495 | + } | |
| 13496 | + return ret; | |
| 13497 | + } else if (builtin__string_starts_with(tmps, _S("0b"))) { | |
| 13498 | + tmps = builtin__string_substr(tmps, 2, 2147483647); | |
| 13499 | + if (tmps.len == 0) { | |
| 13500 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | |
| 13501 | + } | |
| 13502 | + if (!builtin__string_contains_only(tmps, _S("01"))) { | |
| 13503 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | |
| 13504 | + } | |
| 13505 | + if (VSAFE_MOD_int(tmps.len , 8) != 0) { | |
| 13506 | + tmps = builtin__string__plus(builtin__string_repeat(_S("0"), 8 - VSAFE_MOD_int(tmps.len , 8)), tmps); | |
| 13507 | + } | |
| 13508 | + Array_u8 ret = builtin____new_array_with_default(VSAFE_DIV_int(tmps.len , 8), 0, sizeof(u8), 0); | |
| 13509 | + for (int i = 0; i < ret.len; ++i) { | |
| 13510 | + _result_u64 _t8 = builtin__string_parse_uint(builtin__string_substr(tmps, 8 * i, 8 * i + 8), 2, 8); | |
| 13511 | + if (_t8.is_error) { | |
| 13512 | + *(u64*) _t8.data = 0; | |
| 13513 | + } | |
| 13514 | + | |
| 13515 | + builtin__array_set(&ret, i, &(u8[]) { ((u8)((*(u64*)_t8.data))) }); | |
| 13516 | + } | |
| 13517 | + return ret; | |
| 13518 | + } | |
| 13519 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | |
| 13520 | +} | |
| 13521 | +inline u8 builtin__string_u8(string s) { | |
| 13522 | + _result_u64 _t2 = strconv__common_parse_uint(s, 0, 8, false, false); | |
| 13523 | + if (_t2.is_error) { | |
| 13524 | + *(u64*) _t2.data = 0; | |
| 13525 | + } | |
| 13526 | + | |
| 13527 | + return ((u8)((*(u64*)_t2.data))); | |
| 13528 | +} | |
| 13529 | +inline u16 builtin__string_u16(string s) { | |
| 13530 | + _result_u64 _t2 = strconv__common_parse_uint(s, 0, 16, false, false); | |
| 13531 | + if (_t2.is_error) { | |
| 13532 | + *(u64*) _t2.data = 0; | |
| 13533 | + } | |
| 13534 | + | |
| 13535 | + return ((u16)((*(u64*)_t2.data))); | |
| 13536 | +} | |
| 13537 | +inline u32 builtin__string_u32(string s) { | |
| 13538 | + _result_u64 _t2 = strconv__common_parse_uint(s, 0, 32, false, false); | |
| 13539 | + if (_t2.is_error) { | |
| 13540 | + *(u64*) _t2.data = 0; | |
| 13541 | + } | |
| 13542 | + | |
| 13543 | + return ((u32)((*(u64*)_t2.data))); | |
| 13544 | +} | |
| 13545 | +inline u64 builtin__string_u64(string s) { | |
| 13546 | + _result_u64 _t2 = strconv__common_parse_uint(s, 0, 64, false, false); | |
| 13547 | + if (_t2.is_error) { | |
| 13548 | + *(u64*) _t2.data = 0; | |
| 13549 | + } | |
| 13550 | + | |
| 13551 | + return (*(u64*)_t2.data); | |
| 13552 | +} | |
| 13553 | +inline _result_u64 builtin__string_parse_uint(string s, int _base, int _bit_size) { | |
| 13554 | + return strconv__parse_uint(s, _base, _bit_size); | |
| 13555 | +} | |
| 13556 | +inline _result_i64 builtin__string_parse_int(string s, int _base, int _bit_size) { | |
| 13557 | + return strconv__parse_int(s, _base, _bit_size); | |
| 13558 | +} | |
| 13559 | +VV_LOC bool builtin__string__eq(string s, string a) { | |
| 13560 | + if (s.str == 0) { | |
| 13561 | + return a.str == 0 || a.len == 0; | |
| 13562 | + } | |
| 13563 | + if (s.len != a.len) { | |
| 13564 | + return false; | |
| 13565 | + } | |
| 13566 | + { // Unsafe block | |
| 13567 | + return builtin__vmemcmp(s.str, a.str, a.len) == 0; | |
| 13568 | + } | |
| 13569 | + return 0; | |
| 13570 | +} | |
| 13571 | +int builtin__string_compare(string s, string a) { | |
| 13572 | + int min_len = (s.len < a.len ? (s.len) : (a.len)); | |
| 13573 | + for (int i = 0; i < min_len; ++i) { | |
| 13574 | + if (s.str[ i] < a.str[ i]) { | |
| 13575 | + return -1; | |
| 13576 | + } | |
| 13577 | + if (s.str[ i] > a.str[ i]) { | |
| 13578 | + return 1; | |
| 13579 | + } | |
| 13580 | + } | |
| 13581 | + if (s.len < a.len) { | |
| 13582 | + return -1; | |
| 13583 | + } | |
| 13584 | + if (s.len > a.len) { | |
| 13585 | + return 1; | |
| 13586 | + } | |
| 13587 | + return 0; | |
| 13588 | +} | |
| 13589 | +VV_LOC bool builtin__string__lt(string s, string a) { | |
| 13590 | + for (int i = 0; i < s.len; ++i) { | |
| 13591 | + if (i >= a.len || s.str[ i] > a.str[ i]) { | |
| 13592 | + return false; | |
| 13593 | + } else if (s.str[ i] < a.str[ i]) { | |
| 13594 | + return true; | |
| 13595 | + } | |
| 13596 | + } | |
| 13597 | + if (s.len < a.len) { | |
| 13598 | + return true; | |
| 13599 | + } | |
| 13600 | + return false; | |
| 13601 | +} | |
| 13602 | +VV_LOC string builtin__string__plus(string s, string a) { | |
| 13603 | + int slen = (s.len > 0 ? (s.len) : (0)); | |
| 13604 | + int alen = (a.len > 0 ? (a.len) : (0)); | |
| 13605 | + int new_len = alen + slen; | |
| 13606 | + string _t1 = ((string){.str = builtin__malloc_noscan(new_len + 1), .len = new_len}); | |
| 13607 | + string res = _t1; | |
| 13608 | + { // Unsafe block | |
| 13609 | + if (slen > 0) { | |
| 13610 | + builtin__vmemcpy(res.str, s.str, slen); | |
| 13611 | + } | |
| 13612 | + if (alen > 0) { | |
| 13613 | + builtin__vmemcpy(res.str + slen, a.str, alen); | |
| 13614 | + } | |
| 13615 | + res.str[new_len] = 0; | |
| 13616 | + } | |
| 13617 | + return res; | |
| 13618 | +} | |
| 13619 | +VV_LOC string builtin__string_plus_many(int data_len, string* input_base) { | |
| 13620 | + int new_len = 0; | |
| 13621 | + for (int i = 0; i < data_len; i++) { | |
| 13622 | + string part = input_base[i]; | |
| 13623 | + new_len += (part.len > 0 ? (part.len) : (0)); | |
| 13624 | + } | |
| 13625 | + string _t1 = ((string){.str = builtin__malloc_noscan(new_len + 1), .len = new_len}); | |
| 13626 | + string res = _t1; | |
| 13627 | + int offset = 0; | |
| 13628 | + { // Unsafe block | |
| 13629 | + for (int i = 0; i < data_len; i++) { | |
| 13630 | + string part = input_base[i]; | |
| 13631 | + int part_len = (part.len > 0 ? (part.len) : (0)); | |
| 13632 | + if (part_len > 0) { | |
| 13633 | + builtin__vmemcpy(res.str + offset, part.str, part_len); | |
| 13634 | + offset += part_len; | |
| 13635 | + } | |
| 13636 | + } | |
| 13637 | + res.str[new_len] = 0; | |
| 13638 | + } | |
| 13639 | + return res; | |
| 13640 | +} | |
| 13641 | +VV_LOC string builtin__string_plus_two(string s, string a, string b) { | |
| 13642 | + int slen = (s.len > 0 ? (s.len) : (0)); | |
| 13643 | + int alen = (a.len > 0 ? (a.len) : (0)); | |
| 13644 | + int blen = (b.len > 0 ? (b.len) : (0)); | |
| 13645 | + int new_len = alen + blen + slen; | |
| 13646 | + string _t1 = ((string){.str = builtin__malloc_noscan(new_len + 1), .len = new_len}); | |
| 13647 | + string res = _t1; | |
| 13648 | + { // Unsafe block | |
| 13649 | + if (slen > 0) { | |
| 13650 | + builtin__vmemcpy(res.str, s.str, slen); | |
| 13651 | + } | |
| 13652 | + if (alen > 0) { | |
| 13653 | + builtin__vmemcpy(res.str + slen, a.str, alen); | |
| 13654 | + } | |
| 13655 | + if (blen > 0) { | |
| 13656 | + builtin__vmemcpy(res.str + slen + alen, b.str, blen); | |
| 13657 | + } | |
| 13658 | + res.str[new_len] = 0; | |
| 13659 | + } | |
| 13660 | + return res; | |
| 13661 | +} | |
| 13662 | +Array_string builtin__string_split_any(string s, string delim) { | |
| 13663 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | |
| 13664 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | |
| 13665 | + int i = 0; | |
| 13666 | + if (s.len > 0) { | |
| 13667 | + if (delim.len <= 0) { | |
| 13668 | + Array_string _t1 = builtin__string_split(s, _S("")); | |
| 13669 | + { // defer begin | |
| 13670 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | |
| 13671 | + } // defer end | |
| 13672 | + return _t1; | |
| 13673 | + } | |
| 13674 | + for (int index = 0; index < s.len; ++index) { | |
| 13675 | + u8 ch = s.str[index]; | |
| 13676 | + for (int _t2 = 0; _t2 < delim.len; ++_t2) { | |
| 13677 | + u8 delim_ch = delim.str[_t2]; | |
| 13678 | + if (ch == delim_ch) { | |
| 13679 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, i, index) })); | |
| 13680 | + i = index + 1; | |
| 13681 | + break; | |
| 13682 | + } | |
| 13683 | + } | |
| 13684 | + } | |
| 13685 | + if (i < s.len) { | |
| 13686 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, i, 2147483647) })); | |
| 13687 | + } | |
| 13688 | + } | |
| 13689 | + Array_string _t5 = res; | |
| 13690 | + { // defer begin | |
| 13691 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | |
| 13692 | + } // defer end | |
| 13693 | + return _t5; | |
| 13694 | +} | |
| 13695 | +Array_string builtin__string_rsplit_any(string s, string delim) { | |
| 13696 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | |
| 13697 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | |
| 13698 | + int i = s.len - 1; | |
| 13699 | + if (s.len > 0) { | |
| 13700 | + if (delim.len <= 0) { | |
| 13701 | + Array_string _t1 = builtin__string_rsplit(s, _S("")); | |
| 13702 | + { // defer begin | |
| 13703 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | |
| 13704 | + } // defer end | |
| 13705 | + return _t1; | |
| 13706 | + } | |
| 13707 | + int rbound = s.len; | |
| 13708 | + for (;;) { | |
| 13709 | + if (!(i >= 0)) break; | |
| 13710 | + for (int _t2 = 0; _t2 < delim.len; ++_t2) { | |
| 13711 | + u8 delim_ch = delim.str[_t2]; | |
| 13712 | + if (s.str[ i] == delim_ch) { | |
| 13713 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, i + 1, rbound) })); | |
| 13714 | + rbound = i; | |
| 13715 | + break; | |
| 13716 | + } | |
| 13717 | + } | |
| 13718 | + i--; | |
| 13719 | + } | |
| 13720 | + if (rbound > 0) { | |
| 13721 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, 0, rbound) })); | |
| 13722 | + } | |
| 13723 | + } | |
| 13724 | + Array_string _t5 = res; | |
| 13725 | + { // defer begin | |
| 13726 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | |
| 13727 | + } // defer end | |
| 13728 | + return _t5; | |
| 13729 | +} | |
| 13730 | +inline Array_string builtin__string_split(string s, string delim) { | |
| 13731 | + return builtin__string_split_nth(s, delim, 0); | |
| 13732 | +} | |
| 13733 | +inline Array_string builtin__string_rsplit(string s, string delim) { | |
| 13734 | + return builtin__string_rsplit_nth(s, delim, 0); | |
| 13735 | +} | |
| 13736 | +_option_multi_return_string_string builtin__string_split_once(string s, string delim) { | |
| 13737 | + Array_string result = builtin__string_split_nth(s, delim, 2); | |
| 13738 | + if (result.len != 2) { | |
| 13739 | + _option_multi_return_string_string _t1 = (_option_multi_return_string_string){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | |
| 13740 | + return _t1; | |
| 13741 | + } | |
| 13742 | + _option_multi_return_string_string _t2; | |
| 13743 | + builtin___option_ok(&(multi_return_string_string[]) { (multi_return_string_string){.arg0=(*(string*)builtin__array_get(result, 0)), .arg1=(*(string*)builtin__array_get(result, 1))} }, (_option*)(&_t2), sizeof(multi_return_string_string)); | |
| 13744 | + return _t2; | |
| 13745 | +} | |
| 13746 | +_option_multi_return_string_string builtin__string_rsplit_once(string s, string delim) { | |
| 13747 | + Array_string result = builtin__string_rsplit_nth(s, delim, 2); | |
| 13748 | + if (result.len != 2) { | |
| 13749 | + _option_multi_return_string_string _t1 = (_option_multi_return_string_string){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | |
| 13750 | + return _t1; | |
| 13751 | + } | |
| 13752 | + _option_multi_return_string_string _t2; | |
| 13753 | + builtin___option_ok(&(multi_return_string_string[]) { (multi_return_string_string){.arg0=(*(string*)builtin__array_get(result, 1)), .arg1=(*(string*)builtin__array_get(result, 0))} }, (_option*)(&_t2), sizeof(multi_return_string_string)); | |
| 13754 | + return _t2; | |
| 13755 | +} | |
| 13756 | +Array_string builtin__string_split_n(string s, string delim, int n) { | |
| 13757 | + return builtin__string_split_nth(s, delim, n); | |
| 13758 | +} | |
| 13759 | +Array_string builtin__string_split_nth(string s, string delim, int nth) { | |
| 13760 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | |
| 13761 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | |
| 13762 | + switch (delim.len) { | |
| 13763 | + case 0: { | |
| 13764 | + for (int i = 0; i < s.len; ++i) { | |
| 13765 | + u8 ch = s.str[i]; | |
| 13766 | + if (nth > 0 && res.len == nth - 1) { | |
| 13767 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, i, 2147483647) })); | |
| 13768 | + break; | |
| 13769 | + } | |
| 13770 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__u8_ascii_str(ch) })); | |
| 13771 | + } | |
| 13772 | + break; | |
| 13773 | + } | |
| 13774 | + case 1: { | |
| 13775 | + u8 delim_byte = delim.str[ 0]; | |
| 13776 | + int start = 0; | |
| 13777 | + for (int i = 0; i < s.len; ++i) { | |
| 13778 | + u8 ch = s.str[i]; | |
| 13779 | + if (ch == delim_byte) { | |
| 13780 | + if (nth > 0 && res.len == nth - 1) { | |
| 13781 | + break; | |
| 13782 | + } | |
| 13783 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, start, i) })); | |
| 13784 | + start = i + 1; | |
| 13785 | + } | |
| 13786 | + } | |
| 13787 | + if (nth < 1 || res.len < nth) { | |
| 13788 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, start, 2147483647) })); | |
| 13789 | + } | |
| 13790 | + break; | |
| 13791 | + } | |
| 13792 | + default: { | |
| 13793 | + { | |
| 13794 | + int start = 0; | |
| 13795 | + for (int i = 0; i + delim.len <= s.len; ) { | |
| 13796 | + if (builtin__string__eq(builtin__string_substr_unsafe(s, i, i + delim.len), delim)) { | |
| 13797 | + if (nth > 0 && res.len == nth - 1) { | |
| 13798 | + break; | |
| 13799 | + } | |
| 13800 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, start, i) })); | |
| 13801 | + i += delim.len; | |
| 13802 | + start = i; | |
| 13803 | + } else { | |
| 13804 | + i++; | |
| 13805 | + } | |
| 13806 | + } | |
| 13807 | + if (nth < 1 || res.len < nth) { | |
| 13808 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, start, 2147483647) })); | |
| 13809 | + } | |
| 13810 | + break; | |
| 13811 | + } | |
| 13812 | + } | |
| 13813 | + } | |
| 13814 | + | |
| 13815 | + Array_string _t7 = res; | |
| 13816 | + { // defer begin | |
| 13817 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | |
| 13818 | + } // defer end | |
| 13819 | + return _t7; | |
| 13820 | +} | |
| 13821 | +Array_string builtin__string_rsplit_nth(string s, string delim, int nth) { | |
| 13822 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | |
| 13823 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | |
| 13824 | + switch (delim.len) { | |
| 13825 | + case 0: { | |
| 13826 | + for (int i = s.len - 1; i >= 0; i--) { | |
| 13827 | + if (nth > 0 && res.len == nth - 1) { | |
| 13828 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, 0, i + 1) })); | |
| 13829 | + break; | |
| 13830 | + } | |
| 13831 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__u8_ascii_str(s.str[ i]) })); | |
| 13832 | + } | |
| 13833 | + break; | |
| 13834 | + } | |
| 13835 | + case 1: { | |
| 13836 | + u8 delim_byte = delim.str[ 0]; | |
| 13837 | + int rbound = s.len; | |
| 13838 | + for (int i = s.len - 1; i >= 0; i--) { | |
| 13839 | + if (s.str[ i] == delim_byte) { | |
| 13840 | + if (nth > 0 && res.len == nth - 1) { | |
| 13841 | + break; | |
| 13842 | + } | |
| 13843 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, i + 1, rbound) })); | |
| 13844 | + rbound = i; | |
| 13845 | + } | |
| 13846 | + } | |
| 13847 | + if (nth < 1 || res.len < nth) { | |
| 13848 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, 0, rbound) })); | |
| 13849 | + } | |
| 13850 | + break; | |
| 13851 | + } | |
| 13852 | + default: { | |
| 13853 | + { | |
| 13854 | + int rbound = s.len; | |
| 13855 | + for (int i = s.len - 1; i >= 0; i--) { | |
| 13856 | + bool is_delim = i - delim.len >= 0 && builtin__string__eq(builtin__string_substr(s, i - delim.len, i), delim); | |
| 13857 | + if (is_delim) { | |
| 13858 | + if (nth > 0 && res.len == nth - 1) { | |
| 13859 | + break; | |
| 13860 | + } | |
| 13861 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, i, rbound) })); | |
| 13862 | + i -= delim.len; | |
| 13863 | + rbound = i; | |
| 13864 | + } | |
| 13865 | + } | |
| 13866 | + if (nth < 1 || res.len < nth) { | |
| 13867 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, 0, rbound) })); | |
| 13868 | + } | |
| 13869 | + break; | |
| 13870 | + } | |
| 13871 | + } | |
| 13872 | + } | |
| 13873 | + | |
| 13874 | + Array_string _t7 = res; | |
| 13875 | + { // defer begin | |
| 13876 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | |
| 13877 | + } // defer end | |
| 13878 | + return _t7; | |
| 13879 | +} | |
| 13880 | +Array_string builtin__string_split_into_lines(string s) { | |
| 13881 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | |
| 13882 | + if (s.len == 0) { | |
| 13883 | + return res; | |
| 13884 | + } | |
| 13885 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | |
| 13886 | + rune cr = '\r'; | |
| 13887 | + rune lf = '\n'; | |
| 13888 | + int line_start = 0; | |
| 13889 | + for (int i = 0; i < s.len; i++) { | |
| 13890 | + if (line_start <= i) { | |
| 13891 | + if (s.str[ i] == lf) { | |
| 13892 | + builtin__array_push((array*)&res, _MOV((string[]){ (line_start == i ? (_S("")) : (builtin__string_substr(s, line_start, i))) })); | |
| 13893 | + line_start = i + 1; | |
| 13894 | + } else if (s.str[ i] == cr) { | |
| 13895 | + builtin__array_push((array*)&res, _MOV((string[]){ (line_start == i ? (_S("")) : (builtin__string_substr(s, line_start, i))) })); | |
| 13896 | + if ((i + 1) < s.len && s.str[ i + 1] == lf) { | |
| 13897 | + line_start = i + 2; | |
| 13898 | + } else { | |
| 13899 | + line_start = i + 1; | |
| 13900 | + } | |
| 13901 | + } | |
| 13902 | + } | |
| 13903 | + } | |
| 13904 | + if (line_start < s.len) { | |
| 13905 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, line_start, 2147483647) })); | |
| 13906 | + } | |
| 13907 | + Array_string _t5 = res; | |
| 13908 | + { // defer begin | |
| 13909 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | |
| 13910 | + } // defer end | |
| 13911 | + return _t5; | |
| 13912 | +} | |
| 13913 | +Array_string builtin__string_split_by_space(string s) { | |
| 13914 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | |
| 13915 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | |
| 13916 | + Array_string _t1 = builtin__string_split_any(s, _S(" \n\t\v\f\r")); | |
| 13917 | + for (int _t2 = 0; _t2 < _t1.len; ++_t2) { | |
| 13918 | + string word = ((string*)_t1.data)[_t2]; | |
| 13919 | + if ((word).len != 0) { | |
| 13920 | + builtin__array_push((array*)&res, _MOV((string[]){ word })); | |
| 13921 | + } | |
| 13922 | + } | |
| 13923 | + Array_string _t4 = res; | |
| 13924 | + { // defer begin | |
| 13925 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | |
| 13926 | + } // defer end | |
| 13927 | + return _t4; | |
| 13928 | +} | |
| 13929 | +string builtin__string_substr(string s, int start, int _end) { | |
| 13930 | + int end = (_end == _const_max_i64 || _end == _const_max_i32 ? (s.len) : (_end)); | |
| 13931 | + #if 1 | |
| 13932 | + { | |
| 13933 | + if (start > end || start > s.len || end > s.len || start < 0 || end < 0) { | |
| 13934 | + builtin___v_panic(builtin__string_plus_many(8, _MOV((string[8]){_S("substr("), builtin__impl_i64_to_string(start), _S(", "), builtin__impl_i64_to_string(end), _S(") out of bounds (len="), builtin__impl_i64_to_string(s.len), _S(") s="), s}))); | |
| 13935 | + VUNREACHABLE(); | |
| 13936 | + } | |
| 13937 | + } | |
| 13938 | + #endif | |
| 13939 | + int len = end - start; | |
| 13940 | + if (len == s.len) { | |
| 13941 | + return builtin__string_clone(s); | |
| 13942 | + } | |
| 13943 | + string _t3 = ((string){.str = builtin__malloc_noscan(len + 1), .len = len}); | |
| 13944 | + string res = _t3; | |
| 13945 | + { // Unsafe block | |
| 13946 | + builtin__vmemcpy(res.str, s.str + start, len); | |
| 13947 | + res.str[len] = 0; | |
| 13948 | + } | |
| 13949 | + return res; | |
| 13950 | +} | |
| 13951 | +string builtin__string_substr_unsafe(string s, int start, int _end) { | |
| 13952 | + int end = (_end == 2147483647 ? (s.len) : (_end)); | |
| 13953 | + int len = end - start; | |
| 13954 | + if (len == s.len) { | |
| 13955 | + return s; | |
| 13956 | + } | |
| 13957 | + return ((string){.str = s.str + start, .len = len}); | |
| 13958 | +} | |
| 13959 | +string builtin__string_substr_or(string s, int start, int _end, string fallback) { | |
| 13960 | + int end = (_end == _const_max_i64 || _end == _const_max_i32 ? (s.len) : (_end)); | |
| 13961 | + if (start < 0 || start > end || end > s.len) { | |
| 13962 | + return fallback; | |
| 13963 | + } | |
| 13964 | + return builtin__string_substr(s, start, end); | |
| 13965 | +} | |
| 13966 | +_result_string builtin__string_substr_with_check(string s, int start, int _end) { | |
| 13967 | + int end = (_end == _const_max_i64 || _end == _const_max_i32 ? (s.len) : (_end)); | |
| 13968 | + if (start > end || start > s.len || end > s.len || start < 0 || end < 0) { | |
| 13969 | + return (_result_string){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(7, _MOV((string[7]){_S("substr("), builtin__impl_i64_to_string(start), _S(", "), builtin__impl_i64_to_string(end), _S(") out of bounds (len="), builtin__impl_i64_to_string(s.len), _S(")")}))), .data={E_STRUCT} }; | |
| 13970 | + } | |
| 13971 | + int len = end - start; | |
| 13972 | + if (len == s.len) { | |
| 13973 | + _result_string _t2; | |
| 13974 | + builtin___result_ok(&(string[]) { builtin__string_clone(s) }, (_result*)(&_t2), sizeof(string)); | |
| 13975 | + | |
| 13976 | + return _t2; | |
| 13977 | + } | |
| 13978 | + string _t3 = ((string){.str = builtin__malloc_noscan(len + 1), .len = len}); | |
| 13979 | + string res = _t3; | |
| 13980 | + { // Unsafe block | |
| 13981 | + builtin__vmemcpy(res.str, s.str + start, len); | |
| 13982 | + res.str[len] = 0; | |
| 13983 | + } | |
| 13984 | + _result_string _t4; | |
| 13985 | + builtin___result_ok(&(string[]) { res }, (_result*)(&_t4), sizeof(string)); | |
| 13986 | + | |
| 13987 | + return _t4; | |
| 13988 | +} | |
| 13989 | +string builtin__string_substr_ni(string s, int _start, int _end) { | |
| 13990 | + int start = _start; | |
| 13991 | + int end = (_end == _const_max_i64 || _end == _const_max_i32 ? (s.len) : (_end)); | |
| 13992 | + if (start < 0) { | |
| 13993 | + start = s.len + start; | |
| 13994 | + if (start < 0) { | |
| 13995 | + start = 0; | |
| 13996 | + } | |
| 13997 | + } | |
| 13998 | + if (end < 0) { | |
| 13999 | + end = s.len + end; | |
| 14000 | + if (end < 0) { | |
| 14001 | + end = 0; | |
| 14002 | + } | |
| 14003 | + } | |
| 14004 | + if (end >= s.len) { | |
| 14005 | + end = s.len; | |
| 14006 | + } | |
| 14007 | + if (start > s.len || end < start) { | |
| 14008 | + return _S(""); | |
| 14009 | + } | |
| 14010 | + int len = end - start; | |
| 14011 | + string _t2 = ((string){.str = builtin__malloc_noscan(len + 1), .len = len}); | |
| 14012 | + string res = _t2; | |
| 14013 | + { // Unsafe block | |
| 14014 | + builtin__vmemcpy(res.str, s.str + start, len); | |
| 14015 | + res.str[len] = 0; | |
| 14016 | + } | |
| 14017 | + return res; | |
| 14018 | +} | |
| 14019 | +int builtin__string_index_(string s, string p) { | |
| 14020 | + if (p.len > s.len || p.len == 0 || ((u64)(s.str)) <= 0xFFFF || ((u64)(p.str)) <= 0xFFFF) { | |
| 14021 | + return -1; | |
| 14022 | + } | |
| 14023 | + if (p.len > 2) { | |
| 14024 | + return builtin__string_index_kmp(s, p); | |
| 14025 | + } | |
| 14026 | + int i = 0; | |
| 14027 | + for (;;) { | |
| 14028 | + if (!(i < s.len)) break; | |
| 14029 | + int j = 0; | |
| 14030 | + for (;;) { | |
| 14031 | + if (!(j < p.len && s.str[i + j] == p.str[j])) break; | |
| 14032 | + j++; | |
| 14033 | + } | |
| 14034 | + if (j == p.len) { | |
| 14035 | + return i; | |
| 14036 | + } | |
| 14037 | + i++; | |
| 14038 | + } | |
| 14039 | + return -1; | |
| 14040 | +} | |
| 14041 | +_option_int builtin__string_index(string s, string p) { | |
| 14042 | + int idx = builtin__string_index_(s, p); | |
| 14043 | + if (idx == -1) { | |
| 14044 | + return (_option_int){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | |
| 14045 | + } | |
| 14046 | + _option_int _t2; | |
| 14047 | + builtin___option_ok(&(int[]) { idx }, (_option*)(&_t2), sizeof(int)); | |
| 14048 | + | |
| 14049 | + return _t2; | |
| 14050 | +} | |
| 14051 | +inline _option_int builtin__string_last_index(string s, string needle) { | |
| 14052 | + int idx = builtin__string_index_last_(s, needle); | |
| 14053 | + if (idx == -1) { | |
| 14054 | + return (_option_int){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | |
| 14055 | + } | |
| 14056 | + _option_int _t2; | |
| 14057 | + builtin___option_ok(&(int[]) { idx }, (_option*)(&_t2), sizeof(int)); | |
| 14058 | + | |
| 14059 | + return _t2; | |
| 14060 | +} | |
| 14061 | +VV_LOC int builtin__string_index_kmp(string s, string p) { | |
| 14062 | + if (p.len > s.len) { | |
| 14063 | + return -1; | |
| 14064 | + } | |
| 14065 | + Array_fixed_int_20 stack_prefixes = {0}; | |
| 14066 | + int* p_prefixes = &stack_prefixes[0]; | |
| 14067 | + if (p.len > _const_kmp_stack_buffer_size) { | |
| 14068 | + p_prefixes = ((int*)(builtin__vcalloc(p.len * ((int)(sizeof(int)))))); | |
| 14069 | + } | |
| 14070 | + int j = 0; | |
| 14071 | + for (int i = 1; i < p.len; i++) { | |
| 14072 | + for (;;) { | |
| 14073 | + if (!(p.str[j] != p.str[i] && j > 0)) break; | |
| 14074 | + j = p_prefixes[j - 1]; | |
| 14075 | + } | |
| 14076 | + if (p.str[j] == p.str[i]) { | |
| 14077 | + j++; | |
| 14078 | + } | |
| 14079 | + { // Unsafe block | |
| 14080 | + p_prefixes[i] = j; | |
| 14081 | + } | |
| 14082 | + } | |
| 14083 | + j = 0; | |
| 14084 | + for (int i = 0; i < s.len; ++i) { | |
| 14085 | + for (;;) { | |
| 14086 | + if (!(p.str[j] != s.str[i] && j > 0)) break; | |
| 14087 | + j = p_prefixes[j - 1]; | |
| 14088 | + } | |
| 14089 | + if (p.str[j] == s.str[i]) { | |
| 14090 | + j++; | |
| 14091 | + } | |
| 14092 | + if (j == p.len) { | |
| 14093 | + int _t2 = (int)(i - p.len) + 1; | |
| 14094 | + { // defer begin | |
| 14095 | + if (p.len > _const_kmp_stack_buffer_size) { | |
| 14096 | + builtin___v_free(p_prefixes); | |
| 14097 | + } | |
| 14098 | + } // defer end | |
| 14099 | + return _t2; | |
| 14100 | + } | |
| 14101 | + } | |
| 14102 | + int _t3 = -1; | |
| 14103 | + { // defer begin | |
| 14104 | + if (p.len > _const_kmp_stack_buffer_size) { | |
| 14105 | + builtin___v_free(p_prefixes); | |
| 14106 | + } | |
| 14107 | + } // defer end | |
| 14108 | + return _t3; | |
| 14109 | +} | |
| 14110 | +int builtin__string_index_any(string s, string chars) { | |
| 14111 | + for (int i = 0; i < s.len; ++i) { | |
| 14112 | + u8 ss = s.str[i]; | |
| 14113 | + for (int _t1 = 0; _t1 < chars.len; ++_t1) { | |
| 14114 | + u8 c = chars.str[_t1]; | |
| 14115 | + if (c == ss) { | |
| 14116 | + return i; | |
| 14117 | + } | |
| 14118 | + } | |
| 14119 | + } | |
| 14120 | + return -1; | |
| 14121 | +} | |
| 14122 | +VV_LOC int builtin__string_index_last_(string s, string p) { | |
| 14123 | + if (p.len > s.len || p.len == 0) { | |
| 14124 | + return -1; | |
| 14125 | + } | |
| 14126 | + int i = s.len - p.len; | |
| 14127 | + for (;;) { | |
| 14128 | + if (!(i >= 0)) break; | |
| 14129 | + int j = 0; | |
| 14130 | + for (;;) { | |
| 14131 | + if (!(j < p.len && s.str[i + j] == p.str[j])) break; | |
| 14132 | + j++; | |
| 14133 | + } | |
| 14134 | + if (j == p.len) { | |
| 14135 | + return i; | |
| 14136 | + } | |
| 14137 | + i--; | |
| 14138 | + } | |
| 14139 | + return -1; | |
| 14140 | +} | |
| 14141 | +_option_int builtin__string_index_after(string s, string p, int start) { | |
| 14142 | + if (p.len > s.len) { | |
| 14143 | + return (_option_int){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | |
| 14144 | + } | |
| 14145 | + int strt = start; | |
| 14146 | + if (start < 0) { | |
| 14147 | + strt = 0; | |
| 14148 | + } | |
| 14149 | + if (start >= s.len) { | |
| 14150 | + return (_option_int){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | |
| 14151 | + } | |
| 14152 | + int i = strt; | |
| 14153 | + for (;;) { | |
| 14154 | + if (!(i < s.len)) break; | |
| 14155 | + int j = 0; | |
| 14156 | + int ii = i; | |
| 14157 | + for (;;) { | |
| 14158 | + if (!(j < p.len && s.str[ii] == p.str[j])) break; | |
| 14159 | + j++; | |
| 14160 | + ii++; | |
| 14161 | + } | |
| 14162 | + if (j == p.len) { | |
| 14163 | + _option_int _t3; | |
| 14164 | + builtin___option_ok(&(int[]) { i }, (_option*)(&_t3), sizeof(int)); | |
| 14165 | + | |
| 14166 | + return _t3; | |
| 14167 | + } | |
| 14168 | + i++; | |
| 14169 | + } | |
| 14170 | + return (_option_int){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | |
| 14171 | +} | |
| 14172 | +int builtin__string_index_after_(string s, string p, int start) { | |
| 14173 | + if (p.len > s.len) { | |
| 14174 | + return -1; | |
| 14175 | + } | |
| 14176 | + int strt = start; | |
| 14177 | + if (start < 0) { | |
| 14178 | + strt = 0; | |
| 14179 | + } | |
| 14180 | + if (start >= s.len) { | |
| 14181 | + return -1; | |
| 14182 | + } | |
| 14183 | + int i = strt; | |
| 14184 | + for (;;) { | |
| 14185 | + if (!(i < s.len)) break; | |
| 14186 | + int j = 0; | |
| 14187 | + int ii = i; | |
| 14188 | + for (;;) { | |
| 14189 | + if (!(j < p.len && s.str[ii] == p.str[j])) break; | |
| 14190 | + j++; | |
| 14191 | + ii++; | |
| 14192 | + } | |
| 14193 | + if (j == p.len) { | |
| 14194 | + return i; | |
| 14195 | + } | |
| 14196 | + i++; | |
| 14197 | + } | |
| 14198 | + return -1; | |
| 14199 | +} | |
| 14200 | +int builtin__string_index_u8(string s, u8 c) { | |
| 14201 | + for (int i = 0; i < s.len; ++i) { | |
| 14202 | + u8 b = s.str[i]; | |
| 14203 | + if (b == c) { | |
| 14204 | + return i; | |
| 14205 | + } | |
| 14206 | + } | |
| 14207 | + return -1; | |
| 14208 | +} | |
| 14209 | +inline int builtin__string_last_index_u8(string s, u8 c) { | |
| 14210 | + for (int i = s.len - 1; i >= 0; i--) { | |
| 14211 | + if (s.str[ i] == c) { | |
| 14212 | + return i; | |
| 14213 | + } | |
| 14214 | + } | |
| 14215 | + return -1; | |
| 14216 | +} | |
| 14217 | +int builtin__string_count(string s, string substr) { | |
| 14218 | + if (s.len == 0 || substr.len == 0) { | |
| 14219 | + return 0; | |
| 14220 | + } | |
| 14221 | + if (substr.len > s.len) { | |
| 14222 | + return 0; | |
| 14223 | + } | |
| 14224 | + int n = 0; | |
| 14225 | + if (substr.len == 1) { | |
| 14226 | + u8 target = substr.str[ 0]; | |
| 14227 | + for (int _t3 = 0; _t3 < s.len; ++_t3) { | |
| 14228 | + u8 letter = s.str[_t3]; | |
| 14229 | + if (letter == target) { | |
| 14230 | + n++; | |
| 14231 | + } | |
| 14232 | + } | |
| 14233 | + return n; | |
| 14234 | + } | |
| 14235 | + int i = 0; | |
| 14236 | + for (;;) { | |
| 14237 | + i = builtin__string_index_after_(s, substr, i); | |
| 14238 | + if (i == -1) { | |
| 14239 | + return n; | |
| 14240 | + } | |
| 14241 | + i += substr.len; | |
| 14242 | + n++; | |
| 14243 | + } | |
| 14244 | + return 0; | |
| 14245 | +} | |
| 14246 | +bool builtin__string_contains_u8(string s, u8 x) { | |
| 14247 | + for (int _t1 = 0; _t1 < s.len; ++_t1) { | |
| 14248 | + u8 c = s.str[_t1]; | |
| 14249 | + if (x == c) { | |
| 14250 | + return true; | |
| 14251 | + } | |
| 14252 | + } | |
| 14253 | + return false; | |
| 14254 | +} | |
| 14255 | +bool builtin__string_contains(string s, string substr) { | |
| 14256 | + if (substr.len == 0) { | |
| 14257 | + return true; | |
| 14258 | + } | |
| 14259 | + if (substr.len == 1) { | |
| 14260 | + return builtin__string_contains_u8(s, substr.str[0]); | |
| 14261 | + } | |
| 14262 | + return builtin__string_index_(s, substr) != -1; | |
| 14263 | +} | |
| 14264 | +bool builtin__string_contains_any(string s, string chars) { | |
| 14265 | + for (int _t1 = 0; _t1 < chars.len; ++_t1) { | |
| 14266 | + u8 c = chars.str[_t1]; | |
| 14267 | + if (builtin__string_contains_u8(s, c)) { | |
| 14268 | + return true; | |
| 14269 | + } | |
| 14270 | + } | |
| 14271 | + return false; | |
| 14272 | +} | |
| 14273 | +bool builtin__string_contains_only(string s, string chars) { | |
| 14274 | + if (chars.len == 0) { | |
| 14275 | + return false; | |
| 14276 | + } | |
| 14277 | + for (int _t2 = 0; _t2 < s.len; ++_t2) { | |
| 14278 | + u8 ch = s.str[_t2]; | |
| 14279 | + int res = 0; | |
| 14280 | + for (int i = 0; i < chars.len && res == 0; i++) { | |
| 14281 | + res += (int[]){(ch == chars.str[i])?1:0}[0]; | |
| 14282 | + } | |
| 14283 | + if (res == 0) { | |
| 14284 | + return false; | |
| 14285 | + } | |
| 14286 | + } | |
| 14287 | + return true; | |
| 14288 | +} | |
| 14289 | +bool builtin__string_contains_any_substr(string s, Array_string substrs) { | |
| 14290 | + if (substrs.len == 0) { | |
| 14291 | + return true; | |
| 14292 | + } | |
| 14293 | + for (int _t2 = 0; _t2 < substrs.len; ++_t2) { | |
| 14294 | + string sub = ((string*)substrs.data)[_t2]; | |
| 14295 | + if (builtin__string_contains(s, sub)) { | |
| 14296 | + return true; | |
| 14297 | + } | |
| 14298 | + } | |
| 14299 | + return false; | |
| 14300 | +} | |
| 14301 | +bool builtin__string_starts_with(string s, string p) { | |
| 14302 | + if (p.len > s.len || ((u64)(s.str)) <= 0xFFFF || ((u64)(p.str)) <= 0xFFFF) { | |
| 14303 | + return false; | |
| 14304 | + } else if (builtin__vmemcmp(s.str, p.str, p.len) == 0) { | |
| 14305 | + return true; | |
| 14306 | + } | |
| 14307 | + return false; | |
| 14308 | +} | |
| 14309 | +bool builtin__string_ends_with(string s, string p) { | |
| 14310 | + if (p.len > s.len || ((u64)(s.str)) <= 0xFFFF || ((u64)(p.str)) <= 0xFFFF) { | |
| 14311 | + return false; | |
| 14312 | + } else if (builtin__vmemcmp(s.str + s.len - p.len, p.str, p.len) == 0) { | |
| 14313 | + return true; | |
| 14314 | + } | |
| 14315 | + return false; | |
| 14316 | +} | |
| 14317 | +string builtin__string_to_lower_ascii(string s) { | |
| 14318 | + { // Unsafe block | |
| 14319 | + u8* b = builtin__malloc_noscan(s.len + 1); | |
| 14320 | + for (int i = 0; i < s.len; ++i) { | |
| 14321 | + if (s.str[i] >= 'A' && s.str[i] <= 'Z') { | |
| 14322 | + b[i] = (u8)(s.str[i] + 32); | |
| 14323 | + } else { | |
| 14324 | + b[i] = s.str[i]; | |
| 14325 | + } | |
| 14326 | + } | |
| 14327 | + b[s.len] = 0; | |
| 14328 | + return builtin__tos(b, s.len); | |
| 14329 | + } | |
| 14330 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 14331 | +} | |
| 14332 | +string builtin__string_to_lower(string s) { | |
| 14333 | + if (builtin__string_is_pure_ascii(s)) { | |
| 14334 | + return builtin__string_to_lower_ascii(s); | |
| 14335 | + } | |
| 14336 | + Array_rune runes = builtin__string_runes(s); | |
| 14337 | + for (int i = 0; i < runes.len; ++i) { | |
| 14338 | + ((rune*)runes.data)[i] = builtin__rune_to_lower(((rune*)runes.data)[i]); | |
| 14339 | + } | |
| 14340 | + return Array_rune_string(runes); | |
| 14341 | +} | |
| 14342 | +bool builtin__string_is_lower(string s) { | |
| 14343 | + if ((s).len == 0 || builtin__u8_is_digit(s.str[ 0])) { | |
| 14344 | + return false; | |
| 14345 | + } | |
| 14346 | + for (int i = 0; i < s.len; ++i) { | |
| 14347 | + if (s.str[ i] >= 'A' && s.str[ i] <= 'Z') { | |
| 14348 | + return false; | |
| 14349 | + } | |
| 14350 | + } | |
| 14351 | + return true; | |
| 14352 | +} | |
| 14353 | +string builtin__string_to_upper_ascii(string s) { | |
| 14354 | + { // Unsafe block | |
| 14355 | + u8* b = builtin__malloc_noscan(s.len + 1); | |
| 14356 | + for (int i = 0; i < s.len; ++i) { | |
| 14357 | + if (s.str[i] >= 'a' && s.str[i] <= 'z') { | |
| 14358 | + b[i] = (u8)(s.str[i] - 32); | |
| 14359 | + } else { | |
| 14360 | + b[i] = s.str[i]; | |
| 14361 | + } | |
| 14362 | + } | |
| 14363 | + b[s.len] = 0; | |
| 14364 | + return builtin__tos(b, s.len); | |
| 14365 | + } | |
| 14366 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 14367 | +} | |
| 14368 | +string builtin__string_to_upper(string s) { | |
| 14369 | + if (builtin__string_is_pure_ascii(s)) { | |
| 14370 | + return builtin__string_to_upper_ascii(s); | |
| 14371 | + } | |
| 14372 | + Array_rune runes = builtin__string_runes(s); | |
| 14373 | + for (int i = 0; i < runes.len; ++i) { | |
| 14374 | + ((rune*)runes.data)[i] = builtin__rune_to_upper(((rune*)runes.data)[i]); | |
| 14375 | + } | |
| 14376 | + return Array_rune_string(runes); | |
| 14377 | +} | |
| 14378 | +bool builtin__string_is_upper(string s) { | |
| 14379 | + if ((s).len == 0) { | |
| 14380 | + return false; | |
| 14381 | + } | |
| 14382 | + bool has_upper = false; | |
| 14383 | + for (int i = 0; i < s.len; ++i) { | |
| 14384 | + if (s.str[ i] >= 'a' && s.str[ i] <= 'z') { | |
| 14385 | + return false; | |
| 14386 | + } | |
| 14387 | + if (s.str[ i] >= 'A' && s.str[ i] <= 'Z') { | |
| 14388 | + has_upper = true; | |
| 14389 | + } | |
| 14390 | + } | |
| 14391 | + return has_upper; | |
| 14392 | +} | |
| 14393 | +string builtin__string_capitalize(string s) { | |
| 14394 | + if (s.len == 0) { | |
| 14395 | + return _S(""); | |
| 14396 | + } | |
| 14397 | + if (s.len == 1) { | |
| 14398 | + return builtin__string_to_upper(builtin__u8_ascii_str(s.str[ 0])); | |
| 14399 | + } | |
| 14400 | + Array_rune r = builtin__string_runes(s); | |
| 14401 | + string letter = builtin__rune_str(((rune*)r.data)[0]); | |
| 14402 | + string uletter = builtin__string_to_upper(letter); | |
| 14403 | + Array_rune rrest = builtin__array_slice(r, 1, 2147483647); | |
| 14404 | + string srest = Array_rune_string(rrest); | |
| 14405 | + string res = builtin__string__plus(uletter, srest); | |
| 14406 | + return res; | |
| 14407 | +} | |
| 14408 | +string builtin__string_uncapitalize(string s) { | |
| 14409 | + if (s.len == 0) { | |
| 14410 | + return _S(""); | |
| 14411 | + } | |
| 14412 | + if (s.len == 1) { | |
| 14413 | + return builtin__string_to_lower(builtin__u8_ascii_str(s.str[ 0])); | |
| 14414 | + } | |
| 14415 | + Array_rune r = builtin__string_runes(s); | |
| 14416 | + string letter = builtin__rune_str(((rune*)r.data)[0]); | |
| 14417 | + string lletter = builtin__string_to_lower(letter); | |
| 14418 | + Array_rune rrest = builtin__array_slice(r, 1, 2147483647); | |
| 14419 | + string srest = Array_rune_string(rrest); | |
| 14420 | + string res = builtin__string__plus(lletter, srest); | |
| 14421 | + return res; | |
| 14422 | +} | |
| 14423 | +bool builtin__string_is_capital(string s) { | |
| 14424 | + if (s.len == 0 || !(s.str[ 0] >= 'A' && s.str[ 0] <= 'Z')) { | |
| 14425 | + return false; | |
| 14426 | + } | |
| 14427 | + for (int i = 1; i < s.len; ++i) { | |
| 14428 | + if (s.str[ i] >= 'A' && s.str[ i] <= 'Z') { | |
| 14429 | + return false; | |
| 14430 | + } | |
| 14431 | + } | |
| 14432 | + return true; | |
| 14433 | +} | |
| 14434 | +bool builtin__string_starts_with_capital(string s) { | |
| 14435 | + if (s.len == 0 || !builtin__u8_is_capital(s.str[ 0])) { | |
| 14436 | + return false; | |
| 14437 | + } | |
| 14438 | + return true; | |
| 14439 | +} | |
| 14440 | +string builtin__string_title(string s) { | |
| 14441 | + Array_string words = builtin__string_split(s, _S(" ")); | |
| 14442 | + Array_string tit = builtin____new_array_with_default(0, 0, sizeof(string), 0); | |
| 14443 | + for (int _t1 = 0; _t1 < words.len; ++_t1) { | |
| 14444 | + string word = ((string*)words.data)[_t1]; | |
| 14445 | + builtin__array_push((array*)&tit, _MOV((string[]){ builtin__string_capitalize(word) })); | |
| 14446 | + } | |
| 14447 | + string title = Array_string_join(tit, _S(" ")); | |
| 14448 | + return title; | |
| 14449 | +} | |
| 14450 | +bool builtin__string_is_title(string s) { | |
| 14451 | + Array_string words = builtin__string_split(s, _S(" ")); | |
| 14452 | + for (int _t1 = 0; _t1 < words.len; ++_t1) { | |
| 14453 | + string word = ((string*)words.data)[_t1]; | |
| 14454 | + if (!builtin__string_is_capital(word)) { | |
| 14455 | + return false; | |
| 14456 | + } | |
| 14457 | + } | |
| 14458 | + return true; | |
| 14459 | +} | |
| 14460 | +string builtin__string_find_between(string s, string start, string end) { | |
| 14461 | + int start_pos = builtin__string_index_(s, start); | |
| 14462 | + if (start_pos == -1) { | |
| 14463 | + return _S(""); | |
| 14464 | + } | |
| 14465 | + string val = builtin__string_substr(s, start_pos + start.len, 2147483647); | |
| 14466 | + int end_pos = builtin__string_index_(val, end); | |
| 14467 | + if (end_pos == -1) { | |
| 14468 | + return _S(""); | |
| 14469 | + } | |
| 14470 | + return builtin__string_substr(val, 0, end_pos); | |
| 14471 | +} | |
| 14472 | +inline string builtin__string_trim_space(string s) { | |
| 14473 | + return builtin__string_trim(s, _S(" \n\t\v\f\r")); | |
| 14474 | +} | |
| 14475 | +inline string builtin__string_trim_space_left(string s) { | |
| 14476 | + return builtin__string_trim_left(s, _S(" \n\t\v\f\r")); | |
| 14477 | +} | |
| 14478 | +inline string builtin__string_trim_space_right(string s) { | |
| 14479 | + return builtin__string_trim_right(s, _S(" \n\t\v\f\r")); | |
| 14480 | +} | |
| 14481 | +string builtin__string_trim(string s, string cutset) { | |
| 14482 | + if ((s).len == 0 || (cutset).len == 0) { | |
| 14483 | + return builtin__string_clone(s); | |
| 14484 | + } | |
| 14485 | + if (builtin__string_is_pure_ascii(cutset)) { | |
| 14486 | + return builtin__string_trim_chars(s, cutset, TrimMode__trim_both); | |
| 14487 | + } else { | |
| 14488 | + return builtin__string_trim_runes(s, cutset, TrimMode__trim_both); | |
| 14489 | + } | |
| 14490 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 14491 | +} | |
| 14492 | +multi_return_int_int builtin__string_trim_indexes(string s, string cutset) { | |
| 14493 | + int pos_left = 0; | |
| 14494 | + int pos_right = s.len - 1; | |
| 14495 | + bool cs_match = true; | |
| 14496 | + for (;;) { | |
| 14497 | + if (!(pos_left <= s.len && pos_right >= -1 && cs_match)) break; | |
| 14498 | + cs_match = false; | |
| 14499 | + for (int _t1 = 0; _t1 < cutset.len; ++_t1) { | |
| 14500 | + u8 cs = cutset.str[_t1]; | |
| 14501 | + if (s.str[ pos_left] == cs) { | |
| 14502 | + pos_left++; | |
| 14503 | + cs_match = true; | |
| 14504 | + break; | |
| 14505 | + } | |
| 14506 | + } | |
| 14507 | + for (int _t2 = 0; _t2 < cutset.len; ++_t2) { | |
| 14508 | + u8 cs = cutset.str[_t2]; | |
| 14509 | + if (s.str[ pos_right] == cs) { | |
| 14510 | + pos_right--; | |
| 14511 | + cs_match = true; | |
| 14512 | + break; | |
| 14513 | + } | |
| 14514 | + } | |
| 14515 | + if (pos_left > pos_right) { | |
| 14516 | + return (multi_return_int_int){.arg0=0, .arg1=0}; | |
| 14517 | + } | |
| 14518 | + } | |
| 14519 | + return (multi_return_int_int){.arg0=pos_left, .arg1=pos_right + 1}; | |
| 14520 | +} | |
| 14521 | +VV_LOC string builtin__string_trim_chars(string s, string cutset, TrimMode mode) { | |
| 14522 | + int pos_left = 0; | |
| 14523 | + int pos_right = s.len - 1; | |
| 14524 | + bool cs_match = true; | |
| 14525 | + for (;;) { | |
| 14526 | + if (!(pos_left <= s.len && pos_right >= -1 && cs_match)) break; | |
| 14527 | + cs_match = false; | |
| 14528 | + if (mode == TrimMode__trim_left || mode == TrimMode__trim_both) { | |
| 14529 | + for (int _t1 = 0; _t1 < cutset.len; ++_t1) { | |
| 14530 | + u8 cs = cutset.str[_t1]; | |
| 14531 | + if (s.str[ pos_left] == cs) { | |
| 14532 | + pos_left++; | |
| 14533 | + cs_match = true; | |
| 14534 | + break; | |
| 14535 | + } | |
| 14536 | + } | |
| 14537 | + } | |
| 14538 | + if (mode == TrimMode__trim_right || mode == TrimMode__trim_both) { | |
| 14539 | + for (int _t2 = 0; _t2 < cutset.len; ++_t2) { | |
| 14540 | + u8 cs = cutset.str[_t2]; | |
| 14541 | + if (s.str[ pos_right] == cs) { | |
| 14542 | + pos_right--; | |
| 14543 | + cs_match = true; | |
| 14544 | + break; | |
| 14545 | + } | |
| 14546 | + } | |
| 14547 | + } | |
| 14548 | + if (pos_left > pos_right) { | |
| 14549 | + return _S(""); | |
| 14550 | + } | |
| 14551 | + } | |
| 14552 | + return builtin__string_substr(s, pos_left, pos_right + 1); | |
| 14553 | +} | |
| 14554 | +VV_LOC string builtin__string_trim_runes(string s, string cutset, TrimMode mode) { | |
| 14555 | + Array_rune s_runes = builtin__string_runes(s); | |
| 14556 | + Array_rune cs_runes = builtin__string_runes(cutset); | |
| 14557 | + int pos_left = 0; | |
| 14558 | + int pos_right = s_runes.len - 1; | |
| 14559 | + bool cs_match = true; | |
| 14560 | + for (;;) { | |
| 14561 | + if (!(pos_left <= s_runes.len && pos_right >= -1 && cs_match)) break; | |
| 14562 | + cs_match = false; | |
| 14563 | + if (mode == TrimMode__trim_left || mode == TrimMode__trim_both) { | |
| 14564 | + for (int _t1 = 0; _t1 < cs_runes.len; ++_t1) { | |
| 14565 | + rune cs = ((rune*)cs_runes.data)[_t1]; | |
| 14566 | + if (((rune*)s_runes.data)[pos_left] == cs) { | |
| 14567 | + pos_left++; | |
| 14568 | + cs_match = true; | |
| 14569 | + break; | |
| 14570 | + } | |
| 14571 | + } | |
| 14572 | + } | |
| 14573 | + if (mode == TrimMode__trim_right || mode == TrimMode__trim_both) { | |
| 14574 | + for (int _t2 = 0; _t2 < cs_runes.len; ++_t2) { | |
| 14575 | + rune cs = ((rune*)cs_runes.data)[_t2]; | |
| 14576 | + if (((rune*)s_runes.data)[pos_right] == cs) { | |
| 14577 | + pos_right--; | |
| 14578 | + cs_match = true; | |
| 14579 | + break; | |
| 14580 | + } | |
| 14581 | + } | |
| 14582 | + } | |
| 14583 | + if (pos_left > pos_right) { | |
| 14584 | + return _S(""); | |
| 14585 | + } | |
| 14586 | + } | |
| 14587 | + return Array_rune_string(builtin__array_slice(s_runes, pos_left, pos_right + 1)); | |
| 14588 | +} | |
| 14589 | +string builtin__string_trim_left(string s, string cutset) { | |
| 14590 | + if ((s).len == 0 || (cutset).len == 0) { | |
| 14591 | + return builtin__string_clone(s); | |
| 14592 | + } | |
| 14593 | + if (builtin__string_is_pure_ascii(cutset)) { | |
| 14594 | + return builtin__string_trim_chars(s, cutset, TrimMode__trim_left); | |
| 14595 | + } else { | |
| 14596 | + return builtin__string_trim_runes(s, cutset, TrimMode__trim_left); | |
| 14597 | + } | |
| 14598 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 14599 | +} | |
| 14600 | +string builtin__string_trim_right(string s, string cutset) { | |
| 14601 | + if (s.len < 1 || cutset.len < 1) { | |
| 14602 | + return builtin__string_clone(s); | |
| 14603 | + } | |
| 14604 | + if (cutset.len == 1) { | |
| 14605 | + u8 cut = cutset.str[ 0]; | |
| 14606 | + int pos_right = s.len - 1; | |
| 14607 | + for (;;) { | |
| 14608 | + if (!(pos_right >= 0 && s.str[ pos_right] == cut)) break; | |
| 14609 | + pos_right--; | |
| 14610 | + } | |
| 14611 | + if (pos_right < 0) { | |
| 14612 | + return _S(""); | |
| 14613 | + } | |
| 14614 | + return builtin__string_substr(s, 0, pos_right + 1); | |
| 14615 | + } | |
| 14616 | + if (cutset.len == 2 && builtin__string_is_pure_ascii(cutset)) { | |
| 14617 | + u8 cut0 = cutset.str[ 0]; | |
| 14618 | + u8 cut1 = cutset.str[ 1]; | |
| 14619 | + int pos_right = s.len - 1; | |
| 14620 | + for (;;) { | |
| 14621 | + if (!(pos_right >= 0 && (s.str[ pos_right] == cut0 || s.str[ pos_right] == cut1))) break; | |
| 14622 | + pos_right--; | |
| 14623 | + } | |
| 14624 | + if (pos_right < 0) { | |
| 14625 | + return _S(""); | |
| 14626 | + } | |
| 14627 | + return builtin__string_substr(s, 0, pos_right + 1); | |
| 14628 | + } | |
| 14629 | + if (builtin__string_is_pure_ascii(cutset)) { | |
| 14630 | + return builtin__string_trim_chars(s, cutset, TrimMode__trim_right); | |
| 14631 | + } else { | |
| 14632 | + return builtin__string_trim_runes(s, cutset, TrimMode__trim_right); | |
| 14633 | + } | |
| 14634 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 14635 | +} | |
| 14636 | +string builtin__string_trim_string_left(string s, string str) { | |
| 14637 | + if (builtin__string_starts_with(s, str)) { | |
| 14638 | + return builtin__string_substr(s, str.len, 2147483647); | |
| 14639 | + } | |
| 14640 | + return builtin__string_clone(s); | |
| 14641 | +} | |
| 14642 | +string builtin__string_trim_string_right(string s, string str) { | |
| 14643 | + if (builtin__string_ends_with(s, str)) { | |
| 14644 | + return builtin__string_substr(s, 0, s.len - str.len); | |
| 14645 | + } | |
| 14646 | + return builtin__string_clone(s); | |
| 14647 | +} | |
| 14648 | +int builtin__compare_strings(string* a, string* b) { | |
| 14649 | + bool _t2 = true; | |
| 14650 | + int_literal _t3 = 0; | |
| 14651 | + | |
| 14652 | + if (_t2 == (builtin__string__lt(*a, *b))) { | |
| 14653 | + _t3 = -1; | |
| 14654 | + } | |
| 14655 | + else if (_t2 == (builtin__string__lt(*b, *a))) { | |
| 14656 | + _t3 = 1; | |
| 14657 | + } | |
| 14658 | + else { | |
| 14659 | + _t3 = 0; | |
| 14660 | + }return _t3; | |
| 14661 | +} | |
| 14662 | +VV_LOC int builtin__compare_strings_by_len(string* a, string* b) { | |
| 14663 | + bool _t2 = true; | |
| 14664 | + int_literal _t3 = 0; | |
| 14665 | + | |
| 14666 | + if (_t2 == (a->len < b->len)) { | |
| 14667 | + _t3 = -1; | |
| 14668 | + } | |
| 14669 | + else if (_t2 == (a->len > b->len)) { | |
| 14670 | + _t3 = 1; | |
| 14671 | + } | |
| 14672 | + else { | |
| 14673 | + _t3 = 0; | |
| 14674 | + }return _t3; | |
| 14675 | +} | |
| 14676 | +VV_LOC int builtin__compare_lower_strings(string* a, string* b) { | |
| 14677 | + string aa = builtin__string_to_lower(*a); | |
| 14678 | + string bb = builtin__string_to_lower(*b); | |
| 14679 | + return builtin__compare_strings(&aa, &bb); | |
| 14680 | +} | |
| 14681 | +inline void Array_string_sort_ignore_case(Array_string* s) { | |
| 14682 | + if (s->len > 0) { v_stable_sort(s->data, s->len, s->element_size, builtin__compare_lower_strings_qsort_adapter); } | |
| 14683 | + ; | |
| 14684 | +} | |
| 14685 | +inline void Array_string_sort_by_len(Array_string* s) { | |
| 14686 | + if (s->len > 0) { v_stable_sort(s->data, s->len, s->element_size, builtin__compare_strings_by_len_qsort_adapter); } | |
| 14687 | + ; | |
| 14688 | +} | |
| 14689 | +inline string builtin__string_str(string s) { | |
| 14690 | + return builtin__string_clone(s); | |
| 14691 | +} | |
| 14692 | +VV_LOC u8 builtin__string_at(string s, int idx) { | |
| 14693 | + #if 1 | |
| 14694 | + { | |
| 14695 | + if (idx < 0 || idx >= s.len) { | |
| 14696 | + builtin__panic_n2(_S("string index out of range(idx,s.len):"), idx, s.len); | |
| 14697 | + VUNREACHABLE(); | |
| 14698 | + } | |
| 14699 | + } | |
| 14700 | + #endif | |
| 14701 | + return s.str[idx]; | |
| 14702 | +} | |
| 14703 | +VV_LOC u8 builtin__string_at_i64(string s, i64 idx) { | |
| 14704 | + #if 1 | |
| 14705 | + { | |
| 14706 | + if (idx < 0 || idx >= ((i64)(s.len))) { | |
| 14707 | + builtin__panic_n2(_S("string index out of range(idx,s.len):"), idx, s.len); | |
| 14708 | + VUNREACHABLE(); | |
| 14709 | + } | |
| 14710 | + } | |
| 14711 | + #endif | |
| 14712 | + return s.str[((int)(idx))]; | |
| 14713 | +} | |
| 14714 | +VV_LOC u8 builtin__string_at_u64(string s, u64 idx) { | |
| 14715 | + #if 1 | |
| 14716 | + { | |
| 14717 | + if (idx >= ((u64)(s.len))) { | |
| 14718 | + builtin___v_panic(builtin__string_plus_many(4, _MOV((string[4]){_S("string index out of range(idx,s.len): "), builtin__u64_str(idx), _S(", "), builtin__impl_i64_to_string(s.len)}))); | |
| 14719 | + VUNREACHABLE(); | |
| 14720 | + } | |
| 14721 | + } | |
| 14722 | + #endif | |
| 14723 | + return s.str[((int)(idx))]; | |
| 14724 | +} | |
| 14725 | +VV_LOC u8 builtin__string_at_ni(string s, int idx) { | |
| 14726 | + return builtin__string_at(s, builtin__v_ni_index(idx, s.len)); | |
| 14727 | +} | |
| 14728 | +VV_LOC _option_u8 builtin__string_at_with_check(string s, int idx) { | |
| 14729 | + if (idx < 0 || idx >= s.len) { | |
| 14730 | + return (_option_u8){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | |
| 14731 | + } | |
| 14732 | + { // Unsafe block | |
| 14733 | + _option_u8 _t2; | |
| 14734 | + builtin___option_ok(&(u8[]) { s.str[idx] }, (_option*)(&_t2), sizeof(u8)); | |
| 14735 | + | |
| 14736 | + return _t2; | |
| 14737 | + } | |
| 14738 | + return (_option_u8){.state=2, .err=_const_none__, .data={E_STRUCT}}; | |
| 14739 | +} | |
| 14740 | +VV_LOC _option_u8 builtin__string_at_with_check_i64(string s, i64 idx) { | |
| 14741 | + if (idx < 0 || idx >= ((i64)(s.len))) { | |
| 14742 | + return (_option_u8){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | |
| 14743 | + } | |
| 14744 | + { // Unsafe block | |
| 14745 | + _option_u8 _t2; | |
| 14746 | + builtin___option_ok(&(u8[]) { s.str[((int)(idx))] }, (_option*)(&_t2), sizeof(u8)); | |
| 14747 | + | |
| 14748 | + return _t2; | |
| 14749 | + } | |
| 14750 | + return (_option_u8){.state=2, .err=_const_none__, .data={E_STRUCT}}; | |
| 14751 | +} | |
| 14752 | +VV_LOC _option_u8 builtin__string_at_with_check_u64(string s, u64 idx) { | |
| 14753 | + if (idx >= ((u64)(s.len))) { | |
| 14754 | + return (_option_u8){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | |
| 14755 | + } | |
| 14756 | + { // Unsafe block | |
| 14757 | + _option_u8 _t2; | |
| 14758 | + builtin___option_ok(&(u8[]) { s.str[((int)(idx))] }, (_option*)(&_t2), sizeof(u8)); | |
| 14759 | + | |
| 14760 | + return _t2; | |
| 14761 | + } | |
| 14762 | + return (_option_u8){.state=2, .err=_const_none__, .data={E_STRUCT}}; | |
| 14763 | +} | |
| 14764 | +VV_LOC _option_u8 builtin__string_at_with_check_ni(string s, int idx) { | |
| 14765 | + return builtin__string_at_with_check(s, builtin__v_ni_index(idx, s.len)); | |
| 14766 | +} | |
| 14767 | +bool builtin__string_is_oct(string str) { | |
| 14768 | + int i = 0; | |
| 14769 | + if (str.len == 0) { | |
| 14770 | + return false; | |
| 14771 | + } | |
| 14772 | + if (str.str[ i] == '0') { | |
| 14773 | + i++; | |
| 14774 | + } else if (str.str[ i] == '-' || str.str[ i] == '+') { | |
| 14775 | + i++; | |
| 14776 | + if (i < str.len && str.str[ i] == '0') { | |
| 14777 | + i++; | |
| 14778 | + } else { | |
| 14779 | + return false; | |
| 14780 | + } | |
| 14781 | + } else { | |
| 14782 | + return false; | |
| 14783 | + } | |
| 14784 | + if (i < str.len && str.str[ i] == 'o') { | |
| 14785 | + i++; | |
| 14786 | + } else { | |
| 14787 | + return false; | |
| 14788 | + } | |
| 14789 | + if (i == str.len) { | |
| 14790 | + return false; | |
| 14791 | + } | |
| 14792 | + for (;;) { | |
| 14793 | + if (!(i < str.len)) break; | |
| 14794 | + if (str.str[ i] < '0' || str.str[ i] > '7') { | |
| 14795 | + return false; | |
| 14796 | + } | |
| 14797 | + i++; | |
| 14798 | + } | |
| 14799 | + return true; | |
| 14800 | +} | |
| 14801 | +bool builtin__string_is_bin(string str) { | |
| 14802 | + int i = 0; | |
| 14803 | + if (str.len == 0) { | |
| 14804 | + return false; | |
| 14805 | + } | |
| 14806 | + if (str.str[ i] == '0') { | |
| 14807 | + i++; | |
| 14808 | + } else if (str.str[ i] == '-' || str.str[ i] == '+') { | |
| 14809 | + i++; | |
| 14810 | + if (i < str.len && str.str[ i] == '0') { | |
| 14811 | + i++; | |
| 14812 | + } else { | |
| 14813 | + return false; | |
| 14814 | + } | |
| 14815 | + } else { | |
| 14816 | + return false; | |
| 14817 | + } | |
| 14818 | + if (i < str.len && str.str[ i] == 'b') { | |
| 14819 | + i++; | |
| 14820 | + } else { | |
| 14821 | + return false; | |
| 14822 | + } | |
| 14823 | + if (i == str.len) { | |
| 14824 | + return false; | |
| 14825 | + } | |
| 14826 | + for (;;) { | |
| 14827 | + if (!(i < str.len)) break; | |
| 14828 | + if (str.str[ i] < '0' || str.str[ i] > '1') { | |
| 14829 | + return false; | |
| 14830 | + } | |
| 14831 | + i++; | |
| 14832 | + } | |
| 14833 | + return true; | |
| 14834 | +} | |
| 14835 | +bool builtin__string_is_hex(string str) { | |
| 14836 | + int i = 0; | |
| 14837 | + if (str.len == 0) { | |
| 14838 | + return false; | |
| 14839 | + } | |
| 14840 | + if (str.str[ i] == '0') { | |
| 14841 | + i++; | |
| 14842 | + } else if (str.str[ i] == '-' || str.str[ i] == '+') { | |
| 14843 | + i++; | |
| 14844 | + if (i < str.len && str.str[ i] == '0') { | |
| 14845 | + i++; | |
| 14846 | + } else { | |
| 14847 | + return false; | |
| 14848 | + } | |
| 14849 | + } else { | |
| 14850 | + return false; | |
| 14851 | + } | |
| 14852 | + if (i < str.len && str.str[ i] == 'x') { | |
| 14853 | + i++; | |
| 14854 | + } else { | |
| 14855 | + return false; | |
| 14856 | + } | |
| 14857 | + if (i == str.len) { | |
| 14858 | + return false; | |
| 14859 | + } | |
| 14860 | + for (;;) { | |
| 14861 | + if (!(i < str.len)) break; | |
| 14862 | + if ((str.str[ i] < '0' || str.str[ i] > '9') && ((str.str[ i] < 'a' || str.str[ i] > 'f') && (str.str[ i] < 'A' || str.str[ i] > 'F'))) { | |
| 14863 | + return false; | |
| 14864 | + } | |
| 14865 | + i++; | |
| 14866 | + } | |
| 14867 | + return true; | |
| 14868 | +} | |
| 14869 | +bool builtin__string_is_int(string str) { | |
| 14870 | + int i = 0; | |
| 14871 | + if (str.len == 0) { | |
| 14872 | + return false; | |
| 14873 | + } | |
| 14874 | + if ((str.str[ i] != '-' && str.str[ i] != '+') && (!builtin__u8_is_digit(str.str[ i]))) { | |
| 14875 | + return false; | |
| 14876 | + } else { | |
| 14877 | + i++; | |
| 14878 | + } | |
| 14879 | + if (i == str.len && (!builtin__u8_is_digit(str.str[ i - 1]))) { | |
| 14880 | + return false; | |
| 14881 | + } | |
| 14882 | + for (;;) { | |
| 14883 | + if (!(i < str.len)) break; | |
| 14884 | + if (str.str[ i] < '0' || str.str[ i] > '9') { | |
| 14885 | + return false; | |
| 14886 | + } | |
| 14887 | + i++; | |
| 14888 | + } | |
| 14889 | + return true; | |
| 14890 | +} | |
| 14891 | +inline bool builtin__u8_is_space(u8 c) { | |
| 14892 | + return c == 32 || (c > 8 && c < 14) || c == 0x85 || c == 0xa0; | |
| 14893 | +} | |
| 14894 | +inline bool builtin__u8_is_digit(u8 c) { | |
| 14895 | + return c >= '0' && c <= '9'; | |
| 14896 | +} | |
| 14897 | +inline bool builtin__u8_is_hex_digit(u8 c) { | |
| 14898 | + return builtin__u8_is_digit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); | |
| 14899 | +} | |
| 14900 | +inline bool builtin__u8_is_oct_digit(u8 c) { | |
| 14901 | + return c >= '0' && c <= '7'; | |
| 14902 | +} | |
| 14903 | +inline bool builtin__u8_is_bin_digit(u8 c) { | |
| 14904 | + return c == '0' || c == '1'; | |
| 14905 | +} | |
| 14906 | +inline bool builtin__u8_is_letter(u8 c) { | |
| 14907 | + return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); | |
| 14908 | +} | |
| 14909 | +inline bool builtin__u8_is_alnum(u8 c) { | |
| 14910 | + return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'); | |
| 14911 | +} | |
| 14912 | +void builtin__string_free(string* s) { | |
| 14913 | + if (s->is_lit == -98761234) { | |
| 14914 | + u8* double_free_msg = ((u8*)("double string.free() detected\n")); | |
| 14915 | + int double_free_msg_len = builtin__vstrlen(double_free_msg); | |
| 14916 | + #if 0 | |
| 14917 | + { | |
| 14918 | + } | |
| 14919 | + #else | |
| 14920 | + { | |
| 14921 | + builtin___write_buf_to_fd(1, double_free_msg, double_free_msg_len); | |
| 14922 | + } | |
| 14923 | + #endif | |
| 14924 | + return; | |
| 14925 | + } | |
| 14926 | + if (s->is_lit == 1 || s->str == 0) { | |
| 14927 | + return; | |
| 14928 | + } | |
| 14929 | + { // Unsafe block | |
| 14930 | + builtin___v_free(s->str); | |
| 14931 | + s->str = ((void*)0); | |
| 14932 | + } | |
| 14933 | + s->len = 0; | |
| 14934 | + s->is_lit = -98761234; | |
| 14935 | +} | |
| 14936 | +string builtin__string_before(string s, string sub) { | |
| 14937 | + int pos = builtin__string_index_(s, sub); | |
| 14938 | + if (pos == -1) { | |
| 14939 | + return builtin__string_clone(s); | |
| 14940 | + } | |
| 14941 | + return builtin__string_substr(s, 0, pos); | |
| 14942 | +} | |
| 14943 | +string builtin__string_all_before(string s, string sub) { | |
| 14944 | + int pos = builtin__string_index_(s, sub); | |
| 14945 | + if (pos == -1) { | |
| 14946 | + return builtin__string_clone(s); | |
| 14947 | + } | |
| 14948 | + return builtin__string_substr(s, 0, pos); | |
| 14949 | +} | |
| 14950 | +string builtin__string_all_before_last(string s, string sub) { | |
| 14951 | + int pos = builtin__string_index_last_(s, sub); | |
| 14952 | + if (pos == -1) { | |
| 14953 | + return builtin__string_clone(s); | |
| 14954 | + } | |
| 14955 | + return builtin__string_substr(s, 0, pos); | |
| 14956 | +} | |
| 14957 | +string builtin__string_all_after(string s, string sub) { | |
| 14958 | + int pos = builtin__string_index_(s, sub); | |
| 14959 | + if (pos == -1) { | |
| 14960 | + return builtin__string_clone(s); | |
| 14961 | + } | |
| 14962 | + return builtin__string_substr(s, pos + sub.len, 2147483647); | |
| 14963 | +} | |
| 14964 | +string builtin__string_all_after_last(string s, string sub) { | |
| 14965 | + int pos = builtin__string_index_last_(s, sub); | |
| 14966 | + if (pos == -1) { | |
| 14967 | + return builtin__string_clone(s); | |
| 14968 | + } | |
| 14969 | + return builtin__string_substr(s, pos + sub.len, 2147483647); | |
| 14970 | +} | |
| 14971 | +string builtin__string_all_after_first(string s, string sub) { | |
| 14972 | + int pos = builtin__string_index_(s, sub); | |
| 14973 | + if (pos == -1) { | |
| 14974 | + return builtin__string_clone(s); | |
| 14975 | + } | |
| 14976 | + return builtin__string_substr(s, pos + sub.len, 2147483647); | |
| 14977 | +} | |
| 14978 | +inline string builtin__string_after(string s, string sub) { | |
| 14979 | + return builtin__string_all_after_last(s, sub); | |
| 14980 | +} | |
| 14981 | +string builtin__string_after_char(string s, u8 sub) { | |
| 14982 | + int pos = -1; | |
| 14983 | + for (int i = 0; i < s.len; ++i) { | |
| 14984 | + u8 c = s.str[i]; | |
| 14985 | + if (c == sub) { | |
| 14986 | + pos = i; | |
| 14987 | + break; | |
| 14988 | + } | |
| 14989 | + } | |
| 14990 | + if (pos == -1) { | |
| 14991 | + return builtin__string_clone(s); | |
| 14992 | + } | |
| 14993 | + return builtin__string_substr(s, pos + 1, 2147483647); | |
| 14994 | +} | |
| 14995 | +string Array_string_join(Array_string a, string sep) { | |
| 14996 | + if (a.len == 0) { | |
| 14997 | + return _S(""); | |
| 14998 | + } | |
| 14999 | + int len = 0; | |
| 15000 | + for (int _t2 = 0; _t2 < a.len; ++_t2) { | |
| 15001 | + string val = ((string*)a.data)[_t2]; | |
| 15002 | + len += val.len + sep.len; | |
| 15003 | + } | |
| 15004 | + len -= sep.len; | |
| 15005 | + string _t3 = ((string){.str = builtin__malloc_noscan(len + 1), .len = len}); | |
| 15006 | + string res = _t3; | |
| 15007 | + int idx = 0; | |
| 15008 | + for (int i = 0; i < a.len; ++i) { | |
| 15009 | + string val = ((string*)a.data)[i]; | |
| 15010 | + { // Unsafe block | |
| 15011 | + builtin__vmemcpy(((voidptr)(res.str + idx)), val.str, val.len); | |
| 15012 | + idx += val.len; | |
| 15013 | + } | |
| 15014 | + if (i != a.len - 1) { | |
| 15015 | + { // Unsafe block | |
| 15016 | + builtin__vmemcpy(((voidptr)(res.str + idx)), sep.str, sep.len); | |
| 15017 | + idx += sep.len; | |
| 15018 | + } | |
| 15019 | + } | |
| 15020 | + } | |
| 15021 | + { // Unsafe block | |
| 15022 | + res.str[res.len] = 0; | |
| 15023 | + } | |
| 15024 | + return res; | |
| 15025 | +} | |
| 15026 | +inline string Array_string_join_lines(Array_string s) { | |
| 15027 | + return Array_string_join(s, _S("\n")); | |
| 15028 | +} | |
| 15029 | +string builtin__string_reverse(string s) { | |
| 15030 | + if (s.len == 0 || s.len == 1) { | |
| 15031 | + return builtin__string_clone(s); | |
| 15032 | + } | |
| 15033 | + string _t2 = ((string){.str = builtin__malloc_noscan(s.len + 1), .len = s.len}); | |
| 15034 | + string res = _t2; | |
| 15035 | + for (int i = s.len - 1; i >= 0; i--) { | |
| 15036 | + { // Unsafe block | |
| 15037 | + res.str[s.len - i - 1] = s.str[ i]; | |
| 15038 | + } | |
| 15039 | + } | |
| 15040 | + { // Unsafe block | |
| 15041 | + res.str[res.len] = 0; | |
| 15042 | + } | |
| 15043 | + return res; | |
| 15044 | +} | |
| 15045 | +string builtin__string_limit(string s, int max) { | |
| 15046 | + Array_rune u = builtin__string_runes(s); | |
| 15047 | + if (u.len <= max) { | |
| 15048 | + return builtin__string_clone(s); | |
| 15049 | + } | |
| 15050 | + return Array_rune_string(builtin__array_slice(u, 0, max)); | |
| 15051 | +} | |
| 15052 | +int builtin__string_hash(string s) { | |
| 15053 | + u32 h = ((u32)(0)); | |
| 15054 | + if (h == 0 && s.len > 0) { | |
| 15055 | + for (int _t1 = 0; _t1 < s.len; ++_t1) { | |
| 15056 | + u8 c = s.str[_t1]; | |
| 15057 | + h = h * 31 + ((u32)(c)); | |
| 15058 | + } | |
| 15059 | + } | |
| 15060 | + return ((int)(h)); | |
| 15061 | +} | |
| 15062 | +Array_u8 builtin__string_bytes(string s) { | |
| 15063 | + if (s.len == 0) { | |
| 15064 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | |
| 15065 | + } | |
| 15066 | + Array_u8 buf = builtin____new_array_with_default(s.len, 0, sizeof(u8), 0); | |
| 15067 | + builtin__vmemcpy(buf.data, s.str, s.len); | |
| 15068 | + return buf; | |
| 15069 | +} | |
| 15070 | +string builtin__string_repeat(string s, int count) { | |
| 15071 | + if (count <= 0) { | |
| 15072 | + return _S(""); | |
| 15073 | + } else if (count == 1) { | |
| 15074 | + return builtin__string_clone(s); | |
| 15075 | + } | |
| 15076 | + u8* ret = builtin__malloc_noscan(s.len * count + 1); | |
| 15077 | + for (int i = 0; i < count; ++i) { | |
| 15078 | + builtin__vmemcpy(ret + (int)(i * s.len), s.str, s.len); | |
| 15079 | + } | |
| 15080 | + int new_len = s.len * count; | |
| 15081 | + { // Unsafe block | |
| 15082 | + ret[new_len] = 0; | |
| 15083 | + } | |
| 15084 | + return builtin__u8_vstring_with_len(ret, new_len); | |
| 15085 | +} | |
| 15086 | +Array_string builtin__string_fields(string s) { | |
| 15087 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | |
| 15088 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | |
| 15089 | + int word_start = 0; | |
| 15090 | + int word_len = 0; | |
| 15091 | + bool is_in_word = false; | |
| 15092 | + bool is_space = false; | |
| 15093 | + for (int i = 0; i < s.len; ++i) { | |
| 15094 | + u8 c = s.str[i]; | |
| 15095 | + is_space = (c == 32 || c == 9 || c == 10); | |
| 15096 | + if (!is_space) { | |
| 15097 | + word_len++; | |
| 15098 | + } | |
| 15099 | + if (!is_in_word && !is_space) { | |
| 15100 | + word_start = i; | |
| 15101 | + is_in_word = true; | |
| 15102 | + continue; | |
| 15103 | + } | |
| 15104 | + if (is_space && is_in_word) { | |
| 15105 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, word_start, word_start + word_len) })); | |
| 15106 | + is_in_word = false; | |
| 15107 | + word_len = 0; | |
| 15108 | + word_start = 0; | |
| 15109 | + continue; | |
| 15110 | + } | |
| 15111 | + } | |
| 15112 | + if (is_in_word && word_len > 0) { | |
| 15113 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, word_start, s.len) })); | |
| 15114 | + } | |
| 15115 | + Array_string _t3 = res; | |
| 15116 | + { // defer begin | |
| 15117 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | |
| 15118 | + } // defer end | |
| 15119 | + return _t3; | |
| 15120 | +} | |
| 15121 | +inline string builtin__string_strip_margin(string s) { | |
| 15122 | + return builtin__string_strip_margin_custom(s, '|'); | |
| 15123 | +} | |
| 15124 | +string builtin__string_strip_margin_custom(string s, u8 del) { | |
| 15125 | + u8 sep = del; | |
| 15126 | + if (builtin__u8_is_space(sep)) { | |
| 15127 | + builtin__println(_S("Warning: `strip_margin` cannot use white-space as a delimiter")); | |
| 15128 | + builtin__println(_S(" Defaulting to `|`")); | |
| 15129 | + sep = '|'; | |
| 15130 | + } | |
| 15131 | + u8* ret = builtin__malloc_noscan(s.len + 1); | |
| 15132 | + int count = 0; | |
| 15133 | + for (int i = 0; i < s.len; i++) { | |
| 15134 | + if (s.str[ i] == 10 || s.str[ i] == 13) { | |
| 15135 | + { // Unsafe block | |
| 15136 | + ret[count] = s.str[ i]; | |
| 15137 | + } | |
| 15138 | + count++; | |
| 15139 | + if (s.str[ i] == 13 && i < s.len - 1 && s.str[ i + 1] == 10) { | |
| 15140 | + { // Unsafe block | |
| 15141 | + ret[count] = s.str[ i + 1]; | |
| 15142 | + } | |
| 15143 | + count++; | |
| 15144 | + i++; | |
| 15145 | + } | |
| 15146 | + for (;;) { | |
| 15147 | + if (!(s.str[ i] != sep)) break; | |
| 15148 | + i++; | |
| 15149 | + if (i >= s.len) { | |
| 15150 | + break; | |
| 15151 | + } | |
| 15152 | + } | |
| 15153 | + } else { | |
| 15154 | + { // Unsafe block | |
| 15155 | + ret[count] = s.str[ i]; | |
| 15156 | + } | |
| 15157 | + count++; | |
| 15158 | + } | |
| 15159 | + } | |
| 15160 | + { // Unsafe block | |
| 15161 | + ret[count] = 0; | |
| 15162 | + return builtin__u8_vstring_with_len(ret, count); | |
| 15163 | + } | |
| 15164 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 15165 | +} | |
| 15166 | +string builtin__string_trim_indent(string s) { | |
| 15167 | + Array_string lines = builtin__string_split_into_lines(s); | |
| 15168 | + int min_common_indent = ((int)(_const_max_int)); | |
| 15169 | + for (int _t1 = 0; _t1 < lines.len; ++_t1) { | |
| 15170 | + string line = ((string*)lines.data)[_t1]; | |
| 15171 | + if (builtin__string_is_blank(line)) { | |
| 15172 | + continue; | |
| 15173 | + } | |
| 15174 | + int line_indent = builtin__string_indent_width(line); | |
| 15175 | + if (line_indent < min_common_indent) { | |
| 15176 | + min_common_indent = line_indent; | |
| 15177 | + } | |
| 15178 | + } | |
| 15179 | + if (lines.len > 0 && builtin__string_is_blank((*(string*)builtin__array_first(lines)))) { | |
| 15180 | + lines = builtin__array_slice(lines, 1, 2147483647); | |
| 15181 | + } | |
| 15182 | + if (lines.len > 0 && builtin__string_is_blank((*(string*)builtin__array_last(lines)))) { | |
| 15183 | + lines = builtin__array_slice(lines, 0, lines.len - 1); | |
| 15184 | + } | |
| 15185 | + Array_string trimmed_lines = builtin____new_array_with_default(0, lines.len, sizeof(string), 0); | |
| 15186 | + for (int _t2 = 0; _t2 < lines.len; ++_t2) { | |
| 15187 | + string line = ((string*)lines.data)[_t2]; | |
| 15188 | + if (builtin__string_is_blank(line)) { | |
| 15189 | + builtin__array_push((array*)&trimmed_lines, _MOV((string[]){ line })); | |
| 15190 | + continue; | |
| 15191 | + } | |
| 15192 | + builtin__array_push((array*)&trimmed_lines, _MOV((string[]){ builtin__string_substr(line, min_common_indent, 2147483647) })); | |
| 15193 | + } | |
| 15194 | + return Array_string_join(trimmed_lines, _S("\n")); | |
| 15195 | +} | |
| 15196 | +int builtin__string_indent_width(string s) { | |
| 15197 | + for (int i = 0; i < s.len; ++i) { | |
| 15198 | + u8 c = s.str[i]; | |
| 15199 | + if (!builtin__u8_is_space(c)) { | |
| 15200 | + return i; | |
| 15201 | + } | |
| 15202 | + } | |
| 15203 | + return 0; | |
| 15204 | +} | |
| 15205 | +bool builtin__string_is_blank(string s) { | |
| 15206 | + if (s.len == 0) { | |
| 15207 | + return true; | |
| 15208 | + } | |
| 15209 | + for (int _t2 = 0; _t2 < s.len; ++_t2) { | |
| 15210 | + u8 c = s.str[_t2]; | |
| 15211 | + if (!builtin__u8_is_space(c)) { | |
| 15212 | + return false; | |
| 15213 | + } | |
| 15214 | + } | |
| 15215 | + return true; | |
| 15216 | +} | |
| 15217 | +bool builtin__string_match_glob(string name, string pattern) { | |
| 15218 | + int px = 0; | |
| 15219 | + int nx = 0; | |
| 15220 | + int next_px = 0; | |
| 15221 | + int next_nx = 0; | |
| 15222 | + int plen = pattern.len; | |
| 15223 | + int nlen = name.len; | |
| 15224 | + for (;;) { | |
| 15225 | + if (!(px < plen || nx < nlen)) break; | |
| 15226 | + if (px < plen) { | |
| 15227 | + u8 c = pattern.str[ px]; | |
| 15228 | + | |
| 15229 | + if (c == ('?')) { | |
| 15230 | + if (nx < nlen) { | |
| 15231 | + px++; | |
| 15232 | + nx++; | |
| 15233 | + continue; | |
| 15234 | + } | |
| 15235 | + } | |
| 15236 | + else if (c == ('*')) { | |
| 15237 | + next_px = px; | |
| 15238 | + next_nx = nx + 1; | |
| 15239 | + px++; | |
| 15240 | + continue; | |
| 15241 | + } | |
| 15242 | + else if (c == ('[')) { | |
| 15243 | + if (nx < nlen) { | |
| 15244 | + u8 wanted_c = name.str[ nx]; | |
| 15245 | + bool is_inverted = false; | |
| 15246 | + bool inner_match = false; | |
| 15247 | + int inner_idx = px + 1; | |
| 15248 | + if (inner_idx < plen && pattern.str[ inner_idx] == '^') { | |
| 15249 | + is_inverted = true; | |
| 15250 | + inner_idx++; | |
| 15251 | + } | |
| 15252 | + for (; inner_idx < plen && pattern.str[ inner_idx] != ']'; inner_idx++) { | |
| 15253 | + if (pattern.str[ inner_idx] == wanted_c) { | |
| 15254 | + inner_match = true; | |
| 15255 | + } | |
| 15256 | + } | |
| 15257 | + if (inner_idx < plen && ((inner_match && !is_inverted) || (!inner_match && is_inverted))) { | |
| 15258 | + px = inner_idx + 1; | |
| 15259 | + nx++; | |
| 15260 | + continue; | |
| 15261 | + } | |
| 15262 | + } | |
| 15263 | + } | |
| 15264 | + else { | |
| 15265 | + if (nx < nlen && name.str[ nx] == c) { | |
| 15266 | + px++; | |
| 15267 | + nx++; | |
| 15268 | + continue; | |
| 15269 | + } | |
| 15270 | + } | |
| 15271 | + } | |
| 15272 | + if (0 < next_nx && next_nx <= nlen) { | |
| 15273 | + px = next_px; | |
| 15274 | + nx = next_nx; | |
| 15275 | + continue; | |
| 15276 | + } | |
| 15277 | + return false; | |
| 15278 | + } | |
| 15279 | + return true; | |
| 15280 | +} | |
| 15281 | +inline bool builtin__string_is_ascii(string s) { | |
| 15282 | + for (int i = 0; i < s.len; i++) { | |
| 15283 | + if (s.str[ i] < ((u8)(' ')) || s.str[ i] > ((u8)('~'))) { | |
| 15284 | + return false; | |
| 15285 | + } | |
| 15286 | + } | |
| 15287 | + return true; | |
| 15288 | +} | |
| 15289 | +bool builtin__string_is_identifier(string s) { | |
| 15290 | + if (s.len == 0) { | |
| 15291 | + return false; | |
| 15292 | + } | |
| 15293 | + if (!(builtin__u8_is_letter(s.str[ 0]) || s.str[ 0] == '_')) { | |
| 15294 | + return false; | |
| 15295 | + } | |
| 15296 | + for (int i = 1; i < s.len; i++) { | |
| 15297 | + u8 c = s.str[ i]; | |
| 15298 | + if (!(builtin__u8_is_letter(c) || builtin__u8_is_digit(c) || c == '_')) { | |
| 15299 | + return false; | |
| 15300 | + } | |
| 15301 | + } | |
| 15302 | + return true; | |
| 15303 | +} | |
| 15304 | +string builtin__string_camel_to_snake(string s) { | |
| 15305 | + if (s.len == 0) { | |
| 15306 | + return _S(""); | |
| 15307 | + } | |
| 15308 | + if (s.len == 1) { | |
| 15309 | + return builtin__string_to_lower_ascii(s); | |
| 15310 | + } | |
| 15311 | + u8* b = builtin__malloc_noscan(2 * s.len + 1); | |
| 15312 | + int pos = 2; | |
| 15313 | + bool prev_is_upper = false; | |
| 15314 | + bool prev_inserted_boundary = false; | |
| 15315 | + { // Unsafe block | |
| 15316 | + if (builtin__u8_is_capital(s.str[ 0])) { | |
| 15317 | + b[0] = (u8)(s.str[ 0] + 32); | |
| 15318 | + u8 _t3; /* if prepend */ | |
| 15319 | + if (builtin__u8_is_capital(s.str[ 1])) { | |
| 15320 | + prev_is_upper = true; | |
| 15321 | + _t3 = (u8)(s.str[ 1] + 32); | |
| 15322 | + goto _t4; | |
| 15323 | + }; | |
| 15324 | + { | |
| 15325 | + _t3 = s.str[ 1]; | |
| 15326 | + } | |
| 15327 | + _t4: {}; | |
| 15328 | + b[1] = _t3; | |
| 15329 | + } else { | |
| 15330 | + b[0] = s.str[ 0]; | |
| 15331 | + if (builtin__u8_is_capital(s.str[ 1])) { | |
| 15332 | + prev_is_upper = true; | |
| 15333 | + if (s.str[ 0] != '_' && s.len > 2 && !builtin__u8_is_capital(s.str[ 2])) { | |
| 15334 | + b[1] = '_'; | |
| 15335 | + b[2] = (u8)(s.str[ 1] + 32); | |
| 15336 | + pos = 3; | |
| 15337 | + } else { | |
| 15338 | + b[1] = (u8)(s.str[ 1] + 32); | |
| 15339 | + } | |
| 15340 | + } else { | |
| 15341 | + b[1] = s.str[ 1]; | |
| 15342 | + } | |
| 15343 | + } | |
| 15344 | + } | |
| 15345 | + for (int i = 2; i < s.len; i++) { | |
| 15346 | + bool has_boundary_before_upper = false; | |
| 15347 | + u8 c = s.str[ i]; | |
| 15348 | + bool c_is_upper = builtin__u8_is_capital(c); | |
| 15349 | + bool c_is_number = builtin__u8_is_digit(c); | |
| 15350 | + bool next_is_lower = i + 1 < s.len && builtin__u8_is_letter(s.str[ i + 1]) && !builtin__u8_is_capital(s.str[ i + 1]); | |
| 15351 | + bool next2_is_lower = i + 2 < s.len && builtin__u8_is_letter(s.str[ i + 2]) && !builtin__u8_is_capital(s.str[ i + 2]); | |
| 15352 | + bool skip_digit = c_is_number && prev_is_upper && !next_is_lower && next2_is_lower; | |
| 15353 | + if (c_is_upper && prev_is_upper && i >= 2 && builtin__u8_is_capital(s.str[ i - 2]) && next_is_lower && c != '_') { | |
| 15354 | + { // Unsafe block | |
| 15355 | + if (b[pos - 1] != '_') { | |
| 15356 | + b[pos] = '_'; | |
| 15357 | + pos++; | |
| 15358 | + } | |
| 15359 | + } | |
| 15360 | + has_boundary_before_upper = true; | |
| 15361 | + } | |
| 15362 | + if (((c_is_upper && !prev_is_upper) || (!c_is_upper && prev_is_upper && builtin__u8_is_capital(s.str[ i - 2]) && !prev_inserted_boundary && !skip_digit)) && c != '_') { | |
| 15363 | + { // Unsafe block | |
| 15364 | + if (b[pos - 1] != '_') { | |
| 15365 | + b[pos] = '_'; | |
| 15366 | + pos++; | |
| 15367 | + } | |
| 15368 | + } | |
| 15369 | + } | |
| 15370 | + u8 lower_c = (c_is_upper ? ((u8)(c + 32)) : (c)); | |
| 15371 | + { // Unsafe block | |
| 15372 | + b[pos] = lower_c; | |
| 15373 | + } | |
| 15374 | + prev_is_upper = c_is_upper; | |
| 15375 | + prev_inserted_boundary = has_boundary_before_upper; | |
| 15376 | + pos++; | |
| 15377 | + } | |
| 15378 | + { // Unsafe block | |
| 15379 | + b[pos] = 0; | |
| 15380 | + } | |
| 15381 | + return builtin__tos(b, pos); | |
| 15382 | +} | |
| 15383 | +string builtin__string_snake_to_camel(string s) { | |
| 15384 | + if (s.len == 0) { | |
| 15385 | + return _S(""); | |
| 15386 | + } | |
| 15387 | + if (s.len == 1) { | |
| 15388 | + return s; | |
| 15389 | + } | |
| 15390 | + bool need_upper = true; | |
| 15391 | + rune upper_c = '_'; | |
| 15392 | + u8* b = builtin__malloc_noscan(s.len + 1); | |
| 15393 | + int i = 0; | |
| 15394 | + for (int _t3 = 0; _t3 < s.len; ++_t3) { | |
| 15395 | + u8 c = s.str[_t3]; | |
| 15396 | + upper_c = (c >= 'a' && c <= 'z' ? ((u8)(c - 32)) : (c)); | |
| 15397 | + if (c == '_') { | |
| 15398 | + need_upper = true; | |
| 15399 | + } else if (need_upper) { | |
| 15400 | + { // Unsafe block | |
| 15401 | + b[i] = upper_c; | |
| 15402 | + } | |
| 15403 | + i++; | |
| 15404 | + need_upper = false; | |
| 15405 | + } else { | |
| 15406 | + { // Unsafe block | |
| 15407 | + b[i] = c; | |
| 15408 | + } | |
| 15409 | + i++; | |
| 15410 | + } | |
| 15411 | + } | |
| 15412 | + { // Unsafe block | |
| 15413 | + b[i] = 0; | |
| 15414 | + } | |
| 15415 | + return builtin__tos(b, i); | |
| 15416 | +} | |
| 15417 | +string builtin__string_wrap(string s, WrapConfig config) { | |
| 15418 | + if (config.width <= 0) { | |
| 15419 | + return _S(""); | |
| 15420 | + } | |
| 15421 | + Array_string words = builtin__string_fields(s); | |
| 15422 | + if (words.len == 0) { | |
| 15423 | + return _S(""); | |
| 15424 | + } | |
| 15425 | + strings__Builder sb = strings__new_builder(s.len); | |
| 15426 | + strings__Builder_write_string(&sb, (*(string*)builtin__array_get(words, 0))); | |
| 15427 | + int space_left = config.width - (*(string*)builtin__array_get(words, 0)).len; | |
| 15428 | + for (int i = 1; i < words.len; ++i) { | |
| 15429 | + string word = (*(string*)builtin__array_get(words, i)); | |
| 15430 | + if (word.len + 1 > space_left) { | |
| 15431 | + strings__Builder_write_string(&sb, config.end); | |
| 15432 | + strings__Builder_write_string(&sb, word); | |
| 15433 | + space_left = config.width - word.len; | |
| 15434 | + } else { | |
| 15435 | + strings__Builder_write_string(&sb, _S(" ")); | |
| 15436 | + strings__Builder_write_string(&sb, word); | |
| 15437 | + space_left -= 1 + word.len; | |
| 15438 | + } | |
| 15439 | + } | |
| 15440 | + return strings__Builder_str(&sb); | |
| 15441 | +} | |
| 15442 | +string builtin__string_hex(string s) { | |
| 15443 | + if ((s).len == 0) { | |
| 15444 | + return _S(""); | |
| 15445 | + } | |
| 15446 | + return builtin__data_to_hex_string(s.str, s.len); | |
| 15447 | +} | |
| 15448 | +VV_LOC string builtin__data_to_hex_string(u8* data, int len) { | |
| 15449 | + u8* hex = builtin__malloc_noscan(((u64)(len)) * 2 + 1); | |
| 15450 | + int dst = 0; | |
| 15451 | + for (int c = 0; c < len; ++c) { | |
| 15452 | + u8 b = data[c]; | |
| 15453 | + u8 n0 = v__rshift_u8(b, (u64)4); | |
| 15454 | + u8 n1 = (b & 0xF); | |
| 15455 | + hex[dst] = (n0 < 10 ? ((rune)(n0 + '0')) : ((rune)(n0 + 'W'))); | |
| 15456 | + hex[dst + 1] = (n1 < 10 ? ((rune)(n1 + '0')) : ((rune)(n1 + 'W'))); | |
| 15457 | + dst += 2; | |
| 15458 | + } | |
| 15459 | + hex[dst] = 0; | |
| 15460 | + return builtin__tos(hex, dst); | |
| 15461 | +} | |
| 15462 | +RunesIterator builtin__string_runes_iterator(string s) { | |
| 15463 | + return ((RunesIterator){.s = s,.i = 0,}); | |
| 15464 | +} | |
| 15465 | +_option_rune builtin__RunesIterator_next(RunesIterator* ri) { | |
| 15466 | + if (ri->i >= ri->s.len) { | |
| 15467 | + return (_option_rune){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | |
| 15468 | + } | |
| 15469 | + multi_return_rune_int mr_82852 = builtin__utf8_decode_rune(&ri->s.str[ri->i], ri->s.len - ri->i); | |
| 15470 | + rune r = mr_82852.arg0; | |
| 15471 | + int char_len = mr_82852.arg1; | |
| 15472 | + ri->i += (char_len > 0 ? (char_len) : (1)); | |
| 15473 | + _option_rune _t2; | |
| 15474 | + builtin___option_ok(&(rune[]) { r }, (_option*)(&_t2), sizeof(rune)); | |
| 15475 | + | |
| 15476 | + return _t2; | |
| 15477 | +} | |
| 15478 | +Array_u8 builtin__byteptr_vbytes(byteptr data, int len) { | |
| 15479 | + return builtin__voidptr_vbytes(((voidptr)(data)), len); | |
| 15480 | +} | |
| 15481 | +string builtin__byteptr_vstring(byteptr bp) { | |
| 15482 | + return ((string){.str = bp, .len = builtin__vstrlen(bp)}); | |
| 15483 | +} | |
| 15484 | +string builtin__byteptr_vstring_with_len(byteptr bp, int len) { | |
| 15485 | + return ((string){.str = bp, .len = len, .is_lit = 0}); | |
| 15486 | +} | |
| 15487 | +string builtin__charptr_vstring(charptr cp) { | |
| 15488 | + return ((string){.str = ((byteptr)(cp)), .len = builtin__vstrlen_char(cp), .is_lit = 0}); | |
| 15489 | +} | |
| 15490 | +string builtin__charptr_vstring_with_len(charptr cp, int len) { | |
| 15491 | + return ((string){.str = ((byteptr)(cp)), .len = len, .is_lit = 0}); | |
| 15492 | +} | |
| 15493 | +string builtin__byteptr_vstring_literal(byteptr bp) { | |
| 15494 | + return ((string){.str = bp, .len = builtin__vstrlen(bp), .is_lit = 1}); | |
| 15495 | +} | |
| 15496 | +string builtin__byteptr_vstring_literal_with_len(byteptr bp, int len) { | |
| 15497 | + return ((string){.str = bp, .len = len, .is_lit = 1}); | |
| 15498 | +} | |
| 15499 | +string builtin__charptr_vstring_literal(charptr cp) { | |
| 15500 | + return ((string){.str = ((byteptr)(cp)), .len = builtin__vstrlen_char(cp), .is_lit = 1}); | |
| 15501 | +} | |
| 15502 | +string builtin__charptr_vstring_literal_with_len(charptr cp, int len) { | |
| 15503 | + return ((string){.str = ((byteptr)(cp)), .len = len, .is_lit = 1}); | |
| 15504 | +} | |
| 15505 | +string builtin__StrIntpType_str(StrIntpType x) { | |
| 15506 | + string _t2 = (string){.str=(byteptr)"", .is_lit=1}; | |
| 15507 | + switch (x) { | |
| 15508 | + case StrIntpType__si_no_str: { | |
| 15509 | + _t2 = _S("no_str"); | |
| 15510 | + break; | |
| 15511 | + } | |
| 15512 | + case StrIntpType__si_c: { | |
| 15513 | + _t2 = _S("c"); | |
| 15514 | + break; | |
| 15515 | + } | |
| 15516 | + case StrIntpType__si_u8: { | |
| 15517 | + _t2 = _S("u8"); | |
| 15518 | + break; | |
| 15519 | + } | |
| 15520 | + case StrIntpType__si_i8: { | |
| 15521 | + _t2 = _S("i8"); | |
| 15522 | + break; | |
| 15523 | + } | |
| 15524 | + case StrIntpType__si_u16: { | |
| 15525 | + _t2 = _S("u16"); | |
| 15526 | + break; | |
| 15527 | + } | |
| 15528 | + case StrIntpType__si_i16: { | |
| 15529 | + _t2 = _S("i16"); | |
| 15530 | + break; | |
| 15531 | + } | |
| 15532 | + case StrIntpType__si_u32: { | |
| 15533 | + _t2 = _S("u32"); | |
| 15534 | + break; | |
| 15535 | + } | |
| 15536 | + case StrIntpType__si_i32: { | |
| 15537 | + _t2 = _S("i32"); | |
| 15538 | + break; | |
| 15539 | + } | |
| 15540 | + case StrIntpType__si_u64: { | |
| 15541 | + _t2 = _S("u64"); | |
| 15542 | + break; | |
| 15543 | + } | |
| 15544 | + case StrIntpType__si_i64: { | |
| 15545 | + _t2 = _S("i64"); | |
| 15546 | + break; | |
| 15547 | + } | |
| 15548 | + case StrIntpType__si_f32: { | |
| 15549 | + _t2 = _S("f32"); | |
| 15550 | + break; | |
| 15551 | + } | |
| 15552 | + case StrIntpType__si_f64: { | |
| 15553 | + _t2 = _S("f64"); | |
| 15554 | + break; | |
| 15555 | + } | |
| 15556 | + case StrIntpType__si_g32: { | |
| 15557 | + _t2 = _S("f32"); | |
| 15558 | + break; | |
| 15559 | + } | |
| 15560 | + case StrIntpType__si_g64: { | |
| 15561 | + _t2 = _S("f64"); | |
| 15562 | + break; | |
| 15563 | + } | |
| 15564 | + case StrIntpType__si_e32: { | |
| 15565 | + _t2 = _S("f32"); | |
| 15566 | + break; | |
| 15567 | + } | |
| 15568 | + case StrIntpType__si_e64: { | |
| 15569 | + _t2 = _S("f64"); | |
| 15570 | + break; | |
| 15571 | + } | |
| 15572 | + case StrIntpType__si_s: { | |
| 15573 | + _t2 = _S("s"); | |
| 15574 | + break; | |
| 15575 | + } | |
| 15576 | + case StrIntpType__si_p: { | |
| 15577 | + _t2 = _S("p"); | |
| 15578 | + break; | |
| 15579 | + } | |
| 15580 | + case StrIntpType__si_r: { | |
| 15581 | + _t2 = _S("r"); | |
| 15582 | + break; | |
| 15583 | + } | |
| 15584 | + case StrIntpType__si_vp: { | |
| 15585 | + _t2 = _S("vp"); | |
| 15586 | + break; | |
| 15587 | + } | |
| 15588 | + } | |
| 15589 | + return _t2; | |
| 15590 | +} | |
| 15591 | +inline VV_LOC f32 builtin__fabs32(f32 x) { | |
| 15592 | + return (x < 0 ? (-x) : (x)); | |
| 15593 | +} | |
| 15594 | +inline VV_LOC f64 builtin__fabs64(f64 x) { | |
| 15595 | + return (x < 0 ? (-x) : (x)); | |
| 15596 | +} | |
| 15597 | +inline VV_LOC u64 builtin__abs64(i64 x) { | |
| 15598 | + return (x < 0 ? (((u64)(-x))) : (((u64)(x)))); | |
| 15599 | +} | |
| 15600 | +u64 builtin__get_str_intp_u64_format(StrIntpType fmt_type, int in_width, int in_precision, bool in_tail_zeros, bool in_sign, u8 in_pad_ch, int in_base, bool in_upper_case) { | |
| 15601 | + u64 width = (in_width != 0 ? (builtin__abs64(in_width)) : (((u64)(0)))); | |
| 15602 | + u64 align = (in_width > 0 ? (((u64)(32))) : (((u64)(0)))); | |
| 15603 | + u64 upper_case = (in_upper_case ? (((u64)(128))) : (((u64)(0)))); | |
| 15604 | + u64 sign = (in_sign ? (((u64)(256))) : (((u64)(0)))); | |
| 15605 | + u64 precision = (in_precision != 987698 ? ((v__lshift_u64(((u64)((in_precision & 0x7F))), (u64)9))) : (v__lshift_u64(((u64)(0x7F)), (u64)9))); | |
| 15606 | + u32 tail_zeros = (in_tail_zeros ? (v__lshift_u32(((u32)(1)), (u64)16)) : (((u32)(0)))); | |
| 15607 | + u64 base = ((u64)(v__lshift_u32(((u32)((in_base & 0xf))), (u64)27))); | |
| 15608 | + u64 res = ((u64)(((((((((((((u64)(fmt_type)) & 0x1F)) | align) | upper_case) | sign) | precision) | tail_zeros) | (v__lshift_u64(((u64)((width & 0x3FF))), (u64)17))) | base) | (v__lshift_u64(((u64)(in_pad_ch)), (u64)31))))); | |
| 15609 | + return res; | |
| 15610 | +} | |
| 15611 | +u32 builtin__get_str_intp_u32_format(StrIntpType fmt_type, int in_width, int in_precision, bool in_tail_zeros, bool in_sign, u8 in_pad_ch, int in_base, bool in_upper_case) { | |
| 15612 | + u64 width = (in_width != 0 ? (builtin__abs64(in_width)) : (((u32)(0)))); | |
| 15613 | + u32 align = (in_width > 0 ? (((u32)(32))) : (((u32)(0)))); | |
| 15614 | + u32 upper_case = (in_upper_case ? (((u32)(128))) : (((u32)(0)))); | |
| 15615 | + u32 sign = (in_sign ? (((u32)(256))) : (((u32)(0)))); | |
| 15616 | + u32 precision = (in_precision != 987698 ? ((v__lshift_u32(((u32)((in_precision & 0x7F))), (u64)9))) : (v__lshift_u32(((u32)(0x7F)), (u64)9))); | |
| 15617 | + u32 tail_zeros = (in_tail_zeros ? (v__lshift_u32(((u32)(1)), (u64)16)) : (((u32)(0)))); | |
| 15618 | + u32 base = ((u32)(v__lshift_u32(((u32)((in_base & 0xf))), (u64)27))); | |
| 15619 | + u32 res = ((u32)(((((((((((((u32)(fmt_type)) & 0x1F)) | align) | upper_case) | sign) | precision) | tail_zeros) | (v__lshift_u32(((u32)((width & 0x3FF))), (u64)17))) | base) | (v__lshift_u32(((u32)((in_pad_ch & 1))), (u64)31))))); | |
| 15620 | + return res; | |
| 15621 | +} | |
| 15622 | +VV_LOC void builtin__StrIntpData_process_str_intp_data(StrIntpData* data, strings__Builder* sb) { | |
| 15623 | + u32 x = data->fmt; | |
| 15624 | + StrIntpType typ = ((StrIntpType)((x & 0x1F))); | |
| 15625 | + int align = ((int)(((v__rshift_u32(x, (u64)5)) & 0x01))); | |
| 15626 | + bool upper_case = (((v__rshift_u32(x, (u64)7)) & 0x01)) > 0; | |
| 15627 | + int sign = ((int)(((v__rshift_u32(x, (u64)8)) & 0x01))); | |
| 15628 | + int precision = ((int)(((v__rshift_u32(x, (u64)9)) & 0x7F))); | |
| 15629 | + bool tail_zeros = (((v__rshift_u32(x, (u64)16)) & 0x01)) > 0; | |
| 15630 | + int width = ((int)(((i16)(((v__rshift_u32(x, (u64)17)) & 0x3FF))))); | |
| 15631 | + int base = (((int)(v__rshift_u32(x, (u64)27))) & 0xF); | |
| 15632 | + u8 fmt_pad_ch = ((u8)(((v__rshift_u32(x, (u64)31)) & 0xFF))); | |
| 15633 | + bool has_dynamic_width = ((data->dyn_flags & _const_str_intp_has_dynamic_width)) != 0; | |
| 15634 | + bool has_dynamic_precision = ((data->dyn_flags & _const_str_intp_has_dynamic_precision)) != 0; | |
| 15635 | + if (typ == StrIntpType__si_no_str) { | |
| 15636 | + return; | |
| 15637 | + } | |
| 15638 | + if (base > 0) { | |
| 15639 | + base += 2; | |
| 15640 | + } | |
| 15641 | + if (has_dynamic_width) { | |
| 15642 | + width = data->dyn_width; | |
| 15643 | + if (width < 0) { | |
| 15644 | + width = -width; | |
| 15645 | + align = 0; | |
| 15646 | + } else if (width > 0) { | |
| 15647 | + align = 1; | |
| 15648 | + } | |
| 15649 | + } | |
| 15650 | + if (has_dynamic_precision) { | |
| 15651 | + precision = data->dyn_precision; | |
| 15652 | + } | |
| 15653 | + u8 pad_ch = ((u8)(' ')); | |
| 15654 | + if (fmt_pad_ch > 0) { | |
| 15655 | + pad_ch = '0'; | |
| 15656 | + } | |
| 15657 | + int len0_set = (width > 0 ? (width) : (-1)); | |
| 15658 | + int len1_set = (has_dynamic_precision ? ((precision >= 0 ? (precision) : (-1))) : precision == 0x7F ? (-1) : (precision)); | |
| 15659 | + bool sign_set = sign == 1; | |
| 15660 | + strconv__BF_param bf = ((strconv__BF_param){ | |
| 15661 | + .pad_ch = pad_ch, | |
| 15662 | + .len0 = len0_set, | |
| 15663 | + .len1 = len1_set, | |
| 15664 | + .positive = true, | |
| 15665 | + .sign_flag = sign_set, | |
| 15666 | + .align = strconv__Align_text__left, | |
| 15667 | + .rm_tail_zero = tail_zeros, | |
| 15668 | + }); | |
| 15669 | + if (fmt_pad_ch == 0 || pad_ch == '0') { | |
| 15670 | + switch (align) { | |
| 15671 | + case 0: { | |
| 15672 | + bf.align = strconv__Align_text__left; | |
| 15673 | + break; | |
| 15674 | + } | |
| 15675 | + case 1: { | |
| 15676 | + bf.align = strconv__Align_text__right; | |
| 15677 | + break; | |
| 15678 | + } | |
| 15679 | + default: { | |
| 15680 | + { | |
| 15681 | + bf.align = strconv__Align_text__left; | |
| 15682 | + break; | |
| 15683 | + } | |
| 15684 | + } | |
| 15685 | + } | |
| 15686 | + | |
| 15687 | + } else { | |
| 15688 | + bf.align = strconv__Align_text__right; | |
| 15689 | + } | |
| 15690 | + { // Unsafe block | |
| 15691 | + if (typ == StrIntpType__si_s) { | |
| 15692 | + if (upper_case) { | |
| 15693 | + string s = builtin__string_to_upper(data->d.d_s); | |
| 15694 | + if (width == 0) { | |
| 15695 | + strings__Builder_write_string(sb, s); | |
| 15696 | + } else { | |
| 15697 | + strconv__format_str_sb(s, bf, sb); | |
| 15698 | + } | |
| 15699 | + builtin__string_free(&s); | |
| 15700 | + } else { | |
| 15701 | + if (width == 0) { | |
| 15702 | + strings__Builder_write_string(sb, data->d.d_s); | |
| 15703 | + } else { | |
| 15704 | + strconv__format_str_sb(data->d.d_s, bf, sb); | |
| 15705 | + } | |
| 15706 | + } | |
| 15707 | + return; | |
| 15708 | + } | |
| 15709 | + if (typ == StrIntpType__si_r) { | |
| 15710 | + if (width > 0) { | |
| 15711 | + if (upper_case) { | |
| 15712 | + string s = builtin__string_to_upper(data->d.d_s); | |
| 15713 | + for (int _t1 = 1; _t1 < (1 + ((width > 0 ? (width) : (0)))); ++_t1) { | |
| 15714 | + strings__Builder_write_string(sb, s); | |
| 15715 | + } | |
| 15716 | + builtin__string_free(&s); | |
| 15717 | + } else { | |
| 15718 | + for (int _t2 = 1; _t2 < (1 + ((width > 0 ? (width) : (0)))); ++_t2) { | |
| 15719 | + strings__Builder_write_string(sb, data->d.d_s); | |
| 15720 | + } | |
| 15721 | + } | |
| 15722 | + } | |
| 15723 | + return; | |
| 15724 | + } | |
| 15725 | + if (typ == StrIntpType__si_i8 || typ == StrIntpType__si_i16 || typ == StrIntpType__si_i32 || typ == StrIntpType__si_i64) { | |
| 15726 | + i64 d = data->d.d_i64; | |
| 15727 | + if (typ == StrIntpType__si_i8) { | |
| 15728 | + d = ((i64)(data->d.d_i8)); | |
| 15729 | + } else if (typ == StrIntpType__si_i16) { | |
| 15730 | + d = ((i64)(data->d.d_i16)); | |
| 15731 | + } else if (typ == StrIntpType__si_i32) { | |
| 15732 | + d = ((i64)(data->d.d_i32)); | |
| 15733 | + } | |
| 15734 | + if (base == 0) { | |
| 15735 | + if (d < 0) { | |
| 15736 | + bf.positive = false; | |
| 15737 | + } | |
| 15738 | + strconv__format_dec_sb(builtin__abs64(d), bf, sb); | |
| 15739 | + } else { | |
| 15740 | + if (base == 3) { | |
| 15741 | + base = 2; | |
| 15742 | + } | |
| 15743 | + i64 absd = d; | |
| 15744 | + bool write_minus = false; | |
| 15745 | + if (d < 0 && pad_ch != ' ') { | |
| 15746 | + absd = -d; | |
| 15747 | + write_minus = true; | |
| 15748 | + } | |
| 15749 | + string hx = strconv__format_int(absd, base); | |
| 15750 | + if (upper_case) { | |
| 15751 | + string tmp = hx; | |
| 15752 | + hx = builtin__string_to_upper(hx); | |
| 15753 | + builtin__string_free(&tmp); | |
| 15754 | + } | |
| 15755 | + if (write_minus) { | |
| 15756 | + strings__Builder_write_u8(sb, '-'); | |
| 15757 | + bf.len0--; | |
| 15758 | + } | |
| 15759 | + if (width == 0) { | |
| 15760 | + strings__Builder_write_string(sb, hx); | |
| 15761 | + } else { | |
| 15762 | + strconv__format_str_sb(hx, bf, sb); | |
| 15763 | + } | |
| 15764 | + builtin__string_free(&hx); | |
| 15765 | + } | |
| 15766 | + return; | |
| 15767 | + } | |
| 15768 | + if (typ == StrIntpType__si_u8 || typ == StrIntpType__si_u16 || typ == StrIntpType__si_u32 || typ == StrIntpType__si_u64) { | |
| 15769 | + u64 d = data->d.d_u64; | |
| 15770 | + if (typ == StrIntpType__si_u8) { | |
| 15771 | + d = ((u64)(data->d.d_u8)); | |
| 15772 | + } else if (typ == StrIntpType__si_u16) { | |
| 15773 | + d = ((u64)(data->d.d_u16)); | |
| 15774 | + } else if (typ == StrIntpType__si_u32) { | |
| 15775 | + d = ((u64)(data->d.d_u32)); | |
| 15776 | + } | |
| 15777 | + if (base == 0) { | |
| 15778 | + strconv__format_dec_sb(d, bf, sb); | |
| 15779 | + } else { | |
| 15780 | + if (base == 3) { | |
| 15781 | + base = 2; | |
| 15782 | + } | |
| 15783 | + string hx = strconv__format_uint(d, base); | |
| 15784 | + if (upper_case) { | |
| 15785 | + string tmp = hx; | |
| 15786 | + hx = builtin__string_to_upper(hx); | |
| 15787 | + builtin__string_free(&tmp); | |
| 15788 | + } | |
| 15789 | + if (width == 0) { | |
| 15790 | + strings__Builder_write_string(sb, hx); | |
| 15791 | + } else { | |
| 15792 | + strconv__format_str_sb(hx, bf, sb); | |
| 15793 | + } | |
| 15794 | + builtin__string_free(&hx); | |
| 15795 | + } | |
| 15796 | + return; | |
| 15797 | + } | |
| 15798 | + if (typ == StrIntpType__si_p) { | |
| 15799 | + u64 d = ((u64)(data->d.d_p)); | |
| 15800 | + base = 16; | |
| 15801 | + if (base == 0) { | |
| 15802 | + if (width == 0) { | |
| 15803 | + string d_str = builtin__u64_str(d); | |
| 15804 | + strings__Builder_write_string(sb, d_str); | |
| 15805 | + builtin__string_free(&d_str); | |
| 15806 | + return; | |
| 15807 | + } | |
| 15808 | + strconv__format_dec_sb(d, bf, sb); | |
| 15809 | + } else { | |
| 15810 | + string hx = strconv__format_uint(d, base); | |
| 15811 | + if (upper_case) { | |
| 15812 | + string tmp = hx; | |
| 15813 | + hx = builtin__string_to_upper(hx); | |
| 15814 | + builtin__string_free(&tmp); | |
| 15815 | + } | |
| 15816 | + if (width == 0) { | |
| 15817 | + strings__Builder_write_string(sb, hx); | |
| 15818 | + } else { | |
| 15819 | + strconv__format_str_sb(hx, bf, sb); | |
| 15820 | + } | |
| 15821 | + builtin__string_free(&hx); | |
| 15822 | + } | |
| 15823 | + return; | |
| 15824 | + } | |
| 15825 | + bool use_default_str = false; | |
| 15826 | + if (width == 0 && precision == 0x7F) { | |
| 15827 | + bf.len1 = 3; | |
| 15828 | + use_default_str = true; | |
| 15829 | + } | |
| 15830 | + if (bf.len1 < 0) { | |
| 15831 | + bf.len1 = 3; | |
| 15832 | + } | |
| 15833 | + switch (typ) { | |
| 15834 | + case StrIntpType__si_f32: { | |
| 15835 | + #if !defined(CUSTOM_DEFINE_nofloat) | |
| 15836 | + { | |
| 15837 | + if (use_default_str) { | |
| 15838 | + string f = builtin__f32_str(data->d.d_f32); | |
| 15839 | + if (upper_case) { | |
| 15840 | + string tmp = f; | |
| 15841 | + f = builtin__string_to_upper(f); | |
| 15842 | + builtin__string_free(&tmp); | |
| 15843 | + } | |
| 15844 | + strings__Builder_write_string(sb, f); | |
| 15845 | + builtin__string_free(&f); | |
| 15846 | + } else { | |
| 15847 | + if (data->d.d_f32 < 0) { | |
| 15848 | + bf.positive = false; | |
| 15849 | + } | |
| 15850 | + string f = strconv__format_fl(data->d.d_f32, bf); | |
| 15851 | + if (upper_case) { | |
| 15852 | + string tmp = f; | |
| 15853 | + f = builtin__string_to_upper(f); | |
| 15854 | + builtin__string_free(&tmp); | |
| 15855 | + } | |
| 15856 | + strings__Builder_write_string(sb, f); | |
| 15857 | + builtin__string_free(&f); | |
| 15858 | + } | |
| 15859 | + } | |
| 15860 | + #endif | |
| 15861 | + break; | |
| 15862 | + } | |
| 15863 | + case StrIntpType__si_f64: { | |
| 15864 | + #if !defined(CUSTOM_DEFINE_nofloat) | |
| 15865 | + { | |
| 15866 | + if (use_default_str) { | |
| 15867 | + string f = builtin__f64_str(data->d.d_f64); | |
| 15868 | + if (upper_case) { | |
| 15869 | + string tmp = f; | |
| 15870 | + f = builtin__string_to_upper(f); | |
| 15871 | + builtin__string_free(&tmp); | |
| 15872 | + } | |
| 15873 | + strings__Builder_write_string(sb, f); | |
| 15874 | + builtin__string_free(&f); | |
| 15875 | + } else { | |
| 15876 | + if (data->d.d_f64 < 0) { | |
| 15877 | + bf.positive = false; | |
| 15878 | + } | |
| 15879 | + strconv__Float64u _t5 = ((strconv__Float64u){.f = data->d.d_f64,}); | |
| 15880 | + strconv__Float64u f_union = _t5; | |
| 15881 | + if (f_union.u == _const_strconv__double_minus_zero) { | |
| 15882 | + bf.positive = false; | |
| 15883 | + } | |
| 15884 | + string f = strconv__format_fl(data->d.d_f64, bf); | |
| 15885 | + if (upper_case) { | |
| 15886 | + string tmp = f; | |
| 15887 | + f = builtin__string_to_upper(f); | |
| 15888 | + builtin__string_free(&tmp); | |
| 15889 | + } | |
| 15890 | + strings__Builder_write_string(sb, f); | |
| 15891 | + builtin__string_free(&f); | |
| 15892 | + } | |
| 15893 | + } | |
| 15894 | + #endif | |
| 15895 | + break; | |
| 15896 | + } | |
| 15897 | + case StrIntpType__si_g32: { | |
| 15898 | + if (use_default_str) { | |
| 15899 | + #if !defined(CUSTOM_DEFINE_nofloat) | |
| 15900 | + { | |
| 15901 | + string f = builtin__f32_strg(data->d.d_f32); | |
| 15902 | + if (upper_case) { | |
| 15903 | + string tmp = f; | |
| 15904 | + f = builtin__string_to_upper(f); | |
| 15905 | + builtin__string_free(&tmp); | |
| 15906 | + } | |
| 15907 | + strings__Builder_write_string(sb, f); | |
| 15908 | + builtin__string_free(&f); | |
| 15909 | + } | |
| 15910 | + #endif | |
| 15911 | + } else { | |
| 15912 | + if (data->d.d_f32 == _const_strconv__single_plus_zero) { | |
| 15913 | + string tmp_str = _S("0"); | |
| 15914 | + strconv__format_str_sb(tmp_str, bf, sb); | |
| 15915 | + builtin__string_free(&tmp_str); | |
| 15916 | + return; | |
| 15917 | + } | |
| 15918 | + if (data->d.d_f32 == _const_strconv__single_minus_zero) { | |
| 15919 | + string tmp_str = _S("-0"); | |
| 15920 | + strconv__format_str_sb(tmp_str, bf, sb); | |
| 15921 | + builtin__string_free(&tmp_str); | |
| 15922 | + return; | |
| 15923 | + } | |
| 15924 | + if (data->d.d_f32 == _const_strconv__single_plus_infinity) { | |
| 15925 | + string tmp_str = _S("+inf"); | |
| 15926 | + if (upper_case) { | |
| 15927 | + tmp_str = _S("+INF"); | |
| 15928 | + } | |
| 15929 | + strconv__format_str_sb(tmp_str, bf, sb); | |
| 15930 | + builtin__string_free(&tmp_str); | |
| 15931 | + } | |
| 15932 | + if (data->d.d_f32 == _const_strconv__single_minus_infinity) { | |
| 15933 | + string tmp_str = _S("-inf"); | |
| 15934 | + if (upper_case) { | |
| 15935 | + tmp_str = _S("-INF"); | |
| 15936 | + } | |
| 15937 | + strconv__format_str_sb(tmp_str, bf, sb); | |
| 15938 | + builtin__string_free(&tmp_str); | |
| 15939 | + } | |
| 15940 | + if (data->d.d_f32 < 0) { | |
| 15941 | + bf.positive = false; | |
| 15942 | + } | |
| 15943 | + f32 d = builtin__fabs32(data->d.d_f32); | |
| 15944 | + if (d < ((f32)(999999.0)) && d >= ((f32)(0.00001))) { | |
| 15945 | + string f = strconv__format_fl(data->d.d_f32, bf); | |
| 15946 | + if (upper_case) { | |
| 15947 | + string tmp = f; | |
| 15948 | + f = builtin__string_to_upper(f); | |
| 15949 | + builtin__string_free(&tmp); | |
| 15950 | + } | |
| 15951 | + strings__Builder_write_string(sb, f); | |
| 15952 | + builtin__string_free(&f); | |
| 15953 | + return; | |
| 15954 | + } | |
| 15955 | + bf.len1--; | |
| 15956 | + string f = strconv__format_es(data->d.d_f32, bf); | |
| 15957 | + if (upper_case) { | |
| 15958 | + string tmp = f; | |
| 15959 | + f = builtin__string_to_upper(f); | |
| 15960 | + builtin__string_free(&tmp); | |
| 15961 | + } | |
| 15962 | + strings__Builder_write_string(sb, f); | |
| 15963 | + builtin__string_free(&f); | |
| 15964 | + } | |
| 15965 | + break; | |
| 15966 | + } | |
| 15967 | + case StrIntpType__si_g64: { | |
| 15968 | + if (use_default_str) { | |
| 15969 | + #if !defined(CUSTOM_DEFINE_nofloat) | |
| 15970 | + { | |
| 15971 | + string f = builtin__f64_strg(data->d.d_f64); | |
| 15972 | + if (upper_case) { | |
| 15973 | + string tmp = f; | |
| 15974 | + f = builtin__string_to_upper(f); | |
| 15975 | + builtin__string_free(&tmp); | |
| 15976 | + } | |
| 15977 | + strings__Builder_write_string(sb, f); | |
| 15978 | + builtin__string_free(&f); | |
| 15979 | + } | |
| 15980 | + #endif | |
| 15981 | + } else { | |
| 15982 | + if (data->d.d_f64 == _const_strconv__double_plus_zero) { | |
| 15983 | + string tmp_str = _S("0"); | |
| 15984 | + strconv__format_str_sb(tmp_str, bf, sb); | |
| 15985 | + builtin__string_free(&tmp_str); | |
| 15986 | + return; | |
| 15987 | + } | |
| 15988 | + if (data->d.d_f64 == _const_strconv__double_minus_zero) { | |
| 15989 | + string tmp_str = _S("-0"); | |
| 15990 | + strconv__format_str_sb(tmp_str, bf, sb); | |
| 15991 | + builtin__string_free(&tmp_str); | |
| 15992 | + return; | |
| 15993 | + } | |
| 15994 | + if (data->d.d_f64 == _const_strconv__double_plus_infinity) { | |
| 15995 | + string tmp_str = _S("+inf"); | |
| 15996 | + if (upper_case) { | |
| 15997 | + tmp_str = _S("+INF"); | |
| 15998 | + } | |
| 15999 | + strconv__format_str_sb(tmp_str, bf, sb); | |
| 16000 | + builtin__string_free(&tmp_str); | |
| 16001 | + } | |
| 16002 | + if (data->d.d_f64 == _const_strconv__double_minus_infinity) { | |
| 16003 | + string tmp_str = _S("-inf"); | |
| 16004 | + if (upper_case) { | |
| 16005 | + tmp_str = _S("-INF"); | |
| 16006 | + } | |
| 16007 | + strconv__format_str_sb(tmp_str, bf, sb); | |
| 16008 | + builtin__string_free(&tmp_str); | |
| 16009 | + } | |
| 16010 | + if (data->d.d_f64 < 0) { | |
| 16011 | + bf.positive = false; | |
| 16012 | + } | |
| 16013 | + f64 d = builtin__fabs64(data->d.d_f64); | |
| 16014 | + if (d < ((f64)(999999.0)) && d >= ((f64)(0.00001))) { | |
| 16015 | + string f = strconv__format_fl(data->d.d_f64, bf); | |
| 16016 | + if (upper_case) { | |
| 16017 | + string tmp = f; | |
| 16018 | + f = builtin__string_to_upper(f); | |
| 16019 | + builtin__string_free(&tmp); | |
| 16020 | + } | |
| 16021 | + strings__Builder_write_string(sb, f); | |
| 16022 | + builtin__string_free(&f); | |
| 16023 | + return; | |
| 16024 | + } | |
| 16025 | + bf.len1--; | |
| 16026 | + string f = strconv__format_es(data->d.d_f64, bf); | |
| 16027 | + if (upper_case) { | |
| 16028 | + string tmp = f; | |
| 16029 | + f = builtin__string_to_upper(f); | |
| 16030 | + builtin__string_free(&tmp); | |
| 16031 | + } | |
| 16032 | + strings__Builder_write_string(sb, f); | |
| 16033 | + builtin__string_free(&f); | |
| 16034 | + } | |
| 16035 | + break; | |
| 16036 | + } | |
| 16037 | + case StrIntpType__si_e32: { | |
| 16038 | + #if !defined(CUSTOM_DEFINE_nofloat) | |
| 16039 | + { | |
| 16040 | + if (use_default_str) { | |
| 16041 | + string f = builtin__f32_str(data->d.d_f32); | |
| 16042 | + if (upper_case) { | |
| 16043 | + string tmp = f; | |
| 16044 | + f = builtin__string_to_upper(f); | |
| 16045 | + builtin__string_free(&tmp); | |
| 16046 | + } | |
| 16047 | + strings__Builder_write_string(sb, f); | |
| 16048 | + builtin__string_free(&f); | |
| 16049 | + } else { | |
| 16050 | + if (data->d.d_f32 < 0) { | |
| 16051 | + bf.positive = false; | |
| 16052 | + } | |
| 16053 | + string f = strconv__format_es(data->d.d_f32, bf); | |
| 16054 | + if (upper_case) { | |
| 16055 | + string tmp = f; | |
| 16056 | + f = builtin__string_to_upper(f); | |
| 16057 | + builtin__string_free(&tmp); | |
| 16058 | + } | |
| 16059 | + strings__Builder_write_string(sb, f); | |
| 16060 | + builtin__string_free(&f); | |
| 16061 | + } | |
| 16062 | + } | |
| 16063 | + #endif | |
| 16064 | + break; | |
| 16065 | + } | |
| 16066 | + case StrIntpType__si_e64: { | |
| 16067 | + #if !defined(CUSTOM_DEFINE_nofloat) | |
| 16068 | + { | |
| 16069 | + if (use_default_str) { | |
| 16070 | + string f = builtin__f64_str(data->d.d_f64); | |
| 16071 | + if (upper_case) { | |
| 16072 | + string tmp = f; | |
| 16073 | + f = builtin__string_to_upper(f); | |
| 16074 | + builtin__string_free(&tmp); | |
| 16075 | + } | |
| 16076 | + strings__Builder_write_string(sb, f); | |
| 16077 | + builtin__string_free(&f); | |
| 16078 | + } else { | |
| 16079 | + if (data->d.d_f64 < 0) { | |
| 16080 | + bf.positive = false; | |
| 16081 | + } | |
| 16082 | + string f = strconv__format_es(data->d.d_f64, bf); | |
| 16083 | + if (upper_case) { | |
| 16084 | + string tmp = f; | |
| 16085 | + f = builtin__string_to_upper(f); | |
| 16086 | + builtin__string_free(&tmp); | |
| 16087 | + } | |
| 16088 | + strings__Builder_write_string(sb, f); | |
| 16089 | + builtin__string_free(&f); | |
| 16090 | + } | |
| 16091 | + } | |
| 16092 | + #endif | |
| 16093 | + break; | |
| 16094 | + } | |
| 16095 | + case StrIntpType__si_c: { | |
| 16096 | + string ss = builtin__utf32_to_str(data->d.d_c); | |
| 16097 | + strings__Builder_write_string(sb, ss); | |
| 16098 | + builtin__string_free(&ss); | |
| 16099 | + break; | |
| 16100 | + } | |
| 16101 | + case StrIntpType__si_vp: { | |
| 16102 | + string ss = builtin__u64_hex(((u64)(data->d.d_vp))); | |
| 16103 | + strings__Builder_write_string(sb, ss); | |
| 16104 | + builtin__string_free(&ss); | |
| 16105 | + break; | |
| 16106 | + } | |
| 16107 | + case StrIntpType__si_no_str: | |
| 16108 | + case StrIntpType__si_u8: | |
| 16109 | + case StrIntpType__si_i8: | |
| 16110 | + case StrIntpType__si_u16: | |
| 16111 | + case StrIntpType__si_i16: | |
| 16112 | + case StrIntpType__si_u32: | |
| 16113 | + case StrIntpType__si_i32: | |
| 16114 | + case StrIntpType__si_u64: | |
| 16115 | + case StrIntpType__si_i64: | |
| 16116 | + case StrIntpType__si_s: | |
| 16117 | + case StrIntpType__si_p: | |
| 16118 | + case StrIntpType__si_r: | |
| 16119 | + default: { | |
| 16120 | + { | |
| 16121 | + strings__Builder_write_string(sb, _S("***ERROR!***")); | |
| 16122 | + break; | |
| 16123 | + } | |
| 16124 | + } | |
| 16125 | + } | |
| 16126 | + | |
| 16127 | + } | |
| 16128 | +} | |
| 16129 | +string builtin__str_intp(int data_len, StrIntpData* input_base) { | |
| 16130 | + strings__Builder res = strings__new_builder(64); | |
| 16131 | + for (int i = 0; i < data_len; i++) { | |
| 16132 | + StrIntpData* data = &input_base[i]; | |
| 16133 | + if (data->str.len != 0) { | |
| 16134 | + strings__Builder_write_string(&res, data->str); | |
| 16135 | + } | |
| 16136 | + if (data->fmt != 0) { | |
| 16137 | + builtin__StrIntpData_process_str_intp_data(data, (voidptr)&res); | |
| 16138 | + } | |
| 16139 | + } | |
| 16140 | + string ret = strings__Builder_str(&res); | |
| 16141 | + strings__Builder_free(&res); | |
| 16142 | + return ret; | |
| 16143 | +} | |
| 16144 | +inline string builtin__str_intp_sq(string in_str) { | |
| 16145 | + return builtin__string_plus_many(5, _MOV((string[5]){_S("builtin__str_intp(2, _MOV((StrIntpData[]){{_S(\"\'\"), "), _const_si_s_code, _S(", {.d_s = "), in_str, _S("}, 0, 0, 0},{_S(\"\'\"), 0, {0}, 0, 0, 0}}))")})); | |
| 16146 | +} | |
| 16147 | +inline string builtin__str_intp_rune(string in_str) { | |
| 16148 | + return builtin__string_plus_many(5, _MOV((string[5]){_S("builtin__str_intp(2, _MOV((StrIntpData[]){{_S(\"`\"), "), _const_si_s_code, _S(", {.d_s = "), in_str, _S("}, 0, 0, 0},{_S(\"`\"), 0, {0}, 0, 0, 0}}))")})); | |
| 16149 | +} | |
| 16150 | +inline string builtin__str_intp_g32(string in_str) { | |
| 16151 | + return builtin__string_plus_many(5, _MOV((string[5]){_S("builtin__str_intp(1, _MOV((StrIntpData[]){{_SLIT0, "), _const_si_g32_code, _S(", {.d_f32 = "), in_str, _S(" }, 0, 0, 0}}))")})); | |
| 16152 | +} | |
| 16153 | +inline string builtin__str_intp_g64(string in_str) { | |
| 16154 | + return builtin__string_plus_many(5, _MOV((string[5]){_S("builtin__str_intp(1, _MOV((StrIntpData[]){{_SLIT0, "), _const_si_g64_code, _S(", {.d_f64 = "), in_str, _S(" }, 0, 0, 0}}))")})); | |
| 16155 | +} | |
| 16156 | +string builtin__str_intp_sub(string base_str, string in_str) { | |
| 16157 | + _option_int _t1 = builtin__string_index(base_str, _S("%%")); | |
| 16158 | + if (_t1.state != 0) { | |
| 16159 | + builtin__eprintln(_S("No string interpolation %% parameters")); | |
| 16160 | + builtin___v_exit(1); | |
| 16161 | + VUNREACHABLE(); | |
| 16162 | + ; | |
| 16163 | + } | |
| 16164 | + | |
| 16165 | + int index = (*(int*)_t1.data); | |
| 16166 | + { // Unsafe block | |
| 16167 | + string st_str = builtin__string_substr(base_str, 0, index); | |
| 16168 | + if (index + 2 < base_str.len) { | |
| 16169 | + string en_str = builtin__string_substr(base_str, index + 2, 2147483647); | |
| 16170 | + string res_str = builtin__string_plus_many(9, _MOV((string[9]){_S("builtin__str_intp(2, _MOV((StrIntpData[]){{_S(\""), st_str, _S("\"), "), _const_si_s_code, _S(", {.d_s = "), in_str, _S(" }, 0, 0, 0},{_S(\""), en_str, _S("\"), 0, {0}, 0, 0, 0}}))")})); | |
| 16171 | + builtin__string_free(&st_str); | |
| 16172 | + builtin__string_free(&en_str); | |
| 16173 | + return res_str; | |
| 16174 | + } | |
| 16175 | + string res2_str = builtin__string_plus_many(7, _MOV((string[7]){_S("builtin__str_intp(1, _MOV((StrIntpData[]){{_S(\""), st_str, _S("\"), "), _const_si_s_code, _S(", {.d_s = "), in_str, _S(" }, 0, 0, 0}}))")})); | |
| 16176 | + builtin__string_free(&st_str); | |
| 16177 | + return res2_str; | |
| 16178 | + } | |
| 16179 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 16180 | +} | |
| 16181 | +u16* builtin__string_to_wide(string _str, ToWideConfig param) { | |
| 16182 | + #if 0 | |
| 16183 | + { | |
| 16184 | + } | |
| 16185 | + #else | |
| 16186 | + { | |
| 16187 | + Array_rune srunes = builtin__string_runes(_str); | |
| 16188 | + { // Unsafe block | |
| 16189 | + u16* result = ((u16*)(builtin__vcalloc_noscan((srunes.len + 1) * 2))); | |
| 16190 | + for (int i = 0; i < srunes.len; ++i) { | |
| 16191 | + rune r = ((rune*)srunes.data)[i]; | |
| 16192 | + result[i] = ((u16)(r)); | |
| 16193 | + } | |
| 16194 | + result[srunes.len] = 0; | |
| 16195 | + return result; | |
| 16196 | + } | |
| 16197 | + } | |
| 16198 | + #endif | |
| 16199 | + return 0; | |
| 16200 | +} | |
| 16201 | +string builtin__string_from_wide(u16* _wstr) { | |
| 16202 | + #if 0 | |
| 16203 | + { | |
| 16204 | + } | |
| 16205 | + #else | |
| 16206 | + { | |
| 16207 | + int i = 0; | |
| 16208 | + for (;;) { | |
| 16209 | + if (!(_wstr[i] != 0)) break; | |
| 16210 | + i++; | |
| 16211 | + } | |
| 16212 | + return builtin__string_from_wide2(_wstr, i); | |
| 16213 | + } | |
| 16214 | + #endif | |
| 16215 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 16216 | +} | |
| 16217 | +string builtin__string_from_wide2(u16* _wstr, int len) { | |
| 16218 | + #if 0 | |
| 16219 | + { | |
| 16220 | + } | |
| 16221 | + #else | |
| 16222 | + { | |
| 16223 | + strings__Builder sb = strings__new_builder(len); | |
| 16224 | + for (int i = 0; i < len; i++) { | |
| 16225 | + rune u = ((rune)(_wstr[i])); | |
| 16226 | + strings__Builder_write_rune(&sb, u); | |
| 16227 | + } | |
| 16228 | + string res = strings__Builder_str(&sb); | |
| 16229 | + strings__Builder_free(&sb); | |
| 16230 | + return res; | |
| 16231 | + } | |
| 16232 | + #endif | |
| 16233 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 16234 | +} | |
| 16235 | +Array_u8 builtin__wide_to_ansi(u16* _wstr) { | |
| 16236 | + #if 0 | |
| 16237 | + { | |
| 16238 | + } | |
| 16239 | + #else | |
| 16240 | + { | |
| 16241 | + string s = builtin__string_from_wide(_wstr); | |
| 16242 | + Array_u8 str_to = builtin____new_array_with_default(s.len + 1, 0, sizeof(u8), 0); | |
| 16243 | + builtin__vmemcpy(str_to.data, s.str, s.len); | |
| 16244 | + return str_to; | |
| 16245 | + } | |
| 16246 | + #endif | |
| 16247 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | |
| 16248 | +} | |
| 16249 | +int builtin__utf8_char_len(u8 b) { | |
| 16250 | + return ((int)((((v__rshift_u32(((u32)(0xe5000000U)), (u64)(((v__rshift_u8(b, (u64)3)) & 0x1e)))) & 3)) + 1)); | |
| 16251 | +} | |
| 16252 | +string builtin__utf32_to_str(u32 code) { | |
| 16253 | + { // Unsafe block | |
| 16254 | + u8* buffer = builtin__malloc_noscan(5); | |
| 16255 | + string res = builtin__utf32_to_str_no_malloc(code, buffer); | |
| 16256 | + if (res.len == 0) { | |
| 16257 | + builtin___v_free(buffer); | |
| 16258 | + } | |
| 16259 | + return res; | |
| 16260 | + } | |
| 16261 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 16262 | +} | |
| 16263 | +string builtin__utf32_to_str_no_malloc(u32 code, u8* buf) { | |
| 16264 | + { // Unsafe block | |
| 16265 | + int len = builtin__utf32_decode_to_buffer(code, buf); | |
| 16266 | + if (len == 0) { | |
| 16267 | + return _S(""); | |
| 16268 | + } | |
| 16269 | + buf[len] = 0; | |
| 16270 | + return builtin__tos(buf, len); | |
| 16271 | + } | |
| 16272 | + return (string){.str=(byteptr)"", .is_lit=1}; | |
| 16273 | +} | |
| 16274 | +int builtin__utf32_decode_to_buffer(u32 code, u8* buf) { | |
| 16275 | + { // Unsafe block | |
| 16276 | + int icode = ((int)(code)); | |
| 16277 | + u8* buffer = ((u8*)(buf)); | |
| 16278 | + if (icode <= 127) { | |
| 16279 | + buffer[0] = ((u8)(icode)); | |
| 16280 | + return 1; | |
| 16281 | + } else if (icode <= 2047) { | |
| 16282 | + buffer[0] = (192 | ((u8)(v__rshift_int(icode, (u64)6)))); | |
| 16283 | + buffer[1] = (128 | ((u8)((icode & 63)))); | |
| 16284 | + return 2; | |
| 16285 | + } else if (icode <= 65535) { | |
| 16286 | + buffer[0] = (224 | ((u8)(v__rshift_int(icode, (u64)12)))); | |
| 16287 | + buffer[1] = (128 | ((((u8)(v__rshift_int(icode, (u64)6))) & 63))); | |
| 16288 | + buffer[2] = (128 | ((u8)((icode & 63)))); | |
| 16289 | + return 3; | |
| 16290 | + } else if (icode <= 1114111) { | |
| 16291 | + buffer[0] = (240 | ((u8)(v__rshift_int(icode, (u64)18)))); | |
| 16292 | + buffer[1] = (128 | ((((u8)(v__rshift_int(icode, (u64)12))) & 63))); | |
| 16293 | + buffer[2] = (128 | ((((u8)(v__rshift_int(icode, (u64)6))) & 63))); | |
| 16294 | + buffer[3] = (128 | ((u8)((icode & 63)))); | |
| 16295 | + return 4; | |
| 16296 | + } | |
| 16297 | + } | |
| 16298 | + return 0; | |
| 16299 | +} | |
| 16300 | +int builtin__string_utf32_code(string _rune) { | |
| 16301 | + if (_rune.len > 4) { | |
| 16302 | + return 0; | |
| 16303 | + } | |
| 16304 | + return ((int)(builtin__impl_utf8_to_utf32(_rune.str, _rune.len))); | |
| 16305 | +} | |
| 16306 | +_result_rune Array_u8_utf8_to_utf32(Array_u8 _bytes) { | |
| 16307 | + if (_bytes.len > 4) { | |
| 16308 | + return (_result_rune){ .is_error=true, .err=builtin___v_error(_S("attempted to decode too many bytes, utf-8 is limited to four bytes maximum")), .data={E_STRUCT} }; | |
| 16309 | + } | |
| 16310 | + _result_rune _t2; | |
| 16311 | + builtin___result_ok(&(rune[]) { builtin__impl_utf8_to_utf32(_bytes.data, _bytes.len) }, (_result*)(&_t2), sizeof(rune)); | |
| 16312 | + | |
| 16313 | + return _t2; | |
| 16314 | +} | |
| 16315 | +inline VV_LOC bool builtin__utf8_is_continuation(u8 b) { | |
| 16316 | + return ((b & 0xc0)) == 0x80; | |
| 16317 | +} | |
| 16318 | +VV_LOC multi_return_rune_int builtin__utf8_decode_rune(u8* _bytes, int available_len) { | |
| 16319 | + if (available_len <= 0) { | |
| 16320 | + return (multi_return_rune_int){.arg0=0, .arg1=0}; | |
| 16321 | + } | |
| 16322 | + u8 b0 = _bytes[0]; | |
| 16323 | + if (b0 < 0x80) { | |
| 16324 | + return (multi_return_rune_int){.arg0=((rune)(b0)), .arg1=1}; | |
| 16325 | + } | |
| 16326 | + if (b0 < 0xc2) { | |
| 16327 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | |
| 16328 | + } | |
| 16329 | + int _t4; /* if prepend */ | |
| 16330 | + if (b0 < 0xe0) { | |
| 16331 | + _t4 = 2; | |
| 16332 | + goto _t5; | |
| 16333 | + }; | |
| 16334 | + { | |
| 16335 | + if (b0 < 0xf0) { | |
| 16336 | + _t4 = 3; | |
| 16337 | + goto _t5; | |
| 16338 | + }; | |
| 16339 | + { | |
| 16340 | + if (b0 < 0xf5) { | |
| 16341 | + _t4 = 4; | |
| 16342 | + goto _t5; | |
| 16343 | + }; | |
| 16344 | + { | |
| 16345 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | |
| 16346 | + } | |
| 16347 | + } | |
| 16348 | + } | |
| 16349 | + _t5: {}; | |
| 16350 | + int char_len = _t4; | |
| 16351 | + if (available_len < char_len) { | |
| 16352 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | |
| 16353 | + } | |
| 16354 | + u8 b1 = _bytes[1]; | |
| 16355 | + if (!builtin__utf8_is_continuation(b1)) { | |
| 16356 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | |
| 16357 | + } | |
| 16358 | + if (char_len == 2) { | |
| 16359 | + return (multi_return_rune_int){.arg0=((v__lshift_rune(((((rune)(b0)) & 0x1f)), (u64)6)) | ((((rune)(b1)) & 0x3f))), .arg1=2}; | |
| 16360 | + } | |
| 16361 | + if (b0 == 0xe0 && b1 < 0xa0) { | |
| 16362 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | |
| 16363 | + } | |
| 16364 | + if (b0 == 0xed && b1 >= 0xa0) { | |
| 16365 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | |
| 16366 | + } | |
| 16367 | + u8 b2 = _bytes[2]; | |
| 16368 | + if (!builtin__utf8_is_continuation(b2)) { | |
| 16369 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | |
| 16370 | + } | |
| 16371 | + if (char_len == 3) { | |
| 16372 | + return (multi_return_rune_int){.arg0=(((v__lshift_rune(((((rune)(b0)) & 0x0f)), (u64)12)) | (v__lshift_rune(((((rune)(b1)) & 0x3f)), (u64)6))) | ((((rune)(b2)) & 0x3f))), .arg1=3}; | |
| 16373 | + } | |
| 16374 | + if (b0 == 0xf0 && b1 < 0x90) { | |
| 16375 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | |
| 16376 | + } | |
| 16377 | + if (b0 == 0xf4 && b1 > 0x8f) { | |
| 16378 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | |
| 16379 | + } | |
| 16380 | + u8 b3 = _bytes[3]; | |
| 16381 | + if (!builtin__utf8_is_continuation(b3)) { | |
| 16382 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | |
| 16383 | + } | |
| 16384 | + return (multi_return_rune_int){.arg0=((((v__lshift_rune(((((rune)(b0)) & 0x07)), (u64)18)) | (v__lshift_rune(((((rune)(b1)) & 0x3f)), (u64)12))) | (v__lshift_rune(((((rune)(b2)) & 0x3f)), (u64)6))) | ((((rune)(b3)) & 0x3f))), .arg1=4}; | |
| 16385 | +} | |
| 16386 | +VV_LOC rune builtin__impl_utf8_to_utf32(u8* _bytes, int _bytes_len) { | |
| 16387 | + if (_bytes_len == 0 || _bytes_len > 4) { | |
| 16388 | + return 0; | |
| 16389 | + } | |
| 16390 | + multi_return_rune_int mr_4267 = builtin__utf8_decode_rune(_bytes, _bytes_len); | |
| 16391 | + rune r = mr_4267.arg0; | |
| 16392 | + int len = mr_4267.arg1; | |
| 16393 | + if (len != _bytes_len) { | |
| 16394 | + return _const_utf8_replacement_rune; | |
| 16395 | + } | |
| 16396 | + return r; | |
| 16397 | +} | |
| 16398 | +int builtin__utf8_str_visible_length(string s) { | |
| 16399 | + return builtin__utf8_grapheme_visible_length(s); | |
| 16400 | +} | |
| 16401 | +Array_u8 builtin__string_to_ansi_not_null_terminated(string _str) { | |
| 16402 | + u16* wstr = builtin__string_to_wide(_str, ((ToWideConfig){.from_ansi = 0,})); | |
| 16403 | + Array_u8 ansi = builtin__wide_to_ansi(wstr); | |
| 16404 | + if (ansi.len > 0) { | |
| 16405 | + ansi.len--; | |
| 16406 | + } | |
| 16407 | + return ansi; | |
| 16408 | +} | |
| 16409 | +inline bool builtin__ArrayFlags_is_empty(ArrayFlags* e) { | |
| 16410 | + return ((int)(*e)) == 0; | |
| 16411 | +} | |
| 16412 | +inline bool builtin__ArrayFlags_has(ArrayFlags* e, ArrayFlags flag_) { | |
| 16413 | + return ((((int)(*e)) & (((int)(flag_))))) != 0; | |
| 16414 | +} | |
| 16415 | +inline bool builtin__ArrayFlags_all(ArrayFlags* e, ArrayFlags flag_) { | |
| 16416 | + return ((((int)(*e)) & (((int)(flag_))))) == ((int)(flag_)); | |
| 16417 | +} | |
| 16418 | +inline void builtin__ArrayFlags_set(ArrayFlags* e, ArrayFlags flag_) { | |
| 16419 | + { // Unsafe block | |
| 16420 | + *e = ((ArrayFlags)((((int)(*e)) | (((int)(flag_)))))); | |
| 16421 | + } | |
| 16422 | +} | |
| 16423 | +inline void builtin__ArrayFlags_set_all(ArrayFlags* e) { | |
| 16424 | + { // Unsafe block | |
| 16425 | + *e = ((ArrayFlags)(0b1111111)); | |
| 16426 | + } | |
| 16427 | +} | |
| 16428 | +inline void builtin__ArrayFlags_clear(ArrayFlags* e, ArrayFlags flag_) { | |
| 16429 | + { // Unsafe block | |
| 16430 | + *e = ((ArrayFlags)((((int)(*e)) & ~(((int)(flag_)))))); | |
| 16431 | + } | |
| 16432 | +} | |
| 16433 | +inline void builtin__ArrayFlags_clear_all(ArrayFlags* e) { | |
| 16434 | + { // Unsafe block | |
| 16435 | + *e = ((ArrayFlags)(0)); | |
| 16436 | + } | |
| 16437 | +} | |
| 16438 | +inline void builtin__ArrayFlags_toggle(ArrayFlags* e, ArrayFlags flag_) { | |
| 16439 | + { // Unsafe block | |
| 16440 | + *e = ((ArrayFlags)((((int)(*e)) ^ (((int)(flag_)))))); | |
| 16441 | + } | |
| 16442 | +} | |
| 16443 | +inline ArrayFlags builtin__ArrayFlags__static__zero(void) { | |
| 16444 | + return ((ArrayFlags)(0)); | |
| 16445 | +} | |
| 16446 | +VV_LOC void main__vf_init(void) { | |
| 16447 | + string probe = _S("vf"); | |
| 16448 | + {int _ = probe.len;} | |
| 16449 | + ; | |
| 16450 | +} | |
| 16451 | +// export alias: vf_init -> main__vf_init | |
| 16452 | +void vf_init(void) { | |
| 16453 | + return main__vf_init(); | |
| 16454 | +} | |
| 16455 | +VV_LOC int main__vf_add(int a, int b) { | |
| 16456 | + return a + b; | |
| 16457 | +} | |
| 16458 | +// export alias: vf_add -> main__vf_add | |
| 16459 | +int vf_add(int a, int b) { | |
| 16460 | + return main__vf_add(a, b); | |
| 16461 | +} | |
| 16462 | +VV_LOC char* main__vf_greet(char* name) { | |
| 16463 | + string n = builtin__cstring_to_vstring(name); | |
| 16464 | + string res = builtin__string_plus_many(3, _MOV((string[3]){_S("Hello, "), n, _S(", from V!")})); | |
| 16465 | + u8* out = res.str; | |
| 16466 | + builtin__string_free(&n); | |
| 16467 | + return out; | |
| 16468 | +} | |
| 16469 | +// export alias: vf_greet -> main__vf_greet | |
| 16470 | +char* vf_greet(char* name) { | |
| 16471 | + return main__vf_greet(name); | |
| 16472 | +} | |
| 16473 | +VV_LOC void main__vf_free(voidptr p) { | |
| 16474 | + builtin___v_free(p); | |
| 16475 | +} | |
| 16476 | +// export alias: vf_free -> main__vf_free | |
| 16477 | +void vf_free(voidptr p) { | |
| 16478 | + return main__vf_free(p); | |
| 16479 | +} | |
| 16480 | +VV_LOC void main__main(void) { | |
| 16481 | +} | |
| 16482 | +void _vinit(int ___argc, voidptr ___argv) { | |
| 16483 | + static bool once = false; if (once) {return;} once = true; | |
| 16484 | + // Initializations of consts for module builtin.closure | |
| 16485 | + g_closure = ((builtin__closure__Closure){.ClosureMutex = ((builtin__closure__ClosureMutex){.closure_mtx = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}),.closure_ptr = 0,.closure_get_data = ((void*)0),.closure_cap = 0,.free_closure_ptr = 0,.pages = ((void*)0),.v_page_size = ((int)(0x4000)),.live = builtin__new_map(sizeof(voidptr), sizeof(builtin__closure__ClosureLiveInfo), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop),.active_lifetimes = builtin__new_map(sizeof(u64), sizeof(builtin__closure__ClosureLifetimeState*), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop),.next_generation = 0,.free_lifetime_states = ((void*)0),.next_lifetime_generation = 0,.lifetime_state_allocs = 0,}); // global 3 | |
| 16486 | +{ | |
| 16487 | +{ | |
| 16488 | +Array_fixed_u8_15 _t1; | |
| 16489 | +#if defined(__V_ppc64le) | |
| 16490 | +#elif !defined(__V_ppc64le) && !defined(__V_amd64) && !defined(__V_x86) && !defined(__V_arm64) && !defined(__V_arm32) && !defined(__V_rv64) && !defined(__V_rv32) && !defined(__V_s390x) && !defined(__V_loongarch64) | |
| 16491 | +#elif defined(__V_amd64) | |
| 16492 | + { Array_fixed_u8_15 _t2 = {((u8)(0xF3)), 0x44, 0x0F, 0x7E, 0x3D, 0xF7, 0xBF, 0xFF, 0xFF, 0xFF, 0x25, 0xF9, 0xBF, 0xFF, 0xFF} ; | |
| 16493 | + memcpy(&_t1, &_t2, sizeof(Array_fixed_u8_15)); | |
| 16494 | + } | |
| 16495 | + ; | |
| 16496 | +#elif defined(__V_x86) | |
| 16497 | +#elif defined(__V_arm64) | |
| 16498 | +#elif defined(__V_arm32) | |
| 16499 | +#elif defined(__V_rv64) | |
| 16500 | +#elif defined(__V_rv32) | |
| 16501 | +#elif defined(__V_s390x) | |
| 16502 | +#elif defined(__V_loongarch64) | |
| 16503 | +#elif defined(__V_sparc64) | |
| 16504 | +#elif 0 | |
| 16505 | +#else | |
| 16506 | +#endif | |
| 16507 | + memcpy(&_const_builtin__closure__closure_thunk, &_t1, sizeof(Array_fixed_u8_15)); | |
| 16508 | +} | |
| 16509 | +} | |
| 16510 | +{ | |
| 16511 | +{ | |
| 16512 | +Array_fixed_u8_6 _t3; | |
| 16513 | +#if !defined(__V_ppc64le) && !defined(__V_amd64) && !defined(__V_x86) && !defined(__V_arm64) && !defined(__V_arm32) && !defined(__V_rv64) && !defined(__V_rv32) && !defined(__V_s390x) && !defined(__V_loongarch64) | |
| 16514 | +#elif defined(__V_arm32) | |
| 16515 | +#elif defined(__V_amd64) | |
| 16516 | + { Array_fixed_u8_6 _t4 = {((u8)(0x66)), 0x4C, 0x0F, 0x7E, 0xF8, 0xC3} ; | |
| 16517 | + memcpy(&_t3, &_t4, sizeof(Array_fixed_u8_6)); | |
| 16518 | + } | |
| 16519 | + ; | |
| 16520 | +#elif defined(__V_x86) | |
| 16521 | +#elif defined(__V_arm64) | |
| 16522 | +#elif defined(__V_rv64) | |
| 16523 | +#elif defined(__V_rv32) | |
| 16524 | +#elif defined(__V_s390x) | |
| 16525 | +#elif defined(__V_ppc64le) | |
| 16526 | +#elif defined(__V_loongarch64) | |
| 16527 | +#elif defined(__V_sparc64) | |
| 16528 | +#elif 0 | |
| 16529 | +#else | |
| 16530 | +#endif | |
| 16531 | + memcpy(&_const_builtin__closure__closure_get_data_bytes, &_t3, sizeof(Array_fixed_u8_6)); | |
| 16532 | +} | |
| 16533 | +} | |
| 16534 | +{ | |
| 16535 | +{ | |
| 16536 | + _const_builtin__closure__closure_size_1 = (2 * ((u32)(sizeof(voidptr))) > ((u32)(15)) ? (2 * ((u32)(sizeof(voidptr)))) : (((u32)(15)) + ((u32)(sizeof(voidptr))) - 1)); | |
| 16537 | +} | |
| 16538 | +} | |
| 16539 | + _const_builtin__closure__closure_size = ((int)((_const_builtin__closure__closure_size_1 & ~(((u32)(sizeof(voidptr))) - 1)))); | |
| 16540 | + // Initializations of consts for module math.bits | |
| 16541 | + _const_math__bits__overflow_error = _S("Overflow Error"); | |
| 16542 | + _const_math__bits__divide_error = _S("Divide by Zero Error"); | |
| 16543 | + // Initializations of consts for module strconv | |
| 16544 | + _const_strconv__digit_pairs = _S("00102030405060708090011121314151617181910212223242526272829203132333435363738393041424344454647484940515253545556575859506162636465666768696071727374757677787970818283848586878889809192939495969798999"); | |
| 16545 | + _const_strconv__base_digits = _S("0123456789abcdefghijklmnopqrstuvwxyz"); | |
| 16546 | + _const_strconv__i64_min_int32 = ((i64)(-2147483647)) - 1; | |
| 16547 | + _const_strconv__i64_max_int32 = ((i64)(2147483646)) + 1; | |
| 16548 | + // Initializations of consts for module builtin | |
| 16549 | + _const_grapheme_control_ranges = _S("00000000090000000b0000000c0000000e0000001f0000007f0000009f000000ad000000ad0000001c0600001c0600000e1800000e1800000b2000000b2000000e2000000f200000282000002820000029200000292000002a2000002e20000060200000642000006520000065200000662000006f200000fffe0000fffe0000f0ff0000f8ff0000f9ff0000fbff00003034010038340100a0bc0100a3bc010073d101007ad1010000000e0000000e0001000e0001000e0002000e001f000e0080000e00ff000e00f0010e00ff0f0e00"); | |
| 16550 | + _const_grapheme_extend_ranges = _S("000300006f0300008304000087040000880400008904000091050000bd050000bf050000bf050000c1050000c2050000c4050000c5050000c7050000c7050000100600001a0600004b0600005f0600007006000070060000d6060000dc060000df060000e4060000e7060000e8060000ea060000ed0600001107000011070000300700004a070000a6070000b0070000eb070000f3070000fd070000fd07000016080000190800001b080000230800002508000027080000290800002d080000590800005b080000d3080000e1080000e3080000020900003a0900003a0900003c0900003c09000041090000480900004d0900004d090000510900005709000062090000630900008109000081090000bc090000bc090000be090000be090000c1090000c4090000cd090000cd090000d7090000d7090000e2090000e3090000fe090000fe090000010a0000020a00003c0a00003c0a0000410a0000420a0000470a0000480a00004b0a00004d0a0000510a0000510a0000700a0000710a0000750a0000750a0000810a0000820a0000bc0a0000bc0a0000c10a0000c50a0000c70a0000c80a0000cd0a0000cd0a0000e20a0000e30a0000fa0a0000ff0a0000010b0000010b00003c0b00003c0b00003e0b00003e0b00003f0b00003f0b0000410b0000440b00004d0b00004d0b0000550b0000560b0000570b0000570b0000620b0000630b0000820b0000820b0000be0b0000be0b0000c00b0000c00b0000cd0b0000cd0b0000d70b0000d70b0000000c0000000c0000040c0000040c00003e0c0000400c0000460c0000480c00004a0c00004d0c0000550c0000560c0000620c0000630c0000810c0000810c0000bc0c0000bc0c0000bf0c0000bf0c0000c20c0000c20c0000c60c0000c60c0000cc0c0000cd0c0000d50c0000d60c0000e20c0000e30c0000000d0000010d00003b0d00003c0d00003e0d00003e0d0000410d0000440d00004d0d00004d0d0000570d0000570d0000620d0000630d0000810d0000810d0000ca0d0000ca0d0000cf0d0000cf0d0000d20d0000d40d0000d60d0000d60d0000df0d0000df0d0000310e0000310e0000340e00003a0e0000470e00004e0e0000b10e0000b10e0000b40e0000bc0e0000c80e0000cd0e0000180f0000190f0000350f0000350f0000370f0000370f0000390f0000390f0000710f00007e0f0000800f0000840f0000860f0000870f00008d0f0000970f0000990f0000bc0f0000c60f0000c60f00002d100000301000003210000037100000391000003a1000003d1000003e10000058100000591000005e100000601000007110000074100000821000008210000085100000861000008d1000008d1000009d1000009d1000005d1300005f1300001217000014170000321700003417000052170000531700007217000073170000b4170000b5170000b7170000bd170000c6170000c6170000c9170000d3170000dd170000dd1700000b1800000d1800008518000086180000a9180000a9180000201900002219000027190000281900003219000032190000391900003b190000171a0000181a00001b1a00001b1a0000561a0000561a0000581a00005e1a0000601a0000601a0000621a0000621a0000651a00006c1a0000731a00007c1a00007f1a00007f1a0000b01a0000bd1a0000be1a0000be1a0000bf1a0000c01a0000001b0000031b0000341b0000341b0000351b0000351b0000361b00003a1b00003c1b00003c1b0000421b0000421b00006b1b0000731b0000801b0000811b0000a21b0000a51b0000a81b0000a91b0000ab1b0000ad1b0000e61b0000e61b0000e81b0000e91b0000ed1b0000ed1b0000ef1b0000f11b00002c1c0000331c0000361c0000371c0000d01c0000d21c0000d41c0000e01c0000e21c0000e81c0000ed1c0000ed1c0000f41c0000f41c0000f81c0000f91c0000c01d0000f91d0000fb1d0000ff1d00000c2000000c200000d0200000dc200000dd200000e0200000e1200000e1200000e2200000e4200000e5200000f0200000ef2c0000f12c00007f2d00007f2d0000e02d0000ff2d00002a3000002d3000002e3000002f300000993000009a3000006fa600006fa6000070a6000072a6000074a600007da600009ea600009fa60000f0a60000f1a6000002a8000002a8000006a8000006a800000ba800000ba8000025a8000026a800002ca800002ca80000c4a80000c5a80000e0a80000f1a80000ffa80000ffa8000026a900002da9000047a9000051a9000080a9000082a90000b3a90000b3a90000b6a90000b9a90000bca90000bda90000e5a90000e5a9000029aa00002eaa000031aa000032aa000035aa000036aa000043aa000043aa00004caa00004caa00007caa00007caa0000b0aa0000b0aa0000b2aa0000b4aa0000b7aa0000b8aa0000beaa0000bfaa0000c1aa0000c1aa0000ecaa0000edaa0000f6aa0000f6aa0000e5ab0000e5ab0000e8ab0000e8ab0000edab0000edab00001efb00001efb000000fe00000ffe000020fe00002ffe00009eff00009fff0000fd010100fd010100e0020100e0020100760301007a030100010a0100030a0100050a0100060a01000c0a01000f0a0100380a01003a0a01003f0a01003f0a0100e50a0100e60a0100240d0100270d0100ab0e0100ac0e0100460f0100500f0100011001000110010038100100461001007f10010081100100b3100100b6100100b9100100ba1001000011010002110100271101002b1101002d1101003411010073110100731101008011010081110100b6110100be110100c9110100cc110100cf110100cf1101002f12010031120100341201003412010036120100371201003e1201003e120100df120100df120100e3120100ea12010000130100011301003b1301003c1301003e1301003e13010040130100401301005713010057130100661301006c1301007013010074130100381401003f140100421401004414010046140100461401005e1401005e140100b0140100b0140100b3140100b8140100ba140100ba140100bd140100bd140100bf140100c0140100c2140100c3140100af150100af150100b2150100b5150100bc150100bd150100bf150100c0150100dc150100dd150100331601003a1601003d1601003d1601003f16010040160100ab160100ab160100ad160100ad160100b0160100b5160100b7160100b71601001d1701001f1701002217010025170100271701002b1701002f18010037180100391801003a18010030190100301901003b1901003c1901003e1901003e1901004319010043190100d4190100d7190100da190100db190100e0190100e0190100011a01000a1a0100331a0100381a01003b1a01003e1a0100471a0100471a0100511a0100561a0100591a01005b1a01008a1a0100961a0100981a0100991a0100301c0100361c0100381c01003d1c01003f1c01003f1c0100921c0100a71c0100aa1c0100b01c0100b21c0100b31c0100b51c0100b61c0100311d0100361d01003a1d01003a1d01003c1d01003d1d01003f1d0100451d0100471d0100471d0100901d0100911d0100951d0100951d0100971d0100971d0100f31e0100f41e0100f06a0100f46a0100306b0100366b01004f6f01004f6f01008f6f0100926f0100e46f0100e46f01009dbc01009ebc010065d1010065d1010067d1010069d101006ed1010072d101007bd1010082d1010085d101008bd10100aad10100add1010042d2010044d2010000da010036da01003bda01006cda010075da010075da010084da010084da01009bda01009fda0100a1da0100afda010000e0010006e0010008e0010018e001001be0010021e0010023e0010024e0010026e001002ae0010030e1010036e10100ece20100efe20100d0e80100d6e8010044e901004ae90100fbf30100fff3010020000e007f000e0000010e00ef010e00"); | |
| 16551 | + _const_grapheme_spacing_mark_ranges = _S("03090000030900003b0900003b0900003e09000040090000490900004c0900004e0900004f0900008209000083090000bf090000c0090000c7090000c8090000cb090000cc090000030a0000030a00003e0a0000400a0000830a0000830a0000be0a0000c00a0000c90a0000c90a0000cb0a0000cc0a0000020b0000030b0000400b0000400b0000470b0000480b00004b0b00004c0b0000bf0b0000bf0b0000c10b0000c20b0000c60b0000c80b0000ca0b0000cc0b0000010c0000030c0000410c0000440c0000820c0000830c0000be0c0000be0c0000c00c0000c10c0000c30c0000c40c0000c70c0000c80c0000ca0c0000cb0c0000020d0000030d00003f0d0000400d0000460d0000480d00004a0d00004c0d0000820d0000830d0000d00d0000d10d0000d80d0000de0d0000f20d0000f30d0000330e0000330e0000b30e0000b30e00003e0f00003f0f00007f0f00007f0f000031100000311000003b1000003c10000056100000571000008410000084100000b6170000b6170000be170000c5170000c7170000c81700002319000026190000291900002b19000030190000311900003319000038190000191a00001a1a0000551a0000551a0000571a0000571a00006d1a0000721a0000041b0000041b00003b1b00003b1b00003d1b0000411b0000431b0000441b0000821b0000821b0000a11b0000a11b0000a61b0000a71b0000aa1b0000aa1b0000e71b0000e71b0000ea1b0000ec1b0000ee1b0000ee1b0000f21b0000f31b0000241c00002b1c0000341c0000351c0000e11c0000e11c0000f71c0000f71c000023a8000024a8000027a8000027a8000080a8000081a80000b4a80000c3a8000052a9000053a9000083a9000083a90000b4a90000b5a90000baa90000bba90000bea90000c0a900002faa000030aa000033aa000034aa00004daa00004daa0000ebaa0000ebaa0000eeaa0000efaa0000f5aa0000f5aa0000e3ab0000e4ab0000e6ab0000e7ab0000e9ab0000eaab0000ecab0000ecab0000001001000010010002100100021001008210010082100100b0100100b2100100b7100100b81001002c1101002c11010045110100461101008211010082110100b3110100b5110100bf110100c0110100ce110100ce1101002c1201002e12010032120100331201003512010035120100e0120100e212010002130100031301003f1301003f130100411301004413010047130100481301004b1301004d1301006213010063130100351401003714010040140100411401004514010045140100b1140100b2140100b9140100b9140100bb140100bc140100be140100be140100c1140100c1140100b0150100b1150100b8150100bb150100be150100be15010030160100321601003b1601003c1601003e1601003e160100ac160100ac160100ae160100af160100b6160100b6160100201701002117010026170100261701002c1801002e1801003818010038180100311901003519010037190100381901003d1901003d19010040190100401901004219010042190100d1190100d3190100dc190100df190100e4190100e4190100391a0100391a0100571a0100581a0100971a0100971a01002f1c01002f1c01003e1c01003e1c0100a91c0100a91c0100b11c0100b11c0100b41c0100b41c01008a1d01008e1d0100931d0100941d0100961d0100961d0100f51e0100f61e0100516f0100876f0100f06f0100f16f010066d1010066d101006dd101006dd10100"); | |
| 16552 | + _const_grapheme_prepend_ranges = _S("0006000005060000dd060000dd0600000f0700000f070000e2080000e20800004e0d00004e0d0000bd100100bd100100cd100100cd100100c2110100c31101003f1901003f19010041190100411901003a1a01003a1a0100841a0100891a0100461d0100461d0100"); | |
| 16553 | + _const_grapheme_extended_pictographic_ranges = _S("a9000000a9000000ae000000ae0000003c2000003c2000004920000049200000222100002221000039210000392100009421000099210000a9210000aa2100001a2300001b23000028230000282300008823000088230000cf230000cf230000e9230000ec230000ed230000ee230000ef230000ef230000f0230000f0230000f1230000f2230000f3230000f3230000f8230000fa230000c2240000c2240000aa250000ab250000b6250000b6250000c0250000c0250000fb250000fe2500000026000001260000022600000326000004260000042600000526000005260000072600000d2600000e2600000e2600000f2600001026000011260000112600001226000012260000142600001526000016260000172600001826000018260000192600001c2600001d2600001d2600001e2600001f2600002026000020260000212600002126000022260000232600002426000025260000262600002626000027260000292600002a2600002a2600002b2600002d2600002e2600002e2600002f2600002f260000302600003726000038260000392600003a2600003a2600003b2600003f26000040260000402600004126000041260000422600004226000043260000472600004826000053260000542600005e2600005f2600005f2600006026000060260000612600006226000063260000632600006426000064260000652600006626000067260000672600006826000068260000692600007a2600007b2600007b2600007c2600007d2600007e2600007e2600007f2600007f2600008026000085260000902600009126000092260000922600009326000093260000942600009426000095260000952600009626000097260000982600009826000099260000992600009a2600009a2600009b2600009c2600009d2600009f260000a0260000a1260000a2260000a6260000a7260000a7260000a8260000a9260000aa260000ab260000ac260000af260000b0260000b1260000b2260000bc260000bd260000be260000bf260000c3260000c4260000c5260000c6260000c7260000c8260000c8260000c9260000cd260000ce260000ce260000cf260000cf260000d0260000d0260000d1260000d1260000d2260000d2260000d3260000d3260000d4260000d4260000d5260000e8260000e9260000e9260000ea260000ea260000eb260000ef260000f0260000f1260000f2260000f3260000f4260000f4260000f5260000f5260000f6260000f6260000f7260000f9260000fa260000fa260000fb260000fc260000fd260000fd260000fe26000001270000022700000227000003270000042700000527000005270000082700000c2700000d2700000d2700000e2700000e2700000f2700000f27000010270000112700001227000012270000142700001427000016270000162700001d2700001d270000212700002127000028270000282700003327000034270000442700004427000047270000472700004c2700004c2700004e2700004e270000532700005527000057270000572700006327000063270000642700006427000065270000672700009527000097270000a1270000a1270000b0270000b0270000bf270000bf2700003429000035290000052b0000072b00001b2b00001c2b0000502b0000502b0000552b0000552b000030300000303000003d3000003d3000009732000097320000993200009932000000f0010003f0010004f0010004f0010005f00100cef00100cff00100cff00100d0f00100fff001000df101000ff101002ff101002ff101006cf101006ff1010070f1010071f101007ef101007ff101008ef101008ef1010091f101009af10100adf10100e5f1010001f2010002f2010003f201000ff201001af201001af201002ff201002ff2010032f201003af201003cf201003ff2010049f201004ff2010050f2010051f2010052f20100fff2010000f301000cf301000df301000ef301000ff301000ff3010010f3010010f3010011f3010011f3010012f3010012f3010013f3010015f3010016f3010018f3010019f3010019f301001af301001af301001bf301001bf301001cf301001cf301001df301001ef301001ff3010020f3010021f3010021f3010022f3010023f3010024f301002cf301002df301002ff3010030f3010031f3010032f3010033f3010034f3010035f3010036f3010036f3010037f301004af301004bf301004bf301004cf301004ff3010050f3010050f3010051f301007bf301007cf301007cf301007df301007df301007ef301007ff3010080f3010093f3010094f3010095f3010096f3010097f3010098f3010098f3010099f301009bf301009cf301009df301009ef301009ff30100a0f30100c4f30100c5f30100c5f30100c6f30100c6f30100c7f30100c7f30100c8f30100c8f30100c9f30100c9f30100caf30100caf30100cbf30100cef30100cff30100d3f30100d4f30100dff30100e0f30100e3f30100e4f30100e4f30100e5f30100f0f30100f1f30100f2f30100f3f30100f3f30100f4f30100f4f30100f5f30100f5f30100f6f30100f6f30100f7f30100f7f30100f8f30100faf3010000f4010007f4010008f4010008f4010009f401000bf401000cf401000ef401000ff4010010f4010011f4010012f4010013f4010013f4010014f4010014f4010015f4010015f4010016f4010016f4010017f4010029f401002af401002af401002bf401003ef401003ff401003ff4010040f4010040f4010041f4010041f4010042f4010064f4010065f4010065f4010066f401006bf401006cf401006df401006ef40100acf40100adf40100adf40100aef40100b5f40100b6f40100b7f40100b8f40100ebf40100ecf40100edf40100eef40100eef40100eff40100eff40100f0f40100f4f40100f5f40100f5f40100f6f40100f7f40100f8f40100f8f40100f9f40100fcf40100fdf40100fdf40100fef40100fef40100fff4010002f5010003f5010003f5010004f5010007f5010008f5010008f5010009f5010009f501000af5010014f5010015f5010015f5010016f501002bf501002cf501002df501002ef501003df5010046f5010048f5010049f501004af501004bf501004ef501004ff501004ff5010050f501005bf501005cf5010067f5010068f501006ef501006ff5010070f5010071f5010072f5010073f5010079f501007af501007af501007bf5010086f5010087f5010087f5010088f5010089f501008af501008df501008ef501008ff5010090f5010090f5010091f5010094f5010095f5010096f5010097f50100a3f50100a4f50100a4f50100a5f50100a5f50100a6f50100a7f50100a8f50100a8f50100a9f50100b0f50100b1f50100b2f50100b3f50100bbf50100bcf50100bcf50100bdf50100c1f50100c2f50100c4f50100c5f50100d0f50100d1f50100d3f50100d4f50100dbf50100dcf50100def50100dff50100e0f50100e1f50100e1f50100e2f50100e2f50100e3f50100e3f50100e4f50100e7f50100e8f50100e8f50100e9f50100eef50100eff50100eff50100f0f50100f2f50100f3f50100f3f50100f4f50100f9f50100faf50100faf50100fbf50100fff5010000f6010000f6010001f6010006f6010007f6010008f6010009f601000df601000ef601000ef601000ff601000ff6010010f6010010f6010011f6010011f6010012f6010014f6010015f6010015f6010016f6010016f6010017f6010017f6010018f6010018f6010019f6010019f601001af601001af601001bf601001bf601001cf601001ef601001ff601001ff6010020f6010025f6010026f6010027f6010028f601002bf601002cf601002cf601002df601002df601002ef601002ff6010030f6010033f6010034f6010034f6010035f6010035f6010036f6010036f6010037f6010040f6010041f6010044f6010045f601004ff6010080f6010080f6010081f6010082f6010083f6010085f6010086f6010086f6010087f6010087f6010088f6010088f6010089f6010089f601008af601008bf601008cf601008cf601008df601008df601008ef601008ef601008ff601008ff6010090f6010090f6010091f6010093f6010094f6010094f6010095f6010095f6010096f6010096f6010097f6010097f6010098f6010098f6010099f601009af601009bf60100a1f60100a2f60100a2f60100a3f60100a3f60100a4f60100a5f60100a6f60100a6f60100a7f60100adf60100aef60100b1f60100b2f60100b2f60100b3f60100b5f60100b6f60100b6f60100b7f60100b8f60100b9f60100bef60100bff60100bff60100c0f60100c0f60100c1f60100c5f60100c6f60100caf60100cbf60100cbf60100ccf60100ccf60100cdf60100cff60100d0f60100d0f60100d1f60100d2f60100d3f60100d4f60100d5f60100d5f60100d6f60100d7f60100d8f60100dff60100e0f60100e5f60100e6f60100e8f60100e9f60100e9f60100eaf60100eaf60100ebf60100ecf60100edf60100eff60100f0f60100f0f60100f1f60100f2f60100f3f60100f3f60100f4f60100f6f60100f7f60100f8f60100f9f60100f9f60100faf60100faf60100fbf60100fcf60100fdf60100fff6010074f701007ff70100d5f70100dff70100e0f70100ebf70100ecf70100fff701000cf801000ff8010048f801004ff801005af801005ff8010088f801008ff80100aef80100fff801000cf901000cf901000df901000ff9010010f9010018f9010019f901001ef901001ff901001ff9010020f9010027f9010028f901002ff9010030f9010030f9010031f9010032f9010033f901003af901003cf901003ef901003ff901003ff9010040f9010045f9010047f901004bf901004cf901004cf901004df901004ff9010050f901005ef901005ff901006bf901006cf9010070f9010071f9010071f9010072f9010072f9010073f9010076f9010077f9010078f9010079f9010079f901007af901007af901007bf901007bf901007cf901007ff9010080f9010084f9010085f9010091f9010092f9010097f9010098f90100a2f90100a3f90100a4f90100a5f90100aaf90100abf90100adf90100aef90100aff90100b0f90100b9f90100baf90100bff90100c0f90100c0f90100c1f90100c2f90100c3f90100caf90100cbf90100cbf90100ccf90100ccf90100cdf90100cff90100d0f90100e6f90100e7f90100fff9010000fa01006ffa010070fa010073fa010074fa010074fa010075fa010077fa010078fa01007afa01007bfa01007ffa010080fa010082fa010083fa010086fa010087fa01008ffa010090fa010095fa010096fa0100a8fa0100a9fa0100affa0100b0fa0100b6fa0100b7fa0100bffa0100c0fa0100c2fa0100c3fa0100cffa0100d0fa0100d6fa0100d7fa0100fffa010000fc0100fdff0100"); | |
| 16554 | + _const_digit_pairs = _S("00102030405060708090011121314151617181910212223242526272829203132333435363738393041424344454647484940515253545556575859506162636465666768696071727374757677787970818283848586878889809192939495969798999"); | |
| 16555 | + _const_si_s_code = _S("0xfe10"); | |
| 16556 | + _const_si_g32_code = _S("0xfe0e"); | |
| 16557 | + _const_si_g64_code = _S("0xfe0f"); | |
| 16558 | + g_live_reload_info = *(voidptr*)&((voidptr[]){0}[0]); // global 5 | |
| 16559 | + _const_error_sentinel = I_MessageError_to_Interface_IError((HEAP(MessageError, ((MessageError){.msg = _S("error"),.code = 0,})))); | |
| 16560 | + _const_none__ = I_None___to_Interface_IError((HEAP(None__, ((None__){.Error = ((Error){E_STRUCT}),})))); | |
| 16561 | + _const_min_i64 = ((i64)(-9223372036854775807LL - 1)); | |
| 16562 | + _const_max_i64 = ((i64)(9223372036854775807LL)); | |
| 16563 | + _const_utf8_replacement_rune = ((rune)(0xfffd)); | |
| 16564 | +} | |
| 16565 | +void _vcleanup(void) { | |
| 16566 | + static bool once = false; if (once) {return;} once = true; | |
| 16567 | +} | |
| 16568 | +__attribute__ ((constructor)) | |
| 16569 | +void _vinit_caller() { | |
| 16570 | + static bool once = false; if (once) {return;} once = true; | |
| 16571 | + _vinit(0,0); | |
| 16572 | +} | |
| 16573 | +__attribute__ ((destructor)) | |
| 16574 | +void _vcleanup_caller() { | |
| 16575 | + static bool once = false; if (once) {return;} once = true; | |
| 16576 | + _vcleanup(); | |
| 16577 | +} | |
| 16578 | + | |
| 16579 | +int main(int ___argc, char** ___argv){ | |
| 16580 | + g_main_argc = ___argc; | |
| 16581 | + g_main_argv = ___argv; | |
| 16582 | + _vinit(___argc, (voidptr)___argv); | |
| 16583 | + main__main(); | |
| 16584 | + _vcleanup(); | |
| 16585 | + return 0; | |
| 16586 | +} | |
| 16587 | +// THE END. | |
| new file mode 100644 | |||
| @@ -0,0 +1,16587 @@ | |||
| 1 | + | ||
| 2 | +#ifndef V_COMMIT_HASH | ||
| 3 | + #define V_COMMIT_HASH "45ae01d23168b6372f734eeb38a77360bbcf184a" | ||
| 4 | +#endif | ||
| 5 | + | ||
| 6 | +#define V_USE_SIGNAL_H | ||
| 7 | + | ||
| 8 | +// V comptime_definitions: | ||
| 9 | +// V compile time defines by -d or -define flags: | ||
| 10 | +// All custom defines : linux | ||
| 11 | +// Turned ON custom defines: linux | ||
| 12 | +#define CUSTOM_DEFINE_linux | ||
| 13 | + | ||
| 14 | + | ||
| 15 | +// V typedefs: | ||
| 16 | +typedef struct IError IError; | ||
| 17 | +typedef struct none none; | ||
| 18 | + | ||
| 19 | +// BEGIN_array_fixed_return_typedefs | ||
| 20 | +typedef struct _v_Array_fixed_string_11 _v_Array_fixed_string_11; | ||
| 21 | +typedef struct _v_Array_fixed_voidptr_11 _v_Array_fixed_voidptr_11; | ||
| 22 | +typedef struct _v_Array_fixed_u8_128 _v_Array_fixed_u8_128; | ||
| 23 | +typedef struct _v_Array_fixed_u8_32 _v_Array_fixed_u8_32; | ||
| 24 | +typedef struct _v_Array_fixed_u8_64 _v_Array_fixed_u8_64; | ||
| 25 | +typedef struct _v_Array_fixed_u8_5 _v_Array_fixed_u8_5; | ||
| 26 | +typedef struct _v_Array_fixed_u8_20 _v_Array_fixed_u8_20; | ||
| 27 | +typedef struct _v_Array_fixed_u8_15 _v_Array_fixed_u8_15; | ||
| 28 | +typedef struct _v_Array_fixed_u8_6 _v_Array_fixed_u8_6; | ||
| 29 | +typedef struct _v_Array_fixed_u8_256 _v_Array_fixed_u8_256; | ||
| 30 | +typedef struct _v_Array_fixed_u64_309 _v_Array_fixed_u64_309; | ||
| 31 | +typedef struct _v_Array_fixed_u64_324 _v_Array_fixed_u64_324; | ||
| 32 | +typedef struct _v_Array_fixed_u32_10 _v_Array_fixed_u32_10; | ||
| 33 | +typedef struct _v_Array_fixed_u64_20 _v_Array_fixed_u64_20; | ||
| 34 | +typedef struct _v_Array_fixed_u64_584 _v_Array_fixed_u64_584; | ||
| 35 | +typedef struct _v_Array_fixed_u64_652 _v_Array_fixed_u64_652; | ||
| 36 | +typedef struct _v_Array_fixed_f64_36 _v_Array_fixed_f64_36; | ||
| 37 | +typedef struct _v_Array_fixed_u8_26 _v_Array_fixed_u8_26; | ||
| 38 | +typedef struct _v_Array_fixed_u8_512 _v_Array_fixed_u8_512; | ||
| 39 | +typedef struct _v_Array_fixed_u64_47 _v_Array_fixed_u64_47; | ||
| 40 | +typedef struct _v_Array_fixed_u64_31 _v_Array_fixed_u64_31; | ||
| 41 | +typedef struct _v_Array_fixed_int_64 _v_Array_fixed_int_64; | ||
| 42 | +typedef struct _v_Array_fixed_voidptr_64 _v_Array_fixed_voidptr_64; | ||
| 43 | +typedef struct _v_Array_fixed_voidptr_100 _v_Array_fixed_voidptr_100; | ||
| 44 | +typedef struct _v_Array_fixed_u8_1000 _v_Array_fixed_u8_1000; | ||
| 45 | +typedef struct _v_Array_fixed_u8_17 _v_Array_fixed_u8_17; | ||
| 46 | +typedef struct _v_Array_fixed_i32_1264 _v_Array_fixed_i32_1264; | ||
| 47 | +typedef struct _v_Array_fixed_int_10 _v_Array_fixed_int_10; | ||
| 48 | +typedef struct _v_Array_fixed_int_20 _v_Array_fixed_int_20; | ||
| 49 | +// END_array_fixed_return_typedefs | ||
| 50 | + | ||
| 51 | + | ||
| 52 | +// BEGIN_multi_return_typedefs | ||
| 53 | +typedef struct multi_return_u32_u32 multi_return_u32_u32; | ||
| 54 | +typedef struct multi_return_string_string multi_return_string_string; | ||
| 55 | +typedef struct multi_return_int_int multi_return_int_int; | ||
| 56 | +typedef struct multi_return_rune_int multi_return_rune_int; | ||
| 57 | +typedef struct multi_return_u32_u32_u32 multi_return_u32_u32_u32; | ||
| 58 | +typedef struct multi_return_strconv__ParserState_strconv__PrepNumber multi_return_strconv__ParserState_strconv__PrepNumber; | ||
| 59 | +typedef struct multi_return_u64_int multi_return_u64_int; | ||
| 60 | +typedef struct multi_return_i64_int multi_return_i64_int; | ||
| 61 | +typedef struct multi_return_strconv__Dec32_bool multi_return_strconv__Dec32_bool; | ||
| 62 | +typedef struct multi_return_strconv__Dec64_bool multi_return_strconv__Dec64_bool; | ||
| 63 | +typedef struct multi_return_u64_u64 multi_return_u64_u64; | ||
| 64 | +typedef struct multi_return_f64_int multi_return_f64_int; | ||
| 65 | +// END_multi_return_typedefs | ||
| 66 | + | ||
| 67 | +typedef struct strings__IndentParam strings__IndentParam; | ||
| 68 | +typedef struct builtin__closure__ClosurePage builtin__closure__ClosurePage; | ||
| 69 | +typedef struct builtin__closure__ClosureLiveInfo builtin__closure__ClosureLiveInfo; | ||
| 70 | +typedef struct builtin__closure__ClosureLifetimeRecord builtin__closure__ClosureLifetimeRecord; | ||
| 71 | +typedef struct builtin__closure__ClosureLifetimeFrame builtin__closure__ClosureLifetimeFrame; | ||
| 72 | +typedef struct builtin__closure__ClosureLifetimeState builtin__closure__ClosureLifetimeState; | ||
| 73 | +typedef struct builtin__closure__Lifetime builtin__closure__Lifetime; | ||
| 74 | +typedef struct builtin__closure__FrameToken builtin__closure__FrameToken; | ||
| 75 | +typedef struct builtin__closure__Closure builtin__closure__Closure; | ||
| 76 | +typedef struct builtin__closure__ClosureMutex builtin__closure__ClosureMutex; | ||
| 77 | +typedef struct strconv__AtoF64Param strconv__AtoF64Param; | ||
| 78 | +typedef struct strconv__BF_param strconv__BF_param; | ||
| 79 | +typedef struct strconv__PrepNumber strconv__PrepNumber; | ||
| 80 | +typedef struct strconv__Dec32 strconv__Dec32; | ||
| 81 | +typedef struct strconv__Dec64 strconv__Dec64; | ||
| 82 | +typedef struct strconv__Uint128 strconv__Uint128; | ||
| 83 | +typedef union strconv__Uf32 strconv__Uf32; | ||
| 84 | +typedef union strconv__Uf64 strconv__Uf64; | ||
| 85 | +typedef union strconv__Float64u strconv__Float64u; | ||
| 86 | +typedef union strconv__Float32u strconv__Float32u; | ||
| 87 | +typedef struct GCHeapUsage GCHeapUsage; | ||
| 88 | +typedef struct array array; | ||
| 89 | +typedef struct ArrayDataHeader ArrayDataHeader; | ||
| 90 | +typedef struct _result _result; | ||
| 91 | +typedef struct Error Error; | ||
| 92 | +typedef struct MessageError MessageError; | ||
| 93 | +typedef struct _option _option; | ||
| 94 | +typedef struct None__ None__; | ||
| 95 | +typedef struct GraphemeState GraphemeState; | ||
| 96 | +typedef struct InputRuneIterator InputRuneIterator; | ||
| 97 | +typedef struct DenseArray DenseArray; | ||
| 98 | +typedef struct map map; | ||
| 99 | +typedef struct VAssertMetaInfo VAssertMetaInfo; | ||
| 100 | +typedef struct SortedMap SortedMap; | ||
| 101 | +typedef struct mapnode mapnode; | ||
| 102 | +typedef struct string string; | ||
| 103 | +typedef struct RepIndex RepIndex; | ||
| 104 | +typedef struct WrapConfig WrapConfig; | ||
| 105 | +typedef struct RunesIterator RunesIterator; | ||
| 106 | +typedef union StrIntpMem StrIntpMem; | ||
| 107 | +typedef struct StrIntpData StrIntpData; | ||
| 108 | +typedef struct ToWideConfig ToWideConfig; | ||
| 109 | +typedef struct _result_int _result_int; | ||
| 110 | +typedef struct _result_builtin__closure__ClosureLifetimeState_ptr _result_builtin__closure__ClosureLifetimeState_ptr; | ||
| 111 | +typedef struct _result_builtin__closure__FrameToken _result_builtin__closure__FrameToken; | ||
| 112 | +typedef struct _result_void _result_void; | ||
| 113 | +typedef struct _result_f64 _result_f64; | ||
| 114 | +typedef struct _result_u64 _result_u64; | ||
| 115 | +typedef struct _result_i64 _result_i64; | ||
| 116 | +typedef struct _result_multi_return_i64_int _result_multi_return_i64_int; | ||
| 117 | +typedef struct _result_i8 _result_i8; | ||
| 118 | +typedef struct _result_i16 _result_i16; | ||
| 119 | +typedef struct _result_i32 _result_i32; | ||
| 120 | +typedef struct _result_u8 _result_u8; | ||
| 121 | +typedef struct _result_u16 _result_u16; | ||
| 122 | +typedef struct _result_u32 _result_u32; | ||
| 123 | +typedef struct _result_rune _result_rune; | ||
| 124 | +typedef struct _result_string _result_string; | ||
| 125 | +typedef struct _option_builtin__closure__ClosureLiveInfo _option_builtin__closure__ClosureLiveInfo; | ||
| 126 | +typedef struct _option_builtin__closure__ClosureLifetimeState_ptr _option_builtin__closure__ClosureLifetimeState_ptr; | ||
| 127 | +typedef struct _option_int _option_int; | ||
| 128 | +typedef struct _option_rune _option_rune; | ||
| 129 | +typedef struct _option_multi_return_string_string _option_multi_return_string_string; | ||
| 130 | +typedef struct _option_u8 _option_u8; | ||
| 131 | + | ||
| 132 | + // V preincludes: | ||
| 133 | +#define _GNU_SOURCE | ||
| 134 | + | ||
| 135 | +#if defined(__TINYC__) && defined(__has_include) // tcc does not support has_include properly yet, turn it off completely | ||
| 136 | +#undef __has_include | ||
| 137 | +#endif | ||
| 138 | + | ||
| 139 | +#if defined(__TINYC__) && defined(__BIONIC__) | ||
| 140 | + #define __builtin_nanf(ignored_string) (0.0F / 0.0F) | ||
| 141 | + #define __builtin_nan(ignored_string) (0.0 / 0.0) | ||
| 142 | + #define __builtin_nanl(ignored_string) (0.0L / 0.0L) | ||
| 143 | + #define __builtin_inff() (1.0F / 0.0F) | ||
| 144 | + #define __builtin_inf() (1.0 / 0.0) | ||
| 145 | + #define __builtin_infl() (1.0L / 0.0L) | ||
| 146 | + #define __builtin_huge_valf() (1.0F / 0.0F) | ||
| 147 | + #define __builtin_huge_val() (1.0 / 0.0) | ||
| 148 | + #define __builtin_huge_vall() (1.0L / 0.0L) | ||
| 149 | +#endif | ||
| 150 | + | ||
| 151 | +// V cheaders: | ||
| 152 | +// Generated by the V compiler | ||
| 153 | + | ||
| 154 | +#if defined __GNUC__ && __GNUC__ >= 14 | ||
| 155 | +#pragma GCC diagnostic warning "-Wimplicit-function-declaration" | ||
| 156 | +#pragma GCC diagnostic warning "-Wincompatible-pointer-types" | ||
| 157 | +#pragma GCC diagnostic warning "-Wint-conversion" | ||
| 158 | +#pragma GCC diagnostic warning "-Wreturn-mismatch" | ||
| 159 | +#endif | ||
| 160 | + | ||
| 161 | + | ||
| 162 | +#if defined(__TINYC__) && defined(__has_include) // tcc does not support has_include properly yet, turn it off completely | ||
| 163 | +#undef __has_include | ||
| 164 | +#endif | ||
| 165 | + | ||
| 166 | +#if defined(__TINYC__) && defined(__BIONIC__) | ||
| 167 | + #define __builtin_nanf(ignored_string) (0.0F / 0.0F) | ||
| 168 | + #define __builtin_nan(ignored_string) (0.0 / 0.0) | ||
| 169 | + #define __builtin_nanl(ignored_string) (0.0L / 0.0L) | ||
| 170 | + #define __builtin_inff() (1.0F / 0.0F) | ||
| 171 | + #define __builtin_inf() (1.0 / 0.0) | ||
| 172 | + #define __builtin_infl() (1.0L / 0.0L) | ||
| 173 | + #define __builtin_huge_valf() (1.0F / 0.0F) | ||
| 174 | + #define __builtin_huge_val() (1.0 / 0.0) | ||
| 175 | + #define __builtin_huge_vall() (1.0L / 0.0L) | ||
| 176 | +#endif | ||
| 177 | + | ||
| 178 | +#ifdef __TINYC__ | ||
| 179 | +#include <inttypes.h> | ||
| 180 | +#else | ||
| 181 | +#if defined(__has_include) | ||
| 182 | +#if __has_include(<inttypes.h>) | ||
| 183 | +#include <inttypes.h> | ||
| 184 | +#elif __has_include(<stdint.h>) | ||
| 185 | +#include <stdint.h> | ||
| 186 | +#else | ||
| 187 | +#error VERROR_MESSAGE The C compiler can not find <stdint.h>. Please install the package `build-essential`. | ||
| 188 | +#endif | ||
| 189 | +#else | ||
| 190 | +#include <stdint.h> | ||
| 191 | +#endif | ||
| 192 | +#endif | ||
| 193 | + | ||
| 194 | + | ||
| 195 | +#ifdef __TINYC__ | ||
| 196 | +#include <stddef.h> | ||
| 197 | +#else | ||
| 198 | +#if defined(__has_include) | ||
| 199 | +#if __has_include(<stddef.h>) | ||
| 200 | +#include <stddef.h> | ||
| 201 | +#else | ||
| 202 | +#error VERROR_MESSAGE The C compiler can not find <stddef.h>. Please install the package `build-essential`. | ||
| 203 | +#endif | ||
| 204 | +#else | ||
| 205 | +#include <stddef.h> | ||
| 206 | +#endif | ||
| 207 | +#endif | ||
| 208 | + | ||
| 209 | + | ||
| 210 | +//================================== builtin types ================================*/ | ||
| 211 | +#if defined(__x86_64__) || defined(_M_AMD64) || defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64) || (defined(__riscv_xlen) && __riscv_xlen == 64) || defined(__s390x__) || (defined(__powerpc64__) && defined(__LITTLE_ENDIAN__)) || defined(__loongarch64) || defined(__sparc__) || (defined(__powerpc64__) && defined(__BIG_ENDIAN__)) | ||
| 212 | +typedef int64_t vint_t; | ||
| 213 | +#else | ||
| 214 | +typedef int32_t vint_t; | ||
| 215 | +#endif | ||
| 216 | +typedef int64_t i64; | ||
| 217 | +typedef int16_t i16; | ||
| 218 | +typedef int8_t i8; | ||
| 219 | +typedef uint64_t u64; | ||
| 220 | +typedef uint32_t u32; | ||
| 221 | +typedef uint8_t u8; | ||
| 222 | +typedef uint16_t u16; | ||
| 223 | +typedef u8 byte; | ||
| 224 | +typedef int32_t i32; | ||
| 225 | +typedef uint32_t rune; | ||
| 226 | +typedef size_t usize; | ||
| 227 | +typedef ptrdiff_t isize; | ||
| 228 | +#ifndef VNOFLOAT | ||
| 229 | +typedef float f32; | ||
| 230 | +typedef double f64; | ||
| 231 | +#else | ||
| 232 | +typedef int32_t f32; | ||
| 233 | +typedef int64_t f64; | ||
| 234 | +#endif | ||
| 235 | +typedef int64_t int_literal; | ||
| 236 | +#ifndef VNOFLOAT | ||
| 237 | +typedef double float_literal; | ||
| 238 | +#else | ||
| 239 | +typedef int64_t float_literal; | ||
| 240 | +#endif | ||
| 241 | +typedef unsigned char* byteptr; | ||
| 242 | +typedef void* voidptr; | ||
| 243 | +typedef char* charptr; | ||
| 244 | +typedef u8 array_fixed_byte_300 [300]; | ||
| 245 | +typedef struct sync__Channel* chan; | ||
| 246 | +#ifndef CUSTOM_DEFINE_no_bool | ||
| 247 | + #ifndef __cplusplus | ||
| 248 | + #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 202311L | ||
| 249 | + #ifndef bool | ||
| 250 | + #ifdef CUSTOM_DEFINE_4bytebool | ||
| 251 | + typedef int bool; | ||
| 252 | + #else | ||
| 253 | + typedef u8 bool; | ||
| 254 | + #endif | ||
| 255 | + #define true 1 | ||
| 256 | + #define false 0 | ||
| 257 | + #endif | ||
| 258 | + #endif | ||
| 259 | + #endif | ||
| 260 | +#endif | ||
| 261 | + | ||
| 262 | + | ||
| 263 | +#define V_SAFE_SHIFT_BITS(type) ((u64)(sizeof(type) * 8)) | ||
| 264 | +#define V_SAFE_LSHIFT_UNSIGNED(name, type) static inline type name(type x, u64 y) { return y >= V_SAFE_SHIFT_BITS(type) ? (type)0 : (type)(x << y); } | ||
| 265 | +#define V_SAFE_LSHIFT_SIGNED(name, type, unsigned_type) static inline type name(type x, u64 y) { return y >= V_SAFE_SHIFT_BITS(type) ? (type)0 : (type)(((unsigned_type)x) << y); } | ||
| 266 | +#define V_SAFE_RSHIFT_UNSIGNED(name, type) static inline type name(type x, u64 y) { return y >= V_SAFE_SHIFT_BITS(type) ? (type)0 : (type)(x >> y); } | ||
| 267 | +#define V_SAFE_RSHIFT_SIGNED(name, type) static inline type name(type x, u64 y) { return y >= V_SAFE_SHIFT_BITS(type) ? (type)(x < 0 ? -1 : 0) : (type)(x >> y); } | ||
| 268 | +V_SAFE_LSHIFT_SIGNED(v__lshift_char, char, u8) | ||
| 269 | +V_SAFE_RSHIFT_SIGNED(v__rshift_char, char) | ||
| 270 | +V_SAFE_LSHIFT_SIGNED(v__lshift_i8, i8, u8) | ||
| 271 | +V_SAFE_RSHIFT_SIGNED(v__rshift_i8, i8) | ||
| 272 | +V_SAFE_LSHIFT_SIGNED(v__lshift_i16, i16, u16) | ||
| 273 | +V_SAFE_RSHIFT_SIGNED(v__rshift_i16, i16) | ||
| 274 | +V_SAFE_LSHIFT_SIGNED(v__lshift_i32, i32, u32) | ||
| 275 | +V_SAFE_RSHIFT_SIGNED(v__rshift_i32, i32) | ||
| 276 | +V_SAFE_LSHIFT_SIGNED(v__lshift_int, int, unsigned int) | ||
| 277 | +V_SAFE_RSHIFT_SIGNED(v__rshift_int, int) | ||
| 278 | +V_SAFE_LSHIFT_SIGNED(v__lshift_vint_t, vint_t, u64) | ||
| 279 | +V_SAFE_RSHIFT_SIGNED(v__rshift_vint_t, vint_t) | ||
| 280 | +V_SAFE_LSHIFT_SIGNED(v__lshift_i64, i64, u64) | ||
| 281 | +V_SAFE_RSHIFT_SIGNED(v__rshift_i64, i64) | ||
| 282 | +V_SAFE_LSHIFT_SIGNED(v__lshift_isize, isize, usize) | ||
| 283 | +V_SAFE_RSHIFT_SIGNED(v__rshift_isize, isize) | ||
| 284 | +V_SAFE_LSHIFT_UNSIGNED(v__lshift_u8, u8) | ||
| 285 | +V_SAFE_RSHIFT_UNSIGNED(v__rshift_u8, u8) | ||
| 286 | +V_SAFE_LSHIFT_UNSIGNED(v__lshift_u16, u16) | ||
| 287 | +V_SAFE_RSHIFT_UNSIGNED(v__rshift_u16, u16) | ||
| 288 | +V_SAFE_LSHIFT_UNSIGNED(v__lshift_u32, u32) | ||
| 289 | +V_SAFE_RSHIFT_UNSIGNED(v__rshift_u32, u32) | ||
| 290 | +V_SAFE_LSHIFT_UNSIGNED(v__lshift_u64, u64) | ||
| 291 | +V_SAFE_RSHIFT_UNSIGNED(v__rshift_u64, u64) | ||
| 292 | +V_SAFE_LSHIFT_UNSIGNED(v__lshift_usize, usize) | ||
| 293 | +V_SAFE_RSHIFT_UNSIGNED(v__rshift_usize, usize) | ||
| 294 | +V_SAFE_LSHIFT_UNSIGNED(v__lshift_rune, rune) | ||
| 295 | +V_SAFE_RSHIFT_UNSIGNED(v__rshift_rune, rune) | ||
| 296 | +V_SAFE_LSHIFT_SIGNED(v__lshift_int_literal, int_literal, u64) | ||
| 297 | +V_SAFE_RSHIFT_SIGNED(v__rshift_int_literal, int_literal) | ||
| 298 | +#undef V_SAFE_RSHIFT_SIGNED | ||
| 299 | +#undef V_SAFE_RSHIFT_UNSIGNED | ||
| 300 | +#undef V_SAFE_LSHIFT_SIGNED | ||
| 301 | +#undef V_SAFE_LSHIFT_UNSIGNED | ||
| 302 | +#undef V_SAFE_SHIFT_BITS | ||
| 303 | + | ||
| 304 | + | ||
| 305 | +typedef u64 (*MapHashFn)(voidptr); | ||
| 306 | +typedef bool (*MapEqFn)(voidptr, voidptr); | ||
| 307 | +typedef void (*MapCloneFn)(voidptr, voidptr); | ||
| 308 | +typedef void (*MapFreeFn)(voidptr); | ||
| 309 | + | ||
| 310 | +//============================== HELPER C MACROS =============================*/ | ||
| 311 | +// _SLIT0 is used as NULL string for literal arguments | ||
| 312 | +// `"" s` is used to enforce a string literal argument | ||
| 313 | +#define _SLIT0 (string){.str=(byteptr)(""), .len=0, .is_lit=1} | ||
| 314 | +#define _S(s) ((string){.str=(byteptr)("" s), .len=(sizeof(s)-1), .is_lit=1}) | ||
| 315 | +#define _SLEN(s, n) ((string){.str=(byteptr)("" s), .len=n, .is_lit=1}) | ||
| 316 | +// optimized way to compare literal strings | ||
| 317 | +#define _SLIT_EQ(sptr, slen, lit) (slen == sizeof("" lit)-1 && !builtin__vmemcmp(sptr, "" lit, slen)) | ||
| 318 | +#define _SLIT_NE(sptr, slen, lit) (slen != sizeof("" lit)-1 || builtin__vmemcmp(sptr, "" lit, slen)) | ||
| 319 | +// take the address of an rvalue | ||
| 320 | +#define ADDR(type, expr) (&((type[]){expr}[0])) | ||
| 321 | +// copy something to the heap | ||
| 322 | +#define HEAP(type, expr) ((type*)builtin__memdup((void*)&((type[]){expr}[0]), sizeof(type))) | ||
| 323 | +#define HEAP_noscan(type, expr) ((type*)builtin__memdup_noscan((void*)&((type[]){expr}[0]), sizeof(type))) | ||
| 324 | +#define HEAP_align(type, expr, align) ((type*)builtin__memdup_align((void*)&((type[]){expr}[0]), sizeof(type), align)) | ||
| 325 | +#define HEAP_vgc(type, expr, ptrmap, nptrs) ((type*)builtin__vgc_memdup_typed((void*)&((type[]){expr}[0]), sizeof(type), (ptrmap), (nptrs))) | ||
| 326 | +#define _PUSH_MANY(arr, val, tmp, tmp_typ) {tmp_typ tmp = (val); builtin__array_push_many(arr, tmp.data, tmp.len);} | ||
| 327 | +#define _PUSH_MANY_noscan(arr, val, tmp, tmp_typ) {tmp_typ tmp = (val); builtin__array_push_many_noscan(arr, tmp.data, tmp.len);} | ||
| 328 | + | ||
| 329 | +#define E_STRUCT_DECL | ||
| 330 | +#define E_STRUCT | ||
| 331 | +#define __NOINLINE __attribute__((noinline)) | ||
| 332 | +#define __IRQHANDLER __attribute__((interrupt)) | ||
| 333 | +#define __V_architecture 0 | ||
| 334 | +#if defined(__x86_64__) || defined(_M_AMD64) | ||
| 335 | + #define __V_amd64 1 | ||
| 336 | + #undef __V_architecture | ||
| 337 | + #define __V_architecture 1 | ||
| 338 | +#endif | ||
| 339 | +#if defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64) | ||
| 340 | + #define __V_arm64 1 | ||
| 341 | + #undef __V_architecture | ||
| 342 | + #define __V_architecture 2 | ||
| 343 | +#endif | ||
| 344 | +#if defined(__arm__) || defined(_M_ARM) | ||
| 345 | + #define __V_arm32 1 | ||
| 346 | + #undef __V_architecture | ||
| 347 | + #define __V_architecture 3 | ||
| 348 | +#endif | ||
| 349 | +#if defined(__riscv) && __riscv_xlen == 64 | ||
| 350 | + #define __V_rv64 1 | ||
| 351 | + #undef __V_architecture | ||
| 352 | + #define __V_architecture 4 | ||
| 353 | +#endif | ||
| 354 | +#if defined(__riscv) && __riscv_xlen == 32 | ||
| 355 | + #define __V_rv32 1 | ||
| 356 | + #undef __V_architecture | ||
| 357 | + #define __V_architecture 5 | ||
| 358 | +#endif | ||
| 359 | +#if defined(__i386__) || defined(_M_IX86) | ||
| 360 | + #define __V_x86 1 | ||
| 361 | + #undef __V_architecture | ||
| 362 | + #define __V_architecture 6 | ||
| 363 | +#endif | ||
| 364 | +#if defined(__s390x__) | ||
| 365 | + #define __V_s390x 1 | ||
| 366 | + #undef __V_architecture | ||
| 367 | + #define __V_architecture 7 | ||
| 368 | +#endif | ||
| 369 | +#if defined(__powerpc64__) && defined(__LITTLE_ENDIAN__) | ||
| 370 | + #define __V_ppc64le 1 | ||
| 371 | + #undef __V_architecture | ||
| 372 | + #define __V_architecture 8 | ||
| 373 | +#endif | ||
| 374 | +#if defined(__loongarch64) | ||
| 375 | + #define __V_loongarch64 1 | ||
| 376 | + #undef __V_architecture | ||
| 377 | + #define __V_architecture 9 | ||
| 378 | +#endif | ||
| 379 | +#if defined(__sparc__) | ||
| 380 | + #define __V_sparc64 1 | ||
| 381 | + #undef __V_architecture | ||
| 382 | + #define __V_architecture 10 | ||
| 383 | +#endif | ||
| 384 | +#if defined(__powerpc64__) && defined(__BIG_ENDIAN__) | ||
| 385 | + #define __V_ppc64 1 | ||
| 386 | + #undef __V_architecture | ||
| 387 | + #define __V_architecture 11 | ||
| 388 | +#endif | ||
| 389 | +#if (defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) || defined(__ppc__) || defined(__ppc) || defined(__PPC__)) && !defined(__powerpc64__) && !defined(__ppc64__) && !defined(__PPC64__) | ||
| 390 | + #define __V_ppc 1 | ||
| 391 | + #undef __V_architecture | ||
| 392 | + #define __V_architecture 12 | ||
| 393 | +#endif | ||
| 394 | +// Using just __GNUC__ for detecting gcc, is not reliable because other compilers define it too: | ||
| 395 | +#ifdef __GNUC__ | ||
| 396 | + #define __V_GCC__ | ||
| 397 | +#endif | ||
| 398 | +#ifdef __TINYC__ | ||
| 399 | + #undef __V_GCC__ | ||
| 400 | +#endif | ||
| 401 | +#ifdef __cplusplus | ||
| 402 | + #undef __V_GCC__ | ||
| 403 | +#endif | ||
| 404 | +#ifdef __clang__ | ||
| 405 | + #undef __V_GCC__ | ||
| 406 | +#endif | ||
| 407 | +#ifdef _MSC_VER | ||
| 408 | + #undef __V_GCC__ | ||
| 409 | + #undef E_STRUCT_DECL | ||
| 410 | + #undef E_STRUCT | ||
| 411 | + #define E_STRUCT_DECL unsigned char _dummy_pad | ||
| 412 | + #define E_STRUCT 0 | ||
| 413 | +#endif | ||
| 414 | +#if defined(__has_include) && !defined(__TINYC__) | ||
| 415 | + #if __has_include(<execinfo.h>) && !defined(_WIN32) | ||
| 416 | + #define __V_HAVE_EXECINFO_H 1 | ||
| 417 | + #include <execinfo.h> | ||
| 418 | + #else | ||
| 419 | + // On linux: int backtrace(void **__array, int __size); | ||
| 420 | + // On BSD: size_t backtrace(void **, size_t); | ||
| 421 | + #endif | ||
| 422 | +#elif (defined(__linux__) && (defined(__GLIBC__) || defined(__GNU_LIBRARY__))) || defined(__APPLE__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) | ||
| 423 | + #define __V_HAVE_EXECINFO_H 1 | ||
| 424 | + #include <execinfo.h> | ||
| 425 | +#else | ||
| 426 | + // On linux: int backtrace(void **__array, int __size); | ||
| 427 | + // On BSD: size_t backtrace(void **, size_t); | ||
| 428 | +#endif | ||
| 429 | +#ifndef __V_HAVE_EXECINFO_H | ||
| 430 | + #ifdef __cplusplus | ||
| 431 | + extern "C" { | ||
| 432 | + #endif | ||
| 433 | + int backtrace(void **__array, int __size); | ||
| 434 | + char **backtrace_symbols(void *const *__array, int __size); | ||
| 435 | + void backtrace_symbols_fd(void *const *__array, int __size, int __fd); | ||
| 436 | + #ifdef __cplusplus | ||
| 437 | + } | ||
| 438 | + #endif | ||
| 439 | +#endif | ||
| 440 | +#ifdef __TINYC__ | ||
| 441 | + #define _Atomic volatile | ||
| 442 | + #undef E_STRUCT_DECL | ||
| 443 | + #undef E_STRUCT | ||
| 444 | + #define E_STRUCT_DECL unsigned char _dummy_pad | ||
| 445 | + #define E_STRUCT 0 | ||
| 446 | + #undef __NOINLINE | ||
| 447 | + #undef __IRQHANDLER | ||
| 448 | + // tcc does not support inlining at all | ||
| 449 | + #define __NOINLINE | ||
| 450 | + #define __IRQHANDLER | ||
| 451 | + // #include <byteswap.h> | ||
| 452 | + int tcc_backtrace(const char *fmt, ...); | ||
| 453 | +#endif | ||
| 454 | +// Use __offsetof_ptr instead of __offset_of, when you *do* have a valid pointer, to avoid UB: | ||
| 455 | +#ifndef __offsetof_ptr | ||
| 456 | + #define __offsetof_ptr(ptr,PTYPE,FIELDNAME) ((size_t)((byte *)&((PTYPE *)ptr)->FIELDNAME - (byte *)ptr)) | ||
| 457 | +#endif | ||
| 458 | +// for __offset_of | ||
| 459 | +#ifndef __offsetof | ||
| 460 | +#if defined(__TINYC__) || defined(_MSC_VER) | ||
| 461 | + #define __offsetof(PTYPE,FIELDNAME) ((size_t)(&((PTYPE *)0)->FIELDNAME)) | ||
| 462 | +#else | ||
| 463 | + #define __offsetof(st, m) __builtin_offsetof(st, m) | ||
| 464 | +#endif | ||
| 465 | +#endif | ||
| 466 | +#if defined(_WIN32) || defined(__CYGWIN__) | ||
| 467 | + #define VV_EXP extern __declspec(dllexport) | ||
| 468 | + #ifdef _VPARALLELCC | ||
| 469 | + #define VV_LOC | ||
| 470 | + #else | ||
| 471 | + #define VV_LOC static | ||
| 472 | + #endif | ||
| 473 | +#else | ||
| 474 | + // 4 < gcc < 5 is used by some older Ubuntu LTS and Centos versions, | ||
| 475 | + // and does not support __has_attribute(visibility) ... | ||
| 476 | + #ifndef __has_attribute | ||
| 477 | + #define __has_attribute(x) 0 // Compatibility with non-clang compilers. | ||
| 478 | + #endif | ||
| 479 | + #if (defined(__GNUC__) && (__GNUC__ >= 4)) || (defined(__clang__) && __has_attribute(visibility)) | ||
| 480 | + #ifdef ARM | ||
| 481 | + #define VV_EXP extern __attribute__((externally_visible,visibility("default"))) | ||
| 482 | + #else | ||
| 483 | + #define VV_EXP extern __attribute__((visibility("default"))) | ||
| 484 | + #endif | ||
| 485 | + #if defined(_VOBJECTFILE) || (defined(__clang__) && (defined(_VUSECACHE) || defined(_VBUILDMODULE))) | ||
| 486 | + #define VV_LOC static | ||
| 487 | + #else | ||
| 488 | + #define VV_LOC __attribute__ ((visibility ("hidden"))) | ||
| 489 | + #endif | ||
| 490 | + #else | ||
| 491 | + #define VV_EXP extern | ||
| 492 | + #ifdef _VPARALLELCC | ||
| 493 | + #define VV_LOC | ||
| 494 | + #else | ||
| 495 | + #define VV_LOC static | ||
| 496 | + #endif | ||
| 497 | + #endif | ||
| 498 | +#endif | ||
| 499 | +#ifdef __cplusplus | ||
| 500 | + #include <utility> | ||
| 501 | + #define _MOV std::move | ||
| 502 | +#else | ||
| 503 | + #define _MOV | ||
| 504 | +#endif | ||
| 505 | +#if defined(__TINYC__) && defined(__has_include) // tcc does not support has_include properly yet, turn it off completely | ||
| 506 | +#undef __has_include | ||
| 507 | +#endif | ||
| 508 | +//likely and unlikely macros | ||
| 509 | +#if defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__clang__) | ||
| 510 | + #define _likely_(x) __builtin_expect(x,1) | ||
| 511 | + #define _unlikely_(x) __builtin_expect(x,0) | ||
| 512 | +#else | ||
| 513 | + #define _likely_(x) (x) | ||
| 514 | + #define _unlikely_(x) (x) | ||
| 515 | +#endif | ||
| 516 | + | ||
| 517 | +#if !defined(VCALLCONV) | ||
| 518 | + #ifdef _MSC_VER | ||
| 519 | + #define VCALLCONV(name) __##name | ||
| 520 | + #else | ||
| 521 | + #define VCALLCONV(name) __attribute__((name)) | ||
| 522 | + #endif | ||
| 523 | +#endif | ||
| 524 | + | ||
| 525 | +// c_headers | ||
| 526 | +typedef int (*qsort_callback_func)(const void*, const void*); | ||
| 527 | +#if defined(_MSC_VER) && !defined(__clang__) | ||
| 528 | + #define V_CRT_LINKAGE __declspec(dllimport) | ||
| 529 | + #define V_CRT_CALL VCALLCONV(cdecl) | ||
| 530 | +#else | ||
| 531 | + #define V_CRT_LINKAGE | ||
| 532 | + #define V_CRT_CALL | ||
| 533 | +#endif | ||
| 534 | +#if (defined(_MSC_VER) && !defined(__clang__)) || defined(__cplusplus) | ||
| 535 | +// Under C++ (g++/clang++), let libc declare FILE/stdio/string/stdlib to keep | ||
| 536 | +// noexcept specifiers consistent — the manual extern "C" prototypes below | ||
| 537 | +// would otherwise conflict with system headers under -std=c++NN. | ||
| 538 | +#include <stdarg.h> | ||
| 539 | +#include <stdio.h> | ||
| 540 | +#include <stdlib.h> | ||
| 541 | +#include <string.h> | ||
| 542 | +#ifndef va_copy | ||
| 543 | + #define va_copy(dest, src) ((dest) = (src)) | ||
| 544 | +#endif | ||
| 545 | +#ifndef _TRUNCATE | ||
| 546 | + #define _TRUNCATE ((size_t)-1) | ||
| 547 | +#endif | ||
| 548 | +#elif defined(__NetBSD__) | ||
| 549 | +// NetBSD exposes stdin/stdout/stderr as macros into a single `__sF[3]` | ||
| 550 | +// array whose element size (sizeof(FILE)) depends on the platform and libc | ||
| 551 | +// version, so we cannot forward-declare them. The FreeBSD-style | ||
| 552 | +// `__stdinp/__stdoutp/__stderrp` symbols also do not exist on NetBSD (see | ||
| 553 | +// vlang/v#27190). Defer to the system headers for FILE, the stdio streams, | ||
| 554 | +// and the libc prototypes that would otherwise clash with the | ||
| 555 | +// `__restrict`-qualified declarations in NetBSD libc. | ||
| 556 | +#include <stdarg.h> | ||
| 557 | +#include <stdio.h> | ||
| 558 | +#include <stdlib.h> | ||
| 559 | +#include <string.h> | ||
| 560 | +#elif defined(__TINYC__) && (defined(__FreeBSD__) || defined(__OpenBSD__)) | ||
| 561 | +// TinyCC reports a hard redefinition error if system OpenSSL pulls in | ||
| 562 | +// <stdarg.h> after V has provided its own va_start macro. Include it first, | ||
| 563 | +// but keep V manual FILE declarations on these BSD libc variants. | ||
| 564 | +#include <stdarg.h> | ||
| 565 | +#if defined(__FreeBSD__) | ||
| 566 | +typedef struct __sFILE FILE; | ||
| 567 | +extern FILE* __stdinp; | ||
| 568 | +extern FILE* __stdoutp; | ||
| 569 | +extern FILE* __stderrp; | ||
| 570 | +#define stdin __stdinp | ||
| 571 | +#define stdout __stdoutp | ||
| 572 | +#define stderr __stderrp | ||
| 573 | +#else | ||
| 574 | +typedef struct __sFILE FILE; | ||
| 575 | +#ifndef _STDFILES_DECLARED | ||
| 576 | + #define _STDFILES_DECLARED | ||
| 577 | +struct __sFstub { long _stub; }; | ||
| 578 | +extern struct __sFstub __stdin[]; | ||
| 579 | +extern struct __sFstub __stdout[]; | ||
| 580 | +extern struct __sFstub __stderr[]; | ||
| 581 | +#endif | ||
| 582 | +#define stdin ((struct __sFILE *)__stdin) | ||
| 583 | +#define stdout ((struct __sFILE *)__stdout) | ||
| 584 | +#define stderr ((struct __sFILE *)__stderr) | ||
| 585 | +#endif | ||
| 586 | +#elif (defined(__MINGW32__) || defined(__MINGW64__)) && defined(__V_GCC__) | ||
| 587 | +// mingw-w64 stdio.h provides fprintf/vfprintf as static inline overrides | ||
| 588 | +// when __USE_MINGW_ANSI_STDIO is enabled, so use the system declarations | ||
| 589 | +// instead of the manual formatted-stdio prototypes below. | ||
| 590 | +#include <stdarg.h> | ||
| 591 | +#include <stdio.h> | ||
| 592 | +#elif defined(__MINGW32__) || defined(__MINGW64__) || (defined(__clang__) && (defined(_WIN32) || defined(_WIN64))) | ||
| 593 | +typedef struct _iobuf FILE; | ||
| 594 | +FILE* __cdecl __acrt_iob_func(unsigned index); | ||
| 595 | +#define stdin (__acrt_iob_func(0)) | ||
| 596 | +#define stdout (__acrt_iob_func(1)) | ||
| 597 | +#define stderr (__acrt_iob_func(2)) | ||
| 598 | +#elif defined(__TINYC__) && (defined(_WIN32) || defined(_WIN64)) | ||
| 599 | +#ifndef _FILE_DEFINED | ||
| 600 | +struct _iobuf { | ||
| 601 | + char *_ptr; | ||
| 602 | + int _cnt; | ||
| 603 | + char *_base; | ||
| 604 | + int _flag; | ||
| 605 | + int _file; | ||
| 606 | + int _charbuf; | ||
| 607 | + int _bufsiz; | ||
| 608 | + char *_tmpfname; | ||
| 609 | +}; | ||
| 610 | +typedef struct _iobuf FILE; | ||
| 611 | +#define _FILE_DEFINED | ||
| 612 | +#endif | ||
| 613 | + #if defined(_WIN64) | ||
| 614 | +FILE* __cdecl __iob_func(void); | ||
| 615 | + #else | ||
| 616 | + #ifdef _MSVCRT_ | ||
| 617 | +extern FILE _iob[]; | ||
| 618 | + #define __iob_func() (_iob) | ||
| 619 | + #else | ||
| 620 | +extern FILE (*_imp___iob)[]; | ||
| 621 | + #define __iob_func() (*_imp___iob) | ||
| 622 | + #define _iob __iob_func() | ||
| 623 | + #endif | ||
| 624 | + #endif | ||
| 625 | +#define stdin (&__iob_func()[0]) | ||
| 626 | +#define stdout (&__iob_func()[1]) | ||
| 627 | +#define stderr (&__iob_func()[2]) | ||
| 628 | +#elif defined(__vinix__) | ||
| 629 | +typedef struct __file FILE; | ||
| 630 | +extern FILE* stdin; | ||
| 631 | +extern FILE* stdout; | ||
| 632 | +extern FILE* stderr; | ||
| 633 | +struct __thread_data; | ||
| 634 | +struct __threadattr; | ||
| 635 | +// pthread_t handling for vinix builds: | ||
| 636 | +// - Vinix kernel (freestanding, __STDC_HOSTED__=0): no libc, define | ||
| 637 | +// pthread_t ourselves so V code that references it compiles. | ||
| 638 | +// - util-vinix cross-compiled on a libc-providing host (hosted, e.g. | ||
| 639 | +// glibc on Linux or macOS with -D__vinix__): pull pthread_t from | ||
| 640 | +// libc to avoid colliding with the libc typedef. | ||
| 641 | +#if defined(__STDC_HOSTED__) && __STDC_HOSTED__ && defined(__has_include) && __has_include(<pthread.h>) | ||
| 642 | +#include <pthread.h> | ||
| 643 | +#else | ||
| 644 | +typedef struct __thread_data *pthread_t; | ||
| 645 | +#endif | ||
| 646 | +typedef __builtin_va_list va_list; | ||
| 647 | +#ifndef va_start | ||
| 648 | + #define va_start(ap, v) __builtin_va_start(ap, v) | ||
| 649 | +#endif | ||
| 650 | +#ifndef va_arg | ||
| 651 | + #define va_arg(ap, t) __builtin_va_arg(ap, t) | ||
| 652 | +#endif | ||
| 653 | +#ifndef va_end | ||
| 654 | + #define va_end(ap) __builtin_va_end(ap) | ||
| 655 | +#endif | ||
| 656 | +#ifndef va_copy | ||
| 657 | + #define va_copy(dest, src) __builtin_va_copy(dest, src) | ||
| 658 | +#endif | ||
| 659 | +#else | ||
| 660 | + #if defined(__APPLE__) || defined(__FreeBSD__) | ||
| 661 | +typedef struct __sFILE FILE; | ||
| 662 | +extern FILE* __stdinp; | ||
| 663 | +extern FILE* __stdoutp; | ||
| 664 | +extern FILE* __stderrp; | ||
| 665 | +#define stdin __stdinp | ||
| 666 | +#define stdout __stdoutp | ||
| 667 | +#define stderr __stderrp | ||
| 668 | + #elif defined(__DragonFly__) | ||
| 669 | +typedef struct __sFILE FILE; | ||
| 670 | +extern FILE* __stdinp; | ||
| 671 | +extern FILE* __stdoutp; | ||
| 672 | +extern FILE* __stderrp; | ||
| 673 | +#define stdin __stdinp | ||
| 674 | +#define stdout __stdoutp | ||
| 675 | +#define stderr __stderrp | ||
| 676 | + #elif defined(__OpenBSD__) | ||
| 677 | +typedef struct __sFILE FILE; | ||
| 678 | +#ifndef _STDFILES_DECLARED | ||
| 679 | + #define _STDFILES_DECLARED | ||
| 680 | +struct __sFstub { long _stub; }; | ||
| 681 | +extern struct __sFstub __stdin[]; | ||
| 682 | +extern struct __sFstub __stdout[]; | ||
| 683 | +extern struct __sFstub __stderr[]; | ||
| 684 | +#endif | ||
| 685 | +#define stdin ((struct __sFILE *)__stdin) | ||
| 686 | +#define stdout ((struct __sFILE *)__stdout) | ||
| 687 | +#define stderr ((struct __sFILE *)__stderr) | ||
| 688 | + #elif defined(__BIONIC__) | ||
| 689 | +struct __sFILE; | ||
| 690 | +typedef struct __sFILE FILE; | ||
| 691 | +extern FILE* stdin; | ||
| 692 | +extern FILE* stdout; | ||
| 693 | +extern FILE* stderr; | ||
| 694 | + #elif defined(__linux__) && !defined(__GLIBC__) && !defined(__GNU_LIBRARY__) && !defined(__BIONIC__) && !defined(__UCLIBC__) | ||
| 695 | +typedef struct _IO_FILE FILE; | ||
| 696 | +// musl exposes the stdio streams as `FILE *const`, so match that to stay | ||
| 697 | +// compatible with later <stdio.h> includes from headers like miniz.h. | ||
| 698 | +extern FILE* const stdin; | ||
| 699 | +extern FILE* const stdout; | ||
| 700 | +extern FILE* const stderr; | ||
| 701 | + #else | ||
| 702 | +typedef struct _IO_FILE FILE; | ||
| 703 | +extern FILE* stdin; | ||
| 704 | +extern FILE* stdout; | ||
| 705 | +extern FILE* stderr; | ||
| 706 | + #endif | ||
| 707 | +typedef __builtin_va_list va_list; | ||
| 708 | +#ifndef va_start | ||
| 709 | + #define va_start(ap, v) __builtin_va_start(ap, v) | ||
| 710 | +#endif | ||
| 711 | +#ifndef va_arg | ||
| 712 | + #define va_arg(ap, t) __builtin_va_arg(ap, t) | ||
| 713 | +#endif | ||
| 714 | +#ifndef va_end | ||
| 715 | + #define va_end(ap) __builtin_va_end(ap) | ||
| 716 | +#endif | ||
| 717 | +#ifndef va_copy | ||
| 718 | + #define va_copy(dest, src) __builtin_va_copy(dest, src) | ||
| 719 | +#endif | ||
| 720 | +#endif | ||
| 721 | +#if (!defined(_MSC_VER) || defined(__clang__)) && !defined(__cplusplus) && !defined(__NetBSD__) | ||
| 722 | +// mingw-w64 stdio.h declares these as static __mingw_ovr inline overrides | ||
| 723 | +// when __USE_MINGW_ANSI_STDIO is on. Skip them under gcc+mingw to avoid | ||
| 724 | +// static-after-extern conflicts; clang+mingw needs them because it builds | ||
| 725 | +// with -Werror=implicit-function-declaration and does not hit the conflict. | ||
| 726 | +// NetBSD pulls these prototypes from <stdio.h>/<stdlib.h>/<string.h> via | ||
| 727 | +// the include block above to avoid `__restrict` qualifier conflicts. | ||
| 728 | +#if !((defined(__MINGW32__) || defined(__MINGW64__)) && !defined(__clang__)) | ||
| 729 | +V_CRT_LINKAGE int V_CRT_CALL vfprintf(FILE *stream, const char *format, va_list ap); | ||
| 730 | +V_CRT_LINKAGE int V_CRT_CALL vsnprintf(char *str, size_t size, const char *format, va_list ap); | ||
| 731 | +V_CRT_LINKAGE int V_CRT_CALL fprintf(FILE *stream, const char *format, ...); | ||
| 732 | +V_CRT_LINKAGE int V_CRT_CALL printf(const char *format, ...); | ||
| 733 | +V_CRT_LINKAGE int V_CRT_CALL snprintf(char *str, size_t size, const char *format, ...); | ||
| 734 | +V_CRT_LINKAGE int V_CRT_CALL sprintf(char *str, const char *format, ...); | ||
| 735 | +V_CRT_LINKAGE int V_CRT_CALL sscanf(const char *str, const char *format, ...); | ||
| 736 | +V_CRT_LINKAGE int V_CRT_CALL scanf(const char *format, ...); | ||
| 737 | +#endif | ||
| 738 | +V_CRT_LINKAGE int V_CRT_CALL puts(const char *str); | ||
| 739 | +V_CRT_LINKAGE void V_CRT_CALL perror(const char *str); | ||
| 740 | +V_CRT_LINKAGE int V_CRT_CALL fputs(const char *str, FILE *stream); | ||
| 741 | +V_CRT_LINKAGE int V_CRT_CALL getchar(void); | ||
| 742 | +V_CRT_LINKAGE int V_CRT_CALL putchar(int ch); | ||
| 743 | +V_CRT_LINKAGE int V_CRT_CALL getc(FILE *stream); | ||
| 744 | +V_CRT_LINKAGE int V_CRT_CALL fgetc(FILE *stream); | ||
| 745 | +V_CRT_LINKAGE int V_CRT_CALL ungetc(int ch, FILE *stream); | ||
| 746 | +V_CRT_LINKAGE int V_CRT_CALL fflush(FILE *stream); | ||
| 747 | +V_CRT_LINKAGE int V_CRT_CALL feof(FILE *stream); | ||
| 748 | +V_CRT_LINKAGE int V_CRT_CALL ferror(FILE *stream); | ||
| 749 | +V_CRT_LINKAGE void V_CRT_CALL clearerr(FILE *stream); | ||
| 750 | +V_CRT_LINKAGE int V_CRT_CALL setvbuf(FILE *stream, char *buf, int mode, size_t size); | ||
| 751 | +V_CRT_LINKAGE long V_CRT_CALL ftell(FILE *stream); | ||
| 752 | +V_CRT_LINKAGE void V_CRT_CALL rewind(FILE *stream); | ||
| 753 | +V_CRT_LINKAGE FILE * V_CRT_CALL fopen(const char *filename, const char *mode); | ||
| 754 | +V_CRT_LINKAGE FILE * V_CRT_CALL fdopen(int fd, const char *mode); | ||
| 755 | +V_CRT_LINKAGE FILE * V_CRT_CALL freopen(const char *filename, const char *mode, FILE *stream); | ||
| 756 | +V_CRT_LINKAGE int V_CRT_CALL fileno(FILE *stream); | ||
| 757 | +V_CRT_LINKAGE size_t V_CRT_CALL fread(void *ptr, size_t size, size_t items, FILE *stream); | ||
| 758 | +V_CRT_LINKAGE size_t V_CRT_CALL fwrite(const void *ptr, size_t size, size_t items, FILE *stream); | ||
| 759 | +#if defined(__vinix__) | ||
| 760 | +V_CRT_LINKAGE char * V_CRT_CALL fgets(char *str, size_t size, FILE *stream); | ||
| 761 | +#else | ||
| 762 | +V_CRT_LINKAGE char * V_CRT_CALL fgets(char *str, int size, FILE *stream); | ||
| 763 | +#endif | ||
| 764 | +V_CRT_LINKAGE int V_CRT_CALL fclose(FILE *stream); | ||
| 765 | +#if defined(__vinix__) | ||
| 766 | +V_CRT_LINKAGE FILE * V_CRT_CALL popen(char *command, char *mode); | ||
| 767 | +#else | ||
| 768 | +V_CRT_LINKAGE FILE * V_CRT_CALL popen(const char *command, const char *mode); | ||
| 769 | +#endif | ||
| 770 | +V_CRT_LINKAGE int V_CRT_CALL pclose(FILE *stream); | ||
| 771 | +V_CRT_LINKAGE void * V_CRT_CALL malloc(size_t size); | ||
| 772 | +V_CRT_LINKAGE void * V_CRT_CALL calloc(size_t nitems, size_t size); | ||
| 773 | +V_CRT_LINKAGE void * V_CRT_CALL realloc(void *ptr, size_t size); | ||
| 774 | +V_CRT_LINKAGE void * V_CRT_CALL aligned_alloc(size_t alignment, size_t size); | ||
| 775 | +V_CRT_LINKAGE int V_CRT_CALL posix_memalign(void **memptr, size_t alignment, size_t size); | ||
| 776 | +V_CRT_LINKAGE void V_CRT_CALL free(void *ptr); | ||
| 777 | +V_CRT_LINKAGE int V_CRT_CALL rand(void); | ||
| 778 | +V_CRT_LINKAGE void V_CRT_CALL srand(unsigned int seed); | ||
| 779 | +V_CRT_LINKAGE int V_CRT_CALL atexit(void (*cb)(void)); | ||
| 780 | +V_CRT_LINKAGE void V_CRT_CALL exit(int status); | ||
| 781 | +V_CRT_LINKAGE int V_CRT_CALL abs(int n); | ||
| 782 | +V_CRT_LINKAGE int V_CRT_CALL atoi(const char *str); | ||
| 783 | +V_CRT_LINKAGE double V_CRT_CALL atof(const char *str); | ||
| 784 | +V_CRT_LINKAGE char * V_CRT_CALL getenv(const char *name); | ||
| 785 | +V_CRT_LINKAGE int V_CRT_CALL setenv(const char *name, const char *value, int overwrite); | ||
| 786 | +V_CRT_LINKAGE int V_CRT_CALL unsetenv(const char *name); | ||
| 787 | +V_CRT_LINKAGE int V_CRT_CALL system(const char *command); | ||
| 788 | +V_CRT_LINKAGE int V_CRT_CALL remove(const char *path); | ||
| 789 | +V_CRT_LINKAGE int V_CRT_CALL rename(const char *old_path, const char *new_path); | ||
| 790 | +V_CRT_LINKAGE char * V_CRT_CALL realpath(const char *path, char *resolved_path); | ||
| 791 | +V_CRT_LINKAGE int V_CRT_CALL mkstemp(char *stemplate); | ||
| 792 | +V_CRT_LINKAGE void V_CRT_CALL qsort(void *base, size_t items, size_t item_size, qsort_callback_func cb); | ||
| 793 | +#if defined(__vinix__) | ||
| 794 | +V_CRT_LINKAGE int V_CRT_CALL strcmp(char *left, char *right); | ||
| 795 | +V_CRT_LINKAGE int V_CRT_CALL strncmp(char *left, char *right, size_t n); | ||
| 796 | +#else | ||
| 797 | +V_CRT_LINKAGE int V_CRT_CALL strcmp(const char *left, const char *right); | ||
| 798 | +V_CRT_LINKAGE int V_CRT_CALL strncmp(const char *left, const char *right, size_t n); | ||
| 799 | +#endif | ||
| 800 | +#if !defined(_WIN32) && !defined(_WIN64) && !defined(__BIONIC__) | ||
| 801 | +V_CRT_LINKAGE char * V_CRT_CALL strdup(const char *str); | ||
| 802 | +#endif | ||
| 803 | +#if !defined(_WIN32) && !defined(_WIN64) | ||
| 804 | +V_CRT_LINKAGE int V_CRT_CALL strcasecmp(const char *left, const char *right); | ||
| 805 | +V_CRT_LINKAGE int V_CRT_CALL strncasecmp(const char *left, const char *right, size_t n); | ||
| 806 | +#endif | ||
| 807 | +#if defined(__vinix__) | ||
| 808 | +V_CRT_LINKAGE size_t V_CRT_CALL strlen(char *str); | ||
| 809 | +#else | ||
| 810 | +V_CRT_LINKAGE size_t V_CRT_CALL strlen(const char *str); | ||
| 811 | +#endif | ||
| 812 | +V_CRT_LINKAGE char * V_CRT_CALL strerror(int errnum); | ||
| 813 | +V_CRT_LINKAGE void * V_CRT_CALL memcpy(void *dest, const void *src, size_t n); | ||
| 814 | +V_CRT_LINKAGE void * V_CRT_CALL memmove(void *dest, const void *src, size_t n); | ||
| 815 | +V_CRT_LINKAGE void * V_CRT_CALL memset(void *dest, int ch, size_t n); | ||
| 816 | +V_CRT_LINKAGE int V_CRT_CALL memcmp(const void *left, const void *right, size_t n); | ||
| 817 | +V_CRT_LINKAGE void * V_CRT_CALL memchr(const void *str, int c, size_t n); | ||
| 818 | +V_CRT_LINKAGE char * V_CRT_CALL strchr(const char *str, int c); | ||
| 819 | +V_CRT_LINKAGE char * V_CRT_CALL strrchr(const char *str, int c); | ||
| 820 | +V_CRT_LINKAGE char * V_CRT_CALL strstr(const char *haystack, const char *needle); | ||
| 821 | +V_CRT_LINKAGE int V_CRT_CALL fseek(FILE *stream, long offset, int whence); | ||
| 822 | +V_CRT_LINKAGE isize V_CRT_CALL getline(char **lineptr, size_t *n, FILE *stream); | ||
| 823 | +#if defined(_WIN32) || defined(_WIN64) | ||
| 824 | +V_CRT_LINKAGE int V_CRT_CALL _fileno(FILE *stream); | ||
| 825 | +V_CRT_LINKAGE FILE * V_CRT_CALL _wfopen(const unsigned short *filename, const unsigned short *mode); | ||
| 826 | +V_CRT_LINKAGE int V_CRT_CALL _wremove(const unsigned short *path); | ||
| 827 | +V_CRT_LINKAGE void * V_CRT_CALL _aligned_malloc(size_t size, size_t alignment); | ||
| 828 | +V_CRT_LINKAGE void * V_CRT_CALL _aligned_realloc(void *memory, size_t size, size_t alignment); | ||
| 829 | +V_CRT_LINKAGE void V_CRT_CALL _aligned_free(void *memory); | ||
| 830 | +V_CRT_LINKAGE unsigned short * V_CRT_CALL _wgetenv(const unsigned short *varname); | ||
| 831 | +V_CRT_LINKAGE int V_CRT_CALL _wputenv(const unsigned short *envstring); | ||
| 832 | +#endif | ||
| 833 | +#if defined(_MSC_VER) && !defined(__clang__) | ||
| 834 | +#ifndef _TRUNCATE | ||
| 835 | + #define _TRUNCATE ((size_t)-1) | ||
| 836 | +#endif | ||
| 837 | +V_CRT_LINKAGE int V_CRT_CALL _vscprintf(const char *format, va_list ap); | ||
| 838 | +V_CRT_LINKAGE int V_CRT_CALL _vsnprintf_s(char *buffer, size_t size, size_t count, const char *format, va_list ap); | ||
| 839 | +#endif | ||
| 840 | +#endif | ||
| 841 | +#ifndef _IOFBF | ||
| 842 | + #define _IOFBF 0 | ||
| 843 | +#endif | ||
| 844 | +#ifndef _IOLBF | ||
| 845 | + #define _IOLBF 1 | ||
| 846 | +#endif | ||
| 847 | +#ifndef _IONBF | ||
| 848 | + #define _IONBF 2 | ||
| 849 | +#endif | ||
| 850 | +#ifndef EOF | ||
| 851 | + #define EOF (-1) | ||
| 852 | +#endif | ||
| 853 | +#ifndef SEEK_SET | ||
| 854 | + #define SEEK_SET 0 | ||
| 855 | +#endif | ||
| 856 | +#ifndef SEEK_CUR | ||
| 857 | + #define SEEK_CUR 1 | ||
| 858 | +#endif | ||
| 859 | +#ifndef SEEK_END | ||
| 860 | + #define SEEK_END 2 | ||
| 861 | +#endif | ||
| 862 | +#ifndef RAND_MAX | ||
| 863 | +enum { | ||
| 864 | + #if defined(_MSC_VER) | ||
| 865 | + RAND_MAX = 0x7fff | ||
| 866 | + #else | ||
| 867 | + RAND_MAX = 2147483647 | ||
| 868 | + #endif | ||
| 869 | +}; | ||
| 870 | +#endif | ||
| 871 | +#undef V_CRT_LINKAGE | ||
| 872 | +#undef V_CRT_CALL | ||
| 873 | +static void v_stable_sort(void *base, size_t items, size_t item_size, qsort_callback_func cb) { | ||
| 874 | + if (items < 2 || item_size == 0) { | ||
| 875 | + return; | ||
| 876 | + } | ||
| 877 | + if (items > ((size_t)-1) / item_size) { | ||
| 878 | + qsort(base, items, item_size, cb); | ||
| 879 | + return; | ||
| 880 | + } | ||
| 881 | + const size_t bytes = items * item_size; | ||
| 882 | + char *base_bytes = (char*)base; | ||
| 883 | + char *tmp = (char*)malloc(bytes); | ||
| 884 | + if (tmp == 0) { | ||
| 885 | + qsort(base, items, item_size, cb); | ||
| 886 | + return; | ||
| 887 | + } | ||
| 888 | + char *src = base_bytes; | ||
| 889 | + char *dst = tmp; | ||
| 890 | + for (size_t width = 1; width < items;) { | ||
| 891 | + for (size_t left = 0; left < items;) { | ||
| 892 | + size_t mid = left; | ||
| 893 | + mid += width; | ||
| 894 | + if (mid > items) { | ||
| 895 | + mid = items; | ||
| 896 | + } | ||
| 897 | + size_t right = mid; | ||
| 898 | + right += width; | ||
| 899 | + if (right > items || right < mid) { | ||
| 900 | + right = items; | ||
| 901 | + } | ||
| 902 | + size_t i = left; | ||
| 903 | + size_t j = mid; | ||
| 904 | + size_t k = left; | ||
| 905 | + while (i < mid && j < right) { | ||
| 906 | + char *leftp = src; | ||
| 907 | + leftp += i * item_size; | ||
| 908 | + char *rightp = src; | ||
| 909 | + rightp += j * item_size; | ||
| 910 | + char *dstp = dst; | ||
| 911 | + dstp += k * item_size; | ||
| 912 | + if (cb(leftp, rightp) <= 0) { | ||
| 913 | + memcpy(dstp, leftp, item_size); | ||
| 914 | + i++; | ||
| 915 | + } else { | ||
| 916 | + memcpy(dstp, rightp, item_size); | ||
| 917 | + j++; | ||
| 918 | + } | ||
| 919 | + k++; | ||
| 920 | + } | ||
| 921 | + while (i < mid) { | ||
| 922 | + char *dstp = dst; | ||
| 923 | + dstp += k * item_size; | ||
| 924 | + char *srcp = src; | ||
| 925 | + srcp += i * item_size; | ||
| 926 | + memcpy(dstp, srcp, item_size); | ||
| 927 | + i++; | ||
| 928 | + k++; | ||
| 929 | + } | ||
| 930 | + while (j < right) { | ||
| 931 | + char *dstp = dst; | ||
| 932 | + dstp += k * item_size; | ||
| 933 | + char *srcp = src; | ||
| 934 | + srcp += j * item_size; | ||
| 935 | + memcpy(dstp, srcp, item_size); | ||
| 936 | + j++; | ||
| 937 | + k++; | ||
| 938 | + } | ||
| 939 | + left = right; | ||
| 940 | + } | ||
| 941 | + char *next_src = dst; | ||
| 942 | + dst = src; | ||
| 943 | + src = next_src; | ||
| 944 | + if (width > items / 2) { | ||
| 945 | + width = items; | ||
| 946 | + } else { | ||
| 947 | + width *= 2; | ||
| 948 | + } | ||
| 949 | + } | ||
| 950 | + if (src != base_bytes) { | ||
| 951 | + memcpy(base_bytes, src, bytes); | ||
| 952 | + } | ||
| 953 | + free(tmp); | ||
| 954 | +} | ||
| 955 | +#if defined(__TINYC__) | ||
| 956 | +// https://lists.nongnu.org/archive/html/tinycc-devel/2025-10/msg00007.html | ||
| 957 | +// gnu headers use to #define __attribute__ to empty for non-gcc compilers | ||
| 958 | +#undef __attribute__ | ||
| 959 | +#endif | ||
| 960 | +#if defined(_MSC_VER) && !defined(__clang__) | ||
| 961 | +// Ensure C99-like return semantics and NUL-termination for MSVC snprintf/vsnprintf. | ||
| 962 | +static int v__vsnprintf(char *s, size_t n, const char *fmt, va_list ap) { | ||
| 963 | + va_list ap_copy; | ||
| 964 | + va_copy(ap_copy, ap); | ||
| 965 | + const int needed = _vscprintf(fmt, ap_copy); | ||
| 966 | + va_end(ap_copy); | ||
| 967 | + if (n > 0) { | ||
| 968 | + const int written = _vsnprintf_s(s, n, _TRUNCATE, fmt, ap); | ||
| 969 | + if (written < 0) { | ||
| 970 | + s[n - | ||
| 971 | + 1] = 0; | ||
| 972 | + } | ||
| 973 | + } | ||
| 974 | + return needed; | ||
| 975 | +} | ||
| 976 | +static int v__snprintf(char *s, size_t n, const char *fmt, ...) { | ||
| 977 | + va_list ap; | ||
| 978 | + va_start(ap, fmt); | ||
| 979 | + const int needed = v__vsnprintf(s, n, fmt, ap); | ||
| 980 | + va_end(ap); | ||
| 981 | + return needed; | ||
| 982 | +} | ||
| 983 | +#define vsnprintf v__vsnprintf | ||
| 984 | +#define snprintf v__snprintf | ||
| 985 | +#endif | ||
| 986 | +//================================== GLOBALS =================================*/ | ||
| 987 | +#ifdef _VOBJECTFILE | ||
| 988 | +static void _vinit(int ___argc, voidptr ___argv); | ||
| 989 | +static void _vcleanup(void); | ||
| 990 | +#else | ||
| 991 | +void _vinit(int ___argc, voidptr ___argv); | ||
| 992 | +void _vcleanup(void); | ||
| 993 | +#endif | ||
| 994 | +#ifdef _WIN32 | ||
| 995 | + // Export helpers so the autogenerated DllMain, or a user-defined one, | ||
| 996 | + // can reuse the default V shared-library init/cleanup path. | ||
| 997 | + #ifdef _VOBJECTFILE | ||
| 998 | + static void _vinit_caller(); | ||
| 999 | + static void _vcleanup_caller(); | ||
| 1000 | + #else | ||
| 1001 | + VV_EXP void _vinit_caller(); | ||
| 1002 | + VV_EXP void _vcleanup_caller(); | ||
| 1003 | + #endif | ||
| 1004 | +#endif | ||
| 1005 | +#if !defined(_WIN32) | ||
| 1006 | +#define sigaction_size sizeof(sigaction); | ||
| 1007 | +#endif | ||
| 1008 | +#define _ARR_LEN(a) ( (sizeof(a)) / (sizeof(a[0])) ) | ||
| 1009 | +#if INTPTR_MAX == INT32_MAX | ||
| 1010 | + #define TARGET_IS_32BIT 1 | ||
| 1011 | +#elif INTPTR_MAX == INT64_MAX | ||
| 1012 | + #define TARGET_IS_64BIT 1 | ||
| 1013 | +#else | ||
| 1014 | + #error "The environment is not 32 or 64-bit." | ||
| 1015 | +#endif | ||
| 1016 | +#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ || defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN || defined(__BIG_ENDIAN__) || defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || defined(_MIBSEB) || defined(__MIBSEB) || defined(__MIBSEB__) | ||
| 1017 | + #define TARGET_ORDER_IS_BIG 1 | ||
| 1018 | +#elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ || defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN || defined(__LITTLE_ENDIAN__) || defined(__ARMEL__) || defined(__THUMBEL__) || defined(__AARCH64EL__) || defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__) || defined(_M_AMD64) || defined(_M_ARM64) || defined(_M_X64) || defined(_M_IX86) | ||
| 1019 | + #define TARGET_ORDER_IS_LITTLE 1 | ||
| 1020 | +#else | ||
| 1021 | + #error "Unknown architecture endianness" | ||
| 1022 | +#endif | ||
| 1023 | +#if !defined(_WIN32) && !defined(__vinix__) | ||
| 1024 | + #include <ctype.h> | ||
| 1025 | + #include <locale.h> // tolower | ||
| 1026 | + #include <sys/time.h> | ||
| 1027 | + #include <unistd.h> // sleep | ||
| 1028 | + extern char **environ; | ||
| 1029 | + #include <pthread.h> | ||
| 1030 | + #ifndef PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP | ||
| 1031 | + // musl does not have that | ||
| 1032 | + #define pthread_rwlockattr_setkind_np(a, b) | ||
| 1033 | + #endif | ||
| 1034 | +#endif | ||
| 1035 | +#if (defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__serenity__) || defined(__sun) || defined(__plan9__) || defined(__OpenBSD__)) && !defined(__vinix__) | ||
| 1036 | + #include <sys/types.h> | ||
| 1037 | + #include <sys/wait.h> // for os__wait | ||
| 1038 | +#endif | ||
| 1039 | +#ifdef __OpenBSD__ | ||
| 1040 | + #include <sys/resource.h> | ||
| 1041 | +#endif | ||
| 1042 | +#ifdef __FreeBSD__ | ||
| 1043 | + #include <signal.h> | ||
| 1044 | + #include <execinfo.h> | ||
| 1045 | +#endif | ||
| 1046 | +#ifdef __NetBSD__ | ||
| 1047 | + #include <sys/wait.h> // for os__wait | ||
| 1048 | +#endif | ||
| 1049 | +#ifdef __TERMUX__ | ||
| 1050 | +#if !defined(__BIONIC_AVAILABILITY_GUARD) | ||
| 1051 | + #define __BIONIC_AVAILABILITY_GUARD(api_level) 0 | ||
| 1052 | +#endif | ||
| 1053 | +#if __BIONIC_AVAILABILITY_GUARD(28) | ||
| 1054 | +#else | ||
| 1055 | +void * aligned_alloc(size_t alignment, size_t size) { return malloc(size); } | ||
| 1056 | +#endif | ||
| 1057 | +#endif | ||
| 1058 | +#ifdef __APPLE__ | ||
| 1059 | + // macOS only exports aligned_alloc starting with 10.15. | ||
| 1060 | + #if !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500 | ||
| 1061 | +static void *v__aligned_alloc_fallback(size_t alignment, size_t size) { | ||
| 1062 | + void *res = 0; | ||
| 1063 | + if (alignment < sizeof(void *)) { | ||
| 1064 | + alignment = sizeof(void *); | ||
| 1065 | + } | ||
| 1066 | + if (posix_memalign(&res, alignment, size) != 0) { | ||
| 1067 | + return 0; | ||
| 1068 | + } | ||
| 1069 | + return res; | ||
| 1070 | +} | ||
| 1071 | + #define aligned_alloc v__aligned_alloc_fallback | ||
| 1072 | + #endif | ||
| 1073 | +#endif | ||
| 1074 | +#ifdef _WIN32 | ||
| 1075 | + #ifdef WINVER | ||
| 1076 | + #undef WINVER | ||
| 1077 | + #endif | ||
| 1078 | + #define WINVER 0x0600 | ||
| 1079 | + #ifdef _WIN32_WINNT | ||
| 1080 | + #undef _WIN32_WINNT | ||
| 1081 | + #endif | ||
| 1082 | + #define _WIN32_WINNT 0x0600 | ||
| 1083 | + #ifndef WIN32_FULL | ||
| 1084 | + #define WIN32_LEAN_AND_MEAN | ||
| 1085 | + #endif | ||
| 1086 | + #ifndef _UNICODE | ||
| 1087 | + #define _UNICODE | ||
| 1088 | + #endif | ||
| 1089 | + #ifndef UNICODE | ||
| 1090 | + #define UNICODE | ||
| 1091 | + #endif | ||
| 1092 | + #include <windows.h> | ||
| 1093 | + #include <io.h> // _waccess | ||
| 1094 | + #include <direct.h> // _wgetcwd | ||
| 1095 | + #ifdef V_USE_SIGNAL_H | ||
| 1096 | + #include <signal.h> // signal and SIGSEGV for segmentation fault handler | ||
| 1097 | + #endif | ||
| 1098 | + #ifdef _MSC_VER | ||
| 1099 | + // On MSVC these are the same (as long as /volatile:ms is passed) | ||
| 1100 | + #define _Atomic volatile | ||
| 1101 | + // MSVC cannot parse some things properly | ||
| 1102 | + #undef __NOINLINE | ||
| 1103 | + #undef __IRQHANDLER | ||
| 1104 | + #define __NOINLINE __declspec(noinline) | ||
| 1105 | + #define __IRQHANDLER __declspec(naked) | ||
| 1106 | + #include <dbghelp.h> | ||
| 1107 | + #pragma comment(lib, "Dbghelp") | ||
| 1108 | + #endif | ||
| 1109 | +#endif | ||
| 1110 | +#if defined(__CYGWIN__) && !defined(_WIN32) | ||
| 1111 | + #error Cygwin is not supported, please use MinGW or Visual Studio. | ||
| 1112 | +#endif | ||
| 1113 | +#if defined(__MINGW32__) || defined(__MINGW64__) || (defined(_WIN32) && defined(__TINYC__)) || defined(_MSC_VER) | ||
| 1114 | + #undef PRId64 | ||
| 1115 | + #undef PRIi64 | ||
| 1116 | + #undef PRIo64 | ||
| 1117 | + #undef PRIu64 | ||
| 1118 | + #undef PRIx64 | ||
| 1119 | + #undef PRIX64 | ||
| 1120 | + #define PRId64 "lld" | ||
| 1121 | + #define PRIi64 "lli" | ||
| 1122 | + #define PRIo64 "llo" | ||
| 1123 | + #define PRIu64 "llu" | ||
| 1124 | + #define PRIx64 "llx" | ||
| 1125 | + #define PRIX64 "llX" | ||
| 1126 | +#endif | ||
| 1127 | +#ifdef _VFREESTANDING | ||
| 1128 | +#undef _VFREESTANDING | ||
| 1129 | +#endif | ||
| 1130 | + | ||
| 1131 | + | ||
| 1132 | +// deterministic float -> u64 conversions for explicit V casts | ||
| 1133 | +// direct C casts are undefined for out-of-range values | ||
| 1134 | +static inline uint64_t _v_f64_to_u64(double x) { | ||
| 1135 | + if (!(x >= 0.0)) { | ||
| 1136 | + return 0; | ||
| 1137 | + } | ||
| 1138 | + if (x >= 18446744073709551616.0) { | ||
| 1139 | + return UINT64_MAX; | ||
| 1140 | + } | ||
| 1141 | + return (uint64_t)x; | ||
| 1142 | +} | ||
| 1143 | + | ||
| 1144 | + | ||
| 1145 | +// unsigned/signed comparisons | ||
| 1146 | +static inline bool _us32_gt(uint32_t a, int32_t b) { return a > INT32_MAX || (int32_t)a > b; } | ||
| 1147 | +static inline bool _us32_ge(uint32_t a, int32_t b) { return a >= INT32_MAX || (int32_t)a >= b; } | ||
| 1148 | +static inline bool _us32_eq(uint32_t a, int32_t b) { return a <= INT32_MAX && (int32_t)a == b; } | ||
| 1149 | +static inline bool _us32_ne(uint32_t a, int32_t b) { return a > INT32_MAX || (int32_t)a != b; } | ||
| 1150 | +static inline bool _us32_le(uint32_t a, int32_t b) { return a <= INT32_MAX && (int32_t)a <= b; } | ||
| 1151 | +static inline bool _us32_lt(uint32_t a, int32_t b) { return a < INT32_MAX && (int32_t)a < b; } | ||
| 1152 | +static inline bool _us64_gt(uint64_t a, int64_t b) { return a > INT64_MAX || (int64_t)a > b; } | ||
| 1153 | +static inline bool _us64_ge(uint64_t a, int64_t b) { return a >= INT64_MAX || (int64_t)a >= b; } | ||
| 1154 | +static inline bool _us64_eq(uint64_t a, int64_t b) { return a <= INT64_MAX && (int64_t)a == b; } | ||
| 1155 | +static inline bool _us64_ne(uint64_t a, int64_t b) { return a > INT64_MAX || (int64_t)a != b; } | ||
| 1156 | +static inline bool _us64_le(uint64_t a, int64_t b) { return a <= INT64_MAX && (int64_t)a <= b; } | ||
| 1157 | +static inline bool _us64_lt(uint64_t a, int64_t b) { return a < INT64_MAX && (int64_t)a < b; } | ||
| 1158 | + | ||
| 1159 | + | ||
| 1160 | +#if !defined(VNORETURN) | ||
| 1161 | + #if defined(__TINYC__) | ||
| 1162 | + #define VNORETURN __attribute__((noreturn)) | ||
| 1163 | + # elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L | ||
| 1164 | + # define VNORETURN _Noreturn | ||
| 1165 | + # elif !defined(VNORETURN) && defined(__GNUC__) && __GNUC__ >= 2 | ||
| 1166 | + # define VNORETURN __attribute__((noreturn)) | ||
| 1167 | + # endif | ||
| 1168 | + #ifndef VNORETURN | ||
| 1169 | + #define VNORETURN | ||
| 1170 | + #endif | ||
| 1171 | +#endif | ||
| 1172 | + | ||
| 1173 | + | ||
| 1174 | +#if !defined(VUNREACHABLE) | ||
| 1175 | + #if defined(__GNUC__) && !defined(__clang__) | ||
| 1176 | + #define V_GCC_VERSION (__GNUC__ * 10000L + __GNUC_MINOR__ * 100L + __GNUC_PATCHLEVEL__) | ||
| 1177 | + #if (V_GCC_VERSION >= 40500L) && !defined(__TINYC__) | ||
| 1178 | + #define VUNREACHABLE() do { __builtin_unreachable(); } while (0) | ||
| 1179 | + #endif | ||
| 1180 | + #endif | ||
| 1181 | + #if defined(__clang__) && defined(__has_builtin) && !defined(__TINYC__) | ||
| 1182 | + #if __has_builtin(__builtin_unreachable) | ||
| 1183 | + #define VUNREACHABLE() do { __builtin_unreachable(); } while (0) | ||
| 1184 | + #endif | ||
| 1185 | + #endif | ||
| 1186 | + #ifndef VUNREACHABLE | ||
| 1187 | + #define VUNREACHABLE() do { } while (0) | ||
| 1188 | + #endif | ||
| 1189 | +#endif | ||
| 1190 | + | ||
| 1191 | + | ||
| 1192 | +#ifndef wyhash_final_version_4_2 | ||
| 1193 | +#define wyhash_final_version_4_2 | ||
| 1194 | +#ifndef WYHASH_CONDOM | ||
| 1195 | +// protections that produce different results: | ||
| 1196 | +// 1: normal valid behavior | ||
| 1197 | +// 2: extra protection against entropy loss (probability=2^-63), aka. "blind multiplication" | ||
| 1198 | +#define WYHASH_CONDOM 1 | ||
| 1199 | +#endif | ||
| 1200 | +#ifndef WYHASH_32BIT_MUM | ||
| 1201 | +// 0: normal version, slow on 32 bit systems | ||
| 1202 | +// 1: faster on 32 bit systems but produces different results, incompatible with wy2u0k function | ||
| 1203 | +#define WYHASH_32BIT_MUM 0 | ||
| 1204 | +#endif | ||
| 1205 | +// includes | ||
| 1206 | +#include <stdint.h> | ||
| 1207 | +#if defined(_MSC_VER) && defined(_M_X64) | ||
| 1208 | + #include <intrin.h> | ||
| 1209 | + #pragma intrinsic(_umul128) | ||
| 1210 | +#endif | ||
| 1211 | +// 128bit multiply function | ||
| 1212 | +static inline uint64_t _wyrot(uint64_t x) { return (x>>32)|(x<<32); } | ||
| 1213 | +static inline void _wymum(uint64_t *A, uint64_t *B){ | ||
| 1214 | +#if(WYHASH_32BIT_MUM) | ||
| 1215 | + uint64_t hh=(*A>>32)*(*B>>32), hl=(*A>>32)*(uint32_t)*B, lh=(uint32_t)*A*(*B>>32), ll=(uint64_t)(uint32_t)*A*(uint32_t)*B; | ||
| 1216 | + #if(WYHASH_CONDOM>1) | ||
| 1217 | + *A^=_wyrot(hl)^hh; *B^=_wyrot(lh)^ll; | ||
| 1218 | + #else | ||
| 1219 | + *A=_wyrot(hl)^hh; *B=_wyrot(lh)^ll; | ||
| 1220 | + #endif | ||
| 1221 | +#elif defined(__SIZEOF_INT128__) && !defined(VWASM) | ||
| 1222 | + __uint128_t r=*A; r*=*B; | ||
| 1223 | + #if(WYHASH_CONDOM>1) | ||
| 1224 | + *A^=(uint64_t)r; *B^=(uint64_t)(r>>64); | ||
| 1225 | + #else | ||
| 1226 | + *A=(uint64_t)r; *B=(uint64_t)(r>>64); | ||
| 1227 | + #endif | ||
| 1228 | +#elif defined(_MSC_VER) && defined(_M_X64) | ||
| 1229 | + #if(WYHASH_CONDOM>1) | ||
| 1230 | + uint64_t a, b; | ||
| 1231 | + a=_umul128(*A,*B,&b); | ||
| 1232 | + *A^=a; *B^=b; | ||
| 1233 | + #else | ||
| 1234 | + *A=_umul128(*A,*B,B); | ||
| 1235 | + #endif | ||
| 1236 | +#else | ||
| 1237 | + uint64_t ha=*A>>32, hb=*B>>32, la=(uint32_t)*A, lb=(uint32_t)*B, hi, lo; | ||
| 1238 | + uint64_t rh=ha*hb, rm0=ha*lb, rm1=hb*la, rl=la*lb, t=rl+(rm0<<32), c=t<rl; | ||
| 1239 | + lo=t+(rm1<<32); c+=lo<t; hi=rh+(rm0>>32)+(rm1>>32)+c; | ||
| 1240 | + #if(WYHASH_CONDOM>1) | ||
| 1241 | + *A^=lo; *B^=hi; | ||
| 1242 | + #else | ||
| 1243 | + *A=lo; *B=hi; | ||
| 1244 | + #endif | ||
| 1245 | +#endif | ||
| 1246 | +} | ||
| 1247 | +// multiply and xor mix function, aka MUM | ||
| 1248 | +static inline uint64_t _wymix(uint64_t A, uint64_t B){ _wymum(&A,&B); return A^B; } | ||
| 1249 | +// endian macros | ||
| 1250 | +#ifndef WYHASH_LITTLE_ENDIAN | ||
| 1251 | + #ifdef TARGET_ORDER_IS_LITTLE | ||
| 1252 | + #define WYHASH_LITTLE_ENDIAN 1 | ||
| 1253 | + #else | ||
| 1254 | + #define WYHASH_LITTLE_ENDIAN 0 | ||
| 1255 | + #endif | ||
| 1256 | +#endif | ||
| 1257 | +// read functions | ||
| 1258 | +#if (WYHASH_LITTLE_ENDIAN) | ||
| 1259 | + static inline uint64_t _wyr8(const uint8_t *p) { uint64_t v; memcpy(&v, p, 8); return v;} | ||
| 1260 | + static inline uint64_t _wyr4(const uint8_t *p) { uint32_t v; memcpy(&v, p, 4); return v;} | ||
| 1261 | +#elif !defined(__TINYC__) && (defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__clang__)) | ||
| 1262 | + static inline uint64_t _wyr8(const uint8_t *p) { uint64_t v; memcpy(&v, p, 8); return __builtin_bswap64(v);} | ||
| 1263 | + static inline uint64_t _wyr4(const uint8_t *p) { uint32_t v; memcpy(&v, p, 4); return __builtin_bswap32(v);} | ||
| 1264 | +#elif defined(_MSC_VER) | ||
| 1265 | + static inline uint64_t _wyr8(const uint8_t *p) { uint64_t v; memcpy(&v, p, 8); return _byteswap_uint64(v);} | ||
| 1266 | + static inline uint64_t _wyr4(const uint8_t *p) { uint32_t v; memcpy(&v, p, 4); return _byteswap_ulong(v);} | ||
| 1267 | +#else | ||
| 1268 | + static inline uint64_t _wyr8(const uint8_t *p) { | ||
| 1269 | + uint64_t v; memcpy(&v, p, 8); | ||
| 1270 | + return (((v >> 56) & 0xff)| ((v >> 40) & 0xff00)| ((v >> 24) & 0xff0000)| ((v >> 8) & 0xff000000)| ((v << 8) & 0xff00000000)| ((v << 24) & 0xff0000000000)| ((v << 40) & 0xff000000000000)| ((v << 56) & 0xff00000000000000)); | ||
| 1271 | + } | ||
| 1272 | + static inline uint64_t _wyr4(const uint8_t *p) { | ||
| 1273 | + uint32_t v; memcpy(&v, p, 4); | ||
| 1274 | + return (((v >> 24) & 0xff)| ((v >> 8) & 0xff00)| ((v << 8) & 0xff0000)| ((v << 24) & 0xff000000)); | ||
| 1275 | + } | ||
| 1276 | +#endif | ||
| 1277 | +static inline uint64_t _wyr3(const uint8_t *p, size_t k) { return (((uint64_t)p[0])<<16)|(((uint64_t)p[k>>1])<<8)|p[k-1];} | ||
| 1278 | +// wyhash main function | ||
| 1279 | +static inline uint64_t wyhash(const void *key, size_t len, uint64_t seed, const uint64_t *secret){ | ||
| 1280 | + const uint8_t *p=(const uint8_t *)key; seed^=_wymix(seed^secret[0]^len,secret[1]); uint64_t a, b; | ||
| 1281 | + if (_likely_(len<=16)) { | ||
| 1282 | + if (_likely_(len>=4)) { a=(_wyr4(p)<<32)|_wyr4(p+((len>>3)<<2)); b=(_wyr4(p+len-4)<<32)|_wyr4(p+len-4-((len>>3)<<2)); } | ||
| 1283 | + else if (_likely_(len>0)) { a=_wyr3(p,len); b=0; } | ||
| 1284 | + else a=b=0; | ||
| 1285 | + } else { | ||
| 1286 | + size_t i=len; | ||
| 1287 | + if (_unlikely_(i>=48)) { | ||
| 1288 | + uint64_t see1=seed, see2=seed; | ||
| 1289 | + do { | ||
| 1290 | + seed=_wymix(_wyr8(p)^secret[1],_wyr8(p+8)^seed); | ||
| 1291 | + see1=_wymix(_wyr8(p+16)^secret[2],_wyr8(p+24)^see1); | ||
| 1292 | + see2=_wymix(_wyr8(p+32)^secret[3],_wyr8(p+40)^see2); | ||
| 1293 | + p+=48; i-=48; | ||
| 1294 | + } while(_likely_(i>=48)); | ||
| 1295 | + seed^=see1^see2; | ||
| 1296 | + } | ||
| 1297 | + while(_unlikely_(i>16)) { seed=_wymix(_wyr8(p)^secret[1],_wyr8(p+8)^seed); i-=16; p+=16; } | ||
| 1298 | + a=_wyr8(p+i-16); b=_wyr8(p+i-8); | ||
| 1299 | + } | ||
| 1300 | + a^=secret[1]; b^=seed; _wymum(&a,&b); | ||
| 1301 | + return _wymix(a^secret[0]^len,b^secret[1]); | ||
| 1302 | +} | ||
| 1303 | +// the default secret parameters | ||
| 1304 | +static const uint64_t _wyp[4] = {0x2d358dccaa6c78a5ull, 0x8bb84b93962eacc9ull, 0x4b33a62ed433d4a3ull, 0x4d5a2da51de1aa47ull}; | ||
| 1305 | +// a useful 64bit-64bit mix function to produce deterministic pseudo random numbers that can pass BigCrush and PractRand | ||
| 1306 | +static inline uint64_t wyhash64(uint64_t A, uint64_t B){ A^=0x2d358dccaa6c78a5ull; B^=0x8bb84b93962eacc9ull; _wymum(&A,&B); return _wymix(A^0x2d358dccaa6c78a5ull,B^0x8bb84b93962eacc9ull);} | ||
| 1307 | +// the wyrand PRNG that pass BigCrush and PractRand | ||
| 1308 | +static inline uint64_t wyrand(uint64_t *seed){ *seed+=0x2d358dccaa6c78a5ull; return _wymix(*seed,*seed^0x8bb84b93962eacc9ull);} | ||
| 1309 | +#ifndef __vinix__ | ||
| 1310 | +// convert any 64 bit pseudo random numbers to uniform distribution [0,1). It can be combined with wyrand, wyhash64 or wyhash. | ||
| 1311 | +static inline double wy2u01(uint64_t r){ const double _wynorm=1.0/(1ull<<52); return (r>>12)*_wynorm;} | ||
| 1312 | +// convert any 64 bit pseudo random numbers to APPROXIMATE Gaussian distribution. It can be combined with wyrand, wyhash64 or wyhash. | ||
| 1313 | +static inline double wy2gau(uint64_t r){ const double _wynorm=1.0/(1ull<<20); return ((r&0x1fffff)+((r>>21)&0x1fffff)+((r>>42)&0x1fffff))*_wynorm-3.0;} | ||
| 1314 | +#endif | ||
| 1315 | +#if(!WYHASH_32BIT_MUM) | ||
| 1316 | +// fast range integer random number generation on [0,k) credit to Daniel Lemire. May not work when WYHASH_32BIT_MUM=1. It can be combined with wyrand, wyhash64 or wyhash. | ||
| 1317 | +static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; } | ||
| 1318 | +#endif | ||
| 1319 | +#endif | ||
| 1320 | +#define _IN_MAP(val, m) builtin__map_exists(m, val) | ||
| 1321 | + | ||
| 1322 | +#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 30 | ||
| 1323 | +#include <sys/syscall.h> | ||
| 1324 | +#define gettid() syscall(SYS_gettid) | ||
| 1325 | +#endif | ||
| 1326 | + | ||
| 1327 | +// V includes: | ||
| 1328 | + | ||
| 1329 | +#if defined(__TINYC__) && defined(__has_include) // tcc does not support has_include properly yet, turn it off completely | ||
| 1330 | +#undef __has_include | ||
| 1331 | +#endif | ||
| 1332 | + | ||
| 1333 | +#if defined(__TINYC__) && defined(__BIONIC__) | ||
| 1334 | + #define __builtin_nanf(ignored_string) (0.0F / 0.0F) | ||
| 1335 | + #define __builtin_nan(ignored_string) (0.0 / 0.0) | ||
| 1336 | + #define __builtin_nanl(ignored_string) (0.0L / 0.0L) | ||
| 1337 | + #define __builtin_inff() (1.0F / 0.0F) | ||
| 1338 | + #define __builtin_inf() (1.0 / 0.0) | ||
| 1339 | + #define __builtin_infl() (1.0L / 0.0L) | ||
| 1340 | + #define __builtin_huge_valf() (1.0F / 0.0F) | ||
| 1341 | + #define __builtin_huge_val() (1.0 / 0.0) | ||
| 1342 | + #define __builtin_huge_vall() (1.0L / 0.0L) | ||
| 1343 | +#endif | ||
| 1344 | + | ||
| 1345 | +#if 1 | ||
| 1346 | + | ||
| 1347 | +// added by module `builtin.closure`, file: closure_nix.c.v:4: | ||
| 1348 | + | ||
| 1349 | +#ifdef __TINYC__ | ||
| 1350 | +#include <sys/mman.h> | ||
| 1351 | +#else | ||
| 1352 | +#if defined(__has_include) | ||
| 1353 | +#if __has_include(<sys/mman.h>) | ||
| 1354 | +#include <sys/mman.h> | ||
| 1355 | +#else | ||
| 1356 | +#error VERROR_MESSAGE Header file <sys/mman.h>, needed for module `builtin.closure` was not found. Please install the corresponding development headers. | ||
| 1357 | +#endif | ||
| 1358 | +#else | ||
| 1359 | +#include <sys/mman.h> | ||
| 1360 | +#endif | ||
| 1361 | +#endif | ||
| 1362 | + | ||
| 1363 | + | ||
| 1364 | +// inserted by module `builtin.closure`, file: closure_nix.c.v:5: | ||
| 1365 | +#ifndef V_CLOSURE_ONCE_NIX_H | ||
| 1366 | +#define V_CLOSURE_ONCE_NIX_H | ||
| 1367 | + | ||
| 1368 | +#include <pthread.h> | ||
| 1369 | + | ||
| 1370 | +typedef void (*v_closure_init_fn)(void); | ||
| 1371 | + | ||
| 1372 | +#ifndef V_CLOSURE_STATIC_INLINE | ||
| 1373 | +# ifdef _MSC_VER | ||
| 1374 | +# define V_CLOSURE_STATIC_INLINE static __inline | ||
| 1375 | +# else | ||
| 1376 | +# define V_CLOSURE_STATIC_INLINE static inline | ||
| 1377 | +# endif | ||
| 1378 | +#endif | ||
| 1379 | + | ||
| 1380 | +static pthread_mutex_t v_closure_once_mutex = PTHREAD_MUTEX_INITIALIZER; | ||
| 1381 | +static int v_closure_once_done = 0; | ||
| 1382 | + | ||
| 1383 | +V_CLOSURE_STATIC_INLINE void v_closure_init_once(v_closure_init_fn init_fn) { | ||
| 1384 | + pthread_mutex_lock(&v_closure_once_mutex); | ||
| 1385 | + if (!v_closure_once_done) { | ||
| 1386 | + init_fn(); | ||
| 1387 | + v_closure_once_done = 1; | ||
| 1388 | + } | ||
| 1389 | + pthread_mutex_unlock(&v_closure_once_mutex); | ||
| 1390 | +} | ||
| 1391 | + | ||
| 1392 | +#endif | ||
| 1393 | + | ||
| 1394 | +#endif | ||
| 1395 | + | ||
| 1396 | +#if 1 | ||
| 1397 | + | ||
| 1398 | +// added by module `builtin.closure`, file: closure_nix.c.v:4: | ||
| 1399 | + | ||
| 1400 | +#ifdef __TINYC__ | ||
| 1401 | +#include <sys/mman.h> | ||
| 1402 | +#else | ||
| 1403 | +#if defined(__has_include) | ||
| 1404 | +#if __has_include(<sys/mman.h>) | ||
| 1405 | +#include <sys/mman.h> | ||
| 1406 | +#else | ||
| 1407 | +#error VERROR_MESSAGE Header file <sys/mman.h>, needed for module `builtin.closure` was not found. Please install the corresponding development headers. | ||
| 1408 | +#endif | ||
| 1409 | +#else | ||
| 1410 | +#include <sys/mman.h> | ||
| 1411 | +#endif | ||
| 1412 | +#endif | ||
| 1413 | + | ||
| 1414 | + | ||
| 1415 | +// inserted by module `builtin.closure`, file: closure_nix.c.v:5: | ||
| 1416 | +#ifndef V_CLOSURE_ONCE_NIX_H | ||
| 1417 | +#define V_CLOSURE_ONCE_NIX_H | ||
| 1418 | + | ||
| 1419 | +#include <pthread.h> | ||
| 1420 | + | ||
| 1421 | +typedef void (*v_closure_init_fn)(void); | ||
| 1422 | + | ||
| 1423 | +#ifndef V_CLOSURE_STATIC_INLINE | ||
| 1424 | +# ifdef _MSC_VER | ||
| 1425 | +# define V_CLOSURE_STATIC_INLINE static __inline | ||
| 1426 | +# else | ||
| 1427 | +# define V_CLOSURE_STATIC_INLINE static inline | ||
| 1428 | +# endif | ||
| 1429 | +#endif | ||
| 1430 | + | ||
| 1431 | +static pthread_mutex_t v_closure_once_mutex = PTHREAD_MUTEX_INITIALIZER; | ||
| 1432 | +static int v_closure_once_done = 0; | ||
| 1433 | + | ||
| 1434 | +V_CLOSURE_STATIC_INLINE void v_closure_init_once(v_closure_init_fn init_fn) { | ||
| 1435 | + pthread_mutex_lock(&v_closure_once_mutex); | ||
| 1436 | + if (!v_closure_once_done) { | ||
| 1437 | + init_fn(); | ||
| 1438 | + v_closure_once_done = 1; | ||
| 1439 | + } | ||
| 1440 | + pthread_mutex_unlock(&v_closure_once_mutex); | ||
| 1441 | +} | ||
| 1442 | + | ||
| 1443 | +#endif | ||
| 1444 | + | ||
| 1445 | +#endif | ||
| 1446 | + | ||
| 1447 | +// inserted by module `builtin`, file: allocation.c.v:43: | ||
| 1448 | +#ifndef V_TRACK_HEAP_CHECKS_H | ||
| 1449 | +#define V_TRACK_HEAP_CHECKS_H | ||
| 1450 | + | ||
| 1451 | +#if defined(CUSTOM_DEFINE_track_heap) && (defined(_VGCBOEHM) || defined(CUSTOM_DEFINE_gcboehm)) | ||
| 1452 | +#error "-d track_heap requires manual memory management; rebuild with -gc none" | ||
| 1453 | +#endif | ||
| 1454 | + | ||
| 1455 | +#if defined(CUSTOM_DEFINE_track_heap) && defined(CUSTOM_DEFINE_vgc) | ||
| 1456 | +#error "-d track_heap requires manual memory management; rebuild with -gc none" | ||
| 1457 | +#endif | ||
| 1458 | + | ||
| 1459 | +#if defined(CUSTOM_DEFINE_track_heap) && defined(_VPREALLOC) | ||
| 1460 | +#error "-d track_heap requires manual memory management; rebuild with -gc none (not -prealloc)" | ||
| 1461 | +#endif | ||
| 1462 | + | ||
| 1463 | +#endif | ||
| 1464 | + | ||
| 1465 | + | ||
| 1466 | +// added by module `builtin`, file: float.c.v:9: | ||
| 1467 | + | ||
| 1468 | +#ifdef __TINYC__ | ||
| 1469 | +#include <float.h> | ||
| 1470 | +#else | ||
| 1471 | +#if defined(__has_include) | ||
| 1472 | +#if __has_include(<float.h>) | ||
| 1473 | +#include <float.h> | ||
| 1474 | +#else | ||
| 1475 | +#error VERROR_MESSAGE Header file <float.h>, needed for module `builtin` was not found. Please install the corresponding development headers. | ||
| 1476 | +#endif | ||
| 1477 | +#else | ||
| 1478 | +#include <float.h> | ||
| 1479 | +#endif | ||
| 1480 | +#endif | ||
| 1481 | + | ||
| 1482 | +#if !defined(__cplusplus) && !defined(CUSTOM_DEFINE_no_bool) | ||
| 1483 | +#ifdef bool | ||
| 1484 | +#undef bool | ||
| 1485 | +#endif | ||
| 1486 | +#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 202311L | ||
| 1487 | +#ifdef CUSTOM_DEFINE_4bytebool | ||
| 1488 | +typedef int bool; | ||
| 1489 | +#else | ||
| 1490 | +typedef u8 bool; | ||
| 1491 | +#endif | ||
| 1492 | +#endif | ||
| 1493 | +#endif | ||
| 1494 | + | ||
| 1495 | +// V global/const #define ... : | ||
| 1496 | +#define _const_builtin__closure__assumed_page_size 16384 | ||
| 1497 | +#define _const_strconv__digits 18 | ||
| 1498 | +#define _const_strconv__c_dpoint '.' | ||
| 1499 | +#define _const_strconv__c_plus '+' | ||
| 1500 | +#define _const_strconv__c_minus '-' | ||
| 1501 | +#define _const_strconv__c_zero '0' | ||
| 1502 | +#define _const_strconv__c_nine '9' | ||
| 1503 | +#define _const_strconv__int_size 32 | ||
| 1504 | +#define _const_strconv__max_size_f64_char 512 | ||
| 1505 | +#define _const_autostr_type_stack_max_depth 64 | ||
| 1506 | +#define _const_min_int -2147483648 | ||
| 1507 | +#define _const_max_int 2147483647 | ||
| 1508 | +#define _const_hashbits 24 | ||
| 1509 | +#define _const_max_cached_hashbits 16 | ||
| 1510 | +#define _const_init_log_capicity 5 | ||
| 1511 | +#define _const_init_capicity 32 | ||
| 1512 | +#define _const_init_even_index 30 | ||
| 1513 | +#define _const_extra_metas_inc 4 | ||
| 1514 | +#define _const_rune_maps_columns_in_row 4 | ||
| 1515 | +#define _const_rune_maps_ul -3 | ||
| 1516 | +#define _const_rune_maps_utl -2 | ||
| 1517 | +#define _const_degree 6 | ||
| 1518 | +#define _const_mid_index 5 | ||
| 1519 | +#define _const_max_len 11 | ||
| 1520 | +#define _const_replace_stack_buffer_size 10 | ||
| 1521 | +#define _const_kmp_stack_buffer_size 20 | ||
| 1522 | + | ||
| 1523 | +// Enum definitions: | ||
| 1524 | + | ||
| 1525 | +typedef enum { | ||
| 1526 | + strings__IndentState__normal, // | ||
| 1527 | + strings__IndentState__in_string, // +1 | ||
| 1528 | +} strings__IndentState; | ||
| 1529 | + | ||
| 1530 | +typedef enum { | ||
| 1531 | + builtin__closure__MemoryProtectAtrr__read_exec, // | ||
| 1532 | + builtin__closure__MemoryProtectAtrr__read_write, // +1 | ||
| 1533 | +} builtin__closure__MemoryProtectAtrr; | ||
| 1534 | + | ||
| 1535 | +typedef enum { | ||
| 1536 | + strconv__ParserState__ok, // | ||
| 1537 | + strconv__ParserState__pzero, // +1 | ||
| 1538 | + strconv__ParserState__mzero, // +2 | ||
| 1539 | + strconv__ParserState__pinf, // +3 | ||
| 1540 | + strconv__ParserState__minf, // +4 | ||
| 1541 | + strconv__ParserState__invalid_number, // +5 | ||
| 1542 | + strconv__ParserState__extra_char, // +6 | ||
| 1543 | +} strconv__ParserState; | ||
| 1544 | + | ||
| 1545 | +typedef enum { | ||
| 1546 | + strconv__Align_text__right = 0, // 0 | ||
| 1547 | + strconv__Align_text__left, // 0+1 | ||
| 1548 | + strconv__Align_text__center, // 0+2 | ||
| 1549 | +} strconv__Align_text; | ||
| 1550 | + | ||
| 1551 | +typedef enum { | ||
| 1552 | + strconv__Char_parse_state__start, // | ||
| 1553 | + strconv__Char_parse_state__norm_char, // +1 | ||
| 1554 | + strconv__Char_parse_state__field_char, // +2 | ||
| 1555 | + strconv__Char_parse_state__pad_ch, // +3 | ||
| 1556 | + strconv__Char_parse_state__len_set_start, // +4 | ||
| 1557 | + strconv__Char_parse_state__len_set_in, // +5 | ||
| 1558 | + strconv__Char_parse_state__check_type, // +6 | ||
| 1559 | + strconv__Char_parse_state__check_float, // +7 | ||
| 1560 | + strconv__Char_parse_state__check_float_in, // +8 | ||
| 1561 | + strconv__Char_parse_state__reset_params, // +9 | ||
| 1562 | +} strconv__Char_parse_state; | ||
| 1563 | + | ||
| 1564 | +typedef enum { | ||
| 1565 | + ArrayFlags__noslices = 1U, // u64(1) << 0 | ||
| 1566 | + ArrayFlags__noshrink = 2U, // u64(1) << 1 | ||
| 1567 | + ArrayFlags__nogrow = 4U, // u64(1) << 2 | ||
| 1568 | + ArrayFlags__nofree = 8U, // u64(1) << 3 | ||
| 1569 | + ArrayFlags__managed = 16U, // u64(1) << 4 | ||
| 1570 | + ArrayFlags__noscan_data = 32U, // u64(1) << 5 | ||
| 1571 | + ArrayFlags__is_slice = 64U, // u64(1) << 6 | ||
| 1572 | +} ArrayFlags; | ||
| 1573 | + | ||
| 1574 | +typedef enum { | ||
| 1575 | + ChanState__success, // | ||
| 1576 | + ChanState__not_ready, // +1 | ||
| 1577 | + ChanState__closed, // +2 | ||
| 1578 | +} ChanState; | ||
| 1579 | + | ||
| 1580 | +typedef enum { | ||
| 1581 | + GraphemeBreakProperty__other, // | ||
| 1582 | + GraphemeBreakProperty__cr, // +1 | ||
| 1583 | + GraphemeBreakProperty__lf, // +2 | ||
| 1584 | + GraphemeBreakProperty__control, // +3 | ||
| 1585 | + GraphemeBreakProperty__extend, // +4 | ||
| 1586 | + GraphemeBreakProperty__regional_indicator, // +5 | ||
| 1587 | + GraphemeBreakProperty__prepend, // +6 | ||
| 1588 | + GraphemeBreakProperty__spacing_mark, // +7 | ||
| 1589 | + GraphemeBreakProperty__l, // +8 | ||
| 1590 | + GraphemeBreakProperty__v, // +9 | ||
| 1591 | + GraphemeBreakProperty__t, // +10 | ||
| 1592 | + GraphemeBreakProperty__lv, // +11 | ||
| 1593 | + GraphemeBreakProperty__lvt, // +12 | ||
| 1594 | + GraphemeBreakProperty__zwj, // +13 | ||
| 1595 | +} GraphemeBreakProperty; | ||
| 1596 | + | ||
| 1597 | +typedef enum { | ||
| 1598 | + AttributeKind__plain, // | ||
| 1599 | + AttributeKind__string, // +1 | ||
| 1600 | + AttributeKind__number, // +2 | ||
| 1601 | + AttributeKind__bool, // +3 | ||
| 1602 | + AttributeKind__comptime_define, // +4 | ||
| 1603 | +} AttributeKind; | ||
| 1604 | + | ||
| 1605 | +typedef enum { | ||
| 1606 | + MapMode__to_upper, // | ||
| 1607 | + MapMode__to_lower, // +1 | ||
| 1608 | + MapMode__to_title, // +2 | ||
| 1609 | +} MapMode; | ||
| 1610 | + | ||
| 1611 | +typedef enum { | ||
| 1612 | + TrimMode__trim_left, // | ||
| 1613 | + TrimMode__trim_right, // +1 | ||
| 1614 | + TrimMode__trim_both, // +2 | ||
| 1615 | +} TrimMode; | ||
| 1616 | + | ||
| 1617 | +typedef enum { | ||
| 1618 | + StrIntpType__si_no_str = 0, // 0 | ||
| 1619 | + StrIntpType__si_c, // 0+1 | ||
| 1620 | + StrIntpType__si_u8, // 0+2 | ||
| 1621 | + StrIntpType__si_i8, // 0+3 | ||
| 1622 | + StrIntpType__si_u16, // 0+4 | ||
| 1623 | + StrIntpType__si_i16, // 0+5 | ||
| 1624 | + StrIntpType__si_u32, // 0+6 | ||
| 1625 | + StrIntpType__si_i32, // 0+7 | ||
| 1626 | + StrIntpType__si_u64, // 0+8 | ||
| 1627 | + StrIntpType__si_i64, // 0+9 | ||
| 1628 | + StrIntpType__si_e32, // 0+10 | ||
| 1629 | + StrIntpType__si_e64, // 0+11 | ||
| 1630 | + StrIntpType__si_f32, // 0+12 | ||
| 1631 | + StrIntpType__si_f64, // 0+13 | ||
| 1632 | + StrIntpType__si_g32, // 0+14 | ||
| 1633 | + StrIntpType__si_g64, // 0+15 | ||
| 1634 | + StrIntpType__si_s, // 0+16 | ||
| 1635 | + StrIntpType__si_p, // 0+17 | ||
| 1636 | + StrIntpType__si_r, // 0+18 | ||
| 1637 | + StrIntpType__si_vp, // 0+19 | ||
| 1638 | +} StrIntpType; | ||
| 1639 | + | ||
| 1640 | +// V type definitions: | ||
| 1641 | +struct IError { | ||
| 1642 | + union { | ||
| 1643 | + void* _object; | ||
| 1644 | + None__* _None__; | ||
| 1645 | + voidptr* _voidptr; | ||
| 1646 | + MessageError* _MessageError; | ||
| 1647 | + Error* _Error; | ||
| 1648 | + }; | ||
| 1649 | + u32 _typ; | ||
| 1650 | + void* _methods; | ||
| 1651 | +}; | ||
| 1652 | + | ||
| 1653 | +struct string { | ||
| 1654 | + u8* str; | ||
| 1655 | + int len; | ||
| 1656 | + int is_lit; | ||
| 1657 | +}; | ||
| 1658 | + | ||
| 1659 | +struct array { | ||
| 1660 | + voidptr data; | ||
| 1661 | + int offset; | ||
| 1662 | + int len; | ||
| 1663 | + int cap; | ||
| 1664 | + ArrayFlags flags; | ||
| 1665 | + int element_size; | ||
| 1666 | +}; | ||
| 1667 | + | ||
| 1668 | +struct DenseArray { | ||
| 1669 | + int key_bytes; | ||
| 1670 | + int value_bytes; | ||
| 1671 | + int cap; | ||
| 1672 | + int len; | ||
| 1673 | + u32 deletes; | ||
| 1674 | + u8* all_deleted; | ||
| 1675 | + u8* keys; | ||
| 1676 | + u8* values; | ||
| 1677 | +}; | ||
| 1678 | + | ||
| 1679 | +struct map { | ||
| 1680 | + int key_bytes; | ||
| 1681 | + int value_bytes; | ||
| 1682 | + u32 even_index; | ||
| 1683 | + u8 cached_hashbits; | ||
| 1684 | + u8 shift; | ||
| 1685 | + DenseArray key_values; | ||
| 1686 | + u32* metas; | ||
| 1687 | + u32 extra_metas; | ||
| 1688 | + bool has_string_keys; | ||
| 1689 | + MapHashFn hash_fn; | ||
| 1690 | + MapEqFn key_eq_fn; | ||
| 1691 | + MapCloneFn clone_fn; | ||
| 1692 | + MapFreeFn free_fn; | ||
| 1693 | + int len; | ||
| 1694 | +}; | ||
| 1695 | + | ||
| 1696 | +struct Error { | ||
| 1697 | + E_STRUCT_DECL; | ||
| 1698 | +}; | ||
| 1699 | + | ||
| 1700 | +struct _option { | ||
| 1701 | + u8 state; | ||
| 1702 | + IError err; | ||
| 1703 | +}; | ||
| 1704 | + | ||
| 1705 | +struct _result { | ||
| 1706 | + bool is_error; | ||
| 1707 | + IError err; | ||
| 1708 | +}; | ||
| 1709 | +typedef array Array_string; | ||
| 1710 | +typedef array Array_u8; | ||
| 1711 | +typedef array Array_voidptr; | ||
| 1712 | +typedef array Array_int; | ||
| 1713 | +typedef array Array_IError; | ||
| 1714 | +typedef array Array_rune; | ||
| 1715 | +typedef string Array_fixed_string_11 [11]; | ||
| 1716 | +typedef voidptr Array_fixed_voidptr_11 [11]; | ||
| 1717 | +typedef array Array_RepIndex; | ||
| 1718 | +typedef map Map_string_int; | ||
| 1719 | +typedef array Array_bool; | ||
| 1720 | +typedef array Array_builtin__closure__ClosureLifetimeRecord; | ||
| 1721 | +typedef array Array_builtin__closure__ClosureLifetimeFrame; | ||
| 1722 | +typedef map Map_voidptr_builtin__closure__ClosureLiveInfo; | ||
| 1723 | +typedef map Map_u64_builtin__closure__ClosureLifetimeState_ptr; | ||
| 1724 | +typedef u8 Array_fixed_u8_128 [128]; | ||
| 1725 | +typedef u8 Array_fixed_u8_32 [32]; | ||
| 1726 | +typedef u8 Array_fixed_u8_64 [64]; | ||
| 1727 | +typedef u8 Array_fixed_u8_5 [5]; | ||
| 1728 | +typedef u8 Array_fixed_u8_20 [20]; | ||
| 1729 | +typedef u8 Array_fixed_u8_15 [15]; | ||
| 1730 | +typedef u8 Array_fixed_u8_6 [6]; | ||
| 1731 | +typedef u8 Array_fixed_u8_256 [256]; | ||
| 1732 | +typedef u64 Array_fixed_u64_309 [309]; | ||
| 1733 | +typedef u64 Array_fixed_u64_324 [324]; | ||
| 1734 | +typedef u32 Array_fixed_u32_10 [10]; | ||
| 1735 | +typedef u64 Array_fixed_u64_20 [20]; | ||
| 1736 | +typedef u64 Array_fixed_u64_584 [584]; | ||
| 1737 | +typedef u64 Array_fixed_u64_652 [652]; | ||
| 1738 | +typedef f64 Array_fixed_f64_36 [36]; | ||
| 1739 | +typedef u8 Array_fixed_u8_26 [26]; | ||
| 1740 | +typedef u8 Array_fixed_u8_512 [512]; | ||
| 1741 | +typedef u64 Array_fixed_u64_47 [47]; | ||
| 1742 | +typedef u64 Array_fixed_u64_31 [31]; | ||
| 1743 | +typedef int Array_fixed_int_64 [64]; | ||
| 1744 | +typedef voidptr Array_fixed_voidptr_64 [64]; | ||
| 1745 | +typedef voidptr Array_fixed_voidptr_100 [100]; | ||
| 1746 | +typedef u8 Array_fixed_u8_1000 [1000]; | ||
| 1747 | +typedef array Array_GraphemeBreakProperty; | ||
| 1748 | +typedef u8 Array_fixed_u8_17 [17]; | ||
| 1749 | +typedef i32 Array_fixed_i32_1264 [1264]; | ||
| 1750 | +typedef int Array_fixed_int_10 [10]; | ||
| 1751 | +typedef int Array_fixed_int_20 [20]; | ||
| 1752 | +typedef array Array_StrIntpType; | ||
| 1753 | +typedef Array_u8 strings__Builder; | ||
| 1754 | +typedef bool (*anon_fn_voidptr__bool)(voidptr); | ||
| 1755 | +typedef voidptr (*anon_fn_voidptr__voidptr)(voidptr); | ||
| 1756 | +typedef int (*anon_fn_voidptr_voidptr__int)(voidptr,voidptr); | ||
| 1757 | +typedef int (*FnSortCB)(const void*,const void*); | ||
| 1758 | +typedef void (*FnExitCb)(); | ||
| 1759 | +typedef void (*FnGC_WarnCB)(char*,usize); | ||
| 1760 | +typedef voidptr (*builtin__closure__ClosureGetDataFn)(); | ||
| 1761 | +typedef void (*builtin__closure__ClosureInitFn)(); | ||
| 1762 | +typedef void (*anon_fn_)(); | ||
| 1763 | +// #start sorted_symbols | ||
| 1764 | +struct none { | ||
| 1765 | + E_STRUCT_DECL; | ||
| 1766 | +}; | ||
| 1767 | + | ||
| 1768 | +struct None__ { | ||
| 1769 | + Error Error; | ||
| 1770 | +}; | ||
| 1771 | + | ||
| 1772 | +struct InputRuneIterator { | ||
| 1773 | + E_STRUCT_DECL; | ||
| 1774 | +}; | ||
| 1775 | + | ||
| 1776 | +struct GCHeapUsage { | ||
| 1777 | + usize heap_size; | ||
| 1778 | + usize free_bytes; | ||
| 1779 | + usize total_bytes; | ||
| 1780 | + usize unmapped_bytes; | ||
| 1781 | + usize bytes_since_gc; | ||
| 1782 | +}; | ||
| 1783 | + | ||
| 1784 | +struct ArrayDataHeader { | ||
| 1785 | + bool has_slices; | ||
| 1786 | +}; | ||
| 1787 | + | ||
| 1788 | +struct MessageError { | ||
| 1789 | + string msg; | ||
| 1790 | + int code; | ||
| 1791 | +}; | ||
| 1792 | + | ||
| 1793 | +union strconv__Float64u { | ||
| 1794 | + f64 f; | ||
| 1795 | + u64 u; | ||
| 1796 | +}; | ||
| 1797 | + | ||
| 1798 | +union strconv__Float32u { | ||
| 1799 | + f32 f; | ||
| 1800 | + u32 u; | ||
| 1801 | +}; | ||
| 1802 | + | ||
| 1803 | +struct GraphemeState { | ||
| 1804 | + GraphemeBreakProperty prev_prop; | ||
| 1805 | + int ri_count; | ||
| 1806 | + u8 extended_pictographic_state; | ||
| 1807 | +}; | ||
| 1808 | + | ||
| 1809 | +struct VAssertMetaInfo { | ||
| 1810 | + string fpath; | ||
| 1811 | + int line_nr; | ||
| 1812 | + string fn_name; | ||
| 1813 | + string src; | ||
| 1814 | + string op; | ||
| 1815 | + string llabel; | ||
| 1816 | + string rlabel; | ||
| 1817 | + string lvalue; | ||
| 1818 | + string rvalue; | ||
| 1819 | + string message; | ||
| 1820 | + bool has_msg; | ||
| 1821 | +}; | ||
| 1822 | + | ||
| 1823 | +struct SortedMap { | ||
| 1824 | + int value_bytes; | ||
| 1825 | + mapnode* root; | ||
| 1826 | + int len; | ||
| 1827 | +}; | ||
| 1828 | + | ||
| 1829 | +struct RepIndex { | ||
| 1830 | + int idx; | ||
| 1831 | + int val_idx; | ||
| 1832 | +}; | ||
| 1833 | + | ||
| 1834 | +struct WrapConfig { | ||
| 1835 | + int width; | ||
| 1836 | + string end; | ||
| 1837 | +}; | ||
| 1838 | + | ||
| 1839 | +struct RunesIterator { | ||
| 1840 | + string s; | ||
| 1841 | + int i; | ||
| 1842 | +}; | ||
| 1843 | + | ||
| 1844 | +union StrIntpMem { | ||
| 1845 | + u32 d_c; | ||
| 1846 | + u8 d_u8; | ||
| 1847 | + i8 d_i8; | ||
| 1848 | + u16 d_u16; | ||
| 1849 | + i16 d_i16; | ||
| 1850 | + u32 d_u32; | ||
| 1851 | + i32 d_i32; | ||
| 1852 | + u64 d_u64; | ||
| 1853 | + i64 d_i64; | ||
| 1854 | + f32 d_f32; | ||
| 1855 | + f64 d_f64; | ||
| 1856 | + string d_s; | ||
| 1857 | + string d_r; | ||
| 1858 | + voidptr d_p; | ||
| 1859 | + voidptr d_vp; | ||
| 1860 | +}; | ||
| 1861 | + | ||
| 1862 | +struct strconv__BF_param { | ||
| 1863 | + u8 pad_ch; | ||
| 1864 | + int len0; | ||
| 1865 | + int len1; | ||
| 1866 | + bool positive; | ||
| 1867 | + bool sign_flag; | ||
| 1868 | + strconv__Align_text align; | ||
| 1869 | + bool rm_tail_zero; | ||
| 1870 | +}; | ||
| 1871 | + | ||
| 1872 | +struct ToWideConfig { | ||
| 1873 | + bool from_ansi; | ||
| 1874 | +}; | ||
| 1875 | + | ||
| 1876 | +struct strings__IndentParam { | ||
| 1877 | + rune block_start; | ||
| 1878 | + rune block_end; | ||
| 1879 | + rune indent_char; | ||
| 1880 | + int indent_count; | ||
| 1881 | + int starting_level; | ||
| 1882 | +}; | ||
| 1883 | + | ||
| 1884 | +struct strconv__PrepNumber { | ||
| 1885 | + bool negative; | ||
| 1886 | + int exponent; | ||
| 1887 | + u64 mantissa; | ||
| 1888 | +}; | ||
| 1889 | + | ||
| 1890 | +struct strconv__AtoF64Param { | ||
| 1891 | + bool allow_extra_chars; | ||
| 1892 | +}; | ||
| 1893 | + | ||
| 1894 | +struct strconv__Dec32 { | ||
| 1895 | + u32 m; | ||
| 1896 | + int e; | ||
| 1897 | +}; | ||
| 1898 | + | ||
| 1899 | +union strconv__Uf32 { | ||
| 1900 | + f32 f; | ||
| 1901 | + u32 u; | ||
| 1902 | +}; | ||
| 1903 | + | ||
| 1904 | +struct strconv__Dec64 { | ||
| 1905 | + u64 m; | ||
| 1906 | + int e; | ||
| 1907 | +}; | ||
| 1908 | + | ||
| 1909 | +struct strconv__Uint128 { | ||
| 1910 | + u64 lo; | ||
| 1911 | + u64 hi; | ||
| 1912 | +}; | ||
| 1913 | + | ||
| 1914 | +union strconv__Uf64 { | ||
| 1915 | + f64 f; | ||
| 1916 | + u64 u; | ||
| 1917 | +}; | ||
| 1918 | + | ||
| 1919 | +struct builtin__closure__ClosurePage { | ||
| 1920 | + builtin__closure__ClosurePage* next; | ||
| 1921 | + voidptr exec_page_start; | ||
| 1922 | +}; | ||
| 1923 | + | ||
| 1924 | +struct builtin__closure__ClosureLiveInfo { | ||
| 1925 | + voidptr ctx; | ||
| 1926 | + bool owns_data; | ||
| 1927 | + u64 generation; | ||
| 1928 | +}; | ||
| 1929 | + | ||
| 1930 | +struct builtin__closure__ClosureLifetimeRecord { | ||
| 1931 | + voidptr exec_ptr; | ||
| 1932 | + u64 generation; | ||
| 1933 | +}; | ||
| 1934 | + | ||
| 1935 | +struct builtin__closure__ClosureLifetimeFrame { | ||
| 1936 | + int start; | ||
| 1937 | + int end; | ||
| 1938 | +}; | ||
| 1939 | + | ||
| 1940 | +struct builtin__closure__ClosureLifetimeState { | ||
| 1941 | + u64 owner_thread; | ||
| 1942 | + bool active; | ||
| 1943 | + bool disposed; | ||
| 1944 | + int suspended; | ||
| 1945 | + int frame_start; | ||
| 1946 | + u64 frame_gen; | ||
| 1947 | + u64 generation; | ||
| 1948 | + u64 frame_generation; | ||
| 1949 | + Array_builtin__closure__ClosureLifetimeRecord records; | ||
| 1950 | + Array_builtin__closure__ClosureLifetimeFrame frames; | ||
| 1951 | + builtin__closure__ClosureLifetimeState* next_free; | ||
| 1952 | +}; | ||
| 1953 | + | ||
| 1954 | +struct builtin__closure__Lifetime { | ||
| 1955 | + builtin__closure__ClosureLifetimeState* state; | ||
| 1956 | + u64 generation; | ||
| 1957 | + bool disposed; | ||
| 1958 | +}; | ||
| 1959 | + | ||
| 1960 | +struct builtin__closure__FrameToken { | ||
| 1961 | + builtin__closure__ClosureLifetimeState* state; | ||
| 1962 | + u64 thread_id; | ||
| 1963 | + u64 state_generation; | ||
| 1964 | + u64 generation; | ||
| 1965 | +}; | ||
| 1966 | + | ||
| 1967 | +struct mapnode { | ||
| 1968 | + voidptr* children; | ||
| 1969 | + int len; | ||
| 1970 | + Array_fixed_string_11 keys; | ||
| 1971 | + Array_fixed_voidptr_11 values; | ||
| 1972 | +}; | ||
| 1973 | + | ||
| 1974 | +struct StrIntpData { | ||
| 1975 | + string str; | ||
| 1976 | + u32 fmt; | ||
| 1977 | + StrIntpMem d; | ||
| 1978 | + int dyn_width; | ||
| 1979 | + int dyn_precision; | ||
| 1980 | + u8 dyn_flags; | ||
| 1981 | +}; | ||
| 1982 | + | ||
| 1983 | +struct builtin__closure__ClosureMutex { | ||
| 1984 | + Array_fixed_u8_128 closure_mtx; | ||
| 1985 | +}; | ||
| 1986 | + | ||
| 1987 | +struct builtin__closure__Closure { | ||
| 1988 | + builtin__closure__ClosureMutex ClosureMutex; | ||
| 1989 | + voidptr closure_ptr; | ||
| 1990 | + builtin__closure__ClosureGetDataFn closure_get_data; | ||
| 1991 | + int closure_cap; | ||
| 1992 | + voidptr free_closure_ptr; | ||
| 1993 | + builtin__closure__ClosurePage* pages; | ||
| 1994 | + int v_page_size; | ||
| 1995 | + Map_voidptr_builtin__closure__ClosureLiveInfo live; | ||
| 1996 | + Map_u64_builtin__closure__ClosureLifetimeState_ptr active_lifetimes; | ||
| 1997 | + u64 next_generation; | ||
| 1998 | + builtin__closure__ClosureLifetimeState* free_lifetime_states; | ||
| 1999 | + u64 next_lifetime_generation; | ||
| 2000 | + u64 lifetime_state_allocs; | ||
| 2001 | +}; | ||
| 2002 | +// #end sorted_symbols | ||
| 2003 | + | ||
| 2004 | +// BEGIN_array_fixed_return_structs | ||
| 2005 | +struct _v_Array_fixed_string_11 { | ||
| 2006 | + string ret_arr[11]; | ||
| 2007 | +}; | ||
| 2008 | +struct _v_Array_fixed_voidptr_11 { | ||
| 2009 | + voidptr ret_arr[11]; | ||
| 2010 | +}; | ||
| 2011 | +struct _v_Array_fixed_u8_128 { | ||
| 2012 | + u8 ret_arr[128]; | ||
| 2013 | +}; | ||
| 2014 | +struct _v_Array_fixed_u8_32 { | ||
| 2015 | + u8 ret_arr[32]; | ||
| 2016 | +}; | ||
| 2017 | +struct _v_Array_fixed_u8_64 { | ||
| 2018 | + u8 ret_arr[64]; | ||
| 2019 | +}; | ||
| 2020 | +struct _v_Array_fixed_u8_5 { | ||
| 2021 | + u8 ret_arr[5]; | ||
| 2022 | +}; | ||
| 2023 | +struct _v_Array_fixed_u8_20 { | ||
| 2024 | + u8 ret_arr[20]; | ||
| 2025 | +}; | ||
| 2026 | +struct _v_Array_fixed_u8_15 { | ||
| 2027 | + u8 ret_arr[15]; | ||
| 2028 | +}; | ||
| 2029 | +struct _v_Array_fixed_u8_6 { | ||
| 2030 | + u8 ret_arr[6]; | ||
| 2031 | +}; | ||
| 2032 | +struct _v_Array_fixed_u8_256 { | ||
| 2033 | + u8 ret_arr[256]; | ||
| 2034 | +}; | ||
| 2035 | +struct _v_Array_fixed_u64_309 { | ||
| 2036 | + u64 ret_arr[309]; | ||
| 2037 | +}; | ||
| 2038 | +struct _v_Array_fixed_u64_324 { | ||
| 2039 | + u64 ret_arr[324]; | ||
| 2040 | +}; | ||
| 2041 | +struct _v_Array_fixed_u32_10 { | ||
| 2042 | + u32 ret_arr[10]; | ||
| 2043 | +}; | ||
| 2044 | +struct _v_Array_fixed_u64_20 { | ||
| 2045 | + u64 ret_arr[20]; | ||
| 2046 | +}; | ||
| 2047 | +struct _v_Array_fixed_u64_584 { | ||
| 2048 | + u64 ret_arr[584]; | ||
| 2049 | +}; | ||
| 2050 | +struct _v_Array_fixed_u64_652 { | ||
| 2051 | + u64 ret_arr[652]; | ||
| 2052 | +}; | ||
| 2053 | +struct _v_Array_fixed_f64_36 { | ||
| 2054 | + f64 ret_arr[36]; | ||
| 2055 | +}; | ||
| 2056 | +struct _v_Array_fixed_u8_26 { | ||
| 2057 | + u8 ret_arr[26]; | ||
| 2058 | +}; | ||
| 2059 | +struct _v_Array_fixed_u8_512 { | ||
| 2060 | + u8 ret_arr[512]; | ||
| 2061 | +}; | ||
| 2062 | +struct _v_Array_fixed_u64_47 { | ||
| 2063 | + u64 ret_arr[47]; | ||
| 2064 | +}; | ||
| 2065 | +struct _v_Array_fixed_u64_31 { | ||
| 2066 | + u64 ret_arr[31]; | ||
| 2067 | +}; | ||
| 2068 | +struct _v_Array_fixed_int_64 { | ||
| 2069 | + int ret_arr[64]; | ||
| 2070 | +}; | ||
| 2071 | +struct _v_Array_fixed_voidptr_64 { | ||
| 2072 | + voidptr ret_arr[64]; | ||
| 2073 | +}; | ||
| 2074 | +struct _v_Array_fixed_voidptr_100 { | ||
| 2075 | + voidptr ret_arr[100]; | ||
| 2076 | +}; | ||
| 2077 | +struct _v_Array_fixed_u8_1000 { | ||
| 2078 | + u8 ret_arr[1000]; | ||
| 2079 | +}; | ||
| 2080 | +struct _v_Array_fixed_u8_17 { | ||
| 2081 | + u8 ret_arr[17]; | ||
| 2082 | +}; | ||
| 2083 | +struct _v_Array_fixed_i32_1264 { | ||
| 2084 | + i32 ret_arr[1264]; | ||
| 2085 | +}; | ||
| 2086 | +struct _v_Array_fixed_int_10 { | ||
| 2087 | + int ret_arr[10]; | ||
| 2088 | +}; | ||
| 2089 | +struct _v_Array_fixed_int_20 { | ||
| 2090 | + int ret_arr[20]; | ||
| 2091 | +}; | ||
| 2092 | +// END_array_fixed_return_structs | ||
| 2093 | + | ||
| 2094 | + | ||
| 2095 | +// BEGIN_multi_return_structs | ||
| 2096 | +struct multi_return_u32_u32 { | ||
| 2097 | + u32 arg0; | ||
| 2098 | + u32 arg1; | ||
| 2099 | +}; | ||
| 2100 | + | ||
| 2101 | +struct multi_return_string_string { | ||
| 2102 | + string arg0; | ||
| 2103 | + string arg1; | ||
| 2104 | +}; | ||
| 2105 | + | ||
| 2106 | +struct multi_return_int_int { | ||
| 2107 | + int arg0; | ||
| 2108 | + int arg1; | ||
| 2109 | +}; | ||
| 2110 | + | ||
| 2111 | +struct multi_return_rune_int { | ||
| 2112 | + rune arg0; | ||
| 2113 | + int arg1; | ||
| 2114 | +}; | ||
| 2115 | + | ||
| 2116 | +struct multi_return_u32_u32_u32 { | ||
| 2117 | + u32 arg0; | ||
| 2118 | + u32 arg1; | ||
| 2119 | + u32 arg2; | ||
| 2120 | +}; | ||
| 2121 | + | ||
| 2122 | +struct multi_return_strconv__ParserState_strconv__PrepNumber { | ||
| 2123 | + strconv__ParserState arg0; | ||
| 2124 | + strconv__PrepNumber arg1; | ||
| 2125 | +}; | ||
| 2126 | + | ||
| 2127 | +struct multi_return_u64_int { | ||
| 2128 | + u64 arg0; | ||
| 2129 | + int arg1; | ||
| 2130 | +}; | ||
| 2131 | + | ||
| 2132 | +struct multi_return_i64_int { | ||
| 2133 | + i64 arg0; | ||
| 2134 | + int arg1; | ||
| 2135 | +}; | ||
| 2136 | + | ||
| 2137 | +struct multi_return_strconv__Dec32_bool { | ||
| 2138 | + strconv__Dec32 arg0; | ||
| 2139 | + bool arg1; | ||
| 2140 | +}; | ||
| 2141 | + | ||
| 2142 | +struct multi_return_strconv__Dec64_bool { | ||
| 2143 | + strconv__Dec64 arg0; | ||
| 2144 | + bool arg1; | ||
| 2145 | +}; | ||
| 2146 | + | ||
| 2147 | +struct multi_return_u64_u64 { | ||
| 2148 | + u64 arg0; | ||
| 2149 | + u64 arg1; | ||
| 2150 | +}; | ||
| 2151 | + | ||
| 2152 | +struct multi_return_f64_int { | ||
| 2153 | + f64 arg0; | ||
| 2154 | + int arg1; | ||
| 2155 | +}; | ||
| 2156 | + | ||
| 2157 | +// END_multi_return_structs | ||
| 2158 | + | ||
| 2159 | +static bool Array_u8_contains(Array_u8 a, u8 v); | ||
| 2160 | + | ||
| 2161 | +// V Option_xxx definitions: | ||
| 2162 | +struct _option_builtin__closure__ClosureLiveInfo { | ||
| 2163 | + byte state; | ||
| 2164 | + IError err; | ||
| 2165 | + byte data[sizeof(builtin__closure__ClosureLiveInfo) > 1 ? sizeof(builtin__closure__ClosureLiveInfo) : 1]; | ||
| 2166 | +}; | ||
| 2167 | + | ||
| 2168 | +struct _option_builtin__closure__ClosureLifetimeState_ptr { | ||
| 2169 | + byte state; | ||
| 2170 | + IError err; | ||
| 2171 | + byte data[sizeof(builtin__closure__ClosureLifetimeState*) > 1 ? sizeof(builtin__closure__ClosureLifetimeState*) : 1]; | ||
| 2172 | +}; | ||
| 2173 | + | ||
| 2174 | +struct _option_int { | ||
| 2175 | + byte state; | ||
| 2176 | + IError err; | ||
| 2177 | + byte data[sizeof(int) > 1 ? sizeof(int) : 1]; | ||
| 2178 | +}; | ||
| 2179 | + | ||
| 2180 | +struct _option_rune { | ||
| 2181 | + byte state; | ||
| 2182 | + IError err; | ||
| 2183 | + byte data[sizeof(rune) > 1 ? sizeof(rune) : 1]; | ||
| 2184 | +}; | ||
| 2185 | + | ||
| 2186 | +struct _option_multi_return_string_string { | ||
| 2187 | + byte state; | ||
| 2188 | + IError err; | ||
| 2189 | + byte data[sizeof(multi_return_string_string) > 1 ? sizeof(multi_return_string_string) : 1]; | ||
| 2190 | +}; | ||
| 2191 | + | ||
| 2192 | +struct _option_u8 { | ||
| 2193 | + byte state; | ||
| 2194 | + IError err; | ||
| 2195 | + byte data[sizeof(u8) > 1 ? sizeof(u8) : 1]; | ||
| 2196 | +}; | ||
| 2197 | + | ||
| 2198 | + | ||
| 2199 | +// V result_xxx definitions: | ||
| 2200 | +struct _result_int { | ||
| 2201 | + bool is_error; | ||
| 2202 | + IError err; | ||
| 2203 | + byte data[sizeof(int) > 1 ? sizeof(int) : 1]; | ||
| 2204 | +}; | ||
| 2205 | + | ||
| 2206 | +struct _result_builtin__closure__ClosureLifetimeState_ptr { | ||
| 2207 | + bool is_error; | ||
| 2208 | + IError err; | ||
| 2209 | + byte data[sizeof(builtin__closure__ClosureLifetimeState*) > 1 ? sizeof(builtin__closure__ClosureLifetimeState*) : 1]; | ||
| 2210 | +}; | ||
| 2211 | + | ||
| 2212 | +struct _result_builtin__closure__FrameToken { | ||
| 2213 | + bool is_error; | ||
| 2214 | + IError err; | ||
| 2215 | + byte data[sizeof(builtin__closure__FrameToken) > 1 ? sizeof(builtin__closure__FrameToken) : 1]; | ||
| 2216 | +}; | ||
| 2217 | + | ||
| 2218 | +struct _result_void { | ||
| 2219 | + bool is_error; | ||
| 2220 | + IError err; | ||
| 2221 | + byte data[sizeof(u8) > 1 ? sizeof(u8) : 1]; | ||
| 2222 | +}; | ||
| 2223 | + | ||
| 2224 | +struct _result_f64 { | ||
| 2225 | + bool is_error; | ||
| 2226 | + IError err; | ||
| 2227 | + byte data[sizeof(f64) > 1 ? sizeof(f64) : 1]; | ||
| 2228 | +}; | ||
| 2229 | + | ||
| 2230 | +struct _result_u64 { | ||
| 2231 | + bool is_error; | ||
| 2232 | + IError err; | ||
| 2233 | + byte data[sizeof(u64) > 1 ? sizeof(u64) : 1]; | ||
| 2234 | +}; | ||
| 2235 | + | ||
| 2236 | +struct _result_i64 { | ||
| 2237 | + bool is_error; | ||
| 2238 | + IError err; | ||
| 2239 | + byte data[sizeof(i64) > 1 ? sizeof(i64) : 1]; | ||
| 2240 | +}; | ||
| 2241 | + | ||
| 2242 | +struct _result_multi_return_i64_int { | ||
| 2243 | + bool is_error; | ||
| 2244 | + IError err; | ||
| 2245 | + byte data[sizeof(multi_return_i64_int) > 1 ? sizeof(multi_return_i64_int) : 1]; | ||
| 2246 | +}; | ||
| 2247 | + | ||
| 2248 | +struct _result_i8 { | ||
| 2249 | + bool is_error; | ||
| 2250 | + IError err; | ||
| 2251 | + byte data[sizeof(i8) > 1 ? sizeof(i8) : 1]; | ||
| 2252 | +}; | ||
| 2253 | + | ||
| 2254 | +struct _result_i16 { | ||
| 2255 | + bool is_error; | ||
| 2256 | + IError err; | ||
| 2257 | + byte data[sizeof(i16) > 1 ? sizeof(i16) : 1]; | ||
| 2258 | +}; | ||
| 2259 | + | ||
| 2260 | +struct _result_i32 { | ||
| 2261 | + bool is_error; | ||
| 2262 | + IError err; | ||
| 2263 | + byte data[sizeof(i32) > 1 ? sizeof(i32) : 1]; | ||
| 2264 | +}; | ||
| 2265 | + | ||
| 2266 | +struct _result_u8 { | ||
| 2267 | + bool is_error; | ||
| 2268 | + IError err; | ||
| 2269 | + byte data[sizeof(u8) > 1 ? sizeof(u8) : 1]; | ||
| 2270 | +}; | ||
| 2271 | + | ||
| 2272 | +struct _result_u16 { | ||
| 2273 | + bool is_error; | ||
| 2274 | + IError err; | ||
| 2275 | + byte data[sizeof(u16) > 1 ? sizeof(u16) : 1]; | ||
| 2276 | +}; | ||
| 2277 | + | ||
| 2278 | +struct _result_u32 { | ||
| 2279 | + bool is_error; | ||
| 2280 | + IError err; | ||
| 2281 | + byte data[sizeof(u32) > 1 ? sizeof(u32) : 1]; | ||
| 2282 | +}; | ||
| 2283 | + | ||
| 2284 | +struct _result_rune { | ||
| 2285 | + bool is_error; | ||
| 2286 | + IError err; | ||
| 2287 | + byte data[sizeof(rune) > 1 ? sizeof(rune) : 1]; | ||
| 2288 | +}; | ||
| 2289 | + | ||
| 2290 | +struct _result_string { | ||
| 2291 | + bool is_error; | ||
| 2292 | + IError err; | ||
| 2293 | + byte data[sizeof(string) > 1 ? sizeof(string) : 1]; | ||
| 2294 | +}; | ||
| 2295 | + | ||
| 2296 | + | ||
| 2297 | +// V definitions: | ||
| 2298 | +static char * v_typeof_interface_IError(u32 sidx); | ||
| 2299 | +u32 v_typeof_interface_idx_IError(u32 sidx); | ||
| 2300 | +// end of definitions #endif | ||
| 2301 | +strings__Builder strings__new_builder(int initial_size); | ||
| 2302 | +Array_u8 strings__Builder_reuse_as_plain_u8_array(strings__Builder* b); | ||
| 2303 | +void strings__Builder_write_ptr(strings__Builder* b, u8* ptr, int len); | ||
| 2304 | +void strings__Builder_write_rune(strings__Builder* b, rune r); | ||
| 2305 | +void strings__Builder_write_runes(strings__Builder* b, Array_rune runes); | ||
| 2306 | +void strings__Builder_write_u8(strings__Builder* b, u8 data); | ||
| 2307 | +void strings__Builder_write_byte(strings__Builder* b, u8 data); | ||
| 2308 | +void strings__Builder_write_decimal(strings__Builder* b, i64 n); | ||
| 2309 | +void strings__Builder_write_u_decimal(strings__Builder* b, u64 n); | ||
| 2310 | +_result_int strings__Builder_write(strings__Builder* b, Array_u8 data); | ||
| 2311 | +void strings__Builder_drain_builder(strings__Builder* b, strings__Builder* other, int other_new_cap); | ||
| 2312 | +u8 strings__Builder_byte_at(strings__Builder* b, int n); | ||
| 2313 | +void strings__Builder_write_string(strings__Builder* b, string s); | ||
| 2314 | +void strings__Builder_write_string2(strings__Builder* b, string s1, string s2); | ||
| 2315 | +void strings__Builder_go_back(strings__Builder* b, int n); | ||
| 2316 | +string strings__Builder_spart(strings__Builder* b, int start_pos, int n); | ||
| 2317 | +string strings__Builder_cut_last(strings__Builder* b, int n); | ||
| 2318 | +string strings__Builder_cut_to(strings__Builder* b, int pos); | ||
| 2319 | +void strings__Builder_go_back_to(strings__Builder* b, int pos); | ||
| 2320 | +void strings__Builder_writeln(strings__Builder* b, string s); | ||
| 2321 | +void strings__Builder_writeln2(strings__Builder* b, string s1, string s2); | ||
| 2322 | +string strings__Builder_last_n(strings__Builder* b, int n); | ||
| 2323 | +string strings__Builder_after(strings__Builder* b, int n); | ||
| 2324 | +string strings__Builder_str(strings__Builder* b); | ||
| 2325 | +void strings__Builder_ensure_cap(strings__Builder* b, int n); | ||
| 2326 | +void strings__Builder_grow_len(strings__Builder* b, int n); | ||
| 2327 | +void strings__Builder_free(strings__Builder* b); | ||
| 2328 | +void strings__Builder_write_repeated_rune(strings__Builder* b, rune r, int count); | ||
| 2329 | +void strings__Builder_indent(strings__Builder* b, string s, strings__IndentParam param); | ||
| 2330 | +VV_LOC int strings__min(int a, int b, int c); | ||
| 2331 | +VV_LOC int strings__max2(int a, int b); | ||
| 2332 | +VV_LOC int strings__min2(int a, int b); | ||
| 2333 | +VV_LOC int strings__abs2(int a, int b); | ||
| 2334 | +int strings__levenshtein_distance(string a, string b); | ||
| 2335 | +f32 strings__levenshtein_distance_percentage(string a, string b); | ||
| 2336 | +f32 strings__dice_coefficient(string s1, string s2); | ||
| 2337 | +int strings__hamming_distance(string a, string b); | ||
| 2338 | +f32 strings__hamming_similarity(string a, string b); | ||
| 2339 | +f64 strings__jaro_similarity(string a, string b); | ||
| 2340 | +f64 strings__jaro_winkler_similarity(string a, string b); | ||
| 2341 | +string strings__repeat(u8 c, int n); | ||
| 2342 | +string strings__repeat_string(string s, int n); | ||
| 2343 | +string strings__find_between_pair_u8(string input, u8 start, u8 end); | ||
| 2344 | +string strings__find_between_pair_rune(string input, rune start, rune end); | ||
| 2345 | +string strings__find_between_pair_string(string input, string start, string end); | ||
| 2346 | +Array_string strings__split_capital(string s); | ||
| 2347 | +VV_LOC bool builtin__closure__is_ppc64(void); | ||
| 2348 | +VV_LOC voidptr* builtin__closure__closure_slot_meta(voidptr exec_ptr); | ||
| 2349 | +VV_LOC void builtin__closure__closure_register_page(voidptr exec_page_start); | ||
| 2350 | +VV_LOC bool builtin__closure__closure_is_managed(voidptr exec_ptr); | ||
| 2351 | +VV_LOC builtin__closure__ClosureLiveInfo builtin__closure__closure_live_delete(voidptr exec_ptr); | ||
| 2352 | +VV_LOC builtin__closure__ClosureLifetimeState* builtin__closure__new_closure_lifetime_state_no_lock(void); | ||
| 2353 | +VV_LOC builtin__closure__ClosureLifetimeState* builtin__closure__new_closure_lifetime_state(void); | ||
| 2354 | +VV_LOC void builtin__closure__closure_lifetime_recycle_state_no_lock(builtin__closure__ClosureLifetimeState** state); | ||
| 2355 | +VV_LOC string builtin__closure__closure_lifetime_error(builtin__closure__ClosureLifetimeState* state, u64 generation, u64 thread_id); | ||
| 2356 | +VV_LOC _result_builtin__closure__ClosureLifetimeState_ptr builtin__closure__Lifetime_ensure_state(builtin__closure__Lifetime* lifetime); | ||
| 2357 | +VV_LOC voidptr builtin__closure__closure_slot_data(voidptr exec_ptr); | ||
| 2358 | +VV_LOC bool builtin__closure__closure_release_no_lock(voidptr exec_ptr, u64 generation); | ||
| 2359 | +VV_LOC void builtin__closure__closure_lifetime_release_records_no_lock(Array_builtin__closure__ClosureLifetimeRecord records, int start, int end); | ||
| 2360 | +VV_LOC void builtin__closure__closure_lifetime_reclaim_no_lock(builtin__closure__ClosureLifetimeState* state, int retain); | ||
| 2361 | +VV_LOC void builtin__closure__closure_ensure_initialized(void); | ||
| 2362 | +builtin__closure__Lifetime builtin__closure__new_lifetime(void); | ||
| 2363 | +VV_LOC _result_builtin__closure__FrameToken builtin__closure__Lifetime_begin_frame(builtin__closure__Lifetime* lifetime); | ||
| 2364 | +VV_LOC _result_void builtin__closure__Lifetime_end_frame(builtin__closure__Lifetime* lifetime, builtin__closure__FrameToken token); | ||
| 2365 | +_result_void builtin__closure__Lifetime_frame(builtin__closure__Lifetime* lifetime, void (*work)()); | ||
| 2366 | +_result_void builtin__closure__Lifetime_reclaim(builtin__closure__Lifetime* lifetime, int retain); | ||
| 2367 | +_result_void builtin__closure__Lifetime_reclaim_all(builtin__closure__Lifetime* lifetime); | ||
| 2368 | +_result_void builtin__closure__Lifetime_dispose(builtin__closure__Lifetime* lifetime); | ||
| 2369 | +_result_void builtin__closure__Lifetime_suspend(builtin__closure__Lifetime* lifetime, void (*work)()); | ||
| 2370 | +_result_void builtin__closure__Lifetime_untracked(builtin__closure__Lifetime* lifetime, void (*work)()); | ||
| 2371 | +VV_LOC void builtin__closure__closure_alloc(void); | ||
| 2372 | +VV_LOC void builtin__closure__closure_init_body(void); | ||
| 2373 | +VV_LOC voidptr builtin__closure__closure_mtx_ptr_platform(void); | ||
| 2374 | +VV_LOC u8* builtin__closure__closure_alloc_platform(void); | ||
| 2375 | +VV_LOC void builtin__closure__closure_memory_protect_platform(voidptr ptr, isize size, builtin__closure__MemoryProtectAtrr attr); | ||
| 2376 | +VV_LOC int builtin__closure__get_page_size_platform(void); | ||
| 2377 | +VV_LOC void builtin__closure__closure_mtx_lock_init_platform(void); | ||
| 2378 | +VV_LOC void builtin__closure__closure_mtx_lock_platform(void); | ||
| 2379 | +VV_LOC void builtin__closure__closure_mtx_unlock_platform(void); | ||
| 2380 | +VV_LOC u64 builtin__closure__closure_current_thread_id_platform(void); | ||
| 2381 | +VV_LOC void builtin__closure__closure_init_once_platform(void); | ||
| 2382 | +multi_return_u64_u64 math__bits__mul_64(u64 x, u64 y); | ||
| 2383 | +multi_return_u64_u64 math__bits__mul_add_64(u64 x, u64 y, u64 z); | ||
| 2384 | +multi_return_u64_u64 math__bits__div_64(u64 hi, u64 lo, u64 y1); | ||
| 2385 | +int math__bits__leading_zeros_8(u8 x); | ||
| 2386 | +int math__bits__leading_zeros_16(u16 x); | ||
| 2387 | +int math__bits__leading_zeros_32(u32 x); | ||
| 2388 | +int math__bits__leading_zeros_64(u64 x); | ||
| 2389 | +int math__bits__trailing_zeros_8(u8 x); | ||
| 2390 | +int math__bits__trailing_zeros_16(u16 x); | ||
| 2391 | +int math__bits__trailing_zeros_32(u32 x); | ||
| 2392 | +int math__bits__trailing_zeros_64(u64 x); | ||
| 2393 | +int math__bits__ones_count_8(u8 x); | ||
| 2394 | +int math__bits__ones_count_16(u16 x); | ||
| 2395 | +int math__bits__ones_count_32(u32 x); | ||
| 2396 | +int math__bits__ones_count_64(u64 x); | ||
| 2397 | +int math__bits__pure_v_but_overridden_by_c_leading_zeros_8(u8 x); | ||
| 2398 | +VV_LOC int math__bits__leading_zeros_8_default(u8 x); | ||
| 2399 | +int math__bits__pure_v_but_overridden_by_c_leading_zeros_16(u16 x); | ||
| 2400 | +VV_LOC int math__bits__leading_zeros_16_default(u16 x); | ||
| 2401 | +int math__bits__pure_v_but_overridden_by_c_leading_zeros_32(u32 x); | ||
| 2402 | +VV_LOC int math__bits__leading_zeros_32_default(u32 x); | ||
| 2403 | +int math__bits__pure_v_but_overridden_by_c_leading_zeros_64(u64 x); | ||
| 2404 | +VV_LOC int math__bits__leading_zeros_64_default(u64 x); | ||
| 2405 | +int math__bits__pure_v_but_overridden_by_c_trailing_zeros_8(u8 x); | ||
| 2406 | +VV_LOC int math__bits__trailing_zeros_8_default(u8 x); | ||
| 2407 | +int math__bits__pure_v_but_overridden_by_c_trailing_zeros_16(u16 x); | ||
| 2408 | +VV_LOC int math__bits__trailing_zeros_16_default(u16 x); | ||
| 2409 | +int math__bits__pure_v_but_overridden_by_c_trailing_zeros_32(u32 x); | ||
| 2410 | +VV_LOC int math__bits__trailing_zeros_32_default(u32 x); | ||
| 2411 | +int math__bits__pure_v_but_overridden_by_c_trailing_zeros_64(u64 x); | ||
| 2412 | +VV_LOC int math__bits__trailing_zeros_64_default(u64 x); | ||
| 2413 | +int math__bits__pure_v_but_overridden_by_c_ones_count_8(u8 x); | ||
| 2414 | +VV_LOC int math__bits__ones_count_8_default(u8 x); | ||
| 2415 | +int math__bits__pure_v_but_overridden_by_c_ones_count_16(u16 x); | ||
| 2416 | +VV_LOC int math__bits__ones_count_16_default(u16 x); | ||
| 2417 | +int math__bits__pure_v_but_overridden_by_c_ones_count_32(u32 x); | ||
| 2418 | +VV_LOC int math__bits__ones_count_32_default(u32 x); | ||
| 2419 | +int math__bits__pure_v_but_overridden_by_c_ones_count_64(u64 x); | ||
| 2420 | +VV_LOC int math__bits__ones_count_64_default(u64 x); | ||
| 2421 | +u8 math__bits__rotate_left_8(u8 x, int k); | ||
| 2422 | +u16 math__bits__rotate_left_16(u16 x, int k); | ||
| 2423 | +u32 math__bits__rotate_left_32(u32 x, int k); | ||
| 2424 | +u64 math__bits__rotate_left_64(u64 x, int k); | ||
| 2425 | +u8 math__bits__reverse_8(u8 x); | ||
| 2426 | +u16 math__bits__reverse_16(u16 x); | ||
| 2427 | +u32 math__bits__reverse_32(u32 x); | ||
| 2428 | +u64 math__bits__reverse_64(u64 x); | ||
| 2429 | +u16 math__bits__reverse_bytes_16(u16 x); | ||
| 2430 | +u32 math__bits__reverse_bytes_32(u32 x); | ||
| 2431 | +u64 math__bits__reverse_bytes_64(u64 x); | ||
| 2432 | +int math__bits__len_8(u8 x); | ||
| 2433 | +int math__bits__len_16(u16 x); | ||
| 2434 | +int math__bits__len_32(u32 x); | ||
| 2435 | +int math__bits__len_64(u64 x); | ||
| 2436 | +multi_return_u32_u32 math__bits__add_32(u32 x, u32 y, u32 carry); | ||
| 2437 | +multi_return_u64_u64 math__bits__add_64(u64 x, u64 y, u64 carry); | ||
| 2438 | +multi_return_u32_u32 math__bits__sub_32(u32 x, u32 y, u32 borrow); | ||
| 2439 | +multi_return_u64_u64 math__bits__sub_64(u64 x, u64 y, u64 borrow); | ||
| 2440 | +multi_return_u32_u32 math__bits__mul_32(u32 x, u32 y); | ||
| 2441 | +VV_LOC multi_return_u32_u32 math__bits__mul_32_default(u32 x, u32 y); | ||
| 2442 | +multi_return_u64_u64 math__bits__pure_v_but_overridden_by_amd64_mul_64(u64 x, u64 y); | ||
| 2443 | +VV_LOC multi_return_u64_u64 math__bits__mul_64_default(u64 x, u64 y); | ||
| 2444 | +multi_return_u32_u32 math__bits__mul_add_32(u32 x, u32 y, u32 z); | ||
| 2445 | +VV_LOC multi_return_u32_u32 math__bits__mul_add_32_default(u32 x, u32 y, u32 z); | ||
| 2446 | +multi_return_u64_u64 math__bits__pure_v_but_overridden_by_amd64_mul_add_64(u64 x, u64 y, u64 z); | ||
| 2447 | +VV_LOC multi_return_u64_u64 math__bits__mul_add_64_default(u64 x, u64 y, u64 z); | ||
| 2448 | +multi_return_u32_u32 math__bits__div_32(u32 hi, u32 lo, u32 y); | ||
| 2449 | +VV_LOC multi_return_u32_u32 math__bits__div_32_default(u32 hi, u32 lo, u32 y); | ||
| 2450 | +multi_return_u64_u64 math__bits__pure_v_but_overridden_by_amd64_div_64(u64 hi, u64 lo, u64 y1); | ||
| 2451 | +VV_LOC multi_return_u64_u64 math__bits__div_64_default(u64 hi, u64 lo, u64 y1); | ||
| 2452 | +u32 math__bits__rem_32(u32 hi, u32 lo, u32 y); | ||
| 2453 | +u64 math__bits__rem_64(u64 hi, u64 lo, u64 y); | ||
| 2454 | +multi_return_f64_int math__bits__normalize(f64 x); | ||
| 2455 | +u32 math__bits__f32_bits(f32 f); | ||
| 2456 | +f32 math__bits__f32_from_bits(u32 b); | ||
| 2457 | +u64 math__bits__f64_bits(f64 f); | ||
| 2458 | +f64 math__bits__f64_from_bits(u64 b); | ||
| 2459 | +VV_LOC multi_return_u32_u32_u32 strconv__lsr96(u32 s2, u32 s1, u32 s0); | ||
| 2460 | +VV_LOC multi_return_u32_u32_u32 strconv__lsl96(u32 s2, u32 s1, u32 s0); | ||
| 2461 | +VV_LOC multi_return_u32_u32_u32 strconv__add96(u32 s2, u32 s1, u32 s0, u32 d2, u32 d1, u32 d0); | ||
| 2462 | +VV_LOC multi_return_strconv__ParserState_strconv__PrepNumber strconv__parser(string s); | ||
| 2463 | +VV_LOC u64 strconv__converter(strconv__PrepNumber* pn); | ||
| 2464 | +_result_f64 strconv__atof64(string s, strconv__AtoF64Param param); | ||
| 2465 | +f64 strconv__atof_quick(string s); | ||
| 2466 | +u8 strconv__byte_to_lower(u8 c); | ||
| 2467 | +_result_u64 strconv__common_parse_uint(string s, int _base, int _bit_size, bool error_on_non_digit, bool error_on_high_digit); | ||
| 2468 | +multi_return_u64_int strconv__common_parse_uint2(string s, int _base, int _bit_size); | ||
| 2469 | +_result_u64 strconv__parse_uint(string s, int _base, int _bit_size); | ||
| 2470 | +_result_i64 strconv__common_parse_int(string _s, int base, int _bit_size, bool error_on_non_digit, bool error_on_high_digit); | ||
| 2471 | +_result_i64 strconv__parse_int(string _s, int base, int _bit_size); | ||
| 2472 | +VV_LOC _result_multi_return_i64_int strconv__atoi_common_check(string s); | ||
| 2473 | +VV_LOC _result_i64 strconv__atoi_common(string s, i64 type_min, i64 type_max); | ||
| 2474 | +_result_int strconv__atoi(string s); | ||
| 2475 | +_result_i8 strconv__atoi8(string s); | ||
| 2476 | +_result_i16 strconv__atoi16(string s); | ||
| 2477 | +_result_i32 strconv__atoi32(string s); | ||
| 2478 | +_result_i64 strconv__atoi64(string s); | ||
| 2479 | +VV_LOC _result_i64 strconv__safe_add_64bits(i64 a, i64 b); | ||
| 2480 | +VV_LOC _result_i64 strconv__safe_mul10_64bits(i64 a); | ||
| 2481 | +VV_LOC _result_int strconv__atou_common_check(string s); | ||
| 2482 | +VV_LOC _result_u64 strconv__atou_common(string s, u64 type_max); | ||
| 2483 | +_result_u8 strconv__atou8(string s); | ||
| 2484 | +_result_u16 strconv__atou16(string s); | ||
| 2485 | +_result_u32 strconv__atou(string s); | ||
| 2486 | +_result_u32 strconv__atou32(string s); | ||
| 2487 | +_result_u64 strconv__atou64(string s); | ||
| 2488 | +string strconv__Dec32_get_string_32(strconv__Dec32 d, bool neg, int i_n_digit, int i_pad_digit); | ||
| 2489 | +VV_LOC multi_return_strconv__Dec32_bool strconv__f32_to_decimal_exact_int(u32 i_mant, u32 exp); | ||
| 2490 | +VV_LOC strconv__Dec32 strconv__f32_to_decimal(u32 mant, u32 exp); | ||
| 2491 | +string strconv__f32_to_str(f32 f, int n_digit); | ||
| 2492 | +string strconv__f32_to_str_pad(f32 f, int n_digit); | ||
| 2493 | +VV_LOC string strconv__Dec64_get_string_64(strconv__Dec64 d, bool neg, int i_n_digit, int i_pad_digit); | ||
| 2494 | +VV_LOC multi_return_strconv__Dec64_bool strconv__f64_to_decimal_exact_int(u64 i_mant, u64 exp); | ||
| 2495 | +VV_LOC strconv__Dec64 strconv__f64_to_decimal(u64 mant, u64 exp); | ||
| 2496 | +string strconv__f64_to_str(f64 f, int n_digit); | ||
| 2497 | +string strconv__f64_to_str_pad(f64 f, int n_digit); | ||
| 2498 | +string strconv__format_str(string s, strconv__BF_param p); | ||
| 2499 | +void strconv__format_str_sb(string s, strconv__BF_param p, strings__Builder* sb); | ||
| 2500 | +void strconv__format_dec_sb(u64 d, strconv__BF_param p, strings__Builder* res); | ||
| 2501 | +string strconv__f64_to_str_lnd1(f64 f, int dec_digit); | ||
| 2502 | +string strconv__format_fl(f64 f, strconv__BF_param p); | ||
| 2503 | +string strconv__format_es(f64 f, strconv__BF_param p); | ||
| 2504 | +string strconv__remove_tail_zeros(string s); | ||
| 2505 | +string strconv__ftoa_64(f64 f); | ||
| 2506 | +string strconv__ftoa_long_64(f64 f); | ||
| 2507 | +string strconv__ftoa_32(f32 f); | ||
| 2508 | +string strconv__ftoa_long_32(f32 f); | ||
| 2509 | +string strconv__format_int(i64 n, int radix); | ||
| 2510 | +string strconv__format_uint(u64 n, int radix); | ||
| 2511 | +string strconv__f32_to_str_l(f32 f); | ||
| 2512 | +string strconv__f32_to_str_l_with_dot(f32 f); | ||
| 2513 | +string strconv__f64_to_str_l(f64 f); | ||
| 2514 | +string strconv__f64_to_str_l_with_dot(f64 f); | ||
| 2515 | +string strconv__fxx_to_str_l_parse(string s); | ||
| 2516 | +string strconv__fxx_to_str_l_parse_with_dot(string s); | ||
| 2517 | +VV_LOC u32 strconv__bool_to_u32(bool b); | ||
| 2518 | +VV_LOC u64 strconv__bool_to_u64(bool b); | ||
| 2519 | +VV_LOC string strconv__get_string_special(bool neg, bool expZero, bool mantZero); | ||
| 2520 | +VV_LOC u32 strconv__mul_shift_32(u32 m, u64 mul, int ishift); | ||
| 2521 | +VV_LOC u32 strconv__mul_pow5_invdiv_pow2(u32 m, u32 q, int j); | ||
| 2522 | +VV_LOC u32 strconv__mul_pow5_div_pow2(u32 m, u32 i, int j); | ||
| 2523 | +VV_LOC u32 strconv__pow5_factor_32(u32 i_v); | ||
| 2524 | +VV_LOC bool strconv__multiple_of_power_of_five_32(u32 v, u32 p); | ||
| 2525 | +VV_LOC bool strconv__multiple_of_power_of_two_32(u32 v, u32 p); | ||
| 2526 | +VV_LOC u32 strconv__log10_pow2(int e); | ||
| 2527 | +VV_LOC u32 strconv__log10_pow5(int e); | ||
| 2528 | +VV_LOC int strconv__pow5_bits(int e); | ||
| 2529 | +VV_LOC u64 strconv__shift_right_128(strconv__Uint128 v, int shift); | ||
| 2530 | +VV_LOC u64 strconv__mul_shift_64(u64 m, strconv__Uint128 mul, int shift); | ||
| 2531 | +VV_LOC u32 strconv__pow5_factor_64(u64 v_i); | ||
| 2532 | +VV_LOC bool strconv__multiple_of_power_of_five_64(u64 v, u32 p); | ||
| 2533 | +VV_LOC bool strconv__multiple_of_power_of_two_64(u64 v, u32 p); | ||
| 2534 | +int strconv__dec_digits(u64 n); | ||
| 2535 | +void strconv__v_printf(string str, Array_voidptr pt); | ||
| 2536 | +string strconv__v_sprintf(string str, Array_voidptr pt); | ||
| 2537 | +VV_LOC void strconv__v_sprintf_panic(int idx, int len); | ||
| 2538 | +VV_LOC f64 strconv__fabs(f64 x); | ||
| 2539 | +string strconv__format_fl_old(f64 f, strconv__BF_param p); | ||
| 2540 | +VV_LOC string strconv__format_es_old(f64 f, strconv__BF_param p); | ||
| 2541 | +VV_LOC string strconv__remove_tail_zeros_old(string s); | ||
| 2542 | +string strconv__format_dec_old(u64 d, strconv__BF_param p); | ||
| 2543 | +int strconv__write_dec(i64 n, Array_u8* buf); | ||
| 2544 | +int strconv__write_dec_u(u64 n, Array_u8* buf); | ||
| 2545 | +VV_LOC void strconv__write_dec_u_digits(u64 n, Array_u8* buf, int offset, int ndigits); | ||
| 2546 | +VV_LOC void builtin___memory_panic(string fname, isize size); | ||
| 2547 | +u8* builtin___v_malloc(isize n); | ||
| 2548 | +u8* builtin__malloc_noscan(isize n); | ||
| 2549 | +VV_LOC u8* builtin__malloc_uninit(isize n); | ||
| 2550 | +VV_LOC u64 builtin____at_least_one(u64 how_many); | ||
| 2551 | +u8* builtin__malloc_uncollectable(isize n); | ||
| 2552 | +u8* builtin__v_realloc(u8* b, isize n); | ||
| 2553 | +u8* builtin__realloc_data(u8* old_data, int old_size, int new_size); | ||
| 2554 | +u8* builtin__vcalloc(isize n); | ||
| 2555 | +u8* builtin__vcalloc_noscan(isize n); | ||
| 2556 | +void builtin___v_free(voidptr ptr); | ||
| 2557 | +voidptr builtin__memdup(voidptr src, isize sz); | ||
| 2558 | +voidptr builtin__memdup_noscan(voidptr src, isize sz); | ||
| 2559 | +voidptr builtin__memdup_uncollectable(voidptr src, isize sz); | ||
| 2560 | +voidptr builtin__memdup_align(voidptr src, isize sz, isize align); | ||
| 2561 | +GCHeapUsage builtin__gc_heap_usage(void); | ||
| 2562 | +usize builtin__gc_memory_use(void); | ||
| 2563 | +VV_LOC int builtin__array_data_header_size(void); | ||
| 2564 | +VV_LOC u64 builtin__array_data_allocation_size(u64 total_size); | ||
| 2565 | +VV_LOC voidptr builtin__alloc_array_data(u64 total_size); | ||
| 2566 | +VV_LOC voidptr builtin__alloc_array_data_uninit(u64 total_size); | ||
| 2567 | +VV_LOC bool builtin__array_uses_noscan_data(array a); | ||
| 2568 | +VV_LOC voidptr builtin__array_alloc_array_data_like(array a, u64 total_size); | ||
| 2569 | +VV_LOC voidptr builtin__array_alloc_array_data_like_uninit(array a, u64 total_size); | ||
| 2570 | +VV_LOC ArrayDataHeader* builtin__array_data_header(array a); | ||
| 2571 | +VV_LOC bool builtin__array_buffer_has_slices(array a); | ||
| 2572 | +VV_LOC void builtin__array_mark_buffer_has_slices(array* a); | ||
| 2573 | +VV_LOC void builtin__array_set_managed_flags(array* a, bool is_slice); | ||
| 2574 | +VV_LOC void builtin__array_clone_shallow_to_cap(array* a, int new_cap); | ||
| 2575 | +VV_LOC int builtin__v_ni_index(int i, int len); | ||
| 2576 | +VV_LOC array builtin____new_array(int mylen, int cap, int elm_size); | ||
| 2577 | +VV_LOC array builtin____new_array_with_default(int mylen, int cap, int elm_size, voidptr val); | ||
| 2578 | +VV_LOC array builtin____new_array_with_multi_default(int mylen, int cap, int elm_size, voidptr val); | ||
| 2579 | +VV_LOC array builtin____new_array_with_array_default(int mylen, int cap, int elm_size, array val, int depth); | ||
| 2580 | +VV_LOC array builtin__new_array_from_c_array(int len, int cap, int elm_size, voidptr c_array); | ||
| 2581 | +void builtin__array_ensure_cap(array* a, int required); | ||
| 2582 | +array builtin__array_repeat(array a, int count); | ||
| 2583 | +array builtin__array_repeat_to_depth(array a, int count, int depth); | ||
| 2584 | +VV_LOC bool builtin__array_needs_unique_shift(array a, int required); | ||
| 2585 | +VV_LOC bool builtin__array_needs_unique_append(array a, int required); | ||
| 2586 | +VV_LOC bool builtin__array_needs_unique_shrink(array a); | ||
| 2587 | +void builtin__array_insert(array* a, int i, voidptr val); | ||
| 2588 | +void builtin__array_prepend(array* a, voidptr val); | ||
| 2589 | +void builtin__array_delete(array* a, int i); | ||
| 2590 | +void builtin__array_delete_many(array* a, int i, int size); | ||
| 2591 | +void builtin__array_clear(array* a); | ||
| 2592 | +void builtin__array_reset(array* a); | ||
| 2593 | +void builtin__array_trim(array* a, int index); | ||
| 2594 | +void builtin__array_drop(array* a, int num); | ||
| 2595 | +VV_LOC voidptr builtin__array_get_unsafe(array a, int i); | ||
| 2596 | +VV_LOC voidptr builtin__array_get(array a, int i); | ||
| 2597 | +VV_LOC voidptr builtin__array_get_i64(array a, i64 i); | ||
| 2598 | +VV_LOC voidptr builtin__array_get_u64(array a, u64 i); | ||
| 2599 | +VV_LOC voidptr builtin__array_get_ni(array a, int i); | ||
| 2600 | +VV_LOC voidptr builtin__array_get_with_check(array a, int i); | ||
| 2601 | +VV_LOC voidptr builtin__array_get_with_check_i64(array a, i64 i); | ||
| 2602 | +VV_LOC voidptr builtin__array_get_with_check_u64(array a, u64 i); | ||
| 2603 | +VV_LOC voidptr builtin__array_get_with_check_ni(array a, int i); | ||
| 2604 | +voidptr builtin__array_first(array a); | ||
| 2605 | +voidptr builtin__array_last(array a); | ||
| 2606 | +voidptr builtin__array_pop_left(array* a); | ||
| 2607 | +voidptr builtin__array_pop(array* a); | ||
| 2608 | +void builtin__array_delete_last(array* a); | ||
| 2609 | +VV_LOC array builtin__array_slice(array a, int start, int _end); | ||
| 2610 | +VV_LOC array builtin__array_slice_ni(array a, int _start, int _end); | ||
| 2611 | +VV_LOC array builtin__array_clone_static_to_depth(array a, int depth); | ||
| 2612 | +array builtin__array_clone(array* a); | ||
| 2613 | +array builtin__array_clone_to_depth(array* a, int depth); | ||
| 2614 | +VV_LOC void builtin__array_set_unsafe(array* a, int i, voidptr val); | ||
| 2615 | +VV_LOC void builtin__array_set(array* a, int i, voidptr val); | ||
| 2616 | +VV_LOC void builtin__array_set_i64(array* a, i64 i, voidptr val); | ||
| 2617 | +VV_LOC void builtin__array_set_u64(array* a, u64 i, voidptr val); | ||
| 2618 | +VV_LOC void builtin__array_set_ni(array* a, int i, voidptr val); | ||
| 2619 | +VV_LOC void builtin__copy_element_to(voidptr dest, voidptr src, int element_size); | ||
| 2620 | +VV_LOC void builtin__array_push(array* a, voidptr val); | ||
| 2621 | +void builtin__array_push_many(array* a, voidptr val, int size); | ||
| 2622 | +void builtin__array_reverse_in_place(array* a); | ||
| 2623 | +array builtin__array_reverse(array a); | ||
| 2624 | +void builtin__array_free(array* a); | ||
| 2625 | +array builtin__array_filter(array a, bool (*predicate)(voidptr _d1)); | ||
| 2626 | +bool builtin__array_any(array a, bool (*predicate)(voidptr _d1)); | ||
| 2627 | +int builtin__array_count(array a, bool (*predicate)(voidptr _d1)); | ||
| 2628 | +bool builtin__array_all(array a, bool (*predicate)(voidptr _d1)); | ||
| 2629 | +array builtin__array_map(array a, voidptr (*callback)(voidptr _d1)); | ||
| 2630 | +void builtin__array_sort(array* a, int (*callback)(voidptr _d1, voidptr _d2)); | ||
| 2631 | +array builtin__array_sorted(array* a, int (*callback)(voidptr _d1, voidptr _d2)); | ||
| 2632 | +void builtin__array_sort_with_compare(array* a, int (*callback)(const void* const_a, const void* const_b)); | ||
| 2633 | +array builtin__array_sorted_with_compare(array* a, int (*callback)(const void* const_a, const void* const_b)); | ||
| 2634 | +bool builtin__array_contains(array a, voidptr value); | ||
| 2635 | +int builtin__array_index(array a, voidptr value); | ||
| 2636 | +int builtin__array_last_index(array a, voidptr value); | ||
| 2637 | +void Array_string_free(Array_string* a); | ||
| 2638 | +string Array_string_str(Array_string a); | ||
| 2639 | +string Array_u8_hex(Array_u8 b); | ||
| 2640 | +int builtin__copy(Array_u8* dst, Array_u8 src); | ||
| 2641 | +void builtin__array_grow_cap(array* a, int amount); | ||
| 2642 | +void builtin__array_grow_len(array* a, int amount); | ||
| 2643 | +Array_voidptr builtin__array_pointers(array a); | ||
| 2644 | +Array_u8 builtin__voidptr_vbytes(voidptr data, int len); | ||
| 2645 | +Array_u8 builtin__u8_vbytes(u8* data, int len); | ||
| 2646 | +void builtin__u8_free(u8* data); | ||
| 2647 | +VV_LOC void builtin__panic_on_negative_len(int len); | ||
| 2648 | +VV_LOC void builtin__panic_on_negative_cap(int cap); | ||
| 2649 | +VV_LOC array builtin____new_array_noscan(int mylen, int cap, int elm_size); | ||
| 2650 | +VV_LOC array builtin____new_array_with_default_noscan(int mylen, int cap, int elm_size, voidptr val); | ||
| 2651 | +VV_LOC array builtin____new_array_with_multi_default_noscan(int mylen, int cap, int elm_size, voidptr val); | ||
| 2652 | +VV_LOC array builtin____new_array_with_array_default_noscan(int mylen, int cap, int elm_size, array val, int depth); | ||
| 2653 | +VV_LOC void builtin__array_push_noscan(array* a, voidptr val); | ||
| 2654 | +VV_LOC void builtin__array_push_many_noscan(array* a, voidptr val, int size); | ||
| 2655 | +VV_LOC bool builtin__autostr_type_in_stack(int typ); | ||
| 2656 | +VV_LOC void builtin__autostr_type_push(int typ); | ||
| 2657 | +VV_LOC void builtin__autostr_type_pop(void); | ||
| 2658 | +VV_LOC bool builtin__autostr_addr_in_stack(voidptr addr); | ||
| 2659 | +VV_LOC void builtin__autostr_addr_push(voidptr addr); | ||
| 2660 | +VV_LOC void builtin__autostr_addr_pop(void); | ||
| 2661 | +VV_LOC string builtin__autostr_array_circular(int len); | ||
| 2662 | +void builtin__print_backtrace(void); | ||
| 2663 | +VV_LOC string builtin__demangle_v_symbol(string cname); | ||
| 2664 | +VV_LOC Array_string builtin__split_generic_params(string s); | ||
| 2665 | +VV_LOC string builtin__demangle_backtrace_sym(string s); | ||
| 2666 | +VV_LOC void builtin__eprint_space_padding(string output, int max_len); | ||
| 2667 | +bool builtin__print_backtrace_skipping_top_frames(int xskipframes); | ||
| 2668 | +VV_LOC string builtin__backtrace_current_executable_name(void); | ||
| 2669 | +VV_LOC string builtin__backtrace_addr2line_executable(string executable, string current_executable_name); | ||
| 2670 | +VV_LOC string builtin__backtrace_shell_quote(string s); | ||
| 2671 | +VV_LOC bool builtin__print_backtrace_skipping_top_frames_linux(int skipframes); | ||
| 2672 | +void builtin___v_exit(int code); | ||
| 2673 | +_result_void builtin__at_exit(void (*cb)()); | ||
| 2674 | +VV_LOC void builtin__v_segmentation_fault_handler(i32 signal_number); | ||
| 2675 | +VV_LOC int builtin__v_fixed_index(int i, int len); | ||
| 2676 | +VV_LOC int builtin__v_fixed_index_i64(i64 i, int len); | ||
| 2677 | +VV_LOC int builtin__v_fixed_index_u64(u64 i, int len); | ||
| 2678 | +VV_LOC int builtin__v_fixed_index_ni(int i, int len); | ||
| 2679 | +VV_LOC int builtin__v_slice_index_i64(i64 i); | ||
| 2680 | +VV_LOC int builtin__v_slice_index_u64(u64 i); | ||
| 2681 | +Array_string builtin__arguments(void); | ||
| 2682 | +string builtin__vcurrent_hash(void); | ||
| 2683 | +u64 builtin__v_getpid(void); | ||
| 2684 | +u64 builtin__v_gettid(void); | ||
| 2685 | +bool builtin__isnil(voidptr v); | ||
| 2686 | +VV_LOC void builtin__builtin_init(void); | ||
| 2687 | +void builtin__panic_lasterr(string base); | ||
| 2688 | +void builtin__gc_check_leaks(void); | ||
| 2689 | +bool builtin__gc_is_enabled(void); | ||
| 2690 | +void builtin__gc_enable(void); | ||
| 2691 | +void builtin__gc_disable(void); | ||
| 2692 | +void builtin__gc_collect(void); | ||
| 2693 | +void builtin__gc_get_warn_proc(void); | ||
| 2694 | +void builtin__gc_set_warn_proc(void (*cb)(char* msg, usize arg)); | ||
| 2695 | +int builtin__vstrlen(u8* s); | ||
| 2696 | +int builtin__vstrlen_char(char* s); | ||
| 2697 | +voidptr builtin__vmemcpy(voidptr dest, const void* const_src, isize n); | ||
| 2698 | +voidptr builtin__vmemmove(voidptr dest, const void* const_src, isize n); | ||
| 2699 | +int builtin__vmemcmp(const void* const_s1, const void* const_s2, isize n); | ||
| 2700 | +voidptr builtin__vmemset(voidptr s, int c, isize n); | ||
| 2701 | +VV_LOC voidptr builtin__vsort_ptr_at(voidptr base, usize index, usize size); | ||
| 2702 | +VV_LOC void builtin__vstable_sort_merge(voidptr source, voidptr dest, usize left, usize mid, usize right, usize size, int (*sort_cb)(const void* const_a, const void* const_b)); | ||
| 2703 | +VV_LOC void builtin__vqsort(voidptr base, usize nmemb, usize size, int (*sort_cb)(const void* const_a, const void* const_b)); | ||
| 2704 | +void builtin__chan_close(chan ch, Array_IError err); | ||
| 2705 | +ChanState builtin__chan_try_pop(chan ch, voidptr obj); | ||
| 2706 | +ChanState builtin__chan_try_push(chan ch, voidptr obj); | ||
| 2707 | +VV_LOC void builtin___result_ok(voidptr data, _result* res, int size); | ||
| 2708 | +VV_LOC void builtin___result_clone(_result* current, _result* res, int size); | ||
| 2709 | +string builtin__IError_str(IError err); | ||
| 2710 | +string builtin__Error_msg(Error err); | ||
| 2711 | +int builtin__Error_code(Error err); | ||
| 2712 | +string builtin__MessageError_str(MessageError err); | ||
| 2713 | +string builtin__MessageError_msg(MessageError err); | ||
| 2714 | +int builtin__MessageError_code(MessageError err); | ||
| 2715 | +void builtin__MessageError_free(MessageError* err); | ||
| 2716 | +IError builtin___v_error(string message); | ||
| 2717 | +IError builtin__error_with_code(string message, int code); | ||
| 2718 | +VV_LOC void builtin___option_none(voidptr data, _option* option, int size); | ||
| 2719 | +VV_LOC void builtin___option_ok(voidptr data, _option* option, int size); | ||
| 2720 | +VV_LOC void builtin___option_clone(_option* current, _option* option, int size); | ||
| 2721 | +VV_LOC void builtin___result_ok_markused(void); | ||
| 2722 | +VV_LOC string builtin__None___str(None__ _d1); | ||
| 2723 | +string builtin__none_str(none _d1); | ||
| 2724 | +int builtin__input_character(void); | ||
| 2725 | +int builtin__print_character(u8 ch); | ||
| 2726 | +string builtin__f64_str(f64 x); | ||
| 2727 | +string builtin__f64_strg(f64 x); | ||
| 2728 | +string builtin__float_literal_str(float_literal d); | ||
| 2729 | +string builtin__f64_strsci(f64 x, int digit_num); | ||
| 2730 | +string builtin__f64_strlong(f64 x); | ||
| 2731 | +string builtin__f32_str(f32 x); | ||
| 2732 | +string builtin__f32_strg(f32 x); | ||
| 2733 | +string builtin__f32_strsci(f32 x, int digit_num); | ||
| 2734 | +string builtin__f32_strlong(f32 x); | ||
| 2735 | +f32 builtin__f32_abs(f32 a); | ||
| 2736 | +f64 builtin__f64_abs(f64 a); | ||
| 2737 | +f32 builtin__f32_min(f32 a, f32 b); | ||
| 2738 | +f32 builtin__f32_max(f32 a, f32 b); | ||
| 2739 | +f64 builtin__f64_min(f64 a, f64 b); | ||
| 2740 | +f64 builtin__f64_max(f64 a, f64 b); | ||
| 2741 | +bool builtin__f32_eq_epsilon(f32 a, f32 b); | ||
| 2742 | +bool builtin__f64_eq_epsilon(f64 a, f64 b); | ||
| 2743 | +VV_LOC u32 builtin__grapheme_hex_nibble(u8 c); | ||
| 2744 | +VV_LOC u32 builtin__grapheme_hex_byte(string ranges, int i); | ||
| 2745 | +VV_LOC u32 builtin__grapheme_range_value(string ranges, int value_idx); | ||
| 2746 | +VV_LOC bool builtin__in_grapheme_ranges(rune r, string ranges); | ||
| 2747 | +VV_LOC GraphemeBreakProperty builtin__grapheme_break_property(rune r); | ||
| 2748 | +VV_LOC bool builtin__is_extended_pictographic(rune r); | ||
| 2749 | +VV_LOC GraphemeState builtin__grapheme_state_from_rune(rune r, GraphemeBreakProperty prop); | ||
| 2750 | +VV_LOC void builtin__GraphemeState_push(GraphemeState* gs, rune r, GraphemeBreakProperty prop); | ||
| 2751 | +VV_LOC bool builtin__should_break_grapheme(GraphemeState gs, rune r, GraphemeBreakProperty prop); | ||
| 2752 | +VV_LOC int builtin__utf8_rune_visible_width(rune r, GraphemeBreakProperty prop); | ||
| 2753 | +VV_LOC Array_string builtin__string_graphemes_impl(string s); | ||
| 2754 | +VV_LOC int builtin__utf8_grapheme_visible_length(string s); | ||
| 2755 | +_option_rune builtin__input_rune(void); | ||
| 2756 | +_option_rune builtin__InputRuneIterator_next(InputRuneIterator* self); | ||
| 2757 | +InputRuneIterator builtin__input_rune_iterator(void); | ||
| 2758 | +string builtin__ptr_str(voidptr ptr); | ||
| 2759 | +string builtin__isize_str(isize x); | ||
| 2760 | +string builtin__usize_str(usize x); | ||
| 2761 | +string builtin__char_str(char* cptr); | ||
| 2762 | +VV_LOC string builtin__int_str_l(int nn, int max); | ||
| 2763 | +string builtin__i8_str(i8 n); | ||
| 2764 | +string builtin__i16_str(i16 n); | ||
| 2765 | +string builtin__u16_str(u16 n); | ||
| 2766 | +string builtin__i32_str(i32 n); | ||
| 2767 | +string builtin__int_hex_full(int nn); | ||
| 2768 | +string builtin__int_str(int n); | ||
| 2769 | +string builtin__u32_str(u32 nn); | ||
| 2770 | +string builtin__int_literal_str(int_literal n); | ||
| 2771 | +string builtin__i64_str(i64 nn); | ||
| 2772 | +VV_LOC string builtin__impl_i64_to_string(i64 nn); | ||
| 2773 | +string builtin__u64_str(u64 nn); | ||
| 2774 | +string builtin__bool_str(bool b); | ||
| 2775 | +VV_LOC string builtin__u64_to_hex(u64 nn, u8 len); | ||
| 2776 | +VV_LOC string builtin__u64_to_hex_no_leading_zeros(u64 nn, u8 len); | ||
| 2777 | +string builtin__u8_hex(u8 nn); | ||
| 2778 | +string builtin__char_hex(char c); | ||
| 2779 | +string builtin__rune_hex(rune r); | ||
| 2780 | +string builtin__i8_hex(i8 nn); | ||
| 2781 | +string builtin__u16_hex(u16 nn); | ||
| 2782 | +string builtin__i16_hex(i16 nn); | ||
| 2783 | +string builtin__u32_hex(u32 nn); | ||
| 2784 | +string builtin__int_hex(int nn); | ||
| 2785 | +string builtin__int_hex2(int n); | ||
| 2786 | +string builtin__u64_hex(u64 nn); | ||
| 2787 | +string builtin__i64_hex(i64 nn); | ||
| 2788 | +string builtin__int_literal_hex(int_literal nn); | ||
| 2789 | +string builtin__voidptr_str(voidptr nn); | ||
| 2790 | +string builtin__byteptr_str(byteptr nn); | ||
| 2791 | +string builtin__charptr_str(charptr nn); | ||
| 2792 | +string builtin__u8_hex_full(u8 nn); | ||
| 2793 | +string builtin__i8_hex_full(i8 nn); | ||
| 2794 | +string builtin__u16_hex_full(u16 nn); | ||
| 2795 | +string builtin__i16_hex_full(i16 nn); | ||
| 2796 | +string builtin__u32_hex_full(u32 nn); | ||
| 2797 | +string builtin__i64_hex_full(i64 nn); | ||
| 2798 | +string builtin__voidptr_hex_full(voidptr nn); | ||
| 2799 | +string builtin__int_literal_hex_full(int_literal nn); | ||
| 2800 | +string builtin__u64_hex_full(u64 nn); | ||
| 2801 | +string builtin__u8_str(u8 b); | ||
| 2802 | +string builtin__u8_ascii_str(u8 b); | ||
| 2803 | +string builtin__u8_str_escaped(u8 b); | ||
| 2804 | +bool builtin__u8_is_capital(u8 c); | ||
| 2805 | +string Array_u8_bytestr(Array_u8 b); | ||
| 2806 | +_result_rune Array_u8_byterune(Array_u8 b); | ||
| 2807 | +string builtin__u8_repeat(u8 b, int count); | ||
| 2808 | +int builtin__int_min(int a, int b); | ||
| 2809 | +int builtin__int_max(int a, int b); | ||
| 2810 | +VV_LOC bool builtin__fast_string_eq(string a, string b); | ||
| 2811 | +VV_LOC u64 builtin__map_hash_string(voidptr pkey); | ||
| 2812 | +VV_LOC u64 builtin__map_hash_int_1(voidptr pkey); | ||
| 2813 | +VV_LOC u64 builtin__map_hash_int_2(voidptr pkey); | ||
| 2814 | +VV_LOC u64 builtin__map_hash_int_4(voidptr pkey); | ||
| 2815 | +VV_LOC u64 builtin__map_hash_int_8(voidptr pkey); | ||
| 2816 | +VV_LOC voidptr builtin__map_enum_fn(int kind, int esize); | ||
| 2817 | +VV_LOC void builtin__DenseArray_zeros_to_end(DenseArray* d); | ||
| 2818 | +VV_LOC DenseArray builtin__new_dense_array(int key_bytes, int value_bytes); | ||
| 2819 | +VV_LOC voidptr builtin__DenseArray_key(DenseArray* d, int i); | ||
| 2820 | +VV_LOC voidptr builtin__DenseArray_value(DenseArray* d, int i); | ||
| 2821 | +VV_LOC bool builtin__DenseArray_has_index(DenseArray* d, int i); | ||
| 2822 | +VV_LOC void builtin__DenseArray_trim_deleted_tail(DenseArray* d); | ||
| 2823 | +VV_LOC int builtin__DenseArray_expand(DenseArray* d); | ||
| 2824 | +VV_LOC bool builtin__map_eq_string(voidptr a, voidptr b); | ||
| 2825 | +VV_LOC bool builtin__map_eq_int_1(voidptr a, voidptr b); | ||
| 2826 | +VV_LOC bool builtin__map_eq_int_2(voidptr a, voidptr b); | ||
| 2827 | +VV_LOC bool builtin__map_eq_int_4(voidptr a, voidptr b); | ||
| 2828 | +VV_LOC bool builtin__map_eq_int_8(voidptr a, voidptr b); | ||
| 2829 | +VV_LOC bool builtin__map_map_eq(map a, map b); | ||
| 2830 | +VV_LOC void builtin__map_clone_string(voidptr dest, voidptr pkey); | ||
| 2831 | +VV_LOC void builtin__map_clone_int_1(voidptr dest, voidptr pkey); | ||
| 2832 | +VV_LOC void builtin__map_clone_int_2(voidptr dest, voidptr pkey); | ||
| 2833 | +VV_LOC void builtin__map_clone_int_4(voidptr dest, voidptr pkey); | ||
| 2834 | +VV_LOC void builtin__map_clone_int_8(voidptr dest, voidptr pkey); | ||
| 2835 | +VV_LOC void builtin__map_free_string(voidptr pkey); | ||
| 2836 | +VV_LOC void builtin__map_free_nop(voidptr _d1); | ||
| 2837 | +VV_LOC map builtin__new_map(int key_bytes, int value_bytes, u64 (*hash_fn)(voidptr _d1), bool (*key_eq_fn)(voidptr _d1, voidptr _d2), void (*clone_fn)(voidptr _d1, voidptr _d2), void (*free_fn)(voidptr _d1)); | ||
| 2838 | +VV_LOC map builtin__new_map_init(u64 (*hash_fn)(voidptr _d1), bool (*key_eq_fn)(voidptr _d1, voidptr _d2), void (*clone_fn)(voidptr _d1, voidptr _d2), void (*free_fn)(voidptr _d1), int n, int key_bytes, int value_bytes, voidptr keys, voidptr values); | ||
| 2839 | +map builtin__map_move(map* m); | ||
| 2840 | +void builtin__map_clear(map* m); | ||
| 2841 | +VV_LOC multi_return_u32_u32 builtin__map_key_to_index(map* m, voidptr pkey); | ||
| 2842 | +VV_LOC multi_return_u32_u32 builtin__map_meta_less(map* m, u32 _index, u32 _metas); | ||
| 2843 | +VV_LOC void builtin__map_meta_greater(map* m, u32 _index, u32 _metas, u32 kvi); | ||
| 2844 | +VV_LOC void builtin__map_ensure_extra_metas_grow(map* m); | ||
| 2845 | +VV_LOC void builtin__map_ensure_extra_metas(map* m, u32 probe_count); | ||
| 2846 | +VV_LOC void builtin__map_set(map* m, voidptr key, voidptr value); | ||
| 2847 | +VV_LOC void builtin__map_expand(map* m); | ||
| 2848 | +VV_LOC void builtin__map_rehash(map* m); | ||
| 2849 | +VV_LOC void builtin__map_reserve_metas(map* m, u32 meta_bytes); | ||
| 2850 | +void builtin__map_reserve(map* m, u32 n); | ||
| 2851 | +VV_LOC void builtin__map_cached_rehash(map* m, u32 old_cap); | ||
| 2852 | +VV_LOC voidptr builtin__map_get_and_set(map* m, voidptr key, voidptr zero); | ||
| 2853 | +VV_LOC voidptr builtin__map_get(map* m, voidptr key, voidptr zero); | ||
| 2854 | +VV_LOC voidptr builtin__map_get_check(map* m, voidptr key); | ||
| 2855 | +VV_LOC bool builtin__map_exists(map* m, voidptr key); | ||
| 2856 | +VV_LOC void builtin__DenseArray_delete(DenseArray* d, int i); | ||
| 2857 | +void builtin__map_delete(map* m, voidptr key); | ||
| 2858 | +array builtin__map_keys(map* m); | ||
| 2859 | +array builtin__map_values(map* m); | ||
| 2860 | +VV_LOC DenseArray builtin__DenseArray_clone(DenseArray* d); | ||
| 2861 | +map builtin__map_clone(map* m); | ||
| 2862 | +void builtin__map_free(map* m); | ||
| 2863 | +void builtin__VAssertMetaInfo_free(VAssertMetaInfo* ami); | ||
| 2864 | +void builtin__IError_free(IError* ie); | ||
| 2865 | +void builtin__panic_option_not_set(string s); | ||
| 2866 | +void builtin__panic_result_not_set(string s); | ||
| 2867 | +void builtin___v_panic(string s); | ||
| 2868 | +string builtin__c_error_number_str(int errnum); | ||
| 2869 | +void builtin__panic_n(string s, i64 number1); | ||
| 2870 | +void builtin__panic_n2(string s, i64 number1, i64 number2); | ||
| 2871 | +VV_LOC void builtin__panic_n3(string s, i64 number1, i64 number2, i64 number3); | ||
| 2872 | +void builtin__panic_error_number(string basestr, int errnum); | ||
| 2873 | +VV_LOC void builtin__set_stream_unbuffered(FILE* stream); | ||
| 2874 | +void builtin__eprintln(string s); | ||
| 2875 | +void builtin__eprint(string s); | ||
| 2876 | +void builtin__flush_stdout(void); | ||
| 2877 | +void builtin__flush_stderr(void); | ||
| 2878 | +void builtin__unbuffer_stdout(void); | ||
| 2879 | +void builtin__print(string s); | ||
| 2880 | +void builtin__println(string s); | ||
| 2881 | +VV_LOC void builtin___writeln_to_fd(int fd, string s); | ||
| 2882 | +VV_LOC void builtin___write_buf_to_fd(int fd, u8* buf, int buf_len); | ||
| 2883 | +string builtin__reuse_data_as_string(Array_u8 buffer); | ||
| 2884 | +Array_u8 builtin__reuse_string_as_data(string s); | ||
| 2885 | +string builtin__rune_str(rune c); | ||
| 2886 | +string Array_rune_string(Array_rune ra); | ||
| 2887 | +string builtin__rune_repeat(rune c, int count); | ||
| 2888 | +Array_u8 builtin__rune_bytes(rune c); | ||
| 2889 | +int builtin__rune_length_in_bytes(rune c); | ||
| 2890 | +rune builtin__rune_to_upper(rune c); | ||
| 2891 | +rune builtin__rune_to_lower(rune c); | ||
| 2892 | +rune builtin__rune_to_title(rune c); | ||
| 2893 | +VV_LOC rune builtin__rune_map_to(rune c, MapMode mode); | ||
| 2894 | +VV_LOC int builtin__mapnode_find_key(mapnode* n, string k); | ||
| 2895 | +VV_LOC bool builtin__mapnode_remove_key(mapnode* n, string k); | ||
| 2896 | +VV_LOC void builtin__mapnode_remove_from_leaf(mapnode* n, int idx); | ||
| 2897 | +VV_LOC void builtin__mapnode_remove_from_non_leaf(mapnode* n, int idx); | ||
| 2898 | +VV_LOC void builtin__mapnode_fill(mapnode* n, int idx); | ||
| 2899 | +VV_LOC void builtin__mapnode_borrow_from_prev(mapnode* n, int idx); | ||
| 2900 | +VV_LOC void builtin__mapnode_borrow_from_next(mapnode* n, int idx); | ||
| 2901 | +VV_LOC void builtin__mapnode_merge(mapnode* n, int idx); | ||
| 2902 | +void builtin__SortedMap_delete(SortedMap* m, string key); | ||
| 2903 | +VV_LOC int builtin__mapnode_subkeys(mapnode* n, Array_string* keys, int at); | ||
| 2904 | +Array_string builtin__SortedMap_keys(SortedMap* m); | ||
| 2905 | +VV_LOC void builtin__mapnode_free(mapnode* n); | ||
| 2906 | +void builtin__SortedMap_free(SortedMap* m); | ||
| 2907 | +Array_rune builtin__string_runes(string s); | ||
| 2908 | +Array_string builtin__string_graphemes(string s); | ||
| 2909 | +string builtin__cstring_to_vstring(const char* const_s); | ||
| 2910 | +string builtin__tos_clone(const u8* const_s); | ||
| 2911 | +string builtin__tos(u8* s, int len); | ||
| 2912 | +string builtin__tos2(u8* s); | ||
| 2913 | +string builtin__tos3(char* s); | ||
| 2914 | +string builtin__tos4(u8* s); | ||
| 2915 | +string builtin__tos5(char* s); | ||
| 2916 | +string builtin__u8_vstring(u8* bp); | ||
| 2917 | +string builtin__u8_vstring_with_len(u8* bp, int len); | ||
| 2918 | +string builtin__char_vstring(char* cp); | ||
| 2919 | +string builtin__char_vstring_with_len(char* cp, int len); | ||
| 2920 | +string builtin__u8_vstring_literal(u8* bp); | ||
| 2921 | +string builtin__u8_vstring_literal_with_len(u8* bp, int len); | ||
| 2922 | +string builtin__char_vstring_literal(char* cp); | ||
| 2923 | +string builtin__char_vstring_literal_with_len(char* cp, int len); | ||
| 2924 | +int builtin__string_len_utf8(string s); | ||
| 2925 | +bool builtin__string_is_pure_ascii(string s); | ||
| 2926 | +string builtin__string_clone(string a); | ||
| 2927 | +string builtin__string_replace_once(string s, string rep, string with); | ||
| 2928 | +string builtin__string_replace(string s, string rep, string with); | ||
| 2929 | +string builtin__string_replace_each(string s, Array_string vals); | ||
| 2930 | +string builtin__string_format(string s, Array_string args); | ||
| 2931 | +string builtin__string_replace_char(string s, u8 rep, u8 with, int repeat); | ||
| 2932 | +string builtin__string_normalize_tabs(string s, int tab_len); | ||
| 2933 | +string builtin__string_expand_tabs(string s, int tab_len); | ||
| 2934 | +bool builtin__string_bool(string s); | ||
| 2935 | +i8 builtin__string_i8(string s); | ||
| 2936 | +i16 builtin__string_i16(string s); | ||
| 2937 | +i32 builtin__string_i32(string s); | ||
| 2938 | +int builtin__string_int(string s); | ||
| 2939 | +i64 builtin__string_i64(string s); | ||
| 2940 | +f32 builtin__string_f32(string s); | ||
| 2941 | +f64 builtin__string_f64(string s); | ||
| 2942 | +Array_u8 builtin__string_u8_array(string s); | ||
| 2943 | +u8 builtin__string_u8(string s); | ||
| 2944 | +u16 builtin__string_u16(string s); | ||
| 2945 | +u32 builtin__string_u32(string s); | ||
| 2946 | +u64 builtin__string_u64(string s); | ||
| 2947 | +_result_u64 builtin__string_parse_uint(string s, int _base, int _bit_size); | ||
| 2948 | +_result_i64 builtin__string_parse_int(string s, int _base, int _bit_size); | ||
| 2949 | +VV_LOC bool builtin__string__eq(string s, string a); | ||
| 2950 | +int builtin__string_compare(string s, string a); | ||
| 2951 | +VV_LOC bool builtin__string__lt(string s, string a); | ||
| 2952 | +VV_LOC string builtin__string__plus(string s, string a); | ||
| 2953 | +VV_LOC string builtin__string_plus_many(int data_len, string* input_base); | ||
| 2954 | +VV_LOC string builtin__string_plus_two(string s, string a, string b); | ||
| 2955 | +Array_string builtin__string_split_any(string s, string delim); | ||
| 2956 | +Array_string builtin__string_rsplit_any(string s, string delim); | ||
| 2957 | +Array_string builtin__string_split(string s, string delim); | ||
| 2958 | +Array_string builtin__string_rsplit(string s, string delim); | ||
| 2959 | +_option_multi_return_string_string builtin__string_split_once(string s, string delim); | ||
| 2960 | +_option_multi_return_string_string builtin__string_rsplit_once(string s, string delim); | ||
| 2961 | +Array_string builtin__string_split_n(string s, string delim, int n); | ||
| 2962 | +Array_string builtin__string_split_nth(string s, string delim, int nth); | ||
| 2963 | +Array_string builtin__string_rsplit_nth(string s, string delim, int nth); | ||
| 2964 | +Array_string builtin__string_split_into_lines(string s); | ||
| 2965 | +Array_string builtin__string_split_by_space(string s); | ||
| 2966 | +string builtin__string_substr(string s, int start, int _end); | ||
| 2967 | +string builtin__string_substr_unsafe(string s, int start, int _end); | ||
| 2968 | +string builtin__string_substr_or(string s, int start, int _end, string fallback); | ||
| 2969 | +_result_string builtin__string_substr_with_check(string s, int start, int _end); | ||
| 2970 | +string builtin__string_substr_ni(string s, int _start, int _end); | ||
| 2971 | +int builtin__string_index_(string s, string p); | ||
| 2972 | +_option_int builtin__string_index(string s, string p); | ||
| 2973 | +_option_int builtin__string_last_index(string s, string needle); | ||
| 2974 | +VV_LOC int builtin__string_index_kmp(string s, string p); | ||
| 2975 | +int builtin__string_index_any(string s, string chars); | ||
| 2976 | +VV_LOC int builtin__string_index_last_(string s, string p); | ||
| 2977 | +_option_int builtin__string_index_after(string s, string p, int start); | ||
| 2978 | +int builtin__string_index_after_(string s, string p, int start); | ||
| 2979 | +int builtin__string_index_u8(string s, u8 c); | ||
| 2980 | +int builtin__string_last_index_u8(string s, u8 c); | ||
| 2981 | +int builtin__string_count(string s, string substr); | ||
| 2982 | +bool builtin__string_contains_u8(string s, u8 x); | ||
| 2983 | +bool builtin__string_contains(string s, string substr); | ||
| 2984 | +bool builtin__string_contains_any(string s, string chars); | ||
| 2985 | +bool builtin__string_contains_only(string s, string chars); | ||
| 2986 | +bool builtin__string_contains_any_substr(string s, Array_string substrs); | ||
| 2987 | +bool builtin__string_starts_with(string s, string p); | ||
| 2988 | +bool builtin__string_ends_with(string s, string p); | ||
| 2989 | +string builtin__string_to_lower_ascii(string s); | ||
| 2990 | +string builtin__string_to_lower(string s); | ||
| 2991 | +bool builtin__string_is_lower(string s); | ||
| 2992 | +string builtin__string_to_upper_ascii(string s); | ||
| 2993 | +string builtin__string_to_upper(string s); | ||
| 2994 | +bool builtin__string_is_upper(string s); | ||
| 2995 | +string builtin__string_capitalize(string s); | ||
| 2996 | +string builtin__string_uncapitalize(string s); | ||
| 2997 | +bool builtin__string_is_capital(string s); | ||
| 2998 | +bool builtin__string_starts_with_capital(string s); | ||
| 2999 | +string builtin__string_title(string s); | ||
| 3000 | +bool builtin__string_is_title(string s); | ||
| 3001 | +string builtin__string_find_between(string s, string start, string end); | ||
| 3002 | +string builtin__string_trim_space(string s); | ||
| 3003 | +string builtin__string_trim_space_left(string s); | ||
| 3004 | +string builtin__string_trim_space_right(string s); | ||
| 3005 | +string builtin__string_trim(string s, string cutset); | ||
| 3006 | +multi_return_int_int builtin__string_trim_indexes(string s, string cutset); | ||
| 3007 | +VV_LOC string builtin__string_trim_chars(string s, string cutset, TrimMode mode); | ||
| 3008 | +VV_LOC string builtin__string_trim_runes(string s, string cutset, TrimMode mode); | ||
| 3009 | +string builtin__string_trim_left(string s, string cutset); | ||
| 3010 | +string builtin__string_trim_right(string s, string cutset); | ||
| 3011 | +string builtin__string_trim_string_left(string s, string str); | ||
| 3012 | +string builtin__string_trim_string_right(string s, string str); | ||
| 3013 | +int builtin__compare_strings(string* a, string* b); | ||
| 3014 | +VV_LOC int builtin__compare_strings_by_len(string* a, string* b); | ||
| 3015 | +VV_LOC int builtin__compare_lower_strings(string* a, string* b); | ||
| 3016 | +void Array_string_sort_ignore_case(Array_string* s); | ||
| 3017 | +void Array_string_sort_by_len(Array_string* s); | ||
| 3018 | +string builtin__string_str(string s); | ||
| 3019 | +VV_LOC u8 builtin__string_at(string s, int idx); | ||
| 3020 | +VV_LOC u8 builtin__string_at_i64(string s, i64 idx); | ||
| 3021 | +VV_LOC u8 builtin__string_at_u64(string s, u64 idx); | ||
| 3022 | +VV_LOC u8 builtin__string_at_ni(string s, int idx); | ||
| 3023 | +VV_LOC _option_u8 builtin__string_at_with_check(string s, int idx); | ||
| 3024 | +VV_LOC _option_u8 builtin__string_at_with_check_i64(string s, i64 idx); | ||
| 3025 | +VV_LOC _option_u8 builtin__string_at_with_check_u64(string s, u64 idx); | ||
| 3026 | +VV_LOC _option_u8 builtin__string_at_with_check_ni(string s, int idx); | ||
| 3027 | +bool builtin__string_is_oct(string str); | ||
| 3028 | +bool builtin__string_is_bin(string str); | ||
| 3029 | +bool builtin__string_is_hex(string str); | ||
| 3030 | +bool builtin__string_is_int(string str); | ||
| 3031 | +bool builtin__u8_is_space(u8 c); | ||
| 3032 | +bool builtin__u8_is_digit(u8 c); | ||
| 3033 | +bool builtin__u8_is_hex_digit(u8 c); | ||
| 3034 | +bool builtin__u8_is_oct_digit(u8 c); | ||
| 3035 | +bool builtin__u8_is_bin_digit(u8 c); | ||
| 3036 | +bool builtin__u8_is_letter(u8 c); | ||
| 3037 | +bool builtin__u8_is_alnum(u8 c); | ||
| 3038 | +void builtin__string_free(string* s); | ||
| 3039 | +string builtin__string_before(string s, string sub); | ||
| 3040 | +string builtin__string_all_before(string s, string sub); | ||
| 3041 | +string builtin__string_all_before_last(string s, string sub); | ||
| 3042 | +string builtin__string_all_after(string s, string sub); | ||
| 3043 | +string builtin__string_all_after_last(string s, string sub); | ||
| 3044 | +string builtin__string_all_after_first(string s, string sub); | ||
| 3045 | +string builtin__string_after(string s, string sub); | ||
| 3046 | +string builtin__string_after_char(string s, u8 sub); | ||
| 3047 | +string Array_string_join(Array_string a, string sep); | ||
| 3048 | +string Array_string_join_lines(Array_string s); | ||
| 3049 | +string builtin__string_reverse(string s); | ||
| 3050 | +string builtin__string_limit(string s, int max); | ||
| 3051 | +int builtin__string_hash(string s); | ||
| 3052 | +Array_u8 builtin__string_bytes(string s); | ||
| 3053 | +string builtin__string_repeat(string s, int count); | ||
| 3054 | +Array_string builtin__string_fields(string s); | ||
| 3055 | +string builtin__string_strip_margin(string s); | ||
| 3056 | +string builtin__string_strip_margin_custom(string s, u8 del); | ||
| 3057 | +string builtin__string_trim_indent(string s); | ||
| 3058 | +int builtin__string_indent_width(string s); | ||
| 3059 | +bool builtin__string_is_blank(string s); | ||
| 3060 | +bool builtin__string_match_glob(string name, string pattern); | ||
| 3061 | +bool builtin__string_is_ascii(string s); | ||
| 3062 | +bool builtin__string_is_identifier(string s); | ||
| 3063 | +string builtin__string_camel_to_snake(string s); | ||
| 3064 | +string builtin__string_snake_to_camel(string s); | ||
| 3065 | +string builtin__string_wrap(string s, WrapConfig config); | ||
| 3066 | +string builtin__string_hex(string s); | ||
| 3067 | +VV_LOC string builtin__data_to_hex_string(u8* data, int len); | ||
| 3068 | +RunesIterator builtin__string_runes_iterator(string s); | ||
| 3069 | +_option_rune builtin__RunesIterator_next(RunesIterator* ri); | ||
| 3070 | +Array_u8 builtin__byteptr_vbytes(byteptr data, int len); | ||
| 3071 | +string builtin__byteptr_vstring(byteptr bp); | ||
| 3072 | +string builtin__byteptr_vstring_with_len(byteptr bp, int len); | ||
| 3073 | +string builtin__charptr_vstring(charptr cp); | ||
| 3074 | +string builtin__charptr_vstring_with_len(charptr cp, int len); | ||
| 3075 | +string builtin__byteptr_vstring_literal(byteptr bp); | ||
| 3076 | +string builtin__byteptr_vstring_literal_with_len(byteptr bp, int len); | ||
| 3077 | +string builtin__charptr_vstring_literal(charptr cp); | ||
| 3078 | +string builtin__charptr_vstring_literal_with_len(charptr cp, int len); | ||
| 3079 | +string builtin__StrIntpType_str(StrIntpType x); | ||
| 3080 | +VV_LOC f32 builtin__fabs32(f32 x); | ||
| 3081 | +VV_LOC f64 builtin__fabs64(f64 x); | ||
| 3082 | +VV_LOC u64 builtin__abs64(i64 x); | ||
| 3083 | +u64 builtin__get_str_intp_u64_format(StrIntpType fmt_type, int in_width, int in_precision, bool in_tail_zeros, bool in_sign, u8 in_pad_ch, int in_base, bool in_upper_case); | ||
| 3084 | +u32 builtin__get_str_intp_u32_format(StrIntpType fmt_type, int in_width, int in_precision, bool in_tail_zeros, bool in_sign, u8 in_pad_ch, int in_base, bool in_upper_case); | ||
| 3085 | +VV_LOC void builtin__StrIntpData_process_str_intp_data(StrIntpData* data, strings__Builder* sb); | ||
| 3086 | +string builtin__str_intp(int data_len, StrIntpData* input_base); | ||
| 3087 | +string builtin__str_intp_sq(string in_str); | ||
| 3088 | +string builtin__str_intp_rune(string in_str); | ||
| 3089 | +string builtin__str_intp_g32(string in_str); | ||
| 3090 | +string builtin__str_intp_g64(string in_str); | ||
| 3091 | +string builtin__str_intp_sub(string base_str, string in_str); | ||
| 3092 | +u16* builtin__string_to_wide(string _str, ToWideConfig param); | ||
| 3093 | +string builtin__string_from_wide(u16* _wstr); | ||
| 3094 | +string builtin__string_from_wide2(u16* _wstr, int len); | ||
| 3095 | +Array_u8 builtin__wide_to_ansi(u16* _wstr); | ||
| 3096 | +int builtin__utf8_char_len(u8 b); | ||
| 3097 | +string builtin__utf32_to_str(u32 code); | ||
| 3098 | +string builtin__utf32_to_str_no_malloc(u32 code, u8* buf); | ||
| 3099 | +int builtin__utf32_decode_to_buffer(u32 code, u8* buf); | ||
| 3100 | +int builtin__string_utf32_code(string _rune); | ||
| 3101 | +_result_rune Array_u8_utf8_to_utf32(Array_u8 _bytes); | ||
| 3102 | +VV_LOC bool builtin__utf8_is_continuation(u8 b); | ||
| 3103 | +VV_LOC multi_return_rune_int builtin__utf8_decode_rune(u8* _bytes, int available_len); | ||
| 3104 | +VV_LOC rune builtin__impl_utf8_to_utf32(u8* _bytes, int _bytes_len); | ||
| 3105 | +int builtin__utf8_str_visible_length(string s); | ||
| 3106 | +Array_u8 builtin__string_to_ansi_not_null_terminated(string _str); | ||
| 3107 | +bool builtin__ArrayFlags_is_empty(ArrayFlags* e); | ||
| 3108 | +bool builtin__ArrayFlags_has(ArrayFlags* e, ArrayFlags flag_); | ||
| 3109 | +bool builtin__ArrayFlags_all(ArrayFlags* e, ArrayFlags flag_); | ||
| 3110 | +void builtin__ArrayFlags_set(ArrayFlags* e, ArrayFlags flag_); | ||
| 3111 | +void builtin__ArrayFlags_set_all(ArrayFlags* e); | ||
| 3112 | +void builtin__ArrayFlags_clear(ArrayFlags* e, ArrayFlags flag_); | ||
| 3113 | +void builtin__ArrayFlags_clear_all(ArrayFlags* e); | ||
| 3114 | +void builtin__ArrayFlags_toggle(ArrayFlags* e, ArrayFlags flag_); | ||
| 3115 | +ArrayFlags builtin__ArrayFlags__static__zero(void); | ||
| 3116 | +VV_LOC void main__vf_init(void); | ||
| 3117 | +VV_EXP void vf_init(void); // exported fn main.vf_init | ||
| 3118 | +VV_LOC int main__vf_add(int a, int b); | ||
| 3119 | +VV_EXP int vf_add(int a, int b); // exported fn main.vf_add | ||
| 3120 | +VV_LOC char* main__vf_greet(char* name); | ||
| 3121 | +VV_EXP char* vf_greet(char* name); // exported fn main.vf_greet | ||
| 3122 | +VV_LOC void main__vf_free(voidptr p); | ||
| 3123 | +VV_EXP void vf_free(voidptr p); // exported fn main.vf_free | ||
| 3124 | +VV_LOC void main__main(void); | ||
| 3125 | +static bool Array_rune_arr_eq(Array_rune a, Array_rune b); | ||
| 3126 | +static bool builtin__closure__ClosureLifetimeState_struct_eq(builtin__closure__ClosureLifetimeState a, builtin__closure__ClosureLifetimeState b); | ||
| 3127 | +static bool Array_builtin__closure__ClosureLifetimeRecord_arr_eq(Array_builtin__closure__ClosureLifetimeRecord a, Array_builtin__closure__ClosureLifetimeRecord b); | ||
| 3128 | +static bool builtin__closure__ClosureLifetimeRecord_struct_eq(builtin__closure__ClosureLifetimeRecord a, builtin__closure__ClosureLifetimeRecord b); | ||
| 3129 | +static bool Array_builtin__closure__ClosureLifetimeFrame_arr_eq(Array_builtin__closure__ClosureLifetimeFrame a, Array_builtin__closure__ClosureLifetimeFrame b); | ||
| 3130 | +static bool builtin__closure__ClosureLifetimeFrame_struct_eq(builtin__closure__ClosureLifetimeFrame a, builtin__closure__ClosureLifetimeFrame b); | ||
| 3131 | + | ||
| 3132 | +// V global/const non-precomputed definitions: | ||
| 3133 | +static string _const_math__bits__overflow_error; // a string literal, inited later | ||
| 3134 | +static string _const_math__bits__divide_error; // a string literal, inited later | ||
| 3135 | +static string _const_strconv__digit_pairs; // a string literal, inited later | ||
| 3136 | +static string _const_strconv__base_digits; // a string literal, inited later | ||
| 3137 | +static string _const_grapheme_control_ranges; // a string literal, inited later | ||
| 3138 | +static string _const_grapheme_extend_ranges; // a string literal, inited later | ||
| 3139 | +static string _const_grapheme_spacing_mark_ranges; // a string literal, inited later | ||
| 3140 | +static string _const_grapheme_prepend_ranges; // a string literal, inited later | ||
| 3141 | +static string _const_grapheme_extended_pictographic_ranges; // a string literal, inited later | ||
| 3142 | +static string _const_digit_pairs; // a string literal, inited later | ||
| 3143 | +static string _const_si_s_code; // a string literal, inited later | ||
| 3144 | +static string _const_si_g32_code; // a string literal, inited later | ||
| 3145 | +static string _const_si_g64_code; // a string literal, inited later | ||
| 3146 | +builtin__closure__Closure g_closure; // global 6 | ||
| 3147 | + | ||
| 3148 | +static Array_fixed_u8_15 _const_builtin__closure__closure_thunk; // inited later | ||
| 3149 | +static Array_fixed_u8_6 _const_builtin__closure__closure_get_data_bytes; // inited later | ||
| 3150 | +static const u32 _const_math__bits__de_bruijn32 = 125613361; // precomputed2 | ||
| 3151 | +static Array_fixed_u8_32 _const_math__bits__de_bruijn32tab = {((u8)(0)), 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, | ||
| 3152 | +31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9}; // fixed array const | ||
| 3153 | +static const u64 _const_math__bits__de_bruijn64 = 285870213051353865U; // precomputed2 | ||
| 3154 | +static Array_fixed_u8_64 _const_math__bits__de_bruijn64tab = {((u8)(0)), 1, 56, 2, 57, 49, 28, 3, 61, 58, 42, 50, 38, 29, 17, 4, | ||
| 3155 | +62, 47, 59, 36, 45, 43, 51, 22, 53, 39, 33, 30, 24, 18, 12, 5, | ||
| 3156 | +63, 55, 48, 27, 60, 41, 37, 16, 46, 35, 44, 21, 52, 32, 23, 11, | ||
| 3157 | +54, 26, 40, 15, 34, 20, 31, 10, 25, 14, 19, 9, 13, 8, 7, 6}; // fixed array const | ||
| 3158 | +static const u64 _const_math__bits__m0 = 6148914691236517205U; // precomputed2 | ||
| 3159 | +static const u64 _const_math__bits__m1 = 3689348814741910323U; // precomputed2 | ||
| 3160 | +static const u64 _const_math__bits__m2 = 1085102592571150095U; // precomputed2 | ||
| 3161 | +static const u64 _const_math__bits__m3 = 71777214294589695U; // precomputed2 | ||
| 3162 | +static const u64 _const_math__bits__m4 = 281470681808895U; // precomputed2 | ||
| 3163 | +static const u8 _const_math__bits__n8 = 8; // precomputed2 | ||
| 3164 | +static const u16 _const_math__bits__n16 = 16; // precomputed2 | ||
| 3165 | +static const u32 _const_math__bits__n32 = 32; // precomputed2 | ||
| 3166 | +static const u64 _const_math__bits__n64 = 64U; // precomputed2 | ||
| 3167 | +static const u64 _const_math__bits__two32 = 4294967296U; // precomputed2 | ||
| 3168 | +static const u64 _const_math__bits__mask32 = 4294967295U; // precomputed2 | ||
| 3169 | +static Array_fixed_u8_256 _const_math__bits__ntz_8_tab = {((u8)(0x08)), 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3170 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3171 | +0x05, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3172 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3173 | +0x06, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3174 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3175 | +0x05, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3176 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3177 | +0x07, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3178 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3179 | +0x05, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3180 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3181 | +0x06, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3182 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3183 | +0x05, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
| 3184 | +0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00}; // fixed array const | ||
| 3185 | +static Array_fixed_u8_256 _const_math__bits__pop_8_tab = {((u8)(0x00)), 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, 0x03, 0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04, | ||
| 3186 | +0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04, 0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, | ||
| 3187 | +0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04, 0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, | ||
| 3188 | +0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, | ||
| 3189 | +0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04, 0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, | ||
| 3190 | +0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, | ||
| 3191 | +0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, | ||
| 3192 | +0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, 0x04, 0x05, 0x05, 0x06, 0x05, 0x06, 0x06, 0x07, | ||
| 3193 | +0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04, 0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, | ||
| 3194 | +0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, | ||
| 3195 | +0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, | ||
| 3196 | +0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, 0x04, 0x05, 0x05, 0x06, 0x05, 0x06, 0x06, 0x07, | ||
| 3197 | +0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, | ||
| 3198 | +0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, 0x04, 0x05, 0x05, 0x06, 0x05, 0x06, 0x06, 0x07, | ||
| 3199 | +0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, 0x04, 0x05, 0x05, 0x06, 0x05, 0x06, 0x06, 0x07, | ||
| 3200 | +0x04, 0x05, 0x05, 0x06, 0x05, 0x06, 0x06, 0x07, 0x05, 0x06, 0x06, 0x07, 0x06, 0x07, 0x07, 0x08}; // fixed array const | ||
| 3201 | +static Array_fixed_u8_256 _const_math__bits__rev_8_tab = {((u8)(0x00)), 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, | ||
| 3202 | +0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, | ||
| 3203 | +0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, | ||
| 3204 | +0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, | ||
| 3205 | +0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, | ||
| 3206 | +0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, | ||
| 3207 | +0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, | ||
| 3208 | +0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, | ||
| 3209 | +0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, | ||
| 3210 | +0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, | ||
| 3211 | +0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, | ||
| 3212 | +0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, | ||
| 3213 | +0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, | ||
| 3214 | +0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, | ||
| 3215 | +0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, | ||
| 3216 | +0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff}; // fixed array const | ||
| 3217 | +static Array_fixed_u8_256 _const_math__bits__len_8_tab = {((u8)(0x00)), 0x01, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, | ||
| 3218 | +0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, | ||
| 3219 | +0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, | ||
| 3220 | +0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, | ||
| 3221 | +0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, | ||
| 3222 | +0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, | ||
| 3223 | +0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, | ||
| 3224 | +0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, | ||
| 3225 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | ||
| 3226 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | ||
| 3227 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | ||
| 3228 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | ||
| 3229 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | ||
| 3230 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | ||
| 3231 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, | ||
| 3232 | +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08}; // fixed array const | ||
| 3233 | +static const u32 _const_strconv__single_plus_zero = 0; // precomputed2 | ||
| 3234 | +static const u32 _const_strconv__single_minus_zero = 2147483648; // precomputed2 | ||
| 3235 | +static const u32 _const_strconv__single_plus_infinity = 2139095040; // precomputed2 | ||
| 3236 | +static const u32 _const_strconv__single_minus_infinity = 4286578688; // precomputed2 | ||
| 3237 | +static const u64 _const_strconv__double_plus_zero = 0U; // precomputed2 | ||
| 3238 | +static const u64 _const_strconv__double_minus_zero = 9223372036854775808U; // precomputed2 | ||
| 3239 | +static const u64 _const_strconv__double_plus_infinity = 9218868437227405312U; // precomputed2 | ||
| 3240 | +static const u64 _const_strconv__double_minus_infinity = 18442240474082181120U; // precomputed2 | ||
| 3241 | +static const u32 _const_strconv__c_ten = 10; // precomputed2 | ||
| 3242 | +static Array_fixed_u64_309 _const_strconv__pos_exp = {((u64)(0x3ff0000000000000LL)), ((u64)(0x4024000000000000LL)), ((u64)(0x4059000000000000LL)), ((u64)(0x408f400000000000LL)), ((u64)(0x40c3880000000000LL)), ((u64)(0x40f86a0000000000LL)), ((u64)(0x412e848000000000LL)), ((u64)(0x416312d000000000LL)), ((u64)(0x4197d78400000000LL)), ((u64)(0x41cdcd6500000000LL)), ((u64)(0x4202a05f20000000LL)), ((u64)(0x42374876e8000000LL)), ((u64)(0x426d1a94a2000000LL)), ((u64)(0x42a2309ce5400000LL)), ((u64)(0x42d6bcc41e900000LL)), ((u64)(0x430c6bf526340000LL)), | ||
| 3243 | +((u64)(0x4341c37937e08000LL)), ((u64)(0x4376345785d8a000LL)), ((u64)(0x43abc16d674ec800LL)), ((u64)(0x43e158e460913d00LL)), ((u64)(0x4415af1d78b58c40LL)), ((u64)(0x444b1ae4d6e2ef50LL)), ((u64)(0x4480f0cf064dd592LL)), ((u64)(0x44b52d02c7e14af6LL)), ((u64)(0x44ea784379d99db4LL)), ((u64)(0x45208b2a2c280291LL)), ((u64)(0x4554adf4b7320335LL)), ((u64)(0x4589d971e4fe8402LL)), ((u64)(0x45c027e72f1f1281LL)), ((u64)(0x45f431e0fae6d721LL)), ((u64)(0x46293e5939a08ceaLL)), ((u64)(0x465f8def8808b024LL)), | ||
| 3244 | +((u64)(0x4693b8b5b5056e17LL)), ((u64)(0x46c8a6e32246c99cLL)), ((u64)(0x46fed09bead87c03LL)), ((u64)(0x4733426172c74d82LL)), ((u64)(0x476812f9cf7920e3LL)), ((u64)(0x479e17b84357691bLL)), ((u64)(0x47d2ced32a16a1b1LL)), ((u64)(0x48078287f49c4a1dLL)), ((u64)(0x483d6329f1c35ca5LL)), ((u64)(0x48725dfa371a19e7LL)), ((u64)(0x48a6f578c4e0a061LL)), ((u64)(0x48dcb2d6f618c879LL)), ((u64)(0x4911efc659cf7d4cLL)), ((u64)(0x49466bb7f0435c9eLL)), ((u64)(0x497c06a5ec5433c6LL)), ((u64)(0x49b18427b3b4a05cLL)), | ||
| 3245 | +((u64)(0x49e5e531a0a1c873LL)), ((u64)(0x4a1b5e7e08ca3a8fLL)), ((u64)(0x4a511b0ec57e649aLL)), ((u64)(0x4a8561d276ddfdc0LL)), ((u64)(0x4ababa4714957d30LL)), ((u64)(0x4af0b46c6cdd6e3eLL)), ((u64)(0x4b24e1878814c9ceLL)), ((u64)(0x4b5a19e96a19fc41LL)), ((u64)(0x4b905031e2503da9LL)), ((u64)(0x4bc4643e5ae44d13LL)), ((u64)(0x4bf97d4df19d6057LL)), ((u64)(0x4c2fdca16e04b86dLL)), ((u64)(0x4c63e9e4e4c2f344LL)), ((u64)(0x4c98e45e1df3b015LL)), ((u64)(0x4ccf1d75a5709c1bLL)), ((u64)(0x4d03726987666191LL)), | ||
| 3246 | +((u64)(0x4d384f03e93ff9f5LL)), ((u64)(0x4d6e62c4e38ff872LL)), ((u64)(0x4da2fdbb0e39fb47LL)), ((u64)(0x4dd7bd29d1c87a19LL)), ((u64)(0x4e0dac74463a989fLL)), ((u64)(0x4e428bc8abe49f64LL)), ((u64)(0x4e772ebad6ddc73dLL)), ((u64)(0x4eacfa698c95390cLL)), ((u64)(0x4ee21c81f7dd43a7LL)), ((u64)(0x4f16a3a275d49491LL)), ((u64)(0x4f4c4c8b1349b9b5LL)), ((u64)(0x4f81afd6ec0e1411LL)), ((u64)(0x4fb61bcca7119916LL)), ((u64)(0x4feba2bfd0d5ff5bLL)), ((u64)(0x502145b7e285bf99LL)), ((u64)(0x50559725db272f7fLL)), | ||
| 3247 | +((u64)(0x508afcef51f0fb5fLL)), ((u64)(0x50c0de1593369d1bLL)), ((u64)(0x50f5159af8044462LL)), ((u64)(0x512a5b01b605557bLL)), ((u64)(0x516078e111c3556dLL)), ((u64)(0x5194971956342ac8LL)), ((u64)(0x51c9bcdfabc1357aLL)), ((u64)(0x5200160bcb58c16cLL)), ((u64)(0x52341b8ebe2ef1c7LL)), ((u64)(0x526922726dbaae39LL)), ((u64)(0x529f6b0f092959c7LL)), ((u64)(0x52d3a2e965b9d81dLL)), ((u64)(0x53088ba3bf284e24LL)), ((u64)(0x533eae8caef261adLL)), ((u64)(0x53732d17ed577d0cLL)), ((u64)(0x53a7f85de8ad5c4fLL)), | ||
| 3248 | +((u64)(0x53ddf67562d8b363LL)), ((u64)(0x5412ba095dc7701eLL)), ((u64)(0x5447688bb5394c25LL)), ((u64)(0x547d42aea2879f2eLL)), ((u64)(0x54b249ad2594c37dLL)), ((u64)(0x54e6dc186ef9f45cLL)), ((u64)(0x551c931e8ab87173LL)), ((u64)(0x5551dbf316b346e8LL)), ((u64)(0x558652efdc6018a2LL)), ((u64)(0x55bbe7abd3781ecaLL)), ((u64)(0x55f170cb642b133fLL)), ((u64)(0x5625ccfe3d35d80eLL)), ((u64)(0x565b403dcc834e12LL)), ((u64)(0x569108269fd210cbLL)), ((u64)(0x56c54a3047c694feLL)), ((u64)(0x56fa9cbc59b83a3dLL)), | ||
| 3249 | +((u64)(0x5730a1f5b8132466LL)), ((u64)(0x5764ca732617ed80LL)), ((u64)(0x5799fd0fef9de8e0LL)), ((u64)(0x57d03e29f5c2b18cLL)), ((u64)(0x58044db473335defLL)), ((u64)(0x583961219000356bLL)), ((u64)(0x586fb969f40042c5LL)), ((u64)(0x58a3d3e2388029bbLL)), ((u64)(0x58d8c8dac6a0342aLL)), ((u64)(0x590efb1178484135LL)), ((u64)(0x59435ceaeb2d28c1LL)), ((u64)(0x59783425a5f872f1LL)), ((u64)(0x59ae412f0f768fadLL)), ((u64)(0x59e2e8bd69aa19ccLL)), ((u64)(0x5a17a2ecc414a03fLL)), ((u64)(0x5a4d8ba7f519c84fLL)), | ||
| 3250 | +((u64)(0x5a827748f9301d32LL)), ((u64)(0x5ab7151b377c247eLL)), ((u64)(0x5aecda62055b2d9eLL)), ((u64)(0x5b22087d4358fc82LL)), ((u64)(0x5b568a9c942f3ba3LL)), ((u64)(0x5b8c2d43b93b0a8cLL)), ((u64)(0x5bc19c4a53c4e697LL)), ((u64)(0x5bf6035ce8b6203dLL)), ((u64)(0x5c2b843422e3a84dLL)), ((u64)(0x5c6132a095ce4930LL)), ((u64)(0x5c957f48bb41db7cLL)), ((u64)(0x5ccadf1aea12525bLL)), ((u64)(0x5d00cb70d24b7379LL)), ((u64)(0x5d34fe4d06de5057LL)), ((u64)(0x5d6a3de04895e46dLL)), ((u64)(0x5da066ac2d5daec4LL)), | ||
| 3251 | +((u64)(0x5dd4805738b51a75LL)), ((u64)(0x5e09a06d06e26112LL)), ((u64)(0x5e400444244d7cabLL)), ((u64)(0x5e7405552d60dbd6LL)), ((u64)(0x5ea906aa78b912ccLL)), ((u64)(0x5edf485516e7577fLL)), ((u64)(0x5f138d352e5096afLL)), ((u64)(0x5f48708279e4bc5bLL)), ((u64)(0x5f7e8ca3185deb72LL)), ((u64)(0x5fb317e5ef3ab327LL)), ((u64)(0x5fe7dddf6b095ff1LL)), ((u64)(0x601dd55745cbb7edLL)), ((u64)(0x6052a5568b9f52f4LL)), ((u64)(0x60874eac2e8727b1LL)), ((u64)(0x60bd22573a28f19dLL)), ((u64)(0x60f2357684599702LL)), | ||
| 3252 | +((u64)(0x6126c2d4256ffcc3LL)), ((u64)(0x615c73892ecbfbf4LL)), ((u64)(0x6191c835bd3f7d78LL)), ((u64)(0x61c63a432c8f5cd6LL)), ((u64)(0x61fbc8d3f7b3340cLL)), ((u64)(0x62315d847ad00087LL)), ((u64)(0x6265b4e5998400a9LL)), ((u64)(0x629b221effe500d4LL)), ((u64)(0x62d0f5535fef2084LL)), ((u64)(0x630532a837eae8a5LL)), ((u64)(0x633a7f5245e5a2cfLL)), ((u64)(0x63708f936baf85c1LL)), ((u64)(0x63a4b378469b6732LL)), ((u64)(0x63d9e056584240feLL)), ((u64)(0x64102c35f729689fLL)), ((u64)(0x6444374374f3c2c6LL)), | ||
| 3253 | +((u64)(0x647945145230b378LL)), ((u64)(0x64af965966bce056LL)), ((u64)(0x64e3bdf7e0360c36LL)), ((u64)(0x6518ad75d8438f43LL)), ((u64)(0x654ed8d34e547314LL)), ((u64)(0x6583478410f4c7ecLL)), ((u64)(0x65b819651531f9e8LL)), ((u64)(0x65ee1fbe5a7e7861LL)), ((u64)(0x6622d3d6f88f0b3dLL)), ((u64)(0x665788ccb6b2ce0cLL)), ((u64)(0x668d6affe45f818fLL)), ((u64)(0x66c262dfeebbb0f9LL)), ((u64)(0x66f6fb97ea6a9d38LL)), ((u64)(0x672cba7de5054486LL)), ((u64)(0x6761f48eaf234ad4LL)), ((u64)(0x679671b25aec1d89LL)), | ||
| 3254 | +((u64)(0x67cc0e1ef1a724ebLL)), ((u64)(0x680188d357087713LL)), ((u64)(0x6835eb082cca94d7LL)), ((u64)(0x686b65ca37fd3a0dLL)), ((u64)(0x68a11f9e62fe4448LL)), ((u64)(0x68d56785fbbdd55aLL)), ((u64)(0x690ac1677aad4ab1LL)), ((u64)(0x6940b8e0acac4eafLL)), ((u64)(0x6974e718d7d7625aLL)), ((u64)(0x69aa20df0dcd3af1LL)), ((u64)(0x69e0548b68a044d6LL)), ((u64)(0x6a1469ae42c8560cLL)), ((u64)(0x6a498419d37a6b8fLL)), ((u64)(0x6a7fe52048590673LL)), ((u64)(0x6ab3ef342d37a408LL)), ((u64)(0x6ae8eb0138858d0aLL)), | ||
| 3255 | +((u64)(0x6b1f25c186a6f04cLL)), ((u64)(0x6b537798f4285630LL)), ((u64)(0x6b88557f31326bbbLL)), ((u64)(0x6bbe6adefd7f06aaLL)), ((u64)(0x6bf302cb5e6f642aLL)), ((u64)(0x6c27c37e360b3d35LL)), ((u64)(0x6c5db45dc38e0c82LL)), ((u64)(0x6c9290ba9a38c7d1LL)), ((u64)(0x6cc734e940c6f9c6LL)), ((u64)(0x6cfd022390f8b837LL)), ((u64)(0x6d3221563a9b7323LL)), ((u64)(0x6d66a9abc9424febLL)), ((u64)(0x6d9c5416bb92e3e6LL)), ((u64)(0x6dd1b48e353bce70LL)), ((u64)(0x6e0621b1c28ac20cLL)), ((u64)(0x6e3baa1e332d728fLL)), | ||
| 3256 | +((u64)(0x6e714a52dffc6799LL)), ((u64)(0x6ea59ce797fb817fLL)), ((u64)(0x6edb04217dfa61dfLL)), ((u64)(0x6f10e294eebc7d2cLL)), ((u64)(0x6f451b3a2a6b9c76LL)), ((u64)(0x6f7a6208b5068394LL)), ((u64)(0x6fb07d457124123dLL)), ((u64)(0x6fe49c96cd6d16ccLL)), ((u64)(0x7019c3bc80c85c7fLL)), ((u64)(0x70501a55d07d39cfLL)), ((u64)(0x708420eb449c8843LL)), ((u64)(0x70b9292615c3aa54LL)), ((u64)(0x70ef736f9b3494e9LL)), ((u64)(0x7123a825c100dd11LL)), ((u64)(0x7158922f31411456LL)), ((u64)(0x718eb6bafd91596bLL)), | ||
| 3257 | +((u64)(0x71c33234de7ad7e3LL)), ((u64)(0x71f7fec216198ddcLL)), ((u64)(0x722dfe729b9ff153LL)), ((u64)(0x7262bf07a143f6d4LL)), ((u64)(0x72976ec98994f489LL)), ((u64)(0x72cd4a7bebfa31abLL)), ((u64)(0x73024e8d737c5f0bLL)), ((u64)(0x7336e230d05b76cdLL)), ((u64)(0x736c9abd04725481LL)), ((u64)(0x73a1e0b622c774d0LL)), ((u64)(0x73d658e3ab795204LL)), ((u64)(0x740bef1c9657a686LL)), ((u64)(0x74417571ddf6c814LL)), ((u64)(0x7475d2ce55747a18LL)), ((u64)(0x74ab4781ead1989eLL)), ((u64)(0x74e10cb132c2ff63LL)), | ||
| 3258 | +((u64)(0x75154fdd7f73bf3cLL)), ((u64)(0x754aa3d4df50af0bLL)), ((u64)(0x7580a6650b926d67LL)), ((u64)(0x75b4cffe4e7708c0LL)), ((u64)(0x75ea03fde214caf1LL)), ((u64)(0x7620427ead4cfed6LL)), ((u64)(0x7654531e58a03e8cLL)), ((u64)(0x768967e5eec84e2fLL)), ((u64)(0x76bfc1df6a7a61bbLL)), ((u64)(0x76f3d92ba28c7d15LL)), ((u64)(0x7728cf768b2f9c5aLL)), ((u64)(0x775f03542dfb8370LL)), ((u64)(0x779362149cbd3226LL)), ((u64)(0x77c83a99c3ec7eb0LL)), ((u64)(0x77fe494034e79e5cLL)), ((u64)(0x7832edc82110c2f9LL)), | ||
| 3259 | +((u64)(0x7867a93a2954f3b8LL)), ((u64)(0x789d9388b3aa30a5LL)), ((u64)(0x78d27c35704a5e67LL)), ((u64)(0x79071b42cc5cf601LL)), ((u64)(0x793ce2137f743382LL)), ((u64)(0x79720d4c2fa8a031LL)), ((u64)(0x79a6909f3b92c83dLL)), ((u64)(0x79dc34c70a777a4dLL)), ((u64)(0x7a11a0fc668aac70LL)), ((u64)(0x7a46093b802d578cLL)), ((u64)(0x7a7b8b8a6038ad6fLL)), ((u64)(0x7ab137367c236c65LL)), ((u64)(0x7ae585041b2c477fLL)), ((u64)(0x7b1ae64521f7595eLL)), ((u64)(0x7b50cfeb353a97dbLL)), ((u64)(0x7b8503e602893dd2LL)), | ||
| 3260 | +((u64)(0x7bba44df832b8d46LL)), ((u64)(0x7bf06b0bb1fb384cLL)), ((u64)(0x7c2485ce9e7a065fLL)), ((u64)(0x7c59a742461887f6LL)), ((u64)(0x7c9008896bcf54faLL)), ((u64)(0x7cc40aabc6c32a38LL)), ((u64)(0x7cf90d56b873f4c7LL)), ((u64)(0x7d2f50ac6690f1f8LL)), ((u64)(0x7d63926bc01a973bLL)), ((u64)(0x7d987706b0213d0aLL)), ((u64)(0x7dce94c85c298c4cLL)), ((u64)(0x7e031cfd3999f7b0LL)), ((u64)(0x7e37e43c8800759cLL)), ((u64)(0x7e6ddd4baa009303LL)), ((u64)(0x7ea2aa4f4a405be2LL)), ((u64)(0x7ed754e31cd072daLL)), ((u64)(0x7f0d2a1be4048f90LL)), ((u64)(0x7f423a516e82d9baLL)), ((u64)(0x7f76c8e5ca239029LL)), ((u64)(0x7fac7b1f3cac7433LL)), ((u64)(0x7fe1ccf385ebc8a0LL))}; // fixed array const | ||
| 3261 | +static Array_fixed_u64_324 _const_strconv__neg_exp = {((u64)(0x3ff0000000000000LL)), ((u64)(0x3fb999999999999aLL)), ((u64)(0x3f847ae147ae147bLL)), ((u64)(0x3f50624dd2f1a9fcLL)), ((u64)(0x3f1a36e2eb1c432dLL)), ((u64)(0x3ee4f8b588e368f1LL)), ((u64)(0x3eb0c6f7a0b5ed8dLL)), ((u64)(0x3e7ad7f29abcaf48LL)), ((u64)(0x3e45798ee2308c3aLL)), ((u64)(0x3e112e0be826d695LL)), ((u64)(0x3ddb7cdfd9d7bdbbLL)), ((u64)(0x3da5fd7fe1796495LL)), ((u64)(0x3d719799812dea11LL)), ((u64)(0x3d3c25c268497682LL)), ((u64)(0x3d06849b86a12b9bLL)), ((u64)(0x3cd203af9ee75616LL)), | ||
| 3262 | +((u64)(0x3c9cd2b297d889bcLL)), ((u64)(0x3c670ef54646d497LL)), ((u64)(0x3c32725dd1d243acLL)), ((u64)(0x3bfd83c94fb6d2acLL)), ((u64)(0x3bc79ca10c924223LL)), ((u64)(0x3b92e3b40a0e9b4fLL)), ((u64)(0x3b5e392010175ee6LL)), ((u64)(0x3b282db34012b251LL)), ((u64)(0x3af357c299a88ea7LL)), ((u64)(0x3abef2d0f5da7dd9LL)), ((u64)(0x3a88c240c4aecb14LL)), ((u64)(0x3a53ce9a36f23c10LL)), ((u64)(0x3a1fb0f6be506019LL)), ((u64)(0x39e95a5efea6b347LL)), ((u64)(0x39b4484bfeebc2a0LL)), ((u64)(0x398039d665896880LL)), | ||
| 3263 | +((u64)(0x3949f623d5a8a733LL)), ((u64)(0x3914c4e977ba1f5cLL)), ((u64)(0x38e09d8792fb4c49LL)), ((u64)(0x38aa95a5b7f87a0fLL)), ((u64)(0x38754484932d2e72LL)), ((u64)(0x3841039d428a8b8fLL)), ((u64)(0x380b38fb9daa78e4LL)), ((u64)(0x37d5c72fb1552d83LL)), ((u64)(0x37a16c262777579cLL)), ((u64)(0x376be03d0bf225c7LL)), ((u64)(0x37364cfda3281e39LL)), ((u64)(0x3701d7314f534b61LL)), ((u64)(0x36cc8b8218854567LL)), ((u64)(0x3696d601ad376ab9LL)), ((u64)(0x366244ce242c5561LL)), ((u64)(0x362d3ae36d13bbceLL)), | ||
| 3264 | +((u64)(0x35f7624f8a762fd8LL)), ((u64)(0x35c2b50c6ec4f313LL)), ((u64)(0x358dee7a4ad4b81fLL)), ((u64)(0x3557f1fb6f10934cLL)), ((u64)(0x352327fc58da0f70LL)), ((u64)(0x34eea6608e29b24dLL)), ((u64)(0x34b8851a0b548ea4LL)), ((u64)(0x34839dae6f76d883LL)), ((u64)(0x344f62b0b257c0d2LL)), ((u64)(0x34191bc08eac9a41LL)), ((u64)(0x33e41633a556e1ceLL)), ((u64)(0x33b011c2eaabe7d8LL)), ((u64)(0x3379b604aaaca626LL)), ((u64)(0x3344919d5556eb52LL)), ((u64)(0x3310747ddddf22a8LL)), ((u64)(0x32da53fc9631d10dLL)), | ||
| 3265 | +((u64)(0x32a50ffd44f4a73dLL)), ((u64)(0x3270d9976a5d5297LL)), ((u64)(0x323af5bf109550f2LL)), ((u64)(0x32059165a6ddda5bLL)), ((u64)(0x31d1411e1f17e1e3LL)), ((u64)(0x319b9b6364f30304LL)), ((u64)(0x316615e91d8f359dLL)), ((u64)(0x3131ab20e472914aLL)), ((u64)(0x30fc45016d841baaLL)), ((u64)(0x30c69d9abe034955LL)), ((u64)(0x309217aefe690777LL)), ((u64)(0x305cf2b1970e7258LL)), ((u64)(0x3027288e1271f513LL)), ((u64)(0x2ff286d80ec190dcLL)), ((u64)(0x2fbda48ce468e7c7LL)), ((u64)(0x2f87b6d71d20b96cLL)), | ||
| 3266 | +((u64)(0x2f52f8ac174d6123LL)), ((u64)(0x2f1e5aacf2156838LL)), ((u64)(0x2ee8488a5b445360LL)), ((u64)(0x2eb36d3b7c36a91aLL)), ((u64)(0x2e7f152bf9f10e90LL)), ((u64)(0x2e48ddbcc7f40ba6LL)), ((u64)(0x2e13e497065cd61fLL)), ((u64)(0x2ddfd424d6faf031LL)), ((u64)(0x2da97683df2f268dLL)), ((u64)(0x2d745ecfe5bf520bLL)), ((u64)(0x2d404bd984990e6fLL)), ((u64)(0x2d0a12f5a0f4e3e5LL)), ((u64)(0x2cd4dbf7b3f71cb7LL)), ((u64)(0x2ca0aff95cc5b092LL)), ((u64)(0x2c6ab328946f80eaLL)), ((u64)(0x2c355c2076bf9a55LL)), | ||
| 3267 | +((u64)(0x2c0116805effaeaaLL)), ((u64)(0x2bcb5733cb32b111LL)), ((u64)(0x2b95df5ca28ef40dLL)), ((u64)(0x2b617f7d4ed8c33eLL)), ((u64)(0x2b2bff2ee48e0530LL)), ((u64)(0x2af665bf1d3e6a8dLL)), ((u64)(0x2ac1eaff4a98553dLL)), ((u64)(0x2a8cab3210f3bb95LL)), ((u64)(0x2a56ef5b40c2fc77LL)), ((u64)(0x2a225915cd68c9f9LL)), ((u64)(0x29ed5b561574765bLL)), ((u64)(0x29b77c44ddf6c516LL)), ((u64)(0x2982c9d0b1923745LL)), ((u64)(0x294e0fb44f50586eLL)), ((u64)(0x29180c903f7379f2LL)), ((u64)(0x28e33d4032c2c7f5LL)), | ||
| 3268 | +((u64)(0x28aec866b79e0cbaLL)), ((u64)(0x2878a0522c7e7095LL)), ((u64)(0x2843b374f06526deLL)), ((u64)(0x280f8587e7083e30LL)), ((u64)(0x27d9379fec069826LL)), ((u64)(0x27a42c7ff0054685LL)), ((u64)(0x277023998cd10537LL)), ((u64)(0x2739d28f47b4d525LL)), ((u64)(0x2704a8729fc3ddb7LL)), ((u64)(0x26d086c219697e2cLL)), ((u64)(0x269a71368f0f3047LL)), ((u64)(0x2665275ed8d8f36cLL)), ((u64)(0x2630ec4be0ad8f89LL)), ((u64)(0x25fb13ac9aaf4c0fLL)), ((u64)(0x25c5a956e225d672LL)), ((u64)(0x2591544581b7dec2LL)), | ||
| 3269 | +((u64)(0x255bba08cf8c979dLL)), ((u64)(0x25262e6d72d6dfb0LL)), ((u64)(0x24f1bebdf578b2f4LL)), ((u64)(0x24bc6463225ab7ecLL)), ((u64)(0x2486b6b5b5155ff0LL)), ((u64)(0x24522bc490dde65aLL)), ((u64)(0x241d12d41afca3c3LL)), ((u64)(0x23e7424348ca1c9cLL)), ((u64)(0x23b29b69070816e3LL)), ((u64)(0x237dc574d80cf16bLL)), ((u64)(0x2347d12a4670c123LL)), ((u64)(0x23130dbb6b8d674fLL)), ((u64)(0x22de7c5f127bd87eLL)), ((u64)(0x22a8637f41fcad32LL)), ((u64)(0x227382cc34ca2428LL)), ((u64)(0x223f37ad21436d0cLL)), | ||
| 3270 | +((u64)(0x2208f9574dcf8a70LL)), ((u64)(0x21d3faac3e3fa1f3LL)), ((u64)(0x219ff779fd329cb9LL)), ((u64)(0x216992c7fdc216faLL)), ((u64)(0x2134756ccb01abfbLL)), ((u64)(0x21005df0a267bcc9LL)), ((u64)(0x20ca2fe76a3f9475LL)), ((u64)(0x2094f31f8832dd2aLL)), ((u64)(0x2060c27fa028b0efLL)), ((u64)(0x202ad0cc33744e4bLL)), ((u64)(0x1ff573d68f903ea2LL)), ((u64)(0x1fc1297872d9cbb5LL)), ((u64)(0x1f8b758d848fac55LL)), ((u64)(0x1f55f7a46a0c89ddLL)), ((u64)(0x1f2192e9ee706e4bLL)), ((u64)(0x1eec1e43171a4a11LL)), | ||
| 3271 | +((u64)(0x1eb67e9c127b6e74LL)), ((u64)(0x1e81fee341fc585dLL)), ((u64)(0x1e4ccb0536608d61LL)), ((u64)(0x1e1708d0f84d3de7LL)), ((u64)(0x1de26d73f9d764b9LL)), ((u64)(0x1dad7becc2f23ac2LL)), ((u64)(0x1d779657025b6235LL)), ((u64)(0x1d42deac01e2b4f7LL)), ((u64)(0x1d0e3113363787f2LL)), ((u64)(0x1cd8274291c6065bLL)), ((u64)(0x1ca3529ba7d19eafLL)), ((u64)(0x1c6eea92a61c3118LL)), ((u64)(0x1c38bba884e35a7aLL)), ((u64)(0x1c03c9539d82aec8LL)), ((u64)(0x1bcfa885c8d117a6LL)), ((u64)(0x1b99539e3a40dfb8LL)), | ||
| 3272 | +((u64)(0x1b6442e4fb671960LL)), ((u64)(0x1b303583fc527ab3LL)), ((u64)(0x1af9ef3993b72ab8LL)), ((u64)(0x1ac4bf6142f8eefaLL)), ((u64)(0x1a90991a9bfa58c8LL)), ((u64)(0x1a5a8e90f9908e0dLL)), ((u64)(0x1a253eda614071a4LL)), ((u64)(0x19f0ff151a99f483LL)), ((u64)(0x19bb31bb5dc320d2LL)), ((u64)(0x1985c162b168e70eLL)), ((u64)(0x1951678227871f3eLL)), ((u64)(0x191bd8d03f3e9864LL)), ((u64)(0x18e6470cff6546b6LL)), ((u64)(0x18b1d270cc51055fLL)), ((u64)(0x187c83e7ad4e6efeLL)), ((u64)(0x1846cfec8aa52598LL)), | ||
| 3273 | +((u64)(0x18123ff06eea847aLL)), ((u64)(0x17dd331a4b10d3f6LL)), ((u64)(0x17a75c1508da432bLL)), ((u64)(0x1772b010d3e1cf56LL)), ((u64)(0x173de6815302e556LL)), ((u64)(0x1707eb9aa8cf1ddeLL)), ((u64)(0x16d322e220a5b17eLL)), ((u64)(0x169e9e369aa2b597LL)), ((u64)(0x16687e92154ef7acLL)), ((u64)(0x16339874ddd8c623LL)), ((u64)(0x15ff5a549627a36cLL)), ((u64)(0x15c91510781fb5f0LL)), ((u64)(0x159410d9f9b2f7f3LL)), ((u64)(0x15600d7b2e28c65cLL)), ((u64)(0x1529af2b7d0e0a2dLL)), ((u64)(0x14f48c22ca71a1bdLL)), | ||
| 3274 | +((u64)(0x14c0701bd527b498LL)), ((u64)(0x148a4cf9550c5426LL)), ((u64)(0x14550a6110d6a9b8LL)), ((u64)(0x1420d51a73deee2dLL)), ((u64)(0x13eaee90b964b047LL)), ((u64)(0x13b58ba6fab6f36cLL)), ((u64)(0x13813c85955f2923LL)), ((u64)(0x134b9408eefea839LL)), ((u64)(0x1316100725988694LL)), ((u64)(0x12e1a66c1e139eddLL)), ((u64)(0x12ac3d79c9b8fe2eLL)), ((u64)(0x12769794a160cb58LL)), ((u64)(0x124212dd4de70913LL)), ((u64)(0x120ceafbafd80e85LL)), ((u64)(0x11d72262f3133ed1LL)), ((u64)(0x11a281e8c275cbdaLL)), | ||
| 3275 | +((u64)(0x116d9ca79d89462aLL)), ((u64)(0x1137b08617a104eeLL)), ((u64)(0x1102f39e794d9d8bLL)), ((u64)(0x10ce5297287c2f45LL)), ((u64)(0x1098421286c9bf6bLL)), ((u64)(0x1063680ed23aff89LL)), ((u64)(0x102f0ce4839198dbLL)), ((u64)(0x0ff8d71d360e13e2LL)), ((u64)(0x0fc3df4a91a4dcb5LL)), ((u64)(0x0f8fcbaa82a16121LL)), ((u64)(0x0f596fbb9bb44db4LL)), ((u64)(0x0f245962e2f6a490LL)), ((u64)(0x0ef047824f2bb6daLL)), ((u64)(0x0eba0c03b1df8af6LL)), ((u64)(0x0e84d6695b193bf8LL)), ((u64)(0x0e50ab877c142ffaLL)), | ||
| 3276 | +((u64)(0x0e1aac0bf9b9e65cLL)), ((u64)(0x0de5566ffafb1eb0LL)), ((u64)(0x0db111f32f2f4bc0LL)), ((u64)(0x0d7b4feb7eb212cdLL)), ((u64)(0x0d45d98932280f0aLL)), ((u64)(0x0d117ad428200c08LL)), ((u64)(0x0cdbf7b9d9cce00dLL)), ((u64)(0x0ca65fc7e170b33eLL)), ((u64)(0x0c71e6398126f5cbLL)), ((u64)(0x0c3ca38f350b22dfLL)), ((u64)(0x0c06e93f5da2824cLL)), ((u64)(0x0bd25432b14ecea3LL)), ((u64)(0x0b9d53844ee47dd1LL)), ((u64)(0x0b677603725064a8LL)), ((u64)(0x0b32c4cf8ea6b6ecLL)), ((u64)(0x0afe07b27dd78b14LL)), | ||
| 3277 | +((u64)(0x0ac8062864ac6f43LL)), ((u64)(0x0a9338205089f29cLL)), ((u64)(0x0a5ec033b40fea93LL)), ((u64)(0x0a2899c2f6732210LL)), ((u64)(0x09f3ae3591f5b4d9LL)), ((u64)(0x09bf7d228322baf5LL)), ((u64)(0x098930e868e89591LL)), ((u64)(0x0954272053ed4474LL)), ((u64)(0x09201f4d0ff10390LL)), ((u64)(0x08e9cbae7fe805b3LL)), ((u64)(0x08b4a2f1ffecd15cLL)), ((u64)(0x0880825b3323dab0LL)), ((u64)(0x084a6a2b85062ab3LL)), ((u64)(0x081521bc6a6b555cLL)), ((u64)(0x07e0e7c9eebc444aLL)), ((u64)(0x07ab0c764ac6d3a9LL)), | ||
| 3278 | +((u64)(0x0775a391d56bdc87LL)), ((u64)(0x07414fa7ddefe3a0LL)), ((u64)(0x070bb2a62fe638ffLL)), ((u64)(0x06d62884f31e93ffLL)), ((u64)(0x06a1ba03f5b21000LL)), ((u64)(0x066c5cd322b67fffLL)), ((u64)(0x0636b0a8e891ffffLL)), ((u64)(0x060226ed86db3333LL)), ((u64)(0x05cd0b15a491eb84LL)), ((u64)(0x05973c115074bc6aLL)), ((u64)(0x05629674405d6388LL)), ((u64)(0x052dbd86cd6238d9LL)), ((u64)(0x04f7cad23de82d7bLL)), ((u64)(0x04c308a831868ac9LL)), ((u64)(0x048e74404f3daadbLL)), ((u64)(0x04585d003f6488afLL)), | ||
| 3279 | +((u64)(0x04237d99cc506d59LL)), ((u64)(0x03ef2f5c7a1a488eLL)), ((u64)(0x03b8f2b061aea072LL)), ((u64)(0x0383f559e7bee6c1LL)), ((u64)(0x034feef63f97d79cLL)), ((u64)(0x03198bf832dfdfb0LL)), ((u64)(0x02e46ff9c24cb2f3LL)), ((u64)(0x02b059949b708f29LL)), ((u64)(0x027a28edc580e50eLL)), ((u64)(0x0244ed8b04671da5LL)), ((u64)(0x0210be08d0527e1dLL)), ((u64)(0x01dac9a7b3b7302fLL)), ((u64)(0x01a56e1fc2f8f359LL)), ((u64)(0x017124e63593f5e1LL)), ((u64)(0x013b6e3d22865634LL)), ((u64)(0x0105f1ca820511c3LL)), | ||
| 3280 | +((u64)(0x00d18e3b9b374169LL)), ((u64)(0x009c16c5c5253575LL)), ((u64)(0x0066789e3750f791LL)), ((u64)(0x0031fa182c40c60dLL)), ((u64)(0x000730d67819e8d2LL)), ((u64)(0x0000b8157268fdafLL)), ((u64)(0x000012688b70e62bLL)), ((u64)(0x000001d74124e3d1LL)), ((u64)(0x0000002f201d49fbLL)), ((u64)(0x00000004b6695433LL)), ((u64)(0x0000000078a42205)), ((u64)(0x000000000c1069cd)), ((u64)(0x000000000134d761)), ((u64)(0x00000000001ee257)), ((u64)(0x00000000000316a2)), ((u64)(0x0000000000004f10)), ((u64)(0x00000000000007e8)), ((u64)(0x00000000000000ca)), ((u64)(0x0000000000000014)), ((u64)(0x0000000000000002))}; // fixed array const | ||
| 3281 | +static i64 _const_strconv__i64_min_int32; // inited later | ||
| 3282 | +static i64 _const_strconv__i64_max_int32; // inited later | ||
| 3283 | +static Array_fixed_u32_10 _const_strconv__ten_pow_table_32 = {((u32)(1)), ((u32)(10)), ((u32)(100)), ((u32)(1000)), ((u32)(10000)), ((u32)(100000)), ((u32)(1000000)), ((u32)(10000000)), ((u32)(100000000)), ((u32)(1000000000))}; // fixed array const | ||
| 3284 | +static const u32 _const_strconv__mantbits32 = 23; // precomputed2 | ||
| 3285 | +static const u32 _const_strconv__expbits32 = 8; // precomputed2 | ||
| 3286 | +static Array_fixed_u64_20 _const_strconv__ten_pow_table_64 = {((u64)(1)), ((u64)(10)), ((u64)(100)), ((u64)(1000)), ((u64)(10000)), ((u64)(100000)), ((u64)(1000000)), ((u64)(10000000)), ((u64)(100000000)), ((u64)(1000000000)), ((u64)(10000000000LL)), ((u64)(100000000000LL)), ((u64)(1000000000000LL)), ((u64)(10000000000000LL)), ((u64)(100000000000000LL)), ((u64)(1000000000000000LL)), ((u64)(10000000000000000LL)), ((u64)(100000000000000000LL)), ((u64)(1000000000000000000LL)), ((u64)(10000000000000000000ULL))}; // fixed array const | ||
| 3287 | +static const u32 _const_strconv__mantbits64 = 52; // precomputed2 | ||
| 3288 | +static const u32 _const_strconv__expbits64 = 11; // precomputed2 | ||
| 3289 | +static Array_fixed_f64_36 _const_strconv__dec_round = {((f64)(0.5)), 0.05, 0.005, 0.0005, 0.00005, 0.000005, 0.0000005, 0.00000005, 0.000000005, 0.0000000005, 0.00000000005, 0.000000000005, 0.0000000000005, 0.00000000000005, 0.000000000000005, 0.0000000000000005, | ||
| 3290 | +0.00000000000000005, 0.000000000000000005, 0.0000000000000000005, 0.00000000000000000005, 0.000000000000000000005, 0.0000000000000000000005, 0.00000000000000000000005, 0.000000000000000000000005, 0.0000000000000000000000005, 0.00000000000000000000000005, 0.000000000000000000000000005, 0.0000000000000000000000000005, 0.00000000000000000000000000005, 0.000000000000000000000000000005, 0.0000000000000000000000000000005, 0.00000000000000000000000000000005, 0.000000000000000000000000000000005, 0.0000000000000000000000000000000005, 0.00000000000000000000000000000000005, 0.000000000000000000000000000000000005}; // fixed array const | ||
| 3291 | +static Array_fixed_u64_47 _const_strconv__pow5_split_32 = {((u64)(1152921504606846976LL)), ((u64)(1441151880758558720LL)), ((u64)(1801439850948198400LL)), ((u64)(2251799813685248000LL)), ((u64)(1407374883553280000LL)), ((u64)(1759218604441600000LL)), ((u64)(2199023255552000000LL)), ((u64)(1374389534720000000LL)), ((u64)(1717986918400000000LL)), ((u64)(2147483648000000000LL)), ((u64)(1342177280000000000LL)), ((u64)(1677721600000000000LL)), ((u64)(2097152000000000000LL)), ((u64)(1310720000000000000LL)), ((u64)(1638400000000000000LL)), ((u64)(2048000000000000000LL)), | ||
| 3292 | +((u64)(1280000000000000000LL)), ((u64)(1600000000000000000LL)), ((u64)(2000000000000000000LL)), ((u64)(1250000000000000000LL)), ((u64)(1562500000000000000LL)), ((u64)(1953125000000000000LL)), ((u64)(1220703125000000000LL)), ((u64)(1525878906250000000LL)), ((u64)(1907348632812500000LL)), ((u64)(1192092895507812500LL)), ((u64)(1490116119384765625LL)), ((u64)(1862645149230957031LL)), ((u64)(1164153218269348144LL)), ((u64)(1455191522836685180LL)), ((u64)(1818989403545856475LL)), ((u64)(2273736754432320594LL)), | ||
| 3293 | +((u64)(1421085471520200371LL)), ((u64)(1776356839400250464LL)), ((u64)(2220446049250313080LL)), ((u64)(1387778780781445675LL)), ((u64)(1734723475976807094LL)), ((u64)(2168404344971008868LL)), ((u64)(1355252715606880542LL)), ((u64)(1694065894508600678LL)), ((u64)(2117582368135750847LL)), ((u64)(1323488980084844279LL)), ((u64)(1654361225106055349LL)), ((u64)(2067951531382569187LL)), ((u64)(1292469707114105741LL)), ((u64)(1615587133892632177LL)), ((u64)(2019483917365790221LL))}; // fixed array const | ||
| 3294 | +static Array_fixed_u64_31 _const_strconv__pow5_inv_split_32 = {((u64)(576460752303423489LL)), ((u64)(461168601842738791LL)), ((u64)(368934881474191033LL)), ((u64)(295147905179352826LL)), ((u64)(472236648286964522LL)), ((u64)(377789318629571618LL)), ((u64)(302231454903657294LL)), ((u64)(483570327845851670LL)), ((u64)(386856262276681336LL)), ((u64)(309485009821345069LL)), ((u64)(495176015714152110LL)), ((u64)(396140812571321688LL)), ((u64)(316912650057057351LL)), ((u64)(507060240091291761LL)), ((u64)(405648192073033409LL)), ((u64)(324518553658426727LL)), | ||
| 3295 | +((u64)(519229685853482763LL)), ((u64)(415383748682786211LL)), ((u64)(332306998946228969LL)), ((u64)(531691198313966350LL)), ((u64)(425352958651173080LL)), ((u64)(340282366920938464LL)), ((u64)(544451787073501542LL)), ((u64)(435561429658801234LL)), ((u64)(348449143727040987LL)), ((u64)(557518629963265579LL)), ((u64)(446014903970612463LL)), ((u64)(356811923176489971LL)), ((u64)(570899077082383953LL)), ((u64)(456719261665907162LL)), ((u64)(365375409332725730LL))}; // fixed array const | ||
| 3296 | +static Array_fixed_u64_652 _const_strconv__pow5_split_64_x = {((u64)(0x0000000000000000)), ((u64)(0x0100000000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x0140000000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x0190000000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01f4000000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x0138800000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x0186a00000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01e8480000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01312d0000000000LL)), | ||
| 3297 | +((u64)(0x0000000000000000)), ((u64)(0x017d784000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01dcd65000000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x012a05f200000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x0174876e80000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01d1a94a20000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x012309ce54000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x016bcc41e9000000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01c6bf5263400000LL)), | ||
| 3298 | +((u64)(0x0000000000000000)), ((u64)(0x011c37937e080000LL)), ((u64)(0x0000000000000000)), ((u64)(0x016345785d8a0000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01bc16d674ec8000LL)), ((u64)(0x0000000000000000)), ((u64)(0x01158e460913d000LL)), ((u64)(0x0000000000000000)), ((u64)(0x015af1d78b58c400LL)), ((u64)(0x0000000000000000)), ((u64)(0x01b1ae4d6e2ef500LL)), ((u64)(0x0000000000000000)), ((u64)(0x010f0cf064dd5920LL)), ((u64)(0x0000000000000000)), ((u64)(0x0152d02c7e14af68LL)), | ||
| 3299 | +((u64)(0x0000000000000000)), ((u64)(0x01a784379d99db42LL)), ((u64)(0x4000000000000000LL)), ((u64)(0x0108b2a2c2802909LL)), ((u64)(0x9000000000000000ULL)), ((u64)(0x014adf4b7320334bLL)), ((u64)(0x7400000000000000LL)), ((u64)(0x019d971e4fe8401eLL)), ((u64)(0x0880000000000000LL)), ((u64)(0x01027e72f1f12813LL)), ((u64)(0xcaa0000000000000ULL)), ((u64)(0x01431e0fae6d7217LL)), ((u64)(0xbd48000000000000ULL)), ((u64)(0x0193e5939a08ce9dLL)), ((u64)(0x2c9a000000000000LL)), ((u64)(0x01f8def8808b0245LL)), | ||
| 3300 | +((u64)(0x3be0400000000000LL)), ((u64)(0x013b8b5b5056e16bLL)), ((u64)(0x0ad8500000000000LL)), ((u64)(0x018a6e32246c99c6LL)), ((u64)(0x8d8e640000000000ULL)), ((u64)(0x01ed09bead87c037LL)), ((u64)(0xb878fe8000000000ULL)), ((u64)(0x013426172c74d822LL)), ((u64)(0x66973e2000000000LL)), ((u64)(0x01812f9cf7920e2bLL)), ((u64)(0x403d0da800000000LL)), ((u64)(0x01e17b84357691b6LL)), ((u64)(0xe826288900000000ULL)), ((u64)(0x012ced32a16a1b11LL)), ((u64)(0x622fb2ab40000000LL)), ((u64)(0x0178287f49c4a1d6LL)), | ||
| 3301 | +((u64)(0xfabb9f5610000000ULL)), ((u64)(0x01d6329f1c35ca4bLL)), ((u64)(0x7cb54395ca000000LL)), ((u64)(0x0125dfa371a19e6fLL)), ((u64)(0x5be2947b3c800000LL)), ((u64)(0x016f578c4e0a060bLL)), ((u64)(0x32db399a0ba00000LL)), ((u64)(0x01cb2d6f618c878eLL)), ((u64)(0xdfc9040047440000ULL)), ((u64)(0x011efc659cf7d4b8LL)), ((u64)(0x17bb450059150000LL)), ((u64)(0x0166bb7f0435c9e7LL)), ((u64)(0xddaa16406f5a4000ULL)), ((u64)(0x01c06a5ec5433c60LL)), ((u64)(0x8a8a4de845986800ULL)), ((u64)(0x0118427b3b4a05bcLL)), | ||
| 3302 | +((u64)(0xad2ce16256fe8200ULL)), ((u64)(0x015e531a0a1c872bLL)), ((u64)(0x987819baecbe2280ULL)), ((u64)(0x01b5e7e08ca3a8f6LL)), ((u64)(0x1f4b1014d3f6d590LL)), ((u64)(0x0111b0ec57e6499aLL)), ((u64)(0xa71dd41a08f48af4ULL)), ((u64)(0x01561d276ddfdc00LL)), ((u64)(0xd0e549208b31adb1ULL)), ((u64)(0x01aba4714957d300LL)), ((u64)(0x828f4db456ff0c8eULL)), ((u64)(0x010b46c6cdd6e3e0LL)), ((u64)(0xa33321216cbecfb2ULL)), ((u64)(0x014e1878814c9cd8LL)), ((u64)(0xcbffe969c7ee839eULL)), ((u64)(0x01a19e96a19fc40eLL)), | ||
| 3303 | +((u64)(0x3f7ff1e21cf51243LL)), ((u64)(0x0105031e2503da89LL)), ((u64)(0x8f5fee5aa43256d4ULL)), ((u64)(0x014643e5ae44d12bLL)), ((u64)(0x7337e9f14d3eec89LL)), ((u64)(0x0197d4df19d60576LL)), ((u64)(0x1005e46da08ea7abLL)), ((u64)(0x01fdca16e04b86d4LL)), ((u64)(0x8a03aec4845928cbULL)), ((u64)(0x013e9e4e4c2f3444LL)), ((u64)(0xac849a75a56f72fdULL)), ((u64)(0x018e45e1df3b0155LL)), ((u64)(0x17a5c1130ecb4fbdLL)), ((u64)(0x01f1d75a5709c1abLL)), ((u64)(0xeec798abe93f11d6ULL)), ((u64)(0x013726987666190aLL)), | ||
| 3304 | +((u64)(0xaa797ed6e38ed64bULL)), ((u64)(0x0184f03e93ff9f4dLL)), ((u64)(0x1517de8c9c728bdeLL)), ((u64)(0x01e62c4e38ff8721LL)), ((u64)(0xad2eeb17e1c7976bULL)), ((u64)(0x012fdbb0e39fb474LL)), ((u64)(0xd87aa5ddda397d46ULL)), ((u64)(0x017bd29d1c87a191LL)), ((u64)(0x4e994f5550c7dc97LL)), ((u64)(0x01dac74463a989f6LL)), ((u64)(0xf11fd195527ce9deULL)), ((u64)(0x0128bc8abe49f639LL)), ((u64)(0x6d67c5faa71c2456LL)), ((u64)(0x0172ebad6ddc73c8LL)), ((u64)(0x88c1b77950e32d6cULL)), ((u64)(0x01cfa698c95390baLL)), | ||
| 3305 | +((u64)(0x957912abd28dfc63ULL)), ((u64)(0x0121c81f7dd43a74LL)), ((u64)(0xbad75756c7317b7cULL)), ((u64)(0x016a3a275d494911LL)), ((u64)(0x298d2d2c78fdda5bLL)), ((u64)(0x01c4c8b1349b9b56LL)), ((u64)(0xd9f83c3bcb9ea879ULL)), ((u64)(0x011afd6ec0e14115LL)), ((u64)(0x50764b4abe865297LL)), ((u64)(0x0161bcca7119915bLL)), ((u64)(0x2493de1d6e27e73dLL)), ((u64)(0x01ba2bfd0d5ff5b2LL)), ((u64)(0x56dc6ad264d8f086LL)), ((u64)(0x01145b7e285bf98fLL)), ((u64)(0x2c938586fe0f2ca8LL)), ((u64)(0x0159725db272f7f3LL)), | ||
| 3306 | +((u64)(0xf7b866e8bd92f7d2ULL)), ((u64)(0x01afcef51f0fb5efLL)), ((u64)(0xfad34051767bdae3ULL)), ((u64)(0x010de1593369d1b5LL)), ((u64)(0x79881065d41ad19cLL)), ((u64)(0x015159af80444623LL)), ((u64)(0x57ea147f49218603LL)), ((u64)(0x01a5b01b605557acLL)), ((u64)(0xb6f24ccf8db4f3c1ULL)), ((u64)(0x01078e111c3556cbLL)), ((u64)(0xa4aee003712230b2ULL)), ((u64)(0x014971956342ac7eLL)), ((u64)(0x4dda98044d6abcdfLL)), ((u64)(0x019bcdfabc13579eLL)), ((u64)(0xf0a89f02b062b60bULL)), ((u64)(0x010160bcb58c16c2LL)), | ||
| 3307 | +((u64)(0xacd2c6c35c7b638eULL)), ((u64)(0x0141b8ebe2ef1c73LL)), ((u64)(0x98077874339a3c71ULL)), ((u64)(0x01922726dbaae390LL)), ((u64)(0xbe0956914080cb8eULL)), ((u64)(0x01f6b0f092959c74LL)), ((u64)(0xf6c5d61ac8507f38ULL)), ((u64)(0x013a2e965b9d81c8LL)), ((u64)(0x34774ba17a649f07LL)), ((u64)(0x0188ba3bf284e23bLL)), ((u64)(0x01951e89d8fdc6c8LL)), ((u64)(0x01eae8caef261acaLL)), ((u64)(0x40fd3316279e9c3dLL)), ((u64)(0x0132d17ed577d0beLL)), ((u64)(0xd13c7fdbb186434cULL)), ((u64)(0x017f85de8ad5c4edLL)), | ||
| 3308 | +((u64)(0x458b9fd29de7d420LL)), ((u64)(0x01df67562d8b3629LL)), ((u64)(0xcb7743e3a2b0e494ULL)), ((u64)(0x012ba095dc7701d9LL)), ((u64)(0x3e5514dc8b5d1db9LL)), ((u64)(0x017688bb5394c250LL)), ((u64)(0x4dea5a13ae346527LL)), ((u64)(0x01d42aea2879f2e4LL)), ((u64)(0xb0b2784c4ce0bf38ULL)), ((u64)(0x01249ad2594c37ceLL)), ((u64)(0x5cdf165f6018ef06LL)), ((u64)(0x016dc186ef9f45c2LL)), ((u64)(0xf416dbf7381f2ac8ULL)), ((u64)(0x01c931e8ab871732LL)), ((u64)(0xd88e497a83137abdULL)), ((u64)(0x011dbf316b346e7fLL)), | ||
| 3309 | +((u64)(0xceb1dbd923d8596cULL)), ((u64)(0x01652efdc6018a1fLL)), ((u64)(0xc25e52cf6cce6fc7ULL)), ((u64)(0x01be7abd3781eca7LL)), ((u64)(0xd97af3c1a40105dcULL)), ((u64)(0x01170cb642b133e8LL)), ((u64)(0x0fd9b0b20d014754LL)), ((u64)(0x015ccfe3d35d80e3LL)), ((u64)(0xd3d01cde90419929ULL)), ((u64)(0x01b403dcc834e11bLL)), ((u64)(0x6462120b1a28ffb9LL)), ((u64)(0x01108269fd210cb1LL)), ((u64)(0xbd7a968de0b33fa8ULL)), ((u64)(0x0154a3047c694fddLL)), ((u64)(0x2cd93c3158e00f92LL)), ((u64)(0x01a9cbc59b83a3d5LL)), | ||
| 3310 | +((u64)(0x3c07c59ed78c09bbLL)), ((u64)(0x010a1f5b81324665LL)), ((u64)(0x8b09b7068d6f0c2aULL)), ((u64)(0x014ca732617ed7feLL)), ((u64)(0x2dcc24c830cacf34LL)), ((u64)(0x019fd0fef9de8dfeLL)), ((u64)(0xdc9f96fd1e7ec180ULL)), ((u64)(0x0103e29f5c2b18beLL)), ((u64)(0x93c77cbc661e71e1ULL)), ((u64)(0x0144db473335deeeLL)), ((u64)(0x38b95beb7fa60e59LL)), ((u64)(0x01961219000356aaLL)), ((u64)(0xc6e7b2e65f8f91efULL)), ((u64)(0x01fb969f40042c54LL)), ((u64)(0xfc50cfcffbb9bb35ULL)), ((u64)(0x013d3e2388029bb4LL)), | ||
| 3311 | +((u64)(0x3b6503c3faa82a03LL)), ((u64)(0x018c8dac6a0342a2LL)), ((u64)(0xca3e44b4f9523484ULL)), ((u64)(0x01efb1178484134aLL)), ((u64)(0xbe66eaf11bd360d2ULL)), ((u64)(0x0135ceaeb2d28c0eLL)), ((u64)(0x6e00a5ad62c83907LL)), ((u64)(0x0183425a5f872f12LL)), ((u64)(0x0980cf18bb7a4749LL)), ((u64)(0x01e412f0f768fad7LL)), ((u64)(0x65f0816f752c6c8dLL)), ((u64)(0x012e8bd69aa19cc6LL)), ((u64)(0xff6ca1cb527787b1ULL)), ((u64)(0x017a2ecc414a03f7LL)), ((u64)(0xff47ca3e2715699dULL)), ((u64)(0x01d8ba7f519c84f5LL)), | ||
| 3312 | +((u64)(0xbf8cde66d86d6202ULL)), ((u64)(0x0127748f9301d319LL)), ((u64)(0x2f7016008e88ba83LL)), ((u64)(0x017151b377c247e0LL)), ((u64)(0x3b4c1b80b22ae923LL)), ((u64)(0x01cda62055b2d9d8LL)), ((u64)(0x250f91306f5ad1b6LL)), ((u64)(0x012087d4358fc827LL)), ((u64)(0xee53757c8b318623ULL)), ((u64)(0x0168a9c942f3ba30LL)), ((u64)(0x29e852dbadfde7acLL)), ((u64)(0x01c2d43b93b0a8bdLL)), ((u64)(0x3a3133c94cbeb0ccLL)), ((u64)(0x0119c4a53c4e6976LL)), ((u64)(0xc8bd80bb9fee5cffULL)), ((u64)(0x016035ce8b6203d3LL)), | ||
| 3313 | +((u64)(0xbaece0ea87e9f43eULL)), ((u64)(0x01b843422e3a84c8LL)), ((u64)(0x74d40c9294f238a7LL)), ((u64)(0x01132a095ce492fdLL)), ((u64)(0xd2090fb73a2ec6d1ULL)), ((u64)(0x0157f48bb41db7bcLL)), ((u64)(0x068b53a508ba7885LL)), ((u64)(0x01adf1aea12525acLL)), ((u64)(0x8417144725748b53ULL)), ((u64)(0x010cb70d24b7378bLL)), ((u64)(0x651cd958eed1ae28LL)), ((u64)(0x014fe4d06de5056eLL)), ((u64)(0xfe640faf2a8619b2ULL)), ((u64)(0x01a3de04895e46c9LL)), ((u64)(0x3efe89cd7a93d00fLL)), ((u64)(0x01066ac2d5daec3eLL)), | ||
| 3314 | +((u64)(0xcebe2c40d938c413ULL)), ((u64)(0x014805738b51a74dLL)), ((u64)(0x426db7510f86f518LL)), ((u64)(0x019a06d06e261121LL)), ((u64)(0xc9849292a9b4592fULL)), ((u64)(0x0100444244d7cab4LL)), ((u64)(0xfbe5b73754216f7aULL)), ((u64)(0x01405552d60dbd61LL)), ((u64)(0x7adf25052929cb59LL)), ((u64)(0x01906aa78b912cbaLL)), ((u64)(0x1996ee4673743e2fLL)), ((u64)(0x01f485516e7577e9LL)), ((u64)(0xaffe54ec0828a6ddULL)), ((u64)(0x0138d352e5096af1LL)), ((u64)(0x1bfdea270a32d095LL)), ((u64)(0x018708279e4bc5aeLL)), | ||
| 3315 | +((u64)(0xa2fd64b0ccbf84baULL)), ((u64)(0x01e8ca3185deb719LL)), ((u64)(0x05de5eee7ff7b2f4LL)), ((u64)(0x01317e5ef3ab3270LL)), ((u64)(0x0755f6aa1ff59fb1LL)), ((u64)(0x017dddf6b095ff0cLL)), ((u64)(0x092b7454a7f3079eLL)), ((u64)(0x01dd55745cbb7ecfLL)), ((u64)(0x65bb28b4e8f7e4c3LL)), ((u64)(0x012a5568b9f52f41LL)), ((u64)(0xbf29f2e22335ddf3ULL)), ((u64)(0x0174eac2e8727b11LL)), ((u64)(0x2ef46f9aac035570LL)), ((u64)(0x01d22573a28f19d6LL)), ((u64)(0xdd58c5c0ab821566ULL)), ((u64)(0x0123576845997025LL)), | ||
| 3316 | +((u64)(0x54aef730d6629ac0LL)), ((u64)(0x016c2d4256ffcc2fLL)), ((u64)(0x29dab4fd0bfb4170LL)), ((u64)(0x01c73892ecbfbf3bLL)), ((u64)(0xfa28b11e277d08e6ULL)), ((u64)(0x011c835bd3f7d784LL)), ((u64)(0x38b2dd65b15c4b1fLL)), ((u64)(0x0163a432c8f5cd66LL)), ((u64)(0xc6df94bf1db35de7ULL)), ((u64)(0x01bc8d3f7b3340bfLL)), ((u64)(0xdc4bbcf772901ab0ULL)), ((u64)(0x0115d847ad000877LL)), ((u64)(0xd35eac354f34215cULL)), ((u64)(0x015b4e5998400a95LL)), ((u64)(0x48365742a30129b4LL)), ((u64)(0x01b221effe500d3bLL)), | ||
| 3317 | +((u64)(0x0d21f689a5e0ba10LL)), ((u64)(0x010f5535fef20845LL)), ((u64)(0x506a742c0f58e894LL)), ((u64)(0x01532a837eae8a56LL)), ((u64)(0xe4851137132f22b9ULL)), ((u64)(0x01a7f5245e5a2cebLL)), ((u64)(0x6ed32ac26bfd75b4LL)), ((u64)(0x0108f936baf85c13LL)), ((u64)(0x4a87f57306fcd321LL)), ((u64)(0x014b378469b67318LL)), ((u64)(0x5d29f2cfc8bc07e9LL)), ((u64)(0x019e056584240fdeLL)), ((u64)(0xfa3a37c1dd7584f1ULL)), ((u64)(0x0102c35f729689eaLL)), ((u64)(0xb8c8c5b254d2e62eULL)), ((u64)(0x014374374f3c2c65LL)), | ||
| 3318 | +((u64)(0x26faf71eea079fb9LL)), ((u64)(0x01945145230b377fLL)), ((u64)(0xf0b9b4e6a48987a8ULL)), ((u64)(0x01f965966bce055eLL)), ((u64)(0x5674111026d5f4c9LL)), ((u64)(0x013bdf7e0360c35bLL)), ((u64)(0x2c111554308b71fbLL)), ((u64)(0x018ad75d8438f432LL)), ((u64)(0xb7155aa93cae4e7aULL)), ((u64)(0x01ed8d34e547313eLL)), ((u64)(0x326d58a9c5ecf10cLL)), ((u64)(0x013478410f4c7ec7LL)), ((u64)(0xff08aed437682d4fULL)), ((u64)(0x01819651531f9e78LL)), ((u64)(0x3ecada89454238a3LL)), ((u64)(0x01e1fbe5a7e78617LL)), | ||
| 3319 | +((u64)(0x873ec895cb496366ULL)), ((u64)(0x012d3d6f88f0b3ceLL)), ((u64)(0x290e7abb3e1bbc3fLL)), ((u64)(0x01788ccb6b2ce0c2LL)), ((u64)(0xb352196a0da2ab4fULL)), ((u64)(0x01d6affe45f818f2LL)), ((u64)(0xb0134fe24885ab11ULL)), ((u64)(0x01262dfeebbb0f97LL)), ((u64)(0x9c1823dadaa715d6ULL)), ((u64)(0x016fb97ea6a9d37dLL)), ((u64)(0x031e2cd19150db4bLL)), ((u64)(0x01cba7de5054485dLL)), ((u64)(0x21f2dc02fad2890fLL)), ((u64)(0x011f48eaf234ad3aLL)), ((u64)(0xaa6f9303b9872b53ULL)), ((u64)(0x01671b25aec1d888LL)), | ||
| 3320 | +((u64)(0xd50b77c4a7e8f628ULL)), ((u64)(0x01c0e1ef1a724eaaLL)), ((u64)(0xc5272adae8f199d9ULL)), ((u64)(0x01188d357087712aLL)), ((u64)(0x7670f591a32e004fLL)), ((u64)(0x015eb082cca94d75LL)), ((u64)(0xd40d32f60bf98063ULL)), ((u64)(0x01b65ca37fd3a0d2LL)), ((u64)(0xc4883fd9c77bf03eULL)), ((u64)(0x0111f9e62fe44483LL)), ((u64)(0xb5aa4fd0395aec4dULL)), ((u64)(0x0156785fbbdd55a4LL)), ((u64)(0xe314e3c447b1a760ULL)), ((u64)(0x01ac1677aad4ab0dLL)), ((u64)(0xaded0e5aaccf089cULL)), ((u64)(0x010b8e0acac4eae8LL)), | ||
| 3321 | +((u64)(0xd96851f15802cac3ULL)), ((u64)(0x014e718d7d7625a2LL)), ((u64)(0x8fc2666dae037d74ULL)), ((u64)(0x01a20df0dcd3af0bLL)), ((u64)(0x39d980048cc22e68LL)), ((u64)(0x010548b68a044d67LL)), ((u64)(0x084fe005aff2ba03LL)), ((u64)(0x01469ae42c8560c1LL)), ((u64)(0x4a63d8071bef6883LL)), ((u64)(0x0198419d37a6b8f1LL)), ((u64)(0x9cfcce08e2eb42a4ULL)), ((u64)(0x01fe52048590672dLL)), ((u64)(0x821e00c58dd309a7ULL)), ((u64)(0x013ef342d37a407cLL)), ((u64)(0xa2a580f6f147cc10ULL)), ((u64)(0x018eb0138858d09bLL)), | ||
| 3322 | +((u64)(0x8b4ee134ad99bf15ULL)), ((u64)(0x01f25c186a6f04c2LL)), ((u64)(0x97114cc0ec80176dULL)), ((u64)(0x0137798f428562f9LL)), ((u64)(0xfcd59ff127a01d48ULL)), ((u64)(0x018557f31326bbb7LL)), ((u64)(0xfc0b07ed7188249aULL)), ((u64)(0x01e6adefd7f06aa5LL)), ((u64)(0xbd86e4f466f516e0ULL)), ((u64)(0x01302cb5e6f642a7LL)), ((u64)(0xace89e3180b25c98ULL)), ((u64)(0x017c37e360b3d351LL)), ((u64)(0x1822c5bde0def3beLL)), ((u64)(0x01db45dc38e0c826LL)), ((u64)(0xcf15bb96ac8b5857ULL)), ((u64)(0x01290ba9a38c7d17LL)), | ||
| 3323 | +((u64)(0xc2db2a7c57ae2e6dULL)), ((u64)(0x01734e940c6f9c5dLL)), ((u64)(0x3391f51b6d99ba08LL)), ((u64)(0x01d022390f8b8375LL)), ((u64)(0x403b393124801445LL)), ((u64)(0x01221563a9b73229LL)), ((u64)(0x904a077d6da01956ULL)), ((u64)(0x016a9abc9424feb3LL)), ((u64)(0x745c895cc9081facLL)), ((u64)(0x01c5416bb92e3e60LL)), ((u64)(0x48b9d5d9fda513cbLL)), ((u64)(0x011b48e353bce6fcLL)), ((u64)(0x5ae84b507d0e58beLL)), ((u64)(0x01621b1c28ac20bbLL)), ((u64)(0x31a25e249c51eeeeLL)), ((u64)(0x01baa1e332d728eaLL)), | ||
| 3324 | +((u64)(0x5f057ad6e1b33554LL)), ((u64)(0x0114a52dffc67992LL)), ((u64)(0xf6c6d98c9a2002aaULL)), ((u64)(0x0159ce797fb817f6LL)), ((u64)(0xb4788fefc0a80354ULL)), ((u64)(0x01b04217dfa61df4LL)), ((u64)(0xf0cb59f5d8690214ULL)), ((u64)(0x010e294eebc7d2b8LL)), ((u64)(0x2cfe30734e83429aLL)), ((u64)(0x0151b3a2a6b9c767LL)), ((u64)(0xf83dbc9022241340ULL)), ((u64)(0x01a6208b50683940LL)), ((u64)(0x9b2695da15568c08ULL)), ((u64)(0x0107d457124123c8LL)), ((u64)(0xc1f03b509aac2f0aULL)), ((u64)(0x0149c96cd6d16cbaLL)), | ||
| 3325 | +((u64)(0x726c4a24c1573acdLL)), ((u64)(0x019c3bc80c85c7e9LL)), ((u64)(0xe783ae56f8d684c0ULL)), ((u64)(0x0101a55d07d39cf1LL)), ((u64)(0x616499ecb70c25f0LL)), ((u64)(0x01420eb449c8842eLL)), ((u64)(0xf9bdc067e4cf2f6cULL)), ((u64)(0x019292615c3aa539LL)), ((u64)(0x782d3081de02fb47LL)), ((u64)(0x01f736f9b3494e88LL)), ((u64)(0x4b1c3e512ac1dd0cLL)), ((u64)(0x013a825c100dd115LL)), ((u64)(0x9de34de57572544fULL)), ((u64)(0x018922f31411455aLL)), ((u64)(0x455c215ed2cee963LL)), ((u64)(0x01eb6bafd91596b1LL)), | ||
| 3326 | +((u64)(0xcb5994db43c151deULL)), ((u64)(0x0133234de7ad7e2eLL)), ((u64)(0x7e2ffa1214b1a655LL)), ((u64)(0x017fec216198ddbaLL)), ((u64)(0x1dbbf89699de0febLL)), ((u64)(0x01dfe729b9ff1529LL)), ((u64)(0xb2957b5e202ac9f3ULL)), ((u64)(0x012bf07a143f6d39LL)), ((u64)(0x1f3ada35a8357c6fLL)), ((u64)(0x0176ec98994f4888LL)), ((u64)(0x270990c31242db8bLL)), ((u64)(0x01d4a7bebfa31aaaLL)), ((u64)(0x5865fa79eb69c937LL)), ((u64)(0x0124e8d737c5f0aaLL)), ((u64)(0xee7f791866443b85ULL)), ((u64)(0x016e230d05b76cd4LL)), | ||
| 3327 | +((u64)(0x2a1f575e7fd54a66LL)), ((u64)(0x01c9abd04725480aLL)), ((u64)(0x5a53969b0fe54e80LL)), ((u64)(0x011e0b622c774d06LL)), ((u64)(0xf0e87c41d3dea220ULL)), ((u64)(0x01658e3ab7952047LL)), ((u64)(0xed229b5248d64aa8ULL)), ((u64)(0x01bef1c9657a6859LL)), ((u64)(0x3435a1136d85eea9LL)), ((u64)(0x0117571ddf6c8138LL)), ((u64)(0x4143095848e76a53LL)), ((u64)(0x015d2ce55747a186LL)), ((u64)(0xd193cbae5b2144e8ULL)), ((u64)(0x01b4781ead1989e7LL)), ((u64)(0xe2fc5f4cf8f4cb11ULL)), ((u64)(0x0110cb132c2ff630LL)), | ||
| 3328 | +((u64)(0x1bbb77203731fdd5LL)), ((u64)(0x0154fdd7f73bf3bdLL)), ((u64)(0x62aa54e844fe7d4aLL)), ((u64)(0x01aa3d4df50af0acLL)), ((u64)(0xbdaa75112b1f0e4eULL)), ((u64)(0x010a6650b926d66bLL)), ((u64)(0xad15125575e6d1e2ULL)), ((u64)(0x014cffe4e7708c06LL)), ((u64)(0x585a56ead360865bLL)), ((u64)(0x01a03fde214caf08LL)), ((u64)(0x37387652c41c53f8LL)), ((u64)(0x010427ead4cfed65LL)), ((u64)(0x850693e7752368f7ULL)), ((u64)(0x014531e58a03e8beLL)), ((u64)(0x264838e1526c4334LL)), ((u64)(0x01967e5eec84e2eeLL)), | ||
| 3329 | +((u64)(0xafda4719a7075402ULL)), ((u64)(0x01fc1df6a7a61ba9LL)), ((u64)(0x0de86c7008649481LL)), ((u64)(0x013d92ba28c7d14aLL)), ((u64)(0x9162878c0a7db9a1ULL)), ((u64)(0x018cf768b2f9c59cLL)), ((u64)(0xb5bb296f0d1d280aULL)), ((u64)(0x01f03542dfb83703LL)), ((u64)(0x5194f9e568323906LL)), ((u64)(0x01362149cbd32262LL)), ((u64)(0xe5fa385ec23ec747ULL)), ((u64)(0x0183a99c3ec7eafaLL)), ((u64)(0x9f78c67672ce7919ULL)), ((u64)(0x01e494034e79e5b9LL)), ((u64)(0x03ab7c0a07c10bb0LL)), ((u64)(0x012edc82110c2f94LL)), | ||
| 3330 | +((u64)(0x04965b0c89b14e9cLL)), ((u64)(0x017a93a2954f3b79LL)), ((u64)(0x45bbf1cfac1da243LL)), ((u64)(0x01d9388b3aa30a57LL)), ((u64)(0x8b957721cb92856aULL)), ((u64)(0x0127c35704a5e676LL)), ((u64)(0x2e7ad4ea3e7726c4LL)), ((u64)(0x0171b42cc5cf6014LL)), ((u64)(0x3a198a24ce14f075LL)), ((u64)(0x01ce2137f7433819LL)), ((u64)(0xc44ff65700cd1649ULL)), ((u64)(0x0120d4c2fa8a030fLL)), ((u64)(0xb563f3ecc1005bdbULL)), ((u64)(0x016909f3b92c83d3LL)), ((u64)(0xa2bcf0e7f14072d2ULL)), ((u64)(0x01c34c70a777a4c8LL)), | ||
| 3331 | +((u64)(0x65b61690f6c847c3LL)), ((u64)(0x011a0fc668aac6fdLL)), ((u64)(0xbf239c35347a59b4ULL)), ((u64)(0x016093b802d578bcLL)), ((u64)(0xeeec83428198f021ULL)), ((u64)(0x01b8b8a6038ad6ebLL)), ((u64)(0x7553d20990ff9615LL)), ((u64)(0x01137367c236c653LL)), ((u64)(0x52a8c68bf53f7b9aLL)), ((u64)(0x01585041b2c477e8LL)), ((u64)(0x6752f82ef28f5a81LL)), ((u64)(0x01ae64521f7595e2LL)), ((u64)(0x8093db1d57999890ULL)), ((u64)(0x010cfeb353a97dadLL)), ((u64)(0xe0b8d1e4ad7ffeb4ULL)), ((u64)(0x01503e602893dd18LL)), | ||
| 3332 | +((u64)(0x18e7065dd8dffe62LL)), ((u64)(0x01a44df832b8d45fLL)), ((u64)(0x6f9063faa78bfefdLL)), ((u64)(0x0106b0bb1fb384bbLL)), ((u64)(0x4b747cf9516efebcLL)), ((u64)(0x01485ce9e7a065eaLL)), ((u64)(0xde519c37a5cabe6bULL)), ((u64)(0x019a742461887f64LL)), ((u64)(0x0af301a2c79eb703LL)), ((u64)(0x01008896bcf54f9fLL)), ((u64)(0xcdafc20b798664c4ULL)), ((u64)(0x0140aabc6c32a386LL)), ((u64)(0x811bb28e57e7fdf5ULL)), ((u64)(0x0190d56b873f4c68LL)), ((u64)(0xa1629f31ede1fd72ULL)), ((u64)(0x01f50ac6690f1f82LL)), | ||
| 3333 | +((u64)(0xa4dda37f34ad3e67ULL)), ((u64)(0x013926bc01a973b1LL)), ((u64)(0x0e150c5f01d88e01LL)), ((u64)(0x0187706b0213d09eLL)), ((u64)(0x919a4f76c24eb181ULL)), ((u64)(0x01e94c85c298c4c5LL)), ((u64)(0x7b0071aa39712ef1LL)), ((u64)(0x0131cfd3999f7afbLL)), ((u64)(0x59c08e14c7cd7aadLL)), ((u64)(0x017e43c8800759baLL)), ((u64)(0xf030b199f9c0d958ULL)), ((u64)(0x01ddd4baa0093028LL)), ((u64)(0x961e6f003c1887d7ULL)), ((u64)(0x012aa4f4a405be19LL)), ((u64)(0xfba60ac04b1ea9cdULL)), ((u64)(0x01754e31cd072d9fLL)), | ||
| 3334 | +((u64)(0xfa8f8d705de65440ULL)), ((u64)(0x01d2a1be4048f907LL)), ((u64)(0xfc99b8663aaff4a8ULL)), ((u64)(0x0123a516e82d9ba4LL)), ((u64)(0x3bc0267fc95bf1d2LL)), ((u64)(0x016c8e5ca239028eLL)), ((u64)(0xcab0301fbbb2ee47ULL)), ((u64)(0x01c7b1f3cac74331LL)), ((u64)(0x1eae1e13d54fd4ecLL)), ((u64)(0x011ccf385ebc89ffLL)), ((u64)(0xe659a598caa3ca27ULL)), ((u64)(0x01640306766bac7eLL)), ((u64)(0x9ff00efefd4cbcb1ULL)), ((u64)(0x01bd03c81406979eLL)), ((u64)(0x23f6095f5e4ff5efLL)), ((u64)(0x0116225d0c841ec3LL)), | ||
| 3335 | +((u64)(0xecf38bb735e3f36aULL)), ((u64)(0x015baaf44fa52673LL)), ((u64)(0xe8306ea5035cf045ULL)), ((u64)(0x01b295b1638e7010LL)), ((u64)(0x911e4527221a162bULL)), ((u64)(0x010f9d8ede39060aLL)), ((u64)(0x3565d670eaa09bb6LL)), ((u64)(0x015384f295c7478dLL)), ((u64)(0x82bf4c0d2548c2a3ULL)), ((u64)(0x01a8662f3b391970LL)), ((u64)(0x51b78f88374d79a6LL)), ((u64)(0x01093fdd8503afe6LL)), ((u64)(0xe625736a4520d810ULL)), ((u64)(0x014b8fd4e6449bdfLL)), ((u64)(0xdfaed044d6690e14ULL)), ((u64)(0x019e73ca1fd5c2d7LL)), ((u64)(0xebcd422b0601a8ccULL)), ((u64)(0x0103085e53e599c6LL)), ((u64)(0xa6c092b5c78212ffULL)), ((u64)(0x0143ca75e8df0038LL)), ((u64)(0xd070b763396297bfULL)), ((u64)(0x0194bd136316c046LL)), ((u64)(0x848ce53c07bb3dafULL)), ((u64)(0x01f9ec583bdc7058LL)), ((u64)(0x52d80f4584d5068dLL)), ((u64)(0x013c33b72569c637LL)), ((u64)(0x278e1316e60a4831LL)), ((u64)(0x018b40a4eec437c5LL))}; // fixed array const | ||
| 3336 | +static Array_fixed_u64_584 _const_strconv__pow5_inv_split_64_x = {((u64)(0x0000000000000001)), ((u64)(0x0400000000000000LL)), ((u64)(0x3333333333333334LL)), ((u64)(0x0333333333333333LL)), ((u64)(0x28f5c28f5c28f5c3LL)), ((u64)(0x028f5c28f5c28f5cLL)), ((u64)(0xed916872b020c49cULL)), ((u64)(0x020c49ba5e353f7cLL)), ((u64)(0xaf4f0d844d013a93ULL)), ((u64)(0x0346dc5d63886594LL)), ((u64)(0x8c3f3e0370cdc876ULL)), ((u64)(0x029f16b11c6d1e10LL)), ((u64)(0xd698fe69270b06c5ULL)), ((u64)(0x0218def416bdb1a6LL)), ((u64)(0xf0f4ca41d811a46eULL)), ((u64)(0x035afe535795e90aLL)), | ||
| 3337 | +((u64)(0xf3f70834acdae9f1ULL)), ((u64)(0x02af31dc4611873bLL)), ((u64)(0x5cc5a02a23e254c1LL)), ((u64)(0x0225c17d04dad296LL)), ((u64)(0xfad5cd10396a2135ULL)), ((u64)(0x036f9bfb3af7b756LL)), ((u64)(0xfbde3da69454e75eULL)), ((u64)(0x02bfaffc2f2c92abLL)), ((u64)(0x2fe4fe1edd10b918LL)), ((u64)(0x0232f33025bd4223LL)), ((u64)(0x4ca19697c81ac1bfLL)), ((u64)(0x0384b84d092ed038LL)), ((u64)(0x3d4e1213067bce33LL)), ((u64)(0x02d09370d4257360LL)), ((u64)(0x643e74dc052fd829LL)), ((u64)(0x024075f3dceac2b3LL)), | ||
| 3338 | +((u64)(0x6d30baf9a1e626a7LL)), ((u64)(0x039a5652fb113785LL)), ((u64)(0x2426fbfae7eb5220LL)), ((u64)(0x02e1dea8c8da92d1LL)), ((u64)(0x1cebfcc8b9890e80LL)), ((u64)(0x024e4bba3a487574LL)), ((u64)(0x94acc7a78f41b0ccULL)), ((u64)(0x03b07929f6da5586LL)), ((u64)(0xaa23d2ec729af3d7ULL)), ((u64)(0x02f394219248446bLL)), ((u64)(0xbb4fdbf05baf2979ULL)), ((u64)(0x025c768141d369efLL)), ((u64)(0xc54c931a2c4b758dULL)), ((u64)(0x03c7240202ebdcb2LL)), ((u64)(0x9dd6dc14f03c5e0bULL)), ((u64)(0x0305b66802564a28LL)), | ||
| 3339 | +((u64)(0x4b1249aa59c9e4d6LL)), ((u64)(0x026af8533511d4edLL)), ((u64)(0x44ea0f76f60fd489LL)), ((u64)(0x03de5a1ebb4fbb15LL)), ((u64)(0x6a54d92bf80caa07LL)), ((u64)(0x0318481895d96277LL)), ((u64)(0x21dd7a89933d54d2LL)), ((u64)(0x0279d346de4781f9LL)), ((u64)(0x362f2a75b8622150LL)), ((u64)(0x03f61ed7ca0c0328LL)), ((u64)(0xf825bb91604e810dULL)), ((u64)(0x032b4bdfd4d668ecLL)), ((u64)(0xc684960de6a5340bULL)), ((u64)(0x0289097fdd7853f0LL)), ((u64)(0xd203ab3e521dc33cULL)), ((u64)(0x02073accb12d0ff3LL)), | ||
| 3340 | +((u64)(0xe99f7863b696052cULL)), ((u64)(0x033ec47ab514e652LL)), ((u64)(0x87b2c6b62bab3757ULL)), ((u64)(0x02989d2ef743eb75LL)), ((u64)(0xd2f56bc4efbc2c45ULL)), ((u64)(0x0213b0f25f69892aLL)), ((u64)(0x1e55793b192d13a2LL)), ((u64)(0x0352b4b6ff0f41deLL)), ((u64)(0x4b77942f475742e8LL)), ((u64)(0x02a8909265a5ce4bLL)), ((u64)(0xd5f9435905df68baULL)), ((u64)(0x022073a8515171d5LL)), ((u64)(0x565b9ef4d6324129LL)), ((u64)(0x03671f73b54f1c89LL)), ((u64)(0xdeafb25d78283421ULL)), ((u64)(0x02b8e5f62aa5b06dLL)), | ||
| 3341 | +((u64)(0x188c8eb12cecf681LL)), ((u64)(0x022d84c4eeeaf38bLL)), ((u64)(0x8dadb11b7b14bd9bULL)), ((u64)(0x037c07a17e44b8deLL)), ((u64)(0x7157c0e2c8dd647cLL)), ((u64)(0x02c99fb46503c718LL)), ((u64)(0x8ddfcd823a4ab6caULL)), ((u64)(0x023ae629ea696c13LL)), ((u64)(0x1632e269f6ddf142LL)), ((u64)(0x0391704310a8acecLL)), ((u64)(0x44f581ee5f17f435LL)), ((u64)(0x02dac035a6ed5723LL)), ((u64)(0x372ace584c1329c4LL)), ((u64)(0x024899c4858aac1cLL)), ((u64)(0xbeaae3c079b842d3ULL)), ((u64)(0x03a75c6da27779c6LL)), | ||
| 3342 | +((u64)(0x6555830061603576LL)), ((u64)(0x02ec49f14ec5fb05LL)), ((u64)(0xb7779c004de6912bULL)), ((u64)(0x0256a18dd89e626aLL)), ((u64)(0xf258f99a163db512ULL)), ((u64)(0x03bdcf495a9703ddLL)), ((u64)(0x5b7a614811caf741LL)), ((u64)(0x02fe3f6de212697eLL)), ((u64)(0xaf951aa00e3bf901ULL)), ((u64)(0x0264ff8b1b41edfeLL)), ((u64)(0x7f54f7667d2cc19bLL)), ((u64)(0x03d4cc11c5364997LL)), ((u64)(0x32aa5f8530f09ae3LL)), ((u64)(0x0310a3416a91d479LL)), ((u64)(0xf55519375a5a1582ULL)), ((u64)(0x0273b5cdeedb1060LL)), | ||
| 3343 | +((u64)(0xbbbb5b8bc3c3559dULL)), ((u64)(0x03ec56164af81a34LL)), ((u64)(0x2fc916096969114aLL)), ((u64)(0x03237811d593482aLL)), ((u64)(0x596dab3ababa743cLL)), ((u64)(0x0282c674aadc39bbLL)), ((u64)(0x478aef622efb9030LL)), ((u64)(0x0202385d557cfafcLL)), ((u64)(0xd8de4bd04b2c19e6ULL)), ((u64)(0x0336c0955594c4c6LL)), ((u64)(0xad7ea30d08f014b8ULL)), ((u64)(0x029233aaaadd6a38LL)), ((u64)(0x24654f3da0c01093LL)), ((u64)(0x020e8fbbbbe454faLL)), ((u64)(0x3a3bb1fc346680ebLL)), ((u64)(0x034a7f92c63a2190LL)), | ||
| 3344 | +((u64)(0x94fc8e635d1ecd89ULL)), ((u64)(0x02a1ffa89e94e7a6LL)), ((u64)(0xaa63a51c4a7f0ad4ULL)), ((u64)(0x021b32ed4baa52ebLL)), ((u64)(0xdd6c3b607731aaedULL)), ((u64)(0x035eb7e212aa1e45LL)), ((u64)(0x1789c919f8f488bdLL)), ((u64)(0x02b22cb4dbbb4b6bLL)), ((u64)(0xac6e3a7b2d906d64ULL)), ((u64)(0x022823c3e2fc3c55LL)), ((u64)(0x13e390c515b3e23aLL)), ((u64)(0x03736c6c9e606089LL)), ((u64)(0xdcb60d6a77c31b62ULL)), ((u64)(0x02c2bd23b1e6b3a0LL)), ((u64)(0x7d5e7121f968e2b5LL)), ((u64)(0x0235641c8e52294dLL)), | ||
| 3345 | +((u64)(0xc8971b698f0e3787ULL)), ((u64)(0x0388a02db0837548LL)), ((u64)(0xa078e2bad8d82c6cULL)), ((u64)(0x02d3b357c0692aa0LL)), ((u64)(0xe6c71bc8ad79bd24ULL)), ((u64)(0x0242f5dfcd20eee6LL)), ((u64)(0x0ad82c7448c2c839LL)), ((u64)(0x039e5632e1ce4b0bLL)), ((u64)(0x3be023903a356cfaLL)), ((u64)(0x02e511c24e3ea26fLL)), ((u64)(0x2fe682d9c82abd95LL)), ((u64)(0x0250db01d8321b8cLL)), ((u64)(0x4ca4048fa6aac8eeLL)), ((u64)(0x03b4919c8d1cf8e0LL)), ((u64)(0x3d5003a61eef0725LL)), ((u64)(0x02f6dae3a4172d80LL)), | ||
| 3346 | +((u64)(0x9773361e7f259f51ULL)), ((u64)(0x025f1582e9ac2466LL)), ((u64)(0x8beb89ca6508fee8ULL)), ((u64)(0x03cb559e42ad070aLL)), ((u64)(0x6fefa16eb73a6586LL)), ((u64)(0x0309114b688a6c08LL)), ((u64)(0xf3261abef8fb846bULL)), ((u64)(0x026da76f86d52339LL)), ((u64)(0x51d691318e5f3a45LL)), ((u64)(0x03e2a57f3e21d1f6LL)), ((u64)(0x0e4540f471e5c837LL)), ((u64)(0x031bb798fe8174c5LL)), ((u64)(0xd8376729f4b7d360ULL)), ((u64)(0x027c92e0cb9ac3d0LL)), ((u64)(0xf38bd84321261effULL)), ((u64)(0x03fa849adf5e061aLL)), | ||
| 3347 | +((u64)(0x293cad0280eb4bffLL)), ((u64)(0x032ed07be5e4d1afLL)), ((u64)(0xedca240200bc3cccULL)), ((u64)(0x028bd9fcb7ea4158LL)), ((u64)(0xbe3b50019a3030a4ULL)), ((u64)(0x02097b309321cde0LL)), ((u64)(0xc9f88002904d1a9fULL)), ((u64)(0x03425eb41e9c7c9aLL)), ((u64)(0x3b2d3335403daee6LL)), ((u64)(0x029b7ef67ee396e2LL)), ((u64)(0x95bdc291003158b8ULL)), ((u64)(0x0215ff2b98b6124eLL)), ((u64)(0x892f9db4cd1bc126ULL)), ((u64)(0x035665128df01d4aLL)), ((u64)(0x07594af70a7c9a85LL)), ((u64)(0x02ab840ed7f34aa2LL)), | ||
| 3348 | +((u64)(0x6c476f2c0863aed1LL)), ((u64)(0x0222d00bdff5d54eLL)), ((u64)(0x13a57eacda3917b4LL)), ((u64)(0x036ae67966562217LL)), ((u64)(0x0fb7988a482dac90LL)), ((u64)(0x02bbeb9451de81acLL)), ((u64)(0xd95fad3b6cf156daULL)), ((u64)(0x022fefa9db1867bcLL)), ((u64)(0xf565e1f8ae4ef15cULL)), ((u64)(0x037fe5dc91c0a5faLL)), ((u64)(0x911e4e608b725ab0ULL)), ((u64)(0x02ccb7e3a7cd5195LL)), ((u64)(0xda7ea51a0928488dULL)), ((u64)(0x023d5fe9530aa7aaLL)), ((u64)(0xf7310829a8407415ULL)), ((u64)(0x039566421e7772aaLL)), | ||
| 3349 | +((u64)(0x2c2739baed005cdeLL)), ((u64)(0x02ddeb68185f8eefLL)), ((u64)(0xbcec2e2f24004a4bULL)), ((u64)(0x024b22b9ad193f25LL)), ((u64)(0x94ad16b1d333aa11ULL)), ((u64)(0x03ab6ac2ae8ecb6fLL)), ((u64)(0xaa241227dc2954dbULL)), ((u64)(0x02ef889bbed8a2bfLL)), ((u64)(0x54e9a81fe35443e2LL)), ((u64)(0x02593a163246e899LL)), ((u64)(0x2175d9cc9eed396aLL)), ((u64)(0x03c1f689ea0b0dc2LL)), ((u64)(0xe7917b0a18bdc788ULL)), ((u64)(0x03019207ee6f3e34LL)), ((u64)(0xb9412f3b46fe393aULL)), ((u64)(0x0267a8065858fe90LL)), | ||
| 3350 | +((u64)(0xf535185ed7fd285cULL)), ((u64)(0x03d90cd6f3c1974dLL)), ((u64)(0xc42a79e57997537dULL)), ((u64)(0x03140a458fce12a4LL)), ((u64)(0x03552e512e12a931LL)), ((u64)(0x02766e9e0ca4dbb7LL)), ((u64)(0x9eeeb081e3510eb4ULL)), ((u64)(0x03f0b0fce107c5f1LL)), ((u64)(0x4bf226ce4f740bc3LL)), ((u64)(0x0326f3fd80d304c1LL)), ((u64)(0xa3281f0b72c33c9cULL)), ((u64)(0x02858ffe00a8d09aLL)), ((u64)(0x1c2018d5f568fd4aLL)), ((u64)(0x020473319a20a6e2LL)), ((u64)(0xf9ccf48988a7fba9ULL)), ((u64)(0x033a51e8f69aa49cLL)), | ||
| 3351 | +((u64)(0xfb0a5d3ad3b99621ULL)), ((u64)(0x02950e53f87bb6e3LL)), ((u64)(0x2f3b7dc8a96144e7LL)), ((u64)(0x0210d8432d2fc583LL)), ((u64)(0xe52bfc7442353b0cULL)), ((u64)(0x034e26d1e1e608d1LL)), ((u64)(0xb756639034f76270ULL)), ((u64)(0x02a4ebdb1b1e6d74LL)), ((u64)(0x2c451c735d92b526LL)), ((u64)(0x021d897c15b1f12aLL)), ((u64)(0x13a1c71efc1deea3LL)), ((u64)(0x0362759355e981ddLL)), ((u64)(0x761b05b2634b2550LL)), ((u64)(0x02b52adc44bace4aLL)), ((u64)(0x91af37c1e908eaa6ULL)), ((u64)(0x022a88b036fbd83bLL)), | ||
| 3352 | +((u64)(0x82b1f2cfdb417770ULL)), ((u64)(0x03774119f192f392LL)), ((u64)(0xcef4c23fe29ac5f3ULL)), ((u64)(0x02c5cdae5adbf60eLL)), ((u64)(0x3f2a34ffe87bd190LL)), ((u64)(0x0237d7beaf165e72LL)), ((u64)(0x984387ffda5fb5b2ULL)), ((u64)(0x038c8c644b56fd83LL)), ((u64)(0xe0360666484c915bULL)), ((u64)(0x02d6d6b6a2abfe02LL)), ((u64)(0x802b3851d3707449ULL)), ((u64)(0x024578921bbccb35LL)), ((u64)(0x99dec082ebe72075ULL)), ((u64)(0x03a25a835f947855LL)), ((u64)(0xae4bcd358985b391ULL)), ((u64)(0x02e8486919439377LL)), | ||
| 3353 | +((u64)(0xbea30a913ad15c74ULL)), ((u64)(0x02536d20e102dc5fLL)), ((u64)(0xfdd1aa81f7b560b9ULL)), ((u64)(0x03b8ae9b019e2d65LL)), ((u64)(0x97daeece5fc44d61ULL)), ((u64)(0x02fa2548ce182451LL)), ((u64)(0xdfe258a51969d781ULL)), ((u64)(0x0261b76d71ace9daLL)), ((u64)(0x996a276e8f0fbf34ULL)), ((u64)(0x03cf8be24f7b0fc4LL)), ((u64)(0xe121b9253f3fcc2aULL)), ((u64)(0x030c6fe83f95a636LL)), ((u64)(0xb41afa8432997022ULL)), ((u64)(0x02705986994484f8LL)), ((u64)(0xecf7f739ea8f19cfULL)), ((u64)(0x03e6f5a4286da18dLL)), | ||
| 3354 | +((u64)(0x23f99294bba5ae40LL)), ((u64)(0x031f2ae9b9f14e0bLL)), ((u64)(0x4ffadbaa2fb7be99LL)), ((u64)(0x027f5587c7f43e6fLL)), ((u64)(0x7ff7c5dd1925fdc2LL)), ((u64)(0x03feef3fa6539718LL)), ((u64)(0xccc637e4141e649bULL)), ((u64)(0x033258ffb842df46LL)), ((u64)(0xd704f983434b83afULL)), ((u64)(0x028ead9960357f6bLL)), ((u64)(0x126a6135cf6f9c8cLL)), ((u64)(0x020bbe144cf79923LL)), ((u64)(0x83dd685618b29414ULL)), ((u64)(0x0345fced47f28e9eLL)), ((u64)(0x9cb12044e08edcddULL)), ((u64)(0x029e63f1065ba54bLL)), | ||
| 3355 | +((u64)(0x16f419d0b3a57d7dLL)), ((u64)(0x02184ff405161dd6LL)), ((u64)(0x8b20294dec3bfbfbULL)), ((u64)(0x035a19866e89c956LL)), ((u64)(0x3c19baa4bcfcc996LL)), ((u64)(0x02ae7ad1f207d445LL)), ((u64)(0xc9ae2eea30ca3adfULL)), ((u64)(0x02252f0e5b39769dLL)), ((u64)(0x0f7d17dd1add2afdLL)), ((u64)(0x036eb1b091f58a96LL)), ((u64)(0x3f97464a7be42264LL)), ((u64)(0x02bef48d41913babLL)), ((u64)(0xcc790508631ce850ULL)), ((u64)(0x02325d3dce0dc955LL)), ((u64)(0xe0c1a1a704fb0d4dULL)), ((u64)(0x0383c862e3494222LL)), | ||
| 3356 | +((u64)(0x4d67b4859d95a43eLL)), ((u64)(0x02cfd3824f6dce82LL)), ((u64)(0x711fc39e17aae9cbLL)), ((u64)(0x023fdc683f8b0b9bLL)), ((u64)(0xe832d2968c44a945ULL)), ((u64)(0x039960a6cc11ac2bLL)), ((u64)(0xecf575453d03ba9eULL)), ((u64)(0x02e11a1f09a7bcefLL)), ((u64)(0x572ac4376402fbb1LL)), ((u64)(0x024dae7f3aec9726LL)), ((u64)(0x58446d256cd192b5LL)), ((u64)(0x03af7d985e47583dLL)), ((u64)(0x79d0575123dadbc4LL)), ((u64)(0x02f2cae04b6c4697LL)), ((u64)(0x94a6ac40e97be303ULL)), ((u64)(0x025bd5803c569edfLL)), | ||
| 3357 | +((u64)(0x8771139b0f2c9e6cULL)), ((u64)(0x03c62266c6f0fe32LL)), ((u64)(0x9f8da948d8f07ebdULL)), ((u64)(0x0304e85238c0cb5bLL)), ((u64)(0xe60aedd3e0c06564ULL)), ((u64)(0x026a5374fa33d5e2LL)), ((u64)(0xa344afb9679a3bd2ULL)), ((u64)(0x03dd5254c3862304LL)), ((u64)(0xe903bfc78614fca8ULL)), ((u64)(0x031775109c6b4f36LL)), ((u64)(0xba6966393810ca20ULL)), ((u64)(0x02792a73b055d8f8LL)), ((u64)(0x2a423d2859b4769aLL)), ((u64)(0x03f510b91a22f4c1LL)), ((u64)(0xee9b642047c39215ULL)), ((u64)(0x032a73c7481bf700LL)), | ||
| 3358 | +((u64)(0xbee2b680396941aaULL)), ((u64)(0x02885c9f6ce32c00LL)), ((u64)(0xff1bc53361210155ULL)), ((u64)(0x0206b07f8a4f5666LL)), ((u64)(0x31c6085235019bbbLL)), ((u64)(0x033de73276e5570bLL)), ((u64)(0x27d1a041c4014963LL)), ((u64)(0x0297ec285f1ddf3cLL)), ((u64)(0xeca7b367d0010782ULL)), ((u64)(0x021323537f4b18fcLL)), ((u64)(0xadd91f0c8001a59dULL)), ((u64)(0x0351d21f3211c194LL)), ((u64)(0xf17a7f3d3334847eULL)), ((u64)(0x02a7db4c280e3476LL)), ((u64)(0x279532975c2a0398LL)), ((u64)(0x021fe2a3533e905fLL)), | ||
| 3359 | +((u64)(0xd8eeb75893766c26ULL)), ((u64)(0x0366376bb8641a31LL)), ((u64)(0x7a5892ad42c52352LL)), ((u64)(0x02b82c562d1ce1c1LL)), ((u64)(0xfb7a0ef102374f75ULL)), ((u64)(0x022cf044f0e3e7cdLL)), ((u64)(0xc59017e8038bb254ULL)), ((u64)(0x037b1a07e7d30c7cLL)), ((u64)(0x37a67986693c8eaaLL)), ((u64)(0x02c8e19feca8d6caLL)), ((u64)(0xf951fad1edca0bbbULL)), ((u64)(0x023a4e198a20abd4LL)), ((u64)(0x28832ae97c76792bLL)), ((u64)(0x03907cf5a9cddfbbLL)), ((u64)(0x2068ef21305ec756LL)), ((u64)(0x02d9fd9154a4b2fcLL)), | ||
| 3360 | +((u64)(0x19ed8c1a8d189f78LL)), ((u64)(0x0247fe0ddd508f30LL)), ((u64)(0x5caf4690e1c0ff26LL)), ((u64)(0x03a66349621a7eb3LL)), ((u64)(0x4a25d20d81673285LL)), ((u64)(0x02eb82a11b48655cLL)), ((u64)(0x3b5174d79ab8f537LL)), ((u64)(0x0256021a7c39eab0LL)), ((u64)(0x921bee25c45b21f1ULL)), ((u64)(0x03bcd02a605caab3LL)), ((u64)(0xdb498b5169e2818eULL)), ((u64)(0x02fd735519e3bbc2LL)), ((u64)(0x15d46f7454b53472LL)), ((u64)(0x02645c4414b62fcfLL)), ((u64)(0xefba4bed545520b6ULL)), ((u64)(0x03d3c6d35456b2e4LL)), | ||
| 3361 | +((u64)(0xf2fb6ff110441a2bULL)), ((u64)(0x030fd242a9def583LL)), ((u64)(0x8f2f8cc0d9d014efULL)), ((u64)(0x02730e9bbb18c469LL)), ((u64)(0xb1e5ae015c80217fULL)), ((u64)(0x03eb4a92c4f46d75LL)), ((u64)(0xc1848b344a001accULL)), ((u64)(0x0322a20f03f6bdf7LL)), ((u64)(0xce03a2903b3348a3ULL)), ((u64)(0x02821b3f365efe5fLL)), ((u64)(0xd802e873628f6d4fULL)), ((u64)(0x0201af65c518cb7fLL)), ((u64)(0x599e40b89db2487fLL)), ((u64)(0x0335e56fa1c14599LL)), ((u64)(0xe14b66fa17c1d399ULL)), ((u64)(0x029184594e3437adLL)), | ||
| 3362 | +((u64)(0x81091f2e7967dc7aULL)), ((u64)(0x020e037aa4f692f1LL)), ((u64)(0x9b41cb7d8f0c93f6ULL)), ((u64)(0x03499f2aa18a84b5LL)), ((u64)(0xaf67d5fe0c0a0ff8ULL)), ((u64)(0x02a14c221ad536f7LL)), ((u64)(0xf2b977fe70080cc7ULL)), ((u64)(0x021aa34e7bddc592LL)), ((u64)(0x1df58cca4cd9ae0bLL)), ((u64)(0x035dd2172c9608ebLL)), ((u64)(0xe4c470a1d7148b3cULL)), ((u64)(0x02b174df56de6d88LL)), ((u64)(0x83d05a1b1276d5caULL)), ((u64)(0x022790b2abe5246dLL)), ((u64)(0x9fb3c35e83f1560fULL)), ((u64)(0x0372811ddfd50715LL)), | ||
| 3363 | +((u64)(0xb2f635e5365aab3fULL)), ((u64)(0x02c200e4b310d277LL)), ((u64)(0xf591c4b75eaeef66ULL)), ((u64)(0x0234cd83c273db92LL)), ((u64)(0xef4fa125644b18a3ULL)), ((u64)(0x0387af39371fc5b7LL)), ((u64)(0x8c3fb41de9d5ad4fULL)), ((u64)(0x02d2f2942c196af9LL)), ((u64)(0x3cffc34b2177bdd9LL)), ((u64)(0x02425ba9bce12261LL)), ((u64)(0x94cc6bab68bf9628ULL)), ((u64)(0x039d5f75fb01d09bLL)), ((u64)(0x10a38955ed6611b9LL)), ((u64)(0x02e44c5e6267da16LL)), ((u64)(0xda1c6dde5784dafbULL)), ((u64)(0x02503d184eb97b44LL)), | ||
| 3364 | +((u64)(0xf693e2fd58d49191ULL)), ((u64)(0x03b394f3b128c53aLL)), ((u64)(0xc5431bfde0aa0e0eULL)), ((u64)(0x02f610c2f4209dc8LL)), ((u64)(0x6a9c1664b3bb3e72LL)), ((u64)(0x025e73cf29b3b16dLL)), ((u64)(0x10f9bd6dec5eca4fLL)), ((u64)(0x03ca52e50f85e8afLL)), ((u64)(0xda616457f04bd50cULL)), ((u64)(0x03084250d937ed58LL)), ((u64)(0xe1e783798d09773dULL)), ((u64)(0x026d01da475ff113LL)), ((u64)(0x030c058f480f252eLL)), ((u64)(0x03e19c9072331b53LL)), ((u64)(0x68d66ad906728425LL)), ((u64)(0x031ae3a6c1c27c42LL)), | ||
| 3365 | +((u64)(0x8711ef14052869b7ULL)), ((u64)(0x027be952349b969bLL)), ((u64)(0x0b4fe4ecd50d75f2LL)), ((u64)(0x03f97550542c242cLL)), ((u64)(0xa2a650bd773df7f5ULL)), ((u64)(0x032df7737689b689LL)), ((u64)(0xb551da312c31932aULL)), ((u64)(0x028b2c5c5ed49207LL)), ((u64)(0x5ddb14f4235adc22LL)), ((u64)(0x0208f049e576db39LL)), ((u64)(0x2fc4ee536bc49369LL)), ((u64)(0x034180763bf15ec2LL)), ((u64)(0xbfd0bea92303a921ULL)), ((u64)(0x029acd2b63277f01LL)), ((u64)(0x9973cbba8269541aULL)), ((u64)(0x021570ef8285ff34LL)), | ||
| 3366 | +((u64)(0x5bec792a6a42202aLL)), ((u64)(0x0355817f373ccb87LL)), ((u64)(0xe3239421ee9b4cefULL)), ((u64)(0x02aacdff5f63d605LL)), ((u64)(0xb5b6101b25490a59ULL)), ((u64)(0x02223e65e5e97804LL)), ((u64)(0x22bce691d541aa27LL)), ((u64)(0x0369fd6fd64259a1LL)), ((u64)(0xb563eba7ddce21b9ULL)), ((u64)(0x02bb31264501e14dLL)), ((u64)(0xf78322ecb171b494ULL)), ((u64)(0x022f5a850401810aLL)), ((u64)(0x259e9e47824f8753LL)), ((u64)(0x037ef73b399c01abLL)), ((u64)(0x1e187e9f9b72d2a9LL)), ((u64)(0x02cbf8fc2e1667bcLL)), | ||
| 3367 | +((u64)(0x4b46cbb2e2c24221LL)), ((u64)(0x023cc73024deb963LL)), ((u64)(0x120adf849e039d01LL)), ((u64)(0x039471e6a1645bd2LL)), ((u64)(0xdb3be603b19c7d9aULL)), ((u64)(0x02dd27ebb4504974LL)), ((u64)(0x7c2feb3627b0647cLL)), ((u64)(0x024a865629d9d45dLL)), ((u64)(0x2d197856a5e7072cLL)), ((u64)(0x03aa7089dc8fba2fLL)), ((u64)(0x8a7ac6abb7ec05bdULL)), ((u64)(0x02eec06e4a0c94f2LL)), ((u64)(0xd52f05562cbcd164ULL)), ((u64)(0x025899f1d4d6dd8eLL)), ((u64)(0x21e4d556adfae8a0LL)), ((u64)(0x03c0f64fbaf1627eLL)), | ||
| 3368 | +((u64)(0xe7ea444557fbed4dULL)), ((u64)(0x0300c50c958de864LL)), ((u64)(0xecbb69d1132ff10aULL)), ((u64)(0x0267040a113e5383LL)), ((u64)(0xadf8a94e851981aaULL)), ((u64)(0x03d8067681fd526cLL)), ((u64)(0x8b2d543ed0e13488ULL)), ((u64)(0x0313385ece6441f0LL)), ((u64)(0xd5bddcff0d80f6d3ULL)), ((u64)(0x0275c6b23eb69b26LL)), ((u64)(0x892fc7fe7c018aebULL)), ((u64)(0x03efa45064575ea4LL)), ((u64)(0x3a8c9ffec99ad589LL)), ((u64)(0x03261d0d1d12b21dLL)), ((u64)(0xc8707fff07af113bULL)), ((u64)(0x0284e40a7da88e7dLL)), | ||
| 3369 | +((u64)(0x39f39998d2f2742fLL)), ((u64)(0x0203e9a1fe2071feLL)), ((u64)(0x8fec28f484b7204bULL)), ((u64)(0x033975cffd00b663LL)), ((u64)(0xd989ba5d36f8e6a2ULL)), ((u64)(0x02945e3ffd9a2b82LL)), ((u64)(0x47a161e42bfa521cLL)), ((u64)(0x02104b66647b5602LL)), ((u64)(0x0c35696d132a1cf9LL)), ((u64)(0x034d4570a0c5566aLL)), ((u64)(0x09c454574288172dLL)), ((u64)(0x02a4378d4d6aab88LL)), ((u64)(0xa169dd129ba0128bULL)), ((u64)(0x021cf93dd7888939LL)), ((u64)(0x0242fb50f9001dabLL)), ((u64)(0x03618ec958da7529LL)), | ||
| 3370 | +((u64)(0x9b68c90d940017bcULL)), ((u64)(0x02b4723aad7b90edLL)), ((u64)(0x4920a0d7a999ac96LL)), ((u64)(0x0229f4fbbdfc73f1LL)), ((u64)(0x750101590f5c4757LL)), ((u64)(0x037654c5fcc71fe8LL)), ((u64)(0x2a6734473f7d05dfLL)), ((u64)(0x02c5109e63d27fedLL)), ((u64)(0xeeb8f69f65fd9e4cULL)), ((u64)(0x0237407eb641fff0LL)), ((u64)(0xe45b24323cc8fd46ULL)), ((u64)(0x038b9a6456cfffe7LL)), ((u64)(0xb6af502830a0ca9fULL)), ((u64)(0x02d6151d123fffecLL)), ((u64)(0xf88c402026e7087fULL)), ((u64)(0x0244ddb0db666656LL)), | ||
| 3371 | +((u64)(0x2746cd003e3e73feLL)), ((u64)(0x03a162b4923d708bLL)), ((u64)(0x1f6bd73364fec332LL)), ((u64)(0x02e7822a0e978d3cLL)), ((u64)(0xe5efdf5c50cbcf5bULL)), ((u64)(0x0252ce880bac70fcLL)), ((u64)(0x3cb2fefa1adfb22bLL)), ((u64)(0x03b7b0d9ac471b2eLL)), ((u64)(0x308f3261af195b56LL)), ((u64)(0x02f95a47bd05af58LL)), ((u64)(0x5a0c284e25ade2abLL)), ((u64)(0x0261150630d15913LL)), ((u64)(0x29ad0d49d5e30445LL)), ((u64)(0x03ce8809e7b55b52LL)), ((u64)(0x548a7107de4f369dLL)), ((u64)(0x030ba007ec9115dbLL)), ((u64)(0xdd3b8d9fe50c2bb1ULL)), ((u64)(0x026fb3398a0dab15LL)), ((u64)(0x952c15cca1ad12b5ULL)), ((u64)(0x03e5eb8f434911bcLL)), ((u64)(0x775677d6e7bda891LL)), ((u64)(0x031e560c35d40e30LL)), ((u64)(0xc5dec645863153a7ULL)), ((u64)(0x027eab3cf7dcd826LL))}; // fixed array const | ||
| 3372 | +bool v_memory_panic = false; // global 6 | ||
| 3373 | + | ||
| 3374 | +int_literal g_autostr_type_stack_len = 0; // global 6 | ||
| 3375 | + | ||
| 3376 | +int_literal g_autostr_addr_stack_len = 0; // global 6 | ||
| 3377 | + | ||
| 3378 | +int g_main_argc = ((int)(0)); // global 6 | ||
| 3379 | + | ||
| 3380 | +voidptr g_main_argv = ((void*)0); // global 6 | ||
| 3381 | + | ||
| 3382 | +voidptr g_live_reload_info; // global 6 | ||
| 3383 | + | ||
| 3384 | +/* skip C global: stdout */ | ||
| 3385 | + | ||
| 3386 | +/* skip C global: stderr */ | ||
| 3387 | + | ||
| 3388 | +/* skip C global: _wyp */ | ||
| 3389 | + | ||
| 3390 | +static IError _const_error_sentinel; // inited later | ||
| 3391 | +static IError _const_none__; // inited later | ||
| 3392 | +static const i8 _const_min_i8 = -128; // precomputed2 | ||
| 3393 | +static const i8 _const_max_i8 = 127; // precomputed2 | ||
| 3394 | +static const i16 _const_min_i16 = -32768; // precomputed2 | ||
| 3395 | +static const i16 _const_max_i16 = 32767; // precomputed2 | ||
| 3396 | +static const i32 _const_min_i32 = -2147483648; // precomputed2 | ||
| 3397 | +static const i32 _const_max_i32 = 2147483647; // precomputed2 | ||
| 3398 | +static i64 _const_min_i64; // inited later | ||
| 3399 | +static i64 _const_max_i64; // inited later | ||
| 3400 | +static const u8 _const_min_u8 = 0; // precomputed2 | ||
| 3401 | +static const u8 _const_max_u8 = 255; // precomputed2 | ||
| 3402 | +static const u16 _const_min_u16 = 0; // precomputed2 | ||
| 3403 | +static const u16 _const_max_u16 = 65535; // precomputed2 | ||
| 3404 | +static const u32 _const_min_u32 = 0; // precomputed2 | ||
| 3405 | +static const u32 _const_max_u32 = 4294967295; // precomputed2 | ||
| 3406 | +static const u64 _const_min_u64 = 0U; // precomputed2 | ||
| 3407 | +static const u64 _const_max_u64 = 18446744073709551615U; // precomputed2 | ||
| 3408 | +static const u32 _const_hash_mask = 16777215; // precomputed2 | ||
| 3409 | +static const u32 _const_probe_inc = 16777216; // precomputed2 | ||
| 3410 | +static Array_fixed_i32_1264 _const_rune_maps = {((i32)(0xB5)), 0xB5, 743, 0, 0xC0, 0xD6, 0, 32, 0xD8, 0xDE, 0, 32, 0xE0, 0xF6, -32, 0, | ||
| 3411 | +0xF8, 0xFE, -32, 0, 0xFF, 0xFF, 121, 0, 0x100, 0x12F, -3, -3, 0x130, 0x130, 0, -199, | ||
| 3412 | +0x131, 0x131, -232, 0, 0x132, 0x137, -3, -3, 0x139, 0x148, -3, -3, 0x14A, 0x177, -3, -3, | ||
| 3413 | +0x178, 0x178, 0, -121, 0x179, 0x17E, -3, -3, 0x17F, 0x17F, -300, 0, 0x180, 0x180, 195, 0, | ||
| 3414 | +0x181, 0x181, 0, 210, 0x182, 0x185, -3, -3, 0x186, 0x186, 0, 206, 0x187, 0x188, -3, -3, | ||
| 3415 | +0x189, 0x18A, 0, 205, 0x18B, 0x18C, -3, -3, 0x18E, 0x18E, 0, 79, 0x18F, 0x18F, 0, 202, | ||
| 3416 | +0x190, 0x190, 0, 203, 0x191, 0x192, -3, -3, 0x193, 0x193, 0, 205, 0x194, 0x194, 0, 207, | ||
| 3417 | +0x195, 0x195, 97, 0, 0x196, 0x196, 0, 211, 0x197, 0x197, 0, 209, 0x198, 0x199, -3, -3, | ||
| 3418 | +0x19A, 0x19A, 163, 0, 0x19C, 0x19C, 0, 211, 0x19D, 0x19D, 0, 213, 0x19E, 0x19E, 130, 0, | ||
| 3419 | +0x19F, 0x19F, 0, 214, 0x1A0, 0x1A5, -3, -3, 0x1A6, 0x1A6, 0, 218, 0x1A7, 0x1A8, -3, -3, | ||
| 3420 | +0x1A9, 0x1A9, 0, 218, 0x1AC, 0x1AD, -3, -3, 0x1AE, 0x1AE, 0, 218, 0x1AF, 0x1B0, -3, -3, | ||
| 3421 | +0x1B1, 0x1B2, 0, 217, 0x1B3, 0x1B6, -3, -3, 0x1B7, 0x1B7, 0, 219, 0x1B8, 0x1B9, -3, -3, | ||
| 3422 | +0x1BC, 0x1BD, -3, -3, 0x1BF, 0x1BF, 56, 0, 0x1C4, 0x1CC, -2, -2, 0x1CD, 0x1DC, -3, -3, | ||
| 3423 | +0x1DD, 0x1DD, -79, 0, 0x1DE, 0x1EF, -3, -3, 0x1F1, 0x1F3, -2, -2, 0x1F4, 0x1F5, -3, -3, | ||
| 3424 | +0x1F6, 0x1F6, 0, -97, 0x1F7, 0x1F7, 0, -56, 0x1F8, 0x21F, -3, -3, 0x220, 0x220, 0, -130, | ||
| 3425 | +0x222, 0x233, -3, -3, 0x23A, 0x23A, 0, 10795, 0x23B, 0x23C, -3, -3, 0x23D, 0x23D, 0, -163, | ||
| 3426 | +0x23E, 0x23E, 0, 10792, 0x23F, 0x240, 10815, 0, 0x241, 0x242, -3, -3, 0x243, 0x243, 0, -195, | ||
| 3427 | +0x244, 0x244, 0, 69, 0x245, 0x245, 0, 71, 0x246, 0x24F, -3, -3, 0x250, 0x250, 10783, 0, | ||
| 3428 | +0x251, 0x251, 10780, 0, 0x252, 0x252, 10782, 0, 0x253, 0x253, -210, 0, 0x254, 0x254, -206, 0, | ||
| 3429 | +0x256, 0x257, -205, 0, 0x259, 0x259, -202, 0, 0x25B, 0x25B, -203, 0, 0x25C, 0x25C, 42319, 0, | ||
| 3430 | +0x260, 0x260, -205, 0, 0x261, 0x261, 42315, 0, 0x263, 0x263, -207, 0, 0x265, 0x265, 42280, 0, | ||
| 3431 | +0x266, 0x266, 42308, 0, 0x268, 0x268, -209, 0, 0x269, 0x269, -211, 0, 0x26A, 0x26A, 42308, 0, | ||
| 3432 | +0x26B, 0x26B, 10743, 0, 0x26C, 0x26C, 42305, 0, 0x26F, 0x26F, -211, 0, 0x271, 0x271, 10749, 0, | ||
| 3433 | +0x272, 0x272, -213, 0, 0x275, 0x275, -214, 0, 0x27D, 0x27D, 10727, 0, 0x280, 0x280, -218, 0, | ||
| 3434 | +0x282, 0x282, 42307, 0, 0x283, 0x283, -218, 0, 0x287, 0x287, 42282, 0, 0x288, 0x288, -218, 0, | ||
| 3435 | +0x289, 0x289, -69, 0, 0x28A, 0x28B, -217, 0, 0x28C, 0x28C, -71, 0, 0x292, 0x292, -219, 0, | ||
| 3436 | +0x29D, 0x29D, 42261, 0, 0x29E, 0x29E, 42258, 0, 0x345, 0x345, 84, 0, 0x370, 0x373, -3, -3, | ||
| 3437 | +0x376, 0x377, -3, -3, 0x37B, 0x37D, 130, 0, 0x37F, 0x37F, 0, 116, 0x386, 0x386, 0, 38, | ||
| 3438 | +0x388, 0x38A, 0, 37, 0x38C, 0x38C, 0, 64, 0x38E, 0x38F, 0, 63, 0x391, 0x3A1, 0, 32, | ||
| 3439 | +0x3A3, 0x3AB, 0, 32, 0x3AC, 0x3AC, -38, 0, 0x3AD, 0x3AF, -37, 0, 0x3B1, 0x3C1, -32, 0, | ||
| 3440 | +0x3C2, 0x3C2, -31, 0, 0x3C3, 0x3CB, -32, 0, 0x3CC, 0x3CC, -64, 0, 0x3CD, 0x3CE, -63, 0, | ||
| 3441 | +0x3CF, 0x3CF, 0, 8, 0x3D0, 0x3D0, -62, 0, 0x3D1, 0x3D1, -57, 0, 0x3D5, 0x3D5, -47, 0, | ||
| 3442 | +0x3D6, 0x3D6, -54, 0, 0x3D7, 0x3D7, -8, 0, 0x3D8, 0x3EF, -3, -3, 0x3F0, 0x3F0, -86, 0, | ||
| 3443 | +0x3F1, 0x3F1, -80, 0, 0x3F2, 0x3F2, 7, 0, 0x3F3, 0x3F3, -116, 0, 0x3F4, 0x3F4, 0, -60, | ||
| 3444 | +0x3F5, 0x3F5, -96, 0, 0x3F7, 0x3F8, -3, -3, 0x3F9, 0x3F9, 0, -7, 0x3FA, 0x3FB, -3, -3, | ||
| 3445 | +0x3FD, 0x3FF, 0, -130, 0x400, 0x40F, 0, 80, 0x410, 0x42F, 0, 32, 0x430, 0x44F, -32, 0, | ||
| 3446 | +0x450, 0x45F, -80, 0, 0x460, 0x481, -3, -3, 0x48A, 0x4BF, -3, -3, 0x4C0, 0x4C0, 0, 15, | ||
| 3447 | +0x4C1, 0x4CE, -3, -3, 0x4CF, 0x4CF, -15, 0, 0x4D0, 0x52F, -3, -3, 0x531, 0x556, 0, 48, | ||
| 3448 | +0x561, 0x586, -48, 0, 0x10A0, 0x10C5, 0, 7264, 0x10C7, 0x10C7, 0, 7264, 0x10CD, 0x10CD, 0, 7264, | ||
| 3449 | +0x10D0, 0x10FA, 3008, 0, 0x10FD, 0x10FF, 3008, 0, 0x13A0, 0x13EF, 0, 38864, 0x13F0, 0x13F5, 0, 8, | ||
| 3450 | +0x13F8, 0x13FD, -8, 0, 0x1C80, 0x1C80, -6254, 0, 0x1C81, 0x1C81, -6253, 0, 0x1C82, 0x1C82, -6244, 0, | ||
| 3451 | +0x1C83, 0x1C84, -6242, 0, 0x1C85, 0x1C85, -6243, 0, 0x1C86, 0x1C86, -6236, 0, 0x1C87, 0x1C87, -6181, 0, | ||
| 3452 | +0x1C88, 0x1C88, 35266, 0, 0x1C90, 0x1CBA, 0, -3008, 0x1CBD, 0x1CBF, 0, -3008, 0x1D79, 0x1D79, 35332, 0, | ||
| 3453 | +0x1D7D, 0x1D7D, 3814, 0, 0x1D8E, 0x1D8E, 35384, 0, 0x1E00, 0x1E95, -3, -3, 0x1E9B, 0x1E9B, -59, 0, | ||
| 3454 | +0x1E9E, 0x1E9E, 0, -7615, 0x1EA0, 0x1EFF, -3, -3, 0x1F00, 0x1F07, 8, 0, 0x1F08, 0x1F0F, 0, -8, | ||
| 3455 | +0x1F10, 0x1F15, 8, 0, 0x1F18, 0x1F1D, 0, -8, 0x1F20, 0x1F27, 8, 0, 0x1F28, 0x1F2F, 0, -8, | ||
| 3456 | +0x1F30, 0x1F37, 8, 0, 0x1F38, 0x1F3F, 0, -8, 0x1F40, 0x1F45, 8, 0, 0x1F48, 0x1F4D, 0, -8, | ||
| 3457 | +0x1F51, 0x1F51, 8, 0, 0x1F53, 0x1F53, 8, 0, 0x1F55, 0x1F55, 8, 0, 0x1F57, 0x1F57, 8, 0, | ||
| 3458 | +0x1F59, 0x1F59, 0, -8, 0x1F5B, 0x1F5B, 0, -8, 0x1F5D, 0x1F5D, 0, -8, 0x1F5F, 0x1F5F, 0, -8, | ||
| 3459 | +0x1F60, 0x1F67, 8, 0, 0x1F68, 0x1F6F, 0, -8, 0x1F70, 0x1F71, 74, 0, 0x1F72, 0x1F75, 86, 0, | ||
| 3460 | +0x1F76, 0x1F77, 100, 0, 0x1F78, 0x1F79, 128, 0, 0x1F7A, 0x1F7B, 112, 0, 0x1F7C, 0x1F7D, 126, 0, | ||
| 3461 | +0x1F80, 0x1F87, 8, 0, 0x1F88, 0x1F8F, 0, -8, 0x1F90, 0x1F97, 8, 0, 0x1F98, 0x1F9F, 0, -8, | ||
| 3462 | +0x1FA0, 0x1FA7, 8, 0, 0x1FA8, 0x1FAF, 0, -8, 0x1FB0, 0x1FB1, 8, 0, 0x1FB3, 0x1FB3, 9, 0, | ||
| 3463 | +0x1FB8, 0x1FB9, 0, -8, 0x1FBA, 0x1FBB, 0, -74, 0x1FBC, 0x1FBC, 0, -9, 0x1FBE, 0x1FBE, -7205, 0, | ||
| 3464 | +0x1FC3, 0x1FC3, 9, 0, 0x1FC8, 0x1FCB, 0, -86, 0x1FCC, 0x1FCC, 0, -9, 0x1FD0, 0x1FD1, 8, 0, | ||
| 3465 | +0x1FD8, 0x1FD9, 0, -8, 0x1FDA, 0x1FDB, 0, -100, 0x1FE0, 0x1FE1, 8, 0, 0x1FE5, 0x1FE5, 7, 0, | ||
| 3466 | +0x1FE8, 0x1FE9, 0, -8, 0x1FEA, 0x1FEB, 0, -112, 0x1FEC, 0x1FEC, 0, -7, 0x1FF3, 0x1FF3, 9, 0, | ||
| 3467 | +0x1FF8, 0x1FF9, 0, -128, 0x1FFA, 0x1FFB, 0, -126, 0x1FFC, 0x1FFC, 0, -9, 0x2126, 0x2126, 0, -7517, | ||
| 3468 | +0x212A, 0x212A, 0, -8383, 0x212B, 0x212B, 0, -8262, 0x2132, 0x2132, 0, 28, 0x214E, 0x214E, -28, 0, | ||
| 3469 | +0x2160, 0x216F, 0, 16, 0x2170, 0x217F, -16, 0, 0x2183, 0x2184, -3, -3, 0x24B6, 0x24CF, 0, 26, | ||
| 3470 | +0x24D0, 0x24E9, -26, 0, 0x2C00, 0x2C2F, 0, 48, 0x2C30, 0x2C5F, -48, 0, 0x2C60, 0x2C61, -3, -3, | ||
| 3471 | +0x2C62, 0x2C62, 0, -10743, 0x2C63, 0x2C63, 0, -3814, 0x2C64, 0x2C64, 0, -10727, 0x2C65, 0x2C65, -10795, 0, | ||
| 3472 | +0x2C66, 0x2C66, -10792, 0, 0x2C67, 0x2C6C, -3, -3, 0x2C6D, 0x2C6D, 0, -10780, 0x2C6E, 0x2C6E, 0, -10749, | ||
| 3473 | +0x2C6F, 0x2C6F, 0, -10783, 0x2C70, 0x2C70, 0, -10782, 0x2C72, 0x2C73, -3, -3, 0x2C75, 0x2C76, -3, -3, | ||
| 3474 | +0x2C7E, 0x2C7F, 0, -10815, 0x2C80, 0x2CE3, -3, -3, 0x2CEB, 0x2CEE, -3, -3, 0x2CF2, 0x2CF3, -3, -3, | ||
| 3475 | +0x2D00, 0x2D25, -7264, 0, 0x2D27, 0x2D27, -7264, 0, 0x2D2D, 0x2D2D, -7264, 0, 0xA640, 0xA66D, -3, -3, | ||
| 3476 | +0xA680, 0xA69B, -3, -3, 0xA722, 0xA72F, -3, -3, 0xA732, 0xA76F, -3, -3, 0xA779, 0xA77C, -3, -3, | ||
| 3477 | +0xA77D, 0xA77D, 0, -35332, 0xA77E, 0xA787, -3, -3, 0xA78B, 0xA78C, -3, -3, 0xA78D, 0xA78D, 0, -42280, | ||
| 3478 | +0xA790, 0xA793, -3, -3, 0xA794, 0xA794, 48, 0, 0xA796, 0xA7A9, -3, -3, 0xA7AA, 0xA7AA, 0, -42308, | ||
| 3479 | +0xA7AB, 0xA7AB, 0, -42319, 0xA7AC, 0xA7AC, 0, -42315, 0xA7AD, 0xA7AD, 0, -42305, 0xA7AE, 0xA7AE, 0, -42308, | ||
| 3480 | +0xA7B0, 0xA7B0, 0, -42258, 0xA7B1, 0xA7B1, 0, -42282, 0xA7B2, 0xA7B2, 0, -42261, 0xA7B3, 0xA7B3, 0, 928, | ||
| 3481 | +0xA7B4, 0xA7C3, -3, -3, 0xA7C4, 0xA7C4, 0, -48, 0xA7C5, 0xA7C5, 0, -42307, 0xA7C6, 0xA7C6, 0, -35384, | ||
| 3482 | +0xA7C7, 0xA7CA, -3, -3, 0xA7D0, 0xA7D1, -3, -3, 0xA7D6, 0xA7D9, -3, -3, 0xA7F5, 0xA7F6, -3, -3, | ||
| 3483 | +0xAB53, 0xAB53, -928, 0, 0xAB70, 0xABBF, -38864, 0, 0xFF21, 0xFF3A, 0, 32, 0xFF41, 0xFF5A, -32, 0, | ||
| 3484 | +0x10400, 0x10427, 0, 40, 0x10428, 0x1044F, -40, 0, 0x104B0, 0x104D3, 0, 40, 0x104D8, 0x104FB, -40, 0, | ||
| 3485 | +0x10570, 0x1057A, 0, 39, 0x1057C, 0x1058A, 0, 39, 0x1058C, 0x10592, 0, 39, 0x10594, 0x10595, 0, 39, | ||
| 3486 | +0x10597, 0x105A1, -39, 0, 0x105A3, 0x105B1, -39, 0, 0x105B3, 0x105B9, -39, 0, 0x105BB, 0x105BC, -39, 0, | ||
| 3487 | +0x10C80, 0x10CB2, 0, 64, 0x10CC0, 0x10CF2, -64, 0, 0x118A0, 0x118BF, 0, 32, 0x118C0, 0x118DF, -32, 0, | ||
| 3488 | +0x16E40, 0x16E5F, 0, 32, 0x16E60, 0x16E7F, -32, 0, 0x1E900, 0x1E921, 0, 34, 0x1E922, 0x1E943, -34, 0}; // fixed array const | ||
| 3489 | +static const u8 _const_str_intp_has_dynamic_width = 1; // precomputed2 | ||
| 3490 | +static const u8 _const_str_intp_has_dynamic_precision = 2; // precomputed2 | ||
| 3491 | +static rune _const_utf8_replacement_rune; // inited later | ||
| 3492 | +static u32 _const_builtin__closure__closure_size_1; // inited later | ||
| 3493 | +Array_fixed_int_64 g_autostr_type_stack = {0}; // global 6 | ||
| 3494 | + | ||
| 3495 | +Array_fixed_voidptr_64 g_autostr_addr_stack = {0}; // global 6 | ||
| 3496 | + | ||
| 3497 | +static int _const_builtin__closure__closure_size; // inited later | ||
| 3498 | + | ||
| 3499 | +// V interface table: | ||
| 3500 | +static IError I_None___to_Interface_IError(None__* x); | ||
| 3501 | +enum { _IError_None___index = 1 }; | ||
| 3502 | +static IError I_voidptr_to_Interface_IError(voidptr* x); | ||
| 3503 | +enum { _IError_voidptr_index = 2 }; | ||
| 3504 | +static IError I_MessageError_to_Interface_IError(MessageError* x); | ||
| 3505 | +enum { _IError_MessageError_index = 3 }; | ||
| 3506 | +static IError I_Error_to_Interface_IError(Error* x); | ||
| 3507 | +enum { _IError_Error_index = 4 }; | ||
| 3508 | +// ^^^ number of types for interface IError: 4 | ||
| 3509 | + | ||
| 3510 | +// Methods wrapper for interface "IError" | ||
| 3511 | +static inline int builtin__None___code_Interface_IError_method_wrapper(None__* err) { | ||
| 3512 | + return builtin__Error_code(err->Error); | ||
| 3513 | +} | ||
| 3514 | +static inline int builtin__None___code_Interface_IError_method_adapter(void* _x) { | ||
| 3515 | + return builtin__None___code_Interface_IError_method_wrapper((None__*)_x); | ||
| 3516 | +} | ||
| 3517 | +static inline string builtin__None___msg_Interface_IError_method_wrapper(None__* err) { | ||
| 3518 | + return builtin__Error_msg(err->Error); | ||
| 3519 | +} | ||
| 3520 | +static inline string builtin__None___msg_Interface_IError_method_adapter(void* _x) { | ||
| 3521 | + return builtin__None___msg_Interface_IError_method_wrapper((None__*)_x); | ||
| 3522 | +} | ||
| 3523 | +static inline int builtin__MessageError_code_Interface_IError_method_wrapper(MessageError* err) { | ||
| 3524 | + return builtin__MessageError_code(*err); | ||
| 3525 | +} | ||
| 3526 | +static inline int builtin__MessageError_code_Interface_IError_method_adapter(void* _x) { | ||
| 3527 | + return builtin__MessageError_code_Interface_IError_method_wrapper((MessageError*)_x); | ||
| 3528 | +} | ||
| 3529 | +static inline string builtin__MessageError_msg_Interface_IError_method_wrapper(MessageError* err) { | ||
| 3530 | + return builtin__MessageError_msg(*err); | ||
| 3531 | +} | ||
| 3532 | +static inline string builtin__MessageError_msg_Interface_IError_method_adapter(void* _x) { | ||
| 3533 | + return builtin__MessageError_msg_Interface_IError_method_wrapper((MessageError*)_x); | ||
| 3534 | +} | ||
| 3535 | +static inline int builtin__Error_code_Interface_IError_method_wrapper(Error* err) { | ||
| 3536 | + return builtin__Error_code(*err); | ||
| 3537 | +} | ||
| 3538 | +static inline int builtin__Error_code_Interface_IError_method_adapter(void* _x) { | ||
| 3539 | + return builtin__Error_code_Interface_IError_method_wrapper((Error*)_x); | ||
| 3540 | +} | ||
| 3541 | +static inline string builtin__Error_msg_Interface_IError_method_wrapper(Error* err) { | ||
| 3542 | + return builtin__Error_msg(*err); | ||
| 3543 | +} | ||
| 3544 | +static inline string builtin__Error_msg_Interface_IError_method_adapter(void* _x) { | ||
| 3545 | + return builtin__Error_msg_Interface_IError_method_wrapper((Error*)_x); | ||
| 3546 | +} | ||
| 3547 | + | ||
| 3548 | +struct _IError_interface_methods { | ||
| 3549 | + int (*_method_code)(void* _); | ||
| 3550 | + string (*_method_msg)(void* _); | ||
| 3551 | +}; | ||
| 3552 | + | ||
| 3553 | +struct _IError_interface_methods IError_name_table[5] = { | ||
| 3554 | + {0}, | ||
| 3555 | + { | ||
| 3556 | + ._method_code = builtin__None___code_Interface_IError_method_adapter, | ||
| 3557 | + ._method_msg = builtin__None___msg_Interface_IError_method_adapter, | ||
| 3558 | + }, | ||
| 3559 | + { | ||
| 3560 | + ._method_code = (void*) 0, | ||
| 3561 | + ._method_msg = (void*) 0, | ||
| 3562 | + }, | ||
| 3563 | + { | ||
| 3564 | + ._method_code = builtin__MessageError_code_Interface_IError_method_adapter, | ||
| 3565 | + ._method_msg = builtin__MessageError_msg_Interface_IError_method_adapter, | ||
| 3566 | + }, | ||
| 3567 | + { | ||
| 3568 | + ._method_code = builtin__Error_code_Interface_IError_method_adapter, | ||
| 3569 | + ._method_msg = builtin__Error_msg_Interface_IError_method_adapter, | ||
| 3570 | + }, | ||
| 3571 | +}; | ||
| 3572 | + | ||
| 3573 | + | ||
| 3574 | +// Casting functions for converting "None__" to interface "IError" | ||
| 3575 | + | ||
| 3576 | +static inline IError I_None___to_Interface_IError(None__* x) { | ||
| 3577 | +return (IError) { | ||
| 3578 | + ._None__ = x, | ||
| 3579 | + ._typ = _IError_None___index, | ||
| 3580 | + ._methods = &IError_name_table[_IError_None___index], | ||
| 3581 | + }; | ||
| 3582 | +} | ||
| 3583 | + | ||
| 3584 | +// Casting functions for converting "voidptr" to interface "IError" | ||
| 3585 | + | ||
| 3586 | +static inline IError I_voidptr_to_Interface_IError(voidptr* x) { | ||
| 3587 | +return (IError) { | ||
| 3588 | + ._voidptr = x, | ||
| 3589 | + ._typ = _IError_voidptr_index, | ||
| 3590 | + ._methods = &IError_name_table[_IError_voidptr_index], | ||
| 3591 | + }; | ||
| 3592 | +} | ||
| 3593 | + | ||
| 3594 | +// Casting functions for converting "MessageError" to interface "IError" | ||
| 3595 | + | ||
| 3596 | +static inline IError I_MessageError_to_Interface_IError(MessageError* x) { | ||
| 3597 | +return (IError) { | ||
| 3598 | + ._MessageError = x, | ||
| 3599 | + ._typ = _IError_MessageError_index, | ||
| 3600 | + ._methods = &IError_name_table[_IError_MessageError_index], | ||
| 3601 | + }; | ||
| 3602 | +} | ||
| 3603 | + | ||
| 3604 | +// Casting functions for converting "Error" to interface "IError" | ||
| 3605 | + | ||
| 3606 | +static inline IError I_Error_to_Interface_IError(Error* x) { | ||
| 3607 | +return (IError) { | ||
| 3608 | + ._Error = x, | ||
| 3609 | + ._typ = _IError_Error_index, | ||
| 3610 | + ._methods = &IError_name_table[_IError_Error_index], | ||
| 3611 | + }; | ||
| 3612 | +} | ||
| 3613 | + | ||
| 3614 | + | ||
| 3615 | +static inline IError __v_interface_clone_variant__IError__None__(void* x) { | ||
| 3616 | +return I_None___to_Interface_IError((None__*)builtin__memdup(x, sizeof(None__))); | ||
| 3617 | +} | ||
| 3618 | + | ||
| 3619 | +static inline IError __v_interface_clone_variant__IError__voidptr(void* x) { | ||
| 3620 | +return I_voidptr_to_Interface_IError((voidptr*)builtin__memdup(x, sizeof(voidptr))); | ||
| 3621 | +} | ||
| 3622 | + | ||
| 3623 | +static inline IError __v_interface_clone_variant__IError__MessageError(void* x) { | ||
| 3624 | +return I_MessageError_to_Interface_IError((MessageError*)builtin__memdup(x, sizeof(MessageError))); | ||
| 3625 | +} | ||
| 3626 | + | ||
| 3627 | +static inline IError __v_interface_clone_variant__IError__Error(void* x) { | ||
| 3628 | +return I_Error_to_Interface_IError((Error*)builtin__memdup(x, sizeof(Error))); | ||
| 3629 | +} | ||
| 3630 | + | ||
| 3631 | +static inline IError __v_interface_clone__IError(IError x) { | ||
| 3632 | + if (x._object == 0) { | ||
| 3633 | + return x; | ||
| 3634 | + } | ||
| 3635 | + if (x._typ == _IError_None___index) { | ||
| 3636 | + return __v_interface_clone_variant__IError__None__(x._object); | ||
| 3637 | + } | ||
| 3638 | + if (x._typ == _IError_voidptr_index) { | ||
| 3639 | + return __v_interface_clone_variant__IError__voidptr(x._object); | ||
| 3640 | + } | ||
| 3641 | + if (x._typ == _IError_MessageError_index) { | ||
| 3642 | + return __v_interface_clone_variant__IError__MessageError(x._object); | ||
| 3643 | + } | ||
| 3644 | + if (x._typ == _IError_Error_index) { | ||
| 3645 | + return __v_interface_clone_variant__IError__Error(x._object); | ||
| 3646 | + } | ||
| 3647 | + return x; | ||
| 3648 | +} | ||
| 3649 | + | ||
| 3650 | + | ||
| 3651 | +// V sort fn definitions: | ||
| 3652 | +VV_LOC int compare_11734835982493514523_RepIndex_by_idx_expr_612e6964780a3c0a622e696478(RepIndex* a, RepIndex* b) { | ||
| 3653 | + if (a->idx < b->idx) return -1; | ||
| 3654 | + if (b->idx < a->idx) return 1; | ||
| 3655 | + return 0; | ||
| 3656 | +} | ||
| 3657 | + | ||
| 3658 | +VV_LOC int compare_11734835982493514523_RepIndex_by_idx_expr_612e6964780a3c0a622e696478_qsort_adapter(const void* a, const void* b) { | ||
| 3659 | + return compare_11734835982493514523_RepIndex_by_idx_expr_612e6964780a3c0a622e696478((RepIndex*)a, (RepIndex*)b); | ||
| 3660 | +} | ||
| 3661 | + | ||
| 3662 | +VV_LOC int builtin__compare_lower_strings_qsort_adapter(const void* a, const void* b) { | ||
| 3663 | + return builtin__compare_lower_strings((string*)a, (string*)b); | ||
| 3664 | +} | ||
| 3665 | + | ||
| 3666 | +VV_LOC int builtin__compare_strings_by_len_qsort_adapter(const void* a, const void* b) { | ||
| 3667 | + return builtin__compare_strings_by_len((string*)a, (string*)b); | ||
| 3668 | +} | ||
| 3669 | + | ||
| 3670 | +static inline u64 VSAFE_DIV_u64(u64 x, u64 y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("division by zero")); } return x / y; } | ||
| 3671 | +static inline u64 VSAFE_MOD_u64(u64 x, u64 y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("modulo by zero")); } return x % y; } | ||
| 3672 | +static inline int VSAFE_DIV_int(int x, int y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("division by zero")); } return x / y; } | ||
| 3673 | +static inline usize VSAFE_MOD_usize(usize x, usize y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("modulo by zero")); } return x % y; } | ||
| 3674 | +static inline u32 VSAFE_DIV_u32(u32 x, u32 y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("division by zero")); } return x / y; } | ||
| 3675 | +static inline u32 VSAFE_MOD_u32(u32 x, u32 y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("modulo by zero")); } return x % y; } | ||
| 3676 | +static inline i64 VSAFE_DIV_i64(i64 x, i64 y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("division by zero")); } return x / y; } | ||
| 3677 | +static inline int VSAFE_MOD_int(int x, int y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("modulo by zero")); } return x % y; } | ||
| 3678 | +static inline i64 VSAFE_MOD_i64(i64 x, i64 y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("modulo by zero")); } return x % y; } | ||
| 3679 | +static inline rune VSAFE_MOD_rune(rune x, rune y) { if (_unlikely_(0 == y)) { builtin___v_panic(_S("modulo by zero")); } return x % y; } | ||
| 3680 | + | ||
| 3681 | +// end of V out (header) | ||
| 3682 | + | ||
| 3683 | +// V auto functions: | ||
| 3684 | +static bool Array_u8_contains(Array_u8 a, u8 v) { | ||
| 3685 | + for (int i = 0; i < a.len; ++i) { | ||
| 3686 | + if (((u8*)a.data)[i] == v) { | ||
| 3687 | + return true; | ||
| 3688 | + } | ||
| 3689 | + } | ||
| 3690 | + return false; | ||
| 3691 | +} | ||
| 3692 | + | ||
| 3693 | +static inline bool Array_rune_arr_eq(Array_rune a, Array_rune b) { | ||
| 3694 | + if (a.len != b.len) { | ||
| 3695 | + return false; | ||
| 3696 | + } | ||
| 3697 | + for (int i = 0; i < a.len; ++i) { | ||
| 3698 | + if (*((rune*)((byte*)a.data+(i*a.element_size))) != *((rune*)((byte*)b.data+(i*b.element_size)))) { | ||
| 3699 | + return false; | ||
| 3700 | + } | ||
| 3701 | + } | ||
| 3702 | + return true; | ||
| 3703 | +} | ||
| 3704 | + | ||
| 3705 | +static inline bool builtin__closure__ClosureLifetimeRecord_struct_eq(builtin__closure__ClosureLifetimeRecord a, builtin__closure__ClosureLifetimeRecord b) { | ||
| 3706 | + return a.exec_ptr == b.exec_ptr | ||
| 3707 | + && a.generation == b.generation; | ||
| 3708 | +} | ||
| 3709 | + | ||
| 3710 | +static inline bool Array_builtin__closure__ClosureLifetimeRecord_arr_eq(Array_builtin__closure__ClosureLifetimeRecord a, Array_builtin__closure__ClosureLifetimeRecord b) { | ||
| 3711 | + if (a.len != b.len) { | ||
| 3712 | + return false; | ||
| 3713 | + } | ||
| 3714 | + for (int i = 0; i < a.len; ++i) { | ||
| 3715 | + if (!builtin__closure__ClosureLifetimeRecord_struct_eq(((builtin__closure__ClosureLifetimeRecord*)a.data)[i], ((builtin__closure__ClosureLifetimeRecord*)b.data)[i])) { | ||
| 3716 | + return false; | ||
| 3717 | + } | ||
| 3718 | + } | ||
| 3719 | + return true; | ||
| 3720 | +} | ||
| 3721 | + | ||
| 3722 | +static inline bool builtin__closure__ClosureLifetimeFrame_struct_eq(builtin__closure__ClosureLifetimeFrame a, builtin__closure__ClosureLifetimeFrame b) { | ||
| 3723 | + return a.start == b.start | ||
| 3724 | + && a.end == b.end; | ||
| 3725 | +} | ||
| 3726 | + | ||
| 3727 | +static inline bool Array_builtin__closure__ClosureLifetimeFrame_arr_eq(Array_builtin__closure__ClosureLifetimeFrame a, Array_builtin__closure__ClosureLifetimeFrame b) { | ||
| 3728 | + if (a.len != b.len) { | ||
| 3729 | + return false; | ||
| 3730 | + } | ||
| 3731 | + for (int i = 0; i < a.len; ++i) { | ||
| 3732 | + if (!builtin__closure__ClosureLifetimeFrame_struct_eq(((builtin__closure__ClosureLifetimeFrame*)a.data)[i], ((builtin__closure__ClosureLifetimeFrame*)b.data)[i])) { | ||
| 3733 | + return false; | ||
| 3734 | + } | ||
| 3735 | + } | ||
| 3736 | + return true; | ||
| 3737 | +} | ||
| 3738 | + | ||
| 3739 | +static inline bool builtin__closure__ClosureLifetimeState_struct_eq(builtin__closure__ClosureLifetimeState a, builtin__closure__ClosureLifetimeState b) { | ||
| 3740 | + return a.owner_thread == b.owner_thread | ||
| 3741 | + && a.active == b.active | ||
| 3742 | + && a.disposed == b.disposed | ||
| 3743 | + && a.suspended == b.suspended | ||
| 3744 | + && a.frame_start == b.frame_start | ||
| 3745 | + && a.frame_gen == b.frame_gen | ||
| 3746 | + && a.generation == b.generation | ||
| 3747 | + && a.frame_generation == b.frame_generation | ||
| 3748 | + && Array_builtin__closure__ClosureLifetimeRecord_arr_eq(a.records, b.records) | ||
| 3749 | + && Array_builtin__closure__ClosureLifetimeFrame_arr_eq(a.frames, b.frames) | ||
| 3750 | + && a.next_free == b.next_free; | ||
| 3751 | +} | ||
| 3752 | + | ||
| 3753 | + | ||
| 3754 | +// >> typeof() support for sum types / interfaces | ||
| 3755 | +static char * v_typeof_interface_IError(u32 sidx) { | ||
| 3756 | + if (sidx == _IError_None___index) return "None__"; | ||
| 3757 | + if (sidx == _IError_voidptr_index) return "voidptr"; | ||
| 3758 | + if (sidx == _IError_MessageError_index) return "MessageError"; | ||
| 3759 | + if (sidx == _IError_Error_index) return "Error"; | ||
| 3760 | + return "unknown IError"; | ||
| 3761 | +} | ||
| 3762 | + | ||
| 3763 | +u32 v_typeof_interface_idx_IError(u32 sidx) { | ||
| 3764 | + if (sidx == _IError_None___index) return 65; | ||
| 3765 | + if (sidx == _IError_voidptr_index) return 2; | ||
| 3766 | + if (sidx == _IError_MessageError_index) return 67; | ||
| 3767 | + if (sidx == _IError_Error_index) return 66; | ||
| 3768 | + return 30; | ||
| 3769 | +} | ||
| 3770 | +// << typeof() support for sum types | ||
| 3771 | + | ||
| 3772 | +strings__Builder strings__new_builder(int initial_size) { | ||
| 3773 | + strings__Builder res = ((builtin____new_array_with_default(0, initial_size, sizeof(u8), 0))); | ||
| 3774 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | ||
| 3775 | + return res; | ||
| 3776 | +} | ||
| 3777 | +Array_u8 strings__Builder_reuse_as_plain_u8_array(strings__Builder* b) { | ||
| 3778 | + builtin__ArrayFlags_clear(&b->flags, ArrayFlags__noslices); | ||
| 3779 | + return *b; | ||
| 3780 | +} | ||
| 3781 | +void strings__Builder_write_ptr(strings__Builder* b, u8* ptr, int len) { | ||
| 3782 | + if (len == 0) { | ||
| 3783 | + return; | ||
| 3784 | + } | ||
| 3785 | + builtin__array_push_many(b, ptr, len); | ||
| 3786 | +} | ||
| 3787 | +void strings__Builder_write_rune(strings__Builder* b, rune r) { | ||
| 3788 | + Array_fixed_u8_5 buffer = {0}; | ||
| 3789 | + string res = builtin__utf32_to_str_no_malloc(((u32)(r)), &buffer[0]); | ||
| 3790 | + if (res.len == 0) { | ||
| 3791 | + return; | ||
| 3792 | + } | ||
| 3793 | + builtin__array_push_many(b, res.str, res.len); | ||
| 3794 | +} | ||
| 3795 | +void strings__Builder_write_runes(strings__Builder* b, Array_rune runes) { | ||
| 3796 | + Array_fixed_u8_5 buffer = {0}; | ||
| 3797 | + for (int _t1 = 0; _t1 < runes.len; ++_t1) { | ||
| 3798 | + rune r = ((rune*)runes.data)[_t1]; | ||
| 3799 | + string res = builtin__utf32_to_str_no_malloc(((u32)(r)), &buffer[0]); | ||
| 3800 | + if (res.len == 0) { | ||
| 3801 | + continue; | ||
| 3802 | + } | ||
| 3803 | + builtin__array_push_many(b, res.str, res.len); | ||
| 3804 | + } | ||
| 3805 | +} | ||
| 3806 | +inline void strings__Builder_write_u8(strings__Builder* b, u8 data) { | ||
| 3807 | + builtin__array_push((array*)b, _MOV((u8[]){ data })); | ||
| 3808 | +} | ||
| 3809 | +inline void strings__Builder_write_byte(strings__Builder* b, u8 data) { | ||
| 3810 | + builtin__array_push((array*)b, _MOV((u8[]){ data })); | ||
| 3811 | +} | ||
| 3812 | +void strings__Builder_write_decimal(strings__Builder* b, i64 n) { | ||
| 3813 | + if (n == 0) { | ||
| 3814 | + strings__Builder_write_u8(b, 0x30); | ||
| 3815 | + return; | ||
| 3816 | + } | ||
| 3817 | + u64 mag = ((u64)(n)); | ||
| 3818 | + if (n < 0) { | ||
| 3819 | + strings__Builder_write_u8(b, '-'); | ||
| 3820 | + mag = ((u64)(0)) - mag; | ||
| 3821 | + } | ||
| 3822 | + strings__Builder_write_u_decimal(b, mag); | ||
| 3823 | +} | ||
| 3824 | +void strings__Builder_write_u_decimal(strings__Builder* b, u64 n) { | ||
| 3825 | + if (n == 0) { | ||
| 3826 | + strings__Builder_write_u8(b, 0x30); | ||
| 3827 | + return; | ||
| 3828 | + } | ||
| 3829 | + Array_fixed_u8_20 buf = {0}; | ||
| 3830 | + u64 x = n; | ||
| 3831 | + int i = 19; | ||
| 3832 | + for (;;) { | ||
| 3833 | + if (!(x != 0)) break; | ||
| 3834 | + u64 nextx = VSAFE_DIV_u64(x , 10); | ||
| 3835 | + u64 r = VSAFE_MOD_u64(x , 10); | ||
| 3836 | + buf[i] = (u8)(((u8)(r)) + 0x30); | ||
| 3837 | + x = nextx; | ||
| 3838 | + i--; | ||
| 3839 | + } | ||
| 3840 | + strings__Builder_write_ptr(b, &buf[i + 1], 19 - i); | ||
| 3841 | +} | ||
| 3842 | +_result_int strings__Builder_write(strings__Builder* b, Array_u8 data) { | ||
| 3843 | + if (data.len == 0) { | ||
| 3844 | + _result_int _t1; | ||
| 3845 | + builtin___result_ok(&(int[]) { 0 }, (_result*)(&_t1), sizeof(int)); | ||
| 3846 | + | ||
| 3847 | + return _t1; | ||
| 3848 | + } | ||
| 3849 | + builtin__array_push_many(b, data.data, data.len); | ||
| 3850 | + _result_int _t2; | ||
| 3851 | + builtin___result_ok(&(int[]) { data.len }, (_result*)(&_t2), sizeof(int)); | ||
| 3852 | + | ||
| 3853 | + return _t2; | ||
| 3854 | +} | ||
| 3855 | +void strings__Builder_drain_builder(strings__Builder* b, strings__Builder* other, int other_new_cap) { | ||
| 3856 | + if (other->len > 0) { | ||
| 3857 | + _PUSH_MANY(b, (*other), _t1, strings__Builder); | ||
| 3858 | + } | ||
| 3859 | + strings__Builder_free(other); | ||
| 3860 | + *other = strings__new_builder(other_new_cap); | ||
| 3861 | +} | ||
| 3862 | +inline u8 strings__Builder_byte_at(strings__Builder* b, int n) { | ||
| 3863 | + return (*(u8*)builtin__array_get(*(((Array_u8*)(b))), n)); | ||
| 3864 | +} | ||
| 3865 | +inline void strings__Builder_write_string(strings__Builder* b, string s) { | ||
| 3866 | + if (s.len == 0) { | ||
| 3867 | + return; | ||
| 3868 | + } | ||
| 3869 | + builtin__array_push_many(b, s.str, s.len); | ||
| 3870 | +} | ||
| 3871 | +inline void strings__Builder_write_string2(strings__Builder* b, string s1, string s2) { | ||
| 3872 | + if (s1.len != 0) { | ||
| 3873 | + builtin__array_push_many(b, s1.str, s1.len); | ||
| 3874 | + } | ||
| 3875 | + if (s2.len != 0) { | ||
| 3876 | + builtin__array_push_many(b, s2.str, s2.len); | ||
| 3877 | + } | ||
| 3878 | +} | ||
| 3879 | +void strings__Builder_go_back(strings__Builder* b, int n) { | ||
| 3880 | + builtin__array_trim(b, b->len - n); | ||
| 3881 | +} | ||
| 3882 | +inline string strings__Builder_spart(strings__Builder* b, int start_pos, int n) { | ||
| 3883 | + { // Unsafe block | ||
| 3884 | + u8* x = builtin__malloc_noscan(n + 1); | ||
| 3885 | + builtin__vmemcpy(x, ((u8*)(b->data)) + start_pos, n); | ||
| 3886 | + x[n] = 0; | ||
| 3887 | + return builtin__tos(x, n); | ||
| 3888 | + } | ||
| 3889 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 3890 | +} | ||
| 3891 | +string strings__Builder_cut_last(strings__Builder* b, int n) { | ||
| 3892 | + int cut_pos = b->len - n; | ||
| 3893 | + string res = strings__Builder_spart(b, cut_pos, n); | ||
| 3894 | + builtin__array_trim(b, cut_pos); | ||
| 3895 | + return res; | ||
| 3896 | +} | ||
| 3897 | +string strings__Builder_cut_to(strings__Builder* b, int pos) { | ||
| 3898 | + if (pos > b->len) { | ||
| 3899 | + return _S(""); | ||
| 3900 | + } | ||
| 3901 | + return strings__Builder_cut_last(b, b->len - pos); | ||
| 3902 | +} | ||
| 3903 | +void strings__Builder_go_back_to(strings__Builder* b, int pos) { | ||
| 3904 | + builtin__array_trim(b, pos); | ||
| 3905 | +} | ||
| 3906 | +inline void strings__Builder_writeln(strings__Builder* b, string s) { | ||
| 3907 | + if ((s).len != 0) { | ||
| 3908 | + builtin__array_push_many(b, s.str, s.len); | ||
| 3909 | + } | ||
| 3910 | + builtin__array_push((array*)b, _MOV((u8[]){ ((u8)('\n')) })); | ||
| 3911 | +} | ||
| 3912 | +inline void strings__Builder_writeln2(strings__Builder* b, string s1, string s2) { | ||
| 3913 | + if ((s1).len != 0) { | ||
| 3914 | + builtin__array_push_many(b, s1.str, s1.len); | ||
| 3915 | + } | ||
| 3916 | + builtin__array_push((array*)b, _MOV((u8[]){ ((u8)('\n')) })); | ||
| 3917 | + if ((s2).len != 0) { | ||
| 3918 | + builtin__array_push_many(b, s2.str, s2.len); | ||
| 3919 | + } | ||
| 3920 | + builtin__array_push((array*)b, _MOV((u8[]){ ((u8)('\n')) })); | ||
| 3921 | +} | ||
| 3922 | +string strings__Builder_last_n(strings__Builder* b, int n) { | ||
| 3923 | + if (n > b->len) { | ||
| 3924 | + return _S(""); | ||
| 3925 | + } | ||
| 3926 | + return strings__Builder_spart(b, b->len - n, n); | ||
| 3927 | +} | ||
| 3928 | +string strings__Builder_after(strings__Builder* b, int n) { | ||
| 3929 | + if (n >= b->len) { | ||
| 3930 | + return _S(""); | ||
| 3931 | + } | ||
| 3932 | + return strings__Builder_spart(b, n, b->len - n); | ||
| 3933 | +} | ||
| 3934 | +string strings__Builder_str(strings__Builder* b) { | ||
| 3935 | + builtin__array_push((array*)b, _MOV((u8[]){ ((u8)(0)) })); | ||
| 3936 | + u8* bcopy = ((u8*)(builtin__memdup_noscan(b->data, b->len))); | ||
| 3937 | + string s = builtin__u8_vstring_with_len(bcopy, b->len - 1); | ||
| 3938 | + builtin__array_clear(b); | ||
| 3939 | + return s; | ||
| 3940 | +} | ||
| 3941 | +void strings__Builder_ensure_cap(strings__Builder* b, int n) { | ||
| 3942 | + Array_u8* arr = ((Array_u8*)(b)); | ||
| 3943 | + builtin__array_ensure_cap(arr, n); | ||
| 3944 | +} | ||
| 3945 | +void strings__Builder_grow_len(strings__Builder* b, int n) { | ||
| 3946 | + if (n <= 0) { | ||
| 3947 | + return; | ||
| 3948 | + } | ||
| 3949 | + int new_len = b->len + n; | ||
| 3950 | + strings__Builder_ensure_cap(b, new_len); | ||
| 3951 | + { // Unsafe block | ||
| 3952 | + b->len = new_len; | ||
| 3953 | + } | ||
| 3954 | +} | ||
| 3955 | +void strings__Builder_free(strings__Builder* b) { | ||
| 3956 | + if (b->data != 0) { | ||
| 3957 | + Array_u8* arr = ((Array_u8*)(b)); | ||
| 3958 | + builtin__array_free(arr); | ||
| 3959 | + } | ||
| 3960 | +} | ||
| 3961 | +void strings__Builder_write_repeated_rune(strings__Builder* b, rune r, int count) { | ||
| 3962 | + if (count <= 0) { | ||
| 3963 | + return; | ||
| 3964 | + } | ||
| 3965 | + Array_fixed_u8_5 buffer = {0}; | ||
| 3966 | + string res = builtin__utf32_to_str_no_malloc(((u32)(r)), &buffer[0]); | ||
| 3967 | + if (res.len == 0) { | ||
| 3968 | + return; | ||
| 3969 | + } | ||
| 3970 | + if (res.len == 1) { | ||
| 3971 | + strings__Builder_ensure_cap(b, b->len + count); | ||
| 3972 | + { // Unsafe block | ||
| 3973 | + builtin__vmemset(((u8*)(b->data)) + b->len, buffer[0], count); | ||
| 3974 | + b->len += count; | ||
| 3975 | + } | ||
| 3976 | + return; | ||
| 3977 | + } else { | ||
| 3978 | + int total_needed = count * res.len; | ||
| 3979 | + strings__Builder_ensure_cap(b, b->len + total_needed); | ||
| 3980 | + u8* dest = ((u8*)(b->data)) + b->len; | ||
| 3981 | + for (int _t1 = 0; _t1 < count; ++_t1) { | ||
| 3982 | + { // Unsafe block | ||
| 3983 | + builtin__vmemcpy(dest, res.str, res.len); | ||
| 3984 | + dest += res.len; | ||
| 3985 | + } | ||
| 3986 | + } | ||
| 3987 | + { // Unsafe block | ||
| 3988 | + b->len += total_needed; | ||
| 3989 | + } | ||
| 3990 | + } | ||
| 3991 | +} | ||
| 3992 | +void strings__Builder_indent(strings__Builder* b, string s, strings__IndentParam param) { | ||
| 3993 | + if (s.len == 0) { | ||
| 3994 | + return; | ||
| 3995 | + } | ||
| 3996 | + strings__IndentState state = strings__IndentState__normal; | ||
| 3997 | + int indent_level = param.starting_level; | ||
| 3998 | + rune string_char = '\0'; | ||
| 3999 | + bool at_line_start = true; | ||
| 4000 | + for (int i = 0; i < s.len; i++) { | ||
| 4001 | + rune c = ((rune)(s.str[ i])); | ||
| 4002 | + | ||
| 4003 | + if (state == (strings__IndentState__normal)) { | ||
| 4004 | + | ||
| 4005 | + if (c == ('"') || c == ('\'')) { | ||
| 4006 | + state = strings__IndentState__in_string; | ||
| 4007 | + string_char = c; | ||
| 4008 | + if (at_line_start) { | ||
| 4009 | + strings__Builder_write_repeated_rune(b, param.indent_char, indent_level * param.indent_count); | ||
| 4010 | + at_line_start = false; | ||
| 4011 | + } | ||
| 4012 | + strings__Builder_write_rune(b, c); | ||
| 4013 | + } | ||
| 4014 | + else if (c == (param.block_start)) { | ||
| 4015 | + if (at_line_start) { | ||
| 4016 | + strings__Builder_write_repeated_rune(b, param.indent_char, indent_level * param.indent_count); | ||
| 4017 | + at_line_start = false; | ||
| 4018 | + } | ||
| 4019 | + strings__Builder_write_rune(b, c); | ||
| 4020 | + if (i + 1 < s.len && s.str[ i + 1] == param.block_end) { | ||
| 4021 | + strings__Builder_write_rune(b, param.block_end); | ||
| 4022 | + i++; | ||
| 4023 | + } else { | ||
| 4024 | + indent_level++; | ||
| 4025 | + strings__Builder_write_rune(b, '\n'); | ||
| 4026 | + at_line_start = true; | ||
| 4027 | + } | ||
| 4028 | + } | ||
| 4029 | + else if (c == (param.block_end)) { | ||
| 4030 | + if (indent_level > 0) { | ||
| 4031 | + indent_level--; | ||
| 4032 | + } | ||
| 4033 | + if (!at_line_start) { | ||
| 4034 | + strings__Builder_write_rune(b, '\n'); | ||
| 4035 | + } | ||
| 4036 | + strings__Builder_write_repeated_rune(b, param.indent_char, indent_level * param.indent_count); | ||
| 4037 | + at_line_start = false; | ||
| 4038 | + strings__Builder_write_rune(b, c); | ||
| 4039 | + } | ||
| 4040 | + else if (c == (' ') || c == ('\t') || c == ('\r') || c == ('\n')) { | ||
| 4041 | + if (!at_line_start) { | ||
| 4042 | + strings__Builder_write_rune(b, c); | ||
| 4043 | + } | ||
| 4044 | + if (c == '\n') { | ||
| 4045 | + at_line_start = true; | ||
| 4046 | + } | ||
| 4047 | + } | ||
| 4048 | + else { | ||
| 4049 | + if (at_line_start) { | ||
| 4050 | + strings__Builder_write_repeated_rune(b, param.indent_char, indent_level * param.indent_count); | ||
| 4051 | + at_line_start = false; | ||
| 4052 | + } | ||
| 4053 | + strings__Builder_write_rune(b, c); | ||
| 4054 | + } | ||
| 4055 | + } | ||
| 4056 | + else if (state == (strings__IndentState__in_string)) { | ||
| 4057 | + strings__Builder_write_rune(b, c); | ||
| 4058 | + if (c == string_char) { | ||
| 4059 | + if (s.str[ i - 1] != '\\') { | ||
| 4060 | + state = strings__IndentState__normal; | ||
| 4061 | + string_char = '\0'; | ||
| 4062 | + } | ||
| 4063 | + } | ||
| 4064 | + } | ||
| 4065 | + } | ||
| 4066 | +} | ||
| 4067 | +inline VV_LOC int strings__min(int a, int b, int c) { | ||
| 4068 | + int m = a; | ||
| 4069 | + if (b < m) { | ||
| 4070 | + m = b; | ||
| 4071 | + } | ||
| 4072 | + if (c < m) { | ||
| 4073 | + m = c; | ||
| 4074 | + } | ||
| 4075 | + return m; | ||
| 4076 | +} | ||
| 4077 | +inline VV_LOC int strings__max2(int a, int b) { | ||
| 4078 | + if (a < b) { | ||
| 4079 | + return b; | ||
| 4080 | + } | ||
| 4081 | + return a; | ||
| 4082 | +} | ||
| 4083 | +inline VV_LOC int strings__min2(int a, int b) { | ||
| 4084 | + if (a < b) { | ||
| 4085 | + return a; | ||
| 4086 | + } | ||
| 4087 | + return b; | ||
| 4088 | +} | ||
| 4089 | +inline VV_LOC int strings__abs2(int a, int b) { | ||
| 4090 | + if (a < b) { | ||
| 4091 | + return b - a; | ||
| 4092 | + } | ||
| 4093 | + return a - b; | ||
| 4094 | +} | ||
| 4095 | +int strings__levenshtein_distance(string a, string b) { | ||
| 4096 | + if (a.len == 0) { | ||
| 4097 | + return b.len; | ||
| 4098 | + } | ||
| 4099 | + if (b.len == 0) { | ||
| 4100 | + return a.len; | ||
| 4101 | + } | ||
| 4102 | + if (builtin__string__eq(a, b)) { | ||
| 4103 | + return 0; | ||
| 4104 | + } | ||
| 4105 | + Array_int row = builtin____new_array_with_default(a.len + 1, 0, sizeof(int), 0); | ||
| 4106 | + { | ||
| 4107 | + int* pelem = (int*)row.data; | ||
| 4108 | + for (int index=0; index<row.len; index++, pelem++) { | ||
| 4109 | + int it = index; | ||
| 4110 | + *pelem = index; | ||
| 4111 | + } | ||
| 4112 | + } | ||
| 4113 | + ; | ||
| 4114 | + for (int i = 1; i < b.len + 1; i++) { | ||
| 4115 | + int prev = i; | ||
| 4116 | + for (int j = 1; j < a.len + 1; j++) { | ||
| 4117 | + int current = ((int*)row.data)[j - 1]; | ||
| 4118 | + if (b.str[ i - 1] != a.str[ j - 1]) { | ||
| 4119 | + current = strings__min(((int*)row.data)[j - 1] + 1, prev + 1, ((int*)row.data)[j] + 1); | ||
| 4120 | + } | ||
| 4121 | + ((int*)row.data)[j - 1] = prev; | ||
| 4122 | + prev = current; | ||
| 4123 | + } | ||
| 4124 | + ((int*)row.data)[a.len] = prev; | ||
| 4125 | + } | ||
| 4126 | + return ((int*)row.data)[a.len]; | ||
| 4127 | +} | ||
| 4128 | +f32 strings__levenshtein_distance_percentage(string a, string b) { | ||
| 4129 | + int d = strings__levenshtein_distance(a, b); | ||
| 4130 | + int l = (a.len >= b.len ? (a.len) : (b.len)); | ||
| 4131 | + return (((f32)(1.00)) - ((f32)(d)) / ((f32)(l))) * ((f32)(100.00)); | ||
| 4132 | +} | ||
| 4133 | +f32 strings__dice_coefficient(string s1, string s2) { | ||
| 4134 | + if (s1.len == 0 || s2.len == 0) { | ||
| 4135 | + return 0.0; | ||
| 4136 | + } | ||
| 4137 | + if (builtin__string__eq(s1, s2)) { | ||
| 4138 | + return 1.0; | ||
| 4139 | + } | ||
| 4140 | + if (s1.len < 2 || s2.len < 2) { | ||
| 4141 | + return 0.0; | ||
| 4142 | + } | ||
| 4143 | + string a = (s1.len > s2.len ? (s1) : (s2)); | ||
| 4144 | + string b = (builtin__string__eq(a, s1) ? (s2) : (s1)); | ||
| 4145 | + Map_string_int first_bigrams = builtin__new_map(sizeof(string), sizeof(int), &builtin__map_hash_string, &builtin__map_eq_string, &builtin__map_clone_string, &builtin__map_free_string) | ||
| 4146 | + ; | ||
| 4147 | + for (int i = 0; i < a.len - 1; ++i) { | ||
| 4148 | + string bigram = builtin__string_substr(a, i, i + 2); | ||
| 4149 | + int q = (_IN_MAP(ADDR(string, bigram), ADDR(map, first_bigrams)) ? ((*(int*)builtin__map_get(ADDR(map, first_bigrams), &(string[]){bigram}, &(int[]){ 0 })) + 1) : (1)); | ||
| 4150 | + builtin__map_set(&first_bigrams, &(string[]){bigram}, &(int[]) { q }); | ||
| 4151 | + } | ||
| 4152 | + int intersection_size = 0; | ||
| 4153 | + for (int i = 0; i < b.len - 1; ++i) { | ||
| 4154 | + string bigram = builtin__string_substr(b, i, i + 2); | ||
| 4155 | + int count = (_IN_MAP(ADDR(string, bigram), ADDR(map, first_bigrams)) ? ((*(int*)builtin__map_get(ADDR(map, first_bigrams), &(string[]){bigram}, &(int[]){ 0 }))) : (0)); | ||
| 4156 | + if (count > 0) { | ||
| 4157 | + builtin__map_set(&first_bigrams, &(string[]){bigram}, &(int[]) { count - 1 }); | ||
| 4158 | + intersection_size++; | ||
| 4159 | + } | ||
| 4160 | + } | ||
| 4161 | + return (((f32)(2.0)) * ((f32)(intersection_size))) / (((f32)(a.len)) + ((f32)(b.len)) - 2); | ||
| 4162 | +} | ||
| 4163 | +int strings__hamming_distance(string a, string b) { | ||
| 4164 | + if (a.len == 0 && b.len == 0) { | ||
| 4165 | + return 0; | ||
| 4166 | + } | ||
| 4167 | + int match_len = strings__min2(a.len, b.len); | ||
| 4168 | + int diff_count = strings__abs2(a.len, b.len); | ||
| 4169 | + for (int i = 0; i < match_len; ++i) { | ||
| 4170 | + if (a.str[ i] != b.str[ i]) { | ||
| 4171 | + diff_count++; | ||
| 4172 | + } | ||
| 4173 | + } | ||
| 4174 | + return diff_count; | ||
| 4175 | +} | ||
| 4176 | +f32 strings__hamming_similarity(string a, string b) { | ||
| 4177 | + int l = strings__max2(a.len, b.len); | ||
| 4178 | + if (l == 0) { | ||
| 4179 | + return 1.0; | ||
| 4180 | + } | ||
| 4181 | + int d = strings__hamming_distance(a, b); | ||
| 4182 | + return ((f32)(1.00)) - ((f32)(d)) / ((f32)(l)); | ||
| 4183 | +} | ||
| 4184 | +f64 strings__jaro_similarity(string a, string b) { | ||
| 4185 | + int a_len = a.len; | ||
| 4186 | + int b_len = b.len; | ||
| 4187 | + if (a_len == 0 && b_len == 0) { | ||
| 4188 | + return 1.0; | ||
| 4189 | + } | ||
| 4190 | + if (a_len == 0 || b_len == 0) { | ||
| 4191 | + return 0; | ||
| 4192 | + } | ||
| 4193 | + int match_distance = strings__max2(VSAFE_DIV_int(strings__max2(a_len, b_len) , 2) - 1, 0); | ||
| 4194 | + Array_bool a_matches = builtin____new_array_with_default(a_len, 0, sizeof(bool), 0); | ||
| 4195 | + Array_bool b_matches = builtin____new_array_with_default(b_len, 0, sizeof(bool), 0); | ||
| 4196 | + int matches = 0; | ||
| 4197 | + f64 transpositions = 0.0; | ||
| 4198 | + for (int i = 0; i < a_len; ++i) { | ||
| 4199 | + int start = strings__max2(0, (int)(i - match_distance)); | ||
| 4200 | + int end = strings__min2(b_len, (int)(i + match_distance) + 1); | ||
| 4201 | + for (int k = start; k < end; ++k) { | ||
| 4202 | + if (((bool*)b_matches.data)[k]) { | ||
| 4203 | + continue; | ||
| 4204 | + } | ||
| 4205 | + if (a.str[ i] != b.str[ k]) { | ||
| 4206 | + continue; | ||
| 4207 | + } | ||
| 4208 | + ((bool*)a_matches.data)[i] = true; | ||
| 4209 | + ((bool*)b_matches.data)[k] = true; | ||
| 4210 | + matches++; | ||
| 4211 | + break; | ||
| 4212 | + } | ||
| 4213 | + } | ||
| 4214 | + if (matches == 0) { | ||
| 4215 | + return 0; | ||
| 4216 | + } | ||
| 4217 | + int k = 0; | ||
| 4218 | + for (int i = 0; i < a_len; ++i) { | ||
| 4219 | + if (!((bool*)a_matches.data)[i]) { | ||
| 4220 | + continue; | ||
| 4221 | + } | ||
| 4222 | + for (;;) { | ||
| 4223 | + if (!(!((bool*)b_matches.data)[k])) break; | ||
| 4224 | + k++; | ||
| 4225 | + } | ||
| 4226 | + if (a.str[ i] != b.str[ k]) { | ||
| 4227 | + transpositions++; | ||
| 4228 | + } | ||
| 4229 | + k++; | ||
| 4230 | + } | ||
| 4231 | + transpositions /= 2; | ||
| 4232 | + return ((f64)(matches / ((f64)(a_len))) + (f64)(matches / ((f64)(b_len))) + (f64)(((f64)(matches - transpositions)) / matches)) / 3; | ||
| 4233 | +} | ||
| 4234 | +f64 strings__jaro_winkler_similarity(string a, string b) { | ||
| 4235 | + int lmax = strings__min2(4, strings__min2(a.len, b.len)); | ||
| 4236 | + int l = 0; | ||
| 4237 | + for (int i = 0; i < lmax; ++i) { | ||
| 4238 | + if (a.str[ i] == b.str[ i]) { | ||
| 4239 | + l++; | ||
| 4240 | + } | ||
| 4241 | + } | ||
| 4242 | + f64 js = strings__jaro_similarity(a, b); | ||
| 4243 | + f64 p = 0.1; | ||
| 4244 | + f64 ws = js + ((f64)(l)) * p * (1 - js); | ||
| 4245 | + return ws; | ||
| 4246 | +} | ||
| 4247 | +string strings__repeat(u8 c, int n) { | ||
| 4248 | + if (n <= 0) { | ||
| 4249 | + return _S(""); | ||
| 4250 | + } | ||
| 4251 | + u8* bytes = builtin__malloc_noscan(n + 1); | ||
| 4252 | + { // Unsafe block | ||
| 4253 | + memset(bytes, c, n); | ||
| 4254 | + bytes[n] = 0; | ||
| 4255 | + } | ||
| 4256 | + return builtin__u8_vstring_with_len(bytes, n); | ||
| 4257 | +} | ||
| 4258 | +string strings__repeat_string(string s, int n) { | ||
| 4259 | + if (n <= 0 || s.len == 0) { | ||
| 4260 | + return _S(""); | ||
| 4261 | + } | ||
| 4262 | + int slen = s.len; | ||
| 4263 | + int blen = slen * n; | ||
| 4264 | + u8* bytes = builtin__malloc_noscan(blen + 1); | ||
| 4265 | + for (int bi = 0; bi < n; ++bi) { | ||
| 4266 | + int bislen = (int)(bi * slen); | ||
| 4267 | + for (int si = 0; si < slen; ++si) { | ||
| 4268 | + { // Unsafe block | ||
| 4269 | + bytes[(int)(bislen + si)] = s.str[ si]; | ||
| 4270 | + } | ||
| 4271 | + } | ||
| 4272 | + } | ||
| 4273 | + { // Unsafe block | ||
| 4274 | + bytes[blen] = 0; | ||
| 4275 | + } | ||
| 4276 | + return builtin__u8_vstring_with_len(bytes, blen); | ||
| 4277 | +} | ||
| 4278 | +string strings__find_between_pair_u8(string input, u8 start, u8 end) { | ||
| 4279 | + int marks = 0; | ||
| 4280 | + int start_index = -1; | ||
| 4281 | + for (int i = 0; i < input.len; ++i) { | ||
| 4282 | + u8 b = input.str[i]; | ||
| 4283 | + if (b == start) { | ||
| 4284 | + if (start_index == -1) { | ||
| 4285 | + start_index = i + 1; | ||
| 4286 | + } | ||
| 4287 | + marks++; | ||
| 4288 | + continue; | ||
| 4289 | + } | ||
| 4290 | + if (start_index > 0) { | ||
| 4291 | + if (b == end) { | ||
| 4292 | + marks--; | ||
| 4293 | + if (marks == 0) { | ||
| 4294 | + return builtin__string_substr(input, start_index, i); | ||
| 4295 | + } | ||
| 4296 | + } | ||
| 4297 | + } | ||
| 4298 | + } | ||
| 4299 | + return _S(""); | ||
| 4300 | +} | ||
| 4301 | +string strings__find_between_pair_rune(string input, rune start, rune end) { | ||
| 4302 | + int marks = 0; | ||
| 4303 | + int start_index = -1; | ||
| 4304 | + Array_rune runes = builtin__string_runes(input); | ||
| 4305 | + for (int i = 0; i < runes.len; ++i) { | ||
| 4306 | + rune r = ((rune*)runes.data)[i]; | ||
| 4307 | + if (r == start) { | ||
| 4308 | + if (start_index == -1) { | ||
| 4309 | + start_index = i + 1; | ||
| 4310 | + } | ||
| 4311 | + marks++; | ||
| 4312 | + continue; | ||
| 4313 | + } | ||
| 4314 | + if (start_index > 0) { | ||
| 4315 | + if (r == end) { | ||
| 4316 | + marks--; | ||
| 4317 | + if (marks == 0) { | ||
| 4318 | + return Array_rune_string(builtin__array_slice(runes, start_index, i)); | ||
| 4319 | + } | ||
| 4320 | + } | ||
| 4321 | + } | ||
| 4322 | + } | ||
| 4323 | + return _S(""); | ||
| 4324 | +} | ||
| 4325 | +string strings__find_between_pair_string(string input, string start, string end) { | ||
| 4326 | + int start_index = -1; | ||
| 4327 | + int marks = 0; | ||
| 4328 | + Array_rune start_runes = builtin__string_runes(start); | ||
| 4329 | + Array_rune end_runes = builtin__string_runes(end); | ||
| 4330 | + Array_rune runes = builtin__string_runes(input); | ||
| 4331 | + int i = 0; | ||
| 4332 | + for (; i < runes.len; i++) { | ||
| 4333 | + Array_rune start_slice = builtin__array_slice_ni(runes, i, i + start_runes.len); | ||
| 4334 | + if (Array_rune_arr_eq(start_slice, start_runes)) { | ||
| 4335 | + i = i + start_runes.len - 1; | ||
| 4336 | + if (start_index < 0) { | ||
| 4337 | + start_index = i + 1; | ||
| 4338 | + } | ||
| 4339 | + marks++; | ||
| 4340 | + continue; | ||
| 4341 | + } | ||
| 4342 | + if (start_index > 0) { | ||
| 4343 | + Array_rune end_slice = builtin__array_slice_ni(runes, i, i + end_runes.len); | ||
| 4344 | + if (Array_rune_arr_eq(end_slice, end_runes)) { | ||
| 4345 | + marks--; | ||
| 4346 | + if (marks == 0) { | ||
| 4347 | + return Array_rune_string(builtin__array_slice(runes, start_index, i)); | ||
| 4348 | + } | ||
| 4349 | + i = i + end_runes.len - 1; | ||
| 4350 | + continue; | ||
| 4351 | + } | ||
| 4352 | + } | ||
| 4353 | + } | ||
| 4354 | + return _S(""); | ||
| 4355 | +} | ||
| 4356 | +Array_string strings__split_capital(string s) { | ||
| 4357 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | ||
| 4358 | + int word_start = 0; | ||
| 4359 | + for (int idx = 0; idx < s.len; ++idx) { | ||
| 4360 | + u8 c = s.str[idx]; | ||
| 4361 | + if (builtin__u8_is_capital(c)) { | ||
| 4362 | + if (word_start != idx) { | ||
| 4363 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr_ni(s, word_start, idx) })); | ||
| 4364 | + } | ||
| 4365 | + word_start = idx; | ||
| 4366 | + continue; | ||
| 4367 | + } | ||
| 4368 | + } | ||
| 4369 | + if (word_start != s.len) { | ||
| 4370 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr_ni(s, word_start, 2147483647) })); | ||
| 4371 | + } | ||
| 4372 | + return res; | ||
| 4373 | +} | ||
| 4374 | +inline VV_LOC bool builtin__closure__is_ppc64(void) { | ||
| 4375 | + #if 0 | ||
| 4376 | + { | ||
| 4377 | + } | ||
| 4378 | + #else | ||
| 4379 | + { | ||
| 4380 | + return false; | ||
| 4381 | + } | ||
| 4382 | + #endif | ||
| 4383 | + return 0; | ||
| 4384 | +} | ||
| 4385 | +inline VV_LOC voidptr* builtin__closure__closure_slot_meta(voidptr exec_ptr) { | ||
| 4386 | + return ((voidptr*)(((u8*)(exec_ptr)) - _const_builtin__closure__assumed_page_size)); | ||
| 4387 | +} | ||
| 4388 | +VV_LOC void builtin__closure__closure_register_page(voidptr exec_page_start) { | ||
| 4389 | + { // Unsafe block | ||
| 4390 | + builtin__closure__ClosurePage* node = ((builtin__closure__ClosurePage*)(builtin___v_malloc(sizeof(builtin__closure__ClosurePage)))); | ||
| 4391 | + *node = ((builtin__closure__ClosurePage){.next = g_closure.pages,.exec_page_start = exec_page_start,}); | ||
| 4392 | + g_closure.pages = node; | ||
| 4393 | + } | ||
| 4394 | +} | ||
| 4395 | +VV_LOC bool builtin__closure__closure_is_managed(voidptr exec_ptr) { | ||
| 4396 | + if (builtin__isnil(exec_ptr)) { | ||
| 4397 | + return false; | ||
| 4398 | + } | ||
| 4399 | + usize exec_addr = ((usize)(exec_ptr)); | ||
| 4400 | + builtin__closure__ClosurePage* page = g_closure.pages; | ||
| 4401 | + for (;;) { | ||
| 4402 | + if (!(page != ((void*)0))) break; | ||
| 4403 | + usize page_addr = ((usize)(page->exec_page_start)); | ||
| 4404 | + if (exec_addr >= page_addr && exec_addr < page_addr + ((usize)(g_closure.v_page_size))) { | ||
| 4405 | + usize slot_offset = exec_addr - page_addr; | ||
| 4406 | + return slot_offset >= ((usize)(_const_builtin__closure__closure_size)) && VSAFE_MOD_usize(slot_offset , ((usize)(_const_builtin__closure__closure_size))) == 0; | ||
| 4407 | + } | ||
| 4408 | + page = page->next; | ||
| 4409 | + } | ||
| 4410 | + return false; | ||
| 4411 | +} | ||
| 4412 | +VV_LOC builtin__closure__ClosureLiveInfo builtin__closure__closure_live_delete(voidptr exec_ptr) { | ||
| 4413 | + builtin__closure__ClosureLiveInfo* _t2 = (builtin__closure__ClosureLiveInfo*)(builtin__map_get_check(ADDR(map, g_closure.live), &(voidptr[]){exec_ptr})); | ||
| 4414 | + _option_builtin__closure__ClosureLiveInfo _t1 = {0}; | ||
| 4415 | + if (_t2) { | ||
| 4416 | + *((builtin__closure__ClosureLiveInfo*)&_t1.data) = *((builtin__closure__ClosureLiveInfo*)_t2); | ||
| 4417 | + } else { | ||
| 4418 | + _t1.state = 2; _t1.err = builtin___v_error(_S("map key does not exist")); | ||
| 4419 | + } | ||
| 4420 | + | ||
| 4421 | + if (_t1.state == 0) { | ||
| 4422 | + builtin__closure__ClosureLiveInfo info = (*(builtin__closure__ClosureLiveInfo*)_t1.data); | ||
| 4423 | + (*(builtin__closure__ClosureLiveInfo*)builtin__map_get_and_set((map*)&g_closure.live, &(voidptr[]){exec_ptr}, &(builtin__closure__ClosureLiveInfo[]){ (builtin__closure__ClosureLiveInfo){.ctx = 0,.owns_data = 0,.generation = 0,} })) = ((builtin__closure__ClosureLiveInfo){.ctx = 0,.owns_data = 0,.generation = 0,}); | ||
| 4424 | + builtin__map_delete(&g_closure.live, &(voidptr[]){exec_ptr}); | ||
| 4425 | + return info; | ||
| 4426 | + } | ||
| 4427 | + if (_t1.state == 2 && _t1.err._object != _const_none__._object) { builtin___v_free(_t1.err._object); } | ||
| 4428 | + return ((builtin__closure__ClosureLiveInfo){.ctx = 0,.owns_data = 0,.generation = 0,}); | ||
| 4429 | +} | ||
| 4430 | +VV_LOC builtin__closure__ClosureLifetimeState* builtin__closure__new_closure_lifetime_state_no_lock(void) { | ||
| 4431 | + builtin__closure__ClosureLifetimeState* state = g_closure.free_lifetime_states; | ||
| 4432 | + if (!builtin__isnil(state)) { | ||
| 4433 | + g_closure.free_lifetime_states = state->next_free; | ||
| 4434 | + } else { | ||
| 4435 | + { // Unsafe block | ||
| 4436 | + state = ((builtin__closure__ClosureLifetimeState*)(builtin___v_malloc(sizeof(builtin__closure__ClosureLifetimeState)))); | ||
| 4437 | + } | ||
| 4438 | + g_closure.lifetime_state_allocs++; | ||
| 4439 | + } | ||
| 4440 | + g_closure.next_lifetime_generation++; | ||
| 4441 | + { // Unsafe block | ||
| 4442 | + *state = ((builtin__closure__ClosureLifetimeState){.owner_thread = builtin__closure__closure_current_thread_id_platform(),.active = 0,.disposed = 0,.suspended = 0,.frame_start = 0,.frame_gen = 0,.generation = g_closure.next_lifetime_generation,.frame_generation = 0,.records = builtin____new_array(0, 0, sizeof(builtin__closure__ClosureLifetimeRecord)),.frames = builtin____new_array(0, 0, sizeof(builtin__closure__ClosureLifetimeFrame)),.next_free = ((void*)0),}); | ||
| 4443 | + } | ||
| 4444 | + return state; | ||
| 4445 | +} | ||
| 4446 | +VV_LOC builtin__closure__ClosureLifetimeState* builtin__closure__new_closure_lifetime_state(void) { | ||
| 4447 | + builtin__closure__closure_mtx_lock_platform(); | ||
| 4448 | + builtin__closure__ClosureLifetimeState* state = builtin__closure__new_closure_lifetime_state_no_lock(); | ||
| 4449 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4450 | + return state; | ||
| 4451 | +} | ||
| 4452 | +VV_LOC void builtin__closure__closure_lifetime_recycle_state_no_lock(builtin__closure__ClosureLifetimeState** state) { | ||
| 4453 | + (*state)->disposed = true; | ||
| 4454 | + (*state)->active = false; | ||
| 4455 | + (*state)->suspended = 0; | ||
| 4456 | + (*state)->frame_start = 0; | ||
| 4457 | + (*state)->frame_gen = 0; | ||
| 4458 | + (*state)->frame_generation = 0; | ||
| 4459 | + { // Unsafe block | ||
| 4460 | + builtin__array_free(&(*state)->records); | ||
| 4461 | + builtin__array_free(&(*state)->frames); | ||
| 4462 | + } | ||
| 4463 | + (*state)->records = builtin____new_array_with_default(0, 0, sizeof(builtin__closure__ClosureLifetimeRecord), 0); | ||
| 4464 | + (*state)->frames = builtin____new_array_with_default(0, 0, sizeof(builtin__closure__ClosureLifetimeFrame), 0); | ||
| 4465 | + (*state)->next_free = g_closure.free_lifetime_states; | ||
| 4466 | + g_closure.free_lifetime_states = *state; | ||
| 4467 | +} | ||
| 4468 | +VV_LOC string builtin__closure__closure_lifetime_error(builtin__closure__ClosureLifetimeState* state, u64 generation, u64 thread_id) { | ||
| 4469 | + if (state->disposed || state->generation != generation) { | ||
| 4470 | + return _S("closure lifetime used after dispose"); | ||
| 4471 | + } | ||
| 4472 | + if (state->owner_thread != thread_id) { | ||
| 4473 | + return _S("closure lifetime used from a different thread"); | ||
| 4474 | + } | ||
| 4475 | + return _S(""); | ||
| 4476 | +} | ||
| 4477 | +VV_LOC _result_builtin__closure__ClosureLifetimeState_ptr builtin__closure__Lifetime_ensure_state(builtin__closure__Lifetime* lifetime) { | ||
| 4478 | + builtin__closure__closure_ensure_initialized(); | ||
| 4479 | + if (builtin__isnil(lifetime->state)) { | ||
| 4480 | + if (lifetime->disposed) { | ||
| 4481 | + return (_result_builtin__closure__ClosureLifetimeState_ptr){ .is_error=true, .err=builtin___v_error(_S("closure lifetime used after dispose")), .data={E_STRUCT} }; | ||
| 4482 | + } | ||
| 4483 | + lifetime->state = builtin__closure__new_closure_lifetime_state(); | ||
| 4484 | + lifetime->generation = lifetime->state->generation; | ||
| 4485 | + _result_builtin__closure__ClosureLifetimeState_ptr _t2; | ||
| 4486 | + builtin___result_ok(&(builtin__closure__ClosureLifetimeState*[]) { lifetime->state }, (_result*)(&_t2), sizeof(builtin__closure__ClosureLifetimeState*)); | ||
| 4487 | + | ||
| 4488 | + return _t2; | ||
| 4489 | + } | ||
| 4490 | + builtin__closure__closure_mtx_lock_platform(); | ||
| 4491 | + builtin__closure__ClosureLifetimeState* state = lifetime->state; | ||
| 4492 | + if (lifetime->disposed || state->disposed || state->generation != lifetime->generation) { | ||
| 4493 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4494 | + return (_result_builtin__closure__ClosureLifetimeState_ptr){ .is_error=true, .err=builtin___v_error(_S("closure lifetime used after dispose")), .data={E_STRUCT} }; | ||
| 4495 | + } | ||
| 4496 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4497 | + _result_builtin__closure__ClosureLifetimeState_ptr _t4; | ||
| 4498 | + builtin___result_ok(&(builtin__closure__ClosureLifetimeState*[]) { state }, (_result*)(&_t4), sizeof(builtin__closure__ClosureLifetimeState*)); | ||
| 4499 | + | ||
| 4500 | + return _t4; | ||
| 4501 | +} | ||
| 4502 | +VV_LOC voidptr builtin__closure__closure_slot_data(voidptr exec_ptr) { | ||
| 4503 | + { // Unsafe block | ||
| 4504 | + voidptr* p = builtin__closure__closure_slot_meta(exec_ptr); | ||
| 4505 | + if (builtin__closure__is_ppc64()) { | ||
| 4506 | + return p[2]; | ||
| 4507 | + } | ||
| 4508 | + return p[0]; | ||
| 4509 | + } | ||
| 4510 | + return 0; | ||
| 4511 | +} | ||
| 4512 | +VV_LOC bool builtin__closure__closure_release_no_lock(voidptr exec_ptr, u64 generation) { | ||
| 4513 | + if (!builtin__closure__closure_is_managed(exec_ptr)) { | ||
| 4514 | + return false; | ||
| 4515 | + } | ||
| 4516 | + builtin__closure__ClosureLiveInfo* _t3 = (builtin__closure__ClosureLiveInfo*)(builtin__map_get_check(ADDR(map, g_closure.live), &(voidptr[]){exec_ptr})); | ||
| 4517 | + _option_builtin__closure__ClosureLiveInfo _t2 = {0}; | ||
| 4518 | + if (_t3) { | ||
| 4519 | + *((builtin__closure__ClosureLiveInfo*)&_t2.data) = *((builtin__closure__ClosureLiveInfo*)_t3); | ||
| 4520 | + } else { | ||
| 4521 | + _t2.state = 2; _t2.err = builtin___v_error(_S("map key does not exist")); | ||
| 4522 | + } | ||
| 4523 | + ; | ||
| 4524 | + if (_t2.state != 0) { | ||
| 4525 | + return false; | ||
| 4526 | + } | ||
| 4527 | + | ||
| 4528 | + builtin__closure__ClosureLiveInfo info = (*(builtin__closure__ClosureLiveInfo*)_t2.data); | ||
| 4529 | + if (generation != 0 && info.generation != generation) { | ||
| 4530 | + return false; | ||
| 4531 | + } | ||
| 4532 | + voidptr data = builtin__closure__closure_slot_data(exec_ptr); | ||
| 4533 | + builtin__closure__closure_live_delete(exec_ptr); | ||
| 4534 | + if (info.owns_data && !builtin__isnil(data)) { | ||
| 4535 | + builtin___v_free(data); | ||
| 4536 | + } | ||
| 4537 | + { // Unsafe block | ||
| 4538 | + voidptr* p = builtin__closure__closure_slot_meta(exec_ptr); | ||
| 4539 | + p[0] = g_closure.free_closure_ptr; | ||
| 4540 | + if (builtin__closure__is_ppc64()) { | ||
| 4541 | + p[1] = ((void*)0); | ||
| 4542 | + p[2] = ((void*)0); | ||
| 4543 | + p[3] = ((void*)0); | ||
| 4544 | + } else { | ||
| 4545 | + p[1] = ((void*)0); | ||
| 4546 | + } | ||
| 4547 | + g_closure.free_closure_ptr = exec_ptr; | ||
| 4548 | + } | ||
| 4549 | + return true; | ||
| 4550 | +} | ||
| 4551 | +VV_LOC void builtin__closure__closure_lifetime_release_records_no_lock(Array_builtin__closure__ClosureLifetimeRecord records, int start, int end) { | ||
| 4552 | + for (int i = start; i < end; ++i) { | ||
| 4553 | + builtin__closure__ClosureLifetimeRecord record = (*(builtin__closure__ClosureLifetimeRecord*)builtin__array_get(records, i)); | ||
| 4554 | + builtin__closure__closure_release_no_lock(record.exec_ptr, record.generation); | ||
| 4555 | + } | ||
| 4556 | +} | ||
| 4557 | +VV_LOC void builtin__closure__closure_lifetime_reclaim_no_lock(builtin__closure__ClosureLifetimeState* state, int retain) { | ||
| 4558 | + int keep = (retain < 0 ? (0) : (retain)); | ||
| 4559 | + if (state->frames.len <= keep) { | ||
| 4560 | + return; | ||
| 4561 | + } | ||
| 4562 | + int reclaim_count = state->frames.len - keep; | ||
| 4563 | + int cutoff = 0; | ||
| 4564 | + for (int i = 0; i < reclaim_count; ++i) { | ||
| 4565 | + builtin__closure__ClosureLifetimeFrame frame = (*(builtin__closure__ClosureLifetimeFrame*)builtin__array_get(state->frames, i)); | ||
| 4566 | + builtin__closure__closure_lifetime_release_records_no_lock(state->records, frame.start, frame.end); | ||
| 4567 | + cutoff = frame.end; | ||
| 4568 | + } | ||
| 4569 | + builtin__array_delete_many(&state->frames, 0, reclaim_count); | ||
| 4570 | + if (cutoff > 0) { | ||
| 4571 | + builtin__array_delete_many(&state->records, 0, cutoff); | ||
| 4572 | + for (int _t1 = 0; _t1 < state->frames.len; ++_t1) { | ||
| 4573 | + builtin__closure__ClosureLifetimeFrame* frame = ((builtin__closure__ClosureLifetimeFrame*)state->frames.data) + _t1; | ||
| 4574 | + frame->start -= cutoff; | ||
| 4575 | + frame->end -= cutoff; | ||
| 4576 | + } | ||
| 4577 | + } | ||
| 4578 | +} | ||
| 4579 | +VV_LOC void builtin__closure__closure_ensure_initialized(void) { | ||
| 4580 | + builtin__closure__closure_init_once_platform(); | ||
| 4581 | +} | ||
| 4582 | +builtin__closure__Lifetime builtin__closure__new_lifetime(void) { | ||
| 4583 | + builtin__closure__closure_ensure_initialized(); | ||
| 4584 | + builtin__closure__ClosureLifetimeState* state = builtin__closure__new_closure_lifetime_state(); | ||
| 4585 | + return ((builtin__closure__Lifetime){.state = state,.generation = state->generation,.disposed = 0,}); | ||
| 4586 | +} | ||
| 4587 | +VV_LOC _result_builtin__closure__FrameToken builtin__closure__Lifetime_begin_frame(builtin__closure__Lifetime* lifetime) { | ||
| 4588 | + _result_builtin__closure__ClosureLifetimeState_ptr _t1 = builtin__closure__Lifetime_ensure_state(lifetime); | ||
| 4589 | + if (_t1.is_error) { | ||
| 4590 | + _result_builtin__closure__FrameToken _t2 = {0}; | ||
| 4591 | + _t2.is_error = true; | ||
| 4592 | + _t2.err = _t1.err; | ||
| 4593 | + return _t2; | ||
| 4594 | + } | ||
| 4595 | + | ||
| 4596 | + builtin__closure__ClosureLifetimeState* state = (*(builtin__closure__ClosureLifetimeState**)_t1.data); | ||
| 4597 | + u64 thread_id = builtin__closure__closure_current_thread_id_platform(); | ||
| 4598 | + builtin__closure__closure_mtx_lock_platform(); | ||
| 4599 | + string err = builtin__closure__closure_lifetime_error(state, lifetime->generation, thread_id); | ||
| 4600 | + if ((err).len != 0) { | ||
| 4601 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4602 | + return (_result_builtin__closure__FrameToken){ .is_error=true, .err=builtin___v_error(err), .data={E_STRUCT} }; | ||
| 4603 | + } | ||
| 4604 | + if (state->active) { | ||
| 4605 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4606 | + return (_result_builtin__closure__FrameToken){ .is_error=true, .err=builtin___v_error(_S("closure lifetime frames can not be nested")), .data={E_STRUCT} }; | ||
| 4607 | + } | ||
| 4608 | + if (state->suspended > 0) { | ||
| 4609 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4610 | + return (_result_builtin__closure__FrameToken){ .is_error=true, .err=builtin___v_error(_S("closure lifetime frame while suspended")), .data={E_STRUCT} }; | ||
| 4611 | + } | ||
| 4612 | + builtin__closure__ClosureLifetimeState** _t7 = (builtin__closure__ClosureLifetimeState**)(builtin__map_get_check(ADDR(map, g_closure.active_lifetimes), &(u64[]){thread_id})); | ||
| 4613 | + _option_builtin__closure__ClosureLifetimeState_ptr _t6 = {0}; | ||
| 4614 | + if (_t7) { | ||
| 4615 | + *((builtin__closure__ClosureLifetimeState**)&_t6.data) = *((builtin__closure__ClosureLifetimeState**)_t7); | ||
| 4616 | + } else { | ||
| 4617 | + _t6.state = 2; _t6.err = builtin___v_error(_S("map key does not exist")); | ||
| 4618 | + } | ||
| 4619 | + | ||
| 4620 | + if (_t6.state == 0) { | ||
| 4621 | + builtin__closure__ClosureLifetimeState* _dummy_6 = (*(builtin__closure__ClosureLifetimeState**)_t6.data); | ||
| 4622 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4623 | + return (_result_builtin__closure__FrameToken){ .is_error=true, .err=builtin___v_error(_S("another closure lifetime is already active on this thread")), .data={E_STRUCT} }; | ||
| 4624 | + } | ||
| 4625 | + if (_t6.state == 2 && _t6.err._object != _const_none__._object) { builtin___v_free(_t6.err._object); } | ||
| 4626 | + state->frame_generation++; | ||
| 4627 | + state->active = true; | ||
| 4628 | + state->frame_start = state->records.len; | ||
| 4629 | + state->frame_gen = state->frame_generation; | ||
| 4630 | + (*(builtin__closure__ClosureLifetimeState**)builtin__map_get_and_set((map*)&g_closure.active_lifetimes, &(u64[]){thread_id}, &(builtin__closure__ClosureLifetimeState*[]){ 0 })) = state; | ||
| 4631 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4632 | + _result_builtin__closure__FrameToken _t9; | ||
| 4633 | + builtin___result_ok(&(builtin__closure__FrameToken[]) { ((builtin__closure__FrameToken){.state = state,.thread_id = thread_id,.state_generation = lifetime->generation,.generation = state->frame_generation,}) }, (_result*)(&_t9), sizeof(builtin__closure__FrameToken)); | ||
| 4634 | + | ||
| 4635 | + return _t9; | ||
| 4636 | +} | ||
| 4637 | +VV_LOC _result_void builtin__closure__Lifetime_end_frame(builtin__closure__Lifetime* lifetime, builtin__closure__FrameToken token) { | ||
| 4638 | + if (builtin__isnil(token.state)) { | ||
| 4639 | + return (_result_void){ .is_error=true, .err=builtin___v_error(_S("invalid closure lifetime frame token")), .data={E_STRUCT} }; | ||
| 4640 | + } | ||
| 4641 | + builtin__closure__ClosureLifetimeState* state = token.state; | ||
| 4642 | + u64 thread_id = builtin__closure__closure_current_thread_id_platform(); | ||
| 4643 | + builtin__closure__closure_mtx_lock_platform(); | ||
| 4644 | + string err = builtin__closure__closure_lifetime_error(state, token.state_generation, thread_id); | ||
| 4645 | + if ((err).len != 0) { | ||
| 4646 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4647 | + return (_result_void){ .is_error=true, .err=builtin___v_error(err), .data={E_STRUCT} }; | ||
| 4648 | + } | ||
| 4649 | + if (token.thread_id != thread_id || token.generation != state->frame_gen || !state->active) { | ||
| 4650 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4651 | + return (_result_void){ .is_error=true, .err=builtin___v_error(_S("invalid closure lifetime frame token")), .data={E_STRUCT} }; | ||
| 4652 | + } | ||
| 4653 | + builtin__array_push((array*)&state->frames, _MOV((builtin__closure__ClosureLifetimeFrame[]){ ((builtin__closure__ClosureLifetimeFrame){.start = state->frame_start,.end = state->records.len,}) })); | ||
| 4654 | + state->active = false; | ||
| 4655 | + state->frame_start = 0; | ||
| 4656 | + state->frame_gen = 0; | ||
| 4657 | + (*(builtin__closure__ClosureLifetimeState**)builtin__map_get_and_set((map*)&g_closure.active_lifetimes, &(u64[]){thread_id}, &(builtin__closure__ClosureLifetimeState*[]){ 0 })) = ((void*)0); | ||
| 4658 | + builtin__map_delete(&g_closure.active_lifetimes, &(u64[]){thread_id}); | ||
| 4659 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4660 | + return (_result_void){0}; | ||
| 4661 | +} | ||
| 4662 | +_result_void builtin__closure__Lifetime_frame(builtin__closure__Lifetime* lifetime, void (*work)(void)) { | ||
| 4663 | + _result_builtin__closure__FrameToken _t1 = builtin__closure__Lifetime_begin_frame(lifetime); | ||
| 4664 | + if (_t1.is_error) { | ||
| 4665 | + _result_void _t2 = {0}; | ||
| 4666 | + _t2.is_error = true; | ||
| 4667 | + _t2.err = _t1.err; | ||
| 4668 | + return _t2; | ||
| 4669 | + } | ||
| 4670 | + | ||
| 4671 | + builtin__closure__FrameToken token = (*(builtin__closure__FrameToken*)_t1.data); | ||
| 4672 | + bool ended = false; | ||
| 4673 | + work(); | ||
| 4674 | + _result_void _t3 = builtin__closure__Lifetime_end_frame(lifetime, token); | ||
| 4675 | + if (_t3.is_error) { | ||
| 4676 | + { // defer begin | ||
| 4677 | + if (!ended) { | ||
| 4678 | + _result_void _t4 = builtin__closure__Lifetime_end_frame(lifetime, token); | ||
| 4679 | + (void)_t4; | ||
| 4680 | + ; | ||
| 4681 | + } | ||
| 4682 | + } // defer end | ||
| 4683 | + _result_void _t5 = {0}; | ||
| 4684 | + _t5.is_error = true; | ||
| 4685 | + _t5.err = _t3.err; | ||
| 4686 | + return _t5; | ||
| 4687 | + } | ||
| 4688 | + | ||
| 4689 | + ; | ||
| 4690 | + ended = true; | ||
| 4691 | + { // defer begin | ||
| 4692 | + if (!ended) { | ||
| 4693 | + _result_void _t6 = builtin__closure__Lifetime_end_frame(lifetime, token); | ||
| 4694 | + (void)_t6; | ||
| 4695 | + ; | ||
| 4696 | + } | ||
| 4697 | + } // defer end | ||
| 4698 | + return (_result_void){0}; | ||
| 4699 | +} | ||
| 4700 | +_result_void builtin__closure__Lifetime_reclaim(builtin__closure__Lifetime* lifetime, int retain) { | ||
| 4701 | + _result_builtin__closure__ClosureLifetimeState_ptr _t1 = builtin__closure__Lifetime_ensure_state(lifetime); | ||
| 4702 | + if (_t1.is_error) { | ||
| 4703 | + _result_void _t2 = {0}; | ||
| 4704 | + _t2.is_error = true; | ||
| 4705 | + _t2.err = _t1.err; | ||
| 4706 | + return _t2; | ||
| 4707 | + } | ||
| 4708 | + | ||
| 4709 | + builtin__closure__ClosureLifetimeState* state = (*(builtin__closure__ClosureLifetimeState**)_t1.data); | ||
| 4710 | + u64 thread_id = builtin__closure__closure_current_thread_id_platform(); | ||
| 4711 | + builtin__closure__closure_mtx_lock_platform(); | ||
| 4712 | + string err = builtin__closure__closure_lifetime_error(state, lifetime->generation, thread_id); | ||
| 4713 | + if ((err).len != 0) { | ||
| 4714 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4715 | + return (_result_void){ .is_error=true, .err=builtin___v_error(err), .data={E_STRUCT} }; | ||
| 4716 | + } | ||
| 4717 | + if (state->active) { | ||
| 4718 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4719 | + return (_result_void){ .is_error=true, .err=builtin___v_error(_S("closure lifetime reclaim while a frame is active")), .data={E_STRUCT} }; | ||
| 4720 | + } | ||
| 4721 | + builtin__closure__closure_lifetime_reclaim_no_lock(state, retain); | ||
| 4722 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4723 | + return (_result_void){0}; | ||
| 4724 | +} | ||
| 4725 | +_result_void builtin__closure__Lifetime_reclaim_all(builtin__closure__Lifetime* lifetime) { | ||
| 4726 | + _result_void _t1 = builtin__closure__Lifetime_reclaim(lifetime, 0); | ||
| 4727 | + if (_t1.is_error) { | ||
| 4728 | + _result_void _t2 = {0}; | ||
| 4729 | + _t2.is_error = true; | ||
| 4730 | + _t2.err = _t1.err; | ||
| 4731 | + return _t2; | ||
| 4732 | + } | ||
| 4733 | + | ||
| 4734 | + ; | ||
| 4735 | + return (_result_void){0}; | ||
| 4736 | +} | ||
| 4737 | +_result_void builtin__closure__Lifetime_dispose(builtin__closure__Lifetime* lifetime) { | ||
| 4738 | + _result_builtin__closure__ClosureLifetimeState_ptr _t1 = builtin__closure__Lifetime_ensure_state(lifetime); | ||
| 4739 | + if (_t1.is_error) { | ||
| 4740 | + _result_void _t2 = {0}; | ||
| 4741 | + _t2.is_error = true; | ||
| 4742 | + _t2.err = _t1.err; | ||
| 4743 | + return _t2; | ||
| 4744 | + } | ||
| 4745 | + | ||
| 4746 | + builtin__closure__ClosureLifetimeState* state = (*(builtin__closure__ClosureLifetimeState**)_t1.data); | ||
| 4747 | + u64 thread_id = builtin__closure__closure_current_thread_id_platform(); | ||
| 4748 | + builtin__closure__closure_mtx_lock_platform(); | ||
| 4749 | + string err = builtin__closure__closure_lifetime_error(state, lifetime->generation, thread_id); | ||
| 4750 | + if ((err).len != 0) { | ||
| 4751 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4752 | + return (_result_void){ .is_error=true, .err=builtin___v_error(err), .data={E_STRUCT} }; | ||
| 4753 | + } | ||
| 4754 | + if (state->active) { | ||
| 4755 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4756 | + return (_result_void){ .is_error=true, .err=builtin___v_error(_S("closure lifetime dispose while a frame is active")), .data={E_STRUCT} }; | ||
| 4757 | + } | ||
| 4758 | + if (state->suspended > 0) { | ||
| 4759 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4760 | + return (_result_void){ .is_error=true, .err=builtin___v_error(_S("closure lifetime dispose while suspended")), .data={E_STRUCT} }; | ||
| 4761 | + } | ||
| 4762 | + builtin__closure__closure_lifetime_reclaim_no_lock(state, 0); | ||
| 4763 | + lifetime->state = ((void*)0); | ||
| 4764 | + lifetime->disposed = true; | ||
| 4765 | + builtin__closure__closure_lifetime_recycle_state_no_lock(&state); | ||
| 4766 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4767 | + return (_result_void){0}; | ||
| 4768 | +} | ||
| 4769 | +_result_void builtin__closure__Lifetime_suspend(builtin__closure__Lifetime* lifetime, void (*work)(void)) { | ||
| 4770 | + _result_builtin__closure__ClosureLifetimeState_ptr _t1 = builtin__closure__Lifetime_ensure_state(lifetime); | ||
| 4771 | + if (_t1.is_error) { | ||
| 4772 | + _result_void _t2 = {0}; | ||
| 4773 | + _t2.is_error = true; | ||
| 4774 | + _t2.err = _t1.err; | ||
| 4775 | + return _t2; | ||
| 4776 | + } | ||
| 4777 | + | ||
| 4778 | + builtin__closure__ClosureLifetimeState* state = (*(builtin__closure__ClosureLifetimeState**)_t1.data); | ||
| 4779 | + u64 thread_id = builtin__closure__closure_current_thread_id_platform(); | ||
| 4780 | + builtin__closure__closure_mtx_lock_platform(); | ||
| 4781 | + string err = builtin__closure__closure_lifetime_error(state, lifetime->generation, thread_id); | ||
| 4782 | + if ((err).len != 0) { | ||
| 4783 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4784 | + return (_result_void){ .is_error=true, .err=builtin___v_error(err), .data={E_STRUCT} }; | ||
| 4785 | + } | ||
| 4786 | + builtin__closure__ClosureLifetimeState** _t5 = (builtin__closure__ClosureLifetimeState**)(builtin__map_get_check(ADDR(map, g_closure.active_lifetimes), &(u64[]){thread_id})); | ||
| 4787 | + _option_builtin__closure__ClosureLifetimeState_ptr _t4 = {0}; | ||
| 4788 | + if (_t5) { | ||
| 4789 | + *((builtin__closure__ClosureLifetimeState**)&_t4.data) = *((builtin__closure__ClosureLifetimeState**)_t5); | ||
| 4790 | + } else { | ||
| 4791 | + _t4.state = 2; _t4.err = builtin___v_error(_S("map key does not exist")); | ||
| 4792 | + } | ||
| 4793 | + | ||
| 4794 | + if (_t4.state == 0) { | ||
| 4795 | + builtin__closure__ClosureLifetimeState* active = (*(builtin__closure__ClosureLifetimeState**)_t4.data); | ||
| 4796 | + if (!(active == state || (active != 0 && state != 0 && builtin__closure__ClosureLifetimeState_struct_eq(*active, *state)))) { | ||
| 4797 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4798 | + return (_result_void){ .is_error=true, .err=builtin___v_error(_S("another closure lifetime is already active on this thread")), .data={E_STRUCT} }; | ||
| 4799 | + } | ||
| 4800 | + } | ||
| 4801 | + if (_t4.state == 2 && _t4.err._object != _const_none__._object) { builtin___v_free(_t4.err._object); } | ||
| 4802 | + state->suspended++; | ||
| 4803 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4804 | + work(); | ||
| 4805 | + { // defer begin | ||
| 4806 | + builtin__closure__closure_mtx_lock_platform(); | ||
| 4807 | + state->suspended--; | ||
| 4808 | + builtin__closure__closure_mtx_unlock_platform(); | ||
| 4809 | + } // defer end | ||
| 4810 | + return (_result_void){0}; | ||
| 4811 | +} | ||
| 4812 | +_result_void builtin__closure__Lifetime_untracked(builtin__closure__Lifetime* lifetime, void (*work)(void)) { | ||
| 4813 | + _result_void _t1 = builtin__closure__Lifetime_suspend(lifetime, work); | ||
| 4814 | + if (_t1.is_error) { | ||
| 4815 | + _result_void _t2 = {0}; | ||
| 4816 | + _t2.is_error = true; | ||
| 4817 | + _t2.err = _t1.err; | ||
| 4818 | + return _t2; | ||
| 4819 | + } | ||
| 4820 | + | ||
| 4821 | + ; | ||
| 4822 | + return (_result_void){0}; | ||
| 4823 | +} | ||
| 4824 | +VV_LOC void builtin__closure__closure_alloc(void) { | ||
| 4825 | + u8* p = builtin__closure__closure_alloc_platform(); | ||
| 4826 | + if (builtin__isnil(p)) { | ||
| 4827 | + return; | ||
| 4828 | + } | ||
| 4829 | + u8* x = p + g_closure.v_page_size; | ||
| 4830 | + int remaining = VSAFE_DIV_int(g_closure.v_page_size , _const_builtin__closure__closure_size); | ||
| 4831 | + builtin__closure__closure_register_page(x); | ||
| 4832 | + g_closure.closure_ptr = x; | ||
| 4833 | + g_closure.closure_cap = remaining; | ||
| 4834 | + for (;;) { | ||
| 4835 | + if (!(remaining > 0)) break; | ||
| 4836 | + builtin__vmemcpy(x, &_const_builtin__closure__closure_thunk[0], 15); | ||
| 4837 | + remaining--; | ||
| 4838 | + { // Unsafe block | ||
| 4839 | + x += _const_builtin__closure__closure_size; | ||
| 4840 | + } | ||
| 4841 | + } | ||
| 4842 | + builtin__closure__closure_memory_protect_platform(g_closure.closure_ptr, g_closure.v_page_size, builtin__closure__MemoryProtectAtrr__read_exec); | ||
| 4843 | +} | ||
| 4844 | +VV_LOC void builtin__closure__closure_init_body(void) { | ||
| 4845 | + int page_size = builtin__closure__get_page_size_platform(); | ||
| 4846 | + g_closure.v_page_size = page_size; | ||
| 4847 | + g_closure.live = builtin__new_map(sizeof(voidptr), sizeof(builtin__closure__ClosureLiveInfo), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop) | ||
| 4848 | + ; | ||
| 4849 | + g_closure.active_lifetimes = builtin__new_map(sizeof(u64), sizeof(builtin__closure__ClosureLifetimeState*), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop) | ||
| 4850 | + ; | ||
| 4851 | + g_closure.next_generation = 0; | ||
| 4852 | + g_closure.free_lifetime_states = ((void*)0); | ||
| 4853 | + g_closure.next_lifetime_generation = 0; | ||
| 4854 | + g_closure.lifetime_state_allocs = 0; | ||
| 4855 | + builtin__closure__closure_mtx_lock_init_platform(); | ||
| 4856 | + builtin__closure__closure_alloc(); | ||
| 4857 | + { // Unsafe block | ||
| 4858 | + builtin__closure__closure_memory_protect_platform(g_closure.closure_ptr, page_size, builtin__closure__MemoryProtectAtrr__read_write); | ||
| 4859 | + builtin__vmemcpy(g_closure.closure_ptr, &_const_builtin__closure__closure_get_data_bytes[0], 6); | ||
| 4860 | + builtin__closure__closure_memory_protect_platform(g_closure.closure_ptr, page_size, builtin__closure__MemoryProtectAtrr__read_exec); | ||
| 4861 | + } | ||
| 4862 | + if (builtin__closure__is_ppc64()) { | ||
| 4863 | + voidptr* desc = ((voidptr*)(((u8*)(g_closure.closure_ptr)) - _const_builtin__closure__assumed_page_size)); | ||
| 4864 | + { // Unsafe block | ||
| 4865 | + desc[0] = g_closure.closure_ptr; | ||
| 4866 | + desc[1] = ((void*)0); | ||
| 4867 | + } | ||
| 4868 | + g_closure.closure_get_data = ((builtin__closure__ClosureGetDataFn)(desc)); | ||
| 4869 | + } else { | ||
| 4870 | + g_closure.closure_get_data = g_closure.closure_ptr; | ||
| 4871 | + } | ||
| 4872 | + { // Unsafe block | ||
| 4873 | + g_closure.closure_ptr = ((u8*)(g_closure.closure_ptr)) + _const_builtin__closure__closure_size; | ||
| 4874 | + } | ||
| 4875 | + g_closure.closure_cap--; | ||
| 4876 | +} | ||
| 4877 | +#if 1 | ||
| 4878 | +#endif | ||
| 4879 | +inline VV_LOC voidptr builtin__closure__closure_mtx_ptr_platform(void) { | ||
| 4880 | + return ((voidptr)(&g_closure.ClosureMutex.closure_mtx[0])); | ||
| 4881 | +} | ||
| 4882 | +inline VV_LOC u8* builtin__closure__closure_alloc_platform(void) { | ||
| 4883 | + u8* p = ((u8*)(((void*)0))); | ||
| 4884 | + #if 0 | ||
| 4885 | + { | ||
| 4886 | + } | ||
| 4887 | + #else | ||
| 4888 | + { | ||
| 4889 | + p = mmap(0, g_closure.v_page_size * 2, (PROT_READ | PROT_WRITE), (MAP_ANONYMOUS | MAP_PRIVATE), -1, 0); | ||
| 4890 | + if (p == ((u8*)(MAP_FAILED))) { | ||
| 4891 | + return ((void*)0); | ||
| 4892 | + } | ||
| 4893 | + } | ||
| 4894 | + #endif | ||
| 4895 | + return p; | ||
| 4896 | +} | ||
| 4897 | +inline VV_LOC void builtin__closure__closure_memory_protect_platform(voidptr ptr, isize size, builtin__closure__MemoryProtectAtrr attr) { | ||
| 4898 | + #if 0 | ||
| 4899 | + { | ||
| 4900 | + } | ||
| 4901 | + #else | ||
| 4902 | + { | ||
| 4903 | + | ||
| 4904 | + if (attr == (builtin__closure__MemoryProtectAtrr__read_exec)) { | ||
| 4905 | + mprotect(ptr, size, (PROT_READ | PROT_EXEC)); | ||
| 4906 | + } | ||
| 4907 | + else if (attr == (builtin__closure__MemoryProtectAtrr__read_write)) { | ||
| 4908 | + mprotect(ptr, size, (PROT_READ | PROT_WRITE)); | ||
| 4909 | + } | ||
| 4910 | + } | ||
| 4911 | + #endif | ||
| 4912 | +} | ||
| 4913 | +inline VV_LOC int builtin__closure__get_page_size_platform(void) { | ||
| 4914 | + int page_size = 0x4000; | ||
| 4915 | + #if 1 | ||
| 4916 | + { | ||
| 4917 | + page_size = ((int)(sysconf(_SC_PAGESIZE))); | ||
| 4918 | + } | ||
| 4919 | + #endif | ||
| 4920 | + page_size = page_size * ((VSAFE_DIV_int((_const_builtin__closure__assumed_page_size - 1) , page_size)) + 1); | ||
| 4921 | + return page_size; | ||
| 4922 | +} | ||
| 4923 | +inline VV_LOC void builtin__closure__closure_mtx_lock_init_platform(void) { | ||
| 4924 | + #if 1 | ||
| 4925 | + { | ||
| 4926 | + pthread_mutex_init(builtin__closure__closure_mtx_ptr_platform(), 0); | ||
| 4927 | + } | ||
| 4928 | + #endif | ||
| 4929 | +} | ||
| 4930 | +inline VV_LOC void builtin__closure__closure_mtx_lock_platform(void) { | ||
| 4931 | + #if 1 | ||
| 4932 | + { | ||
| 4933 | + pthread_mutex_lock(builtin__closure__closure_mtx_ptr_platform()); | ||
| 4934 | + } | ||
| 4935 | + #endif | ||
| 4936 | +} | ||
| 4937 | +inline VV_LOC void builtin__closure__closure_mtx_unlock_platform(void) { | ||
| 4938 | + #if 1 | ||
| 4939 | + { | ||
| 4940 | + pthread_mutex_unlock(builtin__closure__closure_mtx_ptr_platform()); | ||
| 4941 | + } | ||
| 4942 | + #endif | ||
| 4943 | +} | ||
| 4944 | +inline VV_LOC u64 builtin__closure__closure_current_thread_id_platform(void) { | ||
| 4945 | + #if 1 | ||
| 4946 | + { | ||
| 4947 | + return ((u64)(pthread_self())); | ||
| 4948 | + } | ||
| 4949 | + #endif | ||
| 4950 | + return ((u64)(0)); | ||
| 4951 | +} | ||
| 4952 | +inline VV_LOC void builtin__closure__closure_init_once_platform(void) { | ||
| 4953 | + #if 0 | ||
| 4954 | + { | ||
| 4955 | + } | ||
| 4956 | + #else | ||
| 4957 | + { | ||
| 4958 | + v_closure_init_once(builtin__closure__closure_init_body); | ||
| 4959 | + } | ||
| 4960 | + #endif | ||
| 4961 | +} | ||
| 4962 | +inline multi_return_u64_u64 math__bits__mul_64(u64 x, u64 y) { | ||
| 4963 | + u64 hi = ((u64)(0)); | ||
| 4964 | + u64 lo = ((u64)(0)); | ||
| 4965 | + #if defined(_MSC_VER) | ||
| 4966 | + { | ||
| 4967 | + } | ||
| 4968 | + #elif defined(__V_amd64) | ||
| 4969 | + { | ||
| 4970 | + __asm__ ( | ||
| 4971 | + "mulq %%rdx\n\t" | ||
| 4972 | + : [lo] "=a" (lo), | ||
| 4973 | + [hi] "=d" (hi) | ||
| 4974 | + : [x] "a" (x), | ||
| 4975 | + [y] "d" (y) | ||
| 4976 | + : "cc" | ||
| 4977 | + ); | ||
| 4978 | + return (multi_return_u64_u64){.arg0=hi, .arg1=lo}; | ||
| 4979 | + } | ||
| 4980 | + #endif | ||
| 4981 | + return math__bits__mul_64_default(x, y); | ||
| 4982 | +} | ||
| 4983 | +inline multi_return_u64_u64 math__bits__mul_add_64(u64 x, u64 y, u64 z) { | ||
| 4984 | + u64 hi = ((u64)(0)); | ||
| 4985 | + u64 lo = ((u64)(0)); | ||
| 4986 | + #if defined(_MSC_VER) | ||
| 4987 | + { | ||
| 4988 | + } | ||
| 4989 | + #elif defined(__V_amd64) | ||
| 4990 | + { | ||
| 4991 | + __asm__ ( | ||
| 4992 | + "mulq %%rdx\n\t" | ||
| 4993 | + "addq %[z], %%rax\n\t" | ||
| 4994 | + "adcq $0, %%rdx\n\t" | ||
| 4995 | + : [lo] "=a" (lo), | ||
| 4996 | + [hi] "=d" (hi) | ||
| 4997 | + : [x] "a" (x), | ||
| 4998 | + [y] "d" (y), | ||
| 4999 | + [z] "r" (z) | ||
| 5000 | + : "cc" | ||
| 5001 | + ); | ||
| 5002 | + return (multi_return_u64_u64){.arg0=hi, .arg1=lo}; | ||
| 5003 | + } | ||
| 5004 | + #endif | ||
| 5005 | + return math__bits__mul_add_64_default(x, y, z); | ||
| 5006 | +} | ||
| 5007 | +inline multi_return_u64_u64 math__bits__div_64(u64 hi, u64 lo, u64 y1) { | ||
| 5008 | + u64 y = y1; | ||
| 5009 | + if (y == 0) { | ||
| 5010 | + builtin___v_panic(_const_math__bits__divide_error); | ||
| 5011 | + VUNREACHABLE(); | ||
| 5012 | + } | ||
| 5013 | + if (y <= hi) { | ||
| 5014 | + builtin___v_panic(_const_math__bits__overflow_error); | ||
| 5015 | + VUNREACHABLE(); | ||
| 5016 | + } | ||
| 5017 | + u64 quo = ((u64)(0)); | ||
| 5018 | + u64 rem = ((u64)(0)); | ||
| 5019 | + #if defined(_MSC_VER) | ||
| 5020 | + { | ||
| 5021 | + } | ||
| 5022 | + #elif defined(__V_amd64) | ||
| 5023 | + { | ||
| 5024 | + __asm__ ( | ||
| 5025 | + "div %[y]\n\t" | ||
| 5026 | + : [quo] "=a" (quo), | ||
| 5027 | + [rem] "=d" (rem) | ||
| 5028 | + : [hi] "d" (hi), | ||
| 5029 | + [lo] "a" (lo), | ||
| 5030 | + [y] "r" (y) | ||
| 5031 | + : "cc" | ||
| 5032 | + ); | ||
| 5033 | + return (multi_return_u64_u64){.arg0=quo, .arg1=rem}; | ||
| 5034 | + } | ||
| 5035 | + #endif | ||
| 5036 | + return math__bits__div_64_default(hi, lo, y1); | ||
| 5037 | +} | ||
| 5038 | +inline int math__bits__leading_zeros_8(u8 x) { | ||
| 5039 | + if (x == 0) { | ||
| 5040 | + return 8; | ||
| 5041 | + } | ||
| 5042 | + #if defined(_MSC_VER) | ||
| 5043 | + { | ||
| 5044 | + } | ||
| 5045 | + #elif !defined(__TINYC__) | ||
| 5046 | + { | ||
| 5047 | + return __builtin_clz(((u32)(x))) - 24; | ||
| 5048 | + } | ||
| 5049 | + #endif | ||
| 5050 | + return math__bits__leading_zeros_8_default(x); | ||
| 5051 | +} | ||
| 5052 | +inline int math__bits__leading_zeros_16(u16 x) { | ||
| 5053 | + if (x == 0) { | ||
| 5054 | + return 16; | ||
| 5055 | + } | ||
| 5056 | + #if defined(_MSC_VER) | ||
| 5057 | + { | ||
| 5058 | + } | ||
| 5059 | + #elif !defined(__TINYC__) | ||
| 5060 | + { | ||
| 5061 | + return __builtin_clz(((u32)(x))) - 16; | ||
| 5062 | + } | ||
| 5063 | + #endif | ||
| 5064 | + return math__bits__leading_zeros_16_default(x); | ||
| 5065 | +} | ||
| 5066 | +inline int math__bits__leading_zeros_32(u32 x) { | ||
| 5067 | + if (x == 0) { | ||
| 5068 | + return 32; | ||
| 5069 | + } | ||
| 5070 | + #if defined(_MSC_VER) | ||
| 5071 | + { | ||
| 5072 | + } | ||
| 5073 | + #elif !defined(__TINYC__) | ||
| 5074 | + { | ||
| 5075 | + return __builtin_clz(x); | ||
| 5076 | + } | ||
| 5077 | + #endif | ||
| 5078 | + return math__bits__leading_zeros_32_default(x); | ||
| 5079 | +} | ||
| 5080 | +inline int math__bits__leading_zeros_64(u64 x) { | ||
| 5081 | + if (x == 0) { | ||
| 5082 | + return 64; | ||
| 5083 | + } | ||
| 5084 | + #if defined(_MSC_VER) | ||
| 5085 | + { | ||
| 5086 | + } | ||
| 5087 | + #elif !defined(__TINYC__) | ||
| 5088 | + { | ||
| 5089 | + return __builtin_clzll(x); | ||
| 5090 | + } | ||
| 5091 | + #endif | ||
| 5092 | + return math__bits__leading_zeros_64_default(x); | ||
| 5093 | +} | ||
| 5094 | +inline int math__bits__trailing_zeros_8(u8 x) { | ||
| 5095 | + if (x == 0) { | ||
| 5096 | + return 8; | ||
| 5097 | + } | ||
| 5098 | + #if defined(_MSC_VER) | ||
| 5099 | + { | ||
| 5100 | + } | ||
| 5101 | + #elif !defined(__TINYC__) | ||
| 5102 | + { | ||
| 5103 | + return __builtin_ctz(((u32)(x))); | ||
| 5104 | + } | ||
| 5105 | + #endif | ||
| 5106 | + return math__bits__trailing_zeros_8_default(x); | ||
| 5107 | +} | ||
| 5108 | +inline int math__bits__trailing_zeros_16(u16 x) { | ||
| 5109 | + if (x == 0) { | ||
| 5110 | + return 16; | ||
| 5111 | + } | ||
| 5112 | + #if defined(_MSC_VER) | ||
| 5113 | + { | ||
| 5114 | + } | ||
| 5115 | + #elif !defined(__TINYC__) | ||
| 5116 | + { | ||
| 5117 | + return __builtin_ctz(((u32)(x))); | ||
| 5118 | + } | ||
| 5119 | + #endif | ||
| 5120 | + return math__bits__trailing_zeros_16_default(x); | ||
| 5121 | +} | ||
| 5122 | +inline int math__bits__trailing_zeros_32(u32 x) { | ||
| 5123 | + if (x == 0) { | ||
| 5124 | + return 32; | ||
| 5125 | + } | ||
| 5126 | + #if defined(_MSC_VER) | ||
| 5127 | + { | ||
| 5128 | + } | ||
| 5129 | + #elif !defined(__TINYC__) | ||
| 5130 | + { | ||
| 5131 | + return __builtin_ctz(x); | ||
| 5132 | + } | ||
| 5133 | + #endif | ||
| 5134 | + return math__bits__trailing_zeros_32_default(x); | ||
| 5135 | +} | ||
| 5136 | +inline int math__bits__trailing_zeros_64(u64 x) { | ||
| 5137 | + if (x == 0) { | ||
| 5138 | + return 64; | ||
| 5139 | + } | ||
| 5140 | + #if defined(_MSC_VER) | ||
| 5141 | + { | ||
| 5142 | + } | ||
| 5143 | + #elif !defined(__TINYC__) | ||
| 5144 | + { | ||
| 5145 | + return __builtin_ctzll(x); | ||
| 5146 | + } | ||
| 5147 | + #endif | ||
| 5148 | + return math__bits__trailing_zeros_64_default(x); | ||
| 5149 | +} | ||
| 5150 | +inline int math__bits__ones_count_8(u8 x) { | ||
| 5151 | + #if defined(_MSC_VER) | ||
| 5152 | + { | ||
| 5153 | + } | ||
| 5154 | + #elif !defined(__TINYC__) | ||
| 5155 | + { | ||
| 5156 | + return __builtin_popcount(((u32)(x))); | ||
| 5157 | + } | ||
| 5158 | + #endif | ||
| 5159 | + return math__bits__ones_count_8_default(x); | ||
| 5160 | +} | ||
| 5161 | +inline int math__bits__ones_count_16(u16 x) { | ||
| 5162 | + #if defined(_MSC_VER) | ||
| 5163 | + { | ||
| 5164 | + } | ||
| 5165 | + #elif !defined(__TINYC__) | ||
| 5166 | + { | ||
| 5167 | + return __builtin_popcount(((u32)(x))); | ||
| 5168 | + } | ||
| 5169 | + #endif | ||
| 5170 | + return math__bits__ones_count_16_default(x); | ||
| 5171 | +} | ||
| 5172 | +inline int math__bits__ones_count_32(u32 x) { | ||
| 5173 | + #if defined(_MSC_VER) | ||
| 5174 | + { | ||
| 5175 | + } | ||
| 5176 | + #elif !defined(__TINYC__) | ||
| 5177 | + { | ||
| 5178 | + return __builtin_popcount(x); | ||
| 5179 | + } | ||
| 5180 | + #endif | ||
| 5181 | + return math__bits__ones_count_32_default(x); | ||
| 5182 | +} | ||
| 5183 | +inline int math__bits__ones_count_64(u64 x) { | ||
| 5184 | + #if defined(_MSC_VER) | ||
| 5185 | + { | ||
| 5186 | + } | ||
| 5187 | + #elif !defined(__TINYC__) | ||
| 5188 | + { | ||
| 5189 | + return __builtin_popcountll(x); | ||
| 5190 | + } | ||
| 5191 | + #endif | ||
| 5192 | + return math__bits__ones_count_64_default(x); | ||
| 5193 | +} | ||
| 5194 | +inline int math__bits__pure_v_but_overridden_by_c_leading_zeros_8(u8 x) { | ||
| 5195 | + return math__bits__leading_zeros_8_default(x); | ||
| 5196 | +} | ||
| 5197 | +inline VV_LOC int math__bits__leading_zeros_8_default(u8 x) { | ||
| 5198 | + return 8 - math__bits__len_8(x); | ||
| 5199 | +} | ||
| 5200 | +inline int math__bits__pure_v_but_overridden_by_c_leading_zeros_16(u16 x) { | ||
| 5201 | + return math__bits__leading_zeros_16_default(x); | ||
| 5202 | +} | ||
| 5203 | +inline VV_LOC int math__bits__leading_zeros_16_default(u16 x) { | ||
| 5204 | + return 16 - math__bits__len_16(x); | ||
| 5205 | +} | ||
| 5206 | +inline int math__bits__pure_v_but_overridden_by_c_leading_zeros_32(u32 x) { | ||
| 5207 | + return math__bits__leading_zeros_32_default(x); | ||
| 5208 | +} | ||
| 5209 | +inline VV_LOC int math__bits__leading_zeros_32_default(u32 x) { | ||
| 5210 | + return 32 - math__bits__len_32(x); | ||
| 5211 | +} | ||
| 5212 | +inline int math__bits__pure_v_but_overridden_by_c_leading_zeros_64(u64 x) { | ||
| 5213 | + return math__bits__leading_zeros_64_default(x); | ||
| 5214 | +} | ||
| 5215 | +inline VV_LOC int math__bits__leading_zeros_64_default(u64 x) { | ||
| 5216 | + return 64 - math__bits__len_64(x); | ||
| 5217 | +} | ||
| 5218 | +inline int math__bits__pure_v_but_overridden_by_c_trailing_zeros_8(u8 x) { | ||
| 5219 | + return math__bits__trailing_zeros_8_default(x); | ||
| 5220 | +} | ||
| 5221 | +inline VV_LOC int math__bits__trailing_zeros_8_default(u8 x) { | ||
| 5222 | + return ((int)(_const_math__bits__ntz_8_tab[x])); | ||
| 5223 | +} | ||
| 5224 | +inline int math__bits__pure_v_but_overridden_by_c_trailing_zeros_16(u16 x) { | ||
| 5225 | + return math__bits__trailing_zeros_16_default(x); | ||
| 5226 | +} | ||
| 5227 | +inline VV_LOC int math__bits__trailing_zeros_16_default(u16 x) { | ||
| 5228 | + if (x == 0) { | ||
| 5229 | + return 16; | ||
| 5230 | + } | ||
| 5231 | + return ((int)(_const_math__bits__de_bruijn32tab[v__rshift_u32(((u32)((x & -x))) * _const_math__bits__de_bruijn32, (u64)27)])); | ||
| 5232 | +} | ||
| 5233 | +inline int math__bits__pure_v_but_overridden_by_c_trailing_zeros_32(u32 x) { | ||
| 5234 | + return math__bits__trailing_zeros_32_default(x); | ||
| 5235 | +} | ||
| 5236 | +inline VV_LOC int math__bits__trailing_zeros_32_default(u32 x) { | ||
| 5237 | + if (x == 0) { | ||
| 5238 | + return 32; | ||
| 5239 | + } | ||
| 5240 | + return ((int)(_const_math__bits__de_bruijn32tab[v__rshift_u32(((x & -x)) * _const_math__bits__de_bruijn32, (u64)27)])); | ||
| 5241 | +} | ||
| 5242 | +inline int math__bits__pure_v_but_overridden_by_c_trailing_zeros_64(u64 x) { | ||
| 5243 | + return math__bits__trailing_zeros_64_default(x); | ||
| 5244 | +} | ||
| 5245 | +inline VV_LOC int math__bits__trailing_zeros_64_default(u64 x) { | ||
| 5246 | + if (x == 0) { | ||
| 5247 | + return 64; | ||
| 5248 | + } | ||
| 5249 | + return ((int)(_const_math__bits__de_bruijn64tab[((int)(v__rshift_u64(((x & -x)) * _const_math__bits__de_bruijn64, (u64)58)))])); | ||
| 5250 | +} | ||
| 5251 | +inline int math__bits__pure_v_but_overridden_by_c_ones_count_8(u8 x) { | ||
| 5252 | + return math__bits__ones_count_8_default(x); | ||
| 5253 | +} | ||
| 5254 | +inline VV_LOC int math__bits__ones_count_8_default(u8 x) { | ||
| 5255 | + return ((int)(_const_math__bits__pop_8_tab[x])); | ||
| 5256 | +} | ||
| 5257 | +inline int math__bits__pure_v_but_overridden_by_c_ones_count_16(u16 x) { | ||
| 5258 | + return math__bits__ones_count_16_default(x); | ||
| 5259 | +} | ||
| 5260 | +inline VV_LOC int math__bits__ones_count_16_default(u16 x) { | ||
| 5261 | + return ((int)((u8)(_const_math__bits__pop_8_tab[v__rshift_u16(x, (u64)8)] + _const_math__bits__pop_8_tab[(x & ((u16)(0xff)))]))); | ||
| 5262 | +} | ||
| 5263 | +inline int math__bits__pure_v_but_overridden_by_c_ones_count_32(u32 x) { | ||
| 5264 | + return math__bits__ones_count_32_default(x); | ||
| 5265 | +} | ||
| 5266 | +inline VV_LOC int math__bits__ones_count_32_default(u32 x) { | ||
| 5267 | + return ((int)((u8)((u8)((u8)(_const_math__bits__pop_8_tab[v__rshift_u32(x, (u64)24)] + _const_math__bits__pop_8_tab[((v__rshift_u32(x, (u64)16)) & 0xff)]) + _const_math__bits__pop_8_tab[((v__rshift_u32(x, (u64)8)) & 0xff)]) + _const_math__bits__pop_8_tab[(x & ((u32)(0xff)))]))); | ||
| 5268 | +} | ||
| 5269 | +inline int math__bits__pure_v_but_overridden_by_c_ones_count_64(u64 x) { | ||
| 5270 | + return math__bits__ones_count_64_default(x); | ||
| 5271 | +} | ||
| 5272 | +inline VV_LOC int math__bits__ones_count_64_default(u64 x) { | ||
| 5273 | + u64 y = (((v__rshift_u64(x, (u64)((u64)(1)))) & ((_const_math__bits__m0 & _const_max_u64)))) + ((x & ((_const_math__bits__m0 & _const_max_u64)))); | ||
| 5274 | + y = (((v__rshift_u64(y, (u64)((u64)(2)))) & ((_const_math__bits__m1 & _const_max_u64)))) + ((y & ((_const_math__bits__m1 & _const_max_u64)))); | ||
| 5275 | + y = (((v__rshift_u64(y, (u64)4)) + y) & ((_const_math__bits__m2 & _const_max_u64))); | ||
| 5276 | + y += v__rshift_u64(y, (u64)8); | ||
| 5277 | + y += v__rshift_u64(y, (u64)16); | ||
| 5278 | + y += v__rshift_u64(y, (u64)32); | ||
| 5279 | + return (((int)(y)) & 127); | ||
| 5280 | +} | ||
| 5281 | +inline u8 math__bits__rotate_left_8(u8 x, int k) { | ||
| 5282 | + u8 s = (((u8)(k)) & ((u8)(_const_math__bits__n8 - ((u8)(1))))); | ||
| 5283 | + return ((v__lshift_u8(x, (u64)s)) | (v__rshift_u8(x, (u64)((u8)(_const_math__bits__n8 - s))))); | ||
| 5284 | +} | ||
| 5285 | +inline u16 math__bits__rotate_left_16(u16 x, int k) { | ||
| 5286 | + u16 s = (((u16)(k)) & ((u16)(_const_math__bits__n16 - ((u16)(1))))); | ||
| 5287 | + return ((v__lshift_u16(x, (u64)s)) | (v__rshift_u16(x, (u64)((u16)(_const_math__bits__n16 - s))))); | ||
| 5288 | +} | ||
| 5289 | +inline u32 math__bits__rotate_left_32(u32 x, int k) { | ||
| 5290 | + u32 s = (((u32)(k)) & (_const_math__bits__n32 - ((u32)(1)))); | ||
| 5291 | + return ((v__lshift_u32(x, (u64)s)) | (v__rshift_u32(x, (u64)(_const_math__bits__n32 - s)))); | ||
| 5292 | +} | ||
| 5293 | +inline u64 math__bits__rotate_left_64(u64 x, int k) { | ||
| 5294 | + u64 s = (((u64)(k)) & (_const_math__bits__n64 - ((u64)(1)))); | ||
| 5295 | + return ((v__lshift_u64(x, (u64)s)) | (v__rshift_u64(x, (u64)(_const_math__bits__n64 - s)))); | ||
| 5296 | +} | ||
| 5297 | +inline u8 math__bits__reverse_8(u8 x) { | ||
| 5298 | + return _const_math__bits__rev_8_tab[x]; | ||
| 5299 | +} | ||
| 5300 | +inline u16 math__bits__reverse_16(u16 x) { | ||
| 5301 | + return (((u16)(_const_math__bits__rev_8_tab[v__rshift_u16(x, (u64)8)])) | (v__lshift_u16(((u16)(_const_math__bits__rev_8_tab[(x & ((u16)(0xff)))])), (u64)8))); | ||
| 5302 | +} | ||
| 5303 | +inline u32 math__bits__reverse_32(u32 x) { | ||
| 5304 | + u64 y = (((((v__rshift_u32(x, (u64)((u32)(1)))) & ((_const_math__bits__m0 & _const_max_u32)))) | (v__lshift_u64(((x & ((_const_math__bits__m0 & _const_max_u32)))), (u64)1)))); | ||
| 5305 | + y = (((((v__rshift_u64(y, (u64)((u32)(2)))) & ((_const_math__bits__m1 & _const_max_u32)))) | (v__lshift_u64(((y & ((_const_math__bits__m1 & _const_max_u32)))), (u64)((u32)(2)))))); | ||
| 5306 | + y = (((((v__rshift_u64(y, (u64)((u32)(4)))) & ((_const_math__bits__m2 & _const_max_u32)))) | (v__lshift_u64(((y & ((_const_math__bits__m2 & _const_max_u32)))), (u64)((u32)(4)))))); | ||
| 5307 | + return math__bits__reverse_bytes_32(((u32)(y))); | ||
| 5308 | +} | ||
| 5309 | +inline u64 math__bits__reverse_64(u64 x) { | ||
| 5310 | + u64 y = (((((v__rshift_u64(x, (u64)((u64)(1)))) & ((_const_math__bits__m0 & _const_max_u64)))) | (v__lshift_u64(((x & ((_const_math__bits__m0 & _const_max_u64)))), (u64)1)))); | ||
| 5311 | + y = (((((v__rshift_u64(y, (u64)((u64)(2)))) & ((_const_math__bits__m1 & _const_max_u64)))) | (v__lshift_u64(((y & ((_const_math__bits__m1 & _const_max_u64)))), (u64)2)))); | ||
| 5312 | + y = (((((v__rshift_u64(y, (u64)((u64)(4)))) & ((_const_math__bits__m2 & _const_max_u64)))) | (v__lshift_u64(((y & ((_const_math__bits__m2 & _const_max_u64)))), (u64)4)))); | ||
| 5313 | + return math__bits__reverse_bytes_64(y); | ||
| 5314 | +} | ||
| 5315 | +inline u16 math__bits__reverse_bytes_16(u16 x) { | ||
| 5316 | + return ((v__rshift_u16(x, (u64)8)) | (v__lshift_u16(x, (u64)8))); | ||
| 5317 | +} | ||
| 5318 | +inline u32 math__bits__reverse_bytes_32(u32 x) { | ||
| 5319 | + u64 y = (((((v__rshift_u32(x, (u64)((u32)(8)))) & ((_const_math__bits__m3 & _const_max_u32)))) | (v__lshift_u64(((x & ((_const_math__bits__m3 & _const_max_u32)))), (u64)((u32)(8)))))); | ||
| 5320 | + return ((u32)(((v__rshift_u64(y, (u64)16)) | (v__lshift_u64(y, (u64)16))))); | ||
| 5321 | +} | ||
| 5322 | +inline u64 math__bits__reverse_bytes_64(u64 x) { | ||
| 5323 | + u64 y = (((((v__rshift_u64(x, (u64)((u64)(8)))) & ((_const_math__bits__m3 & _const_max_u64)))) | (v__lshift_u64(((x & ((_const_math__bits__m3 & _const_max_u64)))), (u64)((u64)(8)))))); | ||
| 5324 | + y = (((((v__rshift_u64(y, (u64)((u64)(16)))) & ((_const_math__bits__m4 & _const_max_u64)))) | (v__lshift_u64(((y & ((_const_math__bits__m4 & _const_max_u64)))), (u64)((u64)(16)))))); | ||
| 5325 | + return ((v__rshift_u64(y, (u64)32)) | (v__lshift_u64(y, (u64)32))); | ||
| 5326 | +} | ||
| 5327 | +int math__bits__len_8(u8 x) { | ||
| 5328 | + return ((int)(_const_math__bits__len_8_tab[x])); | ||
| 5329 | +} | ||
| 5330 | +int math__bits__len_16(u16 x) { | ||
| 5331 | + u16 y = x; | ||
| 5332 | + int n = 0; | ||
| 5333 | + if (y >= 256) { | ||
| 5334 | + y = v__rshift_u16(y, (u64)8); | ||
| 5335 | + n = 8; | ||
| 5336 | + } | ||
| 5337 | + return n + ((int)(_const_math__bits__len_8_tab[((int)(y))])); | ||
| 5338 | +} | ||
| 5339 | +int math__bits__len_32(u32 x) { | ||
| 5340 | + u32 y = x; | ||
| 5341 | + int n = 0; | ||
| 5342 | + if (y >= 65536) { | ||
| 5343 | + y = v__rshift_u32(y, (u64)16); | ||
| 5344 | + n = 16; | ||
| 5345 | + } | ||
| 5346 | + if (y >= 256) { | ||
| 5347 | + y = v__rshift_u32(y, (u64)8); | ||
| 5348 | + n += 8; | ||
| 5349 | + } | ||
| 5350 | + return n + ((int)(_const_math__bits__len_8_tab[((int)(y))])); | ||
| 5351 | +} | ||
| 5352 | +int math__bits__len_64(u64 x) { | ||
| 5353 | + u64 y = x; | ||
| 5354 | + int n = 0; | ||
| 5355 | + if (y >= v__lshift_u64(((u64)(1)), (u64)((u64)(32)))) { | ||
| 5356 | + y = v__rshift_u64(y, (u64)32); | ||
| 5357 | + n = 32; | ||
| 5358 | + } | ||
| 5359 | + if (y >= v__lshift_u64(((u64)(1)), (u64)((u64)(16)))) { | ||
| 5360 | + y = v__rshift_u64(y, (u64)16); | ||
| 5361 | + n += 16; | ||
| 5362 | + } | ||
| 5363 | + if (y >= v__lshift_u64(((u64)(1)), (u64)((u64)(8)))) { | ||
| 5364 | + y = v__rshift_u64(y, (u64)8); | ||
| 5365 | + n += 8; | ||
| 5366 | + } | ||
| 5367 | + return n + ((int)(_const_math__bits__len_8_tab[((int)(y))])); | ||
| 5368 | +} | ||
| 5369 | +multi_return_u32_u32 math__bits__add_32(u32 x, u32 y, u32 carry) { | ||
| 5370 | + u64 sum64 = ((u64)(x)) + ((u64)(y)) + ((u64)(carry)); | ||
| 5371 | + u32 sum = ((u32)(sum64)); | ||
| 5372 | + u32 carry_out = ((u32)(v__rshift_u64(sum64, (u64)32))); | ||
| 5373 | + return (multi_return_u32_u32){.arg0=sum, .arg1=carry_out}; | ||
| 5374 | +} | ||
| 5375 | +multi_return_u64_u64 math__bits__add_64(u64 x, u64 y, u64 carry) { | ||
| 5376 | + u64 sum = x + y + carry; | ||
| 5377 | + u64 carry_out = v__rshift_u64(((((x & y)) | ((((x | y)) & ~sum)))), (u64)63); | ||
| 5378 | + return (multi_return_u64_u64){.arg0=sum, .arg1=carry_out}; | ||
| 5379 | +} | ||
| 5380 | +multi_return_u32_u32 math__bits__sub_32(u32 x, u32 y, u32 borrow) { | ||
| 5381 | + u32 diff = x - y - borrow; | ||
| 5382 | + u32 borrow_out = v__rshift_u32(((((~x & y)) | ((~((x ^ y)) & diff)))), (u64)31); | ||
| 5383 | + return (multi_return_u32_u32){.arg0=diff, .arg1=borrow_out}; | ||
| 5384 | +} | ||
| 5385 | +multi_return_u64_u64 math__bits__sub_64(u64 x, u64 y, u64 borrow) { | ||
| 5386 | + u64 diff = x - y - borrow; | ||
| 5387 | + u64 borrow_out = v__rshift_u64(((((~x & y)) | ((~((x ^ y)) & diff)))), (u64)63); | ||
| 5388 | + return (multi_return_u64_u64){.arg0=diff, .arg1=borrow_out}; | ||
| 5389 | +} | ||
| 5390 | +inline multi_return_u32_u32 math__bits__mul_32(u32 x, u32 y) { | ||
| 5391 | + return math__bits__mul_32_default(x, y); | ||
| 5392 | +} | ||
| 5393 | +inline VV_LOC multi_return_u32_u32 math__bits__mul_32_default(u32 x, u32 y) { | ||
| 5394 | + u64 tmp = ((u64)(x)) * ((u64)(y)); | ||
| 5395 | + u32 hi = ((u32)(v__rshift_u64(tmp, (u64)32))); | ||
| 5396 | + u32 lo = ((u32)(tmp)); | ||
| 5397 | + return (multi_return_u32_u32){.arg0=hi, .arg1=lo}; | ||
| 5398 | +} | ||
| 5399 | +inline multi_return_u64_u64 math__bits__pure_v_but_overridden_by_amd64_mul_64(u64 x, u64 y) { | ||
| 5400 | + return math__bits__mul_64_default(x, y); | ||
| 5401 | +} | ||
| 5402 | +VV_LOC multi_return_u64_u64 math__bits__mul_64_default(u64 x, u64 y) { | ||
| 5403 | + u64 x0 = (x & _const_math__bits__mask32); | ||
| 5404 | + u64 x1 = v__rshift_u64(x, (u64)32); | ||
| 5405 | + u64 y0 = (y & _const_math__bits__mask32); | ||
| 5406 | + u64 y1 = v__rshift_u64(y, (u64)32); | ||
| 5407 | + u64 w0 = x0 * y0; | ||
| 5408 | + u64 t = x1 * y0 + (v__rshift_u64(w0, (u64)32)); | ||
| 5409 | + u64 w1 = (t & _const_math__bits__mask32); | ||
| 5410 | + u64 w2 = v__rshift_u64(t, (u64)32); | ||
| 5411 | + w1 += x0 * y1; | ||
| 5412 | + u64 hi = x1 * y1 + w2 + (v__rshift_u64(w1, (u64)32)); | ||
| 5413 | + u64 lo = x * y; | ||
| 5414 | + return (multi_return_u64_u64){.arg0=hi, .arg1=lo}; | ||
| 5415 | +} | ||
| 5416 | +inline multi_return_u32_u32 math__bits__mul_add_32(u32 x, u32 y, u32 z) { | ||
| 5417 | + return math__bits__mul_add_32_default(x, y, z); | ||
| 5418 | +} | ||
| 5419 | +inline VV_LOC multi_return_u32_u32 math__bits__mul_add_32_default(u32 x, u32 y, u32 z) { | ||
| 5420 | + u64 tmp = ((u64)(x)) * ((u64)(y)) + ((u64)(z)); | ||
| 5421 | + u32 hi = ((u32)(v__rshift_u64(tmp, (u64)32))); | ||
| 5422 | + u32 lo = ((u32)(tmp)); | ||
| 5423 | + return (multi_return_u32_u32){.arg0=hi, .arg1=lo}; | ||
| 5424 | +} | ||
| 5425 | +inline multi_return_u64_u64 math__bits__pure_v_but_overridden_by_amd64_mul_add_64(u64 x, u64 y, u64 z) { | ||
| 5426 | + return math__bits__mul_add_64_default(x, y, z); | ||
| 5427 | +} | ||
| 5428 | +inline VV_LOC multi_return_u64_u64 math__bits__mul_add_64_default(u64 x, u64 y, u64 z) { | ||
| 5429 | + multi_return_u64_u64 mr_14968 = math__bits__mul_64(x, y); | ||
| 5430 | + u64 h = mr_14968.arg0; | ||
| 5431 | + u64 l = mr_14968.arg1; | ||
| 5432 | + u64 lo = l + z; | ||
| 5433 | + u64 hi = h + (u64[]){(lo < l)?1:0}[0]; | ||
| 5434 | + return (multi_return_u64_u64){.arg0=hi, .arg1=lo}; | ||
| 5435 | +} | ||
| 5436 | +inline multi_return_u32_u32 math__bits__div_32(u32 hi, u32 lo, u32 y) { | ||
| 5437 | + return math__bits__div_32_default(hi, lo, y); | ||
| 5438 | +} | ||
| 5439 | +VV_LOC multi_return_u32_u32 math__bits__div_32_default(u32 hi, u32 lo, u32 y) { | ||
| 5440 | + if (y == 0) { | ||
| 5441 | + builtin___v_panic(_const_math__bits__divide_error); | ||
| 5442 | + VUNREACHABLE(); | ||
| 5443 | + } | ||
| 5444 | + if (y <= hi) { | ||
| 5445 | + builtin___v_panic(_const_math__bits__overflow_error); | ||
| 5446 | + VUNREACHABLE(); | ||
| 5447 | + } | ||
| 5448 | + u64 z = ((v__lshift_u64(((u64)(hi)), (u64)32)) | ((u64)(lo))); | ||
| 5449 | + u32 quo = ((u32)(VSAFE_DIV_u64(z , ((u64)(y))))); | ||
| 5450 | + u32 rem = ((u32)(VSAFE_MOD_u64(z , ((u64)(y))))); | ||
| 5451 | + return (multi_return_u32_u32){.arg0=quo, .arg1=rem}; | ||
| 5452 | +} | ||
| 5453 | +inline multi_return_u64_u64 math__bits__pure_v_but_overridden_by_amd64_div_64(u64 hi, u64 lo, u64 y1) { | ||
| 5454 | + return math__bits__div_64_default(hi, lo, y1); | ||
| 5455 | +} | ||
| 5456 | +VV_LOC multi_return_u64_u64 math__bits__div_64_default(u64 hi, u64 lo, u64 y1) { | ||
| 5457 | + u64 y = y1; | ||
| 5458 | + if (y == 0) { | ||
| 5459 | + builtin___v_panic(_const_math__bits__divide_error); | ||
| 5460 | + VUNREACHABLE(); | ||
| 5461 | + } | ||
| 5462 | + if (y <= hi) { | ||
| 5463 | + builtin___v_panic(_const_math__bits__overflow_error); | ||
| 5464 | + VUNREACHABLE(); | ||
| 5465 | + } | ||
| 5466 | + u32 s = ((u32)(math__bits__leading_zeros_64(y))); | ||
| 5467 | + y = v__lshift_u64(y, (u64)s); | ||
| 5468 | + u64 yn1 = v__rshift_u64(y, (u64)32); | ||
| 5469 | + u64 yn0 = (y & _const_math__bits__mask32); | ||
| 5470 | + u64 ss1 = (v__lshift_u64(hi, (u64)s)); | ||
| 5471 | + u32 xxx = 64 - s; | ||
| 5472 | + u64 ss2 = v__rshift_u64(lo, (u64)xxx); | ||
| 5473 | + if (xxx == 64) { | ||
| 5474 | + ss2 = 0; | ||
| 5475 | + } | ||
| 5476 | + u64 un32 = (ss1 | ss2); | ||
| 5477 | + u64 un10 = v__lshift_u64(lo, (u64)s); | ||
| 5478 | + u64 un1 = v__rshift_u64(un10, (u64)32); | ||
| 5479 | + u64 un0 = (un10 & _const_math__bits__mask32); | ||
| 5480 | + u64 q1 = VSAFE_DIV_u64(un32 , yn1); | ||
| 5481 | + u64 rhat = un32 - (q1 * yn1); | ||
| 5482 | + for (;;) { | ||
| 5483 | + if (!(q1 >= _const_math__bits__two32 || (q1 * yn0) > ((_const_math__bits__two32 * rhat) + un1))) break; | ||
| 5484 | + q1--; | ||
| 5485 | + rhat += yn1; | ||
| 5486 | + if (rhat >= _const_math__bits__two32) { | ||
| 5487 | + break; | ||
| 5488 | + } | ||
| 5489 | + } | ||
| 5490 | + u64 un21 = (un32 * _const_math__bits__two32) + (un1 - (q1 * y)); | ||
| 5491 | + u64 q0 = VSAFE_DIV_u64(un21 , yn1); | ||
| 5492 | + rhat = un21 - q0 * yn1; | ||
| 5493 | + for (;;) { | ||
| 5494 | + if (!(q0 >= _const_math__bits__two32 || (q0 * yn0) > ((_const_math__bits__two32 * rhat) + un0))) break; | ||
| 5495 | + q0--; | ||
| 5496 | + rhat += yn1; | ||
| 5497 | + if (rhat >= _const_math__bits__two32) { | ||
| 5498 | + break; | ||
| 5499 | + } | ||
| 5500 | + } | ||
| 5501 | + u64 qq = ((q1 * _const_math__bits__two32) + q0); | ||
| 5502 | + u64 rr = v__rshift_u64(((un21 * _const_math__bits__two32) + un0 - (q0 * y)), (u64)s); | ||
| 5503 | + return (multi_return_u64_u64){.arg0=qq, .arg1=rr}; | ||
| 5504 | +} | ||
| 5505 | +inline u32 math__bits__rem_32(u32 hi, u32 lo, u32 y) { | ||
| 5506 | + if (y == 0) { | ||
| 5507 | + builtin___v_panic(_const_math__bits__divide_error); | ||
| 5508 | + VUNREACHABLE(); | ||
| 5509 | + } | ||
| 5510 | + return ((u32)(VSAFE_MOD_u64((((v__lshift_u64(((u64)(hi)), (u64)32)) | ((u64)(lo)))) , ((u64)(y))))); | ||
| 5511 | +} | ||
| 5512 | +inline u64 math__bits__rem_64(u64 hi, u64 lo, u64 y) { | ||
| 5513 | + if (y == 0) { | ||
| 5514 | + builtin___v_panic(_const_math__bits__divide_error); | ||
| 5515 | + VUNREACHABLE(); | ||
| 5516 | + } | ||
| 5517 | + multi_return_u64_u64 mr_18593 = math__bits__div_64(VSAFE_MOD_u64(hi , y), lo, y); | ||
| 5518 | + u64 rem = mr_18593.arg1; | ||
| 5519 | + return rem; | ||
| 5520 | +} | ||
| 5521 | +multi_return_f64_int math__bits__normalize(f64 x) { | ||
| 5522 | + f64 smallest_normal = 2.2250738585072014e-308; | ||
| 5523 | + if (((x > ((f64)(0.0)) ? (x) : (-x))) < smallest_normal) { | ||
| 5524 | + return (multi_return_f64_int){.arg0=(f64)(x * (v__lshift_u64(((u64)(1)), (u64)((u64)(52))))), .arg1=-52}; | ||
| 5525 | + } | ||
| 5526 | + return (multi_return_f64_int){.arg0=x, .arg1=0}; | ||
| 5527 | +} | ||
| 5528 | +inline u32 math__bits__f32_bits(f32 f) { | ||
| 5529 | + u32 p = *((u32*)(&f)); | ||
| 5530 | + return p; | ||
| 5531 | +} | ||
| 5532 | +inline f32 math__bits__f32_from_bits(u32 b) { | ||
| 5533 | + f32 p = *((f32*)(&b)); | ||
| 5534 | + return p; | ||
| 5535 | +} | ||
| 5536 | +inline u64 math__bits__f64_bits(f64 f) { | ||
| 5537 | + u64 p = *((u64*)(&f)); | ||
| 5538 | + return p; | ||
| 5539 | +} | ||
| 5540 | +inline f64 math__bits__f64_from_bits(u64 b) { | ||
| 5541 | + f64 p = *((f64*)(&b)); | ||
| 5542 | + return p; | ||
| 5543 | +} | ||
| 5544 | +VV_LOC multi_return_u32_u32_u32 strconv__lsr96(u32 s2, u32 s1, u32 s0) { | ||
| 5545 | + u32 r0 = ((u32)(0)); | ||
| 5546 | + u32 r1 = ((u32)(0)); | ||
| 5547 | + u32 r2 = ((u32)(0)); | ||
| 5548 | + r0 = ((v__rshift_u32(s0, (u64)1)) | (v__lshift_u32(((s1 & ((u32)(1)))), (u64)31))); | ||
| 5549 | + r1 = ((v__rshift_u32(s1, (u64)1)) | (v__lshift_u32(((s2 & ((u32)(1)))), (u64)31))); | ||
| 5550 | + r2 = v__rshift_u32(s2, (u64)1); | ||
| 5551 | + return (multi_return_u32_u32_u32){.arg0=r2, .arg1=r1, .arg2=r0}; | ||
| 5552 | +} | ||
| 5553 | +VV_LOC multi_return_u32_u32_u32 strconv__lsl96(u32 s2, u32 s1, u32 s0) { | ||
| 5554 | + u32 r0 = ((u32)(0)); | ||
| 5555 | + u32 r1 = ((u32)(0)); | ||
| 5556 | + u32 r2 = ((u32)(0)); | ||
| 5557 | + r2 = ((v__lshift_u32(s2, (u64)1)) | (v__rshift_u32(((s1 & (v__lshift_u32(((u32)(1)), (u64)31)))), (u64)31))); | ||
| 5558 | + r1 = ((v__lshift_u32(s1, (u64)1)) | (v__rshift_u32(((s0 & (v__lshift_u32(((u32)(1)), (u64)31)))), (u64)31))); | ||
| 5559 | + r0 = v__lshift_u32(s0, (u64)1); | ||
| 5560 | + return (multi_return_u32_u32_u32){.arg0=r2, .arg1=r1, .arg2=r0}; | ||
| 5561 | +} | ||
| 5562 | +VV_LOC multi_return_u32_u32_u32 strconv__add96(u32 s2, u32 s1, u32 s0, u32 d2, u32 d1, u32 d0) { | ||
| 5563 | + u64 w = ((u64)(0)); | ||
| 5564 | + u32 r0 = ((u32)(0)); | ||
| 5565 | + u32 r1 = ((u32)(0)); | ||
| 5566 | + u32 r2 = ((u32)(0)); | ||
| 5567 | + w = ((u64)(s0)) + ((u64)(d0)); | ||
| 5568 | + r0 = ((u32)(w)); | ||
| 5569 | + w = v__rshift_u64(w, (u64)32); | ||
| 5570 | + w += ((u64)(s1)) + ((u64)(d1)); | ||
| 5571 | + r1 = ((u32)(w)); | ||
| 5572 | + w = v__rshift_u64(w, (u64)32); | ||
| 5573 | + w += ((u64)(s2)) + ((u64)(d2)); | ||
| 5574 | + r2 = ((u32)(w)); | ||
| 5575 | + return (multi_return_u32_u32_u32){.arg0=r2, .arg1=r1, .arg2=r0}; | ||
| 5576 | +} | ||
| 5577 | +VV_LOC multi_return_strconv__ParserState_strconv__PrepNumber strconv__parser(string s) { | ||
| 5578 | + int digx = 0; | ||
| 5579 | + strconv__ParserState result = strconv__ParserState__ok; | ||
| 5580 | + bool expneg = false; | ||
| 5581 | + int expexp = 0; | ||
| 5582 | + int i = 0; | ||
| 5583 | + strconv__PrepNumber _t1 = ((strconv__PrepNumber){.negative = 0,.exponent = 0,.mantissa = 0,}); | ||
| 5584 | + strconv__PrepNumber pn = _t1; | ||
| 5585 | + for (;;) { | ||
| 5586 | + if (!(i < s.len && builtin__u8_is_space(s.str[ i]))) break; | ||
| 5587 | + i++; | ||
| 5588 | + } | ||
| 5589 | + if (s.str[ i] == '-') { | ||
| 5590 | + pn.negative = true; | ||
| 5591 | + i++; | ||
| 5592 | + } | ||
| 5593 | + if (s.str[ i] == '+') { | ||
| 5594 | + i++; | ||
| 5595 | + } | ||
| 5596 | + for (;;) { | ||
| 5597 | + if (!(i < s.len && builtin__u8_is_digit(s.str[ i]))) break; | ||
| 5598 | + if (pn.mantissa == 0 && s.str[ i] == _const_strconv__c_zero) { | ||
| 5599 | + i++; | ||
| 5600 | + continue; | ||
| 5601 | + } | ||
| 5602 | + if (digx < 18) { | ||
| 5603 | + pn.mantissa *= 10; | ||
| 5604 | + pn.mantissa += ((u64)((rune)(s.str[ i] - _const_strconv__c_zero))); | ||
| 5605 | + digx++; | ||
| 5606 | + } else if (pn.exponent < 2147483647) { | ||
| 5607 | + pn.exponent++; | ||
| 5608 | + } | ||
| 5609 | + i++; | ||
| 5610 | + } | ||
| 5611 | + if (i < s.len && s.str[ i] == '.') { | ||
| 5612 | + i++; | ||
| 5613 | + for (;;) { | ||
| 5614 | + if (!(i < s.len && builtin__u8_is_digit(s.str[ i]))) break; | ||
| 5615 | + if (pn.mantissa == 0 && s.str[ i] == _const_strconv__c_zero) { | ||
| 5616 | + pn.exponent--; | ||
| 5617 | + i++; | ||
| 5618 | + continue; | ||
| 5619 | + } | ||
| 5620 | + if (digx < 18) { | ||
| 5621 | + pn.mantissa *= 10; | ||
| 5622 | + pn.mantissa += ((u64)((rune)(s.str[ i] - _const_strconv__c_zero))); | ||
| 5623 | + pn.exponent--; | ||
| 5624 | + digx++; | ||
| 5625 | + } | ||
| 5626 | + i++; | ||
| 5627 | + } | ||
| 5628 | + } | ||
| 5629 | + if (i < s.len && (s.str[ i] == 'e' || s.str[ i] == 'E')) { | ||
| 5630 | + i++; | ||
| 5631 | + if (i < s.len) { | ||
| 5632 | + if (s.str[ i] == _const_strconv__c_plus) { | ||
| 5633 | + i++; | ||
| 5634 | + } else if (s.str[ i] == _const_strconv__c_minus) { | ||
| 5635 | + expneg = true; | ||
| 5636 | + i++; | ||
| 5637 | + } | ||
| 5638 | + for (;;) { | ||
| 5639 | + if (!(i < s.len && builtin__u8_is_digit(s.str[ i]))) break; | ||
| 5640 | + if (expexp < 214748364) { | ||
| 5641 | + expexp *= 10; | ||
| 5642 | + expexp += ((int)((rune)(s.str[ i] - _const_strconv__c_zero))); | ||
| 5643 | + } | ||
| 5644 | + i++; | ||
| 5645 | + } | ||
| 5646 | + } | ||
| 5647 | + } | ||
| 5648 | + if (expneg) { | ||
| 5649 | + expexp = -expexp; | ||
| 5650 | + } | ||
| 5651 | + pn.exponent += expexp; | ||
| 5652 | + if (pn.mantissa == 0) { | ||
| 5653 | + if (pn.negative) { | ||
| 5654 | + result = strconv__ParserState__mzero; | ||
| 5655 | + } else { | ||
| 5656 | + result = strconv__ParserState__pzero; | ||
| 5657 | + } | ||
| 5658 | + } else if (pn.exponent > 309) { | ||
| 5659 | + if (pn.negative) { | ||
| 5660 | + result = strconv__ParserState__minf; | ||
| 5661 | + } else { | ||
| 5662 | + result = strconv__ParserState__pinf; | ||
| 5663 | + } | ||
| 5664 | + } else if (pn.exponent < -328) { | ||
| 5665 | + if (pn.negative) { | ||
| 5666 | + result = strconv__ParserState__mzero; | ||
| 5667 | + } else { | ||
| 5668 | + result = strconv__ParserState__pzero; | ||
| 5669 | + } | ||
| 5670 | + } | ||
| 5671 | + if (i == 0 && s.len > 0) { | ||
| 5672 | + return (multi_return_strconv__ParserState_strconv__PrepNumber){.arg0=strconv__ParserState__invalid_number, .arg1=pn}; | ||
| 5673 | + } | ||
| 5674 | + if (i != s.len) { | ||
| 5675 | + return (multi_return_strconv__ParserState_strconv__PrepNumber){.arg0=strconv__ParserState__extra_char, .arg1=pn}; | ||
| 5676 | + } | ||
| 5677 | + return (multi_return_strconv__ParserState_strconv__PrepNumber){.arg0=result, .arg1=pn}; | ||
| 5678 | +} | ||
| 5679 | +VV_LOC u64 strconv__converter(strconv__PrepNumber* pn) { | ||
| 5680 | + int binexp = 92; | ||
| 5681 | + u32 s2 = ((u32)(0)); | ||
| 5682 | + u32 s1 = ((u32)(0)); | ||
| 5683 | + u32 s0 = ((u32)(0)); | ||
| 5684 | + u32 q2 = ((u32)(0)); | ||
| 5685 | + u32 q1 = ((u32)(0)); | ||
| 5686 | + u32 q0 = ((u32)(0)); | ||
| 5687 | + u32 r2 = ((u32)(0)); | ||
| 5688 | + u32 r1 = ((u32)(0)); | ||
| 5689 | + u32 r0 = ((u32)(0)); | ||
| 5690 | + u32 mask28 = ((u32)(v__lshift_u64(((u64)(0xF)), (u64)28))); | ||
| 5691 | + u64 result = ((u64)(0)); | ||
| 5692 | + s0 = ((u32)((pn->mantissa & ((u64)(0x00000000FFFFFFFFU))))); | ||
| 5693 | + s1 = ((u32)(v__rshift_u64(pn->mantissa, (u64)32))); | ||
| 5694 | + s2 = ((u32)(0)); | ||
| 5695 | + if (pn->mantissa == 0 && pn->exponent <= 0) { | ||
| 5696 | + return (pn->negative ? (_const_strconv__double_minus_zero) : (_const_strconv__double_plus_zero)); | ||
| 5697 | + } | ||
| 5698 | + for (;;) { | ||
| 5699 | + if (!(pn->exponent > 0)) break; | ||
| 5700 | + multi_return_u32_u32_u32 mr_5881 = strconv__lsl96(s2, s1, s0); | ||
| 5701 | + q2 = mr_5881.arg0; | ||
| 5702 | + q1 = mr_5881.arg1; | ||
| 5703 | + q0 = mr_5881.arg2; | ||
| 5704 | + multi_return_u32_u32_u32 mr_5927 = strconv__lsl96(q2, q1, q0); | ||
| 5705 | + r2 = mr_5927.arg0; | ||
| 5706 | + r1 = mr_5927.arg1; | ||
| 5707 | + r0 = mr_5927.arg2; | ||
| 5708 | + multi_return_u32_u32_u32 mr_5983 = strconv__lsl96(r2, r1, r0); | ||
| 5709 | + s2 = mr_5983.arg0; | ||
| 5710 | + s1 = mr_5983.arg1; | ||
| 5711 | + s0 = mr_5983.arg2; | ||
| 5712 | + multi_return_u32_u32_u32 mr_6039 = strconv__add96(s2, s1, s0, q2, q1, q0); | ||
| 5713 | + s2 = mr_6039.arg0; | ||
| 5714 | + s1 = mr_6039.arg1; | ||
| 5715 | + s0 = mr_6039.arg2; | ||
| 5716 | + pn->exponent--; | ||
| 5717 | + for (;;) { | ||
| 5718 | + if (!(((s2 & mask28)) != 0)) break; | ||
| 5719 | + multi_return_u32_u32_u32 mr_6162 = strconv__lsr96(s2, s1, s0); | ||
| 5720 | + q2 = mr_6162.arg0; | ||
| 5721 | + q1 = mr_6162.arg1; | ||
| 5722 | + q0 = mr_6162.arg2; | ||
| 5723 | + binexp++; | ||
| 5724 | + s2 = q2; | ||
| 5725 | + s1 = q1; | ||
| 5726 | + s0 = q0; | ||
| 5727 | + } | ||
| 5728 | + } | ||
| 5729 | + for (;;) { | ||
| 5730 | + if (!(pn->exponent < 0)) break; | ||
| 5731 | + for (;;) { | ||
| 5732 | + if (!(!(((s2 & (v__lshift_u32(((u32)(1)), (u64)31)))) != 0))) break; | ||
| 5733 | + multi_return_u32_u32_u32 mr_6309 = strconv__lsl96(s2, s1, s0); | ||
| 5734 | + q2 = mr_6309.arg0; | ||
| 5735 | + q1 = mr_6309.arg1; | ||
| 5736 | + q0 = mr_6309.arg2; | ||
| 5737 | + binexp--; | ||
| 5738 | + s2 = q2; | ||
| 5739 | + s1 = q1; | ||
| 5740 | + s0 = q0; | ||
| 5741 | + } | ||
| 5742 | + q2 = VSAFE_DIV_u32(s2 , _const_strconv__c_ten); | ||
| 5743 | + r1 = VSAFE_MOD_u32(s2 , _const_strconv__c_ten); | ||
| 5744 | + r2 = ((v__rshift_u32(s1, (u64)8)) | (v__lshift_u32(r1, (u64)24))); | ||
| 5745 | + q1 = VSAFE_DIV_u32(r2 , _const_strconv__c_ten); | ||
| 5746 | + r1 = VSAFE_MOD_u32(r2 , _const_strconv__c_ten); | ||
| 5747 | + r2 = (((v__lshift_u32(((s1 & ((u32)(0xFF)))), (u64)16)) | (v__rshift_u32(s0, (u64)16))) | (v__lshift_u32(r1, (u64)24))); | ||
| 5748 | + r0 = VSAFE_DIV_u32(r2 , _const_strconv__c_ten); | ||
| 5749 | + r1 = VSAFE_MOD_u32(r2 , _const_strconv__c_ten); | ||
| 5750 | + q1 = ((v__lshift_u32(q1, (u64)8)) | (v__rshift_u32(((r0 & ((u32)(0x00FF0000)))), (u64)16))); | ||
| 5751 | + q0 = v__lshift_u32(r0, (u64)16); | ||
| 5752 | + r2 = (((s0 & ((u32)(0xFFFF)))) | (v__lshift_u32(r1, (u64)16))); | ||
| 5753 | + q0 |= VSAFE_DIV_u32(r2 , _const_strconv__c_ten); | ||
| 5754 | + s2 = q2; | ||
| 5755 | + s1 = q1; | ||
| 5756 | + s0 = q0; | ||
| 5757 | + pn->exponent++; | ||
| 5758 | + } | ||
| 5759 | + if (s2 != 0 || s1 != 0 || s0 != 0) { | ||
| 5760 | + for (;;) { | ||
| 5761 | + if (!(((s2 & mask28)) == 0)) break; | ||
| 5762 | + multi_return_u32_u32_u32 mr_6989 = strconv__lsl96(s2, s1, s0); | ||
| 5763 | + q2 = mr_6989.arg0; | ||
| 5764 | + q1 = mr_6989.arg1; | ||
| 5765 | + q0 = mr_6989.arg2; | ||
| 5766 | + binexp--; | ||
| 5767 | + s2 = q2; | ||
| 5768 | + s1 = q1; | ||
| 5769 | + s0 = q0; | ||
| 5770 | + } | ||
| 5771 | + } | ||
| 5772 | + if (binexp < -1022 && ((s2 | s1)) != 0) { | ||
| 5773 | + int shift = -1022 - binexp; | ||
| 5774 | + if (shift > 60) { | ||
| 5775 | + return (pn->negative ? (_const_strconv__double_minus_zero) : (_const_strconv__double_plus_zero)); | ||
| 5776 | + } | ||
| 5777 | + u64 shifted = v__rshift_u64((((v__lshift_u64(((u64)(s2)), (u64)32)) | ((u64)(s1)))), (u64)((u32)(shift))); | ||
| 5778 | + u64 q = (v__rshift_u64(shifted, (u64)8)) + (u64[]){(((v__rshift_u64(shifted, (u64)7)) & 1) != 0 && (((shifted & 0x7F)) != 0 || ((v__rshift_u64(shifted, (u64)8)) & 1) != 0))?1:0}[0]; | ||
| 5779 | + return (((q & 0x000FFFFFFFFFFFFFLL)) | (v__lshift_u64((u64[]){(pn->negative)?1:0}[0], (u64)63))); | ||
| 5780 | + } | ||
| 5781 | + int nbit = 7; | ||
| 5782 | + u32 check_round_bit = v__lshift_u32(((u32)(1)), (u64)((u32)(nbit))); | ||
| 5783 | + u32 check_round_mask = v__lshift_u32(((u32)(0xFFFFFFFFU)), (u64)((u32)(nbit))); | ||
| 5784 | + if (((s1 & check_round_bit)) != 0) { | ||
| 5785 | + if (((s1 & ~check_round_mask)) != 0) { | ||
| 5786 | + multi_return_u32_u32_u32 mr_9182 = strconv__add96(s2, s1, s0, 0, check_round_bit, 0); | ||
| 5787 | + s2 = mr_9182.arg0; | ||
| 5788 | + s1 = mr_9182.arg1; | ||
| 5789 | + s0 = mr_9182.arg2; | ||
| 5790 | + } else { | ||
| 5791 | + if (((s1 & (v__lshift_u32(check_round_bit, (u64)((u32)(1)))))) != 0) { | ||
| 5792 | + multi_return_u32_u32_u32 mr_9376 = strconv__add96(s2, s1, s0, 0, check_round_bit, 0); | ||
| 5793 | + s2 = mr_9376.arg0; | ||
| 5794 | + s1 = mr_9376.arg1; | ||
| 5795 | + s0 = mr_9376.arg2; | ||
| 5796 | + } | ||
| 5797 | + } | ||
| 5798 | + s1 = (s1 & check_round_mask); | ||
| 5799 | + s0 = ((u32)(0)); | ||
| 5800 | + if ((s2 & (v__lshift_u32(mask28, (u64)((u32)(1))))) != 0) { | ||
| 5801 | + multi_return_u32_u32_u32 mr_9583 = strconv__lsr96(s2, s1, s0); | ||
| 5802 | + q2 = mr_9583.arg0; | ||
| 5803 | + q1 = mr_9583.arg1; | ||
| 5804 | + q0 = mr_9583.arg2; | ||
| 5805 | + binexp++; | ||
| 5806 | + s2 = q2; | ||
| 5807 | + s1 = q1; | ||
| 5808 | + s0 = q0; | ||
| 5809 | + } | ||
| 5810 | + } | ||
| 5811 | + binexp += 1023; | ||
| 5812 | + if (binexp > 2046) { | ||
| 5813 | + if (pn->negative) { | ||
| 5814 | + result = _const_strconv__double_minus_infinity; | ||
| 5815 | + } else { | ||
| 5816 | + result = _const_strconv__double_plus_infinity; | ||
| 5817 | + } | ||
| 5818 | + } else if (binexp < 1) { | ||
| 5819 | + if (pn->negative) { | ||
| 5820 | + result = _const_strconv__double_minus_zero; | ||
| 5821 | + } else { | ||
| 5822 | + result = _const_strconv__double_plus_zero; | ||
| 5823 | + } | ||
| 5824 | + } else if (s2 != 0) { | ||
| 5825 | + u64 q = ((u64)(0)); | ||
| 5826 | + u64 binexs2 = v__lshift_u64(((u64)(binexp)), (u64)52); | ||
| 5827 | + q = (((v__lshift_u64(((u64)((s2 & ~mask28))), (u64)24)) | (v__rshift_u64((((u64)(s1)) + ((u64)(128))), (u64)8))) | binexs2); | ||
| 5828 | + if (pn->negative) { | ||
| 5829 | + q |= (v__lshift_u64(((u64)(1)), (u64)63)); | ||
| 5830 | + } | ||
| 5831 | + result = q; | ||
| 5832 | + } | ||
| 5833 | + return result; | ||
| 5834 | +} | ||
| 5835 | +_result_f64 strconv__atof64(string s, strconv__AtoF64Param param) { | ||
| 5836 | + if (s.len == 0) { | ||
| 5837 | + return (_result_f64){ .is_error=true, .err=builtin___v_error(_S("expected a number found an empty string")), .data={E_STRUCT} }; | ||
| 5838 | + } | ||
| 5839 | + strconv__Float64u _t2 = ((strconv__Float64u){0}); | ||
| 5840 | + strconv__Float64u res = _t2; | ||
| 5841 | + multi_return_strconv__ParserState_strconv__PrepNumber mr_10868 = strconv__parser(s); | ||
| 5842 | + strconv__ParserState res_parsing = mr_10868.arg0; | ||
| 5843 | + strconv__PrepNumber pn = mr_10868.arg1; | ||
| 5844 | + switch (res_parsing) { | ||
| 5845 | + case strconv__ParserState__ok: { | ||
| 5846 | + res.u = strconv__converter((voidptr)&pn); | ||
| 5847 | + break; | ||
| 5848 | + } | ||
| 5849 | + case strconv__ParserState__pzero: { | ||
| 5850 | + res.u = _const_strconv__double_plus_zero; | ||
| 5851 | + break; | ||
| 5852 | + } | ||
| 5853 | + case strconv__ParserState__mzero: { | ||
| 5854 | + res.u = _const_strconv__double_minus_zero; | ||
| 5855 | + break; | ||
| 5856 | + } | ||
| 5857 | + case strconv__ParserState__pinf: { | ||
| 5858 | + res.u = _const_strconv__double_plus_infinity; | ||
| 5859 | + break; | ||
| 5860 | + } | ||
| 5861 | + case strconv__ParserState__minf: { | ||
| 5862 | + res.u = _const_strconv__double_minus_infinity; | ||
| 5863 | + break; | ||
| 5864 | + } | ||
| 5865 | + case strconv__ParserState__extra_char: { | ||
| 5866 | + if (param.allow_extra_chars) { | ||
| 5867 | + res.u = strconv__converter((voidptr)&pn); | ||
| 5868 | + } else { | ||
| 5869 | + return (_result_f64){ .is_error=true, .err=builtin___v_error(_S("extra char after number")), .data={E_STRUCT} }; | ||
| 5870 | + } | ||
| 5871 | + break; | ||
| 5872 | + } | ||
| 5873 | + case strconv__ParserState__invalid_number: { | ||
| 5874 | + return (_result_f64){ .is_error=true, .err=builtin___v_error(_S("not a number")), .data={E_STRUCT} }; | ||
| 5875 | + } | ||
| 5876 | + } | ||
| 5877 | + | ||
| 5878 | + _result_f64 _t5; | ||
| 5879 | + builtin___result_ok(&(f64[]) { res.f }, (_result*)(&_t5), sizeof(f64)); | ||
| 5880 | + | ||
| 5881 | + return _t5; | ||
| 5882 | +} | ||
| 5883 | +f64 strconv__atof_quick(string s) { | ||
| 5884 | + strconv__Float64u _t1 = ((strconv__Float64u){0}); | ||
| 5885 | + strconv__Float64u f = _t1; | ||
| 5886 | + f64 sign = ((f64)(1.0)); | ||
| 5887 | + int i = 0; | ||
| 5888 | + for (;;) { | ||
| 5889 | + if (!(i < s.len && s.str[ i] == ' ')) break; | ||
| 5890 | + i++; | ||
| 5891 | + } | ||
| 5892 | + if (i < s.len) { | ||
| 5893 | + if (s.str[ i] == '-') { | ||
| 5894 | + sign = -1.0; | ||
| 5895 | + i++; | ||
| 5896 | + } else if (s.str[ i] == '+') { | ||
| 5897 | + i++; | ||
| 5898 | + } | ||
| 5899 | + } | ||
| 5900 | + if (s.str[ i] == 'i' && i + 2 < s.len && s.str[ i + 1] == 'n' && s.str[ i + 2] == 'f') { | ||
| 5901 | + if (sign > ((f64)(0.0))) { | ||
| 5902 | + f.u = _const_strconv__double_plus_infinity; | ||
| 5903 | + } else { | ||
| 5904 | + f.u = _const_strconv__double_minus_infinity; | ||
| 5905 | + } | ||
| 5906 | + return f.f; | ||
| 5907 | + } | ||
| 5908 | + for (;;) { | ||
| 5909 | + if (!(i < s.len && s.str[ i] == '0')) break; | ||
| 5910 | + i++; | ||
| 5911 | + if (i >= s.len) { | ||
| 5912 | + if (sign > ((f64)(0.0))) { | ||
| 5913 | + f.u = _const_strconv__double_plus_zero; | ||
| 5914 | + } else { | ||
| 5915 | + f.u = _const_strconv__double_minus_zero; | ||
| 5916 | + } | ||
| 5917 | + return f.f; | ||
| 5918 | + } | ||
| 5919 | + } | ||
| 5920 | + for (;;) { | ||
| 5921 | + if (!(i < s.len && (s.str[ i] >= '0' && s.str[ i] <= '9'))) break; | ||
| 5922 | + f.f *= ((f64)(10.0)); | ||
| 5923 | + f.f += ((f64)((rune)(s.str[ i] - '0'))); | ||
| 5924 | + i++; | ||
| 5925 | + } | ||
| 5926 | + if (i < s.len && s.str[ i] == '.') { | ||
| 5927 | + i++; | ||
| 5928 | + f64 frac_mul = ((f64)(0.1)); | ||
| 5929 | + for (;;) { | ||
| 5930 | + if (!(i < s.len && (s.str[ i] >= '0' && s.str[ i] <= '9'))) break; | ||
| 5931 | + f.f += ((f64)((rune)(s.str[ i] - '0'))) * frac_mul; | ||
| 5932 | + frac_mul *= ((f64)(0.1)); | ||
| 5933 | + i++; | ||
| 5934 | + } | ||
| 5935 | + } | ||
| 5936 | + if (i < s.len && (s.str[ i] == 'e' || s.str[ i] == 'E')) { | ||
| 5937 | + i++; | ||
| 5938 | + int exp = 0; | ||
| 5939 | + int exp_sign = 1; | ||
| 5940 | + if (i < s.len) { | ||
| 5941 | + if (s.str[ i] == '-') { | ||
| 5942 | + exp_sign = -1; | ||
| 5943 | + i++; | ||
| 5944 | + } else if (s.str[ i] == '+') { | ||
| 5945 | + i++; | ||
| 5946 | + } | ||
| 5947 | + } | ||
| 5948 | + for (;;) { | ||
| 5949 | + if (!(i < s.len && s.str[ i] == '0')) break; | ||
| 5950 | + i++; | ||
| 5951 | + } | ||
| 5952 | + for (;;) { | ||
| 5953 | + if (!(i < s.len && (s.str[ i] >= '0' && s.str[ i] <= '9'))) break; | ||
| 5954 | + exp *= 10; | ||
| 5955 | + exp += ((int)((rune)(s.str[ i] - '0'))); | ||
| 5956 | + i++; | ||
| 5957 | + } | ||
| 5958 | + if (exp_sign == 1) { | ||
| 5959 | + if (exp > 309) { | ||
| 5960 | + if (sign > 0) { | ||
| 5961 | + f.u = _const_strconv__double_plus_infinity; | ||
| 5962 | + } else { | ||
| 5963 | + f.u = _const_strconv__double_minus_infinity; | ||
| 5964 | + } | ||
| 5965 | + return f.f; | ||
| 5966 | + } | ||
| 5967 | + strconv__Float64u _t5 = ((strconv__Float64u){.u = _const_strconv__pos_exp[exp],}); | ||
| 5968 | + strconv__Float64u tmp_mul = _t5; | ||
| 5969 | + f.f = f.f * tmp_mul.f; | ||
| 5970 | + } else { | ||
| 5971 | + if (exp > 324) { | ||
| 5972 | + if (sign > 0) { | ||
| 5973 | + f.u = _const_strconv__double_plus_zero; | ||
| 5974 | + } else { | ||
| 5975 | + f.u = _const_strconv__double_minus_zero; | ||
| 5976 | + } | ||
| 5977 | + return f.f; | ||
| 5978 | + } | ||
| 5979 | + strconv__Float64u _t7 = ((strconv__Float64u){.u = _const_strconv__neg_exp[exp],}); | ||
| 5980 | + strconv__Float64u tmp_mul = _t7; | ||
| 5981 | + f.f = f.f * tmp_mul.f; | ||
| 5982 | + } | ||
| 5983 | + } | ||
| 5984 | + { // Unsafe block | ||
| 5985 | + f.f = f.f * sign; | ||
| 5986 | + return f.f; | ||
| 5987 | + } | ||
| 5988 | + return 0; | ||
| 5989 | +} | ||
| 5990 | +inline u8 strconv__byte_to_lower(u8 c) { | ||
| 5991 | + return (c | 32); | ||
| 5992 | +} | ||
| 5993 | +_result_u64 strconv__common_parse_uint(string s, int _base, int _bit_size, bool error_on_non_digit, bool error_on_high_digit) { | ||
| 5994 | + multi_return_u64_int mr_730 = strconv__common_parse_uint2(s, _base, _bit_size); | ||
| 5995 | + u64 result = mr_730.arg0; | ||
| 5996 | + int err = mr_730.arg1; | ||
| 5997 | + if (err != 0 && (error_on_non_digit || error_on_high_digit)) { | ||
| 5998 | + switch (err) { | ||
| 5999 | + case -1: { | ||
| 6000 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(4, _MOV((string[4]){_S("common_parse_uint: wrong base "), builtin__int_str(_base), _S(" for "), s}))), .data={E_STRUCT} }; | ||
| 6001 | + } | ||
| 6002 | + case -2: { | ||
| 6003 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(4, _MOV((string[4]){_S("common_parse_uint: wrong bit size "), builtin__int_str(_bit_size), _S(" for "), s}))), .data={E_STRUCT} }; | ||
| 6004 | + } | ||
| 6005 | + case -3: { | ||
| 6006 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(2, _MOV((string[2]){_S("common_parse_uint: integer overflow "), s}))), .data={E_STRUCT} }; | ||
| 6007 | + } | ||
| 6008 | + default: { | ||
| 6009 | + { | ||
| 6010 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(2, _MOV((string[2]){_S("common_parse_uint: syntax error "), s}))), .data={E_STRUCT} }; | ||
| 6011 | + } | ||
| 6012 | + } | ||
| 6013 | + } | ||
| 6014 | + | ||
| 6015 | + } | ||
| 6016 | + _result_u64 _t5; | ||
| 6017 | + builtin___result_ok(&(u64[]) { result }, (_result*)(&_t5), sizeof(u64)); | ||
| 6018 | + | ||
| 6019 | + return _t5; | ||
| 6020 | +} | ||
| 6021 | +multi_return_u64_int strconv__common_parse_uint2(string s, int _base, int _bit_size) { | ||
| 6022 | + if ((s).len == 0) { | ||
| 6023 | + return (multi_return_u64_int){.arg0=((u64)(0)), .arg1=1}; | ||
| 6024 | + } | ||
| 6025 | + int bit_size = _bit_size; | ||
| 6026 | + int base = _base; | ||
| 6027 | + int start_index = 0; | ||
| 6028 | + if (base == 0) { | ||
| 6029 | + base = 10; | ||
| 6030 | + if (s.str[ 0] == '0') { | ||
| 6031 | + u8 ch = (s.len > 1 ? ((s.str[ 1] | 32)) : ('0')); | ||
| 6032 | + if (s.len >= 3) { | ||
| 6033 | + if (ch == 'b') { | ||
| 6034 | + base = 2; | ||
| 6035 | + start_index += 2; | ||
| 6036 | + } else if (ch == 'o') { | ||
| 6037 | + base = 8; | ||
| 6038 | + start_index += 2; | ||
| 6039 | + } else if (ch == 'x') { | ||
| 6040 | + base = 16; | ||
| 6041 | + start_index += 2; | ||
| 6042 | + } | ||
| 6043 | + if (s.str[ start_index] == '_') { | ||
| 6044 | + start_index++; | ||
| 6045 | + } | ||
| 6046 | + } else if (s.len >= 2 && (s.str[ 1] >= '0' && s.str[ 1] <= '9')) { | ||
| 6047 | + base = 10; | ||
| 6048 | + start_index++; | ||
| 6049 | + } else { | ||
| 6050 | + base = 8; | ||
| 6051 | + start_index++; | ||
| 6052 | + } | ||
| 6053 | + } | ||
| 6054 | + } | ||
| 6055 | + if (bit_size == 0) { | ||
| 6056 | + bit_size = _const_strconv__int_size; | ||
| 6057 | + } else if (bit_size < 0 || bit_size > 64) { | ||
| 6058 | + return (multi_return_u64_int){.arg0=((u64)(0)), .arg1=-2}; | ||
| 6059 | + } | ||
| 6060 | + u64 cutoff = VSAFE_DIV_u64(_const_max_u64 , ((u64)(base))) + ((u64)(1)); | ||
| 6061 | + u64 max_val = (bit_size == 64 ? (_const_max_u64) : ((v__lshift_u64(((u64)(1)), (u64)((u64)(bit_size)))) - ((u64)(1)))); | ||
| 6062 | + int basem1 = base - 1; | ||
| 6063 | + u64 n = ((u64)(0)); | ||
| 6064 | + for (int i = start_index; i < s.len; ++i) { | ||
| 6065 | + u8 c = s.str[ i]; | ||
| 6066 | + if (c == '_') { | ||
| 6067 | + if (i == start_index || i >= (s.len - 1)) { | ||
| 6068 | + return (multi_return_u64_int){.arg0=((u64)(0)), .arg1=1}; | ||
| 6069 | + } | ||
| 6070 | + if (s.str[ i - 1] == '_' || s.str[ i + 1] == '_') { | ||
| 6071 | + return (multi_return_u64_int){.arg0=((u64)(0)), .arg1=1}; | ||
| 6072 | + } | ||
| 6073 | + continue; | ||
| 6074 | + } | ||
| 6075 | + int sub_count = 0; | ||
| 6076 | + c -= 48; | ||
| 6077 | + if (c >= 17) { | ||
| 6078 | + sub_count++; | ||
| 6079 | + c -= 7; | ||
| 6080 | + if (c >= 42) { | ||
| 6081 | + sub_count++; | ||
| 6082 | + c -= 32; | ||
| 6083 | + } | ||
| 6084 | + } | ||
| 6085 | + if (c > basem1 || (sub_count == 0 && c > 9)) { | ||
| 6086 | + return (multi_return_u64_int){.arg0=n, .arg1=i + 1}; | ||
| 6087 | + } | ||
| 6088 | + if (n >= cutoff) { | ||
| 6089 | + return (multi_return_u64_int){.arg0=max_val, .arg1=-3}; | ||
| 6090 | + } | ||
| 6091 | + n *= ((u64)(base)); | ||
| 6092 | + u64 n1 = n + ((u64)(c)); | ||
| 6093 | + if (n1 < n || n1 > max_val) { | ||
| 6094 | + return (multi_return_u64_int){.arg0=max_val, .arg1=-3}; | ||
| 6095 | + } | ||
| 6096 | + n = n1; | ||
| 6097 | + } | ||
| 6098 | + return (multi_return_u64_int){.arg0=n, .arg1=0}; | ||
| 6099 | +} | ||
| 6100 | +_result_u64 strconv__parse_uint(string s, int _base, int _bit_size) { | ||
| 6101 | + return strconv__common_parse_uint(s, _base, _bit_size, true, true); | ||
| 6102 | +} | ||
| 6103 | +_result_i64 strconv__common_parse_int(string _s, int base, int _bit_size, bool error_on_non_digit, bool error_on_high_digit) { | ||
| 6104 | + if ((_s).len == 0) { | ||
| 6105 | + _result_i64 _t1; | ||
| 6106 | + builtin___result_ok(&(i64[]) { ((i64)(0)) }, (_result*)(&_t1), sizeof(i64)); | ||
| 6107 | + | ||
| 6108 | + return _t1; | ||
| 6109 | + } | ||
| 6110 | + int bit_size = _bit_size; | ||
| 6111 | + if (bit_size == 0) { | ||
| 6112 | + bit_size = _const_strconv__int_size; | ||
| 6113 | + } | ||
| 6114 | + string s = _s; | ||
| 6115 | + bool neg = false; | ||
| 6116 | + if (s.str[ 0] == '+') { | ||
| 6117 | + { // Unsafe block | ||
| 6118 | + s = builtin__tos(s.str + 1, s.len - 1); | ||
| 6119 | + } | ||
| 6120 | + } else if (s.str[ 0] == '-') { | ||
| 6121 | + neg = true; | ||
| 6122 | + { // Unsafe block | ||
| 6123 | + s = builtin__tos(s.str + 1, s.len - 1); | ||
| 6124 | + } | ||
| 6125 | + } | ||
| 6126 | + _result_u64 _t2 = strconv__common_parse_uint(s, base, bit_size, error_on_non_digit, error_on_high_digit); | ||
| 6127 | + if (_t2.is_error) { | ||
| 6128 | + _result_i64 _t3 = {0}; | ||
| 6129 | + _t3.is_error = true; | ||
| 6130 | + _t3.err = _t2.err; | ||
| 6131 | + return _t3; | ||
| 6132 | + } | ||
| 6133 | + | ||
| 6134 | + u64 un = (*(u64*)_t2.data); | ||
| 6135 | + if (un == 0) { | ||
| 6136 | + _result_i64 _t4; | ||
| 6137 | + builtin___result_ok(&(i64[]) { ((i64)(0)) }, (_result*)(&_t4), sizeof(i64)); | ||
| 6138 | + | ||
| 6139 | + return _t4; | ||
| 6140 | + } | ||
| 6141 | + u64 cutoff = v__lshift_u64(((u64)(1)), (u64)((u64)(bit_size - 1))); | ||
| 6142 | + if (!neg && un >= cutoff) { | ||
| 6143 | + if (error_on_high_digit) { | ||
| 6144 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(2, _MOV((string[2]){_S("common_parse_int: integer overflow "), _s}))), .data={E_STRUCT} }; | ||
| 6145 | + } | ||
| 6146 | + _result_i64 _t6; | ||
| 6147 | + builtin___result_ok(&(i64[]) { ((i64)(cutoff - ((u64)(1)))) }, (_result*)(&_t6), sizeof(i64)); | ||
| 6148 | + | ||
| 6149 | + return _t6; | ||
| 6150 | + } | ||
| 6151 | + if (neg && un > cutoff) { | ||
| 6152 | + if (error_on_high_digit) { | ||
| 6153 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(2, _MOV((string[2]){_S("common_parse_int: integer overflow "), _s}))), .data={E_STRUCT} }; | ||
| 6154 | + } | ||
| 6155 | + _result_i64 _t8; | ||
| 6156 | + builtin___result_ok(&(i64[]) { -((i64)(cutoff)) }, (_result*)(&_t8), sizeof(i64)); | ||
| 6157 | + | ||
| 6158 | + return _t8; | ||
| 6159 | + } | ||
| 6160 | + _result_i64 _t10; /* if prepend */ | ||
| 6161 | + if (neg) { | ||
| 6162 | + builtin___result_ok(&(i64[]) { -((i64)(un)) }, (_result*)(&_t10), sizeof(i64)); | ||
| 6163 | + goto _t11; | ||
| 6164 | + }; | ||
| 6165 | + { | ||
| 6166 | + builtin___result_ok(&(i64[]) { ((i64)(un)) }, (_result*)(&_t10), sizeof(i64)); | ||
| 6167 | + } | ||
| 6168 | + _t11: {}; | ||
| 6169 | + return _t10; | ||
| 6170 | +} | ||
| 6171 | +_result_i64 strconv__parse_int(string _s, int base, int _bit_size) { | ||
| 6172 | + return strconv__common_parse_int(_s, base, _bit_size, true, false); | ||
| 6173 | +} | ||
| 6174 | +VV_LOC _result_multi_return_i64_int strconv__atoi_common_check(string s) { | ||
| 6175 | + if ((s).len == 0) { | ||
| 6176 | + return (_result_multi_return_i64_int){ .is_error=true, .err=builtin___v_error(_S("strconv.atoi: parsing \"\": empty string")), .data={E_STRUCT} }; | ||
| 6177 | + } | ||
| 6178 | + int start_idx = 0; | ||
| 6179 | + i64 sign = ((i64)(1)); | ||
| 6180 | + if (s.str[ 0] == '-' || s.str[ 0] == '+') { | ||
| 6181 | + start_idx++; | ||
| 6182 | + if (s.str[ 0] == '-') { | ||
| 6183 | + sign = -1; | ||
| 6184 | + } | ||
| 6185 | + } | ||
| 6186 | + if (s.len - start_idx < 1) { | ||
| 6187 | + return (_result_multi_return_i64_int){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi: parsing \""), s, _S("\": no number after sign")}))), .data={E_STRUCT} }; | ||
| 6188 | + } | ||
| 6189 | + if (s.str[ start_idx] == '_' || s.str[ s.len - 1] == '_') { | ||
| 6190 | + return (_result_multi_return_i64_int){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi: parsing \""), s, _S("\": values cannot start or end with underscores")}))), .data={E_STRUCT} }; | ||
| 6191 | + } | ||
| 6192 | + _result_multi_return_i64_int _t4; | ||
| 6193 | + builtin___result_ok(&(multi_return_i64_int[]) { (multi_return_i64_int){.arg0=sign, .arg1=start_idx} }, (_result*)(&_t4), sizeof(multi_return_i64_int)); | ||
| 6194 | + return _t4; | ||
| 6195 | +} | ||
| 6196 | +VV_LOC _result_i64 strconv__atoi_common(string s, i64 type_min, i64 type_max) { | ||
| 6197 | + _result_multi_return_i64_int _t1 = strconv__atoi_common_check(s); | ||
| 6198 | + if (_t1.is_error) { | ||
| 6199 | + _result_i64 _t2 = {0}; | ||
| 6200 | + _t2.is_error = true; | ||
| 6201 | + _t2.err = _t1.err; | ||
| 6202 | + return _t2; | ||
| 6203 | + } | ||
| 6204 | + | ||
| 6205 | + multi_return_i64_int mr_7450 = (*(multi_return_i64_int*)_t1.data); | ||
| 6206 | + i64 sign = mr_7450.arg0; | ||
| 6207 | + int start_idx = mr_7450.arg1; | ||
| 6208 | + i64 x = ((i64)(0)); | ||
| 6209 | + bool underscored = false; | ||
| 6210 | + for (int i = start_idx; i < s.len; ++i) { | ||
| 6211 | + rune c = (rune)(s.str[ i] - '0'); | ||
| 6212 | + if (c == 47) { | ||
| 6213 | + if (underscored == true) { | ||
| 6214 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi: parsing \""), s, _S("\": consecutives underscores are not allowed")}))), .data={E_STRUCT} }; | ||
| 6215 | + } | ||
| 6216 | + underscored = true; | ||
| 6217 | + continue; | ||
| 6218 | + } else { | ||
| 6219 | + if (c > 9) { | ||
| 6220 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi: parsing \""), s, _S("\": invalid radix 10 character")}))), .data={E_STRUCT} }; | ||
| 6221 | + } | ||
| 6222 | + underscored = false; | ||
| 6223 | + x = (x * 10) + ((i64)(c * sign)); | ||
| 6224 | + if (sign == 1 && x > type_max) { | ||
| 6225 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi: parsing \""), s, _S("\": integer overflow")}))), .data={E_STRUCT} }; | ||
| 6226 | + } else { | ||
| 6227 | + if (x < type_min) { | ||
| 6228 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi: parsing \""), s, _S("\": integer underflow")}))), .data={E_STRUCT} }; | ||
| 6229 | + } | ||
| 6230 | + } | ||
| 6231 | + } | ||
| 6232 | + } | ||
| 6233 | + _result_i64 _t7; | ||
| 6234 | + builtin___result_ok(&(i64[]) { x }, (_result*)(&_t7), sizeof(i64)); | ||
| 6235 | + | ||
| 6236 | + return _t7; | ||
| 6237 | +} | ||
| 6238 | +_result_int strconv__atoi(string s) { | ||
| 6239 | + _result_i64 _t2 = strconv__atoi_common(s, _const_strconv__i64_min_int32, _const_strconv__i64_max_int32); | ||
| 6240 | + if (_t2.is_error) { | ||
| 6241 | + _result_int _t3 = {0}; | ||
| 6242 | + _t3.is_error = true; | ||
| 6243 | + _t3.err = _t2.err; | ||
| 6244 | + return _t3; | ||
| 6245 | + } | ||
| 6246 | + | ||
| 6247 | + _result_int _t1; | ||
| 6248 | + builtin___result_ok(&(int[]) { ((int)((*(i64*)_t2.data))) }, (_result*)(&_t1), sizeof(int)); | ||
| 6249 | + | ||
| 6250 | + return _t1; | ||
| 6251 | +} | ||
| 6252 | +_result_i8 strconv__atoi8(string s) { | ||
| 6253 | + _result_i64 _t2 = strconv__atoi_common(s, _const_min_i8, _const_max_i8); | ||
| 6254 | + if (_t2.is_error) { | ||
| 6255 | + _result_i8 _t3 = {0}; | ||
| 6256 | + _t3.is_error = true; | ||
| 6257 | + _t3.err = _t2.err; | ||
| 6258 | + return _t3; | ||
| 6259 | + } | ||
| 6260 | + | ||
| 6261 | + _result_i8 _t1; | ||
| 6262 | + builtin___result_ok(&(i8[]) { ((i8)((*(i64*)_t2.data))) }, (_result*)(&_t1), sizeof(i8)); | ||
| 6263 | + | ||
| 6264 | + return _t1; | ||
| 6265 | +} | ||
| 6266 | +_result_i16 strconv__atoi16(string s) { | ||
| 6267 | + _result_i64 _t2 = strconv__atoi_common(s, _const_min_i16, _const_max_i16); | ||
| 6268 | + if (_t2.is_error) { | ||
| 6269 | + _result_i16 _t3 = {0}; | ||
| 6270 | + _t3.is_error = true; | ||
| 6271 | + _t3.err = _t2.err; | ||
| 6272 | + return _t3; | ||
| 6273 | + } | ||
| 6274 | + | ||
| 6275 | + _result_i16 _t1; | ||
| 6276 | + builtin___result_ok(&(i16[]) { ((i16)((*(i64*)_t2.data))) }, (_result*)(&_t1), sizeof(i16)); | ||
| 6277 | + | ||
| 6278 | + return _t1; | ||
| 6279 | +} | ||
| 6280 | +_result_i32 strconv__atoi32(string s) { | ||
| 6281 | + _result_i64 _t2 = strconv__atoi_common(s, _const_min_i32, _const_max_i32); | ||
| 6282 | + if (_t2.is_error) { | ||
| 6283 | + _result_i32 _t3 = {0}; | ||
| 6284 | + _t3.is_error = true; | ||
| 6285 | + _t3.err = _t2.err; | ||
| 6286 | + return _t3; | ||
| 6287 | + } | ||
| 6288 | + | ||
| 6289 | + _result_i32 _t1; | ||
| 6290 | + builtin___result_ok(&(i32[]) { ((i32)((*(i64*)_t2.data))) }, (_result*)(&_t1), sizeof(i32)); | ||
| 6291 | + | ||
| 6292 | + return _t1; | ||
| 6293 | +} | ||
| 6294 | +_result_i64 strconv__atoi64(string s) { | ||
| 6295 | + _result_multi_return_i64_int _t1 = strconv__atoi_common_check(s); | ||
| 6296 | + if (_t1.is_error) { | ||
| 6297 | + _result_i64 _t2 = {0}; | ||
| 6298 | + _t2.is_error = true; | ||
| 6299 | + _t2.err = _t1.err; | ||
| 6300 | + return _t2; | ||
| 6301 | + } | ||
| 6302 | + | ||
| 6303 | + multi_return_i64_int mr_9202 = (*(multi_return_i64_int*)_t1.data); | ||
| 6304 | + i64 sign = mr_9202.arg0; | ||
| 6305 | + int start_idx = mr_9202.arg1; | ||
| 6306 | + i64 x = ((i64)(0)); | ||
| 6307 | + bool underscored = false; | ||
| 6308 | + for (int i = start_idx; i < s.len; ++i) { | ||
| 6309 | + rune c = (rune)(s.str[ i] - '0'); | ||
| 6310 | + if (c == 47) { | ||
| 6311 | + if (underscored == true) { | ||
| 6312 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi64: parsing \""), s, _S("\": consecutives underscores are not allowed")}))), .data={E_STRUCT} }; | ||
| 6313 | + } | ||
| 6314 | + underscored = true; | ||
| 6315 | + continue; | ||
| 6316 | + } else { | ||
| 6317 | + if (c > 9) { | ||
| 6318 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atoi64: parsing \""), s, _S("\": invalid radix 10 character")}))), .data={E_STRUCT} }; | ||
| 6319 | + } | ||
| 6320 | + underscored = false; | ||
| 6321 | + _result_i64 _t5 = strconv__safe_mul10_64bits(x); | ||
| 6322 | + if (_t5.is_error) { | ||
| 6323 | + IError _t6 = _t5.err; | ||
| 6324 | + IError err = _t6; | ||
| 6325 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__str_intp(3, _MOV((StrIntpData[]){{_S("strconv.atoi64: parsing \""), 0xfe10, {.d_s = s}, 0, 0, 0}, {_S("\": "), 0xfe10, {.d_s = builtin__IError_str(err)}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}))), .data={E_STRUCT} }; | ||
| 6326 | + } | ||
| 6327 | + | ||
| 6328 | + x = (*(i64*)_t5.data); | ||
| 6329 | + _result_i64 _t8 = strconv__safe_add_64bits(x, ((int)((i64)(c * sign)))); | ||
| 6330 | + if (_t8.is_error) { | ||
| 6331 | + IError _t9 = _t8.err; | ||
| 6332 | + IError err = _t9; | ||
| 6333 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(builtin__str_intp(3, _MOV((StrIntpData[]){{_S("strconv.atoi64: parsing \""), 0xfe10, {.d_s = s}, 0, 0, 0}, {_S("\": "), 0xfe10, {.d_s = builtin__IError_str(err)}, 0, 0, 0}, {_SLIT0, 0, { .d_c = 0 }, 0, 0, 0}}))), .data={E_STRUCT} }; | ||
| 6334 | + } | ||
| 6335 | + | ||
| 6336 | + x = (*(i64*)_t8.data); | ||
| 6337 | + } | ||
| 6338 | + } | ||
| 6339 | + _result_i64 _t11; | ||
| 6340 | + builtin___result_ok(&(i64[]) { x }, (_result*)(&_t11), sizeof(i64)); | ||
| 6341 | + | ||
| 6342 | + return _t11; | ||
| 6343 | +} | ||
| 6344 | +inline VV_LOC _result_i64 strconv__safe_add_64bits(i64 a, i64 b) { | ||
| 6345 | + if (a > 0 && b > (_const_max_i64 - a)) { | ||
| 6346 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(_S("integer overflow")), .data={E_STRUCT} }; | ||
| 6347 | + } else if (a < 0 && b < (_const_min_i64 - a)) { | ||
| 6348 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(_S("integer underflow")), .data={E_STRUCT} }; | ||
| 6349 | + } | ||
| 6350 | + _result_i64 _t3; | ||
| 6351 | + builtin___result_ok(&(i64[]) { a + b }, (_result*)(&_t3), sizeof(i64)); | ||
| 6352 | + | ||
| 6353 | + return _t3; | ||
| 6354 | +} | ||
| 6355 | +inline VV_LOC _result_i64 strconv__safe_mul10_64bits(i64 a) { | ||
| 6356 | + if (a > 0 && a > (VSAFE_DIV_i64(_const_max_i64 , 10))) { | ||
| 6357 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(_S("integer overflow")), .data={E_STRUCT} }; | ||
| 6358 | + } | ||
| 6359 | + if (a < 0 && a < (VSAFE_DIV_i64(_const_min_i64 , 10))) { | ||
| 6360 | + return (_result_i64){ .is_error=true, .err=builtin___v_error(_S("integer underflow")), .data={E_STRUCT} }; | ||
| 6361 | + } | ||
| 6362 | + _result_i64 _t3; | ||
| 6363 | + builtin___result_ok(&(i64[]) { a * 10 }, (_result*)(&_t3), sizeof(i64)); | ||
| 6364 | + | ||
| 6365 | + return _t3; | ||
| 6366 | +} | ||
| 6367 | +VV_LOC _result_int strconv__atou_common_check(string s) { | ||
| 6368 | + if ((s).len == 0) { | ||
| 6369 | + return (_result_int){ .is_error=true, .err=builtin___v_error(_S("strconv.atou: parsing \"\": empty string")), .data={E_STRUCT} }; | ||
| 6370 | + } | ||
| 6371 | + int start_idx = 0; | ||
| 6372 | + if (s.str[ 0] == '-') { | ||
| 6373 | + return (_result_int){ .is_error=true, .err=builtin___v_error(_S("strconv.atou: parsing \"{s}\" : negative value")), .data={E_STRUCT} }; | ||
| 6374 | + } | ||
| 6375 | + if (s.str[ 0] == '+') { | ||
| 6376 | + start_idx++; | ||
| 6377 | + } | ||
| 6378 | + if (s.len - start_idx < 1) { | ||
| 6379 | + return (_result_int){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atou: parsing \""), s, _S("\": no number after sign")}))), .data={E_STRUCT} }; | ||
| 6380 | + } | ||
| 6381 | + if (s.str[ start_idx] == '_' || s.str[ s.len - 1] == '_') { | ||
| 6382 | + return (_result_int){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atou: parsing \""), s, _S("\": values cannot start or end with underscores")}))), .data={E_STRUCT} }; | ||
| 6383 | + } | ||
| 6384 | + _result_int _t5; | ||
| 6385 | + builtin___result_ok(&(int[]) { start_idx }, (_result*)(&_t5), sizeof(int)); | ||
| 6386 | + | ||
| 6387 | + return _t5; | ||
| 6388 | +} | ||
| 6389 | +VV_LOC _result_u64 strconv__atou_common(string s, u64 type_max) { | ||
| 6390 | + _result_int _t1 = strconv__atou_common_check(s); | ||
| 6391 | + if (_t1.is_error) { | ||
| 6392 | + _result_u64 _t2 = {0}; | ||
| 6393 | + _t2.is_error = true; | ||
| 6394 | + _t2.err = _t1.err; | ||
| 6395 | + return _t2; | ||
| 6396 | + } | ||
| 6397 | + | ||
| 6398 | + int start_idx = ((int)((*(int*)_t1.data))); | ||
| 6399 | + u64 x = ((u64)(0)); | ||
| 6400 | + bool underscored = false; | ||
| 6401 | + for (int i = start_idx; i < s.len; ++i) { | ||
| 6402 | + rune c = (rune)(s.str[ i] - '0'); | ||
| 6403 | + if (c == 47) { | ||
| 6404 | + if (underscored == true) { | ||
| 6405 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atou: parsing \""), s, _S("\": consecutives underscores are not allowed")}))), .data={E_STRUCT} }; | ||
| 6406 | + } | ||
| 6407 | + underscored = true; | ||
| 6408 | + continue; | ||
| 6409 | + } else { | ||
| 6410 | + if (c > 9) { | ||
| 6411 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atou: parsing \""), s, _S("\": invalid radix 10 character")}))), .data={E_STRUCT} }; | ||
| 6412 | + } | ||
| 6413 | + underscored = false; | ||
| 6414 | + if (x > VSAFE_DIV_u64(type_max , 10)) { | ||
| 6415 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atou: parsing \""), s, _S("\": integer overflow")}))), .data={E_STRUCT} }; | ||
| 6416 | + } | ||
| 6417 | + x *= 10; | ||
| 6418 | + if (x > type_max - ((u64)(c))) { | ||
| 6419 | + return (_result_u64){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(3, _MOV((string[3]){_S("strconv.atou: parsing \""), s, _S("\": integer overflow")}))), .data={E_STRUCT} }; | ||
| 6420 | + } | ||
| 6421 | + x += ((u64)(c)); | ||
| 6422 | + } | ||
| 6423 | + } | ||
| 6424 | + _result_u64 _t7; | ||
| 6425 | + builtin___result_ok(&(u64[]) { x }, (_result*)(&_t7), sizeof(u64)); | ||
| 6426 | + | ||
| 6427 | + return _t7; | ||
| 6428 | +} | ||
| 6429 | +_result_u8 strconv__atou8(string s) { | ||
| 6430 | + _result_u64 _t2 = strconv__atou_common(s, _const_max_u8); | ||
| 6431 | + if (_t2.is_error) { | ||
| 6432 | + _result_u8 _t3 = {0}; | ||
| 6433 | + _t3.is_error = true; | ||
| 6434 | + _t3.err = _t2.err; | ||
| 6435 | + return _t3; | ||
| 6436 | + } | ||
| 6437 | + | ||
| 6438 | + _result_u8 _t1; | ||
| 6439 | + builtin___result_ok(&(u8[]) { ((u8)((*(u64*)_t2.data))) }, (_result*)(&_t1), sizeof(u8)); | ||
| 6440 | + | ||
| 6441 | + return _t1; | ||
| 6442 | +} | ||
| 6443 | +_result_u16 strconv__atou16(string s) { | ||
| 6444 | + _result_u64 _t2 = strconv__atou_common(s, _const_max_u16); | ||
| 6445 | + if (_t2.is_error) { | ||
| 6446 | + _result_u16 _t3 = {0}; | ||
| 6447 | + _t3.is_error = true; | ||
| 6448 | + _t3.err = _t2.err; | ||
| 6449 | + return _t3; | ||
| 6450 | + } | ||
| 6451 | + | ||
| 6452 | + _result_u16 _t1; | ||
| 6453 | + builtin___result_ok(&(u16[]) { ((u16)((*(u64*)_t2.data))) }, (_result*)(&_t1), sizeof(u16)); | ||
| 6454 | + | ||
| 6455 | + return _t1; | ||
| 6456 | +} | ||
| 6457 | +_result_u32 strconv__atou(string s) { | ||
| 6458 | + _result_u64 _t2 = strconv__atou_common(s, _const_max_u32); | ||
| 6459 | + if (_t2.is_error) { | ||
| 6460 | + _result_u32 _t3 = {0}; | ||
| 6461 | + _t3.is_error = true; | ||
| 6462 | + _t3.err = _t2.err; | ||
| 6463 | + return _t3; | ||
| 6464 | + } | ||
| 6465 | + | ||
| 6466 | + _result_u32 _t1; | ||
| 6467 | + builtin___result_ok(&(u32[]) { ((u32)((*(u64*)_t2.data))) }, (_result*)(&_t1), sizeof(u32)); | ||
| 6468 | + | ||
| 6469 | + return _t1; | ||
| 6470 | +} | ||
| 6471 | +_result_u32 strconv__atou32(string s) { | ||
| 6472 | + _result_u64 _t2 = strconv__atou_common(s, _const_max_u32); | ||
| 6473 | + if (_t2.is_error) { | ||
| 6474 | + _result_u32 _t3 = {0}; | ||
| 6475 | + _t3.is_error = true; | ||
| 6476 | + _t3.err = _t2.err; | ||
| 6477 | + return _t3; | ||
| 6478 | + } | ||
| 6479 | + | ||
| 6480 | + _result_u32 _t1; | ||
| 6481 | + builtin___result_ok(&(u32[]) { ((u32)((*(u64*)_t2.data))) }, (_result*)(&_t1), sizeof(u32)); | ||
| 6482 | + | ||
| 6483 | + return _t1; | ||
| 6484 | +} | ||
| 6485 | +_result_u64 strconv__atou64(string s) { | ||
| 6486 | + _result_u64 _t2 = strconv__atou_common(s, _const_max_u64); | ||
| 6487 | + if (_t2.is_error) { | ||
| 6488 | + _result_u64 _t3 = {0}; | ||
| 6489 | + _t3.is_error = true; | ||
| 6490 | + _t3.err = _t2.err; | ||
| 6491 | + return _t3; | ||
| 6492 | + } | ||
| 6493 | + | ||
| 6494 | + _result_u64 _t1; | ||
| 6495 | + builtin___result_ok(&(u64[]) { ((u64)((*(u64*)_t2.data))) }, (_result*)(&_t1), sizeof(u64)); | ||
| 6496 | + | ||
| 6497 | + return _t1; | ||
| 6498 | +} | ||
| 6499 | +string strconv__Dec32_get_string_32(strconv__Dec32 d, bool neg, int i_n_digit, int i_pad_digit) { | ||
| 6500 | + int n_digit = i_n_digit + 1; | ||
| 6501 | + int pad_digit = i_pad_digit + 1; | ||
| 6502 | + u32 out = d.m; | ||
| 6503 | + int out_len = strconv__dec_digits(out); | ||
| 6504 | + int out_len_original = out_len; | ||
| 6505 | + int fw_zeros = 0; | ||
| 6506 | + if (pad_digit > out_len) { | ||
| 6507 | + fw_zeros = pad_digit - out_len; | ||
| 6508 | + } | ||
| 6509 | + Array_u8 buf = builtin____new_array_with_default(((int)(out_len + 5 + 1 + 1)), 0, sizeof(u8), 0); | ||
| 6510 | + int i = 0; | ||
| 6511 | + if (neg) { | ||
| 6512 | + if (buf.data != 0) { | ||
| 6513 | + ((u8*)buf.data)[i] = '-'; | ||
| 6514 | + } | ||
| 6515 | + i++; | ||
| 6516 | + } | ||
| 6517 | + int disp = 0; | ||
| 6518 | + if (out_len <= 1) { | ||
| 6519 | + disp = 1; | ||
| 6520 | + } | ||
| 6521 | + if (n_digit < out_len) { | ||
| 6522 | + out += _const_strconv__ten_pow_table_32[out_len - n_digit - 1] * 5; | ||
| 6523 | + out = VSAFE_DIV_u32(out,_const_strconv__ten_pow_table_32[out_len - n_digit]); | ||
| 6524 | + out_len = n_digit; | ||
| 6525 | + } | ||
| 6526 | + int y = i + out_len; | ||
| 6527 | + int x = 0; | ||
| 6528 | + for (;;) { | ||
| 6529 | + if (!(x < (out_len - disp - 1))) break; | ||
| 6530 | + ((u8*)buf.data)[y - x] = (rune)('0' + ((u8)(VSAFE_MOD_u32(out , 10)))); | ||
| 6531 | + out = VSAFE_DIV_u32(out,10); | ||
| 6532 | + i++; | ||
| 6533 | + x++; | ||
| 6534 | + } | ||
| 6535 | + if (i_n_digit == 0) { | ||
| 6536 | + { // Unsafe block | ||
| 6537 | + ((u8*)buf.data)[i] = 0; | ||
| 6538 | + return builtin__tos(builtin__memdup(&((u8*)buf.data)[0], i + 1), i); | ||
| 6539 | + } | ||
| 6540 | + } | ||
| 6541 | + if (out_len > 1 || fw_zeros > 0) { | ||
| 6542 | + ((u8*)buf.data)[y - x] = '.'; | ||
| 6543 | + i++; | ||
| 6544 | + } | ||
| 6545 | + x++; | ||
| 6546 | + if (y - x >= 0) { | ||
| 6547 | + ((u8*)buf.data)[y - x] = (rune)('0' + ((u8)(VSAFE_MOD_u32(out , 10)))); | ||
| 6548 | + i++; | ||
| 6549 | + } | ||
| 6550 | + for (;;) { | ||
| 6551 | + if (!(fw_zeros > 0)) break; | ||
| 6552 | + ((u8*)buf.data)[i] = '0'; | ||
| 6553 | + i++; | ||
| 6554 | + fw_zeros--; | ||
| 6555 | + } | ||
| 6556 | + ((u8*)buf.data)[i] = 'e'; | ||
| 6557 | + i++; | ||
| 6558 | + int exp = d.e + out_len_original - 1; | ||
| 6559 | + if (exp < 0) { | ||
| 6560 | + ((u8*)buf.data)[i] = '-'; | ||
| 6561 | + i++; | ||
| 6562 | + exp = -exp; | ||
| 6563 | + } else { | ||
| 6564 | + ((u8*)buf.data)[i] = '+'; | ||
| 6565 | + i++; | ||
| 6566 | + } | ||
| 6567 | + int d1 = VSAFE_MOD_int(exp , 10); | ||
| 6568 | + int d0 = VSAFE_DIV_int(exp , 10); | ||
| 6569 | + ((u8*)buf.data)[i] = (rune)('0' + ((u8)(d0))); | ||
| 6570 | + i++; | ||
| 6571 | + ((u8*)buf.data)[i] = (rune)('0' + ((u8)(d1))); | ||
| 6572 | + i++; | ||
| 6573 | + ((u8*)buf.data)[i] = 0; | ||
| 6574 | + return builtin__tos(builtin__memdup(&((u8*)buf.data)[0], i + 1), i); | ||
| 6575 | +} | ||
| 6576 | +VV_LOC multi_return_strconv__Dec32_bool strconv__f32_to_decimal_exact_int(u32 i_mant, u32 exp) { | ||
| 6577 | + strconv__Dec32 _t1 = ((strconv__Dec32){.m = 0,.e = 0,}); | ||
| 6578 | + strconv__Dec32 d = _t1; | ||
| 6579 | + u32 e = exp - 127; | ||
| 6580 | + if (e > _const_strconv__mantbits32) { | ||
| 6581 | + return (multi_return_strconv__Dec32_bool){.arg0=d, .arg1=false}; | ||
| 6582 | + } | ||
| 6583 | + u32 shift = _const_strconv__mantbits32 - e; | ||
| 6584 | + u32 mant = (i_mant | 0x00800000); | ||
| 6585 | + d.m = v__rshift_u32(mant, (u64)shift); | ||
| 6586 | + if ((v__lshift_u32(d.m, (u64)shift)) != mant) { | ||
| 6587 | + return (multi_return_strconv__Dec32_bool){.arg0=d, .arg1=false}; | ||
| 6588 | + } | ||
| 6589 | + for (;;) { | ||
| 6590 | + if (!((VSAFE_MOD_u32(d.m , 10)) == 0)) break; | ||
| 6591 | + d.m = VSAFE_DIV_u32(d.m,10); | ||
| 6592 | + d.e++; | ||
| 6593 | + } | ||
| 6594 | + return (multi_return_strconv__Dec32_bool){.arg0=d, .arg1=true}; | ||
| 6595 | +} | ||
| 6596 | +VV_LOC strconv__Dec32 strconv__f32_to_decimal(u32 mant, u32 exp) { | ||
| 6597 | + int e2 = 0; | ||
| 6598 | + u32 m2 = ((u32)(0)); | ||
| 6599 | + if (exp == 0) { | ||
| 6600 | + e2 = -126 - ((int)(_const_strconv__mantbits32)) - 2; | ||
| 6601 | + m2 = mant; | ||
| 6602 | + } else { | ||
| 6603 | + e2 = ((int)(exp)) - 127 - ((int)(_const_strconv__mantbits32)) - 2; | ||
| 6604 | + m2 = ((v__lshift_u32(((u32)(1)), (u64)_const_strconv__mantbits32)) | mant); | ||
| 6605 | + } | ||
| 6606 | + bool even = ((m2 & 1)) == 0; | ||
| 6607 | + bool accept_bounds = even; | ||
| 6608 | + u32 mv = ((u32)(4 * m2)); | ||
| 6609 | + u32 mp = ((u32)(4 * m2 + 2)); | ||
| 6610 | + u32 mm_shift = strconv__bool_to_u32(mant != 0 || exp <= 1); | ||
| 6611 | + u32 mm = ((u32)(4 * m2 - 1 - mm_shift)); | ||
| 6612 | + u32 vr = ((u32)(0)); | ||
| 6613 | + u32 vp = ((u32)(0)); | ||
| 6614 | + u32 vm = ((u32)(0)); | ||
| 6615 | + int e10 = 0; | ||
| 6616 | + bool vm_is_trailing_zeros = false; | ||
| 6617 | + bool vr_is_trailing_zeros = false; | ||
| 6618 | + u8 last_removed_digit = ((u8)(0)); | ||
| 6619 | + if (e2 >= 0) { | ||
| 6620 | + u32 q = strconv__log10_pow2(e2); | ||
| 6621 | + e10 = ((int)(q)); | ||
| 6622 | + int k = 59 + strconv__pow5_bits(((int)(q))) - 1; | ||
| 6623 | + int i = -e2 + ((int)(q)) + k; | ||
| 6624 | + vr = strconv__mul_pow5_invdiv_pow2(mv, q, i); | ||
| 6625 | + vp = strconv__mul_pow5_invdiv_pow2(mp, q, i); | ||
| 6626 | + vm = strconv__mul_pow5_invdiv_pow2(mm, q, i); | ||
| 6627 | + if (q != 0 && VSAFE_DIV_u32((vp - 1) , 10) <= VSAFE_DIV_u32(vm , 10)) { | ||
| 6628 | + int l = 59 + strconv__pow5_bits(((int)(q - 1))) - 1; | ||
| 6629 | + last_removed_digit = ((u8)(VSAFE_MOD_u32(strconv__mul_pow5_invdiv_pow2(mv, q - 1, -e2 + ((int)(q - 1)) + l) , 10))); | ||
| 6630 | + } | ||
| 6631 | + if (q <= 9) { | ||
| 6632 | + if (VSAFE_MOD_u32(mv , 5) == 0) { | ||
| 6633 | + vr_is_trailing_zeros = strconv__multiple_of_power_of_five_32(mv, q); | ||
| 6634 | + } else if (accept_bounds) { | ||
| 6635 | + vm_is_trailing_zeros = strconv__multiple_of_power_of_five_32(mm, q); | ||
| 6636 | + } else if (strconv__multiple_of_power_of_five_32(mp, q)) { | ||
| 6637 | + vp--; | ||
| 6638 | + } | ||
| 6639 | + } | ||
| 6640 | + } else { | ||
| 6641 | + u32 q = strconv__log10_pow5(-e2); | ||
| 6642 | + e10 = ((int)(q)) + e2; | ||
| 6643 | + int i = -e2 - ((int)(q)); | ||
| 6644 | + int k = strconv__pow5_bits(i) - 61; | ||
| 6645 | + int j = ((int)(q)) - k; | ||
| 6646 | + vr = strconv__mul_pow5_div_pow2(mv, ((u32)(i)), j); | ||
| 6647 | + vp = strconv__mul_pow5_div_pow2(mp, ((u32)(i)), j); | ||
| 6648 | + vm = strconv__mul_pow5_div_pow2(mm, ((u32)(i)), j); | ||
| 6649 | + if (q != 0 && (VSAFE_DIV_u32((vp - 1) , 10)) <= VSAFE_DIV_u32(vm , 10)) { | ||
| 6650 | + j = ((int)(q)) - 1 - (strconv__pow5_bits(i + 1) - 61); | ||
| 6651 | + last_removed_digit = ((u8)(VSAFE_MOD_u32(strconv__mul_pow5_div_pow2(mv, ((u32)(i + 1)), j) , 10))); | ||
| 6652 | + } | ||
| 6653 | + if (q <= 1) { | ||
| 6654 | + vr_is_trailing_zeros = true; | ||
| 6655 | + if (accept_bounds) { | ||
| 6656 | + vm_is_trailing_zeros = mm_shift == 1; | ||
| 6657 | + } else { | ||
| 6658 | + vp--; | ||
| 6659 | + } | ||
| 6660 | + } else if (q < 31) { | ||
| 6661 | + vr_is_trailing_zeros = strconv__multiple_of_power_of_two_32(mv, q - 1); | ||
| 6662 | + } | ||
| 6663 | + } | ||
| 6664 | + int removed = 0; | ||
| 6665 | + u32 out = ((u32)(0)); | ||
| 6666 | + if (vm_is_trailing_zeros || vr_is_trailing_zeros) { | ||
| 6667 | + for (;;) { | ||
| 6668 | + if (!(VSAFE_DIV_u32(vp , 10) > VSAFE_DIV_u32(vm , 10))) break; | ||
| 6669 | + vm_is_trailing_zeros = vm_is_trailing_zeros && (VSAFE_MOD_u32(vm , 10)) == 0; | ||
| 6670 | + vr_is_trailing_zeros = vr_is_trailing_zeros && last_removed_digit == 0; | ||
| 6671 | + last_removed_digit = ((u8)(VSAFE_MOD_u32(vr , 10))); | ||
| 6672 | + vr = VSAFE_DIV_u32(vr,10); | ||
| 6673 | + vp = VSAFE_DIV_u32(vp,10); | ||
| 6674 | + vm = VSAFE_DIV_u32(vm,10); | ||
| 6675 | + removed++; | ||
| 6676 | + } | ||
| 6677 | + if (vm_is_trailing_zeros) { | ||
| 6678 | + for (;;) { | ||
| 6679 | + if (!(VSAFE_MOD_u32(vm , 10) == 0)) break; | ||
| 6680 | + vr_is_trailing_zeros = vr_is_trailing_zeros && last_removed_digit == 0; | ||
| 6681 | + last_removed_digit = ((u8)(VSAFE_MOD_u32(vr , 10))); | ||
| 6682 | + vr = VSAFE_DIV_u32(vr,10); | ||
| 6683 | + vp = VSAFE_DIV_u32(vp,10); | ||
| 6684 | + vm = VSAFE_DIV_u32(vm,10); | ||
| 6685 | + removed++; | ||
| 6686 | + } | ||
| 6687 | + } | ||
| 6688 | + if (vr_is_trailing_zeros && last_removed_digit == 5 && (VSAFE_MOD_u32(vr , 2)) == 0) { | ||
| 6689 | + last_removed_digit = 4; | ||
| 6690 | + } | ||
| 6691 | + out = vr; | ||
| 6692 | + if ((vr == vm && (!accept_bounds || !vm_is_trailing_zeros)) || last_removed_digit >= 5) { | ||
| 6693 | + out++; | ||
| 6694 | + } | ||
| 6695 | + } else { | ||
| 6696 | + for (;;) { | ||
| 6697 | + if (!(VSAFE_DIV_u32(vp , 10) > VSAFE_DIV_u32(vm , 10))) break; | ||
| 6698 | + last_removed_digit = ((u8)(VSAFE_MOD_u32(vr , 10))); | ||
| 6699 | + vr = VSAFE_DIV_u32(vr,10); | ||
| 6700 | + vp = VSAFE_DIV_u32(vp,10); | ||
| 6701 | + vm = VSAFE_DIV_u32(vm,10); | ||
| 6702 | + removed++; | ||
| 6703 | + } | ||
| 6704 | + out = vr + strconv__bool_to_u32(vr == vm || last_removed_digit >= 5); | ||
| 6705 | + } | ||
| 6706 | + return ((strconv__Dec32){.m = out,.e = e10 + removed,}); | ||
| 6707 | +} | ||
| 6708 | +string strconv__f32_to_str(f32 f, int n_digit) { | ||
| 6709 | + strconv__Uf32 _t1 = ((strconv__Uf32){0}); | ||
| 6710 | + strconv__Uf32 u1 = _t1; | ||
| 6711 | + u1.f = f; | ||
| 6712 | + u32 u = u1.u; | ||
| 6713 | + bool neg = (v__rshift_u32(u, (u64)(_const_strconv__mantbits32 + _const_strconv__expbits32))) != 0; | ||
| 6714 | + u32 mant = (u & ((v__lshift_u32(((u32)(1)), (u64)_const_strconv__mantbits32)) - ((u32)(1)))); | ||
| 6715 | + u32 exp = ((v__rshift_u32(u, (u64)_const_strconv__mantbits32)) & ((v__lshift_u32(((u32)(1)), (u64)_const_strconv__expbits32)) - ((u32)(1)))); | ||
| 6716 | + if (exp == 255 || (exp == 0 && mant == 0)) { | ||
| 6717 | + return strconv__get_string_special(neg, exp == 0, mant == 0); | ||
| 6718 | + } | ||
| 6719 | + multi_return_strconv__Dec32_bool mr_8600 = strconv__f32_to_decimal_exact_int(mant, exp); | ||
| 6720 | + strconv__Dec32 d = mr_8600.arg0; | ||
| 6721 | + bool ok = mr_8600.arg1; | ||
| 6722 | + if (!ok) { | ||
| 6723 | + d = strconv__f32_to_decimal(mant, exp); | ||
| 6724 | + } | ||
| 6725 | + return strconv__Dec32_get_string_32(d, neg, n_digit, 0); | ||
| 6726 | +} | ||
| 6727 | +string strconv__f32_to_str_pad(f32 f, int n_digit) { | ||
| 6728 | + strconv__Uf32 _t1 = ((strconv__Uf32){0}); | ||
| 6729 | + strconv__Uf32 u1 = _t1; | ||
| 6730 | + u1.f = f; | ||
| 6731 | + u32 u = u1.u; | ||
| 6732 | + bool neg = (v__rshift_u32(u, (u64)(_const_strconv__mantbits32 + _const_strconv__expbits32))) != 0; | ||
| 6733 | + u32 mant = (u & ((v__lshift_u32(((u32)(1)), (u64)_const_strconv__mantbits32)) - ((u32)(1)))); | ||
| 6734 | + u32 exp = ((v__rshift_u32(u, (u64)_const_strconv__mantbits32)) & ((v__lshift_u32(((u32)(1)), (u64)_const_strconv__expbits32)) - ((u32)(1)))); | ||
| 6735 | + if (exp == 255 || (exp == 0 && mant == 0)) { | ||
| 6736 | + return strconv__get_string_special(neg, exp == 0, mant == 0); | ||
| 6737 | + } | ||
| 6738 | + multi_return_strconv__Dec32_bool mr_9334 = strconv__f32_to_decimal_exact_int(mant, exp); | ||
| 6739 | + strconv__Dec32 d = mr_9334.arg0; | ||
| 6740 | + bool ok = mr_9334.arg1; | ||
| 6741 | + if (!ok) { | ||
| 6742 | + d = strconv__f32_to_decimal(mant, exp); | ||
| 6743 | + } | ||
| 6744 | + return strconv__Dec32_get_string_32(d, neg, n_digit, n_digit); | ||
| 6745 | +} | ||
| 6746 | +VV_LOC string strconv__Dec64_get_string_64(strconv__Dec64 d, bool neg, int i_n_digit, int i_pad_digit) { | ||
| 6747 | + int n_digit = (i_n_digit < 1 ? (1) : (i_n_digit + 1)); | ||
| 6748 | + int pad_digit = i_pad_digit + 1; | ||
| 6749 | + u64 out = d.m; | ||
| 6750 | + int d_exp = d.e; | ||
| 6751 | + int out_len = strconv__dec_digits(out); | ||
| 6752 | + int out_len_original = out_len; | ||
| 6753 | + int fw_zeros = 0; | ||
| 6754 | + if (pad_digit > out_len) { | ||
| 6755 | + fw_zeros = pad_digit - out_len; | ||
| 6756 | + } | ||
| 6757 | + Array_u8 buf = builtin____new_array_with_default((out_len + 6 + 1 + 1 + fw_zeros), 0, sizeof(u8), 0); | ||
| 6758 | + int i = 0; | ||
| 6759 | + if (neg) { | ||
| 6760 | + ((u8*)buf.data)[i] = '-'; | ||
| 6761 | + i++; | ||
| 6762 | + } | ||
| 6763 | + int disp = 0; | ||
| 6764 | + if (out_len <= 1) { | ||
| 6765 | + disp = 1; | ||
| 6766 | + } | ||
| 6767 | + if (n_digit < out_len) { | ||
| 6768 | + out += _const_strconv__ten_pow_table_64[out_len - n_digit - 1] * 5; | ||
| 6769 | + out = VSAFE_DIV_u64(out,_const_strconv__ten_pow_table_64[out_len - n_digit]); | ||
| 6770 | + u64 out_div = VSAFE_DIV_u64(d.m , _const_strconv__ten_pow_table_64[out_len - n_digit]); | ||
| 6771 | + if (out_div < out && strconv__dec_digits(out_div) < strconv__dec_digits(out)) { | ||
| 6772 | + d_exp++; | ||
| 6773 | + n_digit++; | ||
| 6774 | + } | ||
| 6775 | + out_len = n_digit; | ||
| 6776 | + } | ||
| 6777 | + int y = i + out_len; | ||
| 6778 | + int x = 0; | ||
| 6779 | + for (;;) { | ||
| 6780 | + if (!(x < (out_len - disp - 1))) break; | ||
| 6781 | + ((u8*)buf.data)[y - x] = (rune)('0' + ((u8)(VSAFE_MOD_u64(out , 10)))); | ||
| 6782 | + out = VSAFE_DIV_u64(out,10); | ||
| 6783 | + i++; | ||
| 6784 | + x++; | ||
| 6785 | + } | ||
| 6786 | + if (out_len > 1 || fw_zeros > 0) { | ||
| 6787 | + ((u8*)buf.data)[y - x] = '.'; | ||
| 6788 | + i++; | ||
| 6789 | + } | ||
| 6790 | + x++; | ||
| 6791 | + if (y - x >= 0) { | ||
| 6792 | + ((u8*)buf.data)[y - x] = (rune)('0' + ((u8)(VSAFE_MOD_u64(out , 10)))); | ||
| 6793 | + i++; | ||
| 6794 | + } | ||
| 6795 | + for (;;) { | ||
| 6796 | + if (!(fw_zeros > 0)) break; | ||
| 6797 | + ((u8*)buf.data)[i] = '0'; | ||
| 6798 | + i++; | ||
| 6799 | + fw_zeros--; | ||
| 6800 | + } | ||
| 6801 | + ((u8*)buf.data)[i] = 'e'; | ||
| 6802 | + i++; | ||
| 6803 | + int exp = d_exp + out_len_original - 1; | ||
| 6804 | + if (exp < 0) { | ||
| 6805 | + ((u8*)buf.data)[i] = '-'; | ||
| 6806 | + i++; | ||
| 6807 | + exp = -exp; | ||
| 6808 | + } else { | ||
| 6809 | + ((u8*)buf.data)[i] = '+'; | ||
| 6810 | + i++; | ||
| 6811 | + } | ||
| 6812 | + int d2 = VSAFE_MOD_int(exp , 10); | ||
| 6813 | + exp = VSAFE_DIV_int(exp,10); | ||
| 6814 | + int d1 = VSAFE_MOD_int(exp , 10); | ||
| 6815 | + int d0 = VSAFE_DIV_int(exp , 10); | ||
| 6816 | + if (d0 > 0) { | ||
| 6817 | + ((u8*)buf.data)[i] = (rune)('0' + ((u8)(d0))); | ||
| 6818 | + i++; | ||
| 6819 | + } | ||
| 6820 | + ((u8*)buf.data)[i] = (rune)('0' + ((u8)(d1))); | ||
| 6821 | + i++; | ||
| 6822 | + ((u8*)buf.data)[i] = (rune)('0' + ((u8)(d2))); | ||
| 6823 | + i++; | ||
| 6824 | + ((u8*)buf.data)[i] = 0; | ||
| 6825 | + return builtin__tos(builtin__memdup(&((u8*)buf.data)[0], i + 1), i); | ||
| 6826 | +} | ||
| 6827 | +VV_LOC multi_return_strconv__Dec64_bool strconv__f64_to_decimal_exact_int(u64 i_mant, u64 exp) { | ||
| 6828 | + strconv__Dec64 _t1 = ((strconv__Dec64){.m = 0,.e = 0,}); | ||
| 6829 | + strconv__Dec64 d = _t1; | ||
| 6830 | + u64 e = exp - 1023; | ||
| 6831 | + if (e > _const_strconv__mantbits64) { | ||
| 6832 | + return (multi_return_strconv__Dec64_bool){.arg0=d, .arg1=false}; | ||
| 6833 | + } | ||
| 6834 | + u64 shift = (u64)(_const_strconv__mantbits64 - e); | ||
| 6835 | + u64 mant = (i_mant | ((u64)(0x0010000000000000LL))); | ||
| 6836 | + d.m = v__rshift_u64(mant, (u64)shift); | ||
| 6837 | + if ((v__lshift_u64(d.m, (u64)shift)) != mant) { | ||
| 6838 | + return (multi_return_strconv__Dec64_bool){.arg0=d, .arg1=false}; | ||
| 6839 | + } | ||
| 6840 | + for (;;) { | ||
| 6841 | + if (!((VSAFE_MOD_u64(d.m , 10)) == 0)) break; | ||
| 6842 | + d.m = VSAFE_DIV_u64(d.m,10); | ||
| 6843 | + d.e++; | ||
| 6844 | + } | ||
| 6845 | + return (multi_return_strconv__Dec64_bool){.arg0=d, .arg1=true}; | ||
| 6846 | +} | ||
| 6847 | +VV_LOC strconv__Dec64 strconv__f64_to_decimal(u64 mant, u64 exp) { | ||
| 6848 | + int e2 = 0; | ||
| 6849 | + u64 m2 = ((u64)(0)); | ||
| 6850 | + if (exp == 0) { | ||
| 6851 | + e2 = -1022 - ((int)(_const_strconv__mantbits64)) - 2; | ||
| 6852 | + m2 = mant; | ||
| 6853 | + } else { | ||
| 6854 | + e2 = ((int)(exp)) - 1023 - ((int)(_const_strconv__mantbits64)) - 2; | ||
| 6855 | + m2 = ((v__lshift_u64(((u64)(1)), (u64)_const_strconv__mantbits64)) | mant); | ||
| 6856 | + } | ||
| 6857 | + bool even = ((m2 & 1)) == 0; | ||
| 6858 | + bool accept_bounds = even; | ||
| 6859 | + u64 mv = ((u64)(4 * m2)); | ||
| 6860 | + u64 mm_shift = strconv__bool_to_u64(mant != 0 || exp <= 1); | ||
| 6861 | + u64 vr = ((u64)(0)); | ||
| 6862 | + u64 vp = ((u64)(0)); | ||
| 6863 | + u64 vm = ((u64)(0)); | ||
| 6864 | + int e10 = 0; | ||
| 6865 | + bool vm_is_trailing_zeros = false; | ||
| 6866 | + bool vr_is_trailing_zeros = false; | ||
| 6867 | + if (e2 >= 0) { | ||
| 6868 | + u32 q = strconv__log10_pow2(e2) - strconv__bool_to_u32(e2 > 3); | ||
| 6869 | + e10 = ((int)(q)); | ||
| 6870 | + int k = 122 + strconv__pow5_bits(((int)(q))) - 1; | ||
| 6871 | + int i = -e2 + ((int)(q)) + k; | ||
| 6872 | + strconv__Uint128 mul = *(((strconv__Uint128*)(&_const_strconv__pow5_inv_split_64_x[builtin__v_fixed_index(q * 2, 584)]))); | ||
| 6873 | + vr = strconv__mul_shift_64(((u64)(4)) * m2, mul, i); | ||
| 6874 | + vp = strconv__mul_shift_64(((u64)(4)) * m2 + ((u64)(2)), mul, i); | ||
| 6875 | + vm = strconv__mul_shift_64(((u64)(4)) * m2 - ((u64)(1)) - mm_shift, mul, i); | ||
| 6876 | + if (q <= 21) { | ||
| 6877 | + if (VSAFE_MOD_u64(mv , 5) == 0) { | ||
| 6878 | + vr_is_trailing_zeros = strconv__multiple_of_power_of_five_64(mv, q); | ||
| 6879 | + } else if (accept_bounds) { | ||
| 6880 | + vm_is_trailing_zeros = strconv__multiple_of_power_of_five_64(mv - 1 - mm_shift, q); | ||
| 6881 | + } else if (strconv__multiple_of_power_of_five_64(mv + 2, q)) { | ||
| 6882 | + vp--; | ||
| 6883 | + } | ||
| 6884 | + } | ||
| 6885 | + } else { | ||
| 6886 | + u32 q = strconv__log10_pow5(-e2) - strconv__bool_to_u32(-e2 > 1); | ||
| 6887 | + e10 = ((int)(q)) + e2; | ||
| 6888 | + int i = -e2 - ((int)(q)); | ||
| 6889 | + int k = strconv__pow5_bits(i) - 121; | ||
| 6890 | + int j = ((int)(q)) - k; | ||
| 6891 | + strconv__Uint128 mul = *(((strconv__Uint128*)(&_const_strconv__pow5_split_64_x[builtin__v_fixed_index(i * 2, 652)]))); | ||
| 6892 | + vr = strconv__mul_shift_64(((u64)(4)) * m2, mul, j); | ||
| 6893 | + vp = strconv__mul_shift_64(((u64)(4)) * m2 + ((u64)(2)), mul, j); | ||
| 6894 | + vm = strconv__mul_shift_64(((u64)(4)) * m2 - ((u64)(1)) - mm_shift, mul, j); | ||
| 6895 | + if (q <= 1) { | ||
| 6896 | + vr_is_trailing_zeros = true; | ||
| 6897 | + if (accept_bounds) { | ||
| 6898 | + vm_is_trailing_zeros = (mm_shift == 1); | ||
| 6899 | + } else { | ||
| 6900 | + vp--; | ||
| 6901 | + } | ||
| 6902 | + } else if (q < 63) { | ||
| 6903 | + vr_is_trailing_zeros = strconv__multiple_of_power_of_two_64(mv, q - 1); | ||
| 6904 | + } | ||
| 6905 | + } | ||
| 6906 | + int removed = 0; | ||
| 6907 | + u8 last_removed_digit = ((u8)(0)); | ||
| 6908 | + u64 out = ((u64)(0)); | ||
| 6909 | + if (vm_is_trailing_zeros || vr_is_trailing_zeros) { | ||
| 6910 | + for (;;) { | ||
| 6911 | + u64 vp_div_10 = VSAFE_DIV_u64(vp , 10); | ||
| 6912 | + u64 vm_div_10 = VSAFE_DIV_u64(vm , 10); | ||
| 6913 | + if (vp_div_10 <= vm_div_10) { | ||
| 6914 | + break; | ||
| 6915 | + } | ||
| 6916 | + u64 vm_mod_10 = VSAFE_MOD_u64(vm , 10); | ||
| 6917 | + u64 vr_div_10 = VSAFE_DIV_u64(vr , 10); | ||
| 6918 | + u64 vr_mod_10 = VSAFE_MOD_u64(vr , 10); | ||
| 6919 | + vm_is_trailing_zeros = vm_is_trailing_zeros && vm_mod_10 == 0; | ||
| 6920 | + vr_is_trailing_zeros = vr_is_trailing_zeros && last_removed_digit == 0; | ||
| 6921 | + last_removed_digit = ((u8)(vr_mod_10)); | ||
| 6922 | + vr = vr_div_10; | ||
| 6923 | + vp = vp_div_10; | ||
| 6924 | + vm = vm_div_10; | ||
| 6925 | + removed++; | ||
| 6926 | + } | ||
| 6927 | + if (vm_is_trailing_zeros) { | ||
| 6928 | + for (;;) { | ||
| 6929 | + u64 vm_div_10 = VSAFE_DIV_u64(vm , 10); | ||
| 6930 | + u64 vm_mod_10 = VSAFE_MOD_u64(vm , 10); | ||
| 6931 | + if (vm_mod_10 != 0) { | ||
| 6932 | + break; | ||
| 6933 | + } | ||
| 6934 | + u64 vp_div_10 = VSAFE_DIV_u64(vp , 10); | ||
| 6935 | + u64 vr_div_10 = VSAFE_DIV_u64(vr , 10); | ||
| 6936 | + u64 vr_mod_10 = VSAFE_MOD_u64(vr , 10); | ||
| 6937 | + vr_is_trailing_zeros = vr_is_trailing_zeros && last_removed_digit == 0; | ||
| 6938 | + last_removed_digit = ((u8)(vr_mod_10)); | ||
| 6939 | + vr = vr_div_10; | ||
| 6940 | + vp = vp_div_10; | ||
| 6941 | + vm = vm_div_10; | ||
| 6942 | + removed++; | ||
| 6943 | + } | ||
| 6944 | + } | ||
| 6945 | + if (vr_is_trailing_zeros && last_removed_digit == 5 && (VSAFE_MOD_u64(vr , 2)) == 0) { | ||
| 6946 | + last_removed_digit = 4; | ||
| 6947 | + } | ||
| 6948 | + out = vr; | ||
| 6949 | + if ((vr == vm && (!accept_bounds || !vm_is_trailing_zeros)) || last_removed_digit >= 5) { | ||
| 6950 | + out++; | ||
| 6951 | + } | ||
| 6952 | + } else { | ||
| 6953 | + bool round_up = false; | ||
| 6954 | + for (;;) { | ||
| 6955 | + if (!(VSAFE_DIV_u64(vp , 100) > VSAFE_DIV_u64(vm , 100))) break; | ||
| 6956 | + round_up = (VSAFE_MOD_u64(vr , 100)) >= 50; | ||
| 6957 | + vr = VSAFE_DIV_u64(vr,100); | ||
| 6958 | + vp = VSAFE_DIV_u64(vp,100); | ||
| 6959 | + vm = VSAFE_DIV_u64(vm,100); | ||
| 6960 | + removed += 2; | ||
| 6961 | + } | ||
| 6962 | + for (;;) { | ||
| 6963 | + if (!(VSAFE_DIV_u64(vp , 10) > VSAFE_DIV_u64(vm , 10))) break; | ||
| 6964 | + round_up = (VSAFE_MOD_u64(vr , 10)) >= 5; | ||
| 6965 | + vr = VSAFE_DIV_u64(vr,10); | ||
| 6966 | + vp = VSAFE_DIV_u64(vp,10); | ||
| 6967 | + vm = VSAFE_DIV_u64(vm,10); | ||
| 6968 | + removed++; | ||
| 6969 | + } | ||
| 6970 | + out = vr + strconv__bool_to_u64(vr == vm || round_up); | ||
| 6971 | + } | ||
| 6972 | + return ((strconv__Dec64){.m = out,.e = e10 + removed,}); | ||
| 6973 | +} | ||
| 6974 | +string strconv__f64_to_str(f64 f, int n_digit) { | ||
| 6975 | + strconv__Uf64 _t1 = ((strconv__Uf64){0}); | ||
| 6976 | + strconv__Uf64 u1 = _t1; | ||
| 6977 | + u1.f = f; | ||
| 6978 | + u64 u = u1.u; | ||
| 6979 | + bool neg = (v__rshift_u64(u, (u64)(_const_strconv__mantbits64 + _const_strconv__expbits64))) != 0; | ||
| 6980 | + u64 mant = (u & ((v__lshift_u64(((u64)(1)), (u64)_const_strconv__mantbits64)) - ((u64)(1)))); | ||
| 6981 | + u64 exp = ((v__rshift_u64(u, (u64)_const_strconv__mantbits64)) & ((v__lshift_u64(((u64)(1)), (u64)_const_strconv__expbits64)) - ((u64)(1)))); | ||
| 6982 | + if (exp == 2047 || (exp == 0 && mant == 0)) { | ||
| 6983 | + return strconv__get_string_special(neg, exp == 0, mant == 0); | ||
| 6984 | + } | ||
| 6985 | + multi_return_strconv__Dec64_bool mr_9595 = strconv__f64_to_decimal_exact_int(mant, exp); | ||
| 6986 | + strconv__Dec64 d = mr_9595.arg0; | ||
| 6987 | + bool ok = mr_9595.arg1; | ||
| 6988 | + if (!ok) { | ||
| 6989 | + d = strconv__f64_to_decimal(mant, exp); | ||
| 6990 | + } | ||
| 6991 | + return strconv__Dec64_get_string_64(d, neg, n_digit, 0); | ||
| 6992 | +} | ||
| 6993 | +string strconv__f64_to_str_pad(f64 f, int n_digit) { | ||
| 6994 | + strconv__Uf64 _t1 = ((strconv__Uf64){0}); | ||
| 6995 | + strconv__Uf64 u1 = _t1; | ||
| 6996 | + u1.f = f; | ||
| 6997 | + u64 u = u1.u; | ||
| 6998 | + bool neg = (v__rshift_u64(u, (u64)(_const_strconv__mantbits64 + _const_strconv__expbits64))) != 0; | ||
| 6999 | + u64 mant = (u & ((v__lshift_u64(((u64)(1)), (u64)_const_strconv__mantbits64)) - ((u64)(1)))); | ||
| 7000 | + u64 exp = ((v__rshift_u64(u, (u64)_const_strconv__mantbits64)) & ((v__lshift_u64(((u64)(1)), (u64)_const_strconv__expbits64)) - ((u64)(1)))); | ||
| 7001 | + if (exp == 2047 || (exp == 0 && mant == 0)) { | ||
| 7002 | + return strconv__get_string_special(neg, exp == 0, mant == 0); | ||
| 7003 | + } | ||
| 7004 | + multi_return_strconv__Dec64_bool mr_10376 = strconv__f64_to_decimal_exact_int(mant, exp); | ||
| 7005 | + strconv__Dec64 d = mr_10376.arg0; | ||
| 7006 | + bool ok = mr_10376.arg1; | ||
| 7007 | + if (!ok) { | ||
| 7008 | + d = strconv__f64_to_decimal(mant, exp); | ||
| 7009 | + } | ||
| 7010 | + return strconv__Dec64_get_string_64(d, neg, n_digit, n_digit); | ||
| 7011 | +} | ||
| 7012 | +string strconv__format_str(string s, strconv__BF_param p) { | ||
| 7013 | + if (p.len0 <= 0) { | ||
| 7014 | + return builtin__string_clone(s); | ||
| 7015 | + } | ||
| 7016 | + int dif = p.len0 - builtin__utf8_str_visible_length(s); | ||
| 7017 | + if (dif <= 0) { | ||
| 7018 | + return builtin__string_clone(s); | ||
| 7019 | + } | ||
| 7020 | + strings__Builder res = strings__new_builder(s.len + dif); | ||
| 7021 | + if (p.align == strconv__Align_text__right) { | ||
| 7022 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 7023 | + strings__Builder_write_u8(&res, p.pad_ch); | ||
| 7024 | + } | ||
| 7025 | + } | ||
| 7026 | + strings__Builder_write_string(&res, s); | ||
| 7027 | + if (p.align == strconv__Align_text__left) { | ||
| 7028 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 7029 | + strings__Builder_write_u8(&res, p.pad_ch); | ||
| 7030 | + } | ||
| 7031 | + } | ||
| 7032 | + string _t3 = strings__Builder_str(&res); | ||
| 7033 | + { // defer begin | ||
| 7034 | + strings__Builder_free(&res); | ||
| 7035 | + } // defer end | ||
| 7036 | + return _t3; | ||
| 7037 | +} | ||
| 7038 | +void strconv__format_str_sb(string s, strconv__BF_param p, strings__Builder* sb) { | ||
| 7039 | + if (p.len0 <= 0) { | ||
| 7040 | + strings__Builder_write_string(sb, s); | ||
| 7041 | + return; | ||
| 7042 | + } | ||
| 7043 | + int dif = p.len0 - builtin__utf8_str_visible_length(s); | ||
| 7044 | + if (dif <= 0) { | ||
| 7045 | + strings__Builder_write_string(sb, s); | ||
| 7046 | + return; | ||
| 7047 | + } | ||
| 7048 | + if (p.align == strconv__Align_text__right) { | ||
| 7049 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 7050 | + strings__Builder_write_u8(sb, p.pad_ch); | ||
| 7051 | + } | ||
| 7052 | + } | ||
| 7053 | + strings__Builder_write_string(sb, s); | ||
| 7054 | + if (p.align == strconv__Align_text__left) { | ||
| 7055 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 7056 | + strings__Builder_write_u8(sb, p.pad_ch); | ||
| 7057 | + } | ||
| 7058 | + } | ||
| 7059 | +} | ||
| 7060 | +void strconv__format_dec_sb(u64 d, strconv__BF_param p, strings__Builder* res) { | ||
| 7061 | + int n_char = strconv__dec_digits(d); | ||
| 7062 | + int sign_len = (!p.positive || p.sign_flag ? (1) : (0)); | ||
| 7063 | + int number_len = sign_len + n_char; | ||
| 7064 | + int dif = p.len0 - number_len; | ||
| 7065 | + bool sign_written = false; | ||
| 7066 | + if (p.align == strconv__Align_text__right) { | ||
| 7067 | + if (p.pad_ch == '0') { | ||
| 7068 | + if (p.positive) { | ||
| 7069 | + if (p.sign_flag) { | ||
| 7070 | + strings__Builder_write_u8(res, '+'); | ||
| 7071 | + sign_written = true; | ||
| 7072 | + } | ||
| 7073 | + } else { | ||
| 7074 | + strings__Builder_write_u8(res, '-'); | ||
| 7075 | + sign_written = true; | ||
| 7076 | + } | ||
| 7077 | + } | ||
| 7078 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 7079 | + strings__Builder_write_u8(res, p.pad_ch); | ||
| 7080 | + } | ||
| 7081 | + } | ||
| 7082 | + if (!sign_written) { | ||
| 7083 | + if (p.positive) { | ||
| 7084 | + if (p.sign_flag) { | ||
| 7085 | + strings__Builder_write_u8(res, '+'); | ||
| 7086 | + } | ||
| 7087 | + } else { | ||
| 7088 | + strings__Builder_write_u8(res, '-'); | ||
| 7089 | + } | ||
| 7090 | + } | ||
| 7091 | + Array_fixed_u8_32 buf = {0}; | ||
| 7092 | + int i = 20; | ||
| 7093 | + u64 n = d; | ||
| 7094 | + u64 d_i = ((u64)(0)); | ||
| 7095 | + if (n > 0) { | ||
| 7096 | + for (;;) { | ||
| 7097 | + if (!(n > 0)) break; | ||
| 7098 | + u64 n1 = VSAFE_DIV_u64(n , 100); | ||
| 7099 | + d_i = v__lshift_u64((n - (n1 * 100)), (u64)1); | ||
| 7100 | + n = n1; | ||
| 7101 | + { // Unsafe block | ||
| 7102 | + buf[i] = _const_strconv__digit_pairs.str[d_i]; | ||
| 7103 | + } | ||
| 7104 | + i--; | ||
| 7105 | + d_i++; | ||
| 7106 | + { // Unsafe block | ||
| 7107 | + buf[i] = _const_strconv__digit_pairs.str[d_i]; | ||
| 7108 | + } | ||
| 7109 | + i--; | ||
| 7110 | + } | ||
| 7111 | + i++; | ||
| 7112 | + if (d_i < 20) { | ||
| 7113 | + i++; | ||
| 7114 | + } | ||
| 7115 | + strings__Builder_write_ptr(res, &buf[i], n_char); | ||
| 7116 | + } else { | ||
| 7117 | + strings__Builder_write_u8(res, '0'); | ||
| 7118 | + } | ||
| 7119 | + if (p.align == strconv__Align_text__left) { | ||
| 7120 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 7121 | + strings__Builder_write_u8(res, p.pad_ch); | ||
| 7122 | + } | ||
| 7123 | + } | ||
| 7124 | + return; | ||
| 7125 | +} | ||
| 7126 | +string strconv__f64_to_str_lnd1(f64 f, int dec_digit) { | ||
| 7127 | + { // Unsafe block | ||
| 7128 | + int clamped_dec = (dec_digit >= 36 ? (36 - 1) : (dec_digit)); | ||
| 7129 | + string s = strconv__f64_to_str(f + _const_strconv__dec_round[clamped_dec], 18); | ||
| 7130 | + if (s.len > 2 && (s.str[ 0] == 'n' || s.str[ 1] == 'i')) { | ||
| 7131 | + return s; | ||
| 7132 | + } | ||
| 7133 | + bool m_sgn_flag = false; | ||
| 7134 | + int sgn = 1; | ||
| 7135 | + Array_fixed_u8_26 b = {0}; | ||
| 7136 | + int d_pos = 1; | ||
| 7137 | + int i = 0; | ||
| 7138 | + int i1 = 0; | ||
| 7139 | + int exp = 0; | ||
| 7140 | + int exp_sgn = 1; | ||
| 7141 | + int dot_res_sp = -1; | ||
| 7142 | + for (int _t2 = 0; _t2 < s.len; ++_t2) { | ||
| 7143 | + u8 c = s.str[_t2]; | ||
| 7144 | + | ||
| 7145 | + if (c == ('-')) { | ||
| 7146 | + sgn = -1; | ||
| 7147 | + i++; | ||
| 7148 | + } | ||
| 7149 | + else if (c == ('+')) { | ||
| 7150 | + sgn = 1; | ||
| 7151 | + i++; | ||
| 7152 | + } | ||
| 7153 | + else if ((c >= '0' && c <= '9')) { | ||
| 7154 | + b[i1] = c; | ||
| 7155 | + i1++; | ||
| 7156 | + i++; | ||
| 7157 | + } | ||
| 7158 | + else if (c == ('.')) { | ||
| 7159 | + if (sgn > 0) { | ||
| 7160 | + d_pos = i; | ||
| 7161 | + } else { | ||
| 7162 | + d_pos = i - 1; | ||
| 7163 | + } | ||
| 7164 | + i++; | ||
| 7165 | + } | ||
| 7166 | + else if (c == ('e')) { | ||
| 7167 | + i++; | ||
| 7168 | + break; | ||
| 7169 | + } | ||
| 7170 | + else { | ||
| 7171 | + builtin__string_free(&s); | ||
| 7172 | + return _S("[Float conversion error!!]"); | ||
| 7173 | + } | ||
| 7174 | + } | ||
| 7175 | + b[i1] = 0; | ||
| 7176 | + if (s.str[ i] == '-') { | ||
| 7177 | + exp_sgn = -1; | ||
| 7178 | + i++; | ||
| 7179 | + } else if (s.str[ i] == '+') { | ||
| 7180 | + exp_sgn = 1; | ||
| 7181 | + i++; | ||
| 7182 | + } | ||
| 7183 | + int c = i; | ||
| 7184 | + for (;;) { | ||
| 7185 | + if (!(c < s.len)) break; | ||
| 7186 | + exp = exp * 10 + ((int)((rune)(s.str[ c] - '0'))); | ||
| 7187 | + c++; | ||
| 7188 | + } | ||
| 7189 | + int extra_frac_digits = (dec_digit > 0 ? (dec_digit) : (0)); | ||
| 7190 | + int sign_len = (sgn < 0 ? (1) : (0)); | ||
| 7191 | + Array_u8 res = builtin____new_array_with_default(sign_len + i1 + exp + extra_frac_digits + 4, 0, sizeof(u8), &(u8[]){0}); | ||
| 7192 | + int r_i = 0; | ||
| 7193 | + builtin__string_free(&s); | ||
| 7194 | + if (sgn == 1) { | ||
| 7195 | + if (m_sgn_flag) { | ||
| 7196 | + ((u8*)res.data)[r_i] = '+'; | ||
| 7197 | + r_i++; | ||
| 7198 | + } | ||
| 7199 | + } else { | ||
| 7200 | + ((u8*)res.data)[r_i] = '-'; | ||
| 7201 | + r_i++; | ||
| 7202 | + } | ||
| 7203 | + i = 0; | ||
| 7204 | + if (exp_sgn >= 0) { | ||
| 7205 | + for (;;) { | ||
| 7206 | + if (!(b[i] != 0)) break; | ||
| 7207 | + ((u8*)res.data)[r_i] = b[i]; | ||
| 7208 | + r_i++; | ||
| 7209 | + i++; | ||
| 7210 | + if (i >= d_pos && exp >= 0) { | ||
| 7211 | + if (exp == 0) { | ||
| 7212 | + dot_res_sp = r_i; | ||
| 7213 | + ((u8*)res.data)[r_i] = '.'; | ||
| 7214 | + r_i++; | ||
| 7215 | + } | ||
| 7216 | + exp--; | ||
| 7217 | + } | ||
| 7218 | + } | ||
| 7219 | + for (;;) { | ||
| 7220 | + if (!(exp >= 0)) break; | ||
| 7221 | + ((u8*)res.data)[r_i] = '0'; | ||
| 7222 | + r_i++; | ||
| 7223 | + exp--; | ||
| 7224 | + } | ||
| 7225 | + } else { | ||
| 7226 | + bool dot_p = true; | ||
| 7227 | + for (;;) { | ||
| 7228 | + if (!(exp > 0)) break; | ||
| 7229 | + ((u8*)res.data)[r_i] = '0'; | ||
| 7230 | + r_i++; | ||
| 7231 | + exp--; | ||
| 7232 | + if (dot_p) { | ||
| 7233 | + dot_res_sp = r_i; | ||
| 7234 | + ((u8*)res.data)[r_i] = '.'; | ||
| 7235 | + r_i++; | ||
| 7236 | + dot_p = false; | ||
| 7237 | + } | ||
| 7238 | + } | ||
| 7239 | + for (;;) { | ||
| 7240 | + if (!(b[i] != 0)) break; | ||
| 7241 | + ((u8*)res.data)[r_i] = b[i]; | ||
| 7242 | + r_i++; | ||
| 7243 | + i++; | ||
| 7244 | + } | ||
| 7245 | + } | ||
| 7246 | + if (dec_digit <= 0) { | ||
| 7247 | + if (dot_res_sp < 0) { | ||
| 7248 | + dot_res_sp = i + 1; | ||
| 7249 | + } | ||
| 7250 | + string tmp_res = builtin__string_clone(builtin__tos(res.data, dot_res_sp)); | ||
| 7251 | + builtin__array_free(&res); | ||
| 7252 | + return tmp_res; | ||
| 7253 | + } | ||
| 7254 | + if (dot_res_sp >= 0) { | ||
| 7255 | + r_i = dot_res_sp + dec_digit + 1; | ||
| 7256 | + ((u8*)res.data)[r_i] = 0; | ||
| 7257 | + for (int c1 = 1; c1 < dec_digit + 1; ++c1) { | ||
| 7258 | + if (((u8*)res.data)[(int)(r_i - c1)] == 0) { | ||
| 7259 | + ((u8*)res.data)[(int)(r_i - c1)] = '0'; | ||
| 7260 | + } | ||
| 7261 | + } | ||
| 7262 | + string tmp_res = builtin__string_clone(builtin__tos(res.data, r_i)); | ||
| 7263 | + builtin__array_free(&res); | ||
| 7264 | + return tmp_res; | ||
| 7265 | + } else { | ||
| 7266 | + if (dec_digit > 0) { | ||
| 7267 | + int c1 = 0; | ||
| 7268 | + ((u8*)res.data)[r_i] = '.'; | ||
| 7269 | + r_i++; | ||
| 7270 | + for (;;) { | ||
| 7271 | + if (!(c1 < dec_digit)) break; | ||
| 7272 | + ((u8*)res.data)[r_i] = '0'; | ||
| 7273 | + r_i++; | ||
| 7274 | + c1++; | ||
| 7275 | + } | ||
| 7276 | + ((u8*)res.data)[r_i] = 0; | ||
| 7277 | + } | ||
| 7278 | + string tmp_res = builtin__string_clone(builtin__tos(res.data, r_i)); | ||
| 7279 | + builtin__array_free(&res); | ||
| 7280 | + return tmp_res; | ||
| 7281 | + } | ||
| 7282 | + } | ||
| 7283 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 7284 | +} | ||
| 7285 | +string strconv__format_fl(f64 f, strconv__BF_param p) { | ||
| 7286 | + { // Unsafe block | ||
| 7287 | + string fs = strconv__f64_to_str_lnd1((f >= ((f64)(0.0)) ? (f) : (-f)), p.len1); | ||
| 7288 | + if (fs.str[ 0] == '[') { | ||
| 7289 | + return fs; | ||
| 7290 | + } | ||
| 7291 | + if (p.rm_tail_zero) { | ||
| 7292 | + string tmp = fs; | ||
| 7293 | + fs = strconv__remove_tail_zeros(fs); | ||
| 7294 | + builtin__string_free(&tmp); | ||
| 7295 | + } | ||
| 7296 | + Array_fixed_u8_512 buf = {0}; | ||
| 7297 | + Array_fixed_u8_512 out = {0}; | ||
| 7298 | + int buf_i = 0; | ||
| 7299 | + int out_i = 0; | ||
| 7300 | + int sign_len_diff = 0; | ||
| 7301 | + if (p.pad_ch == '0') { | ||
| 7302 | + if (p.positive) { | ||
| 7303 | + if (p.sign_flag) { | ||
| 7304 | + out[out_i] = '+'; | ||
| 7305 | + out_i++; | ||
| 7306 | + sign_len_diff = -1; | ||
| 7307 | + } | ||
| 7308 | + } else { | ||
| 7309 | + out[out_i] = '-'; | ||
| 7310 | + out_i++; | ||
| 7311 | + sign_len_diff = -1; | ||
| 7312 | + } | ||
| 7313 | + } else { | ||
| 7314 | + if (p.positive) { | ||
| 7315 | + if (p.sign_flag) { | ||
| 7316 | + buf[buf_i] = '+'; | ||
| 7317 | + buf_i++; | ||
| 7318 | + } | ||
| 7319 | + } else { | ||
| 7320 | + buf[buf_i] = '-'; | ||
| 7321 | + buf_i++; | ||
| 7322 | + } | ||
| 7323 | + } | ||
| 7324 | + builtin__vmemcpy(&buf[buf_i], fs.str, fs.len); | ||
| 7325 | + buf_i += fs.len; | ||
| 7326 | + int dif = p.len0 - buf_i + sign_len_diff; | ||
| 7327 | + if (p.align == strconv__Align_text__right) { | ||
| 7328 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 7329 | + out[out_i] = p.pad_ch; | ||
| 7330 | + out_i++; | ||
| 7331 | + } | ||
| 7332 | + } | ||
| 7333 | + builtin__vmemcpy(&out[out_i], &buf[0], buf_i); | ||
| 7334 | + out_i += buf_i; | ||
| 7335 | + if (p.align == strconv__Align_text__left) { | ||
| 7336 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 7337 | + out[out_i] = p.pad_ch; | ||
| 7338 | + out_i++; | ||
| 7339 | + } | ||
| 7340 | + } | ||
| 7341 | + out[out_i] = 0; | ||
| 7342 | + string tmp = fs; | ||
| 7343 | + fs = builtin__tos_clone(&out[0]); | ||
| 7344 | + builtin__string_free(&tmp); | ||
| 7345 | + return fs; | ||
| 7346 | + } | ||
| 7347 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 7348 | +} | ||
| 7349 | +string strconv__format_es(f64 f, strconv__BF_param p) { | ||
| 7350 | + { // Unsafe block | ||
| 7351 | + string fs = strconv__f64_to_str_pad((f > 0 ? (f) : (-f)), p.len1); | ||
| 7352 | + if (p.rm_tail_zero) { | ||
| 7353 | + string tmp = fs; | ||
| 7354 | + fs = strconv__remove_tail_zeros(fs); | ||
| 7355 | + builtin__string_free(&tmp); | ||
| 7356 | + } | ||
| 7357 | + Array_fixed_u8_512 buf = {0}; | ||
| 7358 | + Array_fixed_u8_512 out = {0}; | ||
| 7359 | + int buf_i = 0; | ||
| 7360 | + int out_i = 0; | ||
| 7361 | + int sign_len_diff = 0; | ||
| 7362 | + if (p.pad_ch == '0') { | ||
| 7363 | + if (p.positive) { | ||
| 7364 | + if (p.sign_flag) { | ||
| 7365 | + out[out_i] = '+'; | ||
| 7366 | + out_i++; | ||
| 7367 | + sign_len_diff = -1; | ||
| 7368 | + } | ||
| 7369 | + } else { | ||
| 7370 | + out[out_i] = '-'; | ||
| 7371 | + out_i++; | ||
| 7372 | + sign_len_diff = -1; | ||
| 7373 | + } | ||
| 7374 | + } else { | ||
| 7375 | + if (p.positive) { | ||
| 7376 | + if (p.sign_flag) { | ||
| 7377 | + buf[buf_i] = '+'; | ||
| 7378 | + buf_i++; | ||
| 7379 | + } | ||
| 7380 | + } else { | ||
| 7381 | + buf[buf_i] = '-'; | ||
| 7382 | + buf_i++; | ||
| 7383 | + } | ||
| 7384 | + } | ||
| 7385 | + builtin__vmemcpy(&buf[buf_i], fs.str, fs.len); | ||
| 7386 | + buf_i += fs.len; | ||
| 7387 | + int dif = p.len0 - buf_i + sign_len_diff; | ||
| 7388 | + if (p.align == strconv__Align_text__right) { | ||
| 7389 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 7390 | + out[out_i] = p.pad_ch; | ||
| 7391 | + out_i++; | ||
| 7392 | + } | ||
| 7393 | + } | ||
| 7394 | + builtin__vmemcpy(&out[out_i], &buf[0], buf_i); | ||
| 7395 | + out_i += buf_i; | ||
| 7396 | + if (p.align == strconv__Align_text__left) { | ||
| 7397 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 7398 | + out[out_i] = p.pad_ch; | ||
| 7399 | + out_i++; | ||
| 7400 | + } | ||
| 7401 | + } | ||
| 7402 | + out[out_i] = 0; | ||
| 7403 | + string tmp = fs; | ||
| 7404 | + fs = builtin__tos_clone(&out[0]); | ||
| 7405 | + builtin__string_free(&tmp); | ||
| 7406 | + return fs; | ||
| 7407 | + } | ||
| 7408 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 7409 | +} | ||
| 7410 | +string strconv__remove_tail_zeros(string s) { | ||
| 7411 | + { // Unsafe block | ||
| 7412 | + u8* buf = builtin__malloc_noscan(s.len + 1); | ||
| 7413 | + int i_d = 0; | ||
| 7414 | + int i_s = 0; | ||
| 7415 | + for (;;) { | ||
| 7416 | + if (!(i_s < s.len && !(s.str[ i_s] == '-' || s.str[ i_s] == '+') && (s.str[ i_s] > '9' || s.str[ i_s] < '0'))) break; | ||
| 7417 | + buf[i_d] = s.str[ i_s]; | ||
| 7418 | + i_s++; | ||
| 7419 | + i_d++; | ||
| 7420 | + } | ||
| 7421 | + if (i_s < s.len && (s.str[ i_s] == '-' || s.str[ i_s] == '+')) { | ||
| 7422 | + buf[i_d] = s.str[ i_s]; | ||
| 7423 | + i_s++; | ||
| 7424 | + i_d++; | ||
| 7425 | + } | ||
| 7426 | + for (;;) { | ||
| 7427 | + if (!(i_s < s.len && s.str[ i_s] >= '0' && s.str[ i_s] <= '9')) break; | ||
| 7428 | + buf[i_d] = s.str[ i_s]; | ||
| 7429 | + i_s++; | ||
| 7430 | + i_d++; | ||
| 7431 | + } | ||
| 7432 | + if (i_s < s.len && s.str[ i_s] == '.') { | ||
| 7433 | + int i_s1 = i_s + 1; | ||
| 7434 | + int sum = 0; | ||
| 7435 | + int i_s2 = i_s1; | ||
| 7436 | + for (;;) { | ||
| 7437 | + if (!(i_s1 < s.len && s.str[ i_s1] >= '0' && s.str[ i_s1] <= '9')) break; | ||
| 7438 | + sum += (s.str[ i_s1] - ((u8)('0'))); | ||
| 7439 | + if (s.str[ i_s1] != '0') { | ||
| 7440 | + i_s2 = i_s1; | ||
| 7441 | + } | ||
| 7442 | + i_s1++; | ||
| 7443 | + } | ||
| 7444 | + if (sum > 0) { | ||
| 7445 | + for (int c_i = i_s; c_i < i_s2 + 1; ++c_i) { | ||
| 7446 | + buf[i_d] = s.str[ c_i]; | ||
| 7447 | + i_d++; | ||
| 7448 | + } | ||
| 7449 | + } | ||
| 7450 | + i_s = i_s1; | ||
| 7451 | + } | ||
| 7452 | + if (i_s < s.len && s.str[ i_s] != '.') { | ||
| 7453 | + for (;;) { | ||
| 7454 | + buf[i_d] = s.str[ i_s]; | ||
| 7455 | + i_s++; | ||
| 7456 | + i_d++; | ||
| 7457 | + if (i_s >= s.len) { | ||
| 7458 | + break; | ||
| 7459 | + } | ||
| 7460 | + } | ||
| 7461 | + } | ||
| 7462 | + buf[i_d] = 0; | ||
| 7463 | + return builtin__tos(buf, i_d); | ||
| 7464 | + } | ||
| 7465 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 7466 | +} | ||
| 7467 | +inline string strconv__ftoa_64(f64 f) { | ||
| 7468 | + return strconv__f64_to_str(f, 17); | ||
| 7469 | +} | ||
| 7470 | +inline string strconv__ftoa_long_64(f64 f) { | ||
| 7471 | + return strconv__f64_to_str_l(f); | ||
| 7472 | +} | ||
| 7473 | +inline string strconv__ftoa_32(f32 f) { | ||
| 7474 | + return strconv__f32_to_str(f, 8); | ||
| 7475 | +} | ||
| 7476 | +inline string strconv__ftoa_long_32(f32 f) { | ||
| 7477 | + return strconv__f32_to_str_l(f); | ||
| 7478 | +} | ||
| 7479 | +string strconv__format_int(i64 n, int radix) { | ||
| 7480 | + { // Unsafe block | ||
| 7481 | + if (radix < 2 || radix > 36) { | ||
| 7482 | + builtin__panic_n(_S("invalid radix, it should be => 2 and <= 36, actual:"), radix); | ||
| 7483 | + VUNREACHABLE(); | ||
| 7484 | + } | ||
| 7485 | + if (n == 0) { | ||
| 7486 | + return _S("0"); | ||
| 7487 | + } | ||
| 7488 | + i64 n_copy = n; | ||
| 7489 | + bool have_minus = false; | ||
| 7490 | + if (n < 0) { | ||
| 7491 | + have_minus = true; | ||
| 7492 | + n_copy = -n_copy; | ||
| 7493 | + } | ||
| 7494 | + string res = _S(""); | ||
| 7495 | + for (;;) { | ||
| 7496 | + if (!(n_copy != 0)) break; | ||
| 7497 | + string tmp_0 = res; | ||
| 7498 | + int bdx = ((int)((i64)(VSAFE_MOD_i64(n_copy , radix)))); | ||
| 7499 | + string tmp_1 = builtin__u8_ascii_str(_const_strconv__base_digits.str[ bdx]); | ||
| 7500 | + res = builtin__string__plus(tmp_1, res); | ||
| 7501 | + builtin__string_free(&tmp_0); | ||
| 7502 | + builtin__string_free(&tmp_1); | ||
| 7503 | + n_copy = VSAFE_DIV_i64(n_copy,radix); | ||
| 7504 | + } | ||
| 7505 | + if (have_minus) { | ||
| 7506 | + string final_res = builtin__string__plus(_S("-"), res); | ||
| 7507 | + builtin__string_free(&res); | ||
| 7508 | + return final_res; | ||
| 7509 | + } | ||
| 7510 | + return res; | ||
| 7511 | + } | ||
| 7512 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 7513 | +} | ||
| 7514 | +string strconv__format_uint(u64 n, int radix) { | ||
| 7515 | + { // Unsafe block | ||
| 7516 | + if (radix < 2 || radix > 36) { | ||
| 7517 | + builtin__panic_n(_S("invalid radix, it should be => 2 and <= 36, actual:"), radix); | ||
| 7518 | + VUNREACHABLE(); | ||
| 7519 | + } | ||
| 7520 | + if (n == 0) { | ||
| 7521 | + return _S("0"); | ||
| 7522 | + } | ||
| 7523 | + u64 n_copy = n; | ||
| 7524 | + string res = _S(""); | ||
| 7525 | + u64 uradix = ((u64)(radix)); | ||
| 7526 | + for (;;) { | ||
| 7527 | + if (!(n_copy != 0)) break; | ||
| 7528 | + string tmp_0 = res; | ||
| 7529 | + string tmp_1 = builtin__u8_ascii_str(_const_strconv__base_digits.str[ ((int)(VSAFE_MOD_u64(n_copy , uradix)))]); | ||
| 7530 | + res = builtin__string__plus(tmp_1, res); | ||
| 7531 | + builtin__string_free(&tmp_0); | ||
| 7532 | + builtin__string_free(&tmp_1); | ||
| 7533 | + n_copy = VSAFE_DIV_u64(n_copy,uradix); | ||
| 7534 | + } | ||
| 7535 | + return res; | ||
| 7536 | + } | ||
| 7537 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 7538 | +} | ||
| 7539 | +string strconv__f32_to_str_l(f32 f) { | ||
| 7540 | + string s = strconv__f32_to_str(f, 8); | ||
| 7541 | + string res = strconv__fxx_to_str_l_parse(s); | ||
| 7542 | + builtin__string_free(&s); | ||
| 7543 | + return res; | ||
| 7544 | +} | ||
| 7545 | +string strconv__f32_to_str_l_with_dot(f32 f) { | ||
| 7546 | + string s = strconv__f32_to_str(f, 8); | ||
| 7547 | + string res = strconv__fxx_to_str_l_parse_with_dot(s); | ||
| 7548 | + builtin__string_free(&s); | ||
| 7549 | + return res; | ||
| 7550 | +} | ||
| 7551 | +string strconv__f64_to_str_l(f64 f) { | ||
| 7552 | + string s = strconv__f64_to_str(f, 18); | ||
| 7553 | + string res = strconv__fxx_to_str_l_parse(s); | ||
| 7554 | + builtin__string_free(&s); | ||
| 7555 | + return res; | ||
| 7556 | +} | ||
| 7557 | +string strconv__f64_to_str_l_with_dot(f64 f) { | ||
| 7558 | + string s = strconv__f64_to_str(f, 18); | ||
| 7559 | + string res = strconv__fxx_to_str_l_parse_with_dot(s); | ||
| 7560 | + builtin__string_free(&s); | ||
| 7561 | + return res; | ||
| 7562 | +} | ||
| 7563 | +string strconv__fxx_to_str_l_parse(string s) { | ||
| 7564 | + if (s.len > 2 && (s.str[ 0] == 'n' || s.str[ 1] == 'i')) { | ||
| 7565 | + return builtin__string_clone(s); | ||
| 7566 | + } | ||
| 7567 | + bool m_sgn_flag = false; | ||
| 7568 | + int sgn = 1; | ||
| 7569 | + Array_fixed_u8_26 b = {0}; | ||
| 7570 | + int d_pos = 1; | ||
| 7571 | + int i = 0; | ||
| 7572 | + int i1 = 0; | ||
| 7573 | + int exp = 0; | ||
| 7574 | + int exp_sgn = 1; | ||
| 7575 | + for (int _t2 = 0; _t2 < s.len; ++_t2) { | ||
| 7576 | + u8 c = s.str[_t2]; | ||
| 7577 | + if (c == '-') { | ||
| 7578 | + sgn = -1; | ||
| 7579 | + i++; | ||
| 7580 | + } else if (c == '+') { | ||
| 7581 | + sgn = 1; | ||
| 7582 | + i++; | ||
| 7583 | + } else if (c >= '0' && c <= '9') { | ||
| 7584 | + b[i1] = c; | ||
| 7585 | + i1++; | ||
| 7586 | + i++; | ||
| 7587 | + } else if (c == '.') { | ||
| 7588 | + if (sgn > 0) { | ||
| 7589 | + d_pos = i; | ||
| 7590 | + } else { | ||
| 7591 | + d_pos = i - 1; | ||
| 7592 | + } | ||
| 7593 | + i++; | ||
| 7594 | + } else if (c == 'e') { | ||
| 7595 | + i++; | ||
| 7596 | + break; | ||
| 7597 | + } else { | ||
| 7598 | + return _S("Float conversion error!!"); | ||
| 7599 | + } | ||
| 7600 | + } | ||
| 7601 | + b[i1] = 0; | ||
| 7602 | + if (s.str[ i] == '-') { | ||
| 7603 | + exp_sgn = -1; | ||
| 7604 | + i++; | ||
| 7605 | + } else if (s.str[ i] == '+') { | ||
| 7606 | + exp_sgn = 1; | ||
| 7607 | + i++; | ||
| 7608 | + } | ||
| 7609 | + int c = i; | ||
| 7610 | + for (;;) { | ||
| 7611 | + if (!(c < s.len)) break; | ||
| 7612 | + exp = exp * 10 + ((int)((rune)(s.str[ c] - '0'))); | ||
| 7613 | + c++; | ||
| 7614 | + } | ||
| 7615 | + Array_u8 res = builtin____new_array_with_default(exp + 32, 0, sizeof(u8), &(u8[]){0}); | ||
| 7616 | + int r_i = 0; | ||
| 7617 | + if (sgn == 1) { | ||
| 7618 | + if (m_sgn_flag) { | ||
| 7619 | + ((u8*)res.data)[r_i] = '+'; | ||
| 7620 | + r_i++; | ||
| 7621 | + } | ||
| 7622 | + } else { | ||
| 7623 | + ((u8*)res.data)[r_i] = '-'; | ||
| 7624 | + r_i++; | ||
| 7625 | + } | ||
| 7626 | + i = 0; | ||
| 7627 | + if (exp_sgn >= 0) { | ||
| 7628 | + for (;;) { | ||
| 7629 | + if (!(b[i] != 0)) break; | ||
| 7630 | + ((u8*)res.data)[r_i] = b[i]; | ||
| 7631 | + r_i++; | ||
| 7632 | + i++; | ||
| 7633 | + if (i >= d_pos && exp >= 0) { | ||
| 7634 | + if (exp == 0) { | ||
| 7635 | + ((u8*)res.data)[r_i] = '.'; | ||
| 7636 | + r_i++; | ||
| 7637 | + } | ||
| 7638 | + exp--; | ||
| 7639 | + } | ||
| 7640 | + } | ||
| 7641 | + for (;;) { | ||
| 7642 | + if (!(exp >= 0)) break; | ||
| 7643 | + ((u8*)res.data)[r_i] = '0'; | ||
| 7644 | + r_i++; | ||
| 7645 | + exp--; | ||
| 7646 | + } | ||
| 7647 | + } else { | ||
| 7648 | + bool dot_p = true; | ||
| 7649 | + for (;;) { | ||
| 7650 | + if (!(exp > 0)) break; | ||
| 7651 | + ((u8*)res.data)[r_i] = '0'; | ||
| 7652 | + r_i++; | ||
| 7653 | + exp--; | ||
| 7654 | + if (dot_p) { | ||
| 7655 | + ((u8*)res.data)[r_i] = '.'; | ||
| 7656 | + r_i++; | ||
| 7657 | + dot_p = false; | ||
| 7658 | + } | ||
| 7659 | + } | ||
| 7660 | + for (;;) { | ||
| 7661 | + if (!(b[i] != 0)) break; | ||
| 7662 | + ((u8*)res.data)[r_i] = b[i]; | ||
| 7663 | + r_i++; | ||
| 7664 | + i++; | ||
| 7665 | + } | ||
| 7666 | + } | ||
| 7667 | + if (r_i > 1 && ((u8*)res.data)[r_i - 1] == '.') { | ||
| 7668 | + ((u8*)res.data)[r_i] = '0'; | ||
| 7669 | + r_i++; | ||
| 7670 | + } else if (!(Array_u8_contains(res, '.'))) { | ||
| 7671 | + ((u8*)res.data)[r_i] = '.'; | ||
| 7672 | + r_i++; | ||
| 7673 | + ((u8*)res.data)[r_i] = '0'; | ||
| 7674 | + r_i++; | ||
| 7675 | + } | ||
| 7676 | + ((u8*)res.data)[r_i] = 0; | ||
| 7677 | + string tmp_res = builtin__string_clone(builtin__tos(res.data, r_i)); | ||
| 7678 | + builtin__array_free(&res); | ||
| 7679 | + return tmp_res; | ||
| 7680 | +} | ||
| 7681 | +string strconv__fxx_to_str_l_parse_with_dot(string s) { | ||
| 7682 | + if (s.len > 2 && (s.str[ 0] == 'n' || s.str[ 1] == 'i')) { | ||
| 7683 | + return builtin__string_clone(s); | ||
| 7684 | + } | ||
| 7685 | + bool m_sgn_flag = false; | ||
| 7686 | + int sgn = 1; | ||
| 7687 | + Array_fixed_u8_26 b = {0}; | ||
| 7688 | + int d_pos = 1; | ||
| 7689 | + int i = 0; | ||
| 7690 | + int i1 = 0; | ||
| 7691 | + int exp = 0; | ||
| 7692 | + int exp_sgn = 1; | ||
| 7693 | + for (int _t2 = 0; _t2 < s.len; ++_t2) { | ||
| 7694 | + u8 c = s.str[_t2]; | ||
| 7695 | + if (c == '-') { | ||
| 7696 | + sgn = -1; | ||
| 7697 | + i++; | ||
| 7698 | + } else if (c == '+') { | ||
| 7699 | + sgn = 1; | ||
| 7700 | + i++; | ||
| 7701 | + } else if (c >= '0' && c <= '9') { | ||
| 7702 | + b[i1] = c; | ||
| 7703 | + i1++; | ||
| 7704 | + i++; | ||
| 7705 | + } else if (c == '.') { | ||
| 7706 | + if (sgn > 0) { | ||
| 7707 | + d_pos = i; | ||
| 7708 | + } else { | ||
| 7709 | + d_pos = i - 1; | ||
| 7710 | + } | ||
| 7711 | + i++; | ||
| 7712 | + } else if (c == 'e') { | ||
| 7713 | + i++; | ||
| 7714 | + break; | ||
| 7715 | + } else { | ||
| 7716 | + return _S("Float conversion error!!"); | ||
| 7717 | + } | ||
| 7718 | + } | ||
| 7719 | + b[i1] = 0; | ||
| 7720 | + if (s.str[ i] == '-') { | ||
| 7721 | + exp_sgn = -1; | ||
| 7722 | + i++; | ||
| 7723 | + } else if (s.str[ i] == '+') { | ||
| 7724 | + exp_sgn = 1; | ||
| 7725 | + i++; | ||
| 7726 | + } | ||
| 7727 | + int c = i; | ||
| 7728 | + for (;;) { | ||
| 7729 | + if (!(c < s.len)) break; | ||
| 7730 | + exp = exp * 10 + ((int)((rune)(s.str[ c] - '0'))); | ||
| 7731 | + c++; | ||
| 7732 | + } | ||
| 7733 | + Array_u8 res = builtin____new_array_with_default(exp + 32, 0, sizeof(u8), &(u8[]){0}); | ||
| 7734 | + int r_i = 0; | ||
| 7735 | + if (sgn == 1) { | ||
| 7736 | + if (m_sgn_flag) { | ||
| 7737 | + ((u8*)res.data)[r_i] = '+'; | ||
| 7738 | + r_i++; | ||
| 7739 | + } | ||
| 7740 | + } else { | ||
| 7741 | + ((u8*)res.data)[r_i] = '-'; | ||
| 7742 | + r_i++; | ||
| 7743 | + } | ||
| 7744 | + i = 0; | ||
| 7745 | + if (exp_sgn >= 0) { | ||
| 7746 | + for (;;) { | ||
| 7747 | + if (!(b[i] != 0)) break; | ||
| 7748 | + ((u8*)res.data)[r_i] = b[i]; | ||
| 7749 | + r_i++; | ||
| 7750 | + i++; | ||
| 7751 | + if (i >= d_pos && exp >= 0) { | ||
| 7752 | + if (exp == 0) { | ||
| 7753 | + ((u8*)res.data)[r_i] = '.'; | ||
| 7754 | + r_i++; | ||
| 7755 | + } | ||
| 7756 | + exp--; | ||
| 7757 | + } | ||
| 7758 | + } | ||
| 7759 | + for (;;) { | ||
| 7760 | + if (!(exp >= 0)) break; | ||
| 7761 | + ((u8*)res.data)[r_i] = '0'; | ||
| 7762 | + r_i++; | ||
| 7763 | + exp--; | ||
| 7764 | + } | ||
| 7765 | + } else { | ||
| 7766 | + bool dot_p = true; | ||
| 7767 | + for (;;) { | ||
| 7768 | + if (!(exp > 0)) break; | ||
| 7769 | + ((u8*)res.data)[r_i] = '0'; | ||
| 7770 | + r_i++; | ||
| 7771 | + exp--; | ||
| 7772 | + if (dot_p) { | ||
| 7773 | + ((u8*)res.data)[r_i] = '.'; | ||
| 7774 | + r_i++; | ||
| 7775 | + dot_p = false; | ||
| 7776 | + } | ||
| 7777 | + } | ||
| 7778 | + for (;;) { | ||
| 7779 | + if (!(b[i] != 0)) break; | ||
| 7780 | + ((u8*)res.data)[r_i] = b[i]; | ||
| 7781 | + r_i++; | ||
| 7782 | + i++; | ||
| 7783 | + } | ||
| 7784 | + } | ||
| 7785 | + if (r_i > 1 && ((u8*)res.data)[r_i - 1] == '.') { | ||
| 7786 | + ((u8*)res.data)[r_i] = '0'; | ||
| 7787 | + r_i++; | ||
| 7788 | + } else if (!(Array_u8_contains(res, '.'))) { | ||
| 7789 | + ((u8*)res.data)[r_i] = '.'; | ||
| 7790 | + r_i++; | ||
| 7791 | + ((u8*)res.data)[r_i] = '0'; | ||
| 7792 | + r_i++; | ||
| 7793 | + } | ||
| 7794 | + ((u8*)res.data)[r_i] = 0; | ||
| 7795 | + string tmp_res = builtin__string_clone(builtin__tos(res.data, r_i)); | ||
| 7796 | + builtin__array_free(&res); | ||
| 7797 | + return tmp_res; | ||
| 7798 | +} | ||
| 7799 | +inline VV_LOC u32 strconv__bool_to_u32(bool b) { | ||
| 7800 | + if (b) { | ||
| 7801 | + return ((u32)(1)); | ||
| 7802 | + } | ||
| 7803 | + return ((u32)(0)); | ||
| 7804 | +} | ||
| 7805 | +inline VV_LOC u64 strconv__bool_to_u64(bool b) { | ||
| 7806 | + if (b) { | ||
| 7807 | + return ((u64)(1)); | ||
| 7808 | + } | ||
| 7809 | + return ((u64)(0)); | ||
| 7810 | +} | ||
| 7811 | +VV_LOC string strconv__get_string_special(bool neg, bool expZero, bool mantZero) { | ||
| 7812 | + if (!mantZero) { | ||
| 7813 | + return _S("nan"); | ||
| 7814 | + } | ||
| 7815 | + if (!expZero) { | ||
| 7816 | + if (neg) { | ||
| 7817 | + return _S("-inf"); | ||
| 7818 | + } else { | ||
| 7819 | + return _S("+inf"); | ||
| 7820 | + } | ||
| 7821 | + } | ||
| 7822 | + if (neg) { | ||
| 7823 | + return _S("-0e+00"); | ||
| 7824 | + } | ||
| 7825 | + return _S("0e+00"); | ||
| 7826 | +} | ||
| 7827 | +VV_LOC u32 strconv__mul_shift_32(u32 m, u64 mul, int ishift) { | ||
| 7828 | + multi_return_u64_u64 mr_750 = math__bits__mul_64(((u64)(m)), mul); | ||
| 7829 | + u64 hi = mr_750.arg0; | ||
| 7830 | + u64 lo = mr_750.arg1; | ||
| 7831 | + u64 shifted_sum = (v__rshift_u64(lo, (u64)((u64)(ishift)))) + (v__lshift_u64(hi, (u64)((u64)(64 - ishift)))); | ||
| 7832 | + ; | ||
| 7833 | + return ((u32)(shifted_sum)); | ||
| 7834 | +} | ||
| 7835 | +inline VV_LOC u32 strconv__mul_pow5_invdiv_pow2(u32 m, u32 q, int j) { | ||
| 7836 | + ; | ||
| 7837 | + return strconv__mul_shift_32(m, _const_strconv__pow5_inv_split_32[q], j); | ||
| 7838 | +} | ||
| 7839 | +inline VV_LOC u32 strconv__mul_pow5_div_pow2(u32 m, u32 i, int j) { | ||
| 7840 | + ; | ||
| 7841 | + return strconv__mul_shift_32(m, _const_strconv__pow5_split_32[i], j); | ||
| 7842 | +} | ||
| 7843 | +VV_LOC u32 strconv__pow5_factor_32(u32 i_v) { | ||
| 7844 | + u32 v = i_v; | ||
| 7845 | + for (u32 n = ((u32)(0)); true; n++) { | ||
| 7846 | + u32 q = VSAFE_DIV_u32(v , 5); | ||
| 7847 | + u32 r = VSAFE_MOD_u32(v , 5); | ||
| 7848 | + if (r != 0) { | ||
| 7849 | + return n; | ||
| 7850 | + } | ||
| 7851 | + v = q; | ||
| 7852 | + } | ||
| 7853 | + return v; | ||
| 7854 | +} | ||
| 7855 | +VV_LOC bool strconv__multiple_of_power_of_five_32(u32 v, u32 p) { | ||
| 7856 | + return strconv__pow5_factor_32(v) >= p; | ||
| 7857 | +} | ||
| 7858 | +VV_LOC bool strconv__multiple_of_power_of_two_32(u32 v, u32 p) { | ||
| 7859 | + return ((u32)(math__bits__trailing_zeros_32(v))) >= p; | ||
| 7860 | +} | ||
| 7861 | +VV_LOC u32 strconv__log10_pow2(int e) { | ||
| 7862 | + ; | ||
| 7863 | + ; | ||
| 7864 | + return v__rshift_u32((((u32)(e)) * 78913), (u64)18); | ||
| 7865 | +} | ||
| 7866 | +VV_LOC u32 strconv__log10_pow5(int e) { | ||
| 7867 | + ; | ||
| 7868 | + ; | ||
| 7869 | + return v__rshift_u32((((u32)(e)) * 732923), (u64)20); | ||
| 7870 | +} | ||
| 7871 | +VV_LOC int strconv__pow5_bits(int e) { | ||
| 7872 | + ; | ||
| 7873 | + ; | ||
| 7874 | + return ((int)((v__rshift_u32((((u32)(e)) * 1217359), (u64)19)) + 1)); | ||
| 7875 | +} | ||
| 7876 | +VV_LOC u64 strconv__shift_right_128(strconv__Uint128 v, int shift) { | ||
| 7877 | + ; | ||
| 7878 | + return ((v__lshift_u64(v.hi, (u64)((u64)(64 - shift)))) | (v__rshift_u64(v.lo, (u64)((u32)(shift))))); | ||
| 7879 | +} | ||
| 7880 | +VV_LOC u64 strconv__mul_shift_64(u64 m, strconv__Uint128 mul, int shift) { | ||
| 7881 | + multi_return_u64_u64 mr_3253 = math__bits__mul_64(m, mul.hi); | ||
| 7882 | + u64 hihi = mr_3253.arg0; | ||
| 7883 | + u64 hilo = mr_3253.arg1; | ||
| 7884 | + multi_return_u64_u64 mr_3288 = math__bits__mul_64(m, mul.lo); | ||
| 7885 | + u64 lohi = mr_3288.arg0; | ||
| 7886 | + strconv__Uint128 sum = ((strconv__Uint128){.lo = lohi + hilo,.hi = hihi,}); | ||
| 7887 | + if (sum.lo < lohi) { | ||
| 7888 | + sum.hi++; | ||
| 7889 | + } | ||
| 7890 | + return strconv__shift_right_128(sum, shift - 64); | ||
| 7891 | +} | ||
| 7892 | +VV_LOC u32 strconv__pow5_factor_64(u64 v_i) { | ||
| 7893 | + u64 v = v_i; | ||
| 7894 | + for (u32 n = ((u32)(0)); true; n++) { | ||
| 7895 | + u64 q = VSAFE_DIV_u64(v , 5); | ||
| 7896 | + u64 r = VSAFE_MOD_u64(v , 5); | ||
| 7897 | + if (r != 0) { | ||
| 7898 | + return n; | ||
| 7899 | + } | ||
| 7900 | + v = q; | ||
| 7901 | + } | ||
| 7902 | + return ((u32)(0)); | ||
| 7903 | +} | ||
| 7904 | +VV_LOC bool strconv__multiple_of_power_of_five_64(u64 v, u32 p) { | ||
| 7905 | + return strconv__pow5_factor_64(v) >= p; | ||
| 7906 | +} | ||
| 7907 | +VV_LOC bool strconv__multiple_of_power_of_two_64(u64 v, u32 p) { | ||
| 7908 | + return ((u32)(math__bits__trailing_zeros_64(v))) >= p; | ||
| 7909 | +} | ||
| 7910 | +int strconv__dec_digits(u64 n) { | ||
| 7911 | + if (n <= 9999999999LL) { | ||
| 7912 | + if (n <= 99999) { | ||
| 7913 | + if (n <= 99) { | ||
| 7914 | + if (n <= 9) { | ||
| 7915 | + return 1; | ||
| 7916 | + } else { | ||
| 7917 | + return 2; | ||
| 7918 | + } | ||
| 7919 | + } else { | ||
| 7920 | + if (n <= 999) { | ||
| 7921 | + return 3; | ||
| 7922 | + } else { | ||
| 7923 | + if (n <= 9999) { | ||
| 7924 | + return 4; | ||
| 7925 | + } else { | ||
| 7926 | + return 5; | ||
| 7927 | + } | ||
| 7928 | + } | ||
| 7929 | + } | ||
| 7930 | + } else { | ||
| 7931 | + if (n <= 9999999) { | ||
| 7932 | + if (n <= 999999) { | ||
| 7933 | + return 6; | ||
| 7934 | + } else { | ||
| 7935 | + return 7; | ||
| 7936 | + } | ||
| 7937 | + } else { | ||
| 7938 | + if (n <= 99999999) { | ||
| 7939 | + return 8; | ||
| 7940 | + } else { | ||
| 7941 | + if (n <= 999999999) { | ||
| 7942 | + return 9; | ||
| 7943 | + } | ||
| 7944 | + return 10; | ||
| 7945 | + } | ||
| 7946 | + } | ||
| 7947 | + } | ||
| 7948 | + } else { | ||
| 7949 | + if (n <= 999999999999999LL) { | ||
| 7950 | + if (n <= 999999999999LL) { | ||
| 7951 | + if (n <= 99999999999LL) { | ||
| 7952 | + return 11; | ||
| 7953 | + } else { | ||
| 7954 | + return 12; | ||
| 7955 | + } | ||
| 7956 | + } else { | ||
| 7957 | + if (n <= 9999999999999LL) { | ||
| 7958 | + return 13; | ||
| 7959 | + } else { | ||
| 7960 | + if (n <= 99999999999999LL) { | ||
| 7961 | + return 14; | ||
| 7962 | + } else { | ||
| 7963 | + return 15; | ||
| 7964 | + } | ||
| 7965 | + } | ||
| 7966 | + } | ||
| 7967 | + } else { | ||
| 7968 | + if (n <= 99999999999999999LL) { | ||
| 7969 | + if (n <= 9999999999999999LL) { | ||
| 7970 | + return 16; | ||
| 7971 | + } else { | ||
| 7972 | + return 17; | ||
| 7973 | + } | ||
| 7974 | + } else { | ||
| 7975 | + if (n <= 999999999999999999LL) { | ||
| 7976 | + return 18; | ||
| 7977 | + } else { | ||
| 7978 | + if (n <= 9999999999999999999ULL) { | ||
| 7979 | + return 19; | ||
| 7980 | + } | ||
| 7981 | + return 20; | ||
| 7982 | + } | ||
| 7983 | + } | ||
| 7984 | + } | ||
| 7985 | + } | ||
| 7986 | + return 0; | ||
| 7987 | +} | ||
| 7988 | +void strconv__v_printf(string str, Array_voidptr pt) { | ||
| 7989 | + Array_voidptr _t1 = pt; | ||
| 7990 | + Array_voidptr _t2 = builtin____new_array(0, _t1.len, sizeof(voidptr)); | ||
| 7991 | + for (int _t3 = 0; _t3 < _t1.len; ++_t3) { | ||
| 7992 | + voidptr _t4 = (*(voidptr*)builtin__array_get(_t1, _t3)); | ||
| 7993 | + builtin__array_push((array*)&_t2, &_t4); | ||
| 7994 | + } | ||
| 7995 | + builtin__print(strconv__v_sprintf(str,_t2)); | ||
| 7996 | +} | ||
| 7997 | +string strconv__v_sprintf(string str, Array_voidptr pt) { | ||
| 7998 | + strings__Builder res = strings__new_builder(pt.len * 16); | ||
| 7999 | + int i = 0; | ||
| 8000 | + int p_index = 0; | ||
| 8001 | + bool sign = false; | ||
| 8002 | + strconv__Align_text align = strconv__Align_text__right; | ||
| 8003 | + int len0 = -1; | ||
| 8004 | + int len1 = -1; | ||
| 8005 | + int def_len1 = 6; | ||
| 8006 | + u8 pad_ch = ((u8)(' ')); | ||
| 8007 | + rune ch1 = '0'; | ||
| 8008 | + rune ch2 = '0'; | ||
| 8009 | + strconv__Char_parse_state status = strconv__Char_parse_state__norm_char; | ||
| 8010 | + for (;;) { | ||
| 8011 | + if (!(i < str.len)) break; | ||
| 8012 | + if (status == strconv__Char_parse_state__reset_params) { | ||
| 8013 | + sign = false; | ||
| 8014 | + align = strconv__Align_text__right; | ||
| 8015 | + len0 = -1; | ||
| 8016 | + len1 = -1; | ||
| 8017 | + pad_ch = ' '; | ||
| 8018 | + status = strconv__Char_parse_state__norm_char; | ||
| 8019 | + ch1 = '0'; | ||
| 8020 | + ch2 = '0'; | ||
| 8021 | + continue; | ||
| 8022 | + } | ||
| 8023 | + u8 ch = str.str[ i]; | ||
| 8024 | + if (ch != '%' && status == strconv__Char_parse_state__norm_char) { | ||
| 8025 | + strings__Builder_write_u8(&res, ch); | ||
| 8026 | + i++; | ||
| 8027 | + continue; | ||
| 8028 | + } | ||
| 8029 | + if (ch == '%' && status == strconv__Char_parse_state__field_char) { | ||
| 8030 | + status = strconv__Char_parse_state__norm_char; | ||
| 8031 | + strings__Builder_write_u8(&res, ch); | ||
| 8032 | + i++; | ||
| 8033 | + continue; | ||
| 8034 | + } | ||
| 8035 | + if (ch == '%' && status == strconv__Char_parse_state__norm_char) { | ||
| 8036 | + status = strconv__Char_parse_state__field_char; | ||
| 8037 | + i++; | ||
| 8038 | + continue; | ||
| 8039 | + } | ||
| 8040 | + if (ch == 'c' && status == strconv__Char_parse_state__field_char) { | ||
| 8041 | + strconv__v_sprintf_panic(p_index, pt.len); | ||
| 8042 | + u8 d1 = ((u8)(*(((int*)(((voidptr*)pt.data)[p_index]))))); | ||
| 8043 | + strings__Builder_write_u8(&res, d1); | ||
| 8044 | + status = strconv__Char_parse_state__reset_params; | ||
| 8045 | + p_index++; | ||
| 8046 | + i++; | ||
| 8047 | + continue; | ||
| 8048 | + } | ||
| 8049 | + if (ch == 'p' && status == strconv__Char_parse_state__field_char) { | ||
| 8050 | + strconv__v_sprintf_panic(p_index, pt.len); | ||
| 8051 | + strings__Builder_write_string(&res, _S("0x")); | ||
| 8052 | + strings__Builder_write_string(&res, builtin__ptr_str(((voidptr*)pt.data)[p_index])); | ||
| 8053 | + status = strconv__Char_parse_state__reset_params; | ||
| 8054 | + p_index++; | ||
| 8055 | + i++; | ||
| 8056 | + continue; | ||
| 8057 | + } | ||
| 8058 | + if (status == strconv__Char_parse_state__field_char) { | ||
| 8059 | + rune fc_ch1 = '0'; | ||
| 8060 | + rune fc_ch2 = '0'; | ||
| 8061 | + if ((i + 1) < str.len) { | ||
| 8062 | + fc_ch1 = str.str[ i + 1]; | ||
| 8063 | + if ((i + 2) < str.len) { | ||
| 8064 | + fc_ch2 = str.str[ i + 2]; | ||
| 8065 | + } | ||
| 8066 | + } | ||
| 8067 | + if (ch == '+') { | ||
| 8068 | + sign = true; | ||
| 8069 | + i++; | ||
| 8070 | + continue; | ||
| 8071 | + } else if (ch == '-') { | ||
| 8072 | + align = strconv__Align_text__left; | ||
| 8073 | + i++; | ||
| 8074 | + continue; | ||
| 8075 | + } else if (ch == '0' || ch == ' ') { | ||
| 8076 | + if (align == strconv__Align_text__right) { | ||
| 8077 | + pad_ch = ch; | ||
| 8078 | + } | ||
| 8079 | + i++; | ||
| 8080 | + continue; | ||
| 8081 | + } else if (ch == '\'') { | ||
| 8082 | + i++; | ||
| 8083 | + continue; | ||
| 8084 | + } else if (ch == '.' && fc_ch1 >= '1' && fc_ch1 <= '9') { | ||
| 8085 | + status = strconv__Char_parse_state__check_float; | ||
| 8086 | + i++; | ||
| 8087 | + continue; | ||
| 8088 | + } else if (ch == '.' && fc_ch1 == '*' && fc_ch2 == 's') { | ||
| 8089 | + strconv__v_sprintf_panic(p_index, pt.len); | ||
| 8090 | + int len = *(((int*)(((voidptr*)pt.data)[p_index]))); | ||
| 8091 | + p_index++; | ||
| 8092 | + strconv__v_sprintf_panic(p_index, pt.len); | ||
| 8093 | + string s = *(((string*)(((voidptr*)pt.data)[p_index]))); | ||
| 8094 | + s = builtin__string_substr(s, 0, len); | ||
| 8095 | + p_index++; | ||
| 8096 | + strings__Builder_write_string(&res, s); | ||
| 8097 | + status = strconv__Char_parse_state__reset_params; | ||
| 8098 | + i += 3; | ||
| 8099 | + continue; | ||
| 8100 | + } | ||
| 8101 | + status = strconv__Char_parse_state__len_set_start; | ||
| 8102 | + continue; | ||
| 8103 | + } | ||
| 8104 | + if (status == strconv__Char_parse_state__len_set_start) { | ||
| 8105 | + if (ch >= '1' && ch <= '9') { | ||
| 8106 | + len0 = ((int)((rune)(ch - '0'))); | ||
| 8107 | + status = strconv__Char_parse_state__len_set_in; | ||
| 8108 | + i++; | ||
| 8109 | + continue; | ||
| 8110 | + } | ||
| 8111 | + if (ch == '.') { | ||
| 8112 | + status = strconv__Char_parse_state__check_float; | ||
| 8113 | + i++; | ||
| 8114 | + continue; | ||
| 8115 | + } | ||
| 8116 | + status = strconv__Char_parse_state__check_type; | ||
| 8117 | + continue; | ||
| 8118 | + } | ||
| 8119 | + if (status == strconv__Char_parse_state__len_set_in) { | ||
| 8120 | + if (ch >= '0' && ch <= '9') { | ||
| 8121 | + len0 *= 10; | ||
| 8122 | + len0 += ((int)((rune)(ch - '0'))); | ||
| 8123 | + i++; | ||
| 8124 | + continue; | ||
| 8125 | + } | ||
| 8126 | + if (ch == '.') { | ||
| 8127 | + status = strconv__Char_parse_state__check_float; | ||
| 8128 | + i++; | ||
| 8129 | + continue; | ||
| 8130 | + } | ||
| 8131 | + status = strconv__Char_parse_state__check_type; | ||
| 8132 | + continue; | ||
| 8133 | + } | ||
| 8134 | + if (status == strconv__Char_parse_state__check_float) { | ||
| 8135 | + if (ch >= '0' && ch <= '9') { | ||
| 8136 | + len1 = ((int)((rune)(ch - '0'))); | ||
| 8137 | + status = strconv__Char_parse_state__check_float_in; | ||
| 8138 | + i++; | ||
| 8139 | + continue; | ||
| 8140 | + } | ||
| 8141 | + status = strconv__Char_parse_state__check_type; | ||
| 8142 | + continue; | ||
| 8143 | + } | ||
| 8144 | + if (status == strconv__Char_parse_state__check_float_in) { | ||
| 8145 | + if (ch >= '0' && ch <= '9') { | ||
| 8146 | + len1 *= 10; | ||
| 8147 | + len1 += ((int)((rune)(ch - '0'))); | ||
| 8148 | + i++; | ||
| 8149 | + continue; | ||
| 8150 | + } | ||
| 8151 | + status = strconv__Char_parse_state__check_type; | ||
| 8152 | + continue; | ||
| 8153 | + } | ||
| 8154 | + if (status == strconv__Char_parse_state__check_type) { | ||
| 8155 | + if (ch == 'l') { | ||
| 8156 | + if (ch1 == '0') { | ||
| 8157 | + ch1 = 'l'; | ||
| 8158 | + i++; | ||
| 8159 | + continue; | ||
| 8160 | + } else { | ||
| 8161 | + ch2 = 'l'; | ||
| 8162 | + i++; | ||
| 8163 | + continue; | ||
| 8164 | + } | ||
| 8165 | + } else if (ch == 'h') { | ||
| 8166 | + if (ch1 == '0') { | ||
| 8167 | + ch1 = 'h'; | ||
| 8168 | + i++; | ||
| 8169 | + continue; | ||
| 8170 | + } else { | ||
| 8171 | + ch2 = 'h'; | ||
| 8172 | + i++; | ||
| 8173 | + continue; | ||
| 8174 | + } | ||
| 8175 | + } else if (ch == 'd' || ch == 'i') { | ||
| 8176 | + u64 d1 = ((u64)(0)); | ||
| 8177 | + bool positive = true; | ||
| 8178 | + | ||
| 8179 | + if (ch1 == ('h')) { | ||
| 8180 | + strconv__v_sprintf_panic(p_index, pt.len); | ||
| 8181 | + int x = *(((int*)(((voidptr*)pt.data)[p_index]))); | ||
| 8182 | + if (ch2 == 'h') { | ||
| 8183 | + i8 sx = ((i8)(x)); | ||
| 8184 | + positive = (sx >= 0 ? (true) : (false)); | ||
| 8185 | + d1 = (positive ? (((u64)(sx))) : (((u64)(-sx)))); | ||
| 8186 | + } else { | ||
| 8187 | + i16 sx = ((i16)(x)); | ||
| 8188 | + positive = (sx >= 0 ? (true) : (false)); | ||
| 8189 | + d1 = (positive ? (((u64)(sx))) : (((u64)(-sx)))); | ||
| 8190 | + } | ||
| 8191 | + } | ||
| 8192 | + else if (ch1 == ('l')) { | ||
| 8193 | + strconv__v_sprintf_panic(p_index, pt.len); | ||
| 8194 | + i64 x = *(((i64*)(((voidptr*)pt.data)[p_index]))); | ||
| 8195 | + positive = (x >= 0 ? (true) : (false)); | ||
| 8196 | + d1 = (positive ? (((u64)(x))) : (((u64)(-x)))); | ||
| 8197 | + } | ||
| 8198 | + else { | ||
| 8199 | + strconv__v_sprintf_panic(p_index, pt.len); | ||
| 8200 | + int x = *(((int*)(((voidptr*)pt.data)[p_index]))); | ||
| 8201 | + positive = (x >= 0 ? (true) : (false)); | ||
| 8202 | + d1 = (positive ? (((u64)(x))) : (((u64)(-x)))); | ||
| 8203 | + } | ||
| 8204 | + string tmp = strconv__format_dec_old(d1, ((strconv__BF_param){ | ||
| 8205 | + .pad_ch = pad_ch, | ||
| 8206 | + .len0 = len0, | ||
| 8207 | + .len1 = 0, | ||
| 8208 | + .positive = positive, | ||
| 8209 | + .sign_flag = sign, | ||
| 8210 | + .align = align, | ||
| 8211 | + .rm_tail_zero = 0, | ||
| 8212 | + })); | ||
| 8213 | + strings__Builder_write_string(&res, tmp); | ||
| 8214 | + builtin__string_free(&tmp); | ||
| 8215 | + status = strconv__Char_parse_state__reset_params; | ||
| 8216 | + p_index++; | ||
| 8217 | + i++; | ||
| 8218 | + ch1 = '0'; | ||
| 8219 | + ch2 = '0'; | ||
| 8220 | + continue; | ||
| 8221 | + } else if (ch == 'u') { | ||
| 8222 | + u64 d1 = ((u64)(0)); | ||
| 8223 | + bool positive = true; | ||
| 8224 | + strconv__v_sprintf_panic(p_index, pt.len); | ||
| 8225 | + | ||
| 8226 | + if (ch1 == ('h')) { | ||
| 8227 | + int x = *(((int*)(((voidptr*)pt.data)[p_index]))); | ||
| 8228 | + if (ch2 == 'h') { | ||
| 8229 | + d1 = ((u64)(((u8)(x)))); | ||
| 8230 | + } else { | ||
| 8231 | + d1 = ((u64)(((u16)(x)))); | ||
| 8232 | + } | ||
| 8233 | + } | ||
| 8234 | + else if (ch1 == ('l')) { | ||
| 8235 | + d1 = ((u64)(*(((u64*)(((voidptr*)pt.data)[p_index]))))); | ||
| 8236 | + } | ||
| 8237 | + else { | ||
| 8238 | + d1 = ((u64)(((u32)(*(((int*)(((voidptr*)pt.data)[p_index]))))))); | ||
| 8239 | + } | ||
| 8240 | + string tmp = strconv__format_dec_old(d1, ((strconv__BF_param){ | ||
| 8241 | + .pad_ch = pad_ch, | ||
| 8242 | + .len0 = len0, | ||
| 8243 | + .len1 = 0, | ||
| 8244 | + .positive = positive, | ||
| 8245 | + .sign_flag = sign, | ||
| 8246 | + .align = align, | ||
| 8247 | + .rm_tail_zero = 0, | ||
| 8248 | + })); | ||
| 8249 | + strings__Builder_write_string(&res, tmp); | ||
| 8250 | + builtin__string_free(&tmp); | ||
| 8251 | + status = strconv__Char_parse_state__reset_params; | ||
| 8252 | + p_index++; | ||
| 8253 | + i++; | ||
| 8254 | + continue; | ||
| 8255 | + } else if (ch == 'x' || ch == 'X') { | ||
| 8256 | + strconv__v_sprintf_panic(p_index, pt.len); | ||
| 8257 | + string s = _S(""); | ||
| 8258 | + | ||
| 8259 | + if (ch1 == ('h')) { | ||
| 8260 | + int x = *(((int*)(((voidptr*)pt.data)[p_index]))); | ||
| 8261 | + if (ch2 == 'h') { | ||
| 8262 | + s = builtin__i8_hex(((i8)(x))); | ||
| 8263 | + } else { | ||
| 8264 | + s = builtin__i16_hex(((i16)(x))); | ||
| 8265 | + } | ||
| 8266 | + } | ||
| 8267 | + else if (ch1 == ('l')) { | ||
| 8268 | + i64 x = *(((i64*)(((voidptr*)pt.data)[p_index]))); | ||
| 8269 | + s = builtin__i64_hex(x); | ||
| 8270 | + } | ||
| 8271 | + else { | ||
| 8272 | + int x = *(((int*)(((voidptr*)pt.data)[p_index]))); | ||
| 8273 | + s = builtin__int_hex(x); | ||
| 8274 | + } | ||
| 8275 | + if (ch == 'X') { | ||
| 8276 | + string tmp = s; | ||
| 8277 | + s = builtin__string_to_upper(s); | ||
| 8278 | + builtin__string_free(&tmp); | ||
| 8279 | + } | ||
| 8280 | + string tmp = strconv__format_str(s, ((strconv__BF_param){ | ||
| 8281 | + .pad_ch = pad_ch, | ||
| 8282 | + .len0 = len0, | ||
| 8283 | + .len1 = 0, | ||
| 8284 | + .positive = true, | ||
| 8285 | + .sign_flag = false, | ||
| 8286 | + .align = align, | ||
| 8287 | + .rm_tail_zero = 0, | ||
| 8288 | + })); | ||
| 8289 | + strings__Builder_write_string(&res, tmp); | ||
| 8290 | + builtin__string_free(&tmp); | ||
| 8291 | + builtin__string_free(&s); | ||
| 8292 | + status = strconv__Char_parse_state__reset_params; | ||
| 8293 | + p_index++; | ||
| 8294 | + i++; | ||
| 8295 | + continue; | ||
| 8296 | + } | ||
| 8297 | + if (ch == 'f' || ch == 'F') { | ||
| 8298 | + #if !defined(CUSTOM_DEFINE_nofloat) | ||
| 8299 | + { | ||
| 8300 | + strconv__v_sprintf_panic(p_index, pt.len); | ||
| 8301 | + f64 x = *(((f64*)(((voidptr*)pt.data)[p_index]))); | ||
| 8302 | + bool positive = x >= ((f64)(0.0)); | ||
| 8303 | + len1 = (len1 >= 0 ? (len1) : (def_len1)); | ||
| 8304 | + string s = strconv__format_fl_old(((f64)(x)), ((strconv__BF_param){ | ||
| 8305 | + .pad_ch = pad_ch, | ||
| 8306 | + .len0 = len0, | ||
| 8307 | + .len1 = len1, | ||
| 8308 | + .positive = positive, | ||
| 8309 | + .sign_flag = sign, | ||
| 8310 | + .align = align, | ||
| 8311 | + .rm_tail_zero = 0, | ||
| 8312 | + })); | ||
| 8313 | + if (ch == 'F') { | ||
| 8314 | + string tmp = builtin__string_to_upper(s); | ||
| 8315 | + strings__Builder_write_string(&res, tmp); | ||
| 8316 | + builtin__string_free(&tmp); | ||
| 8317 | + } else { | ||
| 8318 | + strings__Builder_write_string(&res, s); | ||
| 8319 | + } | ||
| 8320 | + builtin__string_free(&s); | ||
| 8321 | + } | ||
| 8322 | + #endif | ||
| 8323 | + status = strconv__Char_parse_state__reset_params; | ||
| 8324 | + p_index++; | ||
| 8325 | + i++; | ||
| 8326 | + continue; | ||
| 8327 | + } else if (ch == 'e' || ch == 'E') { | ||
| 8328 | + #if !defined(CUSTOM_DEFINE_nofloat) | ||
| 8329 | + { | ||
| 8330 | + strconv__v_sprintf_panic(p_index, pt.len); | ||
| 8331 | + f64 x = *(((f64*)(((voidptr*)pt.data)[p_index]))); | ||
| 8332 | + bool positive = x >= ((f64)(0.0)); | ||
| 8333 | + len1 = (len1 >= 0 ? (len1) : (def_len1)); | ||
| 8334 | + string s = strconv__format_es_old(((f64)(x)), ((strconv__BF_param){ | ||
| 8335 | + .pad_ch = pad_ch, | ||
| 8336 | + .len0 = len0, | ||
| 8337 | + .len1 = len1, | ||
| 8338 | + .positive = positive, | ||
| 8339 | + .sign_flag = sign, | ||
| 8340 | + .align = align, | ||
| 8341 | + .rm_tail_zero = 0, | ||
| 8342 | + })); | ||
| 8343 | + if (ch == 'E') { | ||
| 8344 | + string tmp = builtin__string_to_upper(s); | ||
| 8345 | + strings__Builder_write_string(&res, tmp); | ||
| 8346 | + builtin__string_free(&tmp); | ||
| 8347 | + } else { | ||
| 8348 | + strings__Builder_write_string(&res, s); | ||
| 8349 | + } | ||
| 8350 | + builtin__string_free(&s); | ||
| 8351 | + } | ||
| 8352 | + #endif | ||
| 8353 | + status = strconv__Char_parse_state__reset_params; | ||
| 8354 | + p_index++; | ||
| 8355 | + i++; | ||
| 8356 | + continue; | ||
| 8357 | + } else if (ch == 'g' || ch == 'G') { | ||
| 8358 | + #if !defined(CUSTOM_DEFINE_nofloat) | ||
| 8359 | + { | ||
| 8360 | + strconv__v_sprintf_panic(p_index, pt.len); | ||
| 8361 | + f64 x = *(((f64*)(((voidptr*)pt.data)[p_index]))); | ||
| 8362 | + bool positive = x >= ((f64)(0.0)); | ||
| 8363 | + string s = _S(""); | ||
| 8364 | + f64 tx = strconv__fabs(x); | ||
| 8365 | + if (tx < ((f64)(999999.0)) && tx >= ((f64)(0.00001))) { | ||
| 8366 | + len1 = (len1 >= 0 ? (len1 + 1) : (def_len1)); | ||
| 8367 | + string tmp = s; | ||
| 8368 | + s = strconv__format_fl_old(x, ((strconv__BF_param){ | ||
| 8369 | + .pad_ch = pad_ch, | ||
| 8370 | + .len0 = len0, | ||
| 8371 | + .len1 = len1, | ||
| 8372 | + .positive = positive, | ||
| 8373 | + .sign_flag = sign, | ||
| 8374 | + .align = align, | ||
| 8375 | + .rm_tail_zero = true, | ||
| 8376 | + })); | ||
| 8377 | + builtin__string_free(&tmp); | ||
| 8378 | + } else { | ||
| 8379 | + len1 = (len1 >= 0 ? (len1 + 1) : (def_len1)); | ||
| 8380 | + string tmp = s; | ||
| 8381 | + s = strconv__format_es_old(x, ((strconv__BF_param){ | ||
| 8382 | + .pad_ch = pad_ch, | ||
| 8383 | + .len0 = len0, | ||
| 8384 | + .len1 = len1, | ||
| 8385 | + .positive = positive, | ||
| 8386 | + .sign_flag = sign, | ||
| 8387 | + .align = align, | ||
| 8388 | + .rm_tail_zero = true, | ||
| 8389 | + })); | ||
| 8390 | + builtin__string_free(&tmp); | ||
| 8391 | + } | ||
| 8392 | + if (ch == 'G') { | ||
| 8393 | + string tmp = builtin__string_to_upper(s); | ||
| 8394 | + strings__Builder_write_string(&res, tmp); | ||
| 8395 | + builtin__string_free(&tmp); | ||
| 8396 | + } else { | ||
| 8397 | + strings__Builder_write_string(&res, s); | ||
| 8398 | + } | ||
| 8399 | + builtin__string_free(&s); | ||
| 8400 | + } | ||
| 8401 | + #endif | ||
| 8402 | + status = strconv__Char_parse_state__reset_params; | ||
| 8403 | + p_index++; | ||
| 8404 | + i++; | ||
| 8405 | + continue; | ||
| 8406 | + } else if (ch == 's') { | ||
| 8407 | + strconv__v_sprintf_panic(p_index, pt.len); | ||
| 8408 | + string s1 = *(((string*)(((voidptr*)pt.data)[p_index]))); | ||
| 8409 | + pad_ch = ' '; | ||
| 8410 | + string tmp = strconv__format_str(s1, ((strconv__BF_param){ | ||
| 8411 | + .pad_ch = pad_ch, | ||
| 8412 | + .len0 = len0, | ||
| 8413 | + .len1 = 0, | ||
| 8414 | + .positive = true, | ||
| 8415 | + .sign_flag = false, | ||
| 8416 | + .align = align, | ||
| 8417 | + .rm_tail_zero = 0, | ||
| 8418 | + })); | ||
| 8419 | + strings__Builder_write_string(&res, tmp); | ||
| 8420 | + builtin__string_free(&tmp); | ||
| 8421 | + status = strconv__Char_parse_state__reset_params; | ||
| 8422 | + p_index++; | ||
| 8423 | + i++; | ||
| 8424 | + continue; | ||
| 8425 | + } | ||
| 8426 | + } | ||
| 8427 | + status = strconv__Char_parse_state__reset_params; | ||
| 8428 | + p_index++; | ||
| 8429 | + i++; | ||
| 8430 | + } | ||
| 8431 | + if (p_index != pt.len) { | ||
| 8432 | + builtin__panic_n2(_S("% conversion specifiers number mismatch (expected %, given args)"), p_index, pt.len); | ||
| 8433 | + VUNREACHABLE(); | ||
| 8434 | + } | ||
| 8435 | + string _t4 = strings__Builder_str(&res); | ||
| 8436 | + { // defer begin | ||
| 8437 | + strings__Builder_free(&res); | ||
| 8438 | + } // defer end | ||
| 8439 | + return _t4; | ||
| 8440 | +} | ||
| 8441 | +inline VV_LOC void strconv__v_sprintf_panic(int idx, int len) { | ||
| 8442 | + if (idx >= len) { | ||
| 8443 | + builtin__panic_n2(_S("% conversion specifiers number mismatch (expected %, given args)"), idx + 1, len); | ||
| 8444 | + VUNREACHABLE(); | ||
| 8445 | + } | ||
| 8446 | +} | ||
| 8447 | +VV_LOC f64 strconv__fabs(f64 x) { | ||
| 8448 | + if (x < ((f64)(0.0))) { | ||
| 8449 | + return -x; | ||
| 8450 | + } | ||
| 8451 | + return x; | ||
| 8452 | +} | ||
| 8453 | +string strconv__format_fl_old(f64 f, strconv__BF_param p) { | ||
| 8454 | + { // Unsafe block | ||
| 8455 | + string s = _S(""); | ||
| 8456 | + string fs = strconv__f64_to_str_lnd1((f >= ((f64)(0.0)) ? (f) : (-f)), p.len1); | ||
| 8457 | + if (fs.str[ 0] == '[') { | ||
| 8458 | + builtin__string_free(&s); | ||
| 8459 | + return fs; | ||
| 8460 | + } | ||
| 8461 | + if (p.rm_tail_zero) { | ||
| 8462 | + string tmp = fs; | ||
| 8463 | + fs = strconv__remove_tail_zeros_old(fs); | ||
| 8464 | + builtin__string_free(&tmp); | ||
| 8465 | + } | ||
| 8466 | + strings__Builder res = strings__new_builder((p.len0 > fs.len ? (p.len0) : (fs.len))); | ||
| 8467 | + int sign_len_diff = 0; | ||
| 8468 | + if (p.pad_ch == '0') { | ||
| 8469 | + if (p.positive) { | ||
| 8470 | + if (p.sign_flag) { | ||
| 8471 | + strings__Builder_write_u8(&res, '+'); | ||
| 8472 | + sign_len_diff = -1; | ||
| 8473 | + } | ||
| 8474 | + } else { | ||
| 8475 | + strings__Builder_write_u8(&res, '-'); | ||
| 8476 | + sign_len_diff = -1; | ||
| 8477 | + } | ||
| 8478 | + string tmp = s; | ||
| 8479 | + s = builtin__string_clone(fs); | ||
| 8480 | + builtin__string_free(&tmp); | ||
| 8481 | + } else { | ||
| 8482 | + if (p.positive) { | ||
| 8483 | + if (p.sign_flag) { | ||
| 8484 | + string tmp = s; | ||
| 8485 | + s = builtin__string__plus(_S("+"), fs); | ||
| 8486 | + builtin__string_free(&tmp); | ||
| 8487 | + } else { | ||
| 8488 | + string tmp = s; | ||
| 8489 | + s = builtin__string_clone(fs); | ||
| 8490 | + builtin__string_free(&tmp); | ||
| 8491 | + } | ||
| 8492 | + } else { | ||
| 8493 | + string tmp = s; | ||
| 8494 | + s = builtin__string__plus(_S("-"), fs); | ||
| 8495 | + builtin__string_free(&tmp); | ||
| 8496 | + } | ||
| 8497 | + } | ||
| 8498 | + int dif = p.len0 - s.len + sign_len_diff; | ||
| 8499 | + if (p.align == strconv__Align_text__right) { | ||
| 8500 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 8501 | + strings__Builder_write_u8(&res, p.pad_ch); | ||
| 8502 | + } | ||
| 8503 | + } | ||
| 8504 | + strings__Builder_write_string(&res, s); | ||
| 8505 | + if (p.align == strconv__Align_text__left) { | ||
| 8506 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 8507 | + strings__Builder_write_u8(&res, p.pad_ch); | ||
| 8508 | + } | ||
| 8509 | + } | ||
| 8510 | + builtin__string_free(&s); | ||
| 8511 | + builtin__string_free(&fs); | ||
| 8512 | + string _t2 = strings__Builder_str(&res); | ||
| 8513 | + { // defer begin | ||
| 8514 | + strings__Builder_free(&res); | ||
| 8515 | + } // defer end | ||
| 8516 | + return _t2; | ||
| 8517 | + { // defer begin | ||
| 8518 | + strings__Builder_free(&res); | ||
| 8519 | + } // defer end | ||
| 8520 | + } | ||
| 8521 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 8522 | +} | ||
| 8523 | +VV_LOC string strconv__format_es_old(f64 f, strconv__BF_param p) { | ||
| 8524 | + { // Unsafe block | ||
| 8525 | + string s = _S(""); | ||
| 8526 | + string fs = strconv__f64_to_str_pad((f > 0 ? (f) : (-f)), p.len1); | ||
| 8527 | + if (p.rm_tail_zero) { | ||
| 8528 | + string tmp = fs; | ||
| 8529 | + fs = strconv__remove_tail_zeros_old(fs); | ||
| 8530 | + builtin__string_free(&tmp); | ||
| 8531 | + } | ||
| 8532 | + strings__Builder res = strings__new_builder((p.len0 > fs.len ? (p.len0) : (fs.len))); | ||
| 8533 | + int sign_len_diff = 0; | ||
| 8534 | + if (p.pad_ch == '0') { | ||
| 8535 | + if (p.positive) { | ||
| 8536 | + if (p.sign_flag) { | ||
| 8537 | + strings__Builder_write_u8(&res, '+'); | ||
| 8538 | + sign_len_diff = -1; | ||
| 8539 | + } | ||
| 8540 | + } else { | ||
| 8541 | + strings__Builder_write_u8(&res, '-'); | ||
| 8542 | + sign_len_diff = -1; | ||
| 8543 | + } | ||
| 8544 | + string tmp = s; | ||
| 8545 | + s = builtin__string_clone(fs); | ||
| 8546 | + builtin__string_free(&tmp); | ||
| 8547 | + } else { | ||
| 8548 | + if (p.positive) { | ||
| 8549 | + if (p.sign_flag) { | ||
| 8550 | + string tmp = s; | ||
| 8551 | + s = builtin__string__plus(_S("+"), fs); | ||
| 8552 | + builtin__string_free(&tmp); | ||
| 8553 | + } else { | ||
| 8554 | + string tmp = s; | ||
| 8555 | + s = builtin__string_clone(fs); | ||
| 8556 | + builtin__string_free(&tmp); | ||
| 8557 | + } | ||
| 8558 | + } else { | ||
| 8559 | + string tmp = s; | ||
| 8560 | + s = builtin__string__plus(_S("-"), fs); | ||
| 8561 | + builtin__string_free(&tmp); | ||
| 8562 | + } | ||
| 8563 | + } | ||
| 8564 | + int dif = p.len0 - s.len + sign_len_diff; | ||
| 8565 | + if (p.align == strconv__Align_text__right) { | ||
| 8566 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 8567 | + strings__Builder_write_u8(&res, p.pad_ch); | ||
| 8568 | + } | ||
| 8569 | + } | ||
| 8570 | + strings__Builder_write_string(&res, s); | ||
| 8571 | + if (p.align == strconv__Align_text__left) { | ||
| 8572 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 8573 | + strings__Builder_write_u8(&res, p.pad_ch); | ||
| 8574 | + } | ||
| 8575 | + } | ||
| 8576 | + string _t1 = strings__Builder_str(&res); | ||
| 8577 | + { // defer begin | ||
| 8578 | + strings__Builder_free(&res); | ||
| 8579 | + builtin__string_free(&fs); | ||
| 8580 | + builtin__string_free(&s); | ||
| 8581 | + } // defer end | ||
| 8582 | + return _t1; | ||
| 8583 | + { // defer begin | ||
| 8584 | + strings__Builder_free(&res); | ||
| 8585 | + builtin__string_free(&fs); | ||
| 8586 | + builtin__string_free(&s); | ||
| 8587 | + } // defer end | ||
| 8588 | + } | ||
| 8589 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 8590 | +} | ||
| 8591 | +VV_LOC string strconv__remove_tail_zeros_old(string s) { | ||
| 8592 | + int i = 0; | ||
| 8593 | + int last_zero_start = -1; | ||
| 8594 | + int dot_pos = -1; | ||
| 8595 | + bool in_decimal = false; | ||
| 8596 | + u8 prev_ch = ((u8)(0)); | ||
| 8597 | + for (;;) { | ||
| 8598 | + if (!(i < s.len)) break; | ||
| 8599 | + u8 ch = s.str[i]; | ||
| 8600 | + if (ch == '.') { | ||
| 8601 | + in_decimal = true; | ||
| 8602 | + dot_pos = i; | ||
| 8603 | + } else if (in_decimal) { | ||
| 8604 | + if (ch == '0' && prev_ch != '0') { | ||
| 8605 | + last_zero_start = i; | ||
| 8606 | + } else if (ch >= '1' && ch <= '9') { | ||
| 8607 | + last_zero_start = -1; | ||
| 8608 | + } else if (ch == 'e') { | ||
| 8609 | + break; | ||
| 8610 | + } | ||
| 8611 | + } | ||
| 8612 | + prev_ch = ch; | ||
| 8613 | + i++; | ||
| 8614 | + } | ||
| 8615 | + string tmp = _S(""); | ||
| 8616 | + if (last_zero_start > 0) { | ||
| 8617 | + if (last_zero_start == dot_pos + 1) { | ||
| 8618 | + tmp = builtin__string__plus(builtin__string_substr(s, 0, dot_pos), builtin__string_substr(s, i, 2147483647)); | ||
| 8619 | + } else { | ||
| 8620 | + tmp = builtin__string__plus(builtin__string_substr(s, 0, last_zero_start), builtin__string_substr(s, i, 2147483647)); | ||
| 8621 | + } | ||
| 8622 | + } else { | ||
| 8623 | + tmp = builtin__string_clone(s); | ||
| 8624 | + } | ||
| 8625 | + if (tmp.str[tmp.len - 1] == '.') { | ||
| 8626 | + return builtin__string_substr(tmp, 0, tmp.len - 1); | ||
| 8627 | + } | ||
| 8628 | + return tmp; | ||
| 8629 | +} | ||
| 8630 | +string strconv__format_dec_old(u64 d, strconv__BF_param p) { | ||
| 8631 | + string s = _S(""); | ||
| 8632 | + strings__Builder res = strings__new_builder(20); | ||
| 8633 | + int sign_len_diff = 0; | ||
| 8634 | + if (p.pad_ch == '0') { | ||
| 8635 | + if (p.positive) { | ||
| 8636 | + if (p.sign_flag) { | ||
| 8637 | + strings__Builder_write_u8(&res, '+'); | ||
| 8638 | + sign_len_diff = -1; | ||
| 8639 | + } | ||
| 8640 | + } else { | ||
| 8641 | + strings__Builder_write_u8(&res, '-'); | ||
| 8642 | + sign_len_diff = -1; | ||
| 8643 | + } | ||
| 8644 | + string tmp = s; | ||
| 8645 | + s = builtin__u64_str(d); | ||
| 8646 | + builtin__string_free(&tmp); | ||
| 8647 | + } else { | ||
| 8648 | + if (p.positive) { | ||
| 8649 | + if (p.sign_flag) { | ||
| 8650 | + string tmp = s; | ||
| 8651 | + s = builtin__string__plus(_S("+"), builtin__u64_str(d)); | ||
| 8652 | + builtin__string_free(&tmp); | ||
| 8653 | + } else { | ||
| 8654 | + string tmp = s; | ||
| 8655 | + s = builtin__u64_str(d); | ||
| 8656 | + builtin__string_free(&tmp); | ||
| 8657 | + } | ||
| 8658 | + } else { | ||
| 8659 | + string tmp = s; | ||
| 8660 | + s = builtin__string__plus(_S("-"), builtin__u64_str(d)); | ||
| 8661 | + builtin__string_free(&tmp); | ||
| 8662 | + } | ||
| 8663 | + } | ||
| 8664 | + int dif = p.len0 - s.len + sign_len_diff; | ||
| 8665 | + if (p.align == strconv__Align_text__right) { | ||
| 8666 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 8667 | + strings__Builder_write_u8(&res, p.pad_ch); | ||
| 8668 | + } | ||
| 8669 | + } | ||
| 8670 | + strings__Builder_write_string(&res, s); | ||
| 8671 | + if (p.align == strconv__Align_text__left) { | ||
| 8672 | + for (int i1 = 0; i1 < dif; i1++) { | ||
| 8673 | + strings__Builder_write_u8(&res, p.pad_ch); | ||
| 8674 | + } | ||
| 8675 | + } | ||
| 8676 | + string _t1 = strings__Builder_str(&res); | ||
| 8677 | + { // defer begin | ||
| 8678 | + strings__Builder_free(&res); | ||
| 8679 | + builtin__string_free(&s); | ||
| 8680 | + } // defer end | ||
| 8681 | + return _t1; | ||
| 8682 | +} | ||
| 8683 | +int strconv__write_dec(i64 n, Array_u8* buf) { | ||
| 8684 | + u64 mag = ((u64)(n)); | ||
| 8685 | + if (n < 0) { | ||
| 8686 | + mag = ((u64)(0)) - mag; | ||
| 8687 | + int ndigits = strconv__dec_digits(mag); | ||
| 8688 | + if (buf->len < ndigits + 1) { | ||
| 8689 | + return -1; | ||
| 8690 | + } | ||
| 8691 | + ((u8*)buf->data)[0] = '-'; | ||
| 8692 | + strconv__write_dec_u_digits(mag, buf, 1, ndigits); | ||
| 8693 | + return ndigits + 1; | ||
| 8694 | + } | ||
| 8695 | + int ndigits = strconv__dec_digits(mag); | ||
| 8696 | + if (buf->len < ndigits) { | ||
| 8697 | + return -1; | ||
| 8698 | + } | ||
| 8699 | + strconv__write_dec_u_digits(mag, buf, 0, ndigits); | ||
| 8700 | + return ndigits; | ||
| 8701 | +} | ||
| 8702 | +int strconv__write_dec_u(u64 n, Array_u8* buf) { | ||
| 8703 | + int ndigits = strconv__dec_digits(n); | ||
| 8704 | + if (buf->len < ndigits) { | ||
| 8705 | + return -1; | ||
| 8706 | + } | ||
| 8707 | + strconv__write_dec_u_digits(n, buf, 0, ndigits); | ||
| 8708 | + return ndigits; | ||
| 8709 | +} | ||
| 8710 | +VV_LOC void strconv__write_dec_u_digits(u64 n, Array_u8* buf, int offset, int ndigits) { | ||
| 8711 | + u64 x = n; | ||
| 8712 | + int i = offset + ndigits; | ||
| 8713 | + for (;;) { | ||
| 8714 | + i--; | ||
| 8715 | + ((u8*)buf->data)[i] = (rune)(((u8)(VSAFE_MOD_u64(x , 10))) + '0'); | ||
| 8716 | + x = VSAFE_DIV_u64(x,10); | ||
| 8717 | + if (x == 0) { | ||
| 8718 | + break; | ||
| 8719 | + } | ||
| 8720 | + } | ||
| 8721 | +} | ||
| 8722 | +VNORETURN VV_LOC void builtin___memory_panic(string fname, isize size) { | ||
| 8723 | + v_memory_panic = true; | ||
| 8724 | + builtin__eprint(fname); | ||
| 8725 | + builtin__eprint(_S("(")); | ||
| 8726 | + #if 0 | ||
| 8727 | + { | ||
| 8728 | + } | ||
| 8729 | + #else | ||
| 8730 | + { | ||
| 8731 | + fprintf(stderr, "%p", ((voidptr)(size))); | ||
| 8732 | + } | ||
| 8733 | + #endif | ||
| 8734 | + if (size < 0) { | ||
| 8735 | + builtin__eprint(_S(" < 0")); | ||
| 8736 | + } | ||
| 8737 | + builtin__eprintln(_S(")")); | ||
| 8738 | + builtin___v_panic(_S("memory allocation failure")); | ||
| 8739 | + VUNREACHABLE(); | ||
| 8740 | + while(1); | ||
| 8741 | +} | ||
| 8742 | +u8* builtin___v_malloc(isize n) { | ||
| 8743 | + if (n < 0) { | ||
| 8744 | + builtin___memory_panic(_S("malloc"), n); | ||
| 8745 | + VUNREACHABLE(); | ||
| 8746 | + } else if (n == 0) { | ||
| 8747 | + return ((u8*)(((void*)0))); | ||
| 8748 | + } | ||
| 8749 | + u8* res = ((u8*)(((void*)0))); | ||
| 8750 | + #if 0 | ||
| 8751 | + { | ||
| 8752 | + } | ||
| 8753 | + #elif defined(CUSTOM_DEFINE_vgc) | ||
| 8754 | + { | ||
| 8755 | + } | ||
| 8756 | + #elif defined(CUSTOM_DEFINE_gcboehm) | ||
| 8757 | + { | ||
| 8758 | + } | ||
| 8759 | + #elif 0 | ||
| 8760 | + { | ||
| 8761 | + } | ||
| 8762 | + #else | ||
| 8763 | + { | ||
| 8764 | + #if 0 | ||
| 8765 | + { | ||
| 8766 | + } | ||
| 8767 | + #else | ||
| 8768 | + { | ||
| 8769 | + res = malloc(n); | ||
| 8770 | + } | ||
| 8771 | + #endif | ||
| 8772 | + } | ||
| 8773 | + #endif | ||
| 8774 | + if (res == 0) { | ||
| 8775 | + builtin___memory_panic(_S("malloc"), n); | ||
| 8776 | + VUNREACHABLE(); | ||
| 8777 | + } | ||
| 8778 | + ; | ||
| 8779 | + return res; | ||
| 8780 | +} | ||
| 8781 | +u8* builtin__malloc_noscan(isize n) { | ||
| 8782 | + if (n < 0) { | ||
| 8783 | + builtin___memory_panic(_S("malloc_noscan"), n); | ||
| 8784 | + VUNREACHABLE(); | ||
| 8785 | + } | ||
| 8786 | + u8* res = ((u8*)(((void*)0))); | ||
| 8787 | + #if 0 | ||
| 8788 | + { | ||
| 8789 | + } | ||
| 8790 | + #elif defined(CUSTOM_DEFINE_vgc) | ||
| 8791 | + { | ||
| 8792 | + } | ||
| 8793 | + #elif defined(CUSTOM_DEFINE_gcboehm) | ||
| 8794 | + { | ||
| 8795 | + } | ||
| 8796 | + #elif 0 | ||
| 8797 | + { | ||
| 8798 | + } | ||
| 8799 | + #else | ||
| 8800 | + { | ||
| 8801 | + #if 0 | ||
| 8802 | + { | ||
| 8803 | + } | ||
| 8804 | + #else | ||
| 8805 | + { | ||
| 8806 | + res = malloc(n); | ||
| 8807 | + } | ||
| 8808 | + #endif | ||
| 8809 | + } | ||
| 8810 | + #endif | ||
| 8811 | + if (res == 0) { | ||
| 8812 | + builtin___memory_panic(_S("malloc_noscan"), n); | ||
| 8813 | + VUNREACHABLE(); | ||
| 8814 | + } | ||
| 8815 | + ; | ||
| 8816 | + return res; | ||
| 8817 | +} | ||
| 8818 | +VV_LOC u8* builtin__malloc_uninit(isize n) { | ||
| 8819 | + if (n < 0) { | ||
| 8820 | + builtin___memory_panic(_S("malloc_uninit"), n); | ||
| 8821 | + VUNREACHABLE(); | ||
| 8822 | + } else if (n == 0) { | ||
| 8823 | + return ((u8*)(((void*)0))); | ||
| 8824 | + } | ||
| 8825 | + return builtin___v_malloc(n); | ||
| 8826 | +} | ||
| 8827 | +inline VV_LOC u64 builtin____at_least_one(u64 how_many) { | ||
| 8828 | + if (how_many == 0) { | ||
| 8829 | + return 1; | ||
| 8830 | + } | ||
| 8831 | + return how_many; | ||
| 8832 | +} | ||
| 8833 | +u8* builtin__malloc_uncollectable(isize n) { | ||
| 8834 | + if (n < 0) { | ||
| 8835 | + builtin___memory_panic(_S("malloc_uncollectable"), n); | ||
| 8836 | + VUNREACHABLE(); | ||
| 8837 | + } | ||
| 8838 | + u8* res = ((u8*)(((void*)0))); | ||
| 8839 | + #if 0 | ||
| 8840 | + { | ||
| 8841 | + } | ||
| 8842 | + #elif defined(CUSTOM_DEFINE_vgc) | ||
| 8843 | + { | ||
| 8844 | + } | ||
| 8845 | + #elif defined(CUSTOM_DEFINE_gcboehm) | ||
| 8846 | + { | ||
| 8847 | + } | ||
| 8848 | + #elif 0 | ||
| 8849 | + { | ||
| 8850 | + } | ||
| 8851 | + #else | ||
| 8852 | + { | ||
| 8853 | + #if 0 | ||
| 8854 | + { | ||
| 8855 | + } | ||
| 8856 | + #else | ||
| 8857 | + { | ||
| 8858 | + res = malloc(n); | ||
| 8859 | + } | ||
| 8860 | + #endif | ||
| 8861 | + } | ||
| 8862 | + #endif | ||
| 8863 | + if (res == 0) { | ||
| 8864 | + builtin___memory_panic(_S("malloc_uncollectable"), n); | ||
| 8865 | + VUNREACHABLE(); | ||
| 8866 | + } | ||
| 8867 | + ; | ||
| 8868 | + return res; | ||
| 8869 | +} | ||
| 8870 | +u8* builtin__v_realloc(u8* b, isize n) { | ||
| 8871 | + u8* new_ptr = ((u8*)(((void*)0))); | ||
| 8872 | + #if 0 | ||
| 8873 | + { | ||
| 8874 | + } | ||
| 8875 | + #elif defined(CUSTOM_DEFINE_vgc) | ||
| 8876 | + { | ||
| 8877 | + } | ||
| 8878 | + #elif defined(CUSTOM_DEFINE_gcboehm) | ||
| 8879 | + { | ||
| 8880 | + } | ||
| 8881 | + #else | ||
| 8882 | + { | ||
| 8883 | + #if 0 | ||
| 8884 | + { | ||
| 8885 | + } | ||
| 8886 | + #else | ||
| 8887 | + { | ||
| 8888 | + new_ptr = realloc(b, n); | ||
| 8889 | + } | ||
| 8890 | + #endif | ||
| 8891 | + } | ||
| 8892 | + #endif | ||
| 8893 | + if (new_ptr == 0) { | ||
| 8894 | + builtin___memory_panic(_S("v_realloc"), n); | ||
| 8895 | + VUNREACHABLE(); | ||
| 8896 | + } | ||
| 8897 | + if (b != ((void*)0)) { | ||
| 8898 | + ; | ||
| 8899 | + } | ||
| 8900 | + ; | ||
| 8901 | + return new_ptr; | ||
| 8902 | +} | ||
| 8903 | +u8* builtin__realloc_data(u8* old_data, int old_size, int new_size) { | ||
| 8904 | + u8* nptr = ((u8*)(((void*)0))); | ||
| 8905 | + #if defined(CUSTOM_DEFINE_vgc) | ||
| 8906 | + { | ||
| 8907 | + } | ||
| 8908 | + #elif defined(CUSTOM_DEFINE_gcboehm) | ||
| 8909 | + { | ||
| 8910 | + } | ||
| 8911 | + #else | ||
| 8912 | + { | ||
| 8913 | + #if 0 | ||
| 8914 | + { | ||
| 8915 | + } | ||
| 8916 | + #else | ||
| 8917 | + { | ||
| 8918 | + nptr = realloc(old_data, new_size); | ||
| 8919 | + } | ||
| 8920 | + #endif | ||
| 8921 | + } | ||
| 8922 | + #endif | ||
| 8923 | + if (nptr == 0) { | ||
| 8924 | + builtin___memory_panic(_S("realloc_data"), ((isize)(new_size))); | ||
| 8925 | + VUNREACHABLE(); | ||
| 8926 | + } | ||
| 8927 | + if (old_data != ((void*)0)) { | ||
| 8928 | + ; | ||
| 8929 | + } | ||
| 8930 | + ; | ||
| 8931 | + return nptr; | ||
| 8932 | +} | ||
| 8933 | +u8* builtin__vcalloc(isize n) { | ||
| 8934 | + if (n < 0) { | ||
| 8935 | + builtin___memory_panic(_S("vcalloc"), n); | ||
| 8936 | + VUNREACHABLE(); | ||
| 8937 | + } else if (n == 0) { | ||
| 8938 | + return ((u8*)(((void*)0))); | ||
| 8939 | + } | ||
| 8940 | + #if 0 | ||
| 8941 | + { | ||
| 8942 | + } | ||
| 8943 | + #elif defined(CUSTOM_DEFINE_vgc) | ||
| 8944 | + { | ||
| 8945 | + } | ||
| 8946 | + #elif defined(CUSTOM_DEFINE_gcboehm) | ||
| 8947 | + { | ||
| 8948 | + } | ||
| 8949 | + #else | ||
| 8950 | + { | ||
| 8951 | + #if 0 | ||
| 8952 | + { | ||
| 8953 | + } | ||
| 8954 | + #else | ||
| 8955 | + { | ||
| 8956 | + voidptr r = calloc(1, n); | ||
| 8957 | + ; | ||
| 8958 | + return r; | ||
| 8959 | + } | ||
| 8960 | + #endif | ||
| 8961 | + } | ||
| 8962 | + #endif | ||
| 8963 | + return ((u8*)(((void*)0))); | ||
| 8964 | +} | ||
| 8965 | +u8* builtin__vcalloc_noscan(isize n) { | ||
| 8966 | + #if 0 | ||
| 8967 | + { | ||
| 8968 | + } | ||
| 8969 | + #elif defined(CUSTOM_DEFINE_vgc) | ||
| 8970 | + { | ||
| 8971 | + } | ||
| 8972 | + #elif defined(CUSTOM_DEFINE_gcboehm) | ||
| 8973 | + { | ||
| 8974 | + } | ||
| 8975 | + #else | ||
| 8976 | + { | ||
| 8977 | + return builtin__vcalloc(n); | ||
| 8978 | + } | ||
| 8979 | + #endif | ||
| 8980 | + return ((u8*)(((void*)0))); | ||
| 8981 | +} | ||
| 8982 | +void builtin___v_free(voidptr ptr) { | ||
| 8983 | + if (ptr == 0) { | ||
| 8984 | + return; | ||
| 8985 | + } | ||
| 8986 | + IError* none_err = ((IError*)(&_const_none__)); | ||
| 8987 | + if (ptr == none_err->_object) { | ||
| 8988 | + return; | ||
| 8989 | + } | ||
| 8990 | + IError* sentinel_err = ((IError*)(&_const_error_sentinel)); | ||
| 8991 | + if (ptr == sentinel_err->_object) { | ||
| 8992 | + return; | ||
| 8993 | + } | ||
| 8994 | + #if 0 | ||
| 8995 | + { | ||
| 8996 | + } | ||
| 8997 | + #elif defined(CUSTOM_DEFINE_vgc) | ||
| 8998 | + { | ||
| 8999 | + } | ||
| 9000 | + #elif defined(CUSTOM_DEFINE_gcboehm) | ||
| 9001 | + { | ||
| 9002 | + } | ||
| 9003 | + #else | ||
| 9004 | + { | ||
| 9005 | + ; | ||
| 9006 | + #if 0 | ||
| 9007 | + { | ||
| 9008 | + } | ||
| 9009 | + #else | ||
| 9010 | + { | ||
| 9011 | + free(ptr); | ||
| 9012 | + } | ||
| 9013 | + #endif | ||
| 9014 | + } | ||
| 9015 | + #endif | ||
| 9016 | +} | ||
| 9017 | +voidptr builtin__memdup(voidptr src, isize sz) { | ||
| 9018 | + if (sz == 0) { | ||
| 9019 | + return builtin__vcalloc(1); | ||
| 9020 | + } | ||
| 9021 | + { // Unsafe block | ||
| 9022 | + u8* mem = builtin___v_malloc(sz); | ||
| 9023 | + return memcpy(mem, src, sz); | ||
| 9024 | + } | ||
| 9025 | + return 0; | ||
| 9026 | +} | ||
| 9027 | +voidptr builtin__memdup_noscan(voidptr src, isize sz) { | ||
| 9028 | + if (sz == 0) { | ||
| 9029 | + return builtin__vcalloc_noscan(1); | ||
| 9030 | + } | ||
| 9031 | + { // Unsafe block | ||
| 9032 | + u8* mem = builtin__malloc_noscan(sz); | ||
| 9033 | + return memcpy(mem, src, sz); | ||
| 9034 | + } | ||
| 9035 | + return 0; | ||
| 9036 | +} | ||
| 9037 | +voidptr builtin__memdup_uncollectable(voidptr src, isize sz) { | ||
| 9038 | + if (sz == 0) { | ||
| 9039 | + return builtin__vcalloc(1); | ||
| 9040 | + } | ||
| 9041 | + { // Unsafe block | ||
| 9042 | + u8* mem = builtin__malloc_uncollectable(sz); | ||
| 9043 | + return memcpy(mem, src, sz); | ||
| 9044 | + } | ||
| 9045 | + return 0; | ||
| 9046 | +} | ||
| 9047 | +voidptr builtin__memdup_align(voidptr src, isize sz, isize align) { | ||
| 9048 | + if (sz == 0) { | ||
| 9049 | + return builtin__vcalloc(1); | ||
| 9050 | + } | ||
| 9051 | + isize n = sz; | ||
| 9052 | + if (n < 0) { | ||
| 9053 | + builtin___memory_panic(_S("memdup_align"), n); | ||
| 9054 | + VUNREACHABLE(); | ||
| 9055 | + } | ||
| 9056 | + u8* res = ((u8*)(((void*)0))); | ||
| 9057 | + #if 0 | ||
| 9058 | + { | ||
| 9059 | + } | ||
| 9060 | + #elif defined(CUSTOM_DEFINE_gcboehm) | ||
| 9061 | + { | ||
| 9062 | + } | ||
| 9063 | + #elif 0 | ||
| 9064 | + { | ||
| 9065 | + } | ||
| 9066 | + #else | ||
| 9067 | + { | ||
| 9068 | + #if 0 | ||
| 9069 | + { | ||
| 9070 | + } | ||
| 9071 | + #else | ||
| 9072 | + { | ||
| 9073 | + res = aligned_alloc(align, n); | ||
| 9074 | + } | ||
| 9075 | + #endif | ||
| 9076 | + } | ||
| 9077 | + #endif | ||
| 9078 | + if (res == 0) { | ||
| 9079 | + builtin___memory_panic(_S("memdup_align"), n); | ||
| 9080 | + VUNREACHABLE(); | ||
| 9081 | + } | ||
| 9082 | + ; | ||
| 9083 | + return memcpy(res, src, sz); | ||
| 9084 | +} | ||
| 9085 | +GCHeapUsage builtin__gc_heap_usage(void) { | ||
| 9086 | + #if defined(CUSTOM_DEFINE_vgc) | ||
| 9087 | + { | ||
| 9088 | + } | ||
| 9089 | + #elif defined(CUSTOM_DEFINE_gcboehm) | ||
| 9090 | + { | ||
| 9091 | + } | ||
| 9092 | + #else | ||
| 9093 | + { | ||
| 9094 | + return ((GCHeapUsage){.heap_size = 0,.free_bytes = 0,.total_bytes = 0,.unmapped_bytes = 0,.bytes_since_gc = 0,}); | ||
| 9095 | + } | ||
| 9096 | + #endif | ||
| 9097 | + return (GCHeapUsage){0}; | ||
| 9098 | +} | ||
| 9099 | +usize builtin__gc_memory_use(void) { | ||
| 9100 | + #if defined(CUSTOM_DEFINE_vgc) | ||
| 9101 | + { | ||
| 9102 | + } | ||
| 9103 | + #elif defined(CUSTOM_DEFINE_gcboehm) | ||
| 9104 | + { | ||
| 9105 | + } | ||
| 9106 | + #else | ||
| 9107 | + { | ||
| 9108 | + return 0; | ||
| 9109 | + } | ||
| 9110 | + #endif | ||
| 9111 | + return 0; | ||
| 9112 | +} | ||
| 9113 | +inline VV_LOC int builtin__array_data_header_size(void) { | ||
| 9114 | + return ((int)(sizeof(voidptr))); | ||
| 9115 | +} | ||
| 9116 | +inline VV_LOC u64 builtin__array_data_allocation_size(u64 total_size) { | ||
| 9117 | + return ((u64)(builtin__array_data_header_size())) + builtin____at_least_one(total_size); | ||
| 9118 | +} | ||
| 9119 | +inline VV_LOC voidptr builtin__alloc_array_data(u64 total_size) { | ||
| 9120 | + u8* raw = builtin__vcalloc(builtin__array_data_allocation_size(total_size)); | ||
| 9121 | + return ((u8*)(raw)) + builtin__array_data_header_size(); | ||
| 9122 | +} | ||
| 9123 | +inline VV_LOC voidptr builtin__alloc_array_data_uninit(u64 total_size) { | ||
| 9124 | + u8* raw = builtin__malloc_uninit(builtin__array_data_allocation_size(total_size)); | ||
| 9125 | + { // Unsafe block | ||
| 9126 | + (((ArrayDataHeader*)(raw)))->has_slices = false; | ||
| 9127 | + return ((u8*)(raw)) + builtin__array_data_header_size(); | ||
| 9128 | + } | ||
| 9129 | + return 0; | ||
| 9130 | +} | ||
| 9131 | +inline VV_LOC bool builtin__array_uses_noscan_data(array a) { | ||
| 9132 | + return builtin__ArrayFlags_has(&a.flags, ArrayFlags__noscan_data); | ||
| 9133 | +} | ||
| 9134 | +inline VV_LOC voidptr builtin__array_alloc_array_data_like(array a, u64 total_size) { | ||
| 9135 | + return builtin__alloc_array_data(total_size); | ||
| 9136 | +} | ||
| 9137 | +inline VV_LOC voidptr builtin__array_alloc_array_data_like_uninit(array a, u64 total_size) { | ||
| 9138 | + return builtin__alloc_array_data_uninit(total_size); | ||
| 9139 | +} | ||
| 9140 | +inline VV_LOC ArrayDataHeader* builtin__array_data_header(array a) { | ||
| 9141 | + if (!builtin__ArrayFlags_has(&a.flags, ArrayFlags__managed) || a.data == ((void*)0)) { | ||
| 9142 | + return ((void*)0); | ||
| 9143 | + } | ||
| 9144 | + u8* base_data = ((u8*)(a.data)) - ((u64)(a.offset)); | ||
| 9145 | + return ((ArrayDataHeader*)(base_data - builtin__array_data_header_size())); | ||
| 9146 | +} | ||
| 9147 | +inline VV_LOC bool builtin__array_buffer_has_slices(array a) { | ||
| 9148 | + if (!builtin__ArrayFlags_has(&a.flags, ArrayFlags__managed) || a.data == ((void*)0)) { | ||
| 9149 | + return false; | ||
| 9150 | + } | ||
| 9151 | + ArrayDataHeader* header = builtin__array_data_header(a); | ||
| 9152 | + if (header == ((void*)0)) { | ||
| 9153 | + return false; | ||
| 9154 | + } | ||
| 9155 | + return header->has_slices; | ||
| 9156 | +} | ||
| 9157 | +inline VV_LOC void builtin__array_mark_buffer_has_slices(array* a) { | ||
| 9158 | + if (!builtin__ArrayFlags_has(&a->flags, ArrayFlags__managed) || a->data == ((void*)0)) { | ||
| 9159 | + return; | ||
| 9160 | + } | ||
| 9161 | + { // Unsafe block | ||
| 9162 | + u8* base_data = ((u8*)(a->data)) - ((u64)(a->offset)); | ||
| 9163 | + ArrayDataHeader* header = ((ArrayDataHeader*)(base_data - builtin__array_data_header_size())); | ||
| 9164 | + if (!header->has_slices) { | ||
| 9165 | + header->has_slices = true; | ||
| 9166 | + } | ||
| 9167 | + } | ||
| 9168 | +} | ||
| 9169 | +inline VV_LOC void builtin__array_set_managed_flags(array* a, bool is_slice) { | ||
| 9170 | + { // Unsafe block | ||
| 9171 | + builtin__ArrayFlags_set(&a->flags, ArrayFlags__managed); | ||
| 9172 | + if (is_slice) { | ||
| 9173 | + builtin__ArrayFlags_set(&a->flags, ArrayFlags__is_slice); | ||
| 9174 | + } else { | ||
| 9175 | + builtin__ArrayFlags_clear(&a->flags, ArrayFlags__is_slice); | ||
| 9176 | + } | ||
| 9177 | + } | ||
| 9178 | +} | ||
| 9179 | +inline VV_LOC void builtin__array_clone_shallow_to_cap(array* a, int new_cap) { | ||
| 9180 | + if (new_cap <= 0) { | ||
| 9181 | + builtin__ArrayFlags_clear(&a->flags, ((ArrayFlags__managed | ArrayFlags__noscan_data) | ArrayFlags__is_slice)); | ||
| 9182 | + a->data = ((void*)0); | ||
| 9183 | + a->offset = 0; | ||
| 9184 | + a->cap = 0; | ||
| 9185 | + return; | ||
| 9186 | + } | ||
| 9187 | + bool use_noscan_data = builtin__array_uses_noscan_data(*a); | ||
| 9188 | + u64 total_size = ((u64)(new_cap)) * ((u64)(a->element_size)); | ||
| 9189 | + voidptr new_data = builtin__array_alloc_array_data_like_uninit(*a, total_size); | ||
| 9190 | + u64 copy_size = ((u64)(a->len)) * ((u64)(a->element_size)); | ||
| 9191 | + if (a->data != ((void*)0) && copy_size > 0) { | ||
| 9192 | + builtin__vmemcpy(new_data, a->data, copy_size); | ||
| 9193 | + } | ||
| 9194 | + a->data = new_data; | ||
| 9195 | + a->offset = 0; | ||
| 9196 | + a->cap = new_cap; | ||
| 9197 | + { // Unsafe block | ||
| 9198 | + if (use_noscan_data) { | ||
| 9199 | + builtin__ArrayFlags_set(&a->flags, ArrayFlags__noscan_data); | ||
| 9200 | + } else { | ||
| 9201 | + builtin__ArrayFlags_clear(&a->flags, ArrayFlags__noscan_data); | ||
| 9202 | + } | ||
| 9203 | + } | ||
| 9204 | + builtin__array_set_managed_flags(a, false); | ||
| 9205 | +} | ||
| 9206 | +inline VV_LOC int builtin__v_ni_index(int i, int len) { | ||
| 9207 | + return (i < 0 ? (len + i) : (i)); | ||
| 9208 | +} | ||
| 9209 | +VV_LOC array builtin____new_array(int mylen, int cap, int elm_size) { | ||
| 9210 | + builtin__panic_on_negative_len(mylen); | ||
| 9211 | + builtin__panic_on_negative_cap(cap); | ||
| 9212 | + int cap_ = (cap < mylen ? (mylen) : (cap)); | ||
| 9213 | + u64 total_size = ((u64)(cap_)) * ((u64)(elm_size)); | ||
| 9214 | + voidptr data = ((void*)0); | ||
| 9215 | + if (cap_ > 0 && mylen == 0) { | ||
| 9216 | + data = builtin__alloc_array_data_uninit(total_size); | ||
| 9217 | + } else if (cap_ > 0) { | ||
| 9218 | + data = builtin__alloc_array_data(total_size); | ||
| 9219 | + } | ||
| 9220 | + array _t1 = ((array){.data = (voidptr)data,.offset = 0,.len = mylen,.cap = cap_,.flags = ArrayFlags__managed,.element_size = elm_size,}); | ||
| 9221 | + array arr = _t1; | ||
| 9222 | + return arr; | ||
| 9223 | +} | ||
| 9224 | +VV_LOC array builtin____new_array_with_default(int mylen, int cap, int elm_size, voidptr val) { | ||
| 9225 | + builtin__panic_on_negative_len(mylen); | ||
| 9226 | + builtin__panic_on_negative_cap(cap); | ||
| 9227 | + int cap_ = (cap < mylen ? (mylen) : (cap)); | ||
| 9228 | + array _t1 = ((array){.data = 0,.offset = 0,.len = mylen,.cap = cap_,.flags = ArrayFlags__managed,.element_size = elm_size,}); | ||
| 9229 | + array arr = _t1; | ||
| 9230 | + u64 total_size = ((u64)(cap_)) * ((u64)(elm_size)); | ||
| 9231 | + if (cap_ > 0 && mylen == 0) { | ||
| 9232 | + arr.data = builtin__alloc_array_data_uninit(total_size); | ||
| 9233 | + } else if (cap_ > 0) { | ||
| 9234 | + arr.data = builtin__alloc_array_data(total_size); | ||
| 9235 | + } | ||
| 9236 | + if (val != 0) { | ||
| 9237 | + u8* eptr = ((u8*)(arr.data)); | ||
| 9238 | + { // Unsafe block | ||
| 9239 | + if (eptr != ((void*)0)) { | ||
| 9240 | + if (arr.element_size == 1) { | ||
| 9241 | + u8 byte_value = *(((u8*)(val))); | ||
| 9242 | + for (int i = 0; i < arr.len; ++i) { | ||
| 9243 | + eptr[i] = byte_value; | ||
| 9244 | + } | ||
| 9245 | + } else { | ||
| 9246 | + for (int _t2 = 0; _t2 < arr.len; ++_t2) { | ||
| 9247 | + builtin__vmemcpy(eptr, val, arr.element_size); | ||
| 9248 | + eptr += arr.element_size; | ||
| 9249 | + } | ||
| 9250 | + } | ||
| 9251 | + } | ||
| 9252 | + } | ||
| 9253 | + } | ||
| 9254 | + return arr; | ||
| 9255 | +} | ||
| 9256 | +VV_LOC array builtin____new_array_with_multi_default(int mylen, int cap, int elm_size, voidptr val) { | ||
| 9257 | + builtin__panic_on_negative_len(mylen); | ||
| 9258 | + builtin__panic_on_negative_cap(cap); | ||
| 9259 | + int cap_ = (cap < mylen ? (mylen) : (cap)); | ||
| 9260 | + array _t1 = ((array){.data = 0,.offset = 0,.len = mylen,.cap = cap_,.flags = ArrayFlags__managed,.element_size = elm_size,}); | ||
| 9261 | + array arr = _t1; | ||
| 9262 | + u64 total_size = ((u64)(cap_)) * ((u64)(elm_size)); | ||
| 9263 | + if (cap_ > 0) { | ||
| 9264 | + arr.data = builtin__alloc_array_data(total_size); | ||
| 9265 | + } | ||
| 9266 | + if (val != 0) { | ||
| 9267 | + u8* eptr = ((u8*)(arr.data)); | ||
| 9268 | + { // Unsafe block | ||
| 9269 | + if (eptr != ((void*)0)) { | ||
| 9270 | + for (int i = 0; i < arr.len; ++i) { | ||
| 9271 | + builtin__vmemcpy(eptr, ((charptr)(val)) + (int)(i * arr.element_size), arr.element_size); | ||
| 9272 | + eptr += arr.element_size; | ||
| 9273 | + } | ||
| 9274 | + } | ||
| 9275 | + } | ||
| 9276 | + } | ||
| 9277 | + return arr; | ||
| 9278 | +} | ||
| 9279 | +VV_LOC array builtin____new_array_with_array_default(int mylen, int cap, int elm_size, array val, int depth) { | ||
| 9280 | + builtin__panic_on_negative_len(mylen); | ||
| 9281 | + builtin__panic_on_negative_cap(cap); | ||
| 9282 | + int cap_ = (cap < mylen ? (mylen) : (cap)); | ||
| 9283 | + array _t1 = ((array){.data = 0,.offset = 0,.len = mylen,.cap = cap_,.flags = ArrayFlags__managed,.element_size = elm_size,}); | ||
| 9284 | + array arr = _t1; | ||
| 9285 | + if (cap_ > 0) { | ||
| 9286 | + arr.data = builtin__alloc_array_data(((u64)(cap_)) * ((u64)(elm_size))); | ||
| 9287 | + } | ||
| 9288 | + u8* eptr = ((u8*)(arr.data)); | ||
| 9289 | + { // Unsafe block | ||
| 9290 | + if (eptr != ((void*)0)) { | ||
| 9291 | + for (int _t2 = 0; _t2 < arr.len; ++_t2) { | ||
| 9292 | + array val_clone = builtin__array_clone_to_depth(&val, depth); | ||
| 9293 | + builtin__vmemcpy(eptr, &val_clone, arr.element_size); | ||
| 9294 | + eptr += arr.element_size; | ||
| 9295 | + } | ||
| 9296 | + } | ||
| 9297 | + } | ||
| 9298 | + return arr; | ||
| 9299 | +} | ||
| 9300 | +VV_LOC array builtin__new_array_from_c_array(int len, int cap, int elm_size, voidptr c_array) { | ||
| 9301 | + builtin__panic_on_negative_len(len); | ||
| 9302 | + builtin__panic_on_negative_cap(cap); | ||
| 9303 | + int cap_ = cap; | ||
| 9304 | + if (cap < len) { | ||
| 9305 | + cap_ = len; | ||
| 9306 | + } | ||
| 9307 | + array _t1 = ((array){.data = builtin__alloc_array_data(((u64)(cap_)) * ((u64)(elm_size))),.offset = 0,.len = len,.cap = cap_,.flags = ArrayFlags__managed,.element_size = elm_size,}); | ||
| 9308 | + array arr = _t1; | ||
| 9309 | + builtin__vmemcpy(arr.data, c_array, ((u64)(len)) * ((u64)(elm_size))); | ||
| 9310 | + return arr; | ||
| 9311 | +} | ||
| 9312 | +void builtin__array_ensure_cap(array* a, int required) { | ||
| 9313 | + if (required <= a->cap) { | ||
| 9314 | + return; | ||
| 9315 | + } | ||
| 9316 | + if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__nogrow)) { | ||
| 9317 | + builtin__panic_n(_S("array.ensure_cap: array with the flag `.nogrow` cannot grow in size, array required new size:"), required); | ||
| 9318 | + VUNREACHABLE(); | ||
| 9319 | + } | ||
| 9320 | + i64 cap = (a->cap > 0 ? (((i64)(a->cap))) : (((i64)(2)))); | ||
| 9321 | + for (;;) { | ||
| 9322 | + if (!(required > cap)) break; | ||
| 9323 | + cap *= 2; | ||
| 9324 | + } | ||
| 9325 | + if (cap > _const_max_int) { | ||
| 9326 | + if (a->cap < _const_max_int) { | ||
| 9327 | + cap = _const_max_int; | ||
| 9328 | + } else { | ||
| 9329 | + builtin__panic_n(_S("array.ensure_cap: array needs to grow to cap (which is > 2^31):"), cap); | ||
| 9330 | + VUNREACHABLE(); | ||
| 9331 | + } | ||
| 9332 | + } | ||
| 9333 | + u64 new_size = ((u64)(cap)) * ((u64)(a->element_size)); | ||
| 9334 | + bool use_noscan_data = builtin__array_uses_noscan_data(*a); | ||
| 9335 | + voidptr new_data = builtin__array_alloc_array_data_like_uninit(*a, new_size); | ||
| 9336 | + if (a->data != ((void*)0)) { | ||
| 9337 | + builtin__vmemcpy(new_data, a->data, ((u64)(a->len)) * ((u64)(a->element_size))); | ||
| 9338 | + if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__noslices) && !builtin__ArrayFlags_has(&a->flags, ArrayFlags__is_slice) && !builtin__array_buffer_has_slices(*a)) { | ||
| 9339 | + { // Unsafe block | ||
| 9340 | + if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__managed)) { | ||
| 9341 | + builtin___v_free(((u8*)(a->data)) - ((u64)(builtin__array_data_header_size()))); | ||
| 9342 | + } else { | ||
| 9343 | + builtin___v_free(a->data); | ||
| 9344 | + } | ||
| 9345 | + } | ||
| 9346 | + } | ||
| 9347 | + } | ||
| 9348 | + a->data = new_data; | ||
| 9349 | + a->offset = 0; | ||
| 9350 | + a->cap = ((int)(cap)); | ||
| 9351 | + { // Unsafe block | ||
| 9352 | + if (use_noscan_data) { | ||
| 9353 | + builtin__ArrayFlags_set(&a->flags, ArrayFlags__noscan_data); | ||
| 9354 | + } else { | ||
| 9355 | + builtin__ArrayFlags_clear(&a->flags, ArrayFlags__noscan_data); | ||
| 9356 | + } | ||
| 9357 | + } | ||
| 9358 | + builtin__array_set_managed_flags(a, false); | ||
| 9359 | +} | ||
| 9360 | +array builtin__array_repeat(array a, int count) { | ||
| 9361 | + return builtin__array_repeat_to_depth(a, count, 0); | ||
| 9362 | +} | ||
| 9363 | +array builtin__array_repeat_to_depth(array a, int count, int depth) { | ||
| 9364 | + if (count < 0) { | ||
| 9365 | + builtin__panic_n(_S("array.repeat: count is negative:"), count); | ||
| 9366 | + VUNREACHABLE(); | ||
| 9367 | + } | ||
| 9368 | + u64 size = ((u64)(count)) * ((u64)(a.len)) * ((u64)(a.element_size)); | ||
| 9369 | + if (size == 0) { | ||
| 9370 | + size = ((u64)(a.element_size)); | ||
| 9371 | + } | ||
| 9372 | + bool use_noscan_data = depth == 0 && builtin__array_uses_noscan_data(a); | ||
| 9373 | + voidptr data = ((void*)0); | ||
| 9374 | + if (use_noscan_data) { | ||
| 9375 | + data = builtin__array_alloc_array_data_like(a, size); | ||
| 9376 | + } else { | ||
| 9377 | + data = builtin__alloc_array_data(size); | ||
| 9378 | + } | ||
| 9379 | + array _t1 = ((array){.data = (voidptr)data,.offset = 0,.len = count * a.len,.cap = count * a.len,.flags = (use_noscan_data ? ((ArrayFlags__managed | ArrayFlags__noscan_data)) : (ArrayFlags__managed)),.element_size = a.element_size,}); | ||
| 9380 | + array arr = _t1; | ||
| 9381 | + if (a.len > 0) { | ||
| 9382 | + u64 a_total_size = ((u64)(a.len)) * ((u64)(a.element_size)); | ||
| 9383 | + u64 arr_step_size = ((u64)(a.len)) * ((u64)(arr.element_size)); | ||
| 9384 | + u8* eptr = ((u8*)(arr.data)); | ||
| 9385 | + { // Unsafe block | ||
| 9386 | + if (eptr != ((void*)0)) { | ||
| 9387 | + for (int _t2 = 0; _t2 < count; ++_t2) { | ||
| 9388 | + if (depth > 0) { | ||
| 9389 | + array ary_clone = builtin__array_clone_to_depth(&a, depth); | ||
| 9390 | + builtin__vmemcpy(eptr, ary_clone.data, a_total_size); | ||
| 9391 | + } else { | ||
| 9392 | + builtin__vmemcpy(eptr, a.data, a_total_size); | ||
| 9393 | + } | ||
| 9394 | + eptr += arr_step_size; | ||
| 9395 | + } | ||
| 9396 | + } | ||
| 9397 | + } | ||
| 9398 | + } | ||
| 9399 | + return arr; | ||
| 9400 | +} | ||
| 9401 | +inline VV_LOC bool builtin__array_needs_unique_shift(array a, int required) { | ||
| 9402 | + return required <= a.cap && (builtin__ArrayFlags_has(&a.flags, ArrayFlags__is_slice) || builtin__array_buffer_has_slices(a)); | ||
| 9403 | +} | ||
| 9404 | +inline VV_LOC bool builtin__array_needs_unique_append(array a, int required) { | ||
| 9405 | + return required <= a.cap && builtin__ArrayFlags_has(&a.flags, ArrayFlags__is_slice); | ||
| 9406 | +} | ||
| 9407 | +inline VV_LOC bool builtin__array_needs_unique_shrink(array a) { | ||
| 9408 | + return builtin__ArrayFlags_has(&a.flags, ArrayFlags__is_slice) || builtin__array_buffer_has_slices(a); | ||
| 9409 | +} | ||
| 9410 | +void builtin__array_insert(array* a, int i, voidptr val) { | ||
| 9411 | + if (i < 0 || i > a->len) { | ||
| 9412 | + builtin__panic_n2(_S("array.insert: index out of range (i,a.len):"), i, a->len); | ||
| 9413 | + VUNREACHABLE(); | ||
| 9414 | + } | ||
| 9415 | + if (a->len == _const_max_int) { | ||
| 9416 | + builtin___v_panic(_S("array.insert: a.len reached max_int")); | ||
| 9417 | + VUNREACHABLE(); | ||
| 9418 | + } | ||
| 9419 | + int required = a->len + 1; | ||
| 9420 | + if (builtin__array_needs_unique_shift(*a, required)) { | ||
| 9421 | + builtin__array_clone_shallow_to_cap(a, a->cap); | ||
| 9422 | + } else if (required > a->cap) { | ||
| 9423 | + builtin__array_ensure_cap(a, required); | ||
| 9424 | + } | ||
| 9425 | + { // Unsafe block | ||
| 9426 | + builtin__vmemmove(builtin__array_get_unsafe(*a, i + 1), builtin__array_get_unsafe(*a, i), ((u64)((a->len - i))) * ((u64)(a->element_size))); | ||
| 9427 | + builtin__array_set_unsafe(a, i, val); | ||
| 9428 | + } | ||
| 9429 | + a->len++; | ||
| 9430 | +} | ||
| 9431 | +void builtin__array_prepend(array* a, voidptr val) { | ||
| 9432 | + builtin__array_insert(a, 0, val); | ||
| 9433 | +} | ||
| 9434 | +void builtin__array_delete(array* a, int i) { | ||
| 9435 | + if (i < 0 || i >= a->len) { | ||
| 9436 | + builtin__panic_n2(_S("array.delete: index out of range (i,a.len):"), i, a->len); | ||
| 9437 | + VUNREACHABLE(); | ||
| 9438 | + } | ||
| 9439 | + if (i == a->len - 1 && !builtin__array_needs_unique_shrink(*a)) { | ||
| 9440 | + a->len--; | ||
| 9441 | + builtin__vmemset(((u8*)(a->data)) + ((u64)(a->len)) * ((u64)(a->element_size)), 0, ((u64)(a->element_size))); | ||
| 9442 | + return; | ||
| 9443 | + } | ||
| 9444 | + builtin__array_delete_many(a, i, 1); | ||
| 9445 | +} | ||
| 9446 | +void builtin__array_delete_many(array* a, int i, int size) { | ||
| 9447 | + if (i < 0 || ((i64)(i)) + ((i64)(size)) > ((i64)(a->len))) { | ||
| 9448 | + if (size > 1) { | ||
| 9449 | + builtin__panic_n3(_S("array.delete: index out of range (i,i+size,a.len):"), i, i + size, a->len); | ||
| 9450 | + VUNREACHABLE(); | ||
| 9451 | + } else { | ||
| 9452 | + builtin__panic_n2(_S("array.delete: index out of range (i,a.len):"), i, a->len); | ||
| 9453 | + VUNREACHABLE(); | ||
| 9454 | + } | ||
| 9455 | + } | ||
| 9456 | + if (size == 0) { | ||
| 9457 | + if (builtin__array_needs_unique_shrink(*a)) { | ||
| 9458 | + builtin__array_clone_shallow_to_cap(a, a->len); | ||
| 9459 | + } | ||
| 9460 | + return; | ||
| 9461 | + } | ||
| 9462 | + if (!builtin__array_needs_unique_shrink(*a)) { | ||
| 9463 | + int new_len = a->len - size; | ||
| 9464 | + { // Unsafe block | ||
| 9465 | + builtin__vmemmove(((u8*)(a->data)) + ((u64)(i)) * ((u64)(a->element_size)), ((u8*)(a->data)) + ((u64)(i + size)) * ((u64)(a->element_size)), ((u64)(a->len - i - size)) * ((u64)(a->element_size))); | ||
| 9466 | + builtin__vmemset(((u8*)(a->data)) + ((u64)(new_len)) * ((u64)(a->element_size)), 0, ((u64)(size)) * ((u64)(a->element_size))); | ||
| 9467 | + } | ||
| 9468 | + a->len = new_len; | ||
| 9469 | + return; | ||
| 9470 | + } | ||
| 9471 | + voidptr old_data = a->data; | ||
| 9472 | + int new_size = a->len - size; | ||
| 9473 | + if (new_size == 0) { | ||
| 9474 | + builtin__ArrayFlags_clear(&a->flags, ((ArrayFlags__managed | ArrayFlags__noscan_data) | ArrayFlags__is_slice)); | ||
| 9475 | + a->data = ((void*)0); | ||
| 9476 | + a->offset = 0; | ||
| 9477 | + a->len = 0; | ||
| 9478 | + a->cap = 0; | ||
| 9479 | + return; | ||
| 9480 | + } | ||
| 9481 | + int new_cap = new_size; | ||
| 9482 | + bool use_noscan_data = builtin__array_uses_noscan_data(*a); | ||
| 9483 | + a->data = builtin__array_alloc_array_data_like(*a, ((u64)(new_cap)) * ((u64)(a->element_size))); | ||
| 9484 | + builtin__vmemcpy(a->data, old_data, ((u64)(i)) * ((u64)(a->element_size))); | ||
| 9485 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(i)) * ((u64)(a->element_size)), ((u8*)(old_data)) + ((u64)(i + size)) * ((u64)(a->element_size)), ((u64)(a->len - i - size)) * ((u64)(a->element_size))); | ||
| 9486 | + if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__noslices) && !builtin__ArrayFlags_has(&a->flags, ArrayFlags__managed)) { | ||
| 9487 | + builtin___v_free(old_data); | ||
| 9488 | + } | ||
| 9489 | + a->len = new_size; | ||
| 9490 | + a->cap = new_cap; | ||
| 9491 | + a->offset = 0; | ||
| 9492 | + { // Unsafe block | ||
| 9493 | + if (use_noscan_data) { | ||
| 9494 | + builtin__ArrayFlags_set(&a->flags, ArrayFlags__noscan_data); | ||
| 9495 | + } else { | ||
| 9496 | + builtin__ArrayFlags_clear(&a->flags, ArrayFlags__noscan_data); | ||
| 9497 | + } | ||
| 9498 | + } | ||
| 9499 | + builtin__array_set_managed_flags(a, false); | ||
| 9500 | +} | ||
| 9501 | +void builtin__array_clear(array* a) { | ||
| 9502 | + if (builtin__array_needs_unique_shrink(*a)) { | ||
| 9503 | + builtin__ArrayFlags_clear(&a->flags, ((ArrayFlags__managed | ArrayFlags__noscan_data) | ArrayFlags__is_slice)); | ||
| 9504 | + a->data = ((void*)0); | ||
| 9505 | + a->offset = 0; | ||
| 9506 | + a->cap = 0; | ||
| 9507 | + } | ||
| 9508 | + a->len = 0; | ||
| 9509 | +} | ||
| 9510 | +void builtin__array_reset(array* a) { | ||
| 9511 | + builtin__vmemset(a->data, 0, a->len * a->element_size); | ||
| 9512 | +} | ||
| 9513 | +void builtin__array_trim(array* a, int index) { | ||
| 9514 | + if (index < a->len) { | ||
| 9515 | + if (index >= 0 && builtin__array_needs_unique_shrink(*a)) { | ||
| 9516 | + builtin__array_delete_many(a, index, a->len - index); | ||
| 9517 | + return; | ||
| 9518 | + } | ||
| 9519 | + a->len = index; | ||
| 9520 | + } | ||
| 9521 | +} | ||
| 9522 | +void builtin__array_drop(array* a, int num) { | ||
| 9523 | + if (num <= 0) { | ||
| 9524 | + return; | ||
| 9525 | + } | ||
| 9526 | + int n = (num <= a->len ? (num) : (a->len)); | ||
| 9527 | + u64 blen = ((u64)(n)) * ((u64)(a->element_size)); | ||
| 9528 | + a->data = ((u8*)(a->data)) + blen; | ||
| 9529 | + a->offset += ((int)(blen)); | ||
| 9530 | + a->len -= n; | ||
| 9531 | + a->cap -= n; | ||
| 9532 | +} | ||
| 9533 | +inline VV_LOC voidptr builtin__array_get_unsafe(array a, int i) { | ||
| 9534 | + { // Unsafe block | ||
| 9535 | + return ((u8*)(a.data)) + ((u64)(i)) * ((u64)(a.element_size)); | ||
| 9536 | + } | ||
| 9537 | + return 0; | ||
| 9538 | +} | ||
| 9539 | +VV_LOC voidptr builtin__array_get(array a, int i) { | ||
| 9540 | + #if 1 | ||
| 9541 | + { | ||
| 9542 | + if (i < 0 || i >= a.len) { | ||
| 9543 | + builtin__panic_n2(_S("array.get: index out of range (i,a.len):"), i, a.len); | ||
| 9544 | + VUNREACHABLE(); | ||
| 9545 | + } | ||
| 9546 | + } | ||
| 9547 | + #endif | ||
| 9548 | + { // Unsafe block | ||
| 9549 | + return ((u8*)(a.data)) + ((u64)(i)) * ((u64)(a.element_size)); | ||
| 9550 | + } | ||
| 9551 | + return 0; | ||
| 9552 | +} | ||
| 9553 | +VV_LOC voidptr builtin__array_get_i64(array a, i64 i) { | ||
| 9554 | + #if 1 | ||
| 9555 | + { | ||
| 9556 | + if (i < 0 || i >= ((i64)(a.len))) { | ||
| 9557 | + builtin__panic_n2(_S("array.get: index out of range (i,a.len):"), i, a.len); | ||
| 9558 | + VUNREACHABLE(); | ||
| 9559 | + } | ||
| 9560 | + } | ||
| 9561 | + #endif | ||
| 9562 | + { // Unsafe block | ||
| 9563 | + return ((u8*)(a.data)) + ((u64)(i)) * ((u64)(a.element_size)); | ||
| 9564 | + } | ||
| 9565 | + return 0; | ||
| 9566 | +} | ||
| 9567 | +VV_LOC voidptr builtin__array_get_u64(array a, u64 i) { | ||
| 9568 | + #if 1 | ||
| 9569 | + { | ||
| 9570 | + if (i >= ((u64)(a.len))) { | ||
| 9571 | + builtin___v_panic(builtin__string_plus_many(4, _MOV((string[4]){_S("array.get: index out of range (i,a.len): "), builtin__u64_str(i), _S(", "), builtin__impl_i64_to_string(a.len)}))); | ||
| 9572 | + VUNREACHABLE(); | ||
| 9573 | + } | ||
| 9574 | + } | ||
| 9575 | + #endif | ||
| 9576 | + { // Unsafe block | ||
| 9577 | + return ((u8*)(a.data)) + i * ((u64)(a.element_size)); | ||
| 9578 | + } | ||
| 9579 | + return 0; | ||
| 9580 | +} | ||
| 9581 | +VV_LOC voidptr builtin__array_get_ni(array a, int i) { | ||
| 9582 | + return builtin__array_get(a, builtin__v_ni_index(i, a.len)); | ||
| 9583 | +} | ||
| 9584 | +VV_LOC voidptr builtin__array_get_with_check(array a, int i) { | ||
| 9585 | + if (i < 0 || i >= a.len) { | ||
| 9586 | + return 0; | ||
| 9587 | + } | ||
| 9588 | + { // Unsafe block | ||
| 9589 | + return ((u8*)(a.data)) + ((u64)(i)) * ((u64)(a.element_size)); | ||
| 9590 | + } | ||
| 9591 | + return 0; | ||
| 9592 | +} | ||
| 9593 | +VV_LOC voidptr builtin__array_get_with_check_i64(array a, i64 i) { | ||
| 9594 | + if (i < 0 || i >= ((i64)(a.len))) { | ||
| 9595 | + return 0; | ||
| 9596 | + } | ||
| 9597 | + { // Unsafe block | ||
| 9598 | + return ((u8*)(a.data)) + ((u64)(i)) * ((u64)(a.element_size)); | ||
| 9599 | + } | ||
| 9600 | + return 0; | ||
| 9601 | +} | ||
| 9602 | +VV_LOC voidptr builtin__array_get_with_check_u64(array a, u64 i) { | ||
| 9603 | + if (i >= ((u64)(a.len))) { | ||
| 9604 | + return 0; | ||
| 9605 | + } | ||
| 9606 | + { // Unsafe block | ||
| 9607 | + return ((u8*)(a.data)) + i * ((u64)(a.element_size)); | ||
| 9608 | + } | ||
| 9609 | + return 0; | ||
| 9610 | +} | ||
| 9611 | +VV_LOC voidptr builtin__array_get_with_check_ni(array a, int i) { | ||
| 9612 | + return builtin__array_get_with_check(a, builtin__v_ni_index(i, a.len)); | ||
| 9613 | +} | ||
| 9614 | +voidptr builtin__array_first(array a) { | ||
| 9615 | + if (a.len == 0) { | ||
| 9616 | + builtin___v_panic(_S("array.first: array is empty")); | ||
| 9617 | + VUNREACHABLE(); | ||
| 9618 | + } | ||
| 9619 | + return a.data; | ||
| 9620 | +} | ||
| 9621 | +voidptr builtin__array_last(array a) { | ||
| 9622 | + if (a.len == 0) { | ||
| 9623 | + builtin___v_panic(_S("array.last: array is empty")); | ||
| 9624 | + VUNREACHABLE(); | ||
| 9625 | + } | ||
| 9626 | + { // Unsafe block | ||
| 9627 | + return ((u8*)(a.data)) + ((u64)(a.len - 1)) * ((u64)(a.element_size)); | ||
| 9628 | + } | ||
| 9629 | + return 0; | ||
| 9630 | +} | ||
| 9631 | +voidptr builtin__array_pop_left(array* a) { | ||
| 9632 | + if (a->len == 0) { | ||
| 9633 | + builtin___v_panic(_S("array.pop_left: array is empty")); | ||
| 9634 | + VUNREACHABLE(); | ||
| 9635 | + } | ||
| 9636 | + voidptr first_elem = a->data; | ||
| 9637 | + { // Unsafe block | ||
| 9638 | + a->data = ((u8*)(a->data)) + ((u64)(a->element_size)); | ||
| 9639 | + } | ||
| 9640 | + a->offset += a->element_size; | ||
| 9641 | + a->len--; | ||
| 9642 | + a->cap--; | ||
| 9643 | + return first_elem; | ||
| 9644 | +} | ||
| 9645 | +voidptr builtin__array_pop(array* a) { | ||
| 9646 | + if (a->len == 0) { | ||
| 9647 | + builtin___v_panic(_S("array.pop: array is empty")); | ||
| 9648 | + VUNREACHABLE(); | ||
| 9649 | + } | ||
| 9650 | + int new_len = a->len - 1; | ||
| 9651 | + u8* last_elem = ((u8*)(a->data)) + ((u64)(new_len)) * ((u64)(a->element_size)); | ||
| 9652 | + if (builtin__array_needs_unique_shrink(*a)) { | ||
| 9653 | + builtin__array_delete_many(a, new_len, 1); | ||
| 9654 | + return last_elem; | ||
| 9655 | + } | ||
| 9656 | + a->len = new_len; | ||
| 9657 | + return last_elem; | ||
| 9658 | +} | ||
| 9659 | +void builtin__array_delete_last(array* a) { | ||
| 9660 | + if (a->len == 0) { | ||
| 9661 | + builtin___v_panic(_S("array.delete_last: array is empty")); | ||
| 9662 | + VUNREACHABLE(); | ||
| 9663 | + } | ||
| 9664 | + if (builtin__array_needs_unique_shrink(*a)) { | ||
| 9665 | + builtin__array_delete_many(a, a->len - 1, 1); | ||
| 9666 | + return; | ||
| 9667 | + } | ||
| 9668 | + a->len--; | ||
| 9669 | + builtin__vmemset(((u8*)(a->data)) + ((u64)(a->len)) * ((u64)(a->element_size)), 0, ((u64)(a->element_size))); | ||
| 9670 | +} | ||
| 9671 | +VV_LOC array builtin__array_slice(array a, int start, int _end) { | ||
| 9672 | + int end = (_end == _const_max_i64 || _end == _const_max_i32 ? (a.len) : (_end)); | ||
| 9673 | + #if 1 | ||
| 9674 | + { | ||
| 9675 | + if (start > end) { | ||
| 9676 | + builtin___v_panic(builtin__string_plus_many(4, _MOV((string[4]){_S("array.slice: invalid slice index (start>end):"), builtin__impl_i64_to_string(((i64)(start))), _S(", "), builtin__impl_i64_to_string(end)}))); | ||
| 9677 | + VUNREACHABLE(); | ||
| 9678 | + } | ||
| 9679 | + if (end > a.len) { | ||
| 9680 | + builtin___v_panic(builtin__string_plus_many(5, _MOV((string[5]){_S("array.slice: slice bounds out of range ("), builtin__impl_i64_to_string(end), _S(" >= "), builtin__impl_i64_to_string(a.len), _S(")")}))); | ||
| 9681 | + VUNREACHABLE(); | ||
| 9682 | + } | ||
| 9683 | + if (start < 0) { | ||
| 9684 | + builtin___v_panic(builtin__string__plus(_S("array.slice: slice bounds out of range (start<0):"), builtin__impl_i64_to_string(start))); | ||
| 9685 | + VUNREACHABLE(); | ||
| 9686 | + } | ||
| 9687 | + } | ||
| 9688 | + #endif | ||
| 9689 | + builtin__array_mark_buffer_has_slices(&a); | ||
| 9690 | + u64 offset = ((u64)(start)) * ((u64)(a.element_size)); | ||
| 9691 | + u8* data = ((u8*)(a.data)) + offset; | ||
| 9692 | + int l = end - start; | ||
| 9693 | + ArrayFlags flags = ArrayFlags__is_slice; | ||
| 9694 | + if (builtin__array_uses_noscan_data(a)) { | ||
| 9695 | + builtin__ArrayFlags_set(&flags, ArrayFlags__noscan_data); | ||
| 9696 | + } | ||
| 9697 | + array res = ((array){ | ||
| 9698 | + .data = (voidptr)data, | ||
| 9699 | + .offset = a.offset + ((int)(offset)), | ||
| 9700 | + .len = l, | ||
| 9701 | + .cap = l, | ||
| 9702 | + .flags = flags, | ||
| 9703 | + .element_size = a.element_size, | ||
| 9704 | + }); | ||
| 9705 | + return res; | ||
| 9706 | +} | ||
| 9707 | +VV_LOC array builtin__array_slice_ni(array a, int _start, int _end) { | ||
| 9708 | + builtin__array_mark_buffer_has_slices(&a); | ||
| 9709 | + ArrayFlags flags = ArrayFlags__is_slice; | ||
| 9710 | + if (builtin__array_uses_noscan_data(a)) { | ||
| 9711 | + builtin__ArrayFlags_set(&flags, ArrayFlags__noscan_data); | ||
| 9712 | + } | ||
| 9713 | + int end = (_end == _const_max_i64 || _end == _const_max_i32 ? (a.len) : (_end)); | ||
| 9714 | + int start = _start; | ||
| 9715 | + if (start < 0) { | ||
| 9716 | + start = a.len + start; | ||
| 9717 | + if (start < 0) { | ||
| 9718 | + start = 0; | ||
| 9719 | + } | ||
| 9720 | + } | ||
| 9721 | + if (end < 0) { | ||
| 9722 | + end = a.len + end; | ||
| 9723 | + if (end < 0) { | ||
| 9724 | + end = 0; | ||
| 9725 | + } | ||
| 9726 | + } | ||
| 9727 | + if (end >= a.len) { | ||
| 9728 | + end = a.len; | ||
| 9729 | + } | ||
| 9730 | + if (start >= a.len || start > end) { | ||
| 9731 | + array res = ((array){ | ||
| 9732 | + .data = a.data, | ||
| 9733 | + .offset = 0, | ||
| 9734 | + .len = 0, | ||
| 9735 | + .cap = 0, | ||
| 9736 | + .flags = flags, | ||
| 9737 | + .element_size = a.element_size, | ||
| 9738 | + }); | ||
| 9739 | + return res; | ||
| 9740 | + } | ||
| 9741 | + u64 offset = ((u64)(start)) * ((u64)(a.element_size)); | ||
| 9742 | + u8* data = ((u8*)(a.data)) + offset; | ||
| 9743 | + int l = end - start; | ||
| 9744 | + array res = ((array){ | ||
| 9745 | + .data = (voidptr)data, | ||
| 9746 | + .offset = a.offset + ((int)(offset)), | ||
| 9747 | + .len = l, | ||
| 9748 | + .cap = l, | ||
| 9749 | + .flags = flags, | ||
| 9750 | + .element_size = a.element_size, | ||
| 9751 | + }); | ||
| 9752 | + return res; | ||
| 9753 | +} | ||
| 9754 | +VV_LOC array builtin__array_clone_static_to_depth(array a, int depth) { | ||
| 9755 | + return builtin__array_clone_to_depth(&a, depth); | ||
| 9756 | +} | ||
| 9757 | +array builtin__array_clone(array* a) { | ||
| 9758 | + return builtin__array_clone_to_depth(a, 0); | ||
| 9759 | +} | ||
| 9760 | +array builtin__array_clone_to_depth(array* a, int depth) { | ||
| 9761 | + u64 source_capacity_in_bytes = ((u64)(a->cap)) * ((u64)(a->element_size)); | ||
| 9762 | + bool use_noscan_data = depth == 0 && builtin__array_uses_noscan_data(*a); | ||
| 9763 | + voidptr data = ((void*)0); | ||
| 9764 | + if (a->cap > 0) { | ||
| 9765 | + if (use_noscan_data) { | ||
| 9766 | + data = builtin__array_alloc_array_data_like(*a, source_capacity_in_bytes); | ||
| 9767 | + } else { | ||
| 9768 | + data = builtin__alloc_array_data(source_capacity_in_bytes); | ||
| 9769 | + } | ||
| 9770 | + } | ||
| 9771 | + array _t1 = ((array){.data = (voidptr)data,.offset = 0,.len = a->len,.cap = a->cap,.flags = (use_noscan_data ? ((ArrayFlags__managed | ArrayFlags__noscan_data)) : (ArrayFlags__managed)),.element_size = a->element_size,}); | ||
| 9772 | + array arr = _t1; | ||
| 9773 | + if (depth > 0 && _us32_eq(sizeof(array),a->element_size) && a->len >= 0 && a->cap >= a->len) { | ||
| 9774 | + array _t2 = ((array){.data = 0,.offset = 0,.len = 0,.cap = 0,.flags = 0,.element_size = 0,}); | ||
| 9775 | + array ar = _t2; | ||
| 9776 | + int asize = ((int)(sizeof(array))); | ||
| 9777 | + for (int i = 0; i < a->len; ++i) { | ||
| 9778 | + builtin__vmemcpy(&ar, builtin__array_get_unsafe(*a, i), asize); | ||
| 9779 | + array ar_clone = builtin__array_clone_to_depth(&ar, depth - 1); | ||
| 9780 | + builtin__array_set_unsafe(&arr, i, &ar_clone); | ||
| 9781 | + } | ||
| 9782 | + return arr; | ||
| 9783 | + } else if (depth > 0 && _us32_eq(sizeof(string),a->element_size) && a->len >= 0 && a->cap >= a->len) { | ||
| 9784 | + for (int i = 0; i < a->len; ++i) { | ||
| 9785 | + string* str_ptr = ((string*)(builtin__array_get_unsafe(*a, i))); | ||
| 9786 | + string str_clone = builtin__string_clone((*str_ptr)); | ||
| 9787 | + builtin__array_set_unsafe(&arr, i, &str_clone); | ||
| 9788 | + } | ||
| 9789 | + return arr; | ||
| 9790 | + } | ||
| 9791 | + if (a->data != 0 && source_capacity_in_bytes > 0) { | ||
| 9792 | + builtin__vmemcpy(arr.data, a->data, source_capacity_in_bytes); | ||
| 9793 | + } | ||
| 9794 | + return arr; | ||
| 9795 | +} | ||
| 9796 | +inline VV_LOC void builtin__array_set_unsafe(array* a, int i, voidptr val) { | ||
| 9797 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(a->element_size)) * ((u64)(i)), val, a->element_size); | ||
| 9798 | +} | ||
| 9799 | +VV_LOC void builtin__array_set(array* a, int i, voidptr val) { | ||
| 9800 | + #if 1 | ||
| 9801 | + { | ||
| 9802 | + if (i < 0 || i >= a->len) { | ||
| 9803 | + builtin__panic_n2(_S("array.set: index out of range (i,a.len):"), i, a->len); | ||
| 9804 | + VUNREACHABLE(); | ||
| 9805 | + } | ||
| 9806 | + } | ||
| 9807 | + #endif | ||
| 9808 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(a->element_size)) * ((u64)(i)), val, a->element_size); | ||
| 9809 | +} | ||
| 9810 | +VV_LOC void builtin__array_set_i64(array* a, i64 i, voidptr val) { | ||
| 9811 | + #if 1 | ||
| 9812 | + { | ||
| 9813 | + if (i < 0 || i >= ((i64)(a->len))) { | ||
| 9814 | + builtin__panic_n2(_S("array.set: index out of range (i,a.len):"), i, a->len); | ||
| 9815 | + VUNREACHABLE(); | ||
| 9816 | + } | ||
| 9817 | + } | ||
| 9818 | + #endif | ||
| 9819 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(a->element_size)) * ((u64)(i)), val, a->element_size); | ||
| 9820 | +} | ||
| 9821 | +VV_LOC void builtin__array_set_u64(array* a, u64 i, voidptr val) { | ||
| 9822 | + #if 1 | ||
| 9823 | + { | ||
| 9824 | + if (i >= ((u64)(a->len))) { | ||
| 9825 | + builtin___v_panic(builtin__string_plus_many(4, _MOV((string[4]){_S("array.set: index out of range (i,a.len): "), builtin__u64_str(i), _S(", "), builtin__impl_i64_to_string(a->len)}))); | ||
| 9826 | + VUNREACHABLE(); | ||
| 9827 | + } | ||
| 9828 | + } | ||
| 9829 | + #endif | ||
| 9830 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(a->element_size)) * i, val, a->element_size); | ||
| 9831 | +} | ||
| 9832 | +VV_LOC void builtin__array_set_ni(array* a, int i, voidptr val) { | ||
| 9833 | + builtin__array_set(a, builtin__v_ni_index(i, a->len), val); | ||
| 9834 | +} | ||
| 9835 | +inline VV_LOC void builtin__copy_element_to(voidptr dest, voidptr src, int element_size) { | ||
| 9836 | + { // Unsafe block | ||
| 9837 | + switch (element_size) { | ||
| 9838 | + case 1: { | ||
| 9839 | + builtin__vmemcpy(dest, src, 1); | ||
| 9840 | + break; | ||
| 9841 | + } | ||
| 9842 | + case 2: { | ||
| 9843 | + builtin__vmemcpy(dest, src, 2); | ||
| 9844 | + break; | ||
| 9845 | + } | ||
| 9846 | + case 4: { | ||
| 9847 | + builtin__vmemcpy(dest, src, 4); | ||
| 9848 | + break; | ||
| 9849 | + } | ||
| 9850 | + case 8: { | ||
| 9851 | + builtin__vmemcpy(dest, src, 8); | ||
| 9852 | + break; | ||
| 9853 | + } | ||
| 9854 | + case 16: { | ||
| 9855 | + builtin__vmemcpy(dest, src, 16); | ||
| 9856 | + break; | ||
| 9857 | + } | ||
| 9858 | + default: { | ||
| 9859 | + { | ||
| 9860 | + builtin__vmemcpy(dest, src, element_size); | ||
| 9861 | + break; | ||
| 9862 | + } | ||
| 9863 | + } | ||
| 9864 | + } | ||
| 9865 | + | ||
| 9866 | + } | ||
| 9867 | +} | ||
| 9868 | +VV_LOC void builtin__array_push(array* a, voidptr val) { | ||
| 9869 | + #if 1 | ||
| 9870 | + { | ||
| 9871 | + if (a->len < 0) { | ||
| 9872 | + builtin___v_panic(_S("array.push: negative len")); | ||
| 9873 | + VUNREACHABLE(); | ||
| 9874 | + } | ||
| 9875 | + } | ||
| 9876 | + #endif | ||
| 9877 | + if (a->len >= _const_max_int) { | ||
| 9878 | + builtin___v_panic(_S("array.push: len bigger than max_int")); | ||
| 9879 | + VUNREACHABLE(); | ||
| 9880 | + } | ||
| 9881 | + int required = a->len + 1; | ||
| 9882 | + if (required > a->cap) { | ||
| 9883 | + builtin__array_ensure_cap(a, required); | ||
| 9884 | + } else if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__is_slice)) { | ||
| 9885 | + builtin__array_clone_shallow_to_cap(a, a->cap); | ||
| 9886 | + } | ||
| 9887 | + builtin__copy_element_to(((u8*)(a->data)) + ((u64)(a->element_size)) * ((u64)(a->len)), val, a->element_size); | ||
| 9888 | + a->len++; | ||
| 9889 | +} | ||
| 9890 | +void builtin__array_push_many(array* a, voidptr val, int size) { | ||
| 9891 | + if (size <= 0 || val == ((void*)0)) { | ||
| 9892 | + return; | ||
| 9893 | + } | ||
| 9894 | + i64 new_len = ((i64)(a->len)) + ((i64)(size)); | ||
| 9895 | + if (new_len > _const_max_int) { | ||
| 9896 | + builtin___v_panic(_S("array.push_many: new len exceeds max_int")); | ||
| 9897 | + VUNREACHABLE(); | ||
| 9898 | + } | ||
| 9899 | + if (builtin__array_needs_unique_append(*a, ((int)(new_len)))) { | ||
| 9900 | + builtin__array_clone_shallow_to_cap(a, a->cap); | ||
| 9901 | + } | ||
| 9902 | + bool is_self_append = a->data == val && a->data != 0; | ||
| 9903 | + if (((int)(new_len)) > a->cap) { | ||
| 9904 | + builtin__array_ensure_cap(a, ((int)(new_len))); | ||
| 9905 | + } | ||
| 9906 | + if (is_self_append) { | ||
| 9907 | + array cloned = builtin__array_clone(a); | ||
| 9908 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(a->element_size)) * ((u64)(a->len)), cloned.data, ((u64)(a->element_size)) * ((u64)(size))); | ||
| 9909 | + } else { | ||
| 9910 | + if (a->data != 0 && val != 0) { | ||
| 9911 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(a->element_size)) * ((u64)(a->len)), val, ((u64)(a->element_size)) * ((u64)(size))); | ||
| 9912 | + } | ||
| 9913 | + } | ||
| 9914 | + a->len = ((int)(new_len)); | ||
| 9915 | +} | ||
| 9916 | +void builtin__array_reverse_in_place(array* a) { | ||
| 9917 | + if (a->len < 2 || a->element_size == 0) { | ||
| 9918 | + return; | ||
| 9919 | + } | ||
| 9920 | + { // Unsafe block | ||
| 9921 | + u8* tmp_value = builtin___v_malloc(a->element_size); | ||
| 9922 | + for (int i = 0; i < VSAFE_DIV_int(a->len , 2); ++i) { | ||
| 9923 | + builtin__vmemcpy(tmp_value, ((u8*)(a->data)) + ((u64)(i)) * ((u64)(a->element_size)), a->element_size); | ||
| 9924 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)(i)) * ((u64)(a->element_size)), ((u8*)(a->data)) + ((u64)((int)(a->len - 1 - i))) * ((u64)(a->element_size)), a->element_size); | ||
| 9925 | + builtin__vmemcpy(((u8*)(a->data)) + ((u64)((int)(a->len - 1 - i))) * ((u64)(a->element_size)), tmp_value, a->element_size); | ||
| 9926 | + } | ||
| 9927 | + builtin___v_free(tmp_value); | ||
| 9928 | + } | ||
| 9929 | +} | ||
| 9930 | +array builtin__array_reverse(array a) { | ||
| 9931 | + if (a.len < 2) { | ||
| 9932 | + return a; | ||
| 9933 | + } | ||
| 9934 | + bool use_noscan_data = builtin__array_uses_noscan_data(a); | ||
| 9935 | + array _t2 = ((array){.data = builtin__array_alloc_array_data_like(a, ((u64)(a.cap)) * ((u64)(a.element_size))),.offset = 0,.len = a.len,.cap = a.cap,.flags = (use_noscan_data ? ((ArrayFlags__managed | ArrayFlags__noscan_data)) : (ArrayFlags__managed)),.element_size = a.element_size,}); | ||
| 9936 | + array arr = _t2; | ||
| 9937 | + for (int i = 0; i < a.len; ++i) { | ||
| 9938 | + builtin__array_set_unsafe(&arr, i, builtin__array_get_unsafe(a, (int)(a.len - 1 - i))); | ||
| 9939 | + } | ||
| 9940 | + return arr; | ||
| 9941 | +} | ||
| 9942 | +void builtin__array_free(array* a) { | ||
| 9943 | + if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__nofree)) { | ||
| 9944 | + return; | ||
| 9945 | + } | ||
| 9946 | + u8* mblock_ptr = ((u8*)(((u64)(a->data)) - ((u64)(a->offset)))); | ||
| 9947 | + if (mblock_ptr != ((void*)0)) { | ||
| 9948 | + { // Unsafe block | ||
| 9949 | + if (builtin__ArrayFlags_has(&a->flags, ArrayFlags__managed)) { | ||
| 9950 | + builtin___v_free(mblock_ptr - builtin__array_data_header_size()); | ||
| 9951 | + } else { | ||
| 9952 | + builtin___v_free(mblock_ptr); | ||
| 9953 | + } | ||
| 9954 | + } | ||
| 9955 | + } | ||
| 9956 | + { // Unsafe block | ||
| 9957 | + a->data = ((void*)0); | ||
| 9958 | + a->offset = 0; | ||
| 9959 | + a->len = 0; | ||
| 9960 | + a->cap = 0; | ||
| 9961 | + } | ||
| 9962 | +} | ||
| 9963 | +array builtin__array_filter(array a, bool (*predicate)(voidptr _d1)); | ||
| 9964 | +bool builtin__array_any(array a, bool (*predicate)(voidptr _d1)); | ||
| 9965 | +int builtin__array_count(array a, bool (*predicate)(voidptr _d1)); | ||
| 9966 | +bool builtin__array_all(array a, bool (*predicate)(voidptr _d1)); | ||
| 9967 | +array builtin__array_map(array a, voidptr (*callback)(voidptr _d1)); | ||
| 9968 | +void builtin__array_sort(array* a, int (*callback)(voidptr _d1, voidptr _d2)); | ||
| 9969 | +array builtin__array_sorted(array* a, int (*callback)(voidptr _d1, voidptr _d2)); | ||
| 9970 | +void builtin__array_sort_with_compare(array* a, int (*callback)(const void* const_a, const void* const_b)) { | ||
| 9971 | + #if 0 | ||
| 9972 | + { | ||
| 9973 | + } | ||
| 9974 | + #else | ||
| 9975 | + { | ||
| 9976 | + builtin__vqsort(a->data, ((usize)(a->len)), ((usize)(a->element_size)), callback); | ||
| 9977 | + } | ||
| 9978 | + #endif | ||
| 9979 | +} | ||
| 9980 | +array builtin__array_sorted_with_compare(array* a, int (*callback)(const void* const_a, const void* const_b)) { | ||
| 9981 | + array r = builtin__array_clone(a); | ||
| 9982 | + builtin__vqsort(r.data, ((usize)(r.len)), ((usize)(r.element_size)), callback); | ||
| 9983 | + return r; | ||
| 9984 | +} | ||
| 9985 | +bool builtin__array_contains(array a, voidptr value); | ||
| 9986 | +int builtin__array_index(array a, voidptr value); | ||
| 9987 | +int builtin__array_last_index(array a, voidptr value); | ||
| 9988 | +void Array_string_free(Array_string* a) { | ||
| 9989 | + for (int _t1 = 0; _t1 < a->len; ++_t1) { | ||
| 9990 | + string* s = ((string*)a->data) + _t1; | ||
| 9991 | + builtin__string_free(s); | ||
| 9992 | + } | ||
| 9993 | + array* arr = ((array*)(a)); | ||
| 9994 | + builtin__array_free(arr); | ||
| 9995 | +} | ||
| 9996 | +string Array_string_str(Array_string a) { | ||
| 9997 | + int sb_len = 4; | ||
| 9998 | + if (a.len > 0) { | ||
| 9999 | + sb_len += ((string*)a.data)[0].len; | ||
| 10000 | + sb_len *= a.len; | ||
| 10001 | + } | ||
| 10002 | + sb_len += 2; | ||
| 10003 | + strings__Builder sb = strings__new_builder(sb_len); | ||
| 10004 | + strings__Builder_write_u8(&sb, '['); | ||
| 10005 | + for (int i = 0; i < a.len; ++i) { | ||
| 10006 | + string val = ((string*)a.data)[i]; | ||
| 10007 | + strings__Builder_write_u8(&sb, '\''); | ||
| 10008 | + strings__Builder_write_string(&sb, val); | ||
| 10009 | + strings__Builder_write_u8(&sb, '\''); | ||
| 10010 | + if (i < a.len - 1) { | ||
| 10011 | + strings__Builder_write_string(&sb, _S(", ")); | ||
| 10012 | + } | ||
| 10013 | + } | ||
| 10014 | + strings__Builder_write_u8(&sb, ']'); | ||
| 10015 | + string res = strings__Builder_str(&sb); | ||
| 10016 | + strings__Builder_free(&sb); | ||
| 10017 | + return res; | ||
| 10018 | +} | ||
| 10019 | +string Array_u8_hex(Array_u8 b) { | ||
| 10020 | + if (b.len == 0) { | ||
| 10021 | + return _S(""); | ||
| 10022 | + } | ||
| 10023 | + return builtin__data_to_hex_string(b.data, b.len); | ||
| 10024 | +} | ||
| 10025 | +int builtin__copy(Array_u8* dst, Array_u8 src) { | ||
| 10026 | + int min = (dst->len < src.len ? (dst->len) : (src.len)); | ||
| 10027 | + if (min > 0) { | ||
| 10028 | + builtin__vmemmove(dst->data, src.data, min); | ||
| 10029 | + } | ||
| 10030 | + return min; | ||
| 10031 | +} | ||
| 10032 | +void builtin__array_grow_cap(array* a, int amount) { | ||
| 10033 | + i64 new_cap = ((i64)(amount)) + ((i64)(a->cap)); | ||
| 10034 | + if (new_cap > _const_max_int) { | ||
| 10035 | + builtin__panic_n(_S("array.grow_cap: max_int will be exceeded by new cap:"), new_cap); | ||
| 10036 | + VUNREACHABLE(); | ||
| 10037 | + } | ||
| 10038 | + builtin__array_ensure_cap(a, ((int)(new_cap))); | ||
| 10039 | +} | ||
| 10040 | +void builtin__array_grow_len(array* a, int amount) { | ||
| 10041 | + i64 new_len = ((i64)(amount)) + ((i64)(a->len)); | ||
| 10042 | + if (new_len > _const_max_int) { | ||
| 10043 | + builtin__panic_n(_S("array.grow_len: max_int will be exceeded by new len:"), new_len); | ||
| 10044 | + VUNREACHABLE(); | ||
| 10045 | + } | ||
| 10046 | + builtin__array_ensure_cap(a, ((int)(new_len))); | ||
| 10047 | + a->len = ((int)(new_len)); | ||
| 10048 | +} | ||
| 10049 | +Array_voidptr builtin__array_pointers(array a) { | ||
| 10050 | + Array_voidptr res = builtin____new_array_with_default(0, 0, sizeof(voidptr), 0); | ||
| 10051 | + for (int i = 0; i < a.len; ++i) { | ||
| 10052 | + builtin__array_push((array*)&res, _MOV((voidptr[]){ builtin__array_get_unsafe(a, i) })); | ||
| 10053 | + } | ||
| 10054 | + return res; | ||
| 10055 | +} | ||
| 10056 | +Array_u8 builtin__voidptr_vbytes(voidptr data, int len) { | ||
| 10057 | + array _t1 = ((array){.data = data,.offset = 0,.len = len,.cap = len,.flags = 0,.element_size = 1,}); | ||
| 10058 | + array res = _t1; | ||
| 10059 | + return res; | ||
| 10060 | +} | ||
| 10061 | +Array_u8 builtin__u8_vbytes(u8* data, int len) { | ||
| 10062 | + return builtin__voidptr_vbytes(((voidptr)(data)), len); | ||
| 10063 | +} | ||
| 10064 | +void builtin__u8_free(u8* data) { | ||
| 10065 | + builtin___v_free(data); | ||
| 10066 | +} | ||
| 10067 | +inline VV_LOC void builtin__panic_on_negative_len(int len) { | ||
| 10068 | + if (len < 0) { | ||
| 10069 | + builtin__panic_n(_S("negative .len:"), len); | ||
| 10070 | + VUNREACHABLE(); | ||
| 10071 | + } | ||
| 10072 | +} | ||
| 10073 | +inline VV_LOC void builtin__panic_on_negative_cap(int cap) { | ||
| 10074 | + if (cap < 0) { | ||
| 10075 | + builtin__panic_n(_S("negative .cap:"), cap); | ||
| 10076 | + VUNREACHABLE(); | ||
| 10077 | + } | ||
| 10078 | +} | ||
| 10079 | +VV_LOC array builtin____new_array_noscan(int mylen, int cap, int elm_size) { | ||
| 10080 | + return builtin____new_array(mylen, cap, elm_size); | ||
| 10081 | +} | ||
| 10082 | +VV_LOC array builtin____new_array_with_default_noscan(int mylen, int cap, int elm_size, voidptr val) { | ||
| 10083 | + return builtin____new_array_with_default(mylen, cap, elm_size, val); | ||
| 10084 | +} | ||
| 10085 | +VV_LOC array builtin____new_array_with_multi_default_noscan(int mylen, int cap, int elm_size, voidptr val) { | ||
| 10086 | + return builtin____new_array_with_multi_default(mylen, cap, elm_size, val); | ||
| 10087 | +} | ||
| 10088 | +VV_LOC array builtin____new_array_with_array_default_noscan(int mylen, int cap, int elm_size, array val, int depth) { | ||
| 10089 | + return builtin____new_array_with_array_default(mylen, cap, elm_size, val, depth); | ||
| 10090 | +} | ||
| 10091 | +VV_LOC void builtin__array_push_noscan(array* a, voidptr val) { | ||
| 10092 | + builtin__array_push(a, val); | ||
| 10093 | +} | ||
| 10094 | +VV_LOC void builtin__array_push_many_noscan(array* a, voidptr val, int size) { | ||
| 10095 | + builtin__array_push_many(a, val, size); | ||
| 10096 | +} | ||
| 10097 | +VV_LOC bool builtin__autostr_type_in_stack(int typ) { | ||
| 10098 | + for (int i = 0; i < g_autostr_type_stack_len; i++) { | ||
| 10099 | + if (g_autostr_type_stack[builtin__v_fixed_index(i, 64)] == typ) { | ||
| 10100 | + return true; | ||
| 10101 | + } | ||
| 10102 | + } | ||
| 10103 | + return false; | ||
| 10104 | +} | ||
| 10105 | +VV_LOC void builtin__autostr_type_push(int typ) { | ||
| 10106 | + if (g_autostr_type_stack_len >= _const_autostr_type_stack_max_depth) { | ||
| 10107 | + return; | ||
| 10108 | + } | ||
| 10109 | + g_autostr_type_stack[builtin__v_fixed_index(g_autostr_type_stack_len, 64)] = typ; | ||
| 10110 | + g_autostr_type_stack_len++; | ||
| 10111 | +} | ||
| 10112 | +VV_LOC void builtin__autostr_type_pop(void) { | ||
| 10113 | + if (g_autostr_type_stack_len > 0) { | ||
| 10114 | + g_autostr_type_stack_len--; | ||
| 10115 | + } | ||
| 10116 | +} | ||
| 10117 | +VV_LOC bool builtin__autostr_addr_in_stack(voidptr addr) { | ||
| 10118 | + for (int i = 0; i < g_autostr_addr_stack_len; i++) { | ||
| 10119 | + if (g_autostr_addr_stack[builtin__v_fixed_index(i, 64)] == addr) { | ||
| 10120 | + return true; | ||
| 10121 | + } | ||
| 10122 | + } | ||
| 10123 | + return false; | ||
| 10124 | +} | ||
| 10125 | +VV_LOC void builtin__autostr_addr_push(voidptr addr) { | ||
| 10126 | + if (g_autostr_addr_stack_len >= _const_autostr_type_stack_max_depth) { | ||
| 10127 | + return; | ||
| 10128 | + } | ||
| 10129 | + g_autostr_addr_stack[builtin__v_fixed_index(g_autostr_addr_stack_len, 64)] = addr; | ||
| 10130 | + g_autostr_addr_stack_len++; | ||
| 10131 | +} | ||
| 10132 | +VV_LOC void builtin__autostr_addr_pop(void) { | ||
| 10133 | + if (g_autostr_addr_stack_len > 0) { | ||
| 10134 | + g_autostr_addr_stack_len--; | ||
| 10135 | + } | ||
| 10136 | +} | ||
| 10137 | +VV_LOC string builtin__autostr_array_circular(int len) { | ||
| 10138 | + if (len <= 0) { | ||
| 10139 | + return _S("[]"); | ||
| 10140 | + } | ||
| 10141 | + strings__Builder sb = strings__new_builder(2 + len * 12); | ||
| 10142 | + strings__Builder_write_string(&sb, _S("[")); | ||
| 10143 | + for (int i = 0; i < len; ++i) { | ||
| 10144 | + if (i > 0) { | ||
| 10145 | + strings__Builder_write_string(&sb, _S(", ")); | ||
| 10146 | + } | ||
| 10147 | + strings__Builder_write_string(&sb, _S("<circular>")); | ||
| 10148 | + } | ||
| 10149 | + strings__Builder_write_string(&sb, _S("]")); | ||
| 10150 | + string res = strings__Builder_str(&sb); | ||
| 10151 | + strings__Builder_free(&sb); | ||
| 10152 | + return res; | ||
| 10153 | +} | ||
| 10154 | +void builtin__print_backtrace(void) { | ||
| 10155 | + #if !defined(CUSTOM_DEFINE_no_backtrace) | ||
| 10156 | + { | ||
| 10157 | + #if 0 | ||
| 10158 | + { | ||
| 10159 | + } | ||
| 10160 | + #elif defined(__TINYC__) | ||
| 10161 | + { | ||
| 10162 | + } | ||
| 10163 | + #elif defined(CUSTOM_DEFINE_use_libbacktrace) | ||
| 10164 | + { | ||
| 10165 | + } | ||
| 10166 | + #else | ||
| 10167 | + { | ||
| 10168 | + builtin__print_backtrace_skipping_top_frames(2); | ||
| 10169 | + } | ||
| 10170 | + #endif | ||
| 10171 | + } | ||
| 10172 | + #endif | ||
| 10173 | +} | ||
| 10174 | +VV_LOC string builtin__demangle_v_symbol(string cname) { | ||
| 10175 | + string name = cname; | ||
| 10176 | + if (builtin__string_starts_with(name, _S("builtin__"))) { | ||
| 10177 | + name = builtin__string_substr(name, 9, 2147483647); | ||
| 10178 | + } | ||
| 10179 | + name = builtin__string_replace(name, _S("__ptr__"), _S("&")); | ||
| 10180 | + _option_int _t1 = builtin__string_index(name, _S("_T_")); | ||
| 10181 | + if (_t1.state != 0) { | ||
| 10182 | + *(int*) _t1.data = -1; | ||
| 10183 | + } | ||
| 10184 | + | ||
| 10185 | + int t_pos = (*(int*)_t1.data); | ||
| 10186 | + if (t_pos >= 0) { | ||
| 10187 | + string base = builtin__string_replace(builtin__string_substr(name, 0, t_pos), _S("__"), _S(".")); | ||
| 10188 | + string generic_suffix = builtin__string_substr(name, t_pos + 3, 2147483647); | ||
| 10189 | + Array_string params = builtin__split_generic_params(generic_suffix); | ||
| 10190 | + Array_string demangled_params = builtin____new_array_with_default(0, params.len, sizeof(string), 0); | ||
| 10191 | + for (int _t2 = 0; _t2 < params.len; ++_t2) { | ||
| 10192 | + string param = ((string*)params.data)[_t2]; | ||
| 10193 | + builtin__array_push((array*)&demangled_params, _MOV((string[]){ builtin__string_replace(param, _S("__"), _S(".")) })); | ||
| 10194 | + } | ||
| 10195 | + return builtin__string_plus_many(4, _MOV((string[4]){base, _S("["), Array_string_join(demangled_params, _S(", ")), _S("]")})); | ||
| 10196 | + } | ||
| 10197 | + name = builtin__string_replace(name, _S("__"), _S(".")); | ||
| 10198 | + if (_SLIT_EQ(name.str, name.len, "main.main")) { | ||
| 10199 | + return _S("main"); | ||
| 10200 | + } | ||
| 10201 | + return name; | ||
| 10202 | +} | ||
| 10203 | +VV_LOC Array_string builtin__split_generic_params(string s) { | ||
| 10204 | + Array_string params = builtin____new_array_with_default(0, 0, sizeof(string), 0); | ||
| 10205 | + int start = 0; | ||
| 10206 | + int i = 0; | ||
| 10207 | + for (;;) { | ||
| 10208 | + if (!(i < s.len)) break; | ||
| 10209 | + if (s.str[ i] == '_') { | ||
| 10210 | + if (i + 1 < s.len && s.str[ i + 1] == '_') { | ||
| 10211 | + i += 2; | ||
| 10212 | + } else { | ||
| 10213 | + if (i > start) { | ||
| 10214 | + builtin__array_push((array*)¶ms, _MOV((string[]){ builtin__string_substr(s, start, i) })); | ||
| 10215 | + } | ||
| 10216 | + i++; | ||
| 10217 | + start = i; | ||
| 10218 | + } | ||
| 10219 | + } else { | ||
| 10220 | + i++; | ||
| 10221 | + } | ||
| 10222 | + } | ||
| 10223 | + if (start < s.len) { | ||
| 10224 | + builtin__array_push((array*)¶ms, _MOV((string[]){ builtin__string_substr(s, start, 2147483647) })); | ||
| 10225 | + } | ||
| 10226 | + return params; | ||
| 10227 | +} | ||
| 10228 | +VV_LOC string builtin__demangle_backtrace_sym(string s) { | ||
| 10229 | + _option_int _t1 = builtin__string_index(s, _S("(")); | ||
| 10230 | + if (_t1.state != 0) { | ||
| 10231 | + return s; | ||
| 10232 | + } | ||
| 10233 | + | ||
| 10234 | + int paren_start = (*(int*)_t1.data); | ||
| 10235 | + int plus_pos = builtin__string_index_after_(s, _S("+"), paren_start); | ||
| 10236 | + if (plus_pos < 0) { | ||
| 10237 | + return s; | ||
| 10238 | + } | ||
| 10239 | + string symbol = builtin__string_substr(s, paren_start + 1, plus_pos); | ||
| 10240 | + if (symbol.len == 0) { | ||
| 10241 | + return s; | ||
| 10242 | + } | ||
| 10243 | + return builtin__string_plus_many(3, _MOV((string[3]){builtin__string_substr(s, 0, paren_start + 1), builtin__demangle_v_symbol(symbol), builtin__string_substr(s, plus_pos, 2147483647)})); | ||
| 10244 | +} | ||
| 10245 | +VV_LOC void builtin__eprint_space_padding(string output, int max_len) { | ||
| 10246 | + int padding_len = max_len - output.len; | ||
| 10247 | + if (padding_len > 0) { | ||
| 10248 | + for (int _t1 = 0; _t1 < padding_len; ++_t1) { | ||
| 10249 | + builtin__eprint(_S(" ")); | ||
| 10250 | + } | ||
| 10251 | + } | ||
| 10252 | +} | ||
| 10253 | +bool builtin__print_backtrace_skipping_top_frames(int xskipframes) { | ||
| 10254 | + #if defined(CUSTOM_DEFINE_no_backtrace) | ||
| 10255 | + { | ||
| 10256 | + } | ||
| 10257 | + #else | ||
| 10258 | + { | ||
| 10259 | + int skipframes = xskipframes + 2; | ||
| 10260 | + #if 0 | ||
| 10261 | + { | ||
| 10262 | + } | ||
| 10263 | + #elif 1 | ||
| 10264 | + { | ||
| 10265 | + return builtin__print_backtrace_skipping_top_frames_linux(skipframes); | ||
| 10266 | + } | ||
| 10267 | + #else | ||
| 10268 | + { | ||
| 10269 | + } | ||
| 10270 | + #endif | ||
| 10271 | + } | ||
| 10272 | + #endif | ||
| 10273 | + return false; | ||
| 10274 | +} | ||
| 10275 | +VV_LOC string builtin__backtrace_current_executable_name(void) { | ||
| 10276 | + Array_string args = builtin__arguments(); | ||
| 10277 | + if (args.len == 0) { | ||
| 10278 | + return _S(""); | ||
| 10279 | + } | ||
| 10280 | + return (*(string*)builtin__array_get(args, 0)); | ||
| 10281 | +} | ||
| 10282 | +VV_LOC string builtin__backtrace_addr2line_executable(string executable, string current_executable_name) { | ||
| 10283 | + if (executable.len == 0) { | ||
| 10284 | + return _S("/proc/self/exe"); | ||
| 10285 | + } | ||
| 10286 | + if (builtin__string_contains(executable, _S("/"))) { | ||
| 10287 | + return executable; | ||
| 10288 | + } | ||
| 10289 | + if (current_executable_name.len > 0 && builtin__string__eq(builtin__string_all_after_last(executable, _S("/")), builtin__string_all_after_last(current_executable_name, _S("/")))) { | ||
| 10290 | + return _S("/proc/self/exe"); | ||
| 10291 | + } | ||
| 10292 | + return executable; | ||
| 10293 | +} | ||
| 10294 | +VV_LOC string builtin__backtrace_shell_quote(string s) { | ||
| 10295 | + string quoted = _S("'"); | ||
| 10296 | + for (int i = 0; i < s.len; ++i) { | ||
| 10297 | + if (builtin__string_at(s, i) == '\'') { | ||
| 10298 | + quoted = builtin__string__plus(quoted, _S("'\\''")); | ||
| 10299 | + } else { | ||
| 10300 | + quoted = builtin__string__plus(quoted, builtin__u8_ascii_str(builtin__string_at(s, i))); | ||
| 10301 | + } | ||
| 10302 | + } | ||
| 10303 | + return builtin__string__plus(quoted, _S("'")); | ||
| 10304 | +} | ||
| 10305 | +VV_LOC bool builtin__print_backtrace_skipping_top_frames_linux(int skipframes) { | ||
| 10306 | + #if defined(CUSTOM_DEFINE_no_backtrace) | ||
| 10307 | + { | ||
| 10308 | + } | ||
| 10309 | + #else | ||
| 10310 | + { | ||
| 10311 | + #if 1 | ||
| 10312 | + { | ||
| 10313 | + #if 0 | ||
| 10314 | + { | ||
| 10315 | + } | ||
| 10316 | + #else | ||
| 10317 | + { | ||
| 10318 | + string current_executable_name = builtin__backtrace_current_executable_name(); | ||
| 10319 | + Array_fixed_voidptr_100 buffer = {0}; | ||
| 10320 | + i32 nr_ptrs = backtrace(&buffer[0], 100); | ||
| 10321 | + if (nr_ptrs < 2) { | ||
| 10322 | + builtin__eprintln(_S("C.backtrace returned less than 2 frames")); | ||
| 10323 | + return false; | ||
| 10324 | + } | ||
| 10325 | + int nr_actual_frames = (int)(nr_ptrs - skipframes); | ||
| 10326 | + char** csymbols = backtrace_symbols(((voidptr)(&buffer[skipframes])), nr_actual_frames); | ||
| 10327 | + for (int i = 0; i < nr_actual_frames; ++i) { | ||
| 10328 | + string sframe = builtin__tos2(((u8*)(csymbols[i]))); | ||
| 10329 | + string executable = builtin__string_all_before(sframe, _S("(")); | ||
| 10330 | + string addr2line_executable = builtin__backtrace_addr2line_executable(executable, current_executable_name); | ||
| 10331 | + string addr = builtin__string_all_before(builtin__string_all_after(sframe, _S("[")), _S("]")); | ||
| 10332 | + string beforeaddr = builtin__string_all_before(sframe, _S("[")); | ||
| 10333 | + string cmd = builtin__string_plus_many(4, _MOV((string[4]){_S("addr2line -e "), builtin__backtrace_shell_quote(addr2line_executable), _S(" "), builtin__backtrace_shell_quote(addr)})); | ||
| 10334 | + voidptr f = popen(((char*)(cmd.str)), "r"); | ||
| 10335 | + if (f == ((void*)0)) { | ||
| 10336 | + builtin__eprintln(sframe); | ||
| 10337 | + continue; | ||
| 10338 | + } | ||
| 10339 | + Array_fixed_u8_1000 buf = {0}; | ||
| 10340 | + string output = _S(""); | ||
| 10341 | + { // Unsafe block | ||
| 10342 | + u8* bp = ((u8*)(&buf[0])); | ||
| 10343 | + for (;;) { | ||
| 10344 | + if (!(fgets(((char*)(bp)), 1000, f) != 0)) break; | ||
| 10345 | + output = builtin__string__plus(output, builtin__tos(bp, builtin__vstrlen(bp))); | ||
| 10346 | + } | ||
| 10347 | + } | ||
| 10348 | + output = builtin__string__plus(builtin__string_trim_chars(output, _S(" \t\n"), TrimMode__trim_both), _S(":")); | ||
| 10349 | + if (pclose(f) != 0) { | ||
| 10350 | + builtin__eprintln(sframe); | ||
| 10351 | + continue; | ||
| 10352 | + } | ||
| 10353 | + if (_SLIT_EQ(output.str, output.len, "??:0:") || _SLIT_EQ(output.str, output.len, "??:?:")) { | ||
| 10354 | + output = _S(""); | ||
| 10355 | + } | ||
| 10356 | + output = builtin__string_replace(output, _S(" (discriminator"), _S(": (d.")); | ||
| 10357 | + builtin__eprint(output); | ||
| 10358 | + builtin__eprint_space_padding(output, 55); | ||
| 10359 | + builtin__eprint(_S(" | ")); | ||
| 10360 | + builtin__eprint(addr); | ||
| 10361 | + builtin__eprint(_S(" | ")); | ||
| 10362 | + builtin__eprintln(builtin__demangle_backtrace_sym(beforeaddr)); | ||
| 10363 | + } | ||
| 10364 | + if (nr_actual_frames > 0) { | ||
| 10365 | + free(csymbols); | ||
| 10366 | + } | ||
| 10367 | + } | ||
| 10368 | + #endif | ||
| 10369 | + } | ||
| 10370 | + #endif | ||
| 10371 | + } | ||
| 10372 | + #endif | ||
| 10373 | + return true; | ||
| 10374 | +} | ||
| 10375 | +VNORETURN void builtin___v_exit(int code) { | ||
| 10376 | + exit(code); | ||
| 10377 | + VUNREACHABLE(); | ||
| 10378 | + for (;;) { | ||
| 10379 | + } | ||
| 10380 | + while(1); | ||
| 10381 | +} | ||
| 10382 | +_result_void builtin__at_exit(void (*cb)(void)) { | ||
| 10383 | + #if 0 | ||
| 10384 | + { | ||
| 10385 | + } | ||
| 10386 | + #else | ||
| 10387 | + { | ||
| 10388 | + i32 res = atexit(cb); | ||
| 10389 | + if (res != 0) { | ||
| 10390 | + return (_result_void){ .is_error=true, .err=builtin__error_with_code(_S("at_exit failed"), res), .data={E_STRUCT} }; | ||
| 10391 | + } | ||
| 10392 | + } | ||
| 10393 | + #endif | ||
| 10394 | + return (_result_void){0}; | ||
| 10395 | +} | ||
| 10396 | +VV_LOC void builtin__v_segmentation_fault_handler(i32 signal_number) { | ||
| 10397 | + #if defined(CUSTOM_DEFINE_v2_native_windows_pe_minimal) | ||
| 10398 | + { | ||
| 10399 | + } | ||
| 10400 | + #else | ||
| 10401 | + { | ||
| 10402 | + #if 0 | ||
| 10403 | + { | ||
| 10404 | + } | ||
| 10405 | + #else | ||
| 10406 | + { | ||
| 10407 | + fprintf(stderr, "signal %d: segmentation fault\n", signal_number); | ||
| 10408 | + } | ||
| 10409 | + #endif | ||
| 10410 | + #if defined(CUSTOM_DEFINE_use_libbacktrace) && !defined(__TINYC__) | ||
| 10411 | + { | ||
| 10412 | + } | ||
| 10413 | + #elif 0 | ||
| 10414 | + { | ||
| 10415 | + } | ||
| 10416 | + #else | ||
| 10417 | + { | ||
| 10418 | + builtin__print_backtrace(); | ||
| 10419 | + } | ||
| 10420 | + #endif | ||
| 10421 | + builtin___v_exit(128 + signal_number); | ||
| 10422 | + VUNREACHABLE(); | ||
| 10423 | + } | ||
| 10424 | + #endif | ||
| 10425 | +} | ||
| 10426 | +inline VV_LOC int builtin__v_fixed_index(int i, int len) { | ||
| 10427 | + #if 1 | ||
| 10428 | + { | ||
| 10429 | + if (i < 0 || i >= len) { | ||
| 10430 | + builtin___v_panic(builtin__string_plus_many(5, _MOV((string[5]){_S("fixed array index out of range (index: "), builtin__i64_str(((i64)(i))), _S(", len: "), builtin__i64_str(((i64)(len))), _S(")")}))); | ||
| 10431 | + VUNREACHABLE(); | ||
| 10432 | + } | ||
| 10433 | + } | ||
| 10434 | + #endif | ||
| 10435 | + return i; | ||
| 10436 | +} | ||
| 10437 | +inline VV_LOC int builtin__v_fixed_index_i64(i64 i, int len) { | ||
| 10438 | + #if 1 | ||
| 10439 | + { | ||
| 10440 | + if (i < 0 || i >= ((i64)(len))) { | ||
| 10441 | + builtin___v_panic(builtin__string_plus_many(5, _MOV((string[5]){_S("fixed array index out of range (index: "), builtin__i64_str(i), _S(", len: "), builtin__i64_str(((i64)(len))), _S(")")}))); | ||
| 10442 | + VUNREACHABLE(); | ||
| 10443 | + } | ||
| 10444 | + } | ||
| 10445 | + #endif | ||
| 10446 | + return ((int)(i)); | ||
| 10447 | +} | ||
| 10448 | +inline VV_LOC int builtin__v_fixed_index_u64(u64 i, int len) { | ||
| 10449 | + #if 1 | ||
| 10450 | + { | ||
| 10451 | + if (i >= ((u64)(len))) { | ||
| 10452 | + builtin___v_panic(builtin__string_plus_many(5, _MOV((string[5]){_S("fixed array index out of range (index: "), builtin__u64_str(i), _S(", len: "), builtin__i64_str(((i64)(len))), _S(")")}))); | ||
| 10453 | + VUNREACHABLE(); | ||
| 10454 | + } | ||
| 10455 | + } | ||
| 10456 | + #endif | ||
| 10457 | + return ((int)(i)); | ||
| 10458 | +} | ||
| 10459 | +inline VV_LOC int builtin__v_fixed_index_ni(int i, int len) { | ||
| 10460 | + return builtin__v_fixed_index(builtin__v_ni_index(i, len), len); | ||
| 10461 | +} | ||
| 10462 | +inline VV_LOC int builtin__v_slice_index_i64(i64 i) { | ||
| 10463 | + if (i < ((i64)(_const_min_int)) || i > ((i64)(_const_max_int))) { | ||
| 10464 | + builtin___v_panic(builtin__string__plus(_S("slice index out of range for int: "), builtin__i64_str(i))); | ||
| 10465 | + VUNREACHABLE(); | ||
| 10466 | + } | ||
| 10467 | + return ((int)(i)); | ||
| 10468 | +} | ||
| 10469 | +inline VV_LOC int builtin__v_slice_index_u64(u64 i) { | ||
| 10470 | + if (i > ((u64)(_const_max_int))) { | ||
| 10471 | + builtin___v_panic(builtin__string__plus(_S("slice index out of range for int: "), builtin__u64_str(i))); | ||
| 10472 | + VUNREACHABLE(); | ||
| 10473 | + } | ||
| 10474 | + return ((int)(i)); | ||
| 10475 | +} | ||
| 10476 | +Array_string builtin__arguments(void) { | ||
| 10477 | + u8** argv = ((u8**)(g_main_argv)); | ||
| 10478 | + Array_string res = builtin____new_array_with_default(0, g_main_argc, sizeof(string), 0); | ||
| 10479 | + for (int i = 0; i < g_main_argc; ++i) { | ||
| 10480 | + #if 0 | ||
| 10481 | + { | ||
| 10482 | + } | ||
| 10483 | + #else | ||
| 10484 | + { | ||
| 10485 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__tos_clone(argv[i]) })); | ||
| 10486 | + } | ||
| 10487 | + #endif | ||
| 10488 | + } | ||
| 10489 | + return res; | ||
| 10490 | +} | ||
| 10491 | +string builtin__vcurrent_hash(void) { | ||
| 10492 | + return _S(""); | ||
| 10493 | +} | ||
| 10494 | +u64 builtin__v_getpid(void) { | ||
| 10495 | + #if defined(CUSTOM_DEFINE_no_getpid) | ||
| 10496 | + { | ||
| 10497 | + } | ||
| 10498 | + #elif 0 | ||
| 10499 | + { | ||
| 10500 | + } | ||
| 10501 | + #else | ||
| 10502 | + { | ||
| 10503 | + return ((u64)(getpid())); | ||
| 10504 | + } | ||
| 10505 | + #endif | ||
| 10506 | + return 0; | ||
| 10507 | +} | ||
| 10508 | +u64 builtin__v_gettid(void) { | ||
| 10509 | + #if defined(CUSTOM_DEFINE_no_gettid) | ||
| 10510 | + { | ||
| 10511 | + } | ||
| 10512 | + #elif 0 | ||
| 10513 | + { | ||
| 10514 | + } | ||
| 10515 | + #elif 1 | ||
| 10516 | + { | ||
| 10517 | + return ((u64)(gettid())); | ||
| 10518 | + } | ||
| 10519 | + #elif 0 | ||
| 10520 | + { | ||
| 10521 | + } | ||
| 10522 | + #else | ||
| 10523 | + { | ||
| 10524 | + } | ||
| 10525 | + #endif | ||
| 10526 | + return 0; | ||
| 10527 | +} | ||
| 10528 | +inline bool builtin__isnil(voidptr v) { | ||
| 10529 | + return v == 0; | ||
| 10530 | +} | ||
| 10531 | +VV_LOC void builtin__builtin_init(void) { | ||
| 10532 | + #if 1 | ||
| 10533 | + { | ||
| 10534 | + builtin__unbuffer_stdout(); | ||
| 10535 | + } | ||
| 10536 | + #endif | ||
| 10537 | +} | ||
| 10538 | +VNORETURN void builtin__panic_lasterr(string base) { | ||
| 10539 | + builtin___v_panic(builtin__string__plus(base, _S(" unknown"))); | ||
| 10540 | + VUNREACHABLE(); | ||
| 10541 | + while(1); | ||
| 10542 | +} | ||
| 10543 | +void builtin__gc_check_leaks(void) { | ||
| 10544 | +} | ||
| 10545 | +bool builtin__gc_is_enabled(void) { | ||
| 10546 | + return false; | ||
| 10547 | +} | ||
| 10548 | +void builtin__gc_enable(void) { | ||
| 10549 | +} | ||
| 10550 | +void builtin__gc_disable(void) { | ||
| 10551 | +} | ||
| 10552 | +void builtin__gc_collect(void) { | ||
| 10553 | +} | ||
| 10554 | +void builtin__gc_get_warn_proc(void) { | ||
| 10555 | +} | ||
| 10556 | +void builtin__gc_set_warn_proc(void (*cb)(char* msg, usize arg)) { | ||
| 10557 | +} | ||
| 10558 | +#if 0 | ||
| 10559 | +#else | ||
| 10560 | +#endif | ||
| 10561 | +inline int builtin__vstrlen(u8* s) { | ||
| 10562 | + return ((int)(strlen(((char*)(s))))); | ||
| 10563 | +} | ||
| 10564 | +inline int builtin__vstrlen_char(char* s) { | ||
| 10565 | + return ((int)(strlen(s))); | ||
| 10566 | +} | ||
| 10567 | +inline voidptr builtin__vmemcpy(voidptr dest, const void* const_src, isize n) { | ||
| 10568 | + if (n == 0 || ((u64)(dest)) <= 0xFFFF || ((u64)(const_src)) <= 0xFFFF) { | ||
| 10569 | + return dest; | ||
| 10570 | + } | ||
| 10571 | + { // Unsafe block | ||
| 10572 | + return memcpy(dest, const_src, n); | ||
| 10573 | + } | ||
| 10574 | + return 0; | ||
| 10575 | +} | ||
| 10576 | +inline voidptr builtin__vmemmove(voidptr dest, const void* const_src, isize n) { | ||
| 10577 | + if (n == 0 || ((u64)(dest)) <= 0xFFFF || ((u64)(const_src)) <= 0xFFFF) { | ||
| 10578 | + return dest; | ||
| 10579 | + } | ||
| 10580 | + { // Unsafe block | ||
| 10581 | + return memmove(dest, const_src, n); | ||
| 10582 | + } | ||
| 10583 | + return 0; | ||
| 10584 | +} | ||
| 10585 | +inline int builtin__vmemcmp(const void* const_s1, const void* const_s2, isize n) { | ||
| 10586 | + if (n == 0 || ((u64)(const_s1)) <= 0xFFFF || ((u64)(const_s2)) <= 0xFFFF) { | ||
| 10587 | + return 0; | ||
| 10588 | + } | ||
| 10589 | + { // Unsafe block | ||
| 10590 | + return memcmp(const_s1, const_s2, n); | ||
| 10591 | + } | ||
| 10592 | + return 0; | ||
| 10593 | +} | ||
| 10594 | +inline voidptr builtin__vmemset(voidptr s, int c, isize n) { | ||
| 10595 | + if (n == 0 || ((u64)(s)) <= 0xFFFF) { | ||
| 10596 | + return s; | ||
| 10597 | + } | ||
| 10598 | + { // Unsafe block | ||
| 10599 | + return memset(s, c, n); | ||
| 10600 | + } | ||
| 10601 | + return 0; | ||
| 10602 | +} | ||
| 10603 | +inline VV_LOC voidptr builtin__vsort_ptr_at(voidptr base, usize index, usize size) { | ||
| 10604 | + return ((voidptr)(((u8*)(base)) + index * size)); | ||
| 10605 | +} | ||
| 10606 | +VV_LOC void builtin__vstable_sort_merge(voidptr source, voidptr dest, usize left, usize mid, usize right, usize size, int (*sort_cb)(const void* const_a, const void* const_b)) { | ||
| 10607 | + usize left_index = left; | ||
| 10608 | + usize right_index = mid; | ||
| 10609 | + usize dest_index = left; | ||
| 10610 | + for (;;) { | ||
| 10611 | + if (!(left_index < mid && right_index < right)) break; | ||
| 10612 | + voidptr left_ptr = builtin__vsort_ptr_at(source, left_index, size); | ||
| 10613 | + voidptr right_ptr = builtin__vsort_ptr_at(source, right_index, size); | ||
| 10614 | + if (sort_cb(left_ptr, right_ptr) <= 0) { | ||
| 10615 | + builtin__vmemcpy(builtin__vsort_ptr_at(dest, dest_index, size), left_ptr, ((isize)(size))); | ||
| 10616 | + left_index++; | ||
| 10617 | + } else { | ||
| 10618 | + builtin__vmemcpy(builtin__vsort_ptr_at(dest, dest_index, size), right_ptr, ((isize)(size))); | ||
| 10619 | + right_index++; | ||
| 10620 | + } | ||
| 10621 | + dest_index++; | ||
| 10622 | + } | ||
| 10623 | + if (left_index < mid) { | ||
| 10624 | + builtin__vmemcpy(builtin__vsort_ptr_at(dest, dest_index, size), builtin__vsort_ptr_at(source, left_index, size), ((isize)((mid - left_index) * size))); | ||
| 10625 | + } | ||
| 10626 | + if (right_index < right) { | ||
| 10627 | + builtin__vmemcpy(builtin__vsort_ptr_at(dest, dest_index, size), builtin__vsort_ptr_at(source, right_index, size), ((isize)((right - right_index) * size))); | ||
| 10628 | + } | ||
| 10629 | +} | ||
| 10630 | +inline VV_LOC void builtin__vqsort(voidptr base, usize nmemb, usize size, int (*sort_cb)(const void* const_a, const void* const_b)) { | ||
| 10631 | + if (nmemb < 2 || size == 0) { | ||
| 10632 | + return; | ||
| 10633 | + } | ||
| 10634 | + isize total_size = ((isize)(nmemb * size)); | ||
| 10635 | + u8* buffer = builtin___v_malloc(total_size); | ||
| 10636 | + voidptr source = base; | ||
| 10637 | + voidptr dest = ((voidptr)(buffer)); | ||
| 10638 | + usize width = ((usize)(1)); | ||
| 10639 | + for (;;) { | ||
| 10640 | + if (!(width < nmemb)) break; | ||
| 10641 | + usize left = ((usize)(0)); | ||
| 10642 | + for (;;) { | ||
| 10643 | + if (!(left < nmemb)) break; | ||
| 10644 | + usize mid = (left + width < nmemb ? (left + width) : (nmemb)); | ||
| 10645 | + usize right = (left + width + width < nmemb ? (left + width + width) : (nmemb)); | ||
| 10646 | + builtin__vstable_sort_merge(source, dest, left, mid, right, size, sort_cb); | ||
| 10647 | + left += width + width; | ||
| 10648 | + } | ||
| 10649 | + voidptr tmp = source; | ||
| 10650 | + source = dest; | ||
| 10651 | + dest = tmp; | ||
| 10652 | + width += width; | ||
| 10653 | + } | ||
| 10654 | + if (source != base) { | ||
| 10655 | + builtin__vmemcpy(base, source, total_size); | ||
| 10656 | + } | ||
| 10657 | + { // defer begin | ||
| 10658 | + builtin___v_free(buffer); | ||
| 10659 | + } // defer end | ||
| 10660 | +} | ||
| 10661 | +void builtin__chan_close(chan ch, Array_IError err) { | ||
| 10662 | +} | ||
| 10663 | +ChanState builtin__chan_try_pop(chan ch, voidptr obj) { | ||
| 10664 | + return ChanState__success; | ||
| 10665 | +} | ||
| 10666 | +ChanState builtin__chan_try_push(chan ch, voidptr obj) { | ||
| 10667 | + return ChanState__success; | ||
| 10668 | +} | ||
| 10669 | +VV_LOC void builtin___result_ok(voidptr data, _result* res, int size) { | ||
| 10670 | + { // Unsafe block | ||
| 10671 | + *res = ((_result){.is_error = 0,.err = _const_none__,}); | ||
| 10672 | + builtin__vmemcpy(((u8*)(&res->err)) + sizeof(IError), data, size); | ||
| 10673 | + } | ||
| 10674 | +} | ||
| 10675 | +VV_LOC void builtin___result_clone(_result* current, _result* res, int size) { | ||
| 10676 | + { // Unsafe block | ||
| 10677 | + *res = ((_result){.is_error = current->is_error,.err = current->err,}); | ||
| 10678 | + builtin__vmemcpy(((u8*)(&res->err)) + sizeof(IError), ((u8*)(¤t->err)) + sizeof(IError), size); | ||
| 10679 | + } | ||
| 10680 | +} | ||
| 10681 | +string builtin__IError_str(IError err) { | ||
| 10682 | + if ((err)._typ == _IError_None___index) { | ||
| 10683 | + return _S("none"); | ||
| 10684 | + } | ||
| 10685 | + int c = ((struct _IError_interface_methods*)(err._methods))->_method_code(err._object); | ||
| 10686 | + if (c > 0) { | ||
| 10687 | + return builtin__string_plus_many(3, _MOV((string[3]){((struct _IError_interface_methods*)(err._methods))->_method_msg(err._object), _S("; code: "), builtin__int_str(c)})); | ||
| 10688 | + } | ||
| 10689 | + return ((struct _IError_interface_methods*)(err._methods))->_method_msg(err._object); | ||
| 10690 | +} | ||
| 10691 | +string builtin__Error_msg(Error err) { | ||
| 10692 | + return _S(""); | ||
| 10693 | +} | ||
| 10694 | +int builtin__Error_code(Error err) { | ||
| 10695 | + return 0; | ||
| 10696 | +} | ||
| 10697 | +string builtin__MessageError_str(MessageError err) { | ||
| 10698 | + if (err.code > 0) { | ||
| 10699 | + return builtin__string_plus_many(3, _MOV((string[3]){err.msg, _S("; code: "), builtin__int_str(err.code)})); | ||
| 10700 | + } | ||
| 10701 | + return err.msg; | ||
| 10702 | +} | ||
| 10703 | +string builtin__MessageError_msg(MessageError err) { | ||
| 10704 | + return err.msg; | ||
| 10705 | +} | ||
| 10706 | +int builtin__MessageError_code(MessageError err) { | ||
| 10707 | + return err.code; | ||
| 10708 | +} | ||
| 10709 | +void builtin__MessageError_free(MessageError* err) { | ||
| 10710 | + builtin__string_free(&err->msg); | ||
| 10711 | +} | ||
| 10712 | +inline IError builtin___v_error(string message) { | ||
| 10713 | + ; | ||
| 10714 | + return I_MessageError_to_Interface_IError((HEAP(MessageError, ((MessageError){.msg = message,.code = 0,})))); | ||
| 10715 | +} | ||
| 10716 | +inline IError builtin__error_with_code(string message, int code) { | ||
| 10717 | + ; | ||
| 10718 | + MessageError* _t2 = (MessageError*)builtin___v_malloc(sizeof(MessageError) == 0 ? 1 : sizeof(MessageError)); | ||
| 10719 | + _t2->msg = message; | ||
| 10720 | + _t2->code = code; | ||
| 10721 | + return I_MessageError_to_Interface_IError( _t2); | ||
| 10722 | +} | ||
| 10723 | +VV_LOC void builtin___option_none(voidptr data, _option* option, int size) { | ||
| 10724 | + { // Unsafe block | ||
| 10725 | + *option = ((_option){.state = 2,.err = _const_none__,}); | ||
| 10726 | + builtin__vmemcpy(((u8*)(&option->err)) + sizeof(IError), data, size); | ||
| 10727 | + } | ||
| 10728 | +} | ||
| 10729 | +VV_LOC void builtin___option_ok(voidptr data, _option* option, int size) { | ||
| 10730 | + { // Unsafe block | ||
| 10731 | + *option = ((_option){.state = 0,.err = _const_none__,}); | ||
| 10732 | + builtin__vmemcpy(((u8*)(&option->err)) + sizeof(IError), data, size); | ||
| 10733 | + } | ||
| 10734 | +} | ||
| 10735 | +VV_LOC void builtin___option_clone(_option* current, _option* option, int size) { | ||
| 10736 | + { // Unsafe block | ||
| 10737 | + *option = ((_option){.state = current->state,.err = current->err,}); | ||
| 10738 | + builtin__vmemcpy(((u8*)(&option->err)) + sizeof(IError), ((u8*)(¤t->err)) + sizeof(IError), size); | ||
| 10739 | + } | ||
| 10740 | +} | ||
| 10741 | +VV_LOC void builtin___result_ok_markused(void) { | ||
| 10742 | + _result _t1 = ((_result){.is_error = 0,.err = _const_none__,}); | ||
| 10743 | + _result res = _t1; | ||
| 10744 | + builtin___result_ok(((void*)0), (voidptr)&res, 0); | ||
| 10745 | +} | ||
| 10746 | +VV_LOC string builtin__None___str(None__ _d1) { | ||
| 10747 | + return _S("none"); | ||
| 10748 | +} | ||
| 10749 | +string builtin__none_str(none _d1) { | ||
| 10750 | + return _S("none"); | ||
| 10751 | +} | ||
| 10752 | +int builtin__input_character(void) { | ||
| 10753 | + int ch = 0; | ||
| 10754 | + #if 0 | ||
| 10755 | + { | ||
| 10756 | + } | ||
| 10757 | + #elif 0 | ||
| 10758 | + { | ||
| 10759 | + } | ||
| 10760 | + #else | ||
| 10761 | + { | ||
| 10762 | + ch = getchar(); | ||
| 10763 | + if (ch == EOF) { | ||
| 10764 | + return -1; | ||
| 10765 | + } | ||
| 10766 | + } | ||
| 10767 | + #endif | ||
| 10768 | + return ch; | ||
| 10769 | +} | ||
| 10770 | +int builtin__print_character(u8 ch) { | ||
| 10771 | + #if 0 | ||
| 10772 | + { | ||
| 10773 | + } | ||
| 10774 | + #elif 0 | ||
| 10775 | + { | ||
| 10776 | + } | ||
| 10777 | + #elif 0 | ||
| 10778 | + { | ||
| 10779 | + } | ||
| 10780 | + #else | ||
| 10781 | + { | ||
| 10782 | + i32 x = putchar(ch); | ||
| 10783 | + if (x == EOF) { | ||
| 10784 | + return -1; | ||
| 10785 | + } | ||
| 10786 | + } | ||
| 10787 | + #endif | ||
| 10788 | + return ch; | ||
| 10789 | +} | ||
| 10790 | +#if !defined(CUSTOM_DEFINE_nofloat) | ||
| 10791 | +#endif | ||
| 10792 | +inline string builtin__f64_str(f64 x) { | ||
| 10793 | + { // Unsafe block | ||
| 10794 | + strconv__Float64u _t1 = ((strconv__Float64u){.f = x,}); | ||
| 10795 | + strconv__Float64u f = _t1; | ||
| 10796 | + if (f.u == _const_strconv__double_minus_zero) { | ||
| 10797 | + return _S("-0.0"); | ||
| 10798 | + } | ||
| 10799 | + if (f.u == _const_strconv__double_plus_zero) { | ||
| 10800 | + return _S("0.0"); | ||
| 10801 | + } | ||
| 10802 | + } | ||
| 10803 | + f64 abs_x = builtin__f64_abs(x); | ||
| 10804 | + if (abs_x >= ((f64)(0.0001)) && abs_x < ((f64)(1.0e6))) { | ||
| 10805 | + return strconv__f64_to_str_l(x); | ||
| 10806 | + } else { | ||
| 10807 | + return strconv__ftoa_64(x); | ||
| 10808 | + } | ||
| 10809 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 10810 | +} | ||
| 10811 | +inline string builtin__f64_strg(f64 x) { | ||
| 10812 | + { // Unsafe block | ||
| 10813 | + strconv__Float64u _t1 = ((strconv__Float64u){.f = x,}); | ||
| 10814 | + strconv__Float64u f = _t1; | ||
| 10815 | + if (f.u == _const_strconv__double_minus_zero || f.u == _const_strconv__double_plus_zero) { | ||
| 10816 | + return _S("0.0"); | ||
| 10817 | + } | ||
| 10818 | + } | ||
| 10819 | + f64 abs_x = builtin__f64_abs(x); | ||
| 10820 | + if (abs_x >= ((f64)(0.0001)) && abs_x < ((f64)(1.0e6))) { | ||
| 10821 | + return strconv__f64_to_str_l_with_dot(x); | ||
| 10822 | + } else { | ||
| 10823 | + return strconv__ftoa_64(x); | ||
| 10824 | + } | ||
| 10825 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 10826 | +} | ||
| 10827 | +inline string builtin__float_literal_str(float_literal d) { | ||
| 10828 | + return builtin__f64_str(((f64)(d))); | ||
| 10829 | +} | ||
| 10830 | +inline string builtin__f64_strsci(f64 x, int digit_num) { | ||
| 10831 | + int n_digit = digit_num; | ||
| 10832 | + if (n_digit < 1) { | ||
| 10833 | + n_digit = 1; | ||
| 10834 | + } else if (n_digit > 17) { | ||
| 10835 | + n_digit = 17; | ||
| 10836 | + } | ||
| 10837 | + return strconv__f64_to_str(x, n_digit); | ||
| 10838 | +} | ||
| 10839 | +inline string builtin__f64_strlong(f64 x) { | ||
| 10840 | + return strconv__f64_to_str_l(x); | ||
| 10841 | +} | ||
| 10842 | +inline string builtin__f32_str(f32 x) { | ||
| 10843 | + { // Unsafe block | ||
| 10844 | + strconv__Float32u _t1 = ((strconv__Float32u){.f = x,}); | ||
| 10845 | + strconv__Float32u f = _t1; | ||
| 10846 | + if (f.u == _const_strconv__single_minus_zero) { | ||
| 10847 | + return _S("-0.0"); | ||
| 10848 | + } | ||
| 10849 | + if (f.u == _const_strconv__single_plus_zero) { | ||
| 10850 | + return _S("0.0"); | ||
| 10851 | + } | ||
| 10852 | + } | ||
| 10853 | + f32 abs_x = builtin__f32_abs(x); | ||
| 10854 | + if (abs_x >= ((f32)(0.0001)) && abs_x < ((f32)(1.0e6))) { | ||
| 10855 | + return strconv__f32_to_str_l(x); | ||
| 10856 | + } else { | ||
| 10857 | + return strconv__ftoa_32(x); | ||
| 10858 | + } | ||
| 10859 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 10860 | +} | ||
| 10861 | +inline string builtin__f32_strg(f32 x) { | ||
| 10862 | + { // Unsafe block | ||
| 10863 | + strconv__Float32u _t1 = ((strconv__Float32u){.f = x,}); | ||
| 10864 | + strconv__Float32u f = _t1; | ||
| 10865 | + if (f.u == _const_strconv__single_minus_zero || f.u == _const_strconv__single_plus_zero) { | ||
| 10866 | + return _S("0.0"); | ||
| 10867 | + } | ||
| 10868 | + } | ||
| 10869 | + f32 abs_x = builtin__f32_abs(x); | ||
| 10870 | + if (abs_x >= ((f32)(0.0001)) && abs_x < ((f32)(1.0e6))) { | ||
| 10871 | + return strconv__f32_to_str_l_with_dot(x); | ||
| 10872 | + } else { | ||
| 10873 | + return strconv__ftoa_32(x); | ||
| 10874 | + } | ||
| 10875 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 10876 | +} | ||
| 10877 | +inline string builtin__f32_strsci(f32 x, int digit_num) { | ||
| 10878 | + int n_digit = digit_num; | ||
| 10879 | + if (n_digit < 1) { | ||
| 10880 | + n_digit = 1; | ||
| 10881 | + } else if (n_digit > 8) { | ||
| 10882 | + n_digit = 8; | ||
| 10883 | + } | ||
| 10884 | + return strconv__f32_to_str(x, n_digit); | ||
| 10885 | +} | ||
| 10886 | +inline string builtin__f32_strlong(f32 x) { | ||
| 10887 | + return strconv__f32_to_str_l(x); | ||
| 10888 | +} | ||
| 10889 | +inline f32 builtin__f32_abs(f32 a) { | ||
| 10890 | + if (a < 0) { | ||
| 10891 | + return -a; | ||
| 10892 | + } | ||
| 10893 | + return a; | ||
| 10894 | +} | ||
| 10895 | +inline f64 builtin__f64_abs(f64 a) { | ||
| 10896 | + if (a < 0) { | ||
| 10897 | + return -a; | ||
| 10898 | + } | ||
| 10899 | + return a; | ||
| 10900 | +} | ||
| 10901 | +inline f32 builtin__f32_min(f32 a, f32 b) { | ||
| 10902 | + if (a < b) { | ||
| 10903 | + return a; | ||
| 10904 | + } | ||
| 10905 | + return b; | ||
| 10906 | +} | ||
| 10907 | +inline f32 builtin__f32_max(f32 a, f32 b) { | ||
| 10908 | + if (a > b) { | ||
| 10909 | + return a; | ||
| 10910 | + } | ||
| 10911 | + return b; | ||
| 10912 | +} | ||
| 10913 | +inline f64 builtin__f64_min(f64 a, f64 b) { | ||
| 10914 | + if (a < b) { | ||
| 10915 | + return a; | ||
| 10916 | + } | ||
| 10917 | + return b; | ||
| 10918 | +} | ||
| 10919 | +inline f64 builtin__f64_max(f64 a, f64 b) { | ||
| 10920 | + if (a > b) { | ||
| 10921 | + return a; | ||
| 10922 | + } | ||
| 10923 | + return b; | ||
| 10924 | +} | ||
| 10925 | +inline bool builtin__f32_eq_epsilon(f32 a, f32 b) { | ||
| 10926 | + f32 hi = builtin__f32_max(builtin__f32_abs(a), builtin__f32_abs(b)); | ||
| 10927 | + f32 delta = builtin__f32_abs(a - b); | ||
| 10928 | + if (hi > ((f32)(1.0))) { | ||
| 10929 | + return delta <= hi * (4 * ((f32)(FLT_EPSILON))); | ||
| 10930 | + } else { | ||
| 10931 | + return (1 / (4 * ((f32)(FLT_EPSILON)))) * delta <= hi; | ||
| 10932 | + } | ||
| 10933 | + return 0; | ||
| 10934 | +} | ||
| 10935 | +inline bool builtin__f64_eq_epsilon(f64 a, f64 b) { | ||
| 10936 | + f64 hi = builtin__f64_max(builtin__f64_abs(a), builtin__f64_abs(b)); | ||
| 10937 | + f64 delta = builtin__f64_abs(a - b); | ||
| 10938 | + if (hi > ((f64)(1.0))) { | ||
| 10939 | + return delta <= hi * (4 * ((f64)(DBL_EPSILON))); | ||
| 10940 | + } else { | ||
| 10941 | + return (1 / (4 * ((f64)(DBL_EPSILON)))) * delta <= hi; | ||
| 10942 | + } | ||
| 10943 | + return 0; | ||
| 10944 | +} | ||
| 10945 | +inline VV_LOC u32 builtin__grapheme_hex_nibble(u8 c) { | ||
| 10946 | + return (c <= '9' ? (((u32)((rune)(c - '0')))) : (((u32)((rune)(((c | 0x20)) - 'a') + 10)))); | ||
| 10947 | +} | ||
| 10948 | +inline VV_LOC u32 builtin__grapheme_hex_byte(string ranges, int i) { | ||
| 10949 | + return ((v__lshift_u32(builtin__grapheme_hex_nibble(builtin__string_at(ranges, i)), (u64)4)) | builtin__grapheme_hex_nibble(builtin__string_at(ranges, i + 1))); | ||
| 10950 | +} | ||
| 10951 | +inline VV_LOC u32 builtin__grapheme_range_value(string ranges, int value_idx) { | ||
| 10952 | + int i = value_idx * 8; | ||
| 10953 | + u32 b0 = builtin__grapheme_hex_byte(ranges, i); | ||
| 10954 | + u32 b1 = builtin__grapheme_hex_byte(ranges, i + 2); | ||
| 10955 | + u32 b2 = builtin__grapheme_hex_byte(ranges, i + 4); | ||
| 10956 | + u32 b3 = builtin__grapheme_hex_byte(ranges, i + 6); | ||
| 10957 | + return (((b0 | (v__lshift_u32(b1, (u64)8))) | (v__lshift_u32(b2, (u64)16))) | (v__lshift_u32(b3, (u64)24))); | ||
| 10958 | +} | ||
| 10959 | +inline VV_LOC bool builtin__in_grapheme_ranges(rune r, string ranges) { | ||
| 10960 | + u32 target = ((u32)(r)); | ||
| 10961 | + int low = 0; | ||
| 10962 | + int high = VSAFE_DIV_int(ranges.len , 16); | ||
| 10963 | + for (;;) { | ||
| 10964 | + if (!(low < high)) break; | ||
| 10965 | + int mid = low + VSAFE_DIV_int((high - low) , 2); | ||
| 10966 | + u32 lo = builtin__grapheme_range_value(ranges, mid * 2); | ||
| 10967 | + u32 hi = builtin__grapheme_range_value(ranges, mid * 2 + 1); | ||
| 10968 | + if (target < lo) { | ||
| 10969 | + high = mid; | ||
| 10970 | + } else if (target > hi) { | ||
| 10971 | + low = mid + 1; | ||
| 10972 | + } else { | ||
| 10973 | + return true; | ||
| 10974 | + } | ||
| 10975 | + } | ||
| 10976 | + return false; | ||
| 10977 | +} | ||
| 10978 | +inline VV_LOC GraphemeBreakProperty builtin__grapheme_break_property(rune r) { | ||
| 10979 | + if (r == '\r') { | ||
| 10980 | + return GraphemeBreakProperty__cr; | ||
| 10981 | + } | ||
| 10982 | + if (r == '\n') { | ||
| 10983 | + return GraphemeBreakProperty__lf; | ||
| 10984 | + } | ||
| 10985 | + if (r == 0x200d) { | ||
| 10986 | + return GraphemeBreakProperty__zwj; | ||
| 10987 | + } | ||
| 10988 | + if (r >= 0x1f1e6 && r <= 0x1f1ff) { | ||
| 10989 | + return GraphemeBreakProperty__regional_indicator; | ||
| 10990 | + } | ||
| 10991 | + if (r >= 0xac00 && r <= 0xd7a3) { | ||
| 10992 | + return (VSAFE_MOD_u32((((u32)(r)) - 0xac00) , 28) == 0 ? (GraphemeBreakProperty__lv) : (GraphemeBreakProperty__lvt)); | ||
| 10993 | + } | ||
| 10994 | + if ((r >= 0x1100 && r <= 0x115f) || (r >= 0xa960 && r <= 0xa97c)) { | ||
| 10995 | + return GraphemeBreakProperty__l; | ||
| 10996 | + } | ||
| 10997 | + if ((r >= 0x1160 && r <= 0x11a7) || (r >= 0xd7b0 && r <= 0xd7c6)) { | ||
| 10998 | + return GraphemeBreakProperty__v; | ||
| 10999 | + } | ||
| 11000 | + if ((r >= 0x11a8 && r <= 0x11ff) || (r >= 0xd7cb && r <= 0xd7fb)) { | ||
| 11001 | + return GraphemeBreakProperty__t; | ||
| 11002 | + } | ||
| 11003 | + if (builtin__in_grapheme_ranges(r, _const_grapheme_control_ranges)) { | ||
| 11004 | + return GraphemeBreakProperty__control; | ||
| 11005 | + } | ||
| 11006 | + if (builtin__in_grapheme_ranges(r, _const_grapheme_extend_ranges)) { | ||
| 11007 | + return GraphemeBreakProperty__extend; | ||
| 11008 | + } | ||
| 11009 | + if (builtin__in_grapheme_ranges(r, _const_grapheme_spacing_mark_ranges)) { | ||
| 11010 | + return GraphemeBreakProperty__spacing_mark; | ||
| 11011 | + } | ||
| 11012 | + if (builtin__in_grapheme_ranges(r, _const_grapheme_prepend_ranges)) { | ||
| 11013 | + return GraphemeBreakProperty__prepend; | ||
| 11014 | + } | ||
| 11015 | + return GraphemeBreakProperty__other; | ||
| 11016 | +} | ||
| 11017 | +inline VV_LOC bool builtin__is_extended_pictographic(rune r) { | ||
| 11018 | + return builtin__in_grapheme_ranges(r, _const_grapheme_extended_pictographic_ranges); | ||
| 11019 | +} | ||
| 11020 | +inline VV_LOC GraphemeState builtin__grapheme_state_from_rune(rune r, GraphemeBreakProperty prop) { | ||
| 11021 | + return ((GraphemeState){.prev_prop = prop,.ri_count = (prop == GraphemeBreakProperty__regional_indicator ? (1) : (0)),.extended_pictographic_state = (builtin__is_extended_pictographic(r) ? (((u8)(1))) : (((u8)(0)))),}); | ||
| 11022 | +} | ||
| 11023 | +inline VV_LOC void builtin__GraphemeState_push(GraphemeState* gs, rune r, GraphemeBreakProperty prop) { | ||
| 11024 | + gs->prev_prop = prop; | ||
| 11025 | + gs->ri_count = (prop == GraphemeBreakProperty__regional_indicator ? (gs->ri_count + 1) : (0)); | ||
| 11026 | + if (builtin__is_extended_pictographic(r)) { | ||
| 11027 | + gs->extended_pictographic_state = 1; | ||
| 11028 | + } else if (prop == GraphemeBreakProperty__extend && gs->extended_pictographic_state == 1) { | ||
| 11029 | + } else if (prop == GraphemeBreakProperty__zwj && gs->extended_pictographic_state == 1) { | ||
| 11030 | + gs->extended_pictographic_state = 2; | ||
| 11031 | + } else { | ||
| 11032 | + gs->extended_pictographic_state = 0; | ||
| 11033 | + } | ||
| 11034 | +} | ||
| 11035 | +inline VV_LOC bool builtin__should_break_grapheme(GraphemeState gs, rune r, GraphemeBreakProperty prop) { | ||
| 11036 | + switch (gs.prev_prop) { | ||
| 11037 | + case GraphemeBreakProperty__cr: { | ||
| 11038 | + if (prop == GraphemeBreakProperty__lf) { | ||
| 11039 | + return false; | ||
| 11040 | + } | ||
| 11041 | + return true; | ||
| 11042 | + } | ||
| 11043 | + case GraphemeBreakProperty__lf: case GraphemeBreakProperty__control: { | ||
| 11044 | + return true; | ||
| 11045 | + } | ||
| 11046 | + case GraphemeBreakProperty__l: { | ||
| 11047 | + if (prop == GraphemeBreakProperty__l || prop == GraphemeBreakProperty__v || prop == GraphemeBreakProperty__lv || prop == GraphemeBreakProperty__lvt) { | ||
| 11048 | + return false; | ||
| 11049 | + } | ||
| 11050 | + break; | ||
| 11051 | + } | ||
| 11052 | + case GraphemeBreakProperty__lv: case GraphemeBreakProperty__v: { | ||
| 11053 | + if (prop == GraphemeBreakProperty__v || prop == GraphemeBreakProperty__t) { | ||
| 11054 | + return false; | ||
| 11055 | + } | ||
| 11056 | + break; | ||
| 11057 | + } | ||
| 11058 | + case GraphemeBreakProperty__lvt: case GraphemeBreakProperty__t: { | ||
| 11059 | + if (prop == GraphemeBreakProperty__t) { | ||
| 11060 | + return false; | ||
| 11061 | + } | ||
| 11062 | + break; | ||
| 11063 | + } | ||
| 11064 | + case GraphemeBreakProperty__prepend: { | ||
| 11065 | + return false; | ||
| 11066 | + } | ||
| 11067 | + case GraphemeBreakProperty__regional_indicator: { | ||
| 11068 | + if (prop == GraphemeBreakProperty__regional_indicator && VSAFE_MOD_int(gs.ri_count , 2) == 1) { | ||
| 11069 | + return false; | ||
| 11070 | + } | ||
| 11071 | + break; | ||
| 11072 | + } | ||
| 11073 | + case GraphemeBreakProperty__other: | ||
| 11074 | + case GraphemeBreakProperty__extend: | ||
| 11075 | + case GraphemeBreakProperty__spacing_mark: | ||
| 11076 | + case GraphemeBreakProperty__zwj: | ||
| 11077 | + default: { | ||
| 11078 | + { | ||
| 11079 | + break; | ||
| 11080 | + } | ||
| 11081 | + } | ||
| 11082 | + } | ||
| 11083 | + | ||
| 11084 | + if (prop == GraphemeBreakProperty__cr || prop == GraphemeBreakProperty__lf || prop == GraphemeBreakProperty__control) { | ||
| 11085 | + return true; | ||
| 11086 | + } | ||
| 11087 | + if (prop == GraphemeBreakProperty__extend || prop == GraphemeBreakProperty__zwj || prop == GraphemeBreakProperty__spacing_mark) { | ||
| 11088 | + return false; | ||
| 11089 | + } | ||
| 11090 | + if (gs.extended_pictographic_state == 2 && builtin__is_extended_pictographic(r)) { | ||
| 11091 | + return false; | ||
| 11092 | + } | ||
| 11093 | + return true; | ||
| 11094 | +} | ||
| 11095 | +inline VV_LOC int builtin__utf8_rune_visible_width(rune r, GraphemeBreakProperty prop) { | ||
| 11096 | + if (prop == GraphemeBreakProperty__extend || prop == GraphemeBreakProperty__zwj || prop == GraphemeBreakProperty__spacing_mark || prop == GraphemeBreakProperty__prepend) { | ||
| 11097 | + return 0; | ||
| 11098 | + } | ||
| 11099 | + if (r >= 0x1100 && (r <= 0x115f || r == 0x2329 || r == 0x232a || (r >= 0x2e80 && r <= 0xa4cf && r != 0x303f) || (r >= 0xac00 && r <= 0xd7a3) || (r >= 0xf900 && r <= 0xfaff) || (r >= 0xfe10 && r <= 0xfe19) || (r >= 0xfe30 && r <= 0xfe6f) || (r >= 0xff00 && r <= 0xff60) || (r >= 0xffe0 && r <= 0xffe6) || (r >= 0x1f300 && r <= 0x1f64f) || (r >= 0x1f680 && r <= 0x1f6ff) || (r >= 0x1f900 && r <= 0x1f9ff) || (r >= 0x1fa70 && r <= 0x1faff) || (r >= 0x20000 && r <= 0x3fffd))) { | ||
| 11100 | + return 2; | ||
| 11101 | + } | ||
| 11102 | + return 1; | ||
| 11103 | +} | ||
| 11104 | +VV_LOC Array_string builtin__string_graphemes_impl(string s) { | ||
| 11105 | + Array_rune runes = builtin__string_runes(s); | ||
| 11106 | + if (runes.len == 0) { | ||
| 11107 | + return builtin____new_array_with_default(0, 0, sizeof(string), 0); | ||
| 11108 | + } | ||
| 11109 | + Array_string res = builtin____new_array_with_default(0, runes.len, sizeof(string), 0); | ||
| 11110 | + Array_rune cluster = builtin____new_array_with_default(0, 4, sizeof(rune), 0); | ||
| 11111 | + GraphemeBreakProperty first_prop = builtin__grapheme_break_property((*(rune*)builtin__array_get(runes, 0))); | ||
| 11112 | + GraphemeState state = builtin__grapheme_state_from_rune((*(rune*)builtin__array_get(runes, 0)), first_prop); | ||
| 11113 | + builtin__array_push((array*)&cluster, _MOV((rune[]){ (*(rune*)builtin__array_get(runes, 0)) })); | ||
| 11114 | + Array_rune _t3 = builtin__array_slice(runes, 1, 2147483647); | ||
| 11115 | + for (int _t4 = 0; _t4 < _t3.len; ++_t4) { | ||
| 11116 | + rune r = ((rune*)_t3.data)[_t4]; | ||
| 11117 | + GraphemeBreakProperty prop = builtin__grapheme_break_property(r); | ||
| 11118 | + if (builtin__should_break_grapheme(state, r, prop)) { | ||
| 11119 | + builtin__array_push((array*)&res, _MOV((string[]){ Array_rune_string(cluster) })); | ||
| 11120 | + cluster = builtin____new_array_with_default(0, 4, sizeof(rune), 0); | ||
| 11121 | + builtin__array_push((array*)&cluster, _MOV((rune[]){ r })); | ||
| 11122 | + state = builtin__grapheme_state_from_rune(r, prop); | ||
| 11123 | + continue; | ||
| 11124 | + } | ||
| 11125 | + builtin__array_push((array*)&cluster, _MOV((rune[]){ r })); | ||
| 11126 | + builtin__GraphemeState_push(&state, r, prop); | ||
| 11127 | + } | ||
| 11128 | + builtin__array_push((array*)&res, _MOV((string[]){ Array_rune_string(cluster) })); | ||
| 11129 | + return res; | ||
| 11130 | +} | ||
| 11131 | +inline VV_LOC int builtin__utf8_grapheme_visible_length(string s) { | ||
| 11132 | + Array_rune runes = builtin__string_runes(s); | ||
| 11133 | + if (runes.len == 0) { | ||
| 11134 | + return 0; | ||
| 11135 | + } | ||
| 11136 | + GraphemeBreakProperty first_prop = builtin__grapheme_break_property((*(rune*)builtin__array_get(runes, 0))); | ||
| 11137 | + GraphemeState state = builtin__grapheme_state_from_rune((*(rune*)builtin__array_get(runes, 0)), first_prop); | ||
| 11138 | + int total = 0; | ||
| 11139 | + int cluster_width = builtin__utf8_rune_visible_width((*(rune*)builtin__array_get(runes, 0)), first_prop); | ||
| 11140 | + Array_rune _t2 = builtin__array_slice(runes, 1, 2147483647); | ||
| 11141 | + for (int _t3 = 0; _t3 < _t2.len; ++_t3) { | ||
| 11142 | + rune r = ((rune*)_t2.data)[_t3]; | ||
| 11143 | + GraphemeBreakProperty prop = builtin__grapheme_break_property(r); | ||
| 11144 | + if (builtin__should_break_grapheme(state, r, prop)) { | ||
| 11145 | + total += cluster_width; | ||
| 11146 | + cluster_width = builtin__utf8_rune_visible_width(r, prop); | ||
| 11147 | + state = builtin__grapheme_state_from_rune(r, prop); | ||
| 11148 | + continue; | ||
| 11149 | + } | ||
| 11150 | + int rune_width = builtin__utf8_rune_visible_width(r, prop); | ||
| 11151 | + if (rune_width > cluster_width) { | ||
| 11152 | + cluster_width = rune_width; | ||
| 11153 | + } | ||
| 11154 | + builtin__GraphemeState_push(&state, r, prop); | ||
| 11155 | + } | ||
| 11156 | + return total + cluster_width; | ||
| 11157 | +} | ||
| 11158 | +_option_rune builtin__input_rune(void) { | ||
| 11159 | + int x = builtin__input_character(); | ||
| 11160 | + if (x <= 0) { | ||
| 11161 | + return (_option_rune){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | ||
| 11162 | + } | ||
| 11163 | + int char_len = builtin__utf8_char_len(((u8)(x))); | ||
| 11164 | + if (char_len == 1) { | ||
| 11165 | + _option_rune _t2; | ||
| 11166 | + builtin___option_ok(&(rune[]) { x }, (_option*)(&_t2), sizeof(rune)); | ||
| 11167 | + | ||
| 11168 | + return _t2; | ||
| 11169 | + } | ||
| 11170 | + u8 b = ((u8)(x)); | ||
| 11171 | + b = v__lshift_u8(b, (u64)char_len); | ||
| 11172 | + rune res = ((rune)(b)); | ||
| 11173 | + int shift = 6 - char_len; | ||
| 11174 | + for (int i = 1; i < char_len; i++) { | ||
| 11175 | + rune c = ((rune)(builtin__input_character())); | ||
| 11176 | + res = v__lshift_rune(((rune)(res)), (u64)shift); | ||
| 11177 | + res |= (c & 63); | ||
| 11178 | + shift = 6; | ||
| 11179 | + } | ||
| 11180 | + _option_rune _t3; | ||
| 11181 | + builtin___option_ok(&(rune[]) { res }, (_option*)(&_t3), sizeof(rune)); | ||
| 11182 | + | ||
| 11183 | + return _t3; | ||
| 11184 | +} | ||
| 11185 | +_option_rune builtin__InputRuneIterator_next(InputRuneIterator* self) { | ||
| 11186 | + return builtin__input_rune(); | ||
| 11187 | +} | ||
| 11188 | +InputRuneIterator builtin__input_rune_iterator(void) { | ||
| 11189 | + return ((InputRuneIterator){E_STRUCT}); | ||
| 11190 | +} | ||
| 11191 | +string builtin__ptr_str(voidptr ptr) { | ||
| 11192 | + string buf1 = builtin__u64_to_hex_no_leading_zeros(((u64)(ptr)), 16); | ||
| 11193 | + return buf1; | ||
| 11194 | +} | ||
| 11195 | +string builtin__isize_str(isize x) { | ||
| 11196 | + return builtin__i64_str(((i64)(x))); | ||
| 11197 | +} | ||
| 11198 | +string builtin__usize_str(usize x) { | ||
| 11199 | + return builtin__u64_str(((u64)(x))); | ||
| 11200 | +} | ||
| 11201 | +string builtin__char_str(char* cptr) { | ||
| 11202 | + return builtin__u64_hex(((u64)(cptr))); | ||
| 11203 | +} | ||
| 11204 | +inline VV_LOC string builtin__int_str_l(int nn, int max) { | ||
| 11205 | + { // Unsafe block | ||
| 11206 | + i64 n = ((i64)(nn)); | ||
| 11207 | + int d = 0; | ||
| 11208 | + if (n == 0) { | ||
| 11209 | + return _S("0"); | ||
| 11210 | + } | ||
| 11211 | + #if 0 | ||
| 11212 | + { | ||
| 11213 | + } | ||
| 11214 | + #else | ||
| 11215 | + { | ||
| 11216 | + if (n == _const_min_i32) { | ||
| 11217 | + return _S("-2147483648"); | ||
| 11218 | + } | ||
| 11219 | + } | ||
| 11220 | + #endif | ||
| 11221 | + bool is_neg = false; | ||
| 11222 | + if (n < 0) { | ||
| 11223 | + n = -n; | ||
| 11224 | + is_neg = true; | ||
| 11225 | + } | ||
| 11226 | + int index = max; | ||
| 11227 | + u8* buf = builtin__malloc_noscan(max + 1); | ||
| 11228 | + buf[index] = 0; | ||
| 11229 | + index--; | ||
| 11230 | + for (;;) { | ||
| 11231 | + if (!(n > 0)) break; | ||
| 11232 | + int n1 = ((int)(VSAFE_DIV_i64(n , 100))); | ||
| 11233 | + d = ((int)(v__lshift_u32(((u32)(((int)(n)) - (n1 * 100))), (u64)1))); | ||
| 11234 | + n = n1; | ||
| 11235 | + buf[index] = _const_digit_pairs.str[d]; | ||
| 11236 | + index--; | ||
| 11237 | + d++; | ||
| 11238 | + buf[index] = _const_digit_pairs.str[d]; | ||
| 11239 | + index--; | ||
| 11240 | + } | ||
| 11241 | + index++; | ||
| 11242 | + if (d < 20) { | ||
| 11243 | + index++; | ||
| 11244 | + } | ||
| 11245 | + if (is_neg) { | ||
| 11246 | + index--; | ||
| 11247 | + buf[index] = '-'; | ||
| 11248 | + } | ||
| 11249 | + int diff = max - index; | ||
| 11250 | + builtin__vmemmove(buf, ((voidptr)(buf + index)), diff + 1); | ||
| 11251 | + return builtin__tos(buf, diff); | ||
| 11252 | + } | ||
| 11253 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 11254 | +} | ||
| 11255 | +string builtin__i8_str(i8 n) { | ||
| 11256 | + return builtin__int_str_l(((int)(n)), 4); | ||
| 11257 | +} | ||
| 11258 | +string builtin__i16_str(i16 n) { | ||
| 11259 | + return builtin__int_str_l(((int)(n)), 6); | ||
| 11260 | +} | ||
| 11261 | +string builtin__u16_str(u16 n) { | ||
| 11262 | + return builtin__int_str_l(((int)(n)), 6); | ||
| 11263 | +} | ||
| 11264 | +string builtin__i32_str(i32 n) { | ||
| 11265 | + return builtin__int_str_l(((int)(n)), 11); | ||
| 11266 | +} | ||
| 11267 | +string builtin__int_hex_full(int nn) { | ||
| 11268 | + return builtin__u64_to_hex(((u64)(nn)), 8); | ||
| 11269 | +} | ||
| 11270 | +string builtin__int_str(int n) { | ||
| 11271 | + #if defined(CUSTOM_DEFINE_new_int) | ||
| 11272 | + { | ||
| 11273 | + } | ||
| 11274 | + #else | ||
| 11275 | + { | ||
| 11276 | + return builtin__int_str_l(n, 11); | ||
| 11277 | + } | ||
| 11278 | + #endif | ||
| 11279 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 11280 | +} | ||
| 11281 | +inline string builtin__u32_str(u32 nn) { | ||
| 11282 | + { // Unsafe block | ||
| 11283 | + u32 n = nn; | ||
| 11284 | + u32 d = ((u32)(0)); | ||
| 11285 | + if (n == 0) { | ||
| 11286 | + return _S("0"); | ||
| 11287 | + } | ||
| 11288 | + int max = 10; | ||
| 11289 | + u8* buf = builtin__malloc_noscan(max + 1); | ||
| 11290 | + int index = max; | ||
| 11291 | + buf[index] = 0; | ||
| 11292 | + index--; | ||
| 11293 | + for (;;) { | ||
| 11294 | + if (!(n > 0)) break; | ||
| 11295 | + u32 n1 = VSAFE_DIV_u32(n , ((u32)(100))); | ||
| 11296 | + d = (v__lshift_u32((n - (n1 * ((u32)(100)))), (u64)((u32)(1)))); | ||
| 11297 | + n = n1; | ||
| 11298 | + buf[index] = _const_digit_pairs.str[ ((int)(d))]; | ||
| 11299 | + index--; | ||
| 11300 | + d++; | ||
| 11301 | + buf[index] = _const_digit_pairs.str[ ((int)(d))]; | ||
| 11302 | + index--; | ||
| 11303 | + } | ||
| 11304 | + index++; | ||
| 11305 | + if (d < ((u32)(20))) { | ||
| 11306 | + index++; | ||
| 11307 | + } | ||
| 11308 | + int diff = max - index; | ||
| 11309 | + builtin__vmemmove(buf, ((voidptr)(buf + index)), diff + 1); | ||
| 11310 | + return builtin__tos(buf, diff); | ||
| 11311 | + } | ||
| 11312 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 11313 | +} | ||
| 11314 | +inline string builtin__int_literal_str(int_literal n) { | ||
| 11315 | + return builtin__impl_i64_to_string(n); | ||
| 11316 | +} | ||
| 11317 | +inline string builtin__i64_str(i64 nn) { | ||
| 11318 | + return builtin__impl_i64_to_string(nn); | ||
| 11319 | +} | ||
| 11320 | +VV_LOC string builtin__impl_i64_to_string(i64 nn) { | ||
| 11321 | + { // Unsafe block | ||
| 11322 | + i64 n = nn; | ||
| 11323 | + i64 d = ((i64)(0)); | ||
| 11324 | + if (n == 0) { | ||
| 11325 | + return _S("0"); | ||
| 11326 | + } else if (n == _const_min_i64) { | ||
| 11327 | + return _S("-9223372036854775808"); | ||
| 11328 | + } | ||
| 11329 | + int max = 20; | ||
| 11330 | + u8* buf = builtin__malloc_noscan(max + 1); | ||
| 11331 | + bool is_neg = false; | ||
| 11332 | + if (n < 0) { | ||
| 11333 | + n = -n; | ||
| 11334 | + is_neg = true; | ||
| 11335 | + } | ||
| 11336 | + int index = max; | ||
| 11337 | + buf[index] = 0; | ||
| 11338 | + index--; | ||
| 11339 | + for (;;) { | ||
| 11340 | + if (!(n > 0)) break; | ||
| 11341 | + i64 n1 = VSAFE_DIV_i64(n , ((i64)(100))); | ||
| 11342 | + d = (v__lshift_u32(((u32)(n - (n1 * ((i64)(100))))), (u64)((i64)(1)))); | ||
| 11343 | + n = n1; | ||
| 11344 | + buf[index] = _const_digit_pairs.str[ ((int)(d))]; | ||
| 11345 | + index--; | ||
| 11346 | + d++; | ||
| 11347 | + buf[index] = _const_digit_pairs.str[ ((int)(d))]; | ||
| 11348 | + index--; | ||
| 11349 | + } | ||
| 11350 | + index++; | ||
| 11351 | + if (d < ((i64)(20))) { | ||
| 11352 | + index++; | ||
| 11353 | + } | ||
| 11354 | + if (is_neg) { | ||
| 11355 | + index--; | ||
| 11356 | + buf[index] = '-'; | ||
| 11357 | + } | ||
| 11358 | + int diff = max - index; | ||
| 11359 | + builtin__vmemmove(buf, ((voidptr)(buf + index)), diff + 1); | ||
| 11360 | + return builtin__tos(buf, diff); | ||
| 11361 | + } | ||
| 11362 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 11363 | +} | ||
| 11364 | +inline string builtin__u64_str(u64 nn) { | ||
| 11365 | + { // Unsafe block | ||
| 11366 | + u64 n = nn; | ||
| 11367 | + u64 d = ((u64)(0)); | ||
| 11368 | + if (n == 0) { | ||
| 11369 | + return _S("0"); | ||
| 11370 | + } | ||
| 11371 | + int max = 20; | ||
| 11372 | + u8* buf = builtin__malloc_noscan(max + 1); | ||
| 11373 | + int index = max; | ||
| 11374 | + buf[index] = 0; | ||
| 11375 | + index--; | ||
| 11376 | + for (;;) { | ||
| 11377 | + if (!(n > 0)) break; | ||
| 11378 | + u64 n1 = VSAFE_DIV_u64(n , 100); | ||
| 11379 | + d = (v__lshift_u64((n - (n1 * 100)), (u64)1)); | ||
| 11380 | + n = n1; | ||
| 11381 | + buf[index] = _const_digit_pairs.str[ ((int)(d))]; | ||
| 11382 | + index--; | ||
| 11383 | + d++; | ||
| 11384 | + buf[index] = _const_digit_pairs.str[ ((int)(d))]; | ||
| 11385 | + index--; | ||
| 11386 | + } | ||
| 11387 | + index++; | ||
| 11388 | + if (d < 20) { | ||
| 11389 | + index++; | ||
| 11390 | + } | ||
| 11391 | + int diff = max - index; | ||
| 11392 | + builtin__vmemmove(buf, ((voidptr)(buf + index)), diff + 1); | ||
| 11393 | + return builtin__tos(buf, diff); | ||
| 11394 | + } | ||
| 11395 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 11396 | +} | ||
| 11397 | +string builtin__bool_str(bool b) { | ||
| 11398 | + if (b) { | ||
| 11399 | + return _S("true"); | ||
| 11400 | + } | ||
| 11401 | + return _S("false"); | ||
| 11402 | +} | ||
| 11403 | +inline VV_LOC string builtin__u64_to_hex(u64 nn, u8 len) { | ||
| 11404 | + u64 n = nn; | ||
| 11405 | + Array_fixed_u8_17 buf = {0}; | ||
| 11406 | + buf[len] = 0; | ||
| 11407 | + int i = 0; | ||
| 11408 | + for (i = (len - 1); i >= 0; i--) { | ||
| 11409 | + u8 d = ((u8)((n & 0xF))); | ||
| 11410 | + buf[i] = (d < 10 ? ((rune)(d + '0')) : ((u8)(d + 87))); | ||
| 11411 | + n = v__rshift_u64(n, (u64)4); | ||
| 11412 | + } | ||
| 11413 | + return builtin__tos(builtin__memdup(&buf[0], (len + 1)), len); | ||
| 11414 | +} | ||
| 11415 | +inline VV_LOC string builtin__u64_to_hex_no_leading_zeros(u64 nn, u8 len) { | ||
| 11416 | + u64 n = nn; | ||
| 11417 | + Array_fixed_u8_17 buf = {0}; | ||
| 11418 | + buf[len] = 0; | ||
| 11419 | + int i = 0; | ||
| 11420 | + for (i = (len - 1); i >= 0; i--) { | ||
| 11421 | + u8 d = ((u8)((n & 0xF))); | ||
| 11422 | + buf[i] = (d < 10 ? ((rune)(d + '0')) : ((u8)(d + 87))); | ||
| 11423 | + n = v__rshift_u64(n, (u64)4); | ||
| 11424 | + if (n == 0) { | ||
| 11425 | + break; | ||
| 11426 | + } | ||
| 11427 | + } | ||
| 11428 | + int res_len = (int)(len - i); | ||
| 11429 | + return builtin__tos(builtin__memdup(&buf[i], res_len + 1), res_len); | ||
| 11430 | +} | ||
| 11431 | +string builtin__u8_hex(u8 nn) { | ||
| 11432 | + if (nn == 0) { | ||
| 11433 | + return _S("00"); | ||
| 11434 | + } | ||
| 11435 | + return builtin__u64_to_hex(nn, 2); | ||
| 11436 | +} | ||
| 11437 | +string builtin__char_hex(char c) { | ||
| 11438 | + return builtin__u8_hex(((u8)(c))); | ||
| 11439 | +} | ||
| 11440 | +string builtin__rune_hex(rune r) { | ||
| 11441 | + return builtin__u32_hex(((u32)(r))); | ||
| 11442 | +} | ||
| 11443 | +string builtin__i8_hex(i8 nn) { | ||
| 11444 | + if (nn == 0) { | ||
| 11445 | + return _S("00"); | ||
| 11446 | + } | ||
| 11447 | + return builtin__u64_to_hex(((u64)(nn)), 2); | ||
| 11448 | +} | ||
| 11449 | +string builtin__u16_hex(u16 nn) { | ||
| 11450 | + if (nn == 0) { | ||
| 11451 | + return _S("0"); | ||
| 11452 | + } | ||
| 11453 | + return builtin__u64_to_hex_no_leading_zeros(nn, 4); | ||
| 11454 | +} | ||
| 11455 | +string builtin__i16_hex(i16 nn) { | ||
| 11456 | + return builtin__u16_hex(((u16)(nn))); | ||
| 11457 | +} | ||
| 11458 | +string builtin__u32_hex(u32 nn) { | ||
| 11459 | + if (nn == 0) { | ||
| 11460 | + return _S("0"); | ||
| 11461 | + } | ||
| 11462 | + return builtin__u64_to_hex_no_leading_zeros(nn, 8); | ||
| 11463 | +} | ||
| 11464 | +string builtin__int_hex(int nn) { | ||
| 11465 | + return builtin__u32_hex(((u32)(nn))); | ||
| 11466 | +} | ||
| 11467 | +string builtin__int_hex2(int n) { | ||
| 11468 | + return builtin__string__plus(_S("0x"), builtin__int_hex(n)); | ||
| 11469 | +} | ||
| 11470 | +string builtin__u64_hex(u64 nn) { | ||
| 11471 | + if (nn == 0) { | ||
| 11472 | + return _S("0"); | ||
| 11473 | + } | ||
| 11474 | + return builtin__u64_to_hex_no_leading_zeros(nn, 16); | ||
| 11475 | +} | ||
| 11476 | +string builtin__i64_hex(i64 nn) { | ||
| 11477 | + return builtin__u64_hex(((u64)(nn))); | ||
| 11478 | +} | ||
| 11479 | +string builtin__int_literal_hex(int_literal nn) { | ||
| 11480 | + return builtin__u64_hex(((u64)(nn))); | ||
| 11481 | +} | ||
| 11482 | +string builtin__voidptr_str(voidptr nn) { | ||
| 11483 | + return builtin__string__plus(_S("0x"), builtin__u64_hex(((u64)(nn)))); | ||
| 11484 | +} | ||
| 11485 | +string builtin__byteptr_str(byteptr nn) { | ||
| 11486 | + return builtin__string__plus(_S("0x"), builtin__u64_hex(((u64)(nn)))); | ||
| 11487 | +} | ||
| 11488 | +string builtin__charptr_str(charptr nn) { | ||
| 11489 | + return builtin__string__plus(_S("0x"), builtin__u64_hex(((u64)(nn)))); | ||
| 11490 | +} | ||
| 11491 | +string builtin__u8_hex_full(u8 nn) { | ||
| 11492 | + return builtin__u64_to_hex(((u64)(nn)), 2); | ||
| 11493 | +} | ||
| 11494 | +string builtin__i8_hex_full(i8 nn) { | ||
| 11495 | + return builtin__u64_to_hex(((u64)(nn)), 2); | ||
| 11496 | +} | ||
| 11497 | +string builtin__u16_hex_full(u16 nn) { | ||
| 11498 | + return builtin__u64_to_hex(((u64)(nn)), 4); | ||
| 11499 | +} | ||
| 11500 | +string builtin__i16_hex_full(i16 nn) { | ||
| 11501 | + return builtin__u64_to_hex(((u64)(nn)), 4); | ||
| 11502 | +} | ||
| 11503 | +string builtin__u32_hex_full(u32 nn) { | ||
| 11504 | + return builtin__u64_to_hex(((u64)(nn)), 8); | ||
| 11505 | +} | ||
| 11506 | +string builtin__i64_hex_full(i64 nn) { | ||
| 11507 | + return builtin__u64_to_hex(((u64)(nn)), 16); | ||
| 11508 | +} | ||
| 11509 | +string builtin__voidptr_hex_full(voidptr nn) { | ||
| 11510 | + return builtin__u64_to_hex(((u64)(nn)), 16); | ||
| 11511 | +} | ||
| 11512 | +string builtin__int_literal_hex_full(int_literal nn) { | ||
| 11513 | + return builtin__u64_to_hex(((u64)(nn)), 16); | ||
| 11514 | +} | ||
| 11515 | +string builtin__u64_hex_full(u64 nn) { | ||
| 11516 | + return builtin__u64_to_hex(nn, 16); | ||
| 11517 | +} | ||
| 11518 | +string builtin__u8_str(u8 b) { | ||
| 11519 | + return builtin__int_str_l(((int)(b)), 4); | ||
| 11520 | +} | ||
| 11521 | +string builtin__u8_ascii_str(u8 b) { | ||
| 11522 | + string _t1 = ((string){.str = builtin__malloc_noscan(2), .len = 1}); | ||
| 11523 | + string str = _t1; | ||
| 11524 | + { // Unsafe block | ||
| 11525 | + str.str[0] = b; | ||
| 11526 | + str.str[1] = 0; | ||
| 11527 | + } | ||
| 11528 | + return str; | ||
| 11529 | +} | ||
| 11530 | +string builtin__u8_str_escaped(u8 b) { | ||
| 11531 | + string _t1 = (string){.str=(byteptr)"", .is_lit=1}; | ||
| 11532 | + | ||
| 11533 | + if (b == (0)) { | ||
| 11534 | + _t1 = _S("`\\0`"); | ||
| 11535 | + } | ||
| 11536 | + else if (b == (7)) { | ||
| 11537 | + _t1 = _S("`\\a`"); | ||
| 11538 | + } | ||
| 11539 | + else if (b == (8)) { | ||
| 11540 | + _t1 = _S("`\\b`"); | ||
| 11541 | + } | ||
| 11542 | + else if (b == (9)) { | ||
| 11543 | + _t1 = _S("`\\t`"); | ||
| 11544 | + } | ||
| 11545 | + else if (b == (10)) { | ||
| 11546 | + _t1 = _S("`\\n`"); | ||
| 11547 | + } | ||
| 11548 | + else if (b == (11)) { | ||
| 11549 | + _t1 = _S("`\\v`"); | ||
| 11550 | + } | ||
| 11551 | + else if (b == (12)) { | ||
| 11552 | + _t1 = _S("`\\f`"); | ||
| 11553 | + } | ||
| 11554 | + else if (b == (13)) { | ||
| 11555 | + _t1 = _S("`\\r`"); | ||
| 11556 | + } | ||
| 11557 | + else if (b == (27)) { | ||
| 11558 | + _t1 = _S("`\\e`"); | ||
| 11559 | + } | ||
| 11560 | + else if ((b >= 32 && b <= 126)) { | ||
| 11561 | + _t1 = builtin__u8_ascii_str(b); | ||
| 11562 | + } | ||
| 11563 | + else { | ||
| 11564 | + string xx = builtin__u8_hex(b); | ||
| 11565 | + string yy = builtin__string__plus(_S("0x"), xx); | ||
| 11566 | + builtin__string_free(&xx); | ||
| 11567 | + _t1 = yy; | ||
| 11568 | + }string str = _t1; | ||
| 11569 | + return str; | ||
| 11570 | +} | ||
| 11571 | +inline bool builtin__u8_is_capital(u8 c) { | ||
| 11572 | + return c >= 'A' && c <= 'Z'; | ||
| 11573 | +} | ||
| 11574 | +string Array_u8_bytestr(Array_u8 b) { | ||
| 11575 | + { // Unsafe block | ||
| 11576 | + u8* buf = builtin__malloc_noscan(b.len + 1); | ||
| 11577 | + builtin__vmemcpy(buf, b.data, b.len); | ||
| 11578 | + buf[b.len] = 0; | ||
| 11579 | + return builtin__tos(buf, b.len); | ||
| 11580 | + } | ||
| 11581 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 11582 | +} | ||
| 11583 | +_result_rune Array_u8_byterune(Array_u8 b) { | ||
| 11584 | + _result_rune _t1 = Array_u8_utf8_to_utf32(b); | ||
| 11585 | + if (_t1.is_error) { | ||
| 11586 | + _result_rune _t2 = {0}; | ||
| 11587 | + _t2.is_error = true; | ||
| 11588 | + _t2.err = _t1.err; | ||
| 11589 | + return _t2; | ||
| 11590 | + } | ||
| 11591 | + | ||
| 11592 | + rune r = (*(rune*)_t1.data); | ||
| 11593 | + _result_rune _t3; | ||
| 11594 | + builtin___result_ok(&(rune[]) { ((rune)(r)) }, (_result*)(&_t3), sizeof(rune)); | ||
| 11595 | + | ||
| 11596 | + return _t3; | ||
| 11597 | +} | ||
| 11598 | +string builtin__u8_repeat(u8 b, int count) { | ||
| 11599 | + if (count <= 0) { | ||
| 11600 | + return _S(""); | ||
| 11601 | + } else if (count == 1) { | ||
| 11602 | + return builtin__u8_ascii_str(b); | ||
| 11603 | + } | ||
| 11604 | + u8* bytes = builtin__malloc_noscan(count + 1); | ||
| 11605 | + { // Unsafe block | ||
| 11606 | + builtin__vmemset(bytes, b, count); | ||
| 11607 | + bytes[count] = 0; | ||
| 11608 | + } | ||
| 11609 | + return builtin__u8_vstring_with_len(bytes, count); | ||
| 11610 | +} | ||
| 11611 | +inline int builtin__int_min(int a, int b) { | ||
| 11612 | + return (a < b ? (a) : (b)); | ||
| 11613 | +} | ||
| 11614 | +inline int builtin__int_max(int a, int b) { | ||
| 11615 | + return (a > b ? (a) : (b)); | ||
| 11616 | +} | ||
| 11617 | +inline VV_LOC bool builtin__fast_string_eq(string a, string b) { | ||
| 11618 | + if (a.len != b.len) { | ||
| 11619 | + return false; | ||
| 11620 | + } | ||
| 11621 | + { // Unsafe block | ||
| 11622 | + return memcmp(a.str, b.str, b.len) == 0; | ||
| 11623 | + } | ||
| 11624 | + return 0; | ||
| 11625 | +} | ||
| 11626 | +VV_LOC u64 builtin__map_hash_string(voidptr pkey) { | ||
| 11627 | + string key = *((string*)(pkey)); | ||
| 11628 | + return wyhash(key.str, ((u64)(key.len)), 0, ((u64*)(((voidptr)(_wyp))))); | ||
| 11629 | +} | ||
| 11630 | +VV_LOC u64 builtin__map_hash_int_1(voidptr pkey) { | ||
| 11631 | + return wyhash64(*((u8*)(pkey)), 0); | ||
| 11632 | +} | ||
| 11633 | +VV_LOC u64 builtin__map_hash_int_2(voidptr pkey) { | ||
| 11634 | + return wyhash64(*((u16*)(pkey)), 0); | ||
| 11635 | +} | ||
| 11636 | +VV_LOC u64 builtin__map_hash_int_4(voidptr pkey) { | ||
| 11637 | + return wyhash64(*((u32*)(pkey)), 0); | ||
| 11638 | +} | ||
| 11639 | +VV_LOC u64 builtin__map_hash_int_8(voidptr pkey) { | ||
| 11640 | + return wyhash64(*((u64*)(pkey)), 0); | ||
| 11641 | +} | ||
| 11642 | +VV_LOC voidptr builtin__map_enum_fn(int kind, int esize) { | ||
| 11643 | + if (!(kind == 1 || kind == 2 || kind == 3)) { | ||
| 11644 | + builtin___v_panic(_S("map_enum_fn: invalid kind")); | ||
| 11645 | + VUNREACHABLE(); | ||
| 11646 | + } | ||
| 11647 | + if (esize > 8 || esize < 0) { | ||
| 11648 | + builtin___v_panic(_S("map_enum_fn: invalid esize")); | ||
| 11649 | + VUNREACHABLE(); | ||
| 11650 | + } | ||
| 11651 | + if (kind == 1) { | ||
| 11652 | + if (esize > 4) { | ||
| 11653 | + return ((voidptr)(builtin__map_hash_int_8)); | ||
| 11654 | + } | ||
| 11655 | + if (esize > 2) { | ||
| 11656 | + return ((voidptr)(builtin__map_hash_int_4)); | ||
| 11657 | + } | ||
| 11658 | + if (esize > 1) { | ||
| 11659 | + return ((voidptr)(builtin__map_hash_int_2)); | ||
| 11660 | + } | ||
| 11661 | + if (esize > 0) { | ||
| 11662 | + return ((voidptr)(builtin__map_hash_int_1)); | ||
| 11663 | + } | ||
| 11664 | + } | ||
| 11665 | + if (kind == 2) { | ||
| 11666 | + if (esize > 4) { | ||
| 11667 | + return ((voidptr)(builtin__map_eq_int_8)); | ||
| 11668 | + } | ||
| 11669 | + if (esize > 2) { | ||
| 11670 | + return ((voidptr)(builtin__map_eq_int_4)); | ||
| 11671 | + } | ||
| 11672 | + if (esize > 1) { | ||
| 11673 | + return ((voidptr)(builtin__map_eq_int_2)); | ||
| 11674 | + } | ||
| 11675 | + if (esize > 0) { | ||
| 11676 | + return ((voidptr)(builtin__map_eq_int_1)); | ||
| 11677 | + } | ||
| 11678 | + } | ||
| 11679 | + if (kind == 3) { | ||
| 11680 | + if (esize > 4) { | ||
| 11681 | + return ((voidptr)(builtin__map_clone_int_8)); | ||
| 11682 | + } | ||
| 11683 | + if (esize > 2) { | ||
| 11684 | + return ((voidptr)(builtin__map_clone_int_4)); | ||
| 11685 | + } | ||
| 11686 | + if (esize > 1) { | ||
| 11687 | + return ((voidptr)(builtin__map_clone_int_2)); | ||
| 11688 | + } | ||
| 11689 | + if (esize > 0) { | ||
| 11690 | + return ((voidptr)(builtin__map_clone_int_1)); | ||
| 11691 | + } | ||
| 11692 | + } | ||
| 11693 | + return ((void*)0); | ||
| 11694 | +} | ||
| 11695 | +VV_LOC void builtin__DenseArray_zeros_to_end(DenseArray* d) { | ||
| 11696 | + u8* tmp_value = builtin___v_malloc(d->value_bytes); | ||
| 11697 | + u8* tmp_key = builtin___v_malloc(d->key_bytes); | ||
| 11698 | + int count = 0; | ||
| 11699 | + for (int i = 0; i < d->len; ++i) { | ||
| 11700 | + if (builtin__DenseArray_has_index(d, i)) { | ||
| 11701 | + { // Unsafe block | ||
| 11702 | + if (count != i) { | ||
| 11703 | + memcpy(tmp_key, builtin__DenseArray_key(d, count), d->key_bytes); | ||
| 11704 | + memcpy(builtin__DenseArray_key(d, count), builtin__DenseArray_key(d, i), d->key_bytes); | ||
| 11705 | + memcpy(builtin__DenseArray_key(d, i), tmp_key, d->key_bytes); | ||
| 11706 | + memcpy(tmp_value, builtin__DenseArray_value(d, count), d->value_bytes); | ||
| 11707 | + memcpy(builtin__DenseArray_value(d, count), builtin__DenseArray_value(d, i), d->value_bytes); | ||
| 11708 | + memcpy(builtin__DenseArray_value(d, i), tmp_value, d->value_bytes); | ||
| 11709 | + } | ||
| 11710 | + } | ||
| 11711 | + count++; | ||
| 11712 | + } | ||
| 11713 | + } | ||
| 11714 | + { // Unsafe block | ||
| 11715 | + builtin___v_free(tmp_value); | ||
| 11716 | + builtin___v_free(tmp_key); | ||
| 11717 | + d->deletes = 0; | ||
| 11718 | + builtin___v_free(d->all_deleted); | ||
| 11719 | + d->all_deleted = ((void*)0); | ||
| 11720 | + } | ||
| 11721 | + d->len = count; | ||
| 11722 | + int old_cap = d->cap; | ||
| 11723 | + if (count < 8) { | ||
| 11724 | + d->cap = 8; | ||
| 11725 | + } else { | ||
| 11726 | + d->cap = count; | ||
| 11727 | + } | ||
| 11728 | + { // Unsafe block | ||
| 11729 | + d->values = builtin__realloc_data(d->values, d->value_bytes * old_cap, d->value_bytes * d->cap); | ||
| 11730 | + d->keys = builtin__realloc_data(d->keys, d->key_bytes * old_cap, d->key_bytes * d->cap); | ||
| 11731 | + } | ||
| 11732 | +} | ||
| 11733 | +inline VV_LOC DenseArray builtin__new_dense_array(int key_bytes, int value_bytes) { | ||
| 11734 | + int cap = 8; | ||
| 11735 | + return ((DenseArray){ | ||
| 11736 | + .key_bytes = key_bytes, | ||
| 11737 | + .value_bytes = value_bytes, | ||
| 11738 | + .cap = cap, | ||
| 11739 | + .len = 0, | ||
| 11740 | + .deletes = 0, | ||
| 11741 | + .all_deleted = ((void*)0), | ||
| 11742 | + .keys = builtin___v_malloc(builtin____at_least_one(((u64)(cap)) * ((u64)(key_bytes)))), | ||
| 11743 | + .values = builtin___v_malloc(builtin____at_least_one(((u64)(cap)) * ((u64)(value_bytes)))), | ||
| 11744 | + }); | ||
| 11745 | +} | ||
| 11746 | +inline VV_LOC voidptr builtin__DenseArray_key(DenseArray* d, int i) { | ||
| 11747 | + return ((voidptr)(d->keys + i * d->key_bytes)); | ||
| 11748 | +} | ||
| 11749 | +inline VV_LOC voidptr builtin__DenseArray_value(DenseArray* d, int i) { | ||
| 11750 | + return ((voidptr)(d->values + i * d->value_bytes)); | ||
| 11751 | +} | ||
| 11752 | +inline VV_LOC bool builtin__DenseArray_has_index(DenseArray* d, int i) { | ||
| 11753 | + return d->deletes == 0 || d->all_deleted[i] == 0; | ||
| 11754 | +} | ||
| 11755 | +inline VV_LOC void builtin__DenseArray_trim_deleted_tail(DenseArray* d) { | ||
| 11756 | + if (d->deletes == 0) { | ||
| 11757 | + return; | ||
| 11758 | + } | ||
| 11759 | + for (;;) { | ||
| 11760 | + if (!(d->len > 0 && d->all_deleted[d->len - 1] != 0)) break; | ||
| 11761 | + { // Unsafe block | ||
| 11762 | + d->all_deleted[d->len - 1] = 0; | ||
| 11763 | + } | ||
| 11764 | + d->deletes--; | ||
| 11765 | + d->len--; | ||
| 11766 | + } | ||
| 11767 | + if (d->deletes == 0) { | ||
| 11768 | + { // Unsafe block | ||
| 11769 | + builtin___v_free(d->all_deleted); | ||
| 11770 | + d->all_deleted = ((void*)0); | ||
| 11771 | + } | ||
| 11772 | + } | ||
| 11773 | +} | ||
| 11774 | +inline VV_LOC int builtin__DenseArray_expand(DenseArray* d) { | ||
| 11775 | + int old_cap = d->cap; | ||
| 11776 | + int old_key_size = d->key_bytes * old_cap; | ||
| 11777 | + int old_value_size = d->value_bytes * old_cap; | ||
| 11778 | + if (d->cap == d->len) { | ||
| 11779 | + d->cap += v__rshift_int(d->cap, (u64)3); | ||
| 11780 | + { // Unsafe block | ||
| 11781 | + d->keys = builtin__realloc_data(d->keys, old_key_size, d->key_bytes * d->cap); | ||
| 11782 | + d->values = builtin__realloc_data(d->values, old_value_size, d->value_bytes * d->cap); | ||
| 11783 | + if (d->deletes != 0) { | ||
| 11784 | + d->all_deleted = builtin__realloc_data(d->all_deleted, old_cap, d->cap); | ||
| 11785 | + builtin__vmemset(((voidptr)(d->all_deleted + d->len)), 0, d->cap - d->len); | ||
| 11786 | + } | ||
| 11787 | + } | ||
| 11788 | + } | ||
| 11789 | + int push_index = d->len; | ||
| 11790 | + { // Unsafe block | ||
| 11791 | + if (d->deletes != 0) { | ||
| 11792 | + d->all_deleted[push_index] = 0; | ||
| 11793 | + } | ||
| 11794 | + } | ||
| 11795 | + d->len++; | ||
| 11796 | + return push_index; | ||
| 11797 | +} | ||
| 11798 | +inline VV_LOC bool builtin__map_eq_string(voidptr a, voidptr b) { | ||
| 11799 | + return builtin__fast_string_eq(*((string*)(a)), *((string*)(b))); | ||
| 11800 | +} | ||
| 11801 | +inline VV_LOC bool builtin__map_eq_int_1(voidptr a, voidptr b) { | ||
| 11802 | + return *((u8*)(a)) == *((u8*)(b)); | ||
| 11803 | +} | ||
| 11804 | +inline VV_LOC bool builtin__map_eq_int_2(voidptr a, voidptr b) { | ||
| 11805 | + return *((u16*)(a)) == *((u16*)(b)); | ||
| 11806 | +} | ||
| 11807 | +inline VV_LOC bool builtin__map_eq_int_4(voidptr a, voidptr b) { | ||
| 11808 | + return *((u32*)(a)) == *((u32*)(b)); | ||
| 11809 | +} | ||
| 11810 | +inline VV_LOC bool builtin__map_eq_int_8(voidptr a, voidptr b) { | ||
| 11811 | + return *((u64*)(a)) == *((u64*)(b)); | ||
| 11812 | +} | ||
| 11813 | +VV_LOC bool builtin__map_map_eq(map a, map b) { | ||
| 11814 | + if (a.len != b.len) { | ||
| 11815 | + return false; | ||
| 11816 | + } | ||
| 11817 | + for (int i = 0; i < a.key_values.len; i++) { | ||
| 11818 | + if (!builtin__DenseArray_has_index(&a.key_values, i)) { | ||
| 11819 | + continue; | ||
| 11820 | + } | ||
| 11821 | + voidptr k = builtin__DenseArray_key(&a.key_values, i); | ||
| 11822 | + if (!builtin__map_exists(&b, k)) { | ||
| 11823 | + return false; | ||
| 11824 | + } | ||
| 11825 | + voidptr va = builtin__DenseArray_value(&a.key_values, i); | ||
| 11826 | + voidptr vb = builtin__map_get(&b, k, va); | ||
| 11827 | + if (builtin__vmemcmp(va, vb, a.value_bytes) != 0) { | ||
| 11828 | + return false; | ||
| 11829 | + } | ||
| 11830 | + } | ||
| 11831 | + return true; | ||
| 11832 | +} | ||
| 11833 | +inline VV_LOC void builtin__map_clone_string(voidptr dest, voidptr pkey) { | ||
| 11834 | + { // Unsafe block | ||
| 11835 | + string s = *((string*)(pkey)); | ||
| 11836 | + string cloned = builtin__string_clone(s); | ||
| 11837 | + builtin__vmemcpy(dest, ((voidptr)(&cloned)), sizeof(string)); | ||
| 11838 | + } | ||
| 11839 | +} | ||
| 11840 | +inline VV_LOC void builtin__map_clone_int_1(voidptr dest, voidptr pkey) { | ||
| 11841 | + { // Unsafe block | ||
| 11842 | + *((u8*)(dest)) = *((u8*)(pkey)); | ||
| 11843 | + } | ||
| 11844 | +} | ||
| 11845 | +inline VV_LOC void builtin__map_clone_int_2(voidptr dest, voidptr pkey) { | ||
| 11846 | + { // Unsafe block | ||
| 11847 | + *((u16*)(dest)) = *((u16*)(pkey)); | ||
| 11848 | + } | ||
| 11849 | +} | ||
| 11850 | +inline VV_LOC void builtin__map_clone_int_4(voidptr dest, voidptr pkey) { | ||
| 11851 | + { // Unsafe block | ||
| 11852 | + *((u32*)(dest)) = *((u32*)(pkey)); | ||
| 11853 | + } | ||
| 11854 | +} | ||
| 11855 | +inline VV_LOC void builtin__map_clone_int_8(voidptr dest, voidptr pkey) { | ||
| 11856 | + { // Unsafe block | ||
| 11857 | + *((u64*)(dest)) = *((u64*)(pkey)); | ||
| 11858 | + } | ||
| 11859 | +} | ||
| 11860 | +inline VV_LOC void builtin__map_free_string(voidptr pkey) { | ||
| 11861 | + builtin__string_free(ADDR(string, (*((string*)(pkey))))); | ||
| 11862 | +} | ||
| 11863 | +inline VV_LOC void builtin__map_free_nop(voidptr _d1) { | ||
| 11864 | +} | ||
| 11865 | +VV_LOC map builtin__new_map(int key_bytes, int value_bytes, u64 (*hash_fn)(voidptr _d1), bool (*key_eq_fn)(voidptr _d1, voidptr _d2), void (*clone_fn)(voidptr _d1, voidptr _d2), void (*free_fn)(voidptr _d1)) { | ||
| 11866 | + int metasize = ((int)((u32)(sizeof(u32) * (_const_init_capicity + _const_extra_metas_inc)))); | ||
| 11867 | + bool has_string_keys = key_bytes > ((int)(sizeof(voidptr))); | ||
| 11868 | + return ((map){ | ||
| 11869 | + .key_bytes = key_bytes, | ||
| 11870 | + .value_bytes = value_bytes, | ||
| 11871 | + .even_index = _const_init_even_index, | ||
| 11872 | + .cached_hashbits = _const_max_cached_hashbits, | ||
| 11873 | + .shift = _const_init_log_capicity, | ||
| 11874 | + .key_values = builtin__new_dense_array(key_bytes, value_bytes), | ||
| 11875 | + .metas = ((u32*)(builtin__vcalloc_noscan(metasize))), | ||
| 11876 | + .extra_metas = _const_extra_metas_inc, | ||
| 11877 | + .has_string_keys = has_string_keys, | ||
| 11878 | + .hash_fn = hash_fn, | ||
| 11879 | + .key_eq_fn = key_eq_fn, | ||
| 11880 | + .clone_fn = clone_fn, | ||
| 11881 | + .free_fn = free_fn, | ||
| 11882 | + .len = 0, | ||
| 11883 | + }); | ||
| 11884 | +} | ||
| 11885 | +VV_LOC map builtin__new_map_init(u64 (*hash_fn)(voidptr _d1), bool (*key_eq_fn)(voidptr _d1, voidptr _d2), void (*clone_fn)(voidptr _d1, voidptr _d2), void (*free_fn)(voidptr _d1), int n, int key_bytes, int value_bytes, voidptr keys, voidptr values) { | ||
| 11886 | + map out = builtin__new_map(key_bytes, value_bytes, hash_fn, key_eq_fn, clone_fn, free_fn); | ||
| 11887 | + u8* pkey = ((u8*)(keys)); | ||
| 11888 | + u8* pval = ((u8*)(values)); | ||
| 11889 | + for (int _t1 = 0; _t1 < n; ++_t1) { | ||
| 11890 | + { // Unsafe block | ||
| 11891 | + builtin__map_set(&out, pkey, pval); | ||
| 11892 | + pkey = pkey + key_bytes; | ||
| 11893 | + pval = pval + value_bytes; | ||
| 11894 | + } | ||
| 11895 | + } | ||
| 11896 | + return out; | ||
| 11897 | +} | ||
| 11898 | +map builtin__map_move(map* m) { | ||
| 11899 | + map r = *m; | ||
| 11900 | + builtin__vmemset(m, 0, ((int)(sizeof(map)))); | ||
| 11901 | + return r; | ||
| 11902 | +} | ||
| 11903 | +void builtin__map_clear(map* m) { | ||
| 11904 | + { // Unsafe block | ||
| 11905 | + if (m->key_values.all_deleted != 0) { | ||
| 11906 | + builtin___v_free(m->key_values.all_deleted); | ||
| 11907 | + m->key_values.all_deleted = ((void*)0); | ||
| 11908 | + } | ||
| 11909 | + builtin__vmemset(m->key_values.keys, 0, m->key_values.key_bytes * m->key_values.cap); | ||
| 11910 | + builtin__vmemset(m->metas, 0, sizeof(u32) * (m->even_index + 2 + m->extra_metas)); | ||
| 11911 | + } | ||
| 11912 | + m->key_values.len = 0; | ||
| 11913 | + m->key_values.deletes = 0; | ||
| 11914 | + m->even_index = _const_init_even_index; | ||
| 11915 | + m->cached_hashbits = _const_max_cached_hashbits; | ||
| 11916 | + m->shift = _const_init_log_capicity; | ||
| 11917 | + m->len = 0; | ||
| 11918 | +} | ||
| 11919 | +inline VV_LOC multi_return_u32_u32 builtin__map_key_to_index(map* m, voidptr pkey) { | ||
| 11920 | + if (((voidptr)(m->hash_fn)) == ((void*)0)) { | ||
| 11921 | + { // Unsafe block | ||
| 11922 | + u64* p = ((u64*)(m)); | ||
| 11923 | + u64 prev2 = (((u64*)(((usize)(m)) - ((usize)(16)))))[0]; | ||
| 11924 | + u64 prev1 = (((u64*)(((usize)(m)) - ((usize)(8)))))[0]; | ||
| 11925 | + builtin___v_panic(builtin__string_plus_many(34, _MOV((string[34]){_S("map.hash_fn is nil map_ptr="), builtin__usize_str(((usize)(m))), _S(" key_bytes="), builtin__int_str(m->key_bytes), _S(" value_bytes="), builtin__int_str(m->value_bytes), _S(" even_index="), builtin__u32_str(m->even_index), _S(" shift="), builtin__u8_str(m->shift), _S(" metas="), builtin__usize_str(((usize)(m->metas))), _S(" prev2="), builtin__u64_str(prev2), _S(" prev1="), builtin__u64_str(prev1), _S(" w0="), builtin__u64_str(p[0]), _S(" w1="), builtin__u64_str(p[1]), _S(" w2="), builtin__u64_str(p[2]), _S(" w3="), builtin__u64_str(p[3]), _S(" w4="), builtin__u64_str(p[4]), _S(" w5="), builtin__u64_str(p[5]), _S(" w6="), builtin__u64_str(p[6]), _S(" w7="), builtin__u64_str(p[7]), _S(" hash_fn="), builtin__usize_str(((usize)(((voidptr)(m->hash_fn)))))}))); | ||
| 11926 | + VUNREACHABLE(); | ||
| 11927 | + } | ||
| 11928 | + } | ||
| 11929 | + u64 hash = m->hash_fn(pkey); | ||
| 11930 | + u64 index = (hash & m->even_index); | ||
| 11931 | + u64 meta = ((((v__rshift_u64(hash, (u64)m->shift)) & _const_hash_mask)) | _const_probe_inc); | ||
| 11932 | + return (multi_return_u32_u32){.arg0=((u32)(index)), .arg1=((u32)(meta))}; | ||
| 11933 | +} | ||
| 11934 | +inline VV_LOC multi_return_u32_u32 builtin__map_meta_less(map* m, u32 _index, u32 _metas) { | ||
| 11935 | + u32 index = _index; | ||
| 11936 | + u32 meta = _metas; | ||
| 11937 | + for (;;) { | ||
| 11938 | + if (!(meta < m->metas[index])) break; | ||
| 11939 | + index += 2; | ||
| 11940 | + meta += _const_probe_inc; | ||
| 11941 | + } | ||
| 11942 | + return (multi_return_u32_u32){.arg0=index, .arg1=meta}; | ||
| 11943 | +} | ||
| 11944 | +inline VV_LOC void builtin__map_meta_greater(map* m, u32 _index, u32 _metas, u32 kvi) { | ||
| 11945 | + u32 meta = _metas; | ||
| 11946 | + u32 index = _index; | ||
| 11947 | + u32 kv_index = kvi; | ||
| 11948 | + for (;;) { | ||
| 11949 | + if (!(m->metas[index] != 0)) break; | ||
| 11950 | + if (meta > m->metas[index]) { | ||
| 11951 | + { // Unsafe block | ||
| 11952 | + u32 tmp_meta = m->metas[index]; | ||
| 11953 | + m->metas[index] = meta; | ||
| 11954 | + meta = tmp_meta; | ||
| 11955 | + u32 tmp_index = m->metas[index + 1]; | ||
| 11956 | + m->metas[index + 1] = kv_index; | ||
| 11957 | + kv_index = tmp_index; | ||
| 11958 | + } | ||
| 11959 | + } | ||
| 11960 | + index += 2; | ||
| 11961 | + meta += _const_probe_inc; | ||
| 11962 | + if (index + 2 >= m->even_index + 2 + m->extra_metas) { | ||
| 11963 | + builtin__map_ensure_extra_metas_grow(m); | ||
| 11964 | + } | ||
| 11965 | + } | ||
| 11966 | + { // Unsafe block | ||
| 11967 | + m->metas[index] = meta; | ||
| 11968 | + m->metas[index + 1] = kv_index; | ||
| 11969 | + } | ||
| 11970 | + u32 probe_count = (v__rshift_u32(meta, (u64)_const_hashbits)) - 1; | ||
| 11971 | + builtin__map_ensure_extra_metas(m, probe_count); | ||
| 11972 | +} | ||
| 11973 | +VV_LOC void builtin__map_ensure_extra_metas_grow(map* m) { | ||
| 11974 | + u32 size_of_u32 = sizeof(u32); | ||
| 11975 | + u32 old_mem_size = (m->even_index + 2 + m->extra_metas); | ||
| 11976 | + m->extra_metas += _const_extra_metas_inc; | ||
| 11977 | + u32 mem_size = (m->even_index + 2 + m->extra_metas); | ||
| 11978 | + { // Unsafe block | ||
| 11979 | + u8* x = builtin__realloc_data(((byteptr)(m->metas)), ((int)(size_of_u32 * old_mem_size)), ((int)(size_of_u32 * mem_size))); | ||
| 11980 | + m->metas = ((u32*)(x)); | ||
| 11981 | + builtin__vmemset(((byteptr)(m->metas)) + (mem_size - _const_extra_metas_inc) * size_of_u32, 0, ((int)(sizeof(u32) * _const_extra_metas_inc))); | ||
| 11982 | + } | ||
| 11983 | +} | ||
| 11984 | +inline VV_LOC void builtin__map_ensure_extra_metas(map* m, u32 probe_count) { | ||
| 11985 | + if ((v__lshift_u32(probe_count, (u64)1)) == m->extra_metas) { | ||
| 11986 | + u32 size_of_u32 = sizeof(u32); | ||
| 11987 | + u32 old_mem_size = (m->even_index + 2 + m->extra_metas); | ||
| 11988 | + m->extra_metas += _const_extra_metas_inc; | ||
| 11989 | + u32 mem_size = (m->even_index + 2 + m->extra_metas); | ||
| 11990 | + { // Unsafe block | ||
| 11991 | + u8* x = builtin__realloc_data(((byteptr)(m->metas)), ((int)(size_of_u32 * old_mem_size)), ((int)(size_of_u32 * mem_size))); | ||
| 11992 | + m->metas = ((u32*)(x)); | ||
| 11993 | + builtin__vmemset(((byteptr)(m->metas)) + (mem_size - _const_extra_metas_inc) * size_of_u32, 0, ((int)(sizeof(u32) * _const_extra_metas_inc))); | ||
| 11994 | + } | ||
| 11995 | + if (probe_count == 252) { | ||
| 11996 | + builtin___v_panic(_S("Probe overflow")); | ||
| 11997 | + VUNREACHABLE(); | ||
| 11998 | + } | ||
| 11999 | + } | ||
| 12000 | +} | ||
| 12001 | +VV_LOC void builtin__map_set(map* m, voidptr key, voidptr value) { | ||
| 12002 | + if (((u32)(5)) * ((u32)(m->len)) > ((u32)(2)) * m->even_index) { | ||
| 12003 | + builtin__map_expand(m); | ||
| 12004 | + } | ||
| 12005 | + multi_return_u32_u32 mr_14546 = builtin__map_key_to_index(m, key); | ||
| 12006 | + u32 index = mr_14546.arg0; | ||
| 12007 | + u32 meta = mr_14546.arg1; | ||
| 12008 | + multi_return_u32_u32 mr_14582 = builtin__map_meta_less(m, index, meta); | ||
| 12009 | + index = mr_14582.arg0; | ||
| 12010 | + meta = mr_14582.arg1; | ||
| 12011 | + for (;;) { | ||
| 12012 | + if (!(meta == m->metas[index])) break; | ||
| 12013 | + int kv_index = ((int)(m->metas[index + 1])); | ||
| 12014 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | ||
| 12015 | + if (m->key_eq_fn(key, pkey)) { | ||
| 12016 | + { // Unsafe block | ||
| 12017 | + voidptr pval = builtin__DenseArray_value(&m->key_values, kv_index); | ||
| 12018 | + builtin__vmemcpy(pval, value, m->value_bytes); | ||
| 12019 | + } | ||
| 12020 | + return; | ||
| 12021 | + } | ||
| 12022 | + index += 2; | ||
| 12023 | + meta += _const_probe_inc; | ||
| 12024 | + } | ||
| 12025 | + int kv_index = builtin__DenseArray_expand(&m->key_values); | ||
| 12026 | + { // Unsafe block | ||
| 12027 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | ||
| 12028 | + voidptr pvalue = builtin__DenseArray_value(&m->key_values, kv_index); | ||
| 12029 | + m->clone_fn(pkey, key); | ||
| 12030 | + builtin__vmemcpy(pvalue, value, m->value_bytes); | ||
| 12031 | + } | ||
| 12032 | + builtin__map_meta_greater(m, index, meta, ((u32)(kv_index))); | ||
| 12033 | + m->len++; | ||
| 12034 | +} | ||
| 12035 | +VV_LOC void builtin__map_expand(map* m) { | ||
| 12036 | + u32 old_cap = m->even_index; | ||
| 12037 | + m->even_index = (v__lshift_u32((m->even_index + 2), (u64)1)) - 2; | ||
| 12038 | + if (m->cached_hashbits == 0) { | ||
| 12039 | + m->shift += _const_max_cached_hashbits; | ||
| 12040 | + m->cached_hashbits = _const_max_cached_hashbits; | ||
| 12041 | + builtin__map_rehash(m); | ||
| 12042 | + } else { | ||
| 12043 | + builtin__map_cached_rehash(m, old_cap); | ||
| 12044 | + m->cached_hashbits--; | ||
| 12045 | + } | ||
| 12046 | +} | ||
| 12047 | +VV_LOC void builtin__map_rehash(map* m) { | ||
| 12048 | + u32 meta_bytes = sizeof(u32) * (m->even_index + 2 + m->extra_metas); | ||
| 12049 | + builtin__map_reserve_metas(m, meta_bytes); | ||
| 12050 | +} | ||
| 12051 | +VV_LOC void builtin__map_reserve_metas(map* m, u32 meta_bytes) { | ||
| 12052 | + { // Unsafe block | ||
| 12053 | + u8* x = builtin__v_realloc(((byteptr)(m->metas)), ((int)(meta_bytes))); | ||
| 12054 | + m->metas = ((u32*)(x)); | ||
| 12055 | + builtin__vmemset(m->metas, 0, ((int)(meta_bytes))); | ||
| 12056 | + } | ||
| 12057 | + for (int i = 0; i < m->key_values.len; i++) { | ||
| 12058 | + if (!builtin__DenseArray_has_index(&m->key_values, i)) { | ||
| 12059 | + continue; | ||
| 12060 | + } | ||
| 12061 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, i); | ||
| 12062 | + multi_return_u32_u32 mr_16309 = builtin__map_key_to_index(m, pkey); | ||
| 12063 | + u32 index = mr_16309.arg0; | ||
| 12064 | + u32 meta = mr_16309.arg1; | ||
| 12065 | + multi_return_u32_u32 mr_16347 = builtin__map_meta_less(m, index, meta); | ||
| 12066 | + index = mr_16347.arg0; | ||
| 12067 | + meta = mr_16347.arg1; | ||
| 12068 | + builtin__map_meta_greater(m, index, meta, ((u32)(i))); | ||
| 12069 | + } | ||
| 12070 | +} | ||
| 12071 | +void builtin__map_reserve(map* m, u32 n) { | ||
| 12072 | + for (;;) { | ||
| 12073 | + if (!(((u64)(n)) * 5 > ((u64)(m->even_index)) * 2)) break; | ||
| 12074 | + builtin__map_expand(m); | ||
| 12075 | + } | ||
| 12076 | +} | ||
| 12077 | +VV_LOC void builtin__map_cached_rehash(map* m, u32 old_cap) { | ||
| 12078 | + u32* old_metas = m->metas; | ||
| 12079 | + int metasize = ((int)(sizeof(u32) * (m->even_index + 2 + m->extra_metas))); | ||
| 12080 | + m->metas = ((u32*)(builtin__vcalloc(metasize))); | ||
| 12081 | + u32 old_extra_metas = m->extra_metas; | ||
| 12082 | + for (u32 i = ((u32)(0)); i <= old_cap + old_extra_metas; i += 2) { | ||
| 12083 | + if (old_metas[i] == 0) { | ||
| 12084 | + continue; | ||
| 12085 | + } | ||
| 12086 | + u32 old_meta = old_metas[i]; | ||
| 12087 | + u32 old_probe_count = v__lshift_u32(((v__rshift_u32(old_meta, (u64)_const_hashbits)) - 1), (u64)1); | ||
| 12088 | + u32 old_index = ((i - old_probe_count) & (v__rshift_u32(m->even_index, (u64)1))); | ||
| 12089 | + u32 index = (((old_index | (v__lshift_u32(old_meta, (u64)m->shift)))) & m->even_index); | ||
| 12090 | + u32 meta = (((old_meta & _const_hash_mask)) | _const_probe_inc); | ||
| 12091 | + u32 kv_index = old_metas[i + 1]; | ||
| 12092 | + multi_return_u32_u32 mr_17370 = builtin__map_meta_less(m, index, meta); | ||
| 12093 | + index = mr_17370.arg0; | ||
| 12094 | + meta = mr_17370.arg1; | ||
| 12095 | + builtin__map_meta_greater(m, index, meta, kv_index); | ||
| 12096 | + } | ||
| 12097 | + builtin___v_free(old_metas); | ||
| 12098 | +} | ||
| 12099 | +VV_LOC voidptr builtin__map_get_and_set(map* m, voidptr key, voidptr zero) { | ||
| 12100 | + for (;;) { | ||
| 12101 | + multi_return_u32_u32 mr_17776 = builtin__map_key_to_index(m, key); | ||
| 12102 | + u32 index = mr_17776.arg0; | ||
| 12103 | + u32 meta = mr_17776.arg1; | ||
| 12104 | + for (;;) { | ||
| 12105 | + if (meta == m->metas[index]) { | ||
| 12106 | + int kv_index = ((int)(m->metas[index + 1])); | ||
| 12107 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | ||
| 12108 | + if (m->key_eq_fn(key, pkey)) { | ||
| 12109 | + voidptr pval = builtin__DenseArray_value(&m->key_values, kv_index); | ||
| 12110 | + return ((u8*)(pval)); | ||
| 12111 | + } | ||
| 12112 | + } | ||
| 12113 | + index += 2; | ||
| 12114 | + meta += _const_probe_inc; | ||
| 12115 | + if (meta > m->metas[index]) { | ||
| 12116 | + break; | ||
| 12117 | + } | ||
| 12118 | + } | ||
| 12119 | + builtin__map_set(m, key, zero); | ||
| 12120 | + } | ||
| 12121 | + return ((void*)0); | ||
| 12122 | +} | ||
| 12123 | +VV_LOC voidptr builtin__map_get(map* m, voidptr key, voidptr zero) { | ||
| 12124 | + if (m->len == 0) { | ||
| 12125 | + return zero; | ||
| 12126 | + } | ||
| 12127 | + multi_return_u32_u32 mr_18537 = builtin__map_key_to_index(m, key); | ||
| 12128 | + u32 index = mr_18537.arg0; | ||
| 12129 | + u32 meta = mr_18537.arg1; | ||
| 12130 | + for (;;) { | ||
| 12131 | + if (meta == m->metas[index]) { | ||
| 12132 | + int kv_index = ((int)(m->metas[index + 1])); | ||
| 12133 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | ||
| 12134 | + if (m->key_eq_fn(key, pkey)) { | ||
| 12135 | + voidptr pval = builtin__DenseArray_value(&m->key_values, kv_index); | ||
| 12136 | + return ((u8*)(pval)); | ||
| 12137 | + } | ||
| 12138 | + } | ||
| 12139 | + index += 2; | ||
| 12140 | + meta += _const_probe_inc; | ||
| 12141 | + if (meta > m->metas[index]) { | ||
| 12142 | + break; | ||
| 12143 | + } | ||
| 12144 | + } | ||
| 12145 | + return zero; | ||
| 12146 | +} | ||
| 12147 | +VV_LOC voidptr builtin__map_get_check(map* m, voidptr key) { | ||
| 12148 | + if (m->len == 0) { | ||
| 12149 | + return 0; | ||
| 12150 | + } | ||
| 12151 | + multi_return_u32_u32 mr_19233 = builtin__map_key_to_index(m, key); | ||
| 12152 | + u32 index = mr_19233.arg0; | ||
| 12153 | + u32 meta = mr_19233.arg1; | ||
| 12154 | + for (;;) { | ||
| 12155 | + if (meta == m->metas[index]) { | ||
| 12156 | + int kv_index = ((int)(m->metas[index + 1])); | ||
| 12157 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | ||
| 12158 | + if (m->key_eq_fn(key, pkey)) { | ||
| 12159 | + voidptr pval = builtin__DenseArray_value(&m->key_values, kv_index); | ||
| 12160 | + return ((u8*)(pval)); | ||
| 12161 | + } | ||
| 12162 | + } | ||
| 12163 | + index += 2; | ||
| 12164 | + meta += _const_probe_inc; | ||
| 12165 | + if (meta > m->metas[index]) { | ||
| 12166 | + break; | ||
| 12167 | + } | ||
| 12168 | + } | ||
| 12169 | + return 0; | ||
| 12170 | +} | ||
| 12171 | +VV_LOC bool builtin__map_exists(map* m, voidptr key) { | ||
| 12172 | + if (m->len == 0) { | ||
| 12173 | + return false; | ||
| 12174 | + } | ||
| 12175 | + multi_return_u32_u32 mr_19778 = builtin__map_key_to_index(m, key); | ||
| 12176 | + u32 index = mr_19778.arg0; | ||
| 12177 | + u32 meta = mr_19778.arg1; | ||
| 12178 | + for (;;) { | ||
| 12179 | + if (meta == m->metas[index]) { | ||
| 12180 | + int kv_index = ((int)(m->metas[index + 1])); | ||
| 12181 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | ||
| 12182 | + if (m->key_eq_fn(key, pkey)) { | ||
| 12183 | + return true; | ||
| 12184 | + } | ||
| 12185 | + } | ||
| 12186 | + index += 2; | ||
| 12187 | + meta += _const_probe_inc; | ||
| 12188 | + if (meta > m->metas[index]) { | ||
| 12189 | + break; | ||
| 12190 | + } | ||
| 12191 | + } | ||
| 12192 | + return false; | ||
| 12193 | +} | ||
| 12194 | +inline VV_LOC void builtin__DenseArray_delete(DenseArray* d, int i) { | ||
| 12195 | + if (i == d->len - 1) { | ||
| 12196 | + d->len--; | ||
| 12197 | + builtin__DenseArray_trim_deleted_tail(d); | ||
| 12198 | + return; | ||
| 12199 | + } | ||
| 12200 | + if (d->deletes == 0) { | ||
| 12201 | + d->all_deleted = builtin__vcalloc(d->cap); | ||
| 12202 | + } | ||
| 12203 | + d->deletes++; | ||
| 12204 | + { // Unsafe block | ||
| 12205 | + d->all_deleted[i] = 1; | ||
| 12206 | + } | ||
| 12207 | +} | ||
| 12208 | +void builtin__map_delete(map* m, voidptr key) { | ||
| 12209 | + multi_return_u32_u32 mr_20483 = builtin__map_key_to_index(m, key); | ||
| 12210 | + u32 index = mr_20483.arg0; | ||
| 12211 | + u32 meta = mr_20483.arg1; | ||
| 12212 | + multi_return_u32_u32 mr_20519 = builtin__map_meta_less(m, index, meta); | ||
| 12213 | + index = mr_20519.arg0; | ||
| 12214 | + meta = mr_20519.arg1; | ||
| 12215 | + for (;;) { | ||
| 12216 | + if (!(meta == m->metas[index])) break; | ||
| 12217 | + int kv_index = ((int)(m->metas[index + 1])); | ||
| 12218 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, kv_index); | ||
| 12219 | + if (m->key_eq_fn(key, pkey)) { | ||
| 12220 | + for (;;) { | ||
| 12221 | + if (!((v__rshift_u32(m->metas[index + 2], (u64)_const_hashbits)) > 1)) break; | ||
| 12222 | + { // Unsafe block | ||
| 12223 | + m->metas[index] = m->metas[index + 2] - _const_probe_inc; | ||
| 12224 | + m->metas[index + 1] = m->metas[index + 3]; | ||
| 12225 | + } | ||
| 12226 | + index += 2; | ||
| 12227 | + } | ||
| 12228 | + m->len--; | ||
| 12229 | + builtin__DenseArray_delete(&m->key_values, kv_index); | ||
| 12230 | + { // Unsafe block | ||
| 12231 | + m->metas[index] = 0; | ||
| 12232 | + m->free_fn(pkey); | ||
| 12233 | + builtin__vmemset(pkey, 0, m->key_bytes); | ||
| 12234 | + } | ||
| 12235 | + if (m->key_values.len <= 32) { | ||
| 12236 | + return; | ||
| 12237 | + } | ||
| 12238 | + if (_us32_ge(m->key_values.deletes,(v__rshift_int(m->key_values.len, (u64)1)))) { | ||
| 12239 | + builtin__DenseArray_zeros_to_end(&m->key_values); | ||
| 12240 | + builtin__map_rehash(m); | ||
| 12241 | + } | ||
| 12242 | + return; | ||
| 12243 | + } | ||
| 12244 | + index += 2; | ||
| 12245 | + meta += _const_probe_inc; | ||
| 12246 | + } | ||
| 12247 | +} | ||
| 12248 | +array builtin__map_keys(map* m) { | ||
| 12249 | + array keys = builtin____new_array(m->len, 0, m->key_bytes); | ||
| 12250 | + u8* item = ((u8*)(keys.data)); | ||
| 12251 | + if (m->key_values.deletes == 0) { | ||
| 12252 | + for (int i = 0; i < m->key_values.len; i++) { | ||
| 12253 | + { // Unsafe block | ||
| 12254 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, i); | ||
| 12255 | + m->clone_fn(item, pkey); | ||
| 12256 | + item = item + m->key_bytes; | ||
| 12257 | + } | ||
| 12258 | + } | ||
| 12259 | + return keys; | ||
| 12260 | + } | ||
| 12261 | + for (int i = 0; i < m->key_values.len; i++) { | ||
| 12262 | + if (!builtin__DenseArray_has_index(&m->key_values, i)) { | ||
| 12263 | + continue; | ||
| 12264 | + } | ||
| 12265 | + { // Unsafe block | ||
| 12266 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, i); | ||
| 12267 | + m->clone_fn(item, pkey); | ||
| 12268 | + item = item + m->key_bytes; | ||
| 12269 | + } | ||
| 12270 | + } | ||
| 12271 | + return keys; | ||
| 12272 | +} | ||
| 12273 | +array builtin__map_values(map* m) { | ||
| 12274 | + array values = builtin____new_array(m->len, 0, m->value_bytes); | ||
| 12275 | + u8* item = ((u8*)(values.data)); | ||
| 12276 | + if (m->key_values.deletes == 0) { | ||
| 12277 | + builtin__vmemcpy(item, m->key_values.values, m->value_bytes * m->key_values.len); | ||
| 12278 | + return values; | ||
| 12279 | + } | ||
| 12280 | + for (int i = 0; i < m->key_values.len; i++) { | ||
| 12281 | + if (!builtin__DenseArray_has_index(&m->key_values, i)) { | ||
| 12282 | + continue; | ||
| 12283 | + } | ||
| 12284 | + { // Unsafe block | ||
| 12285 | + voidptr pvalue = builtin__DenseArray_value(&m->key_values, i); | ||
| 12286 | + builtin__vmemcpy(item, pvalue, m->value_bytes); | ||
| 12287 | + item = item + m->value_bytes; | ||
| 12288 | + } | ||
| 12289 | + } | ||
| 12290 | + return values; | ||
| 12291 | +} | ||
| 12292 | +VV_LOC DenseArray builtin__DenseArray_clone(DenseArray* d) { | ||
| 12293 | + DenseArray res = ((DenseArray){ | ||
| 12294 | + .key_bytes = d->key_bytes, | ||
| 12295 | + .value_bytes = d->value_bytes, | ||
| 12296 | + .cap = d->cap, | ||
| 12297 | + .len = d->len, | ||
| 12298 | + .deletes = d->deletes, | ||
| 12299 | + .all_deleted = ((void*)0), | ||
| 12300 | + .keys = ((void*)0), | ||
| 12301 | + .values = ((void*)0), | ||
| 12302 | + }); | ||
| 12303 | + { // Unsafe block | ||
| 12304 | + if (d->deletes != 0) { | ||
| 12305 | + res.all_deleted = builtin__memdup(d->all_deleted, d->cap); | ||
| 12306 | + } | ||
| 12307 | + res.keys = builtin__memdup(d->keys, d->cap * d->key_bytes); | ||
| 12308 | + res.values = builtin__memdup(d->values, d->cap * d->value_bytes); | ||
| 12309 | + } | ||
| 12310 | + return res; | ||
| 12311 | +} | ||
| 12312 | +map builtin__map_clone(map* m) { | ||
| 12313 | + int metasize = ((int)(sizeof(u32) * (m->even_index + 2 + m->extra_metas))); | ||
| 12314 | + map res = ((map){ | ||
| 12315 | + .key_bytes = m->key_bytes, | ||
| 12316 | + .value_bytes = m->value_bytes, | ||
| 12317 | + .even_index = m->even_index, | ||
| 12318 | + .cached_hashbits = m->cached_hashbits, | ||
| 12319 | + .shift = m->shift, | ||
| 12320 | + .key_values = builtin__DenseArray_clone(&m->key_values), | ||
| 12321 | + .metas = ((u32*)(builtin__malloc_noscan(metasize))), | ||
| 12322 | + .extra_metas = m->extra_metas, | ||
| 12323 | + .has_string_keys = m->has_string_keys, | ||
| 12324 | + .hash_fn = m->hash_fn, | ||
| 12325 | + .key_eq_fn = m->key_eq_fn, | ||
| 12326 | + .clone_fn = m->clone_fn, | ||
| 12327 | + .free_fn = m->free_fn, | ||
| 12328 | + .len = m->len, | ||
| 12329 | + }); | ||
| 12330 | + builtin__vmemcpy(res.metas, m->metas, metasize); | ||
| 12331 | + if (!m->has_string_keys) { | ||
| 12332 | + return res; | ||
| 12333 | + } | ||
| 12334 | + for (int i = 0; i < m->key_values.len; ++i) { | ||
| 12335 | + if (!builtin__DenseArray_has_index(&m->key_values, i)) { | ||
| 12336 | + continue; | ||
| 12337 | + } | ||
| 12338 | + m->clone_fn(builtin__DenseArray_key(&res.key_values, i), builtin__DenseArray_key(&m->key_values, i)); | ||
| 12339 | + } | ||
| 12340 | + return res; | ||
| 12341 | +} | ||
| 12342 | +void builtin__map_free(map* m) { | ||
| 12343 | + builtin___v_free(m->metas); | ||
| 12344 | + { // Unsafe block | ||
| 12345 | + m->metas = ((void*)0); | ||
| 12346 | + } | ||
| 12347 | + if (m->key_values.deletes == 0) { | ||
| 12348 | + for (int i = 0; i < m->key_values.len; i++) { | ||
| 12349 | + { // Unsafe block | ||
| 12350 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, i); | ||
| 12351 | + m->free_fn(pkey); | ||
| 12352 | + builtin__vmemset(pkey, 0, m->key_bytes); | ||
| 12353 | + } | ||
| 12354 | + } | ||
| 12355 | + } else { | ||
| 12356 | + for (int i = 0; i < m->key_values.len; i++) { | ||
| 12357 | + if (!builtin__DenseArray_has_index(&m->key_values, i)) { | ||
| 12358 | + continue; | ||
| 12359 | + } | ||
| 12360 | + { // Unsafe block | ||
| 12361 | + voidptr pkey = builtin__DenseArray_key(&m->key_values, i); | ||
| 12362 | + m->free_fn(pkey); | ||
| 12363 | + builtin__vmemset(pkey, 0, m->key_bytes); | ||
| 12364 | + } | ||
| 12365 | + } | ||
| 12366 | + } | ||
| 12367 | + { // Unsafe block | ||
| 12368 | + if (m->key_values.all_deleted != ((void*)0)) { | ||
| 12369 | + builtin___v_free(m->key_values.all_deleted); | ||
| 12370 | + m->key_values.all_deleted = ((void*)0); | ||
| 12371 | + } | ||
| 12372 | + if (m->key_values.keys != ((void*)0)) { | ||
| 12373 | + builtin___v_free(m->key_values.keys); | ||
| 12374 | + m->key_values.keys = ((void*)0); | ||
| 12375 | + } | ||
| 12376 | + if (m->key_values.values != ((void*)0)) { | ||
| 12377 | + builtin___v_free(m->key_values.values); | ||
| 12378 | + m->key_values.values = ((void*)0); | ||
| 12379 | + } | ||
| 12380 | + m->hash_fn = ((void*)0); | ||
| 12381 | + m->key_eq_fn = ((void*)0); | ||
| 12382 | + m->clone_fn = ((void*)0); | ||
| 12383 | + m->free_fn = ((void*)0); | ||
| 12384 | + m->key_values.cap = 0; | ||
| 12385 | + m->key_values.len = 0; | ||
| 12386 | + m->key_values.deletes = 0; | ||
| 12387 | + m->even_index = 0; | ||
| 12388 | + m->cached_hashbits = 0; | ||
| 12389 | + m->shift = 0; | ||
| 12390 | + m->extra_metas = 0; | ||
| 12391 | + m->has_string_keys = false; | ||
| 12392 | + m->len = 0; | ||
| 12393 | + } | ||
| 12394 | +} | ||
| 12395 | +void builtin__VAssertMetaInfo_free(VAssertMetaInfo* ami) { | ||
| 12396 | + { // Unsafe block | ||
| 12397 | + builtin__string_free(&ami->fpath); | ||
| 12398 | + builtin__string_free(&ami->fn_name); | ||
| 12399 | + builtin__string_free(&ami->src); | ||
| 12400 | + builtin__string_free(&ami->op); | ||
| 12401 | + builtin__string_free(&ami->llabel); | ||
| 12402 | + builtin__string_free(&ami->rlabel); | ||
| 12403 | + builtin__string_free(&ami->lvalue); | ||
| 12404 | + builtin__string_free(&ami->rvalue); | ||
| 12405 | + builtin__string_free(&ami->message); | ||
| 12406 | + } | ||
| 12407 | +} | ||
| 12408 | +void builtin__IError_free(IError* ie) { | ||
| 12409 | + { // Unsafe block | ||
| 12410 | + IError* cie = ((IError*)(ie)); | ||
| 12411 | + builtin___v_free(cie->_object); | ||
| 12412 | + } | ||
| 12413 | +} | ||
| 12414 | +VNORETURN void builtin__panic_option_not_set(string s) { | ||
| 12415 | + builtin___v_panic(builtin__string_plus_many(3, _MOV((string[3]){_S("option not set ("), s, _S(")")}))); | ||
| 12416 | + VUNREACHABLE(); | ||
| 12417 | + while(1); | ||
| 12418 | +} | ||
| 12419 | +VNORETURN void builtin__panic_result_not_set(string s) { | ||
| 12420 | + builtin___v_panic(builtin__string_plus_many(3, _MOV((string[3]){_S("result not set ("), s, _S(")")}))); | ||
| 12421 | + VUNREACHABLE(); | ||
| 12422 | + while(1); | ||
| 12423 | +} | ||
| 12424 | +VNORETURN void builtin___v_panic(string s) { | ||
| 12425 | + #if 0 | ||
| 12426 | + { | ||
| 12427 | + } | ||
| 12428 | + #elif defined(CUSTOM_DEFINE_v2_native_windows_pe_minimal) | ||
| 12429 | + { | ||
| 12430 | + } | ||
| 12431 | + #else | ||
| 12432 | + { | ||
| 12433 | + builtin__flush_stdout(); | ||
| 12434 | + builtin__eprint(_S("V panic: ")); | ||
| 12435 | + builtin__eprintln(s); | ||
| 12436 | + builtin__eprint(_S(" v hash: ")); | ||
| 12437 | + builtin__eprintln(builtin__vcurrent_hash()); | ||
| 12438 | + #if 1 | ||
| 12439 | + { | ||
| 12440 | + builtin__eprint(_S(" pid: ")); | ||
| 12441 | + ; | ||
| 12442 | + fprintf(stderr, "%p\n", ((voidptr)(builtin__v_getpid()))); | ||
| 12443 | + builtin__eprint(_S(" tid: ")); | ||
| 12444 | + ; | ||
| 12445 | + fprintf(stderr, "%p\n", ((voidptr)(builtin__v_gettid()))); | ||
| 12446 | + } | ||
| 12447 | + #endif | ||
| 12448 | + builtin__flush_stdout(); | ||
| 12449 | + #if defined(CUSTOM_DEFINE_exit_after_panic_message) | ||
| 12450 | + { | ||
| 12451 | + } | ||
| 12452 | + #elif defined(CUSTOM_DEFINE_no_backtrace) | ||
| 12453 | + { | ||
| 12454 | + } | ||
| 12455 | + #elif 0 | ||
| 12456 | + { | ||
| 12457 | + } | ||
| 12458 | + #else | ||
| 12459 | + { | ||
| 12460 | + #if defined(CUSTOM_DEFINE_use_libbacktrace) && !defined(__TINYC__) | ||
| 12461 | + { | ||
| 12462 | + } | ||
| 12463 | + #else | ||
| 12464 | + { | ||
| 12465 | + builtin__print_backtrace_skipping_top_frames(1); | ||
| 12466 | + } | ||
| 12467 | + #endif | ||
| 12468 | + exit(1); | ||
| 12469 | + VUNREACHABLE(); | ||
| 12470 | + } | ||
| 12471 | + #endif | ||
| 12472 | + } | ||
| 12473 | + #endif | ||
| 12474 | + exit(1); | ||
| 12475 | + VUNREACHABLE(); | ||
| 12476 | + for (;;) { | ||
| 12477 | + } | ||
| 12478 | + while(1); | ||
| 12479 | +} | ||
| 12480 | +string builtin__c_error_number_str(int errnum) { | ||
| 12481 | + string err_msg = _S(""); | ||
| 12482 | + #if 0 | ||
| 12483 | + { | ||
| 12484 | + } | ||
| 12485 | + #else | ||
| 12486 | + { | ||
| 12487 | + #if 1 | ||
| 12488 | + { | ||
| 12489 | + char* c_msg = strerror(errnum); | ||
| 12490 | + err_msg = ((string){.str = ((u8*)(c_msg)), .len = ((int)(strlen(c_msg))), .is_lit = 1}); | ||
| 12491 | + } | ||
| 12492 | + #endif | ||
| 12493 | + } | ||
| 12494 | + #endif | ||
| 12495 | + return err_msg; | ||
| 12496 | +} | ||
| 12497 | +VNORETURN void builtin__panic_n(string s, i64 number1) { | ||
| 12498 | + builtin___v_panic(builtin__string__plus(s, builtin__impl_i64_to_string(number1))); | ||
| 12499 | + VUNREACHABLE(); | ||
| 12500 | + while(1); | ||
| 12501 | +} | ||
| 12502 | +VNORETURN void builtin__panic_n2(string s, i64 number1, i64 number2) { | ||
| 12503 | + builtin___v_panic(builtin__string_plus_many(4, _MOV((string[4]){s, builtin__impl_i64_to_string(number1), _S(", "), builtin__impl_i64_to_string(number2)}))); | ||
| 12504 | + VUNREACHABLE(); | ||
| 12505 | + while(1); | ||
| 12506 | +} | ||
| 12507 | +VNORETURN VV_LOC void builtin__panic_n3(string s, i64 number1, i64 number2, i64 number3) { | ||
| 12508 | + builtin___v_panic(builtin__string_plus_many(6, _MOV((string[6]){s, builtin__impl_i64_to_string(number1), _S(", "), builtin__impl_i64_to_string(number2), _S(", "), builtin__impl_i64_to_string(number3)}))); | ||
| 12509 | + VUNREACHABLE(); | ||
| 12510 | + while(1); | ||
| 12511 | +} | ||
| 12512 | +VNORETURN void builtin__panic_error_number(string basestr, int errnum) { | ||
| 12513 | + builtin___v_panic(builtin__string__plus(basestr, builtin__c_error_number_str(errnum))); | ||
| 12514 | + VUNREACHABLE(); | ||
| 12515 | + while(1); | ||
| 12516 | +} | ||
| 12517 | +VV_LOC void builtin__set_stream_unbuffered(FILE* stream) { | ||
| 12518 | + setvbuf(stream, ((char*)(((void*)0))), _IONBF, ((usize)(0))); | ||
| 12519 | +} | ||
| 12520 | +void builtin__eprintln(string s) { | ||
| 12521 | + #if 0 | ||
| 12522 | + { | ||
| 12523 | + } | ||
| 12524 | + #elif 0 | ||
| 12525 | + { | ||
| 12526 | + } | ||
| 12527 | + #else | ||
| 12528 | + { | ||
| 12529 | + builtin__flush_stdout(); | ||
| 12530 | + builtin__flush_stderr(); | ||
| 12531 | + builtin___writeln_to_fd(2, s); | ||
| 12532 | + builtin__flush_stderr(); | ||
| 12533 | + } | ||
| 12534 | + #endif | ||
| 12535 | +} | ||
| 12536 | +void builtin__eprint(string s) { | ||
| 12537 | + #if 0 | ||
| 12538 | + { | ||
| 12539 | + } | ||
| 12540 | + #elif 0 | ||
| 12541 | + { | ||
| 12542 | + } | ||
| 12543 | + #else | ||
| 12544 | + { | ||
| 12545 | + builtin__flush_stdout(); | ||
| 12546 | + builtin__flush_stderr(); | ||
| 12547 | + builtin___write_buf_to_fd(2, s.str, s.len); | ||
| 12548 | + builtin__flush_stderr(); | ||
| 12549 | + } | ||
| 12550 | + #endif | ||
| 12551 | +} | ||
| 12552 | +void builtin__flush_stdout(void) { | ||
| 12553 | + #if defined(CUSTOM_DEFINE_v2_native_windows_pe_minimal) | ||
| 12554 | + { | ||
| 12555 | + } | ||
| 12556 | + #elif 0 | ||
| 12557 | + { | ||
| 12558 | + } | ||
| 12559 | + #elif defined(CUSTOM_DEFINE_builtin_write_buf_to_fd_should_use_c_write) | ||
| 12560 | + { | ||
| 12561 | + } | ||
| 12562 | + #else | ||
| 12563 | + { | ||
| 12564 | + fflush(stdout); | ||
| 12565 | + } | ||
| 12566 | + #endif | ||
| 12567 | +} | ||
| 12568 | +void builtin__flush_stderr(void) { | ||
| 12569 | + #if defined(CUSTOM_DEFINE_v2_native_windows_pe_minimal) | ||
| 12570 | + { | ||
| 12571 | + } | ||
| 12572 | + #elif 0 | ||
| 12573 | + { | ||
| 12574 | + } | ||
| 12575 | + #elif defined(CUSTOM_DEFINE_builtin_write_buf_to_fd_should_use_c_write) | ||
| 12576 | + { | ||
| 12577 | + } | ||
| 12578 | + #else | ||
| 12579 | + { | ||
| 12580 | + fflush(stderr); | ||
| 12581 | + } | ||
| 12582 | + #endif | ||
| 12583 | +} | ||
| 12584 | +void builtin__unbuffer_stdout(void) { | ||
| 12585 | + #if 0 | ||
| 12586 | + { | ||
| 12587 | + } | ||
| 12588 | + #elif 0 | ||
| 12589 | + { | ||
| 12590 | + } | ||
| 12591 | + #elif defined(CUSTOM_DEFINE_builtin_write_buf_to_fd_should_use_c_write) | ||
| 12592 | + { | ||
| 12593 | + } | ||
| 12594 | + #else | ||
| 12595 | + { | ||
| 12596 | + builtin__set_stream_unbuffered(stdout); | ||
| 12597 | + } | ||
| 12598 | + #endif | ||
| 12599 | +} | ||
| 12600 | +void builtin__print(string s) { | ||
| 12601 | + #if 0 | ||
| 12602 | + { | ||
| 12603 | + } | ||
| 12604 | + #elif 0 | ||
| 12605 | + { | ||
| 12606 | + } | ||
| 12607 | + #elif 0 | ||
| 12608 | + { | ||
| 12609 | + } | ||
| 12610 | + #else | ||
| 12611 | + { | ||
| 12612 | + builtin___write_buf_to_fd(1, s.str, s.len); | ||
| 12613 | + } | ||
| 12614 | + #endif | ||
| 12615 | +} | ||
| 12616 | +void builtin__println(string s) { | ||
| 12617 | + #if 0 | ||
| 12618 | + { | ||
| 12619 | + } | ||
| 12620 | + #elif 0 | ||
| 12621 | + { | ||
| 12622 | + } | ||
| 12623 | + #elif 0 | ||
| 12624 | + { | ||
| 12625 | + } | ||
| 12626 | + #else | ||
| 12627 | + { | ||
| 12628 | + builtin___writeln_to_fd(1, s); | ||
| 12629 | + } | ||
| 12630 | + #endif | ||
| 12631 | +} | ||
| 12632 | +VV_LOC void builtin___writeln_to_fd(int fd, string s) { | ||
| 12633 | + #if defined(CUSTOM_DEFINE_builtin_writeln_should_write_at_once) | ||
| 12634 | + { | ||
| 12635 | + } | ||
| 12636 | + #else | ||
| 12637 | + { | ||
| 12638 | + u8 lf = ((u8)('\n')); | ||
| 12639 | + builtin___write_buf_to_fd(fd, s.str, s.len); | ||
| 12640 | + builtin___write_buf_to_fd(fd, &lf, 1); | ||
| 12641 | + } | ||
| 12642 | + #endif | ||
| 12643 | +} | ||
| 12644 | +VV_LOC void builtin___write_buf_to_fd(int fd, u8* buf, int buf_len) { | ||
| 12645 | + if (buf_len <= 0) { | ||
| 12646 | + return; | ||
| 12647 | + } | ||
| 12648 | + #if 0 | ||
| 12649 | + { | ||
| 12650 | + } | ||
| 12651 | + #else | ||
| 12652 | + { | ||
| 12653 | + u8* ptr = buf; | ||
| 12654 | + isize remaining_bytes = ((isize)(buf_len)); | ||
| 12655 | + isize x = ((isize)(0)); | ||
| 12656 | + #if 0 | ||
| 12657 | + { | ||
| 12658 | + } | ||
| 12659 | + #else | ||
| 12660 | + { | ||
| 12661 | + voidptr stream = ((voidptr)(stdout)); | ||
| 12662 | + if (fd == 2) { | ||
| 12663 | + stream = ((voidptr)(stderr)); | ||
| 12664 | + } | ||
| 12665 | + { // Unsafe block | ||
| 12666 | + for (;;) { | ||
| 12667 | + if (!(remaining_bytes > 0)) break; | ||
| 12668 | + x = ((isize)(fwrite(ptr, 1, remaining_bytes, stream))); | ||
| 12669 | + if (x <= 0) { | ||
| 12670 | + break; | ||
| 12671 | + } | ||
| 12672 | + ptr += x; | ||
| 12673 | + remaining_bytes -= x; | ||
| 12674 | + } | ||
| 12675 | + } | ||
| 12676 | + } | ||
| 12677 | + #endif | ||
| 12678 | + } | ||
| 12679 | + #endif | ||
| 12680 | +} | ||
| 12681 | +string builtin__reuse_data_as_string(Array_u8 buffer) { | ||
| 12682 | + return ((string){.str = buffer.data, .len = buffer.len, .is_lit = 1}); | ||
| 12683 | +} | ||
| 12684 | +Array_u8 builtin__reuse_string_as_data(string s) { | ||
| 12685 | + array res = ((array){.data = (voidptr)s.str,.offset = 0,.len = s.len,.cap = 0,.flags = ((ArrayFlags__nogrow | ArrayFlags__noshrink) | ArrayFlags__nofree),.element_size = 1,}); | ||
| 12686 | + return res; | ||
| 12687 | +} | ||
| 12688 | +string builtin__rune_str(rune c) { | ||
| 12689 | + return builtin__utf32_to_str(((u32)(c))); | ||
| 12690 | +} | ||
| 12691 | +string Array_rune_string(Array_rune ra) { | ||
| 12692 | + strings__Builder sb = strings__new_builder(ra.len); | ||
| 12693 | + strings__Builder_write_runes(&sb, ra); | ||
| 12694 | + string res = strings__Builder_str(&sb); | ||
| 12695 | + strings__Builder_free(&sb); | ||
| 12696 | + return res; | ||
| 12697 | +} | ||
| 12698 | +string builtin__rune_repeat(rune c, int count) { | ||
| 12699 | + if (count <= 0) { | ||
| 12700 | + return _S(""); | ||
| 12701 | + } else if (count == 1) { | ||
| 12702 | + return builtin__rune_str(c); | ||
| 12703 | + } | ||
| 12704 | + Array_fixed_u8_5 buffer = {0}; | ||
| 12705 | + string res = builtin__utf32_to_str_no_malloc(((u32)(c)), &buffer[0]); | ||
| 12706 | + return builtin__string_repeat(res, count); | ||
| 12707 | +} | ||
| 12708 | +Array_u8 builtin__rune_bytes(rune c) { | ||
| 12709 | + Array_u8 res = builtin____new_array_with_default(0, 5, sizeof(u8), 0); | ||
| 12710 | + u8* buf = ((u8*)(res.data)); | ||
| 12711 | + res.len = builtin__utf32_decode_to_buffer(((u32)(c)), buf); | ||
| 12712 | + return res; | ||
| 12713 | +} | ||
| 12714 | +int builtin__rune_length_in_bytes(rune c) { | ||
| 12715 | + u32 code = ((u32)(c)); | ||
| 12716 | + if (code <= 0x7F) { | ||
| 12717 | + return 1; | ||
| 12718 | + } else if (code <= 0x7FF) { | ||
| 12719 | + return 2; | ||
| 12720 | + } else if (0xD800 <= code && code <= 0xDFFF) { | ||
| 12721 | + return -1; | ||
| 12722 | + } else if (code <= 0xFFFF) { | ||
| 12723 | + return 3; | ||
| 12724 | + } else if (code <= 0x10FFFF) { | ||
| 12725 | + return 4; | ||
| 12726 | + } | ||
| 12727 | + return -1; | ||
| 12728 | +} | ||
| 12729 | +rune builtin__rune_to_upper(rune c) { | ||
| 12730 | + if (c < 0x80) { | ||
| 12731 | + if (c >= 'a' && c <= 'z') { | ||
| 12732 | + return c - 32; | ||
| 12733 | + } | ||
| 12734 | + return c; | ||
| 12735 | + } | ||
| 12736 | + return builtin__rune_map_to(c, MapMode__to_upper); | ||
| 12737 | +} | ||
| 12738 | +rune builtin__rune_to_lower(rune c) { | ||
| 12739 | + if (c < 0x80) { | ||
| 12740 | + if (c >= 'A' && c <= 'Z') { | ||
| 12741 | + return c + 32; | ||
| 12742 | + } | ||
| 12743 | + return c; | ||
| 12744 | + } | ||
| 12745 | + return builtin__rune_map_to(c, MapMode__to_lower); | ||
| 12746 | +} | ||
| 12747 | +rune builtin__rune_to_title(rune c) { | ||
| 12748 | + if (c < 0x80) { | ||
| 12749 | + if (c >= 'a' && c <= 'z') { | ||
| 12750 | + return c - 32; | ||
| 12751 | + } | ||
| 12752 | + return c; | ||
| 12753 | + } | ||
| 12754 | + return builtin__rune_map_to(c, MapMode__to_title); | ||
| 12755 | +} | ||
| 12756 | +VV_LOC rune builtin__rune_map_to(rune c, MapMode mode) { | ||
| 12757 | + int start = 0; | ||
| 12758 | + int end = VSAFE_DIV_int(1264 , _const_rune_maps_columns_in_row); | ||
| 12759 | + for (;;) { | ||
| 12760 | + if (!(start < end)) break; | ||
| 12761 | + int middle = VSAFE_DIV_int((start + end) , 2); | ||
| 12762 | + i32* cur_map = &_const_rune_maps[middle * _const_rune_maps_columns_in_row]; | ||
| 12763 | + if (c >= ((u32)(*cur_map)) && c <= ((u32)(*(cur_map + 1)))) { | ||
| 12764 | + i32 offset = ((mode == MapMode__to_upper || mode == MapMode__to_title) ? (*(cur_map + 2)) : (*(cur_map + 3))); | ||
| 12765 | + if (offset == _const_rune_maps_ul) { | ||
| 12766 | + rune cnt = VSAFE_MOD_rune(((rune)(c - *cur_map)) , 2); | ||
| 12767 | + if (mode == MapMode__to_lower) { | ||
| 12768 | + return c + 1 - cnt; | ||
| 12769 | + } | ||
| 12770 | + return c - cnt; | ||
| 12771 | + } else if (offset == _const_rune_maps_utl) { | ||
| 12772 | + rune cnt = VSAFE_MOD_rune(((rune)(c - *cur_map)) , 3); | ||
| 12773 | + if (mode == MapMode__to_upper) { | ||
| 12774 | + return c - cnt; | ||
| 12775 | + } else if (mode == MapMode__to_lower) { | ||
| 12776 | + return c + 2 - cnt; | ||
| 12777 | + } | ||
| 12778 | + return c + 1 - cnt; | ||
| 12779 | + } | ||
| 12780 | + return (rune)(c + offset); | ||
| 12781 | + } | ||
| 12782 | + if (c < ((u32)(*cur_map))) { | ||
| 12783 | + end = middle; | ||
| 12784 | + } else { | ||
| 12785 | + start = middle + 1; | ||
| 12786 | + } | ||
| 12787 | + } | ||
| 12788 | + return c; | ||
| 12789 | +} | ||
| 12790 | +VV_LOC int builtin__mapnode_find_key(mapnode* n, string k) { | ||
| 12791 | + int idx = 0; | ||
| 12792 | + for (;;) { | ||
| 12793 | + if (!(idx < n->len && builtin__string__lt(n->keys[builtin__v_fixed_index(idx, 11)], k))) break; | ||
| 12794 | + idx++; | ||
| 12795 | + } | ||
| 12796 | + return idx; | ||
| 12797 | +} | ||
| 12798 | +VV_LOC bool builtin__mapnode_remove_key(mapnode* n, string k) { | ||
| 12799 | + int idx = builtin__mapnode_find_key(n, k); | ||
| 12800 | + if (idx < n->len && builtin__string__eq(n->keys[builtin__v_fixed_index(idx, 11)], k)) { | ||
| 12801 | + if (n->children == ((void*)0)) { | ||
| 12802 | + builtin__mapnode_remove_from_leaf(n, idx); | ||
| 12803 | + } else { | ||
| 12804 | + builtin__mapnode_remove_from_non_leaf(n, idx); | ||
| 12805 | + } | ||
| 12806 | + return true; | ||
| 12807 | + } else { | ||
| 12808 | + if (n->children == ((void*)0)) { | ||
| 12809 | + return false; | ||
| 12810 | + } | ||
| 12811 | + bool flag = (idx == n->len ? (true) : (false)); | ||
| 12812 | + if (((mapnode*)(n->children[idx]))->len < _const_degree) { | ||
| 12813 | + builtin__mapnode_fill(n, idx); | ||
| 12814 | + } | ||
| 12815 | + mapnode* node = ((mapnode*)(((void*)0))); | ||
| 12816 | + if (flag && idx > n->len) { | ||
| 12817 | + node = ((mapnode*)(n->children[idx - 1])); | ||
| 12818 | + } else { | ||
| 12819 | + node = ((mapnode*)(n->children[idx])); | ||
| 12820 | + } | ||
| 12821 | + return builtin__mapnode_remove_key(node, k); | ||
| 12822 | + } | ||
| 12823 | + return 0; | ||
| 12824 | +} | ||
| 12825 | +VV_LOC void builtin__mapnode_remove_from_leaf(mapnode* n, int idx) { | ||
| 12826 | + for (int i = idx + 1; i < n->len; i++) { | ||
| 12827 | + n->keys[builtin__v_fixed_index(i - 1, 11)] = n->keys[builtin__v_fixed_index(i, 11)]; | ||
| 12828 | + n->values[builtin__v_fixed_index(i - 1, 11)] = n->values[builtin__v_fixed_index(i, 11)]; | ||
| 12829 | + } | ||
| 12830 | + n->len--; | ||
| 12831 | +} | ||
| 12832 | +VV_LOC void builtin__mapnode_remove_from_non_leaf(mapnode* n, int idx) { | ||
| 12833 | + string k = n->keys[builtin__v_fixed_index(idx, 11)]; | ||
| 12834 | + if (((mapnode*)(n->children[idx]))->len >= _const_degree) { | ||
| 12835 | + mapnode* current = ((mapnode*)(n->children[idx])); | ||
| 12836 | + for (;;) { | ||
| 12837 | + if (!(current->children != ((void*)0))) break; | ||
| 12838 | + current = ((mapnode*)(current->children[current->len])); | ||
| 12839 | + } | ||
| 12840 | + string predecessor = current->keys[builtin__v_fixed_index(current->len - 1, 11)]; | ||
| 12841 | + n->keys[builtin__v_fixed_index(idx, 11)] = predecessor; | ||
| 12842 | + n->values[builtin__v_fixed_index(idx, 11)] = current->values[builtin__v_fixed_index(current->len - 1, 11)]; | ||
| 12843 | + mapnode* node = ((mapnode*)(n->children[idx])); | ||
| 12844 | + builtin__mapnode_remove_key(node, predecessor); | ||
| 12845 | + } else if (((mapnode*)(n->children[idx + 1]))->len >= _const_degree) { | ||
| 12846 | + mapnode* current = ((mapnode*)(n->children[idx + 1])); | ||
| 12847 | + for (;;) { | ||
| 12848 | + if (!(current->children != ((void*)0))) break; | ||
| 12849 | + current = ((mapnode*)(current->children[0])); | ||
| 12850 | + } | ||
| 12851 | + string successor = current->keys[0]; | ||
| 12852 | + n->keys[builtin__v_fixed_index(idx, 11)] = successor; | ||
| 12853 | + n->values[builtin__v_fixed_index(idx, 11)] = current->values[0]; | ||
| 12854 | + mapnode* node = ((mapnode*)(n->children[idx + 1])); | ||
| 12855 | + builtin__mapnode_remove_key(node, successor); | ||
| 12856 | + } else { | ||
| 12857 | + builtin__mapnode_merge(n, idx); | ||
| 12858 | + mapnode* node = ((mapnode*)(n->children[idx])); | ||
| 12859 | + builtin__mapnode_remove_key(node, k); | ||
| 12860 | + } | ||
| 12861 | +} | ||
| 12862 | +VV_LOC void builtin__mapnode_fill(mapnode* n, int idx) { | ||
| 12863 | + if (idx != 0 && ((mapnode*)(n->children[idx - 1]))->len >= _const_degree) { | ||
| 12864 | + builtin__mapnode_borrow_from_prev(n, idx); | ||
| 12865 | + } else if (idx != n->len && ((mapnode*)(n->children[idx + 1]))->len >= _const_degree) { | ||
| 12866 | + builtin__mapnode_borrow_from_next(n, idx); | ||
| 12867 | + } else if (idx != n->len) { | ||
| 12868 | + builtin__mapnode_merge(n, idx); | ||
| 12869 | + } else { | ||
| 12870 | + builtin__mapnode_merge(n, idx - 1); | ||
| 12871 | + } | ||
| 12872 | +} | ||
| 12873 | +VV_LOC void builtin__mapnode_borrow_from_prev(mapnode* n, int idx) { | ||
| 12874 | + mapnode* child = ((mapnode*)(n->children[idx])); | ||
| 12875 | + mapnode* sibling = ((mapnode*)(n->children[idx - 1])); | ||
| 12876 | + for (int i = child->len - 1; i >= 0; i--) { | ||
| 12877 | + child->keys[builtin__v_fixed_index(i + 1, 11)] = child->keys[builtin__v_fixed_index(i, 11)]; | ||
| 12878 | + child->values[builtin__v_fixed_index(i + 1, 11)] = child->values[builtin__v_fixed_index(i, 11)]; | ||
| 12879 | + } | ||
| 12880 | + if (child->children != ((void*)0)) { | ||
| 12881 | + for (int i = child->len; i >= 0; i--) { | ||
| 12882 | + { // Unsafe block | ||
| 12883 | + child->children[i + 1] = child->children[i]; | ||
| 12884 | + } | ||
| 12885 | + } | ||
| 12886 | + } | ||
| 12887 | + child->keys[0] = n->keys[builtin__v_fixed_index(idx - 1, 11)]; | ||
| 12888 | + child->values[0] = n->values[builtin__v_fixed_index(idx - 1, 11)]; | ||
| 12889 | + if (child->children != ((void*)0)) { | ||
| 12890 | + { // Unsafe block | ||
| 12891 | + child->children[0] = sibling->children[sibling->len]; | ||
| 12892 | + } | ||
| 12893 | + } | ||
| 12894 | + n->keys[builtin__v_fixed_index(idx - 1, 11)] = sibling->keys[builtin__v_fixed_index(sibling->len - 1, 11)]; | ||
| 12895 | + n->values[builtin__v_fixed_index(idx - 1, 11)] = sibling->values[builtin__v_fixed_index(sibling->len - 1, 11)]; | ||
| 12896 | + child->len++; | ||
| 12897 | + sibling->len--; | ||
| 12898 | +} | ||
| 12899 | +VV_LOC void builtin__mapnode_borrow_from_next(mapnode* n, int idx) { | ||
| 12900 | + mapnode* child = ((mapnode*)(n->children[idx])); | ||
| 12901 | + mapnode* sibling = ((mapnode*)(n->children[idx + 1])); | ||
| 12902 | + child->keys[builtin__v_fixed_index(child->len, 11)] = n->keys[builtin__v_fixed_index(idx, 11)]; | ||
| 12903 | + child->values[builtin__v_fixed_index(child->len, 11)] = n->values[builtin__v_fixed_index(idx, 11)]; | ||
| 12904 | + if (child->children != ((void*)0)) { | ||
| 12905 | + { // Unsafe block | ||
| 12906 | + child->children[child->len + 1] = sibling->children[0]; | ||
| 12907 | + } | ||
| 12908 | + } | ||
| 12909 | + n->keys[builtin__v_fixed_index(idx, 11)] = sibling->keys[0]; | ||
| 12910 | + n->values[builtin__v_fixed_index(idx, 11)] = sibling->values[0]; | ||
| 12911 | + for (int i = 1; i < sibling->len; i++) { | ||
| 12912 | + sibling->keys[builtin__v_fixed_index(i - 1, 11)] = sibling->keys[builtin__v_fixed_index(i, 11)]; | ||
| 12913 | + sibling->values[builtin__v_fixed_index(i - 1, 11)] = sibling->values[builtin__v_fixed_index(i, 11)]; | ||
| 12914 | + } | ||
| 12915 | + if (sibling->children != ((void*)0)) { | ||
| 12916 | + for (int i = 1; i <= sibling->len; i++) { | ||
| 12917 | + { // Unsafe block | ||
| 12918 | + sibling->children[i - 1] = sibling->children[i]; | ||
| 12919 | + } | ||
| 12920 | + } | ||
| 12921 | + } | ||
| 12922 | + child->len++; | ||
| 12923 | + sibling->len--; | ||
| 12924 | +} | ||
| 12925 | +VV_LOC void builtin__mapnode_merge(mapnode* n, int idx) { | ||
| 12926 | + mapnode* child = ((mapnode*)(n->children[idx])); | ||
| 12927 | + mapnode* sibling = ((mapnode*)(n->children[idx + 1])); | ||
| 12928 | + child->keys[builtin__v_fixed_index(_const_mid_index, 11)] = n->keys[builtin__v_fixed_index(idx, 11)]; | ||
| 12929 | + child->values[builtin__v_fixed_index(_const_mid_index, 11)] = n->values[builtin__v_fixed_index(idx, 11)]; | ||
| 12930 | + for (int i = 0; i < sibling->len; ++i) { | ||
| 12931 | + child->keys[builtin__v_fixed_index(i + _const_degree, 11)] = sibling->keys[builtin__v_fixed_index(i, 11)]; | ||
| 12932 | + child->values[builtin__v_fixed_index(i + _const_degree, 11)] = sibling->values[builtin__v_fixed_index(i, 11)]; | ||
| 12933 | + } | ||
| 12934 | + if (child->children != ((void*)0)) { | ||
| 12935 | + for (int i = 0; i <= sibling->len; i++) { | ||
| 12936 | + { // Unsafe block | ||
| 12937 | + child->children[i + _const_degree] = sibling->children[i]; | ||
| 12938 | + } | ||
| 12939 | + } | ||
| 12940 | + } | ||
| 12941 | + for (int i = idx + 1; i < n->len; i++) { | ||
| 12942 | + n->keys[builtin__v_fixed_index(i - 1, 11)] = n->keys[builtin__v_fixed_index(i, 11)]; | ||
| 12943 | + n->values[builtin__v_fixed_index(i - 1, 11)] = n->values[builtin__v_fixed_index(i, 11)]; | ||
| 12944 | + } | ||
| 12945 | + for (int i = idx + 2; i <= n->len; i++) { | ||
| 12946 | + { // Unsafe block | ||
| 12947 | + n->children[i - 1] = n->children[i]; | ||
| 12948 | + } | ||
| 12949 | + } | ||
| 12950 | + child->len += sibling->len + 1; | ||
| 12951 | + n->len--; | ||
| 12952 | +} | ||
| 12953 | +void builtin__SortedMap_delete(SortedMap* m, string key) { | ||
| 12954 | + if (m->root->len == 0) { | ||
| 12955 | + return; | ||
| 12956 | + } | ||
| 12957 | + bool removed = builtin__mapnode_remove_key(m->root, key); | ||
| 12958 | + if (removed) { | ||
| 12959 | + m->len--; | ||
| 12960 | + } | ||
| 12961 | + if (m->root->len == 0) { | ||
| 12962 | + if (m->root->children == ((void*)0)) { | ||
| 12963 | + return; | ||
| 12964 | + } else { | ||
| 12965 | + m->root = ((mapnode*)(m->root->children[0])); | ||
| 12966 | + } | ||
| 12967 | + } | ||
| 12968 | +} | ||
| 12969 | +VV_LOC int builtin__mapnode_subkeys(mapnode* n, Array_string* keys, int at) { | ||
| 12970 | + int position = at; | ||
| 12971 | + if (n->children != ((void*)0)) { | ||
| 12972 | + for (int i = 0; i < n->len; ++i) { | ||
| 12973 | + mapnode* child = ((mapnode*)(n->children[i])); | ||
| 12974 | + position += builtin__mapnode_subkeys(child, keys, position); | ||
| 12975 | + builtin__array_set(keys, position, &(string[]) { n->keys[builtin__v_fixed_index(i, 11)] }); | ||
| 12976 | + position++; | ||
| 12977 | + } | ||
| 12978 | + mapnode* child = ((mapnode*)(n->children[n->len])); | ||
| 12979 | + position += builtin__mapnode_subkeys(child, keys, position); | ||
| 12980 | + } else { | ||
| 12981 | + for (int i = 0; i < n->len; ++i) { | ||
| 12982 | + builtin__array_set(keys, (int)(position + i), &(string[]) { n->keys[builtin__v_fixed_index(i, 11)] }); | ||
| 12983 | + } | ||
| 12984 | + position += n->len; | ||
| 12985 | + } | ||
| 12986 | + return position - at; | ||
| 12987 | +} | ||
| 12988 | +Array_string builtin__SortedMap_keys(SortedMap* m) { | ||
| 12989 | + Array_string keys = builtin____new_array_with_default(m->len, 0, sizeof(string), &(string[]){_S("")}); | ||
| 12990 | + if (m->root == ((void*)0) || m->root->len == 0) { | ||
| 12991 | + return keys; | ||
| 12992 | + } | ||
| 12993 | + builtin__mapnode_subkeys(m->root, &keys, 0); | ||
| 12994 | + return keys; | ||
| 12995 | +} | ||
| 12996 | +VV_LOC void builtin__mapnode_free(mapnode* n) { | ||
| 12997 | +} | ||
| 12998 | +void builtin__SortedMap_free(SortedMap* m) { | ||
| 12999 | + if (m->root == ((void*)0)) { | ||
| 13000 | + return; | ||
| 13001 | + } | ||
| 13002 | + builtin__mapnode_free(m->root); | ||
| 13003 | +} | ||
| 13004 | +Array_rune builtin__string_runes(string s) { | ||
| 13005 | + Array_rune runes = builtin____new_array_with_default(0, s.len, sizeof(rune), 0); | ||
| 13006 | + for (int i = 0; i < s.len; i++) { | ||
| 13007 | + multi_return_rune_int mr_2797 = builtin__utf8_decode_rune(&s.str[i], s.len - i); | ||
| 13008 | + rune r = mr_2797.arg0; | ||
| 13009 | + int char_len = mr_2797.arg1; | ||
| 13010 | + builtin__array_push((array*)&runes, _MOV((rune[]){ r })); | ||
| 13011 | + if (char_len > 1) { | ||
| 13012 | + i += char_len - 1; | ||
| 13013 | + } | ||
| 13014 | + } | ||
| 13015 | + return runes; | ||
| 13016 | +} | ||
| 13017 | +Array_string builtin__string_graphemes(string s) { | ||
| 13018 | + return builtin__string_graphemes_impl(s); | ||
| 13019 | +} | ||
| 13020 | +string builtin__cstring_to_vstring(const char* const_s) { | ||
| 13021 | + string s = builtin__tos2(((byteptr)(const_s))); | ||
| 13022 | + return builtin__string_clone(s); | ||
| 13023 | +} | ||
| 13024 | +string builtin__tos_clone(const u8* const_s) { | ||
| 13025 | + string s = builtin__tos2(((u8*)(const_s))); | ||
| 13026 | + return builtin__string_clone(s); | ||
| 13027 | +} | ||
| 13028 | +string builtin__tos(u8* s, int len) { | ||
| 13029 | + if (s == 0) { | ||
| 13030 | + builtin___v_panic(_S("tos(): nil string")); | ||
| 13031 | + VUNREACHABLE(); | ||
| 13032 | + } | ||
| 13033 | + return ((string){.str = s, .len = len}); | ||
| 13034 | +} | ||
| 13035 | +string builtin__tos2(u8* s) { | ||
| 13036 | + if (s == 0) { | ||
| 13037 | + builtin___v_panic(_S("tos2: nil string")); | ||
| 13038 | + VUNREACHABLE(); | ||
| 13039 | + } | ||
| 13040 | + return ((string){.str = s, .len = builtin__vstrlen(s)}); | ||
| 13041 | +} | ||
| 13042 | +string builtin__tos3(char* s) { | ||
| 13043 | + if (s == 0) { | ||
| 13044 | + builtin___v_panic(_S("tos3: nil string")); | ||
| 13045 | + VUNREACHABLE(); | ||
| 13046 | + } | ||
| 13047 | + return ((string){.str = ((u8*)(s)), .len = builtin__vstrlen_char(s)}); | ||
| 13048 | +} | ||
| 13049 | +string builtin__tos4(u8* s) { | ||
| 13050 | + if (s == 0) { | ||
| 13051 | + return _S(""); | ||
| 13052 | + } | ||
| 13053 | + return ((string){.str = s, .len = builtin__vstrlen(s)}); | ||
| 13054 | +} | ||
| 13055 | +string builtin__tos5(char* s) { | ||
| 13056 | + if (s == 0) { | ||
| 13057 | + return _S(""); | ||
| 13058 | + } | ||
| 13059 | + return ((string){.str = ((u8*)(s)), .len = builtin__vstrlen_char(s)}); | ||
| 13060 | +} | ||
| 13061 | +string builtin__u8_vstring(u8* bp) { | ||
| 13062 | + return ((string){.str = bp, .len = builtin__vstrlen(bp)}); | ||
| 13063 | +} | ||
| 13064 | +string builtin__u8_vstring_with_len(u8* bp, int len) { | ||
| 13065 | + return ((string){.str = bp, .len = len, .is_lit = 0}); | ||
| 13066 | +} | ||
| 13067 | +string builtin__char_vstring(char* cp) { | ||
| 13068 | + return ((string){.str = ((u8*)(cp)), .len = builtin__vstrlen_char(cp), .is_lit = 0}); | ||
| 13069 | +} | ||
| 13070 | +string builtin__char_vstring_with_len(char* cp, int len) { | ||
| 13071 | + return ((string){.str = ((u8*)(cp)), .len = len, .is_lit = 0}); | ||
| 13072 | +} | ||
| 13073 | +string builtin__u8_vstring_literal(u8* bp) { | ||
| 13074 | + return ((string){.str = bp, .len = builtin__vstrlen(bp), .is_lit = 1}); | ||
| 13075 | +} | ||
| 13076 | +string builtin__u8_vstring_literal_with_len(u8* bp, int len) { | ||
| 13077 | + return ((string){.str = bp, .len = len, .is_lit = 1}); | ||
| 13078 | +} | ||
| 13079 | +string builtin__char_vstring_literal(char* cp) { | ||
| 13080 | + return ((string){.str = ((u8*)(cp)), .len = builtin__vstrlen_char(cp), .is_lit = 1}); | ||
| 13081 | +} | ||
| 13082 | +string builtin__char_vstring_literal_with_len(char* cp, int len) { | ||
| 13083 | + return ((string){.str = ((u8*)(cp)), .len = len, .is_lit = 1}); | ||
| 13084 | +} | ||
| 13085 | +int builtin__string_len_utf8(string s) { | ||
| 13086 | + int l = 0; | ||
| 13087 | + int i = 0; | ||
| 13088 | + for (;;) { | ||
| 13089 | + if (!(i < s.len)) break; | ||
| 13090 | + l++; | ||
| 13091 | + i += ((int)((((v__rshift_u32(((u32)(0xe5000000U)), (u64)(((v__rshift_u8(s.str[i], (u64)3)) & 0x1e)))) & 3)) + 1)); | ||
| 13092 | + } | ||
| 13093 | + return l; | ||
| 13094 | +} | ||
| 13095 | +bool builtin__string_is_pure_ascii(string s) { | ||
| 13096 | + for (int i = 0; i < s.len; ++i) { | ||
| 13097 | + if (s.str[ i] >= 0x80) { | ||
| 13098 | + return false; | ||
| 13099 | + } | ||
| 13100 | + } | ||
| 13101 | + return true; | ||
| 13102 | +} | ||
| 13103 | +string builtin__string_clone(string a) { | ||
| 13104 | + if (a.len <= 0) { | ||
| 13105 | + return _S(""); | ||
| 13106 | + } | ||
| 13107 | + string _t2 = ((string){.str = builtin__malloc_noscan(a.len + 1), .len = a.len}); | ||
| 13108 | + string b = _t2; | ||
| 13109 | + { // Unsafe block | ||
| 13110 | + builtin__vmemcpy(b.str, a.str, a.len); | ||
| 13111 | + b.str[a.len] = 0; | ||
| 13112 | + } | ||
| 13113 | + return b; | ||
| 13114 | +} | ||
| 13115 | +string builtin__string_replace_once(string s, string rep, string with) { | ||
| 13116 | + int idx = builtin__string_index_(s, rep); | ||
| 13117 | + if (idx == -1) { | ||
| 13118 | + return builtin__string_clone(s); | ||
| 13119 | + } | ||
| 13120 | + return builtin__string_plus_two(builtin__string_substr_unsafe(s, 0, idx), with, builtin__string_substr_unsafe(s, idx + rep.len, s.len)); | ||
| 13121 | +} | ||
| 13122 | +string builtin__string_replace(string s, string rep, string with) { | ||
| 13123 | + if (s.len == 0 || rep.len == 0 || rep.len > s.len) { | ||
| 13124 | + return builtin__string_clone(s); | ||
| 13125 | + } | ||
| 13126 | + if (!builtin__string_contains(s, rep)) { | ||
| 13127 | + return builtin__string_clone(s); | ||
| 13128 | + } | ||
| 13129 | + int pidxs_len = 0; | ||
| 13130 | + int pidxs_cap = VSAFE_DIV_int(s.len , rep.len); | ||
| 13131 | + Array_fixed_int_10 stack_idxs = {0}; | ||
| 13132 | + int* pidxs = &stack_idxs[0]; | ||
| 13133 | + if (pidxs_cap > _const_replace_stack_buffer_size) { | ||
| 13134 | + pidxs = ((int*)(builtin___v_malloc(((int)(sizeof(int))) * pidxs_cap))); | ||
| 13135 | + } | ||
| 13136 | + int idx = 0; | ||
| 13137 | + for (;;) { | ||
| 13138 | + idx = builtin__string_index_after_(s, rep, idx); | ||
| 13139 | + if (idx == -1) { | ||
| 13140 | + break; | ||
| 13141 | + } | ||
| 13142 | + { // Unsafe block | ||
| 13143 | + pidxs[pidxs_len] = idx; | ||
| 13144 | + pidxs_len++; | ||
| 13145 | + } | ||
| 13146 | + idx += rep.len; | ||
| 13147 | + } | ||
| 13148 | + if (pidxs_len == 0) { | ||
| 13149 | + string _t3 = builtin__string_clone(s); | ||
| 13150 | + { // defer begin | ||
| 13151 | + if (pidxs_cap > _const_replace_stack_buffer_size) { | ||
| 13152 | + builtin___v_free(pidxs); | ||
| 13153 | + } | ||
| 13154 | + } // defer end | ||
| 13155 | + return _t3; | ||
| 13156 | + } | ||
| 13157 | + int new_len = s.len + pidxs_len * (with.len - rep.len); | ||
| 13158 | + u8* b = builtin__malloc_noscan(new_len + 1); | ||
| 13159 | + int b_i = 0; | ||
| 13160 | + int s_idx = 0; | ||
| 13161 | + for (int j = 0; j < pidxs_len; ++j) { | ||
| 13162 | + int rep_pos = pidxs[j]; | ||
| 13163 | + int before_len = rep_pos - s_idx; | ||
| 13164 | + builtin__vmemcpy(&b[b_i], &s.str[s_idx], before_len); | ||
| 13165 | + b_i += before_len; | ||
| 13166 | + s_idx = rep_pos + rep.len; | ||
| 13167 | + builtin__vmemcpy(&b[b_i], &with.str[0], with.len); | ||
| 13168 | + b_i += with.len; | ||
| 13169 | + } | ||
| 13170 | + if (s_idx < s.len) { | ||
| 13171 | + builtin__vmemcpy(&b[b_i], &s.str[s_idx], s.len - s_idx); | ||
| 13172 | + } | ||
| 13173 | + { // Unsafe block | ||
| 13174 | + b[new_len] = 0; | ||
| 13175 | + string _t4 = builtin__tos(b, new_len); | ||
| 13176 | + { // defer begin | ||
| 13177 | + if (pidxs_cap > _const_replace_stack_buffer_size) { | ||
| 13178 | + builtin___v_free(pidxs); | ||
| 13179 | + } | ||
| 13180 | + } // defer end | ||
| 13181 | + return _t4; | ||
| 13182 | + } | ||
| 13183 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 13184 | +} | ||
| 13185 | +string builtin__string_replace_each(string s, Array_string vals) { | ||
| 13186 | + if (s.len == 0 || vals.len == 0) { | ||
| 13187 | + return builtin__string_clone(s); | ||
| 13188 | + } | ||
| 13189 | + if (VSAFE_MOD_int(vals.len , 2) != 0) { | ||
| 13190 | + builtin__eprintln(_S("string.replace_each(): odd number of strings")); | ||
| 13191 | + return builtin__string_clone(s); | ||
| 13192 | + } | ||
| 13193 | + int new_len = s.len; | ||
| 13194 | + Array_RepIndex idxs = builtin____new_array_with_default(0, 6, sizeof(RepIndex), 0); | ||
| 13195 | + int idx = 0; | ||
| 13196 | + string s_ = builtin__string_clone(s); | ||
| 13197 | + for (int rep_i = 0; rep_i < vals.len; rep_i += 2) { | ||
| 13198 | + string rep = ((string*)vals.data)[rep_i]; | ||
| 13199 | + string with = ((string*)vals.data)[rep_i + 1]; | ||
| 13200 | + for (;;) { | ||
| 13201 | + idx = builtin__string_index_after_(s_, rep, idx); | ||
| 13202 | + if (idx == -1) { | ||
| 13203 | + break; | ||
| 13204 | + } | ||
| 13205 | + for (int i = 0; i < rep.len; ++i) { | ||
| 13206 | + { // Unsafe block | ||
| 13207 | + s_.str[(int)(idx + i)] = 0; | ||
| 13208 | + } | ||
| 13209 | + } | ||
| 13210 | + builtin__array_push((array*)&idxs, _MOV((RepIndex[]){ ((RepIndex){.idx = idx,.val_idx = rep_i,}) })); | ||
| 13211 | + idx += rep.len; | ||
| 13212 | + new_len += with.len - rep.len; | ||
| 13213 | + } | ||
| 13214 | + } | ||
| 13215 | + if (idxs.len == 0) { | ||
| 13216 | + string _t4 = builtin__string_clone(s); | ||
| 13217 | + { // defer begin | ||
| 13218 | + builtin__array_free(&idxs); | ||
| 13219 | + } // defer end | ||
| 13220 | + return _t4; | ||
| 13221 | + } | ||
| 13222 | + if (idxs.len > 0) { v_stable_sort(idxs.data, idxs.len, idxs.element_size, compare_11734835982493514523_RepIndex_by_idx_expr_612e6964780a3c0a622e696478_qsort_adapter); } | ||
| 13223 | + ; | ||
| 13224 | + u8* buf = builtin__malloc_noscan(new_len + 1); | ||
| 13225 | + int idx_pos = 0; | ||
| 13226 | + RepIndex cur_idx = ((RepIndex*)idxs.data)[idx_pos]; | ||
| 13227 | + int buf_i = 0; | ||
| 13228 | + for (int i = 0; i < s.len; i++) { | ||
| 13229 | + if (i == cur_idx.idx) { | ||
| 13230 | + string rep = ((string*)vals.data)[cur_idx.val_idx]; | ||
| 13231 | + string with = ((string*)vals.data)[cur_idx.val_idx + 1]; | ||
| 13232 | + for (int j = 0; j < with.len; ++j) { | ||
| 13233 | + { // Unsafe block | ||
| 13234 | + buf[buf_i] = with.str[ j]; | ||
| 13235 | + } | ||
| 13236 | + buf_i++; | ||
| 13237 | + } | ||
| 13238 | + i += rep.len - 1; | ||
| 13239 | + idx_pos++; | ||
| 13240 | + if (idx_pos < idxs.len) { | ||
| 13241 | + cur_idx = ((RepIndex*)idxs.data)[idx_pos]; | ||
| 13242 | + } | ||
| 13243 | + } else { | ||
| 13244 | + { // Unsafe block | ||
| 13245 | + buf[buf_i] = s.str[i]; | ||
| 13246 | + } | ||
| 13247 | + buf_i++; | ||
| 13248 | + } | ||
| 13249 | + } | ||
| 13250 | + { // Unsafe block | ||
| 13251 | + buf[new_len] = 0; | ||
| 13252 | + string _t5 = builtin__tos(buf, new_len); | ||
| 13253 | + { // defer begin | ||
| 13254 | + builtin__array_free(&idxs); | ||
| 13255 | + } // defer end | ||
| 13256 | + return _t5; | ||
| 13257 | + } | ||
| 13258 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 13259 | +} | ||
| 13260 | +string builtin__string_format(string s, Array_string args) { | ||
| 13261 | + if (s.len == 0) { | ||
| 13262 | + return _S(""); | ||
| 13263 | + } | ||
| 13264 | + strings__Builder out = strings__new_builder(s.len); | ||
| 13265 | + int i = 0; | ||
| 13266 | + for (;;) { | ||
| 13267 | + if (!(i < s.len)) break; | ||
| 13268 | + u8 ch = s.str[ i]; | ||
| 13269 | + if (ch == '{') { | ||
| 13270 | + if (i + 1 < s.len && s.str[ i + 1] == '{') { | ||
| 13271 | + strings__Builder_write_byte(&out, '{'); | ||
| 13272 | + i += 2; | ||
| 13273 | + continue; | ||
| 13274 | + } | ||
| 13275 | + int j = i + 1; | ||
| 13276 | + if (j >= s.len || !builtin__u8_is_digit(s.str[ j])) { | ||
| 13277 | + strings__Builder_write_byte(&out, ch); | ||
| 13278 | + i++; | ||
| 13279 | + continue; | ||
| 13280 | + } | ||
| 13281 | + int idx = 0; | ||
| 13282 | + bool overflowed = false; | ||
| 13283 | + for (;;) { | ||
| 13284 | + if (!(j < s.len && builtin__u8_is_digit(s.str[ j]))) break; | ||
| 13285 | + int digit = ((int)((rune)(s.str[ j] - '0'))); | ||
| 13286 | + if (idx > VSAFE_DIV_int((_const_max_int - digit) , 10)) { | ||
| 13287 | + overflowed = true; | ||
| 13288 | + break; | ||
| 13289 | + } | ||
| 13290 | + idx = idx * 10 + digit; | ||
| 13291 | + j++; | ||
| 13292 | + } | ||
| 13293 | + if (!overflowed && j < s.len && s.str[ j] == '}') { | ||
| 13294 | + if (idx < args.len) { | ||
| 13295 | + strings__Builder_write_string(&out, ((string*)args.data)[idx]); | ||
| 13296 | + } else { | ||
| 13297 | + strings__Builder_write_string(&out, builtin__string_substr(s, i, j + 1)); | ||
| 13298 | + } | ||
| 13299 | + i = j + 1; | ||
| 13300 | + continue; | ||
| 13301 | + } | ||
| 13302 | + strings__Builder_write_byte(&out, ch); | ||
| 13303 | + i++; | ||
| 13304 | + continue; | ||
| 13305 | + } | ||
| 13306 | + if (ch == '}' && i + 1 < s.len && s.str[ i + 1] == '}') { | ||
| 13307 | + strings__Builder_write_byte(&out, '}'); | ||
| 13308 | + i += 2; | ||
| 13309 | + continue; | ||
| 13310 | + } | ||
| 13311 | + strings__Builder_write_byte(&out, ch); | ||
| 13312 | + i++; | ||
| 13313 | + } | ||
| 13314 | + return strings__Builder_str(&out); | ||
| 13315 | +} | ||
| 13316 | +string builtin__string_replace_char(string s, u8 rep, u8 with, int repeat) { | ||
| 13317 | + #if 1 | ||
| 13318 | + { | ||
| 13319 | + if (repeat <= 0) { | ||
| 13320 | + builtin___v_panic(_S("string.replace_char(): tab length too short")); | ||
| 13321 | + VUNREACHABLE(); | ||
| 13322 | + } | ||
| 13323 | + } | ||
| 13324 | + #endif | ||
| 13325 | + if (s.len == 0) { | ||
| 13326 | + return builtin__string_clone(s); | ||
| 13327 | + } | ||
| 13328 | + Array_int idxs = builtin____new_array_with_default(0, v__rshift_int(s.len, (u64)2), sizeof(int), 0); | ||
| 13329 | + for (int i = 0; i < s.len; ++i) { | ||
| 13330 | + u8 ch = s.str[i]; | ||
| 13331 | + if (ch == rep) { | ||
| 13332 | + builtin__array_push((array*)&idxs, _MOV((int[]){ i })); | ||
| 13333 | + } | ||
| 13334 | + } | ||
| 13335 | + if (idxs.len == 0) { | ||
| 13336 | + string _t4 = builtin__string_clone(s); | ||
| 13337 | + { // defer begin | ||
| 13338 | + builtin__array_free(&idxs); | ||
| 13339 | + } // defer end | ||
| 13340 | + return _t4; | ||
| 13341 | + } | ||
| 13342 | + int new_len = s.len + idxs.len * (repeat - 1); | ||
| 13343 | + u8* b = builtin__malloc_noscan(new_len + 1); | ||
| 13344 | + int b_i = 0; | ||
| 13345 | + int s_idx = 0; | ||
| 13346 | + for (int _t5 = 0; _t5 < idxs.len; ++_t5) { | ||
| 13347 | + int rep_pos = ((int*)idxs.data)[_t5]; | ||
| 13348 | + for (int i = s_idx; i < rep_pos; ++i) { | ||
| 13349 | + { // Unsafe block | ||
| 13350 | + b[b_i] = s.str[ i]; | ||
| 13351 | + } | ||
| 13352 | + b_i++; | ||
| 13353 | + } | ||
| 13354 | + s_idx = rep_pos + 1; | ||
| 13355 | + for (int _t6 = 0; _t6 < repeat; ++_t6) { | ||
| 13356 | + { // Unsafe block | ||
| 13357 | + b[b_i] = with; | ||
| 13358 | + } | ||
| 13359 | + b_i++; | ||
| 13360 | + } | ||
| 13361 | + } | ||
| 13362 | + if (s_idx < s.len) { | ||
| 13363 | + for (int i = s_idx; i < s.len; ++i) { | ||
| 13364 | + { // Unsafe block | ||
| 13365 | + b[b_i] = s.str[ i]; | ||
| 13366 | + } | ||
| 13367 | + b_i++; | ||
| 13368 | + } | ||
| 13369 | + } | ||
| 13370 | + { // Unsafe block | ||
| 13371 | + b[new_len] = 0; | ||
| 13372 | + string _t7 = builtin__tos(b, new_len); | ||
| 13373 | + { // defer begin | ||
| 13374 | + builtin__array_free(&idxs); | ||
| 13375 | + } // defer end | ||
| 13376 | + return _t7; | ||
| 13377 | + } | ||
| 13378 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 13379 | +} | ||
| 13380 | +inline string builtin__string_normalize_tabs(string s, int tab_len) { | ||
| 13381 | + return builtin__string_replace_char(s, '\t', ' ', tab_len); | ||
| 13382 | +} | ||
| 13383 | +string builtin__string_expand_tabs(string s, int tab_len) { | ||
| 13384 | + if (tab_len <= 0) { | ||
| 13385 | + return builtin__string_clone(s); | ||
| 13386 | + } | ||
| 13387 | + strings__Builder output = strings__new_builder(s.len); | ||
| 13388 | + int column = 0; | ||
| 13389 | + RunesIterator _t2 = builtin__string_runes_iterator(s); | ||
| 13390 | + while (1) { | ||
| 13391 | + _option_rune _t3 = builtin__RunesIterator_next(&_t2); | ||
| 13392 | + if (_t3.state != 0) break; | ||
| 13393 | + rune r = *(rune*)_t3.data; | ||
| 13394 | + | ||
| 13395 | + if (r == ('\t')) { | ||
| 13396 | + int spaces = tab_len - (VSAFE_MOD_int(column , tab_len)); | ||
| 13397 | + strings__Builder_write_string(&output, builtin__string_repeat(_S(" "), spaces)); | ||
| 13398 | + column += spaces; | ||
| 13399 | + } | ||
| 13400 | + else if (r == ('\n') || r == ('\r')) { | ||
| 13401 | + strings__Builder_write_rune(&output, r); | ||
| 13402 | + column = 0; | ||
| 13403 | + } | ||
| 13404 | + else { | ||
| 13405 | + strings__Builder_write_rune(&output, r); | ||
| 13406 | + column++; | ||
| 13407 | + } | ||
| 13408 | + } | ||
| 13409 | + return strings__Builder_str(&output); | ||
| 13410 | +} | ||
| 13411 | +inline bool builtin__string_bool(string s) { | ||
| 13412 | + return _SLIT_EQ(s.str, s.len, "true") || _SLIT_EQ(s.str, s.len, "t"); | ||
| 13413 | +} | ||
| 13414 | +inline i8 builtin__string_i8(string s) { | ||
| 13415 | + _result_i64 _t2 = strconv__common_parse_int(s, 0, 8, false, false); | ||
| 13416 | + if (_t2.is_error) { | ||
| 13417 | + *(i64*) _t2.data = 0; | ||
| 13418 | + } | ||
| 13419 | + | ||
| 13420 | + return ((i8)((*(i64*)_t2.data))); | ||
| 13421 | +} | ||
| 13422 | +inline i16 builtin__string_i16(string s) { | ||
| 13423 | + _result_i64 _t2 = strconv__common_parse_int(s, 0, 16, false, false); | ||
| 13424 | + if (_t2.is_error) { | ||
| 13425 | + *(i64*) _t2.data = 0; | ||
| 13426 | + } | ||
| 13427 | + | ||
| 13428 | + return ((i16)((*(i64*)_t2.data))); | ||
| 13429 | +} | ||
| 13430 | +inline i32 builtin__string_i32(string s) { | ||
| 13431 | + _result_i64 _t2 = strconv__common_parse_int(s, 0, 32, false, false); | ||
| 13432 | + if (_t2.is_error) { | ||
| 13433 | + *(i64*) _t2.data = 0; | ||
| 13434 | + } | ||
| 13435 | + | ||
| 13436 | + return ((i32)((*(i64*)_t2.data))); | ||
| 13437 | +} | ||
| 13438 | +inline int builtin__string_int(string s) { | ||
| 13439 | + _result_i64 _t2 = strconv__common_parse_int(s, 0, 32, false, false); | ||
| 13440 | + if (_t2.is_error) { | ||
| 13441 | + *(i64*) _t2.data = 0; | ||
| 13442 | + } | ||
| 13443 | + | ||
| 13444 | + return ((int)((*(i64*)_t2.data))); | ||
| 13445 | +} | ||
| 13446 | +inline i64 builtin__string_i64(string s) { | ||
| 13447 | + _result_i64 _t2 = strconv__common_parse_int(s, 0, 64, false, false); | ||
| 13448 | + if (_t2.is_error) { | ||
| 13449 | + *(i64*) _t2.data = 0; | ||
| 13450 | + } | ||
| 13451 | + | ||
| 13452 | + return (*(i64*)_t2.data); | ||
| 13453 | +} | ||
| 13454 | +inline f32 builtin__string_f32(string s) { | ||
| 13455 | + _result_f64 _t2 = strconv__atof64(s, ((strconv__AtoF64Param){.allow_extra_chars = true,})); | ||
| 13456 | + if (_t2.is_error) { | ||
| 13457 | + *(f64*) _t2.data = 0; | ||
| 13458 | + } | ||
| 13459 | + | ||
| 13460 | + return ((f32)((*(f64*)_t2.data))); | ||
| 13461 | +} | ||
| 13462 | +inline f64 builtin__string_f64(string s) { | ||
| 13463 | + _result_f64 _t2 = strconv__atof64(s, ((strconv__AtoF64Param){.allow_extra_chars = true,})); | ||
| 13464 | + if (_t2.is_error) { | ||
| 13465 | + *(f64*) _t2.data = 0; | ||
| 13466 | + } | ||
| 13467 | + | ||
| 13468 | + return (*(f64*)_t2.data); | ||
| 13469 | +} | ||
| 13470 | +Array_u8 builtin__string_u8_array(string s) { | ||
| 13471 | + string tmps = builtin__string_replace(s, _S("_"), _S("")); | ||
| 13472 | + if (tmps.len == 0) { | ||
| 13473 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | ||
| 13474 | + } | ||
| 13475 | + tmps = builtin__string_to_lower_ascii(tmps); | ||
| 13476 | + if (builtin__string_starts_with(tmps, _S("0x"))) { | ||
| 13477 | + tmps = builtin__string_substr(tmps, 2, 2147483647); | ||
| 13478 | + if (tmps.len == 0) { | ||
| 13479 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | ||
| 13480 | + } | ||
| 13481 | + if (!builtin__string_contains_only(tmps, _S("0123456789abcdef"))) { | ||
| 13482 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | ||
| 13483 | + } | ||
| 13484 | + if (VSAFE_MOD_int(tmps.len , 2) == 1) { | ||
| 13485 | + tmps = builtin__string__plus(_S("0"), tmps); | ||
| 13486 | + } | ||
| 13487 | + Array_u8 ret = builtin____new_array_with_default(VSAFE_DIV_int(tmps.len , 2), 0, sizeof(u8), 0); | ||
| 13488 | + for (int i = 0; i < ret.len; ++i) { | ||
| 13489 | + _result_u64 _t4 = builtin__string_parse_uint(builtin__string_substr(tmps, 2 * i, 2 * i + 2), 16, 8); | ||
| 13490 | + if (_t4.is_error) { | ||
| 13491 | + *(u64*) _t4.data = 0; | ||
| 13492 | + } | ||
| 13493 | + | ||
| 13494 | + builtin__array_set(&ret, i, &(u8[]) { ((u8)((*(u64*)_t4.data))) }); | ||
| 13495 | + } | ||
| 13496 | + return ret; | ||
| 13497 | + } else if (builtin__string_starts_with(tmps, _S("0b"))) { | ||
| 13498 | + tmps = builtin__string_substr(tmps, 2, 2147483647); | ||
| 13499 | + if (tmps.len == 0) { | ||
| 13500 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | ||
| 13501 | + } | ||
| 13502 | + if (!builtin__string_contains_only(tmps, _S("01"))) { | ||
| 13503 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | ||
| 13504 | + } | ||
| 13505 | + if (VSAFE_MOD_int(tmps.len , 8) != 0) { | ||
| 13506 | + tmps = builtin__string__plus(builtin__string_repeat(_S("0"), 8 - VSAFE_MOD_int(tmps.len , 8)), tmps); | ||
| 13507 | + } | ||
| 13508 | + Array_u8 ret = builtin____new_array_with_default(VSAFE_DIV_int(tmps.len , 8), 0, sizeof(u8), 0); | ||
| 13509 | + for (int i = 0; i < ret.len; ++i) { | ||
| 13510 | + _result_u64 _t8 = builtin__string_parse_uint(builtin__string_substr(tmps, 8 * i, 8 * i + 8), 2, 8); | ||
| 13511 | + if (_t8.is_error) { | ||
| 13512 | + *(u64*) _t8.data = 0; | ||
| 13513 | + } | ||
| 13514 | + | ||
| 13515 | + builtin__array_set(&ret, i, &(u8[]) { ((u8)((*(u64*)_t8.data))) }); | ||
| 13516 | + } | ||
| 13517 | + return ret; | ||
| 13518 | + } | ||
| 13519 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | ||
| 13520 | +} | ||
| 13521 | +inline u8 builtin__string_u8(string s) { | ||
| 13522 | + _result_u64 _t2 = strconv__common_parse_uint(s, 0, 8, false, false); | ||
| 13523 | + if (_t2.is_error) { | ||
| 13524 | + *(u64*) _t2.data = 0; | ||
| 13525 | + } | ||
| 13526 | + | ||
| 13527 | + return ((u8)((*(u64*)_t2.data))); | ||
| 13528 | +} | ||
| 13529 | +inline u16 builtin__string_u16(string s) { | ||
| 13530 | + _result_u64 _t2 = strconv__common_parse_uint(s, 0, 16, false, false); | ||
| 13531 | + if (_t2.is_error) { | ||
| 13532 | + *(u64*) _t2.data = 0; | ||
| 13533 | + } | ||
| 13534 | + | ||
| 13535 | + return ((u16)((*(u64*)_t2.data))); | ||
| 13536 | +} | ||
| 13537 | +inline u32 builtin__string_u32(string s) { | ||
| 13538 | + _result_u64 _t2 = strconv__common_parse_uint(s, 0, 32, false, false); | ||
| 13539 | + if (_t2.is_error) { | ||
| 13540 | + *(u64*) _t2.data = 0; | ||
| 13541 | + } | ||
| 13542 | + | ||
| 13543 | + return ((u32)((*(u64*)_t2.data))); | ||
| 13544 | +} | ||
| 13545 | +inline u64 builtin__string_u64(string s) { | ||
| 13546 | + _result_u64 _t2 = strconv__common_parse_uint(s, 0, 64, false, false); | ||
| 13547 | + if (_t2.is_error) { | ||
| 13548 | + *(u64*) _t2.data = 0; | ||
| 13549 | + } | ||
| 13550 | + | ||
| 13551 | + return (*(u64*)_t2.data); | ||
| 13552 | +} | ||
| 13553 | +inline _result_u64 builtin__string_parse_uint(string s, int _base, int _bit_size) { | ||
| 13554 | + return strconv__parse_uint(s, _base, _bit_size); | ||
| 13555 | +} | ||
| 13556 | +inline _result_i64 builtin__string_parse_int(string s, int _base, int _bit_size) { | ||
| 13557 | + return strconv__parse_int(s, _base, _bit_size); | ||
| 13558 | +} | ||
| 13559 | +VV_LOC bool builtin__string__eq(string s, string a) { | ||
| 13560 | + if (s.str == 0) { | ||
| 13561 | + return a.str == 0 || a.len == 0; | ||
| 13562 | + } | ||
| 13563 | + if (s.len != a.len) { | ||
| 13564 | + return false; | ||
| 13565 | + } | ||
| 13566 | + { // Unsafe block | ||
| 13567 | + return builtin__vmemcmp(s.str, a.str, a.len) == 0; | ||
| 13568 | + } | ||
| 13569 | + return 0; | ||
| 13570 | +} | ||
| 13571 | +int builtin__string_compare(string s, string a) { | ||
| 13572 | + int min_len = (s.len < a.len ? (s.len) : (a.len)); | ||
| 13573 | + for (int i = 0; i < min_len; ++i) { | ||
| 13574 | + if (s.str[ i] < a.str[ i]) { | ||
| 13575 | + return -1; | ||
| 13576 | + } | ||
| 13577 | + if (s.str[ i] > a.str[ i]) { | ||
| 13578 | + return 1; | ||
| 13579 | + } | ||
| 13580 | + } | ||
| 13581 | + if (s.len < a.len) { | ||
| 13582 | + return -1; | ||
| 13583 | + } | ||
| 13584 | + if (s.len > a.len) { | ||
| 13585 | + return 1; | ||
| 13586 | + } | ||
| 13587 | + return 0; | ||
| 13588 | +} | ||
| 13589 | +VV_LOC bool builtin__string__lt(string s, string a) { | ||
| 13590 | + for (int i = 0; i < s.len; ++i) { | ||
| 13591 | + if (i >= a.len || s.str[ i] > a.str[ i]) { | ||
| 13592 | + return false; | ||
| 13593 | + } else if (s.str[ i] < a.str[ i]) { | ||
| 13594 | + return true; | ||
| 13595 | + } | ||
| 13596 | + } | ||
| 13597 | + if (s.len < a.len) { | ||
| 13598 | + return true; | ||
| 13599 | + } | ||
| 13600 | + return false; | ||
| 13601 | +} | ||
| 13602 | +VV_LOC string builtin__string__plus(string s, string a) { | ||
| 13603 | + int slen = (s.len > 0 ? (s.len) : (0)); | ||
| 13604 | + int alen = (a.len > 0 ? (a.len) : (0)); | ||
| 13605 | + int new_len = alen + slen; | ||
| 13606 | + string _t1 = ((string){.str = builtin__malloc_noscan(new_len + 1), .len = new_len}); | ||
| 13607 | + string res = _t1; | ||
| 13608 | + { // Unsafe block | ||
| 13609 | + if (slen > 0) { | ||
| 13610 | + builtin__vmemcpy(res.str, s.str, slen); | ||
| 13611 | + } | ||
| 13612 | + if (alen > 0) { | ||
| 13613 | + builtin__vmemcpy(res.str + slen, a.str, alen); | ||
| 13614 | + } | ||
| 13615 | + res.str[new_len] = 0; | ||
| 13616 | + } | ||
| 13617 | + return res; | ||
| 13618 | +} | ||
| 13619 | +VV_LOC string builtin__string_plus_many(int data_len, string* input_base) { | ||
| 13620 | + int new_len = 0; | ||
| 13621 | + for (int i = 0; i < data_len; i++) { | ||
| 13622 | + string part = input_base[i]; | ||
| 13623 | + new_len += (part.len > 0 ? (part.len) : (0)); | ||
| 13624 | + } | ||
| 13625 | + string _t1 = ((string){.str = builtin__malloc_noscan(new_len + 1), .len = new_len}); | ||
| 13626 | + string res = _t1; | ||
| 13627 | + int offset = 0; | ||
| 13628 | + { // Unsafe block | ||
| 13629 | + for (int i = 0; i < data_len; i++) { | ||
| 13630 | + string part = input_base[i]; | ||
| 13631 | + int part_len = (part.len > 0 ? (part.len) : (0)); | ||
| 13632 | + if (part_len > 0) { | ||
| 13633 | + builtin__vmemcpy(res.str + offset, part.str, part_len); | ||
| 13634 | + offset += part_len; | ||
| 13635 | + } | ||
| 13636 | + } | ||
| 13637 | + res.str[new_len] = 0; | ||
| 13638 | + } | ||
| 13639 | + return res; | ||
| 13640 | +} | ||
| 13641 | +VV_LOC string builtin__string_plus_two(string s, string a, string b) { | ||
| 13642 | + int slen = (s.len > 0 ? (s.len) : (0)); | ||
| 13643 | + int alen = (a.len > 0 ? (a.len) : (0)); | ||
| 13644 | + int blen = (b.len > 0 ? (b.len) : (0)); | ||
| 13645 | + int new_len = alen + blen + slen; | ||
| 13646 | + string _t1 = ((string){.str = builtin__malloc_noscan(new_len + 1), .len = new_len}); | ||
| 13647 | + string res = _t1; | ||
| 13648 | + { // Unsafe block | ||
| 13649 | + if (slen > 0) { | ||
| 13650 | + builtin__vmemcpy(res.str, s.str, slen); | ||
| 13651 | + } | ||
| 13652 | + if (alen > 0) { | ||
| 13653 | + builtin__vmemcpy(res.str + slen, a.str, alen); | ||
| 13654 | + } | ||
| 13655 | + if (blen > 0) { | ||
| 13656 | + builtin__vmemcpy(res.str + slen + alen, b.str, blen); | ||
| 13657 | + } | ||
| 13658 | + res.str[new_len] = 0; | ||
| 13659 | + } | ||
| 13660 | + return res; | ||
| 13661 | +} | ||
| 13662 | +Array_string builtin__string_split_any(string s, string delim) { | ||
| 13663 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | ||
| 13664 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | ||
| 13665 | + int i = 0; | ||
| 13666 | + if (s.len > 0) { | ||
| 13667 | + if (delim.len <= 0) { | ||
| 13668 | + Array_string _t1 = builtin__string_split(s, _S("")); | ||
| 13669 | + { // defer begin | ||
| 13670 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | ||
| 13671 | + } // defer end | ||
| 13672 | + return _t1; | ||
| 13673 | + } | ||
| 13674 | + for (int index = 0; index < s.len; ++index) { | ||
| 13675 | + u8 ch = s.str[index]; | ||
| 13676 | + for (int _t2 = 0; _t2 < delim.len; ++_t2) { | ||
| 13677 | + u8 delim_ch = delim.str[_t2]; | ||
| 13678 | + if (ch == delim_ch) { | ||
| 13679 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, i, index) })); | ||
| 13680 | + i = index + 1; | ||
| 13681 | + break; | ||
| 13682 | + } | ||
| 13683 | + } | ||
| 13684 | + } | ||
| 13685 | + if (i < s.len) { | ||
| 13686 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, i, 2147483647) })); | ||
| 13687 | + } | ||
| 13688 | + } | ||
| 13689 | + Array_string _t5 = res; | ||
| 13690 | + { // defer begin | ||
| 13691 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | ||
| 13692 | + } // defer end | ||
| 13693 | + return _t5; | ||
| 13694 | +} | ||
| 13695 | +Array_string builtin__string_rsplit_any(string s, string delim) { | ||
| 13696 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | ||
| 13697 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | ||
| 13698 | + int i = s.len - 1; | ||
| 13699 | + if (s.len > 0) { | ||
| 13700 | + if (delim.len <= 0) { | ||
| 13701 | + Array_string _t1 = builtin__string_rsplit(s, _S("")); | ||
| 13702 | + { // defer begin | ||
| 13703 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | ||
| 13704 | + } // defer end | ||
| 13705 | + return _t1; | ||
| 13706 | + } | ||
| 13707 | + int rbound = s.len; | ||
| 13708 | + for (;;) { | ||
| 13709 | + if (!(i >= 0)) break; | ||
| 13710 | + for (int _t2 = 0; _t2 < delim.len; ++_t2) { | ||
| 13711 | + u8 delim_ch = delim.str[_t2]; | ||
| 13712 | + if (s.str[ i] == delim_ch) { | ||
| 13713 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, i + 1, rbound) })); | ||
| 13714 | + rbound = i; | ||
| 13715 | + break; | ||
| 13716 | + } | ||
| 13717 | + } | ||
| 13718 | + i--; | ||
| 13719 | + } | ||
| 13720 | + if (rbound > 0) { | ||
| 13721 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, 0, rbound) })); | ||
| 13722 | + } | ||
| 13723 | + } | ||
| 13724 | + Array_string _t5 = res; | ||
| 13725 | + { // defer begin | ||
| 13726 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | ||
| 13727 | + } // defer end | ||
| 13728 | + return _t5; | ||
| 13729 | +} | ||
| 13730 | +inline Array_string builtin__string_split(string s, string delim) { | ||
| 13731 | + return builtin__string_split_nth(s, delim, 0); | ||
| 13732 | +} | ||
| 13733 | +inline Array_string builtin__string_rsplit(string s, string delim) { | ||
| 13734 | + return builtin__string_rsplit_nth(s, delim, 0); | ||
| 13735 | +} | ||
| 13736 | +_option_multi_return_string_string builtin__string_split_once(string s, string delim) { | ||
| 13737 | + Array_string result = builtin__string_split_nth(s, delim, 2); | ||
| 13738 | + if (result.len != 2) { | ||
| 13739 | + _option_multi_return_string_string _t1 = (_option_multi_return_string_string){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | ||
| 13740 | + return _t1; | ||
| 13741 | + } | ||
| 13742 | + _option_multi_return_string_string _t2; | ||
| 13743 | + builtin___option_ok(&(multi_return_string_string[]) { (multi_return_string_string){.arg0=(*(string*)builtin__array_get(result, 0)), .arg1=(*(string*)builtin__array_get(result, 1))} }, (_option*)(&_t2), sizeof(multi_return_string_string)); | ||
| 13744 | + return _t2; | ||
| 13745 | +} | ||
| 13746 | +_option_multi_return_string_string builtin__string_rsplit_once(string s, string delim) { | ||
| 13747 | + Array_string result = builtin__string_rsplit_nth(s, delim, 2); | ||
| 13748 | + if (result.len != 2) { | ||
| 13749 | + _option_multi_return_string_string _t1 = (_option_multi_return_string_string){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | ||
| 13750 | + return _t1; | ||
| 13751 | + } | ||
| 13752 | + _option_multi_return_string_string _t2; | ||
| 13753 | + builtin___option_ok(&(multi_return_string_string[]) { (multi_return_string_string){.arg0=(*(string*)builtin__array_get(result, 1)), .arg1=(*(string*)builtin__array_get(result, 0))} }, (_option*)(&_t2), sizeof(multi_return_string_string)); | ||
| 13754 | + return _t2; | ||
| 13755 | +} | ||
| 13756 | +Array_string builtin__string_split_n(string s, string delim, int n) { | ||
| 13757 | + return builtin__string_split_nth(s, delim, n); | ||
| 13758 | +} | ||
| 13759 | +Array_string builtin__string_split_nth(string s, string delim, int nth) { | ||
| 13760 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | ||
| 13761 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | ||
| 13762 | + switch (delim.len) { | ||
| 13763 | + case 0: { | ||
| 13764 | + for (int i = 0; i < s.len; ++i) { | ||
| 13765 | + u8 ch = s.str[i]; | ||
| 13766 | + if (nth > 0 && res.len == nth - 1) { | ||
| 13767 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, i, 2147483647) })); | ||
| 13768 | + break; | ||
| 13769 | + } | ||
| 13770 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__u8_ascii_str(ch) })); | ||
| 13771 | + } | ||
| 13772 | + break; | ||
| 13773 | + } | ||
| 13774 | + case 1: { | ||
| 13775 | + u8 delim_byte = delim.str[ 0]; | ||
| 13776 | + int start = 0; | ||
| 13777 | + for (int i = 0; i < s.len; ++i) { | ||
| 13778 | + u8 ch = s.str[i]; | ||
| 13779 | + if (ch == delim_byte) { | ||
| 13780 | + if (nth > 0 && res.len == nth - 1) { | ||
| 13781 | + break; | ||
| 13782 | + } | ||
| 13783 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, start, i) })); | ||
| 13784 | + start = i + 1; | ||
| 13785 | + } | ||
| 13786 | + } | ||
| 13787 | + if (nth < 1 || res.len < nth) { | ||
| 13788 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, start, 2147483647) })); | ||
| 13789 | + } | ||
| 13790 | + break; | ||
| 13791 | + } | ||
| 13792 | + default: { | ||
| 13793 | + { | ||
| 13794 | + int start = 0; | ||
| 13795 | + for (int i = 0; i + delim.len <= s.len; ) { | ||
| 13796 | + if (builtin__string__eq(builtin__string_substr_unsafe(s, i, i + delim.len), delim)) { | ||
| 13797 | + if (nth > 0 && res.len == nth - 1) { | ||
| 13798 | + break; | ||
| 13799 | + } | ||
| 13800 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, start, i) })); | ||
| 13801 | + i += delim.len; | ||
| 13802 | + start = i; | ||
| 13803 | + } else { | ||
| 13804 | + i++; | ||
| 13805 | + } | ||
| 13806 | + } | ||
| 13807 | + if (nth < 1 || res.len < nth) { | ||
| 13808 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, start, 2147483647) })); | ||
| 13809 | + } | ||
| 13810 | + break; | ||
| 13811 | + } | ||
| 13812 | + } | ||
| 13813 | + } | ||
| 13814 | + | ||
| 13815 | + Array_string _t7 = res; | ||
| 13816 | + { // defer begin | ||
| 13817 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | ||
| 13818 | + } // defer end | ||
| 13819 | + return _t7; | ||
| 13820 | +} | ||
| 13821 | +Array_string builtin__string_rsplit_nth(string s, string delim, int nth) { | ||
| 13822 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | ||
| 13823 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | ||
| 13824 | + switch (delim.len) { | ||
| 13825 | + case 0: { | ||
| 13826 | + for (int i = s.len - 1; i >= 0; i--) { | ||
| 13827 | + if (nth > 0 && res.len == nth - 1) { | ||
| 13828 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, 0, i + 1) })); | ||
| 13829 | + break; | ||
| 13830 | + } | ||
| 13831 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__u8_ascii_str(s.str[ i]) })); | ||
| 13832 | + } | ||
| 13833 | + break; | ||
| 13834 | + } | ||
| 13835 | + case 1: { | ||
| 13836 | + u8 delim_byte = delim.str[ 0]; | ||
| 13837 | + int rbound = s.len; | ||
| 13838 | + for (int i = s.len - 1; i >= 0; i--) { | ||
| 13839 | + if (s.str[ i] == delim_byte) { | ||
| 13840 | + if (nth > 0 && res.len == nth - 1) { | ||
| 13841 | + break; | ||
| 13842 | + } | ||
| 13843 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, i + 1, rbound) })); | ||
| 13844 | + rbound = i; | ||
| 13845 | + } | ||
| 13846 | + } | ||
| 13847 | + if (nth < 1 || res.len < nth) { | ||
| 13848 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, 0, rbound) })); | ||
| 13849 | + } | ||
| 13850 | + break; | ||
| 13851 | + } | ||
| 13852 | + default: { | ||
| 13853 | + { | ||
| 13854 | + int rbound = s.len; | ||
| 13855 | + for (int i = s.len - 1; i >= 0; i--) { | ||
| 13856 | + bool is_delim = i - delim.len >= 0 && builtin__string__eq(builtin__string_substr(s, i - delim.len, i), delim); | ||
| 13857 | + if (is_delim) { | ||
| 13858 | + if (nth > 0 && res.len == nth - 1) { | ||
| 13859 | + break; | ||
| 13860 | + } | ||
| 13861 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, i, rbound) })); | ||
| 13862 | + i -= delim.len; | ||
| 13863 | + rbound = i; | ||
| 13864 | + } | ||
| 13865 | + } | ||
| 13866 | + if (nth < 1 || res.len < nth) { | ||
| 13867 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, 0, rbound) })); | ||
| 13868 | + } | ||
| 13869 | + break; | ||
| 13870 | + } | ||
| 13871 | + } | ||
| 13872 | + } | ||
| 13873 | + | ||
| 13874 | + Array_string _t7 = res; | ||
| 13875 | + { // defer begin | ||
| 13876 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | ||
| 13877 | + } // defer end | ||
| 13878 | + return _t7; | ||
| 13879 | +} | ||
| 13880 | +Array_string builtin__string_split_into_lines(string s) { | ||
| 13881 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | ||
| 13882 | + if (s.len == 0) { | ||
| 13883 | + return res; | ||
| 13884 | + } | ||
| 13885 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | ||
| 13886 | + rune cr = '\r'; | ||
| 13887 | + rune lf = '\n'; | ||
| 13888 | + int line_start = 0; | ||
| 13889 | + for (int i = 0; i < s.len; i++) { | ||
| 13890 | + if (line_start <= i) { | ||
| 13891 | + if (s.str[ i] == lf) { | ||
| 13892 | + builtin__array_push((array*)&res, _MOV((string[]){ (line_start == i ? (_S("")) : (builtin__string_substr(s, line_start, i))) })); | ||
| 13893 | + line_start = i + 1; | ||
| 13894 | + } else if (s.str[ i] == cr) { | ||
| 13895 | + builtin__array_push((array*)&res, _MOV((string[]){ (line_start == i ? (_S("")) : (builtin__string_substr(s, line_start, i))) })); | ||
| 13896 | + if ((i + 1) < s.len && s.str[ i + 1] == lf) { | ||
| 13897 | + line_start = i + 2; | ||
| 13898 | + } else { | ||
| 13899 | + line_start = i + 1; | ||
| 13900 | + } | ||
| 13901 | + } | ||
| 13902 | + } | ||
| 13903 | + } | ||
| 13904 | + if (line_start < s.len) { | ||
| 13905 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, line_start, 2147483647) })); | ||
| 13906 | + } | ||
| 13907 | + Array_string _t5 = res; | ||
| 13908 | + { // defer begin | ||
| 13909 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | ||
| 13910 | + } // defer end | ||
| 13911 | + return _t5; | ||
| 13912 | +} | ||
| 13913 | +Array_string builtin__string_split_by_space(string s) { | ||
| 13914 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | ||
| 13915 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | ||
| 13916 | + Array_string _t1 = builtin__string_split_any(s, _S(" \n\t\v\f\r")); | ||
| 13917 | + for (int _t2 = 0; _t2 < _t1.len; ++_t2) { | ||
| 13918 | + string word = ((string*)_t1.data)[_t2]; | ||
| 13919 | + if ((word).len != 0) { | ||
| 13920 | + builtin__array_push((array*)&res, _MOV((string[]){ word })); | ||
| 13921 | + } | ||
| 13922 | + } | ||
| 13923 | + Array_string _t4 = res; | ||
| 13924 | + { // defer begin | ||
| 13925 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | ||
| 13926 | + } // defer end | ||
| 13927 | + return _t4; | ||
| 13928 | +} | ||
| 13929 | +string builtin__string_substr(string s, int start, int _end) { | ||
| 13930 | + int end = (_end == _const_max_i64 || _end == _const_max_i32 ? (s.len) : (_end)); | ||
| 13931 | + #if 1 | ||
| 13932 | + { | ||
| 13933 | + if (start > end || start > s.len || end > s.len || start < 0 || end < 0) { | ||
| 13934 | + builtin___v_panic(builtin__string_plus_many(8, _MOV((string[8]){_S("substr("), builtin__impl_i64_to_string(start), _S(", "), builtin__impl_i64_to_string(end), _S(") out of bounds (len="), builtin__impl_i64_to_string(s.len), _S(") s="), s}))); | ||
| 13935 | + VUNREACHABLE(); | ||
| 13936 | + } | ||
| 13937 | + } | ||
| 13938 | + #endif | ||
| 13939 | + int len = end - start; | ||
| 13940 | + if (len == s.len) { | ||
| 13941 | + return builtin__string_clone(s); | ||
| 13942 | + } | ||
| 13943 | + string _t3 = ((string){.str = builtin__malloc_noscan(len + 1), .len = len}); | ||
| 13944 | + string res = _t3; | ||
| 13945 | + { // Unsafe block | ||
| 13946 | + builtin__vmemcpy(res.str, s.str + start, len); | ||
| 13947 | + res.str[len] = 0; | ||
| 13948 | + } | ||
| 13949 | + return res; | ||
| 13950 | +} | ||
| 13951 | +string builtin__string_substr_unsafe(string s, int start, int _end) { | ||
| 13952 | + int end = (_end == 2147483647 ? (s.len) : (_end)); | ||
| 13953 | + int len = end - start; | ||
| 13954 | + if (len == s.len) { | ||
| 13955 | + return s; | ||
| 13956 | + } | ||
| 13957 | + return ((string){.str = s.str + start, .len = len}); | ||
| 13958 | +} | ||
| 13959 | +string builtin__string_substr_or(string s, int start, int _end, string fallback) { | ||
| 13960 | + int end = (_end == _const_max_i64 || _end == _const_max_i32 ? (s.len) : (_end)); | ||
| 13961 | + if (start < 0 || start > end || end > s.len) { | ||
| 13962 | + return fallback; | ||
| 13963 | + } | ||
| 13964 | + return builtin__string_substr(s, start, end); | ||
| 13965 | +} | ||
| 13966 | +_result_string builtin__string_substr_with_check(string s, int start, int _end) { | ||
| 13967 | + int end = (_end == _const_max_i64 || _end == _const_max_i32 ? (s.len) : (_end)); | ||
| 13968 | + if (start > end || start > s.len || end > s.len || start < 0 || end < 0) { | ||
| 13969 | + return (_result_string){ .is_error=true, .err=builtin___v_error(builtin__string_plus_many(7, _MOV((string[7]){_S("substr("), builtin__impl_i64_to_string(start), _S(", "), builtin__impl_i64_to_string(end), _S(") out of bounds (len="), builtin__impl_i64_to_string(s.len), _S(")")}))), .data={E_STRUCT} }; | ||
| 13970 | + } | ||
| 13971 | + int len = end - start; | ||
| 13972 | + if (len == s.len) { | ||
| 13973 | + _result_string _t2; | ||
| 13974 | + builtin___result_ok(&(string[]) { builtin__string_clone(s) }, (_result*)(&_t2), sizeof(string)); | ||
| 13975 | + | ||
| 13976 | + return _t2; | ||
| 13977 | + } | ||
| 13978 | + string _t3 = ((string){.str = builtin__malloc_noscan(len + 1), .len = len}); | ||
| 13979 | + string res = _t3; | ||
| 13980 | + { // Unsafe block | ||
| 13981 | + builtin__vmemcpy(res.str, s.str + start, len); | ||
| 13982 | + res.str[len] = 0; | ||
| 13983 | + } | ||
| 13984 | + _result_string _t4; | ||
| 13985 | + builtin___result_ok(&(string[]) { res }, (_result*)(&_t4), sizeof(string)); | ||
| 13986 | + | ||
| 13987 | + return _t4; | ||
| 13988 | +} | ||
| 13989 | +string builtin__string_substr_ni(string s, int _start, int _end) { | ||
| 13990 | + int start = _start; | ||
| 13991 | + int end = (_end == _const_max_i64 || _end == _const_max_i32 ? (s.len) : (_end)); | ||
| 13992 | + if (start < 0) { | ||
| 13993 | + start = s.len + start; | ||
| 13994 | + if (start < 0) { | ||
| 13995 | + start = 0; | ||
| 13996 | + } | ||
| 13997 | + } | ||
| 13998 | + if (end < 0) { | ||
| 13999 | + end = s.len + end; | ||
| 14000 | + if (end < 0) { | ||
| 14001 | + end = 0; | ||
| 14002 | + } | ||
| 14003 | + } | ||
| 14004 | + if (end >= s.len) { | ||
| 14005 | + end = s.len; | ||
| 14006 | + } | ||
| 14007 | + if (start > s.len || end < start) { | ||
| 14008 | + return _S(""); | ||
| 14009 | + } | ||
| 14010 | + int len = end - start; | ||
| 14011 | + string _t2 = ((string){.str = builtin__malloc_noscan(len + 1), .len = len}); | ||
| 14012 | + string res = _t2; | ||
| 14013 | + { // Unsafe block | ||
| 14014 | + builtin__vmemcpy(res.str, s.str + start, len); | ||
| 14015 | + res.str[len] = 0; | ||
| 14016 | + } | ||
| 14017 | + return res; | ||
| 14018 | +} | ||
| 14019 | +int builtin__string_index_(string s, string p) { | ||
| 14020 | + if (p.len > s.len || p.len == 0 || ((u64)(s.str)) <= 0xFFFF || ((u64)(p.str)) <= 0xFFFF) { | ||
| 14021 | + return -1; | ||
| 14022 | + } | ||
| 14023 | + if (p.len > 2) { | ||
| 14024 | + return builtin__string_index_kmp(s, p); | ||
| 14025 | + } | ||
| 14026 | + int i = 0; | ||
| 14027 | + for (;;) { | ||
| 14028 | + if (!(i < s.len)) break; | ||
| 14029 | + int j = 0; | ||
| 14030 | + for (;;) { | ||
| 14031 | + if (!(j < p.len && s.str[i + j] == p.str[j])) break; | ||
| 14032 | + j++; | ||
| 14033 | + } | ||
| 14034 | + if (j == p.len) { | ||
| 14035 | + return i; | ||
| 14036 | + } | ||
| 14037 | + i++; | ||
| 14038 | + } | ||
| 14039 | + return -1; | ||
| 14040 | +} | ||
| 14041 | +_option_int builtin__string_index(string s, string p) { | ||
| 14042 | + int idx = builtin__string_index_(s, p); | ||
| 14043 | + if (idx == -1) { | ||
| 14044 | + return (_option_int){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | ||
| 14045 | + } | ||
| 14046 | + _option_int _t2; | ||
| 14047 | + builtin___option_ok(&(int[]) { idx }, (_option*)(&_t2), sizeof(int)); | ||
| 14048 | + | ||
| 14049 | + return _t2; | ||
| 14050 | +} | ||
| 14051 | +inline _option_int builtin__string_last_index(string s, string needle) { | ||
| 14052 | + int idx = builtin__string_index_last_(s, needle); | ||
| 14053 | + if (idx == -1) { | ||
| 14054 | + return (_option_int){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | ||
| 14055 | + } | ||
| 14056 | + _option_int _t2; | ||
| 14057 | + builtin___option_ok(&(int[]) { idx }, (_option*)(&_t2), sizeof(int)); | ||
| 14058 | + | ||
| 14059 | + return _t2; | ||
| 14060 | +} | ||
| 14061 | +VV_LOC int builtin__string_index_kmp(string s, string p) { | ||
| 14062 | + if (p.len > s.len) { | ||
| 14063 | + return -1; | ||
| 14064 | + } | ||
| 14065 | + Array_fixed_int_20 stack_prefixes = {0}; | ||
| 14066 | + int* p_prefixes = &stack_prefixes[0]; | ||
| 14067 | + if (p.len > _const_kmp_stack_buffer_size) { | ||
| 14068 | + p_prefixes = ((int*)(builtin__vcalloc(p.len * ((int)(sizeof(int)))))); | ||
| 14069 | + } | ||
| 14070 | + int j = 0; | ||
| 14071 | + for (int i = 1; i < p.len; i++) { | ||
| 14072 | + for (;;) { | ||
| 14073 | + if (!(p.str[j] != p.str[i] && j > 0)) break; | ||
| 14074 | + j = p_prefixes[j - 1]; | ||
| 14075 | + } | ||
| 14076 | + if (p.str[j] == p.str[i]) { | ||
| 14077 | + j++; | ||
| 14078 | + } | ||
| 14079 | + { // Unsafe block | ||
| 14080 | + p_prefixes[i] = j; | ||
| 14081 | + } | ||
| 14082 | + } | ||
| 14083 | + j = 0; | ||
| 14084 | + for (int i = 0; i < s.len; ++i) { | ||
| 14085 | + for (;;) { | ||
| 14086 | + if (!(p.str[j] != s.str[i] && j > 0)) break; | ||
| 14087 | + j = p_prefixes[j - 1]; | ||
| 14088 | + } | ||
| 14089 | + if (p.str[j] == s.str[i]) { | ||
| 14090 | + j++; | ||
| 14091 | + } | ||
| 14092 | + if (j == p.len) { | ||
| 14093 | + int _t2 = (int)(i - p.len) + 1; | ||
| 14094 | + { // defer begin | ||
| 14095 | + if (p.len > _const_kmp_stack_buffer_size) { | ||
| 14096 | + builtin___v_free(p_prefixes); | ||
| 14097 | + } | ||
| 14098 | + } // defer end | ||
| 14099 | + return _t2; | ||
| 14100 | + } | ||
| 14101 | + } | ||
| 14102 | + int _t3 = -1; | ||
| 14103 | + { // defer begin | ||
| 14104 | + if (p.len > _const_kmp_stack_buffer_size) { | ||
| 14105 | + builtin___v_free(p_prefixes); | ||
| 14106 | + } | ||
| 14107 | + } // defer end | ||
| 14108 | + return _t3; | ||
| 14109 | +} | ||
| 14110 | +int builtin__string_index_any(string s, string chars) { | ||
| 14111 | + for (int i = 0; i < s.len; ++i) { | ||
| 14112 | + u8 ss = s.str[i]; | ||
| 14113 | + for (int _t1 = 0; _t1 < chars.len; ++_t1) { | ||
| 14114 | + u8 c = chars.str[_t1]; | ||
| 14115 | + if (c == ss) { | ||
| 14116 | + return i; | ||
| 14117 | + } | ||
| 14118 | + } | ||
| 14119 | + } | ||
| 14120 | + return -1; | ||
| 14121 | +} | ||
| 14122 | +VV_LOC int builtin__string_index_last_(string s, string p) { | ||
| 14123 | + if (p.len > s.len || p.len == 0) { | ||
| 14124 | + return -1; | ||
| 14125 | + } | ||
| 14126 | + int i = s.len - p.len; | ||
| 14127 | + for (;;) { | ||
| 14128 | + if (!(i >= 0)) break; | ||
| 14129 | + int j = 0; | ||
| 14130 | + for (;;) { | ||
| 14131 | + if (!(j < p.len && s.str[i + j] == p.str[j])) break; | ||
| 14132 | + j++; | ||
| 14133 | + } | ||
| 14134 | + if (j == p.len) { | ||
| 14135 | + return i; | ||
| 14136 | + } | ||
| 14137 | + i--; | ||
| 14138 | + } | ||
| 14139 | + return -1; | ||
| 14140 | +} | ||
| 14141 | +_option_int builtin__string_index_after(string s, string p, int start) { | ||
| 14142 | + if (p.len > s.len) { | ||
| 14143 | + return (_option_int){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | ||
| 14144 | + } | ||
| 14145 | + int strt = start; | ||
| 14146 | + if (start < 0) { | ||
| 14147 | + strt = 0; | ||
| 14148 | + } | ||
| 14149 | + if (start >= s.len) { | ||
| 14150 | + return (_option_int){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | ||
| 14151 | + } | ||
| 14152 | + int i = strt; | ||
| 14153 | + for (;;) { | ||
| 14154 | + if (!(i < s.len)) break; | ||
| 14155 | + int j = 0; | ||
| 14156 | + int ii = i; | ||
| 14157 | + for (;;) { | ||
| 14158 | + if (!(j < p.len && s.str[ii] == p.str[j])) break; | ||
| 14159 | + j++; | ||
| 14160 | + ii++; | ||
| 14161 | + } | ||
| 14162 | + if (j == p.len) { | ||
| 14163 | + _option_int _t3; | ||
| 14164 | + builtin___option_ok(&(int[]) { i }, (_option*)(&_t3), sizeof(int)); | ||
| 14165 | + | ||
| 14166 | + return _t3; | ||
| 14167 | + } | ||
| 14168 | + i++; | ||
| 14169 | + } | ||
| 14170 | + return (_option_int){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | ||
| 14171 | +} | ||
| 14172 | +int builtin__string_index_after_(string s, string p, int start) { | ||
| 14173 | + if (p.len > s.len) { | ||
| 14174 | + return -1; | ||
| 14175 | + } | ||
| 14176 | + int strt = start; | ||
| 14177 | + if (start < 0) { | ||
| 14178 | + strt = 0; | ||
| 14179 | + } | ||
| 14180 | + if (start >= s.len) { | ||
| 14181 | + return -1; | ||
| 14182 | + } | ||
| 14183 | + int i = strt; | ||
| 14184 | + for (;;) { | ||
| 14185 | + if (!(i < s.len)) break; | ||
| 14186 | + int j = 0; | ||
| 14187 | + int ii = i; | ||
| 14188 | + for (;;) { | ||
| 14189 | + if (!(j < p.len && s.str[ii] == p.str[j])) break; | ||
| 14190 | + j++; | ||
| 14191 | + ii++; | ||
| 14192 | + } | ||
| 14193 | + if (j == p.len) { | ||
| 14194 | + return i; | ||
| 14195 | + } | ||
| 14196 | + i++; | ||
| 14197 | + } | ||
| 14198 | + return -1; | ||
| 14199 | +} | ||
| 14200 | +int builtin__string_index_u8(string s, u8 c) { | ||
| 14201 | + for (int i = 0; i < s.len; ++i) { | ||
| 14202 | + u8 b = s.str[i]; | ||
| 14203 | + if (b == c) { | ||
| 14204 | + return i; | ||
| 14205 | + } | ||
| 14206 | + } | ||
| 14207 | + return -1; | ||
| 14208 | +} | ||
| 14209 | +inline int builtin__string_last_index_u8(string s, u8 c) { | ||
| 14210 | + for (int i = s.len - 1; i >= 0; i--) { | ||
| 14211 | + if (s.str[ i] == c) { | ||
| 14212 | + return i; | ||
| 14213 | + } | ||
| 14214 | + } | ||
| 14215 | + return -1; | ||
| 14216 | +} | ||
| 14217 | +int builtin__string_count(string s, string substr) { | ||
| 14218 | + if (s.len == 0 || substr.len == 0) { | ||
| 14219 | + return 0; | ||
| 14220 | + } | ||
| 14221 | + if (substr.len > s.len) { | ||
| 14222 | + return 0; | ||
| 14223 | + } | ||
| 14224 | + int n = 0; | ||
| 14225 | + if (substr.len == 1) { | ||
| 14226 | + u8 target = substr.str[ 0]; | ||
| 14227 | + for (int _t3 = 0; _t3 < s.len; ++_t3) { | ||
| 14228 | + u8 letter = s.str[_t3]; | ||
| 14229 | + if (letter == target) { | ||
| 14230 | + n++; | ||
| 14231 | + } | ||
| 14232 | + } | ||
| 14233 | + return n; | ||
| 14234 | + } | ||
| 14235 | + int i = 0; | ||
| 14236 | + for (;;) { | ||
| 14237 | + i = builtin__string_index_after_(s, substr, i); | ||
| 14238 | + if (i == -1) { | ||
| 14239 | + return n; | ||
| 14240 | + } | ||
| 14241 | + i += substr.len; | ||
| 14242 | + n++; | ||
| 14243 | + } | ||
| 14244 | + return 0; | ||
| 14245 | +} | ||
| 14246 | +bool builtin__string_contains_u8(string s, u8 x) { | ||
| 14247 | + for (int _t1 = 0; _t1 < s.len; ++_t1) { | ||
| 14248 | + u8 c = s.str[_t1]; | ||
| 14249 | + if (x == c) { | ||
| 14250 | + return true; | ||
| 14251 | + } | ||
| 14252 | + } | ||
| 14253 | + return false; | ||
| 14254 | +} | ||
| 14255 | +bool builtin__string_contains(string s, string substr) { | ||
| 14256 | + if (substr.len == 0) { | ||
| 14257 | + return true; | ||
| 14258 | + } | ||
| 14259 | + if (substr.len == 1) { | ||
| 14260 | + return builtin__string_contains_u8(s, substr.str[0]); | ||
| 14261 | + } | ||
| 14262 | + return builtin__string_index_(s, substr) != -1; | ||
| 14263 | +} | ||
| 14264 | +bool builtin__string_contains_any(string s, string chars) { | ||
| 14265 | + for (int _t1 = 0; _t1 < chars.len; ++_t1) { | ||
| 14266 | + u8 c = chars.str[_t1]; | ||
| 14267 | + if (builtin__string_contains_u8(s, c)) { | ||
| 14268 | + return true; | ||
| 14269 | + } | ||
| 14270 | + } | ||
| 14271 | + return false; | ||
| 14272 | +} | ||
| 14273 | +bool builtin__string_contains_only(string s, string chars) { | ||
| 14274 | + if (chars.len == 0) { | ||
| 14275 | + return false; | ||
| 14276 | + } | ||
| 14277 | + for (int _t2 = 0; _t2 < s.len; ++_t2) { | ||
| 14278 | + u8 ch = s.str[_t2]; | ||
| 14279 | + int res = 0; | ||
| 14280 | + for (int i = 0; i < chars.len && res == 0; i++) { | ||
| 14281 | + res += (int[]){(ch == chars.str[i])?1:0}[0]; | ||
| 14282 | + } | ||
| 14283 | + if (res == 0) { | ||
| 14284 | + return false; | ||
| 14285 | + } | ||
| 14286 | + } | ||
| 14287 | + return true; | ||
| 14288 | +} | ||
| 14289 | +bool builtin__string_contains_any_substr(string s, Array_string substrs) { | ||
| 14290 | + if (substrs.len == 0) { | ||
| 14291 | + return true; | ||
| 14292 | + } | ||
| 14293 | + for (int _t2 = 0; _t2 < substrs.len; ++_t2) { | ||
| 14294 | + string sub = ((string*)substrs.data)[_t2]; | ||
| 14295 | + if (builtin__string_contains(s, sub)) { | ||
| 14296 | + return true; | ||
| 14297 | + } | ||
| 14298 | + } | ||
| 14299 | + return false; | ||
| 14300 | +} | ||
| 14301 | +bool builtin__string_starts_with(string s, string p) { | ||
| 14302 | + if (p.len > s.len || ((u64)(s.str)) <= 0xFFFF || ((u64)(p.str)) <= 0xFFFF) { | ||
| 14303 | + return false; | ||
| 14304 | + } else if (builtin__vmemcmp(s.str, p.str, p.len) == 0) { | ||
| 14305 | + return true; | ||
| 14306 | + } | ||
| 14307 | + return false; | ||
| 14308 | +} | ||
| 14309 | +bool builtin__string_ends_with(string s, string p) { | ||
| 14310 | + if (p.len > s.len || ((u64)(s.str)) <= 0xFFFF || ((u64)(p.str)) <= 0xFFFF) { | ||
| 14311 | + return false; | ||
| 14312 | + } else if (builtin__vmemcmp(s.str + s.len - p.len, p.str, p.len) == 0) { | ||
| 14313 | + return true; | ||
| 14314 | + } | ||
| 14315 | + return false; | ||
| 14316 | +} | ||
| 14317 | +string builtin__string_to_lower_ascii(string s) { | ||
| 14318 | + { // Unsafe block | ||
| 14319 | + u8* b = builtin__malloc_noscan(s.len + 1); | ||
| 14320 | + for (int i = 0; i < s.len; ++i) { | ||
| 14321 | + if (s.str[i] >= 'A' && s.str[i] <= 'Z') { | ||
| 14322 | + b[i] = (u8)(s.str[i] + 32); | ||
| 14323 | + } else { | ||
| 14324 | + b[i] = s.str[i]; | ||
| 14325 | + } | ||
| 14326 | + } | ||
| 14327 | + b[s.len] = 0; | ||
| 14328 | + return builtin__tos(b, s.len); | ||
| 14329 | + } | ||
| 14330 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 14331 | +} | ||
| 14332 | +string builtin__string_to_lower(string s) { | ||
| 14333 | + if (builtin__string_is_pure_ascii(s)) { | ||
| 14334 | + return builtin__string_to_lower_ascii(s); | ||
| 14335 | + } | ||
| 14336 | + Array_rune runes = builtin__string_runes(s); | ||
| 14337 | + for (int i = 0; i < runes.len; ++i) { | ||
| 14338 | + ((rune*)runes.data)[i] = builtin__rune_to_lower(((rune*)runes.data)[i]); | ||
| 14339 | + } | ||
| 14340 | + return Array_rune_string(runes); | ||
| 14341 | +} | ||
| 14342 | +bool builtin__string_is_lower(string s) { | ||
| 14343 | + if ((s).len == 0 || builtin__u8_is_digit(s.str[ 0])) { | ||
| 14344 | + return false; | ||
| 14345 | + } | ||
| 14346 | + for (int i = 0; i < s.len; ++i) { | ||
| 14347 | + if (s.str[ i] >= 'A' && s.str[ i] <= 'Z') { | ||
| 14348 | + return false; | ||
| 14349 | + } | ||
| 14350 | + } | ||
| 14351 | + return true; | ||
| 14352 | +} | ||
| 14353 | +string builtin__string_to_upper_ascii(string s) { | ||
| 14354 | + { // Unsafe block | ||
| 14355 | + u8* b = builtin__malloc_noscan(s.len + 1); | ||
| 14356 | + for (int i = 0; i < s.len; ++i) { | ||
| 14357 | + if (s.str[i] >= 'a' && s.str[i] <= 'z') { | ||
| 14358 | + b[i] = (u8)(s.str[i] - 32); | ||
| 14359 | + } else { | ||
| 14360 | + b[i] = s.str[i]; | ||
| 14361 | + } | ||
| 14362 | + } | ||
| 14363 | + b[s.len] = 0; | ||
| 14364 | + return builtin__tos(b, s.len); | ||
| 14365 | + } | ||
| 14366 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 14367 | +} | ||
| 14368 | +string builtin__string_to_upper(string s) { | ||
| 14369 | + if (builtin__string_is_pure_ascii(s)) { | ||
| 14370 | + return builtin__string_to_upper_ascii(s); | ||
| 14371 | + } | ||
| 14372 | + Array_rune runes = builtin__string_runes(s); | ||
| 14373 | + for (int i = 0; i < runes.len; ++i) { | ||
| 14374 | + ((rune*)runes.data)[i] = builtin__rune_to_upper(((rune*)runes.data)[i]); | ||
| 14375 | + } | ||
| 14376 | + return Array_rune_string(runes); | ||
| 14377 | +} | ||
| 14378 | +bool builtin__string_is_upper(string s) { | ||
| 14379 | + if ((s).len == 0) { | ||
| 14380 | + return false; | ||
| 14381 | + } | ||
| 14382 | + bool has_upper = false; | ||
| 14383 | + for (int i = 0; i < s.len; ++i) { | ||
| 14384 | + if (s.str[ i] >= 'a' && s.str[ i] <= 'z') { | ||
| 14385 | + return false; | ||
| 14386 | + } | ||
| 14387 | + if (s.str[ i] >= 'A' && s.str[ i] <= 'Z') { | ||
| 14388 | + has_upper = true; | ||
| 14389 | + } | ||
| 14390 | + } | ||
| 14391 | + return has_upper; | ||
| 14392 | +} | ||
| 14393 | +string builtin__string_capitalize(string s) { | ||
| 14394 | + if (s.len == 0) { | ||
| 14395 | + return _S(""); | ||
| 14396 | + } | ||
| 14397 | + if (s.len == 1) { | ||
| 14398 | + return builtin__string_to_upper(builtin__u8_ascii_str(s.str[ 0])); | ||
| 14399 | + } | ||
| 14400 | + Array_rune r = builtin__string_runes(s); | ||
| 14401 | + string letter = builtin__rune_str(((rune*)r.data)[0]); | ||
| 14402 | + string uletter = builtin__string_to_upper(letter); | ||
| 14403 | + Array_rune rrest = builtin__array_slice(r, 1, 2147483647); | ||
| 14404 | + string srest = Array_rune_string(rrest); | ||
| 14405 | + string res = builtin__string__plus(uletter, srest); | ||
| 14406 | + return res; | ||
| 14407 | +} | ||
| 14408 | +string builtin__string_uncapitalize(string s) { | ||
| 14409 | + if (s.len == 0) { | ||
| 14410 | + return _S(""); | ||
| 14411 | + } | ||
| 14412 | + if (s.len == 1) { | ||
| 14413 | + return builtin__string_to_lower(builtin__u8_ascii_str(s.str[ 0])); | ||
| 14414 | + } | ||
| 14415 | + Array_rune r = builtin__string_runes(s); | ||
| 14416 | + string letter = builtin__rune_str(((rune*)r.data)[0]); | ||
| 14417 | + string lletter = builtin__string_to_lower(letter); | ||
| 14418 | + Array_rune rrest = builtin__array_slice(r, 1, 2147483647); | ||
| 14419 | + string srest = Array_rune_string(rrest); | ||
| 14420 | + string res = builtin__string__plus(lletter, srest); | ||
| 14421 | + return res; | ||
| 14422 | +} | ||
| 14423 | +bool builtin__string_is_capital(string s) { | ||
| 14424 | + if (s.len == 0 || !(s.str[ 0] >= 'A' && s.str[ 0] <= 'Z')) { | ||
| 14425 | + return false; | ||
| 14426 | + } | ||
| 14427 | + for (int i = 1; i < s.len; ++i) { | ||
| 14428 | + if (s.str[ i] >= 'A' && s.str[ i] <= 'Z') { | ||
| 14429 | + return false; | ||
| 14430 | + } | ||
| 14431 | + } | ||
| 14432 | + return true; | ||
| 14433 | +} | ||
| 14434 | +bool builtin__string_starts_with_capital(string s) { | ||
| 14435 | + if (s.len == 0 || !builtin__u8_is_capital(s.str[ 0])) { | ||
| 14436 | + return false; | ||
| 14437 | + } | ||
| 14438 | + return true; | ||
| 14439 | +} | ||
| 14440 | +string builtin__string_title(string s) { | ||
| 14441 | + Array_string words = builtin__string_split(s, _S(" ")); | ||
| 14442 | + Array_string tit = builtin____new_array_with_default(0, 0, sizeof(string), 0); | ||
| 14443 | + for (int _t1 = 0; _t1 < words.len; ++_t1) { | ||
| 14444 | + string word = ((string*)words.data)[_t1]; | ||
| 14445 | + builtin__array_push((array*)&tit, _MOV((string[]){ builtin__string_capitalize(word) })); | ||
| 14446 | + } | ||
| 14447 | + string title = Array_string_join(tit, _S(" ")); | ||
| 14448 | + return title; | ||
| 14449 | +} | ||
| 14450 | +bool builtin__string_is_title(string s) { | ||
| 14451 | + Array_string words = builtin__string_split(s, _S(" ")); | ||
| 14452 | + for (int _t1 = 0; _t1 < words.len; ++_t1) { | ||
| 14453 | + string word = ((string*)words.data)[_t1]; | ||
| 14454 | + if (!builtin__string_is_capital(word)) { | ||
| 14455 | + return false; | ||
| 14456 | + } | ||
| 14457 | + } | ||
| 14458 | + return true; | ||
| 14459 | +} | ||
| 14460 | +string builtin__string_find_between(string s, string start, string end) { | ||
| 14461 | + int start_pos = builtin__string_index_(s, start); | ||
| 14462 | + if (start_pos == -1) { | ||
| 14463 | + return _S(""); | ||
| 14464 | + } | ||
| 14465 | + string val = builtin__string_substr(s, start_pos + start.len, 2147483647); | ||
| 14466 | + int end_pos = builtin__string_index_(val, end); | ||
| 14467 | + if (end_pos == -1) { | ||
| 14468 | + return _S(""); | ||
| 14469 | + } | ||
| 14470 | + return builtin__string_substr(val, 0, end_pos); | ||
| 14471 | +} | ||
| 14472 | +inline string builtin__string_trim_space(string s) { | ||
| 14473 | + return builtin__string_trim(s, _S(" \n\t\v\f\r")); | ||
| 14474 | +} | ||
| 14475 | +inline string builtin__string_trim_space_left(string s) { | ||
| 14476 | + return builtin__string_trim_left(s, _S(" \n\t\v\f\r")); | ||
| 14477 | +} | ||
| 14478 | +inline string builtin__string_trim_space_right(string s) { | ||
| 14479 | + return builtin__string_trim_right(s, _S(" \n\t\v\f\r")); | ||
| 14480 | +} | ||
| 14481 | +string builtin__string_trim(string s, string cutset) { | ||
| 14482 | + if ((s).len == 0 || (cutset).len == 0) { | ||
| 14483 | + return builtin__string_clone(s); | ||
| 14484 | + } | ||
| 14485 | + if (builtin__string_is_pure_ascii(cutset)) { | ||
| 14486 | + return builtin__string_trim_chars(s, cutset, TrimMode__trim_both); | ||
| 14487 | + } else { | ||
| 14488 | + return builtin__string_trim_runes(s, cutset, TrimMode__trim_both); | ||
| 14489 | + } | ||
| 14490 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 14491 | +} | ||
| 14492 | +multi_return_int_int builtin__string_trim_indexes(string s, string cutset) { | ||
| 14493 | + int pos_left = 0; | ||
| 14494 | + int pos_right = s.len - 1; | ||
| 14495 | + bool cs_match = true; | ||
| 14496 | + for (;;) { | ||
| 14497 | + if (!(pos_left <= s.len && pos_right >= -1 && cs_match)) break; | ||
| 14498 | + cs_match = false; | ||
| 14499 | + for (int _t1 = 0; _t1 < cutset.len; ++_t1) { | ||
| 14500 | + u8 cs = cutset.str[_t1]; | ||
| 14501 | + if (s.str[ pos_left] == cs) { | ||
| 14502 | + pos_left++; | ||
| 14503 | + cs_match = true; | ||
| 14504 | + break; | ||
| 14505 | + } | ||
| 14506 | + } | ||
| 14507 | + for (int _t2 = 0; _t2 < cutset.len; ++_t2) { | ||
| 14508 | + u8 cs = cutset.str[_t2]; | ||
| 14509 | + if (s.str[ pos_right] == cs) { | ||
| 14510 | + pos_right--; | ||
| 14511 | + cs_match = true; | ||
| 14512 | + break; | ||
| 14513 | + } | ||
| 14514 | + } | ||
| 14515 | + if (pos_left > pos_right) { | ||
| 14516 | + return (multi_return_int_int){.arg0=0, .arg1=0}; | ||
| 14517 | + } | ||
| 14518 | + } | ||
| 14519 | + return (multi_return_int_int){.arg0=pos_left, .arg1=pos_right + 1}; | ||
| 14520 | +} | ||
| 14521 | +VV_LOC string builtin__string_trim_chars(string s, string cutset, TrimMode mode) { | ||
| 14522 | + int pos_left = 0; | ||
| 14523 | + int pos_right = s.len - 1; | ||
| 14524 | + bool cs_match = true; | ||
| 14525 | + for (;;) { | ||
| 14526 | + if (!(pos_left <= s.len && pos_right >= -1 && cs_match)) break; | ||
| 14527 | + cs_match = false; | ||
| 14528 | + if (mode == TrimMode__trim_left || mode == TrimMode__trim_both) { | ||
| 14529 | + for (int _t1 = 0; _t1 < cutset.len; ++_t1) { | ||
| 14530 | + u8 cs = cutset.str[_t1]; | ||
| 14531 | + if (s.str[ pos_left] == cs) { | ||
| 14532 | + pos_left++; | ||
| 14533 | + cs_match = true; | ||
| 14534 | + break; | ||
| 14535 | + } | ||
| 14536 | + } | ||
| 14537 | + } | ||
| 14538 | + if (mode == TrimMode__trim_right || mode == TrimMode__trim_both) { | ||
| 14539 | + for (int _t2 = 0; _t2 < cutset.len; ++_t2) { | ||
| 14540 | + u8 cs = cutset.str[_t2]; | ||
| 14541 | + if (s.str[ pos_right] == cs) { | ||
| 14542 | + pos_right--; | ||
| 14543 | + cs_match = true; | ||
| 14544 | + break; | ||
| 14545 | + } | ||
| 14546 | + } | ||
| 14547 | + } | ||
| 14548 | + if (pos_left > pos_right) { | ||
| 14549 | + return _S(""); | ||
| 14550 | + } | ||
| 14551 | + } | ||
| 14552 | + return builtin__string_substr(s, pos_left, pos_right + 1); | ||
| 14553 | +} | ||
| 14554 | +VV_LOC string builtin__string_trim_runes(string s, string cutset, TrimMode mode) { | ||
| 14555 | + Array_rune s_runes = builtin__string_runes(s); | ||
| 14556 | + Array_rune cs_runes = builtin__string_runes(cutset); | ||
| 14557 | + int pos_left = 0; | ||
| 14558 | + int pos_right = s_runes.len - 1; | ||
| 14559 | + bool cs_match = true; | ||
| 14560 | + for (;;) { | ||
| 14561 | + if (!(pos_left <= s_runes.len && pos_right >= -1 && cs_match)) break; | ||
| 14562 | + cs_match = false; | ||
| 14563 | + if (mode == TrimMode__trim_left || mode == TrimMode__trim_both) { | ||
| 14564 | + for (int _t1 = 0; _t1 < cs_runes.len; ++_t1) { | ||
| 14565 | + rune cs = ((rune*)cs_runes.data)[_t1]; | ||
| 14566 | + if (((rune*)s_runes.data)[pos_left] == cs) { | ||
| 14567 | + pos_left++; | ||
| 14568 | + cs_match = true; | ||
| 14569 | + break; | ||
| 14570 | + } | ||
| 14571 | + } | ||
| 14572 | + } | ||
| 14573 | + if (mode == TrimMode__trim_right || mode == TrimMode__trim_both) { | ||
| 14574 | + for (int _t2 = 0; _t2 < cs_runes.len; ++_t2) { | ||
| 14575 | + rune cs = ((rune*)cs_runes.data)[_t2]; | ||
| 14576 | + if (((rune*)s_runes.data)[pos_right] == cs) { | ||
| 14577 | + pos_right--; | ||
| 14578 | + cs_match = true; | ||
| 14579 | + break; | ||
| 14580 | + } | ||
| 14581 | + } | ||
| 14582 | + } | ||
| 14583 | + if (pos_left > pos_right) { | ||
| 14584 | + return _S(""); | ||
| 14585 | + } | ||
| 14586 | + } | ||
| 14587 | + return Array_rune_string(builtin__array_slice(s_runes, pos_left, pos_right + 1)); | ||
| 14588 | +} | ||
| 14589 | +string builtin__string_trim_left(string s, string cutset) { | ||
| 14590 | + if ((s).len == 0 || (cutset).len == 0) { | ||
| 14591 | + return builtin__string_clone(s); | ||
| 14592 | + } | ||
| 14593 | + if (builtin__string_is_pure_ascii(cutset)) { | ||
| 14594 | + return builtin__string_trim_chars(s, cutset, TrimMode__trim_left); | ||
| 14595 | + } else { | ||
| 14596 | + return builtin__string_trim_runes(s, cutset, TrimMode__trim_left); | ||
| 14597 | + } | ||
| 14598 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 14599 | +} | ||
| 14600 | +string builtin__string_trim_right(string s, string cutset) { | ||
| 14601 | + if (s.len < 1 || cutset.len < 1) { | ||
| 14602 | + return builtin__string_clone(s); | ||
| 14603 | + } | ||
| 14604 | + if (cutset.len == 1) { | ||
| 14605 | + u8 cut = cutset.str[ 0]; | ||
| 14606 | + int pos_right = s.len - 1; | ||
| 14607 | + for (;;) { | ||
| 14608 | + if (!(pos_right >= 0 && s.str[ pos_right] == cut)) break; | ||
| 14609 | + pos_right--; | ||
| 14610 | + } | ||
| 14611 | + if (pos_right < 0) { | ||
| 14612 | + return _S(""); | ||
| 14613 | + } | ||
| 14614 | + return builtin__string_substr(s, 0, pos_right + 1); | ||
| 14615 | + } | ||
| 14616 | + if (cutset.len == 2 && builtin__string_is_pure_ascii(cutset)) { | ||
| 14617 | + u8 cut0 = cutset.str[ 0]; | ||
| 14618 | + u8 cut1 = cutset.str[ 1]; | ||
| 14619 | + int pos_right = s.len - 1; | ||
| 14620 | + for (;;) { | ||
| 14621 | + if (!(pos_right >= 0 && (s.str[ pos_right] == cut0 || s.str[ pos_right] == cut1))) break; | ||
| 14622 | + pos_right--; | ||
| 14623 | + } | ||
| 14624 | + if (pos_right < 0) { | ||
| 14625 | + return _S(""); | ||
| 14626 | + } | ||
| 14627 | + return builtin__string_substr(s, 0, pos_right + 1); | ||
| 14628 | + } | ||
| 14629 | + if (builtin__string_is_pure_ascii(cutset)) { | ||
| 14630 | + return builtin__string_trim_chars(s, cutset, TrimMode__trim_right); | ||
| 14631 | + } else { | ||
| 14632 | + return builtin__string_trim_runes(s, cutset, TrimMode__trim_right); | ||
| 14633 | + } | ||
| 14634 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 14635 | +} | ||
| 14636 | +string builtin__string_trim_string_left(string s, string str) { | ||
| 14637 | + if (builtin__string_starts_with(s, str)) { | ||
| 14638 | + return builtin__string_substr(s, str.len, 2147483647); | ||
| 14639 | + } | ||
| 14640 | + return builtin__string_clone(s); | ||
| 14641 | +} | ||
| 14642 | +string builtin__string_trim_string_right(string s, string str) { | ||
| 14643 | + if (builtin__string_ends_with(s, str)) { | ||
| 14644 | + return builtin__string_substr(s, 0, s.len - str.len); | ||
| 14645 | + } | ||
| 14646 | + return builtin__string_clone(s); | ||
| 14647 | +} | ||
| 14648 | +int builtin__compare_strings(string* a, string* b) { | ||
| 14649 | + bool _t2 = true; | ||
| 14650 | + int_literal _t3 = 0; | ||
| 14651 | + | ||
| 14652 | + if (_t2 == (builtin__string__lt(*a, *b))) { | ||
| 14653 | + _t3 = -1; | ||
| 14654 | + } | ||
| 14655 | + else if (_t2 == (builtin__string__lt(*b, *a))) { | ||
| 14656 | + _t3 = 1; | ||
| 14657 | + } | ||
| 14658 | + else { | ||
| 14659 | + _t3 = 0; | ||
| 14660 | + }return _t3; | ||
| 14661 | +} | ||
| 14662 | +VV_LOC int builtin__compare_strings_by_len(string* a, string* b) { | ||
| 14663 | + bool _t2 = true; | ||
| 14664 | + int_literal _t3 = 0; | ||
| 14665 | + | ||
| 14666 | + if (_t2 == (a->len < b->len)) { | ||
| 14667 | + _t3 = -1; | ||
| 14668 | + } | ||
| 14669 | + else if (_t2 == (a->len > b->len)) { | ||
| 14670 | + _t3 = 1; | ||
| 14671 | + } | ||
| 14672 | + else { | ||
| 14673 | + _t3 = 0; | ||
| 14674 | + }return _t3; | ||
| 14675 | +} | ||
| 14676 | +VV_LOC int builtin__compare_lower_strings(string* a, string* b) { | ||
| 14677 | + string aa = builtin__string_to_lower(*a); | ||
| 14678 | + string bb = builtin__string_to_lower(*b); | ||
| 14679 | + return builtin__compare_strings(&aa, &bb); | ||
| 14680 | +} | ||
| 14681 | +inline void Array_string_sort_ignore_case(Array_string* s) { | ||
| 14682 | + if (s->len > 0) { v_stable_sort(s->data, s->len, s->element_size, builtin__compare_lower_strings_qsort_adapter); } | ||
| 14683 | + ; | ||
| 14684 | +} | ||
| 14685 | +inline void Array_string_sort_by_len(Array_string* s) { | ||
| 14686 | + if (s->len > 0) { v_stable_sort(s->data, s->len, s->element_size, builtin__compare_strings_by_len_qsort_adapter); } | ||
| 14687 | + ; | ||
| 14688 | +} | ||
| 14689 | +inline string builtin__string_str(string s) { | ||
| 14690 | + return builtin__string_clone(s); | ||
| 14691 | +} | ||
| 14692 | +VV_LOC u8 builtin__string_at(string s, int idx) { | ||
| 14693 | + #if 1 | ||
| 14694 | + { | ||
| 14695 | + if (idx < 0 || idx >= s.len) { | ||
| 14696 | + builtin__panic_n2(_S("string index out of range(idx,s.len):"), idx, s.len); | ||
| 14697 | + VUNREACHABLE(); | ||
| 14698 | + } | ||
| 14699 | + } | ||
| 14700 | + #endif | ||
| 14701 | + return s.str[idx]; | ||
| 14702 | +} | ||
| 14703 | +VV_LOC u8 builtin__string_at_i64(string s, i64 idx) { | ||
| 14704 | + #if 1 | ||
| 14705 | + { | ||
| 14706 | + if (idx < 0 || idx >= ((i64)(s.len))) { | ||
| 14707 | + builtin__panic_n2(_S("string index out of range(idx,s.len):"), idx, s.len); | ||
| 14708 | + VUNREACHABLE(); | ||
| 14709 | + } | ||
| 14710 | + } | ||
| 14711 | + #endif | ||
| 14712 | + return s.str[((int)(idx))]; | ||
| 14713 | +} | ||
| 14714 | +VV_LOC u8 builtin__string_at_u64(string s, u64 idx) { | ||
| 14715 | + #if 1 | ||
| 14716 | + { | ||
| 14717 | + if (idx >= ((u64)(s.len))) { | ||
| 14718 | + builtin___v_panic(builtin__string_plus_many(4, _MOV((string[4]){_S("string index out of range(idx,s.len): "), builtin__u64_str(idx), _S(", "), builtin__impl_i64_to_string(s.len)}))); | ||
| 14719 | + VUNREACHABLE(); | ||
| 14720 | + } | ||
| 14721 | + } | ||
| 14722 | + #endif | ||
| 14723 | + return s.str[((int)(idx))]; | ||
| 14724 | +} | ||
| 14725 | +VV_LOC u8 builtin__string_at_ni(string s, int idx) { | ||
| 14726 | + return builtin__string_at(s, builtin__v_ni_index(idx, s.len)); | ||
| 14727 | +} | ||
| 14728 | +VV_LOC _option_u8 builtin__string_at_with_check(string s, int idx) { | ||
| 14729 | + if (idx < 0 || idx >= s.len) { | ||
| 14730 | + return (_option_u8){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | ||
| 14731 | + } | ||
| 14732 | + { // Unsafe block | ||
| 14733 | + _option_u8 _t2; | ||
| 14734 | + builtin___option_ok(&(u8[]) { s.str[idx] }, (_option*)(&_t2), sizeof(u8)); | ||
| 14735 | + | ||
| 14736 | + return _t2; | ||
| 14737 | + } | ||
| 14738 | + return (_option_u8){.state=2, .err=_const_none__, .data={E_STRUCT}}; | ||
| 14739 | +} | ||
| 14740 | +VV_LOC _option_u8 builtin__string_at_with_check_i64(string s, i64 idx) { | ||
| 14741 | + if (idx < 0 || idx >= ((i64)(s.len))) { | ||
| 14742 | + return (_option_u8){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | ||
| 14743 | + } | ||
| 14744 | + { // Unsafe block | ||
| 14745 | + _option_u8 _t2; | ||
| 14746 | + builtin___option_ok(&(u8[]) { s.str[((int)(idx))] }, (_option*)(&_t2), sizeof(u8)); | ||
| 14747 | + | ||
| 14748 | + return _t2; | ||
| 14749 | + } | ||
| 14750 | + return (_option_u8){.state=2, .err=_const_none__, .data={E_STRUCT}}; | ||
| 14751 | +} | ||
| 14752 | +VV_LOC _option_u8 builtin__string_at_with_check_u64(string s, u64 idx) { | ||
| 14753 | + if (idx >= ((u64)(s.len))) { | ||
| 14754 | + return (_option_u8){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | ||
| 14755 | + } | ||
| 14756 | + { // Unsafe block | ||
| 14757 | + _option_u8 _t2; | ||
| 14758 | + builtin___option_ok(&(u8[]) { s.str[((int)(idx))] }, (_option*)(&_t2), sizeof(u8)); | ||
| 14759 | + | ||
| 14760 | + return _t2; | ||
| 14761 | + } | ||
| 14762 | + return (_option_u8){.state=2, .err=_const_none__, .data={E_STRUCT}}; | ||
| 14763 | +} | ||
| 14764 | +VV_LOC _option_u8 builtin__string_at_with_check_ni(string s, int idx) { | ||
| 14765 | + return builtin__string_at_with_check(s, builtin__v_ni_index(idx, s.len)); | ||
| 14766 | +} | ||
| 14767 | +bool builtin__string_is_oct(string str) { | ||
| 14768 | + int i = 0; | ||
| 14769 | + if (str.len == 0) { | ||
| 14770 | + return false; | ||
| 14771 | + } | ||
| 14772 | + if (str.str[ i] == '0') { | ||
| 14773 | + i++; | ||
| 14774 | + } else if (str.str[ i] == '-' || str.str[ i] == '+') { | ||
| 14775 | + i++; | ||
| 14776 | + if (i < str.len && str.str[ i] == '0') { | ||
| 14777 | + i++; | ||
| 14778 | + } else { | ||
| 14779 | + return false; | ||
| 14780 | + } | ||
| 14781 | + } else { | ||
| 14782 | + return false; | ||
| 14783 | + } | ||
| 14784 | + if (i < str.len && str.str[ i] == 'o') { | ||
| 14785 | + i++; | ||
| 14786 | + } else { | ||
| 14787 | + return false; | ||
| 14788 | + } | ||
| 14789 | + if (i == str.len) { | ||
| 14790 | + return false; | ||
| 14791 | + } | ||
| 14792 | + for (;;) { | ||
| 14793 | + if (!(i < str.len)) break; | ||
| 14794 | + if (str.str[ i] < '0' || str.str[ i] > '7') { | ||
| 14795 | + return false; | ||
| 14796 | + } | ||
| 14797 | + i++; | ||
| 14798 | + } | ||
| 14799 | + return true; | ||
| 14800 | +} | ||
| 14801 | +bool builtin__string_is_bin(string str) { | ||
| 14802 | + int i = 0; | ||
| 14803 | + if (str.len == 0) { | ||
| 14804 | + return false; | ||
| 14805 | + } | ||
| 14806 | + if (str.str[ i] == '0') { | ||
| 14807 | + i++; | ||
| 14808 | + } else if (str.str[ i] == '-' || str.str[ i] == '+') { | ||
| 14809 | + i++; | ||
| 14810 | + if (i < str.len && str.str[ i] == '0') { | ||
| 14811 | + i++; | ||
| 14812 | + } else { | ||
| 14813 | + return false; | ||
| 14814 | + } | ||
| 14815 | + } else { | ||
| 14816 | + return false; | ||
| 14817 | + } | ||
| 14818 | + if (i < str.len && str.str[ i] == 'b') { | ||
| 14819 | + i++; | ||
| 14820 | + } else { | ||
| 14821 | + return false; | ||
| 14822 | + } | ||
| 14823 | + if (i == str.len) { | ||
| 14824 | + return false; | ||
| 14825 | + } | ||
| 14826 | + for (;;) { | ||
| 14827 | + if (!(i < str.len)) break; | ||
| 14828 | + if (str.str[ i] < '0' || str.str[ i] > '1') { | ||
| 14829 | + return false; | ||
| 14830 | + } | ||
| 14831 | + i++; | ||
| 14832 | + } | ||
| 14833 | + return true; | ||
| 14834 | +} | ||
| 14835 | +bool builtin__string_is_hex(string str) { | ||
| 14836 | + int i = 0; | ||
| 14837 | + if (str.len == 0) { | ||
| 14838 | + return false; | ||
| 14839 | + } | ||
| 14840 | + if (str.str[ i] == '0') { | ||
| 14841 | + i++; | ||
| 14842 | + } else if (str.str[ i] == '-' || str.str[ i] == '+') { | ||
| 14843 | + i++; | ||
| 14844 | + if (i < str.len && str.str[ i] == '0') { | ||
| 14845 | + i++; | ||
| 14846 | + } else { | ||
| 14847 | + return false; | ||
| 14848 | + } | ||
| 14849 | + } else { | ||
| 14850 | + return false; | ||
| 14851 | + } | ||
| 14852 | + if (i < str.len && str.str[ i] == 'x') { | ||
| 14853 | + i++; | ||
| 14854 | + } else { | ||
| 14855 | + return false; | ||
| 14856 | + } | ||
| 14857 | + if (i == str.len) { | ||
| 14858 | + return false; | ||
| 14859 | + } | ||
| 14860 | + for (;;) { | ||
| 14861 | + if (!(i < str.len)) break; | ||
| 14862 | + if ((str.str[ i] < '0' || str.str[ i] > '9') && ((str.str[ i] < 'a' || str.str[ i] > 'f') && (str.str[ i] < 'A' || str.str[ i] > 'F'))) { | ||
| 14863 | + return false; | ||
| 14864 | + } | ||
| 14865 | + i++; | ||
| 14866 | + } | ||
| 14867 | + return true; | ||
| 14868 | +} | ||
| 14869 | +bool builtin__string_is_int(string str) { | ||
| 14870 | + int i = 0; | ||
| 14871 | + if (str.len == 0) { | ||
| 14872 | + return false; | ||
| 14873 | + } | ||
| 14874 | + if ((str.str[ i] != '-' && str.str[ i] != '+') && (!builtin__u8_is_digit(str.str[ i]))) { | ||
| 14875 | + return false; | ||
| 14876 | + } else { | ||
| 14877 | + i++; | ||
| 14878 | + } | ||
| 14879 | + if (i == str.len && (!builtin__u8_is_digit(str.str[ i - 1]))) { | ||
| 14880 | + return false; | ||
| 14881 | + } | ||
| 14882 | + for (;;) { | ||
| 14883 | + if (!(i < str.len)) break; | ||
| 14884 | + if (str.str[ i] < '0' || str.str[ i] > '9') { | ||
| 14885 | + return false; | ||
| 14886 | + } | ||
| 14887 | + i++; | ||
| 14888 | + } | ||
| 14889 | + return true; | ||
| 14890 | +} | ||
| 14891 | +inline bool builtin__u8_is_space(u8 c) { | ||
| 14892 | + return c == 32 || (c > 8 && c < 14) || c == 0x85 || c == 0xa0; | ||
| 14893 | +} | ||
| 14894 | +inline bool builtin__u8_is_digit(u8 c) { | ||
| 14895 | + return c >= '0' && c <= '9'; | ||
| 14896 | +} | ||
| 14897 | +inline bool builtin__u8_is_hex_digit(u8 c) { | ||
| 14898 | + return builtin__u8_is_digit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); | ||
| 14899 | +} | ||
| 14900 | +inline bool builtin__u8_is_oct_digit(u8 c) { | ||
| 14901 | + return c >= '0' && c <= '7'; | ||
| 14902 | +} | ||
| 14903 | +inline bool builtin__u8_is_bin_digit(u8 c) { | ||
| 14904 | + return c == '0' || c == '1'; | ||
| 14905 | +} | ||
| 14906 | +inline bool builtin__u8_is_letter(u8 c) { | ||
| 14907 | + return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); | ||
| 14908 | +} | ||
| 14909 | +inline bool builtin__u8_is_alnum(u8 c) { | ||
| 14910 | + return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'); | ||
| 14911 | +} | ||
| 14912 | +void builtin__string_free(string* s) { | ||
| 14913 | + if (s->is_lit == -98761234) { | ||
| 14914 | + u8* double_free_msg = ((u8*)("double string.free() detected\n")); | ||
| 14915 | + int double_free_msg_len = builtin__vstrlen(double_free_msg); | ||
| 14916 | + #if 0 | ||
| 14917 | + { | ||
| 14918 | + } | ||
| 14919 | + #else | ||
| 14920 | + { | ||
| 14921 | + builtin___write_buf_to_fd(1, double_free_msg, double_free_msg_len); | ||
| 14922 | + } | ||
| 14923 | + #endif | ||
| 14924 | + return; | ||
| 14925 | + } | ||
| 14926 | + if (s->is_lit == 1 || s->str == 0) { | ||
| 14927 | + return; | ||
| 14928 | + } | ||
| 14929 | + { // Unsafe block | ||
| 14930 | + builtin___v_free(s->str); | ||
| 14931 | + s->str = ((void*)0); | ||
| 14932 | + } | ||
| 14933 | + s->len = 0; | ||
| 14934 | + s->is_lit = -98761234; | ||
| 14935 | +} | ||
| 14936 | +string builtin__string_before(string s, string sub) { | ||
| 14937 | + int pos = builtin__string_index_(s, sub); | ||
| 14938 | + if (pos == -1) { | ||
| 14939 | + return builtin__string_clone(s); | ||
| 14940 | + } | ||
| 14941 | + return builtin__string_substr(s, 0, pos); | ||
| 14942 | +} | ||
| 14943 | +string builtin__string_all_before(string s, string sub) { | ||
| 14944 | + int pos = builtin__string_index_(s, sub); | ||
| 14945 | + if (pos == -1) { | ||
| 14946 | + return builtin__string_clone(s); | ||
| 14947 | + } | ||
| 14948 | + return builtin__string_substr(s, 0, pos); | ||
| 14949 | +} | ||
| 14950 | +string builtin__string_all_before_last(string s, string sub) { | ||
| 14951 | + int pos = builtin__string_index_last_(s, sub); | ||
| 14952 | + if (pos == -1) { | ||
| 14953 | + return builtin__string_clone(s); | ||
| 14954 | + } | ||
| 14955 | + return builtin__string_substr(s, 0, pos); | ||
| 14956 | +} | ||
| 14957 | +string builtin__string_all_after(string s, string sub) { | ||
| 14958 | + int pos = builtin__string_index_(s, sub); | ||
| 14959 | + if (pos == -1) { | ||
| 14960 | + return builtin__string_clone(s); | ||
| 14961 | + } | ||
| 14962 | + return builtin__string_substr(s, pos + sub.len, 2147483647); | ||
| 14963 | +} | ||
| 14964 | +string builtin__string_all_after_last(string s, string sub) { | ||
| 14965 | + int pos = builtin__string_index_last_(s, sub); | ||
| 14966 | + if (pos == -1) { | ||
| 14967 | + return builtin__string_clone(s); | ||
| 14968 | + } | ||
| 14969 | + return builtin__string_substr(s, pos + sub.len, 2147483647); | ||
| 14970 | +} | ||
| 14971 | +string builtin__string_all_after_first(string s, string sub) { | ||
| 14972 | + int pos = builtin__string_index_(s, sub); | ||
| 14973 | + if (pos == -1) { | ||
| 14974 | + return builtin__string_clone(s); | ||
| 14975 | + } | ||
| 14976 | + return builtin__string_substr(s, pos + sub.len, 2147483647); | ||
| 14977 | +} | ||
| 14978 | +inline string builtin__string_after(string s, string sub) { | ||
| 14979 | + return builtin__string_all_after_last(s, sub); | ||
| 14980 | +} | ||
| 14981 | +string builtin__string_after_char(string s, u8 sub) { | ||
| 14982 | + int pos = -1; | ||
| 14983 | + for (int i = 0; i < s.len; ++i) { | ||
| 14984 | + u8 c = s.str[i]; | ||
| 14985 | + if (c == sub) { | ||
| 14986 | + pos = i; | ||
| 14987 | + break; | ||
| 14988 | + } | ||
| 14989 | + } | ||
| 14990 | + if (pos == -1) { | ||
| 14991 | + return builtin__string_clone(s); | ||
| 14992 | + } | ||
| 14993 | + return builtin__string_substr(s, pos + 1, 2147483647); | ||
| 14994 | +} | ||
| 14995 | +string Array_string_join(Array_string a, string sep) { | ||
| 14996 | + if (a.len == 0) { | ||
| 14997 | + return _S(""); | ||
| 14998 | + } | ||
| 14999 | + int len = 0; | ||
| 15000 | + for (int _t2 = 0; _t2 < a.len; ++_t2) { | ||
| 15001 | + string val = ((string*)a.data)[_t2]; | ||
| 15002 | + len += val.len + sep.len; | ||
| 15003 | + } | ||
| 15004 | + len -= sep.len; | ||
| 15005 | + string _t3 = ((string){.str = builtin__malloc_noscan(len + 1), .len = len}); | ||
| 15006 | + string res = _t3; | ||
| 15007 | + int idx = 0; | ||
| 15008 | + for (int i = 0; i < a.len; ++i) { | ||
| 15009 | + string val = ((string*)a.data)[i]; | ||
| 15010 | + { // Unsafe block | ||
| 15011 | + builtin__vmemcpy(((voidptr)(res.str + idx)), val.str, val.len); | ||
| 15012 | + idx += val.len; | ||
| 15013 | + } | ||
| 15014 | + if (i != a.len - 1) { | ||
| 15015 | + { // Unsafe block | ||
| 15016 | + builtin__vmemcpy(((voidptr)(res.str + idx)), sep.str, sep.len); | ||
| 15017 | + idx += sep.len; | ||
| 15018 | + } | ||
| 15019 | + } | ||
| 15020 | + } | ||
| 15021 | + { // Unsafe block | ||
| 15022 | + res.str[res.len] = 0; | ||
| 15023 | + } | ||
| 15024 | + return res; | ||
| 15025 | +} | ||
| 15026 | +inline string Array_string_join_lines(Array_string s) { | ||
| 15027 | + return Array_string_join(s, _S("\n")); | ||
| 15028 | +} | ||
| 15029 | +string builtin__string_reverse(string s) { | ||
| 15030 | + if (s.len == 0 || s.len == 1) { | ||
| 15031 | + return builtin__string_clone(s); | ||
| 15032 | + } | ||
| 15033 | + string _t2 = ((string){.str = builtin__malloc_noscan(s.len + 1), .len = s.len}); | ||
| 15034 | + string res = _t2; | ||
| 15035 | + for (int i = s.len - 1; i >= 0; i--) { | ||
| 15036 | + { // Unsafe block | ||
| 15037 | + res.str[s.len - i - 1] = s.str[ i]; | ||
| 15038 | + } | ||
| 15039 | + } | ||
| 15040 | + { // Unsafe block | ||
| 15041 | + res.str[res.len] = 0; | ||
| 15042 | + } | ||
| 15043 | + return res; | ||
| 15044 | +} | ||
| 15045 | +string builtin__string_limit(string s, int max) { | ||
| 15046 | + Array_rune u = builtin__string_runes(s); | ||
| 15047 | + if (u.len <= max) { | ||
| 15048 | + return builtin__string_clone(s); | ||
| 15049 | + } | ||
| 15050 | + return Array_rune_string(builtin__array_slice(u, 0, max)); | ||
| 15051 | +} | ||
| 15052 | +int builtin__string_hash(string s) { | ||
| 15053 | + u32 h = ((u32)(0)); | ||
| 15054 | + if (h == 0 && s.len > 0) { | ||
| 15055 | + for (int _t1 = 0; _t1 < s.len; ++_t1) { | ||
| 15056 | + u8 c = s.str[_t1]; | ||
| 15057 | + h = h * 31 + ((u32)(c)); | ||
| 15058 | + } | ||
| 15059 | + } | ||
| 15060 | + return ((int)(h)); | ||
| 15061 | +} | ||
| 15062 | +Array_u8 builtin__string_bytes(string s) { | ||
| 15063 | + if (s.len == 0) { | ||
| 15064 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | ||
| 15065 | + } | ||
| 15066 | + Array_u8 buf = builtin____new_array_with_default(s.len, 0, sizeof(u8), 0); | ||
| 15067 | + builtin__vmemcpy(buf.data, s.str, s.len); | ||
| 15068 | + return buf; | ||
| 15069 | +} | ||
| 15070 | +string builtin__string_repeat(string s, int count) { | ||
| 15071 | + if (count <= 0) { | ||
| 15072 | + return _S(""); | ||
| 15073 | + } else if (count == 1) { | ||
| 15074 | + return builtin__string_clone(s); | ||
| 15075 | + } | ||
| 15076 | + u8* ret = builtin__malloc_noscan(s.len * count + 1); | ||
| 15077 | + for (int i = 0; i < count; ++i) { | ||
| 15078 | + builtin__vmemcpy(ret + (int)(i * s.len), s.str, s.len); | ||
| 15079 | + } | ||
| 15080 | + int new_len = s.len * count; | ||
| 15081 | + { // Unsafe block | ||
| 15082 | + ret[new_len] = 0; | ||
| 15083 | + } | ||
| 15084 | + return builtin__u8_vstring_with_len(ret, new_len); | ||
| 15085 | +} | ||
| 15086 | +Array_string builtin__string_fields(string s) { | ||
| 15087 | + Array_string res = builtin____new_array_with_default(0, 0, sizeof(string), 0); | ||
| 15088 | + builtin__ArrayFlags_set(&res.flags, ArrayFlags__noslices); | ||
| 15089 | + int word_start = 0; | ||
| 15090 | + int word_len = 0; | ||
| 15091 | + bool is_in_word = false; | ||
| 15092 | + bool is_space = false; | ||
| 15093 | + for (int i = 0; i < s.len; ++i) { | ||
| 15094 | + u8 c = s.str[i]; | ||
| 15095 | + is_space = (c == 32 || c == 9 || c == 10); | ||
| 15096 | + if (!is_space) { | ||
| 15097 | + word_len++; | ||
| 15098 | + } | ||
| 15099 | + if (!is_in_word && !is_space) { | ||
| 15100 | + word_start = i; | ||
| 15101 | + is_in_word = true; | ||
| 15102 | + continue; | ||
| 15103 | + } | ||
| 15104 | + if (is_space && is_in_word) { | ||
| 15105 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, word_start, word_start + word_len) })); | ||
| 15106 | + is_in_word = false; | ||
| 15107 | + word_len = 0; | ||
| 15108 | + word_start = 0; | ||
| 15109 | + continue; | ||
| 15110 | + } | ||
| 15111 | + } | ||
| 15112 | + if (is_in_word && word_len > 0) { | ||
| 15113 | + builtin__array_push((array*)&res, _MOV((string[]){ builtin__string_substr(s, word_start, s.len) })); | ||
| 15114 | + } | ||
| 15115 | + Array_string _t3 = res; | ||
| 15116 | + { // defer begin | ||
| 15117 | + builtin__ArrayFlags_clear(&res.flags, ArrayFlags__noslices); | ||
| 15118 | + } // defer end | ||
| 15119 | + return _t3; | ||
| 15120 | +} | ||
| 15121 | +inline string builtin__string_strip_margin(string s) { | ||
| 15122 | + return builtin__string_strip_margin_custom(s, '|'); | ||
| 15123 | +} | ||
| 15124 | +string builtin__string_strip_margin_custom(string s, u8 del) { | ||
| 15125 | + u8 sep = del; | ||
| 15126 | + if (builtin__u8_is_space(sep)) { | ||
| 15127 | + builtin__println(_S("Warning: `strip_margin` cannot use white-space as a delimiter")); | ||
| 15128 | + builtin__println(_S(" Defaulting to `|`")); | ||
| 15129 | + sep = '|'; | ||
| 15130 | + } | ||
| 15131 | + u8* ret = builtin__malloc_noscan(s.len + 1); | ||
| 15132 | + int count = 0; | ||
| 15133 | + for (int i = 0; i < s.len; i++) { | ||
| 15134 | + if (s.str[ i] == 10 || s.str[ i] == 13) { | ||
| 15135 | + { // Unsafe block | ||
| 15136 | + ret[count] = s.str[ i]; | ||
| 15137 | + } | ||
| 15138 | + count++; | ||
| 15139 | + if (s.str[ i] == 13 && i < s.len - 1 && s.str[ i + 1] == 10) { | ||
| 15140 | + { // Unsafe block | ||
| 15141 | + ret[count] = s.str[ i + 1]; | ||
| 15142 | + } | ||
| 15143 | + count++; | ||
| 15144 | + i++; | ||
| 15145 | + } | ||
| 15146 | + for (;;) { | ||
| 15147 | + if (!(s.str[ i] != sep)) break; | ||
| 15148 | + i++; | ||
| 15149 | + if (i >= s.len) { | ||
| 15150 | + break; | ||
| 15151 | + } | ||
| 15152 | + } | ||
| 15153 | + } else { | ||
| 15154 | + { // Unsafe block | ||
| 15155 | + ret[count] = s.str[ i]; | ||
| 15156 | + } | ||
| 15157 | + count++; | ||
| 15158 | + } | ||
| 15159 | + } | ||
| 15160 | + { // Unsafe block | ||
| 15161 | + ret[count] = 0; | ||
| 15162 | + return builtin__u8_vstring_with_len(ret, count); | ||
| 15163 | + } | ||
| 15164 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 15165 | +} | ||
| 15166 | +string builtin__string_trim_indent(string s) { | ||
| 15167 | + Array_string lines = builtin__string_split_into_lines(s); | ||
| 15168 | + int min_common_indent = ((int)(_const_max_int)); | ||
| 15169 | + for (int _t1 = 0; _t1 < lines.len; ++_t1) { | ||
| 15170 | + string line = ((string*)lines.data)[_t1]; | ||
| 15171 | + if (builtin__string_is_blank(line)) { | ||
| 15172 | + continue; | ||
| 15173 | + } | ||
| 15174 | + int line_indent = builtin__string_indent_width(line); | ||
| 15175 | + if (line_indent < min_common_indent) { | ||
| 15176 | + min_common_indent = line_indent; | ||
| 15177 | + } | ||
| 15178 | + } | ||
| 15179 | + if (lines.len > 0 && builtin__string_is_blank((*(string*)builtin__array_first(lines)))) { | ||
| 15180 | + lines = builtin__array_slice(lines, 1, 2147483647); | ||
| 15181 | + } | ||
| 15182 | + if (lines.len > 0 && builtin__string_is_blank((*(string*)builtin__array_last(lines)))) { | ||
| 15183 | + lines = builtin__array_slice(lines, 0, lines.len - 1); | ||
| 15184 | + } | ||
| 15185 | + Array_string trimmed_lines = builtin____new_array_with_default(0, lines.len, sizeof(string), 0); | ||
| 15186 | + for (int _t2 = 0; _t2 < lines.len; ++_t2) { | ||
| 15187 | + string line = ((string*)lines.data)[_t2]; | ||
| 15188 | + if (builtin__string_is_blank(line)) { | ||
| 15189 | + builtin__array_push((array*)&trimmed_lines, _MOV((string[]){ line })); | ||
| 15190 | + continue; | ||
| 15191 | + } | ||
| 15192 | + builtin__array_push((array*)&trimmed_lines, _MOV((string[]){ builtin__string_substr(line, min_common_indent, 2147483647) })); | ||
| 15193 | + } | ||
| 15194 | + return Array_string_join(trimmed_lines, _S("\n")); | ||
| 15195 | +} | ||
| 15196 | +int builtin__string_indent_width(string s) { | ||
| 15197 | + for (int i = 0; i < s.len; ++i) { | ||
| 15198 | + u8 c = s.str[i]; | ||
| 15199 | + if (!builtin__u8_is_space(c)) { | ||
| 15200 | + return i; | ||
| 15201 | + } | ||
| 15202 | + } | ||
| 15203 | + return 0; | ||
| 15204 | +} | ||
| 15205 | +bool builtin__string_is_blank(string s) { | ||
| 15206 | + if (s.len == 0) { | ||
| 15207 | + return true; | ||
| 15208 | + } | ||
| 15209 | + for (int _t2 = 0; _t2 < s.len; ++_t2) { | ||
| 15210 | + u8 c = s.str[_t2]; | ||
| 15211 | + if (!builtin__u8_is_space(c)) { | ||
| 15212 | + return false; | ||
| 15213 | + } | ||
| 15214 | + } | ||
| 15215 | + return true; | ||
| 15216 | +} | ||
| 15217 | +bool builtin__string_match_glob(string name, string pattern) { | ||
| 15218 | + int px = 0; | ||
| 15219 | + int nx = 0; | ||
| 15220 | + int next_px = 0; | ||
| 15221 | + int next_nx = 0; | ||
| 15222 | + int plen = pattern.len; | ||
| 15223 | + int nlen = name.len; | ||
| 15224 | + for (;;) { | ||
| 15225 | + if (!(px < plen || nx < nlen)) break; | ||
| 15226 | + if (px < plen) { | ||
| 15227 | + u8 c = pattern.str[ px]; | ||
| 15228 | + | ||
| 15229 | + if (c == ('?')) { | ||
| 15230 | + if (nx < nlen) { | ||
| 15231 | + px++; | ||
| 15232 | + nx++; | ||
| 15233 | + continue; | ||
| 15234 | + } | ||
| 15235 | + } | ||
| 15236 | + else if (c == ('*')) { | ||
| 15237 | + next_px = px; | ||
| 15238 | + next_nx = nx + 1; | ||
| 15239 | + px++; | ||
| 15240 | + continue; | ||
| 15241 | + } | ||
| 15242 | + else if (c == ('[')) { | ||
| 15243 | + if (nx < nlen) { | ||
| 15244 | + u8 wanted_c = name.str[ nx]; | ||
| 15245 | + bool is_inverted = false; | ||
| 15246 | + bool inner_match = false; | ||
| 15247 | + int inner_idx = px + 1; | ||
| 15248 | + if (inner_idx < plen && pattern.str[ inner_idx] == '^') { | ||
| 15249 | + is_inverted = true; | ||
| 15250 | + inner_idx++; | ||
| 15251 | + } | ||
| 15252 | + for (; inner_idx < plen && pattern.str[ inner_idx] != ']'; inner_idx++) { | ||
| 15253 | + if (pattern.str[ inner_idx] == wanted_c) { | ||
| 15254 | + inner_match = true; | ||
| 15255 | + } | ||
| 15256 | + } | ||
| 15257 | + if (inner_idx < plen && ((inner_match && !is_inverted) || (!inner_match && is_inverted))) { | ||
| 15258 | + px = inner_idx + 1; | ||
| 15259 | + nx++; | ||
| 15260 | + continue; | ||
| 15261 | + } | ||
| 15262 | + } | ||
| 15263 | + } | ||
| 15264 | + else { | ||
| 15265 | + if (nx < nlen && name.str[ nx] == c) { | ||
| 15266 | + px++; | ||
| 15267 | + nx++; | ||
| 15268 | + continue; | ||
| 15269 | + } | ||
| 15270 | + } | ||
| 15271 | + } | ||
| 15272 | + if (0 < next_nx && next_nx <= nlen) { | ||
| 15273 | + px = next_px; | ||
| 15274 | + nx = next_nx; | ||
| 15275 | + continue; | ||
| 15276 | + } | ||
| 15277 | + return false; | ||
| 15278 | + } | ||
| 15279 | + return true; | ||
| 15280 | +} | ||
| 15281 | +inline bool builtin__string_is_ascii(string s) { | ||
| 15282 | + for (int i = 0; i < s.len; i++) { | ||
| 15283 | + if (s.str[ i] < ((u8)(' ')) || s.str[ i] > ((u8)('~'))) { | ||
| 15284 | + return false; | ||
| 15285 | + } | ||
| 15286 | + } | ||
| 15287 | + return true; | ||
| 15288 | +} | ||
| 15289 | +bool builtin__string_is_identifier(string s) { | ||
| 15290 | + if (s.len == 0) { | ||
| 15291 | + return false; | ||
| 15292 | + } | ||
| 15293 | + if (!(builtin__u8_is_letter(s.str[ 0]) || s.str[ 0] == '_')) { | ||
| 15294 | + return false; | ||
| 15295 | + } | ||
| 15296 | + for (int i = 1; i < s.len; i++) { | ||
| 15297 | + u8 c = s.str[ i]; | ||
| 15298 | + if (!(builtin__u8_is_letter(c) || builtin__u8_is_digit(c) || c == '_')) { | ||
| 15299 | + return false; | ||
| 15300 | + } | ||
| 15301 | + } | ||
| 15302 | + return true; | ||
| 15303 | +} | ||
| 15304 | +string builtin__string_camel_to_snake(string s) { | ||
| 15305 | + if (s.len == 0) { | ||
| 15306 | + return _S(""); | ||
| 15307 | + } | ||
| 15308 | + if (s.len == 1) { | ||
| 15309 | + return builtin__string_to_lower_ascii(s); | ||
| 15310 | + } | ||
| 15311 | + u8* b = builtin__malloc_noscan(2 * s.len + 1); | ||
| 15312 | + int pos = 2; | ||
| 15313 | + bool prev_is_upper = false; | ||
| 15314 | + bool prev_inserted_boundary = false; | ||
| 15315 | + { // Unsafe block | ||
| 15316 | + if (builtin__u8_is_capital(s.str[ 0])) { | ||
| 15317 | + b[0] = (u8)(s.str[ 0] + 32); | ||
| 15318 | + u8 _t3; /* if prepend */ | ||
| 15319 | + if (builtin__u8_is_capital(s.str[ 1])) { | ||
| 15320 | + prev_is_upper = true; | ||
| 15321 | + _t3 = (u8)(s.str[ 1] + 32); | ||
| 15322 | + goto _t4; | ||
| 15323 | + }; | ||
| 15324 | + { | ||
| 15325 | + _t3 = s.str[ 1]; | ||
| 15326 | + } | ||
| 15327 | + _t4: {}; | ||
| 15328 | + b[1] = _t3; | ||
| 15329 | + } else { | ||
| 15330 | + b[0] = s.str[ 0]; | ||
| 15331 | + if (builtin__u8_is_capital(s.str[ 1])) { | ||
| 15332 | + prev_is_upper = true; | ||
| 15333 | + if (s.str[ 0] != '_' && s.len > 2 && !builtin__u8_is_capital(s.str[ 2])) { | ||
| 15334 | + b[1] = '_'; | ||
| 15335 | + b[2] = (u8)(s.str[ 1] + 32); | ||
| 15336 | + pos = 3; | ||
| 15337 | + } else { | ||
| 15338 | + b[1] = (u8)(s.str[ 1] + 32); | ||
| 15339 | + } | ||
| 15340 | + } else { | ||
| 15341 | + b[1] = s.str[ 1]; | ||
| 15342 | + } | ||
| 15343 | + } | ||
| 15344 | + } | ||
| 15345 | + for (int i = 2; i < s.len; i++) { | ||
| 15346 | + bool has_boundary_before_upper = false; | ||
| 15347 | + u8 c = s.str[ i]; | ||
| 15348 | + bool c_is_upper = builtin__u8_is_capital(c); | ||
| 15349 | + bool c_is_number = builtin__u8_is_digit(c); | ||
| 15350 | + bool next_is_lower = i + 1 < s.len && builtin__u8_is_letter(s.str[ i + 1]) && !builtin__u8_is_capital(s.str[ i + 1]); | ||
| 15351 | + bool next2_is_lower = i + 2 < s.len && builtin__u8_is_letter(s.str[ i + 2]) && !builtin__u8_is_capital(s.str[ i + 2]); | ||
| 15352 | + bool skip_digit = c_is_number && prev_is_upper && !next_is_lower && next2_is_lower; | ||
| 15353 | + if (c_is_upper && prev_is_upper && i >= 2 && builtin__u8_is_capital(s.str[ i - 2]) && next_is_lower && c != '_') { | ||
| 15354 | + { // Unsafe block | ||
| 15355 | + if (b[pos - 1] != '_') { | ||
| 15356 | + b[pos] = '_'; | ||
| 15357 | + pos++; | ||
| 15358 | + } | ||
| 15359 | + } | ||
| 15360 | + has_boundary_before_upper = true; | ||
| 15361 | + } | ||
| 15362 | + if (((c_is_upper && !prev_is_upper) || (!c_is_upper && prev_is_upper && builtin__u8_is_capital(s.str[ i - 2]) && !prev_inserted_boundary && !skip_digit)) && c != '_') { | ||
| 15363 | + { // Unsafe block | ||
| 15364 | + if (b[pos - 1] != '_') { | ||
| 15365 | + b[pos] = '_'; | ||
| 15366 | + pos++; | ||
| 15367 | + } | ||
| 15368 | + } | ||
| 15369 | + } | ||
| 15370 | + u8 lower_c = (c_is_upper ? ((u8)(c + 32)) : (c)); | ||
| 15371 | + { // Unsafe block | ||
| 15372 | + b[pos] = lower_c; | ||
| 15373 | + } | ||
| 15374 | + prev_is_upper = c_is_upper; | ||
| 15375 | + prev_inserted_boundary = has_boundary_before_upper; | ||
| 15376 | + pos++; | ||
| 15377 | + } | ||
| 15378 | + { // Unsafe block | ||
| 15379 | + b[pos] = 0; | ||
| 15380 | + } | ||
| 15381 | + return builtin__tos(b, pos); | ||
| 15382 | +} | ||
| 15383 | +string builtin__string_snake_to_camel(string s) { | ||
| 15384 | + if (s.len == 0) { | ||
| 15385 | + return _S(""); | ||
| 15386 | + } | ||
| 15387 | + if (s.len == 1) { | ||
| 15388 | + return s; | ||
| 15389 | + } | ||
| 15390 | + bool need_upper = true; | ||
| 15391 | + rune upper_c = '_'; | ||
| 15392 | + u8* b = builtin__malloc_noscan(s.len + 1); | ||
| 15393 | + int i = 0; | ||
| 15394 | + for (int _t3 = 0; _t3 < s.len; ++_t3) { | ||
| 15395 | + u8 c = s.str[_t3]; | ||
| 15396 | + upper_c = (c >= 'a' && c <= 'z' ? ((u8)(c - 32)) : (c)); | ||
| 15397 | + if (c == '_') { | ||
| 15398 | + need_upper = true; | ||
| 15399 | + } else if (need_upper) { | ||
| 15400 | + { // Unsafe block | ||
| 15401 | + b[i] = upper_c; | ||
| 15402 | + } | ||
| 15403 | + i++; | ||
| 15404 | + need_upper = false; | ||
| 15405 | + } else { | ||
| 15406 | + { // Unsafe block | ||
| 15407 | + b[i] = c; | ||
| 15408 | + } | ||
| 15409 | + i++; | ||
| 15410 | + } | ||
| 15411 | + } | ||
| 15412 | + { // Unsafe block | ||
| 15413 | + b[i] = 0; | ||
| 15414 | + } | ||
| 15415 | + return builtin__tos(b, i); | ||
| 15416 | +} | ||
| 15417 | +string builtin__string_wrap(string s, WrapConfig config) { | ||
| 15418 | + if (config.width <= 0) { | ||
| 15419 | + return _S(""); | ||
| 15420 | + } | ||
| 15421 | + Array_string words = builtin__string_fields(s); | ||
| 15422 | + if (words.len == 0) { | ||
| 15423 | + return _S(""); | ||
| 15424 | + } | ||
| 15425 | + strings__Builder sb = strings__new_builder(s.len); | ||
| 15426 | + strings__Builder_write_string(&sb, (*(string*)builtin__array_get(words, 0))); | ||
| 15427 | + int space_left = config.width - (*(string*)builtin__array_get(words, 0)).len; | ||
| 15428 | + for (int i = 1; i < words.len; ++i) { | ||
| 15429 | + string word = (*(string*)builtin__array_get(words, i)); | ||
| 15430 | + if (word.len + 1 > space_left) { | ||
| 15431 | + strings__Builder_write_string(&sb, config.end); | ||
| 15432 | + strings__Builder_write_string(&sb, word); | ||
| 15433 | + space_left = config.width - word.len; | ||
| 15434 | + } else { | ||
| 15435 | + strings__Builder_write_string(&sb, _S(" ")); | ||
| 15436 | + strings__Builder_write_string(&sb, word); | ||
| 15437 | + space_left -= 1 + word.len; | ||
| 15438 | + } | ||
| 15439 | + } | ||
| 15440 | + return strings__Builder_str(&sb); | ||
| 15441 | +} | ||
| 15442 | +string builtin__string_hex(string s) { | ||
| 15443 | + if ((s).len == 0) { | ||
| 15444 | + return _S(""); | ||
| 15445 | + } | ||
| 15446 | + return builtin__data_to_hex_string(s.str, s.len); | ||
| 15447 | +} | ||
| 15448 | +VV_LOC string builtin__data_to_hex_string(u8* data, int len) { | ||
| 15449 | + u8* hex = builtin__malloc_noscan(((u64)(len)) * 2 + 1); | ||
| 15450 | + int dst = 0; | ||
| 15451 | + for (int c = 0; c < len; ++c) { | ||
| 15452 | + u8 b = data[c]; | ||
| 15453 | + u8 n0 = v__rshift_u8(b, (u64)4); | ||
| 15454 | + u8 n1 = (b & 0xF); | ||
| 15455 | + hex[dst] = (n0 < 10 ? ((rune)(n0 + '0')) : ((rune)(n0 + 'W'))); | ||
| 15456 | + hex[dst + 1] = (n1 < 10 ? ((rune)(n1 + '0')) : ((rune)(n1 + 'W'))); | ||
| 15457 | + dst += 2; | ||
| 15458 | + } | ||
| 15459 | + hex[dst] = 0; | ||
| 15460 | + return builtin__tos(hex, dst); | ||
| 15461 | +} | ||
| 15462 | +RunesIterator builtin__string_runes_iterator(string s) { | ||
| 15463 | + return ((RunesIterator){.s = s,.i = 0,}); | ||
| 15464 | +} | ||
| 15465 | +_option_rune builtin__RunesIterator_next(RunesIterator* ri) { | ||
| 15466 | + if (ri->i >= ri->s.len) { | ||
| 15467 | + return (_option_rune){ .state=2, .err=_const_none__, .data={E_STRUCT} }; | ||
| 15468 | + } | ||
| 15469 | + multi_return_rune_int mr_82852 = builtin__utf8_decode_rune(&ri->s.str[ri->i], ri->s.len - ri->i); | ||
| 15470 | + rune r = mr_82852.arg0; | ||
| 15471 | + int char_len = mr_82852.arg1; | ||
| 15472 | + ri->i += (char_len > 0 ? (char_len) : (1)); | ||
| 15473 | + _option_rune _t2; | ||
| 15474 | + builtin___option_ok(&(rune[]) { r }, (_option*)(&_t2), sizeof(rune)); | ||
| 15475 | + | ||
| 15476 | + return _t2; | ||
| 15477 | +} | ||
| 15478 | +Array_u8 builtin__byteptr_vbytes(byteptr data, int len) { | ||
| 15479 | + return builtin__voidptr_vbytes(((voidptr)(data)), len); | ||
| 15480 | +} | ||
| 15481 | +string builtin__byteptr_vstring(byteptr bp) { | ||
| 15482 | + return ((string){.str = bp, .len = builtin__vstrlen(bp)}); | ||
| 15483 | +} | ||
| 15484 | +string builtin__byteptr_vstring_with_len(byteptr bp, int len) { | ||
| 15485 | + return ((string){.str = bp, .len = len, .is_lit = 0}); | ||
| 15486 | +} | ||
| 15487 | +string builtin__charptr_vstring(charptr cp) { | ||
| 15488 | + return ((string){.str = ((byteptr)(cp)), .len = builtin__vstrlen_char(cp), .is_lit = 0}); | ||
| 15489 | +} | ||
| 15490 | +string builtin__charptr_vstring_with_len(charptr cp, int len) { | ||
| 15491 | + return ((string){.str = ((byteptr)(cp)), .len = len, .is_lit = 0}); | ||
| 15492 | +} | ||
| 15493 | +string builtin__byteptr_vstring_literal(byteptr bp) { | ||
| 15494 | + return ((string){.str = bp, .len = builtin__vstrlen(bp), .is_lit = 1}); | ||
| 15495 | +} | ||
| 15496 | +string builtin__byteptr_vstring_literal_with_len(byteptr bp, int len) { | ||
| 15497 | + return ((string){.str = bp, .len = len, .is_lit = 1}); | ||
| 15498 | +} | ||
| 15499 | +string builtin__charptr_vstring_literal(charptr cp) { | ||
| 15500 | + return ((string){.str = ((byteptr)(cp)), .len = builtin__vstrlen_char(cp), .is_lit = 1}); | ||
| 15501 | +} | ||
| 15502 | +string builtin__charptr_vstring_literal_with_len(charptr cp, int len) { | ||
| 15503 | + return ((string){.str = ((byteptr)(cp)), .len = len, .is_lit = 1}); | ||
| 15504 | +} | ||
| 15505 | +string builtin__StrIntpType_str(StrIntpType x) { | ||
| 15506 | + string _t2 = (string){.str=(byteptr)"", .is_lit=1}; | ||
| 15507 | + switch (x) { | ||
| 15508 | + case StrIntpType__si_no_str: { | ||
| 15509 | + _t2 = _S("no_str"); | ||
| 15510 | + break; | ||
| 15511 | + } | ||
| 15512 | + case StrIntpType__si_c: { | ||
| 15513 | + _t2 = _S("c"); | ||
| 15514 | + break; | ||
| 15515 | + } | ||
| 15516 | + case StrIntpType__si_u8: { | ||
| 15517 | + _t2 = _S("u8"); | ||
| 15518 | + break; | ||
| 15519 | + } | ||
| 15520 | + case StrIntpType__si_i8: { | ||
| 15521 | + _t2 = _S("i8"); | ||
| 15522 | + break; | ||
| 15523 | + } | ||
| 15524 | + case StrIntpType__si_u16: { | ||
| 15525 | + _t2 = _S("u16"); | ||
| 15526 | + break; | ||
| 15527 | + } | ||
| 15528 | + case StrIntpType__si_i16: { | ||
| 15529 | + _t2 = _S("i16"); | ||
| 15530 | + break; | ||
| 15531 | + } | ||
| 15532 | + case StrIntpType__si_u32: { | ||
| 15533 | + _t2 = _S("u32"); | ||
| 15534 | + break; | ||
| 15535 | + } | ||
| 15536 | + case StrIntpType__si_i32: { | ||
| 15537 | + _t2 = _S("i32"); | ||
| 15538 | + break; | ||
| 15539 | + } | ||
| 15540 | + case StrIntpType__si_u64: { | ||
| 15541 | + _t2 = _S("u64"); | ||
| 15542 | + break; | ||
| 15543 | + } | ||
| 15544 | + case StrIntpType__si_i64: { | ||
| 15545 | + _t2 = _S("i64"); | ||
| 15546 | + break; | ||
| 15547 | + } | ||
| 15548 | + case StrIntpType__si_f32: { | ||
| 15549 | + _t2 = _S("f32"); | ||
| 15550 | + break; | ||
| 15551 | + } | ||
| 15552 | + case StrIntpType__si_f64: { | ||
| 15553 | + _t2 = _S("f64"); | ||
| 15554 | + break; | ||
| 15555 | + } | ||
| 15556 | + case StrIntpType__si_g32: { | ||
| 15557 | + _t2 = _S("f32"); | ||
| 15558 | + break; | ||
| 15559 | + } | ||
| 15560 | + case StrIntpType__si_g64: { | ||
| 15561 | + _t2 = _S("f64"); | ||
| 15562 | + break; | ||
| 15563 | + } | ||
| 15564 | + case StrIntpType__si_e32: { | ||
| 15565 | + _t2 = _S("f32"); | ||
| 15566 | + break; | ||
| 15567 | + } | ||
| 15568 | + case StrIntpType__si_e64: { | ||
| 15569 | + _t2 = _S("f64"); | ||
| 15570 | + break; | ||
| 15571 | + } | ||
| 15572 | + case StrIntpType__si_s: { | ||
| 15573 | + _t2 = _S("s"); | ||
| 15574 | + break; | ||
| 15575 | + } | ||
| 15576 | + case StrIntpType__si_p: { | ||
| 15577 | + _t2 = _S("p"); | ||
| 15578 | + break; | ||
| 15579 | + } | ||
| 15580 | + case StrIntpType__si_r: { | ||
| 15581 | + _t2 = _S("r"); | ||
| 15582 | + break; | ||
| 15583 | + } | ||
| 15584 | + case StrIntpType__si_vp: { | ||
| 15585 | + _t2 = _S("vp"); | ||
| 15586 | + break; | ||
| 15587 | + } | ||
| 15588 | + } | ||
| 15589 | + return _t2; | ||
| 15590 | +} | ||
| 15591 | +inline VV_LOC f32 builtin__fabs32(f32 x) { | ||
| 15592 | + return (x < 0 ? (-x) : (x)); | ||
| 15593 | +} | ||
| 15594 | +inline VV_LOC f64 builtin__fabs64(f64 x) { | ||
| 15595 | + return (x < 0 ? (-x) : (x)); | ||
| 15596 | +} | ||
| 15597 | +inline VV_LOC u64 builtin__abs64(i64 x) { | ||
| 15598 | + return (x < 0 ? (((u64)(-x))) : (((u64)(x)))); | ||
| 15599 | +} | ||
| 15600 | +u64 builtin__get_str_intp_u64_format(StrIntpType fmt_type, int in_width, int in_precision, bool in_tail_zeros, bool in_sign, u8 in_pad_ch, int in_base, bool in_upper_case) { | ||
| 15601 | + u64 width = (in_width != 0 ? (builtin__abs64(in_width)) : (((u64)(0)))); | ||
| 15602 | + u64 align = (in_width > 0 ? (((u64)(32))) : (((u64)(0)))); | ||
| 15603 | + u64 upper_case = (in_upper_case ? (((u64)(128))) : (((u64)(0)))); | ||
| 15604 | + u64 sign = (in_sign ? (((u64)(256))) : (((u64)(0)))); | ||
| 15605 | + u64 precision = (in_precision != 987698 ? ((v__lshift_u64(((u64)((in_precision & 0x7F))), (u64)9))) : (v__lshift_u64(((u64)(0x7F)), (u64)9))); | ||
| 15606 | + u32 tail_zeros = (in_tail_zeros ? (v__lshift_u32(((u32)(1)), (u64)16)) : (((u32)(0)))); | ||
| 15607 | + u64 base = ((u64)(v__lshift_u32(((u32)((in_base & 0xf))), (u64)27))); | ||
| 15608 | + u64 res = ((u64)(((((((((((((u64)(fmt_type)) & 0x1F)) | align) | upper_case) | sign) | precision) | tail_zeros) | (v__lshift_u64(((u64)((width & 0x3FF))), (u64)17))) | base) | (v__lshift_u64(((u64)(in_pad_ch)), (u64)31))))); | ||
| 15609 | + return res; | ||
| 15610 | +} | ||
| 15611 | +u32 builtin__get_str_intp_u32_format(StrIntpType fmt_type, int in_width, int in_precision, bool in_tail_zeros, bool in_sign, u8 in_pad_ch, int in_base, bool in_upper_case) { | ||
| 15612 | + u64 width = (in_width != 0 ? (builtin__abs64(in_width)) : (((u32)(0)))); | ||
| 15613 | + u32 align = (in_width > 0 ? (((u32)(32))) : (((u32)(0)))); | ||
| 15614 | + u32 upper_case = (in_upper_case ? (((u32)(128))) : (((u32)(0)))); | ||
| 15615 | + u32 sign = (in_sign ? (((u32)(256))) : (((u32)(0)))); | ||
| 15616 | + u32 precision = (in_precision != 987698 ? ((v__lshift_u32(((u32)((in_precision & 0x7F))), (u64)9))) : (v__lshift_u32(((u32)(0x7F)), (u64)9))); | ||
| 15617 | + u32 tail_zeros = (in_tail_zeros ? (v__lshift_u32(((u32)(1)), (u64)16)) : (((u32)(0)))); | ||
| 15618 | + u32 base = ((u32)(v__lshift_u32(((u32)((in_base & 0xf))), (u64)27))); | ||
| 15619 | + u32 res = ((u32)(((((((((((((u32)(fmt_type)) & 0x1F)) | align) | upper_case) | sign) | precision) | tail_zeros) | (v__lshift_u32(((u32)((width & 0x3FF))), (u64)17))) | base) | (v__lshift_u32(((u32)((in_pad_ch & 1))), (u64)31))))); | ||
| 15620 | + return res; | ||
| 15621 | +} | ||
| 15622 | +VV_LOC void builtin__StrIntpData_process_str_intp_data(StrIntpData* data, strings__Builder* sb) { | ||
| 15623 | + u32 x = data->fmt; | ||
| 15624 | + StrIntpType typ = ((StrIntpType)((x & 0x1F))); | ||
| 15625 | + int align = ((int)(((v__rshift_u32(x, (u64)5)) & 0x01))); | ||
| 15626 | + bool upper_case = (((v__rshift_u32(x, (u64)7)) & 0x01)) > 0; | ||
| 15627 | + int sign = ((int)(((v__rshift_u32(x, (u64)8)) & 0x01))); | ||
| 15628 | + int precision = ((int)(((v__rshift_u32(x, (u64)9)) & 0x7F))); | ||
| 15629 | + bool tail_zeros = (((v__rshift_u32(x, (u64)16)) & 0x01)) > 0; | ||
| 15630 | + int width = ((int)(((i16)(((v__rshift_u32(x, (u64)17)) & 0x3FF))))); | ||
| 15631 | + int base = (((int)(v__rshift_u32(x, (u64)27))) & 0xF); | ||
| 15632 | + u8 fmt_pad_ch = ((u8)(((v__rshift_u32(x, (u64)31)) & 0xFF))); | ||
| 15633 | + bool has_dynamic_width = ((data->dyn_flags & _const_str_intp_has_dynamic_width)) != 0; | ||
| 15634 | + bool has_dynamic_precision = ((data->dyn_flags & _const_str_intp_has_dynamic_precision)) != 0; | ||
| 15635 | + if (typ == StrIntpType__si_no_str) { | ||
| 15636 | + return; | ||
| 15637 | + } | ||
| 15638 | + if (base > 0) { | ||
| 15639 | + base += 2; | ||
| 15640 | + } | ||
| 15641 | + if (has_dynamic_width) { | ||
| 15642 | + width = data->dyn_width; | ||
| 15643 | + if (width < 0) { | ||
| 15644 | + width = -width; | ||
| 15645 | + align = 0; | ||
| 15646 | + } else if (width > 0) { | ||
| 15647 | + align = 1; | ||
| 15648 | + } | ||
| 15649 | + } | ||
| 15650 | + if (has_dynamic_precision) { | ||
| 15651 | + precision = data->dyn_precision; | ||
| 15652 | + } | ||
| 15653 | + u8 pad_ch = ((u8)(' ')); | ||
| 15654 | + if (fmt_pad_ch > 0) { | ||
| 15655 | + pad_ch = '0'; | ||
| 15656 | + } | ||
| 15657 | + int len0_set = (width > 0 ? (width) : (-1)); | ||
| 15658 | + int len1_set = (has_dynamic_precision ? ((precision >= 0 ? (precision) : (-1))) : precision == 0x7F ? (-1) : (precision)); | ||
| 15659 | + bool sign_set = sign == 1; | ||
| 15660 | + strconv__BF_param bf = ((strconv__BF_param){ | ||
| 15661 | + .pad_ch = pad_ch, | ||
| 15662 | + .len0 = len0_set, | ||
| 15663 | + .len1 = len1_set, | ||
| 15664 | + .positive = true, | ||
| 15665 | + .sign_flag = sign_set, | ||
| 15666 | + .align = strconv__Align_text__left, | ||
| 15667 | + .rm_tail_zero = tail_zeros, | ||
| 15668 | + }); | ||
| 15669 | + if (fmt_pad_ch == 0 || pad_ch == '0') { | ||
| 15670 | + switch (align) { | ||
| 15671 | + case 0: { | ||
| 15672 | + bf.align = strconv__Align_text__left; | ||
| 15673 | + break; | ||
| 15674 | + } | ||
| 15675 | + case 1: { | ||
| 15676 | + bf.align = strconv__Align_text__right; | ||
| 15677 | + break; | ||
| 15678 | + } | ||
| 15679 | + default: { | ||
| 15680 | + { | ||
| 15681 | + bf.align = strconv__Align_text__left; | ||
| 15682 | + break; | ||
| 15683 | + } | ||
| 15684 | + } | ||
| 15685 | + } | ||
| 15686 | + | ||
| 15687 | + } else { | ||
| 15688 | + bf.align = strconv__Align_text__right; | ||
| 15689 | + } | ||
| 15690 | + { // Unsafe block | ||
| 15691 | + if (typ == StrIntpType__si_s) { | ||
| 15692 | + if (upper_case) { | ||
| 15693 | + string s = builtin__string_to_upper(data->d.d_s); | ||
| 15694 | + if (width == 0) { | ||
| 15695 | + strings__Builder_write_string(sb, s); | ||
| 15696 | + } else { | ||
| 15697 | + strconv__format_str_sb(s, bf, sb); | ||
| 15698 | + } | ||
| 15699 | + builtin__string_free(&s); | ||
| 15700 | + } else { | ||
| 15701 | + if (width == 0) { | ||
| 15702 | + strings__Builder_write_string(sb, data->d.d_s); | ||
| 15703 | + } else { | ||
| 15704 | + strconv__format_str_sb(data->d.d_s, bf, sb); | ||
| 15705 | + } | ||
| 15706 | + } | ||
| 15707 | + return; | ||
| 15708 | + } | ||
| 15709 | + if (typ == StrIntpType__si_r) { | ||
| 15710 | + if (width > 0) { | ||
| 15711 | + if (upper_case) { | ||
| 15712 | + string s = builtin__string_to_upper(data->d.d_s); | ||
| 15713 | + for (int _t1 = 1; _t1 < (1 + ((width > 0 ? (width) : (0)))); ++_t1) { | ||
| 15714 | + strings__Builder_write_string(sb, s); | ||
| 15715 | + } | ||
| 15716 | + builtin__string_free(&s); | ||
| 15717 | + } else { | ||
| 15718 | + for (int _t2 = 1; _t2 < (1 + ((width > 0 ? (width) : (0)))); ++_t2) { | ||
| 15719 | + strings__Builder_write_string(sb, data->d.d_s); | ||
| 15720 | + } | ||
| 15721 | + } | ||
| 15722 | + } | ||
| 15723 | + return; | ||
| 15724 | + } | ||
| 15725 | + if (typ == StrIntpType__si_i8 || typ == StrIntpType__si_i16 || typ == StrIntpType__si_i32 || typ == StrIntpType__si_i64) { | ||
| 15726 | + i64 d = data->d.d_i64; | ||
| 15727 | + if (typ == StrIntpType__si_i8) { | ||
| 15728 | + d = ((i64)(data->d.d_i8)); | ||
| 15729 | + } else if (typ == StrIntpType__si_i16) { | ||
| 15730 | + d = ((i64)(data->d.d_i16)); | ||
| 15731 | + } else if (typ == StrIntpType__si_i32) { | ||
| 15732 | + d = ((i64)(data->d.d_i32)); | ||
| 15733 | + } | ||
| 15734 | + if (base == 0) { | ||
| 15735 | + if (d < 0) { | ||
| 15736 | + bf.positive = false; | ||
| 15737 | + } | ||
| 15738 | + strconv__format_dec_sb(builtin__abs64(d), bf, sb); | ||
| 15739 | + } else { | ||
| 15740 | + if (base == 3) { | ||
| 15741 | + base = 2; | ||
| 15742 | + } | ||
| 15743 | + i64 absd = d; | ||
| 15744 | + bool write_minus = false; | ||
| 15745 | + if (d < 0 && pad_ch != ' ') { | ||
| 15746 | + absd = -d; | ||
| 15747 | + write_minus = true; | ||
| 15748 | + } | ||
| 15749 | + string hx = strconv__format_int(absd, base); | ||
| 15750 | + if (upper_case) { | ||
| 15751 | + string tmp = hx; | ||
| 15752 | + hx = builtin__string_to_upper(hx); | ||
| 15753 | + builtin__string_free(&tmp); | ||
| 15754 | + } | ||
| 15755 | + if (write_minus) { | ||
| 15756 | + strings__Builder_write_u8(sb, '-'); | ||
| 15757 | + bf.len0--; | ||
| 15758 | + } | ||
| 15759 | + if (width == 0) { | ||
| 15760 | + strings__Builder_write_string(sb, hx); | ||
| 15761 | + } else { | ||
| 15762 | + strconv__format_str_sb(hx, bf, sb); | ||
| 15763 | + } | ||
| 15764 | + builtin__string_free(&hx); | ||
| 15765 | + } | ||
| 15766 | + return; | ||
| 15767 | + } | ||
| 15768 | + if (typ == StrIntpType__si_u8 || typ == StrIntpType__si_u16 || typ == StrIntpType__si_u32 || typ == StrIntpType__si_u64) { | ||
| 15769 | + u64 d = data->d.d_u64; | ||
| 15770 | + if (typ == StrIntpType__si_u8) { | ||
| 15771 | + d = ((u64)(data->d.d_u8)); | ||
| 15772 | + } else if (typ == StrIntpType__si_u16) { | ||
| 15773 | + d = ((u64)(data->d.d_u16)); | ||
| 15774 | + } else if (typ == StrIntpType__si_u32) { | ||
| 15775 | + d = ((u64)(data->d.d_u32)); | ||
| 15776 | + } | ||
| 15777 | + if (base == 0) { | ||
| 15778 | + strconv__format_dec_sb(d, bf, sb); | ||
| 15779 | + } else { | ||
| 15780 | + if (base == 3) { | ||
| 15781 | + base = 2; | ||
| 15782 | + } | ||
| 15783 | + string hx = strconv__format_uint(d, base); | ||
| 15784 | + if (upper_case) { | ||
| 15785 | + string tmp = hx; | ||
| 15786 | + hx = builtin__string_to_upper(hx); | ||
| 15787 | + builtin__string_free(&tmp); | ||
| 15788 | + } | ||
| 15789 | + if (width == 0) { | ||
| 15790 | + strings__Builder_write_string(sb, hx); | ||
| 15791 | + } else { | ||
| 15792 | + strconv__format_str_sb(hx, bf, sb); | ||
| 15793 | + } | ||
| 15794 | + builtin__string_free(&hx); | ||
| 15795 | + } | ||
| 15796 | + return; | ||
| 15797 | + } | ||
| 15798 | + if (typ == StrIntpType__si_p) { | ||
| 15799 | + u64 d = ((u64)(data->d.d_p)); | ||
| 15800 | + base = 16; | ||
| 15801 | + if (base == 0) { | ||
| 15802 | + if (width == 0) { | ||
| 15803 | + string d_str = builtin__u64_str(d); | ||
| 15804 | + strings__Builder_write_string(sb, d_str); | ||
| 15805 | + builtin__string_free(&d_str); | ||
| 15806 | + return; | ||
| 15807 | + } | ||
| 15808 | + strconv__format_dec_sb(d, bf, sb); | ||
| 15809 | + } else { | ||
| 15810 | + string hx = strconv__format_uint(d, base); | ||
| 15811 | + if (upper_case) { | ||
| 15812 | + string tmp = hx; | ||
| 15813 | + hx = builtin__string_to_upper(hx); | ||
| 15814 | + builtin__string_free(&tmp); | ||
| 15815 | + } | ||
| 15816 | + if (width == 0) { | ||
| 15817 | + strings__Builder_write_string(sb, hx); | ||
| 15818 | + } else { | ||
| 15819 | + strconv__format_str_sb(hx, bf, sb); | ||
| 15820 | + } | ||
| 15821 | + builtin__string_free(&hx); | ||
| 15822 | + } | ||
| 15823 | + return; | ||
| 15824 | + } | ||
| 15825 | + bool use_default_str = false; | ||
| 15826 | + if (width == 0 && precision == 0x7F) { | ||
| 15827 | + bf.len1 = 3; | ||
| 15828 | + use_default_str = true; | ||
| 15829 | + } | ||
| 15830 | + if (bf.len1 < 0) { | ||
| 15831 | + bf.len1 = 3; | ||
| 15832 | + } | ||
| 15833 | + switch (typ) { | ||
| 15834 | + case StrIntpType__si_f32: { | ||
| 15835 | + #if !defined(CUSTOM_DEFINE_nofloat) | ||
| 15836 | + { | ||
| 15837 | + if (use_default_str) { | ||
| 15838 | + string f = builtin__f32_str(data->d.d_f32); | ||
| 15839 | + if (upper_case) { | ||
| 15840 | + string tmp = f; | ||
| 15841 | + f = builtin__string_to_upper(f); | ||
| 15842 | + builtin__string_free(&tmp); | ||
| 15843 | + } | ||
| 15844 | + strings__Builder_write_string(sb, f); | ||
| 15845 | + builtin__string_free(&f); | ||
| 15846 | + } else { | ||
| 15847 | + if (data->d.d_f32 < 0) { | ||
| 15848 | + bf.positive = false; | ||
| 15849 | + } | ||
| 15850 | + string f = strconv__format_fl(data->d.d_f32, bf); | ||
| 15851 | + if (upper_case) { | ||
| 15852 | + string tmp = f; | ||
| 15853 | + f = builtin__string_to_upper(f); | ||
| 15854 | + builtin__string_free(&tmp); | ||
| 15855 | + } | ||
| 15856 | + strings__Builder_write_string(sb, f); | ||
| 15857 | + builtin__string_free(&f); | ||
| 15858 | + } | ||
| 15859 | + } | ||
| 15860 | + #endif | ||
| 15861 | + break; | ||
| 15862 | + } | ||
| 15863 | + case StrIntpType__si_f64: { | ||
| 15864 | + #if !defined(CUSTOM_DEFINE_nofloat) | ||
| 15865 | + { | ||
| 15866 | + if (use_default_str) { | ||
| 15867 | + string f = builtin__f64_str(data->d.d_f64); | ||
| 15868 | + if (upper_case) { | ||
| 15869 | + string tmp = f; | ||
| 15870 | + f = builtin__string_to_upper(f); | ||
| 15871 | + builtin__string_free(&tmp); | ||
| 15872 | + } | ||
| 15873 | + strings__Builder_write_string(sb, f); | ||
| 15874 | + builtin__string_free(&f); | ||
| 15875 | + } else { | ||
| 15876 | + if (data->d.d_f64 < 0) { | ||
| 15877 | + bf.positive = false; | ||
| 15878 | + } | ||
| 15879 | + strconv__Float64u _t5 = ((strconv__Float64u){.f = data->d.d_f64,}); | ||
| 15880 | + strconv__Float64u f_union = _t5; | ||
| 15881 | + if (f_union.u == _const_strconv__double_minus_zero) { | ||
| 15882 | + bf.positive = false; | ||
| 15883 | + } | ||
| 15884 | + string f = strconv__format_fl(data->d.d_f64, bf); | ||
| 15885 | + if (upper_case) { | ||
| 15886 | + string tmp = f; | ||
| 15887 | + f = builtin__string_to_upper(f); | ||
| 15888 | + builtin__string_free(&tmp); | ||
| 15889 | + } | ||
| 15890 | + strings__Builder_write_string(sb, f); | ||
| 15891 | + builtin__string_free(&f); | ||
| 15892 | + } | ||
| 15893 | + } | ||
| 15894 | + #endif | ||
| 15895 | + break; | ||
| 15896 | + } | ||
| 15897 | + case StrIntpType__si_g32: { | ||
| 15898 | + if (use_default_str) { | ||
| 15899 | + #if !defined(CUSTOM_DEFINE_nofloat) | ||
| 15900 | + { | ||
| 15901 | + string f = builtin__f32_strg(data->d.d_f32); | ||
| 15902 | + if (upper_case) { | ||
| 15903 | + string tmp = f; | ||
| 15904 | + f = builtin__string_to_upper(f); | ||
| 15905 | + builtin__string_free(&tmp); | ||
| 15906 | + } | ||
| 15907 | + strings__Builder_write_string(sb, f); | ||
| 15908 | + builtin__string_free(&f); | ||
| 15909 | + } | ||
| 15910 | + #endif | ||
| 15911 | + } else { | ||
| 15912 | + if (data->d.d_f32 == _const_strconv__single_plus_zero) { | ||
| 15913 | + string tmp_str = _S("0"); | ||
| 15914 | + strconv__format_str_sb(tmp_str, bf, sb); | ||
| 15915 | + builtin__string_free(&tmp_str); | ||
| 15916 | + return; | ||
| 15917 | + } | ||
| 15918 | + if (data->d.d_f32 == _const_strconv__single_minus_zero) { | ||
| 15919 | + string tmp_str = _S("-0"); | ||
| 15920 | + strconv__format_str_sb(tmp_str, bf, sb); | ||
| 15921 | + builtin__string_free(&tmp_str); | ||
| 15922 | + return; | ||
| 15923 | + } | ||
| 15924 | + if (data->d.d_f32 == _const_strconv__single_plus_infinity) { | ||
| 15925 | + string tmp_str = _S("+inf"); | ||
| 15926 | + if (upper_case) { | ||
| 15927 | + tmp_str = _S("+INF"); | ||
| 15928 | + } | ||
| 15929 | + strconv__format_str_sb(tmp_str, bf, sb); | ||
| 15930 | + builtin__string_free(&tmp_str); | ||
| 15931 | + } | ||
| 15932 | + if (data->d.d_f32 == _const_strconv__single_minus_infinity) { | ||
| 15933 | + string tmp_str = _S("-inf"); | ||
| 15934 | + if (upper_case) { | ||
| 15935 | + tmp_str = _S("-INF"); | ||
| 15936 | + } | ||
| 15937 | + strconv__format_str_sb(tmp_str, bf, sb); | ||
| 15938 | + builtin__string_free(&tmp_str); | ||
| 15939 | + } | ||
| 15940 | + if (data->d.d_f32 < 0) { | ||
| 15941 | + bf.positive = false; | ||
| 15942 | + } | ||
| 15943 | + f32 d = builtin__fabs32(data->d.d_f32); | ||
| 15944 | + if (d < ((f32)(999999.0)) && d >= ((f32)(0.00001))) { | ||
| 15945 | + string f = strconv__format_fl(data->d.d_f32, bf); | ||
| 15946 | + if (upper_case) { | ||
| 15947 | + string tmp = f; | ||
| 15948 | + f = builtin__string_to_upper(f); | ||
| 15949 | + builtin__string_free(&tmp); | ||
| 15950 | + } | ||
| 15951 | + strings__Builder_write_string(sb, f); | ||
| 15952 | + builtin__string_free(&f); | ||
| 15953 | + return; | ||
| 15954 | + } | ||
| 15955 | + bf.len1--; | ||
| 15956 | + string f = strconv__format_es(data->d.d_f32, bf); | ||
| 15957 | + if (upper_case) { | ||
| 15958 | + string tmp = f; | ||
| 15959 | + f = builtin__string_to_upper(f); | ||
| 15960 | + builtin__string_free(&tmp); | ||
| 15961 | + } | ||
| 15962 | + strings__Builder_write_string(sb, f); | ||
| 15963 | + builtin__string_free(&f); | ||
| 15964 | + } | ||
| 15965 | + break; | ||
| 15966 | + } | ||
| 15967 | + case StrIntpType__si_g64: { | ||
| 15968 | + if (use_default_str) { | ||
| 15969 | + #if !defined(CUSTOM_DEFINE_nofloat) | ||
| 15970 | + { | ||
| 15971 | + string f = builtin__f64_strg(data->d.d_f64); | ||
| 15972 | + if (upper_case) { | ||
| 15973 | + string tmp = f; | ||
| 15974 | + f = builtin__string_to_upper(f); | ||
| 15975 | + builtin__string_free(&tmp); | ||
| 15976 | + } | ||
| 15977 | + strings__Builder_write_string(sb, f); | ||
| 15978 | + builtin__string_free(&f); | ||
| 15979 | + } | ||
| 15980 | + #endif | ||
| 15981 | + } else { | ||
| 15982 | + if (data->d.d_f64 == _const_strconv__double_plus_zero) { | ||
| 15983 | + string tmp_str = _S("0"); | ||
| 15984 | + strconv__format_str_sb(tmp_str, bf, sb); | ||
| 15985 | + builtin__string_free(&tmp_str); | ||
| 15986 | + return; | ||
| 15987 | + } | ||
| 15988 | + if (data->d.d_f64 == _const_strconv__double_minus_zero) { | ||
| 15989 | + string tmp_str = _S("-0"); | ||
| 15990 | + strconv__format_str_sb(tmp_str, bf, sb); | ||
| 15991 | + builtin__string_free(&tmp_str); | ||
| 15992 | + return; | ||
| 15993 | + } | ||
| 15994 | + if (data->d.d_f64 == _const_strconv__double_plus_infinity) { | ||
| 15995 | + string tmp_str = _S("+inf"); | ||
| 15996 | + if (upper_case) { | ||
| 15997 | + tmp_str = _S("+INF"); | ||
| 15998 | + } | ||
| 15999 | + strconv__format_str_sb(tmp_str, bf, sb); | ||
| 16000 | + builtin__string_free(&tmp_str); | ||
| 16001 | + } | ||
| 16002 | + if (data->d.d_f64 == _const_strconv__double_minus_infinity) { | ||
| 16003 | + string tmp_str = _S("-inf"); | ||
| 16004 | + if (upper_case) { | ||
| 16005 | + tmp_str = _S("-INF"); | ||
| 16006 | + } | ||
| 16007 | + strconv__format_str_sb(tmp_str, bf, sb); | ||
| 16008 | + builtin__string_free(&tmp_str); | ||
| 16009 | + } | ||
| 16010 | + if (data->d.d_f64 < 0) { | ||
| 16011 | + bf.positive = false; | ||
| 16012 | + } | ||
| 16013 | + f64 d = builtin__fabs64(data->d.d_f64); | ||
| 16014 | + if (d < ((f64)(999999.0)) && d >= ((f64)(0.00001))) { | ||
| 16015 | + string f = strconv__format_fl(data->d.d_f64, bf); | ||
| 16016 | + if (upper_case) { | ||
| 16017 | + string tmp = f; | ||
| 16018 | + f = builtin__string_to_upper(f); | ||
| 16019 | + builtin__string_free(&tmp); | ||
| 16020 | + } | ||
| 16021 | + strings__Builder_write_string(sb, f); | ||
| 16022 | + builtin__string_free(&f); | ||
| 16023 | + return; | ||
| 16024 | + } | ||
| 16025 | + bf.len1--; | ||
| 16026 | + string f = strconv__format_es(data->d.d_f64, bf); | ||
| 16027 | + if (upper_case) { | ||
| 16028 | + string tmp = f; | ||
| 16029 | + f = builtin__string_to_upper(f); | ||
| 16030 | + builtin__string_free(&tmp); | ||
| 16031 | + } | ||
| 16032 | + strings__Builder_write_string(sb, f); | ||
| 16033 | + builtin__string_free(&f); | ||
| 16034 | + } | ||
| 16035 | + break; | ||
| 16036 | + } | ||
| 16037 | + case StrIntpType__si_e32: { | ||
| 16038 | + #if !defined(CUSTOM_DEFINE_nofloat) | ||
| 16039 | + { | ||
| 16040 | + if (use_default_str) { | ||
| 16041 | + string f = builtin__f32_str(data->d.d_f32); | ||
| 16042 | + if (upper_case) { | ||
| 16043 | + string tmp = f; | ||
| 16044 | + f = builtin__string_to_upper(f); | ||
| 16045 | + builtin__string_free(&tmp); | ||
| 16046 | + } | ||
| 16047 | + strings__Builder_write_string(sb, f); | ||
| 16048 | + builtin__string_free(&f); | ||
| 16049 | + } else { | ||
| 16050 | + if (data->d.d_f32 < 0) { | ||
| 16051 | + bf.positive = false; | ||
| 16052 | + } | ||
| 16053 | + string f = strconv__format_es(data->d.d_f32, bf); | ||
| 16054 | + if (upper_case) { | ||
| 16055 | + string tmp = f; | ||
| 16056 | + f = builtin__string_to_upper(f); | ||
| 16057 | + builtin__string_free(&tmp); | ||
| 16058 | + } | ||
| 16059 | + strings__Builder_write_string(sb, f); | ||
| 16060 | + builtin__string_free(&f); | ||
| 16061 | + } | ||
| 16062 | + } | ||
| 16063 | + #endif | ||
| 16064 | + break; | ||
| 16065 | + } | ||
| 16066 | + case StrIntpType__si_e64: { | ||
| 16067 | + #if !defined(CUSTOM_DEFINE_nofloat) | ||
| 16068 | + { | ||
| 16069 | + if (use_default_str) { | ||
| 16070 | + string f = builtin__f64_str(data->d.d_f64); | ||
| 16071 | + if (upper_case) { | ||
| 16072 | + string tmp = f; | ||
| 16073 | + f = builtin__string_to_upper(f); | ||
| 16074 | + builtin__string_free(&tmp); | ||
| 16075 | + } | ||
| 16076 | + strings__Builder_write_string(sb, f); | ||
| 16077 | + builtin__string_free(&f); | ||
| 16078 | + } else { | ||
| 16079 | + if (data->d.d_f64 < 0) { | ||
| 16080 | + bf.positive = false; | ||
| 16081 | + } | ||
| 16082 | + string f = strconv__format_es(data->d.d_f64, bf); | ||
| 16083 | + if (upper_case) { | ||
| 16084 | + string tmp = f; | ||
| 16085 | + f = builtin__string_to_upper(f); | ||
| 16086 | + builtin__string_free(&tmp); | ||
| 16087 | + } | ||
| 16088 | + strings__Builder_write_string(sb, f); | ||
| 16089 | + builtin__string_free(&f); | ||
| 16090 | + } | ||
| 16091 | + } | ||
| 16092 | + #endif | ||
| 16093 | + break; | ||
| 16094 | + } | ||
| 16095 | + case StrIntpType__si_c: { | ||
| 16096 | + string ss = builtin__utf32_to_str(data->d.d_c); | ||
| 16097 | + strings__Builder_write_string(sb, ss); | ||
| 16098 | + builtin__string_free(&ss); | ||
| 16099 | + break; | ||
| 16100 | + } | ||
| 16101 | + case StrIntpType__si_vp: { | ||
| 16102 | + string ss = builtin__u64_hex(((u64)(data->d.d_vp))); | ||
| 16103 | + strings__Builder_write_string(sb, ss); | ||
| 16104 | + builtin__string_free(&ss); | ||
| 16105 | + break; | ||
| 16106 | + } | ||
| 16107 | + case StrIntpType__si_no_str: | ||
| 16108 | + case StrIntpType__si_u8: | ||
| 16109 | + case StrIntpType__si_i8: | ||
| 16110 | + case StrIntpType__si_u16: | ||
| 16111 | + case StrIntpType__si_i16: | ||
| 16112 | + case StrIntpType__si_u32: | ||
| 16113 | + case StrIntpType__si_i32: | ||
| 16114 | + case StrIntpType__si_u64: | ||
| 16115 | + case StrIntpType__si_i64: | ||
| 16116 | + case StrIntpType__si_s: | ||
| 16117 | + case StrIntpType__si_p: | ||
| 16118 | + case StrIntpType__si_r: | ||
| 16119 | + default: { | ||
| 16120 | + { | ||
| 16121 | + strings__Builder_write_string(sb, _S("***ERROR!***")); | ||
| 16122 | + break; | ||
| 16123 | + } | ||
| 16124 | + } | ||
| 16125 | + } | ||
| 16126 | + | ||
| 16127 | + } | ||
| 16128 | +} | ||
| 16129 | +string builtin__str_intp(int data_len, StrIntpData* input_base) { | ||
| 16130 | + strings__Builder res = strings__new_builder(64); | ||
| 16131 | + for (int i = 0; i < data_len; i++) { | ||
| 16132 | + StrIntpData* data = &input_base[i]; | ||
| 16133 | + if (data->str.len != 0) { | ||
| 16134 | + strings__Builder_write_string(&res, data->str); | ||
| 16135 | + } | ||
| 16136 | + if (data->fmt != 0) { | ||
| 16137 | + builtin__StrIntpData_process_str_intp_data(data, (voidptr)&res); | ||
| 16138 | + } | ||
| 16139 | + } | ||
| 16140 | + string ret = strings__Builder_str(&res); | ||
| 16141 | + strings__Builder_free(&res); | ||
| 16142 | + return ret; | ||
| 16143 | +} | ||
| 16144 | +inline string builtin__str_intp_sq(string in_str) { | ||
| 16145 | + return builtin__string_plus_many(5, _MOV((string[5]){_S("builtin__str_intp(2, _MOV((StrIntpData[]){{_S(\"\'\"), "), _const_si_s_code, _S(", {.d_s = "), in_str, _S("}, 0, 0, 0},{_S(\"\'\"), 0, {0}, 0, 0, 0}}))")})); | ||
| 16146 | +} | ||
| 16147 | +inline string builtin__str_intp_rune(string in_str) { | ||
| 16148 | + return builtin__string_plus_many(5, _MOV((string[5]){_S("builtin__str_intp(2, _MOV((StrIntpData[]){{_S(\"`\"), "), _const_si_s_code, _S(", {.d_s = "), in_str, _S("}, 0, 0, 0},{_S(\"`\"), 0, {0}, 0, 0, 0}}))")})); | ||
| 16149 | +} | ||
| 16150 | +inline string builtin__str_intp_g32(string in_str) { | ||
| 16151 | + return builtin__string_plus_many(5, _MOV((string[5]){_S("builtin__str_intp(1, _MOV((StrIntpData[]){{_SLIT0, "), _const_si_g32_code, _S(", {.d_f32 = "), in_str, _S(" }, 0, 0, 0}}))")})); | ||
| 16152 | +} | ||
| 16153 | +inline string builtin__str_intp_g64(string in_str) { | ||
| 16154 | + return builtin__string_plus_many(5, _MOV((string[5]){_S("builtin__str_intp(1, _MOV((StrIntpData[]){{_SLIT0, "), _const_si_g64_code, _S(", {.d_f64 = "), in_str, _S(" }, 0, 0, 0}}))")})); | ||
| 16155 | +} | ||
| 16156 | +string builtin__str_intp_sub(string base_str, string in_str) { | ||
| 16157 | + _option_int _t1 = builtin__string_index(base_str, _S("%%")); | ||
| 16158 | + if (_t1.state != 0) { | ||
| 16159 | + builtin__eprintln(_S("No string interpolation %% parameters")); | ||
| 16160 | + builtin___v_exit(1); | ||
| 16161 | + VUNREACHABLE(); | ||
| 16162 | + ; | ||
| 16163 | + } | ||
| 16164 | + | ||
| 16165 | + int index = (*(int*)_t1.data); | ||
| 16166 | + { // Unsafe block | ||
| 16167 | + string st_str = builtin__string_substr(base_str, 0, index); | ||
| 16168 | + if (index + 2 < base_str.len) { | ||
| 16169 | + string en_str = builtin__string_substr(base_str, index + 2, 2147483647); | ||
| 16170 | + string res_str = builtin__string_plus_many(9, _MOV((string[9]){_S("builtin__str_intp(2, _MOV((StrIntpData[]){{_S(\""), st_str, _S("\"), "), _const_si_s_code, _S(", {.d_s = "), in_str, _S(" }, 0, 0, 0},{_S(\""), en_str, _S("\"), 0, {0}, 0, 0, 0}}))")})); | ||
| 16171 | + builtin__string_free(&st_str); | ||
| 16172 | + builtin__string_free(&en_str); | ||
| 16173 | + return res_str; | ||
| 16174 | + } | ||
| 16175 | + string res2_str = builtin__string_plus_many(7, _MOV((string[7]){_S("builtin__str_intp(1, _MOV((StrIntpData[]){{_S(\""), st_str, _S("\"), "), _const_si_s_code, _S(", {.d_s = "), in_str, _S(" }, 0, 0, 0}}))")})); | ||
| 16176 | + builtin__string_free(&st_str); | ||
| 16177 | + return res2_str; | ||
| 16178 | + } | ||
| 16179 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 16180 | +} | ||
| 16181 | +u16* builtin__string_to_wide(string _str, ToWideConfig param) { | ||
| 16182 | + #if 0 | ||
| 16183 | + { | ||
| 16184 | + } | ||
| 16185 | + #else | ||
| 16186 | + { | ||
| 16187 | + Array_rune srunes = builtin__string_runes(_str); | ||
| 16188 | + { // Unsafe block | ||
| 16189 | + u16* result = ((u16*)(builtin__vcalloc_noscan((srunes.len + 1) * 2))); | ||
| 16190 | + for (int i = 0; i < srunes.len; ++i) { | ||
| 16191 | + rune r = ((rune*)srunes.data)[i]; | ||
| 16192 | + result[i] = ((u16)(r)); | ||
| 16193 | + } | ||
| 16194 | + result[srunes.len] = 0; | ||
| 16195 | + return result; | ||
| 16196 | + } | ||
| 16197 | + } | ||
| 16198 | + #endif | ||
| 16199 | + return 0; | ||
| 16200 | +} | ||
| 16201 | +string builtin__string_from_wide(u16* _wstr) { | ||
| 16202 | + #if 0 | ||
| 16203 | + { | ||
| 16204 | + } | ||
| 16205 | + #else | ||
| 16206 | + { | ||
| 16207 | + int i = 0; | ||
| 16208 | + for (;;) { | ||
| 16209 | + if (!(_wstr[i] != 0)) break; | ||
| 16210 | + i++; | ||
| 16211 | + } | ||
| 16212 | + return builtin__string_from_wide2(_wstr, i); | ||
| 16213 | + } | ||
| 16214 | + #endif | ||
| 16215 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 16216 | +} | ||
| 16217 | +string builtin__string_from_wide2(u16* _wstr, int len) { | ||
| 16218 | + #if 0 | ||
| 16219 | + { | ||
| 16220 | + } | ||
| 16221 | + #else | ||
| 16222 | + { | ||
| 16223 | + strings__Builder sb = strings__new_builder(len); | ||
| 16224 | + for (int i = 0; i < len; i++) { | ||
| 16225 | + rune u = ((rune)(_wstr[i])); | ||
| 16226 | + strings__Builder_write_rune(&sb, u); | ||
| 16227 | + } | ||
| 16228 | + string res = strings__Builder_str(&sb); | ||
| 16229 | + strings__Builder_free(&sb); | ||
| 16230 | + return res; | ||
| 16231 | + } | ||
| 16232 | + #endif | ||
| 16233 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 16234 | +} | ||
| 16235 | +Array_u8 builtin__wide_to_ansi(u16* _wstr) { | ||
| 16236 | + #if 0 | ||
| 16237 | + { | ||
| 16238 | + } | ||
| 16239 | + #else | ||
| 16240 | + { | ||
| 16241 | + string s = builtin__string_from_wide(_wstr); | ||
| 16242 | + Array_u8 str_to = builtin____new_array_with_default(s.len + 1, 0, sizeof(u8), 0); | ||
| 16243 | + builtin__vmemcpy(str_to.data, s.str, s.len); | ||
| 16244 | + return str_to; | ||
| 16245 | + } | ||
| 16246 | + #endif | ||
| 16247 | + return builtin____new_array_with_default(0, 0, sizeof(u8), 0); | ||
| 16248 | +} | ||
| 16249 | +int builtin__utf8_char_len(u8 b) { | ||
| 16250 | + return ((int)((((v__rshift_u32(((u32)(0xe5000000U)), (u64)(((v__rshift_u8(b, (u64)3)) & 0x1e)))) & 3)) + 1)); | ||
| 16251 | +} | ||
| 16252 | +string builtin__utf32_to_str(u32 code) { | ||
| 16253 | + { // Unsafe block | ||
| 16254 | + u8* buffer = builtin__malloc_noscan(5); | ||
| 16255 | + string res = builtin__utf32_to_str_no_malloc(code, buffer); | ||
| 16256 | + if (res.len == 0) { | ||
| 16257 | + builtin___v_free(buffer); | ||
| 16258 | + } | ||
| 16259 | + return res; | ||
| 16260 | + } | ||
| 16261 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 16262 | +} | ||
| 16263 | +string builtin__utf32_to_str_no_malloc(u32 code, u8* buf) { | ||
| 16264 | + { // Unsafe block | ||
| 16265 | + int len = builtin__utf32_decode_to_buffer(code, buf); | ||
| 16266 | + if (len == 0) { | ||
| 16267 | + return _S(""); | ||
| 16268 | + } | ||
| 16269 | + buf[len] = 0; | ||
| 16270 | + return builtin__tos(buf, len); | ||
| 16271 | + } | ||
| 16272 | + return (string){.str=(byteptr)"", .is_lit=1}; | ||
| 16273 | +} | ||
| 16274 | +int builtin__utf32_decode_to_buffer(u32 code, u8* buf) { | ||
| 16275 | + { // Unsafe block | ||
| 16276 | + int icode = ((int)(code)); | ||
| 16277 | + u8* buffer = ((u8*)(buf)); | ||
| 16278 | + if (icode <= 127) { | ||
| 16279 | + buffer[0] = ((u8)(icode)); | ||
| 16280 | + return 1; | ||
| 16281 | + } else if (icode <= 2047) { | ||
| 16282 | + buffer[0] = (192 | ((u8)(v__rshift_int(icode, (u64)6)))); | ||
| 16283 | + buffer[1] = (128 | ((u8)((icode & 63)))); | ||
| 16284 | + return 2; | ||
| 16285 | + } else if (icode <= 65535) { | ||
| 16286 | + buffer[0] = (224 | ((u8)(v__rshift_int(icode, (u64)12)))); | ||
| 16287 | + buffer[1] = (128 | ((((u8)(v__rshift_int(icode, (u64)6))) & 63))); | ||
| 16288 | + buffer[2] = (128 | ((u8)((icode & 63)))); | ||
| 16289 | + return 3; | ||
| 16290 | + } else if (icode <= 1114111) { | ||
| 16291 | + buffer[0] = (240 | ((u8)(v__rshift_int(icode, (u64)18)))); | ||
| 16292 | + buffer[1] = (128 | ((((u8)(v__rshift_int(icode, (u64)12))) & 63))); | ||
| 16293 | + buffer[2] = (128 | ((((u8)(v__rshift_int(icode, (u64)6))) & 63))); | ||
| 16294 | + buffer[3] = (128 | ((u8)((icode & 63)))); | ||
| 16295 | + return 4; | ||
| 16296 | + } | ||
| 16297 | + } | ||
| 16298 | + return 0; | ||
| 16299 | +} | ||
| 16300 | +int builtin__string_utf32_code(string _rune) { | ||
| 16301 | + if (_rune.len > 4) { | ||
| 16302 | + return 0; | ||
| 16303 | + } | ||
| 16304 | + return ((int)(builtin__impl_utf8_to_utf32(_rune.str, _rune.len))); | ||
| 16305 | +} | ||
| 16306 | +_result_rune Array_u8_utf8_to_utf32(Array_u8 _bytes) { | ||
| 16307 | + if (_bytes.len > 4) { | ||
| 16308 | + return (_result_rune){ .is_error=true, .err=builtin___v_error(_S("attempted to decode too many bytes, utf-8 is limited to four bytes maximum")), .data={E_STRUCT} }; | ||
| 16309 | + } | ||
| 16310 | + _result_rune _t2; | ||
| 16311 | + builtin___result_ok(&(rune[]) { builtin__impl_utf8_to_utf32(_bytes.data, _bytes.len) }, (_result*)(&_t2), sizeof(rune)); | ||
| 16312 | + | ||
| 16313 | + return _t2; | ||
| 16314 | +} | ||
| 16315 | +inline VV_LOC bool builtin__utf8_is_continuation(u8 b) { | ||
| 16316 | + return ((b & 0xc0)) == 0x80; | ||
| 16317 | +} | ||
| 16318 | +VV_LOC multi_return_rune_int builtin__utf8_decode_rune(u8* _bytes, int available_len) { | ||
| 16319 | + if (available_len <= 0) { | ||
| 16320 | + return (multi_return_rune_int){.arg0=0, .arg1=0}; | ||
| 16321 | + } | ||
| 16322 | + u8 b0 = _bytes[0]; | ||
| 16323 | + if (b0 < 0x80) { | ||
| 16324 | + return (multi_return_rune_int){.arg0=((rune)(b0)), .arg1=1}; | ||
| 16325 | + } | ||
| 16326 | + if (b0 < 0xc2) { | ||
| 16327 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | ||
| 16328 | + } | ||
| 16329 | + int _t4; /* if prepend */ | ||
| 16330 | + if (b0 < 0xe0) { | ||
| 16331 | + _t4 = 2; | ||
| 16332 | + goto _t5; | ||
| 16333 | + }; | ||
| 16334 | + { | ||
| 16335 | + if (b0 < 0xf0) { | ||
| 16336 | + _t4 = 3; | ||
| 16337 | + goto _t5; | ||
| 16338 | + }; | ||
| 16339 | + { | ||
| 16340 | + if (b0 < 0xf5) { | ||
| 16341 | + _t4 = 4; | ||
| 16342 | + goto _t5; | ||
| 16343 | + }; | ||
| 16344 | + { | ||
| 16345 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | ||
| 16346 | + } | ||
| 16347 | + } | ||
| 16348 | + } | ||
| 16349 | + _t5: {}; | ||
| 16350 | + int char_len = _t4; | ||
| 16351 | + if (available_len < char_len) { | ||
| 16352 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | ||
| 16353 | + } | ||
| 16354 | + u8 b1 = _bytes[1]; | ||
| 16355 | + if (!builtin__utf8_is_continuation(b1)) { | ||
| 16356 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | ||
| 16357 | + } | ||
| 16358 | + if (char_len == 2) { | ||
| 16359 | + return (multi_return_rune_int){.arg0=((v__lshift_rune(((((rune)(b0)) & 0x1f)), (u64)6)) | ((((rune)(b1)) & 0x3f))), .arg1=2}; | ||
| 16360 | + } | ||
| 16361 | + if (b0 == 0xe0 && b1 < 0xa0) { | ||
| 16362 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | ||
| 16363 | + } | ||
| 16364 | + if (b0 == 0xed && b1 >= 0xa0) { | ||
| 16365 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | ||
| 16366 | + } | ||
| 16367 | + u8 b2 = _bytes[2]; | ||
| 16368 | + if (!builtin__utf8_is_continuation(b2)) { | ||
| 16369 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | ||
| 16370 | + } | ||
| 16371 | + if (char_len == 3) { | ||
| 16372 | + return (multi_return_rune_int){.arg0=(((v__lshift_rune(((((rune)(b0)) & 0x0f)), (u64)12)) | (v__lshift_rune(((((rune)(b1)) & 0x3f)), (u64)6))) | ((((rune)(b2)) & 0x3f))), .arg1=3}; | ||
| 16373 | + } | ||
| 16374 | + if (b0 == 0xf0 && b1 < 0x90) { | ||
| 16375 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | ||
| 16376 | + } | ||
| 16377 | + if (b0 == 0xf4 && b1 > 0x8f) { | ||
| 16378 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | ||
| 16379 | + } | ||
| 16380 | + u8 b3 = _bytes[3]; | ||
| 16381 | + if (!builtin__utf8_is_continuation(b3)) { | ||
| 16382 | + return (multi_return_rune_int){.arg0=_const_utf8_replacement_rune, .arg1=1}; | ||
| 16383 | + } | ||
| 16384 | + return (multi_return_rune_int){.arg0=((((v__lshift_rune(((((rune)(b0)) & 0x07)), (u64)18)) | (v__lshift_rune(((((rune)(b1)) & 0x3f)), (u64)12))) | (v__lshift_rune(((((rune)(b2)) & 0x3f)), (u64)6))) | ((((rune)(b3)) & 0x3f))), .arg1=4}; | ||
| 16385 | +} | ||
| 16386 | +VV_LOC rune builtin__impl_utf8_to_utf32(u8* _bytes, int _bytes_len) { | ||
| 16387 | + if (_bytes_len == 0 || _bytes_len > 4) { | ||
| 16388 | + return 0; | ||
| 16389 | + } | ||
| 16390 | + multi_return_rune_int mr_4267 = builtin__utf8_decode_rune(_bytes, _bytes_len); | ||
| 16391 | + rune r = mr_4267.arg0; | ||
| 16392 | + int len = mr_4267.arg1; | ||
| 16393 | + if (len != _bytes_len) { | ||
| 16394 | + return _const_utf8_replacement_rune; | ||
| 16395 | + } | ||
| 16396 | + return r; | ||
| 16397 | +} | ||
| 16398 | +int builtin__utf8_str_visible_length(string s) { | ||
| 16399 | + return builtin__utf8_grapheme_visible_length(s); | ||
| 16400 | +} | ||
| 16401 | +Array_u8 builtin__string_to_ansi_not_null_terminated(string _str) { | ||
| 16402 | + u16* wstr = builtin__string_to_wide(_str, ((ToWideConfig){.from_ansi = 0,})); | ||
| 16403 | + Array_u8 ansi = builtin__wide_to_ansi(wstr); | ||
| 16404 | + if (ansi.len > 0) { | ||
| 16405 | + ansi.len--; | ||
| 16406 | + } | ||
| 16407 | + return ansi; | ||
| 16408 | +} | ||
| 16409 | +inline bool builtin__ArrayFlags_is_empty(ArrayFlags* e) { | ||
| 16410 | + return ((int)(*e)) == 0; | ||
| 16411 | +} | ||
| 16412 | +inline bool builtin__ArrayFlags_has(ArrayFlags* e, ArrayFlags flag_) { | ||
| 16413 | + return ((((int)(*e)) & (((int)(flag_))))) != 0; | ||
| 16414 | +} | ||
| 16415 | +inline bool builtin__ArrayFlags_all(ArrayFlags* e, ArrayFlags flag_) { | ||
| 16416 | + return ((((int)(*e)) & (((int)(flag_))))) == ((int)(flag_)); | ||
| 16417 | +} | ||
| 16418 | +inline void builtin__ArrayFlags_set(ArrayFlags* e, ArrayFlags flag_) { | ||
| 16419 | + { // Unsafe block | ||
| 16420 | + *e = ((ArrayFlags)((((int)(*e)) | (((int)(flag_)))))); | ||
| 16421 | + } | ||
| 16422 | +} | ||
| 16423 | +inline void builtin__ArrayFlags_set_all(ArrayFlags* e) { | ||
| 16424 | + { // Unsafe block | ||
| 16425 | + *e = ((ArrayFlags)(0b1111111)); | ||
| 16426 | + } | ||
| 16427 | +} | ||
| 16428 | +inline void builtin__ArrayFlags_clear(ArrayFlags* e, ArrayFlags flag_) { | ||
| 16429 | + { // Unsafe block | ||
| 16430 | + *e = ((ArrayFlags)((((int)(*e)) & ~(((int)(flag_)))))); | ||
| 16431 | + } | ||
| 16432 | +} | ||
| 16433 | +inline void builtin__ArrayFlags_clear_all(ArrayFlags* e) { | ||
| 16434 | + { // Unsafe block | ||
| 16435 | + *e = ((ArrayFlags)(0)); | ||
| 16436 | + } | ||
| 16437 | +} | ||
| 16438 | +inline void builtin__ArrayFlags_toggle(ArrayFlags* e, ArrayFlags flag_) { | ||
| 16439 | + { // Unsafe block | ||
| 16440 | + *e = ((ArrayFlags)((((int)(*e)) ^ (((int)(flag_)))))); | ||
| 16441 | + } | ||
| 16442 | +} | ||
| 16443 | +inline ArrayFlags builtin__ArrayFlags__static__zero(void) { | ||
| 16444 | + return ((ArrayFlags)(0)); | ||
| 16445 | +} | ||
| 16446 | +VV_LOC void main__vf_init(void) { | ||
| 16447 | + string probe = _S("vf"); | ||
| 16448 | + {int _ = probe.len;} | ||
| 16449 | + ; | ||
| 16450 | +} | ||
| 16451 | +// export alias: vf_init -> main__vf_init | ||
| 16452 | +void vf_init(void) { | ||
| 16453 | + return main__vf_init(); | ||
| 16454 | +} | ||
| 16455 | +VV_LOC int main__vf_add(int a, int b) { | ||
| 16456 | + return a + b; | ||
| 16457 | +} | ||
| 16458 | +// export alias: vf_add -> main__vf_add | ||
| 16459 | +int vf_add(int a, int b) { | ||
| 16460 | + return main__vf_add(a, b); | ||
| 16461 | +} | ||
| 16462 | +VV_LOC char* main__vf_greet(char* name) { | ||
| 16463 | + string n = builtin__cstring_to_vstring(name); | ||
| 16464 | + string res = builtin__string_plus_many(3, _MOV((string[3]){_S("Hello, "), n, _S(", from V!")})); | ||
| 16465 | + u8* out = res.str; | ||
| 16466 | + builtin__string_free(&n); | ||
| 16467 | + return out; | ||
| 16468 | +} | ||
| 16469 | +// export alias: vf_greet -> main__vf_greet | ||
| 16470 | +char* vf_greet(char* name) { | ||
| 16471 | + return main__vf_greet(name); | ||
| 16472 | +} | ||
| 16473 | +VV_LOC void main__vf_free(voidptr p) { | ||
| 16474 | + builtin___v_free(p); | ||
| 16475 | +} | ||
| 16476 | +// export alias: vf_free -> main__vf_free | ||
| 16477 | +void vf_free(voidptr p) { | ||
| 16478 | + return main__vf_free(p); | ||
| 16479 | +} | ||
| 16480 | +VV_LOC void main__main(void) { | ||
| 16481 | +} | ||
| 16482 | +void _vinit(int ___argc, voidptr ___argv) { | ||
| 16483 | + static bool once = false; if (once) {return;} once = true; | ||
| 16484 | + // Initializations of consts for module builtin.closure | ||
| 16485 | + g_closure = ((builtin__closure__Closure){.ClosureMutex = ((builtin__closure__ClosureMutex){.closure_mtx = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}),.closure_ptr = 0,.closure_get_data = ((void*)0),.closure_cap = 0,.free_closure_ptr = 0,.pages = ((void*)0),.v_page_size = ((int)(0x4000)),.live = builtin__new_map(sizeof(voidptr), sizeof(builtin__closure__ClosureLiveInfo), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop),.active_lifetimes = builtin__new_map(sizeof(u64), sizeof(builtin__closure__ClosureLifetimeState*), &builtin__map_hash_int_8, &builtin__map_eq_int_8, &builtin__map_clone_int_8, &builtin__map_free_nop),.next_generation = 0,.free_lifetime_states = ((void*)0),.next_lifetime_generation = 0,.lifetime_state_allocs = 0,}); // global 3 | ||
| 16486 | +{ | ||
| 16487 | +{ | ||
| 16488 | +Array_fixed_u8_15 _t1; | ||
| 16489 | +#if defined(__V_ppc64le) | ||
| 16490 | +#elif !defined(__V_ppc64le) && !defined(__V_amd64) && !defined(__V_x86) && !defined(__V_arm64) && !defined(__V_arm32) && !defined(__V_rv64) && !defined(__V_rv32) && !defined(__V_s390x) && !defined(__V_loongarch64) | ||
| 16491 | +#elif defined(__V_amd64) | ||
| 16492 | + { Array_fixed_u8_15 _t2 = {((u8)(0xF3)), 0x44, 0x0F, 0x7E, 0x3D, 0xF7, 0xBF, 0xFF, 0xFF, 0xFF, 0x25, 0xF9, 0xBF, 0xFF, 0xFF} ; | ||
| 16493 | + memcpy(&_t1, &_t2, sizeof(Array_fixed_u8_15)); | ||
| 16494 | + } | ||
| 16495 | + ; | ||
| 16496 | +#elif defined(__V_x86) | ||
| 16497 | +#elif defined(__V_arm64) | ||
| 16498 | +#elif defined(__V_arm32) | ||
| 16499 | +#elif defined(__V_rv64) | ||
| 16500 | +#elif defined(__V_rv32) | ||
| 16501 | +#elif defined(__V_s390x) | ||
| 16502 | +#elif defined(__V_loongarch64) | ||
| 16503 | +#elif defined(__V_sparc64) | ||
| 16504 | +#elif 0 | ||
| 16505 | +#else | ||
| 16506 | +#endif | ||
| 16507 | + memcpy(&_const_builtin__closure__closure_thunk, &_t1, sizeof(Array_fixed_u8_15)); | ||
| 16508 | +} | ||
| 16509 | +} | ||
| 16510 | +{ | ||
| 16511 | +{ | ||
| 16512 | +Array_fixed_u8_6 _t3; | ||
| 16513 | +#if !defined(__V_ppc64le) && !defined(__V_amd64) && !defined(__V_x86) && !defined(__V_arm64) && !defined(__V_arm32) && !defined(__V_rv64) && !defined(__V_rv32) && !defined(__V_s390x) && !defined(__V_loongarch64) | ||
| 16514 | +#elif defined(__V_arm32) | ||
| 16515 | +#elif defined(__V_amd64) | ||
| 16516 | + { Array_fixed_u8_6 _t4 = {((u8)(0x66)), 0x4C, 0x0F, 0x7E, 0xF8, 0xC3} ; | ||
| 16517 | + memcpy(&_t3, &_t4, sizeof(Array_fixed_u8_6)); | ||
| 16518 | + } | ||
| 16519 | + ; | ||
| 16520 | +#elif defined(__V_x86) | ||
| 16521 | +#elif defined(__V_arm64) | ||
| 16522 | +#elif defined(__V_rv64) | ||
| 16523 | +#elif defined(__V_rv32) | ||
| 16524 | +#elif defined(__V_s390x) | ||
| 16525 | +#elif defined(__V_ppc64le) | ||
| 16526 | +#elif defined(__V_loongarch64) | ||
| 16527 | +#elif defined(__V_sparc64) | ||
| 16528 | +#elif 0 | ||
| 16529 | +#else | ||
| 16530 | +#endif | ||
| 16531 | + memcpy(&_const_builtin__closure__closure_get_data_bytes, &_t3, sizeof(Array_fixed_u8_6)); | ||
| 16532 | +} | ||
| 16533 | +} | ||
| 16534 | +{ | ||
| 16535 | +{ | ||
| 16536 | + _const_builtin__closure__closure_size_1 = (2 * ((u32)(sizeof(voidptr))) > ((u32)(15)) ? (2 * ((u32)(sizeof(voidptr)))) : (((u32)(15)) + ((u32)(sizeof(voidptr))) - 1)); | ||
| 16537 | +} | ||
| 16538 | +} | ||
| 16539 | + _const_builtin__closure__closure_size = ((int)((_const_builtin__closure__closure_size_1 & ~(((u32)(sizeof(voidptr))) - 1)))); | ||
| 16540 | + // Initializations of consts for module math.bits | ||
| 16541 | + _const_math__bits__overflow_error = _S("Overflow Error"); | ||
| 16542 | + _const_math__bits__divide_error = _S("Divide by Zero Error"); | ||
| 16543 | + // Initializations of consts for module strconv | ||
| 16544 | + _const_strconv__digit_pairs = _S("00102030405060708090011121314151617181910212223242526272829203132333435363738393041424344454647484940515253545556575859506162636465666768696071727374757677787970818283848586878889809192939495969798999"); | ||
| 16545 | + _const_strconv__base_digits = _S("0123456789abcdefghijklmnopqrstuvwxyz"); | ||
| 16546 | + _const_strconv__i64_min_int32 = ((i64)(-2147483647)) - 1; | ||
| 16547 | + _const_strconv__i64_max_int32 = ((i64)(2147483646)) + 1; | ||
| 16548 | + // Initializations of consts for module builtin | ||
| 16549 | + _const_grapheme_control_ranges = _S("00000000090000000b0000000c0000000e0000001f0000007f0000009f000000ad000000ad0000001c0600001c0600000e1800000e1800000b2000000b2000000e2000000f200000282000002820000029200000292000002a2000002e20000060200000642000006520000065200000662000006f200000fffe0000fffe0000f0ff0000f8ff0000f9ff0000fbff00003034010038340100a0bc0100a3bc010073d101007ad1010000000e0000000e0001000e0001000e0002000e001f000e0080000e00ff000e00f0010e00ff0f0e00"); | ||
| 16550 | + _const_grapheme_extend_ranges = _S("000300006f0300008304000087040000880400008904000091050000bd050000bf050000bf050000c1050000c2050000c4050000c5050000c7050000c7050000100600001a0600004b0600005f0600007006000070060000d6060000dc060000df060000e4060000e7060000e8060000ea060000ed0600001107000011070000300700004a070000a6070000b0070000eb070000f3070000fd070000fd07000016080000190800001b080000230800002508000027080000290800002d080000590800005b080000d3080000e1080000e3080000020900003a0900003a0900003c0900003c09000041090000480900004d0900004d090000510900005709000062090000630900008109000081090000bc090000bc090000be090000be090000c1090000c4090000cd090000cd090000d7090000d7090000e2090000e3090000fe090000fe090000010a0000020a00003c0a00003c0a0000410a0000420a0000470a0000480a00004b0a00004d0a0000510a0000510a0000700a0000710a0000750a0000750a0000810a0000820a0000bc0a0000bc0a0000c10a0000c50a0000c70a0000c80a0000cd0a0000cd0a0000e20a0000e30a0000fa0a0000ff0a0000010b0000010b00003c0b00003c0b00003e0b00003e0b00003f0b00003f0b0000410b0000440b00004d0b00004d0b0000550b0000560b0000570b0000570b0000620b0000630b0000820b0000820b0000be0b0000be0b0000c00b0000c00b0000cd0b0000cd0b0000d70b0000d70b0000000c0000000c0000040c0000040c00003e0c0000400c0000460c0000480c00004a0c00004d0c0000550c0000560c0000620c0000630c0000810c0000810c0000bc0c0000bc0c0000bf0c0000bf0c0000c20c0000c20c0000c60c0000c60c0000cc0c0000cd0c0000d50c0000d60c0000e20c0000e30c0000000d0000010d00003b0d00003c0d00003e0d00003e0d0000410d0000440d00004d0d00004d0d0000570d0000570d0000620d0000630d0000810d0000810d0000ca0d0000ca0d0000cf0d0000cf0d0000d20d0000d40d0000d60d0000d60d0000df0d0000df0d0000310e0000310e0000340e00003a0e0000470e00004e0e0000b10e0000b10e0000b40e0000bc0e0000c80e0000cd0e0000180f0000190f0000350f0000350f0000370f0000370f0000390f0000390f0000710f00007e0f0000800f0000840f0000860f0000870f00008d0f0000970f0000990f0000bc0f0000c60f0000c60f00002d100000301000003210000037100000391000003a1000003d1000003e10000058100000591000005e100000601000007110000074100000821000008210000085100000861000008d1000008d1000009d1000009d1000005d1300005f1300001217000014170000321700003417000052170000531700007217000073170000b4170000b5170000b7170000bd170000c6170000c6170000c9170000d3170000dd170000dd1700000b1800000d1800008518000086180000a9180000a9180000201900002219000027190000281900003219000032190000391900003b190000171a0000181a00001b1a00001b1a0000561a0000561a0000581a00005e1a0000601a0000601a0000621a0000621a0000651a00006c1a0000731a00007c1a00007f1a00007f1a0000b01a0000bd1a0000be1a0000be1a0000bf1a0000c01a0000001b0000031b0000341b0000341b0000351b0000351b0000361b00003a1b00003c1b00003c1b0000421b0000421b00006b1b0000731b0000801b0000811b0000a21b0000a51b0000a81b0000a91b0000ab1b0000ad1b0000e61b0000e61b0000e81b0000e91b0000ed1b0000ed1b0000ef1b0000f11b00002c1c0000331c0000361c0000371c0000d01c0000d21c0000d41c0000e01c0000e21c0000e81c0000ed1c0000ed1c0000f41c0000f41c0000f81c0000f91c0000c01d0000f91d0000fb1d0000ff1d00000c2000000c200000d0200000dc200000dd200000e0200000e1200000e1200000e2200000e4200000e5200000f0200000ef2c0000f12c00007f2d00007f2d0000e02d0000ff2d00002a3000002d3000002e3000002f300000993000009a3000006fa600006fa6000070a6000072a6000074a600007da600009ea600009fa60000f0a60000f1a6000002a8000002a8000006a8000006a800000ba800000ba8000025a8000026a800002ca800002ca80000c4a80000c5a80000e0a80000f1a80000ffa80000ffa8000026a900002da9000047a9000051a9000080a9000082a90000b3a90000b3a90000b6a90000b9a90000bca90000bda90000e5a90000e5a9000029aa00002eaa000031aa000032aa000035aa000036aa000043aa000043aa00004caa00004caa00007caa00007caa0000b0aa0000b0aa0000b2aa0000b4aa0000b7aa0000b8aa0000beaa0000bfaa0000c1aa0000c1aa0000ecaa0000edaa0000f6aa0000f6aa0000e5ab0000e5ab0000e8ab0000e8ab0000edab0000edab00001efb00001efb000000fe00000ffe000020fe00002ffe00009eff00009fff0000fd010100fd010100e0020100e0020100760301007a030100010a0100030a0100050a0100060a01000c0a01000f0a0100380a01003a0a01003f0a01003f0a0100e50a0100e60a0100240d0100270d0100ab0e0100ac0e0100460f0100500f0100011001000110010038100100461001007f10010081100100b3100100b6100100b9100100ba1001000011010002110100271101002b1101002d1101003411010073110100731101008011010081110100b6110100be110100c9110100cc110100cf110100cf1101002f12010031120100341201003412010036120100371201003e1201003e120100df120100df120100e3120100ea12010000130100011301003b1301003c1301003e1301003e13010040130100401301005713010057130100661301006c1301007013010074130100381401003f140100421401004414010046140100461401005e1401005e140100b0140100b0140100b3140100b8140100ba140100ba140100bd140100bd140100bf140100c0140100c2140100c3140100af150100af150100b2150100b5150100bc150100bd150100bf150100c0150100dc150100dd150100331601003a1601003d1601003d1601003f16010040160100ab160100ab160100ad160100ad160100b0160100b5160100b7160100b71601001d1701001f1701002217010025170100271701002b1701002f18010037180100391801003a18010030190100301901003b1901003c1901003e1901003e1901004319010043190100d4190100d7190100da190100db190100e0190100e0190100011a01000a1a0100331a0100381a01003b1a01003e1a0100471a0100471a0100511a0100561a0100591a01005b1a01008a1a0100961a0100981a0100991a0100301c0100361c0100381c01003d1c01003f1c01003f1c0100921c0100a71c0100aa1c0100b01c0100b21c0100b31c0100b51c0100b61c0100311d0100361d01003a1d01003a1d01003c1d01003d1d01003f1d0100451d0100471d0100471d0100901d0100911d0100951d0100951d0100971d0100971d0100f31e0100f41e0100f06a0100f46a0100306b0100366b01004f6f01004f6f01008f6f0100926f0100e46f0100e46f01009dbc01009ebc010065d1010065d1010067d1010069d101006ed1010072d101007bd1010082d1010085d101008bd10100aad10100add1010042d2010044d2010000da010036da01003bda01006cda010075da010075da010084da010084da01009bda01009fda0100a1da0100afda010000e0010006e0010008e0010018e001001be0010021e0010023e0010024e0010026e001002ae0010030e1010036e10100ece20100efe20100d0e80100d6e8010044e901004ae90100fbf30100fff3010020000e007f000e0000010e00ef010e00"); | ||
| 16551 | + _const_grapheme_spacing_mark_ranges = _S("03090000030900003b0900003b0900003e09000040090000490900004c0900004e0900004f0900008209000083090000bf090000c0090000c7090000c8090000cb090000cc090000030a0000030a00003e0a0000400a0000830a0000830a0000be0a0000c00a0000c90a0000c90a0000cb0a0000cc0a0000020b0000030b0000400b0000400b0000470b0000480b00004b0b00004c0b0000bf0b0000bf0b0000c10b0000c20b0000c60b0000c80b0000ca0b0000cc0b0000010c0000030c0000410c0000440c0000820c0000830c0000be0c0000be0c0000c00c0000c10c0000c30c0000c40c0000c70c0000c80c0000ca0c0000cb0c0000020d0000030d00003f0d0000400d0000460d0000480d00004a0d00004c0d0000820d0000830d0000d00d0000d10d0000d80d0000de0d0000f20d0000f30d0000330e0000330e0000b30e0000b30e00003e0f00003f0f00007f0f00007f0f000031100000311000003b1000003c10000056100000571000008410000084100000b6170000b6170000be170000c5170000c7170000c81700002319000026190000291900002b19000030190000311900003319000038190000191a00001a1a0000551a0000551a0000571a0000571a00006d1a0000721a0000041b0000041b00003b1b00003b1b00003d1b0000411b0000431b0000441b0000821b0000821b0000a11b0000a11b0000a61b0000a71b0000aa1b0000aa1b0000e71b0000e71b0000ea1b0000ec1b0000ee1b0000ee1b0000f21b0000f31b0000241c00002b1c0000341c0000351c0000e11c0000e11c0000f71c0000f71c000023a8000024a8000027a8000027a8000080a8000081a80000b4a80000c3a8000052a9000053a9000083a9000083a90000b4a90000b5a90000baa90000bba90000bea90000c0a900002faa000030aa000033aa000034aa00004daa00004daa0000ebaa0000ebaa0000eeaa0000efaa0000f5aa0000f5aa0000e3ab0000e4ab0000e6ab0000e7ab0000e9ab0000eaab0000ecab0000ecab0000001001000010010002100100021001008210010082100100b0100100b2100100b7100100b81001002c1101002c11010045110100461101008211010082110100b3110100b5110100bf110100c0110100ce110100ce1101002c1201002e12010032120100331201003512010035120100e0120100e212010002130100031301003f1301003f130100411301004413010047130100481301004b1301004d1301006213010063130100351401003714010040140100411401004514010045140100b1140100b2140100b9140100b9140100bb140100bc140100be140100be140100c1140100c1140100b0150100b1150100b8150100bb150100be150100be15010030160100321601003b1601003c1601003e1601003e160100ac160100ac160100ae160100af160100b6160100b6160100201701002117010026170100261701002c1801002e1801003818010038180100311901003519010037190100381901003d1901003d19010040190100401901004219010042190100d1190100d3190100dc190100df190100e4190100e4190100391a0100391a0100571a0100581a0100971a0100971a01002f1c01002f1c01003e1c01003e1c0100a91c0100a91c0100b11c0100b11c0100b41c0100b41c01008a1d01008e1d0100931d0100941d0100961d0100961d0100f51e0100f61e0100516f0100876f0100f06f0100f16f010066d1010066d101006dd101006dd10100"); | ||
| 16552 | + _const_grapheme_prepend_ranges = _S("0006000005060000dd060000dd0600000f0700000f070000e2080000e20800004e0d00004e0d0000bd100100bd100100cd100100cd100100c2110100c31101003f1901003f19010041190100411901003a1a01003a1a0100841a0100891a0100461d0100461d0100"); | ||
| 16553 | + _const_grapheme_extended_pictographic_ranges = _S("a9000000a9000000ae000000ae0000003c2000003c2000004920000049200000222100002221000039210000392100009421000099210000a9210000aa2100001a2300001b23000028230000282300008823000088230000cf230000cf230000e9230000ec230000ed230000ee230000ef230000ef230000f0230000f0230000f1230000f2230000f3230000f3230000f8230000fa230000c2240000c2240000aa250000ab250000b6250000b6250000c0250000c0250000fb250000fe2500000026000001260000022600000326000004260000042600000526000005260000072600000d2600000e2600000e2600000f2600001026000011260000112600001226000012260000142600001526000016260000172600001826000018260000192600001c2600001d2600001d2600001e2600001f2600002026000020260000212600002126000022260000232600002426000025260000262600002626000027260000292600002a2600002a2600002b2600002d2600002e2600002e2600002f2600002f260000302600003726000038260000392600003a2600003a2600003b2600003f26000040260000402600004126000041260000422600004226000043260000472600004826000053260000542600005e2600005f2600005f2600006026000060260000612600006226000063260000632600006426000064260000652600006626000067260000672600006826000068260000692600007a2600007b2600007b2600007c2600007d2600007e2600007e2600007f2600007f2600008026000085260000902600009126000092260000922600009326000093260000942600009426000095260000952600009626000097260000982600009826000099260000992600009a2600009a2600009b2600009c2600009d2600009f260000a0260000a1260000a2260000a6260000a7260000a7260000a8260000a9260000aa260000ab260000ac260000af260000b0260000b1260000b2260000bc260000bd260000be260000bf260000c3260000c4260000c5260000c6260000c7260000c8260000c8260000c9260000cd260000ce260000ce260000cf260000cf260000d0260000d0260000d1260000d1260000d2260000d2260000d3260000d3260000d4260000d4260000d5260000e8260000e9260000e9260000ea260000ea260000eb260000ef260000f0260000f1260000f2260000f3260000f4260000f4260000f5260000f5260000f6260000f6260000f7260000f9260000fa260000fa260000fb260000fc260000fd260000fd260000fe26000001270000022700000227000003270000042700000527000005270000082700000c2700000d2700000d2700000e2700000e2700000f2700000f27000010270000112700001227000012270000142700001427000016270000162700001d2700001d270000212700002127000028270000282700003327000034270000442700004427000047270000472700004c2700004c2700004e2700004e270000532700005527000057270000572700006327000063270000642700006427000065270000672700009527000097270000a1270000a1270000b0270000b0270000bf270000bf2700003429000035290000052b0000072b00001b2b00001c2b0000502b0000502b0000552b0000552b000030300000303000003d3000003d3000009732000097320000993200009932000000f0010003f0010004f0010004f0010005f00100cef00100cff00100cff00100d0f00100fff001000df101000ff101002ff101002ff101006cf101006ff1010070f1010071f101007ef101007ff101008ef101008ef1010091f101009af10100adf10100e5f1010001f2010002f2010003f201000ff201001af201001af201002ff201002ff2010032f201003af201003cf201003ff2010049f201004ff2010050f2010051f2010052f20100fff2010000f301000cf301000df301000ef301000ff301000ff3010010f3010010f3010011f3010011f3010012f3010012f3010013f3010015f3010016f3010018f3010019f3010019f301001af301001af301001bf301001bf301001cf301001cf301001df301001ef301001ff3010020f3010021f3010021f3010022f3010023f3010024f301002cf301002df301002ff3010030f3010031f3010032f3010033f3010034f3010035f3010036f3010036f3010037f301004af301004bf301004bf301004cf301004ff3010050f3010050f3010051f301007bf301007cf301007cf301007df301007df301007ef301007ff3010080f3010093f3010094f3010095f3010096f3010097f3010098f3010098f3010099f301009bf301009cf301009df301009ef301009ff30100a0f30100c4f30100c5f30100c5f30100c6f30100c6f30100c7f30100c7f30100c8f30100c8f30100c9f30100c9f30100caf30100caf30100cbf30100cef30100cff30100d3f30100d4f30100dff30100e0f30100e3f30100e4f30100e4f30100e5f30100f0f30100f1f30100f2f30100f3f30100f3f30100f4f30100f4f30100f5f30100f5f30100f6f30100f6f30100f7f30100f7f30100f8f30100faf3010000f4010007f4010008f4010008f4010009f401000bf401000cf401000ef401000ff4010010f4010011f4010012f4010013f4010013f4010014f4010014f4010015f4010015f4010016f4010016f4010017f4010029f401002af401002af401002bf401003ef401003ff401003ff4010040f4010040f4010041f4010041f4010042f4010064f4010065f4010065f4010066f401006bf401006cf401006df401006ef40100acf40100adf40100adf40100aef40100b5f40100b6f40100b7f40100b8f40100ebf40100ecf40100edf40100eef40100eef40100eff40100eff40100f0f40100f4f40100f5f40100f5f40100f6f40100f7f40100f8f40100f8f40100f9f40100fcf40100fdf40100fdf40100fef40100fef40100fff4010002f5010003f5010003f5010004f5010007f5010008f5010008f5010009f5010009f501000af5010014f5010015f5010015f5010016f501002bf501002cf501002df501002ef501003df5010046f5010048f5010049f501004af501004bf501004ef501004ff501004ff5010050f501005bf501005cf5010067f5010068f501006ef501006ff5010070f5010071f5010072f5010073f5010079f501007af501007af501007bf5010086f5010087f5010087f5010088f5010089f501008af501008df501008ef501008ff5010090f5010090f5010091f5010094f5010095f5010096f5010097f50100a3f50100a4f50100a4f50100a5f50100a5f50100a6f50100a7f50100a8f50100a8f50100a9f50100b0f50100b1f50100b2f50100b3f50100bbf50100bcf50100bcf50100bdf50100c1f50100c2f50100c4f50100c5f50100d0f50100d1f50100d3f50100d4f50100dbf50100dcf50100def50100dff50100e0f50100e1f50100e1f50100e2f50100e2f50100e3f50100e3f50100e4f50100e7f50100e8f50100e8f50100e9f50100eef50100eff50100eff50100f0f50100f2f50100f3f50100f3f50100f4f50100f9f50100faf50100faf50100fbf50100fff5010000f6010000f6010001f6010006f6010007f6010008f6010009f601000df601000ef601000ef601000ff601000ff6010010f6010010f6010011f6010011f6010012f6010014f6010015f6010015f6010016f6010016f6010017f6010017f6010018f6010018f6010019f6010019f601001af601001af601001bf601001bf601001cf601001ef601001ff601001ff6010020f6010025f6010026f6010027f6010028f601002bf601002cf601002cf601002df601002df601002ef601002ff6010030f6010033f6010034f6010034f6010035f6010035f6010036f6010036f6010037f6010040f6010041f6010044f6010045f601004ff6010080f6010080f6010081f6010082f6010083f6010085f6010086f6010086f6010087f6010087f6010088f6010088f6010089f6010089f601008af601008bf601008cf601008cf601008df601008df601008ef601008ef601008ff601008ff6010090f6010090f6010091f6010093f6010094f6010094f6010095f6010095f6010096f6010096f6010097f6010097f6010098f6010098f6010099f601009af601009bf60100a1f60100a2f60100a2f60100a3f60100a3f60100a4f60100a5f60100a6f60100a6f60100a7f60100adf60100aef60100b1f60100b2f60100b2f60100b3f60100b5f60100b6f60100b6f60100b7f60100b8f60100b9f60100bef60100bff60100bff60100c0f60100c0f60100c1f60100c5f60100c6f60100caf60100cbf60100cbf60100ccf60100ccf60100cdf60100cff60100d0f60100d0f60100d1f60100d2f60100d3f60100d4f60100d5f60100d5f60100d6f60100d7f60100d8f60100dff60100e0f60100e5f60100e6f60100e8f60100e9f60100e9f60100eaf60100eaf60100ebf60100ecf60100edf60100eff60100f0f60100f0f60100f1f60100f2f60100f3f60100f3f60100f4f60100f6f60100f7f60100f8f60100f9f60100f9f60100faf60100faf60100fbf60100fcf60100fdf60100fff6010074f701007ff70100d5f70100dff70100e0f70100ebf70100ecf70100fff701000cf801000ff8010048f801004ff801005af801005ff8010088f801008ff80100aef80100fff801000cf901000cf901000df901000ff9010010f9010018f9010019f901001ef901001ff901001ff9010020f9010027f9010028f901002ff9010030f9010030f9010031f9010032f9010033f901003af901003cf901003ef901003ff901003ff9010040f9010045f9010047f901004bf901004cf901004cf901004df901004ff9010050f901005ef901005ff901006bf901006cf9010070f9010071f9010071f9010072f9010072f9010073f9010076f9010077f9010078f9010079f9010079f901007af901007af901007bf901007bf901007cf901007ff9010080f9010084f9010085f9010091f9010092f9010097f9010098f90100a2f90100a3f90100a4f90100a5f90100aaf90100abf90100adf90100aef90100aff90100b0f90100b9f90100baf90100bff90100c0f90100c0f90100c1f90100c2f90100c3f90100caf90100cbf90100cbf90100ccf90100ccf90100cdf90100cff90100d0f90100e6f90100e7f90100fff9010000fa01006ffa010070fa010073fa010074fa010074fa010075fa010077fa010078fa01007afa01007bfa01007ffa010080fa010082fa010083fa010086fa010087fa01008ffa010090fa010095fa010096fa0100a8fa0100a9fa0100affa0100b0fa0100b6fa0100b7fa0100bffa0100c0fa0100c2fa0100c3fa0100cffa0100d0fa0100d6fa0100d7fa0100fffa010000fc0100fdff0100"); | ||
| 16554 | + _const_digit_pairs = _S("00102030405060708090011121314151617181910212223242526272829203132333435363738393041424344454647484940515253545556575859506162636465666768696071727374757677787970818283848586878889809192939495969798999"); | ||
| 16555 | + _const_si_s_code = _S("0xfe10"); | ||
| 16556 | + _const_si_g32_code = _S("0xfe0e"); | ||
| 16557 | + _const_si_g64_code = _S("0xfe0f"); | ||
| 16558 | + g_live_reload_info = *(voidptr*)&((voidptr[]){0}[0]); // global 5 | ||
| 16559 | + _const_error_sentinel = I_MessageError_to_Interface_IError((HEAP(MessageError, ((MessageError){.msg = _S("error"),.code = 0,})))); | ||
| 16560 | + _const_none__ = I_None___to_Interface_IError((HEAP(None__, ((None__){.Error = ((Error){E_STRUCT}),})))); | ||
| 16561 | + _const_min_i64 = ((i64)(-9223372036854775807LL - 1)); | ||
| 16562 | + _const_max_i64 = ((i64)(9223372036854775807LL)); | ||
| 16563 | + _const_utf8_replacement_rune = ((rune)(0xfffd)); | ||
| 16564 | +} | ||
| 16565 | +void _vcleanup(void) { | ||
| 16566 | + static bool once = false; if (once) {return;} once = true; | ||
| 16567 | +} | ||
| 16568 | +__attribute__ ((constructor)) | ||
| 16569 | +void _vinit_caller() { | ||
| 16570 | + static bool once = false; if (once) {return;} once = true; | ||
| 16571 | + _vinit(0,0); | ||
| 16572 | +} | ||
| 16573 | +__attribute__ ((destructor)) | ||
| 16574 | +void _vcleanup_caller() { | ||
| 16575 | + static bool once = false; if (once) {return;} once = true; | ||
| 16576 | + _vcleanup(); | ||
| 16577 | +} | ||
| 16578 | + | ||
| 16579 | +int main(int ___argc, char** ___argv){ | ||
| 16580 | + g_main_argc = ___argc; | ||
| 16581 | + g_main_argv = ___argv; | ||
| 16582 | + _vinit(___argc, (voidptr)___argv); | ||
| 16583 | + main__main(); | ||
| 16584 | + _vcleanup(); | ||
| 16585 | + return 0; | ||
| 16586 | +} | ||
| 16587 | +// THE END. | ||
added
macos/Classes/vflutter.h +30 -0 | new file mode 100644 | ||
| @@ -0,0 +1,30 @@ | ||
| 1 | +// C-ABI surface of the V library. Hand-maintained; ffigen parses this. | |
| 2 | +#ifndef VFLUTTER_H | |
| 3 | +#define VFLUTTER_H | |
| 4 | + | |
| 5 | +#ifdef __cplusplus | |
| 6 | +extern "C" { | |
| 7 | +#endif | |
| 8 | + | |
| 9 | +#if defined(_WIN32) | |
| 10 | + #define VF_API __declspec(dllexport) | |
| 11 | +#else | |
| 12 | + #define VF_API __attribute__((visibility("default"))) | |
| 13 | +#endif | |
| 14 | + | |
| 15 | +// Idempotent. Safe to call from any isolate; required only on platforms | |
| 16 | +// where the ELF/Mach-O constructor may not have run (iOS static archives). | |
| 17 | +VF_API void vf_init(void); | |
| 18 | + | |
| 19 | +VF_API int vf_add(int a, int b); | |
| 20 | + | |
| 21 | +// Returns a NUL-terminated string allocated by V. Caller MUST release it | |
| 22 | +// with vf_free. Never free it with Dart's calloc/malloc. | |
| 23 | +VF_API char *vf_greet(const char *name); | |
| 24 | + | |
| 25 | +VF_API void vf_free(void *p); | |
| 26 | + | |
| 27 | +#ifdef __cplusplus | |
| 28 | +} | |
| 29 | +#endif | |
| 30 | +#endif // VFLUTTER_H | |
| new file mode 100644 | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | +// C-ABI surface of the V library. Hand-maintained; ffigen parses this. | ||
| 2 | +#ifndef VFLUTTER_H | ||
| 3 | +#define VFLUTTER_H | ||
| 4 | + | ||
| 5 | +#ifdef __cplusplus | ||
| 6 | +extern "C" { | ||
| 7 | +#endif | ||
| 8 | + | ||
| 9 | +#if defined(_WIN32) | ||
| 10 | + #define VF_API __declspec(dllexport) | ||
| 11 | +#else | ||
| 12 | + #define VF_API __attribute__((visibility("default"))) | ||
| 13 | +#endif | ||
| 14 | + | ||
| 15 | +// Idempotent. Safe to call from any isolate; required only on platforms | ||
| 16 | +// where the ELF/Mach-O constructor may not have run (iOS static archives). | ||
| 17 | +VF_API void vf_init(void); | ||
| 18 | + | ||
| 19 | +VF_API int vf_add(int a, int b); | ||
| 20 | + | ||
| 21 | +// Returns a NUL-terminated string allocated by V. Caller MUST release it | ||
| 22 | +// with vf_free. Never free it with Dart's calloc/malloc. | ||
| 23 | +VF_API char *vf_greet(const char *name); | ||
| 24 | + | ||
| 25 | +VF_API void vf_free(void *p); | ||
| 26 | + | ||
| 27 | +#ifdef __cplusplus | ||
| 28 | +} | ||
| 29 | +#endif | ||
| 30 | +#endif // VFLUTTER_H | ||
added
macos/vflutter_ffi.podspec +24 -0 | new file mode 100644 | ||
| @@ -0,0 +1,24 @@ | ||
| 1 | +Pod::Spec.new do |s| | |
| 2 | + s.name = 'vflutter_ffi' | |
| 3 | + s.version = '0.1.0' | |
| 4 | + s.summary = 'V language runtime bridged to Flutter via dart:ffi.' | |
| 5 | + s.homepage = 'https://example.com' | |
| 6 | + s.license = { :file => '../LICENSE' } | |
| 7 | + s.author = { 'you' => 'you@example.com' } | |
| 8 | + s.source = { :path => '.' } | |
| 9 | + s.source_files = 'Classes/**/*' | |
| 10 | + s.dependency 'Flutter' | |
| 11 | + s.platform = :osx, "10.14" | |
| 12 | + | |
| 13 | + # V's generated C is machine output. | |
| 14 | + s.compiler_flags = '-w' | |
| 15 | + | |
| 16 | + # The V runtime initialises through __attribute__((constructor)). In a static | |
| 17 | + # archive the linker drops objects nothing references, which would silently | |
| 18 | + # skip that. -all_load keeps them, and vf_init() is the belt-and-braces path. | |
| 19 | + s.pod_target_xcconfig = { | |
| 20 | + 'DEFINES_MODULE' => 'YES', | |
| 21 | + 'OTHER_LDFLAGS' => '-all_load', | |
| 22 | + | |
| 23 | + } | |
| 24 | +end | |
| new file mode 100644 | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | +Pod::Spec.new do |s| | ||
| 2 | + s.name = 'vflutter_ffi' | ||
| 3 | + s.version = '0.1.0' | ||
| 4 | + s.summary = 'V language runtime bridged to Flutter via dart:ffi.' | ||
| 5 | + s.homepage = 'https://example.com' | ||
| 6 | + s.license = { :file => '../LICENSE' } | ||
| 7 | + s.author = { 'you' => 'you@example.com' } | ||
| 8 | + s.source = { :path => '.' } | ||
| 9 | + s.source_files = 'Classes/**/*' | ||
| 10 | + s.dependency 'Flutter' | ||
| 11 | + s.platform = :osx, "10.14" | ||
| 12 | + | ||
| 13 | + # V's generated C is machine output. | ||
| 14 | + s.compiler_flags = '-w' | ||
| 15 | + | ||
| 16 | + # The V runtime initialises through __attribute__((constructor)). In a static | ||
| 17 | + # archive the linker drops objects nothing references, which would silently | ||
| 18 | + # skip that. -all_load keeps them, and vf_init() is the belt-and-braces path. | ||
| 19 | + s.pod_target_xcconfig = { | ||
| 20 | + 'DEFINES_MODULE' => 'YES', | ||
| 21 | + 'OTHER_LDFLAGS' => '-all_load', | ||
| 22 | + | ||
| 23 | + } | ||
| 24 | +end | ||
added
pubspec.lock +189 -0 | new file mode 100644 | ||
| @@ -0,0 +1,189 @@ | ||
| 1 | +# Generated by pub | |
| 2 | +# See https://dart.dev/tools/pub/glossary#lockfile | |
| 3 | +packages: | |
| 4 | + args: | |
| 5 | + dependency: transitive | |
| 6 | + description: | |
| 7 | + name: args | |
| 8 | + sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04 | |
| 9 | + url: "https://pub.dev" | |
| 10 | + source: hosted | |
| 11 | + version: "2.7.0" | |
| 12 | + async: | |
| 13 | + dependency: transitive | |
| 14 | + description: | |
| 15 | + name: async | |
| 16 | + sha256: e2eb0491ba5ddb6177742d2da23904574082139b07c1e33b8503b9f46f3e1a37 | |
| 17 | + url: "https://pub.dev" | |
| 18 | + source: hosted | |
| 19 | + version: "2.13.1" | |
| 20 | + boolean_selector: | |
| 21 | + dependency: transitive | |
| 22 | + description: | |
| 23 | + name: boolean_selector | |
| 24 | + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" | |
| 25 | + url: "https://pub.dev" | |
| 26 | + source: hosted | |
| 27 | + version: "2.1.2" | |
| 28 | + cli_util: | |
| 29 | + dependency: transitive | |
| 30 | + description: | |
| 31 | + name: cli_util | |
| 32 | + sha256: ff6785f7e9e3c38ac98b2fb035701789de90154024a75b6cb926445e83197d1c | |
| 33 | + url: "https://pub.dev" | |
| 34 | + source: hosted | |
| 35 | + version: "0.4.2" | |
| 36 | + collection: | |
| 37 | + dependency: transitive | |
| 38 | + description: | |
| 39 | + name: collection | |
| 40 | + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" | |
| 41 | + url: "https://pub.dev" | |
| 42 | + source: hosted | |
| 43 | + version: "1.19.1" | |
| 44 | + ffi: | |
| 45 | + dependency: "direct main" | |
| 46 | + description: | |
| 47 | + name: ffi | |
| 48 | + sha256: "6d7fd89431262d8f3125e81b50d3847a091d846eafcd4fdb88dd06f36d705a45" | |
| 49 | + url: "https://pub.dev" | |
| 50 | + source: hosted | |
| 51 | + version: "2.2.0" | |
| 52 | + ffigen: | |
| 53 | + dependency: "direct dev" | |
| 54 | + description: | |
| 55 | + name: ffigen | |
| 56 | + sha256: "10cb41647d73e0204f8d35138a3f20eb52418cce96599ad49167b1111e59a557" | |
| 57 | + url: "https://pub.dev" | |
| 58 | + source: hosted | |
| 59 | + version: "13.0.0" | |
| 60 | + file: | |
| 61 | + dependency: transitive | |
| 62 | + description: | |
| 63 | + name: file | |
| 64 | + sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4 | |
| 65 | + url: "https://pub.dev" | |
| 66 | + source: hosted | |
| 67 | + version: "7.0.1" | |
| 68 | + glob: | |
| 69 | + dependency: transitive | |
| 70 | + description: | |
| 71 | + name: glob | |
| 72 | + sha256: "218aeb56050c714f62a3182775320dfa04602b55074873e24e31bbd39bda96fb" | |
| 73 | + url: "https://pub.dev" | |
| 74 | + source: hosted | |
| 75 | + version: "2.2.0" | |
| 76 | + logging: | |
| 77 | + dependency: transitive | |
| 78 | + description: | |
| 79 | + name: logging | |
| 80 | + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 | |
| 81 | + url: "https://pub.dev" | |
| 82 | + source: hosted | |
| 83 | + version: "1.3.0" | |
| 84 | + matcher: | |
| 85 | + dependency: transitive | |
| 86 | + description: | |
| 87 | + name: matcher | |
| 88 | + sha256: "31bd099b47c10cd1aeb55146a2d46ce0277630ecef3f7dae54ad7873f36696cd" | |
| 89 | + url: "https://pub.dev" | |
| 90 | + source: hosted | |
| 91 | + version: "0.12.20" | |
| 92 | + meta: | |
| 93 | + dependency: transitive | |
| 94 | + description: | |
| 95 | + name: meta | |
| 96 | + sha256: "307249ce4ff29d58a18e97f6345f539382eb9c9c29ecda628900f31de0443dd9" | |
| 97 | + url: "https://pub.dev" | |
| 98 | + source: hosted | |
| 99 | + version: "1.19.0" | |
| 100 | + package_config: | |
| 101 | + dependency: transitive | |
| 102 | + description: | |
| 103 | + name: package_config | |
| 104 | + sha256: f096c55ebb7deb7e384101542bfba8c52696c1b56fca2eb62827989ef2353bbc | |
| 105 | + url: "https://pub.dev" | |
| 106 | + source: hosted | |
| 107 | + version: "2.2.0" | |
| 108 | + path: | |
| 109 | + dependency: transitive | |
| 110 | + description: | |
| 111 | + name: path | |
| 112 | + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" | |
| 113 | + url: "https://pub.dev" | |
| 114 | + source: hosted | |
| 115 | + version: "1.9.1" | |
| 116 | + quiver: | |
| 117 | + dependency: transitive | |
| 118 | + description: | |
| 119 | + name: quiver | |
| 120 | + sha256: ea0b925899e64ecdfbf9c7becb60d5b50e706ade44a85b2363be2a22d88117d2 | |
| 121 | + url: "https://pub.dev" | |
| 122 | + source: hosted | |
| 123 | + version: "3.2.2" | |
| 124 | + source_span: | |
| 125 | + dependency: transitive | |
| 126 | + description: | |
| 127 | + name: source_span | |
| 128 | + sha256: "56a02f1f4cd1a2d96303c0144c93bd6d909eea6bee6bf5a0e0b685edbd4c47ab" | |
| 129 | + url: "https://pub.dev" | |
| 130 | + source: hosted | |
| 131 | + version: "1.10.2" | |
| 132 | + stack_trace: | |
| 133 | + dependency: transitive | |
| 134 | + description: | |
| 135 | + name: stack_trace | |
| 136 | + sha256: "277654b3034d17ac6f9f1cb5595db011b1d5d41e8806866db28e0abaa101c490" | |
| 137 | + url: "https://pub.dev" | |
| 138 | + source: hosted | |
| 139 | + version: "1.12.2" | |
| 140 | + stream_channel: | |
| 141 | + dependency: transitive | |
| 142 | + description: | |
| 143 | + name: stream_channel | |
| 144 | + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" | |
| 145 | + url: "https://pub.dev" | |
| 146 | + source: hosted | |
| 147 | + version: "2.1.4" | |
| 148 | + string_scanner: | |
| 149 | + dependency: transitive | |
| 150 | + description: | |
| 151 | + name: string_scanner | |
| 152 | + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" | |
| 153 | + url: "https://pub.dev" | |
| 154 | + source: hosted | |
| 155 | + version: "1.4.1" | |
| 156 | + term_glyph: | |
| 157 | + dependency: transitive | |
| 158 | + description: | |
| 159 | + name: term_glyph | |
| 160 | + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" | |
| 161 | + url: "https://pub.dev" | |
| 162 | + source: hosted | |
| 163 | + version: "1.2.2" | |
| 164 | + test_api: | |
| 165 | + dependency: transitive | |
| 166 | + description: | |
| 167 | + name: test_api | |
| 168 | + sha256: "0a10344e901e5b2e63819567951cb6a06673ed6b84f40462188ff5a0c41f371f" | |
| 169 | + url: "https://pub.dev" | |
| 170 | + source: hosted | |
| 171 | + version: "0.7.14" | |
| 172 | + yaml: | |
| 173 | + dependency: transitive | |
| 174 | + description: | |
| 175 | + name: yaml | |
| 176 | + sha256: f67cdd8e07d3c6329146aaef1ba043542b3134c12489f553ca9a7435d1068aea | |
| 177 | + url: "https://pub.dev" | |
| 178 | + source: hosted | |
| 179 | + version: "3.1.4" | |
| 180 | + yaml_edit: | |
| 181 | + dependency: transitive | |
| 182 | + description: | |
| 183 | + name: yaml_edit | |
| 184 | + sha256: "07c9e63ba42519745182b88ca12264a7ba2484d8239958778dfe4d44fe760488" | |
| 185 | + url: "https://pub.dev" | |
| 186 | + source: hosted | |
| 187 | + version: "2.2.4" | |
| 188 | +sdks: | |
| 189 | + dart: ">=3.11.0 <4.0.0" | |
| new file mode 100644 | |||
| @@ -0,0 +1,189 @@ | |||
| 1 | +# Generated by pub | ||
| 2 | +# See https://dart.dev/tools/pub/glossary#lockfile | ||
| 3 | +packages: | ||
| 4 | + args: | ||
| 5 | + dependency: transitive | ||
| 6 | + description: | ||
| 7 | + name: args | ||
| 8 | + sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04 | ||
| 9 | + url: "https://pub.dev" | ||
| 10 | + source: hosted | ||
| 11 | + version: "2.7.0" | ||
| 12 | + async: | ||
| 13 | + dependency: transitive | ||
| 14 | + description: | ||
| 15 | + name: async | ||
| 16 | + sha256: e2eb0491ba5ddb6177742d2da23904574082139b07c1e33b8503b9f46f3e1a37 | ||
| 17 | + url: "https://pub.dev" | ||
| 18 | + source: hosted | ||
| 19 | + version: "2.13.1" | ||
| 20 | + boolean_selector: | ||
| 21 | + dependency: transitive | ||
| 22 | + description: | ||
| 23 | + name: boolean_selector | ||
| 24 | + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" | ||
| 25 | + url: "https://pub.dev" | ||
| 26 | + source: hosted | ||
| 27 | + version: "2.1.2" | ||
| 28 | + cli_util: | ||
| 29 | + dependency: transitive | ||
| 30 | + description: | ||
| 31 | + name: cli_util | ||
| 32 | + sha256: ff6785f7e9e3c38ac98b2fb035701789de90154024a75b6cb926445e83197d1c | ||
| 33 | + url: "https://pub.dev" | ||
| 34 | + source: hosted | ||
| 35 | + version: "0.4.2" | ||
| 36 | + collection: | ||
| 37 | + dependency: transitive | ||
| 38 | + description: | ||
| 39 | + name: collection | ||
| 40 | + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" | ||
| 41 | + url: "https://pub.dev" | ||
| 42 | + source: hosted | ||
| 43 | + version: "1.19.1" | ||
| 44 | + ffi: | ||
| 45 | + dependency: "direct main" | ||
| 46 | + description: | ||
| 47 | + name: ffi | ||
| 48 | + sha256: "6d7fd89431262d8f3125e81b50d3847a091d846eafcd4fdb88dd06f36d705a45" | ||
| 49 | + url: "https://pub.dev" | ||
| 50 | + source: hosted | ||
| 51 | + version: "2.2.0" | ||
| 52 | + ffigen: | ||
| 53 | + dependency: "direct dev" | ||
| 54 | + description: | ||
| 55 | + name: ffigen | ||
| 56 | + sha256: "10cb41647d73e0204f8d35138a3f20eb52418cce96599ad49167b1111e59a557" | ||
| 57 | + url: "https://pub.dev" | ||
| 58 | + source: hosted | ||
| 59 | + version: "13.0.0" | ||
| 60 | + file: | ||
| 61 | + dependency: transitive | ||
| 62 | + description: | ||
| 63 | + name: file | ||
| 64 | + sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4 | ||
| 65 | + url: "https://pub.dev" | ||
| 66 | + source: hosted | ||
| 67 | + version: "7.0.1" | ||
| 68 | + glob: | ||
| 69 | + dependency: transitive | ||
| 70 | + description: | ||
| 71 | + name: glob | ||
| 72 | + sha256: "218aeb56050c714f62a3182775320dfa04602b55074873e24e31bbd39bda96fb" | ||
| 73 | + url: "https://pub.dev" | ||
| 74 | + source: hosted | ||
| 75 | + version: "2.2.0" | ||
| 76 | + logging: | ||
| 77 | + dependency: transitive | ||
| 78 | + description: | ||
| 79 | + name: logging | ||
| 80 | + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 | ||
| 81 | + url: "https://pub.dev" | ||
| 82 | + source: hosted | ||
| 83 | + version: "1.3.0" | ||
| 84 | + matcher: | ||
| 85 | + dependency: transitive | ||
| 86 | + description: | ||
| 87 | + name: matcher | ||
| 88 | + sha256: "31bd099b47c10cd1aeb55146a2d46ce0277630ecef3f7dae54ad7873f36696cd" | ||
| 89 | + url: "https://pub.dev" | ||
| 90 | + source: hosted | ||
| 91 | + version: "0.12.20" | ||
| 92 | + meta: | ||
| 93 | + dependency: transitive | ||
| 94 | + description: | ||
| 95 | + name: meta | ||
| 96 | + sha256: "307249ce4ff29d58a18e97f6345f539382eb9c9c29ecda628900f31de0443dd9" | ||
| 97 | + url: "https://pub.dev" | ||
| 98 | + source: hosted | ||
| 99 | + version: "1.19.0" | ||
| 100 | + package_config: | ||
| 101 | + dependency: transitive | ||
| 102 | + description: | ||
| 103 | + name: package_config | ||
| 104 | + sha256: f096c55ebb7deb7e384101542bfba8c52696c1b56fca2eb62827989ef2353bbc | ||
| 105 | + url: "https://pub.dev" | ||
| 106 | + source: hosted | ||
| 107 | + version: "2.2.0" | ||
| 108 | + path: | ||
| 109 | + dependency: transitive | ||
| 110 | + description: | ||
| 111 | + name: path | ||
| 112 | + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" | ||
| 113 | + url: "https://pub.dev" | ||
| 114 | + source: hosted | ||
| 115 | + version: "1.9.1" | ||
| 116 | + quiver: | ||
| 117 | + dependency: transitive | ||
| 118 | + description: | ||
| 119 | + name: quiver | ||
| 120 | + sha256: ea0b925899e64ecdfbf9c7becb60d5b50e706ade44a85b2363be2a22d88117d2 | ||
| 121 | + url: "https://pub.dev" | ||
| 122 | + source: hosted | ||
| 123 | + version: "3.2.2" | ||
| 124 | + source_span: | ||
| 125 | + dependency: transitive | ||
| 126 | + description: | ||
| 127 | + name: source_span | ||
| 128 | + sha256: "56a02f1f4cd1a2d96303c0144c93bd6d909eea6bee6bf5a0e0b685edbd4c47ab" | ||
| 129 | + url: "https://pub.dev" | ||
| 130 | + source: hosted | ||
| 131 | + version: "1.10.2" | ||
| 132 | + stack_trace: | ||
| 133 | + dependency: transitive | ||
| 134 | + description: | ||
| 135 | + name: stack_trace | ||
| 136 | + sha256: "277654b3034d17ac6f9f1cb5595db011b1d5d41e8806866db28e0abaa101c490" | ||
| 137 | + url: "https://pub.dev" | ||
| 138 | + source: hosted | ||
| 139 | + version: "1.12.2" | ||
| 140 | + stream_channel: | ||
| 141 | + dependency: transitive | ||
| 142 | + description: | ||
| 143 | + name: stream_channel | ||
| 144 | + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" | ||
| 145 | + url: "https://pub.dev" | ||
| 146 | + source: hosted | ||
| 147 | + version: "2.1.4" | ||
| 148 | + string_scanner: | ||
| 149 | + dependency: transitive | ||
| 150 | + description: | ||
| 151 | + name: string_scanner | ||
| 152 | + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" | ||
| 153 | + url: "https://pub.dev" | ||
| 154 | + source: hosted | ||
| 155 | + version: "1.4.1" | ||
| 156 | + term_glyph: | ||
| 157 | + dependency: transitive | ||
| 158 | + description: | ||
| 159 | + name: term_glyph | ||
| 160 | + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" | ||
| 161 | + url: "https://pub.dev" | ||
| 162 | + source: hosted | ||
| 163 | + version: "1.2.2" | ||
| 164 | + test_api: | ||
| 165 | + dependency: transitive | ||
| 166 | + description: | ||
| 167 | + name: test_api | ||
| 168 | + sha256: "0a10344e901e5b2e63819567951cb6a06673ed6b84f40462188ff5a0c41f371f" | ||
| 169 | + url: "https://pub.dev" | ||
| 170 | + source: hosted | ||
| 171 | + version: "0.7.14" | ||
| 172 | + yaml: | ||
| 173 | + dependency: transitive | ||
| 174 | + description: | ||
| 175 | + name: yaml | ||
| 176 | + sha256: f67cdd8e07d3c6329146aaef1ba043542b3134c12489f553ca9a7435d1068aea | ||
| 177 | + url: "https://pub.dev" | ||
| 178 | + source: hosted | ||
| 179 | + version: "3.1.4" | ||
| 180 | + yaml_edit: | ||
| 181 | + dependency: transitive | ||
| 182 | + description: | ||
| 183 | + name: yaml_edit | ||
| 184 | + sha256: "07c9e63ba42519745182b88ca12264a7ba2484d8239958778dfe4d44fe760488" | ||
| 185 | + url: "https://pub.dev" | ||
| 186 | + source: hosted | ||
| 187 | + version: "2.2.4" | ||
| 188 | +sdks: | ||
| 189 | + dart: ">=3.11.0 <4.0.0" | ||
added
pubspec.yaml +27 -0 | new file mode 100644 | ||
| @@ -0,0 +1,27 @@ | ||
| 1 | +name: vflutter_ffi | |
| 2 | +description: Write application logic in V and call it from Flutter over dart:ffi. | |
| 3 | +version: 0.1.0 | |
| 4 | +environment: | |
| 5 | + sdk: '>=3.3.0 <4.0.0' | |
| 6 | + | |
| 7 | +dependencies: | |
| 8 | + ffi: ^2.1.0 | |
| 9 | + | |
| 10 | +dev_dependencies: | |
| 11 | + ffigen: ^13.0.0 | |
| 12 | + | |
| 13 | +# Marks this as an FFI plugin: no platform channels, no Dart-side registration, | |
| 14 | +# the native build is wired per platform below. | |
| 15 | +flutter: | |
| 16 | + plugin: | |
| 17 | + platforms: | |
| 18 | + android: | |
| 19 | + ffiPlugin: true | |
| 20 | + ios: | |
| 21 | + ffiPlugin: true | |
| 22 | + linux: | |
| 23 | + ffiPlugin: true | |
| 24 | + macos: | |
| 25 | + ffiPlugin: true | |
| 26 | + windows: | |
| 27 | + ffiPlugin: true | |
| new file mode 100644 | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | +name: vflutter_ffi | ||
| 2 | +description: Write application logic in V and call it from Flutter over dart:ffi. | ||
| 3 | +version: 0.1.0 | ||
| 4 | +environment: | ||
| 5 | + sdk: '>=3.3.0 <4.0.0' | ||
| 6 | + | ||
| 7 | +dependencies: | ||
| 8 | + ffi: ^2.1.0 | ||
| 9 | + | ||
| 10 | +dev_dependencies: | ||
| 11 | + ffigen: ^13.0.0 | ||
| 12 | + | ||
| 13 | +# Marks this as an FFI plugin: no platform channels, no Dart-side registration, | ||
| 14 | +# the native build is wired per platform below. | ||
| 15 | +flutter: | ||
| 16 | + plugin: | ||
| 17 | + platforms: | ||
| 18 | + android: | ||
| 19 | + ffiPlugin: true | ||
| 20 | + ios: | ||
| 21 | + ffiPlugin: true | ||
| 22 | + linux: | ||
| 23 | + ffiPlugin: true | ||
| 24 | + macos: | ||
| 25 | + ffiPlugin: true | ||
| 26 | + windows: | ||
| 27 | + ffiPlugin: true | ||
added
src/CMakeLists.txt +41 -0 | new file mode 100644 | ||
| @@ -0,0 +1,41 @@ | ||
| 1 | +# Shared CMake logic for every platform that builds the V library from source. | |
| 2 | +# Included by android/, linux/ and windows/. | |
| 3 | +cmake_minimum_required(VERSION 3.15) | |
| 4 | +project(vflutter LANGUAGES C) | |
| 5 | + | |
| 6 | +find_program(V_EXECUTABLE v REQUIRED | |
| 7 | + DOC "The V compiler. Set -DV_EXECUTABLE=/path/to/v to override.") | |
| 8 | + | |
| 9 | +set(VF_SRC "${CMAKE_CURRENT_LIST_DIR}/vflutter.v") | |
| 10 | + | |
| 11 | +# V cross-compiles by emitting C, so the reliable pattern is: | |
| 12 | +# V source -> C (V's job) C -> object/library (the platform's toolchain) | |
| 13 | +# This keeps the NDK / MSVC / clang in charge of ABI, sysroot and flags. | |
| 14 | +set(VF_GENERATED_C "${CMAKE_CURRENT_BINARY_DIR}/vflutter.gen.c") | |
| 15 | + | |
| 16 | +add_custom_command( | |
| 17 | + OUTPUT "${VF_GENERATED_C}" | |
| 18 | + COMMAND "${V_EXECUTABLE}" -shared -gc none -no-parallel -o "${VF_GENERATED_C}" "${VF_SRC}" | |
| 19 | + DEPENDS "${VF_SRC}" | |
| 20 | + COMMENT "v -shared -> C (${CMAKE_SYSTEM_NAME}/${CMAKE_SYSTEM_PROCESSOR})" | |
| 21 | + VERBATIM) | |
| 22 | + | |
| 23 | +add_library(vflutter SHARED "${VF_GENERATED_C}") | |
| 24 | + | |
| 25 | +target_include_directories(vflutter PUBLIC "${CMAKE_CURRENT_LIST_DIR}") | |
| 26 | + | |
| 27 | +# V's generated C is machine output: silence the noise, keep real errors. | |
| 28 | +if(NOT MSVC) | |
| 29 | + target_compile_options(vflutter PRIVATE | |
| 30 | + -w -fPIC -Wno-int-conversion -Wno-incompatible-pointer-types) | |
| 31 | +endif() | |
| 32 | + | |
| 33 | +# Boehm GC ships with V and is linked statically by the V toolchain on desktop; | |
| 34 | +# on Android it must come from the NDK-built copy. See tool/build_gc.sh. | |
| 35 | +if(ANDROID) | |
| 36 | + target_link_libraries(vflutter PRIVATE log) | |
| 37 | +endif() | |
| 38 | + | |
| 39 | +set_target_properties(vflutter PROPERTIES | |
| 40 | + OUTPUT_NAME "vflutter" | |
| 41 | + C_VISIBILITY_PRESET hidden) | |
| new file mode 100644 | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | +# Shared CMake logic for every platform that builds the V library from source. | ||
| 2 | +# Included by android/, linux/ and windows/. | ||
| 3 | +cmake_minimum_required(VERSION 3.15) | ||
| 4 | +project(vflutter LANGUAGES C) | ||
| 5 | + | ||
| 6 | +find_program(V_EXECUTABLE v REQUIRED | ||
| 7 | + DOC "The V compiler. Set -DV_EXECUTABLE=/path/to/v to override.") | ||
| 8 | + | ||
| 9 | +set(VF_SRC "${CMAKE_CURRENT_LIST_DIR}/vflutter.v") | ||
| 10 | + | ||
| 11 | +# V cross-compiles by emitting C, so the reliable pattern is: | ||
| 12 | +# V source -> C (V's job) C -> object/library (the platform's toolchain) | ||
| 13 | +# This keeps the NDK / MSVC / clang in charge of ABI, sysroot and flags. | ||
| 14 | +set(VF_GENERATED_C "${CMAKE_CURRENT_BINARY_DIR}/vflutter.gen.c") | ||
| 15 | + | ||
| 16 | +add_custom_command( | ||
| 17 | + OUTPUT "${VF_GENERATED_C}" | ||
| 18 | + COMMAND "${V_EXECUTABLE}" -shared -gc none -no-parallel -o "${VF_GENERATED_C}" "${VF_SRC}" | ||
| 19 | + DEPENDS "${VF_SRC}" | ||
| 20 | + COMMENT "v -shared -> C (${CMAKE_SYSTEM_NAME}/${CMAKE_SYSTEM_PROCESSOR})" | ||
| 21 | + VERBATIM) | ||
| 22 | + | ||
| 23 | +add_library(vflutter SHARED "${VF_GENERATED_C}") | ||
| 24 | + | ||
| 25 | +target_include_directories(vflutter PUBLIC "${CMAKE_CURRENT_LIST_DIR}") | ||
| 26 | + | ||
| 27 | +# V's generated C is machine output: silence the noise, keep real errors. | ||
| 28 | +if(NOT MSVC) | ||
| 29 | + target_compile_options(vflutter PRIVATE | ||
| 30 | + -w -fPIC -Wno-int-conversion -Wno-incompatible-pointer-types) | ||
| 31 | +endif() | ||
| 32 | + | ||
| 33 | +# Boehm GC ships with V and is linked statically by the V toolchain on desktop; | ||
| 34 | +# on Android it must come from the NDK-built copy. See tool/build_gc.sh. | ||
| 35 | +if(ANDROID) | ||
| 36 | + target_link_libraries(vflutter PRIVATE log) | ||
| 37 | +endif() | ||
| 38 | + | ||
| 39 | +set_target_properties(vflutter PROPERTIES | ||
| 40 | + OUTPUT_NAME "vflutter" | ||
| 41 | + C_VISIBILITY_PRESET hidden) | ||
added
src/vflutter.h +30 -0 | new file mode 100644 | ||
| @@ -0,0 +1,30 @@ | ||
| 1 | +// C-ABI surface of the V library. Hand-maintained; ffigen parses this. | |
| 2 | +#ifndef VFLUTTER_H | |
| 3 | +#define VFLUTTER_H | |
| 4 | + | |
| 5 | +#ifdef __cplusplus | |
| 6 | +extern "C" { | |
| 7 | +#endif | |
| 8 | + | |
| 9 | +#if defined(_WIN32) | |
| 10 | + #define VF_API __declspec(dllexport) | |
| 11 | +#else | |
| 12 | + #define VF_API __attribute__((visibility("default"))) | |
| 13 | +#endif | |
| 14 | + | |
| 15 | +// Idempotent. Safe to call from any isolate; required only on platforms | |
| 16 | +// where the ELF/Mach-O constructor may not have run (iOS static archives). | |
| 17 | +VF_API void vf_init(void); | |
| 18 | + | |
| 19 | +VF_API int vf_add(int a, int b); | |
| 20 | + | |
| 21 | +// Returns a NUL-terminated string allocated by V. Caller MUST release it | |
| 22 | +// with vf_free. Never free it with Dart's calloc/malloc. | |
| 23 | +VF_API char *vf_greet(const char *name); | |
| 24 | + | |
| 25 | +VF_API void vf_free(void *p); | |
| 26 | + | |
| 27 | +#ifdef __cplusplus | |
| 28 | +} | |
| 29 | +#endif | |
| 30 | +#endif // VFLUTTER_H | |
| new file mode 100644 | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | +// C-ABI surface of the V library. Hand-maintained; ffigen parses this. | ||
| 2 | +#ifndef VFLUTTER_H | ||
| 3 | +#define VFLUTTER_H | ||
| 4 | + | ||
| 5 | +#ifdef __cplusplus | ||
| 6 | +extern "C" { | ||
| 7 | +#endif | ||
| 8 | + | ||
| 9 | +#if defined(_WIN32) | ||
| 10 | + #define VF_API __declspec(dllexport) | ||
| 11 | +#else | ||
| 12 | + #define VF_API __attribute__((visibility("default"))) | ||
| 13 | +#endif | ||
| 14 | + | ||
| 15 | +// Idempotent. Safe to call from any isolate; required only on platforms | ||
| 16 | +// where the ELF/Mach-O constructor may not have run (iOS static archives). | ||
| 17 | +VF_API void vf_init(void); | ||
| 18 | + | ||
| 19 | +VF_API int vf_add(int a, int b); | ||
| 20 | + | ||
| 21 | +// Returns a NUL-terminated string allocated by V. Caller MUST release it | ||
| 22 | +// with vf_free. Never free it with Dart's calloc/malloc. | ||
| 23 | +VF_API char *vf_greet(const char *name); | ||
| 24 | + | ||
| 25 | +VF_API void vf_free(void *p); | ||
| 26 | + | ||
| 27 | +#ifdef __cplusplus | ||
| 28 | +} | ||
| 29 | +#endif | ||
| 30 | +#endif // VFLUTTER_H | ||
added
src/vflutter.v +43 -0 | new file mode 100644 | ||
| @@ -0,0 +1,43 @@ | ||
| 1 | +module main | |
| 2 | + | |
| 3 | +// --------------------------------------------------------------------------- | |
| 4 | +// C-ABI surface consumed by Dart FFI. | |
| 5 | +// | |
| 6 | +// Rules for everything below: | |
| 7 | +// * only C-compatible types cross the boundary (int, f64, &char, voidptr) | |
| 8 | +// * V strings/arrays/options/sumtypes never cross; convert first | |
| 9 | +// * anything V allocates and hands out is released by vf_free | |
| 10 | +// --------------------------------------------------------------------------- | |
| 11 | + | |
| 12 | +// Touches the V runtime so the GC and global initialisers are demonstrably | |
| 13 | +// live. The ELF/Mach-O constructor emitted by `v -shared` already does this; | |
| 14 | +// this exists for static-archive builds (iOS) where the caller wants a | |
| 15 | +// guaranteed, idempotent entry point. | |
| 16 | +@[export: 'vf_init'] | |
| 17 | +fn vf_init() { | |
| 18 | + probe := 'vf' | |
| 19 | + _ = probe.len | |
| 20 | +} | |
| 21 | + | |
| 22 | +@[export: 'vf_add'] | |
| 23 | +fn vf_add(a int, b int) int { | |
| 24 | + return a + b | |
| 25 | +} | |
| 26 | + | |
| 27 | +// Returns a V-allocated C string. Caller releases it with vf_free. | |
| 28 | +// | |
| 29 | +// Built with `-gc none`, so every intermediate V allocation here must be | |
| 30 | +// freed by hand. Only the returned buffer outlives the call. | |
| 31 | +@[export: 'vf_greet'] | |
| 32 | +fn vf_greet(name &char) &char { | |
| 33 | + n := unsafe { cstring_to_vstring(name) } | |
| 34 | + res := 'Hello, ${n}, from V!' | |
| 35 | + out := unsafe { res.str } | |
| 36 | + unsafe { n.free() } | |
| 37 | + return out | |
| 38 | +} | |
| 39 | + | |
| 40 | +@[export: 'vf_free'] | |
| 41 | +fn vf_free(p voidptr) { | |
| 42 | + unsafe { free(p) } | |
| 43 | +} | |
| new file mode 100644 | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | +module main | ||
| 2 | + | ||
| 3 | +// --------------------------------------------------------------------------- | ||
| 4 | +// C-ABI surface consumed by Dart FFI. | ||
| 5 | +// | ||
| 6 | +// Rules for everything below: | ||
| 7 | +// * only C-compatible types cross the boundary (int, f64, &char, voidptr) | ||
| 8 | +// * V strings/arrays/options/sumtypes never cross; convert first | ||
| 9 | +// * anything V allocates and hands out is released by vf_free | ||
| 10 | +// --------------------------------------------------------------------------- | ||
| 11 | + | ||
| 12 | +// Touches the V runtime so the GC and global initialisers are demonstrably | ||
| 13 | +// live. The ELF/Mach-O constructor emitted by `v -shared` already does this; | ||
| 14 | +// this exists for static-archive builds (iOS) where the caller wants a | ||
| 15 | +// guaranteed, idempotent entry point. | ||
| 16 | +@[export: 'vf_init'] | ||
| 17 | +fn vf_init() { | ||
| 18 | + probe := 'vf' | ||
| 19 | + _ = probe.len | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +@[export: 'vf_add'] | ||
| 23 | +fn vf_add(a int, b int) int { | ||
| 24 | + return a + b | ||
| 25 | +} | ||
| 26 | + | ||
| 27 | +// Returns a V-allocated C string. Caller releases it with vf_free. | ||
| 28 | +// | ||
| 29 | +// Built with `-gc none`, so every intermediate V allocation here must be | ||
| 30 | +// freed by hand. Only the returned buffer outlives the call. | ||
| 31 | +@[export: 'vf_greet'] | ||
| 32 | +fn vf_greet(name &char) &char { | ||
| 33 | + n := unsafe { cstring_to_vstring(name) } | ||
| 34 | + res := 'Hello, ${n}, from V!' | ||
| 35 | + out := unsafe { res.str } | ||
| 36 | + unsafe { n.free() } | ||
| 37 | + return out | ||
| 38 | +} | ||
| 39 | + | ||
| 40 | +@[export: 'vf_free'] | ||
| 41 | +fn vf_free(p voidptr) { | ||
| 42 | + unsafe { free(p) } | ||
| 43 | +} | ||
added
tool/build.sh +9 -0 | new file mode 100755 | ||
| @@ -0,0 +1,9 @@ | ||
| 1 | +#!/usr/bin/env bash | |
| 2 | +# Host build + smoke test. CI entry point; not used by Flutter itself. | |
| 3 | +set -euo pipefail | |
| 4 | +cd "$(dirname "$0")/.." | |
| 5 | +command -v v >/dev/null || { echo "V compiler not on PATH"; exit 1; } | |
| 6 | +mkdir -p build | |
| 7 | +v -shared -o build/libvflutter.so src/vflutter.v | |
| 8 | +echo "built: $(ls -la build/libvflutter.so | awk '{print $5}') bytes" | |
| 9 | +nm -D --defined-only build/libvflutter.so | grep ' vf_' || { echo "no vf_ exports!"; exit 1; } | |
| new file mode 100755 | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | +#!/usr/bin/env bash | ||
| 2 | +# Host build + smoke test. CI entry point; not used by Flutter itself. | ||
| 3 | +set -euo pipefail | ||
| 4 | +cd "$(dirname "$0")/.." | ||
| 5 | +command -v v >/dev/null || { echo "V compiler not on PATH"; exit 1; } | ||
| 6 | +mkdir -p build | ||
| 7 | +v -shared -o build/libvflutter.so src/vflutter.v | ||
| 8 | +echo "built: $(ls -la build/libvflutter.so | awk '{print $5}') bytes" | ||
| 9 | +nm -D --defined-only build/libvflutter.so | grep ' vf_' || { echo "no vf_ exports!"; exit 1; } | ||
added
tool/gen_ios_sources.sh +12 -0 | new file mode 100755 | ||
| @@ -0,0 +1,12 @@ | ||
| 1 | +#!/usr/bin/env bash | |
| 2 | +# iOS/macOS cannot run `v` from inside Xcode's sandbox, and App Store builds | |
| 3 | +# want a static archive. So V's C output is generated ahead of time and | |
| 4 | +# checked in; CocoaPods then compiles it like any other C source. | |
| 5 | +# | |
| 6 | +# Re-run this whenever src/vflutter.v changes. | |
| 7 | +set -euo pipefail | |
| 8 | +cd "$(dirname "$0")/.." | |
| 9 | +v -shared -gc none -no-parallel -o ios/Classes/vflutter.gen.c src/vflutter.v | |
| 10 | +cp src/vflutter.h ios/Classes/vflutter.h | |
| 11 | +cp ios/Classes/vflutter.gen.c ios/Classes/vflutter.h macos/Classes/ | |
| 12 | +echo "regenerated ios/ + macos/ sources ($(wc -l < ios/Classes/vflutter.gen.c) lines)" | |
| new file mode 100755 | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | +#!/usr/bin/env bash | ||
| 2 | +# iOS/macOS cannot run `v` from inside Xcode's sandbox, and App Store builds | ||
| 3 | +# want a static archive. So V's C output is generated ahead of time and | ||
| 4 | +# checked in; CocoaPods then compiles it like any other C source. | ||
| 5 | +# | ||
| 6 | +# Re-run this whenever src/vflutter.v changes. | ||
| 7 | +set -euo pipefail | ||
| 8 | +cd "$(dirname "$0")/.." | ||
| 9 | +v -shared -gc none -no-parallel -o ios/Classes/vflutter.gen.c src/vflutter.v | ||
| 10 | +cp src/vflutter.h ios/Classes/vflutter.h | ||
| 11 | +cp ios/Classes/vflutter.gen.c ios/Classes/vflutter.h macos/Classes/ | ||
| 12 | +echo "regenerated ios/ + macos/ sources ($(wc -l < ios/Classes/vflutter.gen.c) lines)" | ||
added
windows/CMakeLists.txt +3 -0 | new file mode 100644 | ||
| @@ -0,0 +1,3 @@ | ||
| 1 | +cmake_minimum_required(VERSION 3.15) | |
| 2 | +add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../src" "${CMAKE_CURRENT_BINARY_DIR}/vf") | |
| 3 | +set(vflutter_ffi_bundled_libraries "$<TARGET_FILE:vflutter>" PARENT_SCOPE) | |
| new file mode 100644 | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | +cmake_minimum_required(VERSION 3.15) | ||
| 2 | +add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../src" "${CMAKE_CURRENT_BINARY_DIR}/vf") | ||
| 3 | +set(vflutter_ffi_bundled_libraries "$<TARGET_FILE:vflutter>" PARENT_SCOPE) | ||