backend: All AST types should implement Debug

This commit is contained in:
Nick Fitzgerald 2018-05-25 16:19:09 -07:00
parent 50b8842b95
commit 018f083402
3 changed files with 19 additions and 6 deletions

View File

@ -17,5 +17,5 @@ spans = ["proc-macro2/nightly"]
quote = '0.6'
proc-macro2 = "0.4"
wasm-bindgen-shared = { path = "../shared", version = "=0.2.11" }
syn = { version = '0.14', features = ['full', 'visit-mut'] }
syn = { version = '0.14', features = ['extra-traits', 'full', 'visit-mut'] }
serde_json = "1.0"

View File

@ -3,7 +3,7 @@ use quote::ToTokens;
use shared;
use syn;
#[derive(Default)]
#[derive(Debug, Default)]
pub struct Program {
pub exports: Vec<Export>,
pub imports: Vec<Import>,
@ -11,6 +11,7 @@ pub struct Program {
pub structs: Vec<Struct>,
}
#[derive(Debug)]
pub struct Export {
pub class: Option<Ident>,
pub method: bool,
@ -19,6 +20,7 @@ pub struct Export {
pub function: Function,
}
#[derive(Debug)]
pub struct Import {
pub module: Option<String>,
pub version: Option<String>,
@ -26,12 +28,14 @@ pub struct Import {
pub kind: ImportKind,
}
#[derive(Debug)]
pub enum ImportKind {
Function(ImportFunction),
Static(ImportStatic),
Type(ImportType),
}
#[derive(Debug)]
pub struct ImportFunction {
pub function: Function,
pub rust_name: Ident,
@ -39,12 +43,14 @@ pub struct ImportFunction {
pub shim: Ident,
}
#[derive(Debug)]
pub enum ImportFunctionKind {
Method { class: String, ty: syn::Type },
JsConstructor { class: String, ty: syn::Type },
Normal,
}
#[derive(Debug)]
pub struct ImportStatic {
pub vis: syn::Visibility,
pub ty: syn::Type,
@ -53,11 +59,13 @@ pub struct ImportStatic {
pub js_name: Ident,
}
#[derive(Debug)]
pub struct ImportType {
pub vis: syn::Visibility,
pub name: Ident,
}
#[derive(Debug)]
pub struct Function {
pub name: Ident,
pub arguments: Vec<syn::Type>,
@ -68,11 +76,13 @@ pub struct Function {
pub rust_vis: syn::Visibility,
}
#[derive(Debug)]
pub struct Struct {
pub name: Ident,
pub fields: Vec<StructField>,
}
#[derive(Debug)]
pub struct StructField {
pub opts: BindgenAttrs,
pub name: Ident,
@ -82,24 +92,26 @@ pub struct StructField {
pub setter: Ident,
}
#[derive(Debug)]
pub struct Enum {
pub name: Ident,
pub variants: Vec<Variant>,
}
#[derive(Debug)]
pub struct Variant {
pub name: Ident,
pub value: u32,
}
#[derive(Copy, Clone)]
#[derive(Copy, Clone, Debug)]
pub enum TypeKind {
ByRef,
ByMutRef,
ByValue,
}
#[derive(Copy, Clone)]
#[derive(Copy, Clone, Debug)]
pub enum TypeLocation {
ImportArgument,
ImportRet,
@ -757,7 +769,7 @@ impl StructField {
}
}
#[derive(Default)]
#[derive(Debug, Default)]
pub struct BindgenAttrs {
attrs: Vec<BindgenAttr>,
}
@ -918,7 +930,7 @@ impl syn::synom::Synom for BindgenAttrs {
));
}
#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
enum BindgenAttr {
Catch,
Constructor,

1
crates/backend/src/lib.rs Normal file → Executable file
View File

@ -1,4 +1,5 @@
#![recursion_limit = "256"]
#![deny(missing_debug_implementations)]
extern crate proc_macro2;
#[macro_use]