Skip to content

Commit 8affc78

Browse files
committed
Turn constants in back::abi into uints, and propagate types
This means GEPi now takes a list of uints. Apologies in advance if this is hard to rebase against, but it gets rid of many a cast :-) Also modernized some for loops here and there.
1 parent 2830bc3 commit 8affc78

File tree

9 files changed

+184
-199
lines changed

9 files changed

+184
-199
lines changed

src/rustc/back/abi.rs

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,54 @@
11

22

33

4-
// FIXME: Most of these should be uints.
5-
const rc_base_field_refcnt: int = 0;
4+
const rc_base_field_refcnt: uint = 0u;
65

7-
const task_field_refcnt: int = 0;
6+
const task_field_refcnt: uint = 0u;
87

9-
const task_field_stk: int = 2;
8+
const task_field_stk: uint = 2u;
109

11-
const task_field_runtime_sp: int = 3;
10+
const task_field_runtime_sp: uint = 3u;
1211

13-
const task_field_rust_sp: int = 4;
12+
const task_field_rust_sp: uint = 4u;
1413

15-
const task_field_gc_alloc_chain: int = 5;
14+
const task_field_gc_alloc_chain: uint = 5u;
1615

17-
const task_field_dom: int = 6;
16+
const task_field_dom: uint = 6u;
1817

19-
const n_visible_task_fields: int = 7;
18+
const n_visible_task_fields: uint = 7u;
2019

21-
const dom_field_interrupt_flag: int = 1;
20+
const dom_field_interrupt_flag: uint = 1u;
2221

23-
const frame_glue_fns_field_mark: int = 0;
22+
const frame_glue_fns_field_mark: uint = 0u;
2423

25-
const frame_glue_fns_field_drop: int = 1;
24+
const frame_glue_fns_field_drop: uint = 1u;
2625

27-
const frame_glue_fns_field_reloc: int = 2;
26+
const frame_glue_fns_field_reloc: uint = 2u;
2827

29-
const box_field_refcnt: int = 0;
30-
const box_field_tydesc: int = 1;
31-
const box_field_prev: int = 2;
32-
const box_field_next: int = 3;
33-
const box_field_body: int = 4;
28+
const box_field_refcnt: uint = 0u;
29+
const box_field_tydesc: uint = 1u;
30+
const box_field_prev: uint = 2u;
31+
const box_field_next: uint = 3u;
32+
const box_field_body: uint = 4u;
3433

35-
const general_code_alignment: int = 16;
34+
const general_code_alignment: uint = 16u;
3635

37-
const tydesc_field_first_param: int = 0;
38-
const tydesc_field_size: int = 1;
39-
const tydesc_field_align: int = 2;
40-
const tydesc_field_take_glue: int = 3;
41-
const tydesc_field_drop_glue: int = 4;
42-
const tydesc_field_free_glue: int = 5;
43-
const tydesc_field_unused: int = 6;
44-
const tydesc_field_sever_glue: int = 7;
45-
const tydesc_field_mark_glue: int = 8;
46-
const tydesc_field_unused2: int = 9;
47-
const tydesc_field_unused_2: int = 10;
48-
const tydesc_field_shape: int = 11;
49-
const tydesc_field_shape_tables: int = 12;
50-
const tydesc_field_n_params: int = 13;
51-
const tydesc_field_obj_params: int = 14; // FIXME unused
52-
const n_tydesc_fields: int = 15;
36+
const tydesc_field_first_param: uint = 0u;
37+
const tydesc_field_size: uint = 1u;
38+
const tydesc_field_align: uint = 2u;
39+
const tydesc_field_take_glue: uint = 3u;
40+
const tydesc_field_drop_glue: uint = 4u;
41+
const tydesc_field_free_glue: uint = 5u;
42+
const tydesc_field_unused: uint = 6u;
43+
const tydesc_field_sever_glue: uint = 7u;
44+
const tydesc_field_mark_glue: uint = 8u;
45+
const tydesc_field_unused2: uint = 9u;
46+
const tydesc_field_unused_2: uint = 10u;
47+
const tydesc_field_shape: uint = 11u;
48+
const tydesc_field_shape_tables: uint = 12u;
49+
const tydesc_field_n_params: uint = 13u;
50+
const tydesc_field_obj_params: uint = 14u; // FIXME unused (#2351)
51+
const n_tydesc_fields: uint = 15u;
5352

5453
const cmp_glue_op_eq: uint = 0u;
5554

@@ -58,23 +57,23 @@ const cmp_glue_op_lt: uint = 1u;
5857
const cmp_glue_op_le: uint = 2u;
5958

6059
// The two halves of a closure: code and environment.
61-
const fn_field_code: int = 0;
62-
const fn_field_box: int = 1;
60+
const fn_field_code: uint = 0u;
61+
const fn_field_box: uint = 1u;
6362

