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:
parent
b4c0893a39
commit
3d7fdb509a
@ -28,7 +28,6 @@ type ty_param = ident;
|
||||
|
||||
tag def {
|
||||
def_fn(def_id, purity);
|
||||
def_obj(def_id);
|
||||
def_obj_field(def_id);
|
||||
def_mod(def_id);
|
||||
def_native_mod(def_id);
|
||||
@ -55,7 +54,6 @@ fn variant_def_ids(&def d) -> tup(def_id, def_id) {
|
||||
fn def_id_of_def(def d) -> def_id {
|
||||
alt (d) {
|
||||
case (def_fn(?id,_)) { ret id; }
|
||||
case (def_obj(?id)) { ret id; }
|
||||
case (def_obj_field(?id)) { ret id; }
|
||||
case (def_mod(?id)) { ret id; }
|
||||
case (def_native_mod(?id)) { ret id; }
|
||||
|
@ -701,7 +701,6 @@ fn kind_has_type_params(u8 kind_ch) -> bool {
|
||||
case ('p') { true }
|
||||
case ('F') { true }
|
||||
case ('y') { true }
|
||||
case ('o') { true }
|
||||
case ('t') { true }
|
||||
case ('T') { false }
|
||||
case ('m') { false }
|
||||
@ -731,13 +730,9 @@ fn lookup_def(int cnum, vec[u8] data, &ast::def_id did_) -> ast::def {
|
||||
case ('p') { ast::def_fn(did, ast::pure_fn) }
|
||||
case ('F') { ast::def_native_fn(did) }
|
||||
case ('y') { ast::def_ty(did) }
|
||||
case ('o') { ast::def_obj(did) }
|
||||
case ('T') { ast::def_native_ty(did) }
|
||||
case (
|
||||
// We treat references to tags as references to types.
|
||||
't') {
|
||||
ast::def_ty(did)
|
||||
}
|
||||
// We treat references to tags as references to types.
|
||||
case ('t') { ast::def_ty(did) }
|
||||
case ('m') { ast::def_mod(did) }
|
||||
case ('n') { ast::def_native_mod(did) }
|
||||
case ('v') {
|
||||
@ -843,7 +838,6 @@ fn item_kind_to_str(u8 kind) -> str {
|
||||
case ('p') { ret "pred"; }
|
||||
case ('F') { ret "native fn"; }
|
||||
case ('y') { ret "type"; }
|
||||
case ('o') { ret "obj"; }
|
||||
case ('T') { ret "native type"; }
|
||||
case ('t') { ret "type"; }
|
||||
case ('m') { ret "mod"; }
|
||||
|
@ -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);
|
||||
|
@ -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 }
|
||||
|
@ -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)) {
|
||||
|
@ -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; }
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user