forked from gfwilliams/tiny-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScriptConsole.as.js
41 lines (34 loc) · 975 Bytes
/
ScriptConsole.as.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
* Author: ghernan
*
* Script console for AsyncScript.
*
* The first ever AsyncScript source file!
* In fact, it was written before AsyncScript had a working implementation.
*
* Created on December 18, 2016, 13:33 PM
*/
actor ScriptConsole
{
const reader = spawn IO.StdinLineReader;
lineIn <- reader.lineOut;
input lineIn (cmd)
{
const result = safeEval (line);
//TODO: Missing global scope management!
if (result.ok)
Console.log ("> " + result.value);
else
Console.error ("! " + result.error);
}
input childStopped(actor, result, error)
{
if (actor === this.lineIn)
this.stop(result, error);
else if (error == null)
Console.log ("> Actor '" + actor.name + "' finished: " + result);
else
Console.error ("! Actor '" + actor.name + "' failed: " + result);
}
}
spawn ScriptConsole;