Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions crates/plotnik-cli/src/commands/debug/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,9 @@ pub fn run(args: DebugArgs) {

let show_query = has_query_input && !args.symbols && !args.graph && !args.types;
let show_source = has_source_input;
let show_headers = (show_query || args.symbols) && show_source;
let show_both_graphs = args.graph_raw && args.graph;

if show_query && let Some(ref q) = query {
if show_headers {
println!("=== QUERY ===");
}
print!(
"{}",
q.printer()
Expand All @@ -76,9 +73,6 @@ pub fn run(args: DebugArgs) {
if args.symbols
&& let Some(ref q) = query
{
if show_headers {
println!("=== SYMBOLS ===");
}
print!(
"{}",
q.printer()
Expand All @@ -93,28 +87,40 @@ pub fn run(args: DebugArgs) {
&& let Some(q) = query.take()
{
let (q, pre_opt_dump) = q.build_graph_with_pre_opt_dump();
let mut needs_separator = false;
if args.graph_raw {
println!("=== GRAPH (raw) ===");
if show_both_graphs {
println!("(pre-optimization)");
}
print!("{}", pre_opt_dump);
needs_separator = true;
}
if args.graph {
println!("=== GRAPH ===");
if needs_separator {
println!();
}
if show_both_graphs {
println!("(post-optimization)");
}
print!("{}", q.graph().dump_live(q.dead_nodes()));
needs_separator = true;
}
if args.types {
println!("=== TYPES ===");
if needs_separator {
println!();
}
print!("{}", q.type_info().dump());
}
return;
}

if show_source {
if show_query || args.symbols {
println!();
}
let resolved_lang = resolve_lang(&args.lang, &args.source_text, &args.source_file);
let source_code = load_source(&args.source_text, &args.source_file);
let tree = parse_tree(&source_code, resolved_lang);
if show_headers {
println!("=== SOURCE ===");
}
print!("{}", dump_source(&tree, &source_code, args.raw));
}

Expand Down
4 changes: 2 additions & 2 deletions crates/plotnik-lib/src/ir/emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use super::{
};

use crate::query::graph::{BuildEffect, BuildGraph, BuildMatcher, BuildNode, RefMarker};
use crate::query::typing::TypeInferenceResult;
use crate::query::infer::TypeInferenceResult;

/// Callback for resolving node kind names to IDs.
pub trait NodeKindResolver {
Expand Down Expand Up @@ -727,7 +727,7 @@ impl<'src, 'g, R: NodeKindResolver> QueryEmitter<'src, 'g, R> {
mod tests {
use super::*;
use crate::query::graph::{BuildEffect, BuildGraph, BuildMatcher, BuildNode};
use crate::query::typing::TypeInferenceResult;
use crate::query::infer::TypeInferenceResult;
use std::num::NonZeroU16;

fn make_resolver() -> MapResolver {
Expand Down
Loading