]> git.proxmox.com Git - rustc.git/blob - src/librustc_metadata/common.rs
Imported Upstream version 1.6.0+dfsg1
[rustc.git] / src / librustc_metadata / common.rs
1 // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![allow(non_camel_case_types, non_upper_case_globals)]
12
13 pub use self::astencode_tag::*;
14
15 // RBML enum definitions and utils shared by the encoder and decoder
16 //
17 // 0x00..0x1f: reserved for RBML generic type tags
18 // 0x20..0xef: free for use, preferred for frequent tags
19 // 0xf0..0xff: internally used by RBML to encode 0x100..0xfff in two bytes
20 // 0x100..0xfff: free for use, preferred for infrequent tags
21
22 pub const tag_items: usize = 0x100; // top-level only
23
24 pub const tag_paths_data_name: usize = 0x20;
25
26 pub const tag_def_id: usize = 0x21;
27
28 pub const tag_items_data: usize = 0x22;
29
30 pub const tag_items_data_item: usize = 0x23;
31
32 pub const tag_items_data_item_family: usize = 0x24;
33
34 pub const tag_items_data_item_type: usize = 0x25;
35
36 pub const tag_items_data_item_symbol: usize = 0x26;
37
38 pub const tag_items_data_item_variant: usize = 0x27;
39
40 pub const tag_items_data_parent_item: usize = 0x28;
41
42 pub const tag_items_data_item_is_tuple_struct_ctor: usize = 0x29;
43
44 pub const tag_items_closure_kind: usize = 0x2a;
45 pub const tag_items_closure_ty: usize = 0x2b;
46 pub const tag_def_key: usize = 0x2c;
47
48 // GAP 0x2d 0x2e
49
50 pub const tag_index: usize = 0x110; // top-level only
51 pub const tag_xref_index: usize = 0x111; // top-level only
52 pub const tag_xref_data: usize = 0x112; // top-level only
53
54 pub const tag_meta_item_name_value: usize = 0x2f;
55
56 pub const tag_meta_item_name: usize = 0x30;
57
58 pub const tag_meta_item_value: usize = 0x31;
59
60 pub const tag_attributes: usize = 0x101; // top-level only
61
62 pub const tag_attribute: usize = 0x32;
63
64 pub const tag_meta_item_word: usize = 0x33;
65
66 pub const tag_meta_item_list: usize = 0x34;
67
68 // The list of crates that this crate depends on
69 pub const tag_crate_deps: usize = 0x102; // top-level only
70
71 // A single crate dependency
72 pub const tag_crate_dep: usize = 0x35;
73
74 pub const tag_crate_hash: usize = 0x103; // top-level only
75 pub const tag_crate_crate_name: usize = 0x104; // top-level only
76
77 pub const tag_crate_dep_crate_name: usize = 0x36;
78 pub const tag_crate_dep_hash: usize = 0x37;
79 pub const tag_crate_dep_explicitly_linked: usize = 0x38; // top-level only
80
81 pub const tag_item_trait_item: usize = 0x3a;
82
83 pub const tag_item_trait_ref: usize = 0x3b;
84
85 // discriminator value for variants
86 pub const tag_disr_val: usize = 0x3c;
87
88 // used to encode ast_map::PathElem
89 pub const tag_path: usize = 0x3d;
90 pub const tag_path_len: usize = 0x3e;
91 pub const tag_path_elem_mod: usize = 0x3f;
92 pub const tag_path_elem_name: usize = 0x40;
93 pub const tag_item_field: usize = 0x41;
94
95 pub const tag_item_variances: usize = 0x43;
96 /*
97 trait items contain tag_item_trait_item elements,
98 impl items contain tag_item_impl_item elements, and classes
99 have both. That's because some code treats classes like traits,
100 and other code treats them like impls. Because classes can contain
101 both, tag_item_trait_item and tag_item_impl_item have to be two
102 different tags.
103 */
104 pub const tag_item_impl_item: usize = 0x44;
105 pub const tag_item_trait_method_explicit_self: usize = 0x45;
106
107
108 // Reexports are found within module tags. Each reexport contains def_ids
109 // and names.
110 pub const tag_items_data_item_reexport: usize = 0x46;
111 pub const tag_items_data_item_reexport_def_id: usize = 0x47;
112 pub const tag_items_data_item_reexport_name: usize = 0x48;
113
114 // used to encode crate_ctxt side tables
115 enum_from_u32! {
116 #[derive(Copy, Clone, PartialEq)]
117 #[repr(usize)]
118 pub enum astencode_tag { // Reserves 0x50 -- 0x6f
119 tag_ast = 0x50,
120
121 tag_tree = 0x51,
122
123 // GAP 0x52
124 tag_table = 0x53,
125 // GAP 0x54, 0x55
126 tag_table_def = 0x56,
127 tag_table_node_type = 0x57,
128 tag_table_item_subst = 0x58,
129 tag_table_freevars = 0x59,
130 // GAP 0x5a, 0x5b, 0x5c, 0x5d, 0x5e
131 tag_table_method_map = 0x5f,
132 // GAP 0x60
133 tag_table_adjustments = 0x61,
134 // GAP 0x62, 0x63, 0x64, 0x65
135 tag_table_upvar_capture_map = 0x66,
136 // GAP 0x67, 0x68
137 tag_table_const_qualif = 0x69,
138 tag_table_cast_kinds = 0x6a,
139 }
140 }
141
142 pub const tag_item_trait_item_sort: usize = 0x70;
143
144 pub const tag_crate_triple: usize = 0x105; // top-level only
145
146 pub const tag_dylib_dependency_formats: usize = 0x106; // top-level only
147
148 // Language items are a top-level directory (for speed). Hierarchy:
149 //
150 // tag_lang_items
151 // - tag_lang_items_item
152 // - tag_lang_items_item_id: u32
153 // - tag_lang_items_item_index: u32
154
155 pub const tag_lang_items: usize = 0x107; // top-level only
156 pub const tag_lang_items_item: usize = 0x73;
157 pub const tag_lang_items_item_id: usize = 0x74;
158 pub const tag_lang_items_item_index: usize = 0x75;
159 pub const tag_lang_items_missing: usize = 0x76;
160
161 pub const tag_item_unnamed_field: usize = 0x77;
162 pub const tag_items_data_item_visibility: usize = 0x78;
163 pub const tag_items_data_item_inherent_impl: usize = 0x79;
164 // GAP 0x7a
165 pub const tag_mod_child: usize = 0x7b;
166 pub const tag_misc_info: usize = 0x108; // top-level only
167 pub const tag_misc_info_crate_items: usize = 0x7c;
168
169 pub const tag_impls: usize = 0x109; // top-level only
170 pub const tag_impls_trait: usize = 0x7d;
171 pub const tag_impls_trait_impl: usize = 0x7e;
172
173 // GAP 0x7f, 0x80, 0x81
174
175 pub const tag_native_libraries: usize = 0x10a; // top-level only
176 pub const tag_native_libraries_lib: usize = 0x82;
177 pub const tag_native_libraries_name: usize = 0x83;
178 pub const tag_native_libraries_kind: usize = 0x84;
179
180 pub const tag_plugin_registrar_fn: usize = 0x10b; // top-level only
181
182 pub const tag_method_argument_names: usize = 0x85;
183 pub const tag_method_argument_name: usize = 0x86;
184
185 pub const tag_reachable_ids: usize = 0x10c; // top-level only
186 pub const tag_reachable_id: usize = 0x87;
187
188 pub const tag_items_data_item_stability: usize = 0x88;
189
190 pub const tag_items_data_item_repr: usize = 0x89;
191
192 pub const tag_struct_fields: usize = 0x10d; // top-level only
193 pub const tag_struct_field: usize = 0x8a;
194
195 pub const tag_items_data_item_struct_ctor: usize = 0x8b;
196 pub const tag_attribute_is_sugared_doc: usize = 0x8c;
197 // GAP 0x8d
198 pub const tag_items_data_region: usize = 0x8e;
199
200 pub const tag_region_param_def: usize = 0x8f;
201 pub const tag_region_param_def_ident: usize = 0x90;
202 pub const tag_region_param_def_def_id: usize = 0x91;
203 pub const tag_region_param_def_space: usize = 0x92;
204 pub const tag_region_param_def_index: usize = 0x93;
205
206 pub const tag_type_param_def: usize = 0x94;
207
208 pub const tag_item_generics: usize = 0x95;
209 pub const tag_method_ty_generics: usize = 0x96;
210
211 pub const tag_type_predicate: usize = 0x97;
212 pub const tag_self_predicate: usize = 0x98;
213 pub const tag_fn_predicate: usize = 0x99;
214
215 pub const tag_unsafety: usize = 0x9a;
216
217 pub const tag_associated_type_names: usize = 0x9b;
218 pub const tag_associated_type_name: usize = 0x9c;
219
220 pub const tag_polarity: usize = 0x9d;
221
222 pub const tag_macro_defs: usize = 0x10e; // top-level only
223 pub const tag_macro_def: usize = 0x9e;
224 pub const tag_macro_def_body: usize = 0x9f;
225
226 pub const tag_paren_sugar: usize = 0xa0;
227
228 pub const tag_codemap: usize = 0xa1;
229 pub const tag_codemap_filemap: usize = 0xa2;
230
231 pub const tag_item_super_predicates: usize = 0xa3;
232
233 pub const tag_defaulted_trait: usize = 0xa4;
234
235 pub const tag_impl_coerce_unsized_kind: usize = 0xa5;
236
237 pub const tag_items_data_item_constness: usize = 0xa6;
238
239 pub const tag_rustc_version: usize = 0x10f;
240 pub fn rustc_version() -> String {
241 format!(
242 "rustc {}",
243 option_env!("CFG_VERSION").unwrap_or("unknown version")
244 )
245 }