1
Fork 0

librustc: Get rid of structural records save for front/test.rs.

This commit is contained in:
Luqman Aden 2013-02-19 02:40:42 -05:00 committed by Tim Chevalier
parent 8f8f0ec2c6
commit cd82c4566b
67 changed files with 1483 additions and 1115 deletions

View file

@ -1298,32 +1298,36 @@ pub fn SetLinkage(Global: ValueRef, Link: Linkage) {
/* Memory-managed object interface to type handles. */
pub type type_names = @{type_names: HashMap<TypeRef, @str>,
named_types: HashMap<@str, TypeRef>};
pub struct TypeNames {
type_names: HashMap<TypeRef, @str>,
named_types: HashMap<@str, TypeRef>
}
pub fn associate_type(tn: type_names, s: @str, t: TypeRef) {
pub fn associate_type(tn: @TypeNames, s: @str, t: TypeRef) {
assert tn.type_names.insert(t, s);
assert tn.named_types.insert(s, t);
}
pub fn type_has_name(tn: type_names, t: TypeRef) -> Option<@str> {
pub fn type_has_name(tn: @TypeNames, t: TypeRef) -> Option<@str> {
return tn.type_names.find(&t);
}
pub fn name_has_type(tn: type_names, s: @str) -> Option<TypeRef> {
pub fn name_has_type(tn: @TypeNames, s: @str) -> Option<TypeRef> {
return tn.named_types.find(&s);
}
pub fn mk_type_names() -> type_names {
@{type_names: HashMap(),
named_types: HashMap()}
pub fn mk_type_names() -> @TypeNames {
@TypeNames {
type_names: HashMap(),
named_types: HashMap()
}
}
pub fn type_to_str(names: type_names, ty: TypeRef) -> @str {
pub fn type_to_str(names: @TypeNames, ty: TypeRef) -> @str {
return type_to_str_inner(names, [], ty);
}
pub fn type_to_str_inner(names: type_names, +outer0: &[TypeRef], ty: TypeRef)
pub fn type_to_str_inner(names: @TypeNames, +outer0: &[TypeRef], ty: TypeRef)
-> @str {
unsafe {
match type_has_name(names, ty) {
@ -1335,7 +1339,7 @@ pub fn type_to_str_inner(names: type_names, +outer0: &[TypeRef], ty: TypeRef)
let kind = llvm::LLVMGetTypeKind(ty);
fn tys_str(names: type_names, outer: &[TypeRef],
fn tys_str(names: @TypeNames, outer: &[TypeRef],
tys: ~[TypeRef]) -> @str {
let mut s = ~"";
let mut first: bool = true;
@ -1473,14 +1477,21 @@ pub fn target_data_res(TD: TargetDataRef) -> target_data_res {
}
}
pub type target_data = {lltd: TargetDataRef, dtor: @target_data_res};
pub struct TargetData {
lltd: TargetDataRef,
dtor: @target_data_res
}
pub fn mk_target_data(string_rep: ~str) -> target_data {
pub fn mk_target_data(string_rep: ~str) -> TargetData {
let lltd =
str::as_c_str(string_rep, |buf| unsafe {
llvm::LLVMCreateTargetData(buf)
});
return {lltd: lltd, dtor: @target_data_res(lltd)};
TargetData {
lltd: lltd,
dtor: @target_data_res(lltd)
}
}
/* Memory-managed interface to pass managers. */
@ -1500,12 +1511,19 @@ pub fn pass_manager_res(PM: PassManagerRef) -> pass_manager_res {
}
}
pub type pass_manager = {llpm: PassManagerRef, dtor: @pass_manager_res};
pub struct PassManager {
llpm: PassManagerRef,
dtor: @pass_manager_res
}
pub fn mk_pass_manager() -> pass_manager {
pub fn mk_pass_manager() -> PassManager {
unsafe {
let llpm = llvm::LLVMCreatePassManager();
return {llpm: llpm, dtor: @pass_manager_res(llpm)};
PassManager {
llpm: llpm,
dtor: @pass_manager_res(llpm)
}
}
}
@ -1526,13 +1544,20 @@ pub fn object_file_res(ObjFile: ObjectFileRef) -> object_file_res {
}
}
pub type object_file = {llof: ObjectFileRef, dtor: @object_file_res};
pub struct ObjectFile {
llof: ObjectFileRef,
dtor: @object_file_res
}
pub fn mk_object_file(llmb: MemoryBufferRef) -> Option<object_file> {
pub fn mk_object_file(llmb: MemoryBufferRef) -> Option<ObjectFile> {
unsafe {
let llof = llvm::LLVMCreateObjectFile(llmb);
if llof as int == 0 { return option::None::<object_file>; }
return option::Some({llof: llof, dtor: @object_file_res(llof)});
if llof as int == 0 { return option::None::<ObjectFile>; }
option::Some(ObjectFile {
llof: llof,
dtor: @object_file_res(llof)
})
}
}
@ -1553,12 +1578,18 @@ pub fn section_iter_res(SI: SectionIteratorRef) -> section_iter_res {
}
}
pub type section_iter = {llsi: SectionIteratorRef, dtor: @section_iter_res};
pub struct SectionIter {
llsi: SectionIteratorRef,
dtor: @section_iter_res
}
pub fn mk_section_iter(llof: ObjectFileRef) -> section_iter {
pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter {
unsafe {
let llsi = llvm::LLVMGetSections(llof);
return {llsi: llsi, dtor: @section_iter_res(llsi)};
SectionIter {
llsi: llsi,
dtor: @section_iter_res(llsi)
}
}
}