Skip to content

Commit d9da439

Browse files
committed
Merge branch 'master' of github.com:graydon/rust
2 parents f10a5bb + 36d75d6 commit d9da439

File tree

14 files changed

+724
-237
lines changed

14 files changed

+724
-237
lines changed

doc/rust.texi

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ table. The task ahead involves combining, trimming, and implementing.
120120
@end quotation
121121
@sp 2
122122

123-
Rust is a curly-brace, block-structured statement language. It visually
123+
Rust is a curly-brace, block-structured expression language. It visually
124124
resembles the C language family, but differs significantly in syntactic and
125125
semantic details. Its design is oriented toward concerns of ``programming in
126126
the large'', that is, of creating and maintaining @emph{boundaries} -- both
@@ -334,7 +334,7 @@ The Rust type system is primarily structural, and contains the standard
334334
assortment of useful ``algebraic'' type constructors from functional
335335
languages, such as function types, tuples, record types, vectors, and
336336
nominally-tagged disjoint unions. Such values may be @emph{pattern-matched} in
337-
an @code{alt} statement.
337+
an @code{alt} expression.
338338

339339
@sp 1
340340
@item Generic code
@@ -394,8 +394,8 @@ the surrounding text by skipping over the bracketed ``extension text''.
394394
@sp 1
395395
@item Idempotent failure
396396

397-
If a task fails due to a signal, or if it executes the special @code{fail}
398-
statement, it enters the @emph{failing} state. A failing task unwinds its
397+
If a task fails due to a signal, or if it evaluates the special @code{fail}
398+
expression, it enters the @emph{failing} state. A failing task unwinds its
399399
control stack, frees all of its owned resources (executing destructors) and
400400
enters the @emph{dead} state. Failure is idempotent and non-recoverable.
401401

@@ -1486,8 +1486,8 @@ operating-system processes.
14861486
@cindex Port
14871487
@cindex Channel
14881488
@cindex Message passing
1489-
@cindex Send statement
1490-
@cindex Receive statement
1489+
@cindex Send expression
1490+
@cindex Receive expression
14911491

14921492
With the exception of @emph{unsafe} constructs, Rust tasks are isolated from
14931493
interfering with one another's memory directly. Instead of manipulating shared
@@ -1563,14 +1563,14 @@ A task begins its lifecycle -- once it has been spawned -- in the
15631563
function, and any functions called by the entry function.
15641564

15651565
A task may transition from the @emph{running} state to the @emph{blocked}
1566-
state any time it executes a communication statement on a port or channel that
1567-
cannot be immediately completed. When the communication statement can be
1566+
state any time it evaluates a communication expression on a port or channel that
1567+
cannot be immediately completed. When the communication expression can be
15681568
completed -- when a message arrives at a sender, or a queue drains
15691569
sufficiently to complete a semi-synchronous send -- then the blocked task will
15701570
unblock and transition back to @emph{running}.
15711571

15721572
A task may transition to the @emph{failing} state at any time, due to an
1573-
un-trapped signal or the execution of a @code{fail} statement. Once
1573+
un-trapped signal or the evaluation of a @code{fail} expression. Once
15741574
@emph{failing}, a task unwinds its stack and transitions to the @emph{dead}
15751575
state. Unwinding the stack of a task is done by the task itself, on its own
15761576
control stack. If a value with a destructor is freed during unwinding, the
@@ -1804,8 +1804,8 @@ otherwise exactly as a function item (with a minor additional cost of calling
18041804
the function, as such a call is indirect). @xref{Ref.Type.Fn}.
18051805

18061806
Every control path in a function ends with either a @code{ret} or @code{be}
1807-
statement. If a control path lacks a @code{ret} statement in source code, an
1808-
implicit @code{ret} statement is appended to the end of the control path
1807+
expression. If a control path lacks a @code{ret} expression in source code, an
1808+
implicit @code{ret} expression is appended to the end of the control path
18091809
during compilation, returning the implicit @code{()} value.
18101810

18111811
A function may have an @emph{effect}, which may be either @code{impure} or
@@ -1827,9 +1827,9 @@ fn add(int x, int y) -> int @{
18271827
@c * Ref.Item.Iter:: Items defining iterators.
18281828

18291829
@cindex Iterators
1830-
@cindex Put statement
1831-
@cindex Put each statement
1832-
@cindex Foreach statement
1830+
@cindex Put expression
1831+
@cindex Put each expression
1832+
@cindex Foreach expression
18331833

18341834
Iterators are function-like items that can @code{put} multiple values during
18351835
their execution before returning or tail-calling.
@@ -1841,11 +1841,11 @@ but the iterator frame is only @emph{suspended} during the put, and will be
18411841
the caller's loop.
18421842

18431843
The output type of an iterator is the type of value that the function will
1844-
@code{put}, before it eventually executes a @code{ret} or @code{be} statement
1844+
@code{put}, before it eventually evaluates a @code{ret} or @code{be} expression
18451845
of type @code{()} and completes its execution.
18461846

18471847
An iterator can only be called in the loop header of a matching @code{for
1848-
each} loop or as the argument in a @code{put each} statement.
1848+
each} loop or as the argument in a @code{put each} expression.
18491849
@xref{Ref.Stmt.Foreach}.
18501850

18511851
An example of an iterator:
@@ -2052,13 +2052,13 @@ Rust; they cannot be used as user-defined identifiers in any context.
20522052
@cindex Any type
20532053
@cindex Dynamic type, see @i{Any type}
20542054
@cindex Reflection
2055-
@cindex Alt type statement
2055+
@cindex Alt type expression
20562056

20572057
The type @code{any} is the union of all possible Rust types. A value of type
20582058
@code{any} is represented in memory as a pair consisting of a boxed value of
20592059
some non-@code{any} type @var{T} and a reflection of the type @var{T}.
20602060

