meta_language/translation/
product_emission_rules.rs1#![allow(
5 unused,
6 unreachable_patterns,
7 non_snake_case,
8 non_camel_case_types,
9 invalid_nan_comparisons
10)]
11
12pub use crate::translation::frontend_rules::ml_array;
14
15#[must_use]
16pub fn join_product_items(items: &[String]) -> String {
17 {
18 let text = String::new();
19 {
20 let index = 0f64;
21 {
22 crate::translation::product_emission_rules::ml_join_product_items_loop1(
23 items, text, index,
24 )
25 }
26 }
27 }
28}
29
30#[must_use]
31pub fn render_tuple_value(target: &str, items: &[String], frozen: bool) -> String {
32 if (target == "JavaScript") {
33 {
34 let text = format!(
35 "{}{}",
36 (format!(
37 "{}{}",
38 (String::from("[")),
39 (crate::translation::product_emission_rules::join_product_items(items))
40 )),
41 (String::from("]"))
42 );
43 if frozen {
44 format!(
45 "{}{}",
46 (format!("{}{}", (String::from("Object.freeze(")), text)),
47 (String::from(")"))
48 )
49 } else {
50 text
51 }
52 }
53 } else if (target == "Rust") {
54 format!(
55 "{}{}",
56 (format!(
57 "{}{}",
58 (format!(
59 "{}{}",
60 (String::from("(")),
61 (crate::translation::product_emission_rules::join_product_items(items))
62 )),
63 (if items.len() == 1 {
64 String::from(",")
65 } else {
66 String::new()
67 })
68 )),
69 (String::from(")"))
70 )
71 } else {
72 String::new()
73 }
74}
75
76#[must_use]
77pub fn render_tuple_projection(target: &str, object: &str, index: &str) -> String {
78 if (target == "JavaScript") {
79 format!(
80 "{}{}",
81 (format!(
82 "{}{}",
83 (format!(
84 "{}{}",
85 (format!("{}{}", (String::from("(")), object)),
86 (String::from(")["))
87 )),
88 index
89 )),
90 (String::from("]"))
91 )
92 } else if (target == "Rust") {
93 format!(
94 "{}{}",
95 (format!(
96 "{}{}",
97 (format!("{}{}", (String::from("(")), object)),
98 (String::from(")."))
99 )),
100 index
101 )
102 } else {
103 String::new()
104 }
105}
106
107#[must_use]
108pub fn accept_tuple_copy_type(kind: &str, fields: &[bool]) -> bool {
109 if ((((kind == "bool") || (kind == "fixed")) || (kind == "float")) || (kind == "unit")) {
110 true
111 } else if kind == "tuple" {
112 {
113 let index = 0f64;
114 {
115 let ml_s1 =
116 crate::translation::product_emission_rules::ml_accept_tuple_copy_type_loop2(
117 fields, index,
118 );
119 match ml_s1 {
120 crate::translation::product_emission_rules::MlAcceptTupleCopyTypeLoop2Result::MlAcceptTupleCopyTypeLoop2Done => {
121 true
122 }
123 crate::translation::product_emission_rules::MlAcceptTupleCopyTypeLoop2Result::MlAcceptTupleCopyTypeLoop2Return(ml_result2) => {
124 ml_result2
125 }
126 }
127 }
128 }
129 } else {
130 false
131 }
132}
133
134#[must_use]
135pub fn render_java_script_unit(language: &str) -> String {
136 if (language == "JavaScript") {
137 String::from("undefined")
138 } else {
139 String::from("null")
140 }
141}
142
143#[expect(
144 clippy::cast_precision_loss,
145 reason = "the checked JavaScript array-length domain is at most 2^32 - 1, and its loop index starts at zero, advances by one, and is bounded by that length"
146)]
147#[must_use]
148pub fn ml_join_product_items_loop1(items: &[String], mut text: String, mut index: f64) -> String {
149 loop {
150 if (index < (items.len() as f64)) {
151 {
152 let text_3 = if (index > (0f64)) {
153 { format!("{}{}", text, (String::from(", "))) }
154 } else {
155 text
156 };
157 {
158 let text_4 = format!(
159 "{}{}",
160 text_3,
161 (crate::translation::product_emission_rules::ml_array::optional_at(
162 items,
163 crate::translation::product_emission_rules::ml_array::number_index(
164 index
165 )
166 )
167 .unwrap_or_else(|| String::from("undefined")))
168 );
169 {
170 let index_2 = (index + 1f64);
171 {
172 (text, index) = (text_4, index_2);
173 continue;
174 }
175 }
176 }
177 }
178 }
179 return { text };
180 }
181}
182
183#[derive(Clone, Debug, PartialEq, Eq)]
184pub enum MlAcceptTupleCopyTypeLoop2Result {
185 MlAcceptTupleCopyTypeLoop2Done,
186 MlAcceptTupleCopyTypeLoop2Return(bool),
187}
188
189#[expect(
190 clippy::cast_precision_loss,
191 reason = "the checked JavaScript array-length domain is at most 2^32 - 1, and its loop index starts at zero, advances by one, and is bounded by that length"
192)]
193#[must_use]
194pub fn ml_accept_tuple_copy_type_loop2(
195 fields: &[bool],
196 mut index: f64,
197) -> crate::translation::product_emission_rules::MlAcceptTupleCopyTypeLoop2Result {
198 loop {
199 return if (index < (fields.len() as f64)) {
200 if (crate::translation::product_emission_rules::ml_array::optional_at(
201 fields,
202 crate::translation::product_emission_rules::ml_array::number_index(index),
203 )
204 .unwrap_or_default())
205 {
206 {
207 let index_2 = (index + 1f64);
208 {
209 index = index_2;
210 continue;
211 }
212 }
213 }
214 {
215 crate::translation::product_emission_rules::MlAcceptTupleCopyTypeLoop2Result::MlAcceptTupleCopyTypeLoop2Return(false)
216 }
217 } else {
218 crate::translation::product_emission_rules::MlAcceptTupleCopyTypeLoop2Result::MlAcceptTupleCopyTypeLoop2Done
219 };
220 }
221}
222
223const fn ml_main() {}
224
225fn main() {
227 let check = std::env::args().any(|argument| argument == "--ml-check-theorems");
228 let worker = std::thread::Builder::new()
229 .stack_size(1 << 28)
230 .spawn(ml_main)
231 .expect("spawn the program thread");
232 if worker.join().is_err() {
233 std::process::exit(101);
234 }
235}