-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathChapter11.cs
More file actions
69 lines (53 loc) · 1.37 KB
/
Chapter11.cs
File metadata and controls
69 lines (53 loc) · 1.37 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using WattleScript.Interpreter;
using WattleScript.Interpreter.Loaders;
using WattleScript.Interpreter.Platforms;
using WattleScript.RemoteDebugger;
namespace Tutorials.Chapters
{
[Tutorial]
static class Chapter11
{
static RemoteDebuggerService remoteDebugger;
static void ActivateRemoteDebugger(Script script)
{
if (remoteDebugger == null)
{
remoteDebugger = new RemoteDebuggerService();
// the last boolean is to specify if the script is free to run
// after attachment, defaults to false
remoteDebugger.Attach(script, "Description of the script", false);
}
// start the web-browser at the correct url. Replace this or just
// pass the url to the user in some way.
Process.Start(remoteDebugger.HttpUrlStringLocalHost);
}
[Tutorial]
static void DebuggerDemo()
{
Script script = new Script();
ActivateRemoteDebugger(script);
script.DoString(@"
function accum(n, f)
if (n == 0) then
return 1;
else
return n * f(n);
end
end
local sum = 0;
for i = 1, 5 do
-- let's use a lambda to spice things up
sum = sum + accum(i, | x | x - 1);
end
");
Console.WriteLine("The script has ended..");
}
}
}