49 lines
885 B
Rust
Raw Normal View History

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