diff options
| author | Tim Chevalier <[email protected]> | 2011-05-04 11:28:13 -0700 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-05-05 11:26:07 -0700 |
| commit | e3a68e235cd077c35654f79013ad54da46d72fee (patch) | |
| tree | 7838fc4a8937e2637cf7e3531d9c8e17feaff34b /src/comp/middle/fold.rs | |
| parent | Update docs to reflect assert vs. check (diff) | |
| download | rust-e3a68e235cd077c35654f79013ad54da46d72fee.tar.xz rust-e3a68e235cd077c35654f79013ad54da46d72fee.zip | |
Bring back "pred" syntax for writing predicates for check
This commit reinstates the requirement that the predicate in a
"check" must be a manifest call to a special kind of function
declared with the new "pred" keyword instead of "fn". Preds must
have a boolean return type and can only call other preds; they
can't have any effects (as enforced by the typechecker).
The arguments to a predicate in a check expression must be
slot variables or literals.
Diffstat (limited to 'src/comp/middle/fold.rs')
| -rw-r--r-- | src/comp/middle/fold.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/comp/middle/fold.rs b/src/comp/middle/fold.rs index 49b6290c..b37f7be8 100644 --- a/src/comp/middle/fold.rs +++ b/src/comp/middle/fold.rs @@ -30,6 +30,7 @@ import front.ast.def; import front.ast.def_id; import front.ast.ann; import front.ast.mt; +import front.ast.purity; import std._uint; import std._vec; @@ -301,7 +302,8 @@ type ast_fold[ENV] = (fn(&ENV e, vec[arg] inputs, - @ty output) -> ast.fn_decl) fold_fn_decl, + @ty output, + purity p) -> ast.fn_decl) fold_fn_decl, (fn(&ENV e, &ast._mod m) -> ast._mod) fold_mod, @@ -900,7 +902,7 @@ fn fold_fn_decl[ENV](&ENV env, ast_fold[ENV] fld, inputs += vec(fold_arg(env, fld, a)); } auto output = fold_ty[ENV](env, fld, decl.output); - ret fld.fold_fn_decl(env, inputs, output); + ret fld.fold_fn_decl(env, inputs, output, decl.purity); } fn fold_fn[ENV](&ENV env, ast_fold[ENV] fld, &ast._fn f) -> ast._fn { @@ -1542,8 +1544,9 @@ fn identity_fold_block[ENV](&ENV e, &span sp, &ast.block_ blk) -> block { fn identity_fold_fn_decl[ENV](&ENV e, vec[arg] inputs, - @ty output) -> ast.fn_decl { - ret rec(inputs=inputs, output=output); + @ty output, + purity p) -> ast.fn_decl { + ret rec(inputs=inputs, output=output, purity=p); } fn identity_fold_fn[ENV](&ENV e, @@ -1732,7 +1735,7 @@ fn new_identity_fold[ENV]() -> ast_fold[ENV] { fold_ann = bind identity_fold_ann[ENV](_,_), fold_fn = bind identity_fold_fn[ENV](_,_,_,_), - fold_fn_decl = bind identity_fold_fn_decl[ENV](_,_,_), + fold_fn_decl = bind identity_fold_fn_decl[ENV](_,_,_,_), fold_mod = bind identity_fold_mod[ENV](_,_), fold_native_mod = bind identity_fold_native_mod[ENV](_,_), fold_crate = bind identity_fold_crate[ENV](_,_,_,_), |