Kill unused variables
This commit is contained in:
parent
a0cdb23892
commit
d8db9a0fe1
@ -137,7 +137,6 @@ mod write {
|
||||
if (is_object_or_assembly_or_exe(opts.output_type)) {
|
||||
let int LLVMAssemblyFile = 0;
|
||||
let int LLVMObjectFile = 1;
|
||||
let int LLVMNullFile = 2;
|
||||
let int LLVMOptNone = 0; // -O0
|
||||
let int LLVMOptLess = 1; // -O1
|
||||
let int LLVMOptDefault = 2; // -O2, -Os
|
||||
|
@ -138,7 +138,6 @@ fn noop_fold_crate(&crate_ c, ast_fold fld) -> crate_ {
|
||||
|
||||
fn noop_fold_crate_directive(&crate_directive_ cd, ast_fold fld)
|
||||
-> crate_directive_ {
|
||||
auto fold_meta_item = bind fold_meta_item_(_,fld);
|
||||
ret alt(cd) {
|
||||
case(cdir_expr(?e)) { cdir_expr(fld.fold_expr(e)) }
|
||||
case(cdir_let(?id, ?e, ?cds)) {
|
||||
|
@ -148,7 +148,6 @@ fn consume_block_comment(&reader rdr) {
|
||||
|
||||
fn digits_to_string(str s) -> int {
|
||||
let int accum_int = 0;
|
||||
let int i = 0;
|
||||
for (u8 c in s) {
|
||||
accum_int *= 10;
|
||||
accum_int += dec_digit_val(c as char);
|
||||
|
@ -456,7 +456,7 @@ fn parse_ty(&parser p) -> @ast::ty {
|
||||
let ast::ty_ t;
|
||||
// FIXME: do something with this
|
||||
|
||||
let ast::layer lyr = parse_layer(p);
|
||||
parse_layer(p);
|
||||
if (eat_word(p, "bool")) {
|
||||
t = ast::ty_bool;
|
||||
} else if (eat_word(p, "int")) {
|
||||
@ -863,15 +863,12 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
|
||||
ex = ast::expr_fail(msg);
|
||||
} else if (eat_word(p, "log")) {
|
||||
auto e = parse_expr(p);
|
||||
auto hi = e.span.hi;
|
||||
ex = ast::expr_log(1, e);
|
||||
} else if (eat_word(p, "log_err")) {
|
||||
auto e = parse_expr(p);
|
||||
auto hi = e.span.hi;
|
||||
ex = ast::expr_log(0, e);
|
||||
} else if (eat_word(p, "assert")) {
|
||||
auto e = parse_expr(p);
|
||||
auto hi = e.span.hi;
|
||||
ex = ast::expr_assert(e);
|
||||
} else if (eat_word(p, "check")) {
|
||||
/* Should be a predicate (pure boolean function) applied to
|
||||
@ -879,7 +876,6 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
|
||||
but the typechecker enforces that. */
|
||||
|
||||
auto e = parse_expr(p);
|
||||
auto hi = e.span.hi;
|
||||
ex = ast::expr_check(ast::checked, e);
|
||||
} else if (eat_word(p, "claim")) {
|
||||
/* Same rules as check, except that if check-claims
|
||||
@ -887,7 +883,6 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
|
||||
claims into check */
|
||||
|
||||
auto e = parse_expr(p);
|
||||
auto hi = e.span.hi;
|
||||
ex = ast::expr_check(ast::unchecked, e);
|
||||
} else if (eat_word(p, "ret")) {
|
||||
alt (p.peek()) {
|
||||
@ -1253,7 +1248,6 @@ fn parse_if_expr_1(&parser p) -> tup(@ast::expr,
|
||||
}
|
||||
|
||||
fn parse_if_expr(&parser p) -> @ast::expr {
|
||||
auto lo = p.get_last_lo_pos();
|
||||
if (eat_word(p, "check")) {
|
||||
auto q = parse_if_expr_1(p);
|
||||
ret mk_expr(p, q._3, q._4, ast::expr_if_check(q._0, q._1, q._2));
|
||||
@ -1282,7 +1276,6 @@ fn parse_else_expr(&parser p) -> @ast::expr {
|
||||
}
|
||||
|
||||
fn parse_head_local(&parser p) -> @ast::local {
|
||||
auto lo = p.get_lo_pos();
|
||||
if (is_word(p, "auto")) {
|
||||
ret parse_auto_local(p);
|
||||
} else {
|
||||
@ -1507,11 +1500,9 @@ fn parse_source_stmt(&parser p) -> @ast::stmt {
|
||||
auto lo = p.get_lo_pos();
|
||||
if (eat_word(p, "let")) {
|
||||
auto decl = parse_let(p);
|
||||
auto hi = p.get_span();
|
||||
ret @spanned(lo, decl.span.hi, ast::stmt_decl(decl, p.get_id()));
|
||||
} else if (eat_word(p, "auto")) {
|
||||
auto decl = parse_auto(p);
|
||||
auto hi = p.get_span();
|
||||
ret @spanned(lo, decl.span.hi, ast::stmt_decl(decl, p.get_id()));
|
||||
} else {
|
||||
|
||||
@ -1918,7 +1909,7 @@ fn parse_item_native_fn(&parser p) -> @ast::native_item {
|
||||
}
|
||||
|
||||
fn parse_native_item(&parser p) -> @ast::native_item {
|
||||
let ast::layer lyr = parse_layer(p);
|
||||
parse_layer(p);
|
||||
if (eat_word(p, "type")) {
|
||||
ret parse_item_native_type(p);
|
||||
} else if (eat_word(p, "fn")) {
|
||||
@ -2010,7 +2001,7 @@ fn parse_item_tag(&parser p, vec[ast::attribute] attrs) -> @ast::item {
|
||||
}
|
||||
auto vhi = p.get_hi_pos();
|
||||
expect(p, token::SEMI);
|
||||
auto id = p.get_id();
|
||||
p.get_id();
|
||||
auto vr =
|
||||
rec(name=p.get_str(name),
|
||||
args=args,
|
||||
|
@ -93,7 +93,6 @@ fn item_type(&ebml::doc item, int this_cnum, ty::ctxt tcx) -> ty::t {
|
||||
ret tup(this_cnum, external_def_id._1);
|
||||
}
|
||||
auto tp = ebml::get_doc(item, tag_items_data_item_type);
|
||||
auto s = str::unsafe_from_bytes(ebml::doc_data(tp));
|
||||
ret parse_ty_data(item.data, this_cnum, tp.start, tp.end - tp.start,
|
||||
bind parse_external_def_id(this_cnum, _), tcx);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ fn parse_ty_data(vec[u8] data, int crate_num, uint pos, uint len, str_def sd,
|
||||
|
||||
fn parse_ty_or_bang(@pstate st, str_def sd) -> ty_or_bang {
|
||||
alt (peek(st) as char) {
|
||||
case ('!') { auto ignore = next(st); ret a_bang[ty::t]; }
|
||||
case ('!') { next(st); ret a_bang[ty::t]; }
|
||||
case (_) { ret a_ty[ty::t](parse_ty(st, sd)); }
|
||||
}
|
||||
}
|
||||
@ -74,7 +74,7 @@ fn parse_constrs(@pstate st, str_def sd) -> vec[@ty::constr_def] {
|
||||
alt (peek(st) as char) {
|
||||
case (':') {
|
||||
do {
|
||||
auto ignore = next(st);
|
||||
next(st);
|
||||
vec::push(rslt, parse_constr(st, sd));
|
||||
} while (peek(st) as char == ';')
|
||||
}
|
||||
@ -91,10 +91,7 @@ fn parse_path(@pstate st, str_def sd) -> ast::path {
|
||||
idents += [parse_ident_(st, sd, is_last)];
|
||||
while (true) {
|
||||
alt (peek(st) as char) {
|
||||
case (':') {
|
||||
auto ignore = next(st);
|
||||
ignore = next(st);
|
||||
}
|
||||
case (':') { next(st); next(st); }
|
||||
case (?c) {
|
||||
if (c == '(') {
|
||||
ret respan(rec(lo=0u, hi=0u),
|
||||
|
@ -61,7 +61,7 @@ fn enc_ty(&io::writer w, &@ctxt cx, &ty::t t) {
|
||||
case (some(?a)) { w.write_str(a.s); ret; }
|
||||
case (none) {
|
||||
auto pos = w.get_buf_writer().tell();
|
||||
auto ss = enc_sty(w, cx, ty::struct(cx.tcx, t));
|
||||
enc_sty(w, cx, ty::struct(cx.tcx, t));
|
||||
auto end = w.get_buf_writer().tell();
|
||||
auto len = end - pos;
|
||||
fn estimate_sz(uint u) -> uint {
|
||||
|
@ -392,7 +392,6 @@ fn check_lval(&@ctx cx, &@ast::expr dest, &scope sc, &vt[scope] v) {
|
||||
cx.tcx.sess.span_fatal(dest.span,
|
||||
"assigning to immutable obj field");
|
||||
}
|
||||
auto var_t = ty::expr_ty(*cx.tcx, dest);
|
||||
for (restrict r in sc) {
|
||||
if (vec::member(dnum, r.root_vars)) {
|
||||
r.ok = overwritten(dest.span, p);
|
||||
|
@ -766,7 +766,6 @@ fn type_of_native_fn(&@crate_ctxt cx, &span sp, ast::native_abi abi,
|
||||
let vec[TypeRef] atys = [];
|
||||
if (abi == ast::native_abi_rust) {
|
||||
atys += [T_taskptr(cx.tn)];
|
||||
auto t = ty::ty_native_fn(abi, inputs, output);
|
||||
auto i = 0u;
|
||||
while (i < ty_param_count) {
|
||||
atys += [T_ptr(T_tydesc(cx.tn))];
|
||||
@ -2684,7 +2683,6 @@ fn iter_structural_ty_full(&@block_ctxt cx, ValueRef av, ValueRef bv,
|
||||
case (ty::ty_fn(_, ?args, _, _, _)) {
|
||||
auto j = 0;
|
||||
for (ty::arg a in args) {
|
||||
auto v = [C_int(0), C_int(j as int)];
|
||||
auto rslt =
|
||||
GEP_tag(variant_cx, llunion_a_ptr, tid,
|
||||
variant.id, tps, j);
|
||||
@ -3636,8 +3634,7 @@ mod ivec {
|
||||
auto p = stack_spill_cx.build.InBoundsGEP(spill_stub, stub_p);
|
||||
stack_spill_cx.build.Load(p)
|
||||
};
|
||||
auto heap_len_ptr_spill =
|
||||
{
|
||||
{
|
||||
auto v = [C_int(0), C_uint(abi::ivec_heap_elt_len)];
|
||||
stack_spill_cx.build.InBoundsGEP(heap_ptr_spill, v)
|
||||
};
|
||||
@ -3673,10 +3670,9 @@ mod ivec {
|
||||
|
||||
auto unit_ty = ty::sequence_element_type(cx.fcx.lcx.ccx.tcx, t);
|
||||
auto llunitty = type_of_or_i8(cx, unit_ty);
|
||||
auto skip_null;
|
||||
alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
|
||||
case (ty::ty_istr) { skip_null = true; }
|
||||
case (ty::ty_ivec(_)) { skip_null = false; }
|
||||
case (ty::ty_istr) { }
|
||||
case (ty::ty_ivec(_)) { }
|
||||
case (_) {
|
||||
cx.fcx.lcx.ccx.tcx.sess.bug("non-istr/ivec in trans_append");
|
||||
}
|
||||
@ -3692,10 +3688,8 @@ mod ivec {
|
||||
auto no_tydesc_info = none;
|
||||
|
||||
rs = get_tydesc(bcx, t, false, no_tydesc_info);
|
||||
auto vec_tydesc = rs.val;
|
||||
bcx = rs.bcx;
|
||||
rs = get_tydesc(bcx, unit_ty, false, no_tydesc_info);
|
||||
auto unit_tydesc = rs.val;
|
||||
bcx = rs.bcx;
|
||||
lazily_emit_tydesc_glue(bcx, abi::tydesc_field_copy_glue, none);
|
||||
lazily_emit_tydesc_glue(bcx, abi::tydesc_field_drop_glue, none);
|
||||
@ -4516,7 +4510,6 @@ fn trans_for_each(&@block_ctxt cx, &@ast::local local, &@ast::expr seq,
|
||||
auto decl_ty = node_id_type(lcx.ccx, local.node.id);
|
||||
auto decl_id = local.node.id;
|
||||
auto upvars = collect_upvars(cx, body, decl_id);
|
||||
auto upvar_count = vec::len(upvars);
|
||||
|
||||
auto environment_data = build_environment(cx, upvars);
|
||||
auto llenvptr = environment_data._0;
|
||||
@ -4791,7 +4784,6 @@ fn lval_generic_fn(&@block_ctxt cx, &ty::ty_param_count_and_ty tpt,
|
||||
lv = trans_external_path(cx, fn_id, tpt);
|
||||
}
|
||||
auto tys = ty::node_id_to_type_params(cx.fcx.lcx.ccx.tcx, id);
|
||||
auto monoty = ty::node_id_to_type(cx.fcx.lcx.ccx.tcx, id);
|
||||
if (vec::len[ty::t](tys) != 0u) {
|
||||
auto bcx = lv.res.bcx;
|
||||
let vec[ValueRef] tydescs = [];
|
||||
@ -5299,7 +5291,7 @@ fn trans_bind_thunk(&@local_ctxt cx, &span sp, &ty::t incoming_fty,
|
||||
outgoing_args, outgoing_ret_ty, ty_param_count);
|
||||
lltargetfn = bcx.build.PointerCast(lltargetfn, T_ptr(T_ptr(lltargetty)));
|
||||
lltargetfn = bcx.build.Load(lltargetfn);
|
||||
auto r = bcx.build.FastCall(lltargetfn, llargs);
|
||||
bcx.build.FastCall(lltargetfn, llargs);
|
||||
bcx.build.RetVoid();
|
||||
finish_fn(fcx, lltop);
|
||||
ret llthunk;
|
||||
@ -6459,7 +6451,6 @@ fn trans_port(&@block_ctxt cx, ast::node_id id) -> result {
|
||||
case (ty::ty_port(?t)) { unit_ty = t; }
|
||||
case (_) { cx.fcx.lcx.ccx.sess.bug("non-port type in trans_port"); }
|
||||
}
|
||||
auto llunit_ty = type_of(cx.fcx.lcx.ccx, cx.sp, unit_ty);
|
||||
auto bcx = cx;
|
||||
auto unit_sz = size_of(bcx, unit_ty);
|
||||
bcx = unit_sz.bcx;
|
||||
@ -6587,7 +6578,6 @@ fn trans_spawn(&@block_ctxt cx, &ast::spawn_dom dom, &option::t[str] name,
|
||||
fn mk_spawn_wrapper(&@block_ctxt cx, &@ast::expr func, &ty::t args_ty) ->
|
||||
result {
|
||||
auto llmod = cx.fcx.lcx.ccx.llmod;
|
||||
let TypeRef args_ty_tref = type_of(cx.fcx.lcx.ccx, cx.sp, args_ty);
|
||||
let TypeRef wrapper_fn_type =
|
||||
type_of_fn(cx.fcx.lcx.ccx, cx.sp, ast::proto_fn,
|
||||
[rec(mode=ty::mo_alias(false), ty=args_ty)], ty::idx_nil,
|
||||
@ -6669,8 +6659,6 @@ fn deep_copy(&@block_ctxt bcx, ValueRef v, ty::t t, ValueRef target_task)
|
||||
}
|
||||
else if(ty::type_is_structural(tcx, t)) {
|
||||
fn inner_deep_copy(&@block_ctxt bcx, ValueRef v, ty::t t) -> result {
|
||||
auto tcx = bcx.fcx.lcx.ccx.tcx;
|
||||
|
||||
log_err "Unimplemented type for deep_copy.";
|
||||
fail;
|
||||
}
|
||||
@ -6841,7 +6829,6 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
|
||||
|
||||
// If with_obj (the object being extended) exists, translate it, producing
|
||||
// a result.
|
||||
let option::t[result] with_obj_val = none;
|
||||
let ty::t with_obj_ty = ty::mk_type(ccx.tcx);
|
||||
let TypeRef llwith_obj_ty;
|
||||
auto vtbl;
|
||||
@ -6857,7 +6844,7 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
|
||||
case (some(?e)) {
|
||||
// Translating with_obj returns a ValueRef (pointer to a 2-word
|
||||
// value) wrapped in a result.
|
||||
with_obj_val = some[result](trans_expr(bcx, e));
|
||||
trans_expr(bcx, e);
|
||||
|
||||
// TODO: What makes more sense to get the type of an expr --
|
||||
// calling ty::expr_ty(ccx.tcx, e) on it or calling
|
||||
@ -6992,7 +6979,7 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
|
||||
// FIXME (part of issue #538): make this work eventually, when we
|
||||
// have additional field exprs in the AST.
|
||||
|
||||
auto field_val = load_if_immediate(
|
||||
load_if_immediate(
|
||||
bcx,
|
||||
additional_field_vals.(i).val,
|
||||
additional_field_tys.(i));
|
||||
@ -7992,7 +7979,6 @@ fn trans_const_expr(&@crate_ctxt cx, @ast::expr e) -> ValueRef {
|
||||
}
|
||||
|
||||
fn trans_const(&@crate_ctxt cx, @ast::expr e, ast::node_id id) {
|
||||
auto t = node_id_type(cx, id);
|
||||
auto v = trans_const_expr(cx, e);
|
||||
// The scalars come back as 1st class LLVM vals
|
||||
// which we have to stick into global constants.
|
||||
@ -8179,15 +8165,9 @@ fn decl_native_fn_and_pair(&@crate_ctxt ccx, &span sp, vec[str] path,
|
||||
auto lltop = bcx.llbb;
|
||||
// Declare the function itself.
|
||||
|
||||
auto item = alt (ccx.ast_map.get(id)) {
|
||||
case (ast_map::node_native_item(?i)) { i }
|
||||
};
|
||||
auto fn_type = node_id_type(ccx, id); // NB: has no type params
|
||||
|
||||
auto abi = ty::ty_fn_abi(ccx.tcx, fn_type);
|
||||
auto llfnty =
|
||||
type_of_native_fn(ccx, sp, abi, ty::ty_fn_args(ccx.tcx, fn_type),
|
||||
ty::ty_fn_ret(ccx.tcx, fn_type), num_ty_param);
|
||||
// FIXME: If the returned type is not nil, then we assume it's 32 bits
|
||||
// wide. This is obviously wildly unsafe. We should have a better FFI
|
||||
// that allows types of different sizes to be returned.
|
||||
@ -8561,11 +8541,11 @@ fn make_common_glue(&session::session sess, &str output) {
|
||||
llvm::LLVMGetGlobalContext());
|
||||
llvm::LLVMSetDataLayout(llmod, str::buf(x86::get_data_layout()));
|
||||
llvm::LLVMSetTarget(llmod, str::buf(x86::get_target_triple()));
|
||||
auto td = mk_target_data(x86::get_data_layout());
|
||||
mk_target_data(x86::get_data_layout());
|
||||
auto tn = mk_type_names();
|
||||
auto intrinsics = declare_intrinsics(llmod);
|
||||
declare_intrinsics(llmod);
|
||||
llvm::LLVMSetModuleInlineAsm(llmod, str::buf(x86::get_module_asm()));
|
||||
auto glues = make_glues(llmod, tn);
|
||||
make_glues(llmod, tn);
|
||||
link::write::run_passes(sess, llmod, output);
|
||||
}
|
||||
|
||||
@ -8686,7 +8666,7 @@ fn trans_crate(&session::session sess, &@ast::crate crate, &ty::ctxt tcx,
|
||||
collect_tag_ctors(ccx, crate);
|
||||
trans_constants(ccx, crate);
|
||||
trans_mod(cx, crate.node.module);
|
||||
auto crate_map = create_crate_map(ccx);
|
||||
create_crate_map(ccx);
|
||||
emit_tydescs(ccx);
|
||||
// Translate the metadata:
|
||||
|
||||
|
@ -97,7 +97,6 @@ fn log_tritv(&fn_ctxt fcx, &tritv::t v) { log tritv_to_str(fcx, v); }
|
||||
fn first_difference_string(&fn_ctxt fcx, &tritv::t expected, &tritv::t actual)
|
||||
-> str {
|
||||
let str s = "";
|
||||
auto done = false;
|
||||
for (norm_constraint c in constraints(fcx)) {
|
||||
if (tritv_get(expected, c.bit_num) == ttrue &&
|
||||
tritv_get(actual, c.bit_num) != ttrue) {
|
||||
|
@ -124,7 +124,8 @@ fn check_states_stmt(&fn_ctxt fcx, &@stmt s) {
|
||||
}
|
||||
}
|
||||
|
||||
fn check_states_against_conditions(&fn_ctxt fcx, &_fn f, &vec[ast::ty_param] tps,
|
||||
fn check_states_against_conditions(&fn_ctxt fcx, &_fn f,
|
||||
&vec[ast::ty_param] tps,
|
||||
node_id id, &span sp, &fn_ident i) {
|
||||
/* Postorder traversal instead of pre is important
|
||||
because we want the smallest possible erroneous statement
|
||||
|
@ -60,7 +60,8 @@ fn collect_pred(&@expr e, &ctxt cx, &visit::vt[ctxt] v) {
|
||||
visit::visit_expr(e, cx, v);
|
||||
}
|
||||
|
||||
fn do_nothing(&@item i, &ctxt ignore1, &visit::vt[ctxt] ignore) {
|
||||
fn do_nothing(&_fn f, &vec[ty_param] tp, &span sp, &fn_ident i,
|
||||
node_id iid, &ctxt cx, &visit::vt[ctxt] v) {
|
||||
}
|
||||
|
||||
fn find_locals(&ty::ctxt tcx, &_fn f, &vec[ast::ty_param] tps,
|
||||
@ -72,7 +73,7 @@ fn find_locals(&ty::ctxt tcx, &_fn f, &vec[ast::ty_param] tps,
|
||||
visitor =
|
||||
@rec(visit_local=collect_local,
|
||||
visit_expr=collect_pred,
|
||||
visit_item=do_nothing
|
||||
visit_fn=do_nothing
|
||||
with *visitor);
|
||||
visit::visit_fn(f, tps, sp, i, id, cx, visit::vtor(visitor));
|
||||
ret cx;
|
||||
@ -119,9 +120,6 @@ fn mk_fn_info(&crate_ctxt ccx, &_fn f, &vec[ast::ty_param] tp,
|
||||
node_id id) {
|
||||
auto res_map = @new_int_hash[constraint]();
|
||||
let uint next = 0u;
|
||||
let vec[arg] f_args = f.decl.inputs;
|
||||
/* ignore args, which we know are initialized;
|
||||
just collect locally declared vars */
|
||||
|
||||
let ctxt cx = find_locals(ccx.tcx, f, tp, f_sp, f_name, id);
|
||||
/* now we have to add bit nums for both the constraints
|
||||
|
@ -157,9 +157,6 @@ fn find_pre_post_exprs(&fn_ctxt fcx, &vec[@expr] args, node_id id) {
|
||||
log "find_pre_post_exprs: oper =";
|
||||
log_expr(*args.(0));
|
||||
}
|
||||
auto enclosing = fcx.enclosing;
|
||||
auto fm = fcx.ccx.fm;
|
||||
auto nv = num_constraints(enclosing);
|
||||
fn do_one(fn_ctxt fcx, &@expr e) { find_pre_post_expr(fcx, e); }
|
||||
auto f = bind do_one(fcx, _);
|
||||
vec::map[@expr, ()](f, args);
|
||||
@ -194,7 +191,6 @@ fn find_pre_post_loop(&fn_ctxt fcx, &@local l, &@expr index, &block body,
|
||||
// and alternative maybe_alt
|
||||
fn join_then_else(&fn_ctxt fcx, &@expr antec, &block conseq,
|
||||
&option::t[@expr] maybe_alt, node_id id, &if_ty chck) {
|
||||
auto num_local_vars = num_constraints(fcx.enclosing);
|
||||
find_pre_post_expr(fcx, antec);
|
||||
find_pre_post_block(fcx, conseq);
|
||||
alt (maybe_alt) {
|
||||
@ -580,8 +576,6 @@ fn find_pre_post_expr(&fn_ctxt fcx, @expr e) {
|
||||
fn find_pre_post_stmt(&fn_ctxt fcx, &stmt s) {
|
||||
log "stmt =";
|
||||
log_stmt(s);
|
||||
auto enclosing = fcx.enclosing;
|
||||
auto num_local_vars = num_constraints(enclosing);
|
||||
alt (s.node) {
|
||||
case (stmt_decl(?adecl, ?id)) {
|
||||
alt (adecl.node) {
|
||||
|
@ -670,7 +670,6 @@ fn find_pre_post_state_stmt(&fn_ctxt fcx, &prestate pres, @stmt s) -> bool {
|
||||
returns a boolean flag saying whether any pre- or poststates changed */
|
||||
fn find_pre_post_state_block(&fn_ctxt fcx, &prestate pres0, &block b)
|
||||
-> bool {
|
||||
auto num_local_vars = num_constraints(fcx.enclosing);
|
||||
/* First, set the pre-states and post-states for every expression */
|
||||
|
||||
auto pres = pres0;
|
||||
|
@ -689,7 +689,6 @@ fn walk_ty(&ctxt cx, ty_walk walker, t ty) {
|
||||
walk_ty(cx, walker, ret_ty);
|
||||
}
|
||||
case (ty_obj(?methods)) {
|
||||
let vec[method] new_methods = [];
|
||||
for (method m in methods) {
|
||||
for (arg a in m.inputs) { walk_ty(cx, walker, a.ty); }
|
||||
walk_ty(cx, walker, m.output);
|
||||
|
@ -133,7 +133,6 @@ fn instantiate_path(&@fn_ctxt fcx, &ast::path pth, &ty_param_count_and_ty tpt,
|
||||
bind_params_in_type(sp, fcx.ccx.tcx, bind next_ty_var_id(fcx), tpt._1,
|
||||
ty_param_count);
|
||||
auto ty_param_vars = bind_result._0;
|
||||
auto t = bind_result._1;
|
||||
auto ty_substs_opt;
|
||||
auto ty_substs_len = vec::len[@ast::ty](pth.node.types);
|
||||
if (ty_substs_len > 0u) {
|
||||
@ -260,7 +259,6 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
|
||||
params_opt_and_ty._1);
|
||||
ret typ;
|
||||
}
|
||||
auto mut = ast::imm;
|
||||
auto typ;
|
||||
auto cname = none[str];
|
||||
alt (ast_ty.node) {
|
||||
@ -691,12 +689,11 @@ mod collect {
|
||||
ty_params);
|
||||
}
|
||||
case (ast::item_obj(?object, ?ty_params, ?ctor_id)) {
|
||||
// This calls ty_of_obj().
|
||||
|
||||
auto t_obj = ty_of_item(cx, it);
|
||||
// Now we need to call ty_of_obj_ctor(); this is the type that
|
||||
// we write into the table for this item.
|
||||
|
||||
ty_of_item(cx, it);
|
||||
|
||||
auto tpt =
|
||||
ty_of_obj_ctor(cx, it.ident, object, ctor_id, ty_params);
|
||||
write::ty_only(cx.tcx, ctor_id, tpt._1);
|
||||
@ -924,7 +921,6 @@ fn are_compatible(&@fn_ctxt fcx, &ty::t expected, &ty::t actual) -> bool {
|
||||
// Returns the types of the arguments to a tag variant.
|
||||
fn variant_arg_types(&@crate_ctxt ccx, &span sp, &ast::def_id vid,
|
||||
&vec[ty::t] tag_ty_params) -> vec[ty::t] {
|
||||
auto ty_param_count = vec::len[ty::t](tag_ty_params);
|
||||
let vec[ty::t] result = [];
|
||||
auto tpt = ty::lookup_item_type(ccx.tcx, vid);
|
||||
alt (ty::struct(ccx.tcx, tpt._1)) {
|
||||
@ -1025,12 +1021,14 @@ mod writeback {
|
||||
fn visit_item_post(@mutable bool ignore, &@ast::item item) {
|
||||
*ignore = false;
|
||||
}
|
||||
fn visit_fn_pre(@mutable bool ignore, &ast::_fn f, &vec[ast::ty_param] tps,
|
||||
&span sp, &ast::fn_ident i, ast::node_id d) {
|
||||
fn visit_fn_pre(@mutable bool ignore, &ast::_fn f,
|
||||
&vec[ast::ty_param] tps, &span sp,
|
||||
&ast::fn_ident i, ast::node_id d) {
|
||||
*ignore = true;
|
||||
}
|
||||
fn visit_fn_post(@mutable bool ignore, &ast::_fn f, &vec[ast::ty_param] tps,
|
||||
&span sp, &ast::fn_ident i, ast::node_id d) {
|
||||
fn visit_fn_post(@mutable bool ignore, &ast::_fn f,
|
||||
&vec[ast::ty_param] tps, &span sp,
|
||||
&ast::fn_ident i, ast::node_id d) {
|
||||
*ignore = false;
|
||||
}
|
||||
fn keep_going(@mutable bool ignore) -> bool { ret !*ignore; }
|
||||
@ -1555,7 +1553,6 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
||||
write::ty_only_fixup(fcx, id, oper_t);
|
||||
}
|
||||
case (ast::expr_path(?pth)) {
|
||||
auto t = ty::mk_nil(fcx.ccx.tcx);
|
||||
auto defn = fcx.ccx.tcx.def_map.get(id);
|
||||
auto tpt = ty_param_count_and_ty_for_def(fcx, expr.span, defn);
|
||||
if (ty::def_has_ty_params(defn)) {
|
||||
@ -1627,7 +1624,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
||||
write::nil_ty(fcx.ccx.tcx, id);
|
||||
}
|
||||
case (ast::expr_log(?l, ?e)) {
|
||||
auto expr_t = check_expr(fcx, e);
|
||||
check_expr(fcx, e);
|
||||
write::nil_ty(fcx.ccx.tcx, id);
|
||||
}
|
||||
case (ast::expr_check(_, ?e)) {
|
||||
@ -1671,10 +1668,9 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
||||
check_expr(fcx, rhs);
|
||||
auto rhs_t = expr_ty(fcx.ccx.tcx, rhs);
|
||||
auto chan_t = ty::mk_chan(fcx.ccx.tcx, rhs_t);
|
||||
auto item_t;
|
||||
auto lhs_t = expr_ty(fcx.ccx.tcx, lhs);
|
||||
alt (structure_of(fcx, expr.span, lhs_t)) {
|
||||
case (ty::ty_chan(?it)) { item_t = it; }
|
||||
case (ty::ty_chan(?it)) { }
|
||||
case (_) {
|
||||
auto s = #fmt("mismatched types: expected chan \
|
||||
but found %s",
|
||||
@ -1755,7 +1751,6 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
||||
// Now typecheck the blocks.
|
||||
|
||||
auto result_ty = next_ty_var(fcx);
|
||||
let vec[ast::block] blocks = [];
|
||||
for (ast::arm arm in arms) {
|
||||
check_block(fcx, arm.block);
|
||||
auto bty = block_ty(fcx.ccx.tcx, arm.block);
|
||||
@ -2135,7 +2130,6 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
||||
this_obj=di));
|
||||
|
||||
// Typecheck 'with_obj', if it exists.
|
||||
let option::t[@ast::expr] with_obj = none[@ast::expr];
|
||||
alt (anon_obj.with_obj) {
|
||||
case (none) { }
|
||||
case (some(?e)) {
|
||||
@ -2192,7 +2186,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
||||
for (@ast::method method in anon_obj.methods) {
|
||||
check_method(fcx.ccx, method);
|
||||
}
|
||||
auto t = next_ty_var(fcx);
|
||||
next_ty_var(fcx);
|
||||
// Now remove the info from the stack.
|
||||
|
||||
vec::pop[obj_info](fcx.ccx.obj_infos);
|
||||
|
@ -39,8 +39,10 @@ type ast_visitor =
|
||||
fn(&@ast::ty) visit_ty_pre,
|
||||
fn(&@ast::ty) visit_ty_post,
|
||||
fn(&@ast::constr) visit_constr,
|
||||
fn(&ast::_fn, &vec[ast::ty_param], &span, &ast::fn_ident, ast::node_id) visit_fn_pre,
|
||||
fn(&ast::_fn, &vec[ast::ty_param], &span, &ast::fn_ident, ast::node_id) visit_fn_post);
|
||||
fn(&ast::_fn, &vec[ast::ty_param], &span, &ast::fn_ident,
|
||||
ast::node_id) visit_fn_pre,
|
||||
fn(&ast::_fn, &vec[ast::ty_param], &span, &ast::fn_ident,
|
||||
ast::node_id) visit_fn_post);
|
||||
|
||||
fn walk_crate(&ast_visitor v, &ast::crate c) {
|
||||
if (!v.keep_going()) { ret; }
|
||||
@ -387,8 +389,6 @@ fn walk_expr(&ast_visitor v, @ast::expr e) {
|
||||
case (ast::expr_anon_obj(?anon_obj, _, _)) {
|
||||
// Fields
|
||||
|
||||
let option::t[vec[ast::anon_obj_field]] fields =
|
||||
none[vec[ast::anon_obj_field]];
|
||||
alt (anon_obj.fields) {
|
||||
case (none) { }
|
||||
case (some(?fields)) {
|
||||
@ -400,7 +400,6 @@ fn walk_expr(&ast_visitor v, @ast::expr e) {
|
||||
}
|
||||
// with_obj
|
||||
|
||||
let option::t[@ast::expr] with_obj = none[@ast::expr];
|
||||
alt (anon_obj.with_obj) {
|
||||
case (none) { }
|
||||
case (some(?e)) { walk_expr(v, e); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user