Skip to content

Commit 3f927ed

Browse files
committed
---
yaml --- r: 41983 b: refs/heads/master c: 90734a0 h: refs/heads/master i: 41981: 1d2f3de 41979: eafbf88 41975: 738b910 41967: 5ffd98e 41951: 7f7d825 41919: 8cf6388 41855: db144bf 41727: 5479d73 41471: 3c2270b 40959: a2875c3 v: v3
1 parent e46d5a8 commit 3f927ed

File tree

4 files changed

+51
-16
lines changed

4 files changed

+51
-16
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: 79a9b23f4a6397398c915e092d70989041dfef28
2+
refs/heads/master: 90734a0d3378b26f7800fc0ffdaa3a6897839514
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
55
refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650

trunk/src/libcore/extfmt.rs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,13 +376,23 @@ pub mod ct {
376376
fn test_parse_fmt_string() {
377377
assert parse_fmt_string("foo %s bar", die) == ~[
378378
PieceString(~"foo "),
379-
PieceConv(Conv {param: None, flags: ~[], width: CountImplied,
380-
precision: CountImplied, ty: TyStr}),
379+
PieceConv(Conv {
380+
param: None,
381+
flags: ~[],
382+
width: CountImplied,
383+
precision: CountImplied,
384+
ty: TyStr,
385+
}),
381386
PieceString(~" bar")];
382387

383388
assert parse_fmt_string("%s", die) == ~[
384-
PieceConv(Conv {param: None, flags: ~[], width: CountImplied,
385-
precision: CountImplied, ty: TyStr })];
389+
PieceConv(Conv {
390+
param: None,
391+
flags: ~[],
392+
width: CountImplied,
393+
precision: CountImplied,
394+
ty: TyStr,
395+
})];
386396

387397
assert parse_fmt_string("%%%%", die) == ~[
388398
PieceString(~"%"), PieceString(~"%")];
@@ -486,8 +496,19 @@ pub mod rt {
486496

487497
pub enum Ty { TyDefault, TyBits, TyHexUpper, TyHexLower, TyOctal, }
488498

499+
#[cfg(stage0)]
489500
pub type Conv = {flags: u32, width: Count, precision: Count, ty: Ty};
490501

502+
#[cfg(stage1)]
503+
#[cfg(stage2)]
504+
#[cfg(stage3)]
505+
pub struct Conv {
506+
flags: u32,
507+
width: Count,
508+
precision: Count,
509+
ty: Ty,
510+
}
511+
491512
pub pure fn conv_int(cv: Conv, i: int) -> ~str {
492513
let radix = 10;
493514
let prec = get_int_precision(cv);

trunk/src/libsyntax/ext/build.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,15 @@ fn mk_struct_e(cx: ext_ctxt, sp: span,
172172
mk_fields(sp, fields),
173173
option::None::<@ast::expr>))
174174
}
175+
fn mk_global_struct_e(cx: ext_ctxt, sp: span,
176+
ctor_path: ~[ast::ident],
177+
fields: ~[{ident: ast::ident, ex: @ast::expr}]) ->
178+
@ast::expr {
179+
mk_expr(cx, sp,
180+
ast::expr_struct(mk_raw_path_global(sp, ctor_path),
181+
mk_fields(sp, fields),
182+
option::None::<@ast::expr>))
183+
}
175184
fn mk_glob_use(cx: ext_ctxt, sp: span,
176185
path: ~[ast::ident]) -> @ast::view_item {
177186
let glob = @ast::spanned {

trunk/src/libsyntax/ext/fmt.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree])
5656
fn pieces_to_expr(cx: ext_ctxt, sp: span,
5757
pieces: ~[Piece], args: ~[@ast::expr])
5858
-> @ast::expr {
59-
fn make_path_vec(_cx: ext_ctxt, ident: @~str) -> ~[ast::ident] {
60-
let intr = _cx.parse_sess().interner;
59+
fn make_path_vec(cx: ext_ctxt, ident: @~str) -> ~[ast::ident] {
60+
let intr = cx.parse_sess().interner;
6161
return ~[intr.intern(@~"extfmt"), intr.intern(@~"rt"),
6262
intr.intern(ident)];
6363
}
@@ -111,23 +111,28 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
111111
}
112112
return make_rt_path_expr(cx, sp, @rt_type);
113113
}
114-
fn make_conv_rec(cx: ext_ctxt, sp: span, flags_expr: @ast::expr,
114+
fn make_conv_struct(cx: ext_ctxt, sp: span, flags_expr: @ast::expr,
115115
width_expr: @ast::expr, precision_expr: @ast::expr,
116116
ty_expr: @ast::expr) -> @ast::expr {
117117
let intr = cx.parse_sess().interner;
118-
return mk_rec_e(cx, sp,
119-
~[{ident: intr.intern(@~"flags"), ex: flags_expr},
120-
{ident: intr.intern(@~"width"), ex: width_expr},
121-
{ident: intr.intern(@~"precision"),
122-
ex: precision_expr},
123-
{ident: intr.intern(@~"ty"), ex: ty_expr}]);
118+
mk_global_struct_e(
119+
cx,
120+
sp,
121+
make_path_vec(cx, @~"Conv"),
122+
~[
123+
{ident: intr.intern(@~"flags"), ex: flags_expr},
124+
{ident: intr.intern(@~"width"), ex: width_expr},
125+
{ident: intr.intern(@~"precision"), ex: precision_expr},
126+
{ident: intr.intern(@~"ty"), ex: ty_expr},
127+
]
128+
)
124129
}
125130
let rt_conv_flags = make_flags(cx, sp, cnv.flags);
126131
let rt_conv_width = make_count(cx, sp, cnv.width);
127132
let rt_conv_precision = make_count(cx, sp, cnv.precision);
128133
let rt_conv_ty = make_ty(cx, sp, cnv.ty);
129-
return make_conv_rec(cx, sp, rt_conv_flags, rt_conv_width,
130-
rt_conv_precision, rt_conv_ty);
134+
make_conv_struct(cx, sp, rt_conv_flags, rt_conv_width,
135+
rt_conv_precision, rt_conv_ty)
131136
}
132137
fn make_conv_call(cx: ext_ctxt, sp: span, conv_type: ~str, cnv: Conv,
133138
arg: @ast::expr) -> @ast::expr {

0 commit comments

Comments
 (0)