Renamed syntax::ast::ident -> Ident

This commit is contained in:
Marvin Löbel 2013-09-02 02:50:59 +02:00
parent 1f4aba8cbf
commit 857f867320
56 changed files with 512 additions and 510 deletions

View file

@ -337,12 +337,12 @@ impl Session_ {
} }
// pointless function, now... // pointless function, now...
pub fn str_of(@self, id: ast::ident) -> @str { pub fn str_of(@self, id: ast::Ident) -> @str {
token::ident_to_str(&id) token::ident_to_str(&id)
} }
// pointless function, now... // pointless function, now...
pub fn ident_of(@self, st: &str) -> ast::ident { pub fn ident_of(@self, st: &str) -> ast::Ident {
token::str_to_ident(st) token::str_to_ident(st)
} }

View file

@ -30,7 +30,7 @@ type node_id_gen = @fn() -> ast::NodeId;
struct Test { struct Test {
span: Span, span: Span,
path: ~[ast::ident], path: ~[ast::Ident],
bench: bool, bench: bool,
ignore: bool, ignore: bool,
should_fail: bool should_fail: bool
@ -39,7 +39,7 @@ struct Test {
struct TestCtxt { struct TestCtxt {
sess: session::Session, sess: session::Session,
crate: @ast::Crate, crate: @ast::Crate,
path: ~[ast::ident], path: ~[ast::Ident],
ext_cx: @ExtCtxt, ext_cx: @ExtCtxt,
testfns: ~[Test] testfns: ~[Test]
} }
@ -383,7 +383,7 @@ fn nospan<T>(t: T) -> codemap::Spanned<T> {
codemap::Spanned { node: t, span: dummy_sp() } codemap::Spanned { node: t, span: dummy_sp() }
} }
fn path_node(ids: ~[ast::ident]) -> ast::Path { fn path_node(ids: ~[ast::Ident]) -> ast::Path {
ast::Path { ast::Path {
span: dummy_sp(), span: dummy_sp(),
global: false, global: false,
@ -395,7 +395,7 @@ fn path_node(ids: ~[ast::ident]) -> ast::Path {
} }
} }
fn path_node_global(ids: ~[ast::ident]) -> ast::Path { fn path_node_global(ids: ~[ast::Ident]) -> ast::Path {
ast::Path { ast::Path {
span: dummy_sp(), span: dummy_sp(),
global: true, global: true,

View file

@ -25,7 +25,7 @@ use syntax::ast_map;
use syntax::diagnostic::expect; use syntax::diagnostic::expect;
pub struct StaticMethodInfo { pub struct StaticMethodInfo {
ident: ast::ident, ident: ast::Ident,
def_id: ast::def_id, def_id: ast::def_id,
purity: ast::purity purity: ast::purity
} }
@ -52,7 +52,7 @@ pub fn each_lang_item(cstore: @mut cstore::CStore,
/// Iterates over each child of the given item. /// Iterates over each child of the given item.
pub fn each_child_of_item(cstore: @mut cstore::CStore, pub fn each_child_of_item(cstore: @mut cstore::CStore,
def_id: ast::def_id, def_id: ast::def_id,
callback: &fn(decoder::DefLike, ast::ident)) { callback: &fn(decoder::DefLike, ast::Ident)) {
let crate_data = cstore::get_crate_data(cstore, def_id.crate); let crate_data = cstore::get_crate_data(cstore, def_id.crate);
let get_crate_data: decoder::GetCrateDataCb = |cnum| { let get_crate_data: decoder::GetCrateDataCb = |cnum| {
cstore::get_crate_data(cstore, cnum) cstore::get_crate_data(cstore, cnum)
@ -68,7 +68,7 @@ pub fn each_child_of_item(cstore: @mut cstore::CStore,
pub fn each_top_level_item_of_crate(cstore: @mut cstore::CStore, pub fn each_top_level_item_of_crate(cstore: @mut cstore::CStore,
cnum: ast::CrateNum, cnum: ast::CrateNum,
callback: &fn(decoder::DefLike, callback: &fn(decoder::DefLike,
ast::ident)) { ast::Ident)) {
let crate_data = cstore::get_crate_data(cstore, cnum); let crate_data = cstore::get_crate_data(cstore, cnum);
let get_crate_data: decoder::GetCrateDataCb = |cnum| { let get_crate_data: decoder::GetCrateDataCb = |cnum| {
cstore::get_crate_data(cstore, cnum) cstore::get_crate_data(cstore, cnum)
@ -129,7 +129,7 @@ pub fn get_method(tcx: ty::ctxt, def: ast::def_id) -> ty::Method {
pub fn get_method_name_and_explicit_self(cstore: @mut cstore::CStore, pub fn get_method_name_and_explicit_self(cstore: @mut cstore::CStore,
def: ast::def_id) def: ast::def_id)
-> (ast::ident, ast::explicit_self_) -> (ast::Ident, ast::explicit_self_)
{ {
let cdata = cstore::get_crate_data(cstore, def.crate); let cdata = cstore::get_crate_data(cstore, def.crate);
decoder::get_method_name_and_explicit_self(cstore.intr, cdata, def.node) decoder::get_method_name_and_explicit_self(cstore.intr, cdata, def.node)
@ -156,7 +156,7 @@ pub fn get_supertraits(tcx: ty::ctxt, def: ast::def_id) -> ~[@ty::TraitRef] {
} }
pub fn get_type_name_if_impl(cstore: @mut cstore::CStore, def: ast::def_id) pub fn get_type_name_if_impl(cstore: @mut cstore::CStore, def: ast::def_id)
-> Option<ast::ident> { -> Option<ast::Ident> {
let cdata = cstore::get_crate_data(cstore, def.crate); let cdata = cstore::get_crate_data(cstore, def.crate);
decoder::get_type_name_if_impl(cdata, def.node) decoder::get_type_name_if_impl(cdata, def.node)
} }
@ -245,7 +245,7 @@ pub fn get_impl_vtables(tcx: ty::ctxt,
pub fn get_impl_method(cstore: @mut cstore::CStore, pub fn get_impl_method(cstore: @mut cstore::CStore,
def: ast::def_id, def: ast::def_id,
mname: ast::ident) mname: ast::Ident)
-> Option<ast::def_id> { -> Option<ast::def_id> {
let cdata = cstore::get_crate_data(cstore, def.crate); let cdata = cstore::get_crate_data(cstore, def.crate);
decoder::get_impl_method(cstore.intr, cdata, def.node, mname) decoder::get_impl_method(cstore.intr, cdata, def.node, mname)

View file

@ -312,12 +312,12 @@ fn item_path(item_doc: ebml::Doc) -> ast_map::path {
return result; return result;
} }
fn item_name(intr: @ident_interner, item: ebml::Doc) -> ast::ident { fn item_name(intr: @ident_interner, item: ebml::Doc) -> ast::Ident {
let name = reader::get_doc(item, tag_paths_data_name); let name = reader::get_doc(item, tag_paths_data_name);
let string = name.as_str_slice(); let string = name.as_str_slice();
match intr.find_equiv(&string) { match intr.find_equiv(&string) {
None => token::str_to_ident(string), None => token::str_to_ident(string),
Some(val) => ast::new_ident(val), Some(val) => ast::Ident::new(val),
} }
} }
@ -452,7 +452,7 @@ pub fn get_impl_vtables(cdata: Cmd,
pub fn get_impl_method(intr: @ident_interner, cdata: Cmd, id: ast::NodeId, pub fn get_impl_method(intr: @ident_interner, cdata: Cmd, id: ast::NodeId,
name: ast::ident) -> Option<ast::def_id> { name: ast::Ident) -> Option<ast::def_id> {
let items = reader::get_doc(reader::Doc(cdata.data), tag_items); let items = reader::get_doc(reader::Doc(cdata.data), tag_items);
let mut found = None; let mut found = None;
do reader::tagged_docs(find_item(id, items), tag_item_impl_method) |mid| { do reader::tagged_docs(find_item(id, items), tag_item_impl_method) |mid| {
@ -706,7 +706,7 @@ fn each_child_of_item_or_crate(intr: @ident_interner,
cdata: Cmd, cdata: Cmd,
item_doc: ebml::Doc, item_doc: ebml::Doc,
get_crate_data: GetCrateDataCb, get_crate_data: GetCrateDataCb,
callback: &fn(DefLike, ast::ident)) { callback: &fn(DefLike, ast::Ident)) {
// Iterate over all children. // Iterate over all children.
let _ = do reader::tagged_docs(item_doc, tag_mod_child) |child_info_doc| { let _ = do reader::tagged_docs(item_doc, tag_mod_child) |child_info_doc| {
let child_def_id = reader::with_doc_data(child_info_doc, let child_def_id = reader::with_doc_data(child_info_doc,
@ -829,7 +829,7 @@ pub fn each_child_of_item(intr: @ident_interner,
cdata: Cmd, cdata: Cmd,
id: ast::NodeId, id: ast::NodeId,
get_crate_data: GetCrateDataCb, get_crate_data: GetCrateDataCb,
callback: &fn(DefLike, ast::ident)) { callback: &fn(DefLike, ast::Ident)) {
// Find the item. // Find the item.
let root_doc = reader::Doc(cdata.data); let root_doc = reader::Doc(cdata.data);
let items = reader::get_doc(root_doc, tag_items); let items = reader::get_doc(root_doc, tag_items);
@ -849,7 +849,7 @@ pub fn each_child_of_item(intr: @ident_interner,
pub fn each_top_level_item_of_crate(intr: @ident_interner, pub fn each_top_level_item_of_crate(intr: @ident_interner,
cdata: Cmd, cdata: Cmd,
get_crate_data: GetCrateDataCb, get_crate_data: GetCrateDataCb,
callback: &fn(DefLike, ast::ident)) { callback: &fn(DefLike, ast::Ident)) {
let root_doc = reader::Doc(cdata.data); let root_doc = reader::Doc(cdata.data);
let misc_info_doc = reader::get_doc(root_doc, tag_misc_info); let misc_info_doc = reader::get_doc(root_doc, tag_misc_info);
let crate_items_doc = reader::get_doc(misc_info_doc, let crate_items_doc = reader::get_doc(misc_info_doc,
@ -995,7 +995,7 @@ pub fn get_impl(intr: @ident_interner, cdata: Cmd, impl_id: ast::NodeId,
pub fn get_method_name_and_explicit_self( pub fn get_method_name_and_explicit_self(
intr: @ident_interner, intr: @ident_interner,
cdata: Cmd, cdata: Cmd,
id: ast::NodeId) -> (ast::ident, ast::explicit_self_) id: ast::NodeId) -> (ast::Ident, ast::explicit_self_)
{ {
let method_doc = lookup_item(id, cdata.data); let method_doc = lookup_item(id, cdata.data);
let name = item_name(intr, method_doc); let name = item_name(intr, method_doc);
@ -1093,7 +1093,7 @@ pub fn get_supertraits(cdata: Cmd, id: ast::NodeId, tcx: ty::ctxt)
} }
pub fn get_type_name_if_impl(cdata: Cmd, pub fn get_type_name_if_impl(cdata: Cmd,
node_id: ast::NodeId) -> Option<ast::ident> { node_id: ast::NodeId) -> Option<ast::Ident> {
let item = lookup_item(node_id, cdata.data); let item = lookup_item(node_id, cdata.data);
if item_family(item) != Impl { if item_family(item) != Impl {
return None; return None;
@ -1352,7 +1352,7 @@ pub fn get_crate_attributes(data: @~[u8]) -> ~[ast::Attribute] {
#[deriving(Clone)] #[deriving(Clone)]
pub struct CrateDep { pub struct CrateDep {
cnum: ast::CrateNum, cnum: ast::CrateNum,
name: ast::ident, name: ast::Ident,
vers: @str, vers: @str,
hash: @str hash: @str
} }

View file

@ -102,13 +102,13 @@ pub fn reachable(ecx: &EncodeContext, id: NodeId) -> bool {
fn encode_name(ecx: &EncodeContext, fn encode_name(ecx: &EncodeContext,
ebml_w: &mut writer::Encoder, ebml_w: &mut writer::Encoder,
name: ident) { name: Ident) {
ebml_w.wr_tagged_str(tag_paths_data_name, ecx.tcx.sess.str_of(name)); ebml_w.wr_tagged_str(tag_paths_data_name, ecx.tcx.sess.str_of(name));
} }
fn encode_impl_type_basename(ecx: &EncodeContext, fn encode_impl_type_basename(ecx: &EncodeContext,
ebml_w: &mut writer::Encoder, ebml_w: &mut writer::Encoder,
name: ident) { name: Ident) {
ebml_w.wr_tagged_str(tag_item_impl_type_basename, ebml_w.wr_tagged_str(tag_item_impl_type_basename,
ecx.tcx.sess.str_of(name)); ecx.tcx.sess.str_of(name));
} }
@ -135,9 +135,9 @@ struct entry<T> {
} }
fn add_to_index(ebml_w: &mut writer::Encoder, fn add_to_index(ebml_w: &mut writer::Encoder,
path: &[ident], path: &[Ident],
index: &mut ~[entry<~str>], index: &mut ~[entry<~str>],
name: ident) { name: Ident) {
let mut full_path = ~[]; let mut full_path = ~[];
full_path.push_all(path); full_path.push_all(path);
full_path.push(name); full_path.push(name);
@ -379,7 +379,7 @@ fn encode_reexported_static_method(ecx: &EncodeContext,
ebml_w: &mut writer::Encoder, ebml_w: &mut writer::Encoder,
exp: &middle::resolve::Export2, exp: &middle::resolve::Export2,
method_def_id: def_id, method_def_id: def_id,
method_ident: ident) { method_ident: Ident) {
debug!("(encode reexported static method) %s::%s", debug!("(encode reexported static method) %s::%s",
exp.name, ecx.tcx.sess.str_of(method_ident)); exp.name, ecx.tcx.sess.str_of(method_ident));
ebml_w.start_tag(tag_items_data_item_reexport); ebml_w.start_tag(tag_items_data_item_reexport);
@ -541,7 +541,7 @@ fn encode_info_for_mod(ecx: &EncodeContext,
md: &_mod, md: &_mod,
id: NodeId, id: NodeId,
path: &[ast_map::path_elt], path: &[ast_map::path_elt],
name: ident, name: Ident,
vis: visibility) { vis: visibility) {
ebml_w.start_tag(tag_items_data_item); ebml_w.start_tag(tag_items_data_item);
encode_def_id(ebml_w, local_def(id)); encode_def_id(ebml_w, local_def(id));
@ -700,7 +700,7 @@ fn encode_info_for_struct(ecx: &EncodeContext,
fn encode_info_for_struct_ctor(ecx: &EncodeContext, fn encode_info_for_struct_ctor(ecx: &EncodeContext,
ebml_w: &mut writer::Encoder, ebml_w: &mut writer::Encoder,
path: &[ast_map::path_elt], path: &[ast_map::path_elt],
name: ast::ident, name: ast::Ident,
ctor_id: NodeId, ctor_id: NodeId,
index: @mut ~[entry<i64>]) { index: @mut ~[entry<i64>]) {
index.push(entry { val: ctor_id as i64, pos: ebml_w.writer.tell() }); index.push(entry { val: ctor_id as i64, pos: ebml_w.writer.tell() });

View file

@ -90,13 +90,13 @@ fn scan<R>(st: &mut PState, is_last: &fn(char) -> bool,
return op(st.data.slice(start_pos, end_pos)); return op(st.data.slice(start_pos, end_pos));
} }
pub fn parse_ident(st: &mut PState, last: char) -> ast::ident { pub fn parse_ident(st: &mut PState, last: char) -> ast::Ident {
fn is_last(b: char, c: char) -> bool { return c == b; } fn is_last(b: char, c: char) -> bool { return c == b; }
return parse_ident_(st, |a| is_last(last, a) ); return parse_ident_(st, |a| is_last(last, a) );
} }
fn parse_ident_(st: &mut PState, is_last: @fn(char) -> bool) -> fn parse_ident_(st: &mut PState, is_last: @fn(char) -> bool) ->
ast::ident { ast::Ident {
let rslt = scan(st, is_last, str::from_bytes); let rslt = scan(st, is_last, str::from_bytes);
return st.tcx.sess.ident_of(rslt); return st.tcx.sess.ident_of(rslt);
} }
@ -130,7 +130,7 @@ pub fn parse_trait_ref_data(data: &[u8], crate_num: int, pos: uint, tcx: ty::ctx
} }
fn parse_path(st: &mut PState) -> @ast::Path { fn parse_path(st: &mut PState) -> @ast::Path {
let mut idents: ~[ast::ident] = ~[]; let mut idents: ~[ast::Ident] = ~[];
fn is_last(c: char) -> bool { return c == '(' || c == ':'; } fn is_last(c: char) -> bool { return c == '(' || c == ':'; }
idents.push(parse_ident_(st, is_last)); idents.push(parse_ident_(st, is_last));
loop { loop {

View file

@ -1256,7 +1256,7 @@ trait fake_ext_ctxt {
fn cfg(&self) -> ast::CrateConfig; fn cfg(&self) -> ast::CrateConfig;
fn parse_sess(&self) -> @mut parse::ParseSess; fn parse_sess(&self) -> @mut parse::ParseSess;
fn call_site(&self) -> Span; fn call_site(&self) -> Span;
fn ident_of(&self, st: &str) -> ast::ident; fn ident_of(&self, st: &str) -> ast::Ident;
} }
#[cfg(test)] #[cfg(test)]
@ -1273,7 +1273,7 @@ impl fake_ext_ctxt for fake_session {
expn_info: None expn_info: None
} }
} }
fn ident_of(&self, st: &str) -> ast::ident { fn ident_of(&self, st: &str) -> ast::Ident {
token::str_to_ident(st) token::str_to_ident(st)
} }
} }

View file

@ -488,7 +488,7 @@ impl CFGBuilder {
fn find_scope(&self, fn find_scope(&self,
expr: @ast::expr, expr: @ast::expr,
label: Option<ast::ident>) -> LoopScope { label: Option<ast::Ident>) -> LoopScope {
match label { match label {
None => { None => {
return *self.loop_scopes.last(); return *self.loop_scopes.last();

View file

@ -867,7 +867,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
fn find_scope<'a>(&self, fn find_scope<'a>(&self,
expr: @ast::expr, expr: @ast::expr,
label: Option<ast::ident>, label: Option<ast::Ident>,
loop_scopes: &'a mut ~[LoopScope]) -> &'a mut LoopScope { loop_scopes: &'a mut ~[LoopScope]) -> &'a mut LoopScope {
let index = match label { let index = match label {
None => { None => {

View file

@ -1033,7 +1033,7 @@ fn lint_path_statement() -> @mut OuterLint {
} }
fn check_item_non_camel_case_types(cx: &Context, it: &ast::item) { fn check_item_non_camel_case_types(cx: &Context, it: &ast::item) {
fn is_camel_case(cx: ty::ctxt, ident: ast::ident) -> bool { fn is_camel_case(cx: ty::ctxt, ident: ast::Ident) -> bool {
let ident = cx.sess.str_of(ident); let ident = cx.sess.str_of(ident);
assert!(!ident.is_empty()); assert!(!ident.is_empty());
let ident = ident.trim_chars(&'_'); let ident = ident.trim_chars(&'_');
@ -1044,7 +1044,7 @@ fn check_item_non_camel_case_types(cx: &Context, it: &ast::item) {
!ident.contains_char('_') !ident.contains_char('_')
} }
fn check_case(cx: &Context, sort: &str, ident: ast::ident, span: Span) { fn check_case(cx: &Context, sort: &str, ident: ast::Ident, span: Span) {
if !is_camel_case(cx.tcx, ident) { if !is_camel_case(cx.tcx, ident) {
cx.span_lint( cx.span_lint(
non_camel_case_types, span, non_camel_case_types, span,

View file

@ -227,13 +227,13 @@ enum LocalKind {
struct LocalInfo { struct LocalInfo {
id: NodeId, id: NodeId,
ident: ident, ident: Ident,
is_mutbl: bool, is_mutbl: bool,
kind: LocalKind, kind: LocalKind,
} }
enum VarKind { enum VarKind {
Arg(NodeId, ident), Arg(NodeId, Ident),
Local(LocalInfo), Local(LocalInfo),
ImplicitRet ImplicitRet
} }
@ -756,7 +756,7 @@ impl Liveness {
} }
pub fn find_loop_scope(&self, pub fn find_loop_scope(&self,
opt_label: Option<ident>, opt_label: Option<Ident>,
id: NodeId, id: NodeId,
sp: Span) sp: Span)
-> NodeId { -> NodeId {

View file

@ -99,7 +99,7 @@ pub enum InteriorKind {
#[deriving(Eq, IterBytes)] #[deriving(Eq, IterBytes)]
pub enum FieldName { pub enum FieldName {
NamedField(ast::ident), NamedField(ast::Ident),
PositionalField(uint) PositionalField(uint)
} }
@ -613,7 +613,7 @@ impl mem_categorization_ctxt {
pub fn cat_field<N:ast_node>(&self, pub fn cat_field<N:ast_node>(&self,
node: N, node: N,
base_cmt: cmt, base_cmt: cmt,
f_name: ast::ident, f_name: ast::Ident,
f_ty: ty::t) f_ty: ty::t)
-> cmt { -> cmt {
@cmt_ { @cmt_ {
@ -1058,7 +1058,7 @@ impl mem_categorization_ctxt {
/// an enum to determine which variant is in use. /// an enum to determine which variant is in use.
pub fn field_mutbl(tcx: ty::ctxt, pub fn field_mutbl(tcx: ty::ctxt,
base_ty: ty::t, base_ty: ty::t,
f_name: ast::ident, f_name: ast::Ident,
node_id: ast::NodeId) node_id: ast::NodeId)
-> Option<ast::mutability> { -> Option<ast::mutability> {
// Need to refactor so that struct/enum fields can be treated uniformly. // Need to refactor so that struct/enum fields can be treated uniformly.

View file

@ -16,7 +16,7 @@ use syntax::ast::*;
use syntax::ast_util::{path_to_ident, walk_pat}; use syntax::ast_util::{path_to_ident, walk_pat};
use syntax::codemap::Span; use syntax::codemap::Span;
pub type PatIdMap = HashMap<ident, NodeId>; pub type PatIdMap = HashMap<Ident, NodeId>;
// This is used because same-named variables in alternative patterns need to // This is used because same-named variables in alternative patterns need to
// use the NodeId of their namesake in the first pattern. // use the NodeId of their namesake in the first pattern.

View file

@ -20,7 +20,7 @@ use middle::typeck::{method_static, method_object};
use std::util::ignore; use std::util::ignore;
use syntax::ast::{decl_item, def, def_fn, def_id, def_static_method}; use syntax::ast::{decl_item, def, def_fn, def_id, def_static_method};
use syntax::ast::{def_variant, expr_field, expr_method_call, expr_path}; use syntax::ast::{def_variant, expr_field, expr_method_call, expr_path};
use syntax::ast::{expr_struct, expr_unary, ident, inherited, item_enum}; use syntax::ast::{expr_struct, expr_unary, Ident, inherited, item_enum};
use syntax::ast::{item_foreign_mod, item_fn, item_impl, item_struct}; use syntax::ast::{item_foreign_mod, item_fn, item_impl, item_struct};
use syntax::ast::{item_trait, LOCAL_CRATE, NodeId, pat_struct, Path}; use syntax::ast::{item_trait, LOCAL_CRATE, NodeId, pat_struct, Path};
use syntax::ast::{private, provided, public, required, stmt_decl, visibility}; use syntax::ast::{private, provided, public, required, stmt_decl, visibility};
@ -203,7 +203,7 @@ impl PrivacyVisitor {
} }
// Checks that a private field is in scope. // Checks that a private field is in scope.
fn check_field(&mut self, span: Span, id: ast::def_id, ident: ast::ident) { fn check_field(&mut self, span: Span, id: ast::def_id, ident: ast::Ident) {
let fields = ty::lookup_struct_fields(self.tcx, id); let fields = ty::lookup_struct_fields(self.tcx, id);
for field in fields.iter() { for field in fields.iter() {
if field.ident != ident { loop; } if field.ident != ident { loop; }
@ -216,7 +216,7 @@ impl PrivacyVisitor {
} }
// Given the ID of a method, checks to ensure it's in scope. // Given the ID of a method, checks to ensure it's in scope.
fn check_method_common(&mut self, span: Span, method_id: def_id, name: &ident) { fn check_method_common(&mut self, span: Span, method_id: def_id, name: &Ident) {
// If the method is a default method, we need to use the def_id of // If the method is a default method, we need to use the def_id of
// the default implementation. // the default implementation.
// Having to do this this is really unfortunate. // Having to do this this is really unfortunate.
@ -280,7 +280,7 @@ impl PrivacyVisitor {
} }
// Checks that a private method is in scope. // Checks that a private method is in scope.
fn check_method(&mut self, span: Span, origin: &method_origin, ident: ast::ident) { fn check_method(&mut self, span: Span, origin: &method_origin, ident: ast::Ident) {
match *origin { match *origin {
method_static(method_id) => { method_static(method_id) => {
self.check_method_common(span, method_id, &ident) self.check_method_common(span, method_id, &ident)

View file

@ -51,7 +51,7 @@ pub struct binding_info {
} }
// Map from the name in a pattern to its binding mode. // Map from the name in a pattern to its binding mode.
pub type BindingMap = HashMap<ident,binding_info>; pub type BindingMap = HashMap<Ident,binding_info>;
// Trait method resolution // Trait method resolution
pub type TraitMap = HashMap<NodeId,@mut ~[def_id]>; pub type TraitMap = HashMap<NodeId,@mut ~[def_id]>;
@ -162,7 +162,7 @@ impl Visitor<()> for ResolveVisitor {
/// Contains data for specific types of import directives. /// Contains data for specific types of import directives.
pub enum ImportDirectiveSubclass { pub enum ImportDirectiveSubclass {
SingleImport(ident /* target */, ident /* source */), SingleImport(Ident /* target */, Ident /* source */),
GlobImport GlobImport
} }
@ -311,7 +311,7 @@ pub enum DuplicateCheckingMode {
/// One local scope. /// One local scope.
pub struct Rib { pub struct Rib {
bindings: @mut HashMap<ident, DefLike>, bindings: @mut HashMap<Ident, DefLike>,
self_binding: @mut Option<DefLike>, self_binding: @mut Option<DefLike>,
kind: RibKind, kind: RibKind,
} }
@ -329,7 +329,7 @@ impl Rib {
/// One import directive. /// One import directive.
pub struct ImportDirective { pub struct ImportDirective {
privacy: Privacy, privacy: Privacy,
module_path: ~[ident], module_path: ~[Ident],
subclass: @ImportDirectiveSubclass, subclass: @ImportDirectiveSubclass,
span: Span, span: Span,
id: NodeId, id: NodeId,
@ -337,7 +337,7 @@ pub struct ImportDirective {
impl ImportDirective { impl ImportDirective {
pub fn new(privacy: Privacy, pub fn new(privacy: Privacy,
module_path: ~[ident], module_path: ~[Ident],
subclass: @ImportDirectiveSubclass, subclass: @ImportDirectiveSubclass,
span: Span, span: Span,
id: NodeId) id: NodeId)
@ -425,7 +425,7 @@ impl ImportResolution {
/// The link from a module up to its nearest parent node. /// The link from a module up to its nearest parent node.
pub enum ParentLink { pub enum ParentLink {
NoParentLink, NoParentLink,
ModuleParentLink(@mut Module, ident), ModuleParentLink(@mut Module, Ident),
BlockParentLink(@mut Module, NodeId) BlockParentLink(@mut Module, NodeId)
} }
@ -445,12 +445,12 @@ pub struct Module {
def_id: Option<def_id>, def_id: Option<def_id>,
kind: ModuleKind, kind: ModuleKind,
children: @mut HashMap<ident, @mut NameBindings>, children: @mut HashMap<Ident, @mut NameBindings>,
imports: @mut ~[@ImportDirective], imports: @mut ~[@ImportDirective],
// The external module children of this node that were declared with // The external module children of this node that were declared with
// `extern mod`. // `extern mod`.
external_module_children: @mut HashMap<ident, @mut Module>, external_module_children: @mut HashMap<Ident, @mut Module>,
// The anonymous children of this node. Anonymous children are pseudo- // The anonymous children of this node. Anonymous children are pseudo-
// modules that are implicitly created around items contained within // modules that are implicitly created around items contained within
@ -469,7 +469,7 @@ pub struct Module {
anonymous_children: @mut HashMap<NodeId,@mut Module>, anonymous_children: @mut HashMap<NodeId,@mut Module>,
// The status of resolving each import in this module. // The status of resolving each import in this module.
import_resolutions: @mut HashMap<ident, @mut ImportResolution>, import_resolutions: @mut HashMap<Ident, @mut ImportResolution>,
// The number of unresolved globs that this module exports. // The number of unresolved globs that this module exports.
glob_count: uint, glob_count: uint,
@ -759,7 +759,7 @@ pub fn NameBindings() -> NameBindings {
/// Interns the names of the primitive types. /// Interns the names of the primitive types.
pub struct PrimitiveTypeTable { pub struct PrimitiveTypeTable {
primitive_types: HashMap<ident,prim_ty>, primitive_types: HashMap<Ident,prim_ty>,
} }
impl PrimitiveTypeTable { impl PrimitiveTypeTable {
@ -873,7 +873,7 @@ pub struct Resolver {
graph_root: @mut NameBindings, graph_root: @mut NameBindings,
method_map: @mut HashMap<ident, HashSet<def_id>>, method_map: @mut HashMap<Ident, HashSet<def_id>>,
structs: HashSet<def_id>, structs: HashSet<def_id>,
// The number of imports that are currently unresolved. // The number of imports that are currently unresolved.
@ -900,9 +900,9 @@ pub struct Resolver {
current_trait_refs: Option<~[def_id]>, current_trait_refs: Option<~[def_id]>,
// The ident for the keyword "self". // The ident for the keyword "self".
self_ident: ident, self_ident: Ident,
// The ident for the non-keyword "Self". // The ident for the non-keyword "Self".
type_self_ident: ident, type_self_ident: Ident,
// The idents for the primitive types. // The idents for the primitive types.
primitive_type_table: @PrimitiveTypeTable, primitive_type_table: @PrimitiveTypeTable,
@ -1017,7 +1017,7 @@ impl Resolver {
* a block, fails. * a block, fails.
*/ */
pub fn add_child(@mut self, pub fn add_child(@mut self,
name: ident, name: Ident,
reduced_graph_parent: ReducedGraphParent, reduced_graph_parent: ReducedGraphParent,
duplicate_checking_mode: DuplicateCheckingMode, duplicate_checking_mode: DuplicateCheckingMode,
// For printing errors // For printing errors
@ -1153,7 +1153,7 @@ impl Resolver {
return false; return false;
} }
pub fn get_parent_link(@mut self, parent: ReducedGraphParent, name: ident) pub fn get_parent_link(@mut self, parent: ReducedGraphParent, name: Ident)
-> ParentLink { -> ParentLink {
match parent { match parent {
ModuleReducedGraphParent(module_) => { ModuleReducedGraphParent(module_) => {
@ -1659,7 +1659,7 @@ impl Resolver {
visibility: ast::visibility, visibility: ast::visibility,
child_name_bindings: @mut NameBindings, child_name_bindings: @mut NameBindings,
final_ident: &str, final_ident: &str,
ident: ident, ident: Ident,
new_parent: ReducedGraphParent) { new_parent: ReducedGraphParent) {
let privacy = visibility_to_privacy(visibility); let privacy = visibility_to_privacy(visibility);
match def { match def {
@ -1783,7 +1783,7 @@ impl Resolver {
fn build_reduced_graph_for_external_crate_def(@mut self, fn build_reduced_graph_for_external_crate_def(@mut self,
root: @mut Module, root: @mut Module,
def_like: DefLike, def_like: DefLike,
ident: ident) { ident: Ident) {
match def_like { match def_like {
DlDef(def) => { DlDef(def) => {
// Add the new child item, if necessary. // Add the new child item, if necessary.
@ -1962,7 +1962,7 @@ impl Resolver {
pub fn build_import_directive(@mut self, pub fn build_import_directive(@mut self,
privacy: Privacy, privacy: Privacy,
module_: @mut Module, module_: @mut Module,
module_path: ~[ident], module_path: ~[Ident],
subclass: @ImportDirectiveSubclass, subclass: @ImportDirectiveSubclass,
span: Span, span: Span,
id: NodeId) { id: NodeId) {
@ -2107,7 +2107,7 @@ impl Resolver {
} }
} }
pub fn idents_to_str(@mut self, idents: &[ident]) -> ~str { pub fn idents_to_str(@mut self, idents: &[Ident]) -> ~str {
let mut first = true; let mut first = true;
let mut result = ~""; let mut result = ~"";
for ident in idents.iter() { for ident in idents.iter() {
@ -2122,7 +2122,7 @@ impl Resolver {
} }
fn path_idents_to_str(@mut self, path: &Path) -> ~str { fn path_idents_to_str(@mut self, path: &Path) -> ~str {
let identifiers: ~[ast::ident] = path.segments let identifiers: ~[ast::Ident] = path.segments
.iter() .iter()
.map(|seg| seg.identifier) .map(|seg| seg.identifier)
.collect(); .collect();
@ -2139,7 +2139,7 @@ impl Resolver {
} }
pub fn import_path_to_str(@mut self, pub fn import_path_to_str(@mut self,
idents: &[ident], idents: &[Ident],
subclass: ImportDirectiveSubclass) subclass: ImportDirectiveSubclass)
-> @str { -> @str {
if idents.is_empty() { if idents.is_empty() {
@ -2262,8 +2262,8 @@ impl Resolver {
pub fn resolve_single_import(@mut self, pub fn resolve_single_import(@mut self,
module_: @mut Module, module_: @mut Module,
containing_module: @mut Module, containing_module: @mut Module,
target: ident, target: Ident,
source: ident, source: Ident,
directive: &ImportDirective) directive: &ImportDirective)
-> ResolveResult<()> { -> ResolveResult<()> {
debug!("(resolving single import) resolving `%s` = `%s::%s` from \ debug!("(resolving single import) resolving `%s` = `%s::%s` from \
@ -2620,7 +2620,7 @@ impl Resolver {
/// Resolves the given module path from the given root `module_`. /// Resolves the given module path from the given root `module_`.
pub fn resolve_module_path_from_root(@mut self, pub fn resolve_module_path_from_root(@mut self,
module_: @mut Module, module_: @mut Module,
module_path: &[ident], module_path: &[Ident],
index: uint, index: uint,
span: Span, span: Span,
mut name_search_type: NameSearchType) mut name_search_type: NameSearchType)
@ -2729,7 +2729,7 @@ impl Resolver {
/// rooted at the given module. /// rooted at the given module.
pub fn resolve_module_path(@mut self, pub fn resolve_module_path(@mut self,
module_: @mut Module, module_: @mut Module,
module_path: &[ident], module_path: &[Ident],
use_lexical_scope: UseLexicalScopeFlag, use_lexical_scope: UseLexicalScopeFlag,
span: Span, span: Span,
name_search_type: NameSearchType) name_search_type: NameSearchType)
@ -2822,7 +2822,7 @@ impl Resolver {
/// import resolution. /// import resolution.
pub fn resolve_item_in_lexical_scope(@mut self, pub fn resolve_item_in_lexical_scope(@mut self,
module_: @mut Module, module_: @mut Module,
name: ident, name: Ident,
namespace: Namespace, namespace: Namespace,
search_through_modules: search_through_modules:
SearchThroughModulesFlag) SearchThroughModulesFlag)
@ -2951,7 +2951,7 @@ impl Resolver {
/// Resolves a module name in the current lexical scope. /// Resolves a module name in the current lexical scope.
pub fn resolve_module_in_lexical_scope(@mut self, pub fn resolve_module_in_lexical_scope(@mut self,
module_: @mut Module, module_: @mut Module,
name: ident) name: Ident)
-> ResolveResult<@mut Module> { -> ResolveResult<@mut Module> {
// If this module is an anonymous module, resolve the item in the // If this module is an anonymous module, resolve the item in the
// lexical scope. Otherwise, resolve the item from the crate root. // lexical scope. Otherwise, resolve the item from the crate root.
@ -3038,7 +3038,7 @@ impl Resolver {
/// (b) some chain of `super::`. /// (b) some chain of `super::`.
pub fn resolve_module_prefix(@mut self, pub fn resolve_module_prefix(@mut self,
module_: @mut Module, module_: @mut Module,
module_path: &[ident]) module_path: &[Ident])
-> ResolveResult<ModulePrefixResult> { -> ResolveResult<ModulePrefixResult> {
// Start at the current module if we see `self` or `super`, or at the // Start at the current module if we see `self` or `super`, or at the
// top of the crate otherwise. // top of the crate otherwise.
@ -3081,7 +3081,7 @@ impl Resolver {
/// the name. /// the name.
pub fn resolve_name_in_module(@mut self, pub fn resolve_name_in_module(@mut self,
module_: @mut Module, module_: @mut Module,
name: ident, name: Ident,
namespace: Namespace, namespace: Namespace,
name_search_type: NameSearchType) name_search_type: NameSearchType)
-> ResolveResult<Target> { -> ResolveResult<Target> {
@ -3273,7 +3273,7 @@ impl Resolver {
pub fn add_exports_of_namebindings(@mut self, pub fn add_exports_of_namebindings(@mut self,
exports2: &mut ~[Export2], exports2: &mut ~[Export2],
ident: ident, ident: Ident,
namebindings: @mut NameBindings, namebindings: @mut NameBindings,
ns: Namespace, ns: Namespace,
reexport: bool) { reexport: bool) {
@ -3344,7 +3344,7 @@ impl Resolver {
// generate a fake "implementation scope" containing all the // generate a fake "implementation scope" containing all the
// implementations thus found, for compatibility with old resolve pass. // implementations thus found, for compatibility with old resolve pass.
pub fn with_scope(@mut self, name: Option<ident>, f: &fn()) { pub fn with_scope(@mut self, name: Option<Ident>, f: &fn()) {
let orig_module = self.current_module; let orig_module = self.current_module;
// Move down in the graph. // Move down in the graph.
@ -3498,7 +3498,7 @@ impl Resolver {
pub fn search_ribs(@mut self, pub fn search_ribs(@mut self,
ribs: &mut ~[@Rib], ribs: &mut ~[@Rib],
name: ident, name: Ident,
span: Span, span: Span,
allow_capturing_self: AllowCapturingSelfFlag) allow_capturing_self: AllowCapturingSelfFlag)
-> Option<DefLike> { -> Option<DefLike> {
@ -3892,7 +3892,7 @@ impl Resolver {
generics: &Generics, generics: &Generics,
fields: &[@struct_field], fields: &[@struct_field],
visitor: &mut ResolveVisitor) { visitor: &mut ResolveVisitor) {
let mut ident_map: HashMap<ast::ident,@struct_field> = HashMap::new(); let mut ident_map: HashMap<ast::Ident,@struct_field> = HashMap::new();
for &field in fields.iter() { for &field in fields.iter() {
match field.node.kind { match field.node.kind {
named_field(ident, _) => { named_field(ident, _) => {
@ -4035,7 +4035,7 @@ impl Resolver {
pub fn resolve_module(@mut self, pub fn resolve_module(@mut self,
module_: &_mod, module_: &_mod,
_span: Span, _span: Span,
_name: ident, _name: Ident,
id: NodeId, id: NodeId,
visitor: &mut ResolveVisitor) { visitor: &mut ResolveVisitor) {
// Write the implementations in scope into the module metadata. // Write the implementations in scope into the module metadata.
@ -4272,7 +4272,7 @@ impl Resolver {
mutability: Mutability, mutability: Mutability,
// Maps idents to the node ID for the (outermost) // Maps idents to the node ID for the (outermost)
// pattern that binds them // pattern that binds them
bindings_list: Option<@mut HashMap<ident,NodeId>>, bindings_list: Option<@mut HashMap<Ident,NodeId>>,
visitor: &mut ResolveVisitor) { visitor: &mut ResolveVisitor) {
let pat_id = pattern.id; let pat_id = pattern.id;
do walk_pat(pattern) |pattern| { do walk_pat(pattern) |pattern| {
@ -4517,7 +4517,7 @@ impl Resolver {
}; };
} }
pub fn resolve_bare_identifier_pattern(@mut self, name: ident) pub fn resolve_bare_identifier_pattern(@mut self, name: Ident)
-> ->
BareIdentifierPatternResolution { BareIdentifierPatternResolution {
match self.resolve_item_in_lexical_scope(self.current_module, match self.resolve_item_in_lexical_scope(self.current_module,
@ -4604,7 +4604,7 @@ impl Resolver {
} }
pub fn resolve_identifier(@mut self, pub fn resolve_identifier(@mut self,
identifier: ident, identifier: Ident,
namespace: Namespace, namespace: Namespace,
check_ribs: bool, check_ribs: bool,
span: Span) span: Span)
@ -4629,7 +4629,7 @@ impl Resolver {
// FIXME #4952: Merge me with resolve_name_in_module? // FIXME #4952: Merge me with resolve_name_in_module?
pub fn resolve_definition_of_name_in_module(@mut self, pub fn resolve_definition_of_name_in_module(@mut self,
containing_module: @mut Module, containing_module: @mut Module,
name: ident, name: Ident,
namespace: Namespace, namespace: Namespace,
xray: XrayFlag) xray: XrayFlag)
-> NameDefinition { -> NameDefinition {
@ -4702,7 +4702,7 @@ impl Resolver {
return NoNameDefinition; return NoNameDefinition;
} }
pub fn intern_module_part_of_path(@mut self, path: &Path) -> ~[ident] { pub fn intern_module_part_of_path(@mut self, path: &Path) -> ~[Ident] {
let mut module_path_idents = ~[]; let mut module_path_idents = ~[];
for (index, segment) in path.segments.iter().enumerate() { for (index, segment) in path.segments.iter().enumerate() {
if index == path.segments.len() - 1 { if index == path.segments.len() - 1 {
@ -4829,7 +4829,7 @@ impl Resolver {
} }
pub fn resolve_identifier_in_local_ribs(@mut self, pub fn resolve_identifier_in_local_ribs(@mut self,
ident: ident, ident: Ident,
namespace: Namespace, namespace: Namespace,
span: Span) span: Span)
-> Option<def> { -> Option<def> {
@ -4895,7 +4895,7 @@ impl Resolver {
} }
pub fn resolve_item_by_identifier_in_lexical_scope(@mut self, pub fn resolve_item_by_identifier_in_lexical_scope(@mut self,
ident: ident, ident: Ident,
namespace: Namespace) namespace: Namespace)
-> Option<def> { -> Option<def> {
// Check the items. // Check the items.
@ -5273,7 +5273,7 @@ impl Resolver {
} }
} }
pub fn search_for_traits_containing_method(@mut self, name: ident) pub fn search_for_traits_containing_method(@mut self, name: Ident)
-> ~[def_id] { -> ~[def_id] {
debug!("(searching for traits containing method) looking for '%s'", debug!("(searching for traits containing method) looking for '%s'",
self.session.str_of(name)); self.session.str_of(name));
@ -5376,7 +5376,7 @@ impl Resolver {
pub fn add_trait_info(&self, pub fn add_trait_info(&self,
found_traits: &mut ~[def_id], found_traits: &mut ~[def_id],
trait_def_id: def_id, trait_def_id: def_id,
name: ident) { name: Ident) {
debug!("(adding trait info) found trait %d:%d for method '%s'", debug!("(adding trait info) found trait %d:%d for method '%s'",
trait_def_id.crate, trait_def_id.crate,
trait_def_id.node, trait_def_id.node,
@ -5493,7 +5493,7 @@ impl Resolver {
if idents.len() == 0 { if idents.len() == 0 {
return ~"???"; return ~"???";
} }
return self.idents_to_str(idents.move_rev_iter().collect::<~[ast::ident]>()); return self.idents_to_str(idents.move_rev_iter().collect::<~[ast::Ident]>());
} }
pub fn dump_module(@mut self, module_: @mut Module) { pub fn dump_module(@mut self, module_: @mut Module) {

View file

@ -222,7 +222,7 @@ use util::ppaux::{Repr, vec_map_to_str};
use std::hashmap::HashMap; use std::hashmap::HashMap;
use std::vec; use std::vec;
use syntax::ast; use syntax::ast;
use syntax::ast::ident; use syntax::ast::Ident;
use syntax::ast_util::path_to_ident; use syntax::ast_util::path_to_ident;
use syntax::ast_util; use syntax::ast_util;
use syntax::codemap::{Span, dummy_sp}; use syntax::codemap::{Span, dummy_sp};
@ -390,7 +390,7 @@ struct BindingInfo {
ty: ty::t, ty: ty::t,
} }
type BindingsMap = HashMap<ident, BindingInfo>; type BindingsMap = HashMap<Ident, BindingInfo>;
#[deriving(Clone)] #[deriving(Clone)]
struct ArmData<'self> { struct ArmData<'self> {
@ -409,7 +409,7 @@ struct ArmData<'self> {
struct Match<'self> { struct Match<'self> {
pats: ~[@ast::pat], pats: ~[@ast::pat],
data: ArmData<'self>, data: ArmData<'self>,
bound_ptrs: ~[(ident, ValueRef)] bound_ptrs: ~[(Ident, ValueRef)]
} }
impl<'self> Repr for Match<'self> { impl<'self> Repr for Match<'self> {
@ -736,7 +736,7 @@ fn enter_rec_or_struct<'r>(bcx: @mut Block,
dm: DefMap, dm: DefMap,
m: &[Match<'r>], m: &[Match<'r>],
col: uint, col: uint,
fields: &[ast::ident], fields: &[ast::Ident],
val: ValueRef) val: ValueRef)
-> ~[Match<'r>] { -> ~[Match<'r>] {
debug!("enter_rec_or_struct(bcx=%s, m=%s, col=%u, val=%s)", debug!("enter_rec_or_struct(bcx=%s, m=%s, col=%u, val=%s)",
@ -1076,8 +1076,8 @@ fn extract_vec_elems(bcx: @mut Block,
fn collect_record_or_struct_fields(bcx: @mut Block, fn collect_record_or_struct_fields(bcx: @mut Block,
m: &[Match], m: &[Match],
col: uint) col: uint)
-> Option<~[ast::ident]> { -> Option<~[ast::Ident]> {
let mut fields: ~[ast::ident] = ~[]; let mut fields: ~[ast::Ident] = ~[];
let mut found = false; let mut found = false;
for br in m.iter() { for br in m.iter() {
match br.pats[col].node { match br.pats[col].node {
@ -1099,7 +1099,7 @@ fn collect_record_or_struct_fields(bcx: @mut Block,
return None; return None;
} }
fn extend(idents: &mut ~[ast::ident], field_pats: &[ast::field_pat]) { fn extend(idents: &mut ~[ast::Ident], field_pats: &[ast::field_pat]) {
for field_pat in field_pats.iter() { for field_pat in field_pats.iter() {
let field_ident = field_pat.ident; let field_ident = field_pat.ident;
if !idents.iter().any(|x| *x == field_ident) { if !idents.iter().any(|x| *x == field_ident) {

View file

@ -76,7 +76,7 @@ use std::vec;
use std::local_data; use std::local_data;
use extra::time; use extra::time;
use extra::sort; use extra::sort;
use syntax::ast::ident; use syntax::ast::Ident;
use syntax::ast_map::{path, path_elt_to_str, path_name}; use syntax::ast_map::{path, path_elt_to_str, path_name};
use syntax::ast_util::{local_def}; use syntax::ast_util::{local_def};
use syntax::attr; use syntax::attr;
@ -1203,7 +1203,7 @@ pub fn scope_block(bcx: @mut Block,
pub fn loop_scope_block(bcx: @mut Block, pub fn loop_scope_block(bcx: @mut Block,
loop_break: @mut Block, loop_break: @mut Block,
loop_label: Option<ident>, loop_label: Option<Ident>,
n: &str, n: &str,
opt_node_info: Option<NodeInfo>) -> @mut Block { opt_node_info: Option<NodeInfo>) -> @mut Block {
return new_block(bcx.fcx, Some(bcx), Some(@mut ScopeInfo { return new_block(bcx.fcx, Some(bcx), Some(@mut ScopeInfo {

View file

@ -38,7 +38,7 @@ use std::cast;
use std::hashmap::{HashMap}; use std::hashmap::{HashMap};
use std::libc::{c_uint, c_longlong, c_ulonglong, c_char}; use std::libc::{c_uint, c_longlong, c_ulonglong, c_char};
use std::vec; use std::vec;
use syntax::ast::ident; use syntax::ast::Ident;
use syntax::ast_map::{path, path_elt}; use syntax::ast_map::{path, path_elt};
use syntax::codemap::Span; use syntax::codemap::Span;
use syntax::parse::token; use syntax::parse::token;
@ -46,7 +46,7 @@ use syntax::{ast, ast_map};
pub use middle::trans::context::CrateContext; pub use middle::trans::context::CrateContext;
pub fn gensym_name(name: &str) -> ident { pub fn gensym_name(name: &str) -> Ident {
token::str_to_ident(fmt!("%s_%u", name, token::gensym(name))) token::str_to_ident(fmt!("%s_%u", name, token::gensym(name)))
} }
@ -460,7 +460,7 @@ pub fn block_cleanups(bcx: @mut Block) -> ~[cleanup] {
pub struct ScopeInfo { pub struct ScopeInfo {
parent: Option<@mut ScopeInfo>, parent: Option<@mut ScopeInfo>,
loop_break: Option<@mut Block>, loop_break: Option<@mut Block>,
loop_label: Option<ident>, loop_label: Option<Ident>,
// A list of functions that must be run at when leaving this // A list of functions that must be run at when leaving this
// block, cleaning up any variables that were introduced in the // block, cleaning up any variables that were introduced in the
// block. // block.
@ -562,7 +562,7 @@ impl Block {
pub fn tcx(&self) -> ty::ctxt { self.fcx.ccx.tcx } pub fn tcx(&self) -> ty::ctxt { self.fcx.ccx.tcx }
pub fn sess(&self) -> Session { self.fcx.ccx.sess } pub fn sess(&self) -> Session { self.fcx.ccx.sess }
pub fn ident(&self, ident: ident) -> @str { pub fn ident(&self, ident: Ident) -> @str {
token::ident_to_str(&ident) token::ident_to_str(&ident)
} }

View file

@ -87,7 +87,7 @@ pub struct CrateContext {
// Cache of external const values // Cache of external const values
extern_const_values: HashMap<ast::def_id, ValueRef>, extern_const_values: HashMap<ast::def_id, ValueRef>,
impl_method_cache: HashMap<(ast::def_id, ast::ident), ast::def_id>, impl_method_cache: HashMap<(ast::def_id, ast::Ident), ast::def_id>,
module_data: HashMap<~str, ValueRef>, module_data: HashMap<~str, ValueRef>,
lltypes: HashMap<ty::t, Type>, lltypes: HashMap<ty::t, Type>,

View file

@ -27,7 +27,7 @@ use util::ppaux;
use middle::trans::type_::Type; use middle::trans::type_::Type;
use syntax::ast; use syntax::ast;
use syntax::ast::ident; use syntax::ast::Ident;
use syntax::ast_map::path_mod; use syntax::ast_map::path_mod;
use syntax::ast_util; use syntax::ast_util;
use syntax::codemap::Span; use syntax::codemap::Span;
@ -194,7 +194,7 @@ pub fn trans_while(bcx: @mut Block, cond: @ast::expr, body: &ast::Block) -> @mut
pub fn trans_loop(bcx:@mut Block, pub fn trans_loop(bcx:@mut Block,
body: &ast::Block, body: &ast::Block,
opt_label: Option<ident>) opt_label: Option<Ident>)
-> @mut Block { -> @mut Block {
let _icx = push_ctxt("trans_loop"); let _icx = push_ctxt("trans_loop");
let next_bcx = sub_block(bcx, "next"); let next_bcx = sub_block(bcx, "next");
@ -273,7 +273,7 @@ pub fn trans_log(log_ex: &ast::expr,
} }
pub fn trans_break_cont(bcx: @mut Block, pub fn trans_break_cont(bcx: @mut Block,
opt_label: Option<ident>, opt_label: Option<Ident>,
to_end: bool) to_end: bool)
-> @mut Block { -> @mut Block {
let _icx = push_ctxt("trans_break_cont"); let _icx = push_ctxt("trans_break_cont");
@ -326,11 +326,11 @@ pub fn trans_break_cont(bcx: @mut Block,
return bcx; return bcx;
} }
pub fn trans_break(bcx: @mut Block, label_opt: Option<ident>) -> @mut Block { pub fn trans_break(bcx: @mut Block, label_opt: Option<Ident>) -> @mut Block {
return trans_break_cont(bcx, label_opt, true); return trans_break_cont(bcx, label_opt, true);
} }
pub fn trans_cont(bcx: @mut Block, label_opt: Option<ident>) -> @mut Block { pub fn trans_cont(bcx: @mut Block, label_opt: Option<Ident>) -> @mut Block {
return trans_break_cont(bcx, label_opt, false); return trans_break_cont(bcx, label_opt, false);
} }

View file

@ -155,7 +155,7 @@ pub fn create_local_var_metadata(bcx: @mut Block, local: &ast::Local) {
/// ///
/// Adds the created metadata nodes directly to the crate's IR. /// Adds the created metadata nodes directly to the crate's IR.
pub fn create_match_binding_metadata(bcx: @mut Block, pub fn create_match_binding_metadata(bcx: @mut Block,
variable_ident: ast::ident, variable_ident: ast::Ident,
node_id: ast::NodeId, node_id: ast::NodeId,
variable_type: ty::t, variable_type: ty::t,
span: Span) { span: Span) {
@ -640,7 +640,7 @@ fn compile_unit_metadata(cx: @mut CrateContext) {
} }
fn declare_local(bcx: @mut Block, fn declare_local(bcx: @mut Block,
variable_ident: ast::ident, variable_ident: ast::Ident,
node_id: ast::NodeId, node_id: ast::NodeId,
variable_type: ty::t, variable_type: ty::t,
span: Span) { span: Span) {
@ -1539,7 +1539,7 @@ fn populate_scope_map(cx: &mut CrateContext,
struct ScopeStackEntry { struct ScopeStackEntry {
scope_metadata: DIScope, scope_metadata: DIScope,
ident: Option<ast::ident> ident: Option<ast::Ident>
} }
let mut scope_stack = ~[ScopeStackEntry { scope_metadata: fn_metadata, ident: None }]; let mut scope_stack = ~[ScopeStackEntry { scope_metadata: fn_metadata, ident: None }];

View file

@ -894,7 +894,7 @@ fn trans_lvalue_unadjusted(bcx: @mut Block, expr: @ast::expr) -> DatumBlock {
fn trans_rec_field(bcx: @mut Block, fn trans_rec_field(bcx: @mut Block,
base: @ast::expr, base: @ast::expr,
field: ast::ident) -> DatumBlock { field: ast::Ident) -> DatumBlock {
//! Translates `base.field`. //! Translates `base.field`.
let mut bcx = bcx; let mut bcx = bcx;

View file

@ -47,7 +47,7 @@ see `trans::base::lval_static_fn()` or `trans::base::monomorphic_fn()`.
*/ */
pub fn trans_impl(ccx: @mut CrateContext, pub fn trans_impl(ccx: @mut CrateContext,
path: path, path: path,
name: ast::ident, name: ast::Ident,
methods: &[@ast::method], methods: &[@ast::method],
generics: &ast::Generics, generics: &ast::Generics,
id: ast::NodeId) { id: ast::NodeId) {
@ -294,7 +294,7 @@ pub fn trans_static_method_callee(bcx: @mut Block,
pub fn method_with_name(ccx: &mut CrateContext, pub fn method_with_name(ccx: &mut CrateContext,
impl_id: ast::def_id, impl_id: ast::def_id,
name: ast::ident) -> ast::def_id { name: ast::Ident) -> ast::def_id {
let meth_id_opt = ccx.impl_method_cache.find_copy(&(impl_id, name)); let meth_id_opt = ccx.impl_method_cache.find_copy(&(impl_id, name));
match meth_id_opt { match meth_id_opt {
Some(m) => return m, Some(m) => return m,

View file

@ -56,7 +56,7 @@ pub static INITIAL_DISCRIMINANT_VALUE: Disr = 0;
#[deriving(Eq, IterBytes)] #[deriving(Eq, IterBytes)]
pub struct field { pub struct field {
ident: ast::ident, ident: ast::Ident,
mt: mt mt: mt
} }
@ -68,7 +68,7 @@ pub enum MethodContainer {
#[deriving(Clone)] #[deriving(Clone)]
pub struct Method { pub struct Method {
ident: ast::ident, ident: ast::Ident,
generics: ty::Generics, generics: ty::Generics,
transformed_self_ty: Option<ty::t>, transformed_self_ty: Option<ty::t>,
fty: BareFnTy, fty: BareFnTy,
@ -82,7 +82,7 @@ pub struct Method {
} }
impl Method { impl Method {
pub fn new(ident: ast::ident, pub fn new(ident: ast::Ident,
generics: ty::Generics, generics: ty::Generics,
transformed_self_ty: Option<ty::t>, transformed_self_ty: Option<ty::t>,
fty: BareFnTy, fty: BareFnTy,
@ -122,7 +122,7 @@ impl Method {
pub struct Impl { pub struct Impl {
did: def_id, did: def_id,
ident: ident, ident: Ident,
methods: ~[@Method] methods: ~[@Method]
} }
@ -156,7 +156,7 @@ pub enum SelfMode {
} }
pub struct field_ty { pub struct field_ty {
ident: ident, ident: Ident,
id: def_id, id: def_id,
vis: ast::visibility, vis: ast::visibility,
} }
@ -431,7 +431,7 @@ pub struct ClosureTy {
* - `output` is the return type. */ * - `output` is the return type. */
#[deriving(Clone, Eq, IterBytes)] #[deriving(Clone, Eq, IterBytes)]
pub struct FnSig { pub struct FnSig {
bound_lifetime_names: OptVec<ast::ident>, bound_lifetime_names: OptVec<ast::Ident>,
inputs: ~[t], inputs: ~[t],
output: t output: t
} }
@ -504,7 +504,7 @@ pub enum bound_region {
br_anon(uint), br_anon(uint),
/// Named region parameters for functions (a in &'a T) /// Named region parameters for functions (a in &'a T)
br_named(ast::ident), br_named(ast::Ident),
/// Fresh bound identifiers created during GLB computations. /// Fresh bound identifiers created during GLB computations.
br_fresh(uint), br_fresh(uint),
@ -684,7 +684,7 @@ pub enum type_err {
terr_ty_param_size(expected_found<uint>), terr_ty_param_size(expected_found<uint>),
terr_record_size(expected_found<uint>), terr_record_size(expected_found<uint>),
terr_record_mutability, terr_record_mutability,
terr_record_fields(expected_found<ident>), terr_record_fields(expected_found<Ident>),
terr_arg_count, terr_arg_count,
terr_regions_does_not_outlive(Region, Region), terr_regions_does_not_outlive(Region, Region),
terr_regions_not_same(Region, Region), terr_regions_not_same(Region, Region),
@ -693,7 +693,7 @@ pub enum type_err {
terr_regions_overly_polymorphic(bound_region, Region), terr_regions_overly_polymorphic(bound_region, Region),
terr_vstores_differ(terr_vstore_kind, expected_found<vstore>), terr_vstores_differ(terr_vstore_kind, expected_found<vstore>),
terr_trait_stores_differ(terr_vstore_kind, expected_found<TraitStore>), terr_trait_stores_differ(terr_vstore_kind, expected_found<TraitStore>),
terr_in_field(@type_err, ast::ident), terr_in_field(@type_err, ast::Ident),
terr_sorts(expected_found<t>), terr_sorts(expected_found<t>),
terr_integer_as_char, terr_integer_as_char,
terr_int_mismatch(expected_found<IntVarValue>), terr_int_mismatch(expected_found<IntVarValue>),
@ -848,7 +848,7 @@ impl ToStr for IntVarValue {
#[deriving(Clone)] #[deriving(Clone)]
pub struct TypeParameterDef { pub struct TypeParameterDef {
ident: ast::ident, ident: ast::Ident,
def_id: ast::def_id, def_id: ast::def_id,
bounds: @ParamBounds bounds: @ParamBounds
} }
@ -3359,13 +3359,13 @@ pub fn stmt_node_id(s: &ast::stmt) -> ast::NodeId {
} }
} }
pub fn field_idx(id: ast::ident, fields: &[field]) -> Option<uint> { pub fn field_idx(id: ast::Ident, fields: &[field]) -> Option<uint> {
let mut i = 0u; let mut i = 0u;
for f in fields.iter() { if f.ident == id { return Some(i); } i += 1u; } for f in fields.iter() { if f.ident == id { return Some(i); } i += 1u; }
return None; return None;
} }
pub fn field_idx_strict(tcx: ty::ctxt, id: ast::ident, fields: &[field]) pub fn field_idx_strict(tcx: ty::ctxt, id: ast::Ident, fields: &[field])
-> uint { -> uint {
let mut i = 0u; let mut i = 0u;
for f in fields.iter() { if f.ident == id { return i; } i += 1u; } for f in fields.iter() { if f.ident == id { return i; } i += 1u; }
@ -3375,7 +3375,7 @@ pub fn field_idx_strict(tcx: ty::ctxt, id: ast::ident, fields: &[field])
fields.map(|f| tcx.sess.str_of(f.ident)))); fields.map(|f| tcx.sess.str_of(f.ident))));
} }
pub fn method_idx(id: ast::ident, meths: &[@Method]) -> Option<uint> { pub fn method_idx(id: ast::Ident, meths: &[@Method]) -> Option<uint> {
meths.iter().position(|m| m.ident == id) meths.iter().position(|m| m.ident == id)
} }
@ -3823,9 +3823,9 @@ fn struct_ctor_id(cx: ctxt, struct_did: ast::def_id) -> Option<ast::def_id> {
#[deriving(Clone)] #[deriving(Clone)]
pub struct VariantInfo { pub struct VariantInfo {
args: ~[t], args: ~[t],
arg_names: Option<~[ast::ident]>, arg_names: Option<~[ast::Ident]>,
ctor_ty: t, ctor_ty: t,
name: ast::ident, name: ast::Ident,
id: ast::def_id, id: ast::def_id,
disr_val: Disr, disr_val: Disr,
vis: visibility vis: visibility

View file

@ -555,7 +555,7 @@ pub fn ty_of_arg<AC:AstConv,
pub fn bound_lifetimes<AC:AstConv>( pub fn bound_lifetimes<AC:AstConv>(
this: &AC, this: &AC,
ast_lifetimes: &OptVec<ast::Lifetime>) -> OptVec<ast::ident> ast_lifetimes: &OptVec<ast::Lifetime>) -> OptVec<ast::Ident>
{ {
/*! /*!
* *

View file

@ -126,7 +126,7 @@ pub fn lookup(
self_expr: @ast::expr, // The expression `a`. self_expr: @ast::expr, // The expression `a`.
callee_id: NodeId, /* Where to store `a.b`'s type, callee_id: NodeId, /* Where to store `a.b`'s type,
* also the scope of the call */ * also the scope of the call */
m_name: ast::ident, // The ident `b`. m_name: ast::Ident, // The ident `b`.
self_ty: ty::t, // The type of `a`. self_ty: ty::t, // The type of `a`.
supplied_tps: &[ty::t], // The list of types X, Y, ... . supplied_tps: &[ty::t], // The list of types X, Y, ... .
deref_args: check::DerefArgs, // Whether we autopointer first. deref_args: check::DerefArgs, // Whether we autopointer first.
@ -173,7 +173,7 @@ pub struct LookupContext<'self> {
expr: @ast::expr, expr: @ast::expr,
self_expr: @ast::expr, self_expr: @ast::expr,
callee_id: NodeId, callee_id: NodeId,
m_name: ast::ident, m_name: ast::Ident,
supplied_tps: &'self [ty::t], supplied_tps: &'self [ty::t],
impl_dups: @mut HashSet<def_id>, impl_dups: @mut HashSet<def_id>,
inherent_candidates: @mut ~[Candidate], inherent_candidates: @mut ~[Candidate],

View file

@ -557,7 +557,7 @@ pub fn check_method(ccx: @mut CrateCtxt,
} }
pub fn check_no_duplicate_fields(tcx: ty::ctxt, pub fn check_no_duplicate_fields(tcx: ty::ctxt,
fields: ~[(ast::ident, Span)]) { fields: ~[(ast::Ident, Span)]) {
let mut field_names = HashMap::new(); let mut field_names = HashMap::new();
for p in fields.iter() { for p in fields.iter() {
@ -714,7 +714,7 @@ impl RegionScope for FnCtxt {
} }
fn named_region(&self, fn named_region(&self,
span: Span, span: Span,
id: ast::ident) -> Result<ty::Region, RegionError> { id: ast::Ident) -> Result<ty::Region, RegionError> {
self.search_in_scope_regions(span, ty::br_named(id)) self.search_in_scope_regions(span, ty::br_named(id))
} }
} }
@ -1116,7 +1116,7 @@ pub fn impl_self_ty(vcx: &VtableContext,
pub fn lookup_field_ty(tcx: ty::ctxt, pub fn lookup_field_ty(tcx: ty::ctxt,
class_id: ast::def_id, class_id: ast::def_id,
items: &[ty::field_ty], items: &[ty::field_ty],
fieldname: ast::ident, fieldname: ast::Ident,
substs: &ty::substs) -> Option<ty::t> { substs: &ty::substs) -> Option<ty::t> {
let o_field = items.iter().find(|f| f.ident == fieldname); let o_field = items.iter().find(|f| f.ident == fieldname);
@ -1536,7 +1536,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
callee_id: ast::NodeId, callee_id: ast::NodeId,
expr: @ast::expr, expr: @ast::expr,
rcvr: @ast::expr, rcvr: @ast::expr,
method_name: ast::ident, method_name: ast::Ident,
args: &[@ast::expr], args: &[@ast::expr],
tps: &[ast::Ty], tps: &[ast::Ty],
sugar: ast::CallSugar) { sugar: ast::CallSugar) {
@ -1636,7 +1636,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
op_ex: @ast::expr, op_ex: @ast::expr,
self_ex: @ast::expr, self_ex: @ast::expr,
self_t: ty::t, self_t: ty::t,
opname: ast::ident, opname: ast::Ident,
args: ~[@ast::expr], args: ~[@ast::expr],
deref_args: DerefArgs, deref_args: DerefArgs,
autoderef_receiver: AutoderefReceiverFlag, autoderef_receiver: AutoderefReceiverFlag,
@ -1936,7 +1936,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
fn check_field(fcx: @mut FnCtxt, fn check_field(fcx: @mut FnCtxt,
expr: @ast::expr, expr: @ast::expr,
base: @ast::expr, base: @ast::expr,
field: ast::ident, field: ast::Ident,
tys: &[ast::Ty]) { tys: &[ast::Ty]) {
let tcx = fcx.ccx.tcx; let tcx = fcx.ccx.tcx;
let bot = check_expr(fcx, base); let bot = check_expr(fcx, base);

View file

@ -368,7 +368,7 @@ pub fn ensure_trait_methods(ccx: &CrateCtxt,
trait_rp: Option<ty::region_variance>, trait_rp: Option<ty::region_variance>,
trait_generics: &ast::Generics, trait_generics: &ast::Generics,
m_id: &ast::NodeId, m_id: &ast::NodeId,
m_ident: &ast::ident, m_ident: &ast::Ident,
m_explicit_self: &ast::explicit_self, m_explicit_self: &ast::explicit_self,
m_generics: &ast::Generics, m_generics: &ast::Generics,
m_purity: &ast::purity, m_purity: &ast::purity,

View file

@ -27,7 +27,7 @@ pub struct RegionError {
pub trait RegionScope { pub trait RegionScope {
fn anon_region(&self, span: Span) -> Result<ty::Region, RegionError>; fn anon_region(&self, span: Span) -> Result<ty::Region, RegionError>;
fn self_region(&self, span: Span) -> Result<ty::Region, RegionError>; fn self_region(&self, span: Span) -> Result<ty::Region, RegionError>;
fn named_region(&self, span: Span, id: ast::ident) fn named_region(&self, span: Span, id: ast::Ident)
-> Result<ty::Region, RegionError>; -> Result<ty::Region, RegionError>;
} }
@ -43,7 +43,7 @@ impl RegionScope for EmptyRscope {
fn self_region(&self, _span: Span) -> Result<ty::Region, RegionError> { fn self_region(&self, _span: Span) -> Result<ty::Region, RegionError> {
self.anon_region(_span) self.anon_region(_span)
} }
fn named_region(&self, _span: Span, _id: ast::ident) fn named_region(&self, _span: Span, _id: ast::Ident)
-> Result<ty::Region, RegionError> -> Result<ty::Region, RegionError>
{ {
self.anon_region(_span) self.anon_region(_span)
@ -51,14 +51,14 @@ impl RegionScope for EmptyRscope {
} }
#[deriving(Clone)] #[deriving(Clone)]
pub struct RegionParamNames(OptVec<ast::ident>); pub struct RegionParamNames(OptVec<ast::Ident>);
impl RegionParamNames { impl RegionParamNames {
fn has_self(&self) -> bool { fn has_self(&self) -> bool {
self.has_ident(special_idents::self_) self.has_ident(special_idents::self_)
} }
fn has_ident(&self, ident: ast::ident) -> bool { fn has_ident(&self, ident: ast::Ident) -> bool {
for region_param_name in self.iter() { for region_param_name in self.iter() {
if *region_param_name == ident { if *region_param_name == ident {
return true; return true;
@ -197,7 +197,7 @@ impl RegionScope for MethodRscope {
} }
result::Ok(ty::re_bound(ty::br_self)) result::Ok(ty::re_bound(ty::br_self))
} }
fn named_region(&self, span: Span, id: ast::ident) fn named_region(&self, span: Span, id: ast::Ident)
-> Result<ty::Region, RegionError> { -> Result<ty::Region, RegionError> {
if !self.region_param_names.has_ident(id) { if !self.region_param_names.has_ident(id) {
return RegionParamNames::undeclared_name(None); return RegionParamNames::undeclared_name(None);
@ -249,7 +249,7 @@ impl RegionScope for TypeRscope {
} }
result::Ok(ty::re_bound(ty::br_self)) result::Ok(ty::re_bound(ty::br_self))
} }
fn named_region(&self, span: Span, id: ast::ident) fn named_region(&self, span: Span, id: ast::Ident)
-> Result<ty::Region, RegionError> { -> Result<ty::Region, RegionError> {
do EmptyRscope.named_region(span, id).chain_err |_e| { do EmptyRscope.named_region(span, id).chain_err |_e| {
result::Err(RegionError { result::Err(RegionError {
@ -308,7 +308,7 @@ impl RegionScope for BindingRscope {
} }
fn named_region(&self, fn named_region(&self,
span: Span, span: Span,
id: ast::ident) -> Result<ty::Region, RegionError> id: ast::Ident) -> Result<ty::Region, RegionError>
{ {
do self.base.named_region(span, id).chain_err |_e| { do self.base.named_region(span, id).chain_err |_e| {
let result = ty::re_bound(ty::br_named(id)); let result = ty::re_bound(ty::br_named(id));

View file

@ -305,7 +305,7 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str {
fn bare_fn_to_str(cx: ctxt, fn bare_fn_to_str(cx: ctxt,
purity: ast::purity, purity: ast::purity,
abis: AbiSet, abis: AbiSet,
ident: Option<ast::ident>, ident: Option<ast::Ident>,
sig: &ty::FnSig) sig: &ty::FnSig)
-> ~str { -> ~str {
let mut s = ~"extern "; let mut s = ~"extern ";
@ -693,7 +693,7 @@ impl Repr for ty::Method {
} }
} }
impl Repr for ast::ident { impl Repr for ast::Ident {
fn repr(&self, _tcx: ctxt) -> ~str { fn repr(&self, _tcx: ctxt) -> ~str {
token::ident_to_str(self).to_owned() token::ident_to_str(self).to_owned()
} }

View file

@ -22,7 +22,7 @@ use syntax::parse::token;
// Hack; rather than thread an interner through everywhere, rely on // Hack; rather than thread an interner through everywhere, rely on
// thread-local data // thread-local data
// Hack-Becomes-Feature: using thread-local-state everywhere... // Hack-Becomes-Feature: using thread-local-state everywhere...
pub fn to_str(id: ast::ident) -> ~str { pub fn to_str(id: ast::Ident) -> ~str {
/* bad */ ident_to_str(&id).to_owned() /* bad */ ident_to_str(&id).to_owned()
} }

View file

@ -54,14 +54,14 @@ pub fn is_cmd(cmd: &str) -> bool {
struct ListenerFn { struct ListenerFn {
cmds: ~[~str], cmds: ~[~str],
span: codemap::Span, span: codemap::Span,
path: ~[ast::ident] path: ~[ast::Ident]
} }
struct ReadyCtx { struct ReadyCtx {
sess: session::Session, sess: session::Session,
crate: @ast::Crate, crate: @ast::Crate,
ext_cx: @ExtCtxt, ext_cx: @ExtCtxt,
path: ~[ast::ident], path: ~[ast::Ident],
fns: ~[ListenerFn] fns: ~[ListenerFn]
} }

View file

@ -25,10 +25,12 @@ use extra::serialize::{Encodable, Decodable, Encoder, Decoder};
// macro expansion per Flatt et al., "Macros // macro expansion per Flatt et al., "Macros
// That Work Together" // That Work Together"
#[deriving(Clone, Eq, IterBytes, ToStr)] #[deriving(Clone, Eq, IterBytes, ToStr)]
pub struct ident { name: Name, ctxt: SyntaxContext } pub struct Ident { name: Name, ctxt: SyntaxContext }
/// Construct an identifier with the given name and an empty context: impl Ident {
pub fn new_ident(name: Name) -> ident { ident {name: name, ctxt: empty_ctxt}} /// Construct an identifier with the given name and an empty context:
pub fn new(name: Name) -> Ident { Ident {name: name, ctxt: empty_ctxt}}
}
/// A SyntaxContext represents a chain of macro-expandings /// A SyntaxContext represents a chain of macro-expandings
/// and renamings. Each macro expansion corresponds to /// and renamings. Each macro expansion corresponds to
@ -48,7 +50,7 @@ pub type SyntaxContext = uint;
pub struct SCTable { pub struct SCTable {
table : ~[SyntaxContext_], table : ~[SyntaxContext_],
mark_memo : HashMap<(SyntaxContext,Mrk),SyntaxContext>, mark_memo : HashMap<(SyntaxContext,Mrk),SyntaxContext>,
rename_memo : HashMap<(SyntaxContext,ident,Name),SyntaxContext> rename_memo : HashMap<(SyntaxContext,Ident,Name),SyntaxContext>
} }
// NB: these must be placed in any SCTable... // NB: these must be placed in any SCTable...
pub static empty_ctxt : uint = 0; pub static empty_ctxt : uint = 0;
@ -66,7 +68,7 @@ pub enum SyntaxContext_ {
// "to" slot must have the same name and context // "to" slot must have the same name and context
// in the "from" slot. In essence, they're all // in the "from" slot. In essence, they're all
// pointers to a single "rename" event node. // pointers to a single "rename" event node.
Rename (ident,Name,SyntaxContext), Rename (Ident,Name,SyntaxContext),
IllegalCtxt() IllegalCtxt()
} }
@ -76,27 +78,27 @@ pub type Name = uint;
/// A mark represents a unique id associated with a macro expansion /// A mark represents a unique id associated with a macro expansion
pub type Mrk = uint; pub type Mrk = uint;
impl<S:Encoder> Encodable<S> for ident { impl<S:Encoder> Encodable<S> for Ident {
fn encode(&self, s: &mut S) { fn encode(&self, s: &mut S) {
s.emit_str(interner_get(self.name)); s.emit_str(interner_get(self.name));
} }
} }
#[deriving(IterBytes)] #[deriving(IterBytes)]
impl<D:Decoder> Decodable<D> for ident { impl<D:Decoder> Decodable<D> for Ident {
fn decode(d: &mut D) -> ident { fn decode(d: &mut D) -> Ident {
str_to_ident(d.read_str()) str_to_ident(d.read_str())
} }
} }
/// Function name (not all functions have names) /// Function name (not all functions have names)
pub type fn_ident = Option<ident>; pub type fn_ident = Option<Ident>;
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub struct Lifetime { pub struct Lifetime {
id: NodeId, id: NodeId,
span: Span, span: Span,
ident: ident ident: Ident
} }
// a "Path" is essentially Rust's notion of a name; // a "Path" is essentially Rust's notion of a name;
@ -118,7 +120,7 @@ pub struct Path {
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub struct PathSegment { pub struct PathSegment {
/// The identifier portion of this path segment. /// The identifier portion of this path segment.
identifier: ident, identifier: Ident,
/// The lifetime parameter for this path segment. Currently only one /// The lifetime parameter for this path segment. Currently only one
/// lifetime parameter is allowed. /// lifetime parameter is allowed.
lifetime: Option<Lifetime>, lifetime: Option<Lifetime>,
@ -151,7 +153,7 @@ pub enum TyParamBound {
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub struct TyParam { pub struct TyParam {
ident: ident, ident: Ident,
id: NodeId, id: NodeId,
bounds: OptVec<TyParamBound> bounds: OptVec<TyParamBound>
} }
@ -275,7 +277,7 @@ pub struct pat {
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub struct field_pat { pub struct field_pat {
ident: ident, ident: Ident,
pat: @pat, pat: @pat,
} }
@ -430,7 +432,7 @@ pub struct arm {
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub struct Field { pub struct Field {
ident: ident, ident: Ident,
expr: @expr, expr: @expr,
span: Span, span: Span,
} }
@ -473,7 +475,7 @@ pub enum expr_ {
expr_vstore(@expr, expr_vstore), expr_vstore(@expr, expr_vstore),
expr_vec(~[@expr], mutability), expr_vec(~[@expr], mutability),
expr_call(@expr, ~[@expr], CallSugar), expr_call(@expr, ~[@expr], CallSugar),
expr_method_call(NodeId, @expr, ident, ~[Ty], ~[@expr], CallSugar), expr_method_call(NodeId, @expr, Ident, ~[Ty], ~[@expr], CallSugar),
expr_tup(~[@expr]), expr_tup(~[@expr]),
expr_binary(NodeId, binop, @expr, @expr), expr_binary(NodeId, binop, @expr, @expr),
expr_unary(NodeId, unop, @expr), expr_unary(NodeId, unop, @expr),
@ -485,7 +487,7 @@ pub enum expr_ {
/* Conditionless loop (can be exited with break, cont, or ret) /* Conditionless loop (can be exited with break, cont, or ret)
Same semantics as while(true) { body }, but typestate knows that the Same semantics as while(true) { body }, but typestate knows that the
(implicit) condition is always true. */ (implicit) condition is always true. */
expr_loop(Block, Option<ident>), expr_loop(Block, Option<Ident>),
expr_match(@expr, ~[arm]), expr_match(@expr, ~[arm]),
expr_fn_block(fn_decl, Block), expr_fn_block(fn_decl, Block),
expr_do_body(@expr), expr_do_body(@expr),
@ -493,15 +495,15 @@ pub enum expr_ {
expr_assign(@expr, @expr), expr_assign(@expr, @expr),
expr_assign_op(NodeId, binop, @expr, @expr), expr_assign_op(NodeId, binop, @expr, @expr),
expr_field(@expr, ident, ~[Ty]), expr_field(@expr, Ident, ~[Ty]),
expr_index(NodeId, @expr, @expr), expr_index(NodeId, @expr, @expr),
expr_path(Path), expr_path(Path),
/// The special identifier `self`. /// The special identifier `self`.
expr_self, expr_self,
expr_addr_of(mutability, @expr), expr_addr_of(mutability, @expr),
expr_break(Option<ident>), expr_break(Option<Ident>),
expr_again(Option<ident>), expr_again(Option<Ident>),
expr_ret(Option<@expr>), expr_ret(Option<@expr>),
expr_log(@expr, @expr), expr_log(@expr, @expr),
@ -550,7 +552,7 @@ pub enum token_tree {
tt_seq(Span, @mut ~[token_tree], Option<::parse::token::Token>, bool), tt_seq(Span, @mut ~[token_tree], Option<::parse::token::Token>, bool),
// a syntactic variable that will be filled in by macro expansion. // a syntactic variable that will be filled in by macro expansion.
tt_nonterminal(Span, ident) tt_nonterminal(Span, Ident)
} }
// //
@ -615,7 +617,7 @@ pub enum matcher_ {
// lo, hi position-in-match-array used: // lo, hi position-in-match-array used:
match_seq(~[matcher], Option<::parse::token::Token>, bool, uint, uint), match_seq(~[matcher], Option<::parse::token::Token>, bool, uint, uint),
// parse a Rust NT: name to bind, name of NT, position in match array: // parse a Rust NT: name to bind, name of NT, position in match array:
match_nonterminal(ident, ident, uint) match_nonterminal(Ident, Ident, uint)
} }
pub type mac = Spanned<mac_>; pub type mac = Spanned<mac_>;
@ -649,14 +651,14 @@ pub struct mt {
#[deriving(Eq, Encodable, Decodable,IterBytes)] #[deriving(Eq, Encodable, Decodable,IterBytes)]
pub struct TypeField { pub struct TypeField {
ident: ident, ident: Ident,
mt: mt, mt: mt,
span: Span, span: Span,
} }
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub struct TypeMethod { pub struct TypeMethod {
ident: ident, ident: Ident,
attrs: ~[Attribute], attrs: ~[Attribute],
purity: purity, purity: purity,
decl: fn_decl, decl: fn_decl,
@ -868,7 +870,7 @@ pub type explicit_self = Spanned<explicit_self_>;
#[deriving(Eq, Encodable, Decodable,IterBytes)] #[deriving(Eq, Encodable, Decodable,IterBytes)]
pub struct method { pub struct method {
ident: ident, ident: Ident,
attrs: ~[Attribute], attrs: ~[Attribute],
generics: Generics, generics: Generics,
explicit_self: explicit_self, explicit_self: explicit_self,
@ -921,7 +923,7 @@ pub struct enum_def {
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub struct variant_ { pub struct variant_ {
name: ident, name: Ident,
attrs: ~[Attribute], attrs: ~[Attribute],
kind: variant_kind, kind: variant_kind,
id: NodeId, id: NodeId,
@ -933,7 +935,7 @@ pub type variant = Spanned<variant_>;
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub struct path_list_ident_ { pub struct path_list_ident_ {
name: ident, name: Ident,
id: NodeId, id: NodeId,
} }
@ -949,7 +951,7 @@ pub enum view_path_ {
// or just // or just
// //
// foo::bar::baz (with 'baz =' implicitly on the left) // foo::bar::baz (with 'baz =' implicitly on the left)
view_path_simple(ident, Path, NodeId), view_path_simple(Ident, Path, NodeId),
// foo::bar::* // foo::bar::*
view_path_glob(Path, NodeId), view_path_glob(Path, NodeId),
@ -972,7 +974,7 @@ pub enum view_item_ {
// optional @str: if present, this is a location (containing // optional @str: if present, this is a location (containing
// arbitrary characters) from which to fetch the crate sources // arbitrary characters) from which to fetch the crate sources
// For example, extern mod whatever = "github.com/mozilla/rust" // For example, extern mod whatever = "github.com/mozilla/rust"
view_item_extern_mod(ident, Option<@str>, ~[@MetaItem], NodeId), view_item_extern_mod(Ident, Option<@str>, ~[@MetaItem], NodeId),
view_item_use(~[@view_path]), view_item_use(~[@view_path]),
} }
@ -1037,7 +1039,7 @@ pub type struct_field = Spanned<struct_field_>;
#[deriving(Eq, Encodable, Decodable,IterBytes)] #[deriving(Eq, Encodable, Decodable,IterBytes)]
pub enum struct_field_kind { pub enum struct_field_kind {
named_field(ident, visibility), named_field(Ident, visibility),
unnamed_field // element of a tuple-like struct unnamed_field // element of a tuple-like struct
} }
@ -1055,7 +1057,7 @@ pub struct struct_def {
*/ */
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub struct item { pub struct item {
ident: ident, ident: Ident,
attrs: ~[Attribute], attrs: ~[Attribute],
id: NodeId, id: NodeId,
node: item_, node: item_,
@ -1083,7 +1085,7 @@ pub enum item_ {
#[deriving(Eq, Encodable, Decodable,IterBytes)] #[deriving(Eq, Encodable, Decodable,IterBytes)]
pub struct foreign_item { pub struct foreign_item {
ident: ident, ident: Ident,
attrs: ~[Attribute], attrs: ~[Attribute],
node: foreign_item_, node: foreign_item_,
id: NodeId, id: NodeId,

View file

@ -27,8 +27,8 @@ use std::vec;
#[deriving(Clone, Eq)] #[deriving(Clone, Eq)]
pub enum path_elt { pub enum path_elt {
path_mod(ident), path_mod(Ident),
path_name(ident) path_name(Ident)
} }
pub type path = ~[path_elt]; pub type path = ~[path_elt];
@ -44,7 +44,7 @@ pub fn path_to_str_with_sep(p: &[path_elt], sep: &str, itr: @ident_interner)
strs.connect(sep) strs.connect(sep)
} }
pub fn path_ident_to_str(p: &path, i: ident, itr: @ident_interner) -> ~str { pub fn path_ident_to_str(p: &path, i: Ident, itr: @ident_interner) -> ~str {
if p.is_empty() { if p.is_empty() {
itr.get(i.name).to_owned() itr.get(i.name).to_owned()
} else { } else {
@ -74,7 +74,7 @@ pub enum ast_node {
node_expr(@expr), node_expr(@expr),
node_stmt(@stmt), node_stmt(@stmt),
node_arg, node_arg,
node_local(ident), node_local(Ident),
node_block(Block), node_block(Block),
node_struct_ctor(@struct_def, @item, @path), node_struct_ctor(@struct_def, @item, @path),
node_callee_scope(@expr) node_callee_scope(@expr)
@ -89,7 +89,7 @@ pub struct Ctx {
} }
impl Ctx { impl Ctx {
fn extend(&self, elt: ident) -> @path { fn extend(&self, elt: Ident) -> @path {
@vec::append(self.path.clone(), [path_name(elt)]) @vec::append(self.path.clone(), [path_name(elt)])
} }
@ -110,7 +110,7 @@ impl Ctx {
fn map_struct_def(&mut self, fn map_struct_def(&mut self,
struct_def: @ast::struct_def, struct_def: @ast::struct_def,
parent_node: ast_node, parent_node: ast_node,
ident: ast::ident) { ident: ast::Ident) {
let p = self.extend(ident); let p = self.extend(ident);
// If this is a tuple-like struct, register the constructor. // If this is a tuple-like struct, register the constructor.
@ -356,7 +356,7 @@ impl Visitor<()> for Ctx {
fn visit_struct_def(&mut self, fn visit_struct_def(&mut self,
struct_def: @struct_def, struct_def: @struct_def,
ident: ident, ident: Ident,
generics: &Generics, generics: &Generics,
node_id: NodeId, node_id: NodeId,
_: ()) { _: ()) {

View file

@ -23,12 +23,12 @@ use std::local_data;
use std::num; use std::num;
use std::option; use std::option;
pub fn path_name_i(idents: &[ident]) -> ~str { pub fn path_name_i(idents: &[Ident]) -> ~str {
// FIXME: Bad copies (#2543 -- same for everything else that says "bad") // FIXME: Bad copies (#2543 -- same for everything else that says "bad")
idents.map(|i| token::interner_get(i.name)).connect("::") idents.map(|i| token::interner_get(i.name)).connect("::")
} }
pub fn path_to_ident(path: &Path) -> ident { pub fn path_to_ident(path: &Path) -> Ident {
path.segments.last().identifier path.segments.last().identifier
} }
@ -217,7 +217,7 @@ pub fn default_block(
} }
} }
pub fn ident_to_path(s: Span, identifier: ident) -> Path { pub fn ident_to_path(s: Span, identifier: Ident) -> Path {
ast::Path { ast::Path {
span: s, span: s,
global: false, global: false,
@ -231,7 +231,7 @@ pub fn ident_to_path(s: Span, identifier: ident) -> Path {
} }
} }
pub fn ident_to_pat(id: NodeId, s: Span, i: ident) -> @pat { pub fn ident_to_pat(id: NodeId, s: Span, i: Ident) -> @pat {
@ast::pat { id: id, @ast::pat { id: id,
node: pat_ident(bind_infer, ident_to_path(s, i), None), node: pat_ident(bind_infer, ident_to_path(s, i), None),
span: s } span: s }
@ -302,13 +302,13 @@ pub fn struct_field_visibility(field: ast::struct_field) -> visibility {
} }
pub trait inlined_item_utils { pub trait inlined_item_utils {
fn ident(&self) -> ident; fn ident(&self) -> Ident;
fn id(&self) -> ast::NodeId; fn id(&self) -> ast::NodeId;
fn accept<E: Clone, V:Visitor<E>>(&self, e: E, v: &mut V); fn accept<E: Clone, V:Visitor<E>>(&self, e: E, v: &mut V);
} }
impl inlined_item_utils for inlined_item { impl inlined_item_utils for inlined_item {
fn ident(&self) -> ident { fn ident(&self) -> Ident {
match *self { match *self {
ii_item(i) => i.ident, ii_item(i) => i.ident,
ii_foreign(i) => i.ident, ii_foreign(i) => i.ident,
@ -608,7 +608,7 @@ impl Visitor<()> for IdVisitor {
// XXX: Default // XXX: Default
fn visit_struct_def(&mut self, fn visit_struct_def(&mut self,
struct_definition: @struct_def, struct_definition: @struct_def,
identifier: ident, identifier: Ident,
generics: &Generics, generics: &Generics,
node_id: NodeId, node_id: NodeId,
env: ()) { env: ()) {
@ -749,7 +749,7 @@ impl SimpleVisitor for EachViewItemData {
} }
fn visit_struct_def(&mut self, fn visit_struct_def(&mut self,
_: @struct_def, _: @struct_def,
_: ident, _: Ident,
_: &Generics, _: &Generics,
_: NodeId) { _: NodeId) {
// XXX: Default method. // XXX: Default method.
@ -827,7 +827,7 @@ pub fn pat_is_ident(pat: @ast::pat) -> bool {
// HYGIENE FUNCTIONS // HYGIENE FUNCTIONS
/// Construct an identifier with the given name and an empty context: /// Construct an identifier with the given name and an empty context:
pub fn new_ident(name: Name) -> ident { ident {name: name, ctxt: 0}} pub fn new_ident(name: Name) -> Ident { Ident {name: name, ctxt: 0}}
/// Extend a syntax context with a given mark /// Extend a syntax context with a given mark
pub fn new_mark(m:Mrk, tail:SyntaxContext) -> SyntaxContext { pub fn new_mark(m:Mrk, tail:SyntaxContext) -> SyntaxContext {
@ -859,13 +859,13 @@ pub fn new_mark_internal(m:Mrk, tail:SyntaxContext,table:&mut SCTable)
} }
/// Extend a syntax context with a given rename /// Extend a syntax context with a given rename
pub fn new_rename(id:ident, to:Name, tail:SyntaxContext) -> SyntaxContext { pub fn new_rename(id:Ident, to:Name, tail:SyntaxContext) -> SyntaxContext {
new_rename_internal(id, to, tail, get_sctable()) new_rename_internal(id, to, tail, get_sctable())
} }
// Extend a syntax context with a given rename and sctable // Extend a syntax context with a given rename and sctable
// FIXME #4536 : currently pub to allow testing // FIXME #4536 : currently pub to allow testing
pub fn new_rename_internal(id:ident, to:Name, tail:SyntaxContext, table: &mut SCTable) pub fn new_rename_internal(id:Ident, to:Name, tail:SyntaxContext, table: &mut SCTable)
-> SyntaxContext { -> SyntaxContext {
let key = (tail,id,to); let key = (tail,id,to);
// FIXME #5074 // FIXME #5074
@ -916,22 +916,22 @@ fn idx_push<T>(vec: &mut ~[T], val: T) -> uint {
} }
/// Resolve a syntax object to a name, per MTWT. /// Resolve a syntax object to a name, per MTWT.
pub fn resolve(id : ident) -> Name { pub fn resolve(id : Ident) -> Name {
resolve_internal(id, get_sctable()) resolve_internal(id, get_sctable())
} }
// Resolve a syntax object to a name, per MTWT. // Resolve a syntax object to a name, per MTWT.
// FIXME #4536 : currently pub to allow testing // FIXME #4536 : currently pub to allow testing
pub fn resolve_internal(id : ident, table : &mut SCTable) -> Name { pub fn resolve_internal(id : Ident, table : &mut SCTable) -> Name {
match table.table[id.ctxt] { match table.table[id.ctxt] {
EmptyCtxt => id.name, EmptyCtxt => id.name,
// ignore marks here: // ignore marks here:
Mark(_,subctxt) => resolve_internal(ident{name:id.name, ctxt: subctxt},table), Mark(_,subctxt) => resolve_internal(Ident{name:id.name, ctxt: subctxt},table),
// do the rename if necessary: // do the rename if necessary:
Rename(ident{name,ctxt},toname,subctxt) => { Rename(Ident{name,ctxt},toname,subctxt) => {
// this could be cached or computed eagerly: // this could be cached or computed eagerly:
let resolvedfrom = resolve_internal(ident{name:name,ctxt:ctxt},table); let resolvedfrom = resolve_internal(Ident{name:name,ctxt:ctxt},table);
let resolvedthis = resolve_internal(ident{name:id.name,ctxt:subctxt},table); let resolvedthis = resolve_internal(Ident{name:id.name,ctxt:subctxt},table);
if ((resolvedthis == resolvedfrom) if ((resolvedthis == resolvedfrom)
&& (marksof(ctxt,resolvedthis,table) && (marksof(ctxt,resolvedthis,table)
== marksof(subctxt,resolvedthis,table))) { == marksof(subctxt,resolvedthis,table))) {
@ -1014,12 +1014,12 @@ mod test {
// convert a list of uints to an @[ident] // convert a list of uints to an @[ident]
// (ignores the interner completely) // (ignores the interner completely)
fn uints_to_idents (uints: &~[uint]) -> @~[ident] { fn uints_to_idents (uints: &~[uint]) -> @~[Ident] {
@uints.map(|u| ident {name:*u, ctxt: empty_ctxt}) @uints.map(|u| Ident {name:*u, ctxt: empty_ctxt})
} }
fn id (u : uint, s: SyntaxContext) -> ident { fn id (u : uint, s: SyntaxContext) -> Ident {
ident{name:u, ctxt: s} Ident{name:u, ctxt: s}
} }
// because of the SCTable, I now need a tidy way of // because of the SCTable, I now need a tidy way of
@ -1027,7 +1027,7 @@ mod test {
#[deriving(Clone, Eq)] #[deriving(Clone, Eq)]
enum TestSC { enum TestSC {
M(Mrk), M(Mrk),
R(ident,Name) R(Ident,Name)
} }
// unfold a vector of TestSC values into a SCTable, // unfold a vector of TestSC values into a SCTable,

View file

@ -57,7 +57,7 @@ pub struct SyntaxExpanderTTItem {
pub type SyntaxExpanderTTItemFun = @fn(@ExtCtxt, pub type SyntaxExpanderTTItemFun = @fn(@ExtCtxt,
Span, Span,
ast::ident, ast::Ident,
~[ast::token_tree]) ~[ast::token_tree])
-> MacResult; -> MacResult;
@ -114,7 +114,7 @@ pub struct BlockInfo {
} }
// a list of ident->name renamings // a list of ident->name renamings
type RenameList = ~[(ast::ident,Name)]; type RenameList = ~[(ast::Ident,Name)];
// The base map of methods for expanding syntax extension // The base map of methods for expanding syntax extension
// AST nodes into full ASTs // AST nodes into full ASTs
@ -228,7 +228,7 @@ pub struct ExtCtxt {
// and there are bugs in the code for object // and there are bugs in the code for object
// types that make this hard to get right at the // types that make this hard to get right at the
// moment. - nmatsakis // moment. - nmatsakis
mod_path: @mut ~[ast::ident], mod_path: @mut ~[ast::Ident],
trace_mac: @mut bool trace_mac: @mut bool
} }
@ -255,9 +255,9 @@ impl ExtCtxt {
} }
pub fn print_backtrace(&self) { } pub fn print_backtrace(&self) { }
pub fn backtrace(&self) -> Option<@ExpnInfo> { *self.backtrace } pub fn backtrace(&self) -> Option<@ExpnInfo> { *self.backtrace }
pub fn mod_push(&self, i: ast::ident) { self.mod_path.push(i); } pub fn mod_push(&self, i: ast::Ident) { self.mod_path.push(i); }
pub fn mod_pop(&self) { self.mod_path.pop(); } pub fn mod_pop(&self) { self.mod_path.pop(); }
pub fn mod_path(&self) -> ~[ast::ident] { (*self.mod_path).clone() } pub fn mod_path(&self) -> ~[ast::Ident] { (*self.mod_path).clone() }
pub fn bt_push(&self, ei: codemap::ExpnInfo) { pub fn bt_push(&self, ei: codemap::ExpnInfo) {
match ei { match ei {
ExpnInfo {call_site: cs, callee: ref callee} => { ExpnInfo {call_site: cs, callee: ref callee} => {
@ -311,10 +311,10 @@ impl ExtCtxt {
pub fn set_trace_macros(&self, x: bool) { pub fn set_trace_macros(&self, x: bool) {
*self.trace_mac = x *self.trace_mac = x
} }
pub fn str_of(&self, id: ast::ident) -> @str { pub fn str_of(&self, id: ast::Ident) -> @str {
ident_to_str(&id) ident_to_str(&id)
} }
pub fn ident_of(&self, st: &str) -> ast::ident { pub fn ident_of(&self, st: &str) -> ast::Ident {
str_to_ident(st) str_to_ident(st)
} }
} }

View file

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
use abi::AbiSet; use abi::AbiSet;
use ast::ident; use ast::Ident;
use ast; use ast;
use ast_util; use ast_util;
use codemap::{Span, respan, dummy_sp}; use codemap::{Span, respan, dummy_sp};
@ -20,7 +20,7 @@ use opt_vec;
use opt_vec::OptVec; use opt_vec::OptVec;
pub struct Field { pub struct Field {
ident: ast::ident, ident: ast::Ident,
ex: @ast::expr ex: @ast::expr
} }
@ -32,12 +32,12 @@ mod syntax {
pub trait AstBuilder { pub trait AstBuilder {
// paths // paths
fn path(&self, span: Span, strs: ~[ast::ident]) -> ast::Path; fn path(&self, span: Span, strs: ~[ast::Ident]) -> ast::Path;
fn path_ident(&self, span: Span, id: ast::ident) -> ast::Path; fn path_ident(&self, span: Span, id: ast::Ident) -> ast::Path;
fn path_global(&self, span: Span, strs: ~[ast::ident]) -> ast::Path; fn path_global(&self, span: Span, strs: ~[ast::Ident]) -> ast::Path;
fn path_all(&self, sp: Span, fn path_all(&self, sp: Span,
global: bool, global: bool,
idents: ~[ast::ident], idents: ~[ast::Ident],
rp: Option<ast::Lifetime>, rp: Option<ast::Lifetime>,
types: ~[ast::Ty]) types: ~[ast::Ty])
-> ast::Path; -> ast::Path;
@ -47,7 +47,7 @@ pub trait AstBuilder {
fn ty(&self, span: Span, ty: ast::ty_) -> ast::Ty; fn ty(&self, span: Span, ty: ast::ty_) -> ast::Ty;
fn ty_path(&self, ast::Path, Option<OptVec<ast::TyParamBound>>) -> ast::Ty; fn ty_path(&self, ast::Path, Option<OptVec<ast::TyParamBound>>) -> ast::Ty;
fn ty_ident(&self, span: Span, idents: ast::ident) -> ast::Ty; fn ty_ident(&self, span: Span, idents: ast::Ident) -> ast::Ty;
fn ty_rptr(&self, span: Span, fn ty_rptr(&self, span: Span,
ty: ast::Ty, ty: ast::Ty,
@ -62,22 +62,22 @@ pub trait AstBuilder {
fn ty_vars(&self, ty_params: &OptVec<ast::TyParam>) -> ~[ast::Ty]; fn ty_vars(&self, ty_params: &OptVec<ast::TyParam>) -> ~[ast::Ty];
fn ty_vars_global(&self, ty_params: &OptVec<ast::TyParam>) -> ~[ast::Ty]; fn ty_vars_global(&self, ty_params: &OptVec<ast::TyParam>) -> ~[ast::Ty];
fn ty_field_imm(&self, span: Span, name: ident, ty: ast::Ty) -> ast::TypeField; fn ty_field_imm(&self, span: Span, name: Ident, ty: ast::Ty) -> ast::TypeField;
fn strip_bounds(&self, bounds: &Generics) -> Generics; fn strip_bounds(&self, bounds: &Generics) -> Generics;
fn typaram(&self, id: ast::ident, bounds: OptVec<ast::TyParamBound>) -> ast::TyParam; fn typaram(&self, id: ast::Ident, bounds: OptVec<ast::TyParamBound>) -> ast::TyParam;
fn trait_ref(&self, path: ast::Path) -> ast::trait_ref; fn trait_ref(&self, path: ast::Path) -> ast::trait_ref;
fn typarambound(&self, path: ast::Path) -> ast::TyParamBound; fn typarambound(&self, path: ast::Path) -> ast::TyParamBound;
fn lifetime(&self, span: Span, ident: ast::ident) -> ast::Lifetime; fn lifetime(&self, span: Span, ident: ast::Ident) -> ast::Lifetime;
// statements // statements
fn stmt_expr(&self, expr: @ast::expr) -> @ast::stmt; fn stmt_expr(&self, expr: @ast::expr) -> @ast::stmt;
fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::ident, ex: @ast::expr) -> @ast::stmt; fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident, ex: @ast::expr) -> @ast::stmt;
fn stmt_let_typed(&self, fn stmt_let_typed(&self,
sp: Span, sp: Span,
mutbl: bool, mutbl: bool,
ident: ast::ident, ident: ast::Ident,
typ: ast::Ty, typ: ast::Ty,
ex: @ast::expr) ex: @ast::expr)
-> @ast::stmt; -> @ast::stmt;
@ -93,7 +93,7 @@ pub trait AstBuilder {
// expressions // expressions
fn expr(&self, span: Span, node: ast::expr_) -> @ast::expr; fn expr(&self, span: Span, node: ast::expr_) -> @ast::expr;
fn expr_path(&self, path: ast::Path) -> @ast::expr; fn expr_path(&self, path: ast::Path) -> @ast::expr;
fn expr_ident(&self, span: Span, id: ast::ident) -> @ast::expr; fn expr_ident(&self, span: Span, id: ast::Ident) -> @ast::expr;
fn expr_self(&self, span: Span) -> @ast::expr; fn expr_self(&self, span: Span) -> @ast::expr;
fn expr_binary(&self, sp: Span, op: ast::binop, fn expr_binary(&self, sp: Span, op: ast::binop,
@ -104,19 +104,19 @@ pub trait AstBuilder {
fn expr_managed(&self, sp: Span, e: @ast::expr) -> @ast::expr; fn expr_managed(&self, sp: Span, e: @ast::expr) -> @ast::expr;
fn expr_addr_of(&self, sp: Span, e: @ast::expr) -> @ast::expr; fn expr_addr_of(&self, sp: Span, e: @ast::expr) -> @ast::expr;
fn expr_mut_addr_of(&self, sp: Span, e: @ast::expr) -> @ast::expr; fn expr_mut_addr_of(&self, sp: Span, e: @ast::expr) -> @ast::expr;
fn expr_field_access(&self, span: Span, expr: @ast::expr, ident: ast::ident) -> @ast::expr; fn expr_field_access(&self, span: Span, expr: @ast::expr, ident: ast::Ident) -> @ast::expr;
fn expr_call(&self, span: Span, expr: @ast::expr, args: ~[@ast::expr]) -> @ast::expr; fn expr_call(&self, span: Span, expr: @ast::expr, args: ~[@ast::expr]) -> @ast::expr;
fn expr_call_ident(&self, span: Span, id: ast::ident, args: ~[@ast::expr]) -> @ast::expr; fn expr_call_ident(&self, span: Span, id: ast::Ident, args: ~[@ast::expr]) -> @ast::expr;
fn expr_call_global(&self, sp: Span, fn_path: ~[ast::ident], fn expr_call_global(&self, sp: Span, fn_path: ~[ast::Ident],
args: ~[@ast::expr]) -> @ast::expr; args: ~[@ast::expr]) -> @ast::expr;
fn expr_method_call(&self, span: Span, fn expr_method_call(&self, span: Span,
expr: @ast::expr, ident: ast::ident, expr: @ast::expr, ident: ast::Ident,
args: ~[@ast::expr]) -> @ast::expr; args: ~[@ast::expr]) -> @ast::expr;
fn expr_block(&self, b: ast::Block) -> @ast::expr; fn expr_block(&self, b: ast::Block) -> @ast::expr;
fn field_imm(&self, span: Span, name: ident, e: @ast::expr) -> ast::Field; fn field_imm(&self, span: Span, name: Ident, e: @ast::expr) -> ast::Field;
fn expr_struct(&self, span: Span, path: ast::Path, fields: ~[ast::Field]) -> @ast::expr; fn expr_struct(&self, span: Span, path: ast::Path, fields: ~[ast::Field]) -> @ast::expr;
fn expr_struct_ident(&self, span: Span, id: ast::ident, fields: ~[ast::Field]) -> @ast::expr; fn expr_struct_ident(&self, span: Span, id: ast::Ident, fields: ~[ast::Field]) -> @ast::expr;
fn expr_lit(&self, sp: Span, lit: ast::lit_) -> @ast::expr; fn expr_lit(&self, sp: Span, lit: ast::lit_) -> @ast::expr;
@ -137,11 +137,11 @@ pub trait AstBuilder {
fn pat(&self, span: Span, pat: ast::pat_) -> @ast::pat; fn pat(&self, span: Span, pat: ast::pat_) -> @ast::pat;
fn pat_wild(&self, span: Span) -> @ast::pat; fn pat_wild(&self, span: Span) -> @ast::pat;
fn pat_lit(&self, span: Span, expr: @ast::expr) -> @ast::pat; fn pat_lit(&self, span: Span, expr: @ast::expr) -> @ast::pat;
fn pat_ident(&self, span: Span, ident: ast::ident) -> @ast::pat; fn pat_ident(&self, span: Span, ident: ast::Ident) -> @ast::pat;
fn pat_ident_binding_mode(&self, fn pat_ident_binding_mode(&self,
span: Span, span: Span,
ident: ast::ident, ident: ast::Ident,
bm: ast::binding_mode) -> @ast::pat; bm: ast::binding_mode) -> @ast::pat;
fn pat_enum(&self, span: Span, path: ast::Path, subpats: ~[@ast::pat]) -> @ast::pat; fn pat_enum(&self, span: Span, path: ast::Path, subpats: ~[@ast::pat]) -> @ast::pat;
fn pat_struct(&self, span: Span, fn pat_struct(&self, span: Span,
@ -156,65 +156,65 @@ pub trait AstBuilder {
fn lambda_fn_decl(&self, span: Span, fn_decl: ast::fn_decl, blk: ast::Block) -> @ast::expr; fn lambda_fn_decl(&self, span: Span, fn_decl: ast::fn_decl, blk: ast::Block) -> @ast::expr;
fn lambda(&self, span: Span, ids: ~[ast::ident], blk: ast::Block) -> @ast::expr; fn lambda(&self, span: Span, ids: ~[ast::Ident], blk: ast::Block) -> @ast::expr;
fn lambda0(&self, span: Span, blk: ast::Block) -> @ast::expr; fn lambda0(&self, span: Span, blk: ast::Block) -> @ast::expr;
fn lambda1(&self, span: Span, blk: ast::Block, ident: ast::ident) -> @ast::expr; fn lambda1(&self, span: Span, blk: ast::Block, ident: ast::Ident) -> @ast::expr;
fn lambda_expr(&self, span: Span, ids: ~[ast::ident], blk: @ast::expr) -> @ast::expr; fn lambda_expr(&self, span: Span, ids: ~[ast::Ident], blk: @ast::expr) -> @ast::expr;
fn lambda_expr_0(&self, span: Span, expr: @ast::expr) -> @ast::expr; fn lambda_expr_0(&self, span: Span, expr: @ast::expr) -> @ast::expr;
fn lambda_expr_1(&self, span: Span, expr: @ast::expr, ident: ast::ident) -> @ast::expr; fn lambda_expr_1(&self, span: Span, expr: @ast::expr, ident: ast::Ident) -> @ast::expr;
fn lambda_stmts(&self, span: Span, ids: ~[ast::ident], blk: ~[@ast::stmt]) -> @ast::expr; fn lambda_stmts(&self, span: Span, ids: ~[ast::Ident], blk: ~[@ast::stmt]) -> @ast::expr;
fn lambda_stmts_0(&self, span: Span, stmts: ~[@ast::stmt]) -> @ast::expr; fn lambda_stmts_0(&self, span: Span, stmts: ~[@ast::stmt]) -> @ast::expr;
fn lambda_stmts_1(&self, span: Span, stmts: ~[@ast::stmt], ident: ast::ident) -> @ast::expr; fn lambda_stmts_1(&self, span: Span, stmts: ~[@ast::stmt], ident: ast::Ident) -> @ast::expr;
// items // items
fn item(&self, span: Span, fn item(&self, span: Span,
name: ident, attrs: ~[ast::Attribute], node: ast::item_) -> @ast::item; name: Ident, attrs: ~[ast::Attribute], node: ast::item_) -> @ast::item;
fn arg(&self, span: Span, name: ident, ty: ast::Ty) -> ast::arg; fn arg(&self, span: Span, name: Ident, ty: ast::Ty) -> ast::arg;
// XXX unused self // XXX unused self
fn fn_decl(&self, inputs: ~[ast::arg], output: ast::Ty) -> ast::fn_decl; fn fn_decl(&self, inputs: ~[ast::arg], output: ast::Ty) -> ast::fn_decl;
fn item_fn_poly(&self, fn item_fn_poly(&self,
span: Span, span: Span,
name: ident, name: Ident,
inputs: ~[ast::arg], inputs: ~[ast::arg],
output: ast::Ty, output: ast::Ty,
generics: Generics, generics: Generics,
body: ast::Block) -> @ast::item; body: ast::Block) -> @ast::item;
fn item_fn(&self, fn item_fn(&self,
span: Span, span: Span,
name: ident, name: Ident,
inputs: ~[ast::arg], inputs: ~[ast::arg],
output: ast::Ty, output: ast::Ty,
body: ast::Block) -> @ast::item; body: ast::Block) -> @ast::item;
fn variant(&self, span: Span, name: ident, tys: ~[ast::Ty]) -> ast::variant; fn variant(&self, span: Span, name: Ident, tys: ~[ast::Ty]) -> ast::variant;
fn item_enum_poly(&self, fn item_enum_poly(&self,
span: Span, span: Span,
name: ident, name: Ident,
enum_definition: ast::enum_def, enum_definition: ast::enum_def,
generics: Generics) -> @ast::item; generics: Generics) -> @ast::item;
fn item_enum(&self, span: Span, name: ident, enum_def: ast::enum_def) -> @ast::item; fn item_enum(&self, span: Span, name: Ident, enum_def: ast::enum_def) -> @ast::item;
fn item_struct_poly(&self, fn item_struct_poly(&self,
span: Span, span: Span,
name: ident, name: Ident,
struct_def: ast::struct_def, struct_def: ast::struct_def,
generics: Generics) -> @ast::item; generics: Generics) -> @ast::item;
fn item_struct(&self, span: Span, name: ident, struct_def: ast::struct_def) -> @ast::item; fn item_struct(&self, span: Span, name: Ident, struct_def: ast::struct_def) -> @ast::item;
fn item_mod(&self, span: Span, fn item_mod(&self, span: Span,
name: ident, attrs: ~[ast::Attribute], name: Ident, attrs: ~[ast::Attribute],
vi: ~[ast::view_item], items: ~[@ast::item]) -> @ast::item; vi: ~[ast::view_item], items: ~[@ast::item]) -> @ast::item;
fn item_ty_poly(&self, fn item_ty_poly(&self,
span: Span, span: Span,
name: ident, name: Ident,
ty: ast::Ty, ty: ast::Ty,
generics: Generics) -> @ast::item; generics: Generics) -> @ast::item;
fn item_ty(&self, span: Span, name: ident, ty: ast::Ty) -> @ast::item; fn item_ty(&self, span: Span, name: Ident, ty: ast::Ty) -> @ast::item;
fn attribute(&self, sp: Span, mi: @ast::MetaItem) -> ast::Attribute; fn attribute(&self, sp: Span, mi: @ast::MetaItem) -> ast::Attribute;
@ -225,25 +225,25 @@ pub trait AstBuilder {
fn view_use(&self, sp: Span, fn view_use(&self, sp: Span,
vis: ast::visibility, vp: ~[@ast::view_path]) -> ast::view_item; vis: ast::visibility, vp: ~[@ast::view_path]) -> ast::view_item;
fn view_use_list(&self, sp: Span, vis: ast::visibility, fn view_use_list(&self, sp: Span, vis: ast::visibility,
path: ~[ast::ident], imports: &[ast::ident]) -> ast::view_item; path: ~[ast::Ident], imports: &[ast::Ident]) -> ast::view_item;
fn view_use_glob(&self, sp: Span, fn view_use_glob(&self, sp: Span,
vis: ast::visibility, path: ~[ast::ident]) -> ast::view_item; vis: ast::visibility, path: ~[ast::Ident]) -> ast::view_item;
} }
impl AstBuilder for @ExtCtxt { impl AstBuilder for @ExtCtxt {
fn path(&self, span: Span, strs: ~[ast::ident]) -> ast::Path { fn path(&self, span: Span, strs: ~[ast::Ident]) -> ast::Path {
self.path_all(span, false, strs, None, ~[]) self.path_all(span, false, strs, None, ~[])
} }
fn path_ident(&self, span: Span, id: ast::ident) -> ast::Path { fn path_ident(&self, span: Span, id: ast::Ident) -> ast::Path {
self.path(span, ~[id]) self.path(span, ~[id])
} }
fn path_global(&self, span: Span, strs: ~[ast::ident]) -> ast::Path { fn path_global(&self, span: Span, strs: ~[ast::Ident]) -> ast::Path {
self.path_all(span, true, strs, None, ~[]) self.path_all(span, true, strs, None, ~[])
} }
fn path_all(&self, fn path_all(&self,
sp: Span, sp: Span,
global: bool, global: bool,
mut idents: ~[ast::ident], mut idents: ~[ast::Ident],
rp: Option<ast::Lifetime>, rp: Option<ast::Lifetime>,
types: ~[ast::Ty]) types: ~[ast::Ty])
-> ast::Path { -> ast::Path {
@ -291,7 +291,7 @@ impl AstBuilder for @ExtCtxt {
// Might need to take bounds as an argument in the future, if you ever want // Might need to take bounds as an argument in the future, if you ever want
// to generate a bounded existential trait type. // to generate a bounded existential trait type.
fn ty_ident(&self, span: Span, ident: ast::ident) fn ty_ident(&self, span: Span, ident: ast::Ident)
-> ast::Ty { -> ast::Ty {
self.ty_path(self.path_ident(span, ident), None) self.ty_path(self.path_ident(span, ident), None)
} }
@ -326,7 +326,7 @@ impl AstBuilder for @ExtCtxt {
~[ ty ]), None) ~[ ty ]), None)
} }
fn ty_field_imm(&self, span: Span, name: ident, ty: ast::Ty) -> ast::TypeField { fn ty_field_imm(&self, span: Span, name: Ident, ty: ast::Ty) -> ast::TypeField {
ast::TypeField { ast::TypeField {
ident: name, ident: name,
mt: ast::mt { ty: ~ty, mutbl: ast::m_imm }, mt: ast::mt { ty: ~ty, mutbl: ast::m_imm },
@ -346,7 +346,7 @@ impl AstBuilder for @ExtCtxt {
} }
} }
fn typaram(&self, id: ast::ident, bounds: OptVec<ast::TyParamBound>) -> ast::TyParam { fn typaram(&self, id: ast::Ident, bounds: OptVec<ast::TyParamBound>) -> ast::TyParam {
ast::TyParam { ident: id, id: self.next_id(), bounds: bounds } ast::TyParam { ident: id, id: self.next_id(), bounds: bounds }
} }
@ -385,7 +385,7 @@ impl AstBuilder for @ExtCtxt {
ast::TraitTyParamBound(self.trait_ref(path)) ast::TraitTyParamBound(self.trait_ref(path))
} }
fn lifetime(&self, span: Span, ident: ast::ident) -> ast::Lifetime { fn lifetime(&self, span: Span, ident: ast::Ident) -> ast::Lifetime {
ast::Lifetime { id: self.next_id(), span: span, ident: ident } ast::Lifetime { id: self.next_id(), span: span, ident: ident }
} }
@ -393,7 +393,7 @@ impl AstBuilder for @ExtCtxt {
@respan(expr.span, ast::stmt_semi(expr, self.next_id())) @respan(expr.span, ast::stmt_semi(expr, self.next_id()))
} }
fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::ident, ex: @ast::expr) -> @ast::stmt { fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident, ex: @ast::expr) -> @ast::stmt {
let pat = self.pat_ident(sp, ident); let pat = self.pat_ident(sp, ident);
let local = @ast::Local { let local = @ast::Local {
is_mutbl: mutbl, is_mutbl: mutbl,
@ -410,7 +410,7 @@ impl AstBuilder for @ExtCtxt {
fn stmt_let_typed(&self, fn stmt_let_typed(&self,
sp: Span, sp: Span,
mutbl: bool, mutbl: bool,
ident: ast::ident, ident: ast::Ident,
typ: ast::Ty, typ: ast::Ty,
ex: @ast::expr) ex: @ast::expr)
-> @ast::stmt { -> @ast::stmt {
@ -461,7 +461,7 @@ impl AstBuilder for @ExtCtxt {
self.expr(path.span, ast::expr_path(path)) self.expr(path.span, ast::expr_path(path))
} }
fn expr_ident(&self, span: Span, id: ast::ident) -> @ast::expr { fn expr_ident(&self, span: Span, id: ast::Ident) -> @ast::expr {
self.expr_path(self.path_ident(span, id)) self.expr_path(self.path_ident(span, id))
} }
fn expr_self(&self, span: Span) -> @ast::expr { fn expr_self(&self, span: Span) -> @ast::expr {
@ -485,7 +485,7 @@ impl AstBuilder for @ExtCtxt {
self.expr_unary(sp, ast::box(ast::m_imm), e) self.expr_unary(sp, ast::box(ast::m_imm), e)
} }
fn expr_field_access(&self, sp: Span, expr: @ast::expr, ident: ast::ident) -> @ast::expr { fn expr_field_access(&self, sp: Span, expr: @ast::expr, ident: ast::Ident) -> @ast::expr {
self.expr(sp, ast::expr_field(expr, ident, ~[])) self.expr(sp, ast::expr_field(expr, ident, ~[]))
} }
fn expr_addr_of(&self, sp: Span, e: @ast::expr) -> @ast::expr { fn expr_addr_of(&self, sp: Span, e: @ast::expr) -> @ast::expr {
@ -498,18 +498,18 @@ impl AstBuilder for @ExtCtxt {
fn expr_call(&self, span: Span, expr: @ast::expr, args: ~[@ast::expr]) -> @ast::expr { fn expr_call(&self, span: Span, expr: @ast::expr, args: ~[@ast::expr]) -> @ast::expr {
self.expr(span, ast::expr_call(expr, args, ast::NoSugar)) self.expr(span, ast::expr_call(expr, args, ast::NoSugar))
} }
fn expr_call_ident(&self, span: Span, id: ast::ident, args: ~[@ast::expr]) -> @ast::expr { fn expr_call_ident(&self, span: Span, id: ast::Ident, args: ~[@ast::expr]) -> @ast::expr {
self.expr(span, self.expr(span,
ast::expr_call(self.expr_ident(span, id), args, ast::NoSugar)) ast::expr_call(self.expr_ident(span, id), args, ast::NoSugar))
} }
fn expr_call_global(&self, sp: Span, fn_path: ~[ast::ident], fn expr_call_global(&self, sp: Span, fn_path: ~[ast::Ident],
args: ~[@ast::expr]) -> @ast::expr { args: ~[@ast::expr]) -> @ast::expr {
let pathexpr = self.expr_path(self.path_global(sp, fn_path)); let pathexpr = self.expr_path(self.path_global(sp, fn_path));
self.expr_call(sp, pathexpr, args) self.expr_call(sp, pathexpr, args)
} }
fn expr_method_call(&self, span: Span, fn expr_method_call(&self, span: Span,
expr: @ast::expr, expr: @ast::expr,
ident: ast::ident, ident: ast::Ident,
args: ~[@ast::expr]) -> @ast::expr { args: ~[@ast::expr]) -> @ast::expr {
self.expr(span, self.expr(span,
ast::expr_method_call(self.next_id(), expr, ident, ~[], args, ast::NoSugar)) ast::expr_method_call(self.next_id(), expr, ident, ~[], args, ast::NoSugar))
@ -517,14 +517,14 @@ impl AstBuilder for @ExtCtxt {
fn expr_block(&self, b: ast::Block) -> @ast::expr { fn expr_block(&self, b: ast::Block) -> @ast::expr {
self.expr(b.span, ast::expr_block(b)) self.expr(b.span, ast::expr_block(b))
} }
fn field_imm(&self, span: Span, name: ident, e: @ast::expr) -> ast::Field { fn field_imm(&self, span: Span, name: Ident, e: @ast::expr) -> ast::Field {
ast::Field { ident: name, expr: e, span: span } ast::Field { ident: name, expr: e, span: span }
} }
fn expr_struct(&self, span: Span, path: ast::Path, fields: ~[ast::Field]) -> @ast::expr { fn expr_struct(&self, span: Span, path: ast::Path, fields: ~[ast::Field]) -> @ast::expr {
self.expr(span, ast::expr_struct(path, fields, None)) self.expr(span, ast::expr_struct(path, fields, None))
} }
fn expr_struct_ident(&self, span: Span, fn expr_struct_ident(&self, span: Span,
id: ast::ident, fields: ~[ast::Field]) -> @ast::expr { id: ast::Ident, fields: ~[ast::Field]) -> @ast::expr {
self.expr_struct(span, self.path_ident(span, id), fields) self.expr_struct(span, self.path_ident(span, id), fields)
} }
@ -591,13 +591,13 @@ impl AstBuilder for @ExtCtxt {
fn pat_lit(&self, span: Span, expr: @ast::expr) -> @ast::pat { fn pat_lit(&self, span: Span, expr: @ast::expr) -> @ast::pat {
self.pat(span, ast::pat_lit(expr)) self.pat(span, ast::pat_lit(expr))
} }
fn pat_ident(&self, span: Span, ident: ast::ident) -> @ast::pat { fn pat_ident(&self, span: Span, ident: ast::Ident) -> @ast::pat {
self.pat_ident_binding_mode(span, ident, ast::bind_infer) self.pat_ident_binding_mode(span, ident, ast::bind_infer)
} }
fn pat_ident_binding_mode(&self, fn pat_ident_binding_mode(&self,
span: Span, span: Span,
ident: ast::ident, ident: ast::Ident,
bm: ast::binding_mode) -> @ast::pat { bm: ast::binding_mode) -> @ast::pat {
let path = self.path_ident(span, ident); let path = self.path_ident(span, ident);
let pat = ast::pat_ident(bm, path, None); let pat = ast::pat_ident(bm, path, None);
@ -638,7 +638,7 @@ impl AstBuilder for @ExtCtxt {
fn lambda_fn_decl(&self, span: Span, fn_decl: ast::fn_decl, blk: ast::Block) -> @ast::expr { fn lambda_fn_decl(&self, span: Span, fn_decl: ast::fn_decl, blk: ast::Block) -> @ast::expr {
self.expr(span, ast::expr_fn_block(fn_decl, blk)) self.expr(span, ast::expr_fn_block(fn_decl, blk))
} }
fn lambda(&self, span: Span, ids: ~[ast::ident], blk: ast::Block) -> @ast::expr { fn lambda(&self, span: Span, ids: ~[ast::Ident], blk: ast::Block) -> @ast::expr {
let fn_decl = self.fn_decl( let fn_decl = self.fn_decl(
ids.map(|id| self.arg(span, *id, self.ty_infer(span))), ids.map(|id| self.arg(span, *id, self.ty_infer(span))),
self.ty_infer(span)); self.ty_infer(span));
@ -658,38 +658,38 @@ impl AstBuilder for @ExtCtxt {
} }
#[cfg(stage0)] #[cfg(stage0)]
fn lambda1(&self, _span: Span, blk: ast::Block, ident: ast::ident) -> @ast::expr { fn lambda1(&self, _span: Span, blk: ast::Block, ident: ast::Ident) -> @ast::expr {
let ext_cx = *self; let ext_cx = *self;
let blk_e = self.expr(blk.span, ast::expr_block(blk.clone())); let blk_e = self.expr(blk.span, ast::expr_block(blk.clone()));
quote_expr!(|$ident| $blk_e ) quote_expr!(|$ident| $blk_e )
} }
#[cfg(not(stage0))] #[cfg(not(stage0))]
fn lambda1(&self, _span: Span, blk: ast::Block, ident: ast::ident) -> @ast::expr { fn lambda1(&self, _span: Span, blk: ast::Block, ident: ast::Ident) -> @ast::expr {
let blk_e = self.expr(blk.span, ast::expr_block(blk.clone())); let blk_e = self.expr(blk.span, ast::expr_block(blk.clone()));
quote_expr!(*self, |$ident| $blk_e ) quote_expr!(*self, |$ident| $blk_e )
} }
fn lambda_expr(&self, span: Span, ids: ~[ast::ident], expr: @ast::expr) -> @ast::expr { fn lambda_expr(&self, span: Span, ids: ~[ast::Ident], expr: @ast::expr) -> @ast::expr {
self.lambda(span, ids, self.block_expr(expr)) self.lambda(span, ids, self.block_expr(expr))
} }
fn lambda_expr_0(&self, span: Span, expr: @ast::expr) -> @ast::expr { fn lambda_expr_0(&self, span: Span, expr: @ast::expr) -> @ast::expr {
self.lambda0(span, self.block_expr(expr)) self.lambda0(span, self.block_expr(expr))
} }
fn lambda_expr_1(&self, span: Span, expr: @ast::expr, ident: ast::ident) -> @ast::expr { fn lambda_expr_1(&self, span: Span, expr: @ast::expr, ident: ast::Ident) -> @ast::expr {
self.lambda1(span, self.block_expr(expr), ident) self.lambda1(span, self.block_expr(expr), ident)
} }
fn lambda_stmts(&self, span: Span, ids: ~[ast::ident], stmts: ~[@ast::stmt]) -> @ast::expr { fn lambda_stmts(&self, span: Span, ids: ~[ast::Ident], stmts: ~[@ast::stmt]) -> @ast::expr {
self.lambda(span, ids, self.block(span, stmts, None)) self.lambda(span, ids, self.block(span, stmts, None))
} }
fn lambda_stmts_0(&self, span: Span, stmts: ~[@ast::stmt]) -> @ast::expr { fn lambda_stmts_0(&self, span: Span, stmts: ~[@ast::stmt]) -> @ast::expr {
self.lambda0(span, self.block(span, stmts, None)) self.lambda0(span, self.block(span, stmts, None))
} }
fn lambda_stmts_1(&self, span: Span, stmts: ~[@ast::stmt], ident: ast::ident) -> @ast::expr { fn lambda_stmts_1(&self, span: Span, stmts: ~[@ast::stmt], ident: ast::Ident) -> @ast::expr {
self.lambda1(span, self.block(span, stmts, None), ident) self.lambda1(span, self.block(span, stmts, None), ident)
} }
fn arg(&self, span: Span, ident: ast::ident, ty: ast::Ty) -> ast::arg { fn arg(&self, span: Span, ident: ast::Ident, ty: ast::Ty) -> ast::arg {
let arg_pat = self.pat_ident(span, ident); let arg_pat = self.pat_ident(span, ident);
ast::arg { ast::arg {
is_mutbl: false, is_mutbl: false,
@ -709,7 +709,7 @@ impl AstBuilder for @ExtCtxt {
} }
fn item(&self, span: Span, fn item(&self, span: Span,
name: ident, attrs: ~[ast::Attribute], node: ast::item_) -> @ast::item { name: Ident, attrs: ~[ast::Attribute], node: ast::item_) -> @ast::item {
// XXX: Would be nice if our generated code didn't violate // XXX: Would be nice if our generated code didn't violate
// Rust coding conventions // Rust coding conventions
@ast::item { ident: name, @ast::item { ident: name,
@ -722,7 +722,7 @@ impl AstBuilder for @ExtCtxt {
fn item_fn_poly(&self, fn item_fn_poly(&self,
span: Span, span: Span,
name: ident, name: Ident,
inputs: ~[ast::arg], inputs: ~[ast::arg],
output: ast::Ty, output: ast::Ty,
generics: Generics, generics: Generics,
@ -739,7 +739,7 @@ impl AstBuilder for @ExtCtxt {
fn item_fn(&self, fn item_fn(&self,
span: Span, span: Span,
name: ident, name: Ident,
inputs: ~[ast::arg], inputs: ~[ast::arg],
output: ast::Ty, output: ast::Ty,
body: ast::Block body: ast::Block
@ -753,7 +753,7 @@ impl AstBuilder for @ExtCtxt {
body) body)
} }
fn variant(&self, span: Span, name: ident, tys: ~[ast::Ty]) -> ast::variant { fn variant(&self, span: Span, name: Ident, tys: ~[ast::Ty]) -> ast::variant {
let args = tys.move_iter().map(|ty| { let args = tys.move_iter().map(|ty| {
ast::variant_arg { ty: ty, id: self.next_id() } ast::variant_arg { ty: ty, id: self.next_id() }
}).collect(); }).collect();
@ -769,13 +769,13 @@ impl AstBuilder for @ExtCtxt {
}) })
} }
fn item_enum_poly(&self, span: Span, name: ident, fn item_enum_poly(&self, span: Span, name: Ident,
enum_definition: ast::enum_def, enum_definition: ast::enum_def,
generics: Generics) -> @ast::item { generics: Generics) -> @ast::item {
self.item(span, name, ~[], ast::item_enum(enum_definition, generics)) self.item(span, name, ~[], ast::item_enum(enum_definition, generics))
} }
fn item_enum(&self, span: Span, name: ident, fn item_enum(&self, span: Span, name: Ident,
enum_definition: ast::enum_def) -> @ast::item { enum_definition: ast::enum_def) -> @ast::item {
self.item_enum_poly(span, name, enum_definition, self.item_enum_poly(span, name, enum_definition,
ast_util::empty_generics()) ast_util::empty_generics())
@ -784,7 +784,7 @@ impl AstBuilder for @ExtCtxt {
fn item_struct( fn item_struct(
&self, &self,
span: Span, span: Span,
name: ident, name: Ident,
struct_def: ast::struct_def struct_def: ast::struct_def
) -> @ast::item { ) -> @ast::item {
self.item_struct_poly( self.item_struct_poly(
@ -798,14 +798,14 @@ impl AstBuilder for @ExtCtxt {
fn item_struct_poly( fn item_struct_poly(
&self, &self,
span: Span, span: Span,
name: ident, name: Ident,
struct_def: ast::struct_def, struct_def: ast::struct_def,
generics: Generics generics: Generics
) -> @ast::item { ) -> @ast::item {
self.item(span, name, ~[], ast::item_struct(@struct_def, generics)) self.item(span, name, ~[], ast::item_struct(@struct_def, generics))
} }
fn item_mod(&self, span: Span, name: ident, fn item_mod(&self, span: Span, name: Ident,
attrs: ~[ast::Attribute], attrs: ~[ast::Attribute],
vi: ~[ast::view_item], vi: ~[ast::view_item],
items: ~[@ast::item]) -> @ast::item { items: ~[@ast::item]) -> @ast::item {
@ -820,12 +820,12 @@ impl AstBuilder for @ExtCtxt {
) )
} }
fn item_ty_poly(&self, span: Span, name: ident, ty: ast::Ty, fn item_ty_poly(&self, span: Span, name: Ident, ty: ast::Ty,
generics: Generics) -> @ast::item { generics: Generics) -> @ast::item {
self.item(span, name, ~[], ast::item_ty(ty, generics)) self.item(span, name, ~[], ast::item_ty(ty, generics))
} }
fn item_ty(&self, span: Span, name: ident, ty: ast::Ty) -> @ast::item { fn item_ty(&self, span: Span, name: Ident, ty: ast::Ty) -> @ast::item {
self.item_ty_poly(span, name, ty, ast_util::empty_generics()) self.item_ty_poly(span, name, ty, ast_util::empty_generics())
} }
@ -858,7 +858,7 @@ impl AstBuilder for @ExtCtxt {
} }
fn view_use_list(&self, sp: Span, vis: ast::visibility, fn view_use_list(&self, sp: Span, vis: ast::visibility,
path: ~[ast::ident], imports: &[ast::ident]) -> ast::view_item { path: ~[ast::Ident], imports: &[ast::Ident]) -> ast::view_item {
let imports = do imports.map |id| { let imports = do imports.map |id| {
respan(sp, ast::path_list_ident_ { name: *id, id: self.next_id() }) respan(sp, ast::path_list_ident_ { name: *id, id: self.next_id() })
}; };
@ -871,7 +871,7 @@ impl AstBuilder for @ExtCtxt {
} }
fn view_use_glob(&self, sp: Span, fn view_use_glob(&self, sp: Span,
vis: ast::visibility, path: ~[ast::ident]) -> ast::view_item { vis: ast::visibility, path: ~[ast::Ident]) -> ast::view_item {
self.view_use(sp, vis, self.view_use(sp, vis,
~[@respan(sp, ~[@respan(sp,
ast::view_path_glob(self.path(sp, path), self.next_id()))]) ast::view_path_glob(self.path(sp, path), self.next_id()))])

View file

@ -163,7 +163,7 @@ StaticEnum(<ast::enum_def of C>, ~[(<ident of C0>, Left(1)),
*/ */
use ast; use ast;
use ast::{enum_def, expr, ident, Generics, struct_def}; use ast::{enum_def, expr, Ident, Generics, struct_def};
use ext::base::ExtCtxt; use ext::base::ExtCtxt;
use ext::build::AstBuilder; use ext::build::AstBuilder;
@ -216,9 +216,9 @@ pub struct MethodDef<'self> {
/// All the data about the data structure/method being derived upon. /// All the data about the data structure/method being derived upon.
pub struct Substructure<'self> { pub struct Substructure<'self> {
/// ident of self /// ident of self
type_ident: ident, type_ident: Ident,
/// ident of the method /// ident of the method
method_ident: ident, method_ident: Ident,
/// dereferenced access to any Self or Ptr(Self, _) arguments /// dereferenced access to any Self or Ptr(Self, _) arguments
self_args: &'self [@expr], self_args: &'self [@expr],
/// verbatim access to any other arguments /// verbatim access to any other arguments
@ -234,26 +234,26 @@ pub enum SubstructureFields<'self> {
ident is the ident of the current field (`None` for all fields in tuple ident is the ident of the current field (`None` for all fields in tuple
structs). structs).
*/ */
Struct(~[(Option<ident>, @expr, ~[@expr])]), Struct(~[(Option<Ident>, @expr, ~[@expr])]),
/** /**
Matching variants of the enum: variant index, ast::variant, Matching variants of the enum: variant index, ast::variant,
fields: `(field ident, self, [others])`, where the field ident is fields: `(field ident, self, [others])`, where the field ident is
only non-`None` in the case of a struct variant. only non-`None` in the case of a struct variant.
*/ */
EnumMatching(uint, &'self ast::variant, ~[(Option<ident>, @expr, ~[@expr])]), EnumMatching(uint, &'self ast::variant, ~[(Option<Ident>, @expr, ~[@expr])]),
/** /**
non-matching variants of the enum, [(variant index, ast::variant, non-matching variants of the enum, [(variant index, ast::variant,
[field ident, fields])] (i.e. all fields for self are in the [field ident, fields])] (i.e. all fields for self are in the
first tuple, for other1 are in the second tuple, etc.) first tuple, for other1 are in the second tuple, etc.)
*/ */
EnumNonMatching(&'self [(uint, ast::variant, ~[(Option<ident>, @expr)])]), EnumNonMatching(&'self [(uint, ast::variant, ~[(Option<Ident>, @expr)])]),
/// A static method where Self is a struct /// A static method where Self is a struct
StaticStruct(&'self ast::struct_def, Either<uint, ~[ident]>), StaticStruct(&'self ast::struct_def, Either<uint, ~[Ident]>),
/// A static method where Self is an enum /// A static method where Self is an enum
StaticEnum(&'self ast::enum_def, ~[(ident, Either<uint, ~[ident]>)]) StaticEnum(&'self ast::enum_def, ~[(Ident, Either<uint, ~[Ident]>)])
} }
@ -273,7 +273,7 @@ representing each variant: (variant index, ast::variant instance,
pub type EnumNonMatchFunc<'self> = pub type EnumNonMatchFunc<'self> =
&'self fn(@ExtCtxt, Span, &'self fn(@ExtCtxt, Span,
&[(uint, ast::variant, &[(uint, ast::variant,
~[(Option<ident>, @expr)])], ~[(Option<Ident>, @expr)])],
&[@expr]) -> @expr; &[@expr]) -> @expr;
@ -315,7 +315,7 @@ impl<'self> TraitDef<'self> {
* *
*/ */
fn create_derived_impl(&self, cx: @ExtCtxt, span: Span, fn create_derived_impl(&self, cx: @ExtCtxt, span: Span,
type_ident: ident, generics: &Generics, type_ident: Ident, generics: &Generics,
methods: ~[@ast::method]) -> @ast::item { methods: ~[@ast::method]) -> @ast::item {
let trait_path = self.path.to_path(cx, span, type_ident, generics); let trait_path = self.path.to_path(cx, span, type_ident, generics);
@ -375,7 +375,7 @@ impl<'self> TraitDef<'self> {
fn expand_struct_def(&self, cx: @ExtCtxt, fn expand_struct_def(&self, cx: @ExtCtxt,
span: Span, span: Span,
struct_def: &struct_def, struct_def: &struct_def,
type_ident: ident, type_ident: Ident,
generics: &Generics) -> @ast::item { generics: &Generics) -> @ast::item {
let methods = do self.methods.map |method_def| { let methods = do self.methods.map |method_def| {
let (explicit_self, self_args, nonself_args, tys) = let (explicit_self, self_args, nonself_args, tys) =
@ -406,7 +406,7 @@ impl<'self> TraitDef<'self> {
fn expand_enum_def(&self, fn expand_enum_def(&self,
cx: @ExtCtxt, span: Span, cx: @ExtCtxt, span: Span,
enum_def: &enum_def, enum_def: &enum_def,
type_ident: ident, type_ident: Ident,
generics: &Generics) -> @ast::item { generics: &Generics) -> @ast::item {
let methods = do self.methods.map |method_def| { let methods = do self.methods.map |method_def| {
let (explicit_self, self_args, nonself_args, tys) = let (explicit_self, self_args, nonself_args, tys) =
@ -439,7 +439,7 @@ impl<'self> MethodDef<'self> {
fn call_substructure_method(&self, fn call_substructure_method(&self,
cx: @ExtCtxt, cx: @ExtCtxt,
span: Span, span: Span,
type_ident: ident, type_ident: Ident,
self_args: &[@expr], self_args: &[@expr],
nonself_args: &[@expr], nonself_args: &[@expr],
fields: &SubstructureFields) fields: &SubstructureFields)
@ -456,7 +456,7 @@ impl<'self> MethodDef<'self> {
} }
fn get_ret_ty(&self, cx: @ExtCtxt, span: Span, fn get_ret_ty(&self, cx: @ExtCtxt, span: Span,
generics: &Generics, type_ident: ident) -> ast::Ty { generics: &Generics, type_ident: Ident) -> ast::Ty {
self.ret_ty.to_ty(cx, span, type_ident, generics) self.ret_ty.to_ty(cx, span, type_ident, generics)
} }
@ -465,8 +465,8 @@ impl<'self> MethodDef<'self> {
} }
fn split_self_nonself_args(&self, cx: @ExtCtxt, span: Span, fn split_self_nonself_args(&self, cx: @ExtCtxt, span: Span,
type_ident: ident, generics: &Generics) type_ident: Ident, generics: &Generics)
-> (ast::explicit_self, ~[@expr], ~[@expr], ~[(ident, ast::Ty)]) { -> (ast::explicit_self, ~[@expr], ~[@expr], ~[(Ident, ast::Ty)]) {
let mut self_args = ~[]; let mut self_args = ~[];
let mut nonself_args = ~[]; let mut nonself_args = ~[];
@ -511,10 +511,10 @@ impl<'self> MethodDef<'self> {
} }
fn create_method(&self, cx: @ExtCtxt, span: Span, fn create_method(&self, cx: @ExtCtxt, span: Span,
type_ident: ident, type_ident: Ident,
generics: &Generics, generics: &Generics,
explicit_self: ast::explicit_self, explicit_self: ast::explicit_self,
arg_types: ~[(ident, ast::Ty)], arg_types: ~[(Ident, ast::Ty)],
body: @expr) -> @ast::method { body: @expr) -> @ast::method {
// create the generics that aren't for Self // create the generics that aren't for Self
let fn_generics = self.generics.to_generics(cx, span, type_ident, generics); let fn_generics = self.generics.to_generics(cx, span, type_ident, generics);
@ -571,7 +571,7 @@ impl<'self> MethodDef<'self> {
cx: @ExtCtxt, cx: @ExtCtxt,
span: Span, span: Span,
struct_def: &struct_def, struct_def: &struct_def,
type_ident: ident, type_ident: Ident,
self_args: &[@expr], self_args: &[@expr],
nonself_args: &[@expr]) nonself_args: &[@expr])
-> @expr { -> @expr {
@ -625,7 +625,7 @@ impl<'self> MethodDef<'self> {
cx: @ExtCtxt, cx: @ExtCtxt,
span: Span, span: Span,
struct_def: &struct_def, struct_def: &struct_def,
type_ident: ident, type_ident: Ident,
self_args: &[@expr], self_args: &[@expr],
nonself_args: &[@expr]) nonself_args: &[@expr])
-> @expr { -> @expr {
@ -667,7 +667,7 @@ impl<'self> MethodDef<'self> {
cx: @ExtCtxt, cx: @ExtCtxt,
span: Span, span: Span,
enum_def: &enum_def, enum_def: &enum_def,
type_ident: ident, type_ident: Ident,
self_args: &[@expr], self_args: &[@expr],
nonself_args: &[@expr]) nonself_args: &[@expr])
-> @expr { -> @expr {
@ -702,12 +702,12 @@ impl<'self> MethodDef<'self> {
fn build_enum_match(&self, fn build_enum_match(&self,
cx: @ExtCtxt, span: Span, cx: @ExtCtxt, span: Span,
enum_def: &enum_def, enum_def: &enum_def,
type_ident: ident, type_ident: Ident,
self_args: &[@expr], self_args: &[@expr],
nonself_args: &[@expr], nonself_args: &[@expr],
matching: Option<uint>, matching: Option<uint>,
matches_so_far: &mut ~[(uint, ast::variant, matches_so_far: &mut ~[(uint, ast::variant,
~[(Option<ident>, @expr)])], ~[(Option<Ident>, @expr)])],
match_count: uint) -> @expr { match_count: uint) -> @expr {
if match_count == self_args.len() { if match_count == self_args.len() {
// we've matched against all arguments, so make the final // we've matched against all arguments, so make the final
@ -852,7 +852,7 @@ impl<'self> MethodDef<'self> {
cx: @ExtCtxt, cx: @ExtCtxt,
span: Span, span: Span,
enum_def: &enum_def, enum_def: &enum_def,
type_ident: ident, type_ident: Ident,
self_args: &[@expr], self_args: &[@expr],
nonself_args: &[@expr]) nonself_args: &[@expr])
-> @expr { -> @expr {
@ -874,7 +874,7 @@ impl<'self> MethodDef<'self> {
} }
fn summarise_struct(cx: @ExtCtxt, span: Span, fn summarise_struct(cx: @ExtCtxt, span: Span,
struct_def: &struct_def) -> Either<uint, ~[ident]> { struct_def: &struct_def) -> Either<uint, ~[Ident]> {
let mut named_idents = ~[]; let mut named_idents = ~[];
let mut unnamed_count = 0; let mut unnamed_count = 0;
for field in struct_def.fields.iter() { for field in struct_def.fields.iter() {
@ -913,11 +913,11 @@ enum StructType {
fn create_struct_pattern(cx: @ExtCtxt, fn create_struct_pattern(cx: @ExtCtxt,
span: Span, span: Span,
struct_ident: ident, struct_ident: Ident,
struct_def: &struct_def, struct_def: &struct_def,
prefix: &str, prefix: &str,
mutbl: ast::mutability) mutbl: ast::mutability)
-> (@ast::pat, ~[(Option<ident>, @expr)]) { -> (@ast::pat, ~[(Option<Ident>, @expr)]) {
if struct_def.fields.is_empty() { if struct_def.fields.is_empty() {
return ( return (
cx.pat_ident_binding_mode( cx.pat_ident_binding_mode(
@ -977,7 +977,7 @@ fn create_enum_variant_pattern(cx: @ExtCtxt,
variant: &ast::variant, variant: &ast::variant,
prefix: &str, prefix: &str,
mutbl: ast::mutability) mutbl: ast::mutability)
-> (@ast::pat, ~[(Option<ident>, @expr)]) { -> (@ast::pat, ~[(Option<Ident>, @expr)]) {
let variant_ident = variant.node.name; let variant_ident = variant.node.name;
match variant.node.kind { match variant.node.kind {

View file

@ -18,7 +18,7 @@ library.
*/ */
use ast::{enum_def, ident, item, Generics, struct_def}; use ast::{enum_def, Ident, item, Generics, struct_def};
use ast::{MetaItem, MetaList, MetaNameValue, MetaWord}; use ast::{MetaItem, MetaList, MetaNameValue, MetaWord};
use ext::base::ExtCtxt; use ext::base::ExtCtxt;
use ext::build::AstBuilder; use ext::build::AstBuilder;
@ -47,13 +47,13 @@ pub mod generic;
pub type ExpandDerivingStructDefFn<'self> = &'self fn(@ExtCtxt, pub type ExpandDerivingStructDefFn<'self> = &'self fn(@ExtCtxt,
Span, Span,
x: &struct_def, x: &struct_def,
ident, Ident,
y: &Generics) y: &Generics)
-> @item; -> @item;
pub type ExpandDerivingEnumDefFn<'self> = &'self fn(@ExtCtxt, pub type ExpandDerivingEnumDefFn<'self> = &'self fn(@ExtCtxt,
Span, Span,
x: &enum_def, x: &enum_def,
ident, Ident,
y: &Generics) y: &Generics)
-> @item; -> @item;

View file

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
use ast; use ast;
use ast::{MetaItem, item, expr, ident}; use ast::{MetaItem, item, expr, Ident};
use codemap::Span; use codemap::Span;
use ext::base::ExtCtxt; use ext::base::ExtCtxt;
use ext::build::{AstBuilder, Duplicate}; use ext::build::{AstBuilder, Duplicate};
@ -129,8 +129,8 @@ fn rand_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @expr {
}; };
fn rand_thing(cx: @ExtCtxt, span: Span, fn rand_thing(cx: @ExtCtxt, span: Span,
ctor_ident: ident, ctor_ident: Ident,
summary: &Either<uint, ~[ident]>, summary: &Either<uint, ~[Ident]>,
rand_call: &fn() -> @expr) -> @expr { rand_call: &fn() -> @expr) -> @expr {
match *summary { match *summary {
Left(count) => { Left(count) => {

View file

@ -47,8 +47,8 @@ fn to_str_substructure(cx: @ExtCtxt, span: Span,
substr: &Substructure) -> @expr { substr: &Substructure) -> @expr {
let to_str = cx.ident_of("to_str"); let to_str = cx.ident_of("to_str");
let doit = |start: &str, end: @str, name: ast::ident, let doit = |start: &str, end: @str, name: ast::Ident,
fields: &[(Option<ast::ident>, @expr, ~[@expr])]| { fields: &[(Option<ast::Ident>, @expr, ~[@expr])]| {
if fields.len() == 0 { if fields.len() == 0 {
cx.expr_str_uniq(span, cx.str_of(name)) cx.expr_str_uniq(span, cx.str_of(name))
} else { } else {

View file

@ -14,7 +14,7 @@ explicit `Self` type to use when specifying impls to be derived.
*/ */
use ast; use ast;
use ast::{expr,Generics,ident}; use ast::{expr,Generics,Ident};
use ext::base::ExtCtxt; use ext::base::ExtCtxt;
use ext::build::AstBuilder; use ext::build::AstBuilder;
use codemap::{Span,respan}; use codemap::{Span,respan};
@ -59,7 +59,7 @@ impl<'self> Path<'self> {
pub fn to_ty(&self, pub fn to_ty(&self,
cx: @ExtCtxt, cx: @ExtCtxt,
span: Span, span: Span,
self_ty: ident, self_ty: Ident,
self_generics: &Generics) self_generics: &Generics)
-> ast::Ty { -> ast::Ty {
cx.ty_path(self.to_path(cx, span, self_ty, self_generics), None) cx.ty_path(self.to_path(cx, span, self_ty, self_generics), None)
@ -67,7 +67,7 @@ impl<'self> Path<'self> {
pub fn to_path(&self, pub fn to_path(&self,
cx: @ExtCtxt, cx: @ExtCtxt,
span: Span, span: Span,
self_ty: ident, self_ty: Ident,
self_generics: &Generics) self_generics: &Generics)
-> ast::Path { -> ast::Path {
let idents = self.path.map(|s| cx.ident_of(*s) ); let idents = self.path.map(|s| cx.ident_of(*s) );
@ -120,7 +120,7 @@ impl<'self> Ty<'self> {
pub fn to_ty(&self, pub fn to_ty(&self,
cx: @ExtCtxt, cx: @ExtCtxt,
span: Span, span: Span,
self_ty: ident, self_ty: Ident,
self_generics: &Generics) self_generics: &Generics)
-> ast::Ty { -> ast::Ty {
match *self { match *self {
@ -158,7 +158,7 @@ impl<'self> Ty<'self> {
pub fn to_path(&self, pub fn to_path(&self,
cx: @ExtCtxt, cx: @ExtCtxt,
span: Span, span: Span,
self_ty: ident, self_ty: Ident,
self_generics: &Generics) self_generics: &Generics)
-> ast::Path { -> ast::Path {
match *self { match *self {
@ -186,7 +186,7 @@ impl<'self> Ty<'self> {
fn mk_ty_param(cx: @ExtCtxt, span: Span, name: &str, bounds: &[Path], fn mk_ty_param(cx: @ExtCtxt, span: Span, name: &str, bounds: &[Path],
self_ident: ident, self_generics: &Generics) -> ast::TyParam { self_ident: Ident, self_generics: &Generics) -> ast::TyParam {
let bounds = opt_vec::from( let bounds = opt_vec::from(
do bounds.map |b| { do bounds.map |b| {
let path = b.to_path(cx, span, self_ident, self_generics); let path = b.to_path(cx, span, self_ident, self_generics);
@ -217,7 +217,7 @@ impl<'self> LifetimeBounds<'self> {
pub fn to_generics(&self, pub fn to_generics(&self,
cx: @ExtCtxt, cx: @ExtCtxt,
span: Span, span: Span,
self_ty: ident, self_ty: Ident,
self_generics: &Generics) self_generics: &Generics)
-> Generics { -> Generics {
let lifetimes = do self.lifetimes.map |lt| { let lifetimes = do self.lifetimes.map |lt| {

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use ast::{Block, Crate, NodeId, expr_, expr_mac, ident, mac_invoc_tt}; use ast::{Block, Crate, NodeId, expr_, expr_mac, Ident, mac_invoc_tt};
use ast::{item_mac, stmt_, stmt_mac, stmt_expr, stmt_semi}; use ast::{item_mac, stmt_, stmt_mac, stmt_expr, stmt_semi};
use ast::{illegal_ctxt}; use ast::{illegal_ctxt};
use ast; use ast;
@ -140,7 +140,7 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv,
} }
} }
fn mk_simple_path(ident: ast::ident, span: Span) -> ast::Path { fn mk_simple_path(ident: ast::Ident, span: Span) -> ast::Path {
ast::Path { ast::Path {
span: span, span: span,
global: false, global: false,
@ -523,7 +523,7 @@ pub fn expand_stmt(extsbox: @mut SyntaxEnv,
#[deriving(Clone)] #[deriving(Clone)]
struct NewNameFinderContext { struct NewNameFinderContext {
ident_accumulator: @mut ~[ast::ident], ident_accumulator: @mut ~[ast::Ident],
} }
impl Visitor<()> for NewNameFinderContext { impl Visitor<()> for NewNameFinderContext {
@ -645,7 +645,7 @@ impl Visitor<()> for NewNameFinderContext {
fn visit_struct_def(&mut self, fn visit_struct_def(&mut self,
struct_def: @ast::struct_def, struct_def: @ast::struct_def,
ident: ident, ident: Ident,
generics: &ast::Generics, generics: &ast::Generics,
node_id: NodeId, node_id: NodeId,
_: ()) { _: ()) {
@ -667,7 +667,7 @@ impl Visitor<()> for NewNameFinderContext {
// return a visitor that extracts the pat_ident paths // return a visitor that extracts the pat_ident paths
// from a given pattern and puts them in a mutable // from a given pattern and puts them in a mutable
// array (passed in to the traversal) // array (passed in to the traversal)
pub fn new_name_finder(idents: @mut ~[ast::ident]) -> @mut Visitor<()> { pub fn new_name_finder(idents: @mut ~[ast::Ident]) -> @mut Visitor<()> {
let context = @mut NewNameFinderContext { let context = @mut NewNameFinderContext {
ident_accumulator: idents, ident_accumulator: idents,
}; };
@ -697,7 +697,7 @@ fn get_block_info(exts : SyntaxEnv) -> BlockInfo {
// given a mutable list of renames, return a tree-folder that applies those // given a mutable list of renames, return a tree-folder that applies those
// renames. // renames.
fn renames_to_fold(renames : @mut ~[(ast::ident,ast::Name)]) -> @ast_fold { fn renames_to_fold(renames : @mut ~[(ast::Ident,ast::Name)]) -> @ast_fold {
let afp = default_ast_fold(); let afp = default_ast_fold();
let f_pre = @AstFoldFns { let f_pre = @AstFoldFns {
fold_ident: |id,_| { fold_ident: |id,_| {
@ -706,7 +706,7 @@ fn renames_to_fold(renames : @mut ~[(ast::ident,ast::Name)]) -> @ast_fold {
let new_ctxt = renames.iter().fold(id.ctxt,|ctxt,&(from,to)| { let new_ctxt = renames.iter().fold(id.ctxt,|ctxt,&(from,to)| {
new_rename(from,to,ctxt) new_rename(from,to,ctxt)
}); });
ast::ident{name:id.name,ctxt:new_ctxt} ast::Ident{name:id.name,ctxt:new_ctxt}
}, },
.. *afp .. *afp
}; };
@ -1144,7 +1144,7 @@ pub fn expand_crate(parse_sess: @mut parse::ParseSess,
// given a function from idents to idents, produce // given a function from idents to idents, produce
// an ast_fold that applies that function: // an ast_fold that applies that function:
pub fn fun_to_ident_folder(f: @fn(ast::ident)->ast::ident) -> @ast_fold{ pub fn fun_to_ident_folder(f: @fn(ast::Ident)->ast::Ident) -> @ast_fold{
let afp = default_ast_fold(); let afp = default_ast_fold();
let f_pre = @AstFoldFns{ let f_pre = @AstFoldFns{
fold_ident : |id, _| f(id), fold_ident : |id, _| f(id),
@ -1154,11 +1154,11 @@ pub fn fun_to_ident_folder(f: @fn(ast::ident)->ast::ident) -> @ast_fold{
} }
// update the ctxts in a path to get a rename node // update the ctxts in a path to get a rename node
pub fn new_ident_renamer(from: ast::ident, pub fn new_ident_renamer(from: ast::Ident,
to: ast::Name) -> to: ast::Name) ->
@fn(ast::ident)->ast::ident { @fn(ast::Ident)->ast::Ident {
|id : ast::ident| |id : ast::Ident|
ast::ident{ ast::Ident{
name: id.name, name: id.name,
ctxt: new_rename(from,to,id.ctxt) ctxt: new_rename(from,to,id.ctxt)
} }
@ -1167,9 +1167,9 @@ pub fn new_ident_renamer(from: ast::ident,
// update the ctxts in a path to get a mark node // update the ctxts in a path to get a mark node
pub fn new_ident_marker(mark: uint) -> pub fn new_ident_marker(mark: uint) ->
@fn(ast::ident)->ast::ident { @fn(ast::Ident)->ast::Ident {
|id : ast::ident| |id : ast::Ident|
ast::ident{ ast::Ident{
name: id.name, name: id.name,
ctxt: new_mark(mark,id.ctxt) ctxt: new_mark(mark,id.ctxt)
} }
@ -1178,9 +1178,9 @@ pub fn new_ident_marker(mark: uint) ->
// perform resolution (in the MTWT sense) on all of the // perform resolution (in the MTWT sense) on all of the
// idents in the tree. This is the final step in expansion. // idents in the tree. This is the final step in expansion.
pub fn new_ident_resolver() -> pub fn new_ident_resolver() ->
@fn(ast::ident)->ast::ident { @fn(ast::Ident)->ast::Ident {
|id : ast::ident| |id : ast::Ident|
ast::ident { ast::Ident {
name : resolve(id), name : resolve(id),
ctxt : illegal_ctxt ctxt : illegal_ctxt
} }
@ -1304,7 +1304,7 @@ mod test {
}; };
let a_name = intern("a"); let a_name = intern("a");
let a2_name = intern("a2"); let a2_name = intern("a2");
let renamer = new_ident_renamer(ast::ident{name:a_name,ctxt:empty_ctxt}, let renamer = new_ident_renamer(ast::Ident{name:a_name,ctxt:empty_ctxt},
a2_name); a2_name);
let renamed_ast = fun_to_ident_folder(renamer).fold_item(item_ast).unwrap(); let renamed_ast = fun_to_ident_folder(renamer).fold_item(item_ast).unwrap();
let resolver = new_ident_resolver(); let resolver = new_ident_resolver();

View file

@ -50,7 +50,7 @@ pub fn expand_syntax_ext(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
fn pieces_to_expr(cx: @ExtCtxt, sp: Span, fn pieces_to_expr(cx: @ExtCtxt, sp: Span,
pieces: ~[Piece], args: ~[@ast::expr]) pieces: ~[Piece], args: ~[@ast::expr])
-> @ast::expr { -> @ast::expr {
fn make_path_vec(ident: &str) -> ~[ast::ident] { fn make_path_vec(ident: &str) -> ~[ast::Ident] {
return ~[str_to_ident("std"), return ~[str_to_ident("std"),
str_to_ident("unstable"), str_to_ident("unstable"),
str_to_ident("extfmt"), str_to_ident("extfmt"),

View file

@ -637,7 +637,7 @@ impl Context {
} }
fn format_arg(&self, sp: Span, arg: Either<uint, @str>, fn format_arg(&self, sp: Span, arg: Either<uint, @str>,
ident: ast::ident) -> @ast::expr { ident: ast::Ident) -> @ast::expr {
let ty = match arg { let ty = match arg {
Left(i) => self.arg_types[i].unwrap(), Left(i) => self.arg_types[i].unwrap(),
Right(s) => *self.name_types.get(&s) Right(s) => *self.name_types.get(&s)

View file

@ -68,7 +68,7 @@ pub mod rt {
fn to_source(&self) -> @str; fn to_source(&self) -> @str;
} }
impl ToSource for ast::ident { impl ToSource for ast::Ident {
fn to_source(&self) -> @str { fn to_source(&self) -> @str {
ident_to_str(self) ident_to_str(self)
} }
@ -216,7 +216,7 @@ pub mod rt {
) )
) )
impl_to_tokens!(ast::ident) impl_to_tokens!(ast::Ident)
impl_to_tokens!(@ast::item) impl_to_tokens!(@ast::item)
impl_to_tokens_self!(&'self [@ast::item]) impl_to_tokens_self!(&'self [@ast::item])
impl_to_tokens!(ast::Ty) impl_to_tokens!(ast::Ty)
@ -334,16 +334,16 @@ pub fn expand_quote_stmt(cx: @ExtCtxt,
~[e_attrs], tts)) ~[e_attrs], tts))
} }
fn ids_ext(strs: ~[~str]) -> ~[ast::ident] { fn ids_ext(strs: ~[~str]) -> ~[ast::Ident] {
strs.map(|str| str_to_ident(*str)) strs.map(|str| str_to_ident(*str))
} }
fn id_ext(str: &str) -> ast::ident { fn id_ext(str: &str) -> ast::Ident {
str_to_ident(str) str_to_ident(str)
} }
// Lift an ident to the expr that evaluates to that ident. // Lift an ident to the expr that evaluates to that ident.
fn mk_ident(cx: @ExtCtxt, sp: Span, ident: ast::ident) -> @ast::expr { fn mk_ident(cx: @ExtCtxt, sp: Span, ident: ast::Ident) -> @ast::expr {
let e_str = cx.expr_str(sp, cx.str_of(ident)); let e_str = cx.expr_str(sp, cx.str_of(ident));
cx.expr_method_call(sp, cx.expr_method_call(sp,
cx.expr_ident(sp, id_ext("ext_cx")), cx.expr_ident(sp, id_ext("ext_cx")),

View file

@ -11,7 +11,7 @@
// Earley-like parser for macros. // Earley-like parser for macros.
use ast; use ast;
use ast::{matcher, match_tok, match_seq, match_nonterminal, ident}; use ast::{matcher, match_tok, match_seq, match_nonterminal, Ident};
use codemap::{BytePos, mk_sp}; use codemap::{BytePos, mk_sp};
use codemap; use codemap;
use parse::lexer::*; //resolve bug? use parse::lexer::*; //resolve bug?
@ -189,9 +189,9 @@ pub enum named_match {
pub type earley_item = ~MatcherPos; pub type earley_item = ~MatcherPos;
pub fn nameize(p_s: @mut ParseSess, ms: &[matcher], res: &[@named_match]) pub fn nameize(p_s: @mut ParseSess, ms: &[matcher], res: &[@named_match])
-> HashMap<ident,@named_match> { -> HashMap<Ident,@named_match> {
fn n_rec(p_s: @mut ParseSess, m: &matcher, res: &[@named_match], fn n_rec(p_s: @mut ParseSess, m: &matcher, res: &[@named_match],
ret_val: &mut HashMap<ident, @named_match>) { ret_val: &mut HashMap<Ident, @named_match>) {
match *m { match *m {
codemap::Spanned {node: match_tok(_), _} => (), codemap::Spanned {node: match_tok(_), _} => (),
codemap::Spanned {node: match_seq(ref more_ms, _, _, _, _), _} => { codemap::Spanned {node: match_seq(ref more_ms, _, _, _, _), _} => {
@ -216,7 +216,7 @@ pub fn nameize(p_s: @mut ParseSess, ms: &[matcher], res: &[@named_match])
} }
pub enum parse_result { pub enum parse_result {
success(HashMap<ident, @named_match>), success(HashMap<Ident, @named_match>),
failure(codemap::Span, ~str), failure(codemap::Span, ~str),
error(codemap::Span, ~str) error(codemap::Span, ~str)
} }
@ -226,7 +226,7 @@ pub fn parse_or_else(
cfg: ast::CrateConfig, cfg: ast::CrateConfig,
rdr: @mut reader, rdr: @mut reader,
ms: ~[matcher] ms: ~[matcher]
) -> HashMap<ident, @named_match> { ) -> HashMap<Ident, @named_match> {
match parse(sess, cfg, rdr, ms) { match parse(sess, cfg, rdr, ms) {
success(m) => m, success(m) => m,
failure(sp, str) => sess.span_diagnostic.span_fatal(sp, str), failure(sp, str) => sess.span_diagnostic.span_fatal(sp, str),

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use ast::{ident, matcher_, matcher, match_tok, match_nonterminal, match_seq}; use ast::{Ident, matcher_, matcher, match_tok, match_nonterminal, match_seq};
use ast::{tt_delim}; use ast::{tt_delim};
use ast; use ast;
use codemap::{Span, Spanned, dummy_sp}; use codemap::{Span, Spanned, dummy_sp};
@ -25,7 +25,7 @@ use print;
pub fn add_new_extension(cx: @ExtCtxt, pub fn add_new_extension(cx: @ExtCtxt,
sp: Span, sp: Span,
name: ident, name: Ident,
arg: ~[ast::token_tree]) arg: ~[ast::token_tree])
-> base::MacResult { -> base::MacResult {
// these spans won't matter, anyways // these spans won't matter, anyways
@ -74,7 +74,7 @@ pub fn add_new_extension(cx: @ExtCtxt,
}; };
// Given `lhses` and `rhses`, this is the new macro we create // Given `lhses` and `rhses`, this is the new macro we create
fn generic_extension(cx: @ExtCtxt, sp: Span, name: ident, fn generic_extension(cx: @ExtCtxt, sp: Span, name: Ident,
arg: &[ast::token_tree], arg: &[ast::token_tree],
lhses: &[@named_match], rhses: &[@named_match]) lhses: &[@named_match], rhses: &[@named_match])
-> MacResult { -> MacResult {

View file

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
use ast; use ast;
use ast::{token_tree, tt_delim, tt_tok, tt_seq, tt_nonterminal,ident}; use ast::{token_tree, tt_delim, tt_tok, tt_seq, tt_nonterminal,Ident};
use codemap::{Span, dummy_sp}; use codemap::{Span, dummy_sp};
use diagnostic::span_handler; use diagnostic::span_handler;
use ext::tt::macro_parser::{named_match, matched_seq, matched_nonterminal}; use ext::tt::macro_parser::{named_match, matched_seq, matched_nonterminal};
@ -34,7 +34,7 @@ pub struct TtReader {
// the unzipped tree: // the unzipped tree:
stack: @mut TtFrame, stack: @mut TtFrame,
/* for MBE-style macro transcription */ /* for MBE-style macro transcription */
interpolations: HashMap<ident, @named_match>, interpolations: HashMap<Ident, @named_match>,
repeat_idx: ~[uint], repeat_idx: ~[uint],
repeat_len: ~[uint], repeat_len: ~[uint],
/* cached: */ /* cached: */
@ -46,7 +46,7 @@ pub struct TtReader {
* `src` contains no `tt_seq`s and `tt_nonterminal`s, `interp` can (and * `src` contains no `tt_seq`s and `tt_nonterminal`s, `interp` can (and
* should) be none. */ * should) be none. */
pub fn new_tt_reader(sp_diag: @mut span_handler, pub fn new_tt_reader(sp_diag: @mut span_handler,
interp: Option<HashMap<ident,@named_match>>, interp: Option<HashMap<Ident,@named_match>>,
src: ~[ast::token_tree]) src: ~[ast::token_tree])
-> @mut TtReader { -> @mut TtReader {
let r = @mut TtReader { let r = @mut TtReader {
@ -113,7 +113,7 @@ fn lookup_cur_matched_by_matched(r: &mut TtReader,
r.repeat_idx.iter().fold(start, red) r.repeat_idx.iter().fold(start, red)
} }
fn lookup_cur_matched(r: &mut TtReader, name: ident) -> @named_match { fn lookup_cur_matched(r: &mut TtReader, name: Ident) -> @named_match {
match r.interpolations.find_copy(&name) { match r.interpolations.find_copy(&name) {
Some(s) => lookup_cur_matched_by_matched(r, s), Some(s) => lookup_cur_matched_by_matched(r, s),
None => { None => {
@ -126,7 +126,7 @@ fn lookup_cur_matched(r: &mut TtReader, name: ident) -> @named_match {
#[deriving(Clone)] #[deriving(Clone)]
enum lis { enum lis {
lis_unconstrained, lis_unconstrained,
lis_constraint(uint, ident), lis_constraint(uint, Ident),
lis_contradiction(~str), lis_contradiction(~str),
} }

View file

@ -32,7 +32,7 @@ pub trait ast_fold {
fn fold_mod(@self, &_mod) -> _mod; fn fold_mod(@self, &_mod) -> _mod;
fn fold_foreign_mod(@self, &foreign_mod) -> foreign_mod; fn fold_foreign_mod(@self, &foreign_mod) -> foreign_mod;
fn fold_variant(@self, &variant) -> variant; fn fold_variant(@self, &variant) -> variant;
fn fold_ident(@self, ident) -> ident; fn fold_ident(@self, Ident) -> Ident;
fn fold_path(@self, &Path) -> Path; fn fold_path(@self, &Path) -> Path;
fn fold_local(@self, @Local) -> @Local; fn fold_local(@self, @Local) -> @Local;
fn map_exprs(@self, @fn(@expr) -> @expr, &[@expr]) -> ~[@expr]; fn map_exprs(@self, @fn(@expr) -> @expr, &[@expr]) -> ~[@expr];
@ -61,7 +61,7 @@ pub struct AstFoldFns {
fold_mod: @fn(&_mod, @ast_fold) -> _mod, fold_mod: @fn(&_mod, @ast_fold) -> _mod,
fold_foreign_mod: @fn(&foreign_mod, @ast_fold) -> foreign_mod, fold_foreign_mod: @fn(&foreign_mod, @ast_fold) -> foreign_mod,
fold_variant: @fn(&variant_, Span, @ast_fold) -> (variant_, Span), fold_variant: @fn(&variant_, Span, @ast_fold) -> (variant_, Span),
fold_ident: @fn(ident, @ast_fold) -> ident, fold_ident: @fn(Ident, @ast_fold) -> Ident,
fold_path: @fn(&Path, @ast_fold) -> Path, fold_path: @fn(&Path, @ast_fold) -> Path,
fold_local: @fn(@Local, @ast_fold) -> @Local, fold_local: @fn(@Local, @ast_fold) -> @Local,
map_exprs: @fn(@fn(@expr) -> @expr, &[@expr]) -> ~[@expr], map_exprs: @fn(@fn(@expr) -> @expr, &[@expr]) -> ~[@expr],
@ -758,7 +758,7 @@ fn noop_fold_variant(v: &variant_, fld: @ast_fold) -> variant_ {
} }
} }
fn noop_fold_ident(i: ident, _fld: @ast_fold) -> ident { fn noop_fold_ident(i: Ident, _fld: @ast_fold) -> Ident {
i i
} }
@ -913,7 +913,7 @@ impl ast_fold for AstFoldFns {
let (n, s) = (self.fold_variant)(&x.node, x.span, self as @ast_fold); let (n, s) = (self.fold_variant)(&x.node, x.span, self as @ast_fold);
Spanned { node: n, span: (self.new_span)(s) } Spanned { node: n, span: (self.new_span)(s) }
} }
fn fold_ident(@self, x: ident) -> ident { fn fold_ident(@self, x: Ident) -> Ident {
(self.fold_ident)(x, self as @ast_fold) (self.fold_ident)(x, self as @ast_fold)
} }
fn fold_path(@self, x: &Path) -> Path { fn fold_path(@self, x: &Path) -> Path {
@ -961,7 +961,7 @@ mod test {
// taken from expand // taken from expand
// given a function from idents to idents, produce // given a function from idents to idents, produce
// an ast_fold that applies that function: // an ast_fold that applies that function:
pub fn fun_to_ident_folder(f: @fn(ast::ident)->ast::ident) -> @ast_fold{ pub fn fun_to_ident_folder(f: @fn(ast::Ident)->ast::Ident) -> @ast_fold{
let afp = default_ast_fold(); let afp = default_ast_fold();
let f_pre = @AstFoldFns{ let f_pre = @AstFoldFns{
fold_ident : |id, _| f(id), fold_ident : |id, _| f(id),
@ -976,7 +976,7 @@ mod test {
} }
// change every identifier to "zz" // change every identifier to "zz"
pub fn to_zz() -> @fn(ast::ident)->ast::ident { pub fn to_zz() -> @fn(ast::Ident)->ast::Ident {
let zz_id = token::str_to_ident("zz"); let zz_id = token::str_to_ident("zz");
|_id| {zz_id} |_id| {zz_id}
} }

View file

@ -34,10 +34,10 @@ pub enum vt<E> { mk_vt(visitor<E>), }
pub enum fn_kind<'self> { pub enum fn_kind<'self> {
// fn foo() or extern "Abi" fn foo() // fn foo() or extern "Abi" fn foo()
fk_item_fn(ident, &'self Generics, purity, AbiSet), fk_item_fn(Ident, &'self Generics, purity, AbiSet),
// fn foo(&self) // fn foo(&self)
fk_method(ident, &'self Generics, &'self method), fk_method(Ident, &'self Generics, &'self method),
// @fn(x, y) { ... } // @fn(x, y) { ... }
fk_anon(ast::Sigil), fk_anon(ast::Sigil),
@ -46,7 +46,7 @@ pub enum fn_kind<'self> {
fk_fn_block, fk_fn_block,
} }
pub fn name_of_fn(fk: &fn_kind) -> ident { pub fn name_of_fn(fk: &fn_kind) -> Ident {
match *fk { match *fk {
fk_item_fn(name, _, _, _) | fk_method(name, _, _) => { fk_item_fn(name, _, _, _) | fk_method(name, _, _) => {
name name
@ -88,7 +88,7 @@ pub struct Visitor<E> {
visit_fn: @fn(&fn_kind, &fn_decl, &Block, Span, NodeId, (E, vt<E>)), visit_fn: @fn(&fn_kind, &fn_decl, &Block, Span, NodeId, (E, vt<E>)),
visit_ty_method: @fn(&TypeMethod, (E, vt<E>)), visit_ty_method: @fn(&TypeMethod, (E, vt<E>)),
visit_trait_method: @fn(&trait_method, (E, vt<E>)), visit_trait_method: @fn(&trait_method, (E, vt<E>)),
visit_struct_def: @fn(@struct_def, ident, &Generics, NodeId, (E, vt<E>)), visit_struct_def: @fn(@struct_def, Ident, &Generics, NodeId, (E, vt<E>)),
visit_struct_field: @fn(@struct_field, (E, vt<E>)), visit_struct_field: @fn(@struct_field, (E, vt<E>)),
} }
@ -422,7 +422,7 @@ pub fn visit_trait_method<E:Clone>(m: &trait_method, (e, v): (E, vt<E>)) {
pub fn visit_struct_def<E:Clone>( pub fn visit_struct_def<E:Clone>(
sd: @struct_def, sd: @struct_def,
_nm: ast::ident, _nm: ast::Ident,
_generics: &Generics, _generics: &Generics,
_id: NodeId, _id: NodeId,
(e, v): (E, vt<E>) (e, v): (E, vt<E>)
@ -612,7 +612,7 @@ pub struct SimpleVisitor {
visit_fn: @fn(&fn_kind, &fn_decl, &Block, Span, NodeId), visit_fn: @fn(&fn_kind, &fn_decl, &Block, Span, NodeId),
visit_ty_method: @fn(&TypeMethod), visit_ty_method: @fn(&TypeMethod),
visit_trait_method: @fn(&trait_method), visit_trait_method: @fn(&trait_method),
visit_struct_def: @fn(@struct_def, ident, &Generics, NodeId), visit_struct_def: @fn(@struct_def, Ident, &Generics, NodeId),
visit_struct_field: @fn(@struct_field), visit_struct_field: @fn(@struct_field),
visit_struct_method: @fn(@method) visit_struct_method: @fn(@method)
} }
@ -715,9 +715,9 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
visit_trait_method(m, (e, v)); visit_trait_method(m, (e, v));
} }
fn v_struct_def( fn v_struct_def(
f: @fn(@struct_def, ident, &Generics, NodeId), f: @fn(@struct_def, Ident, &Generics, NodeId),
sd: @struct_def, sd: @struct_def,
nm: ident, nm: Ident,
generics: &Generics, generics: &Generics,
id: NodeId, id: NodeId,
(e, v): ((), vt<()>) (e, v): ((), vt<()>)

View file

@ -34,7 +34,7 @@ use ast::{expr_vstore_slice, expr_vstore_box};
use ast::{expr_vstore_mut_slice, expr_while, expr_for_loop, extern_fn, Field, fn_decl}; use ast::{expr_vstore_mut_slice, expr_while, expr_for_loop, extern_fn, Field, fn_decl};
use ast::{expr_vstore_uniq, Onceness, Once, Many}; use ast::{expr_vstore_uniq, Onceness, Once, Many};
use ast::{foreign_item, foreign_item_static, foreign_item_fn, foreign_mod}; use ast::{foreign_item, foreign_item_static, foreign_item_fn, foreign_mod};
use ast::{ident, impure_fn, inherited, item, item_, item_static}; use ast::{Ident, impure_fn, inherited, item, item_, item_static};
use ast::{item_enum, item_fn, item_foreign_mod, item_impl}; use ast::{item_enum, item_fn, item_foreign_mod, item_impl};
use ast::{item_mac, item_mod, item_struct, item_trait, item_ty, lit, lit_}; use ast::{item_mac, item_mod, item_struct, item_trait, item_ty, lit, lit_};
use ast::{lit_bool, lit_float, lit_float_unsuffixed, lit_int}; use ast::{lit_bool, lit_float, lit_float_unsuffixed, lit_int};
@ -95,7 +95,7 @@ enum restriction {
} }
type arg_or_capture_item = Either<arg, ()>; type arg_or_capture_item = Either<arg, ()>;
type item_info = (ident, item_, Option<~[Attribute]>); type item_info = (Ident, item_, Option<~[Attribute]>);
/// How to parse a path. There are four different kinds of paths, all of which /// How to parse a path. There are four different kinds of paths, all of which
/// are parsed somewhat differently. /// are parsed somewhat differently.
@ -476,7 +476,7 @@ impl Parser {
self.commit_stmt(s, &[edible], &[]) self.commit_stmt(s, &[edible], &[])
} }
pub fn parse_ident(&self) -> ast::ident { pub fn parse_ident(&self) -> ast::Ident {
self.check_strict_keywords(); self.check_strict_keywords();
self.check_reserved_keywords(); self.check_reserved_keywords();
match *self.token { match *self.token {
@ -756,7 +756,7 @@ impl Parser {
} }
pub fn get_id(&self) -> NodeId { next_node_id(self.sess) } pub fn get_id(&self) -> NodeId { next_node_id(self.sess) }
pub fn id_to_str(&self, id: ident) -> @str { pub fn id_to_str(&self, id: Ident) -> @str {
get_ident_interner().get(id.name) get_ident_interner().get(id.name)
} }
@ -775,7 +775,7 @@ impl Parser {
} }
} }
pub fn get_lifetime(&self, tok: &token::Token) -> ast::ident { pub fn get_lifetime(&self, tok: &token::Token) -> ast::Ident {
match *tok { match *tok {
token::LIFETIME(ref ident) => *ident, token::LIFETIME(ref ident) => *ident,
_ => self.bug("not a lifetime"), _ => self.bug("not a lifetime"),
@ -1664,7 +1664,7 @@ impl Parser {
pub fn mk_method_call(&self, pub fn mk_method_call(&self,
rcvr: @expr, rcvr: @expr,
ident: ident, ident: Ident,
tps: ~[Ty], tps: ~[Ty],
args: ~[@expr], args: ~[@expr],
sugar: CallSugar) -> ast::expr_ { sugar: CallSugar) -> ast::expr_ {
@ -1675,7 +1675,7 @@ impl Parser {
expr_index(self.get_id(), expr, idx) expr_index(self.get_id(), expr, idx)
} }
pub fn mk_field(&self, expr: @expr, ident: ident, tys: ~[Ty]) -> ast::expr_ { pub fn mk_field(&self, expr: @expr, ident: Ident, tys: ~[Ty]) -> ast::expr_ {
expr_field(expr, ident, tys) expr_field(expr, ident, tys)
} }
@ -2550,7 +2550,7 @@ impl Parser {
return self.mk_expr(lo, hi, expr_while(cond, body)); return self.mk_expr(lo, hi, expr_while(cond, body));
} }
pub fn parse_loop_expr(&self, opt_ident: Option<ast::ident>) -> @expr { pub fn parse_loop_expr(&self, opt_ident: Option<ast::Ident>) -> @expr {
// loop headers look like 'loop {' or 'loop unsafe {' // loop headers look like 'loop {' or 'loop unsafe {'
let is_loop_header = let is_loop_header =
*self.token == token::LBRACE *self.token == token::LBRACE
@ -3713,13 +3713,13 @@ impl Parser {
} }
// parse the name and optional generic types of a function header. // parse the name and optional generic types of a function header.
fn parse_fn_header(&self) -> (ident, ast::Generics) { fn parse_fn_header(&self) -> (Ident, ast::Generics) {
let id = self.parse_ident(); let id = self.parse_ident();
let generics = self.parse_generics(); let generics = self.parse_generics();
(id, generics) (id, generics)
} }
fn mk_item(&self, lo: BytePos, hi: BytePos, ident: ident, fn mk_item(&self, lo: BytePos, hi: BytePos, ident: Ident,
node: item_, vis: visibility, node: item_, vis: visibility,
attrs: ~[Attribute]) -> @item { attrs: ~[Attribute]) -> @item {
@ast::item { ident: ident, @ast::item { ident: ident,
@ -4107,7 +4107,7 @@ impl Parser {
} }
} }
fn push_mod_path(&self, id: ident, attrs: &[Attribute]) { fn push_mod_path(&self, id: Ident, attrs: &[Attribute]) {
let default_path = token::interner_get(id.name); let default_path = token::interner_get(id.name);
let file_path = match ::attr::first_attr_value_str_by_name(attrs, let file_path = match ::attr::first_attr_value_str_by_name(attrs,
"path") { "path") {
@ -4123,7 +4123,7 @@ impl Parser {
// read a module from a source file. // read a module from a source file.
fn eval_src_mod(&self, fn eval_src_mod(&self,
id: ast::ident, id: ast::Ident,
outer_attrs: &[ast::Attribute], outer_attrs: &[ast::Attribute],
id_sp: Span) id_sp: Span)
-> (ast::item_, ~[ast::Attribute]) { -> (ast::item_, ~[ast::Attribute]) {

View file

@ -76,22 +76,22 @@ pub enum Token {
LIT_INT(i64, ast::int_ty), LIT_INT(i64, ast::int_ty),
LIT_UINT(u64, ast::uint_ty), LIT_UINT(u64, ast::uint_ty),
LIT_INT_UNSUFFIXED(i64), LIT_INT_UNSUFFIXED(i64),
LIT_FLOAT(ast::ident, ast::float_ty), LIT_FLOAT(ast::Ident, ast::float_ty),
LIT_FLOAT_UNSUFFIXED(ast::ident), LIT_FLOAT_UNSUFFIXED(ast::Ident),
LIT_STR(ast::ident), LIT_STR(ast::Ident),
/* Name components */ /* Name components */
// an identifier contains an "is_mod_name" boolean, // an identifier contains an "is_mod_name" boolean,
// indicating whether :: follows this token with no // indicating whether :: follows this token with no
// whitespace in between. // whitespace in between.
IDENT(ast::ident, bool), IDENT(ast::Ident, bool),
UNDERSCORE, UNDERSCORE,
LIFETIME(ast::ident), LIFETIME(ast::Ident),
/* For interpolation */ /* For interpolation */
INTERPOLATED(nonterminal), INTERPOLATED(nonterminal),
DOC_COMMENT(ast::ident), DOC_COMMENT(ast::Ident),
EOF, EOF,
} }
@ -104,7 +104,7 @@ pub enum nonterminal {
nt_pat( @ast::pat), nt_pat( @ast::pat),
nt_expr(@ast::expr), nt_expr(@ast::expr),
nt_ty( ~ast::Ty), nt_ty( ~ast::Ty),
nt_ident(~ast::ident, bool), nt_ident(~ast::Ident, bool),
nt_attr(@ast::Attribute), // #[foo] nt_attr(@ast::Attribute), // #[foo]
nt_path(~ast::Path), nt_path(~ast::Path),
nt_tt( @ast::token_tree), //needs @ed to break a circularity nt_tt( @ast::token_tree), //needs @ed to break a circularity
@ -307,46 +307,46 @@ pub fn is_bar(t: &Token) -> bool {
pub mod special_idents { pub mod special_idents {
use ast::ident; use ast::Ident;
pub static underscore : ident = ident { name: 0, ctxt: 0}; pub static underscore : Ident = Ident { name: 0, ctxt: 0};
pub static anon : ident = ident { name: 1, ctxt: 0}; pub static anon : Ident = Ident { name: 1, ctxt: 0};
pub static invalid : ident = ident { name: 2, ctxt: 0}; // '' pub static invalid : Ident = Ident { name: 2, ctxt: 0}; // ''
pub static unary : ident = ident { name: 3, ctxt: 0}; pub static unary : Ident = Ident { name: 3, ctxt: 0};
pub static not_fn : ident = ident { name: 4, ctxt: 0}; pub static not_fn : Ident = Ident { name: 4, ctxt: 0};
pub static idx_fn : ident = ident { name: 5, ctxt: 0}; pub static idx_fn : Ident = Ident { name: 5, ctxt: 0};
pub static unary_minus_fn : ident = ident { name: 6, ctxt: 0}; pub static unary_minus_fn : Ident = Ident { name: 6, ctxt: 0};
pub static clownshoes_extensions : ident = ident { name: 7, ctxt: 0}; pub static clownshoes_extensions : Ident = Ident { name: 7, ctxt: 0};
pub static self_ : ident = ident { name: 8, ctxt: 0}; // 'self' pub static self_ : Ident = Ident { name: 8, ctxt: 0}; // 'self'
/* for matcher NTs */ /* for matcher NTs */
pub static item : ident = ident { name: 9, ctxt: 0}; pub static item : Ident = Ident { name: 9, ctxt: 0};
pub static block : ident = ident { name: 10, ctxt: 0}; pub static block : Ident = Ident { name: 10, ctxt: 0};
pub static stmt : ident = ident { name: 11, ctxt: 0}; pub static stmt : Ident = Ident { name: 11, ctxt: 0};
pub static pat : ident = ident { name: 12, ctxt: 0}; pub static pat : Ident = Ident { name: 12, ctxt: 0};
pub static expr : ident = ident { name: 13, ctxt: 0}; pub static expr : Ident = Ident { name: 13, ctxt: 0};
pub static ty : ident = ident { name: 14, ctxt: 0}; pub static ty : Ident = Ident { name: 14, ctxt: 0};
pub static ident : ident = ident { name: 15, ctxt: 0}; pub static ident : Ident = Ident { name: 15, ctxt: 0};
pub static path : ident = ident { name: 16, ctxt: 0}; pub static path : Ident = Ident { name: 16, ctxt: 0};
pub static tt : ident = ident { name: 17, ctxt: 0}; pub static tt : Ident = Ident { name: 17, ctxt: 0};
pub static matchers : ident = ident { name: 18, ctxt: 0}; pub static matchers : Ident = Ident { name: 18, ctxt: 0};
pub static str : ident = ident { name: 19, ctxt: 0}; // for the type pub static str : Ident = Ident { name: 19, ctxt: 0}; // for the type
/* outside of libsyntax */ /* outside of libsyntax */
pub static arg : ident = ident { name: 20, ctxt: 0}; pub static arg : Ident = Ident { name: 20, ctxt: 0};
pub static descrim : ident = ident { name: 21, ctxt: 0}; pub static descrim : Ident = Ident { name: 21, ctxt: 0};
pub static clownshoe_abi : ident = ident { name: 22, ctxt: 0}; pub static clownshoe_abi : Ident = Ident { name: 22, ctxt: 0};
pub static clownshoe_stack_shim : ident = ident { name: 23, ctxt: 0}; pub static clownshoe_stack_shim : Ident = Ident { name: 23, ctxt: 0};
pub static main : ident = ident { name: 24, ctxt: 0}; pub static main : Ident = Ident { name: 24, ctxt: 0};
pub static opaque : ident = ident { name: 25, ctxt: 0}; pub static opaque : Ident = Ident { name: 25, ctxt: 0};
pub static blk : ident = ident { name: 26, ctxt: 0}; pub static blk : Ident = Ident { name: 26, ctxt: 0};
pub static statik : ident = ident { name: 27, ctxt: 0}; pub static statik : Ident = Ident { name: 27, ctxt: 0};
pub static clownshoes_foreign_mod: ident = ident { name: 28, ctxt: 0}; pub static clownshoes_foreign_mod: Ident = Ident { name: 28, ctxt: 0};
pub static unnamed_field: ident = ident { name: 29, ctxt: 0}; pub static unnamed_field: Ident = Ident { name: 29, ctxt: 0};
pub static c_abi: ident = ident { name: 30, ctxt: 0}; pub static c_abi: Ident = Ident { name: 30, ctxt: 0};
pub static type_self: ident = ident { name: 31, ctxt: 0}; // `Self` pub static type_self: Ident = Ident { name: 31, ctxt: 0}; // `Self`
} }
/** /**
@ -525,18 +525,18 @@ pub fn interner_get(name : Name) -> @str {
} }
// maps an identifier to the string that it corresponds to // maps an identifier to the string that it corresponds to
pub fn ident_to_str(id : &ast::ident) -> @str { pub fn ident_to_str(id : &ast::Ident) -> @str {
interner_get(id.name) interner_get(id.name)
} }
// maps a string to an identifier with an empty syntax context // maps a string to an identifier with an empty syntax context
pub fn str_to_ident(str : &str) -> ast::ident { pub fn str_to_ident(str : &str) -> ast::Ident {
ast::new_ident(intern(str)) ast::Ident::new(intern(str))
} }
// maps a string to a gensym'ed identifier // maps a string to a gensym'ed identifier
pub fn gensym_ident(str : &str) -> ast::ident { pub fn gensym_ident(str : &str) -> ast::Ident {
ast::new_ident(gensym(str)) ast::Ident::new(gensym(str))
} }
@ -561,7 +561,7 @@ pub fn fresh_name(src_name : &str) -> Name {
* the language and may not appear as identifiers. * the language and may not appear as identifiers.
*/ */
pub mod keywords { pub mod keywords {
use ast::ident; use ast::Ident;
pub enum Keyword { pub enum Keyword {
// Strict keywords // Strict keywords
@ -608,46 +608,46 @@ pub mod keywords {
} }
impl Keyword { impl Keyword {
pub fn to_ident(&self) -> ident { pub fn to_ident(&self) -> Ident {
match *self { match *self {
As => ident { name: 32, ctxt: 0 }, As => Ident { name: 32, ctxt: 0 },
Break => ident { name: 33, ctxt: 0 }, Break => Ident { name: 33, ctxt: 0 },
Const => ident { name: 34, ctxt: 0 }, Const => Ident { name: 34, ctxt: 0 },
Do => ident { name: 35, ctxt: 0 }, Do => Ident { name: 35, ctxt: 0 },
Else => ident { name: 36, ctxt: 0 }, Else => Ident { name: 36, ctxt: 0 },
Enum => ident { name: 37, ctxt: 0 }, Enum => Ident { name: 37, ctxt: 0 },
Extern => ident { name: 38, ctxt: 0 }, Extern => Ident { name: 38, ctxt: 0 },
False => ident { name: 39, ctxt: 0 }, False => Ident { name: 39, ctxt: 0 },
Fn => ident { name: 40, ctxt: 0 }, Fn => Ident { name: 40, ctxt: 0 },
For => ident { name: 41, ctxt: 0 }, For => Ident { name: 41, ctxt: 0 },
If => ident { name: 42, ctxt: 0 }, If => Ident { name: 42, ctxt: 0 },
Impl => ident { name: 43, ctxt: 0 }, Impl => Ident { name: 43, ctxt: 0 },
In => ident { name: 63, ctxt: 0 }, In => Ident { name: 63, ctxt: 0 },
Let => ident { name: 44, ctxt: 0 }, Let => Ident { name: 44, ctxt: 0 },
__Log => ident { name: 45, ctxt: 0 }, __Log => Ident { name: 45, ctxt: 0 },
Loop => ident { name: 46, ctxt: 0 }, Loop => Ident { name: 46, ctxt: 0 },
Match => ident { name: 47, ctxt: 0 }, Match => Ident { name: 47, ctxt: 0 },
Mod => ident { name: 48, ctxt: 0 }, Mod => Ident { name: 48, ctxt: 0 },
Mut => ident { name: 49, ctxt: 0 }, Mut => Ident { name: 49, ctxt: 0 },
Once => ident { name: 50, ctxt: 0 }, Once => Ident { name: 50, ctxt: 0 },
Priv => ident { name: 51, ctxt: 0 }, Priv => Ident { name: 51, ctxt: 0 },
Pub => ident { name: 52, ctxt: 0 }, Pub => Ident { name: 52, ctxt: 0 },
Ref => ident { name: 53, ctxt: 0 }, Ref => Ident { name: 53, ctxt: 0 },
Return => ident { name: 54, ctxt: 0 }, Return => Ident { name: 54, ctxt: 0 },
Static => ident { name: 27, ctxt: 0 }, Static => Ident { name: 27, ctxt: 0 },
Self => ident { name: 8, ctxt: 0 }, Self => Ident { name: 8, ctxt: 0 },
Struct => ident { name: 55, ctxt: 0 }, Struct => Ident { name: 55, ctxt: 0 },
Super => ident { name: 56, ctxt: 0 }, Super => Ident { name: 56, ctxt: 0 },
True => ident { name: 57, ctxt: 0 }, True => Ident { name: 57, ctxt: 0 },
Trait => ident { name: 58, ctxt: 0 }, Trait => Ident { name: 58, ctxt: 0 },
Type => ident { name: 59, ctxt: 0 }, Type => Ident { name: 59, ctxt: 0 },
Typeof => ident { name: 67, ctxt: 0 }, Typeof => Ident { name: 67, ctxt: 0 },
Unsafe => ident { name: 60, ctxt: 0 }, Unsafe => Ident { name: 60, ctxt: 0 },
Use => ident { name: 61, ctxt: 0 }, Use => Ident { name: 61, ctxt: 0 },
While => ident { name: 62, ctxt: 0 }, While => Ident { name: 62, ctxt: 0 },
Be => ident { name: 64, ctxt: 0 }, Be => Ident { name: 64, ctxt: 0 },
Pure => ident { name: 65, ctxt: 0 }, Pure => Ident { name: 65, ctxt: 0 },
Yield => ident { name: 66, ctxt: 0 }, Yield => Ident { name: 66, ctxt: 0 },
} }
} }
} }

View file

@ -185,7 +185,7 @@ pub fn path_to_str(p: &ast::Path, intr: @ident_interner) -> ~str {
to_str(p, |a,b| print_path(a, b, false), intr) to_str(p, |a,b| print_path(a, b, false), intr)
} }
pub fn fun_to_str(decl: &ast::fn_decl, purity: ast::purity, name: ast::ident, pub fn fun_to_str(decl: &ast::fn_decl, purity: ast::purity, name: ast::Ident,
opt_explicit_self: Option<ast::explicit_self_>, opt_explicit_self: Option<ast::explicit_self_>,
generics: &ast::Generics, intr: @ident_interner) -> ~str { generics: &ast::Generics, intr: @ident_interner) -> ~str {
do io::with_str_writer |wr| { do io::with_str_writer |wr| {
@ -639,7 +639,7 @@ fn print_trait_ref(s: @ps, t: &ast::trait_ref) {
} }
pub fn print_enum_def(s: @ps, enum_definition: &ast::enum_def, pub fn print_enum_def(s: @ps, enum_definition: &ast::enum_def,
generics: &ast::Generics, ident: ast::ident, generics: &ast::Generics, ident: ast::Ident,
span: codemap::Span, visibility: ast::visibility) { span: codemap::Span, visibility: ast::visibility) {
head(s, visibility_qualified(visibility, "enum")); head(s, visibility_qualified(visibility, "enum"));
print_ident(s, ident); print_ident(s, ident);
@ -691,7 +691,7 @@ pub fn print_visibility(s: @ps, vis: ast::visibility) {
pub fn print_struct(s: @ps, pub fn print_struct(s: @ps,
struct_def: &ast::struct_def, struct_def: &ast::struct_def,
generics: &ast::Generics, generics: &ast::Generics,
ident: ast::ident, ident: ast::Ident,
span: codemap::Span) { span: codemap::Span) {
print_ident(s, ident); print_ident(s, ident);
print_generics(s, generics); print_generics(s, generics);
@ -1495,7 +1495,7 @@ pub fn print_decl(s: @ps, decl: &ast::decl) {
} }
} }
pub fn print_ident(s: @ps, ident: ast::ident) { pub fn print_ident(s: @ps, ident: ast::Ident) {
word(s.s, ident_to_str(&ident)); word(s.s, ident_to_str(&ident));
} }
@ -1698,7 +1698,7 @@ pub fn print_fn(s: @ps,
decl: &ast::fn_decl, decl: &ast::fn_decl,
purity: Option<ast::purity>, purity: Option<ast::purity>,
abis: AbiSet, abis: AbiSet,
name: ast::ident, name: ast::Ident,
generics: &ast::Generics, generics: &ast::Generics,
opt_explicit_self: Option<ast::explicit_self_>, opt_explicit_self: Option<ast::explicit_self_>,
vis: ast::visibility) { vis: ast::visibility) {
@ -1946,7 +1946,7 @@ pub fn print_ty_fn(s: @ps,
purity: ast::purity, purity: ast::purity,
onceness: ast::Onceness, onceness: ast::Onceness,
decl: &ast::fn_decl, decl: &ast::fn_decl,
id: Option<ast::ident>, id: Option<ast::Ident>,
opt_bounds: &Option<OptVec<ast::TyParamBound>>, opt_bounds: &Option<OptVec<ast::TyParamBound>>,
generics: Option<&ast::Generics>, generics: Option<&ast::Generics>,
opt_explicit_self: Option<ast::explicit_self_>) { opt_explicit_self: Option<ast::explicit_self_>) {

View file

@ -82,7 +82,7 @@ pub fn string_to_pat(source_str : @str) -> @ast::pat {
} }
// convert a vector of strings to a vector of ast::idents // convert a vector of strings to a vector of ast::idents
pub fn strs_to_idents(ids: ~[&str]) -> ~[ast::ident] { pub fn strs_to_idents(ids: ~[&str]) -> ~[ast::Ident] {
ids.map(|u| token::str_to_ident(*u)) ids.map(|u| token::str_to_ident(*u))
} }

View file

@ -30,10 +30,10 @@ use opt_vec::OptVec;
pub enum fn_kind<'self> { pub enum fn_kind<'self> {
// fn foo() or extern "Abi" fn foo() // fn foo() or extern "Abi" fn foo()
fk_item_fn(ident, &'self Generics, purity, AbiSet), fk_item_fn(Ident, &'self Generics, purity, AbiSet),
// fn foo(&self) // fn foo(&self)
fk_method(ident, &'self Generics, &'self method), fk_method(Ident, &'self Generics, &'self method),
// @fn(x, y) { ... } // @fn(x, y) { ... }
fk_anon(ast::Sigil), fk_anon(ast::Sigil),
@ -42,7 +42,7 @@ pub enum fn_kind<'self> {
fk_fn_block, fk_fn_block,
} }
pub fn name_of_fn(fk: &fn_kind) -> ident { pub fn name_of_fn(fk: &fn_kind) -> Ident {
match *fk { match *fk {
fk_item_fn(name, _, _, _) | fk_method(name, _, _) => { fk_item_fn(name, _, _, _) | fk_method(name, _, _) => {
name name
@ -86,7 +86,7 @@ pub trait Visitor<E:Clone> {
} }
fn visit_ty_method(&mut self, t:&TypeMethod, e:E) { walk_ty_method(self, t, e) } fn visit_ty_method(&mut self, t:&TypeMethod, e:E) { walk_ty_method(self, t, e) }
fn visit_trait_method(&mut self, t:&trait_method, e:E) { walk_trait_method(self, t, e) } fn visit_trait_method(&mut self, t:&trait_method, e:E) { walk_trait_method(self, t, e) }
fn visit_struct_def(&mut self, s:@struct_def, i:ident, g:&Generics, n:NodeId, e:E) { fn visit_struct_def(&mut self, s:@struct_def, i:Ident, g:&Generics, n:NodeId, e:E) {
walk_struct_def(self, s, i, g, n, e) walk_struct_def(self, s, i, g, n, e)
} }
fn visit_struct_field(&mut self, s:@struct_field, e:E) { walk_struct_field(self, s, e) } fn visit_struct_field(&mut self, s:@struct_field, e:E) { walk_struct_field(self, s, e) }
@ -144,7 +144,7 @@ impl<E:Clone> Visitor<E> for @mut Visitor<E> {
fn visit_trait_method(&mut self, a:&trait_method, e:E) { fn visit_trait_method(&mut self, a:&trait_method, e:E) {
(*self).visit_trait_method(a, e) (*self).visit_trait_method(a, e)
} }
fn visit_struct_def(&mut self, a:@struct_def, b:ident, c:&Generics, d:NodeId, e:E) { fn visit_struct_def(&mut self, a:@struct_def, b:Ident, c:&Generics, d:NodeId, e:E) {
(*self).visit_struct_def(a, b, c, d, e) (*self).visit_struct_def(a, b, c, d, e)
} }
fn visit_struct_field(&mut self, a:@struct_field, e:E) { fn visit_struct_field(&mut self, a:@struct_field, e:E) {
@ -476,7 +476,7 @@ pub fn walk_trait_method<E:Clone, V:Visitor<E>>(visitor: &mut V,
pub fn walk_struct_def<E:Clone, V:Visitor<E>>(visitor: &mut V, pub fn walk_struct_def<E:Clone, V:Visitor<E>>(visitor: &mut V,
struct_definition: @struct_def, struct_definition: @struct_def,
_: ast::ident, _: ast::Ident,
_: &Generics, _: &Generics,
_: NodeId, _: NodeId,
env: E) { env: E) {
@ -693,7 +693,7 @@ pub trait SimpleVisitor {
fn visit_fn(&mut self, &fn_kind, &fn_decl, &Block, Span, NodeId); fn visit_fn(&mut self, &fn_kind, &fn_decl, &Block, Span, NodeId);
fn visit_ty_method(&mut self, &TypeMethod); fn visit_ty_method(&mut self, &TypeMethod);
fn visit_trait_method(&mut self, &trait_method); fn visit_trait_method(&mut self, &trait_method);
fn visit_struct_def(&mut self, @struct_def, ident, &Generics, NodeId); fn visit_struct_def(&mut self, @struct_def, Ident, &Generics, NodeId);
fn visit_struct_field(&mut self, @struct_field); fn visit_struct_field(&mut self, @struct_field);
fn visit_struct_method(&mut self, @method); fn visit_struct_method(&mut self, @method);
} }
@ -792,7 +792,7 @@ impl Visitor<()> for SimpleVisitorVisitor {
} }
fn visit_struct_def(&mut self, fn visit_struct_def(&mut self,
struct_definition: @struct_def, struct_definition: @struct_def,
identifier: ident, identifier: Ident,
generics: &Generics, generics: &Generics,
node_id: NodeId, node_id: NodeId,
env: ()) { env: ()) {