Convert uses of #fmt to #ifmt. Issue #855

This commit is contained in:
Brian Anderson 2011-08-28 00:24:28 -07:00
parent 959938e891
commit 498e38b705
51 changed files with 345 additions and 380 deletions

View file

@ -341,9 +341,7 @@ fn build_link_meta(sess: &session::session, c: &ast::crate, output: &istr,
fn crate_meta_extras_hash(sha: sha1, _crate: &ast::crate,
metas: &provided_metas) -> istr {
fn len_and_str(s: &istr) -> istr {
ret istr::from_estr(#fmt["%u_%s",
istr::byte_len(s),
istr::to_estr(s)]);
ret #ifmt["%u_%s", istr::byte_len(s), s];
}
fn len_and_str_lit(l: &ast::lit) -> istr {
@ -374,9 +372,9 @@ fn build_link_meta(sess: &session::session, c: &ast::crate, output: &istr,
fn warn_missing(sess: &session::session, name: &istr, default: &istr) {
if !sess.get_opts().library { ret; }
sess.warn(istr::from_estr(
#fmt["missing crate link meta '%s', using '%s' as default",
istr::to_estr(name), istr::to_estr(default)]));
sess.warn(
#ifmt["missing crate link meta '%s', using '%s' as default",
name, default]);
}
fn crate_meta_name(sess: &session::session, _crate: &ast::crate,
@ -461,9 +459,7 @@ fn mangle(ss: &[istr]) -> istr {
let n = ~"_ZN"; // Begin name-sequence.
for s: istr in ss {
n += istr::from_estr(#fmt["%u%s",
istr::byte_len(s),
istr::to_estr(s)]);
n += #ifmt["%u%s", istr::byte_len(s), s];
}
n += ~"E"; // End name-sequence.

View file

@ -122,8 +122,8 @@ fn time<@T>(do_it: bool, what: &istr, 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", istr::to_estr(what),
istr::to_estr(common::float_to_str(end - start, 3u))];
log_err #ifmt["time: %s took %s s", what,
common::float_to_str(end - start, 3u)];
ret rv;
}
@ -255,21 +255,21 @@ fn pretty_print_input(sess: session::session, cfg: ast::crate_cfg,
}
fn version(argv0: &istr) {
let vers = "unknown version";
let vers = ~"unknown version";
// FIXME: Restore after istr conversion
//let env_vers = #env["CFG_VERSION"];
let env_vers = "FIXME";
if str::byte_len(env_vers) != 0u { vers = env_vers; }
let env_vers = ~"FIXME";
if istr::byte_len(env_vers) != 0u { vers = env_vers; }
io::stdout().write_str(
istr::from_estr(#fmt["%s %s\n",
istr::to_estr(argv0),
vers]));
#ifmt["%s %s\n",
argv0,
vers]);
}
fn usage(argv0: &istr) {
io::stdout().write_str(istr::from_estr(
#fmt["usage: %s [options] <input>\n", istr::to_estr(argv0)] +
"
io::stdout().write_str(
#ifmt["usage: %s [options] <input>\n", argv0] +
~"
options:
-h --help display this message
@ -302,7 +302,7 @@ options:
--test build test harness
--gc garbage collect shared data (experimental/temporary)
"));
");
}
fn get_os(triple: &istr) -> session::os {
@ -473,7 +473,7 @@ fn main(args: [str]) {
alt getopts::getopts(args, opts()) {
getopts::success(m) { m }
getopts::failure(f) {
log_err #fmt["error: %s", istr::to_estr(getopts::fail_str(f))];
log_err #ifmt["error: %s", getopts::fail_str(f)];
fail
}
};
@ -637,11 +637,11 @@ fn main(args: [str]) {
let err_code = run::run_program(prog, gcc_args);
if 0 != err_code {
sess.err(istr::from_estr(
#fmt["linking with gcc failed with code %d", err_code]));
sess.note(istr::from_estr(
#fmt["gcc arguments: %s",
istr::to_estr(istr::connect(gcc_args, ~" "))]));
sess.err(
#ifmt["linking with gcc failed with code %d", err_code]);
sess.note(
#ifmt["gcc arguments: %s",
istr::connect(gcc_args, ~" ")]);
sess.abort_if_errors();
}
// Clean up on Darwin

View file

@ -95,13 +95,13 @@ obj session(targ_cfg: @config,
}
fn span_bug(sp: span, msg: &istr) -> ! {
self.span_fatal(sp,
istr::from_estr(#fmt["internal compiler error %s",
istr::to_estr(msg)]));
#ifmt["internal compiler error %s",
msg]);
}
fn bug(msg: &istr) -> ! {
self.fatal(istr::from_estr(
#fmt["internal compiler error %s",
istr::to_estr(msg)]));
self.fatal(
#ifmt["internal compiler error %s",
msg]);
}
fn span_unimpl(sp: span, msg: &istr) -> ! {
self.span_bug(sp, ~"unimplemented " + msg);

View file

@ -124,13 +124,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",
istr::to_estr(
syntax::print::pprust::meta_item_to_str(*needle))];
log #ifmt["looking for %s",
syntax::print::pprust::meta_item_to_str(*needle)];
for item: @ast::meta_item in haystack {
log #fmt["looking in %s",
istr::to_estr(
syntax::print::pprust::meta_item_to_str(*item))];
log #ifmt["looking in %s",
syntax::print::pprust::meta_item_to_str(*item)];
if eq(item, needle) { log "found it!"; ret true; }
}
log "found it not :(";
@ -185,9 +183,9 @@ fn require_unique_names(sess: &session::session, metas: &[@ast::meta_item]) {
for meta: @ast::meta_item in metas {
let name = get_meta_item_name(meta);
if map.contains_key(name) {
sess.span_fatal(meta.span, istr::from_estr(
#fmt["duplicate meta item `%s`",
istr::to_estr(name)]));
sess.span_fatal(meta.span,
#ifmt["duplicate meta item `%s`",
name]);
}
map.insert(name, ());
}

