Skip to content

Commit 1134fbf

Browse files
committed
---
yaml --- r: 1106 b: refs/heads/master c: bfdba2d h: refs/heads/master v: v3
1 parent 43f83e5 commit 1134fbf

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
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: 31f0642da3519985e69235be6cc30fc3f574ba95
2+
refs/heads/master: bfdba2dbcceb33e0738949e9f4d6635f689baf1b

trunk/src/comp/middle/trans.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,21 @@ fn T_task() -> TypeRef {
214214
));
215215
}
216216

217+
fn T_tydesc() -> TypeRef {
218+
auto pvoid = T_ptr(T_i8());
219+
auto glue_fn_ty = T_ptr(T_fn(vec(T_taskptr(), pvoid), T_void()));
220+
ret T_struct(vec(pvoid, // first_param
221+
T_int(), // size
222+
T_int(), // align
223+
glue_fn_ty, // copy_glue_off
224+
glue_fn_ty, // drop_glue_off
225+
glue_fn_ty, // free_glue_off
226+
glue_fn_ty, // sever_glue_off
227+
glue_fn_ty, // mark_glue_off
228+
glue_fn_ty, // obj_drop_glue_off
229+
glue_fn_ty)); // is_stateful
230+
}
231+
217232
fn T_array(TypeRef t, uint n) -> TypeRef {
218233
ret llvm.LLVMArrayType(t, n);
219234
}
@@ -271,6 +286,15 @@ fn type_of_fn(@crate_ctxt cx,
271286
vec[typeck.arg] inputs,
272287
@typeck.ty output) -> TypeRef {
273288
let vec[TypeRef] atys = vec(T_taskptr());
289+
290+
auto fn_ty = typeck.plain_ty(typeck.ty_fn(inputs, output));
291+
auto ty_param_count = typeck.count_ty_params(fn_ty);
292+
auto i = 0u;
293+
while (i < ty_param_count) {
294+
atys += T_tydesc();
295+
i += 1u;
296+
}
297+
274298
for (typeck.arg arg in inputs) {
275299
let TypeRef t = type_of(cx, arg.ty);
276300
alt (arg.mode) {
@@ -2614,6 +2638,7 @@ fn trans_exit_task_glue(@crate_ctxt cx) {
26142638
fn create_typedefs(@crate_ctxt cx) {
26152639
llvm.LLVMAddTypeName(cx.llmod, _str.buf("rust_crate"), T_crate());
26162640
llvm.LLVMAddTypeName(cx.llmod, _str.buf("rust_task"), T_task());
2641+
llvm.LLVMAddTypeName(cx.llmod, _str.buf("rust_tydesc"), T_tydesc());
26172642
}
26182643

26192644
fn crate_constant(@crate_ctxt cx) -> ValueRef {

trunk/src/comp/middle/typeck.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,33 @@ fn ann_to_type(&ast.ann ann) -> @ty {
942942
}
943943
}
944944

945+
fn count_ty_params(@ty t) -> uint {
946+
state obj ty_param_counter(@mutable vec[ast.def_id] param_ids) {
947+
fn fold_simple_ty(@ty t) -> @ty {
948+
alt (t.struct) {
949+
case (ty_param(?param_id)) {
950+
for (ast.def_id other_param_id in *param_ids) {
951+
if (param_id._0 == other_param_id._0 &&
952+
param_id._1 == other_param_id._1) {
953+
ret t;
954+
}
955+
}
956+
*param_ids += vec(param_id);
957+
}
958+
case (_) { /* fall through */ }
959+
}
960+
ret t;
961+
}
962+
}
963+
964+
let vec[ast.def_id] param_ids_inner = vec();
965+
let @mutable vec[ast.def_id] param_ids = @mutable param_ids_inner;
966+
fold_ty(ty_param_counter(param_ids), t);
967+
ret _vec.len[ast.def_id](*param_ids);
968+
}
969+
970+
// Type accessors for AST nodes
971+
945972
fn stmt_ty(@ast.stmt s) -> @ty {
946973
alt (s.node) {
947974
case (ast.stmt_expr(?e)) {

0 commit comments

Comments
 (0)