Skip to content

Commit cad1835

Browse files
committed
---
yaml --- r: 11013 b: refs/heads/master c: 485e489 h: refs/heads/master i: 11011: 98a3808 v: v3
1 parent bb5713d commit cad1835

File tree

4 files changed

+41
-8
lines changed

4 files changed

+41
-8
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 98450d0dade3c9a1b91a3384426cc4e824b82052
2+
refs/heads/master: 485e489ba2cb025bb84606396b1cea3023c8c99c
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/comp/rustc.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ mod syntax {
7474
mod ext {
7575
mod base;
7676
mod expand;
77+
mod qquote;
7778
mod build;
7879

7980
mod fmt;

trunk/src/comp/syntax/ext/expand.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import vec;
88
import syntax::ast::{crate, expr_, expr_mac, mac_invoc, mac_qq};
99
import syntax::fold::*;
1010
import syntax::ext::base::*;
11+
import syntax::ext::qquote::expand_qquote;
1112
import syntax::parse::parser::parse_expr_from_source_str;
1213

1314
import codemap::span;
@@ -53,13 +54,6 @@ fn expand_expr(exts: hashmap<str, syntax_extension>, cx: ext_ctxt,
5354
};
5455
}
5556

56-
fn expand_qquote(cx: ext_ctxt, sp: span, e: @ast::expr) -> ast::expr_ {
57-
import syntax::ext::build::*;
58-
let str = codemap::span_to_snippet(sp, cx.session().parse_sess.cm);
59-
let expr = mk_str(cx, e.span, str);
60-
ret expr.node;
61-
}
62-
6357
// FIXME: this is a terrible kludge to inject some macros into the default
6458
// compilation environment. When the macro-definition system is substantially
6559
// more mature, these should move from here, into a compiled part of libcore

trunk/src/comp/syntax/ext/qquote.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import driver::session;
2+
3+
import option::{none, some};
4+
5+
import syntax::ast::{crate, expr_, expr_mac, mac_invoc, mac_qq};
6+
import syntax::fold::*;
7+
import syntax::ext::base::*;
8+
import syntax::ext::build::*;
9+
import syntax::parse::parser::parse_expr_from_source_str;
10+
11+
import codemap::span;
12+
13+
fn expand_qquote(cx: ext_ctxt, sp: span, _e: @ast::expr) -> ast::expr_ {
14+
let str = codemap::span_to_snippet(sp, cx.session().parse_sess.cm);
15+
let session_call = bind mk_call_(cx,sp,
16+
mk_access(cx,sp,["ext_cx"], "session"),
17+
[]);
18+
let call = mk_call(cx,sp,
19+
["syntax", "parse", "parser",
20+
"parse_expr_from_source_str"],
21+
[mk_str(cx,sp, "<anon>"),
22+
mk_unary(cx,sp, ast::box(ast::imm),
23+
mk_str(cx,sp, str)),
24+
mk_access_(cx,sp,
25+
mk_access_(cx,sp, session_call(), "opts"),
26+
"cfg"),
27+
mk_access_(cx,sp, session_call(), "parse_sess")]
28+
);
29+
ret call.node;
30+
}
31+
32+
// Local Variables:
33+
// mode: rust
34+
// fill-column: 78;
35+
// indent-tabs-mode: nil
36+
// c-basic-offset: 4
37+
// buffer-file-coding-system: utf-8-unix
38+
// End:

0 commit comments

Comments
 (0)