#[macro_use] extern crate serde_derive; #[derive(Serialize, Deserialize)] pub struct Program { pub structs: Vec, pub free_functions: Vec, } #[derive(Serialize, Deserialize)] pub struct Struct { pub name: String, pub ctor: Function, pub functions: Vec, pub methods: Vec, } #[derive(Serialize, Deserialize)] pub struct Method { pub mutable: bool, pub function: Function, } #[derive(Serialize, Deserialize)] pub struct Function { pub name: String, pub arguments: Vec, pub ret: Option, } #[derive(Serialize, Deserialize)] pub enum Type { Number, BorrowedStr, String, ByValue(String), ByRef(String), ByMutRef(String), } impl Type { pub fn is_number(&self) -> bool { match *self { Type::Number => true, _ => false, } } }