6463
// closures, see trans_closure.rs
65-
const closure_body_ty_params: int = 0;
66-
const closure_body_bindings: int = 1;
64+
const closure_body_ty_params: uint = 0u;
65+
const closure_body_bindings: uint = 1u;
6766

68-
const vec_elt_fill: int = 0;
67+
const vec_elt_fill: uint = 0u;
6968

70-
const vec_elt_alloc: int = 1;
69+
const vec_elt_alloc: uint = 1u;
7170

72-
const vec_elt_elems: int = 2;
71+
const vec_elt_elems: uint = 2u;
7372

74-
const slice_elt_base: int = 0;
75-
const slice_elt_len: int = 1;
73+
const slice_elt_base: uint = 0u;
74+
const slice_elt_len: uint = 1u;
7675

77-
const worst_case_glue_call_args: int = 7;
76+
const worst_case_glue_call_args: uint = 7u;
7877

7978
const abi_version: uint = 1u;
8079

src/rustc/middle/trans/alt.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ fn extract_variant_args(bcx: block, pat_id: ast::node_id,
274274
if size > 0u && (*variants).len() != 1u {
275275
let enumptr =
276276
PointerCast(bcx, val, T_opaque_enum_ptr(ccx));
277-
blobptr = GEPi(bcx, enumptr, [0, 1]);
277+
blobptr = GEPi(bcx, enumptr, [0u, 1u]);
278278
}
279279
let vdefs_tg = vdefs.enm;
280280
let vdefs_var = vdefs.var;
@@ -410,7 +410,7 @@ fn compile_submatch(bcx: block, m: match, vals: [ValueRef],
410410
let mut rec_vals = [];
411411
for vec::each(rec_fields) {|field_name|
412412
let ix = option::get(ty::field_idx(field_name, fields));
413-
rec_vals += [GEPi(bcx, val, [0, ix as int])];
413+
rec_vals += [GEPi(bcx, val, [0u, ix])];
414414
}
415415
compile_submatch(bcx, enter_rec(dm, m, col, rec_fields, val),
416416
rec_vals + vals_left, chk, exits);
@@ -425,7 +425,7 @@ fn compile_submatch(bcx: block, m: match, vals: [ValueRef],
425425
};
426426
let mut tup_vals = [], i = 0u;
427427
while i < n_tup_elts {
428-
tup_vals += [GEPi(bcx, val, [0, i as int])];
428+
tup_vals += [GEPi(bcx, val, [0u, i])];
429429
i += 1u;
430430
}
431431
compile_submatch(bcx, enter_tup(dm, m, col, val, n_tup_elts),
@@ -436,7 +436,7 @@ fn compile_submatch(bcx: block, m: match, vals: [ValueRef],
436436
// Unbox in case of a box field
437437
if any_box_pat(m, col) {
438438
let box = Load(bcx, val);
439-
let unboxed = GEPi(bcx, box, [0, abi::box_field_body]);
439+
let unboxed = GEPi(bcx, box, [0u, abi::box_field_body]);
440440
compile_submatch(bcx, enter_box(dm, m, col, val), [unboxed]
441441
+ vals_left, chk, exits);
442442
ret;
@@ -462,7 +462,7 @@ fn compile_submatch(bcx: block, m: match, vals: [ValueRef],
462462
} else {
463463
let enumptr =
464464
PointerCast(bcx, val, T_opaque_enum_ptr(ccx));
465-
let discrimptr = GEPi(bcx, enumptr, [0, 0]);
465+
let discrimptr = GEPi(bcx, enumptr, [0u, 0u]);
466466
test_val = Load(bcx, discrimptr);
467467
kind = switch;
468468
}
@@ -711,22 +711,22 @@ fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef,
711711
let rec_fields = ty::get_fields(node_id_type(bcx, pat.id));
712712
for vec::each(fields) {|f|
713713
let ix = option::get(ty::field_idx(f.ident, rec_fields));
714-
let fldptr = GEPi(bcx, val, [0, ix as int]);
714+
let fldptr = GEPi(bcx, val, [0u, ix]);
715715
bcx = bind_irrefutable_pat(bcx, f.pat, fldptr, make_copy);
716716
}
717717
}
718718
ast::pat_tup(elems) {
719719
let mut i = 0u;
720720
for vec::each(elems) {|elem|
721-
let fldptr = GEPi(bcx, val, [0, i as int]);
721+
let fldptr = GEPi(bcx, val, [0u, i]);
722722
bcx = bind_irrefutable_pat(bcx, elem, fldptr, make_copy);
723723
i += 1u;
724724
}
725725
}
726726
ast::pat_box(inner) {
727727
let box = Load(bcx, val);
728728
let unboxed =
729-
GEPi(bcx, box, [0, abi::box_field_body]);
729+
GEPi(bcx, box, [0u, abi::box_field_body]);
730730
bcx = bind_irrefutable_pat(bcx, inner, unboxed, true);
731731
}
732732
ast::pat_uniq(inner) {

0 commit comments

Comments
 (0)