Skip to content

Commit 24102d5

Browse files
committed
Obj system? What obj system?
Removes the obj system from the compiler. Closes #1484
1 parent eb07fa4 commit 24102d5

30 files changed

+139
-2020
lines changed

src/comp/back/abi.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const tydesc_field_cmp_glue: int = 10;
4646
const tydesc_field_shape: int = 11;
4747
const tydesc_field_shape_tables: int = 12;
4848
const tydesc_field_n_params: int = 13;
49-
const tydesc_field_obj_params: int = 14;
49+
const tydesc_field_obj_params: int = 14; // FIXME unused
5050
const n_tydesc_fields: int = 15;
5151

5252
const cmp_glue_op_eq: uint = 0u;
@@ -55,19 +55,6 @@ const cmp_glue_op_lt: uint = 1u;
5555

5656
const cmp_glue_op_le: uint = 2u;
5757

58-
const obj_field_vtbl: int = 0;
59-
60-
const obj_field_box: int = 1;
61-
62-
const obj_body_elt_tydesc: int = 0;
63-
64-
const obj_body_elt_typarams: int = 1;
65-
66-
const obj_body_elt_fields: int = 2;
67-
68-
// The base object to which an anonymous object is attached.
69-
const obj_body_elt_inner_obj: int = 3;
70-
7158
// The two halves of a closure: code and environment.
7259
const fn_field_code: int = 0;
7360
const fn_field_box: int = 1;

