Skip to content

Commit 024a65e

Browse files
author
Lenny222
committed
---
yaml --- r: 6925 b: refs/heads/master c: d812d06 h: refs/heads/master i: 6923: fb225ce v: v3
1 parent d073177 commit 024a65e

31 files changed

+499
-347
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: 9587c672301663d46f8d97d34bb82cd0506f8454
2+
refs/heads/master: d812d06bc8d8f5c655b206838b64b133c83a7975

trunk/src/comp/front/test.rs

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn fold_mod(_cx: test_ctxt, m: ast::_mod, fld: fold::ast_fold) -> ast::_mod {
5151
// we want to be main.
5252
fn nomain(&&item: @ast::item) -> option::t<@ast::item> {
5353
alt item.node {
54-
ast::item_fn(_, _, _) {
54+
ast::item_fn(f, _) {
5555
if item.ident == "main" {
5656
option::none
5757
} else { option::some(item) }
@@ -83,7 +83,7 @@ fn fold_item(cx: test_ctxt, &&i: @ast::item, fld: fold::ast_fold) ->
8383

8484
if is_test_fn(i) {
8585
alt i.node {
86-
ast::item_fn(decl, _, _) when decl.purity == ast::unsafe_fn {
86+
ast::item_fn(f, _) when f.decl.purity == ast::unsafe_fn {
8787
cx.sess.span_fatal(
8888
i.span,
8989
"unsafe functions cannot be used for tests");
@@ -110,9 +110,9 @@ fn is_test_fn(i: @ast::item) -> bool {
110110

111111
fn has_test_signature(i: @ast::item) -> bool {
112112
alt i.node {
113-
ast::item_fn(decl, tps, _) {
114-
let input_cnt = vec::len(decl.inputs);
115-
let no_output = decl.output.node == ast::ty_nil;
113+
ast::item_fn(f, tps) {
114+
let input_cnt = vec::len(f.decl.inputs);
115+
let no_output = f.decl.output.node == ast::ty_nil;
116116
let tparm_cnt = vec::len(tps);
117117
input_cnt == 0u && no_output && tparm_cnt == 0u
118118
}
@@ -190,12 +190,13 @@ fn mk_tests(cx: test_ctxt) -> @ast::item {
190190
let ret_ty = mk_test_desc_vec_ty(cx);
191191

192192
let decl: ast::fn_decl =
193-
{proto: ast::proto_bare,
194-
inputs: [],
193+
{inputs: [],
195194
output: ret_ty,
196195
purity: ast::impure_fn,
196+
il: ast::il_normal,
197197
cf: ast::return_val,
198198
constraints: []};
199+
let proto = ast::proto_bare;
199200

200201
// The vector of test_descs for this crate
201202
let test_descs = mk_test_desc_vec(cx);
@@ -204,7 +205,9 @@ fn mk_tests(cx: test_ctxt) -> @ast::item {
204205
default_block([], option::some(test_descs), cx.sess.next_node_id());
205206
let body = nospan(body_);
206207

207-
let item_ = ast::item_fn(decl, [], body);
208+
let fn_ = {decl: decl, proto: proto, body: body};
209+
210+
let item_ = ast::item_fn(fn_, []);
208211
let item: ast::item =
209212
{ident: "tests",
210213
attrs: [],
@@ -322,10 +325,10 @@ fn mk_test_wrapper(cx: test_ctxt,
322325
ast::stmt_expr(@call_expr, cx.sess.next_node_id()));
323326

324327
let wrapper_decl: ast::fn_decl = {
325-
proto: ast::proto_bare,
326328
inputs: [],
327329
output: @nospan(ast::ty_nil),
328330
purity: ast::impure_fn,
331+
il: ast::il_normal,
329332
cf: ast::return_val,
330333
constraints: []
331334
};
@@ -338,14 +341,20 @@ fn mk_test_wrapper(cx: test_ctxt,
338341
rules: ast::default_blk
339342
});
340343

344+
let wrapper_fn: ast::_fn = {
345+
decl: wrapper_decl,
346+
proto: ast::proto_bare,
347+
body: wrapper_body
348+
};
349+
341350
let wrapper_capture: @ast::capture_clause = @{
342351
copies: [],
343352
moves: []
344353
};
345354

346355
let wrapper_expr: ast::expr = {
347356
id: cx.sess.next_node_id(),
348-
node: ast::expr_fn(wrapper_decl, wrapper_body, wrapper_capture),
357+
node: ast::expr_fn(wrapper_fn, wrapper_capture),
349358
span: span
350359
};
351360

@@ -366,12 +375,13 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
366375
let ret_ty = nospan(ast::ty_nil);
367376

368377
let decl: ast::fn_decl =
369-
{proto: ast::proto_bare,
370-
inputs: [args_arg],
378+
{inputs: [args_arg],
371379
output: @ret_ty,
372380
purity: ast::impure_fn,
381+
il: ast::il_normal,
373382
cf: ast::return_val,
374383
constraints: []};
384+
let proto = ast::proto_bare;
375385

376386
let test_main_call_expr = mk_test_main_call(cx);
377387

@@ -380,7 +390,9 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
380390
cx.sess.next_node_id());
381391
let body = {node: body_, span: dummy_sp()};
382392

383-
let item_ = ast::item_fn(decl, [], body);
393+
let fn_ = {decl: decl, proto: proto, body: body};
394+
395+
let item_ = ast::item_fn(fn_, []);
384396
let item: ast::item =
385397
{ident: "main",
386398
attrs: [],

trunk/src/comp/metadata/common.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ const tag_crate_deps: uint = 0x25u;
6262
// A single crate dependency
6363
const tag_crate_dep: uint = 0x26u;
6464

65+
const tag_items_data_item_inlineness: uint = 0x27u;
66+
6567
const tag_crate_hash: uint = 0x28u;
6668

6769
const tag_mod_impl: uint = 0x30u;

trunk/src/comp/metadata/encoder.rs

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ fn encode_module_item_paths(ebml_w: ebml::writer, module: _mod, path: [str],
7474
encode_def_id(ebml_w, local_def(it.id));
7575
ebml::end_tag(ebml_w);
7676
}
77-
item_fn(_, tps, _) {
77+
item_fn(_, tps) {
7878
add_to_index(ebml_w, path, index, it.ident);
7979
ebml::start_tag(ebml_w, tag_paths_data_item);
8080
encode_name(ebml_w, it.ident);
@@ -105,7 +105,7 @@ fn encode_module_item_paths(ebml_w: ebml::writer, module: _mod, path: [str],
105105
encode_def_id(ebml_w, local_def(it.id));
106106
ebml::end_tag(ebml_w);
107107
}
108-
item_res(_, tps, _, _, ctor_id) {
108+
item_res(_, _, tps, ctor_id) {
109109
add_to_index(ebml_w, path, index, it.ident);
110110
ebml::start_tag(ebml_w, tag_paths_data_item);
111111
encode_name(ebml_w, it.ident);
@@ -173,6 +173,12 @@ fn encode_family(ebml_w: ebml::writer, c: u8) {
173173
ebml::end_tag(ebml_w);
174174
}
175175

176+
fn encode_inlineness(ebml_w: ebml::writer, c: u8) {
177+
ebml::start_tag(ebml_w, tag_items_data_item_inlineness);
178+
ebml_w.writer.write([c]);
179+
ebml::end_tag(ebml_w);
180+
}
181+
176182
fn def_to_str(did: def_id) -> str { ret #fmt["%d:%d", did.crate, did.node]; }
177183

178184
fn encode_type_param_kinds(ebml_w: ebml::writer, tps: [ty_param]) {
@@ -276,15 +282,20 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
276282
encode_symbol(ecx, ebml_w, item.id);
277283
ebml::end_tag(ebml_w);
278284
}
279-
item_fn(decl, tps, _) {
285+
item_fn(fd, tps) {
280286
ebml::start_tag(ebml_w, tag_items_data_item);
281287
encode_def_id(ebml_w, local_def(item.id));
282288
encode_family(ebml_w,
283-
alt decl.purity {
289+
alt fd.decl.purity {
284290
unsafe_fn. { 'u' }
285291
pure_fn. { 'p' }
286292
impure_fn. { 'f' }
287293
} as u8);
294+
encode_inlineness(ebml_w,
295+
alt fd.decl.il {
296+
il_normal. { 'n' }
297+
il_inline. { 'i' }
298+
} as u8);
288299
encode_type_param_kinds(ebml_w, tps);
289300
encode_type(ecx, ebml_w, node_id_to_monotype(ecx.ccx.tcx, item.id));
290301
encode_symbol(ecx, ebml_w, item.id);
@@ -322,7 +333,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
322333
ebml::end_tag(ebml_w);
323334
encode_tag_variant_info(ecx, ebml_w, item.id, variants, index, tps);
324335
}
325-
item_res(_, tps, _, _, ctor_id) {
336+
item_res(_, _, tps, ctor_id) {
326337
let fn_ty = node_id_to_monotype(ecx.ccx.tcx, ctor_id);
327338

328339
ebml::start_tag(ebml_w, tag_items_data_item);
@@ -372,21 +383,22 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
372383
encode_name(ebml_w, item.ident);
373384
for m in methods {
374385
ebml::start_tag(ebml_w, tag_impl_method);
375-
ebml_w.writer.write(str::bytes(def_to_str(local_def(m.id))));
386+
ebml_w.writer.write(str::bytes(def_to_str(local_def(m.node.id))));
376387
ebml::end_tag(ebml_w);
377388
}
378389
ebml::end_tag(ebml_w);
379390

380391
for m in methods {
381-
index += [{val: m.id, pos: ebml_w.writer.tell()}];
392+
index += [{val: m.node.id, pos: ebml_w.writer.tell()}];
382393
ebml::start_tag(ebml_w, tag_items_data_item);
383-
encode_def_id(ebml_w, local_def(m.id));
394+
encode_def_id(ebml_w, local_def(m.node.id));
384395
encode_family(ebml_w, 'f' as u8);
385-
encode_type_param_kinds(ebml_w, tps + m.tps);
396+
encode_inlineness(ebml_w, 'n' as u8);
397+
encode_type_param_kinds(ebml_w, tps + m.node.tps);
386398
encode_type(ecx, ebml_w,
387-
node_id_to_monotype(ecx.ccx.tcx, m.id));
388-
encode_name(ebml_w, m.ident);
389-
encode_symbol(ecx, ebml_w, m.id);
399+
node_id_to_monotype(ecx.ccx.tcx, m.node.id));
400+
encode_name(ebml_w, m.node.ident);
401+
encode_symbol(ecx, ebml_w, m.node.id);
390402
ebml::end_tag(ebml_w);
391403
}
392404
}

trunk/src/comp/middle/ast_map.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ fn map_item(cx: ctx, i: @item) {
6868
item_obj(ob, _, ctor_id) {
6969
cx.map.insert(ctor_id, node_obj_ctor(i));
7070
for m in ob.methods {
71-
cx.map.insert(m.id, node_obj_method(m));
71+
cx.map.insert(m.node.id, node_obj_method(m));
7272
}
7373
}
7474
item_impl(_, _, ms) {
75-
for m in ms { cx.map.insert(m.id, node_method(m)); }
75+
for m in ms { cx.map.insert(m.node.id, node_method(m)); }
7676
}
77-
item_res(_, _, _, dtor_id, ctor_id) {
77+
item_res(_, dtor_id, _, ctor_id) {
7878
cx.map.insert(ctor_id, node_res_ctor(i));
7979
cx.map.insert(dtor_id, node_item(i));
8080
}

trunk/src/comp/middle/debuginfo.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -721,23 +721,23 @@ fn create_function(fcx: @fn_ctxt) -> @metadata<subprogram_md> {
721721
let (ident, ret_ty, id) = alt cx.ast_map.get(fcx.id) {
722722
ast_map::node_item(item) {
723723
alt item.node {
724-
ast::item_fn(decl, _, _) | ast::item_res(decl, _, _, _, _) {
725-
(item.ident, decl.output, item.id)
724+
ast::item_fn(f, _) | ast::item_res(f, _, _, _) {
725+
(item.ident, f.decl.output, item.id)
726726
}
727727
}
728728
}
729729
ast_map::node_obj_method(method) {
730-
(method.ident, method.decl.output, method.id)
730+
(method.node.ident, method.node.meth.decl.output, method.node.id)
731731
}
732732
ast_map::node_res_ctor(item) {
733-
alt item.node { ast::item_res(decl, _, _, _, ctor_id) {
734-
(item.ident, decl.output, ctor_id)
733+
alt item.node { ast::item_res(f, _, _, ctor_id) {
734+
(item.ident, f.decl.output, ctor_id)
735735
}}
736736
}
737737
ast_map::node_expr(expr) {
738738
alt expr.node {
739-
ast::expr_fn(decl, _, _) {
740-
(dbg_cx.names.next("fn"), decl.output, expr.id)
739+
ast::expr_fn(f, _) {
740+
(dbg_cx.names.next("fn"), f.decl.output, expr.id)
741741
}
742742
ast::expr_fn_block(decl, _) {
743743
(dbg_cx.names.next("fn"), decl.output, expr.id)

trunk/src/comp/middle/freevars.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ fn collect_freevars(def_map: resolve::def_map, blk: ast::blk)
3838
let walk_expr =
3939
lambda (expr: @ast::expr, &&depth: int, v: visit::vt<int>) {
4040
alt expr.node {
41-
ast::expr_fn(decl, _, captures) {
42-
if decl.proto != ast::proto_bare {
41+
ast::expr_fn(f, captures) {
42+
if f.proto != ast::proto_bare {
4343
visit::visit_expr(expr, depth + 1, v);
4444
}
4545
}

trunk/src/comp/middle/kind.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,8 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
178178
}
179179
}
180180
expr_ternary(_, a, b) { maybe_copy(cx, a); maybe_copy(cx, b); }
181-
expr_fn(_, _, cap_clause) {
182-
check_fn_cap_clause(cx, e.id, *cap_clause);
183-
}
181+
expr_fn(_, cap_clause) { check_fn_cap_clause(cx, e.id, *cap_clause); }
182+
184183
_ { }
185184
}
186185
visit::visit_expr(e, cx, v);

trunk/src/comp/middle/last_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ fn visit_expr(ex: @expr, cx: ctx, v: visit::vt<ctx>) {
136136
for arg in args {
137137
alt arg.node {
138138
//NDM--register captured as uses
139-
expr_fn(_, _, captured) { fns += [arg]; }
139+
expr_fn(_, captured) { fns += [arg]; }
140140
expr_fn_block(_, _) { fns += [arg]; }
141141
_ {
142142
alt arg_ts[i].mode {

0 commit comments

Comments
 (0)