Skip to content

Commit af9c521

Browse files
lkupergraydon
authored andcommitted
---
yaml --- r: 2530 b: refs/heads/master c: 814b173 h: refs/heads/master v: v3
1 parent 549a6a5 commit af9c521

File tree

5 files changed

+77
-85
lines changed

5 files changed

+77
-85
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: b6f35c6a4b7b91399e9338fa29d91781f3bf2797
2+
refs/heads/master: 814b17352c5b5267e29f73a6ddf93f97030ac62c

trunk/src/comp/front/ast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,10 @@ type _obj = rec(vec[obj_field] fields,
374374

375375
type anon_obj = rec(
376376
// New fields and methods, if they exist.
377-
Option.t[vec[obj_field]] fields,
377+
option::t[vec[obj_field]] fields,
378378
vec[@method] methods,
379379
// with_obj: the original object being extended, if it exists.
380-
Option.t[ident] with_obj);
380+
option::t[ident] with_obj);
381381

382382
type _mod = rec(vec[@view_item] view_items,
383383
vec[@item] items);

trunk/src/comp/front/parser.rs

Lines changed: 43 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -773,58 +773,21 @@ fn parse_bottom_expr(parser p) -> @ast::expr {
773773
some(token::COMMA),
774774
pf, hi, p);
775775
ex = ast::expr_vec(es, mut, p.get_ann());
776-
} else if (eat_word(p, "rec")) {
777-
expect(p, token::LPAREN);
778-
auto fields = vec(parse_field(p));
779-
780-
auto more = true;
781-
auto base = none[@ast::expr];
782-
while (more) {
783-
if (p.peek() == token::RPAREN) {
784-
hi = p.get_hi_pos();
785-
p.bump();
786-
more = false;
787-
} else if (eat_word(p, "with")) {
788-
base = some[@ast::expr](parse_expr(p));
789-
hi = p.get_hi_pos();
790-
expect(p, token::RPAREN);
791-
more = false;
792-
} else if (p.peek() == token::COMMA) {
793-
p.bump();
794-
fields += vec(parse_field(p));
795-
} else {
796-
unexpected(p, p.peek());
797-
}
798-
}
799-
800-
ex = ast::expr_rec(fields, base, p.get_ann());
801-
}
802-
// Anonymous object
803-
else if (eat_word(p, "obj")) {
776+
} else if (eat_word(p, "obj")) {
777+
// Anonymous object
804778

805779
// FIXME: Can anonymous objects have ty params?
806780
auto ty_params = parse_ty_params(p);
807781

808782
// Only make people type () if they're actually adding new fields
809-
let option.t[vec[ast::obj_field]] fields = none[vec[ast::obj_field]];
783+
let option::t[vec[ast::obj_field]] fields =
784+
none[vec[ast::obj_field]];
810785
if (p.peek() == token::LPAREN) {
811786
auto pf = parse_obj_field;
812-
expect(p, token::LBRACE);
813-
while (p.peek() != token::RBRACE) {
814-
alt (p.peek()) {
815-
case (token.WITH) {
816-
p.bump();
817-
with_obj = some[ast::ident](parse_ident(p));
818-
}
819-
case (_) {
820-
Vec.push[@ast::method](meths,
821-
parse_method(p));
822-
}
823-
}
824-
}
825-
826787
hi = p.get_hi_pos();
827788
expect(p, token::LPAREN);
789+
790+
828791
fields = some[vec[ast::obj_field]]
829792
(parse_seq_to_end[ast::obj_field]
830793
(token::RPAREN,
@@ -833,36 +796,65 @@ fn parse_bottom_expr(parser p) -> @ast::expr {
833796
}
834797

835798
let vec[@ast::method] meths = vec();
836-
let option.t[ast::ident] with_obj = none[ast::ident];
799+
let option::t[ast::ident] with_obj = none[ast::ident];
837800

838801
expect(p, token::LBRACE);
802+
839803
while (p.peek() != token::RBRACE) {
840804
alt (p.peek()) {
841805
case (token::WITH) {
806+
p.bump();
842807
with_obj = some[ast::ident](parse_ident(p));
843808
}
844809
case (_) {
845-
// fall through
810+
_vec::push[@ast::method](meths,
811+
parse_method(p));
846812
}
847813
}
848814
}
815+
849816
hi = p.get_hi_pos();
850817
expect(p, token::RBRACE);
851818

852-
// fields and methods may be *additional* or *overriding* fields and
853-
// methods if there's a with_obj, or they may be the *only* fields and
854-
// methods if there's no with_obj.
819+
// fields and methods may be *additional* or *overriding* fields
820+
// and methods if there's a with_obj, or they may be the *only*
821+
// fields and methods if there's no with_obj.
855822

856823
// We don't need to pull ".node" out of fields because it's not a
857824
// "spanned".
858825
let ast::anon_obj ob = rec(fields=fields,
859-
methods=meths,
860-
with_obj=with_obj);
826+
methods=meths,
827+
with_obj=with_obj);
861828

862829
auto odid = rec(ty=p.next_def_id(), ctor=p.next_def_id());
863830

864-
ex = ast::expr_anon_obj(ob, ty_params, odid, ast::ann_none);
831+
ex = ast::expr_anon_obj(ob, ty_params, odid, p.get_ann());
832+
833+
} else if (eat_word(p, "rec")) {
834+
expect(p, token::LPAREN);
835+
auto fields = vec(parse_field(p));
836+
837+
auto more = true;
838+
auto base = none[@ast::expr];
839+
while (more) {
840+
if (p.peek() == token::RPAREN) {
841+
hi = p.get_hi_pos();
842+
p.bump();
843+
more = false;
844+
} else if (eat_word(p, "with")) {
845+
base = some[@ast::expr](parse_expr(p));
846+
hi = p.get_hi_pos();
847+
expect(p, token::RPAREN);
848+
more = false;
849+
} else if (p.peek() == token::COMMA) {
850+
p.bump();
851+
fields += vec(parse_field(p));
852+
} else {
853+
unexpected(p, p.peek());
854+
}
855+
}
865856

857+
ex = ast::expr_rec(fields, base, p.get_ann());
866858
} else if (eat_word(p, "bind")) {
867859
auto e = parse_expr_res(p, RESTRICT_NO_CALL_EXPRS);
868860
fn parse_expr_opt(parser p) -> option::t[@ast::expr] {

trunk/src/comp/middle/fold.rs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,9 @@ type ast_fold[ENV] =
210210
&@expr e, &ann a) -> @expr) fold_expr_chan,
211211

212212
(fn(&ENV e, &span sp,
213-
&ast.anon_obj ob, // TODO: Is the ob arg supposed to be & or not?
214-
vec[ast.ty_param] tps,
215-
ast.obj_def_ids odid, ann a) -> @expr) fold_expr_anon_obj,
213+
&ast::anon_obj ob, // TODO: Is the ob arg supposed to be & or not?
214+
vec[ast::ty_param] tps,
215+
ast::obj_def_ids odid, ann a) -> @expr) fold_expr_anon_obj,
216216

