Skip to content

Commit d301dd3

Browse files
committed
remove the old auto_serialize syntax extension
1 parent e1c517c commit d301dd3

File tree

5 files changed

+146
-316
lines changed

5 files changed

+146
-316
lines changed

src/libsyntax/ext/auto_serialize.rs

Lines changed: 1 addition & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -122,34 +122,7 @@ fn expand(cx: ext_ctxt,
122122
}
123123
}
124124

125-
trait ext_ctxt_helpers {
126-
fn helper_path(base_path: @ast::path, helper_name: ~str) -> @ast::path;
127-
fn path(span: span, strs: ~[ast::ident]) -> @ast::path;
128-
fn path_tps(span: span, strs: ~[ast::ident],
129-
tps: ~[@ast::ty]) -> @ast::path;
130-
fn ty_path(span: span, strs: ~[ast::ident], tps: ~[@ast::ty]) -> @ast::ty;
131-
fn ty_fn(span: span,
132-
-input_tys: ~[@ast::ty],
133-
-output: @ast::ty) -> @ast::ty;
134-
fn ty_nil(span: span) -> @ast::ty;
135-
fn expr(span: span, node: ast::expr_) -> @ast::expr;
136-
fn var_ref(span: span, name: ast::ident) -> @ast::expr;
137-
fn blk(span: span, stmts: ~[@ast::stmt]) -> ast::blk;
138-
fn expr_blk(expr: @ast::expr) -> ast::blk;
139-
fn binder_pat(span: span, nm: ast::ident) -> @ast::pat;
140-
fn stmt(expr: @ast::expr) -> @ast::stmt;
141-
fn alt_stmt(arms: ~[ast::arm], span: span, -v: @ast::expr) -> @ast::stmt;
142-
fn lit_str(span: span, s: @~str) -> @ast::expr;
143-
fn lit_uint(span: span, i: uint) -> @ast::expr;
144-
fn lambda(blk: ast::blk) -> @ast::expr;
145-
fn clone_folder() -> fold::ast_fold;
146-
fn clone(v: @ast::expr) -> @ast::expr;
147-
fn clone_ty(v: @ast::ty) -> @ast::ty;
148-
fn clone_ty_param(v: ast::ty_param) -> ast::ty_param;
149-
fn at(span: span, expr: @ast::expr) -> @ast::expr;
150-
}
151-
152-
impl ext_ctxt: ext_ctxt_helpers {
125+
priv impl ext_ctxt {
153126
fn helper_path(base_path: @ast::path,
154127
helper_name: ~str) -> @ast::path {
155128
let head = vec::init(base_path.idents);
@@ -162,22 +135,6 @@ impl ext_ctxt: ext_ctxt_helpers {
162135
tail)))]))
163136
}
164137

