Merge branch 'rt-changes' into incoming

This commit is contained in:
Michael Sullivan
2012-07-12 10:28:43 -07:00
28 changed files with 116 additions and 204 deletions

View File

@@ -10,9 +10,8 @@ export log_str;
export lock_and_signal, condition, methods; export lock_and_signal, condition, methods;
enum type_desc = { enum type_desc = {
first_param: **libc::c_int, size: uint,
size: libc::size_t, align: uint
align: libc::size_t
// Remaining fields not listed // Remaining fields not listed
}; };

View File

@@ -31,11 +31,11 @@ impl arena for arena {
head = chunk(uint::next_power_of_two(new_min_chunk_size + 1u)); head = chunk(uint::next_power_of_two(new_min_chunk_size + 1u));
self.chunks = @cons(head, self.chunks); self.chunks = @cons(head, self.chunks);
ret self.alloc(n_bytes, align); ret self.alloc_inner(n_bytes, align);
} }
#[inline(always)] #[inline(always)]
fn alloc(n_bytes: uint, align: uint) -> *() { fn alloc_inner(n_bytes: uint, align: uint) -> *() {
let alignm1 = align - 1u; let alignm1 = align - 1u;
let mut head = list::head(self.chunks); let mut head = list::head(self.chunks);
@@ -52,5 +52,13 @@ impl arena for arena {
ret unsafe::reinterpret_cast(p); ret unsafe::reinterpret_cast(p);
} }
} }
#[inline(always)]
fn alloc(tydesc: *()) -> *() {
unsafe {
let tydesc = tydesc as *sys::type_desc;
self.alloc_inner((*tydesc).size, (*tydesc).align)
}
}
} }

View File

@@ -459,7 +459,6 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map,
~[] ~[]
} }
ast::ty_vstore(@{node: ast::ty_vec(mt),_}, ast::vstore_uniq) |
ast::ty_vec(mt) { ast::ty_vec(mt) {
let ser_e = let ser_e =
cx.expr( cx.expr(
@@ -477,6 +476,11 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map,
}] }]
} }
// For unique vstores, just pass through to the underlying vec or str
ast::ty_vstore(ty, ast::vstore_uniq) {
ser_ty(cx, tps, ty, s, v)
}
ast::ty_vstore(_, _) { ast::ty_vstore(_, _) {
cx.span_unimpl(ty.span, "serialization for vstore types"); cx.span_unimpl(ty.span, "serialization for vstore types");
} }
@@ -685,12 +689,16 @@ fn deser_ty(cx: ext_ctxt, tps: deser_tps_map,
#ast{ fail } #ast{ fail }
} }
ast::ty_vstore(@{node: ast::ty_vec(mt),_}, ast::vstore_uniq) |
ast::ty_vec(mt) { ast::ty_vec(mt) {
let l = deser_lambda(cx, tps, mt.ty, cx.clone(d)); let l = deser_lambda(cx, tps, mt.ty, cx.clone(d));
#ast{ std::serialization::read_to_vec($(d), $(l)) } #ast{ std::serialization::read_to_vec($(d), $(l)) }
} }
// For unique vstores, just pass through to the underlying vec or str
ast::ty_vstore(ty, ast::vstore_uniq) {
deser_ty(cx, tps, ty, d)
}
ast::ty_vstore(_, _) { ast::ty_vstore(_, _) {
cx.span_unimpl(ty.span, "deserialization for vstore types"); cx.span_unimpl(ty.span, "deserialization for vstore types");
} }

View File