217217
// Decl folds.
218218
(fn(&ENV e, &span sp,
@@ -327,9 +327,9 @@ type ast_fold[ENV] =
327327
-> ast::_obj) fold_obj,
328328

329329
(fn(&ENV e,
330-
Option.t[vec[ast.obj_field]] fields,
331-
vec[@ast.method] methods,
332-
Option.t[ident] with_obj) -> ast.anon_obj) fold_anon_obj,
330+
option::t[vec[ast::obj_field]] fields,
331+
vec[@ast::method] methods,
332+
option::t[ident] with_obj) -> ast::anon_obj) fold_anon_obj,
333333

334334
// Env updates.
335335
(fn(&ENV e, &@ast::crate c) -> ENV) update_env_for_crate,
@@ -838,7 +838,7 @@ fn fold_expr[ENV](&ENV env, &ast_fold[ENV] fld, &@expr e) -> @expr {
838838
ret fld.fold_expr_chan(env_, e.span, ee, t2);
839839
}
840840

841-
case (ast.expr_anon_obj(?ob, ?tps, ?odid, ?t)) {
841+
case (ast::expr_anon_obj(?ob, ?tps, ?odid, ?t)) {
842842
auto ee = fold_anon_obj(env_, fld, ob);
843843
auto t2 = fld.fold_ann(env_, t);
844844
ret fld.fold_expr_anon_obj(env_, e.span, ee, tps, odid, t2);
@@ -976,45 +976,45 @@ fn fold_obj[ENV](&ENV env, &ast_fold[ENV] fld, &ast::_obj ob) -> ast::_obj {
976976
ret fld.fold_obj(env, fields, meths, dtor);
977977
}
978978

979-
fn fold_anon_obj[ENV](&ENV env, ast_fold[ENV] fld, &ast.anon_obj ob)
980-
-> ast.anon_obj {
979+
fn fold_anon_obj[ENV](&ENV env, ast_fold[ENV] fld, &ast::anon_obj ob)
980+
-> ast::anon_obj {
981981

982982
// Fields
983-
let Option.t[vec[ast.obj_field]] fields = none[vec[ast.obj_field]];
983+
let option::t[vec[ast::obj_field]] fields = none[vec[ast::obj_field]];
984984
alt (ob.fields) {
985-
case (none[vec[ast.obj_field]]) { }
986-
case (some[vec[ast.obj_field]](?v)) {
987-
let vec[ast.obj_field] fields = vec();
988-
for (ast.obj_field f in v) {
985+
case (none[vec[ast::obj_field]]) { }
986+
case (some[vec[ast::obj_field]](?v)) {
987+
let vec[ast::obj_field] fields = vec();
988+
for (ast::obj_field f in v) {
989989
fields += vec(fold_obj_field(env, fld, f));
990990
}
991991
}
992992
}
993993

994994
// with_obj
995-
let Option.t[ast.ident] with_obj = none[ast.ident];
995+
let option::t[ast::ident] with_obj = none[ast::ident];
996996
alt (ob.with_obj) {
997-
case (none[ast.ident]) { }
998-
case (some[ast.ident](?i)) {
999-
with_obj = some[ast.ident](i);
997+
case (none[ast::ident]) { }
998+
case (some[ast::ident](?i)) {
999+
with_obj = some[ast::ident](i);
10001000
}
10011001
}
10021002

10031003
// Methods
1004-
let vec[@ast.method] meths = vec();
1005-
let vec[ast.ty_param] tp = vec();
1006-
for (@ast.method m in ob.methods) {
1007-
// Fake-up an ast.item for this method.
1004+
let vec[@ast::method] meths = vec();
1005+
let vec[ast::ty_param] tp = vec();
1006+
for (@ast::method m in ob.methods) {
1007+
// Fake-up an ast::item for this method.
10081008
// FIXME: this is kinda awful. Maybe we should reformulate
10091009
// the way we store methods in the AST?
1010-
let @ast.item i = @rec(node=ast.item_fn(m.node.ident,
1010+
let @ast::item i = @rec(node=ast::item_fn(m.node.ident,
10111011
m.node.meth,
10121012
tp,
10131013
m.node.id,
10141014
m.node.ann),
10151015
span=m.span);
10161016
let ENV _env = fld.update_env_for_item(env, i);
1017-
Vec.push[@ast.method](meths, fold_method(_env, fld, m));
1017+
_vec::push[@ast::method](meths, fold_method(_env, fld, m));
10181018
}
10191019
ret fld.fold_anon_obj(env, fields, meths, with_obj);
10201020
}
@@ -1468,9 +1468,9 @@ fn identity_fold_expr_chan[ENV](&ENV e, &span sp, &@expr x,
14681468
}
14691469

14701470
fn identity_fold_expr_anon_obj[ENV](&ENV e, &span sp,
1471-
&ast.anon_obj ob, vec[ast.ty_param] tps,
1472-
ast.obj_def_ids odid, ann a) -> @expr {
1473-
ret @respan(sp, ast.expr_anon_obj(ob, tps, odid, a));
1471+
&ast::anon_obj ob, vec[ast::ty_param] tps,
1472+
ast::obj_def_ids odid, ann a) -> @expr {
1473+
ret @respan(sp, ast::expr_anon_obj(ob, tps, odid, a));
14741474
}
14751475

14761476
// Decl identities.
@@ -1648,9 +1648,9 @@ fn identity_fold_obj[ENV](&ENV e,
16481648
}
16491649

16501650
fn identity_fold_anon_obj[ENV](&ENV e,
1651-
Option.t[vec[ast.obj_field]] fields,
1652-
vec[@ast.method] methods,
1653-
Option.t[ident] with_obj) -> ast.anon_obj {
1651+
option::t[vec[ast::obj_field]] fields,
1652+
vec[@ast::method] methods,
1653+
option::t[ident] with_obj) -> ast::anon_obj {
16541654
ret rec(fields=fields, methods=methods, with_obj=with_obj);
16551655
}
16561656

trunk/src/comp/middle/trans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2889,7 +2889,7 @@ fn iter_sequence(@block_ctxt cx,
28892889

28902890
cx.fcx.lcx.ccx.sess.bug("unexpected type in " +
28912891
"trans::iter_sequence: " +
2892-
ty.ty_to_str(cx.fcx.lcx.ccx.tcx, t));
2892+
ty::ty_to_str(cx.fcx.lcx.ccx.tcx, t));
28932893
fail;
28942894
}
28952895
}

0 commit comments

Comments
 (0)