@@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
99use uuid:: Uuid ;
1010
1111use crate :: {
12- CompilationError , EngineManager , ExecutorContext , KclErrorWithOutputs , SourceRange ,
12+ CompilationError , EngineManager , ExecutorContext , KclErrorWithOutputs , MockConfig , SourceRange ,
1313 collections:: AhashIndexSet ,
1414 errors:: { KclError , KclErrorDetails , Severity } ,
1515 exec:: DefaultPlanes ,
@@ -128,6 +128,9 @@ pub(super) struct ModuleState {
128128 pub module_exports : Vec < String > ,
129129 /// Settings specified from annotations.
130130 pub settings : MetaSettings ,
131+ /// True to do more costly analysis of whether the sketch block segments are
132+ /// under-constrained.
133+ pub freedom_analysis : bool ,
131134 pub ( super ) explicit_length_units : bool ,
132135 pub ( super ) path : ModulePath ,
133136 /// Artifacts for only this module.
@@ -151,14 +154,24 @@ impl ExecState {
151154 pub fn new ( exec_context : & super :: ExecutorContext ) -> Self {
152155 ExecState {
153156 global : GlobalState :: new ( & exec_context. settings , Default :: default ( ) ) ,
154- mod_local : ModuleState :: new ( ModulePath :: Main , ProgramMemory :: new ( ) , Default :: default ( ) , 0 ) ,
157+ mod_local : ModuleState :: new ( ModulePath :: Main , ProgramMemory :: new ( ) , Default :: default ( ) , 0 , false ) ,
155158 }
156159 }
157160
158- pub fn new_sketch_mode ( exec_context : & super :: ExecutorContext , segment_ids_edited : AhashIndexSet < ObjectId > ) -> Self {
161+ pub fn new_sketch_mode ( exec_context : & super :: ExecutorContext , mock_config : & MockConfig ) -> Self {
162+ #[ cfg( feature = "artifact-graph" ) ]
163+ let segment_ids_edited = mock_config. segment_ids_edited . clone ( ) ;
164+ #[ cfg( not( feature = "artifact-graph" ) ) ]
165+ let segment_ids_edited = Default :: default ( ) ;
159166 ExecState {
160167 global : GlobalState :: new ( & exec_context. settings , segment_ids_edited) ,
161- mod_local : ModuleState :: new ( ModulePath :: Main , ProgramMemory :: new ( ) , Default :: default ( ) , 0 ) ,
168+ mod_local : ModuleState :: new (
169+ ModulePath :: Main ,
170+ ProgramMemory :: new ( ) ,
171+ Default :: default ( ) ,
172+ 0 ,
173+ mock_config. freedom_analysis ,
174+ ) ,
162175 }
163176 }
164177
@@ -167,7 +180,13 @@ impl ExecState {
167180
168181 * self = ExecState {
169182 global,
170- mod_local : ModuleState :: new ( self . mod_local . path . clone ( ) , ProgramMemory :: new ( ) , Default :: default ( ) , 0 ) ,
183+ mod_local : ModuleState :: new (
184+ self . mod_local . path . clone ( ) ,
185+ ProgramMemory :: new ( ) ,
186+ Default :: default ( ) ,
187+ 0 ,
188+ false ,
189+ ) ,
171190 } ;
172191 }
173192
@@ -639,6 +658,7 @@ impl ModuleState {
639658 memory : Arc < ProgramMemory > ,
640659 module_id : Option < ModuleId > ,
641660 next_object_id : usize ,
661+ freedom_analysis : bool ,
642662 ) -> Self {
643663 #[ cfg( not( feature = "artifact-graph" ) ) ]
644664 let _ = next_object_id;
@@ -653,6 +673,7 @@ impl ModuleState {
653673 explicit_length_units : false ,
654674 path,
655675 settings : Default :: default ( ) ,
676+ freedom_analysis,
656677 #[ cfg( not( feature = "artifact-graph" ) ) ]
657678 artifacts : Default :: default ( ) ,
658679 #[ cfg( feature = "artifact-graph" ) ]
0 commit comments