Skip to content

Commit f3c6bd2

Browse files
committed
---
yaml --- r: 6849 b: refs/heads/master c: 41ae146 h: refs/heads/master i: 6847: 90af989 v: v3
1 parent 436ac95 commit f3c6bd2

File tree

6 files changed

+39
-16
lines changed

6 files changed

+39
-16
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: b2b2a430df33a234be62d97d7efc1f0a3d419b50
2+
refs/heads/master: 41ae146057431d99d5ab5c87d385dbf787a10ea2

trunk/src/comp/middle/trans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3551,7 +3551,7 @@ fn trans_expr(bcx: @block_ctxt, e: @ast::expr, dest: dest) -> @block_ctxt {
35513551
ret trans_unary(bcx, op, x, e.id, dest);
35523552
}
35533553
// NDM captures
3554-
ast::expr_fn(f, cap) {
3554+
ast::expr_fn(f, cap_clause) {
35553555
ret trans_closure::trans_expr_fn(bcx, f, e.span, e.id, dest);
35563556
}
35573557
ast::expr_bind(f, args) {

trunk/src/comp/middle/tstate/auxiliary.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,6 @@ fn copy_in_poststate_two(fcx: fn_ctxt, src_post: poststate,
865865
};
866866
}
867867

868-
869868
/* FIXME should refactor this better */
870869
fn forget_in_postcond(fcx: fn_ctxt, parent_exp: node_id, dead_v: node_id) {
871870
// In the postcondition given by parent_exp, clear the bits
@@ -875,6 +874,9 @@ fn forget_in_postcond(fcx: fn_ctxt, parent_exp: node_id, dead_v: node_id) {
875874
some(d_id) {
876875
for c: norm_constraint in constraints(fcx) {
877876
if constraint_mentions(fcx, c, d_id) {
877+
log ("clearing constraint ",
878+
c.bit_num,
879+
constraint_to_str(fcx.ccx.tcx, c.c));
878880
clear_in_postcond(c.bit_num,
879881
node_id_to_ts_ann(fcx.ccx,
880882
parent_exp).conditions);

trunk/src/comp/middle/tstate/ck.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import syntax::ast;
33
import ast::{_fn, stmt,
44
fn_ident, node_id, crate, return_val, noreturn,
55
expr};
6-
import syntax::visit;
6+
import syntax::{visit, print};
77
import syntax::codemap::span;
88
import middle::ty::{type_is_nil, ret_ty_of_fn};
99
import tstate::ann::{
@@ -73,14 +73,12 @@ fn check_states_stmt(s: @stmt, fcx: fn_ctxt, v: visit::vt<fn_ctxt>) {
7373
let pres: prestate = ann_prestate(a);
7474

7575

76-
/*
77-
log_err("check_states_stmt:");
78-
log_stmt_err(*s);
79-
log_err("prec = ");
80-
log_tritv_err(fcx, prec);
81-
log_err("pres = ");
82-
log_tritv_err(fcx, pres);
83-
*/
76+
log("check_states_stmt:");
77+
log print::pprust::stmt_to_str(*s);
78+
log("prec = ");
79+
log_tritv(fcx, prec);
80+
log("pres = ");
81+
log_tritv(fcx, pres);
8482

8583
if !implies(pres, prec) {
8684
let ss = "";

trunk/src/comp/middle/tstate/pre_post_conditions.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,13 +339,21 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
339339
find_pre_post_expr(fcx, arg);
340340
copy_pre_post(fcx.ccx, e.id, arg);
341341
}
342-
expr_fn(f, _) { // NDM captures
342+
expr_fn(f, cap_clause) {
343343
let rslt = expr_pp(fcx.ccx, e);
344344
clear_pp(rslt);
345-
for @{def, span} in *freevars::get_freevars(fcx.ccx.tcx, e.id) {
345+
for def in *freevars::get_freevars(fcx.ccx.tcx, e.id) {
346346
log ("handle_var_def: def=", def);
347-
handle_var_def(fcx, rslt, def, "upvar");
347+
handle_var_def(fcx, rslt, def.def, "upvar");
348348
}
349+
350+
vec::iter(cap_clause.moves) { |cap_item|
351+
log ("forget_in_postcond: ", cap_item);
352+
forget_in_postcond(fcx, e.id, cap_item.id);
353+
}
354+
355+
let ann = node_id_to_ts_ann(fcx.ccx, e.id);
356+
log_cond(tritv::to_vec(ann.conditions.postcondition));
349357
}
350358
expr_block(b) {
351359
find_pre_post_block(fcx, b);

trunk/src/comp/middle/tstate/states.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,19 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk,
320320
ret changed;
321321
}
322322

323+
fn find_pre_post_state_cap_clause(fcx: fn_ctxt, e_id: node_id,
324+
pres: prestate, cap_clause: capture_clause)
325+
-> bool
326+
{
327+
let ccx = fcx.ccx;
328+
let pres_changed = set_prestate_ann(ccx, e_id, pres);
329+
let post = tritv_clone(pres);
330+
vec::iter(cap_clause.moves) { |cap_item|
331+
forget_in_poststate(fcx, post, cap_item.id);
332+
}
333+
ret set_poststate_ann(ccx, e_id, post) || pres_changed;
334+
}
335+
323336
fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
324337
let num_constrs = num_constraints(fcx.enclosing);
325338

@@ -358,7 +371,9 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
358371
}
359372
expr_mac(_) { fcx.ccx.tcx.sess.bug("unexpanded macro"); }
360373
expr_lit(l) { ret pure_exp(fcx.ccx, e.id, pres); }
361-
expr_fn(f, _) { ret pure_exp(fcx.ccx, e.id, pres); } // NDM Captures
374+
expr_fn(_, cap_clause) {
375+
ret find_pre_post_state_cap_clause(fcx, e.id, pres, *cap_clause);
376+
}
362377
expr_block(b) {
363378
ret find_pre_post_state_block(fcx, pres, b) |
364379
set_prestate_ann(fcx.ccx, e.id, pres) |

0 commit comments

Comments
 (0)