Skip to content

Commit 57067a4

Browse files
committed
---
yaml --- r: 2223 b: refs/heads/master c: d0ed2e3 h: refs/heads/master i: 2221: d455986 2219: 5a431b2 2215: d6dfdc1 2207: 941d27a v: v3
1 parent 403b8f1 commit 57067a4

File tree

3 files changed

+32
-39
lines changed

3 files changed

+32
-39
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: 418b23a5389482c2889c5c01f7f31ba5061c5bc5
2+
refs/heads/master: d0ed2e384a3b90394ca0f160e21a4948a1dbccb0

trunk/src/comp/middle/trans.rs

Lines changed: 25 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,7 @@ fn dynamic_size_of(@block_ctxt cx, ty.t t) -> result {
12281228
auto elt_size = size_of(bcx, e);
12291229
bcx = elt_size.bcx;
12301230
auto aligned_off = align_to(bcx, off, elt_align.val);
1231-
off = bcx.build.Add(aligned_off, elt_size.val);
1231+
off = cx.build.Add(aligned_off, elt_size.val);
12321232
max_align = umax(bcx, max_align, elt_align.val);
12331233
}
12341234
off = align_to(bcx, off, max_align);
@@ -1488,7 +1488,7 @@ fn trans_raw_malloc(@block_ctxt cx, TypeRef llptr_ty, ValueRef llsize)
14881488
// FIXME: need a table to collect tydesc globals.
14891489
auto tydesc = C_int(0);
14901490
auto rslt = trans_upcall(cx, "upcall_malloc", vec(llsize, tydesc));
1491-
rslt = res(rslt.bcx, vi2p(rslt.bcx, rslt.val, llptr_ty));
1491+
rslt = res(rslt.bcx, vi2p(cx, rslt.val, llptr_ty));
14921492
ret rslt;
14931493
}
14941494

@@ -1949,8 +1949,6 @@ fn make_drop_glue(@block_ctxt cx, ValueRef v0, ty.t t) {
19491949
ty.type_is_native(cx.fcx.lcx.ccx.tcx, t) ||
19501950
ty.type_is_nil(cx.fcx.lcx.ccx.tcx, t)) {
19511951
rslt = res(cx, C_nil());
1952-
} else {
1953-
rslt = res(cx, C_nil());
19541952
}
19551953
}
19561954
}
@@ -2358,7 +2356,7 @@ fn iter_structural_ty_full(@block_ctxt cx,
23582356

23592357
auto r = f(inner_cx, box_a_ptr, box_b_ptr, tbox);
23602358
r.bcx.build.Br(next_cx.llbb);
2361-
ret res(next_cx, C_nil());
2359+
ret res(next_cx, r.val);
23622360
}
23632361

23642362
alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
@@ -2628,7 +2626,7 @@ fn iter_sequence(@block_ctxt cx,
26282626
auto p1 = vi2p(bcx, bcx.build.Add(vp2i(bcx, p0), len),
26292627
T_ptr(llunit_ty));
26302628

2631-
ret iter_sequence_inner(bcx, p0, p1, elt_ty, f);
2629+
ret iter_sequence_inner(cx, p0, p1, elt_ty, f);
26322630
}
26332631

26342632
alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
@@ -2662,13 +2660,11 @@ fn call_tydesc_glue_full(@block_ctxt cx, ValueRef v,
26622660
llrawptr));
26632661
}
26642662

