Skip to content

Commit 296984c

Browse files
committed
---
yaml --- r: 1123 b: refs/heads/master c: e70c695 h: refs/heads/master i: 1121: 8feb741 1119: ab483a6 v: v3
1 parent 6a57e22 commit 296984c

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 194d7844ea653442a1e713ad9ff79c3ce43209ab
2+
refs/heads/master: e70c695ab9a910f4079088c439a2efbf5ab9c447

trunk/src/comp/middle/trans.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ fn type_of_fn(@crate_ctxt cx,
293293
auto ty_param_count = typeck.count_ty_params(fn_ty);
294294
auto i = 0u;
295295
while (i < ty_param_count) {
296-
atys += T_tydesc();
296+
atys += T_ptr(T_tydesc());
297297
i += 1u;
298298
}
299299

@@ -578,15 +578,28 @@ fn trans_malloc(@block_ctxt cx, @typeck.ty t) -> result {
578578
// returns an LLVM ValueRef of that field from the tydesc, generating the
579579
// tydesc if necessary.
580580
fn field_of_tydesc(@block_ctxt cx, @typeck.ty ty, int field) -> ValueRef {
581-
auto tydesc = get_tydesc(cx.fcx.ccx, ty);
581+
auto tydesc = get_tydesc(cx, ty);
582582
ret cx.build.GEP(tydesc, vec(C_int(0), C_int(field)));
583583
}
584584

585-
fn get_tydesc(@crate_ctxt cx, @typeck.ty ty) -> ValueRef {
586-
if (!cx.tydescs.contains_key(ty)) {
587-
make_tydesc(cx, ty);
585+
fn get_tydesc(&@block_ctxt cx, @typeck.ty ty) -> ValueRef {
586+
// Is the supplied type a type param? If so, return the passed-in tydesc.
587+
alt (typeck.type_param(ty)) {
588+
case (some[ast.def_id](?id)) { ret cx.fcx.lltydescs.get(id); }
589+
case (none[ast.def_id]) { /* fall through */ }
588590
}
589-
ret cx.tydescs.get(ty);
591+
592+
// Does it contain a type param? If so, generate a derived tydesc.
593+
if (typeck.count_ty_params(ty) > 0u) {
594+
log "TODO: trans.get_tydesc(): generate a derived type descriptor";
595+
fail;
596+
}
597+
598+
// Otherwise, generate a tydesc if necessary, and return it.
599+
if (!cx.fcx.ccx.tydescs.contains_key(ty)) {
600+
make_tydesc(cx.fcx.ccx, ty);
601+
}
602+
ret cx.fcx.ccx.tydescs.get(ty);
590603
}
591604

592605
fn make_tydesc(@crate_ctxt cx, @typeck.ty ty) {

trunk/src/comp/middle/typeck.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,14 @@ fn type_is_signed(@ty t) -> bool {
954954
fail;
955955
}
956956

957+
fn type_param(@ty t) -> option.t[ast.def_id] {
958+
alt (t.struct) {
959+
case (ty_param(?id)) { ret some[ast.def_id](id); }
960+
case (_) { /* fall through */ }
961+
}
962+
ret none[ast.def_id];
963+
}
964+
957965
fn plain_ty(&sty st) -> @ty {
958966
ret @rec(struct=st, mut=ast.imm, cname=none[str]);
959967
}

0 commit comments

Comments
 (0)