Skip to content

Commit d1e59d6

Browse files
committed
Add input coordinate tracking to all major rustc ast nodes.
1 parent 4168c1d commit d1e59d6

File tree

4 files changed

+196
-83
lines changed

4 files changed

+196
-83
lines changed

src/comp/front/ast.rs

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,39 @@
22
import util.common.option;
33
import std.map.hashmap;
44
import util.common.span;
5+
import util.common.spanned;
56
import util.common.option;
67
import util.common.some;
78
import util.common.none;
89

910
type ident = str;
1011

11-
type name = rec(ident ident, vec[ty] types);
12+
type name_ = rec(ident ident, vec[ty] types);
13+
type name = spanned[name_];
1214
type path = vec[name];
1315

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;
1719

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);
2126
}
2227

28+
tag referent {
29+
ref_slot(slot_id);
30+
ref_item(item_id);
31+
}
2332

24-
type crate = rec(_mod module);
33+
type crate = spanned[crate_];
34+
type crate_ = rec(_mod module);
2535

26-
type block = vec[@stmt];
36+
type block = spanned[block_];
37+
type block_ = vec[@stmt];
2738

2839
tag binop {
2940
add;
@@ -55,19 +66,22 @@ tag unop {
5566
neg;
5667
}
5768

58-
tag stmt {
69+
type stmt = spanned[stmt_];
70+
tag stmt_ {
5971
stmt_decl(@decl);
6072
stmt_ret(option[@expr]);
6173
stmt_log(@expr);
6274
stmt_expr(@expr);
6375
}
6476

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);
6881
}
6982

70-
tag expr {
83+
type expr = spanned[expr_];
84+
tag expr_ {
7185
expr_vec(vec[@expr]);
7286
expr_tup(vec[@expr]);
7387
expr_rec(vec[tup(ident,@expr)]);
@@ -83,7 +97,8 @@ tag expr {
8397
expr_block(block);
8498
}
8599

86-
tag lit {
100+
type lit = spanned[lit_];
101+
tag lit_ {
87102
lit_str(str);
88103
lit_char(char);
89104
lit_int(int);
@@ -92,7 +107,8 @@ tag lit {
92107
lit_bool(bool);
93108
}
94109

95-
tag ty {
110+
type ty = spanned[ty_];
111+
tag ty_ {
96112
ty_nil;
97113
ty_bool;
98114
ty_int;
@@ -109,18 +125,19 @@ tag mode {
109125
alias;
110126
}
111127

112-
type slot = rec(ty ty, mode mode);
128+
type slot = rec(ty ty, mode mode, option[slot_id] id);
113129

114130
type _fn = rec(vec[rec(slot slot, ident ident)] inputs,
115131
slot output,
116132
block body);
117133

118134
type _mod = hashmap[ident,item];
119135

120-
tag item {
121-
item_fn(@_fn);
136+
type item = spanned[item_];
137+
tag item_ {
138+
item_fn(@_fn, item_id);
122139
item_mod(@_mod);
123-
item_ty(@ty);
140+
item_ty(@ty, item_id);
124141
}
125142

126143

0 commit comments

Comments
 (0)