2
2
import util. common . option ;
3
3
import std. map . hashmap ;
4
4
import util. common . span ;
5
+ import util. common . spanned ;
5
6
import util. common . option ;
6
7
import util. common . some ;
7
8
import util. common . none ;
8
9
9
10
type ident = str ;
10
11
11
- type name = rec ( ident ident, vec[ ty] types ) ;
12
+ type name_ = rec ( ident ident, vec[ ty] types ) ;
13
+ type name = spanned[ name_ ] ;
12
14
type path = vec[ name ] ;
13
15
14
- type crate_id = int ;
15
- type slot_id = int ;
16
- type item_id = int ;
16
+ type crate_num = int ;
17
+ type slot_num = int ;
18
+ type item_num = int ;
17
19
18
- tag referent {
19
- ref_slot( crate_id, slot_id) ;
20
- ref_item ( crate_id, item_id) ;
20
+ tag slot_id {
21
+ id_slot( crate_num, slot_num) ;
22
+ }
23
+
24
+ tag item_id {
25
+ id_item( crate_num, slot_num) ;
21
26
}
22
27
28
+ tag referent {
29
+ ref_slot( slot_id) ;
30
+ ref_item ( item_id) ;
31
+ }
23
32
24
- type crate = rec ( _mod module ) ;
33
+ type crate = spanned[ crate_ ] ;
34
+ type crate_ = rec ( _mod module ) ;
25
35
26
- type block = vec [ @stmt] ;
36
+ type block = spanned[ block_ ] ;
37
+ type block_ = vec [ @stmt] ;
27
38
28
39
tag binop {
29
40
add;
@@ -55,19 +66,22 @@ tag unop {
55
66
neg;
56
67
}
57
68
58
- tag stmt {
69
+ type stmt = spanned[ stmt_ ] ;
70
+ tag stmt_ {
59
71
stmt_decl( @decl) ;
60
72
stmt_ret ( option[ @expr] ) ;
61
73
stmt_log ( @expr) ;
62
74
stmt_expr ( @expr) ;
63
75
}
64
76
65
- tag decl {
66
- decl_local( ident, option[ ty] ) ;
67
- decl_item ( ident, @item) ;
77
+ type decl = spanned[ decl_ ] ;
78
+ tag decl_ {
79
+ decl_local( ident, option[ ty] , ty) ;
80
+ decl_item ( name, @item) ;
68
81
}
69
82
70
- tag expr {
83
+ type expr = spanned[ expr_ ] ;
84
+ tag expr_ {
71
85
expr_vec( vec[ @expr] ) ;
72
86
expr_tup ( vec[ @expr] ) ;
73
87
expr_rec ( vec[ tup ( ident, @expr) ] ) ;
@@ -83,7 +97,8 @@ tag expr {
83
97
expr_block ( block) ;
84
98
}
85
99
86
- tag lit {
100
+ type lit = spanned[ lit_ ] ;
101
+ tag lit_ {
87
102
lit_str( str) ;
88
103
lit_char ( char) ;
89
104
lit_int ( int) ;
@@ -92,7 +107,8 @@ tag lit {
92
107
lit_bool ( bool) ;
93
108
}
94
109
95
- tag ty {
110
+ type ty = spanned[ ty_ ] ;
111
+ tag ty_ {
96
112
ty_nil;
97
113
ty_bool;
98
114
ty_int;
@@ -109,18 +125,19 @@ tag mode {
109
125
alias;
110
126
}
111
127
112
- type slot = rec ( ty ty, mode mode) ;
128
+ type slot = rec ( ty ty, mode mode, option [ slot_id ] id ) ;
113
129
114
130
type _fn = rec ( vec[ rec( slot slot, ident ident) ] inputs ,
115
131
slot output ,
116
132
block body) ;
117
133
118
134
type _mod = hashmap [ ident, item] ;
119
135
120
- tag item {
121
- item_fn( @_fn) ;
136
+ type item = spanned[ item_ ] ;
137
+ tag item_ {
138
+ item_fn( @_fn, item_id) ;
122
139
item_mod ( @_mod) ;
123
- item_ty ( @ty) ;
140
+ item_ty ( @ty, item_id ) ;
124
141
}
125
142
126
143
0 commit comments