Created
July 8, 2013 03:37
-
-
Save Aatch/5946068 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern mod std; | |
extern mod syntax; | |
use syntax::ast::*; | |
use std::sys::size_of; | |
macro_rules! type_size ( | |
(S $t:ident) => (print_type_size::<$t>("struct", stringify!($t))); | |
(E $t:ident) => (print_type_size::<$t>("enum", stringify!($t))) | |
) | |
fn main() { | |
println("== Structs =="); | |
type_size!(S Lifetime); | |
type_size!(S Path); | |
type_size!(S def_id); | |
type_size!(S TyParam); | |
type_size!(S Generics); | |
type_size!(S crate_); | |
type_size!(S blk_); | |
type_size!(S field_pat); | |
type_size!(S local_); | |
type_size!(S arm); | |
type_size!(S field_); | |
type_size!(S mac_); | |
type_size!(S mt); | |
type_size!(S ty_field); | |
type_size!(S ty_method); | |
type_size!(S Ty); | |
type_size!(S TyClosure); | |
type_size!(S TyBareFn); | |
type_size!(S inline_asm); | |
type_size!(S arg); | |
type_size!(S fn_decl); | |
type_size!(S method); | |
type_size!(S foreign_mod); | |
type_size!(S variant_arg); | |
type_size!(S variant_); | |
type_size!(S trait_ref); | |
type_size!(S struct_field_); | |
type_size!(S struct_def); | |
type_size!(S item) | |
type_size!(S foreign_item) | |
println("\n== Enums ==\n"); | |
type_size!(E TyParamBound); | |
type_size!(E meta_item_); | |
type_size!(E binding_mode); | |
type_size!(E pat_); | |
type_size!(E mutability); | |
type_size!(E Sigil); | |
type_size!(E vstore); | |
type_size!(E stmt_); | |
type_size!(E decl_); | |
type_size!(E expr_); | |
type_size!(E token_tree); | |
type_size!(E matcher_); | |
type_size!(E lit_); | |
type_size!(E trait_method); | |
type_size!(E ty_); | |
type_size!(E view_path_); | |
type_size!(E view_item); | |
type_size!(E item_) | |
type_size!(E foreign_item_) | |
} | |
fn print_type_size<T>(ty: &str, nm: &str) { | |
println(fmt!("[%s] \t%s: %u", ty, nm, size_of::<T>())); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment