forked from PureKrome/EcmaScript.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContinuation.cs
More file actions
130 lines (106 loc) · 3.62 KB
/
Copy pathContinuation.cs
File metadata and controls
130 lines (106 loc) · 3.62 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//------------------------------------------------------------------------------
// <license file="Continuation.cs">
//
// The use and distribution terms for this software are contained in the file
// named 'LICENSE', which can be found in the resources directory of this
// distribution.
//
// By using this software in any fashion, you are agreeing to be bound by the
// terms of this license.
//
// </license>
//------------------------------------------------------------------------------
using System;
using EcmaScript.NET;
namespace EcmaScript.NET
{
public sealed class Continuation : IdScriptableObject, IFunction
{
public object Implementation
{
get
{
return implementation;
}
}
override public string ClassName
{
get
{
return "Continuation";
}
}
private static readonly object FTAG = new object ();
private object implementation;
public static void Init (IScriptable scope, bool zealed)
{
Continuation obj = new Continuation ();
obj.ExportAsJSClass (MAX_PROTOTYPE_ID, scope, zealed);
}
public void initImplementation (object implementation)
{
this.implementation = implementation;
}
public IScriptable Construct (Context cx, IScriptable scope, object [] args)
{
throw Context.ReportRuntimeError ("Direct call is not supported");
}
public object Call (Context cx, IScriptable scope, IScriptable thisObj, object [] args)
{
return Interpreter.restartContinuation (this, cx, scope, args);
}
public static bool IsContinuationConstructor (IdFunctionObject f)
{
if (f.HasTag (FTAG) && f.MethodId == Id_constructor) {
return true;
}
return false;
}
protected internal override void InitPrototypeId (int id)
{
string s;
int arity;
switch (id) {
case Id_constructor:
arity = 0;
s = "constructor";
break;
default:
throw new ArgumentException (Convert.ToString (id));
}
InitPrototypeMethod (FTAG, id, s, arity);
}
public override object ExecIdCall (IdFunctionObject f, Context cx, IScriptable scope, IScriptable thisObj, object [] args)
{
if (!f.HasTag (FTAG)) {
return base.ExecIdCall (f, cx, scope, thisObj, args);
}
int id = f.MethodId;
switch (id) {
case Id_constructor:
throw Context.ReportRuntimeError ("Direct call is not supported");
}
throw new ArgumentException (Convert.ToString (id));
}
// #string_id_map#
protected internal override int FindPrototypeId (string s)
{
int id;
#region Generated PrototypeId Switch
L0: {
id = 0;
string X = null;
if (s.Length == 11) { X = "constructor"; id = Id_constructor; }
if (X != null && X != s && !X.Equals (s))
id = 0;
}
EL0:
#endregion
return id;
}
#region PrototypeIds
private const int Id_constructor = 1;
private const int MAX_PROTOTYPE_ID = 1;
#endregion
}
}