about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2011-11-14 19:37:35 -0800
committerNiko Matsakis <niko@alum.mit.edu>2011-11-16 15:16:43 -0800
commitb27a88e99c2ab011ebc2fcaa8a8943bcfc0b3065 (patch)
tree36953a9f149dc4688d8d7df125af1f6ef2ba6137
parent9043bd97788bd6643c095952516670ce954a1777 (diff)
downloadrust-b27a88e99c2ab011ebc2fcaa8a8943bcfc0b3065.tar.gz
rust-b27a88e99c2ab011ebc2fcaa8a8943bcfc0b3065.zip
fix bug in shape where s_int/s_uint were not customized to platform
-rw-r--r--src/comp/middle/ast_map.rs8
-rw-r--r--src/comp/middle/shape.rs33
2 files changed, 29 insertions, 12 deletions
diff --git a/src/comp/middle/ast_map.rs b/src/comp/middle/ast_map.rs
index fcf30a7b255..1ed720322f3 100644
--- a/src/comp/middle/ast_map.rs
+++ b/src/comp/middle/ast_map.rs
@@ -158,7 +158,7 @@ fn node_span(node: ast_node) -> codemap::span {
 mod test {
     import syntax::ast_util;
 
-    //FIXME NDM #[test]
+    #[test]
     fn test_node_span_item() {
         let expected: codemap::span = ast_util::mk_sp(20u, 30u);
         let node =
@@ -170,7 +170,7 @@ mod test {
         assert (node_span(node) == expected);
     }
 
-    //FIXME NDM #[test]
+    #[test]
     fn test_node_span_obj_ctor() {
         let expected: codemap::span = ast_util::mk_sp(20u, 30u);
         let node =
@@ -182,7 +182,7 @@ mod test {
         assert (node_span(node) == expected);
     }
 
-    //FIXME NDM #[test]
+    #[test]
     fn test_node_span_native_item() {
         let expected: codemap::span = ast_util::mk_sp(20u, 30u);
         let node =
@@ -194,7 +194,7 @@ mod test {
         assert (node_span(node) == expected);
     }
 
-    //FIXME NDM #[test]
+    #[test]
     fn test_node_span_expr() {
         let expected: codemap::span = ast_util::mk_sp(20u, 30u);
         let node = node_expr(@{id: 0, node: expr_break, span: expected});
diff --git a/src/comp/middle/shape.rs b/src/comp/middle/shape.rs
index 42435d808f4..de12ea36b93 100644
--- a/src/comp/middle/shape.rs
+++ b/src/comp/middle/shape.rs
@@ -3,6 +3,7 @@
 
 import lib::llvm::True;
 import lib::llvm::llvm::{ModuleRef, TypeRef, ValueRef};
+import driver::session;
 import middle::{trans, trans_common};
 import middle::trans_common::{crate_ctxt, val_ty, C_bytes,
                               C_named_struct, C_struct};
@@ -231,16 +232,32 @@ fn tag_kind(ccx: @crate_ctxt, did: ast::def_id) -> tag_kind {
 
 
 // Returns the code corresponding to the pointer size on this architecture.
-fn s_int(_tcx: ty_ctxt) -> u8 {
-    ret shape_i32; // TODO: x86-64
+fn s_int(tcx: ty_ctxt) -> u8 {
+    ret alt tcx.sess.get_targ_cfg().arch {
+        session::arch_x86. { shape_i32 }
+        session::arch_x86_64. { shape_i64 }
+        session::arch_arm. { shape_i32 }
+    };
 }
 
-fn s_uint(_tcx: ty_ctxt) -> u8 {
-    ret shape_u32; // TODO: x86-64
+fn s_uint(tcx: ty_ctxt) -> u8 {
+    ret alt tcx.sess.get_targ_cfg().arch {
+        session::arch_x86. { shape_u32 }
+        session::arch_x86_64. { shape_u64 }
+        session::arch_arm. { shape_u32 }
+    };
 }
 
-fn s_float(_tcx: ty_ctxt) -> u8 {
-    ret shape_f64; // TODO: x86-64
+fn s_float(tcx: ty_ctxt) -> u8 {
+    ret alt tcx.sess.get_targ_cfg().arch {
+        session::arch_x86. { shape_f64 }
+        session::arch_x86_64. { shape_f64 }
+        session::arch_arm. { shape_f64 }
+    };
+}
+
+fn s_variant_tag_t(tcx: ty_ctxt) -> u8 {
+    ret s_int(tcx);
 }
 
 fn mk_ctxt(llmod: ModuleRef) -> ctxt {
@@ -329,9 +346,9 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t, ty_param_map: [uint],
         alt tag_kind(ccx, did) {
           tk_unit. {
             // FIXME: For now we do this.
-            s += [shape_u32];
+            s += [s_variant_tag_t(ccx.tcx)];
           }
-          tk_enum. { s += [shape_u32]; }
+          tk_enum. { s += [s_variant_tag_t(ccx.tcx)]; }
           tk_complex. {
             s += [shape_tag];