@@ -484,8 +484,7 @@ log::walk_res2(const rust_fn *dtor, const uint8_t *end_sp) {
extern "C" void extern "C" void
shape_cmp_type(int8_t *result, const type_desc *tydesc, shape_cmp_type(int8_t *result, const type_desc *tydesc,
const type_desc **subtydescs, uint8_t *data_0, uint8_t *data_0, uint8_t *data_1, uint8_t cmp_type) {
uint8_t *data_1, uint8_t cmp_type) {
rust_task *task = rust_get_current_task(); rust_task *task = rust_get_current_task();
shape::arena arena; shape::arena arena;

View File

@@ -407,10 +407,6 @@ ctxt<T>::walk_tag0() {
// Determine the size and alignment. // Determine the size and alignment.
tinfo.tag_sa = get_size_align(tinfo.info_ptr); tinfo.tag_sa = get_size_align(tinfo.info_ptr);
// Read in a dummy value; this used to be the number of parameters
uint16_t number_of_params = get_u16_bump(sp);
assert(number_of_params == 0 && "tag has type parameters on it");
// Call to the implementation. // Call to the implementation.
static_cast<T *>(this)->walk_tag1(tinfo); static_cast<T *>(this)->walk_tag1(tinfo);
} }
@@ -489,10 +485,6 @@ ctxt<T>::walk_res0() {
reinterpret_cast<const rust_fn **>(tables->resources); reinterpret_cast<const rust_fn **>(tables->resources);
const rust_fn *dtor = resources[dtor_offset]; const rust_fn *dtor = resources[dtor_offset];
// Read in a dummy value; this used to be the number of parameters
uint16_t number_of_params = get_u16_bump(sp);
assert(number_of_params == 0 && "resource has type parameters on it");
uint16_t sp_size = get_u16_bump(sp); uint16_t sp_size = get_u16_bump(sp);
const uint8_t *end_sp = sp + sp_size; const uint8_t *end_sp = sp + sp_size;

View File

@@ -45,24 +45,15 @@ static inline void *box_body(rust_opaque_box *box) {
return (void*)(box + 1); return (void*)(box + 1);
} }
// N.B. If you want to add a field to tydesc, please use one of the
// unused fields!
struct type_desc { struct type_desc {
uintptr_t UNUSED_1;
size_t size; size_t size;
size_t align; size_t align;
glue_fn *take_glue; glue_fn *take_glue;
glue_fn *drop_glue; glue_fn *drop_glue;
glue_fn *free_glue; glue_fn *free_glue;
glue_fn *visit_glue; glue_fn *visit_glue;
uintptr_t UNUSED_2;
uintptr_t UNUSED_3;
uintptr_t UNUSED_4;
uintptr_t UNUSED_5;
const uint8_t *shape; const uint8_t *shape;
const rust_shape_tables *shape_tables; const rust_shape_tables *shape_tables;
uintptr_t UNUSED_6;
uintptr_t UNUSED_7;
}; };
extern "C" type_desc *rust_clone_type_desc(type_desc*); extern "C" type_desc *rust_clone_type_desc(type_desc*);

View File

@@ -335,59 +335,6 @@ upcall_str_new_shared(const char *cstr, size_t len) {
} }
struct s_vec_grow_args {
rust_task *task;
rust_vec_box** vp;
size_t new_sz;
};
extern "C" CDECL void
upcall_s_vec_grow(s_vec_grow_args *args) {
rust_task *task = args->task;
LOG_UPCALL_ENTRY(task);
reserve_vec(task, args->vp, args->new_sz);
(*args->vp)->body.fill = args->new_sz;
}
extern "C" CDECL void
upcall_vec_grow(rust_vec_box** vp, size_t new_sz) {
rust_task *task = rust_get_current_task();
s_vec_grow_args args = {task, vp, new_sz};
UPCALL_SWITCH_STACK(task, &args, upcall_s_vec_grow);
}
struct s_str_concat_args {
rust_task *task;
rust_vec_box* lhs;
rust_vec_box* rhs;
rust_vec_box* retval;
};
extern "C" CDECL void
upcall_s_str_concat(s_str_concat_args *args) {
rust_vec *lhs = &args->lhs->body;
rust_vec *rhs = &args->rhs->body;
rust_task *task = args->task;
size_t fill = lhs->fill + rhs->fill - 1;
rust_vec_box* v = (rust_vec_box*)
task->kernel->malloc(fill + sizeof(rust_vec_box),
"str_concat");
v->header.td = args->lhs->header.td;
v->body.fill = v->body.alloc = fill;
memmove(&v->body.data[0], &lhs->data[0], lhs->fill - 1);
memmove(&v->body.data[lhs->fill - 1], &rhs->data[0], rhs->fill);
args->retval = v;
}
extern "C" CDECL rust_vec_box*
upcall_str_concat(rust_vec_box* lhs, rust_vec_box* rhs) {
rust_task *task = rust_get_current_task();
s_str_concat_args args = {task, lhs, rhs, 0};
UPCALL_SWITCH_STACK(task, &args, upcall_s_str_concat);
return args.retval;
}
extern "C" _Unwind_Reason_Code extern "C" _Unwind_Reason_Code
__gxx_personality_v0(int version, __gxx_personality_v0(int version,
_Unwind_Action actions, _Unwind_Action actions,
@@ -444,13 +391,11 @@ upcall_rust_personality(int version,
extern "C" void extern "C" void
shape_cmp_type(int8_t *result, const type_desc *tydesc, shape_cmp_type(int8_t *result, const type_desc *tydesc,
const type_desc **subtydescs, uint8_t *data_0, uint8_t *data_0, uint8_t *data_1, uint8_t cmp_type);
uint8_t *data_1, uint8_t cmp_type);
struct s_cmp_type_args { struct s_cmp_type_args {
int8_t *result; int8_t *result;
const type_desc *tydesc; const type_desc *tydesc;
const type_desc **subtydescs;
uint8_t *data_0; uint8_t *data_0;
uint8_t *data_1; uint8_t *data_1;
uint8_t cmp_type; uint8_t cmp_type;
@@ -458,16 +403,15 @@ struct s_cmp_type_args {
extern "C" void extern "C" void
upcall_s_cmp_type(s_cmp_type_args *args) { upcall_s_cmp_type(s_cmp_type_args *args) {
shape_cmp_type(args->result, args->tydesc, args->subtydescs, shape_cmp_type(args->result, args->tydesc,
args->data_0, args->data_1, args->cmp_type); args->data_0, args->data_1, args->cmp_type);
} }
extern "C" void extern "C" void
upcall_cmp_type(int8_t *result, const type_desc *tydesc, upcall_cmp_type(int8_t *result, const type_desc *tydesc,
const type_desc **subtydescs, uint8_t *data_0, uint8_t *data_0, uint8_t *data_1, uint8_t cmp_type) {
uint8_t *data_1, uint8_t cmp_type) {
rust_task *task = rust_get_current_task(); rust_task *task = rust_get_current_task();
s_cmp_type_args args = {result, tydesc, subtydescs, s_cmp_type_args args = {result, tydesc,
data_0, data_1, cmp_type}; data_0, data_1, cmp_type};
UPCALL_SWITCH_STACK(task, &args, upcall_s_cmp_type); UPCALL_SWITCH_STACK(task, &args, upcall_s_cmp_type);
} }

View File

@@ -15,21 +15,14 @@ uint8_t str_body_shape[] = {
}; };
struct type_desc str_body_tydesc = { struct type_desc str_body_tydesc = {
0, // unused
1, // size 1, // size
1, // align 1, // align
NULL, // take_glue NULL, // take_glue
NULL, // drop_glue NULL, // drop_glue
NULL, // free_glue NULL, // free_glue
NULL, // visit_glue NULL, // visit_glue
0, // unused
0, // unused
0, // unused
0, // unused
str_body_shape, // shape str_body_shape, // shape
&empty_shape_tables, // shape_tables &empty_shape_tables, // shape_tables
0, // unused
0, // unused
}; };
// //

View File

@@ -76,11 +76,8 @@ upcall_validate_box
upcall_log_type upcall_log_type
upcall_malloc upcall_malloc
upcall_rust_personality upcall_rust_personality
upcall_vec_grow
upcall_str_new
upcall_str_new_uniq upcall_str_new_uniq
upcall_str_new_shared upcall_str_new_shared
upcall_str_concat
upcall_call_shim_on_c_stack upcall_call_shim_on_c_stack
upcall_call_shim_on_rust_stack upcall_call_shim_on_rust_stack
upcall_new_stack upcall_new_stack

View File

@@ -33,22 +33,15 @@ const box_field_body: uint = 4u;
const general_code_alignment: uint = 16u; const general_code_alignment: uint = 16u;
const tydesc_field_first_param: uint = 0u; const tydesc_field_size: uint = 0u;
const tydesc_field_size: uint = 1u; const tydesc_field_align: uint = 1u;
const tydesc_field_align: uint = 2u; const tydesc_field_take_glue: uint = 2u;
const tydesc_field_take_glue: uint = 3u; const tydesc_field_drop_glue: uint = 3u;
const tydesc_field_drop_glue: uint = 4u; const tydesc_field_free_glue: uint = 4u;
const tydesc_field_free_glue: uint = 5u; const tydesc_field_visit_glue: uint = 5u;
const tydesc_field_visit_glue: uint = 6u; const tydesc_field_shape: uint = 6u;
const tydesc_field_sever_glue: uint = 7u; const tydesc_field_shape_tables: uint = 7u;
const tydesc_field_mark_glue: uint = 8u; const n_tydesc_fields: uint = 8u;
const tydesc_field_unused2: uint = 9u;
const tydesc_field_unused_2: uint = 10u;
const tydesc_field_shape: uint = 11u;
const tydesc_field_shape_tables: uint = 12u;
const tydesc_field_n_params: uint = 13u;
const tydesc_field_obj_params: uint = 14u; // FIXME unused (#2351)
const n_tydesc_fields: uint = 15u;
const cmp_glue_op_eq: uint = 0u; const cmp_glue_op_eq: uint = 0u;

View File

@@ -16,10 +16,8 @@ type upcalls =
exchange_free: ValueRef, exchange_free: ValueRef,
validate_box: ValueRef, validate_box: ValueRef,
mark: ValueRef, mark: ValueRef,
vec_grow: ValueRef,
str_new_uniq: ValueRef, str_new_uniq: ValueRef,
str_new_shared: ValueRef, str_new_shared: ValueRef,
str_concat: ValueRef,
cmp_type: ValueRef, cmp_type: ValueRef,
log_type: ValueRef, log_type: ValueRef,
alloc_c_stack: ValueRef, alloc_c_stack: ValueRef,
@@ -71,22 +69,16 @@ fn declare_upcalls(targ_cfg: @session::config,
nothrow(dv("validate_box", ~[T_ptr(T_i8())])), nothrow(dv("validate_box", ~[T_ptr(T_i8())])),
mark: mark:
d("mark", ~[T_ptr(T_i8())], int_t), d("mark", ~[T_ptr(T_i8())], int_t),
vec_grow:
nothrow(dv("vec_grow", ~[T_ptr(T_ptr(T_i8())), int_t])),
str_new_uniq: str_new_uniq:
nothrow(d("str_new_uniq", ~[T_ptr(T_i8()), int_t], nothrow(d("str_new_uniq", ~[T_ptr(T_i8()), int_t],
T_ptr(T_i8()))), T_ptr(T_i8()))),
str_new_shared: str_new_shared:
nothrow(d("str_new_shared", ~[T_ptr(T_i8()), int_t], nothrow(d("str_new_shared", ~[T_ptr(T_i8()), int_t],
T_ptr(T_i8()))), T_ptr(T_i8()))),
str_concat:
nothrow(d("str_concat", ~[T_ptr(T_i8()),
T_ptr(T_i8())],
T_ptr(T_i8()))),
cmp_type: cmp_type:
dv("cmp_type", dv("cmp_type",
~[T_ptr(T_i1()), T_ptr(tydesc_type), ~[T_ptr(T_i1()), T_ptr(tydesc_type),
T_ptr(T_ptr(tydesc_type)), T_ptr(T_i8()), T_ptr(T_i8()),
T_ptr(T_i8()), T_ptr(T_i8()),
T_i8()]), T_i8()]),
log_type: log_type:

View File

@@ -596,21 +596,14 @@ fn emit_tydescs(ccx: @crate_ctxt) {
let tydesc = let tydesc =
C_named_struct(ccx.tydesc_type, C_named_struct(ccx.tydesc_type,
~[C_null(T_ptr(T_ptr(ccx.tydesc_type))), ~[ti.size, // size
ti.size, // size ti.align, // align
ti.align, // align take_glue, // take_glue
take_glue, // take_glue drop_glue, // drop_glue
drop_glue, // drop_glue free_glue, // free_glue
free_glue, // free_glue visit_glue, // visit_glue
visit_glue, // visit_glue C_shape(ccx, shape), // shape
C_int(ccx, 0), // unused shape_tables]); // shape_tables
C_int(ccx, 0), // unused
C_int(ccx, 0), // unused
C_int(ccx, 0), // unused
C_shape(ccx, shape), // shape
shape_tables, // shape_tables
C_int(ccx, 0), // unused
C_int(ccx, 0)]); // unused
let gvar = ti.tydesc; let gvar = ti.tydesc;
llvm::LLVMSetInitializer(gvar, tydesc); llvm::LLVMSetInitializer(gvar, tydesc);
@@ -1213,14 +1206,12 @@ fn call_cmp_glue(bcx: block, lhs: ValueRef, rhs: ValueRef, t: ty::t,
let llrawlhsptr = BitCast(bcx, lllhs, T_ptr(T_i8())); let llrawlhsptr = BitCast(bcx, lllhs, T_ptr(T_i8()));
let llrawrhsptr = BitCast(bcx, llrhs, T_ptr(T_i8())); let llrawrhsptr = BitCast(bcx, llrhs, T_ptr(T_i8()));
let lltydesc = get_tydesc_simple(bcx.ccx(), t); let lltydesc = get_tydesc_simple(bcx.ccx(), t);
let lltydescs =
Load(bcx, GEPi(bcx, lltydesc, ~[0u, abi::tydesc_field_first_param]));
let llfn = bcx.ccx().upcalls.cmp_type; let llfn = bcx.ccx().upcalls.cmp_type;
let llcmpresultptr = alloca(bcx, T_i1()); let llcmpresultptr = alloca(bcx, T_i1());
Call(bcx, llfn, ~[llcmpresultptr, lltydesc, lltydescs, Call(bcx, llfn, ~[llcmpresultptr, lltydesc,
llrawlhsptr, llrawrhsptr, llop]); llrawlhsptr, llrawrhsptr, llop]);
ret Load(bcx, llcmpresultptr); ret Load(bcx, llcmpresultptr);
} }
@@ -3702,9 +3693,9 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block {
ret trans_assign_op(bcx, e, op, dst, src); ret trans_assign_op(bcx, e, op, dst, src);
} }
ast::expr_new(pool, alloc_id, val) { ast::expr_new(pool, alloc_id, val) {
// First, call pool->alloc(sz, align) to get back a void*. Then, // First, call pool->alloc(tydesc) to get back a void*.
// cast this memory to the required type and evaluate value into // Then, cast this memory to the required type and evaluate value
// it. // into it.
let ccx = bcx.ccx(); let ccx = bcx.ccx();
// Allocate space for the ptr that will be returned from // Allocate space for the ptr that will be returned from
@@ -3715,24 +3706,21 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block {
#debug["ptr_ty = %s", ppaux::ty_to_str(tcx, ptr_ty)]; #debug["ptr_ty = %s", ppaux::ty_to_str(tcx, ptr_ty)];
#debug["ptr_ptr_val = %s", val_str(ccx.tn, ptr_ptr_val)]; #debug["ptr_ptr_val = %s", val_str(ccx.tn, ptr_ptr_val)];
let void_ty = ty::mk_ptr(tcx, {ty: ty::mk_nil(tcx), let void_ty = ty::mk_nil_ptr(tcx);
mutbl: ast::m_imm}); let llvoid_ty = type_of(ccx, void_ty);
let voidval = { let voidval = PointerCast(bcx, ptr_ptr_val, T_ptr(llvoid_ty));
let llvoid_ty = type_of(ccx, void_ty);
PointerCast(bcx, ptr_ptr_val, T_ptr(llvoid_ty))
};
#debug["voidval = %s", val_str(ccx.tn, voidval)]; #debug["voidval = %s", val_str(ccx.tn, voidval)];
let llval_ty = type_of(ccx, expr_ty(bcx, val)); let static_ti = get_tydesc(ccx, expr_ty(bcx, val));
let args = lazily_emit_all_tydesc_glue(ccx, static_ti);
~[llsize_of(ccx, llval_ty), llalign_of(ccx, llval_ty)]; let lltydesc = PointerCast(bcx, static_ti.tydesc, llvoid_ty);
let origin = bcx.ccx().maps.method_map.get(alloc_id); let origin = bcx.ccx().maps.method_map.get(alloc_id);
let bcx = trans_call_inner( let bcx = trans_call_inner(
bcx, e.info(), node_id_type(bcx, alloc_id), void_ty, bcx, e.info(), node_id_type(bcx, alloc_id), void_ty,
|bcx| impl::trans_method_callee(bcx, alloc_id, |bcx| impl::trans_method_callee(bcx, alloc_id,
pool, origin), pool, origin),
arg_vals(args), arg_vals(~[lltydesc]),
save_in(voidval)); save_in(voidval));
#debug["dest = %s", dest_str(ccx, dest)]; #debug["dest = %s", dest_str(ccx, dest)];

View File

@@ -660,10 +660,9 @@ fn T_tydesc(targ_cfg: @session::config) -> TypeRef {
let int_type = T_int(targ_cfg); let int_type = T_int(targ_cfg);
let elems = let elems =
~[tydescpp, int_type, int_type, ~[int_type, int_type,
glue_fn_ty, glue_fn_ty, glue_fn_ty, glue_fn_ty, glue_fn_ty, glue_fn_ty, glue_fn_ty, glue_fn_ty,
int_type, int_type, int_type, int_type, T_ptr(T_i8()), T_ptr(T_i8())];
T_ptr(T_i8()), T_ptr(T_i8()), int_type, int_type];
set_struct_body(tydesc, elems); set_struct_body(tydesc, elems);
ret tydesc; ret tydesc;
} }

View File

@@ -250,10 +250,6 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] {
} }
add_u16(s, id as u16); add_u16(s, id as u16);
// Hack: always encode 0 tps, since the shape glue format
// hasn't changed since we started monomorphizing.
add_u16(s, 0_u16);
s s
} }
} }
@@ -342,10 +338,6 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] {
let ri = @{did: dtor_did, parent_id: some(did), tps: tps}; let ri = @{did: dtor_did, parent_id: some(did), tps: tps};
let id = interner::intern(ccx.shape_cx.resources, ri); let id = interner::intern(ccx.shape_cx.resources, ri);
add_u16(s, id as u16); add_u16(s, id as u16);
// Hack: always encode 0 tps, since the shape glue format
// hasn't changed since we started monomorphizing.
add_u16(s, 0_u16);
}; };
for ty::class_items_as_mutable_fields(ccx.tcx, did, substs).each |f| { for ty::class_items_as_mutable_fields(ccx.tcx, did, substs).each |f| {
sub += shape_of(ccx, f.mt.ty); sub += shape_of(ccx, f.mt.ty);

View File

@@ -658,7 +658,7 @@ fn mk_mach_float(cx: ctxt, tm: ast::float_ty) -> t { mk_t(cx, ty_float(tm)) }
fn mk_char(cx: ctxt) -> t { mk_t(cx, ty_int(ast::ty_char)) } fn mk_char(cx: ctxt) -> t { mk_t(cx, ty_int(ast::ty_char)) }
fn mk_str(cx: ctxt) -> t { mk_t(cx, ty_str) } fn mk_str(cx: ctxt) -> t { mk_estr(cx, vstore_uniq) }
fn mk_estr(cx: ctxt, t: vstore) -> t { fn mk_estr(cx: ctxt, t: vstore) -> t {
mk_t(cx, ty_estr(t)) mk_t(cx, ty_estr(t))

View File

@@ -223,7 +223,7 @@ fn arg_is_argv_ty(_tcx: ty::ctxt, a: ty::arg) -> bool {
ty::ty_evec(mt, vstore_uniq) { ty::ty_evec(mt, vstore_uniq) {
if mt.mutbl != ast::m_imm { ret false; } if mt.mutbl != ast::m_imm { ret false; }
alt ty::get(mt.ty).struct { alt ty::get(mt.ty).struct {
ty::ty_str { ret true; } ty::ty_estr(vstore_uniq) { ret true; }
_ { ret false; } _ { ret false; }
} }
} }

View File

@@ -164,31 +164,30 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy>(
self: AC, rscope: RS, a_seq_ty: @ast::ty, vst: ty::vstore) -> ty::t { self: AC, rscope: RS, a_seq_ty: @ast::ty, vst: ty::vstore) -> ty::t {
let tcx = self.tcx(); let tcx = self.tcx();
let seq_ty = ast_ty_to_ty(self, rscope, a_seq_ty);
alt ty::get(seq_ty).struct { alt a_seq_ty.node {
ty::ty_vec(mt) { ast::ty_vec(mt) {
ret ty::mk_evec(tcx, mt, vst); ret ty::mk_evec(tcx, ast_mt_to_mt(self, rscope, mt), vst);
} }
ast::ty_path(path, id) {
// HACK: if we get a ~[], we assume that it was actually a alt tcx.def_map.find(id) {
// [] that got written down, and we throw away the /~... some(ast::def_prim_ty(ast::ty_str)) {
ty::ty_evec(mt, vstore_uniq) { check_path_args(tcx, path, NO_TPS | NO_REGIONS);
ret ty::mk_evec(tcx, mt, vst); ret ty::mk_estr(tcx, vst);
} }
_ {}
ty::ty_str { }
ret ty::mk_estr(tcx, vst);
}
_ {
tcx.sess.span_err(
a_seq_ty.span,
#fmt["bound not allowed on a %s",
ty::ty_sort_str(tcx, seq_ty)]);
ret seq_ty;
} }
_ {}
} }
// Get the type, just for the error message
let seq_ty = ast_ty_to_ty(self, rscope, a_seq_ty);
tcx.sess.span_err(
a_seq_ty.span,
#fmt["bound not allowed on a %s",
ty::ty_sort_str(tcx, seq_ty)]);
ret seq_ty;
} }
fn check_path_args(tcx: ty::ctxt, fn check_path_args(tcx: ty::ctxt,

View File

@@ -1631,17 +1631,15 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
some(entry) { some(entry) {
fcx.ccx.method_map.insert(alloc_id, entry); fcx.ccx.method_map.insert(alloc_id, entry);
// Check that the alloc() method has the expected type, which // Check that the alloc() method has the expected
// should be fn(sz: uint, align: uint) -> *(). // type, which should be fn(tydesc: *()) -> *().
let expected_ty = { let expected_ty = {
let ty_uint = ty::mk_uint(tcx);
let ty_nilp = ty::mk_ptr(tcx, {ty: ty::mk_nil(tcx), let ty_nilp = ty::mk_ptr(tcx, {ty: ty::mk_nil(tcx),
mutbl: ast::m_imm}); mutbl: ast::m_imm});
let m = ast::expl(ty::default_arg_mode_for_ty(ty_uint)); let m = ast::expl(ty::default_arg_mode_for_ty(ty_nilp));
ty::mk_fn(tcx, {purity: ast::impure_fn, ty::mk_fn(tcx, {purity: ast::impure_fn,
proto: ast::proto_any, proto: ast::proto_any,
inputs: ~[{mode: m, ty: ty_uint}, inputs: ~[{mode: m, ty: ty_nilp}],
{mode: m, ty: ty_uint}],
output: ty_nilp, output: ty_nilp,
ret_style: ast::return_val, ret_style: ast::return_val,
constraints: ~[]}) constraints: ~[]})

View File

@@ -1,3 +1,11 @@
S 2012-07-12 8ad4e92
macos-i386 b31efba34f0af7ce527adc49cd345548da528ccf
macos-x86_64 ef82309eb8ba269091fbe5f41a1e28fa3c6da90e
freebsd-x86_64 2a6471cf27a9d03637b96aa12f39736f663312e3
linux-i386 94f77c50d753816df8c42608054a8cc3112ef34c
linux-x86_64 6d95183ceace8ae009b0d43a8df3a9cf13ad85a2
winnt-i386 90edcaf74134a12d656898605c67551931830fcd
S 2012-07-06 b5f5676 S 2012-07-06 b5f5676
macos-i386 c0f36f05f84696b98243046d0ebcb0fcc84995e7 macos-i386 c0f36f05f84696b98243046d0ebcb0fcc84995e7
macos-x86_64 b2bc7ba068de0ca426dfe7ae018ae3c6442fc0a5 macos-x86_64 b2bc7ba068de0ca426dfe7ae018ae3c6442fc0a5

View File

@@ -1,4 +1,4 @@
// error-pattern:expected `str` but found `int` // error-pattern:expected `str/~` but found `int`
const i: str = 10i; const i: str = 10i;
fn main() { log(debug, i); } fn main() { log(debug, i); }

View File

@@ -1,3 +1,3 @@
// error-pattern:^ cannot be applied to type `str` // error-pattern:^ cannot be applied to type `str/~`
fn main() { let x = "a" ^ "b"; } fn main() { let x = "a" ^ "b"; }

View File

@@ -1,2 +1,2 @@
// error-pattern:expected `str` but found `~[int]` // error-pattern:expected `str/~` but found `~[int]`
fn main() { fail ~[0i]; } fn main() { fail ~[0i]; }

View File

@@ -8,5 +8,5 @@ import std::map::map;
fn main() { fn main() {
let x: map<str,str> = map::str_hash::<str>() as map::<str,str>; let x: map<str,str> = map::str_hash::<str>() as map::<str,str>;
let y: map<uint,str> = x; let y: map<uint,str> = x;
//~^ ERROR mismatched types: expected `std::map::map<uint,str>` //~^ ERROR mismatched types: expected `std::map::map<uint,str/~>`
} }

View File

@@ -1,3 +1,3 @@
// error-pattern:cannot apply unary operator `-` to type `str` // error-pattern:cannot apply unary operator `-` to type `str/~`
fn main() { -"foo"; } fn main() { -"foo"; }

View File

@@ -3,7 +3,7 @@
fn foo(f: fn()) { f() } fn foo(f: fn()) { f() }
fn main() { fn main() {
"" || 42; //~ ERROR binary operation || cannot be applied to type `str` "" || 42; //~ ERROR binary operation || cannot be applied to type `str/~`
foo || {}; //~ ERROR binary operation || cannot be applied to type `extern fn(fn())` foo || {}; //~ ERROR binary operation || cannot be applied to type `extern fn(fn())`
//~^ NOTE did you forget the 'do' keyword for the call? //~^ NOTE did you forget the 'do' keyword for the call?
} }

View File

@@ -11,5 +11,5 @@ impl methods for malloc_pool {
fn main() { fn main() {
let p = &malloc_pool(()); let p = &malloc_pool(());
let x = new(*p) 4u; let x = new(*p) 4u;
//~^ ERROR mismatched types: expected `fn(uint, uint) -> *()` //~^ ERROR mismatched types: expected `fn(*()) -> *()`
} }

View File

@@ -3,11 +3,17 @@ import libc, unsafe;
enum malloc_pool = (); enum malloc_pool = ();
impl methods for malloc_pool { impl methods for malloc_pool {
fn alloc(sz: uint, align: uint) -> *() { fn alloc_inner(sz: uint, align: uint) -> *() {
unsafe { unsafe {
unsafe::reinterpret_cast(libc::malloc(sz as libc::size_t)) unsafe::reinterpret_cast(libc::malloc(sz as libc::size_t))
} }
} }
fn alloc(tydesc: *()) -> *() {
unsafe {
let tydesc = tydesc as *sys::type_desc;
self.alloc_inner((*tydesc).size, (*tydesc).align)
}
}
} }
fn main() { fn main() {

View File

@@ -16,9 +16,15 @@ type ccx = {
}; };
impl arena for arena { impl arena for arena {
fn alloc(sz: uint, _align: uint) -> *() unsafe { fn alloc_inner(sz: uint, _align: uint) -> *() unsafe {
ret unsafe::reinterpret_cast(libc::malloc(sz as libc::size_t)); ret unsafe::reinterpret_cast(libc::malloc(sz as libc::size_t));
} }
fn alloc(tydesc: *()) -> *() {
unsafe {
let tydesc = tydesc as *sys::type_desc;
self.alloc_inner((*tydesc).size, (*tydesc).align)
}
}
} }
fn h(bcx : &bcx) -> &bcx { fn h(bcx : &bcx) -> &bcx {