Skip to content

Commit 1a6921d

Browse files
committed
---
yaml --- r: 139805 b: refs/heads/try2 c: 16e8af9 h: refs/heads/master i: 139803: bcec489 v: v3
1 parent 3dbdb97 commit 1a6921d

File tree

7 files changed

+106
-29
lines changed

7 files changed

+106
-29
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 40e3577b0834794b2d44e6c527fda90d1adbc88e
8+
refs/heads/try2: 16e8af9e477fd5a6e7dcf668840144a97e3b1410
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/AUTHORS.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Bilal Husain <[email protected]>
3131
Bill Fallon <[email protected]>
3232
Brendan Eich <[email protected]>
3333
Brendan Zabarauskas <[email protected]>
34+
Brett Cannon <[email protected]>
3435
Brian Anderson <[email protected]>
3536
Brian J. Burg <[email protected]>
3637
Brian Leibig <[email protected]>
@@ -50,6 +51,7 @@ Dave Herman <[email protected]>
5051
David Forsythe <[email protected]>
5152
David Klein <[email protected]>
5253
David Rajchenbach-Teller <[email protected]>
54+
Diggory Hardy <[email protected]>
5355
Dimitri Krassovski <[email protected]>
5456
Donovan Preston <[email protected]>
5557
Drew Willcoxon <[email protected]>
@@ -76,9 +78,11 @@ Ian D. Bollinger <[email protected]>
7678
Ilyong Cho <[email protected]>
7779
Isaac Aggrey <[email protected]>
7880
Ivano Coppola <[email protected]>
81+
Jack Moffitt <[email protected]>
7982
Jacob Harris Cryer Kragh <[email protected]>
8083
Jacob Parker <[email protected]>
8184
Jakub Wieczorek <[email protected]>
85+
James Miller <[email protected]>
8286
Jason Orendorff <[email protected]>
8387
Jed Davis <[email protected]>
8488
Jeff Balogh <[email protected]>