2061-
Values of type @code{any} can be used in an @code{alt type} statement, in
2061+
Values of type @code{any} can be used in an @code{alt type} expression, in
20622062
which the reflection is used to select a block corresponding to a particular
20632063
type extraction. @xref{Ref.Stmt.Alt}.
20642064

@@ -2549,7 +2549,7 @@ right hand side of copy statements, @xref{Ref.Stmt.Copy}.
25492549
@c * Ref.Stmt:: Executable statements.
25502550
@cindex Statements
25512551

2552-
A @dfn{statement} is a component of a block, which is in turn a components of
2552+
A @dfn{statement} is a component of a block, which is in turn a component of
25532553
an outer block, a function or an iterator. When a function is spawned into a
25542554
task, the task @emph{executes} statements in an order determined by the body
25552555
of the enclosing structure. Each statement causes the task to perform certain

src/comp/front/ast.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ fn binop_to_str(binop op) -> str {
188188
189189
190190
tag unop {
191-
box;
191+
box(mutability);
192192
deref;
193193
bitnot;
194194
not;
@@ -197,7 +197,10 @@ tag unop {
197197
198198
fn unop_to_str(unop op) -> str {
199199
alt (op) {
200-
case (box) {ret "@";}
200+
case (box(?mt)) {
201+
if (mt == mut) { ret "@mutable"; }
202+
ret "@";
203+
}
201204
case (deref) {ret "*";}
202205
case (bitnot) {ret "~";}
203206
case (not) {ret "!";}
@@ -255,7 +258,7 @@ tag expr_ {
255258
expr_tup(vec[elt], ann);
256259
expr_rec(vec[field], option.t[@expr], ann);
257260
expr_call(@expr, vec[@expr], ann);
258-
expr_call_self(@expr, vec[@expr], ann);
261+
expr_call_self(ident, vec[@expr], ann);
259262
expr_bind(@expr, vec[option.t[@expr]], ann);
260263
expr_spawn(spawn_dom, option.t[str], @expr, vec[@expr], ann);
261264
expr_binary(binop, @expr, @expr, ann);

src/comp/front/parser.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -887,17 +887,19 @@ impure fn parse_bottom_expr(parser p) -> @ast.expr {
887887
}
888888

889889
case (token.SELF) {
890+
log "parsing a self-call...";
891+
890892
p.bump();
891893
expect(p, token.DOT);
892894
// The rest is a call expression.
893-
auto e = parse_bottom_expr(p);
895+
auto e = parse_ident(p);
894896
auto pf = parse_expr;
895897
auto es = parse_seq[@ast.expr](token.LPAREN,
896898
token.RPAREN,
897899
some(token.COMMA),
898900
pf, p);
899901
hi = es.span;
900-
auto ex = ast.expr_call_self(e, es.node, ast.ann_none);
902+
ex = ast.expr_call_self(e, es.node, ast.ann_none);
901903
}
902904

903905
case (_) {
@@ -1074,9 +1076,10 @@ impure fn parse_prefix_expr(parser p) -> @ast.expr {
10741076

10751077
case (token.AT) {
10761078
p.bump();
1079+
auto m = parse_mutability(p);
10771080
auto e = parse_prefix_expr(p);
10781081
hi = e.span;
1079-
ex = ast.expr_unary(ast.box, e, ast.ann_none);
1082+
ex = ast.expr_unary(ast.box(m), e, ast.ann_none);
10801083
}
10811084

10821085
case (_) {

src/comp/front/token.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,8 @@ fn to_str(token t) -> str {
348348

349349
/* Object type */
350350
case (OBJ) { ret "obj"; }
351+
case (SELF) { ret "self"; }
352+
351353

352354
/* Comm and task types */
353355
case (CHAN) { ret "chan"; }

src/comp/middle/fold.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ type ast_fold[ENV] =
8888
ann a) -> @expr) fold_expr_call,
8989

9090
(fn(&ENV e, &span sp,
91-
@expr f, vec[@expr] args,
91+
ident id, vec[@expr] args,
9292
ann a) -> @expr) fold_expr_call_self,
9393

9494
(fn(&ENV e, &span sp,
@@ -566,10 +566,9 @@ fn fold_expr[ENV](&ENV env, ast_fold[ENV] fld, &@expr e) -> @expr {
566566
ret fld.fold_expr_call(env_, e.span, ff, aargs, t);
567567
}
568568

569-
case (ast.expr_call_self(?f, ?args, ?t)) {
570-
auto ff = fold_expr(env_, fld, f);
569+
case (ast.expr_call_self(?ident, ?args, ?t)) {
571570
auto aargs = fold_exprs(env_, fld, args);
572-
ret fld.fold_expr_call_self(env_, e.span, ff, aargs, t);
571+
ret fld.fold_expr_call_self(env_, e.span, ident, aargs, t);
573572
}
574573

575574
case (ast.expr_bind(?f, ?args_opt, ?t)) {
@@ -1185,9 +1184,9 @@ fn identity_fold_expr_call[ENV](&ENV env, &span sp, @expr f,
11851184
ret @respan(sp, ast.expr_call(f, args, a));
11861185
}
11871186

1188-
fn identity_fold_expr_call_self[ENV](&ENV env, &span sp, @expr f,
1187+
fn identity_fold_expr_call_self[ENV](&ENV env, &span sp, ident id,
11891188
vec[@expr] args, ann a) -> @expr {
1190-
ret @respan(sp, ast.expr_call_self(f, args, a));
1189+
ret @respan(sp, ast.expr_call_self(id, args, a));
11911190
}
11921191

11931192
fn identity_fold_expr_bind[ENV](&ENV env, &span sp, @expr f,

0 commit comments

Comments
 (0)