Merge all 3 log syntaxes, tidy up residual misuses.

This commit is contained in:
Graydon Hoare 2011-12-22 16:13:40 -08:00
parent f816d8c71c
commit 389329ef1e
26 changed files with 117 additions and 133 deletions

View file

@ -117,8 +117,8 @@ fn get_rpath_relative_to_output(os: session::os,
fn get_relative_to(abs1: fs::path, abs2: fs::path) -> fs::path {
assert fs::path_is_absolute(abs1);
assert fs::path_is_absolute(abs2);
log #fmt("finding relative path from %s to %s",
abs1, abs2);
#debug("finding relative path from %s to %s",
abs1, abs2);
let normal1 = fs::normalize(abs1);
let normal2 = fs::normalize(abs2);
let split1 = str::split(normal1, os_fs::path_sep as u8);

View file

@ -105,8 +105,8 @@ fn time<T>(do_it: bool, what: str, thunk: fn@() -> T) -> T {
let start = std::time::precise_time_s();
let rv = thunk();
let end = std::time::precise_time_s();
log_err #fmt["time: %s took %s s", what,
float::to_str(end - start, 3u)];
#error("time: %s took %s s", what,
float::to_str(end - start, 3u));
ret rv;
}

View file

@ -135,11 +135,11 @@ fn eq(a: @ast::meta_item, b: @ast::meta_item) -> bool {
}
fn contains(haystack: [@ast::meta_item], needle: @ast::meta_item) -> bool {
log #fmt["looking for %s",
syntax::print::pprust::meta_item_to_str(*needle)];
#debug("looking for %s",
syntax::print::pprust::meta_item_to_str(*needle));
for item: @ast::meta_item in haystack {
log #fmt["looking in %s",
syntax::print::pprust::meta_item_to_str(*item)];
#debug("looking in %s",
syntax::print::pprust::meta_item_to_str(*item));
if eq(item, needle) { #debug("found it!"); ret true; }
}
#debug("found it not :(");

View file

