]> git.lizzy.rs Git - rust.git/commitdiff
libsyntax: Remove all `@str` from the AST
authorPatrick Walton <pcwalton@mimiga.net>
Thu, 16 Jan 2014 02:30:40 +0000 (18:30 -0800)
committerHuon Wilson <dbau.pp+github@gmail.com>
Sat, 1 Feb 2014 14:44:48 +0000 (01:44 +1100)
src/librustc/metadata/creader.rs
src/librustc/middle/trans/asm.rs
src/libsyntax/ast.rs
src/libsyntax/ext/asm.rs
src/libsyntax/fold.rs
src/libsyntax/parse/parser.rs
src/libsyntax/print/pprust.rs

index c43cf0a6ad79d26bd6e8d9bab6ad9dfe4d5135b8..56ede9dfce178bfc6a4730080b988df00e0a0626 100644 (file)
@@ -168,8 +168,8 @@ fn extract_crate_info(i: &ast::ViewItem) -> Option<CrateInfo> {
             debug!("resolving extern mod stmt. ident: {:?} path_opt: {:?}",
                    ident, path_opt);
             let (name, version) = match path_opt {
-                Some((path_str, _)) => {
-                    let crateid: Option<CrateId> = from_str(path_str);
+                Some((ref path_str, _)) => {
+                    let crateid: Option<CrateId> = from_str(path_str.get());
                     match crateid {
                         None => (@"", @""),
                         Some(crateid) => {
index bae35f68ada5630dd3e51edb4db1b6b358232356..db99bd53704ebd38f0628a24cfb571727a8ef98b 100644 (file)
@@ -38,8 +38,8 @@ pub fn trans_inline_asm<'a>(bcx: &'a Block<'a>, ia: &ast::InlineAsm)
     let temp_scope = fcx.push_custom_cleanup_scope();
 
     // Prepare the output operands
-    let outputs = ia.outputs.map(|&(c, out)| {
-        constraints.push(c);
+    let outputs = ia.outputs.map(|&(ref c, out)| {
+        constraints.push((*c).clone());
 
         let out_datum = unpack_datum!(bcx, expr::trans(bcx, out));
         output_types.push(type_of::type_of(bcx.ccx(), out_datum.ty));
@@ -48,8 +48,8 @@ pub fn trans_inline_asm<'a>(bcx: &'a Block<'a>, ia: &ast::InlineAsm)
     });
 
     // Now the input operands
-    let inputs = ia.inputs.map(|&(c, input)| {
-        constraints.push(c);
+    let inputs = ia.inputs.map(|&(ref c, input)| {
+        constraints.push((*c).clone());
 
         unpack_result!(bcx, {
             callee::trans_arg_expr(bcx,
@@ -63,13 +63,13 @@ pub fn trans_inline_asm<'a>(bcx: &'a Block<'a>, ia: &ast::InlineAsm)
     // no failure occurred preparing operands, no need to cleanup
     fcx.pop_custom_cleanup_scope(temp_scope);
 
-    let mut constraints = constraints.connect(",");
+    let mut constraints = constraints.map(|s| s.get().to_str()).connect(",");
 
     let mut clobbers = getClobbers();
-    if !ia.clobbers.is_empty() && !clobbers.is_empty() {
-        clobbers = format!("{},{}", ia.clobbers, clobbers);
+    if !ia.clobbers.get().is_empty() && !clobbers.is_empty() {
+        clobbers = format!("{},{}", ia.clobbers.get(), clobbers);
     } else {
-        clobbers.push_str(ia.clobbers);
+        clobbers.push_str(ia.clobbers.get());
     }
 
     // Add the clobbers to our constraints list
@@ -98,7 +98,7 @@ pub fn trans_inline_asm<'a>(bcx: &'a Block<'a>, ia: &ast::InlineAsm)
         ast::AsmIntel => lib::llvm::AD_Intel
     };
 
-    let r = ia.asm.with_c_str(|a| {
+    let r = ia.asm.get().with_c_str(|a| {
         constraints.with_c_str(|c| {
             InlineAsmCall(bcx, a, c, inputs, output_type, ia.volatile, ia.alignstack, dialect)
         })
index 380641a868968b68856b241079288ba0e3585cc9..a8bbdbd60d30551d10e4922e53e1a16e929899a7 100644 (file)
@@ -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]),
 }
 
index babf0f13874169d9d9a1a5c850cd489dcf2ad27f..1a3ebf3ce5d1cccdbd04140d1ec338f59cebcc02 100644 (file)
@@ -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,
index 9a346e17d287eb743121e92b9093f1c7d64bdd7e..f41d508f07d4ab554442e37be35e10c6fbc6c776 100644 (file)
@@ -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()
             })
         }
index e86873d64187744b8be7db4c2f4f1fd7ad9a3cf6..07124120b1248687886cf39bd449acea809bbb7c 100644 (file)
@@ -5130,17 +5130,20 @@ pub fn parse_crate_mod(&mut self) -> Crate {
         }
     }
 
-    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")
index d2a388cc14d9b0a27d7bc81dcfda057d7fc1ceb6..2761cc4ea56ecabed639c87a07ebf7be6be0f965 100644 (file)
@@ -1466,25 +1466,25 @@ fn print_field(s: &mut State, field: &ast::Field) {
             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);
             }
         }