1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
// zigir/lower/class.rs
// Class declaration lowering: fields, methods, constructor, this-rewrite.
use std::collections::HashSet;
use oxc_ast::ast::*;
use crate::types::ZigType;
use crate::zigir::ops::{AssignOp, BinOp, UpdateOp};
use crate::zigir::types::{IrAssignTarget, IrBlock, IrExpr, IrParam, IrStmt};
use super::Lowerer;
use super::cabi::property_key_name;
// ¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T
// Remaining stubs
// ¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T
impl Lowerer {
/// Generate a unique name for an anonymous class expression.
fn next_anon_class_name(&mut self) -> String {
let n = self.anon_class_counter;
self.anon_class_counter += 1;
format!("_AnonClass_{}", n)
}
/// Lower a class declaration into IrClassDecl.
///
/// Extracts fields (from PropertyDefinition and implicit constructor `this.x = ...`),
/// constructor ¡ú IrClassMethod, regular methods ¡ú IrClassMethod, and static inits.
pub(super) fn lower_class_decl(
&mut self,
cd: &Class,
) -> Option<crate::zigir::types::IrClassDecl> {
use crate::zigir::types::{IrClassDecl, IrClassField, IrClassMethod};
let class_name = cd
.id
.as_ref()
.map(|id| id.name.to_string())
.unwrap_or_else(|| {
// Anonymous class expression needs a unique name to avoid collisions
self.next_anon_class_name()
});
// Save/restore current_class — set early so that static blocks
// and field initializers can reference `this` correctly.
let saved_class = self.current_class.take();
self.current_class = Some(class_name.clone());
// Pre-scan: collect static field names so `this.field` in static blocks
// can be routed correctly via class_static_fields during lowering.
let mut pre_scan_static_names: HashSet<String> = HashSet::new();
for elem in &cd.body.body {
if let ClassElement::PropertyDefinition(pd) = elem
&& pd.r#static
&& !pd.computed
&& let Some(name) = property_key_name(&pd.key)
{
pre_scan_static_names.insert(name);
}
}
if !pre_scan_static_names.is_empty() {
self.class_static_fields
.insert(class_name.clone(), pre_scan_static_names);
}
// ── First pass: collect explicit fields from PropertyDefinition ──
let mut field_names: Vec<String> = Vec::new();
let mut fields: Vec<IrClassField> = Vec::new();
let mut static_inits: Vec<(String, crate::zigir::types::IrExpr, ZigType)> = Vec::new();
let mut static_blocks: Vec<IrBlock> = Vec::new();
let mut has_constructor = false;
let mut constructor_func: Option<&Function> = None;
for elem in &cd.body.body {
match elem {
ClassElement::PropertyDefinition(pd) => {
if pd.computed {
continue;
}
let is_static = pd.r#static;
if let Some(name) = property_key_name(&pd.key) {
if is_static {
if let Some(value) = &pd.value {
let field_ty = self
.type_info
.class_field_types
.get(&class_name)
.and_then(|m| m.get(&name))
.cloned()
.or_else(|| {
// Fallback: for anonymous class expressions,
// field types are stored under the variable name
self.class_expr_var_name.as_ref().and_then(|vn| {
self.type_info
.class_field_types
.get(vn)
.and_then(|m| m.get(&name))
.cloned()
})
})
.unwrap_or(ZigType::JsAny);
// Register static field type in var_types for Member target type inference
let var_key = format!("__{}_{}", class_name, name);
self.type_info.var_types.insert(var_key, field_ty.clone());
static_inits.push((name.clone(), self.lower_expr(value), field_ty));
}
} else if !field_names.contains(&name) {
let field_ty = self
.type_info
.class_field_types
.get(&class_name)
.and_then(|m| m.get(&name))
.cloned()
.or_else(|| {
// Fallback: for anonymous class expressions,
// field types are stored under the variable name
self.class_expr_var_name.as_ref().and_then(|vn| {
self.type_info
.class_field_types
.get(vn)
.and_then(|m| m.get(&name))
.cloned()
})
})
.unwrap_or(ZigType::JsAny);
let default = pd.value.as_ref().map(|v| self.lower_expr(v));
field_names.push(name.clone());
fields.push(IrClassField {
name,
zig_type: field_ty,
default,
});
}
}
}
ClassElement::MethodDefinition(md) if Self::is_constructor_method(md) => {
has_constructor = true;
constructor_func = Some(&md.value);
}
ClassElement::StaticBlock(sb) => {
// Lower static block — set in_static_block so `this` → ClassName
let saved_static_block = self.in_static_block;
self.in_static_block = true;
let block = self.lower_block(&sb.body);
self.in_static_block = saved_static_block;
static_blocks.push(block);
}
_ => {}
}
}
// ── Second pass: scan constructor body for implicit `this.x = ...` fields ──
if let Some(func) = constructor_func
&& let Some(body) = &func.body
{
self.collect_implicit_class_fields(
&body.statements,
&class_name,
&mut field_names,
&mut fields,
);
}
// ── Lower constructor ──
let constructor = if has_constructor {
constructor_func
.map(|func| self.lower_class_method(&class_name, &field_names, "init", func, false))
} else {
None
};
// ©¤©¤ Lower methods ©¤©¤
let mut methods: Vec<IrClassMethod> = Vec::new();
for elem in &cd.body.body {
if let ClassElement::MethodDefinition(md) = elem
&& !Self::is_constructor_method(md)
{
let method_name =
property_key_name(&md.key).unwrap_or_else(|| "anonymous".to_string());
let is_static = md.r#static;
let method = self.lower_class_method(
&class_name,
&field_names,
&method_name,
&md.value,
is_static,
);
methods.push(method);
}
}
// ©¤©¤ Restore ©¤©¤
self.current_class = saved_class;
// ©¤©¤ extends ©¤©¤
let extends = cd.super_class.as_ref().and_then(|sc| {
if let Expression::Identifier(id) = sc {
Some(id.name.to_string())
} else {
None
}
});
// static field names already registered in class_static_fields during pre-scan
// Compute needs_deinit: true if any field is Map, Set, ArrayList, BigInt,
// or a NamedStruct that itself needs deinit (nested class).
let needs_deinit = fields.iter().any(|f| {
matches!(
f.zig_type,
ZigType::NamedStruct(ref n) if n == "Map" || n == "Set"
) || matches!(f.zig_type, ZigType::ArrayList(_))
|| matches!(f.zig_type, ZigType::BigInt)
});
Some(IrClassDecl {
name: self.make_ident(&class_name),
fields,
constructor,
methods,
static_inits,
static_blocks,
extends,
needs_deinit,
})
}
/// Check if a MethodDefinition is `constructor()`.
pub(super) fn is_constructor_method(md: &MethodDefinition) -> bool {
property_key_name(&md.key).is_some_and(|name| name == "constructor")
}
/// Scan constructor body for `this.x = ...` assignments and add
/// discovered fields if not already present.
pub(super) fn collect_implicit_class_fields(
&self,
stmts: &[Statement],
class_name: &str,
field_names: &mut Vec<String>,
fields: &mut Vec<crate::zigir::types::IrClassField>,
) {
for stmt in stmts {
match stmt {
Statement::ExpressionStatement(es) => {
if let Expression::AssignmentExpression(ae) = &es.expression {
let maybe_fname = match &ae.left {
AssignmentTarget::StaticMemberExpression(sme)
if matches!(&sme.object, Expression::ThisExpression(_)) =>
{
Some(sme.property.name.to_string())
}
AssignmentTarget::PrivateFieldExpression(pfe)
if matches!(&pfe.object, Expression::ThisExpression(_)) =>
{
Some(pfe.field.name.to_string())
}
_ => None,
};
if let Some(fname) = maybe_fname
&& !field_names.contains(&fname)
{
let ftype = self
.type_info
.class_field_types
.get(class_name)
.and_then(|m| m.get(&fname))
.cloned()
.or_else(|| {
// Fallback: for anonymous class expressions,
// field types are stored under the variable name
self.class_expr_var_name.as_ref().and_then(|vn| {
self.type_info
.class_field_types
.get(vn)
.and_then(|m| m.get(&fname))
.cloned()
})
})
.unwrap_or(ZigType::JsAny);
field_names.push(fname.clone());
fields.push(crate::zigir::types::IrClassField {
name: fname,
zig_type: ftype,
default: None,
});
}
}
}
Statement::IfStatement(is) => {
self.collect_implicit_class_fields(
std::slice::from_ref(&is.consequent),
class_name,
field_names,
fields,
);
if let Some(alt) = &is.alternate {
self.collect_implicit_class_fields(
std::slice::from_ref(alt),
class_name,
field_names,
fields,
);
}
}
Statement::BlockStatement(bs) => {
self.collect_implicit_class_fields(&bs.body, class_name, field_names, fields);
}
// R8-C7: Recurse into loop/switch/try bodies so that
// `this.field = value` nested inside them is discovered as a
// class field (added to field_names) and later rewritten by
// try_rewrite_this_field_assignment during body lowering.
// Without this, such fields were silently dropped.
Statement::WhileStatement(ws) => {
self.collect_implicit_class_fields(
std::slice::from_ref(&ws.body),
class_name,
field_names,
fields,
);
}
Statement::DoWhileStatement(dws) => {
self.collect_implicit_class_fields(
std::slice::from_ref(&dws.body),
class_name,
field_names,
fields,
);
}
Statement::ForStatement(fs) => {
self.collect_implicit_class_fields(
std::slice::from_ref(&fs.body),
class_name,
field_names,
fields,
);
}
Statement::ForOfStatement(fos) => {
self.collect_implicit_class_fields(
std::slice::from_ref(&fos.body),
class_name,
field_names,
fields,
);
}
Statement::ForInStatement(fis) => {
self.collect_implicit_class_fields(
std::slice::from_ref(&fis.body),
class_name,
field_names,
fields,
);
}
Statement::LabeledStatement(ls) => {
self.collect_implicit_class_fields(
std::slice::from_ref(&ls.body),
class_name,
field_names,
fields,
);
}
Statement::SwitchStatement(ss) => {
for case in &ss.cases {
self.collect_implicit_class_fields(
&case.consequent,
class_name,
field_names,
fields,
);
}
}
Statement::TryStatement(ts) => {
self.collect_implicit_class_fields(
&ts.block.body,
class_name,
field_names,
fields,
);
if let Some(handler) = &ts.handler {
self.collect_implicit_class_fields(
&handler.body.body,
class_name,
field_names,
fields,
);
}
if let Some(fin) = &ts.finalizer {
self.collect_implicit_class_fields(
&fin.body,
class_name,
field_names,
fields,
);
}
}
_ => {}
}
}
}
/// Lower a class method (constructor or regular) into IrClassMethod.
pub(super) fn lower_class_method(
&mut self,
class_name: &str,
field_names: &[String],
method_name: &str,
func: &Function,
is_static: bool,
) -> crate::zigir::types::IrClassMethod {
// For fully-qualified key lookups
let fq_method = format!("{}.{}", class_name, method_name);
let return_type = self
.type_info
.fn_return_types
.get(&fq_method)
.or_else(|| self.type_info.fn_return_types.get(method_name))
.or_else(|| {
// Fallback: for anonymous class expressions, return types are
// stored under the variable name (e.g. "Point.sum" not "_AnonClass_0.sum")
self.class_expr_var_name.as_ref().and_then(|vn| {
let var_fq = format!("{}.{}", vn, method_name);
self.type_info.fn_return_types.get(&var_fq)
})
})
.cloned()
.unwrap_or(if method_name == "init" {
ZigType::NamedStruct(class_name.to_string())
} else {
ZigType::Void
});
// Parameters
let params = if method_name == "init" {
self.lower_fn_params(func, "init")
} else {
let param_types = self
.type_info
.fn_param_types
.get(&fq_method)
.or_else(|| self.type_info.fn_param_types.get(method_name))
.or_else(|| {
// Fallback: for anonymous class expressions
self.class_expr_var_name.as_ref().and_then(|vn| {
let var_fq = format!("{}.{}", vn, method_name);
self.type_info.fn_param_types.get(&var_fq)
})
})
.cloned();
if let Some(ptypes) = param_types {
let mut params = Vec::new();
for (pname, ptype) in &ptypes {
params.push(IrParam {
name: self.make_ident(pname),
zig_type: ptype.clone(),
is_unused: false,
is_rest: false,
});
}
params
} else {
self.lower_fn_params(func, method_name)
}
};
// Enter function context
let saved_fn = self.enter_fn(method_name, false, Some(return_type.clone()));
// For static methods, set in_static_block so `this` → ClassName
// (static methods don't have a `self` parameter in Zig).
let saved_static_block = self.in_static_block;
if is_static && method_name != "init" {
self.in_static_block = true;
}
// Lower body
let body = func
.body
.as_ref()
.map(|b| {
if method_name == "init" {
// Constructor: set the this-rewrite flag so that
// `this.field = value` statements (directly, or nested
// inside if/loop/switch/try bodies) are rewritten to
// `const field = value` for the Emitter's struct return.
// `enter_fn` above already saved+cleared the flag; we set
// it here and `exit_fn` will restore the (cleared) saved
// value, scoping the flag to just this constructor body.
self.this_rewrite_fields = Some(field_names.to_vec());
self.lower_block(&b.statements)
} else {
self.lower_block(&b.statements)
}
})
.unwrap_or_else(|| IrBlock::new(vec![]));
self.in_static_block = saved_static_block;
self.exit_fn(saved_fn);
crate::zigir::types::IrClassMethod {
name: method_name.to_string(),
params,
return_type,
body,
is_static,
}
}
/// R8-C7/C9: Rewrite `this.field` mutations into local `field` operations
/// that write to a pre-declared `var` in the constructor, so the Emitter
/// can collect field values for the struct return.
///
/// Handles three categories:
/// 1. `this.field = value` → `Assign { target: Ident(field), op: Assign }`
/// 2. `this.field += value` (and all compound ops) → `Assign { target: Ident(field), op: <compound> }`
/// - BigInt compound: expanded to `field = field <op> value` (no Zig += for BigInt)
/// 3. `this.field++` / `this.field--` → `Expr(Update { target: Ident(field), is_expr_stmt: true })`
/// - BigInt ++/--: expanded to `field = field.add/sub(BigInt(1))`
///
/// `**=` and `>>>=` are NOT handled (they expand to BlockExpr in
/// lower_assignment) — these rare cases fall through to normal lowering.
///
/// Returns `Some(IrStmt)` when the expression is a rewriteable this-field
/// mutation whose name is in `field_names`; otherwise `None`.
///
/// Invoked from `lower_stmt`'s ExpressionStatement arm and from
/// `lower_for_statement`'s init/update. The active field list lives on
/// `self.this_rewrite_fields` and is cleared inside nested function
/// contexts (via `enter_fn`) so that `this` in a nested function is not
/// confused with the constructor's `this`.
pub(super) fn try_rewrite_this_field_assignment(
&mut self,
expr: &Expression,
field_names: &[String],
) -> Option<IrStmt> {
match expr {
// this.field = value / this.field += value / etc.
Expression::AssignmentExpression(ae) => {
let fname = self.extract_this_field_name_from_assign_target(&ae.left)?;
if !field_names.contains(&fname) {
return None;
}
// **= and >>>= are expanded by lower_assignment into
// BlockExpr — let them fall through to normal lowering.
if matches!(
ae.operator,
AssignmentOperator::Exponential | AssignmentOperator::ShiftRightZeroFill
) {
return None;
}
// BigInt compound assignments need expansion to
// field = field <op> value (no Zig += for BigInt).
if ae.operator != AssignmentOperator::Assign
&& self.infer_assign_target_type(&ae.left) == Some(ZigType::BigInt)
{
let bin_op = match ae.operator {
AssignmentOperator::Addition => BinOp::Add,
AssignmentOperator::Subtraction => BinOp::Sub,
AssignmentOperator::Multiplication => BinOp::Mul,
AssignmentOperator::Division => BinOp::Div,
AssignmentOperator::Remainder => BinOp::Mod,
AssignmentOperator::BitwiseAnd => BinOp::BitAnd,
AssignmentOperator::BitwiseOR => BinOp::BitOr,
AssignmentOperator::BitwiseXOR => BinOp::BitXor,
AssignmentOperator::ShiftLeft => BinOp::Shl,
AssignmentOperator::ShiftRight => BinOp::Shr,
_ => return None,
};
let value_ir = self.lower_expr(&ae.right);
let read_expr = IrExpr::Ident(self.make_ident(&fname));
return Some(IrStmt::Assign {
target: IrAssignTarget::Ident(self.make_ident(&fname)),
op: AssignOp::Assign,
value: IrExpr::Binary {
op: bin_op,
left: Box::new(read_expr),
right: Box::new(value_ir),
left_type: Some(ZigType::BigInt),
right_type: Some(ZigType::BigInt),
},
});
}
// Non-BigInt compound or plain =: map operator directly.
let op = match ae.operator {
AssignmentOperator::Assign => AssignOp::Assign,
AssignmentOperator::Addition => AssignOp::Add,
AssignmentOperator::Subtraction => AssignOp::Sub,
AssignmentOperator::Multiplication => AssignOp::Mul,
AssignmentOperator::Division => AssignOp::Div,
AssignmentOperator::Remainder => AssignOp::Mod,
AssignmentOperator::ShiftLeft => AssignOp::Shl,
AssignmentOperator::ShiftRight => AssignOp::Shr,
AssignmentOperator::BitwiseAnd => AssignOp::BitAnd,
AssignmentOperator::BitwiseOR => AssignOp::BitOr,
AssignmentOperator::BitwiseXOR => AssignOp::BitXor,
AssignmentOperator::LogicalAnd => AssignOp::LogicAnd,
AssignmentOperator::LogicalOr => AssignOp::LogicOr,
AssignmentOperator::LogicalNullish => AssignOp::Nullish,
_ => return None,
};
let value_ir = self.lower_expr(&ae.right);
Some(IrStmt::Assign {
target: IrAssignTarget::Ident(self.make_ident(&fname)),
op,
value: value_ir,
})
}
// this.field++ / this.field-- / ++this.field / --this.field
Expression::UpdateExpression(ue) => {
let fname = self.extract_this_field_name_from_simple_target(&ue.argument)?;
if !field_names.contains(&fname) {
return None;
}
// BigInt ++/-- needs expansion to field = field.add/sub(BigInt(1)).
// In statement context (which is the only context this function is
// called from), the return value is discarded, so prefix/postfix
// are equivalent — both just mutate the field.
if self.infer_simple_assign_target_type(&ue.argument) == Some(ZigType::BigInt) {
let bin_op = if ue.operator == UpdateOperator::Increment {
BinOp::Add
} else {
BinOp::Sub
};
let read_expr = IrExpr::Ident(self.make_ident(&fname));
return Some(IrStmt::Assign {
target: IrAssignTarget::Ident(self.make_ident(&fname)),
op: AssignOp::Assign,
value: IrExpr::Binary {
op: bin_op,
left: Box::new(read_expr),
right: Box::new(IrExpr::BigIntLiteral("1".to_string())),
left_type: Some(ZigType::BigInt),
right_type: Some(ZigType::BigInt),
},
});
}
// Non-BigInt: emit field++ / field-- as a statement.
let op = if ue.operator == UpdateOperator::Increment {
UpdateOp::Increment
} else {
UpdateOp::Decrement
};
Some(IrStmt::Expr(IrExpr::Update {
op,
target: Box::new(IrAssignTarget::Ident(self.make_ident(&fname))),
is_expr_stmt: true,
prefix: ue.prefix,
}))
}
_ => None,
}
}
/// Extract field name from `this.field` in an AssignmentTarget (for
/// `this.field = ...` or `this.field += ...`).
fn extract_this_field_name_from_assign_target(
&self,
target: &AssignmentTarget,
) -> Option<String> {
match target {
AssignmentTarget::StaticMemberExpression(sme)
if matches!(&sme.object, Expression::ThisExpression(_)) =>
{
Some(sme.property.name.to_string())
}
AssignmentTarget::PrivateFieldExpression(pfe)
if matches!(&pfe.object, Expression::ThisExpression(_)) =>
{
// PrivateIdentifier.name does NOT include the '#' prefix
Some(pfe.field.name.to_string())
}
_ => None,
}
}
/// Extract field name from `this.field` in a SimpleAssignmentTarget (for
/// `this.field++` / `++this.field`).
fn extract_this_field_name_from_simple_target(
&self,
target: &SimpleAssignmentTarget,
) -> Option<String> {
match target {
SimpleAssignmentTarget::StaticMemberExpression(sme)
if matches!(&sme.object, Expression::ThisExpression(_)) =>
{
Some(sme.property.name.to_string())
}
SimpleAssignmentTarget::PrivateFieldExpression(pfe)
if matches!(&pfe.object, Expression::ThisExpression(_)) =>
{
Some(pfe.field.name.to_string())
}
_ => None,
}
}
}