diff options
| author | Graydon Hoare <graydon@mozilla.com> | 2011-12-07 11:52:38 -0800 |
|---|---|---|
| committer | Graydon Hoare <graydon@mozilla.com> | 2011-12-07 11:52:38 -0800 |
| commit | a3f48d3fe1d90a4684cb20e75688ffbca804e82c (patch) | |
| tree | f8ca510a3e827cb31e38cffdc260ab6112cf6b79 /src/comp/middle | |
| parent | 1652b921fa2fadc936b346fc3de217cf97b0e476 (diff) | |
| parent | 6c95e400d82699887b66f5de0fef2bb5e1f8cc32 (diff) | |
| download | rust-a3f48d3fe1d90a4684cb20e75688ffbca804e82c.tar.gz rust-a3f48d3fe1d90a4684cb20e75688ffbca804e82c.zip | |
Merge branch 'master' of github.com:graydon/rust
Diffstat (limited to 'src/comp/middle')
| -rw-r--r-- | src/comp/middle/mut.rs | 25 | ||||
| -rw-r--r-- | src/comp/middle/trans.rs | 15 | ||||
| -rw-r--r-- | src/comp/middle/trans_build.rs | 4 | ||||
| -rw-r--r-- | src/comp/middle/tstate/pre_post_conditions.rs | 4 | ||||
| -rw-r--r-- | src/comp/middle/tstate/states.rs | 6 | ||||
| -rw-r--r-- | src/comp/middle/ty.rs | 30 |
6 files changed, 67 insertions, 17 deletions
diff --git a/src/comp/middle/mut.rs b/src/comp/middle/mut.rs index 12598f3729b..63dadd347e1 100644 --- a/src/comp/middle/mut.rs +++ b/src/comp/middle/mut.rs @@ -150,6 +150,7 @@ fn visit_decl(cx: @ctx, d: @decl, &&e: (), v: visit::vt<()>) { fn visit_expr(cx: @ctx, ex: @expr, &&e: (), v: visit::vt<()>) { alt ex.node { expr_call(f, args, _) { check_call(cx, f, args); } + expr_bind(f, args) { check_bind(cx, f, args); } expr_swap(lhs, rhs) { check_lval(cx, lhs, msg_assign); check_lval(cx, rhs, msg_assign); @@ -230,6 +231,30 @@ fn check_call(cx: @ctx, f: @expr, args: [@expr]) { } } +fn check_bind(cx: @ctx, f: @expr, args: [option::t<@expr>]) { + let arg_ts = ty::ty_fn_args(cx.tcx, ty::expr_ty(cx.tcx, f)); + let i = 0u; + for arg in args { + alt arg { + some(expr) { + alt (alt arg_ts[i].mode { + by_mut_ref. { some("by mutable reference") } + by_move. { some("by move") } + _ { none } + }) { + some(name) { + cx.tcx.sess.span_err( + expr.span, "can not bind an argument passed " + name); + } + none. {} + } + } + _ {} + } + i += 1u; + } +} + fn is_immutable_def(def: def) -> option::t<str> { alt def { def_fn(_, _) | def_mod(_) | def_native_mod(_) | def_const(_) | diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 6804434bb4c..107c53cfac3 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -3462,6 +3462,12 @@ fn trans_bind_thunk(cx: @local_ctxt, sp: span, incoming_fty: ty::t, bcx = bound_arg.bcx; let val = bound_arg.val; if out_arg.mode == ast::by_val { val = Load(bcx, val); } + if out_arg.mode == ast::by_copy { + let {bcx: cx, val: alloc} = alloc_ty(bcx, out_arg.ty); + bcx = memmove_ty(cx, alloc, val, out_arg.ty); + bcx = take_ty(bcx, alloc, out_arg.ty); + val = alloc; + } // If the type is parameterized, then we need to cast the // type we actually have to the parameterized out type. if ty::type_contains_params(cx.ccx.tcx, out_arg.ty) { @@ -3904,6 +3910,11 @@ fn trans_landing_pad(bcx: @block_ctxt, // The landing pad block is a cleanup SetCleanup(bcx, llpad); + // Because we may have unwound across a stack boundary, we must call into + // the runtime to figure out which stack segment we are on and place the + // stack limit back into the TLS. + Call(bcx, bcx_ccx(bcx).upcalls.reset_stack_limit, []); + // FIXME: This seems like a very naive and redundant way to generate the // landing pads, as we're re-generating all in-scope cleanups for each // function call. Probably good optimization opportunities here. @@ -4531,7 +4542,9 @@ fn zero_alloca(cx: @block_ctxt, llptr: ValueRef, t: ty::t) fn trans_stmt(cx: @block_ctxt, s: ast::stmt) -> @block_ctxt { // FIXME Fill in cx.sp - add_span_comment(cx, s.span, stmt_to_str(s)); + if (!bcx_ccx(cx).sess.get_opts().no_asm_comments) { + add_span_comment(cx, s.span, stmt_to_str(s)); + } let bcx = cx; alt s.node { diff --git a/src/comp/middle/trans_build.rs b/src/comp/middle/trans_build.rs index 02894769ae6..b7756b0902d 100644 --- a/src/comp/middle/trans_build.rs +++ b/src/comp/middle/trans_build.rs @@ -515,7 +515,9 @@ fn add_span_comment(bcx: @block_ctxt, sp: span, text: str) { fn add_comment(bcx: @block_ctxt, text: str) { let ccx = bcx_ccx(bcx); if (!ccx.sess.get_opts().no_asm_comments) { - let comment_text = "; " + text; + check str::is_not_empty("$"); + let sanitized = str::replace(text, "$", ""); + let comment_text = "; " + sanitized; let asm = str::as_buf(comment_text, { |c| str::as_buf("", { |e| llvm::LLVMConstInlineAsm(T_fn([], T_void()), c, e, 0, 0)})}); diff --git a/src/comp/middle/tstate/pre_post_conditions.rs b/src/comp/middle/tstate/pre_post_conditions.rs index d0ac63704d7..d8e57c90986 100644 --- a/src/comp/middle/tstate/pre_post_conditions.rs +++ b/src/comp/middle/tstate/pre_post_conditions.rs @@ -452,6 +452,10 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { expr_alt(ex, alts) { find_pre_post_expr(fcx, ex); fn do_an_alt(fcx: fn_ctxt, an_alt: arm) -> pre_and_post { + alt an_alt.guard { + some(e) { find_pre_post_expr(fcx, e); } + _ {} + } find_pre_post_block(fcx, an_alt.body); ret block_pp(fcx.ccx, an_alt.body); } diff --git a/src/comp/middle/tstate/states.rs b/src/comp/middle/tstate/states.rs index ed84520a6b9..aa7977d142d 100644 --- a/src/comp/middle/tstate/states.rs +++ b/src/comp/middle/tstate/states.rs @@ -530,6 +530,12 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { if vec::len(alts) > 0u { a_post = false_postcond(num_constrs); for an_alt: arm in alts { + alt an_alt.guard { + some(e) { + changed |= find_pre_post_state_expr(fcx, e_post, e); + } + _ {} + } changed |= find_pre_post_state_block(fcx, e_post, an_alt.body); intersect(a_post, block_poststate(fcx.ccx, an_alt.body)); diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index b5b5559f4aa..022b249674b 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -1299,23 +1299,23 @@ fn type_autoderef(cx: ctxt, t: ty::t) -> ty::t { fn hash_type_structure(st: sty) -> uint { fn hash_uint(id: uint, n: uint) -> uint { let h = id; - h += h << 5u + n; + h += (h << 5u) + n; ret h; } fn hash_def(id: uint, did: ast::def_id) -> uint { let h = id; - h += h << 5u + (did.crate as uint); - h += h << 5u + (did.node as uint); + h += (h << 5u) + (did.crate as uint); + h += (h << 5u) + (did.node as uint); ret h; } fn hash_subty(id: uint, subty: t) -> uint { let h = id; - h += h << 5u + hash_ty(subty); + h += (h << 5u) + hash_ty(subty); ret h; } fn hash_type_constr(id: uint, c: @type_constr) -> uint { let h = id; - h += h << 5u + hash_def(h, c.node.id); + h += (h << 5u) + hash_def(h, c.node.id); ret hash_type_constr_args(h, c.node.args); } fn hash_type_constr_args(id: uint, args: [@ty_constr_arg]) -> uint { @@ -1338,8 +1338,8 @@ fn hash_type_structure(st: sty) -> uint { fn hash_fn(id: uint, args: [arg], rty: t) -> uint { let h = id; - for a: arg in args { h += h << 5u + hash_ty(a.ty); } - h += h << 5u + hash_ty(rty); + for a: arg in args { h += (h << 5u) + hash_ty(a.ty); } + h += (h << 5u) + hash_ty(rty); ret h; } alt st { @@ -1366,19 +1366,19 @@ fn hash_type_structure(st: sty) -> uint { ty_str. { ret 17u; } ty_tag(did, tys) { let h = hash_def(18u, did); - for typ: t in tys { h += h << 5u + hash_ty(typ); } + for typ: t in tys { h += (h << 5u) + hash_ty(typ); } ret h; } ty_box(mt) { ret hash_subty(19u, mt.ty); } ty_vec(mt) { ret hash_subty(21u, mt.ty); } ty_rec(fields) { let h = 26u; - for f: field in fields { h += h << 5u + hash_ty(f.mt.ty); } + for f: field in fields { h += (h << 5u) + hash_ty(f.mt.ty); } ret h; } ty_tup(ts) { let h = 25u; - for tt in ts { h += h << 5u + hash_ty(tt); } + for tt in ts { h += (h << 5u) + hash_ty(tt); } ret h; } @@ -1389,7 +1389,7 @@ fn hash_type_structure(st: sty) -> uint { ty_native_fn(args, rty) { ret hash_fn(28u, args, rty); } ty_obj(methods) { let h = 29u; - for m: method in methods { h += h << 5u + str::hash(m.ident); } + for m: method in methods { h += (h << 5u) + str::hash(m.ident); } ret h; } ty_var(v) { ret hash_uint(30u, v as uint); } @@ -1400,15 +1400,15 @@ fn hash_type_structure(st: sty) -> uint { ty_ptr(mt) { ret hash_subty(35u, mt.ty); } ty_res(did, sub, tps) { let h = hash_subty(hash_def(18u, did), sub); - for tp: t in tps { h += h << 5u + hash_ty(tp); } + for tp: t in tps { h += (h << 5u) + hash_ty(tp); } ret h; } ty_constr(t, cs) { let h = 36u; - for c: @type_constr in cs { h += h << 5u + hash_type_constr(h, c); } + for c: @type_constr in cs { h += (h << 5u) + hash_type_constr(h, c); } ret h; } - ty_uniq(mt) { let h = 37u; h += h << 5u + hash_ty(mt.ty); ret h; } + ty_uniq(mt) { let h = 37u; h += (h << 5u) + hash_ty(mt.ty); ret h; } } } @@ -1416,7 +1416,7 @@ fn hash_type_info(st: sty, cname_opt: option::t<str>) -> uint { let h = hash_type_structure(st); alt cname_opt { none. {/* no-op */ } - some(s) { h += h << 5u + str::hash(s); } + some(s) { h += (h << 5u) + str::hash(s); } } ret h; } |