View file

@ -92,14 +92,14 @@ fn fold_item(cx: &test_ctxt, i: &@ast::item, fld: fold::ast_fold) ->
@ast::item {
cx.path += [i.ident];
log #fmt["current path: %s",
istr::to_estr(ast_util::path_name_i(cx.path))];
log #ifmt["current path: %s",
ast_util::path_name_i(cx.path)];
if is_test_fn(i) {
log "this is a test function";
let test = {path: cx.path, ignore: is_ignored(i)};
cx.testfns += [test];
log #fmt["have %u test functions", vec::len(cx.testfns)];
log #ifmt["have %u test functions", vec::len(cx.testfns)];
}
let res = fold::noop_fold_item(i, fld);
@ -168,8 +168,8 @@ fn mk_test_module(cx: &test_ctxt) -> @ast::item {
node: item_,
span: dummy_sp()};
log #fmt["Synthetic test module:\n%s\n",
istr::to_estr(pprust::item_to_str(@item))];
log #ifmt["Synthetic test module:\n%s\n",
pprust::item_to_str(@item)];
ret @item;
}
@ -234,7 +234,7 @@ fn mk_test_desc_vec_ty(cx: &test_ctxt) -> @ast::ty {
}
fn mk_test_desc_vec(cx: &test_ctxt) -> @ast::expr {
log #fmt["building test vector from %u tests", vec::len(cx.testfns)];
log #ifmt["building test vector from %u tests", vec::len(cx.testfns)];
let descs = [];
for test: test in cx.testfns {
let test_ = test; // Satisfy alias analysis
@ -249,8 +249,8 @@ fn mk_test_desc_vec(cx: &test_ctxt) -> @ast::expr {
fn mk_test_desc_rec(cx: &test_ctxt, test: test) -> @ast::expr {
let path = test.path;
log #fmt["encoding %s",
istr::to_estr(ast_util::path_name_i(path))];
log #ifmt["encoding %s",
ast_util::path_name_i(path)];
let name_lit: ast::lit =
nospan(ast::lit_str(ast_util::path_name_i(path), ast::sk_rc));

View file

@ -1040,7 +1040,7 @@ fn type_to_str_inner(names: type_names, outer0: &[TypeRef], ty: TypeRef) ->
}
13 { ret ~"Vector"; }
14 { ret ~"Metadata"; }
_ { log_err #fmt["unknown TypeKind %d", kind as int]; fail; }
_ { log_err #ifmt["unknown TypeKind %d", kind as int]; fail; }
}
}

View file

@ -100,13 +100,13 @@ 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",
log #ifmt["matching %u metadata requirements against %u items",
vec::len(metas), vec::len(linkage_metas)];
for needed: @ast::meta_item in metas {
if !attr::contains(linkage_metas, needed) {
log #fmt["missing %s",
istr::to_estr(pprust::meta_item_to_str(*needed))];
log #ifmt["missing %s",
pprust::meta_item_to_str(*needed)];
ret false;
}
}
@ -170,27 +170,27 @@ fn find_library_crate_aux(nn: &{prefix: istr, suffix: istr},
// manually filtering fs::list_dir here.
for library_search_path: istr in library_search_paths {
log #fmt["searching %s", istr::to_estr(library_search_path)];
log #ifmt["searching %s", library_search_path];
for path: istr in fs::list_dir(library_search_path) {
log #fmt["searching %s", istr::to_estr(path)];
log #ifmt["searching %s", path];
let f: istr = fs::basename(path);
if !(istr::starts_with(f, prefix) && istr::ends_with(f, suffix))
{
log #fmt["skipping %s, doesn't look like %s*%s",
istr::to_estr(path),
istr::to_estr(prefix),
istr::to_estr(suffix)];
log #ifmt["skipping %s, doesn't look like %s*%s",
path,
prefix,
suffix];
cont;
}
alt get_metadata_section(path) {
option::some(cvec) {
if !metadata_matches(cvec, metas) {
log #fmt["skipping %s, metadata doesn't match",
istr::to_estr(path)];
log #ifmt["skipping %s, metadata doesn't match",
path];
cont;
}
log #fmt["found %s with matching metadata",
istr::to_estr(path)];
log #ifmt["found %s with matching metadata",
path];
ret some({ident: path, data: cvec});
}
_ { }
@ -230,9 +230,9 @@ fn load_library_crate(sess: &session::session, span: span, ident: &ast::ident,
alt find_library_crate(sess, ident, metas, library_search_paths) {
some(t) { ret t; }
none. {
sess.span_fatal(span, istr::from_estr(
#fmt["can't find crate for '%s'",
istr::to_estr(ident)]));
sess.span_fatal(span,
#ifmt["can't find crate for '%s'",
ident]);
}
}
}
@ -275,7 +275,7 @@ fn resolve_crate_deps(e: env, cdata: &@[u8]) -> cstore::cnum_map {
for dep: decoder::crate_dep in decoder::get_crate_deps(cdata) {
let extrn_cnum = dep.cnum;
let cname = dep.ident;
log #fmt["resolving dep %s", istr::to_estr(cname)];
log #ifmt["resolving dep %s", cname];
if e.crate_cache.contains_key(cname) {
log "already have it";
// We've already seen this crate

View file

@ -349,9 +349,8 @@ fn get_attributes(md: &ebml::doc) -> [ast::attribute] {
fn list_meta_items(meta_items: &ebml::doc, out: io::writer) {
for mi: @ast::meta_item in get_meta_items(meta_items) {
out.write_str(
istr::from_estr(
#fmt["%s\n",
istr::to_estr(pprust::meta_item_to_str(*mi))]));
#ifmt["%s\n",
pprust::meta_item_to_str(*mi)]);
}
}
@ -360,9 +359,8 @@ fn list_crate_attributes(md: &ebml::doc, out: io::writer) {
for attr: ast::attribute in get_attributes(md) {
out.write_str(
istr::from_estr(
#fmt["%s\n",
istr::to_estr(pprust::attribute_to_str(attr))]));
#ifmt["%s\n",
pprust::attribute_to_str(attr)]);
}
out.write_str(~"\n\n");
@ -392,8 +390,8 @@ fn list_crate_deps(data: @[u8], out: io::writer) {
for dep: crate_dep in get_crate_deps(data) {
out.write_str(
istr::from_estr(#fmt["%d %s\n", dep.cnum,
istr::to_estr(dep.ident)]));
#ifmt["%d %s\n", dep.cnum,
dep.ident]);
}
out.write_str(~"\n");
@ -414,10 +412,9 @@ fn list_crate_items(bytes: &@[u8], md: &ebml::doc, out: io::writer) {
let did_doc = ebml::get_doc(def, tag_def_id);
let did = parse_def_id(ebml::doc_data(did_doc));
out.write_str(
istr::from_estr(
#fmt["%s (%s)\n",
istr::to_estr(data.path),
istr::to_estr(describe_def(items, did))]));
#ifmt["%s (%s)\n",
data.path,
describe_def(items, did)]);
}
}
out.write_str(~"\n");

