forked from rust-lang/rustc_codegen_c
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmisc.rs
53 lines (42 loc) · 1.44 KB
/
misc.rs
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
use std::cell::RefCell;
use rustc_codegen_c_ast::expr::CValue;
use rustc_codegen_ssa::traits::MiscMethods;
use rustc_hash::FxHashMap;
use rustc_middle::mir::mono::CodegenUnit;
use rustc_middle::ty::{Instance, PolyExistentialTraitRef, Ty};
use crate::context::CodegenCx;
impl<'tcx, 'mx> MiscMethods<'tcx> for CodegenCx<'tcx, 'mx> {
fn vtables(
&self,
) -> &RefCell<FxHashMap<(Ty<'tcx>, Option<PolyExistentialTraitRef<'tcx>>), Self::Value>> {
todo!()
}
fn get_fn(&self, instance: Instance<'tcx>) -> Self::Function {
*self.function_instances.borrow().get(&instance).unwrap()
}
fn get_fn_addr(&self, instance: Instance<'tcx>) -> Self::Value {
let funcs = self.mcx.module().funcs.borrow();
let path = self.tcx.def_path_debug_str(instance.def_id());
let name = path.split("::").last().unwrap();
let func = funcs.iter().find(|f| f.0.name == name).unwrap();
CValue::Func(func.0.name)
}
fn eh_personality(&self) -> Self::Value {
todo!()
}
fn sess(&self) -> &rustc_session::Session {
self.tcx.sess
}
fn codegen_unit(&self) -> &'tcx CodegenUnit<'tcx> {
todo!()
}
fn set_frame_pointer_type(&self, llfn: Self::Function) {
todo!()
}
fn apply_target_cpu_attr(&self, llfn: Self::Function) {
todo!()
}
fn declare_c_main(&self, fn_type: Self::Type) -> Option<Self::Function> {
todo!()
}
}