Use unboxed vecs for string shape glue.

This commit is contained in:
Michael Sullivan 2012-06-18 14:51:50 -07:00
parent 88ec259cee
commit 797856cbde
5 changed files with 5 additions and 12 deletions

View File

@ -43,6 +43,7 @@ const uint8_t SHAPE_I64 = 7u;
const uint8_t SHAPE_F32 = 8u;
const uint8_t SHAPE_F64 = 9u;
const uint8_t SHAPE_BOX = 10u;
// FIXME: remove after snapshot (6/18/12)
const uint8_t SHAPE_VEC = 11u;
const uint8_t SHAPE_TAG = 12u;
const uint8_t SHAPE_STRUCT = 17u;

View File

@ -78,7 +78,6 @@ fn new_nominal_id_hash<T: copy>() -> hashmap<nominal_id, T> {
const shape_f32: u8 = 8u8;
const shape_f64: u8 = 9u8;
const shape_box: u8 = 10u8;
const shape_vec: u8 = 11u8;
const shape_enum: u8 = 12u8;
const shape_struct: u8 = 17u8;
const shape_box_fn: u8 = 18u8;
@ -226,14 +225,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> [u8] {
ty::ty_float(ast::ty_f64) { [shape_f64] }
ty::ty_estr(ty::vstore_uniq) |
ty::ty_str {
// FIXME: we want to emit this as a unique pointer to an unboxed vec,
// but it doesn't work at the moment, since trans doesn't put
// tydescs in string boxes...
let mut s = [shape_vec];
add_bool(s, true); // type is POD
let unit_ty = ty::mk_mach_uint(ccx.tcx, ast::ty_u8);
add_substr(s, shape_of(ccx, unit_ty));
s
shape_of(ccx, tvec::expand_boxed_vec_ty(ccx.tcx, t))
}
ty::ty_enum(did, substs) {
alt enum_kind(ccx, did) {

View File

@ -12,7 +12,7 @@ fn check_log<T>(exp: str, v: T) {
fn main() {
let x = list::from_vec([a(22u), b("hi")]);
let exp = "@cons(a(22), @cons(b(\"hi\"), @nil))";
let exp = "@cons(a(22), @cons(b(~\"hi\"), @nil))";
assert #fmt["%?", x] == exp;
check_log(exp, x);
}

View File

@ -6,6 +6,6 @@ enum foo {
fn main() {
assert "a(22)" == #fmt["%?", a(22u)];
assert "b(\"hi\")" == #fmt["%?", b("hi")];
assert "b(~\"hi\")" == #fmt["%?", b("hi")];
assert "c" == #fmt["%?", c];
}

View File

@ -1,4 +1,4 @@
fn main() {
assert "~[1, 2, 3]" == sys::log_str([1, 2, 3]);
assert #fmt["%?/%5?", [1, 2, 3], "hi"] == "~[1, 2, 3]/ \"hi\"";
assert #fmt["%?/%6?", [1, 2, 3], "hi"] == "~[1, 2, 3]/ ~\"hi\"";
}