-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathExecutable.cs
More file actions
50 lines (43 loc) · 1.26 KB
/
Copy pathExecutable.cs
File metadata and controls
50 lines (43 loc) · 1.26 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
namespace BlocklyNet.Core.Model;
/// <summary>
/// Represents something executable.
/// </summary>
public abstract class Executable : IFragment
{
/// <summary>
/// Unique name of the executable.
/// </summary>
public required string Name { get; set; }
/// <summary>
/// Block to calculate the value of the executable.
/// </summary>
public required Block? Block { get; set; }
/// <summary>
/// Use the block to evaluate the value.
/// </summary>
/// <param name="context">Current execution context.</param>
/// <returns>The value.</returns>
public Task<object?> EvaluateAsync(Context context)
{
/* See if script should be terminated. */
context.Cancellation.ThrowIfCancellationRequested();
/* Use the block to get the current value. */
for (var block = Block; block != null; block = block.Next)
if (block.Enabled)
return block.EnterBlockAsync(context);
/* If there is no block the result will always be null. */
return Task.FromResult<object?>(null);
}
}
/// <summary>
/// Represents a single value.
/// </summary>
public class Value : Executable
{
}
/// <summary>
/// Represents a statement.
/// </summary>
public class Statement : Executable
{
}