Skip to content

Commit e3372be

Browse files
committed
---
yaml --- r: 54267 b: refs/heads/dist-snap c: ce9e5ec h: refs/heads/master i: 54265: ecc565b 54263: fc1fdcf v: v3
1 parent 0b19993 commit e3372be

File tree

5 files changed

+196
-10
lines changed

5 files changed

+196
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: 44d4d6de762f3f9aae1fedcf454c66b79b3ad58d
10-
refs/heads/dist-snap: 145f66fdf06b5e975910cf887879d575be6af672
10+
refs/heads/dist-snap: ce9e5ecb6c1f833eccb520b4179cf86329331fa6
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ then
533533
LLVM_VERSION=$($LLVM_CONFIG --version)
534534

535535
case $LLVM_VERSION in
536-
(3.1svn|3.1|3.0svn|3.0)
536+
(3.2svn|3.2|3.1svn|3.1|3.0svn|3.0)
537537
msg "found ok version of LLVM: $LLVM_VERSION"
538538
;;
539539
(*)

branches/dist-snap/src/libcore/unstable/extfmt.rs

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,9 @@ pub mod ct {
470470
// decisions made a runtime. If it proves worthwhile then some of these
471471
// conditions can be evaluated at compile-time. For now though it's cleaner to
472472
// implement it this way, I think.
473+
#[cfg(stage1)]
474+
#[cfg(stage2)]
475+
#[cfg(stage3)]
473476
#[doc(hidden)]
474477
pub mod rt {
475478
use float;
@@ -673,6 +676,192 @@ pub mod rt {
673676
}
674677
}
675678
679+
// XXX: remove after a snapshot of the above changes have gone in
680+
#[cfg(stage0)]
681+
#[doc(hidden)]
682+
pub mod rt {
683+
use float;
684+
use str;
685+
use sys;
686+
use uint;
687+
use vec;
688+
689+
pub static flag_none : u32 = 0u32;
690+
pub static flag_left_justify : u32 = 0b00000000000001u32;
691+
pub static flag_left_zero_pad : u32 = 0b00000000000010u32;
692+
pub static flag_space_for_sign : u32 = 0b00000000000100u32;
693+
pub static flag_sign_always : u32 = 0b00000000001000u32;
694+
pub static flag_alternate : u32 = 0b00000000010000u32;
695+
696+
pub enum Count { CountIs(uint), CountImplied, }
697+
698+
pub enum Ty { TyDefault, TyBits, TyHexUpper, TyHexLower, TyOctal, }
699+
700+
pub struct Conv {
701+
flags: u32,
702+
width: Count,
703+
precision: Count,
704+
ty: Ty,
705+
}
706+
707+
pub fn conv_int(cv: Conv, i: int) -> ~str {
708+
let radix = 10;
709+
let prec = get_int_precision(cv);
710+
let mut s : ~str = int_to_str_prec(i, radix, prec);
711+
if 0 <= i {
712+
if have_flag(cv.flags, flag_sign_always) {
713+
unsafe { str::unshift_char(&mut s, '+') };
714+
} else if have_flag(cv.flags, flag_space_for_sign) {
715+
unsafe { str::unshift_char(&mut s, ' ') };
716+
}
717+
}
718+
return unsafe { pad(cv, s, PadSigned) };
719+
}
720+
pub fn conv_uint(cv: Conv, u: uint) -> ~str {
721+
let prec = get_int_precision(cv);
722+
let mut rs =
723+
match cv.ty {
724+
TyDefault => uint_to_str_prec(u, 10, prec),
725+
TyHexLower => uint_to_str_prec(u, 16, prec),
726+
TyHexUpper => str::to_upper(uint_to_str_prec(u, 16, prec)),
727+
TyBits => uint_to_str_prec(u, 2, prec),
728+
TyOctal => uint_to_str_prec(u, 8, prec)
729+
};
730+
return unsafe { pad(cv, rs, PadUnsigned) };
731+
}
732+
pub fn conv_bool(cv: Conv, b: bool) -> ~str {
733+
let s = if b { ~"true" } else { ~"false" };
734+
// run the boolean conversion through the string conversion logic,
735+
// giving it the same rules for precision, etc.
736+
return conv_str(cv, s);
737+
}
738+
pub fn conv_char(cv: Conv, c: char) -> ~str {
739+
let mut s = str::from_char(c);
740+
return unsafe { pad(cv, s, PadNozero) };
741+
}
742+
pub fn conv_str(cv: Conv, s: &str) -> ~str {
743+
// For strings, precision is the maximum characters
744+
// displayed
745+
let mut unpadded = match cv.precision {
746+
CountImplied => s.to_owned(),
747+
CountIs(max) => if (max as uint) < str::char_len(s) {
748+
str::substr(s, 0, max as uint).to_owned()
749+
} else {
750+
s.to_owned()
751+
}
752+
};
753+
return unsafe { pad(cv, unpadded, PadNozero) };
754+
}
755+
pub fn conv_float(cv: Conv, f: float) -> ~str {
756+
let (to_str, digits) = match cv.precision {
757+
CountIs(c) => (float::to_str_exact, c as uint),
758+
CountImplied => (float::to_str_digits, 6u)
759+
};
760+
let mut s = unsafe { to_str(f, digits) };
761+
if 0.0 <= f {
762+
if have_flag(cv.flags, flag_sign_always) {
763+
s = ~"+" + s;
764+
} else if have_flag(cv.flags, flag_space_for_sign) {
765+
s = ~" " + s;
766+
}
767+
}
768+
return unsafe { pad(cv, s, PadFloat) };
769+
}
770+
pub fn conv_poly<T>(cv: Conv, v: &T) -> ~str {
771+
let s = sys::log_str(v);
772+
return conv_str(cv, s);
773+
}
774+
775+
// Convert an int to string with minimum number of digits. If precision is
776+
// 0 and num is 0 then the result is the empty string.
777+
pub fn int_to_str_prec(num: int, radix: uint, prec: uint) -> ~str {
778+
return if num < 0 {
779+
~"-" + uint_to_str_prec(-num as uint, radix, prec)
780+
} else { uint_to_str_prec(num as uint, radix, prec) };
781+
}
782+
783+
// Convert a uint to string with a minimum number of digits. If precision
784+
// is 0 and num is 0 then the result is the empty string. Could move this
785+
// to uint: but it doesn't seem all that useful.
786+
pub fn uint_to_str_prec(num: uint, radix: uint,
787+
prec: uint) -> ~str {
788+
return if prec == 0u && num == 0u {
789+
~""
790+
} else {
791+
let s = uint::to_str_radix(num, radix);
792+
let len = str::char_len(s);
793+
if len < prec {
794+
let diff = prec - len;
795+
let pad = str::from_chars(vec::from_elem(diff, '0'));
796+
pad + s
797+
} else { s }
798+
};
799+
}
800+
pub fn get_int_precision(cv: Conv) -> uint {
801+
return match cv.precision {
802+
CountIs(c) => c as uint,
803+
CountImplied => 1u
804+
};
805+
}
806+
807+
#[deriving(Eq)]
808+
pub enum PadMode { PadSigned, PadUnsigned, PadNozero, PadFloat }
809+
810+
pub fn pad(cv: Conv, s: ~str, mode: PadMode) -> ~str {
811+
let mut s = s; // sadtimes
812+
let uwidth : uint = match cv.width {
813+
CountImplied => return (s),
814+
CountIs(width) => { width as uint }
815+
};
816+
let strlen = str::char_len(s);
817+
if uwidth <= strlen { return (s); }
818+
let mut padchar = ' ';
819+
let diff = uwidth - strlen;
820+
if have_flag(cv.flags, flag_left_justify) {
821+
let padstr = str::from_chars(vec::from_elem(diff, padchar));
822+
return s + padstr;
823+
}
824+
let (might_zero_pad, signed) = match mode {
825+
PadNozero => (false, true),
826+
PadSigned => (true, true),
827+
PadFloat => (true, true),
828+
PadUnsigned => (true, false)
829+
};
830+
fn have_precision(cv: Conv) -> bool {
831+
return match cv.precision { CountImplied => false, _ => true };
832+
}
833+
let zero_padding = {
834+
if might_zero_pad && have_flag(cv.flags, flag_left_zero_pad) &&
835+
(!have_precision(cv) || mode == PadFloat) {
836+
padchar = '0';
837+
true
838+
} else {
839+
false
840+
}
841+
};
842+
let padstr = str::from_chars(vec::from_elem(diff, padchar));
843+
// This is completely heinous. If we have a signed value then
844+
// potentially rip apart the intermediate result and insert some
845+
// zeros. It may make sense to convert zero padding to a precision
846+
// instead.
847+
848+
if signed && zero_padding && s.len() > 0 {
849+
let head = str::shift_char(&mut s);
850+
if head == '+' || head == '-' || head == ' ' {
851+
let headstr = str::from_chars(vec::from_elem(1u, head));
852+
return headstr + padstr + s;
853+
}
854+
else {
855+
str::unshift_char(&mut s, head);
856+
}
857+
}
858+
return padstr + s;
859+
}
860+
pub fn have_flag(flags: u32, f: u32) -> bool {
861+
flags & f != 0
862+
}
863+
}
864+
676865
// Bulk of the tests are in src/test/run-pass/syntax-extension-fmt.rs
677866
#[cfg(test)]
678867
mod test {

branches/dist-snap/src/libcore/unstable/lang.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ pub unsafe fn fail_borrowed() {
6464

6565
// FIXME #4942: Make these signatures agree with exchange_alloc's signatures
6666
#[lang="exchange_malloc"]
67+
#[inline(always)]
6768
pub unsafe fn exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char {
6869
transmute(exchange_alloc::malloc(transmute(td), transmute(size)))
6970
}
@@ -72,11 +73,13 @@ pub unsafe fn exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char {
7273
// inside a landing pad may corrupt the state of the exception handler. If a
7374
// problem occurs, call exit instead.
7475
#[lang="exchange_free"]
76+
#[inline(always)]
7577
pub unsafe fn exchange_free(ptr: *c_char) {
7678
exchange_alloc::free(transmute(ptr))
7779
}
7880

7981
#[lang="malloc"]
82+
#[inline(always)]
8083
pub unsafe fn local_malloc(td: *c_char, size: uintptr_t) -> *c_char {
8184
return rustrt::rust_upcall_malloc(td, size);
8285
}
@@ -85,6 +88,7 @@ pub unsafe fn local_malloc(td: *c_char, size: uintptr_t) -> *c_char {
8588
// inside a landing pad may corrupt the state of the exception handler. If a
8689
// problem occurs, call exit instead.
8790
#[lang="free"]
91+
#[inline(always)]
8892
pub unsafe fn local_free(ptr: *c_char) {
8993
rustrt::rust_upcall_free(ptr);
9094
}
@@ -117,6 +121,7 @@ pub unsafe fn check_not_borrowed(a: *u8) {
117121
}
118122

119123
#[lang="strdup_uniq"]
124+
#[inline(always)]
120125
pub unsafe fn strdup_uniq(ptr: *c_uchar, len: uint) -> ~str {
121126
str::raw::from_buf_len(ptr, len)
122127
}

branches/dist-snap/src/snapshots.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
S 2013-03-27 8c15409
2-
macos-x86_64 05eb3801b60056d95715c891d00c5d372e34d00c
3-
macos-i386 4119e3fa614fa86adf60ed0183d00db3ce6d0dbc
4-
linux-x86_64 e9308bade0e068bca4abe59ef4afe8c8bb7c134d
5-
linux-i386 bcb30ed1817df1a07588cde2fb0ccaf9ffad7efb
6-
winnt-i386 a16d409465e125bc6f779b45821ae1ea276c6bd4
7-
freebsd-x86_64 348192f348f03541549f4e2c97af78901d59ca6e
8-
91
S 2013-03-21 ed25a67
102
freebsd-x86_64 5f0b08839ae3d1207808f0d57cbfdb00eff9c883
113
linux-i386 54765a17c6b6d04a7013cada2a51d190462979b8

0 commit comments

Comments
 (0)