import Ġkotlinx . coroutines .* Ċ import Ġorg . lu aj . lu aj c . Core Test Ċ import Ġorg . lu aj . vm 2 . Lua Closure Ċ import Ġorg . lu aj . vm 2 . lib . j se . Co erce Java To Lua Ċ import Ġorg . lu aj . vm 2 . lib . j se . J se Platform Ċ import Ġjava . io . ByteArray InputStream Ċ import Ġjava . io . File Ċ import Ġjava . io . Object InputStream Ċ Ċ class ĠMain T Ġ{ Ċ } Ċ Ċ var Ġscript Ġ= ĊĠĠĠ Ġ" function Ġtest ( a 1 , b 1 , c 1 , d 1 , e 1 )\ n " Ġ+ ĊĠĠĠ Ġ" ĉ print ( a 1 .. b 1 .. c 1 .. d 1 .. e 1 )\ n "+ ĊĠĠĠ Ġ" ĠĠ Ġobj : core Delay ( 2 0 0 )\ n "+ ĊĠĠĠ Ġ" ĠĠ Ġlocal Ġa = obj : core Fun ()\ n "+ ĊĠĠĠ Ġ" ĉ print ( a )\ n "+ ĊĠĠĠ Ġ" ĠĠ Ġprint (\" end Ġof Ġtest \") \ n "+ ĊĠĠĠ Ġ" end \ n "+ ĊĠĠĠ Ġ" function Ġtest 2 ( a 1 , b 1 , c 1 , d 1 )\ n "+ ĊĠĠĠ Ġ" ĉ print ( a 1 .. b 1 .. c 1 .. d 1 )\ n "+ ĊĠĠĠ Ġ" ĠĠ Ġtest ( 1 , 2 , 3 , 4 , 5 )\ n "+ ĊĠĠĠ Ġ" ĠĠ Ġlocal Ġa 3 = obj : core Fun ()\ n "+ ĊĠĠĠ Ġ" ĉ print ( a 3 )\ n "+ ĊĠĠĠ Ġ" ĠĠ Ġprint (\" end Ġof Ġtest 2 \") \ n "+ ĊĠĠĠ Ġ" end \ n "+ ĊĠĠĠ Ġ" function Ġtest 3 ( a 1 , b 1 , c 1 )\ n "+ ĊĠĠĠ Ġ" ĉ print ( a 1 .. b 1 .. c 1 )\ n "+ ĊĠĠĠ Ġ" ĠĠ Ġlocal Ġa = obj : core Fun ()\ n "+ ĊĠĠĠ Ġ" ĉ print ( a )\ n "+ ĊĠĠĠ Ġ" ĠĠ Ġtest 2 ( 1 , 2 , 3 , 4 )\ n "+ ĊĠĠĠ Ġ" ĠĠ Ġprint (\" end Ġof Ġtest 3 \") \ n "+ ĊĠĠĠ Ġ" end \ n "+ ĊĠĠĠ Ġ" function Ġtest 4 ( a 1 , Ġb 1 )\ n "+ ĊĠĠĠ Ġ" ĉ print ( a 1 .. b 1 )\ n "+ ĊĠĠĠ Ġ" ĠĠ Ġlocal Ġa = obj : core Fun ()\ n "+ ĊĠĠĠ Ġ" ĠĠ Ġobj : core Delay ( 3 0 0 )\ n "+ ĊĠĠĠ Ġ" ĉ print ( a )\ n "+ ĊĠĠĠ Ġ" ĠĠ Ġtest 3 ( 1 , 2 , 3 )\ n "+ ĊĠĠĠ Ġ" ĠĠ Ġlocal Ġa 2 = obj : core Fun ()\ n "+ ĊĠĠĠ Ġ" ĉ print ( a 2 )\ n "+ ĊĠĠĠ Ġ" ĠĠ Ġprint (\" end Ġof Ġtest 4 \") \ n "+ ĊĠĠĠ Ġ" end \ n "+ ĊĠĠĠ Ġ" obj : core Delay ( 1 0 0 )\ n "+ ĊĠĠĠ Ġ" test 4 ( 1 , Ġ 2 )\ n "+ ĊĠĠĠ Ġ" local Ġa 2 = obj : core Fun ()\ n "+ ĊĠĠĠ Ġ" print ( a 2 )\ n "+ Ċ " ĠĠ Ġprint (\" end Ġof Ġscript \") \ n " Ċ Ċ suspend Ġfun Ġmain () = Ġcoroutine Scope { ĊĠĠĠ Ġlaunch { ĊĠĠĠĠĠĠĠ Ġexecute New Procedure () ĊĠĠĠĠĠĠĠ Ġdelay ( 1 0 0 0 ) ĊĠĠĠĠĠĠĠ Ġexecute Old Procedure From ExecutionContext () ĊĠĠĠĠĠĠĠ Ġexecute Old Procedure From ExecutionContext () ĊĠĠĠĠĠĠĠ Ġexecute Old Procedure From ExecutionContext () ĊĠĠĠĠĠĠĠ Ġexecute Old Procedure From ExecutionContext () ĊĠĠĠĠĠĠĠ Ġexecute Old Procedure From ExecutionContext () ĊĠĠĠĠĠĠĠ Ġexecute Old Procedure From ExecutionContext () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprintln (" Start ") Ċ } Ċ Ċ suspend Ġfun Ġexecute Old Procedure From ExecutionContext (){ ĊĠĠĠ Ġlua Closure Ġ= Ġdeserialize ExecutionContext ( File (" context "). read Bytes ()) ĊĠĠĠ Ġlua Closure !!. set ReturnValue (" test val ") ĊĠĠĠ Ġlua Closure !!. suspend able Call () Ċ } Ċ Ċ suspend Ġfun Ġexecute New Procedure (){ ĊĠĠĠ Ġval Ġglobals Ġ= ĠJ se Platform . standard Globals () ĊĠĠĠ Ġlua Closure Ġ= Ġglobals . load ( script , Ġ" script ") Ġas ĠLua Closure ĊĠĠĠ Ġval Ġtest Ġ= ĠCo erce Java To Lua . coerce ( Core Test ()) ĊĠĠĠ Ġglobals [" obj "] Ġ= Ġtest ĊĠĠĠ Ġlua Closure ?. suspend able Call () Ċ } Ċ Ċ fun Ġdeserialize ExecutionContext ( executionContext : ĠByteArray ): ĠLua Closure Ġ{ ĊĠĠĠ Ġval Ġbis Ġ= ĠByteArrayInputStream ( executionContext ) ĊĠĠĠ ĠObject InputStream ( bis ). use Ġ{ Ġo is Ġ-> Ġreturn Ġo is . read Object () Ġas ĠLua Closure Ġ} Ċ } Ċ Ċ var Ġlua Closure : ĠLua Closure ? Ġ= Ġnull