View file

@ -178,7 +178,7 @@ fn encode_inlineness(ebml_w: &ebml::writer, c: u8) {
}
fn def_to_str(did: &def_id) -> istr {
ret istr::from_estr(#fmt["%d:%d", did.crate, did.node]);
ret #ifmt["%d:%d", did.crate, did.node];
}
fn encode_type_param_kinds(ebml_w: &ebml::writer, tps: &[ty_param]) {

View file

@ -257,10 +257,10 @@ fn check_call(cx: &ctx, f: &@ast::expr, args: &[@ast::expr], sc: &scope) ->
alt f.node {
ast::expr_path(_) {
if def_is_local(cx.tcx.def_map.get(f.id), true) {
cx.tcx.sess.span_err(f.span, istr::from_estr(
#fmt["function may alias with \
cx.tcx.sess.span_err(f.span,
#ifmt["function may alias with \
argument %u, which is not immutably rooted",
unsafe_t_offsets[0]]));
unsafe_t_offsets[0]]);
}
}
_ { }
@ -275,10 +275,10 @@ fn check_call(cx: &ctx, f: &@ast::expr, args: &[@ast::expr], sc: &scope) ->
let mut_alias = arg_t.mode == ty::mo_alias(true);
if i != offset &&
ty_can_unsafely_include(cx, unsafe, arg_t.ty, mut_alias) {
cx.tcx.sess.span_err(args[i].span, istr::from_estr(
#fmt["argument %u may alias with \
cx.tcx.sess.span_err(args[i].span,
#ifmt["argument %u may alias with \
argument %u, which is not immutably rooted",
i, offset]));
i, offset]);
}
i += 1u;
}

View file

@ -96,11 +96,11 @@ fn lower_kind(a: kind, b: kind) -> kind {
if kind_lteq(a, b) { a } else { b }
}
fn kind_to_str(k: kind) -> str {
fn kind_to_str(k: kind) -> istr {
alt k {
ast::kind_pinned. { "pinned" }
ast::kind_unique. { "unique" }
ast::kind_shared. { "shared" }
ast::kind_pinned. { ~"pinned" }
ast::kind_unique. { ~"unique" }
ast::kind_shared. { ~"shared" }
}
}
@ -114,17 +114,17 @@ fn type_and_kind(tcx: &ty::ctxt, e: &@ast::expr) ->
fn need_expr_kind(tcx: &ty::ctxt, e: &@ast::expr, k_need: ast::kind,
descr: &istr) {
let tk = type_and_kind(tcx, e);
log #fmt["for %s: want %s type, got %s type %s", istr::to_estr(descr),
log #ifmt["for %s: want %s type, got %s type %s", descr,
kind_to_str(k_need), kind_to_str(tk.kind),
istr::to_estr(util::ppaux::ty_to_str(tcx, tk.ty))];
util::ppaux::ty_to_str(tcx, tk.ty)];
if !kind_lteq(k_need, tk.kind) {
let s =
#fmt["mismatched kinds for %s: needed %s type, got %s type %s",
istr::to_estr(descr), kind_to_str(k_need),
#ifmt["mismatched kinds for %s: needed %s type, got %s type %s",
descr, kind_to_str(k_need),
kind_to_str(tk.kind),
istr::to_estr(util::ppaux::ty_to_str(tcx, tk.ty))];
tcx.sess.span_err(e.span, istr::from_estr(s));
util::ppaux::ty_to_str(tcx, tk.ty)];
tcx.sess.span_err(e.span, s);
}
}
@ -169,11 +169,11 @@ fn check_expr(tcx: &ty::ctxt, e: &@ast::expr) {
let k = ty::type_kind(tcx, t);
if !kind_lteq(k_need, k) {
let s =
#fmt["mismatched kinds for typaram %d: \
#ifmt["mismatched kinds for typaram %d: \
needed %s type, got %s type %s",
i, kind_to_str(k_need), kind_to_str(k),
istr::to_estr(util::ppaux::ty_to_str(tcx, t))];
tcx.sess.span_err(e.span, istr::from_estr(s));
util::ppaux::ty_to_str(tcx, t)];
tcx.sess.span_err(e.span, s);
}
i += 1;
}

View file

@ -575,8 +575,7 @@ fn unresolved_fatal(e: &env, sp: &span, id: &ident, kind: &istr) -> ! {
}
fn mk_unresolved_msg(id: &ident, kind: &istr) -> istr {
ret istr::from_estr(
#fmt["unresolved %s: %s", istr::to_estr(kind), istr::to_estr(id)]);
ret #ifmt["unresolved %s: %s", kind, id];
}
// Lookup helpers
@ -1011,8 +1010,7 @@ fn lookup_glob_in_mod(e: &env, info: @indexed_mod, sp: &span, id: &ident,
for match: glob_imp_def in matches {
let sp = match.item.span;
e.sess.span_note(
sp, istr::from_estr(#fmt["'%s' is imported here",
istr::to_estr(id)]));
sp, #ifmt["'%s' is imported here", id]);
}
e.sess.span_fatal(sp,
~"'" + id

View file

@ -1893,8 +1893,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",
istr::to_estr(ty_to_str(bcx_tcx(cx), ti.ty))];
log #ifmt["+++ 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),
@ -1903,16 +1903,16 @@ fn lazily_emit_tydesc_glue(cx: &@block_ctxt, field: int,
make_generic_glue(lcx, cx.sp, ti.ty, glue_fn,
default_helper(make_take_glue),
ti.ty_params, ~"take");
log #fmt["--- lazily_emit_tydesc_glue TAKE %s",
istr::to_estr(ty_to_str(bcx_tcx(cx), ti.ty))];
log #ifmt["--- 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",
istr::to_estr(ty_to_str(bcx_tcx(cx), ti.ty))];
log #ifmt["+++ 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),
@ -1921,16 +1921,16 @@ fn lazily_emit_tydesc_glue(cx: &@block_ctxt, field: int,
make_generic_glue(lcx, cx.sp, ti.ty, glue_fn,
default_helper(make_drop_glue),
ti.ty_params, ~"drop");
log #fmt["--- lazily_emit_tydesc_glue DROP %s",
istr::to_estr(ty_to_str(bcx_tcx(cx), ti.ty))];
log #ifmt["--- 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",
istr::to_estr(ty_to_str(bcx_tcx(cx), ti.ty))];
log #ifmt["+++ 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),
@ -1939,19 +1939,19 @@ fn lazily_emit_tydesc_glue(cx: &@block_ctxt, field: int,
make_generic_glue(lcx, cx.sp, ti.ty, glue_fn,
default_helper(make_free_glue),
ti.ty_params, ~"free");
log #fmt["--- lazily_emit_tydesc_glue FREE %s",
istr::to_estr(ty_to_str(bcx_tcx(cx), ti.ty))];
log #ifmt["--- 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",
istr::to_estr(ty_to_str(bcx_tcx(cx), ti.ty))];
log #ifmt["+++ 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",
istr::to_estr(ty_to_str(bcx_tcx(cx), ti.ty))];
log #ifmt["--- lazily_emit_tydesc_glue CMP %s",
ty_to_str(bcx_tcx(cx), ti.ty)];
}
}
} else if field == abi::tydesc_field_copy_glue {
@ -6323,16 +6323,16 @@ fn trans_crate(sess: &session::session, crate: &@ast::crate, tcx: &ty::ctxt,
write_metadata(cx.ccx, crate);
if ccx.sess.get_opts().stats {
log_err "--- trans stats ---";
log_err #fmt["n_static_tydescs: %u", ccx.stats.n_static_tydescs];
log_err #fmt["n_derived_tydescs: %u", ccx.stats.n_derived_tydescs];
log_err #fmt["n_glues_created: %u", ccx.stats.n_glues_created];
log_err #fmt["n_null_glues: %u", ccx.stats.n_null_glues];
log_err #fmt["n_real_glues: %u", ccx.stats.n_real_glues];
log_err #ifmt["n_static_tydescs: %u", ccx.stats.n_static_tydescs];
log_err #ifmt["n_derived_tydescs: %u", ccx.stats.n_derived_tydescs];
log_err #ifmt["n_glues_created: %u", ccx.stats.n_glues_created];
log_err #ifmt["n_null_glues: %u", ccx.stats.n_null_glues];
log_err #ifmt["n_real_glues: %u", ccx.stats.n_real_glues];
for timing: {ident: istr, time: int} in *ccx.stats.fn_times {
log_err #fmt["time: %s took %d ms",
istr::to_estr(timing.ident), timing.time];
log_err #ifmt["time: %s took %d ms",
timing.ident, timing.time];
}
}
ret llmod;

View file

@ -170,10 +170,10 @@ fn find_pre_post_state_call(fcx: &fn_ctxt, pres: &prestate, a: &@expr,
let changed = find_pre_post_state_expr(fcx, pres, a);
// FIXME: This could be a typestate constraint
if vec::len(bs) != vec::len(ops) {
fcx.ccx.tcx.sess.span_bug(a.span, istr::from_estr(
#fmt["mismatched arg lengths: \
fcx.ccx.tcx.sess.span_bug(a.span,
#ifmt["mismatched arg lengths: \
%u exprs vs. %u ops",
vec::len(bs), vec::len(ops)]));
vec::len(bs), vec::len(ops)]);
}
ret find_pre_post_state_exprs(fcx, expr_poststate(fcx.ccx, a), id, ops,
bs, cf) || changed;

View file

@ -2440,20 +2440,20 @@ mod unify {
fn dump_var_bindings(tcx: ty_ctxt, vb: @var_bindings) {
let i = 0u;
while i < vec::len::<ufind::node>(vb.sets.nodes) {
let sets = "";
let sets = ~"";
let j = 0u;
while j < vec::len::<option::t<uint>>(vb.sets.nodes) {
if ufind::find(vb.sets, j) == i { sets += #fmt[" %u", j]; }
if ufind::find(vb.sets, j) == i { sets += #ifmt[" %u", j]; }
j += 1u;
}
let typespec;
alt smallintmap::find::<t>(vb.types, i) {
none. { typespec = ""; }
none. { typespec = ~""; }
some(typ) {
typespec = " =" + istr::to_estr(ty_to_str(tcx, typ));
typespec = ~" =" + ty_to_str(tcx, typ);
}
}
log_err #fmt["set %u:%s%s", i, typespec, sets];
log_err #ifmt["set %u:%s%s", i, typespec, sets];
i += 1u;
}
}

View file

@ -1368,16 +1368,16 @@ fn check_pat(fcx: &@fn_ctxt, map: &ast_util::pat_id_map, pat: &@ast::pat,
let arg_len = vec::len::<ty::t>(arg_types);
if arg_len != subpats_len {
// TODO: note definition of tag variant
// TODO (issue #448): Wrap a #fmt string over multiple
// TODO (issue #448): Wrap a #ifmt string over multiple
// lines...
let s =
#fmt["this pattern has %u field%s, but the \
#ifmt["this pattern has %u field%s, but the \
corresponding variant has %u field%s",
subpats_len,
if subpats_len == 1u { "" } else { "s" },
arg_len, if arg_len == 1u { "" } else { "s" }];
if subpats_len == 1u { ~"" } else { ~"s" },
arg_len, if arg_len == 1u { ~"" } else { ~"s" }];
fcx.ccx.tcx.sess.span_fatal(
pat.span, istr::from_estr(s));
pat.span, s);
}
// TODO: vec::iter2
@ -1390,14 +1390,14 @@ fn check_pat(fcx: &@fn_ctxt, map: &ast_util::pat_id_map, pat: &@ast::pat,
} else if subpats_len > 0u {
// TODO: note definition of tag variant
fcx.ccx.tcx.sess.span_fatal(
pat.span, istr::from_estr(
#fmt["this pattern has %u field%s, \
pat.span,
#ifmt["this pattern has %u field%s, \
but the corresponding \
variant has no fields",
subpats_len,
if subpats_len == 1u {
""
} else { "s" }]));
~""
} else { ~"s" }]);
}
write::ty_fixup(fcx, pat.id, path_tpot);
}
@ -1405,9 +1405,9 @@ fn check_pat(fcx: &@fn_ctxt, map: &ast_util::pat_id_map, pat: &@ast::pat,
// FIXME: Switch expected and actual in this message? I
// can never tell.
fcx.ccx.tcx.sess.span_fatal(
pat.span, istr::from_estr(
#fmt["mismatched types: expected %s, found tag",
istr::to_estr(ty_to_str(fcx.ccx.tcx, expected))]));
pat.span,
#ifmt["mismatched types: expected %s, found tag",
ty_to_str(fcx.ccx.tcx, expected)]);
}
}
write::ty_fixup(fcx, pat.id, path_tpot);
@ -1418,20 +1418,20 @@ fn check_pat(fcx: &@fn_ctxt, map: &ast_util::pat_id_map, pat: &@ast::pat,
ty::ty_rec(fields) { ex_fields = fields; }
_ {
fcx.ccx.tcx.sess.span_fatal(
pat.span, istr::from_estr(
#fmt["mismatched types: expected %s, found record",
istr::to_estr(ty_to_str(fcx.ccx.tcx, expected))]));
pat.span,
#ifmt["mismatched types: expected %s, found record",
ty_to_str(fcx.ccx.tcx, expected)]);
}
}
let f_count = vec::len(fields);
let ex_f_count = vec::len(ex_fields);
if ex_f_count < f_count || !etc && ex_f_count > f_count {
fcx.ccx.tcx.sess.span_fatal(
pat.span, istr::from_estr(
#fmt["mismatched types: expected a record \
pat.span,
#ifmt["mismatched types: expected a record \
with %u fields, found one with %u \
fields",
ex_f_count, f_count]));
ex_f_count, f_count]);
}
fn matches(name: &istr, f: &ty::field) -> bool {
ret istr::eq(name, f.ident);
@ -1440,10 +1440,10 @@ fn check_pat(fcx: &@fn_ctxt, map: &ast_util::pat_id_map, pat: &@ast::pat,
alt vec::find(bind matches(f.ident, _), ex_fields) {
some(field) { check_pat(fcx, map, f.pat, field.mt.ty); }
none. {
fcx.ccx.tcx.sess.span_fatal(pat.span, istr::from_estr(
#fmt["mismatched types: did not \
fcx.ccx.tcx.sess.span_fatal(pat.span,
#ifmt["mismatched types: did not \
expect a record with a field %s",
istr::to_estr(f.ident)]));
f.ident]);
}
}
}
@ -1455,19 +1455,19 @@ fn check_pat(fcx: &@fn_ctxt, map: &ast_util::pat_id_map, pat: &@ast::pat,
ty::ty_tup(elts) { ex_elts = elts; }
_ {
fcx.ccx.tcx.sess.span_fatal(
pat.span, istr::from_estr(
#fmt["mismatched types: expected %s, found tuple",
istr::to_estr(ty_to_str(fcx.ccx.tcx, expected))]));
pat.span,
#ifmt["mismatched types: expected %s, found tuple",
ty_to_str(fcx.ccx.tcx, expected)]);
}
}
let e_count = vec::len(elts);
if e_count != vec::len(ex_elts) {
fcx.ccx.tcx.sess.span_fatal(
pat.span, istr::from_estr(
#fmt["mismatched types: expected a tuple \
pat.span,
#ifmt["mismatched types: expected a tuple \
with %u fields, found one with %u \
fields",
vec::len(ex_elts), e_count]));
vec::len(ex_elts), e_count]);
}
let i = 0u;
for elt in elts { check_pat(fcx, map, elt, ex_elts[i]); i += 1u; }
@ -1595,16 +1595,17 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr, unify: &unifier,
let expected_arg_count = vec::len(arg_tys);
let supplied_arg_count = vec::len(args);
if expected_arg_count != supplied_arg_count {
fcx.ccx.tcx.sess.span_err(sp, istr::from_estr(
#fmt["this function takes %u \
fcx.ccx.tcx.sess.span_err(
sp,
#ifmt["this function takes %u \
parameter%s but %u parameter%s supplied",
expected_arg_count,
if expected_arg_count == 1u {
""
} else { "s" }, supplied_arg_count,
if supplied_arg_count == 1u {
" was"
} else { "s were" }]));
expected_arg_count,
if expected_arg_count == 1u {
~""
} else { ~"s" }, supplied_arg_count,
if supplied_arg_count == 1u {
~" was"
} else { ~"s were" }]);
// HACK: extend the arguments list with dummy arguments to
// check against
let dummy = {mode: ty::mo_val, ty: ty::mk_nil(fcx.ccx.tcx)};
@ -1819,10 +1820,10 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr, unify: &unifier,
if !type_is_integral(fcx, oper.span, oper_t) &&
structure_of(fcx, oper.span, oper_t) != ty::ty_bool {
tcx.sess.span_err(
expr.span, istr::from_estr(
#fmt["mismatched types: expected bool \
expr.span,
#ifmt["mismatched types: expected bool \
or integer but found %s",
istr::to_estr(ty_to_str(tcx, oper_t))]));
ty_to_str(tcx, oper_t)]);
}
}
ast::neg. {
@ -2266,9 +2267,9 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr, unify: &unifier,
_ {
let t_err = resolve_type_vars_if_possible(fcx, base_t);
let msg =
#fmt["attempted field access on type %s",
istr::to_estr(ty_to_str(tcx, t_err))];
tcx.sess.span_fatal(expr.span, istr::from_estr(msg));
#ifmt["attempted field access on type %s",
ty_to_str(tcx, t_err)];
tcx.sess.span_fatal(expr.span, msg);
}
}
}

