Port the compiler to foo<T> decl syntax.
This commit is contained in:
parent
4c9049c50c
commit
4abc471390
@ -110,7 +110,7 @@ fn parse_input_src(sess: session::session, cfg: &ast::crate_cfg,
|
||||
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();
|
||||
|
@ -189,7 +189,7 @@ fn require_unique_names(sess: &session::session,
|
||||
}
|
||||
}
|
||||
|
||||
fn span[T](item: &T) -> ast::spanned<T> {
|
||||
fn span<T>(item: &T) -> ast::spanned<T> {
|
||||
ret {node: item, span: ast::mk_sp(0u, 0u)};
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ fn mk_test_module(cx: &test_ctxt) -> @ast::item {
|
||||
ret @item;
|
||||
}
|
||||
|
||||
fn nospan[T](t: &T) -> ast::spanned<T> {
|
||||
fn nospan<T>(t: &T) -> ast::spanned<T> {
|
||||
ret {node: t, span: ast::dummy_sp()};
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ fn encode_def_id(ebml_w: &ebml::writer, id: &def_id) {
|
||||
ebml::end_tag(ebml_w);
|
||||
}
|
||||
|
||||
type entry[T] = {val: T, pos: uint};
|
||||
type entry<T> = {val: T, pos: uint};
|
||||
|
||||
fn encode_tag_variant_paths(ebml_w: &ebml::writer, variants: &[variant],
|
||||
path: &[str], index: &mutable [entry<str>]) {
|
||||
@ -392,7 +392,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>]] = ~[];
|
||||
for each i: uint in uint::range(0u, 256u) { buckets += ~[@mutable ~[]]; }
|
||||
@ -408,7 +408,7 @@ fn create_index[T](index: &[entry<T>], hash_fn: fn(&T) -> uint ) ->
|
||||
ret buckets_frozen;
|
||||
}
|
||||
|
||||
fn encode_index[T](ebml_w: &ebml::writer, buckets: &[@[entry<T>]],
|
||||
fn encode_index<T>(ebml_w: &ebml::writer, buckets: &[@[entry<T>]],
|
||||
write_fn: fn(&io::writer, &T) ) {
|
||||
let writer = io::new_writer_(ebml_w.writer);
|
||||
ebml::start_tag(ebml_w, tag_index);
|
||||
|
@ -115,7 +115,7 @@ fn parse_path(st: @pstate, sd: str_def) -> ast::path {
|
||||
fail "parse_path: ill-formed path";
|
||||
}
|
||||
|
||||
type arg_parser[T] = fn(@pstate, str_def) -> ast::constr_arg_general_<T> ;
|
||||
type arg_parser<T> = fn(@pstate, str_def) -> ast::constr_arg_general_<T> ;
|
||||
|
||||
fn parse_constr_arg(st: @pstate, sd: str_def) -> ast::fn_constr_arg {
|
||||
alt peek(st) as char {
|
||||
@ -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::dummy_sp(); // FIXME: use a real span
|
||||
let args: [@sp_constr_arg<T>] = ~[];
|
||||
|
@ -48,7 +48,7 @@ fn map_expr(map: &map, ex: &@expr, e: &(), v: &vt<()>) {
|
||||
visit::visit_expr(ex, e, v);
|
||||
}
|
||||
|
||||
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);
|
||||
@ -59,13 +59,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>,
|
||||
obj adapter<@K,
|
||||
@V>(map: smallintmap::smallintmap<V>,
|
||||
key_idx: fn(&K) -> uint ,
|
||||
idx_key: fn(&uint) -> K ) {
|
||||
|
||||
|
@ -1392,7 +1392,7 @@ fn add_name(ch: &checker, sp: &span, name: &ident) {
|
||||
|
||||
fn ident_id(i: &ident) -> ident { ret i; }
|
||||
|
||||
fn ensure_unique[T](e: &env, sp: &span, elts: &[T], id: fn(&T) -> ident ,
|
||||
fn ensure_unique<T>(e: &env, sp: &span, elts: &[T], id: fn(&T) -> ident ,
|
||||
kind: &str) {
|
||||
let ch = checker(e, kind);
|
||||
for elt: T in elts { add_name(ch, sp, id(elt)); }
|
||||
|
@ -1012,13 +1012,13 @@ fn non_init_constraint_mentions(fcx: &fn_ctxt, c: &norm_constraint,
|
||||
};
|
||||
}
|
||||
|
||||
fn args_mention[T](args: &[@constr_arg_use], q: fn(&[T], node_id) -> bool ,
|
||||
fn args_mention<T>(args: &[@constr_arg_use], q: fn(&[T], node_id) -> bool ,
|
||||
s: &[T]) -> bool {
|
||||
/*
|
||||
FIXME
|
||||
The following version causes an assertion in trans to fail
|
||||
(something about type_is_tup_like)
|
||||
fn mentions[T](&[T] s, &fn(&[T], def_id) -> bool q,
|
||||
fn mentions<T>(&[T] s, &fn(&[T], def_id) -> bool q,
|
||||
&@constr_arg_use a) -> bool {
|
||||
alt (a.node) {
|
||||
case (carg_ident(?p1)) {
|
||||
@ -1051,7 +1051,7 @@ fn op_to_oper_ty(io: init_op) -> oper_type {
|
||||
}
|
||||
|
||||
// default function visitor
|
||||
fn do_nothing[T](f: &_fn, tp: &[ty_param], sp: &span, i: &fn_ident,
|
||||
fn do_nothing<T>(f: &_fn, tp: &[ty_param], sp: &span, i: &fn_ident,
|
||||
iid: node_id, cx: &T, v: &visit::vt<T>) {
|
||||
}
|
||||
|
||||
|
@ -284,7 +284,7 @@ tag sty {
|
||||
|
||||
// In the middle end, constraints have a def_id attached, referring
|
||||
// to the definition of the operator in the constraint.
|
||||
type constr_general[ARG] = spanned<constr_general_<ARG, def_id>>;
|
||||
type constr_general<ARG> = spanned<constr_general_<ARG, def_id>>;
|
||||
type type_constr = constr_general<path>;
|
||||
type constr = constr_general<uint>;
|
||||
|
||||
@ -1554,7 +1554,7 @@ fn hash_ty(typ: &t) -> uint { ret typ; }
|
||||
// users should use `eq_ty()` instead.
|
||||
fn eq_int(x: &uint, y: &uint) -> bool { ret x == y; }
|
||||
|
||||
fn arg_eq[T](eq: &fn(&T, &T) -> bool , a: @sp_constr_arg<T>,
|
||||
fn arg_eq<T>(eq: &fn(&T, &T) -> bool , a: @sp_constr_arg<T>,
|
||||
b: @sp_constr_arg<T>) -> bool {
|
||||
alt a.node {
|
||||
ast::carg_base. {
|
||||
@ -1569,7 +1569,7 @@ fn arg_eq[T](eq: &fn(&T, &T) -> bool , a: @sp_constr_arg<T>,
|
||||
}
|
||||
}
|
||||
|
||||
fn args_eq[T](eq: fn(&T, &T) -> bool , a: &[@sp_constr_arg<T>],
|
||||
fn args_eq<T>(eq: fn(&T, &T) -> bool , a: &[@sp_constr_arg<T>],
|
||||
b: &[@sp_constr_arg<T>]) -> bool {
|
||||
let i: uint = 0u;
|
||||
for arg: @sp_constr_arg<T> in a {
|
||||
@ -3090,7 +3090,7 @@ fn is_binopable(cx: &ctxt, ty: t, op: ast::binop) -> bool {
|
||||
ret tbl.(tycat(cx, ty)).(opcat(op));
|
||||
}
|
||||
|
||||
fn ast_constr_to_constr[T](tcx: ty::ctxt, c: &@ast::constr_general<T>) ->
|
||||
fn ast_constr_to_constr<T>(tcx: ty::ctxt, c: &@ast::constr_general<T>) ->
|
||||
@ty::constr_general<T> {
|
||||
alt tcx.def_map.find(c.node.id) {
|
||||
some(ast::def_fn(pred_id, ast::pure_fn.)) {
|
||||
|
@ -1281,10 +1281,10 @@ fn gather_locals(ccx: &@crate_ctxt, f: &ast::_fn, id: &ast::node_id,
|
||||
};
|
||||
|
||||
// Don't descend into fns and items
|
||||
fn visit_fn[E](f: &ast::_fn, tp: &[ast::ty_param], sp: &span,
|
||||
fn visit_fn<E>(f: &ast::_fn, tp: &[ast::ty_param], sp: &span,
|
||||
i: &ast::fn_ident, id: ast::node_id, e: &E,
|
||||
v: &visit::vt<E>) { }
|
||||
fn visit_item[E](i: &@ast::item, e: &E, v: &visit::vt<E>) { }
|
||||
fn visit_item<E>(i: &@ast::item, e: &E, v: &visit::vt<E>) { }
|
||||
|
||||
let visit =
|
||||
@{visit_local: visit_local,
|
||||
|
@ -5,8 +5,8 @@ import std::str;
|
||||
import codemap::span;
|
||||
import codemap::filename;
|
||||
|
||||
type spanned[T] = {node: T, span: span};
|
||||
fn respan[T](sp: &span, t: &T) -> spanned<T> { ret {node: t, span: sp}; }
|
||||
type spanned<T> = {node: T, span: span};
|
||||
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 {
|
||||
@ -468,10 +468,10 @@ so that the typestate pass doesn't have to map a function name onto its decl.
|
||||
So, the constr_arg type is parameterized: it's instantiated with uint for
|
||||
declarations, and ident for uses.
|
||||
*/
|
||||
tag constr_arg_general_[T] { carg_base; carg_ident(T); carg_lit(@lit); }
|
||||
tag constr_arg_general_<T> { carg_base; carg_ident(T); carg_lit(@lit); }
|
||||
|
||||
type fn_constr_arg = constr_arg_general_<uint>;
|
||||
type sp_constr_arg[T] = spanned<constr_arg_general_<T>>;
|
||||
type sp_constr_arg<T> = spanned<constr_arg_general_<T>>;
|
||||
type ty_constr_arg = sp_constr_arg<path>;
|
||||
type constr_arg = spanned<fn_constr_arg>;
|
||||
|
||||
@ -480,12 +480,12 @@ type constr_arg = spanned<fn_constr_arg>;
|
||||
// The implicit root of such path, in the constraint-list for a
|
||||
// constrained type, is * (referring to the base record)
|
||||
|
||||
type constr_general_[ARG, ID] =
|
||||
type constr_general_<ARG, ID> =
|
||||
{path: path, args: [@spanned<constr_arg_general_<ARG>>], id: ID};
|
||||
|
||||
// In the front end, constraints have a node ID attached.
|
||||
// Typeck turns this to a def_id, using the output of resolve.
|
||||
type constr_general[ARG] = spanned<constr_general_<ARG, node_id>>;
|
||||
type constr_general<ARG> = spanned<constr_general_<ARG, node_id>>;
|
||||
type constr_ = constr_general_<uint, node_id>;
|
||||
type constr = spanned<constr_general_<uint, node_id>>;
|
||||
type ty_constr_ = ast::constr_general_<ast::path, ast::node_id>;
|
||||
|
@ -43,7 +43,7 @@ fn path_to_ident(pth: &path) -> option::t<ident> {
|
||||
type clause = {params: binders, body: @expr};
|
||||
|
||||
/* logically, an arb_depth should contain only one kind of matchable */
|
||||
tag arb_depth[T] { leaf(T); seq(@[arb_depth<T>], span); }
|
||||
tag arb_depth<T> { leaf(T); seq(@[arb_depth<T>], span); }
|
||||
|
||||
|
||||
tag matchable {
|
||||
@ -121,7 +121,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 {
|
||||
|
@ -75,7 +75,7 @@ type a_f =
|
||||
new_span: fn(&span) -> span};
|
||||
|
||||
|
||||
//fn nf_dummy[T](&T node) -> T { fail; }
|
||||
//fn nf_dummy<T>(&T node) -> T { fail; }
|
||||
fn nf_crate_dummy(c: &crate) -> crate { fail; }
|
||||
fn nf_crate_directive_dummy(c: &@crate_directive) -> @crate_directive {
|
||||
fail;
|
||||
|
@ -224,7 +224,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::mk_sp(lo, hi)};
|
||||
}
|
||||
|
||||
@ -429,7 +429,7 @@ fn parse_constr_in_type(p: &parser) -> @ast::ty_constr {
|
||||
}
|
||||
|
||||
|
||||
fn parse_constrs[T](pser: fn(&parser) -> @ast::constr_general<T>, p: &parser)
|
||||
fn parse_constrs<T>(pser: fn(&parser) -> @ast::constr_general<T>, p: &parser)
|
||||
-> [@ast::constr_general<T>] {
|
||||
let constrs: [@ast::constr_general<T>] = ~[];
|
||||
while true {
|
||||
@ -643,7 +643,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;
|
||||
let v = ~[];
|
||||
@ -660,7 +660,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);
|
||||
@ -668,7 +668,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);
|
||||
@ -678,14 +678,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, sep: option::t<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;
|
||||
let v: [T] = ~[];
|
||||
@ -700,7 +700,7 @@ fn parse_seq_to_before_end[T](ket: token::token, sep: option::t<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();
|
||||
|
@ -217,7 +217,7 @@ fn synth_comment(s: &ps, text: str) {
|
||||
word(s.s, "*/");
|
||||
}
|
||||
|
||||
fn commasep[IN](s: &ps, b: breaks, elts: &[IN], op: fn(&ps, &IN) ) {
|
||||
fn commasep<IN>(s: &ps, b: breaks, elts: &[IN], op: fn(&ps, &IN) ) {
|
||||
box(s, 0u, b);
|
||||
let first = true;
|
||||
for elt: IN in elts {
|
||||
@ -228,7 +228,7 @@ fn commasep[IN](s: &ps, b: breaks, elts: &[IN], op: fn(&ps, &IN) ) {
|
||||
}
|
||||
|
||||
|
||||
fn commasep_cmnt[IN](s: &ps, b: breaks, elts: &[IN], op: fn(&ps, &IN) ,
|
||||
fn commasep_cmnt<IN>(s: &ps, b: breaks, elts: &[IN], op: fn(&ps, &IN) ,
|
||||
get_span: fn(&IN) -> codemap::span ) {
|
||||
box(s, 0u, b);
|
||||
let len = vec::len[IN](elts);
|
||||
@ -1515,7 +1515,7 @@ fn escape_str(st: str, to_escape: char) -> str {
|
||||
ret out;
|
||||
}
|
||||
|
||||
fn to_str[T](t: &T, f: fn(&ps, &T) ) -> str {
|
||||
fn to_str<T>(t: &T, f: fn(&ps, &T) ) -> str {
|
||||
let writer = io::string_writer();
|
||||
let s = rust_printer(writer.get_writer());
|
||||
f(s, t);
|
||||
@ -1536,7 +1536,7 @@ fn next_comment(s: &ps) -> option::t<lexer::cmnt> {
|
||||
|
||||
// Removing the aliases from the type of f in the next two functions
|
||||
// triggers memory corruption, but I haven't isolated the bug yet. FIXME
|
||||
fn constr_args_to_str[T](f: &fn(&T) -> str ,
|
||||
fn constr_args_to_str<T>(f: &fn(&T) -> str ,
|
||||
args: &[@ast::sp_constr_arg<T>]) -> str {
|
||||
let comma = false;
|
||||
let s = "(";
|
||||
@ -1548,7 +1548,7 @@ fn constr_args_to_str[T](f: &fn(&T) -> str ,
|
||||
ret s;
|
||||
}
|
||||
|
||||
fn constr_arg_to_str[T](f: &fn(&T) -> str, c: &ast::constr_arg_general_<T>)
|
||||
fn constr_arg_to_str<T>(f: &fn(&T) -> str, c: &ast::constr_arg_general_<T>)
|
||||
-> str {
|
||||
alt c {
|
||||
ast::carg_base. { ret "*"; }
|
||||
|
@ -370,7 +370,7 @@ fn dummy() {
|
||||
extract_fn(ctx, elts.(idx))]];
|
||||
}
|
||||
|
||||
fn seq_cv[T](conversion: fn (&ctx, &@ast_node) -> T)
|
||||
fn seq_cv<T>(conversion: fn (&ctx, &@ast_node) -> T)
|
||||
-> fn (&ctx, @ast_node) -> T[] {
|
||||
ret lambda(ctx: &ctx, ut: @ast_node) -> T[] {
|
||||
ret alt *ut {
|
||||
@ -383,7 +383,7 @@ fn seq_cv[T](conversion: fn (&ctx, &@ast_node) -> T)
|
||||
}
|
||||
}
|
||||
|
||||
fn opt_cv[T](conversion: fn (&ctx, &@ast_node) -> T)
|
||||
fn opt_cv<T>(conversion: fn (&ctx, &@ast_node) -> T)
|
||||
-> fn (&ctx, @ast_node) -> option::t<T> {
|
||||
ret lambda(ctx: &ctx, ut: @ast_node) -> option::t<T> {
|
||||
ret alt *ut {
|
||||
|
@ -10,18 +10,18 @@ import std::option;
|
||||
import std::option::none;
|
||||
import std::option::some;
|
||||
|
||||
type interner[T] =
|
||||
type interner<T> =
|
||||
{map: hashmap<T, uint>,
|
||||
mutable vect: [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. {
|
||||
@ -33,7 +33,7 @@ fn intern[@T](itr: &interner<T>, val: &T) -> uint {
|
||||
}
|
||||
}
|
||||
|
||||
fn get[T](itr: &interner<T>, idx: uint) -> T { ret itr.vect.(idx); }
|
||||
fn get<T>(itr: &interner<T>, idx: uint) -> T { ret itr.vect.(idx); }
|
||||
|
||||
fn len[T](itr : &interner<T>) -> uint { ret vec::len(itr.vect); }
|
||||
fn len<T>(itr : &interner<T>) -> uint { ret vec::len(itr.vect); }
|
||||
|
||||
|
@ -14,9 +14,9 @@ import codemap::span;
|
||||
|
||||
// Our typesystem doesn't do circular types, so the visitor record can not
|
||||
// hold functions that take visitors. A vt tag is used to break the cycle.
|
||||
tag vt[E] { mk_vt(visitor<E>); }
|
||||
tag vt<E> { mk_vt(visitor<E>); }
|
||||
|
||||
type visitor[E] =
|
||||
type visitor<E> =
|
||||
// takes the components so that one function can be
|
||||
// generic over constr and ty_constr
|
||||
@{visit_mod: fn(&_mod, &span, &E, &vt<E>),
|
||||
@ -35,7 +35,7 @@ type visitor[E] =
|
||||
visit_fn:
|
||||
fn(&_fn, &[ty_param], &span, &fn_ident, node_id, &E, &vt<E>) };
|
||||
|
||||
fn default_visitor[E]() -> visitor<E> {
|
||||
fn default_visitor<E>() -> visitor<E> {
|
||||
ret @{visit_mod: bind visit_mod[E](_, _, _, _),
|
||||
visit_view_item: bind visit_view_item[E](_, _, _),
|
||||
visit_native_item: bind visit_native_item[E](_, _, _),
|
||||
@ -52,11 +52,11 @@ fn default_visitor[E]() -> visitor<E> {
|
||||
visit_fn: bind visit_fn[E](_, _, _, _, _, _, _)};
|
||||
}
|
||||
|
||||
fn visit_crate[E](c: &crate, e: &E, v: &vt<E>) {
|
||||
fn visit_crate<E>(c: &crate, e: &E, v: &vt<E>) {
|
||||
v.visit_mod(c.node.module, c.span, e, v);
|
||||
}
|
||||
|
||||
fn visit_crate_directive[E](cd: &@crate_directive, e: &E, v: &vt<E>) {
|
||||
fn visit_crate_directive<E>(cd: &@crate_directive, e: &E, v: &vt<E>) {
|
||||
alt cd.node {
|
||||
cdir_src_mod(_, _, _) { }
|
||||
cdir_dir_mod(_, _, cdirs, _) {
|
||||
@ -70,20 +70,20 @@ fn visit_crate_directive[E](cd: &@crate_directive, e: &E, v: &vt<E>) {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_mod[E](m: &_mod, sp: &span, e: &E, v: &vt<E>) {
|
||||
fn visit_mod<E>(m: &_mod, sp: &span, e: &E, v: &vt<E>) {
|
||||
for vi: @view_item in m.view_items { v.visit_view_item(vi, e, v); }
|
||||
for i: @item in m.items { v.visit_item(i, e, v); }
|
||||
}
|
||||
|
||||
fn visit_view_item[E](vi: &@view_item, e: &E, v: &vt<E>) { }
|
||||
fn visit_view_item<E>(vi: &@view_item, e: &E, v: &vt<E>) { }
|
||||
|
||||
fn visit_local[E](loc: &@local, e: &E, v: &vt<E>) {
|
||||
fn visit_local<E>(loc: &@local, e: &E, v: &vt<E>) {
|
||||
v.visit_pat(loc.node.pat, e, v);
|
||||
v.visit_ty(loc.node.ty, e, v);
|
||||
alt loc.node.init { none. { } some(i) { v.visit_expr(i.expr, e, v); } }
|
||||
}
|
||||
|
||||
fn visit_item[E](i: &@item, e: &E, v: &vt<E>) {
|
||||
fn visit_item<E>(i: &@item, e: &E, v: &vt<E>) {
|
||||
alt i.node {
|
||||
item_const(t, ex) { v.visit_ty(t, e, v); v.visit_expr(ex, e, v); }
|
||||
item_fn(f, tp) { v.visit_fn(f, tp, i.span, some(i.ident), i.id, e, v); }
|
||||
@ -111,7 +111,7 @@ fn visit_item[E](i: &@item, e: &E, v: &vt<E>) {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_ty[E](t: &@ty, e: &E, v: &vt<E>) {
|
||||
fn visit_ty<E>(t: &@ty, e: &E, v: &vt<E>) {
|
||||
alt t.node {
|
||||
ty_nil. {/* no-op */ }
|
||||
ty_bot. {/* no-op */ }
|
||||
@ -161,12 +161,12 @@ fn visit_ty[E](t: &@ty, e: &E, v: &vt<E>) {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_constr[E](operator: &path, sp: &span, id: node_id, e: &E,
|
||||
fn visit_constr<E>(operator: &path, sp: &span, id: node_id, e: &E,
|
||||
v: &vt<E>) {
|
||||
// default
|
||||
}
|
||||
|
||||
fn visit_pat[E](p: &@pat, e: &E, v: &vt<E>) {
|
||||
fn visit_pat<E>(p: &@pat, e: &E, v: &vt<E>) {
|
||||
alt p.node {
|
||||
pat_tag(path, children) {
|
||||
for tp: @ty in path.node.types { v.visit_ty(tp, e, v); }
|
||||
@ -183,14 +183,14 @@ fn visit_pat[E](p: &@pat, e: &E, v: &vt<E>) {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_native_item[E](ni: &@native_item, e: &E, v: &vt<E>) {
|
||||
fn visit_native_item<E>(ni: &@native_item, e: &E, v: &vt<E>) {
|
||||
alt ni.node {
|
||||
native_item_fn(_, fd, _) { visit_fn_decl(fd, e, v); }
|
||||
native_item_ty. { }
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_fn_decl[E](fd: &fn_decl, e: &E, v: &vt<E>) {
|
||||
fn visit_fn_decl<E>(fd: &fn_decl, e: &E, v: &vt<E>) {
|
||||
for a: arg in fd.inputs { v.visit_ty(a.ty, e, v); }
|
||||
for c: @constr in fd.constraints {
|
||||
v.visit_constr(c.node.path, c.span, c.node.id, e, v);
|
||||
@ -198,18 +198,18 @@ fn visit_fn_decl[E](fd: &fn_decl, e: &E, v: &vt<E>) {
|
||||
v.visit_ty(fd.output, e, v);
|
||||
}
|
||||
|
||||
fn visit_fn[E](f: &_fn, tp: &[ty_param], sp: &span, i: &fn_ident, id: node_id,
|
||||
fn visit_fn<E>(f: &_fn, tp: &[ty_param], sp: &span, i: &fn_ident, id: node_id,
|
||||
e: &E, v: &vt<E>) {
|
||||
visit_fn_decl(f.decl, e, v);
|
||||
v.visit_block(f.body, e, v);
|
||||
}
|
||||
|
||||
fn visit_block[E](b: &ast::blk, e: &E, v: &vt<E>) {
|
||||
fn visit_block<E>(b: &ast::blk, e: &E, v: &vt<E>) {
|
||||
for s: @stmt in b.node.stmts { v.visit_stmt(s, e, v); }
|
||||
visit_expr_opt(b.node.expr, e, v);
|
||||
}
|
||||
|
||||
fn visit_stmt[E](s: &@stmt, e: &E, v: &vt<E>) {
|
||||
fn visit_stmt<E>(s: &@stmt, e: &E, v: &vt<E>) {
|
||||
alt s.node {
|
||||
stmt_decl(d, _) { v.visit_decl(d, e, v); }
|
||||
stmt_expr(ex, _) { v.visit_expr(ex, e, v); }
|
||||
@ -217,7 +217,7 @@ fn visit_stmt[E](s: &@stmt, e: &E, v: &vt<E>) {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_decl[E](d: &@decl, e: &E, v: &vt<E>) {
|
||||
fn visit_decl<E>(d: &@decl, e: &E, v: &vt<E>) {
|
||||
alt d.node {
|
||||
decl_local(locs) {
|
||||
for loc: @ast::local in locs { v.visit_local(loc, e, v); }
|
||||
@ -226,15 +226,15 @@ fn visit_decl[E](d: &@decl, e: &E, v: &vt<E>) {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_expr_opt[E](eo: option::t<@expr>, e: &E, v: &vt<E>) {
|
||||
fn visit_expr_opt<E>(eo: option::t<@expr>, e: &E, v: &vt<E>) {
|
||||
alt eo { none. { } some(ex) { v.visit_expr(ex, e, v); } }
|
||||
}
|
||||
|
||||
fn visit_exprs[E](exprs: &[@expr], e: &E, v: &vt<E>) {
|
||||
fn visit_exprs<E>(exprs: &[@expr], e: &E, v: &vt<E>) {
|
||||
for ex: @expr in exprs { v.visit_expr(ex, e, v); }
|
||||
}
|
||||
|
||||
fn visit_mac[E](m: mac, e: &E, v: &vt<E>) {
|
||||
fn visit_mac<E>(m: mac, e: &E, v: &vt<E>) {
|
||||
alt m.node {
|
||||
ast::mac_invoc(pth, arg, body) { visit_expr(arg, e, v); }
|
||||
ast::mac_embed_type(ty) { v.visit_ty(ty, e, v); }
|
||||
@ -243,7 +243,7 @@ fn visit_mac[E](m: mac, e: &E, v: &vt<E>) {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_expr[E](ex: &@expr, e: &E, v: &vt<E>) {
|
||||
fn visit_expr<E>(ex: &@expr, e: &E, v: &vt<E>) {
|
||||
alt ex.node {
|
||||
expr_vec(es, _, _) { visit_exprs(es, e, v); }
|
||||
expr_rec(flds, base) {
|
||||
@ -338,7 +338,7 @@ fn visit_expr[E](ex: &@expr, e: &E, v: &vt<E>) {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_arm[E](a: &arm, e: &E, v: &vt<E>) {
|
||||
fn visit_arm<E>(a: &arm, e: &E, v: &vt<E>) {
|
||||
for p: @pat in a.pats { v.visit_pat(p, e, v); }
|
||||
v.visit_block(a.body, e, v);
|
||||
}
|
||||
|
@ -41,7 +41,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);
|
||||
|
@ -162,7 +162,7 @@ fn constrs_str(constrs: &[@constr]) -> str {
|
||||
ret s;
|
||||
}
|
||||
|
||||
fn ty_constr_to_str[Q](c: &@ast::spanned<ast::constr_general_<ast::path, Q>>)
|
||||
fn ty_constr_to_str<Q>(c: &@ast::spanned<ast::constr_general_<ast::path, Q>>)
|
||||
-> str {
|
||||
ret path_to_str(c.node.path) +
|
||||
constr_args_to_str[ast::path](path_to_str, c.node.args);
|
||||
|
Loading…
x
Reference in New Issue
Block a user