ast: Actually format debug messages

Also fixes two format strings
This commit is contained in:
Fabian Boehm 2024-01-10 19:20:07 +01:00
parent b5ccacf5b5
commit 76ddfca420

View File

@ -10,7 +10,7 @@
* Most clients will be interested in visiting the nodes of an ast. * Most clients will be interested in visiting the nodes of an ast.
*/ */
use crate::common::{unescape_string, UnescapeStringStyle}; use crate::common::{unescape_string, UnescapeStringStyle};
use crate::flog::FLOG; use crate::flog::{FLOG, FLOGF};
use crate::parse_constants::{ use crate::parse_constants::{
token_type_user_presentable_description, ParseError, ParseErrorCode, ParseErrorList, token_type_user_presentable_description, ParseError, ParseErrorCode, ParseErrorList,
ParseKeyword, ParseTokenType, ParseTreeFlags, SourceRange, StatementDecoration, ParseKeyword, ParseTokenType, ParseTreeFlags, SourceRange, StatementDecoration,
@ -2622,7 +2622,7 @@ macro_rules! internal_error {
) )
$(, $args)* $(, $args)*
); );
FLOG!(debug, "Encountered while parsing:<<<<\n{}\n>>>", $self.tokens.src); FLOGF!(debug, "Encountered while parsing:<<<<\n{}\n>>>", $self.tokens.src);
panic!(); panic!();
}; };
} }
@ -2664,7 +2664,7 @@ macro_rules! parse_error_range {
if !$self.unwinding { if !$self.unwinding {
$self.unwinding = true; $self.unwinding = true;
FLOG!(ast_construction, "%*sparse error - begin unwinding", $self.spaces(), ""); FLOGF!(ast_construction, "%*sparse error - begin unwinding", $self.spaces(), "");
// TODO: can store this conditionally dependent on flags. // TODO: can store this conditionally dependent on flags.
if $range.start() != SOURCE_OFFSET_INVALID { if $range.start() != SOURCE_OFFSET_INVALID {
$self.errors.push($range); $self.errors.push($range);
@ -2797,9 +2797,9 @@ impl<'s> NodeVisitorMut for Populator<'s> {
} }
fn will_visit_fields_of(&mut self, node: &mut dyn NodeMut) { fn will_visit_fields_of(&mut self, node: &mut dyn NodeMut) {
FLOG!( FLOGF!(
ast_construction, ast_construction,
"%*swill_visit %ls %p", "%*swill_visit %ls",
self.spaces(), self.spaces(),
"", "",
node.describe() node.describe()
@ -3434,7 +3434,7 @@ impl<'s> Populator<'s> {
"exhaust_stream should only be set at top level, and so we should not be unwinding" "exhaust_stream should only be set at top level, and so we should not be unwinding"
); );
// Mark in the list that it was unwound. // Mark in the list that it was unwound.
FLOG!( FLOGF!(
ast_construction, ast_construction,
"%*sunwinding %ls", "%*sunwinding %ls",
self.spaces(), self.spaces(),
@ -3471,7 +3471,7 @@ impl<'s> Populator<'s> {
} }
let tok = self.tokens.pop(); let tok = self.tokens.pop();
self.errors.push(tok.range()); self.errors.push(tok.range());
FLOG!( FLOGF!(
ast_construction, ast_construction,
"%*schomping range %u-%u", "%*schomping range %u-%u",
self.spaces(), self.spaces(),
@ -3480,7 +3480,7 @@ impl<'s> Populator<'s> {
tok.source_length() tok.source_length()
); );
} }
FLOG!(ast_construction, "%*sdone unwinding", self.spaces(), ""); FLOGF!(ast_construction, "%*sdone unwinding", self.spaces(), "");
self.unwinding = false; self.unwinding = false;
} }
@ -3514,7 +3514,7 @@ impl<'s> Populator<'s> {
*list.contents_mut() = contents; *list.contents_mut() = contents;
} }
FLOG!( FLOGF!(
ast_construction, ast_construction,
"%*s%ls size: %lu", "%*s%ls size: %lu",
self.spaces(), self.spaces(),
@ -3693,9 +3693,9 @@ impl<'s> Populator<'s> {
/// \return the resulting Node /// \return the resulting Node
fn allocate<T: NodeMut + Default>(&self) -> Box<T> { fn allocate<T: NodeMut + Default>(&self) -> Box<T> {
let result = Box::<T>::default(); let result = Box::<T>::default();
FLOG!( FLOGF!(
ast_construction, ast_construction,
"%*smake %ls %p", "%*smake %ls %ls",
self.spaces(), self.spaces(),
"", "",
ast_type_to_string(result.typ()), ast_type_to_string(result.typ()),