pr 33
This commit is contained in:
@@ -3,6 +3,8 @@ use super::ids::FunctionId;
|
||||
use super::block::Block;
|
||||
use super::types::Type;
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
pub struct Param {
|
||||
pub name: String,
|
||||
@@ -17,4 +19,6 @@ pub struct Function {
|
||||
pub params: Vec<Param>,
|
||||
pub return_type: Type,
|
||||
pub blocks: Vec<Block>,
|
||||
#[serde(default)]
|
||||
pub local_types: HashMap<u32, Type>,
|
||||
}
|
||||
|
||||
@@ -47,9 +47,11 @@ mod tests {
|
||||
],
|
||||
terminator: Terminator::Return,
|
||||
}],
|
||||
local_types: std::collections::HashMap::new(),
|
||||
}],
|
||||
}],
|
||||
field_offsets: std::collections::HashMap::new(),
|
||||
field_types: std::collections::HashMap::new(),
|
||||
};
|
||||
|
||||
let json = serde_json::to_string_pretty(&program).unwrap();
|
||||
@@ -87,12 +89,14 @@ mod tests {
|
||||
],
|
||||
"terminator": "Return"
|
||||
}
|
||||
]
|
||||
],
|
||||
"local_types": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"field_offsets": {}
|
||||
"field_offsets": {},
|
||||
"field_types": {}
|
||||
}"#;
|
||||
assert_eq!(json, expected);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ use serde::{Deserialize, Serialize};
|
||||
use super::module::Module;
|
||||
use super::const_pool::ConstPool;
|
||||
use super::ids::FieldId;
|
||||
use super::types::Type;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
@@ -10,4 +11,6 @@ pub struct Program {
|
||||
pub modules: Vec<Module>,
|
||||
#[serde(default)]
|
||||
pub field_offsets: HashMap<FieldId, u32>,
|
||||
#[serde(default)]
|
||||
pub field_types: HashMap<FieldId, Type>,
|
||||
}
|
||||
|
||||
@@ -161,6 +161,7 @@ mod tests {
|
||||
params: vec![],
|
||||
return_type: Type::Void,
|
||||
blocks,
|
||||
local_types: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,6 +173,7 @@ mod tests {
|
||||
functions: vec![func],
|
||||
}],
|
||||
field_offsets: HashMap::new(),
|
||||
field_types: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user