@ -104,8 +104,8 @@ fn metadata_matches(crate_data: @[u8], metas: [@ast::meta_item]) -> bool {
let attrs = decoder::get_crate_attributes(crate_data);
let linkage_metas = attr::find_linkage_metas(attrs);
log #fmt["matching %u metadata requirements against %u items",
vec::len(metas), vec::len(linkage_metas)];
#debug("matching %u metadata requirements against %u items",
vec::len(metas), vec::len(linkage_metas));
#debug("crate metadata:");
for have: @ast::meta_item in linkage_metas {
@ -178,8 +178,8 @@ fn find_library_crate_aux(sess: session::session,
#debug("inspecting file %s", path);
let f: str = fs::basename(path);
if !(str::starts_with(f, prefix) && str::ends_with(f, suffix)) {
log #fmt["skipping %s, doesn't look like %s*%s", path, prefix,
suffix];
#debug("skipping %s, doesn't look like %s*%s", path, prefix,
suffix);
option::none
} else {
#debug("%s is a candidate", path);

View file

@ -37,8 +37,8 @@ fn resolve_path(cstore: cstore::cstore, cnum: ast::crate_num,
path: [ast::ident]) ->
[(ast::crate_num, @[u8], ast::def_id)] {
let cm = cstore::get_crate_data(cstore, cnum);
log #fmt("resolve_path %s in crates[%d]:%s",
str::connect(path, "::"), cnum, cm.name);
#debug("resolve_path %s in crates[%d]:%s",
str::connect(path, "::"), cnum, cm.name);
let result = [];
for def in decoder::resolve_path(path, cm.data) {
if def.crate == ast::local_crate {

View file

@ -1393,9 +1393,8 @@ fn lookup_external(e: env, cnum: int, ids: [ident], ns: namespace) ->
let cname = cstore::get_crate_data(e.cstore, did.crate).name;
let name =
csearch::get_item_name(e.cstore, did.crate, did.node);
log #fmt("lookup_external: %s %d, %d, %s, %s", cname,
did.crate, did.node,
str::connect(ids, "::"), name);
#debug("lookup_external: %s %d, %d, %s, %s", cname,
did.crate, did.node, str::connect(ids, "::"), name);
e.ext_map.insert(did, vec::init(ids) + [name]);
} else {
e.ext_map.insert(did, ids);

View file

@ -205,8 +205,6 @@ fn type_of_inner(cx: @crate_ctxt, sp: span, t: ty::t)
T_opaque_closure(cx)
}
_ {
log_err ("type_of_inner not implemented for ",
ty::struct(cx.tcx, t));
fail "type_of_inner not implemented for this kind of type";
}
};
@ -1759,8 +1757,8 @@ fn lazily_emit_tydesc_glue(cx: @block_ctxt, field: int,
alt ti.take_glue {
some(_) { }
none. {
log #fmt["+++ lazily_emit_tydesc_glue TAKE %s",
ty_to_str(bcx_tcx(cx), ti.ty)];
#debug("+++ lazily_emit_tydesc_glue TAKE %s",
ty_to_str(bcx_tcx(cx), ti.ty));
let lcx = cx.fcx.lcx;
let glue_fn =
declare_generic_glue(lcx, ti.ty, T_glue_fn(lcx.ccx),
@ -1769,16 +1767,16 @@ fn lazily_emit_tydesc_glue(cx: @block_ctxt, field: int,
make_generic_glue(lcx, cx.sp, ti.ty, glue_fn,
make_take_glue,
ti.ty_params, "take");
log #fmt["--- lazily_emit_tydesc_glue TAKE %s",
ty_to_str(bcx_tcx(cx), ti.ty)];
#debug("--- lazily_emit_tydesc_glue TAKE %s",
ty_to_str(bcx_tcx(cx), ti.ty));
}
}
} else if field == abi::tydesc_field_drop_glue {
alt ti.drop_glue {
some(_) { }
none. {
log #fmt["+++ lazily_emit_tydesc_glue DROP %s",
ty_to_str(bcx_tcx(cx), ti.ty)];
#debug("+++ lazily_emit_tydesc_glue DROP %s",
ty_to_str(bcx_tcx(cx), ti.ty));
let lcx = cx.fcx.lcx;
let glue_fn =
declare_generic_glue(lcx, ti.ty, T_glue_fn(lcx.ccx),
@ -1787,16 +1785,16 @@ fn lazily_emit_tydesc_glue(cx: @block_ctxt, field: int,
make_generic_glue(lcx, cx.sp, ti.ty, glue_fn,
make_drop_glue,
ti.ty_params, "drop");
log #fmt["--- lazily_emit_tydesc_glue DROP %s",
ty_to_str(bcx_tcx(cx), ti.ty)];
#debug("--- lazily_emit_tydesc_glue DROP %s",
ty_to_str(bcx_tcx(cx), ti.ty));
}
}
} else if field == abi::tydesc_field_free_glue {
alt ti.free_glue {
some(_) { }
none. {
log #fmt["+++ lazily_emit_tydesc_glue FREE %s",
ty_to_str(bcx_tcx(cx), ti.ty)];
#debug("+++ lazily_emit_tydesc_glue FREE %s",
ty_to_str(bcx_tcx(cx), ti.ty));
let lcx = cx.fcx.lcx;
let glue_fn =
declare_generic_glue(lcx, ti.ty, T_glue_fn(lcx.ccx),
@ -1805,19 +1803,19 @@ fn lazily_emit_tydesc_glue(cx: @block_ctxt, field: int,
make_generic_glue(lcx, cx.sp, ti.ty, glue_fn,
make_free_glue,
ti.ty_params, "free");
log #fmt["--- lazily_emit_tydesc_glue FREE %s",
ty_to_str(bcx_tcx(cx), ti.ty)];
#debug("--- lazily_emit_tydesc_glue FREE %s",
ty_to_str(bcx_tcx(cx), ti.ty));
}
}
} else if field == abi::tydesc_field_cmp_glue {
alt ti.cmp_glue {
some(_) { }
none. {
log #fmt["+++ lazily_emit_tydesc_glue CMP %s",
ty_to_str(bcx_tcx(cx), ti.ty)];
#debug("+++ lazily_emit_tydesc_glue CMP %s",
ty_to_str(bcx_tcx(cx), ti.ty));
ti.cmp_glue = some(bcx_ccx(cx).upcalls.cmp_type);
log #fmt["--- lazily_emit_tydesc_glue CMP %s",
ty_to_str(bcx_tcx(cx), ti.ty)];
#debug("--- lazily_emit_tydesc_glue CMP %s",
ty_to_str(bcx_tcx(cx), ti.ty));
}
}
}

View file

