Add a type_is_tup_like predicate that takes a block ctxt, and make some fns pure
This commit is contained in:
parent
8613f28a16
commit
2b98eccfee
2 changed files with 18 additions and 15 deletions
|
|
@ -449,14 +449,14 @@ fn find_scope_cx(cx: @block_ctxt) -> @block_ctxt {
|
|||
// Accessors
|
||||
// TODO: When we have overloading, simplify these names!
|
||||
|
||||
fn bcx_tcx(bcx: @block_ctxt) -> ty::ctxt { ret bcx.fcx.lcx.ccx.tcx; }
|
||||
fn bcx_ccx(bcx: @block_ctxt) -> @crate_ctxt { ret bcx.fcx.lcx.ccx; }
|
||||
fn bcx_lcx(bcx: @block_ctxt) -> @local_ctxt { ret bcx.fcx.lcx; }
|
||||
fn bcx_fcx(bcx: @block_ctxt) -> @fn_ctxt { ret bcx.fcx; }
|
||||
fn fcx_ccx(fcx: @fn_ctxt) -> @crate_ctxt { ret fcx.lcx.ccx; }
|
||||
fn fcx_tcx(fcx: @fn_ctxt) -> ty::ctxt { ret fcx.lcx.ccx.tcx; }
|
||||
fn lcx_ccx(lcx: @local_ctxt) -> @crate_ctxt { ret lcx.ccx; }
|
||||
fn ccx_tcx(ccx: @crate_ctxt) -> ty::ctxt { ret ccx.tcx; }
|
||||
pure fn bcx_tcx(bcx: @block_ctxt) -> ty::ctxt { bcx.fcx.lcx.ccx.tcx }
|
||||
pure fn bcx_ccx(bcx: @block_ctxt) -> @crate_ctxt { bcx.fcx.lcx.ccx }
|
||||
pure fn bcx_lcx(bcx: @block_ctxt) -> @local_ctxt { bcx.fcx.lcx }
|
||||
pure fn bcx_fcx(bcx: @block_ctxt) -> @fn_ctxt { bcx.fcx }
|
||||
pure fn fcx_ccx(fcx: @fn_ctxt) -> @crate_ctxt { fcx.lcx.ccx }
|
||||
pure fn fcx_tcx(fcx: @fn_ctxt) -> ty::ctxt { fcx.lcx.ccx.tcx }
|
||||
pure fn lcx_ccx(lcx: @local_ctxt) -> @crate_ctxt { lcx.ccx }
|
||||
pure fn ccx_tcx(ccx: @crate_ctxt) -> ty::ctxt { ccx.tcx }
|
||||
|
||||
// LLVM type constructors.
|
||||
fn T_void() -> TypeRef {
|
||||
|
|
@ -861,6 +861,11 @@ pure fn returns_non_ty_var(cx: @crate_ctxt, t: ty::t) -> bool {
|
|||
non_ty_var(cx, ty::ty_fn_ret(cx.tcx, t))
|
||||
}
|
||||
|
||||
pure fn type_is_tup_like(cx: @block_ctxt, t: ty::t) -> bool {
|
||||
let tcx = bcx_tcx(cx);
|
||||
ty::type_is_tup_like(tcx, t)
|
||||
}
|
||||
|
||||
//
|
||||
// Local Variables:
|
||||
// mode: rust
|
||||
|
|
|
|||
|
|
@ -832,13 +832,11 @@ fn sequence_element_type(cx: ctxt, ty: t) -> t {
|
|||
}
|
||||
}
|
||||
|
||||
fn type_is_tup_like(cx: ctxt, ty: t) -> bool {
|
||||
alt struct(cx, ty) {
|
||||
ty_box(_) { ret true; }
|
||||
ty_rec(_) { ret true; }
|
||||
ty_tup(_) { ret true; }
|
||||
ty_tag(_, _) { ret true; }
|
||||
_ { ret false; }
|
||||
pure fn type_is_tup_like(cx: ctxt, ty: t) -> bool {
|
||||
let sty = unchecked { struct(cx, ty) };
|
||||
alt sty {
|
||||
ty_box(_) | ty_rec(_) | ty_tup(_) | ty_tag(_,_) { true }
|
||||
_ { false }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue