Convert the rest of rustc::middle to istrs. Issue #855

This commit is contained in:
Brian Anderson 2011-08-26 22:09:06 -07:00
parent 9e01e05f3b
commit 7d70685eef
10 changed files with 130 additions and 123 deletions

View File

@ -22,8 +22,8 @@ type ctxt = @{mutable next_tydesc_num: uint};
fn mk_ctxt() -> ctxt { ret @{mutable next_tydesc_num: 0u}; }
fn add_global(ccx: &@crate_ctxt, llval: ValueRef, name: str) -> ValueRef {
let llglobal = istr::as_buf(istr::from_estr(name), { |buf|
fn add_global(ccx: &@crate_ctxt, llval: ValueRef, name: &istr) -> ValueRef {
let llglobal = istr::as_buf(name, { |buf|
lll::LLVMAddGlobal(ccx.llmod, val_ty(llval), buf)
});
lll::LLVMSetInitializer(llglobal, llval);
@ -63,10 +63,10 @@ fn add_gc_root(cx: &@block_ctxt, llval: ValueRef, ty: ty::t) -> @block_ctxt {
let lldestindex =
add_global(bcx_ccx(bcx), C_struct([C_int(0), C_uint(number)]),
"rust_gc_tydesc_dest_index");
~"rust_gc_tydesc_dest_index");
let llsrcindex =
add_global(bcx_ccx(bcx), C_struct([C_int(1), C_uint(number)]),
"rust_gc_tydesc_src_index");
~"rust_gc_tydesc_src_index");
lldestindex = lll::LLVMConstPointerCast(lldestindex, T_ptr(T_i8()));
llsrcindex = lll::LLVMConstPointerCast(llsrcindex, T_ptr(T_i8()));
@ -86,7 +86,7 @@ fn add_gc_root(cx: &@block_ctxt, llval: ValueRef, ty: ty::t) -> @block_ctxt {
let llstaticgcmeta =
add_global(bcx_ccx(bcx), C_struct([C_int(2), lltydesc]),
"rust_gc_tydesc_static_gc_meta");
~"rust_gc_tydesc_static_gc_meta");
let llstaticgcmetaptr =
lll::LLVMConstPointerCast(llstaticgcmeta, T_ptr(T_i8()));

View File

@ -75,12 +75,12 @@ tag import_state {
option::t<def>); /* module */
}
type ext_hash = hashmap<{did: def_id, ident: str, ns: namespace}, def>;
type ext_hash = hashmap<{did: def_id, ident: istr, ns: namespace}, def>;
fn new_ext_hash() -> ext_hash {
type key = {did: def_id, ident: str, ns: namespace};
type key = {did: def_id, ident: istr, ns: namespace};
fn hash(v: &key) -> uint {
ret str::hash(v.ident) + util::common::hash_def(v.did) +
ret istr::hash(v.ident) + util::common::hash_def(v.did) +
alt v.ns {
ns_value. { 1u }
ns_type. { 2u }
@ -89,7 +89,7 @@ fn new_ext_hash() -> ext_hash {
}
fn eq(v1: &key, v2: &key) -> bool {
ret util::common::def_eq(v1.did, v2.did) &&
str::eq(v1.ident, v2.ident) && v1.ns == v2.ns;
istr::eq(v1.ident, v2.ident) && v1.ns == v2.ns;
}
ret std::map::mk_hashmap::<key, def>(hash, eq);
}
@ -128,7 +128,7 @@ type env =
mod_map: hashmap<ast::node_id, @indexed_mod>,
ext_map: hashmap<def_id, [ident]>,
ext_cache: ext_hash,
mutable reported: [{ident: str, sc: scope}],
mutable reported: [{ident: istr, sc: scope}],
sess: session};
@ -477,7 +477,8 @@ fn resolve_import(e: &env, defid: ast::def_id, name: &ast::ident,
alt lookup_in_scope(e, sc, sp, ids[0], ns_module) {
some(dcur) { dcur }
none. {
unresolved_err(e, sc, sp, ids[0], ns_name(ns_module));
unresolved_err(e, sc, sp, ids[0],
ns_name(ns_module));
remove_if_unresolved(e.imports, defid.node);
ret ()
}
@ -499,7 +500,8 @@ fn resolve_import(e: &env, defid: ast::def_id, name: &ast::ident,
{
some(dcur) { dcur }
none. {
unresolved_err(e, sc, sp, ids[i], ns_name(ns_module));
unresolved_err(e, sc, sp, ids[i],
ns_name(ns_module));
remove_if_unresolved(e.imports, defid.node);
ret () // FIXME (issue #521)
}
@ -512,7 +514,7 @@ fn resolve_import(e: &env, defid: ast::def_id, name: &ast::ident,
val: &option::t<def>, typ: &option::t<def>,
md: &option::t<def>) {
if is_none(val) && is_none(typ) && is_none(md) {
unresolved_err(e, sc, sp, name, "import");
unresolved_err(e, sc, sp, name, ~"import");
} else { e.imports.insert(defid.node, resolved(val, typ, md)); }
}
fn remove_if_unresolved(imports: hashmap<ast::node_id, import_state>,
@ -532,15 +534,16 @@ fn resolve_import(e: &env, defid: ast::def_id, name: &ast::ident,
// Utilities
fn ns_name(ns: namespace) -> str {
fn ns_name(ns: namespace) -> istr {
alt ns {
ns_type. { ret "typename"; }
ns_value. { ret "name"; }
ns_module. { ret "modulename"; }
ns_type. { ret ~"typename"; }
ns_value. { ret ~"name"; }
ns_module. { ret ~"modulename"; }
}
}
fn unresolved_err(e: &env, sc: &scopes, sp: &span, name: &ident, kind: &str) {
fn unresolved_err(e: &env, sc: &scopes, sp: &span,
name: &ident, kind: &istr) {
fn find_fn_or_mod_scope(sc: scopes) -> scope {
while true {
alt sc {
@ -558,20 +561,21 @@ fn unresolved_err(e: &env, sc: &scopes, sp: &span, name: &ident, kind: &str) {
fail;
}
let err_scope = find_fn_or_mod_scope(sc);
for rs: {ident: str, sc: scope} in e.reported {
if str::eq(rs.ident, istr::to_estr(name))
for rs: {ident: istr, sc: scope} in e.reported {
if istr::eq(rs.ident, name)
&& err_scope == rs.sc { ret; }
}
e.reported += [{ident: istr::to_estr(name), sc: err_scope}];
e.sess.span_err(sp, mk_unresolved_msg(name, kind));
e.reported += [{ident: name, sc: err_scope}];
e.sess.span_err(sp, istr::to_estr(mk_unresolved_msg(name, kind)));
}
fn unresolved_fatal(e: &env, sp: &span, id: &ident, kind: &str) -> ! {
e.sess.span_fatal(sp, mk_unresolved_msg(id, kind));
fn unresolved_fatal(e: &env, sp: &span, id: &ident, kind: &istr) -> ! {
e.sess.span_fatal(sp, istr::to_estr(mk_unresolved_msg(id, kind)));
}
fn mk_unresolved_msg(id: &ident, kind: &str) -> str {
ret #fmt["unresolved %s: %s", kind, istr::to_estr(id)];
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)]);
}
// Lookup helpers
@ -602,7 +606,8 @@ fn lookup_path_strict(e: &env, sc: &scopes, sp: &span, pth: &ast::path_,
fn lookup_in_scope_strict(e: &env, sc: scopes, sp: &span, name: &ident,
ns: namespace) -> option::t<def> {
alt lookup_in_scope(e, sc, sp, name, ns) {
none. { unresolved_err(e, sc, sp, name, ns_name(ns)); ret none; }
none. { unresolved_err(e, sc, sp, name,
ns_name(ns)); ret none; }
some(d) { ret some(d); }
}
}
@ -888,7 +893,8 @@ fn found_def_item(i: &@ast::item, ns: namespace) -> option::t<def> {
fn lookup_in_mod_strict(e: &env, sc: &scopes, m: def, sp: &span, name: &ident,
ns: namespace, dr: dir) -> option::t<def> {
alt lookup_in_mod(e, m, sp, name, ns, dr) {
none. { unresolved_err(e, sc, sp, name, ns_name(ns)); ret none; }
none. { unresolved_err(e, sc, sp, name,
ns_name(ns)); ret none; }
some(d) { ret some(d); }
}
}
@ -900,14 +906,14 @@ fn lookup_in_mod(e: &env, m: &def, sp: &span, name: &ident, ns: namespace,
// examining a module in an external crate
let cached = e.ext_cache.find({did: defid,
ident: istr::to_estr(name), ns: ns});
ident: name, ns: ns});
if !is_none(cached) { ret cached; }
let path = [name];
if defid.node != -1 { path = e.ext_map.get(defid) + path; }
let fnd = lookup_external(e, defid.crate, path, ns);
if !is_none(fnd) {
e.ext_cache.insert({did: defid,
ident: istr::to_estr(name), ns: ns},
ident: name, ns: ns},
option::get(fnd));
}
ret fnd;
@ -1214,26 +1220,26 @@ fn check_mod_name(e: &env, name: &ident, entries: list<mod_index_entry>) {
let saw_mod = false;
let saw_type = false;
let saw_value = false;
fn dup(e: &env, sp: &span, word: &str, name: &ident) {
e.sess.span_fatal(sp, "duplicate definition of " + word
+ istr::to_estr(name));
fn dup(e: &env, sp: &span, word: &istr, name: &ident) {
e.sess.span_fatal(sp, "duplicate definition of " +
istr::to_estr(word + name));
}
while true {
alt entries {
cons(entry, rest) {
if !is_none(lookup_in_mie(e, entry, ns_value)) {
if saw_value {
dup(e, mie_span(entry), "", name);
dup(e, mie_span(entry), ~"", name);
} else { saw_value = true; }
}
if !is_none(lookup_in_mie(e, entry, ns_type)) {
if saw_type {
dup(e, mie_span(entry), "type ", name);
dup(e, mie_span(entry), ~"type ", name);
} else { saw_type = true; }
}
if !is_none(lookup_in_mie(e, entry, ns_module)) {
if saw_mod {
dup(e, mie_span(entry), "module ", name);
dup(e, mie_span(entry), ~"module ", name);
} else { saw_mod = true; }
}
entries = *rest;
@ -1264,20 +1270,20 @@ fn check_item(e: &@env, i: &@ast::item, x: &(), v: &vt<()>) {
ast::item_fn(f, ty_params) {
check_fn(*e, i.span, f);
ensure_unique(*e, i.span, typaram_names(ty_params), ident_id,
"type parameter");
~"type parameter");
}
ast::item_obj(ob, ty_params, _) {
fn field_name(field: &ast::obj_field) -> ident { ret field.ident; }
ensure_unique(*e, i.span, ob.fields, field_name, "object field");
ensure_unique(*e, i.span, ob.fields, field_name, ~"object field");
for m: @ast::method in ob.methods {
check_fn(*e, m.span, m.node.meth);
}
ensure_unique(*e, i.span, typaram_names(ty_params), ident_id,
"type parameter");
~"type parameter");
}
ast::item_tag(_, ty_params) {
ensure_unique(*e, i.span, typaram_names(ty_params), ident_id,
"type parameter");
~"type parameter");
}
_ { }
}
@ -1292,13 +1298,13 @@ fn check_pat(ch: checker, p: &@ast::pat) {
fn check_arm(e: &@env, a: &ast::arm, x: &(), v: &vt<()>) {
visit::visit_arm(a, x, v);
let ch0 = checker(*e, "binding");
let ch0 = checker(*e, ~"binding");
check_pat(ch0, a.pats[0]);
let seen0 = ch0.seen;
let i = vec::len(a.pats);
while i > 1u {
i -= 1u;
let ch = checker(*e, "binding");
let ch = checker(*e, ~"binding");
check_pat(ch, a.pats[i]);
// Ensure the bindings introduced in this pattern are the same as in
@ -1322,15 +1328,15 @@ fn check_arm(e: &@env, a: &ast::arm, x: &(), v: &vt<()>) {
fn check_block(e: &@env, b: &ast::blk, x: &(), v: &vt<()>) {
visit::visit_block(b, x, v);
let values = checker(*e, "value");
let types = checker(*e, "type");
let mods = checker(*e, "module");
let values = checker(*e, ~"value");
let types = checker(*e, ~"type");
let mods = checker(*e, ~"module");
for st: @ast::stmt in b.node.stmts {
alt st.node {
ast::stmt_decl(d, _) {
alt d.node {
ast::decl_local(locs) {
let local_values = checker(*e, "value");
let local_values = checker(*e, ~"value");
for loc in locs {
for each p in ast_util::pat_bindings(loc.node.pat) {
let ident = alt p.node { pat_bind(n) { n } };
@ -1370,14 +1376,14 @@ fn check_block(e: &@env, b: &ast::blk, x: &(), v: &vt<()>) {
fn check_fn(e: &env, sp: &span, f: &ast::_fn) {
fn arg_name(a: &ast::arg) -> ident { ret a.ident; }
ensure_unique(e, sp, f.decl.inputs, arg_name, "argument");
ensure_unique(e, sp, f.decl.inputs, arg_name, ~"argument");
}
fn check_expr(e: &@env, ex: &@ast::expr, x: &(), v: &vt<()>) {
alt ex.node {
ast::expr_rec(fields, _) {
fn field_name(f: &ast::field) -> ident { ret f.node.ident; }
ensure_unique(*e, ex.span, fields, field_name, "field");
ensure_unique(*e, ex.span, fields, field_name, ~"field");
}
_ { }
}
@ -1388,16 +1394,16 @@ fn check_ty(e: &@env, ty: &@ast::ty, x: &(), v: &vt<()>) {
alt ty.node {
ast::ty_rec(fields) {
fn field_name(f: &ast::ty_field) -> ident { ret f.node.ident; }
ensure_unique(*e, ty.span, fields, field_name, "field");
ensure_unique(*e, ty.span, fields, field_name, ~"field");
}
_ { }
}
visit::visit_ty(ty, x, v);
}
type checker = @{mutable seen: [ident], kind: str, sess: session};
type checker = @{mutable seen: [ident], kind: istr, sess: session};
fn checker(e: &env, kind: str) -> checker {
fn checker(e: &env, kind: &istr) -> checker {
let seen: [ident] = [];
ret @{mutable seen: seen, kind: kind, sess: e.sess};
}
@ -1405,7 +1411,7 @@ fn checker(e: &env, kind: str) -> checker {
fn check_name(ch: &checker, sp: &span, name: &ident) {
for s: ident in ch.seen {
if istr::eq(s, name) {
ch.sess.span_fatal(sp, "duplicate " + ch.kind
ch.sess.span_fatal(sp, "duplicate " + istr::to_estr(ch.kind)
+ " name: " + istr::to_estr(name));
}
}
@ -1418,7 +1424,7 @@ fn add_name(ch: &checker, sp: &span, name: &ident) {
fn ident_id(i: &ident) -> ident { ret i; }
fn ensure_unique<T>(e: &env, sp: &span, elts: &[T], id: fn(&T) -> ident,
kind: &str) {
kind: &istr) {
let ch = checker(e, kind);
for elt: T in elts { add_name(ch, sp, id(elt)); }
}

View File

@ -85,9 +85,9 @@ fn eq_res_info(a: &res_info, b: &res_info) -> bool {
ret a.did.crate == b.did.crate && a.did.node == b.did.node && a.t == b.t;
}
fn mk_global(ccx: &@crate_ctxt, name: &str, llval: ValueRef,
fn mk_global(ccx: &@crate_ctxt, name: &istr, llval: ValueRef,
internal: bool) -> ValueRef {
let llglobal = istr::as_buf(istr::from_estr(name), { |buf|
let llglobal = istr::as_buf(name, { |buf|
lib::llvm::llvm::LLVMAddGlobal(ccx.llmod, val_ty(llval), buf)
});
lib::llvm::llvm::LLVMSetInitializer(llglobal, llval);
@ -521,7 +521,7 @@ fn gen_tag_shapes(ccx: &@crate_ctxt) -> ValueRef {
header += data;
header += lv_table;
ret mk_global(ccx, "tag_shapes", C_bytes(header), true);
ret mk_global(ccx, ~"tag_shapes", C_bytes(header), true);
}
fn gen_resource_shapes(ccx: &@crate_ctxt) -> ValueRef {
@ -534,7 +534,7 @@ fn gen_resource_shapes(ccx: &@crate_ctxt) -> ValueRef {
i += 1u;
}
ret mk_global(ccx, "resource_shapes", C_struct(dtors), true);
ret mk_global(ccx, ~"resource_shapes", C_struct(dtors), true);
}
fn gen_shape_tables(ccx: &@crate_ctxt) {

View File

@ -6403,7 +6403,7 @@ fn write_metadata(cx: &@crate_ctxt, crate: &@ast::crate) {
// Writes the current ABI version into the crate.
fn write_abi_version(ccx: &@crate_ctxt) {
shape::mk_global(ccx, "rust_abi_version", C_uint(abi::abi_version),
shape::mk_global(ccx, ~"rust_abi_version", C_uint(abi::abi_version),
false);
}

View File

@ -527,7 +527,7 @@ fn create_vtbl(cx: @local_ctxt, sp: &span, outer_obj_ty: ty::t,
}
}
ret finish_vtbl(cx, llmethods, "vtbl");
ret finish_vtbl(cx, llmethods, ~"vtbl");
}
// create_backwarding_vtbl: Create a vtable for the inner object of an
@ -561,16 +561,16 @@ fn create_backwarding_vtbl(cx: @local_ctxt, sp: &span, inner_obj_ty: ty::t,
// being forwarded to.
llmethods += [process_bkwding_mthd(cx, sp, @m, [], outer_obj_ty, [])];
}
ret finish_vtbl(cx, llmethods, "backwarding_vtbl");
ret finish_vtbl(cx, llmethods, ~"backwarding_vtbl");
}
// finish_vtbl: Given a vector of vtable entries, create the table in
// read-only memory and return a pointer to it.
fn finish_vtbl(cx: @local_ctxt, llmethods: [ValueRef], name: str) ->
fn finish_vtbl(cx: @local_ctxt, llmethods: [ValueRef], name: &istr) ->
ValueRef {
let vtbl = C_struct(llmethods);
let vtbl_name = mangle_internal_name_by_path(
cx.ccx, cx.path + [istr::from_estr(name)]);
cx.ccx, cx.path + [name]);
let gvar = istr::as_buf(vtbl_name, { |buf|
llvm::LLVMAddGlobal(cx.ccx.llmod, val_ty(vtbl), buf)
});

View File

@ -239,8 +239,8 @@ fn implies(a: t, b: t) -> bool {
ret tritv_doesntcare(tmp);
}
fn trit_str(t: trit) -> str {
alt t { dont_care. { "?" } ttrue. { "1" } tfalse. { "0" } }
fn trit_str(t: trit) -> istr {
alt t { dont_care. { ~"?" } ttrue. { ~"1" } tfalse. { ~"0" } }
}
//
// Local Variables:

View File

@ -56,47 +56,48 @@ tag oper_type {
}
/* logging funs */
fn def_id_to_str(d: def_id) -> str {
ret istr::to_estr(int::str(d.crate) + ~"," + int::str(d.node));
fn def_id_to_str(d: def_id) -> istr {
ret int::str(d.crate) + ~"," + int::str(d.node);
}
fn comma_str(args: &[@constr_arg_use]) -> str {
let rslt = "";
fn comma_str(args: &[@constr_arg_use]) -> istr {
let rslt = ~"";
let comma = false;
for a: @constr_arg_use in args {
if comma { rslt += ", "; } else { comma = true; }
if comma { rslt += ~", "; } else { comma = true; }
alt a.node {
carg_base. { rslt += "*"; }
carg_ident(i) { rslt += istr::to_estr(i.ident); }
carg_lit(l) { rslt += lit_to_str(l); }
carg_base. { rslt += ~"*"; }
carg_ident(i) { rslt += i.ident; }
carg_lit(l) { rslt += istr::from_estr(lit_to_str(l)); }
}
}
ret rslt;
}
fn constraint_to_str(tcx: &ty::ctxt, c: &sp_constr) -> str {
fn constraint_to_str(tcx: &ty::ctxt, c: &sp_constr) -> istr {
alt c.node {
ninit(_, i) {
ret "init(" +
istr::to_estr(i) + " [" + tcx.sess.span_str(c.span) + "])";
ret ~"init(" + i + ~" [" +
istr::from_estr(tcx.sess.span_str(c.span)) + ~"])";
}
npred(p, _, args) {
ret path_to_str(p) + "(" + comma_str(args) + ")" + "[" +
tcx.sess.span_str(c.span) + "]";
ret istr::from_estr(path_to_str(p)) + ~"(" +
comma_str(args) + ~")" + ~"[" +
istr::from_estr(tcx.sess.span_str(c.span)) + ~"]";
}
}
}
fn tritv_to_str(fcx: fn_ctxt, v: &tritv::t) -> str {
let s = "";
fn tritv_to_str(fcx: fn_ctxt, v: &tritv::t) -> istr {
let s = ~"";
let comma = false;
for p: norm_constraint in constraints(fcx) {
alt tritv_get(v, p.bit_num) {
dont_care. { }
t {
s +=
if comma { ", " } else { comma = true; "" } +
if t == tfalse { "!" } else { "" } +
if comma { ~", " } else { comma = true; ~"" } +
if t == tfalse { ~"!" } else { ~"" } +
constraint_to_str(fcx.ccx.tcx, p.c);
}
}
@ -107,8 +108,8 @@ fn tritv_to_str(fcx: fn_ctxt, v: &tritv::t) -> str {
fn log_tritv(fcx: &fn_ctxt, v: &tritv::t) { log tritv_to_str(fcx, v); }
fn first_difference_string(fcx: &fn_ctxt, expected: &tritv::t,
actual: &tritv::t) -> str {
let s: str = "";
actual: &tritv::t) -> istr {
let s: istr = ~"";
for c: norm_constraint in constraints(fcx) {
if tritv_get(expected, c.bit_num) == ttrue &&
tritv_get(actual, c.bit_num) != ttrue {
@ -120,12 +121,12 @@ fn first_difference_string(fcx: &fn_ctxt, expected: &tritv::t,
fn log_tritv_err(fcx: fn_ctxt, v: tritv::t) { log_err tritv_to_str(fcx, v); }
fn tos(v: &[uint]) -> str {
let rslt = "";
fn tos(v: &[uint]) -> istr {
let rslt = ~"";
for i: uint in v {
if i == 0u {
rslt += "0";
} else if i == 1u { rslt += "1"; } else { rslt += "?"; }
rslt += ~"0";
} else if i == 1u { rslt += ~"1"; } else { rslt += ~"?"; }
}
ret rslt;
}
@ -597,7 +598,7 @@ fn match_args(fcx: &fn_ctxt, occs: &@mutable [pred_args],
ret istr::to_estr(i.ident);
}, occ);
for pd: pred_args in *occs {
log "match_args: candidate " + pred_args_to_str(pd);
log ~"match_args: candidate " + pred_args_to_str(pd);
fn eq(p: &inst, q: &inst) -> bool { ret p.node == q.node; }
if ty::args_eq(eq, pd.node.args, occ) { ret pd.node.bit_num; }
}
@ -685,12 +686,12 @@ fn expr_to_constr(tcx: ty::ctxt, e: &@expr) -> sp_constr {
}
}
fn pred_args_to_str(p: &pred_args) -> str {
"<" + istr::to_estr(uint::str(p.node.bit_num)) + ", " +
constr_args_to_str(fn (i: &inst) -> str {
ret istr::to_estr(i.ident);
}, p.node.args)
+ ">"
fn pred_args_to_str(p: &pred_args) -> istr {
istr::from_estr("<" + istr::to_estr(uint::str(p.node.bit_num)) + ", " +
constr_args_to_str(fn (i: &inst) -> str {
ret istr::to_estr(i.ident);
}, p.node.args)
+ ">")
}
fn substitute_constr_args(cx: &ty::ctxt, actuals: &[@expr], c: &@ty::constr)
@ -789,18 +790,18 @@ fn find_in_subst_bool(s: &subst, id: node_id) -> bool {
is_some(find_in_subst(id, s))
}
fn insts_to_str(stuff: &[constr_arg_general_<inst>]) -> str {
let rslt = "<";
fn insts_to_str(stuff: &[constr_arg_general_<inst>]) -> istr {
let rslt = ~"<";
for i: constr_arg_general_<inst> in stuff {
rslt +=
" " +
~" " +
alt i {
carg_ident(p) { istr::to_estr(p.ident) }
carg_base. { "*" }
carg_lit(_) { "[lit]" }
} + " ";
carg_ident(p) { p.ident }
carg_base. { ~"*" }
carg_lit(_) { ~"[lit]" }
} + ~" ";
}
rslt += ">";
rslt += ~">";
rslt
}

View File

@ -82,17 +82,17 @@ fn check_states_expr(e: &@expr, fcx: &fn_ctxt, v: &visit::vt<fn_ctxt>) {
*/
if !implies(pres, prec) {
let s = "";
let s = ~"";
let diff = first_difference_string(fcx, prec, pres);
s +=
"Unsatisfied precondition constraint (for example, " + diff +
") for expression:\n";
s += syntax::print::pprust::expr_to_str(e);
s += "\nPrecondition:\n";
~"Unsatisfied precondition constraint (for example, " + diff +
~") for expression:\n";
s += istr::from_estr(syntax::print::pprust::expr_to_str(e));
s += ~"\nPrecondition:\n";
s += tritv_to_str(fcx, prec);
s += "\nPrestate:\n";
s += ~"\nPrestate:\n";
s += tritv_to_str(fcx, pres);
fcx.ccx.tcx.sess.span_fatal(e.span, s);
fcx.ccx.tcx.sess.span_fatal(e.span, istr::to_estr(s));
}
}
@ -114,17 +114,17 @@ fn check_states_stmt(s: &@stmt, fcx: &fn_ctxt, v: &visit::vt<fn_ctxt>) {
*/
if !implies(pres, prec) {
let ss = "";
let ss = ~"";
let diff = first_difference_string(fcx, prec, pres);
ss +=
"Unsatisfied precondition constraint (for example, " + diff +
") for statement:\n";
ss += syntax::print::pprust::stmt_to_str(*s);
ss += "\nPrecondition:\n";
~"Unsatisfied precondition constraint (for example, " + diff +
~") for statement:\n";
ss += istr::from_estr(syntax::print::pprust::stmt_to_str(*s));
ss += ~"\nPrecondition:\n";
ss += tritv_to_str(fcx, prec);
ss += "\nPrestate: \n";
ss += ~"\nPrestate: \n";
ss += tritv_to_str(fcx, pres);
fcx.ccx.tcx.sess.span_fatal(s.span, ss);
fcx.ccx.tcx.sess.span_fatal(s.span, istr::to_estr(ss));
}
}

View File

@ -61,8 +61,8 @@ fn find_locals(tcx: &ty::ctxt, f: &_fn, tps: &[ty_param], sp: &span,
fn add_constraint(tcx: &ty::ctxt, c: sp_constr, next: uint, tbl: constr_map)
-> uint {
log constraint_to_str(tcx, c) + " |-> "
+ istr::to_estr(std::uint::str(next));
log constraint_to_str(tcx, c) + ~" |-> "
+ std::uint::str(next);
alt c.node {
ninit(id, i) { tbl.insert(local_def(id), cinit(next, c.span, i)); }
npred(p, d_id, args) {

View File

@ -261,15 +261,15 @@ fn to_vec(v: &t) -> [uint] {
ret rslt;
}
fn to_str(v: &t) -> str {
fn to_str(v: &t) -> istr {
let i: uint = 0u;
let rs: str = "";
let rs: istr = ~"";
while i < v.nbits {
rs +=
alt tritv_get(v, i) {
dont_care. { "?" }
ttrue. { "1" }
tfalse. { "0" }
dont_care. { ~"?" }
ttrue. { ~"1" }
tfalse. { ~"0" }
};
i += 1u;
}