Skip to content

Commit d03945d

Browse files
committed
---
yaml --- r: 3011 b: refs/heads/master c: 40e3a9f h: refs/heads/master i: 3009: 4923492 3007: 28d49db v: v3
1 parent f3bf66c commit d03945d

File tree

7 files changed

+37
-148
lines changed

7 files changed

+37
-148
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: 60706f1e3559a1164c96378172bc8839c9870f51
2+
refs/heads/master: 40e3a9fcbcd6d9ebb98bc29729b1ef1b4dbec95c

trunk/src/comp/back/link.rs

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ mod write {
279279
*/
280280

281281

282-
iter crate_export_metas(&ast::crate c) -> @ast::meta_item {
282+
iter crate_export_metas(ast::crate c) -> @ast::meta_item {
283283
for (@ast::crate_directive cdir in c.node.directives) {
284284
alt (cdir.node) {
285285
case (ast::cdir_meta(?v, ?mis)) {
@@ -293,30 +293,12 @@ iter crate_export_metas(&ast::crate c) -> @ast::meta_item {
293293
}
294294
}
295295
}
296-
297-
298-
iter crate_local_metas(&ast::crate c) -> @ast::meta_item {
299-
for (@ast::crate_directive cdir in c.node.directives) {
300-
alt (cdir.node) {
301-
case (ast::cdir_meta(?v, ?mis)) {
302-
if (v == ast::local_meta) {
303-
for (@ast::meta_item mi in mis) {
304-
put mi;
305-
}
306-
}
307-
}
308-
case (_) {}
309-
}
310-
}
311-
}
312-
313-
314-
fn get_crate_meta_export(&session::session sess,
315-
&ast::crate c, str k, str default,
316-
bool warn_default) -> str {
296+
fn get_crate_meta(&session::session sess,
297+
&ast::crate c, str k, str default,
298+
bool warn_default) -> str {
317299
let vec[@ast::meta_item] v = [];
318300
for each (@ast::meta_item mi in crate_export_metas(c)) {
319-
if (mi.node.key == k) {
301+
if (mi.node.name == k) {
320302
v += [mi];
321303
}
322304
}
@@ -341,7 +323,7 @@ fn get_crate_meta_export(&session::session sess,
341323
fn crate_meta_extras_hash(sha1 sha, &ast::crate crate) -> str {
342324
fn lteq(&@ast::meta_item ma,
343325
&@ast::meta_item mb) -> bool {
344-
ret ma.node.key <= mb.node.key;
326+
ret ma.node.name <= mb.node.name;
345327
}
346328

347329
fn len_and_str(&str s) -> str {
@@ -350,16 +332,16 @@ fn crate_meta_extras_hash(sha1 sha, &ast::crate crate) -> str {
350332

351333
let vec[mutable @ast::meta_item] v = [mutable];
352334
for each (@ast::meta_item mi in crate_export_metas(crate)) {
353-
if (mi.node.key != "name" &&
354-
mi.node.key != "vers") {
335+
if (mi.node.name != "name" &&
336+
mi.node.name != "vers") {
355337
v += [mutable mi];
356338
}
357339
}
358340
sort::quick_sort(lteq, v);
359341
sha.reset();
360342
for (@ast::meta_item m_ in v) {
361343
auto m = m_;
362-
sha.input_str(len_and_str(m.node.key));
344+
sha.input_str(len_and_str(m.node.name));
363345
sha.input_str(len_and_str(m.node.value));
364346
}
365347
ret truncated_sha1_result(sha);
@@ -370,13 +352,13 @@ fn crate_meta_name(&session::session sess, &ast::crate crate,
370352
auto os = str::split(fs::basename(output), '.' as u8);
371353
assert vec::len(os) >= 2u;
372354
vec::pop(os);
373-
ret get_crate_meta_export(sess, crate, "name", str::connect(os, "."),
374-
sess.get_opts().shared);
355+
ret get_crate_meta(sess, crate, "name", str::connect(os, "."),
356+
sess.get_opts().shared);
375357
}
376358

377359
fn crate_meta_vers(&session::session sess, &ast::crate crate) -> str {
378-
ret get_crate_meta_export(sess, crate, "vers", "0.0",
379-
sess.get_opts().shared);
360+
ret get_crate_meta(sess, crate, "vers", "0.0",
361+
sess.get_opts().shared);
380362
}
381363

382364
fn truncated_sha1_result(sha1 sha) -> str {

trunk/src/comp/front/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ type crate_directive = spanned[crate_directive_];
9797

9898

9999
type meta_item = spanned[meta_item_];
100-
type meta_item_ = rec(ident key, str value);
100+
type meta_item_ = rec(ident name, str value);
101101

102102
type block = spanned[block_];
103103
type block_ = rec(vec[@stmt] stmts,

trunk/src/comp/front/creader.rs

Lines changed: 16 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -502,75 +502,24 @@ fn get_metadata_section(str filename) -> option::t[vec[u8]] {
502502
}
503503

504504

505-
fn metadata_matches(&vec[u8] data,
506-
&vec[@ast::meta_item] metas) -> bool {
507-
ret true;
508-
}
509-
510-
fn find_library_crate(&session::session sess,
511-
&ast::ident ident,
512-
&vec[@ast::meta_item] metas,
513-
&vec[str] library_search_paths)
514-
-> option::t[tup(str, vec[u8])] {
515-
516-
let str crate_name = ident;
517-
for (@ast::meta_item mi in metas) {
518-
if (mi.node.key == "name") {
519-
crate_name = mi.node.value;
520-
break;
521-
}
522-
}
523-
auto nn = parser::default_native_lib_naming(sess);
524-
let str prefix = nn.prefix + crate_name;
525-
526-
// FIXME: we could probably use a 'glob' function in std::fs but it will
527-
// be much easier to write once the unsafe module knows more about FFI
528-
// tricks. Currently the glob(3) interface is a bit more than we can
529-
// stomach from here, and writing a C++ wrapper is more work than just
530-
// manually filtering fs::list_dir here.
531-
505+
fn load_crate(session::session sess,
506+
int cnum,
507+
ast::ident ident,
508+
vec[str] library_search_paths) {
509+
auto filename = parser::default_native_name(sess, ident);
532510
for (str library_search_path in library_search_paths) {
533-
534-
for (str path in fs::list_dir(library_search_path)) {
535-
536-
let str f = fs::basename(path);
537-
if (! (str::starts_with(f, prefix) &&
538-
str::ends_with(f, nn.suffix))) {
539-
log #fmt("skipping %s, doesn't look like %s*%s",
540-
path, prefix, nn.suffix);
541-
cont;
511+
auto path = fs::connect(library_search_path, filename);
512+
alt (get_metadata_section(path)) {
513+
case (option::some(?cvec)) {
514+
sess.set_external_crate(cnum, rec(name=ident, data=cvec));
515+
ret;
542516
}
543-
544-
alt (get_metadata_section(path)) {
545-
case (option::some(?cvec)) {
546-
if (!metadata_matches(cvec, metas)) {
547-
log #fmt("skipping %s, metadata doesn't match", path);
548-
cont;
549-
}
550-
log #fmt("found %s with matching metadata", path);
551-
ret some(tup(path, cvec));
552-
}
553-
case (_) {}
554-
}
555-
}
556-
}
557-
ret none;
558-
}
559-
560-
fn load_library_crate(&session::session sess,
561-
&int cnum,
562-
&ast::ident ident,
563-
&vec[@ast::meta_item] metas,
564-
&vec[str] library_search_paths) {
565-
alt (find_library_crate(sess, ident, metas, library_search_paths)) {
566-
case (some(?t)) {
567-
sess.set_external_crate(cnum, rec(name=ident,
568-
data=t._1));
569-
ret;
517+
case (_) {}
570518
}
571-
case (_) {}
572519
}
573-
log_err #fmt("can't find crate for '%s'", ident);
520+
521+
log_err #fmt("can't open crate '%s' (looked for '%s' in lib search path)",
522+
ident, filename);
574523
fail;
575524
}
576525

@@ -588,8 +537,8 @@ fn visit_view_item(env e, &@ast::view_item i) {
588537
auto cnum;
589538
if (!e.crate_cache.contains_key(ident)) {
590539
cnum = e.next_crate_num;
591-
load_library_crate(e.sess, cnum, ident, meta_items,
592-
e.library_search_paths);
540+
load_crate(e.sess, cnum, ident,
541+
e.library_search_paths);
593542
e.crate_cache.insert(ident, e.next_crate_num);
594543
e.next_crate_num += 1;
595544
} else {

trunk/src/comp/front/parser.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1992,26 +1992,20 @@ fn parse_native_mod_items(&parser p, &str native_name,
19921992
items=items);
19931993
}
19941994

1995-
fn default_native_lib_naming(session::session sess)
1996-
-> rec(str prefix, str suffix) {
1995+
fn default_native_name(session::session sess, str id) -> str {
19971996
alt (sess.get_targ_cfg().os) {
19981997
case (session::os_win32) {
1999-
ret rec(prefix="", suffix=".dll");
1998+
ret id + ".dll";
20001999
}
20012000
case (session::os_macos) {
2002-
ret rec(prefix="lib", suffix=".dylib");
2001+
ret "lib" + id + ".dylib";
20032002
}
20042003
case (session::os_linux) {
2005-
ret rec(prefix="lib", suffix=".so");
2004+
ret "lib" + id + ".so";
20062005
}
20072006
}
20082007
}
20092008

2010-
fn default_native_name(session::session sess, str id) -> str {
2011-
auto n = default_native_lib_naming(sess);
2012-
ret n.prefix + id + n.suffix;
2013-
}
2014-
20152009
fn parse_item_native_mod(&parser p) -> @ast::item {
20162010
auto lo = p.get_last_lo_pos();
20172011
auto abi = ast::native_abi_cdecl;
@@ -2200,7 +2194,7 @@ fn parse_meta_item(&parser p) -> @ast::meta_item {
22002194
case (token::LIT_STR(?s)) {
22012195
auto hi = p.get_hi_pos();
22022196
p.bump();
2203-
ret @spanned(lo, hi, rec(key = ident,
2197+
ret @spanned(lo, hi, rec(name = ident,
22042198
value = p.get_str(s)));
22052199
}
22062200
case (_) {

trunk/src/comp/middle/metadata.rs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import middle::trans;
1414
import middle::ty;
1515
import middle::ty::path_to_str;
1616
import back::x86;
17-
import back::link;
1817
import util::common;
1918
import pretty::ppaux::lit_to_str;
2019

@@ -47,12 +46,6 @@ const uint tag_index_buckets_bucket = 0x13u;
4746
const uint tag_index_buckets_bucket_elt = 0x14u;
4847
const uint tag_index_table = 0x15u;
4948

50-
const uint tag_meta_export = 0x16u;
51-
const uint tag_meta_local = 0x17u;
52-
const uint tag_meta_item = 0x18u;
53-
const uint tag_meta_item_key = 0x19u;
54-
const uint tag_meta_item_value = 0x20u;
55-
5649
// Type encoding
5750

5851
// Compact string representation for ty.t values. API ty_str & parse_from_str.
@@ -718,41 +711,12 @@ fn write_int(&io::writer writer, &int n) {
718711
}
719712

720713

721-
fn encode_meta_items(&ebml::writer ebml_w, &ast::crate crate) {
722-
723-
fn encode_meta_item(&ebml::writer ebml_w, &ast::meta_item mi) {
724-
ebml::start_tag(ebml_w, tag_meta_item);
725-
ebml::start_tag(ebml_w, tag_meta_item_key);
726-
ebml_w.writer.write(str::bytes(mi.node.key));
727-
ebml::end_tag(ebml_w);
728-
ebml::start_tag(ebml_w, tag_meta_item_value);
729-
ebml_w.writer.write(str::bytes(mi.node.value));
730-
ebml::end_tag(ebml_w);
731-
ebml::end_tag(ebml_w);
732-
}
733-
734-
ebml::start_tag(ebml_w, tag_meta_export);
735-
for each (@ast::meta_item mi in link::crate_export_metas(crate)) {
736-
encode_meta_item(ebml_w, *mi);
737-
}
738-
ebml::end_tag(ebml_w);
739-
740-
ebml::start_tag(ebml_w, tag_meta_local);
741-
for each (@ast::meta_item mi in link::crate_local_metas(crate)) {
742-
encode_meta_item(ebml_w, *mi);
743-
}
744-
ebml::end_tag(ebml_w);
745-
}
746-
747714
fn encode_metadata(&@trans::crate_ctxt cx, &@ast::crate crate)
748715
-> ValueRef {
749716
auto string_w = io::string_writer();
750717
auto buf_w = string_w.get_writer().get_buf_writer();
751718
auto ebml_w = ebml::create_writer(buf_w);
752719

753-
// Encode the meta items
754-
encode_meta_items(ebml_w, *crate);
755-
756720
// Encode and index the paths.
757721
ebml::start_tag(ebml_w, tag_paths);
758722
auto paths_index = encode_item_paths(ebml_w, crate);

trunk/src/comp/pretty/pprust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ fn print_view_item(&ps s, &@ast::view_item item) {
10001000
popen(s);
10011001
fn print_meta(&ps s, &@ast::meta_item item) {
10021002
ibox(s, indent_unit);
1003-
word_space(s, item.node.key);
1003+
word_space(s, item.node.name);
10041004
word_space(s, "=");
10051005
print_string(s, item.node.value);
10061006
end(s);

0 commit comments

Comments
 (0)