File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change
1
+ ( (name) var
2
+ 1 4 1 range (i) (
3
+ name i concat print
4
+ 0.7 sleep
5
+ ) for
6
+ ) (hey) var
7
+
8
+ ((太郎) hey eval) thread
9
+ ((次郎) hey eval) thread
10
+ (三郎) hey eval
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ use powershell_script::PsScriptBuilder;
2
2
use rand:: seq:: SliceRandom ;
3
3
use std:: collections:: HashMap ;
4
4
use std:: env;
5
+ use std:: thread;
5
6
use std:: fs:: File ;
6
7
use std:: io:: { self , Error , Read , Write } ;
7
8
use std:: thread:: sleep;
@@ -143,6 +144,7 @@ impl Type {
143
144
}
144
145
145
146
/// プログラム実行を管理
147
+ #[ derive( Clone , Debug ) ]
146
148
struct Executor {
147
149
stack : Vec < Type > , // スタック
148
150
memory : HashMap < String , Type > , // 変数のメモリ領域
@@ -564,6 +566,14 @@ impl Executor {
564
566
}
565
567
}
566
568
569
+ "thread" => {
570
+ let code = self . pop_stack ( ) . get_string ( ) ;
571
+ let mut executor = self . clone ( ) ;
572
+ thread:: spawn ( move || {
573
+ executor. evaluate_program ( code)
574
+ } ) ;
575
+ }
576
+
567
577
// シェルコマンドを実行
568
578
"shell" => {
569
579
let ps = PsScriptBuilder :: new ( )
You can’t perform that action at this time.
0 commit comments