Implement some traits for FunctionCx

This commit is contained in:
bjorn3 2018-06-24 14:25:29 +02:00
parent f62381865f
commit c53d58f923

View File

@ -1,4 +1,7 @@
extern crate rustc_target;
use syntax::ast::{IntTy, UintTy};
use self::rustc_target::spec::{HasTargetSpec, Target};
use cretonne_module::{Module, Linkage, FuncId};
@ -277,6 +280,24 @@ impl<'a, 'tcx: 'a> LayoutOf for &'a FunctionCx<'a, 'tcx> {
}
}
impl<'a, 'tcx> layout::HasTyCtxt<'tcx> for &'a FunctionCx<'a, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx, 'tcx> {
self.tcx
}
}
impl<'a, 'tcx> layout::HasDataLayout for &'a FunctionCx<'a, 'tcx> {
fn data_layout(&self) -> &layout::TargetDataLayout {
&self.tcx.data_layout
}
}
impl<'a, 'tcx> HasTargetSpec for &'a FunctionCx<'a, 'tcx> {
fn target_spec(&self) -> &Target {
&self.tcx.sess.target.target
}
}
impl<'f, 'tcx> FunctionCx<'f, 'tcx> {
pub fn monomorphize<T>(&self, value: &T) -> T
where T: TypeFoldable<'tcx>