Skip to content

Commit 23bae67

Browse files
committed
Simplify arguments to trans_anon_obj and friends.
1 parent bc5d6ae commit 23bae67

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

src/comp/middle/trans.rs

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6268,8 +6268,8 @@ fn trans_expr_out(&@block_ctxt cx, &@ast::expr e, out_method output) ->
62686268
case (ast::expr_spawn(?dom, ?name, ?func, ?args)) {
62696269
ret trans_spawn(cx, dom, name, func, args, e.id);
62706270
}
6271-
case (ast::expr_anon_obj(?anon_obj, ?tps, ?odid)) {
6272-
ret trans_anon_obj(cx, e.span, anon_obj, tps, odid.ctor, e.id);
6271+
case (ast::expr_anon_obj(?anon_obj, ?tps, _)) {
6272+
ret trans_anon_obj(cx, e.span, anon_obj, tps, e.id);
62736273
}
62746274
case (_) {
62756275
// The expression is an lvalue. Fall through.
@@ -6929,8 +6929,7 @@ fn recv_val(&@block_ctxt cx, ValueRef to, &@ast::expr from, &ty::t unit_ty,
69296929
// instead "inlining" the construction of the object and returning the object
69306930
// itself.
69316931
fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
6932-
&vec[ast::ty_param] ty_params, ast::node_id oid,
6933-
ast::node_id type_id) -> result {
6932+
&vec[ast::ty_param] ty_params, ast::node_id id) -> result {
69346933

69356934
// Right now, we're assuming that anon objs don't take ty params, even
69366935
// though the AST supports it. It's nonsensical to write an expression
@@ -6960,7 +6959,7 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
69606959

69616960
// Get the type of the eventual entire anonymous object, possibly with
69626961
// extensions. NB: This type includes both inner and outer methods.
6963-
auto outer_obj_ty = ty::node_id_to_type(ccx.tcx, type_id);
6962+
auto outer_obj_ty = ty::node_id_to_type(ccx.tcx, id);
69646963
auto llouter_obj_ty = type_of(ccx, sp, outer_obj_ty);
69656964

69666965
// Create a vtable for the anonymous object.
@@ -6979,7 +6978,6 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
69796978

69806979
let result with_obj_val;
69816980
let ty::t with_obj_ty;
6982-
let TypeRef llwith_obj_ty;
69836981
auto vtbl;
69846982
alt (anon_obj.with_obj) {
69856983
case (none) {
@@ -7012,8 +7010,6 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
70127010
with_obj_ty = ty::expr_ty(ccx.tcx, e);
70137011
//with_obj_ty = ty::node_id_to_type(ccx.tcx, e.id);
70147012

7015-
llwith_obj_ty = type_of(ccx, sp, with_obj_ty);
7016-
70177013
// If there's a with_obj, we pass its type along to create_vtbl().
70187014
// Part of what create_vtbl() will do is take the set difference
70197015
// of methods defined on the original and methods being added.
@@ -7023,7 +7019,7 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
70237019
// normal vtable entry for every method being added.
70247020
vtbl = create_vtbl(bcx.fcx.lcx, llouter_obj_ty, outer_obj_ty,
70257021
wrapper_obj, ty_params,
7026-
some(tup(with_obj_ty, llwith_obj_ty)),
7022+
some(with_obj_ty),
70277023
additional_field_tys);
70287024
}
70297025
}
@@ -7037,7 +7033,7 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
70377033
vec::len[ast::ty_param](ty_params))]));
70387034

70397035
// Take care of cleanups.
7040-
auto t = node_id_type(ccx, type_id);
7036+
auto t = node_id_type(ccx, id);
70417037
find_scope_cx(bcx).cleanups += [clean(bind drop_ty(_, pair, t))];
70427038

