Start adding support for classes

This commit is contained in:
Alex Crichton
2017-12-18 12:39:14 -08:00
parent 2225942000
commit 7c510a8a7e
7 changed files with 504 additions and 171 deletions

View File

@ -1,6 +1,26 @@
#[macro_use]
extern crate serde_derive;
#[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,
}
#[derive(Serialize, Deserialize)]
pub struct Function {
pub name: String,
@ -13,6 +33,9 @@ pub enum Type {
Number,
BorrowedStr,
String,
ByValue(String),
ByRef(String),
ByMutRef(String),
}
impl Type {