2013-06-22 20:58:41 -05:00
|
|
|
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
|
2012-12-03 18:48:01 -06:00
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
2013-12-09 15:56:53 -06:00
|
|
|
|
2013-06-28 17:32:26 -05:00
|
|
|
use std::cast;
|
2013-12-28 11:16:48 -06:00
|
|
|
use syntax::crateid::CrateId;
|
2013-01-07 16:16:52 -06:00
|
|
|
|
2012-01-19 16:24:03 -06:00
|
|
|
// EBML enum definitions and utils shared by the encoder and decoder
|
2011-07-07 14:22:39 -05:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_items: uint = 0x02u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_paths_data_name: uint = 0x04u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_def_id: uint = 0x07u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_items_data: uint = 0x08u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_items_data_item: uint = 0x09u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_items_data_item_family: uint = 0x0au;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_items_data_item_ty_param_bounds: uint = 0x0bu;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_items_data_item_type: uint = 0x0cu;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_items_data_item_symbol: uint = 0x0du;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_items_data_item_variant: uint = 0x0eu;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_items_data_parent_item: uint = 0x0fu;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_index: uint = 0x11u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_index_buckets: uint = 0x12u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_index_buckets_bucket: uint = 0x13u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_index_buckets_bucket_elt: uint = 0x14u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_index_table: uint = 0x15u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_meta_item_name_value: uint = 0x18u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_meta_item_name: uint = 0x19u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_meta_item_value: uint = 0x20u;
|
2011-06-27 21:41:48 -05:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_attributes: uint = 0x21u;
|
2011-06-27 21:41:48 -05:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_attribute: uint = 0x22u;
|
2011-06-27 21:41:48 -05:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_meta_item_word: uint = 0x23u;
|
2011-06-28 01:02:02 -05:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_meta_item_list: uint = 0x24u;
|
2011-07-07 14:22:39 -05:00
|
|
|
|
2011-07-08 13:29:56 -05:00
|
|
|
// The list of crates that this crate depends on
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_crate_deps: uint = 0x25u;
|
2011-07-08 13:29:56 -05:00
|
|
|
|
|
|
|
// A single crate dependency
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_crate_dep: uint = 0x26u;
|
2011-07-08 13:29:56 -05:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_crate_hash: uint = 0x28u;
|
2011-12-11 09:23:38 -06:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_parent_item: uint = 0x29u;
|
2012-03-08 16:13:57 -06:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_crate_dep_name: uint = 0x2au;
|
|
|
|
pub static tag_crate_dep_hash: uint = 0x2bu;
|
|
|
|
pub static tag_crate_dep_vers: uint = 0x2cu;
|
2012-04-07 12:59:37 -05:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_mod_impl: uint = 0x30u;
|
2011-12-16 07:17:52 -06:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_item_trait_method: uint = 0x31u;
|
2013-03-27 05:16:28 -05:00
|
|
|
|
|
|
|
pub static tag_item_trait_ref: uint = 0x32u;
|
|
|
|
pub static tag_item_super_trait_ref: uint = 0x33u;
|
2011-12-16 07:17:52 -06:00
|
|
|
|
2012-01-10 15:50:40 -06:00
|
|
|
// discriminator value for variants
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_disr_val: uint = 0x34u;
|
2012-01-10 15:50:40 -06:00
|
|
|
|
2014-01-09 07:05:33 -06:00
|
|
|
// used to encode ast_map::Path and ast_map::PathElem
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_path: uint = 0x40u;
|
|
|
|
pub static tag_path_len: uint = 0x41u;
|
2014-01-09 07:05:33 -06:00
|
|
|
pub static tag_path_elem_mod: uint = 0x42u;
|
|
|
|
pub static tag_path_elem_name: uint = 0x43u;
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_item_field: uint = 0x44u;
|
|
|
|
pub static tag_struct_mut: uint = 0x45u;
|
|
|
|
|
2013-10-29 05:08:34 -05:00
|
|
|
pub static tag_item_variances: uint = 0x46;
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_mod_impl_trait: uint = 0x47u;
|
2012-04-26 14:15:46 -05:00
|
|
|
/*
|
2012-07-03 18:30:42 -05:00
|
|
|
trait items contain tag_item_trait_method elements,
|
2012-04-26 14:15:46 -05:00
|
|
|
impl items contain tag_item_impl_method elements, and classes
|
2012-07-03 18:30:42 -05:00
|
|
|
have both. That's because some code treats classes like traits,
|
2012-04-26 14:15:46 -05:00
|
|
|
and other code treats them like impls. Because classes can contain
|
2012-07-03 18:30:42 -05:00
|
|
|
both, tag_item_trait_method and tag_item_impl_method have to be two
|
2012-04-26 14:15:46 -05:00
|
|
|
different tags.
|
|
|
|
*/
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_item_impl_method: uint = 0x48u;
|
2013-04-30 10:49:48 -05:00
|
|
|
pub static tag_item_trait_method_explicit_self: uint = 0x4b;
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_item_trait_method_self_ty_region: uint = 0x4c;
|
2012-04-18 23:26:25 -05:00
|
|
|
|
2013-03-27 09:26:57 -05:00
|
|
|
|
2012-08-17 14:41:34 -05:00
|
|
|
// Reexports are found within module tags. Each reexport contains def_ids
|
|
|
|
// and names.
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_items_data_item_reexport: uint = 0x4d;
|
|
|
|
pub static tag_items_data_item_reexport_def_id: uint = 0x4e;
|
|
|
|
pub static tag_items_data_item_reexport_name: uint = 0x4f;
|
2012-08-17 14:41:34 -05:00
|
|
|
|
2012-02-14 17:21:53 -06:00
|
|
|
// used to encode crate_ctxt side tables
|
2013-09-25 11:41:10 -05:00
|
|
|
#[deriving(Eq)]
|
|
|
|
#[repr(uint)]
|
2013-01-29 18:51:16 -06:00
|
|
|
pub enum astencode_tag { // Reserves 0x50 -- 0x6f
|
2012-02-14 17:21:53 -06:00
|
|
|
tag_ast = 0x50,
|
|
|
|
|
|
|
|
tag_tree = 0x51,
|
|
|
|
|
|
|
|
tag_id_range = 0x52,
|
|
|
|
|
|
|
|
tag_table = 0x53,
|
|
|
|
tag_table_id = 0x54,
|
|
|
|
tag_table_val = 0x55,
|
|
|
|
tag_table_def = 0x56,
|
|
|
|
tag_table_node_type = 0x57,
|
|
|
|
tag_table_node_type_subst = 0x58,
|
|
|
|
tag_table_freevars = 0x59,
|
2012-08-17 14:41:34 -05:00
|
|
|
tag_table_tcache = 0x5a,
|
Cleanup substitutions and treatment of generics around traits in a number of ways.
- In a TraitRef, use the self type consistently to refer to the Self type:
- trait ref in `impl Trait<A,B,C> for S` has a self type of `S`.
- trait ref in `A:Trait` has the self type `A`
- trait ref associated with a trait decl has self type `Self`
- trait ref associated with a supertype has self type `Self`
- trait ref in an object type `@Trait` has no self type
- Rewrite `each_bound_traits_and_supertraits` to perform
substitutions as it goes, and thus yield a series of trait refs
that are always in the same 'namespace' as the type parameter
bound given as input. Before, we left this to the caller, but
this doesn't work because the caller lacks adequare information
to perform the type substitutions correctly.
- For provided methods, substitute the generics involved in the provided
method correctly.
- Introduce TypeParameterDef, which tracks the bounds declared on a type
parameter and brings them together with the def_id and (in the future)
other information (maybe even the parameter's name!).
- Introduce Subst trait, which helps to cleanup a lot of the
repetitive code involved with doing type substitution.
- Introduce Repr trait, which makes debug printouts far more convenient.
Fixes #4183. Needed for #5656.
2013-04-09 00:54:49 -05:00
|
|
|
tag_table_param_defs = 0x5b,
|
2012-08-17 14:41:34 -05:00
|
|
|
tag_table_mutbl = 0x5d,
|
|
|
|
tag_table_last_use = 0x5e,
|
|
|
|
tag_table_spill = 0x5f,
|
|
|
|
tag_table_method_map = 0x60,
|
|
|
|
tag_table_vtable_map = 0x61,
|
2012-10-02 18:19:03 -05:00
|
|
|
tag_table_adjustments = 0x62,
|
2013-02-26 20:42:00 -06:00
|
|
|
tag_table_moves_map = 0x63,
|
|
|
|
tag_table_capture_map = 0x64
|
2012-02-14 17:21:53 -06:00
|
|
|
}
|
2013-06-22 20:58:41 -05:00
|
|
|
static first_astencode_tag : uint = tag_ast as uint;
|
|
|
|
static last_astencode_tag : uint = tag_table_capture_map as uint;
|
|
|
|
impl astencode_tag {
|
|
|
|
pub fn from_uint(value : uint) -> Option<astencode_tag> {
|
|
|
|
let is_a_tag = first_astencode_tag <= value && value <= last_astencode_tag;
|
|
|
|
if !is_a_tag { None } else {
|
2013-08-28 20:21:04 -05:00
|
|
|
Some(unsafe { cast::transmute(value) })
|
2013-06-22 20:58:41 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-02-10 08:01:32 -06:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_item_trait_method_sort: uint = 0x70;
|
2012-10-08 14:39:30 -05:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_item_impl_type_basename: uint = 0x71;
|
2012-10-18 15:29:34 -05:00
|
|
|
|
2013-01-07 12:51:53 -06:00
|
|
|
// Language items are a top-level directory (for speed). Hierarchy:
|
|
|
|
//
|
|
|
|
// tag_lang_items
|
|
|
|
// - tag_lang_items_item
|
|
|
|
// - tag_lang_items_item_id: u32
|
|
|
|
// - tag_lang_items_item_node_id: u32
|
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_lang_items: uint = 0x72;
|
|
|
|
pub static tag_lang_items_item: uint = 0x73;
|
|
|
|
pub static tag_lang_items_item_id: uint = 0x74;
|
|
|
|
pub static tag_lang_items_item_node_id: uint = 0x75;
|
2013-01-07 12:51:53 -06:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_item_unnamed_field: uint = 0x76;
|
|
|
|
pub static tag_items_data_item_struct_ctor: uint = 0x77;
|
|
|
|
pub static tag_items_data_item_visibility: uint = 0x78;
|
2013-02-11 18:28:39 -06:00
|
|
|
|
2013-03-22 16:00:15 -05:00
|
|
|
pub static tag_link_args: uint = 0x79;
|
|
|
|
pub static tag_link_args_arg: uint = 0x7a;
|
2013-03-07 00:06:53 -06:00
|
|
|
|
2013-03-27 09:26:57 -05:00
|
|
|
pub static tag_item_method_tps: uint = 0x7b;
|
|
|
|
pub static tag_item_method_fty: uint = 0x7c;
|
2013-03-29 15:02:55 -05:00
|
|
|
pub static tag_item_method_transformed_self_ty: uint = 0x7d;
|
2013-03-27 09:26:57 -05:00
|
|
|
|
2013-06-18 11:39:16 -05:00
|
|
|
pub static tag_mod_child: uint = 0x7e;
|
|
|
|
pub static tag_misc_info: uint = 0x7f;
|
|
|
|
pub static tag_misc_info_crate_items: uint = 0x80;
|
|
|
|
|
2013-07-16 18:28:33 -05:00
|
|
|
pub static tag_item_method_provided_source: uint = 0x81;
|
2013-07-22 18:40:31 -05:00
|
|
|
pub static tag_item_impl_vtables: uint = 0x82;
|
2013-07-16 18:28:33 -05:00
|
|
|
|
2013-08-20 16:55:54 -05:00
|
|
|
pub static tag_impls: uint = 0x83;
|
|
|
|
pub static tag_impls_impl: uint = 0x84;
|
|
|
|
|
2013-08-23 16:34:00 -05:00
|
|
|
pub static tag_items_data_item_inherent_impl: uint = 0x85;
|
|
|
|
pub static tag_items_data_item_extension_impl: uint = 0x86;
|
|
|
|
|
2014-01-09 07:05:33 -06:00
|
|
|
pub static tag_path_elem_pretty_name: uint = 0x87;
|
|
|
|
pub static tag_path_elem_pretty_name_ident: uint = 0x88;
|
|
|
|
pub static tag_path_elem_pretty_name_extra: uint = 0x89;
|
2013-08-30 02:47:10 -05:00
|
|
|
|
2013-10-29 05:03:32 -05:00
|
|
|
pub static tag_region_param_def: uint = 0x100;
|
|
|
|
pub static tag_region_param_def_ident: uint = 0x101;
|
|
|
|
pub static tag_region_param_def_def_id: uint = 0x102;
|
|
|
|
|
Add generation of static libraries to rustc
This commit implements the support necessary for generating both intermediate
and result static rust libraries. This is an implementation of my thoughts in
https://mail.mozilla.org/pipermail/rust-dev/2013-November/006686.html.
When compiling a library, we still retain the "lib" option, although now there
are "rlib", "staticlib", and "dylib" as options for crate_type (and these are
stackable). The idea of "lib" is to generate the "compiler default" instead of
having too choose (although all are interchangeable). For now I have left the
"complier default" to be a dynamic library for size reasons.
Of the rust libraries, lib{std,extra,rustuv} will bootstrap with an
rlib/dylib pair, but lib{rustc,syntax,rustdoc,rustpkg} will only be built as a
dynamic object. I chose this for size reasons, but also because you're probably
not going to be embedding the rustc compiler anywhere any time soon.
Other than the options outlined above, there are a few defaults/preferences that
are now opinionated in the compiler:
* If both a .dylib and .rlib are found for a rust library, the compiler will
prefer the .rlib variant. This is overridable via the -Z prefer-dynamic option
* If generating a "lib", the compiler will generate a dynamic library. This is
overridable by explicitly saying what flavor you'd like (rlib, staticlib,
dylib).
* If no options are passed to the command line, and no crate_type is found in
the destination crate, then an executable is generated
With this change, you can successfully build a rust program with 0 dynamic
dependencies on rust libraries. There is still a dynamic dependency on
librustrt, but I plan on removing that in a subsequent commit.
This change includes no tests just yet. Our current testing
infrastructure/harnesses aren't very amenable to doing flavorful things with
linking, so I'm planning on adding a new mode of testing which I believe belongs
as a separate commit.
Closes #552
2013-11-15 16:03:29 -06:00
|
|
|
pub static tag_native_libraries: uint = 0x103;
|
|
|
|
pub static tag_native_libraries_lib: uint = 0x104;
|
2013-11-30 13:39:55 -06:00
|
|
|
pub static tag_native_libraries_name: uint = 0x105;
|
|
|
|
pub static tag_native_libraries_kind: uint = 0x106;
|
2013-10-29 05:03:32 -05:00
|
|
|
|
2013-12-09 15:56:53 -06:00
|
|
|
#[deriving(Clone)]
|
2013-02-19 01:40:42 -06:00
|
|
|
pub struct LinkMeta {
|
2013-12-28 11:16:48 -06:00
|
|
|
crateid: CrateId,
|
2013-12-09 15:56:53 -06:00
|
|
|
crate_hash: @str,
|
2013-02-19 01:40:42 -06:00
|
|
|
}
|