@@ -45,26 +45,12 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: span, arg: @ast::expr,
45
45
// NOTE: Moved many of the common ones to build.rs --kevina
46
46
fn pieces_to_expr ( cx : ext_ctxt , sp : span , pieces : [ piece ] , args : [ @ast:: expr ] )
47
47
-> @ast:: expr {
48
- fn make_rec_expr ( cx : ext_ctxt , sp : span ,
49
- fields : [ { ident: ast:: ident , ex : @ast:: expr } ] ) ->
50
- @ast:: expr {
51
- let astfields: [ ast:: field ] = [ ] ;
52
- for field: { ident: ast:: ident, ex: @ast:: expr} in fields {
53
- let ident = field. ident ;
54
- let val = field. ex ;
55
- let astfield =
56
- { node : { mut : ast:: imm, ident : ident, expr : val} , span: sp} ;
57
- astfields += [ astfield] ;
58
- }
59
- let recexpr = ast:: expr_rec ( astfields, option:: none :: < @ast:: expr > ) ;
60
- ret @{ id : cx. next_id ( ) , node : recexpr, span : sp} ;
61
- }
62
48
fn make_path_vec ( _cx : ext_ctxt , ident : ast:: ident ) -> [ ast:: ident ] {
63
49
ret [ "extfmt" , "rt" , ident] ;
64
50
}
65
51
fn make_rt_path_expr ( cx : ext_ctxt , sp : span , ident : str ) -> @ast:: expr {
66
52
let path = make_path_vec ( cx, ident) ;
67
- ret make_path_expr ( cx, sp, path) ;
53
+ ret mk_path ( cx, sp, path) ;
68
54
}
69
55
// Produces an AST expression that represents a RT::conv record,
70
56
// which tells the RT::conv* functions how to perform the conversion
@@ -90,18 +76,18 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr])
90
76
if vec:: len :: < @ast:: expr > ( flagexprs) == 0 u {
91
77
flagexprs += [ make_rt_path_expr ( cx, sp, "flag_none" ) ] ;
92
78
}
93
- ret make_vec_expr ( cx, sp, flagexprs) ;
79
+ ret mk_vec_e ( cx, sp, flagexprs) ;
94
80
}
95
81
fn make_count ( cx : ext_ctxt , sp : span , cnt : count ) -> @ast:: expr {
96
82
alt cnt {
97
83
count_implied {
98
84
ret make_rt_path_expr( cx, sp, "count_implied" ) ;
99
85
}
100
86
count_is ( c) {
101
- let count_lit = make_new_int ( cx, sp, c) ;
87
+ let count_lit = mk_int ( cx, sp, c) ;
102
88
let count_is_path = make_path_vec ( cx, "count_is" ) ;
103
89
let count_is_args = [ count_lit] ;
104
- ret make_call ( cx, sp, count_is_path, count_is_args) ;
90
+ ret mk_call ( cx, sp, count_is_path, count_is_args) ;
105
91
}
106
92
_ { cx. span_unimpl ( sp, "unimplemented #fmt conversion" ) ; }
107
93
}
@@ -124,11 +110,11 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr])
124
110
fn make_conv_rec ( cx : ext_ctxt , sp : span , flags_expr : @ast:: expr ,
125
111
width_expr : @ast:: expr , precision_expr : @ast:: expr ,
126
112
ty_expr : @ast:: expr ) -> @ast:: expr {
127
- ret make_rec_expr ( cx, sp,
128
- [ { ident: "flags" , ex: flags_expr} ,
129
- { ident: "width" , ex: width_expr} ,
130
- { ident: "precision" , ex: precision_expr} ,
131
- { ident: "ty" , ex: ty_expr} ] ) ;
113
+ ret mk_rec_e ( cx, sp,
114
+ [ { ident: "flags" , ex: flags_expr} ,
115
+ { ident: "width" , ex: width_expr} ,
116
+ { ident: "precision" , ex: precision_expr} ,
117
+ { ident: "ty" , ex: ty_expr} ] ) ;
132
118
}
133
119
let rt_conv_flags = make_flags ( cx, sp, cnv. flags ) ;
134
120
let rt_conv_width = make_count ( cx, sp, cnv. width ) ;
@@ -143,7 +129,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr])
143
129
let path = make_path_vec ( cx, fname) ;
144
130
let cnv_expr = make_rt_conv_expr ( cx, sp, cnv) ;
145
131
let args = [ cnv_expr, arg] ;
146
- ret make_call ( cx, arg. span , path, args) ;
132
+ ret mk_call ( cx, arg. span , path, args) ;
147
133
}
148
134
fn make_new_conv ( cx : ext_ctxt , sp : span , cnv : conv , arg : @ast:: expr ) ->
149
135
@ast:: expr {
@@ -272,13 +258,13 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr])
272
258
}
273
259
let fmt_sp = args[ 0 ] . span ;
274
260
let n = 0 u;
275
- let tmp_expr = make_new_str ( cx, sp, "" ) ;
261
+ let tmp_expr = mk_str ( cx, sp, "" ) ;
276
262
let nargs = vec:: len :: < @ast:: expr > ( args) ;
277
263
for pc: piece in pieces {
278
264
alt pc {
279
265
piece_string( s) {
280
- let s_expr = make_new_str ( cx, fmt_sp, s) ;
281
- tmp_expr = make_add_expr ( cx, fmt_sp, tmp_expr, s_expr) ;
266
+ let s_expr = mk_str ( cx, fmt_sp, s) ;
267
+ tmp_expr = mk_binary ( cx, fmt_sp, ast :: add , tmp_expr, s_expr) ;
282
268
}
283
269
piece_conv ( conv) {
284
270
n += 1 u;
@@ -291,7 +277,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr])
291
277
log_conv ( conv) ;
292
278
let arg_expr = args[ n] ;
293
279
let c_expr = make_new_conv ( cx, fmt_sp, conv, arg_expr) ;
294
- tmp_expr = make_add_expr ( cx, fmt_sp, tmp_expr, c_expr) ;
280
+ tmp_expr = mk_binary ( cx, fmt_sp, ast :: add , tmp_expr, c_expr) ;
295
281
}
296
282
}
297
283
}
0 commit comments