]> git.proxmox.com Git - rustc.git/blame - src/librustc/metadata/common.rs
Imported Upstream version 1.1.0+dfsg1
[rustc.git] / src / librustc / metadata / common.rs
CommitLineData
c34b1796 1// Copyright 2012-2015 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
13pub use self::astencode_tag::*;
14
1a4d82fc 15use back::svh::Svh;
223e47cc 16
c34b1796
AL
17// RBML enum definitions and utils shared by the encoder and decoder
18//
19// 0x00..0x1f: reserved for RBML generic type tags
20// 0x20..0xef: free for use, preferred for frequent tags
21// 0xf0..0xff: internally used by RBML to encode 0x100..0xfff in two bytes
22// 0x100..0xfff: free for use, preferred for infrequent tags
223e47cc 23
c34b1796 24pub const tag_items: usize = 0x100; // top-level only
223e47cc 25
c34b1796 26pub const tag_paths_data_name: usize = 0x20;
223e47cc 27
c34b1796 28pub const tag_def_id: usize = 0x21;
223e47cc 29
c34b1796 30pub const tag_items_data: usize = 0x22;
223e47cc 31
c34b1796 32pub const tag_items_data_item: usize = 0x23;
223e47cc 33
c34b1796 34pub const tag_items_data_item_family: usize = 0x24;
223e47cc 35
c34b1796 36pub const tag_items_data_item_type: usize = 0x25;
223e47cc 37
c34b1796 38pub const tag_items_data_item_symbol: usize = 0x26;
223e47cc 39
c34b1796 40pub const tag_items_data_item_variant: usize = 0x27;
223e47cc 41
c34b1796 42pub const tag_items_data_parent_item: usize = 0x28;
223e47cc 43
c34b1796 44pub const tag_items_data_item_is_tuple_struct_ctor: usize = 0x29;
223e47cc 45
c34b1796 46pub const tag_index: usize = 0x2a;
223e47cc 47
c34b1796 48pub const tag_index_buckets: usize = 0x2b;
223e47cc 49
c34b1796 50pub const tag_index_buckets_bucket: usize = 0x2c;
223e47cc 51
c34b1796 52pub const tag_index_buckets_bucket_elt: usize = 0x2d;
223e47cc 53
c34b1796 54pub const tag_index_table: usize = 0x2e;
223e47cc 55
c34b1796 56pub const tag_meta_item_name_value: usize = 0x2f;
223e47cc 57
c34b1796 58pub const tag_meta_item_name: usize = 0x30;
223e47cc 59
c34b1796 60pub const tag_meta_item_value: usize = 0x31;
223e47cc 61
c34b1796 62pub const tag_attributes: usize = 0x101; // top-level only
223e47cc 63
c34b1796 64pub const tag_attribute: usize = 0x32;
223e47cc 65
c34b1796 66pub const tag_meta_item_word: usize = 0x33;
223e47cc 67
c34b1796 68pub const tag_meta_item_list: usize = 0x34;
223e47cc
LB
69
70// The list of crates that this crate depends on
c34b1796 71pub const tag_crate_deps: usize = 0x102; // top-level only
223e47cc
LB
72
73// A single crate dependency
c34b1796 74pub const tag_crate_dep: usize = 0x35;
223e47cc 75
c34b1796
AL
76pub const tag_crate_hash: usize = 0x103; // top-level only
77pub const tag_crate_crate_name: usize = 0x104; // top-level only
223e47cc 78
c34b1796
AL
79pub const tag_crate_dep_crate_name: usize = 0x36;
80pub const tag_crate_dep_hash: usize = 0x37;
223e47cc 81
c34b1796 82pub const tag_mod_impl: usize = 0x38;
223e47cc 83
c34b1796 84pub const tag_item_trait_item: usize = 0x39;
223e47cc 85
c34b1796 86pub const tag_item_trait_ref: usize = 0x3a;
223e47cc
LB
87
88// discriminator value for variants
c34b1796 89pub const tag_disr_val: usize = 0x3c;
1a4d82fc
JJ
90
91// used to encode ast_map::PathElem
c34b1796
AL
92pub const tag_path: usize = 0x3d;
93pub const tag_path_len: usize = 0x3e;
94pub const tag_path_elem_mod: usize = 0x3f;
95pub const tag_path_elem_name: usize = 0x40;
96pub const tag_item_field: usize = 0x41;
97pub const tag_item_field_origin: usize = 0x42;
98
99pub const tag_item_variances: usize = 0x43;
223e47cc 100/*
1a4d82fc
JJ
101 trait items contain tag_item_trait_item elements,
102 impl items contain tag_item_impl_item elements, and classes
223e47cc
LB
103 have both. That's because some code treats classes like traits,
104 and other code treats them like impls. Because classes can contain
1a4d82fc 105 both, tag_item_trait_item and tag_item_impl_item have to be two
223e47cc
LB
106 different tags.
107 */
c34b1796
AL
108pub const tag_item_impl_item: usize = 0x44;
109pub const tag_item_trait_method_explicit_self: usize = 0x45;
223e47cc 110
970d7e83 111
223e47cc
LB
112// Reexports are found within module tags. Each reexport contains def_ids
113// and names.
c34b1796
AL
114pub const tag_items_data_item_reexport: usize = 0x46;
115pub const tag_items_data_item_reexport_def_id: usize = 0x47;
116pub const tag_items_data_item_reexport_name: usize = 0x48;
223e47cc
LB
117
118// used to encode crate_ctxt side tables
9346a6ac
AL
119enum_from_u32! {
120 #[derive(Copy, Clone, PartialEq)]
121 #[repr(usize)]
122 pub enum astencode_tag { // Reserves 0x50 -- 0x6f
123 tag_ast = 0x50,
124
125 tag_tree = 0x51,
126
127 tag_id_range = 0x52,
128
129 tag_table = 0x53,
130 // GAP 0x54, 0x55
131 tag_table_def = 0x56,
132 tag_table_node_type = 0x57,
133 tag_table_item_subst = 0x58,
134 tag_table_freevars = 0x59,
135 tag_table_tcache = 0x5a,
136 tag_table_param_defs = 0x5b,
137 tag_table_mutbl = 0x5c,
138 tag_table_last_use = 0x5d,
139 tag_table_spill = 0x5e,
140 tag_table_method_map = 0x5f,
141 tag_table_vtable_map = 0x60,
142 tag_table_adjustments = 0x61,
143 tag_table_moves_map = 0x62,
144 tag_table_capture_map = 0x63,
145 tag_table_closure_tys = 0x64,
146 tag_table_closure_kinds = 0x65,
147 tag_table_upvar_capture_map = 0x66,
148 tag_table_capture_modes = 0x67,
149 tag_table_object_cast_map = 0x68,
150 tag_table_const_qualif = 0x69,
151 }
970d7e83 152}
223e47cc 153
c34b1796 154pub const tag_item_trait_item_sort: usize = 0x70;
1a4d82fc 155
c34b1796 156pub const tag_item_trait_parent_sort: usize = 0x71;
1a4d82fc 157
c34b1796 158pub const tag_item_impl_type_basename: usize = 0x72;
223e47cc 159
c34b1796 160pub const tag_crate_triple: usize = 0x105; // top-level only
1a4d82fc 161
c34b1796 162pub const tag_dylib_dependency_formats: usize = 0x106; // top-level only
223e47cc
LB
163
164// Language items are a top-level directory (for speed). Hierarchy:
165//
166// tag_lang_items
167// - tag_lang_items_item
168// - tag_lang_items_item_id: u32
169// - tag_lang_items_item_node_id: u32
170
c34b1796
AL
171pub const tag_lang_items: usize = 0x107; // top-level only
172pub const tag_lang_items_item: usize = 0x73;
173pub const tag_lang_items_item_id: usize = 0x74;
174pub const tag_lang_items_item_node_id: usize = 0x75;
175pub const tag_lang_items_missing: usize = 0x76;
1a4d82fc 176
c34b1796
AL
177pub const tag_item_unnamed_field: usize = 0x77;
178pub const tag_items_data_item_visibility: usize = 0x78;
1a4d82fc 179
c34b1796
AL
180pub const tag_item_method_tps: usize = 0x79;
181pub const tag_item_method_fty: usize = 0x7a;
1a4d82fc 182
c34b1796
AL
183pub const tag_mod_child: usize = 0x7b;
184pub const tag_misc_info: usize = 0x108; // top-level only
185pub const tag_misc_info_crate_items: usize = 0x7c;
1a4d82fc 186
c34b1796
AL
187pub const tag_item_method_provided_source: usize = 0x7d;
188pub const tag_item_impl_vtables: usize = 0x7e;
1a4d82fc 189
c34b1796
AL
190pub const tag_impls: usize = 0x109; // top-level only
191pub const tag_impls_impl: usize = 0x7f;
d9579d0f 192pub const tag_impls_impl_trait_def_id: usize = 0x8d;
1a4d82fc 193
c34b1796
AL
194pub const tag_items_data_item_inherent_impl: usize = 0x80;
195pub const tag_items_data_item_extension_impl: usize = 0x81;
223e47cc 196
c34b1796
AL
197pub const tag_native_libraries: usize = 0x10a; // top-level only
198pub const tag_native_libraries_lib: usize = 0x82;
199pub const tag_native_libraries_name: usize = 0x83;
200pub const tag_native_libraries_kind: usize = 0x84;
223e47cc 201
c34b1796 202pub const tag_plugin_registrar_fn: usize = 0x10b; // top-level only
223e47cc 203
c34b1796
AL
204pub const tag_method_argument_names: usize = 0x85;
205pub const tag_method_argument_name: usize = 0x86;
970d7e83 206
c34b1796
AL
207pub const tag_reachable_extern_fns: usize = 0x10c; // top-level only
208pub const tag_reachable_extern_fn_id: usize = 0x87;
970d7e83 209
c34b1796 210pub const tag_items_data_item_stability: usize = 0x88;
1a4d82fc 211
c34b1796 212pub const tag_items_data_item_repr: usize = 0x89;
1a4d82fc 213
85aaf69f 214#[derive(Clone, Debug)]
223e47cc 215pub struct LinkMeta {
1a4d82fc
JJ
216 pub crate_name: String,
217 pub crate_hash: Svh,
223e47cc 218}
1a4d82fc 219
c34b1796
AL
220pub const tag_struct_fields: usize = 0x10d; // top-level only
221pub const tag_struct_field: usize = 0x8a;
222pub const tag_struct_field_id: usize = 0x8b;
223
224pub const tag_attribute_is_sugared_doc: usize = 0x8c;
1a4d82fc 225
c34b1796 226pub const tag_items_data_region: usize = 0x8e;
1a4d82fc 227
c34b1796
AL
228pub const tag_region_param_def: usize = 0x8f;
229pub const tag_region_param_def_ident: usize = 0x90;
230pub const tag_region_param_def_def_id: usize = 0x91;
231pub const tag_region_param_def_space: usize = 0x92;
232pub const tag_region_param_def_index: usize = 0x93;
1a4d82fc 233
c34b1796 234pub const tag_type_param_def: usize = 0x94;
1a4d82fc 235
c34b1796
AL
236pub const tag_item_generics: usize = 0x95;
237pub const tag_method_ty_generics: usize = 0x96;
1a4d82fc 238
c34b1796
AL
239pub const tag_predicate: usize = 0x97;
240pub const tag_predicate_space: usize = 0x98;
241pub const tag_predicate_data: usize = 0x99;
1a4d82fc 242
c34b1796 243pub const tag_unsafety: usize = 0x9a;
1a4d82fc 244
c34b1796
AL
245pub const tag_associated_type_names: usize = 0x9b;
246pub const tag_associated_type_name: usize = 0x9c;
1a4d82fc 247
c34b1796 248pub const tag_polarity: usize = 0x9d;
1a4d82fc 249
c34b1796
AL
250pub const tag_macro_defs: usize = 0x10e; // top-level only
251pub const tag_macro_def: usize = 0x9e;
252pub const tag_macro_def_body: usize = 0x9f;
1a4d82fc 253
c34b1796 254pub const tag_paren_sugar: usize = 0xa0;
1a4d82fc 255
c34b1796
AL
256pub const tag_codemap: usize = 0xa1;
257pub const tag_codemap_filemap: usize = 0xa2;
1a4d82fc 258
c34b1796 259pub const tag_item_super_predicates: usize = 0xa3;
85aaf69f 260
c34b1796 261pub const tag_defaulted_trait: usize = 0xa4;
d9579d0f
AL
262
263pub const tag_impl_coerce_unsized_kind: usize = 0xa5;