diff options
| author | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2011-08-12 07:15:18 -0700 |
|---|---|---|
| committer | Graydon Hoare <graydon@mozilla.com> | 2011-08-16 15:05:56 -0700 |
| commit | e4a0f997fb01b9cbb650532fea1278159faff064 (patch) | |
| tree | 6544a660e7af2a2485a14d200730d38e08ef29e4 /src/comp/syntax | |
| parent | f764f9a8cf52e686ba6e54b594e6bbbdd5bc7b32 (diff) | |
| download | rust-e4a0f997fb01b9cbb650532fea1278159faff064.tar.gz rust-e4a0f997fb01b9cbb650532fea1278159faff064.zip | |
Port the compiler to the typaram foo<T> syntax.
Diffstat (limited to 'src/comp/syntax')
| -rw-r--r-- | src/comp/syntax/ast.rs | 94 | ||||
| -rw-r--r-- | src/comp/syntax/codemap.rs | 14 | ||||
| -rw-r--r-- | src/comp/syntax/ext/base.rs | 6 | ||||
| -rw-r--r-- | src/comp/syntax/ext/concat_idents.rs | 2 | ||||
| -rw-r--r-- | src/comp/syntax/ext/env.rs | 4 | ||||
| -rw-r--r-- | src/comp/syntax/ext/expand.rs | 2 | ||||
| -rw-r--r-- | src/comp/syntax/ext/fmt.rs | 2 | ||||
| -rw-r--r-- | src/comp/syntax/ext/ident_to_str.rs | 2 | ||||
| -rw-r--r-- | src/comp/syntax/ext/log_syntax.rs | 4 | ||||
| -rw-r--r-- | src/comp/syntax/ext/simplext.rs | 48 | ||||
| -rw-r--r-- | src/comp/syntax/fold.rs | 2 | ||||
| -rw-r--r-- | src/comp/syntax/parse/lexer.rs | 10 | ||||
| -rw-r--r-- | src/comp/syntax/parse/parser.rs | 60 | ||||
| -rw-r--r-- | src/comp/syntax/print/pprust.rs | 28 | ||||
| -rw-r--r-- | src/comp/syntax/untyped_ast.rs | 14 | ||||
| -rw-r--r-- | src/comp/syntax/util/interner.rs | 14 | ||||
| -rw-r--r-- | src/comp/syntax/visit.rs | 106 |
17 files changed, 206 insertions, 206 deletions
diff --git a/src/comp/syntax/ast.rs b/src/comp/syntax/ast.rs index 53e00e8c6b4..05a9f86d04e 100644 --- a/src/comp/syntax/ast.rs +++ b/src/comp/syntax/ast.rs @@ -6,7 +6,7 @@ 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}; } +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 { @@ -18,14 +18,14 @@ fn dummy_sp() -> span { ret mk_sp(0u, 0u); } type ident = str; // Functions may or may not have names. -type fn_ident = option::t[ident]; +type fn_ident = option::t<ident>; // FIXME: with typestate constraint, could say // idents and types are the same length, and are // non-empty type path_ = {global: bool, idents: [ident], types: [@ty]}; -type path = spanned[path_]; +type path = spanned<path_>; fn path_name(p: &path) -> str { path_name_i(p.node.idents) } @@ -90,7 +90,7 @@ fn def_id_of_def(d: def) -> def_id { // used to drive conditional compilation type crate_cfg = [@meta_item]; -type crate = spanned[crate_]; +type crate = spanned<crate_>; type crate_ = {directives: [@crate_directive], @@ -99,9 +99,9 @@ type crate_ = config: crate_cfg}; tag crate_directive_ { - cdir_src_mod(ident, option::t[filename], [attribute]); + cdir_src_mod(ident, option::t<filename>, [attribute]); cdir_dir_mod(ident, - option::t[filename], + option::t<filename>, [@crate_directive], [attribute]); cdir_view_item(@view_item); @@ -109,9 +109,9 @@ tag crate_directive_ { cdir_auth(path, _auth); } -type crate_directive = spanned[crate_directive_]; +type crate_directive = spanned<crate_directive_>; -type meta_item = spanned[meta_item_]; +type meta_item = spanned<meta_item_>; tag meta_item_ { meta_word(ident); @@ -119,9 +119,9 @@ tag meta_item_ { meta_name_value(ident, lit); } -type blk = spanned[blk_]; +type blk = spanned<blk_>; -type blk_ = {stmts: [@stmt], expr: option::t[@expr], id: node_id}; +type blk_ = {stmts: [@stmt], expr: option::t<@expr>, id: node_id}; type pat = {id: node_id, node: pat_, span: span}; @@ -137,7 +137,7 @@ tag pat_ { pat_box(@pat); } -type pat_id_map = std::map::hashmap[str, ast::node_id]; +type pat_id_map = std::map::hashmap<str, ast::node_id>; // This is used because same-named variables in alternative patterns need to // use the node_id of their namesake in the first pattern. @@ -252,7 +252,7 @@ fn unop_to_str(op: unop) -> str { tag mode { val; alias(bool); move; } -type stmt = spanned[stmt_]; +type stmt = spanned<stmt_>; tag stmt_ { stmt_decl(@decl, node_id); @@ -267,12 +267,12 @@ type initializer = {op: init_op, expr: @expr}; type local_ = {ty: @ty, pat: @pat, - init: option::t[initializer], + init: option::t<initializer>, id: node_id}; -type local = spanned[local_]; +type local = spanned<local_>; -type decl = spanned[decl_]; +type decl = spanned<decl_>; tag decl_ { decl_local([@local]); decl_item(@item); } @@ -280,7 +280,7 @@ type arm = {pats: [@pat], body: blk}; type field_ = {mut: mutability, ident: ident, expr: @expr}; -type field = spanned[field_]; +type field = spanned<field_>; tag spawn_dom { dom_implicit; dom_thread; } @@ -293,16 +293,16 @@ type expr = {id: node_id, node: expr_, span: span}; tag expr_ { expr_vec([@expr], mutability, seq_kind); - expr_rec([field], option::t[@expr]); + expr_rec([field], option::t<@expr>); expr_call(@expr, [@expr]); expr_tup([@expr]); expr_self_method(ident); - expr_bind(@expr, [option::t[@expr]]); + expr_bind(@expr, [option::t<@expr>]); expr_binary(binop, @expr, @expr); expr_unary(unop, @expr); expr_lit(@lit); expr_cast(@expr, @ty); - expr_if(@expr, blk, option::t[@expr]); + expr_if(@expr, blk, option::t<@expr>); expr_ternary(@expr, @expr, @expr); expr_while(@expr, blk); expr_for(@local, @expr, blk); @@ -323,11 +323,11 @@ tag expr_ { expr_field(@expr, ident); expr_index(@expr, @expr); expr_path(path); - expr_fail(option::t[@expr]); + expr_fail(option::t<@expr>); expr_break; expr_cont; - expr_ret(option::t[@expr]); - expr_put(option::t[@expr]); + expr_ret(option::t<@expr>); + expr_put(option::t<@expr>); expr_be(@expr); expr_log(int, @expr); /* just an assert, no significance to typestate */ @@ -336,22 +336,22 @@ tag expr_ { expr_check(check_mode, @expr); /* FIXME Would be nice if expr_check desugared to expr_if_check. */ - expr_if_check(@expr, blk, option::t[@expr]); + expr_if_check(@expr, blk, option::t<@expr>); expr_anon_obj(anon_obj); expr_mac(mac); expr_uniq(@expr); } -type mac = spanned[mac_]; +type mac = spanned<mac_>; tag mac_ { - mac_invoc(path, @expr, option::t[str]); + mac_invoc(path, @expr, option::t<str>); mac_embed_type(@ty); mac_embed_block(blk); mac_ellipsis; } -type lit = spanned[lit_]; +type lit = spanned<lit_>; tag lit_ { lit_str(str, seq_kind); @@ -386,11 +386,11 @@ type ty_method_ = cf: controlflow, constrs: [@constr]}; -type ty_field = spanned[ty_field_]; +type ty_field = spanned<ty_field_>; -type ty_arg = spanned[ty_arg_]; +type ty_arg = spanned<ty_arg_>; -type ty_method = spanned[ty_method_]; +type ty_method = spanned<ty_method_>; tag ty_mach { ty_i8; @@ -420,7 +420,7 @@ fn ty_mach_to_str(tm: ty_mach) -> str { } } -type ty = spanned[ty_]; +type ty = spanned<ty_>; tag ty_ { ty_nil; @@ -470,10 +470,10 @@ declarations, and ident for uses. */ 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 ty_constr_arg = sp_constr_arg[path]; -type constr_arg = spanned[fn_constr_arg]; +type fn_constr_arg = constr_arg_general_<uint>; +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>; // Constrained types' args are parameterized by paths, since // we refer to paths directly and not by indices. @@ -481,15 +481,15 @@ type constr_arg = spanned[fn_constr_arg]; // constrained type, is * (referring to the base record) type constr_general_[ARG, ID] = - {path: path, args: [@spanned[constr_arg_general_[ARG]]], id: 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_ = constr_general_[uint, node_id]; -type constr = spanned[constr_general_[uint, node_id]]; -type ty_constr_ = ast::constr_general_[ast::path, ast::node_id]; -type ty_constr = spanned[ty_constr_]; +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>; +type ty_constr = spanned<ty_constr_>; /* The parser generates ast::constrs; resolve generates a mapping from each function to a list of ty::constr_defs, @@ -521,7 +521,7 @@ type _fn = {decl: fn_decl, proto: proto, body: blk}; type method_ = {ident: ident, meth: _fn, id: node_id}; -type method = spanned[method_]; +type method = spanned<method_>; type obj_field = {mut: mutability, ty: @ty, ident: ident, id: node_id}; type anon_obj_field = @@ -531,10 +531,10 @@ type _obj = {fields: [obj_field], methods: [@method]}; type anon_obj = // New fields and methods, if they exist. - {fields: option::t[[anon_obj_field]], + {fields: option::t<[anon_obj_field]>, methods: [@method], // inner_obj: the original object being extended, if it exists. - inner_obj: option::t[@expr]}; + inner_obj: option::t<@expr>}; type _mod = {view_items: [@view_item], items: [@item]}; @@ -556,9 +556,9 @@ type variant_arg = {ty: @ty, id: node_id}; type variant_ = {name: str, args: [variant_arg], id: node_id}; -type variant = spanned[variant_]; +type variant = spanned<variant_>; -type view_item = spanned[view_item_]; +type view_item = spanned<view_item_>; tag view_item_ { view_item_use(ident, [@meta_item], node_id); @@ -571,7 +571,7 @@ type obj_def_ids = {ty: node_id, ctor: node_id}; // Meta-data associated with an item -type attribute = spanned[attribute_]; +type attribute = spanned<attribute_>; // Distinguishes between attributes that decorate items and attributes that @@ -607,7 +607,7 @@ type native_item = tag native_item_ { native_item_ty; - native_item_fn(option::t[str], fn_decl, [ty_param]); + native_item_fn(option::t<str>, fn_decl, [ty_param]); } fn is_exported(i: ident, m: _mod) -> bool { diff --git a/src/comp/syntax/codemap.rs b/src/comp/syntax/codemap.rs index 10bf7f478b7..a2542e5fddf 100644 --- a/src/comp/syntax/codemap.rs +++ b/src/comp/syntax/codemap.rs @@ -95,10 +95,10 @@ fn span_to_str(sp: &span, cm: &codemap) -> str { ret res; } -fn emit_diagnostic(sp: &option::t[span], msg: &str, kind: &str, color: u8, +fn emit_diagnostic(sp: &option::t<span>, msg: &str, kind: &str, color: u8, cm: &codemap) { let ss = "<input>:0:0:0:0"; - let maybe_lines: option::t[@file_lines] = none; + let maybe_lines: option::t<@file_lines> = none; alt sp { some(ssp) { ss = span_to_str(ssp, cm); @@ -119,8 +119,8 @@ fn emit_diagnostic(sp: &option::t[span], msg: &str, kind: &str, color: u8, maybe_highlight_lines(sp, cm, maybe_lines); } -fn maybe_highlight_lines(sp: &option::t[span], cm: &codemap, - maybe_lines: option::t[@file_lines]) { +fn maybe_highlight_lines(sp: &option::t<span>, cm: &codemap, + maybe_lines: option::t<@file_lines>) { alt maybe_lines { some(lines) { @@ -187,13 +187,13 @@ fn maybe_highlight_lines(sp: &option::t[span], cm: &codemap, } } -fn emit_warning(sp: &option::t[span], msg: &str, cm: &codemap) { +fn emit_warning(sp: &option::t<span>, msg: &str, cm: &codemap) { emit_diagnostic(sp, msg, "warning", 11u8, cm); } -fn emit_error(sp: &option::t[span], msg: &str, cm: &codemap) { +fn emit_error(sp: &option::t<span>, msg: &str, cm: &codemap) { emit_diagnostic(sp, msg, "error", 9u8, cm); } -fn emit_note(sp: &option::t[span], msg: &str, cm: &codemap) { +fn emit_note(sp: &option::t<span>, msg: &str, cm: &codemap) { emit_diagnostic(sp, msg, "note", 10u8, cm); } diff --git a/src/comp/syntax/ext/base.rs b/src/comp/syntax/ext/base.rs index 47048ed1951..5a9b3ac1d19 100644 --- a/src/comp/syntax/ext/base.rs +++ b/src/comp/syntax/ext/base.rs @@ -7,10 +7,10 @@ import std::map::new_str_hash; import codemap; type syntax_expander = - fn(&ext_ctxt, span, @ast::expr, option::t[str]) -> @ast::expr ; + fn(&ext_ctxt, span, @ast::expr, option::t<str>) -> @ast::expr ; type macro_def = {ident: str, ext: syntax_extension}; type macro_definer = - fn(&ext_ctxt, span, @ast::expr, option::t[str]) -> macro_def ; + fn(&ext_ctxt, span, @ast::expr, option::t<str>) -> macro_def ; tag syntax_extension { normal(syntax_expander); @@ -19,7 +19,7 @@ tag syntax_extension { // A temporary hard-coded map of methods for expanding syntax extension // AST nodes into full ASTs -fn syntax_expander_table() -> hashmap[str, syntax_extension] { +fn syntax_expander_table() -> hashmap<str, syntax_extension> { let syntax_expanders = new_str_hash[syntax_extension](); syntax_expanders.insert("fmt", normal(ext::fmt::expand_syntax_ext)); syntax_expanders.insert("env", normal(ext::env::expand_syntax_ext)); diff --git a/src/comp/syntax/ext/concat_idents.rs b/src/comp/syntax/ext/concat_idents.rs index f21af93668f..43ec2488816 100644 --- a/src/comp/syntax/ext/concat_idents.rs +++ b/src/comp/syntax/ext/concat_idents.rs @@ -3,7 +3,7 @@ import base::*; import syntax::ast; fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr, - body: option::t[str]) -> @ast::expr { + body: option::t<str>) -> @ast::expr { let args: [@ast::expr] = alt arg.node { ast::expr_vec(elts, _, _) { elts } _ { cx.span_fatal(sp, "#concat_idents requires a vector argument .") } diff --git a/src/comp/syntax/ext/env.rs b/src/comp/syntax/ext/env.rs index 5a53f26a007..498792b80b0 100644 --- a/src/comp/syntax/ext/env.rs +++ b/src/comp/syntax/ext/env.rs @@ -11,7 +11,7 @@ import base::*; export expand_syntax_ext; fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr, - body: option::t[str]) -> @ast::expr { + body: option::t<str>) -> @ast::expr { let args: [@ast::expr] = alt arg.node { ast::expr_vec(elts, _, _) { elts } _ { cx.span_fatal(sp, "#env requires arguments of the form `[...]`.") } @@ -20,7 +20,7 @@ fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr, cx.span_fatal(sp, "malformed #env call"); } // FIXME: if this was more thorough it would manufacture an - // option::t[str] rather than just an maybe-empty string. + // option::t<str> rather than just an maybe-empty string. let var = expr_to_str(cx, args.(0), "#env requires a string"); alt generic_os::getenv(var) { diff --git a/src/comp/syntax/ext/expand.rs b/src/comp/syntax/ext/expand.rs index d5e9fda2c84..044bee4ba2b 100644 --- a/src/comp/syntax/ext/expand.rs +++ b/src/comp/syntax/ext/expand.rs @@ -14,7 +14,7 @@ import syntax::fold::*; import syntax::ext::base::*; -fn expand_expr(exts: &hashmap[str, syntax_extension], cx: &ext_ctxt, +fn expand_expr(exts: &hashmap<str, syntax_extension>, cx: &ext_ctxt, e: &expr_, fld: ast_fold, orig: &fn(&expr_, ast_fold) -> expr_ ) -> expr_ { ret alt e { diff --git a/src/comp/syntax/ext/fmt.rs b/src/comp/syntax/ext/fmt.rs index b8ab57303df..fd0ba7d4d01 100644 --- a/src/comp/syntax/ext/fmt.rs +++ b/src/comp/syntax/ext/fmt.rs @@ -16,7 +16,7 @@ import codemap::span; export expand_syntax_ext; fn expand_syntax_ext(cx: &ext_ctxt, sp: span, arg: @ast::expr, - body: option::t[str]) -> @ast::expr { + body: option::t<str>) -> @ast::expr { let args: [@ast::expr] = alt arg.node { ast::expr_vec(elts, _, _) { elts } _ { cx.span_fatal(sp, "#fmt requires arguments of the form `[...]`.") } diff --git a/src/comp/syntax/ext/ident_to_str.rs b/src/comp/syntax/ext/ident_to_str.rs index c32acaf05b3..841f8221e3e 100644 --- a/src/comp/syntax/ext/ident_to_str.rs +++ b/src/comp/syntax/ext/ident_to_str.rs @@ -4,7 +4,7 @@ import base::*; import syntax::ast; fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr, - body: option::t[str]) -> @ast::expr { + body: option::t<str>) -> @ast::expr { let args: [@ast::expr] = alt arg.node { ast::expr_vec(elts, _, _) { elts } _ { cx.span_fatal(sp, "#ident_to_str requires a vector argument .") } diff --git a/src/comp/syntax/ext/log_syntax.rs b/src/comp/syntax/ext/log_syntax.rs index 9cd745f07f7..34c240a985c 100644 --- a/src/comp/syntax/ext/log_syntax.rs +++ b/src/comp/syntax/ext/log_syntax.rs @@ -3,11 +3,11 @@ import base::*; import syntax::ast; fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr, - body: option::t[str]) -> @ast::expr { + body: option::t<str>) -> @ast::expr { cx.print_backtrace(); std::io::stdout().write_line(print::pprust::expr_to_str(arg)); //trivial expression ret @{id: cx.next_id(), node: ast::expr_rec(~[], option::none), span: sp}; -} \ No newline at end of file +} diff --git a/src/comp/syntax/ext/simplext.rs b/src/comp/syntax/ext/simplext.rs index 29f474b7878..aae2404f57b 100644 --- a/src/comp/syntax/ext/simplext.rs +++ b/src/comp/syntax/ext/simplext.rs @@ -32,7 +32,7 @@ import ast::mac_invoc; export add_new_extension; -fn path_to_ident(pth: &path) -> option::t[ident] { +fn path_to_ident(pth: &path) -> option::t<ident> { if vec::len(pth.node.idents) == 1u && vec::len(pth.node.types) == 0u { ret some(pth.node.idents.(0u)); } @@ -43,13 +43,13 @@ 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 { match_expr(@expr); match_path(path); - match_ident(ast::spanned[ident]); + match_ident(ast::spanned<ident>); match_ty(@ty); match_block(ast::blk); match_exact; /* don't bind anything, just verify the AST traversal */ @@ -88,11 +88,11 @@ fn match_error(cx: &ext_ctxt, m: &matchable, expected: &str) -> ! { // If we want better match failure error messages (like in Fortifying Syntax), // we'll want to return something indicating amount of progress and location // of failure instead of `none`. -type match_result = option::t[arb_depth[matchable]]; +type match_result = option::t<arb_depth<matchable>>; type selector = fn(&matchable) -> match_result ; fn elts_to_ell(cx: &ext_ctxt, elts: &[@expr]) - -> {pre: [@expr], rep: option::t[@expr], post: [@expr]} { + -> {pre: [@expr], rep: option::t<@expr>, post: [@expr]} { let idx: uint = 0u; let res = none; for elt: @expr in elts { @@ -121,8 +121,8 @@ fn elts_to_ell(cx: &ext_ctxt, elts: &[@expr]) } } -fn option_flatten_map[T, U](f: &fn(&T) -> option::t[U] , v: &[T]) -> - option::t[[U]] { +fn option_flatten_map[T, U](f: &fn(&T) -> option::t<U>, v: &[T]) -> + option::t<[U]> { let res = ~[]; for elem: T in v { alt f(elem) { none. { ret none; } some(fv) { res += ~[fv]; } } @@ -130,7 +130,7 @@ fn option_flatten_map[T, U](f: &fn(&T) -> option::t[U] , v: &[T]) -> ret some(res); } -fn a_d_map(ad: &arb_depth[matchable], f: &selector) -> match_result { +fn a_d_map(ad: &arb_depth<matchable>, f: &selector) -> match_result { alt ad { leaf(x) { ret f(x); } seq(ads, span) { @@ -155,9 +155,9 @@ fn compose_sels(s1: selector, s2: selector) -> selector { type binders = - {real_binders: hashmap[ident, selector], + {real_binders: hashmap<ident, selector>, mutable literal_ast_matchers: [selector]}; -type bindings = hashmap[ident, arb_depth[matchable]]; +type bindings = hashmap<ident, arb_depth<matchable>>; fn acumm_bindings(cx: &ext_ctxt, b_dest: &bindings, b_src: &bindings) { } @@ -182,8 +182,8 @@ fn pattern_to_selectors(cx: &ext_ctxt, e: @expr) -> binders { bindings. Most of the work is done in p_t_s, which generates the selectors. */ -fn use_selectors_to_bind(b: &binders, e: @expr) -> option::t[bindings] { - let res = new_str_hash[arb_depth[matchable]](); +fn use_selectors_to_bind(b: &binders, e: @expr) -> option::t<bindings> { + let res = new_str_hash[arb_depth<matchable>](); //need to do this first, to check vec lengths. for sel: selector in b.literal_ast_matchers { alt sel(match_expr(e)) { none. { ret none; } _ { } } @@ -230,9 +230,9 @@ fn transcribe(cx: &ext_ctxt, b: &bindings, body: @expr) -> @expr { /* helper: descend into a matcher */ -fn follow(m: &arb_depth[matchable], idx_path: @mutable [uint]) -> - arb_depth[matchable] { - let res: arb_depth[matchable] = m; +fn follow(m: &arb_depth<matchable>, idx_path: @mutable [uint]) -> + arb_depth<matchable> { + let res: arb_depth<matchable> = m; for idx: uint in *idx_path { alt res { leaf(_) { ret res;/* end of the line */ } @@ -242,8 +242,8 @@ fn follow(m: &arb_depth[matchable], idx_path: @mutable [uint]) -> ret res; } -fn follow_for_trans(cx: &ext_ctxt, mmaybe: &option::t[arb_depth[matchable]], - idx_path: @mutable [uint]) -> option::t[matchable] { +fn follow_for_trans(cx: &ext_ctxt, mmaybe: &option::t<arb_depth<matchable>>, + idx_path: @mutable [uint]) -> option::t<matchable> { alt mmaybe { none. { ret none } some(m) { @@ -262,9 +262,9 @@ fn follow_for_trans(cx: &ext_ctxt, mmaybe: &option::t[arb_depth[matchable]], /* helper for transcribe_exprs: what vars from `b` occur in `e`? */ iter free_vars(b: &bindings, e: @expr) -> ident { - let idents: hashmap[ident, ()] = new_str_hash[()](); + let idents: hashmap<ident, ()> = new_str_hash[()](); fn mark_ident(i: &ident, fld: ast_fold, b: &bindings, - idents: &hashmap[ident, ()]) -> ident { + idents: &hashmap<ident, ()>) -> ident { if b.contains_key(i) { idents.insert(i, ()); } ret i; } @@ -290,7 +290,7 @@ fn transcribe_exprs(cx: &ext_ctxt, b: &bindings, idx_path: @mutable [uint], alt repeat_me_maybe { none. {} some(repeat_me) { - let repeat: option::t[{rep_count: uint, name: ident}] = none; + let repeat: option::t<{rep_count: uint, name: ident}> = none; /* we need to walk over all the free vars in lockstep, except for the leaves, which are just duplicated */ for each fv: ident in free_vars(b, repeat_me) { @@ -533,7 +533,7 @@ fn p_t_s_r_path(cx: &ext_ctxt, p: &path, s: &selector, b: &binders) { } } -fn block_to_ident(blk: &blk_) -> option::t[ident] { +fn block_to_ident(blk: &blk_) -> option::t<ident> { if vec::len(blk.stmts) != 0u { ret none; } ret alt blk.expr { some(expr) { @@ -676,7 +676,7 @@ fn p_t_s_r_actual_vector(cx: &ext_ctxt, elts: [@expr], repeat_after: bool, } fn add_new_extension(cx: &ext_ctxt, sp: span, arg: @expr, - body: option::t[str]) -> base::macro_def { + body: option::t<str>) -> base::macro_def { let args: [@ast::expr] = alt arg.node { ast::expr_vec(elts, _, _) { elts } _ { @@ -684,7 +684,7 @@ fn add_new_extension(cx: &ext_ctxt, sp: span, arg: @expr, } }; - let macro_name: option::t[str] = none; + let macro_name: option::t<str> = none; let clauses: [@clause] = ~[]; for arg: @expr in args { alt arg.node { @@ -753,7 +753,7 @@ fn add_new_extension(cx: &ext_ctxt, sp: span, arg: @expr, ext: normal(ext)}; fn generic_extension(cx: &ext_ctxt, sp: span, arg: @expr, - body: option::t[str], clauses: [@clause]) -> @expr { + body: option::t<str>, clauses: [@clause]) -> @expr { for c: @clause in clauses { alt use_selectors_to_bind(c.params, arg) { some(bindings) { diff --git a/src/comp/syntax/fold.rs b/src/comp/syntax/fold.rs index 9cf9bf3e8b4..ca318f191d8 100644 --- a/src/comp/syntax/fold.rs +++ b/src/comp/syntax/fold.rs @@ -497,7 +497,7 @@ fn noop_fold_local(l: &local_, fld: ast_fold) -> local_ { id: l.id}; } -/* temporarily eta-expand because of a compiler bug with using `fn[T]` as a +/* temporarily eta-expand because of a compiler bug with using `fn<T>` as a value */ fn noop_map_exprs(f: fn(&@expr) -> @expr , es: [@expr]) -> [@expr] { ret vec::map(f, es); diff --git a/src/comp/syntax/parse/lexer.rs b/src/comp/syntax/parse/lexer.rs index 8b7eaee1534..2d92da32273 100644 --- a/src/comp/syntax/parse/lexer.rs +++ b/src/comp/syntax/parse/lexer.rs @@ -20,7 +20,7 @@ type reader = fn init() ; fn bump() ; fn get_str_from(uint) -> str ; - fn get_interner() -> @interner::interner[str] ; + fn get_interner() -> @interner::interner<str> ; fn get_chpos() -> uint ; fn get_byte_pos() -> uint ; fn get_col() -> uint ; @@ -29,7 +29,7 @@ type reader = }; fn new_reader(cm: &codemap::codemap, src: str, filemap: codemap::filemap, - itr: @interner::interner[str]) -> reader { + itr: @interner::interner<str>) -> reader { obj reader(cm: codemap::codemap, src: str, len: uint, @@ -39,7 +39,7 @@ fn new_reader(cm: &codemap::codemap, src: str, filemap: codemap::filemap, mutable chpos: uint, mutable strs: [str], fm: codemap::filemap, - itr: @interner::interner[str]) { + itr: @interner::interner<str>) { fn is_eof() -> bool { ret ch == -1 as char; } fn get_str_from(start: uint) -> str { // I'm pretty skeptical about this subtraction. What if there's a @@ -74,7 +74,7 @@ fn new_reader(cm: &codemap::codemap, src: str, filemap: codemap::filemap, ch = next.ch; } else { ch = -1 as char; } } - fn get_interner() -> @interner::interner[str] { ret itr; } + fn get_interner() -> @interner::interner<str> { ret itr; } fn get_col() -> uint { ret col; } fn get_filemap() -> codemap::filemap { ret fm; } fn err(m: str) { @@ -173,7 +173,7 @@ fn digits_to_string(s: str) -> int { ret accum_int; } -fn scan_exponent(rdr: &reader) -> option::t[str] { +fn scan_exponent(rdr: &reader) -> option::t<str> { let c = rdr.curr(); let rslt = ""; if c == 'e' || c == 'E' { diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index 2bbebc3c56e..3bdeef0c011 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -52,7 +52,7 @@ type parser = fn get_str(token::str_num) -> str ; fn get_reader() -> lexer::reader ; fn get_filemap() -> codemap::filemap ; - fn get_bad_expr_words() -> hashmap[str, ()] ; + fn get_bad_expr_words() -> hashmap<str, ()> ; fn get_chpos() -> uint ; fn get_byte_pos() -> uint ; fn get_id() -> node_id ; @@ -84,7 +84,7 @@ fn new_parser(sess: parse_sess, cfg: ast::crate_cfg, rdr: lexer::reader, mutable restr: restriction, rdr: lexer::reader, precs: @[op_spec], - bad_words: hashmap[str, ()]) { + bad_words: hashmap<str, ()>) { fn peek() -> token::token { ret tok; } fn bump() { last_tok_span = tok_span; @@ -132,7 +132,7 @@ fn new_parser(sess: parse_sess, cfg: ast::crate_cfg, rdr: lexer::reader, } fn get_reader() -> lexer::reader { ret rdr; } fn get_filemap() -> codemap::filemap { ret rdr.get_filemap(); } - fn get_bad_expr_words() -> hashmap[str, ()] { ret bad_words; } + fn get_bad_expr_words() -> hashmap<str, ()> { ret bad_words; } fn get_chpos() -> uint { ret rdr.get_chpos(); } fn get_byte_pos() -> uint { ret rdr.get_byte_pos(); } fn get_id() -> node_id { ret next_node_id(sess); } @@ -148,7 +148,7 @@ fn new_parser(sess: parse_sess, cfg: ast::crate_cfg, rdr: lexer::reader, // These are the words that shouldn't be allowed as value identifiers, // because, if used at the start of a line, they will cause the line to be // interpreted as a specific kind of statement, which would be confusing. -fn bad_expr_word_table() -> hashmap[str, ()] { +fn bad_expr_word_table() -> hashmap<str, ()> { let words = new_str_hash(); words.insert("mod", ()); words.insert("if", ()); @@ -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,9 +429,9 @@ fn parse_constr_in_type(p: &parser) -> @ast::ty_constr { } -fn parse_constrs[T](pser: fn(&parser) -> @ast::constr_general[T] , p: &parser) - -> [@ast::constr_general[T]] { - let constrs: [@ast::constr_general[T]] = ~[]; +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 { let constr = pser(p); constrs += ~[constr]; @@ -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,8 +668,8 @@ 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, - p: &parser) -> spanned[[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); let result = parse_seq_to_before_gt[T](sep, f, p); @@ -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] = ~[]; @@ -701,8 +701,8 @@ 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, - sep: option::t[token::token], f: fn(&parser) -> T , - p: &parser) -> spanned[[T]] { + sep: option::t<token::token>, f: fn(&parser) -> T , + p: &parser) -> spanned<[T]> { let lo = p.get_lo_pos(); expect(p, bra); let result = parse_seq_to_before_end[T](ket, sep, f, p); @@ -955,7 +955,7 @@ fn parse_bottom_expr(p: &parser) -> @ast::expr { // Anonymous object // Only make people type () if they're actually adding new fields - let fields: option::t[[ast::anon_obj_field]] = none; + let fields: option::t<[ast::anon_obj_field]> = none; if p.peek() == token::LPAREN { p.bump(); fields = @@ -963,7 +963,7 @@ fn parse_bottom_expr(p: &parser) -> @ast::expr { parse_anon_obj_field, p)); } let meths: [@ast::method] = ~[]; - let inner_obj: option::t[@ast::expr] = none; + let inner_obj: option::t<@ast::expr> = none; expect(p, token::LBRACE); while p.peek() != token::RBRACE { if eat_word(p, "with") { @@ -982,7 +982,7 @@ fn parse_bottom_expr(p: &parser) -> @ast::expr { ex = ast::expr_anon_obj(ob); } else if (eat_word(p, "bind")) { let e = parse_expr_res(p, RESTRICT_NO_CALL_EXPRS); - fn parse_expr_opt(p: &parser) -> option::t[@ast::expr] { + fn parse_expr_opt(p: &parser) -> option::t<@ast::expr> { alt p.peek() { token::UNDERSCORE. { p.bump(); ret none; } _ { ret some(parse_expr(p)); } @@ -1329,13 +1329,13 @@ fn parse_assign_expr(p: &parser) -> @ast::expr { fn parse_if_expr_1(p: &parser) -> {cond: @ast::expr, then: ast::blk, - els: option::t[@ast::expr], + els: option::t<@ast::expr>, lo: uint, hi: uint} { let lo = p.get_last_lo_pos(); let cond = parse_expr(p); let thn = parse_block(p); - let els: option::t[@ast::expr] = none; + let els: option::t<@ast::expr> = none; let hi = thn.span.hi; if eat_word(p, "else") { let elexpr = parse_else_expr(p); @@ -1437,7 +1437,7 @@ fn parse_expr_res(p: &parser, r: restriction) -> @ast::expr { ret e; } -fn parse_initializer(p: &parser) -> option::t[ast::initializer] { +fn parse_initializer(p: &parser) -> option::t<ast::initializer> { alt p.peek() { token::EQ. { p.bump(); @@ -1653,7 +1653,7 @@ fn parse_source_stmt(p: &parser) -> @ast::stmt { } } -fn stmt_to_expr(stmt: @ast::stmt) -> option::t[@ast::expr] { +fn stmt_to_expr(stmt: @ast::stmt) -> option::t<@ast::expr> { ret alt stmt.node { ast::stmt_expr(e, _) { some(e) } _ { none } }; } @@ -1724,7 +1724,7 @@ fn parse_block(p: &parser) -> ast::blk { // some blocks start with "#{"... fn parse_block_tail(p: &parser, lo: uint) -> ast::blk { let stmts: [@ast::stmt] = ~[]; - let expr: option::t[@ast::expr] = none; + let expr: option::t<@ast::expr> = none; while p.peek() != token::RBRACE { alt p.peek() { token::SEMI. { @@ -1796,7 +1796,7 @@ fn parse_ty_params(p: &parser) -> [ast::ty_param] { fn parse_fn_decl(p: &parser, purity: ast::purity, il: ast::inlineness) -> ast::fn_decl { - let inputs: ast::spanned[[ast::arg]] = + let inputs: ast::spanned<[ast::arg]> = parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA), parse_arg, p); let rslt: ty_or_bang; @@ -1835,7 +1835,7 @@ fn parse_fn_decl(p: &parser, purity: ast::purity, il: ast::inlineness) } fn parse_fn_block_decl(p: &parser) -> ast::fn_decl { - let inputs: ast::spanned[[ast::arg]] = + let inputs: ast::spanned<[ast::arg]> = parse_seq(token::BINOP(token::OR), token::BINOP(token::OR), some(token::COMMA), parse_fn_block_arg, p); ret {inputs: inputs.node, @@ -1910,7 +1910,7 @@ fn parse_item_obj(p: &parser, attrs: &[ast::attribute]) -> let lo = p.get_last_lo_pos(); let ident = parse_value_ident(p); let ty_params = parse_ty_params(p); - let fields: ast::spanned[[ast::obj_field]] = + let fields: ast::spanned<[ast::obj_field]> = parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA), parse_obj_field, p); let meths: [@ast::method] = ~[]; @@ -2171,7 +2171,7 @@ fn parse_auth(p: &parser) -> ast::_auth { } else { unexpected(p, p.peek()); } } -fn parse_item(p: &parser, attrs: &[ast::attribute]) -> option::t[@ast::item] { +fn parse_item(p: &parser, attrs: &[ast::attribute]) -> option::t<@ast::item> { if eat_word(p, "const") { ret some(parse_item_const(p, attrs)); } else if (eat_word(p, "inline")) { @@ -2207,7 +2207,7 @@ fn parse_item(p: &parser, attrs: &[ast::attribute]) -> option::t[@ast::item] { // A type to distingush between the parsing of item attributes or syntax // extensions, which both begin with token.POUND -type attr_or_ext = option::t[either::t[[ast::attribute], @ast::expr]]; +type attr_or_ext = option::t<either::t<[ast::attribute], @ast::expr>>; fn parse_outer_attrs_or_ext(p: &parser) -> attr_or_ext { if p.peek() == token::POUND { @@ -2311,7 +2311,7 @@ fn parse_use(p: &parser) -> ast::view_item_ { } fn parse_rest_import_name(p: &parser, first: ast::ident, - def_ident: option::t[ast::ident]) -> + def_ident: option::t<ast::ident>) -> ast::view_item_ { let identifiers: [ast::ident] = ~[first]; let glob: bool = false; diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs index f7a967fd57c..330b859aa85 100644 --- a/src/comp/syntax/print/pprust.rs +++ b/src/comp/syntax/print/pprust.rs @@ -40,9 +40,9 @@ fn no_ann() -> pp_ann { type ps = @{s: pp::printer, - cm: option::t[codemap], - comments: option::t[[lexer::cmnt]], - literals: option::t[[lexer::lit]], + cm: option::t<codemap>, + comments: option::t<[lexer::cmnt]>, + literals: option::t<[lexer::lit]>, mutable cur_cmnt: uint, mutable cur_lit: uint, mutable boxes: [pp::breaks], @@ -619,7 +619,7 @@ fn print_possibly_embedded_block(s: &ps, blk: &ast::blk, embedded: embed_type, // followed by a unary op statement. In those cases we have to add an // extra semi to make sure the unop is not parsed as a binop with the // if/alt/block expression. - fn maybe_protect_unop(s: &ps, last: &option::t[@ast::stmt], + fn maybe_protect_unop(s: &ps, last: &option::t<@ast::stmt>, next: &expr_or_stmt) { let last_expr_is_block = alt last { option::some(@{node: ast::stmt_expr(e, _), _}) { @@ -651,13 +651,13 @@ fn print_possibly_embedded_block(s: &ps, blk: &ast::blk, embedded: embed_type, } fn print_if(s: &ps, test: &@ast::expr, blk: &ast::blk, - elseopt: &option::t[@ast::expr], chk: bool) { + elseopt: &option::t<@ast::expr>, chk: bool) { head(s, "if"); if chk { word_nbsp(s, "check"); } print_expr(s, test); space(s.s); print_block(s, blk); - fn do_else(s: &ps, els: option::t[@ast::expr]) { + fn do_else(s: &ps, els: option::t<@ast::expr>) { alt els { some(_else) { alt _else.node { @@ -773,7 +773,7 @@ fn print_expr(s: &ps, expr: &@ast::expr) { print_ident(s, ident); } ast::expr_bind(func, args) { - fn print_opt(s: &ps, expr: &option::t[@ast::expr]) { + fn print_opt(s: &ps, expr: &option::t<@ast::expr>) { alt expr { some(expr) { print_expr(s, expr); } _ { word(s.s, "_"); } @@ -1325,7 +1325,7 @@ fn print_mt(s: &ps, mt: &ast::mt) { print_type(s, mt.ty); } -fn print_ty_fn(s: &ps, proto: &ast::proto, id: &option::t[str], +fn print_ty_fn(s: &ps, proto: &ast::proto, id: &option::t<str>, inputs: &[ast::ty_arg], output: &@ast::ty, cf: &ast::controlflow, constrs: &[@ast::constr]) { ibox(s, indent_unit); @@ -1355,7 +1355,7 @@ fn print_ty_fn(s: &ps, proto: &ast::proto, id: &option::t[str], } fn maybe_print_trailing_comment(s: &ps, span: codemap::span, - next_pos: option::t[uint]) { + next_pos: option::t<uint>) { let cm; alt s.cm { some(ccm) { cm = ccm; } _ { ret; } } alt next_comment(s) { @@ -1431,7 +1431,7 @@ fn print_literal(s: &ps, lit: &@ast::lit) { fn lit_to_str(l: &@ast::lit) -> str { be to_str(l, print_literal); } -fn next_lit(s: &ps) -> option::t[lexer::lit] { +fn next_lit(s: &ps) -> option::t<lexer::lit> { alt s.literals { some(lits) { if s.cur_lit < vec::len(lits) { @@ -1523,7 +1523,7 @@ fn to_str[T](t: &T, f: fn(&ps, &T) ) -> str { ret writer.get_str(); } -fn next_comment(s: &ps) -> option::t[lexer::cmnt] { +fn next_comment(s: &ps) -> option::t<lexer::cmnt> { alt s.comments { some(cmnts) { if s.cur_cmnt < vec::len(cmnts) { @@ -1537,10 +1537,10 @@ 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 , - args: &[@ast::sp_constr_arg[T]]) -> str { + args: &[@ast::sp_constr_arg<T>]) -> str { let comma = false; let s = "("; - for a: @ast::sp_constr_arg[T] in args { + for a: @ast::sp_constr_arg<T> in args { if comma { s += ", "; } else { comma = true; } s += constr_arg_to_str[T](f, a.node); } @@ -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 "*"; } diff --git a/src/comp/syntax/untyped_ast.rs b/src/comp/syntax/untyped_ast.rs index 39982ec4ca4..ad92513ede0 100644 --- a/src/comp/syntax/untyped_ast.rs +++ b/src/comp/syntax/untyped_ast.rs @@ -9,9 +9,9 @@ import codemap::span; import codemap::filename; tag ast_node { - branch(node_name, option::t[span], (@ast_node)[]); + branch(node_name, option::t<span>, (@ast_node)[]); i_seq((@ast_node)[]); - i_opt(option::t[@ast_node]); + i_opt(option::t<@ast_node>); l_bool(bool); l_ident(ident); l_fn_ident(fn_ident); @@ -44,8 +44,8 @@ tag ast_node { l_attr_style; // these could be avoided, at the cost of making #br_* more convoluted - l_optional_filename(option::t[filename]); - l_optional_string(option::t[str]); + l_optional_filename(option::t<filename>); + l_optional_string(option::t<str>); l_seq_ident(ident[]); l_seq_ty_param(ty_param[]); @@ -245,7 +245,7 @@ type ctx = { /** Type of failure function: to be invoked if typification fails. It's hopefully a bug for this to be invoked without a span. */ -type ff = fn(sp: option::t[span], msg: str) -> !; +type ff = fn(sp: option::t<span>, msg: str) -> !; fn dummy() { @@ -384,8 +384,8 @@ fn seq_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] { + -> fn (&ctx, @ast_node) -> option::t<T> { + ret lambda(ctx: &ctx, ut: @ast_node) -> option::t<T> { ret alt *ut { i_opt(ut_maybe) { option::map(bind conversion(ctx, _), ut_maybe) } branch(_, sp, _) { diff --git a/src/comp/syntax/util/interner.rs b/src/comp/syntax/util/interner.rs index 3dbda76f5d9..b0838d5329d 100644 --- a/src/comp/syntax/util/interner.rs +++ b/src/comp/syntax/util/interner.rs @@ -11,17 +11,17 @@ import std::option::none; import std::option::some; type interner[T] = - {map: hashmap[T, uint], + {map: hashmap<T, uint>, mutable vect: [T], - hasher: hashfn[T], - eqer: eqfn[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); } diff --git a/src/comp/syntax/visit.rs b/src/comp/syntax/visit.rs index 2f259ddcc30..8f4323e5c17 100644 --- a/src/comp/syntax/visit.rs +++ b/src/comp/syntax/visit.rs @@ -14,28 +14,28 @@ 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] = // takes the components so that one function can be // generic over constr and ty_constr - @{visit_mod: fn(&_mod, &span, &E, &vt[E]) , - visit_view_item: fn(&@view_item, &E, &vt[E]) , - visit_native_item: fn(&@native_item, &E, &vt[E]) , - visit_item: fn(&@item, &E, &vt[E]) , - visit_local: fn(&@local, &E, &vt[E]) , - visit_block: fn(&ast::blk, &E, &vt[E]) , - visit_stmt: fn(&@stmt, &E, &vt[E]) , - visit_arm: fn(&arm, &E, &vt[E]) , - visit_pat: fn(&@pat, &E, &vt[E]) , - visit_decl: fn(&@decl, &E, &vt[E]) , - visit_expr: fn(&@expr, &E, &vt[E]) , - visit_ty: fn(&@ty, &E, &vt[E]) , - visit_constr: fn(&path, &span, node_id, &E, &vt[E]) , + @{visit_mod: fn(&_mod, &span, &E, &vt<E>), + visit_view_item: fn(&@view_item, &E, &vt<E>), + visit_native_item: fn(&@native_item, &E, &vt<E>), + visit_item: fn(&@item, &E, &vt<E>), + visit_local: fn(&@local, &E, &vt<E>), + visit_block: fn(&ast::blk, &E, &vt<E>), + visit_stmt: fn(&@stmt, &E, &vt<E>), + visit_arm: fn(&arm, &E, &vt<E>), + visit_pat: fn(&@pat, &E, &vt<E>), + visit_decl: fn(&@decl, &E, &vt<E>), + visit_expr: fn(&@expr, &E, &vt<E>), + visit_ty: fn(&@ty, &E, &vt<E>), + visit_constr: fn(&path, &span, node_id, &E, &vt<E>), visit_fn: - fn(&_fn, &[ty_param], &span, &fn_ident, node_id, &E, &vt[E]) }; + 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 */ } @@ -153,7 +153,7 @@ fn visit_ty[E](t: &@ty, e: &E, v: &vt[E]) { ty_type. {/* no-op */ } ty_constr(t, cs) { v.visit_ty(t, e, v); - for tc: @spanned[constr_general_[path, node_id]] in cs { + for tc: @spanned<constr_general_<path, node_id>> in cs { v.visit_constr(tc.node.path, tc.span, tc.node.id, e, v); } } @@ -162,11 +162,11 @@ fn visit_ty[E](t: &@ty, e: &E, v: &vt[E]) { } fn visit_constr[E](operator: &path, sp: &span, id: node_id, e: &E, - v: &vt[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); @@ -199,17 +199,17 @@ fn visit_fn_decl[E](fd: &fn_decl, e: &E, v: &vt[E]) { } fn visit_fn[E](f: &_fn, tp: &[ty_param], sp: &span, i: &fn_ident, id: node_id, - e: &E, v: &vt[E]) { + 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) { @@ -260,7 +260,7 @@ fn visit_expr[E](ex: &@expr, e: &E, v: &vt[E]) { expr_self_method(_) { } expr_bind(callee, args) { v.visit_expr(callee, e, v); - for eo: option::t[@expr] in args { visit_expr_opt(eo, e, v); } + for eo: option::t<@expr> in args { visit_expr_opt(eo, e, v); } } expr_binary(_, a, b) { v.visit_expr(a, e, v); v.visit_expr(b, e, v); } expr_unary(_, a) { v.visit_expr(a, e, v); } @@ -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); } @@ -384,64 +384,64 @@ fn default_simple_visitor() -> simple_visitor { }}; } -fn mk_simple_visitor(v: &simple_visitor) -> vt[()] { - fn v_mod(f: fn(&_mod, &span) , m: &_mod, sp: &span, e: &(), v: &vt[()]) { +fn mk_simple_visitor(v: &simple_visitor) -> vt<()> { + fn v_mod(f: fn(&_mod, &span) , m: &_mod, sp: &span, e: &(), v: &vt<()>) { f(m, sp); visit_mod(m, sp, e, v); } - fn v_view_item(f: fn(&@view_item) , vi: &@view_item, e: &(), v: &vt[()]) { + fn v_view_item(f: fn(&@view_item) , vi: &@view_item, e: &(), v: &vt<()>) { f(vi); visit_view_item(vi, e, v); } fn v_native_item(f: fn(&@native_item) , ni: &@native_item, e: &(), - v: &vt[()]) { + v: &vt<()>) { f(ni); visit_native_item(ni, e, v); } - fn v_item(f: fn(&@item) , i: &@item, e: &(), v: &vt[()]) { + fn v_item(f: fn(&@item) , i: &@item, e: &(), v: &vt<()>) { f(i); visit_item(i, e, v); } - fn v_local(f: fn(&@local) , l: &@local, e: &(), v: &vt[()]) { + fn v_local(f: fn(&@local) , l: &@local, e: &(), v: &vt<()>) { f(l); visit_local(l, e, v); } - fn v_block(f: fn(&ast::blk) , bl: &ast::blk, e: &(), v: &vt[()]) { + fn v_block(f: fn(&ast::blk) , bl: &ast::blk, e: &(), v: &vt<()>) { f(bl); visit_block(bl, e, v); } - fn v_stmt(f: fn(&@stmt) , st: &@stmt, e: &(), v: &vt[()]) { + fn v_stmt(f: fn(&@stmt) , st: &@stmt, e: &(), v: &vt<()>) { f(st); visit_stmt(st, e, v); } - fn v_arm(f: fn(&arm) , a: &arm, e: &(), v: &vt[()]) { + fn v_arm(f: fn(&arm) , a: &arm, e: &(), v: &vt<()>) { f(a); visit_arm(a, e, v); } - fn v_pat(f: fn(&@pat) , p: &@pat, e: &(), v: &vt[()]) { + fn v_pat(f: fn(&@pat) , p: &@pat, e: &(), v: &vt<()>) { f(p); visit_pat(p, e, v); } - fn v_decl(f: fn(&@decl) , d: &@decl, e: &(), v: &vt[()]) { + fn v_decl(f: fn(&@decl) , d: &@decl, e: &(), v: &vt<()>) { f(d); visit_decl(d, e, v); } - fn v_expr(f: fn(&@expr) , ex: &@expr, e: &(), v: &vt[()]) { + fn v_expr(f: fn(&@expr) , ex: &@expr, e: &(), v: &vt<()>) { f(ex); visit_expr(ex, e, v); } - fn v_ty(f: fn(&@ty) , ty: &@ty, e: &(), v: &vt[()]) { + fn v_ty(f: fn(&@ty) , ty: &@ty, e: &(), v: &vt<()>) { f(ty); visit_ty(ty, e, v); } fn v_constr(f: fn(&path, &span, node_id) , pt: &path, sp: &span, - id: node_id, e: &(), v: &vt[()]) { + id: node_id, e: &(), v: &vt<()>) { f(pt, sp, id); visit_constr(pt, sp, id, e, v); } fn v_fn(f: fn(&_fn, &[ty_param], &span, &fn_ident, node_id) , ff: &_fn, tps: &[ty_param], sp: &span, ident: &fn_ident, id: node_id, - e: &(), v: &vt[()]) { + e: &(), v: &vt<()>) { f(ff, tps, sp, ident, id); visit_fn(ff, tps, sp, ident, id, e, v); } |
