Skip to content

Commit 5e7aec4

Browse files
committed
---
yaml --- r: 36221 b: refs/heads/try2 c: 59a592f h: refs/heads/master i: 36219: a069b0b v: v3
1 parent 45e4b08 commit 5e7aec4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1019
-952
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: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: b0ed151539cddb1c191f67f9f9597942919d44eb
8+
refs/heads/try2: 59a592f4c43a1a7a1814951ecc5f41896cabd05d
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
1010
refs/heads/dist-snap: 22efa39382d41b084fde1719df7ae8ce5697d8c9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try2/src/libstd/net_tcp.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ pub fn TcpSocket(socket_data: @TcpSocketData) -> TcpSocket {
4848
*/
4949
struct TcpSocketBuf {
5050
data: @TcpBufferedSocketData,
51+
mut end_of_stream: bool,
5152
}
5253

5354
pub fn TcpSocketBuf(data: @TcpBufferedSocketData) -> TcpSocketBuf {
5455
TcpSocketBuf {
55-
data: data
56+
data: data,
57+
end_of_stream: false
5658
}
5759
}
5860

@@ -782,6 +784,7 @@ impl TcpSocketBuf: io::Reader {
782784
let err_data = read_result.get_err();
783785

784786
if err_data.err_name == ~"EOF" {
787+
self.end_of_stream = true;
785788
break;
786789
} else {
787790
debug!("ERROR sock_buf as io::reader.read err %? %?",
@@ -808,13 +811,21 @@ impl TcpSocketBuf: io::Reader {
808811
}
809812
fn read_byte() -> int {
810813
let mut bytes = ~[0];
811-
if self.read(bytes, 1u) == 0 { fail } else { bytes[0] as int }
814+
if self.read(bytes, 1u) == 0 {
815+
if self.end_of_stream {
816+
-1
817+
} else {
818+
fail
819+
}
820+
} else {
821+
bytes[0] as int
822+
}
812823
}
813824
fn unread_byte(amt: int) {
814825
self.data.buf.unshift(amt as u8);
815826
}
816827
fn eof() -> bool {
817-
false // noop
828+
self.end_of_stream
818829
}
819830
fn seek(dist: int, seek: io::SeekStyle) {
820831
log(debug, fmt!("tcp_socket_buf seek stub %? %?", dist, seek));
@@ -871,7 +882,8 @@ fn tear_down_socket_data(socket_data: @TcpSocketData) unsafe {
871882
uv::ll::close(stream_handle_ptr, tcp_socket_dtor_close_cb);
872883
};
873884
core::comm::recv(closed_po);
874-
log(debug, fmt!("about to free socket_data at %?", socket_data));
885+
//the line below will most likely crash
886+
//log(debug, fmt!("about to free socket_data at %?", socket_data));
875887
rustrt::rust_uv_current_kernel_free(stream_handle_ptr
876888
as *libc::c_void);
877889
log(debug, ~"exiting dtor for tcp_socket");

branches/try2/src/libsyntax/ast.rs

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -410,24 +410,18 @@ impl mutability : cmp::Eq {
410410

411411
#[auto_serialize]
412412
#[auto_deserialize]
413-
pub enum Proto {
414-
ProtoBare, // bare functions (deprecated)
415-
ProtoUniq, // ~fn
416-
ProtoBox, // @fn
417-
ProtoBorrowed, // &fn
413+
enum proto {
414+
proto_bare, // foreign fn
415+
proto_uniq, // fn~
416+
proto_box, // fn@
417+
proto_block, // fn&
418418
}
419419

420-
impl Proto : cmp::Eq {
421-
pure fn eq(other: &Proto) -> bool {
420+
impl proto : cmp::Eq {
421+
pure fn eq(other: &proto) -> bool {
422422
(self as uint) == ((*other) as uint)
423423
}
424-
pure fn ne(other: &Proto) -> bool { !self.eq(other) }
425-
}
426-
427-
impl Proto : to_bytes::IterBytes {
428-
pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {
429-
(self as uint).iter_bytes(lsb0, f);
430-
}
424+
pure fn ne(other: &proto) -> bool { !self.eq(other) }
431425
}
432426

433427
#[auto_serialize]
@@ -450,10 +444,10 @@ enum expr_vstore {
450444
expr_vstore_slice // &[1,2,3,4]
451445
}
452446

453-
pure fn is_blockish(p: ast::Proto) -> bool {
447+
pure fn is_blockish(p: ast::proto) -> bool {
454448
match p {
455-
ProtoBorrowed => true,
456-
ProtoBare | ProtoUniq | ProtoBox => false
449+
proto_block => true,
450+
proto_bare | proto_uniq | proto_box => false
457451
}
458452
}
459453

@@ -684,7 +678,7 @@ enum expr_ {
684678
(implicit) condition is always true. */
685679
expr_loop(blk, Option<ident>),
686680
expr_match(@expr, ~[arm]),
687-
expr_fn(Proto, fn_decl, blk, capture_clause),
681+
expr_fn(proto, fn_decl, blk, capture_clause),
688682
expr_fn_block(fn_decl, blk, capture_clause),
689683
// Inner expr is always an expr_fn_block. We need the wrapping node to
690684
// easily type this (a function returning nil on the inside but bool on
@@ -1084,17 +1078,6 @@ impl Onceness : cmp::Eq {
10841078
}
10851079
}
10861080

1087-
#[auto_serialize]
1088-
#[auto_deserialize]
1089-
struct TyFn {
1090-
proto: Proto,
1091-
region: Option<@region>,
1092-
purity: purity,
1093-
onceness: Onceness,
1094-
bounds: @~[ty_param_bound],
1095-
decl: fn_decl
1096-
}
1097-
10981081
#[auto_serialize]
10991082
#[auto_deserialize]
11001083
enum ty_ {
@@ -1103,13 +1086,13 @@ enum ty_ {
11031086
ty_box(mt),
11041087
ty_uniq(mt),
11051088
ty_vec(mt),
1106-
ty_fixed_length_vec(mt, uint),
11071089
ty_ptr(mt),
11081090
ty_rptr(@region, mt),
11091091
ty_rec(~[ty_field]),
1110-
ty_fn(@TyFn),
1092+
ty_fn(proto, purity, Onceness, @~[ty_param_bound], fn_decl),
11111093
ty_tup(~[@Ty]),
11121094
ty_path(@path, node_id),
1095+
ty_fixed_length(@Ty, Option<uint>),
11131096
ty_mac(mac),
11141097
// ty_infer means the type should be inferred instead of it having been
11151098
// specified. This should only appear at the "top level" of a type and not

branches/try2/src/libsyntax/fold.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -524,19 +524,15 @@ fn noop_fold_ty(t: ty_, fld: ast_fold) -> ty_ {
524524
ty_ptr(mt) => ty_ptr(fold_mt(mt, fld)),
525525
ty_rptr(region, mt) => ty_rptr(region, fold_mt(mt, fld)),
526526
ty_rec(fields) => ty_rec(vec::map(fields, |f| fold_field(*f, fld))),
527-
ty_fn(f) =>
528-
ty_fn(@TyFn {
529-
proto: f.proto,
530-
purity: f.purity,
531-
region: f.region,
532-
onceness: f.onceness,
533-
bounds: @vec::map(*f.bounds, |x| fold_ty_param_bound(*x, fld)),
534-
decl: fold_fn_decl(f.decl, fld)
535-
}),
527+
ty_fn(proto, purity, onceness, bounds, decl) =>
528+
ty_fn(proto,
529+
purity,
530+
onceness,
531+
@vec::map(*bounds, |x| fold_ty_param_bound(*x, fld)),
532+
fold_fn_decl(decl, fld)),
536533
ty_tup(tys) => ty_tup(vec::map(tys, |ty| fld.fold_ty(*ty))),
537534
ty_path(path, id) => ty_path(fld.fold_path(path), fld.new_id(id)),
538-
ty_fixed_length_vec(mt, vs) =>
539-
ty_fixed_length_vec(fold_mt(mt, fld), vs),
535+
ty_fixed_length(t, vs) => ty_fixed_length(fld.fold_ty(t), vs),
540536
ty_mac(mac) => ty_mac(fold_mac(mac))
541537
}
542538
}

branches/try2/src/libsyntax/parse/obsolete.rs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub enum ObsoleteSyntax {
2424
ObsoletePrivSection,
2525
ObsoleteModeInFnType,
2626
ObsoleteByMutRefMode,
27+
ObsoleteFixedLengthVec,
2728
ObsoleteMoveInit,
2829
ObsoleteBinaryMove
2930
}
@@ -101,6 +102,11 @@ impl Parser : ObsoleteReporter {
101102
"by-mutable-reference mode",
102103
"Declare an argument of type &mut T instead"
103104
),
105+
ObsoleteFixedLengthVec => (
106+
"fixed-length vector",
107+
"Fixed-length types are now written `[T * N]`, and instances \
108+
are type-inferred"
109+
),
104110
ObsoleteMoveInit => (
105111
"initializer-by-move",
106112
"Write `let foo = move bar` instead"
@@ -194,5 +200,65 @@ impl Parser : ObsoleteReporter {
194200
}
195201
}
196202

203+
fn try_parse_obsolete_fixed_vstore() -> Option<Option<uint>> {
204+
if self.token == token::BINOP(token::SLASH) {
205+
self.bump();
206+
match copy self.token {
207+
token::UNDERSCORE => {
208+
self.obsolete(copy self.last_span,
209+
ObsoleteFixedLengthVec);
210+
self.bump(); Some(None)
211+
}
212+
token::LIT_INT_UNSUFFIXED(i) if i >= 0i64 => {
213+
self.obsolete(copy self.last_span,
214+
ObsoleteFixedLengthVec);
215+
self.bump(); Some(Some(i as uint))
216+
}
217+
_ => None
218+
}
219+
} else {
220+
None
221+
}
222+
}
223+
224+
fn try_convert_ty_to_obsolete_fixed_length_vstore(sp: span, t: ast::ty_)
225+
-> ast::ty_ {
226+
match self.try_parse_obsolete_fixed_vstore() {
227+
// Consider a fixed length vstore suffix (/N or /_)
228+
None => t,
229+
Some(v) => {
230+
ast::ty_fixed_length(
231+
@{id: self.get_id(), node: t, span: sp}, v)
232+
}
233+
}
234+
}
235+
236+
fn try_convert_expr_to_obsolete_fixed_length_vstore(
237+
lo: uint, hi: uint, ex: ast::expr_
238+
) -> (uint, ast::expr_) {
239+
240+
let mut hi = hi;
241+
let mut ex = ex;
242+
243+
// Vstore is legal following expr_lit(lit_str(...)) and expr_vec(...)
244+
// only.
245+
match ex {
246+
ast::expr_lit(@{node: ast::lit_str(_), span: _}) |
247+
ast::expr_vec(_, _) => {
248+
match self.try_parse_obsolete_fixed_vstore() {
249+
None => (),
250+
Some(v) => {
251+
hi = self.span.hi;
252+
ex = ast::expr_vstore(self.mk_expr(lo, hi, ex),
253+
ast::expr_vstore_fixed(v));
254+
}
255+
}
256+
}
257+
_ => ()
258+
}
259+
260+
return (hi, ex);
261+
}
262+
197263
}
198264

0 commit comments

Comments
 (0)