]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/middle/trans/common.rs
auto merge of #15999 : Kimundi/rust/fix_folder, r=nikomatsakis
[rust.git] / src / librustc / middle / trans / common.rs
index 945185f59534208593556a85b663f67dd119ab6d..71ddc2e40459c241ff48727876e23d99e7ac98b0 100644 (file)
@@ -71,7 +71,8 @@ pub fn type_is_immediate(ccx: &CrateContext, ty: ty::t) -> bool {
     }
     match ty::get(ty).sty {
         ty::ty_bot => true,
-        ty::ty_struct(..) | ty::ty_enum(..) | ty::ty_tup(..) => {
+        ty::ty_struct(..) | ty::ty_enum(..) | ty::ty_tup(..) |
+        ty::ty_unboxed_closure(..) => {
             let llty = sizing_type_of(ccx, ty);
             llsize_of_alloc(ccx, llty) <= llsize_of_alloc(ccx, ccx.int_type)
         }
@@ -220,6 +221,12 @@ fn substp(&self, tcx: &ty::ctxt, substs: &param_substs) -> T {
 pub type RvalueDatum = datum::Datum<datum::Rvalue>;
 pub type LvalueDatum = datum::Datum<datum::Lvalue>;
 
+#[deriving(Clone, Eq, PartialEq)]
+pub enum HandleItemsFlag {
+    IgnoreItems,
+    TranslateItems,
+}
+
 // Function context.  Every LLVM function we create will have one of
 // these.
 pub struct FunctionContext<'a> {
@@ -288,6 +295,9 @@ pub struct FunctionContext<'a> {
 
     // Cleanup scopes.
     pub scopes: RefCell<Vec<cleanup::CleanupScope<'a>> >,
+
+    // How to handle items encountered during translation of this function.
+    pub handle_items: HandleItemsFlag,
 }
 
 impl<'a> FunctionContext<'a> {
@@ -632,12 +642,6 @@ pub fn C_bytes(ccx: &CrateContext, bytes: &[u8]) -> ValueRef {
     }
 }
 
-pub fn get_param(fndecl: ValueRef, param: uint) -> ValueRef {
-    unsafe {
-        llvm::LLVMGetParam(fndecl, param as c_uint)
-    }
-}
-
 pub fn const_get_elt(cx: &CrateContext, v: ValueRef, us: &[c_uint])
                   -> ValueRef {
     unsafe {
@@ -792,6 +796,9 @@ pub fn resolve_vtable_under_param_substs(tcx: &ty::ctxt,
         typeck::vtable_param(n_param, n_bound) => {
             find_vtable(tcx, param_substs, n_param, n_bound)
         }
+        typeck::vtable_unboxed_closure(def_id) => {
+            typeck::vtable_unboxed_closure(def_id)
+        }
         typeck::vtable_error => typeck::vtable_error
     }
 }