Remove uses of variable name 'res' from rustc
This in preparation of making 'res' a keyword for defining resources. Please don't introduce too many new ones in the meantime...
This commit is contained in:
parent
d507d5fe91
commit
9643aedb04
@ -71,11 +71,11 @@ fn parse_ident(@pstate st, str_def sd, char last) -> ast::ident {
|
||||
|
||||
fn parse_ident_(@pstate st, str_def sd, fn(char) -> bool is_last)
|
||||
-> ast::ident {
|
||||
auto res = "";
|
||||
auto rslt = "";
|
||||
while (! is_last(peek(st) as char)) {
|
||||
res += str::unsafe_from_byte(next(st));
|
||||
rslt += str::unsafe_from_byte(next(st));
|
||||
}
|
||||
ret res;
|
||||
ret rslt;
|
||||
}
|
||||
|
||||
|
||||
@ -95,17 +95,17 @@ fn parse_ty_or_bang(@pstate st, str_def sd) -> ty_or_bang {
|
||||
}
|
||||
|
||||
fn parse_constrs(@pstate st, str_def sd) -> vec[@ty::constr_def] {
|
||||
let vec[@ty::constr_def] res = [];
|
||||
let vec[@ty::constr_def] rslt = [];
|
||||
alt (peek(st) as char) {
|
||||
case (':') {
|
||||
do {
|
||||
auto ignore = next(st);
|
||||
vec::push(res, parse_constr(st, sd));
|
||||
vec::push(rslt, parse_constr(st, sd));
|
||||
} while (peek(st) as char == ';')
|
||||
}
|
||||
case (_) { }
|
||||
}
|
||||
ret res;
|
||||
ret rslt;
|
||||
}
|
||||
|
||||
fn parse_path(@pstate st, str_def sd) -> ast::path {
|
||||
@ -370,8 +370,7 @@ fn parse_ty_fn(@pstate st, str_def sd) ->
|
||||
}
|
||||
st.pos += 1u; // eat the ']'
|
||||
auto cs = parse_constrs(st, sd);
|
||||
auto res = parse_ty_or_bang(st, sd);
|
||||
alt (res) {
|
||||
alt (parse_ty_or_bang(st, sd)) {
|
||||
case (a_bang) {
|
||||
ret tup(inputs, ty::mk_bot(st.tcx), ast::noreturn, cs);
|
||||
}
|
||||
|
@ -158,31 +158,31 @@ fn digits_to_string(str s) -> int {
|
||||
|
||||
fn scan_exponent(&reader rdr) -> option::t[str] {
|
||||
auto c = rdr.curr();
|
||||
auto res = "";
|
||||
auto rslt = "";
|
||||
if (c == 'e' || c == 'E') {
|
||||
res += str::from_bytes([c as u8]);
|
||||
rslt += str::from_bytes([c as u8]);
|
||||
rdr.bump();
|
||||
c = rdr.curr();
|
||||
if (c == '-' || c == '+') {
|
||||
res += str::from_bytes([c as u8]);
|
||||
rslt += str::from_bytes([c as u8]);
|
||||
rdr.bump();
|
||||
}
|
||||
auto exponent = scan_dec_digits(rdr);
|
||||
if (str::byte_len(exponent) > 0u) {
|
||||
ret some(res + exponent);
|
||||
ret some(rslt + exponent);
|
||||
} else { rdr.err("scan_exponent: bad fp literal"); fail; }
|
||||
} else { ret none[str]; }
|
||||
}
|
||||
|
||||
fn scan_dec_digits(&reader rdr) -> str {
|
||||
auto c = rdr.curr();
|
||||
let str res = "";
|
||||
let str rslt = "";
|
||||
while (is_dec_digit(c) || c == '_') {
|
||||
if (c != '_') { res += str::from_bytes([c as u8]); }
|
||||
if (c != '_') { rslt += str::from_bytes([c as u8]); }
|
||||
rdr.bump();
|
||||
c = rdr.curr();
|
||||
}
|
||||
ret res;
|
||||
ret rslt;
|
||||
}
|
||||
|
||||
fn scan_number(char c, &reader rdr) -> token::token {
|
||||
|
@ -58,7 +58,7 @@ fn new_parser(session::session sess, eval::env env,
|
||||
mutable uint lo,
|
||||
mutable uint hi,
|
||||
mutable uint last_lo,
|
||||
mutable restriction res,
|
||||
mutable restriction restr,
|
||||
lexer::reader rdr,
|
||||
vec[op_spec] precs,
|
||||
mutable ast::node_id next_id_var,
|
||||
@ -75,8 +75,8 @@ fn new_parser(session::session sess, eval::env env,
|
||||
hi = rdr.get_chpos();
|
||||
}
|
||||
fn fatal(str m) -> ! { sess.span_fatal(rec(lo=lo, hi=hi), m); }
|
||||
fn restrict(restriction r) { res = r; }
|
||||
fn get_restriction() -> restriction { ret res; }
|
||||
fn restrict(restriction r) { restr = r; }
|
||||
fn get_restriction() -> restriction { ret restr; }
|
||||
fn get_session() -> session::session { ret sess; }
|
||||
fn get_span() -> common::span { ret rec(lo=lo, hi=hi); }
|
||||
fn get_lo_pos() -> uint { ret lo; }
|
||||
@ -1653,15 +1653,15 @@ fn parse_fn_decl(&parser p, ast::purity purity) -> ast::fn_decl {
|
||||
let util::common::spanned[vec[ast::arg]] inputs =
|
||||
parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA), parse_arg,
|
||||
p);
|
||||
let ty_or_bang res;
|
||||
let ty_or_bang rslt;
|
||||
auto constrs = parse_constrs(inputs.node, p).node;
|
||||
if (p.peek() == token::RARROW) {
|
||||
p.bump();
|
||||
res = parse_ty_or_bang(p);
|
||||
rslt = parse_ty_or_bang(p);
|
||||
} else {
|
||||
res = a_ty(@spanned(inputs.span.lo, inputs.span.hi, ast::ty_nil));
|
||||
rslt = a_ty(@spanned(inputs.span.lo, inputs.span.hi, ast::ty_nil));
|
||||
}
|
||||
alt (res) {
|
||||
alt (rslt) {
|
||||
case (a_ty(?t)) {
|
||||
ret rec(inputs=inputs.node,
|
||||
output=t,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -54,9 +54,9 @@ fn empty_prestate(uint num_vars) -> prestate { be true_precond(num_vars); }
|
||||
fn empty_poststate(uint num_vars) -> poststate { be true_precond(num_vars); }
|
||||
|
||||
fn false_postcond(uint num_vars) -> postcond {
|
||||
auto res = create_tritv(num_vars);
|
||||
tritv_set_all(res);
|
||||
ret res;
|
||||
auto rslt = create_tritv(num_vars);
|
||||
tritv_set_all(rslt);
|
||||
ret rslt;
|
||||
}
|
||||
|
||||
fn empty_pre_post(uint num_vars) -> pre_and_post {
|
||||
|
@ -23,42 +23,42 @@ import aux::crate_ctxt;
|
||||
import aux::add_node;
|
||||
import middle::tstate::ann::empty_ann;
|
||||
|
||||
fn collect_ids_expr(&@expr e, @mutable vec[node_id] res) {
|
||||
vec::push(*res, e.id);
|
||||
fn collect_ids_expr(&@expr e, @mutable vec[node_id] rs) {
|
||||
vec::push(*rs, e.id);
|
||||
}
|
||||
|
||||
fn collect_ids_block(&block b, @mutable vec[node_id] res) {
|
||||
vec::push(*res, b.node.id);
|
||||
fn collect_ids_block(&block b, @mutable vec[node_id] rs) {
|
||||
vec::push(*rs, b.node.id);
|
||||
}
|
||||
|
||||
fn collect_ids_stmt(&@stmt s, @mutable vec[node_id] res) {
|
||||
fn collect_ids_stmt(&@stmt s, @mutable vec[node_id] rs) {
|
||||
alt (s.node) {
|
||||
case (stmt_decl(_, ?id)) {
|
||||
log "node_id " + istr(id);
|
||||
log_stmt(*s);
|
||||
vec::push(*res, id);
|
||||
vec::push(*rs, id);
|
||||
}
|
||||
case (stmt_expr(_, ?id)) {
|
||||
log "node_id " + istr(id);
|
||||
log_stmt(*s);
|
||||
vec::push(*res, id);
|
||||
vec::push(*rs, id);
|
||||
}
|
||||
case (_) { }
|
||||
}
|
||||
}
|
||||
|
||||
fn collect_ids_local(&@local l, @mutable vec[node_id] res) {
|
||||
vec::push(*res, l.node.id);
|
||||
fn collect_ids_local(&@local l, @mutable vec[node_id] rs) {
|
||||
vec::push(*rs, l.node.id);
|
||||
}
|
||||
|
||||
fn node_ids_in_fn(&_fn f, &span sp, &ident i, node_id id,
|
||||
@mutable vec[node_id] res) {
|
||||
@mutable vec[node_id] rs) {
|
||||
auto collect_ids = walk::default_visitor();
|
||||
collect_ids =
|
||||
rec(visit_expr_pre=bind collect_ids_expr(_, res),
|
||||
visit_block_pre=bind collect_ids_block(_, res),
|
||||
visit_stmt_pre=bind collect_ids_stmt(_, res),
|
||||
visit_local_pre=bind collect_ids_local(_, res) with collect_ids);
|
||||
rec(visit_expr_pre=bind collect_ids_expr(_, rs),
|
||||
visit_block_pre=bind collect_ids_block(_, rs),
|
||||
visit_stmt_pre=bind collect_ids_stmt(_, rs),
|
||||
visit_local_pre=bind collect_ids_local(_, rs) with collect_ids);
|
||||
walk::walk_fn(collect_ids, f, sp, i, id);
|
||||
}
|
||||
|
||||
|
@ -49,17 +49,17 @@ import pretty::ppaux::lit_to_str;
|
||||
fn def_id_to_str(def_id d) -> str { ret istr(d._0) + "," + istr(d._1); }
|
||||
|
||||
fn comma_str(vec[@constr_arg_use] args) -> str {
|
||||
auto res = "";
|
||||
auto rslt = "";
|
||||
auto comma = false;
|
||||
for (@constr_arg_use a in args) {
|
||||
if (comma) { res += ", "; } else { comma = true; }
|
||||
if (comma) { rslt += ", "; } else { comma = true; }
|
||||
alt (a.node) {
|
||||
case (carg_base) { res += "*"; }
|
||||
case (carg_ident(?i)) { res += i._0; }
|
||||
case (carg_lit(?l)) { res += lit_to_str(l); }
|
||||
case (carg_base) { rslt += "*"; }
|
||||
case (carg_ident(?i)) { rslt += i._0; }
|
||||
case (carg_lit(?l)) { rslt += lit_to_str(l); }
|
||||
}
|
||||
}
|
||||
ret res;
|
||||
ret rslt;
|
||||
}
|
||||
|
||||
fn constraint_to_str(&ty::ctxt tcx, &constr c) -> str {
|
||||
@ -120,11 +120,11 @@ fn first_difference_string(&fn_ctxt fcx, &tritv::t expected, &tritv::t actual)
|
||||
fn log_tritv_err(fn_ctxt fcx, tritv::t v) { log_err tritv_to_str(fcx, v); }
|
||||
|
||||
fn tos(vec[uint] v) -> str {
|
||||
auto res = "";
|
||||
for (uint i in v) { if (i == 0u) { res += "0"; }
|
||||
else if (i == 1u) { res += "1"; }
|
||||
else { res += "?"; } }
|
||||
ret res;
|
||||
auto rslt = "";
|
||||
for (uint i in v) { if (i == 0u) { rslt += "0"; }
|
||||
else if (i == 1u) { rslt += "1"; }
|
||||
else { rslt += "?"; } }
|
||||
ret rslt;
|
||||
}
|
||||
|
||||
fn log_cond(vec[uint] v) { log tos(v); }
|
||||
@ -497,15 +497,15 @@ fn norm_a_constraint(node_id id, &constraint c) -> vec[norm_constraint] {
|
||||
ret [rec(bit_num=n, c=respan(sp, rec(id=id, c=ninit(i))))];
|
||||
}
|
||||
case (cpred(?p, ?descs)) {
|
||||
let vec[norm_constraint] res = [];
|
||||
let vec[norm_constraint] rslt = [];
|
||||
for (pred_desc pd in *descs) {
|
||||
vec::push(res,
|
||||
vec::push(rslt,
|
||||
rec(bit_num=pd.node.bit_num,
|
||||
c=respan(pd.span,
|
||||
rec(id=id,
|
||||
c=npred(p, pd.node.args)))));
|
||||
}
|
||||
ret res;
|
||||
ret rslt;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -514,11 +514,11 @@ fn norm_a_constraint(node_id id, &constraint c) -> vec[norm_constraint] {
|
||||
// Tried to write this as an iterator, but I got a
|
||||
// non-exhaustive match in trans.
|
||||
fn constraints(&fn_ctxt fcx) -> vec[norm_constraint] {
|
||||
let vec[norm_constraint] res = [];
|
||||
let vec[norm_constraint] rslt = [];
|
||||
for each (@tup(node_id, constraint) p in fcx.enclosing.constrs.items()) {
|
||||
res += norm_a_constraint(p._0, p._1);
|
||||
rslt += norm_a_constraint(p._0, p._1);
|
||||
}
|
||||
ret res;
|
||||
ret rslt;
|
||||
}
|
||||
|
||||
fn match_args(&fn_ctxt fcx, vec[pred_desc] occs, vec[@constr_arg_use] occ) ->
|
||||
@ -617,11 +617,11 @@ fn pred_desc_to_str(&pred_desc p) -> str {
|
||||
|
||||
fn substitute_constr_args(&ty::ctxt cx, &vec[@expr] actuals,
|
||||
&@ty::constr_def c) -> constr__ {
|
||||
let vec[@constr_arg_use] res = [];
|
||||
let vec[@constr_arg_use] rslt = [];
|
||||
for (@constr_arg a in c.node.args) {
|
||||
res += [substitute_arg(cx, actuals, a)];
|
||||
rslt += [substitute_arg(cx, actuals, a)];
|
||||
}
|
||||
ret npred(c.node.path, res);
|
||||
ret npred(c.node.path, rslt);
|
||||
}
|
||||
|
||||
type subst = vec[tup(arg, @expr)];
|
||||
|
@ -43,10 +43,10 @@ import tritv::*;
|
||||
|
||||
fn bit_num(&fn_ctxt fcx, &constr_ c) -> uint {
|
||||
assert (fcx.enclosing.constrs.contains_key(c.id));
|
||||
auto res = fcx.enclosing.constrs.get(c.id);
|
||||
auto rslt = fcx.enclosing.constrs.get(c.id);
|
||||
alt (c.c) {
|
||||
case (ninit(_)) {
|
||||
alt (res) {
|
||||
alt (rslt) {
|
||||
case (cinit(?n, _, _)) { ret n; }
|
||||
case (_) {
|
||||
fcx.ccx.tcx.sess.bug("bit_num: asked for init constraint,"
|
||||
@ -55,7 +55,7 @@ fn bit_num(&fn_ctxt fcx, &constr_ c) -> uint {
|
||||
}
|
||||
}
|
||||
case (npred(_, ?args)) {
|
||||
alt (res) {
|
||||
alt (rslt) {
|
||||
case (cpred(_, ?descs)) { ret match_args(fcx, *descs, args); }
|
||||
case (_) {
|
||||
fcx.ccx.tcx.sess.bug("bit_num: asked for pred constraint,"
|
||||
@ -166,11 +166,11 @@ fn gen(&fn_ctxt fcx, node_id id, &constr_ c) -> bool {
|
||||
}
|
||||
|
||||
fn declare_var(&fn_ctxt fcx, &constr_ c, prestate pre) -> prestate {
|
||||
auto res = clone(pre);
|
||||
relax_prestate(bit_num(fcx, c), res);
|
||||
auto rslt = clone(pre);
|
||||
relax_prestate(bit_num(fcx, c), rslt);
|
||||
// idea is this is scoped
|
||||
relax_poststate(bit_num(fcx, c), res);
|
||||
ret res;
|
||||
relax_poststate(bit_num(fcx, c), rslt);
|
||||
ret rslt;
|
||||
}
|
||||
|
||||
fn relax_precond_block_non_recursive(&fn_ctxt fcx, node_id i, &block b) {
|
||||
|
@ -123,12 +123,12 @@ fn mk_fn_info(&crate_ctxt ccx, &_fn f, &span f_sp, &ident f_name,
|
||||
|
||||
add_constraint(cx.tcx, respan(f_sp, rec(id=id, c=ninit(f_name))), next,
|
||||
res_map);
|
||||
auto res =
|
||||
auto rslt =
|
||||
rec(constrs=res_map,
|
||||
num_constraints=vec::len(*cx.cs) + 1u,
|
||||
cf=f.decl.cf);
|
||||
ccx.fm.insert(id, res);
|
||||
log f_name + " has " + uistr(num_constraints(res)) + " constraints";
|
||||
ccx.fm.insert(id, rslt);
|
||||
log f_name + " has " + uistr(num_constraints(rslt)) + " constraints";
|
||||
}
|
||||
|
||||
|
||||
|
@ -314,8 +314,8 @@ fn find_pre_post_expr(&fn_ctxt fcx, @expr e) {
|
||||
find_pre_post_exprs(fcx, elt_exprs(elts), e.id);
|
||||
}
|
||||
case (expr_path(?p)) {
|
||||
auto res = expr_pp(fcx.ccx, e);
|
||||
clear_pp(res);
|
||||
auto rslt = expr_pp(fcx.ccx, e);
|
||||
clear_pp(rslt);
|
||||
auto df = node_id_to_def_strict(fcx.ccx.tcx, e.id);
|
||||
alt (df) {
|
||||
case (def_local(?d_id)) {
|
||||
@ -323,7 +323,7 @@ fn find_pre_post_expr(&fn_ctxt fcx, @expr e) {
|
||||
bit_num(fcx,
|
||||
rec(id=d_id._1,
|
||||
c=ninit(path_to_ident(fcx.ccx.tcx, p))));
|
||||
require_and_preserve(i, res);
|
||||
require_and_preserve(i, rslt);
|
||||
}
|
||||
case (_) {/* nothing to check */ }
|
||||
}
|
||||
|
@ -102,10 +102,10 @@ fn seq_states(&fn_ctxt fcx, prestate pres, vec[@expr] exprs) ->
|
||||
|
||||
fn find_pre_post_state_exprs(&fn_ctxt fcx, &prestate pres, ast::node_id id,
|
||||
&vec[@expr] es) -> bool {
|
||||
auto res = seq_states(fcx, pres, es);
|
||||
auto changed = res._0;
|
||||
auto rslt = seq_states(fcx, pres, es);
|
||||
auto changed = rslt._0;
|
||||
changed = extend_prestate_ann(fcx.ccx, id, pres) || changed;
|
||||
changed = extend_poststate_ann(fcx.ccx, id, res._1) || changed;
|
||||
changed = extend_poststate_ann(fcx.ccx, id, rslt._1) || changed;
|
||||
ret changed;
|
||||
}
|
||||
|
||||
|
@ -224,15 +224,15 @@ fn tritv_doesntcare(&t v) -> bool {
|
||||
|
||||
fn to_vec(&t v) -> vec[uint] {
|
||||
let uint i = 0u;
|
||||
let vec[uint] res = [];
|
||||
let vec[uint] rslt = [];
|
||||
while (i < v.nbits) {
|
||||
res += [alt (tritv_get(v, i)) {
|
||||
rslt += [alt (tritv_get(v, i)) {
|
||||
case (dont_care) { 2u }
|
||||
case (ttrue) { 1u }
|
||||
case (tfalse) { 0u } }];
|
||||
i += 1u;
|
||||
}
|
||||
ret res;
|
||||
ret rslt;
|
||||
}
|
||||
//
|
||||
// Local Variables:
|
||||
|
@ -1956,7 +1956,7 @@ mod unify {
|
||||
case (ures_ok(?unified_type)) {
|
||||
result_type = unified_type;
|
||||
}
|
||||
case (?res) { ret res; }
|
||||
case (?rs) { ret rs; }
|
||||
}
|
||||
}
|
||||
case (none) {/* fall through */ }
|
||||
@ -2179,7 +2179,7 @@ mod unify {
|
||||
// Just bind the type variable to the expected type.
|
||||
alt (record_var_binding(cx, actual_id, expected)) {
|
||||
case (ures_ok(_)) {/* fall through */ }
|
||||
case (?res) { ret res; }
|
||||
case (?rs) { ret rs; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2193,7 +2193,7 @@ mod unify {
|
||||
|
||||
alt (record_var_binding(cx, expected_id, actual)) {
|
||||
case (ures_ok(_)) {/* fall through */ }
|
||||
case (?res) { ret res; }
|
||||
case (?rs) { ret rs; }
|
||||
}
|
||||
ret ures_ok(mk_var(cx.tcx, expected_id));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user