Clean up pretty printing and work on logging.
This commit is contained in:
@@ -83,7 +83,7 @@ impl<M: Module> Backend<M> {
|
||||
true,
|
||||
false,
|
||||
)?;
|
||||
println!("defining {} with primitive type {}", top_level_name, pt);
|
||||
tracing::info!(name = %top_level_name, data_type = %pt, "defining top-level data");
|
||||
self.module.define_data(data_id, &pt.blank_data())?;
|
||||
self.defined_symbols
|
||||
.insert(top_level_name, (data_id, pt.into()));
|
||||
@@ -125,7 +125,7 @@ impl<M: Module> Backend<M> {
|
||||
argument_types: Vec<Type>,
|
||||
return_type: Type,
|
||||
) -> Result<FuncId, cranelift_module::ModuleError> {
|
||||
println!("Declaring {:?} function {}", linkage, name);
|
||||
tracing::info!(linkage = ?linkage, name, "Declaring function");
|
||||
let basic_signature = Signature {
|
||||
params: argument_types
|
||||
.iter()
|
||||
@@ -148,6 +148,7 @@ impl<M: Module> Backend<M> {
|
||||
}
|
||||
|
||||
/// Compile the given function.
|
||||
#[tracing::instrument(level = "debug", skip(self, variables, body))]
|
||||
pub fn compile_function(
|
||||
&mut self,
|
||||
variables: &mut HashMap<Variable, ReferenceBuilder>,
|
||||
@@ -156,22 +157,6 @@ impl<M: Module> Backend<M> {
|
||||
return_type: Type,
|
||||
body: Expression<Type>,
|
||||
) -> Result<FuncId, BackendError> {
|
||||
println!("Compiling function {}", function_name);
|
||||
{
|
||||
use pretty::{DocAllocator, Pretty};
|
||||
let allocator = pretty::BoxAllocator;
|
||||
allocator
|
||||
.text("Function body:")
|
||||
.append(allocator.hardline())
|
||||
.append(body.pretty(&allocator))
|
||||
.append(allocator.hardline())
|
||||
.1
|
||||
.render_colored(
|
||||
70,
|
||||
pretty::termcolor::StandardStream::stdout(pretty::termcolor::ColorChoice::Auto),
|
||||
)
|
||||
.expect("rendering works");
|
||||
}
|
||||
// reset the next variable counter. this value shouldn't matter; hopefully
|
||||
// we won't be using close to 2^32 variables!
|
||||
self.reset_local_variable_tracker();
|
||||
|
||||
Reference in New Issue
Block a user