src/comp/metadata/encoder.rs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,6 @@ fn encode_module_item_paths(ebml_w: ebml::writer, module: _mod, path: [str],
126126
ebml::end_tag(ebml_w);
127127
encode_tag_variant_paths(ebml_w, variants, path, index);
128128
}
129-
item_obj(_, tps, ctor_id) {
130-
add_to_index(ebml_w, path, index, it.ident);
131-
ebml::start_tag(ebml_w, tag_paths_data_item);
132-
encode_name(ebml_w, it.ident);
133-
encode_def_id(ebml_w, local_def(ctor_id));
134-
ebml::end_tag(ebml_w);
135-
add_to_index(ebml_w, path, index, it.ident);
136-
ebml::start_tag(ebml_w, tag_paths_data_item);
137-
encode_name(ebml_w, it.ident);
138-
encode_def_id(ebml_w, local_def(it.id));
139-
ebml::end_tag(ebml_w);
140-
}
141129
item_iface(_, _) {
142130
add_to_index(ebml_w, path, index, it.ident);
143131
ebml::start_tag(ebml_w, tag_paths_data_item);
@@ -366,26 +354,6 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
366354
encode_symbol(ecx, ebml_w, ctor_id);
367355
ebml::end_tag(ebml_w);
368356
}
369-
item_obj(_, tps, ctor_id) {
370-
let fn_ty = node_id_to_monotype(tcx, ctor_id);
371-
372-
ebml::start_tag(ebml_w, tag_items_data_item);
373-
encode_def_id(ebml_w, local_def(item.id));
374-
encode_family(ebml_w, 'y' as u8);
375-
encode_type_param_bounds(ebml_w, ecx, tps);
376-
encode_type(ecx, ebml_w, ty::ty_fn_ret(tcx, fn_ty));
377-
encode_name(ebml_w, item.ident);
378-
ebml::end_tag(ebml_w);
379-
380-
index += [{val: ctor_id, pos: ebml_w.writer.tell()}];
381-
ebml::start_tag(ebml_w, tag_items_data_item);
382-
encode_def_id(ebml_w, local_def(ctor_id));
383-
encode_family(ebml_w, 'f' as u8);
384-
encode_type_param_bounds(ebml_w, ecx, tps);
385-
encode_type(ecx, ebml_w, fn_ty);
386-
encode_symbol(ecx, ebml_w, ctor_id);
387-
ebml::end_tag(ebml_w);
388-
}
389357
item_impl(tps, ifce, _, methods) {
390358
ebml::start_tag(ebml_w, tag_items_data_item);
391359
encode_def_id(ebml_w, local_def(item.id));

src/comp/metadata/tydecode.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -246,24 +246,6 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
246246
let func = parse_ty_fn(st, conv);
247247
ret ty::mk_native_fn(st.tcx, func.inputs, func.output);
248248
}
249-
'O' {
250-
assert (next(st) as char == '[');
251-
let methods: [ty::method] = [];
252-
while peek(st) as char != ']' {
253-
let proto;
254-
alt next(st) as char {
255-
'f' { proto = ast::proto_bare; }
256-
}
257-
let name = "";
258-
while peek(st) as char != '[' {
259-
name += str::unsafe_from_byte(next(st));
260-
}
261-
methods += [{ident: name, tps: @[],
262-
fty: {proto: proto with parse_ty_fn(st, conv)}}];
263-
}
264-
st.pos += 1u;
265-
ret ty::mk_obj(st.tcx, methods);
266-
}
267249
'r' {
268250
assert (next(st) as char == '[');
269251
let def = parse_def(st, conv);

src/comp/metadata/tyencode.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,6 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
157157
enc_ty_fn(w, cx, {proto: proto_bare, inputs: args, output: out,
158158
ret_style: return_val, constraints: []});
159159
}
160-
ty::ty_obj(methods) {
161-
w.write_str("O[");
162-
for m: ty::method in methods {
163-
enc_proto(w, m.fty.proto);
164-
w.write_str(m.ident);
165-
enc_ty_fn(w, cx, m.fty);
166-
}
167-
w.write_char(']');
168-
}
169160
ty::ty_res(def, ty, tps) {
170161
w.write_str("r[");
171162
w.write_str(cx.ds(def));

src/comp/middle/alias.rs

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ type ctx = {tcx: ty::ctxt,
5656
mutable silent: bool};
5757

5858
fn check_crate(tcx: ty::ctxt, crate: @ast::crate) -> (copy_map, ref_map) {
59-
// Stores information about object fields and function
60-
// arguments that's otherwise not easily available.
59+
// Stores information about function arguments that's otherwise not easily
60+
// available.
6161
let cx = @{tcx: tcx,
6262
copy_map: std::map::new_int_hash(),
6363
ref_map: std::map::new_int_hash(),
@@ -521,7 +521,7 @@ fn ty_can_unsafely_include(cx: ctx, needle: unsafe_ty, haystack: ty::t,
521521
}
522522
ty::ty_fn({proto: ast::proto_bare., _}) { ret false; }
523523
// These may contain anything.
524-
ty::ty_fn(_) | ty::ty_obj(_) { ret true; }
524+
ty::ty_fn(_) | ty::ty_iface(_, _) { ret true; }
525525
// A type param may include everything, but can only be
526526
// treated as opaque downstream, and is thus safe unless we
527527
// saw mutable fields, in which case the whole thing can be
@@ -536,8 +536,7 @@ fn ty_can_unsafely_include(cx: ctx, needle: unsafe_ty, haystack: ty::t,
536536
fn def_is_local(d: ast::def) -> bool {
537537
alt d {
538538
ast::def_local(_, _) | ast::def_arg(_, _) | ast::def_binding(_) |
539-
ast::def_upvar(_, _, _) | ast::def_self(_) |
540-
ast::def_obj_field(_, _) { true }
539+
ast::def_upvar(_, _, _) | ast::def_self(_) { true }
541540
_ { false }
542541
}
543542
}
@@ -557,10 +556,9 @@ fn copy_is_expensive(tcx: ty::ctxt, ty: ty::t) -> bool {
557556
ty::ty_nil. | ty::ty_bot. | ty::ty_bool. | ty::ty_int(_) |
558557
ty::ty_uint(_) | ty::ty_float(_) | ty::ty_type. | ty::ty_native(_) |
559558
ty::ty_ptr(_) { 1u }
560-
ty::ty_box(_) { 3u }
559+
ty::ty_box(_) | ty::ty_iface(_, _) { 3u }
561560
ty::ty_constr(t, _) | ty::ty_res(_, t, _) { score_ty(tcx, t) }
562-
ty::ty_fn(_) | ty::ty_native_fn(_, _) |
563-
ty::ty_obj(_) { 4u }
561+
ty::ty_fn(_) | ty::ty_native_fn(_, _) { 4u }
564562
ty::ty_str. | ty::ty_vec(_) | ty::ty_param(_, _) { 50u }
565563
ty::ty_uniq(mt) { 1u + score_ty(tcx, mt.ty) }
566564
ty::ty_tag(_, ts) | ty::ty_tup(ts) {
@@ -633,17 +631,6 @@ fn expr_root(cx: ctx, ex: @ast::expr, autoderef: bool)
633631
for d in *base_root.ds {
634632
if d.mut { unsafe_ty = some(contains(d.outer_t)); break; }
635633
}
636-
alt base_root.ex.node {
637-
ast::expr_path(_) {
638-
alt cx.tcx.def_map.get(base_root.ex.id) {
639-
ast::def_obj_field(_, ast::mut.) {
640-
unsafe_ty = some(mut_contains(ty::expr_ty(cx.tcx, base_root.ex)));
641-
}
642-
_ {}
643-
}
644-
}
645-
_ {}
646-
}
647634
ret {ex: base_root.ex, mut: unsafe_ty};
648635
}
649636

src/comp/middle/ast_map.rs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import syntax::{visit, codemap};
66

77
tag ast_node {
88
node_item(@item);
9-
node_obj_ctor(@item);
10-
node_obj_method(@method);
119
node_native_item(@native_item);
1210
node_method(@method);
1311
node_expr(@expr);
@@ -62,12 +60,6 @@ fn map_arm(cx: ctx, arm: arm) {
6260
fn map_item(cx: ctx, i: @item) {
6361
cx.map.insert(i.id, node_item(i));
6462
alt i.node {
65-
item_obj(ob, _, ctor_id) {
66-
cx.map.insert(ctor_id, node_obj_ctor(i));
67-
for m in ob.methods {
68-
cx.map.insert(m.id, node_obj_method(m));
69-
}
70-
}
7163
item_impl(_, _, _, ms) {
7264
for m in ms { cx.map.insert(m.id, node_method(m)); }
7365
}
@@ -85,20 +77,11 @@ fn map_native_item(cx: ctx, i: @native_item) {
8577

8678
fn map_expr(cx: ctx, ex: @expr) {
8779
cx.map.insert(ex.id, node_expr(ex));
88-
alt ex.node {
89-
expr_anon_obj(ao) {
90-
for m in ao.methods {
91-
cx.map.insert(m.id, node_obj_method(m));
92-
}
93-
}
94-
_ {}
95-
}
9680
}
9781

9882
fn node_span(node: ast_node) -> codemap::span {
9983
alt node {
10084
node_item(item) { item.span }
101-
node_obj_ctor(item) { item.span }
10285
node_native_item(nitem) { nitem.span }
10386
node_expr(expr) { expr.span }
10487
}
@@ -120,18 +103,6 @@ mod test {
120103
assert (node_span(node) == expected);
121104
}
122105

123-
#[test]
124-
fn test_node_span_obj_ctor() {
125-
let expected: codemap::span = ast_util::mk_sp(20u, 30u);
126-
let node =
127-
node_obj_ctor(@{ident: "test",
128-
attrs: [],
129-
id: 0,
130-
node: item_mod({view_items: [], items: []}),
131-
span: expected});
132-
assert (node_span(node) == expected);
133-
}
134-
135106
#[test]
136107
fn test_node_span_native_item() {
137108
let expected: codemap::span = ast_util::mk_sp(20u, 30u);

src/comp/middle/debuginfo.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -727,9 +727,6 @@ fn create_function(fcx: @fn_ctxt) -> @metadata<subprogram_md> {
727727
}
728728
}
729729
}
730-
ast_map::node_obj_method(method) | ast_map::node_method(method) {
731-
(method.ident, method.decl.output, method.id)
732-
}
733730
ast_map::node_res_ctor(item) {
734731
alt item.node { ast::item_res(decl, _, _, _, ctor_id) {
735732
(item.ident, decl.output, ctor_id)

src/comp/middle/gc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import lib::llvm::True;
44
import lib::llvm::llvm::ValueRef;
55
import middle::trans;
6-
import middle::trans::{get_tydesc, tps_normal};
6+
import middle::trans::get_tydesc;
77
import middle::trans_common::*;
88
import middle::ty;
99
import option::none;
@@ -43,7 +43,7 @@ fn add_gc_root(cx: @block_ctxt, llval: ValueRef, ty: ty::t) -> @block_ctxt {
4343
bcx = trans::zero_alloca(bcx, llval, ty);
4444

4545
let ti = none;
46-
let td_r = get_tydesc(bcx, ty, false, tps_normal, ti);
46+
let td_r = get_tydesc(bcx, ty, false, ti);
4747
bcx = td_r.result.bcx;
4848
let lltydesc = td_r.result.val;
4949

@@ -147,7 +147,7 @@ fn type_is_gc_relevant(cx: ty::ctxt, ty: ty::t) -> bool {
147147
}
148148
ty::ty_constr(sub, _) { ret type_is_gc_relevant(cx, sub); }
149149
ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_fn(_) |
150-
ty::ty_native_fn(_, _) | ty::ty_obj(_) | ty::ty_param(_, _) |
150+
ty::ty_native_fn(_, _) | ty::ty_param(_, _) |
151151
ty::ty_res(_, _, _) { ret true; }
152152
ty::ty_var(_) {
153153
fail "ty_var in type_is_gc_relevant";

src/comp/middle/kind.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import driver::session::session;
88
// Kind analysis pass. There are three kinds:
99
//
1010
// sendable: scalar types, and unique types containing only sendable types
11-
// copyable: boxes, objects, closures, and uniques containing copyable types
11+
// copyable: boxes, closures, and uniques containing copyable types
1212
// noncopyable: resources, or unique types containing resources
1313
//
1414
// This pass ensures that type parameters are only instantiated with types
@@ -218,7 +218,7 @@ fn maybe_copy(cx: ctx, ex: @expr) {
218218
}
219219

220220
fn check_copy_ex(cx: ctx, ex: @expr, _warn: bool) {
221-
if ty::expr_is_lval(cx.method_map, cx.tcx, ex) &&
221+
if ty::expr_is_lval(cx.method_map, ex) &&
222222
!cx.last_uses.contains_key(ex.id) {
223223
let ty = ty::expr_ty(cx.tcx, ex);
224224
check_copy(cx, ty, ex.span);

src/comp/middle/mut.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fn expr_root(tcx: ty::ctxt, ex: @expr, autoderef: bool) ->
6060
}
6161
}
6262
}
63-
ty::ty_obj(_) { }
63+
_ {}
6464
}
6565
ds += [@{mut: is_mut, kind: field, outer_t: auto_unbox.t}];
6666
ds += auto_unbox.ds;
@@ -201,9 +201,6 @@ fn check_move_rhs(cx: @ctx, src: @expr) {
201201
alt src.node {
202202
expr_path(p) {
203203
alt cx.tcx.def_map.get(src.id) {
204-
def_obj_field(_, _) {
205-
mk_err(cx, src.span, msg_move_out, "object field");
206-
}
207204
def_self(_) {
208205
mk_err(cx, src.span, msg_move_out, "method self");
209206
}
@@ -267,7 +264,6 @@ fn is_immutable_def(cx: @ctx, def: def) -> option::t<str> {
267264
}
268265
def_arg(_, by_ref.) | def_arg(_, by_val.) |
269266
def_arg(_, mode_infer.) { some("argument") }
270-
def_obj_field(_, imm.) { some("immutable object field") }
271267
def_self(_) { some("self argument") }
272268
def_upvar(_, inner, node_id) {
273269
let ty = ty::node_id_to_monotype(cx.tcx, node_id);

0 commit comments

Comments
 (0)