Skip to content

Commit

Permalink
Removed duplicated ret_ty_of_fn. This also means the native function …
Browse files Browse the repository at this point in the history
…branch is working now, so this commit closes #506.
  • Loading branch information
Eric Holk committed Jun 20, 2011
1 parent ce50ae3 commit 9921536
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
27 changes: 7 additions & 20 deletions src/comp/middle/trans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7055,21 +7055,6 @@ fn arg_tys_of_fn(&@crate_ctxt ccx, ast::ann ann) -> vec[ty::arg] {
}
}

fn ret_ty_of_fn_ty(&@crate_ctxt ccx, ty::t t) -> ty::t {
alt (ty::struct(ccx.tcx, t)) {
case (ty::ty_fn(_, _, ?ret_ty, _, _)) { ret ret_ty; }
case (ty::ty_native_fn(_, _, ?ret_ty)) { ret ret_ty; }
case (_) {
ccx.sess.bug("ret_ty_of_fn_ty() called on non-function type: " +
ty_to_str(ccx.tcx, t));
}
}
}

fn ret_ty_of_fn(&@crate_ctxt ccx, ast::ann ann) -> ty::t {
ret ret_ty_of_fn_ty(ccx, ty::ann_to_type(ccx.tcx, ann));
}

fn populate_fn_ctxt_from_llself(@fn_ctxt fcx, val_self_pair llself) {
auto bcx = llstaticallocas_block_ctxt(fcx);
let vec[ty::t] field_tys = [];
Expand Down Expand Up @@ -7143,8 +7128,8 @@ fn trans_fn(@local_ctxt cx, &span sp, &ast::_fn f, ValueRef llfndecl,

auto fcx = new_fn_ctxt(cx, sp, llfndecl);
create_llargs_for_fn_args(fcx, f.proto, ty_self,
ret_ty_of_fn(cx.ccx, ann), f.decl.inputs,
ty_params);
ty::ret_ty_of_fn(cx.ccx.tcx, ann),
f.decl.inputs, ty_params);
copy_any_self_to_alloca(fcx, ty_self);
alt ({ fcx.llself }) {
case (some(?llself)) { populate_fn_ctxt_from_llself(fcx, llself); }
Expand Down Expand Up @@ -7275,7 +7260,8 @@ fn trans_obj(@local_ctxt cx, &span sp, &ast::_obj ob, ast::def_id oid,
// Both regular arguments and type parameters are handled here.

create_llargs_for_fn_args(fcx, ast::proto_fn, none[ty_self_pair],
ret_ty_of_fn(ccx, ann), fn_args, ty_params);
ty::ret_ty_of_fn(ccx.tcx, ann),
fn_args, ty_params);
let vec[ty::arg] arg_tys = arg_tys_of_fn(ccx, ann);
copy_args_to_allocas(fcx, fn_args, arg_tys);
// Create the first block context in the function and keep a handle on it
Expand All @@ -7286,7 +7272,7 @@ fn trans_obj(@local_ctxt cx, &span sp, &ast::_obj ob, ast::def_id oid,
// Pick up the type of this object by looking at our own output type, that
// is, the output type of the object constructor we're building.

auto self_ty = ret_ty_of_fn(ccx, ann);
auto self_ty = ty::ret_ty_of_fn(ccx.tcx, ann);
auto llself_ty = type_of(ccx, sp, self_ty);
// Set up the two-word pair that we're going to return from the object
// constructor we're building. The two elements of this pair will be a
Expand Down Expand Up @@ -7461,7 +7447,8 @@ fn trans_tag_variant(@local_ctxt cx, ast::def_id tag_id,
let ValueRef llfndecl = cx.ccx.item_ids.get(variant.node.id);
auto fcx = new_fn_ctxt(cx, variant.span, llfndecl);
create_llargs_for_fn_args(fcx, ast::proto_fn, none[ty_self_pair],
ret_ty_of_fn(cx.ccx, variant.node.ann), fn_args,
ty::ret_ty_of_fn(cx.ccx.tcx, variant.node.ann),
fn_args,
ty_params);
let vec[ty::t] ty_param_substs = [];
i = 0u;
Expand Down
6 changes: 5 additions & 1 deletion src/comp/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import front::creader;
import middle::metadata;
import util::common::*;
import util::data::interner;
import pretty::ppaux::ty_to_str;


export ann_to_monotype;
export ann_to_type;
Expand Down Expand Up @@ -2741,8 +2743,10 @@ fn lookup_item_type(ctxt cx, ast::def_id did) -> ty_param_count_and_ty {
fn ret_ty_of_fn_ty(ctxt cx, t a_ty) -> t {
alt (ty::struct(cx, a_ty)) {
case (ty::ty_fn(_, _, ?ret_ty, _, _)) { ret ret_ty; }
case (ty::ty_native_fn(_, _, ?ret_ty)) { ret ret_ty; }
case (_) {
cx.sess.bug("ret_ty_of_fn_ty() called on non-function type");
cx.sess.bug("ret_ty_of_fn_ty() called on non-function type: " +
ty_to_str(cx, a_ty));
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/run-pass/issue-506.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
A reduced test case for Issue #506, provided by Rob Arnold.
*/

// xfail-stage0

native "rust" mod rustrt {
fn task_yield();
}
Expand Down

0 comments on commit 9921536

Please sign in to comment.