diff options
Diffstat (limited to 'src/modelica_ast.rs')
-rw-r--r-- | src/modelica_ast.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/modelica_ast.rs b/src/modelica_ast.rs index 6903900..f97cd0a 100644 --- a/src/modelica_ast.rs +++ b/src/modelica_ast.rs @@ -3,7 +3,7 @@ use std::clone::Clone; use std::fmt::{Debug, Formatter, Error}; use std::collections::HashMap; -#[derive(PartialEq)] +#[derive(Clone, PartialEq)] pub struct ModelicaModel { pub name: String, pub components: Vec<Component>, @@ -68,12 +68,13 @@ pub enum BinOperator { impl ModelicaModel { - pub fn get_constant_vars(&self) -> HashMap<String,Expr> { + pub fn get_constant_vars(&self) -> HashMap<String,Option<Expr>> { let mut binds = HashMap::new(); + // XXX: actually implement this... for c in &self.components { match c.prefix { - Some(ComponentPrefix::Constant) => { binds.insert(c.name.clone(), Expr::Integer(123)); }, - Some(ComponentPrefix::Parameter) => { binds.insert(c.name.clone(), Expr::Float(4.56)); }, + Some(ComponentPrefix::Constant) => { binds.insert(c.name.clone(), Some(Expr::Integer(123))); }, + Some(ComponentPrefix::Parameter) => { binds.insert(c.name.clone(), Some(Expr::Float(4.56))); }, _ => (), } } @@ -127,6 +128,7 @@ fn intersect_strings(a: &Vec<String>, b: &Vec<String>) -> Vec<String> { impl Expr { // Order is undefined + // TODO: should return a HashSet, not a Vec pub fn identifiers(&self) -> Vec<String> { use self::Expr::*; match *self { |