about summary refs log tree commit diff
path: root/src/comp
diff options
context:
space:
mode:
authorTim Chevalier <chevalier@alum.wellesley.edu>2011-05-18 15:38:38 -0700
committerGraydon Hoare <graydon@mozilla.com>2011-05-19 11:40:16 -0700
commit0d429a76032dc81b5c6660be180bea76a75eb3f4 (patch)
treeb67a52f3745cc969ee722b4446295e06180749e1 /src/comp
parent60399ed198ce5a86f386e8114e202937fbe670ed (diff)
downloadrust-0d429a76032dc81b5c6660be180bea76a75eb3f4.tar.gz
rust-0d429a76032dc81b5c6660be180bea76a75eb3f4.zip
add a bunch more logging things
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/util/common.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/comp/util/common.rs b/src/comp/util/common.rs
index deb73c84a7c..8d62e27f5bc 100644
--- a/src/comp/util/common.rs
+++ b/src/comp/util/common.rs
@@ -4,6 +4,7 @@ import std::uint;
 import std::int;
 import std::vec;
 import std::option::none;
+import std::option::some;
 import front::ast;
 import front::ast::ty;
 import front::ast::pat;
@@ -16,6 +17,7 @@ import std::io::stdout;
 import std::io::str_writer;
 import std::io::string_writer;
 import pretty::pprust::print_block;
+import pretty::pprust::print_item;
 import pretty::pprust::print_expr;
 import pretty::pprust::print_decl;
 import pretty::pprust::print_fn;
@@ -171,6 +173,17 @@ fn block_to_str(&ast::block b) -> str {
   ret s.get_str();
 }
 
+fn item_to_str(&@ast::item i) -> str {
+  let str_writer s = string_writer();
+  auto out_ = mkstate(s.get_writer(), 80u);
+  auto out = @rec(s=out_,
+                  comments=none[vec[front::lexer::cmnt]],
+                  mutable cur_cmnt=0u);
+
+  print_item(out, i);
+  ret s.get_str();
+}
+
 fn log_block(&ast::block b) -> () {
     log(block_to_str(b));
 }
@@ -179,6 +192,21 @@ fn log_block_err(&ast::block b) -> () {
     log_err(block_to_str(b));
 }
 
+fn log_item_err(&@ast::item i) -> () {
+    log_err(item_to_str(i));
+}
+
+fn log_ann(&ast::ann a) -> () {
+    alt (a) {
+        case (ast::ann_none(_)) {
+            log("ann_none");
+        }
+        case (ast::ann_type(_,_,_,_)) {
+            log("ann_type");
+        }
+    }
+}
+
 fn fun_to_str(&ast::_fn f, str name, vec[ast::ty_param] params) -> str {
  let str_writer s = string_writer();
   auto out_ = mkstate(s.get_writer(), 80u);
@@ -286,6 +314,13 @@ fn has_nonlocal_exits(&ast::block b) -> bool {
     ret (has_exits.size() > 0u);
 }
 
+fn local_rhs_span(&@ast::local l, &ast::span def) -> ast::span {
+    alt (l.init) {
+        case (some[ast::initializer](?i)) { ret i.expr.span; }
+        case (_) { ret def; }
+    }
+}
+
 //
 // Local Variables:
 // mode: rust