Remove def_obj

Since obj constructors and types have different def_ids now,
their def can simply be a def_fn and a def_ty.
This commit is contained in:
Marijn Haverbeke 2011-06-23 18:07:58 +02:00
parent b4c0893a39
commit 3d7fdb509a
7 changed files with 7 additions and 28 deletions

View file

@ -556,7 +556,7 @@ fn encode_info_for_item(@trans::crate_ctxt cx, &ebml::writer ebml_w,
case (item_obj(_, ?tps, ?ctor_id)) {
ebml::start_tag(ebml_w, tag_items_data_item);
encode_def_id(ebml_w, local_def(ctor_id));
encode_kind(ebml_w, 'o' as u8);
encode_kind(ebml_w, 'f' as u8);
encode_type_param_count(ebml_w, tps);
auto fn_ty = trans::node_id_type(cx, item.id);
encode_type(cx, ebml_w, fn_ty);

View file

@ -412,7 +412,7 @@ fn resolve_constr(@env e, node_id id, &@ast::constr c, &scopes sc,
lookup_path_strict(*e, sc, c.span, c.node.path.node.idents, ns_value);
if (option::is_some(new_def)) {
alt (option::get(new_def)) {
case (ast::def_fn(?pred_id, _)) {
case (ast::def_fn(?pred_id, ast::pure_fn)) {
let ty::constr_general[uint] c_ =
rec(path=c.node.path, args=c.node.args, id=pred_id);
let ty::constr_def new_constr = respan(c.span, c_);
@ -826,8 +826,9 @@ fn found_def_item(&@ast::item i, namespace ns) -> option::t[def] {
}
case (ast::item_obj(_, _, ?ctor_id)) {
alt (ns) {
case (ns_value) { ret some(ast::def_obj(local_def(ctor_id)));}
case (ns_type) { ret some(ast::def_obj(local_def(i.id))); }
case (ns_value) { ret some(ast::def_fn(local_def(ctor_id),
ast::impure_fn)); }
case (ns_type) { ret some(ast::def_ty(local_def(i.id))); }
case (_) { }
}
}
@ -1123,7 +1124,6 @@ fn index_nmod(&ast::native_mod md) -> mod_index {
fn ns_for_def(def d) -> namespace {
ret alt (d) {
case (ast::def_fn(?id, _)) { ns_value }
case (ast::def_obj(?id)) { ns_value }
case (ast::def_obj_field(?id)) { ns_value }
case (ast::def_mod(?id)) { ns_module }
case (ast::def_native_mod(?id)) { ns_module }

View file

@ -4718,10 +4718,6 @@ fn trans_path(&@block_ctxt cx, &ast::path p, ast::node_id id) -> lval_result {
auto tyt = ty::lookup_item_type(cx.fcx.lcx.ccx.tcx, did);
ret lval_generic_fn(cx, tyt, did, id);
}
case (ast::def_obj(?did)) {
auto tyt = ty::lookup_item_type(cx.fcx.lcx.ccx.tcx, did);
ret lval_generic_fn(cx, tyt, did, id);
}
case (ast::def_variant(?tid, ?vid)) {
auto v_tyt = ty::lookup_item_type(cx.fcx.lcx.ccx.tcx, vid);
alt (ty::struct(cx.fcx.lcx.ccx.tcx, v_tyt._1)) {

View file

@ -2658,7 +2658,6 @@ fn substitute_type_params(&ctxt cx, vec[ty::t] substs, t typ) -> t {
fn def_has_ty_params(&ast::def def) -> bool {
alt (def) {
case (ast::def_fn(_,_)) { ret true; }
case (ast::def_obj(_)) { ret true; }
case (ast::def_obj_field(_)) { ret false; }
case (ast::def_mod(_)) { ret false; }
case (ast::def_const(_)) { ret false; }

View file

@ -105,9 +105,6 @@ fn ty_param_count_and_ty_for_def(&@fn_ctxt fcx, &span sp, &ast::def defn) ->
auto typ = ty::mk_var(fcx.ccx.tcx, fcx.locals.get(id._1));
ret tup(0u, typ);
}
case (ast::def_obj(?id)) {
ret ty::lookup_item_type(fcx.ccx.tcx, id);
}
case (ast::def_mod(_)) {
// Hopefully part of a path.
// TODO: return a type that's more poisonous, perhaps?
@ -327,11 +324,6 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
path.node.types);
}
case (ast::def_native_ty(?id)) { typ = getter(id)._1; }
case (ast::def_obj(?id)) {
typ =
instantiate(tcx, ast_ty.span, getter, id,
path.node.types);
}
case (ast::def_ty_arg(?id)) { typ = ty::mk_param(tcx, id); }
case (_) {
tcx.sess.span_fatal(ast_ty.span,