|
| 1 | +use core::prelude::*; |
| 2 | + |
| 3 | +use back::{abi, upcall}; |
| 4 | +use driver::session; |
| 5 | +use driver::session::Session; |
| 6 | +use lib::llvm::{ModuleRef, ValueRef, TypeRef, BasicBlockRef, BuilderRef}; |
| 7 | +use lib::llvm::{ContextRef, True, False, Bool}; |
| 8 | +use lib::llvm::{llvm, TargetData, TypeNames, associate_type, name_has_type}; |
| 9 | +use lib; |
| 10 | +use metadata::common::LinkMeta; |
| 11 | +use middle::astencode; |
| 12 | +use middle::resolve; |
| 13 | +use middle::trans::adt; |
| 14 | +use middle::trans::base; |
| 15 | +use middle::trans::build; |
| 16 | +use middle::trans::datum; |
| 17 | +use middle::trans::debuginfo; |
| 18 | +use middle::trans::glue; |
| 19 | +use middle::trans::reachable; |
| 20 | +use middle::trans::shape; |
| 21 | +use middle::trans::type_of; |
| 22 | +use middle::trans::type_use; |
| 23 | +use middle::trans::write_guard; |
| 24 | +use middle::ty::substs; |
| 25 | +use middle::ty; |
| 26 | +use middle::typeck; |
| 27 | +use middle::borrowck::root_map_key; |
| 28 | + |
| 29 | +use core::cast::transmute; |
| 30 | +use core::cast; |
| 31 | +use core::hash; |
| 32 | +use core::hashmap::{HashMap, HashSet}; |
| 33 | +use core::libc::{c_uint, c_longlong, c_ulonglong}; |
| 34 | +use core::str; |
| 35 | +use core::to_bytes; |
| 36 | +use core::vec::raw::to_ptr; |
| 37 | +use core::vec; |
| 38 | +use syntax::ast::ident; |
| 39 | +use syntax::ast_map::{path, path_elt}; |
| 40 | +use syntax::codemap::span; |
| 41 | +use syntax::parse::token; |
| 42 | +use syntax::{ast, ast_map}; |
| 43 | +use syntax::abi::{X86, X86_64, Arm, Mips}; |
| 44 | + |
| 45 | +use middle::trans::common::{ExternMap,tydesc_info,BuilderRef_res,Stats,namegen,addrspace_gen}; |
| 46 | +use middle::trans::common::{mono_id}; |
| 47 | + |
| 48 | +pub struct CrateContext { |
| 49 | + sess: session::Session, |
| 50 | + llmod: ModuleRef, |
| 51 | + llcx: ContextRef, |
| 52 | + td: TargetData, |
| 53 | + tn: @TypeNames, |
| 54 | + externs: ExternMap, |
| 55 | + intrinsics: HashMap<&'static str, ValueRef>, |
| 56 | + item_vals: @mut HashMap<ast::node_id, ValueRef>, |
| 57 | + exp_map2: resolve::ExportMap2, |
| 58 | + reachable: reachable::map, |
| 59 | + item_symbols: @mut HashMap<ast::node_id, ~str>, |
| 60 | + link_meta: LinkMeta, |
| 61 | + enum_sizes: @mut HashMap<ty::t, uint>, |
| 62 | + discrims: @mut HashMap<ast::def_id, ValueRef>, |
| 63 | + discrim_symbols: @mut HashMap<ast::node_id, @str>, |
| 64 | + tydescs: @mut HashMap<ty::t, @mut tydesc_info>, |
| 65 | + // Set when running emit_tydescs to enforce that no more tydescs are |
| 66 | + // created. |
| 67 | + finished_tydescs: @mut bool, |
| 68 | + // Track mapping of external ids to local items imported for inlining |
| 69 | + external: @mut HashMap<ast::def_id, Option<ast::node_id>>, |
| 70 | + // Cache instances of monomorphized functions |
| 71 | + monomorphized: @mut HashMap<mono_id, ValueRef>, |
| 72 | + monomorphizing: @mut HashMap<ast::def_id, uint>, |
| 73 | + // Cache computed type parameter uses (see type_use.rs) |
| 74 | + type_use_cache: @mut HashMap<ast::def_id, @~[type_use::type_uses]>, |
| 75 | + // Cache generated vtables |
| 76 | + vtables: @mut HashMap<mono_id, ValueRef>, |
| 77 | + // Cache of constant strings, |
| 78 | + const_cstr_cache: @mut HashMap<@str, ValueRef>, |
| 79 | + |
| 80 | + // Reverse-direction for const ptrs cast from globals. |
| 81 | + // Key is an int, cast from a ValueRef holding a *T, |
| 82 | + // Val is a ValueRef holding a *[T]. |
| 83 | + // |
| 84 | + // Needed because LLVM loses pointer->pointee association |
| 85 | + // when we ptrcast, and we have to ptrcast during translation |
| 86 | + // of a [T] const because we form a slice, a [*T,int] pair, not |
| 87 | + // a pointer to an LLVM array type. |
| 88 | + const_globals: @mut HashMap<int, ValueRef>, |
| 89 | + |
| 90 | + // Cache of emitted const values |
| 91 | + const_values: @mut HashMap<ast::node_id, ValueRef>, |
| 92 | + |
| 93 | + // Cache of external const values |
| 94 | + extern_const_values: @mut HashMap<ast::def_id, ValueRef>, |
| 95 | + |
| 96 | + module_data: @mut HashMap<~str, ValueRef>, |
| 97 | + lltypes: @mut HashMap<ty::t, TypeRef>, |
| 98 | + llsizingtypes: @mut HashMap<ty::t, TypeRef>, |
| 99 | + adt_reprs: @mut HashMap<ty::t, @adt::Repr>, |
| 100 | + names: namegen, |
| 101 | + next_addrspace: addrspace_gen, |
| 102 | + symbol_hasher: @mut hash::State, |
| 103 | + type_hashcodes: @mut HashMap<ty::t, @str>, |
| 104 | + type_short_names: @mut HashMap<ty::t, ~str>, |
| 105 | + all_llvm_symbols: @mut HashSet<@str>, |
| 106 | + tcx: ty::ctxt, |
| 107 | + maps: astencode::Maps, |
| 108 | + stats: @mut Stats, |
| 109 | + upcalls: @upcall::Upcalls, |
| 110 | + tydesc_type: TypeRef, |
| 111 | + int_type: TypeRef, |
| 112 | + float_type: TypeRef, |
| 113 | + opaque_vec_type: TypeRef, |
| 114 | + builder: BuilderRef_res, |
| 115 | + shape_cx: shape::Ctxt, |
| 116 | + crate_map: ValueRef, |
| 117 | + // Set when at least one function uses GC. Needed so that |
| 118 | + // decl_gc_metadata knows whether to link to the module metadata, which |
| 119 | + // is not emitted by LLVM's GC pass when no functions use GC. |
| 120 | + uses_gc: @mut bool, |
| 121 | + dbg_cx: Option<debuginfo::DebugContext>, |
| 122 | + do_not_commit_warning_issued: @mut bool |
| 123 | +} |
0 commit comments