Rename all variables that have uppercase characters in their names to use only lowercase characters
This commit is contained in:
parent
fe50c75d02
commit
6d9bdf975a
@ -73,31 +73,31 @@ pub fn run_metrics(config: config, testfile: ~str, mm: &mut MetricMap) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn run_cfail_test(config: &config, props: &TestProps, testfile: &Path) {
|
fn run_cfail_test(config: &config, props: &TestProps, testfile: &Path) {
|
||||||
let ProcRes = compile_test(config, props, testfile);
|
let proc_res = compile_test(config, props, testfile);
|
||||||
|
|
||||||
if ProcRes.status.success() {
|
if proc_res.status.success() {
|
||||||
fatal_ProcRes(~"compile-fail test compiled successfully!", &ProcRes);
|
fatal_ProcRes(~"compile-fail test compiled successfully!", &proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
check_correct_failure_status(&ProcRes);
|
check_correct_failure_status(&proc_res);
|
||||||
|
|
||||||
let expected_errors = errors::load_errors(testfile);
|
let expected_errors = errors::load_errors(testfile);
|
||||||
if !expected_errors.is_empty() {
|
if !expected_errors.is_empty() {
|
||||||
if !props.error_patterns.is_empty() {
|
if !props.error_patterns.is_empty() {
|
||||||
fatal(~"both error pattern and expected errors specified");
|
fatal(~"both error pattern and expected errors specified");
|
||||||
}
|
}
|
||||||
check_expected_errors(expected_errors, testfile, &ProcRes);
|
check_expected_errors(expected_errors, testfile, &proc_res);
|
||||||
} else {
|
} else {
|
||||||
check_error_patterns(props, testfile, &ProcRes);
|
check_error_patterns(props, testfile, &proc_res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_rfail_test(config: &config, props: &TestProps, testfile: &Path) {
|
fn run_rfail_test(config: &config, props: &TestProps, testfile: &Path) {
|
||||||
let ProcRes = if !config.jit {
|
let proc_res = if !config.jit {
|
||||||
let ProcRes = compile_test(config, props, testfile);
|
let proc_res = compile_test(config, props, testfile);
|
||||||
|
|
||||||
if !ProcRes.status.success() {
|
if !proc_res.status.success() {
|
||||||
fatal_ProcRes(~"compilation failed!", &ProcRes);
|
fatal_ProcRes(~"compilation failed!", &proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
exec_compiled_test(config, props, testfile)
|
exec_compiled_test(config, props, testfile)
|
||||||
@ -107,41 +107,41 @@ fn run_rfail_test(config: &config, props: &TestProps, testfile: &Path) {
|
|||||||
|
|
||||||
// The value our Makefile configures valgrind to return on failure
|
// The value our Makefile configures valgrind to return on failure
|
||||||
static VALGRIND_ERR: int = 100;
|
static VALGRIND_ERR: int = 100;
|
||||||
if ProcRes.status.matches_exit_status(VALGRIND_ERR) {
|
if proc_res.status.matches_exit_status(VALGRIND_ERR) {
|
||||||
fatal_ProcRes(~"run-fail test isn't valgrind-clean!", &ProcRes);
|
fatal_ProcRes(~"run-fail test isn't valgrind-clean!", &proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
check_correct_failure_status(&ProcRes);
|
check_correct_failure_status(&proc_res);
|
||||||
check_error_patterns(props, testfile, &ProcRes);
|
check_error_patterns(props, testfile, &proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_correct_failure_status(ProcRes: &ProcRes) {
|
fn check_correct_failure_status(proc_res: &ProcRes) {
|
||||||
// The value the rust runtime returns on failure
|
// The value the rust runtime returns on failure
|
||||||
static RUST_ERR: int = 101;
|
static RUST_ERR: int = 101;
|
||||||
if !ProcRes.status.matches_exit_status(RUST_ERR) {
|
if !proc_res.status.matches_exit_status(RUST_ERR) {
|
||||||
fatal_ProcRes(
|
fatal_ProcRes(
|
||||||
format!("failure produced the wrong error: {}", ProcRes.status),
|
format!("failure produced the wrong error: {}", proc_res.status),
|
||||||
ProcRes);
|
proc_res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_rpass_test(config: &config, props: &TestProps, testfile: &Path) {
|
fn run_rpass_test(config: &config, props: &TestProps, testfile: &Path) {
|
||||||
if !config.jit {
|
if !config.jit {
|
||||||
let mut ProcRes = compile_test(config, props, testfile);
|
let mut proc_res = compile_test(config, props, testfile);
|
||||||
|
|
||||||
if !ProcRes.status.success() {
|
if !proc_res.status.success() {
|
||||||
fatal_ProcRes(~"compilation failed!", &ProcRes);
|
fatal_ProcRes(~"compilation failed!", &proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcRes = exec_compiled_test(config, props, testfile);
|
proc_res = exec_compiled_test(config, props, testfile);
|
||||||
|
|
||||||
if !ProcRes.status.success() {
|
if !proc_res.status.success() {
|
||||||
fatal_ProcRes(~"test run failed!", &ProcRes);
|
fatal_ProcRes(~"test run failed!", &proc_res);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let ProcRes = jit_test(config, props, testfile);
|
let proc_res = jit_test(config, props, testfile);
|
||||||
|
|
||||||
if !ProcRes.status.success() { fatal_ProcRes(~"jit failed!", &ProcRes); }
|
if !proc_res.status.success() { fatal_ProcRes(~"jit failed!", &proc_res); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,14 +160,14 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
|
|||||||
let mut round = 0;
|
let mut round = 0;
|
||||||
while round < rounds {
|
while round < rounds {
|
||||||
logv(config, format!("pretty-printing round {}", round));
|
logv(config, format!("pretty-printing round {}", round));
|
||||||
let ProcRes = print_source(config, testfile, srcs[round].clone());
|
let proc_res = print_source(config, testfile, srcs[round].clone());
|
||||||
|
|
||||||
if !ProcRes.status.success() {
|
if !proc_res.status.success() {
|
||||||
fatal_ProcRes(format!("pretty-printing failed in round {}", round),
|
fatal_ProcRes(format!("pretty-printing failed in round {}", round),
|
||||||
&ProcRes);
|
&proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
let ProcRes{ stdout, .. } = ProcRes;
|
let ProcRes{ stdout, .. } = proc_res;
|
||||||
srcs.push(stdout);
|
srcs.push(stdout);
|
||||||
round += 1;
|
round += 1;
|
||||||
}
|
}
|
||||||
@ -192,10 +192,10 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
|
|||||||
compare_source(expected, actual);
|
compare_source(expected, actual);
|
||||||
|
|
||||||
// Finally, let's make sure it actually appears to remain valid code
|
// Finally, let's make sure it actually appears to remain valid code
|
||||||
let ProcRes = typecheck_source(config, props, testfile, actual);
|
let proc_res = typecheck_source(config, props, testfile, actual);
|
||||||
|
|
||||||
if !ProcRes.status.success() {
|
if !proc_res.status.success() {
|
||||||
fatal_ProcRes(~"pretty-printed source does not typecheck", &ProcRes);
|
fatal_ProcRes(~"pretty-printed source does not typecheck", &proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -269,14 +269,14 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
|
|||||||
let mut cmds = props.debugger_cmds.connect("\n");
|
let mut cmds = props.debugger_cmds.connect("\n");
|
||||||
|
|
||||||
// compile test file (it shoud have 'compile-flags:-g' in the header)
|
// compile test file (it shoud have 'compile-flags:-g' in the header)
|
||||||
let mut ProcRes = compile_test(config, props, testfile);
|
let mut proc_res = compile_test(config, props, testfile);
|
||||||
if !ProcRes.status.success() {
|
if !proc_res.status.success() {
|
||||||
fatal_ProcRes(~"compilation failed!", &ProcRes);
|
fatal_ProcRes(~"compilation failed!", &proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
let exe_file = make_exe_name(config, testfile);
|
let exe_file = make_exe_name(config, testfile);
|
||||||
|
|
||||||
let mut ProcArgs;
|
let mut proc_args;
|
||||||
match config.target {
|
match config.target {
|
||||||
~"arm-linux-androideabi" => {
|
~"arm-linux-androideabi" => {
|
||||||
|
|
||||||
@ -356,7 +356,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
|
|||||||
cmdline
|
cmdline
|
||||||
};
|
};
|
||||||
|
|
||||||
ProcRes = ProcRes {status: status,
|
proc_res = ProcRes {status: status,
|
||||||
stdout: out,
|
stdout: out,
|
||||||
stderr: err,
|
stderr: err,
|
||||||
cmdline: cmdline};
|
cmdline: cmdline};
|
||||||
@ -383,12 +383,12 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
|
|||||||
let debugger_opts = ~[~"-quiet", ~"-batch", ~"-nx",
|
let debugger_opts = ~[~"-quiet", ~"-batch", ~"-nx",
|
||||||
"-command=" + debugger_script.as_str().unwrap().to_owned(),
|
"-command=" + debugger_script.as_str().unwrap().to_owned(),
|
||||||
exe_file.as_str().unwrap().to_owned()];
|
exe_file.as_str().unwrap().to_owned()];
|
||||||
ProcArgs = ProcArgs {prog: debugger(), args: debugger_opts};
|
proc_args = ProcArgs {prog: debugger(), args: debugger_opts};
|
||||||
ProcRes = compose_and_run(config, testfile, ProcArgs, ~[], "", None);
|
proc_res = compose_and_run(config, testfile, proc_args, ~[], "", None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !ProcRes.status.success() {
|
if !proc_res.status.success() {
|
||||||
fatal(~"gdb failed to execute");
|
fatal(~"gdb failed to execute");
|
||||||
}
|
}
|
||||||
let num_check_lines = check_lines.len();
|
let num_check_lines = check_lines.len();
|
||||||
@ -399,7 +399,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
|
|||||||
// check if each line in props.check_lines appears in the
|
// check if each line in props.check_lines appears in the
|
||||||
// output (in order)
|
// output (in order)
|
||||||
let mut i = 0u;
|
let mut i = 0u;
|
||||||
for line in ProcRes.stdout.lines() {
|
for line in proc_res.stdout.lines() {
|
||||||
let mut rest = line.trim();
|
let mut rest = line.trim();
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
let mut failed = false;
|
let mut failed = false;
|
||||||
@ -430,7 +430,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
|
|||||||
}
|
}
|
||||||
if i != num_check_lines {
|
if i != num_check_lines {
|
||||||
fatal_ProcRes(format!("line not found in debugger output: {}",
|
fatal_ProcRes(format!("line not found in debugger output: {}",
|
||||||
check_lines[i]), &ProcRes);
|
check_lines[i]), &proc_res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,12 +451,12 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
|
|||||||
|
|
||||||
fn check_error_patterns(props: &TestProps,
|
fn check_error_patterns(props: &TestProps,
|
||||||
testfile: &Path,
|
testfile: &Path,
|
||||||
ProcRes: &ProcRes) {
|
proc_res: &ProcRes) {
|
||||||
if props.error_patterns.is_empty() {
|
if props.error_patterns.is_empty() {
|
||||||
fatal(~"no error pattern specified in " + testfile.display().as_maybe_owned().as_slice());
|
fatal(~"no error pattern specified in " + testfile.display().as_maybe_owned().as_slice());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ProcRes.status.success() {
|
if proc_res.status.success() {
|
||||||
fatal(~"process did not return an error status");
|
fatal(~"process did not return an error status");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,9 +464,9 @@ fn check_error_patterns(props: &TestProps,
|
|||||||
let mut next_err_pat = &props.error_patterns[next_err_idx];
|
let mut next_err_pat = &props.error_patterns[next_err_idx];
|
||||||
let mut done = false;
|
let mut done = false;
|
||||||
let output_to_check = if props.check_stdout {
|
let output_to_check = if props.check_stdout {
|
||||||
ProcRes.stdout + ProcRes.stderr
|
proc_res.stdout + proc_res.stderr
|
||||||
} else {
|
} else {
|
||||||
ProcRes.stderr.clone()
|
proc_res.stderr.clone()
|
||||||
};
|
};
|
||||||
for line in output_to_check.lines() {
|
for line in output_to_check.lines() {
|
||||||
if line.contains(*next_err_pat) {
|
if line.contains(*next_err_pat) {
|
||||||
@ -486,24 +486,24 @@ fn check_error_patterns(props: &TestProps,
|
|||||||
props.error_patterns.slice(next_err_idx, props.error_patterns.len());
|
props.error_patterns.slice(next_err_idx, props.error_patterns.len());
|
||||||
if missing_patterns.len() == 1u {
|
if missing_patterns.len() == 1u {
|
||||||
fatal_ProcRes(format!("error pattern '{}' not found!",
|
fatal_ProcRes(format!("error pattern '{}' not found!",
|
||||||
missing_patterns[0]), ProcRes);
|
missing_patterns[0]), proc_res);
|
||||||
} else {
|
} else {
|
||||||
for pattern in missing_patterns.iter() {
|
for pattern in missing_patterns.iter() {
|
||||||
error(format!("error pattern '{}' not found!", *pattern));
|
error(format!("error pattern '{}' not found!", *pattern));
|
||||||
}
|
}
|
||||||
fatal_ProcRes(~"multiple error patterns not found", ProcRes);
|
fatal_ProcRes(~"multiple error patterns not found", proc_res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
|
fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
|
||||||
testfile: &Path,
|
testfile: &Path,
|
||||||
ProcRes: &ProcRes) {
|
proc_res: &ProcRes) {
|
||||||
|
|
||||||
// true if we found the error in question
|
// true if we found the error in question
|
||||||
let mut found_flags = vec::from_elem(
|
let mut found_flags = vec::from_elem(
|
||||||
expected_errors.len(), false);
|
expected_errors.len(), false);
|
||||||
|
|
||||||
if ProcRes.status.success() {
|
if proc_res.status.success() {
|
||||||
fatal(~"process did not return an error status");
|
fatal(~"process did not return an error status");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -542,7 +542,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
|
|||||||
// filename:line1:col1: line2:col2: *warning:* msg
|
// filename:line1:col1: line2:col2: *warning:* msg
|
||||||
// where line1:col1: is the starting point, line2:col2:
|
// where line1:col1: is the starting point, line2:col2:
|
||||||
// is the ending point, and * represents ANSI color codes.
|
// is the ending point, and * represents ANSI color codes.
|
||||||
for line in ProcRes.stderr.lines() {
|
for line in proc_res.stderr.lines() {
|
||||||
let mut was_expected = false;
|
let mut was_expected = false;
|
||||||
for (i, ee) in expected_errors.iter().enumerate() {
|
for (i, ee) in expected_errors.iter().enumerate() {
|
||||||
if !found_flags[i] {
|
if !found_flags[i] {
|
||||||
@ -566,7 +566,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
|
|||||||
if !was_expected && is_compiler_error_or_warning(line) {
|
if !was_expected && is_compiler_error_or_warning(line) {
|
||||||
fatal_ProcRes(format!("unexpected compiler error or warning: '{}'",
|
fatal_ProcRes(format!("unexpected compiler error or warning: '{}'",
|
||||||
line),
|
line),
|
||||||
ProcRes);
|
proc_res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -574,7 +574,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
|
|||||||
if !flag {
|
if !flag {
|
||||||
let ee = &expected_errors[i];
|
let ee = &expected_errors[i];
|
||||||
fatal_ProcRes(format!("expected {} on line {} not found: {}",
|
fatal_ProcRes(format!("expected {} on line {} not found: {}",
|
||||||
ee.kind, ee.line, ee.msg), ProcRes);
|
ee.kind, ee.line, ee.msg), proc_res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -933,7 +933,7 @@ fn error(err: ~str) { println!("\nerror: {}", err); }
|
|||||||
|
|
||||||
fn fatal(err: ~str) -> ! { error(err); fail!(); }
|
fn fatal(err: ~str) -> ! { error(err); fail!(); }
|
||||||
|
|
||||||
fn fatal_ProcRes(err: ~str, ProcRes: &ProcRes) -> ! {
|
fn fatal_ProcRes(err: ~str, proc_res: &ProcRes) -> ! {
|
||||||
print!("\n\
|
print!("\n\
|
||||||
error: {}\n\
|
error: {}\n\
|
||||||
command: {}\n\
|
command: {}\n\
|
||||||
@ -946,7 +946,7 @@ stderr:\n\
|
|||||||
{}\n\
|
{}\n\
|
||||||
------------------------------------------\n\
|
------------------------------------------\n\
|
||||||
\n",
|
\n",
|
||||||
err, ProcRes.cmdline, ProcRes.stdout, ProcRes.stderr);
|
err, proc_res.cmdline, proc_res.stdout, proc_res.stderr);
|
||||||
fail!();
|
fail!();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1094,7 +1094,7 @@ fn compile_cc_with_clang_and_save_bitcode(config: &config, _props: &TestProps,
|
|||||||
let bitcodefile = output_base_name(config, testfile).with_extension("bc");
|
let bitcodefile = output_base_name(config, testfile).with_extension("bc");
|
||||||
let bitcodefile = append_suffix_to_stem(&bitcodefile, "clang");
|
let bitcodefile = append_suffix_to_stem(&bitcodefile, "clang");
|
||||||
let testcc = testfile.with_extension("cc");
|
let testcc = testfile.with_extension("cc");
|
||||||
let ProcArgs = ProcArgs {
|
let proc_args = ProcArgs {
|
||||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||||
prog: config.clang_path.get_ref().as_str().unwrap().to_owned(),
|
prog: config.clang_path.get_ref().as_str().unwrap().to_owned(),
|
||||||
args: ~[~"-c",
|
args: ~[~"-c",
|
||||||
@ -1102,7 +1102,7 @@ fn compile_cc_with_clang_and_save_bitcode(config: &config, _props: &TestProps,
|
|||||||
~"-o", bitcodefile.as_str().unwrap().to_owned(),
|
~"-o", bitcodefile.as_str().unwrap().to_owned(),
|
||||||
testcc.as_str().unwrap().to_owned() ]
|
testcc.as_str().unwrap().to_owned() ]
|
||||||
};
|
};
|
||||||
compose_and_run(config, testfile, ProcArgs, ~[], "", None)
|
compose_and_run(config, testfile, proc_args, ~[], "", None)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extract_function_from_bitcode(config: &config, _props: &TestProps,
|
fn extract_function_from_bitcode(config: &config, _props: &TestProps,
|
||||||
@ -1112,14 +1112,14 @@ fn extract_function_from_bitcode(config: &config, _props: &TestProps,
|
|||||||
let bitcodefile = append_suffix_to_stem(&bitcodefile, suffix);
|
let bitcodefile = append_suffix_to_stem(&bitcodefile, suffix);
|
||||||
let extracted_bc = append_suffix_to_stem(&bitcodefile, "extract");
|
let extracted_bc = append_suffix_to_stem(&bitcodefile, "extract");
|
||||||
let prog = config.llvm_bin_path.get_ref().join("llvm-extract");
|
let prog = config.llvm_bin_path.get_ref().join("llvm-extract");
|
||||||
let ProcArgs = ProcArgs {
|
let proc_args = ProcArgs {
|
||||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||||
prog: prog.as_str().unwrap().to_owned(),
|
prog: prog.as_str().unwrap().to_owned(),
|
||||||
args: ~["-func=" + fname,
|
args: ~["-func=" + fname,
|
||||||
"-o=" + extracted_bc.as_str().unwrap(),
|
"-o=" + extracted_bc.as_str().unwrap(),
|
||||||
bitcodefile.as_str().unwrap().to_owned() ]
|
bitcodefile.as_str().unwrap().to_owned() ]
|
||||||
};
|
};
|
||||||
compose_and_run(config, testfile, ProcArgs, ~[], "", None)
|
compose_and_run(config, testfile, proc_args, ~[], "", None)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn disassemble_extract(config: &config, _props: &TestProps,
|
fn disassemble_extract(config: &config, _props: &TestProps,
|
||||||
@ -1129,13 +1129,13 @@ fn disassemble_extract(config: &config, _props: &TestProps,
|
|||||||
let extracted_bc = append_suffix_to_stem(&bitcodefile, "extract");
|
let extracted_bc = append_suffix_to_stem(&bitcodefile, "extract");
|
||||||
let extracted_ll = extracted_bc.with_extension("ll");
|
let extracted_ll = extracted_bc.with_extension("ll");
|
||||||
let prog = config.llvm_bin_path.get_ref().join("llvm-dis");
|
let prog = config.llvm_bin_path.get_ref().join("llvm-dis");
|
||||||
let ProcArgs = ProcArgs {
|
let proc_args = ProcArgs {
|
||||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||||
prog: prog.as_str().unwrap().to_owned(),
|
prog: prog.as_str().unwrap().to_owned(),
|
||||||
args: ~["-o=" + extracted_ll.as_str().unwrap(),
|
args: ~["-o=" + extracted_ll.as_str().unwrap(),
|
||||||
extracted_bc.as_str().unwrap().to_owned() ]
|
extracted_bc.as_str().unwrap().to_owned() ]
|
||||||
};
|
};
|
||||||
compose_and_run(config, testfile, ProcArgs, ~[], "", None)
|
compose_and_run(config, testfile, proc_args, ~[], "", None)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1157,35 +1157,35 @@ fn run_codegen_test(config: &config, props: &TestProps,
|
|||||||
fatal(~"missing --clang-path");
|
fatal(~"missing --clang-path");
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut ProcRes = compile_test_and_save_bitcode(config, props, testfile);
|
let mut proc_res = compile_test_and_save_bitcode(config, props, testfile);
|
||||||
if !ProcRes.status.success() {
|
if !proc_res.status.success() {
|
||||||
fatal_ProcRes(~"compilation failed!", &ProcRes);
|
fatal_ProcRes(~"compilation failed!", &proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcRes = extract_function_from_bitcode(config, props, "test", testfile, "");
|
proc_res = extract_function_from_bitcode(config, props, "test", testfile, "");
|
||||||
if !ProcRes.status.success() {
|
if !proc_res.status.success() {
|
||||||
fatal_ProcRes(~"extracting 'test' function failed", &ProcRes);
|
fatal_ProcRes(~"extracting 'test' function failed", &proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcRes = disassemble_extract(config, props, testfile, "");
|
proc_res = disassemble_extract(config, props, testfile, "");
|
||||||
if !ProcRes.status.success() {
|
if !proc_res.status.success() {
|
||||||
fatal_ProcRes(~"disassembling extract failed", &ProcRes);
|
fatal_ProcRes(~"disassembling extract failed", &proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let mut ProcRes = compile_cc_with_clang_and_save_bitcode(config, props, testfile);
|
let mut proc_res = compile_cc_with_clang_and_save_bitcode(config, props, testfile);
|
||||||
if !ProcRes.status.success() {
|
if !proc_res.status.success() {
|
||||||
fatal_ProcRes(~"compilation failed!", &ProcRes);
|
fatal_ProcRes(~"compilation failed!", &proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcRes = extract_function_from_bitcode(config, props, "test", testfile, "clang");
|
proc_res = extract_function_from_bitcode(config, props, "test", testfile, "clang");
|
||||||
if !ProcRes.status.success() {
|
if !proc_res.status.success() {
|
||||||
fatal_ProcRes(~"extracting 'test' function failed", &ProcRes);
|
fatal_ProcRes(~"extracting 'test' function failed", &proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcRes = disassemble_extract(config, props, testfile, "clang");
|
proc_res = disassemble_extract(config, props, testfile, "clang");
|
||||||
if !ProcRes.status.success() {
|
if !proc_res.status.success() {
|
||||||
fatal_ProcRes(~"disassembling extract failed", &ProcRes);
|
fatal_ProcRes(~"disassembling extract failed", &proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
let base = output_base_name(config, testfile);
|
let base = output_base_name(config, testfile);
|
||||||
|
@ -266,14 +266,14 @@ impl Mul<BigUint, BigUint> for BigUint {
|
|||||||
// (a1*b1 + a0*b0 - (a1-b0)*(b1-a0)) * base +
|
// (a1*b1 + a0*b0 - (a1-b0)*(b1-a0)) * base +
|
||||||
// a0*b0
|
// a0*b0
|
||||||
let half_len = cmp::max(s_len, o_len) / 2;
|
let half_len = cmp::max(s_len, o_len) / 2;
|
||||||
let (sHi, sLo) = cut_at(self, half_len);
|
let (s_hi, s_lo) = cut_at(self, half_len);
|
||||||
let (oHi, oLo) = cut_at(other, half_len);
|
let (o_hi, o_lo) = cut_at(other, half_len);
|
||||||
|
|
||||||
let ll = sLo * oLo;
|
let ll = s_lo * o_lo;
|
||||||
let hh = sHi * oHi;
|
let hh = s_hi * o_hi;
|
||||||
let mm = {
|
let mm = {
|
||||||
let (s1, n1) = sub_sign(sHi, sLo);
|
let (s1, n1) = sub_sign(s_hi, s_lo);
|
||||||
let (s2, n2) = sub_sign(oHi, oLo);
|
let (s2, n2) = sub_sign(o_hi, o_lo);
|
||||||
match (s1, s2) {
|
match (s1, s2) {
|
||||||
(Equal, _) | (_, Equal) => hh + ll,
|
(Equal, _) | (_, Equal) => hh + ll,
|
||||||
(Less, Greater) | (Greater, Less) => hh + ll + (n1 * n2),
|
(Less, Greater) | (Greater, Less) => hh + ll + (n1 * n2),
|
||||||
@ -1778,10 +1778,10 @@ mod biguint_tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_add() {
|
fn test_add() {
|
||||||
for elm in sum_triples.iter() {
|
for elm in sum_triples.iter() {
|
||||||
let (aVec, bVec, cVec) = *elm;
|
let (a_vec, b_vec, c_vec) = *elm;
|
||||||
let a = BigUint::from_slice(aVec);
|
let a = BigUint::from_slice(a_vec);
|
||||||
let b = BigUint::from_slice(bVec);
|
let b = BigUint::from_slice(b_vec);
|
||||||
let c = BigUint::from_slice(cVec);
|
let c = BigUint::from_slice(c_vec);
|
||||||
|
|
||||||
assert!(a + b == c);
|
assert!(a + b == c);
|
||||||
assert!(b + a == c);
|
assert!(b + a == c);
|
||||||
@ -1791,10 +1791,10 @@ mod biguint_tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_sub() {
|
fn test_sub() {
|
||||||
for elm in sum_triples.iter() {
|
for elm in sum_triples.iter() {
|
||||||
let (aVec, bVec, cVec) = *elm;
|
let (a_vec, b_vec, c_vec) = *elm;
|
||||||
let a = BigUint::from_slice(aVec);
|
let a = BigUint::from_slice(a_vec);
|
||||||
let b = BigUint::from_slice(bVec);
|
let b = BigUint::from_slice(b_vec);
|
||||||
let c = BigUint::from_slice(cVec);
|
let c = BigUint::from_slice(c_vec);
|
||||||
|
|
||||||
assert!(c - a == b);
|
assert!(c - a == b);
|
||||||
assert!(c - b == a);
|
assert!(c - b == a);
|
||||||
@ -1842,21 +1842,21 @@ mod biguint_tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_mul() {
|
fn test_mul() {
|
||||||
for elm in mul_triples.iter() {
|
for elm in mul_triples.iter() {
|
||||||
let (aVec, bVec, cVec) = *elm;
|
let (a_vec, b_vec, c_vec) = *elm;
|
||||||
let a = BigUint::from_slice(aVec);
|
let a = BigUint::from_slice(a_vec);
|
||||||
let b = BigUint::from_slice(bVec);
|
let b = BigUint::from_slice(b_vec);
|
||||||
let c = BigUint::from_slice(cVec);
|
let c = BigUint::from_slice(c_vec);
|
||||||
|
|
||||||
assert!(a * b == c);
|
assert!(a * b == c);
|
||||||
assert!(b * a == c);
|
assert!(b * a == c);
|
||||||
}
|
}
|
||||||
|
|
||||||
for elm in div_rem_quadruples.iter() {
|
for elm in div_rem_quadruples.iter() {
|
||||||
let (aVec, bVec, cVec, dVec) = *elm;
|
let (a_vec, b_vec, c_vec, d_vec) = *elm;
|
||||||
let a = BigUint::from_slice(aVec);
|
let a = BigUint::from_slice(a_vec);
|
||||||
let b = BigUint::from_slice(bVec);
|
let b = BigUint::from_slice(b_vec);
|
||||||
let c = BigUint::from_slice(cVec);
|
let c = BigUint::from_slice(c_vec);
|
||||||
let d = BigUint::from_slice(dVec);
|
let d = BigUint::from_slice(d_vec);
|
||||||
|
|
||||||
assert!(a == b * c + d);
|
assert!(a == b * c + d);
|
||||||
assert!(a == c * b + d);
|
assert!(a == c * b + d);
|
||||||
@ -1866,10 +1866,10 @@ mod biguint_tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_div_rem() {
|
fn test_div_rem() {
|
||||||
for elm in mul_triples.iter() {
|
for elm in mul_triples.iter() {
|
||||||
let (aVec, bVec, cVec) = *elm;
|
let (a_vec, b_vec, c_vec) = *elm;
|
||||||
let a = BigUint::from_slice(aVec);
|
let a = BigUint::from_slice(a_vec);
|
||||||
let b = BigUint::from_slice(bVec);
|
let b = BigUint::from_slice(b_vec);
|
||||||
let c = BigUint::from_slice(cVec);
|
let c = BigUint::from_slice(c_vec);
|
||||||
|
|
||||||
if !a.is_zero() {
|
if !a.is_zero() {
|
||||||
assert_eq!(c.div_rem(&a), (b.clone(), Zero::zero()));
|
assert_eq!(c.div_rem(&a), (b.clone(), Zero::zero()));
|
||||||
@ -1880,11 +1880,11 @@ mod biguint_tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for elm in div_rem_quadruples.iter() {
|
for elm in div_rem_quadruples.iter() {
|
||||||
let (aVec, bVec, cVec, dVec) = *elm;
|
let (a_vec, b_vec, c_vec, d_vec) = *elm;
|
||||||
let a = BigUint::from_slice(aVec);
|
let a = BigUint::from_slice(a_vec);
|
||||||
let b = BigUint::from_slice(bVec);
|
let b = BigUint::from_slice(b_vec);
|
||||||
let c = BigUint::from_slice(cVec);
|
let c = BigUint::from_slice(c_vec);
|
||||||
let d = BigUint::from_slice(dVec);
|
let d = BigUint::from_slice(d_vec);
|
||||||
|
|
||||||
if !b.is_zero() { assert!(a.div_rem(&b) == (c, d)); }
|
if !b.is_zero() { assert!(a.div_rem(&b) == (c, d)); }
|
||||||
}
|
}
|
||||||
@ -2351,10 +2351,10 @@ mod bigint_tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_add() {
|
fn test_add() {
|
||||||
for elm in sum_triples.iter() {
|
for elm in sum_triples.iter() {
|
||||||
let (aVec, bVec, cVec) = *elm;
|
let (a_vec, b_vec, c_vec) = *elm;
|
||||||
let a = BigInt::from_slice(Plus, aVec);
|
let a = BigInt::from_slice(Plus, a_vec);
|
||||||
let b = BigInt::from_slice(Plus, bVec);
|
let b = BigInt::from_slice(Plus, b_vec);
|
||||||
let c = BigInt::from_slice(Plus, cVec);
|
let c = BigInt::from_slice(Plus, c_vec);
|
||||||
|
|
||||||
assert!(a + b == c);
|
assert!(a + b == c);
|
||||||
assert!(b + a == c);
|
assert!(b + a == c);
|
||||||
@ -2370,10 +2370,10 @@ mod bigint_tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_sub() {
|
fn test_sub() {
|
||||||
for elm in sum_triples.iter() {
|
for elm in sum_triples.iter() {
|
||||||
let (aVec, bVec, cVec) = *elm;
|
let (a_vec, b_vec, c_vec) = *elm;
|
||||||
let a = BigInt::from_slice(Plus, aVec);
|
let a = BigInt::from_slice(Plus, a_vec);
|
||||||
let b = BigInt::from_slice(Plus, bVec);
|
let b = BigInt::from_slice(Plus, b_vec);
|
||||||
let c = BigInt::from_slice(Plus, cVec);
|
let c = BigInt::from_slice(Plus, c_vec);
|
||||||
|
|
||||||
assert!(c - a == b);
|
assert!(c - a == b);
|
||||||
assert!(c - b == a);
|
assert!(c - b == a);
|
||||||
@ -2427,10 +2427,10 @@ mod bigint_tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_mul() {
|
fn test_mul() {
|
||||||
for elm in mul_triples.iter() {
|
for elm in mul_triples.iter() {
|
||||||
let (aVec, bVec, cVec) = *elm;
|
let (a_vec, b_vec, c_vec) = *elm;
|
||||||
let a = BigInt::from_slice(Plus, aVec);
|
let a = BigInt::from_slice(Plus, a_vec);
|
||||||
let b = BigInt::from_slice(Plus, bVec);
|
let b = BigInt::from_slice(Plus, b_vec);
|
||||||
let c = BigInt::from_slice(Plus, cVec);
|
let c = BigInt::from_slice(Plus, c_vec);
|
||||||
|
|
||||||
assert!(a * b == c);
|
assert!(a * b == c);
|
||||||
assert!(b * a == c);
|
assert!(b * a == c);
|
||||||
@ -2440,11 +2440,11 @@ mod bigint_tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for elm in div_rem_quadruples.iter() {
|
for elm in div_rem_quadruples.iter() {
|
||||||
let (aVec, bVec, cVec, dVec) = *elm;
|
let (a_vec, b_vec, c_vec, d_vec) = *elm;
|
||||||
let a = BigInt::from_slice(Plus, aVec);
|
let a = BigInt::from_slice(Plus, a_vec);
|
||||||
let b = BigInt::from_slice(Plus, bVec);
|
let b = BigInt::from_slice(Plus, b_vec);
|
||||||
let c = BigInt::from_slice(Plus, cVec);
|
let c = BigInt::from_slice(Plus, c_vec);
|
||||||
let d = BigInt::from_slice(Plus, dVec);
|
let d = BigInt::from_slice(Plus, d_vec);
|
||||||
|
|
||||||
assert!(a == b * c + d);
|
assert!(a == b * c + d);
|
||||||
assert!(a == c * b + d);
|
assert!(a == c * b + d);
|
||||||
@ -2479,21 +2479,21 @@ mod bigint_tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for elm in mul_triples.iter() {
|
for elm in mul_triples.iter() {
|
||||||
let (aVec, bVec, cVec) = *elm;
|
let (a_vec, b_vec, c_vec) = *elm;
|
||||||
let a = BigInt::from_slice(Plus, aVec);
|
let a = BigInt::from_slice(Plus, a_vec);
|
||||||
let b = BigInt::from_slice(Plus, bVec);
|
let b = BigInt::from_slice(Plus, b_vec);
|
||||||
let c = BigInt::from_slice(Plus, cVec);
|
let c = BigInt::from_slice(Plus, c_vec);
|
||||||
|
|
||||||
if !a.is_zero() { check(&c, &a, &b, &Zero::zero()); }
|
if !a.is_zero() { check(&c, &a, &b, &Zero::zero()); }
|
||||||
if !b.is_zero() { check(&c, &b, &a, &Zero::zero()); }
|
if !b.is_zero() { check(&c, &b, &a, &Zero::zero()); }
|
||||||
}
|
}
|
||||||
|
|
||||||
for elm in div_rem_quadruples.iter() {
|
for elm in div_rem_quadruples.iter() {
|
||||||
let (aVec, bVec, cVec, dVec) = *elm;
|
let (a_vec, b_vec, c_vec, d_vec) = *elm;
|
||||||
let a = BigInt::from_slice(Plus, aVec);
|
let a = BigInt::from_slice(Plus, a_vec);
|
||||||
let b = BigInt::from_slice(Plus, bVec);
|
let b = BigInt::from_slice(Plus, b_vec);
|
||||||
let c = BigInt::from_slice(Plus, cVec);
|
let c = BigInt::from_slice(Plus, c_vec);
|
||||||
let d = BigInt::from_slice(Plus, dVec);
|
let d = BigInt::from_slice(Plus, d_vec);
|
||||||
|
|
||||||
if !b.is_zero() {
|
if !b.is_zero() {
|
||||||
check(&a, &b, &c, &d);
|
check(&a, &b, &c, &d);
|
||||||
@ -2522,21 +2522,21 @@ mod bigint_tests {
|
|||||||
check_sub(&a.neg(), &b.neg(), q, &r.neg());
|
check_sub(&a.neg(), &b.neg(), q, &r.neg());
|
||||||
}
|
}
|
||||||
for elm in mul_triples.iter() {
|
for elm in mul_triples.iter() {
|
||||||
let (aVec, bVec, cVec) = *elm;
|
let (a_vec, b_vec, c_vec) = *elm;
|
||||||
let a = BigInt::from_slice(Plus, aVec);
|
let a = BigInt::from_slice(Plus, a_vec);
|
||||||
let b = BigInt::from_slice(Plus, bVec);
|
let b = BigInt::from_slice(Plus, b_vec);
|
||||||
let c = BigInt::from_slice(Plus, cVec);
|
let c = BigInt::from_slice(Plus, c_vec);
|
||||||
|
|
||||||
if !a.is_zero() { check(&c, &a, &b, &Zero::zero()); }
|
if !a.is_zero() { check(&c, &a, &b, &Zero::zero()); }
|
||||||
if !b.is_zero() { check(&c, &b, &a, &Zero::zero()); }
|
if !b.is_zero() { check(&c, &b, &a, &Zero::zero()); }
|
||||||
}
|
}
|
||||||
|
|
||||||
for elm in div_rem_quadruples.iter() {
|
for elm in div_rem_quadruples.iter() {
|
||||||
let (aVec, bVec, cVec, dVec) = *elm;
|
let (a_vec, b_vec, c_vec, d_vec) = *elm;
|
||||||
let a = BigInt::from_slice(Plus, aVec);
|
let a = BigInt::from_slice(Plus, a_vec);
|
||||||
let b = BigInt::from_slice(Plus, bVec);
|
let b = BigInt::from_slice(Plus, b_vec);
|
||||||
let c = BigInt::from_slice(Plus, cVec);
|
let c = BigInt::from_slice(Plus, c_vec);
|
||||||
let d = BigInt::from_slice(Plus, dVec);
|
let d = BigInt::from_slice(Plus, d_vec);
|
||||||
|
|
||||||
if !b.is_zero() {
|
if !b.is_zero() {
|
||||||
check(&a, &b, &c, &d);
|
check(&a, &b, &c, &d);
|
||||||
|
@ -68,15 +68,15 @@ pub fn llvm_err(sess: Session, msg: ~str) -> ! {
|
|||||||
|
|
||||||
pub fn WriteOutputFile(
|
pub fn WriteOutputFile(
|
||||||
sess: Session,
|
sess: Session,
|
||||||
Target: lib::llvm::TargetMachineRef,
|
target: lib::llvm::TargetMachineRef,
|
||||||
PM: lib::llvm::PassManagerRef,
|
pm: lib::llvm::PassManagerRef,
|
||||||
M: ModuleRef,
|
m: ModuleRef,
|
||||||
Output: &Path,
|
output: &Path,
|
||||||
FileType: lib::llvm::FileType) {
|
file_type: lib::llvm::FileType) {
|
||||||
unsafe {
|
unsafe {
|
||||||
Output.with_c_str(|Output| {
|
output.with_c_str(|output| {
|
||||||
let result = llvm::LLVMRustWriteOutputFile(
|
let result = llvm::LLVMRustWriteOutputFile(
|
||||||
Target, PM, M, Output, FileType);
|
target, pm, m, output, file_type);
|
||||||
if !result {
|
if !result {
|
||||||
llvm_err(sess, ~"could not write output");
|
llvm_err(sess, ~"could not write output");
|
||||||
}
|
}
|
||||||
@ -138,7 +138,7 @@ pub mod write {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let OptLevel = match sess.opts.optimize {
|
let opt_level = match sess.opts.optimize {
|
||||||
session::No => lib::llvm::CodeGenLevelNone,
|
session::No => lib::llvm::CodeGenLevelNone,
|
||||||
session::Less => lib::llvm::CodeGenLevelLess,
|
session::Less => lib::llvm::CodeGenLevelLess,
|
||||||
session::Default => lib::llvm::CodeGenLevelDefault,
|
session::Default => lib::llvm::CodeGenLevelDefault,
|
||||||
@ -152,14 +152,14 @@ pub mod write {
|
|||||||
(sess.targ_cfg.os == abi::OsMacos &&
|
(sess.targ_cfg.os == abi::OsMacos &&
|
||||||
sess.targ_cfg.arch == abi::X86_64);
|
sess.targ_cfg.arch == abi::X86_64);
|
||||||
|
|
||||||
let tm = sess.targ_cfg.target_strs.target_triple.with_c_str(|T| {
|
let tm = sess.targ_cfg.target_strs.target_triple.with_c_str(|t| {
|
||||||
sess.opts.cg.target_cpu.with_c_str(|CPU| {
|
sess.opts.cg.target_cpu.with_c_str(|cpu| {
|
||||||
target_feature(&sess).with_c_str(|Features| {
|
target_feature(&sess).with_c_str(|features| {
|
||||||
llvm::LLVMRustCreateTargetMachine(
|
llvm::LLVMRustCreateTargetMachine(
|
||||||
T, CPU, Features,
|
t, cpu, features,
|
||||||
lib::llvm::CodeModelDefault,
|
lib::llvm::CodeModelDefault,
|
||||||
lib::llvm::RelocPIC,
|
lib::llvm::RelocPIC,
|
||||||
OptLevel,
|
opt_level,
|
||||||
true,
|
true,
|
||||||
use_softfp,
|
use_softfp,
|
||||||
no_fp_elim
|
no_fp_elim
|
||||||
@ -185,7 +185,7 @@ pub mod write {
|
|||||||
if !sess.opts.cg.no_prepopulate_passes {
|
if !sess.opts.cg.no_prepopulate_passes {
|
||||||
llvm::LLVMRustAddAnalysisPasses(tm, fpm, llmod);
|
llvm::LLVMRustAddAnalysisPasses(tm, fpm, llmod);
|
||||||
llvm::LLVMRustAddAnalysisPasses(tm, mpm, llmod);
|
llvm::LLVMRustAddAnalysisPasses(tm, mpm, llmod);
|
||||||
populate_llvm_passes(fpm, mpm, llmod, OptLevel);
|
populate_llvm_passes(fpm, mpm, llmod, opt_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
for pass in sess.opts.cg.passes.iter() {
|
for pass in sess.opts.cg.passes.iter() {
|
||||||
|
@ -1774,25 +1774,25 @@ pub mod llvm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn SetInstructionCallConv(Instr: ValueRef, CC: CallConv) {
|
pub fn SetInstructionCallConv(instr: ValueRef, cc: CallConv) {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMSetInstructionCallConv(Instr, CC as c_uint);
|
llvm::LLVMSetInstructionCallConv(instr, cc as c_uint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn SetFunctionCallConv(Fn: ValueRef, CC: CallConv) {
|
pub fn SetFunctionCallConv(fn_: ValueRef, cc: CallConv) {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMSetFunctionCallConv(Fn, CC as c_uint);
|
llvm::LLVMSetFunctionCallConv(fn_, cc as c_uint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn SetLinkage(Global: ValueRef, Link: Linkage) {
|
pub fn SetLinkage(global: ValueRef, link: Linkage) {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMSetLinkage(Global, Link as c_uint);
|
llvm::LLVMSetLinkage(global, link as c_uint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn SetUnnamedAddr(Global: ValueRef, Unnamed: bool) {
|
pub fn SetUnnamedAddr(global: ValueRef, unnamed: bool) {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMSetUnnamedAddr(Global, Unnamed as Bool);
|
llvm::LLVMSetUnnamedAddr(global, unnamed as Bool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1802,20 +1802,20 @@ pub fn set_thread_local(global: ValueRef, is_thread_local: bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ConstICmp(Pred: IntPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef {
|
pub fn ConstICmp(pred: IntPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMConstICmp(Pred as c_ushort, V1, V2)
|
llvm::LLVMConstICmp(pred as c_ushort, v1, v2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn ConstFCmp(Pred: RealPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef {
|
pub fn ConstFCmp(pred: RealPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMConstFCmp(Pred as c_ushort, V1, V2)
|
llvm::LLVMConstFCmp(pred as c_ushort, v1, v2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn SetFunctionAttribute(Fn: ValueRef, attr: Attribute) {
|
pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMAddFunctionAttr(Fn, attr as c_uint)
|
llvm::LLVMAddFunctionAttr(fn_, attr as c_uint)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Memory-managed object interface to type handles. */
|
/* Memory-managed object interface to type handles. */
|
||||||
@ -1879,9 +1879,9 @@ impl Drop for target_data_res {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn target_data_res(TD: TargetDataRef) -> target_data_res {
|
pub fn target_data_res(td: TargetDataRef) -> target_data_res {
|
||||||
target_data_res {
|
target_data_res {
|
||||||
TD: TD
|
TD: td
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1915,9 +1915,9 @@ impl Drop for pass_manager_res {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pass_manager_res(PM: PassManagerRef) -> pass_manager_res {
|
pub fn pass_manager_res(pm: PassManagerRef) -> pass_manager_res {
|
||||||
pass_manager_res {
|
pass_manager_res {
|
||||||
PM: PM
|
PM: pm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1982,9 +1982,9 @@ impl Drop for section_iter_res {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn section_iter_res(SI: SectionIteratorRef) -> section_iter_res {
|
pub fn section_iter_res(si: SectionIteratorRef) -> section_iter_res {
|
||||||
section_iter_res {
|
section_iter_res {
|
||||||
SI: SI
|
SI: si
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,12 +82,12 @@ pub fn trans_inline_asm<'a>(bcx: &'a Block<'a>, ia: &ast::InlineAsm)
|
|||||||
|
|
||||||
debug!("Asm Constraints: {:?}", constraints);
|
debug!("Asm Constraints: {:?}", constraints);
|
||||||
|
|
||||||
let numOutputs = outputs.len();
|
let num_outputs = outputs.len();
|
||||||
|
|
||||||
// Depending on how many outputs we have, the return type is different
|
// Depending on how many outputs we have, the return type is different
|
||||||
let output_type = if numOutputs == 0 {
|
let output_type = if num_outputs == 0 {
|
||||||
Type::void()
|
Type::void()
|
||||||
} else if numOutputs == 1 {
|
} else if num_outputs == 1 {
|
||||||
output_types[0]
|
output_types[0]
|
||||||
} else {
|
} else {
|
||||||
Type::struct_(output_types, false)
|
Type::struct_(output_types, false)
|
||||||
@ -112,7 +112,7 @@ pub fn trans_inline_asm<'a>(bcx: &'a Block<'a>, ia: &ast::InlineAsm)
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Again, based on how many outputs we have
|
// Again, based on how many outputs we have
|
||||||
if numOutputs == 1 {
|
if num_outputs == 1 {
|
||||||
Store(bcx, r, *outputs.get(0));
|
Store(bcx, r, *outputs.get(0));
|
||||||
} else {
|
} else {
|
||||||
for (i, o) in outputs.iter().enumerate() {
|
for (i, o) in outputs.iter().enumerate() {
|
||||||
|
@ -54,64 +54,64 @@ pub fn RetVoid(cx: &Block) {
|
|||||||
B(cx).ret_void();
|
B(cx).ret_void();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Ret(cx: &Block, V: ValueRef) {
|
pub fn Ret(cx: &Block, v: ValueRef) {
|
||||||
if cx.unreachable.get() { return; }
|
if cx.unreachable.get() { return; }
|
||||||
check_not_terminated(cx);
|
check_not_terminated(cx);
|
||||||
terminate(cx, "Ret");
|
terminate(cx, "Ret");
|
||||||
B(cx).ret(V);
|
B(cx).ret(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn AggregateRet(cx: &Block, RetVals: &[ValueRef]) {
|
pub fn AggregateRet(cx: &Block, ret_vals: &[ValueRef]) {
|
||||||
if cx.unreachable.get() { return; }
|
if cx.unreachable.get() { return; }
|
||||||
check_not_terminated(cx);
|
check_not_terminated(cx);
|
||||||
terminate(cx, "AggregateRet");
|
terminate(cx, "AggregateRet");
|
||||||
B(cx).aggregate_ret(RetVals);
|
B(cx).aggregate_ret(ret_vals);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Br(cx: &Block, Dest: BasicBlockRef) {
|
pub fn Br(cx: &Block, dest: BasicBlockRef) {
|
||||||
if cx.unreachable.get() { return; }
|
if cx.unreachable.get() { return; }
|
||||||
check_not_terminated(cx);
|
check_not_terminated(cx);
|
||||||
terminate(cx, "Br");
|
terminate(cx, "Br");
|
||||||
B(cx).br(Dest);
|
B(cx).br(dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn CondBr(cx: &Block,
|
pub fn CondBr(cx: &Block,
|
||||||
If: ValueRef,
|
if_: ValueRef,
|
||||||
Then: BasicBlockRef,
|
then: BasicBlockRef,
|
||||||
Else: BasicBlockRef) {
|
else_: BasicBlockRef) {
|
||||||
if cx.unreachable.get() { return; }
|
if cx.unreachable.get() { return; }
|
||||||
check_not_terminated(cx);
|
check_not_terminated(cx);
|
||||||
terminate(cx, "CondBr");
|
terminate(cx, "CondBr");
|
||||||
B(cx).cond_br(If, Then, Else);
|
B(cx).cond_br(if_, then, else_);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Switch(cx: &Block, V: ValueRef, Else: BasicBlockRef, NumCases: uint)
|
pub fn Switch(cx: &Block, v: ValueRef, else_: BasicBlockRef, num_cases: uint)
|
||||||
-> ValueRef {
|
-> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(V); }
|
if cx.unreachable.get() { return _Undef(v); }
|
||||||
check_not_terminated(cx);
|
check_not_terminated(cx);
|
||||||
terminate(cx, "Switch");
|
terminate(cx, "Switch");
|
||||||
B(cx).switch(V, Else, NumCases)
|
B(cx).switch(v, else_, num_cases)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn AddCase(S: ValueRef, OnVal: ValueRef, Dest: BasicBlockRef) {
|
pub fn AddCase(s: ValueRef, on_val: ValueRef, dest: BasicBlockRef) {
|
||||||
unsafe {
|
unsafe {
|
||||||
if llvm::LLVMIsUndef(S) == lib::llvm::True { return; }
|
if llvm::LLVMIsUndef(s) == lib::llvm::True { return; }
|
||||||
llvm::LLVMAddCase(S, OnVal, Dest);
|
llvm::LLVMAddCase(s, on_val, dest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn IndirectBr(cx: &Block, Addr: ValueRef, NumDests: uint) {
|
pub fn IndirectBr(cx: &Block, addr: ValueRef, num_dests: uint) {
|
||||||
if cx.unreachable.get() { return; }
|
if cx.unreachable.get() { return; }
|
||||||
check_not_terminated(cx);
|
check_not_terminated(cx);
|
||||||
terminate(cx, "IndirectBr");
|
terminate(cx, "IndirectBr");
|
||||||
B(cx).indirect_br(Addr, NumDests);
|
B(cx).indirect_br(addr, num_dests);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Invoke(cx: &Block,
|
pub fn Invoke(cx: &Block,
|
||||||
Fn: ValueRef,
|
fn_: ValueRef,
|
||||||
Args: &[ValueRef],
|
args: &[ValueRef],
|
||||||
Then: BasicBlockRef,
|
then: BasicBlockRef,
|
||||||
Catch: BasicBlockRef,
|
catch: BasicBlockRef,
|
||||||
attributes: &[(uint, lib::llvm::Attribute)])
|
attributes: &[(uint, lib::llvm::Attribute)])
|
||||||
-> ValueRef {
|
-> ValueRef {
|
||||||
if cx.unreachable.get() {
|
if cx.unreachable.get() {
|
||||||
@ -120,9 +120,9 @@ pub fn Invoke(cx: &Block,
|
|||||||
check_not_terminated(cx);
|
check_not_terminated(cx);
|
||||||
terminate(cx, "Invoke");
|
terminate(cx, "Invoke");
|
||||||
debug!("Invoke({} with arguments ({}))",
|
debug!("Invoke({} with arguments ({}))",
|
||||||
cx.val_to_str(Fn),
|
cx.val_to_str(fn_),
|
||||||
Args.map(|a| cx.val_to_str(*a)).connect(", "));
|
args.map(|a| cx.val_to_str(*a)).connect(", "));
|
||||||
B(cx).invoke(Fn, Args, Then, Catch, attributes)
|
B(cx).invoke(fn_, args, then, catch, attributes)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Unreachable(cx: &Block) {
|
pub fn Unreachable(cx: &Block) {
|
||||||
@ -142,208 +142,208 @@ pub fn _Undef(val: ValueRef) -> ValueRef {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Arithmetic */
|
/* Arithmetic */
|
||||||
pub fn Add(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
pub fn Add(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(LHS); }
|
if cx.unreachable.get() { return _Undef(lhs); }
|
||||||
B(cx).add(LHS, RHS)
|
B(cx).add(lhs, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn NSWAdd(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
pub fn NSWAdd(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(LHS); }
|
if cx.unreachable.get() { return _Undef(lhs); }
|
||||||
B(cx).nswadd(LHS, RHS)
|
B(cx).nswadd(lhs, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn NUWAdd(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
pub fn NUWAdd(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(LHS); }
|
if cx.unreachable.get() { return _Undef(lhs); }
|
||||||
B(cx).nuwadd(LHS, RHS)
|
B(cx).nuwadd(lhs, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn FAdd(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
pub fn FAdd(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(LHS); }
|
if cx.unreachable.get() { return _Undef(lhs); }
|
||||||
B(cx).fadd(LHS, RHS)
|
B(cx).fadd(lhs, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Sub(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
pub fn Sub(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(LHS); }
|
if cx.unreachable.get() { return _Undef(lhs); }
|
||||||
B(cx).sub(LHS, RHS)
|
B(cx).sub(lhs, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn NSWSub(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
pub fn NSWSub(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(LHS); }
|
if cx.unreachable.get() { return _Undef(lhs); }
|
||||||
B(cx).nswsub(LHS, RHS)
|
B(cx).nswsub(lhs, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn NUWSub(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
pub fn NUWSub(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(LHS); }
|
if cx.unreachable.get() { return _Undef(lhs); }
|
||||||
B(cx).nuwsub(LHS, RHS)
|
B(cx).nuwsub(lhs, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn FSub(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
pub fn FSub(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(LHS); }
|
if cx.unreachable.get() { return _Undef(lhs); }
|
||||||
B(cx).fsub(LHS, RHS)
|
B(cx).fsub(lhs, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Mul(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
pub fn Mul(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(LHS); }
|
if cx.unreachable.get() { return _Undef(lhs); }
|
||||||
B(cx).mul(LHS, RHS)
|
B(cx).mul(lhs, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn NSWMul(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
pub fn NSWMul(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(LHS); }
|
if cx.unreachable.get() { return _Undef(lhs); }
|
||||||
B(cx).nswmul(LHS, RHS)
|
B(cx).nswmul(lhs, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn NUWMul(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
pub fn NUWMul(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(LHS); }
|
if cx.unreachable.get() { return _Undef(lhs); }
|
||||||
B(cx).nuwmul(LHS, RHS)
|
B(cx).nuwmul(lhs, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn FMul(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
pub fn FMul(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(LHS); }
|
if cx.unreachable.get() { return _Undef(lhs); }
|
||||||
B(cx).fmul(LHS, RHS)
|
B(cx).fmul(lhs, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn UDiv(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
pub fn UDiv(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(LHS); }
|
if cx.unreachable.get() { return _Undef(lhs); }
|
||||||
B(cx).udiv(LHS, RHS)
|
B(cx).udiv(lhs, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn SDiv(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
pub fn SDiv(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(LHS); }
|
if cx.unreachable.get() { return _Undef(lhs); }
|
||||||
B(cx).sdiv(LHS, RHS)
|
B(cx).sdiv(lhs, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ExactSDiv(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
pub fn ExactSDiv(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(LHS); }
|
if cx.unreachable.get() { return _Undef(lhs); }
|
||||||
B(cx).exactsdiv(LHS, RHS)
|
B(cx).exactsdiv(lhs, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn FDiv(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
pub fn FDiv(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(LHS); }
|
if cx.unreachable.get() { return _Undef(lhs); }
|
||||||
B(cx).fdiv(LHS, RHS)
|
B(cx).fdiv(lhs, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn URem(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
pub fn URem(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(LHS); }
|
if cx.unreachable.get() { return _Undef(lhs); }
|
||||||
B(cx).urem(LHS, RHS)
|
B(cx).urem(lhs, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn SRem(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
pub fn SRem(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(LHS); }
|
if cx.unreachable.get() { return _Undef(lhs); }
|
||||||
B(cx).srem(LHS, RHS)
|
B(cx).srem(lhs, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn FRem(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
pub fn FRem(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(LHS); }
|
if cx.unreachable.get() { return _Undef(lhs); }
|
||||||
B(cx).frem(LHS, RHS)
|
B(cx).frem(lhs, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Shl(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
pub fn Shl(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(LHS); }
|
if cx.unreachable.get() { return _Undef(lhs); }
|
||||||
B(cx).shl(LHS, RHS)
|
B(cx).shl(lhs, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn LShr(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
pub fn LShr(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(LHS); }
|
if cx.unreachable.get() { return _Undef(lhs); }
|
||||||
B(cx).lshr(LHS, RHS)
|
B(cx).lshr(lhs, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn AShr(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
pub fn AShr(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(LHS); }
|
if cx.unreachable.get() { return _Undef(lhs); }
|
||||||
B(cx).ashr(LHS, RHS)
|
B(cx).ashr(lhs, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn And(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
pub fn And(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(LHS); }
|
if cx.unreachable.get() { return _Undef(lhs); }
|
||||||
B(cx).and(LHS, RHS)
|
B(cx).and(lhs, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Or(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
pub fn Or(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(LHS); }
|
if cx.unreachable.get() { return _Undef(lhs); }
|
||||||
B(cx).or(LHS, RHS)
|
B(cx).or(lhs, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Xor(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
pub fn Xor(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(LHS); }
|
if cx.unreachable.get() { return _Undef(lhs); }
|
||||||
B(cx).xor(LHS, RHS)
|
B(cx).xor(lhs, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn BinOp(cx: &Block, Op: Opcode, LHS: ValueRef, RHS: ValueRef)
|
pub fn BinOp(cx: &Block, op: Opcode, lhs: ValueRef, rhs: ValueRef)
|
||||||
-> ValueRef {
|
-> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(LHS); }
|
if cx.unreachable.get() { return _Undef(lhs); }
|
||||||
B(cx).binop(Op, LHS, RHS)
|
B(cx).binop(op, lhs, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Neg(cx: &Block, V: ValueRef) -> ValueRef {
|
pub fn Neg(cx: &Block, v: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(V); }
|
if cx.unreachable.get() { return _Undef(v); }
|
||||||
B(cx).neg(V)
|
B(cx).neg(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn NSWNeg(cx: &Block, V: ValueRef) -> ValueRef {
|
pub fn NSWNeg(cx: &Block, v: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(V); }
|
if cx.unreachable.get() { return _Undef(v); }
|
||||||
B(cx).nswneg(V)
|
B(cx).nswneg(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn NUWNeg(cx: &Block, V: ValueRef) -> ValueRef {
|
pub fn NUWNeg(cx: &Block, v: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(V); }
|
if cx.unreachable.get() { return _Undef(v); }
|
||||||
B(cx).nuwneg(V)
|
B(cx).nuwneg(v)
|
||||||
}
|
}
|
||||||
pub fn FNeg(cx: &Block, V: ValueRef) -> ValueRef {
|
pub fn FNeg(cx: &Block, v: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(V); }
|
if cx.unreachable.get() { return _Undef(v); }
|
||||||
B(cx).fneg(V)
|
B(cx).fneg(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Not(cx: &Block, V: ValueRef) -> ValueRef {
|
pub fn Not(cx: &Block, v: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(V); }
|
if cx.unreachable.get() { return _Undef(v); }
|
||||||
B(cx).not(V)
|
B(cx).not(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Memory */
|
/* Memory */
|
||||||
pub fn Malloc(cx: &Block, Ty: Type) -> ValueRef {
|
pub fn Malloc(cx: &Block, ty: Type) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i8p().to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i8p().to_ref()); }
|
||||||
B(cx).malloc(Ty)
|
B(cx).malloc(ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ArrayMalloc(cx: &Block, Ty: Type, Val: ValueRef) -> ValueRef {
|
pub fn ArrayMalloc(cx: &Block, ty: Type, val: ValueRef) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i8p().to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i8p().to_ref()); }
|
||||||
B(cx).array_malloc(Ty, Val)
|
B(cx).array_malloc(ty, val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Alloca(cx: &Block, Ty: Type, name: &str) -> ValueRef {
|
pub fn Alloca(cx: &Block, ty: Type, name: &str) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(Ty.ptr_to().to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(ty.ptr_to().to_ref()); }
|
||||||
AllocaFcx(cx.fcx, Ty, name)
|
AllocaFcx(cx.fcx, ty, name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn AllocaFcx(fcx: &FunctionContext, Ty: Type, name: &str) -> ValueRef {
|
pub fn AllocaFcx(fcx: &FunctionContext, ty: Type, name: &str) -> ValueRef {
|
||||||
let b = fcx.ccx.builder();
|
let b = fcx.ccx.builder();
|
||||||
b.position_before(fcx.alloca_insert_pt.get().unwrap());
|
b.position_before(fcx.alloca_insert_pt.get().unwrap());
|
||||||
b.alloca(Ty, name)
|
b.alloca(ty, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ArrayAlloca(cx: &Block, Ty: Type, Val: ValueRef) -> ValueRef {
|
pub fn ArrayAlloca(cx: &Block, ty: Type, val: ValueRef) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(Ty.ptr_to().to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(ty.ptr_to().to_ref()); }
|
||||||
let b = cx.fcx.ccx.builder();
|
let b = cx.fcx.ccx.builder();
|
||||||
b.position_before(cx.fcx.alloca_insert_pt.get().unwrap());
|
b.position_before(cx.fcx.alloca_insert_pt.get().unwrap());
|
||||||
b.array_alloca(Ty, Val)
|
b.array_alloca(ty, val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Free(cx: &Block, PointerVal: ValueRef) {
|
pub fn Free(cx: &Block, pointer_val: ValueRef) {
|
||||||
if cx.unreachable.get() { return; }
|
if cx.unreachable.get() { return; }
|
||||||
B(cx).free(PointerVal)
|
B(cx).free(pointer_val)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Load(cx: &Block, PointerVal: ValueRef) -> ValueRef {
|
pub fn Load(cx: &Block, pointer_val: ValueRef) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
let ccx = cx.fcx.ccx;
|
let ccx = cx.fcx.ccx;
|
||||||
if cx.unreachable.get() {
|
if cx.unreachable.get() {
|
||||||
let ty = val_ty(PointerVal);
|
let ty = val_ty(pointer_val);
|
||||||
let eltty = if ty.kind() == lib::llvm::Array {
|
let eltty = if ty.kind() == lib::llvm::Array {
|
||||||
ty.element_type()
|
ty.element_type()
|
||||||
} else {
|
} else {
|
||||||
@ -351,33 +351,33 @@ pub fn Load(cx: &Block, PointerVal: ValueRef) -> ValueRef {
|
|||||||
};
|
};
|
||||||
return llvm::LLVMGetUndef(eltty.to_ref());
|
return llvm::LLVMGetUndef(eltty.to_ref());
|
||||||
}
|
}
|
||||||
B(cx).load(PointerVal)
|
B(cx).load(pointer_val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn VolatileLoad(cx: &Block, PointerVal: ValueRef) -> ValueRef {
|
pub fn VolatileLoad(cx: &Block, pointer_val: ValueRef) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
|
||||||
B(cx).volatile_load(PointerVal)
|
B(cx).volatile_load(pointer_val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn AtomicLoad(cx: &Block, PointerVal: ValueRef, order: AtomicOrdering) -> ValueRef {
|
pub fn AtomicLoad(cx: &Block, pointer_val: ValueRef, order: AtomicOrdering) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
let ccx = cx.fcx.ccx;
|
let ccx = cx.fcx.ccx;
|
||||||
if cx.unreachable.get() {
|
if cx.unreachable.get() {
|
||||||
return llvm::LLVMGetUndef(ccx.int_type.to_ref());
|
return llvm::LLVMGetUndef(ccx.int_type.to_ref());
|
||||||
}
|
}
|
||||||
B(cx).atomic_load(PointerVal, order)
|
B(cx).atomic_load(pointer_val, order)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn LoadRangeAssert(cx: &Block, PointerVal: ValueRef, lo: c_ulonglong,
|
pub fn LoadRangeAssert(cx: &Block, pointer_val: ValueRef, lo: c_ulonglong,
|
||||||
hi: c_ulonglong, signed: lib::llvm::Bool) -> ValueRef {
|
hi: c_ulonglong, signed: lib::llvm::Bool) -> ValueRef {
|
||||||
if cx.unreachable.get() {
|
if cx.unreachable.get() {
|
||||||
let ccx = cx.fcx.ccx;
|
let ccx = cx.fcx.ccx;
|
||||||
let ty = val_ty(PointerVal);
|
let ty = val_ty(pointer_val);
|
||||||
let eltty = if ty.kind() == lib::llvm::Array {
|
let eltty = if ty.kind() == lib::llvm::Array {
|
||||||
ty.element_type()
|
ty.element_type()
|
||||||
} else {
|
} else {
|
||||||
@ -387,29 +387,29 @@ pub fn LoadRangeAssert(cx: &Block, PointerVal: ValueRef, lo: c_ulonglong,
|
|||||||
llvm::LLVMGetUndef(eltty.to_ref())
|
llvm::LLVMGetUndef(eltty.to_ref())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
B(cx).load_range_assert(PointerVal, lo, hi, signed)
|
B(cx).load_range_assert(pointer_val, lo, hi, signed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Store(cx: &Block, Val: ValueRef, Ptr: ValueRef) {
|
pub fn Store(cx: &Block, val: ValueRef, ptr: ValueRef) {
|
||||||
if cx.unreachable.get() { return; }
|
if cx.unreachable.get() { return; }
|
||||||
B(cx).store(Val, Ptr)
|
B(cx).store(val, ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn VolatileStore(cx: &Block, Val: ValueRef, Ptr: ValueRef) {
|
pub fn VolatileStore(cx: &Block, val: ValueRef, ptr: ValueRef) {
|
||||||
if cx.unreachable.get() { return; }
|
if cx.unreachable.get() { return; }
|
||||||
B(cx).volatile_store(Val, Ptr)
|
B(cx).volatile_store(val, ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn AtomicStore(cx: &Block, Val: ValueRef, Ptr: ValueRef, order: AtomicOrdering) {
|
pub fn AtomicStore(cx: &Block, val: ValueRef, ptr: ValueRef, order: AtomicOrdering) {
|
||||||
if cx.unreachable.get() { return; }
|
if cx.unreachable.get() { return; }
|
||||||
B(cx).atomic_store(Val, Ptr, order)
|
B(cx).atomic_store(val, ptr, order)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn GEP(cx: &Block, Pointer: ValueRef, Indices: &[ValueRef]) -> ValueRef {
|
pub fn GEP(cx: &Block, pointer: ValueRef, indices: &[ValueRef]) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().ptr_to().to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().ptr_to().to_ref()); }
|
||||||
B(cx).gep(Pointer, Indices)
|
B(cx).gep(pointer, indices)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,199 +423,199 @@ pub fn GEPi(cx: &Block, base: ValueRef, ixs: &[uint]) -> ValueRef {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn InBoundsGEP(cx: &Block, Pointer: ValueRef, Indices: &[ValueRef]) -> ValueRef {
|
pub fn InBoundsGEP(cx: &Block, pointer: ValueRef, indices: &[ValueRef]) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().ptr_to().to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().ptr_to().to_ref()); }
|
||||||
B(cx).inbounds_gep(Pointer, Indices)
|
B(cx).inbounds_gep(pointer, indices)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn StructGEP(cx: &Block, Pointer: ValueRef, Idx: uint) -> ValueRef {
|
pub fn StructGEP(cx: &Block, pointer: ValueRef, idx: uint) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().ptr_to().to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().ptr_to().to_ref()); }
|
||||||
B(cx).struct_gep(Pointer, Idx)
|
B(cx).struct_gep(pointer, idx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn GlobalString(cx: &Block, _Str: *c_char) -> ValueRef {
|
pub fn GlobalString(cx: &Block, _str: *c_char) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i8p().to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i8p().to_ref()); }
|
||||||
B(cx).global_string(_Str)
|
B(cx).global_string(_str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn GlobalStringPtr(cx: &Block, _Str: *c_char) -> ValueRef {
|
pub fn GlobalStringPtr(cx: &Block, _str: *c_char) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i8p().to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i8p().to_ref()); }
|
||||||
B(cx).global_string_ptr(_Str)
|
B(cx).global_string_ptr(_str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Casts */
|
/* Casts */
|
||||||
pub fn Trunc(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
|
pub fn Trunc(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); }
|
||||||
B(cx).trunc(Val, DestTy)
|
B(cx).trunc(val, dest_ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ZExt(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
|
pub fn ZExt(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); }
|
||||||
B(cx).zext(Val, DestTy)
|
B(cx).zext(val, dest_ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn SExt(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
|
pub fn SExt(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); }
|
||||||
B(cx).sext(Val, DestTy)
|
B(cx).sext(val, dest_ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn FPToUI(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
|
pub fn FPToUI(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); }
|
||||||
B(cx).fptoui(Val, DestTy)
|
B(cx).fptoui(val, dest_ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn FPToSI(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
|
pub fn FPToSI(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); }
|
||||||
B(cx).fptosi(Val, DestTy)
|
B(cx).fptosi(val, dest_ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn UIToFP(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
|
pub fn UIToFP(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); }
|
||||||
B(cx).uitofp(Val, DestTy)
|
B(cx).uitofp(val, dest_ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn SIToFP(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
|
pub fn SIToFP(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); }
|
||||||
B(cx).sitofp(Val, DestTy)
|
B(cx).sitofp(val, dest_ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn FPTrunc(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
|
pub fn FPTrunc(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); }
|
||||||
B(cx).fptrunc(Val, DestTy)
|
B(cx).fptrunc(val, dest_ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn FPExt(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
|
pub fn FPExt(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); }
|
||||||
B(cx).fpext(Val, DestTy)
|
B(cx).fpext(val, dest_ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn PtrToInt(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
|
pub fn PtrToInt(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); }
|
||||||
B(cx).ptrtoint(Val, DestTy)
|
B(cx).ptrtoint(val, dest_ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn IntToPtr(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
|
pub fn IntToPtr(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); }
|
||||||
B(cx).inttoptr(Val, DestTy)
|
B(cx).inttoptr(val, dest_ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn BitCast(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
|
pub fn BitCast(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); }
|
||||||
B(cx).bitcast(Val, DestTy)
|
B(cx).bitcast(val, dest_ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ZExtOrBitCast(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
|
pub fn ZExtOrBitCast(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); }
|
||||||
B(cx).zext_or_bitcast(Val, DestTy)
|
B(cx).zext_or_bitcast(val, dest_ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn SExtOrBitCast(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
|
pub fn SExtOrBitCast(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); }
|
||||||
B(cx).sext_or_bitcast(Val, DestTy)
|
B(cx).sext_or_bitcast(val, dest_ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn TruncOrBitCast(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
|
pub fn TruncOrBitCast(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); }
|
||||||
B(cx).trunc_or_bitcast(Val, DestTy)
|
B(cx).trunc_or_bitcast(val, dest_ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Cast(cx: &Block, Op: Opcode, Val: ValueRef, DestTy: Type, _: *u8)
|
pub fn Cast(cx: &Block, op: Opcode, val: ValueRef, dest_ty: Type, _: *u8)
|
||||||
-> ValueRef {
|
-> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); }
|
||||||
B(cx).cast(Op, Val, DestTy)
|
B(cx).cast(op, val, dest_ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn PointerCast(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
|
pub fn PointerCast(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); }
|
||||||
B(cx).pointercast(Val, DestTy)
|
B(cx).pointercast(val, dest_ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn IntCast(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
|
pub fn IntCast(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); }
|
||||||
B(cx).intcast(Val, DestTy)
|
B(cx).intcast(val, dest_ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn FPCast(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
|
pub fn FPCast(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); }
|
||||||
B(cx).fpcast(Val, DestTy)
|
B(cx).fpcast(val, dest_ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Comparisons */
|
/* Comparisons */
|
||||||
pub fn ICmp(cx: &Block, Op: IntPredicate, LHS: ValueRef, RHS: ValueRef)
|
pub fn ICmp(cx: &Block, op: IntPredicate, lhs: ValueRef, rhs: ValueRef)
|
||||||
-> ValueRef {
|
-> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i1().to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i1().to_ref()); }
|
||||||
B(cx).icmp(Op, LHS, RHS)
|
B(cx).icmp(op, lhs, rhs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn FCmp(cx: &Block, Op: RealPredicate, LHS: ValueRef, RHS: ValueRef)
|
pub fn FCmp(cx: &Block, op: RealPredicate, lhs: ValueRef, rhs: ValueRef)
|
||||||
-> ValueRef {
|
-> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i1().to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i1().to_ref()); }
|
||||||
B(cx).fcmp(Op, LHS, RHS)
|
B(cx).fcmp(op, lhs, rhs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Miscellaneous instructions */
|
/* Miscellaneous instructions */
|
||||||
pub fn EmptyPhi(cx: &Block, Ty: Type) -> ValueRef {
|
pub fn EmptyPhi(cx: &Block, ty: Type) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(Ty.to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(ty.to_ref()); }
|
||||||
B(cx).empty_phi(Ty)
|
B(cx).empty_phi(ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Phi(cx: &Block, Ty: Type, vals: &[ValueRef], bbs: &[BasicBlockRef]) -> ValueRef {
|
pub fn Phi(cx: &Block, ty: Type, vals: &[ValueRef], bbs: &[BasicBlockRef]) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(Ty.to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(ty.to_ref()); }
|
||||||
B(cx).phi(Ty, vals, bbs)
|
B(cx).phi(ty, vals, bbs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -626,10 +626,10 @@ pub fn AddIncomingToPhi(phi: ValueRef, val: ValueRef, bb: BasicBlockRef) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn _UndefReturn(cx: &Block, Fn: ValueRef) -> ValueRef {
|
pub fn _UndefReturn(cx: &Block, fn_: ValueRef) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
let ccx = cx.fcx.ccx;
|
let ccx = cx.fcx.ccx;
|
||||||
let ty = val_ty(Fn);
|
let ty = val_ty(fn_);
|
||||||
let retty = if ty.kind() == lib::llvm::Integer {
|
let retty = if ty.kind() == lib::llvm::Integer {
|
||||||
ty.return_type()
|
ty.return_type()
|
||||||
} else {
|
} else {
|
||||||
@ -655,16 +655,16 @@ pub fn InlineAsmCall(cx: &Block, asm: *c_char, cons: *c_char,
|
|||||||
B(cx).inline_asm_call(asm, cons, inputs, output, volatile, alignstack, dia)
|
B(cx).inline_asm_call(asm, cons, inputs, output, volatile, alignstack, dia)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Call(cx: &Block, Fn: ValueRef, Args: &[ValueRef],
|
pub fn Call(cx: &Block, fn_: ValueRef, args: &[ValueRef],
|
||||||
attributes: &[(uint, lib::llvm::Attribute)]) -> ValueRef {
|
attributes: &[(uint, lib::llvm::Attribute)]) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _UndefReturn(cx, Fn); }
|
if cx.unreachable.get() { return _UndefReturn(cx, fn_); }
|
||||||
B(cx).call(Fn, Args, attributes)
|
B(cx).call(fn_, args, attributes)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn CallWithConv(cx: &Block, Fn: ValueRef, Args: &[ValueRef], Conv: CallConv,
|
pub fn CallWithConv(cx: &Block, fn_: ValueRef, args: &[ValueRef], conv: CallConv,
|
||||||
attributes: &[(uint, lib::llvm::Attribute)]) -> ValueRef {
|
attributes: &[(uint, lib::llvm::Attribute)]) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _UndefReturn(cx, Fn); }
|
if cx.unreachable.get() { return _UndefReturn(cx, fn_); }
|
||||||
B(cx).call_with_conv(Fn, Args, Conv, attributes)
|
B(cx).call_with_conv(fn_, args, conv, attributes)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn AtomicFence(cx: &Block, order: AtomicOrdering) {
|
pub fn AtomicFence(cx: &Block, order: AtomicOrdering) {
|
||||||
@ -672,81 +672,81 @@ pub fn AtomicFence(cx: &Block, order: AtomicOrdering) {
|
|||||||
B(cx).atomic_fence(order)
|
B(cx).atomic_fence(order)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Select(cx: &Block, If: ValueRef, Then: ValueRef, Else: ValueRef) -> ValueRef {
|
pub fn Select(cx: &Block, if_: ValueRef, then: ValueRef, else_: ValueRef) -> ValueRef {
|
||||||
if cx.unreachable.get() { return _Undef(Then); }
|
if cx.unreachable.get() { return _Undef(then); }
|
||||||
B(cx).select(If, Then, Else)
|
B(cx).select(if_, then, else_)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn VAArg(cx: &Block, list: ValueRef, Ty: Type) -> ValueRef {
|
pub fn VAArg(cx: &Block, list: ValueRef, ty: Type) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(Ty.to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(ty.to_ref()); }
|
||||||
B(cx).va_arg(list, Ty)
|
B(cx).va_arg(list, ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ExtractElement(cx: &Block, VecVal: ValueRef, Index: ValueRef) -> ValueRef {
|
pub fn ExtractElement(cx: &Block, vec_val: ValueRef, index: ValueRef) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
|
||||||
B(cx).extract_element(VecVal, Index)
|
B(cx).extract_element(vec_val, index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn InsertElement(cx: &Block, VecVal: ValueRef, EltVal: ValueRef,
|
pub fn InsertElement(cx: &Block, vec_val: ValueRef, elt_val: ValueRef,
|
||||||
Index: ValueRef) -> ValueRef {
|
index: ValueRef) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
|
||||||
B(cx).insert_element(VecVal, EltVal, Index)
|
B(cx).insert_element(vec_val, elt_val, index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ShuffleVector(cx: &Block, V1: ValueRef, V2: ValueRef,
|
pub fn ShuffleVector(cx: &Block, v1: ValueRef, v2: ValueRef,
|
||||||
Mask: ValueRef) -> ValueRef {
|
mask: ValueRef) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
|
||||||
B(cx).shuffle_vector(V1, V2, Mask)
|
B(cx).shuffle_vector(v1, v2, mask)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn VectorSplat(cx: &Block, NumElts: uint, EltVal: ValueRef) -> ValueRef {
|
pub fn VectorSplat(cx: &Block, num_elts: uint, elt_val: ValueRef) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
|
||||||
B(cx).vector_splat(NumElts, EltVal)
|
B(cx).vector_splat(num_elts, elt_val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ExtractValue(cx: &Block, AggVal: ValueRef, Index: uint) -> ValueRef {
|
pub fn ExtractValue(cx: &Block, agg_val: ValueRef, index: uint) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
|
||||||
B(cx).extract_value(AggVal, Index)
|
B(cx).extract_value(agg_val, index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn InsertValue(cx: &Block, AggVal: ValueRef, EltVal: ValueRef, Index: uint) -> ValueRef {
|
pub fn InsertValue(cx: &Block, agg_val: ValueRef, elt_val: ValueRef, index: uint) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
|
||||||
B(cx).insert_value(AggVal, EltVal, Index)
|
B(cx).insert_value(agg_val, elt_val, index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn IsNull(cx: &Block, Val: ValueRef) -> ValueRef {
|
pub fn IsNull(cx: &Block, val: ValueRef) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i1().to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i1().to_ref()); }
|
||||||
B(cx).is_null(Val)
|
B(cx).is_null(val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn IsNotNull(cx: &Block, Val: ValueRef) -> ValueRef {
|
pub fn IsNotNull(cx: &Block, val: ValueRef) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i1().to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i1().to_ref()); }
|
||||||
B(cx).is_not_null(Val)
|
B(cx).is_not_null(val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn PtrDiff(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
pub fn PtrDiff(cx: &Block, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
let ccx = cx.fcx.ccx;
|
let ccx = cx.fcx.ccx;
|
||||||
if cx.unreachable.get() { return llvm::LLVMGetUndef(ccx.int_type.to_ref()); }
|
if cx.unreachable.get() { return llvm::LLVMGetUndef(ccx.int_type.to_ref()); }
|
||||||
B(cx).ptrdiff(LHS, RHS)
|
B(cx).ptrdiff(lhs, rhs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -755,21 +755,21 @@ pub fn Trap(cx: &Block) {
|
|||||||
B(cx).trap();
|
B(cx).trap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn LandingPad(cx: &Block, Ty: Type, PersFn: ValueRef,
|
pub fn LandingPad(cx: &Block, ty: Type, pers_fn: ValueRef,
|
||||||
NumClauses: uint) -> ValueRef {
|
num_clauses: uint) -> ValueRef {
|
||||||
check_not_terminated(cx);
|
check_not_terminated(cx);
|
||||||
assert!(!cx.unreachable.get());
|
assert!(!cx.unreachable.get());
|
||||||
B(cx).landing_pad(Ty, PersFn, NumClauses)
|
B(cx).landing_pad(ty, pers_fn, num_clauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn SetCleanup(cx: &Block, LandingPad: ValueRef) {
|
pub fn SetCleanup(cx: &Block, landing_pad: ValueRef) {
|
||||||
B(cx).set_cleanup(LandingPad)
|
B(cx).set_cleanup(landing_pad)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Resume(cx: &Block, Exn: ValueRef) -> ValueRef {
|
pub fn Resume(cx: &Block, exn: ValueRef) -> ValueRef {
|
||||||
check_not_terminated(cx);
|
check_not_terminated(cx);
|
||||||
terminate(cx, "Resume");
|
terminate(cx, "Resume");
|
||||||
B(cx).resume(Exn)
|
B(cx).resume(exn)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Atomic Operations
|
// Atomic Operations
|
||||||
|
@ -362,37 +362,37 @@ impl<'a> Builder<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn neg(&self, V: ValueRef) -> ValueRef {
|
pub fn neg(&self, v: ValueRef) -> ValueRef {
|
||||||
self.count_insn("neg");
|
self.count_insn("neg");
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildNeg(self.llbuilder, V, noname())
|
llvm::LLVMBuildNeg(self.llbuilder, v, noname())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn nswneg(&self, V: ValueRef) -> ValueRef {
|
pub fn nswneg(&self, v: ValueRef) -> ValueRef {
|
||||||
self.count_insn("nswneg");
|
self.count_insn("nswneg");
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildNSWNeg(self.llbuilder, V, noname())
|
llvm::LLVMBuildNSWNeg(self.llbuilder, v, noname())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn nuwneg(&self, V: ValueRef) -> ValueRef {
|
pub fn nuwneg(&self, v: ValueRef) -> ValueRef {
|
||||||
self.count_insn("nuwneg");
|
self.count_insn("nuwneg");
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildNUWNeg(self.llbuilder, V, noname())
|
llvm::LLVMBuildNUWNeg(self.llbuilder, v, noname())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn fneg(&self, V: ValueRef) -> ValueRef {
|
pub fn fneg(&self, v: ValueRef) -> ValueRef {
|
||||||
self.count_insn("fneg");
|
self.count_insn("fneg");
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildFNeg(self.llbuilder, V, noname())
|
llvm::LLVMBuildFNeg(self.llbuilder, v, noname())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn not(&self, V: ValueRef) -> ValueRef {
|
pub fn not(&self, v: ValueRef) -> ValueRef {
|
||||||
self.count_insn("not");
|
self.count_insn("not");
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildNot(self.llbuilder, V, noname())
|
llvm::LLVMBuildNot(self.llbuilder, v, noname())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -561,17 +561,17 @@ impl<'a> Builder<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn global_string(&self, _Str: *c_char) -> ValueRef {
|
pub fn global_string(&self, _str: *c_char) -> ValueRef {
|
||||||
self.count_insn("globalstring");
|
self.count_insn("globalstring");
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildGlobalString(self.llbuilder, _Str, noname())
|
llvm::LLVMBuildGlobalString(self.llbuilder, _str, noname())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn global_string_ptr(&self, _Str: *c_char) -> ValueRef {
|
pub fn global_string_ptr(&self, _str: *c_char) -> ValueRef {
|
||||||
self.count_insn("globalstringptr");
|
self.count_insn("globalstringptr");
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildGlobalStringPtr(self.llbuilder, _Str, noname())
|
llvm::LLVMBuildGlobalStringPtr(self.llbuilder, _str, noname())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -857,9 +857,9 @@ impl<'a> Builder<'a> {
|
|||||||
pub fn vector_splat(&self, num_elts: uint, elt: ValueRef) -> ValueRef {
|
pub fn vector_splat(&self, num_elts: uint, elt: ValueRef) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
let elt_ty = val_ty(elt);
|
let elt_ty = val_ty(elt);
|
||||||
let Undef = llvm::LLVMGetUndef(Type::vector(&elt_ty, num_elts as u64).to_ref());
|
let undef = llvm::LLVMGetUndef(Type::vector(&elt_ty, num_elts as u64).to_ref());
|
||||||
let vec = self.insert_element(Undef, elt, C_i32(0));
|
let vec = self.insert_element(undef, elt, C_i32(0));
|
||||||
self.shuffle_vector(vec, Undef, C_null(Type::vector(&Type::i32(), num_elts as u64)))
|
self.shuffle_vector(vec, undef, C_null(Type::vector(&Type::i32(), num_elts as u64)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -902,17 +902,17 @@ impl<'a> Builder<'a> {
|
|||||||
|
|
||||||
pub fn trap(&self) {
|
pub fn trap(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let BB: BasicBlockRef = llvm::LLVMGetInsertBlock(self.llbuilder);
|
let bb: BasicBlockRef = llvm::LLVMGetInsertBlock(self.llbuilder);
|
||||||
let FN: ValueRef = llvm::LLVMGetBasicBlockParent(BB);
|
let fn_: ValueRef = llvm::LLVMGetBasicBlockParent(bb);
|
||||||
let M: ModuleRef = llvm::LLVMGetGlobalParent(FN);
|
let m: ModuleRef = llvm::LLVMGetGlobalParent(fn_);
|
||||||
let T: ValueRef = "llvm.trap".with_c_str(|buf| {
|
let t: ValueRef = "llvm.trap".with_c_str(|buf| {
|
||||||
llvm::LLVMGetNamedFunction(M, buf)
|
llvm::LLVMGetNamedFunction(m, buf)
|
||||||
});
|
});
|
||||||
assert!((T as int != 0));
|
assert!((t as int != 0));
|
||||||
let args: &[ValueRef] = [];
|
let args: &[ValueRef] = [];
|
||||||
self.count_insn("trap");
|
self.count_insn("trap");
|
||||||
llvm::LLVMBuildCall(
|
llvm::LLVMBuildCall(
|
||||||
self.llbuilder, T, args.as_ptr(), args.len() as c_uint, noname());
|
self.llbuilder, t, args.as_ptr(), args.len() as c_uint, noname());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,9 +175,9 @@ impl Drop for BuilderRef_res {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn BuilderRef_res(B: BuilderRef) -> BuilderRef_res {
|
pub fn BuilderRef_res(b: BuilderRef) -> BuilderRef_res {
|
||||||
BuilderRef_res {
|
BuilderRef_res {
|
||||||
B: B
|
B: b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -654,9 +654,9 @@ pub fn C_struct(elts: &[ValueRef], packed: bool) -> ValueRef {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn C_named_struct(T: Type, elts: &[ValueRef]) -> ValueRef {
|
pub fn C_named_struct(t: Type, elts: &[ValueRef]) -> ValueRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMConstNamedStruct(T.to_ref(), elts.as_ptr(), elts.len() as c_uint)
|
llvm::LLVMConstNamedStruct(t.to_ref(), elts.as_ptr(), elts.len() as c_uint)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,8 +302,8 @@ fn const_expr_unadjusted(cx: @CrateContext, e: &ast::Expr,
|
|||||||
is_local: bool) -> (ValueRef, bool) {
|
is_local: bool) -> (ValueRef, bool) {
|
||||||
let map_list = |exprs: &[@ast::Expr]| {
|
let map_list = |exprs: &[@ast::Expr]| {
|
||||||
exprs.iter().map(|&e| const_expr(cx, e, is_local))
|
exprs.iter().map(|&e| const_expr(cx, e, is_local))
|
||||||
.fold((~[], true), |(L, all_inlineable), (val, inlineable)| {
|
.fold((~[], true), |(l, all_inlineable), (val, inlineable)| {
|
||||||
(vec::append_one(L, val), all_inlineable && inlineable)
|
(vec::append_one(l, val), all_inlineable && inlineable)
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -330,17 +330,17 @@ pub fn trans_fail<'a>(
|
|||||||
sp: Span,
|
sp: Span,
|
||||||
fail_str: InternedString)
|
fail_str: InternedString)
|
||||||
-> &'a Block<'a> {
|
-> &'a Block<'a> {
|
||||||
let V_fail_str = C_cstr(bcx.ccx(), fail_str);
|
let v_fail_str = C_cstr(bcx.ccx(), fail_str);
|
||||||
let _icx = push_ctxt("trans_fail_value");
|
let _icx = push_ctxt("trans_fail_value");
|
||||||
let ccx = bcx.ccx();
|
let ccx = bcx.ccx();
|
||||||
let sess = bcx.sess();
|
let sess = bcx.sess();
|
||||||
let loc = sess.parse_sess.cm.lookup_char_pos(sp.lo);
|
let loc = sess.parse_sess.cm.lookup_char_pos(sp.lo);
|
||||||
let V_filename = C_cstr(bcx.ccx(),
|
let v_filename = C_cstr(bcx.ccx(),
|
||||||
token::intern_and_get_ident(loc.file.name));
|
token::intern_and_get_ident(loc.file.name));
|
||||||
let V_line = loc.line as int;
|
let v_line = loc.line as int;
|
||||||
let V_str = PointerCast(bcx, V_fail_str, Type::i8p());
|
let v_str = PointerCast(bcx, v_fail_str, Type::i8p());
|
||||||
let V_filename = PointerCast(bcx, V_filename, Type::i8p());
|
let v_filename = PointerCast(bcx, v_filename, Type::i8p());
|
||||||
let args = ~[V_str, V_filename, C_int(ccx, V_line)];
|
let args = ~[v_str, v_filename, C_int(ccx, v_line)];
|
||||||
let did = langcall(bcx, Some(sp), "", FailFnLangItem);
|
let did = langcall(bcx, Some(sp), "", FailFnLangItem);
|
||||||
let bcx = callee::trans_lang_call(bcx, did, args, Some(expr::Ignore)).bcx;
|
let bcx = callee::trans_lang_call(bcx, did, args, Some(expr::Ignore)).bcx;
|
||||||
Unreachable(bcx);
|
Unreachable(bcx);
|
||||||
|
@ -338,12 +338,12 @@ impl Engine256State {
|
|||||||
let mut g = self.H6;
|
let mut g = self.H6;
|
||||||
let mut h = self.H7;
|
let mut h = self.H7;
|
||||||
|
|
||||||
let mut W = [0u32, ..64];
|
let mut w = [0u32, ..64];
|
||||||
|
|
||||||
// Sha-512 and Sha-256 use basically the same calculations which are implemented
|
// Sha-512 and Sha-256 use basically the same calculations which are implemented
|
||||||
// by these macros. Inlining the calculations seems to result in better generated code.
|
// by these macros. Inlining the calculations seems to result in better generated code.
|
||||||
macro_rules! schedule_round( ($t:expr) => (
|
macro_rules! schedule_round( ($t:expr) => (
|
||||||
W[$t] = sigma1(W[$t - 2]) + W[$t - 7] + sigma0(W[$t - 15]) + W[$t - 16];
|
w[$t] = sigma1(w[$t - 2]) + w[$t - 7] + sigma0(w[$t - 15]) + w[$t - 16];
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -351,14 +351,14 @@ impl Engine256State {
|
|||||||
($A:ident, $B:ident, $C:ident, $D:ident,
|
($A:ident, $B:ident, $C:ident, $D:ident,
|
||||||
$E:ident, $F:ident, $G:ident, $H:ident, $K:ident, $t:expr) => (
|
$E:ident, $F:ident, $G:ident, $H:ident, $K:ident, $t:expr) => (
|
||||||
{
|
{
|
||||||
$H += sum1($E) + ch($E, $F, $G) + $K[$t] + W[$t];
|
$H += sum1($E) + ch($E, $F, $G) + $K[$t] + w[$t];
|
||||||
$D += $H;
|
$D += $H;
|
||||||
$H += sum0($A) + maj($A, $B, $C);
|
$H += sum0($A) + maj($A, $B, $C);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
read_u32v_be(W.mut_slice(0, 16), data);
|
read_u32v_be(w.mut_slice(0, 16), data);
|
||||||
|
|
||||||
// Putting the message schedule inside the same loop as the round calculations allows for
|
// Putting the message schedule inside the same loop as the round calculations allows for
|
||||||
// the compiler to generate better code.
|
// the compiler to generate better code.
|
||||||
|
@ -199,9 +199,9 @@ impl<'a> FromBase64 for &'a str {
|
|||||||
* println!("base64 output: {}", hello_str);
|
* println!("base64 output: {}", hello_str);
|
||||||
* let res = hello_str.from_base64();
|
* let res = hello_str.from_base64();
|
||||||
* if res.is_ok() {
|
* if res.is_ok() {
|
||||||
* let optBytes = str::from_utf8_owned(res.unwrap());
|
* let opt_bytes = str::from_utf8_owned(res.unwrap());
|
||||||
* if optBytes.is_some() {
|
* if opt_bytes.is_some() {
|
||||||
* println!("decoded from base64: {}", optBytes.unwrap());
|
* println!("decoded from base64: {}", opt_bytes.unwrap());
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
@ -1672,15 +1672,15 @@ mod tests {
|
|||||||
]"
|
]"
|
||||||
);
|
);
|
||||||
|
|
||||||
let longTestList = List(~[
|
let long_test_list = List(~[
|
||||||
Boolean(false),
|
Boolean(false),
|
||||||
Null,
|
Null,
|
||||||
List(~[String(~"foo\nbar"), Number(3.5)])]);
|
List(~[String(~"foo\nbar"), Number(3.5)])]);
|
||||||
|
|
||||||
assert_eq!(longTestList.to_str(),
|
assert_eq!(long_test_list.to_str(),
|
||||||
~"[false,null,[\"foo\\nbar\",3.5]]");
|
~"[false,null,[\"foo\\nbar\",3.5]]");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
longTestList.to_pretty_str(),
|
long_test_list.to_pretty_str(),
|
||||||
~"\
|
~"\
|
||||||
[\n \
|
[\n \
|
||||||
false,\n \
|
false,\n \
|
||||||
@ -1710,7 +1710,7 @@ mod tests {
|
|||||||
}"
|
}"
|
||||||
);
|
);
|
||||||
|
|
||||||
let complexObj = mk_object([
|
let complex_obj = mk_object([
|
||||||
(~"b", List(~[
|
(~"b", List(~[
|
||||||
mk_object([(~"c", String(~"\x0c\r"))]),
|
mk_object([(~"c", String(~"\x0c\r"))]),
|
||||||
mk_object([(~"d", String(~""))])
|
mk_object([(~"d", String(~""))])
|
||||||
@ -1718,7 +1718,7 @@ mod tests {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
complexObj.to_str(),
|
complex_obj.to_str(),
|
||||||
~"{\
|
~"{\
|
||||||
\"b\":[\
|
\"b\":[\
|
||||||
{\"c\":\"\\f\\r\"},\
|
{\"c\":\"\\f\\r\"},\
|
||||||
@ -1727,7 +1727,7 @@ mod tests {
|
|||||||
}"
|
}"
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
complexObj.to_pretty_str(),
|
complex_obj.to_pretty_str(),
|
||||||
~"\
|
~"\
|
||||||
{\n \
|
{\n \
|
||||||
\"b\": [\n \
|
\"b\": [\n \
|
||||||
|
@ -181,7 +181,7 @@ macro_rules! impl_hash_tuple(
|
|||||||
);
|
);
|
||||||
)
|
)
|
||||||
|
|
||||||
impl_hash_tuple!(A0 A1 A2 A3 A4 A5 A6 A7)
|
impl_hash_tuple!(a0 a1 a2 a3 a4 a5 a6 a7)
|
||||||
|
|
||||||
impl<'a, S: Writer, T: Hash<S>> Hash<S> for &'a [T] {
|
impl<'a, S: Writer, T: Hash<S>> Hash<S> for &'a [T] {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -85,8 +85,8 @@ impl Reader for UdpStream {
|
|||||||
|
|
||||||
impl Writer for UdpStream {
|
impl Writer for UdpStream {
|
||||||
fn write(&mut self, buf: &[u8]) -> IoResult<()> {
|
fn write(&mut self, buf: &[u8]) -> IoResult<()> {
|
||||||
let connectedTo = self.connectedTo;
|
let connected_to = self.connectedTo;
|
||||||
self.as_socket(|sock| sock.sendto(buf, connectedTo))
|
self.as_socket(|sock| sock.sendto(buf, connected_to))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,8 +213,8 @@ mod ziggurat_tables;
|
|||||||
fn ziggurat<R:Rng>(
|
fn ziggurat<R:Rng>(
|
||||||
rng: &mut R,
|
rng: &mut R,
|
||||||
symmetric: bool,
|
symmetric: bool,
|
||||||
X: ziggurat_tables::ZigTable,
|
x_tab: ziggurat_tables::ZigTable,
|
||||||
F: ziggurat_tables::ZigTable,
|
f_tab: ziggurat_tables::ZigTable,
|
||||||
pdf: 'static |f64| -> f64,
|
pdf: 'static |f64| -> f64,
|
||||||
zero_case: 'static |&mut R, f64| -> f64)
|
zero_case: 'static |&mut R, f64| -> f64)
|
||||||
-> f64 {
|
-> f64 {
|
||||||
@ -233,19 +233,19 @@ fn ziggurat<R:Rng>(
|
|||||||
// u is either U(-1, 1) or U(0, 1) depending on if this is a
|
// u is either U(-1, 1) or U(0, 1) depending on if this is a
|
||||||
// symmetric distribution or not.
|
// symmetric distribution or not.
|
||||||
let u = if symmetric {2.0 * f - 1.0} else {f};
|
let u = if symmetric {2.0 * f - 1.0} else {f};
|
||||||
let x = u * X[i];
|
let x = u * x_tab[i];
|
||||||
|
|
||||||
let test_x = if symmetric {num::abs(x)} else {x};
|
let test_x = if symmetric {num::abs(x)} else {x};
|
||||||
|
|
||||||
// algebraically equivalent to |u| < X[i+1]/X[i] (or u < X[i+1]/X[i])
|
// algebraically equivalent to |u| < x_tab[i+1]/x_tab[i] (or u < x_tab[i+1]/x_tab[i])
|
||||||
if test_x < X[i + 1] {
|
if test_x < x_tab[i + 1] {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
return zero_case(rng, u);
|
return zero_case(rng, u);
|
||||||
}
|
}
|
||||||
// algebraically equivalent to f1 + DRanU()*(f0 - f1) < 1
|
// algebraically equivalent to f1 + DRanU()*(f0 - f1) < 1
|
||||||
if F[i + 1] + (F[i] - F[i + 1]) * rng.gen() < pdf(x) {
|
if f_tab[i + 1] + (f_tab[i] - f_tab[i + 1]) * rng.gen() < pdf(x) {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -803,11 +803,11 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_sample() {
|
fn test_sample() {
|
||||||
let MIN_VAL = 1;
|
let min_val = 1;
|
||||||
let MAX_VAL = 100;
|
let max_val = 100;
|
||||||
|
|
||||||
let mut r = rng();
|
let mut r = rng();
|
||||||
let vals = range(MIN_VAL, MAX_VAL).to_owned_vec();
|
let vals = range(min_val, max_val).to_owned_vec();
|
||||||
let small_sample = r.sample(vals.iter(), 5);
|
let small_sample = r.sample(vals.iter(), 5);
|
||||||
let large_sample = r.sample(vals.iter(), vals.len() + 5);
|
let large_sample = r.sample(vals.iter(), vals.len() + 5);
|
||||||
|
|
||||||
@ -815,7 +815,7 @@ mod test {
|
|||||||
assert_eq!(large_sample.len(), vals.len());
|
assert_eq!(large_sample.len(), vals.len());
|
||||||
|
|
||||||
assert!(small_sample.iter().all(|e| {
|
assert!(small_sample.iter().all(|e| {
|
||||||
**e >= MIN_VAL && **e <= MAX_VAL
|
**e >= min_val && **e <= max_val
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -575,9 +575,9 @@ fn canonical_sort(comb: &mut [(char, u8)]) {
|
|||||||
for i in range(0, len) {
|
for i in range(0, len) {
|
||||||
let mut swapped = false;
|
let mut swapped = false;
|
||||||
for j in range(1, len-i) {
|
for j in range(1, len-i) {
|
||||||
let classA = *comb[j-1].ref1();
|
let class_a = *comb[j-1].ref1();
|
||||||
let classB = *comb[j].ref1();
|
let class_b = *comb[j].ref1();
|
||||||
if classA != 0 && classB != 0 && classA > classB {
|
if class_a != 0 && class_b != 0 && class_a > class_b {
|
||||||
comb.swap(j-1, j);
|
comb.swap(j-1, j);
|
||||||
swapped = true;
|
swapped = true;
|
||||||
}
|
}
|
||||||
@ -3427,8 +3427,8 @@ mod tests {
|
|||||||
let repl = ~"دولة الكويت";
|
let repl = ~"دولة الكويت";
|
||||||
|
|
||||||
let a = ~"ประเ";
|
let a = ~"ประเ";
|
||||||
let A = ~"دولة الكويتทศไทย中华";
|
let a2 = ~"دولة الكويتทศไทย中华";
|
||||||
assert_eq!(data.replace(a, repl), A);
|
assert_eq!(data.replace(a, repl), a2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -3437,8 +3437,8 @@ mod tests {
|
|||||||
let repl = ~"دولة الكويت";
|
let repl = ~"دولة الكويت";
|
||||||
|
|
||||||
let b = ~"ะเ";
|
let b = ~"ะเ";
|
||||||
let B = ~"ปรدولة الكويتทศไทย中华";
|
let b2 = ~"ปรدولة الكويتทศไทย中华";
|
||||||
assert_eq!(data.replace(b, repl), B);
|
assert_eq!(data.replace(b, repl), b2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -3447,8 +3447,8 @@ mod tests {
|
|||||||
let repl = ~"دولة الكويت";
|
let repl = ~"دولة الكويت";
|
||||||
|
|
||||||
let c = ~"中华";
|
let c = ~"中华";
|
||||||
let C = ~"ประเทศไทยدولة الكويت";
|
let c2 = ~"ประเทศไทยدولة الكويت";
|
||||||
assert_eq!(data.replace(c, repl), C);
|
assert_eq!(data.replace(c, repl), c2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -217,7 +217,7 @@ impl<'a> Condvar<'a> {
|
|||||||
* wait() is equivalent to wait_on(0).
|
* wait() is equivalent to wait_on(0).
|
||||||
*/
|
*/
|
||||||
pub fn wait_on(&self, condvar_id: uint) {
|
pub fn wait_on(&self, condvar_id: uint) {
|
||||||
let mut WaitEnd = None;
|
let mut wait_end = None;
|
||||||
let mut out_of_bounds = None;
|
let mut out_of_bounds = None;
|
||||||
// Release lock, 'atomically' enqueuing ourselves in so doing.
|
// Release lock, 'atomically' enqueuing ourselves in so doing.
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -230,7 +230,7 @@ impl<'a> Condvar<'a> {
|
|||||||
}
|
}
|
||||||
// Create waiter nobe, and enqueue ourself to
|
// Create waiter nobe, and enqueue ourself to
|
||||||
// be woken up by a signaller.
|
// be woken up by a signaller.
|
||||||
WaitEnd = Some(state.blocked[condvar_id].wait_end());
|
wait_end = Some(state.blocked[condvar_id].wait_end());
|
||||||
} else {
|
} else {
|
||||||
out_of_bounds = Some(state.blocked.len());
|
out_of_bounds = Some(state.blocked.len());
|
||||||
}
|
}
|
||||||
@ -244,7 +244,7 @@ impl<'a> Condvar<'a> {
|
|||||||
// signaller already sent -- I mean 'unconditionally' in contrast
|
// signaller already sent -- I mean 'unconditionally' in contrast
|
||||||
// with acquire().)
|
// with acquire().)
|
||||||
(|| {
|
(|| {
|
||||||
let _ = WaitEnd.take_unwrap().recv();
|
let _ = wait_end.take_unwrap().recv();
|
||||||
}).finally(|| {
|
}).finally(|| {
|
||||||
// Reacquire the condvar.
|
// Reacquire the condvar.
|
||||||
match self.order {
|
match self.order {
|
||||||
|
@ -339,12 +339,12 @@ fn highlight_lines(err: &mut EmitterWriter,
|
|||||||
for _ in range(0, skip) { s.push_char(' '); }
|
for _ in range(0, skip) { s.push_char(' '); }
|
||||||
let orig = fm.get_line(*lines.lines.get(0) as int);
|
let orig = fm.get_line(*lines.lines.get(0) as int);
|
||||||
for pos in range(0u, left-skip) {
|
for pos in range(0u, left-skip) {
|
||||||
let curChar = orig[pos] as char;
|
let cur_char = orig[pos] as char;
|
||||||
// Whenever a tab occurs on the previous line, we insert one on
|
// Whenever a tab occurs on the previous line, we insert one on
|
||||||
// the error-point-squiggly-line as well (instead of a space).
|
// the error-point-squiggly-line as well (instead of a space).
|
||||||
// That way the squiggly line will usually appear in the correct
|
// That way the squiggly line will usually appear in the correct
|
||||||
// position.
|
// position.
|
||||||
match curChar {
|
match cur_char {
|
||||||
'\t' => s.push_char('\t'),
|
'\t' => s.push_char('\t'),
|
||||||
_ => s.push_char(' '),
|
_ => s.push_char(' '),
|
||||||
};
|
};
|
||||||
|
@ -124,10 +124,10 @@ pub fn buf_str(toks: Vec<Token> , szs: Vec<int> , left: uint, right: uint,
|
|||||||
let n = toks.len();
|
let n = toks.len();
|
||||||
assert_eq!(n, szs.len());
|
assert_eq!(n, szs.len());
|
||||||
let mut i = left;
|
let mut i = left;
|
||||||
let mut L = lim;
|
let mut l = lim;
|
||||||
let mut s = ~"[";
|
let mut s = ~"[";
|
||||||
while i != right && L != 0u {
|
while i != right && l != 0u {
|
||||||
L -= 1u;
|
l -= 1u;
|
||||||
if i != left {
|
if i != left {
|
||||||
s.push_str(", ");
|
s.push_str(", ");
|
||||||
}
|
}
|
||||||
@ -427,15 +427,15 @@ impl Printer {
|
|||||||
self.right %= self.buf_len;
|
self.right %= self.buf_len;
|
||||||
assert!((self.right != self.left));
|
assert!((self.right != self.left));
|
||||||
}
|
}
|
||||||
pub fn advance_left(&mut self, x: Token, L: int) -> io::IoResult<()> {
|
pub fn advance_left(&mut self, x: Token, l: int) -> io::IoResult<()> {
|
||||||
debug!("advnce_left ~[{},{}], sizeof({})={}", self.left, self.right,
|
debug!("advnce_left ~[{},{}], sizeof({})={}", self.left, self.right,
|
||||||
self.left, L);
|
self.left, l);
|
||||||
if L >= 0 {
|
if l >= 0 {
|
||||||
let ret = self.print(x.clone(), L);
|
let ret = self.print(x.clone(), l);
|
||||||
match x {
|
match x {
|
||||||
Break(b) => self.left_total += b.blank_space,
|
Break(b) => self.left_total += b.blank_space,
|
||||||
String(_, len) => {
|
String(_, len) => {
|
||||||
assert_eq!(len, L); self.left_total += len;
|
assert_eq!(len, l); self.left_total += len;
|
||||||
}
|
}
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
@ -510,8 +510,8 @@ impl Printer {
|
|||||||
}
|
}
|
||||||
write!(self.out, "{}", s)
|
write!(self.out, "{}", s)
|
||||||
}
|
}
|
||||||
pub fn print(&mut self, x: Token, L: int) -> io::IoResult<()> {
|
pub fn print(&mut self, x: Token, l: int) -> io::IoResult<()> {
|
||||||
debug!("print {} {} (remaining line space={})", tok_str(x.clone()), L,
|
debug!("print {} {} (remaining line space={})", tok_str(x.clone()), l,
|
||||||
self.space);
|
self.space);
|
||||||
debug!("{}", buf_str(self.token.clone(),
|
debug!("{}", buf_str(self.token.clone(),
|
||||||
self.size.clone(),
|
self.size.clone(),
|
||||||
@ -520,7 +520,7 @@ impl Printer {
|
|||||||
6));
|
6));
|
||||||
match x {
|
match x {
|
||||||
Begin(b) => {
|
Begin(b) => {
|
||||||
if L > self.space {
|
if l > self.space {
|
||||||
let col = self.margin - self.space + b.offset;
|
let col = self.margin - self.space + b.offset;
|
||||||
debug!("print Begin -> push broken block at col {}", col);
|
debug!("print Begin -> push broken block at col {}", col);
|
||||||
self.print_stack.push(PrintStackElem {
|
self.print_stack.push(PrintStackElem {
|
||||||
@ -560,7 +560,7 @@ impl Printer {
|
|||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
Broken(Inconsistent) => {
|
Broken(Inconsistent) => {
|
||||||
if L > self.space {
|
if l > self.space {
|
||||||
debug!("print Break({}+{}) w/ newline in inconsistent",
|
debug!("print Break({}+{}) w/ newline in inconsistent",
|
||||||
top.offset, b.offset);
|
top.offset, b.offset);
|
||||||
let ret = self.print_newline(top.offset + b.offset);
|
let ret = self.print_newline(top.offset + b.offset);
|
||||||
@ -578,8 +578,8 @@ impl Printer {
|
|||||||
}
|
}
|
||||||
String(s, len) => {
|
String(s, len) => {
|
||||||
debug!("print String({})", s);
|
debug!("print String({})", s);
|
||||||
assert_eq!(L, len);
|
assert_eq!(l, len);
|
||||||
// assert!(L <= space);
|
// assert!(l <= space);
|
||||||
self.space -= len;
|
self.space -= len;
|
||||||
self.print_str(s)
|
self.print_str(s)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user