mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-18 03:25:55 +00:00
rusti: Remove usage of fmt!
This commit is contained in:
parent
1b80558be3
commit
4d47601a7e
@ -100,7 +100,7 @@ impl Program {
|
||||
// It's easy to initialize things if we don't run things...
|
||||
for (name, var) in self.local_vars.iter() {
|
||||
let mt = var.mt();
|
||||
code.push_str(fmt!("let%s %s: %s = fail!();\n", mt, *name, var.ty));
|
||||
code.push_str(format!("let{} {}: {} = fail!();\n", mt, *name, var.ty));
|
||||
var.alter(*name, &mut code);
|
||||
}
|
||||
code.push_str("{\n");
|
||||
@ -115,7 +115,7 @@ impl Program {
|
||||
}
|
||||
|
||||
for p in new_locals.iter() {
|
||||
code.push_str(fmt!("assert_encodable(&%s);\n", *p.first_ref()));
|
||||
code.push_str(format!("assert_encodable(&{});\n", *p.first_ref()));
|
||||
}
|
||||
code.push_str("};}");
|
||||
return code;
|
||||
@ -138,22 +138,22 @@ impl Program {
|
||||
// variables. This works by totally legitimately using the 'code'
|
||||
// pointer of the 'tls_key' function as a uint, and then casting it back
|
||||
// up to a function
|
||||
code.push_str(fmt!("
|
||||
let __tls_map: @mut ::std::hashmap::HashMap<~str, @~[u8]> = unsafe {
|
||||
let key = ::std::cast::transmute(%u);
|
||||
code.push_str(format!("
|
||||
let __tls_map: @mut ::std::hashmap::HashMap<~str, @~[u8]> = unsafe \\{
|
||||
let key = ::std::cast::transmute({});
|
||||
::std::local_data::get(key, |k| k.map(|&x| *x)).unwrap()
|
||||
};\n", key as uint));
|
||||
\\};\n", key));
|
||||
|
||||
// Using this __tls_map handle, deserialize each variable binding that
|
||||
// we know about
|
||||
for (name, var) in self.local_vars.iter() {
|
||||
let mt = var.mt();
|
||||
code.push_str(fmt!("let%s %s: %s = {
|
||||
let data = __tls_map.get_copy(&~\"%s\");
|
||||
code.push_str(format!("let{} {}: {} = \\{
|
||||
let data = __tls_map.get_copy(&~\"{}\");
|
||||
let doc = ::extra::ebml::reader::Doc(data);
|
||||
let mut decoder = ::extra::ebml::reader::Decoder(doc);
|
||||
::extra::serialize::Decodable::decode(&mut decoder)
|
||||
};\n", mt, *name, var.ty, *name));
|
||||
\\};\n", mt, *name, var.ty, *name));
|
||||
var.alter(*name, &mut code);
|
||||
}
|
||||
|
||||
@ -162,7 +162,7 @@ impl Program {
|
||||
code.push_char('\n');
|
||||
|
||||
match *to_print {
|
||||
Some(ref s) => { code.push_str(fmt!("pp({\n%s\n});", *s)); }
|
||||
Some(ref s) => { code.push_str(format!("pp(\\{\n{}\n\\});", *s)); }
|
||||
None => {}
|
||||
}
|
||||
|
||||
@ -174,14 +174,14 @@ impl Program {
|
||||
// After the input code is run, we can re-serialize everything back out
|
||||
// into tls map (to be read later on by this task)
|
||||
for (name, var) in self.local_vars.iter() {
|
||||
code.push_str(fmt!("{
|
||||
let local: %s = %s;
|
||||
let bytes = do ::std::io::with_bytes_writer |io| {
|
||||
code.push_str(format!("\\{
|
||||
let local: {} = {};
|
||||
let bytes = do ::std::io::with_bytes_writer |io| \\{
|
||||
let mut enc = ::extra::ebml::writer::Encoder(io);
|
||||
local.encode(&mut enc);
|
||||
};
|
||||
__tls_map.insert(~\"%s\", @bytes);
|
||||
}\n", var.real_ty(), *name, *name));
|
||||
\\};
|
||||
__tls_map.insert(~\"{}\", @bytes);
|
||||
\\}\n", var.real_ty(), *name, *name));
|
||||
}
|
||||
|
||||
// Close things up, and we're done.
|
||||
@ -193,14 +193,14 @@ impl Program {
|
||||
fn program_header(&self) -> ~str {
|
||||
// up front, disable lots of annoying lints, then include all global
|
||||
// state such as items, view items, and extern mods.
|
||||
let mut code = fmt!("
|
||||
#[allow(warnings)];
|
||||
let mut code = format!("
|
||||
\\#[allow(warnings)];
|
||||
|
||||
extern mod extra;
|
||||
%s // extern mods
|
||||
{} // extern mods
|
||||
|
||||
use extra::serialize::*;
|
||||
%s // view items
|
||||
{} // view items
|
||||
", self.externs, self.view_items);
|
||||
for (_, s) in self.structs.iter() {
|
||||
// The structs aren't really useful unless they're encodable
|
||||
@ -236,7 +236,7 @@ impl Program {
|
||||
for (name, value) in cons_map.move_iter() {
|
||||
match self.local_vars.find_mut(&name) {
|
||||
Some(v) => { v.data = (*value).clone(); }
|
||||
None => { fail!("unknown variable %s", name) }
|
||||
None => { fail2!("unknown variable {}", name) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -272,7 +272,7 @@ impl Program {
|
||||
/// Once the types are known, they are inserted into the local_vars map in
|
||||
/// this Program (to be deserialized later on
|
||||
pub fn register_new_vars(&mut self, blk: &ast::Block, tcx: ty::ctxt) {
|
||||
debug!("looking for new variables");
|
||||
debug2!("looking for new variables");
|
||||
let newvars = @mut HashMap::new();
|
||||
do each_user_local(blk) |local| {
|
||||
let mutable = local.is_mutbl;
|
||||
@ -378,7 +378,7 @@ impl Program {
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
fail!("couldn't find user block");
|
||||
fail2!("couldn't find user block");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -389,9 +389,9 @@ impl LocalVariable {
|
||||
fn alter(&self, name: &str, code: &mut ~str) {
|
||||
match self.alterations {
|
||||
Some((ref real_ty, ref prefix)) => {
|
||||
code.push_str(fmt!("let%s %s: %s = %s%s;\n",
|
||||
self.mt(), name,
|
||||
*real_ty, *prefix, name));
|
||||
code.push_str(format!("let{} {}: {} = {}{};\n",
|
||||
self.mt(), name,
|
||||
*real_ty, *prefix, name));
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str],
|
||||
//
|
||||
// Stage 1: parse the input and filter it into the program (as necessary)
|
||||
//
|
||||
debug!("parsing: %s", input);
|
||||
debug2!("parsing: {}", input);
|
||||
let crate = parse_input(sess, input);
|
||||
let mut to_run = ~[]; // statements to run (emitted back into code)
|
||||
let new_locals = @mut ~[]; // new locals being defined
|
||||
@ -231,11 +231,11 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str],
|
||||
// Stage 2: run everything up to typeck to learn the types of the new
|
||||
// variables introduced into the program
|
||||
//
|
||||
info!("Learning about the new types in the program");
|
||||
info2!("Learning about the new types in the program");
|
||||
program.set_cache(); // before register_new_vars (which changes them)
|
||||
let input = to_run.connect("\n");
|
||||
let test = program.test_code(input, &result, *new_locals);
|
||||
debug!("testing with ^^^^^^ %?", (||{ println(test) })());
|
||||
debug2!("testing with ^^^^^^ {:?}", (||{ println(test) })());
|
||||
let dinput = driver::str_input(test.to_managed());
|
||||
let cfg = driver::build_configuration(sess);
|
||||
|
||||
@ -252,9 +252,9 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str],
|
||||
//
|
||||
// Stage 3: Actually run the code in the JIT
|
||||
//
|
||||
info!("actually running code");
|
||||
info2!("actually running code");
|
||||
let code = program.code(input, &result);
|
||||
debug!("actually running ^^^^^^ %?", (||{ println(code) })());
|
||||
debug2!("actually running ^^^^^^ {:?}", (||{ println(code) })());
|
||||
let input = driver::str_input(code.to_managed());
|
||||
let cfg = driver::build_configuration(sess);
|
||||
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],
|
||||
// Stage 4: Inform the program that computation is done so it can update all
|
||||
// local variable bindings.
|
||||
//
|
||||
info!("cleaning up after code");
|
||||
info2!("cleaning up after code");
|
||||
program.consume_cache();
|
||||
|
||||
//
|
||||
@ -284,7 +284,7 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str],
|
||||
return (program, jit::consume_engine());
|
||||
|
||||
fn parse_input(sess: session::Session, input: &str) -> ast::Crate {
|
||||
let code = fmt!("fn main() {\n %s \n}", input);
|
||||
let code = format!("fn main() \\{\n {} \n\\}", input);
|
||||
let input = driver::str_input(code.to_managed());
|
||||
let cfg = driver::build_configuration(sess);
|
||||
driver::phase_1_parse_input(sess, cfg.clone(), &input)
|
||||
@ -302,7 +302,7 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str],
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
fail!("main function was expected somewhere...");
|
||||
fail2!("main function was expected somewhere...");
|
||||
}
|
||||
}
|
||||
|
||||
@ -355,7 +355,7 @@ fn compile_crate(src_filename: ~str, binary: ~str) -> Option<bool> {
|
||||
None => { },
|
||||
}
|
||||
if (should_compile) {
|
||||
println(fmt!("compiling %s...", src_filename));
|
||||
println(format!("compiling {}...", src_filename));
|
||||
let crate = driver::phase_1_parse_input(sess, cfg.clone(), &input);
|
||||
let expanded_crate = driver::phase_2_configure_and_expand(sess, cfg, crate);
|
||||
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,
|
||||
for crate in loaded_crates.iter() {
|
||||
let crate_path = Path(*crate);
|
||||
let crate_dir = crate_path.dirname();
|
||||
repl.program.record_extern(fmt!("extern mod %s;", *crate));
|
||||
repl.program.record_extern(format!("extern mod {};", *crate));
|
||||
if !repl.lib_search_paths.iter().any(|x| x == &crate_dir) {
|
||||
repl.lib_search_paths.push(crate_dir);
|
||||
}
|
||||
@ -445,7 +445,7 @@ fn run_cmd(repl: &mut Repl, _in: @io::Reader, _out: @io::Writer,
|
||||
let mut end_multiline = false;
|
||||
while (!end_multiline) {
|
||||
match get_line(use_rl, "rusti| ") {
|
||||
None => fail!("unterminated multiline command :{ .. :}"),
|
||||
None => fail2!("unterminated multiline command :\\{ .. :\\}"),
|
||||
Some(line) => {
|
||||
if line.trim() == ":}" {
|
||||
end_multiline = true;
|
||||
|
Loading…
Reference in New Issue
Block a user