Skip to content

Commit 07bb291

Browse files
committed
---
yaml --- r: 139421 b: refs/heads/try2 c: 4675022 h: refs/heads/master i: 139419: 575f58b v: v3
1 parent ea40fc4 commit 07bb291

File tree

37 files changed

+505
-303
lines changed

37 files changed

+505
-303
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 7a6cd2b21e240d3b075b30d598e661b038fe6fbe
8+
refs/heads/try2: 467502216efabae9e209b30702fc9444b184de7a
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/RELEASES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Version 0.6 (April 2013)
1+
Version 0.6 (March 2013)
22
---------------------------
33

44
* ~2100 changes, numerous bugfixes

branches/try2/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.2svn|3.2|3.1svn|3.1|3.0svn|3.0)
536+
(3.1svn|3.1|3.0svn|3.0)
537537
msg "found ok version of LLVM: $LLVM_VERSION"
538538
;;
539539
(*)

branches/try2/doc/tutorial.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -875,8 +875,7 @@ the compiler that unsafety does not leak outside of the unsafe block, and is
875875
used to create safe concepts on top of low-level code.
876876

877877
~~~~
878-
use core::libc::funcs::c95::stdlib::{calloc, free};
879-
use core::libc::types::os::arch::c95::size_t;
878+
use core::libc::{calloc, free, size_t};
880879
881880
fn main() {
882881
unsafe {
@@ -909,9 +908,7 @@ The unsafe code from above can be contained behind a safe API that prevents
909908
memory leaks or use-after-free:
910909

911910
~~~~
912-
use core::libc::funcs::c95::stdlib::{calloc, free};
913-
use core::libc::types::common::c95::c_void;
914-
use core::libc::types::os::arch::c95::size_t;
911+
use core::libc::{calloc, free, c_void, size_t};
915912
916913
struct Blob { priv ptr: *c_void }
917914

branches/try2/src/libcore/str.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,8 +726,7 @@ pub fn each_split_within<'a>(ss: &'a str,
726726

727727
(B, Cr, UnderLim) => { B }
728728
(B, Cr, OverLim) if (i - last_start + 1) > lim
729-
=> fail!(fmt!("word starting with %? longer than limit!",
730-
self::slice(ss, last_start, i + 1))),
729+
=> { fail!(~"word longer than limit!") }
731730
(B, Cr, OverLim) => { slice(); slice_start = last_start; B }
732731
(B, Ws, UnderLim) => { last_end = i; C }
733732
(B, Ws, OverLim) => { last_end = i; slice(); A }

branches/try2/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/try2/src/libcore/unstable/lang.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ 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)]
6867
pub unsafe fn exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char {
6968
transmute(exchange_alloc::malloc(transmute(td), transmute(size)))
7069
}
@@ -73,13 +72,11 @@ pub unsafe fn exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char {
7372
// inside a landing pad may corrupt the state of the exception handler. If a
7473
// problem occurs, call exit instead.
7574
#[lang="exchange_free"]
76-
#[inline(always)]
7775
pub unsafe fn exchange_free(ptr: *c_char) {
7876
exchange_alloc::free(transmute(ptr))
7977
}
8078

8179
#[lang="malloc"]
82-
#[inline(always)]
8380
pub unsafe fn local_malloc(td: *c_char, size: uintptr_t) -> *c_char {
8481
return rustrt::rust_upcall_malloc(td, size);
8582
}
@@ -88,7 +85,6 @@ pub unsafe fn local_malloc(td: *c_char, size: uintptr_t) -> *c_char {
8885
// inside a landing pad may corrupt the state of the exception handler. If a
8986
// problem occurs, call exit instead.
9087
#[lang="free"]
91-
#[inline(always)]
9288
pub unsafe fn local_free(ptr: *c_char) {
9389
rustrt::rust_upcall_free(ptr);
9490
}
@@ -121,7 +117,6 @@ pub unsafe fn check_not_borrowed(a: *u8) {
121117
}
122118

123119
#[lang="strdup_uniq"]
124-
#[inline(always)]
125120
pub unsafe fn strdup_uniq(ptr: *c_uchar, len: uint) -> ~str {
126121
str::raw::from_buf_len(ptr, len)
127122
}

branches/try2/src/librustc/driver/driver.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,8 @@ pub fn optgroups() -> ~[getopts::groups::OptGroup] {
762762
optflag(~"", ~"test", ~"Build a test harness"),
763763
optopt(~"", ~"target",
764764
~"Target triple cpu-manufacturer-kernel[-os]
765-
to compile for (see chapter 3.4 of http://www.sourceware.org/autobook/
765+
to compile for (see
766+
http://sources.redhat.com/autobook/autobook/autobook_17.html
766767
for detail)", ~"TRIPLE"),
767768
optopt(~"", ~"android-cross-path",
768769
~"The path to the Android NDK", "PATH"),

branches/try2/src/librustc/metadata/encoder.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ fn encode_enum_variant_info(ecx: @EncodeContext, ebml_w: writer::Encoder,
286286
if args.len() > 0 && generics.ty_params.len() == 0 => {
287287
encode_symbol(ecx, ebml_w, variant.node.id);
288288
}
289-
ast::tuple_variant_kind(_) | ast::struct_variant_kind(_) => {}
289+
ast::tuple_variant_kind(_) | ast::struct_variant_kind(_) |
290+
ast::enum_variant_kind(_) => {}
290291
}
291292
encode_discriminant(ecx, ebml_w, variant.node.id);
292293
if vi[i].disr_val != disr_val {

branches/try2/src/librustc/middle/liveness.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,11 +1306,11 @@ pub impl Liveness {
13061306
self.propagate_through_expr(e, succ)
13071307
}
13081308

1309-
expr_inline_asm(ref ia) =>{
1310-
let succ = do ia.inputs.foldr(succ) |&(_, expr), succ| {
1309+
expr_inline_asm(_, ref ins, ref outs, _, _, _) =>{
1310+
let succ = do ins.foldr(succ) |&(_, expr), succ| {
13111311
self.propagate_through_expr(expr, succ)
13121312
};
1313-
do ia.outputs.foldr(succ) |&(_, expr), succ| {
1313+
do outs.foldr(succ) |&(_, expr), succ| {
13141314
self.propagate_through_expr(expr, succ)
13151315
}
13161316
}
@@ -1580,19 +1580,14 @@ fn check_expr(expr: @expr, &&self: @Liveness, vt: vt<@Liveness>) {
15801580
visit::visit_expr(expr, self, vt);
15811581
}
15821582

1583-
expr_inline_asm(ref ia) => {
1584-
for ia.inputs.each |&(_, in)| {
1583+
expr_inline_asm(_, ref ins, ref outs, _, _, _) => {
1584+
for ins.each |&(_, in)| {
15851585
(vt.visit_expr)(in, self, vt);
15861586
}
15871587

15881588
// Output operands must be lvalues
1589-
for ia.outputs.each |&(_, out)| {
1590-
match out.node {
1591-
expr_addr_of(_, inner) => {
1592-
self.check_lvalue(inner, vt);
1593-
}
1594-
_ => {}
1595-
}
1589+
for outs.each |&(_, out)| {
1590+
self.check_lvalue(out, vt);
15961591
(vt.visit_expr)(out, self, vt);
15971592
}
15981593

branches/try2/src/librustc/middle/resolve.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use syntax::ast::{expr_binary, expr_break, expr_cast, expr_field};
3737
use syntax::ast::{expr_fn_block, expr_index, expr_method_call, expr_path};
3838
use syntax::ast::{def_prim_ty, def_region, def_self, def_ty, def_ty_param};
3939
use syntax::ast::{def_upvar, def_use, def_variant, div, eq};
40-
use syntax::ast::{expr, expr_again, expr_assign_op};
40+
use syntax::ast::{enum_variant_kind, expr, expr_again, expr_assign_op};
4141
use syntax::ast::{expr_index, expr_loop};
4242
use syntax::ast::{expr_path, expr_struct, expr_unary, fn_decl};
4343
use syntax::ast::{foreign_item, foreign_item_const, foreign_item_fn, ge};
@@ -1383,6 +1383,16 @@ pub impl Resolver {
13831383
variant.span);
13841384
self.structs.insert(local_def(variant.node.id));
13851385
}
1386+
enum_variant_kind(ref enum_definition) => {
1387+
child.define_type(privacy,
1388+
def_ty(local_def(variant.node.id)),
1389+
variant.span);
1390+
for (*enum_definition).variants.each |variant| {
1391+
self.build_reduced_graph_for_variant(*variant, item_id,
1392+
parent_privacy,
1393+
parent, visitor);
1394+
}
1395+
}
13861396
}
13871397
}
13881398

0 commit comments

Comments
 (0)