@@ -541,22 +541,6 @@ impl Stack {
541
541
self . push_new_env_for_call ( snapshot) ;
542
542
}
543
543
544
- /// Push a new stack frame on to the call stack for callees which should not read or write
545
- /// from memory.
546
- ///
547
- /// This is suitable for calling standard library functions or other functions written in Rust
548
- /// which will use 'Rust memory' rather than KCL's memory and cannot reach into the wider
549
- /// environment.
550
- ///
551
- /// Trying to read or write from this environment will panic with an index out of bounds.
552
- pub fn push_new_env_for_rust_call ( & mut self ) {
553
- self . call_stack . push ( self . current_env ) ;
554
- // Rust functions shouldn't try to set or access anything in their environment, so don't
555
- // waste time and space on a new env. Using usize::MAX means we'll get an overflow if we
556
- // try to access anything rather than a silent error.
557
- self . current_env = EnvironmentRef ( usize:: MAX , 0 ) ;
558
- }
559
-
560
544
/// Push a new stack frame on to the call stack with no connection to a parent environment.
561
545
///
562
546
/// Suitable for executing a separate module.
@@ -683,7 +667,7 @@ impl Stack {
683
667
env. contains_key ( var)
684
668
}
685
669
686
- /// Get a key from the first KCL (i.e., non-Rust) stack frame on the call stack.
670
+ /// Get a key from the first stack frame on the call stack.
687
671
pub fn get_from_call_stack ( & self , key : & str , source_range : SourceRange ) -> Result < ( usize , & KclValue ) , KclError > {
688
672
if !self . current_env . skip_env ( ) {
689
673
return Ok ( ( self . current_env . 1 , self . get ( key, source_range) ?) ) ;
@@ -695,7 +679,7 @@ impl Stack {
695
679
}
696
680
}
697
681
698
- unreachable ! ( "It can't be Rust frames all the way down " ) ;
682
+ unreachable ! ( "No frames on the stack? " ) ;
699
683
}
700
684
701
685
/// Iterate over all keys in the current environment which satisfy the provided predicate.
@@ -1217,24 +1201,6 @@ mod test {
1217
1201
assert_get_from ( mem, "c" , 5 , callee) ;
1218
1202
}
1219
1203
1220
- #[ test]
1221
- fn rust_env ( ) {
1222
- let mem = & mut Stack :: new_for_tests ( ) ;
1223
- mem. add ( "a" . to_owned ( ) , val ( 1 ) , sr ( ) ) . unwrap ( ) ;
1224
- mem. add ( "b" . to_owned ( ) , val ( 3 ) , sr ( ) ) . unwrap ( ) ;
1225
- let sn = mem. snapshot ( ) ;
1226
-
1227
- mem. push_new_env_for_rust_call ( ) ;
1228
- mem. push_new_env_for_call ( sn) ;
1229
- assert_get ( mem, "b" , 3 ) ;
1230
- mem. add ( "b" . to_owned ( ) , val ( 4 ) , sr ( ) ) . unwrap ( ) ;
1231
- assert_get ( mem, "b" , 4 ) ;
1232
-
1233
- mem. pop_env ( ) ;
1234
- mem. pop_env ( ) ;
1235
- assert_get ( mem, "b" , 3 ) ;
1236
- }
1237
-
1238
1204
#[ test]
1239
1205
fn deep_call_env ( ) {
1240
1206
let mem = & mut Stack :: new_for_tests ( ) ;
0 commit comments