forked from AbleOS/ableos
k
This commit is contained in:
parent
ce81658f3e
commit
df423d0b79
|
@ -2,7 +2,7 @@ use {
|
||||||
crate::{
|
crate::{
|
||||||
codegen,
|
codegen,
|
||||||
ident::{self, Ident},
|
ident::{self, Ident},
|
||||||
lexer::{Lexer, LineMap, Token, TokenKind},
|
lexer::{self, Lexer, LineMap, Token, TokenKind},
|
||||||
log,
|
log,
|
||||||
},
|
},
|
||||||
std::{
|
std::{
|
||||||
|
@ -874,8 +874,8 @@ impl<'a> std::fmt::Display for Expr<'a> {
|
||||||
Consecutive => Expr::UnOp { .. },
|
Consecutive => Expr::UnOp { .. },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let source = unsafe { &*FMT_SOURCE.with(|s| s.get()) };
|
||||||
{
|
{
|
||||||
let source = unsafe { &*FMT_SOURCE.with(|s| s.get()) };
|
|
||||||
let pos = self.pos();
|
let pos = self.pos();
|
||||||
|
|
||||||
if let Some(before) = source.get(..pos as usize) {
|
if let Some(before) = source.get(..pos as usize) {
|
||||||
|
@ -959,11 +959,17 @@ impl<'a> std::fmt::Display for Expr<'a> {
|
||||||
writeln!(f)?;
|
writeln!(f)?;
|
||||||
INDENT.with(|i| i.set(i.get() + 1));
|
INDENT.with(|i| i.set(i.get() + 1));
|
||||||
let res = (|| {
|
let res = (|| {
|
||||||
for stmt in stmts {
|
for (i, stmt) in stmts.iter().enumerate() {
|
||||||
for _ in 0..INDENT.with(|i| i.get()) {
|
for _ in 0..INDENT.with(|i| i.get()) {
|
||||||
write!(f, "\t")?;
|
write!(f, "\t")?;
|
||||||
}
|
}
|
||||||
writeln!(f, "{stmt};")?;
|
write!(f, "{stmt}")?;
|
||||||
|
if let Some(expr) = stmts.get(i + 1)
|
||||||
|
&& let Some(rest) = source.get(expr.pos() as usize..)
|
||||||
|
&& lexer::Lexer::new(rest).next().kind.precedence().is_some()
|
||||||
|
{
|
||||||
|
write!(f, ";")?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Reference in a new issue