]> git.proxmox.com Git - rustc.git/blame - src/librustc/metadata/common.rs
* Introduce some changes by Angus Lees
[rustc.git] / src / librustc / metadata / common.rs
CommitLineData
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
13pub use self::astencode_tag::*;
14
15use std::mem;
16use back::svh::Svh;
223e47cc
LB
17
18// EBML enum definitions and utils shared by the encoder and decoder
19
1a4d82fc 20pub const tag_items: uint = 0x00;
223e47cc 21
1a4d82fc 22pub const tag_paths_data_name: uint = 0x01;
223e47cc 23
1a4d82fc 24pub const tag_def_id: uint = 0x02;
223e47cc 25
1a4d82fc 26pub const tag_items_data: uint = 0x03;
223e47cc 27
1a4d82fc 28pub const tag_items_data_item: uint = 0x04;
223e47cc 29
1a4d82fc 30pub const tag_items_data_item_family: uint = 0x05;
223e47cc 31
1a4d82fc 32pub const tag_items_data_item_type: uint = 0x07;
223e47cc 33
1a4d82fc 34pub const tag_items_data_item_symbol: uint = 0x08;
223e47cc 35
1a4d82fc 36pub const tag_items_data_item_variant: uint = 0x09;
223e47cc 37
1a4d82fc 38pub const tag_items_data_parent_item: uint = 0x0a;
223e47cc 39
1a4d82fc 40pub const tag_items_data_item_is_tuple_struct_ctor: uint = 0x0b;
223e47cc 41
1a4d82fc 42pub const tag_index: uint = 0x0c;
223e47cc 43
1a4d82fc 44pub const tag_index_buckets: uint = 0x0d;
223e47cc 45
1a4d82fc 46pub const tag_index_buckets_bucket: uint = 0x0e;
223e47cc 47
1a4d82fc 48pub const tag_index_buckets_bucket_elt: uint = 0x0f;
223e47cc 49
1a4d82fc 50pub const tag_index_table: uint = 0x10;
223e47cc 51
1a4d82fc 52pub const tag_meta_item_name_value: uint = 0x11;
223e47cc 53
1a4d82fc 54pub const tag_meta_item_name: uint = 0x12;
223e47cc 55
1a4d82fc 56pub const tag_meta_item_value: uint = 0x13;
223e47cc 57
1a4d82fc 58pub const tag_attributes: uint = 0x14;
223e47cc 59
1a4d82fc 60pub const tag_attribute: uint = 0x15;
223e47cc 61
1a4d82fc 62pub const tag_meta_item_word: uint = 0x16;
223e47cc 63
1a4d82fc 64pub const tag_meta_item_list: uint = 0x17;
223e47cc
LB
65
66// The list of crates that this crate depends on
1a4d82fc 67pub const tag_crate_deps: uint = 0x18;
223e47cc
LB
68
69// A single crate dependency
1a4d82fc 70pub const tag_crate_dep: uint = 0x19;
223e47cc 71
1a4d82fc
JJ
72pub const tag_crate_hash: uint = 0x1a;
73pub const tag_crate_crate_name: uint = 0x1b;
223e47cc 74
1a4d82fc
JJ
75pub const tag_crate_dep_crate_name: uint = 0x1d;
76pub const tag_crate_dep_hash: uint = 0x1e;
223e47cc 77
1a4d82fc 78pub const tag_mod_impl: uint = 0x1f;
223e47cc 79
1a4d82fc 80pub const tag_item_trait_item: uint = 0x20;
223e47cc 81
1a4d82fc
JJ
82pub const tag_item_trait_ref: uint = 0x21;
83pub const tag_item_super_trait_ref: uint = 0x22;
223e47cc
LB
84
85// discriminator value for variants
1a4d82fc
JJ
86pub const tag_disr_val: uint = 0x23;
87
88// used to encode ast_map::PathElem
89pub const tag_path: uint = 0x24;
90pub const tag_path_len: uint = 0x25;
91pub const tag_path_elem_mod: uint = 0x26;
92pub const tag_path_elem_name: uint = 0x27;
93pub const tag_item_field: uint = 0x28;
94pub const tag_item_field_origin: uint = 0x29;
95
96pub 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
105pub const tag_item_impl_item: uint = 0x30;
106pub 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
111pub const tag_items_data_item_reexport: uint = 0x38;
112pub const tag_items_data_item_reexport_def_id: uint = 0x39;
113pub 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)]
118pub 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
148static first_astencode_tag: uint = tag_ast as uint;
149static last_astencode_tag: uint = tag_table_object_cast_map as uint;
970d7e83
LB
150impl 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
159pub const tag_item_trait_item_sort: uint = 0x60;
160
161pub const tag_item_trait_parent_sort: uint = 0x61;
162
163pub const tag_item_impl_type_basename: uint = 0x62;
223e47cc 164
1a4d82fc
JJ
165pub const tag_crate_triple: uint = 0x66;
166
167pub 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
176pub const tag_lang_items: uint = 0x70;
177pub const tag_lang_items_item: uint = 0x71;
178pub const tag_lang_items_item_id: uint = 0x72;
179pub const tag_lang_items_item_node_id: uint = 0x73;
180pub const tag_lang_items_missing: uint = 0x74;
181
182pub const tag_item_unnamed_field: uint = 0x75;
183pub const tag_items_data_item_visibility: uint = 0x76;
184
185pub const tag_item_method_tps: uint = 0x79;
186pub const tag_item_method_fty: uint = 0x7a;
187
188pub const tag_mod_child: uint = 0x7b;
189pub const tag_misc_info: uint = 0x7c;
190pub const tag_misc_info_crate_items: uint = 0x7d;
191
192pub const tag_item_method_provided_source: uint = 0x7e;
193pub const tag_item_impl_vtables: uint = 0x7f;
194
195pub const tag_impls: uint = 0x80;
196pub const tag_impls_impl: uint = 0x81;
197
198pub const tag_items_data_item_inherent_impl: uint = 0x82;
199pub const tag_items_data_item_extension_impl: uint = 0x83;
200
201// GAP 0x84, 0x85, 0x86
223e47cc 202
1a4d82fc
JJ
203pub const tag_native_libraries: uint = 0x87;
204pub const tag_native_libraries_lib: uint = 0x88;
205pub const tag_native_libraries_name: uint = 0x89;
206pub const tag_native_libraries_kind: uint = 0x8a;
223e47cc 207
1a4d82fc 208pub const tag_plugin_registrar_fn: uint = 0x8b;
223e47cc 209
1a4d82fc 210// GAP 0x8c, 0x8d
970d7e83 211
1a4d82fc
JJ
212pub const tag_method_argument_names: uint = 0x8e;
213pub const tag_method_argument_name: uint = 0x8f;
970d7e83 214
1a4d82fc
JJ
215pub const tag_reachable_extern_fns: uint = 0x90;
216pub const tag_reachable_extern_fn_id: uint = 0x91;
217
218pub const tag_items_data_item_stability: uint = 0x92;
219
220pub const tag_items_data_item_repr: uint = 0x93;
221
222#[derive(Clone, Show)]
223e47cc 223pub struct LinkMeta {
1a4d82fc
JJ
224 pub crate_name: String,
225 pub crate_hash: Svh,
223e47cc 226}
1a4d82fc
JJ
227
228pub const tag_unboxed_closures: uint = 0x95;
229pub const tag_unboxed_closure: uint = 0x96;
230pub const tag_unboxed_closure_type: uint = 0x97;
231pub const tag_unboxed_closure_kind: uint = 0x98;
232
233pub const tag_struct_fields: uint = 0x99;
234pub const tag_struct_field: uint = 0x9a;
235pub const tag_struct_field_id: uint = 0x9b;
236
237pub const tag_attribute_is_sugared_doc: uint = 0x9c;
238
239pub const tag_trait_def_bounds: uint = 0x9d;
240
241pub const tag_items_data_region: uint = 0x9e;
242
243pub const tag_region_param_def: uint = 0xa0;
244pub const tag_region_param_def_ident: uint = 0xa1;
245pub const tag_region_param_def_def_id: uint = 0xa2;
246pub const tag_region_param_def_space: uint = 0xa3;
247pub const tag_region_param_def_index: uint = 0xa4;
248
249pub const tag_type_param_def: uint = 0xa5;
250
251pub const tag_item_generics: uint = 0xa6;
252pub const tag_method_ty_generics: uint = 0xa7;
253
254pub const tag_predicate: uint = 0xa8;
255pub const tag_predicate_space: uint = 0xa9;
256pub const tag_predicate_data: uint = 0xb0;
257
258pub const tag_unsafety: uint = 0xb1;
259
260pub const tag_associated_type_names: uint = 0xb2;
261pub const tag_associated_type_name: uint = 0xb3;
262
263pub const tag_polarity: uint = 0xb4;
264
265pub const tag_macro_defs: uint = 0xb5;
266pub const tag_macro_def: uint = 0xb6;
267pub const tag_macro_def_body: uint = 0xb7;