diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2014-01-15 18:30:40 -0800 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2014-02-02 01:44:48 +1100 |
| commit | f9af11d6cc0266a5690897b4645d8cab2ed1115b (patch) | |
| tree | 5389d0af37aa4d5207ac8ea5890183d81bc81d16 /src/libsyntax | |
| parent | b496d7bec2a79feab092e6b4e251f7b0cee2a6a6 (diff) | |
libsyntax: Remove all `@str` from the AST
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/ext/asm.rs | 18 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 13 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 14 |
5 files changed, 35 insertions, 28 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 380641a8689..a8bbdbd60d3 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -898,11 +898,11 @@ pub enum AsmDialect { #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub struct InlineAsm { - asm: @str, + asm: InternedString, asm_str_style: StrStyle, - clobbers: @str, - inputs: ~[(@str, @Expr)], - outputs: ~[(@str, @Expr)], + clobbers: InternedString, + inputs: ~[(InternedString, @Expr)], + outputs: ~[(InternedString, @Expr)], volatile: bool, alignstack: bool, dialect: AsmDialect @@ -1075,7 +1075,7 @@ pub enum ViewItem_ { // optional @str: if present, this is a location (containing // arbitrary characters) from which to fetch the crate sources // For example, extern mod whatever = "github.com/mozilla/rust" - ViewItemExternMod(Ident, Option<(@str, StrStyle)>, NodeId), + ViewItemExternMod(Ident, Option<(InternedString,StrStyle)>, NodeId), ViewItemUse(~[@ViewPath]), } diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs index babf0f13874..1a3ebf3ce5d 100644 --- a/src/libsyntax/ext/asm.rs +++ b/src/libsyntax/ext/asm.rs @@ -80,10 +80,10 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) let (constraint, _str_style) = p.parse_str(); - if constraint.starts_with("+") { + if constraint.get().starts_with("+") { cx.span_unimpl(p.last_span, "'+' (read+write) output operand constraint modifier"); - } else if !constraint.starts_with("=") { + } else if !constraint.get().starts_with("=") { cx.span_err(p.last_span, "output operand constraint lacks '='"); } @@ -105,9 +105,9 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) let (constraint, _str_style) = p.parse_str(); - if constraint.starts_with("=") { + if constraint.get().starts_with("=") { cx.span_err(p.last_span, "input operand constraint contains '='"); - } else if constraint.starts_with("+") { + } else if constraint.get().starts_with("+") { cx.span_err(p.last_span, "input operand constraint contains '+'"); } @@ -138,11 +138,11 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) Options => { let (option, _str_style) = p.parse_str(); - if "volatile" == option { + if option.equiv(&("volatile")) { volatile = true; - } else if "alignstack" == option { + } else if option.equiv(&("alignstack")) { alignstack = true; - } else if "intel" == option { + } else if option.equiv(&("intel")) { dialect = ast::AsmIntel; } @@ -192,9 +192,9 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) MRExpr(@ast::Expr { id: ast::DUMMY_NODE_ID, node: ast::ExprInlineAsm(ast::InlineAsm { - asm: asm.get().to_managed(), + asm: token::intern_and_get_ident(asm.get()), asm_str_style: asm_str_style.unwrap(), - clobbers: cons.to_managed(), + clobbers: token::intern_and_get_ident(cons), inputs: inputs, outputs: outputs, volatile: volatile, diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 9a346e17d28..f41d508f07d 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -814,8 +814,12 @@ pub fn noop_fold_expr<T: Folder>(e: @Expr, folder: &mut T) -> @Expr { } ExprInlineAsm(ref a) => { ExprInlineAsm(InlineAsm { - inputs: a.inputs.map(|&(c, input)| (c, folder.fold_expr(input))), - outputs: a.outputs.map(|&(c, out)| (c, folder.fold_expr(out))), + inputs: a.inputs.map(|&(ref c, input)| { + ((*c).clone(), folder.fold_expr(input)) + }), + outputs: a.outputs.map(|&(ref c, out)| { + ((*c).clone(), folder.fold_expr(out)) + }), .. (*a).clone() }) } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index e86873d6418..07124120b12 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -5130,17 +5130,20 @@ impl Parser { } } - pub fn parse_optional_str(&mut self) -> Option<(@str, ast::StrStyle)> { + pub fn parse_optional_str(&mut self) + -> Option<(InternedString, ast::StrStyle)> { let (s, style) = match self.token { - token::LIT_STR(s) => (s, ast::CookedStr), - token::LIT_STR_RAW(s, n) => (s, ast::RawStr(n)), + token::LIT_STR(s) => (self.id_to_interned_str(s), ast::CookedStr), + token::LIT_STR_RAW(s, n) => { + (self.id_to_interned_str(s), ast::RawStr(n)) + } _ => return None }; self.bump(); - Some((ident_to_str(&s), style)) + Some((s, style)) } - pub fn parse_str(&mut self) -> (@str, StrStyle) { + pub fn parse_str(&mut self) -> (InternedString, StrStyle) { match self.parse_optional_str() { Some(s) => { s } _ => self.fatal("expected string literal") diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index d2a388cc14d..2761cc4ea56 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1466,25 +1466,25 @@ pub fn print_expr(s: &mut State, expr: &ast::Expr) { word(&mut s.s, "asm!"); } popen(s); - print_string(s, a.asm, a.asm_str_style); + print_string(s, a.asm.get(), a.asm_str_style); word_space(s, ":"); - for &(co, o) in a.outputs.iter() { - print_string(s, co, ast::CookedStr); + for &(ref co, o) in a.outputs.iter() { + print_string(s, co.get(), ast::CookedStr); popen(s); print_expr(s, o); pclose(s); word_space(s, ","); } word_space(s, ":"); - for &(co, o) in a.inputs.iter() { - print_string(s, co, ast::CookedStr); + for &(ref co, o) in a.inputs.iter() { + print_string(s, co.get(), ast::CookedStr); popen(s); print_expr(s, o); pclose(s); word_space(s, ","); } word_space(s, ":"); - print_string(s, a.clobbers, ast::CookedStr); + print_string(s, a.clobbers.get(), ast::CookedStr); pclose(s); } ast::ExprMac(ref m) => print_mac(s, m), @@ -1998,7 +1998,7 @@ pub fn print_view_item(s: &mut State, item: &ast::ViewItem) { space(&mut s.s); word(&mut s.s, "="); space(&mut s.s); - print_string(s, *p, style); + print_string(s, p.get(), style); } } |
