Skip to content

Commit a4694ce

Browse files
committed
Create a trans_impl module
1 parent 3a1710d commit a4694ce

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

src/comp/middle/trans.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
// but many TypeRefs correspond to one ty::t; for instance, tup(int, int,
1414
// int) and rec(x=int, y=int, z=int) will have the same TypeRef.
1515

16-
import core::{either, str, int, uint, option, vec};
1716
import std::{map, time};
1817
import std::map::hashmap;
1918
import std::map::{new_int_hash, new_str_hash};
@@ -4712,20 +4711,6 @@ fn trans_tag_variant(cx: @local_ctxt, tag_id: ast::node_id,
47124711
finish_fn(fcx, lltop);
47134712
}
47144713

4715-
fn trans_impl(cx: @local_ctxt, name: ast::ident, methods: [@ast::method],
4716-
id: ast::node_id, tps: [ast::ty_param]) {
4717-
let sub_cx = extend_path(cx, name);
4718-
for m in methods {
4719-
alt cx.ccx.item_ids.find(m.id) {
4720-
some(llfn) {
4721-
trans_fn(extend_path(sub_cx, m.ident), m.span, m.decl, m.body,
4722-
llfn, impl_self(ty::node_id_to_monotype(cx.ccx.tcx, id)),
4723-
tps + m.tps, m.id);
4724-
}
4725-
}
4726-
}
4727-
}
4728-
47294714

47304715
// FIXME: this should do some structural hash-consing to avoid
47314716
// duplicate constants. I think. Maybe LLVM has a magical mode
@@ -5026,7 +5011,7 @@ fn trans_item(cx: @local_ctxt, item: ast::item) {
50265011
trans_obj(sub_cx, item.span, ob, ctor_id, tps);
50275012
}
50285013
ast::item_impl(tps, _, _, ms) {
5029-
trans_impl(cx, item.ident, ms, item.id, tps);
5014+
trans_impl::trans_impl(cx, item.ident, ms, item.id, tps);
50305015
}
50315016
ast::item_res(decl, tps, body, dtor_id, ctor_id) {
50325017
trans_res_ctor(cx, item.span, decl, ctor_id, tps);

src/comp/middle/trans_impl.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import trans::*;
2+
import trans_common::*;
3+
import option::{some, none};
4+
import syntax::ast;
5+
6+
fn trans_impl(cx: @local_ctxt, name: ast::ident, methods: [@ast::method],
7+
id: ast::node_id, tps: [ast::ty_param]) {
8+
let sub_cx = extend_path(cx, name);
9+
for m in methods {
10+
alt cx.ccx.item_ids.find(m.id) {
11+
some(llfn) {
12+
trans_fn(extend_path(sub_cx, m.ident), m.span, m.decl, m.body,
13+
llfn, impl_self(ty::node_id_to_monotype(cx.ccx.tcx, id)),
14+
tps + m.tps, m.id);
15+
}
16+
}
17+
}
18+
}

src/comp/rustc.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ mod middle {
2222
mod trans_uniq;
2323
mod trans_closure;
2424
mod trans_vec;
25+
mod trans_impl;
2526
mod ty;
2627
mod ast_map;
2728
mod resolve;

0 commit comments

Comments
 (0)