forked from argotorg/fe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod.rs
More file actions
772 lines (690 loc) · 22 KB
/
Copy pathmod.rs
File metadata and controls
772 lines (690 loc) · 22 KB
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
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
mod abi;
mod contract;
mod data;
mod emit;
mod revert;
mod safe_math;
use std::fmt::Write;
use fe_analyzer::namespace::items::ContractId;
use fe_mir::ir::{types::ArrayDef, FunctionId, TypeId, TypeKind};
use fxhash::FxHashMap;
use yultsur::*;
use num_bigint::BigInt;
use crate::{db::CodegenDb, yul::slot_size::SLOT_SIZE};
use super::slot_size::yul_primitive_type;
pub trait RuntimeProvider {
fn collect_definitions(&self) -> Vec<yul::FunctionDefinition>;
fn alloc(&mut self, db: &dyn CodegenDb, size: yul::Expression) -> yul::Expression;
fn avail(&mut self, db: &dyn CodegenDb) -> yul::Expression;
fn create(
&mut self,
db: &dyn CodegenDb,
contract: ContractId,
value: yul::Expression,
) -> yul::Expression;
fn create2(
&mut self,
db: &dyn CodegenDb,
contract: ContractId,
value: yul::Expression,
salt: yul::Expression,
) -> yul::Expression;
fn emit(
&mut self,
db: &dyn CodegenDb,
event: yul::Expression,
event_ty: TypeId,
) -> yul::Expression;
fn revert(
&mut self,
db: &dyn CodegenDb,
arg: Option<yul::Expression>,
arg_name: &str,
arg_ty: TypeId,
) -> yul::Expression;
fn external_call(
&mut self,
db: &dyn CodegenDb,
function: FunctionId,
args: Vec<yul::Expression>,
) -> yul::Expression;
fn map_value_ptr(
&mut self,
db: &dyn CodegenDb,
map_ptr: yul::Expression,
key: yul::Expression,
key_ty: TypeId,
) -> yul::Expression;
fn aggregate_init(
&mut self,
db: &dyn CodegenDb,
ptr: yul::Expression,
args: Vec<yul::Expression>,
ptr_ty: TypeId,
arg_tys: Vec<TypeId>,
) -> yul::Expression;
fn string_copy(
&mut self,
db: &dyn CodegenDb,
dst: yul::Expression,
data: &str,
is_dst_storage: bool,
) -> yul::Expression;
fn string_construct(
&mut self,
db: &dyn CodegenDb,
data: &str,
string_len: usize,
) -> yul::Expression;
/// Copy data from `src` to `dst`.
/// NOTE: src and dst must be aligned by 32 when a ptr is storage ptr.
fn ptr_copy(
&mut self,
db: &dyn CodegenDb,
src: yul::Expression,
dst: yul::Expression,
size: yul::Expression,
is_src_storage: bool,
is_dst_storage: bool,
) -> yul::Expression;
fn ptr_store(
&mut self,
db: &dyn CodegenDb,
ptr: yul::Expression,
imm: yul::Expression,
ptr_ty: TypeId,
) -> yul::Expression;
fn ptr_load(
&mut self,
db: &dyn CodegenDb,
ptr: yul::Expression,
ptr_ty: TypeId,
) -> yul::Expression;
fn abi_encode(
&mut self,
db: &dyn CodegenDb,
src: yul::Expression,
dst: yul::Expression,
src_ty: TypeId,
is_dst_storage: bool,
) -> yul::Expression;
fn abi_encode_seq(
&mut self,
db: &dyn CodegenDb,
src: &[yul::Expression],
dst: yul::Expression,
src_tys: &[TypeId],
is_dst_storage: bool,
) -> yul::Expression;
fn abi_decode(
&mut self,
db: &dyn CodegenDb,
src: yul::Expression,
size: yul::Expression,
types: &[TypeId],
abi_loc: AbiSrcLocation,
) -> yul::Expression;
fn primitive_cast(
&mut self,
db: &dyn CodegenDb,
value: yul::Expression,
from_ty: TypeId,
) -> yul::Expression {
debug_assert!(from_ty.is_primitive(db.upcast()));
let from_size = from_ty.size_of(db.upcast(), SLOT_SIZE);
if from_ty.is_signed(db.upcast()) {
let significant = literal_expression! {(from_size-1)};
expression! { signextend([significant], [value]) }
} else {
let mask = BitMask::new(from_size);
expression! { and([value], [mask.as_expr()]) }
}
}
// TODO: The all functions below will be reimplemented in `std`.
fn safe_add(
&mut self,
db: &dyn CodegenDb,
lhs: yul::Expression,
rhs: yul::Expression,
ty: TypeId,
) -> yul::Expression;
fn safe_sub(
&mut self,
db: &dyn CodegenDb,
lhs: yul::Expression,
rhs: yul::Expression,
ty: TypeId,
) -> yul::Expression;
fn safe_mul(
&mut self,
db: &dyn CodegenDb,
lhs: yul::Expression,
rhs: yul::Expression,
ty: TypeId,
) -> yul::Expression;
fn safe_div(
&mut self,
db: &dyn CodegenDb,
lhs: yul::Expression,
rhs: yul::Expression,
ty: TypeId,
) -> yul::Expression;
fn safe_mod(
&mut self,
db: &dyn CodegenDb,
lhs: yul::Expression,
rhs: yul::Expression,
ty: TypeId,
) -> yul::Expression;
fn safe_pow(
&mut self,
db: &dyn CodegenDb,
lhs: yul::Expression,
rhs: yul::Expression,
ty: TypeId,
) -> yul::Expression;
}
#[derive(Clone, Copy, Debug)]
pub enum AbiSrcLocation {
CallData,
Memory,
}
#[derive(Debug, Default)]
pub struct DefaultRuntimeProvider {
functions: FxHashMap<String, RuntimeFunction>,
}
impl DefaultRuntimeProvider {
fn create_then_call<F>(
&mut self,
name: &str,
args: Vec<yul::Expression>,
func_builder: F,
) -> yul::Expression
where
F: FnOnce(&mut Self) -> RuntimeFunction,
{
if let Some(func) = self.functions.get(name) {
func.call(args)
} else {
let func = func_builder(self);
let result = func.call(args);
self.functions.insert(name.to_string(), func);
result
}
}
}
impl RuntimeProvider for DefaultRuntimeProvider {
fn collect_definitions(&self) -> Vec<yul::FunctionDefinition> {
self.functions
.values()
.map(RuntimeFunction::definition)
.collect()
}
fn alloc(&mut self, _db: &dyn CodegenDb, bytes: yul::Expression) -> yul::Expression {
let name = "$alloc";
let arg = vec![bytes];
self.create_then_call(name, arg, |_| data::make_alloc(name))
}
fn avail(&mut self, _db: &dyn CodegenDb) -> yul::Expression {
let name = "$avail";
let arg = vec![];
self.create_then_call(name, arg, |_| data::make_avail(name))
}
fn create(
&mut self,
db: &dyn CodegenDb,
contract: ContractId,
value: yul::Expression,
) -> yul::Expression {
let name = format!("$create_{}", db.codegen_contract_symbol_name(contract));
let arg = vec![value];
self.create_then_call(&name, arg, |provider| {
contract::make_create(provider, db, &name, contract)
})
}
fn create2(
&mut self,
db: &dyn CodegenDb,
contract: ContractId,
value: yul::Expression,
salt: yul::Expression,
) -> yul::Expression {
let name = format!("$create2_{}", db.codegen_contract_symbol_name(contract));
let arg = vec![value, salt];
self.create_then_call(&name, arg, |provider| {
contract::make_create2(provider, db, &name, contract)
})
}
fn emit(
&mut self,
db: &dyn CodegenDb,
event: yul::Expression,
event_ty: TypeId,
) -> yul::Expression {
let name = format!("$emit_{}", event_ty.0);
let legalized_ty = db.codegen_legalized_type(event_ty);
self.create_then_call(&name, vec![event], |provider| {
emit::make_emit(provider, db, &name, legalized_ty)
})
}
fn revert(
&mut self,
db: &dyn CodegenDb,
arg: Option<yul::Expression>,
arg_name: &str,
arg_ty: TypeId,
) -> yul::Expression {
let func_name = format! {"$revert_{}_{}", arg_name, arg_ty.0};
let args = match arg {
Some(arg) => vec![arg],
None => vec![],
};
self.create_then_call(&func_name, args, |provider| {
revert::make_revert(provider, db, &func_name, arg_name, arg_ty)
})
}
fn external_call(
&mut self,
db: &dyn CodegenDb,
function: FunctionId,
args: Vec<yul::Expression>,
) -> yul::Expression {
let name = format!(
"$call_external__{}",
db.codegen_function_symbol_name(function)
);
self.create_then_call(&name, args, |provider| {
contract::make_external_call(provider, db, &name, function)
})
}
fn map_value_ptr(
&mut self,
db: &dyn CodegenDb,
map_ptr: yul::Expression,
key: yul::Expression,
key_ty: TypeId,
) -> yul::Expression {
if key_ty.is_primitive(db.upcast()) {
let name = "$map_value_ptr_with_primitive_key";
self.create_then_call(name, vec![map_ptr, key], |provider| {
data::make_map_value_ptr_with_primitive_key(provider, db, name, key_ty)
})
} else if key_ty.is_mptr(db.upcast()) {
let name = "$map_value_ptr_with_ptr_key";
self.create_then_call(name, vec![map_ptr, key], |provider| {
data::make_map_value_ptr_with_ptr_key(provider, db, name, key_ty)
})
} else {
unreachable!()
}
}
fn aggregate_init(
&mut self,
db: &dyn CodegenDb,
ptr: yul::Expression,
args: Vec<yul::Expression>,
ptr_ty: TypeId,
arg_tys: Vec<TypeId>,
) -> yul::Expression {
debug_assert!(ptr_ty.is_ptr(db.upcast()));
let name = format!("$aggregate_init_{}", ptr_ty.0);
let args = std::iter::once(ptr).chain(args.into_iter()).collect();
let legalized_ty = db.codegen_legalized_type(ptr_ty);
self.create_then_call(&name, args, |provider| {
data::make_aggregate_init(provider, db, &name, legalized_ty, arg_tys)
})
}
fn string_copy(
&mut self,
db: &dyn CodegenDb,
dst: yul::Expression,
data: &str,
is_dst_storage: bool,
) -> yul::Expression {
debug_assert!(data.is_ascii());
let symbol_name = db.codegen_constant_string_symbol_name(data.to_string());
let name = if is_dst_storage {
format!("$string_copy_{}_storage", symbol_name)
} else {
format!("$string_copy_{}_memory", symbol_name)
};
self.create_then_call(&name, vec![dst], |provider| {
data::make_string_copy(provider, db, &name, data, is_dst_storage)
})
}
fn string_construct(
&mut self,
db: &dyn CodegenDb,
data: &str,
string_len: usize,
) -> yul::Expression {
debug_assert!(data.is_ascii());
debug_assert!(string_len >= data.len());
let symbol_name = db.codegen_constant_string_symbol_name(data.to_string());
let name = format!("$string_construct_{}", symbol_name);
let arg = literal_expression!((32 + string_len));
self.create_then_call(&name, vec![arg], |provider| {
data::make_string_construct(provider, db, &name, data)
})
}
fn ptr_copy(
&mut self,
_db: &dyn CodegenDb,
src: yul::Expression,
dst: yul::Expression,
size: yul::Expression,
is_src_storage: bool,
is_dst_storage: bool,
) -> yul::Expression {
let args = vec![src, dst, size];
match (is_src_storage, is_dst_storage) {
(true, true) => {
let name = "scopys";
self.create_then_call(name, args, |_| data::make_scopys(name))
}
(true, false) => {
let name = "scopym";
self.create_then_call(name, args, |_| data::make_scopym(name))
}
(false, true) => {
let name = "mcopys";
self.create_then_call(name, args, |_| data::make_mcopys(name))
}
(false, false) => {
let name = "mcopym";
self.create_then_call(name, args, |_| data::make_mcopym(name))
}
}
}
fn ptr_store(
&mut self,
db: &dyn CodegenDb,
ptr: yul::Expression,
imm: yul::Expression,
ptr_ty: TypeId,
) -> yul::Expression {
debug_assert!(ptr_ty.is_ptr(db.upcast()));
let size = ptr_ty.deref(db.upcast()).size_of(db.upcast(), SLOT_SIZE);
debug_assert!(size <= 32);
let size_bits = size * 8;
if ptr_ty.is_sptr(db.upcast()) {
let name = "$sptr_store";
let args = vec![ptr, imm, literal_expression! {(size_bits)}];
self.create_then_call(name, args, |_| data::make_sptr_store(name))
} else if ptr_ty.is_mptr(db.upcast()) {
let name = "$mptr_store";
let shift_num = literal_expression! {(256 - size_bits)};
let mask = BitMask::new(32 - size);
let args = vec![ptr, imm, shift_num, mask.as_expr()];
self.create_then_call(name, args, |_| data::make_mptr_store(name))
} else {
unreachable!()
}
}
fn ptr_load(
&mut self,
db: &dyn CodegenDb,
ptr: yul::Expression,
ptr_ty: TypeId,
) -> yul::Expression {
debug_assert!(ptr_ty.is_ptr(db.upcast()));
let size = ptr_ty.deref(db.upcast()).size_of(db.upcast(), SLOT_SIZE);
debug_assert!(size <= 32);
let size_bits = size * 8;
if ptr_ty.is_sptr(db.upcast()) {
let name = "$sptr_load";
let args = vec![ptr, literal_expression! {(size_bits)}];
self.create_then_call(name, args, |_| data::make_sptr_load(name))
} else if ptr_ty.is_mptr(db.upcast()) {
let name = "$mptr_load";
let shift_num = literal_expression! {(256 - size_bits)};
let args = vec![ptr, shift_num];
self.create_then_call(name, args, |_| data::make_mptr_load(name))
} else {
unreachable!()
}
}
fn abi_encode(
&mut self,
db: &dyn CodegenDb,
src: yul::Expression,
dst: yul::Expression,
src_ty: TypeId,
is_dst_storage: bool,
) -> yul::Expression {
let legalized_ty = db.codegen_legalized_type(src_ty);
let args = vec![src.clone(), dst.clone()];
let func_name_postfix = if is_dst_storage { "storage" } else { "memory" };
if legalized_ty.is_primitive(db.upcast()) {
let name = format!(
"$abi_encode_primitive_type_{}_to_{}",
src_ty.0, func_name_postfix
);
return self.create_then_call(&name, args, |provider| {
abi::make_abi_encode_primitive_type(
provider,
db,
&name,
legalized_ty,
is_dst_storage,
)
});
}
let deref_ty = legalized_ty.deref(db.upcast());
let abi_ty = db.codegen_abi_type(deref_ty);
if abi_ty.is_primitive() {
let value = self.ptr_load(db, src, src_ty);
let extended_value = self.primitive_cast(db, value, deref_ty);
self.abi_encode(db, extended_value, dst, deref_ty, is_dst_storage)
} else if abi_ty.is_static() {
if deref_ty.is_array(db.upcast()) {
let name = format!(
"$abi_encode_static_array_type_{}_to_{}",
src_ty.0, func_name_postfix
);
self.create_then_call(&name, args, |provider| {
abi::make_abi_encode_static_array_type(provider, db, &name, legalized_ty)
})
} else {
let name = format!(
"$abi_encode_static_aggregate_type_{}_to_{}",
src_ty.0, func_name_postfix
);
self.create_then_call(&name, args, |provider| {
abi::make_abi_encode_static_aggregate_type(provider, db, &name, legalized_ty)
})
}
} else if abi_ty.is_string() {
let name = format! {"$abi_encode_string_type_to_{}", func_name_postfix};
self.create_then_call(&name, args, |provider| {
abi::make_abi_encode_string_type(provider, db, &name, is_dst_storage)
})
} else if abi_ty.is_bytes() {
let len = match &deref_ty.data(db.upcast()).kind {
TypeKind::Array(ArrayDef { len, .. }) => *len,
_ => unreachable!(),
};
let name = format! {"$abi_encode_bytes{}_type_to_{}", len, func_name_postfix};
self.create_then_call(&name, args, |provider| {
abi::make_abi_encode_bytes_type(provider, db, &name, len, is_dst_storage)
})
} else {
todo! {}
}
}
fn abi_encode_seq(
&mut self,
db: &dyn CodegenDb,
src: &[yul::Expression],
dst: yul::Expression,
src_tys: &[TypeId],
is_dst_storage: bool,
) -> yul::Expression {
let mut name = "$abi_encode_value_seq".to_string();
for ty in src_tys {
write!(&mut name, "_{}", ty.0).unwrap();
}
let mut args = vec![dst];
args.extend(src.iter().cloned());
self.create_then_call(&name, args, |provider| {
abi::make_abi_encode_value_seq(provider, db, &name, src_tys, is_dst_storage)
})
}
fn abi_decode(
&mut self,
db: &dyn CodegenDb,
src: yul::Expression,
size: yul::Expression,
types: &[TypeId],
abi_loc: AbiSrcLocation,
) -> yul::Expression {
let mut name = "$abi_decode_seq".to_string();
for ty in types {
write!(name, "_{}", ty.0).unwrap();
}
match abi_loc {
AbiSrcLocation::CallData => write!(name, "_from_calldata").unwrap(),
AbiSrcLocation::Memory => write!(name, "_from_memory").unwrap(),
};
self.create_then_call(&name, vec![src, size], |provider| {
abi::make_abi_decode(provider, db, &name, types, abi_loc)
})
}
fn safe_add(
&mut self,
db: &dyn CodegenDb,
lhs: yul::Expression,
rhs: yul::Expression,
ty: TypeId,
) -> yul::Expression {
debug_assert!(ty.is_integral(db.upcast()));
safe_math::dispatch_safe_add(self, db, lhs, rhs, ty)
}
fn safe_sub(
&mut self,
db: &dyn CodegenDb,
lhs: yul::Expression,
rhs: yul::Expression,
ty: TypeId,
) -> yul::Expression {
debug_assert!(ty.is_integral(db.upcast()));
safe_math::dispatch_safe_sub(self, db, lhs, rhs, ty)
}
fn safe_mul(
&mut self,
db: &dyn CodegenDb,
lhs: yul::Expression,
rhs: yul::Expression,
ty: TypeId,
) -> yul::Expression {
debug_assert!(ty.is_integral(db.upcast()));
safe_math::dispatch_safe_mul(self, db, lhs, rhs, ty)
}
fn safe_div(
&mut self,
db: &dyn CodegenDb,
lhs: yul::Expression,
rhs: yul::Expression,
ty: TypeId,
) -> yul::Expression {
debug_assert!(ty.is_integral(db.upcast()));
safe_math::dispatch_safe_div(self, db, lhs, rhs, ty)
}
fn safe_mod(
&mut self,
db: &dyn CodegenDb,
lhs: yul::Expression,
rhs: yul::Expression,
ty: TypeId,
) -> yul::Expression {
debug_assert!(ty.is_integral(db.upcast()));
safe_math::dispatch_safe_mod(self, db, lhs, rhs, ty)
}
fn safe_pow(
&mut self,
db: &dyn CodegenDb,
lhs: yul::Expression,
rhs: yul::Expression,
ty: TypeId,
) -> yul::Expression {
debug_assert!(ty.is_integral(db.upcast()));
safe_math::dispatch_safe_pow(self, db, lhs, rhs, ty)
}
}
#[derive(Debug)]
struct RuntimeFunction(yul::FunctionDefinition);
impl RuntimeFunction {
fn arg_num(&self) -> usize {
self.0.parameters.len()
}
fn definition(&self) -> yul::FunctionDefinition {
self.0.clone()
}
/// # Panics
/// Panics if a number of arguments doesn't match the definition.
fn call(&self, args: Vec<yul::Expression>) -> yul::Expression {
debug_assert_eq!(self.arg_num(), args.len());
yul::Expression::FunctionCall(yul::FunctionCall {
identifier: self.0.name.clone(),
arguments: args,
})
}
/// Remove this when `yultsur::function_definition!` becomes to return
/// `FunctionDefinition`.
fn from_statement(func: yul::Statement) -> Self {
match func {
yul::Statement::FunctionDefinition(def) => Self(def),
_ => unreachable!(),
}
}
}
fn make_ptr(db: &dyn CodegenDb, inner: TypeId, is_sptr: bool) -> TypeId {
if is_sptr {
inner.make_sptr(db.upcast())
} else {
inner.make_mptr(db.upcast())
}
}
struct BitMask(BigInt);
impl BitMask {
fn new(byte_size: usize) -> Self {
debug_assert!(byte_size <= 32);
let one: BigInt = 1usize.into();
Self((one << (byte_size * 8)) - 1)
}
fn not(&self) -> Self {
// Bigint is variable length integer, so we need special handling for `not`
// operation.
let one: BigInt = 1usize.into();
let u256_max = (one << 256) - 1;
Self(u256_max ^ &self.0)
}
fn as_expr(&self) -> yul::Expression {
let mask = format!("{:#x}", self.0);
literal_expression! {(mask)}
}
}
pub(super) fn error_revert_numeric(
provider: &mut dyn RuntimeProvider,
db: &dyn CodegenDb,
error_code: yul::Expression,
) -> yul::Statement {
yul::Statement::Expression(provider.revert(
db,
Some(error_code),
"Error",
yul_primitive_type(db),
))
}
pub(super) fn panic_revert_numeric(
provider: &mut dyn RuntimeProvider,
db: &dyn CodegenDb,
error_code: yul::Expression,
) -> yul::Statement {
yul::Statement::Expression(provider.revert(
db,
Some(error_code),
"Panic",
yul_primitive_type(db),
))
}