Skip to content

Commit c349562

Browse files
committed
---
yaml --- r: 2007 b: refs/heads/master c: 2e90bd9 h: refs/heads/master i: 2005: 21f0289 2003: b674364 1999: 52883fe v: v3
1 parent 74f8d92 commit c349562

File tree

17 files changed

+348
-137
lines changed

17 files changed

+348
-137
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: d9da43984b5e9d50f711320d2afc3307537dfb44
2+
refs/heads/master: 2e90bd94de32c739733966bfac96cf35e9a08655

trunk/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ config.mk
5252
/test/
5353
/build/
5454
src/.DS_Store
55+
/stage0/

trunk/src/comp/front/ast.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ tag mode {
215215
216216
type stmt = spanned[stmt_];
217217
tag stmt_ {
218-
stmt_decl(@decl);
219-
stmt_expr(@expr);
218+
stmt_decl(@decl, option.t[@ts_ann]);
219+
stmt_expr(@expr, option.t[@ts_ann]);
220220
// These only exist in crate-level blocks.
221221
stmt_crate_directive(@crate_directive);
222222
}
@@ -495,7 +495,7 @@ fn index_native_view_item(native_mod_index index, @view_item it) {
495495
496496
fn index_stmt(block_index index, @stmt s) {
497497
alt (s.node) {
498-
case (ast.stmt_decl(?d)) {
498+
case (ast.stmt_decl(?d,_)) {
499499
alt (d.node) {
500500
case (ast.decl_local(?loc)) {
501501
index.insert(loc.ident, ast.bie_local(loc));

trunk/src/comp/front/parser.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import util.common;
1111
import util.common.filename;
1212
import util.common.span;
1313
import util.common.new_str_hash;
14+
import util.typestate_ann.ts_ann;
1415

1516
tag restriction {
1617
UNRESTRICTED;
@@ -1555,13 +1556,13 @@ impure fn parse_source_stmt(parser p) -> @ast.stmt {
15551556
case (token.LET) {
15561557
auto decl = parse_let(p);
15571558
auto hi = p.get_span();
1558-
ret @spanned(lo, hi, ast.stmt_decl(decl));
1559+
ret @spanned(lo, hi, ast.stmt_decl(decl, none[@ts_ann]));
15591560
}
15601561

15611562
case (token.AUTO) {
15621563
auto decl = parse_auto(p);
15631564
auto hi = p.get_span();
1564-
ret @spanned(lo, hi, ast.stmt_decl(decl));
1565+
ret @spanned(lo, hi, ast.stmt_decl(decl, none[@ts_ann]));
15651566
}
15661567

15671568
case (_) {
@@ -1570,13 +1571,13 @@ impure fn parse_source_stmt(parser p) -> @ast.stmt {
15701571
auto i = parse_item(p);
15711572
auto hi = i.span;
15721573
auto decl = @spanned(lo, hi, ast.decl_item(i));
1573-
ret @spanned(lo, hi, ast.stmt_decl(decl));
1574+
ret @spanned(lo, hi, ast.stmt_decl(decl, none[@ts_ann]));
15741575

15751576
} else {
15761577
// Remainder are line-expr stmts.
15771578
auto e = parse_expr(p);
15781579
auto hi = p.get_span();
1579-
ret @spanned(lo, hi, ast.stmt_expr(e));
1580+
ret @spanned(lo, hi, ast.stmt_expr(e, none[@ts_ann]));
15801581
}
15811582
}
15821583
}
@@ -1613,21 +1614,21 @@ fn index_arm(@ast.pat pat) -> hashmap[ast.ident,ast.def_id] {
16131614

16141615
fn stmt_to_expr(@ast.stmt stmt) -> option.t[@ast.expr] {
16151616
alt (stmt.node) {
1616-
case (ast.stmt_expr(?e)) { ret some[@ast.expr](e); }
1617+
case (ast.stmt_expr(?e,_)) { ret some[@ast.expr](e); }
16171618
case (_) { /* fall through */ }
16181619
}
16191620
ret none[@ast.expr];
16201621
}
16211622

16221623
fn stmt_ends_with_semi(@ast.stmt stmt) -> bool {
16231624
alt (stmt.node) {
1624-
case (ast.stmt_decl(?d)) {
1625+
case (ast.stmt_decl(?d,_)) {
16251626
alt (d.node) {
16261627
case (ast.decl_local(_)) { ret true; }
16271628
case (ast.decl_item(_)) { ret false; }
16281629
}
16291630
}
1630-
case (ast.stmt_expr(?e)) {
1631+
case (ast.stmt_expr(?e,_)) {
16311632
alt (e.node) {
16321633
case (ast.expr_vec(_,_,_)) { ret true; }
16331634
case (ast.expr_tup(_,_)) { ret true; }

trunk/src/comp/middle/fold.rs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import util.common.new_str_hash;
77
import util.common.spanned;
88
import util.common.span;
99
import util.common.ty_mach;
10+
import util.typestate_ann.ts_ann;
1011

1112
import front.ast;
1213
import front.ast.fn_decl;
@@ -232,10 +233,12 @@ type ast_fold[ENV] =
232233

233234
// Stmt folds.
234235
(fn(&ENV e, &span sp,
235-
@decl decl) -> @stmt) fold_stmt_decl,
236+
@decl decl, option.t[@ts_ann] a)
237+
-> @stmt) fold_stmt_decl,
236238

237239
(fn(&ENV e, &span sp,
238-
@expr e) -> @stmt) fold_stmt_expr,
240+
@expr e, option.t[@ts_ann] a)
241+
-> @stmt) fold_stmt_expr,
239242

240243
// Item folds.
241244
(fn(&ENV e, &span sp, ident ident,
@@ -788,14 +791,14 @@ fn fold_stmt[ENV](&ENV env, ast_fold[ENV] fld, &@stmt s) -> @stmt {
788791
}
789792

790793
alt (s.node) {
791-
case (ast.stmt_decl(?d)) {
794+
case (ast.stmt_decl(?d, ?a)) {
792795
auto dd = fold_decl(env_, fld, d);
793-
ret fld.fold_stmt_decl(env_, s.span, dd);
796+
ret fld.fold_stmt_decl(env_, s.span, dd, a);
794797
}
795798

796-
case (ast.stmt_expr(?e)) {
799+
case (ast.stmt_expr(?e, ?a)) {
797800
auto ee = fold_expr(env_, fld, e);
798-
ret fld.fold_stmt_expr(env_, s.span, ee);
801+
ret fld.fold_stmt_expr(env_, s.span, ee, a);
799802
}
800803
}
801804
fail;
@@ -1386,12 +1389,14 @@ fn identity_fold_pat_tag[ENV](&ENV e, &span sp, path p, vec[@pat] args,
13861389

13871390
// Stmt identities.
13881391

1389-
fn identity_fold_stmt_decl[ENV](&ENV env, &span sp, @decl d) -> @stmt {
1390-
ret @respan(sp, ast.stmt_decl(d));
1392+
fn identity_fold_stmt_decl[ENV](&ENV env, &span sp, @decl d,
1393+
option.t[@ts_ann] a) -> @stmt {
1394+
ret @respan(sp, ast.stmt_decl(d, a));
13911395
}
13921396

1393-
fn identity_fold_stmt_expr[ENV](&ENV e, &span sp, @expr x) -> @stmt {
1394-
ret @respan(sp, ast.stmt_expr(x));
1397+
fn identity_fold_stmt_expr[ENV](&ENV e, &span sp, @expr x,
1398+
option.t[@ts_ann] a) -> @stmt {
1399+
ret @respan(sp, ast.stmt_expr(x, a));
13951400
}
13961401

13971402

@@ -1642,8 +1647,8 @@ fn new_identity_fold[ENV]() -> ast_fold[ENV] {
16421647
fold_pat_bind = bind identity_fold_pat_bind[ENV](_,_,_,_,_),
16431648
fold_pat_tag = bind identity_fold_pat_tag[ENV](_,_,_,_,_,_),
16441649

1645-
fold_stmt_decl = bind identity_fold_stmt_decl[ENV](_,_,_),
1646-
fold_stmt_expr = bind identity_fold_stmt_expr[ENV](_,_,_),
1650+
fold_stmt_decl = bind identity_fold_stmt_decl[ENV](_,_,_,_),
1651+
fold_stmt_expr = bind identity_fold_stmt_expr[ENV](_,_,_,_),
16471652

16481653
fold_item_const= bind identity_fold_item_const[ENV](_,_,_,_,_,_,_),
16491654
fold_item_fn = bind identity_fold_item_fn[ENV](_,_,_,_,_,_,_),

trunk/src/comp/middle/resolve.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import front.creader;
66
import driver.session;
77
import util.common.new_def_hash;
88
import util.common.span;
9+
import util.typestate_ann.ts_ann;
910
import std.map.hashmap;
1011
import std.list.list;
1112
import std.list.nil;
@@ -348,7 +349,7 @@ fn lookup_name_wrapped(&env e, ast.ident i, namespace ns)
348349

349350
fn found_decl_stmt(@ast.stmt s, namespace ns) -> def_wrap {
350351
alt (s.node) {
351-
case (ast.stmt_decl(?d)) {
352+
case (ast.stmt_decl(?d,_)) {
352353
alt (d.node) {
353354
case (ast.decl_local(?loc)) {
354355
auto t = ast.def_local(loc.id);

trunk/src/comp/middle/trans.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ fn type_of_inner(@crate_ctxt cx, @ty.t t, bool boxed) -> TypeRef {
710710
llty = T_fn_pair(cx.tn, type_of_fn(cx, proto, args, out, 0u));
711711
}
712712
case (ty.ty_native_fn(?abi, ?args, ?out)) {
713-
auto nft = native_fn_wrapper_type(cx, 0u, t);
713+
auto nft = type_of_native_fn(cx, abi, args, out, 0u);
714714
llty = T_fn_pair(cx.tn, nft);
715715
}
716716
case (ty.ty_obj(?meths)) {
@@ -5208,11 +5208,11 @@ fn init_local(@block_ctxt cx, @ast.local local) -> result {
52085208
fn trans_stmt(@block_ctxt cx, &ast.stmt s) -> result {
52095209
auto bcx = cx;
52105210
alt (s.node) {
5211-
case (ast.stmt_expr(?e)) {
5211+
case (ast.stmt_expr(?e,_)) {
52125212
bcx = trans_expr(cx, e).bcx;
52135213
}
52145214

5215-
case (ast.stmt_decl(?d)) {
5215+
case (ast.stmt_decl(?d,_)) {
52165216
alt (d.node) {
52175217
case (ast.decl_local(?local)) {
52185218
bcx = init_local(bcx, local).bcx;
@@ -5302,7 +5302,7 @@ iter block_locals(&ast.block b) -> @ast.local {
53025302
// use the index here.
53035303
for (@ast.stmt s in b.node.stmts) {
53045304
alt (s.node) {
5305-
case (ast.stmt_decl(?d)) {
5305+
case (ast.stmt_decl(?d,_)) {
53065306
alt (d.node) {
53075307
case (ast.decl_local(?local)) {
53085308
put local;
@@ -6092,8 +6092,9 @@ fn native_fn_ty_param_count(@crate_ctxt cx, &ast.def_id id) -> uint {
60926092
ret count;
60936093
}
60946094

6095-
fn native_fn_wrapper_type(@crate_ctxt cx, uint ty_param_count, @ty.t x)
6095+
fn native_fn_wrapper_type(@crate_ctxt cx, uint ty_param_count, &ast.ann ann)
60966096
-> TypeRef {
6097+
auto x = node_ann_type(cx, ann);
60976098
alt (x.struct) {
60986099
case (ty.ty_native_fn(?abi, ?args, ?out)) {
60996100
ret type_of_fn(cx, ast.proto_fn, args, out, ty_param_count);
@@ -6109,8 +6110,7 @@ fn decl_native_fn_and_pair(@crate_ctxt cx,
61096110
auto num_ty_param = native_fn_ty_param_count(cx, id);
61106111

61116112
// Declare the wrapper.
6112-
auto t = node_ann_type(cx, ann);
6113-
auto wrapper_type = native_fn_wrapper_type(cx, num_ty_param, t);
6113+
auto wrapper_type = native_fn_wrapper_type(cx, num_ty_param, ann);
61146114
let str s = mangle_name_by_seq(cx, "wrapper");
61156115
let ValueRef wrapper_fn = decl_internal_fastcall_fn(cx.llmod, s,
61166116
wrapper_type);

trunk/src/comp/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ fn item_ty(@ast.item it) -> ty_params_and_ty {
731731

732732
fn stmt_ty(@ast.stmt s) -> @t {
733733
alt (s.node) {
734-
case (ast.stmt_expr(?e)) {
734+
case (ast.stmt_expr(?e,_)) {
735735
ret expr_ty(e);
736736
}
737737
case (_) {

trunk/src/comp/middle/typeck.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2479,12 +2479,12 @@ fn check_decl_local(&@fn_ctxt fcx, &@ast.decl decl) -> @ast.decl {
24792479

24802480
fn check_stmt(&@fn_ctxt fcx, &@ast.stmt stmt) -> @ast.stmt {
24812481
alt (stmt.node) {
2482-
case (ast.stmt_decl(?decl)) {
2482+
case (ast.stmt_decl(?decl,?a)) {
24832483
alt (decl.node) {
24842484
case (ast.decl_local(_)) {
24852485
auto decl_1 = check_decl_local(fcx, decl);
24862486
ret @fold.respan[ast.stmt_](stmt.span,
2487-
ast.stmt_decl(decl_1));
2487+
ast.stmt_decl(decl_1, a));
24882488
}
24892489

24902490
case (ast.decl_item(_)) {
@@ -2495,9 +2495,9 @@ fn check_stmt(&@fn_ctxt fcx, &@ast.stmt stmt) -> @ast.stmt {
24952495
ret stmt;
24962496
}
24972497

2498-
case (ast.stmt_expr(?expr)) {
2498+
case (ast.stmt_expr(?expr,?a)) {
24992499
auto expr_t = check_expr(fcx, expr);
2500-
ret @fold.respan[ast.stmt_](stmt.span, ast.stmt_expr(expr_t));
2500+
ret @fold.respan[ast.stmt_](stmt.span, ast.stmt_expr(expr_t, a));
25012501
}
25022502
}
25032503

0 commit comments

Comments
 (0)