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.Collections.Generic.Stack.js
More file actions
96 lines (82 loc) · 3.03 KB
/
System.Collections.Generic.Stack.js
File metadata and controls
96 lines (82 loc) · 3.03 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
//? include("../Utils/$jsilcore.InitResizableArray.js");
JSIL.ImplementExternals("System.Collections.Generic.Stack`1", function ($) {
var system = JSIL.GetAssembly("System", true);
$.Method({ Static: false, Public: true }, ".ctor",
(JSIL.MethodSignature.Void),
function _ctor() {
$jsilcore.InitResizableArray(this, this.T, 16);
this._size = 0;
}
);
$.Method({ Static: false, Public: true }, ".ctor",
(new JSIL.MethodSignature(null, [$.Int32], [])),
function _ctor(capacity) {
$jsilcore.InitResizableArray(this, this.T, capacity);
this._size = 0;
}
);
$.Method({ Static: false, Public: true }, "Clear",
(JSIL.MethodSignature.Void),
function Clear() {
this._items.length = this._size = 0;
}
);
$.Method({ Static: false, Public: true }, "get_Count",
(new JSIL.MethodSignature($.Int32, [], [])),
function get_Count() {
return this._size;
}
);
$.Method({ Static: false, Public: true }, "GetEnumerator",
(new JSIL.MethodSignature(system.TypeRef("System.Collections.Generic.Stack`1+Enumerator", [new JSIL.GenericParameter("T", "System.Collections.Generic.Stack`1")]), [], [])),
function GetEnumerator() {
return this.$GetEnumerator();
}
);
$.Method({ Static: false, Public: true }, "Peek",
(new JSIL.MethodSignature(new JSIL.GenericParameter("T", "System.Collections.Generic.Stack`1"), [], [])),
function Peek() {
if (this._size <= 0)
throw new System.InvalidOperationException("Stack is empty");
return this._items[this._size - 1];
}
);
$.Method({ Static: false, Public: true }, "Pop",
(new JSIL.MethodSignature(new JSIL.GenericParameter("T", "System.Collections.Generic.Stack`1"), [], [])),
function Pop() {
var result = this._items.pop();
this._size -= 1;
return result;
}
);
$.Method({ Static: false, Public: true }, "Push",
(new JSIL.MethodSignature(null, [new JSIL.GenericParameter("T", "System.Collections.Generic.Stack`1")], [])),
function Push(item) {
this._items.push(item)
this._size += 1;
}
);
});
//? if ('GENERATE_STUBS' in __out) {
JSIL.MakeClass("System.Object", "System.Collections.Generic.Stack`1", true, ["T"], function ($) {
$.Property({ Public: true, Static: false }, "Count");
$.ImplementInterfaces(
$jsilcore.TypeRef("System.Collections.Generic.IEnumerable`1", [new JSIL.GenericParameter("T", "System.Collections.Generic.Stack`1")]),
"System.Collections.IEnumerable"
);
});
JSIL.MakeType({
BaseType: $jsilcore.TypeRef("System.ValueType"),
Name: "System.Collections.Generic.Stack`1+Enumerator",
IsPublic: true,
IsReferenceType: false,
GenericParameters: ["T"],
MaximumConstructorArguments: 1,
}, function ($) {
$.ImplementInterfaces(
$jsilcore.TypeRef("System.Collections.Generic.IEnumerator`1", [new JSIL.GenericParameter("T", "System.Collections.Generic.Stack`1+Enumerator")]),
$jsilcore.TypeRef("System.IDisposable"),
$jsilcore.TypeRef("System.Collections.IEnumerator")
);
});
//? }