Skip to content

Commit c720b75

Browse files
committed
---
yaml --- r: 54237 b: refs/heads/dist-snap c: 58338dd h: refs/heads/master i: 54235: 3819db4 v: v3
1 parent 9b5a101 commit c720b75

File tree

30 files changed

+261
-134
lines changed

30 files changed

+261
-134
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: 44d4d6de762f3f9aae1fedcf454c66b79b3ad58d
10-
refs/heads/dist-snap: 4de9a9440711724a88805847ab6f93336e24e157
10+
refs/heads/dist-snap: 58338dd3d00075301ef2d43aeb0998f53776eebe
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/RELEASES.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ Version 0.6 (March 2013)
6262
* Pattern matching over vectors improved and expanded
6363
* Typechecking of closure types has been overhauled to
6464
improve inference and eliminate unsoundness
65-
* Macros leave scope at the end of modules, unless that module is
66-
tagged with #[macro_escape]
6765

6866
* Libraries
6967
* Added big integers to `std::bigint`

branches/dist-snap/src/libcore/ops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,5 @@ pub trait Shr<RHS,Result> {
7777

7878
#[lang="index"]
7979
pub trait Index<Index,Result> {
80-
fn index(&self, index: &Index) -> Result;
80+
fn index(&self, index: Index) -> Result;
8181
}

branches/dist-snap/src/libcore/rt/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ fn initialize_call_frame(regs: &mut Registers, fptr: *c_void, arg: *c_void, sp:
126126
type Registers = [uint, ..22];
127127

128128
#[cfg(target_arch = "x86_64")]
129-
fn new_regs() -> ~Registers { ~[0, .. 22] }
129+
fn new_regs() -> ~Registers { ~([0, .. 22]) }
130130

131131
#[cfg(target_arch = "x86_64")]
132132
fn initialize_call_frame(regs: &mut Registers, fptr: *c_void, arg: *c_void, sp: *mut uint) {

branches/dist-snap/src/librustc/metadata/decoder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,7 @@ fn get_self_ty(item: ebml::Doc) -> ast::self_ty_ {
630630
let self_ty_kind = string[0];
631631
match self_ty_kind as char {
632632
's' => { return ast::sty_static; }
633+
'r' => { return ast::sty_by_ref; }
633634
'v' => { return ast::sty_value; }
634635
'@' => { return ast::sty_box(get_mutability(string[1])); }
635636
'~' => { return ast::sty_uniq(get_mutability(string[1])); }

branches/dist-snap/src/librustc/metadata/encoder.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,9 @@ fn encode_self_type(ebml_w: writer::Encoder, self_type: ast::self_ty_) {
410410
sty_static => {
411411
ebml_w.writer.write(&[ 's' as u8 ]);
412412
}
413+
sty_by_ref => {
414+
ebml_w.writer.write(&[ 'r' as u8 ]);
415+
}
413416
sty_value => {
414417
ebml_w.writer.write(&[ 'v' as u8 ]);
415418
}

branches/dist-snap/src/librustc/middle/astencode.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
342342
}
343343
344344
fn decode_ast(par_doc: ebml::Doc) -> ast::inlined_item {
345-
let chi_doc = par_doc.get(c::tag_tree as uint);
345+
let chi_doc = par_doc[c::tag_tree as uint];
346346
let d = &reader::Decoder(chi_doc);
347347
Decodable::decode(d)
348348
}
@@ -1089,9 +1089,9 @@ impl ebml_decoder_decoder_helpers for reader::Decoder {
10891089
fn decode_side_tables(xcx: @ExtendedDecodeContext,
10901090
ast_doc: ebml::Doc) {
10911091
let dcx = xcx.dcx;
1092-
let tbl_doc = ast_doc.get(c::tag_table as uint);
1092+
let tbl_doc = ast_doc[c::tag_table as uint];
10931093
for reader::docs(tbl_doc) |tag, entry_doc| {
1094-
let id0 = entry_doc.get(c::tag_table_id as uint).as_int();
1094+
let id0 = entry_doc[c::tag_table_id as uint].as_int();
10951095
let id = xcx.tr_id(id0);
10961096
10971097
debug!(">> Side table document with tag 0x%x \
@@ -1103,7 +1103,7 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext,
11031103
} else if tag == (c::tag_table_moves_map as uint) {
11041104
dcx.maps.moves_map.insert(id);
11051105
} else {
1106-
let val_doc = entry_doc.get(c::tag_table_val as uint);
1106+
let val_doc = entry_doc[c::tag_table_val as uint];
11071107
let val_dsr = &reader::Decoder(val_doc);
11081108
if tag == (c::tag_table_def as uint) {
11091109
let def = decode_def(xcx, val_doc);
@@ -1172,7 +1172,7 @@ fn encode_item_ast(ebml_w: writer::Encoder, item: @ast::item) {
11721172
11731173
#[cfg(test)]
11741174
fn decode_item_ast(par_doc: ebml::Doc) -> @ast::item {
1175-
let chi_doc = par_doc.get(c::tag_tree as uint);
1175+
let chi_doc = par_doc[c::tag_tree as uint];
11761176
let d = &reader::Decoder(chi_doc);
11771177
@Decodable::decode(d)
11781178
}

branches/dist-snap/src/librustc/middle/borrowck/gather_loans.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,21 @@ fn req_loans_in_expr(ex: @ast::expr,
180180
}
181181
}
182182

183+
match self.bccx.method_map.find(&ex.id) {
184+
Some(ref method_map_entry) => {
185+
match (*method_map_entry).explicit_self {
186+
ast::sty_by_ref => {
187+
let rcvr_cmt = self.bccx.cat_expr(rcvr);
188+
self.guarantee_valid(rcvr_cmt, m_imm, scope_r);
189+
}
190+
_ => {} // Nothing to do.
191+
}
192+
}
193+
None => {
194+
self.tcx().sess.span_bug(ex.span, ~"no method map entry");
195+
}
196+
}
197+
183198
visit::visit_expr(ex, self, vt);
184199
}
185200

branches/dist-snap/src/librustc/middle/liveness.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,11 @@ fn visit_fn(fk: &visit::fn_kind,
467467
match *fk {
468468
fk_method(_, _, method) => {
469469
match method.self_ty.node {
470+
sty_by_ref => {
471+
fn_maps.add_variable(Arg(method.self_id,
472+
special_idents::self_,
473+
by_ref));
474+
}
470475
sty_value | sty_region(*) | sty_box(_) | sty_uniq(_) => {
471476
fn_maps.add_variable(Arg(method.self_id,
472477
special_idents::self_,

branches/dist-snap/src/librustc/middle/moves.rs

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ pub impl VisitContext {
436436

437437
expr_unary(deref, base) => { // *base
438438
if !self.use_overloaded_operator(
439-
expr, base, [], visitor)
439+
expr, DontDerefArgs, base, [], visitor)
440440
{
441441
// Moving out of *base moves out of base.
442442
self.use_expr(base, comp_mode, visitor);
@@ -450,7 +450,7 @@ pub impl VisitContext {
450450

451451
expr_index(lhs, rhs) => { // lhs[rhs]
452452
if !self.use_overloaded_operator(
453-
expr, lhs, [rhs], visitor)
453+
expr, DontDerefArgs, lhs, [rhs], visitor)
454454
{
455455
self.use_expr(lhs, comp_mode, visitor);
456456
self.consume_expr(rhs, visitor);
@@ -579,15 +579,15 @@ pub impl VisitContext {
579579

580580
expr_unary(_, lhs) => {
581581
if !self.use_overloaded_operator(
582-
expr, lhs, [], visitor)
582+
expr, DontDerefArgs, lhs, [], visitor)
583583
{
584584
self.consume_expr(lhs, visitor);
585585
}
586586
}
587587

588588
expr_binary(_, lhs, rhs) => {
589589
if !self.use_overloaded_operator(
590-
expr, lhs, [rhs], visitor)
590+
expr, DoDerefArgs, lhs, [rhs], visitor)
591591
{
592592
self.consume_expr(lhs, visitor);
593593
self.consume_expr(rhs, visitor);
@@ -659,6 +659,7 @@ pub impl VisitContext {
659659

660660
fn use_overloaded_operator(&self,
661661
expr: @expr,
662+
deref_args: DerefArgs,
662663
receiver_expr: @expr,
663664
arg_exprs: &[@expr],
664665
visitor: vt<VisitContext>) -> bool
@@ -669,10 +670,21 @@ pub impl VisitContext {
669670

670671
self.use_receiver(expr.id, expr.span, receiver_expr, visitor);
671672

672-
// for overloaded operatrs, we are always passing in a
673-
// borrowed pointer, so it's always read mode:
674-
for arg_exprs.each |arg_expr| {
675-
self.use_expr(*arg_expr, Read, visitor);
673+
// The deref_args stuff should eventually be converted into
674+
// adjustments. Moreover, it should eventually be applied
675+
// consistently to all overloaded operators. But that's not
676+
// how it is today.
677+
match deref_args {
678+
DoDerefArgs => {
679+
// we are always passing in a borrowed pointer,
680+
// so it's always read mode:
681+
for arg_exprs.each |arg_expr| {
682+
self.use_expr(*arg_expr, Read, visitor);
683+
}
684+
}
685+
DontDerefArgs => {
686+
self.use_fn_args(expr.callee_id, arg_exprs, visitor);
687+
}
676688
}
677689

678690
return true;
@@ -725,7 +737,20 @@ pub impl VisitContext {
725737
receiver_expr: @expr,
726738
visitor: vt<VisitContext>)
727739
{
728-
self.use_fn_arg(by_copy, receiver_expr, visitor);
740+
let callee_mode = match self.method_map.find(&expr_id) {
741+
Some(ref method_map_entry) => {
742+
match method_map_entry.explicit_self {
743+
sty_by_ref => by_ref,
744+
_ => by_copy
745+
}
746+
}
747+
None => {
748+
self.tcx.sess.span_bug(
749+
span,
750+
~"no method map entry");
751+
}
752+
};
753+
self.use_fn_arg(callee_mode, receiver_expr, visitor);
729754
}
730755

731756
fn use_fn_args(&self,

branches/dist-snap/src/librustc/middle/resolve.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ use syntax::ast::{named_field, ne, neg, node_id, pat, pat_enum, pat_ident};
5050
use syntax::ast::{path, pat_box, pat_lit, pat_range, pat_struct};
5151
use syntax::ast::{pat_tup, pat_uniq, pat_wild, prim_ty, private, provided};
5252
use syntax::ast::{public, required, rem, self_ty_, shl, shr, stmt_decl};
53-
use syntax::ast::{struct_dtor, struct_field, struct_variant_kind};
53+
use syntax::ast::{struct_dtor, struct_field, struct_variant_kind, sty_by_ref};
5454
use syntax::ast::{sty_static, subtract, trait_ref, tuple_variant_kind, Ty};
5555
use syntax::ast::{ty_bool, ty_char, ty_f, ty_f32, ty_f64, ty_float, ty_i};
5656
use syntax::ast::{ty_i16, ty_i32, ty_i64, ty_i8, ty_int, TyParam, ty_path};
@@ -3792,6 +3792,7 @@ pub impl Resolver {
37923792
// we only have self ty if it is a non static method
37933793
let self_binding = match method.self_ty.node {
37943794
sty_static => { NoSelfBinding }
3795+
sty_by_ref => { HasSelfBinding(method.self_id, true) }
37953796
_ => { HasSelfBinding(method.self_id, false) }
37963797
};
37973798

branches/dist-snap/src/librustc/middle/trans/base.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2540,8 +2540,9 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::node_id) -> ValueRef {
25402540
}
25412541
}
25422542
2543-
_ => {
2544-
ccx.sess.bug(~"get_item_val(): unexpected variant")
2543+
ref variant => {
2544+
ccx.sess.bug(fmt!("get_item_val(): unexpected variant: %?",
2545+
variant))
25452546
}
25462547
};
25472548
if !(exprt || ccx.reachable.contains(&id)) {
@@ -3085,6 +3086,7 @@ pub fn trans_crate(sess: session::Session,
30853086
const_cstr_cache: @mut LinearMap::new(),
30863087
const_globals: @mut LinearMap::new(),
30873088
const_values: @mut LinearMap::new(),
3089+
extern_const_values: @mut LinearMap::new(),
30883090
module_data: @mut LinearMap::new(),
30893091
lltypes: @mut LinearMap::new(),
30903092
llsizingtypes: @mut LinearMap::new(),

branches/dist-snap/src/librustc/middle/trans/common.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ pub struct CrateContext {
201201

202202
// Cache of emitted const values
203203
const_values: @mut LinearMap<ast::node_id, ValueRef>,
204+
205+
// Cache of external const values
206+
extern_const_values: @mut LinearMap<ast::def_id, ValueRef>,
207+
204208
module_data: @mut LinearMap<~str, ValueRef>,
205209
lltypes: @mut LinearMap<ty::t, TypeRef>,
206210
llsizingtypes: @mut LinearMap<ty::t, TypeRef>,

branches/dist-snap/src/librustc/middle/trans/expr.rs

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ use core::prelude::*;
124124
use back::abi;
125125
use lib;
126126
use lib::llvm::{ValueRef, TypeRef, llvm, True};
127+
use metadata::csearch;
127128
use middle::borrowck::root_map_key;
128129
use middle::trans::_match;
129130
use middle::trans::adt;
@@ -150,6 +151,7 @@ use middle::ty::{AutoPtr, AutoBorrowVec, AutoBorrowVecRef, AutoBorrowFn,
150151
use util::common::indenter;
151152
use util::ppaux::ty_to_str;
152153

154+
use core::cast::transmute;
153155
use core::hashmap::linear::LinearMap;
154156
use syntax::print::pprust::{expr_to_str};
155157
use syntax::ast;
@@ -766,15 +768,18 @@ fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr,
766768
}
767769
ast::expr_binary(_, lhs, rhs) => {
768770
// if not overloaded, would be RvalueDatumExpr
769-
return trans_overloaded_op(bcx, expr, lhs, ~[rhs], dest);
771+
return trans_overloaded_op(bcx, expr, lhs, ~[rhs], dest,
772+
DoAutorefArg);
770773
}
771774
ast::expr_unary(_, subexpr) => {
772775
// if not overloaded, would be RvalueDatumExpr
773-
return trans_overloaded_op(bcx, expr, subexpr, ~[], dest);
776+
return trans_overloaded_op(bcx, expr, subexpr, ~[], dest,
777+
DontAutorefArg);
774778
}
775779
ast::expr_index(base, idx) => {
776780
// if not overloaded, would be RvalueDatumExpr
777-
return trans_overloaded_op(bcx, expr, base, ~[idx], dest);
781+
return trans_overloaded_op(bcx, expr, base, ~[idx], dest,
782+
DontAutorefArg);
778783
}
779784
ast::expr_cast(val, _) => {
780785
match ty::get(node_id_type(bcx, expr.id)).sty {
@@ -1093,11 +1098,35 @@ fn trans_lvalue_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock {
10931098
10941099
fn get_val(bcx: block, did: ast::def_id, const_ty: ty::t)
10951100
-> ValueRef {
1096-
// The LLVM global has the type of its initializer,
1097-
// which may not be equal to the enum's type for
1098-
// non-C-like enums.
1099-
PointerCast(bcx, base::get_item_val(bcx.ccx(), did.node),
1100-
T_ptr(type_of(bcx.ccx(), const_ty)))
1101+
if did.crate == ast::local_crate {
1102+
// The LLVM global has the type of its initializer,
1103+
// which may not be equal to the enum's type for
1104+
// non-C-like enums.
1105+
PointerCast(bcx,
1106+
base::get_item_val(bcx.ccx(), did.node),
1107+
T_ptr(type_of(bcx.ccx(), const_ty)))
1108+
} else {
1109+
// For external constants, we don't inline.
1110+
match bcx.ccx().extern_const_values.find(&did) {
1111+
None => {
1112+
unsafe {
1113+
let llty = type_of(bcx.ccx(), const_ty);
1114+
let symbol = csearch::get_symbol(
1115+
bcx.ccx().sess.cstore,
1116+
did);
1117+
let llval = llvm::LLVMAddGlobal(
1118+
bcx.ccx().llmod,
1119+
llty,
1120+
transmute::<&u8,*i8>(&symbol[0]));
1121+
bcx.ccx().extern_const_values.insert(
1122+
did,
1123+
llval);
1124+
llval
1125+
}
1126+
}
1127+
Some(llval) => *llval
1128+
}
1129+
}
11011130
}
11021131
11031132
let did = get_did(ccx, did);
@@ -1641,15 +1670,16 @@ fn trans_overloaded_op(bcx: block,
16411670
expr: @ast::expr,
16421671
rcvr: @ast::expr,
16431672
+args: ~[@ast::expr],
1644-
dest: Dest) -> block
1673+
dest: Dest,
1674+
+autoref_arg: AutorefArg) -> block
16451675
{
16461676
let origin = *bcx.ccx().maps.method_map.get(&expr.id);
16471677
let fty = node_id_type(bcx, expr.callee_id);
16481678
return callee::trans_call_inner(
16491679
bcx, expr.info(), fty,
16501680
expr_ty(bcx, expr),
16511681
|bcx| meth::trans_method_callee(bcx, expr.callee_id, rcvr, origin),
1652-
callee::ArgExprs(args), dest, DoAutorefArg);
1682+
callee::ArgExprs(args), dest, autoref_arg);
16531683
}
16541684
16551685
fn int_cast(bcx: block, lldsttype: TypeRef, llsrctype: TypeRef,
@@ -1802,7 +1832,7 @@ fn trans_assign_op(bcx: block,
18021832
// FIXME(#2528) evaluates the receiver twice!!
18031833
let scratch = scratch_datum(bcx, dst_datum.ty, false);
18041834
let bcx = trans_overloaded_op(bcx, expr, dst, ~[src],
1805-
SaveIn(scratch.val));
1835+
SaveIn(scratch.val), DoAutorefArg);
18061836
return scratch.move_to_datum(bcx, DROP_EXISTING, dst_datum);
18071837
}
18081838

0 commit comments

Comments
 (0)