Skip to content

Commit 0d429a7

Browse files
catamorphismgraydon
authored andcommitted
add a bunch more logging things
1 parent 60399ed commit 0d429a7

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/comp/util/common.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import std::uint;
44
import std::int;
55
import std::vec;
66
import std::option::none;
7+
import std::option::some;
78
import front::ast;
89
import front::ast::ty;
910
import front::ast::pat;
@@ -16,6 +17,7 @@ import std::io::stdout;
1617
import std::io::str_writer;
1718
import std::io::string_writer;
1819
import pretty::pprust::print_block;
20+
import pretty::pprust::print_item;
1921
import pretty::pprust::print_expr;
2022
import pretty::pprust::print_decl;
2123
import pretty::pprust::print_fn;
@@ -171,6 +173,17 @@ fn block_to_str(&ast::block b) -> str {
171173
ret s.get_str();
172174
}
173175

176+
fn item_to_str(&@ast::item i) -> str {
177+
let str_writer s = string_writer();
178+
auto out_ = mkstate(s.get_writer(), 80u);
179+
auto out = @rec(s=out_,
180+
comments=none[vec[front::lexer::cmnt]],
181+
mutable cur_cmnt=0u);
182+
183+
print_item(out, i);
184+
ret s.get_str();
185+
}
186+
174187
fn log_block(&ast::block b) -> () {
175188
log(block_to_str(b));
176189
}
@@ -179,6 +192,21 @@ fn log_block_err(&ast::block b) -> () {
179192
log_err(block_to_str(b));
180193
}
181194

195+
fn log_item_err(&@ast::item i) -> () {
196+
log_err(item_to_str(i));
197+
}
198+
199+
fn log_ann(&ast::ann a) -> () {
200+
alt (a) {
201+
case (ast::ann_none(_)) {
202+
log("ann_none");
203+
}
204+
case (ast::ann_type(_,_,_,_)) {
205+
log("ann_type");
206+
}
207+
}
208+
}
209+
182210
fn fun_to_str(&ast::_fn f, str name, vec[ast::ty_param] params) -> str {
183211
let str_writer s = string_writer();
184212
auto out_ = mkstate(s.get_writer(), 80u);
@@ -286,6 +314,13 @@ fn has_nonlocal_exits(&ast::block b) -> bool {
286314
ret (has_exits.size() > 0u);
287315
}
288316

317+
fn local_rhs_span(&@ast::local l, &ast::span def) -> ast::span {
318+
alt (l.init) {
319+
case (some[ast::initializer](?i)) { ret i.expr.span; }
320+
case (_) { ret def; }
321+
}
322+
}
323+
289324
//
290325
// Local Variables:
291326
// mode: rust

0 commit comments

Comments
 (0)