Update our code to new type parameter kind syntax

Closes #1067
This commit is contained in:
Marijn Haverbeke 2011-10-25 15:56:55 +02:00
parent 58c82a8da2
commit cfdf193c46
94 changed files with 289 additions and 288 deletions

View file

@ -88,7 +88,7 @@ fn parse_input_src(sess: session::session, cfg: ast::crate_cfg, infile: str)
ret {crate: crate, src: src};
}
fn time<@T>(do_it: bool, what: str, thunk: fn@() -> T) -> T {
fn time<T>(do_it: bool, what: str, thunk: fn@() -> T) -> T {
if !do_it { ret thunk(); }
let start = std::time::precise_time_s();
let rv = thunk();

View file

@ -182,7 +182,7 @@ fn require_unique_names(sess: session::session, metas: [@ast::meta_item]) {
}
}
fn span<@T>(item: T) -> ast::spanned<T> {
fn span<T>(item: T) -> ast::spanned<T> {
ret {node: item, span: ast_util::dummy_sp()};
}

View file

@ -180,7 +180,7 @@ fn mk_test_module(cx: test_ctxt) -> @ast::item {
ret @item;
}
fn nospan<@T>(t: T) -> ast::spanned<T> { ret {node: t, span: dummy_sp()}; }
fn nospan<T>(t: T) -> ast::spanned<T> { ret {node: t, span: dummy_sp()}; }
fn mk_tests(cx: test_ctxt) -> @ast::item {
let ret_ty = mk_test_desc_vec_ty(cx);

View file

@ -391,7 +391,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer) ->
// Path and definition ID indexing
fn create_index<@T>(index: [entry<T>], hash_fn: fn(T) -> uint) ->
fn create_index<T>(index: [entry<T>], hash_fn: fn(T) -> uint) ->
[@[entry<T>]] {
let buckets: [@mutable [entry<T>]] = [];
uint::range(0u, 256u) {|_i| buckets += [@mutable []]; };

View file

@ -150,7 +150,7 @@ fn parse_ty_constr_arg(st: @pstate, sd: str_def) ->
}
}
fn parse_constr<@T>(st: @pstate, sd: str_def, pser: arg_parser<T>) ->
fn parse_constr<T>(st: @pstate, sd: str_def, pser: arg_parser<T>) ->
@ty::constr_general<T> {
let sp = ast_util::dummy_sp(); // FIXME: use a real span
let args: [@sp_constr_arg<T>] = [];

View file

@ -75,7 +75,7 @@ fn map_expr(cx: ctx, ex: @expr) {
cx.map.insert(ex.id, node_expr(ex));
}
fn new_smallintmap_int_adapter<@V>() -> std::map::hashmap<int, V> {
fn new_smallintmap_int_adapter<V>() -> std::map::hashmap<int, V> {
let key_idx = fn (&&key: int) -> uint { key as uint };
let idx_key = fn (idx: uint) -> int { idx as int };
ret new_smallintmap_adapter(key_idx, idx_key);
@ -86,13 +86,13 @@ fn new_smallintmap_int_adapter<@V>() -> std::map::hashmap<int, V> {
// the entire codebase adapting all the callsites to the different
// interface.
// FIXME: hashmap and smallintmap should support the same interface.
fn new_smallintmap_adapter<@K, @V>(key_idx: fn(K) -> uint,
fn new_smallintmap_adapter<K, V>(key_idx: fn(K) -> uint,
idx_key: fn(uint) -> K)
-> std::map::hashmap<K, V> {
obj adapter<@K, @V>(map: smallintmap::smallintmap<V>,
key_idx: fn(K) -> uint,
idx_key: fn(uint) -> K) {
obj adapter<K, V>(map: smallintmap::smallintmap<V>,
key_idx: fn(K) -> uint,
idx_key: fn(uint) -> K) {
fn size() -> uint { fail }

View file

@ -25,10 +25,10 @@
*
*
* Since this forms a lattice, we denote the capabilites in terms of a
* worst-case requirement. That is, if your function needs to move-and-send
* (or copy) your T, you write fn<~T>(...). If you need to move but not send,
* you write fn<@T>(...). And if you need neither -- can work with any sort of
* pinned data at all -- then you write fn<T>(...).
* worst-case requirement. That is, if your function needs to move-and-send (or
* copy) your T, you write fn<unique T>(...). If you need to move but not send,
* you write fn<T>(...). And if you need neither -- can work with any sort of
* pinned data at all -- then you write fn<pinned T>(...).
*
* Most types are unique or shared. Other possible name combinations for these
* two: (tree, graph; pruned, pooled; message, local; owned, common) are

View file

@ -2,7 +2,7 @@ import std::{str, option};
import codemap::span;
import ast::*;
fn respan<@T>(sp: span, t: T) -> spanned<T> { ret {node: t, span: sp}; }
fn respan<T>(sp: span, t: T) -> spanned<T> { ret {node: t, span: sp}; }
/* assuming that we're not in macro expansion */
fn mk_sp(lo: uint, hi: uint) -> span {
@ -186,7 +186,7 @@ fn eq_def_id(&&a: def_id, &&b: def_id) -> bool {
a == b
}
fn new_def_id_hash<@T>() -> std::map::hashmap<def_id, T> {
fn new_def_id_hash<T>() -> std::map::hashmap<def_id, T> {
std::map::mk_hashmap(hash_def_id, eq_def_id)
}

View file

@ -104,7 +104,7 @@ fn elts_to_ell(cx: ext_ctxt, elts: [@expr]) ->
}
}
fn option_flatten_map<T, @U>(f: fn@(T) -> option::t<U>, v: [T]) ->
fn option_flatten_map<T, U>(f: fn@(T) -> option::t<U>, v: [T]) ->
option::t<[U]> {
let res = [];
for elem: T in v {

View file

@ -210,7 +210,7 @@ fn expect_gt(p: parser) {
}
}
fn spanned<@T>(lo: uint, hi: uint, node: T) -> spanned<T> {
fn spanned<T>(lo: uint, hi: uint, node: T) -> spanned<T> {
ret {node: node, span: ast_util::mk_sp(lo, hi)};
}
@ -595,7 +595,7 @@ fn parse_fn_block_arg(p: parser) -> ast::arg {
ret {mode: m, ty: t, ident: i, id: p.get_id()};
}
fn parse_seq_to_before_gt<@T>(sep: option::t<token::token>,
fn parse_seq_to_before_gt<T>(sep: option::t<token::token>,
f: fn@(parser) -> T,
p: parser) -> [T] {
let first = true;
@ -612,7 +612,7 @@ fn parse_seq_to_before_gt<@T>(sep: option::t<token::token>,
ret v;
}
fn parse_seq_to_gt<@T>(sep: option::t<token::token>, f: fn@(parser) -> T,
fn parse_seq_to_gt<T>(sep: option::t<token::token>, f: fn@(parser) -> T,
p: parser) -> [T] {
let v = parse_seq_to_before_gt(sep, f, p);
expect_gt(p);
@ -620,7 +620,7 @@ fn parse_seq_to_gt<@T>(sep: option::t<token::token>, f: fn@(parser) -> T,
ret v;
}
fn parse_seq_lt_gt<@T>(sep: option::t<token::token>, f: fn@(parser) -> T,
fn parse_seq_lt_gt<T>(sep: option::t<token::token>, f: fn@(parser) -> T,
p: parser) -> spanned<[T]> {
let lo = p.get_lo_pos();
expect(p, token::LT);
@ -630,14 +630,14 @@ fn parse_seq_lt_gt<@T>(sep: option::t<token::token>, f: fn@(parser) -> T,
ret spanned(lo, hi, result);
}
fn parse_seq_to_end<@T>(ket: token::token, sep: option::t<token::token>,
fn parse_seq_to_end<T>(ket: token::token, sep: option::t<token::token>,
f: fn(parser) -> T, p: parser) -> [T] {
let val = parse_seq_to_before_end(ket, sep, f, p);
p.bump();
ret val;
}
fn parse_seq_to_before_end<@T>(ket: token::token,
fn parse_seq_to_before_end<T>(ket: token::token,
sep: option::t<token::token>,
f: fn@(parser) -> T, p: parser) -> [T] {
let first: bool = true;
@ -653,7 +653,7 @@ fn parse_seq_to_before_end<@T>(ket: token::token,
}
fn parse_seq<@T>(bra: token::token, ket: token::token,
fn parse_seq<T>(bra: token::token, ket: token::token,
sep: option::t<token::token>, f: fn@(parser) -> T, p: parser)
-> spanned<[T]> {
let lo = p.get_lo_pos();

View file

@ -11,12 +11,12 @@ type interner<T> =
hasher: hashfn<T>,
eqer: eqfn<T>};
fn mk<@T>(hasher: hashfn<T>, eqer: eqfn<T>) -> interner<T> {
fn mk<T>(hasher: hashfn<T>, eqer: eqfn<T>) -> interner<T> {
let m = map::mk_hashmap::<T, uint>(hasher, eqer);
ret {map: m, mutable vect: [], hasher: hasher, eqer: eqer};
}
fn intern<@T>(itr: interner<T>, val: T) -> uint {
fn intern<T>(itr: interner<T>, val: T) -> uint {
alt itr.map.find(val) {
some(idx) { ret idx; }
none. {
@ -31,7 +31,7 @@ fn intern<@T>(itr: interner<T>, val: T) -> uint {
// |get| isn't "pure" in the traditional sense, because it can go from
// failing to returning a value as items are interned. But for typestate,
// where we first check a pred and then rely on it, ceasing to fail is ok.
pure fn get<@T>(itr: interner<T>, idx: uint) -> T {
pure fn get<T>(itr: interner<T>, idx: uint) -> T {
unchecked {
itr.vect[idx]
}

View file

@ -25,7 +25,7 @@ fn hash_def(d: ast::def_id) -> uint {
ret h;
}
fn new_def_hash<@V>() -> std::map::hashmap<ast::def_id, V> {
fn new_def_hash<V>() -> std::map::hashmap<ast::def_id, V> {
let hasher: std::map::hashfn<ast::def_id> = hash_def;
let eqer: std::map::eqfn<ast::def_id> = def_eq;
ret std::map::mk_hashmap::<ast::def_id, V>(hasher, eqer);
@ -166,7 +166,7 @@ fn lit_in_range(l: @ast::lit, m1: @ast::lit, m2: @ast::lit) -> bool {
}
}
fn ranges_overlap<@T>(a1: T, a2: T, b1: T, b2: T) -> bool {
fn ranges_overlap<T>(a1: T, a2: T, b1: T, b2: T) -> bool {
let min1 = min(a1, a2);
let max1 = max(a1, a2);
let min2 = min(b1, b2);

View file

@ -16,7 +16,7 @@ export pick_file;
export search;
export relative_target_lib_path;
type pick<@T> = block(path: fs::path) -> option::t<T>;
type pick<T> = block(path: fs::path) -> option::t<T>;
fn pick_file(file: fs::path, path: fs::path) -> option::t<fs::path> {
if fs::basename(path) == file { option::some(path) }
@ -57,7 +57,7 @@ fn mk_filesearch(maybe_sysroot: option::t<fs::path>,
}
// FIXME #1001: This can't be an obj method
fn search<@T>(filesearch: filesearch, pick: pick<T>) -> option::t<T> {
fn search<T>(filesearch: filesearch, pick: pick<T>) -> option::t<T> {
for lib_search_path in filesearch.lib_search_paths() {
log #fmt["searching %s", lib_search_path];
for path in fs::list_dir(lib_search_path) {