]> git.lizzy.rs Git - rust.git/blob - src/librustc/metadata/common.rs
Convert most code to new inner attribute syntax.
[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::cast;
14 use syntax::crateid::CrateId;
15 use back::svh::Svh;
16
17 // EBML enum definitions and utils shared by the encoder and decoder
18
19 pub static tag_items: uint = 0x00;
20
21 pub static tag_paths_data_name: uint = 0x01;
22
23 pub static tag_def_id: uint = 0x02;
24
25 pub static tag_items_data: uint = 0x03;
26
27 pub static tag_items_data_item: uint = 0x04;
28
29 pub static tag_items_data_item_family: uint = 0x05;
30
31 pub static tag_items_data_item_ty_param_bounds: uint = 0x06;
32
33 pub static tag_items_data_item_type: uint = 0x07;
34
35 pub static tag_items_data_item_symbol: uint = 0x08;
36
37 pub static tag_items_data_item_variant: uint = 0x09;
38
39 pub static tag_items_data_parent_item: uint = 0x0a;
40
41 pub static tag_items_data_item_is_tuple_struct_ctor: uint = 0x0b;
42
43 pub static tag_index: uint = 0x0c;
44
45 pub static tag_index_buckets: uint = 0x0d;
46
47 pub static tag_index_buckets_bucket: uint = 0x0e;
48
49 pub static tag_index_buckets_bucket_elt: uint = 0x0f;
50
51 pub static tag_index_table: uint = 0x10;
52
53 pub static tag_meta_item_name_value: uint = 0x11;
54
55 pub static tag_meta_item_name: uint = 0x12;
56
57 pub static tag_meta_item_value: uint = 0x13;
58
59 pub static tag_attributes: uint = 0x14;
60
61 pub static tag_attribute: uint = 0x15;
62
63 pub static tag_meta_item_word: uint = 0x16;
64
65 pub static tag_meta_item_list: uint = 0x17;
66
67 // The list of crates that this crate depends on
68 pub static tag_crate_deps: uint = 0x18;
69
70 // A single crate dependency
71 pub static tag_crate_dep: uint = 0x19;
72
73 pub static tag_crate_hash: uint = 0x1a;
74 pub static tag_crate_crateid: uint = 0x1b;
75
76 pub static tag_parent_item: uint = 0x1c;
77
78 pub static tag_crate_dep_crateid: uint = 0x1d;
79 pub static tag_crate_dep_hash: uint = 0x1e;
80
81 pub static tag_mod_impl: uint = 0x1f;
82
83 pub static tag_item_trait_method: uint = 0x20;
84
85 pub static tag_item_trait_ref: uint = 0x21;
86 pub static tag_item_super_trait_ref: uint = 0x22;
87
88 // discriminator value for variants
89 pub static tag_disr_val: uint = 0x23;
90
91 // used to encode ast_map::PathElem
92 pub static tag_path: uint = 0x24;
93 pub static tag_path_len: uint = 0x25;
94 pub static tag_path_elem_mod: uint = 0x26;
95 pub static tag_path_elem_name: uint = 0x27;
96 pub static tag_item_field: uint = 0x28;
97 pub static tag_struct_mut: uint = 0x29;
98
99 pub static tag_item_variances: uint = 0x2a;
100 pub static tag_mod_impl_trait: uint = 0x2b;
101 /*
102   trait items contain tag_item_trait_method elements,
103   impl items contain tag_item_impl_method elements, and classes
104   have both. That's because some code treats classes like traits,
105   and other code treats them like impls. Because classes can contain
106   both, tag_item_trait_method and tag_item_impl_method have to be two
107   different tags.
108  */
109 pub static tag_item_impl_method: uint = 0x2c;
110 pub static tag_item_trait_method_explicit_self: uint = 0x2d;
111 pub static tag_item_trait_method_self_ty_region: uint = 0x2e;
112
113
114 // Reexports are found within module tags. Each reexport contains def_ids
115 // and names.
116 pub static tag_items_data_item_reexport: uint = 0x2f;
117 pub static tag_items_data_item_reexport_def_id: uint = 0x30;
118 pub static tag_items_data_item_reexport_name: uint = 0x31;
119
120 // used to encode crate_ctxt side tables
121 #[deriving(Eq)]
122 #[repr(uint)]
123 pub enum astencode_tag { // Reserves 0x32 -- 0x45
124     tag_ast = 0x32,
125
126     tag_tree = 0x33,
127
128     tag_id_range = 0x34,
129
130     tag_table = 0x35,
131     tag_table_id = 0x36,
132     tag_table_val = 0x37,
133     tag_table_def = 0x38,
134     tag_table_node_type = 0x39,
135     tag_table_node_type_subst = 0x3a,
136     tag_table_freevars = 0x3b,
137     tag_table_tcache = 0x3c,
138     tag_table_param_defs = 0x3d,
139     tag_table_mutbl = 0x3e,
140     tag_table_last_use = 0x3f,
141     tag_table_spill = 0x40,
142     tag_table_method_map = 0x41,
143     tag_table_vtable_map = 0x42,
144     tag_table_adjustments = 0x43,
145     tag_table_moves_map = 0x44,
146     tag_table_capture_map = 0x45
147 }
148 static first_astencode_tag: uint = tag_ast as uint;
149 static last_astencode_tag: uint = tag_table_capture_map as uint;
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 {
154             Some(unsafe { cast::transmute(value) })
155         }
156     }
157 }
158
159 pub static tag_item_trait_method_sort: uint = 0x46;
160
161 pub static tag_item_impl_type_basename: uint = 0x47;
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 = 0x48;
171 pub static tag_lang_items_item: uint = 0x49;
172 pub static tag_lang_items_item_id: uint = 0x4a;
173 pub static tag_lang_items_item_node_id: uint = 0x4b;
174
175 pub static tag_item_unnamed_field: uint = 0x4c;
176 pub static tag_items_data_item_struct_ctor: uint = 0x4d;
177 pub static tag_items_data_item_visibility: uint = 0x4e;
178
179 pub static tag_link_args: uint = 0x4f;
180 pub static tag_link_args_arg: uint = 0x50;
181
182 pub static tag_item_method_tps: uint = 0x51;
183 pub static tag_item_method_fty: uint = 0x52;
184
185 pub static tag_mod_child: uint = 0x53;
186 pub static tag_misc_info: uint = 0x54;
187 pub static tag_misc_info_crate_items: uint = 0x55;
188
189 pub static tag_item_method_provided_source: uint = 0x56;
190 pub static tag_item_impl_vtables: uint = 0x57;
191
192 pub static tag_impls: uint = 0x58;
193 pub static tag_impls_impl: uint = 0x59;
194
195 pub static tag_items_data_item_inherent_impl: uint = 0x5a;
196 pub static tag_items_data_item_extension_impl: uint = 0x5b;
197
198 pub static tag_region_param_def: uint = 0x5c;
199 pub static tag_region_param_def_ident: uint = 0x5d;
200 pub static tag_region_param_def_def_id: uint = 0x5e;
201
202 pub static tag_native_libraries: uint = 0x5f;
203 pub static tag_native_libraries_lib: uint = 0x60;
204 pub static tag_native_libraries_name: uint = 0x61;
205 pub static tag_native_libraries_kind: uint = 0x62;
206
207 pub static tag_macro_registrar_fn: uint = 0x63;
208 pub static tag_exported_macros: uint = 0x64;
209 pub static tag_macro_def: uint = 0x65;
210
211 #[deriving(Clone, Show)]
212 pub struct LinkMeta {
213     crateid: CrateId,
214     crate_hash: Svh,
215 }