about summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
authorJohn Clements <clements@racket-lang.org>2013-04-03 10:28:14 -0700
committerJohn Clements <clements@racket-lang.org>2013-04-16 10:06:06 -0700
commit7e4cd09e2e57aae38d837531a7af1de00461d416 (patch)
treef8b6ba2bf0e13434265980fbd705f2ee9318b46b /src/libsyntax/ext
parent1083ae6b06939292c104f2a71fb2ebfaf9a2c70e (diff)
downloadrust-7e4cd09e2e57aae38d837531a7af1de00461d416.tar.gz
rust-7e4cd09e2e57aae38d837531a7af1de00461d416.zip
added MTWT functions
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/expand.rs47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index 09498f09a29..430402a8982 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -547,6 +547,53 @@ pub fn expand_crate(parse_sess: @mut parse::ParseSess,
     @f.fold_crate(&*c)
 }
 
+// given a function from paths to paths, produce
+// an ast_fold that applies that function:
+fn fun_to_path_folder(f: @fn(&ast::Path)->ast::Path) -> @ast_fold{
+    let afp = default_ast_fold();
+    let f_pre = @AstFoldFns{
+        fold_path : |p, _| f(p),
+        .. *afp
+    };
+    make_fold(f_pre)
+}
+/* going to have to figure out whether the table is passed in or
+extracted from TLS...
+// update the ctxts in a path to get a rename node
+fn ctxt_update_rename(from: ast::Name,
+                       fromctx: ast::SyntaxContext, to: ast::Name) ->
+    @fn(&ast::Path,@ast_fold)->ast::Path {
+    return |p:&ast::Path,_|
+    ast::Path {span: p.span,
+               global: p.global,
+               idents: p.idents.map(|id|
+                                    ast::ident{
+                                        repr: id.repr,
+                                        // this needs to be cached....
+                                        ctxt: Some(@ast::Rename(from,fromctx,
+                                                           to,id.ctxt))
+                                    }),
+               rp: p.rp,
+               types: p.types};
+}
+
+// update the ctxts in a path to get a mark node
+fn ctxt_update_mark(mark: uint) ->
+    @fn(&ast::Path,@ast_fold)->ast::Path {
+    return |p:&ast::Path,_|
+    ast::Path {span: p.span,
+               global: p.global,
+               idents: p.idents.map(|id|
+                                    ast::ident{
+                                        repr: id.repr,
+                                        // this needs to be cached....
+                                        ctxt: Some(@ast::Mark(mark,id.ctxt))
+                                    }),
+               rp: p.rp,
+               types: p.types};
+}
+*/
+
 #[cfg(test)]
 mod test {
     use super::*;