Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustc: De-mode some bits of trans #5246

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ pub fn get_extern_const(externs: ExternMap, llmod: ModuleRef,
}

pub fn trans_foreign_call(cx: block, externs: ExternMap,
llmod: ModuleRef, name: @str, args: ~[ValueRef]) ->
llmod: ModuleRef, name: @str, args: &[ValueRef]) ->
ValueRef {
let _icx = cx.insn_ctxt("trans_foreign_call");
let n = args.len() as int;
Expand Down Expand Up @@ -242,7 +242,7 @@ pub fn bump_ptr(bcx: block, t: ty::t, base: ValueRef, sz: ValueRef) ->
// @llblobptr is the data part of a enum value; its actual type
// is meaningless, as it will be cast away.
pub fn GEP_enum(bcx: block, llblobptr: ValueRef, enum_id: ast::def_id,
variant_id: ast::def_id, ty_substs: ~[ty::t],
variant_id: ast::def_id, ty_substs: &[ty::t],
ix: uint) -> ValueRef {
let _icx = bcx.insn_ctxt("GEP_enum");
let ccx = bcx.ccx();
Expand Down Expand Up @@ -449,7 +449,7 @@ pub fn set_inline_hint(f: ValueRef) {
}
}

pub fn set_inline_hint_if_appr(attrs: ~[ast::attribute],
pub fn set_inline_hint_if_appr(attrs: &[ast::attribute],
llfn: ValueRef) {
match attr::find_inline_attr(attrs) {
attr::ia_hint => set_inline_hint(llfn),
Expand Down Expand Up @@ -489,7 +489,7 @@ pub fn note_unique_llvm_symbol(ccx: @CrateContext, +sym: ~str) {


pub fn get_res_dtor(ccx: @CrateContext, did: ast::def_id,
parent_id: ast::def_id, substs: ~[ty::t])
parent_id: ast::def_id, substs: &[ty::t])
-> ValueRef {
let _icx = ccx.insn_ctxt("trans_res_dtor");
if !substs.is_empty() {
Expand All @@ -516,7 +516,7 @@ pub fn get_res_dtor(ccx: @CrateContext, did: ast::def_id,
}

// Structural comparison: a rather involved form of glue.
pub fn maybe_name_value(cx: @CrateContext, v: ValueRef, s: ~str) {
pub fn maybe_name_value(cx: @CrateContext, v: ValueRef, s: &str) {
if cx.sess.opts.save_temps {
let _: () = str::as_c_str(s, |buf| {
unsafe {
Expand Down Expand Up @@ -641,7 +641,7 @@ pub fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,

fn iter_variant(cx: block, a_tup: ValueRef,
variant: ty::VariantInfo,
tps: ~[ty::t], tid: ast::def_id,
tps: &[ty::t], tid: ast::def_id,
f: val_and_ty_fn) -> block {
let _icx = cx.insn_ctxt("iter_variant");
if variant.args.len() == 0u { return cx; }
Expand Down Expand Up @@ -916,7 +916,7 @@ pub fn have_cached_lpad(bcx: block) -> bool {
return res;
}

pub fn in_lpad_scope_cx(bcx: block, f: fn(&mut scope_info)) {
pub fn in_lpad_scope_cx(bcx: block, f: fn(+si: &mut scope_info)) {
let mut bcx = bcx;
loop {
{
Expand Down Expand Up @@ -1652,7 +1652,7 @@ pub fn new_fn_ctxt(ccx: @CrateContext,
// field of the fn_ctxt with
pub fn create_llargs_for_fn_args(cx: fn_ctxt,
ty_self: self_arg,
args: ~[ast::arg]) -> ~[ValueRef] {
args: &[ast::arg]) -> ~[ValueRef] {
let _icx = cx.insn_ctxt("create_llargs_for_fn_args");

match ty_self {
Expand Down Expand Up @@ -1865,7 +1865,7 @@ pub fn trans_fn(ccx: @CrateContext,
debug!("trans_fn(ty_self=%?)", ty_self);
let _icx = ccx.insn_ctxt("trans_fn");
ccx.stats.n_fns += 1;
let the_path_str = path_str(ccx.sess, path);
let the_path_str = path_str(ccx.sess, &path);
trans_closure(ccx, path, decl, body, llfndecl, ty_self,
param_substs, id, impl_id,
|fcx| {
Expand All @@ -1883,7 +1883,7 @@ pub fn trans_fn(ccx: @CrateContext,
pub fn trans_enum_variant(ccx: @CrateContext,
enum_id: ast::node_id,
variant: ast::variant,
args: ~[ast::variant_arg],
args: &[ast::variant_arg],
disr: int,
is_degen: bool,
param_substs: Option<@param_substs>,
Expand Down Expand Up @@ -1946,7 +1946,7 @@ pub fn trans_enum_variant(ccx: @CrateContext,
// NB: In theory this should be merged with the function above. But the AST
// structures are completely different, so very little code would be shared.
pub fn trans_tuple_struct(ccx: @CrateContext,
fields: ~[@ast::struct_field],
fields: &[@ast::struct_field],
ctor_id: ast::node_id,
param_substs: Option<@param_substs>,
llfndecl: ValueRef) {
Expand Down Expand Up @@ -2847,7 +2847,7 @@ pub fn trap(bcx: block) {
}
}

pub fn decl_gc_metadata(ccx: @CrateContext, llmod_id: ~str) {
pub fn decl_gc_metadata(ccx: @CrateContext, llmod_id: &str) {
if !ccx.sess.opts.gc || !*ccx.uses_gc {
return;
}
Expand Down Expand Up @@ -3014,7 +3014,7 @@ pub fn trans_crate(sess: session::Session,
tcx: ty::ctxt,
output: &Path,
emap2: resolve::ExportMap2,
maps: astencode::Maps) -> (ModuleRef, LinkMeta) {
+maps: astencode::Maps) -> (ModuleRef, LinkMeta) {

let symbol_hasher = @hash::default_state();
let link_meta =
Expand Down
19 changes: 9 additions & 10 deletions src/librustc/middle/trans/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub fn Ret(cx: block, V: ValueRef) {
}
}

pub fn AggregateRet(cx: block, RetVals: ~[ValueRef]) {
pub fn AggregateRet(cx: block, RetVals: &[ValueRef]) {
if cx.unreachable { return; }
check_not_terminated(cx);
terminate(cx, "AggregateRet");
Expand Down Expand Up @@ -184,7 +184,7 @@ pub fn noname() -> *libc::c_char {
}
}

pub fn Invoke(cx: block, Fn: ValueRef, Args: ~[ValueRef],
pub fn Invoke(cx: block, Fn: ValueRef, Args: &[ValueRef],
Then: BasicBlockRef, Catch: BasicBlockRef) {
if cx.unreachable { return; }
check_not_terminated(cx);
Expand All @@ -202,7 +202,7 @@ pub fn Invoke(cx: block, Fn: ValueRef, Args: ~[ValueRef],
}
}

pub fn FastInvoke(cx: block, Fn: ValueRef, Args: ~[ValueRef],
pub fn FastInvoke(cx: block, Fn: ValueRef, Args: &[ValueRef],
Then: BasicBlockRef, Catch: BasicBlockRef) {
if cx.unreachable { return; }
check_not_terminated(cx);
Expand Down Expand Up @@ -567,7 +567,7 @@ pub fn Store(cx: block, Val: ValueRef, Ptr: ValueRef) {
}
}

pub fn GEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) -> ValueRef {
pub fn GEP(cx: block, Pointer: ValueRef, Indices: &[ValueRef]) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_nil())); }
count_insn(cx, "gep");
Expand Down Expand Up @@ -810,7 +810,7 @@ pub fn EmptyPhi(cx: block, Ty: TypeRef) -> ValueRef {
}
}

pub fn Phi(cx: block, Ty: TypeRef, vals: ~[ValueRef], bbs: ~[BasicBlockRef])
pub fn Phi(cx: block, Ty: TypeRef, vals: &[ValueRef], bbs: &[BasicBlockRef])
-> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(Ty); }
Expand Down Expand Up @@ -844,11 +844,10 @@ pub fn _UndefReturn(cx: block, Fn: ValueRef) -> ValueRef {
}
}

pub fn add_span_comment(bcx: block, sp: span, text: ~str) {
pub fn add_span_comment(bcx: block, sp: span, text: &str) {
let ccx = bcx.ccx();
if !ccx.sess.no_asm_comments() {
let s = text + ~" (" + ccx.sess.codemap.span_to_str(sp)
+ ~")";
let s = fmt!("%s (%s)", text, ccx.sess.codemap.span_to_str(sp));
log(debug, copy s);
add_comment(bcx, s);
}
Expand Down Expand Up @@ -888,7 +887,7 @@ pub fn Call(cx: block, Fn: ValueRef, Args: &[ValueRef]) -> ValueRef {
}
}

pub fn FastCall(cx: block, Fn: ValueRef, Args: ~[ValueRef]) -> ValueRef {
pub fn FastCall(cx: block, Fn: ValueRef, Args: &[ValueRef]) -> ValueRef {
if cx.unreachable { return _UndefReturn(cx, Fn); }
unsafe {
count_insn(cx, "fastcall");
Expand All @@ -899,7 +898,7 @@ pub fn FastCall(cx: block, Fn: ValueRef, Args: ~[ValueRef]) -> ValueRef {
}
}

pub fn CallWithConv(cx: block, Fn: ValueRef, Args: ~[ValueRef],
pub fn CallWithConv(cx: block, Fn: ValueRef, Args: &[ValueRef],
Conv: CallConv) -> ValueRef {
if cx.unreachable { return _UndefReturn(cx, Fn); }
unsafe {
Expand Down
12 changes: 6 additions & 6 deletions src/librustc/middle/trans/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ pub fn trans_fn_ref_with_vtables_to_callee(
bcx: block,
def_id: ast::def_id,
ref_id: ast::node_id,
+type_params: ~[ty::t],
type_params: &[ty::t],
vtables: Option<typeck::vtable_res>)
-> Callee {
Callee {bcx: bcx,
Expand All @@ -199,7 +199,7 @@ pub fn trans_fn_ref_with_vtables(
bcx: block, //
def_id: ast::def_id, // def id of fn
ref_id: ast::node_id, // node id of use of fn; may be zero if N/A
+type_params: ~[ty::t], // values for fn's ty params
type_params: &[ty::t], // values for fn's ty params
vtables: Option<typeck::vtable_res>)
-> FnData {
//!
Expand Down Expand Up @@ -378,7 +378,7 @@ pub fn trans_lang_call(bcx: block,
pub fn trans_lang_call_with_type_params(bcx: block,
did: ast::def_id,
args: &[ValueRef],
type_params: ~[ty::t],
type_params: &[ty::t],
dest: expr::Dest)
-> block {
let fty;
Expand All @@ -394,7 +394,7 @@ pub fn trans_lang_call_with_type_params(bcx: block,
|bcx| {
let callee =
trans_fn_ref_with_vtables_to_callee(bcx, did, 0,
copy type_params,
type_params,
None);

let new_llval;
Expand Down Expand Up @@ -636,8 +636,8 @@ pub enum AutorefArg {
pub fn trans_arg_expr(bcx: block,
formal_ty: ty::arg,
arg_expr: @ast::expr,
temp_cleanups: &mut ~[ValueRef],
ret_flag: Option<ValueRef>,
+temp_cleanups: &mut ~[ValueRef],
+ret_flag: Option<ValueRef>,
+autoref_arg: AutorefArg) -> Result {
let _icx = bcx.insn_ctxt("trans_arg_expr");
let ccx = bcx.ccx();
Expand Down
39 changes: 19 additions & 20 deletions src/librustc/middle/trans/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,12 @@ use syntax::codemap::span;
use syntax::parse::token::ident_interner;
use syntax::{ast, ast_map};

pub type namegen = @fn(~str) -> ident;
pub type namegen = @fn(+s: ~str) -> ident;
pub fn new_namegen(intr: @ident_interner) -> namegen {
let f: @fn(~str) -> ident = |prefix| {
// XXX: Bad copies.
let f: @fn(+s: ~str) -> ident = |prefix| {
intr.gensym(@fmt!("%s_%u",
prefix,
intr.gensym(@copy prefix).repr))
intr.gensym(@prefix).repr))
};
f
}
Expand Down Expand Up @@ -325,10 +324,10 @@ pub struct fn_ctxt_ {

pub type fn_ctxt = @mut fn_ctxt_;

pub fn warn_not_to_commit(ccx: @CrateContext, msg: ~str) {
pub fn warn_not_to_commit(ccx: @CrateContext, msg: &str) {
if !*ccx.do_not_commit_warning_issued {
*ccx.do_not_commit_warning_issued = true;
ccx.sess.warn(msg + ~" -- do not commit like this!");
ccx.sess.warn(msg.to_str() + ~" -- do not commit like this!");
}
}

Expand Down Expand Up @@ -358,7 +357,7 @@ pub struct cleanup_path {
dest: BasicBlockRef
}

pub fn scope_clean_changed(scope_info: &mut scope_info) {
pub fn scope_clean_changed(+scope_info: &mut scope_info) {
if scope_info.cleanup_paths.len() > 0u { scope_info.cleanup_paths = ~[]; }
scope_info.landing_pad = None;
}
Expand Down Expand Up @@ -625,7 +624,7 @@ pub fn rslt(bcx: block, val: ValueRef) -> Result {
}

pub impl Result {
fn unpack(&self, bcx: &mut block) -> ValueRef {
fn unpack(&self, +bcx: &mut block) -> ValueRef {
*bcx = self.bcx;
return self.val;
}
Expand All @@ -645,7 +644,7 @@ pub fn val_str(tn: @TypeNames, v: ValueRef) -> @str {
return ty_str(tn, val_ty(v));
}

pub fn in_scope_cx(cx: block, f: &fn(&mut scope_info)) {
pub fn in_scope_cx(cx: block, f: &fn(+si: &mut scope_info)) {
let mut cur = cx;
loop {
{
Expand Down Expand Up @@ -811,7 +810,7 @@ pub fn T_size_t(targ_cfg: @session::config) -> TypeRef {
return T_int(targ_cfg);
}

pub fn T_fn(inputs: ~[TypeRef], output: TypeRef) -> TypeRef {
pub fn T_fn(inputs: &[TypeRef], output: TypeRef) -> TypeRef {
unsafe {
return llvm::LLVMFunctionType(output, to_ptr(inputs),
inputs.len() as c_uint,
Expand All @@ -835,22 +834,22 @@ pub fn T_root(t: TypeRef, addrspace: addrspace) -> TypeRef {
}
}

pub fn T_struct(elts: ~[TypeRef]) -> TypeRef {
pub fn T_struct(elts: &[TypeRef]) -> TypeRef {
unsafe {
return llvm::LLVMStructType(to_ptr(elts),
elts.len() as c_uint,
False);
}
}

pub fn T_named_struct(name: ~str) -> TypeRef {
pub fn T_named_struct(name: &str) -> TypeRef {
unsafe {
let c = llvm::LLVMGetGlobalContext();
return str::as_c_str(name, |buf| llvm::LLVMStructCreateNamed(c, buf));
}
}

pub fn set_struct_body(t: TypeRef, elts: ~[TypeRef]) {
pub fn set_struct_body(t: TypeRef, elts: &[TypeRef]) {
unsafe {
llvm::LLVMStructSetBody(t,
to_ptr(elts),
Expand Down Expand Up @@ -1094,7 +1093,7 @@ pub fn C_integral(t: TypeRef, u: u64, sign_extend: Bool) -> ValueRef {
}
}

pub fn C_floating(s: ~str, t: TypeRef) -> ValueRef {
pub fn C_floating(s: &str, t: TypeRef) -> ValueRef {
unsafe {
return str::as_c_str(s, |buf| llvm::LLVMConstRealOfString(t, buf));
}
Expand Down Expand Up @@ -1169,7 +1168,7 @@ pub fn C_estr_slice(cx: @CrateContext, s: @~str) -> ValueRef {
}

// Returns a Plain Old LLVM String:
pub fn C_postr(s: ~str) -> ValueRef {
pub fn C_postr(s: &str) -> ValueRef {
unsafe {
return do str::as_c_str(s) |buf| {
llvm::LLVMConstString(buf, str::len(s) as c_uint, False)
Expand Down Expand Up @@ -1212,22 +1211,22 @@ pub fn C_named_struct(T: TypeRef, elts: &[ValueRef]) -> ValueRef {
}
}

pub fn C_array(ty: TypeRef, elts: ~[ValueRef]) -> ValueRef {
pub fn C_array(ty: TypeRef, elts: &[ValueRef]) -> ValueRef {
unsafe {
return llvm::LLVMConstArray(ty, vec::raw::to_ptr(elts),
elts.len() as c_uint);
}
}

pub fn C_bytes(bytes: ~[u8]) -> ValueRef {
pub fn C_bytes(bytes: &[u8]) -> ValueRef {
unsafe {
return llvm::LLVMConstString(
cast::reinterpret_cast(&vec::raw::to_ptr(bytes)),
bytes.len() as c_uint, True);
}
}

pub fn C_bytes_plus_null(bytes: ~[u8]) -> ValueRef {
pub fn C_bytes_plus_null(bytes: &[u8]) -> ValueRef {
unsafe {
return llvm::LLVMConstString(
cast::reinterpret_cast(&vec::raw::to_ptr(bytes)),
Expand Down Expand Up @@ -1311,9 +1310,9 @@ pub fn align_to(cx: block, off: ValueRef, align: ValueRef) -> ValueRef {
return build::And(cx, bumped, build::Not(cx, mask));
}

pub fn path_str(sess: session::Session, p: path) -> ~str {
pub fn path_str(sess: session::Session, p: &path) -> ~str {
let mut r = ~"", first = true;
for vec::each(p) |e| {
for vec::each(*p) |e| {
match *e {
ast_map::path_name(s) | ast_map::path_mod(s) => {
if first { first = false; }
Expand Down
Loading