mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-12 15:52:43 +00:00
Fix warnings in trans
This commit is contained in:
parent
81cf72c264
commit
0b0c756c9c
@ -13,9 +13,7 @@ use core::prelude::*;
|
||||
use core::hashmap::HashMap;
|
||||
use core::libc::{c_uint, c_ushort};
|
||||
use core::option;
|
||||
use core::ptr;
|
||||
use core::str;
|
||||
use core::vec;
|
||||
|
||||
use middle::trans::type_::Type;
|
||||
|
||||
|
@ -30,7 +30,7 @@ use back::{link, abi};
|
||||
use driver::session;
|
||||
use driver::session::Session;
|
||||
use lib::llvm::{ContextRef, ModuleRef, ValueRef, BasicBlockRef};
|
||||
use lib::llvm::{llvm, True, False};
|
||||
use lib::llvm::{llvm, True};
|
||||
use lib;
|
||||
use metadata::common::LinkMeta;
|
||||
use metadata::{csearch, cstore, encoder};
|
||||
@ -1462,7 +1462,7 @@ pub fn zero_mem(cx: block, llptr: ValueRef, t: ty::t) {
|
||||
// allocation for large data structures, and the generated code will be
|
||||
// awful. (A telltale sign of this is large quantities of
|
||||
// `mov [byte ptr foo],0` in the generated code.)
|
||||
pub fn memzero(cx: block, llptr: ValueRef, llty: TypeRef) {
|
||||
pub fn memzero(cx: block, llptr: ValueRef, ty: Type) {
|
||||
let _icx = cx.insn_ctxt("memzero");
|
||||
let ccx = cx.ccx();
|
||||
|
||||
@ -1493,7 +1493,7 @@ pub fn alloca(cx: block, ty: Type) -> ValueRef {
|
||||
alloca_maybe_zeroed(cx, ty, false)
|
||||
}
|
||||
|
||||
pub fn alloca_maybe_zeroed(cx: block, t: TypeRef, zero: bool) -> ValueRef {
|
||||
pub fn alloca_maybe_zeroed(cx: block, ty: Type, zero: bool) -> ValueRef {
|
||||
let _icx = cx.insn_ctxt("alloca");
|
||||
if cx.unreachable {
|
||||
unsafe {
|
||||
@ -1506,7 +1506,7 @@ pub fn alloca_maybe_zeroed(cx: block, t: TypeRef, zero: bool) -> ValueRef {
|
||||
p
|
||||
}
|
||||
|
||||
pub fn arrayalloca(cx: block, t: TypeRef, v: ValueRef) -> ValueRef {
|
||||
pub fn arrayalloca(cx: block, ty: Type, v: ValueRef) -> ValueRef {
|
||||
let _icx = cx.insn_ctxt("arrayalloca");
|
||||
if cx.unreachable {
|
||||
unsafe {
|
||||
@ -2885,8 +2885,7 @@ pub fn write_metadata(cx: &mut CrateContext, crate: &ast::crate) {
|
||||
|
||||
// Writes the current ABI version into the crate.
|
||||
pub fn write_abi_version(ccx: &mut CrateContext) {
|
||||
mk_global(ccx, "rust_abi_version", C_uint(ccx, abi::abi_version),
|
||||
false);
|
||||
mk_global(ccx, "rust_abi_version", C_uint(ccx, abi::abi_version), false);
|
||||
}
|
||||
|
||||
pub fn trans_crate(sess: session::Session,
|
||||
|
@ -22,8 +22,8 @@ use syntax::codemap::span;
|
||||
use middle::trans::type_::Type;
|
||||
|
||||
use core::cast;
|
||||
use core::hashmap::HashMap;
|
||||
use core::libc::{c_uint, c_ulonglong, c_char};
|
||||
use core::hashmap::HashMap;
|
||||
use core::str;
|
||||
use core::vec;
|
||||
|
||||
@ -619,15 +619,12 @@ pub fn GEPi(cx: block, base: ValueRef, ixs: &[uint]) -> ValueRef {
|
||||
return InBoundsGEP(cx, base, v);
|
||||
}
|
||||
|
||||
pub fn InBoundsGEP(cx: block, Pointer: ValueRef, Indices: &[ValueRef]) ->
|
||||
ValueRef {
|
||||
pub fn InBoundsGEP(cx: block, Pointer: ValueRef, Indices: &[ValueRef]) -> ValueRef {
|
||||
unsafe {
|
||||
if cx.unreachable { return llvm::LLVMGetUndef(Type::nil().ptr_to().to_ref()); }
|
||||
count_insn(cx, "inboundsgep");
|
||||
return llvm::LLVMBuildInBoundsGEP(B(cx), Pointer,
|
||||
vec::raw::to_ptr(Indices),
|
||||
Indices.len() as c_uint,
|
||||
noname());
|
||||
return llvm::LLVMBuildInBoundsGEP(
|
||||
B(cx), Pointer, vec::raw::to_ptr(Indices), Indices.len() as c_uint, noname());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1077,8 +1074,7 @@ pub fn Trap(cx: block) {
|
||||
assert!((T as int != 0));
|
||||
let Args: ~[ValueRef] = ~[];
|
||||
count_insn(cx, "trap");
|
||||
llvm::LLVMBuildCall(b, T, vec::raw::to_ptr(Args),
|
||||
Args.len() as c_uint, noname());
|
||||
llvm::LLVMBuildCall(b, T, vec::raw::to_ptr(Args), Args.len() as c_uint, noname());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1088,8 +1084,8 @@ pub fn LandingPad(cx: block, Ty: Type, PersFn: ValueRef,
|
||||
check_not_terminated(cx);
|
||||
assert!(!cx.unreachable);
|
||||
count_insn(cx, "landingpad");
|
||||
return llvm::LLVMBuildLandingPad(B(cx), Ty.to_ref(), PersFn,
|
||||
NumClauses as c_uint, noname());
|
||||
return llvm::LLVMBuildLandingPad(
|
||||
B(cx), Ty.to_ref(), PersFn, NumClauses as c_uint, noname());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
use lib::llvm::{llvm, Integer, Pointer, Float, Double, Struct, Array};
|
||||
use lib::llvm::{Attribute, StructRetAttribute};
|
||||
use lib::llvm::True;
|
||||
use middle::trans::cabi::{ABIInfo, FnType, LLVMType};
|
||||
|
||||
use middle::trans::type_::Type;
|
||||
@ -116,14 +115,12 @@ fn classify_arg_ty(ty: Type) -> (LLVMType, Option<Attribute>) {
|
||||
}
|
||||
|
||||
fn is_reg_ty(ty: Type) -> bool {
|
||||
unsafe {
|
||||
match ty.kind() {
|
||||
Integer
|
||||
| Pointer
|
||||
| Float
|
||||
| Double => true,
|
||||
_ => false
|
||||
}
|
||||
match ty.kind() {
|
||||
Integer
|
||||
| Pointer
|
||||
| Float
|
||||
| Double => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,14 +11,11 @@
|
||||
use core::prelude::*;
|
||||
|
||||
use core::libc::c_uint;
|
||||
use core::ptr;
|
||||
use core::uint;
|
||||
use core::vec;
|
||||
use lib::llvm::{llvm, Integer, Pointer, Float, Double, Struct, Array};
|
||||
use lib::llvm::{Attribute, StructRetAttribute};
|
||||
use lib::llvm::True;
|
||||
use middle::trans::context::task_llcx;
|
||||
use middle::trans::common::*;
|
||||
use middle::trans::cabi::*;
|
||||
|
||||
use middle::trans::type_::Type;
|
||||
@ -122,15 +119,13 @@ fn classify_arg_ty(ty: Type, offset: &mut uint) -> (LLVMType, Option<Attribute>)
|
||||
}
|
||||
|
||||
fn is_reg_ty(ty: Type) -> bool {
|
||||
unsafe {
|
||||
return match ty.kind() {
|
||||
Integer
|
||||
| Pointer
|
||||
| Float
|
||||
| Double => true,
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
return match ty.kind() {
|
||||
Integer
|
||||
| Pointer
|
||||
| Float
|
||||
| Double => true,
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
|
||||
fn padding_ty(align: uint, offset: uint) -> Option<Type> {
|
||||
|
@ -12,7 +12,6 @@ use core::prelude::*;
|
||||
|
||||
use driver::session::{os_win32, os_macos};
|
||||
use lib::llvm::*;
|
||||
use lib::llvm::llvm::*;
|
||||
use super::cabi::*;
|
||||
use super::common::*;
|
||||
use super::machine::*;
|
||||
@ -43,7 +42,7 @@ impl ABIInfo for X86_ABIInfo {
|
||||
// http://www.angelcode.com/dev/callconv/callconv.html
|
||||
// Clang's ABI handling is in lib/CodeGen/TargetInfo.cpp
|
||||
let sret = {
|
||||
let returning_a_struct = unsafe { rty.kind() == Struct && ret_def };
|
||||
let returning_a_struct = rty.kind() == Struct && ret_def;
|
||||
let big_struct = match self.ccx.sess.targ_cfg.os {
|
||||
os_win32 | os_macos => llsize_of_alloc(self.ccx, rty) > 8,
|
||||
_ => true
|
||||
|
@ -14,13 +14,10 @@
|
||||
use lib::llvm::{llvm, Integer, Pointer, Float, Double};
|
||||
use lib::llvm::{Struct, Array, Attribute};
|
||||
use lib::llvm::{StructRetAttribute, ByValAttribute};
|
||||
use lib::llvm::True;
|
||||
use middle::trans::common::*;
|
||||
use middle::trans::cabi::*;
|
||||
|
||||
use middle::trans::type_::Type;
|
||||
|
||||
use core::libc::c_uint;
|
||||
use core::option;
|
||||
use core::option::Option;
|
||||
use core::uint;
|
||||
@ -189,98 +186,94 @@ fn classify_ty(ty: Type) -> ~[RegClass] {
|
||||
fn classify(ty: Type,
|
||||
cls: &mut [RegClass], ix: uint,
|
||||
off: uint) {
|
||||
unsafe {
|
||||
let t_align = ty_align(ty);
|
||||
let t_size = ty_size(ty);
|
||||
let t_align = ty_align(ty);
|
||||
let t_size = ty_size(ty);
|
||||
|
||||
let misalign = off % t_align;
|
||||
if misalign != 0u {
|
||||
let mut i = off / 8u;
|
||||
let e = (off + t_size + 7u) / 8u;
|
||||
while i < e {
|
||||
unify(cls, ix + i, Memory);
|
||||
let misalign = off % t_align;
|
||||
if misalign != 0u {
|
||||
let mut i = off / 8u;
|
||||
let e = (off + t_size + 7u) / 8u;
|
||||
while i < e {
|
||||
unify(cls, ix + i, Memory);
|
||||
i += 1u;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
match ty.kind() {
|
||||
Integer |
|
||||
Pointer => {
|
||||
unify(cls, ix + off / 8u, Int);
|
||||
}
|
||||
Float => {
|
||||
if off % 8u == 4u {
|
||||
unify(cls, ix + off / 8u, SSEFv);
|
||||
} else {
|
||||
unify(cls, ix + off / 8u, SSEFs);
|
||||
}
|
||||
}
|
||||
Double => {
|
||||
unify(cls, ix + off / 8u, SSEDs);
|
||||
}
|
||||
Struct => {
|
||||
classify_struct(ty.field_types(), cls, ix, off);
|
||||
}
|
||||
Array => {
|
||||
let len = ty.array_length();
|
||||
let elt = ty.element_type();
|
||||
let eltsz = ty_size(elt);
|
||||
let mut i = 0u;
|
||||
while i < len {
|
||||
classify(elt, cls, ix, off + i * eltsz);
|
||||
i += 1u;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
match ty.kind() {
|
||||
Integer |
|
||||
Pointer => {
|
||||
unify(cls, ix + off / 8u, Int);
|
||||
}
|
||||
Float => {
|
||||
if off % 8u == 4u {
|
||||
unify(cls, ix + off / 8u, SSEFv);
|
||||
} else {
|
||||
unify(cls, ix + off / 8u, SSEFs);
|
||||
}
|
||||
}
|
||||
Double => {
|
||||
unify(cls, ix + off / 8u, SSEDs);
|
||||
}
|
||||
Struct => {
|
||||
classify_struct(ty.field_types(), cls, ix, off);
|
||||
}
|
||||
Array => {
|
||||
let len = ty.array_length();
|
||||
let elt = ty.element_type();
|
||||
let eltsz = ty_size(elt);
|
||||
let mut i = 0u;
|
||||
while i < len {
|
||||
classify(elt, cls, ix, off + i * eltsz);
|
||||
i += 1u;
|
||||
}
|
||||
}
|
||||
_ => fail!("classify: unhandled type")
|
||||
}
|
||||
_ => fail!("classify: unhandled type")
|
||||
}
|
||||
}
|
||||
|
||||
fn fixup(ty: Type, cls: &mut [RegClass]) {
|
||||
unsafe {
|
||||
let mut i = 0u;
|
||||
let ty_kind = ty.kind();
|
||||
let e = cls.len();
|
||||
if cls.len() > 2u &&
|
||||
(ty_kind == Struct ||
|
||||
ty_kind == Array) {
|
||||
if cls[i].is_sse() {
|
||||
i += 1u;
|
||||
while i < e {
|
||||
if cls[i] != SSEUp {
|
||||
all_mem(cls);
|
||||
return;
|
||||
}
|
||||
i += 1u;
|
||||
let mut i = 0u;
|
||||
let ty_kind = ty.kind();
|
||||
let e = cls.len();
|
||||
if cls.len() > 2u &&
|
||||
(ty_kind == Struct ||
|
||||
ty_kind == Array) {
|
||||
if cls[i].is_sse() {
|
||||
i += 1u;
|
||||
while i < e {
|
||||
if cls[i] != SSEUp {
|
||||
all_mem(cls);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
all_mem(cls);
|
||||
return
|
||||
i += 1u;
|
||||
}
|
||||
} else {
|
||||
while i < e {
|
||||
if cls[i] == Memory {
|
||||
all_mem(cls);
|
||||
return;
|
||||
}
|
||||
if cls[i] == X87Up {
|
||||
// for darwin
|
||||
// cls[i] = SSEDs;
|
||||
all_mem(cls);
|
||||
return;
|
||||
}
|
||||
if cls[i] == SSEUp {
|
||||
cls[i] = SSEInt;
|
||||
} else if cls[i].is_sse() {
|
||||
i += 1;
|
||||
while i != e && cls[i] == SSEUp { i += 1u; }
|
||||
} else if cls[i] == X87 {
|
||||
i += 1;
|
||||
while i != e && cls[i] == X87Up { i += 1u; }
|
||||
} else {
|
||||
i += 1;
|
||||
}
|
||||
all_mem(cls);
|
||||
return
|
||||
}
|
||||
} else {
|
||||
while i < e {
|
||||
if cls[i] == Memory {
|
||||
all_mem(cls);
|
||||
return;
|
||||
}
|
||||
if cls[i] == X87Up {
|
||||
// for darwin
|
||||
// cls[i] = SSEDs;
|
||||
all_mem(cls);
|
||||
return;
|
||||
}
|
||||
if cls[i] == SSEUp {
|
||||
cls[i] = SSEInt;
|
||||
} else if cls[i].is_sse() {
|
||||
i += 1;
|
||||
while i != e && cls[i] == SSEUp { i += 1u; }
|
||||
} else if cls[i] == X87 {
|
||||
i += 1;
|
||||
while i != e && cls[i] == X87Up { i += 1u; }
|
||||
} else {
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -310,34 +303,32 @@ fn llreg_ty(cls: &[RegClass]) -> Type {
|
||||
return len;
|
||||
}
|
||||
|
||||
unsafe {
|
||||
let mut tys = ~[];
|
||||
let mut i = 0u;
|
||||
let e = cls.len();
|
||||
while i < e {
|
||||
match cls[i] {
|
||||
Int => {
|
||||
tys.push(Type::i64());
|
||||
}
|
||||
SSEFv => {
|
||||
let vec_len = llvec_len(vec::tailn(cls, i + 1u)) * 2u;
|
||||
let vec_ty = Type::vector(&Type::f32(), vec_len as u64);
|
||||
tys.push(vec_ty);
|
||||
i += vec_len;
|
||||
loop;
|
||||
}
|
||||
SSEFs => {
|
||||
tys.push(Type::f32());
|
||||
}
|
||||
SSEDs => {
|
||||
tys.push(Type::f64());
|
||||
}
|
||||
_ => fail!("llregtype: unhandled class")
|
||||
let mut tys = ~[];
|
||||
let mut i = 0u;
|
||||
let e = cls.len();
|
||||
while i < e {
|
||||
match cls[i] {
|
||||
Int => {
|
||||
tys.push(Type::i64());
|
||||
}
|
||||
i += 1u;
|
||||
SSEFv => {
|
||||
let vec_len = llvec_len(vec::tailn(cls, i + 1u)) * 2u;
|
||||
let vec_ty = Type::vector(&Type::f32(), vec_len as u64);
|
||||
tys.push(vec_ty);
|
||||
i += vec_len;
|
||||
loop;
|
||||
}
|
||||
SSEFs => {
|
||||
tys.push(Type::f32());
|
||||
}
|
||||
SSEDs => {
|
||||
tys.push(Type::f64());
|
||||
}
|
||||
_ => fail!("llregtype: unhandled class")
|
||||
}
|
||||
return Type::struct_(tys, false);
|
||||
i += 1u;
|
||||
}
|
||||
return Type::struct_(tys, false);
|
||||
}
|
||||
|
||||
fn x86_64_tys(atys: &[Type],
|
||||
|
@ -12,18 +12,16 @@
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use back::{abi};
|
||||
use driver::session;
|
||||
use driver::session::Session;
|
||||
use lib::llvm::{ValueRef, TypeRef, BasicBlockRef, BuilderRef};
|
||||
use lib::llvm::{ValueRef, BasicBlockRef, BuilderRef};
|
||||
use lib::llvm::{True, False, Bool};
|
||||
use lib::llvm::{llvm, TypeNames};
|
||||
use lib::llvm::{llvm};
|
||||
use lib;
|
||||
use middle::trans::base;
|
||||
use middle::trans::build;
|
||||
use middle::trans::datum;
|
||||
use middle::trans::glue;
|
||||
use middle::trans::type_of;
|
||||
use middle::trans::write_guard;
|
||||
use middle::ty::substs;
|
||||
use middle::ty;
|
||||
@ -37,16 +35,13 @@ use core::cast::transmute;
|
||||
use core::cast;
|
||||
use core::hashmap::{HashMap};
|
||||
use core::libc::{c_uint, c_longlong, c_ulonglong};
|
||||
use core::str;
|
||||
use core::to_bytes;
|
||||
use core::vec::raw::to_ptr;
|
||||
use core::vec;
|
||||
use syntax::ast::ident;
|
||||
use syntax::ast_map::{path, path_elt};
|
||||
use syntax::codemap::span;
|
||||
use syntax::parse::token;
|
||||
use syntax::{ast, ast_map};
|
||||
use syntax::abi::{X86, X86_64, Arm, Mips};
|
||||
|
||||
pub use middle::trans::context::CrateContext;
|
||||
|
||||
|
@ -11,8 +11,7 @@
|
||||
use core::prelude::*;
|
||||
|
||||
use back::abi;
|
||||
use lib::llvm::{llvm, ConstFCmp, ConstICmp, SetLinkage, PrivateLinkage, ValueRef, Bool,
|
||||
True, False};
|
||||
use lib::llvm::{llvm, ConstFCmp, ConstICmp, SetLinkage, PrivateLinkage, ValueRef, Bool, True};
|
||||
use lib::llvm::{IntEQ, IntNE, IntUGT, IntUGE, IntULT, IntULE, IntSGT, IntSGE, IntSLT, IntSLE,
|
||||
RealOEQ, RealOGT, RealOGE, RealOLT, RealOLE, RealONE};
|
||||
|
||||
|
@ -15,7 +15,6 @@ use driver::session;
|
||||
use lib::llvm::{ContextRef, ModuleRef, ValueRef};
|
||||
use lib::llvm::{llvm, TargetData, TypeNames};
|
||||
use lib::llvm::{mk_target_data};
|
||||
use lib;
|
||||
use metadata::common::LinkMeta;
|
||||
use middle::astencode;
|
||||
use middle::resolve;
|
||||
|
@ -693,7 +693,7 @@ fn set_debug_location(cx: @mut CrateContext, scope: DIScope, line: uint, col: ui
|
||||
}
|
||||
|
||||
/// Set current debug location at the beginning of the span
|
||||
pub fn update_source_pos(bcx: block, span: span) {
|
||||
pub fn update_source_pos(bcx: @mut Block, span: span) {
|
||||
if !bcx.sess().opts.debuginfo || (*span.lo == 0 && *span.hi == 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -217,23 +217,21 @@ fn build_wrap_fn_(ccx: @mut CrateContext,
|
||||
tie_up_header_blocks(fcx, lltop);
|
||||
|
||||
// Then return according to the C ABI.
|
||||
unsafe {
|
||||
let return_context = raw_block(fcx, false, fcx.llreturn);
|
||||
let return_context = raw_block(fcx, false, fcx.llreturn);
|
||||
|
||||
let llfunctiontype = val_ty(llwrapfn);
|
||||
let llfunctiontype = llfunctiontype.element_type();
|
||||
let return_type = llfunctiontype.return_type();
|
||||
if return_type.kind() == ::lib::llvm::Void {
|
||||
// XXX: This might be wrong if there are any functions for which
|
||||
// the C ABI specifies a void output pointer and the Rust ABI
|
||||
// does not.
|
||||
RetVoid(return_context);
|
||||
} else {
|
||||
// Cast if we have to...
|
||||
// XXX: This is ugly.
|
||||
let llretptr = BitCast(return_context, fcx.llretptr.get(), return_type.ptr_to());
|
||||
Ret(return_context, Load(return_context, llretptr));
|
||||
}
|
||||
let llfunctiontype = val_ty(llwrapfn);
|
||||
let llfunctiontype = llfunctiontype.element_type();
|
||||
let return_type = llfunctiontype.return_type();
|
||||
if return_type.kind() == ::lib::llvm::Void {
|
||||
// XXX: This might be wrong if there are any functions for which
|
||||
// the C ABI specifies a void output pointer and the Rust ABI
|
||||
// does not.
|
||||
RetVoid(return_context);
|
||||
} else {
|
||||
// Cast if we have to...
|
||||
// XXX: This is ugly.
|
||||
let llretptr = BitCast(return_context, fcx.llretptr.get(), return_type.ptr_to());
|
||||
Ret(return_context, Load(return_context, llretptr));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
// Information concerning the machine representation of various types.
|
||||
|
||||
use lib::llvm::{ValueRef, TypeRef};
|
||||
use lib::llvm::{ValueRef};
|
||||
use lib::llvm::False;
|
||||
use lib::llvm::llvm;
|
||||
use middle::trans::common::*;
|
||||
|
@ -15,7 +15,6 @@
|
||||
use lib::llvm::llvm;
|
||||
use lib::llvm::{True, ModuleRef, ValueRef};
|
||||
use middle::trans::common::*;
|
||||
use middle::trans;
|
||||
|
||||
use middle::trans::type_::Type;
|
||||
|
||||
@ -62,16 +61,3 @@ pub fn mk_ctxt(llmod: ModuleRef) -> Ctxt {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Although these two functions are never called, they are here
|
||||
for a VERY GOOD REASON. See #3670
|
||||
pub fn add_u16(dest: &mut ~[u8], val: u16) {
|
||||
*dest += [(val & 0xffu16) as u8, (val >> 8u16) as u8];
|
||||
}
|
||||
|
||||
pub fn add_substr(dest: &mut ~[u8], src: ~[u8]) {
|
||||
add_u16(&mut *dest, src.len() as u16);
|
||||
*dest += src;
|
||||
}
|
||||
*/
|
||||
|
@ -350,9 +350,7 @@ impl Type {
|
||||
}
|
||||
|
||||
pub fn return_type(&self) -> Type {
|
||||
unsafe {
|
||||
ty!(llvm::LLVMGetReturnType(self.to_ref()))
|
||||
}
|
||||
ty!(llvm::LLVMGetReturnType(self.to_ref()))
|
||||
}
|
||||
|
||||
pub fn func_params(&self) -> ~[Type] {
|
||||
|
@ -10,11 +10,8 @@
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use lib::llvm::llvm;
|
||||
use middle::trans::adt;
|
||||
use middle::trans::base;
|
||||
use middle::trans::common::*;
|
||||
use middle::trans::common;
|
||||
use middle::ty;
|
||||
use util::ppaux;
|
||||
|
||||
@ -40,36 +37,28 @@ pub fn type_of_explicit_args(ccx: &mut CrateContext,
|
||||
inputs.map(|arg_ty| type_of_explicit_arg(ccx, arg_ty))
|
||||
}
|
||||
|
||||
pub fn type_of_fn(cx: &mut CrateContext, inputs: &[ty::t], output: ty::t)
|
||||
-> Type {
|
||||
unsafe {
|
||||
let mut atys: ~[Type] = ~[];
|
||||
pub fn type_of_fn(cx: &mut CrateContext, inputs: &[ty::t], output: ty::t) -> Type {
|
||||
let mut atys: ~[Type] = ~[];
|
||||
|
||||
// Arg 0: Output pointer.
|
||||
// (if the output type is non-immediate)
|
||||
let output_is_immediate = ty::type_is_immediate(output);
|
||||
let lloutputtype = type_of(cx, output);
|
||||
if !output_is_immediate {
|
||||
atys.push(lloutputtype.ptr_to());
|
||||
}
|
||||
// Arg 0: Output pointer.
|
||||
// (if the output type is non-immediate)
|
||||
let output_is_immediate = ty::type_is_immediate(output);
|
||||
let lloutputtype = type_of(cx, output);
|
||||
if !output_is_immediate {
|
||||
atys.push(lloutputtype.ptr_to());
|
||||
}
|
||||
|
||||
// Arg 1: Environment
|
||||
atys.push(Type::opaque_box(cx).ptr_to());
|
||||
// Arg 1: Environment
|
||||
atys.push(Type::opaque_box(cx).ptr_to());
|
||||
|
||||
// ... then explicit args.
|
||||
atys.push_all(type_of_explicit_args(cx, inputs));
|
||||
// ... then explicit args.
|
||||
atys.push_all(type_of_explicit_args(cx, inputs));
|
||||
|
||||
// Use the output as the actual return value if it's immediate.
|
||||
<<<<<<< HEAD
|
||||
if output_is_immediate && !ty::type_is_nil(output) {
|
||||
Type::func(atys, lloutputtype)
|
||||
=======
|
||||
if output_is_immediate {
|
||||
Type::func(atys, &lloutputtype)
|
||||
>>>>>>> Finish up Type refactoring
|
||||
} else {
|
||||
Type::func(atys, &Type::void())
|
||||
}
|
||||
// Use the output as the actual return value if it's immediate.
|
||||
if output_is_immediate && !ty::type_is_nil(output) {
|
||||
Type::func(atys, &lloutputtype)
|
||||
} else {
|
||||
Type::func(atys, &Type::void())
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user