165-
fn path(span: span, strs: ~[ast::ident]) -> @ast::path {
166-
@{span: span, global: false, idents: strs, rp: None, types: ~[]}
167-
}
168-
169-
fn path_tps(span: span, strs: ~[ast::ident],
170-
tps: ~[@ast::ty]) -> @ast::path {
171-
@{span: span, global: false, idents: strs, rp: None, types: tps}
172-
}
173-
174-
fn ty_path(span: span, strs: ~[ast::ident],
175-
tps: ~[@ast::ty]) -> @ast::ty {
176-
@{id: self.next_id(),
177-
node: ast::ty_path(self.path_tps(span, strs, tps), self.next_id()),
178-
span: span}
179-
}
180-
181138
fn ty_fn(span: span,
182139
-input_tys: ~[@ast::ty],
183140
-output: @ast::ty) -> @ast::ty {
@@ -202,48 +159,10 @@ impl ext_ctxt: ext_ctxt_helpers {
202159
@{id: self.next_id(), node: ast::ty_nil, span: span}
203160
}
204161

205-
fn expr(span: span, node: ast::expr_) -> @ast::expr {
206-
@{id: self.next_id(), callee_id: self.next_id(),
207-
node: node, span: span}
208-
}
209-
210162
fn var_ref(span: span, name: ast::ident) -> @ast::expr {
211163
self.expr(span, ast::expr_path(self.path(span, ~[name])))
212164
}
213165

214-
fn blk(span: span, stmts: ~[@ast::stmt]) -> ast::blk {
215-
{node: {view_items: ~[],
216-
stmts: stmts,
217-
expr: None,
218-
id: self.next_id(),
219-
rules: ast::default_blk},
220-
span: span}
221-
}
222-
223-
fn expr_blk(expr: @ast::expr) -> ast::blk {
224-
{node: {view_items: ~[],
225-
stmts: ~[],
226-
expr: Some(expr),
227-
id: self.next_id(),
228-
rules: ast::default_blk},
229-
span: expr.span}
230-
}
231-
232-
fn binder_pat(span: span, nm: ast::ident) -> @ast::pat {
233-
let path = @{span: span, global: false, idents: ~[nm],
234-
rp: None, types: ~[]};
235-
@{id: self.next_id(),
236-
node: ast::pat_ident(ast::bind_by_implicit_ref,
237-
path,
238-
None),
239-
span: span}
240-
}
241-
242-
fn stmt(expr: @ast::expr) -> @ast::stmt {
243-
@{node: ast::stmt_semi(expr, self.next_id()),
244-
span: expr.span}
245-
}
246-
247166
fn alt_stmt(arms: ~[ast::arm],
248167
span: span, -v: @ast::expr) -> @ast::stmt {
249168
self.stmt(
@@ -252,32 +171,6 @@ impl ext_ctxt: ext_ctxt_helpers {
252171
ast::expr_match(v, arms)))
253172
}
254173

255-
fn lit_str(span: span, s: @~str) -> @ast::expr {
256-
self.expr(
257-
span,
258-
ast::expr_vstore(
259-
self.expr(
260-
span,
261-
ast::expr_lit(
262-
@{node: ast::lit_str(s),
263-
span: span})),
264-
ast::expr_vstore_uniq))
265-
}
266-
267-
fn lit_uint(span: span, i: uint) -> @ast::expr {
268-
self.expr(
269-
span,
270-
ast::expr_lit(
271-
@{node: ast::lit_uint(i as u64, ast::ty_u),
272-
span: span}))
273-
}
274-
275-
fn lambda(blk: ast::blk) -> @ast::expr {
276-
let ext_cx = self;
277-
let blk_e = self.expr(blk.span, ast::expr_block(blk));
278-
#ast{ || $(blk_e) }
279-
}
280-
281174
fn clone_folder() -> fold::ast_fold {
282175
fold::make_fold(@{
283176
new_id: |_id| self.next_id(),

src/libsyntax/ext/auto_serialize2.rs

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,86 @@ fn expand_auto_deserialize(
215215
}
216216

217217
priv impl ext_ctxt {
218+
fn expr(span: span, node: ast::expr_) -> @ast::expr {
219+
@{id: self.next_id(), callee_id: self.next_id(),
220+
node: node, span: span}
221+
}
222+
223+
fn path(span: span, strs: ~[ast::ident]) -> @ast::path {
224+
@{span: span, global: false, idents: strs, rp: None, types: ~[]}
225+
}
226+
227+
fn path_tps(span: span, strs: ~[ast::ident],
228+
tps: ~[@ast::ty]) -> @ast::path {
229+
@{span: span, global: false, idents: strs, rp: None, types: tps}
230+
}
231+
232+
fn ty_path(span: span, strs: ~[ast::ident],
233+
tps: ~[@ast::ty]) -> @ast::ty {
234+
@{id: self.next_id(),
235+
node: ast::ty_path(self.path_tps(span, strs, tps), self.next_id()),
236+
span: span}
237+
}
238+
239+
fn binder_pat(span: span, nm: ast::ident) -> @ast::pat {
240+
let path = @{span: span, global: false, idents: ~[nm],
241+
rp: None, types: ~[]};
242+
@{id: self.next_id(),
243+
node: ast::pat_ident(ast::bind_by_implicit_ref,
244+
path,
245+
None),
246+
span: span}
247+
}
248+
249+
fn stmt(expr: @ast::expr) -> @ast::stmt {
250+
@{node: ast::stmt_semi(expr, self.next_id()),
251+
span: expr.span}
252+
}
253+
254+
fn lit_str(span: span, s: @~str) -> @ast::expr {
255+
self.expr(
256+
span,
257+
ast::expr_vstore(
258+
self.expr(
259+
span,
260+
ast::expr_lit(
261+
@{node: ast::lit_str(s),
262+
span: span})),
263+
ast::expr_vstore_uniq))
264+
}
265+
266+
fn lit_uint(span: span, i: uint) -> @ast::expr {
267+
self.expr(
268+
span,
269+
ast::expr_lit(
270+
@{node: ast::lit_uint(i as u64, ast::ty_u),
271+
span: span}))
272+
}
273+
274+
fn lambda(blk: ast::blk) -> @ast::expr {
275+
let ext_cx = self;
276+
let blk_e = self.expr(blk.span, ast::expr_block(blk));
277+
#ast{ || $(blk_e) }
278+
}
279+
280+
fn blk(span: span, stmts: ~[@ast::stmt]) -> ast::blk {
281+
{node: {view_items: ~[],
282+
stmts: stmts,
283+
expr: None,
284+
id: self.next_id(),
285+
rules: ast::default_blk},
286+
span: span}
287+
}
288+
289+
fn expr_blk(expr: @ast::expr) -> ast::blk {
290+
{node: {view_items: ~[],
291+
stmts: ~[],
292+
expr: Some(expr),
293+
id: self.next_id(),
294+
rules: ast::default_blk},
295+
span: expr.span}
296+
}
297+
218298
fn expr_path(span: span, strs: ~[ast::ident]) -> @ast::expr {
219299
self.expr(span, ast::expr_path(self.path(span, strs)))
220300
}

src/libsyntax/ext/base.rs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ enum syntax_extension {
6464

6565
// A temporary hard-coded map of methods for expanding syntax extension
6666
// AST nodes into full ASTs
67+
#[cfg(stage0)]
6768
fn syntax_expander_table() -> HashMap<~str, syntax_extension> {
6869
fn builtin(f: syntax_expander_) -> syntax_extension
6970
{normal({expander: f, span: None})}
@@ -122,6 +123,69 @@ fn syntax_expander_table() -> HashMap<~str, syntax_extension> {
122123
return syntax_expanders;
123124
}
124125

126+
#[cfg(stage1)]
127+
#[cfg(stage2)]
128+
fn syntax_expander_table() -> HashMap<~str, syntax_extension> {
129+
fn builtin(f: syntax_expander_) -> syntax_extension
130+
{normal({expander: f, span: None})}
131+
fn builtin_expr_tt(f: syntax_expander_tt_) -> syntax_extension {
132+
expr_tt({expander: f, span: None})
133+
}
134+
fn builtin_item_tt(f: syntax_expander_tt_item_) -> syntax_extension {
135+
item_tt({expander: f, span: None})
136+
}
137+
let syntax_expanders = HashMap();
138+
syntax_expanders.insert(~"macro",
139+
macro_defining(ext::simplext::add_new_extension));
140+
syntax_expanders.insert(~"macro_rules",
141+
builtin_item_tt(
142+
ext::tt::macro_rules::add_new_extension));
143+
syntax_expanders.insert(~"fmt", builtin(ext::fmt::expand_syntax_ext));
144+
syntax_expanders.insert(
145+
~"auto_serialize",
146+
item_decorator(ext::auto_serialize2::expand_auto_serialize));
147+
syntax_expanders.insert(
148+
~"auto_deserialize",
149+
item_decorator(ext::auto_serialize2::expand_auto_deserialize));
150+
syntax_expanders.insert(
151+
~"auto_serialize2",
152+
item_decorator(ext::auto_serialize2::expand_auto_serialize));
153+
syntax_expanders.insert(
154+
~"auto_deserialize2",
155+
item_decorator(ext::auto_serialize2::expand_auto_deserialize));
156+
syntax_expanders.insert(~"env", builtin(ext::env::expand_syntax_ext));
157+
syntax_expanders.insert(~"concat_idents",
158+
builtin(ext::concat_idents::expand_syntax_ext));
159+
syntax_expanders.insert(~"ident_to_str",
160+
builtin(ext::ident_to_str::expand_syntax_ext));
161+
syntax_expanders.insert(~"log_syntax",
162+
builtin_expr_tt(
163+
ext::log_syntax::expand_syntax_ext));
164+
syntax_expanders.insert(~"ast",
165+
builtin(ext::qquote::expand_ast));
166+
syntax_expanders.insert(~"line",
167+
builtin(ext::source_util::expand_line));
168+
syntax_expanders.insert(~"col",
169+
builtin(ext::source_util::expand_col));
170+
syntax_expanders.insert(~"file",
171+
builtin(ext::source_util::expand_file));
172+
syntax_expanders.insert(~"stringify",
173+
builtin(ext::source_util::expand_stringify));
174+
syntax_expanders.insert(~"include",
175+
builtin(ext::source_util::expand_include));
176+
syntax_expanders.insert(~"include_str",
177+
builtin(ext::source_util::expand_include_str));
178+
syntax_expanders.insert(~"include_bin",
179+
builtin(ext::source_util::expand_include_bin));
180+
syntax_expanders.insert(~"module_path",
181+
builtin(ext::source_util::expand_mod));
182+
syntax_expanders.insert(~"proto",
183+
builtin_item_tt(ext::pipes::expand_proto));
184+
syntax_expanders.insert(
185+
~"trace_macros",
186+
builtin_expr_tt(ext::trace_macros::expand_trace_macros));
187+
return syntax_expanders;
188+
}
125189

126190
// One of these is made during expansion and incrementally updated as we go;
127191
// when a macro expansion occurs, the resulting nodes have the backtrace()

src/libsyntax/syntax.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ mod ext {
128128
mod ident_to_str;
129129
#[legacy_exports]
130130
mod log_syntax;
131+
#[cfg(stage0)]
131132
#[legacy_exports]
132133
mod auto_serialize;
133134
#[legacy_exports]

0 commit comments

Comments
 (0)