提交 fc06114d 编写于 作者: B Brian Anderson

Merge remote-tracking branch 'brson/companion' into incoming

Conflicts:
	src/compiletest/compiletest.rs
	src/libcargo/cargo.rs
	src/libcore/core.rs
	src/librustc/rustc.rs
	src/librustdoc/rustdoc.rc
enum mode { mode_compile_fail, mode_run_fail, mode_run_pass, mode_pretty, }
#[cfg(stage0)]
impl mode : cmp::Eq {
pure fn eq(other: &mode) -> bool {
(*other) as int == self as int
}
pure fn ne(other: &mode) -> bool { !self.eq(other) }
}
#[cfg(stage1)]
#[cfg(stage2)]
impl mode : cmp::Eq {
pure fn eq(&self, other: &mode) -> bool {
(*other) as int == (*self) as int
......
......@@ -26,6 +26,198 @@ mod common;
#[legacy_exports]
mod errors;
use std::getopts;
use std::test;
use core::result;
use result::{Ok, Err};
use common::config;
use common::mode_run_pass;
use common::mode_run_fail;
use common::mode_compile_fail;
use common::mode_pretty;
use common::mode;
use util::logv;
fn main() {
let args = os::args();
let config = parse_config(args);
log_config(config);
run_tests(config);
}
fn parse_config(args: ~[~str]) -> config {
let opts =
~[getopts::reqopt(~"compile-lib-path"),
getopts::reqopt(~"run-lib-path"),
getopts::reqopt(~"rustc-path"), getopts::reqopt(~"src-base"),
getopts::reqopt(~"build-base"), getopts::reqopt(~"aux-base"),
getopts::reqopt(~"stage-id"),
getopts::reqopt(~"mode"), getopts::optflag(~"ignored"),
getopts::optopt(~"runtool"), getopts::optopt(~"rustcflags"),
getopts::optflag(~"verbose"),
getopts::optopt(~"logfile"),
getopts::optflag(~"jit")];
assert (vec::is_not_empty(args));
let args_ = vec::tail(args);
let matches =
&match getopts::getopts(args_, opts) {
Ok(m) => m,
Err(f) => fail getopts::fail_str(f)
};
fn opt_path(m: &getopts::Matches, nm: ~str) -> Path {
Path(getopts::opt_str(m, nm))
}
return {compile_lib_path: getopts::opt_str(matches, ~"compile-lib-path"),
run_lib_path: getopts::opt_str(matches, ~"run-lib-path"),
rustc_path: opt_path(matches, ~"rustc-path"),
src_base: opt_path(matches, ~"src-base"),
build_base: opt_path(matches, ~"build-base"),
aux_base: opt_path(matches, ~"aux-base"),
stage_id: getopts::opt_str(matches, ~"stage-id"),
mode: str_mode(getopts::opt_str(matches, ~"mode")),
run_ignored: getopts::opt_present(matches, ~"ignored"),
filter:
if vec::len(matches.free) > 0u {
option::Some(matches.free[0])
} else { option::None },
logfile: option::map(&getopts::opt_maybe_str(matches,
~"logfile"),
|s| Path(*s)),
runtool: getopts::opt_maybe_str(matches, ~"runtool"),
rustcflags: getopts::opt_maybe_str(matches, ~"rustcflags"),
jit: getopts::opt_present(matches, ~"jit"),
verbose: getopts::opt_present(matches, ~"verbose")};
}
fn log_config(config: config) {
let c = config;
logv(c, fmt!("configuration:"));
logv(c, fmt!("compile_lib_path: %s", config.compile_lib_path));
logv(c, fmt!("run_lib_path: %s", config.run_lib_path));
logv(c, fmt!("rustc_path: %s", config.rustc_path.to_str()));
logv(c, fmt!("src_base: %s", config.src_base.to_str()));
logv(c, fmt!("build_base: %s", config.build_base.to_str()));
logv(c, fmt!("stage_id: %s", config.stage_id));
logv(c, fmt!("mode: %s", mode_str(config.mode)));
logv(c, fmt!("run_ignored: %b", config.run_ignored));
logv(c, fmt!("filter: %s", opt_str(config.filter)));
logv(c, fmt!("runtool: %s", opt_str(config.runtool)));
logv(c, fmt!("rustcflags: %s", opt_str(config.rustcflags)));
logv(c, fmt!("jit: %b", config.jit));
logv(c, fmt!("verbose: %b", config.verbose));
logv(c, fmt!("\n"));
}
fn opt_str(maybestr: Option<~str>) -> ~str {
match maybestr { option::Some(s) => s, option::None => ~"(none)" }
}
fn str_opt(maybestr: ~str) -> Option<~str> {
if maybestr != ~"(none)" { option::Some(maybestr) } else { option::None }
}
fn str_mode(s: ~str) -> mode {
match s {
~"compile-fail" => mode_compile_fail,
~"run-fail" => mode_run_fail,
~"run-pass" => mode_run_pass,
~"pretty" => mode_pretty,
_ => fail ~"invalid mode"
}
}
fn mode_str(mode: mode) -> ~str {
match mode {
mode_compile_fail => ~"compile-fail",
mode_run_fail => ~"run-fail",
mode_run_pass => ~"run-pass",
mode_pretty => ~"pretty"
}
}
fn run_tests(config: config) {
let opts = test_opts(config);
let tests = make_tests(config);
let res = test::run_tests_console(&opts, tests);
if !res { fail ~"Some tests failed"; }
}
fn test_opts(config: config) -> test::TestOpts {
{filter:
match config.filter {
option::Some(s) => option::Some(s),
option::None => option::None
},
run_ignored: config.run_ignored,
logfile:
match config.logfile {
option::Some(s) => option::Some(s.to_str()),
option::None => option::None
}
}
}
fn make_tests(config: config) -> ~[test::TestDesc] {
debug!("making tests from %s",
config.src_base.to_str());
let mut tests = ~[];
for os::list_dir_path(&config.src_base).each |file| {
let file = copy *file;
debug!("inspecting file %s", file.to_str());
if is_test(config, file) {
tests.push(make_test(config, file))
}
}
move tests
}
fn is_test(config: config, testfile: &Path) -> bool {
// Pretty-printer does not work with .rc files yet
let valid_extensions =
match config.mode {
mode_pretty => ~[~".rs"],
_ => ~[~".rc", ~".rs"]
};
let invalid_prefixes = ~[~".", ~"#", ~"~"];
let name = testfile.filename().get();
let mut valid = false;
for valid_extensions.each |ext| {
if str::ends_with(name, *ext) { valid = true; }
}
for invalid_prefixes.each |pre| {
if str::starts_with(name, *pre) { valid = false; }
}
return valid;
}
fn make_test(config: config, testfile: &Path) ->
test::TestDesc {
{
name: make_test_name(config, testfile),
testfn: make_test_closure(config, testfile),
ignore: header::is_test_ignored(config, testfile),
should_fail: false
}
}
fn make_test_name(config: config, testfile: &Path) -> ~str {
fmt!("[%s] %s", mode_str(config.mode), testfile.to_str())
}
fn make_test_closure(config: config, testfile: &Path) -> test::TestFn {
let testfile = testfile.to_str();
fn~() { runtest::run(config, testfile) }
}
// Local Variables:
// fill-column: 78;
// indent-tabs-mode: nil
......
use std::getopts;
use std::test;
use core::result;
use result::{Ok, Err};
use common::config;
use common::mode_run_pass;
use common::mode_run_fail;
use common::mode_compile_fail;
use common::mode_pretty;
use common::mode;
use util::logv;
fn main() {
let args = os::args();
let config = parse_config(args);
log_config(config);
run_tests(config);
}
fn parse_config(args: ~[~str]) -> config {
let opts =
~[getopts::reqopt(~"compile-lib-path"),
getopts::reqopt(~"run-lib-path"),
getopts::reqopt(~"rustc-path"), getopts::reqopt(~"src-base"),
getopts::reqopt(~"build-base"), getopts::reqopt(~"aux-base"),
getopts::reqopt(~"stage-id"),
getopts::reqopt(~"mode"), getopts::optflag(~"ignored"),
getopts::optopt(~"runtool"), getopts::optopt(~"rustcflags"),
getopts::optflag(~"verbose"),
getopts::optopt(~"logfile"),
getopts::optflag(~"jit")];
assert (vec::is_not_empty(args));
let args_ = vec::tail(args);
let matches =
&match getopts::getopts(args_, opts) {
Ok(m) => m,
Err(f) => fail getopts::fail_str(f)
};
fn opt_path(m: &getopts::Matches, nm: ~str) -> Path {
Path(getopts::opt_str(m, nm))
}
return {compile_lib_path: getopts::opt_str(matches, ~"compile-lib-path"),
run_lib_path: getopts::opt_str(matches, ~"run-lib-path"),
rustc_path: opt_path(matches, ~"rustc-path"),
src_base: opt_path(matches, ~"src-base"),
build_base: opt_path(matches, ~"build-base"),
aux_base: opt_path(matches, ~"aux-base"),
stage_id: getopts::opt_str(matches, ~"stage-id"),
mode: str_mode(getopts::opt_str(matches, ~"mode")),
run_ignored: getopts::opt_present(matches, ~"ignored"),
filter:
if vec::len(matches.free) > 0u {
option::Some(matches.free[0])
} else { option::None },
logfile: option::map(&getopts::opt_maybe_str(matches,
~"logfile"),
|s| Path(*s)),
runtool: getopts::opt_maybe_str(matches, ~"runtool"),
rustcflags: getopts::opt_maybe_str(matches, ~"rustcflags"),
jit: getopts::opt_present(matches, ~"jit"),
verbose: getopts::opt_present(matches, ~"verbose")};
}
fn log_config(config: config) {
let c = config;
logv(c, fmt!("configuration:"));
logv(c, fmt!("compile_lib_path: %s", config.compile_lib_path));
logv(c, fmt!("run_lib_path: %s", config.run_lib_path));
logv(c, fmt!("rustc_path: %s", config.rustc_path.to_str()));
logv(c, fmt!("src_base: %s", config.src_base.to_str()));
logv(c, fmt!("build_base: %s", config.build_base.to_str()));
logv(c, fmt!("stage_id: %s", config.stage_id));
logv(c, fmt!("mode: %s", mode_str(config.mode)));
logv(c, fmt!("run_ignored: %b", config.run_ignored));
logv(c, fmt!("filter: %s", opt_str(config.filter)));
logv(c, fmt!("runtool: %s", opt_str(config.runtool)));
logv(c, fmt!("rustcflags: %s", opt_str(config.rustcflags)));
logv(c, fmt!("jit: %b", config.jit));
logv(c, fmt!("verbose: %b", config.verbose));
logv(c, fmt!("\n"));
}
fn opt_str(maybestr: Option<~str>) -> ~str {
match maybestr { option::Some(s) => s, option::None => ~"(none)" }
}
fn str_opt(maybestr: ~str) -> Option<~str> {
if maybestr != ~"(none)" { option::Some(maybestr) } else { option::None }
}
fn str_mode(s: ~str) -> mode {
match s {
~"compile-fail" => mode_compile_fail,
~"run-fail" => mode_run_fail,
~"run-pass" => mode_run_pass,
~"pretty" => mode_pretty,
_ => fail ~"invalid mode"
}
}
fn mode_str(mode: mode) -> ~str {
match mode {
mode_compile_fail => ~"compile-fail",
mode_run_fail => ~"run-fail",
mode_run_pass => ~"run-pass",
mode_pretty => ~"pretty"
}
}
fn run_tests(config: config) {
let opts = test_opts(config);
let tests = make_tests(config);
let res = test::run_tests_console(&opts, tests);
if !res { fail ~"Some tests failed"; }
}
fn test_opts(config: config) -> test::TestOpts {
{filter:
match config.filter {
option::Some(s) => option::Some(s),
option::None => option::None
},
run_ignored: config.run_ignored,
logfile:
match config.logfile {
option::Some(s) => option::Some(s.to_str()),
option::None => option::None
}
}
}
fn make_tests(config: config) -> ~[test::TestDesc] {
debug!("making tests from %s",
config.src_base.to_str());
let mut tests = ~[];
for os::list_dir_path(&config.src_base).each |file| {
let file = copy *file;
debug!("inspecting file %s", file.to_str());
if is_test(config, file) {
tests.push(make_test(config, file))
}
}
move tests
}
fn is_test(config: config, testfile: &Path) -> bool {
// Pretty-printer does not work with .rc files yet
let valid_extensions =
match config.mode {
mode_pretty => ~[~".rs"],
_ => ~[~".rc", ~".rs"]
};
let invalid_prefixes = ~[~".", ~"#", ~"~"];
let name = testfile.filename().get();
let mut valid = false;
for valid_extensions.each |ext| {
if str::ends_with(name, *ext) { valid = true; }
}
for invalid_prefixes.each |pre| {
if str::starts_with(name, *pre) { valid = false; }
}
return valid;
}
fn make_test(config: config, testfile: &Path) ->
test::TestDesc {
{
name: make_test_name(config, testfile),
testfn: make_test_closure(config, testfile),
ignore: header::is_test_ignored(config, testfile),
should_fail: false
}
}
fn make_test_name(config: config, testfile: &Path) -> ~str {
fmt!("[%s] %s", mode_str(config.mode), testfile.to_str())
}
fn make_test_closure(config: config, testfile: &Path) -> test::TestFn {
let testfile = testfile.to_str();
fn~() { runtest::run(config, testfile) }
}
// Local Variables:
// fill-column: 78;
// indent-tabs-mode: nil
// c-basic-offset: 4
// buffer-file-coding-system: utf-8-unix
// End:
此差异已折叠。
此差异已折叠。
......@@ -66,15 +66,7 @@ pub fn all_values(blk: fn(v: bool)) {
pub pure fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } }
impl bool : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &bool) -> bool { self == (*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &bool) -> bool { (*self) == (*other) }
#[cfg(stage0)]
pure fn ne(other: &bool) -> bool { self != (*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &bool) -> bool { (*self) != (*other) }
}
......
......@@ -28,38 +28,14 @@ pub struct BoxRepr {
}
impl<T:Eq> @const T : Eq {
#[cfg(stage0)]
pure fn eq(other: &@const T) -> bool { *self == *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &@const T) -> bool { *(*self) == *(*other) }
#[cfg(stage0)]
pure fn ne(other: &@const T) -> bool { *self != *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &@const T) -> bool { *(*self) != *(*other) }
}
impl<T:Ord> @const T : Ord {
#[cfg(stage0)]
pure fn lt(other: &@const T) -> bool { *self < *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn lt(&self, other: &@const T) -> bool { *(*self) < *(*other) }
#[cfg(stage0)]
pure fn le(other: &@const T) -> bool { *self <= *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn le(&self, other: &@const T) -> bool { *(*self) <= *(*other) }
#[cfg(stage0)]
pure fn ge(other: &@const T) -> bool { *self >= *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ge(&self, other: &@const T) -> bool { *(*self) >= *(*other) }
#[cfg(stage0)]
pure fn gt(other: &@const T) -> bool { *self > *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn gt(&self, other: &@const T) -> bool { *(*self) > *(*other) }
}
......
......@@ -181,15 +181,7 @@
}
impl char : Eq {
#[cfg(stage0)]
pure fn eq(other: &char) -> bool { self == (*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &char) -> bool { (*self) == (*other) }
#[cfg(stage0)]
pure fn ne(other: &char) -> bool { self != (*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &char) -> bool { (*self) != (*other) }
}
......
......@@ -30,17 +30,6 @@ mod nounittest {
* default implementations.
*/
#[lang="ord"]
#[cfg(stage0)]
pub trait Ord {
pure fn lt(other: &self) -> bool;
pure fn le(other: &self) -> bool;
pure fn ge(other: &self) -> bool;
pure fn gt(other: &self) -> bool;
}
#[lang="ord"]
#[cfg(stage1)]
#[cfg(stage2)]
pub trait Ord {
pure fn lt(&self, other: &self) -> bool;
pure fn le(&self, other: &self) -> bool;
......@@ -58,15 +47,6 @@ pub trait Ord {
* a default implementation.
*/
#[lang="eq"]
#[cfg(stage0)]
pub trait Eq {
pure fn eq(other: &self) -> bool;
pure fn ne(other: &self) -> bool;
}
#[lang="eq"]
#[cfg(stage1)]
#[cfg(stage2)]
pub trait Eq {
pure fn eq(&self, other: &self) -> bool;
pure fn ne(&self, other: &self) -> bool;
......@@ -81,16 +61,6 @@ mod nounittest {
mod unittest {
#[legacy_exports];
#[cfg(stage0)]
pub trait Ord {
pure fn lt(other: &self) -> bool;
pure fn le(other: &self) -> bool;
pure fn ge(other: &self) -> bool;
pure fn gt(other: &self) -> bool;
}
#[cfg(stage1)]
#[cfg(stage2)]
pub trait Ord {
pure fn lt(&self, other: &self) -> bool;
pure fn le(&self, other: &self) -> bool;
......@@ -98,14 +68,6 @@ pub trait Ord {
pure fn gt(&self, other: &self) -> bool;
}
#[cfg(stage0)]
pub trait Eq {
pure fn eq(other: &self) -> bool;
pure fn ne(other: &self) -> bool;
}
#[cfg(stage1)]
#[cfg(stage2)]
pub trait Eq {
pure fn eq(&self, other: &self) -> bool;
pure fn ne(&self, other: &self) -> bool;
......
......@@ -45,80 +45,54 @@ Implicitly, all crates behave as if they included the following prologue:
// Built-in-type support modules
/// Operations and constants for `int`
#[path = "int-template"]
pub mod int {
pub use inst::{ pow };
#[path = "int.rs"]
pub mod inst;
}
#[path = "int-template.rs"]
#[merge = "int-template/intb.rs"]
pub mod int;
/// Operations and constants for `i8`
#[path = "int-template"]
pub mod i8 {
#[path = "i8.rs"]
pub mod inst;
}
#[path = "int-template.rs"]
#[merge = "int-template/i8b.rs"]
pub mod i8;
/// Operations and constants for `i16`
#[path = "int-template"]
pub mod i16 {
#[path = "i16.rs"]
pub mod inst;
}
#[path = "int-template.rs"]
#[merge = "int-template/i16b.rs"]
pub mod i16;
/// Operations and constants for `i32`
#[path = "int-template"]
pub mod i32 {
#[path = "i32.rs"]
pub mod inst;
}
#[path = "int-template.rs"]
#[merge = "int-template/i32b.rs"]
pub mod i32;
/// Operations and constants for `i64`
#[path = "int-template"]
pub mod i64 {
#[path = "i64.rs"]
pub mod inst;
}
#[path = "int-template.rs"]
#[merge = "int-template/i64b.rs"]
pub mod i64;
/// Operations and constants for `uint`
#[path = "uint-template"]
pub mod uint {
pub use inst::{
div_ceil, div_round, div_floor, iterate,
next_power_of_two
};
#[path = "uint.rs"]
pub mod inst;
}
#[path = "uint-template.rs"]
#[merge = "uint-template/uintb.rs"]
pub mod uint;
/// Operations and constants for `u8`
#[path = "uint-template"]
pub mod u8 {
pub use inst::is_ascii;
#[path = "u8.rs"]
pub mod inst;
}
#[path = "uint-template.rs"]
#[merge = "uint-template/u8b.rs"]
pub mod u8;
/// Operations and constants for `u16`
#[path = "uint-template"]
pub mod u16 {
#[path = "u16.rs"]
pub mod inst;
}
#[path = "uint-template.rs"]
#[merge = "uint-template/u16b.rs"]
pub mod u16;
/// Operations and constants for `u32`
#[path = "uint-template"]
pub mod u32 {
#[path = "u32.rs"]
pub mod inst;
}
#[path = "uint-template.rs"]
#[merge = "uint-template/u32b.rs"]
pub mod u32;
/// Operations and constants for `u64`
#[path = "uint-template"]
pub mod u64 {
#[path = "u64.rs"]
pub mod inst;
}
#[path = "uint-template.rs"]
#[merge = "uint-template/u64b.rs"]
pub mod u64;
pub mod box;
......@@ -146,11 +120,9 @@ pub mod either;
pub mod iter;
pub mod logging;
pub mod option;
#[path="iter-trait"]
pub mod option_iter {
#[path = "option.rs"]
pub mod inst;
}
#[path="iter-trait.rs"]
#[merge = "iter-trait/optionb.rs"]
pub mod option_iter;
pub mod result;
pub mod to_str;
pub mod to_bytes;
......@@ -161,27 +133,19 @@ pub mod clone;
// Data structure modules
pub mod dvec;
#[path="iter-trait"]
pub mod dvec_iter {
#[path = "dvec.rs"]
pub mod inst;
}
#[path="iter-trait.rs"]
#[merge = "iter-trait/dvecb.rs"]
pub mod dvec_iter;
pub mod dlist;
#[path="iter-trait"]
pub mod dlist_iter {
#[path ="dlist.rs"]
pub mod inst;
}
#[path="iter-trait.rs"]
#[merge = "iter-trait/dlistb.rs"]
pub mod dlist_iter;
pub mod send_map;
// Concurrency
pub mod comm;
pub mod task {
pub mod local_data;
mod local_data_priv;
pub mod spawn;
pub mod rt;
}
#[merge = "task/mod.rs"]
pub mod task;
pub mod pipes;
// Runtime and language-primitive support
......@@ -219,6 +183,92 @@ mod unicode;
mod cmath;
mod stackwalk;
// Top-level, visible-everywhere definitions.
// Export various ubiquitous types, constructors, methods.
pub use option::{Some, None};
pub use Option = option::Option;
pub use result::{Result, Ok, Err};
pub use Path = path::Path;
pub use GenericPath = path::GenericPath;
pub use WindowsPath = path::WindowsPath;
pub use PosixPath = path::PosixPath;
pub use tuple::{CopyableTuple, ImmutableTuple, ExtendedTupleOps};
pub use str::{StrSlice, Trimmable};
pub use vec::{ConstVector, CopyableVector, ImmutableVector};
pub use vec::{ImmutableEqVector, ImmutableCopyableVector};
pub use vec::{MutableVector, MutableCopyableVector};
pub use iter::{BaseIter, ExtendedIter, EqIter, CopyableIter};
pub use iter::{CopyableOrderedIter, CopyableNonstrictIter, Times};
pub use num::Num;
pub use ptr::Ptr;
pub use to_str::ToStr;
// The following exports are the core operators and kinds
// The compiler has special knowlege of these so we must not duplicate them
// when compiling for testing
#[cfg(notest)]
pub use ops::{Const, Copy, Send, Owned};
#[cfg(notest)]
pub use ops::{Drop};
#[cfg(notest)]
pub use ops::{Add, Sub, Mul, Div, Modulo, Neg, BitAnd, BitOr, BitXor};
#[cfg(notest)]
pub use ops::{Shl, Shr, Index};
#[cfg(test)]
extern mod coreops(name = "core", vers = "0.5");
#[cfg(test)]
pub use coreops::ops::{Const, Copy, Send, Owned};
#[cfg(test)]
pub use coreops::ops::{Drop};
#[cfg(test)]
pub use coreops::ops::{Add, Sub, Mul, Div, Modulo, Neg, BitAnd, BitOr};
#[cfg(test)]
pub use coreops::ops::{BitXor};
#[cfg(test)]
pub use coreops::ops::{Shl, Shr, Index};
#[cfg(notest)]
pub use clone::Clone;
#[cfg(test)]
pub use coreops::clone::Clone;
// Export the log levels as global constants. Higher levels mean
// more-verbosity. Error is the bottom level, default logging level is
// warn-and-below.
/// The error log level
pub const error : u32 = 1_u32;
/// The warning log level
pub const warn : u32 = 2_u32;
/// The info log level
pub const info : u32 = 3_u32;
/// The debug log level
pub const debug : u32 = 4_u32;
// A curious inner-module that's not exported that contains the binding
// 'core' so that macro-expanded references to core::error and such
// can be resolved within libcore.
#[doc(hidden)] // FIXME #3538
mod core {
pub const error : u32 = 1_u32;
pub const warn : u32 = 2_u32;
pub const info : u32 = 3_u32;
pub const debug : u32 = 4_u32;
}
// Similar to above. Some magic to make core testable.
#[cfg(test)]
mod std {
extern mod std(vers = "0.5");
pub use std::test;
}
// Local Variables:
// mode: rust;
// fill-column: 78;
......
// Top-level, visible-everywhere definitions.
// Export various ubiquitous types, constructors, methods.
pub use option::{Some, None};
pub use Option = option::Option;
pub use result::{Result, Ok, Err};
pub use Path = path::Path;
pub use GenericPath = path::GenericPath;
pub use WindowsPath = path::WindowsPath;
pub use PosixPath = path::PosixPath;
pub use tuple::{CopyableTuple, ImmutableTuple, ExtendedTupleOps};
pub use str::{StrSlice, Trimmable};
pub use vec::{ConstVector, CopyableVector, ImmutableVector};
pub use vec::{ImmutableEqVector, ImmutableCopyableVector};
pub use vec::{MutableVector, MutableCopyableVector};
pub use iter::{BaseIter, ExtendedIter, EqIter, CopyableIter};
pub use iter::{CopyableOrderedIter, CopyableNonstrictIter, Times};
pub use num::Num;
pub use ptr::Ptr;
pub use to_str::ToStr;
// The following exports are the core operators and kinds
// The compiler has special knowlege of these so we must not duplicate them
// when compiling for testing
#[cfg(notest)]
pub use ops::{Const, Copy, Send, Owned};
#[cfg(notest)]
pub use ops::{Drop};
#[cfg(notest)]
pub use ops::{Add, Sub, Mul, Div, Modulo, Neg, BitAnd, BitOr, BitXor};
#[cfg(notest)]
pub use ops::{Shl, Shr, Index};
#[cfg(test)]
extern mod coreops(name = "core", vers = "0.5");
#[cfg(test)]
pub use coreops::ops::{Const, Copy, Send, Owned};
#[cfg(test)]
pub use coreops::ops::{Drop};
#[cfg(test)]
pub use coreops::ops::{Add, Sub, Mul, Div, Modulo, Neg, BitAnd, BitOr};
#[cfg(test)]
pub use coreops::ops::{BitXor};
#[cfg(test)]
pub use coreops::ops::{Shl, Shr, Index};
#[cfg(notest)]
pub use clone::Clone;
#[cfg(test)]
pub use coreops::clone::Clone;
// Export the log levels as global constants. Higher levels mean
// more-verbosity. Error is the bottom level, default logging level is
// warn-and-below.
/// The error log level
pub const error : u32 = 1_u32;
/// The warning log level
pub const warn : u32 = 2_u32;
/// The info log level
pub const info : u32 = 3_u32;
/// The debug log level
pub const debug : u32 = 4_u32;
// A curious inner-module that's not exported that contains the binding
// 'core' so that macro-expanded references to core::error and such
// can be resolved within libcore.
#[doc(hidden)] // FIXME #3538
mod core {
pub const error : u32 = 1_u32;
pub const warn : u32 = 2_u32;
pub const info : u32 = 3_u32;
pub const debug : u32 = 4_u32;
}
// Similar to above. Some magic to make core testable.
#[cfg(test)]
mod std {
extern mod std(vers = "0.5");
pub use std::test;
}
......@@ -132,25 +132,6 @@ pub fn partition<T: Copy, U: Copy>(eithers: &[Either<T, U>])
}
impl<T:Eq,U:Eq> Either<T,U> : Eq {
#[cfg(stage0)]
pure fn eq(other: &Either<T,U>) -> bool {
match self {
Left(ref a) => {
match (*other) {
Left(ref b) => (*a).eq(b),
Right(_) => false
}
}
Right(ref a) => {
match (*other) {
Left(_) => false,
Right(ref b) => (*a).eq(b)
}
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Either<T,U>) -> bool {
match (*self) {
Left(ref a) => {
......@@ -167,10 +148,6 @@ impl<T:Eq,U:Eq> Either<T,U> : Eq {
}
}
}
#[cfg(stage0)]
pure fn ne(other: &Either<T,U>) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Either<T,U>) -> bool { !(*self).eq(other) }
}
......
......@@ -438,21 +438,6 @@ pub enum Ty { TyDefault, TyBits, TyHexUpper, TyHexLower, TyOctal, }
pub enum PadMode { PadSigned, PadUnsigned, PadNozero, PadFloat }
pub impl PadMode : Eq {
#[cfg(stage0)]
pure fn eq(other: &PadMode) -> bool {
match (self, (*other)) {
(PadSigned, PadSigned) => true,
(PadUnsigned, PadUnsigned) => true,
(PadNozero, PadNozero) => true,
(PadFloat, PadFloat) => true,
(PadSigned, _) => false,
(PadUnsigned, _) => false,
(PadNozero, _) => false,
(PadFloat, _) => false
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &PadMode) -> bool {
match ((*self), (*other)) {
(PadSigned, PadSigned) => true,
......@@ -465,10 +450,6 @@ pub impl PadMode : Eq {
(PadFloat, _) => false
}
}
#[cfg(stage0)]
pure fn ne(other: &PadMode) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &PadMode) -> bool { !(*self).eq(other) }
}
......
......@@ -400,38 +400,14 @@ pub fn from_str(num: &str) -> Option<float> {
pub pure fn tan(x: float) -> float { f64::tan(x as f64) as float }
impl float : Eq {
#[cfg(stage0)]
pub pure fn eq(other: &float) -> bool { self == (*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &float) -> bool { (*self) == (*other) }
#[cfg(stage0)]
pub pure fn ne(other: &float) -> bool { self != (*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &float) -> bool { (*self) != (*other) }
}
impl float : Ord {
#[cfg(stage0)]
pub pure fn lt(other: &float) -> bool { self < (*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn lt(&self, other: &float) -> bool { (*self) < (*other) }
#[cfg(stage0)]
pub pure fn le(other: &float) -> bool { self <= (*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn le(&self, other: &float) -> bool { (*self) <= (*other) }
#[cfg(stage0)]
pub pure fn ge(other: &float) -> bool { self >= (*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ge(&self, other: &float) -> bool { (*self) >= (*other) }
#[cfg(stage0)]
pub pure fn gt(other: &float) -> bool { self > (*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn gt(&self, other: &float) -> bool { (*self) > (*other) }
}
......
......@@ -55,38 +55,14 @@ pub fn range(lo: T, hi: T, it: fn(T) -> bool) {
}
impl T : Ord {
#[cfg(stage0)]
pure fn lt(other: &T) -> bool { return self < (*other); }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn lt(&self, other: &T) -> bool { return (*self) < (*other); }
#[cfg(stage0)]
pure fn le(other: &T) -> bool { return self <= (*other); }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn le(&self, other: &T) -> bool { return (*self) <= (*other); }
#[cfg(stage0)]
pure fn ge(other: &T) -> bool { return self >= (*other); }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ge(&self, other: &T) -> bool { return (*self) >= (*other); }
#[cfg(stage0)]
pure fn gt(other: &T) -> bool { return self > (*other); }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn gt(&self, other: &T) -> bool { return (*self) > (*other); }
}
impl T : Eq {
#[cfg(stage0)]
pure fn eq(other: &T) -> bool { return self == (*other); }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &T) -> bool { return (*self) == (*other); }
#[cfg(stage0)]
pure fn ne(other: &T) -> bool { return self != (*other); }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &T) -> bool { return (*self) != (*other); }
}
......
mod inst {
pub type T = i16;
pub const bits: uint = u16::bits;
}
\ No newline at end of file
mod inst {
pub type T = i32;
pub const bits: uint = u32::bits;
}
mod inst {
pub type T = i64;
pub const bits: uint = u64::bits;
}
\ No newline at end of file
mod inst {
pub type T = i8;
pub const bits: uint = u8::bits;
}
\ No newline at end of file
此差异已折叠。
......@@ -516,25 +516,12 @@ pub enum FileFlag { Append, Create, Truncate, NoFlag, }
pub enum WriterType { Screen, File }
pub impl WriterType : Eq {
#[cfg(stage0)]
pure fn eq(other: &WriterType) -> bool {
match (self, (*other)) {
(Screen, Screen) | (File, File) => true,
(Screen, _) | (File, _) => false
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &WriterType) -> bool {
match ((*self), (*other)) {
(Screen, Screen) | (File, File) => true,
(Screen, _) | (File, _) => false
}
}
#[cfg(stage0)]
pure fn ne(other: &WriterType) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &WriterType) -> bool { !(*self).eq(other) }
}
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
mod local_data_priv;
pub mod local_data;
pub mod rt;
pub mod spawn;
此差异已折叠。
此差异已折叠。
mod inst {
pub type T = u16;
pub const bits: uint = 16;
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册