@ -547,8 +547,8 @@ fn constraints(fcx: fn_ctxt) -> [norm_constraint] {
// should freeze it at some earlier point.
fn match_args(fcx: fn_ctxt, occs: @mutable [pred_args],
occ: [@constr_arg_use]) -> uint {
log "match_args: looking at " +
constr_args_to_str(fn (i: inst) -> str { ret i.ident; }, occ);
#debug("match_args: looking at %s",
constr_args_to_str(fn (i: inst) -> str { ret i.ident; }, occ));
for pd: pred_args in *occs {
log_full(core::debug,
"match_args: candidate " + pred_args_to_str(pd));
@ -879,9 +879,9 @@ fn forget_in_postcond(fcx: fn_ctxt, parent_exp: node_id, dead_v: node_id) {
some(d_id) {
for c: norm_constraint in constraints(fcx) {
if constraint_mentions(fcx, c, d_id) {
log ("clearing constraint ",
c.bit_num,
constraint_to_str(fcx.ccx.tcx, c.c));
#debug("clearing constraint %u %s",
c.bit_num,
constraint_to_str(fcx.ccx.tcx, c.c));
clear_in_postcond(c.bit_num,
node_id_to_ts_ann(fcx.ccx,
parent_exp).conditions);

View file

@ -71,11 +71,11 @@ fn check_states_stmt(s: @stmt, fcx: fn_ctxt, v: visit::vt<fn_ctxt>) {
let pres: prestate = ann_prestate(a);
log("check_states_stmt:");
#debug("check_states_stmt:");
log_full(core::debug, print::pprust::stmt_to_str(*s));
log("prec = ");
#debug("prec = ");
log_tritv(fcx, prec);
log("pres = ");
#debug("pres = ");
log_tritv(fcx, pres);
if !implies(pres, prec) {

View file

@ -154,8 +154,7 @@ fn mk_fn_info(ccx: crate_ctxt,
i_diverge: ninit(diverges_id, diverges_name),
used_vars: v};
ccx.fm.insert(id, rslt);
log name + " has " + uint::str(num_constraints(rslt)) +
" constraints";
#debug("%s has %u constraints", name, num_constraints(rslt));
}

View file

@ -1502,9 +1502,9 @@ fn check_expr_fn_with_unifier(fcx: @fn_ctxt,
let fty = ty_of_fn_decl(tcx, m_check_tyvar(fcx), decl);
log #fmt("check_expr_fn_with_unifier %s fty=%s",
expr_to_str(expr),
ty_to_str(tcx, fty));
#debug("check_expr_fn_with_unifier %s fty=%s",
expr_to_str(expr),
ty_to_str(tcx, fty));
write::ty_only_fixup(fcx, expr.id, fty);
@ -1965,9 +1965,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
ast::proto_block
}
};
log #fmt("checking expr_fn_block %s expected=%s",
expr_to_str(expr),
ty_to_str(tcx, expected));
#debug("checking expr_fn_block %s expected=%s",
expr_to_str(expr),
ty_to_str(tcx, expected));
check_expr_fn_with_unifier(fcx, expr, {proto: proto with decl}, body,
unify, expected);
write::ty_only_fixup(fcx, id, expected);

View file

@ -30,8 +30,8 @@ fn eval_crate_directives_to_mod(cx: ctx, cdirs: [@ast::crate_directive],
prefix: str, suffix: option::t<str>)
-> (ast::_mod, [ast::attribute]) {
#debug("eval crate prefix: %s", prefix);
log #fmt("eval crate suffix: %s",
option::from_maybe("none", suffix));
#debug("eval crate suffix: %s",
option::from_maybe("none", suffix));
let (cview_items, citems, cattrs)
= parse_companion_mod(cx, prefix, suffix);
let view_items: [@ast::view_item] = [];

View file

@ -910,7 +910,10 @@ fn parse_bottom_expr(p: parser) -> @ast::expr {
hi = e.span.hi;
ex = ast::expr_fail(some(e));
} else { ex = ast::expr_fail(none); }
} else if eat_word(p, "log_full") {
} else if
(eat_word(p, "log_full")
|| eat_word(p, "log")
|| eat_word(p, "log_err")) {
expect(p, token::LPAREN);
let lvl = parse_expr(p);
expect(p, token::COMMA);
@ -918,14 +921,6 @@ fn parse_bottom_expr(p: parser) -> @ast::expr {
ex = ast::expr_log(2, lvl, e);
hi = p.get_hi_pos();
expect(p, token::RPAREN);
} else if eat_word(p, "log") {
let e = parse_expr(p);
ex = ast::expr_log(1, mk_lit_u32(p, 1u32), e);
hi = e.span.hi;
} else if eat_word(p, "log_err") {
let e = parse_expr(p);
ex = ast::expr_log(0, mk_lit_u32(p, 0u32), e);
hi = e.span.hi;
} else if eat_word(p, "assert") {
let e = parse_expr(p);
ex = ast::expr_assert(e);

View file

@ -304,11 +304,11 @@ obj printer(out: io::writer,
}
}
fn check_stream() {
log #fmt["check_stream [%u, %u] with left_total=%d, right_total=%d",
left, right, left_total, right_total];
#debug("check_stream [%u, %u] with left_total=%d, right_total=%d",
left, right, left_total, right_total);
if right_total - left_total > space {
log #fmt["scan window is %d, longer than space on line (%d)",
right_total - left_total, space];
#debug("scan window is %d, longer than space on line (%d)",
right_total - left_total, space);
if !scan_stack_empty {
if left == scan_stack[bottom] {
#debug("setting %u to infinity and popping", left);
@ -411,8 +411,8 @@ obj printer(out: io::writer,
out.write_str(s);
}
fn print(x: token, L: int) {
log #fmt["print %s %d (remaining line space=%d)", tok_str(x), L,
space];
#debug("print %s %d (remaining line space=%d)", tok_str(x), L,
space);
log_full(core::debug, buf_str(token, size, left, right, 6u));
alt x {
BEGIN(b) {