diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2012-08-02 15:42:56 -0700 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2012-08-02 15:53:28 -0700 |
| commit | 97452c0ca16238a2de5503aca07db26ff9e8ba63 (patch) | |
| tree | 47ef430d1671ab297bc192009aa74a23723a42fc /src/libsyntax/ext | |
| parent | 476ce459bd3b687658e566c75d0fb73281450d67 (diff) | |
| download | rust-97452c0ca16238a2de5503aca07db26ff9e8ba63.tar.gz rust-97452c0ca16238a2de5503aca07db26ff9e8ba63.zip | |
Remove modes from map API and replace with regions.
API is (for now) mostly by value, there are options to use it by reference if you like. Hash and equality functions must be pure and by reference (forward looking to the day when something like send_map becomes the standard map).
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/qquote.rs | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/libsyntax/ext/qquote.rs b/src/libsyntax/ext/qquote.rs index 1c3e0aa5181..ec0b69d652c 100644 --- a/src/libsyntax/ext/qquote.rs +++ b/src/libsyntax/ext/qquote.rs @@ -13,10 +13,14 @@ import io::*; import codemap::span; -type aq_ctxt = @{lo: uint, - gather: dvec<{lo: uint, hi: uint, - e: @ast::expr, - constr: ~str}>}; +struct gather_item { + lo: uint; + hi: uint; + e: @ast::expr; + constr: ~str; +} + +type aq_ctxt = @{lo: uint, gather: dvec<gather_item>}; enum fragment { from_expr(@ast::expr), from_ty(@ast::ty) @@ -110,7 +114,10 @@ fn gather_anti_quotes<N: qq_helper>(lo: uint, node: N) -> aq_ctxt // FIXME (#2250): Maybe this is an overkill (merge_sort), it might // be better to just keep the gather array in sorted order. do cx.gather.swap |v| { - vec::to_mut(std::sort::merge_sort(|a,b| a.lo < b.lo, v)) + pure fn by_lo(a: &gather_item, b: &gather_item) -> bool { + a.lo < b.lo + } + vec::to_mut(std::sort::merge_sort(by_lo, v)) }; return cx; } @@ -119,8 +126,11 @@ fn visit_aq<T:qq_helper>(node: T, constr: ~str, &&cx: aq_ctxt, v: vt<aq_ctxt>) { alt (node.extract_mac()) { some(mac_aq(sp, e)) { - cx.gather.push({lo: sp.lo - cx.lo, hi: sp.hi - cx.lo, - e: e, constr: constr}); + cx.gather.push(gather_item { + lo: sp.lo - cx.lo, + hi: sp.hi - cx.lo, + e: e, + constr: constr}); } _ {node.visit(cx, v);} } |
