fmt, macro in app_logic for hash
This commit is contained in:
@ -128,24 +128,23 @@ pub enum BasicValue {
|
||||
},
|
||||
Trace {
|
||||
value: rsprocess::trace::SlicingTrace<
|
||||
rsprocess::set::Set,
|
||||
rsprocess::set::Set,
|
||||
rsprocess::reaction::Reaction,
|
||||
rsprocess::system::System
|
||||
>
|
||||
rsprocess::system::System,
|
||||
>,
|
||||
},
|
||||
PositiveTrace {
|
||||
value: rsprocess::trace::SlicingTrace<
|
||||
rsprocess::set::PositiveSet,
|
||||
rsprocess::set::PositiveSet,
|
||||
rsprocess::reaction::PositiveReaction,
|
||||
rsprocess::system::PositiveSystem
|
||||
>
|
||||
rsprocess::system::PositiveSystem,
|
||||
>,
|
||||
},
|
||||
PositiveSet {
|
||||
value: rsprocess::set::PositiveSet
|
||||
value: rsprocess::set::PositiveSet,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
impl Hash for BasicValue {
|
||||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||
macro_rules! default_hash {
|
||||
@ -344,18 +343,14 @@ impl NodeInstruction {
|
||||
vec![("sys", PositiveSystem), ("experiment", Experiment)],
|
||||
| Self::PositiveFastFrequency =>
|
||||
vec![("sys", PositiveSystem), ("experiment", Experiment)],
|
||||
| Self::Trace =>
|
||||
vec![("sys", System), ("limit", PositiveInt)],
|
||||
| Self::Trace => vec![("sys", System), ("limit", PositiveInt)],
|
||||
| Self::PositiveTrace =>
|
||||
vec![("sys", PositiveSystem), ("limit", PositiveInt)],
|
||||
| Self::SliceTrace =>
|
||||
vec![("trace", Trace), ("marking", Set)],
|
||||
| Self::SliceTrace => vec![("trace", Trace), ("marking", Set)],
|
||||
| Self::PositiveSliceTrace =>
|
||||
vec![("trace", PositiveTrace), ("marking", PositiveSet)],
|
||||
| Self::PositiveSet =>
|
||||
vec![("string", String)],
|
||||
| Self::ToPositiveSet =>
|
||||
vec![("value", Set)],
|
||||
| Self::PositiveSet => vec![("string", String)],
|
||||
| Self::ToPositiveSet => vec![("value", Set)],
|
||||
}
|
||||
.into_iter()
|
||||
.map(|e| (e.0.to_string(), e.1))
|
||||
@ -418,16 +413,18 @@ impl NodeInstruction {
|
||||
) -> Box<dyn Fn(NodeId, &mut NodeGraph, &str)> {
|
||||
macro_rules! helper {
|
||||
($name: ident, $def: expr) => {
|
||||
Box::new(|node_id: NodeId, graph: &mut NodeGraph, name: &str| {
|
||||
graph.add_input_param(
|
||||
node_id,
|
||||
name.to_string(),
|
||||
BasicDataType::$name,
|
||||
BasicValue::$name { value: $def },
|
||||
InputParamKind::ConnectionOrConstant,
|
||||
true,
|
||||
);
|
||||
})
|
||||
Box::new(
|
||||
|node_id: NodeId, graph: &mut NodeGraph, name: &str| {
|
||||
graph.add_input_param(
|
||||
node_id,
|
||||
name.to_string(),
|
||||
BasicDataType::$name,
|
||||
BasicValue::$name { value: $def },
|
||||
InputParamKind::ConnectionOrConstant,
|
||||
true,
|
||||
);
|
||||
},
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
@ -441,7 +438,8 @@ impl NodeInstruction {
|
||||
helper!(System, rsprocess::system::System::default()),
|
||||
| BasicDataType::PositiveInt => helper!(PositiveInt, 1),
|
||||
| BasicDataType::Symbol => helper!(Symbol, "*".into()),
|
||||
| BasicDataType::Experiment => helper!(Experiment, (vec![], vec![])),
|
||||
| BasicDataType::Experiment =>
|
||||
helper!(Experiment, (vec![], vec![])),
|
||||
| BasicDataType::Graph => helper!(Graph, petgraph::Graph::new()),
|
||||
| BasicDataType::GroupingFunction =>
|
||||
helper!(GroupingFunction, assert::relabel::Assert::default()),
|
||||
@ -467,7 +465,8 @@ impl NodeInstruction {
|
||||
Environment,
|
||||
rsprocess::environment::Environment::default()
|
||||
),
|
||||
| BasicDataType::Set => helper!(Set, rsprocess::set::Set::default()),
|
||||
| BasicDataType::Set =>
|
||||
helper!(Set, rsprocess::set::Set::default()),
|
||||
| BasicDataType::Context =>
|
||||
helper!(Context, rsprocess::process::Process::default()),
|
||||
| BasicDataType::Reactions => helper!(Reactions, vec![]),
|
||||
@ -475,18 +474,14 @@ impl NodeInstruction {
|
||||
PositiveSystem,
|
||||
rsprocess::system::PositiveSystem::default()
|
||||
),
|
||||
| BasicDataType::Trace => helper!(
|
||||
Trace,
|
||||
rsprocess::trace::SlicingTrace::default()
|
||||
),
|
||||
| BasicDataType::Trace =>
|
||||
helper!(Trace, rsprocess::trace::SlicingTrace::default()),
|
||||
| BasicDataType::PositiveTrace => helper!(
|
||||
PositiveTrace,
|
||||
rsprocess::trace::SlicingTrace::default()
|
||||
),
|
||||
| BasicDataType::PositiveSet => helper!(
|
||||
PositiveSet,
|
||||
rsprocess::set::PositiveSet::default()
|
||||
),
|
||||
| BasicDataType::PositiveSet =>
|
||||
helper!(PositiveSet, rsprocess::set::PositiveSet::default()),
|
||||
}
|
||||
}
|
||||
|
||||
@ -496,13 +491,15 @@ impl NodeInstruction {
|
||||
) -> Box<dyn Fn(NodeId, &mut NodeGraph, &str)> {
|
||||
macro_rules! helper {
|
||||
($name: ident) => {
|
||||
Box::new(|node_id: NodeId, graph: &mut NodeGraph, name: &str| {
|
||||
graph.add_output_param(
|
||||
node_id,
|
||||
name.to_string(),
|
||||
BasicDataType::$name,
|
||||
);
|
||||
})
|
||||
Box::new(
|
||||
|node_id: NodeId, graph: &mut NodeGraph, name: &str| {
|
||||
graph.add_output_param(
|
||||
node_id,
|
||||
name.to_string(),
|
||||
BasicDataType::$name,
|
||||
);
|
||||
},
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
@ -543,7 +540,6 @@ pub enum CustomResponse {
|
||||
SaveToFile(NodeId),
|
||||
}
|
||||
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
#[cfg_attr(
|
||||
feature = "persistence",
|
||||
@ -797,48 +793,47 @@ impl NodeTemplateTrait for NodeInstruction {
|
||||
) -> Vec<&'static str> {
|
||||
match self {
|
||||
| Self::String
|
||||
| Self::Path
|
||||
| Self::ReadPath
|
||||
| Self::Symbol
|
||||
| Self::SaveString => vec!["String"],
|
||||
| Self::Path
|
||||
| Self::ReadPath
|
||||
| Self::Symbol
|
||||
| Self::SaveString => vec!["String"],
|
||||
| Self::System
|
||||
| Self::Statistics
|
||||
| Self::Target
|
||||
| Self::Run
|
||||
| Self::Loop
|
||||
| Self::ComposeSystem
|
||||
| Self::Environment
|
||||
| Self::Set
|
||||
| Self::Context
|
||||
| Self::Reactions => vec!["System"],
|
||||
| Self::Statistics
|
||||
| Self::Target
|
||||
| Self::Run
|
||||
| Self::Loop
|
||||
| Self::ComposeSystem
|
||||
| Self::Environment
|
||||
| Self::Set
|
||||
| Self::Context
|
||||
| Self::Reactions => vec!["System"],
|
||||
| Self::Frequency
|
||||
| Self::LimitFrequency
|
||||
| Self::Experiment
|
||||
| Self::FastFrequency => vec!["System", "Frequency"],
|
||||
| Self::LimitFrequency
|
||||
| Self::Experiment
|
||||
| Self::FastFrequency => vec!["System", "Frequency"],
|
||||
| Self::BisimilarityKanellakisSmolka
|
||||
| Self::BisimilarityPaigeTarjanNoLabels
|
||||
| Self::BisimilarityPaigeTarjan
|
||||
| Self::GroupFunction => vec!["System", "Bisimilarity"],
|
||||
| Self::BisimilarityPaigeTarjanNoLabels
|
||||
| Self::BisimilarityPaigeTarjan
|
||||
| Self::GroupFunction => vec!["System", "Bisimilarity"],
|
||||
| Self::SystemGraph => vec!["System", "Graph"],
|
||||
| Self::Dot
|
||||
| Self::DisplayNode
|
||||
| Self::DisplayEdge
|
||||
| Self::ColorNode
|
||||
| Self::ColorEdge
|
||||
| Self::GraphML => vec!["Graph"],
|
||||
| Self::DisplayNode
|
||||
| Self::DisplayEdge
|
||||
| Self::ColorNode
|
||||
| Self::ColorEdge
|
||||
| Self::GraphML => vec!["Graph"],
|
||||
| Self::PositiveSystem
|
||||
| Self::PositiveTarget
|
||||
| Self::PositiveRun
|
||||
| Self::PositiveLoop
|
||||
| Self::PositiveFrequency
|
||||
| Self::PositiveLimitFrequency
|
||||
| Self::PositiveFastFrequency
|
||||
| Self::PositiveSet
|
||||
| Self::ToPositiveSet => vec!["Positive System"],
|
||||
| Self::PositiveTarget
|
||||
| Self::PositiveRun
|
||||
| Self::PositiveLoop
|
||||
| Self::PositiveFrequency
|
||||
| Self::PositiveLimitFrequency
|
||||
| Self::PositiveFastFrequency
|
||||
| Self::PositiveSet
|
||||
| Self::ToPositiveSet => vec!["Positive System"],
|
||||
| Self::Trace => vec!["Trace", "System"],
|
||||
| Self::PositiveTrace => vec!["Trace", "Positive System"],
|
||||
| Self::SliceTrace
|
||||
| Self::PositiveSliceTrace => vec!["Trace"],
|
||||
| Self::SliceTrace | Self::PositiveSliceTrace => vec!["Trace"],
|
||||
}
|
||||
}
|
||||
|
||||
@ -1097,9 +1092,9 @@ impl NodeDataTrait for NodeData {
|
||||
match (is_active, graph[node_id].user_data.template) {
|
||||
| (_, NodeInstruction::SaveString) => {
|
||||
if ui.button("Write").clicked() {
|
||||
responses.push(NodeResponse::User(CustomResponse::SaveToFile(
|
||||
node_id,
|
||||
)));
|
||||
responses.push(NodeResponse::User(
|
||||
CustomResponse::SaveToFile(node_id),
|
||||
));
|
||||
}
|
||||
},
|
||||
| (true, _) => {
|
||||
@ -1108,8 +1103,9 @@ impl NodeDataTrait for NodeData {
|
||||
)
|
||||
.fill(egui::Color32::GOLD);
|
||||
if ui.add(button).clicked() {
|
||||
responses
|
||||
.push(NodeResponse::User(CustomResponse::ClearActiveNode));
|
||||
responses.push(NodeResponse::User(
|
||||
CustomResponse::ClearActiveNode,
|
||||
));
|
||||
}
|
||||
},
|
||||
| (false, _) =>
|
||||
@ -1412,7 +1408,7 @@ fn create_output(ng: &mut AppHandle, ctx: &egui::Context) -> LayoutJob {
|
||||
ctx,
|
||||
),
|
||||
&ng.user_state.translator,
|
||||
ctx
|
||||
ctx,
|
||||
);
|
||||
},
|
||||
| (None, None) => {
|
||||
@ -1431,7 +1427,7 @@ fn create_output(ng: &mut AppHandle, ctx: &egui::Context) -> LayoutJob {
|
||||
fn get_layout(
|
||||
value: anyhow::Result<BasicValue>,
|
||||
translator: &rsprocess::translator::Translator,
|
||||
ctx: &egui::Context
|
||||
ctx: &egui::Context,
|
||||
) -> LayoutJob {
|
||||
let mut text = LayoutJob::default();
|
||||
|
||||
@ -1439,7 +1435,8 @@ fn get_layout(
|
||||
| Ok(value) => match value {
|
||||
| BasicValue::SaveString { path, value: _ } => text.append(
|
||||
&format!("Saving to file \"{}\"", path),
|
||||
0., Default::default()
|
||||
0.,
|
||||
Default::default(),
|
||||
),
|
||||
| BasicValue::Error { value } => {
|
||||
text = value;
|
||||
@ -1451,7 +1448,8 @@ fn get_layout(
|
||||
text.append(&value, 0., Default::default()),
|
||||
| BasicValue::System { value } => text.append(
|
||||
&format!("{}", Formatter::from(translator, &value)),
|
||||
0., Default::default(),
|
||||
0.,
|
||||
Default::default(),
|
||||
),
|
||||
| BasicValue::PositiveInt { value } =>
|
||||
text.append(&format!("{value}"), 0., Default::default()),
|
||||
@ -1465,7 +1463,8 @@ fn get_layout(
|
||||
weight,
|
||||
Formatter::from(translator, set)
|
||||
),
|
||||
0., Default::default(),
|
||||
0.,
|
||||
Default::default(),
|
||||
)
|
||||
}
|
||||
},
|
||||
@ -1475,11 +1474,13 @@ fn get_layout(
|
||||
value.node_count(),
|
||||
value.edge_count()
|
||||
),
|
||||
0., Default::default(),
|
||||
0.,
|
||||
Default::default(),
|
||||
),
|
||||
| BasicValue::GroupingFunction { value } => text.append(
|
||||
&format!("{}", Formatter::from(translator, &value)),
|
||||
0., Default::default(),
|
||||
0.,
|
||||
Default::default(),
|
||||
),
|
||||
| BasicValue::DisplayNode { value } =>
|
||||
text.append(&format!("{value:?}"), 0., TextFormat {
|
||||
@ -1493,15 +1494,18 @@ fn get_layout(
|
||||
text.append(&format!("{value:?}"), 0., Default::default()),
|
||||
| BasicValue::Environment { value } => text.append(
|
||||
&format!("{}", Formatter::from(translator, &value)),
|
||||
0., Default::default(),
|
||||
0.,
|
||||
Default::default(),
|
||||
),
|
||||
| BasicValue::Set { value } => text.append(
|
||||
&format!("{}", Formatter::from(translator, &value)),
|
||||
0., Default::default(),
|
||||
0.,
|
||||
Default::default(),
|
||||
),
|
||||
| BasicValue::Context { value } => text.append(
|
||||
&format!("{}", Formatter::from(translator, &value)),
|
||||
0., Default::default(),
|
||||
0.,
|
||||
Default::default(),
|
||||
),
|
||||
| BasicValue::Reactions { value } => {
|
||||
text.append("(", 0., TextFormat {
|
||||
@ -1512,12 +1516,14 @@ fn get_layout(
|
||||
if i.peek().is_some() {
|
||||
text.append(
|
||||
&format!("{}, ", Formatter::from(translator, r)),
|
||||
0., Default::default(),
|
||||
0.,
|
||||
Default::default(),
|
||||
);
|
||||
} else {
|
||||
text.append(
|
||||
&format!("{}", Formatter::from(translator, r)),
|
||||
0., Default::default(),
|
||||
0.,
|
||||
Default::default(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1525,13 +1531,15 @@ fn get_layout(
|
||||
},
|
||||
| BasicValue::PositiveSystem { value } => text.append(
|
||||
&format!("{}", Formatter::from(translator, &value)),
|
||||
0., Default::default(),
|
||||
0.,
|
||||
Default::default(),
|
||||
),
|
||||
| BasicValue::Trace { value } => text.append(
|
||||
&format!("{}", Formatter::from(translator, &value)),
|
||||
0.,
|
||||
TextFormat {
|
||||
font_id: eframe::egui::TextStyle::Monospace.resolve(&ctx.style()),
|
||||
font_id: eframe::egui::TextStyle::Monospace
|
||||
.resolve(&ctx.style()),
|
||||
..Default::default()
|
||||
},
|
||||
),
|
||||
@ -1539,13 +1547,15 @@ fn get_layout(
|
||||
&format!("{}", Formatter::from(translator, &value)),
|
||||
0.,
|
||||
TextFormat {
|
||||
font_id: eframe::egui::TextStyle::Monospace.resolve(&ctx.style()),
|
||||
font_id: eframe::egui::TextStyle::Monospace
|
||||
.resolve(&ctx.style()),
|
||||
..Default::default()
|
||||
},
|
||||
),
|
||||
| BasicValue::PositiveSet { value } => text.append(
|
||||
&format!("{}", Formatter::from(translator, &value)),
|
||||
0., Default::default(),
|
||||
0.,
|
||||
Default::default(),
|
||||
),
|
||||
},
|
||||
| Err(err) => {
|
||||
|
||||
@ -7,7 +7,7 @@ use rsprocess::system::{ExtensionsSystem, LoopSystem};
|
||||
use rsprocess::translator::Formatter;
|
||||
|
||||
use crate::app::{
|
||||
BasicDataType, NodeData, NodeInstruction, BasicValue, OutputsCache,
|
||||
BasicDataType, BasicValue, NodeData, NodeInstruction, OutputsCache,
|
||||
};
|
||||
use crate::helper;
|
||||
|
||||
@ -164,6 +164,8 @@ fn generate_to_evaluate(
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn process_template(
|
||||
graph: &MyGraph,
|
||||
@ -175,7 +177,6 @@ fn process_template(
|
||||
to_ret: &mut Option<BasicValue>,
|
||||
ctx: &eframe::egui::Context,
|
||||
) -> anyhow::Result<Option<BasicValue>> {
|
||||
|
||||
// macro that builds a tuple of retrieved values from cache
|
||||
// same order as in the definition of the inputs
|
||||
macro_rules! retrieve_from_cache {
|
||||
@ -284,7 +285,8 @@ fn process_template(
|
||||
|
||||
(@as_expr $e:expr) => {$e};
|
||||
[0] => {
|
||||
compile_error!("Macro returns a value or a tuple, supply an integer greater than 0")
|
||||
compile_error!("Macro returns a value or a tuple, supply an \
|
||||
integer greater than 0")
|
||||
};
|
||||
[1] => {
|
||||
outputs_cache.retrieve_cache_output(
|
||||
@ -300,11 +302,15 @@ fn process_template(
|
||||
};
|
||||
}
|
||||
|
||||
// creates a vector of the hash of the inputs
|
||||
macro_rules! hash_inputs {
|
||||
($($i:ident),*) => (vec![$(OutputsCache::calculate_hash(&$i)),*]);
|
||||
}
|
||||
|
||||
match template {
|
||||
| NodeInstruction::String => {
|
||||
let s = retrieve_from_cache![1];
|
||||
|
||||
let hash_inputs = vec![OutputsCache::calculate_hash(&s)];
|
||||
let hash_inputs = hash_inputs!(s);
|
||||
|
||||
if let BasicValue::String { value: _ } = s {
|
||||
let res = s;
|
||||
@ -321,8 +327,7 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::Path => {
|
||||
let s = retrieve_from_cache![1];
|
||||
|
||||
let hash_inputs = vec![OutputsCache::calculate_hash(&s)];
|
||||
let hash_inputs = hash_inputs!(s);
|
||||
|
||||
if let BasicValue::String { value } = s {
|
||||
let res = BasicValue::Path { value };
|
||||
@ -339,20 +344,20 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::ReadPath => {
|
||||
let s = retrieve_from_cache![1];
|
||||
|
||||
let hash_inputs = vec![OutputsCache::calculate_hash(&s)];
|
||||
let hash_inputs = hash_inputs!(s);
|
||||
|
||||
if let BasicValue::Path { value } = s {
|
||||
let file = match std::fs::read_to_string(value) {
|
||||
Ok(f) => f,
|
||||
Err(e) =>
|
||||
| Ok(f) => f,
|
||||
| Err(e) =>
|
||||
return Ok(Some(BasicValue::Error {
|
||||
value: helper::reformat_generic_error(e.to_string(), ctx)
|
||||
}))
|
||||
};
|
||||
let res = BasicValue::String {
|
||||
value: file
|
||||
value: helper::reformat_generic_error(
|
||||
e.to_string(),
|
||||
ctx,
|
||||
),
|
||||
})),
|
||||
};
|
||||
let res = BasicValue::String { value: file };
|
||||
outputs_cache.populate_output(
|
||||
graph,
|
||||
node_id,
|
||||
@ -366,8 +371,7 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::System => {
|
||||
let s = retrieve_from_cache![1];
|
||||
|
||||
let hash_inputs = vec![OutputsCache::calculate_hash(&s)];
|
||||
let hash_inputs = hash_inputs!(s);
|
||||
|
||||
if let BasicValue::String { value } = s {
|
||||
let res = grammar_separated::grammar::SystemParser::new()
|
||||
@ -398,8 +402,7 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::Statistics => {
|
||||
let s = retrieve_from_cache![1];
|
||||
|
||||
let hash_inputs = vec![OutputsCache::calculate_hash(&s)];
|
||||
let hash_inputs = hash_inputs!(s);
|
||||
|
||||
if let BasicValue::System { value } = s {
|
||||
let res = BasicValue::String {
|
||||
@ -418,11 +421,8 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::Target => {
|
||||
let (s, i) = retrieve_from_cache![2];
|
||||
let hash_inputs = hash_inputs!(s, i);
|
||||
|
||||
let hash_inputs = vec![
|
||||
OutputsCache::calculate_hash(&s),
|
||||
OutputsCache::calculate_hash(&i),
|
||||
];
|
||||
match (s, i) {
|
||||
| (
|
||||
BasicValue::System { value: s },
|
||||
@ -463,11 +463,8 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::Run => {
|
||||
let (s, i) = retrieve_from_cache![2];
|
||||
let hash_inputs = hash_inputs!(s, i);
|
||||
|
||||
let hash_inputs = vec![
|
||||
OutputsCache::calculate_hash(&s),
|
||||
OutputsCache::calculate_hash(&i),
|
||||
];
|
||||
match (s, i) {
|
||||
| (
|
||||
BasicValue::System { value: s },
|
||||
@ -512,11 +509,8 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::Loop => {
|
||||
let (s, i) = retrieve_from_cache![2];
|
||||
let hash_inputs = hash_inputs!(s, i);
|
||||
|
||||
let hash_inputs = vec![
|
||||
OutputsCache::calculate_hash(&s),
|
||||
OutputsCache::calculate_hash(&i),
|
||||
];
|
||||
match (s, i) {
|
||||
| (
|
||||
BasicValue::System { value: sys },
|
||||
@ -556,8 +550,8 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::Symbol => {
|
||||
let s = retrieve_from_cache![1];
|
||||
let hash_inputs = hash_inputs!(s);
|
||||
|
||||
let hash_inputs = vec![OutputsCache::calculate_hash(&s)];
|
||||
if let BasicValue::String { value } = s {
|
||||
let res = BasicValue::Symbol { value };
|
||||
outputs_cache.populate_output(
|
||||
@ -573,8 +567,7 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::Frequency => {
|
||||
let s = retrieve_from_cache![1];
|
||||
|
||||
let hash_inputs = vec![OutputsCache::calculate_hash(&s)];
|
||||
let hash_inputs = hash_inputs!(s);
|
||||
|
||||
if let BasicValue::System { value } = s {
|
||||
let res = match rsprocess::frequency::Frequency::naive_frequency(
|
||||
@ -601,11 +594,8 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::LimitFrequency => {
|
||||
let (sys, exp) = retrieve_from_cache![2];
|
||||
let hash_inputs = hash_inputs!(sys, exp);
|
||||
|
||||
let hash_inputs = vec![
|
||||
OutputsCache::calculate_hash(&sys),
|
||||
OutputsCache::calculate_hash(&exp),
|
||||
];
|
||||
match (sys, exp) {
|
||||
| (
|
||||
BasicValue::System { value: sys },
|
||||
@ -644,8 +634,8 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::Experiment => {
|
||||
let s = retrieve_from_cache![1];
|
||||
let hash_inputs = hash_inputs!(s);
|
||||
|
||||
let hash_inputs = vec![OutputsCache::calculate_hash(&s)];
|
||||
if let BasicValue::String { value } = s {
|
||||
let value =
|
||||
match grammar_separated::grammar::ExperimentParser::new()
|
||||
@ -671,11 +661,8 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::FastFrequency => {
|
||||
let (sys, exp) = retrieve_from_cache![2];
|
||||
let hash_inputs = hash_inputs!(sys, exp);
|
||||
|
||||
let hash_inputs = vec![
|
||||
OutputsCache::calculate_hash(&sys),
|
||||
OutputsCache::calculate_hash(&exp),
|
||||
];
|
||||
match (sys, exp) {
|
||||
| (
|
||||
BasicValue::System { value: sys },
|
||||
@ -715,12 +702,8 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::BisimilarityKanellakisSmolka => {
|
||||
let (graph_1, graph_2, grouping) = retrieve_from_cache![3];
|
||||
let hash_inputs = hash_inputs!(graph_1, graph_2, grouping);
|
||||
|
||||
let hash_inputs = vec![
|
||||
OutputsCache::calculate_hash(&graph_1),
|
||||
OutputsCache::calculate_hash(&graph_2),
|
||||
OutputsCache::calculate_hash(&grouping),
|
||||
];
|
||||
match (graph_1, graph_2, grouping) {
|
||||
| (
|
||||
BasicValue::Graph { value: graph_1 },
|
||||
@ -756,8 +739,7 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::GroupFunction => {
|
||||
let s = retrieve_from_cache![1];
|
||||
|
||||
let hash_inputs = vec![OutputsCache::calculate_hash(&s)];
|
||||
let hash_inputs = hash_inputs!(s);
|
||||
|
||||
if let BasicValue::String { value } = s {
|
||||
let res = grammar_separated::assert::AssertParser::new()
|
||||
@ -788,12 +770,8 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::BisimilarityPaigeTarjanNoLabels => {
|
||||
let (graph_1, graph_2, grouping) = retrieve_from_cache![3];
|
||||
let hash_inputs = hash_inputs!(graph_1, graph_2, grouping);
|
||||
|
||||
let hash_inputs = vec![
|
||||
OutputsCache::calculate_hash(&graph_1),
|
||||
OutputsCache::calculate_hash(&graph_2),
|
||||
OutputsCache::calculate_hash(&grouping),
|
||||
];
|
||||
match (graph_1, graph_2, grouping) {
|
||||
| (
|
||||
BasicValue::Graph { value: graph_1 },
|
||||
@ -829,12 +807,8 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::BisimilarityPaigeTarjan => {
|
||||
let (graph_1, graph_2, grouping) = retrieve_from_cache![3];
|
||||
let hash_inputs = hash_inputs!(graph_1, graph_2, grouping);
|
||||
|
||||
let hash_inputs = vec![
|
||||
OutputsCache::calculate_hash(&graph_1),
|
||||
OutputsCache::calculate_hash(&graph_2),
|
||||
OutputsCache::calculate_hash(&grouping),
|
||||
];
|
||||
match (graph_1, graph_2, grouping) {
|
||||
| (
|
||||
BasicValue::Graph { value: graph_1 },
|
||||
@ -873,8 +847,7 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::SystemGraph => {
|
||||
let s = retrieve_from_cache![1];
|
||||
|
||||
let hash_inputs = vec![OutputsCache::calculate_hash(&s)];
|
||||
let hash_inputs = hash_inputs!(s);
|
||||
|
||||
if let BasicValue::System { value } = s {
|
||||
let value = match value.digraph() {
|
||||
@ -915,16 +888,21 @@ fn process_template(
|
||||
}
|
||||
},
|
||||
| NodeInstruction::Dot => {
|
||||
let (input_graph, display_node, display_edge, color_node, color_edge) =
|
||||
retrieve_from_cache![5];
|
||||
let (
|
||||
input_graph,
|
||||
display_node,
|
||||
display_edge,
|
||||
color_node,
|
||||
color_edge,
|
||||
) = retrieve_from_cache![5];
|
||||
let hash_inputs = hash_inputs!(
|
||||
input_graph,
|
||||
display_node,
|
||||
display_edge,
|
||||
color_node,
|
||||
color_edge
|
||||
);
|
||||
|
||||
let hash_inputs = vec![
|
||||
OutputsCache::calculate_hash(&input_graph),
|
||||
OutputsCache::calculate_hash(&display_node),
|
||||
OutputsCache::calculate_hash(&display_edge),
|
||||
OutputsCache::calculate_hash(&color_node),
|
||||
OutputsCache::calculate_hash(&color_edge),
|
||||
];
|
||||
match (
|
||||
input_graph,
|
||||
display_node,
|
||||
@ -986,8 +964,7 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::DisplayNode => {
|
||||
let s = retrieve_from_cache![1];
|
||||
|
||||
let hash_inputs = vec![OutputsCache::calculate_hash(&s)];
|
||||
let hash_inputs = hash_inputs!(s);
|
||||
|
||||
if let BasicValue::String { value } = s {
|
||||
let res =
|
||||
@ -1019,8 +996,7 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::DisplayEdge => {
|
||||
let s = retrieve_from_cache![1];
|
||||
|
||||
let hash_inputs = vec![OutputsCache::calculate_hash(&s)];
|
||||
let hash_inputs = hash_inputs!(s);
|
||||
|
||||
if let BasicValue::String { value } = s {
|
||||
let res =
|
||||
@ -1052,8 +1028,7 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::ColorNode => {
|
||||
let s = retrieve_from_cache![1];
|
||||
|
||||
let hash_inputs = vec![OutputsCache::calculate_hash(&s)];
|
||||
let hash_inputs = hash_inputs!(s);
|
||||
|
||||
if let BasicValue::String { value } = s {
|
||||
let res =
|
||||
@ -1085,8 +1060,7 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::ColorEdge => {
|
||||
let s = retrieve_from_cache![1];
|
||||
|
||||
let hash_inputs = vec![OutputsCache::calculate_hash(&s)];
|
||||
let hash_inputs = hash_inputs!(s);
|
||||
|
||||
if let BasicValue::String { value } = s {
|
||||
let res =
|
||||
@ -1117,13 +1091,11 @@ fn process_template(
|
||||
}
|
||||
},
|
||||
| NodeInstruction::GraphML => {
|
||||
let (input_graph, display_node, display_edge) = retrieve_from_cache![3];
|
||||
let (input_graph, display_node, display_edge) =
|
||||
retrieve_from_cache![3];
|
||||
let hash_inputs =
|
||||
hash_inputs!(input_graph, display_node, display_edge);
|
||||
|
||||
let hash_inputs = vec![
|
||||
OutputsCache::calculate_hash(&input_graph),
|
||||
OutputsCache::calculate_hash(&display_node),
|
||||
OutputsCache::calculate_hash(&display_edge),
|
||||
];
|
||||
match (input_graph, display_node, display_edge) {
|
||||
| (
|
||||
BasicValue::Graph { value: input_graph },
|
||||
@ -1166,15 +1138,18 @@ fn process_template(
|
||||
}
|
||||
},
|
||||
| NodeInstruction::ComposeSystem => {
|
||||
let (input_env, input_initial_etities, input_context, input_reactions)
|
||||
= retrieve_from_cache![4];
|
||||
|
||||
let hash_inputs = vec![
|
||||
OutputsCache::calculate_hash(&input_env),
|
||||
OutputsCache::calculate_hash(&input_initial_etities),
|
||||
OutputsCache::calculate_hash(&input_context),
|
||||
OutputsCache::calculate_hash(&input_reactions),
|
||||
];
|
||||
let (
|
||||
input_env,
|
||||
input_initial_etities,
|
||||
input_context,
|
||||
input_reactions,
|
||||
) = retrieve_from_cache![4];
|
||||
let hash_inputs = hash_inputs!(
|
||||
input_env,
|
||||
input_initial_etities,
|
||||
input_context,
|
||||
input_reactions
|
||||
);
|
||||
|
||||
match (
|
||||
input_env,
|
||||
@ -1211,8 +1186,7 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::Environment => {
|
||||
let s = retrieve_from_cache![1];
|
||||
|
||||
let hash_inputs = vec![OutputsCache::calculate_hash(&s)];
|
||||
let hash_inputs = hash_inputs!(s);
|
||||
|
||||
if let BasicValue::String { value } = s {
|
||||
let res = grammar_separated::grammar::EnvironmentParser::new()
|
||||
@ -1243,8 +1217,7 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::Set => {
|
||||
let s = retrieve_from_cache![1];
|
||||
|
||||
let hash_inputs = vec![OutputsCache::calculate_hash(&s)];
|
||||
let hash_inputs = hash_inputs!(s);
|
||||
|
||||
if let BasicValue::String { value } = s {
|
||||
let res = grammar_separated::grammar::SetParser::new()
|
||||
@ -1275,8 +1248,7 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::Context => {
|
||||
let s = retrieve_from_cache![1];
|
||||
|
||||
let hash_inputs = vec![OutputsCache::calculate_hash(&s)];
|
||||
let hash_inputs = hash_inputs!(s);
|
||||
|
||||
if let BasicValue::String { value } = s {
|
||||
let res = grammar_separated::grammar::ContextParser::new()
|
||||
@ -1307,8 +1279,7 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::Reactions => {
|
||||
let s = retrieve_from_cache![1];
|
||||
|
||||
let hash_inputs = vec![OutputsCache::calculate_hash(&s)];
|
||||
let hash_inputs = hash_inputs!(s);
|
||||
|
||||
if let BasicValue::String { value } = s {
|
||||
let res = grammar_separated::grammar::ReactionsParser::new()
|
||||
@ -1339,8 +1310,7 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::PositiveSystem => {
|
||||
let s = retrieve_from_cache![1];
|
||||
|
||||
let hash_inputs = vec![OutputsCache::calculate_hash(&s)];
|
||||
let hash_inputs = hash_inputs!(s);
|
||||
|
||||
if let BasicValue::System { value } = s {
|
||||
let res = BasicValue::PositiveSystem {
|
||||
@ -1359,11 +1329,8 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::PositiveTarget => {
|
||||
let (s, i) = retrieve_from_cache![2];
|
||||
let hash_inputs = hash_inputs!(s, i);
|
||||
|
||||
let hash_inputs = vec![
|
||||
OutputsCache::calculate_hash(&s),
|
||||
OutputsCache::calculate_hash(&i),
|
||||
];
|
||||
match (s, i) {
|
||||
| (
|
||||
BasicValue::PositiveSystem { value: s },
|
||||
@ -1404,11 +1371,8 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::PositiveRun => {
|
||||
let (s, i) = retrieve_from_cache![2];
|
||||
let hash_inputs = hash_inputs!(s, i);
|
||||
|
||||
let hash_inputs = vec![
|
||||
OutputsCache::calculate_hash(&s),
|
||||
OutputsCache::calculate_hash(&i),
|
||||
];
|
||||
match (s, i) {
|
||||
| (
|
||||
BasicValue::PositiveSystem { value: s },
|
||||
@ -1453,11 +1417,8 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::PositiveLoop => {
|
||||
let (s, i) = retrieve_from_cache![2];
|
||||
let hash_inputs = hash_inputs!(s, i);
|
||||
|
||||
let hash_inputs = vec![
|
||||
OutputsCache::calculate_hash(&s),
|
||||
OutputsCache::calculate_hash(&i),
|
||||
];
|
||||
match (s, i) {
|
||||
| (
|
||||
BasicValue::PositiveSystem { value: sys },
|
||||
@ -1497,8 +1458,7 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::PositiveFrequency => {
|
||||
let s = retrieve_from_cache![1];
|
||||
|
||||
let hash_inputs = vec![OutputsCache::calculate_hash(&s)];
|
||||
let hash_inputs = hash_inputs!(s);
|
||||
|
||||
if let BasicValue::PositiveSystem { value } = s {
|
||||
let res = match rsprocess::frequency::PositiveFrequency::naive_frequency(&value) {
|
||||
@ -1523,11 +1483,8 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::PositiveLimitFrequency => {
|
||||
let (sys, exp) = retrieve_from_cache![2];
|
||||
let hash_inputs = hash_inputs!(sys, exp);
|
||||
|
||||
let hash_inputs = vec![
|
||||
OutputsCache::calculate_hash(&sys),
|
||||
OutputsCache::calculate_hash(&exp),
|
||||
];
|
||||
match (sys, exp) {
|
||||
| (
|
||||
BasicValue::PositiveSystem { value: sys },
|
||||
@ -1567,11 +1524,8 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::PositiveFastFrequency => {
|
||||
let (sys, exp) = retrieve_from_cache![2];
|
||||
let hash_inputs = hash_inputs!(sys, exp);
|
||||
|
||||
let hash_inputs = vec![
|
||||
OutputsCache::calculate_hash(&sys),
|
||||
OutputsCache::calculate_hash(&exp),
|
||||
];
|
||||
match (sys, exp) {
|
||||
| (
|
||||
BasicValue::PositiveSystem { value: sys },
|
||||
@ -1612,27 +1566,25 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::Trace => {
|
||||
let (s, limit) = retrieve_from_cache![2];
|
||||
let hash_inputs = hash_inputs!(s, limit);
|
||||
|
||||
let hash_inputs = vec![
|
||||
OutputsCache::calculate_hash(&s),
|
||||
OutputsCache::calculate_hash(&limit),
|
||||
];
|
||||
match (s, limit) {
|
||||
| (BasicValue::System { value: s }, BasicValue::PositiveInt { value: limit }) => {
|
||||
| (
|
||||
BasicValue::System { value: s },
|
||||
BasicValue::PositiveInt { value: limit },
|
||||
) => {
|
||||
let trace = if limit == 0 {
|
||||
match s.slice_trace() {
|
||||
Ok(t) => t,
|
||||
Err(e) => anyhow::bail!(e),
|
||||
| Ok(t) => t,
|
||||
| Err(e) => anyhow::bail!(e),
|
||||
}
|
||||
} else {
|
||||
match s.slice_trace_limit(limit) {
|
||||
Ok(t) => t,
|
||||
Err(e) => anyhow::bail!(e),
|
||||
| Ok(t) => t,
|
||||
| Err(e) => anyhow::bail!(e),
|
||||
}
|
||||
};
|
||||
let res = BasicValue::Trace {
|
||||
value: trace,
|
||||
};
|
||||
let res = BasicValue::Trace { value: trace };
|
||||
outputs_cache.populate_output(
|
||||
graph,
|
||||
node_id,
|
||||
@ -1645,35 +1597,30 @@ fn process_template(
|
||||
anyhow::bail!("Not a positive integer"),
|
||||
| (_, BasicValue::PositiveInt { value: _ }) =>
|
||||
anyhow::bail!("Not a system"),
|
||||
| (_, _) =>
|
||||
anyhow::bail!("Inputs all wrong"),
|
||||
| (_, _) => anyhow::bail!("Inputs all wrong"),
|
||||
}
|
||||
},
|
||||
| NodeInstruction::PositiveTrace => {
|
||||
let (s, limit) = retrieve_from_cache![2];
|
||||
let hash_inputs = hash_inputs!(s, limit);
|
||||
|
||||
let hash_inputs = vec![
|
||||
OutputsCache::calculate_hash(&s),
|
||||
OutputsCache::calculate_hash(&limit),
|
||||
];
|
||||
match (s, limit) {
|
||||
| (BasicValue::PositiveSystem { value: s },
|
||||
BasicValue::PositiveInt { value: limit }) =>
|
||||
{
|
||||
| (
|
||||
BasicValue::PositiveSystem { value: s },
|
||||
BasicValue::PositiveInt { value: limit },
|
||||
) => {
|
||||
let trace = if limit == 0 {
|
||||
match s.slice_trace() {
|
||||
Ok(t) => t,
|
||||
Err(e) => anyhow::bail!(e),
|
||||
| Ok(t) => t,
|
||||
| Err(e) => anyhow::bail!(e),
|
||||
}
|
||||
} else {
|
||||
match s.slice_trace_limit(limit) {
|
||||
Ok(t) => t,
|
||||
Err(e) => anyhow::bail!(e),
|
||||
| Ok(t) => t,
|
||||
| Err(e) => anyhow::bail!(e),
|
||||
}
|
||||
};
|
||||
let res = BasicValue::PositiveTrace {
|
||||
value: trace,
|
||||
};
|
||||
let res = BasicValue::PositiveTrace { value: trace };
|
||||
outputs_cache.populate_output(
|
||||
graph,
|
||||
node_id,
|
||||
@ -1686,29 +1633,24 @@ fn process_template(
|
||||
anyhow::bail!("Not a positive integer"),
|
||||
| (_, BasicValue::PositiveInt { value: _ }) =>
|
||||
anyhow::bail!("Not a positive system"),
|
||||
| (_, _) =>
|
||||
anyhow::bail!("Inputs all wrong"),
|
||||
| (_, _) => anyhow::bail!("Inputs all wrong"),
|
||||
}
|
||||
},
|
||||
| NodeInstruction::SliceTrace => {
|
||||
let (trace, set) = retrieve_from_cache![2];
|
||||
let hash_inputs = hash_inputs!(trace, set);
|
||||
|
||||
let hash_inputs = vec![
|
||||
OutputsCache::calculate_hash(&trace),
|
||||
OutputsCache::calculate_hash(&set),
|
||||
];
|
||||
match (trace, set) {
|
||||
| (BasicValue::Trace { value: trace },
|
||||
BasicValue::Set { value: set }) =>
|
||||
{
|
||||
| (
|
||||
BasicValue::Trace { value: trace },
|
||||
BasicValue::Set { value: set },
|
||||
) => {
|
||||
let new_trace = match trace.slice(set) {
|
||||
Ok(t) => t,
|
||||
Err(e) => anyhow::bail!(e),
|
||||
| Ok(t) => t,
|
||||
| Err(e) => anyhow::bail!(e),
|
||||
};
|
||||
|
||||
let res = BasicValue::Trace {
|
||||
value: new_trace,
|
||||
};
|
||||
let res = BasicValue::Trace { value: new_trace };
|
||||
outputs_cache.populate_output(
|
||||
graph,
|
||||
node_id,
|
||||
@ -1721,29 +1663,24 @@ fn process_template(
|
||||
anyhow::bail!("Not a set"),
|
||||
| (_, BasicValue::Set { value: _ }) =>
|
||||
anyhow::bail!("Not a trace"),
|
||||
| (_, _) =>
|
||||
anyhow::bail!("Inputs all wrong"),
|
||||
| (_, _) => anyhow::bail!("Inputs all wrong"),
|
||||
}
|
||||
},
|
||||
| NodeInstruction::PositiveSliceTrace => {
|
||||
let (trace, set) = retrieve_from_cache![2];
|
||||
let hash_inputs = hash_inputs!(trace, set);
|
||||
|
||||
let hash_inputs = vec![
|
||||
OutputsCache::calculate_hash(&trace),
|
||||
OutputsCache::calculate_hash(&set),
|
||||
];
|
||||
match (trace, set) {
|
||||
| (BasicValue::PositiveTrace { value: trace },
|
||||
BasicValue::PositiveSet { value: set }) =>
|
||||
{
|
||||
| (
|
||||
BasicValue::PositiveTrace { value: trace },
|
||||
BasicValue::PositiveSet { value: set },
|
||||
) => {
|
||||
let new_trace = match trace.slice(set) {
|
||||
Ok(t) => t,
|
||||
Err(e) => anyhow::bail!(e),
|
||||
| Ok(t) => t,
|
||||
| Err(e) => anyhow::bail!(e),
|
||||
};
|
||||
|
||||
let res = BasicValue::PositiveTrace {
|
||||
value: new_trace,
|
||||
};
|
||||
let res = BasicValue::PositiveTrace { value: new_trace };
|
||||
outputs_cache.populate_output(
|
||||
graph,
|
||||
node_id,
|
||||
@ -1756,14 +1693,13 @@ fn process_template(
|
||||
anyhow::bail!("Not a set"),
|
||||
| (_, BasicValue::PositiveSet { value: _ }) =>
|
||||
anyhow::bail!("Not a trace"),
|
||||
| (_, _) =>
|
||||
anyhow::bail!("Inputs all wrong"),
|
||||
| (_, _) => anyhow::bail!("Inputs all wrong"),
|
||||
}
|
||||
},
|
||||
| NodeInstruction::PositiveSet => {
|
||||
let s = retrieve_from_cache![1];
|
||||
let hash_inputs = hash_inputs!(s);
|
||||
|
||||
let hash_inputs = vec![OutputsCache::calculate_hash(&s)];
|
||||
if let BasicValue::String { value } = s {
|
||||
let res = grammar_separated::grammar::PositiveSetParser::new()
|
||||
.parse(&mut *translator, &value);
|
||||
@ -1793,12 +1729,12 @@ fn process_template(
|
||||
},
|
||||
| NodeInstruction::ToPositiveSet => {
|
||||
let s = retrieve_from_cache![1];
|
||||
|
||||
let hash_inputs = vec![OutputsCache::calculate_hash(&s)];
|
||||
let hash_inputs = hash_inputs!(s);
|
||||
|
||||
if let BasicValue::Set { value } = s {
|
||||
let res = BasicValue::PositiveSet {
|
||||
value: value.to_positive_set(rsprocess::element::IdState::Positive)
|
||||
value: value
|
||||
.to_positive_set(rsprocess::element::IdState::Positive),
|
||||
};
|
||||
outputs_cache.populate_output(
|
||||
graph,
|
||||
@ -1810,7 +1746,7 @@ fn process_template(
|
||||
} else {
|
||||
anyhow::bail!("Not a string");
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
@ -165,15 +165,11 @@ where
|
||||
pub fn reformat_generic_error(
|
||||
e: impl Into<String>,
|
||||
_ctx: &eframe::egui::Context,
|
||||
) -> LayoutJob
|
||||
{
|
||||
) -> LayoutJob {
|
||||
let text_format = TextFormat {
|
||||
font_id: Default::default(),
|
||||
color: Color32::RED,
|
||||
..Default::default()
|
||||
};
|
||||
LayoutJob::single_section(
|
||||
e.into(),
|
||||
text_format
|
||||
)
|
||||
LayoutJob::single_section(e.into(), text_format)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user