2011-06-15 13:19:50 -05:00
|
|
|
|
2011-07-05 04:48:19 -05:00
|
|
|
import ast::*;
|
2011-06-08 15:48:19 -05:00
|
|
|
import std::option;
|
|
|
|
import std::option::some;
|
|
|
|
import std::option::none;
|
2011-07-05 04:48:19 -05:00
|
|
|
import codemap::span;
|
2011-06-08 15:48:19 -05:00
|
|
|
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2011-06-10 10:29:34 -05:00
|
|
|
// Context-passing AST walker. Each overridden visit method has full control
|
|
|
|
// over what happens with its node, it can do its own traversal of the node's
|
|
|
|
// children (potentially passing in different contexts to each), call
|
|
|
|
// visit::visit_* to apply the default traversal algorithm (again, it can
|
|
|
|
// override the context), or prevent deeper traversal by doing nothing.
|
|
|
|
|
2011-06-08 15:48:19 -05:00
|
|
|
// Lots of redundant indirection and refcounting. Our typesystem doesn't do
|
|
|
|
// circular types, so the visitor record can not hold functions that take
|
2011-06-10 10:29:34 -05:00
|
|
|
// visitors. A vt tag is used to break the cycle.
|
2011-06-08 15:48:19 -05:00
|
|
|
tag vt[E] { vtor(visitor[E]); }
|
2011-06-15 13:19:50 -05:00
|
|
|
|
|
|
|
fn vt[E](&vt[E] x) -> visitor[E] { alt (x) { case (vtor(?v)) { ret v; } } }
|
2011-06-08 15:48:19 -05:00
|
|
|
|
|
|
|
type visitor[E] =
|
2011-06-15 13:19:50 -05:00
|
|
|
@rec(fn(&_mod, &span, &E, &vt[E]) visit_mod,
|
|
|
|
fn(&@view_item, &E, &vt[E]) visit_view_item,
|
|
|
|
fn(&@native_item, &E, &vt[E]) visit_native_item,
|
|
|
|
fn(&@item, &E, &vt[E]) visit_item,
|
|
|
|
fn(&@local, &E, &vt[E]) visit_local,
|
|
|
|
fn(&block, &E, &vt[E]) visit_block,
|
|
|
|
fn(&@stmt, &E, &vt[E]) visit_stmt,
|
|
|
|
fn(&arm, &E, &vt[E]) visit_arm,
|
|
|
|
fn(&@pat, &E, &vt[E]) visit_pat,
|
|
|
|
fn(&@decl, &E, &vt[E]) visit_decl,
|
|
|
|
fn(&@expr, &E, &vt[E]) visit_expr,
|
|
|
|
fn(&@ty, &E, &vt[E]) visit_ty,
|
|
|
|
fn(&@constr, &E, &vt[E]) visit_constr,
|
2011-07-06 21:00:00 -05:00
|
|
|
fn(&_fn, &ty_param[], &span, &fn_ident, node_id, &E, &vt[E])
|
2011-06-15 13:19:50 -05:00
|
|
|
visit_fn);
|
2011-06-08 15:48:19 -05:00
|
|
|
|
|
|
|
fn default_visitor[E]() -> visitor[E] {
|
2011-06-15 13:19:50 -05:00
|
|
|
ret @rec(visit_mod=bind visit_mod[E](_, _, _, _),
|
|
|
|
visit_view_item=bind visit_view_item[E](_, _, _),
|
|
|
|
visit_native_item=bind visit_native_item[E](_, _, _),
|
|
|
|
visit_item=bind visit_item[E](_, _, _),
|
|
|
|
visit_local=bind visit_local[E](_, _, _),
|
|
|
|
visit_block=bind visit_block[E](_, _, _),
|
|
|
|
visit_stmt=bind visit_stmt[E](_, _, _),
|
|
|
|
visit_arm=bind visit_arm[E](_, _, _),
|
|
|
|
visit_pat=bind visit_pat[E](_, _, _),
|
|
|
|
visit_decl=bind visit_decl[E](_, _, _),
|
|
|
|
visit_expr=bind visit_expr[E](_, _, _),
|
|
|
|
visit_ty=bind visit_ty[E](_, _, _),
|
|
|
|
visit_constr=bind visit_constr[E](_, _, _),
|
2011-06-19 15:41:21 -05:00
|
|
|
visit_fn=bind visit_fn[E](_, _, _, _, _, _, _));
|
2011-06-08 15:48:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn visit_crate[E](&crate c, &E e, &vt[E] v) {
|
|
|
|
vt(v).visit_mod(c.node.module, c.span, e, v);
|
|
|
|
}
|
|
|
|
|
2011-06-09 08:50:20 -05:00
|
|
|
fn visit_crate_directive[E](&@crate_directive cd, &E e, &vt[E] v) {
|
|
|
|
alt (cd.node) {
|
2011-06-28 20:15:39 -05:00
|
|
|
case (cdir_src_mod(_, _, _)) { }
|
|
|
|
case (cdir_dir_mod(_, _, ?cdirs, _)) {
|
2011-06-09 08:50:20 -05:00
|
|
|
for (@crate_directive cdir in cdirs) {
|
|
|
|
visit_crate_directive(cdir, e, v);
|
|
|
|
}
|
|
|
|
}
|
2011-06-15 13:19:50 -05:00
|
|
|
case (cdir_view_item(?vi)) { vt(v).visit_view_item(vi, e, v); }
|
|
|
|
case (cdir_syntax(_)) { }
|
|
|
|
case (cdir_auth(_, _)) { }
|
2011-06-09 08:50:20 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-08 15:48:19 -05:00
|
|
|
fn visit_mod[E](&_mod m, &span sp, &E e, &vt[E] v) {
|
2011-06-15 13:19:50 -05:00
|
|
|
for (@view_item vi in m.view_items) { vt(v).visit_view_item(vi, e, v); }
|
|
|
|
for (@item i in m.items) { vt(v).visit_item(i, e, v); }
|
2011-06-08 15:48:19 -05:00
|
|
|
}
|
|
|
|
|
2011-06-15 13:19:50 -05:00
|
|
|
fn visit_view_item[E](&@view_item vi, &E e, &vt[E] v) { }
|
2011-06-09 08:50:20 -05:00
|
|
|
|
2011-06-13 19:04:15 -05:00
|
|
|
fn visit_local[E](&@local loc, &E e, &vt[E] v) {
|
|
|
|
alt (loc.node.ty) {
|
2011-06-15 13:19:50 -05:00
|
|
|
case (none) { }
|
2011-06-13 19:04:15 -05:00
|
|
|
case (some(?t)) { vt(v).visit_ty(t, e, v); }
|
|
|
|
}
|
|
|
|
alt (loc.node.init) {
|
2011-06-15 13:19:50 -05:00
|
|
|
case (none) { }
|
2011-06-13 19:04:15 -05:00
|
|
|
case (some(?i)) { vt(v).visit_expr(i.expr, e, v); }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-08 15:48:19 -05:00
|
|
|
fn visit_item[E](&@item i, &E e, &vt[E] v) {
|
|
|
|
alt (i.node) {
|
2011-06-16 04:53:06 -05:00
|
|
|
case (item_const(?t, ?ex)) {
|
2011-06-08 15:48:19 -05:00
|
|
|
vt(v).visit_ty(t, e, v);
|
|
|
|
vt(v).visit_expr(ex, e, v);
|
|
|
|
}
|
2011-06-16 04:53:06 -05:00
|
|
|
case (item_fn(?f, ?tp)) {
|
2011-06-28 19:49:15 -05:00
|
|
|
vt(v).visit_fn(f, tp, i.span, some(i.ident), i.id, e, v);
|
2011-06-08 15:48:19 -05:00
|
|
|
}
|
2011-06-16 04:53:06 -05:00
|
|
|
case (item_mod(?m)) { vt(v).visit_mod(m, i.span, e, v); }
|
|
|
|
case (item_native_mod(?nm)) {
|
2011-06-09 08:50:20 -05:00
|
|
|
for (@view_item vi in nm.view_items) {
|
|
|
|
vt(v).visit_view_item(vi, e, v);
|
|
|
|
}
|
2011-06-08 15:48:19 -05:00
|
|
|
for (@native_item ni in nm.items) {
|
|
|
|
vt(v).visit_native_item(ni, e, v);
|
|
|
|
}
|
|
|
|
}
|
2011-06-16 04:53:06 -05:00
|
|
|
case (item_ty(?t, _)) { vt(v).visit_ty(t, e, v); }
|
2011-06-24 11:10:40 -05:00
|
|
|
case (item_res(?f, ?dtor_id, ?tps, _)) {
|
2011-06-28 19:49:15 -05:00
|
|
|
vt(v).visit_fn(f, tps, i.span, some(i.ident), dtor_id, e, v);
|
2011-06-24 11:10:40 -05:00
|
|
|
}
|
2011-06-16 04:53:06 -05:00
|
|
|
case (item_tag(?variants, _)) {
|
2011-06-08 15:48:19 -05:00
|
|
|
for (variant vr in variants) {
|
|
|
|
for (variant_arg va in vr.node.args) {
|
|
|
|
vt(v).visit_ty(va.ty, e, v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-06-16 04:53:06 -05:00
|
|
|
case (item_obj(?ob, _, _)) {
|
2011-06-15 13:19:50 -05:00
|
|
|
for (obj_field f in ob.fields) { vt(v).visit_ty(f.ty, e, v); }
|
2011-06-08 15:48:19 -05:00
|
|
|
for (@method m in ob.methods) {
|
2011-07-06 21:00:00 -05:00
|
|
|
vt(v).visit_fn(m.node.meth, ~[], m.span, some(m.node.ident),
|
2011-06-19 15:41:21 -05:00
|
|
|
m.node.id, e, v);
|
2011-06-08 15:48:19 -05:00
|
|
|
}
|
|
|
|
alt (ob.dtor) {
|
2011-06-15 13:19:50 -05:00
|
|
|
case (none) { }
|
2011-06-08 15:48:19 -05:00
|
|
|
case (some(?m)) {
|
2011-07-06 21:00:00 -05:00
|
|
|
vt(v).visit_fn(m.node.meth, ~[], m.span,
|
2011-06-29 17:11:20 -05:00
|
|
|
some(m.node.ident),
|
2011-06-19 15:41:21 -05:00
|
|
|
m.node.id, e, v);
|
2011-06-08 15:48:19 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn visit_ty[E](&@ty t, &E e, &vt[E] v) {
|
|
|
|
alt (t.node) {
|
2011-06-16 16:25:44 -05:00
|
|
|
case (ty_nil) { /* no-op */ }
|
|
|
|
case (ty_bot) { /* no-op */ }
|
|
|
|
case (ty_bool) { /* no-op */ }
|
|
|
|
case (ty_int) { /* no-op */ }
|
|
|
|
case (ty_float) { /* no-op */ }
|
|
|
|
case (ty_uint) { /* no-op */ }
|
|
|
|
case (ty_machine(_)) { /* no-op */ }
|
|
|
|
case (ty_char) { /* no-op */ }
|
|
|
|
case (ty_str) { /* no-op */ }
|
|
|
|
case (ty_istr) { /* no-op */ }
|
|
|
|
case (ty_box(?mt)) { vt(v).visit_ty(mt.ty, e, v); }
|
|
|
|
case (ty_vec(?mt)) { vt(v).visit_ty(mt.ty, e, v); }
|
|
|
|
case (ty_ivec(?mt)) { vt(v).visit_ty(mt.ty, e, v); }
|
|
|
|
case (ty_ptr(?mt)) { vt(v).visit_ty(mt.ty, e, v); }
|
|
|
|
case (ty_port(?t)) { vt(v).visit_ty(t, e, v); }
|
|
|
|
case (ty_chan(?t)) { vt(v).visit_ty(t, e, v); }
|
|
|
|
case (ty_task) { /* no-op */ }
|
2011-06-08 15:48:19 -05:00
|
|
|
case (ty_tup(?mts)) {
|
2011-06-15 13:19:50 -05:00
|
|
|
for (mt mt in mts) { vt(v).visit_ty(mt.ty, e, v); }
|
2011-06-08 15:48:19 -05:00
|
|
|
}
|
|
|
|
case (ty_rec(?flds)) {
|
2011-06-15 13:19:50 -05:00
|
|
|
for (ty_field f in flds) { vt(v).visit_ty(f.node.mt.ty, e, v); }
|
2011-06-08 15:48:19 -05:00
|
|
|
}
|
2011-06-10 21:12:42 -05:00
|
|
|
case (ty_fn(_, ?args, ?out, _, ?constrs)) {
|
2011-06-15 13:19:50 -05:00
|
|
|
for (ty_arg a in args) { vt(v).visit_ty(a.node.ty, e, v); }
|
|
|
|
for (@constr c in constrs) { vt(v).visit_constr(c, e, v); }
|
2011-06-08 15:48:19 -05:00
|
|
|
vt(v).visit_ty(out, e, v);
|
|
|
|
}
|
|
|
|
case (ty_obj(?tmeths)) {
|
|
|
|
for (ty_method m in tmeths) {
|
|
|
|
for (ty_arg a in m.node.inputs) {
|
|
|
|
vt(v).visit_ty(a.node.ty, e, v);
|
|
|
|
}
|
|
|
|
vt(v).visit_ty(m.node.output, e, v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case (ty_path(?p, _)) {
|
2011-06-15 13:19:50 -05:00
|
|
|
for (@ty tp in p.node.types) { vt(v).visit_ty(tp, e, v); }
|
2011-06-08 15:48:19 -05:00
|
|
|
}
|
2011-06-16 16:25:44 -05:00
|
|
|
case (ty_type) { /* no-op */ }
|
2011-06-08 15:48:19 -05:00
|
|
|
case (ty_constr(?t, _)) { vt(v).visit_ty(t, e, v); }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-10 21:12:42 -05:00
|
|
|
fn visit_constr[E](&@constr c, &E e, &vt[E] v) {
|
|
|
|
// default
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2011-06-10 21:12:42 -05:00
|
|
|
}
|
|
|
|
|
2011-06-08 15:48:19 -05:00
|
|
|
fn visit_pat[E](&@pat p, &E e, &vt[E] v) {
|
|
|
|
alt (p.node) {
|
2011-07-04 14:53:33 -05:00
|
|
|
case (pat_tag(?path, ?children)) {
|
2011-06-09 08:50:20 -05:00
|
|
|
for (@ty tp in path.node.types) { vt(v).visit_ty(tp, e, v); }
|
|
|
|
for (@pat child in children) { vt(v).visit_pat(child, e, v); }
|
2011-06-08 15:48:19 -05:00
|
|
|
}
|
2011-06-15 13:19:50 -05:00
|
|
|
case (_) { }
|
2011-06-08 15:48:19 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn visit_native_item[E](&@native_item ni, &E e, &vt[E] v) {
|
|
|
|
alt (ni.node) {
|
2011-06-21 16:01:08 -05:00
|
|
|
case (native_item_fn(_, ?fd, _)) { visit_fn_decl(fd, e, v); }
|
|
|
|
case (native_item_ty) { }
|
2011-06-08 15:48:19 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn visit_fn_decl[E](&fn_decl fd, &E e, &vt[E] v) {
|
2011-06-15 13:19:50 -05:00
|
|
|
for (arg a in fd.inputs) { vt(v).visit_ty(a.ty, e, v); }
|
|
|
|
for (@constr c in fd.constraints) { vt(v).visit_constr(c, e, v); }
|
2011-06-08 15:48:19 -05:00
|
|
|
vt(v).visit_ty(fd.output, e, v);
|
|
|
|
}
|
|
|
|
|
2011-07-06 21:00:00 -05:00
|
|
|
fn visit_fn[E](&_fn f, &ty_param[] tp, &span sp, &fn_ident i,
|
2011-06-19 15:41:21 -05:00
|
|
|
node_id id, &E e, &vt[E] v) {
|
2011-06-08 15:48:19 -05:00
|
|
|
visit_fn_decl(f.decl, e, v);
|
|
|
|
vt(v).visit_block(f.body, e, v);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn visit_block[E](&block b, &E e, &vt[E] v) {
|
|
|
|
for (@stmt s in b.node.stmts) { vt(v).visit_stmt(s, e, v); }
|
|
|
|
visit_expr_opt(b.node.expr, e, v);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn visit_stmt[E](&@stmt s, &E e, &vt[E] v) {
|
|
|
|
alt (s.node) {
|
|
|
|
case (stmt_decl(?d, _)) { vt(v).visit_decl(d, e, v); }
|
|
|
|
case (stmt_expr(?ex, _)) { vt(v).visit_expr(ex, e, v); }
|
2011-06-09 08:50:20 -05:00
|
|
|
case (stmt_crate_directive(?cd)) { visit_crate_directive(cd, e, v); }
|
2011-06-08 15:48:19 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn visit_decl[E](&@decl d, &E e, &vt[E] v) {
|
|
|
|
alt (d.node) {
|
|
|
|
case (decl_local(?loc)) {
|
2011-06-16 17:58:25 -05:00
|
|
|
vt(v).visit_local(loc, e, v);
|
2011-06-08 15:48:19 -05:00
|
|
|
}
|
|
|
|
case (decl_item(?it)) { vt(v).visit_item(it, e, v); }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn visit_expr_opt[E](option::t[@expr] eo, &E e, &vt[E] v) {
|
|
|
|
alt (eo) {
|
2011-06-15 13:19:50 -05:00
|
|
|
case (none) { }
|
|
|
|
case (some(?ex)) { vt(v).visit_expr(ex, e, v); }
|
2011-06-08 15:48:19 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-06 21:00:00 -05:00
|
|
|
fn visit_exprs[E](&(@expr)[] exprs, &E e, &vt[E] v) {
|
2011-06-08 15:48:19 -05:00
|
|
|
for (@expr ex in exprs) { vt(v).visit_expr(ex, e, v); }
|
|
|
|
}
|
|
|
|
|
|
|
|
fn visit_expr[E](&@expr ex, &E e, &vt[E] v) {
|
|
|
|
alt (ex.node) {
|
2011-06-21 15:16:40 -05:00
|
|
|
case (expr_vec(?es, _, _)) { visit_exprs(es, e, v); }
|
|
|
|
case (expr_tup(?elts)) {
|
2011-06-08 15:48:19 -05:00
|
|
|
for (elt el in elts) { vt(v).visit_expr(el.expr, e, v); }
|
|
|
|
}
|
2011-06-21 15:16:40 -05:00
|
|
|
case (expr_rec(?flds, ?base)) {
|
2011-06-08 15:48:19 -05:00
|
|
|
for (field f in flds) { vt(v).visit_expr(f.node.expr, e, v); }
|
|
|
|
visit_expr_opt(base, e, v);
|
|
|
|
}
|
2011-06-21 15:16:40 -05:00
|
|
|
case (expr_call(?callee, ?args)) {
|
2011-06-08 15:48:19 -05:00
|
|
|
vt(v).visit_expr(callee, e, v);
|
|
|
|
visit_exprs(args, e, v);
|
|
|
|
}
|
2011-06-21 15:16:40 -05:00
|
|
|
case (expr_self_method(_)) { }
|
|
|
|
case (expr_bind(?callee, ?args)) {
|
2011-06-08 15:48:19 -05:00
|
|
|
vt(v).visit_expr(callee, e, v);
|
|
|
|
for (option::t[@expr] eo in args) { visit_expr_opt(eo, e, v); }
|
|
|
|
}
|
2011-06-21 15:16:40 -05:00
|
|
|
case (expr_spawn(_, _, ?callee, ?args)) {
|
2011-06-08 15:48:19 -05:00
|
|
|
vt(v).visit_expr(callee, e, v);
|
|
|
|
visit_exprs(args, e, v);
|
|
|
|
}
|
2011-06-21 15:16:40 -05:00
|
|
|
case (expr_binary(_, ?a, ?b)) {
|
2011-06-08 15:48:19 -05:00
|
|
|
vt(v).visit_expr(a, e, v);
|
|
|
|
vt(v).visit_expr(b, e, v);
|
|
|
|
}
|
2011-06-21 15:16:40 -05:00
|
|
|
case (expr_unary(_, ?a)) { vt(v).visit_expr(a, e, v); }
|
|
|
|
case (expr_lit(_)) { }
|
|
|
|
case (expr_cast(?x, ?t)) {
|
2011-06-08 15:48:19 -05:00
|
|
|
vt(v).visit_expr(x, e, v);
|
|
|
|
vt(v).visit_ty(t, e, v);
|
|
|
|
}
|
2011-06-21 15:16:40 -05:00
|
|
|
case (expr_if(?x, ?b, ?eo)) {
|
2011-06-08 15:48:19 -05:00
|
|
|
vt(v).visit_expr(x, e, v);
|
|
|
|
vt(v).visit_block(b, e, v);
|
|
|
|
visit_expr_opt(eo, e, v);
|
|
|
|
}
|
2011-06-21 15:16:40 -05:00
|
|
|
case (expr_if_check(?x, ?b, ?eo)) {
|
2011-06-16 13:56:34 -05:00
|
|
|
vt(v).visit_expr(x, e, v);
|
|
|
|
vt(v).visit_block(b, e, v);
|
|
|
|
visit_expr_opt(eo, e, v);
|
|
|
|
}
|
2011-06-23 17:15:50 -05:00
|
|
|
case (expr_ternary(?c, ?t, ?el)) {
|
|
|
|
vt(v).visit_expr(c, e, v);
|
|
|
|
vt(v).visit_expr(t, e, v);
|
|
|
|
vt(v).visit_expr(el, e, v);
|
|
|
|
}
|
2011-06-21 15:16:40 -05:00
|
|
|
case (expr_while(?x, ?b)) {
|
2011-06-08 15:48:19 -05:00
|
|
|
vt(v).visit_expr(x, e, v);
|
|
|
|
vt(v).visit_block(b, e, v);
|
|
|
|
}
|
2011-06-21 15:16:40 -05:00
|
|
|
case (expr_for(?dcl, ?x, ?b)) {
|
2011-06-13 19:04:15 -05:00
|
|
|
vt(v).visit_local(dcl, e, v);
|
2011-06-08 15:48:19 -05:00
|
|
|
vt(v).visit_expr(x, e, v);
|
|
|
|
vt(v).visit_block(b, e, v);
|
|
|
|
}
|
2011-06-21 15:16:40 -05:00
|
|
|
case (expr_for_each(?dcl, ?x, ?b)) {
|
2011-06-13 19:04:15 -05:00
|
|
|
vt(v).visit_local(dcl, e, v);
|
2011-06-08 15:48:19 -05:00
|
|
|
vt(v).visit_expr(x, e, v);
|
|
|
|
vt(v).visit_block(b, e, v);
|
|
|
|
}
|
2011-06-21 15:16:40 -05:00
|
|
|
case (expr_do_while(?b, ?x)) {
|
2011-06-08 15:48:19 -05:00
|
|
|
vt(v).visit_block(b, e, v);
|
|
|
|
vt(v).visit_expr(x, e, v);
|
|
|
|
}
|
2011-06-21 15:16:40 -05:00
|
|
|
case (expr_alt(?x, ?arms)) {
|
2011-06-08 15:48:19 -05:00
|
|
|
vt(v).visit_expr(x, e, v);
|
2011-06-15 13:19:50 -05:00
|
|
|
for (arm a in arms) { vt(v).visit_arm(a, e, v); }
|
2011-06-08 15:48:19 -05:00
|
|
|
}
|
2011-06-21 15:16:40 -05:00
|
|
|
case (expr_fn(?f)) {
|
2011-07-06 21:00:00 -05:00
|
|
|
vt(v).visit_fn(f, ~[], ex.span, none, ex.id, e, v);
|
2011-06-14 08:20:04 -05:00
|
|
|
}
|
2011-06-21 15:16:40 -05:00
|
|
|
case (expr_block(?b)) { vt(v).visit_block(b, e, v); }
|
|
|
|
case (expr_assign(?a, ?b)) {
|
2011-06-08 15:48:19 -05:00
|
|
|
vt(v).visit_expr(b, e, v);
|
|
|
|
vt(v).visit_expr(a, e, v);
|
|
|
|
}
|
2011-06-21 15:16:40 -05:00
|
|
|
case (expr_move(?a, ?b)) {
|
2011-06-08 15:48:19 -05:00
|
|
|
vt(v).visit_expr(b, e, v);
|
|
|
|
vt(v).visit_expr(a, e, v);
|
|
|
|
}
|
2011-06-21 15:16:40 -05:00
|
|
|
case (expr_swap(?a, ?b)) {
|
2011-06-13 19:34:54 -05:00
|
|
|
vt(v).visit_expr(a, e, v);
|
|
|
|
vt(v).visit_expr(b, e, v);
|
|
|
|
}
|
2011-06-21 15:16:40 -05:00
|
|
|
case (expr_assign_op(_, ?a, ?b)) {
|
2011-06-08 15:48:19 -05:00
|
|
|
vt(v).visit_expr(b, e, v);
|
|
|
|
vt(v).visit_expr(a, e, v);
|
|
|
|
}
|
2011-06-21 15:16:40 -05:00
|
|
|
case (expr_send(?a, ?b)) {
|
2011-06-08 15:48:19 -05:00
|
|
|
vt(v).visit_expr(a, e, v);
|
|
|
|
vt(v).visit_expr(b, e, v);
|
|
|
|
}
|
2011-06-21 15:16:40 -05:00
|
|
|
case (expr_recv(?a, ?b)) {
|
2011-06-08 15:48:19 -05:00
|
|
|
vt(v).visit_expr(a, e, v);
|
|
|
|
vt(v).visit_expr(b, e, v);
|
|
|
|
}
|
2011-06-21 15:16:40 -05:00
|
|
|
case (expr_field(?x, _)) { vt(v).visit_expr(x, e, v); }
|
|
|
|
case (expr_index(?a, ?b)) {
|
2011-06-08 15:48:19 -05:00
|
|
|
vt(v).visit_expr(a, e, v);
|
|
|
|
vt(v).visit_expr(b, e, v);
|
|
|
|
}
|
2011-06-21 15:16:40 -05:00
|
|
|
case (expr_path(?p)) {
|
2011-06-15 13:19:50 -05:00
|
|
|
for (@ty tp in p.node.types) { vt(v).visit_ty(tp, e, v); }
|
2011-06-08 15:48:19 -05:00
|
|
|
}
|
2011-06-21 15:16:40 -05:00
|
|
|
case (expr_ext(_, _, _, ?expansion)) {
|
2011-06-08 15:48:19 -05:00
|
|
|
vt(v).visit_expr(expansion, e, v);
|
|
|
|
}
|
2011-07-03 04:38:11 -05:00
|
|
|
case (expr_fail(?eo)) {
|
|
|
|
visit_expr_opt(eo, e, v);
|
|
|
|
}
|
2011-06-21 15:16:40 -05:00
|
|
|
case (expr_break) { }
|
|
|
|
case (expr_cont) { }
|
|
|
|
case (expr_ret(?eo)) { visit_expr_opt(eo, e, v); }
|
|
|
|
case (expr_put(?eo)) { visit_expr_opt(eo, e, v); }
|
|
|
|
case (expr_be(?x)) { vt(v).visit_expr(x, e, v); }
|
|
|
|
case (expr_log(_, ?x)) { vt(v).visit_expr(x, e, v); }
|
2011-06-28 18:29:37 -05:00
|
|
|
case (expr_check(_, ?x)) { vt(v).visit_expr(x, e, v); }
|
2011-06-21 15:16:40 -05:00
|
|
|
case (expr_assert(?x)) { vt(v).visit_expr(x, e, v); }
|
2011-06-28 17:54:16 -05:00
|
|
|
case (expr_port(_)) { }
|
2011-06-21 15:16:40 -05:00
|
|
|
case (expr_chan(?x)) { vt(v).visit_expr(x, e, v); }
|
2011-07-06 13:29:22 -05:00
|
|
|
case (expr_anon_obj(?anon_obj, _)) {
|
2011-06-08 15:48:19 -05:00
|
|
|
alt (anon_obj.fields) {
|
|
|
|
case (none) { }
|
|
|
|
case (some(?fields)) {
|
2011-06-16 19:33:31 -05:00
|
|
|
for (anon_obj_field f in fields) {
|
2011-06-08 15:48:19 -05:00
|
|
|
vt(v).visit_ty(f.ty, e, v);
|
2011-06-16 19:33:31 -05:00
|
|
|
vt(v).visit_expr(f.expr, e, v);
|
2011-06-08 15:48:19 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
alt (anon_obj.with_obj) {
|
|
|
|
case (none) { }
|
2011-06-15 13:19:50 -05:00
|
|
|
case (some(?ex)) { vt(v).visit_expr(ex, e, v); }
|
2011-06-08 15:48:19 -05:00
|
|
|
}
|
|
|
|
for (@method m in anon_obj.methods) {
|
2011-07-06 21:00:00 -05:00
|
|
|
vt(v).visit_fn(m.node.meth, ~[], m.span, some(m.node.ident),
|
2011-06-19 15:41:21 -05:00
|
|
|
m.node.id, e, v);
|
2011-06-08 15:48:19 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn visit_arm[E](&arm a, &E e, &vt[E] v) {
|
2011-07-08 09:27:55 -05:00
|
|
|
for (@pat p in a.pats) { vt(v).visit_pat(p, e, v); }
|
2011-06-08 15:48:19 -05:00
|
|
|
vt(v).visit_block(a.block, e, v);
|
|
|
|
}
|
|
|
|
// Local Variables:
|
|
|
|
// mode: rust
|
|
|
|
// fill-column: 78;
|
|
|
|
// indent-tabs-mode: nil
|
|
|
|
// c-basic-offset: 4
|
|
|
|
// buffer-file-coding-system: utf-8-unix
|
|
|
|
// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
|
|
|
|
// End:
|