Adjust function signatures to allow for vecs being immediate

Some code was relying on vectors being implicitly by-reference (as
non-immediate value). This adds the necessary &&-sigils.

Closes #1021
This commit is contained in:
Marijn Haverbeke 2011-10-10 13:54:03 +02:00
parent b4bae8fea5
commit 33167f7dec
15 changed files with 34 additions and 38 deletions

View file

@ -245,7 +245,7 @@ fn follow_for_trans(cx: ext_ctxt, mmaybe: option::t<arb_depth<matchable>>,
/* helper for transcribe_exprs: what vars from `b` occur in `e`? */
iter free_vars(b: bindings, e: @expr) -> ident {
let idents: hashmap<ident, ()> = new_str_hash::<()>();
fn mark_ident(i: ident, _fld: ast_fold, b: bindings,
fn mark_ident(&&i: ident, _fld: ast_fold, b: bindings,
idents: hashmap<ident, ()>) -> ident {
if b.contains_key(i) { idents.insert(i, ()); }
ret i;
@ -325,7 +325,7 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
// substitute, in a position that's required to be an ident
fn transcribe_ident(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
i: ident, _fld: ast_fold) -> ident {
&&i: ident, _fld: ast_fold) -> ident {
ret alt follow_for_trans(cx, b.find(i), idx_path) {
some(match_ident(a_id)) { a_id.node }
some(m) { match_error(cx, m, "an identifier") }

View file

@ -39,7 +39,7 @@ type ast_fold_precursor =
fold_mod: fn(_mod, ast_fold) -> _mod,
fold_native_mod: fn(native_mod, ast_fold) -> native_mod,
fold_variant: fn(variant_, ast_fold) -> variant_,
fold_ident: fn(ident, ast_fold) -> ident,
fold_ident: fn(&&ident, ast_fold) -> ident,
fold_path: fn(path_, ast_fold) -> path_,
fold_local: fn(local_, ast_fold) -> local_,
map_exprs: fn(fn(&&@expr) -> @expr, [@expr]) -> [@expr],
@ -66,7 +66,7 @@ type a_f =
fold_mod: fn(_mod) -> _mod,
fold_native_mod: fn(native_mod) -> native_mod,
fold_variant: fn(variant) -> variant,
fold_ident: fn(ident) -> ident,
fold_ident: fn(&&ident) -> ident,
fold_path: fn(path) -> path,
fold_local: fn(&&@local) -> @local,
map_exprs: fn(fn(&&@expr) -> @expr, [@expr]) -> [@expr],
@ -96,7 +96,7 @@ fn nf_fn_dummy(_f: _fn) -> _fn { fail; }
fn nf_mod_dummy(_m: _mod) -> _mod { fail; }
fn nf_native_mod_dummy(_n: native_mod) -> native_mod { fail; }
fn nf_variant_dummy(_v: variant) -> variant { fail; }
fn nf_ident_dummy(_i: ident) -> ident { fail; }
fn nf_ident_dummy(&&_i: ident) -> ident { fail; }
fn nf_path_dummy(_p: path) -> path { fail; }
fn nf_obj_field_dummy(_o: obj_field) -> obj_field { fail; }
fn nf_local_dummy(&&_o: @local) -> @local { fail; }
@ -471,7 +471,7 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ {
ret {name: v.name, args: vec::map(fold_variant_arg, v.args), id: v.id};
}
fn noop_fold_ident(i: ident, _fld: ast_fold) -> ident { ret i; }
fn noop_fold_ident(&&i: ident, _fld: ast_fold) -> ident { ret i; }
fn noop_fold_path(p: path_, fld: ast_fold) -> path_ {
ret {global: p.global,
@ -667,7 +667,7 @@ fn make_fold(afp: ast_fold_precursor) -> @foldres {
variant {
ret {node: afp.fold_variant(x.node, f), span: afp.new_span(x.span)};
}
fn f_ident(afp: ast_fold_precursor, f: ast_fold, x: ident) -> ident {
fn f_ident(afp: ast_fold_precursor, f: ast_fold, &&x: ident) -> ident {
ret afp.fold_ident(x, f);
}
fn f_path(afp: ast_fold_precursor, f: ast_fold, x: path) -> path {

View file

@ -1277,7 +1277,7 @@ fn print_view_item(s: ps, item: @ast::view_item) {
ast::view_item_export(ids, _) {
head(s, "export");
commasep(s, inconsistent, ids,
fn (s: ps, w: ast::ident) { word(s.s, w) });
fn (s: ps, &&w: ast::ident) { word(s.s, w) });
}
}
word(s.s, ";");