View file

@ -80,13 +80,13 @@ fn span_to_str(sp: &span, cm: &codemap) -> istr {
while true {
let lo = lookup_char_pos(cm, cur.lo);
let hi = lookup_char_pos(cm, cur.hi);
res += istr::from_estr(
#fmt["%s:%u:%u: %u:%u",
res +=
#ifmt["%s:%u:%u: %u:%u",
if some(lo.filename) == prev_file {
"-"
~"-"
} else {
istr::to_estr(lo.filename)
}, lo.line, lo.col, hi.line, hi.col]);
lo.filename
}, lo.line, lo.col, hi.line, hi.col];
alt cur.expanded_from {
os_none. { break; }
os_some(new_sp) {
@ -115,10 +115,9 @@ fn emit_diagnostic(sp: &option::t<span>, msg: &istr, kind: &istr, color: u8,
if term::color_supported() {
term::fg(io::stdout().get_buf_writer(), color);
}
io::stdout().write_str(istr::from_estr(#fmt["%s:", istr::to_estr(kind)]));
io::stdout().write_str(#ifmt[~"%s:", kind]);
if term::color_supported() { term::reset(io::stdout().get_buf_writer()); }
io::stdout().write_str(istr::from_estr(#fmt[" %s\n",
istr::to_estr(msg)]));
io::stdout().write_str(#ifmt[~" %s\n", msg]);
maybe_highlight_lines(sp, cm, maybe_lines);
}
@ -148,17 +147,15 @@ fn maybe_highlight_lines(sp: &option::t<span>, cm: &codemap,
// Print the offending lines
for line: uint in display_lines {
io::stdout().write_str(
istr::from_estr(#fmt["%s:%u ",
istr::to_estr(fm.name), line + 1u]));
#ifmt[~"%s:%u ", fm.name, line + 1u]);
let s = get_line(fm, line as int, file);
if !istr::ends_with(s, ~"\n") { s += ~"\n"; }
io::stdout().write_str(s);
}
if elided {
let last_line = display_lines[vec::len(display_lines) - 1u];
let s = #fmt["%s:%u ",
istr::to_estr(fm.name), last_line + 1u];
let indent = str::char_len(s);
let s = #ifmt[~"%s:%u ", fm.name, last_line + 1u];
let indent = istr::char_len(s);
let out = ~"";
while indent > 0u { out += ~" "; indent -= 1u; }
out += ~"...\n";

View file

@ -26,9 +26,9 @@ fn expand_expr(exts: &hashmap<istr, syntax_extension>, cx: &ext_ctxt,
let extname = pth.node.idents[0];
alt exts.find(extname) {
none. {
cx.span_fatal(pth.span, istr::from_estr(
#fmt["macro undefined: '%s'",
istr::to_estr(extname)]))
cx.span_fatal(pth.span,
#ifmt["macro undefined: '%s'",
extname])
}
some(normal(ext)) {
let expanded = ext(cx, pth.span, args, body);

View file

@ -1,7 +1,7 @@
/*
* The compiler code necessary to support the #fmt extension. Eventually this
* The compiler code necessary to support the #ifmt extension. Eventually this
* should all get sucked into either the standard library extfmt module or the
* compiler syntax extension plugin interface.
*/
@ -22,15 +22,16 @@ fn expand_syntax_ext(cx: &ext_ctxt, sp: span, arg: @ast::expr,
alt arg.node {
ast::expr_vec(elts, _) { elts }
_ {
cx.span_fatal(sp, ~"#fmt requires arguments of the form `[...]`.")
cx.span_fatal(
sp, ~"#ifmt requires arguments of the form `[...]`.")
}
};
if vec::len::<@ast::expr>(args) == 0u {
cx.span_fatal(sp, ~"#fmt requires a format string");
cx.span_fatal(sp, ~"#ifmt requires a format string");
}
let fmt =
expr_to_str(cx, args[0],
~"first argument to #fmt must be a "
~"first argument to #ifmt must be a "
+ ~"string literal.");
let fmtspan = args[0].span;
log "Format string:";
@ -151,7 +152,7 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
let count_is_args = [count_lit];
ret make_call(cx, sp, count_is_path, count_is_args);
}
_ { cx.span_unimpl(sp, ~"unimplemented #fmt conversion"); }
_ { cx.span_unimpl(sp, ~"unimplemented #ifmt conversion"); }
}
}
fn make_ty(cx: &ext_ctxt, sp: span, t: &ty) -> @ast::expr {
@ -205,7 +206,7 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
_ { ret false; }
}
}
let unsupported = ~"conversion not supported in #fmt string";
let unsupported = ~"conversion not supported in #ifmt string";
alt cnv.param {
option::none. { }
_ { cx.span_unimpl(sp, unsupported); }
@ -217,14 +218,14 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
if !is_signed_type(cnv) {
cx.span_fatal(sp,
~"+ flag only valid in " +
~"signed #fmt conversion");
~"signed #ifmt conversion");
}
}
flag_space_for_sign. {
if !is_signed_type(cnv) {
cx.span_fatal(sp,
~"space flag only valid in " +
~"signed #fmt conversions");
~"signed #ifmt conversions");
}
}
flag_left_zero_pad. { }
@ -330,7 +331,7 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
n += 1u;
if n >= nargs {
cx.span_fatal(sp,
~"not enough arguments to #fmt " +
~"not enough arguments to #ifmt " +
~"for the given format string");
}
log "Building conversion:";
@ -345,9 +346,9 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
if expected_nargs < nargs {
cx.span_fatal(
sp, istr::from_estr(
#fmt["too many arguments to #fmt. found %u, expected %u",
nargs, expected_nargs]));
sp,
#ifmt["too many arguments to #fmt. found %u, expected %u",
nargs, expected_nargs]);
}
ret tmp_expr;
}

