libsyntax: De-@str literal strings in the AST

This commit is contained in:
Patrick Walton
2014-01-10 14:02:36 -08:00
committed by Huon Wilson
parent 70c5a0fbf7
commit 8e52b85d5a
45 changed files with 432 additions and 275 deletions

View File

@@ -14,6 +14,7 @@ use ast;
use codemap;
use ext::base;
use ext::build::AstBuilder;
use parse::token;
pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
sp: codemap::Span,
@@ -28,8 +29,10 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
match e.node {
ast::ExprLit(lit) => {
match lit.node {
ast::LitStr(s, _) | ast::LitFloat(s, _)
| ast::LitFloatUnsuffixed(s) => {
ast::LitStr(ref s, _) => {
accumulator.push_str(s.get());
}
ast::LitFloat(s, _) | ast::LitFloatUnsuffixed(s) => {
accumulator.push_str(s);
}
ast::LitChar(c) => {
@@ -55,5 +58,5 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
}
}
}
return base::MRExpr(cx.expr_str(sp, accumulator.to_managed()));
base::MRExpr(cx.expr_str(sp, token::intern_and_get_ident(accumulator)))
}