libsyntax: Make float literals not use @str

This commit is contained in:
Patrick Walton
2014-01-15 17:15:39 -08:00
committed by Huon Wilson
parent 8d6ef2e1b1
commit b496d7bec2
7 changed files with 24 additions and 20 deletions

View File

@@ -728,8 +728,8 @@ pub enum Lit_ {
LitInt(i64, IntTy),
LitUint(u64, UintTy),
LitIntUnsuffixed(i64),
LitFloat(@str, FloatTy),
LitFloatUnsuffixed(@str),
LitFloat(InternedString, FloatTy),
LitFloatUnsuffixed(InternedString),
LitNil,
LitBool(bool),
}

View File

@@ -29,12 +29,11 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
match e.node {
ast::ExprLit(lit) => {
match lit.node {
ast::LitStr(ref s, _) => {
ast::LitStr(ref s, _) |
ast::LitFloat(ref s, _) |
ast::LitFloatUnsuffixed(ref s) => {
accumulator.push_str(s.get());
}
ast::LitFloat(s, _) | ast::LitFloatUnsuffixed(s) => {
accumulator.push_str(s);
}
ast::LitChar(c) => {
accumulator.push_char(char::from_u32(c).unwrap());
}

View File

@@ -1405,9 +1405,12 @@ impl Parser {
token::LIT_INT(i, it) => LitInt(i, it),
token::LIT_UINT(u, ut) => LitUint(u, ut),
token::LIT_INT_UNSUFFIXED(i) => LitIntUnsuffixed(i),
token::LIT_FLOAT(s, ft) => LitFloat(self.id_to_str(s), ft),
token::LIT_FLOAT_UNSUFFIXED(s) =>
LitFloatUnsuffixed(self.id_to_str(s)),
token::LIT_FLOAT(s, ft) => {
LitFloat(self.id_to_interned_str(s), ft)
}
token::LIT_FLOAT_UNSUFFIXED(s) => {
LitFloatUnsuffixed(self.id_to_interned_str(s))
}
token::LIT_STR(s) => {
LitStr(self.id_to_interned_str(s), ast::CookedStr)
}

View File

@@ -2202,10 +2202,10 @@ pub fn print_literal(s: &mut State, lit: &ast::Lit) {
word(&mut s.s, (i as u64).to_str_radix(10u));
}
}
ast::LitFloat(f, t) => {
word(&mut s.s, f.to_owned() + ast_util::float_ty_to_str(t));
ast::LitFloat(ref f, t) => {
word(&mut s.s, f.get() + ast_util::float_ty_to_str(t));
}
ast::LitFloatUnsuffixed(f) => word(&mut s.s, f),
ast::LitFloatUnsuffixed(ref f) => word(&mut s.s, f.get()),
ast::LitNil => word(&mut s.s, "()"),
ast::LitBool(val) => {
if val { word(&mut s.s, "true"); } else { word(&mut s.s, "false"); }