rustc: Eliminate the direct use of ty.t.struct
This commit is contained in:
parent
9eb1479746
commit
c1335510d5
5 changed files with 118 additions and 111 deletions
|
|
@ -546,7 +546,7 @@ fn get_tag_variants(session.session sess,
|
|||
auto item = find_item(did._1, items);
|
||||
auto ctor_ty = item_type(item, external_crate_id, tystore);
|
||||
let vec[@ty.t] arg_tys = vec();
|
||||
alt (ctor_ty.struct) {
|
||||
alt (ty.struct(ctor_ty)) {
|
||||
case (ty.ty_fn(_, ?args, _)) {
|
||||
for (ty.arg a in args) {
|
||||
arg_tys += vec(a.ty);
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ const uint tag_index_table = 0x15u;
|
|||
type def_str = fn(ast.def_id) -> str;
|
||||
|
||||
fn ty_str(@ty.t t, def_str ds) -> str {
|
||||
ret sty_str(t.struct, ds);
|
||||
ret sty_str(ty.struct(t), ds);
|
||||
}
|
||||
|
||||
fn mt_str(&ty.mt mt, def_str ds) -> str {
|
||||
|
|
|
|||
|
|
@ -683,7 +683,7 @@ fn type_of_inner(@crate_ctxt cx, @ty.t t) -> TypeRef {
|
|||
|
||||
let TypeRef llty = 0 as TypeRef;
|
||||
|
||||
alt (t.struct) {
|
||||
alt (ty.struct(t)) {
|
||||
case (ty.ty_native) { llty = T_ptr(T_i8()); }
|
||||
case (ty.ty_nil) { llty = T_nil(); }
|
||||
case (ty.ty_bool) { llty = T_bool(); }
|
||||
|
|
@ -789,7 +789,7 @@ fn type_of_inner(@crate_ctxt cx, @ty.t t) -> TypeRef {
|
|||
}
|
||||
|
||||
fn type_of_arg(@local_ctxt cx, &ty.arg arg) -> TypeRef {
|
||||
alt (arg.ty.struct) {
|
||||
alt (ty.struct(arg.ty)) {
|
||||
case (ty.ty_param(_)) {
|
||||
if (arg.mode == ast.alias) {
|
||||
ret T_typaram_ptr(cx.ccx.tn);
|
||||
|
|
@ -811,7 +811,7 @@ fn type_of_arg(@local_ctxt cx, &ty.arg arg) -> TypeRef {
|
|||
|
||||
fn type_of_ty_param_count_and_ty(@local_ctxt lcx,
|
||||
ty.ty_param_count_and_ty tpt) -> TypeRef {
|
||||
alt (tpt._1.struct) {
|
||||
alt (ty.struct(tpt._1)) {
|
||||
case (ty.ty_fn(?proto, ?inputs, ?output)) {
|
||||
auto llfnty = type_of_fn(lcx.ccx, proto, inputs, output, tpt._0);
|
||||
ret T_fn_pair(lcx.ccx.tn, llfnty);
|
||||
|
|
@ -1148,7 +1148,7 @@ fn array_alloca(@block_ctxt cx, TypeRef t, ValueRef n) -> ValueRef {
|
|||
// types.
|
||||
fn simplify_type(@crate_ctxt ccx, @ty.t typ) -> @ty.t {
|
||||
fn simplifier(@crate_ctxt ccx, @ty.t typ) -> @ty.t {
|
||||
alt (typ.struct) {
|
||||
alt (ty.struct(typ)) {
|
||||
case (ty.ty_box(_)) {
|
||||
ret ty.mk_imm_box(ccx.tystore, ty.mk_nil(ccx.tystore));
|
||||
}
|
||||
|
|
@ -1172,7 +1172,7 @@ fn static_size_of_tag(@crate_ctxt cx, @ty.t t) -> uint {
|
|||
|
||||
auto tid;
|
||||
let vec[@ty.t] subtys;
|
||||
alt (t.struct) {
|
||||
alt (ty.struct(t)) {
|
||||
case (ty.ty_tag(?tid_, ?subtys_)) {
|
||||
tid = tid_;
|
||||
subtys = subtys_;
|
||||
|
|
@ -1232,7 +1232,7 @@ fn dynamic_size_of(@block_ctxt cx, @ty.t t) -> result {
|
|||
ret res(bcx, off);
|
||||
}
|
||||
|
||||
alt (t.struct) {
|
||||
alt (ty.struct(t)) {
|
||||
case (ty.ty_param(?p)) {
|
||||
auto szptr = field_of_tydesc(cx, t, abi.tydesc_field_size);
|
||||
ret res(szptr.bcx, szptr.bcx.build.Load(szptr.val));
|
||||
|
|
@ -1287,7 +1287,7 @@ fn dynamic_size_of(@block_ctxt cx, @ty.t t) -> result {
|
|||
}
|
||||
|
||||
fn dynamic_align_of(@block_ctxt cx, @ty.t t) -> result {
|
||||
alt (t.struct) {
|
||||
alt (ty.struct(t)) {
|
||||
case (ty.ty_param(?p)) {
|
||||
auto aptr = field_of_tydesc(cx, t, abi.tydesc_field_align);
|
||||
ret res(aptr.bcx, aptr.bcx.build.Load(aptr.val));
|
||||
|
|
@ -1526,7 +1526,7 @@ fn linearize_ty_params(@block_ctxt cx, @ty.t t) ->
|
|||
mutable vec[uint] defs);
|
||||
|
||||
fn linearizer(@rr r, @ty.t t) {
|
||||
alt(t.struct) {
|
||||
alt(ty.struct(t)) {
|
||||
case (ty.ty_param(?pid)) {
|
||||
let bool seen = false;
|
||||
for (uint d in r.defs) {
|
||||
|
|
@ -1797,7 +1797,7 @@ fn incr_refcnt_of_boxed(@block_ctxt cx, ValueRef box_ptr) -> result {
|
|||
fn make_drop_glue(@block_ctxt cx, ValueRef v0, @ty.t t) {
|
||||
// NB: v0 is an *alias* of type t here, not a direct value.
|
||||
auto rslt;
|
||||
alt (t.struct) {
|
||||
alt (ty.struct(t)) {
|
||||
case (ty.ty_str) {
|
||||
auto v = cx.build.Load(v0);
|
||||
rslt = decr_refcnt_and_if_zero
|
||||
|
|
@ -2353,7 +2353,7 @@ fn iter_structural_ty_full(@block_ctxt cx,
|
|||
ret res(next_cx, r.val);
|
||||
}
|
||||
|
||||
alt (t.struct) {
|
||||
alt (ty.struct(t)) {
|
||||
case (ty.ty_tup(?args)) {
|
||||
let int i = 0;
|
||||
for (ty.mt arg in args) {
|
||||
|
|
@ -2427,7 +2427,7 @@ fn iter_structural_ty_full(@block_ctxt cx,
|
|||
if (_vec.len[@ty.t](variant.args) > 0u) {
|
||||
// N-ary variant.
|
||||
auto fn_ty = variant.ctor_ty;
|
||||
alt (fn_ty.struct) {
|
||||
alt (ty.struct(fn_ty)) {
|
||||
case (ty.ty_fn(_, ?args, _)) {
|
||||
auto j = 0;
|
||||
for (ty.arg a in args) {
|
||||
|
|
@ -2623,7 +2623,7 @@ fn iter_sequence(@block_ctxt cx,
|
|||
ret iter_sequence_inner(cx, p0, p1, elt_ty, f);
|
||||
}
|
||||
|
||||
alt (t.struct) {
|
||||
alt (ty.struct(t)) {
|
||||
case (ty.ty_vec(?elt)) {
|
||||
ret iter_sequence_body(cx, v, elt.ty, f, false);
|
||||
}
|
||||
|
|
@ -2850,7 +2850,7 @@ fn trans_lit(@crate_ctxt cx, &ast.lit lit, &ast.ann ann) -> ValueRef {
|
|||
}
|
||||
|
||||
fn target_type(@crate_ctxt cx, @ty.t t) -> @ty.t {
|
||||
alt (t.struct) {
|
||||
alt (ty.struct(t)) {
|
||||
case (ty.ty_int) {
|
||||
auto struct_ty = ty.mk_mach(cx.tystore,
|
||||
cx.sess.get_targ_cfg().int_type);
|
||||
|
|
@ -2914,7 +2914,7 @@ fn trans_unary(@block_ctxt cx, ast.unop op,
|
|||
case (ast.neg) {
|
||||
sub = autoderef(sub.bcx, sub.val,
|
||||
ty.expr_ty(cx.fcx.lcx.ccx.tystore, e));
|
||||
if(e_ty.struct == ty.ty_float) {
|
||||
if(ty.struct(e_ty) == ty.ty_float) {
|
||||
ret res(sub.bcx, sub.bcx.build.FNeg(sub.val));
|
||||
}
|
||||
else {
|
||||
|
|
@ -3005,7 +3005,7 @@ fn trans_vec_append(@block_ctxt cx, @ty.t t,
|
|||
auto elt_ty = ty.sequence_element_type(cx.fcx.lcx.ccx.tystore, t);
|
||||
|
||||
auto skip_null = C_bool(false);
|
||||
alt (t.struct) {
|
||||
alt (ty.struct(t)) {
|
||||
case (ty.ty_str) { skip_null = C_bool(true); }
|
||||
case (_) { }
|
||||
}
|
||||
|
|
@ -3045,7 +3045,7 @@ fn trans_eager_binop(@block_ctxt cx, ast.binop op, @ty.t intype,
|
|||
ValueRef lhs, ValueRef rhs) -> result {
|
||||
|
||||
auto is_float = false;
|
||||
alt (intype.struct) {
|
||||
alt (ty.struct(intype)) {
|
||||
case (ty.ty_float) {
|
||||
is_float = true;
|
||||
}
|
||||
|
|
@ -3123,7 +3123,7 @@ fn autoderef(@block_ctxt cx, ValueRef v, @ty.t t) -> result {
|
|||
let @ty.t t1 = t;
|
||||
|
||||
while (true) {
|
||||
alt (t1.struct) {
|
||||
alt (ty.struct(t1)) {
|
||||
case (ty.ty_box(?mt)) {
|
||||
auto body = cx.build.GEP(v1,
|
||||
vec(C_int(0),
|
||||
|
|
@ -3154,7 +3154,7 @@ fn autoderefed_ty(@ty.t t) -> @ty.t {
|
|||
let @ty.t t1 = t;
|
||||
|
||||
while (true) {
|
||||
alt (t1.struct) {
|
||||
alt (ty.struct(t1)) {
|
||||
case (ty.ty_box(?mt)) {
|
||||
t1 = mt.ty;
|
||||
}
|
||||
|
|
@ -3990,7 +3990,7 @@ fn trans_path(@block_ctxt cx, &ast.path p, &option.t[ast.def] dopt,
|
|||
auto v_tyt = ty.lookup_item_type(cx.fcx.lcx.ccx.sess,
|
||||
cx.fcx.lcx.ccx.tystore,
|
||||
cx.fcx.lcx.ccx.type_cache, vid);
|
||||
alt (v_tyt._1.struct) {
|
||||
alt (ty.struct(v_tyt._1)) {
|
||||
case (ty.ty_fn(_, _, _)) {
|
||||
// N-ary variant.
|
||||
ret lval_generic_fn(cx, v_tyt, vid, ann);
|
||||
|
|
@ -4052,7 +4052,7 @@ fn trans_field(@block_ctxt cx, &ast.span sp, ValueRef v, @ty.t t0,
|
|||
auto r = autoderef(cx, v, t0);
|
||||
auto t = autoderefed_ty(t0);
|
||||
|
||||
alt (t.struct) {
|
||||
alt (ty.struct(t)) {
|
||||
case (ty.ty_tup(_)) {
|
||||
let uint ix = ty.field_num(cx.fcx.lcx.ccx.sess, sp, field);
|
||||
auto v = GEP_tup_like(r.bcx, t, r.val, vec(0, ix as int));
|
||||
|
|
@ -4820,7 +4820,7 @@ fn trans_vec(@block_ctxt cx, vec[@ast.expr] args,
|
|||
&ast.ann ann) -> result {
|
||||
auto t = node_ann_type(cx.fcx.lcx.ccx, ann);
|
||||
auto unit_ty = t;
|
||||
alt (t.struct) {
|
||||
alt (ty.struct(t)) {
|
||||
case (ty.ty_vec(?mt)) {
|
||||
unit_ty = mt.ty;
|
||||
}
|
||||
|
|
@ -4914,7 +4914,7 @@ fn trans_rec(@block_ctxt cx, vec[ast.field] fields,
|
|||
}
|
||||
|
||||
let vec[ty.field] ty_fields = vec();
|
||||
alt (t.struct) {
|
||||
alt (ty.struct(t)) {
|
||||
case (ty.ty_rec(?flds)) { ty_fields = flds; }
|
||||
}
|
||||
|
||||
|
|
@ -5170,7 +5170,7 @@ fn trans_log(int lvl, @block_ctxt cx, @ast.expr e) -> result {
|
|||
if (ty.type_is_fp(e_ty)) {
|
||||
let TypeRef tr;
|
||||
let bool is32bit = false;
|
||||
alt (e_ty.struct) {
|
||||
alt (ty.struct(e_ty)) {
|
||||
case (ty.ty_machine(util.common.ty_f32)) {
|
||||
tr = T_f32();
|
||||
is32bit = true;
|
||||
|
|
@ -5196,7 +5196,7 @@ fn trans_log(int lvl, @block_ctxt cx, @ast.expr e) -> result {
|
|||
uval.bcx.build.Br(after_cx.llbb);
|
||||
}
|
||||
} else {
|
||||
alt (e_ty.struct) {
|
||||
alt (ty.struct(e_ty)) {
|
||||
case (ty.ty_str) {
|
||||
auto v = vp2i(sub.bcx, sub.val);
|
||||
trans_upcall(sub.bcx,
|
||||
|
|
@ -5382,7 +5382,7 @@ fn trans_port(@block_ctxt cx, ast.ann ann) -> result {
|
|||
|
||||
auto t = node_ann_type(cx.fcx.lcx.ccx, ann);
|
||||
auto unit_ty;
|
||||
alt (t.struct) {
|
||||
alt (ty.struct(t)) {
|
||||
case (ty.ty_port(?t)) {
|
||||
unit_ty = t;
|
||||
}
|
||||
|
|
@ -5437,7 +5437,7 @@ fn trans_send(@block_ctxt cx, @ast.expr lhs, @ast.expr rhs,
|
|||
|
||||
auto chan_ty = node_ann_type(cx.fcx.lcx.ccx, ann);
|
||||
auto unit_ty;
|
||||
alt (chan_ty.struct) {
|
||||
alt (ty.struct(chan_ty)) {
|
||||
case (ty.ty_chan(?t)) {
|
||||
unit_ty = t;
|
||||
}
|
||||
|
|
@ -5915,7 +5915,7 @@ fn is_terminated(@block_ctxt cx) -> bool {
|
|||
}
|
||||
|
||||
fn arg_tys_of_fn(ast.ann ann) -> vec[ty.arg] {
|
||||
alt (ty.ann_to_type(ann).struct) {
|
||||
alt (ty.struct(ty.ann_to_type(ann))) {
|
||||
case (ty.ty_fn(_, ?arg_tys, _)) {
|
||||
ret arg_tys;
|
||||
}
|
||||
|
|
@ -5924,7 +5924,7 @@ fn arg_tys_of_fn(ast.ann ann) -> vec[ty.arg] {
|
|||
}
|
||||
|
||||
fn ret_ty_of_fn_ty(@ty.t t) -> @ty.t {
|
||||
alt (t.struct) {
|
||||
alt (ty.struct(t)) {
|
||||
case (ty.ty_fn(_, _, ?ret_ty)) {
|
||||
ret ret_ty;
|
||||
}
|
||||
|
|
@ -6060,7 +6060,7 @@ fn trans_vtbl(@local_ctxt cx,
|
|||
for (@ast.method m in meths) {
|
||||
|
||||
auto llfnty = T_nil();
|
||||
alt (node_ann_type(cx.ccx, m.node.ann).struct) {
|
||||
alt (ty.struct(node_ann_type(cx.ccx, m.node.ann))) {
|
||||
case (ty.ty_fn(?proto, ?inputs, ?output)) {
|
||||
llfnty = type_of_fn_full(cx.ccx, proto,
|
||||
some[TypeRef](llself_ty),
|
||||
|
|
@ -6099,7 +6099,7 @@ fn trans_dtor(@local_ctxt cx,
|
|||
&@ast.method dtor) -> ValueRef {
|
||||
|
||||
auto llfnty = T_nil();
|
||||
alt (node_ann_type(cx.ccx, dtor.node.ann).struct) {
|
||||
alt (ty.struct(node_ann_type(cx.ccx, dtor.node.ann))) {
|
||||
case (ty.ty_fn(?proto, ?inputs, ?output)) {
|
||||
llfnty = type_of_fn_full(cx.ccx, proto,
|
||||
some[TypeRef](llself_ty),
|
||||
|
|
@ -6423,7 +6423,7 @@ fn decl_fn_and_pair(@crate_ctxt ccx,
|
|||
|
||||
auto llfty;
|
||||
auto llpairty;
|
||||
alt (node_ann_type(ccx, ann).struct) {
|
||||
alt (ty.struct(node_ann_type(ccx, ann))) {
|
||||
case (ty.ty_fn(?proto, ?inputs, ?output)) {
|
||||
llfty = type_of_fn(ccx, proto, inputs, output,
|
||||
_vec.len[ast.ty_param](ty_params));
|
||||
|
|
@ -6482,7 +6482,7 @@ fn native_fn_ty_param_count(@crate_ctxt cx, &ast.def_id id) -> uint {
|
|||
|
||||
fn native_fn_wrapper_type(@crate_ctxt cx, uint ty_param_count, @ty.t x)
|
||||
-> TypeRef {
|
||||
alt (x.struct) {
|
||||
alt (ty.struct(x)) {
|
||||
case (ty.ty_native_fn(?abi, ?args, ?out)) {
|
||||
ret type_of_fn(cx, ast.proto_fn, args, out, ty_param_count);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,10 +36,12 @@ fn method_ty_to_fn_ty(@type_store tystore, method m) -> @ty.t {
|
|||
ret mk_fn(tystore, m.proto, m.inputs, m.output);
|
||||
}
|
||||
|
||||
// Never construct these manually. These are interned.
|
||||
// Never construct these manually. These are interned. Also don't assume that
|
||||
// you can access the fields of this type directly; soon these will just be
|
||||
// uints, and that won't work anymore.
|
||||
//
|
||||
// TODO: It'd be really nice to be able to hide this definition from the
|
||||
// outside world, to enforce the above invariant.
|
||||
// outside world, to enforce the above invariants.
|
||||
type t = rec(sty struct, option.t[str] cname, uint hash);
|
||||
|
||||
// NB: If you change this, you'll probably want to change the corresponding
|
||||
|
|
@ -211,6 +213,10 @@ fn mk_type(@type_store ts) -> @t { ret gen_ty(ts, ty_type); }
|
|||
fn mk_native(@type_store ts) -> @t { ret gen_ty(ts, ty_native); }
|
||||
|
||||
|
||||
// Returns the one-level-deep type structure of the given type.
|
||||
fn struct(@t typ) -> sty { ret typ.struct; }
|
||||
|
||||
|
||||
// Stringification
|
||||
|
||||
fn path_to_str(&ast.path pth) -> str {
|
||||
|
|
@ -264,7 +270,7 @@ fn ty_to_str(&@t typ) -> str {
|
|||
s += _str.connect(_vec.map[arg,str](f, inputs), ", ");
|
||||
s += ")";
|
||||
|
||||
if (output.struct != ty_nil) {
|
||||
if (struct(output) != ty_nil) {
|
||||
s += " -> " + ty_to_str(output);
|
||||
}
|
||||
ret s;
|
||||
|
|
@ -291,7 +297,7 @@ fn ty_to_str(&@t typ) -> str {
|
|||
}
|
||||
|
||||
auto s = "";
|
||||
alt (typ.struct) {
|
||||
alt (struct(typ)) {
|
||||
case (ty_native) { s += "native"; }
|
||||
case (ty_nil) { s += "()"; }
|
||||
case (ty_bool) { s += "bool"; }
|
||||
|
|
@ -377,7 +383,7 @@ fn ty_to_str(&@t typ) -> str {
|
|||
type ty_walk = fn(@t);
|
||||
|
||||
fn walk_ty(ty_walk walker, @t ty) {
|
||||
alt (ty.struct) {
|
||||
alt (struct(ty)) {
|
||||
case (ty_nil) { /* no-op */ }
|
||||
case (ty_bool) { /* no-op */ }
|
||||
case (ty_int) { /* no-op */ }
|
||||
|
|
@ -441,7 +447,7 @@ type ty_fold = fn(@t) -> @t;
|
|||
|
||||
fn fold_ty(@type_store tystore, ty_fold fld, @t ty_0) -> @t {
|
||||
auto ty = ty_0;
|
||||
alt (ty.struct) {
|
||||
alt (struct(ty)) {
|
||||
case (ty_nil) { /* no-op */ }
|
||||
case (ty_bool) { /* no-op */ }
|
||||
case (ty_int) { /* no-op */ }
|
||||
|
|
@ -542,13 +548,13 @@ fn fold_ty(@type_store tystore, ty_fold fld, @t ty_0) -> @t {
|
|||
// Type utilities
|
||||
|
||||
fn rename(@type_store tystore, @t typ, str new_cname) -> @t {
|
||||
ret gen_ty_full(tystore, typ.struct, some[str](new_cname));
|
||||
ret gen_ty_full(tystore, struct(typ), some[str](new_cname));
|
||||
}
|
||||
|
||||
// Returns a type with the structural part taken from `struct_ty` and the
|
||||
// canonical name from `cname_ty`.
|
||||
fn copy_cname(@type_store tystore, @t struct_ty, @t cname_ty) -> @t {
|
||||
ret gen_ty_full(tystore, struct_ty.struct, cname_ty.cname);
|
||||
ret gen_ty_full(tystore, struct(struct_ty), cname_ty.cname);
|
||||
}
|
||||
|
||||
// FIXME: remove me when == works on these tags.
|
||||
|
|
@ -561,7 +567,7 @@ fn mode_is_alias(ast.mode m) -> bool {
|
|||
}
|
||||
|
||||
fn type_is_nil(@t ty) -> bool {
|
||||
alt (ty.struct) {
|
||||
alt (struct(ty)) {
|
||||
case (ty_nil) { ret true; }
|
||||
case (_) { ret false; }
|
||||
}
|
||||
|
|
@ -569,7 +575,7 @@ fn type_is_nil(@t ty) -> bool {
|
|||
}
|
||||
|
||||
fn type_is_bool(@t ty) -> bool {
|
||||
alt (ty.struct) {
|
||||
alt (struct(ty)) {
|
||||
case (ty_bool) { ret true; }
|
||||
case (_) { ret false; }
|
||||
}
|
||||
|
|
@ -577,7 +583,7 @@ fn type_is_bool(@t ty) -> bool {
|
|||
|
||||
|
||||
fn type_is_structural(@t ty) -> bool {
|
||||
alt (ty.struct) {
|
||||
alt (struct(ty)) {
|
||||
case (ty_tup(_)) { ret true; }
|
||||
case (ty_rec(_)) { ret true; }
|
||||
case (ty_tag(_,_)) { ret true; }
|
||||
|
|
@ -589,7 +595,7 @@ fn type_is_structural(@t ty) -> bool {
|
|||
}
|
||||
|
||||
fn type_is_sequence(@t ty) -> bool {
|
||||
alt (ty.struct) {
|
||||
alt (struct(ty)) {
|
||||
case (ty_str) { ret true; }
|
||||
case (ty_vec(_)) { ret true; }
|
||||
case (_) { ret false; }
|
||||
|
|
@ -598,7 +604,7 @@ fn type_is_sequence(@t ty) -> bool {
|
|||
}
|
||||
|
||||
fn sequence_element_type(@type_store tystore, @t ty) -> @t {
|
||||
alt (ty.struct) {
|
||||
alt (struct(ty)) {
|
||||
case (ty_str) { ret mk_mach(tystore, common.ty_u8); }
|
||||
case (ty_vec(?mt)) { ret mt.ty; }
|
||||
}
|
||||
|
|
@ -607,7 +613,7 @@ fn sequence_element_type(@type_store tystore, @t ty) -> @t {
|
|||
|
||||
|
||||
fn type_is_tup_like(@t ty) -> bool {
|
||||
alt (ty.struct) {
|
||||
alt (struct(ty)) {
|
||||
case (ty_box(_)) { ret true; }
|
||||
case (ty_tup(_)) { ret true; }
|
||||
case (ty_rec(_)) { ret true; }
|
||||
|
|
@ -619,7 +625,7 @@ fn type_is_tup_like(@t ty) -> bool {
|
|||
|
||||
fn get_element_type(@t ty, uint i) -> @t {
|
||||
check (type_is_tup_like(ty));
|
||||
alt (ty.struct) {
|
||||
alt (struct(ty)) {
|
||||
case (ty_tup(?mts)) {
|
||||
ret mts.(i).ty;
|
||||
}
|
||||
|
|
@ -631,7 +637,7 @@ fn get_element_type(@t ty, uint i) -> @t {
|
|||
}
|
||||
|
||||
fn type_is_box(@t ty) -> bool {
|
||||
alt (ty.struct) {
|
||||
alt (struct(ty)) {
|
||||
case (ty_box(_)) { ret true; }
|
||||
case (_) { ret false; }
|
||||
}
|
||||
|
|
@ -639,7 +645,7 @@ fn type_is_box(@t ty) -> bool {
|
|||
}
|
||||
|
||||
fn type_is_boxed(@t ty) -> bool {
|
||||
alt (ty.struct) {
|
||||
alt (struct(ty)) {
|
||||
case (ty_str) { ret true; }
|
||||
case (ty_vec(_)) { ret true; }
|
||||
case (ty_box(_)) { ret true; }
|
||||
|
|
@ -651,7 +657,7 @@ fn type_is_boxed(@t ty) -> bool {
|
|||
}
|
||||
|
||||
fn type_is_scalar(@t ty) -> bool {
|
||||
alt (ty.struct) {
|
||||
alt (struct(ty)) {
|
||||
case (ty_nil) { ret true; }
|
||||
case (ty_bool) { ret true; }
|
||||
case (ty_int) { ret true; }
|
||||
|
|
@ -669,7 +675,7 @@ fn type_is_scalar(@t ty) -> bool {
|
|||
// FIXME: should we just return true for native types in
|
||||
// type_is_scalar?
|
||||
fn type_is_native(@t ty) -> bool {
|
||||
alt (ty.struct) {
|
||||
alt (struct(ty)) {
|
||||
case (ty_native) { ret true; }
|
||||
case (_) { ret false; }
|
||||
}
|
||||
|
|
@ -677,7 +683,7 @@ fn type_is_native(@t ty) -> bool {
|
|||
}
|
||||
|
||||
fn type_has_dynamic_size(@t ty) -> bool {
|
||||
alt (ty.struct) {
|
||||
alt (struct(ty)) {
|
||||
case (ty_tup(?mts)) {
|
||||
auto i = 0u;
|
||||
while (i < _vec.len[mt](mts)) {
|
||||
|
|
@ -706,7 +712,7 @@ fn type_has_dynamic_size(@t ty) -> bool {
|
|||
}
|
||||
|
||||
fn type_is_integral(@t ty) -> bool {
|
||||
alt (ty.struct) {
|
||||
alt (struct(ty)) {
|
||||
case (ty_int) { ret true; }
|
||||
case (ty_uint) { ret true; }
|
||||
case (ty_machine(?m)) {
|
||||
|
|
@ -730,7 +736,7 @@ fn type_is_integral(@t ty) -> bool {
|
|||
}
|
||||
|
||||
fn type_is_fp(@t ty) -> bool {
|
||||
alt (ty.struct) {
|
||||
alt (struct(ty)) {
|
||||
case (ty_machine(?tm)) {
|
||||
alt (tm) {
|
||||
case (common.ty_f32) { ret true; }
|
||||
|
|
@ -747,7 +753,7 @@ fn type_is_fp(@t ty) -> bool {
|
|||
}
|
||||
|
||||
fn type_is_signed(@t ty) -> bool {
|
||||
alt (ty.struct) {
|
||||
alt (struct(ty)) {
|
||||
case (ty_int) { ret true; }
|
||||
case (ty_machine(?tm)) {
|
||||
alt (tm) {
|
||||
|
|
@ -764,7 +770,7 @@ fn type_is_signed(@t ty) -> bool {
|
|||
}
|
||||
|
||||
fn type_param(@t ty) -> option.t[uint] {
|
||||
alt (ty.struct) {
|
||||
alt (struct(ty)) {
|
||||
case (ty_param(?id)) { ret some[uint](id); }
|
||||
case (_) { /* fall through */ }
|
||||
}
|
||||
|
|
@ -1225,7 +1231,7 @@ fn eq_ty_full(&@t a, &@t b) -> bool {
|
|||
}
|
||||
|
||||
// Check structures.
|
||||
ret equal_type_structures(a.struct, b.struct);
|
||||
ret equal_type_structures(struct(a), struct(b));
|
||||
}
|
||||
|
||||
// This is the equality function the public should use. It works as long as
|
||||
|
|
@ -1292,7 +1298,7 @@ fn triv_ann(@ty.t typ) -> ast.ann {
|
|||
// Returns the number of distinct type parameters in the given type.
|
||||
fn count_ty_params(@t ty) -> uint {
|
||||
fn counter(@mutable vec[uint] param_indices, @t ty) {
|
||||
alt (ty.struct) {
|
||||
alt (struct(ty)) {
|
||||
case (ty_param(?param_idx)) {
|
||||
auto seen = false;
|
||||
for (uint other_param_idx in *param_indices) {
|
||||
|
|
@ -1317,7 +1323,7 @@ fn count_ty_params(@t ty) -> uint {
|
|||
|
||||
fn type_contains_vars(@t typ) -> bool {
|
||||
fn checker(@mutable bool flag, @t typ) {
|
||||
alt (typ.struct) {
|
||||
alt (struct(typ)) {
|
||||
case (ty_var(_)) { *flag = true; }
|
||||
case (_) { /* fall through */ }
|
||||
}
|
||||
|
|
@ -1332,7 +1338,7 @@ fn type_contains_vars(@t typ) -> bool {
|
|||
// Type accessors for substructures of types
|
||||
|
||||
fn ty_fn_args(@t fty) -> vec[arg] {
|
||||
alt (fty.struct) {
|
||||
alt (struct(fty)) {
|
||||
case (ty.ty_fn(_, ?a, _)) { ret a; }
|
||||
case (ty.ty_native_fn(_, ?a, _)) { ret a; }
|
||||
}
|
||||
|
|
@ -1340,21 +1346,21 @@ fn ty_fn_args(@t fty) -> vec[arg] {
|
|||
}
|
||||
|
||||
fn ty_fn_proto(@t fty) -> ast.proto {
|
||||
alt (fty.struct) {
|
||||
alt (struct(fty)) {
|
||||
case (ty.ty_fn(?p, _, _)) { ret p; }
|
||||
}
|
||||
fail;
|
||||
}
|
||||
|
||||
fn ty_fn_abi(@t fty) -> ast.native_abi {
|
||||
alt (fty.struct) {
|
||||
alt (struct(fty)) {
|
||||
case (ty.ty_native_fn(?a, _, _)) { ret a; }
|
||||
}
|
||||
fail;
|
||||
}
|
||||
|
||||
fn ty_fn_ret(@t fty) -> @t {
|
||||
alt (fty.struct) {
|
||||
alt (struct(fty)) {
|
||||
case (ty.ty_fn(_, _, ?r)) { ret r; }
|
||||
case (ty.ty_native_fn(_, _, ?r)) { ret r; }
|
||||
}
|
||||
|
|
@ -1362,7 +1368,7 @@ fn ty_fn_ret(@t fty) -> @t {
|
|||
}
|
||||
|
||||
fn is_fn_ty(@t fty) -> bool {
|
||||
alt (fty.struct) {
|
||||
alt (struct(fty)) {
|
||||
case (ty.ty_fn(_, _, _)) { ret true; }
|
||||
case (ty.ty_native_fn(_, _, _)) { ret true; }
|
||||
case (_) { ret false; }
|
||||
|
|
@ -1675,7 +1681,7 @@ mod Unify {
|
|||
|
||||
// Simple structural type comparison.
|
||||
fn struct_cmp(@ty.t expected, @ty.t actual) -> result {
|
||||
if (expected.struct == actual.struct) {
|
||||
if (struct(expected) == struct(actual)) {
|
||||
ret ures_ok(expected);
|
||||
}
|
||||
|
||||
|
|
@ -1840,7 +1846,7 @@ mod Unify {
|
|||
a_meth.inputs, a_meth.output);
|
||||
alt (r) {
|
||||
case (ures_ok(?tfn)) {
|
||||
alt (tfn.struct) {
|
||||
alt (struct(tfn)) {
|
||||
case (ty_fn(?proto, ?ins, ?out)) {
|
||||
result_meths += vec(rec(inputs = ins,
|
||||
output = out
|
||||
|
|
@ -1880,12 +1886,12 @@ mod Unify {
|
|||
// Fast path.
|
||||
if (eq_ty(expected, actual)) { ret ures_ok(expected); }
|
||||
|
||||
alt (actual.struct) {
|
||||
alt (struct(actual)) {
|
||||
// If the RHS is a variable type, then just do the appropriate
|
||||
// binding.
|
||||
case (ty.ty_var(?actual_id)) {
|
||||
auto actual_n = get_or_create_set(cx, actual_id);
|
||||
alt (expected.struct) {
|
||||
alt (struct(expected)) {
|
||||
case (ty.ty_var(?expected_id)) {
|
||||
auto expected_n = get_or_create_set(cx, expected_id);
|
||||
UFind.union(cx.sets, expected_n, actual_n);
|
||||
|
|
@ -1921,7 +1927,7 @@ mod Unify {
|
|||
ret ures_ok(result_ty);
|
||||
}
|
||||
case (ty.ty_bound_param(?actual_id)) {
|
||||
alt (expected.struct) {
|
||||
alt (struct(expected)) {
|
||||
case (ty.ty_local(_)) {
|
||||
log_err "TODO: bound param unifying with local";
|
||||
fail;
|
||||
|
|
@ -1935,7 +1941,7 @@ mod Unify {
|
|||
case (_) { /* empty */ }
|
||||
}
|
||||
|
||||
alt (expected.struct) {
|
||||
alt (struct(expected)) {
|
||||
case (ty.ty_nil) { ret struct_cmp(expected, actual); }
|
||||
case (ty.ty_bool) { ret struct_cmp(expected, actual); }
|
||||
case (ty.ty_int) { ret struct_cmp(expected, actual); }
|
||||
|
|
@ -1949,7 +1955,7 @@ mod Unify {
|
|||
case (ty.ty_param(_)) { ret struct_cmp(expected, actual); }
|
||||
|
||||
case (ty.ty_tag(?expected_id, ?expected_tps)) {
|
||||
alt (actual.struct) {
|
||||
alt (struct(actual)) {
|
||||
case (ty.ty_tag(?actual_id, ?actual_tps)) {
|
||||
if (expected_id._0 != actual_id._0 ||
|
||||
expected_id._1 != actual_id._1) {
|
||||
|
|
@ -1991,7 +1997,7 @@ mod Unify {
|
|||
}
|
||||
|
||||
case (ty.ty_box(?expected_mt)) {
|
||||
alt (actual.struct) {
|
||||
alt (struct(actual)) {
|
||||
case (ty.ty_box(?actual_mt)) {
|
||||
auto mut;
|
||||
alt (unify_mut(expected_mt.mut, actual_mt.mut)) {
|
||||
|
|
@ -2023,7 +2029,7 @@ mod Unify {
|
|||
}
|
||||
|
||||
case (ty.ty_vec(?expected_mt)) {
|
||||
alt (actual.struct) {
|
||||
alt (struct(actual)) {
|
||||
case (ty.ty_vec(?actual_mt)) {
|
||||
auto mut;
|
||||
alt (unify_mut(expected_mt.mut, actual_mt.mut)) {
|
||||
|
|
@ -2055,7 +2061,7 @@ mod Unify {
|
|||
}
|
||||
|
||||
case (ty.ty_port(?expected_sub)) {
|
||||
alt (actual.struct) {
|
||||
alt (struct(actual)) {
|
||||
case (ty.ty_port(?actual_sub)) {
|
||||
auto result = unify_step(cx,
|
||||
expected_sub,
|
||||
|
|
@ -2077,7 +2083,7 @@ mod Unify {
|
|||
}
|
||||
|
||||
case (ty.ty_chan(?expected_sub)) {
|
||||
alt (actual.struct) {
|
||||
alt (struct(actual)) {
|
||||
case (ty.ty_chan(?actual_sub)) {
|
||||
auto result = unify_step(cx,
|
||||
expected_sub,
|
||||
|
|
@ -2099,7 +2105,7 @@ mod Unify {
|
|||
}
|
||||
|
||||
case (ty.ty_tup(?expected_elems)) {
|
||||
alt (actual.struct) {
|
||||
alt (struct(actual)) {
|
||||
case (ty.ty_tup(?actual_elems)) {
|
||||
auto expected_len = _vec.len[ty.mt](expected_elems);
|
||||
auto actual_len = _vec.len[ty.mt](actual_elems);
|
||||
|
|
@ -2153,7 +2159,7 @@ mod Unify {
|
|||
}
|
||||
|
||||
case (ty.ty_rec(?expected_fields)) {
|
||||
alt (actual.struct) {
|
||||
alt (struct(actual)) {
|
||||
case (ty.ty_rec(?actual_fields)) {
|
||||
auto expected_len = _vec.len[field](expected_fields);
|
||||
auto actual_len = _vec.len[field](actual_fields);
|
||||
|
|
@ -2217,7 +2223,7 @@ mod Unify {
|
|||
}
|
||||
|
||||
case (ty.ty_fn(?ep, ?expected_inputs, ?expected_output)) {
|
||||
alt (actual.struct) {
|
||||
alt (struct(actual)) {
|
||||
case (ty.ty_fn(?ap, ?actual_inputs, ?actual_output)) {
|
||||
ret unify_fn(cx, ep, ap,
|
||||
expected, actual,
|
||||
|
|
@ -2233,7 +2239,7 @@ mod Unify {
|
|||
|
||||
case (ty.ty_native_fn(?e_abi, ?expected_inputs,
|
||||
?expected_output)) {
|
||||
alt (actual.struct) {
|
||||
alt (struct(actual)) {
|
||||
case (ty.ty_native_fn(?a_abi, ?actual_inputs,
|
||||
?actual_output)) {
|
||||
ret unify_native_fn(cx, e_abi, a_abi,
|
||||
|
|
@ -2248,7 +2254,7 @@ mod Unify {
|
|||
}
|
||||
|
||||
case (ty.ty_obj(?expected_meths)) {
|
||||
alt (actual.struct) {
|
||||
alt (struct(actual)) {
|
||||
case (ty.ty_obj(?actual_meths)) {
|
||||
ret unify_obj(cx, expected, actual,
|
||||
expected_meths, actual_meths);
|
||||
|
|
@ -2301,7 +2307,7 @@ mod Unify {
|
|||
// Performs type binding substitution.
|
||||
fn substitute(@ctxt cx, vec[@t] set_types, @t typ) -> @t {
|
||||
fn substituter(@ctxt cx, vec[@t] types, @t typ) -> @t {
|
||||
alt (typ.struct) {
|
||||
alt (struct(typ)) {
|
||||
case (ty_var(?id)) {
|
||||
alt (cx.var_ids.find(id)) {
|
||||
case (some[uint](?n)) {
|
||||
|
|
@ -2434,7 +2440,7 @@ fn substitute_type_params(@type_store tystore,
|
|||
vec[@t] bindings,
|
||||
@t typ) -> @t {
|
||||
fn replacer(vec[@t] bindings, @t typ) -> @t {
|
||||
alt (typ.struct) {
|
||||
alt (struct(typ)) {
|
||||
case (ty_bound_param(?param_index)) {
|
||||
ret bindings.(param_index);
|
||||
}
|
||||
|
|
@ -2449,7 +2455,7 @@ fn substitute_type_params(@type_store tystore,
|
|||
// Converts type parameters in a type to bound type parameters.
|
||||
fn bind_params_in_type(@type_store tystore, @t typ) -> @t {
|
||||
fn binder(@type_store tystore, @t typ) -> @t {
|
||||
alt (typ.struct) {
|
||||
alt (struct(typ)) {
|
||||
case (ty_bound_param(?index)) {
|
||||
log_err "bind_params_in_type() called on type that already " +
|
||||
"has bound params in it";
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import middle.ty.method;
|
|||
import middle.ty.mode_is_alias;
|
||||
import middle.ty.pat_ty;
|
||||
import middle.ty.path_to_str;
|
||||
import middle.ty.struct;
|
||||
import middle.ty.triv_ann;
|
||||
import middle.ty.ty_to_str;
|
||||
import middle.ty.type_is_integral;
|
||||
|
|
@ -80,7 +81,7 @@ fn substitute_ty_params(&@crate_ctxt ccx,
|
|||
vec[@ty.t] supplied,
|
||||
&span sp) -> @ty.t {
|
||||
fn substituter(@crate_ctxt ccx, vec[@ty.t] supplied, @ty.t typ) -> @ty.t {
|
||||
alt (typ.struct) {
|
||||
alt (struct(typ)) {
|
||||
case (ty.ty_bound_param(?pid)) { ret supplied.(pid); }
|
||||
case (_) { ret typ; }
|
||||
}
|
||||
|
|
@ -686,9 +687,9 @@ mod Collect {
|
|||
}
|
||||
|
||||
fn get_ctor_obj_methods(@ty.t t) -> vec[method] {
|
||||
alt (t.struct) {
|
||||
alt (struct(t)) {
|
||||
case (ty.ty_fn(_,_,?tobj)) {
|
||||
alt (tobj.struct) {
|
||||
alt (struct(tobj)) {
|
||||
case (ty.ty_obj(?tm)) {
|
||||
ret tm;
|
||||
}
|
||||
|
|
@ -923,7 +924,7 @@ tag autoderef_kind {
|
|||
fn strip_boxes(@ty.t t) -> @ty.t {
|
||||
auto t1 = t;
|
||||
while (true) {
|
||||
alt (t1.struct) {
|
||||
alt (struct(t1)) {
|
||||
case (ty.ty_box(?inner)) { t1 = inner.ty; }
|
||||
case (_) { ret t1; }
|
||||
}
|
||||
|
|
@ -945,7 +946,7 @@ fn count_boxes(@ty.t t) -> uint {
|
|||
auto n = 0u;
|
||||
auto t1 = t;
|
||||
while (true) {
|
||||
alt (t1.struct) {
|
||||
alt (struct(t1)) {
|
||||
case (ty.ty_box(?inner)) { n += 1u; t1 = inner.ty; }
|
||||
case (_) { ret n; }
|
||||
}
|
||||
|
|
@ -1039,7 +1040,7 @@ fn variant_arg_types(@crate_ctxt ccx, &span sp, ast.def_id vid,
|
|||
|
||||
auto tpt = ty.lookup_item_type(ccx.sess, ccx.tystore, ccx.type_cache,
|
||||
vid);
|
||||
alt (tpt._1.struct) {
|
||||
alt (struct(tpt._1)) {
|
||||
case (ty.ty_fn(_, ?ins, _)) {
|
||||
// N-ary variant.
|
||||
for (ty.arg arg in ins) {
|
||||
|
|
@ -1108,7 +1109,7 @@ mod Pushdown {
|
|||
// Take the variant's type parameters out of the expected
|
||||
// type.
|
||||
auto tag_tps;
|
||||
alt (expected.struct) {
|
||||
alt (struct(expected)) {
|
||||
case (ty.ty_tag(_, ?tps)) { tag_tps = tps; }
|
||||
case (_) {
|
||||
log_err "tag pattern type not actually a tag?!";
|
||||
|
|
@ -1158,7 +1159,7 @@ mod Pushdown {
|
|||
auto t = Demand.simple(fcx, e.span, expected,
|
||||
ann_to_type(ann));
|
||||
let vec[@ast.expr] es_1 = vec();
|
||||
alt (t.struct) {
|
||||
alt (struct(t)) {
|
||||
case (ty.ty_vec(?mt)) {
|
||||
for (@ast.expr e_0 in es_0) {
|
||||
es_1 += vec(pushdown_expr(fcx, mt.ty, e_0));
|
||||
|
|
@ -1175,7 +1176,7 @@ mod Pushdown {
|
|||
auto t = Demand.simple(fcx, e.span, expected,
|
||||
ann_to_type(ann));
|
||||
let vec[ast.elt] elts_1 = vec();
|
||||
alt (t.struct) {
|
||||
alt (struct(t)) {
|
||||
case (ty.ty_tup(?mts)) {
|
||||
auto i = 0u;
|
||||
for (ast.elt elt_0 in es_0) {
|
||||
|
|
@ -1199,7 +1200,7 @@ mod Pushdown {
|
|||
auto t = Demand.simple(fcx, e.span, expected,
|
||||
ann_to_type(ann));
|
||||
let vec[ast.field] fields_1 = vec();
|
||||
alt (t.struct) {
|
||||
alt (struct(t)) {
|
||||
case (ty.ty_rec(?field_mts)) {
|
||||
alt (base_0) {
|
||||
case (none[@ast.expr]) {
|
||||
|
|
@ -1412,7 +1413,7 @@ mod Pushdown {
|
|||
auto t = Demand.simple(fcx, e.span, expected,
|
||||
ann_to_type(ann));
|
||||
let @ast.expr es_1;
|
||||
alt (t.struct) {
|
||||
alt (struct(t)) {
|
||||
case (ty.ty_chan(?subty)) {
|
||||
auto pt = ty.mk_port(fcx.ccx.tystore, subty);
|
||||
es_1 = pushdown_expr(fcx, pt, es);
|
||||
|
|
@ -1514,7 +1515,7 @@ fn writeback_local(&option.t[@fn_ctxt] env, &span sp, @ast.local local)
|
|||
fn resolve_local_types_in_annotation(&option.t[@fn_ctxt] env, ast.ann ann)
|
||||
-> ast.ann {
|
||||
fn resolver(@fn_ctxt fcx, @ty.t typ) -> @ty.t {
|
||||
alt (typ.struct) {
|
||||
alt (struct(typ)) {
|
||||
case (ty.ty_local(?lid)) { ret fcx.locals.get(lid); }
|
||||
case (_) { ret typ; }
|
||||
}
|
||||
|
|
@ -1603,7 +1604,7 @@ fn check_pat(&@fn_ctxt fcx, @ast.pat pat) -> @ast.pat {
|
|||
fcx.ccx.type_cache, vdef._0);
|
||||
auto ann = instantiate_path(fcx, p, tpt, pat.span);
|
||||
|
||||
alt (t.struct) {
|
||||
alt (struct(t)) {
|
||||
// N-ary variants have function types.
|
||||
case (ty.ty_fn(_, ?args, ?tag_ty)) {
|
||||
auto arg_len = _vec.len[arg](args);
|
||||
|
|
@ -1691,7 +1692,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
|
|||
|
||||
auto rt_0 = next_ty_var(fcx.ccx);
|
||||
auto t_0;
|
||||
alt (expr_ty(fcx.ccx.tystore, f_0).struct) {
|
||||
alt (struct(expr_ty(fcx.ccx.tystore, f_0))) {
|
||||
case (ty.ty_fn(?proto, _, _)) {
|
||||
t_0 = ty.mk_fn(fcx.ccx.tystore, proto, arg_tys_0, rt_0);
|
||||
}
|
||||
|
|
@ -1800,7 +1801,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
|
|||
rec(ty=oper_t, mut=mut));
|
||||
}
|
||||
case (ast.deref) {
|
||||
alt (oper_t.struct) {
|
||||
alt (struct(oper_t)) {
|
||||
case (ty.ty_box(?inner)) {
|
||||
oper_t = inner.ty;
|
||||
}
|
||||
|
|
@ -1970,7 +1971,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
|
|||
auto chan_t = ty.mk_chan(fcx.ccx.tystore, rhs_t);
|
||||
auto lhs_1 = Pushdown.pushdown_expr(fcx, chan_t, lhs_0);
|
||||
auto item_t;
|
||||
alt (expr_ty(fcx.ccx.tystore, lhs_1).struct) {
|
||||
alt (struct(expr_ty(fcx.ccx.tystore, lhs_1))) {
|
||||
case (ty.ty_chan(?it)) {
|
||||
item_t = it;
|
||||
}
|
||||
|
|
@ -1993,7 +1994,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
|
|||
auto port_t = ty.mk_port(fcx.ccx.tystore, lhs_t1);
|
||||
auto rhs_1 = Pushdown.pushdown_expr(fcx, port_t, rhs_0);
|
||||
auto item_t;
|
||||
alt (expr_ty(fcx.ccx.tystore, rhs_0).struct) {
|
||||
alt (struct(expr_ty(fcx.ccx.tystore, rhs_0))) {
|
||||
case (ty.ty_port(?it)) {
|
||||
item_t = it;
|
||||
}
|
||||
|
|
@ -2163,7 +2164,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
|
|||
auto proto_1;
|
||||
let vec[ty.arg] arg_tys_1 = vec();
|
||||
auto rt_1;
|
||||
alt (expr_ty(fcx.ccx.tystore, result._0).struct) {
|
||||
alt (struct(expr_ty(fcx.ccx.tystore, result._0))) {
|
||||
case (ty.ty_fn(?proto, ?arg_tys, ?rt)) {
|
||||
proto_1 = proto;
|
||||
rt_1 = rt;
|
||||
|
|
@ -2201,7 +2202,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
|
|||
|
||||
// Pull the return type out of the type of the function.
|
||||
auto rt_1 = ty.mk_nil(fcx.ccx.tystore); // FIXME: typestate botch
|
||||
alt (expr_ty(fcx.ccx.tystore, f_1).struct) {
|
||||
alt (struct(expr_ty(fcx.ccx.tystore, f_1))) {
|
||||
case (ty.ty_fn(_,_,?rt)) { rt_1 = rt; }
|
||||
case (ty.ty_native_fn(_, _, ?rt)) { rt_1 = rt; }
|
||||
case (_) {
|
||||
|
|
@ -2233,7 +2234,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
|
|||
// Grab this method's type out of the current object type
|
||||
|
||||
// this_obj_ty is an @ty.t
|
||||
alt (this_obj_ty.struct) {
|
||||
alt (struct(this_obj_ty)) {
|
||||
case (ty.ty_obj(?methods)) {
|
||||
for (ty.method method in methods) {
|
||||
if (method.ident == id) {
|
||||
|
|
@ -2257,9 +2258,9 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
|
|||
auto args_1 = result._1;
|
||||
|
||||
// Check the return type
|
||||
alt (expr_ty(fcx.ccx.tystore, f_1).struct) {
|
||||
alt (struct(expr_ty(fcx.ccx.tystore, f_1))) {
|
||||
case (ty.ty_fn(_,_,?rt)) {
|
||||
alt (rt.struct) {
|
||||
alt (struct(rt)) {
|
||||
case (ty.ty_nil) {
|
||||
// This is acceptable
|
||||
}
|
||||
|
|
@ -2373,7 +2374,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
|
|||
|
||||
let vec[field] base_fields = vec();
|
||||
|
||||
alt (bexpr_t.struct) {
|
||||
alt (struct(bexpr_t)) {
|
||||
case (ty.ty_rec(?flds)) {
|
||||
base_fields = flds;
|
||||
}
|
||||
|
|
@ -2412,7 +2413,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
|
|||
case (ast.expr_field(?base, ?field, _)) {
|
||||
auto base_1 = check_expr(fcx, base);
|
||||
auto base_t = strip_boxes(expr_ty(fcx.ccx.tystore, base_1));
|
||||
alt (base_t.struct) {
|
||||
alt (struct(base_t)) {
|
||||
case (ty.ty_tup(?args)) {
|
||||
let uint ix = ty.field_num(fcx.ccx.sess,
|
||||
expr.span, field);
|
||||
|
|
@ -2473,7 +2474,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
|
|||
auto idx_1 = check_expr(fcx, idx);
|
||||
auto idx_t = expr_ty(fcx.ccx.tystore, idx_1);
|
||||
|
||||
alt (base_t.struct) {
|
||||
alt (struct(base_t)) {
|
||||
case (ty.ty_vec(?mt)) {
|
||||
if (! type_is_integral(idx_t)) {
|
||||
fcx.ccx.sess.span_err
|
||||
|
|
@ -2520,7 +2521,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
|
|||
case (ast.expr_chan(?x, _)) {
|
||||
auto expr_1 = check_expr(fcx, x);
|
||||
auto port_t = expr_ty(fcx.ccx.tystore, expr_1);
|
||||
alt (port_t.struct) {
|
||||
alt (struct(port_t)) {
|
||||
case (ty.ty_port(?subtype)) {
|
||||
auto ct = ty.mk_chan(fcx.ccx.tystore, subtype);
|
||||
auto ann = triv_ann(ct);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue