From c53d58f92395b2168dbc94b45bc472430a20ee26 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 24 Jun 2018 14:25:29 +0200 Subject: [PATCH] Implement some traits for FunctionCx --- src/common.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/common.rs b/src/common.rs index d753255bfa9..8a8e29bbda5 100644 --- a/src/common.rs +++ b/src/common.rs @@ -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(&self, value: &T) -> T where T: TypeFoldable<'tcx>