Replace snapshot mechanism with epochs (#5764)
* Make tag identifiers monotonic Signed-off-by: Nick Cameron <nrc@ncameron.org> * Use epochs rather than snapshots in memory Signed-off-by: Nick Cameron <nrc@ncameron.org> --------- Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
@ -286,13 +286,16 @@ impl Args {
|
||||
exec_state: &'e mut ExecState,
|
||||
tag: &'a TagIdentifier,
|
||||
) -> Result<&'e crate::execution::TagEngineInfo, KclError> {
|
||||
if let KclValue::TagIdentifier(t) = exec_state.stack().get_from_call_stack(&tag.value, self.source_range)? {
|
||||
Ok(t.info.as_ref().ok_or_else(|| {
|
||||
if let (epoch, KclValue::TagIdentifier(t)) =
|
||||
exec_state.stack().get_from_call_stack(&tag.value, self.source_range)?
|
||||
{
|
||||
let info = t.get_info(epoch).ok_or_else(|| {
|
||||
KclError::Type(KclErrorDetails {
|
||||
message: format!("Tag `{}` does not have engine info", tag.value),
|
||||
source_ranges: vec![self.source_range],
|
||||
})
|
||||
})?)
|
||||
})?;
|
||||
Ok(info)
|
||||
} else {
|
||||
Err(KclError::Type(KclErrorDetails {
|
||||
message: format!("Tag `{}` does not exist", tag.value),
|
||||
@ -309,7 +312,7 @@ impl Args {
|
||||
where
|
||||
'e: 'a,
|
||||
{
|
||||
if let Some(info) = &tag.info {
|
||||
if let Some(info) = tag.get_cur_info() {
|
||||
return Ok(info);
|
||||
}
|
||||
|
||||
@ -324,7 +327,7 @@ impl Args {
|
||||
where
|
||||
'e: 'a,
|
||||
{
|
||||
if let Some(info) = &tag.info {
|
||||
if let Some(info) = tag.get_cur_info() {
|
||||
if info.surface.is_some() {
|
||||
return Ok(info);
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ async fn inner_circle(
|
||||
|
||||
let mut new_sketch = sketch.clone();
|
||||
if let Some(tag) = &tag {
|
||||
new_sketch.add_tag(tag, ¤t_path);
|
||||
new_sketch.add_tag(tag, ¤t_path, exec_state);
|
||||
}
|
||||
|
||||
new_sketch.paths.push(current_path);
|
||||
@ -251,7 +251,7 @@ async fn inner_circle_three_point(
|
||||
|
||||
let mut new_sketch = sketch.clone();
|
||||
if let Some(tag) = &tag {
|
||||
new_sketch.add_tag(tag, ¤t_path);
|
||||
new_sketch.add_tag(tag, ¤t_path, exec_state);
|
||||
}
|
||||
|
||||
new_sketch.paths.push(current_path);
|
||||
@ -414,7 +414,7 @@ async fn inner_polygon(
|
||||
};
|
||||
|
||||
if let Some(tag) = &tag {
|
||||
sketch.add_tag(tag, ¤t_path);
|
||||
sketch.add_tag(tag, ¤t_path, exec_state);
|
||||
}
|
||||
|
||||
sketch.paths.push(current_path);
|
||||
@ -450,7 +450,7 @@ async fn inner_polygon(
|
||||
};
|
||||
|
||||
if let Some(tag) = &tag {
|
||||
sketch.add_tag(tag, ¤t_path);
|
||||
sketch.add_tag(tag, ¤t_path, exec_state);
|
||||
}
|
||||
|
||||
sketch.paths.push(current_path);
|
||||
|
@ -253,7 +253,7 @@ async fn straight_line(
|
||||
|
||||
let mut new_sketch = sketch.clone();
|
||||
if let Some(tag) = &tag {
|
||||
new_sketch.add_tag(tag, ¤t_path);
|
||||
new_sketch.add_tag(tag, ¤t_path, exec_state);
|
||||
}
|
||||
|
||||
new_sketch.paths.push(current_path);
|
||||
@ -489,7 +489,7 @@ async fn inner_angled_line(
|
||||
|
||||
let mut new_sketch = sketch.clone();
|
||||
if let Some(tag) = &tag {
|
||||
new_sketch.add_tag(tag, ¤t_path);
|
||||
new_sketch.add_tag(tag, ¤t_path, exec_state);
|
||||
}
|
||||
|
||||
new_sketch.paths.push(current_path);
|
||||
@ -1280,14 +1280,17 @@ pub(crate) async fn inner_start_profile_at(
|
||||
meta: vec![args.source_range.into()],
|
||||
tags: if let Some(tag) = &tag {
|
||||
let mut tag_identifier: TagIdentifier = tag.into();
|
||||
tag_identifier.info = Some(TagEngineInfo {
|
||||
id: current_path.geo_meta.id,
|
||||
sketch: path_id,
|
||||
path: Some(Path::Base {
|
||||
base: current_path.clone(),
|
||||
}),
|
||||
surface: None,
|
||||
});
|
||||
tag_identifier.info = vec![(
|
||||
exec_state.stack().current_epoch(),
|
||||
TagEngineInfo {
|
||||
id: current_path.geo_meta.id,
|
||||
sketch: path_id,
|
||||
path: Some(Path::Base {
|
||||
base: current_path.clone(),
|
||||
}),
|
||||
surface: None,
|
||||
},
|
||||
)];
|
||||
IndexMap::from([(tag.name.to_string(), tag_identifier)])
|
||||
} else {
|
||||
Default::default()
|
||||
@ -1442,7 +1445,7 @@ pub(crate) async fn inner_close(
|
||||
|
||||
let mut new_sketch = sketch.clone();
|
||||
if let Some(tag) = &tag {
|
||||
new_sketch.add_tag(tag, ¤t_path);
|
||||
new_sketch.add_tag(tag, ¤t_path, exec_state);
|
||||
}
|
||||
|
||||
new_sketch.paths.push(current_path);
|
||||
@ -1595,7 +1598,7 @@ pub(crate) async fn inner_arc(
|
||||
|
||||
let mut new_sketch = sketch.clone();
|
||||
if let Some(tag) = &tag {
|
||||
new_sketch.add_tag(tag, ¤t_path);
|
||||
new_sketch.add_tag(tag, ¤t_path, exec_state);
|
||||
}
|
||||
|
||||
new_sketch.paths.push(current_path);
|
||||
@ -1697,7 +1700,7 @@ pub(crate) async fn inner_arc_to(
|
||||
|
||||
let mut new_sketch = sketch.clone();
|
||||
if let Some(tag) = &tag {
|
||||
new_sketch.add_tag(tag, ¤t_path);
|
||||
new_sketch.add_tag(tag, ¤t_path, exec_state);
|
||||
}
|
||||
|
||||
new_sketch.paths.push(current_path);
|
||||
@ -1848,7 +1851,7 @@ async fn inner_tangential_arc(
|
||||
|
||||
let mut new_sketch = sketch.clone();
|
||||
if let Some(tag) = &tag {
|
||||
new_sketch.add_tag(tag, ¤t_path);
|
||||
new_sketch.add_tag(tag, ¤t_path, exec_state);
|
||||
}
|
||||
|
||||
new_sketch.paths.push(current_path);
|
||||
@ -1945,7 +1948,7 @@ async fn inner_tangential_arc_to(
|
||||
|
||||
let mut new_sketch = sketch.clone();
|
||||
if let Some(tag) = &tag {
|
||||
new_sketch.add_tag(tag, ¤t_path);
|
||||
new_sketch.add_tag(tag, ¤t_path, exec_state);
|
||||
}
|
||||
|
||||
new_sketch.paths.push(current_path);
|
||||
@ -2029,7 +2032,7 @@ async fn inner_tangential_arc_to_relative(
|
||||
|
||||
let mut new_sketch = sketch.clone();
|
||||
if let Some(tag) = &tag {
|
||||
new_sketch.add_tag(tag, ¤t_path);
|
||||
new_sketch.add_tag(tag, ¤t_path, exec_state);
|
||||
}
|
||||
|
||||
new_sketch.paths.push(current_path);
|
||||
@ -2125,7 +2128,7 @@ async fn inner_bezier_curve(
|
||||
|
||||
let mut new_sketch = sketch.clone();
|
||||
if let Some(tag) = &tag {
|
||||
new_sketch.add_tag(tag, ¤t_path);
|
||||
new_sketch.add_tag(tag, ¤t_path, exec_state);
|
||||
}
|
||||
|
||||
new_sketch.paths.push(current_path);
|
||||
@ -2254,7 +2257,7 @@ mod tests {
|
||||
|
||||
str_json = serde_json::to_string(&TagIdentifier {
|
||||
value: "thing".to_string(),
|
||||
info: None,
|
||||
info: Vec::new(),
|
||||
meta: Default::default(),
|
||||
})
|
||||
.unwrap();
|
||||
@ -2263,7 +2266,7 @@ mod tests {
|
||||
data,
|
||||
crate::std::sketch::FaceTag::Tag(Box::new(TagIdentifier {
|
||||
value: "thing".to_string(),
|
||||
info: None,
|
||||
info: Vec::new(),
|
||||
meta: Default::default()
|
||||
}))
|
||||
);
|
||||
|
Reference in New Issue
Block a user