Skip to content

Commit a3f828f

Browse files
committed
Sketch trans_vtbl.
1 parent bfdba2d commit a3f828f

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/comp/front/ast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,10 @@ type _fn = rec(effect effect,
199199
block body);
200200

201201

202-
type method_ = rec(ident ident, _fn meth, def_id id);
202+
type method_ = rec(ident ident, _fn meth, def_id id, ann ann);
203203
type method = spanned[method_];
204204

205-
type obj_field = rec(@ty ty, ident ident, def_id id);
205+
type obj_field = rec(@ty ty, ident ident, def_id id, ann ann);
206206
type _obj = rec(vec[obj_field] fields,
207207
vec[@method] methods);
208208

src/comp/front/parser.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,7 @@ impure fn parse_item_fn(parser p, ast.effect eff) -> @ast.item {
12851285
impure fn parse_obj_field(parser p) -> ast.obj_field {
12861286
auto ty = parse_ty(p);
12871287
auto ident = parse_ident(p);
1288-
ret rec(ty=ty, ident=ident, id=p.next_def_id());
1288+
ret rec(ty=ty, ident=ident, id=p.next_def_id(), ann=ast.ann_none);
12891289
}
12901290

12911291
impure fn parse_method(parser p) -> @ast.method {
@@ -1294,7 +1294,8 @@ impure fn parse_method(parser p) -> @ast.method {
12941294
expect(p, token.FN);
12951295
auto ident = parse_ident(p);
12961296
auto f = parse_fn(p, eff);
1297-
auto meth = rec(ident = ident, meth = f, id = p.next_def_id());
1297+
auto meth = rec(ident=ident, meth=f,
1298+
id=p.next_def_id(), ann=ast.ann_none);
12981299
ret @spanned(lo, f.body.span, meth);
12991300
}
13001301

src/comp/middle/trans.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2307,6 +2307,15 @@ impure fn trans_fn(@crate_ctxt cx, &ast._fn f, ast.def_id fid,
23072307
}
23082308
}
23092309

2310+
impure fn trans_vtbl(@crate_ctxt cx, &ast._obj ob) -> ValueRef {
2311+
let vec[ValueRef] methods = vec();
2312+
for (@ast.method m in ob.methods) {
2313+
trans_fn(cx, m.node.meth, m.node.id, m.node.ann);
2314+
methods += cx.item_ids.get(m.node.id);
2315+
}
2316+
ret C_struct(methods);
2317+
}
2318+
23102319
fn trans_obj(@crate_ctxt cx, &ast._obj ob, ast.def_id oid,
23112320
&ast.ann ann) {
23122321

0 commit comments

Comments
 (0)