Reformat for new mode syntax, step 1
Long lines were fixed in a very crude way, as I'll be following up with another reformat in a bit.
This commit is contained in:
parent
64a6376da5
commit
fc6b7c8b38
209 changed files with 3358 additions and 3353 deletions
|
|
@ -30,11 +30,11 @@ import print::pp::mk_printer;
|
|||
|
||||
type flag = hashmap<str, ()>;
|
||||
|
||||
fn def_eq(a: &ast::def_id, b: &ast::def_id) -> bool {
|
||||
fn def_eq(a: ast::def_id, b: ast::def_id) -> bool {
|
||||
ret a.crate == b.crate && a.node == b.node;
|
||||
}
|
||||
|
||||
fn hash_def(d: &ast::def_id) -> uint {
|
||||
fn hash_def(d: ast::def_id) -> uint {
|
||||
let h = 5381u;
|
||||
h = (h << 5u) + h ^ (d.crate as uint);
|
||||
h = (h << 5u) + h ^ (d.node as uint);
|
||||
|
|
@ -47,43 +47,43 @@ fn new_def_hash<@V>() -> std::map::hashmap<ast::def_id, V> {
|
|||
ret std::map::mk_hashmap::<ast::def_id, V>(hasher, eqer);
|
||||
}
|
||||
|
||||
fn field_expr(f: &ast::field) -> @ast::expr { ret f.node.expr; }
|
||||
fn field_expr(f: ast::field) -> @ast::expr { ret f.node.expr; }
|
||||
|
||||
fn field_exprs(fields: &[ast::field]) -> [@ast::expr] {
|
||||
fn field_exprs(fields: [ast::field]) -> [@ast::expr] {
|
||||
let es = [];
|
||||
for f: ast::field in fields { es += [f.node.expr]; }
|
||||
ret es;
|
||||
}
|
||||
|
||||
fn log_expr(e: &ast::expr) { log print::pprust::expr_to_str(@e); }
|
||||
fn log_expr(e: ast::expr) { log print::pprust::expr_to_str(@e); }
|
||||
|
||||
fn log_expr_err(e: &ast::expr) { log_err print::pprust::expr_to_str(@e); }
|
||||
fn log_expr_err(e: ast::expr) { log_err print::pprust::expr_to_str(@e); }
|
||||
|
||||
fn log_ty_err(t: &@ty) { log_err print::pprust::ty_to_str(t); }
|
||||
fn log_ty_err(t: @ty) { log_err print::pprust::ty_to_str(t); }
|
||||
|
||||
fn log_pat_err(p: &@pat) { log_err print::pprust::pat_to_str(p); }
|
||||
fn log_pat_err(p: @pat) { log_err print::pprust::pat_to_str(p); }
|
||||
|
||||
fn log_block(b: &ast::blk) { log print::pprust::block_to_str(b); }
|
||||
fn log_block(b: ast::blk) { log print::pprust::block_to_str(b); }
|
||||
|
||||
fn log_block_err(b: &ast::blk) { log_err print::pprust::block_to_str(b); }
|
||||
fn log_block_err(b: ast::blk) { log_err print::pprust::block_to_str(b); }
|
||||
|
||||
fn log_item_err(i: &@ast::item) { log_err print::pprust::item_to_str(i); }
|
||||
fn log_item_err(i: @ast::item) { log_err print::pprust::item_to_str(i); }
|
||||
|
||||
fn log_fn(f: &ast::_fn, name: &ast::ident, params: &[ast::ty_param]) {
|
||||
fn log_fn(f: ast::_fn, name: ast::ident, params: [ast::ty_param]) {
|
||||
log print::pprust::fun_to_str(f, name, params);
|
||||
}
|
||||
|
||||
fn log_fn_err(f: &ast::_fn, name: &ast::ident, params: &[ast::ty_param]) {
|
||||
fn log_fn_err(f: ast::_fn, name: ast::ident, params: [ast::ty_param]) {
|
||||
log_err print::pprust::fun_to_str(f, name, params);
|
||||
}
|
||||
|
||||
fn log_stmt(st: &ast::stmt) { log print::pprust::stmt_to_str(st); }
|
||||
fn log_stmt(st: ast::stmt) { log print::pprust::stmt_to_str(st); }
|
||||
|
||||
fn log_stmt_err(st: &ast::stmt) { log_err print::pprust::stmt_to_str(st); }
|
||||
fn log_stmt_err(st: ast::stmt) { log_err print::pprust::stmt_to_str(st); }
|
||||
|
||||
fn has_nonlocal_exits(b: &ast::blk) -> bool {
|
||||
fn has_nonlocal_exits(b: ast::blk) -> bool {
|
||||
let has_exits = @mutable false;
|
||||
fn visit_expr(flag: @mutable bool, e: &@ast::expr) {
|
||||
fn visit_expr(flag: @mutable bool, e: @ast::expr) {
|
||||
alt e.node {
|
||||
ast::expr_break. { *flag = true; }
|
||||
ast::expr_cont. { *flag = true; }
|
||||
|
|
@ -97,11 +97,11 @@ fn has_nonlocal_exits(b: &ast::blk) -> bool {
|
|||
ret *has_exits;
|
||||
}
|
||||
|
||||
fn local_rhs_span(l: &@ast::local, def: &span) -> span {
|
||||
fn local_rhs_span(l: @ast::local, def: span) -> span {
|
||||
alt l.node.init { some(i) { ret i.expr.span; } _ { ret def; } }
|
||||
}
|
||||
|
||||
fn lit_eq(l: &@ast::lit, m: &@ast::lit) -> bool {
|
||||
fn lit_eq(l: @ast::lit, m: @ast::lit) -> bool {
|
||||
alt l.node {
|
||||
ast::lit_str(s) {
|
||||
alt m.node { ast::lit_str(t) { ret s == t } _ { ret false; } }
|
||||
|
|
@ -150,7 +150,7 @@ fn call_kind_str(c: call_kind) -> str {
|
|||
}
|
||||
}
|
||||
|
||||
fn is_main_name(path: &[ast::ident]) -> bool {
|
||||
fn is_main_name(path: [ast::ident]) -> bool {
|
||||
str::eq(option::get(std::vec::last(path)), "main")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import syntax::ast;
|
|||
import middle::ast_map;
|
||||
import metadata::csearch;
|
||||
|
||||
fn mode_str(m: &ty::mode) -> str {
|
||||
fn mode_str(m: ty::mode) -> str {
|
||||
alt m {
|
||||
ast::by_ref. { "" }
|
||||
ast::by_mut_ref. { "&" }
|
||||
|
|
@ -29,15 +29,15 @@ fn mode_str(m: &ty::mode) -> str {
|
|||
}
|
||||
}
|
||||
|
||||
fn mode_str_1(m: &ty::mode) -> str {
|
||||
fn mode_str_1(m: ty::mode) -> str {
|
||||
alt m { ast::by_ref. { "ref" } _ { mode_str(m) } }
|
||||
}
|
||||
|
||||
fn fn_ident_to_string(id: ast::node_id, i: &ast::fn_ident) -> str {
|
||||
fn fn_ident_to_string(id: ast::node_id, i: ast::fn_ident) -> str {
|
||||
ret alt i { none. { "anon" + int::str(id) } some(s) { s } };
|
||||
}
|
||||
|
||||
fn get_id_ident(cx: &ctxt, id: ast::def_id) -> str {
|
||||
fn get_id_ident(cx: ctxt, id: ast::def_id) -> str {
|
||||
if id.crate != ast::local_crate {
|
||||
alt cx.ext_map.find(id) {
|
||||
some(j) { str::connect(j, "::") }
|
||||
|
|
@ -54,15 +54,15 @@ fn get_id_ident(cx: &ctxt, id: ast::def_id) -> str {
|
|||
}
|
||||
}
|
||||
|
||||
fn ty_to_str(cx: &ctxt, typ: &t) -> str {
|
||||
fn fn_input_to_str(cx: &ctxt, input: &{mode: middle::ty::mode, ty: t}) ->
|
||||
fn ty_to_str(cx: ctxt, typ: t) -> str {
|
||||
fn fn_input_to_str(cx: ctxt, input: {mode: middle::ty::mode, ty: t}) ->
|
||||
str {
|
||||
let s = mode_str(input.mode);
|
||||
ret s + ty_to_str(cx, input.ty);
|
||||
}
|
||||
fn fn_to_str(cx: &ctxt, proto: ast::proto, ident: option::t<ast::ident>,
|
||||
inputs: &[arg], output: t, cf: ast::controlflow,
|
||||
constrs: &[@constr]) -> str {
|
||||
fn fn_to_str(cx: ctxt, proto: ast::proto, ident: option::t<ast::ident>,
|
||||
inputs: [arg], output: t, cf: ast::controlflow,
|
||||
constrs: [@constr]) -> str {
|
||||
let s = proto_to_str(proto);
|
||||
alt ident { some(i) { s += " "; s += i; } _ { } }
|
||||
s += "(";
|
||||
|
|
@ -79,14 +79,14 @@ fn ty_to_str(cx: &ctxt, typ: &t) -> str {
|
|||
s += constrs_str(constrs);
|
||||
ret s;
|
||||
}
|
||||
fn method_to_str(cx: &ctxt, m: &method) -> str {
|
||||
fn method_to_str(cx: ctxt, m: method) -> str {
|
||||
ret fn_to_str(cx, m.proto, some::<ast::ident>(m.ident), m.inputs,
|
||||
m.output, m.cf, m.constrs) + ";";
|
||||
}
|
||||
fn field_to_str(cx: &ctxt, f: &field) -> str {
|
||||
fn field_to_str(cx: ctxt, f: field) -> str {
|
||||
ret f.ident + ": " + mt_to_str(cx, f.mt);
|
||||
}
|
||||
fn mt_to_str(cx: &ctxt, m: &mt) -> str {
|
||||
fn mt_to_str(cx: ctxt, m: mt) -> str {
|
||||
let mstr;
|
||||
alt m.mut {
|
||||
ast::mut. { mstr = "mutable "; }
|
||||
|
|
@ -151,18 +151,18 @@ fn ty_to_str(cx: &ctxt, typ: &t) -> str {
|
|||
}
|
||||
}
|
||||
|
||||
fn ty_to_short_str(cx: &ctxt, typ: t) -> str {
|
||||
fn ty_to_short_str(cx: ctxt, typ: t) -> str {
|
||||
let s = encoder::encoded_ty(cx, typ);
|
||||
if str::byte_len(s) >= 32u { s = str::substr(s, 0u, 32u); }
|
||||
ret s;
|
||||
}
|
||||
|
||||
fn constr_to_str(c: &@constr) -> str {
|
||||
fn constr_to_str(c: @constr) -> str {
|
||||
ret path_to_str(c.node.path) +
|
||||
pprust::constr_args_to_str(pprust::uint_to_str, c.node.args);
|
||||
}
|
||||
|
||||
fn constrs_str(constrs: &[@constr]) -> str {
|
||||
fn constrs_str(constrs: [@constr]) -> str {
|
||||
let s = "";
|
||||
let colon = true;
|
||||
for c: @constr in constrs {
|
||||
|
|
@ -172,7 +172,7 @@ fn constrs_str(constrs: &[@constr]) -> str {
|
|||
ret s;
|
||||
}
|
||||
|
||||
fn ty_constr_to_str<Q>(c: &@ast::spanned<ast::constr_general_<ast::path, Q>>)
|
||||
fn ty_constr_to_str<Q>(c: @ast::spanned<ast::constr_general_<ast::path, Q>>)
|
||||
-> str {
|
||||
ret path_to_str(c.node.path) +
|
||||
constr_args_to_str::<ast::path>(path_to_str, c.node.args);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue