track f64 offsets in Literal (#1190)
This commit is contained in:
@@ -533,10 +533,17 @@ pub enum Literal {
|
||||
Fixnum(Fixnum),
|
||||
Integer(TypedArenaPtr<Integer>),
|
||||
Rational(TypedArenaPtr<Rational>),
|
||||
Float(F64Ptr),
|
||||
Float(F64Offset),
|
||||
String(Atom),
|
||||
}
|
||||
|
||||
impl From<F64Ptr> for Literal {
|
||||
#[inline(always)]
|
||||
fn from(ptr: F64Ptr) -> Literal {
|
||||
Literal::Float(ptr.as_offset())
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Literal {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
|
||||
@@ -633,7 +633,7 @@ impl<'a, R: CharRead> Lexer<'a, R> {
|
||||
fn vacate_with_float(&mut self, mut token: String) -> Result<Token, ParserError> {
|
||||
self.return_char(token.pop().unwrap());
|
||||
let n = parse_lossy::<f64, _>(token.as_bytes())?;
|
||||
Ok(Token::Literal(Literal::Float(float_alloc!(n, self.machine_st.arena))))
|
||||
Ok(Token::Literal(Literal::from(float_alloc!(n, self.machine_st.arena))))
|
||||
}
|
||||
|
||||
fn skip_underscore_in_number(&mut self) -> Result<char, ParserError> {
|
||||
@@ -744,7 +744,7 @@ impl<'a, R: CharRead> Lexer<'a, R> {
|
||||
}
|
||||
|
||||
let n = parse_lossy::<f64, _>(token.as_bytes())?;
|
||||
Ok(Token::Literal(Literal::Float(
|
||||
Ok(Token::Literal(Literal::from(
|
||||
float_alloc!(n, self.machine_st.arena)
|
||||
)))
|
||||
} else {
|
||||
@@ -752,7 +752,7 @@ impl<'a, R: CharRead> Lexer<'a, R> {
|
||||
}
|
||||
} else {
|
||||
let n = parse_lossy::<f64, _>(token.as_bytes())?;
|
||||
Ok(Token::Literal(Literal::Float(
|
||||
Ok(Token::Literal(Literal::from(
|
||||
float_alloc!(n, self.machine_st.arena)
|
||||
)))
|
||||
}
|
||||
|
||||
@@ -949,9 +949,9 @@ impl<'a, R: CharRead> Parser<'a, R> {
|
||||
self.negate_number(n, negate_rc, |r, _| Literal::Rational(r))
|
||||
}
|
||||
Token::Literal(Literal::Float(n)) => self.negate_number(
|
||||
**n,
|
||||
**n.as_ptr(),
|
||||
|n| -n,
|
||||
|n, arena| Literal::Float(float_alloc!(n, arena))
|
||||
|n, arena| Literal::from(float_alloc!(n, arena)),
|
||||
),
|
||||
Token::Literal(c) => {
|
||||
if let Some(name) = atomize_constant(&mut self.lexer.machine_st.atom_tbl, c) {
|
||||
|
||||
Reference in New Issue
Block a user