summaryrefslogtreecommitdiff
path: root/lib/libproc_macro
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2017-11-18 17:33:44 +0800
committerJohn Hodge <tpg@ucc.asn.au>2017-11-18 17:47:12 +0800
commita5134d18945a823a5995f26ebc05359bc9f33b34 (patch)
tree3c0e04fab055fb31767b28175cfda9053be86389 /lib/libproc_macro
parenta2db789d465cd0306e1d87335ddb23c6021fab4e (diff)
downloadmrust-a5134d18945a823a5995f26ebc05359bc9f33b34.tar.gz
libproc_macro - Hacky debugging prints
Diffstat (limited to 'lib/libproc_macro')
-rw-r--r--lib/libproc_macro/src/lib.rs31
1 files changed, 26 insertions, 5 deletions
diff --git a/lib/libproc_macro/src/lib.rs b/lib/libproc_macro/src/lib.rs
index 7a3f1bdf..6de1140e 100644
--- a/lib/libproc_macro/src/lib.rs
+++ b/lib/libproc_macro/src/lib.rs
@@ -1,7 +1,26 @@
// MRustC custom version of libproc_macro
//
// Unlike the rustc version, this one is designed to live complely detached from its compiler.
-// See the
+
+//#[macro_use]
+//extern crate log;
+//extern crate env_logger;
+
+macro_rules! debug {
+ ( $($t:tt)* ) => {
+ if ::std::env::var_os("MRUSTC_PM_DEBUG").is_some() {
+ eprintln!($($t)*)
+ }
+ }
+}
+macro_rules! note {
+ ( $($t:tt)* ) => {
+ if ::std::env::var_os("MRUSTC_PM_DEBUG").is_some() {
+ eprintln!($($t)*)
+ }
+ }
+}
+
use std::fmt;
use std::str::FromStr;
@@ -646,6 +665,8 @@ pub struct MacroDesc
pub fn main(macros: &[MacroDesc])
{
+ //::env_logger::init();
+
let mac_name = ::std::env::args().nth(1).expect("Was not passed a macro name");
//eprintln!("Searching for macro {}\r", mac_name);
for m in macros
@@ -654,13 +675,13 @@ pub fn main(macros: &[MacroDesc])
use std::io::Write;
::std::io::stdout().write(&[0]);
::std::io::stdout().flush();
- //eprintln!("Waiting for input\r");
+ debug!("Waiting for input\r");
let input = recv_token_stream();
- //eprintln!("INPUT = `{}`\r", input);
+ debug!("INPUT = `{}`\r", input);
let output = (m.handler)( input );
- //eprintln!("OUTPUT = `{}`\r", output);
+ debug!("OUTPUT = `{}`\r", output);
send_token_stream(output);
- //eprintln!("Done");
+ note!("Done");
return ;
}
}