Add a print-cfg subcommand.

The command returns parses a .cton file, builds a CFG, and prints it to
stdout in graphviz format.
This commit is contained in:
Morgan Phillips
2016-07-13 14:31:05 -07:00
parent 83279026ba
commit 4a6e53f90d
2 changed files with 174 additions and 0 deletions

View File

@@ -11,12 +11,14 @@ use std::process;
mod cat;
mod print_cfg;
const USAGE: &'static str = "
Cretonne code generator utility
Usage:
cton-util cat <file>...
cton-util print-cfg <file>...
cton-util --help | --version
Options:
@@ -28,6 +30,7 @@ Options:
#[derive(RustcDecodable, Debug)]
struct Args {
cmd_cat: bool,
cmd_print_cfg: bool,
arg_file: Vec<String>,
}
@@ -48,6 +51,8 @@ fn cton_util() -> CommandResult {
// Find the sub-command to execute.
if args.cmd_cat {
cat::run(args.arg_file)
} else if args.cmd_print_cfg {
print_cfg::run(args.arg_file)
} else {
// Debugging / shouldn't happen with proper command line handling above.
Err(format!("Unhandled args: {:?}", args))