about summary refs log tree commit diff
path: root/src/comp/syntax
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2012-01-25 14:34:31 +0100
committerMarijn Haverbeke <marijnh@gmail.com>2012-01-25 14:34:31 +0100
commit76aabbe99d598dc42e8e3723d98516422bd26d33 (patch)
tree3beefd7e656624cba83b6c3f503459de1ac2e299 /src/comp/syntax
parent8420f8c52e5946f64d93c721d0f673b49ad966f7 (diff)
downloadrust-76aabbe99d598dc42e8e3723d98516422bd26d33.tar.gz
rust-76aabbe99d598dc42e8e3723d98516422bd26d33.zip
Rename tag to enum throughout the compiler
This should reduce confusion of people trying to read the code.
Diffstat (limited to 'src/comp/syntax')
-rw-r--r--src/comp/syntax/ast.rs12
-rw-r--r--src/comp/syntax/ast_util.rs23
-rw-r--r--src/comp/syntax/fold.rs8
-rw-r--r--src/comp/syntax/parse/parser.rs30
-rw-r--r--src/comp/syntax/print/pprust.rs8
-rw-r--r--src/comp/syntax/visit.rs4
6 files changed, 43 insertions, 42 deletions
diff --git a/src/comp/syntax/ast.rs b/src/comp/syntax/ast.rs
index 661bb68309d..7f7f6d76bc1 100644
--- a/src/comp/syntax/ast.rs
+++ b/src/comp/syntax/ast.rs
@@ -103,12 +103,12 @@ enum pat_ {
     // In the nullary enum case, the parser can't determine
     // which it is. The resolver determines this, and
     // records this pattern's node_id in an auxiliary
-    // set (of "pat_idents that refer to nullary tags")
+    // set (of "pat_idents that refer to nullary enums")
     // After the resolution phase, code should never pattern-
     // match on a pat directly! Always call pat_util::normalize_pat --
-    // it turns any pat_idents that refer to nullary tags into pat_tags.
+    // it turns any pat_idents that refer to nullary enums into pat_enums.
     pat_ident(@path, option::t<@pat>),
-    pat_tag(@path, [@pat]),
+    pat_enum(@path, [@pat]),
     pat_rec([field_pat], bool),
     pat_tup([@pat]),
     pat_box(@pat),
@@ -440,9 +440,9 @@ enum view_item_ {
     view_item_import_from(@simple_path, [import_ident], node_id),
     view_item_export([ident], node_id),
     // export foo::{}
-    view_item_export_tag_none(ident, node_id),
+    view_item_export_enum_none(ident, node_id),
     // export foo::{bar, baz, blat}
-    view_item_export_tag_some(ident, [import_ident], node_id)
+    view_item_export_enum_some(ident, [import_ident], node_id)
 }
 
 // Meta-data associated with an item
@@ -465,7 +465,7 @@ enum item_ {
     item_mod(_mod),
     item_native_mod(native_mod),
     item_ty(@ty, [ty_param]),
-    item_tag([variant], [ty_param]),
+    item_enum([variant], [ty_param]),
     item_res(fn_decl /* dtor */, [ty_param], blk,
              node_id /* dtor id */, node_id /* ctor id */),
     item_iface([ty_param], [ty_method]),
diff --git a/src/comp/syntax/ast_util.rs b/src/comp/syntax/ast_util.rs
index 7d5e07d7950..53fb3e094d7 100644
--- a/src/comp/syntax/ast_util.rs
+++ b/src/comp/syntax/ast_util.rs
@@ -20,7 +20,7 @@ fn path_name_i(idents: [ident]) -> str { str::connect(idents, "::") }
 fn local_def(id: node_id) -> def_id { ret {crate: local_crate, node: id}; }
 
 fn variant_def_ids(d: def) -> {tg: def_id, var: def_id} {
-    alt d { def_variant(tag_id, var_id) { ret {tg: tag_id, var: var_id}; } }
+    alt d { def_variant(enum_id, var_id) { ret {tg: enum_id, var: var_id}; } }
 }
 
 fn def_id_of_def(d: def) -> def_id {
@@ -113,15 +113,15 @@ fn float_ty_to_str(t: float_ty) -> str {
 
 fn is_exported(i: ident, m: _mod) -> bool {
     let nonlocal = true;
-    let parent_tag : option<ident> = none;
+    let parent_enum : option<ident> = none;
     for it: @item in m.items {
         if it.ident == i { nonlocal = false; }
         alt it.node {
-          item_tag(variants, _) {
+          item_enum(variants, _) {
             for v: variant in variants {
                 if v.node.name == i {
                    nonlocal = false;
-                   parent_tag = some(it.ident);
+                   parent_enum = some(it.ident);
                 }
             }
           }
@@ -133,24 +133,24 @@ fn is_exported(i: ident, m: _mod) -> bool {
     for vi: @view_item in m.view_items {
         alt vi.node {
           view_item_export(ids, _) {
-              // If any of ids is a tag, we want to consider
+              // If any of ids is a enum, we want to consider
               // all the variants to be exported
             for id in ids {
                 if str::eq(i, id) { ret true; }
-                alt parent_tag {
-                    some(parent_tag_id) {
-                        if str::eq(id, parent_tag_id) { ret true; }
+                alt parent_enum {
+                    some(parent_enum_id) {
+                        if str::eq(id, parent_enum_id) { ret true; }
                     }
                     _ { }
                  }
             }
             count += 1u;
           }
-          view_item_export_tag_none(id, _) {
+          view_item_export_enum_none(id, _) {
               if str::eq(i, id) { ret true; }
               count += 1u;
           }
-          view_item_export_tag_some(id, ids, _) {
+          view_item_export_enum_some(id, ids, _) {
               if str::eq(i, id) { ret true; }
               for id in ids { if str::eq(i, id.node.name) { ret true; } }
               count += 1u;
@@ -278,7 +278,8 @@ fn eval_const_expr(e: @expr) -> const_val {
               mul { const_uint(a * b) } div { const_uint(a / b) }
               rem { const_uint(a % b) } and | bitand { const_uint(a & b) }
               or | bitor { const_uint(a | b) } bitxor { const_uint(a ^ b) }
-              lsl { const_int(a << b as i64) } lsr { const_int(a >> b as i64) }
+              lsl { const_int(a << b as i64) }
+              lsr { const_int(a >> b as i64) }
               asr { const_int(a >>> b as i64) }
               eq { fromb(a == b) } lt { fromb(a < b) }
               le { fromb(a <= b) } ne { fromb(a != b) }
diff --git a/src/comp/syntax/fold.rs b/src/comp/syntax/fold.rs
index f4647211f61..d2019930b4a 100644
--- a/src/comp/syntax/fold.rs
+++ b/src/comp/syntax/fold.rs
@@ -226,8 +226,8 @@ fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ {
           item_mod(m) { item_mod(fld.fold_mod(m)) }
           item_native_mod(nm) { item_native_mod(fld.fold_native_mod(nm)) }
           item_ty(t, typms) { item_ty(fld.fold_ty(t), typms) }
-          item_tag(variants, typms) {
-            item_tag(vec::map(variants, fld.fold_variant), typms)
+          item_enum(variants, typms) {
+            item_enum(vec::map(variants, fld.fold_variant), typms)
           }
           item_impl(tps, ifce, ty, methods) {
             item_impl(tps, option::map(ifce, fld.fold_ty), fld.fold_ty(ty),
@@ -279,8 +279,8 @@ fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ {
             pat_ident(fld.fold_path(pth), option::map(sub, fld.fold_pat))
           }
           pat_lit(_) { p }
-          pat_tag(pth, pats) {
-            pat_tag(fld.fold_path(pth), vec::map(pats, fld.fold_pat))
+          pat_enum(pth, pats) {
+            pat_enum(fld.fold_path(pth), vec::map(pats, fld.fold_pat))
           }
           pat_rec(fields, etc) {
             let fs = [];
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs
index 8d95a670421..602e209e573 100644
--- a/src/comp/syntax/parse/parser.rs
+++ b/src/comp/syntax/parse/parser.rs
@@ -1501,8 +1501,8 @@ fn parse_pat(p: parser) -> @ast::pat {
             let sub = eat(p, token::AT) ? some(parse_pat(p)) : none;
             pat = ast::pat_ident(name, sub);
         } else {
-            let tag_path = parse_path_and_ty_param_substs(p, true);
-            hi = tag_path.span.hi;
+            let enum_path = parse_path_and_ty_param_substs(p, true);
+            hi = enum_path.span.hi;
             let args: [@ast::pat];
             alt p.token {
               token::LPAREN {
@@ -1516,11 +1516,11 @@ fn parse_pat(p: parser) -> @ast::pat {
             }
             // at this point, we're not sure whether it's a enum or a bind
             if vec::len(args) == 0u &&
-               vec::len(tag_path.node.idents) == 1u {
-                pat = ast::pat_ident(tag_path, none);
+               vec::len(enum_path.node.idents) == 1u {
+                pat = ast::pat_ident(enum_path, none);
             }
             else {
-                pat = ast::pat_tag(tag_path, args);
+                pat = ast::pat_enum(enum_path, args);
             }
         }
       }
@@ -2024,7 +2024,7 @@ fn parse_item_type(p: parser, attrs: [ast::attribute]) -> @ast::item {
     ret mk_item(p, t.lo, hi, t.ident, ast::item_ty(ty, tps), attrs);
 }
 
-fn parse_item_tag(p: parser, attrs: [ast::attribute]) -> @ast::item {
+fn parse_item_enum(p: parser, attrs: [ast::attribute]) -> @ast::item {
     let lo = p.last_span.lo;
     let id = parse_ident(p);
     let ty_params = parse_ty_params(p);
@@ -2044,7 +2044,7 @@ fn parse_item_tag(p: parser, attrs: [ast::attribute]) -> @ast::item {
                      id: p.get_id(),
                      disr_expr: none});
         ret mk_item(p, lo, ty.span.hi, id,
-                    ast::item_tag([variant], ty_params), attrs);
+                    ast::item_enum([variant], ty_params), attrs);
     }
     expect(p, token::LBRACE);
     let all_nullary = true, have_disr = false;
@@ -2077,7 +2077,7 @@ fn parse_item_tag(p: parser, attrs: [ast::attribute]) -> @ast::item {
         p.fatal("discriminator values can only be used with a c-like enum");
     }
     ret mk_item(p, lo, p.last_span.hi, id,
-                ast::item_tag(variants, ty_params), attrs);
+                ast::item_enum(variants, ty_params), attrs);
 }
 
 fn parse_fn_ty_proto(p: parser) -> ast::proto {
@@ -2134,7 +2134,7 @@ fn parse_item(p: parser, attrs: [ast::attribute]) -> option::t<@ast::item> {
     } if eat_word(p, "type") {
         ret some(parse_item_type(p, attrs));
     } else if eat_word(p, "enum") {
-        ret some(parse_item_tag(p, attrs));
+        ret some(parse_item_enum(p, attrs));
     } else if eat_word(p, "iface") {
         ret some(parse_item_iface(p, attrs));
     } else if eat_word(p, "impl") {
@@ -2364,16 +2364,16 @@ fn parse_import(p: parser) -> ast::view_item_ {
     }
 }
 
-fn parse_tag_export(p:parser, tyname:ast::ident) -> ast::view_item_ {
-    let tagnames:[ast::import_ident] =
+fn parse_enum_export(p:parser, tyname:ast::ident) -> ast::view_item_ {
+    let enumnames:[ast::import_ident] =
         parse_seq(token::LBRACE, token::RBRACE,
              seq_sep(token::COMMA), {|p| parse_import_ident(p) }, p).node;
     let id = p.get_id();
-    if vec::is_empty(tagnames) {
-       ret ast::view_item_export_tag_none(tyname, id);
+    if vec::is_empty(enumnames) {
+       ret ast::view_item_export_enum_none(tyname, id);
     }
     else {
-       ret ast::view_item_export_tag_some(tyname, tagnames, id);
+       ret ast::view_item_export_enum_some(tyname, enumnames, id);
     }
 }
 
@@ -2382,7 +2382,7 @@ fn parse_export(p: parser) -> ast::view_item_ {
     alt p.token {
        token::MOD_SEP {
            p.bump();
-           ret parse_tag_export(p, first);
+           ret parse_enum_export(p, first);
        }
        t {
            if t == token::COMMA { p.bump(); }
diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs
index 1f09436361d..ad6f96e9a1b 100644
--- a/src/comp/syntax/print/pprust.rs
+++ b/src/comp/syntax/print/pprust.rs
@@ -412,7 +412,7 @@ fn print_item(s: ps, &&item: @ast::item) {
         word(s.s, ";");
         end(s); // end the outer ibox
       }
-      ast::item_tag(variants, params) {
+      ast::item_enum(variants, params) {
         let newtype =
             vec::len(variants) == 1u &&
                 str::eq(item.ident, variants[0].node.name) &&
@@ -1081,7 +1081,7 @@ fn print_pat(s: ps, &&pat: @ast::pat) {
           _ {}
         }
       }
-      ast::pat_tag(path, args) {
+      ast::pat_enum(path, args) {
         print_path(s, path, true);
         if vec::len(args) > 0u {
             popen(s);
@@ -1304,12 +1304,12 @@ fn print_view_item(s: ps, item: @ast::view_item) {
         commasep(s, inconsistent, ids,
                  fn@(s: ps, &&w: ast::ident) { word(s.s, w) });
       }
-      ast::view_item_export_tag_none(id, _) {
+      ast::view_item_export_enum_none(id, _) {
           head(s, "export");
           word(s.s, id);
           word(s.s, "::{}");
       }
-      ast::view_item_export_tag_some(id, ids, _) {
+      ast::view_item_export_enum_some(id, ids, _) {
           head(s, "export");
           word(s.s, id);
           word(s.s, "::{");
diff --git a/src/comp/syntax/visit.rs b/src/comp/syntax/visit.rs
index ddabc5e1c48..e60e5b097ea 100644
--- a/src/comp/syntax/visit.rs
+++ b/src/comp/syntax/visit.rs
@@ -120,7 +120,7 @@ fn visit_item<E>(i: @item, e: E, v: vt<E>) {
         v.visit_fn(fk_res(i.ident, tps), decl, body, i.span,
                    dtor_id, e, v);
       }
-      item_tag(variants, tps) {
+      item_enum(variants, tps) {
         v.visit_ty_params(tps, e, v);
         for vr: variant in variants {
             for va: variant_arg in vr.node.args { v.visit_ty(va.ty, e, v); }
@@ -187,7 +187,7 @@ fn visit_path<E>(p: @path, e: E, v: vt<E>) {
 
 fn visit_pat<E>(p: @pat, e: E, v: vt<E>) {
     alt p.node {
-      pat_tag(path, children) {
+      pat_enum(path, children) {
         visit_path(path, e, v);
         for child: @pat in children { v.visit_pat(child, e, v); }
       }