File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
interpreter/src/evaluator Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -365,9 +365,9 @@ fn three_body_threading(args: Vec<Object>) -> Object {
365
365
{
366
366
fn three_body_thread_new ( args : Vec < Object > ) -> Object {
367
367
match & args[ 0 ] {
368
- Object :: String ( input) => {
369
- let input = ( * input) . clone ( ) ;
368
+ Object :: Function ( params, ast, env ) => {
370
369
370
+ let stmts = ast. clone ( ) ;
371
371
let mut handle = std:: thread:: spawn ( move || {
372
372
let local_set = tokio:: task:: LocalSet :: new ( ) ;
373
373
let rt = tokio:: runtime:: Builder :: new_current_thread ( )
@@ -376,7 +376,12 @@ fn three_body_threading(args: Vec<Object>) -> Object {
376
376
. unwrap ( ) ;
377
377
378
378
// 在 LocalSet 中安排任务
379
- local_set. spawn_local ( async move { eval ( & input) } ) ;
379
+ local_set. spawn_local ( async move {
380
+ let mut ev = evaluator:: Evaluator {
381
+ env : Rc :: new ( RefCell :: new ( evaluator:: env:: Env :: from ( new_builtins ( ) ) ) ) ,
382
+ } ;
383
+ ev. eval ( & stmts) ;
384
+ } ) ;
380
385
381
386
// 运行 LocalSet 直到其中的任务完成
382
387
rt. block_on ( local_set) ;
@@ -385,7 +390,7 @@ fn three_body_threading(args: Vec<Object>) -> Object {
385
390
let handle = Box :: leak ( Box :: new ( handle) ) ;
386
391
let handle_ptr = & mut * handle as * mut std:: thread:: JoinHandle < ( ) > ;
387
392
Object :: Native ( Box :: new ( NativeObject :: Thread ( handle_ptr) ) )
388
- } ,
393
+ }
389
394
_ => panic ! ( )
390
395
}
391
396
}
You can’t perform that action at this time.
0 commit comments