forked from argotorg/fe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.rs
More file actions
25 lines (19 loc) · 897 Bytes
/
Copy pathfunction.rs
File metadata and controls
25 lines (19 loc) · 897 Bytes
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
use std::rc::Rc;
use fe_mir::ir::{FunctionBody, FunctionId, FunctionSignature};
use crate::{db::CodegenDb, yul::legalize};
pub fn legalized_signature(db: &dyn CodegenDb, function: FunctionId) -> Rc<FunctionSignature> {
let mut sig = function.signature(db.upcast()).as_ref().clone();
legalize::legalize_func_signature(db, &mut sig);
sig.into()
}
pub fn legalized_body(db: &dyn CodegenDb, function: FunctionId) -> Rc<FunctionBody> {
let mut body = function.body(db.upcast()).as_ref().clone();
legalize::legalize_func_body(db, &mut body);
body.into()
}
pub fn symbol_name(db: &dyn CodegenDb, function: FunctionId) -> Rc<String> {
let module = function.signature(db.upcast()).module_id;
let module_name = module.name(db.upcast());
let func_name = function.name_with_class(db.upcast()).replace("::", "$");
format!("{}${}", module_name, func_name).into()
}