]>
Commit | Line | Data |
---|---|---|
1a4d82fc | 1 | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT |
223e47cc LB |
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. | |
1a4d82fc JJ |
10 | |
11 | #![allow(non_camel_case_types, non_upper_case_globals)] | |
12 | ||
13 | pub use self::astencode_tag::*; | |
14 | ||
15 | use std::mem; | |
16 | use back::svh::Svh; | |
223e47cc LB |
17 | |
18 | // EBML enum definitions and utils shared by the encoder and decoder | |
19 | ||
1a4d82fc | 20 | pub const tag_items: uint = 0x00; |
223e47cc | 21 | |
1a4d82fc | 22 | pub const tag_paths_data_name: uint = 0x01; |
223e47cc | 23 | |
1a4d82fc | 24 | pub const tag_def_id: uint = 0x02; |
223e47cc | 25 | |
1a4d82fc | 26 | pub const tag_items_data: uint = 0x03; |
223e47cc | 27 | |
1a4d82fc | 28 | pub const tag_items_data_item: uint = 0x04; |
223e47cc | 29 | |
1a4d82fc | 30 | pub const tag_items_data_item_family: uint = 0x05; |
223e47cc | 31 | |
1a4d82fc | 32 | pub const tag_items_data_item_type: uint = 0x07; |
223e47cc | 33 | |
1a4d82fc | 34 | pub const tag_items_data_item_symbol: uint = 0x08; |
223e47cc | 35 | |
1a4d82fc | 36 | pub const tag_items_data_item_variant: uint = 0x09; |
223e47cc | 37 | |
1a4d82fc | 38 | pub const tag_items_data_parent_item: uint = 0x0a; |
223e47cc | 39 | |
1a4d82fc | 40 | pub const tag_items_data_item_is_tuple_struct_ctor: uint = 0x0b; |
223e47cc | 41 | |
1a4d82fc | 42 | pub const tag_index: uint = 0x0c; |
223e47cc | 43 | |
1a4d82fc | 44 | pub const tag_index_buckets: uint = 0x0d; |
223e47cc | 45 | |
1a4d82fc | 46 | pub const tag_index_buckets_bucket: uint = 0x0e; |
223e47cc | 47 | |
1a4d82fc | 48 | pub const tag_index_buckets_bucket_elt: uint = 0x0f; |
223e47cc | 49 | |
1a4d82fc | 50 | pub const tag_index_table: uint = 0x10; |
223e47cc | 51 | |
1a4d82fc | 52 | pub const tag_meta_item_name_value: uint = 0x11; |
223e47cc | 53 | |
1a4d82fc | 54 | pub const tag_meta_item_name: uint = 0x12; |
223e47cc | 55 | |
1a4d82fc | 56 | pub const tag_meta_item_value: uint = 0x13; |
223e47cc | 57 | |
1a4d82fc | 58 | pub const tag_attributes: uint = 0x14; |
223e47cc | 59 | |
1a4d82fc | 60 | pub const tag_attribute: uint = 0x15; |
223e47cc | 61 | |
1a4d82fc | 62 | pub const tag_meta_item_word: uint = 0x16; |
223e47cc | 63 | |
1a4d82fc | 64 | pub const tag_meta_item_list: uint = 0x17; |
223e47cc LB |
65 | |
66 | // The list of crates that this crate depends on | |
1a4d82fc | 67 | pub const tag_crate_deps: uint = 0x18; |
223e47cc LB |
68 | |
69 | // A single crate dependency | |
1a4d82fc | 70 | pub const tag_crate_dep: uint = 0x19; |
223e47cc | 71 | |
1a4d82fc JJ |
72 | pub const tag_crate_hash: uint = 0x1a; |
73 | pub const tag_crate_crate_name: uint = 0x1b; | |
223e47cc | 74 | |
1a4d82fc JJ |
75 | pub const tag_crate_dep_crate_name: uint = 0x1d; |
76 | pub const tag_crate_dep_hash: uint = 0x1e; | |
223e47cc | 77 | |
1a4d82fc | 78 | pub const tag_mod_impl: uint = 0x1f; |
223e47cc | 79 | |
1a4d82fc | 80 | pub const tag_item_trait_item: uint = 0x20; |
223e47cc | 81 | |
1a4d82fc JJ |
82 | pub const tag_item_trait_ref: uint = 0x21; |
83 | pub const tag_item_super_trait_ref: uint = 0x22; | |
223e47cc LB |
84 | |
85 | // discriminator value for variants | |
1a4d82fc JJ |
86 | pub const tag_disr_val: uint = 0x23; |
87 | ||
88 | // used to encode ast_map::PathElem | |
89 | pub const tag_path: uint = 0x24; | |
90 | pub const tag_path_len: uint = 0x25; | |
91 | pub const tag_path_elem_mod: uint = 0x26; | |
92 | pub const tag_path_elem_name: uint = 0x27; | |
93 | pub const tag_item_field: uint = 0x28; | |
94 | pub const tag_item_field_origin: uint = 0x29; | |
95 | ||
96 | pub const tag_item_variances: uint = 0x2a; | |
223e47cc | 97 | /* |
1a4d82fc JJ |
98 | trait items contain tag_item_trait_item elements, |
99 | impl items contain tag_item_impl_item elements, and classes | |
223e47cc LB |
100 | have both. That's because some code treats classes like traits, |
101 | and other code treats them like impls. Because classes can contain | |
1a4d82fc | 102 | both, tag_item_trait_item and tag_item_impl_item have to be two |
223e47cc LB |
103 | different tags. |
104 | */ | |
1a4d82fc JJ |
105 | pub const tag_item_impl_item: uint = 0x30; |
106 | pub const tag_item_trait_method_explicit_self: uint = 0x31; | |
223e47cc | 107 | |
970d7e83 | 108 | |
223e47cc LB |
109 | // Reexports are found within module tags. Each reexport contains def_ids |
110 | // and names. | |
1a4d82fc JJ |
111 | pub const tag_items_data_item_reexport: uint = 0x38; |
112 | pub const tag_items_data_item_reexport_def_id: uint = 0x39; | |
113 | pub const tag_items_data_item_reexport_name: uint = 0x3a; | |
223e47cc LB |
114 | |
115 | // used to encode crate_ctxt side tables | |
1a4d82fc JJ |
116 | #[derive(Copy, PartialEq)] |
117 | #[repr(uint)] | |
118 | pub enum astencode_tag { // Reserves 0x40 -- 0x5f | |
119 | tag_ast = 0x40, | |
120 | ||
121 | tag_tree = 0x41, | |
122 | ||
123 | tag_id_range = 0x42, | |
124 | ||
125 | tag_table = 0x43, | |
126 | tag_table_id = 0x44, | |
127 | tag_table_val = 0x45, | |
128 | tag_table_def = 0x46, | |
129 | tag_table_node_type = 0x47, | |
130 | tag_table_item_subst = 0x48, | |
131 | tag_table_freevars = 0x49, | |
132 | tag_table_tcache = 0x4a, | |
133 | tag_table_param_defs = 0x4b, | |
134 | tag_table_mutbl = 0x4c, | |
135 | tag_table_last_use = 0x4d, | |
136 | tag_table_spill = 0x4e, | |
137 | tag_table_method_map = 0x4f, | |
138 | tag_table_vtable_map = 0x50, | |
139 | tag_table_adjustments = 0x51, | |
140 | tag_table_moves_map = 0x52, | |
141 | tag_table_capture_map = 0x53, | |
142 | tag_table_unboxed_closures = 0x54, | |
143 | tag_table_upvar_borrow_map = 0x55, | |
144 | tag_table_capture_modes = 0x56, | |
145 | tag_table_object_cast_map = 0x57, | |
223e47cc | 146 | } |
1a4d82fc JJ |
147 | |
148 | static first_astencode_tag: uint = tag_ast as uint; | |
149 | static last_astencode_tag: uint = tag_table_object_cast_map as uint; | |
970d7e83 LB |
150 | impl astencode_tag { |
151 | pub fn from_uint(value : uint) -> Option<astencode_tag> { | |
152 | let is_a_tag = first_astencode_tag <= value && value <= last_astencode_tag; | |
153 | if !is_a_tag { None } else { | |
1a4d82fc | 154 | Some(unsafe { mem::transmute::<uint, astencode_tag>(value) }) |
970d7e83 LB |
155 | } |
156 | } | |
157 | } | |
223e47cc | 158 | |
1a4d82fc JJ |
159 | pub const tag_item_trait_item_sort: uint = 0x60; |
160 | ||
161 | pub const tag_item_trait_parent_sort: uint = 0x61; | |
162 | ||
163 | pub const tag_item_impl_type_basename: uint = 0x62; | |
223e47cc | 164 | |
1a4d82fc JJ |
165 | pub const tag_crate_triple: uint = 0x66; |
166 | ||
167 | pub const tag_dylib_dependency_formats: uint = 0x67; | |
223e47cc LB |
168 | |
169 | // Language items are a top-level directory (for speed). Hierarchy: | |
170 | // | |
171 | // tag_lang_items | |
172 | // - tag_lang_items_item | |
173 | // - tag_lang_items_item_id: u32 | |
174 | // - tag_lang_items_item_node_id: u32 | |
175 | ||
1a4d82fc JJ |
176 | pub const tag_lang_items: uint = 0x70; |
177 | pub const tag_lang_items_item: uint = 0x71; | |
178 | pub const tag_lang_items_item_id: uint = 0x72; | |
179 | pub const tag_lang_items_item_node_id: uint = 0x73; | |
180 | pub const tag_lang_items_missing: uint = 0x74; | |
181 | ||
182 | pub const tag_item_unnamed_field: uint = 0x75; | |
183 | pub const tag_items_data_item_visibility: uint = 0x76; | |
184 | ||
185 | pub const tag_item_method_tps: uint = 0x79; | |
186 | pub const tag_item_method_fty: uint = 0x7a; | |
187 | ||
188 | pub const tag_mod_child: uint = 0x7b; | |
189 | pub const tag_misc_info: uint = 0x7c; | |
190 | pub const tag_misc_info_crate_items: uint = 0x7d; | |
191 | ||
192 | pub const tag_item_method_provided_source: uint = 0x7e; | |
193 | pub const tag_item_impl_vtables: uint = 0x7f; | |
194 | ||
195 | pub const tag_impls: uint = 0x80; | |
196 | pub const tag_impls_impl: uint = 0x81; | |
197 | ||
198 | pub const tag_items_data_item_inherent_impl: uint = 0x82; | |
199 | pub const tag_items_data_item_extension_impl: uint = 0x83; | |
200 | ||
201 | // GAP 0x84, 0x85, 0x86 | |
223e47cc | 202 | |
1a4d82fc JJ |
203 | pub const tag_native_libraries: uint = 0x87; |
204 | pub const tag_native_libraries_lib: uint = 0x88; | |
205 | pub const tag_native_libraries_name: uint = 0x89; | |
206 | pub const tag_native_libraries_kind: uint = 0x8a; | |
223e47cc | 207 | |
1a4d82fc | 208 | pub const tag_plugin_registrar_fn: uint = 0x8b; |
223e47cc | 209 | |
1a4d82fc | 210 | // GAP 0x8c, 0x8d |
970d7e83 | 211 | |
1a4d82fc JJ |
212 | pub const tag_method_argument_names: uint = 0x8e; |
213 | pub const tag_method_argument_name: uint = 0x8f; | |
970d7e83 | 214 | |
1a4d82fc JJ |
215 | pub const tag_reachable_extern_fns: uint = 0x90; |
216 | pub const tag_reachable_extern_fn_id: uint = 0x91; | |
217 | ||
218 | pub const tag_items_data_item_stability: uint = 0x92; | |
219 | ||
220 | pub const tag_items_data_item_repr: uint = 0x93; | |
221 | ||
222 | #[derive(Clone, Show)] | |
223e47cc | 223 | pub struct LinkMeta { |
1a4d82fc JJ |
224 | pub crate_name: String, |
225 | pub crate_hash: Svh, | |
223e47cc | 226 | } |
1a4d82fc JJ |
227 | |
228 | pub const tag_unboxed_closures: uint = 0x95; | |
229 | pub const tag_unboxed_closure: uint = 0x96; | |
230 | pub const tag_unboxed_closure_type: uint = 0x97; | |
231 | pub const tag_unboxed_closure_kind: uint = 0x98; | |
232 | ||
233 | pub const tag_struct_fields: uint = 0x99; | |
234 | pub const tag_struct_field: uint = 0x9a; | |
235 | pub const tag_struct_field_id: uint = 0x9b; | |
236 | ||
237 | pub const tag_attribute_is_sugared_doc: uint = 0x9c; | |
238 | ||
239 | pub const tag_trait_def_bounds: uint = 0x9d; | |
240 | ||
241 | pub const tag_items_data_region: uint = 0x9e; | |
242 | ||
243 | pub const tag_region_param_def: uint = 0xa0; | |
244 | pub const tag_region_param_def_ident: uint = 0xa1; | |
245 | pub const tag_region_param_def_def_id: uint = 0xa2; | |
246 | pub const tag_region_param_def_space: uint = 0xa3; | |
247 | pub const tag_region_param_def_index: uint = 0xa4; | |
248 | ||
249 | pub const tag_type_param_def: uint = 0xa5; | |
250 | ||
251 | pub const tag_item_generics: uint = 0xa6; | |
252 | pub const tag_method_ty_generics: uint = 0xa7; | |
253 | ||
254 | pub const tag_predicate: uint = 0xa8; | |
255 | pub const tag_predicate_space: uint = 0xa9; | |
256 | pub const tag_predicate_data: uint = 0xb0; | |
257 | ||
258 | pub const tag_unsafety: uint = 0xb1; | |
259 | ||
260 | pub const tag_associated_type_names: uint = 0xb2; | |
261 | pub const tag_associated_type_name: uint = 0xb3; | |
262 | ||
263 | pub const tag_polarity: uint = 0xb4; | |
264 | ||
265 | pub const tag_macro_defs: uint = 0xb5; | |
266 | pub const tag_macro_def: uint = 0xb6; | |
267 | pub const tag_macro_def_body: uint = 0xb7; |