diff options
| author | Graydon Hoare <graydon@mozilla.com> | 2011-12-22 14:42:52 -0800 |
|---|---|---|
| committer | Graydon Hoare <graydon@mozilla.com> | 2011-12-22 14:42:52 -0800 |
| commit | 8b580954fe140dd45db61d719a49065c3e31de95 (patch) | |
| tree | 265e743361e058682486713db96aadb2f3381b99 /src/comp/syntax | |
| parent | 3b610646317f3b2be49936dc113c684dc4910df6 (diff) | |
| download | rust-8b580954fe140dd45db61d719a49065c3e31de95.tar.gz rust-8b580954fe140dd45db61d719a49065c3e31de95.zip | |
Register snapshots and switch logging over to use of log_full or #error / #debug.
Diffstat (limited to 'src/comp/syntax')
| -rw-r--r-- | src/comp/syntax/ext/fmt.rs | 60 | ||||
| -rw-r--r-- | src/comp/syntax/parse/eval.rs | 6 | ||||
| -rw-r--r-- | src/comp/syntax/parse/lexer.rs | 22 | ||||
| -rw-r--r-- | src/comp/syntax/print/pp.rs | 44 |
4 files changed, 68 insertions, 64 deletions
diff --git a/src/comp/syntax/ext/fmt.rs b/src/comp/syntax/ext/fmt.rs index 3700ce2edfa..b91c19644bb 100644 --- a/src/comp/syntax/ext/fmt.rs +++ b/src/comp/syntax/ext/fmt.rs @@ -28,8 +28,8 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: span, arg: @ast::expr, expr_to_str(cx, args[0], "first argument to #fmt must be a " + "string literal."); let fmtspan = args[0].span; - log "Format string:"; - log fmt; + #debug("Format string:"); + log_full(core::debug, fmt); fn parse_fmt_err_(cx: ext_ctxt, sp: span, msg: str) -> ! { cx.span_fatal(sp, msg); } @@ -252,53 +252,57 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr]) } fn log_conv(c: conv) { alt c.param { - some(p) { log "param: " + int::to_str(p, 10u); } - _ { log "param: none"; } + some(p) { log_full(core::debug, "param: " + int::to_str(p, 10u)); } + _ { #debug("param: none"); } } for f: flag in c.flags { alt f { - flag_left_justify. { log "flag: left justify"; } - flag_left_zero_pad. { log "flag: left zero pad"; } - flag_space_for_sign. { log "flag: left space pad"; } - flag_sign_always. { log "flag: sign always"; } - flag_alternate. { log "flag: alternate"; } + flag_left_justify. { #debug("flag: left justify"); } + flag_left_zero_pad. { #debug("flag: left zero pad"); } + flag_space_for_sign. { #debug("flag: left space pad"); } + flag_sign_always. { #debug("flag: sign always"); } + flag_alternate. { #debug("flag: alternate"); } } } alt c.width { - count_is(i) { log "width: count is " + int::to_str(i, 10u); } + count_is(i) { log_full(core::debug, + "width: count is " + int::to_str(i, 10u)); } count_is_param(i) { - log "width: count is param " + int::to_str(i, 10u); + log_full(core::debug, + "width: count is param " + int::to_str(i, 10u)); } - count_is_next_param. { log "width: count is next param"; } - count_implied. { log "width: count is implied"; } + count_is_next_param. { #debug("width: count is next param"); } + count_implied. { #debug("width: count is implied"); } } alt c.precision { - count_is(i) { log "prec: count is " + int::to_str(i, 10u); } + count_is(i) { log_full(core::debug, + "prec: count is " + int::to_str(i, 10u)); } count_is_param(i) { - log "prec: count is param " + int::to_str(i, 10u); + log_full(core::debug, + "prec: count is param " + int::to_str(i, 10u)); } - count_is_next_param. { log "prec: count is next param"; } - count_implied. { log "prec: count is implied"; } + count_is_next_param. { #debug("prec: count is next param"); } + count_implied. { #debug("prec: count is implied"); } } alt c.ty { - ty_bool. { log "type: bool"; } - ty_str. { log "type: str"; } - ty_char. { log "type: char"; } + ty_bool. { #debug("type: bool"); } + ty_str. { #debug("type: str"); } + ty_char. { #debug("type: char"); } ty_int(s) { alt s { - signed. { log "type: signed"; } - unsigned. { log "type: unsigned"; } + signed. { #debug("type: signed"); } + unsigned. { #debug("type: unsigned"); } } } - ty_bits. { log "type: bits"; } + ty_bits. { #debug("type: bits"); } ty_hex(cs) { alt cs { - case_upper. { log "type: uhex"; } - case_lower. { log "type: lhex"; } + case_upper. { #debug("type: uhex"); } + case_lower. { #debug("type: lhex"); } } } - ty_octal. { log "type: octal"; } - ty_float. { log "type: float"; } + ty_octal. { #debug("type: octal"); } + ty_float. { #debug("type: float"); } } } let fmt_sp = args[0].span; @@ -318,7 +322,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr]) "not enough arguments to #fmt " + "for the given format string"); } - log "Building conversion:"; + #debug("Building conversion:"); log_conv(conv); let arg_expr = args[n]; let c_expr = make_new_conv(cx, fmt_sp, conv, arg_expr); diff --git a/src/comp/syntax/parse/eval.rs b/src/comp/syntax/parse/eval.rs index 2b0fcab9b8e..904b7698118 100644 --- a/src/comp/syntax/parse/eval.rs +++ b/src/comp/syntax/parse/eval.rs @@ -29,7 +29,7 @@ fn eval_crate_directives(cx: ctx, cdirs: [@ast::crate_directive], prefix: str, fn eval_crate_directives_to_mod(cx: ctx, cdirs: [@ast::crate_directive], prefix: str, suffix: option::t<str>) -> (ast::_mod, [ast::attribute]) { - log #fmt("eval crate prefix: %s", prefix); + #debug("eval crate prefix: %s", prefix); log #fmt("eval crate suffix: %s", option::from_maybe("none", suffix)); let (cview_items, citems, cattrs) @@ -72,9 +72,9 @@ fn parse_companion_mod(cx: ctx, prefix: str, suffix: option::t<str>) } let modpath = companion_file(prefix, suffix); - log #fmt("looking for companion mod %s", modpath); + #debug("looking for companion mod %s", modpath); if file_exists(modpath) { - log "found companion mod"; + #debug("found companion mod"); let p0 = new_parser_from_file(cx.sess, cx.cfg, modpath, cx.chpos, cx.byte_pos, SOURCE_FILE); let inner_attrs = parse_inner_attrs_and_next(p0); diff --git a/src/comp/syntax/parse/lexer.rs b/src/comp/syntax/parse/lexer.rs index 3529a512a89..9821f7bdfa9 100644 --- a/src/comp/syntax/parse/lexer.rs +++ b/src/comp/syntax/parse/lexer.rs @@ -560,7 +560,7 @@ fn consume_non_eol_whitespace(rdr: reader) { } fn push_blank_line_comment(rdr: reader, &comments: [cmnt]) { - log ">>> blank-line comment"; + #debug(">>> blank-line comment"); let v: [str] = []; comments += [{style: blank_line, lines: v, pos: rdr.get_chpos()}]; } @@ -575,16 +575,16 @@ fn consume_whitespace_counting_blank_lines(rdr: reader, &comments: [cmnt]) { } fn read_line_comments(rdr: reader, code_to_the_left: bool) -> cmnt { - log ">>> line comments"; + #debug(">>> line comments"); let p = rdr.get_chpos(); let lines: [str] = []; while rdr.curr() == '/' && rdr.next() == '/' { let line = read_one_line_comment(rdr); - log line; + log_full(core::debug, line); lines += [line]; consume_non_eol_whitespace(rdr); } - log "<<< line comments"; + #debug("<<< line comments"); ret {style: if code_to_the_left { trailing } else { isolated }, lines: lines, pos: p}; @@ -603,12 +603,12 @@ fn trim_whitespace_prefix_and_push_line(&lines: [str], s: str, col: uint) { s1 = str::slice(s, col, str::byte_len(s)); } else { s1 = ""; } } else { s1 = s; } - log "pushing line: " + s1; + log_full(core::debug, "pushing line: " + s1); lines += [s1]; } fn read_block_comment(rdr: reader, code_to_the_left: bool) -> cmnt { - log ">>> block comment"; + #debug(">>> block comment"); let p = rdr.get_chpos(); let lines: [str] = []; let col: uint = rdr.get_col(); @@ -617,7 +617,7 @@ fn read_block_comment(rdr: reader, code_to_the_left: bool) -> cmnt { let curr_line = "/*"; let level: int = 1; while level > 0 { - log #fmt["=== block comment level %d", level]; + #debug("=== block comment level %d", level); if rdr.is_eof() { rdr.err("unterminated block comment"); fail; } if rdr.curr() == '\n' { trim_whitespace_prefix_and_push_line(lines, curr_line, col); @@ -648,7 +648,7 @@ fn read_block_comment(rdr: reader, code_to_the_left: bool) -> cmnt { if !rdr.is_eof() && rdr.curr() != '\n' && vec::len(lines) == 1u { style = mixed; } - log "<<< block comment"; + #debug("<<< block comment"); ret {style: style, lines: lines, pos: p}; } @@ -658,13 +658,13 @@ fn peeking_at_comment(rdr: reader) -> bool { } fn consume_comment(rdr: reader, code_to_the_left: bool, &comments: [cmnt]) { - log ">>> consume comment"; + #debug(">>> consume comment"); if rdr.curr() == '/' && rdr.next() == '/' { comments += [read_line_comments(rdr, code_to_the_left)]; } else if rdr.curr() == '/' && rdr.next() == '*' { comments += [read_block_comment(rdr, code_to_the_left)]; } else { fail; } - log "<<< consume comment"; + #debug("<<< consume comment"); } fn is_lit(t: token::token) -> bool { @@ -707,7 +707,7 @@ fn gather_comments_and_literals(cm: codemap::codemap, path: str, if is_lit(tok.tok) { literals += [{lit: rdr.get_str_from(tok.bpos), pos: tok.chpos}]; } - log "tok: " + token::to_str(rdr, tok.tok); + log_full(core::debug, "tok: " + token::to_str(rdr, tok.tok)); first_read = false; } ret {cmnts: comments, lits: literals}; diff --git a/src/comp/syntax/print/pp.rs b/src/comp/syntax/print/pp.rs index b870f9f93da..556ce0b774a 100644 --- a/src/comp/syntax/print/pp.rs +++ b/src/comp/syntax/print/pp.rs @@ -101,7 +101,7 @@ fn mk_printer(out: io::writer, linewidth: uint) -> printer { // fall behind. let n: uint = 3u * linewidth; - log #fmt["mk_printer %u", linewidth]; + #debug("mk_printer %u", linewidth); let token: [mutable token] = vec::init_elt_mut(EOF, n); let size: [mutable int] = vec::init_elt_mut(0, n); let scan_stack: [mutable uint] = vec::init_elt_mut(0u, n); @@ -241,7 +241,7 @@ obj printer(out: io::writer, fn replace_last_token(t: token) { token[right] = t; } fn pretty_print(t: token) { - log #fmt["pp [%u,%u]", left, right]; + #debug("pp [%u,%u]", left, right); alt t { EOF. { if !scan_stack_empty { @@ -257,17 +257,17 @@ obj printer(out: io::writer, left = 0u; right = 0u; } else { self.advance_right(); } - log #fmt["pp BEGIN/buffer [%u,%u]", left, right]; + #debug("pp BEGIN/buffer [%u,%u]", left, right); token[right] = t; size[right] = -right_total; self.scan_push(right); } END. { if scan_stack_empty { - log #fmt["pp END/print [%u,%u]", left, right]; + #debug("pp END/print [%u,%u]", left, right); self.print(t, 0); } else { - log #fmt["pp END/buffer [%u,%u]", left, right]; + #debug("pp END/buffer [%u,%u]", left, right); self.advance_right(); token[right] = t; size[right] = -1; @@ -281,7 +281,7 @@ obj printer(out: io::writer, left = 0u; right = 0u; } else { self.advance_right(); } - log #fmt["pp BREAK/buffer [%u,%u]", left, right]; + #debug("pp BREAK/buffer [%u,%u]", left, right); self.check_stack(0); self.scan_push(right); token[right] = t; @@ -290,10 +290,10 @@ obj printer(out: io::writer, } STRING(s, len) { if scan_stack_empty { - log #fmt["pp STRING/print [%u,%u]", left, right]; + #debug("pp STRING/print [%u,%u]", left, right); self.print(t, len); } else { - log #fmt["pp STRING/buffer [%u,%u]", left, right]; + #debug("pp STRING/buffer [%u,%u]", left, right); self.advance_right(); token[right] = t; size[right] = len; @@ -311,7 +311,7 @@ obj printer(out: io::writer, right_total - left_total, space]; if !scan_stack_empty { if left == scan_stack[bottom] { - log #fmt["setting %u to infinity and popping", left]; + #debug("setting %u to infinity and popping", left); size[self.scan_pop_bottom()] = size_infinity; } } @@ -320,7 +320,7 @@ obj printer(out: io::writer, } } fn scan_push(x: uint) { - log #fmt["scan_push %u", x]; + #debug("scan_push %u", x); if scan_stack_empty { scan_stack_empty = false; } else { top += 1u; top %= buf_len; assert (top != bottom); } @@ -349,7 +349,7 @@ obj printer(out: io::writer, assert (right != left); } fn advance_left(x: token, L: int) { - log #fmt["advnce_left [%u,%u], sizeof(%u)=%d", left, right, left, L]; + #debug("advnce_left [%u,%u], sizeof(%u)=%d", left, right, left, L); if L >= 0 { self.print(x, L); alt x { @@ -388,13 +388,13 @@ obj printer(out: io::writer, } } fn print_newline(amount: int) { - log #fmt["NEWLINE %d", amount]; + #debug("NEWLINE %d", amount); out.write_str("\n"); pending_indentation = 0; self.indent(amount); } fn indent(amount: int) { - log #fmt["INDENT %d", amount]; + #debug("INDENT %d", amount); pending_indentation += amount; } fn top() -> print_stack_elt { @@ -413,20 +413,20 @@ obj printer(out: io::writer, fn print(x: token, L: int) { log #fmt["print %s %d (remaining line space=%d)", tok_str(x), L, space]; - log buf_str(token, size, left, right, 6u); + log_full(core::debug, buf_str(token, size, left, right, 6u)); alt x { BEGIN(b) { if L > space { let col = margin - space + b.offset; - log #fmt["print BEGIN -> push broken block at col %d", col]; + #debug("print BEGIN -> push broken block at col %d", col); print_stack += [{offset: col, pbreak: broken(b.breaks)}]; } else { - log "print BEGIN -> push fitting block"; + #debug("print BEGIN -> push fitting block"); print_stack += [{offset: 0, pbreak: fits}]; } } END. { - log "print END -> pop END"; + #debug("print END -> pop END"); assert (vec::len(print_stack) != 0u); vec::pop(print_stack); } @@ -434,22 +434,22 @@ obj printer(out: io::writer, let top = self.top(); alt top.pbreak { fits. { - log "print BREAK in fitting block"; + #debug("print BREAK in fitting block"); space -= b.blank_space; self.indent(b.blank_space); } broken(consistent.) { - log "print BREAK in consistent block"; + #debug("print BREAK in consistent block"); self.print_newline(top.offset + b.offset); space = margin - (top.offset + b.offset); } broken(inconsistent.) { if L > space { - log "print BREAK w/ newline in inconsistent"; + #debug("print BREAK w/ newline in inconsistent"); self.print_newline(top.offset + b.offset); space = margin - (top.offset + b.offset); } else { - log "print BREAK w/o newline in inconsistent"; + #debug("print BREAK w/o newline in inconsistent"); self.indent(b.blank_space); space -= b.blank_space; } @@ -457,7 +457,7 @@ obj printer(out: io::writer, } } STRING(s, len) { - log "print STRING"; + #debug("print STRING"); assert (L == len); // assert L <= space; |
