Skip to content

Commit badf8c6

Browse files
lhtbrson
authored andcommitted
---
yaml --- r: 6288 b: refs/heads/master c: 88f29aa h: refs/heads/master v: v3
1 parent f3f88a8 commit badf8c6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+169
-129
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: 7a9b66db631478b7f42cdbfae52f96d5e7bb0a1f
2+
refs/heads/master: 88f29aab27bf56bda4cf7062cb53af0be4b5c251

trunk/src/comp/front/config.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ fn fold_native_mod(cfg: ast::crate_cfg, nm: ast::native_mod,
4545
fld: fold::ast_fold) -> ast::native_mod {
4646
let filter = bind filter_native_item(cfg, _);
4747
let filtered_items = vec::filter_map(filter, nm.items);
48-
ret {native_name: nm.native_name,
49-
abi: nm.abi,
48+
ret {abi: nm.abi,
5049
view_items: vec::map(fld.fold_view_item, nm.view_items),
5150
items: filtered_items};
5251
}

trunk/src/comp/lib/llvm.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ const LLVMRealULE: uint = 13u;
110110
const LLVMRealUNE: uint = 14u;
111111

112112
#[link_args = "-Lrustllvm"]
113-
native "cdecl" mod llvm = "rustllvm" {
113+
#[link_name = "rustllvm"]
114+
#[abi = "cdecl"]
115+
native mod llvm {
114116

115117
type ModuleRef;
116118
type ContextRef;

trunk/src/comp/metadata/creader.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ fn visit_item(e: env, i: @ast::item) {
5454
ret;
5555
}
5656
let cstore = e.sess.get_cstore();
57-
if !cstore::add_used_library(cstore, m.native_name) { ret; }
57+
let native_name = i.ident;
58+
alt attr::get_meta_item_value_str_by_name(i.attrs, "link_name") {
59+
some(nn) { native_name = nn; }
60+
none. { }
61+
}
62+
if !cstore::add_used_library(cstore, native_name) { ret; }
5863
for a: ast::attribute in
5964
attr::find_attrs_by_name(i.attrs, "link_args") {
6065

trunk/src/comp/syntax/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ tag native_abi {
432432
}
433433

434434
type native_mod =
435-
{native_name: str,
435+
{// FIXME: Removing abi from AST. Depends on Issue #1179.
436436
abi: native_abi,
437437
view_items: [@view_item],
438438
items: [@native_item]};

trunk/src/comp/syntax/fold.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,7 @@ fn noop_fold_mod(m: _mod, fld: ast_fold) -> _mod {
452452
}
453453

454454
fn noop_fold_native_mod(nm: native_mod, fld: ast_fold) -> native_mod {
455-
ret {native_name: nm.native_name,
456-
abi: nm.abi,
455+
ret {abi: nm.abi,
457456
view_items: vec::map(fld.fold_view_item, nm.view_items),
458457
items: vec::map(fld.fold_native_item, nm.items)}
459458
}

trunk/src/comp/syntax/parse/parser.rs

Lines changed: 20 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1978,7 +1978,7 @@ fn parse_native_item(p: parser, attrs: [ast::attribute]) ->
19781978
} else { unexpected(p, p.peek()); }
19791979
}
19801980

1981-
fn parse_native_mod_items(p: parser, native_name: str, abi: ast::native_abi,
1981+
fn parse_native_mod_items(p: parser, abi: ast::native_abi,
19821982
first_item_attrs: [ast::attribute]) ->
19831983
ast::native_mod {
19841984
// Shouldn't be any view items since we've already parsed an item attr
@@ -1993,63 +1993,37 @@ fn parse_native_mod_items(p: parser, native_name: str, abi: ast::native_abi,
19931993
initial_attrs = [];
19941994
items += [parse_native_item(p, attrs)];
19951995
}
1996-
ret {native_name: native_name,
1997-
abi: abi,
1996+
ret {abi: abi,
19981997
view_items: view_items,
19991998
items: items};
20001999
}
20012000

20022001
fn parse_item_native_mod(p: parser, attrs: [ast::attribute]) -> @ast::item {
20032002
let lo = p.get_last_lo_pos();
2004-
let abi = ast::native_abi_cdecl;
2005-
if !is_word(p, "mod") {
2006-
let t = parse_str(p);
2007-
if str::eq(t, "rust-intrinsic") {
2008-
abi = ast::native_abi_rust_intrinsic;
2009-
} else if str::eq(t, "cdecl") {
2010-
abi = ast::native_abi_cdecl;
2011-
} else if str::eq(t, "stdcall") {
2012-
abi = ast::native_abi_stdcall;
2013-
} else {
2014-
p.fatal("unsupported abi: " + t);
2015-
}
2016-
} else {
2017-
abi =
2018-
alt attr::get_meta_item_value_str_by_name(attrs, "abi") {
2019-
none. { ast::native_abi_cdecl }
2020-
some("rust-intrinsic") {
2021-
ast::native_abi_rust_intrinsic
2022-
}
2023-
some("cdecl") {
2024-
ast::native_abi_cdecl
2025-
}
2026-
some("stdcall") {
2027-
ast::native_abi_stdcall
2028-
}
2029-
some(t) {
2030-
p.fatal("unsupported abi: " + t);
2031-
}
2032-
};
2033-
}
20342003
expect_word(p, "mod");
20352004
let id = parse_ident(p);
2036-
let native_name;
2037-
if p.peek() == token::EQ {
2038-
expect(p, token::EQ);
2039-
native_name = parse_str(p);
2040-
} else {
2041-
native_name =
2042-
alt attr::get_meta_item_value_str_by_name(attrs, "link_name") {
2043-
none. { id }
2044-
some(nn) { nn }
2045-
};
2046-
}
20472005
expect(p, token::LBRACE);
20482006
let more_attrs = parse_inner_attrs_and_next(p);
20492007
let inner_attrs = more_attrs.inner;
20502008
let first_item_outer_attrs = more_attrs.next;
2051-
let m =
2052-
parse_native_mod_items(p, native_name, abi, first_item_outer_attrs);
2009+
let abi =
2010+
alt attr::get_meta_item_value_str_by_name(
2011+
attrs + inner_attrs, "abi") {
2012+
none. { ast::native_abi_cdecl }
2013+
some("rust-intrinsic") {
2014+
ast::native_abi_rust_intrinsic
2015+
}
2016+
some("cdecl") {
2017+
ast::native_abi_cdecl
2018+
}
2019+
some("stdcall") {
2020+
ast::native_abi_stdcall
2021+
}
2022+
some(t) {
2023+
p.fatal("unsupported abi: " + t);
2024+
}
2025+
};
2026+
let m = parse_native_mod_items(p, abi, first_item_outer_attrs);
20532027
let hi = p.get_hi_pos();
20542028
expect(p, token::RBRACE);
20552029
ret mk_item(p, lo, hi, id, ast::item_native_mod(m), attrs + inner_attrs);

trunk/src/comp/syntax/print/pprust.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -395,24 +395,8 @@ fn print_item(s: ps, &&item: @ast::item) {
395395
}
396396
ast::item_native_mod(nmod) {
397397
head(s, "native");
398-
alt nmod.abi {
399-
ast::native_abi_rust_intrinsic. {
400-
word_nbsp(s, "\"rust-intrinsic\"");
401-
}
402-
ast::native_abi_cdecl. {
403-
word_nbsp(s, "\"cdecl\"");
404-
}
405-
ast::native_abi_stdcall. {
406-
word_nbsp(s, "\"stdcall\"");
407-
}
408-
}
409398
word_nbsp(s, "mod");
410399
word_nbsp(s, item.ident);
411-
if !str::eq(nmod.native_name, item.ident) {
412-
word_space(s, "=");
413-
print_string(s, nmod.native_name);
414-
nbsp(s);
415-
}
416400
bopen(s);
417401
print_native_mod(s, nmod, item.attrs);
418402
bclose(s, item.span);

trunk/src/lib/comm.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export recv;
3434
export chan;
3535
export port;
3636

37-
native "cdecl" mod rustrt {
37+
#[abi = "cdecl"]
38+
native mod rustrt {
3839
type void;
3940
type rust_port;
4041

@@ -48,7 +49,8 @@ native "cdecl" mod rustrt {
4849
fn rust_port_size(po: *rust_port) -> ctypes::size_t;
4950
}
5051

51-
native "rust-intrinsic" mod rusti {
52+
#[abi = "rust-intrinsic"]
53+
native mod rusti {
5254
fn recv<uniq T>(port: *rustrt::rust_port) -> T;
5355
}
5456

trunk/src/lib/dbg.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
* logging.
99
*/
1010

11-
native "cdecl" mod rustrt {
11+
#[abi = "cdecl"]
12+
native mod rustrt {
1213
fn debug_tydesc(td: *sys::type_desc);
1314
fn debug_opaque<T>(td: *sys::type_desc, x: T);
1415
fn debug_box<T>(td: *sys::type_desc, x: @T);

trunk/src/lib/fs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ File system manipulation
77
import os::getcwd;
88
import os_fs;
99

10-
native "cdecl" mod rustrt {
10+
#[abi = "cdecl"]
11+
native mod rustrt {
1112
fn rust_file_is_dir(path: str::sbuf) -> int;
1213
}
1314

trunk/src/lib/io.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

2-
native "cdecl" mod rustrt {
2+
#[abi = "cdecl"]
3+
native mod rustrt {
34
fn rust_get_stdin() -> os::libc::FILE;
45
fn rust_get_stdout() -> os::libc::FILE;
56
fn rust_get_stderr() -> os::libc::FILE;

trunk/src/lib/linux_os.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ TODO: Restructure and document
66

77
// FIXME Somehow merge stuff duplicated here and macosx_os.rs. Made difficult
88
// by https://github.com/graydon/rust/issues#issue/268
9-
native "cdecl" mod libc = "" {
9+
#[link_name = ""]
10+
#[abi = "cdecl"]
11+
native mod libc {
1012
fn read(fd: int, buf: *u8, count: uint) -> int;
1113
fn write(fd: int, buf: *u8, count: uint) -> int;
1214
fn fread(buf: *u8, size: uint, n: uint, f: libc::FILE) -> uint;
@@ -81,7 +83,8 @@ fn waitpid(pid: int) -> int {
8183
ret status;
8284
}
8385

84-
native "cdecl" mod rustrt {
86+
#[abi = "cdecl"]
87+
native mod rustrt {
8588
fn rust_getcwd() -> str;
8689
}
8790

trunk/src/lib/macos_os.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

2-
native "cdecl" mod libc = "" {
2+
#[link_name = ""]
3+
#[abi = "cdecl"]
4+
native mod libc {
35
fn read(fd: int, buf: *u8, count: uint) -> int;
46
fn write(fd: int, buf: *u8, count: uint) -> int;
57
fn fread(buf: *u8, size: uint, n: uint, f: libc::FILE) -> uint;
@@ -74,7 +76,8 @@ fn waitpid(pid: int) -> int {
7476
ret status;
7577
}
7678

77-
native "cdecl" mod rustrt {
79+
#[abi = "cdecl"]
80+
native mod rustrt {
7881
fn rust_getcwd() -> str;
7982
}
8083

trunk/src/lib/math.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/* Module: math */
22

3-
native "cdecl" mod libc = "" {
3+
#[link_name = ""]
4+
#[abi = "cdecl"]
5+
native mod libc {
46
fn sqrt(n: float) -> float;
57
fn sin(n: float) -> float;
68
fn asin(n: float) -> float;

trunk/src/lib/posix_fs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
native "cdecl" mod rustrt {
1+
#[abi = "cdecl"]
2+
native mod rustrt {
23
fn rust_list_files(path: str) -> [str];
34
}
45

trunk/src/lib/ptr.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ Module: ptr
33
44
Unsafe pointer utility functions
55
*/
6-
native "rust-intrinsic" mod rusti {
6+
#[abi = "rust-intrinsic"]
7+
native mod rusti {
78
fn addr_of<T>(val: T) -> *T;
89
fn ptr_offset<T>(ptr: *T, count: uint) -> *T;
910
}

trunk/src/lib/rand.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ Module: rand
33
44
Random number generation
55
*/
6-
native "cdecl" mod rustrt {
6+
#[abi = "cdecl"]
7+
native mod rustrt {
78
type rctx;
89
fn rand_new() -> rctx;
910
fn rand_next(c: rctx) -> u32;

trunk/src/lib/run_program.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export program_output;
1212
export spawn_process;
1313
export waitpid;
1414

15-
native "cdecl" mod rustrt {
15+
#[abi = "cdecl"]
16+
native mod rustrt {
1617
fn rust_run_program(argv: *sbuf, in_fd: int, out_fd: int, err_fd: int) ->
1718
int;
1819
}

trunk/src/lib/str.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ export eq, lteq, hash, is_empty, is_not_empty, is_whitespace, byte_len,
1616
contains, iter_chars, loop_chars, loop_chars_sub,
1717
escape;
1818

19-
native "cdecl" mod rustrt {
19+
#[abi = "cdecl"]
20+
native mod rustrt {
2021
fn rust_str_push(&s: str, ch: u8);
2122
}
2223

trunk/src/lib/sys.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ tag type_desc {
77
type_desc(@type_desc);
88
}
99

10-
native "cdecl" mod rustrt {
10+
#[abi = "cdecl"]
11+
native mod rustrt {
1112
// Explicitly re-export native stuff we want to be made
1213
// available outside this crate. Otherwise it's
1314
// visible-in-crate, but not re-exported.
@@ -19,7 +20,8 @@ native "cdecl" mod rustrt {
1920
fn unsupervise();
2021
}
2122

22-
native "rust-intrinsic" mod rusti {
23+
#[abi = "rust-intrinsic"]
24+
native mod rusti {
2325
fn get_type_desc<T>() -> *type_desc;
2426
}
2527

trunk/src/lib/task.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,15 @@ export spawn;
5050
export spawn_notify;
5151
export spawn_joinable;
5252

53-
native "rust-intrinsic" mod rusti {
53+
#[abi = "rust-intrinsic"]
54+
native mod rusti {
5455
// these must run on the Rust stack so that they can swap stacks etc:
5556
fn task_sleep(time_in_us: uint);
5657
}
5758

58-
native "cdecl" mod rustrt = "rustrt" {
59+
#[link_name = "rustrt"]
60+
#[abi = "cdecl"]
61+
native mod rustrt {
5962
// these can run on the C stack:
6063
fn pin_task();
6164
fn unpin_task();

trunk/src/lib/test.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ export default_test_to_task;
2525
export configure_test_task;
2626
export joinable;
2727

28-
native "cdecl" mod rustrt {
28+
#[abi = "cdecl"]
29+
native mod rustrt {
2930
fn sched_threads() -> uint;
3031
}
3132

trunk/src/lib/time.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ Module: time
44

55
// FIXME: Document what these functions do
66

7-
native "cdecl" mod rustrt {
7+
#[abi = "cdecl"]
8+
native mod rustrt {
89
fn get_time(&sec: u32, &usec: u32);
910
fn nano_time(&ns: u64);
1011
}

trunk/src/lib/unicode.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ mod icu {
148148
// FIXME: should be -1, change when compiler supports negative
149149
// constants
150150

151-
native "cdecl" mod libicu = "icuuc" {
151+
#[link_name = "icuuc"]
152+
#[abi = "cdecl"]
153+
native mod libicu {
152154
fn u_hasBinaryProperty(c: UChar32, which: UProperty) -> UBool;
153155
}
154156
}

0 commit comments

Comments
 (0)