fix bug in shape where s_int/s_uint were not customized to platform

This commit is contained in:
Niko Matsakis 2011-11-14 19:37:35 -08:00
parent 9043bd9778
commit b27a88e99c
2 changed files with 29 additions and 12 deletions

View file

@ -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});

View file

@ -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];