Skip to content

Commit

Permalink
commit contents:
Browse files Browse the repository at this point in the history
- renamed hiding to lifeline elimination
- exported handling of graphviz to an external library and refactoring
- exported drawing of colored text to an external library and refactoring
- implemented delayed alternative (not yet active in code)
  • Loading branch information
erwanM974 committed Mar 25, 2023
1 parent 19aefc6 commit b8a56b2
Show file tree
Hide file tree
Showing 71 changed files with 853 additions and 1,725 deletions.
26 changes: 24 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hibou_label"
version = "0.8.3"
version = "0.8.4"
authors = ["Erwan Mahe"]
edition = "2021"

Expand All @@ -12,12 +12,14 @@ description = "Holistic Interaction Behavioral Oracle Utility - hibou provides u
[dependencies]
image = "0.24.5" # for rendering interactions
imageproc = "0.23.0" # ...
strum = "0.24.1" # for as_static in the graphviz package and others
strum_macros = "0.24.3" # ...
rusttype = "0.9.3" # for fonts and scale for text in images
image_colored_text = "0.1.0" # for drawing colored text
#rusttype = "0.9.3" # for fonts and scale for text in images
pest = "2.5.6" # for pest parser
pest_derive = "2.5.6" # ...
clap = {version="3.2.22",features=["yaml"]} # for the command line interface
maplit = "1.0.2" # for !hashset macro etc
itertools = "0.10.5" # for .sorted() etc
rand = "0.8.5" # random number generation e.g. for traversal heuristics for interaction semantics exploration and/or multitrace analysis
rand = "0.8.5" # random number generation e.g. for traversal heuristics for interaction semantics exploration and/or multitrace analysis
graphviz_dot_builder = "0.1.1" # for generating dot files to be used with graphviz
strum = "0.24.1" # for IntoStaticStr
strum_macros = "0.24.3" # ...
15 changes: 15 additions & 0 deletions src/core/execution/semantics/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,21 @@ fn execute_interaction_both(my_int : &Interaction,
tar_lf_ids : &HashSet<usize>,
get_affected : bool) -> ExecutionResult {
match my_int {
Interaction::Alt(i1,i2) => {
let exres1 = execute_interaction(i1,sub_p1, tar_lf_ids,get_affected);
let exres2 = execute_interaction(i2,sub_p2, tar_lf_ids,get_affected);
// ***
let mut new_aff = exres1.affected_lifelines;
new_aff.extend(exres2.affected_lifelines);
// ***
if exres1.interaction == Interaction::Empty && exres2.interaction == Interaction::Empty {
return ExecutionResult::new(Interaction::Empty,new_aff);
} else {
return ExecutionResult::new(Interaction::Alt(Box::new(exres1.interaction),
Box::new(exres2.interaction)),
new_aff);
}
},
Interaction::Sync(sync_acts, i1, i2) => {
let exres1 = execute_interaction(i1,sub_p1, tar_lf_ids,get_affected);
let exres2 = execute_interaction(i2,sub_p2, tar_lf_ids,get_affected);
Expand Down
58 changes: 58 additions & 0 deletions src/core/execution/semantics/frontier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,64 @@ fn global_frontier_rec(interaction : &Interaction, loop_depth : u32) -> Vec<Fron
return front;
},
Interaction::Alt(ref i1, ref i2) => {
/*
let mut match_indices : HashSet<(usize,usize)> = hashset! {};
let mut frt1_matched : HashSet<usize> = hashset![];
let mut frt2_matched : HashSet<usize> = hashset![];
// ***
let frt1 = global_frontier_rec(i1,loop_depth);
let frt2 = global_frontier_rec(i2,loop_depth);
// ***
for (frt1_idx,frt1_elt) in frt1.iter().enumerate() {
for (frt2_idx,frt2_elt) in frt2.iter().enumerate() {
if frt1_elt.target_actions == frt2_elt.target_actions {
frt1_matched.insert(frt1_idx);
frt2_matched.insert(frt2_idx);
match_indices.insert( (frt1_idx,frt2_idx) );
}
}
}
// ***
let mut new_front = vec![];
// ***
for (frt1_idx,frt2_idx) in match_indices {
let frt1_elt : &FrontierElement = frt1.get(frt1_idx).unwrap();
let frt2_elt: &FrontierElement = frt2.get(frt2_idx).unwrap();
let new_pos = Position::Both( Box::new(frt1_elt.position.clone()), Box::new(frt2_elt.position.clone()));
let new_target_lf_ids : HashSet<usize> = frt1_elt.target_lf_ids.union(&frt2_elt.target_lf_ids).cloned().collect();
let new_target_actions : HashSet<TraceAction> = frt1_elt.target_actions.union(&frt2_elt.target_actions).cloned().collect();
let new_max_loop_depth = frt1_elt.max_loop_depth.max(frt2_elt.max_loop_depth);
// ***
new_front.push( FrontierElement::new(new_pos,
new_target_lf_ids,
new_target_actions,
new_max_loop_depth ));
}
// ***
for (frt1_idx,frt1_elt) in frt1.into_iter().enumerate() {
if !frt1_matched.contains(&frt1_idx) {
let shifted_pos = Position::Left(Box::new(frt1_elt.position));
new_front.push( FrontierElement::new(shifted_pos,
frt1_elt.target_lf_ids,
frt1_elt.target_actions,
frt1_elt.max_loop_depth ));
}
}
// ***
for (frt2_idx,frt2_elt) in frt2.into_iter().enumerate() {
if !frt2_matched.contains(&frt2_idx) {
let shifted_pos = Position::Right(Box::new(frt2_elt.position));
new_front.push( FrontierElement::new(shifted_pos,
frt2_elt.target_lf_ids,
frt2_elt.target_actions,
frt2_elt.max_loop_depth ));
}
}
// ***
return new_front;
*/
// *****
// BELOW non-delayed ALT
let mut front = push_frontier_left( &mut global_frontier_rec(i1,loop_depth) );
front.append( &mut push_frontier_right( &mut global_frontier_rec(i2,loop_depth)) );
return front;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ limitations under the License.


use std::collections::HashSet;
use crate::core::language::hide::hideable::LifelineHideable;
use crate::core::language::eliminate_lf::eliminable::LifelineEliminable;
use crate::core::language::syntax::action::{EmissionAction, EmissionTargetRef, ReceptionAction};
use crate::core::language::syntax::interaction::Interaction;



impl LifelineHideable for EmissionAction {
impl LifelineEliminable for EmissionAction {

fn hide(&self, lfs_to_remove: &HashSet<usize>) -> Interaction {
fn eliminate_lifelines(&self, lfs_to_remove: &HashSet<usize>) -> Interaction {
if lfs_to_remove.contains(&self.origin_lf_id) {
let mut has_lf_tars = false;
let mut target_lfs : Vec<usize> = Vec::new();
Expand All @@ -43,11 +43,11 @@ impl LifelineHideable for EmissionAction {
}
// ***
if has_lf_tars {
let hidden_act = ReceptionAction::new(None,
let new_act = ReceptionAction::new(None,
self.ms_id,
self.synchronicity.clone(),
target_lfs);
return Interaction::Reception( hidden_act );
return Interaction::Reception( new_act );
} else {
return Interaction::Empty;
}
Expand All @@ -65,19 +65,19 @@ impl LifelineHideable for EmissionAction {
}
}
}
let hidden_act = EmissionAction::new(self.origin_lf_id,
let new_act = EmissionAction::new(self.origin_lf_id,
self.ms_id,
self.synchronicity.clone(),
targets);
return Interaction::Emission( hidden_act );
return Interaction::Emission( new_act );
}
}
}



impl LifelineHideable for ReceptionAction {
fn hide(&self, lfs_to_remove: &HashSet<usize>) -> Interaction {
impl LifelineEliminable for ReceptionAction {
fn eliminate_lifelines(&self, lfs_to_remove: &HashSet<usize>) -> Interaction {
let mut has_lf_tars = false;
let mut target_lfs : Vec<usize> = Vec::new();
for tar_lf_id in &self.recipients {
Expand All @@ -88,11 +88,11 @@ impl LifelineHideable for ReceptionAction {
}
// ***
if has_lf_tars {
let hidden_act = ReceptionAction::new(self.origin_gt_id.clone(),
let new_act = ReceptionAction::new(self.origin_gt_id.clone(),
self.ms_id,
self.synchronicity.clone(),
target_lfs);
return Interaction::Reception( hidden_act );
return Interaction::Reception( new_act );
} else {
return Interaction::Empty;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ use std::collections::HashSet;
use crate::core::language::syntax::interaction::Interaction;


pub trait LifelineHideable {
pub trait LifelineEliminable {

fn hide(&self, lfs_to_remove : &HashSet<usize>) -> Interaction;
fn eliminate_lifelines(&self, lfs_to_eliminate : &HashSet<usize>) -> Interaction;

}

Expand Down
Loading

0 comments on commit b8a56b2

Please sign in to comment.