Make fn denote a bare function. Convert fn to fn@ as needed
This commit is contained in:
parent
f324704c0a
commit
29ad3bdb10
64 changed files with 263 additions and 248 deletions
|
|
@ -6,10 +6,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);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import syntax::ext::base::*;
|
|||
|
||||
|
||||
fn expand_expr(exts: hashmap<str, syntax_extension>, cx: ext_ctxt, e: expr_,
|
||||
fld: ast_fold, orig: fn(expr_, ast_fold) -> expr_) -> expr_ {
|
||||
fld: ast_fold, orig: fn@(expr_, ast_fold) -> expr_) -> expr_ {
|
||||
ret alt e {
|
||||
expr_mac(mac) {
|
||||
alt mac.node {
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ fn match_error(cx: ext_ctxt, m: matchable, expected: str) -> ! {
|
|||
// 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 selector = fn(matchable) -> match_result;
|
||||
type selector = fn@(matchable) -> match_result;
|
||||
|
||||
fn elts_to_ell(cx: ext_ctxt, elts: [@expr]) ->
|
||||
{pre: [@expr], rep: option::t<@expr>, post: [@expr]} {
|
||||
|
|
@ -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 {
|
||||
|
|
@ -263,7 +263,7 @@ iter free_vars(b: bindings, e: @expr) -> ident {
|
|||
|
||||
/* handle sequences (anywhere in the AST) of exprs, either real or ...ed */
|
||||
fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
|
||||
recur: fn(&&@expr) -> @expr, exprs: [@expr]) -> [@expr] {
|
||||
recur: fn@(&&@expr) -> @expr, exprs: [@expr]) -> [@expr] {
|
||||
alt elts_to_ell(cx, exprs) {
|
||||
{pre: pre, rep: repeat_me_maybe, post: post} {
|
||||
let res = vec::map(recur, pre);
|
||||
|
|
@ -351,7 +351,7 @@ fn transcribe_path(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
|
|||
|
||||
fn transcribe_expr(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
|
||||
e: ast::expr_, fld: ast_fold,
|
||||
orig: fn(ast::expr_, ast_fold) -> ast::expr_) ->
|
||||
orig: fn@(ast::expr_, ast_fold) -> ast::expr_) ->
|
||||
ast::expr_ {
|
||||
ret alt e {
|
||||
expr_path(p) {
|
||||
|
|
@ -378,7 +378,7 @@ fn transcribe_expr(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
|
|||
|
||||
fn transcribe_type(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
|
||||
t: ast::ty_, fld: ast_fold,
|
||||
orig: fn(ast::ty_, ast_fold) -> ast::ty_) -> ast::ty_ {
|
||||
orig: fn@(ast::ty_, ast_fold) -> ast::ty_) -> ast::ty_ {
|
||||
ret alt t {
|
||||
ast::ty_path(pth, _) {
|
||||
alt path_to_ident(pth) {
|
||||
|
|
@ -402,7 +402,7 @@ fn transcribe_type(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
|
|||
|
||||
fn transcribe_block(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
|
||||
blk: blk_, fld: ast_fold,
|
||||
orig: fn(blk_, ast_fold) -> blk_) -> blk_ {
|
||||
orig: fn@(blk_, ast_fold) -> blk_) -> blk_ {
|
||||
ret alt block_to_ident(blk) {
|
||||
some(id) {
|
||||
alt follow_for_trans(cx, b.find(id), idx_path) {
|
||||
|
|
|
|||
|
|
@ -20,58 +20,59 @@ type ast_fold = @mutable a_f;
|
|||
|
||||
type ast_fold_precursor =
|
||||
//unlike the others, item_ is non-trivial
|
||||
{fold_crate: fn(crate_, ast_fold) -> crate_,
|
||||
fold_crate_directive: fn(crate_directive_, ast_fold) -> crate_directive_,
|
||||
fold_view_item: fn(view_item_, ast_fold) -> view_item_,
|
||||
fold_native_item: fn(&&@native_item, ast_fold) -> @native_item,
|
||||
fold_item: fn(&&@item, ast_fold) -> @item,
|
||||
fold_item_underscore: fn(item_, ast_fold) -> item_,
|
||||
fold_method: fn(method_, ast_fold) -> method_,
|
||||
fold_block: fn(blk_, ast_fold) -> blk_,
|
||||
fold_stmt: fn(stmt_, ast_fold) -> stmt_,
|
||||
fold_arm: fn(arm, ast_fold) -> arm,
|
||||
fold_pat: fn(pat_, ast_fold) -> pat_,
|
||||
fold_decl: fn(decl_, ast_fold) -> decl_,
|
||||
fold_expr: fn(expr_, ast_fold) -> expr_,
|
||||
fold_ty: fn(ty_, ast_fold) -> ty_,
|
||||
fold_constr: fn(ast::constr_, ast_fold) -> constr_,
|
||||
fold_fn: fn(_fn, ast_fold) -> _fn,
|
||||
fold_mod: fn(_mod, ast_fold) -> _mod,
|
||||
fold_native_mod: fn(native_mod, ast_fold) -> native_mod,
|
||||
fold_variant: fn(variant_, ast_fold) -> variant_,
|
||||
fold_ident: fn(&&ident, ast_fold) -> ident,
|
||||
fold_path: fn(path_, ast_fold) -> path_,
|
||||
fold_local: fn(local_, ast_fold) -> local_,
|
||||
map_exprs: fn(fn(&&@expr) -> @expr, [@expr]) -> [@expr],
|
||||
new_id: fn(node_id) -> node_id,
|
||||
new_span: fn(span) -> span};
|
||||
{fold_crate: fn@(crate_, ast_fold) -> crate_,
|
||||
fold_crate_directive: fn@(crate_directive_,
|
||||
ast_fold) -> crate_directive_,
|
||||
fold_view_item: fn@(view_item_, ast_fold) -> view_item_,
|
||||
fold_native_item: fn@(&&@native_item, ast_fold) -> @native_item,
|
||||
fold_item: fn@(&&@item, ast_fold) -> @item,
|
||||
fold_item_underscore: fn@(item_, ast_fold) -> item_,
|
||||
fold_method: fn@(method_, ast_fold) -> method_,
|
||||
fold_block: fn@(blk_, ast_fold) -> blk_,
|
||||
fold_stmt: fn@(stmt_, ast_fold) -> stmt_,
|
||||
fold_arm: fn@(arm, ast_fold) -> arm,
|
||||
fold_pat: fn@(pat_, ast_fold) -> pat_,
|
||||
fold_decl: fn@(decl_, ast_fold) -> decl_,
|
||||
fold_expr: fn@(expr_, ast_fold) -> expr_,
|
||||
fold_ty: fn@(ty_, ast_fold) -> ty_,
|
||||
fold_constr: fn@(ast::constr_, ast_fold) -> constr_,
|
||||
fold_fn: fn@(_fn, ast_fold) -> _fn,
|
||||
fold_mod: fn@(_mod, ast_fold) -> _mod,
|
||||
fold_native_mod: fn@(native_mod, ast_fold) -> native_mod,
|
||||
fold_variant: fn@(variant_, ast_fold) -> variant_,
|
||||
fold_ident: fn@(&&ident, ast_fold) -> ident,
|
||||
fold_path: fn@(path_, ast_fold) -> path_,
|
||||
fold_local: fn@(local_, ast_fold) -> local_,
|
||||
map_exprs: fn@(fn@(&&@expr) -> @expr, [@expr]) -> [@expr],
|
||||
new_id: fn@(node_id) -> node_id,
|
||||
new_span: fn@(span) -> span};
|
||||
|
||||
type a_f =
|
||||
{fold_crate: fn(crate) -> crate,
|
||||
fold_crate_directive: fn(&&@crate_directive) -> @crate_directive,
|
||||
fold_view_item: fn(&&@view_item) -> @view_item,
|
||||
fold_native_item: fn(&&@native_item) -> @native_item,
|
||||
fold_item: fn(&&@item) -> @item,
|
||||
fold_item_underscore: fn(item_) -> item_,
|
||||
fold_method: fn(&&@method) -> @method,
|
||||
fold_block: fn(blk) -> blk,
|
||||
fold_stmt: fn(&&@stmt) -> @stmt,
|
||||
fold_arm: fn(arm) -> arm,
|
||||
fold_pat: fn(&&@pat) -> @pat,
|
||||
fold_decl: fn(&&@decl) -> @decl,
|
||||
fold_expr: fn(&&@expr) -> @expr,
|
||||
fold_ty: fn(&&@ty) -> @ty,
|
||||
fold_constr: fn(&&@constr) -> @constr,
|
||||
fold_fn: fn(_fn) -> _fn,
|
||||
fold_mod: fn(_mod) -> _mod,
|
||||
fold_native_mod: fn(native_mod) -> native_mod,
|
||||
fold_variant: fn(variant) -> variant,
|
||||
fold_ident: fn(&&ident) -> ident,
|
||||
fold_path: fn(path) -> path,
|
||||
fold_local: fn(&&@local) -> @local,
|
||||
map_exprs: fn(fn(&&@expr) -> @expr, [@expr]) -> [@expr],
|
||||
new_id: fn(node_id) -> node_id,
|
||||
new_span: fn(span) -> span};
|
||||
{fold_crate: fn@(crate) -> crate,
|
||||
fold_crate_directive: fn@(&&@crate_directive) -> @crate_directive,
|
||||
fold_view_item: fn@(&&@view_item) -> @view_item,
|
||||
fold_native_item: fn@(&&@native_item) -> @native_item,
|
||||
fold_item: fn@(&&@item) -> @item,
|
||||
fold_item_underscore: fn@(item_) -> item_,
|
||||
fold_method: fn@(&&@method) -> @method,
|
||||
fold_block: fn@(blk) -> blk,
|
||||
fold_stmt: fn@(&&@stmt) -> @stmt,
|
||||
fold_arm: fn@(arm) -> arm,
|
||||
fold_pat: fn@(&&@pat) -> @pat,
|
||||
fold_decl: fn@(&&@decl) -> @decl,
|
||||
fold_expr: fn@(&&@expr) -> @expr,
|
||||
fold_ty: fn@(&&@ty) -> @ty,
|
||||
fold_constr: fn@(&&@constr) -> @constr,
|
||||
fold_fn: fn@(_fn) -> _fn,
|
||||
fold_mod: fn@(_mod) -> _mod,
|
||||
fold_native_mod: fn@(native_mod) -> native_mod,
|
||||
fold_variant: fn@(variant) -> variant,
|
||||
fold_ident: fn@(&&ident) -> ident,
|
||||
fold_path: fn@(path) -> path,
|
||||
fold_local: fn@(&&@local) -> @local,
|
||||
map_exprs: fn@(fn@(&&@expr) -> @expr, [@expr]) -> [@expr],
|
||||
new_id: fn@(node_id) -> node_id,
|
||||
new_span: fn@(span) -> span};
|
||||
|
||||
|
||||
//fn nf_dummy<T>(&T node) -> T { fail; }
|
||||
|
|
@ -119,7 +120,7 @@ fn fold_meta_item_(&&mi: @meta_item, fld: ast_fold) -> @meta_item {
|
|||
span: mi.span};
|
||||
}
|
||||
//used in noop_fold_item and noop_fold_crate
|
||||
fn fold_attribute_(at: attribute, fmi: fn(&&@meta_item) -> @meta_item) ->
|
||||
fn fold_attribute_(at: attribute, fmi: fn@(&&@meta_item) -> @meta_item) ->
|
||||
attribute {
|
||||
ret {node: {style: at.node.style, value: *fmi(@at.node.value)},
|
||||
span: at.span};
|
||||
|
|
@ -495,7 +496,7 @@ fn noop_fold_local(l: local_, fld: ast_fold) -> local_ {
|
|||
|
||||
/* 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] {
|
||||
fn noop_map_exprs(f: fn@(&&@expr) -> @expr, es: [@expr]) -> [@expr] {
|
||||
ret vec::map(f, es);
|
||||
}
|
||||
|
||||
|
|
@ -568,32 +569,34 @@ resource foldres(f: ast_fold) {
|
|||
}
|
||||
|
||||
fn make_fold(afp: ast_fold_precursor) -> @foldres {
|
||||
// FIXME: Have to bind all the bare functions into shared functions
|
||||
// because @mutable is invariant with respect to its contents
|
||||
let result: ast_fold =
|
||||
@mutable {fold_crate: nf_crate_dummy,
|
||||
fold_crate_directive: nf_crate_directive_dummy,
|
||||
fold_view_item: nf_view_item_dummy,
|
||||
fold_native_item: nf_native_item_dummy,
|
||||
fold_item: nf_item_dummy,
|
||||
fold_item_underscore: nf_item_underscore_dummy,
|
||||
fold_method: nf_method_dummy,
|
||||
fold_block: nf_blk_dummy,
|
||||
fold_stmt: nf_stmt_dummy,
|
||||
fold_arm: nf_arm_dummy,
|
||||
fold_pat: nf_pat_dummy,
|
||||
fold_decl: nf_decl_dummy,
|
||||
fold_expr: nf_expr_dummy,
|
||||
fold_ty: nf_ty_dummy,
|
||||
fold_constr: nf_constr_dummy,
|
||||
fold_fn: nf_fn_dummy,
|
||||
fold_mod: nf_mod_dummy,
|
||||
fold_native_mod: nf_native_mod_dummy,
|
||||
fold_variant: nf_variant_dummy,
|
||||
fold_ident: nf_ident_dummy,
|
||||
fold_path: nf_path_dummy,
|
||||
fold_local: nf_local_dummy,
|
||||
map_exprs: noop_map_exprs,
|
||||
new_id: noop_id,
|
||||
new_span: noop_span};
|
||||
@mutable {fold_crate: bind nf_crate_dummy(_),
|
||||
fold_crate_directive: bind nf_crate_directive_dummy(_),
|
||||
fold_view_item: bind nf_view_item_dummy(_),
|
||||
fold_native_item: bind nf_native_item_dummy(_),
|
||||
fold_item: bind nf_item_dummy(_),
|
||||
fold_item_underscore: bind nf_item_underscore_dummy(_),
|
||||
fold_method: bind nf_method_dummy(_),
|
||||
fold_block: bind nf_blk_dummy(_),
|
||||
fold_stmt: bind nf_stmt_dummy(_),
|
||||
fold_arm: bind nf_arm_dummy(_),
|
||||
fold_pat: bind nf_pat_dummy(_),
|
||||
fold_decl: bind nf_decl_dummy(_),
|
||||
fold_expr: bind nf_expr_dummy(_),
|
||||
fold_ty: bind nf_ty_dummy(_),
|
||||
fold_constr: bind nf_constr_dummy(_),
|
||||
fold_fn: bind nf_fn_dummy(_),
|
||||
fold_mod: bind nf_mod_dummy(_),
|
||||
fold_native_mod: bind nf_native_mod_dummy(_),
|
||||
fold_variant: bind nf_variant_dummy(_),
|
||||
fold_ident: bind nf_ident_dummy(_),
|
||||
fold_path: bind nf_path_dummy(_),
|
||||
fold_local: bind nf_local_dummy(_),
|
||||
map_exprs: bind noop_map_exprs(_, _),
|
||||
new_id: bind noop_id(_),
|
||||
new_span: bind noop_span(_)};
|
||||
|
||||
/* naturally, a macro to write these would be nice */
|
||||
fn f_crate(afp: ast_fold_precursor, f: ast_fold, c: crate) -> crate {
|
||||
|
|
|
|||
|
|
@ -390,7 +390,8 @@ 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 {
|
||||
|
|
@ -602,7 +603,7 @@ fn parse_fn_block_arg(p: parser) -> ast::arg {
|
|||
}
|
||||
|
||||
fn parse_seq_to_before_gt<@T>(sep: option::t<token::token>,
|
||||
f: fn(parser) -> T,
|
||||
f: fn@(parser) -> T,
|
||||
p: parser) -> [T] {
|
||||
let first = true;
|
||||
let v = [];
|
||||
|
|
@ -618,7 +619,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);
|
||||
|
|
@ -626,7 +627,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);
|
||||
|
|
@ -645,7 +646,7 @@ fn parse_seq_to_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] {
|
||||
f: fn@(parser) -> T, p: parser) -> [T] {
|
||||
let first: bool = true;
|
||||
let v: [T] = [];
|
||||
while p.peek() != ket {
|
||||
|
|
@ -660,7 +661,7 @@ fn parse_seq_to_before_end<@T>(ket: token::token,
|
|||
|
||||
|
||||
fn parse_seq<@T>(bra: token::token, ket: token::token,
|
||||
sep: option::t<token::token>, f: fn(parser) -> T, p: parser)
|
||||
sep: option::t<token::token>, f: fn@(parser) -> T, p: parser)
|
||||
-> spanned<[T]> {
|
||||
let lo = p.get_lo_pos();
|
||||
expect(p, bra);
|
||||
|
|
@ -2141,7 +2142,7 @@ fn parse_fn_item_proto(p: parser) -> ast::proto {
|
|||
p.bump();
|
||||
ast::proto_fn
|
||||
} else {
|
||||
ast::proto_fn
|
||||
ast::proto_bare
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2153,7 +2154,7 @@ fn parse_fn_ty_proto(p: parser) -> ast::proto {
|
|||
p.bump();
|
||||
ast::proto_fn
|
||||
} else {
|
||||
ast::proto_fn
|
||||
ast::proto_bare
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2165,7 +2166,7 @@ fn parse_fn_anon_proto(p: parser) -> ast::proto {
|
|||
p.bump();
|
||||
ast::proto_fn
|
||||
} else {
|
||||
ast::proto_fn
|
||||
ast::proto_bare
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2198,7 +2199,8 @@ fn parse_item(p: parser, attrs: [ast::attribute]) -> option::t<@ast::item> {
|
|||
} else if is_word(p, "unsafe") && p.look_ahead(1u) != token::LBRACE {
|
||||
p.bump();
|
||||
expect_word(p, "fn");
|
||||
ret some(parse_item_fn_or_iter(p, ast::unsafe_fn, ast::proto_fn,
|
||||
let proto = parse_fn_item_proto(p);
|
||||
ret some(parse_item_fn_or_iter(p, ast::unsafe_fn, proto,
|
||||
attrs, ast::il_normal));
|
||||
} else if eat_word(p, "iter") {
|
||||
ret some(parse_item_fn_or_iter(p, ast::impure_fn, ast::proto_iter,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ tag ann_node {
|
|||
node_expr(ps, @ast::expr);
|
||||
node_pat(ps, @ast::pat);
|
||||
}
|
||||
type pp_ann = {pre: fn(ann_node), post: fn(ann_node)};
|
||||
type pp_ann = {pre: fn@(ann_node), post: fn@(ann_node)};
|
||||
|
||||
fn no_ann() -> pp_ann {
|
||||
fn ignore(_node: ann_node) { }
|
||||
|
|
@ -352,7 +352,7 @@ fn print_native_item(s: ps, item: @ast::native_item) {
|
|||
|
||||
|
||||
ast::native_item_fn(lname, decl, typarams) {
|
||||
print_fn(s, decl, ast::proto_fn, item.ident, typarams,
|
||||
print_fn(s, decl, ast::proto_bare, item.ident, typarams,
|
||||
decl.constraints);
|
||||
alt lname {
|
||||
none. { }
|
||||
|
|
@ -1557,7 +1557,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);
|
||||
|
|
@ -1578,7 +1578,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, args: [@ast::sp_constr_arg<T>]) ->
|
||||
fn constr_args_to_str<T>(f: fn@(T) -> str, args: [@ast::sp_constr_arg<T>]) ->
|
||||
str {
|
||||
let comma = false;
|
||||
let s = "(";
|
||||
|
|
@ -1590,7 +1590,7 @@ fn constr_args_to_str<T>(f: fn(T) -> str, args: [@ast::sp_constr_arg<T>]) ->
|
|||
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 "*"; }
|
||||
|
|
@ -1643,11 +1643,11 @@ fn ast_fn_constrs_str(decl: ast::fn_decl, constrs: [@ast::constr]) -> str {
|
|||
|
||||
fn proto_to_str(p: ast::proto) -> str {
|
||||
ret alt p {
|
||||
ast::proto_fn. { "fn" }
|
||||
ast::proto_fn. { "fn@" }
|
||||
ast::proto_iter. { "iter" }
|
||||
ast::proto_block. { "block" }
|
||||
ast::proto_closure. { "lambda" }
|
||||
ast::proto_bare. { "fn#" }
|
||||
ast::proto_bare. { "fn" }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,20 +18,20 @@ 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_fn: fn(_fn, [ty_param], span, fn_ident, 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 default_visitor<E>() -> visitor<E> {
|
||||
ret @{visit_mod: bind visit_mod::<E>(_, _, _, _),
|
||||
|
|
@ -341,97 +341,97 @@ fn visit_arm<E>(a: arm, e: E, v: vt<E>) {
|
|||
type simple_visitor =
|
||||
// takes the components so that one function can be
|
||||
// generic over constr and ty_constr
|
||||
@{visit_mod: fn(_mod, span),
|
||||
visit_view_item: fn(@view_item),
|
||||
visit_native_item: fn(@native_item),
|
||||
visit_item: fn(@item),
|
||||
visit_local: fn(@local),
|
||||
visit_block: fn(ast::blk),
|
||||
visit_stmt: fn(@stmt),
|
||||
visit_arm: fn(arm),
|
||||
visit_pat: fn(@pat),
|
||||
visit_decl: fn(@decl),
|
||||
visit_expr: fn(@expr),
|
||||
visit_ty: fn(@ty),
|
||||
visit_constr: fn(path, span, node_id),
|
||||
visit_fn: fn(_fn, [ty_param], span, fn_ident, node_id)};
|
||||
@{visit_mod: fn@(_mod, span),
|
||||
visit_view_item: fn@(@view_item),
|
||||
visit_native_item: fn@(@native_item),
|
||||
visit_item: fn@(@item),
|
||||
visit_local: fn@(@local),
|
||||
visit_block: fn@(ast::blk),
|
||||
visit_stmt: fn@(@stmt),
|
||||
visit_arm: fn@(arm),
|
||||
visit_pat: fn@(@pat),
|
||||
visit_decl: fn@(@decl),
|
||||
visit_expr: fn@(@expr),
|
||||
visit_ty: fn@(@ty),
|
||||
visit_constr: fn@(path, span, node_id),
|
||||
visit_fn: fn@(_fn, [ty_param], span, fn_ident, node_id)};
|
||||
|
||||
fn default_simple_visitor() -> simple_visitor {
|
||||
ret @{visit_mod: fn (_m: _mod, _sp: span) { },
|
||||
visit_view_item: fn (_vi: @view_item) { },
|
||||
visit_native_item: fn (_ni: @native_item) { },
|
||||
visit_item: fn (_i: @item) { },
|
||||
visit_local: fn (_l: @local) { },
|
||||
visit_block: fn (_b: ast::blk) { },
|
||||
visit_stmt: fn (_s: @stmt) { },
|
||||
visit_arm: fn (_a: arm) { },
|
||||
visit_pat: fn (_p: @pat) { },
|
||||
visit_decl: fn (_d: @decl) { },
|
||||
visit_expr: fn (_e: @expr) { },
|
||||
visit_ty: fn (_t: @ty) { },
|
||||
visit_constr: fn (_p: path, _sp: span, _id: node_id) { },
|
||||
ret @{visit_mod: fn(_m: _mod, _sp: span) { },
|
||||
visit_view_item: fn(_vi: @view_item) { },
|
||||
visit_native_item: fn(_ni: @native_item) { },
|
||||
visit_item: fn(_i: @item) { },
|
||||
visit_local: fn(_l: @local) { },
|
||||
visit_block: fn(_b: ast::blk) { },
|
||||
visit_stmt: fn(_s: @stmt) { },
|
||||
visit_arm: fn(_a: arm) { },
|
||||
visit_pat: fn(_p: @pat) { },
|
||||
visit_decl: fn(_d: @decl) { },
|
||||
visit_expr: fn(_e: @expr) { },
|
||||
visit_ty: fn(_t: @ty) { },
|
||||
visit_constr: fn(_p: path, _sp: span, _id: node_id) { },
|
||||
visit_fn:
|
||||
fn (_f: _fn, _tps: [ty_param], _sp: span, _ident: fn_ident,
|
||||
fn(_f: _fn, _tps: [ty_param], _sp: span, _ident: fn_ident,
|
||||
_id: node_id) {
|
||||
}};
|
||||
}
|
||||
|
||||
fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
|
||||
fn v_mod(f: fn(_mod, span), m: _mod, sp: span, &&e: (), v: 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: (),
|
||||
fn v_native_item(f: fn@(@native_item), ni: @native_item, &&e: (),
|
||||
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,
|
||||
fn v_constr(f: fn@(path, span, node_id), pt: path, sp: span, 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,
|
||||
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<()>) {
|
||||
f(ff, tps, sp, ident, id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue