diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2011-10-06 12:26:12 +0200 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2011-10-07 09:09:50 +0200 |
| commit | f9fbd86f52cf597b85359ade1ca60b8d6ebf7286 (patch) | |
| tree | d6f0cdd039642052f3ccb4ba8f3b9821bb7cbaaf /src/comp/front | |
| parent | 4709038d641ad009b44ed2bf5980fa3a252d6927 (diff) | |
| download | rust-f9fbd86f52cf597b85359ade1ca60b8d6ebf7286.tar.gz rust-f9fbd86f52cf597b85359ade1ca60b8d6ebf7286.zip | |
Parse and typecheck by-value and by-ref arg specs
Add sprinkle && throughout the compiler to make it typecheck again. Issue #1008
Diffstat (limited to 'src/comp/front')
| -rw-r--r-- | src/comp/front/attr.rs | 6 | ||||
| -rw-r--r-- | src/comp/front/config.rs | 43 | ||||
| -rw-r--r-- | src/comp/front/test.rs | 2 |
3 files changed, 25 insertions, 26 deletions
diff --git a/src/comp/front/attr.rs b/src/comp/front/attr.rs index a84c74b94f4..62c6a0282ce 100644 --- a/src/comp/front/attr.rs +++ b/src/comp/front/attr.rs @@ -57,7 +57,7 @@ fn get_attr_name(attr: ast::attribute) -> ast::ident { fn find_meta_items_by_name(metas: [@ast::meta_item], name: ast::ident) -> [@ast::meta_item] { let filter = - bind fn (m: @ast::meta_item, name: ast::ident) -> + bind fn (&&m: @ast::meta_item, name: ast::ident) -> option::t<@ast::meta_item> { if get_meta_item_name(m) == name { option::some(m) @@ -134,7 +134,7 @@ fn contains_name(metas: [@ast::meta_item], name: ast::ident) -> bool { // FIXME: This needs to sort by meta_item variant in addition to the item name fn sort_meta_items(items: [@ast::meta_item]) -> [@ast::meta_item] { - fn lteq(ma: @ast::meta_item, mb: @ast::meta_item) -> bool { + fn lteq(&&ma: @ast::meta_item, &&mb: @ast::meta_item) -> bool { fn key(m: @ast::meta_item) -> ast::ident { alt m.node { ast::meta_word(name) { name } @@ -160,7 +160,7 @@ fn remove_meta_items_by_name(items: [@ast::meta_item], name: str) -> [@ast::meta_item] { let filter = - bind fn (item: @ast::meta_item, name: str) -> + bind fn (&&item: @ast::meta_item, name: str) -> option::t<@ast::meta_item> { if get_meta_item_name(item) != name { option::some(item) diff --git a/src/comp/front/config.rs b/src/comp/front/config.rs index cdd95bd6313..cc2b35d8d9e 100644 --- a/src/comp/front/config.rs +++ b/src/comp/front/config.rs @@ -20,7 +20,7 @@ fn strip_unconfigured_items(crate: @ast::crate) -> @ast::crate { ret res; } -fn filter_item(cfg: ast::crate_cfg, item: @ast::item) -> +fn filter_item(cfg: ast::crate_cfg, &&item: @ast::item) -> option::t<@ast::item> { if item_in_cfg(cfg, item) { option::some(item) } else { option::none } } @@ -29,11 +29,11 @@ fn fold_mod(cfg: ast::crate_cfg, m: ast::_mod, fld: fold::ast_fold) -> ast::_mod { let filter = bind filter_item(cfg, _); let filtered_items = vec::filter_map(filter, m.items); - ret {view_items: vec::map(fld.fold_view_item, m.view_items), - items: vec::map(fld.fold_item, filtered_items)}; + ret {view_items: vec::map_imm(fld.fold_view_item, m.view_items), + items: vec::map_imm(fld.fold_item, filtered_items)}; } -fn filter_native_item(cfg: ast::crate_cfg, item: @ast::native_item) -> +fn filter_native_item(cfg: ast::crate_cfg, &&item: @ast::native_item) -> option::t<@ast::native_item> { if native_item_in_cfg(cfg, item) { option::some(item) @@ -46,11 +46,11 @@ fn fold_native_mod(cfg: ast::crate_cfg, nm: ast::native_mod, let filtered_items = vec::filter_map(filter, nm.items); ret {native_name: nm.native_name, abi: nm.abi, - view_items: vec::map(fld.fold_view_item, nm.view_items), + view_items: vec::map_imm(fld.fold_view_item, nm.view_items), items: filtered_items}; } -fn filter_stmt(cfg: ast::crate_cfg, stmt: @ast::stmt) -> +fn filter_stmt(cfg: ast::crate_cfg, &&stmt: @ast::stmt) -> option::t<@ast::stmt> { alt stmt.node { ast::stmt_decl(decl, _) { @@ -71,8 +71,8 @@ fn fold_block(cfg: ast::crate_cfg, b: ast::blk_, fld: fold::ast_fold) -> ast::blk_ { let filter = bind filter_stmt(cfg, _); let filtered_stmts = vec::filter_map(filter, b.stmts); - ret {stmts: vec::map(fld.fold_stmt, filtered_stmts), - expr: option::map(fld.fold_expr, b.expr), + ret {stmts: vec::map_imm(fld.fold_stmt, filtered_stmts), + expr: option::map_imm(fld.fold_expr, b.expr), id: b.id, rules: b.rules}; } @@ -97,21 +97,20 @@ fn in_cfg(cfg: ast::crate_cfg, attrs: [ast::attribute]) -> bool { // Pull the inner meta_items from the #[cfg(meta_item, ...)] attributes, // so we can match against them. This is the list of configurations for // which the item is valid - let item_cfg_metas = - { - fn extract_metas(inner_items: [@ast::meta_item], - cfg_item: @ast::meta_item) -> [@ast::meta_item] { - alt cfg_item.node { - ast::meta_list(name, items) { - assert (name == "cfg"); - inner_items + items - } - _ { inner_items } - } + let item_cfg_metas = { + fn extract_metas(inner_items: [@ast::meta_item], + &&cfg_item: @ast::meta_item) -> [@ast::meta_item] { + alt cfg_item.node { + ast::meta_list(name, items) { + assert (name == "cfg"); + inner_items + items + } + _ { inner_items } } - let cfg_metas = attr::attr_metas(item_cfg_attrs); - vec::foldl(extract_metas, [], cfg_metas) - }; + } + let cfg_metas = attr::attr_metas(item_cfg_attrs); + vec::foldl(extract_metas, [], cfg_metas) + }; for cfg_mi: @ast::meta_item in item_cfg_metas { if attr::contains(cfg, cfg_mi) { ret true; } diff --git a/src/comp/front/test.rs b/src/comp/front/test.rs index 9aed642a2d5..030a4faf5f9 100644 --- a/src/comp/front/test.rs +++ b/src/comp/front/test.rs @@ -56,7 +56,7 @@ fn fold_mod(_cx: test_ctxt, m: ast::_mod, fld: fold::ast_fold) -> ast::_mod { // the one we're going to add. FIXME: This is sloppy. Instead we should // have some mechanism to indicate to the translation pass which function // we want to be main. - fn nomain(item: @ast::item) -> option::t<@ast::item> { + fn nomain(&&item: @ast::item) -> option::t<@ast::item> { alt item.node { ast::item_fn(f, _) { if item.ident == "main" { |
