Move tyencode::ty_str to metadata::encoder
This commit is contained in:
parent
73963eae9a
commit
7d26d1d67b
@ -4,6 +4,7 @@ import lib::llvm::llvm;
|
||||
import front::attr;
|
||||
import middle::trans;
|
||||
import middle::ty;
|
||||
import metadata::encoder;
|
||||
import std::str;
|
||||
import std::fs;
|
||||
import std::vec;
|
||||
@ -407,7 +408,7 @@ fn symbol_hash(ty::ctxt tcx, sha1 sha, &ty::t t,
|
||||
// FIXME: This wants to be link_meta.meta_hash
|
||||
sha.input_str(link_meta.name);
|
||||
sha.input_str("-");
|
||||
sha.input_str(metadata::tyencode::ty_str(tcx, t));
|
||||
sha.input_str(encoder::ty_str(tcx, t));
|
||||
auto hash = truncated_sha1_result(sha);
|
||||
// Prefix with _ so that it never blends into adjacent digits
|
||||
|
||||
|
@ -18,6 +18,7 @@ import front::attr;
|
||||
|
||||
export def_to_str;
|
||||
export encode_metadata;
|
||||
export ty_str;
|
||||
|
||||
// Path table encoding
|
||||
fn encode_name(&ebml::writer ebml_w, &str name) {
|
||||
@ -540,6 +541,16 @@ fn encode_metadata(&@crate_ctxt cx, &@crate crate) -> str {
|
||||
ret string_w.get_str();
|
||||
}
|
||||
|
||||
// Get the encoded string for a type
|
||||
fn ty_str(&ty::ctxt tcx, &ty::t t) -> str {
|
||||
auto cx = @rec(ds = encoder::def_to_str,
|
||||
tcx = tcx,
|
||||
abbrevs = metadata::tyencode::ac_no_abbrevs);
|
||||
auto sw = io::string_writer();
|
||||
tyencode::enc_ty(sw.get_writer(), cx, t);
|
||||
ret sw.get_str();
|
||||
}
|
||||
|
||||
|
||||
// Local Variables:
|
||||
// mode: rust
|
||||
|
@ -16,7 +16,6 @@ export ty_abbrev;
|
||||
export ac_no_abbrevs;
|
||||
export ac_use_abbrevs;
|
||||
export enc_ty;
|
||||
export ty_str;
|
||||
|
||||
type ctxt =
|
||||
rec(fn(&def_id) -> str ds, // Def -> str Callback:
|
||||
@ -36,14 +35,7 @@ fn cx_uses_abbrevs(&@ctxt cx) -> bool {
|
||||
case (ac_use_abbrevs(_)) { ret true; }
|
||||
}
|
||||
}
|
||||
fn ty_str(&ty::ctxt tcx, &ty::t t) -> str {
|
||||
auto cx = @rec(ds = encoder::def_to_str,
|
||||
tcx = tcx,
|
||||
abbrevs = metadata::tyencode::ac_no_abbrevs);
|
||||
auto sw = io::string_writer();
|
||||
enc_ty(sw.get_writer(), cx, t);
|
||||
ret sw.get_str();
|
||||
}
|
||||
|
||||
fn enc_ty(&io::writer w, &@ctxt cx, &ty::t t) {
|
||||
alt (cx.abbrevs) {
|
||||
case (ac_no_abbrevs) {
|
||||
|
@ -8,6 +8,7 @@ import std::option::none;
|
||||
import std::option::some;
|
||||
import middle::ty;
|
||||
import middle::ty::*;
|
||||
import metadata::encoder;
|
||||
import syntax::print::pp;
|
||||
import syntax::print::pprust;
|
||||
import pp::word;
|
||||
@ -151,7 +152,7 @@ fn ty_to_str(&ctxt cx, &t typ) -> str {
|
||||
}
|
||||
|
||||
fn ty_to_short_str(&ctxt cx, t typ) -> str {
|
||||
auto s = metadata::tyencode::ty_str(cx, typ);
|
||||
auto s = encoder::ty_str(cx, typ);
|
||||
if (str::byte_len(s) >= 32u) { s = str::substr(s, 0u, 32u); }
|
||||
ret s;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user