aboutsummaryrefslogtreecommitdiff
path: root/src/comp/middle/trans.rs
diff options
context:
space:
mode:
authorMarijn Haverbeke <[email protected]>2011-05-12 17:24:54 +0200
committerMarijn Haverbeke <[email protected]>2011-05-12 21:30:44 +0200
commit3816e57fd2a8ab19e4ac6d4b3ddd5b49d5973ff2 (patch)
tree508982ed2f789aedd89eebd529343d9dc88b8e01 /src/comp/middle/trans.rs
parentTransitional change to make extfmt output lowercase module name (diff)
downloadrust-3816e57fd2a8ab19e4ac6d4b3ddd5b49d5973ff2.tar.xz
rust-3816e57fd2a8ab19e4ac6d4b3ddd5b49d5973ff2.zip
Downcase std modules again, move to :: for module dereferencing
This should be a snapshot transition.
Diffstat (limited to 'src/comp/middle/trans.rs')
-rw-r--r--src/comp/middle/trans.rs2875
1 files changed, 1443 insertions, 1432 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index ecdf78cf..55f938d4 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -1,49 +1,49 @@
-import std.Int;
-import std.Str;
-import std.UInt;
-import std.Vec;
-import std.Str.rustrt.sbuf;
-import std.Vec.rustrt.vbuf;
-import std.Map;
-import std.Map.hashmap;
-import std.Option;
-import std.Option.some;
-import std.Option.none;
-
-import front.ast;
-import front.creader;
-import driver.session;
-import middle.ty;
-import back.Link;
-import back.x86;
-import back.abi;
-import back.upcall;
-
-import middle.ty.pat_ty;
-
-import util.common;
-import util.common.istr;
-import util.common.new_def_hash;
-import util.common.new_str_hash;
-
-import lib.llvm.llvm;
-import lib.llvm.builder;
-import lib.llvm.target_data;
-import lib.llvm.type_handle;
-import lib.llvm.type_names;
-import lib.llvm.mk_target_data;
-import lib.llvm.mk_type_handle;
-import lib.llvm.mk_type_names;
-import lib.llvm.llvm.ModuleRef;
-import lib.llvm.llvm.ValueRef;
-import lib.llvm.llvm.TypeRef;
-import lib.llvm.llvm.TypeHandleRef;
-import lib.llvm.llvm.BuilderRef;
-import lib.llvm.llvm.BasicBlockRef;
-
-import lib.llvm.False;
-import lib.llvm.True;
-import lib.llvm.Bool;
+import std::_int;
+import std::_str;
+import std::_uint;
+import std::_vec;
+import std::_str::rustrt::sbuf;
+import std::_vec::rustrt::vbuf;
+import std::map;
+import std::map::hashmap;
+import std::option;
+import std::option::some;
+import std::option::none;
+
+import front::ast;
+import front::creader;
+import driver::session;
+import middle::ty;
+import back::Link;
+import back::x86;
+import back::abi;
+import back::upcall;
+
+import middle::ty::pat_ty;
+
+import util::common;
+import util::common::istr;
+import util::common::new_def_hash;
+import util::common::new_str_hash;
+
+import lib::llvm::llvm;
+import lib::llvm::builder;
+import lib::llvm::target_data;
+import lib::llvm::type_handle;
+import lib::llvm::type_names;
+import lib::llvm::mk_target_data;
+import lib::llvm::mk_type_handle;
+import lib::llvm::mk_type_names;
+import lib::llvm::llvm::ModuleRef;
+import lib::llvm::llvm::ValueRef;
+import lib::llvm::llvm::TypeRef;
+import lib::llvm::llvm::TypeHandleRef;
+import lib::llvm::llvm::BuilderRef;
+import lib::llvm::llvm::BasicBlockRef;
+
+import lib::llvm::False;
+import lib::llvm::True;
+import lib::llvm::Bool;
state obj namegen(mutable int i) {
fn next(str prefix) -> str {
@@ -78,7 +78,7 @@ type tydesc_info = rec(ValueRef tydesc,
*
* A "native" is a combination of an extern that references C code, plus a
* glue-code stub that "looks like" a rust function, emitted here, plus a
- * generic N-ary bit of asm glue (found over in back/x86.rs) that performs a
+ * generic N-ary bit of asm glue (found over in back/x86::rs) that performs a
* control transfer into C from rust. Natives may be normal C library code.
*
* An upcall is a native call generated by the compiler (not corresponding to
@@ -87,46 +87,46 @@ type tydesc_info = rec(ValueRef tydesc,
*
*/
-state type crate_ctxt = rec(session.session sess,
+state type crate_ctxt = rec(session::session sess,
ModuleRef llmod,
target_data td,
type_names tn,
ValueRef crate_ptr,
hashmap[str, ValueRef] externs,
hashmap[str, ValueRef] intrinsics,
- hashmap[ast.def_id, ValueRef] item_ids,
- hashmap[ast.def_id, @ast.item] items,
- hashmap[ast.def_id,
- @ast.native_item] native_items,
- ty.type_cache type_cache,
- hashmap[ast.def_id, str] item_symbols,
+ hashmap[ast::def_id, ValueRef] item_ids,
+ hashmap[ast::def_id, @ast::item] items,
+ hashmap[ast::def_id,
+ @ast::native_item] native_items,
+ ty::type_cache type_cache,
+ hashmap[ast::def_id, str] item_symbols,
// TODO: hashmap[tup(tag_id,subtys), @tag_info]
- hashmap[ty.t, uint] tag_sizes,
- hashmap[ast.def_id, ValueRef] discrims,
- hashmap[ast.def_id, str] discrim_symbols,
- hashmap[ast.def_id, ValueRef] fn_pairs,
- hashmap[ast.def_id, ValueRef] consts,
- hashmap[ast.def_id,()] obj_methods,
- hashmap[ty.t, @tydesc_info] tydescs,
+ hashmap[ty::t, uint] tag_sizes,
+ hashmap[ast::def_id, ValueRef] discrims,
+ hashmap[ast::def_id, str] discrim_symbols,
+ hashmap[ast::def_id, ValueRef] fn_pairs,
+ hashmap[ast::def_id, ValueRef] consts,
+ hashmap[ast::def_id,()] obj_methods,
+ hashmap[ty::t, @tydesc_info] tydescs,
hashmap[str, ValueRef] module_data,
- hashmap[ty.t, TypeRef] lltypes,
+ hashmap[ty::t, TypeRef] lltypes,
@glue_fns glues,
namegen names,
- std.SHA1.sha1 sha,
- hashmap[ty.t, str] type_sha1s,
- hashmap[ty.t, metadata.ty_abbrev] type_abbrevs,
- hashmap[ty.t, str] type_short_names,
- ty.ctxt tcx,
- @upcall.upcalls upcalls);
+ std::sha1::sha1 sha,
+ hashmap[ty::t, str] type_sha1s,
+ hashmap[ty::t, metadata::ty_abbrev] type_abbrevs,
+ hashmap[ty::t, str] type_short_names,
+ ty::ctxt tcx,
+ @upcall::upcalls upcalls);
type local_ctxt = rec(vec[str] path,
vec[str] module_path,
- vec[ast.ty_param] obj_typarams,
- vec[ast.obj_field] obj_fields,
+ vec[ast::ty_param] obj_typarams,
+ vec[ast::obj_field] obj_fields,
@crate_ctxt ccx);
-type self_vt = rec(ValueRef v, ty.t t);
+type self_vt = rec(ValueRef v, ty::t t);
state type fn_ctxt = rec(ValueRef llfn,
ValueRef lltaskptr,
@@ -135,14 +135,14 @@ state type fn_ctxt = rec(ValueRef llfn,
mutable BasicBlockRef llallocas,
mutable BasicBlockRef llcopyargs,
mutable BasicBlockRef llderivedtydescs,
- mutable Option.t[self_vt] llself,
- mutable Option.t[ValueRef] lliterbody,
- hashmap[ast.def_id, ValueRef] llargs,
- hashmap[ast.def_id, ValueRef] llobjfields,
- hashmap[ast.def_id, ValueRef] lllocals,
- hashmap[ast.def_id, ValueRef] llupvars,
+ mutable option::t[self_vt] llself,
+ mutable option::t[ValueRef] lliterbody,
+ hashmap[ast::def_id, ValueRef] llargs,
+ hashmap[ast::def_id, ValueRef] llobjfields,
+ hashmap[ast::def_id, ValueRef] lllocals,
+ hashmap[ast::def_id, ValueRef] llupvars,
mutable vec[ValueRef] lltydescs,
- hashmap[ty.t, derived_tydesc_info] derived_tydescs,
+ hashmap[ty::t, derived_tydesc_info] derived_tydescs,
@local_ctxt lcx);
tag cleanup {
@@ -152,7 +152,7 @@ tag cleanup {
tag block_kind {
SCOPE_BLOCK;
- LOOP_SCOPE_BLOCK(Option.t[@block_ctxt], @block_ctxt);
+ LOOP_SCOPE_BLOCK(option::t[@block_ctxt], @block_ctxt);
NON_SCOPE_BLOCK;
}
@@ -163,7 +163,7 @@ state type block_ctxt = rec(BasicBlockRef llbb,
mutable vec[cleanup] cleanups,
@fn_ctxt fcx);
-// FIXME: we should be able to use Option.t[@block_parent] here but
+// FIXME: we should be able to use option::t[@block_parent] here but
// the infinite-tag check in rustboot gets upset.
tag block_parent {
@@ -184,38 +184,40 @@ fn extend_path(@local_ctxt cx, &str name) -> @local_ctxt {
}
fn path_name(&vec[str] path) -> str {
- ret Str.connect(path, sep());
+ ret _str::connect(path, sep());
}
-fn get_type_sha1(&@crate_ctxt ccx, &ty.t t) -> str {
+fn get_type_sha1(&@crate_ctxt ccx, &ty::t t) -> str {
auto hash = "";
alt (ccx.type_sha1s.find(t)) {
case (some[str](?h)) { hash = h; }
case (none[str]) {
ccx.sha.reset();
- auto f = metadata.def_to_str;
+ auto f = metadata::def_to_str;
// NB: do *not* use abbrevs here as we want the symbol names
// to be independent of one another in the crate.
- auto cx = @rec(ds=f, tcx=ccx.tcx, abbrevs=metadata.ac_no_abbrevs);
+ auto cx = @rec(ds=f,
+ tcx=ccx.tcx,
+ abbrevs=metadata::ac_no_abbrevs);
- ccx.sha.input_str(metadata.Encode.ty_str(cx, t));
- hash = Str.substr(ccx.sha.result_str(), 0u, 16u);
+ ccx.sha.input_str(metadata::Encode::ty_str(cx, t));
+ hash = _str::substr(ccx.sha.result_str(), 0u, 16u);
ccx.type_sha1s.insert(t, hash);
}
}
ret hash;
}
-fn mangle_name_by_type(&@crate_ctxt ccx, &vec[str] path, &ty.t t) -> str {
+fn mangle_name_by_type(&@crate_ctxt ccx, &vec[str] path, &ty::t t) -> str {
auto hash = get_type_sha1(ccx, t);
ret sep() + "rust" + sep() + hash + sep() + path_name(path);
}
-fn mangle_name_by_type_only(&@crate_ctxt ccx, &ty.t t, &str name) -> str {
- auto f = metadata.def_to_str;
- auto cx = @rec(ds=f, tcx=ccx.tcx, abbrevs=metadata.ac_no_abbrevs);
- auto s = ty.ty_to_short_str(ccx.tcx, t);
+fn mangle_name_by_type_only(&@crate_ctxt ccx, &ty::t t, &str name) -> str {
+ auto f = metadata::def_to_str;
+ auto cx = @rec(ds=f, tcx=ccx.tcx, abbrevs=metadata::ac_no_abbrevs);
+ auto s = ty::ty_to_short_str(ccx.tcx, t);
auto hash = get_type_sha1(ccx, t);
ret sep() + "rust" + sep() + hash + sep() + name + "_" + s;
@@ -234,11 +236,11 @@ fn res(@block_ctxt bcx, ValueRef val) -> result {
}
fn ty_str(type_names tn, TypeRef t) -> str {
- ret lib.llvm.type_to_str(tn, t);
+ ret lib::llvm::type_to_str(tn, t);
}
fn val_ty(ValueRef v) -> TypeRef {
- ret llvm.LLVMTypeOf(v);
+ ret llvm::LLVMTypeOf(v);
}
fn val_str(type_names tn, ValueRef v) -> str {
@@ -259,40 +261,40 @@ fn T_void() -> TypeRef {
// zero). This makes the result incorrect for now -- things like a tuple
// of 10 nil values will have 10-bit size -- but it doesn't seem like we
// have any other options until it's fixed upstream.
- ret llvm.LLVMVoidType();
+ ret llvm::LLVMVoidType();
}
fn T_nil() -> TypeRef {
// NB: See above in T_void().
- ret llvm.LLVMInt1Type();
+ ret llvm::LLVMInt1Type();
}
fn T_i1() -> TypeRef {
- ret llvm.LLVMInt1Type();
+ ret llvm::LLVMInt1Type();
}
fn T_i8() -> TypeRef {
- ret llvm.LLVMInt8Type();
+ ret llvm::LLVMInt8Type();
}
fn T_i16() -> TypeRef {
- ret llvm.LLVMInt16Type();
+ ret llvm::LLVMInt16Type();
}
fn T_i32() -> TypeRef {
- ret llvm.LLVMInt32Type();
+ ret llvm::LLVMInt32Type();
}
fn T_i64() -> TypeRef {
- ret llvm.LLVMInt64Type();
+ ret llvm::LLVMInt64Type();
}
fn T_f32() -> TypeRef {
- ret llvm.LLVMFloatType();
+ ret llvm::LLVMFloatType();
}
fn T_f64() -> TypeRef {
- ret llvm.LLVMDoubleType();
+ ret llvm::LLVMDoubleType();
}
fn T_bool() -> TypeRef {
@@ -319,9 +321,9 @@ fn T_size_t() -> TypeRef {
}
fn T_fn(vec[TypeRef] inputs, TypeRef output) -> TypeRef {
- ret llvm.LLVMFunctionType(output,
- Vec.buf[TypeRef](inputs),
- Vec.len[TypeRef](inputs),
+ ret llvm::LLVMFunctionType(output,
+ _vec::buf[TypeRef](inputs),
+ _vec::len[TypeRef](inputs),
False);
}
@@ -331,17 +333,17 @@ fn T_fn_pair(&type_names tn, TypeRef tfn) -> TypeRef {
}
fn T_ptr(TypeRef t) -> TypeRef {
- ret llvm.LLVMPointerType(t, 0u);
+ ret llvm::LLVMPointerType(t, 0u);
}
fn T_struct(&vec[TypeRef] elts) -> TypeRef {
- ret llvm.LLVMStructType(Vec.buf[TypeRef](elts),
- Vec.len[TypeRef](elts),
+ ret llvm::LLVMStructType(_vec::buf[TypeRef](elts),
+ _vec::len[TypeRef](elts),
False);
}
fn T_opaque() -> TypeRef {
- ret llvm.LLVMOpaqueType();
+ ret llvm::LLVMOpaqueType();
}
fn T_task(&type_names tn) -> TypeRef {
@@ -366,10 +368,10 @@ fn T_task(&type_names tn) -> TypeRef {
fn T_tydesc_field(&type_names tn, int field) -> TypeRef {
// Bit of a kludge: pick the fn typeref out of the tydesc..
let vec[TypeRef] tydesc_elts =
- Vec.init_elt[TypeRef](T_nil(), abi.n_tydesc_fields as uint);
- llvm.LLVMGetStructElementTypes(T_tydesc(tn),
- Vec.buf[TypeRef](tydesc_elts));
- auto t = llvm.LLVMGetElementType(tydesc_elts.(field));
+ _vec::init_elt[TypeRef](T_nil(), abi::n_tydesc_fields as uint);
+ llvm::LLVMGetStructElementTypes(T_tydesc(tn),
+ _vec::buf[TypeRef](tydesc_elts));
+ auto t = llvm::LLVMGetElementType(tydesc_elts.(field));
ret t;
}
@@ -379,14 +381,14 @@ fn T_glue_fn(&type_names tn) -> TypeRef {
ret tn.get_type(s);
}
- auto t = T_tydesc_field(tn, abi.tydesc_field_drop_glue);
+ auto t = T_tydesc_field(tn, abi::tydesc_field_drop_glue);
tn.associate(s, t);
ret t;
}
fn T_dtor(&@crate_ctxt ccx, TypeRef llself_ty) -> TypeRef {
- ret type_of_fn_full(ccx, ast.proto_fn, some[TypeRef](llself_ty),
- Vec.empty[ty.arg](), ty.mk_nil(ccx.tcx), 0u);
+ ret type_of_fn_full(ccx, ast::proto_fn, some[TypeRef](llself_ty),
+ _vec::empty[ty::arg](), ty::mk_nil(ccx.tcx), 0u);
}
fn T_cmp_glue_fn(&type_names tn) -> TypeRef {
@@ -395,7 +397,7 @@ fn T_cmp_glue_fn(&type_names tn) -> TypeRef {
ret tn.get_type(s);
}
- auto t = T_tydesc_field(tn, abi.tydesc_field_cmp_glue);
+ auto t = T_tydesc_field(tn, abi::tydesc_field_cmp_glue);
tn.associate(s, t);
ret t;
}
@@ -408,7 +410,7 @@ fn T_tydesc(&type_names tn) -> TypeRef {
}
auto th = mk_type_handle();
- auto abs_tydesc = llvm.LLVMResolveTypeHandle(th.llth);
+ auto abs_tydesc = llvm::LLVMResolveTypeHandle(th.llth);
auto tydescpp = T_ptr(T_ptr(abs_tydesc));
auto pvoid = T_ptr(T_i8());
auto glue_fn_ty = T_ptr(T_fn(vec(T_ptr(T_nil()),
@@ -435,15 +437,15 @@ fn T_tydesc(&type_names tn) -> TypeRef {
glue_fn_ty, // is_stateful
cmp_glue_fn_ty)); // cmp_glue
- llvm.LLVMRefineType(abs_tydesc, tydesc);
- auto t = llvm.LLVMResolveTypeHandle(th.llth);
+ llvm::LLVMRefineType(abs_tydesc, tydesc);
+ auto t = llvm::LLVMResolveTypeHandle(th.llth);
tn.associate(s, t);
ret t;
}
fn T_array(TypeRef t, uint n) -> TypeRef {
assert (n != 0u);
- ret llvm.LLVMArrayType(t, n);
+ ret llvm::LLVMArrayType(t, n);
}
fn T_vec(TypeRef t) -> TypeRef {
@@ -527,7 +529,7 @@ fn T_closure_ptr(&type_names tn,
uint n_ty_params) -> TypeRef {
// NB: keep this in sync with code in trans_bind; we're making
- // an LLVM typeref structure that has the same "shape" as the ty.t
+ // an LLVM typeref structure that has the same "shape" as the ty::t
// it constructs.
ret T_ptr(T_box(T_struct(vec(T_ptr(T_tydesc(tn)),
lltarget_ty,
@@ -550,7 +552,7 @@ fn T_opaque_closure_ptr(&type_names tn) -> TypeRef {
}
fn T_tag(&type_names tn, uint size) -> TypeRef {
- auto s = "tag_" + UInt.to_str(size, 10u);
+ auto s = "tag_" + _uint::to_str(size, 10u);
if (tn.name_has_type(s)) {
ret tn.get_type(s);
}
@@ -581,7 +583,7 @@ fn T_opaque_tag_ptr(&type_names tn) -> TypeRef {
}
fn T_captured_tydescs(&type_names tn, uint n) -> TypeRef {
- ret T_struct(Vec.init_elt[TypeRef](T_ptr(T_tydesc(tn)), n));
+ ret T_struct(_vec::init_elt[TypeRef](T_ptr(T_tydesc(tn)), n));
}
fn T_obj_ptr(&type_names tn, uint n_captured_tydescs) -> TypeRef {
@@ -608,10 +610,10 @@ fn T_opaque_chan_ptr() -> TypeRef { ret T_ptr(T_i8()); }
// return value was always meaningless in that case anyhow). Beware!
//
// TODO: Enforce via a predicate.
-fn type_of(&@crate_ctxt cx, &ty.t t) -> TypeRef {
- if (ty.type_has_dynamic_size(cx.tcx, t)) {
+fn type_of(&@crate_ctxt cx, &ty::t t) -> TypeRef {
+ if (ty::type_has_dynamic_size(cx.tcx, t)) {
log_err "type_of() called on a type with dynamic size: " +
- ty.ty_to_str(cx.tcx, t);
+ ty::ty_to_str(cx.tcx, t);
fail;
}
@@ -619,16 +621,16 @@ fn type_of(&@crate_ctxt cx, &ty.t t) -> TypeRef {
}
fn type_of_explicit_args(&@crate_ctxt cx,
- &vec[ty.arg] inputs) -> vec[TypeRef] {
+ &vec[ty::arg] inputs) -> vec[TypeRef] {
let vec[TypeRef] atys = vec();
- for (ty.arg arg in inputs) {
- if (ty.type_has_dynamic_size(cx.tcx, arg.ty)) {
- assert (arg.mode == ty.mo_alias);
+ for (ty::arg arg in inputs) {
+ if (ty::type_has_dynamic_size(cx.tcx, arg.ty)) {
+ assert (arg.mode == ty::mo_alias);
atys += vec(T_typaram_ptr(cx.tn));
} else {
let TypeRef t;
alt (arg.mode) {
- case (ty.mo_alias) {
+ case (ty::mo_alias) {
t = T_ptr(type_of_inner(cx, arg.ty));
}
case (_) {
@@ -649,21 +651,21 @@ fn type_of_explicit_args(&@crate_ctxt cx,
// - trans_args
fn type_of_fn_full(&@crate_ctxt cx,
- ast.proto proto,
- &Option.t[TypeRef] obj_self,
- &vec[ty.arg] inputs,
- &ty.t output,
+ ast::proto proto,
+ &option::t[TypeRef] obj_self,
+ &vec[ty::arg] inputs,
+ &ty::t output,
uint ty_param_count) -> TypeRef {
let vec[TypeRef] atys = vec();
// Arg 0: Output pointer.
- if (ty.type_has_dynamic_size(cx.tcx, output)) {
+ if (ty::type_has_dynamic_size(cx.tcx, output)) {
atys += vec(T_typaram_ptr(cx.tn));
} else {
atys += vec(T_ptr(type_of_inner(cx, output)));
}
- // Arg 1: Task pointer.
+ // Arg 1: task pointer.
atys += vec(T_taskptr(cx.tn));
// Arg 2: Env (closure-bindings / self-obj)
@@ -686,41 +688,41 @@ fn type_of_fn_full(&@crate_ctxt cx,
}
}
- if (proto == ast.proto_iter) {
+ if (proto == ast::proto_iter) {
// If it's an iter, the 'output' type of the iter is actually the
// *input* type of the function we're given as our iter-block
// argument.
atys +=
vec(T_fn_pair(cx.tn,
- type_of_fn_full(cx, ast.proto_fn, none[TypeRef],
- vec(rec(mode=ty.mo_alias,
+ type_of_fn_full(cx, ast::proto_fn, none[TypeRef],
+ vec(rec(mode=ty::mo_alias,
ty=output)),
- ty.mk_nil(cx.tcx), 0u)));
+ ty::mk_nil(cx.tcx), 0u)));
}
// ... then explicit args.
atys += type_of_explicit_args(cx, inputs);
- ret T_fn(atys, llvm.LLVMVoidType());
+ ret T_fn(atys, llvm::LLVMVoidType());
}
fn type_of_fn(&@crate_ctxt cx,
- ast.proto proto,
- &vec[ty.arg] inputs,
- &ty.t output,
+ ast::proto proto,
+ &vec[ty::arg] inputs,
+ &ty::t output,
uint ty_param_count) -> TypeRef {
ret type_of_fn_full(cx, proto, none[TypeRef], inputs, output,
ty_param_count);
}
-fn type_of_native_fn(&@crate_ctxt cx, ast.native_abi abi,
- &vec[ty.arg] inputs,
- &ty.t output,
+fn type_of_native_fn(&@crate_ctxt cx, ast::native_abi abi,
+ &vec[ty::arg] inputs,
+ &ty::t output,
uint ty_param_count) -> TypeRef {
let vec[TypeRef] atys = vec();
- if (abi == ast.native_abi_rust) {
+ if (abi == ast::native_abi_rust) {
atys += vec(T_taskptr(cx.tn));
- auto t = ty.ty_native_fn(abi, inputs, output);
+ auto t = ty::ty_native_fn(abi, inputs, output);
auto i = 0u;
while (i < ty_param_count) {
atys += vec(T_ptr(T_tydesc(cx.tn)));
@@ -731,7 +733,7 @@ fn type_of_native_fn(&@crate_ctxt cx, ast.native_abi abi,
ret T_fn(atys, type_of_inner(cx, output));
}
-fn type_of_inner(&@crate_ctxt cx, &ty.t t) -> TypeRef {
+fn type_of_inner(&@crate_ctxt cx, &ty::t t) -> TypeRef {
// Check the cache.
if (cx.lltypes.contains_key(t)) {
ret cx.lltypes.get(t);
@@ -739,76 +741,76 @@ fn type_of_inner(&@crate_ctxt cx, &ty.t t) -> TypeRef {
let TypeRef llty = 0 as TypeRef;
- alt (ty.struct(cx.tcx, t)) {
- case (ty.ty_native) { llty = T_ptr(T_i8()); }
- case (ty.ty_nil) { llty = T_nil(); }
- case (ty.ty_bool) { llty = T_bool(); }
- case (ty.ty_int) { llty = T_int(); }
- case (ty.ty_float) { llty = T_float(); }
- case (ty.ty_uint) { llty = T_int(); }
- case (ty.ty_machine(?tm)) {
+ alt (ty::struct(cx.tcx, t)) {
+ case (ty::ty_native) { llty = T_ptr(T_i8()); }
+ case (ty::ty_nil) { llty = T_nil(); }
+ case (ty::ty_bool) { llty = T_bool(); }
+ case (ty::ty_int) { llty = T_int(); }
+ case (ty::ty_float) { llty = T_float(); }
+ case (ty::ty_uint) { llty = T_int(); }
+ case (ty::ty_machine(?tm)) {
alt (tm) {
- case (common.ty_i8) { llty = T_i8(); }
- case (common.ty_u8) { llty = T_i8(); }
- case (common.ty_i16) { llty = T_i16(); }
- case (common.ty_u16) { llty = T_i16(); }
- case (common.ty_i32) { llty = T_i32(); }
- case (common.ty_u32) { llty = T_i32(); }
- case (common.ty_i64) { llty = T_i64(); }
- case (common.ty_u64) { llty = T_i64(); }
- case (common.ty_f32) { llty = T_f32(); }
- case (common.ty_f64) { llty = T_f64(); }
+ case (common::ty_i8) { llty = T_i8(); }
+ case (common::ty_u8) { llty = T_i8(); }
+ case (common::ty_i16) { llty = T_i16(); }
+ case (common::ty_u16) { llty = T_i16(); }
+ case (common::ty_i32) { llty = T_i32(); }
+ case (common::ty_u32) { llty = T_i32(); }
+ case (common::ty_i64) { llty = T_i64(); }
+ case (common::ty_u64) { llty = T_i64(); }
+ case (common::ty_f32) { llty = T_f32(); }
+ case (common::ty_f64) { llty = T_f64(); }
}
}
- case (ty.ty_char) { llty = T_char(); }
- case (ty.ty_str) { llty = T_ptr(T_str()); }
- case (ty.ty_tag(_, _)) {
- if (ty.type_has_dynamic_size(cx.tcx, t)) {
+ case (ty::ty_char) { llty = T_char(); }
+ case (ty::ty_str) { llty = T_ptr(T_str()); }
+ case (ty::ty_tag(_, _)) {
+ if (ty::type_has_dynamic_size(cx.tcx, t)) {
llty = T_opaque_tag(cx.tn);
} else {
auto size = static_size_of_tag(cx, t);
llty = T_tag(cx.tn, size);
}
}
- case (ty.ty_box(?mt)) {
+ case (ty::ty_box(?mt)) {
llty = T_ptr(T_box(type_of_inner(cx, mt.ty)));
}
- case (ty.ty_vec(?mt)) {
+ case (ty::ty_vec(?mt)) {
llty = T_ptr(T_vec(type_of_inner(cx, mt.ty)));
}
- case (ty.ty_port(?t)) {
+ case (ty::ty_port(?t)) {
llty = T_ptr(T_port(type_of_inner(cx, t)));
}
- case (ty.ty_chan(?t)) {
+ case (ty::ty_chan(?t)) {
llty = T_ptr(T_chan(type_of_inner(cx, t)));
}
- case (ty.ty_tup(?elts)) {
+ case (ty::ty_tup(?elts)) {
let vec[TypeRef] tys = vec();
- for (ty.mt elt in elts) {
+ for (ty::mt elt in elts) {
tys += vec(type_of_inner(cx, elt.ty));
}
llty = T_struct(tys);
}
- case (ty.ty_rec(?fields)) {
+ case (ty::ty_rec(?fields)) {
let vec[TypeRef] tys = vec();
- for (ty.field f in fields) {
+ for (ty::field f in fields) {
tys += vec(type_of_inner(cx, f.mt.ty));
}
llty = T_struct(tys);
}
- case (ty.ty_fn(?proto, ?args, ?out)) {
+ case (ty::ty_fn(?proto, ?args, ?out)) {
llty = T_fn_pair(cx.tn, type_of_fn(cx, proto, args, out, 0u));
}
- case (ty.ty_native_fn(?abi, ?args, ?out)) {
+ case (ty::ty_native_fn(?abi, ?args, ?out)) {
auto nft = native_fn_wrapper_type(cx, 0u, t);
llty = T_fn_pair(cx.tn, nft);
}
- case (ty.ty_obj(?meths)) {
+ case (ty::ty_obj(?meths)) {
auto th = mk_type_handle();
- auto self_ty = llvm.LLVMResolveTypeHandle(th.llth);
+ auto self_ty = llvm::LLVMResolveTypeHandle(th.llth);
let vec[TypeRef] mtys = vec(T_ptr(T_i8()));
- for (ty.method m in meths) {
+ for (ty::method m in meths) {
let TypeRef mty =
type_of_fn_full(cx, m.proto,
some[TypeRef](self_ty),
@@ -819,39 +821,39 @@ fn type_of_inner(&@crate_ctxt cx, &ty.t t) -> TypeRef {
let TypeRef pair = T_struct(vec(T_ptr(vtbl),
T_opaque_obj_ptr(cx.tn)));
- auto abs_pair = llvm.LLVMResolveTypeHandle(th.llth);
- llvm.LLVMRefineType(abs_pair, pair);
- abs_pair = llvm.LLVMResolveTypeHandle(th.llth);
+ auto abs_pair = llvm::LLVMResolveTypeHandle(th.llth);
+ llvm::LLVMRefineType(abs_pair, pair);
+ abs_pair = llvm::LLVMResolveTypeHandle(th.llth);
llty = abs_pair;
}
- case (ty.ty_var(_)) {
- log_err "ty_var in trans.type_of";
+ case (ty::ty_var(_)) {
+ log_err "ty_var in trans::type_of";
fail;
}
- case (ty.ty_param(_)) {
+ case (ty::ty_param(_)) {
llty = T_i8();
}
- case (ty.ty_bound_param(_)) {
- log_err "ty_bound_param in trans.type_of";
+ case (ty::ty_bound_param(_)) {
+ log_err "ty_bound_param in trans::type_of";
fail;
}
- case (ty.ty_type) { llty = T_ptr(T_tydesc(cx.tn)); }
+ case (ty::ty_type) { llty = T_ptr(T_tydesc(cx.tn)); }
}
assert (llty as int != 0);
if (cx.sess.get_opts().save_temps) {
- llvm.LLVMAddTypeName(cx.llmod,
- Str.buf(ty.ty_to_short_str(cx.tcx, t)),
+ llvm::LLVMAddTypeName(cx.llmod,
+ _str::buf(ty::ty_to_short_str(cx.tcx, t)),
llty);
}
cx.lltypes.insert(t, llty);
ret llty;
}
-fn type_of_arg(@local_ctxt cx, &ty.arg arg) -> TypeRef {
- alt (ty.struct(cx.ccx.tcx, arg.ty)) {
- case (ty.ty_param(_)) {
- if (arg.mode == ty.mo_alias) {
+fn type_of_arg(@local_ctxt cx, &ty::arg arg) -> TypeRef {
+ alt (ty::struct(cx.ccx.tcx, arg.ty)) {
+ case (ty::ty_param(_)) {
+ if (arg.mode == ty::mo_alias) {
ret T_typaram_ptr(cx.ccx.tn);
}
}
@@ -861,7 +863,7 @@ fn type_of_arg(@local_ctxt cx, &ty.arg arg) -> TypeRef {
}
auto typ;
- if (arg.mode == ty.mo_alias) {
+ if (arg.mode == ty::mo_alias) {
typ = T_ptr(type_of_inner(cx.ccx, arg.ty));
} else {
typ = type_of_inner(cx.ccx, arg.ty);
@@ -870,9 +872,9 @@ fn type_of_arg(@local_ctxt cx, &ty.arg arg) -> TypeRef {
}
fn type_of_ty_param_count_and_ty(@local_ctxt lcx,
- &ty.ty_param_count_and_ty tpt) -> TypeRef {
- alt (ty.struct(lcx.ccx.tcx, tpt._1)) {
- case (ty.ty_fn(?proto, ?inputs, ?output)) {
+ &ty::ty_param_count_and_ty tpt) -> TypeRef {
+ alt (ty::struct(lcx.ccx.tcx, tpt._1)) {
+ case (ty::ty_fn(?proto, ?inputs, ?output)) {
auto llfnty = type_of_fn(lcx.ccx, proto, inputs, output, tpt._0);
ret T_fn_pair(lcx.ccx.tn, llfnty);
}
@@ -903,7 +905,7 @@ fn sanitize(&str s) -> str {
c != (' ' as u8) && c != ('\t' as u8) &&
c != (';' as u8)) {
auto v = vec(c);
- result += Str.from_bytes(v);
+ result += _str::from_bytes(v);
}
}
}
@@ -915,24 +917,24 @@ fn sanitize(&str s) -> str {
// LLVM constant constructors.
fn C_null(TypeRef t) -> ValueRef {
- ret llvm.LLVMConstNull(t);
+ ret llvm::LLVMConstNull(t);
}
fn C_integral(TypeRef t, uint u, Bool sign_extend) -> ValueRef {
- // FIXME. We can't use LLVM.ULongLong with our existing minimal native
+ // FIXME: We can't use LLVM::ULongLong with our existing minimal native
// API, which only knows word-sized args.
//
- // ret llvm.LLVMConstInt(T_int(), t as LLVM.ULongLong, False);
+ // ret llvm::LLVMConstInt(T_int(), t as LLVM::ULongLong, False);
//
- ret llvm.LLVMRustConstSmallInt(t, u, sign_extend);
+ ret llvm::LLVMRustConstSmallInt(t, u, sign_extend);
}
fn C_float(&str s) -> ValueRef {
- ret llvm.LLVMConstRealOfString(T_float(), Str.buf(s));
+ ret llvm::LLVMConstRealOfString(T_float(), _str::buf(s));
}
fn C_floating(&str s, TypeRef t) -> ValueRef {
- ret llvm.LLVMConstRealOfString(t, Str.buf(s));
+ ret llvm::LLVMConstRealOfString(t, _str::buf(s));
}
fn C_nil() -> ValueRef {
@@ -959,32 +961,32 @@ fn C_u8(uint i) -> ValueRef {
// This is a 'c-like' raw string, which differs from
// our boxed-and-length-annotated strings.
fn C_cstr(&@crate_ctxt cx, &str s) -> ValueRef {
- auto sc = llvm.LLVMConstString(Str.buf(s), Str.byte_len(s), False);
- auto g = llvm.LLVMAddGlobal(cx.llmod, val_ty(sc),
- Str.buf(cx.names.next("str")));
- llvm.LLVMSetInitializer(g, sc);
- llvm.LLVMSetGlobalConstant(g, True);
- llvm.LLVMSetLinkage(g, lib.llvm.LLVMInternalLinkage
- as llvm.Linkage);
+ auto sc = llvm::LLVMConstString(_str::buf(s), _str::byte_len(s), False);
+ auto g = llvm::LLVMAddGlobal(cx.llmod, val_ty(sc),
+ _str::buf(cx.names.next("str")));
+ llvm::LLVMSetInitializer(g, sc);
+ llvm::LLVMSetGlobalConstant(g, True);
+ llvm::LLVMSetLinkage(g, lib::llvm::LLVMInternalLinkage
+ as llvm::Linkage);
ret g;
}
// A rust boxed-and-length-annotated string.
fn C_str(&@crate_ctxt cx, &str s) -> ValueRef {
- auto len = Str.byte_len(s);
- auto box = C_struct(vec(C_int(abi.const_refcount as int),
+ auto len = _str::byte_len(s);
+ auto box = C_struct(vec(C_int(abi::const_refcount as int),
C_int(len + 1u as int), // 'alloc'
C_int(len + 1u as int), // 'fill'
C_int(0), // 'pad'
- llvm.LLVMConstString(Str.buf(s),
+ llvm::LLVMConstString(_str::buf(s),
len, False)));
- auto g = llvm.LLVMAddGlobal(cx.llmod, val_ty(box),
- Str.buf(cx.names.next("str")));
- llvm.LLVMSetInitializer(g, box);
- llvm.LLVMSetGlobalConstant(g, True);
- llvm.LLVMSetLinkage(g, lib.llvm.LLVMInternalLinkage
- as llvm.Linkage);
- ret llvm.LLVMConstPointerCast(g, T_ptr(T_str()));
+ auto g = llvm::LLVMAddGlobal(cx.llmod, val_ty(box),
+ _str::buf(cx.names.next("str")));
+ llvm::LLVMSetInitializer(g, box);
+ llvm::LLVMSetGlobalConstant(g, True);
+ llvm::LLVMSetLinkage(g, lib::llvm::LLVMInternalLinkage
+ as llvm::Linkage);
+ ret llvm::LLVMConstPointerCast(g, T_ptr(T_str()));
}
fn C_zero_byte_arr(uint size) -> ValueRef {
@@ -994,40 +996,41 @@ fn C_zero_byte_arr(uint size) -> ValueRef {
elts += vec(C_u8(0u));
i += 1u;
}
- ret llvm.LLVMConstArray(T_i8(), Vec.buf[ValueRef](elts),
- Vec.len[ValueRef](elts));
+ ret llvm::LLVMConstArray(T_i8(), _vec::buf[ValueRef](elts),
+ _vec::len[ValueRef](elts));
}
fn C_struct(&vec[ValueRef] elts) -> ValueRef {
- ret llvm.LLVMConstStruct(Vec.buf[ValueRef](elts),
- Vec.len[ValueRef](elts),
+ ret llvm::LLVMConstStruct(_vec::buf[ValueRef](elts),
+ _vec::len[ValueRef](elts),
False);
}
fn C_array(TypeRef ty, &vec[ValueRef] elts) -> ValueRef {
- ret llvm.LLVMConstArray(ty, Vec.buf[ValueRef](elts),
- Vec.len[ValueRef](elts));
+ ret llvm::LLVMConstArray(ty, _vec::buf[ValueRef](elts),
+ _vec::len[ValueRef](elts));
}
fn decl_fn(ModuleRef llmod, &str name, uint cc, TypeRef llty) -> ValueRef {
let ValueRef llfn =
- llvm.LLVMAddFunction(llmod, Str.buf(name), llty);
- llvm.LLVMSetFunctionCallConv(llfn, cc);
+ llvm::LLVMAddFunction(llmod, _str::buf(name), llty);
+ llvm::LLVMSetFunctionCallConv(llfn, cc);
ret llfn;
}
fn decl_cdecl_fn(ModuleRef llmod, &str name, TypeRef llty) -> ValueRef {
- ret decl_fn(llmod, name, lib.llvm.LLVMCCallConv, llty);
+ ret decl_fn(llmod, name, lib::llvm::LLVMCCallConv, llty);
}
fn decl_fastcall_fn(ModuleRef llmod, &str name, TypeRef llty) -> ValueRef {
- ret decl_fn(llmod, name, lib.llvm.LLVMFastCallConv, llty);
+ ret decl_fn(llmod, name, lib::llvm::LLVMFastCallConv, llty);
}
fn decl_internal_fastcall_fn(ModuleRef llmod,
&str name, TypeRef llty) -> ValueRef {
- auto llfn = decl_fn(llmod, name, lib.llvm.LLVMFastCallConv, llty);
- llvm.LLVMSetLinkage(llfn, lib.llvm.LLVMInternalLinkage as llvm.Linkage);
+ auto llfn = decl_fn(llmod, name, lib::llvm::LLVMFastCallConv, llty);
+ llvm::LLVMSetLinkage(llfn, lib::llvm::LLVMInternalLinkage
+ as llvm::Linkage);
ret llfn;
}
@@ -1036,12 +1039,12 @@ fn decl_glue(ModuleRef llmod, type_names tn, &str s) -> ValueRef {
}
fn decl_native_glue(ModuleRef llmod, &type_names tn,
- abi.native_glue_type ngt, uint _n) -> ValueRef {
+ abi::native_glue_type ngt, uint _n) -> ValueRef {
let bool pass_task;
alt (ngt) {
- case (abi.ngt_rust) { pass_task = true; }
- case (abi.ngt_pure_rust) { pass_task = true; }
- case (abi.ngt_cdecl) { pass_task = false; }
+ case (abi::ngt_rust) { pass_task = true; }
+ case (abi::ngt_pure_rust) { pass_task = true; }
+ case (abi::ngt_cdecl) { pass_task = false; }
}
// It doesn't actually matter what type we come up with here, at the
@@ -1049,14 +1052,14 @@ fn decl_native_glue(ModuleRef llmod, &type_names tn,
// them to the indirect native-invocation glue. But eventually we'd like
// to call them directly, once we have a calling convention worked out.
let int n = _n as int;
- let str s = abi.native_glue_name(n, ngt);
+ let str s = abi::native_glue_name(n, ngt);
let vec[TypeRef] args = vec(T_int()); // callee
if (!pass_task) {
args += vec(T_int()); // taskptr, will not be passed
}
- args += Vec.init_elt[TypeRef](T_int(), n as uint);
+ args += _vec::init_elt[TypeRef](T_int(), n as uint);
ret decl_fastcall_fn(llmod, s, T_fn(args, T_int()));
}
@@ -1077,7 +1080,7 @@ fn get_extern_const(&hashmap[str, ValueRef] externs,
if (externs.contains_key(name)) {
ret externs.get(name);
}
- auto c = llvm.LLVMAddGlobal(llmod, ty, Str.buf(name));
+ auto c = llvm::LLVMAddGlobal(llmod, ty, _str::buf(name));
externs.insert(name, c);
ret c;
}
@@ -1085,19 +1088,19 @@ fn get_extern_const(&hashmap[str, ValueRef] externs,
fn get_simple_extern_fn(&hashmap[str, ValueRef] externs,
ModuleRef llmod, &str name,
int n_args) -> ValueRef {
- auto inputs = Vec.init_elt[TypeRef](T_int(), n_args as uint);
+ auto inputs = _vec::init_elt[TypeRef](T_int(), n_args as uint);
auto output = T_int();
auto t = T_fn(inputs, output);
- ret get_extern_fn(externs, llmod, name, lib.llvm.LLVMCCallConv, t);
+ ret get_extern_fn(externs, llmod, name, lib::llvm::LLVMCCallConv, t);
}
fn trans_native_call(&builder b, @glue_fns glues, ValueRef lltaskptr,
&hashmap[str, ValueRef] externs,
&type_names tn, ModuleRef llmod, &str name,
bool pass_task, &vec[ValueRef] args) -> ValueRef {
- let int n = (Vec.len[ValueRef](args) as int);
+ let int n = (_vec::len[ValueRef](args) as int);
let ValueRef llnative = get_simple_extern_fn(externs, llmod, name, n);
- llnative = llvm.LLVMConstPointerCast(llnative, T_int());
+ llnative = llvm::LLVMConstPointerCast(llnative, T_int());
let ValueRef llglue;
if (pass_task) {
@@ -1152,12 +1155,12 @@ fn find_outer_scope_cx(&@block_ctxt cx) -> @block_ctxt {
}
fn umax(&@block_ctxt cx, ValueRef a, ValueRef b) -> ValueRef {
- auto cond = cx.build.ICmp(lib.llvm.LLVMIntULT, a, b);
+ auto cond = cx.build.ICmp(lib::llvm::LLVMIntULT, a, b);
ret cx.build.Select(cond, b, a);
}
fn umin(&@block_ctxt cx, ValueRef a, ValueRef b) -> ValueRef {
- auto cond = cx.build.ICmp(lib.llvm.LLVMIntULT, a, b);
+ auto cond = cx.build.ICmp(lib::llvm::LLVMIntULT, a, b);
ret cx.build.Select(cond, a, b);
}
@@ -1169,26 +1172,28 @@ fn align_to(&@block_ctxt cx, ValueRef off, ValueRef align) -> ValueRef {
// Returns the real size of the given type for the current target.
fn llsize_of_real(&@crate_ctxt cx, TypeRef t) -> uint {
- ret llvm.LLVMStoreSizeOfType(cx.td.lltd, t);
+ ret llvm::LLVMStoreSizeOfType(cx.td.lltd, t);
}
fn llsize_of(TypeRef t) -> ValueRef {
- ret llvm.LLVMConstIntCast(lib.llvm.llvm.LLVMSizeOf(t), T_int(), False);
+ ret llvm::LLVMConstIntCast(lib::llvm::llvm::LLVMSizeOf(t),
+ T_int(), False);
}
fn llalign_of(TypeRef t) -> ValueRef {
- ret llvm.LLVMConstIntCast(lib.llvm.llvm.LLVMAlignOf(t), T_int(), False);
+ ret llvm::LLVMConstIntCast(lib::llvm::llvm::LLVMAlignOf(t),
+ T_int(), False);
}
-fn size_of(&@block_ctxt cx, &ty.t t) -> result {
- if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
+fn size_of(&@block_ctxt cx, &ty::t t) -> result {
+ if (!ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
ret res(cx, llsize_of(type_of(cx.fcx.lcx.ccx, t)));
}
ret dynamic_size_of(cx, t);
}
-fn align_of(&@block_ctxt cx, &ty.t t) -> result {
- if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
+fn align_of(&@block_ctxt cx, &ty::t t) -> result {
+ if (!ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
ret res(cx, llalign_of(type_of(cx.fcx.lcx.ccx, t)));
}
ret dynamic_align_of(cx, t);
@@ -1207,22 +1212,22 @@ fn array_alloca(&@block_ctxt cx, TypeRef t, ValueRef n) -> ValueRef {
// to have (a) the same size as the type that was passed in; (b) to be non-
// recursive. This is done by replacing all boxes in a type with boxed unit
// types.
-fn simplify_type(&@crate_ctxt ccx, &ty.t typ) -> ty.t {
- fn simplifier(@crate_ctxt ccx, ty.t typ) -> ty.t {
- alt (ty.struct(ccx.tcx, typ)) {
- case (ty.ty_box(_)) {
- ret ty.mk_imm_box(ccx.tcx, ty.mk_nil(ccx.tcx));
+fn simplify_type(&@crate_ctxt ccx, &ty::t typ) -> ty::t {
+ fn simplifier(@crate_ctxt ccx, ty::t typ) -> ty::t {
+ alt (ty::struct(ccx.tcx, typ)) {
+ case (ty::ty_box(_)) {
+ ret ty::mk_imm_box(ccx.tcx, ty::mk_nil(ccx.tcx));
}
case (_) { ret typ; }
}
}
auto f = bind simplifier(ccx, _);
- ret ty.fold_ty(ccx.tcx, f, typ);
+ ret ty::fold_ty(ccx.tcx, f, typ);
}
// Computes the size of the data part of a non-dynamically-sized tag.
-fn static_size_of_tag(&@crate_ctxt cx, &ty.t t) -> uint {
- if (ty.type_has_dynamic_size(cx.tcx, t)) {
+fn static_size_of_tag(&@crate_ctxt cx, &ty::t t) -> uint {
+ if (ty::type_has_dynamic_size(cx.tcx, t)) {
log_err "dynamically sized type passed to static_size_of_tag()";
fail;
}
@@ -1232,9 +1237,9 @@ fn static_size_of_tag(&@crate_ctxt cx, &ty.t t) -> uint {
}
auto tid;
- let vec[ty.t] subtys;
- alt (ty.struct(cx.tcx, t)) {
- case (ty.ty_tag(?tid_, ?subtys_)) {
+ let vec[ty::t] subtys;
+ alt (ty::struct(cx.tcx, t)) {
+ case (ty::ty_tag(?tid_, ?subtys_)) {
tid = tid_;
subtys = subtys_;
}
@@ -1248,11 +1253,11 @@ fn static_size_of_tag(&@crate_ctxt cx, &ty.t t) -> uint {
auto max_size = 0u;
auto variants = tag_variants(cx, tid);
for (variant_info variant in variants) {
- auto tup_ty = simplify_type(cx, ty.mk_imm_tup(cx.tcx, variant.args));
+ auto tup_ty = simplify_type(cx, ty::mk_imm_tup(cx.tcx, variant.args));
// Perform any type parameter substitutions.
- tup_ty = ty.bind_params_in_type(cx.tcx, tup_ty);
- tup_ty = ty.substitute_type_params(cx.tcx, subtys, tup_ty);
+ tup_ty = ty::bind_params_in_type(cx.tcx, tup_ty);
+ tup_ty = ty::substitute_type_params(cx.tcx, subtys, tup_ty);
// Here we possibly do a recursive call.
auto this_size = llsize_of_real(cx, type_of(cx, tup_ty));
@@ -1266,8 +1271,8 @@ fn static_size_of_tag(&@crate_ctxt cx, &ty.t t) -> uint {
ret max_size;
}
-fn dynamic_size_of(&@block_ctxt cx, ty.t t) -> result {
- fn align_elements(&@block_ctxt cx, &vec[ty.t] elts) -> result {
+fn dynamic_size_of(&@block_ctxt cx, ty::t t) -> result {
+ fn align_elements(&@block_ctxt cx, &vec[ty::t] elts) -> result {
//
// C padding rules:
//
@@ -1279,7 +1284,7 @@ fn dynamic_size_of(&@block_ctxt cx, ty.t t) -> result {
auto off = C_int(0);
auto max_align = C_int(1);
auto bcx = cx;
- for (ty.t e in elts) {
+ for (ty::t e in elts) {
auto elt_align = align_of(bcx, e);
bcx = elt_align.bcx;
auto elt_size = size_of(bcx, e);
@@ -1292,26 +1297,27 @@ fn dynamic_size_of(&@block_ctxt cx, ty.t t) -> result {
ret res(bcx, off);
}
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
- case (ty.ty_param(?p)) {
- auto szptr = field_of_tydesc(cx, t, false, abi.tydesc_field_size);
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
+ case (ty::ty_param(?p)) {
+ auto szptr = field_of_tydesc(cx, t, false,
+ abi::tydesc_field_size);
ret res(szptr.bcx, szptr.bcx.build.Load(szptr.val));
}
- case (ty.ty_tup(?elts)) {
- let vec[ty.t] tys = vec();
- for (ty.mt mt in elts) {
+ case (ty::ty_tup(?elts)) {
+ let vec[ty::t] tys = vec();
+ for (ty::mt mt in elts) {
tys += vec(mt.ty);
}
ret align_elements(cx, tys);
}
- case (ty.ty_rec(?flds)) {
- let vec[ty.t] tys = vec();
- for (ty.field f in flds) {
+ case (ty::ty_rec(?flds)) {
+ let vec[ty::t] tys = vec();
+ for (ty::field f in flds) {
tys += vec(f.mt.ty);
}
ret align_elements(cx, tys);
}
- case (ty.ty_tag(?tid, ?tps)) {
+ case (ty::ty_tag(?tid, ?tps)) {
auto bcx = cx;
// Compute max(variant sizes).
@@ -1321,12 +1327,13 @@ fn dynamic_size_of(&@block_ctxt cx, ty.t t) -> result {
auto variants = tag_variants(bcx.fcx.lcx.ccx, tid);
for (variant_info variant in variants) {
// Perform type substitution on the raw argument types.
- let vec[ty.t] raw_tys = variant.args;
- let vec[ty.t] tys = vec();
- for (ty.t raw_ty in raw_tys) {
- auto t = ty.bind_params_in_type(cx.fcx.lcx.ccx.tcx,
+ let vec[ty::t] raw_tys = variant.args;
+ let vec[ty::t] tys = vec();
+ for (ty::t raw_ty in raw_tys) {
+ auto t = ty::bind_params_in_type(cx.fcx.lcx.ccx.tcx,
raw_ty);
- t = ty.substitute_type_params(cx.fcx.lcx.ccx.tcx, tps, t);
+ t = ty::substitute_type_params(cx.fcx.lcx.ccx.tcx, tps,
+ t);
tys += vec(t);
}
@@ -1345,33 +1352,34 @@ fn dynamic_size_of(&@block_ctxt cx, ty.t t) -> result {
}
}
-fn dynamic_align_of(&@block_ctxt cx, &ty.t t) -> result {
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
- case (ty.ty_param(?p)) {
- auto aptr = field_of_tydesc(cx, t, false, abi.tydesc_field_align);
+fn dynamic_align_of(&@block_ctxt cx, &ty::t t) -> result {
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
+ case (ty::ty_param(?p)) {
+ auto aptr = field_of_tydesc(cx, t, false,
+ abi::tydesc_field_align);
ret res(aptr.bcx, aptr.bcx.build.Load(aptr.val));
}
- case (ty.ty_tup(?elts)) {
+ case (ty::ty_tup(?elts)) {
auto a = C_int(1);
auto bcx = cx;
- for (ty.mt e in elts) {
+ for (ty::mt e in elts) {
auto align = align_of(bcx, e.ty);
bcx = align.bcx;
a = umax(bcx, a, align.val);
}
ret res(bcx, a);
}
- case (ty.ty_rec(?flds)) {
+ case (ty::ty_rec(?flds)) {
auto a = C_int(1);
auto bcx = cx;
- for (ty.field f in flds) {
+ for (ty::field f in flds) {
auto align = align_of(bcx, f.mt.ty);
bcx = align.bcx;
a = umax(bcx, a, align.val);
}
ret res(bcx, a);
}
- case (ty.ty_tag(_, _)) {
+ case (ty::ty_tag(_, _)) {
ret res(cx, C_int(1)); // FIXME: stub
}
}
@@ -1379,18 +1387,18 @@ fn dynamic_align_of(&@block_ctxt cx, &ty.t t) -> result {
// Replacement for the LLVM 'GEP' instruction when field-indexing into a
// tuple-like structure (tup, rec) with a static index. This one is driven off
-// ty.struct and knows what to do when it runs into a ty_param stuck in the
+// ty::struct and knows what to do when it runs into a ty_param stuck in the
// middle of the thing it's GEP'ing into. Much like size_of and align_of,
// above.
-fn GEP_tup_like(&@block_ctxt cx, &ty.t t,
+fn GEP_tup_like(&@block_ctxt cx, &ty::t t,
ValueRef base, &vec[int] ixs) -> result {
- assert (ty.type_is_tup_like(cx.fcx.lcx.ccx.tcx, t));
+ assert (ty::type_is_tup_like(cx.fcx.lcx.ccx.tcx, t));
// It might be a static-known type. Handle this.
- if (! ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
+ if (! ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
let vec[ValueRef] v = vec();
for (int i in ixs) {
v += vec(C_int(i));
@@ -1415,12 +1423,12 @@ fn GEP_tup_like(&@block_ctxt cx, &ty.t t,
// elements of the type and splitting the Xth off. Return the prefix as
// well as the innermost Xth type.
- fn split_type(&@crate_ctxt ccx, &ty.t t, &vec[int] ixs, uint n)
- -> rec(vec[ty.t] prefix, ty.t target) {
+ fn split_type(&@crate_ctxt ccx, &ty::t t, &vec[int] ixs, uint n)
+ -> rec(vec[ty::t] prefix, ty::t target) {
- let uint len = Vec.len[int](ixs);
+ let uint len = _vec::len[int](ixs);
- // We don't support 0-index or 1-index GEPs. The former is nonsense
+ // We don't support 0-index or 1-index GEPs: The former is nonsense
// and the latter would only be meaningful if we supported non-0
// values for the 0th index (we don't).
@@ -1437,15 +1445,15 @@ fn GEP_tup_like(&@block_ctxt cx, &ty.t t,
assert (n < len);
let int ix = ixs.(n);
- let vec[ty.t] prefix = vec();
+ let vec[ty::t] prefix = vec();
let int i = 0;
while (i < ix) {
- Vec.push[ty.t](prefix,
- ty.get_element_type(ccx.tcx, t, i as uint));
+ _vec::push[ty::t](prefix,
+ ty::get_element_type(ccx.tcx, t, i as uint));
i += 1 ;
}
- auto selected = ty.get_element_type(ccx.tcx, t, i as uint);
+ auto selected = ty::get_element_type(ccx.tcx, t, i as uint);
if (n == len-1u) {
// We are at the innermost index.
@@ -1466,14 +1474,14 @@ fn GEP_tup_like(&@block_ctxt cx, &ty.t t,
// flattened the incoming structure.
auto s = split_type(cx.fcx.lcx.ccx, t, ixs, 0u);
- auto prefix_ty = ty.mk_imm_tup(cx.fcx.lcx.ccx.tcx, s.prefix);
+ auto prefix_ty = ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx, s.prefix);
auto bcx = cx;
auto sz = size_of(bcx, prefix_ty);
bcx = sz.bcx;
auto raw = bcx.build.PointerCast(base, T_ptr(T_i8()));
auto bumped = bcx.build.GEP(raw, vec(sz.val));
- if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, s.target)) {
+ if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, s.target)) {
ret res(bcx, bumped);
}
@@ -1487,9 +1495,9 @@ fn GEP_tup_like(&@block_ctxt cx, &ty.t t,
// meaningless, as it will be cast away.
fn GEP_tag(@block_ctxt cx,
ValueRef llblobptr,
- &ast.def_id tag_id,
- &ast.def_id variant_id,
- &vec[ty.t] ty_substs,
+ &ast::def_id tag_id,
+ &ast::def_id variant_id,
+ &vec[ty::t] ty_substs,
int ix)
-> result {
auto variant = tag_variant_with_id(cx.fcx.lcx.ccx, tag_id, variant_id);
@@ -1497,12 +1505,12 @@ fn GEP_tag(@block_ctxt cx,
// Synthesize a tuple type so that GEP_tup_like() can work its magic.
// Separately, store the type of the element we're interested in.
auto arg_tys = variant.args;
- auto elem_ty = ty.mk_nil(cx.fcx.lcx.ccx.tcx); // typestate infelicity
+ auto elem_ty = ty::mk_nil(cx.fcx.lcx.ccx.tcx); // typestate infelicity
auto i = 0;
- let vec[ty.t] true_arg_tys = vec();
- for (ty.t aty in arg_tys) {
- auto arg_ty = ty.bind_params_in_type(cx.fcx.lcx.ccx.tcx, aty);
- arg_ty = ty.substitute_type_params(cx.fcx.lcx.ccx.tcx, ty_substs,
+ let vec[ty::t] true_arg_tys = vec();
+ for (ty::t aty in arg_tys) {
+ auto arg_ty = ty::bind_params_in_type(cx.fcx.lcx.ccx.tcx, aty);
+ arg_ty = ty::substitute_type_params(cx.fcx.lcx.ccx.tcx, ty_substs,
arg_ty);
true_arg_tys += vec(arg_ty);
if (i == ix) {
@@ -1512,12 +1520,12 @@ fn GEP_tag(@block_ctxt cx,
i += 1;
}
- auto tup_ty = ty.mk_imm_tup(cx.fcx.lcx.ccx.tcx, true_arg_tys);
+ auto tup_ty = ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx, true_arg_tys);
// Cast the blob pointer to the appropriate type, if we need to (i.e. if
// the blob pointer isn't dynamically sized).
let ValueRef llunionptr;
- if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, tup_ty)) {
+ if (!ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, tup_ty)) {
auto llty = type_of(cx.fcx.lcx.ccx, tup_ty);
llunionptr = cx.build.TruncOrBitCast(llblobptr, T_ptr(llty));
} else {
@@ -1529,7 +1537,7 @@ fn GEP_tag(@block_ctxt cx,
// Cast the result to the appropriate type, if necessary.
auto val;
- if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, elem_ty)) {
+ if (!ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, elem_ty)) {
auto llelemty = type_of(rslt.bcx.fcx.lcx.ccx, elem_ty);
val = rslt.bcx.build.PointerCast(rslt.val, T_ptr(llelemty));
} else {
@@ -1549,12 +1557,12 @@ fn trans_raw_malloc(&@block_ctxt cx, TypeRef llptr_ty, ValueRef llsize)
ret res(cx, cx.build.PointerCast(rval, llptr_ty));
}
-fn trans_malloc_boxed(&@block_ctxt cx, ty.t t) -> result {
+fn trans_malloc_boxed(&@block_ctxt cx, ty::t t) -> result {
// Synthesize a fake box type structurally so we have something
// to measure the size of.
- auto boxed_body = ty.mk_imm_tup(cx.fcx.lcx.ccx.tcx,
- vec(ty.mk_int(cx.fcx.lcx.ccx.tcx), t));
- auto box_ptr = ty.mk_imm_box(cx.fcx.lcx.ccx.tcx, t);
+ auto boxed_body = ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx,
+ vec(ty::mk_int(cx.fcx.lcx.ccx.tcx), t));
+ auto box_ptr = ty::mk_imm_box(cx.fcx.lcx.ccx.tcx, t);
auto sz = size_of(cx, boxed_body);
auto llty = type_of(cx.fcx.lcx.ccx, box_ptr);
ret trans_raw_malloc(sz.bcx, llty, sz.val);
@@ -1566,7 +1574,7 @@ fn trans_malloc_boxed(&@block_ctxt cx, ty.t t) -> result {
// Given a type and a field index into its corresponding type descriptor,
// returns an LLVM ValueRef of that field from the tydesc, generating the
// tydesc if necessary.
-fn field_of_tydesc(&@block_ctxt cx, &ty.t t, bool escapes, int field)
+fn field_of_tydesc(&@block_ctxt cx, &ty::t t, bool escapes, int field)
-> result {
auto tydesc = get_tydesc(cx, t, escapes);
ret res(tydesc.bcx,
@@ -1577,7 +1585,7 @@ fn field_of_tydesc(&@block_ctxt cx, &ty.t t, bool escapes, int field)
// each of the ty params it uses (from the current frame) and a vector of the
// indices of the ty params present in the type. This is used solely for
// constructing derived tydescs.
-fn linearize_ty_params(&@block_ctxt cx, &ty.t t) ->
+fn linearize_ty_params(&@block_ctxt cx, &ty::t t) ->
tup(vec[uint], vec[ValueRef]) {
let vec[ValueRef] param_vals = vec();
let vec[uint] param_defs = vec();
@@ -1585,9 +1593,9 @@ fn linearize_ty_params(&@block_ctxt cx, &ty.t t) ->
mutable vec[ValueRef] vals,
mutable vec[uint] defs);
- fn linearizer(@rr r, ty.t t) {
- alt(ty.struct(r.cx.fcx.lcx.ccx.tcx, t)) {
- case (ty.ty_param(?pid)) {
+ fn linearizer(@rr r, ty::t t) {
+ alt(ty::struct(r.cx.fcx.lcx.ccx.tcx, t)) {
+ case (ty::ty_param(?pid)) {
let bool seen = false;
for (uint d in r.defs) {
if (d == pid) {
@@ -1609,7 +1617,7 @@ fn linearize_ty_params(&@block_ctxt cx, &ty.t t) ->
mutable defs = param_defs);
auto f = bind linearizer(x, _);
- ty.walk_ty(cx.fcx.lcx.ccx.tcx, f, t);
+ ty::walk_ty(cx.fcx.lcx.ccx.tcx, f, t);
ret tup(x.defs, x.vals);
}
@@ -1617,7 +1625,7 @@ fn linearize_ty_params(&@block_ctxt cx, &ty.t t) ->
fn trans_stack_local_derived_tydesc(&@block_ctxt cx, ValueRef llsz,
ValueRef llalign,
ValueRef llroottydesc,
- &Option.t[ValueRef] llparamtydescs)
+ &option::t[ValueRef] llparamtydescs)
-> ValueRef {
auto llmyroottydesc = alloca(cx, T_tydesc(cx.fcx.lcx.ccx.tn));
@@ -1650,7 +1658,7 @@ fn trans_stack_local_derived_tydesc(&@block_ctxt cx, ValueRef llsz,
ret llmyroottydesc;
}
-fn mk_derived_tydesc(&@block_ctxt cx, &ty.t t, bool escapes) -> result {
+fn mk_derived_tydesc(&@block_ctxt cx, &ty::t t, bool escapes) -> result {
alt (cx.fcx.derived_tydescs.find(t)) {
case (some[derived_tydesc_info](?info)) {
// If the tydesc escapes in this context, the cached derived
@@ -1662,11 +1670,11 @@ fn mk_derived_tydesc(&@block_ctxt cx, &ty.t t, bool escapes) -> result {
auto bcx = new_raw_block_ctxt(cx.fcx, cx.fcx.llderivedtydescs);
- let uint n_params = ty.count_ty_params(bcx.fcx.lcx.ccx.tcx, t);
+ let uint n_params = ty::count_ty_params(bcx.fcx.lcx.ccx.tcx, t);
auto tys = linearize_ty_params(bcx, t);
- assert (n_params == Vec.len[uint](tys._0));
- assert (n_params == Vec.len[ValueRef](tys._1));
+ assert (n_params == _vec::len[uint](tys._0));
+ assert (n_params == _vec::len[ValueRef](tys._1));
auto root = get_static_tydesc(bcx, t, tys._0).tydesc;
@@ -1729,16 +1737,16 @@ fn mk_derived_tydesc(&@block_ctxt cx, &ty.t t, bool escapes) -> result {
ret res(cx, v);
}
-fn get_tydesc(&@block_ctxt cx, &ty.t t, bool escapes) -> result {
+fn get_tydesc(&@block_ctxt cx, &ty::t t, bool escapes) -> result {
// Is the supplied type a type param? If so, return the passed-in tydesc.
- alt (ty.type_param(cx.fcx.lcx.ccx.tcx, t)) {
+ alt (ty::type_param(cx.fcx.lcx.ccx.tcx, t)) {
case (some[uint](?id)) { ret res(cx, cx.fcx.lltydescs.(id)); }
case (none[uint]) { /* fall through */ }
}
// Does it contain a type param? If so, generate a derived tydesc.
- if (ty.type_contains_params(cx.fcx.lcx.ccx.tcx, t)) {
+ if (ty::type_contains_params(cx.fcx.lcx.ccx.tcx, t)) {
ret mk_derived_tydesc(cx, t, escapes);
}
@@ -1749,7 +1757,7 @@ fn get_tydesc(&@block_ctxt cx, &ty.t t, bool escapes) -> result {
}
fn get_static_tydesc(&@block_ctxt cx,
- &ty.t t, &vec[uint] ty_params) -> @tydesc_info {
+ &ty::t t, &vec[uint] ty_params) -> @tydesc_info {
alt (cx.fcx.lcx.ccx.tydescs.find(t)) {
case (some[@tydesc_info](?info)) {
ret info;
@@ -1762,11 +1770,11 @@ fn get_static_tydesc(&@block_ctxt cx,
// in this file. Experiment with other approaches to this.
/*
- fn simplifier(ty.t typ) -> ty.t {
+ fn simplifier(ty::t typ) -> ty::t {
ret @rec(cname=none[str] with *typ);
}
auto f = simplifier;
- auto t_simplified = ty.fold_ty(cx.fcx.lcx.ccx.tcx, f, t);
+ auto t_simplified = ty::fold_ty(cx.fcx.lcx.ccx.tcx, f, t);
auto info = declare_tydesc(cx.fcx.lcx, t_simplified);
cx.fcx.lcx.ccx.tydescs.insert(t_simplified, info);
*/
@@ -1782,7 +1790,7 @@ fn get_static_tydesc(&@block_ctxt cx,
// Generates the declaration for (but doesn't fill in) a type descriptor. This
// needs to be separate from make_tydesc() below, because sometimes type glue
// functions needs to refer to their own type descriptors.
-fn declare_tydesc(&@local_ctxt cx, &ty.t t) -> @tydesc_info {
+fn declare_tydesc(&@local_ctxt cx, &ty::t t) -> @tydesc_info {
auto take_glue = declare_generic_glue(cx, t, T_glue_fn(cx.ccx.tn),
"take");
auto drop_glue = declare_generic_glue(cx, t, T_glue_fn(cx.ccx.tn),
@@ -1793,7 +1801,7 @@ fn declare_tydesc(&@local_ctxt cx, &ty.t t) -> @tydesc_info {
auto llsize;
auto llalign;
- if (!ty.type_has_dynamic_size(ccx.tcx, t)) {
+ if (!ty::type_has_dynamic_size(ccx.tcx, t)) {
auto llty = type_of(ccx, t);
llsize = llsize_of(llty);
llalign = llalign_of(llty);
@@ -1814,8 +1822,8 @@ fn declare_tydesc(&@local_ctxt cx, &ty.t t) -> @tydesc_info {
name = mangle_name_by_seq(cx.ccx, cx.path, "tydesc");
}
- auto gvar = llvm.LLVMAddGlobal(ccx.llmod, T_tydesc(ccx.tn),
- Str.buf(name));
+ auto gvar = llvm::LLVMAddGlobal(ccx.llmod, T_tydesc(ccx.tn),
+ _str::buf(name));
auto tydesc = C_struct(vec(C_null(T_ptr(T_ptr(T_tydesc(ccx.tn)))),
llsize,
llalign,
@@ -1828,10 +1836,10 @@ fn declare_tydesc(&@local_ctxt cx, &ty.t t) -> @tydesc_info {
C_null(glue_fn_ty), // is_stateful
cmp_glue)); // cmp_glue
- llvm.LLVMSetInitializer(gvar, tydesc);
- llvm.LLVMSetGlobalConstant(gvar, True);
- llvm.LLVMSetLinkage(gvar, lib.llvm.LLVMInternalLinkage
- as llvm.Linkage);
+ llvm::LLVMSetInitializer(gvar, tydesc);
+ llvm::LLVMSetGlobalConstant(gvar, True);
+ llvm::LLVMSetLinkage(gvar, lib::llvm::LLVMInternalLinkage
+ as llvm::Linkage);
auto info = @rec(
tydesc=gvar,
@@ -1844,12 +1852,12 @@ fn declare_tydesc(&@local_ctxt cx, &ty.t t) -> @tydesc_info {
}
tag make_generic_glue_helper_fn {
- mgghf_single(fn(&@block_ctxt cx, ValueRef v, &ty.t t));
+ mgghf_single(fn(&@block_ctxt cx, ValueRef v, &ty::t t));
mgghf_cmp;
}
// declare_tydesc() above must have been called first.
-fn define_tydesc(&@local_ctxt cx, &ty.t t, &vec[uint] ty_params) {
+fn define_tydesc(&@local_ctxt cx, &ty::t t, &vec[uint] ty_params) {
auto info = cx.ccx.tydescs.get(t);
auto gvar = info.tydesc;
@@ -1861,7 +1869,7 @@ fn define_tydesc(&@local_ctxt cx, &ty.t t, &vec[uint] ty_params) {
}
fn declare_generic_glue(&@local_ctxt cx,
- &ty.t t,
+ &ty::t t,
TypeRef llfnty,
&str name) -> ValueRef {
auto fn_nm;
@@ -1876,7 +1884,7 @@ fn declare_generic_glue(&@local_ctxt cx,
}
fn make_generic_glue(&@local_ctxt cx,
- &ty.t t,
+ &ty::t t,
ValueRef llfn,
&make_generic_glue_helper_fn helper,
&vec[uint] ty_params) -> ValueRef {
@@ -1888,34 +1896,34 @@ fn make_generic_glue(&@local_ctxt cx,
// passed by value.
auto llty;
- if (ty.type_has_dynamic_size(cx.ccx.tcx, t)) {
+ if (ty::type_has_dynamic_size(cx.ccx.tcx, t)) {
llty = T_ptr(T_i8());
} else {
llty = T_ptr(type_of(cx.ccx, t));
}
- auto ty_param_count = Vec.len[uint](ty_params);
+ auto ty_param_count = _vec::len[uint](ty_params);
- auto lltyparams = llvm.LLVMGetParam(llfn, 3u);
+ auto lltyparams = llvm::LLVMGetParam(llfn, 3u);
auto copy_args_bcx = new_raw_block_ctxt(fcx, fcx.llcopyargs);
- auto lltydescs = Vec.empty_mut[ValueRef]();
+ auto lltydescs = _vec::empty_mut[ValueRef]();
auto p = 0u;
while (p < ty_param_count) {
auto llparam = copy_args_bcx.build.GEP(lltyparams,
vec(C_int(p as int)));
llparam = copy_args_bcx.build.Load(llparam);
- Vec.grow_set[ValueRef](lltydescs, ty_params.(p), 0 as ValueRef,
+ _vec::grow_set[ValueRef](lltydescs, ty_params.(p), 0 as ValueRef,
llparam);
p += 1u;
}
- fcx.lltydescs = Vec.freeze[ValueRef](lltydescs);
+ fcx.lltydescs = _vec::freeze[ValueRef](lltydescs);
auto bcx = new_top_block_ctxt(fcx);
auto lltop = bcx.llbb;
- auto llrawptr0 = llvm.LLVMGetParam(llfn, 4u);
+ auto llrawptr0 = llvm::LLVMGetParam(llfn, 4u);
auto llval0 = bcx.build.BitCast(llrawptr0, llty);
alt (helper) {
@@ -1923,10 +1931,10 @@ fn make_generic_glue(&@local_ctxt cx,
single_fn(bcx, llval0, t);
}
case (mgghf_cmp) {
- auto llrawptr1 = llvm.LLVMGetParam(llfn, 5u);
+ auto llrawptr1 = llvm::LLVMGetParam(llfn, 5u);
auto llval1 = bcx.build.BitCast(llrawptr1, llty);
- auto llcmpval = llvm.LLVMGetParam(llfn, 6u);
+ auto llcmpval = llvm::LLVMGetParam(llfn, 6u);
make_cmp_glue(bcx, llval0, llval1, t, llcmpval);
}
@@ -1937,13 +1945,13 @@ fn make_generic_glue(&@local_ctxt cx,
ret llfn;
}
-fn make_take_glue(&@block_ctxt cx, ValueRef v, &ty.t t) {
+fn make_take_glue(&@block_ctxt cx, ValueRef v, &ty::t t) {
// NB: v is an *alias* of type t here, not a direct value.
auto bcx;
- if (ty.type_is_boxed(cx.fcx.lcx.ccx.tcx, t)) {
+ if (ty::type_is_boxed(cx.fcx.lcx.ccx.tcx, t)) {
bcx = incr_refcnt_of_boxed(cx, cx.build.Load(v)).bcx;
- } else if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, t)) {
+ } else if (ty::type_is_structural(cx.fcx.lcx.ccx.tcx, t)) {
bcx = iter_structural_ty(cx, v, t,
bind take_ty(_, _, _)).bcx;
} else {
@@ -1954,14 +1962,14 @@ fn make_take_glue(&@block_ctxt cx, ValueRef v, &ty.t t) {
fn incr_refcnt_of_boxed(&@block_ctxt cx, ValueRef box_ptr) -> result {
auto rc_ptr = cx.build.GEP(box_ptr, vec(C_int(0),
- C_int(abi.box_rc_field_refcnt)));
+ C_int(abi::box_rc_field_refcnt)));
auto rc = cx.build.Load(rc_ptr);
auto rc_adj_cx = new_sub_block_ctxt(cx, "rc++");
auto next_cx = new_sub_block_ctxt(cx, "next");
- auto const_test = cx.build.ICmp(lib.llvm.LLVMIntEQ,
- C_int(abi.const_refcount as int), rc);
+ auto const_test = cx.build.ICmp(lib::llvm::LLVMIntEQ,
+ C_int(abi::const_refcount as int), rc);
cx.build.CondBr(const_test, next_cx.llbb, rc_adj_cx.llbb);
rc = rc_adj_cx.build.Add(rc, C_int(1));
@@ -1971,11 +1979,11 @@ fn incr_refcnt_of_boxed(&@block_ctxt cx, ValueRef box_ptr) -> result {
ret res(next_cx, C_nil());
}
-fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty.t t) {
+fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty::t t) {
// NB: v0 is an *alias* of type t here, not a direct value.
auto rslt;
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
- case (ty.ty_str) {
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
+ case (ty::ty_str) {
auto v = cx.build.Load(v0);
rslt = decr_refcnt_and_if_zero
(cx, v, bind trans_non_gc_free(_, v),
@@ -1983,9 +1991,9 @@ fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty.t t) {
T_int(), C_int(0));
}
- case (ty.ty_vec(_)) {
+ case (ty::ty_vec(_)) {
fn hit_zero(&@block_ctxt cx, ValueRef v,
- ty.t t) -> result {
+ ty::t t) -> result {
auto res = iter_sequence(cx, v, t,
bind drop_ty(_,_,_));
// FIXME: switch gc/non-gc on layer of the type.
@@ -1998,12 +2006,12 @@ fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty.t t) {
T_int(), C_int(0));
}
- case (ty.ty_box(?body_mt)) {
+ case (ty::ty_box(?body_mt)) {
fn hit_zero(&@block_ctxt cx, ValueRef v,
- ty.t body_ty) -> result {
+ ty::t body_ty) -> result {
auto body = cx.build.GEP(v,
vec(C_int(0),
- C_int(abi.box_rc_field_body)));
+ C_int(abi::box_rc_field_body)));
auto body_val = load_if_immediate(cx, body, body_ty);
auto res = drop_ty(cx, body_val, body_ty);
@@ -2017,7 +2025,7 @@ fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty.t t) {
T_int(), C_int(0));
}
- case (ty.ty_port(_)) {
+ case (ty::ty_port(_)) {
fn hit_zero(&@block_ctxt cx, ValueRef v) -> result {
cx.build.Call(cx.fcx.lcx.ccx.upcalls.del_port,
vec(cx.fcx.lltaskptr,
@@ -2031,7 +2039,7 @@ fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty.t t) {
T_int(), C_int(0));
}
- case (ty.ty_chan(_)) {
+ case (ty::ty_chan(_)) {
fn hit_zero(&@block_ctxt cx, ValueRef v) -> result {
cx.build.Call(cx.fcx.lcx.ccx.upcalls.del_chan,
vec(cx.fcx.lltaskptr,
@@ -2045,23 +2053,23 @@ fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty.t t) {
T_int(), C_int(0));
}
- case (ty.ty_obj(_)) {
+ case (ty::ty_obj(_)) {
fn hit_zero(&@block_ctxt cx, ValueRef b, ValueRef o) -> result {
auto body =
cx.build.GEP(b,
vec(C_int(0),
- C_int(abi.box_rc_field_body)));
+ C_int(abi::box_rc_field_body)));
auto tydescptr =
cx.build.GEP(body,
vec(C_int(0),
- C_int(abi.obj_body_elt_tydesc)));
+ C_int(abi::obj_body_elt_tydesc)));
auto tydesc = cx.build.Load(tydescptr);
auto cx_ = maybe_call_dtor(cx, o);
// Call through the obj's own fields-drop glue first.
call_tydesc_glue_full(cx_, body, tydesc,
- abi.tydesc_field_drop_glue);
+ abi::tydesc_field_drop_glue);
// Then free the body.
// FIXME: switch gc/non-gc on layer of the type.
@@ -2070,7 +2078,7 @@ fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty.t t) {
auto box_cell =
cx.build.GEP(v0,
vec(C_int(0),
- C_int(abi.obj_field_box)));
+ C_int(abi::obj_field_box)));
auto boxptr = cx.build.Load(box_cell);
@@ -2080,26 +2088,26 @@ fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty.t t) {
T_int(), C_int(0));
}
- case (ty.ty_fn(_,_,_)) {
+ case (ty::ty_fn(_,_,_)) {
fn hit_zero(&@block_ctxt cx, ValueRef v) -> result {
// Call through the closure's own fields-drop glue first.
auto body =
cx.build.GEP(v,
vec(C_int(0),
- C_int(abi.box_rc_field_body)));
+ C_int(abi::box_rc_field_body)));
auto bindings =
cx.build.GEP(body,
vec(C_int(0),
- C_int(abi.closure_elt_bindings)));
+ C_int(abi::closure_elt_bindings)));
auto tydescptr =
cx.build.GEP(body,
vec(C_int(0),
- C_int(abi.closure_elt_tydesc)));
+ C_int(abi::closure_elt_tydesc)));
call_tydesc_glue_full(cx, bindings, cx.build.Load(tydescptr),
- abi.tydesc_field_drop_glue);
+ abi::tydesc_field_drop_glue);
// Then free the body.
@@ -2109,7 +2117,7 @@ fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty.t t) {
auto box_cell =
cx.build.GEP(v0,
vec(C_int(0),
- C_int(abi.fn_field_box)));
+ C_int(abi::fn_field_box)));
auto boxptr = cx.build.Load(box_cell);
@@ -2120,13 +2128,13 @@ fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty.t t) {
}
case (_) {
- if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, t)) {
+ if (ty::type_is_structural(cx.fcx.lcx.ccx.tcx, t)) {
rslt = iter_structural_ty(cx, v0, t,
bind drop_ty(_, _, _));
- } else if (ty.type_is_scalar(cx.fcx.lcx.ccx.tcx, t) ||
- ty.type_is_native(cx.fcx.lcx.ccx.tcx, t) ||
- ty.type_is_nil(cx.fcx.lcx.ccx.tcx, t)) {
+ } else if (ty::type_is_scalar(cx.fcx.lcx.ccx.tcx, t) ||
+ ty::type_is_native(cx.fcx.lcx.ccx.tcx, t) ||
+ ty::type_is_nil(cx.fcx.lcx.ccx.tcx, t)) {
rslt = res(cx, C_nil());
} else {
rslt = res(cx, C_nil());
@@ -2154,17 +2162,17 @@ fn decr_refcnt_and_if_zero(&@block_ctxt cx,
auto rc_ptr = load_rc_cx.build.GEP(box_ptr,
vec(C_int(0),
- C_int(abi.box_rc_field_refcnt)));
+ C_int(abi::box_rc_field_refcnt)));
auto rc = load_rc_cx.build.Load(rc_ptr);
auto const_test =
- load_rc_cx.build.ICmp(lib.llvm.LLVMIntEQ,
- C_int(abi.const_refcount as int), rc);
+ load_rc_cx.build.ICmp(lib::llvm::LLVMIntEQ,
+ C_int(abi::const_refcount as int), rc);
load_rc_cx.build.CondBr(const_test, next_cx.llbb, rc_adj_cx.llbb);
rc = rc_adj_cx.build.Sub(rc, C_int(1));
rc_adj_cx.build.Store(rc, rc_ptr);
- auto zero_test = rc_adj_cx.build.ICmp(lib.llvm.LLVMIntEQ, C_int(0), rc);
+ auto zero_test = rc_adj_cx.build.ICmp(lib::llvm::LLVMIntEQ, C_int(0), rc);
rc_adj_cx.build.CondBr(zero_test, inner_cx.llbb, next_cx.llbb);
auto inner_res = inner(inner_cx);
@@ -2184,31 +2192,31 @@ fn decr_refcnt_and_if_zero(&@block_ctxt cx,
fn maybe_name_value(&@crate_ctxt cx, ValueRef v, &str s) {
if (cx.sess.get_opts().save_temps) {
- llvm.LLVMSetValueName(v, Str.buf(s));
+ llvm::LLVMSetValueName(v, _str::buf(s));
}
}
fn make_cmp_glue(&@block_ctxt cx,
ValueRef lhs0,
ValueRef rhs0,
- &ty.t t,
+ &ty::t t,
ValueRef llop) {
auto lhs = load_if_immediate(cx, lhs0, t);
auto rhs = load_if_immediate(cx, rhs0, t);
- if (ty.type_is_scalar(cx.fcx.lcx.ccx.tcx, t)) {
+ if (ty::type_is_scalar(cx.fcx.lcx.ccx.tcx, t)) {
make_scalar_cmp_glue(cx, lhs, rhs, t, llop);
- } else if (ty.type_is_box(cx.fcx.lcx.ccx.tcx, t)) {
- lhs = cx.build.GEP(lhs, vec(C_int(0), C_int(abi.box_rc_field_body)));
- rhs = cx.build.GEP(rhs, vec(C_int(0), C_int(abi.box_rc_field_body)));
+ } else if (ty::type_is_box(cx.fcx.lcx.ccx.tcx, t)) {
+ lhs = cx.build.GEP(lhs, vec(C_int(0), C_int(abi::box_rc_field_body)));
+ rhs = cx.build.GEP(rhs, vec(C_int(0), C_int(abi::box_rc_field_body)));
auto rslt = call_cmp_glue(cx, lhs, rhs, t, llop);
rslt.bcx.build.Store(rslt.val, cx.fcx.llretptr);
rslt.bcx.build.RetVoid();
- } else if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, t)
- || ty.type_is_sequence(cx.fcx.lcx.ccx.tcx, t)) {
+ } else if (ty::type_is_structural(cx.fcx.lcx.ccx.tcx, t)
+ || ty::type_is_sequence(cx.fcx.lcx.ccx.tcx, t)) {
auto scx = new_sub_block_ctxt(cx, "structural compare start");
auto next = new_sub_block_ctxt(cx, "structural compare end");
@@ -2222,7 +2230,7 @@ fn make_cmp_glue(&@block_ctxt cx,
* !=, < and >.
*
* We then move one element at a time through the structure checking
- * for pairwise element equality. If we have equality, our assumption
+ * for pairwise element equality: If we have equality, our assumption
* about overall sequence equality is not modified, so we have to move
* to the next element.
*
@@ -2242,7 +2250,7 @@ fn make_cmp_glue(&@block_ctxt cx,
maybe_name_value(cx.fcx.lcx.ccx, flag, "flag");
auto r;
- if (ty.type_is_sequence(cx.fcx.lcx.ccx.tcx, t)) {
+ if (ty::type_is_sequence(cx.fcx.lcx.ccx.tcx, t)) {
// If we hit == all the way through the minimum-shared-length
// section, default to judging the relative sequence lengths.
@@ -2256,8 +2264,8 @@ fn make_cmp_glue(&@block_ctxt cx,
} else {
// == and <= default to true if they find == all the way. <
// defaults to false if it finds == all the way.
- auto result_if_equal = scx.build.ICmp(lib.llvm.LLVMIntNE, llop,
- C_u8(abi.cmp_glue_op_lt));
+ auto result_if_equal = scx.build.ICmp(lib::llvm::LLVMIntNE, llop,
+ C_u8(abi::cmp_glue_op_lt));
scx.build.Store(result_if_equal, flag);
r = res(scx, C_nil());
}
@@ -2269,7 +2277,7 @@ fn make_cmp_glue(&@block_ctxt cx,
&@block_ctxt cx,
ValueRef av0,
ValueRef bv0,
- ty.t t) -> result {
+ ty::t t) -> result {
auto cnt_cx = new_sub_block_ctxt(cx, "continue_comparison");
auto stop_cx = new_sub_block_ctxt(cx, "stop_comparison");
@@ -2281,7 +2289,7 @@ fn make_cmp_glue(&@block_ctxt cx,
// be i8, because the data part of a vector always has type
// i8[]. So we need to cast it to the proper type.
- if (!ty.type_has_dynamic_size(last_cx.fcx.lcx.ccx.tcx, t)) {
+ if (!ty::type_has_dynamic_size(last_cx.fcx.lcx.ccx.tcx, t)) {
auto llelemty = T_ptr(type_of(last_cx.fcx.lcx.ccx, t));
av = cx.build.PointerCast(av, llelemty);
bv = cx.build.PointerCast(bv, llelemty);
@@ -2293,7 +2301,7 @@ fn make_cmp_glue(&@block_ctxt cx,
// First 'eq' comparison: if so, continue to next elts.
auto eq_r = call_cmp_glue(cx, av, bv, t,
- C_u8(abi.cmp_glue_op_eq));
+ C_u8(abi::cmp_glue_op_eq));
eq_r.bcx.build.CondBr(eq_r.val, cnt_cx.llbb, stop_cx.llbb);
// Second 'op' comparison: find out how this elt-pair decides.
@@ -2303,7 +2311,7 @@ fn make_cmp_glue(&@block_ctxt cx,
ret res(cnt_cx, C_nil());
}
- if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, t)) {
+ if (ty::type_is_structural(cx.fcx.lcx.ccx.tcx, t)) {
r = iter_structural_ty_full(r.bcx, lhs, rhs, t,
bind inner(next, false, flag, llop,
_, _, _, _));
@@ -2313,7 +2321,7 @@ fn make_cmp_glue(&@block_ctxt cx,
auto min_len = umin(r.bcx, vec_fill(r.bcx, lhs),
vec_fill(r.bcx, rhs));
auto rhs_lim = r.bcx.build.GEP(rhs_p0, vec(min_len));
- auto elt_ty = ty.sequence_element_type(cx.fcx.lcx.ccx.tcx, t);
+ auto elt_ty = ty::sequence_element_type(cx.fcx.lcx.ccx.tcx, t);
r = size_of(r.bcx, elt_ty);
r = iter_sequence_raw(r.bcx, lhs_p0, rhs_p0, rhs_lim, r.val,
bind inner(next, true, flag, llop,
@@ -2329,61 +2337,61 @@ fn make_cmp_glue(&@block_ctxt cx,
} else {
// FIXME: compare obj, fn by pointer?
- trans_fail(cx, none[common.span],
+ trans_fail(cx, none[common::span],
"attempt to compare values of type " +
- ty.ty_to_str(cx.fcx.lcx.ccx.tcx, t));
+ ty::ty_to_str(cx.fcx.lcx.ccx.tcx, t));
}
}
// A helper function to create scalar comparison glue.
fn make_scalar_cmp_glue(&@block_ctxt cx, ValueRef lhs, ValueRef rhs,
- &ty.t t, ValueRef llop) {
- if (ty.type_is_fp(cx.fcx.lcx.ccx.tcx, t)) {
+ &ty::t t, ValueRef llop) {
+ if (ty::type_is_fp(cx.fcx.lcx.ccx.tcx, t)) {
make_fp_cmp_glue(cx, lhs, rhs, t, llop);
ret;
}
- if (ty.type_is_integral(cx.fcx.lcx.ccx.tcx, t) ||
- ty.type_is_bool(cx.fcx.lcx.ccx.tcx, t)) {
+ if (ty::type_is_integral(cx.fcx.lcx.ccx.tcx, t) ||
+ ty::type_is_bool(cx.fcx.lcx.ccx.tcx, t)) {
make_integral_cmp_glue(cx, lhs, rhs, t, llop);
ret;
}
- if (ty.type_is_nil(cx.fcx.lcx.ccx.tcx, t)) {
+ if (ty::type_is_nil(cx.fcx.lcx.ccx.tcx, t)) {
cx.build.Store(C_bool(true), cx.fcx.llretptr);
cx.build.RetVoid();
ret;
}
- trans_fail(cx, none[common.span],
+ trans_fail(cx, none[common::span],
"attempt to compare values of type " +
- ty.ty_to_str(cx.fcx.lcx.ccx.tcx, t));
+ ty::ty_to_str(cx.fcx.lcx.ccx.tcx, t));
}
// A helper function to create floating point comparison glue.
fn make_fp_cmp_glue(&@block_ctxt cx, ValueRef lhs, ValueRef rhs,
- &ty.t fptype, ValueRef llop) {
+ &ty::t fptype, ValueRef llop) {
auto last_cx = new_sub_block_ctxt(cx, "last");
auto eq_cx = new_sub_block_ctxt(cx, "eq");
- auto eq_result = eq_cx.build.FCmp(lib.llvm.LLVMRealUEQ, lhs, rhs);
+ auto eq_result = eq_cx.build.FCmp(lib::llvm::LLVMRealUEQ, lhs, rhs);
eq_cx.build.Br(last_cx.llbb);
auto lt_cx = new_sub_block_ctxt(cx, "lt");
- auto lt_result = lt_cx.build.FCmp(lib.llvm.LLVMRealULT, lhs, rhs);
+ auto lt_result = lt_cx.build.FCmp(lib::llvm::LLVMRealULT, lhs, rhs);
lt_cx.build.Br(last_cx.llbb);
auto le_cx = new_sub_block_ctxt(cx, "le");
- auto le_result = le_cx.build.FCmp(lib.llvm.LLVMRealULE, lhs, rhs);
+ auto le_result = le_cx.build.FCmp(lib::llvm::LLVMRealULE, lhs, rhs);
le_cx.build.Br(last_cx.llbb);
auto unreach_cx = new_sub_block_ctxt(cx, "unreach");
unreach_cx.build.Unreachable();
auto llswitch = cx.build.Switch(llop, unreach_cx.llbb, 3u);
- llvm.LLVMAddCase(llswitch, C_u8(abi.cmp_glue_op_eq), eq_cx.llbb);
- llvm.LLVMAddCase(llswitch, C_u8(abi.cmp_glue_op_lt), lt_cx.llbb);
- llvm.LLVMAddCase(llswitch, C_u8(abi.cmp_glue_op_le), le_cx.llbb);
+ llvm::LLVMAddCase(llswitch, C_u8(abi::cmp_glue_op_eq), eq_cx.llbb);
+ llvm::LLVMAddCase(llswitch, C_u8(abi::cmp_glue_op_lt), lt_cx.llbb);
+ llvm::LLVMAddCase(llswitch, C_u8(abi::cmp_glue_op_le), le_cx.llbb);
auto last_result =
last_cx.build.Phi(T_i1(), vec(eq_result, lt_result, le_result),
@@ -2398,17 +2406,17 @@ fn compare_integral_values(&@block_ctxt cx, ValueRef lhs, ValueRef rhs,
bool signed, ValueRef llop) -> result {
auto lt_cmp; auto le_cmp;
if (signed) {
- lt_cmp = lib.llvm.LLVMIntSLT;
- le_cmp = lib.llvm.LLVMIntSLE;
+ lt_cmp = lib::llvm::LLVMIntSLT;
+ le_cmp = lib::llvm::LLVMIntSLE;
} else {
- lt_cmp = lib.llvm.LLVMIntULT;
- le_cmp = lib.llvm.LLVMIntULE;
+ lt_cmp = lib::llvm::LLVMIntULT;
+ le_cmp = lib::llvm::LLVMIntULE;
}
auto last_cx = new_sub_block_ctxt(cx, "last");
auto eq_cx = new_sub_block_ctxt(cx, "eq");
- auto eq_result = eq_cx.build.ICmp(lib.llvm.LLVMIntEQ, lhs, rhs);
+ auto eq_result = eq_cx.build.ICmp(lib::llvm::LLVMIntEQ, lhs, rhs);
eq_cx.build.Br(last_cx.llbb);
auto lt_cx = new_sub_block_ctxt(cx, "lt");
@@ -2423,9 +2431,9 @@ fn compare_integral_values(&@block_ctxt cx, ValueRef lhs, ValueRef rhs,
unreach_cx.build.Unreachable();
auto llswitch = cx.build.Switch(llop, unreach_cx.llbb, 3u);
- llvm.LLVMAddCase(llswitch, C_u8(abi.cmp_glue_op_eq), eq_cx.llbb);
- llvm.LLVMAddCase(llswitch, C_u8(abi.cmp_glue_op_lt), lt_cx.llbb);
- llvm.LLVMAddCase(llswitch, C_u8(abi.cmp_glue_op_le), le_cx.llbb);
+ llvm::LLVMAddCase(llswitch, C_u8(abi::cmp_glue_op_eq), eq_cx.llbb);
+ llvm::LLVMAddCase(llswitch, C_u8(abi::cmp_glue_op_lt), lt_cx.llbb);
+ llvm::LLVMAddCase(llswitch, C_u8(abi::cmp_glue_op_le), le_cx.llbb);
auto last_result =
last_cx.build.Phi(T_i1(), vec(eq_result, lt_result, le_result),
@@ -2435,9 +2443,9 @@ fn compare_integral_values(&@block_ctxt cx, ValueRef lhs, ValueRef rhs,
// A helper function to create integral comparison glue.
fn make_integral_cmp_glue(&@block_ctxt cx, ValueRef lhs, ValueRef rhs,
- &ty.t intype, ValueRef llop) {
+ &ty::t intype, ValueRef llop) {
auto r = compare_integral_values(cx, lhs, rhs,
- ty.type_is_signed(cx.fcx.lcx.ccx.tcx, intype), llop);
+ ty::type_is_signed(cx.fcx.lcx.ccx.tcx, intype), llop);
r.bcx.build.Store(r.val, r.bcx.fcx.llretptr);
r.bcx.build.RetVoid();
}
@@ -2445,23 +2453,23 @@ fn make_integral_cmp_glue(&@block_ctxt cx, ValueRef lhs, ValueRef rhs,
// Tag information
-type variant_info = rec(vec[ty.t] args, ty.t ctor_ty, ast.def_id id);
+type variant_info = rec(vec[ty::t] args, ty::t ctor_ty, ast::def_id id);
// Returns information about the variants in a tag.
-fn tag_variants(&@crate_ctxt cx, &ast.def_id id) -> vec[variant_info] {
+fn tag_variants(&@crate_ctxt cx, &ast::def_id id) -> vec[variant_info] {
if (cx.sess.get_targ_crate_num() != id._0) {
- ret creader.get_tag_variants(cx.sess, cx.tcx, id);
+ ret creader::get_tag_variants(cx.sess, cx.tcx, id);
}
assert (cx.items.contains_key(id));
alt (cx.items.get(id).node) {
- case (ast.item_tag(_, ?variants, _, _, _)) {
+ case (ast::item_tag(_, ?variants, _, _, _)) {
let vec[variant_info] result = vec();
- for (ast.variant variant in variants) {
+ for (ast::variant variant in variants) {
auto ctor_ty = node_ann_type(cx, variant.node.ann);
- let vec[ty.t] arg_tys = vec();
- if (Vec.len[ast.variant_arg](variant.node.args) > 0u) {
- for (ty.arg a in ty.ty_fn_args(cx.tcx, ctor_ty)) {
+ let vec[ty::t] arg_tys = vec();
+ if (_vec::len[ast::variant_arg](variant.node.args) > 0u) {
+ for (ty::arg a in ty::ty_fn_args(cx.tcx, ctor_ty)) {
arg_tys += vec(a.ty);
}
}
@@ -2474,16 +2482,16 @@ fn tag_variants(&@crate_ctxt cx, &ast.def_id id) -> vec[variant_info] {
fail; // not reached
}
-// Returns information about the tag variant with the given ID.
+// Returns information about the tag variant with the given ID:
fn tag_variant_with_id(&@crate_ctxt cx,
- &ast.def_id tag_id,
- &ast.def_id variant_id) -> variant_info {
+ &ast::def_id tag_id,
+ &ast::def_id variant_id) -> variant_info {
auto variants = tag_variants(cx, tag_id);
auto i = 0u;
- while (i < Vec.len[variant_info](variants)) {
+ while (i < _vec::len[variant_info](variants)) {
auto variant = variants.(i);
- if (common.def_eq(variant.id, variant_id)) {
+ if (common::def_eq(variant.id, variant_id)) {
ret variant;
}
i += 1u;
@@ -2496,22 +2504,22 @@ fn tag_variant_with_id(&@crate_ctxt cx,
type val_pair_fn = fn(&@block_ctxt cx, ValueRef dst, ValueRef src) -> result;
-type val_and_ty_fn = fn(&@block_ctxt cx, ValueRef v, ty.t t) -> result;
+type val_and_ty_fn = fn(&@block_ctxt cx, ValueRef v, ty::t t) -> result;
type val_pair_and_ty_fn =
- fn(&@block_ctxt cx, ValueRef av, ValueRef bv, ty.t t) -> result;
+ fn(&@block_ctxt cx, ValueRef av, ValueRef bv, ty::t t) -> result;
// Iterates through the elements of a structural type.
fn iter_structural_ty(&@block_ctxt cx,
ValueRef v,
- &ty.t t,
+ &ty::t t,
val_and_ty_fn f)
-> result {
fn adaptor_fn(val_and_ty_fn f,
&@block_ctxt cx,
ValueRef av,
ValueRef bv,
- ty.t t) -> result {
+ ty::t t) -> result {
ret f(cx, av, t);
}
be iter_structural_ty_full(cx, v, v, t,
@@ -2522,7 +2530,7 @@ fn iter_structural_ty(&@block_ctxt cx,
fn iter_structural_ty_full(&@block_ctxt cx,
ValueRef av,
ValueRef bv,
- &ty.t t,
+ &ty::t t,
&val_pair_and_ty_fn f)
-> result {
let result r = res(cx, C_nil());
@@ -2533,8 +2541,8 @@ fn iter_structural_ty_full(&@block_ctxt cx,
&val_pair_and_ty_fn f) -> result {
auto box_a_ptr = cx.build.Load(box_a_cell);
auto box_b_ptr = cx.build.Load(box_b_cell);
- auto tnil = ty.mk_nil(cx.fcx.lcx.ccx.tcx);
- auto tbox = ty.mk_imm_box(cx.fcx.lcx.ccx.tcx, tnil);
+ auto tnil = ty::mk_nil(cx.fcx.lcx.ccx.tcx);
+ auto tbox = ty::mk_imm_box(cx.fcx.lcx.ccx.tcx, tnil);
auto inner_cx = new_sub_block_ctxt(cx, "iter box");
auto next_cx = new_sub_block_ctxt(cx, "next");
@@ -2546,10 +2554,10 @@ fn iter_structural_ty_full(&@block_ctxt cx,
ret res(next_cx, C_nil());
}
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
- case (ty.ty_tup(?args)) {
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
+ case (ty::ty_tup(?args)) {
let int i = 0;
- for (ty.mt arg in args) {
+ for (ty::mt arg in args) {
r = GEP_tup_like(r.bcx, t, av, vec(0, i));
auto elt_a = r.val;
r = GEP_tup_like(r.bcx, t, bv, vec(0, i));
@@ -2561,9 +2569,9 @@ fn iter_structural_ty_full(&@block_ctxt cx,
i += 1;
}
}
- case (ty.ty_rec(?fields)) {
+ case (ty::ty_rec(?fields)) {
let int i = 0;
- for (ty.field fld in fields) {
+ for (ty::field fld in fields) {
r = GEP_tup_like(r.bcx, t, av, vec(0, i));
auto llfld_a = r.val;
r = GEP_tup_like(r.bcx, t, bv, vec(0, i));
@@ -2575,9 +2583,9 @@ fn iter_structural_ty_full(&@block_ctxt cx,
i += 1;
}
}
- case (ty.ty_tag(?tid, ?tps)) {
+ case (ty::ty_tag(?tid, ?tps)) {
auto variants = tag_variants(cx.fcx.lcx.ccx, tid);
- auto n_variants = Vec.len[variant_info](variants);
+ auto n_variants = _vec::len[variant_info](variants);
// Cast the tags to types we can GEP into.
auto lltagty = T_opaque_tag_ptr(cx.fcx.lcx.ccx.tn);
@@ -2600,7 +2608,7 @@ fn iter_structural_ty_full(&@block_ctxt cx,
// comparison know not to proceed when the discriminants differ.
auto bcx = cx;
bcx = f(bcx, lldiscrim_a, lldiscrim_b,
- ty.mk_int(cx.fcx.lcx.ccx.tcx)).bcx;
+ ty::mk_int(cx.fcx.lcx.ccx.tcx)).bcx;
auto unr_cx = new_sub_block_ctxt(bcx, "tag-iter-unr");
unr_cx.build.Unreachable();
@@ -2614,16 +2622,16 @@ fn iter_structural_ty_full(&@block_ctxt cx,
for (variant_info variant in variants) {
auto variant_cx = new_sub_block_ctxt(bcx,
"tag-iter-variant-" +
- UInt.to_str(i, 10u));
- llvm.LLVMAddCase(llswitch, C_int(i as int), variant_cx.llbb);
+ _uint::to_str(i, 10u));
+ llvm::LLVMAddCase(llswitch, C_int(i as int), variant_cx.llbb);
- if (Vec.len[ty.t](variant.args) > 0u) {
+ if (_vec::len[ty::t](variant.args) > 0u) {
// N-ary variant.
auto fn_ty = variant.ctor_ty;
- alt (ty.struct(bcx.fcx.lcx.ccx.tcx, fn_ty)) {
- case (ty.ty_fn(_, ?args, _)) {
+ alt (ty::struct(bcx.fcx.lcx.ccx.tcx, fn_ty)) {
+ case (ty::ty_fn(_, ?args, _)) {
auto j = 0;
- for (ty.arg a in args) {
+ for (ty::arg a in args) {
auto v = vec(C_int(0), C_int(j as int));
auto rslt = GEP_tag(variant_cx, llunion_a_ptr,
@@ -2636,9 +2644,9 @@ fn iter_structural_ty_full(&@block_ctxt cx,
auto llfldp_b = rslt.val;
variant_cx = rslt.bcx;
- auto ty_subst = ty.bind_params_in_type(
+ auto ty_subst = ty::bind_params_in_type(
cx.fcx.lcx.ccx.tcx, a.ty);
- ty_subst = ty.substitute_type_params(
+ ty_subst = ty::substitute_type_params(
cx.fcx.lcx.ccx.tcx, tps, ty_subst);
auto llfld_a =
@@ -2671,26 +2679,26 @@ fn iter_structural_ty_full(&@block_ctxt cx,
ret res(next_cx, C_nil());
}
- case (ty.ty_fn(_,_,_)) {
+ case (ty::ty_fn(_,_,_)) {
auto box_cell_a =
cx.build.GEP(av,
vec(C_int(0),
- C_int(abi.fn_field_box)));
+ C_int(abi::fn_field_box)));
auto box_cell_b =
cx.build.GEP(bv,
vec(C_int(0),
- C_int(abi.fn_field_box)));
+ C_int(abi::fn_field_box)));
ret iter_boxpp(cx, box_cell_a, box_cell_b, f);
}
- case (ty.ty_obj(_)) {
+ case (ty::ty_obj(_)) {
auto box_cell_a =
cx.build.GEP(av,
vec(C_int(0),
- C_int(abi.obj_field_box)));
+ C_int(abi::obj_field_box)));
auto box_cell_b =
cx.build.GEP(bv,
vec(C_int(0),
- C_int(abi.obj_field_box)));
+ C_int(abi::obj_field_box)));
ret iter_boxpp(cx, box_cell_a, box_cell_b, f);
}
case (_) {
@@ -2725,7 +2733,7 @@ fn iter_sequence_raw(@block_ctxt cx,
let ValueRef src_curr = cond_cx.build.Phi(T_int(),
vec(src_int), vec(bcx.llbb));
- auto end_test = cond_cx.build.ICmp(lib.llvm.LLVMIntULT,
+ auto end_test = cond_cx.build.ICmp(lib::llvm::LLVMIntULT,
src_curr, src_lim_int);
cond_cx.build.CondBr(end_test, body_cx.llbb, next_cx.llbb);
@@ -2752,15 +2760,15 @@ fn iter_sequence_raw(@block_ctxt cx,
fn iter_sequence_inner(&@block_ctxt cx,
ValueRef src, // elt*
ValueRef src_lim, // elt*
- &ty.t elt_ty,
+ &ty::t elt_ty,
&val_and_ty_fn f) -> result {
fn adaptor_fn(val_and_ty_fn f,
- ty.t elt_ty,
+ ty::t elt_ty,
&@block_ctxt cx,
ValueRef dst,
ValueRef src) -> result {
auto llptrty;
- if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, elt_ty)) {
+ if (!ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, elt_ty)) {
auto llty = type_of(cx.fcx.lcx.ccx, elt_ty);
llptrty = T_ptr(llty);
} else {
@@ -2780,22 +2788,22 @@ fn iter_sequence_inner(&@block_ctxt cx,
// Iterates through the elements of a vec or str.
fn iter_sequence(@block_ctxt cx,
ValueRef v,
- &ty.t t,
+ &ty::t t,
&val_and_ty_fn f) -> result {
fn iter_sequence_body(@block_ctxt cx,
ValueRef v,
- &ty.t elt_ty,
+ &ty::t elt_ty,
&val_and_ty_fn f,
bool trailing_null) -> result {
auto p0 = cx.build.GEP(v, vec(C_int(0),
- C_int(abi.vec_elt_data)));
+ C_int(abi::vec_elt_data)));
auto lenptr = cx.build.GEP(v, vec(C_int(0),
- C_int(abi.vec_elt_fill)));
+ C_int(abi::vec_elt_fill)));
auto llunit_ty;
- if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, elt_ty)) {
+ if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, elt_ty)) {
llunit_ty = T_i8();
} else {
llunit_ty = type_of(cx.fcx.lcx.ccx, elt_ty);
@@ -2816,17 +2824,17 @@ fn iter_sequence(@block_ctxt cx,
ret iter_sequence_inner(bcx, p0, p1, elt_ty, f);
}
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
- case (ty.ty_vec(?elt)) {
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
+ case (ty::ty_vec(?elt)) {
ret iter_sequence_body(cx, v, elt.ty, f, false);
}
- case (ty.ty_str) {
- auto et = ty.mk_mach(cx.fcx.lcx.ccx.tcx, common.ty_u8);
+ case (ty::ty_str) {
+ auto et = ty::mk_mach(cx.fcx.lcx.ccx.tcx, common::ty_u8);
ret iter_sequence_body(cx, v, et, f, true);
}
case (_) { fail; }
}
- cx.fcx.lcx.ccx.sess.bug("bad type in trans.iter_sequence");
+ cx.fcx.lcx.ccx.sess.bug("bad type in trans::iter_sequence");
fail;
}
@@ -2835,7 +2843,7 @@ fn call_tydesc_glue_full(&@block_ctxt cx, ValueRef v,
auto llrawptr = cx.build.BitCast(v, T_ptr(T_i8()));
auto lltydescs = cx.build.GEP(tydesc,
vec(C_int(0),
- C_int(abi.tydesc_field_first_param)));
+ C_int(abi::tydesc_field_first_param)));
lltydescs = cx.build.Load(lltydescs);
auto llfnptr = cx.build.GEP(tydesc, vec(C_int(0), C_int(field)));
auto llfn = cx.build.Load(llfnptr);
@@ -2848,7 +2856,7 @@ fn call_tydesc_glue_full(&@block_ctxt cx, ValueRef v,
}
fn call_tydesc_glue(&@block_ctxt cx, ValueRef v,
- &ty.t t, bool escapes, int field) -> result {
+ &ty::t t, bool escapes, int field) -> result {
auto td = get_tydesc(cx, t, escapes);
call_tydesc_glue_full(td.bcx,
spill_if_immediate(td.bcx, v, t),
@@ -2857,17 +2865,17 @@ fn call_tydesc_glue(&@block_ctxt cx, ValueRef v,
}
fn maybe_call_dtor(&@block_ctxt cx, ValueRef v) -> @block_ctxt {
- auto vtbl = cx.build.GEP(v, vec(C_int(0), C_int(abi.obj_field_vtbl)));
+ auto vtbl = cx.build.GEP(v, vec(C_int(0), C_int(abi::obj_field_vtbl)));
vtbl = cx.build.Load(vtbl);
auto dtor_ptr = cx.build.GEP(vtbl, vec(C_int(0), C_int(0)));
dtor_ptr = cx.build.Load(dtor_ptr);
- auto self_t = llvm.LLVMGetElementType(val_ty(v));
+ auto self_t = llvm::LLVMGetElementType(val_ty(v));
dtor_ptr = cx.build.BitCast(dtor_ptr,
T_ptr(T_dtor(cx.fcx.lcx.ccx, self_t)));
auto dtor_cx = new_sub_block_ctxt(cx, "dtor");
auto after_cx = new_sub_block_ctxt(cx, "after_dtor");
- auto test = cx.build.ICmp(lib.llvm.LLVMIntNE, dtor_ptr,
+ auto test = cx.build.ICmp(lib::llvm::LLVMIntNE, dtor_ptr,
C_null(val_ty(dtor_ptr)));
cx.build.CondBr(test, dtor_cx.llbb, after_cx.llbb);
@@ -2881,7 +2889,7 @@ fn maybe_call_dtor(&@block_ctxt cx, ValueRef v) -> @block_ctxt {
fn call_cmp_glue(&@block_ctxt cx,
ValueRef lhs,
ValueRef rhs,
- &ty.t t,
+ &ty::t t,
ValueRef llop) -> result {
// We can't use call_tydesc_glue_full() and friends here because compare
// glue has a special signature.
@@ -2895,11 +2903,11 @@ fn call_cmp_glue(&@block_ctxt cx,
auto r = get_tydesc(cx, t, false);
auto lltydescs =
r.bcx.build.GEP(r.val, vec(C_int(0),
- C_int(abi.tydesc_field_first_param)));
+ C_int(abi::tydesc_field_first_param)));
lltydescs = r.bcx.build.Load(lltydescs);
auto llfnptr =
r.bcx.build.GEP(r.val, vec(C_int(0),
- C_int(abi.tydesc_field_cmp_glue)));
+ C_int(abi::tydesc_field_cmp_glue)));
auto llfn = r.bcx.build.Load(llfnptr);
auto llcmpresultptr = r.bcx.build.Alloca(T_i1());
@@ -2917,31 +2925,31 @@ fn call_cmp_glue(&@block_ctxt cx,
ret res(r.bcx, r.bcx.build.Load(llcmpresultptr));
}
-fn take_ty(&@block_ctxt cx, ValueRef v, ty.t t) -> result {
- if (!ty.type_is_scalar(cx.fcx.lcx.ccx.tcx, t)) {
- ret call_tydesc_glue(cx, v, t, false, abi.tydesc_field_take_glue);
+fn take_ty(&@block_ctxt cx, ValueRef v, ty::t t) -> result {
+ if (!ty::type_is_scalar(cx.fcx.lcx.ccx.tcx, t)) {
+ ret call_tydesc_glue(cx, v, t, false, abi::tydesc_field_take_glue);
}
ret res(cx, C_nil());
}
fn drop_slot(&@block_ctxt cx,
ValueRef slot,
- &ty.t t) -> result {
+ &ty::t t) -> result {
auto llptr = load_if_immediate(cx, slot, t);
auto re = drop_ty(cx, llptr, t);
auto llty = val_ty(slot);
- auto llelemty = lib.llvm.llvm.LLVMGetElementType(llty);
+ auto llelemty = lib::llvm::llvm::LLVMGetElementType(llty);
re.bcx.build.Store(C_null(llelemty), slot);
ret re;
}
fn drop_ty(&@block_ctxt cx,
ValueRef v,
- ty.t t) -> result {
+ ty::t t) -> result {
- if (!ty.type_is_scalar(cx.fcx.lcx.ccx.tcx, t)) {
- ret call_tydesc_glue(cx, v, t, false, abi.tydesc_field_drop_glue);
+ if (!ty::type_is_scalar(cx.fcx.lcx.ccx.tcx, t)) {
+ ret call_tydesc_glue(cx, v, t, false, abi::tydesc_field_drop_glue);
}
ret res(cx, C_nil());
}
@@ -2959,7 +2967,7 @@ fn call_memmove(&@block_ctxt cx,
auto dst_ptr = cx.build.PointerCast(dst, T_ptr(T_i8()));
auto size = cx.build.IntCast(n_bytes, T_i32());
auto align =
- if (lib.llvm.llvm.LLVMIsConstant(align_bytes) == True)
+ if (lib::llvm::llvm::LLVMIsConstant(align_bytes) == True)
{ cx.build.IntCast(align_bytes, T_i32()) }
else
{ cx.build.IntCast(C_int(0), T_i32()) };
@@ -2982,7 +2990,7 @@ fn call_bzero(&@block_ctxt cx,
auto dst_ptr = cx.build.PointerCast(dst, T_ptr(T_i8()));
auto size = cx.build.IntCast(n_bytes, T_i32());
auto align =
- if (lib.llvm.llvm.LLVMIsConstant(align_bytes) == True)
+ if (lib::llvm::llvm::LLVMIsConstant(align_bytes) == True)
{ cx.build.IntCast(align_bytes, T_i32()) }
else
{ cx.build.IntCast(C_int(0), T_i32()) };
@@ -2996,8 +3004,8 @@ fn call_bzero(&@block_ctxt cx,
fn memmove_ty(&@block_ctxt cx,
ValueRef dst,
ValueRef src,
- &ty.t t) -> result {
- if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
+ &ty::t t) -> result {
+ if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
auto llsz = size_of(cx, t);
auto llalign = align_of(llsz.bcx, t);
ret call_memmove(llalign.bcx, dst, src, llsz.val, llalign.val);
@@ -3016,23 +3024,23 @@ fn copy_ty(&@block_ctxt cx,
copy_action action,
ValueRef dst,
ValueRef src,
- &ty.t t) -> result {
- if (ty.type_is_scalar(cx.fcx.lcx.ccx.tcx, t) ||
- ty.type_is_native(cx.fcx.lcx.ccx.tcx, t)) {
+ &ty::t t) -> result {
+ if (ty::type_is_scalar(cx.fcx.lcx.ccx.tcx, t) ||
+ ty::type_is_native(cx.fcx.lcx.ccx.tcx, t)) {
ret res(cx, cx.build.Store(src, dst));
- } else if (ty.type_is_nil(cx.fcx.lcx.ccx.tcx, t)) {
+ } else if (ty::type_is_nil(cx.fcx.lcx.ccx.tcx, t)) {
ret res(cx, C_nil());
- } else if (ty.type_is_boxed(cx.fcx.lcx.ccx.tcx, t)) {
+ } else if (ty::type_is_boxed(cx.fcx.lcx.ccx.tcx, t)) {
auto r = take_ty(cx, src, t);
if (action == DROP_EXISTING) {
r = drop_ty(r.bcx, r.bcx.build.Load(dst), t);
}
ret res(r.bcx, r.bcx.build.Store(src, dst));
- } else if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, t) ||
- ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
+ } else if (ty::type_is_structural(cx.fcx.lcx.ccx.tcx, t) ||
+ ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
auto r = take_ty(cx, src, t);
if (action == DROP_EXISTING) {
r = drop_ty(r.bcx, dst, t);
@@ -3040,75 +3048,75 @@ fn copy_ty(&@block_ctxt cx,
ret memmove_ty(r.bcx, dst, src, t);
}
- cx.fcx.lcx.ccx.sess.bug("unexpected type in trans.copy_ty: " +
- ty.ty_to_str(cx.fcx.lcx.ccx.tcx, t));
+ cx.fcx.lcx.ccx.sess.bug("unexpected type in trans::copy_ty: " +
+ ty::ty_to_str(cx.fcx.lcx.ccx.tcx, t));
fail;
}
-fn trans_lit(&@crate_ctxt cx, &ast.lit lit, &ast.ann ann) -> ValueRef {
+fn trans_lit(&@crate_ctxt cx, &ast::lit lit, &ast::ann ann) -> ValueRef {
alt (lit.node) {
- case (ast.lit_int(?i)) {
+ case (ast::lit_int(?i)) {
ret C_int(i);
}
- case (ast.lit_uint(?u)) {
+ case (ast::lit_uint(?u)) {
ret C_int(u as int);
}
- case (ast.lit_mach_int(?tm, ?i)) {
+ case (ast::lit_mach_int(?tm, ?i)) {
// FIXME: the entire handling of mach types falls apart
// if target int width is larger than host, at the moment;
// re-do the mach-int types using 'big' when that works.
auto t = T_int();
auto s = True;
alt (tm) {
- case (common.ty_u8) { t = T_i8(); s = False; }
- case (common.ty_u16) { t = T_i16(); s = False; }
- case (common.ty_u32) { t = T_i32(); s = False; }
- case (common.ty_u64) { t = T_i64(); s = False; }
-
- case (common.ty_i8) { t = T_i8(); }
- case (common.ty_i16) { t = T_i16(); }
- case (common.ty_i32) { t = T_i32(); }
- case (common.ty_i64) { t = T_i64(); }
+ case (common::ty_u8) { t = T_i8(); s = False; }
+ case (common::ty_u16) { t = T_i16(); s = False; }
+ case (common::ty_u32) { t = T_i32(); s = False; }
+ case (common::ty_u64) { t = T_i64(); s = False; }
+
+ case (common::ty_i8) { t = T_i8(); }
+ case (common::ty_i16) { t = T_i16(); }
+ case (common::ty_i32) { t = T_i32(); }
+ case (common::ty_i64) { t = T_i64(); }
}
ret C_integral(t, i as uint, s);
}
- case(ast.lit_float(?fs)) {
+ case(ast::lit_float(?fs)) {
ret C_float(fs);
}
- case(ast.lit_mach_float(?tm, ?s)) {
+ case(ast::lit_mach_float(?tm, ?s)) {
auto t = T_float();
alt(tm) {
- case(common.ty_f32) { t = T_f32(); }
- case(common.ty_f64) { t = T_f64(); }
+ case(common::ty_f32) { t = T_f32(); }
+ case(common::ty_f64) { t = T_f64(); }
}
ret C_floating(s, t);
}
- case (ast.lit_char(?c)) {
+ case (ast::lit_char(?c)) {
ret C_integral(T_char(), c as uint, False);
}
- case (ast.lit_bool(?b)) {
+ case (ast::lit_bool(?b)) {
ret C_bool(b);
}
- case (ast.lit_nil) {
+ case (ast::lit_nil) {
ret C_nil();
}
- case (ast.lit_str(?s)) {
+ case (ast::lit_str(?s)) {
ret C_str(cx, s);
}
}
}
-fn target_type(&@crate_ctxt cx, &ty.t t) -> ty.t {
- alt (ty.struct(cx.tcx, t)) {
- case (ty.ty_int) {
- auto struct_ty = ty.mk_mach(cx.tcx,
+fn target_type(&@crate_ctxt cx, &ty::t t) -> ty::t {
+ alt (ty::struct(cx.tcx, t)) {
+ case (ty::ty_int) {
+ auto struct_ty = ty::mk_mach(cx.tcx,
cx.sess.get_targ_cfg().int_type);
- ret ty.copy_cname(cx.tcx, struct_ty, t);
+ ret ty::copy_cname(cx.tcx, struct_ty, t);
}
- case (ty.ty_uint) {
- auto struct_ty = ty.mk_mach(cx.tcx,
+ case (ty::ty_uint) {
+ auto struct_ty = ty::mk_mach(cx.tcx,
cx.sess.get_targ_cfg().uint_type);
- ret ty.copy_cname(cx.tcx, struct_ty, t);
+ ret ty::copy_cname(cx.tcx, struct_ty, t);
}
case (_) { /* fall through */ }
}
@@ -3117,61 +3125,61 @@ fn target_type(&@crate_ctxt cx, &ty.t t) -> ty.t {
// Converts an annotation to a type
-fn node_ann_type(&@crate_ctxt cx, &ast.ann a) -> ty.t {
- ret target_type(cx, ty.ann_to_monotype(cx.tcx, a));
+fn node_ann_type(&@crate_ctxt cx, &ast::ann a) -> ty::t {
+ ret target_type(cx, ty::ann_to_monotype(cx.tcx, a));
}
-fn node_ann_ty_params(&ast.ann a) -> vec[ty.t] {
+fn node_ann_ty_params(&ast::ann a) -> vec[ty::t] {
alt (a) {
- case (ast.ann_none(_)) {
+ case (ast::ann_none(_)) {
log_err "missing type annotation";
fail;
}
- case (ast.ann_type(_, _, ?tps_opt, _)) {
+ case (ast::ann_type(_, _, ?tps_opt, _)) {
alt (tps_opt) {
- case (none[vec[ty.t]]) {
+ case (none[vec[ty::t]]) {
log_err "type annotation has no ty params";
fail;
}
- case (some[vec[ty.t]](?tps)) { ret tps; }
+ case (some[vec[ty::t]](?tps)) { ret tps; }
}
}
}
}
-fn node_type(&@crate_ctxt cx, &ast.ann a) -> TypeRef {
+fn node_type(&@crate_ctxt cx, &ast::ann a) -> TypeRef {
ret type_of(cx, node_ann_type(cx, a));
}
-fn trans_unary(&@block_ctxt cx, ast.unop op,
- &@ast.expr e, &ast.ann a) -> result {
+fn trans_unary(&@block_ctxt cx, ast::unop op,
+ &@ast::expr e, &ast::ann a) -> result {
auto sub = trans_expr(cx, e);
- auto e_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, e);
+ auto e_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, e);
alt (op) {
- case (ast.bitnot) {
+ case (ast::bitnot) {
sub = autoderef(sub.bcx, sub.val,
- ty.expr_ty(cx.fcx.lcx.ccx.tcx, e));
+ ty::expr_ty(cx.fcx.lcx.ccx.tcx, e));
ret res(sub.bcx, sub.bcx.build.Not(sub.val));
}
- case (ast.not) {
+ case (ast::not) {
sub = autoderef(sub.bcx, sub.val,
- ty.expr_ty(cx.fcx.lcx.ccx.tcx, e));
+ ty::expr_ty(cx.fcx.lcx.ccx.tcx, e));
ret res(sub.bcx, sub.bcx.build.Not(sub.val));
}
- case (ast.neg) {
+ case (ast::neg) {
sub = autoderef(sub.bcx, sub.val,
- ty.expr_ty(cx.fcx.lcx.ccx.tcx, e));
- if(ty.struct(cx.fcx.lcx.ccx.tcx, e_ty) == ty.ty_float) {
+ ty::expr_ty(cx.fcx.lcx.ccx.tcx, e));
+ if(ty::struct(cx.fcx.lcx.ccx.tcx, e_ty) == ty::ty_float) {
ret res(sub.bcx, sub.bcx.build.FNeg(sub.val));
}
else {
ret res(sub.bcx, sub.bcx.build.Neg(sub.val));
}
}
- case (ast.box(_)) {
- auto e_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, e);
+ case (ast::box(_)) {
+ auto e_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, e);
auto e_val = sub.val;
auto box_ty = node_ann_type(sub.bcx.fcx.lcx.ccx, a);
sub = trans_malloc_boxed(sub.bcx, e_ty);
@@ -3181,16 +3189,16 @@ fn trans_unary(&@block_ctxt cx, ast.unop op,
auto box = sub.val;
auto rc = sub.bcx.build.GEP(box,
vec(C_int(0),
- C_int(abi.box_rc_field_refcnt)));
+ C_int(abi::box_rc_field_refcnt)));
auto body = sub.bcx.build.GEP(box,
vec(C_int(0),
- C_int(abi.box_rc_field_body)));
+ C_int(abi::box_rc_field_body)));
sub.bcx.build.Store(C_int(1), rc);
// Cast the body type to the type of the value. This is needed to
// make tags work, since tags have a different LLVM type depending
// on whether they're boxed or not.
- if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, e_ty)) {
+ if (!ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, e_ty)) {
auto llety = T_ptr(type_of(sub.bcx.fcx.lcx.ccx, e_ty));
body = sub.bcx.build.PointerCast(body, llety);
}
@@ -3198,7 +3206,7 @@ fn trans_unary(&@block_ctxt cx, ast.unop op,
sub = copy_ty(sub.bcx, INIT, body, e_val, e_ty);
ret res(sub.bcx, box);
}
- case (ast.deref) {
+ case (ast::deref) {
log_err "deref expressions should have been translated using " +
"trans_lval(), not trans_unary()";
fail;
@@ -3207,7 +3215,7 @@ fn trans_unary(&@block_ctxt cx, ast.unop op,
fail;
}
-fn trans_compare(&@block_ctxt cx0, ast.binop op, &ty.t t0,
+fn trans_compare(&@block_ctxt cx0, ast::binop op, &ty::t t0,
ValueRef lhs0, ValueRef rhs0) -> result {
// Autoderef both sides.
auto cx = cx0;
@@ -3226,12 +3234,12 @@ fn trans_compare(&@block_ctxt cx0, ast.binop op, &ty.t t0,
// FIXME: Use or-patterns when we have them.
auto llop;
alt (op) {
- case (ast.eq) { llop = C_u8(abi.cmp_glue_op_eq); }
- case (ast.lt) { llop = C_u8(abi.cmp_glue_op_lt); }
- case (ast.le) { llop = C_u8(abi.cmp_glue_op_le); }
- case (ast.ne) { llop = C_u8(abi.cmp_glue_op_eq); }
- case (ast.ge) { llop = C_u8(abi.cmp_glue_op_lt); }
- case (ast.gt) { llop = C_u8(abi.cmp_glue_op_le); }
+ case (ast::eq) { llop = C_u8(abi::cmp_glue_op_eq); }
+ case (ast::lt) { llop = C_u8(abi::cmp_glue_op_lt); }
+ case (ast::le) { llop = C_u8(abi::cmp_glue_op_le); }
+ case (ast::ne) { llop = C_u8(abi::cmp_glue_op_eq); }
+ case (ast::ge) { llop = C_u8(abi::cmp_glue_op_lt); }
+ case (ast::gt) { llop = C_u8(abi::cmp_glue_op_le); }
}
auto rslt = call_cmp_glue(cx, lhs, rhs, t, llop);
@@ -3239,23 +3247,23 @@ fn trans_compare(&@block_ctxt cx0, ast.binop op, &ty.t t0,
// Invert the result if necessary.
// FIXME: Use or-patterns when we have them.
alt (op) {
- case (ast.eq) { ret res(rslt.bcx, rslt.val); }
- case (ast.lt) { ret res(rslt.bcx, rslt.val); }
- case (ast.le) { ret res(rslt.bcx, rslt.val); }
- case (ast.ne) { ret res(rslt.bcx, rslt.bcx.build.Not(rslt.val)); }
- case (ast.ge) { ret res(rslt.bcx, rslt.bcx.build.Not(rslt.val)); }
- case (ast.gt) { ret res(rslt.bcx, rslt.bcx.build.Not(rslt.val)); }
+ case (ast::eq) { ret res(rslt.bcx, rslt.val); }
+ case (ast::lt) { ret res(rslt.bcx, rslt.val); }
+ case (ast::le) { ret res(rslt.bcx, rslt.val); }
+ case (ast::ne) { ret res(rslt.bcx, rslt.bcx.build.Not(rslt.val)); }
+ case (ast::ge) { ret res(rslt.bcx, rslt.bcx.build.Not(rslt.val)); }
+ case (ast::gt) { ret res(rslt.bcx, rslt.bcx.build.Not(rslt.val)); }
}
}
-fn trans_vec_append(&@block_ctxt cx, &ty.t t,
+fn trans_vec_append(&@block_ctxt cx, &ty::t t,
ValueRef lhs, ValueRef rhs) -> result {
- auto elt_ty = ty.sequence_element_type(cx.fcx.lcx.ccx.tcx, t);
+ auto elt_ty = ty::sequence_element_type(cx.fcx.lcx.ccx.tcx, t);
auto skip_null = C_bool(false);
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
- case (ty.ty_str) { skip_null = C_bool(true); }
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
+ case (ty::ty_str) { skip_null = C_bool(true); }
case (_) { }
}
@@ -3277,7 +3285,7 @@ fn trans_vec_append(&@block_ctxt cx, &ty.t t,
dst, src, skip_null)));
}
-fn trans_vec_add(&@block_ctxt cx, &ty.t t,
+fn trans_vec_add(&@block_ctxt cx, &ty::t t,
ValueRef lhs, ValueRef rhs) -> result {
auto r = alloc_ty(cx, t);
auto tmp = r.val;
@@ -3290,12 +3298,12 @@ fn trans_vec_add(&@block_ctxt cx, &ty.t t,
}
-fn trans_eager_binop(&@block_ctxt cx, ast.binop op, &ty.t intype,
+fn trans_eager_binop(&@block_ctxt cx, ast::binop op, &ty::t intype,
ValueRef lhs, ValueRef rhs) -> result {
auto is_float = false;
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, intype)) {
- case (ty.ty_float) {
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, intype)) {
+ case (ty::ty_float) {
is_float = true;
}
case (_) {
@@ -3304,8 +3312,8 @@ fn trans_eager_binop(&@block_ctxt cx, ast.binop op, &ty.t intype,
}
alt (op) {
- case (ast.add) {
- if (ty.type_is_sequence(cx.fcx.lcx.ccx.tcx, intype)) {
+ case (ast::add) {
+ if (ty::type_is_sequence(cx.fcx.lcx.ccx.tcx, intype)) {
ret trans_vec_add(cx, intype, lhs, rhs);
}
if (is_float) {
@@ -3315,7 +3323,7 @@ fn trans_eager_binop(&@block_ctxt cx, ast.binop op, &ty.t intype,
ret res(cx, cx.build.Add(lhs, rhs));
}
}
- case (ast.sub) {
+ case (ast::sub) {
if (is_float) {
ret res(cx, cx.build.FSub(lhs, rhs));
}
@@ -3324,7 +3332,7 @@ fn trans_eager_binop(&@block_ctxt cx, ast.binop op, &ty.t intype,
}
}
- case (ast.mul) {
+ case (ast::mul) {
if (is_float) {
ret res(cx, cx.build.FMul(lhs, rhs));
}
@@ -3333,33 +3341,33 @@ fn trans_eager_binop(&@block_ctxt cx, ast.binop op, &ty.t intype,
}
}
- case (ast.div) {
+ case (ast::div) {
if (is_float) {
ret res(cx, cx.build.FDiv(lhs, rhs));
}
- if (ty.type_is_signed(cx.fcx.lcx.ccx.tcx, intype)) {
+ if (ty::type_is_signed(cx.fcx.lcx.ccx.tcx, intype)) {
ret res(cx, cx.build.SDiv(lhs, rhs));
} else {
ret res(cx, cx.build.UDiv(lhs, rhs));
}
}
- case (ast.rem) {
+ case (ast::rem) {
if (is_float) {
ret res(cx, cx.build.FRem(lhs, rhs));
}
- if (ty.type_is_signed(cx.fcx.lcx.ccx.tcx, intype)) {
+ if (ty::type_is_signed(cx.fcx.lcx.ccx.tcx, intype)) {
ret res(cx, cx.build.SRem(lhs, rhs));
} else {
ret res(cx, cx.build.URem(lhs, rhs));
}
}
- case (ast.bitor) { ret res(cx, cx.build.Or(lhs, rhs)); }
- case (ast.bitand) { ret res(cx, cx.build.And(lhs, rhs)); }
- case (ast.bitxor) { ret res(cx, cx.build.Xor(lhs, rhs)); }
- case (ast.lsl) { ret res(cx, cx.build.Shl(lhs, rhs)); }
- case (ast.lsr) { ret res(cx, cx.build.LShr(lhs, rhs)); }
- case (ast.asr) { ret res(cx, cx.build.AShr(lhs, rhs)); }
+ case (ast::bitor) { ret res(cx, cx.build.Or(lhs, rhs)); }
+ case (ast::bitand) { ret res(cx, cx.build.And(lhs, rhs)); }
+ case (ast::bitxor) { ret res(cx, cx.build.Xor(lhs, rhs)); }
+ case (ast::lsl) { ret res(cx, cx.build.Shl(lhs, rhs)); }
+ case (ast::lsr) { ret res(cx, cx.build.LShr(lhs, rhs)); }
+ case (ast::asr) { ret res(cx, cx.build.AShr(lhs, rhs)); }
case (_) {
ret trans_compare(cx, op, intype, lhs, rhs);
}
@@ -3367,23 +3375,23 @@ fn trans_eager_binop(&@block_ctxt cx, ast.binop op, &ty.t intype,
fail;
}
-fn autoderef(&@block_ctxt cx, ValueRef v, &ty.t t) -> result {
+fn autoderef(&@block_ctxt cx, ValueRef v, &ty::t t) -> result {
let ValueRef v1 = v;
- let ty.t t1 = t;
+ let ty::t t1 = t;
while (true) {
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, t1)) {
- case (ty.ty_box(?mt)) {
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, t1)) {
+ case (ty::ty_box(?mt)) {
auto body = cx.build.GEP(v1,
vec(C_int(0),
- C_int(abi.box_rc_field_body)));
+ C_int(abi::box_rc_field_body)));
t1 = mt.ty;
// Since we're changing levels of box indirection, we may have
// to cast this pointer, since statically-sized tag types have
// different types depending on whether they're behind a box
// or not.
- if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, mt.ty)) {
+ if (!ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, mt.ty)) {
auto llty = type_of(cx.fcx.lcx.ccx, mt.ty);
v1 = cx.build.PointerCast(body, T_ptr(llty));
} else {
@@ -3399,12 +3407,12 @@ fn autoderef(&@block_ctxt cx, ValueRef v, &ty.t t) -> result {
}
}
-fn autoderefed_ty(&@crate_ctxt ccx, &ty.t t) -> ty.t {
- let ty.t t1 = t;
+fn autoderefed_ty(&@crate_ctxt ccx, &ty::t t) -> ty::t {
+ let ty::t t1 = t;
while (true) {
- alt (ty.struct(ccx.tcx, t1)) {
- case (ty.ty_box(?mt)) {
+ alt (ty::struct(ccx.tcx, t1)) {
+ case (ty::ty_box(?mt)) {
t1 = mt.ty;
}
case (_) {
@@ -3414,22 +3422,22 @@ fn autoderefed_ty(&@crate_ctxt ccx, &ty.t t) -> ty.t {
}
}
-fn trans_binary(&@block_ctxt cx, ast.binop op,
- &@ast.expr a, &@ast.expr b) -> result {
+fn trans_binary(&@block_ctxt cx, ast::binop op,
+ &@ast::expr a, &@ast::expr b) -> result {
// First couple cases are lazy:
alt (op) {
- case (ast.and) {
+ case (ast::and) {
// Lazy-eval and
auto lhs_res = trans_expr(cx, a);
lhs_res = autoderef(lhs_res.bcx, lhs_res.val,
- ty.expr_ty(cx.fcx.lcx.ccx.tcx, a));
+ ty::expr_ty(cx.fcx.lcx.ccx.tcx, a));
auto rhs_cx = new_scope_block_ctxt(cx, "rhs");
auto rhs_res = trans_expr(rhs_cx, b);
rhs_res = autoderef(rhs_res.bcx, rhs_res.val,
- ty.expr_ty(cx.fcx.lcx.ccx.tcx, b));
+ ty::expr_ty(cx.fcx.lcx.ccx.tcx, b));
auto lhs_false_cx = new_scope_block_ctxt(cx, "lhs false");
auto lhs_false_res = res(lhs_false_cx, C_bool(false));
@@ -3442,16 +3450,16 @@ fn trans_binary(&@block_ctxt cx, ast.binop op,
vec(lhs_false_res, rhs_res));
}
- case (ast.or) {
+ case (ast::or) {
// Lazy-eval or
auto lhs_res = trans_expr(cx, a);
lhs_res = autoderef(lhs_res.bcx, lhs_res.val,
- ty.expr_ty(cx.fcx.lcx.ccx.tcx, a));
+ ty::expr_ty(cx.fcx.lcx.ccx.tcx, a));
auto rhs_cx = new_scope_block_ctxt(cx, "rhs");
auto rhs_res = trans_expr(rhs_cx, b);
rhs_res = autoderef(rhs_res.bcx, rhs_res.val,
- ty.expr_ty(cx.fcx.lcx.ccx.tcx, b));
+ ty::expr_ty(cx.fcx.lcx.ccx.tcx, b));
auto lhs_true_cx = new_scope_block_ctxt(cx, "lhs true");
auto lhs_true_res = res(lhs_true_cx, C_bool(true));
@@ -3467,10 +3475,10 @@ fn trans_binary(&@block_ctxt cx, ast.binop op,
case (_) {
// Remaining cases are eager:
auto lhs = trans_expr(cx, a);
- auto lhty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, a);
+ auto lhty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, a);
lhs = autoderef(lhs.bcx, lhs.val, lhty);
auto rhs = trans_expr(lhs.bcx, b);
- auto rhty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, b);
+ auto rhty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, b);
rhs = autoderef(rhs.bcx, rhs.val, rhty);
ret trans_eager_binop(rhs.bcx, op,
autoderefed_ty(cx.fcx.lcx.ccx, lhty), lhs.val, rhs.val);
@@ -3496,12 +3504,12 @@ fn join_results(&@block_ctxt parent_cx,
}
}
- alt (Vec.len[result](live)) {
+ alt (_vec::len[result](live)) {
case (0u) {
// No incoming edges are live, so we're in dead-code-land.
// Arbitrarily pick the first dead edge, since the caller
// is just going to propagate it outward.
- assert (Vec.len[result](ins) >= 1u);
+ assert (_vec::len[result](ins) >= 1u);
ret ins.(0);
}
@@ -3517,8 +3525,8 @@ fn join_results(&@block_ctxt parent_cx,
ret res(join_cx, phi);
}
-fn trans_if(&@block_ctxt cx, &@ast.expr cond,
- &ast.block thn, &Option.t[@ast.expr] els) -> result {
+fn trans_if(&@block_ctxt cx, &@ast::expr cond,
+ &ast::block thn, &option::t[@ast::expr] els) -> result {
auto cond_res = trans_expr(cx, cond);
@@ -3530,12 +3538,12 @@ fn trans_if(&@block_ctxt cx, &@ast.expr cond,
auto else_res;
auto expr_llty;
alt (els) {
- case (some[@ast.expr](?elexpr)) {
+ case (some[@ast::expr](?elexpr)) {
alt (elexpr.node) {
- case (ast.expr_if(_, _, _, _)) {
+ case (ast::expr_if(_, _, _, _)) {
else_res = trans_expr(else_cx, elexpr);
}
- case (ast.expr_block(?blk, _)) {
+ case (ast::expr_block(?blk, _)) {
// Calling trans_block directly instead of trans_expr
// because trans_expr will create another scope block
// context for the block, but we've already got the
@@ -3547,12 +3555,12 @@ fn trans_if(&@block_ctxt cx, &@ast.expr cond,
// If we have an else expression, then the entire
// if expression can have a non-nil type.
// FIXME: This isn't quite right, particularly re: dynamic types
- auto expr_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, elexpr);
- if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, expr_ty)) {
+ auto expr_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, elexpr);
+ if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, expr_ty)) {
expr_llty = T_typaram_ptr(cx.fcx.lcx.ccx.tn);
} else {
expr_llty = type_of(else_res.bcx.fcx.lcx.ccx, expr_ty);
- if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, expr_ty)) {
+ if (ty::type_is_structural(cx.fcx.lcx.ccx.tcx, expr_ty)) {
expr_llty = T_ptr(expr_llty);
}
}
@@ -3572,17 +3580,17 @@ fn trans_if(&@block_ctxt cx, &@ast.expr cond,
}
fn trans_for(&@block_ctxt cx,
- &@ast.decl decl,
- &@ast.expr seq,
- &ast.block body) -> result {
+ &@ast::decl decl,
+ &@ast::expr seq,
+ &ast::block body) -> result {
fn inner(&@block_ctxt cx,
- @ast.local local, ValueRef curr,
- ty.t t, ast.block body,
+ @ast::local local, ValueRef curr,
+ ty::t t, ast::block body,
@block_ctxt outer_next_cx) -> result {
auto next_cx = new_sub_block_ctxt(cx, "next");
auto scope_cx =
- new_loop_scope_block_ctxt(cx, Option.some[@block_ctxt](next_cx),
+ new_loop_scope_block_ctxt(cx, option::some[@block_ctxt](next_cx),
outer_next_cx, "for loop scope");
cx.build.Br(scope_cx.llbb);
@@ -3596,15 +3604,15 @@ fn trans_for(&@block_ctxt cx,
}
- let @ast.local local;
+ let @ast::local local;
alt (decl.node) {
- case (ast.decl_local(?loc)) {
+ case (ast::decl_local(?loc)) {
local = loc;
}
}
auto next_cx = new_sub_block_ctxt(cx, "next");
- auto seq_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, seq);
+ auto seq_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, seq);
auto seq_res = trans_expr(cx, seq);
auto it = iter_sequence(seq_res.bcx, seq_res.val, seq_ty,
bind inner(_, local, _, _, body, next_cx));
@@ -3617,26 +3625,26 @@ fn trans_for(&@block_ctxt cx,
// Searches through a block for all references to locals or upvars in this
// frame and returns the list of definition IDs thus found.
-fn collect_upvars(&@block_ctxt cx, &ast.block bloc, &ast.def_id initial_decl)
- -> vec[ast.def_id] {
+fn collect_upvars(&@block_ctxt cx, &ast::block bloc,
+ &ast::def_id initial_decl) -> vec[ast::def_id] {
type env = @rec(
- mutable vec[ast.def_id] refs,
- hashmap[ast.def_id,()] decls,
- resolve.def_map def_map
+ mutable vec[ast::def_id] refs,
+ hashmap[ast::def_id,()] decls,
+ resolve::def_map def_map
);
- fn walk_expr(env e, &@ast.expr expr) {
+ fn walk_expr(env e, &@ast::expr expr) {
alt (expr.node) {
- case (ast.expr_path(?path, ?ann)) {
- alt (e.def_map.get(ast.ann_tag(ann))) {
- case (ast.def_arg(?did)) {
- Vec.push[ast.def_id](e.refs, did);
+ case (ast::expr_path(?path, ?ann)) {
+ alt (e.def_map.get(ast::ann_tag(ann))) {
+ case (ast::def_arg(?did)) {
+ _vec::push[ast::def_id](e.refs, did);
}
- case (ast.def_local(?did)) {
- Vec.push[ast.def_id](e.refs, did);
+ case (ast::def_local(?did)) {
+ _vec::push[ast::def_id](e.refs, did);
}
- case (ast.def_upvar(?did)) {
- Vec.push[ast.def_id](e.refs, did);
+ case (ast::def_upvar(?did)) {
+ _vec::push[ast::def_id](e.refs, did);
}
case (_) {}
}
@@ -3645,17 +3653,17 @@ fn collect_upvars(&@block_ctxt cx, &ast.block bloc, &ast.def_id initial_decl)
}
}
- fn walk_decl(env e, &@ast.decl decl) {
+ fn walk_decl(env e, &@ast::decl decl) {
alt (decl.node) {
- case (ast.decl_local(?local)) {
+ case (ast::decl_local(?local)) {
e.decls.insert(local.id, ());
}
case (_) {}
}
}
- let vec[ast.def_id] refs = vec();
- let hashmap[ast.def_id,()] decls = new_def_hash[()]();
+ let vec[ast::def_id] refs = vec();
+ let hashmap[ast::def_id,()] decls = new_def_hash[()]();
decls.insert(initial_decl, ());
let env e = @rec(mutable refs=refs,
decls=decls,
@@ -3663,12 +3671,12 @@ fn collect_upvars(&@block_ctxt cx, &ast.block bloc, &ast.def_id initial_decl)
auto visitor = @rec(visit_decl_pre = bind walk_decl(e, _),
visit_expr_pre = bind walk_expr(e, _)
- with walk.default_visitor());
- walk.walk_block(*visitor, bloc);
+ with walk::default_visitor());
+ walk::walk_block(*visitor, bloc);
// Calculate (refs - decls). This is the set of captured upvars.
- let vec[ast.def_id] result = vec();
- for (ast.def_id ref_id in e.refs) {
+ let vec[ast::def_id] result = vec();
+ for (ast::def_id ref_id in e.refs) {
if (!decls.contains_key(ref_id)) {
result += vec(ref_id);
}
@@ -3678,9 +3686,9 @@ fn collect_upvars(&@block_ctxt cx, &ast.block bloc, &ast.def_id initial_decl)
}
fn trans_for_each(&@block_ctxt cx,
- &@ast.decl decl,
- &@ast.expr seq,
- &ast.block body) -> result {
+ &@ast::decl decl,
+ &@ast::expr seq,
+ &ast::block body) -> result {
/*
* The translation is a little .. complex here. Code like:
*
@@ -3709,24 +3717,24 @@ fn trans_for_each(&@block_ctxt cx,
auto lcx = cx.fcx.lcx;
// FIXME: possibly support alias-mode here?
- auto decl_ty = ty.mk_nil(lcx.ccx.tcx);
+ auto decl_ty = ty::mk_nil(lcx.ccx.tcx);
auto decl_id;
alt (decl.node) {
- case (ast.decl_local(?local)) {
+ case (ast::decl_local(?local)) {
decl_ty = node_ann_type(lcx.ccx, local.ann);
decl_id = local.id;
}
}
auto upvars = collect_upvars(cx, body, decl_id);
- auto upvar_count = Vec.len[ast.def_id](upvars);
+ auto upvar_count = _vec::len[ast::def_id](upvars);
auto llbindingsptr;
if (upvar_count > 0u) {
// Gather up the upvars.
let vec[ValueRef] llbindings = vec();
let vec[TypeRef] llbindingtys = vec();
- for (ast.def_id did in upvars) {
+ for (ast::def_id did in upvars) {
auto llbinding;
alt (cx.fcx.lllocals.find(did)) {
case (none[ValueRef]) {
@@ -3758,14 +3766,14 @@ fn trans_for_each(&@block_ctxt cx,
}
// Create an environment and populate it with the bindings.
- auto tydesc_count = Vec.len[ValueRef](cx.fcx.lltydescs);
+ auto tydesc_count = _vec::len[ValueRef](cx.fcx.lltydescs);
auto llenvptrty = T_closure_ptr(lcx.ccx.tn, T_ptr(T_nil()),
val_ty(llbindingsptr), tydesc_count);
- auto llenvptr = alloca(cx, llvm.LLVMGetElementType(llenvptrty));
+ auto llenvptr = alloca(cx, llvm::LLVMGetElementType(llenvptrty));
auto llbindingsptrptr = cx.build.GEP(llenvptr,
vec(C_int(0),
- C_int(abi.box_rc_field_body),
+ C_int(abi::box_rc_field_body),
C_int(2)));
cx.build.Store(llbindingsptr, llbindingsptrptr);
@@ -3773,8 +3781,8 @@ fn trans_for_each(&@block_ctxt cx,
// to them.
auto lltydescsptr = cx.build.GEP(llenvptr,
vec(C_int(0),
- C_int(abi.box_rc_field_body),
- C_int(abi.closure_elt_ty_params)));
+ C_int(abi::box_rc_field_body),
+ C_int(abi::closure_elt_ty_params)));
auto i = 0u;
while (i < tydesc_count) {
auto lltydescptr = cx.build.GEP(lltydescsptr,
@@ -3794,10 +3802,10 @@ fn trans_for_each(&@block_ctxt cx,
// and pass it in as a first class fn-arg to the iterator.
auto iter_body_llty =
- type_of_fn_full(lcx.ccx, ast.proto_fn,
+ type_of_fn_full(lcx.ccx, ast::proto_fn,
none[TypeRef],
- vec(rec(mode=ty.mo_alias, ty=decl_ty)),
- ty.mk_nil(lcx.ccx.tcx), 0u);
+ vec(rec(mode=ty::mo_alias, ty=decl_ty)),
+ ty::mk_nil(lcx.ccx.tcx), 0u);
let ValueRef lliterbody = decl_internal_fastcall_fn(lcx.ccx.llmod,
s, iter_body_llty);
@@ -3812,8 +3820,8 @@ fn trans_for_each(&@block_ctxt cx,
auto llremotebindingsptrptr =
copy_args_bcx.build.GEP(llremoteenvptr,
vec(C_int(0),
- C_int(abi.box_rc_field_body),
- C_int(abi.closure_elt_bindings)));
+ C_int(abi::box_rc_field_body),
+ C_int(abi::closure_elt_bindings)));
auto llremotebindingsptr =
copy_args_bcx.build.Load(llremotebindingsptrptr);
@@ -3833,8 +3841,8 @@ fn trans_for_each(&@block_ctxt cx,
auto llremotetydescsptr =
copy_args_bcx.build.GEP(llremoteenvptr,
vec(C_int(0),
- C_int(abi.box_rc_field_body),
- C_int(abi.closure_elt_ty_params)));
+ C_int(abi::box_rc_field_body),
+ C_int(abi::closure_elt_ty_params)));
i = 0u;
while (i < tydesc_count) {
@@ -3847,7 +3855,7 @@ fn trans_for_each(&@block_ctxt cx,
}
// Add an upvar for the loop variable alias.
- fcx.llupvars.insert(decl_id, llvm.LLVMGetParam(fcx.llfn, 3u));
+ fcx.llupvars.insert(decl_id, llvm::LLVMGetParam(fcx.llfn, 3u));
auto bcx = new_top_block_ctxt(fcx);
auto lltop = bcx.llbb;
@@ -3862,17 +3870,17 @@ fn trans_for_each(&@block_ctxt cx,
alt (seq.node) {
- case (ast.expr_call(?f, ?args, ?ann)) {
+ case (ast::expr_call(?f, ?args, ?ann)) {
auto pair = alloca(cx, T_fn_pair(lcx.ccx.tn,
iter_body_llty));
auto code_cell = cx.build.GEP(pair,
vec(C_int(0),
- C_int(abi.fn_field_code)));
+ C_int(abi::fn_field_code)));
cx.build.Store(lliterbody, code_cell);
auto env_cell = cx.build.GEP(pair, vec(C_int(0),
- C_int(abi.fn_field_box)));
+ C_int(abi::fn_field_box)));
auto llenvblobptr = cx.build.PointerCast(llenvptr,
T_opaque_closure_ptr(lcx.ccx.tn));
cx.build.Store(llenvblobptr, env_cell);
@@ -3889,12 +3897,12 @@ fn trans_for_each(&@block_ctxt cx,
}
-fn trans_while(&@block_ctxt cx, &@ast.expr cond,
- &ast.block body) -> result {
+fn trans_while(&@block_ctxt cx, &@ast::expr cond,
+ &ast::block body) -> result {
auto cond_cx = new_scope_block_ctxt(cx, "while cond");
auto next_cx = new_sub_block_ctxt(cx, "next");
- auto body_cx = new_loop_scope_block_ctxt(cx, Option.none[@block_ctxt],
+ auto body_cx = new_loop_scope_block_ctxt(cx, option::none[@block_ctxt],
next_cx, "while loop body");
auto body_res = trans_block(body_cx, body);
@@ -3909,11 +3917,11 @@ fn trans_while(&@block_ctxt cx, &@ast.expr cond,
ret res(next_cx, C_nil());
}
-fn trans_do_while(&@block_ctxt cx, &ast.block body,
- &@ast.expr cond) -> result {
+fn trans_do_while(&@block_ctxt cx, &ast::block body,
+ &@ast::expr cond) -> result {
auto next_cx = new_sub_block_ctxt(cx, "next");
- auto body_cx = new_loop_scope_block_ctxt(cx, Option.none[@block_ctxt],
+ auto body_cx = new_loop_scope_block_ctxt(cx, option::none[@block_ctxt],
next_cx, "do-while loop body");
auto body_res = trans_block(body_cx, body);
@@ -3928,23 +3936,23 @@ fn trans_do_while(&@block_ctxt cx, &ast.block body,
// Pattern matching translation
-fn trans_pat_match(&@block_ctxt cx, &@ast.pat pat, ValueRef llval,
+fn trans_pat_match(&@block_ctxt cx, &@ast::pat pat, ValueRef llval,
&@block_ctxt next_cx) -> result {
alt (pat.node) {
- case (ast.pat_wild(_)) { ret res(cx, llval); }
- case (ast.pat_bind(_, _, _)) { ret res(cx, llval); }
+ case (ast::pat_wild(_)) { ret res(cx, llval); }
+ case (ast::pat_bind(_, _, _)) { ret res(cx, llval); }
- case (ast.pat_lit(?lt, ?ann)) {
+ case (ast::pat_lit(?lt, ?ann)) {
auto lllit = trans_lit(cx.fcx.lcx.ccx, *lt, ann);
- auto lltype = ty.ann_to_type(ann);
- auto lleq = trans_compare(cx, ast.eq, lltype, llval, lllit);
+ auto lltype = ty::ann_to_type(ann);
+ auto lleq = trans_compare(cx, ast::eq, lltype, llval, lllit);
auto matched_cx = new_sub_block_ctxt(lleq.bcx, "matched_cx");
lleq.bcx.build.CondBr(lleq.val, matched_cx.llbb, next_cx.llbb);
ret res(matched_cx, llval);
}
- case (ast.pat_tag(?id, ?subpats, ?ann)) {
+ case (ast::pat_tag(?id, ?subpats, ?ann)) {
auto lltagptr = cx.build.PointerCast(llval,
T_opaque_tag_ptr(cx.fcx.lcx.ccx.tn));
@@ -3952,8 +3960,8 @@ fn trans_pat_match(&@block_ctxt cx, &@ast.pat pat, ValueRef llval,
vec(C_int(0), C_int(0)));
auto lldiscrim = cx.build.Load(lldiscrimptr);
- auto vdef = ast.variant_def_ids
- (cx.fcx.lcx.ccx.tcx.def_map.get(ast.ann_tag(ann)));
+ auto vdef = ast::variant_def_ids
+ (cx.fcx.lcx.ccx.tcx.def_map.get(ast::ann_tag(ann)));
auto variant_tag = 0;
auto variants = tag_variants(cx.fcx.lcx.ccx, vdef._0);
@@ -3969,17 +3977,17 @@ fn trans_pat_match(&@block_ctxt cx, &@ast.pat pat, ValueRef llval,
auto matched_cx = new_sub_block_ctxt(cx, "matched_cx");
- auto lleq = cx.build.ICmp(lib.llvm.LLVMIntEQ, lldiscrim,
+ auto lleq = cx.build.ICmp(lib::llvm::LLVMIntEQ, lldiscrim,
C_int(variant_tag));
cx.build.CondBr(lleq, matched_cx.llbb, next_cx.llbb);
auto ty_params = node_ann_ty_params(ann);
- if (Vec.len[@ast.pat](subpats) > 0u) {
+ if (_vec::len[@ast::pat](subpats) > 0u) {
auto llblobptr = matched_cx.build.GEP(lltagptr,
vec(C_int(0), C_int(1)));
auto i = 0;
- for (@ast.pat subpat in subpats) {
+ for (@ast::pat subpat in subpats) {
auto rslt = GEP_tag(matched_cx, llblobptr, vdef._0,
vdef._1, ty_params, i);
auto llsubvalptr = rslt.val;
@@ -4002,13 +4010,13 @@ fn trans_pat_match(&@block_ctxt cx, &@ast.pat pat, ValueRef llval,
fail;
}
-fn trans_pat_binding(&@block_ctxt cx, &@ast.pat pat,
+fn trans_pat_binding(&@block_ctxt cx, &@ast::pat pat,
ValueRef llval, bool bind_alias)
-> result {
alt (pat.node) {
- case (ast.pat_wild(_)) { ret res(cx, llval); }
- case (ast.pat_lit(_, _)) { ret res(cx, llval); }
- case (ast.pat_bind(?id, ?def_id, ?ann)) {
+ case (ast::pat_wild(_)) { ret res(cx, llval); }
+ case (ast::pat_lit(_, _)) { ret res(cx, llval); }
+ case (ast::pat_bind(?id, ?def_id, ?ann)) {
if (bind_alias) {
cx.fcx.lllocals.insert(def_id, llval);
ret res(cx, llval);
@@ -4024,12 +4032,12 @@ fn trans_pat_binding(&@block_ctxt cx, &@ast.pat pat,
ret copy_ty(bcx, INIT, dst, llval, t);
}
}
- case (ast.pat_tag(_, ?subpats, ?ann)) {
- if (Vec.len[@ast.pat](subpats) == 0u) { ret res(cx, llval); }
+ case (ast::pat_tag(_, ?subpats, ?ann)) {
+ if (_vec::len[@ast::pat](subpats) == 0u) { ret res(cx, llval); }
// Get the appropriate variant for this tag.
- auto vdef = ast.variant_def_ids
- (cx.fcx.lcx.ccx.tcx.def_map.get(ast.ann_tag(ann)));
+ auto vdef = ast::variant_def_ids
+ (cx.fcx.lcx.ccx.tcx.def_map.get(ast::ann_tag(ann)));
auto lltagptr = cx.build.PointerCast(llval,
T_opaque_tag_ptr(cx.fcx.lcx.ccx.tn));
@@ -4039,7 +4047,7 @@ fn trans_pat_binding(&@block_ctxt cx, &@ast.pat pat,
auto this_cx = cx;
auto i = 0;
- for (@ast.pat subpat in subpats) {
+ for (@ast::pat subpat in subpats) {
auto rslt = GEP_tag(this_cx, llblobptr, vdef._0, vdef._1,
ty_param_substs, i);
this_cx = rslt.bcx;
@@ -4054,13 +4062,13 @@ fn trans_pat_binding(&@block_ctxt cx, &@ast.pat pat,
}
}
-fn trans_alt(&@block_ctxt cx, &@ast.expr expr,
- &vec[ast.arm] arms, &ast.ann ann) -> result {
+fn trans_alt(&@block_ctxt cx, &@ast::expr expr,
+ &vec[ast::arm] arms, &ast::ann ann) -> result {
auto expr_res = trans_expr(cx, expr);
auto this_cx = expr_res.bcx;
let vec[result] arm_results = vec();
- for (ast.arm arm in arms) {
+ for (ast::arm arm in arms) {
auto next_cx = new_sub_block_ctxt(expr_res.bcx, "next");
auto match_res = trans_pat_match(this_cx, arm.pat, expr_res.val,
next_cx);
@@ -4078,17 +4086,17 @@ fn trans_alt(&@block_ctxt cx, &@ast.expr expr,
}
auto default_cx = this_cx;
- auto default_res = trans_fail(default_cx, some[common.span](expr.span),
+ auto default_res = trans_fail(default_cx, some[common::span](expr.span),
"non-exhaustive match failure");
// FIXME: This isn't quite right, particularly re: dynamic types
- auto expr_ty = ty.ann_to_type(ann);
+ auto expr_ty = ty::ann_to_type(ann);
auto expr_llty;
- if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, expr_ty)) {
+ if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, expr_ty)) {
expr_llty = T_typaram_ptr(cx.fcx.lcx.ccx.tn);
} else {
expr_llty = type_of(cx.fcx.lcx.ccx, expr_ty);
- if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, expr_ty)) {
+ if (ty::type_is_structural(cx.fcx.lcx.ccx.tcx, expr_ty)) {
expr_llty = T_ptr(expr_llty);
}
}
@@ -4096,21 +4104,21 @@ fn trans_alt(&@block_ctxt cx, &@ast.expr expr,
ret join_results(cx, expr_llty, arm_results);
}
-type generic_info = rec(ty.t item_type,
+type generic_info = rec(ty::t item_type,
vec[ValueRef] tydescs);
type lval_result = rec(result res,
bool is_mem,
- Option.t[generic_info] generic,
- Option.t[ValueRef] llobj,
- Option.t[ty.t] method_ty);
+ option::t[generic_info] generic,
+ option::t[ValueRef] llobj,
+ option::t[ty::t] method_ty);
fn lval_mem(&@block_ctxt cx, ValueRef val) -> lval_result {
ret rec(res=res(cx, val),
is_mem=true,
generic=none[generic_info],
llobj=none[ValueRef],
- method_ty=none[ty.t]);
+ method_ty=none[ty::t]);
}
fn lval_val(&@block_ctxt cx, ValueRef val) -> lval_result {
@@ -4118,22 +4126,22 @@ fn lval_val(&@block_ctxt cx, ValueRef val) -> lval_result {
is_mem=false,
generic=none[generic_info],
llobj=none[ValueRef],
- method_ty=none[ty.t]);
+ method_ty=none[ty::t]);
}
-fn trans_external_path(&@block_ctxt cx, &ast.def_id did,
- &ty.ty_param_count_and_ty tpt) -> lval_result {
+fn trans_external_path(&@block_ctxt cx, &ast::def_id did,
+ &ty::ty_param_count_and_ty tpt) -> lval_result {
auto lcx = cx.fcx.lcx;
- auto name = creader.get_symbol(lcx.ccx.sess, did);
+ auto name = creader::get_symbol(lcx.ccx.sess, did);
auto v = get_extern_const(lcx.ccx.externs, lcx.ccx.llmod,
name, type_of_ty_param_count_and_ty(lcx, tpt));
ret lval_val(cx, v);
}
fn lval_generic_fn(&@block_ctxt cx,
- &ty.ty_param_count_and_ty tpt,
- &ast.def_id fn_id,
- &ast.ann ann)
+ &ty::ty_param_count_and_ty tpt,
+ &ast::def_id fn_id,
+ &ast::ann ann)
-> lval_result {
auto lv;
if (cx.fcx.lcx.ccx.sess.get_targ_crate_num() == fn_id._0) {
@@ -4146,26 +4154,26 @@ fn lval_generic_fn(&@block_ctxt cx,
}
auto monoty;
- let vec[ty.t] tys;
+ let vec[ty::t] tys;
alt (ann) {
- case (ast.ann_none(_)) {
+ case (ast::ann_none(_)) {
cx.fcx.lcx.ccx.sess.bug("no type annotation for path!");
fail;
}
- case (ast.ann_type(_, ?monoty_, ?tps, _)) {
+ case (ast::ann_type(_, ?monoty_, ?tps, _)) {
monoty = monoty_;
- tys = Option.get[vec[ty.t]](tps);
+ tys = option::get[vec[ty::t]](tps);
}
}
- if (Vec.len[ty.t](tys) != 0u) {
+ if (_vec::len[ty::t](tys) != 0u) {
auto bcx = lv.res.bcx;
let vec[ValueRef] tydescs = vec();
- for (ty.t t in tys) {
+ for (ty::t t in tys) {
// TODO: Doesn't always escape.
auto td = get_tydesc(bcx, t, true);
bcx = td.bcx;
- Vec.push[ValueRef](tydescs, td.val);
+ _vec::push[ValueRef](tydescs, td.val);
}
auto gen = rec( item_type = tpt._1,
tydescs = tydescs );
@@ -4176,18 +4184,18 @@ fn lval_generic_fn(&@block_ctxt cx,
ret lv;
}
-fn lookup_discriminant(&@local_ctxt lcx, &ast.def_id tid, &ast.def_id vid)
+fn lookup_discriminant(&@local_ctxt lcx, &ast::def_id tid, &ast::def_id vid)
-> ValueRef {
alt (lcx.ccx.discrims.find(vid)) {
case (none[ValueRef]) {
// It's an external discriminant that we haven't seen yet.
assert (lcx.ccx.sess.get_targ_crate_num() != vid._0);
- auto sym = creader.get_symbol(lcx.ccx.sess, vid);
- auto gvar = llvm.LLVMAddGlobal(lcx.ccx.llmod, T_int(),
- Str.buf(sym));
- llvm.LLVMSetLinkage(gvar,
- lib.llvm.LLVMExternalLinkage as llvm.Linkage);
- llvm.LLVMSetGlobalConstant(gvar, True);
+ auto sym = creader::get_symbol(lcx.ccx.sess, vid);
+ auto gvar = llvm::LLVMAddGlobal(lcx.ccx.llmod, T_int(),
+ _str::buf(sym));
+ llvm::LLVMSetLinkage(gvar, lib::llvm::LLVMExternalLinkage
+ as llvm::Linkage);
+ llvm::LLVMSetGlobalConstant(gvar, True);
lcx.ccx.discrims.insert(vid, gvar);
ret gvar;
}
@@ -4195,9 +4203,9 @@ fn lookup_discriminant(&@local_ctxt lcx, &ast.def_id tid, &ast.def_id vid)
}
}
-fn trans_path(&@block_ctxt cx, &ast.path p, &ast.ann ann) -> lval_result {
- alt (cx.fcx.lcx.ccx.tcx.def_map.get(ast.ann_tag(ann))) {
- case (ast.def_arg(?did)) {
+fn trans_path(&@block_ctxt cx, &ast::path p, &ast::ann ann) -> lval_result {
+ alt (cx.fcx.lcx.ccx.tcx.def_map.get(ast::ann_tag(ann))) {
+ case (ast::def_arg(?did)) {
alt (cx.fcx.llargs.find(did)) {
case (none[ValueRef]) {
assert (cx.fcx.llupvars.contains_key(did));
@@ -4208,7 +4216,7 @@ fn trans_path(&@block_ctxt cx, &ast.path p, &ast.ann ann) -> lval_result {
}
}
}
- case (ast.def_local(?did)) {
+ case (ast::def_local(?did)) {
alt (cx.fcx.lllocals.find(did)) {
case (none[ValueRef]) {
assert (cx.fcx.llupvars.contains_key(did));
@@ -4219,32 +4227,32 @@ fn trans_path(&@block_ctxt cx, &ast.path p, &ast.ann ann) -> lval_result {
}
}
}
- case (ast.def_binding(?did)) {
+ case (ast::def_binding(?did)) {
assert (cx.fcx.lllocals.contains_key(did));
ret lval_mem(cx, cx.fcx.lllocals.get(did));
}
- case (ast.def_obj_field(?did)) {
+ case (ast::def_obj_field(?did)) {
assert (cx.fcx.llobjfields.contains_key(did));
ret lval_mem(cx, cx.fcx.llobjfields.get(did));
}
- case (ast.def_fn(?did)) {
- auto tyt = ty.lookup_item_type(cx.fcx.lcx.ccx.sess,
+ case (ast::def_fn(?did)) {
+ auto tyt = ty::lookup_item_type(cx.fcx.lcx.ccx.sess,
cx.fcx.lcx.ccx.tcx,
cx.fcx.lcx.ccx.type_cache, did);
ret lval_generic_fn(cx, tyt, did, ann);
}
- case (ast.def_obj(?did)) {
- auto tyt = ty.lookup_item_type(cx.fcx.lcx.ccx.sess,
+ case (ast::def_obj(?did)) {
+ auto tyt = ty::lookup_item_type(cx.fcx.lcx.ccx.sess,
cx.fcx.lcx.ccx.tcx,
cx.fcx.lcx.ccx.type_cache, did);
ret lval_generic_fn(cx, tyt, did, ann);
}
- case (ast.def_variant(?tid, ?vid)) {
- auto v_tyt = ty.lookup_item_type(cx.fcx.lcx.ccx.sess,
+ case (ast::def_variant(?tid, ?vid)) {
+ auto v_tyt = ty::lookup_item_type(cx.fcx.lcx.ccx.sess,
cx.fcx.lcx.ccx.tcx,
cx.fcx.lcx.ccx.type_cache, vid);
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, v_tyt._1)) {
- case (ty.ty_fn(_, _, _)) {
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, v_tyt._1)) {
+ case (ty::ty_fn(_, _, _)) {
// N-ary variant.
ret lval_generic_fn(cx, v_tyt, vid, ann);
}
@@ -4259,7 +4267,7 @@ fn trans_path(&@block_ctxt cx, &ast.path p, &ast.ann ann) -> lval_result {
auto lltagblob = alloc_result.val;
auto lltagty;
- if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx,
+ if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx,
tag_ty)) {
lltagty = T_opaque_tag(cx.fcx.lcx.ccx.tn);
} else {
@@ -4277,13 +4285,13 @@ fn trans_path(&@block_ctxt cx, &ast.path p, &ast.ann ann) -> lval_result {
}
}
}
- case (ast.def_const(?did)) {
+ case (ast::def_const(?did)) {
// TODO: externals
assert (cx.fcx.lcx.ccx.consts.contains_key(did));
ret lval_mem(cx, cx.fcx.lcx.ccx.consts.get(did));
}
- case (ast.def_native_fn(?did)) {
- auto tyt = ty.lookup_item_type(cx.fcx.lcx.ccx.sess,
+ case (ast::def_native_fn(?did)) {
+ auto tyt = ty::lookup_item_type(cx.fcx.lcx.ccx.sess,
cx.fcx.lcx.ccx.tcx,
cx.fcx.lcx.ccx.type_cache, did);
ret lval_generic_fn(cx, tyt, did, ann);
@@ -4294,40 +4302,40 @@ fn trans_path(&@block_ctxt cx, &ast.path p, &ast.ann ann) -> lval_result {
}
}
-fn trans_field(&@block_ctxt cx, &ast.span sp, ValueRef v, &ty.t t0,
- &ast.ident field, &ast.ann ann) -> lval_result {
+fn trans_field(&@block_ctxt cx, &ast::span sp, ValueRef v, &ty::t t0,
+ &ast::ident field, &ast::ann ann) -> lval_result {
auto r = autoderef(cx, v, t0);
auto t = autoderefed_ty(cx.fcx.lcx.ccx, t0);
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
- case (ty.ty_tup(_)) {
- let uint ix = ty.field_num(cx.fcx.lcx.ccx.sess, sp, field);
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
+ case (ty::ty_tup(_)) {
+ let uint ix = ty::field_num(cx.fcx.lcx.ccx.sess, sp, field);
auto v = GEP_tup_like(r.bcx, t, r.val, vec(0, ix as int));
ret lval_mem(v.bcx, v.val);
}
- case (ty.ty_rec(?fields)) {
- let uint ix = ty.field_idx(cx.fcx.lcx.ccx.sess, sp, field,
+ case (ty::ty_rec(?fields)) {
+ let uint ix = ty::field_idx(cx.fcx.lcx.ccx.sess, sp, field,
fields);
auto v = GEP_tup_like(r.bcx, t, r.val, vec(0, ix as int));
ret lval_mem(v.bcx, v.val);
}
- case (ty.ty_obj(?methods)) {
- let uint ix = ty.method_idx(cx.fcx.lcx.ccx.sess, sp, field,
+ case (ty::ty_obj(?methods)) {
+ let uint ix = ty::method_idx(cx.fcx.lcx.ccx.sess, sp, field,
methods);
auto vtbl = r.bcx.build.GEP(r.val,
vec(C_int(0),
- C_int(abi.obj_field_vtbl)));
+ C_int(abi::obj_field_vtbl)));
vtbl = r.bcx.build.Load(vtbl);
// +1 because slot #0 contains the destructor
auto v = r.bcx.build.GEP(vtbl, vec(C_int(0),
C_int((ix + 1u) as int)));
auto lvo = lval_mem(r.bcx, v);
- let ty.t fn_ty = ty.method_ty_to_fn_ty(cx.fcx.lcx.ccx.tcx,
+ let ty::t fn_ty = ty::method_ty_to_fn_ty(cx.fcx.lcx.ccx.tcx,
methods.(ix));
ret rec(llobj = some[ValueRef](r.val),
- method_ty = some[ty.t](fn_ty)
+ method_ty = some[ty::t](fn_ty)
with lvo);
}
case (_) {cx.fcx.lcx.ccx.sess.unimpl("field variant in trans_field");}
@@ -4335,11 +4343,11 @@ fn trans_field(&@block_ctxt cx, &ast.span sp, ValueRef v, &ty.t t0,
fail;
}
-fn trans_index(&@block_ctxt cx, &ast.span sp, &@ast.expr base,
- &@ast.expr idx, &ast.ann ann) -> lval_result {
+fn trans_index(&@block_ctxt cx, &ast::span sp, &@ast::expr base,
+ &@ast::expr idx, &ast::ann ann) -> lval_result {
auto lv = trans_expr(cx, base);
- lv = autoderef(lv.bcx, lv.val, ty.expr_ty(cx.fcx.lcx.ccx.tcx, base));
+ lv = autoderef(lv.bcx, lv.val, ty::expr_ty(cx.fcx.lcx.ccx.tcx, base));
auto ix = trans_expr(lv.bcx, idx);
auto v = lv.val;
auto bcx = ix.bcx;
@@ -4364,10 +4372,10 @@ fn trans_index(&@block_ctxt cx, &ast.span sp, &@ast.expr base,
auto scaled_ix = bcx.build.Mul(ix_val, unit_sz.val);
maybe_name_value(cx.fcx.lcx.ccx, scaled_ix, "scaled_ix");
- auto lim = bcx.build.GEP(v, vec(C_int(0), C_int(abi.vec_elt_fill)));
+ auto lim = bcx.build.GEP(v, vec(C_int(0), C_int(abi::vec_elt_fill)));
lim = bcx.build.Load(lim);
- auto bounds_check = bcx.build.ICmp(lib.llvm.LLVMIntULT,
+ auto bounds_check = bcx.build.ICmp(lib::llvm::LLVMIntULT,
scaled_ix, lim);
auto fail_cx = new_sub_block_ctxt(bcx, "fail");
@@ -4375,12 +4383,12 @@ fn trans_index(&@block_ctxt cx, &ast.span sp, &@ast.expr base,
bcx.build.CondBr(bounds_check, next_cx.llbb, fail_cx.llbb);
// fail: bad bounds check.
- auto fail_res = trans_fail(fail_cx, some[common.span](sp),
+ auto fail_res = trans_fail(fail_cx, some[common::span](sp),
"bounds check");
- auto body = next_cx.build.GEP(v, vec(C_int(0), C_int(abi.vec_elt_data)));
+ auto body = next_cx.build.GEP(v, vec(C_int(0), C_int(abi::vec_elt_data)));
auto elt;
- if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, unit_ty)) {
+ if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, unit_ty)) {
body = next_cx.build.PointerCast(body, T_ptr(T_array(T_i8(), 1u)));
elt = next_cx.build.GEP(body, vec(C_int(0), scaled_ix));
} else {
@@ -4398,29 +4406,29 @@ fn trans_index(&@block_ctxt cx, &ast.span sp, &@ast.expr base,
// represented as an alloca or heap, hence needs a 'load' to be used as an
// immediate).
-fn trans_lval(&@block_ctxt cx, &@ast.expr e) -> lval_result {
+fn trans_lval(&@block_ctxt cx, &@ast::expr e) -> lval_result {
alt (e.node) {
- case (ast.expr_path(?p, ?ann)) {
+ case (ast::expr_path(?p, ?ann)) {
ret trans_path(cx, p, ann);
}
- case (ast.expr_field(?base, ?ident, ?ann)) {
+ case (ast::expr_field(?base, ?ident, ?ann)) {
auto r = trans_expr(cx, base);
- auto t = ty.expr_ty(cx.fcx.lcx.ccx.tcx, base);
+ auto t = ty::expr_ty(cx.fcx.lcx.ccx.tcx, base);
ret trans_field(r.bcx, e.span, r.val, t, ident, ann);
}
- case (ast.expr_index(?base, ?idx, ?ann)) {
+ case (ast::expr_index(?base, ?idx, ?ann)) {
ret trans_index(cx, e.span, base, idx, ann);
}
- case (ast.expr_unary(?unop, ?base, ?ann)) {
- assert (unop == ast.deref);
+ case (ast::expr_unary(?unop, ?base, ?ann)) {
+ assert (unop == ast::deref);
auto sub = trans_expr(cx, base);
auto val = sub.bcx.build.GEP(sub.val,
vec(C_int(0),
- C_int(abi.box_rc_field_body)));
+ C_int(abi::box_rc_field_body)));
ret lval_mem(sub.bcx, val);
}
- case (ast.expr_self_method(?ident, ?ann)) {
+ case (ast::expr_self_method(?ident, ?ann)) {
alt (cx.fcx.llself) {
case (some[self_vt](?s_vt)) {
auto r = s_vt.v;
@@ -4444,8 +4452,8 @@ fn trans_lval(&@block_ctxt cx, &@ast.expr e) -> lval_result {
fn int_cast(&@block_ctxt bcx, TypeRef lldsttype, TypeRef llsrctype,
ValueRef llsrc, bool signed) -> ValueRef {
- if (llvm.LLVMGetIntTypeWidth(lldsttype) >
- llvm.LLVMGetIntTypeWidth(llsrctype)) {
+ if (llvm::LLVMGetIntTypeWidth(lldsttype) >
+ llvm::LLVMGetIntTypeWidth(llsrctype)) {
if (signed) {
// Widening signed cast.
ret bcx.build.SExtOrBitCast(llsrc, lldsttype);
@@ -4458,21 +4466,21 @@ fn int_cast(&@block_ctxt bcx, TypeRef lldsttype, TypeRef llsrctype,
ret bcx.build.TruncOrBitCast(llsrc, lldsttype);
}
-fn trans_cast(&@block_ctxt cx, &@ast.expr e, &ast.ann ann) -> result {
+fn trans_cast(&@block_ctxt cx, &@ast::expr e, &ast::ann ann) -> result {
auto e_res = trans_expr(cx, e);
auto llsrctype = val_ty(e_res.val);
auto t = node_ann_type(cx.fcx.lcx.ccx, ann);
auto lldsttype = type_of(cx.fcx.lcx.ccx, t);
- if (!ty.type_is_fp(cx.fcx.lcx.ccx.tcx, t)) {
+ if (!ty::type_is_fp(cx.fcx.lcx.ccx.tcx, t)) {
// TODO: native-to-native casts
- if (ty.type_is_native(cx.fcx.lcx.ccx.tcx,
- ty.expr_ty(cx.fcx.lcx.ccx.tcx, e))) {
+ if (ty::type_is_native(cx.fcx.lcx.ccx.tcx,
+ ty::expr_ty(cx.fcx.lcx.ccx.tcx, e))) {
e_res.val = e_res.bcx.build.PtrToInt(e_res.val, lldsttype);
- } else if (ty.type_is_native(cx.fcx.lcx.ccx.tcx, t)) {
+ } else if (ty::type_is_native(cx.fcx.lcx.ccx.tcx, t)) {
e_res.val = e_res.bcx.build.IntToPtr(e_res.val, lldsttype);
} else {
e_res.val = int_cast(e_res.bcx, lldsttype, llsrctype, e_res.val,
- ty.type_is_signed(cx.fcx.lcx.ccx.tcx, t));
+ ty::type_is_signed(cx.fcx.lcx.ccx.tcx, t));
}
} else {
cx.fcx.lcx.ccx.sess.unimpl("fp cast");
@@ -4481,14 +4489,14 @@ fn trans_cast(&@block_ctxt cx, &@ast.expr e, &ast.ann ann) -> result {
}
fn trans_bind_thunk(&@local_ctxt cx,
- &ty.t incoming_fty,
- &ty.t outgoing_fty,
- &vec[Option.t[@ast.expr]] args,
- &ty.t closure_ty,
- &vec[ty.t] bound_tys,
+ &ty::t incoming_fty,
+ &ty::t outgoing_fty,
+ &vec[option::t[@ast::expr]] args,
+ &ty::t closure_ty,
+ &vec[ty::t] bound_tys,
uint ty_param_count) -> ValueRef {
// Construct a thunk-call with signature incoming_fty, and that copies
- // args forward into a call to outgoing_fty.
+ // args forward into a call to outgoing_fty:
let str s = mangle_name_by_seq(cx.ccx, cx.path, "thunk");
let TypeRef llthunk_ty = get_pair_fn_ty(type_of(cx.ccx, incoming_fty));
@@ -4500,24 +4508,24 @@ fn trans_bind_thunk(&@local_ctxt cx,
auto lltop = bcx.llbb;
auto llclosure_ptr_ty =
- type_of(cx.ccx, ty.mk_imm_box(cx.ccx.tcx, closure_ty));
+ type_of(cx.ccx, ty::mk_imm_box(cx.ccx.tcx, closure_ty));
auto llclosure = bcx.build.PointerCast(fcx.llenv, llclosure_ptr_ty);
auto lltarget = GEP_tup_like(bcx, closure_ty, llclosure,
vec(0,
- abi.box_rc_field_body,
- abi.closure_elt_target));
+ abi::box_rc_field_body,
+ abi::closure_elt_target));
bcx = lltarget.bcx;
auto lltargetclosure = bcx.build.GEP(lltarget.val,
vec(C_int(0),
- C_int(abi.fn_field_box)));
+ C_int(abi::fn_field_box)));
lltargetclosure = bcx.build.Load(lltargetclosure);
- auto outgoing_ret_ty = ty.ty_fn_ret(cx.ccx.tcx, outgoing_fty);
- auto outgoing_args = ty.ty_fn_args(cx.ccx.tcx, outgoing_fty);
+ auto outgoing_ret_ty = ty::ty_fn_ret(cx.ccx.tcx, outgoing_fty);
+ auto outgoing_args = ty::ty_fn_args(cx.ccx.tcx, outgoing_fty);
auto llretptr = fcx.llretptr;
- if (ty.type_has_dynamic_size(cx.ccx.tcx, outgoing_ret_ty)) {
+ if (ty::type_has_dynamic_size(cx.ccx.tcx, outgoing_ret_ty)) {
llretptr = bcx.build.PointerCast(llretptr, T_typaram_ptr(cx.ccx.tn));
}
@@ -4531,8 +4539,8 @@ fn trans_bind_thunk(&@local_ctxt cx,
auto lltyparam_ptr =
GEP_tup_like(bcx, closure_ty, llclosure,
vec(0,
- abi.box_rc_field_body,
- abi.closure_elt_ty_params,
+ abi::box_rc_field_body,
+ abi::closure_elt_ty_params,
(i as int)));
bcx = lltyparam_ptr.bcx;
auto td = bcx.build.Load(lltyparam_ptr.val);
@@ -4547,7 +4555,7 @@ fn trans_bind_thunk(&@local_ctxt cx,
let vec[TypeRef] llout_arg_tys =
type_of_explicit_args(cx.ccx, outgoing_args);
- for (Option.t[@ast.expr] arg in args) {
+ for (option::t[@ast::expr] arg in args) {
auto out_arg = outgoing_args.(outgoing_arg_index);
auto llout_arg_ty = llout_arg_tys.(outgoing_arg_index);
@@ -4555,19 +4563,19 @@ fn trans_bind_thunk(&@local_ctxt cx,
alt (arg) {
// Arg provided at binding time; thunk copies it from closure.
- case (some[@ast.expr](?e)) {
- auto e_ty = ty.expr_ty(cx.ccx.tcx, e);
+ case (some[@ast::expr](?e)) {
+ auto e_ty = ty::expr_ty(cx.ccx.tcx, e);
auto bound_arg =
GEP_tup_like(bcx, closure_ty, llclosure,
vec(0,
- abi.box_rc_field_body,
- abi.closure_elt_bindings,
+ abi::box_rc_field_body,
+ abi::closure_elt_bindings,
b));
bcx = bound_arg.bcx;
auto val = bound_arg.val;
- if (out_arg.mode == ty.mo_val) {
+ if (out_arg.mode == ty::mo_val) {
if (type_is_immediate(cx.ccx, e_ty)) {
val = bcx.build.Load(val);
bcx = take_ty(bcx, val, e_ty).bcx;
@@ -4575,9 +4583,9 @@ fn trans_bind_thunk(&@local_ctxt cx,
bcx = take_ty(bcx, val, e_ty).bcx;
val = bcx.build.Load(val);
}
- } else if (ty.type_contains_params(cx.ccx.tcx,
+ } else if (ty::type_contains_params(cx.ccx.tcx,
out_arg.ty)) {
- assert (out_arg.mode == ty.mo_alias);
+ assert (out_arg.mode == ty::mo_alias);
val = bcx.build.PointerCast(val, llout_arg_ty);
}
@@ -4586,11 +4594,11 @@ fn trans_bind_thunk(&@local_ctxt cx,
}
// Arg will be provided when the thunk is invoked.
- case (none[@ast.expr]) {
- let ValueRef passed_arg = llvm.LLVMGetParam(llthunk, a);
+ case (none[@ast::expr]) {
+ let ValueRef passed_arg = llvm::LLVMGetParam(llthunk, a);
- if (ty.type_contains_params(cx.ccx.tcx, out_arg.ty)) {
- assert (out_arg.mode == ty.mo_alias);
+ if (ty::type_contains_params(cx.ccx.tcx, out_arg.ty)) {
+ assert (out_arg.mode == ty::mo_alias);
passed_arg = bcx.build.PointerCast(passed_arg,
llout_arg_ty);
}
@@ -4606,12 +4614,12 @@ fn trans_bind_thunk(&@local_ctxt cx,
// FIXME: turn this call + ret into a tail call.
auto lltargetfn = bcx.build.GEP(lltarget.val,
vec(C_int(0),
- C_int(abi.fn_field_code)));
+ C_int(abi::fn_field_code)));
// Cast the outgoing function to the appropriate type (see the comments in
// trans_bind below for why this is necessary).
auto lltargetty = type_of_fn(bcx.fcx.lcx.ccx,
- ty.ty_fn_proto(bcx.fcx.lcx.ccx.tcx,
+ ty::ty_fn_proto(bcx.fcx.lcx.ccx.tcx,
outgoing_fty),
outgoing_args,
outgoing_ret_ty,
@@ -4628,31 +4636,31 @@ fn trans_bind_thunk(&@local_ctxt cx,
ret llthunk;
}
-fn trans_bind(&@block_ctxt cx, &@ast.expr f,
- &vec[Option.t[@ast.expr]] args,
- &ast.ann ann) -> result {
+fn trans_bind(&@block_ctxt cx, &@ast::expr f,
+ &vec[option::t[@ast::expr]] args,
+ &ast::ann ann) -> result {
auto f_res = trans_lval(cx, f);
if (f_res.is_mem) {
cx.fcx.lcx.ccx.sess.unimpl("re-binding existing function");
} else {
- let vec[@ast.expr] bound = vec();
+ let vec[@ast::expr] bound = vec();
- for (Option.t[@ast.expr] argopt in args) {
+ for (option::t[@ast::expr] argopt in args) {
alt (argopt) {
- case (none[@ast.expr]) {
+ case (none[@ast::expr]) {
}
- case (some[@ast.expr](?e)) {
- Vec.push[@ast.expr](bound, e);
+ case (some[@ast::expr](?e)) {
+ _vec::push[@ast::expr](bound, e);
}
}
}
// Figure out which tydescs we need to pass, if any.
- let ty.t outgoing_fty;
+ let ty::t outgoing_fty;
let vec[ValueRef] lltydescs;
alt (f_res.generic) {
case (none[generic_info]) {
- outgoing_fty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, f);
+ outgoing_fty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, f);
lltydescs = vec();
}
case (some[generic_info](?ginfo)) {
@@ -4660,9 +4668,9 @@ fn trans_bind(&@block_ctxt cx, &@ast.expr f,
lltydescs = ginfo.tydescs;
}
}
- auto ty_param_count = Vec.len[ValueRef](lltydescs);
+ auto ty_param_count = _vec::len[ValueRef](lltydescs);
- if (Vec.len[@ast.expr](bound) == 0u && ty_param_count == 0u) {
+ if (_vec::len[@ast::expr](bound) == 0u && ty_param_count == 0u) {
// Trivial 'binding': just return the static pair-ptr.
ret f_res.res;
} else {
@@ -4671,39 +4679,39 @@ fn trans_bind(&@block_ctxt cx, &@ast.expr f,
auto pair_v = alloca(bcx, pair_t);
// Translate the bound expressions.
- let vec[ty.t] bound_tys = vec();
+ let vec[ty::t] bound_tys = vec();
let vec[ValueRef] bound_vals = vec();
auto i = 0u;
- for (@ast.expr e in bound) {
+ for (@ast::expr e in bound) {
auto arg = trans_expr(bcx, e);
bcx = arg.bcx;
- Vec.push[ValueRef](bound_vals, arg.val);
- Vec.push[ty.t](bound_tys,
- ty.expr_ty(cx.fcx.lcx.ccx.tcx, e));
+ _vec::push[ValueRef](bound_vals, arg.val);
+ _vec::push[ty::t](bound_tys,
+ ty::expr_ty(cx.fcx.lcx.ccx.tcx, e));
i += 1u;
}
// Synthesize a closure type.
- let ty.t bindings_ty = ty.mk_imm_tup(cx.fcx.lcx.ccx.tcx,
+ let ty::t bindings_ty = ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx,
bound_tys);
// NB: keep this in sync with T_closure_ptr; we're making
- // a ty.t structure that has the same "shape" as the LLVM type
+ // a ty::t structure that has the same "shape" as the LLVM type
// it constructs.
- let ty.t tydesc_ty = ty.mk_type(cx.fcx.lcx.ccx.tcx);
+ let ty::t tydesc_ty = ty::mk_type(cx.fcx.lcx.ccx.tcx);
- let vec[ty.t] captured_tys =
- Vec.init_elt[ty.t](tydesc_ty, ty_param_count);
+ let vec[ty::t] captured_tys =
+ _vec::init_elt[ty::t](tydesc_ty, ty_param_count);
- let vec[ty.t] closure_tys =
+ let vec[ty::t] closure_tys =
vec(tydesc_ty,
outgoing_fty,
bindings_ty,
- ty.mk_imm_tup(cx.fcx.lcx.ccx.tcx, captured_tys));
+ ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx, captured_tys));
- let ty.t closure_ty = ty.mk_imm_tup(cx.fcx.lcx.ccx.tcx,
+ let ty::t closure_ty = ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx,
closure_tys);
auto r = trans_malloc_boxed(bcx, closure_ty);
@@ -4711,18 +4719,18 @@ fn trans_bind(&@block_ctxt cx, &@ast.expr f,
bcx = r.bcx;
auto rc = bcx.build.GEP(box,
vec(C_int(0),
- C_int(abi.box_rc_field_refcnt)));
+ C_int(abi::box_rc_field_refcnt)));
auto closure =
bcx.build.GEP(box,
vec(C_int(0),
- C_int(abi.box_rc_field_body)));
+ C_int(abi::box_rc_field_body)));
bcx.build.Store(C_int(1), rc);
// Store bindings tydesc.
auto bound_tydesc =
bcx.build.GEP(closure,
vec(C_int(0),
- C_int(abi.closure_elt_tydesc)));
+ C_int(abi::closure_elt_tydesc)));
auto bindings_tydesc = get_tydesc(bcx, bindings_ty, true);
bcx = bindings_tydesc.bcx;
bcx.build.Store(bindings_tydesc.val, bound_tydesc);
@@ -4734,9 +4742,9 @@ fn trans_bind(&@block_ctxt cx, &@ast.expr f,
// function has, which type_of() doesn't, as only we know which
// item the function refers to.
auto llfnty = type_of_fn(bcx.fcx.lcx.ccx,
- ty.ty_fn_proto(bcx.fcx.lcx.ccx.tcx, outgoing_fty),
- ty.ty_fn_args(bcx.fcx.lcx.ccx.tcx, outgoing_fty),
- ty.ty_fn_ret(bcx.fcx.lcx.ccx.tcx, outgoing_fty),
+ ty::ty_fn_proto(bcx.fcx.lcx.ccx.tcx, outgoing_fty),
+ ty::ty_fn_args(bcx.fcx.lcx.ccx.tcx, outgoing_fty),
+ ty::ty_fn_ret(bcx.fcx.lcx.ccx.tcx, outgoing_fty),
ty_param_count);
auto llclosurety = T_ptr(T_fn_pair(bcx.fcx.lcx.ccx.tn, llfnty));
@@ -4744,7 +4752,7 @@ fn trans_bind(&@block_ctxt cx, &@ast.expr f,
auto bound_target =
bcx.build.GEP(closure,
vec(C_int(0),
- C_int(abi.closure_elt_target)));
+ C_int(abi::closure_elt_target)));
auto src = bcx.build.Load(f_res.res.val);
bound_target = bcx.build.PointerCast(bound_target, llclosurety);
bcx.build.Store(src, bound_target);
@@ -4754,7 +4762,7 @@ fn trans_bind(&@block_ctxt cx, &@ast.expr f,
auto bindings =
bcx.build.GEP(closure,
vec(C_int(0),
- C_int(abi.closure_elt_bindings)));
+ C_int(abi::closure_elt_bindings)));
for (ValueRef v in bound_vals) {
auto bound = bcx.build.GEP(bindings,
vec(C_int(0), C_int(i as int)));
@@ -4770,7 +4778,7 @@ fn trans_bind(&@block_ctxt cx, &@ast.expr f,
auto ty_params_slot =
bcx.build.GEP(closure,
vec(C_int(0),
- C_int(abi.closure_elt_ty_params)));
+ C_int(abi::closure_elt_ty_params)));
auto i = 0;
for (ValueRef td in ginfo.tydescs) {
auto ty_param_slot = bcx.build.GEP(ty_params_slot,
@@ -4787,9 +4795,9 @@ fn trans_bind(&@block_ctxt cx, &@ast.expr f,
// Make thunk and store thunk-ptr in outer pair's code slot.
auto pair_code = bcx.build.GEP(pair_v,
vec(C_int(0),
- C_int(abi.fn_field_code)));
+ C_int(abi::fn_field_code)));
- let ty.t pair_ty = node_ann_type(cx.fcx.lcx.ccx, ann);
+ let ty::t pair_ty = node_ann_type(cx.fcx.lcx.ccx, ann);
let ValueRef llthunk =
trans_bind_thunk(cx.fcx.lcx, pair_ty, outgoing_fty,
@@ -4801,7 +4809,7 @@ fn trans_bind(&@block_ctxt cx, &@ast.expr f,
// Store box ptr in outer pair's box slot.
auto pair_box = bcx.build.GEP(pair_v,
vec(C_int(0),
- C_int(abi.fn_field_box)));
+ C_int(abi::fn_field_box)));
bcx.build.Store
(bcx.build.PointerCast
(box,
@@ -4817,21 +4825,21 @@ fn trans_bind(&@block_ctxt cx, &@ast.expr f,
}
fn trans_arg_expr(&@block_ctxt cx,
- &ty.arg arg,
+ &ty::arg arg,
TypeRef lldestty0,
- &@ast.expr e) -> result {
+ &@ast::expr e) -> result {
auto val;
auto bcx = cx;
- auto e_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, e);
+ auto e_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, e);
- if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, e_ty)) {
+ if (ty::type_is_structural(cx.fcx.lcx.ccx.tcx, e_ty)) {
auto re = trans_expr(bcx, e);
val = re.val;
bcx = re.bcx;
- } else if (arg.mode == ty.mo_alias) {
+ } else if (arg.mode == ty::mo_alias) {
let lval_result lv;
- if (ty.is_lval(e)) {
+ if (ty::is_lval(e)) {
lv = trans_lval(bcx, e);
} else {
auto r = trans_expr(bcx, e);
@@ -4856,24 +4864,24 @@ fn trans_arg_expr(&@block_ctxt cx,
bcx = re.bcx;
}
- if (arg.mode != ty.mo_alias) {
+ if (arg.mode != ty::mo_alias) {
bcx = take_ty(bcx, val, e_ty).bcx;
}
- if (ty.type_contains_params(cx.fcx.lcx.ccx.tcx, arg.ty)) {
+ if (ty::type_contains_params(cx.fcx.lcx.ccx.tcx, arg.ty)) {
auto lldestty = lldestty0;
- if (arg.mode == ty.mo_val) {
+ if (arg.mode == ty::mo_val) {
// FIXME: we'd prefer to use &&, but rustboot doesn't like it
- if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, e_ty)) {
+ if (ty::type_is_structural(cx.fcx.lcx.ccx.tcx, e_ty)) {
lldestty = T_ptr(lldestty);
}
}
val = bcx.build.PointerCast(val, lldestty);
}
- if (arg.mode == ty.mo_val) {
+ if (arg.mode == ty::mo_val) {
// FIXME: we'd prefer to use &&, but rustboot doesn't like it
- if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, e_ty)) {
+ if (ty::type_is_structural(cx.fcx.lcx.ccx.tcx, e_ty)) {
// Until here we've been treating structures by pointer;
// we are now passing it as an arg, so need to load it.
val = bcx.build.Load(val);
@@ -4891,21 +4899,21 @@ fn trans_arg_expr(&@block_ctxt cx,
fn trans_args(&@block_ctxt cx,
ValueRef llenv,
- &Option.t[ValueRef] llobj,
- &Option.t[generic_info] gen,
- &Option.t[ValueRef] lliterbody,
- &vec[@ast.expr] es,
- &ty.t fn_ty)
+ &option::t[ValueRef] llobj,
+ &option::t[generic_info] gen,
+ &option::t[ValueRef] lliterbody,
+ &vec[@ast::expr] es,
+ &ty::t fn_ty)
-> tup(@block_ctxt, vec[ValueRef], ValueRef) {
- let vec[ty.arg] args = ty.ty_fn_args(cx.fcx.lcx.ccx.tcx, fn_ty);
+ let vec[ty::arg] args = ty::ty_fn_args(cx.fcx.lcx.ccx.tcx, fn_ty);
let vec[ValueRef] llargs = vec();
let vec[ValueRef] lltydescs = vec();
let @block_ctxt bcx = cx;
// Arg 0: Output pointer.
- auto retty = ty.ty_fn_ret(cx.fcx.lcx.ccx.tcx, fn_ty);
+ auto retty = ty::ty_fn_ret(cx.fcx.lcx.ccx.tcx, fn_ty);
auto llretslot_res = alloc_ty(bcx, retty);
bcx = llretslot_res.bcx;
auto llretslot = llretslot_res.val;
@@ -4913,16 +4921,16 @@ fn trans_args(&@block_ctxt cx,
alt (gen) {
case (some[generic_info](?g)) {
lltydescs = g.tydescs;
- args = ty.ty_fn_args(cx.fcx.lcx.ccx.tcx, g.item_type);
- retty = ty.ty_fn_ret(cx.fcx.lcx.ccx.tcx, g.item_type);
+ args = ty::ty_fn_args(cx.fcx.lcx.ccx.tcx, g.item_type);
+ retty = ty::ty_fn_ret(cx.fcx.lcx.ccx.tcx, g.item_type);
}
case (_) {
}
}
- if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, retty)) {
+ if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, retty)) {
llargs += vec(bcx.build.PointerCast
(llretslot, T_typaram_ptr(cx.fcx.lcx.ccx.tn)));
- } else if (ty.type_contains_params(cx.fcx.lcx.ccx.tcx, retty)) {
+ } else if (ty::type_contains_params(cx.fcx.lcx.ccx.tcx, retty)) {
// It's possible that the callee has some generic-ness somewhere in
// its return value -- say a method signature within an obj or a fn
// type deep in a structure -- which the caller has a concrete view
@@ -4936,7 +4944,7 @@ fn trans_args(&@block_ctxt cx,
}
- // Arg 1: Task pointer.
+ // Arg 1: task pointer.
llargs += vec(bcx.fcx.lltaskptr);
// Arg 2: Env (closure-bindings / self-obj)
@@ -4971,7 +4979,7 @@ fn trans_args(&@block_ctxt cx,
auto arg_tys = type_of_explicit_args(cx.fcx.lcx.ccx, args);
auto i = 0u;
- for (@ast.expr e in es) {
+ for (@ast::expr e in es) {
auto r = trans_arg_expr(bcx, args.(i), arg_tys.(i), e);
bcx = r.bcx;
llargs += vec(r.val);
@@ -4981,10 +4989,10 @@ fn trans_args(&@block_ctxt cx,
ret tup(bcx, llargs, llretslot);
}
-fn trans_call(&@block_ctxt cx, &@ast.expr f,
- &Option.t[ValueRef] lliterbody,
- &vec[@ast.expr] args,
- &ast.ann ann) -> result {
+fn trans_call(&@block_ctxt cx, &@ast::expr f,
+ &option::t[ValueRef] lliterbody,
+ &vec[@ast::expr] args,
+ &ast::ann ann) -> result {
// NB: 'f' isn't necessarily a function; it might be an entire self-call
// expression because of the hack that allows us to process self-calls
@@ -5004,31 +5012,31 @@ fn trans_call(&@block_ctxt cx, &@ast.expr f,
auto bcx = f_res.res.bcx;
auto pair = faddr;
faddr = bcx.build.GEP(pair, vec(C_int(0),
- C_int(abi.fn_field_code)));
+ C_int(abi::fn_field_code)));
faddr = bcx.build.Load(faddr);
auto llclosure = bcx.build.GEP(pair,
vec(C_int(0),
- C_int(abi.fn_field_box)));
+ C_int(abi::fn_field_box)));
llenv = bcx.build.Load(llclosure);
}
}
- let ty.t fn_ty;
+ let ty::t fn_ty;
alt (f_res.method_ty) {
- case (some[ty.t](?meth)) {
+ case (some[ty::t](?meth)) {
// self-call
fn_ty = meth;
}
case (_) {
- fn_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, f);
+ fn_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, f);
}
}
- auto ret_ty = ty.ann_to_type(ann);
+ auto ret_ty = ty::ann_to_type(ann);
auto args_res = trans_args(f_res.res.bcx,
llenv, f_res.llobj,
f_res.generic,
@@ -5052,7 +5060,7 @@ fn trans_call(&@block_ctxt cx, &@ast.expr f,
alt (lliterbody) {
case (none[ValueRef]) {
- if (!ty.type_is_nil(cx.fcx.lcx.ccx.tcx, ret_ty)) {
+ if (!ty::type_is_nil(cx.fcx.lcx.ccx.tcx, ret_ty)) {
retval = load_if_immediate(bcx, llretslot, ret_ty);
// Retval doesn't correspond to anything really tangible in
// the frame, but it's a ref all the same, so we put a note
@@ -5070,8 +5078,8 @@ fn trans_call(&@block_ctxt cx, &@ast.expr f,
ret res(bcx, retval);
}
-fn trans_tup(&@block_ctxt cx, &vec[ast.elt] elts,
- &ast.ann ann) -> result {
+fn trans_tup(&@block_ctxt cx, &vec[ast::elt] elts,
+ &ast::ann ann) -> result {
auto bcx = cx;
auto t = node_ann_type(bcx.fcx.lcx.ccx, ann);
auto tup_res = alloc_ty(bcx, t);
@@ -5082,8 +5090,8 @@ fn trans_tup(&@block_ctxt cx, &vec[ast.elt] elts,
vec(clean(bind drop_ty(_, tup_val, t)));
let int i = 0;
- for (ast.elt e in elts) {
- auto e_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, e.expr);
+ for (ast::elt e in elts) {
+ auto e_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, e.expr);
auto src_res = trans_expr(bcx, e.expr);
bcx = src_res.bcx;
auto dst_res = GEP_tup_like(bcx, t, tup_val, vec(0, i));
@@ -5094,12 +5102,12 @@ fn trans_tup(&@block_ctxt cx, &vec[ast.elt] elts,
ret res(bcx, tup_val);
}
-fn trans_vec(&@block_ctxt cx, &vec[@ast.expr] args,
- &ast.ann ann) -> result {
+fn trans_vec(&@block_ctxt cx, &vec[@ast::expr] args,
+ &ast::ann ann) -> result {
auto t = node_ann_type(cx.fcx.lcx.ccx, ann);
auto unit_ty = t;
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
- case (ty.ty_vec(?mt)) {
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
+ case (ty::ty_vec(?mt)) {
unit_ty = mt.ty;
}
case (_) {
@@ -5110,7 +5118,7 @@ fn trans_vec(&@block_ctxt cx, &vec[@ast.expr] args,
auto bcx = cx;
auto unit_sz = size_of(bcx, unit_ty);
bcx = unit_sz.bcx;
- auto data_sz = bcx.build.Mul(C_int(Vec.len[@ast.expr](args) as int),
+ auto data_sz = bcx.build.Mul(C_int(_vec::len[@ast::expr](args) as int),
unit_sz.val);
// FIXME: pass tydesc properly.
@@ -5124,15 +5132,15 @@ fn trans_vec(&@block_ctxt cx, &vec[@ast.expr] args,
vec(clean(bind drop_ty(_, vec_val, t)));
auto body = bcx.build.GEP(vec_val, vec(C_int(0),
- C_int(abi.vec_elt_data)));
+ C_int(abi::vec_elt_data)));
auto pseudo_tup_ty =
- ty.mk_imm_tup(cx.fcx.lcx.ccx.tcx,
- Vec.init_elt[ty.t](unit_ty,
- Vec.len[@ast.expr](args)));
+ ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx,
+ _vec::init_elt[ty::t](unit_ty,
+ _vec::len[@ast::expr](args)));
let int i = 0;
- for (@ast.expr e in args) {
+ for (@ast::expr e in args) {
auto src_res = trans_expr(bcx, e);
bcx = src_res.bcx;
auto dst_res = GEP_tup_like(bcx, pseudo_tup_ty, body, vec(0, i));
@@ -5151,7 +5159,7 @@ fn trans_vec(&@block_ctxt cx, &vec[@ast.expr] args,
// (5) "src_res" is derived from "unit_ty", which is not behind a box.
auto dst_val;
- if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, unit_ty)) {
+ if (!ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, unit_ty)) {
auto llunit_ty = type_of(cx.fcx.lcx.ccx, unit_ty);
dst_val = bcx.build.PointerCast(dst_res.val, T_ptr(llunit_ty));
} else {
@@ -5162,14 +5170,14 @@ fn trans_vec(&@block_ctxt cx, &vec[@ast.expr] args,
i += 1;
}
auto fill = bcx.build.GEP(vec_val,
- vec(C_int(0), C_int(abi.vec_elt_fill)));
+ vec(C_int(0), C_int(abi::vec_elt_fill)));
bcx.build.Store(data_sz, fill);
ret res(bcx, vec_val);
}
-fn trans_rec(&@block_ctxt cx, &vec[ast.field] fields,
- &Option.t[@ast.expr] base, &ast.ann ann) -> result {
+fn trans_rec(&@block_ctxt cx, &vec[ast::field] fields,
+ &option::t[@ast::expr] base, &ast::ann ann) -> result {
auto bcx = cx;
auto t = node_ann_type(bcx.fcx.lcx.ccx, ann);
@@ -5184,20 +5192,20 @@ fn trans_rec(&@block_ctxt cx, &vec[ast.field] fields,
auto base_val = C_nil();
alt (base) {
- case (none[@ast.expr]) { }
- case (some[@ast.expr](?bexp)) {
+ case (none[@ast::expr]) { }
+ case (some[@ast::expr](?bexp)) {
auto base_res = trans_expr(bcx, bexp);
bcx = base_res.bcx;
base_val = base_res.val;
}
}
- let vec[ty.field] ty_fields = vec();
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
- case (ty.ty_rec(?flds)) { ty_fields = flds; }
+ let vec[ty::field] ty_fields = vec();
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
+ case (ty::ty_rec(?flds)) { ty_fields = flds; }
}
- for (ty.field tf in ty_fields) {
+ for (ty::field tf in ty_fields) {
auto e_ty = tf.mt.ty;
auto dst_res = GEP_tup_like(bcx, t, rec_val, vec(0, i));
bcx = dst_res.bcx;
@@ -5205,8 +5213,8 @@ fn trans_rec(&@block_ctxt cx, &vec[ast.field] fields,
auto expr_provided = false;
auto src_res = res(bcx, C_nil());
- for (ast.field f in fields) {
- if (Str.eq(f.ident, tf.ident)) {
+ for (ast::field f in fields) {
+ if (_str::eq(f.ident, tf.ident)) {
expr_provided = true;
src_res = trans_expr(bcx, f.expr);
}
@@ -5226,47 +5234,47 @@ fn trans_rec(&@block_ctxt cx, &vec[ast.field] fields,
-fn trans_expr(&@block_ctxt cx, &@ast.expr e) -> result {
+fn trans_expr(&@block_ctxt cx, &@ast::expr e) -> result {
alt (e.node) {
- case (ast.expr_lit(?lit, ?ann)) {
+ case (ast::expr_lit(?lit, ?ann)) {
ret res(cx, trans_lit(cx.fcx.lcx.ccx, *lit, ann));
}
- case (ast.expr_unary(?op, ?x, ?ann)) {
- if (op != ast.deref) {
+ case (ast::expr_unary(?op, ?x, ?ann)) {
+ if (op != ast::deref) {
ret trans_unary(cx, op, x, ann);
}
}
- case (ast.expr_binary(?op, ?x, ?y, _)) {
+ case (ast::expr_binary(?op, ?x, ?y, _)) {
ret trans_binary(cx, op, x, y);
}
- case (ast.expr_if(?cond, ?thn, ?els, _)) {
+ case (ast::expr_if(?cond, ?thn, ?els, _)) {
ret trans_if(cx, cond, thn, els);
}
- case (ast.expr_for(?decl, ?seq, ?body, _)) {
+ case (ast::expr_for(?decl, ?seq, ?body, _)) {
ret trans_for(cx, decl, seq, body);
}
- case (ast.expr_for_each(?decl, ?seq, ?body, _)) {
+ case (ast::expr_for_each(?decl, ?seq, ?body, _)) {
ret trans_for_each(cx, decl, seq, body);
}
- case (ast.expr_while(?cond, ?body, _)) {
+ case (ast::expr_while(?cond, ?body, _)) {
ret trans_while(cx, cond, body);
}
- case (ast.expr_do_while(?body, ?cond, _)) {
+ case (ast::expr_do_while(?body, ?cond, _)) {
ret trans_do_while(cx, body, cond);
}
- case (ast.expr_alt(?expr, ?arms, ?ann)) {
+ case (ast::expr_alt(?expr, ?arms, ?ann)) {
ret trans_alt(cx, expr, arms, ann);
}
- case (ast.expr_block(?blk, _)) {
+ case (ast::expr_block(?blk, _)) {
auto sub_cx = new_scope_block_ctxt(cx, "block-expr body");
auto next_cx = new_sub_block_ctxt(cx, "next");
auto sub = trans_block(sub_cx, blk);
@@ -5277,7 +5285,7 @@ fn trans_expr(&@block_ctxt cx, &@ast.expr e) -> result {
ret res(next_cx, sub.val);
}
- case (ast.expr_assign(?dst, ?src, ?ann)) {
+ case (ast::expr_assign(?dst, ?src, ?ann)) {
auto lhs_res = trans_lval(cx, dst);
assert (lhs_res.is_mem);
auto rhs_res = trans_expr(lhs_res.res.bcx, src);
@@ -5287,14 +5295,14 @@ fn trans_expr(&@block_ctxt cx, &@ast.expr e) -> result {
lhs_res.res.val, rhs_res.val, t);
}
- case (ast.expr_assign_op(?op, ?dst, ?src, ?ann)) {
+ case (ast::expr_assign_op(?op, ?dst, ?src, ?ann)) {
auto t = node_ann_type(cx.fcx.lcx.ccx, ann);
auto lhs_res = trans_lval(cx, dst);
assert (lhs_res.is_mem);
auto rhs_res = trans_expr(lhs_res.res.bcx, src);
- if (ty.type_is_sequence(cx.fcx.lcx.ccx.tcx, t)) {
+ if (ty::type_is_sequence(cx.fcx.lcx.ccx.tcx, t)) {
alt (op) {
- case (ast.add) {
+ case (ast::add) {
ret trans_vec_append(rhs_res.bcx, t,
lhs_res.res.val,
rhs_res.val);
@@ -5311,83 +5319,83 @@ fn trans_expr(&@block_ctxt cx, &@ast.expr e) -> result {
lhs_res.res.val, v.val, t);
}
- case (ast.expr_bind(?f, ?args, ?ann)) {
+ case (ast::expr_bind(?f, ?args, ?ann)) {
ret trans_bind(cx, f, args, ann);
}
- case (ast.expr_call(?f, ?args, ?ann)) {
+ case (ast::expr_call(?f, ?args, ?ann)) {
ret trans_call(cx, f, none[ValueRef], args, ann);
}
- case (ast.expr_cast(?e, _, ?ann)) {
+ case (ast::expr_cast(?e, _, ?ann)) {
ret trans_cast(cx, e, ann);
}
- case (ast.expr_vec(?args, _, ?ann)) {
+ case (ast::expr_vec(?args, _, ?ann)) {
ret trans_vec(cx, args, ann);
}
- case (ast.expr_tup(?args, ?ann)) {
+ case (ast::expr_tup(?args, ?ann)) {
ret trans_tup(cx, args, ann);
}
- case (ast.expr_rec(?args, ?base, ?ann)) {
+ case (ast::expr_rec(?args, ?base, ?ann)) {
ret trans_rec(cx, args, base, ann);
}
- case (ast.expr_ext(_, _, _, ?expanded, _)) {
+ case (ast::expr_ext(_, _, _, ?expanded, _)) {
ret trans_expr(cx, expanded);
}
- case (ast.expr_fail(_)) {
- ret trans_fail(cx, some[common.span](e.span), "explicit failure");
+ case (ast::expr_fail(_)) {
+ ret trans_fail(cx, some(e.span), "explicit failure");
}
- case (ast.expr_log(?lvl, ?a, _)) {
+ case (ast::expr_log(?lvl, ?a, _)) {
ret trans_log(lvl, cx, a);
}
- case (ast.expr_assert(?a, _)) {
+ case (ast::expr_assert(?a, _)) {
ret trans_check_expr(cx, a);
}
- case (ast.expr_check(?a, _)) {
+ case (ast::expr_check(?a, _)) {
ret trans_check_expr(cx, a);
}
- case (ast.expr_break(?a)) {
+ case (ast::expr_break(?a)) {
ret trans_break(cx);
}
- case (ast.expr_cont(?a)) {
+ case (ast::expr_cont(?a)) {
ret trans_cont(cx);
}
- case (ast.expr_ret(?e, _)) {
+ case (ast::expr_ret(?e, _)) {
ret trans_ret(cx, e);
}
- case (ast.expr_put(?e, _)) {
+ case (ast::expr_put(?e, _)) {
ret trans_put(cx, e);
}
- case (ast.expr_be(?e, _)) {
+ case (ast::expr_be(?e, _)) {
ret trans_be(cx, e);
}
- case (ast.expr_port(?ann)) {
+ case (ast::expr_port(?ann)) {
ret trans_port(cx, ann);
}
- case (ast.expr_chan(?e, ?ann)) {
+ case (ast::expr_chan(?e, ?ann)) {
ret trans_chan(cx, e, ann);
}
- case (ast.expr_send(?lhs, ?rhs, ?ann)) {
+ case (ast::expr_send(?lhs, ?rhs, ?ann)) {
ret trans_send(cx, lhs, rhs, ann);
}
- case (ast.expr_recv(?lhs, ?rhs, ?ann)) {
+ case (ast::expr_recv(?lhs, ?rhs, ?ann)) {
ret trans_recv(cx, lhs, rhs, ann);
}
@@ -5399,7 +5407,7 @@ fn trans_expr(&@block_ctxt cx, &@ast.expr e) -> result {
// lval cases fall through to trans_lval and then
// possibly load the result (if it's non-structural).
- auto t = ty.expr_ty(cx.fcx.lcx.ccx.tcx, e);
+ auto t = ty::expr_ty(cx.fcx.lcx.ccx.tcx, e);
auto sub = trans_lval(cx, e);
ret res(sub.res.bcx, load_if_immediate(sub.res.bcx, sub.res.val, t));
}
@@ -5410,10 +5418,10 @@ fn trans_expr(&@block_ctxt cx, &@ast.expr e) -> result {
// pointer (or need one), perform load/store operations based on the
// immediate-ness of the type.
-fn type_is_immediate(&@crate_ctxt ccx, &ty.t t) -> bool {
- ret ty.type_is_scalar(ccx.tcx, t) ||
- ty.type_is_boxed(ccx.tcx, t) ||
- ty.type_is_native(ccx.tcx, t);
+fn type_is_immediate(&@crate_ctxt ccx, &ty::t t) -> bool {
+ ret ty::type_is_scalar(ccx.tcx, t) ||
+ ty::type_is_boxed(ccx.tcx, t) ||
+ ty::type_is_native(ccx.tcx, t);
}
fn do_spill(&@block_ctxt cx, ValueRef v) -> ValueRef {
@@ -5423,55 +5431,55 @@ fn do_spill(&@block_ctxt cx, ValueRef v) -> ValueRef {
ret llptr;
}
-fn spill_if_immediate(&@block_ctxt cx, ValueRef v, &ty.t t) -> ValueRef {
+fn spill_if_immediate(&@block_ctxt cx, ValueRef v, &ty::t t) -> ValueRef {
if (type_is_immediate(cx.fcx.lcx.ccx, t)) {
ret do_spill(cx, v);
}
ret v;
}
-fn load_if_immediate(&@block_ctxt cx, ValueRef v, &ty.t t) -> ValueRef {
+fn load_if_immediate(&@block_ctxt cx, ValueRef v, &ty::t t) -> ValueRef {
if (type_is_immediate(cx.fcx.lcx.ccx, t)) {
ret cx.build.Load(v);
}
ret v;
}
-fn trans_log(int lvl, &@block_ctxt cx, &@ast.expr e) -> result {
+fn trans_log(int lvl, &@block_ctxt cx, &@ast::expr e) -> result {
auto lcx = cx.fcx.lcx;
- auto modname = Str.connect(lcx.module_path, "::");
+ auto modname = _str::connect(lcx.module_path, "::");
auto global;
if (lcx.ccx.module_data.contains_key(modname)) {
global = lcx.ccx.module_data.get(modname);
} else {
- global = llvm.LLVMAddGlobal(lcx.ccx.llmod, T_int(),
- Str.buf("_rust_mod_log_" + modname));
- llvm.LLVMSetGlobalConstant(global, False);
- llvm.LLVMSetInitializer(global, C_null(T_int()));
- llvm.LLVMSetLinkage(global, lib.llvm.LLVMInternalLinkage
- as llvm.Linkage);
+ global = llvm::LLVMAddGlobal(lcx.ccx.llmod, T_int(),
+ _str::buf("_rust_mod_log_" + modname));
+ llvm::LLVMSetGlobalConstant(global, False);
+ llvm::LLVMSetInitializer(global, C_null(T_int()));
+ llvm::LLVMSetLinkage(global, lib::llvm::LLVMInternalLinkage
+ as llvm::Linkage);
lcx.ccx.module_data.insert(modname, global);
}
auto log_cx = new_scope_block_ctxt(cx, "log");
auto after_cx = new_sub_block_ctxt(cx, "after");
auto load = cx.build.Load(global);
- auto test = cx.build.ICmp(lib.llvm.LLVMIntSGE, load, C_int(lvl));
+ auto test = cx.build.ICmp(lib::llvm::LLVMIntSGE, load, C_int(lvl));
cx.build.CondBr(test, log_cx.llbb, after_cx.llbb);
auto sub = trans_expr(log_cx, e);
- auto e_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, e);
+ auto e_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, e);
auto log_bcx = sub.bcx;
- if (ty.type_is_fp(cx.fcx.lcx.ccx.tcx, e_ty)) {
+ if (ty::type_is_fp(cx.fcx.lcx.ccx.tcx, e_ty)) {
let TypeRef tr;
let bool is32bit = false;
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, e_ty)) {
- case (ty.ty_machine(util.common.ty_f32)) {
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, e_ty)) {
+ case (ty::ty_machine(util::common::ty_f32)) {
tr = T_f32();
is32bit = true;
}
- case (ty.ty_machine(util.common.ty_f64)) {
+ case (ty::ty_machine(util::common::ty_f64)) {
tr = T_f64();
}
case (_) {
@@ -5490,8 +5498,8 @@ fn trans_log(int lvl, &@block_ctxt cx, &@ast.expr e) -> result {
vec(log_bcx.fcx.lltaskptr, C_int(lvl), tmp));
}
} else {
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, e_ty)) {
- case (ty.ty_str) {
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, e_ty)) {
+ case (ty::ty_str) {
log_bcx.build.Call(log_bcx.fcx.lcx.ccx.upcalls.log_str,
vec(log_bcx.fcx.lltaskptr, C_int(lvl),
sub.val));
@@ -5513,12 +5521,12 @@ fn trans_log(int lvl, &@block_ctxt cx, &@ast.expr e) -> result {
ret res(after_cx, C_nil());
}
-fn trans_check_expr(&@block_ctxt cx, &@ast.expr e) -> result {
+fn trans_check_expr(&@block_ctxt cx, &@ast::expr e) -> result {
auto cond_res = trans_expr(cx, e);
- auto expr_str = util.common.expr_to_str(e);
+ auto expr_str = util::common::expr_to_str(e);
auto fail_cx = new_sub_block_ctxt(cx, "fail");
- auto fail_res = trans_fail(fail_cx, some[common.span](e.span), expr_str);
+ auto fail_res = trans_fail(fail_cx, some[common::span](e.span), expr_str);
auto next_cx = new_sub_block_ctxt(cx, "next");
cond_res.bcx.build.CondBr(cond_res.val,
@@ -5527,18 +5535,18 @@ fn trans_check_expr(&@block_ctxt cx, &@ast.expr e) -> result {
ret res(next_cx, C_nil());
}
-fn trans_fail(&@block_ctxt cx, &Option.t[common.span] sp_opt, &str fail_str)
+fn trans_fail(&@block_ctxt cx, &option::t[common::span] sp_opt, &str fail_str)
-> result {
auto V_fail_str = C_cstr(cx.fcx.lcx.ccx, fail_str);
auto V_filename; auto V_line;
alt (sp_opt) {
- case (some[common.span](?sp)) {
+ case (some[common::span](?sp)) {
auto loc = cx.fcx.lcx.ccx.sess.lookup_pos(sp.lo);
V_filename = C_cstr(cx.fcx.lcx.ccx, loc.filename);
V_line = loc.line as int;
}
- case (none[common.span]) {
+ case (none[common::span]) {
V_filename = C_cstr(cx.fcx.lcx.ccx, "<runtime>");
V_line = 0;
}
@@ -5554,7 +5562,7 @@ fn trans_fail(&@block_ctxt cx, &Option.t[common.span] sp_opt, &str fail_str)
ret res(cx, C_nil());
}
-fn trans_put(&@block_ctxt cx, &Option.t[@ast.expr] e) -> result {
+fn trans_put(&@block_ctxt cx, &option::t[@ast::expr] e) -> result {
auto llcallee = C_nil();
auto llenv = C_nil();
@@ -5564,11 +5572,11 @@ fn trans_put(&@block_ctxt cx, &Option.t[@ast.expr] e) -> result {
cx.build.Store(lli, slot);
llcallee = cx.build.GEP(slot, vec(C_int(0),
- C_int(abi.fn_field_code)));
+ C_int(abi::fn_field_code)));
llcallee = cx.build.Load(llcallee);
llenv = cx.build.GEP(slot, vec(C_int(0),
- C_int(abi.fn_field_box)));
+ C_int(abi::fn_field_box)));
llenv = cx.build.Load(llenv);
}
}
@@ -5576,10 +5584,10 @@ fn trans_put(&@block_ctxt cx, &Option.t[@ast.expr] e) -> result {
auto dummy_retslot = alloca(bcx, T_nil());
let vec[ValueRef] llargs = vec(dummy_retslot, cx.fcx.lltaskptr, llenv);
alt (e) {
- case (none[@ast.expr]) { }
- case (some[@ast.expr](?x)) {
- auto e_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, x);
- auto arg = rec(mode=ty.mo_alias, ty=e_ty);
+ case (none[@ast::expr]) { }
+ case (some[@ast::expr](?x)) {
+ auto e_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, x);
+ auto arg = rec(mode=ty::mo_alias, ty=e_ty);
auto arg_tys = type_of_explicit_args(cx.fcx.lcx.ccx, vec(arg));
auto r = trans_arg_expr(bcx, arg, arg_tys.(0), x);
bcx = r.bcx;
@@ -5602,7 +5610,7 @@ fn trans_break_cont(&@block_ctxt cx, bool to_end) -> result {
bcx.build.Br(_break.llbb);
} else {
alt (_cont) {
- case (Option.some[@block_ctxt](?_cont)) {
+ case (option::some[@block_ctxt](?_cont)) {
bcx.build.Br(_cont.llbb);
}
case (_) {
@@ -5632,26 +5640,26 @@ fn trans_cont(&@block_ctxt cx) -> result {
}
-fn trans_ret(&@block_ctxt cx, &Option.t[@ast.expr] e) -> result {
+fn trans_ret(&@block_ctxt cx, &option::t[@ast::expr] e) -> result {
auto bcx = cx;
auto val = C_nil();
alt (e) {
- case (some[@ast.expr](?x)) {
- auto t = ty.expr_ty(cx.fcx.lcx.ccx.tcx, x);
+ case (some[@ast::expr](?x)) {
+ auto t = ty::expr_ty(cx.fcx.lcx.ccx.tcx, x);
auto r = trans_expr(cx, x);
bcx = r.bcx;
val = r.val;
bcx = copy_ty(bcx, INIT, cx.fcx.llretptr, val, t).bcx;
}
case (_) {
- auto t = llvm.LLVMGetElementType(val_ty(cx.fcx.llretptr));
- auto null = lib.llvm.llvm.LLVMConstNull(t);
+ auto t = llvm::LLVMGetElementType(val_ty(cx.fcx.llretptr));
+ auto null = lib::llvm::llvm::LLVMConstNull(t);
bcx.build.Store(null, cx.fcx.llretptr);
}
}
- // Run all cleanups and back out.
+ // run all cleanups and back out.
let bool more_cleanups = true;
auto cleanup_cx = cx;
while (more_cleanups) {
@@ -5670,20 +5678,20 @@ fn trans_ret(&@block_ctxt cx, &Option.t[@ast.expr] e) -> result {
ret res(new_sub_block_ctxt(bcx, "ret.unreachable"), C_nil());
}
-fn trans_be(&@block_ctxt cx, &@ast.expr e) -> result {
+fn trans_be(&@block_ctxt cx, &@ast::expr e) -> result {
// FIXME: This should be a typestate precondition
- assert (ast.is_call_expr(e));
+ assert (ast::is_call_expr(e));
// FIXME: Turn this into a real tail call once
// calling convention issues are settled
ret trans_ret(cx, some(e));
}
-fn trans_port(&@block_ctxt cx, &ast.ann ann) -> result {
+fn trans_port(&@block_ctxt cx, &ast::ann ann) -> result {
auto t = node_ann_type(cx.fcx.lcx.ccx, ann);
auto unit_ty;
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
- case (ty.ty_port(?t)) {
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
+ case (ty::ty_port(?t)) {
unit_ty = t;
}
case (_) {
@@ -5707,7 +5715,7 @@ fn trans_port(&@block_ctxt cx, &ast.ann ann) -> result {
ret res(bcx, port_val);
}
-fn trans_chan(&@block_ctxt cx, &@ast.expr e, &ast.ann ann) -> result {
+fn trans_chan(&@block_ctxt cx, &@ast::expr e, &ast::ann ann) -> result {
auto bcx = cx;
auto prt = trans_expr(bcx, e);
@@ -5726,8 +5734,8 @@ fn trans_chan(&@block_ctxt cx, &@ast.expr e, &ast.ann ann) -> result {
ret res(bcx, chan_val);
}
-fn trans_send(&@block_ctxt cx, &@ast.expr lhs, &@ast.expr rhs,
- &ast.ann ann) -> result {
+fn trans_send(&@block_ctxt cx, &@ast::expr lhs, &@ast::expr rhs,
+ &ast::ann ann) -> result {
auto bcx = cx;
auto chn = trans_expr(bcx, lhs);
@@ -5737,8 +5745,8 @@ fn trans_send(&@block_ctxt cx, &@ast.expr lhs, &@ast.expr rhs,
auto chan_ty = node_ann_type(cx.fcx.lcx.ccx, ann);
auto unit_ty;
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, chan_ty)) {
- case (ty.ty_chan(?t)) {
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, chan_ty)) {
+ case (ty::ty_chan(?t)) {
unit_ty = t;
}
case (_) {
@@ -5763,8 +5771,8 @@ fn trans_send(&@block_ctxt cx, &@ast.expr lhs, &@ast.expr rhs,
ret res(bcx, chn.val);
}
-fn trans_recv(&@block_ctxt cx, &@ast.expr lhs, &@ast.expr rhs,
- &ast.ann ann) -> result {
+fn trans_recv(&@block_ctxt cx, &@ast::expr lhs, &@ast::expr rhs,
+ &ast::ann ann) -> result {
auto bcx = cx;
auto data = trans_lval(bcx, lhs);
@@ -5776,8 +5784,8 @@ fn trans_recv(&@block_ctxt cx, &@ast.expr lhs, &@ast.expr rhs,
ret recv_val(bcx, data.res.val, rhs, unit_ty, DROP_EXISTING);
}
-fn recv_val(&@block_ctxt cx, ValueRef lhs, &@ast.expr rhs,
- &ty.t unit_ty, copy_action action) -> result {
+fn recv_val(&@block_ctxt cx, ValueRef lhs, &@ast::expr rhs,
+ &ty::t unit_ty, copy_action action) -> result {
auto bcx = cx;
auto prt = trans_expr(bcx, rhs);
@@ -5797,7 +5805,7 @@ fn recv_val(&@block_ctxt cx, ValueRef lhs, &@ast.expr rhs,
ret res(bcx, lhs);
}
-fn init_local(&@block_ctxt cx, &@ast.local local) -> result {
+fn init_local(&@block_ctxt cx, &@ast::local local) -> result {
// Make a note to drop this slot on the way out.
assert (cx.fcx.lllocals.contains_key(local.id));
@@ -5809,13 +5817,13 @@ fn init_local(&@block_ctxt cx, &@ast.local local) -> result {
vec(clean(bind drop_slot(_, llptr, ty)));
alt (local.init) {
- case (some[ast.initializer](?init)) {
+ case (some[ast::initializer](?init)) {
alt (init.op) {
- case (ast.init_assign) {
+ case (ast::init_assign) {
auto sub = trans_expr(bcx, init.expr);
bcx = copy_ty(sub.bcx, INIT, llptr, sub.val, ty).bcx;
}
- case (ast.init_recv) {
+ case (ast::init_recv) {
bcx = recv_val(bcx, llptr, init.expr, ty, INIT).bcx;
}
}
@@ -5827,34 +5835,34 @@ fn init_local(&@block_ctxt cx, &@ast.local local) -> result {
ret res(bcx, llptr);
}
-fn zero_alloca(&@block_ctxt cx, ValueRef llptr, ty.t t) -> result {
+fn zero_alloca(&@block_ctxt cx, ValueRef llptr, ty::t t) -> result {
auto bcx = cx;
- if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
+ if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
auto llsz = size_of(bcx, t);
auto llalign = align_of(llsz.bcx, t);
bcx = call_bzero(llalign.bcx, llptr,
llsz.val, llalign.val).bcx;
} else {
auto llty = type_of(bcx.fcx.lcx.ccx, t);
- auto null = lib.llvm.llvm.LLVMConstNull(llty);
+ auto null = lib::llvm::llvm::LLVMConstNull(llty);
bcx.build.Store(null, llptr);
}
ret res(bcx, llptr);
}
-fn trans_stmt(&@block_ctxt cx, &ast.stmt s) -> result {
+fn trans_stmt(&@block_ctxt cx, &ast::stmt s) -> result {
auto bcx = cx;
alt (s.node) {
- case (ast.stmt_expr(?e,_)) {
+ case (ast::stmt_expr(?e,_)) {
bcx = trans_expr(cx, e).bcx;
}
- case (ast.stmt_decl(?d,_)) {
+ case (ast::stmt_decl(?d,_)) {
alt (d.node) {
- case (ast.decl_local(?local)) {
+ case (ast::decl_local(?local)) {
bcx = init_local(bcx, local).bcx;
}
- case (ast.decl_item(?i)) {
+ case (ast::decl_item(?i)) {
trans_item(cx.fcx.lcx, *i);
}
}
@@ -5867,8 +5875,8 @@ fn trans_stmt(&@block_ctxt cx, &ast.stmt s) -> result {
}
fn new_builder(BasicBlockRef llbb) -> builder {
- let BuilderRef llbuild = llvm.LLVMCreateBuilder();
- llvm.LLVMPositionBuilderAtEnd(llbuild, llbb);
+ let BuilderRef llbuild = llvm::LLVMCreateBuilder();
+ llvm::LLVMPositionBuilderAtEnd(llbuild, llbb);
ret builder(llbuild, @mutable false);
}
@@ -5878,11 +5886,11 @@ fn new_block_ctxt(&@fn_ctxt cx, &block_parent parent,
block_kind kind,
&str name) -> @block_ctxt {
let vec[cleanup] cleanups = vec();
- auto s = Str.buf("");
+ auto s = _str::buf("");
if (cx.lcx.ccx.sess.get_opts().save_temps) {
- s = Str.buf(cx.lcx.ccx.names.next(name));
+ s = _str::buf(cx.lcx.ccx.names.next(name));
}
- let BasicBlockRef llbb = llvm.LLVMAppendBasicBlock(cx.llfn, s);
+ let BasicBlockRef llbb = llvm::LLVMAppendBasicBlock(cx.llfn, s);
ret @rec(llbb=llbb,
build=new_builder(llbb),
parent=parent,
@@ -5902,7 +5910,7 @@ fn new_scope_block_ctxt(&@block_ctxt bcx, &str n) -> @block_ctxt {
ret new_block_ctxt(bcx.fcx, parent_some(bcx), SCOPE_BLOCK, n);
}
-fn new_loop_scope_block_ctxt(&@block_ctxt bcx, &Option.t[@block_ctxt] _cont,
+fn new_loop_scope_block_ctxt(&@block_ctxt bcx, &option::t[@block_ctxt] _cont,
&@block_ctxt _break, &str n) -> @block_ctxt {
ret new_block_ctxt(bcx.fcx, parent_some(bcx),
LOOP_SCOPE_BLOCK(_cont, _break), n);
@@ -5925,10 +5933,10 @@ fn trans_block_cleanups(&@block_ctxt cx,
auto bcx = cx;
if (cleanup_cx.kind == NON_SCOPE_BLOCK) {
- assert (Vec.len[cleanup](cleanup_cx.cleanups) == 0u);
+ assert (_vec::len[cleanup](cleanup_cx.cleanups) == 0u);
}
- auto i = Vec.len[cleanup](cleanup_cx.cleanups);
+ auto i = _vec::len[cleanup](cleanup_cx.cleanups);
while (i > 0u) {
i -= 1u;
auto c = cleanup_cx.cleanups.(i);
@@ -5941,14 +5949,14 @@ fn trans_block_cleanups(&@block_ctxt cx,
ret bcx;
}
-iter block_locals(&ast.block b) -> @ast.local {
+iter block_locals(&ast::block b) -> @ast::local {
// FIXME: putting from inside an iter block doesn't work, so we can't
// use the index here.
- for (@ast.stmt s in b.node.stmts) {
+ for (@ast::stmt s in b.node.stmts) {
alt (s.node) {
- case (ast.stmt_decl(?d,_)) {
+ case (ast::stmt_decl(?d,_)) {
alt (d.node) {
- case (ast.decl_local(?local)) {
+ case (ast::decl_local(?local)) {
put local;
}
case (_) { /* fall through */ }
@@ -5969,9 +5977,9 @@ fn llallocas_block_ctxt(&@fn_ctxt fcx) -> @block_ctxt {
fcx=fcx);
}
-fn alloc_ty(&@block_ctxt cx, &ty.t t) -> result {
+fn alloc_ty(&@block_ctxt cx, &ty::t t) -> result {
auto val = C_int(0);
- if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
+ if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
// NB: we have to run this particular 'size_of' in a
// block_ctxt built on the llallocas block for the fn,
@@ -5993,22 +6001,22 @@ fn alloc_ty(&@block_ctxt cx, &ty.t t) -> result {
ret res(cx, val);
}
-fn alloc_local(&@block_ctxt cx, &@ast.local local) -> result {
+fn alloc_local(&@block_ctxt cx, &@ast::local local) -> result {
auto t = node_ann_type(cx.fcx.lcx.ccx, local.ann);
auto r = alloc_ty(cx, t);
r.bcx.fcx.lllocals.insert(local.id, r.val);
ret r;
}
-fn trans_block(&@block_ctxt cx, &ast.block b) -> result {
+fn trans_block(&@block_ctxt cx, &ast::block b) -> result {
auto bcx = cx;
- for each (@ast.local local in block_locals(b)) {
+ for each (@ast::local local in block_locals(b)) {
bcx = alloc_local(bcx, local).bcx;
}
auto r = res(bcx, C_nil());
- for (@ast.stmt s in b.node.stmts) {
+ for (@ast::stmt s in b.node.stmts) {
r = trans_stmt(bcx, *s);
bcx = r.bcx;
// If we hit a terminator, control won't go any further so
@@ -6019,15 +6027,15 @@ fn trans_block(&@block_ctxt cx, &ast.block b) -> result {
}
alt (b.node.expr) {
- case (some[@ast.expr](?e)) {
+ case (some[@ast::expr](?e)) {
r = trans_expr(bcx, e);
bcx = r.bcx;
if (is_terminated(bcx)) {
ret r;
} else {
- auto r_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, e);
- if (!ty.type_is_nil(cx.fcx.lcx.ccx.tcx, r_ty)) {
+ auto r_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, e);
+ if (!ty::type_is_nil(cx.fcx.lcx.ccx.tcx, r_ty)) {
// The value resulting from the block gets copied into an
// alloca created in an outer scope and its refcount
// bumped so that it can escape this block. This means
@@ -6053,7 +6061,7 @@ fn trans_block(&@block_ctxt cx, &ast.block b) -> result {
fn drop_hoisted_ty(&@block_ctxt cx,
ValueRef alloca_val,
- ty.t t) -> result {
+ ty::t t) -> result {
auto reg_val = load_if_immediate(cx,
alloca_val, t);
ret drop_ty(cx, reg_val, t);
@@ -6065,7 +6073,7 @@ fn trans_block(&@block_ctxt cx, &ast.block b) -> result {
}
}
}
- case (none[@ast.expr]) {
+ case (none[@ast::expr]) {
r = res(bcx, C_nil());
}
}
@@ -6076,8 +6084,8 @@ fn trans_block(&@block_ctxt cx, &ast.block b) -> result {
fn new_local_ctxt(&@crate_ctxt ccx) -> @local_ctxt {
let vec[str] pth = vec();
- let vec[ast.ty_param] obj_typarams = vec();
- let vec[ast.obj_field] obj_fields = vec();
+ let vec[ast::ty_param] obj_typarams = vec();
+ let vec[ast::obj_field] obj_fields = vec();
ret @rec(path=pth,
module_path=vec(crate_name(ccx, "main")),
obj_typarams = obj_typarams,
@@ -6089,9 +6097,9 @@ fn new_local_ctxt(&@crate_ctxt ccx) -> @local_ctxt {
// tydescs.
fn mk_standard_basic_blocks(ValueRef llfn) ->
tup(BasicBlockRef, BasicBlockRef, BasicBlockRef) {
- ret tup(llvm.LLVMAppendBasicBlock(llfn, Str.buf("allocas")),
- llvm.LLVMAppendBasicBlock(llfn, Str.buf("copy_args")),
- llvm.LLVMAppendBasicBlock(llfn, Str.buf("derived_tydescs")));
+ ret tup(llvm::LLVMAppendBasicBlock(llfn, _str::buf("allocas")),
+ llvm::LLVMAppendBasicBlock(llfn, _str::buf("copy_args")),
+ llvm::LLVMAppendBasicBlock(llfn, _str::buf("derived_tydescs")));
}
// NB: must keep 4 fns in sync:
@@ -6104,17 +6112,17 @@ fn mk_standard_basic_blocks(ValueRef llfn) ->
fn new_fn_ctxt(@local_ctxt cx,
ValueRef llfndecl) -> @fn_ctxt {
- let ValueRef llretptr = llvm.LLVMGetParam(llfndecl, 0u);
- let ValueRef lltaskptr = llvm.LLVMGetParam(llfndecl, 1u);
- let ValueRef llenv = llvm.LLVMGetParam(llfndecl, 2u);
+ let ValueRef llretptr = llvm::LLVMGetParam(llfndecl, 0u);
+ let ValueRef lltaskptr = llvm::LLVMGetParam(llfndecl, 1u);
+ let ValueRef llenv = llvm::LLVMGetParam(llfndecl, 2u);
- let hashmap[ast.def_id, ValueRef] llargs = new_def_hash[ValueRef]();
- let hashmap[ast.def_id, ValueRef] llobjfields = new_def_hash[ValueRef]();
- let hashmap[ast.def_id, ValueRef] lllocals = new_def_hash[ValueRef]();
- let hashmap[ast.def_id, ValueRef] llupvars = new_def_hash[ValueRef]();
+ let hashmap[ast::def_id, ValueRef] llargs = new_def_hash[ValueRef]();
+ let hashmap[ast::def_id, ValueRef] llobjfields = new_def_hash[ValueRef]();
+ let hashmap[ast::def_id, ValueRef] lllocals = new_def_hash[ValueRef]();
+ let hashmap[ast::def_id, ValueRef] llupvars = new_def_hash[ValueRef]();
auto derived_tydescs =
- Map.mk_hashmap[ty.t, derived_tydesc_info](ty.hash_ty, ty.eq_ty);
+ map::mk_hashmap[ty::t, derived_tydesc_info](ty::hash_ty, ty::eq_ty);
auto llbbs = mk_standard_basic_blocks(llfndecl);
@@ -6131,7 +6139,7 @@ fn new_fn_ctxt(@local_ctxt cx,
llobjfields=llobjfields,
lllocals=lllocals,
llupvars=llupvars,
- mutable lltydescs=Vec.empty[ValueRef](),
+ mutable lltydescs=_vec::empty[ValueRef](),
derived_tydescs=derived_tydescs,
lcx=cx);
}
@@ -6144,22 +6152,22 @@ fn new_fn_ctxt(@local_ctxt cx,
// - trans_args
fn create_llargs_for_fn_args(&@fn_ctxt cx,
- ast.proto proto,
- Option.t[tup(TypeRef, ty.t)] ty_self,
- ty.t ret_ty,
- &vec[ast.arg] args,
- &vec[ast.ty_param] ty_params) {
+ ast::proto proto,
+ option::t[tup(TypeRef, ty::t)] ty_self,
+ ty::t ret_ty,
+ &vec[ast::arg] args,
+ &vec[ast::ty_param] ty_params) {
auto arg_n = 3u;
alt (ty_self) {
- case (some[tup(TypeRef, ty.t)](?tt)) {
+ case (some[tup(TypeRef, ty::t)](?tt)) {
cx.llself = some[self_vt](rec(v = cx.llenv, t = tt._1));
}
- case (none[tup(TypeRef, ty.t)]) {
+ case (none[tup(TypeRef, ty::t)]) {
auto i = 0u;
- for (ast.ty_param tp in ty_params) {
- auto llarg = llvm.LLVMGetParam(cx.llfn, arg_n);
+ for (ast::ty_param tp in ty_params) {
+ auto llarg = llvm::LLVMGetParam(cx.llfn, arg_n);
assert (llarg as int != 0);
cx.lltydescs += vec(llarg);
arg_n += 1u;
@@ -6168,15 +6176,15 @@ fn create_llargs_for_fn_args(&@fn_ctxt cx,
}
}
- if (proto == ast.proto_iter) {
- auto llarg = llvm.LLVMGetParam(cx.llfn, arg_n);
+ if (proto == ast::proto_iter) {
+ auto llarg = llvm::LLVMGetParam(cx.llfn, arg_n);
assert (llarg as int != 0);
cx.lliterbody = some[ValueRef](llarg);
arg_n += 1u;
}
- for (ast.arg arg in args) {
- auto llarg = llvm.LLVMGetParam(cx.llfn, arg_n);
+ for (ast::arg arg in args) {
+ auto llarg = llvm::LLVMGetParam(cx.llfn, arg_n);
assert (llarg as int != 0);
cx.llargs.insert(arg.id, llarg);
arg_n += 1u;
@@ -6188,14 +6196,14 @@ fn create_llargs_for_fn_args(&@fn_ctxt cx,
// were passed and whatnot. Apparently mem2reg will mop up.
fn copy_any_self_to_alloca(@fn_ctxt fcx,
- Option.t[tup(TypeRef, ty.t)] ty_self) {
+ option::t[tup(TypeRef, ty::t)] ty_self) {
auto bcx = llallocas_block_ctxt(fcx);
alt (fcx.llself) {
case (some[self_vt](?s_vt)) {
alt (ty_self) {
- case (some[tup(TypeRef, ty.t)](?tt)) {
+ case (some[tup(TypeRef, ty::t)](?tt)) {
auto a = alloca(bcx, tt._0);
bcx.build.Store(s_vt.v, a);
fcx.llself = some[self_vt](rec(v = a, t = s_vt.t));
@@ -6209,14 +6217,14 @@ fn copy_any_self_to_alloca(@fn_ctxt fcx,
fn copy_args_to_allocas(@fn_ctxt fcx,
- vec[ast.arg] args,
- vec[ty.arg] arg_tys) {
+ vec[ast::arg] args,
+ vec[ty::arg] arg_tys) {
auto bcx = new_raw_block_ctxt(fcx, fcx.llcopyargs);
let uint arg_n = 0u;
- for (ast.arg aarg in args) {
- if (aarg.mode != ast.alias) {
+ for (ast::arg aarg in args) {
+ if (aarg.mode != ast::alias) {
auto arg_t = type_of_arg(bcx.fcx.lcx, arg_tys.(arg_n));
auto a = alloca(bcx, arg_t);
auto argval = bcx.fcx.llargs.get(aarg.id);
@@ -6230,11 +6238,11 @@ fn copy_args_to_allocas(@fn_ctxt fcx,
}
fn add_cleanups_for_args(&@block_ctxt bcx,
- vec[ast.arg] args,
- vec[ty.arg] arg_tys) {
+ vec[ast::arg] args,
+ vec[ty::arg] arg_tys) {
let uint arg_n = 0u;
- for (ast.arg aarg in args) {
- if (aarg.mode != ast.alias) {
+ for (ast::arg aarg in args) {
+ if (aarg.mode != ast::alias) {
auto argval = bcx.fcx.llargs.get(aarg.id);
find_scope_cx(bcx).cleanups +=
vec(clean(bind drop_slot(_, argval, arg_tys.(arg_n).ty)));
@@ -6245,22 +6253,22 @@ fn add_cleanups_for_args(&@block_ctxt bcx,
fn is_terminated(&@block_ctxt cx) -> bool {
- auto inst = llvm.LLVMGetLastInstruction(cx.llbb);
- ret llvm.LLVMIsATerminatorInst(inst) as int != 0;
+ auto inst = llvm::LLVMGetLastInstruction(cx.llbb);
+ ret llvm::LLVMIsATerminatorInst(inst) as int != 0;
}
-fn arg_tys_of_fn(&@crate_ctxt ccx, ast.ann ann) -> vec[ty.arg] {
- alt (ty.struct(ccx.tcx, ty.ann_to_type(ann))) {
- case (ty.ty_fn(_, ?arg_tys, _)) {
+fn arg_tys_of_fn(&@crate_ctxt ccx, ast::ann ann) -> vec[ty::arg] {
+ alt (ty::struct(ccx.tcx, ty::ann_to_type(ann))) {
+ case (ty::ty_fn(_, ?arg_tys, _)) {
ret arg_tys;
}
}
fail;
}
-fn ret_ty_of_fn_ty(&@crate_ctxt ccx, ty.t t) -> ty.t {
- alt (ty.struct(ccx.tcx, t)) {
- case (ty.ty_fn(_, _, ?ret_ty)) {
+fn ret_ty_of_fn_ty(&@crate_ctxt ccx, ty::t t) -> ty::t {
+ alt (ty::struct(ccx.tcx, t)) {
+ case (ty::ty_fn(_, _, ?ret_ty)) {
ret ret_ty;
}
}
@@ -6268,30 +6276,30 @@ fn ret_ty_of_fn_ty(&@crate_ctxt ccx, ty.t t) -> ty.t {
}
-fn ret_ty_of_fn(&@crate_ctxt ccx, ast.ann ann) -> ty.t {
- ret ret_ty_of_fn_ty(ccx, ty.ann_to_type(ann));
+fn ret_ty_of_fn(&@crate_ctxt ccx, ast::ann ann) -> ty::t {
+ ret ret_ty_of_fn_ty(ccx, ty::ann_to_type(ann));
}
fn populate_fn_ctxt_from_llself(@fn_ctxt fcx, self_vt llself) {
auto bcx = llallocas_block_ctxt(fcx);
- let vec[ty.t] field_tys = vec();
+ let vec[ty::t] field_tys = vec();
- for (ast.obj_field f in bcx.fcx.lcx.obj_fields) {
+ for (ast::obj_field f in bcx.fcx.lcx.obj_fields) {
field_tys += vec(node_ann_type(bcx.fcx.lcx.ccx, f.ann));
}
// Synthesize a tuple type for the fields so that GEP_tup_like() can work
// its magic.
- auto fields_tup_ty = ty.mk_imm_tup(fcx.lcx.ccx.tcx, field_tys);
+ auto fields_tup_ty = ty::mk_imm_tup(fcx.lcx.ccx.tcx, field_tys);
- auto n_typarams = Vec.len[ast.ty_param](bcx.fcx.lcx.obj_typarams);
+ auto n_typarams = _vec::len[ast::ty_param](bcx.fcx.lcx.obj_typarams);
let TypeRef llobj_box_ty = T_obj_ptr(bcx.fcx.lcx.ccx.tn, n_typarams);
auto box_cell =
bcx.build.GEP(llself.v,
vec(C_int(0),
- C_int(abi.obj_field_box)));
+ C_int(abi::obj_field_box)));
auto box_ptr = bcx.build.Load(box_cell);
@@ -6299,18 +6307,18 @@ fn populate_fn_ctxt_from_llself(@fn_ctxt fcx, self_vt llself) {
auto obj_typarams = bcx.build.GEP(box_ptr,
vec(C_int(0),
- C_int(abi.box_rc_field_body),
- C_int(abi.obj_body_elt_typarams)));
+ C_int(abi::box_rc_field_body),
+ C_int(abi::obj_body_elt_typarams)));
// The object fields immediately follow the type parameters, so we skip
// over them to get the pointer.
auto obj_fields = bcx.build.Add(vp2i(bcx, obj_typarams),
- llsize_of(llvm.LLVMGetElementType(val_ty(obj_typarams))));
+ llsize_of(llvm::LLVMGetElementType(val_ty(obj_typarams))));
// If we can (i.e. the type is statically sized), then cast the resulting
// fields pointer to the appropriate LLVM type. If not, just leave it as
// i8 *.
- if (!ty.type_has_dynamic_size(fcx.lcx.ccx.tcx, fields_tup_ty)) {
+ if (!ty::type_has_dynamic_size(fcx.lcx.ccx.tcx, fields_tup_ty)) {
auto llfields_ty = type_of(fcx.lcx.ccx, fields_tup_ty);
obj_fields = vi2p(bcx, obj_fields, T_ptr(llfields_ty));
} else {
@@ -6320,7 +6328,7 @@ fn populate_fn_ctxt_from_llself(@fn_ctxt fcx, self_vt llself) {
let int i = 0;
- for (ast.ty_param p in fcx.lcx.obj_typarams) {
+ for (ast::ty_param p in fcx.lcx.obj_typarams) {
let ValueRef lltyparam = bcx.build.GEP(obj_typarams,
vec(C_int(0),
C_int(i)));
@@ -6330,7 +6338,7 @@ fn populate_fn_ctxt_from_llself(@fn_ctxt fcx, self_vt llself) {
}
i = 0;
- for (ast.obj_field f in fcx.lcx.obj_fields) {
+ for (ast::obj_field f in fcx.lcx.obj_fields) {
auto rslt = GEP_tup_like(bcx, fields_tup_ty, obj_fields, vec(0, i));
bcx = llallocas_block_ctxt(fcx);
auto llfield = rslt.val;
@@ -6348,9 +6356,9 @@ fn finish_fn(&@fn_ctxt fcx, BasicBlockRef lltop) {
new_builder(fcx.llderivedtydescs).Br(lltop);
}
-fn trans_fn(@local_ctxt cx, &ast._fn f, ast.def_id fid,
- Option.t[tup(TypeRef, ty.t)] ty_self,
- &vec[ast.ty_param] ty_params, &ast.ann ann) {
+fn trans_fn(@local_ctxt cx, &ast::_fn f, ast::def_id fid,
+ option::t[tup(TypeRef, ty::t)] ty_self,
+ &vec[ast::ty_param] ty_params, &ast::ann ann) {
auto llfndecl = cx.ccx.item_ids.get(fid);
auto fcx = new_fn_ctxt(cx, llfndecl);
@@ -6388,35 +6396,35 @@ fn trans_fn(@local_ctxt cx, &ast._fn f, ast.def_id fid,
fn trans_vtbl(@local_ctxt cx,
TypeRef llself_ty,
- ty.t self_ty,
- &ast._obj ob,
- &vec[ast.ty_param] ty_params) -> ValueRef {
+ ty::t self_ty,
+ &ast::_obj ob,
+ &vec[ast::ty_param] ty_params) -> ValueRef {
auto dtor = C_null(T_ptr(T_i8()));
alt (ob.dtor) {
- case (some[@ast.method](?d)) {
+ case (some[@ast::method](?d)) {
auto dtor_1 = trans_dtor(cx, llself_ty, self_ty, ty_params, d);
- dtor = llvm.LLVMConstBitCast(dtor_1, val_ty(dtor));
+ dtor = llvm::LLVMConstBitCast(dtor_1, val_ty(dtor));
}
- case (none[@ast.method]) {}
+ case (none[@ast::method]) {}
}
let vec[ValueRef] methods = vec(dtor);
- fn meth_lteq(&@ast.method a, &@ast.method b) -> bool {
- ret Str.lteq(a.node.ident, b.node.ident);
+ fn meth_lteq(&@ast::method a, &@ast::method b) -> bool {
+ ret _str::lteq(a.node.ident, b.node.ident);
}
- auto meths = std.Sort.merge_sort[@ast.method](bind meth_lteq(_,_),
+ auto meths = std::sort::merge_sort[@ast::method](bind meth_lteq(_,_),
ob.methods);
- for (@ast.method m in meths) {
+ for (@ast::method m in meths) {
auto llfnty = T_nil();
- alt (ty.struct(cx.ccx.tcx, node_ann_type(cx.ccx, m.node.ann))) {
- case (ty.ty_fn(?proto, ?inputs, ?output)) {
+ alt (ty::struct(cx.ccx.tcx, node_ann_type(cx.ccx, m.node.ann))) {
+ case (ty::ty_fn(?proto, ?inputs, ?output)) {
llfnty = type_of_fn_full(cx.ccx, proto,
some[TypeRef](llself_ty),
inputs, output,
- Vec.len[ast.ty_param](ty_params));
+ _vec::len[ast::ty_param](ty_params));
}
}
@@ -6428,26 +6436,26 @@ fn trans_vtbl(@local_ctxt cx,
cx.ccx.item_symbols.insert(m.node.id, s);
trans_fn(mcx, m.node.meth, m.node.id,
- some[tup(TypeRef, ty.t)](tup(llself_ty, self_ty)),
+ some[tup(TypeRef, ty::t)](tup(llself_ty, self_ty)),
ty_params, m.node.ann);
methods += vec(llfn);
}
auto vtbl = C_struct(methods);
auto vtbl_name = mangle_name_by_seq(cx.ccx, cx.path, "vtbl");
- auto gvar = llvm.LLVMAddGlobal(cx.ccx.llmod, val_ty(vtbl),
- Str.buf(vtbl_name));
- llvm.LLVMSetInitializer(gvar, vtbl);
- llvm.LLVMSetGlobalConstant(gvar, True);
- llvm.LLVMSetLinkage(gvar, lib.llvm.LLVMInternalLinkage
- as llvm.Linkage);
+ auto gvar = llvm::LLVMAddGlobal(cx.ccx.llmod, val_ty(vtbl),
+ _str::buf(vtbl_name));
+ llvm::LLVMSetInitializer(gvar, vtbl);
+ llvm::LLVMSetGlobalConstant(gvar, True);
+ llvm::LLVMSetLinkage(gvar, lib::llvm::LLVMInternalLinkage
+ as llvm::Linkage);
ret gvar;
}
fn trans_dtor(@local_ctxt cx,
TypeRef llself_ty,
- ty.t self_ty,
- &vec[ast.ty_param] ty_params,
- &@ast.method dtor) -> ValueRef {
+ ty::t self_ty,
+ &vec[ast::ty_param] ty_params,
+ &@ast::method dtor) -> ValueRef {
auto llfnty = T_dtor(cx.ccx, llself_ty);
let @local_ctxt dcx = extend_path(cx, "drop");
@@ -6457,30 +6465,30 @@ fn trans_dtor(@local_ctxt cx,
cx.ccx.item_symbols.insert(dtor.node.id, s);
trans_fn(dcx, dtor.node.meth, dtor.node.id,
- some[tup(TypeRef, ty.t)](tup(llself_ty, self_ty)),
+ some[tup(TypeRef, ty::t)](tup(llself_ty, self_ty)),
ty_params, dtor.node.ann);
ret llfn;
}
-fn trans_obj(@local_ctxt cx, &ast._obj ob, ast.def_id oid,
- &vec[ast.ty_param] ty_params, &ast.ann ann) {
+fn trans_obj(@local_ctxt cx, &ast::_obj ob, ast::def_id oid,
+ &vec[ast::ty_param] ty_params, &ast::ann ann) {
auto ccx = cx.ccx;
auto llctor_decl = ccx.item_ids.get(oid);
// Translate obj ctor args to function arguments.
- let vec[ast.arg] fn_args = vec();
- for (ast.obj_field f in ob.fields) {
- fn_args += vec(rec(mode=ast.alias, ty=f.ty, ident=f.ident, id=f.id));
+ let vec[ast::arg] fn_args = vec();
+ for (ast::obj_field f in ob.fields) {
+ fn_args += vec(rec(mode=ast::alias, ty=f.ty, ident=f.ident, id=f.id));
}
auto fcx = new_fn_ctxt(cx, llctor_decl);
- create_llargs_for_fn_args(fcx, ast.proto_fn,
- none[tup(TypeRef, ty.t)],
+ create_llargs_for_fn_args(fcx, ast::proto_fn,
+ none[tup(TypeRef, ty::t)],
ret_ty_of_fn(ccx, ann),
fn_args, ty_params);
- let vec[ty.arg] arg_tys = arg_tys_of_fn(ccx, ann);
+ let vec[ty::arg] arg_tys = arg_tys_of_fn(ccx, ann);
copy_args_to_allocas(fcx, fn_args, arg_tys);
auto bcx = new_top_block_ctxt(fcx);
@@ -6493,66 +6501,66 @@ fn trans_obj(@local_ctxt cx, &ast._obj ob, ast.def_id oid,
auto vtbl = trans_vtbl(cx, llself_ty, self_ty, ob, ty_params);
auto pair_vtbl = bcx.build.GEP(pair,
vec(C_int(0),
- C_int(abi.obj_field_vtbl)));
+ C_int(abi::obj_field_vtbl)));
auto pair_box = bcx.build.GEP(pair,
vec(C_int(0),
- C_int(abi.obj_field_box)));
+ C_int(abi::obj_field_box)));
bcx.build.Store(vtbl, pair_vtbl);
let TypeRef llbox_ty = T_opaque_obj_ptr(ccx.tn);
// FIXME we should probably also allocate a box for empty objs that have a
// dtor, since otherwise they are never dropped, and the dtor never runs
- if (Vec.len[ast.ty_param](ty_params) == 0u &&
- Vec.len[ty.arg](arg_tys) == 0u) {
+ if (_vec::len[ast::ty_param](ty_params) == 0u &&
+ _vec::len[ty::arg](arg_tys) == 0u) {
// Store null into pair, if no args or typarams.
bcx.build.Store(C_null(llbox_ty), pair_box);
} else {
// Malloc a box for the body and copy args in.
- let vec[ty.t] obj_fields = vec();
- for (ty.arg a in arg_tys) {
- Vec.push[ty.t](obj_fields, a.ty);
+ let vec[ty::t] obj_fields = vec();
+ for (ty::arg a in arg_tys) {
+ _vec::push[ty::t](obj_fields, a.ty);
}
// Synthesize an obj body type.
- auto tydesc_ty = ty.mk_type(ccx.tcx);
- let vec[ty.t] tps = vec();
- for (ast.ty_param tp in ty_params) {
- Vec.push[ty.t](tps, tydesc_ty);
+ auto tydesc_ty = ty::mk_type(ccx.tcx);
+ let vec[ty::t] tps = vec();
+ for (ast::ty_param tp in ty_params) {
+ _vec::push[ty::t](tps, tydesc_ty);
}
- let ty.t typarams_ty = ty.mk_imm_tup(ccx.tcx, tps);
- let ty.t fields_ty = ty.mk_imm_tup(ccx.tcx, obj_fields);
- let ty.t body_ty = ty.mk_imm_tup(ccx.tcx,
+ let ty::t typarams_ty = ty::mk_imm_tup(ccx.tcx, tps);
+ let ty::t fields_ty = ty::mk_imm_tup(ccx.tcx, obj_fields);
+ let ty::t body_ty = ty::mk_imm_tup(ccx.tcx,
vec(tydesc_ty,
typarams_ty,
fields_ty));
- let ty.t boxed_body_ty = ty.mk_imm_box(ccx.tcx, body_ty);
+ let ty::t boxed_body_ty = ty::mk_imm_box(ccx.tcx, body_ty);
// Malloc a box for the body.
auto box = trans_malloc_boxed(bcx, body_ty);
bcx = box.bcx;
auto rc = GEP_tup_like(bcx, boxed_body_ty, box.val,
- vec(0, abi.box_rc_field_refcnt));
+ vec(0, abi::box_rc_field_refcnt));
bcx = rc.bcx;
auto body = GEP_tup_like(bcx, boxed_body_ty, box.val,
- vec(0, abi.box_rc_field_body));
+ vec(0, abi::box_rc_field_body));
bcx = body.bcx;
bcx.build.Store(C_int(1), rc.val);
// Store body tydesc.
auto body_tydesc =
GEP_tup_like(bcx, body_ty, body.val,
- vec(0, abi.obj_body_elt_tydesc));
+ vec(0, abi::obj_body_elt_tydesc));
bcx = body_tydesc.bcx;
auto body_td = get_tydesc(bcx, body_ty, true);
auto dtor = C_null(T_ptr(T_glue_fn(ccx.tn)));
alt (ob.dtor) {
- case (some[@ast.method](?d)) {
+ case (some[@ast::method](?d)) {
dtor = trans_dtor(cx, llself_ty, self_ty, ty_params, d);
}
- case (none[@ast.method]) {}
+ case (none[@ast::method]) {}
}
bcx = body_td.bcx;
@@ -6561,10 +6569,10 @@ fn trans_obj(@local_ctxt cx, &ast._obj ob, ast.def_id oid,
// Copy typarams into captured typarams.
auto body_typarams =
GEP_tup_like(bcx, body_ty, body.val,
- vec(0, abi.obj_body_elt_typarams));
+ vec(0, abi::obj_body_elt_typarams));
bcx = body_typarams.bcx;
let int i = 0;
- for (ast.ty_param tp in ty_params) {
+ for (ast::ty_param tp in ty_params) {
auto typaram = bcx.fcx.lltydescs.(i);
auto capture = GEP_tup_like(bcx, typarams_ty, body_typarams.val,
vec(0, i));
@@ -6576,11 +6584,11 @@ fn trans_obj(@local_ctxt cx, &ast._obj ob, ast.def_id oid,
// Copy args into body fields.
auto body_fields =
GEP_tup_like(bcx, body_ty, body.val,
- vec(0, abi.obj_body_elt_fields));
+ vec(0, abi::obj_body_elt_fields));
bcx = body_fields.bcx;
i = 0;
- for (ast.obj_field f in ob.fields) {
+ for (ast::obj_field f in ob.fields) {
auto arg = bcx.fcx.llargs.get(f.id);
arg = load_if_immediate(bcx, arg, arg_tys.(i).ty);
auto field = GEP_tup_like(bcx, fields_ty, body_fields.val,
@@ -6598,20 +6606,20 @@ fn trans_obj(@local_ctxt cx, &ast._obj ob, ast.def_id oid,
finish_fn(fcx, lltop);
}
-fn trans_tag_variant(@local_ctxt cx, ast.def_id tag_id,
- &ast.variant variant, int index,
- &vec[ast.ty_param] ty_params) {
- if (Vec.len[ast.variant_arg](variant.node.args) == 0u) {
+fn trans_tag_variant(@local_ctxt cx, ast::def_id tag_id,
+ &ast::variant variant, int index,
+ &vec[ast::ty_param] ty_params) {
+ if (_vec::len[ast::variant_arg](variant.node.args) == 0u) {
ret; // nullary constructors are just constants
}
// Translate variant arguments to function arguments.
- let vec[ast.arg] fn_args = vec();
+ let vec[ast::arg] fn_args = vec();
auto i = 0u;
- for (ast.variant_arg varg in variant.node.args) {
- fn_args += vec(rec(mode=ast.alias,
+ for (ast::variant_arg varg in variant.node.args) {
+ fn_args += vec(rec(mode=ast::alias,
ty=varg.ty,
- ident="arg" + UInt.to_str(i, 10u),
+ ident="arg" + _uint::to_str(i, 10u),
id=varg.id));
}
@@ -6620,15 +6628,15 @@ fn trans_tag_variant(@local_ctxt cx, ast.def_id tag_id,
auto fcx = new_fn_ctxt(cx, llfndecl);
- create_llargs_for_fn_args(fcx, ast.proto_fn,
- none[tup(TypeRef, ty.t)],
+ create_llargs_for_fn_args(fcx, ast::proto_fn,
+ none[tup(TypeRef, ty::t)],
ret_ty_of_fn(cx.ccx, variant.node.ann),
fn_args, ty_params);
- let vec[ty.t] ty_param_substs = vec();
+ let vec[ty::t] ty_param_substs = vec();
i = 0u;
- for (ast.ty_param tp in ty_params) {
- ty_param_substs += vec(ty.mk_param(cx.ccx.tcx, i));
+ for (ast::ty_param tp in ty_params) {
+ ty_param_substs += vec(ty::mk_param(cx.ccx.tcx, i));
i += 1u;
}
@@ -6650,7 +6658,7 @@ fn trans_tag_variant(@local_ctxt cx, ast.def_id tag_id,
vec(C_int(0), C_int(1)));
i = 0u;
- for (ast.variant_arg va in variant.node.args) {
+ for (ast::variant_arg va in variant.node.args) {
auto rslt = GEP_tag(bcx, llblobptr, tag_id, variant.node.id,
ty_param_substs, i as int);
bcx = rslt.bcx;
@@ -6664,8 +6672,8 @@ fn trans_tag_variant(@local_ctxt cx, ast.def_id tag_id,
auto arg_ty = arg_tys.(i).ty;
auto llargval;
- if (ty.type_is_structural(cx.ccx.tcx, arg_ty) ||
- ty.type_has_dynamic_size(cx.ccx.tcx, arg_ty)) {
+ if (ty::type_is_structural(cx.ccx.tcx, arg_ty) ||
+ ty::type_has_dynamic_size(cx.ccx.tcx, arg_ty)) {
llargval = llargptr;
} else {
llargval = bcx.build.Load(llargptr);
@@ -6687,9 +6695,9 @@ fn trans_tag_variant(@local_ctxt cx, ast.def_id tag_id,
// duplicate constants. I think. Maybe LLVM has a magical mode
// that does so later on?
-fn trans_const_expr(&@crate_ctxt cx, @ast.expr e) -> ValueRef {
+fn trans_const_expr(&@crate_ctxt cx, @ast::expr e) -> ValueRef {
alt (e.node) {
- case (ast.expr_lit(?lit, ?ann)) {
+ case (ast::expr_lit(?lit, ?ann)) {
ret trans_lit(cx, *lit, ann);
}
case (_) {
@@ -6698,53 +6706,53 @@ fn trans_const_expr(&@crate_ctxt cx, @ast.expr e) -> ValueRef {
}
}
-fn trans_const(&@crate_ctxt cx, @ast.expr e,
- &ast.def_id cid, &ast.ann ann) {
+fn trans_const(&@crate_ctxt cx, @ast::expr e,
+ &ast::def_id cid, &ast::ann ann) {
auto t = node_ann_type(cx, ann);
auto v = trans_const_expr(cx, e);
// The scalars come back as 1st class LLVM vals
// which we have to stick into global constants.
auto g = cx.consts.get(cid);
- llvm.LLVMSetInitializer(g, v);
- llvm.LLVMSetGlobalConstant(g, True);
+ llvm::LLVMSetInitializer(g, v);
+ llvm::LLVMSetGlobalConstant(g, True);
}
-fn trans_item(@local_ctxt cx, &ast.item item) {
+fn trans_item(@local_ctxt cx, &ast::item item) {
alt (item.node) {
- case (ast.item_fn(?name, ?f, ?tps, ?fid, ?ann)) {
+ case (ast::item_fn(?name, ?f, ?tps, ?fid, ?ann)) {
auto sub_cx = extend_path(cx, name);
- trans_fn(sub_cx, f, fid, none[tup(TypeRef, ty.t)], tps, ann);
+ trans_fn(sub_cx, f, fid, none[tup(TypeRef, ty::t)], tps, ann);
}
- case (ast.item_obj(?name, ?ob, ?tps, ?oid, ?ann)) {
+ case (ast::item_obj(?name, ?ob, ?tps, ?oid, ?ann)) {
auto sub_cx = @rec(obj_typarams=tps,
obj_fields=ob.fields with
*extend_path(cx, name));
trans_obj(sub_cx, ob, oid.ctor, tps, ann);
}
- case (ast.item_mod(?name, ?m, _)) {
+ case (ast::item_mod(?name, ?m, _)) {
auto sub_cx = @rec(path = cx.path + vec(name),
module_path = cx.module_path + vec(name)
with *cx);
trans_mod(sub_cx, m);
}
- case (ast.item_tag(?name, ?variants, ?tps, ?tag_id, _)) {
+ case (ast::item_tag(?name, ?variants, ?tps, ?tag_id, _)) {
auto sub_cx = extend_path(cx, name);
auto i = 0;
- for (ast.variant variant in variants) {
+ for (ast::variant variant in variants) {
trans_tag_variant(sub_cx, tag_id, variant, i, tps);
i += 1;
}
}
- case (ast.item_const(?name, _, ?expr, ?cid, ?ann)) {
+ case (ast::item_const(?name, _, ?expr, ?cid, ?ann)) {
trans_const(cx.ccx, expr, cid, ann);
}
case (_) { /* fall through */ }
}
}
-fn trans_mod(@local_ctxt cx, &ast._mod m) {
- for (@ast.item item in m.items) {
+fn trans_mod(@local_ctxt cx, &ast::_mod m) {
+ for (@ast::item item in m.items) {
trans_item(cx, *item);
}
}
@@ -6752,24 +6760,24 @@ fn trans_mod(@local_ctxt cx, &ast._mod m) {
fn get_pair_fn_ty(TypeRef llpairty) -> TypeRef {
// Bit of a kludge: pick the fn typeref out of the pair.
let vec[TypeRef] pair_tys = vec(T_nil(), T_nil());
- llvm.LLVMGetStructElementTypes(llpairty,
- Vec.buf[TypeRef](pair_tys));
- ret llvm.LLVMGetElementType(pair_tys.(0));
+ llvm::LLVMGetStructElementTypes(llpairty,
+ _vec::buf[TypeRef](pair_tys));
+ ret llvm::LLVMGetElementType(pair_tys.(0));
}
fn decl_fn_and_pair(&@crate_ctxt ccx,
vec[str] path,
str flav,
- vec[ast.ty_param] ty_params,
- &ast.ann ann,
- ast.def_id id) {
+ vec[ast::ty_param] ty_params,
+ &ast::ann ann,
+ ast::def_id id) {
auto llfty;
auto llpairty;
- alt (ty.struct(ccx.tcx, node_ann_type(ccx, ann))) {
- case (ty.ty_fn(?proto, ?inputs, ?output)) {
+ alt (ty::struct(ccx.tcx, node_ann_type(ccx, ann))) {
+ case (ty::ty_fn(?proto, ?inputs, ?output)) {
llfty = type_of_fn(ccx, proto, inputs, output,
- Vec.len[ast.ty_param](ty_params));
+ _vec::len[ast::ty_param](ty_params));
llpairty = T_fn_pair(ccx.tn, llfty);
}
case (_) {
@@ -6789,17 +6797,17 @@ fn decl_fn_and_pair(&@crate_ctxt ccx,
}
fn register_fn_pair(&@crate_ctxt cx, str ps, TypeRef llpairty, ValueRef llfn,
- ast.def_id id) {
- let ValueRef gvar = llvm.LLVMAddGlobal(cx.llmod, llpairty,
- Str.buf(ps));
+ ast::def_id id) {
+ let ValueRef gvar = llvm::LLVMAddGlobal(cx.llmod, llpairty,
+ _str::buf(ps));
auto pair = C_struct(vec(llfn,
C_null(T_opaque_closure_ptr(cx.tn))));
- llvm.LLVMSetInitializer(gvar, pair);
- llvm.LLVMSetGlobalConstant(gvar, True);
- llvm.LLVMSetVisibility(gvar,
- lib.llvm.LLVMProtectedVisibility
- as llvm.Visibility);
+ llvm::LLVMSetInitializer(gvar, pair);
+ llvm::LLVMSetGlobalConstant(gvar, True);
+ llvm::LLVMSetVisibility(gvar,
+ lib::llvm::LLVMProtectedVisibility
+ as llvm::Visibility);
cx.item_ids.insert(id, llfn);
cx.item_symbols.insert(id, ps);
@@ -6807,27 +6815,27 @@ fn register_fn_pair(&@crate_ctxt cx, str ps, TypeRef llpairty, ValueRef llfn,
}
// Returns the number of type parameters that the given native function has.
-fn native_fn_ty_param_count(&@crate_ctxt cx, &ast.def_id id) -> uint {
+fn native_fn_ty_param_count(&@crate_ctxt cx, &ast::def_id id) -> uint {
auto count;
auto native_item = cx.native_items.get(id);
alt (native_item.node) {
- case (ast.native_item_ty(_,_)) {
+ case (ast::native_item_ty(_,_)) {
cx.sess.bug("decl_native_fn_and_pair(): native fn isn't " +
"actually a fn?!");
fail;
}
- case (ast.native_item_fn(_, _, _, ?tps, _, _)) {
- count = Vec.len[ast.ty_param](tps);
+ case (ast::native_item_fn(_, _, _, ?tps, _, _)) {
+ count = _vec::len[ast::ty_param](tps);
}
}
ret count;
}
-fn native_fn_wrapper_type(&@crate_ctxt cx, uint ty_param_count, ty.t x)
+fn native_fn_wrapper_type(&@crate_ctxt cx, uint ty_param_count, ty::t x)
-> TypeRef {
- alt (ty.struct(cx.tcx, x)) {
- case (ty.ty_native_fn(?abi, ?args, ?out)) {
- ret type_of_fn(cx, ast.proto_fn, args, out, ty_param_count);
+ alt (ty::struct(cx.tcx, x)) {
+ case (ty::ty_native_fn(?abi, ?args, ?out)) {
+ ret type_of_fn(cx, ast::proto_fn, args, out, ty_param_count);
}
}
fail;
@@ -6836,8 +6844,8 @@ fn native_fn_wrapper_type(&@crate_ctxt cx, uint ty_param_count, ty.t x)
fn decl_native_fn_and_pair(&@crate_ctxt ccx,
vec[str] path,
str name,
- &ast.ann ann,
- ast.def_id id) {
+ &ast::ann ann,
+ ast::def_id id) {
auto num_ty_param = native_fn_ty_param_count(ccx, id);
// Declare the wrapper.
@@ -6862,32 +6870,33 @@ fn decl_native_fn_and_pair(&@crate_ctxt ccx,
auto item = ccx.native_items.get(id);
auto fn_type = node_ann_type(ccx, ann); // NB: has no type params
- auto abi = ty.ty_fn_abi(ccx.tcx, fn_type);
+ auto abi = ty::ty_fn_abi(ccx.tcx, fn_type);
auto llfnty = type_of_native_fn(ccx, abi,
- ty.ty_fn_args(ccx.tcx, fn_type),
- ty.ty_fn_ret(ccx.tcx, fn_type), num_ty_param);
+ ty::ty_fn_args(ccx.tcx, fn_type),
+ ty::ty_fn_ret(ccx.tcx, fn_type), num_ty_param);
// FIXME: If the returned type is not nil, then we assume it's 32 bits
// wide. This is obviously wildly unsafe. We should have a better FFI
// that allows types of different sizes to be returned.
- auto rty_is_nil = ty.type_is_nil(ccx.tcx, ty.ty_fn_ret(ccx.tcx, fn_type));
+ auto rty_is_nil = ty::type_is_nil(ccx.tcx, ty::ty_fn_ret(ccx.tcx,
+ fn_type));
auto pass_task;
auto cast_to_i32;
alt (abi) {
- case (ast.native_abi_rust) {
+ case (ast::native_abi_rust) {
pass_task = true;
cast_to_i32 = true;
}
- case (ast.native_abi_rust_intrinsic) {
+ case (ast::native_abi_rust_intrinsic) {
pass_task = true;
cast_to_i32 = false;
}
- case (ast.native_abi_cdecl) {
+ case (ast::native_abi_cdecl) {
pass_task = false;
cast_to_i32 = true;
}
- case (ast.native_abi_llvm) {
+ case (ast::native_abi_llvm) {
pass_task = false;
cast_to_i32 = false;
}
@@ -6904,8 +6913,8 @@ fn decl_native_fn_and_pair(&@crate_ctxt ccx,
if (pass_task) { call_args += vec(lltaskptr); }
auto arg_n = 3u;
- for each (uint i in UInt.range(0u, num_ty_param)) {
- auto llarg = llvm.LLVMGetParam(fcx.llfn, arg_n);
+ for each (uint i in _uint::range(0u, num_ty_param)) {
+ auto llarg = llvm::LLVMGetParam(fcx.llfn, arg_n);
fcx.lltydescs += vec(llarg);
assert (llarg as int != 0);
@@ -6920,19 +6929,19 @@ fn decl_native_fn_and_pair(&@crate_ctxt ccx,
fn convert_arg_to_i32(&@block_ctxt cx,
ValueRef v,
- ty.t t,
- ty.mode mode) -> ValueRef {
- if (mode == ty.mo_val) {
- if (ty.type_is_integral(cx.fcx.lcx.ccx.tcx, t)) {
+ ty::t t,
+ ty::mode mode) -> ValueRef {
+ if (mode == ty::mo_val) {
+ if (ty::type_is_integral(cx.fcx.lcx.ccx.tcx, t)) {
auto lldsttype = T_int();
auto llsrctype = type_of(cx.fcx.lcx.ccx, t);
- if (llvm.LLVMGetIntTypeWidth(lldsttype) >
- llvm.LLVMGetIntTypeWidth(llsrctype)) {
+ if (llvm::LLVMGetIntTypeWidth(lldsttype) >
+ llvm::LLVMGetIntTypeWidth(llsrctype)) {
ret cx.build.ZExtOrBitCast(v, T_int());
}
ret cx.build.TruncOrBitCast(v, T_int());
}
- if (ty.type_is_fp(cx.fcx.lcx.ccx.tcx, t)) {
+ if (ty::type_is_fp(cx.fcx.lcx.ccx.tcx, t)) {
ret cx.build.FPToSI(v, T_int());
}
}
@@ -6943,7 +6952,7 @@ fn decl_native_fn_and_pair(&@crate_ctxt ccx,
fn trans_simple_native_abi(&@block_ctxt bcx,
str name,
&mutable vec[ValueRef] call_args,
- ty.t fn_type,
+ ty::t fn_type,
uint first_arg_n) -> tup(ValueRef, ValueRef) {
let vec[TypeRef] call_arg_tys = vec();
for (ValueRef arg in call_args) {
@@ -6953,12 +6962,12 @@ fn decl_native_fn_and_pair(&@crate_ctxt ccx,
auto llnativefnty =
T_fn(call_arg_tys,
type_of(bcx.fcx.lcx.ccx,
- ty.ty_fn_ret(bcx.fcx.lcx.ccx.tcx, fn_type)));
+ ty::ty_fn_ret(bcx.fcx.lcx.ccx.tcx, fn_type)));
auto llnativefn = get_extern_fn(bcx.fcx.lcx.ccx.externs,
bcx.fcx.lcx.ccx.llmod,
name,
- lib.llvm.LLVMCCallConv,
+ lib::llvm::LLVMCCallConv,
llnativefnty);
auto r = bcx.build.Call(llnativefn, call_args);
@@ -6966,13 +6975,13 @@ fn decl_native_fn_and_pair(&@crate_ctxt ccx,
ret tup(r, rptr);
}
- auto args = ty.ty_fn_args(ccx.tcx, fn_type);
+ auto args = ty::ty_fn_args(ccx.tcx, fn_type);
// Build up the list of arguments.
- let vec[tup(ValueRef, ty.t)] drop_args = vec();
+ let vec[tup(ValueRef, ty::t)] drop_args = vec();
auto i = arg_n;
- for (ty.arg arg in args) {
- auto llarg = llvm.LLVMGetParam(fcx.llfn, i);
+ for (ty::arg arg in args) {
+ auto llarg = llvm::LLVMGetParam(fcx.llfn, i);
assert (llarg as int != 0);
if (cast_to_i32) {
@@ -6982,7 +6991,7 @@ fn decl_native_fn_and_pair(&@crate_ctxt ccx,
call_args += vec(llarg);
}
- if (arg.mode == ty.mo_val) {
+ if (arg.mode == ty::mo_val) {
drop_args += vec(tup(llarg, arg.ty));
}
@@ -6992,12 +7001,12 @@ fn decl_native_fn_and_pair(&@crate_ctxt ccx,
auto r;
auto rptr;
alt (abi) {
- case (ast.native_abi_llvm) {
+ case (ast::native_abi_llvm) {
auto result = trans_simple_native_abi(bcx, name, call_args,
fn_type, arg_n);
r = result._0; rptr = result._1;
}
- case (ast.native_abi_rust_intrinsic) {
+ case (ast::native_abi_rust_intrinsic) {
auto external_name = "rust_intrinsic_" + name;
auto result = trans_simple_native_abi(bcx, external_name,
call_args, fn_type, arg_n);
@@ -7017,7 +7026,7 @@ fn decl_native_fn_and_pair(&@crate_ctxt ccx,
// the FIXME above.
if (!rty_is_nil) { bcx.build.Store(r, rptr); }
- for (tup(ValueRef, ty.t) d in drop_args) {
+ for (tup(ValueRef, ty::t) d in drop_args) {
bcx = drop_ty(bcx, d._0, d._1).bcx;
}
@@ -7032,94 +7041,94 @@ fn new_walk_ctxt() -> @walk_ctxt {
ret @rec(mutable path=path);
}
-fn enter_item(@walk_ctxt cx, &@ast.item item) {
+fn enter_item(@walk_ctxt cx, &@ast::item item) {
alt (item.node) {
- case (ast.item_fn(?name, _, _, _, _)) {
- Vec.push[str](cx.path, name);
+ case (ast::item_fn(?name, _, _, _, _)) {
+ _vec::push[str](cx.path, name);
}
- case (ast.item_obj(?name, _, _, _, _)) {
- Vec.push[str](cx.path, name);
+ case (ast::item_obj(?name, _, _, _, _)) {
+ _vec::push[str](cx.path, name);
}
- case (ast.item_mod(?name, _, _)) {
- Vec.push[str](cx.path, name);
+ case (ast::item_mod(?name, _, _)) {
+ _vec::push[str](cx.path, name);
}
case (_) { }
}
}
-fn leave_item(@walk_ctxt cx, &@ast.item item) {
+fn leave_item(@walk_ctxt cx, &@ast::item item) {
alt (item.node) {
- case (ast.item_fn(_, _, _, _, _)) {
- Vec.pop[str](cx.path);
+ case (ast::item_fn(_, _, _, _, _)) {
+ _vec::pop[str](cx.path);
}
- case (ast.item_obj(_, _, _, _, _)) {
- Vec.pop[str](cx.path);
+ case (ast::item_obj(_, _, _, _, _)) {
+ _vec::pop[str](cx.path);
}
- case (ast.item_mod(_, _, _)) {
- Vec.pop[str](cx.path);
+ case (ast::item_mod(_, _, _)) {
+ _vec::pop[str](cx.path);
}
case (_) { }
}
}
fn collect_native_item(&@crate_ctxt ccx, @walk_ctxt wcx,
- &@ast.native_item i) {
+ &@ast::native_item i) {
alt (i.node) {
- case (ast.native_item_fn(?name, _, _, _, ?fid, ?ann)) {
+ case (ast::native_item_fn(?name, _, _, _, ?fid, ?ann)) {
ccx.native_items.insert(fid, i);
if (!ccx.obj_methods.contains_key(fid)) {
decl_native_fn_and_pair(ccx, wcx.path, name, ann, fid);
}
}
- case (ast.native_item_ty(_, ?tid)) {
+ case (ast::native_item_ty(_, ?tid)) {
ccx.native_items.insert(tid, i);
}
}
}
-fn collect_item_1(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast.item i) {
+fn collect_item_1(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast::item i) {
enter_item(wcx, i);
alt (i.node) {
- case (ast.item_const(?name, _, _, ?cid, ?ann)) {
+ case (ast::item_const(?name, _, _, ?cid, ?ann)) {
auto typ = node_ann_type(ccx, ann);
- auto g = llvm.LLVMAddGlobal(ccx.llmod, type_of(ccx, typ),
- Str.buf(ccx.names.next(name)));
- llvm.LLVMSetLinkage(g, lib.llvm.LLVMInternalLinkage
- as llvm.Linkage);
+ auto g = llvm::LLVMAddGlobal(ccx.llmod, type_of(ccx, typ),
+ _str::buf(ccx.names.next(name)));
+ llvm::LLVMSetLinkage(g, lib::llvm::LLVMInternalLinkage
+ as llvm::Linkage);
ccx.items.insert(cid, i);
ccx.consts.insert(cid, g);
}
- case (ast.item_mod(?name, ?m, ?mid)) {
+ case (ast::item_mod(?name, ?m, ?mid)) {
ccx.items.insert(mid, i);
}
- case (ast.item_native_mod(_, _, ?mid)) {
+ case (ast::item_native_mod(_, _, ?mid)) {
ccx.items.insert(mid, i);
}
- case (ast.item_ty(_, _, _, ?did, _)) {
+ case (ast::item_ty(_, _, _, ?did, _)) {
ccx.items.insert(did, i);
}
- case (ast.item_tag(?name, ?variants, ?tps, ?tag_id, _)) {
+ case (ast::item_tag(?name, ?variants, ?tps, ?tag_id, _)) {
ccx.items.insert(tag_id, i);
}
case (_) {}
}
}
-fn collect_item_2(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast.item i) {
+fn collect_item_2(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast::item i) {
enter_item(wcx, i);
alt (i.node) {
- case (ast.item_fn(?name, ?f, ?tps, ?fid, ?ann)) {
+ case (ast::item_fn(?name, ?f, ?tps, ?fid, ?ann)) {
ccx.items.insert(fid, i);
if (!ccx.obj_methods.contains_key(fid)) {
decl_fn_and_pair(ccx, wcx.path, "fn", tps, ann, fid);
}
}
- case (ast.item_obj(?name, ?ob, ?tps, ?oid, ?ann)) {
+ case (ast::item_obj(?name, ?ob, ?tps, ?oid, ?ann)) {
ccx.items.insert(oid.ctor, i);
decl_fn_and_pair(ccx, wcx.path, "obj_ctor", tps, ann, oid.ctor);
- for (@ast.method m in ob.methods) {
+ for (@ast::method m in ob.methods) {
ccx.obj_methods.insert(m.node.id, ());
}
}
@@ -7127,9 +7136,9 @@ fn collect_item_2(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast.item i) {
}
}
-fn collect_items(&@crate_ctxt ccx, @ast.crate crate) {
+fn collect_items(&@crate_ctxt ccx, @ast::crate crate) {
auto wcx = new_walk_ctxt();
- auto visitor0 = walk.default_visitor();
+ auto visitor0 = walk::default_visitor();
auto visitor1 = rec(visit_native_item_pre =
bind collect_native_item(ccx, wcx, _),
visit_item_pre = bind collect_item_1(ccx, wcx, _),
@@ -7138,17 +7147,17 @@ fn collect_items(&@crate_ctxt ccx, @ast.crate crate) {
auto visitor2 = rec(visit_item_pre = bind collect_item_2(ccx, wcx, _),
visit_item_post = bind leave_item(wcx, _)
with visitor0);
- walk.walk_crate(visitor1, *crate);
- walk.walk_crate(visitor2, *crate);
+ walk::walk_crate(visitor1, *crate);
+ walk::walk_crate(visitor2, *crate);
}
-fn collect_tag_ctor(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast.item i) {
+fn collect_tag_ctor(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast::item i) {
enter_item(wcx, i);
alt (i.node) {
- case (ast.item_tag(_, ?variants, ?tps, _, _)) {
- for (ast.variant variant in variants) {
- if (Vec.len[ast.variant_arg](variant.node.args) != 0u) {
+ case (ast::item_tag(_, ?variants, ?tps, _, _)) {
+ for (ast::variant variant in variants) {
+ if (_vec::len[ast::variant_arg](variant.node.args) != 0u) {
decl_fn_and_pair(ccx, wcx.path + vec(variant.node.name),
"tag", tps, variant.node.ann,
variant.node.id);
@@ -7160,23 +7169,23 @@ fn collect_tag_ctor(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast.item i) {
}
}
-fn collect_tag_ctors(&@crate_ctxt ccx, @ast.crate crate) {
+fn collect_tag_ctors(&@crate_ctxt ccx, @ast::crate crate) {
auto wcx = new_walk_ctxt();
auto visitor = rec(visit_item_pre = bind collect_tag_ctor(ccx, wcx, _),
visit_item_post = bind leave_item(wcx, _)
- with walk.default_visitor());
- walk.walk_crate(visitor, *crate);
+ with walk::default_visitor());
+ walk::walk_crate(visitor, *crate);
}
// The constant translation pass.
-fn trans_constant(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast.item it) {
+fn trans_constant(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast::item it) {
enter_item(wcx, it);
alt (it.node) {
- case (ast.item_tag(?ident, ?variants, _, ?tag_id, _)) {
+ case (ast::item_tag(?ident, ?variants, _, ?tag_id, _)) {
auto i = 0u;
- auto n_variants = Vec.len[ast.variant](variants);
+ auto n_variants = _vec::len[ast::variant](variants);
while (i < n_variants) {
auto variant = variants.(i);
@@ -7185,11 +7194,11 @@ fn trans_constant(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast.item it) {
auto s = mangle_name_by_seq(ccx, wcx.path,
#fmt("_rust_tag_discrim_%s_%u",
ident, i));
- auto discrim_gvar = llvm.LLVMAddGlobal(ccx.llmod, T_int(),
- Str.buf(s));
+ auto discrim_gvar = llvm::LLVMAddGlobal(ccx.llmod, T_int(),
+ _str::buf(s));
- llvm.LLVMSetInitializer(discrim_gvar, discrim_val);
- llvm.LLVMSetGlobalConstant(discrim_gvar, True);
+ llvm::LLVMSetInitializer(discrim_gvar, discrim_val);
+ llvm::LLVMSetGlobalConstant(discrim_gvar, True);
ccx.discrims.insert(variant.node.id, discrim_gvar);
ccx.discrim_symbols.insert(variant.node.id, s);
@@ -7198,7 +7207,7 @@ fn trans_constant(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast.item it) {
}
}
- case (ast.item_const(?name, _, ?expr, ?cid, ?ann)) {
+ case (ast::item_const(?name, _, ?expr, ?cid, ?ann)) {
// FIXME: The whole expr-translation system needs cloning to deal
// with consts.
auto v = C_int(1);
@@ -7212,12 +7221,12 @@ fn trans_constant(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast.item it) {
}
}
-fn trans_constants(&@crate_ctxt ccx, @ast.crate crate) {
+fn trans_constants(&@crate_ctxt ccx, @ast::crate crate) {
auto wcx = new_walk_ctxt();
auto visitor = rec(visit_item_pre = bind trans_constant(ccx, wcx, _),
visit_item_post = bind leave_item(wcx, _)
- with walk.default_visitor());
- walk.walk_crate(visitor, *crate);
+ with walk::default_visitor());
+ walk::walk_crate(visitor, *crate);
}
@@ -7231,11 +7240,11 @@ fn vi2p(&@block_ctxt cx, ValueRef v, TypeRef t) -> ValueRef {
}
fn p2i(ValueRef v) -> ValueRef {
- ret llvm.LLVMConstPtrToInt(v, T_int());
+ ret llvm::LLVMConstPtrToInt(v, T_int());
}
fn i2p(ValueRef v, TypeRef t) -> ValueRef {
- ret llvm.LLVMConstIntToPtr(v, t);
+ ret llvm::LLVMConstIntToPtr(v, t);
}
fn trans_exit_task_glue(@glue_fns glues,
@@ -7246,14 +7255,14 @@ fn trans_exit_task_glue(@glue_fns glues,
auto llfn = glues.exit_task_glue;
- auto entrybb = llvm.LLVMAppendBasicBlock(llfn, Str.buf("entry"));
+ auto entrybb = llvm::LLVMAppendBasicBlock(llfn, _str::buf("entry"));
auto build = new_builder(entrybb);
- let ValueRef arg1 = llvm.LLVMGetParam(llfn, 0u);
- let ValueRef arg2 = llvm.LLVMGetParam(llfn, 1u);
- let ValueRef arg3 = llvm.LLVMGetParam(llfn, 2u);
- let ValueRef arg4 = llvm.LLVMGetParam(llfn, 3u);
- let ValueRef arg5 = llvm.LLVMGetParam(llfn, 4u);
+ let ValueRef arg1 = llvm::LLVMGetParam(llfn, 0u);
+ let ValueRef arg2 = llvm::LLVMGetParam(llfn, 1u);
+ let ValueRef arg3 = llvm::LLVMGetParam(llfn, 2u);
+ let ValueRef arg4 = llvm::LLVMGetParam(llfn, 3u);
+ let ValueRef arg5 = llvm::LLVMGetParam(llfn, 4u);
auto main_type = T_fn(vec(T_int(), T_int(), T_int(), T_int()), T_void());
@@ -7268,9 +7277,9 @@ fn trans_exit_task_glue(@glue_fns glues,
}
fn create_typedefs(&@crate_ctxt cx) {
- llvm.LLVMAddTypeName(cx.llmod, Str.buf("crate"), T_crate(cx.tn));
- llvm.LLVMAddTypeName(cx.llmod, Str.buf("task"), T_task(cx.tn));
- llvm.LLVMAddTypeName(cx.llmod, Str.buf("tydesc"), T_tydesc(cx.tn));
+ llvm::LLVMAddTypeName(cx.llmod, _str::buf("crate"), T_crate(cx.tn));
+ llvm::LLVMAddTypeName(cx.llmod, _str::buf("task"), T_task(cx.tn));
+ llvm::LLVMAddTypeName(cx.llmod, _str::buf("tydesc"), T_tydesc(cx.tn));
}
fn create_crate_constant(ValueRef crate_ptr, @glue_fns glues) {
@@ -7278,13 +7287,13 @@ fn create_crate_constant(ValueRef crate_ptr, @glue_fns glues) {
let ValueRef crate_addr = p2i(crate_ptr);
let ValueRef activate_glue_off =
- llvm.LLVMConstSub(p2i(glues.activate_glue), crate_addr);
+ llvm::LLVMConstSub(p2i(glues.activate_glue), crate_addr);
let ValueRef yield_glue_off =
- llvm.LLVMConstSub(p2i(glues.yield_glue), crate_addr);
+ llvm::LLVMConstSub(p2i(glues.yield_glue), crate_addr);
let ValueRef exit_task_glue_off =
- llvm.LLVMConstSub(p2i(glues.exit_task_glue), crate_addr);
+ llvm::LLVMConstSub(p2i(glues.exit_task_glue), crate_addr);
let ValueRef crate_val =
C_struct(vec(C_null(T_int()), // ptrdiff_t image_base_off
@@ -7301,18 +7310,18 @@ fn create_crate_constant(ValueRef crate_ptr, @glue_fns glues) {
C_null(T_int()), // int n_rust_syms
C_null(T_int()), // int n_c_syms
C_null(T_int()), // int n_libs
- C_int(abi.abi_x86_rustc_fastcall) // uintptr_t abi_tag
+ C_int(abi::abi_x86_rustc_fastcall) // uintptr_t abi_tag
));
- llvm.LLVMSetInitializer(crate_ptr, crate_val);
+ llvm::LLVMSetInitializer(crate_ptr, crate_val);
}
fn find_main_fn(&@crate_ctxt cx) -> ValueRef {
auto e = sep() + "main";
let ValueRef v = C_nil();
let uint n = 0u;
- for each (@tup(ast.def_id, str) i in cx.item_symbols.items()) {
- if (Str.ends_with(i._1, e)) {
+ for each (@tup(ast::def_id, str) i in cx.item_symbols.items()) {
+ if (_str::ends_with(i._1, e)) {
n += 1u;
v = cx.item_ids.get(i._0);
}
@@ -7336,7 +7345,7 @@ fn trans_main_fn(@local_ctxt cx, ValueRef llcrate, ValueRef crate_map) {
auto T_rust_start_args = vec(T_int(), T_int(), T_int(), T_int(), T_int());
auto main_name;
- if (Str.eq(std.OS.target_os(), "win32")) {
+ if (_str::eq(std::os::target_os(), "win32")) {
main_name = "WinMain@16";
} else {
main_name = "main";
@@ -7348,8 +7357,8 @@ fn trans_main_fn(@local_ctxt cx, ValueRef llcrate, ValueRef crate_map) {
auto llrust_start = decl_cdecl_fn(cx.ccx.llmod, "rust_start",
T_fn(T_rust_start_args, T_int()));
- auto llargc = llvm.LLVMGetParam(llmain, 0u);
- auto llargv = llvm.LLVMGetParam(llmain, 1u);
+ auto llargc = llvm::LLVMGetParam(llmain, 0u);
+ auto llargv = llvm::LLVMGetParam(llmain, 1u);
auto llrust_main = find_main_fn(cx.ccx);
//
@@ -7361,7 +7370,7 @@ fn trans_main_fn(@local_ctxt cx, ValueRef llcrate, ValueRef crate_map) {
//
let BasicBlockRef llbb =
- llvm.LLVMAppendBasicBlock(llmain, Str.buf(""));
+ llvm::LLVMAppendBasicBlock(llmain, _str::buf(""));
auto b = new_builder(llbb);
auto start_args = vec(p2i(llrust_main), p2i(llcrate), llargc, llargv,
@@ -7428,12 +7437,12 @@ fn trap(&@block_ctxt bcx) {
fn decl_no_op_type_glue(ModuleRef llmod, type_names tn) -> ValueRef {
auto ty = T_fn(vec(T_taskptr(tn), T_ptr(T_i8())), T_void());
- ret decl_fastcall_fn(llmod, abi.no_op_type_glue_name(), ty);
+ ret decl_fastcall_fn(llmod, abi::no_op_type_glue_name(), ty);
}
fn make_no_op_type_glue(ValueRef fun) {
- auto bb_name = Str.buf("_rust_no_op_type_glue_bb");
- auto llbb = llvm.LLVMAppendBasicBlock(fun, bb_name);
+ auto bb_name = _str::buf("_rust_no_op_type_glue_bb");
+ auto llbb = llvm::LLVMAppendBasicBlock(fun, bb_name);
new_builder(llbb).RetVoid();
}
@@ -7465,34 +7474,34 @@ fn make_vec_append_glue(ModuleRef llmod, type_names tn) -> ValueRef {
T_opaque_vec_ptr(), T_bool()),
T_void());
- auto llfn = decl_fastcall_fn(llmod, abi.vec_append_glue_name(), ty);
+ auto llfn = decl_fastcall_fn(llmod, abi::vec_append_glue_name(), ty);
ret llfn;
}
fn vec_fill(&@block_ctxt bcx, ValueRef v) -> ValueRef {
ret bcx.build.Load(bcx.build.GEP(v, vec(C_int(0),
- C_int(abi.vec_elt_fill))));
+ C_int(abi::vec_elt_fill))));
}
fn put_vec_fill(&@block_ctxt bcx, ValueRef v, ValueRef fill) -> ValueRef {
ret bcx.build.Store(fill,
bcx.build.GEP(v,
vec(C_int(0),
- C_int(abi.vec_elt_fill))));
+ C_int(abi::vec_elt_fill))));
}
fn vec_fill_adjusted(&@block_ctxt bcx, ValueRef v,
ValueRef skipnull) -> ValueRef {
auto f = bcx.build.Load(bcx.build.GEP(v,
vec(C_int(0),
- C_int(abi.vec_elt_fill))));
+ C_int(abi::vec_elt_fill))));
ret bcx.build.Select(skipnull, bcx.build.Sub(f, C_int(1)), f);
}
fn vec_p0(&@block_ctxt bcx, ValueRef v) -> ValueRef {
auto p = bcx.build.GEP(v, vec(C_int(0),
- C_int(abi.vec_elt_data)));
+ C_int(abi::vec_elt_data)));
ret bcx.build.PointerCast(p, T_ptr(T_i8()));
}
@@ -7512,14 +7521,14 @@ fn trans_vec_append_glue(@local_ctxt cx) {
auto llfn = cx.ccx.glues.vec_append_glue;
- let ValueRef lltaskptr = llvm.LLVMGetParam(llfn, 0u);
- let ValueRef llvec_tydesc = llvm.LLVMGetParam(llfn, 1u);
- let ValueRef llelt_tydesc = llvm.LLVMGetParam(llfn, 2u);
- let ValueRef lldst_vec_ptr = llvm.LLVMGetParam(llfn, 3u);
- let ValueRef llsrc_vec = llvm.LLVMGetParam(llfn, 4u);
- let ValueRef llskipnull = llvm.LLVMGetParam(llfn, 5u);
+ let ValueRef lltaskptr = llvm::LLVMGetParam(llfn, 0u);
+ let ValueRef llvec_tydesc = llvm::LLVMGetParam(llfn, 1u);
+ let ValueRef llelt_tydesc = llvm::LLVMGetParam(llfn, 2u);
+ let ValueRef lldst_vec_ptr = llvm::LLVMGetParam(llfn, 3u);
+ let ValueRef llsrc_vec = llvm::LLVMGetParam(llfn, 4u);
+ let ValueRef llskipnull = llvm::LLVMGetParam(llfn, 5u);
auto derived_tydescs =
- Map.mk_hashmap[ty.t, derived_tydesc_info](ty.hash_ty, ty.eq_ty);
+ map::mk_hashmap[ty::t, derived_tydesc_info](ty::hash_ty, ty::eq_ty);
auto llbbs = mk_standard_basic_blocks(llfn);
@@ -7536,7 +7545,7 @@ fn trans_vec_append_glue(@local_ctxt cx) {
llobjfields=new_def_hash[ValueRef](),
lllocals=new_def_hash[ValueRef](),
llupvars=new_def_hash[ValueRef](),
- mutable lltydescs=Vec.empty[ValueRef](),
+ mutable lltydescs=_vec::empty[ValueRef](),
derived_tydescs=derived_tydescs,
lcx=cx);
@@ -7581,13 +7590,13 @@ fn trans_vec_append_glue(@local_ctxt cx) {
auto elt_llsz =
cx.build.Load(cx.build.GEP(elt_tydesc,
vec(C_int(0),
- C_int(abi.tydesc_field_size))));
+ C_int(abi::tydesc_field_size))));
maybe_name_value(cx.fcx.lcx.ccx, elt_llsz, "elt_llsz");
auto elt_llalign =
cx.build.Load(cx.build.GEP(elt_tydesc,
vec(C_int(0),
- C_int(abi.tydesc_field_align))));
+ C_int(abi::tydesc_field_align))));
maybe_name_value(cx.fcx.lcx.ccx, elt_llsz, "elt_llalign");
@@ -7596,7 +7605,7 @@ fn trans_vec_append_glue(@local_ctxt cx) {
ValueRef dst, ValueRef src) -> result {
call_tydesc_glue_full(cx, src,
elt_tydesc,
- abi.tydesc_field_take_glue);
+ abi::tydesc_field_take_glue);
ret res(cx, src);
}
@@ -7648,9 +7657,9 @@ fn trans_vec_append_glue(@local_ctxt cx) {
fn make_glues(ModuleRef llmod, &type_names tn) -> @glue_fns {
- ret @rec(activate_glue = decl_glue(llmod, tn, abi.activate_glue_name()),
- yield_glue = decl_glue(llmod, tn, abi.yield_glue_name()),
- exit_task_glue = decl_cdecl_fn(llmod, abi.exit_task_glue_name(),
+ ret @rec(activate_glue = decl_glue(llmod, tn, abi::activate_glue_name()),
+ yield_glue = decl_glue(llmod, tn, abi::yield_glue_name()),
+ exit_task_glue = decl_cdecl_fn(llmod, abi::exit_task_glue_name(),
T_fn(vec(T_int(),
T_int(),
T_int(),
@@ -7659,65 +7668,66 @@ fn make_glues(ModuleRef llmod, &type_names tn) -> @glue_fns {
T_void())),
native_glues_rust =
- Vec.init_fn[ValueRef](bind decl_native_glue(llmod, tn,
- abi.ngt_rust, _), abi.n_native_glues + 1 as uint),
+ _vec::init_fn[ValueRef](bind decl_native_glue(llmod, tn,
+ abi::ngt_rust, _), abi::n_native_glues + 1 as uint),
native_glues_pure_rust =
- Vec.init_fn[ValueRef](bind decl_native_glue(llmod, tn,
- abi.ngt_pure_rust, _), abi.n_native_glues + 1 as uint),
+ _vec::init_fn[ValueRef](bind decl_native_glue(llmod, tn,
+ abi::ngt_pure_rust, _), abi::n_native_glues + 1 as uint),
native_glues_cdecl =
- Vec.init_fn[ValueRef](bind decl_native_glue(llmod, tn,
- abi.ngt_cdecl, _), abi.n_native_glues + 1 as uint),
+ _vec::init_fn[ValueRef](bind decl_native_glue(llmod, tn,
+ abi::ngt_cdecl, _), abi::n_native_glues + 1 as uint),
no_op_type_glue = decl_no_op_type_glue(llmod, tn),
vec_append_glue = make_vec_append_glue(llmod, tn));
}
-fn make_common_glue(&session.session sess, &str output) {
+fn make_common_glue(&session::session sess, &str output) {
// FIXME: part of this is repetitive and is probably a good idea
// to autogen it.
auto llmod =
- llvm.LLVMModuleCreateWithNameInContext(Str.buf("rust_out"),
- llvm.LLVMGetGlobalContext());
+ llvm::LLVMModuleCreateWithNameInContext(_str::buf("rust_out"),
+ llvm::LLVMGetGlobalContext());
- llvm.LLVMSetDataLayout(llmod, Str.buf(x86.get_data_layout()));
- llvm.LLVMSetTarget(llmod, Str.buf(x86.get_target_triple()));
- auto td = mk_target_data(x86.get_data_layout());
+ llvm::LLVMSetDataLayout(llmod, _str::buf(x86::get_data_layout()));
+ llvm::LLVMSetTarget(llmod, _str::buf(x86::get_target_triple()));
+ auto td = mk_target_data(x86::get_data_layout());
auto tn = mk_type_names();
let ValueRef crate_ptr =
- llvm.LLVMAddGlobal(llmod, T_crate(tn), Str.buf("rust_crate"));
+ llvm::LLVMAddGlobal(llmod, T_crate(tn), _str::buf("rust_crate"));
auto intrinsics = declare_intrinsics(llmod);
- llvm.LLVMSetModuleInlineAsm(llmod, Str.buf(x86.get_module_asm()));
+ llvm::LLVMSetModuleInlineAsm(llmod, _str::buf(x86::get_module_asm()));
auto glues = make_glues(llmod, tn);
create_crate_constant(crate_ptr, glues);
- trans.trans_exit_task_glue(glues, new_str_hash[ValueRef](), tn,
+ trans::trans_exit_task_glue(glues, new_str_hash[ValueRef](), tn,
llmod);
- Link.Write.run_passes(sess, llmod, output);
+ Link::Write::run_passes(sess, llmod, output);
}
fn create_module_map(&@crate_ctxt ccx) -> ValueRef {
auto elttype = T_struct(vec(T_int(), T_int()));
auto maptype = T_array(elttype, ccx.module_data.size() + 1u);
- auto map = llvm.LLVMAddGlobal(ccx.llmod, maptype,
- Str.buf("_rust_mod_map"));
- llvm.LLVMSetLinkage(map, lib.llvm.LLVMInternalLinkage as llvm.Linkage);
+ auto map = llvm::LLVMAddGlobal(ccx.llmod, maptype,
+ _str::buf("_rust_mod_map"));
+ llvm::LLVMSetLinkage(map, lib::llvm::LLVMInternalLinkage
+ as llvm::Linkage);
let vec[ValueRef] elts = vec();
for each (@tup(str, ValueRef) item in ccx.module_data.items()) {
auto elt = C_struct(vec(p2i(C_cstr(ccx, item._0)), p2i(item._1)));
- Vec.push[ValueRef](elts, elt);
+ _vec::push[ValueRef](elts, elt);
}
auto term = C_struct(vec(C_int(0), C_int(0)));
- Vec.push[ValueRef](elts, term);
- llvm.LLVMSetInitializer(map, C_array(elttype, elts));
+ _vec::push[ValueRef](elts, term);
+ llvm::LLVMSetInitializer(map, C_array(elttype, elts));
ret map;
}
fn crate_name(&@crate_ctxt ccx, &str deflt) -> str {
- for (@ast.meta_item item in ccx.sess.get_metadata()) {
- if (Str.eq(item.node.name, "name")) {
+ for (@ast::meta_item item in ccx.sess.get_metadata()) {
+ if (_str::eq(item.node.name, "name")) {
ret item.node.value;
}
}
@@ -7730,47 +7740,48 @@ fn create_crate_map(&@crate_ctxt ccx) -> ValueRef {
auto i = 1;
while (ccx.sess.has_external_crate(i)) {
auto name = ccx.sess.get_external_crate(i).name;
- auto cr = llvm.LLVMAddGlobal(ccx.llmod, T_int(),
- Str.buf("_rust_crate_map_" + name));
- Vec.push[ValueRef](subcrates, p2i(cr));
+ auto cr = llvm::LLVMAddGlobal(ccx.llmod, T_int(),
+ _str::buf("_rust_crate_map_" + name));
+ _vec::push[ValueRef](subcrates, p2i(cr));
i += 1;
}
- Vec.push[ValueRef](subcrates, C_int(0));
+ _vec::push[ValueRef](subcrates, C_int(0));
auto sym_name = "_rust_crate_map_" + crate_name(ccx, "__none__");
- auto arrtype = T_array(T_int(), Vec.len[ValueRef](subcrates));
+ auto arrtype = T_array(T_int(), _vec::len[ValueRef](subcrates));
auto maptype = T_struct(vec(T_int(), arrtype));
- auto map = llvm.LLVMAddGlobal(ccx.llmod, maptype, Str.buf(sym_name));
- llvm.LLVMSetLinkage(map, lib.llvm.LLVMExternalLinkage as llvm.Linkage);
- llvm.LLVMSetInitializer(map, C_struct(vec(p2i(create_module_map(ccx)),
+ auto map = llvm::LLVMAddGlobal(ccx.llmod, maptype, _str::buf(sym_name));
+ llvm::LLVMSetLinkage(map, lib::llvm::LLVMExternalLinkage
+ as llvm::Linkage);
+ llvm::LLVMSetInitializer(map, C_struct(vec(p2i(create_module_map(ccx)),
C_array(T_int(), subcrates))));
ret map;
}
-fn trans_crate(&session.session sess, &@ast.crate crate, &ty.ctxt tcx,
- &ty.type_cache type_cache, &str output)
+fn trans_crate(&session::session sess, &@ast::crate crate, &ty::ctxt tcx,
+ &ty::type_cache type_cache, &str output)
-> ModuleRef {
auto llmod =
- llvm.LLVMModuleCreateWithNameInContext(Str.buf("rust_out"),
- llvm.LLVMGetGlobalContext());
+ llvm::LLVMModuleCreateWithNameInContext(_str::buf("rust_out"),
+ llvm::LLVMGetGlobalContext());
- llvm.LLVMSetDataLayout(llmod, Str.buf(x86.get_data_layout()));
- llvm.LLVMSetTarget(llmod, Str.buf(x86.get_target_triple()));
- auto td = mk_target_data(x86.get_data_layout());
+ llvm::LLVMSetDataLayout(llmod, _str::buf(x86::get_data_layout()));
+ llvm::LLVMSetTarget(llmod, _str::buf(x86::get_target_triple()));
+ auto td = mk_target_data(x86::get_data_layout());
auto tn = mk_type_names();
let ValueRef crate_ptr =
- llvm.LLVMAddGlobal(llmod, T_crate(tn), Str.buf("rust_crate"));
+ llvm::LLVMAddGlobal(llmod, T_crate(tn), _str::buf("rust_crate"));
auto intrinsics = declare_intrinsics(llmod);
auto glues = make_glues(llmod, tn);
- auto hasher = ty.hash_ty;
- auto eqer = ty.eq_ty;
- auto tag_sizes = Map.mk_hashmap[ty.t,uint](hasher, eqer);
- auto tydescs = Map.mk_hashmap[ty.t,@tydesc_info](hasher, eqer);
- auto lltypes = Map.mk_hashmap[ty.t,TypeRef](hasher, eqer);
- auto sha1s = Map.mk_hashmap[ty.t,str](hasher, eqer);
- auto abbrevs = Map.mk_hashmap[ty.t,metadata.ty_abbrev](hasher, eqer);
- auto short_names = Map.mk_hashmap[ty.t,str](hasher, eqer);
+ auto hasher = ty::hash_ty;
+ auto eqer = ty::eq_ty;
+ auto tag_sizes = map::mk_hashmap[ty::t,uint](hasher, eqer);
+ auto tydescs = map::mk_hashmap[ty::t,@tydesc_info](hasher, eqer);
+ auto lltypes = map::mk_hashmap[ty::t,TypeRef](hasher, eqer);
+ auto sha1s = map::mk_hashmap[ty::t,str](hasher, eqer);
+ auto abbrevs = map::mk_hashmap[ty::t,metadata::ty_abbrev](hasher, eqer);
+ auto short_names = map::mk_hashmap[ty::t,str](hasher, eqer);
auto ccx = @rec(sess = sess,
llmod = llmod,
@@ -7780,8 +7791,8 @@ fn trans_crate(&session.session sess, &@ast.crate crate, &ty.ctxt tcx,
externs = new_str_hash[ValueRef](),
intrinsics = intrinsics,
item_ids = new_def_hash[ValueRef](),
- items = new_def_hash[@ast.item](),
- native_items = new_def_hash[@ast.native_item](),
+ items = new_def_hash[@ast::item](),
+ native_items = new_def_hash[@ast::native_item](),
type_cache = type_cache,
item_symbols = new_def_hash[str](),
tag_sizes = tag_sizes,
@@ -7795,12 +7806,12 @@ fn trans_crate(&session.session sess, &@ast.crate crate, &ty.ctxt tcx,
lltypes = lltypes,
glues = glues,
names = namegen(0),
- sha = std.SHA1.mk_sha1(),
+ sha = std::sha1::mk_sha1(),
type_sha1s = sha1s,
type_abbrevs = abbrevs,
type_short_names = short_names,
tcx = tcx,
- upcalls = upcall.declare_upcalls(tn, llmod));
+ upcalls = upcall::declare_upcalls(tn, llmod));
auto cx = new_local_ctxt(ccx);
create_typedefs(ccx);
@@ -7815,8 +7826,8 @@ fn trans_crate(&session.session sess, &@ast.crate crate, &ty.ctxt tcx,
trans_main_fn(cx, crate_ptr, crate_map);
}
- // Translate the metadata.
- middle.metadata.write_metadata(cx.ccx, crate);
+ // Translate the metadata:
+ middle::metadata::write_metadata(cx.ccx, crate);
ret llmod;
}