Skip to content

Commit d83af64

Browse files
author
Eric Holk
committed
---
yaml --- r: 3130 b: refs/heads/master c: 02018fe h: refs/heads/master v: v3
1 parent cff960c commit d83af64

32 files changed

+761
-1138
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: 14c5900a701bf5d08f9512cbac52a8bf7dc8f4ef
2+
refs/heads/master: 02018fed427cf3d2954603392712a5822bf7a9b5

trunk/mk/stage3.mk

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
stage3/$(CFG_STDLIB): $(STDLIB_CRATE) $(STDLIB_INPUTS) \
1+
stage3/std.o: $(STDLIB_CRATE) $(STDLIB_INPUTS) \
22
stage2/rustc$(X) stage2/$(CFG_STDLIB) stage2/intrinsics.bc \
33
$(LREQ) $(MKFILES)
4-
@$(call E, compile_and_link: $@)
5-
$(STAGE2) --shared -o $@ $<
4+
@$(call E, compile: $@)
5+
$(STAGE2) -c --shared -o $@ $<
6+
7+
stage3/$(CFG_STDLIB): stage2/std.o stage2/glue.o
8+
@$(call E, link: $@)
9+
$(Q)gcc $(CFG_GCCISH_CFLAGS) stage2/glue.o $(CFG_GCCISH_LINK_FLAGS) -o \
10+
$@ $< -Lstage2 -Lrt -lrustrt
611

712
stage3/librustc.o: $(COMPILER_CRATE) $(COMPILER_INPUTS) $(SREQ2)
813
@$(call E, compile: $@)

trunk/src/comp/back/abi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ const int closure_elt_bindings = 2;
104104

105105
const int closure_elt_ty_params = 3;
106106

107-
const uint ivec_default_length = 4u;
107+
const uint ivec_default_length = 8u;
108108

109109
const uint ivec_elt_len = 0u;
110110

