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;
22use rand:: seq:: SliceRandom ;
33use std:: collections:: HashMap ;
44use std:: env;
5+ use std:: thread;
56use std:: fs:: File ;
67use std:: io:: { self , Error , Read , Write } ;
78use std:: thread:: sleep;
@@ -143,6 +144,7 @@ impl Type {
143144}
144145
145146/// プログラム実行を管理
147+ #[ derive( Clone , Debug ) ]
146148struct Executor {
147149 stack : Vec < Type > , // スタック
148150 memory : HashMap < String , Type > , // 変数のメモリ領域
@@ -564,6 +566,14 @@ impl Executor {
564566 }
565567 }
566568
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+
567577 // シェルコマンドを実行
568578 "shell" => {
569579 let ps = PsScriptBuilder :: new ( )
You can’t perform that action at this time.
0 commit comments