diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index ec51e8e691b..d700611ac4a 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -560,6 +560,25 @@ fn T_opaque_vec_ptr() -> TypeRef { ret T_ptr(T_vec(T_int())); } +// Interior vector. +// +// TODO: Support user-defined vector sizes. +fn T_ivec(TypeRef t) -> TypeRef { + ret T_struct([T_int(), // Length ("fill") + T_int(), // Alloc (if zero, it's heapified) + T_array(t, 16u) // Body elements + ]); +} + +// Interior vector on the heap. Cast to this when the allocated length (second +// element of T_ivec above) is zero. +fn T_ivec_heap(TypeRef t) -> TypeRef { + ret T_struct([T_int(), // Length ("fill") + T_int(), // Alloc (zero in this case) + T_ptr(T_struct([T_int(), // Real alloc + T_array(t, 0u)]))]); // Body elements +} + fn T_str() -> TypeRef { ret T_vec(T_i8()); } @@ -834,6 +853,7 @@ fn type_of_inner(&@crate_ctxt cx, &span sp, &ty::t t) -> TypeRef { } case (ty::ty_char) { llty = T_char(); } case (ty::ty_str) { llty = T_ptr(T_str()); } + case (ty::ty_istr) { llty = T_ivec(T_i8()); } case (ty::ty_tag(_, _)) { if (ty::type_has_dynamic_size(cx.tcx, t)) { llty = T_opaque_tag(cx.tn); @@ -848,6 +868,9 @@ fn type_of_inner(&@crate_ctxt cx, &span sp, &ty::t t) -> TypeRef { case (ty::ty_vec(?mt)) { llty = T_ptr(T_vec(type_of_inner(cx, sp, mt.ty))); } + case (ty::ty_ivec(?mt)) { + llty = T_ivec(type_of_inner(cx, sp, mt.ty)); + } case (ty::ty_ptr(?mt)) { llty = T_ptr(type_of_inner(cx, sp, mt.ty)); } diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index ea2058d0785..e8a3cbbb5f0 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -295,6 +295,20 @@ fn mk_raw_ty(&ctxt cx, &sty st, &option::t[str] cname) -> raw_t { } alt (st) { + case (ty_nil) { /* no-op */ } + case (ty_bot) { /* no-op */ } + case (ty_bool) { /* no-op */ } + case (ty_int) { /* no-op */ } + case (ty_float) { /* no-op */ } + case (ty_uint) { /* no-op */ } + case (ty_machine(_)) { /* no-op */ } + case (ty_char) { /* no-op */ } + case (ty_str) { /* no-op */ } + case (ty_istr) { /* no-op */ } + case (ty_task) { /* no-op */ } + case (ty_type) { /* no-op */ } + case (ty_native) { /* no-op */ } + case (ty_param(_)) { has_params = true; } @@ -312,6 +326,10 @@ fn mk_raw_ty(&ctxt cx, &sty st, &option::t[str] cname) -> raw_t { derive_flags_mt(cx, has_params, has_vars, m); } + case (ty_ivec(?m)) { + derive_flags_mt(cx, has_params, has_vars, m); + } + case (ty_port(?tt)) { derive_flags_t(cx, has_params, has_vars, tt); } @@ -346,7 +364,6 @@ fn mk_raw_ty(&ctxt cx, &sty st, &option::t[str] cname) -> raw_t { m.output); } } - case (_) { } } ret rec(struct=st, cname=cname, hash=h, @@ -581,6 +598,7 @@ fn fold_ty(&ctxt cx, fold_mode fld, t ty_0) -> t { case (ty_machine(_)) { /* no-op */ } case (ty_char) { /* no-op */ } case (ty_str) { /* no-op */ } + case (ty_istr) { /* no-op */ } case (ty_type) { /* no-op */ } case (ty_native) { /* no-op */ } case (ty_task) { /* no-op */ } @@ -596,6 +614,10 @@ fn fold_ty(&ctxt cx, fold_mode fld, t ty_0) -> t { ty = copy_cname(cx, mk_vec(cx, rec(ty=fold_ty(cx, fld, tm.ty), mut=tm.mut)), ty); } + case (ty_ivec(?tm)) { + ty = copy_cname(cx, mk_ivec(cx, rec(ty=fold_ty(cx, fld, tm.ty), + mut=tm.mut)), ty); + } case (ty_port(?subty)) { ty = copy_cname(cx, mk_port(cx, fold_ty(cx, fld, subty)), ty); }