Add operations for variable declarations (#7451)
* Add operations for variable declarations * Update output * Change to use OpKclValue * Update output after merge
This commit is contained in:
@ -8,7 +8,8 @@ pub use artifact::{Artifact, ArtifactCommand, ArtifactGraph, CodeRef, StartSketc
|
||||
use cache::GlobalState;
|
||||
pub use cache::{bust_cache, clear_mem_cache};
|
||||
#[cfg(feature = "artifact-graph")]
|
||||
pub use cad_op::{Group, Operation};
|
||||
pub use cad_op::Group;
|
||||
pub use cad_op::Operation;
|
||||
pub use geometry::*;
|
||||
pub use id_generator::IdGenerator;
|
||||
pub(crate) use import::PreImportedGeometry;
|
||||
@ -1175,6 +1176,9 @@ impl ExecutorContext {
|
||||
/// SAFETY: the current thread must have sole access to the memory referenced in exec_state.
|
||||
async fn eval_prelude(&self, exec_state: &mut ExecState, source_range: SourceRange) -> Result<(), KclError> {
|
||||
if exec_state.stack().memory.requires_std() {
|
||||
#[cfg(feature = "artifact-graph")]
|
||||
let initial_ops = exec_state.global.artifacts.operations.len();
|
||||
|
||||
let path = vec!["std".to_owned(), "prelude".to_owned()];
|
||||
let resolved_path = ModulePath::from_std_import_path(&path)?;
|
||||
let id = self
|
||||
@ -1183,6 +1187,14 @@ impl ExecutorContext {
|
||||
let (module_memory, _) = self.exec_module_for_items(id, exec_state, source_range).await?;
|
||||
|
||||
exec_state.mut_stack().memory.set_std(module_memory);
|
||||
|
||||
// Operations generated by the prelude are not useful, so clear them
|
||||
// out.
|
||||
//
|
||||
// TODO: Should we also clear them out of each module so that they
|
||||
// don't appear in test output?
|
||||
#[cfg(feature = "artifact-graph")]
|
||||
exec_state.global.artifacts.operations.truncate(initial_ops);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
Reference in New Issue
Block a user