diff options
| author | Eric Holk <eric.holk@gmail.com> | 2012-07-05 16:46:32 -0700 |
|---|---|---|
| committer | Eric Holk <eric.holk@gmail.com> | 2012-07-06 10:42:40 -0700 |
| commit | 84434bc0844545e9c3fb392126f3e80913028b9e (patch) | |
| tree | 4b0944452e6567cdb9d4c745fa1aa41a65010595 /src/libsyntax/ext | |
| parent | d09bcc0131935e2ad403aa965e9be06ddcf01c08 (diff) | |
| download | rust-84434bc0844545e9c3fb392126f3e80913028b9e.tar.gz rust-84434bc0844545e9c3fb392126f3e80913028b9e.zip | |
Recursively expand items, and keep expansion stack, per Paul's code review comments.
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 63b3c0881e1..4ac7dc19c00 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -139,7 +139,7 @@ fn expand_item(exts: hashmap<str, syntax_extension>, }; let it = alt it.node { ast::item_mac(*) { - expand_item_mac(exts, cx, it) + expand_item_mac(exts, cx, it, fld) } _ { it } }; @@ -150,7 +150,8 @@ fn expand_item(exts: hashmap<str, syntax_extension>, } fn expand_item_mac(exts: hashmap<str, syntax_extension>, - cx: ext_ctxt, &&it: @ast::item) -> @ast::item { + cx: ext_ctxt, &&it: @ast::item, + fld: ast_fold) -> @ast::item { alt it.node { item_mac({node: mac_invoc_tt(pth, tt), span}) { let extname = pth.idents[0]; @@ -160,7 +161,13 @@ fn expand_item_mac(exts: hashmap<str, syntax_extension>, #fmt("macro undefined: '%s'", *extname)) } some(item_tt(expand)) { - expand.expander(cx, it.span, it.ident, tt) + cx.bt_push(expanded_from({call_site: it.span, + callie: {name: *extname, + span: expand.span}})); + let it = fld.fold_item( + expand.expander(cx, it.span, it.ident, tt)); + cx.bt_pop(); + ret it } _ { cx.span_fatal(it.span, #fmt("%s is not a legal here", *extname)) } |
