2012-01-19 16:24:03 -06:00
|
|
|
// EBML enum definitions and utils shared by the encoder and decoder
|
2011-07-07 14:22:39 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
const tag_paths: uint = 0x01u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
const tag_items: uint = 0x02u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
const tag_paths_data: uint = 0x03u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
const tag_paths_data_name: uint = 0x04u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
const tag_paths_data_item: uint = 0x05u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
const tag_paths_data_mod: uint = 0x06u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
const tag_def_id: uint = 0x07u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
const tag_items_data: uint = 0x08u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
const tag_items_data_item: uint = 0x09u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2011-07-29 18:40:23 -05:00
|
|
|
const tag_items_data_item_family: uint = 0x0au;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2011-12-28 10:50:12 -06:00
|
|
|
const tag_items_data_item_ty_param_bounds: uint = 0x0bu;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
const tag_items_data_item_type: uint = 0x0cu;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
const tag_items_data_item_symbol: uint = 0x0du;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
const tag_items_data_item_variant: uint = 0x0eu;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2012-03-08 16:13:57 -06:00
|
|
|
const tag_items_data_parent_item: uint = 0x0fu;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
const tag_index: uint = 0x11u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
const tag_index_buckets: uint = 0x12u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
const tag_index_buckets_bucket: uint = 0x13u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
const tag_index_buckets_bucket_elt: uint = 0x14u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
const tag_index_table: uint = 0x15u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
const tag_meta_item_name_value: uint = 0x18u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
const tag_meta_item_name: uint = 0x19u;
|
2011-06-27 16:54:59 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
const tag_meta_item_value: uint = 0x20u;
|
2011-06-27 21:41:48 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
const tag_attributes: uint = 0x21u;
|
2011-06-27 21:41:48 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
const tag_attribute: uint = 0x22u;
|
2011-06-27 21:41:48 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
const tag_meta_item_word: uint = 0x23u;
|
2011-06-28 01:02:02 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
const tag_meta_item_list: uint = 0x24u;
|
2011-07-07 14:22:39 -05:00
|
|
|
|
2011-07-08 13:29:56 -05:00
|
|
|
// The list of crates that this crate depends on
|
2011-07-27 07:19:39 -05:00
|
|
|
const tag_crate_deps: uint = 0x25u;
|
2011-07-08 13:29:56 -05:00
|
|
|
|
|
|
|
// A single crate dependency
|
2011-07-27 07:19:39 -05:00
|
|
|
const tag_crate_dep: uint = 0x26u;
|
2011-07-08 13:29:56 -05:00
|
|
|
|
2011-12-11 09:23:38 -06:00
|
|
|
const tag_crate_hash: uint = 0x28u;
|
|
|
|
|
2012-03-08 16:13:57 -06:00
|
|
|
const tag_parent_item: uint = 0x29u;
|
|
|
|
|
2012-04-07 12:59:37 -05:00
|
|
|
const tag_crate_dep_name: uint = 0x2au;
|
|
|
|
const tag_crate_dep_hash: uint = 0x2bu;
|
|
|
|
const tag_crate_dep_vers: uint = 0x2cu;
|
|
|
|
|
2011-12-16 07:17:52 -06:00
|
|
|
const tag_mod_impl: uint = 0x30u;
|
|
|
|
|
2012-04-26 14:15:46 -05:00
|
|
|
const tag_item_iface_method: uint = 0x31u;
|
2012-01-05 03:57:19 -06:00
|
|
|
const tag_impl_iface: uint = 0x32u;
|
2011-12-16 07:17:52 -06:00
|
|
|
|
2012-01-10 15:50:40 -06:00
|
|
|
// discriminator value for variants
|
|
|
|
const tag_disr_val: uint = 0x34u;
|
|
|
|
|
2012-02-10 08:01:32 -06:00
|
|
|
// used to encode ast_map::path and ast_map::path_elt
|
|
|
|
const tag_path: uint = 0x40u;
|
|
|
|
const tag_path_len: uint = 0x41u;
|
|
|
|
const tag_path_elt_mod: uint = 0x42u;
|
|
|
|
const tag_path_elt_name: uint = 0x43u;
|
2012-03-22 20:03:12 -05:00
|
|
|
const tag_item_field: uint = 0x44u;
|
2012-03-28 00:08:48 -05:00
|
|
|
const tag_class_mut: uint = 0x45u;
|
2012-02-10 08:01:32 -06:00
|
|
|
|
2012-04-18 23:26:25 -05:00
|
|
|
const tag_region_param: uint = 0x46u;
|
2012-05-02 16:02:22 -05:00
|
|
|
const tag_mod_impl_iface: uint = 0x47u;
|
2012-04-26 14:15:46 -05:00
|
|
|
/*
|
|
|
|
iface items contain tag_item_iface_method elements,
|
|
|
|
impl items contain tag_item_impl_method elements, and classes
|
|
|
|
have both. That's because some code treats classes like ifaces,
|
|
|
|
and other code treats them like impls. Because classes can contain
|
|
|
|
both, tag_item_iface_method and tag_item_impl_method have to be two
|
|
|
|
different tags.
|
|
|
|
*/
|
2012-05-02 16:02:22 -05:00
|
|
|
const tag_item_impl_method: uint = 0x48u;
|
2012-05-15 19:59:55 -05:00
|
|
|
const tag_item_dtor: uint = 0x49u;
|
2012-04-18 23:26:25 -05:00
|
|
|
|
2012-02-14 17:21:53 -06:00
|
|
|
// used to encode crate_ctxt side tables
|
|
|
|
enum astencode_tag { // Reserves 0x50 -- 0x6f
|
|
|
|
tag_ast = 0x50,
|
|
|
|
|
|
|
|
tag_tree = 0x51,
|
|
|
|
|
|
|
|
tag_id_range = 0x52,
|
|
|
|
|
|
|
|
tag_table = 0x53,
|
|
|
|
tag_table_id = 0x54,
|
|
|
|
tag_table_val = 0x55,
|
|
|
|
tag_table_def = 0x56,
|
|
|
|
tag_table_node_type = 0x57,
|
|
|
|
tag_table_node_type_subst = 0x58,
|
|
|
|
tag_table_freevars = 0x59,
|
|
|
|
tag_table_tcache,
|
|
|
|
tag_table_param_bounds,
|
|
|
|
tag_table_inferred_modes,
|
|
|
|
tag_table_mutbl,
|
|
|
|
tag_table_copy,
|
|
|
|
tag_table_last_use,
|
2012-03-23 10:05:53 -05:00
|
|
|
tag_table_spill,
|
2012-02-14 17:21:53 -06:00
|
|
|
tag_table_method_map,
|
2012-04-23 17:23:20 -05:00
|
|
|
tag_table_vtable_map,
|
|
|
|
tag_table_borrowings
|
2012-02-14 17:21:53 -06:00
|
|
|
}
|
2012-02-10 08:01:32 -06:00
|
|
|
|
2011-07-07 14:22:39 -05:00
|
|
|
// djb's cdb hashes.
|
2011-10-06 05:26:12 -05:00
|
|
|
fn hash_node_id(&&node_id: int) -> uint { ret 177573u ^ (node_id as uint); }
|
2011-07-07 14:22:39 -05:00
|
|
|
|
2011-10-10 06:54:03 -05:00
|
|
|
fn hash_path(&&s: str) -> uint {
|
2012-03-15 08:47:03 -05:00
|
|
|
let mut h = 5381u;
|
2012-04-06 13:01:43 -05:00
|
|
|
for str::each(s) {|ch| h = (h << 5u) + h ^ (ch as uint); }
|
2011-07-07 14:22:39 -05:00
|
|
|
ret h;
|
|
|
|
}
|