This repository was archived by the owner on Aug 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 238
Expand file tree
/
Copy pathSystem.Runtime.CompilerServices.TaskAwaiter.js
More file actions
142 lines (121 loc) · 5.56 KB
/
System.Runtime.CompilerServices.TaskAwaiter.js
File metadata and controls
142 lines (121 loc) · 5.56 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
131
132
133
134
135
136
137
138
139
140
141
142
JSIL.ImplementExternals("System.Runtime.CompilerServices.TaskAwaiter", function ($) {
$.Method({ Static: false, Public: true }, ".ctor",
new JSIL.MethodSignature(null, [$jsilcore.TypeRef("System.Threading.Tasks.Task")], []),
function TaskAwaiter__ctor(task) {
// TODO: Check MemberwiseClone here. We don't define _task as field. Is it work?
this._task = task;
}
);
$.Method({ Static: false, Public: true }, "get_IsCompleted",
new JSIL.MethodSignature($.Boolean, [], []),
function MyTaskAwaiter_get_IsCompleted() {
return this._task.get_IsCompleted();
}
);
$.Method({ Static: false, Public: true }, "GetResult",
new JSIL.MethodSignature(null, [], []),
function GetResult() {
if (!this._task.get_IsCompleted()) {
throw new JSIL.ConstructorSignature($jsilcore.TypeRef("System.Exception"), [$jsilcore.TypeRef("System.String")]).Construct("TaskNotCompleted");
}
var taskException = this._task.get_Exception();
if (taskException !== null) {
throw taskException.get_InnerException();
}
}
);
$.Method({ Static: false, Public: true, Virtual: true }, "OnCompleted",
new JSIL.MethodSignature(null, [$jsilcore.TypeRef("System.Action")], []),
function MyTaskAwaiter_OnCompleted(continuation) {
System.Threading.Tasks.Task.$Methods.ContinueWith.InterfaceMethod.Of(
new JSIL.MethodSignature($jsilcore.TypeRef("System.Threading.Tasks.Task"), [$jsilcore.TypeRef("System.Action`1", [$jsilcore.TypeRef("System.Threading.Tasks.Task")])], []))
.Call(this._task, null, function (task) { continuation() });
}
);
});
JSIL.ImplementExternals("System.Runtime.CompilerServices.TaskAwaiter`1", function ($) {
$.Method({ Static: false, Public: true }, ".ctor",
new JSIL.MethodSignature(null, [$jsilcore.TypeRef("System.Threading.Tasks.Task`1", [new JSIL.GenericParameter("TResult", "System.Runtime.CompilerServices.TaskAwaiter`1")])], []),
function TaskAwaiter__ctor(task) {
this._task = task;
}
);
$.Method({ Static: false, Public: true }, "get_IsCompleted",
new JSIL.MethodSignature($.Boolean, [], []),
function MyTaskAwaiter_get_IsCompleted() {
return this._task.get_IsCompleted();
}
);
$.Method({ Static: false, Public: true }, "GetResult",
new JSIL.MethodSignature(new JSIL.GenericParameter("TResult", "System.Runtime.CompilerServices.TaskAwaiter`1"), [], []),
function GetResult() {
if (!this._task.get_IsCompleted()) {
throw new JSIL.ConstructorSignature($jsilcore.TypeRef("System.Exception"), [$jsilcore.TypeRef("System.String")]).Construct("TaskNotCompleted");
}
var taskException = this._task.get_Exception();
if (taskException !== null) {
throw taskException.get_InnerException();
}
return this._task.get_Result();
}
);
$.Method({ Static: false, Public: true, Virtual: true }, "OnCompleted",
new JSIL.MethodSignature(null, [$jsilcore.TypeRef("System.Action")], []),
function MyTaskAwaiter_OnCompleted(continuation) {
System.Threading.Tasks.Task$b1.Of(this.TResult).$Methods.ContinueWith.InterfaceMethod.Of(
new JSIL.MethodSignature($jsilcore.TypeRef("System.Threading.Tasks.Task"), [$jsilcore.TypeRef("System.Action`1", [$jsilcore.TypeRef("System.Threading.Tasks.Task")])], []))
.Call(this._task, null, function (task) { continuation() });
}
);
});
JSIL.MakeType({
BaseType: $jsilcore.TypeRef("System.ValueType"),
Name: "System.Runtime.CompilerServices.TaskAwaiter",
IsPublic: true,
IsReferenceType: false,
MaximumConstructorArguments: 1,
}, function ($interfaceBuilder) {
var $ = $interfaceBuilder;
$.ExternalMethod({ Static: false, Public: false }, ".ctor",
new JSIL.MethodSignature(null, [$jsilcore.TypeRef("System.Threading.Tasks.Task")], [])
);
$.ExternalMethod({ Static: false, Public: true }, "get_IsCompleted",
new JSIL.MethodSignature($.Boolean, [], [])
);
$.ExternalMethod({ Static: false, Public: true }, "GetResult",
new JSIL.MethodSignature(null, [], [])
);
$.ExternalMethod({ Static: false, Public: true, Virtual: true }, "OnCompleted",
new JSIL.MethodSignature(null, [$jsilcore.TypeRef("System.Action")], [])
);
$.Property({ Static: false, Public: true }, "IsCompleted", $.Boolean);
$.ImplementInterfaces(
/* 0 */ $jsilcore.TypeRef("System.Runtime.CompilerServices.INotifyCompletion")
);
});
JSIL.MakeType({
BaseType: $jsilcore.TypeRef("System.ValueType"),
Name: "System.Runtime.CompilerServices.TaskAwaiter`1",
IsPublic: true,
IsReferenceType: false,
GenericParameters: ["TResult"],
MaximumConstructorArguments: 1,
}, function ($interfaceBuilder) {
var $ = $interfaceBuilder;
$.ExternalMethod({ Static: false, Public: false }, ".ctor",
new JSIL.MethodSignature(null, [$jsilcore.TypeRef("System.Threading.Tasks.Task`1", [new JSIL.GenericParameter("TResult", "System.Runtime.CompilerServices.TaskAwaiter`1")])], [])
);
$.ExternalMethod({ Static: false, Public: true }, "get_IsCompleted",
new JSIL.MethodSignature($.Boolean, [], [])
);
$.ExternalMethod({ Static: false, Public: true }, "GetResult",
new JSIL.MethodSignature(new JSIL.GenericParameter("TResult", "System.Runtime.CompilerServices.TaskAwaiter`1"), [], [])
);
$.ExternalMethod({ Static: false, Public: true, Virtual: true }, "OnCompleted",
new JSIL.MethodSignature(null, [$jsilcore.TypeRef("System.Action")], [])
);
$.Property({ Static: false, Public: true }, "IsCompleted", $.Boolean);
$.ImplementInterfaces(
/* 0 */ $jsilcore.TypeRef("System.Runtime.CompilerServices.INotifyCompletion")
);
});