trunk/src/comp/back/link.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ mod write {
209209
*
210210
* There are a few issues to handle:
211211
*
212-
* - Linnkers operate on a flat namespace, so we have to flatten names.
212+
* - Linkers operate on a flat namespace, so we have to flatten names.
213213
* We do this using the C++ namespace-mangling technique. Foo::bar
214214
* symbols and such.
215215
*
@@ -221,15 +221,15 @@ mod write {
221221
* symbols in the same process before you're even hitting birthday-paradox
222222
* collision probability.
223223
*
224-
* - Symbols in different crates but with same names "within" the crate need
224+
* - Symbols in dirrerent crates but with same names "within" the crate need
225225
* to get different linkage-names.
226226
*
227227
* So here is what we do:
228228
*
229229
* - Separate the meta tags into two sets: exported and local. Only work with
230230
* the exported ones when considering linkage.
231231
*
232-
* - Consider two exported tags as special (and mandatory): name and vers.
232+
* - Consider two exported tags as special (and madatory): name and vers.
233233
* Every crate gets them; if it doesn't name them explicitly we infer them
234234
* as basename(crate) and "0.1", respectively. Call these CNAME, CVERS.
235235
*

trunk/src/comp/driver/rustc.rs

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,18 @@ fn compile_input(session::session sess, eval::env env, str input,
8181
auto crate =
8282
time(time_passes, "parsing", bind parse_input(sess, p, input));
8383
if (sess.get_opts().output_type == link::output_type_none) { ret; }
84-
auto d =
84+
auto def_map =
8585
time(time_passes, "resolution",
8686
bind resolve::resolve_crate(sess, crate));
87-
auto ty_cx = ty::mk_ctxt(sess, d._0, d._1);
87+
auto ty_cx = ty::mk_ctxt(sess, def_map);
8888
time[()](time_passes, "typechecking",
8989
bind typeck::check_crate(ty_cx, crate));
9090
if (sess.get_opts().run_typestate) {
9191
time(time_passes, "typestate checking",
9292
bind middle::tstate::ck::check_crate(ty_cx, crate));
9393
}
9494
time(time_passes, "alias checking",
95-
bind middle::alias::check_crate(@ty_cx, crate));
95+
bind middle::alias::check_crate(@ty_cx, def_map, crate));
9696
auto llmod =
9797
time[llvm::llvm::ModuleRef](time_passes, "translation",
9898
bind trans::trans_crate(sess, crate,
@@ -109,8 +109,8 @@ fn pretty_print_input(session::session sess, eval::env env, str input,
109109
auto mode;
110110
alt (ppm) {
111111
case (ppm_typed) {
112-
auto d = resolve::resolve_crate(sess, crate);
113-
auto ty_cx = ty::mk_ctxt(sess, d._0, d._1);
112+
auto def_map = resolve::resolve_crate(sess, crate);
113+
auto ty_cx = ty::mk_ctxt(sess, def_map);
114114
typeck::check_crate(ty_cx, crate);
115115
mode = ppaux::mo_typed(ty_cx);
116116
}
@@ -399,34 +399,37 @@ fn main(vec[str] args) {
399399
let str prog = "gcc";
400400
// The invocations of gcc share some flags across platforms
401401

402-
let vec[str] common_args = [stage, "-Lrt", "-lrustrt",
403-
"-fno-strict-aliasing", "-fPIC", "-Wall",
404-
"-fno-rtti", "-fno-exceptions", "-g", glu, "-o",
405-
saved_out_filename, saved_out_filename + ".o"];
406-
407-
auto shared_cmd;
408-
402+
let vec[str] common_cflags =
403+
["-fno-strict-aliasing", "-fPIC", "-Wall", "-fno-rtti",
404+
"-fno-exceptions", "-g"];
405+
let vec[str] common_libs =
406+
[stage, "-Lrustllvm", "-Lrt", "-lrustrt", "-lrustllvm", "-lstd",
407+
"-lm"];
409408
alt (sess.get_targ_cfg().os) {
410409
case (session::os_win32) {
411-
shared_cmd = "-shared";
412-
gcc_args = common_args + ["-march=i686", "-O2"];
410+
gcc_args =
411+
common_cflags +
412+
["-march=i686", "-O2", glu, main, "-o",
413+
saved_out_filename, saved_out_filename + ".o"] +
414+
common_libs;
413415
}
414416
case (session::os_macos) {
415-
shared_cmd = "-dynamiclib";
416-
gcc_args = common_args + ["-arch i386", "-O0", "-m32"];
417+
gcc_args =
418+
common_cflags +
419+
["-arch i386", "-O0", "-m32", glu, main, "-o",
420+
saved_out_filename, saved_out_filename + ".o"] +
421+
common_libs;
417422
}
418423
case (session::os_linux) {
419-
shared_cmd = "-shared";
420-
gcc_args = common_args + ["-march=i686", "-O2", "-m32"];
424+
gcc_args =
425+
common_cflags +
426+
["-march=i686", "-O2", "-m32", glu, main, "-o",
427+
saved_out_filename, saved_out_filename + ".o"] +
428+
common_libs;
421429
}
422430
}
423-
if (sopts.shared) {
424-
gcc_args += [shared_cmd];
425-
} else {
426-
gcc_args += ["-Lrustllvm", "-lrustllvm", "-lstd", "-lm", main];
427-
}
428-
429431
// We run 'gcc' here
432+
430433
run::run_program(prog, gcc_args);
431434
// Clean up on Darwin
432435

trunk/src/comp/front/ast.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -359,17 +359,19 @@ tag constr_arg_general_[T] { carg_base; carg_ident(T); carg_lit(@lit); }
359359
360360
type constr_arg = constr_arg_general[uint];
361361
362+
type constr_arg_use = constr_arg_general[ident];
363+
362364
type constr_arg_general[T] = spanned[constr_arg_general_[T]];
363365
364-
type constr_ = rec(path path,
365-
vec[@constr_arg_general[uint]] args,
366-
ann ann);
367366
368-
type constr = spanned[constr_];
367+
// The ann field is there so that using the def_map in the type
368+
// context, we can get the def_id for the path.
369+
type constr_general[T] =
370+
rec(path path, vec[@constr_arg_general[T]] args, ann ann);
371+
372+
type constr = spanned[constr_general[uint]];
369373
370-
/* The parser generates ast::constrs; resolve generates
371-
a mapping from each function to a list of ty::constr_defs,
372-
corresponding to these. */
374+
type constr_use = spanned[constr_general[ident]];
373375
374376
type arg = rec(mode mode, @ty ty, ident ident, def_id id);
375377

trunk/src/comp/front/creader.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ fn parse_ty_or_bang(@pstate st, str_def sd) -> ty_or_bang {
7878
}
7979
}
8080

81-
fn parse_constrs(@pstate st, str_def sd) -> vec[@ty::constr_def] {
82-
let vec[@ty::constr_def] res = [];
81+
fn parse_constrs(@pstate st, str_def sd) -> vec[@ast::constr] {
82+
let vec[@ast::constr] res = [];
8383
alt (peek(st) as char) {
8484
case (':') {
8585
do {
@@ -92,7 +92,7 @@ fn parse_constrs(@pstate st, str_def sd) -> vec[@ty::constr_def] {
9292
ret res;
9393
}
9494

95-
fn parse_constr(@pstate st, str_def sd) -> @ty::constr_def {
95+
fn parse_constr(@pstate st, str_def sd) -> @ast::constr {
9696
st.tcx.sess.unimpl("Reading constraints " + " isn't implemented");
9797
/*
9898
let vec[@ast::constr_arg] args = [];
@@ -318,7 +318,7 @@ fn parse_hex(@pstate st) -> uint {
318318
}
319319

320320
fn parse_ty_fn(@pstate st, str_def sd) ->
321-
tup(vec[ty::arg], ty::t, ast::controlflow, vec[@ty::constr_def]) {
321+
tup(vec[ty::arg], ty::t, ast::controlflow, vec[@ast::constr]) {
322322
assert (next(st) as char == '[');
323323
let vec[ty::arg] inputs = [];
324324
while (peek(st) as char != ']') {

trunk/src/comp/front/parser.rs

Lines changed: 16 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ import std::str;
55
import std::option;
66
import std::option::some;
77
import std::option::none;
8-
import std::either;
9-
import std::either::left;
10-
import std::either::right;
118
import std::map::hashmap;
129
import driver::session;
1310
import util::common;
@@ -819,9 +816,14 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
819816
hi = es.span.hi;
820817
ex = ast::expr_bind(e, es.node, p.get_ann());
821818
} else if (p.peek() == token::POUND) {
822-
auto ex_ext = parse_syntax_ext(p);
823-
lo = ex_ext.span.lo;
824-
ex = ex_ext.node;
819+
p.bump();
820+
auto pth = parse_path(p);
821+
auto es =
822+
parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA),
823+
parse_expr, p);
824+
hi = es.span.hi;
825+
auto ext_span = rec(lo=lo, hi=hi);
826+
ex = expand_syntax_ext(p, ext_span, pth, es.node, none);
825827
} else if (eat_word(p, "fail")) {
826828
auto msg;
827829
alt (p.peek()) {
@@ -915,21 +917,6 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
915917
ret @spanned(lo, hi, ex);
916918
}
917919

918-
fn parse_syntax_ext(&parser p) -> @ast::expr {
919-
auto lo = p.get_lo_pos();
920-
expect(p, token::POUND);
921-
ret parse_syntax_ext_inner(p, lo);
922-
}
923-
924-
fn parse_syntax_ext_inner(&parser p, uint lo) -> @ast::expr {
925-
auto pth = parse_path(p);
926-
auto es = parse_seq(token::LPAREN, token::RPAREN,
927-
some(token::COMMA), parse_expr, p);
928-
auto hi = es.span.hi;
929-
auto ext_span = rec(lo=lo, hi=hi);
930-
auto ex = expand_syntax_ext(p, ext_span, pth, es.node, none);
931-
ret @spanned(lo, hi, ex);
932-
}
933920

934921
/*
935922
* FIXME: This is a crude approximation of the syntax-extension system,
@@ -1436,22 +1423,7 @@ fn parse_source_stmt(&parser p) -> @ast::stmt {
14361423
auto hi = p.get_span();
14371424
ret @spanned(lo, decl.span.hi, ast::stmt_decl(decl, p.get_ann()));
14381425
} else {
1439-
1440-
auto item_attrs;
1441-
alt (parse_attrs_or_ext(p)) {
1442-
case (none) {
1443-
item_attrs = [];
1444-
}
1445-
case (some(left(?attrs))) {
1446-
item_attrs = attrs;
1447-
}
1448-
case (some(right(?ext))) {
1449-
ret @spanned(lo, ext.span.hi,
1450-
ast::stmt_expr(ext, p.get_ann()));
1451-
}
1452-
}
1453-
1454-
alt (parse_item(p, item_attrs)) {
1426+
alt (parse_item(p, [])) {
14551427
case (got_item(?i)) {
14561428
auto hi = i.span.hi;
14571429
auto decl = @spanned(lo, hi, ast::decl_item(i));
@@ -1964,26 +1936,6 @@ fn parse_item(&parser p, vec[ast::attribute] attrs) -> parsed_item {
19641936
} else { ret no_item; }
19651937
}
19661938

1967-
// A type to distingush between the parsing of item attributes or syntax
1968-
// extensions, which both begin with token.POUND
1969-
type attr_or_ext = option::t[either::t[vec[ast::attribute],
1970-
@ast::expr]];
1971-
1972-
fn parse_attrs_or_ext(&parser p) -> attr_or_ext {
1973-
if (p.peek() == token::POUND) {
1974-
auto lo = p.get_lo_pos();
1975-
p.bump();
1976-
if (p.peek() == token::LBRACKET) {
1977-
auto first_attr = parse_attribute_inner(p, lo);
1978-
ret some(left([first_attr] + parse_attributes(p)));
1979-
} else {
1980-
ret some(right(parse_syntax_ext_inner(p, lo)));
1981-
}
1982-
} else {
1983-
ret none;
1984-
}
1985-
}
1986-
19871939
fn parse_attributes(&parser p) -> vec[ast::attribute] {
19881940
let vec[ast::attribute] attrs = [];
19891941
while (p.peek() == token::POUND) { attrs += [parse_attribute(p)]; }
@@ -1993,10 +1945,6 @@ fn parse_attributes(&parser p) -> vec[ast::attribute] {
19931945
fn parse_attribute(&parser p) -> ast::attribute {
19941946
auto lo = p.get_lo_pos();
19951947
expect(p, token::POUND);
1996-
ret parse_attribute_inner(p, lo);
1997-
}
1998-
1999-
fn parse_attribute_inner(&parser p, uint lo) -> ast::attribute {
20001948
expect(p, token::LBRACKET);
20011949
auto meta_item = parse_meta_item(p);
20021950
expect(p, token::RBRACKET);
@@ -2233,7 +2181,13 @@ fn parse_crate_directive(&parser p) -> ast::crate_directive {
22332181
auto hi = p.get_hi_pos();
22342182
expect(p, token::RBRACE);
22352183
ret spanned(lo, hi, ast::cdir_let(id, x, v));
2236-
} else if (is_view_item(p)) {
2184+
} else if (is_word(p, "use")) {
2185+
auto vi = parse_view_item(p);
2186+
ret spanned(lo, vi.span.hi, ast::cdir_view_item(vi));
2187+
} else if (is_word(p, "import")) {
2188+
auto vi = parse_view_item(p);
2189+
ret spanned(lo, vi.span.hi, ast::cdir_view_item(vi));
2190+
} else if (is_word(p, "export")) {
22372191
auto vi = parse_view_item(p);
22382192
ret spanned(lo, vi.span.hi, ast::cdir_view_item(vi));
22392193
} else {

0 commit comments

Comments
 (0)