mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-13 23:42:56 +00:00
Revert "rustc: Introduce the concept of inline to the AST"
This reverts commit 9b9170f9fe
.
This commit is contained in:
parent
9b9170f9fe
commit
59e9b629c0
@ -59,7 +59,7 @@ fn fold_mod(cx: &test_ctxt, m: &ast::_mod, fld: fold::ast_fold) -> ast::_mod {
|
||||
// we want to be main.
|
||||
fn nomain(item: &@ast::item) -> option::t[@ast::item] {
|
||||
alt item.node {
|
||||
ast::item_fn(f, _, _) {
|
||||
ast::item_fn(f, _) {
|
||||
if item.ident == "main" {
|
||||
option::none
|
||||
} else { option::some(item) }
|
||||
@ -107,7 +107,7 @@ fn is_test_fn(i: &@ast::item) -> bool {
|
||||
|
||||
fn has_test_signature(i: &@ast::item) -> bool {
|
||||
alt i.node {
|
||||
ast::item_fn(f, tps, _) {
|
||||
ast::item_fn(f, tps) {
|
||||
let input_cnt = ivec::len(f.decl.inputs);
|
||||
let no_output = f.decl.output.node == ast::ty_nil;
|
||||
let tparm_cnt = ivec::len(tps);
|
||||
@ -191,7 +191,7 @@ fn mk_tests(cx: &test_ctxt) -> @ast::item {
|
||||
|
||||
let fn_ = {decl: decl, proto: proto, body: body};
|
||||
|
||||
let item_ = ast::item_fn(fn_, ~[], ast::il_normal);
|
||||
let item_ = ast::item_fn(fn_, ~[]);
|
||||
let item: ast::item =
|
||||
{ident: "tests",
|
||||
attrs: ~[],
|
||||
@ -309,7 +309,7 @@ fn mk_main(cx: &test_ctxt) -> @ast::item {
|
||||
|
||||
let fn_ = {decl: decl, proto: proto, body: body};
|
||||
|
||||
let item_ = ast::item_fn(fn_, ~[], ast::il_normal);
|
||||
let item_ = ast::item_fn(fn_, ~[]);
|
||||
let item: ast::item =
|
||||
{ident: "main",
|
||||
attrs: ~[],
|
||||
|
@ -81,7 +81,7 @@ fn encode_module_item_paths(ebml_w: &ebmlivec::writer, module: &_mod,
|
||||
encode_def_id(ebml_w, local_def(it.id));
|
||||
ebmlivec::end_tag(ebml_w);
|
||||
}
|
||||
item_fn(_, tps, _) {
|
||||
item_fn(_, tps) {
|
||||
add_to_index(ebml_w, path, index, it.ident);
|
||||
ebmlivec::start_tag(ebml_w, tag_paths_data_item);
|
||||
encode_name(ebml_w, it.ident);
|
||||
@ -250,7 +250,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: &ebmlivec::writer,
|
||||
encode_symbol(ecx, ebml_w, item.id);
|
||||
ebmlivec::end_tag(ebml_w);
|
||||
}
|
||||
item_fn(fd, tps, _) {
|
||||
item_fn(fd, tps) {
|
||||
ebmlivec::start_tag(ebml_w, tag_items_data_item);
|
||||
encode_def_id(ebml_w, local_def(item.id));
|
||||
encode_family(ebml_w,
|
||||
|
@ -4,7 +4,6 @@ import ast::ident;
|
||||
import ast::fn_ident;
|
||||
import ast::node_id;
|
||||
import ast::def_id;
|
||||
import ast::inlineness;
|
||||
import syntax::codemap::span;
|
||||
import syntax::visit;
|
||||
import visit::vt;
|
||||
@ -43,7 +42,7 @@ fn check_crate(tcx: ty::ctxt, crate: &@ast::crate) {
|
||||
// Stores information about object fields and function
|
||||
// arguments that's otherwise not easily available.
|
||||
let cx = @{tcx: tcx, local_map: std::map::new_int_hash()};
|
||||
let v = @{visit_fn: bind visit_fn(cx, _, _, _, _, _, _, _, _),
|
||||
let v = @{visit_fn: bind visit_fn(cx, _, _, _, _, _, _, _),
|
||||
visit_item: bind visit_item(cx, _, _, _),
|
||||
visit_expr: bind visit_expr(cx, _, _, _),
|
||||
visit_decl: bind visit_decl(cx, _, _, _)
|
||||
@ -52,9 +51,8 @@ fn check_crate(tcx: ty::ctxt, crate: &@ast::crate) {
|
||||
tcx.sess.abort_if_errors();
|
||||
}
|
||||
|
||||
fn visit_fn(cx: &@ctx, f: &ast::_fn, tp: &ast::ty_param[], il: inlineness,
|
||||
sp: &span, name: &fn_ident, id: ast::node_id, sc: &scope,
|
||||
v: &vt[scope]) {
|
||||
fn visit_fn(cx: &@ctx, f: &ast::_fn, tp: &ast::ty_param[], sp: &span,
|
||||
name: &fn_ident, id: ast::node_id, sc: &scope, v: &vt[scope]) {
|
||||
visit::visit_fn_decl(f.decl, sc, v);
|
||||
for arg_: ast::arg in f.decl.inputs {
|
||||
cx.local_map.insert(arg_.id, arg(arg_.mode));
|
||||
|
@ -8,7 +8,6 @@ import std::option;
|
||||
import std::int;
|
||||
import std::option::*;
|
||||
import syntax::ast;
|
||||
import syntax::ast::inlineness;
|
||||
import syntax::visit;
|
||||
import driver::session;
|
||||
import middle::resolve;
|
||||
@ -46,8 +45,8 @@ fn collect_freevars(def_map: &resolve::def_map, sess: &session::session,
|
||||
for decl: ast::node_id in initial_decls { set_add(decls, decl); }
|
||||
let refs = @mutable ~[];
|
||||
|
||||
let walk_fn = lambda(f: &ast::_fn, tps: &ast::ty_param[], il: inlineness,
|
||||
sp: &span, i: &ast::fn_ident, nid: ast::node_id) {
|
||||
let walk_fn = lambda(f: &ast::_fn, tps: &ast::ty_param[], sp: &span,
|
||||
i: &ast::fn_ident, nid: ast::node_id) {
|
||||
for a: ast::arg in f.decl.inputs { set_add(decls, a.id); }
|
||||
};
|
||||
let walk_expr = lambda(expr: &@ast::expr) {
|
||||
@ -108,10 +107,10 @@ fn annotate_freevars(sess: &session::session, def_map: &resolve::def_map,
|
||||
crate: &@ast::crate) -> freevar_map {
|
||||
let freevars = new_int_hash();
|
||||
|
||||
let walk_fn = lambda(f: &ast::_fn, tps: &ast::ty_param[], il: inlineness,
|
||||
sp: &span, i: &ast::fn_ident, nid: ast::node_id) {
|
||||
let walk_fn = lambda(f: &ast::_fn, tps: &ast::ty_param[], sp: &span,
|
||||
i: &ast::fn_ident, nid: ast::node_id) {
|
||||
let start_walk = lambda(v: &visit::vt[()]) {
|
||||
v.visit_fn(f, tps, il, sp, i, nid, (), v);
|
||||
v.visit_fn(f, tps, sp, i, nid, (), v);
|
||||
};
|
||||
let vars = collect_freevars(def_map, sess, start_walk, ~[]);
|
||||
freevars.insert(nid, vars);
|
||||
|
@ -7,7 +7,6 @@ import ast::def;
|
||||
import ast::def_id;
|
||||
import ast::node_id;
|
||||
import ast::local_def;
|
||||
import ast::inlineness;
|
||||
|
||||
import metadata::csearch;
|
||||
import metadata::cstore;
|
||||
@ -260,7 +259,7 @@ fn resolve_names(e: &@env, c: &@ast::crate) {
|
||||
visit_expr: bind walk_expr(e, _, _, _),
|
||||
visit_ty: bind walk_ty(e, _, _, _),
|
||||
visit_constr: bind walk_constr(e, _, _, _, _, _),
|
||||
visit_fn: bind visit_fn_with_scope(e, _, _, _, _, _, _, _, _)
|
||||
visit_fn: bind visit_fn_with_scope(e, _, _, _, _, _, _, _)
|
||||
with *visit::default_visitor()};
|
||||
visit::visit_crate(*c, cons(scope_crate, @nil), visit::mk_vt(v));
|
||||
e.sess.abort_if_errors();
|
||||
@ -329,8 +328,8 @@ fn visit_native_item_with_scope(ni: &@ast::native_item, sc: &scopes,
|
||||
}
|
||||
|
||||
fn visit_fn_with_scope(e: &@env, f: &ast::_fn, tp: &ast::ty_param[],
|
||||
il: inlineness, sp: &span, name: &fn_ident,
|
||||
id: node_id, sc: &scopes, v: &vt[scopes]) {
|
||||
sp: &span, name: &fn_ident, id: node_id, sc: &scopes,
|
||||
v: &vt[scopes]) {
|
||||
// is this a main fn declaration?
|
||||
alt name {
|
||||
some(nm) {
|
||||
@ -349,7 +348,7 @@ fn visit_fn_with_scope(e: &@env, f: &ast::_fn, tp: &ast::ty_param[],
|
||||
for c: @ast::constr in f.decl.constraints {
|
||||
resolve_constr(e, id, c, sc, v);
|
||||
}
|
||||
visit::visit_fn(f, tp, il, sp, name, id,
|
||||
visit::visit_fn(f, tp, sp, name, id,
|
||||
cons(scope_fn(f.decl, f.proto, tp), @sc), v);
|
||||
}
|
||||
|
||||
@ -825,7 +824,7 @@ fn found_def_item(i: &@ast::item, ns: namespace) -> option::t[def] {
|
||||
ast::item_const(_, _) {
|
||||
if ns == ns_value { ret some(ast::def_const(local_def(i.id))); }
|
||||
}
|
||||
ast::item_fn(f, _, _) {
|
||||
ast::item_fn(f, _) {
|
||||
if ns == ns_value {
|
||||
ret some(ast::def_fn(local_def(i.id), f.decl.purity));
|
||||
}
|
||||
@ -1083,7 +1082,7 @@ fn index_mod(md: &ast::_mod) -> mod_index {
|
||||
}
|
||||
for it: @ast::item in md.items {
|
||||
alt it.node {
|
||||
ast::item_const(_, _) | ast::item_fn(_, _, _) | ast::item_mod(_) |
|
||||
ast::item_const(_, _) | ast::item_fn(_, _) | ast::item_mod(_) |
|
||||
ast::item_native_mod(_) | ast::item_ty(_, _) |
|
||||
ast::item_res(_, _, _, _) | ast::item_obj(_, _, _) {
|
||||
add_to_index(index, it.ident, mie_item(it));
|
||||
@ -1219,7 +1218,7 @@ fn check_item(e: &@env, i: &@ast::item, x: &(), v: &vt[()]) {
|
||||
}
|
||||
visit::visit_item(i, x, v);
|
||||
alt i.node {
|
||||
ast::item_fn(f, ty_params, _) {
|
||||
ast::item_fn(f, ty_params) {
|
||||
check_fn(*e, i.span, f);
|
||||
ensure_unique(*e, i.span, typaram_names(ty_params),
|
||||
ident_id, "type parameter");
|
||||
@ -1303,7 +1302,7 @@ fn check_block(e: &@env, b: &ast::blk, x: &(), v: &vt[()]) {
|
||||
ast::item_mod(_) | ast::item_native_mod(_) {
|
||||
add_name(mods, it.span, it.ident);
|
||||
}
|
||||
ast::item_const(_, _) | ast::item_fn(_, _, _) {
|
||||
ast::item_const(_, _) | ast::item_fn(_, _) {
|
||||
add_name(values, it.span, it.ident);
|
||||
}
|
||||
ast::item_ty(_, _) { add_name(types, it.span, it.ident); }
|
||||
|
@ -7329,7 +7329,7 @@ fn trans_const(cx: &@crate_ctxt, e: @ast::expr, id: ast::node_id) {
|
||||
|
||||
fn trans_item(cx: @local_ctxt, item: &ast::item) {
|
||||
alt item.node {
|
||||
ast::item_fn(f, tps, _) {
|
||||
ast::item_fn(f, tps) {
|
||||
let sub_cx = extend_path(cx, item.ident);
|
||||
alt cx.ccx.item_ids.find(item.id) {
|
||||
some(llfndecl) {
|
||||
@ -7740,7 +7740,7 @@ fn collect_item_2(ccx: &@crate_ctxt, i: &@ast::item, pt: &str[],
|
||||
let new_pt = pt + item_path(i);
|
||||
visit::visit_item(i, new_pt, v);
|
||||
alt i.node {
|
||||
ast::item_fn(f, tps, _) {
|
||||
ast::item_fn(f, tps) {
|
||||
if !ccx.obj_methods.contains_key(i.id) {
|
||||
decl_fn_and_pair(ccx, i.span, new_pt, "fn", tps, i.id);
|
||||
}
|
||||
|
@ -47,15 +47,15 @@ fn collect_ids_local(l: &@local, rs: @mutable node_id[]) {
|
||||
*rs += pat_binding_ids(l.node.pat);
|
||||
}
|
||||
|
||||
fn node_ids_in_fn(f: &_fn, tps: &ty_param[], il: inlineness, sp: &span,
|
||||
i: &fn_ident, id: node_id, rs: @mutable node_id[]) {
|
||||
fn node_ids_in_fn(f: &_fn, tps: &ty_param[], sp: &span, i: &fn_ident,
|
||||
id: node_id, rs: @mutable node_id[]) {
|
||||
let collect_ids =
|
||||
visit::mk_simple_visitor(@{visit_expr: bind collect_ids_expr(_, rs),
|
||||
visit_block: bind collect_ids_block(_, rs),
|
||||
visit_stmt: bind collect_ids_stmt(_, rs),
|
||||
visit_local: bind collect_ids_local(_, rs)
|
||||
with *visit::default_simple_visitor()});
|
||||
visit::visit_fn(f, tps, il, sp, i, id, (), collect_ids);
|
||||
visit::visit_fn(f, tps, sp, i, id, (), collect_ids);
|
||||
}
|
||||
|
||||
fn init_vecs(ccx: &crate_ctxt, node_ids: &node_id[], len: uint) {
|
||||
@ -66,25 +66,24 @@ fn init_vecs(ccx: &crate_ctxt, node_ids: &node_id[], len: uint) {
|
||||
}
|
||||
|
||||
fn visit_fn(ccx: &crate_ctxt, num_constraints: uint, f: &_fn,
|
||||
tps: &ty_param[], il: inlineness, sp: &span, i: &fn_ident,
|
||||
id: node_id) {
|
||||
tps: &ty_param[], sp: &span, i: &fn_ident, id: node_id) {
|
||||
let node_ids: @mutable node_id[] = @mutable ~[];
|
||||
node_ids_in_fn(f, tps, il, sp, i, id, node_ids);
|
||||
node_ids_in_fn(f, tps, sp, i, id, node_ids);
|
||||
let node_id_vec = *node_ids;
|
||||
init_vecs(ccx, node_id_vec, num_constraints);
|
||||
}
|
||||
|
||||
fn annotate_in_fn(ccx: &crate_ctxt, f: &_fn, tps: &ty_param[], il: inlineness,
|
||||
sp: &span, i: &fn_ident, id: node_id) {
|
||||
fn annotate_in_fn(ccx: &crate_ctxt, f: &_fn, tps: &ty_param[], sp: &span,
|
||||
i: &fn_ident, id: node_id) {
|
||||
let f_info = get_fn_info(ccx, id);
|
||||
visit_fn(ccx, num_constraints(f_info), f, tps, il, sp, i, id);
|
||||
visit_fn(ccx, num_constraints(f_info), f, tps, sp, i, id);
|
||||
}
|
||||
|
||||
fn annotate_crate(ccx: &crate_ctxt, crate: &crate) {
|
||||
let do_ann =
|
||||
visit::mk_simple_visitor(@{visit_fn:
|
||||
bind annotate_in_fn(ccx, _, _, _, _, _, _)
|
||||
with *visit::default_simple_visitor()});
|
||||
bind annotate_in_fn(ccx, _, _, _, _, _)
|
||||
with *visit::default_simple_visitor()});
|
||||
visit::visit_crate(crate, (), do_ann);
|
||||
}
|
||||
//
|
||||
|
@ -1051,8 +1051,8 @@ fn op_to_oper_ty(io: init_op) -> oper_type {
|
||||
}
|
||||
|
||||
// default function visitor
|
||||
fn do_nothing[T](f: &_fn, tp: &ty_param[], il: inlineness, sp: &span,
|
||||
i: &fn_ident, iid: node_id, cx: &T, v: &visit::vt[T]) {
|
||||
fn do_nothing[T](f: &_fn, tp: &ty_param[], sp: &span, i: &fn_ident,
|
||||
iid: node_id, cx: &T, v: &visit::vt[T]) {
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,7 +17,6 @@ import ast::crate;
|
||||
import ast::return;
|
||||
import ast::noreturn;
|
||||
import ast::expr;
|
||||
import ast::inlineness;
|
||||
import syntax::visit;
|
||||
import syntax::codemap::span;
|
||||
import middle::ty::type_is_nil;
|
||||
@ -126,8 +125,8 @@ fn check_states_stmt(s: &@stmt, fcx: &fn_ctxt, v: &visit::vt[fn_ctxt]) {
|
||||
}
|
||||
|
||||
fn check_states_against_conditions(fcx: &fn_ctxt, f: &_fn,
|
||||
tps: &ast::ty_param[], il: inlineness,
|
||||
id: node_id, sp: &span, i: &fn_ident) {
|
||||
tps: &ast::ty_param[], id: node_id,
|
||||
sp: &span, i: &fn_ident) {
|
||||
/* Postorder traversal instead of pre is important
|
||||
because we want the smallest possible erroneous statement
|
||||
or expression. */
|
||||
@ -138,7 +137,7 @@ fn check_states_against_conditions(fcx: &fn_ctxt, f: &_fn,
|
||||
@{visit_stmt: check_states_stmt,
|
||||
visit_expr: check_states_expr,
|
||||
visit_fn: do_nothing with *visitor};
|
||||
visit::visit_fn(f, tps, il, sp, i, id, fcx, visit::mk_vt(visitor));
|
||||
visit::visit_fn(f, tps, sp, i, id, fcx, visit::mk_vt(visitor));
|
||||
|
||||
/* Check that the return value is initialized */
|
||||
let post = aux::block_poststate(fcx.ccx, f.body);
|
||||
@ -171,8 +170,8 @@ fn check_states_against_conditions(fcx: &fn_ctxt, f: &_fn,
|
||||
check_unused_vars(fcx);
|
||||
}
|
||||
|
||||
fn check_fn_states(fcx: &fn_ctxt, f: &_fn, tps: &ast::ty_param[],
|
||||
il: inlineness, id: node_id, sp: &span, i: &fn_ident) {
|
||||
fn check_fn_states(fcx: &fn_ctxt, f: &_fn, tps: &ast::ty_param[], id: node_id,
|
||||
sp: &span, i: &fn_ident) {
|
||||
/* Compute the pre- and post-states for this function */
|
||||
|
||||
// Fixpoint iteration
|
||||
@ -181,20 +180,19 @@ fn check_fn_states(fcx: &fn_ctxt, f: &_fn, tps: &ast::ty_param[],
|
||||
/* Now compare each expr's pre-state to its precondition
|
||||
and post-state to its postcondition */
|
||||
|
||||
check_states_against_conditions(fcx, f, tps, il, id, sp, i);
|
||||
check_states_against_conditions(fcx, f, tps, id, sp, i);
|
||||
}
|
||||
|
||||
fn fn_states(f: &_fn, tps: &ast::ty_param[], il: inlineness, sp: &span,
|
||||
i: &fn_ident, id: node_id, ccx: &crate_ctxt,
|
||||
v: &visit::vt[crate_ctxt]) {
|
||||
visit::visit_fn(f, tps, il, sp, i, id, ccx, v);
|
||||
fn fn_states(f: &_fn, tps: &ast::ty_param[], sp: &span, i: &fn_ident,
|
||||
id: node_id, ccx: &crate_ctxt, v: &visit::vt[crate_ctxt]) {
|
||||
visit::visit_fn(f, tps, sp, i, id, ccx, v);
|
||||
/* Look up the var-to-bit-num map for this function */
|
||||
|
||||
assert (ccx.fm.contains_key(id));
|
||||
let f_info = ccx.fm.get(id);
|
||||
let name = option::from_maybe("anon", i);
|
||||
let fcx = {enclosing: f_info, id: id, name: name, ccx: ccx};
|
||||
check_fn_states(fcx, f, tps, il, id, sp, i);
|
||||
check_fn_states(fcx, f, tps, id, sp, i);
|
||||
}
|
||||
|
||||
fn check_crate(cx: ty::ctxt, crate: @crate) {
|
||||
|
@ -43,8 +43,8 @@ fn collect_pred(e: &@expr, cx: &ctxt, v: &visit::vt[ctxt]) {
|
||||
visit::visit_expr(e, cx, v);
|
||||
}
|
||||
|
||||
fn find_locals(tcx: &ty::ctxt, f: &_fn, tps: &ty_param[], il: inlineness,
|
||||
sp: &span, i: &fn_ident, id: node_id) -> ctxt {
|
||||
fn find_locals(tcx: &ty::ctxt, f: &_fn, tps: &ty_param[], sp: &span,
|
||||
i: &fn_ident, id: node_id) -> ctxt {
|
||||
let cx: ctxt = {cs: @mutable ~[], tcx: tcx};
|
||||
let visitor = visit::default_visitor[ctxt]();
|
||||
|
||||
@ -52,7 +52,7 @@ fn find_locals(tcx: &ty::ctxt, f: &_fn, tps: &ty_param[], il: inlineness,
|
||||
@{visit_local: collect_local,
|
||||
visit_expr: collect_pred,
|
||||
visit_fn: do_nothing with *visitor};
|
||||
visit::visit_fn(f, tps, il, sp, i, id, cx, visit::mk_vt(visitor));
|
||||
visit::visit_fn(f, tps, sp, i, id, cx, visit::mk_vt(visitor));
|
||||
ret cx;
|
||||
}
|
||||
|
||||
@ -88,13 +88,13 @@ fn add_constraint(tcx: &ty::ctxt, c: sp_constr, next: uint, tbl: constr_map)
|
||||
|
||||
/* builds a table mapping each local var defined in f
|
||||
to a bit number in the precondition/postcondition vectors */
|
||||
fn mk_fn_info(ccx: &crate_ctxt, f: &_fn, tp: &ty_param[], il: inlineness,
|
||||
f_sp: &span, f_name: &fn_ident, id: node_id) {
|
||||
fn mk_fn_info(ccx: &crate_ctxt, f: &_fn, tp: &ty_param[], f_sp: &span,
|
||||
f_name: &fn_ident, id: node_id) {
|
||||
let name = fn_ident_to_string(id, f_name);
|
||||
let res_map = @new_def_hash[constraint]();
|
||||
let next: uint = 0u;
|
||||
|
||||
let cx: ctxt = find_locals(ccx.tcx, f, tp, il, f_sp, f_name, id);
|
||||
let cx: ctxt = find_locals(ccx.tcx, f, tp, f_sp, f_name, id);
|
||||
/* now we have to add bit nums for both the constraints
|
||||
and the variables... */
|
||||
|
||||
@ -144,7 +144,7 @@ fn mk_fn_info(ccx: &crate_ctxt, f: &_fn, tp: &ty_param[], il: inlineness,
|
||||
fn mk_f_to_fn_info(ccx: &crate_ctxt, c: @crate) {
|
||||
let visitor =
|
||||
visit::mk_simple_visitor(@{visit_fn:
|
||||
bind mk_fn_info(ccx, _, _, _, _, _, _)
|
||||
bind mk_fn_info(ccx, _, _, _, _, _)
|
||||
with *visit::default_simple_visitor()});
|
||||
visit::visit_crate(*c, (), visitor);
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ fn find_pre_post_item(ccx: &crate_ctxt, i: &item) {
|
||||
ccx: ccx};
|
||||
find_pre_post_expr(fake_fcx, e);
|
||||
}
|
||||
item_fn(f, _, _) {
|
||||
item_fn(f, _) {
|
||||
assert (ccx.fm.contains_key(i.id));
|
||||
let fcx =
|
||||
{enclosing: ccx.fm.get(i.id), id: i.id, name: i.ident, ccx: ccx};
|
||||
@ -709,10 +709,9 @@ fn find_pre_post_fn(fcx: &fn_ctxt, f: &_fn) {
|
||||
}
|
||||
}
|
||||
|
||||
fn fn_pre_post(f: &_fn, tps: &ty_param[], il: inlineness, sp: &span,
|
||||
i: &fn_ident, id: node_id, ccx: &crate_ctxt,
|
||||
v: &visit::vt[crate_ctxt]) {
|
||||
visit::visit_fn(f, tps, il, sp, i, id, ccx, v);
|
||||
fn fn_pre_post(f: &_fn, tps: &ty_param[], sp: &span, i: &fn_ident,
|
||||
id: node_id, ccx: &crate_ctxt, v: &visit::vt[crate_ctxt]) {
|
||||
visit::visit_fn(f, tps, sp, i, id, ccx, v);
|
||||
assert (ccx.fm.contains_key(id));
|
||||
let fcx =
|
||||
{enclosing: ccx.fm.get(id),
|
||||
|
@ -1,6 +1,5 @@
|
||||
import syntax::ast;
|
||||
import ast::mutability;
|
||||
import ast::inlineness;
|
||||
import ast::local_def;
|
||||
import ast::respan;
|
||||
import ast::spanned;
|
||||
@ -648,7 +647,7 @@ mod collect {
|
||||
cx.tcx.tcache.insert(local_def(it.id), tpt);
|
||||
ret tpt;
|
||||
}
|
||||
ast::item_fn(fn_info, tps, _) {
|
||||
ast::item_fn(fn_info, tps) {
|
||||
let f = bind ty_of_arg(cx, _);
|
||||
ret ty_of_fn_decl(cx, convert, f, fn_info.decl, fn_info.proto,
|
||||
tps, some(local_def(it.id)));
|
||||
@ -1297,8 +1296,8 @@ 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[], il: inlineness,
|
||||
sp: &span, i: &ast::fn_ident, id: ast::node_id, e: &E,
|
||||
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]) { }
|
||||
|
||||
@ -2704,7 +2703,7 @@ fn check_method(ccx: &@crate_ctxt, method: &@ast::method) {
|
||||
fn check_item(ccx: @crate_ctxt, it: &@ast::item) {
|
||||
alt it.node {
|
||||
ast::item_const(_, e) { check_const(ccx, it.span, e, it.id); }
|
||||
ast::item_fn(f, _, _) { check_fn(ccx, f, it.id, none); }
|
||||
ast::item_fn(f, _) { check_fn(ccx, f, it.id, none); }
|
||||
ast::item_res(f, dtor_id, _, _) { check_fn(ccx, f, dtor_id, none); }
|
||||
ast::item_obj(ob, _, _) {
|
||||
// We're entering an object, so gather up the info we need.
|
||||
|
@ -604,11 +604,9 @@ type attribute_ = {style: attr_style, value: meta_item};
|
||||
type item = // For objs and resources, this is the type def_id
|
||||
{ident: ident, attrs: attribute[], id: node_id, node: item_, span: span};
|
||||
|
||||
tag inlineness { il_normal; il_inline; }
|
||||
|
||||
tag item_ {
|
||||
item_const(@ty, @expr);
|
||||
item_fn(_fn, ty_param[], inlineness);
|
||||
item_fn(_fn, ty_param[]);
|
||||
item_mod(_mod);
|
||||
item_native_mod(native_mod);
|
||||
item_ty(@ty, ty_param[]);
|
||||
|
@ -223,7 +223,7 @@ fn noop_fold_item_underscore(i: &item_, fld: ast_fold) -> item_ {
|
||||
|
||||
ret alt i {
|
||||
item_const(t, e) { item_const(fld.fold_ty(t), fld.fold_expr(e)) }
|
||||
item_fn(f, typms, il) { item_fn(fld.fold_fn(f), typms, il) }
|
||||
item_fn(f, typms) { item_fn(fld.fold_fn(f), typms) }
|
||||
item_mod(m) { item_mod(fld.fold_mod(m)) }
|
||||
item_native_mod(nm) { item_native_mod(fld.fold_native_mod(nm)) }
|
||||
item_ty(t, typms) { item_ty(fld.fold_ty(t), typms) }
|
||||
|
@ -1769,8 +1769,8 @@ fn parse_item_fn_or_iter(p: &parser, purity: ast::purity, proto: ast::proto,
|
||||
let lo = p.get_last_lo_pos();
|
||||
let t = parse_fn_header(p);
|
||||
let f = parse_fn(p, proto, purity);
|
||||
ret mk_item(p, lo, f.body.span.hi, t.ident,
|
||||
ast::item_fn(f, t.tps, ast::il_normal), attrs);
|
||||
ret mk_item(p, lo, f.body.span.hi, t.ident, ast::item_fn(f, t.tps),
|
||||
attrs);
|
||||
}
|
||||
|
||||
fn parse_obj_field(p: &parser) -> ast::obj_field {
|
||||
|
@ -412,7 +412,7 @@ fn print_item(s: &ps, item: &@ast::item) {
|
||||
end(s); // end the outer cbox
|
||||
|
||||
}
|
||||
ast::item_fn(_fn, typarams, _) {
|
||||
ast::item_fn(_fn, typarams) {
|
||||
print_fn(s, _fn.decl, _fn.proto, item.ident, typarams,
|
||||
_fn.decl.constraints);
|
||||
word(s.s, " ");
|
||||
|
@ -33,9 +33,7 @@ type visitor[E] =
|
||||
visit_ty: fn(&@ty, &E, &vt[E]) ,
|
||||
visit_constr: fn(&path, &span, node_id, &E, &vt[E]) ,
|
||||
visit_fn:
|
||||
fn(&_fn, &ty_param[], inlineness, &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] {
|
||||
ret @{visit_mod: bind visit_mod[E](_, _, _, _),
|
||||
@ -51,7 +49,7 @@ fn default_visitor[E]() -> visitor[E] {
|
||||
visit_expr: bind visit_expr[E](_, _, _),
|
||||
visit_ty: bind visit_ty[E](_, _, _),
|
||||
visit_constr: bind visit_constr[E](_, _, _, _, _),
|
||||
visit_fn: bind visit_fn[E](_, _, _, _, _, _, _, _)};
|
||||
visit_fn: bind visit_fn[E](_, _, _, _, _, _, _)};
|
||||
}
|
||||
|
||||
fn visit_crate[E](c: &crate, e: &E, v: &vt[E]) {
|
||||
@ -88,9 +86,7 @@ fn visit_local[E](loc: &@local, 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, il) {
|
||||
v.visit_fn(f, tp, il, i.span, some(i.ident), i.id, e, v);
|
||||
}
|
||||
item_fn(f, tp) { v.visit_fn(f, tp, i.span, some(i.ident), i.id, e, v); }
|
||||
item_mod(m) { v.visit_mod(m, i.span, e, v); }
|
||||
item_native_mod(nm) {
|
||||
for vi: @view_item in nm.view_items { v.visit_view_item(vi, e, v); }
|
||||
@ -98,7 +94,7 @@ fn visit_item[E](i: &@item, e: &E, v: &vt[E]) {
|
||||
}
|
||||
item_ty(t, _) { v.visit_ty(t, e, v); }
|
||||
item_res(f, dtor_id, tps, _) {
|
||||
v.visit_fn(f, tps, il_normal, i.span, some(i.ident), dtor_id, e, v);
|
||||
v.visit_fn(f, tps, i.span, some(i.ident), dtor_id, e, v);
|
||||
}
|
||||
item_tag(variants, _) {
|
||||
for vr: variant in variants {
|
||||
@ -108,8 +104,8 @@ fn visit_item[E](i: &@item, e: &E, v: &vt[E]) {
|
||||
item_obj(ob, _, _) {
|
||||
for f: obj_field in ob.fields { v.visit_ty(f.ty, e, v); }
|
||||
for m: @method in ob.methods {
|
||||
v.visit_fn(m.node.meth, ~[], il_normal, m.span,
|
||||
some(m.node.ident), m.node.id, e, v);
|
||||
v.visit_fn(m.node.meth, ~[], m.span, some(m.node.ident),
|
||||
m.node.id, e, v);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -199,8 +195,8 @@ 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[], il: inlineness, sp: &span,
|
||||
i: &fn_ident, id: node_id, 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]) {
|
||||
visit_fn_decl(f.decl, e, v);
|
||||
v.visit_block(f.body, e, v);
|
||||
}
|
||||
@ -294,9 +290,7 @@ fn visit_expr[E](ex: &@expr, e: &E, v: &vt[E]) {
|
||||
v.visit_expr(x, e, v);
|
||||
for a: arm in arms { v.visit_arm(a, e, v); }
|
||||
}
|
||||
expr_fn(f) {
|
||||
v.visit_fn(f, ~[], il_normal, ex.span, none, ex.id, e, v);
|
||||
}
|
||||
expr_fn(f) { v.visit_fn(f, ~[], ex.span, none, ex.id, e, v); }
|
||||
expr_block(b) { v.visit_block(b, e, v); }
|
||||
expr_assign(a, b) { v.visit_expr(b, e, v); v.visit_expr(a, e, v); }
|
||||
expr_move(a, b) { v.visit_expr(b, e, v); v.visit_expr(a, e, v); }
|
||||
@ -336,8 +330,8 @@ fn visit_expr[E](ex: &@expr, e: &E, v: &vt[E]) {
|
||||
some(ex) { v.visit_expr(ex, e, v); }
|
||||
}
|
||||
for m: @method in anon_obj.methods {
|
||||
v.visit_fn(m.node.meth, ~[], il_normal, m.span,
|
||||
some(m.node.ident), m.node.id, e, v);
|
||||
v.visit_fn(m.node.meth, ~[], m.span, some(m.node.ident),
|
||||
m.node.id, e, v);
|
||||
}
|
||||
}
|
||||
expr_mac(mac) { visit_mac(mac, e, v); }
|
||||
@ -368,8 +362,7 @@ type simple_visitor =
|
||||
visit_expr: fn(&@expr) ,
|
||||
visit_ty: fn(&@ty) ,
|
||||
visit_constr: fn(&path, &span, node_id) ,
|
||||
visit_fn: fn(&_fn, &ty_param[], inlineness, &span, &fn_ident, 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) { },
|
||||
@ -386,8 +379,8 @@ fn default_simple_visitor() -> simple_visitor {
|
||||
visit_ty: fn (t: &@ty) { },
|
||||
visit_constr: fn (p: &path, sp: &span, id: node_id) { },
|
||||
visit_fn:
|
||||
fn (f: &_fn, tps: &ty_param[], il: inlineness, sp: &span,
|
||||
ident: &fn_ident, id: node_id) {
|
||||
fn (f: &_fn, tps: &ty_param[], sp: &span, ident: &fn_ident,
|
||||
id: node_id) {
|
||||
}};
|
||||
}
|
||||
|
||||
@ -446,11 +439,11 @@ fn mk_simple_visitor(v: &simple_visitor) -> vt[()] {
|
||||
f(pt, sp, id);
|
||||
visit_constr(pt, sp, id, e, v);
|
||||
}
|
||||
fn v_fn(f: fn(&_fn, &ty_param[], inlineness, &span, &fn_ident, node_id),
|
||||
ff: &_fn, tps: &ty_param[], il: inlineness, sp: &span,
|
||||
ident: &fn_ident, id: node_id, e: &(), v: &vt[()]) {
|
||||
f(ff, tps, il, sp, ident, id);
|
||||
visit_fn(ff, tps, il, sp, ident, 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[()]) {
|
||||
f(ff, tps, sp, ident, id);
|
||||
visit_fn(ff, tps, sp, ident, id, e, v);
|
||||
}
|
||||
ret mk_vt(@{visit_mod: bind v_mod(v.visit_mod, _, _, _, _),
|
||||
visit_view_item: bind v_view_item(v.visit_view_item, _, _, _),
|
||||
@ -466,7 +459,7 @@ fn mk_simple_visitor(v: &simple_visitor) -> vt[()] {
|
||||
visit_expr: bind v_expr(v.visit_expr, _, _, _),
|
||||
visit_ty: bind v_ty(v.visit_ty, _, _, _),
|
||||
visit_constr: bind v_constr(v.visit_constr, _, _, _, _, _),
|
||||
visit_fn: bind v_fn(v.visit_fn, _, _, _, _, _, _, _, _)});
|
||||
visit_fn: bind v_fn(v.visit_fn, _, _, _, _, _, _, _)});
|
||||
}
|
||||
|
||||
// Local Variables:
|
||||
|
Loading…
Reference in New Issue
Block a user