aboutsummaryrefslogtreecommitdiff
path: root/src/comp/front
diff options
context:
space:
mode:
authorPatrick Walton <[email protected]>2011-04-12 15:09:50 -0700
committerPatrick Walton <[email protected]>2011-04-12 15:10:40 -0700
commitde0175abed80b13d8d8528002fe637d8c9687c93 (patch)
tree88fe8e28d5cc64c174233c0986ddc4734f2280e1 /src/comp/front
parentrustc: Add "float" as a type to the pretty printer (diff)
downloadrust-de0175abed80b13d8d8528002fe637d8c9687c93.tar.xz
rust-de0175abed80b13d8d8528002fe637d8c9687c93.zip
rustc: Switch to indices for type parameters
Diffstat (limited to 'src/comp/front')
-rw-r--r--src/comp/front/ast.rs6
-rw-r--r--src/comp/front/creader.rs25
-rw-r--r--src/comp/front/parser.rs3
3 files changed, 16 insertions, 18 deletions
diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs
index 50517f00..dfc69695 100644
--- a/src/comp/front/ast.rs
+++ b/src/comp/front/ast.rs
@@ -17,7 +17,7 @@ type crate_num = int;
type def_num = int;
type def_id = tup(crate_num, def_num);
-type ty_param = rec(ident ident, def_id id);
+type ty_param = ident;
// Annotations added during successive passes.
tag ann {
@@ -39,7 +39,7 @@ tag def {
def_upvar(def_id);
def_variant(def_id /* tag */, def_id /* variant */);
def_ty(def_id);
- def_ty_arg(def_id);
+ def_ty_arg(uint);
def_binding(def_id);
def_use(def_id);
def_native_ty(def_id);
@@ -59,7 +59,7 @@ fn def_id_of_def(def d) -> def_id {
case (def_upvar(?id)) { ret id; }
case (def_variant(_, ?id)) { ret id; }
case (def_ty(?id)) { ret id; }
- case (def_ty_arg(?id)) { ret id; }
+ case (def_ty_arg(_)) { fail; }
case (def_binding(?id)) { ret id; }
case (def_use(?id)) { ret id; }
case (def_native_ty(?id)) { ret id; }
diff --git a/src/comp/front/creader.rs b/src/comp/front/creader.rs
index 7fc6e247..b7015380 100644
--- a/src/comp/front/creader.rs
+++ b/src/comp/front/creader.rs
@@ -131,7 +131,7 @@ impure fn parse_sty(@pstate st, str_def sd) -> ty.sty {
st.pos = st.pos + 1u;
ret ty.ty_tag(def, params);
}
- case ('p') {ret ty.ty_param(parse_def(st, sd));}
+ case ('p') {ret ty.ty_param(parse_int(st) as uint);}
case ('@') {ret ty.ty_box(parse_mt(st, sd));}
case ('V') {ret ty.ty_vec(parse_mt(st, sd));}
case ('P') {ret ty.ty_port(parse_ty(st, sd));}
@@ -351,14 +351,13 @@ fn item_type(&ebml.doc item, int this_cnum) -> @ty.t {
ret parse_ty_str(s, bind parse_external_def_id(this_cnum, _));
}
-fn item_ty_params(&ebml.doc item, int this_cnum) -> vec[ast.def_id] {
- let vec[ast.def_id] params = vec();
- auto tp = metadata.tag_items_data_item_ty_param;
+fn item_ty_param_count(&ebml.doc item, int this_cnum) -> uint {
+ let uint ty_param_count = 0u;
+ auto tp = metadata.tag_items_data_item_ty_param_count;
for each (ebml.doc p in ebml.tagged_docs(item, tp)) {
- auto ext = parse_def_id(ebml.doc_data(p));
- _vec.push[ast.def_id](params, tup(this_cnum, ext._1));
+ ty_param_count = ebml.vint_at(ebml.doc_data(p), 0u)._0;
}
- ret params;
+ ret ty_param_count;
}
fn tag_variant_ids(&ebml.doc item, int this_cnum) -> vec[ast.def_id] {
@@ -511,23 +510,23 @@ fn lookup_def(session.session sess, int cnum, vec[ast.ident] path)
ret some[ast.def](def);
}
-fn get_type(session.session sess, ast.def_id def) -> ty.ty_params_opt_and_ty {
+fn get_type(session.session sess, ast.def_id def)
+ -> ty.ty_param_count_and_ty {
auto external_crate_id = def._0;
auto data = sess.get_external_crate(external_crate_id);
auto item = lookup_item(def._1, data);
auto t = item_type(item, external_crate_id);
- auto tps_opt;
+ auto tp_count;
auto kind_ch = item_kind(item);
auto has_ty_params = kind_has_type_params(kind_ch);
if (has_ty_params) {
- auto tps = item_ty_params(item, external_crate_id);
- tps_opt = some[vec[ast.def_id]](tps);
+ tp_count = item_ty_param_count(item, external_crate_id);
} else {
- tps_opt = none[vec[ast.def_id]];
+ tp_count = 0u;
}
- ret tup(tps_opt, t);
+ ret tup(tp_count, t);
}
fn get_symbol(session.session sess, ast.def_id def) -> str {
diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs
index 94104655..85badb1e 100644
--- a/src/comp/front/parser.rs
+++ b/src/comp/front/parser.rs
@@ -1740,8 +1740,7 @@ impure fn parse_block(parser p) -> ast.block {
}
impure fn parse_ty_param(parser p) -> ast.ty_param {
- auto ident = parse_ident(p);
- ret rec(ident=ident, id=p.next_def_id());
+ ret parse_ident(p);
}
impure fn parse_ty_params(parser p) -> vec[ast.ty_param] {