Skip to content

Commit 7e814d5

Browse files
committed
---
yaml --- r: 3864 b: refs/heads/master c: 73e6a4f h: refs/heads/master v: v3
1 parent 69ddb27 commit 7e814d5

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
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: 41a3888da7fbcff128f03c16a8cefe4d74ab5a58
2+
refs/heads/master: 73e6a4f9e512b8e7fbec1c645311fa4382558aff

trunk/src/comp/front/test.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ fn modify_for_testing(@ast::crate crate) -> @ast::crate {
3535
mutable testfns = ~[]);
3636

3737
auto precursor = rec(fold_crate = bind fold_crate(cx, _, _),
38-
fold_item = bind fold_item(cx, _, _)
38+
fold_item = bind fold_item(cx, _, _),
39+
fold_mod = bind fold_mod(cx, _, _)
3940
with *fold::default_ast_fold());
4041

4142
auto fold = fold::make_fold(precursor);
@@ -45,6 +46,28 @@ fn modify_for_testing(@ast::crate crate) -> @ast::crate {
4546
ret res;
4647
}
4748

49+
fn fold_mod(&test_ctxt cx, &ast::_mod m,
50+
fold::ast_fold fld) -> ast::_mod {
51+
52+
// Remove any defined main function from the AST so it doesn't clash with
53+
// the one we're going to add. FIXME: This is sloppy. Instead we should
54+
// have some mechanism to indicate to the translation pass which function
55+
// we want to be main.
56+
fn nomain(&@ast::item item) -> option::t[@ast::item] {
57+
alt (item.node) {
58+
ast::item_fn(?f, _) {
59+
if (item.ident == "main") { option::none }
60+
else { option::some(item) }
61+
}
62+
_ { option::some(item) }
63+
}
64+
}
65+
66+
auto mod_nomain = rec(view_items=m.view_items,
67+
items=ivec::filter_map(nomain, m.items));
68+
ret fold::noop_fold_mod(mod_nomain, fld);
69+
}
70+
4871
fn fold_crate(&test_ctxt cx, &ast::crate_ c,
4972
fold::ast_fold fld) -> ast::crate_ {
5073
auto folded = fold::noop_fold_crate(c, fld);

trunk/src/comp/syntax/fold.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export dummy_out;
1212
export noop_fold_crate;
1313
export noop_fold_item;
1414
export noop_fold_expr;
15+
export noop_fold_mod;
1516

1617
type ast_fold = @mutable a_f;
1718

0 commit comments

Comments
 (0)