]> git.lizzy.rs Git - rust.git/blob - src/librustc/metadata/common.rs
216a575f2fb2b30e1c35adf917bbb3849b3c1f83
[rust.git] / src / librustc / metadata / common.rs
1 // Copyright 2012-2014 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)]
12
13 use std::mem;
14 use back::svh::Svh;
15
16 // EBML enum definitions and utils shared by the encoder and decoder
17
18 pub static tag_items: uint = 0x00;
19
20 pub static tag_paths_data_name: uint = 0x01;
21
22 pub static tag_def_id: uint = 0x02;
23
24 pub static tag_items_data: uint = 0x03;
25
26 pub static tag_items_data_item: uint = 0x04;
27
28 pub static tag_items_data_item_family: uint = 0x05;
29
30 pub static tag_items_data_item_ty_param_bounds: uint = 0x06;
31
32 pub static tag_items_data_item_type: uint = 0x07;
33
34 pub static tag_items_data_item_symbol: uint = 0x08;
35
36 pub static tag_items_data_item_variant: uint = 0x09;
37
38 pub static tag_items_data_parent_item: uint = 0x0a;
39
40 pub static tag_items_data_item_is_tuple_struct_ctor: uint = 0x0b;
41
42 pub static tag_index: uint = 0x0c;
43
44 pub static tag_index_buckets: uint = 0x0d;
45
46 pub static tag_index_buckets_bucket: uint = 0x0e;
47
48 pub static tag_index_buckets_bucket_elt: uint = 0x0f;
49
50 pub static tag_index_table: uint = 0x10;
51
52 pub static tag_meta_item_name_value: uint = 0x11;
53
54 pub static tag_meta_item_name: uint = 0x12;
55
56 pub static tag_meta_item_value: uint = 0x13;
57
58 pub static tag_attributes: uint = 0x14;
59
60 pub static tag_attribute: uint = 0x15;
61
62 pub static tag_meta_item_word: uint = 0x16;
63
64 pub static tag_meta_item_list: uint = 0x17;
65
66 // The list of crates that this crate depends on
67 pub static tag_crate_deps: uint = 0x18;
68
69 // A single crate dependency
70 pub static tag_crate_dep: uint = 0x19;
71
72 pub static tag_crate_hash: uint = 0x1a;
73 pub static tag_crate_crate_name: uint = 0x1b;
74
75 pub static tag_crate_dep_crate_name: uint = 0x1d;
76 pub static tag_crate_dep_hash: uint = 0x1e;
77
78 pub static tag_mod_impl: uint = 0x1f;
79
80 pub static tag_item_trait_method: uint = 0x20;
81
82 pub static tag_item_trait_ref: uint = 0x21;
83 pub static tag_item_super_trait_ref: uint = 0x22;
84
85 // discriminator value for variants
86 pub static tag_disr_val: uint = 0x23;
87
88 // used to encode ast_map::PathElem
89 pub static tag_path: uint = 0x24;
90 pub static tag_path_len: uint = 0x25;
91 pub static tag_path_elem_mod: uint = 0x26;
92 pub static tag_path_elem_name: uint = 0x27;
93 pub static tag_item_field: uint = 0x28;
94 pub static tag_item_field_origin: uint = 0x29;
95
96 pub static tag_item_variances: uint = 0x2a;
97 /*
98   trait items contain tag_item_trait_method elements,
99   impl items contain tag_item_impl_method elements, and classes
100   have both. That's because some code treats classes like traits,
101   and other code treats them like impls. Because classes can contain
102   both, tag_item_trait_method and tag_item_impl_method have to be two
103   different tags.
104  */
105 pub static tag_item_impl_method: uint = 0x30;
106 pub static tag_item_trait_method_explicit_self: uint = 0x31;
107
108
109 // Reexports are found within module tags. Each reexport contains def_ids
110 // and names.
111 pub static tag_items_data_item_reexport: uint = 0x38;
112 pub static tag_items_data_item_reexport_def_id: uint = 0x39;
113 pub static tag_items_data_item_reexport_name: uint = 0x3a;
114
115 // used to encode crate_ctxt side tables
116 #[deriving(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_closure_type = 0x54,
143 }
144 static first_astencode_tag: uint = tag_ast as uint;
145 static last_astencode_tag: uint = tag_table_unboxed_closure_type as uint;
146 impl astencode_tag {
147     pub fn from_uint(value : uint) -> Option<astencode_tag> {
148         let is_a_tag = first_astencode_tag <= value && value <= last_astencode_tag;
149         if !is_a_tag { None } else {
150             Some(unsafe { mem::transmute(value) })
151         }
152     }
153 }
154
155 pub static tag_item_trait_method_sort: uint = 0x60;
156
157 pub static tag_item_impl_type_basename: uint = 0x61;
158
159 pub static tag_crate_triple: uint = 0x66;
160
161 pub static tag_dylib_dependency_formats: uint = 0x67;
162
163 // Language items are a top-level directory (for speed). Hierarchy:
164 //
165 // tag_lang_items
166 // - tag_lang_items_item
167 //   - tag_lang_items_item_id: u32
168 //   - tag_lang_items_item_node_id: u32
169
170 pub static tag_lang_items: uint = 0x70;
171 pub static tag_lang_items_item: uint = 0x71;
172 pub static tag_lang_items_item_id: uint = 0x72;
173 pub static tag_lang_items_item_node_id: uint = 0x73;
174 pub static tag_lang_items_missing: uint = 0x74;
175
176 pub static tag_item_unnamed_field: uint = 0x75;
177 pub static tag_items_data_item_visibility: uint = 0x76;
178 pub static tag_items_data_item_sized: uint = 0x77;
179
180 pub static tag_item_method_tps: uint = 0x79;
181 pub static tag_item_method_fty: uint = 0x7a;
182
183 pub static tag_mod_child: uint = 0x7b;
184 pub static tag_misc_info: uint = 0x7c;
185 pub static tag_misc_info_crate_items: uint = 0x7d;
186
187 pub static tag_item_method_provided_source: uint = 0x7e;
188 pub static tag_item_impl_vtables: uint = 0x7f;
189
190 pub static tag_impls: uint = 0x80;
191 pub static tag_impls_impl: uint = 0x81;
192
193 pub static tag_items_data_item_inherent_impl: uint = 0x82;
194 pub static tag_items_data_item_extension_impl: uint = 0x83;
195
196 // GAP 0x84, 0x85, 0x86
197
198 pub static tag_native_libraries: uint = 0x87;
199 pub static tag_native_libraries_lib: uint = 0x88;
200 pub static tag_native_libraries_name: uint = 0x89;
201 pub static tag_native_libraries_kind: uint = 0x8a;
202
203 pub static tag_plugin_registrar_fn: uint = 0x8b;
204 pub static tag_exported_macros: uint = 0x8c;
205 pub static tag_macro_def: uint = 0x8d;
206
207 pub static tag_method_argument_names: uint = 0x8e;
208 pub static tag_method_argument_name: uint = 0x8f;
209
210 pub static tag_reachable_extern_fns: uint = 0x90;
211 pub static tag_reachable_extern_fn_id: uint = 0x91;
212
213 pub static tag_items_data_item_stability: uint = 0x92;
214
215 #[deriving(Clone, Show)]
216 pub struct LinkMeta {
217     pub crate_name: String,
218     pub crate_hash: Svh,
219 }
220
221 pub static tag_region_param_def: uint = 0x90;
222 pub static tag_region_param_def_ident: uint = 0x91;
223 pub static tag_region_param_def_def_id: uint = 0x92;
224 pub static tag_region_param_def_space: uint = 0x93;
225 pub static tag_region_param_def_index: uint = 0x94;
226
227 pub static tag_unboxed_closures: uint = 0x95;
228 pub static tag_unboxed_closure: uint = 0x96;
229 pub static tag_unboxed_closure_type: uint = 0x97;