@@ -16,17 +16,16 @@ type path = spanned[path_];
16
16
fn path_name ( & path p) -> str { ret str:: connect ( p. node . idents , "::" ) ; }
17
17
18
18
type crate_num = int ;
19
+ type node_id = int ;
20
+ type def_id = tup ( crate_num , node_id ) ;
19
21
20
22
const crate_num local_crate = 0 ;
21
-
22
- type def_num = int ;
23
-
24
- type def_id = tup ( crate_num , def_num ) ;
23
+ fn local_def ( node_id id) -> def_id {
24
+ ret tup ( local_crate, id) ;
25
+ }
25
26
26
27
type ty_param = ident ;
27
28
28
- type ann = rec ( uint id) ;
29
-
30
29
tag def {
31
30
def_fn( def_id) ;
32
31
def_obj ( def_id) ;
@@ -102,15 +101,15 @@ type meta_item_ = rec(ident key, str value);
102
101
103
102
type block = spanned[ block_ ] ;
104
103
105
- type block_ = rec ( vec[ @stmt] stmts , option:: t[ @expr] expr, ann a ) ;
104
+ type block_ = rec ( vec[ @stmt] stmts , option:: t[ @expr] expr, node_id id ) ;
106
105
107
106
type pat = spanned[ pat_ ] ;
108
107
109
108
tag pat_ {
110
- pat_wild( ann ) ;
111
- pat_bind ( ident, def_id , ann ) ;
112
- pat_lit ( @lit, ann ) ;
113
- pat_tag ( path, vec[ @pat] , ann ) ;
109
+ pat_wild( node_id ) ;
110
+ pat_bind ( ident, node_id ) ;
111
+ pat_lit ( @lit, node_id ) ;
112
+ pat_tag ( path, vec[ @pat] , node_id ) ;
114
113
}
115
114
116
115
tag mutability { mut; imm; maybe_mut; }
@@ -183,8 +182,8 @@ tag mode { val; alias(bool); }
183
182
type stmt = spanned[stmt_];
184
183
185
184
tag stmt_ {
186
- stmt_decl(@decl, ann );
187
- stmt_expr(@expr, ann );
185
+ stmt_decl(@decl, node_id );
186
+ stmt_expr(@expr, node_id );
188
187
189
188
// These only exist in crate-level blocks.
190
189
stmt_crate_directive(@crate_directive);
@@ -199,8 +198,7 @@ type local_ =
199
198
bool infer,
200
199
ident ident,
201
200
option::t[initializer] init,
202
- def_id id,
203
- ann ann);
201
+ node_id id);
204
202
205
203
type local = spanned[local_];
206
204
@@ -225,58 +223,58 @@ tag seq_kind { sk_unique; sk_rc; }
225
223
type expr = spanned[expr_];
226
224
227
225
tag expr_ {
228
- expr_vec(vec[@expr], mutability, seq_kind, ann );
229
- expr_tup(vec[elt], ann );
230
- expr_rec(vec[field], option::t[@expr], ann );
231
- expr_call(@expr, vec[@expr], ann );
232
- expr_self_method(ident, ann );
233
- expr_bind(@expr, vec[option::t[@expr]], ann );
234
- expr_spawn(spawn_dom, option::t[str], @expr, vec[@expr], ann );
235
- expr_binary(binop, @expr, @expr, ann );
236
- expr_unary(unop, @expr, ann );
237
- expr_lit(@lit, ann );
238
- expr_cast(@expr, @ty, ann );
239
- expr_if(@expr, block, option::t[@expr], ann );
240
- expr_while(@expr, block, ann );
241
- expr_for(@local, @expr, block, ann );
242
- expr_for_each(@local, @expr, block, ann );
243
- expr_do_while(block, @expr, ann );
244
- expr_alt(@expr, vec[arm], ann );
245
- expr_fn(_fn, ann );
246
- expr_block(block, ann );
226
+ expr_vec(vec[@expr], mutability, seq_kind, node_id );
227
+ expr_tup(vec[elt], node_id );
228
+ expr_rec(vec[field], option::t[@expr], node_id );
229
+ expr_call(@expr, vec[@expr], node_id );
230
+ expr_self_method(ident, node_id );
231
+ expr_bind(@expr, vec[option::t[@expr]], node_id );
232
+ expr_spawn(spawn_dom, option::t[str], @expr, vec[@expr], node_id );
233
+ expr_binary(binop, @expr, @expr, node_id );
234
+ expr_unary(unop, @expr, node_id );
235
+ expr_lit(@lit, node_id );
236
+ expr_cast(@expr, @ty, node_id );
237
+ expr_if(@expr, block, option::t[@expr], node_id );
238
+ expr_while(@expr, block, node_id );
239
+ expr_for(@local, @expr, block, node_id );
240
+ expr_for_each(@local, @expr, block, node_id );
241
+ expr_do_while(block, @expr, node_id );
242
+ expr_alt(@expr, vec[arm], node_id );
243
+ expr_fn(_fn, node_id );
244
+ expr_block(block, node_id );
247
245
/*
248
246
* FIXME: many of these @exprs should be constrained with
249
247
* is_lval once we have constrained types working.
250
248
*/
251
- expr_move(@expr, @expr, ann );
252
- expr_assign(@expr,@expr, ann );
253
- expr_swap(@expr, @expr, ann );
254
- expr_assign_op(binop, @expr, @expr, ann );
255
- expr_send(@expr, @expr, ann );
256
- expr_recv(@expr, @expr, ann );
257
- expr_field(@expr, ident, ann );
258
- expr_index(@expr, @expr, ann );
259
- expr_path(path, ann );
260
- expr_ext(path, vec[@expr], option::t[str], @expr, ann );
261
- expr_fail(ann , option::t[str]);
262
- expr_break(ann );
263
- expr_cont(ann );
264
- expr_ret(option::t[@expr], ann );
265
- expr_put(option::t[@expr], ann );
266
- expr_be(@expr, ann );
267
- expr_log(int, @expr, ann );
249
+ expr_move(@expr, @expr, node_id );
250
+ expr_assign(@expr,@expr, node_id );
251
+ expr_swap(@expr, @expr, node_id );
252
+ expr_assign_op(binop, @expr, @expr, node_id );
253
+ expr_send(@expr, @expr, node_id );
254
+ expr_recv(@expr, @expr, node_id );
255
+ expr_field(@expr, ident, node_id );
256
+ expr_index(@expr, @expr, node_id );
257
+ expr_path(path, node_id );
258
+ expr_ext(path, vec[@expr], option::t[str], @expr, node_id );
259
+ expr_fail(node_id , option::t[str]);
260
+ expr_break(node_id );
261
+ expr_cont(node_id );
262
+ expr_ret(option::t[@expr], node_id );
263
+ expr_put(option::t[@expr], node_id );
264
+ expr_be(@expr, node_id );
265
+ expr_log(int, @expr, node_id );
268
266
269
267
/* just an assert, no significance to typestate */
270
- expr_assert(@expr, ann );
268
+ expr_assert(@expr, node_id );
271
269
272
270
/* preds that typestate is aware of */
273
- expr_check(@expr, ann );
271
+ expr_check(@expr, node_id );
274
272
/* FIXME Would be nice if expr_check desugared
275
273
to expr_if_check. */
276
- expr_if_check(@expr, block, option::t[@expr], ann );
277
- expr_port(ann );
278
- expr_chan(@expr, ann );
279
- expr_anon_obj(anon_obj, vec[ty_param], obj_def_ids, ann );
274
+ expr_if_check(@expr, block, option::t[@expr], node_id );
275
+ expr_port(node_id );
276
+ expr_chan(@expr, node_id );
277
+ expr_anon_obj(anon_obj, vec[ty_param], obj_def_ids, node_id );
280
278
}
281
279
282
280
type lit = spanned[lit_];
@@ -348,7 +346,7 @@ tag ty_ {
348
346
ty_rec(vec[ty_field]);
349
347
ty_fn(proto, vec[ty_arg], @ty, controlflow, vec[@constr]);
350
348
ty_obj(vec[ty_method]);
351
- ty_path(path, ann );
349
+ ty_path(path, node_id );
352
350
ty_type;
353
351
ty_constr(@ty, vec[@constr]);
354
352
}
@@ -368,15 +366,17 @@ type constr_arg = constr_arg_general[uint];
368
366
369
367
type constr_arg_general[T] = spanned[constr_arg_general_[T]];
370
368
371
- type constr_ = rec(path path, vec[@constr_arg_general[uint]] args, ann ann);
369
+ type constr_ = rec(path path,
370
+ vec[@constr_arg_general[uint]] args,
371
+ node_id id);
372
372
373
373
type constr = spanned[constr_];
374
374
375
375
376
376
/* The parser generates ast::constrs; resolve generates
377
377
a mapping from each function to a list of ty::constr_defs,
378
378
corresponding to these. */
379
- type arg = rec(mode mode, @ty ty, ident ident, def_id id);
379
+ type arg = rec(mode mode, @ty ty, ident ident, node_id id);
380
380
381
381
type fn_decl =
382
382
rec(vec[arg] inputs,
@@ -402,11 +402,11 @@ tag controlflow {
402
402
403
403
type _fn = rec ( fn_decl decl, proto proto, block body) ;
404
404
405
- type method_ = rec ( ident ident, _fn meth , def_id id, ann ann ) ;
405
+ type method_ = rec ( ident ident, _fn meth , node_id id) ;
406
406
407
407
type method = spanned[ method_ ] ;
408
408
409
- type obj_field = rec ( mutability mut, @ty ty, ident ident, def_id id, ann ann ) ;
409
+ type obj_field = rec ( mutability mut, @ty ty, ident ident, node_id id) ;
410
410
411
411
type _obj =
412
412
rec ( vec[ obj_field] fields , vec[ @method] methods , option:: t[ @method] dtor ) ;
@@ -435,22 +435,22 @@ type native_mod =
435
435
vec[ @view_item] view_items ,
436
436
vec[ @native_item] items ) ;
437
437
438
- type variant_arg = rec ( @ty ty, def_id id ) ;
438
+ type variant_arg = rec ( @ty ty, node_id id ) ;
439
439
440
- type variant_ = rec ( str name , vec[ variant_arg] args , def_id id, ann ann ) ;
440
+ type variant_ = rec ( str name , vec[ variant_arg] args , node_id id) ;
441
441
442
442
type variant = spanned[ variant_ ] ;
443
443
444
444
type view_item = spanned[ view_item_ ] ;
445
445
446
446
tag view_item_ {
447
- view_item_use( ident, vec[ @meta_item] , def_id , ann ) ;
448
- view_item_import ( ident, vec[ ident] , def_id ) ;
449
- view_item_import_glob ( vec[ ident] , def_id ) ;
450
- view_item_export ( ident) ;
447
+ view_item_use( ident, vec[ @meta_item] , node_id ) ;
448
+ view_item_import ( ident, vec[ ident] , node_id ) ;
449
+ view_item_import_glob ( vec[ ident] , node_id ) ;
450
+ view_item_export ( ident, node_id ) ;
451
451
}
452
452
453
- type obj_def_ids = rec ( def_id ty, def_id ctor) ;
453
+ type obj_def_ids = rec ( node_id ty, node_id ctor) ;
454
454
455
455
456
456
// Meta-data associated with an item
@@ -464,14 +464,11 @@ tag attr_style { attr_outer; attr_inner; }
464
464
465
465
type attribute_ = rec ( attr_style style, meta_item value) ;
466
466
467
- type item =
468
- rec ( ident ident,
469
- vec[ attribute] attrs ,
470
- def_id id, // For objs, this is the type def_id
471
-
472
- ann ann,
473
- item_ node,
474
- span span) ;
467
+ type item = rec ( ident ident,
468
+ vec[ attribute] attrs ,
469
+ node_id id, // For objs, this is the type's def_id
470
+ item_ node,
471
+ span span) ;
475
472
476
473
tag item_ {
477
474
item_const( @ty, @expr) ;
@@ -480,21 +477,18 @@ tag item_ {
480
477
item_native_mod ( native_mod) ;
481
478
item_ty ( @ty, vec[ ty_param] ) ;
482
479
item_tag ( vec[ variant] , vec[ ty_param] ) ;
483
- item_obj ( _obj, vec[ ty_param] , def_id) ;
484
- /* constructor id */
485
-
480
+ item_obj ( _obj, vec[ ty_param] , node_id /* constructor id */ ) ;
486
481
}
487
482
488
483
type native_item = spanned[ native_item_ ] ;
489
484
490
485
tag native_item_ {
491
- native_item_ty( ident, def_id ) ;
486
+ native_item_ty( ident, node_id ) ;
492
487
native_item_fn ( ident,
493
488
option:: t[ str] ,
494
489
fn_decl,
495
490
vec[ ty_param] ,
496
- def_id,
497
- ann) ;
491
+ node_id) ;
498
492
}
499
493
500
494
fn is_exported ( ident i, _mod m) -> bool {
@@ -514,7 +508,7 @@ fn is_exported(ident i, _mod m) -> bool {
514
508
auto count = 0 u;
515
509
for ( @ast:: view_item vi in m. view_items) {
516
510
alt ( vi. node ) {
517
- case ( ast:: view_item_export ( ?id) ) {
511
+ case ( ast:: view_item_export ( ?id, _ ) ) {
518
512
if ( str:: eq ( i, id) ) {
519
513
// even if it's nonlocal (since it's explicit)
520
514
0 commit comments