branches/try2/src/librustc/metadata/encoder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub struct EncodeParams {
6363
reachable: reachable::map,
6464
reexports2: middle::resolve::ExportMap2,
6565
item_symbols: @mut HashMap<ast::node_id, ~str>,
66-
discrim_symbols: @mut HashMap<ast::node_id, ~str>,
66+
discrim_symbols: @mut HashMap<ast::node_id, @~str>,
6767
link_meta: LinkMeta,
6868
cstore: @mut cstore::CStore,
6969
encode_inlined_item: encode_inlined_item
@@ -90,7 +90,7 @@ pub struct EncodeContext {
9090
reachable: reachable::map,
9191
reexports2: middle::resolve::ExportMap2,
9292
item_symbols: @mut HashMap<ast::node_id, ~str>,
93-
discrim_symbols: @mut HashMap<ast::node_id, ~str>,
93+
discrim_symbols: @mut HashMap<ast::node_id, @~str>,
9494
link_meta: LinkMeta,
9595
cstore: @mut cstore::CStore,
9696
encode_inlined_item: encode_inlined_item,
@@ -285,7 +285,7 @@ fn encode_symbol(ecx: @EncodeContext, ebml_w: writer::Encoder, id: node_id) {
285285
fn encode_discriminant(ecx: @EncodeContext, ebml_w: writer::Encoder,
286286
id: node_id) {
287287
ebml_w.start_tag(tag_items_data_item_symbol);
288-
ebml_w.writer.write(str::to_bytes(*ecx.discrim_symbols.get(&id)));
288+
ebml_w.writer.write(str::to_bytes(**ecx.discrim_symbols.get(&id)));
289289
ebml_w.end_tag();
290290
}
291291

branches/try2/src/librustc/middle/trans/base.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -468,11 +468,9 @@ pub fn set_glue_inlining(f: ValueRef, t: ty::t) {
468468

469469
// Double-check that we never ask LLVM to declare the same symbol twice. It
470470
// silently mangles such symbols, breaking our linkage model.
471-
pub fn note_unique_llvm_symbol(ccx: @CrateContext, +sym: ~str) {
472-
// XXX: this should not be necessary
473-
use core::container::Set;
471+
pub fn note_unique_llvm_symbol(ccx: @CrateContext, sym: @~str) {
474472
if ccx.all_llvm_symbols.contains(&sym) {
475-
ccx.sess.bug(~"duplicate LLVM symbol: " + sym);
473+
ccx.sess.bug(~"duplicate LLVM symbol: " + *sym);
476474
}
477475
ccx.all_llvm_symbols.insert(sym);
478476
}
@@ -2576,11 +2574,10 @@ pub fn trans_constant(ccx: @CrateContext, it: @ast::item) {
25762574
path_name(variant.node.name),
25772575
path_name(special_idents::descrim)
25782576
]);
2579-
let s = mangle_exported_name(ccx, p, ty::mk_int(ccx.tcx));
2577+
let s = @mangle_exported_name(ccx, p, ty::mk_int(ccx.tcx));
25802578
let disr_val = vi[i].disr_val;
2581-
// XXX: Bad copy.
2582-
note_unique_llvm_symbol(ccx, copy s);
2583-
let discrim_gvar = str::as_c_str(s, |buf| {
2579+
note_unique_llvm_symbol(ccx, s);
2580+
let discrim_gvar = str::as_c_str(*s, |buf| {
25842581
unsafe {
25852582
llvm::LLVMAddGlobal(ccx.llmod, ccx.int_type, buf)
25862583
}

branches/try2/src/librustc/middle/trans/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ pub struct CrateContext {
173173
link_meta: LinkMeta,
174174
enum_sizes: @mut HashMap<ty::t, uint>,
175175
discrims: @mut HashMap<ast::def_id, ValueRef>,
176-
discrim_symbols: @mut HashMap<ast::node_id, ~str>,
176+
discrim_symbols: @mut HashMap<ast::node_id, @~str>,
177177
tydescs: @mut HashMap<ty::t, @mut tydesc_info>,
178178
// Set when running emit_tydescs to enforce that no more tydescs are
179179
// created.
@@ -215,7 +215,7 @@ pub struct CrateContext {
215215
symbol_hasher: @hash::State,
216216
type_hashcodes: @mut HashMap<ty::t, @str>,
217217
type_short_names: @mut HashMap<ty::t, ~str>,
218-
all_llvm_symbols: @mut HashSet<~str>,
218+
all_llvm_symbols: @mut HashSet<@~str>,
219219
tcx: ty::ctxt,
220220
maps: astencode::Maps,
221221
stats: @mut Stats,

branches/try2/src/librustc/middle/trans/glue.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -684,15 +684,14 @@ pub fn declare_tydesc(ccx: @CrateContext, t: ty::t) -> @mut tydesc_info {
684684
let llalign = llalign_of(ccx, llty);
685685
let addrspace = declare_tydesc_addrspace(ccx, t);
686686
//XXX this triggers duplicate LLVM symbols
687-
let name = if false /*ccx.sess.opts.debuginfo*/ {
687+
let name = @(if false /*ccx.sess.opts.debuginfo*/ {
688688
mangle_internal_name_by_type_only(ccx, t, ~"tydesc")
689689
} else {
690690
mangle_internal_name_by_seq(ccx, ~"tydesc")
691-
};
692-
// XXX: Bad copy.
693-
note_unique_llvm_symbol(ccx, copy name);
694-
debug!("+++ declare_tydesc %s %s", ppaux::ty_to_str(ccx.tcx, t), name);
695-
let gvar = str::as_c_str(name, |buf| {
691+
});
692+
note_unique_llvm_symbol(ccx, name);
693+
debug!("+++ declare_tydesc %s %s", ppaux::ty_to_str(ccx.tcx, t), *name);
694+
let gvar = str::as_c_str(*name, |buf| {
696695
unsafe {
697696
llvm::LLVMAddGlobal(ccx.llmod, ccx.tydesc_type, buf)
698697
}
@@ -718,17 +717,16 @@ pub fn declare_generic_glue(ccx: @CrateContext, t: ty::t, llfnty: TypeRef,
718717
+name: ~str) -> ValueRef {
719718
let _icx = ccx.insn_ctxt("declare_generic_glue");
720719
let name = name;
721-
let mut fn_nm;
722720
//XXX this triggers duplicate LLVM symbols
723-
if false /*ccx.sess.opts.debuginfo*/ {
724-
fn_nm = mangle_internal_name_by_type_only(ccx, t, (~"glue_" + name));
721+
let fn_nm = @(if false /*ccx.sess.opts.debuginfo*/ {
722+
mangle_internal_name_by_type_only(ccx, t, (~"glue_" + name))
725723
} else {
726-
fn_nm = mangle_internal_name_by_seq(ccx, (~"glue_" + name));
727-
}
728-
debug!("%s is for type %s", fn_nm, ppaux::ty_to_str(ccx.tcx, t));
724+
mangle_internal_name_by_seq(ccx, (~"glue_" + name))
725+
});
726+
debug!("%s is for type %s", *fn_nm, ppaux::ty_to_str(ccx.tcx, t));
729727
// XXX: Bad copy.
730-
note_unique_llvm_symbol(ccx, copy fn_nm);
731-
let llfn = decl_cdecl_fn(ccx.llmod, fn_nm, llfnty);
728+
note_unique_llvm_symbol(ccx, fn_nm);
729+
let llfn = decl_cdecl_fn(ccx.llmod, *fn_nm, llfnty);
732730
set_glue_inlining(llfn, t);
733731
return llfn;
734732
}

branches/try2/src/libstd/base64.rs

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -27,6 +27,21 @@ static CHARS: [char, ..64] = [
2727
];
2828

2929
impl<'self> ToBase64 for &'self [u8] {
30+
/**
31+
* Turn a vector of `u8` bytes into a base64 string.
32+
*
33+
* *Example*:
34+
*
35+
* ~~~~
36+
* extern mod std;
37+
* use std::base64::ToBase64;
38+
*
39+
* fn main () {
40+
* let str = [52,32].to_base64();
41+
* println(fmt!("%s", str));
42+
* }
43+
* ~~~~
44+
*/
3045
fn to_base64(&self) -> ~str {
3146
let mut s = ~"";
3247
let len = self.len();
@@ -74,6 +89,23 @@ impl<'self> ToBase64 for &'self [u8] {
7489
}
7590
7691
impl<'self> ToBase64 for &'self str {
92+
/**
93+
* Convert any string (literal, `@`, `&`, or `~`) to base64 encoding.
94+
*
95+
*
96+
* *Example*:
97+
*
98+
* ~~~~
99+
* extern mod std;
100+
* use std::base64::ToBase64;
101+
*
102+
* fn main () {
103+
* let str = "Hello, World".to_base64();
104+
* println(fmt!("%s",str));
105+
* }
106+
* ~~~~
107+
*
108+
*/
77109
fn to_base64(&self) -> ~str {
78110
str::to_bytes(*self).to_base64()
79111
}
@@ -84,6 +116,25 @@ pub trait FromBase64 {
84116
}
85117
86118
impl FromBase64 for ~[u8] {
119+
/**
120+
* Convert base64 `u8` vector into u8 byte values.
121+
* Every 4 encoded characters is converted into 3 octets, modulo padding.
122+
*
123+
* *Example*:
124+
*
125+
* ~~~~
126+
* extern mod std;
127+
* use std::base64::ToBase64;
128+
* use std::base64::FromBase64;
129+
*
130+
* fn main () {
131+
* let str = [52,32].to_base64();
132+
* println(fmt!("%s", str));
133+
* let bytes = str.from_base64();
134+
* println(fmt!("%?",bytes));
135+
* }
136+
* ~~~~
137+
*/
87138
fn from_base64(&self) -> ~[u8] {
88139
if self.len() % 4u != 0u { fail!(~"invalid base64 length"); }
89140
@@ -144,6 +195,33 @@ impl FromBase64 for ~[u8] {
144195
}
145196
146197
impl FromBase64 for ~str {
198+
/**
199+
* Convert any base64 encoded string (literal, `@`, `&`, or `~`)
200+
* to the byte values it encodes.
201+
*
202+
* You can use the `from_bytes` function in `core::str`
203+
* to turn a `[u8]` into a string with characters corresponding to those values.
204+
*
205+
* *Example*:
206+
*
207+
* This converts a string literal to base64 and back.
208+
*
209+
* ~~~~
210+
* extern mod std;
211+
* use std::base64::ToBase64;
212+
* use std::base64::FromBase64;
213+
* use core::str;
214+
*
215+
* fn main () {
216+
* let hello_str = "Hello, World".to_base64();
217+
* println(fmt!("%s",hello_str));
218+
* let bytes = hello_str.from_base64();
219+
* println(fmt!("%?",bytes));
220+
* let result_str = str::from_bytes(bytes);
221+
* println(fmt!("%s",result_str));
222+
* }
223+
* ~~~~
224+
*/
147225
fn from_base64(&self) -> ~[u8] {
148226
str::to_bytes(*self).from_base64()
149227
}

0 commit comments

Comments
 (0)