View file

@ -1,7 +1,7 @@
/*
* The compiler code necessary to support the #fmt extension. Eventually this
* The compiler code necessary to support the #ifmt extension. Eventually this
* should all get sucked into either the standard library extfmt module or the
* compiler syntax extension plugin interface.
*/
@ -22,15 +22,16 @@ fn expand_syntax_ext(cx: &ext_ctxt, sp: span, arg: @ast::expr,
alt arg.node {
ast::expr_vec(elts, _) { elts }
_ {
cx.span_fatal(sp, ~"#fmt requires arguments of the form `[...]`.")
cx.span_fatal(
sp, ~"#ifmt requires arguments of the form `[...]`.")
}
};
if vec::len::<@ast::expr>(args) == 0u {
cx.span_fatal(sp, ~"#fmt requires a format string");
cx.span_fatal(sp, ~"#ifmt requires a format string");
}
let fmt =
expr_to_str(cx, args[0],
~"first argument to #fmt must be a "
~"first argument to #ifmt must be a "
+ ~"string literal.");
let fmtspan = args[0].span;
log "Format string:";
@ -151,7 +152,7 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
let count_is_args = [count_lit];
ret make_call(cx, sp, count_is_path, count_is_args);
}
_ { cx.span_unimpl(sp, ~"unimplemented #fmt conversion"); }
_ { cx.span_unimpl(sp, ~"unimplemented #ifmt conversion"); }
}
}
fn make_ty(cx: &ext_ctxt, sp: span, t: &ty) -> @ast::expr {
@ -205,7 +206,7 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
_ { ret false; }
}
}
let unsupported = ~"conversion not supported in #fmt string";
let unsupported = ~"conversion not supported in #ifmt string";
alt cnv.param {
option::none. { }
_ { cx.span_unimpl(sp, unsupported); }
@ -217,14 +218,14 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
if !is_signed_type(cnv) {
cx.span_fatal(sp,
~"+ flag only valid in " +
~"signed #fmt conversion");
~"signed #ifmt conversion");
}
}
flag_space_for_sign. {
if !is_signed_type(cnv) {
cx.span_fatal(sp,
~"space flag only valid in " +
~"signed #fmt conversions");
~"signed #ifmt conversions");
}
}
flag_left_zero_pad. { }
@ -330,7 +331,7 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
n += 1u;
if n >= nargs {
cx.span_fatal(sp,
~"not enough arguments to #fmt " +
~"not enough arguments to #ifmt " +
~"for the given format string");
}
log "Building conversion:";
@ -345,9 +346,9 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
if expected_nargs < nargs {
cx.span_fatal(
sp, istr::from_estr(
#fmt["too many arguments to #fmt. found %u, expected %u",
nargs, expected_nargs]));
sp,
#ifmt["too many arguments to #fmt. found %u, expected %u",
nargs, expected_nargs]);
}
ret tmp_expr;
}

View file

@ -309,13 +309,13 @@ fn transcribe_exprs(cx: &ext_ctxt, b: &bindings, idx_path: @mutable [uint],
let len = vec::len(*ms);
if old_len != len {
let msg =
#fmt["'%s' occurs %u times, but ",
istr::to_estr(fv), len] +
#fmt["'%s' occurs %u times",
istr::to_estr(old_name),
#ifmt["'%s' occurs %u times, but ",
fv, len] +
#ifmt["'%s' occurs %u times",
old_name,
old_len];
cx.span_fatal(
repeat_me.span, istr::from_estr(msg));
repeat_me.span, msg);
}
}
}

View file

