rustc: Don't recurse in seq_preconds. Consumes too much stack

This commit is contained in:
Brian Anderson 2012-05-18 14:28:34 -07:00
parent afca68b820
commit 3f283bb168
2 changed files with 2020 additions and 15 deletions

View File

@ -82,23 +82,26 @@ fn seq_preconds(fcx: fn_ctxt, pps: [pre_and_post]) -> precond {
fn seq_preconds_go(fcx: fn_ctxt, pps: [pre_and_post], first: pre_and_post)
-> precond {
let sz: uint = vec::len(pps);
if sz >= 1u {
let second = pps[0];
assert (pps_len(second) == num_constraints(fcx.enclosing));
let second_pre = clone(second.precondition);
difference(second_pre, first.postcondition);
let next_first = clone(first.precondition);
union(next_first, second_pre);
let next_first_post = clone(first.postcondition);
seq_tritv(next_first_post, second.postcondition);
ret seq_preconds_go(fcx, vec::slice(pps, 1u, sz),
@{precondition: next_first,
postcondition: next_first_post});
} else { ret first.precondition; }
let mut pps = pps;
let mut first = first;
loop {
let sz: uint = vec::len(pps);
if sz >= 1u {
let second = pps[0];
assert (pps_len(second) == num_constraints(fcx.enclosing));
let second_pre = clone(second.precondition);
difference(second_pre, first.postcondition);
let next_first = clone(first.precondition);
union(next_first, second_pre);
let next_first_post = clone(first.postcondition);
seq_tritv(next_first_post, second.postcondition);
pps = vec::slice(pps, 1u, sz);
first = @{precondition: next_first,
postcondition: next_first_post};
} else { ret first.precondition; }
}
}
if sz >= 1u {
let first = pps[0];
assert (pps_len(first) == num_vars);

File diff suppressed because it is too large Load Diff