2665-
fn call_tydesc_glue(@block_ctxt cx, ValueRef v,
2666-
ty.t t, int field) -> result {
2663+
fn call_tydesc_glue(@block_ctxt cx, ValueRef v, ty.t t, int field) {
26672664
auto td = get_tydesc(cx, t);
26682665
call_tydesc_glue_full(td.bcx,
26692666
spill_if_immediate(td.bcx, v, t),
26702667
td.val, field);
2671-
ret res(td.bcx, C_nil());
26722668
}
26732669

26742670
fn call_cmp_glue(@block_ctxt cx, ValueRef lhs, ValueRef rhs, ty.t t,
@@ -2709,7 +2705,7 @@ fn call_cmp_glue(@block_ctxt cx, ValueRef lhs, ValueRef rhs, ty.t t,
27092705

27102706
fn take_ty(@block_ctxt cx, ValueRef v, ty.t t) -> result {
27112707
if (!ty.type_is_scalar(cx.fcx.lcx.ccx.tcx, t)) {
2712-
ret call_tydesc_glue(cx, v, t, abi.tydesc_field_take_glue);
2708+
call_tydesc_glue(cx, v, t, abi.tydesc_field_take_glue);
27132709
}
27142710
ret res(cx, C_nil());
27152711
}
@@ -2731,7 +2727,7 @@ fn drop_ty(@block_ctxt cx,
27312727
ty.t t) -> result {
27322728

27332729
if (!ty.type_is_scalar(cx.fcx.lcx.ccx.tcx, t)) {
2734-
ret call_tydesc_glue(cx, v, t, abi.tydesc_field_drop_glue);
2730+
call_tydesc_glue(cx, v, t, abi.tydesc_field_drop_glue);
27352731
}
27362732
ret res(cx, C_nil());
27372733
}
@@ -3533,7 +3529,7 @@ fn trans_for_each(@block_ctxt cx,
35333529
auto lltydescsptr = cx.build.GEP(llenvptr,
35343530
vec(C_int(0),
35353531
C_int(abi.box_rc_field_body),
3536-
C_int(abi.closure_elt_ty_params)));
3532+
C_int(3)));
35373533
auto i = 0u;
35383534
while (i < tydesc_count) {
35393535
auto lltydescptr = cx.build.GEP(lltydescsptr,
@@ -3567,10 +3563,8 @@ fn trans_for_each(@block_ctxt cx,
35673563

35683564
// Populate the upvars from the environment.
35693565
auto llremoteenvptr = bcx.build.PointerCast(fcx.llenv, llenvptrty);
3570-
auto llremotebindingsptrptr =
3571-
bcx.build.GEP(llremoteenvptr, vec(C_int(0),
3572-
C_int(abi.box_rc_field_body),
3573-
C_int(abi.closure_elt_bindings)));
3566+
auto llremotebindingsptrptr = bcx.build.GEP(llremoteenvptr,
3567+
vec(C_int(0), C_int(abi.box_rc_field_body), C_int(2)));
35743568
auto llremotebindingsptr = bcx.build.Load(llremotebindingsptrptr);
35753569

35763570
i = 0u;
@@ -3585,11 +3579,10 @@ fn trans_for_each(@block_ctxt cx,
35853579
}
35863580

35873581
// Populate the type parameters from the environment.
3588-
auto llremotetydescsptr =
3589-
bcx.build.GEP(llremoteenvptr,
3590-
vec(C_int(0),
3591-
C_int(abi.box_rc_field_body),
3592-
C_int(abi.closure_elt_ty_params)));
3582+
auto llremotetydescsptr = bcx.build.GEP(llremoteenvptr,
3583+
vec(C_int(0),
3584+
C_int(abi.box_rc_field_body),
3585+
C_int(3)));
35933586

35943587
i = 0u;
35953588
while (i < tydesc_count) {
@@ -3910,7 +3903,7 @@ fn lval_generic_fn(@block_ctxt cx,
39103903
}
39113904

39123905
if (_vec.len[ty.t](tys) != 0u) {
3913-
auto bcx = lv.res.bcx;
3906+
auto bcx = cx;
39143907
let vec[ValueRef] tydescs = vec();
39153908
for (ty.t t in tys) {
39163909
auto td = get_tydesc(bcx, t);
@@ -4504,7 +4497,7 @@ fn trans_bind(@block_ctxt cx, @ast.expr f,
45044497
for (ValueRef v in bound_vals) {
45054498
auto bound = bcx.build.GEP(bindings,
45064499
vec(C_int(0), C_int(i as int)));
4507-
bcx = copy_ty(bcx, INIT, bound, v, bound_tys.(i)).bcx;
4500+
bcx = copy_ty(r.bcx, INIT, bound, v, bound_tys.(i)).bcx;
45084501
i += 1u;
45094502
}
45104503

@@ -5331,7 +5324,7 @@ fn trans_break_cont(@block_ctxt cx, bool to_end) -> result {
53315324
}
53325325
}
53335326
}
5334-
ret res(bcx, C_nil());
5327+
ret res(new_sub_block_ctxt(cx, "unreachable"), C_nil());
53355328
}
53365329
case (_) {
53375330
alt (cleanup_cx.parent) {
@@ -5340,7 +5333,7 @@ fn trans_break_cont(@block_ctxt cx, bool to_end) -> result {
53405333
}
53415334
}
53425335
}
5343-
fail;
5336+
ret res(cx, C_nil()); // Never reached. Won't compile otherwise.
53445337
}
53455338

53465339
fn trans_break(@block_ctxt cx) -> result {
@@ -5364,11 +5357,7 @@ fn trans_ret(@block_ctxt cx, &option.t[@ast.expr] e) -> result {
53645357
val = r.val;
53655358
bcx = copy_ty(bcx, INIT, cx.fcx.llretptr, val, t).bcx;
53665359
}
5367-
case (_) {
5368-
auto t = llvm.LLVMGetElementType(val_ty(cx.fcx.llretptr));
5369-
auto null = lib.llvm.llvm.LLVMConstNull(t);
5370-
bcx.build.Store(null, cx.fcx.llretptr);
5371-
}
5360+
case (_) { /* fall through */ }
53725361
}
53735362

53745363
// Run all cleanups and back out.
@@ -6063,7 +6052,7 @@ fn trans_fn(@local_ctxt cx, &ast._fn f, ast.def_id fid,
60636052
new_builder(fcx.llallocas).Br(lltop);
60646053
}
60656054

6066-
fn trans_vtbl(@local_ctxt cx,
6055+
fn trans_vtbl(@local_ctxt cx,
60676056
TypeRef llself_ty,
60686057
ty.t self_ty,
60696058
&ast._obj ob,
@@ -6096,7 +6085,7 @@ fn trans_vtbl(@local_ctxt cx,
60966085
cx.ccx.item_ids.insert(m.node.id, llfn);
60976086
cx.ccx.item_symbols.insert(m.node.id, s);
60986087

6099-
trans_fn(mcx, m.node.meth, m.node.id,
6088+
trans_fn(mcx, m.node.meth, m.node.id,
61006089
some[tup(TypeRef, ty.t)](tup(llself_ty, self_ty)),
61016090
ty_params, m.node.ann);
61026091
methods += vec(llfn);
@@ -6157,7 +6146,7 @@ fn trans_obj(@local_ctxt cx, &ast._obj ob, ast.def_id oid,
61576146

61586147
auto fcx = new_fn_ctxt(cx, llctor_decl);
61596148
create_llargs_for_fn_args(fcx, ast.proto_fn,
6160-
none[tup(TypeRef, ty.t)],
6149+
none[tup(TypeRef, ty.t)],
61616150
ret_ty_of_fn(cx.ccx, ann),
61626151
fn_args, ty_params);
61636152

@@ -6300,7 +6289,7 @@ fn trans_tag_variant(@local_ctxt cx, ast.def_id tag_id,
63006289
auto fcx = new_fn_ctxt(cx, llfndecl);
63016290

63026291
create_llargs_for_fn_args(fcx, ast.proto_fn,
6303-
none[tup(TypeRef, ty.t)],
6292+
none[tup(TypeRef, ty.t)],
63046293
ret_ty_of_fn(cx.ccx, variant.node.ann),
63056294
fn_args, ty_params);
63066295

@@ -6729,7 +6718,7 @@ fn collect_item_2(@crate_ctxt ccx, @walk_ctxt wcx, @ast.item i) {
67296718
fn collect_items(@crate_ctxt ccx, @ast.crate crate) {
67306719
auto wcx = new_walk_ctxt();
67316720
auto visitor0 = walk.default_visitor();
6732-
auto visitor1 = rec(visit_native_item_pre =
6721+
auto visitor1 = rec(visit_native_item_pre =
67336722
bind collect_native_item(ccx, wcx, _),
67346723
visit_item_pre = bind collect_item_1(ccx, wcx, _),
67356724
visit_item_post = bind leave_item(wcx, _)
@@ -6771,7 +6760,7 @@ fn collect_tag_ctors(@crate_ctxt ccx, @ast.crate crate) {
67716760

67726761
fn trans_constant(@crate_ctxt ccx, @walk_ctxt wcx, @ast.item it) {
67736762
enter_item(wcx, it);
6774-
6763+
67756764
alt (it.node) {
67766765
case (ast.item_tag(?ident, ?variants, _, ?tag_id, _)) {
67776766
auto i = 0u;

trunk/src/lib/_str.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,14 @@ fn ends_with(str haystack, str needle) -> bool {
391391
}
392392

393393
fn substr(str s, uint begin, uint len) -> str {
394+
ret slice(s, begin, begin + len);
395+
}
396+
397+
fn slice(str s, uint begin, uint end) -> str {
394398
let str accum = "";
395399
let uint i = begin;
396-
while (i < begin+len) {
397-
accum += unsafe_from_byte(s.(i));
400+
while (i < end) {
401+
push_byte(accum, s.(i));
398402
i += 1u;
399403
}
400404
ret accum;

0 commit comments

Comments
 (0)