@ -326,8 +326,7 @@ fn scan_numeric_escape(rdr: &reader, n_hex_digits: uint) -> char {
rdr.bump();
if !is_hex_digit(n) {
rdr.err(
istr::from_estr(
#fmt["illegal numeric character escape: %d", n as int]));
#ifmt["illegal numeric character escape: %d", n as int]);
fail;
}
accum_int *= 16;
@ -471,8 +470,8 @@ fn next_token_inner(rdr: &reader) -> token::token {
'U' { c2 = scan_numeric_escape(rdr, 8u); }
c2 {
rdr.err(
istr::from_estr(#fmt["unknown character escape: %d",
c2 as int]));
#ifmt["unknown character escape: %d",
c2 as int]);
fail;
}
}
@ -512,8 +511,8 @@ fn next_token_inner(rdr: &reader) -> token::token {
}
c2 {
rdr.err(
istr::from_estr(#fmt["unknown string escape: %d",
c2 as int]));
#ifmt["unknown string escape: %d",
c2 as int]);
fail;
}
}
@ -553,7 +552,7 @@ fn next_token_inner(rdr: &reader) -> token::token {
'%' { ret binop(rdr, token::PERCENT); }
c {
rdr.err(
istr::from_estr(#fmt["unkown start of token: %d", c as int]));
#ifmt["unkown start of token: %d", c as int]);
fail;
}
}
@ -654,7 +653,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];
log #ifmt["=== 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);

View file

@ -67,8 +67,7 @@ tag token { STRING(istr, int); BREAK(break_t); BEGIN(begin_t); END; EOF; }
fn tok_str(t: token) -> istr {
alt t {
STRING(s, len) {
ret istr::from_estr(
#fmt["STR(%s,%d)", istr::to_estr(s), len]);
ret #ifmt[~"STR(%s,%d)", s, len];
}
BREAK(_) { ret ~"BREAK"; }
BEGIN(_) { ret ~"BEGIN"; }
@ -87,8 +86,7 @@ fn buf_str(toks: &[mutable token], szs: &[mutable int], left: uint,
while i != right && L != 0u {
L -= 1u;
if i != left { s += ~", "; }
s += istr::from_estr(
#fmt["%d=%s", szs[i], istr::to_estr(tok_str(toks[i]))]);
s += #ifmt[~"%d=%s", szs[i], tok_str(toks[i])];
i += 1u;
i %= n;
}
@ -107,7 +105,7 @@ fn mk_printer(out: io::writer, linewidth: uint) -> printer {
// fall behind.
let n: uint = 3u * linewidth;
log #fmt["mk_printer %u", linewidth];
log #ifmt[~"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);
@ -247,7 +245,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];
log #ifmt[~"pp [%u,%u]", left, right];
alt t {
EOF. {
if !scan_stack_empty {
@ -263,17 +261,17 @@ obj printer(out: io::writer,
left = 0u;
right = 0u;
} else { self.advance_right(); }
log #fmt["pp BEGIN/buffer [%u,%u]", left, right];
log #ifmt[~"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];
log #ifmt[~"pp END/print [%u,%u]", left, right];
self.print(t, 0);
} else {
log #fmt["pp END/buffer [%u,%u]", left, right];
log #ifmt[~"pp END/buffer [%u,%u]", left, right];
self.advance_right();
token[right] = t;
size[right] = -1;
@ -287,7 +285,7 @@ obj printer(out: io::writer,
left = 0u;
right = 0u;
} else { self.advance_right(); }
log #fmt["pp BREAK/buffer [%u,%u]", left, right];
log #ifmt[~"pp BREAK/buffer [%u,%u]", left, right];
self.check_stack(0);
self.scan_push(right);
token[right] = t;
@ -296,10 +294,10 @@ obj printer(out: io::writer,
}
STRING(s, len) {
if scan_stack_empty {
log #fmt["pp STRING/print [%u,%u]", left, right];
log #ifmt[~"pp STRING/print [%u,%u]", left, right];
self.print(t, len);
} else {
log #fmt["pp STRING/buffer [%u,%u]", left, right];
log #ifmt[~"pp STRING/buffer [%u,%u]", left, right];
self.advance_right();
token[right] = t;
size[right] = len;
@ -310,14 +308,14 @@ obj printer(out: io::writer,
}
}
fn check_stream() {
log #fmt["check_stream [%u, %u] with left_total=%d, right_total=%d",
log #ifmt[~"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)",
log #ifmt[~"scan window is %d, longer than space on line (%d)",
right_total - left_total, space];
if !scan_stack_empty {
if left == scan_stack[bottom] {
log #fmt["setting %u to infinity and popping", left];
log #ifmt["setting %u to infinity and popping", left];
size[self.scan_pop_bottom()] = size_infinity;
}
}
@ -326,7 +324,7 @@ obj printer(out: io::writer,
}
}
fn scan_push(x: uint) {
log #fmt["scan_push %u", x];
log #ifmt["scan_push %u", x];
if scan_stack_empty {
scan_stack_empty = false;
} else { top += 1u; top %= buf_len; assert (top != bottom); }
@ -355,7 +353,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];
log #ifmt["advnce_left [%u,%u], sizeof(%u)=%d", left, right, left, L];
if L >= 0 {
self.print(x, L);
alt x {
@ -394,13 +392,13 @@ obj printer(out: io::writer,
}
}
fn print_newline(amount: int) {
log #fmt["NEWLINE %d", amount];
log #ifmt["NEWLINE %d", amount];
out.write_str(~"\n");
pending_indentation = 0;
self.indent(amount);
}
fn indent(amount: int) {
log #fmt["INDENT %d", amount];
log #ifmt["INDENT %d", amount];
pending_indentation += amount;
}
fn top() -> print_stack_elt {
@ -417,15 +415,15 @@ obj printer(out: io::writer,
out.write_str(s);
}
fn print(x: token, L: int) {
log #fmt["print %s %d (remaining line space=%d)",
istr::to_estr(tok_str(x)), L,
log #ifmt["print %s %d (remaining line space=%d)",
tok_str(x), L,
space];
log 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];
log #ifmt["print BEGIN -> push broken block at col %d", col];
print_stack += [{offset: col, pbreak: broken(b.breaks)}];
} else {
log "print BEGIN -> push fitting block";

View file

@ -362,7 +362,7 @@ fn dummy() {
alt *elts.(idx) {
leaf_destructure(x) { x }
_ {
ctx.ff(sp, #fmt["expected %s in position %u",
ctx.ff(sp, #ifmt["expected %s in position %u",
#ident_to_str[leaf_destructure], idx])
}
}],