diff --git a/src/rustc/middle/alias.rs b/src/rustc/middle/alias.rs index 1fb17d4f385..7b25a0955f3 100644 --- a/src/rustc/middle/alias.rs +++ b/src/rustc/middle/alias.rs @@ -2,6 +2,7 @@ import syntax::{ast, ast_util, ast_map}; import ast_util::path_to_ident; import ast::{ident, fn_ident, node_id}; import syntax::codemap::span; +import syntax::print::pprust::expr_to_str; import syntax::visit; import visit::vt; import std::list; @@ -703,7 +704,7 @@ fn expr_root(cx: ctx, ex: @ast::expr, autoderef: bool) } } ty::ty_class(did, _) { - util::common::log_expr(*base); + #debug["base: %s", expr_to_str(base)]; let in_self = alt ctor_self { some(selfid) { alt tcx.def_map.find(base.id) { diff --git a/src/rustc/middle/resolve.rs b/src/rustc/middle/resolve.rs index d8a47a5e3a0..1eeb0b0821e 100644 --- a/src/rustc/middle/resolve.rs +++ b/src/rustc/middle/resolve.rs @@ -8,7 +8,7 @@ import pat_util::*; import syntax::attr; import metadata::{csearch, cstore}; import driver::session::session; -import util::common::*; +import util::common::is_main_name; import std::map::{int_hash, str_hash, hashmap}; import vec::each; import syntax::codemap::span; diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index cb17f199731..61d0786b215 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -28,7 +28,7 @@ import syntax::codemap::span; import syntax::print::pprust::{expr_to_str, stmt_to_str, path_to_str}; import pat_util::*; import visit::vt; -import util::common::*; +import util::common::is_main_name; import lib::llvm::{llvm, mk_target_data, mk_type_names}; import lib::llvm::{ModuleRef, ValueRef, TypeRef, BasicBlockRef}; import lib::llvm::{True, False}; @@ -1696,7 +1696,7 @@ fn trans_eager_binop(cx: block, op: ast::binop, lhs: ValueRef, fn trans_assign_op(bcx: block, ex: @ast::expr, op: ast::binop, dst: @ast::expr, src: @ast::expr) -> block { - log_expr(*ex); + #debug["%s", expr_to_str(ex)]; let _icx = bcx.insn_ctxt("trans_assign_op"); let t = expr_ty(bcx, src); let lhs_res = trans_lval(bcx, dst); diff --git a/src/rustc/middle/trans/common.rs b/src/rustc/middle/trans/common.rs index da650eea792..dce90a51db2 100644 --- a/src/rustc/middle/trans/common.rs +++ b/src/rustc/middle/trans/common.rs @@ -11,7 +11,6 @@ import driver::session; import session::session; import middle::{resolve, ty}; import back::{link, abi, upcall}; -import util::common::*; import syntax::codemap::span; import lib::llvm::{llvm, target_data, type_names, associate_type, name_has_type}; diff --git a/src/rustc/middle/trans/shape.rs b/src/rustc/middle/trans/shape.rs index 72eda246db2..7be5bfe2c68 100644 --- a/src/rustc/middle/trans/shape.rs +++ b/src/rustc/middle/trans/shape.rs @@ -13,7 +13,6 @@ import middle::ty::field; import syntax::ast; import syntax::ast_util::{dummy_sp, new_def_hash}; import syntax::util::interner; -import util::common; import util::ppaux::ty_to_str; import syntax::codemap::span; import dvec::{dvec, extensions}; diff --git a/src/rustc/middle/tstate/annotate.rs b/src/rustc/middle/tstate/annotate.rs index 791c1aa6924..0db63a4ac26 100644 --- a/src/rustc/middle/tstate/annotate.rs +++ b/src/rustc/middle/tstate/annotate.rs @@ -2,7 +2,7 @@ import syntax::ast::*; import syntax::visit; import syntax::codemap::span; -import util::common::{log_stmt}; +import syntax::print::pprust::stmt_to_str; import aux::{num_constraints, get_fn_info, crate_ctxt, add_node}; import ann::empty_ann; import pat_util::pat_binding_ids; @@ -14,8 +14,8 @@ fn collect_ids_block(b: blk, rs: @mut [node_id]) { *rs += [b.node.id]; } fn collect_ids_stmt(s: @stmt, rs: @mut [node_id]) { alt s.node { stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) { - log(debug, "node_id " + int::str(id)); - log_stmt(*s); + #debug["node_id %s", int::str(id)]; + #debug["%s", stmt_to_str(*s)]; *rs += [id]; } } diff --git a/src/rustc/middle/tstate/bitvectors.rs b/src/rustc/middle/tstate/bitvectors.rs index 714efaa471a..c3a38ac35eb 100644 --- a/src/rustc/middle/tstate/bitvectors.rs +++ b/src/rustc/middle/tstate/bitvectors.rs @@ -10,7 +10,6 @@ import tstate::ann::{pre_and_post, precond, postcond, prestate, poststate, clear_in_poststate, clear_in_prestate, clear_in_poststate_}; import tritv::*; -import util::common::*; import driver::session::session; import std::map::hashmap; diff --git a/src/rustc/middle/tstate/ck.rs b/src/rustc/middle/tstate/ck.rs index a200a05d179..64936ec37e5 100644 --- a/src/rustc/middle/tstate/ck.rs +++ b/src/rustc/middle/tstate/ck.rs @@ -14,6 +14,7 @@ import annotate::annotate_crate; import collect_locals::mk_f_to_fn_info; import pre_post_conditions::fn_pre_post; import states::find_pre_post_state_fn; +import syntax::print::pprust::expr_to_str; import driver::session::session; import std::map::hashmap; @@ -23,16 +24,6 @@ fn check_states_expr(e: @expr, fcx: fn_ctxt, v: visit::vt) { let prec: precond = expr_precond(fcx.ccx, e); let pres: prestate = expr_prestate(fcx.ccx, e); - - /* - log_err("check_states_expr:"); - util::common::log_expr_err(*e); - log_err("prec = "); - log_tritv_err(fcx, prec); - log_err("pres = "); - log_tritv_err(fcx, pres); - */ - if !implies(pres, prec) { let mut s = ""; let diff = first_difference_string(fcx, prec, pres); @@ -55,7 +46,6 @@ fn check_states_stmt(s: @stmt, fcx: fn_ctxt, v: visit::vt) { let prec: precond = ann_precond(a); let pres: prestate = ann_prestate(a); - #debug("check_states_stmt:"); log(debug, print::pprust::stmt_to_str(*s)); #debug("prec = "); diff --git a/src/rustc/middle/tstate/pre_post_conditions.rs b/src/rustc/middle/tstate/pre_post_conditions.rs index 062ec0f38f8..a51a4f72a0e 100644 --- a/src/rustc/middle/tstate/pre_post_conditions.rs +++ b/src/rustc/middle/tstate/pre_post_conditions.rs @@ -8,9 +8,9 @@ import tritv::*; import pat_util::*; import syntax::ast::*; import syntax::ast_util::*; +import syntax::print::pprust::{expr_to_str, stmt_to_str}; import syntax::visit; -import util::common::{log_expr, field_exprs, - has_nonlocal_exits, log_stmt}; +import util::common::{field_exprs, has_nonlocal_exits}; import syntax::codemap::span; import driver::session::session; import std::map::hashmap; @@ -73,8 +73,7 @@ fn find_pre_post_item(ccx: crate_ctxt, i: item) { be the union of all postconditions for */ fn find_pre_post_exprs(fcx: fn_ctxt, args: [@expr], id: node_id) { if vec::len::<@expr>(args) > 0u { - #debug("find_pre_post_exprs: oper ="); - log_expr(*args[0]); + #debug["find_pre_post_exprs: oper = %s", expr_to_str(args[0])]; } fn do_one(fcx: fn_ctxt, e: @expr) { find_pre_post_expr(fcx, e); } for args.each {|e| do_one(fcx, e); } @@ -473,8 +472,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { } fn find_pre_post_stmt(fcx: fn_ctxt, s: stmt) { - #debug("stmt ="); - log_stmt(s); + #debug["stmt = %s", stmt_to_str(s)]; alt s.node { stmt_decl(adecl, id) { alt adecl.node { @@ -571,12 +569,6 @@ fn find_pre_post_block(fcx: fn_ctxt, b: blk) { let nv = num_constraints(fcx.enclosing); fn do_one_(fcx: fn_ctxt, s: @stmt) { find_pre_post_stmt(fcx, *s); - /* - #error("pre_post for stmt:"); - log_stmt_err(*s); - #error("is:"); - log_pp_err(stmt_pp(fcx.ccx, *s)); - */ } for b.node.stmts.each {|s| do_one_(fcx, s); } fn do_inner_(fcx: fn_ctxt, &&e: @expr) { find_pre_post_expr(fcx, e); } diff --git a/src/rustc/middle/tstate/states.rs b/src/rustc/middle/tstate/states.rs index c5a4e1c5815..89932070a0c 100644 --- a/src/rustc/middle/tstate/states.rs +++ b/src/rustc/middle/tstate/states.rs @@ -7,9 +7,10 @@ import bitvectors::*; import pat_util::*; import syntax::ast::*; import syntax::ast_util::*; +import syntax::print::pprust::{expr_to_str, stmt_to_str}; import syntax::codemap::span; import middle::ty::{expr_ty, type_is_bot}; -import util::common::*; +import util::common::{field_exprs, has_nonlocal_exits, may_break}; import driver::session::session; import std::map::hashmap; @@ -204,21 +205,6 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk, set_prestate_ann(fcx.ccx, id, pres) | find_pre_post_state_expr(fcx, pres, antec); - /* - log_err("join_then_else:"); - log_expr_err(*antec); - log_bitv_err(fcx, expr_prestate(fcx.ccx, antec)); - log_bitv_err(fcx, expr_poststate(fcx.ccx, antec)); - log_block_err(conseq); - log_bitv_err(fcx, block_prestate(fcx.ccx, conseq)); - log_bitv_err(fcx, block_poststate(fcx.ccx, conseq)); - log_err("****"); - log_bitv_err(fcx, expr_precond(fcx.ccx, antec)); - log_bitv_err(fcx, expr_postcond(fcx.ccx, antec)); - log_bitv_err(fcx, block_precond(fcx.ccx, conseq)); - log_bitv_err(fcx, block_postcond(fcx.ccx, conseq)); - */ - alt maybe_alt { none { alt chk { @@ -313,8 +299,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { return_val); } expr_call(operator, operands, _) { - #debug("hey it's a call"); - log_expr(*e); + #debug["hey it's a call: %s", expr_to_str(e)]; ret find_pre_post_state_call(fcx, pres, operator, e.id, callee_arg_init_ops(fcx, operator.id), operands, @@ -423,12 +408,6 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { oper_assign_op); } expr_while(test, body) { - /* - #error("in a while loop:"); - log_expr_err(*e); - aux::log_tritv_err(fcx, block_poststate(fcx.ccx, body)); - aux::log_tritv_err(fcx, pres); - */ let loop_pres = intersect_states(block_poststate(fcx.ccx, body), pres); @@ -537,13 +516,10 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { fn find_pre_post_state_stmt(fcx: fn_ctxt, pres: prestate, s: @stmt) -> bool { let stmt_ann = stmt_to_ann(fcx.ccx, *s); - log(debug, "[" + fcx.name + "]"); - #debug("*At beginning: stmt = "); - log_stmt(*s); - #debug("*prestate = "); - log(debug, tritv::to_str(stmt_ann.states.prestate)); - #debug("*poststate ="); - log(debug, tritv::to_str(stmt_ann.states.prestate)); + #debug["[ %s ]", fcx.name]; + #debug["*At beginning: stmt = %s", stmt_to_str(*s)]; + #debug["*prestate = %s", tritv::to_str(stmt_ann.states.prestate)]; + #debug["*poststate = %s", tritv::to_str(stmt_ann.states.prestate)]; alt s.node { stmt_decl(adecl, id) { @@ -559,14 +535,10 @@ fn find_pre_post_state_stmt(fcx: fn_ctxt, pres: prestate, s: @stmt) -> bool { let mut changed = set_poststate(stmt_ann, c_and_p.post) | c_and_p.changed; - #debug("Summary: stmt = "); - log_stmt(*s); - #debug("prestate = "); - log(debug, tritv::to_str(stmt_ann.states.prestate)); - #debug("poststate ="); - log(debug, tritv::to_str(stmt_ann.states.prestate)); - #debug("changed ="); - log(debug, changed); + #debug["Summary: stmt = %s", stmt_to_str(*s)]; + #debug["prestate = %s", tritv::to_str(stmt_ann.states.prestate)]; + #debug["poststate = %s",tritv::to_str(stmt_ann.states.poststate)]; + #debug["changed = %s", bool::to_str(changed)]; ret changed; } @@ -583,13 +555,10 @@ fn find_pre_post_state_stmt(fcx: fn_ctxt, pres: prestate, s: @stmt) -> bool { set_poststate(stmt_ann, expr_poststate(fcx.ccx, ex)); - #debug("Finally:"); - log_stmt(*s); - log(debug, "prestate = "); - log(debug, tritv::to_str(stmt_ann.states.prestate)); - #debug("poststate ="); - log(debug, (tritv::to_str(stmt_ann.states.poststate))); - #debug("changed ="); + #debug["Finally: %s", stmt_to_str(*s)]; + #debug["prestate = %s", tritv::to_str(stmt_ann.states.prestate)]; + #debug["poststate = %s", tritv::to_str(stmt_ann.states.poststate)]; + #debug["changed = %s", bool::to_str(changed)]; ret changed; } @@ -624,20 +593,6 @@ fn find_pre_post_state_block(fcx: fn_ctxt, pres0: prestate, b: blk) -> bool { set_prestate_ann(fcx.ccx, b.node.id, pres0); set_poststate_ann(fcx.ccx, b.node.id, post); - - /* - #error("For block:"); - log_block_err(b); - #error("poststate = "); - log_states_err(block_states(fcx.ccx, b)); - #error("pres0:"); - log_tritv_err(fcx, pres0); - #error("post:"); - log_tritv_err(fcx, post); - #error("changed = "); - log(error, changed); - */ - ret changed; } diff --git a/src/rustc/middle/typeck.rs b/src/rustc/middle/typeck.rs index 51e5886340b..f8b24d004b7 100644 --- a/src/rustc/middle/typeck.rs +++ b/src/rustc/middle/typeck.rs @@ -46,7 +46,7 @@ import syntax::ast_util::{local_def, respan, split_class_items}; import syntax::visit; import metadata::csearch; import driver::session::session; -import util::common::*; +import util::common::may_break; import syntax::codemap::span; import pat_util::{pat_is_variant, pat_id_map}; import middle::ty; diff --git a/src/rustc/util/common.rs b/src/rustc/util/common.rs index daab9eb33f1..dfddbab647f 100644 --- a/src/rustc/util/common.rs +++ b/src/rustc/util/common.rs @@ -33,41 +33,6 @@ fn field_exprs(fields: [ast::field]) -> [@ast::expr] { ret es; } -fn log_expr(e: ast::expr) { - log(debug, print::pprust::expr_to_str(@e)); -} - -fn log_expr_err(e: ast::expr) { - log(error, print::pprust::expr_to_str(@e)); -} - -fn log_ty_err(t: @ty) { - log(error, print::pprust::ty_to_str(t)); -} - -fn log_pat_err(p: @pat) { - log(error, print::pprust::pat_to_str(p)); -} - -fn log_block(b: ast::blk) { - log(debug, print::pprust::block_to_str(b)); -} - -fn log_block_err(b: ast::blk) { - log(error, print::pprust::block_to_str(b)); -} - -fn log_item_err(i: @ast::item) { - log(error, print::pprust::item_to_str(i)); -} -fn log_stmt(st: ast::stmt) { - log(debug, print::pprust::stmt_to_str(st)); -} - -fn log_stmt_err(st: ast::stmt) { - log(error, print::pprust::stmt_to_str(st)); -} - fn has_nonlocal_exits(b: ast::blk) -> bool { let has_exits = @mut false; fn visit_expr(flag: @mut bool, e: @ast::expr) {