libsyntax: Convert ast::attribute_ to store a @meta_item

This commit is contained in:
Erick Tryzelaar 2013-02-25 06:19:44 -08:00
parent b26d434ad1
commit 5b9e110eab
14 changed files with 28 additions and 27 deletions

View file

@ -358,7 +358,7 @@ pub mod test {
pub fn make_crate_type_attr(+t: ~str) -> ast::attribute {
codemap::respan(codemap::dummy_sp(), ast::attribute_ {
style: ast::attr_outer,
value: codemap::respan(codemap::dummy_sp(),
value: @codemap::respan(codemap::dummy_sp(),
ast::meta_name_value(
@~"crate_type",
codemap::respan(codemap::dummy_sp(),

View file

@ -50,7 +50,7 @@ fn inject_libcore_ref(sess: Session,
attrs: ~[
spanned(ast::attribute_ {
style: ast::attr_inner,
value: spanned(ast::meta_name_value(
value: @spanned(ast::meta_name_value(
@~"vers",
spanned(ast::lit_str(@CORE_VERSION.to_str()))
)),

View file

@ -994,7 +994,7 @@ fn get_attributes(md: ebml::Doc) -> ~[ast::attribute] {
codemap::spanned {
node: ast::attribute_ {
style: ast::attr_outer,
value: /*bad*/copy *meta_item,
value: meta_item,
is_sugared_doc: false,
},
span: codemap::dummy_sp()

View file

@ -1020,7 +1020,7 @@ fn write_int(writer: io::Writer, &&n: int) {
writer.write_be_u32(n as u32);
}
fn encode_meta_item(ebml_w: writer::Encoder, mi: meta_item) {
fn encode_meta_item(ebml_w: writer::Encoder, mi: @meta_item) {
match mi.node {
meta_word(name) => {
ebml_w.start_tag(tag_meta_item_word);
@ -1050,7 +1050,7 @@ fn encode_meta_item(ebml_w: writer::Encoder, mi: meta_item) {
ebml_w.writer.write(str::to_bytes(*name));
ebml_w.end_tag();
for items.each |inner_item| {
encode_meta_item(ebml_w, **inner_item);
encode_meta_item(ebml_w, *inner_item);
}
ebml_w.end_tag();
}

View file

@ -316,7 +316,7 @@ struct LanguageItemCollector {
impl LanguageItemCollector {
fn match_and_collect_meta_item(&self, item_def_id: def_id,
meta_item: meta_item) {
meta_item: @meta_item) {
match meta_item.node {
meta_name_value(key, literal) => {
match literal.node {
@ -368,10 +368,10 @@ impl LanguageItemCollector {
visit_item: |item| {
for item.attrs.each |attribute| {
unsafe {
(*this).match_and_collect_meta_item(local_def(item
.id),
attribute.node
.value);
(*this).match_and_collect_meta_item(
local_def(item.id),
attribute.node.value
);
}
}
},

View file

@ -1142,7 +1142,7 @@ pub enum attr_style { attr_outer, attr_inner, }
#[deriving_eq]
pub struct attribute_ {
style: attr_style,
value: meta_item,
value: @meta_item,
is_sugared_doc: bool,
}

View file

@ -51,16 +51,17 @@ pub fn mk_word_item(name: @~str) -> @ast::meta_item {
pub fn mk_attr(item: @ast::meta_item) -> ast::attribute {
dummy_spanned(ast::attribute_ { style: ast::attr_inner,
value: *item,
value: item,
is_sugared_doc: false })
}
pub fn mk_sugared_doc_attr(text: ~str,
pub fn mk_sugared_doc_attr(+text: ~str,
+lo: BytePos, +hi: BytePos) -> ast::attribute {
let style = doc_comment_style(text);
let lit = spanned(lo, hi, ast::lit_str(@text));
let attr = ast::attribute_ {
style: doc_comment_style(text),
value: spanned(lo, hi, ast::meta_name_value(@~"doc", lit)),
style: style,
value: @spanned(lo, hi, ast::meta_name_value(@~"doc", lit)),
is_sugared_doc: true
};
spanned(lo, hi, attr)
@ -69,7 +70,7 @@ pub fn mk_sugared_doc_attr(text: ~str,
/* Conversion */
pub fn attr_meta(attr: ast::attribute) -> @ast::meta_item {
@attr.node.value
attr.node.value
}
// Get the meta_items from inside a vector of attributes
@ -79,7 +80,7 @@ pub fn attr_metas(attrs: ~[ast::attribute]) -> ~[@ast::meta_item] {
pub fn desugar_doc_attr(attr: &ast::attribute) -> ast::attribute {
if attr.node.is_sugared_doc {
let comment = get_meta_item_value_str(@attr.node.value).get();
let comment = get_meta_item_value_str(attr.node.value).get();
let meta = mk_name_value_item_str(@~"doc",
@strip_doc_comment_decoration(*comment));
mk_attr(meta)
@ -91,7 +92,7 @@ pub fn desugar_doc_attr(attr: &ast::attribute) -> ast::attribute {
/* Accessors */
pub pure fn get_attr_name(attr: &ast::attribute) -> @~str {
get_meta_item_name(@attr.node.value)
get_meta_item_name(attr.node.value)
}
pub pure fn get_meta_item_name(meta: @ast::meta_item) -> @~str {

View file

@ -110,7 +110,7 @@ mod syntax {
pub fn expand_auto_encode(
cx: ext_ctxt,
span: span,
_mitem: ast::meta_item,
_mitem: @ast::meta_item,
in_items: ~[@ast::item]
) -> ~[@ast::item] {
fn is_auto_encode(a: &ast::attribute) -> bool {
@ -165,7 +165,7 @@ pub fn expand_auto_encode(
pub fn expand_auto_decode(
cx: ext_ctxt,
span: span,
_mitem: ast::meta_item,
_mitem: @ast::meta_item,
in_items: ~[@ast::item]
) -> ~[@ast::item] {
fn is_auto_decode(a: &ast::attribute) -> bool {

View file

@ -38,7 +38,7 @@ pub struct MacroDef {
}
pub type ItemDecorator =
fn@(ext_ctxt, span, ast::meta_item, ~[@ast::item]) -> ~[@ast::item];
fn@(ext_ctxt, span, @ast::meta_item, ~[@ast::item]) -> ~[@ast::item];
pub struct SyntaxExpanderTT {
expander: SyntaxExpanderTTFun,

View file

@ -58,7 +58,7 @@ type ExpandDerivingEnumDefFn = &fn(ext_ctxt,
pub fn expand_deriving_eq(cx: ext_ctxt,
span: span,
_mitem: meta_item,
_mitem: @meta_item,
in_items: ~[@item])
-> ~[@item] {
expand_deriving(cx,
@ -70,7 +70,7 @@ pub fn expand_deriving_eq(cx: ext_ctxt,
pub fn expand_deriving_iter_bytes(cx: ext_ctxt,
span: span,
_mitem: meta_item,
_mitem: @meta_item,
in_items: ~[@item])
-> ~[@item] {
expand_deriving(cx,

View file

@ -227,7 +227,7 @@ pub impl ext_ctxt_ast_builder for ext_ctxt {
// Rust coding conventions
let non_camel_case_attribute = respan(dummy_sp(), ast::attribute_ {
style: ast::attr_outer,
value: respan(dummy_sp(),
value: @respan(dummy_sp(),
ast::meta_list(@~"allow", ~[
@respan(dummy_sp(),
ast::meta_word(

View file

@ -98,7 +98,7 @@ fn fold_attribute_(at: attribute, fld: ast_fold) -> attribute {
spanned {
node: ast::attribute_ {
style: at.node.style,
value: *fold_meta_item_(@at.node.value, fld),
value: fold_meta_item_(at.node.value, fld),
is_sugared_doc: at.node.is_sugared_doc,
},
span: fld.new_span(at.span),

View file

@ -72,7 +72,7 @@ impl parser_attr for Parser {
self.expect(token::RBRACKET);
let mut hi = self.span.hi;
return spanned(lo, hi, ast::attribute_ { style: style,
value: *meta_item,
value: meta_item,
is_sugared_doc: false });
}

View file

@ -904,7 +904,7 @@ pub fn print_attribute(s: @ps, attr: ast::attribute) {
word(s.s, *comment);
} else {
word(s.s, ~"#[");
print_meta_item(s, @attr.node.value);
print_meta_item(s, attr.node.value);
word(s.s, ~"]");
}
}