Skip to content

Commit a56e4b8

Browse files
committed
---
yaml --- r: 879 b: refs/heads/master c: 1d214b4 h: refs/heads/master i: 877: 10c5a51 875: 0ae3013 871: a13ca83 863: 735079e v: v3
1 parent d6f5344 commit a56e4b8

File tree

12 files changed

+69
-47
lines changed

12 files changed

+69
-47
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 16faef2218ec5c3621079f04e6b093a5bb1b44c2
2+
refs/heads/master: 1d214b4df3013a53e50d778fa921ed99bc498d02

trunk/src/comp/driver/rustc.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import front.token;
55
import middle.trans;
66
import middle.resolve;
77

8-
import std.util.option;
9-
import std.util.some;
10-
import std.util.none;
8+
import std.option;
9+
import std.option.some;
10+
import std.option.none;
1111
import std._str;
1212
import std._vec;
1313

@@ -39,8 +39,8 @@ fn usage(session.session sess, str argv0) {
3939
impure fn main(vec[str] args) {
4040

4141
auto sess = session.session();
42-
let option[str] input_file = none[str];
43-
let option[str] output_file = none[str];
42+
let option.t[str] input_file = none[str];
43+
let option.t[str] output_file = none[str];
4444
let bool do_warn = true;
4545

4646
auto i = 1u;

trunk/src/comp/front/ast.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11

2-
import util.common.option;
32
import std.map.hashmap;
43
import std.util.option;
54
import util.common.span;

trunk/src/comp/front/parser.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import std._io;
2-
import std.util.option;
3-
import std.util.some;
4-
import std.util.none;
2+
import std.option.some;
3+
import std.option.none;
54
import std.map.hashmap;
5+
import std.util.option;
66

77
import driver.session;
88
import util.common;

trunk/src/comp/middle/fold.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import std.map.hashmap;
2+
import std.option.some;
3+
import std.option.none;
24
import std.util.option;
3-
import std.util.some;
4-
import std.util.none;
55

66
import util.common.new_str_hash;
77
import util.common.spanned;

trunk/src/comp/middle/resolve.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import std.map.hashmap;
88
import std.list.list;
99
import std.list.nil;
1010
import std.list.cons;
11+
import std.option.some;
12+
import std.option.none;
1113
import std.util.option;
12-
import std.util.some;
13-
import std.util.none;
1414
import std._str;
1515

1616
tag scope {

trunk/src/comp/middle/trans.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import std._vec;
33
import std._str.rustrt.sbuf;
44
import std._vec.rustrt.vbuf;
55
import std.map.hashmap;
6+
import std.option.some;
7+
import std.option.none;
68
import std.util.option;
7-
import std.util.some;
8-
import std.util.none;
99

1010
import front.ast;
1111
import driver.session;

trunk/src/lib/deque.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* A deque, for fun. Untested as of yet. Likely buggy.
33
*/
44

5-
import std.util;
5+
import std.option;
66
import std._vec;
77
import std._int;
88

@@ -23,7 +23,7 @@ type t[T] = obj {
2323

2424
fn create[T]() -> t[T] {
2525

26-
type cell[T] = mutable util.option[T];
26+
type cell[T] = mutable option.t[T];
2727

2828
let uint initial_capacity = 32u; // 2^5
2929

@@ -39,7 +39,7 @@ fn create[T]() -> t[T] {
3939
if (i < nelts) {
4040
ret old.((lo + i) % nelts);
4141
} else {
42-
ret util.none[T];
42+
ret option.none;
4343
}
4444
}
4545

@@ -50,7 +50,7 @@ fn create[T]() -> t[T] {
5050

5151
fn get[T](vec[cell[T]] elts, uint i) -> T {
5252
alt (elts.(i)) {
53-
case (util.some[T](?t)) { ret t; }
53+
case (option.some[T](?t)) { ret t; }
5454
case (_) { fail; }
5555
}
5656
}
@@ -77,7 +77,7 @@ fn create[T]() -> t[T] {
7777
hi = nelts;
7878
}
7979

80-
elts.(lo) = util.some[T](t);
80+
elts.(lo) = option.some[T](t);
8181
nelts += 1u;
8282
}
8383

@@ -88,7 +88,7 @@ fn create[T]() -> t[T] {
8888
hi = nelts;
8989
}
9090

91-
elts.(hi) = util.some[T](t);
91+
elts.(hi) = option.some[T](t);
9292
hi = (hi + 1u) % _vec.len[cell[T]](elts);
9393
nelts += 1u;
9494
}
@@ -99,7 +99,7 @@ fn create[T]() -> t[T] {
9999
*/
100100
fn pop_front() -> T {
101101
let T t = get[T](elts, lo);
102-
elts.(lo) = util.none[T];
102+
elts.(lo) = option.none[T];
103103
lo = (lo + 1u) % _vec.len[cell[T]](elts);
104104
nelts -= 1u;
105105
ret t;
@@ -113,7 +113,7 @@ fn create[T]() -> t[T] {
113113
}
114114

115115
let T t = get[T](elts, hi);
116-
elts.(hi) = util.none[T];
116+
elts.(hi) = option.none[T];
117117
nelts -= 1u;
118118
ret t;
119119
}
@@ -132,7 +132,7 @@ fn create[T]() -> t[T] {
132132
}
133133

134134
}
135-
let vec[cell[T]] v = _vec.init_elt[cell[T]](util.none[T],
135+
let vec[cell[T]] v = _vec.init_elt[cell[T]](option.none[T],
136136
initial_capacity);
137137

138138
ret deque[T](0u, 0u, 0u, v);

trunk/src/lib/list.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

2-
import util.option;
3-
import util.some;
4-
import util.none;
2+
import option;
3+
import option.some;
4+
import option.none;
55

66
// FIXME: It would probably be more appealing to define this as
77
// type list[T] = rec(T hd, option[@list[T]] tl), but at the moment
@@ -27,7 +27,7 @@ fn foldl[T,U](&list[T] ls, &U u, fn(&T t, U u) -> U f) -> U {
2727
}
2828

2929
fn find[T,U](&list[T] ls,
30-
(fn(&T) -> option[U]) f) -> option[U] {
30+
(fn(&T) -> option.t[U]) f) -> option.t[U] {
3131
alt(ls) {
3232
case (cons[T](?hd, ?tl)) {
3333
alt (f(hd)) {

trunk/src/lib/option.rs

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// lib/option.rs
2+
3+
tag t[T] {
4+
none;
5+
some(T);
6+
}
7+
8+
type operator[T, U] = fn(&T) -> U;
9+
10+
fn get[T](&t[T] opt) -> T {
11+
alt (opt) {
12+
case (some[T](?x)) {
13+
ret x;
14+
}
15+
case (none[T]) {
16+
fail;
17+
}
18+
}
19+
}
20+
21+
fn map[T, U](&operator[T, U] f, &t[T] opt) -> t[U] {
22+
alt (opt) {
23+
case (some[T](?x)) {
24+
ret some[U](f(x));
25+
}
26+
case (none[T]) {
27+
ret none[U];
28+
}
29+
}
30+
}
31+
32+
// Local Variables:
33+
// mode: rust;
34+
// fill-column: 78;
35+
// indent-tabs-mode: nil
36+
// c-basic-offset: 4
37+
// buffer-file-coding-system: utf-8-unix
38+
// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
39+
// End:
40+

trunk/src/lib/std.rc

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ mod _task;
2020

2121
// Utility modules.
2222

23+
mod option;
2324
mod util;
2425

2526
// Authorize various rule-bendings.

trunk/src/lib/util.rs

-18
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,3 @@
1-
tag option[T] {
2-
none;
3-
some(T);
4-
}
5-
6-
type operator[T, U] = fn(&T) -> U;
7-
8-
fn option_map[T, U](&operator[T, U] f, &option[T] opt) -> option[U] {
9-
alt (opt) {
10-
case (some[T](?x)) {
11-
ret some[U](f(x));
12-
}
13-
case (none[T]) {
14-
ret none[U];
15-
}
16-
}
17-
}
18-
191
fn id[T](&T x) -> T {
202
ret x;
213
}

0 commit comments

Comments
 (0)