Skip to content

Commit d9ab493

Browse files
committed
---
yaml --- r: 3685 b: refs/heads/master c: 7d26d1d h: refs/heads/master i: 3683: 2cf09d3 v: v3
1 parent ad10a58 commit d9ab493

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 73963eae9a37d16bab872f3ffc9bdcc1b4567c00
2+
refs/heads/master: 7d26d1d67b271dcc2a422e13138163cd31393fd3

trunk/src/comp/back/link.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import lib::llvm::llvm;
44
import front::attr;
55
import middle::trans;
66
import middle::ty;
7+
import metadata::encoder;
78
import std::str;
89
import std::fs;
910
import std::vec;
@@ -407,7 +408,7 @@ fn symbol_hash(ty::ctxt tcx, sha1 sha, &ty::t t,
407408
// FIXME: This wants to be link_meta.meta_hash
408409
sha.input_str(link_meta.name);
409410
sha.input_str("-");
410-
sha.input_str(metadata::tyencode::ty_str(tcx, t));
411+
sha.input_str(encoder::ty_str(tcx, t));
411412
auto hash = truncated_sha1_result(sha);
412413
// Prefix with _ so that it never blends into adjacent digits
413414

trunk/src/comp/metadata/encoder.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import front::attr;
1818

1919
export def_to_str;
2020
export encode_metadata;
21+
export ty_str;
2122

2223
// Path table encoding
2324
fn encode_name(&ebml::writer ebml_w, &str name) {
@@ -540,6 +541,16 @@ fn encode_metadata(&@crate_ctxt cx, &@crate crate) -> str {
540541
ret string_w.get_str();
541542
}
542543

544+
// Get the encoded string for a type
545+
fn ty_str(&ty::ctxt tcx, &ty::t t) -> str {
546+
auto cx = @rec(ds = encoder::def_to_str,
547+
tcx = tcx,
548+
abbrevs = metadata::tyencode::ac_no_abbrevs);
549+
auto sw = io::string_writer();
550+
tyencode::enc_ty(sw.get_writer(), cx, t);
551+
ret sw.get_str();
552+
}
553+
543554

544555
// Local Variables:
545556
// mode: rust

trunk/src/comp/metadata/tyencode.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export ty_abbrev;
1616
export ac_no_abbrevs;
1717
export ac_use_abbrevs;
1818
export enc_ty;
19-
export ty_str;
2019

2120
type ctxt =
2221
rec(fn(&def_id) -> str ds, // Def -> str Callback:
@@ -36,14 +35,7 @@ fn cx_uses_abbrevs(&@ctxt cx) -> bool {
3635
case (ac_use_abbrevs(_)) { ret true; }
3736
}
3837
}
39-
fn ty_str(&ty::ctxt tcx, &ty::t t) -> str {
40-
auto cx = @rec(ds = encoder::def_to_str,
41-
tcx = tcx,
42-
abbrevs = metadata::tyencode::ac_no_abbrevs);
43-
auto sw = io::string_writer();
44-
enc_ty(sw.get_writer(), cx, t);
45-
ret sw.get_str();
46-
}
38+
4739
fn enc_ty(&io::writer w, &@ctxt cx, &ty::t t) {
4840
alt (cx.abbrevs) {
4941
case (ac_no_abbrevs) {

trunk/src/comp/util/ppaux.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import std::option::none;
88
import std::option::some;
99
import middle::ty;
1010
import middle::ty::*;
11+
import metadata::encoder;
1112
import syntax::print::pp;
1213
import syntax::print::pprust;
1314
import pp::word;
@@ -151,7 +152,7 @@ fn ty_to_str(&ctxt cx, &t typ) -> str {
151152
}
152153

153154
fn ty_to_short_str(&ctxt cx, t typ) -> str {
154-
auto s = metadata::tyencode::ty_str(cx, typ);
155+
auto s = encoder::ty_str(cx, typ);
155156
if (str::byte_len(s) >= 32u) { s = str::substr(s, 0u, 32u); }
156157
ret s;
157158
}

0 commit comments

Comments
 (0)