70437039
// Grab onto the first and second elements of the pair.
@@ -7800,7 +7796,7 @@ fn trans_fn(@local_ctxt cx, &span sp, &ast::_fn f, ValueRef llfndecl,
78007796
// helper function for create_vtbl.
78017797
fn process_fwding_mthd(@local_ctxt cx, @ty::method m, TypeRef llself_ty,
78027798
ty::t self_ty, &vec[ast::ty_param] ty_params,
7803-
tup(ty::t, TypeRef) with_obj_ty_tup,
7799+
ty::t with_obj_ty,
78047800
ty::t[] additional_field_tys) -> ValueRef {
78057801

78067802
// NB: self_ty (and llself_ty) is the type of the outer object;
@@ -7816,10 +7812,6 @@ fn process_fwding_mthd(@local_ctxt cx, @ty::method m, TypeRef llself_ty,
78167812
// on. That object won't exist until run-time, but we know its type
78177813
// statically.
78187814

7819-
// Unpack the tuple.
7820-
let ty::t with_obj_ty = with_obj_ty_tup._0;
7821-
// TODO: We don't actually need both halves of this.
7822-
78237815
// Create a fake span for functions that expect it. Shouldn't matter what
78247816
// it is, since this isn't user-written code. (Possibly better: have
78257817
// create_vtable take a span argument and pass it in here?)
@@ -8024,7 +8016,7 @@ fn process_normal_mthd(@local_ctxt cx, @ast::method m, TypeRef llself_ty,
80248016
// read-only memory.
80258017
fn create_vtbl(@local_ctxt cx, TypeRef llself_ty, ty::t self_ty,
80268018
&ast::_obj ob, &vec[ast::ty_param] ty_params,
8027-
option::t[tup(ty::t, TypeRef)] with_obj_ty_tup,
8019+
option::t[ty::t] with_obj_ty,
80288020
ty::t[] additional_field_tys) -> ValueRef {
80298021

80308022
// Used only inside create_vtbl to distinguish different kinds of slots
@@ -8048,15 +8040,15 @@ fn create_vtbl(@local_ctxt cx, TypeRef llself_ty, ty::t self_ty,
80488040
let vec[ValueRef] llmethods = [dtor];
80498041
let vec[vtbl_mthd] meths = [];
80508042

8051-
alt (with_obj_ty_tup) {
8043+
alt (with_obj_ty) {
80528044
case (none) {
80538045
// If there's no with_obj, then we don't need any forwarding
80548046
// slots. Just use the object's regular methods.
80558047
for (@ast::method m in ob.methods) {
80568048
meths += [normal_mthd(m)];
80578049
}
80588050
}
8059-
case (some(?with_obj_ty_tup)) {
8051+
case (some(?with_obj_ty)) {
80608052
// Handle forwarding slots.
80618053

80628054
// If this vtable is being created for an extended object, then
@@ -8074,7 +8066,7 @@ fn create_vtbl(@local_ctxt cx, TypeRef llself_ty, ty::t self_ty,
80748066
// methods we need forwarding methods for.
80758067

80768068
// Gather up methods on the original object in 'meths'.
8077-
alt (ty::struct(cx.ccx.tcx, with_obj_ty_tup._0)) {
8069+
alt (ty::struct(cx.ccx.tcx, with_obj_ty)) {
80788070
case (ty::ty_obj(?with_obj_methods)) {
80798071
for (ty::method m in with_obj_methods) {
80808072
meths += [fwding_mthd(@m)];
@@ -8156,11 +8148,11 @@ fn create_vtbl(@local_ctxt cx, TypeRef llself_ty, ty::t self_ty,
81568148
// If we have to process a forwarding method, then we need to know
81578149
// about the with_obj's type as well as the outer object's type.
81588150
case (fwding_mthd(?fm)) {
8159-
alt (with_obj_ty_tup) {
8151+
alt (with_obj_ty) {
81608152
case (none) {
81618153
// This shouldn't happen; if we're trying to process a
81628154
// forwarding method, then we should always have a
8163-
// with_obj_ty_tup.
8155+
// with_obj_ty.
81648156
cx.ccx.sess.bug("create_vtbl(): trying to create "
81658157
+ "forwarding method without a type "
81668158
+ "of object to forward to");

0 commit comments

Comments
 (0)