mirror of
https://github.com/fluencelabs/aquavm
synced 2024-12-04 23:20:18 +00:00
fix(air-beautifier): print fold's last_instruction (#630)
It was not printed before by mistake.
This commit is contained in:
parent
75f5516c58
commit
adcf708c95
@ -31,7 +31,6 @@ macro_rules! multiline {
|
||||
}
|
||||
$crate::beautifier::Beautifier::beautify_walker($beautifier, $nest, $indent + indent_step)?;
|
||||
)+
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
||||
@ -183,7 +182,8 @@ impl<W: io::Write> Beautifier<W> {
|
||||
&par.0;
|
||||
"|"; // TODO: SHOULD BE UNINDENTED AS PER SPEC; OR WE MAY CHANGE THE SPEC
|
||||
&par.1
|
||||
)
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn beautify_xor(&mut self, xor: &ast::Xor<'_>, indent: usize) -> io::Result<()> {
|
||||
@ -193,15 +193,18 @@ impl<W: io::Write> Beautifier<W> {
|
||||
&xor.0;
|
||||
"catch:";
|
||||
&xor.1
|
||||
)
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn beautify_match(&mut self, match_: &ast::Match<'_>, indent: usize) -> io::Result<()> {
|
||||
compound!(self, indent, match_)
|
||||
compound!(self, indent, match_);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn beautify_mismatch(&mut self, mismatch: &ast::MisMatch<'_>, indent: usize) -> io::Result<()> {
|
||||
compound!(self, indent, mismatch)
|
||||
compound!(self, indent, mismatch);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn beautify_fold_scalar(
|
||||
@ -209,7 +212,14 @@ impl<W: io::Write> Beautifier<W> {
|
||||
fold: &ast::FoldScalar<'_>,
|
||||
indent: usize,
|
||||
) -> io::Result<()> {
|
||||
compound!(self, indent, fold)
|
||||
compound!(self, indent, fold);
|
||||
if let Some(last_instruction) = &fold.last_instruction {
|
||||
multiline!(
|
||||
self, indent;
|
||||
"last:";
|
||||
last_instruction);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn beautify_fold_stream(
|
||||
@ -217,7 +227,15 @@ impl<W: io::Write> Beautifier<W> {
|
||||
fold: &ast::FoldStream<'_>,
|
||||
indent: usize,
|
||||
) -> io::Result<()> {
|
||||
compound!(self, indent, fold)
|
||||
compound!(self, indent, fold);
|
||||
if let Some(last_instruction) = &fold.last_instruction {
|
||||
multiline!(
|
||||
self, indent;
|
||||
"last:";
|
||||
last_instruction
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn beautify_fold_stream_map(
|
||||
@ -225,10 +243,19 @@ impl<W: io::Write> Beautifier<W> {
|
||||
fold: &ast::FoldStreamMap<'_>,
|
||||
indent: usize,
|
||||
) -> io::Result<()> {
|
||||
compound!(self, indent, fold)
|
||||
compound!(self, indent, fold);
|
||||
if let Some(last_instruction) = &fold.last_instruction {
|
||||
multiline!(
|
||||
self, indent;
|
||||
"last:";
|
||||
last_instruction
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn beautify_new(&mut self, new: &ast::New<'_>, indent: usize) -> io::Result<()> {
|
||||
compound!(self, indent, new)
|
||||
compound!(self, indent, new);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -240,6 +240,22 @@ fold var i:
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fold_scalar_with_last_instruction() {
|
||||
let script = r#"(seq (call "it" ("" "") [] var) (fold var i (null) (never)))"#;
|
||||
let output = beautify_to_string(script).unwrap();
|
||||
|
||||
assert_eq!(
|
||||
output,
|
||||
r#"var <- call "it" ("", "") []
|
||||
fold var i:
|
||||
null
|
||||
last:
|
||||
never
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fold_stream() {
|
||||
let script = r#"(seq (call "it" ("" "") [] $var) (fold $var i (null)))"#;
|
||||
@ -254,6 +270,22 @@ fold $var i:
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fold_stream_with_last_instruction() {
|
||||
let script = r#"(seq (call "it" ("" "") [] $var) (fold $var i (never) (null)))"#;
|
||||
let output = beautify_to_string(script).unwrap();
|
||||
|
||||
assert_eq!(
|
||||
output,
|
||||
r#"$var <- call "it" ("", "") []
|
||||
fold $var i:
|
||||
never
|
||||
last:
|
||||
null
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn call_var() {
|
||||
let script = "(call \"{0}\" (\"a\" \"b\") [\"stream_1\" \"stream_2\"] streamvar)";
|
||||
|
Loading…
Reference in New Issue
Block a user