Skip to content

Commit aaa67e3

Browse files
committed
---
yaml --- r: 81289 b: refs/heads/snap-stage3 c: 4d47601 h: refs/heads/master i: 81287: 9cf0249 v: v3
1 parent d1a7908 commit aaa67e3

File tree

3 files changed

+38
-38
lines changed

3 files changed

+38
-38
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 4c6bf4872012c010f84dc7fa2cdfe87522533f89
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 1b80558be38226eb50e6f6d574d7f6ae7e727346
4+
refs/heads/snap-stage3: 4d47601a7e7324de1dd616a535248d908a1543fe
55
refs/heads/try: 70152ff55722878cde684ee6462c14c65f2c4729
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/librusti/program.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl Program {
100100
// It's easy to initialize things if we don't run things...
101101
for (name, var) in self.local_vars.iter() {
102102
let mt = var.mt();
103-
code.push_str(fmt!("let%s %s: %s = fail!();\n", mt, *name, var.ty));
103+
code.push_str(format!("let{} {}: {} = fail!();\n", mt, *name, var.ty));
104104
var.alter(*name, &mut code);
105105
}
106106
code.push_str("{\n");
@@ -115,7 +115,7 @@ impl Program {
115115
}
116116

117117
for p in new_locals.iter() {
118-
code.push_str(fmt!("assert_encodable(&%s);\n", *p.first_ref()));
118+
code.push_str(format!("assert_encodable(&{});\n", *p.first_ref()));
119119
}
120120
code.push_str("};}");
121121
return code;
@@ -138,22 +138,22 @@ impl Program {
138138
// variables. This works by totally legitimately using the 'code'
139139
// pointer of the 'tls_key' function as a uint, and then casting it back
140140
// up to a function
141-
code.push_str(fmt!("
142-
let __tls_map: @mut ::std::hashmap::HashMap<~str, @~[u8]> = unsafe {
143-
let key = ::std::cast::transmute(%u);
141+
code.push_str(format!("
142+
let __tls_map: @mut ::std::hashmap::HashMap<~str, @~[u8]> = unsafe \\{
143+
let key = ::std::cast::transmute({});
144144
::std::local_data::get(key, |k| k.map(|&x| *x)).unwrap()
145-
};\n", key as uint));
145+
\\};\n", key));
146146

147147
// Using this __tls_map handle, deserialize each variable binding that
148148
// we know about
149149
for (name, var) in self.local_vars.iter() {
150150
let mt = var.mt();
151-
code.push_str(fmt!("let%s %s: %s = {
152-
let data = __tls_map.get_copy(&~\"%s\");
151+
code.push_str(format!("let{} {}: {} = \\{
152+
let data = __tls_map.get_copy(&~\"{}\");
153153
let doc = ::extra::ebml::reader::Doc(data);
154154
let mut decoder = ::extra::ebml::reader::Decoder(doc);
155155
::extra::serialize::Decodable::decode(&mut decoder)
156-
};\n", mt, *name, var.ty, *name));
156+
\\};\n", mt, *name, var.ty, *name));
157157
var.alter(*name, &mut code);
158158
}
159159

@@ -162,7 +162,7 @@ impl Program {
162162
code.push_char('\n');
163163

164164
match *to_print {
165-
Some(ref s) => { code.push_str(fmt!("pp({\n%s\n});", *s)); }
165+
Some(ref s) => { code.push_str(format!("pp(\\{\n{}\n\\});", *s)); }
166166
None => {}
167167
}
168168

@@ -174,14 +174,14 @@ impl Program {
174174
// After the input code is run, we can re-serialize everything back out
175175
// into tls map (to be read later on by this task)
176176
for (name, var) in self.local_vars.iter() {
177-
code.push_str(fmt!("{
178-
let local: %s = %s;
179-
let bytes = do ::std::io::with_bytes_writer |io| {
177+
code.push_str(format!("\\{
178+
let local: {} = {};
179+
let bytes = do ::std::io::with_bytes_writer |io| \\{
180180
let mut enc = ::extra::ebml::writer::Encoder(io);
181181
local.encode(&mut enc);
182-
};
183-
__tls_map.insert(~\"%s\", @bytes);
184-
}\n", var.real_ty(), *name, *name));
182+
\\};
183+
__tls_map.insert(~\"{}\", @bytes);
184+
\\}\n", var.real_ty(), *name, *name));
185185
}
186186

187187
// Close things up, and we're done.
@@ -193,14 +193,14 @@ impl Program {
193193
fn program_header(&self) -> ~str {
194194
// up front, disable lots of annoying lints, then include all global
195195
// state such as items, view items, and extern mods.
196-
let mut code = fmt!("
197-
#[allow(warnings)];
196+
let mut code = format!("
197+
\\#[allow(warnings)];
198198
199199
extern mod extra;
200-
%s // extern mods
200+
{} // extern mods
201201
202202
use extra::serialize::*;
203-
%s // view items
203+
{} // view items
204204
", self.externs, self.view_items);
205205
for (_, s) in self.structs.iter() {
206206
// The structs aren't really useful unless they're encodable
@@ -236,7 +236,7 @@ impl Program {
236236
for (name, value) in cons_map.move_iter() {
237237
match self.local_vars.find_mut(&name) {
238238
Some(v) => { v.data = (*value).clone(); }
239-
None => { fail!("unknown variable %s", name) }
239+
None => { fail2!("unknown variable {}", name) }
240240
}
241241
}
242242
}
@@ -272,7 +272,7 @@ impl Program {
272272
/// Once the types are known, they are inserted into the local_vars map in
273273
/// this Program (to be deserialized later on
274274
pub fn register_new_vars(&mut self, blk: &ast::Block, tcx: ty::ctxt) {
275-
debug!("looking for new variables");
275+
debug2!("looking for new variables");
276276
let newvars = @mut HashMap::new();
277277
do each_user_local(blk) |local| {
278278
let mutable = local.is_mutbl;
@@ -378,7 +378,7 @@ impl Program {
378378
_ => {}
379379
}
380380
}
381-
fail!("couldn't find user block");
381+
fail2!("couldn't find user block");
382382
}
383383
}
384384
}
@@ -389,9 +389,9 @@ impl LocalVariable {
389389
fn alter(&self, name: &str, code: &mut ~str) {
390390
match self.alterations {
391391
Some((ref real_ty, ref prefix)) => {
392-
code.push_str(fmt!("let%s %s: %s = %s%s;\n",
393-
self.mt(), name,
394-
*real_ty, *prefix, name));
392+
code.push_str(format!("let{} {}: {} = {}{};\n",
393+
self.mt(), name,
394+
*real_ty, *prefix, name));
395395
}
396396
None => {}
397397
}

branches/snap-stage3/src/librusti/rusti.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str],
156156
//
157157
// Stage 1: parse the input and filter it into the program (as necessary)
158158
//
159-
debug!("parsing: %s", input);
159+
debug2!("parsing: {}", input);
160160
let crate = parse_input(sess, input);
161161
let mut to_run = ~[]; // statements to run (emitted back into code)
162162
let new_locals = @mut ~[]; // new locals being defined
@@ -231,11 +231,11 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str],
231231
// Stage 2: run everything up to typeck to learn the types of the new
232232
// variables introduced into the program
233233
//
234-
info!("Learning about the new types in the program");
234+
info2!("Learning about the new types in the program");
235235
program.set_cache(); // before register_new_vars (which changes them)
236236
let input = to_run.connect("\n");
237237
let test = program.test_code(input, &result, *new_locals);
238-
debug!("testing with ^^^^^^ %?", (||{ println(test) })());
238+
debug2!("testing with ^^^^^^ {:?}", (||{ println(test) })());
239239
let dinput = driver::str_input(test.to_managed());
240240
let cfg = driver::build_configuration(sess);
241241

@@ -252,9 +252,9 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str],
252252
//
253253
// Stage 3: Actually run the code in the JIT
254254
//
255-
info!("actually running code");
255+
info2!("actually running code");
256256
let code = program.code(input, &result);
257-
debug!("actually running ^^^^^^ %?", (||{ println(code) })());
257+
debug2!("actually running ^^^^^^ {:?}", (||{ println(code) })());
258258
let input = driver::str_input(code.to_managed());
259259
let cfg = driver::build_configuration(sess);
260260
let outputs = driver::build_output_filenames(&input, &None, &None, [], sess);
@@ -272,7 +272,7 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str],
272272
// Stage 4: Inform the program that computation is done so it can update all
273273
// local variable bindings.
274274
//
275-
info!("cleaning up after code");
275+
info2!("cleaning up after code");
276276
program.consume_cache();
277277

278278
//
@@ -284,7 +284,7 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str],
284284
return (program, jit::consume_engine());
285285

286286
fn parse_input(sess: session::Session, input: &str) -> ast::Crate {
287-
let code = fmt!("fn main() {\n %s \n}", input);
287+
let code = format!("fn main() \\{\n {} \n\\}", input);
288288
let input = driver::str_input(code.to_managed());
289289
let cfg = driver::build_configuration(sess);
290290
driver::phase_1_parse_input(sess, cfg.clone(), &input)
@@ -302,7 +302,7 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str],
302302
_ => {}
303303
}
304304
}
305-
fail!("main function was expected somewhere...");
305+
fail2!("main function was expected somewhere...");
306306
}
307307
}
308308

@@ -355,7 +355,7 @@ fn compile_crate(src_filename: ~str, binary: ~str) -> Option<bool> {
355355
None => { },
356356
}
357357
if (should_compile) {
358-
println(fmt!("compiling %s...", src_filename));
358+
println(format!("compiling {}...", src_filename));
359359
let crate = driver::phase_1_parse_input(sess, cfg.clone(), &input);
360360
let expanded_crate = driver::phase_2_configure_and_expand(sess, cfg, crate);
361361
let analysis = driver::phase_3_run_analysis_passes(sess, &expanded_crate);
@@ -429,7 +429,7 @@ fn run_cmd(repl: &mut Repl, _in: @io::Reader, _out: @io::Writer,
429429
for crate in loaded_crates.iter() {
430430
let crate_path = Path(*crate);
431431
let crate_dir = crate_path.dirname();
432-
repl.program.record_extern(fmt!("extern mod %s;", *crate));
432+
repl.program.record_extern(format!("extern mod {};", *crate));
433433
if !repl.lib_search_paths.iter().any(|x| x == &crate_dir) {
434434
repl.lib_search_paths.push(crate_dir);
435435
}
@@ -445,7 +445,7 @@ fn run_cmd(repl: &mut Repl, _in: @io::Reader, _out: @io::Writer,
445445
let mut end_multiline = false;
446446
while (!end_multiline) {
447447
match get_line(use_rl, "rusti| ") {
448-
None => fail!("unterminated multiline command :{ .. :}"),
448+
None => fail2!("unterminated multiline command :\\{ .. :\\}"),
449449
Some(line) => {
450450
if line.trim() == ":}" {
451451
end_multiline = true;

0 commit comments

Comments
 (0)