Skip to content

Commit

Permalink
feat(fkl): try t oadd to aggregate
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Sep 24, 2022
1 parent 64605d3 commit cc971bc
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions crates/fkl_parser/src/transform.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::collections::HashMap;
use indexmap::IndexMap;

use crate::{ContextMap, mir, ParseError};
Expand All @@ -9,6 +10,7 @@ use crate::parser::parse as ast_parse;
pub struct MirTransform {
pub context_map_name: String,
pub contexts: IndexMap<String, BoundedContext>,
// pub contexts: HashMap<String, BoundedContext>,
pub aggregates: IndexMap<String, Aggregate>,
pub relations: Vec<mir::ContextRelation>,
}
Expand All @@ -29,6 +31,8 @@ impl MirTransform {
Err(e) => return Err(e),
};

transform.build_context_map();

Ok(ContextMap {
name: transform.context_map_name,
state: Default::default(),
Expand All @@ -37,6 +41,24 @@ impl MirTransform {
})
}

fn build_context_map(&self) -> Vec<BoundedContext> {
let mut contexts = vec![];

self.contexts.values().for_each(|context| {
let mut context = BoundedContext::new(&context.name);

for aggregate in context.aggregates.clone() {
if let Some(agg) = self.aggregates.get(&aggregate.name) {
context.aggregates.push(agg.clone());
} else {
context.aggregates.push(aggregate.clone())
}
}
});

contexts
}

fn lower_decls(&mut self, decls: Vec<FklDeclaration>) {
decls.iter().for_each(|declaration| {
match declaration {
Expand Down

0 comments on commit cc971bc

Please sign in to comment.