Include @ in crate_ctxt and fn_ctxt type definitions

So that code using them doesn't have to spell it out constantly.
This commit is contained in:
Marijn Haverbeke 2012-02-21 15:11:20 +01:00
parent b1d7f252a9
commit d85d4f55f7
10 changed files with 160 additions and 160 deletions

View File

@ -501,7 +501,7 @@ fn symbol_hash(tcx: ty::ctxt, sha: sha1, t: ty::t, link_meta: link_meta) ->
ret "_" + hash;
}
fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> str {
fn get_symbol_hash(ccx: crate_ctxt, t: ty::t) -> str {
let hash = "";
alt ccx.type_sha1s.find(t) {
some(h) { hash = h; }
@ -533,28 +533,28 @@ fn exported_name(path: path, hash: str, _vers: str) -> str {
}
fn mangle_exported_name(ccx: @crate_ctxt, path: path, t: ty::t) -> str {
fn mangle_exported_name(ccx: crate_ctxt, path: path, t: ty::t) -> str {
let hash = get_symbol_hash(ccx, t);
ret exported_name(path, hash, ccx.link_meta.vers);
}
fn mangle_internal_name_by_type_only(ccx: @crate_ctxt, t: ty::t, name: str) ->
fn mangle_internal_name_by_type_only(ccx: crate_ctxt, t: ty::t, name: str) ->
str {
let s = util::ppaux::ty_to_short_str(ccx.tcx, t);
let hash = get_symbol_hash(ccx, t);
ret mangle([path_name(name), path_name(s), path_name(hash)]);
}
fn mangle_internal_name_by_path_and_seq(ccx: @crate_ctxt, path: path,
fn mangle_internal_name_by_path_and_seq(ccx: crate_ctxt, path: path,
flav: str) -> str {
ret mangle(path + [path_name(ccx.names(flav))]);
}
fn mangle_internal_name_by_path(_ccx: @crate_ctxt, path: path) -> str {
fn mangle_internal_name_by_path(_ccx: crate_ctxt, path: path) -> str {
ret mangle(path);
}
fn mangle_internal_name_by_seq(ccx: @crate_ctxt, flav: str) -> str {
fn mangle_internal_name_by_seq(ccx: crate_ctxt, flav: str) -> str {
ret ccx.names(flav);
}

View File

@ -19,7 +19,7 @@ export encoded_ty;
type abbrev_map = map::hashmap<ty::t, tyencode::ty_abbrev>;
type encode_ctxt = {ccx: @crate_ctxt, type_abbrevs: abbrev_map};
type encode_ctxt = {ccx: crate_ctxt, type_abbrevs: abbrev_map};
// Path table encoding
fn encode_name(ebml_w: ebml::writer, name: str) {
@ -702,7 +702,7 @@ fn encode_hash(ebml_w: ebml::writer, hash: str) {
ebml::end_tag(ebml_w);
}
fn encode_metadata(cx: @crate_ctxt, crate: @crate) -> [u8] {
fn encode_metadata(cx: crate_ctxt, crate: @crate) -> [u8] {
let abbrevs = ty::new_ty_hash();
let ecx = @{ccx: cx, type_abbrevs: abbrevs};

View File

@ -63,7 +63,7 @@ fn trans_opt(bcx: block, o: opt) -> opt_result {
}
}
fn variant_opt(ccx: @crate_ctxt, pat_id: ast::node_id) -> opt {
fn variant_opt(ccx: crate_ctxt, pat_id: ast::node_id) -> opt {
let vdef = ast_util::variant_def_ids(ccx.tcx.def_map.get(pat_id));
let variants = ty::enum_variants(ccx.tcx, vdef.enm);
for v: ty::variant_info in *variants {
@ -155,10 +155,10 @@ fn enter_default(m: match, col: uint, val: ValueRef) -> match {
ret enter_match(m, col, val, e);
}
fn enter_opt(ccx: @crate_ctxt, m: match, opt: opt, col: uint, enum_size: uint,
fn enter_opt(ccx: crate_ctxt, m: match, opt: opt, col: uint, enum_size: uint,
val: ValueRef) -> match {
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
fn e(ccx: @crate_ctxt, dummy: @ast::pat, opt: opt, size: uint,
fn e(ccx: crate_ctxt, dummy: @ast::pat, opt: opt, size: uint,
p: @ast::pat) -> option<[@ast::pat]> {
alt p.node {
ast::pat_enum(ctor, subpats) {
@ -235,7 +235,7 @@ fn enter_uniq(m: match, col: uint, val: ValueRef) -> match {
ret enter_match(m, col, val, bind e(dummy, _));
}
fn get_options(ccx: @crate_ctxt, m: match, col: uint) -> [opt] {
fn get_options(ccx: crate_ctxt, m: match, col: uint) -> [opt] {
fn add_to_set(&set: [opt], val: opt) {
for l: opt in set { if opt_eq(l, val) { ret; } }
set += [val];

View File

@ -46,7 +46,7 @@ import build::*;
import shape::*;
import ast_map::{path, path_mod, path_name};
fn type_of_explicit_args(cx: @crate_ctxt, inputs: [ty::arg]) -> [TypeRef] {
fn type_of_explicit_args(cx: crate_ctxt, inputs: [ty::arg]) -> [TypeRef] {
vec::map(inputs) {|arg|
let arg_ty = arg.ty;
let llty = type_of(cx, arg_ty);
@ -64,7 +64,7 @@ fn type_of_explicit_args(cx: @crate_ctxt, inputs: [ty::arg]) -> [TypeRef] {
// - create_llargs_for_fn_args.
// - new_fn_ctxt
// - trans_args
fn type_of_fn(cx: @crate_ctxt, inputs: [ty::arg],
fn type_of_fn(cx: crate_ctxt, inputs: [ty::arg],
output: ty::t, params: [ty::param_bounds]) -> TypeRef {
let atys: [TypeRef] = [];
@ -90,12 +90,12 @@ fn type_of_fn(cx: @crate_ctxt, inputs: [ty::arg],
}
// Given a function type and a count of ty params, construct an llvm type
fn type_of_fn_from_ty(cx: @crate_ctxt, fty: ty::t,
fn type_of_fn_from_ty(cx: crate_ctxt, fty: ty::t,
param_bounds: [ty::param_bounds]) -> TypeRef {
type_of_fn(cx, ty::ty_fn_args(fty), ty::ty_fn_ret(fty), param_bounds)
}
fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
fn type_of(cx: crate_ctxt, t: ty::t) -> TypeRef {
assert !ty::type_has_vars(t);
// Check the cache.
@ -159,7 +159,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
ret llty;
}
fn type_of_enum(cx: @crate_ctxt, did: ast::def_id, t: ty::t)
fn type_of_enum(cx: crate_ctxt, did: ast::def_id, t: ty::t)
-> TypeRef {
let degen = (*ty::enum_variants(cx.tcx, did)).len() == 1u;
if check type_has_static_size(cx, t) {
@ -175,7 +175,7 @@ fn type_of_enum(cx: @crate_ctxt, did: ast::def_id, t: ty::t)
}
fn type_of_ty_param_bounds_and_ty
(ccx: @crate_ctxt, tpt: ty::ty_param_bounds_and_ty) -> TypeRef {
(ccx: crate_ctxt, tpt: ty::ty_param_bounds_and_ty) -> TypeRef {
let t = tpt.ty;
alt ty::get(t).struct {
ty::ty_fn(_) {
@ -188,7 +188,7 @@ fn type_of_ty_param_bounds_and_ty
type_of(ccx, t)
}
fn type_of_or_i8(ccx: @crate_ctxt, typ: ty::t) -> TypeRef {
fn type_of_or_i8(ccx: crate_ctxt, typ: ty::t) -> TypeRef {
if check type_has_static_size(ccx, typ) {
type_of(ccx, typ)
} else { T_i8() }
@ -223,7 +223,7 @@ fn sanitize(s: str) -> str {
}
fn log_fn_time(ccx: @crate_ctxt, name: str, start: time::timeval,
fn log_fn_time(ccx: crate_ctxt, name: str, start: time::timeval,
end: time::timeval) {
let elapsed = 1000 * ((end.sec - start.sec) as int) +
((end.usec as int) - (start.usec as int)) / 1000;
@ -343,7 +343,7 @@ fn dynastack_alloca(cx: block, t: TypeRef, n: ValueRef, ty: ty::t) ->
ret PointerCast(dy_cx, llresult, T_ptr(t));
}
fn mk_obstack_token(ccx: @crate_ctxt, fcx: @fn_ctxt) ->
fn mk_obstack_token(ccx: crate_ctxt, fcx: fn_ctxt) ->
ValueRef {
let cx = raw_block(fcx, fcx.lldynamicallocas);
ret Call(cx, ccx.upcalls.dynastack_mark, []);
@ -686,7 +686,7 @@ fn get_tydesc(cx: block, t: ty::t, escapes: bool,
ret rslt(cx, info.tydesc);
}
fn get_static_tydesc(ccx: @crate_ctxt, t: ty::t, ty_params: [uint])
fn get_static_tydesc(ccx: crate_ctxt, t: ty::t, ty_params: [uint])
-> @tydesc_info {
alt ccx.tydescs.find(t) {
some(info) { ret info; }
@ -729,7 +729,7 @@ fn set_glue_inlining(f: ValueRef, t: ty::t) {
// Generates the declaration for (but doesn't emit) a type descriptor.
fn declare_tydesc(ccx: @crate_ctxt, t: ty::t, ty_params: [uint])
fn declare_tydesc(ccx: crate_ctxt, t: ty::t, ty_params: [uint])
-> @tydesc_info {
log(debug, "+++ declare_tydesc " + ty_to_str(ccx.tcx, t));
let llsize;
@ -768,7 +768,7 @@ fn declare_tydesc(ccx: @crate_ctxt, t: ty::t, ty_params: [uint])
type glue_helper = fn@(block, ValueRef, ty::t);
fn declare_generic_glue(ccx: @crate_ctxt, t: ty::t, llfnty: TypeRef,
fn declare_generic_glue(ccx: crate_ctxt, t: ty::t, llfnty: TypeRef,
name: str) -> ValueRef {
let name = name;
let fn_nm;
@ -781,7 +781,7 @@ fn declare_generic_glue(ccx: @crate_ctxt, t: ty::t, llfnty: TypeRef,
ret llfn;
}
fn make_generic_glue_inner(ccx: @crate_ctxt, t: ty::t,
fn make_generic_glue_inner(ccx: crate_ctxt, t: ty::t,
llfn: ValueRef, helper: glue_helper,
ty_params: [uint]) -> ValueRef {
let fcx = new_fn_ctxt(ccx, [], llfn, none);
@ -819,7 +819,7 @@ fn make_generic_glue_inner(ccx: @crate_ctxt, t: ty::t,
ret llfn;
}
fn make_generic_glue(ccx: @crate_ctxt, t: ty::t, llfn: ValueRef,
fn make_generic_glue(ccx: crate_ctxt, t: ty::t, llfn: ValueRef,
helper: glue_helper, ty_params: [uint], name: str)
-> ValueRef {
if !ccx.sess.opts.stats {
@ -834,7 +834,7 @@ fn make_generic_glue(ccx: @crate_ctxt, t: ty::t, llfn: ValueRef,
ret llval;
}
fn emit_tydescs(ccx: @crate_ctxt) {
fn emit_tydescs(ccx: crate_ctxt) {
ccx.tydescs.items {|key, val|
let glue_fn_ty = T_ptr(T_glue_fn(ccx));
let ti = val;
@ -1076,7 +1076,7 @@ fn decr_refcnt_maybe_free(bcx: block, box_ptr: ValueRef, t: ty::t) -> block {
}
// Structural comparison: a rather involved form of glue.
fn maybe_name_value(cx: @crate_ctxt, v: ValueRef, s: str) {
fn maybe_name_value(cx: crate_ctxt, v: ValueRef, s: str) {
if cx.sess.opts.save_temps {
let _: () = str::as_buf(s, {|buf| llvm::LLVMSetValueName(v, buf) });
}
@ -1279,21 +1279,21 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
ret cx;
}
fn lazily_emit_all_tydesc_glue(ccx: @crate_ctxt,
fn lazily_emit_all_tydesc_glue(ccx: crate_ctxt,
static_ti: option<@tydesc_info>) {
lazily_emit_tydesc_glue(ccx, abi::tydesc_field_take_glue, static_ti);
lazily_emit_tydesc_glue(ccx, abi::tydesc_field_drop_glue, static_ti);
lazily_emit_tydesc_glue(ccx, abi::tydesc_field_free_glue, static_ti);
}
fn lazily_emit_all_generic_info_tydesc_glues(ccx: @crate_ctxt,
fn lazily_emit_all_generic_info_tydesc_glues(ccx: crate_ctxt,
gi: generic_info) {
for ti: option<@tydesc_info> in gi.static_tis {
lazily_emit_all_tydesc_glue(ccx, ti);
}
}
fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: int,
fn lazily_emit_tydesc_glue(ccx: crate_ctxt, field: int,
static_ti: option<@tydesc_info>) {
alt static_ti {
none { }
@ -1612,7 +1612,7 @@ fn store_temp_expr(cx: block, action: copy_action, dst: ValueRef,
ret move_val(cx, action, dst, src, t);
}
fn trans_crate_lit(cx: @crate_ctxt, lit: ast::lit) -> ValueRef {
fn trans_crate_lit(cx: crate_ctxt, lit: ast::lit) -> ValueRef {
alt lit.node {
ast::lit_int(i, t) { C_integral(T_int_ty(cx, t), i as u64, True) }
ast::lit_uint(u, t) { C_integral(T_uint_ty(cx, t), u, False) }
@ -2147,7 +2147,7 @@ fn trans_external_path(cx: block, did: ast::def_id,
type_of_ty_param_bounds_and_ty(ccx, tpt));
}
fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, substs: [ty::t],
fn monomorphic_fn(ccx: crate_ctxt, fn_id: ast::def_id, substs: [ty::t],
dicts: option<typeck::dict_res>)
-> option<{llfn: ValueRef, fty: ty::t}> {
let substs = vec::map(substs, {|t|
@ -2290,7 +2290,7 @@ fn lval_static_fn(bcx: block, fn_id: ast::def_id, id: ast::node_id,
ret {bcx: bcx, val: val, kind: owned, env: null_env, generic: gen};
}
fn lookup_discriminant(ccx: @crate_ctxt, vid: ast::def_id) -> ValueRef {
fn lookup_discriminant(ccx: crate_ctxt, vid: ast::def_id) -> ValueRef {
alt ccx.discrims.find(vid) {
none {
// It's an external discriminant that we haven't seen yet.
@ -3603,7 +3603,7 @@ fn trans_stmt(cx: block, s: ast::stmt) -> block {
// You probably don't want to use this one. See the
// next three functions instead.
fn new_block(cx: @fn_ctxt, parent: block_parent, kind: block_kind,
fn new_block(cx: fn_ctxt, parent: block_parent, kind: block_kind,
name: str, block_span: option<span>) -> block {
let s = "";
if cx.ccx.sess.opts.save_temps || cx.ccx.sess.opts.debuginfo {
@ -3634,7 +3634,7 @@ fn simple_block_scope() -> block_kind {
}
// Use this when you're at the top block of a function or the like.
fn top_scope_block(fcx: @fn_ctxt, sp: option<span>) -> block {
fn top_scope_block(fcx: fn_ctxt, sp: option<span>) -> block {
ret new_block(fcx, parent_none, simple_block_scope(),
"function top level", sp);
}
@ -3661,7 +3661,7 @@ fn sub_block(bcx: block, n: str) -> block {
ret new_block(bcx.fcx, parent_some(bcx), block_non_scope, n, none);
}
fn raw_block(fcx: @fn_ctxt, llbb: BasicBlockRef) -> block {
fn raw_block(fcx: fn_ctxt, llbb: BasicBlockRef) -> block {
ret @{llbb: llbb,
mutable terminated: false,
mutable unreachable: false,
@ -3764,7 +3764,7 @@ fn with_cond(bcx: block, val: ValueRef, f: fn(block) -> block) -> block {
next_cx
}
fn trans_fn_cleanups(fcx: @fn_ctxt, cx: block) {
fn trans_fn_cleanups(fcx: fn_ctxt, cx: block) {
option::may(fcx.llobstacktoken) {|lltoken|
Call(cx, fcx.ccx.upcalls.dynastack_free, [lltoken]);
}
@ -3889,10 +3889,10 @@ fn mk_standard_basic_blocks(llfn: ValueRef) ->
// - create_llargs_for_fn_args.
// - new_fn_ctxt
// - trans_args
fn new_fn_ctxt_w_id(ccx: @crate_ctxt, path: path,
fn new_fn_ctxt_w_id(ccx: crate_ctxt, path: path,
llfndecl: ValueRef, id: ast::node_id,
param_substs: option<param_substs>,
sp: option<span>) -> @fn_ctxt {
sp: option<span>) -> fn_ctxt {
let llbbs = mk_standard_basic_blocks(llfndecl);
ret @{llfn: llfndecl,
llenv: llvm::LLVMGetParam(llfndecl, 1u as c_uint),
@ -3918,8 +3918,8 @@ fn new_fn_ctxt_w_id(ccx: @crate_ctxt, path: path,
ccx: ccx};
}
fn new_fn_ctxt(ccx: @crate_ctxt, path: path, llfndecl: ValueRef,
sp: option<span>) -> @fn_ctxt {
fn new_fn_ctxt(ccx: crate_ctxt, path: path, llfndecl: ValueRef,
sp: option<span>) -> fn_ctxt {
ret new_fn_ctxt_w_id(ccx, path, llfndecl, -1, none, sp);
}
@ -3937,7 +3937,7 @@ fn new_fn_ctxt(ccx: @crate_ctxt, path: path, llfndecl: ValueRef,
// spaces that have been created for them (by code in the llallocas field of
// the function's fn_ctxt). create_llargs_for_fn_args populates the llargs
// field of the fn_ctxt with
fn create_llargs_for_fn_args(cx: @fn_ctxt, ty_self: self_arg,
fn create_llargs_for_fn_args(cx: fn_ctxt, ty_self: self_arg,
args: [ast::arg], ty_params: [ast::ty_param]) {
// Skip the implicit arguments 0, and 1.
let arg_n = first_tp_arg;
@ -3980,7 +3980,7 @@ fn create_llargs_for_fn_args(cx: @fn_ctxt, ty_self: self_arg,
}
}
fn copy_args_to_allocas(fcx: @fn_ctxt, bcx: block, args: [ast::arg],
fn copy_args_to_allocas(fcx: fn_ctxt, bcx: block, args: [ast::arg],
arg_tys: [ty::arg]) -> block {
let tcx = bcx.tcx();
let arg_n: uint = 0u, bcx = bcx;
@ -4017,14 +4017,14 @@ fn copy_args_to_allocas(fcx: @fn_ctxt, bcx: block, args: [ast::arg],
// Ties up the llstaticallocas -> llloadenv -> llderivedtydescs ->
// lldynamicallocas -> lltop edges, and builds the return block.
fn finish_fn(fcx: @fn_ctxt, lltop: BasicBlockRef) {
fn finish_fn(fcx: fn_ctxt, lltop: BasicBlockRef) {
tie_up_header_blocks(fcx, lltop);
let ret_cx = raw_block(fcx, fcx.llreturn);
trans_fn_cleanups(fcx, ret_cx);
RetVoid(ret_cx);
}
fn tie_up_header_blocks(fcx: @fn_ctxt, lltop: BasicBlockRef) {
fn tie_up_header_blocks(fcx: fn_ctxt, lltop: BasicBlockRef) {
Br(raw_block(fcx, fcx.llstaticallocas), fcx.llloadenv);
Br(raw_block(fcx, fcx.llloadenv), fcx.llderivedtydescs_first);
Br(raw_block(fcx, fcx.llderivedtydescs), fcx.lldynamicallocas);
@ -4036,11 +4036,11 @@ enum self_arg { impl_self(ty::t), no_self, }
// trans_closure: Builds an LLVM function out of a source function.
// If the function closes over its environment a closure will be
// returned.
fn trans_closure(ccx: @crate_ctxt, path: path, decl: ast::fn_decl,
fn trans_closure(ccx: crate_ctxt, path: path, decl: ast::fn_decl,
body: ast::blk, llfndecl: ValueRef,
ty_self: self_arg, ty_params: [ast::ty_param],
param_substs: option<param_substs>,
id: ast::node_id, maybe_load_env: fn(@fn_ctxt)) {
id: ast::node_id, maybe_load_env: fn(fn_ctxt)) {
set_uwtable(llfndecl);
// Set up arguments to the function.
@ -4078,7 +4078,7 @@ fn trans_closure(ccx: @crate_ctxt, path: path, decl: ast::fn_decl,
// trans_fn: creates an LLVM function corresponding to a source language
// function.
fn trans_fn(ccx: @crate_ctxt, path: path, decl: ast::fn_decl,
fn trans_fn(ccx: crate_ctxt, path: path, decl: ast::fn_decl,
body: ast::blk, llfndecl: ValueRef, ty_self: self_arg,
ty_params: [ast::ty_param], param_substs: option<param_substs>,
id: ast::node_id) {
@ -4097,7 +4097,7 @@ fn trans_fn(ccx: @crate_ctxt, path: path, decl: ast::fn_decl,
}
}
fn trans_res_ctor(ccx: @crate_ctxt, path: path, dtor: ast::fn_decl,
fn trans_res_ctor(ccx: crate_ctxt, path: path, dtor: ast::fn_decl,
ctor_id: ast::node_id, ty_params: [ast::ty_param],
param_substs: option<param_substs>, llfndecl: ValueRef) {
// Create a function for the constructor
@ -4131,7 +4131,7 @@ fn trans_res_ctor(ccx: @crate_ctxt, path: path, dtor: ast::fn_decl,
}
fn trans_enum_variant(ccx: @crate_ctxt, enum_id: ast::node_id,
fn trans_enum_variant(ccx: crate_ctxt, enum_id: ast::node_id,
variant: ast::variant, disr: int, is_degen: bool,
ty_params: [ast::ty_param],
param_substs: option<param_substs>,
@ -4200,7 +4200,7 @@ fn trans_enum_variant(ccx: @crate_ctxt, enum_id: ast::node_id,
// FIXME: this should do some structural hash-consing to avoid
// duplicate constants. I think. Maybe LLVM has a magical mode
// that does so later on?
fn trans_const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
fn trans_const_expr(cx: crate_ctxt, e: @ast::expr) -> ValueRef {
alt e.node {
ast::expr_lit(lit) { ret trans_crate_lit(cx, *lit); }
ast::expr_binary(b, e1, e2) {
@ -4271,7 +4271,7 @@ fn trans_const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
}
}
fn trans_const(cx: @crate_ctxt, e: @ast::expr, id: ast::node_id) {
fn trans_const(cx: crate_ctxt, e: @ast::expr, id: ast::node_id) {
let v = trans_const_expr(cx, e);
// The scalars come back as 1st class LLVM vals
@ -4286,7 +4286,7 @@ fn trans_const(cx: @crate_ctxt, e: @ast::expr, id: ast::node_id) {
}
}
fn trans_item(ccx: @crate_ctxt, item: ast::item) {
fn trans_item(ccx: crate_ctxt, item: ast::item) {
let path = alt check ccx.tcx.items.get(item.id) {
ast_map::node_item(_, p) { p }
};
@ -4358,7 +4358,7 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
// separate modules in the compiled program. That's because modules exist
// only as a convenience for humans working with the code, to organize names
// and control visibility.
fn trans_mod(ccx: @crate_ctxt, m: ast::_mod) {
fn trans_mod(ccx: crate_ctxt, m: ast::_mod) {
for item in m.items { trans_item(ccx, *item); }
}
@ -4367,17 +4367,17 @@ fn get_pair_fn_ty(llpairty: TypeRef) -> TypeRef {
ret struct_elt(llpairty, 0u);
}
fn register_fn(ccx: @crate_ctxt, sp: span, path: path, flav: str,
fn register_fn(ccx: crate_ctxt, sp: span, path: path, flav: str,
ty_params: [ast::ty_param], node_id: ast::node_id) {
let t = ty::node_id_to_type(ccx.tcx, node_id);
register_fn_full(ccx, sp, path, flav, ty_params, node_id, t);
}
fn param_bounds(ccx: @crate_ctxt, tp: ast::ty_param) -> ty::param_bounds {
fn param_bounds(ccx: crate_ctxt, tp: ast::ty_param) -> ty::param_bounds {
ccx.tcx.ty_param_bounds.get(tp.id)
}
fn register_fn_full(ccx: @crate_ctxt, sp: span, path: path, flav: str,
fn register_fn_full(ccx: crate_ctxt, sp: span, path: path, flav: str,
tps: [ast::ty_param], node_id: ast::node_id,
node_type: ty::t) {
let llfty = type_of_fn_from_ty(ccx, node_type,
@ -4386,7 +4386,7 @@ fn register_fn_full(ccx: @crate_ctxt, sp: span, path: path, flav: str,
lib::llvm::CCallConv, llfty);
}
fn register_fn_fuller(ccx: @crate_ctxt, sp: span, path: path, _flav: str,
fn register_fn_fuller(ccx: crate_ctxt, sp: span, path: path, _flav: str,
node_id: ast::node_id, node_type: ty::t,
cc: lib::llvm::CallConv, llfty: TypeRef) {
let ps: str = mangle_exported_name(ccx, path, node_type);
@ -4400,7 +4400,7 @@ fn register_fn_fuller(ccx: @crate_ctxt, sp: span, path: path, _flav: str,
// Create a _rust_main(args: [str]) function which will be called from the
// runtime rust_start function
fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
fn create_main_wrapper(ccx: crate_ctxt, sp: span, main_llfn: ValueRef,
main_node_type: ty::t) {
if ccx.main_fn != none::<ValueRef> {
@ -4418,7 +4418,7 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
ccx.main_fn = some(llfn);
create_entry_fn(ccx, llfn);
fn create_main(ccx: @crate_ctxt, main_llfn: ValueRef,
fn create_main(ccx: crate_ctxt, main_llfn: ValueRef,
takes_argv: bool) -> ValueRef {
let unit_ty = ty::mk_str(ccx.tcx);
let vecarg_ty: ty::arg =
@ -4446,7 +4446,7 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
ret llfdecl;
}
fn create_entry_fn(ccx: @crate_ctxt, rust_main: ValueRef) {
fn create_entry_fn(ccx: crate_ctxt, rust_main: ValueRef) {
#[cfg(target_os = "win32")]
fn main_name() -> str { ret "WinMain@16"; }
#[cfg(target_os = "macos")]
@ -4498,7 +4498,7 @@ fn fill_fn_pair(bcx: block, pair: ValueRef, llfn: ValueRef,
Store(bcx, llenvblobptr, env_cell);
}
fn collect_native_item(ccx: @crate_ctxt,
fn collect_native_item(ccx: crate_ctxt,
abi: @mutable option<ast::native_abi>,
i: @ast::native_item) {
alt i.node {
@ -4549,13 +4549,13 @@ fn collect_native_item(ccx: @crate_ctxt,
}
}
fn item_path(ccx: @crate_ctxt, i: @ast::item) -> path {
fn item_path(ccx: crate_ctxt, i: @ast::item) -> path {
*alt check ccx.tcx.items.get(i.id) {
ast_map::node_item(_, p) { p }
} + [path_name(i.ident)]
}
fn collect_item(ccx: @crate_ctxt, abi: @mutable option<ast::native_abi>,
fn collect_item(ccx: crate_ctxt, abi: @mutable option<ast::native_abi>,
i: @ast::item) {
let my_path = item_path(ccx, i);
alt i.node {
@ -4614,7 +4614,7 @@ fn collect_item(ccx: @crate_ctxt, abi: @mutable option<ast::native_abi>,
}
}
fn collect_items(ccx: @crate_ctxt, crate: @ast::crate) {
fn collect_items(ccx: crate_ctxt, crate: @ast::crate) {
let abi = @mutable none::<ast::native_abi>;
visit::visit_crate(*crate, (), visit::mk_simple_visitor(@{
visit_native_item: bind collect_native_item(ccx, abi, _),
@ -4624,7 +4624,7 @@ fn collect_items(ccx: @crate_ctxt, crate: @ast::crate) {
}
// The constant translation pass.
fn trans_constant(ccx: @crate_ctxt, it: @ast::item) {
fn trans_constant(ccx: crate_ctxt, it: @ast::item) {
alt it.node {
ast::item_enum(variants, _) {
let vi = ty::enum_variants(ccx.tcx, {crate: ast::local_crate,
@ -4660,7 +4660,7 @@ fn trans_constant(ccx: @crate_ctxt, it: @ast::item) {
}
}
fn trans_constants(ccx: @crate_ctxt, crate: @ast::crate) {
fn trans_constants(ccx: crate_ctxt, crate: @ast::crate) {
visit::visit_crate(*crate, (), visit::mk_simple_visitor(@{
visit_item: bind trans_constant(ccx, _)
with *visit::default_simple_visitor()
@ -4672,7 +4672,7 @@ fn vp2i(cx: block, v: ValueRef) -> ValueRef {
ret PtrToInt(cx, v, ccx.int_type);
}
fn p2i(ccx: @crate_ctxt, v: ValueRef) -> ValueRef {
fn p2i(ccx: crate_ctxt, v: ValueRef) -> ValueRef {
ret llvm::LLVMConstPtrToInt(v, ccx.int_type);
}
@ -4736,7 +4736,7 @@ fn trap(bcx: block) {
}
}
fn create_module_map(ccx: @crate_ctxt) -> ValueRef {
fn create_module_map(ccx: crate_ctxt) -> ValueRef {
let elttype = T_struct([ccx.int_type, ccx.int_type]);
let maptype = T_array(elttype, ccx.module_data.size() + 1u);
let map = str::as_buf("_rust_mod_map", {|buf|
@ -4775,7 +4775,7 @@ fn decl_crate_map(sess: session::session, mapname: str,
}
// FIXME use hashed metadata instead of crate names once we have that
fn fill_crate_map(ccx: @crate_ctxt, map: ValueRef) {
fn fill_crate_map(ccx: crate_ctxt, map: ValueRef) {
let subcrates: [ValueRef] = [];
let i = 1;
let cstore = ccx.sess.cstore;
@ -4793,7 +4793,7 @@ fn fill_crate_map(ccx: @crate_ctxt, map: ValueRef) {
C_array(ccx.int_type, subcrates)]));
}
fn write_metadata(cx: @crate_ctxt, crate: @ast::crate) {
fn write_metadata(cx: crate_ctxt, crate: @ast::crate) {
if !cx.sess.building_library { ret; }
let llmeta = C_bytes(metadata::encoder::encode_metadata(cx, crate));
let llconst = C_struct([llmeta]);
@ -4816,7 +4816,7 @@ fn write_metadata(cx: @crate_ctxt, crate: @ast::crate) {
}
// Writes the current ABI version into the crate.
fn write_abi_version(ccx: @crate_ctxt) {
fn write_abi_version(ccx: crate_ctxt) {
mk_global(ccx, "rust_abi_version", C_uint(ccx, abi::abi_version),
false);
}

View File

@ -101,7 +101,7 @@ enum environment_value {
env_ref(ValueRef, ty::t, lval_kind),
}
fn ev_to_str(ccx: @crate_ctxt, ev: environment_value) -> str {
fn ev_to_str(ccx: crate_ctxt, ev: environment_value) -> str {
alt ev {
env_expr(ex, _) { expr_to_str(ex) }
env_copy(v, t, lk) { #fmt("copy(%s,%s)", val_str(ccx.tn, v),
@ -385,7 +385,7 @@ fn build_closure(bcx0: block,
// and a list of upvars, generate code to load and populate the environment
// with the upvars and type descriptors.
fn load_environment(enclosing_cx: block,
fcx: @fn_ctxt,
fcx: fn_ctxt,
cdata_ty: ty::t,
cap_vars: [capture::capture_var],
ck: ty::closure_kind) {
@ -709,7 +709,7 @@ enum target_info {
}
// pth is cx.path
fn trans_bind_thunk(ccx: @crate_ctxt,
fn trans_bind_thunk(ccx: crate_ctxt,
path: path,
incoming_fty: ty::t,
outgoing_fty: ty::t,

View File

@ -67,8 +67,8 @@ type stats =
resource BuilderRef_res(B: BuilderRef) { llvm::LLVMDisposeBuilder(B); }
// Crate context. Every crate we compile has one of these.
type crate_ctxt =
{sess: session::session,
type crate_ctxt = @{
sess: session::session,
llmod: ModuleRef,
td: target_data,
tn: type_names,
@ -126,7 +126,7 @@ type param_substs = {tys: [ty::t],
// Function context. Every LLVM function we create will have one of
// these.
type fn_ctxt = {
type fn_ctxt = @{
// The ValueRef returned from a call to llvm::LLVMAddFunction; the
// address of the first instruction in the sequence of
// instructions for this function that will go in the .text
@ -203,10 +203,10 @@ type fn_ctxt = {
path: path,
// This function's enclosing crate context.
ccx: @crate_ctxt
ccx: crate_ctxt
};
fn warn_not_to_commit(ccx: @crate_ctxt, msg: str) {
fn warn_not_to_commit(ccx: crate_ctxt, 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!");
@ -289,7 +289,7 @@ fn revoke_clean(cx: block, val: ValueRef) {
}
}
fn get_res_dtor(ccx: @crate_ctxt, did: ast::def_id, inner_t: ty::t)
fn get_res_dtor(ccx: crate_ctxt, did: ast::def_id, inner_t: ty::t)
-> ValueRef {
if did.crate == ast::local_crate {
alt ccx.item_ids.find(did.node) {
@ -358,7 +358,7 @@ type block = @{
mutable block_span: option<span>,
// The function context for the function to which this block is
// attached.
fcx: @fn_ctxt
fcx: fn_ctxt
};
// First two args are retptr, env
@ -410,7 +410,7 @@ fn block_parent(cx: block) -> block {
// Accessors
impl bxc_cxs for block {
fn ccx() -> @crate_ctxt { self.fcx.ccx }
fn ccx() -> crate_ctxt { self.fcx.ccx }
fn tcx() -> ty::ctxt { self.fcx.ccx.tcx }
fn sess() -> session { self.fcx.ccx.sess }
}
@ -463,7 +463,7 @@ fn T_int(targ_cfg: @session::config) -> TypeRef {
};
}
fn T_int_ty(cx: @crate_ctxt, t: ast::int_ty) -> TypeRef {
fn T_int_ty(cx: crate_ctxt, t: ast::int_ty) -> TypeRef {
alt t {
ast::ty_i { cx.int_type }
ast::ty_char { T_char() }
@ -474,7 +474,7 @@ fn T_int_ty(cx: @crate_ctxt, t: ast::int_ty) -> TypeRef {
}
}
fn T_uint_ty(cx: @crate_ctxt, t: ast::uint_ty) -> TypeRef {
fn T_uint_ty(cx: crate_ctxt, t: ast::uint_ty) -> TypeRef {
alt t {
ast::ty_u { cx.int_type }
ast::ty_u8 { T_i8() }
@ -484,7 +484,7 @@ fn T_uint_ty(cx: @crate_ctxt, t: ast::uint_ty) -> TypeRef {
}
}
fn T_float_ty(cx: @crate_ctxt, t: ast::float_ty) -> TypeRef {
fn T_float_ty(cx: crate_ctxt, t: ast::float_ty) -> TypeRef {
alt t {
ast::ty_f { cx.float_type }
ast::ty_f32 { T_f32() }
@ -512,7 +512,7 @@ fn T_fn(inputs: [TypeRef], output: TypeRef) -> TypeRef unsafe {
False);
}
fn T_fn_pair(cx: @crate_ctxt, tfn: TypeRef) -> TypeRef {
fn T_fn_pair(cx: crate_ctxt, tfn: TypeRef) -> TypeRef {
ret T_struct([T_ptr(tfn), T_opaque_cbox_ptr(cx)]);
}
@ -564,7 +564,7 @@ fn T_task(targ_cfg: @session::config) -> TypeRef {
ret t;
}
fn T_tydesc_field(cx: @crate_ctxt, field: int) -> TypeRef unsafe {
fn T_tydesc_field(cx: crate_ctxt, field: int) -> TypeRef unsafe {
// Bit of a kludge: pick the fn typeref out of the tydesc..
let tydesc_elts: [TypeRef] =
@ -576,7 +576,7 @@ fn T_tydesc_field(cx: @crate_ctxt, field: int) -> TypeRef unsafe {
ret t;
}
fn T_glue_fn(cx: @crate_ctxt) -> TypeRef {
fn T_glue_fn(cx: crate_ctxt) -> TypeRef {
let s = "glue_fn";
alt name_has_type(cx.tn, s) { some(t) { ret t; } _ {} }
let t = T_tydesc_field(cx, abi::tydesc_field_drop_glue);
@ -615,7 +615,7 @@ fn T_vec2(targ_cfg: @session::config, t: TypeRef) -> TypeRef {
T_array(t, 0u)]); // elements
}
fn T_vec(ccx: @crate_ctxt, t: TypeRef) -> TypeRef {
fn T_vec(ccx: crate_ctxt, t: TypeRef) -> TypeRef {
ret T_vec2(ccx.sess.targ_cfg, t);
}
@ -641,38 +641,38 @@ fn tuplify_cbox_ty(tcx: ty::ctxt, t: ty::t, tydesc_t: ty::t) -> ty::t {
t]);
}
fn T_box_header_fields(cx: @crate_ctxt) -> [TypeRef] {
fn T_box_header_fields(cx: crate_ctxt) -> [TypeRef] {
let ptr = T_ptr(T_i8());
ret [cx.int_type, T_ptr(cx.tydesc_type), ptr, ptr];
}
fn T_box_header(cx: @crate_ctxt) -> TypeRef {
fn T_box_header(cx: crate_ctxt) -> TypeRef {
ret T_struct(T_box_header_fields(cx));
}
fn T_box(cx: @crate_ctxt, t: TypeRef) -> TypeRef {
fn T_box(cx: crate_ctxt, t: TypeRef) -> TypeRef {
ret T_struct(T_box_header_fields(cx) + [t]);
}
fn T_opaque_box(cx: @crate_ctxt) -> TypeRef {
fn T_opaque_box(cx: crate_ctxt) -> TypeRef {
ret T_box(cx, T_i8());
}
fn T_opaque_box_ptr(cx: @crate_ctxt) -> TypeRef {
fn T_opaque_box_ptr(cx: crate_ctxt) -> TypeRef {
ret T_ptr(T_opaque_box(cx));
}
fn T_port(cx: @crate_ctxt, _t: TypeRef) -> TypeRef {
fn T_port(cx: crate_ctxt, _t: TypeRef) -> TypeRef {
ret T_struct([cx.int_type]); // Refcount
}
fn T_chan(cx: @crate_ctxt, _t: TypeRef) -> TypeRef {
fn T_chan(cx: crate_ctxt, _t: TypeRef) -> TypeRef {
ret T_struct([cx.int_type]); // Refcount
}
fn T_taskptr(cx: @crate_ctxt) -> TypeRef { ret T_ptr(cx.task_type); }
fn T_taskptr(cx: crate_ctxt) -> TypeRef { ret T_ptr(cx.task_type); }
// This type must never be used directly; it must always be cast away.
@ -686,17 +686,17 @@ fn T_typaram(tn: type_names) -> TypeRef {
fn T_typaram_ptr(tn: type_names) -> TypeRef { ret T_ptr(T_typaram(tn)); }
fn T_opaque_cbox_ptr(cx: @crate_ctxt) -> TypeRef {
fn T_opaque_cbox_ptr(cx: crate_ctxt) -> TypeRef {
// closures look like boxes (even when they are fn~ or fn&)
// see trans_closure.rs
ret T_opaque_box_ptr(cx);
}
fn T_enum_variant(cx: @crate_ctxt) -> TypeRef {
fn T_enum_variant(cx: crate_ctxt) -> TypeRef {
ret cx.int_type;
}
fn T_enum(cx: @crate_ctxt, size: uint) -> TypeRef {
fn T_enum(cx: crate_ctxt, size: uint) -> TypeRef {
let s = "enum_" + uint::to_str(size, 10u);
alt name_has_type(cx.tn, s) { some(t) { ret t; } _ {} }
let t =
@ -707,7 +707,7 @@ fn T_enum(cx: @crate_ctxt, size: uint) -> TypeRef {
ret t;
}
fn T_opaque_enum(cx: @crate_ctxt) -> TypeRef {
fn T_opaque_enum(cx: crate_ctxt) -> TypeRef {
let s = "opaque_enum";
alt name_has_type(cx.tn, s) { some(t) { ret t; } _ {} }
let t = T_struct([T_enum_variant(cx), T_i8()]);
@ -715,15 +715,15 @@ fn T_opaque_enum(cx: @crate_ctxt) -> TypeRef {
ret t;
}
fn T_opaque_enum_ptr(cx: @crate_ctxt) -> TypeRef {
fn T_opaque_enum_ptr(cx: crate_ctxt) -> TypeRef {
ret T_ptr(T_opaque_enum(cx));
}
fn T_captured_tydescs(cx: @crate_ctxt, n: uint) -> TypeRef {
fn T_captured_tydescs(cx: crate_ctxt, n: uint) -> TypeRef {
ret T_struct(vec::init_elt::<TypeRef>(n, T_ptr(cx.tydesc_type)));
}
fn T_opaque_iface(cx: @crate_ctxt) -> TypeRef {
fn T_opaque_iface(cx: crate_ctxt) -> TypeRef {
T_struct([T_ptr(cx.tydesc_type), T_opaque_box_ptr(cx)])
}
@ -765,11 +765,11 @@ fn C_i64(i: i64) -> ValueRef {
ret C_integral(T_i64(), i as u64, True);
}
fn C_int(cx: @crate_ctxt, i: int) -> ValueRef {
fn C_int(cx: crate_ctxt, i: int) -> ValueRef {
ret C_integral(cx.int_type, i as u64, True);
}
fn C_uint(cx: @crate_ctxt, i: uint) -> ValueRef {
fn C_uint(cx: crate_ctxt, i: uint) -> ValueRef {
ret C_integral(cx.int_type, i as u64, False);
}
@ -778,7 +778,7 @@ fn C_u8(i: uint) -> ValueRef { ret C_integral(T_i8(), i as u64, False); }
// This is a 'c-like' raw string, which differs from
// our boxed-and-length-annotated strings.
fn C_cstr(cx: @crate_ctxt, s: str) -> ValueRef {
fn C_cstr(cx: crate_ctxt, s: str) -> ValueRef {
let sc = str::as_buf(s) {|buf|
llvm::LLVMConstString(buf, str::len_bytes(s) as unsigned, False)
};
@ -827,7 +827,7 @@ fn C_bytes(bytes: [u8]) -> ValueRef unsafe {
bytes.len() as unsigned, False);
}
fn C_shape(ccx: @crate_ctxt, bytes: [u8]) -> ValueRef {
fn C_shape(ccx: crate_ctxt, bytes: [u8]) -> ValueRef {
let llshape = C_bytes(bytes);
let llglobal = str::as_buf(ccx.names("shape"), {|buf|
llvm::LLVMAddGlobal(ccx.llmod, val_ty(llshape), buf)
@ -852,7 +852,7 @@ pure fn valid_variant_index(ix: uint, cx: block, enum_id: ast::def_id,
}
}
pure fn type_has_static_size(cx: @crate_ctxt, t: ty::t) -> bool {
pure fn type_has_static_size(cx: crate_ctxt, t: ty::t) -> bool {
!ty::type_has_dynamic_size(cx.tcx, t)
}

View File

@ -74,7 +74,7 @@ fn llnull() -> ValueRef unsafe {
unsafe::reinterpret_cast(ptr::null::<ValueRef>())
}
fn add_named_metadata(cx: @crate_ctxt, name: str, val: ValueRef) {
fn add_named_metadata(cx: crate_ctxt, name: str, val: ValueRef) {
str::as_buf(name, {|sbuf|
llvm::LLVMAddNamedMetadataOperand(cx.llmod, sbuf,
val)
@ -155,7 +155,7 @@ fn cached_metadata<T: copy>(cache: metadata_cache, mdtag: int,
ret option::none;
}
fn create_compile_unit(cx: @crate_ctxt, full_path: str)
fn create_compile_unit(cx: crate_ctxt, full_path: str)
-> @metadata<compile_unit_md> unsafe {
let cache = get_cache(cx);
let tg = CompileUnitTag;
@ -194,11 +194,11 @@ fn create_compile_unit(cx: @crate_ctxt, full_path: str)
ret mdval;
}
fn get_cache(cx: @crate_ctxt) -> metadata_cache {
fn get_cache(cx: crate_ctxt) -> metadata_cache {
option::get(cx.dbg_cx).llmetadata
}
fn create_file(cx: @crate_ctxt, full_path: str) -> @metadata<file_md> {
fn create_file(cx: crate_ctxt, full_path: str) -> @metadata<file_md> {
let cache = get_cache(cx);;
let tg = FileDescriptorTag;
alt cached_metadata::<@metadata<file_md>>(
@ -274,7 +274,7 @@ fn size_and_align_of<T>() -> (int, int) {
(sys::size_of::<T>() as int, sys::align_of::<T>() as int)
}
fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: ast::prim_ty, span: span)
fn create_basic_type(cx: crate_ctxt, t: ty::t, ty: ast::prim_ty, span: span)
-> @metadata<tydesc_md> {
let cache = get_cache(cx);
let tg = BasicTypeDescriptorTag;
@ -328,7 +328,7 @@ fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: ast::prim_ty, span: span)
ret mdval;
}
fn create_pointer_type(cx: @crate_ctxt, t: ty::t, span: span,
fn create_pointer_type(cx: crate_ctxt, t: ty::t, span: span,
pointee: @metadata<tydesc_md>)
-> @metadata<tydesc_md> {
let tg = PointerTypeTag;
@ -401,7 +401,7 @@ fn add_member(cx: @struct_ctxt, name: str, line: int, size: int, align: int,
cx.total_size += size * 8;
}
fn create_record(cx: @crate_ctxt, t: ty::t, fields: [ast::ty_field],
fn create_record(cx: crate_ctxt, t: ty::t, fields: [ast::ty_field],
span: span) -> @metadata<tydesc_md> {
let fname = filename_from_span(cx, span);
let file_node = create_file(cx, fname);
@ -421,7 +421,7 @@ fn create_record(cx: @crate_ctxt, t: ty::t, fields: [ast::ty_field],
ret mdval;
}
fn create_boxed_type(cx: @crate_ctxt, outer: ty::t, _inner: ty::t,
fn create_boxed_type(cx: crate_ctxt, outer: ty::t, _inner: ty::t,
span: span, boxed: @metadata<tydesc_md>)
-> @metadata<tydesc_md> {
//let tg = StructureTypeTag;
@ -480,7 +480,7 @@ fn create_composite_type(type_tag: int, name: str, file: ValueRef, line: int,
ret llmdnode(lldata);
}
fn create_vec(cx: @crate_ctxt, vec_t: ty::t, elem_t: ty::t,
fn create_vec(cx: crate_ctxt, vec_t: ty::t, elem_t: ty::t,
vec_ty_span: codemap::span, elem_ty: @ast::ty)
-> @metadata<tydesc_md> {
let fname = filename_from_span(cx, vec_ty_span);
@ -554,7 +554,7 @@ fn member_size_and_align(tcx: ty::ctxt, ty: @ast::ty) -> (int, int) {
}
}
fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty)
fn create_ty(_cx: crate_ctxt, _t: ty::t, _ty: @ast::ty)
-> @metadata<tydesc_md> {
/*let cache = get_cache(cx);
alt cached_metadata::<@metadata<tydesc_md>>(
@ -576,7 +576,7 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty)
fail;
/*
fn t_to_ty(cx: @crate_ctxt, t: ty::t, span: span) -> @ast::ty {
fn t_to_ty(cx: crate_ctxt, t: ty::t, span: span) -> @ast::ty {
let ty = alt ty::get(t).struct {
ty::ty_nil { ast::ty_nil }
ty::ty_bot { ast::ty_bot }
@ -658,7 +658,7 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty)
*/
}
fn filename_from_span(cx: @crate_ctxt, sp: codemap::span) -> str {
fn filename_from_span(cx: crate_ctxt, sp: codemap::span) -> str {
codemap::lookup_char_pos(cx.sess.codemap, sp.lo).file.name
}
@ -772,7 +772,7 @@ fn update_source_pos(cx: block, s: span) {
llvm::LLVMSetCurrentDebugLocation(trans::build::B(cx), dbgscope);
}
fn create_function(fcx: @fn_ctxt) -> @metadata<subprogram_md> {
fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> {
let cx = fcx.ccx;
let dbg_cx = option::get(cx.dbg_cx);

View File

@ -41,7 +41,7 @@ import ast_map::{path, path_mod, path_name};
// annotates nodes with information about the methods and dicts that
// are referenced (ccx.method_map and ccx.dict_map).
fn trans_impl(ccx: @crate_ctxt, path: path, name: ast::ident,
fn trans_impl(ccx: crate_ctxt, path: path, name: ast::ident,
methods: [@ast::method], id: ast::node_id,
tps: [ast::ty_param]) {
let sub_path = path + [path_name(name)];
@ -100,7 +100,7 @@ fn trans_static_callee(bcx: block, callee_id: ast::node_id,
with lval_static_fn(bcx, did, callee_id, substs)}
}
fn wrapper_fn_ty(ccx: @crate_ctxt, dict_ty: TypeRef, fty: ty::t,
fn wrapper_fn_ty(ccx: crate_ctxt, dict_ty: TypeRef, fty: ty::t,
tps: @[ty::param_bounds]) -> {ty: ty::t, llty: TypeRef} {
let bare_fn_ty = type_of_fn_from_ty(ccx, fty, *tps);
let {inputs, output} = llfn_arg_tys(bare_fn_ty);
@ -203,7 +203,7 @@ fn llfn_arg_tys(ft: TypeRef) -> {inputs: [TypeRef], output: TypeRef} {
{inputs: args, output: out_ty}
}
fn trans_vtable(ccx: @crate_ctxt, id: ast::node_id, name: str,
fn trans_vtable(ccx: crate_ctxt, id: ast::node_id, name: str,
ptrs: [ValueRef]) {
let tbl = C_struct(ptrs);
let vt_gvar = str::as_buf(name, {|buf|
@ -230,7 +230,7 @@ fn find_dict_in_fn_ctxt(ps: param_substs, n_param: uint, n_bound: uint)
option::get(ps.dicts)[dict_off]
}
fn resolve_dicts_in_fn_ctxt(fcx: @fn_ctxt, dicts: typeck::dict_res)
fn resolve_dicts_in_fn_ctxt(fcx: fn_ctxt, dicts: typeck::dict_res)
-> option<typeck::dict_res> {
let result = [];
for dict in *dicts {
@ -265,7 +265,7 @@ fn resolve_dicts_in_fn_ctxt(fcx: @fn_ctxt, dicts: typeck::dict_res)
some(@result)
}
fn trans_wrapper(ccx: @crate_ctxt, pt: path, llfty: TypeRef,
fn trans_wrapper(ccx: crate_ctxt, pt: path, llfty: TypeRef,
fill: fn(ValueRef, block) -> block)
-> ValueRef {
let name = link::mangle_internal_name_by_path(ccx, pt);
@ -278,7 +278,7 @@ fn trans_wrapper(ccx: @crate_ctxt, pt: path, llfty: TypeRef,
ret llfn;
}
fn trans_impl_wrapper(ccx: @crate_ctxt, pt: path,
fn trans_impl_wrapper(ccx: crate_ctxt, pt: path,
extra_tps: [ty::param_bounds], real_fn: ValueRef)
-> ValueRef {
let {inputs: real_args, output: real_ret} =
@ -323,7 +323,7 @@ fn trans_impl_wrapper(ccx: @crate_ctxt, pt: path,
})
}
fn trans_impl_vtable(ccx: @crate_ctxt, pt: path,
fn trans_impl_vtable(ccx: crate_ctxt, pt: path,
iface_id: ast::def_id, ms: [@ast::method],
tps: [ast::ty_param], it: @ast::item) {
let new_pt = pt + [path_name(it.ident), path_name(int::str(it.id)),
@ -347,7 +347,7 @@ fn trans_impl_vtable(ccx: @crate_ctxt, pt: path,
trans_vtable(ccx, it.id, s, ptrs);
}
fn trans_iface_wrapper(ccx: @crate_ctxt, pt: path, m: ty::method,
fn trans_iface_wrapper(ccx: crate_ctxt, pt: path, m: ty::method,
n: uint) -> ValueRef {
let {llty: llfty, _} = wrapper_fn_ty(ccx, T_ptr(T_i8()),
ty::mk_fn(ccx.tcx, m.fty), m.tps);
@ -373,7 +373,7 @@ fn trans_iface_wrapper(ccx: @crate_ctxt, pt: path, m: ty::method,
})
}
fn trans_iface_vtable(ccx: @crate_ctxt, pt: path, it: @ast::item) {
fn trans_iface_vtable(ccx: crate_ctxt, pt: path, it: @ast::item) {
let new_pt = pt + [path_name(it.ident), path_name(int::str(it.id))];
let i_did = ast_util::local_def(it.id), i = 0u;
let ptrs = vec::map(*ty::iface_methods(ccx.tcx, i_did), {|m|
@ -478,7 +478,7 @@ fn get_static_dict(bcx: block, origin: typeck::dict_origin)
fn get_dict_ptrs(bcx: block, origin: typeck::dict_origin)
-> {bcx: block, ptrs: [ValueRef]} {
let ccx = bcx.ccx();
fn get_vtable(ccx: @crate_ctxt, did: ast::def_id) -> ValueRef {
fn get_vtable(ccx: crate_ctxt, did: ast::def_id) -> ValueRef {
if did.crate == ast::local_crate {
ccx.item_ids.get(did.node)
} else {

View File

@ -26,7 +26,7 @@ type c_stack_tys = {
shim_fn_ty: TypeRef
};
fn c_arg_and_ret_lltys(ccx: @crate_ctxt,
fn c_arg_and_ret_lltys(ccx: crate_ctxt,
id: ast::node_id) -> ([TypeRef], TypeRef, ty::t) {
alt ty::get(ty::node_id_to_type(ccx.tcx, id)).struct {
ty::ty_fn({inputs: arg_tys, output: ret_ty, _}) {
@ -38,7 +38,7 @@ fn c_arg_and_ret_lltys(ccx: @crate_ctxt,
}
}
fn c_stack_tys(ccx: @crate_ctxt,
fn c_stack_tys(ccx: crate_ctxt,
id: ast::node_id) -> @c_stack_tys {
let (llargtys, llretty, ret_ty) = c_arg_and_ret_lltys(ccx, id);
let bundle_ty = T_struct(llargtys + [T_ptr(llretty)]);
@ -57,7 +57,7 @@ type shim_arg_builder = fn(bcx: block, tys: @c_stack_tys,
type shim_ret_builder = fn(bcx: block, tys: @c_stack_tys,
llargbundle: ValueRef, llretval: ValueRef);
fn build_shim_fn_(ccx: @crate_ctxt,
fn build_shim_fn_(ccx: crate_ctxt,
shim_name: str,
llbasefn: ValueRef,
tys: @c_stack_tys,
@ -94,7 +94,7 @@ type wrap_arg_builder = fn(bcx: block, tys: @c_stack_tys,
type wrap_ret_builder = fn(bcx: block, tys: @c_stack_tys,
llargbundle: ValueRef);
fn build_wrap_fn_(ccx: @crate_ctxt,
fn build_wrap_fn_(ccx: crate_ctxt,
tys: @c_stack_tys,
llshimfn: ValueRef,
llwrapfn: ValueRef,
@ -158,9 +158,9 @@ fn build_wrap_fn_(ccx: @crate_ctxt,
// stack pointer appropriately to avoid a round of copies. (In fact, the shim
// function itself is unnecessary). We used to do this, in fact, and will
// perhaps do so in the future.
fn trans_native_mod(ccx: @crate_ctxt,
fn trans_native_mod(ccx: crate_ctxt,
native_mod: ast::native_mod, abi: ast::native_abi) {
fn build_shim_fn(ccx: @crate_ctxt,
fn build_shim_fn(ccx: crate_ctxt,
native_item: @ast::native_item,
tys: @c_stack_tys,
cc: lib::llvm::CallConv) -> ValueRef {
@ -201,7 +201,7 @@ fn trans_native_mod(ccx: @crate_ctxt,
build_args, build_ret);
}
fn build_wrap_fn(ccx: @crate_ctxt,
fn build_wrap_fn(ccx: crate_ctxt,
tys: @c_stack_tys,
num_tps: uint,
llshimfn: ValueRef,
@ -262,10 +262,10 @@ fn trans_native_mod(ccx: @crate_ctxt,
}
}
fn trans_crust_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
fn trans_crust_fn(ccx: crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
body: ast::blk, llwrapfn: ValueRef, id: ast::node_id) {
fn build_rust_fn(ccx: @crate_ctxt, path: ast_map::path,
fn build_rust_fn(ccx: crate_ctxt, path: ast_map::path,
decl: ast::fn_decl, body: ast::blk,
id: ast::node_id) -> ValueRef {
let t = ty::node_id_to_type(ccx.tcx, id);
@ -277,7 +277,7 @@ fn trans_crust_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
ret llfndecl;
}
fn build_shim_fn(ccx: @crate_ctxt, path: ast_map::path,
fn build_shim_fn(ccx: crate_ctxt, path: ast_map::path,
llrustfn: ValueRef, tys: @c_stack_tys) -> ValueRef {
fn build_args(bcx: block, tys: @c_stack_tys,
@ -310,7 +310,7 @@ fn trans_crust_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
build_args, build_ret);
}
fn build_wrap_fn(ccx: @crate_ctxt, llshimfn: ValueRef,
fn build_wrap_fn(ccx: crate_ctxt, llshimfn: ValueRef,
llwrapfn: ValueRef, tys: @c_stack_tys) {
fn build_args(bcx: block, tys: @c_stack_tys,
@ -348,7 +348,7 @@ fn trans_crust_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
build_wrap_fn(ccx, llshimfn, llwrapfn, tys)
}
fn register_crust_fn(ccx: @crate_ctxt, sp: span,
fn register_crust_fn(ccx: crate_ctxt, sp: span,
path: ast_map::path, node_id: ast::node_id) {
let t = ty::node_id_to_type(ccx.tcx, node_id);
let (llargtys, llretty, _) = c_arg_and_ret_lltys(ccx, node_id);

View File

@ -75,7 +75,7 @@ fn eq_res_info(a: res_info, b: res_info) -> bool {
ret a.did.crate == b.did.crate && a.did.node == b.did.node && a.t == b.t;
}
fn mk_global(ccx: @crate_ctxt, name: str, llval: ValueRef, internal: bool) ->
fn mk_global(ccx: crate_ctxt, name: str, llval: ValueRef, internal: bool) ->
ValueRef {
let llglobal =
str::as_buf(name,
@ -100,7 +100,7 @@ fn mk_global(ccx: @crate_ctxt, name: str, llval: ValueRef, internal: bool) ->
//
// FIXME: Use this in dynamic_size_of() as well.
fn largest_variants(ccx: @crate_ctxt, tag_id: ast::def_id) -> [uint] {
fn largest_variants(ccx: crate_ctxt, tag_id: ast::def_id) -> [uint] {
// Compute the minimum and maximum size and alignment for each variant.
//
// FIXME: We could do better here; e.g. we know that any variant that
@ -179,7 +179,7 @@ fn round_up(size: u16, align: u8) -> u16 {
type size_align = {size: u16, align: u8};
fn compute_static_enum_size(ccx: @crate_ctxt, largest_variants: [uint],
fn compute_static_enum_size(ccx: crate_ctxt, largest_variants: [uint],
did: ast::def_id) -> size_align {
let max_size = 0u16;
let max_align = 1u8;
@ -219,7 +219,7 @@ enum enum_kind {
tk_complex // N variants, no data
}
fn enum_kind(ccx: @crate_ctxt, did: ast::def_id) -> enum_kind {
fn enum_kind(ccx: crate_ctxt, did: ast::def_id) -> enum_kind {
let variants = ty::enum_variants(ccx.tcx, did);
if vec::any(*variants) {|v| vec::len(v.args) > 0u} {
if vec::len(*variants) == 1u { tk_newtype }
@ -293,7 +293,7 @@ fn add_substr(&dest: [u8], src: [u8]) {
dest += src;
}
fn shape_of(ccx: @crate_ctxt, t: ty::t, ty_param_map: [uint]) -> [u8] {
fn shape_of(ccx: crate_ctxt, t: ty::t, ty_param_map: [uint]) -> [u8] {
let s = [];
alt ty::get(t).struct {
@ -433,7 +433,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t, ty_param_map: [uint]) -> [u8] {
}
// FIXME: We might discover other variants as we traverse these. Handle this.
fn shape_of_variant(ccx: @crate_ctxt, v: ty::variant_info,
fn shape_of_variant(ccx: crate_ctxt, v: ty::variant_info,
ty_param_count: uint) -> [u8] {
let ty_param_map = [];
let i = 0u;
@ -444,7 +444,7 @@ fn shape_of_variant(ccx: @crate_ctxt, v: ty::variant_info,
ret s;
}
fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef {
fn gen_enum_shapes(ccx: crate_ctxt) -> ValueRef {
// Loop over all the enum variants and write their shapes into a
// data buffer. As we do this, it's possible for us to discover
// new enums, so we must do this first.
@ -542,7 +542,7 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef {
ret mk_global(ccx, "tag_shapes", C_bytes(header), true);
}
fn gen_resource_shapes(ccx: @crate_ctxt) -> ValueRef {
fn gen_resource_shapes(ccx: crate_ctxt) -> ValueRef {
let dtors = [];
let i = 0u;
let len = interner::len(ccx.shape_cx.resources);
@ -555,7 +555,7 @@ fn gen_resource_shapes(ccx: @crate_ctxt) -> ValueRef {
ret mk_global(ccx, "resource_shapes", C_struct(dtors), true);
}
fn gen_shape_tables(ccx: @crate_ctxt) {
fn gen_shape_tables(ccx: crate_ctxt) {
let lltagstable = gen_enum_shapes(ccx);
let llresourcestable = gen_resource_shapes(ccx);
trans::common::set_struct_body(ccx.shape_cx.llshapetablesty,
@ -618,21 +618,21 @@ fn metrics(bcx: block, t: ty::t) -> metrics {
}
// Returns the real size of the given type for the current target.
fn llsize_of_real(cx: @crate_ctxt, t: TypeRef) -> uint {
fn llsize_of_real(cx: crate_ctxt, t: TypeRef) -> uint {
ret llvm::LLVMStoreSizeOfType(cx.td.lltd, t) as uint;
}
// Returns the real alignment of the given type for the current target.
fn llalign_of_real(cx: @crate_ctxt, t: TypeRef) -> uint {
fn llalign_of_real(cx: crate_ctxt, t: TypeRef) -> uint {
ret llvm::LLVMPreferredAlignmentOfType(cx.td.lltd, t) as uint;
}
fn llsize_of(cx: @crate_ctxt, t: TypeRef) -> ValueRef {
fn llsize_of(cx: crate_ctxt, t: TypeRef) -> ValueRef {
ret llvm::LLVMConstIntCast(lib::llvm::llvm::LLVMSizeOf(t), cx.int_type,
False);
}
fn llalign_of(cx: @crate_ctxt, t: TypeRef) -> ValueRef {
fn llalign_of(cx: crate_ctxt, t: TypeRef) -> ValueRef {
ret llvm::LLVMConstIntCast(lib::llvm::llvm::LLVMAlignOf(t), cx.int_type,
False);
}
@ -643,7 +643,7 @@ fn llalign_of(cx: @crate_ctxt, t: TypeRef) -> ValueRef {
// FIXME: Migrate trans over to use this.
// Computes the size of the data part of a non-dynamically-sized enum.
fn static_size_of_enum(cx: @crate_ctxt, t: ty::t) -> uint {
fn static_size_of_enum(cx: crate_ctxt, t: ty::t) -> uint {
if cx.enum_sizes.contains_key(t) { ret cx.enum_sizes.get(t); }
alt ty::get(t).struct {
ty::ty_enum(tid, subtys) {