Change the log level to be an enum rather than an int
This allows for eliminating a match check.
This commit is contained in:
parent
73ffc7e700
commit
0a5f88a240
3 changed files with 10 additions and 6 deletions
|
@ -309,6 +309,10 @@ enum blk_check_mode { default_blk, unchecked_blk, unsafe_blk, }
|
|||
type expr = {id: node_id, callee_id: node_id, node: expr_, span: span};
|
||||
// Extra node ID is only used for index, assign_op, unary, binary
|
||||
|
||||
#[auto_serialize]
|
||||
enum log_level { error, debug, other }
|
||||
// 0 = error, 1 = debug, 2 = other
|
||||
|
||||
#[auto_serialize]
|
||||
enum alt_mode { alt_check, alt_exhaustive, }
|
||||
|
||||
|
@ -354,7 +358,7 @@ enum expr_ {
|
|||
expr_break(option<ident>),
|
||||
expr_again(option<ident>),
|
||||
expr_ret(option<@expr>),
|
||||
expr_log(int, @expr, @expr),
|
||||
expr_log(log_level, @expr, @expr),
|
||||
|
||||
/* just an assert */
|
||||
expr_assert(@expr),
|
||||
|
|
|
@ -947,7 +947,7 @@ struct parser {
|
|||
let lvl = self.parse_expr();
|
||||
self.expect(token::COMMA);
|
||||
let e = self.parse_expr();
|
||||
ex = expr_log(2, lvl, e);
|
||||
ex = expr_log(ast::other, lvl, e);
|
||||
hi = self.span.hi;
|
||||
self.expect(token::RPAREN);
|
||||
} else if self.eat_keyword(~"assert") {
|
||||
|
|
|
@ -1309,10 +1309,10 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
|
|||
}
|
||||
}
|
||||
ast::expr_log(lvl, lexp, expr) => {
|
||||
match check lvl {
|
||||
1 => { word_nbsp(s, ~"log"); print_expr(s, expr); }
|
||||
0 => { word_nbsp(s, ~"log_err"); print_expr(s, expr); }
|
||||
2 => {
|
||||
match lvl {
|
||||
ast::debug => { word_nbsp(s, ~"log"); print_expr(s, expr); }
|
||||
ast::error => { word_nbsp(s, ~"log_err"); print_expr(s, expr); }
|
||||
ast::other => {
|
||||
word_nbsp(s, ~"log");
|
||||
popen(s);
|
||||
print_expr(s, lexp);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue