wasm-idle 0.7.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -32
- package/dist/clang/gccCompat.d.ts +15 -0
- package/dist/clang/gccCompat.js +767 -0
- package/dist/clang/index.js +5 -1
- package/dist/clang/url.d.ts +4 -4
- package/dist/clang/url.js +5 -4
- package/dist/clangd/session.d.ts +5 -1
- package/dist/clangd/session.js +22 -4
- package/dist/clangd/worker.js +32 -47
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lsp/cpp/server.js +17 -6
- package/dist/lsp/index.d.ts +1 -1
- package/dist/lsp/index.js +1 -1
- package/dist/lsp/python/server.js +1 -1
- package/dist/lsp/runtime.d.ts +2 -0
- package/dist/lsp/runtime.js +9 -8
- package/dist/lsp/types.d.ts +2 -0
- package/dist/playground/assetBridge.js +8 -2
- package/dist/playground/assets.d.ts +5 -1
- package/dist/playground/assets.js +88 -47
- package/dist/playground/clang.d.ts +4 -2
- package/dist/playground/clang.js +35 -4
- package/dist/playground/ocaml.js +2 -0
- package/dist/playground/options.d.ts +4 -0
- package/dist/playground/tinygo.d.ts +4 -1
- package/dist/playground/tinygo.js +11 -6
- package/dist/playground/wasmOcamlVersion.d.ts +1 -1
- package/dist/playground/wasmOcamlVersion.js +1 -1
- package/dist/playground/wasmTinyGoVersion.d.ts +1 -1
- package/dist/playground/wasmTinyGoVersion.js +1 -1
- package/dist/playground/worker/clang.js +7 -2
- package/dist/playground/worker/elixir.js +296 -22
- package/dist/playground/worker/ocaml.js +5 -4
- package/dist/playground/worker/tinygo.js +7 -4
- package/dist/terminal/Terminal.svelte +4 -0
- package/dist/utils/vscodeJsonrpcBrowser.d.ts +5 -0
- package/dist/utils/vscodeJsonrpcBrowser.js +4 -0
- package/package.json +1 -1
|
@@ -0,0 +1,767 @@
|
|
|
1
|
+
const treePolicyHeader = String.raw `#ifndef WASM_CLANG_EXT_PB_DS_TREE_POLICY_HPP
|
|
2
|
+
#define WASM_CLANG_EXT_PB_DS_TREE_POLICY_HPP
|
|
3
|
+
|
|
4
|
+
#include <cstddef>
|
|
5
|
+
|
|
6
|
+
namespace __gnu_pbds {
|
|
7
|
+
|
|
8
|
+
struct null_type {};
|
|
9
|
+
struct rb_tree_tag {};
|
|
10
|
+
struct splay_tree_tag {};
|
|
11
|
+
struct ov_tree_tag {};
|
|
12
|
+
|
|
13
|
+
template <typename Node_CItr, typename Node_Itr, typename Cmp_Fn, typename Allocator>
|
|
14
|
+
class null_node_update {
|
|
15
|
+
public:
|
|
16
|
+
typedef Node_CItr node_const_iterator;
|
|
17
|
+
typedef Node_Itr node_iterator;
|
|
18
|
+
typedef Cmp_Fn cmp_fn;
|
|
19
|
+
typedef Allocator allocator_type;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
template <typename Node_CItr, typename Node_Itr, typename Cmp_Fn, typename Allocator>
|
|
23
|
+
class tree_order_statistics_node_update {
|
|
24
|
+
public:
|
|
25
|
+
typedef Node_CItr node_const_iterator;
|
|
26
|
+
typedef Node_Itr node_iterator;
|
|
27
|
+
typedef Cmp_Fn cmp_fn;
|
|
28
|
+
typedef Allocator allocator_type;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
} // namespace __gnu_pbds
|
|
32
|
+
|
|
33
|
+
#endif
|
|
34
|
+
`;
|
|
35
|
+
const assocContainerHeader = String.raw `#ifndef WASM_CLANG_EXT_PB_DS_ASSOC_CONTAINER_HPP
|
|
36
|
+
#define WASM_CLANG_EXT_PB_DS_ASSOC_CONTAINER_HPP
|
|
37
|
+
|
|
38
|
+
#include <algorithm>
|
|
39
|
+
#include <cstddef>
|
|
40
|
+
#include <functional>
|
|
41
|
+
#include <iterator>
|
|
42
|
+
#include <map>
|
|
43
|
+
#include <memory>
|
|
44
|
+
#include <set>
|
|
45
|
+
#include <type_traits>
|
|
46
|
+
#include <unordered_map>
|
|
47
|
+
#include <unordered_set>
|
|
48
|
+
#include <utility>
|
|
49
|
+
#include <ext/pb_ds/tree_policy.hpp>
|
|
50
|
+
|
|
51
|
+
namespace __gnu_pbds {
|
|
52
|
+
|
|
53
|
+
namespace detail {
|
|
54
|
+
|
|
55
|
+
template <typename Allocator, typename Value>
|
|
56
|
+
struct rebind_allocator {
|
|
57
|
+
typedef typename std::allocator_traits<Allocator>::template rebind_alloc<Value> type;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
template <typename Iterator>
|
|
61
|
+
Iterator advance_to_order(Iterator first, Iterator last, std::size_t order) {
|
|
62
|
+
if (order >= static_cast<std::size_t>(std::distance(first, last))) return last;
|
|
63
|
+
std::advance(
|
|
64
|
+
first,
|
|
65
|
+
static_cast<typename std::iterator_traits<Iterator>::difference_type>(order)
|
|
66
|
+
);
|
|
67
|
+
return first;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
template <
|
|
71
|
+
typename Key,
|
|
72
|
+
typename Mapped,
|
|
73
|
+
typename Hash_Fn,
|
|
74
|
+
typename Eq_Fn,
|
|
75
|
+
typename Allocator
|
|
76
|
+
>
|
|
77
|
+
struct hash_table_selector {
|
|
78
|
+
typedef std::pair<const Key, Mapped> value_type;
|
|
79
|
+
typedef typename rebind_allocator<Allocator, value_type>::type allocator_type;
|
|
80
|
+
typedef std::unordered_map<Key, Mapped, Hash_Fn, Eq_Fn, allocator_type> type;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
template <typename Key, typename Hash_Fn, typename Eq_Fn, typename Allocator>
|
|
84
|
+
struct hash_table_selector<Key, null_type, Hash_Fn, Eq_Fn, Allocator> {
|
|
85
|
+
typedef typename rebind_allocator<Allocator, Key>::type allocator_type;
|
|
86
|
+
typedef std::unordered_set<Key, Hash_Fn, Eq_Fn, allocator_type> type;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
} // namespace detail
|
|
90
|
+
|
|
91
|
+
template <
|
|
92
|
+
typename Key,
|
|
93
|
+
typename Mapped,
|
|
94
|
+
typename Cmp_Fn = std::less<Key>,
|
|
95
|
+
typename Tag = rb_tree_tag,
|
|
96
|
+
template <typename Node_CItr, typename Node_Itr, typename Cmp_Fn_, typename Allocator_>
|
|
97
|
+
class Node_Update = null_node_update,
|
|
98
|
+
typename Allocator = std::allocator<char>
|
|
99
|
+
>
|
|
100
|
+
class tree {
|
|
101
|
+
public:
|
|
102
|
+
typedef Key key_type;
|
|
103
|
+
typedef Mapped mapped_type;
|
|
104
|
+
typedef std::pair<const Key, Mapped> value_type;
|
|
105
|
+
typedef Cmp_Fn cmp_fn;
|
|
106
|
+
typedef Tag container_category;
|
|
107
|
+
typedef Allocator allocator_type;
|
|
108
|
+
typedef std::size_t size_type;
|
|
109
|
+
|
|
110
|
+
private:
|
|
111
|
+
typedef typename detail::rebind_allocator<Allocator, value_type>::type value_allocator_type;
|
|
112
|
+
typedef std::map<Key, Mapped, Cmp_Fn, value_allocator_type> container_type;
|
|
113
|
+
|
|
114
|
+
public:
|
|
115
|
+
typedef typename container_type::iterator iterator;
|
|
116
|
+
typedef typename container_type::const_iterator const_iterator;
|
|
117
|
+
typedef typename container_type::iterator point_iterator;
|
|
118
|
+
typedef typename container_type::const_iterator const_point_iterator;
|
|
119
|
+
typedef typename container_type::reverse_iterator reverse_iterator;
|
|
120
|
+
typedef typename container_type::const_reverse_iterator const_reverse_iterator;
|
|
121
|
+
|
|
122
|
+
tree() = default;
|
|
123
|
+
explicit tree(const Cmp_Fn& compare) : values_(compare) {}
|
|
124
|
+
|
|
125
|
+
template <typename InputIt>
|
|
126
|
+
tree(InputIt first, InputIt last) : values_(first, last) {}
|
|
127
|
+
|
|
128
|
+
bool empty() const { return values_.empty(); }
|
|
129
|
+
size_type size() const { return values_.size(); }
|
|
130
|
+
size_type max_size() const { return values_.max_size(); }
|
|
131
|
+
|
|
132
|
+
iterator begin() { return values_.begin(); }
|
|
133
|
+
const_iterator begin() const { return values_.begin(); }
|
|
134
|
+
const_iterator cbegin() const { return values_.cbegin(); }
|
|
135
|
+
iterator end() { return values_.end(); }
|
|
136
|
+
const_iterator end() const { return values_.end(); }
|
|
137
|
+
const_iterator cend() const { return values_.cend(); }
|
|
138
|
+
reverse_iterator rbegin() { return values_.rbegin(); }
|
|
139
|
+
const_reverse_iterator rbegin() const { return values_.rbegin(); }
|
|
140
|
+
reverse_iterator rend() { return values_.rend(); }
|
|
141
|
+
const_reverse_iterator rend() const { return values_.rend(); }
|
|
142
|
+
|
|
143
|
+
std::pair<iterator, bool> insert(const value_type& value) { return values_.insert(value); }
|
|
144
|
+
std::pair<iterator, bool> insert(value_type&& value) { return values_.insert(std::move(value)); }
|
|
145
|
+
|
|
146
|
+
template <typename InputIt>
|
|
147
|
+
void insert(InputIt first, InputIt last) {
|
|
148
|
+
values_.insert(first, last);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
mapped_type& operator[](const key_type& key) { return values_[key]; }
|
|
152
|
+
mapped_type& at(const key_type& key) { return values_.at(key); }
|
|
153
|
+
const mapped_type& at(const key_type& key) const { return values_.at(key); }
|
|
154
|
+
|
|
155
|
+
iterator find(const key_type& key) { return values_.find(key); }
|
|
156
|
+
const_iterator find(const key_type& key) const { return values_.find(key); }
|
|
157
|
+
bool contains(const key_type& key) const { return values_.find(key) != values_.end(); }
|
|
158
|
+
size_type count(const key_type& key) const { return values_.count(key); }
|
|
159
|
+
|
|
160
|
+
iterator lower_bound(const key_type& key) { return values_.lower_bound(key); }
|
|
161
|
+
const_iterator lower_bound(const key_type& key) const { return values_.lower_bound(key); }
|
|
162
|
+
iterator upper_bound(const key_type& key) { return values_.upper_bound(key); }
|
|
163
|
+
const_iterator upper_bound(const key_type& key) const { return values_.upper_bound(key); }
|
|
164
|
+
|
|
165
|
+
size_type erase(const key_type& key) { return values_.erase(key); }
|
|
166
|
+
iterator erase(const_iterator position) { return values_.erase(position); }
|
|
167
|
+
iterator erase(const_iterator first, const_iterator last) { return values_.erase(first, last); }
|
|
168
|
+
void clear() { values_.clear(); }
|
|
169
|
+
void swap(tree& other) { values_.swap(other.values_); }
|
|
170
|
+
|
|
171
|
+
iterator find_by_order(size_type order) {
|
|
172
|
+
return detail::advance_to_order(values_.begin(), values_.end(), order);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const_iterator find_by_order(size_type order) const {
|
|
176
|
+
return detail::advance_to_order(values_.begin(), values_.end(), order);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
size_type order_of_key(const key_type& key) const {
|
|
180
|
+
return static_cast<size_type>(std::distance(values_.begin(), values_.lower_bound(key)));
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
void join(tree& other) {
|
|
184
|
+
values_.insert(other.values_.begin(), other.values_.end());
|
|
185
|
+
other.values_.clear();
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
void split(const key_type& key, tree& other) {
|
|
189
|
+
iterator first = values_.upper_bound(key);
|
|
190
|
+
other.values_.insert(first, values_.end());
|
|
191
|
+
values_.erase(first, values_.end());
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
private:
|
|
195
|
+
container_type values_;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
template <
|
|
199
|
+
typename Key,
|
|
200
|
+
typename Cmp_Fn,
|
|
201
|
+
typename Tag,
|
|
202
|
+
template <typename Node_CItr, typename Node_Itr, typename Cmp_Fn_, typename Allocator_>
|
|
203
|
+
class Node_Update,
|
|
204
|
+
typename Allocator
|
|
205
|
+
>
|
|
206
|
+
class tree<Key, null_type, Cmp_Fn, Tag, Node_Update, Allocator> {
|
|
207
|
+
public:
|
|
208
|
+
typedef Key key_type;
|
|
209
|
+
typedef null_type mapped_type;
|
|
210
|
+
typedef Key value_type;
|
|
211
|
+
typedef Cmp_Fn cmp_fn;
|
|
212
|
+
typedef Tag container_category;
|
|
213
|
+
typedef Allocator allocator_type;
|
|
214
|
+
typedef std::size_t size_type;
|
|
215
|
+
|
|
216
|
+
private:
|
|
217
|
+
typedef typename detail::rebind_allocator<Allocator, value_type>::type value_allocator_type;
|
|
218
|
+
typedef std::set<Key, Cmp_Fn, value_allocator_type> container_type;
|
|
219
|
+
|
|
220
|
+
public:
|
|
221
|
+
typedef typename container_type::iterator iterator;
|
|
222
|
+
typedef typename container_type::const_iterator const_iterator;
|
|
223
|
+
typedef typename container_type::iterator point_iterator;
|
|
224
|
+
typedef typename container_type::const_iterator const_point_iterator;
|
|
225
|
+
typedef typename container_type::reverse_iterator reverse_iterator;
|
|
226
|
+
typedef typename container_type::const_reverse_iterator const_reverse_iterator;
|
|
227
|
+
|
|
228
|
+
tree() = default;
|
|
229
|
+
explicit tree(const Cmp_Fn& compare) : values_(compare) {}
|
|
230
|
+
|
|
231
|
+
template <typename InputIt>
|
|
232
|
+
tree(InputIt first, InputIt last) : values_(first, last) {}
|
|
233
|
+
|
|
234
|
+
bool empty() const { return values_.empty(); }
|
|
235
|
+
size_type size() const { return values_.size(); }
|
|
236
|
+
size_type max_size() const { return values_.max_size(); }
|
|
237
|
+
|
|
238
|
+
iterator begin() { return values_.begin(); }
|
|
239
|
+
const_iterator begin() const { return values_.begin(); }
|
|
240
|
+
const_iterator cbegin() const { return values_.cbegin(); }
|
|
241
|
+
iterator end() { return values_.end(); }
|
|
242
|
+
const_iterator end() const { return values_.end(); }
|
|
243
|
+
const_iterator cend() const { return values_.cend(); }
|
|
244
|
+
reverse_iterator rbegin() { return values_.rbegin(); }
|
|
245
|
+
const_reverse_iterator rbegin() const { return values_.rbegin(); }
|
|
246
|
+
reverse_iterator rend() { return values_.rend(); }
|
|
247
|
+
const_reverse_iterator rend() const { return values_.rend(); }
|
|
248
|
+
|
|
249
|
+
std::pair<iterator, bool> insert(const value_type& value) { return values_.insert(value); }
|
|
250
|
+
std::pair<iterator, bool> insert(value_type&& value) { return values_.insert(std::move(value)); }
|
|
251
|
+
|
|
252
|
+
template <typename InputIt>
|
|
253
|
+
void insert(InputIt first, InputIt last) {
|
|
254
|
+
values_.insert(first, last);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
iterator find(const key_type& key) { return values_.find(key); }
|
|
258
|
+
const_iterator find(const key_type& key) const { return values_.find(key); }
|
|
259
|
+
bool contains(const key_type& key) const { return values_.find(key) != values_.end(); }
|
|
260
|
+
size_type count(const key_type& key) const { return values_.count(key); }
|
|
261
|
+
|
|
262
|
+
iterator lower_bound(const key_type& key) { return values_.lower_bound(key); }
|
|
263
|
+
const_iterator lower_bound(const key_type& key) const { return values_.lower_bound(key); }
|
|
264
|
+
iterator upper_bound(const key_type& key) { return values_.upper_bound(key); }
|
|
265
|
+
const_iterator upper_bound(const key_type& key) const { return values_.upper_bound(key); }
|
|
266
|
+
|
|
267
|
+
size_type erase(const key_type& key) { return values_.erase(key); }
|
|
268
|
+
iterator erase(const_iterator position) { return values_.erase(position); }
|
|
269
|
+
iterator erase(const_iterator first, const_iterator last) { return values_.erase(first, last); }
|
|
270
|
+
void clear() { values_.clear(); }
|
|
271
|
+
void swap(tree& other) { values_.swap(other.values_); }
|
|
272
|
+
|
|
273
|
+
iterator find_by_order(size_type order) {
|
|
274
|
+
return detail::advance_to_order(values_.begin(), values_.end(), order);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const_iterator find_by_order(size_type order) const {
|
|
278
|
+
return detail::advance_to_order(values_.begin(), values_.end(), order);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
size_type order_of_key(const key_type& key) const {
|
|
282
|
+
return static_cast<size_type>(std::distance(values_.begin(), values_.lower_bound(key)));
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
void join(tree& other) {
|
|
286
|
+
values_.insert(other.values_.begin(), other.values_.end());
|
|
287
|
+
other.values_.clear();
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
void split(const key_type& key, tree& other) {
|
|
291
|
+
iterator first = values_.upper_bound(key);
|
|
292
|
+
other.values_.insert(first, values_.end());
|
|
293
|
+
values_.erase(first, values_.end());
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
private:
|
|
297
|
+
container_type values_;
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
template <
|
|
301
|
+
typename Key,
|
|
302
|
+
typename Mapped,
|
|
303
|
+
typename Hash_Fn = std::hash<Key>,
|
|
304
|
+
typename Eq_Fn = std::equal_to<Key>,
|
|
305
|
+
typename Comb_Hash_Fn = void,
|
|
306
|
+
typename Resize_Policy = void,
|
|
307
|
+
bool Store_Hash = false,
|
|
308
|
+
typename Allocator = std::allocator<char>
|
|
309
|
+
>
|
|
310
|
+
using gp_hash_table = typename detail::hash_table_selector<
|
|
311
|
+
Key,
|
|
312
|
+
Mapped,
|
|
313
|
+
Hash_Fn,
|
|
314
|
+
Eq_Fn,
|
|
315
|
+
Allocator
|
|
316
|
+
>::type;
|
|
317
|
+
|
|
318
|
+
template <
|
|
319
|
+
typename Key,
|
|
320
|
+
typename Mapped,
|
|
321
|
+
typename Hash_Fn = std::hash<Key>,
|
|
322
|
+
typename Eq_Fn = std::equal_to<Key>,
|
|
323
|
+
typename Comb_Hash_Fn = void,
|
|
324
|
+
typename Resize_Policy = void,
|
|
325
|
+
bool Store_Hash = false,
|
|
326
|
+
typename Allocator = std::allocator<char>
|
|
327
|
+
>
|
|
328
|
+
using cc_hash_table = typename detail::hash_table_selector<
|
|
329
|
+
Key,
|
|
330
|
+
Mapped,
|
|
331
|
+
Hash_Fn,
|
|
332
|
+
Eq_Fn,
|
|
333
|
+
Allocator
|
|
334
|
+
>::type;
|
|
335
|
+
|
|
336
|
+
} // namespace __gnu_pbds
|
|
337
|
+
|
|
338
|
+
#endif
|
|
339
|
+
`;
|
|
340
|
+
const hashPolicyHeader = String.raw `#ifndef WASM_CLANG_EXT_PB_DS_HASH_POLICY_HPP
|
|
341
|
+
#define WASM_CLANG_EXT_PB_DS_HASH_POLICY_HPP
|
|
342
|
+
|
|
343
|
+
#include <cstddef>
|
|
344
|
+
|
|
345
|
+
namespace __gnu_pbds {
|
|
346
|
+
|
|
347
|
+
template <typename Size_Type = std::size_t>
|
|
348
|
+
class direct_mask_range_hashing {
|
|
349
|
+
public:
|
|
350
|
+
typedef Size_Type size_type;
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
template <typename Size_Type = std::size_t>
|
|
354
|
+
class direct_mod_range_hashing {
|
|
355
|
+
public:
|
|
356
|
+
typedef Size_Type size_type;
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
template <typename Size_Type = std::size_t>
|
|
360
|
+
class linear_probe_fn {
|
|
361
|
+
public:
|
|
362
|
+
typedef Size_Type size_type;
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
template <typename Size_Type = std::size_t>
|
|
366
|
+
class quadratic_probe_fn {
|
|
367
|
+
public:
|
|
368
|
+
typedef Size_Type size_type;
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
class hash_exponential_size_policy {};
|
|
372
|
+
class hash_prime_size_policy {};
|
|
373
|
+
|
|
374
|
+
template <bool External_Load_Access = false, typename Size_Type = std::size_t>
|
|
375
|
+
class hash_load_check_resize_trigger {
|
|
376
|
+
public:
|
|
377
|
+
typedef Size_Type size_type;
|
|
378
|
+
explicit hash_load_check_resize_trigger(float = 0.125, float = 0.5) {}
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
template <bool External_Load_Access = false, typename Size_Type = std::size_t>
|
|
382
|
+
class cc_hash_max_collision_check_resize_trigger {
|
|
383
|
+
public:
|
|
384
|
+
typedef Size_Type size_type;
|
|
385
|
+
explicit cc_hash_max_collision_check_resize_trigger(float = 0.5) {}
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
template <
|
|
389
|
+
typename Size_Policy = hash_exponential_size_policy,
|
|
390
|
+
typename Trigger_Policy = hash_load_check_resize_trigger<>,
|
|
391
|
+
bool External_Size_Access = false,
|
|
392
|
+
typename Size_Type = std::size_t
|
|
393
|
+
>
|
|
394
|
+
class hash_standard_resize_policy {
|
|
395
|
+
public:
|
|
396
|
+
typedef Size_Type size_type;
|
|
397
|
+
hash_standard_resize_policy() = default;
|
|
398
|
+
explicit hash_standard_resize_policy(const Size_Policy&) {}
|
|
399
|
+
hash_standard_resize_policy(const Size_Policy&, const Trigger_Policy&) {}
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
} // namespace __gnu_pbds
|
|
403
|
+
|
|
404
|
+
#endif
|
|
405
|
+
`;
|
|
406
|
+
const priorityQueueHeader = String.raw `#ifndef WASM_CLANG_EXT_PB_DS_PRIORITY_QUEUE_HPP
|
|
407
|
+
#define WASM_CLANG_EXT_PB_DS_PRIORITY_QUEUE_HPP
|
|
408
|
+
|
|
409
|
+
#include <algorithm>
|
|
410
|
+
#include <cstddef>
|
|
411
|
+
#include <functional>
|
|
412
|
+
#include <memory>
|
|
413
|
+
#include <queue>
|
|
414
|
+
#include <utility>
|
|
415
|
+
#include <vector>
|
|
416
|
+
|
|
417
|
+
namespace __gnu_pbds {
|
|
418
|
+
|
|
419
|
+
struct pairing_heap_tag {};
|
|
420
|
+
struct binary_heap_tag {};
|
|
421
|
+
struct binomial_heap_tag {};
|
|
422
|
+
struct rc_binomial_heap_tag {};
|
|
423
|
+
struct thin_heap_tag {};
|
|
424
|
+
|
|
425
|
+
namespace detail {
|
|
426
|
+
|
|
427
|
+
template <typename Allocator, typename Value>
|
|
428
|
+
struct priority_queue_rebind_allocator {
|
|
429
|
+
typedef typename std::allocator_traits<Allocator>::template rebind_alloc<Value> type;
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
} // namespace detail
|
|
433
|
+
|
|
434
|
+
template <
|
|
435
|
+
typename Value_Type,
|
|
436
|
+
typename Cmp_Fn = std::less<Value_Type>,
|
|
437
|
+
typename Tag = pairing_heap_tag,
|
|
438
|
+
typename Allocator = std::allocator<char>
|
|
439
|
+
>
|
|
440
|
+
class priority_queue {
|
|
441
|
+
public:
|
|
442
|
+
typedef Value_Type value_type;
|
|
443
|
+
typedef Cmp_Fn cmp_fn;
|
|
444
|
+
typedef Tag container_category;
|
|
445
|
+
typedef Allocator allocator_type;
|
|
446
|
+
typedef std::size_t size_type;
|
|
447
|
+
typedef value_type& reference;
|
|
448
|
+
typedef const value_type& const_reference;
|
|
449
|
+
|
|
450
|
+
private:
|
|
451
|
+
typedef typename detail::priority_queue_rebind_allocator<Allocator, value_type>::type value_allocator_type;
|
|
452
|
+
typedef std::vector<value_type, value_allocator_type> container_type;
|
|
453
|
+
|
|
454
|
+
public:
|
|
455
|
+
typedef typename container_type::iterator point_iterator;
|
|
456
|
+
typedef typename container_type::const_iterator const_point_iterator;
|
|
457
|
+
|
|
458
|
+
priority_queue() : values_(), compare_() {
|
|
459
|
+
std::make_heap(values_.begin(), values_.end(), compare_);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
explicit priority_queue(const Cmp_Fn& compare) : values_(), compare_(compare) {
|
|
463
|
+
std::make_heap(values_.begin(), values_.end(), compare_);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
template <typename InputIt>
|
|
467
|
+
priority_queue(InputIt first, InputIt last) : values_(first, last), compare_() {
|
|
468
|
+
std::make_heap(values_.begin(), values_.end(), compare_);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
bool empty() const { return values_.empty(); }
|
|
472
|
+
size_type size() const { return values_.size(); }
|
|
473
|
+
const_reference top() const { return values_.front(); }
|
|
474
|
+
void clear() { values_.clear(); }
|
|
475
|
+
void swap(priority_queue& other) {
|
|
476
|
+
values_.swap(other.values_);
|
|
477
|
+
std::swap(compare_, other.compare_);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
point_iterator push(const_reference value) {
|
|
481
|
+
values_.push_back(value);
|
|
482
|
+
std::push_heap(values_.begin(), values_.end(), compare_);
|
|
483
|
+
return values_.empty() ? values_.end() : values_.begin();
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
void pop() {
|
|
487
|
+
std::pop_heap(values_.begin(), values_.end(), compare_);
|
|
488
|
+
values_.pop_back();
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
void modify(point_iterator position, const_reference value) {
|
|
492
|
+
if (position == values_.end()) return;
|
|
493
|
+
*position = value;
|
|
494
|
+
std::make_heap(values_.begin(), values_.end(), compare_);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
void erase(point_iterator position) {
|
|
498
|
+
if (position == values_.end()) return;
|
|
499
|
+
values_.erase(position);
|
|
500
|
+
std::make_heap(values_.begin(), values_.end(), compare_);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
void join(priority_queue& other) {
|
|
504
|
+
values_.insert(values_.end(), other.values_.begin(), other.values_.end());
|
|
505
|
+
other.values_.clear();
|
|
506
|
+
std::make_heap(values_.begin(), values_.end(), compare_);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
private:
|
|
510
|
+
container_type values_;
|
|
511
|
+
Cmp_Fn compare_;
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
} // namespace __gnu_pbds
|
|
515
|
+
|
|
516
|
+
#endif
|
|
517
|
+
`;
|
|
518
|
+
const ropeHeader = String.raw `#ifndef WASM_CLANG_EXT_ROPE
|
|
519
|
+
#define WASM_CLANG_EXT_ROPE
|
|
520
|
+
|
|
521
|
+
#include <algorithm>
|
|
522
|
+
#include <cstddef>
|
|
523
|
+
#include <iosfwd>
|
|
524
|
+
#include <iterator>
|
|
525
|
+
#include <memory>
|
|
526
|
+
#include <ostream>
|
|
527
|
+
#include <string>
|
|
528
|
+
#include <utility>
|
|
529
|
+
|
|
530
|
+
namespace __gnu_cxx {
|
|
531
|
+
|
|
532
|
+
template <typename CharT, typename Alloc = std::allocator<CharT>>
|
|
533
|
+
class rope {
|
|
534
|
+
public:
|
|
535
|
+
typedef CharT value_type;
|
|
536
|
+
typedef Alloc allocator_type;
|
|
537
|
+
typedef std::basic_string<CharT, std::char_traits<CharT>, Alloc> string_type;
|
|
538
|
+
typedef typename string_type::traits_type traits_type;
|
|
539
|
+
typedef typename string_type::size_type size_type;
|
|
540
|
+
typedef typename string_type::difference_type difference_type;
|
|
541
|
+
typedef typename string_type::reference reference;
|
|
542
|
+
typedef typename string_type::const_reference const_reference;
|
|
543
|
+
typedef typename string_type::iterator iterator;
|
|
544
|
+
typedef typename string_type::const_iterator const_iterator;
|
|
545
|
+
|
|
546
|
+
static const size_type npos = string_type::npos;
|
|
547
|
+
|
|
548
|
+
rope() = default;
|
|
549
|
+
rope(const rope&) = default;
|
|
550
|
+
rope(rope&&) = default;
|
|
551
|
+
rope& operator=(const rope&) = default;
|
|
552
|
+
rope& operator=(rope&&) = default;
|
|
553
|
+
|
|
554
|
+
rope(const CharT* value) : data_(value ? value : empty_c_str()) {}
|
|
555
|
+
rope(const CharT* value, size_type count) : data_(value, count) {}
|
|
556
|
+
rope(size_type count, CharT value) : data_(count, value) {}
|
|
557
|
+
rope(const string_type& value) : data_(value) {}
|
|
558
|
+
rope(string_type&& value) : data_(std::move(value)) {}
|
|
559
|
+
|
|
560
|
+
template <typename InputIt>
|
|
561
|
+
rope(InputIt first, InputIt last) : data_(first, last) {}
|
|
562
|
+
|
|
563
|
+
bool empty() const { return data_.empty(); }
|
|
564
|
+
size_type size() const { return data_.size(); }
|
|
565
|
+
size_type length() const { return data_.length(); }
|
|
566
|
+
size_type max_size() const { return data_.max_size(); }
|
|
567
|
+
void clear() { data_.clear(); }
|
|
568
|
+
|
|
569
|
+
const CharT* c_str() const { return data_.c_str(); }
|
|
570
|
+
const string_type& str() const { return data_; }
|
|
571
|
+
|
|
572
|
+
iterator begin() { return data_.begin(); }
|
|
573
|
+
const_iterator begin() const { return data_.begin(); }
|
|
574
|
+
const_iterator cbegin() const { return data_.cbegin(); }
|
|
575
|
+
iterator end() { return data_.end(); }
|
|
576
|
+
const_iterator end() const { return data_.end(); }
|
|
577
|
+
const_iterator cend() const { return data_.cend(); }
|
|
578
|
+
|
|
579
|
+
reference operator[](size_type index) { return data_[index]; }
|
|
580
|
+
const_reference operator[](size_type index) const { return data_[index]; }
|
|
581
|
+
reference at(size_type index) { return data_.at(index); }
|
|
582
|
+
const_reference at(size_type index) const { return data_.at(index); }
|
|
583
|
+
reference mutable_reference_at(size_type index) { return data_.at(index); }
|
|
584
|
+
|
|
585
|
+
void push_back(CharT value) { data_.push_back(value); }
|
|
586
|
+
void pop_back() { data_.pop_back(); }
|
|
587
|
+
|
|
588
|
+
rope& append(const rope& value) {
|
|
589
|
+
data_.append(value.data_);
|
|
590
|
+
return *this;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
rope& append(const CharT* value) {
|
|
594
|
+
data_.append(value ? value : empty_c_str());
|
|
595
|
+
return *this;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
rope& append(const CharT* value, size_type count) {
|
|
599
|
+
data_.append(value, count);
|
|
600
|
+
return *this;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
rope& append(size_type count, CharT value) {
|
|
604
|
+
data_.append(count, value);
|
|
605
|
+
return *this;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
rope& insert(size_type position, const rope& value) {
|
|
609
|
+
data_.insert(position, value.data_);
|
|
610
|
+
return *this;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
rope& insert(size_type position, const CharT* value) {
|
|
614
|
+
data_.insert(position, value ? value : empty_c_str());
|
|
615
|
+
return *this;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
rope& insert(size_type position, const CharT* value, size_type count) {
|
|
619
|
+
data_.insert(position, value, count);
|
|
620
|
+
return *this;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
rope& insert(size_type position, size_type count, CharT value) {
|
|
624
|
+
data_.insert(position, count, value);
|
|
625
|
+
return *this;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
rope& erase(size_type position = 0, size_type count = npos) {
|
|
629
|
+
data_.erase(position, count);
|
|
630
|
+
return *this;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
rope& replace(size_type position, size_type count, const rope& value) {
|
|
634
|
+
data_.replace(position, count, value.data_);
|
|
635
|
+
return *this;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
rope& replace(size_type position, size_type count, const CharT* value) {
|
|
639
|
+
data_.replace(position, count, value ? value : empty_c_str());
|
|
640
|
+
return *this;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
rope substr(size_type position = 0, size_type count = npos) const {
|
|
644
|
+
return rope(data_.substr(position, count));
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
size_type copy(size_type position, size_type count, CharT* target) const {
|
|
648
|
+
if (position > data_.size()) return 0;
|
|
649
|
+
const size_type copied = std::min(count, data_.size() - position);
|
|
650
|
+
traits_type::copy(target, data_.data() + position, copied);
|
|
651
|
+
return copied;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
int compare(const rope& value) const { return data_.compare(value.data_); }
|
|
655
|
+
|
|
656
|
+
rope& operator+=(const rope& value) { return append(value); }
|
|
657
|
+
rope& operator+=(const CharT* value) { return append(value); }
|
|
658
|
+
rope& operator+=(CharT value) {
|
|
659
|
+
push_back(value);
|
|
660
|
+
return *this;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
private:
|
|
664
|
+
static const CharT* empty_c_str() {
|
|
665
|
+
static const CharT empty[1] = {};
|
|
666
|
+
return empty;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
string_type data_;
|
|
670
|
+
};
|
|
671
|
+
|
|
672
|
+
template <typename CharT, typename Alloc>
|
|
673
|
+
rope<CharT, Alloc> operator+(rope<CharT, Alloc> left, const rope<CharT, Alloc>& right) {
|
|
674
|
+
left += right;
|
|
675
|
+
return left;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
template <typename CharT, typename Alloc>
|
|
679
|
+
bool operator==(const rope<CharT, Alloc>& left, const rope<CharT, Alloc>& right) {
|
|
680
|
+
return left.compare(right) == 0;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
template <typename CharT, typename Alloc>
|
|
684
|
+
bool operator!=(const rope<CharT, Alloc>& left, const rope<CharT, Alloc>& right) {
|
|
685
|
+
return !(left == right);
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
template <typename CharT, typename Alloc>
|
|
689
|
+
bool operator<(const rope<CharT, Alloc>& left, const rope<CharT, Alloc>& right) {
|
|
690
|
+
return left.compare(right) < 0;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
template <typename CharT, typename Alloc>
|
|
694
|
+
std::basic_ostream<CharT>& operator<<(
|
|
695
|
+
std::basic_ostream<CharT>& output,
|
|
696
|
+
const rope<CharT, Alloc>& value
|
|
697
|
+
) {
|
|
698
|
+
return output << value.str();
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
typedef rope<char> crope;
|
|
702
|
+
typedef rope<wchar_t> wrope;
|
|
703
|
+
|
|
704
|
+
} // namespace __gnu_cxx
|
|
705
|
+
|
|
706
|
+
#endif
|
|
707
|
+
`;
|
|
708
|
+
const bitsExtcxxHeader = String.raw `#ifndef WASM_CLANG_BITS_EXTCXX_H
|
|
709
|
+
#define WASM_CLANG_BITS_EXTCXX_H
|
|
710
|
+
|
|
711
|
+
#include <bits/stdc++.h>
|
|
712
|
+
#include <ext/hash_map>
|
|
713
|
+
#include <ext/hash_set>
|
|
714
|
+
#include <ext/rope>
|
|
715
|
+
#include <ext/pb_ds/assoc_container.hpp>
|
|
716
|
+
#include <ext/pb_ds/hash_policy.hpp>
|
|
717
|
+
#include <ext/pb_ds/priority_queue.hpp>
|
|
718
|
+
#include <ext/pb_ds/tree_policy.hpp>
|
|
719
|
+
|
|
720
|
+
#endif
|
|
721
|
+
`;
|
|
722
|
+
export const GCC_COMPATIBILITY_HEADERS = [
|
|
723
|
+
{
|
|
724
|
+
path: 'include/bits/extc++.h',
|
|
725
|
+
contents: bitsExtcxxHeader
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
path: 'include/c++/v1/ext/rope',
|
|
729
|
+
contents: ropeHeader
|
|
730
|
+
},
|
|
731
|
+
{
|
|
732
|
+
path: 'include/c++/v1/ext/pb_ds/tree_policy.hpp',
|
|
733
|
+
contents: treePolicyHeader
|
|
734
|
+
},
|
|
735
|
+
{
|
|
736
|
+
path: 'include/c++/v1/ext/pb_ds/assoc_container.hpp',
|
|
737
|
+
contents: assocContainerHeader
|
|
738
|
+
},
|
|
739
|
+
{
|
|
740
|
+
path: 'include/c++/v1/ext/pb_ds/hash_policy.hpp',
|
|
741
|
+
contents: hashPolicyHeader
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
path: 'include/c++/v1/ext/pb_ds/priority_queue.hpp',
|
|
745
|
+
contents: priorityQueueHeader
|
|
746
|
+
}
|
|
747
|
+
];
|
|
748
|
+
const gccCompatibilityDirectories = ['include/c++/v1/ext/pb_ds', 'include/bits'];
|
|
749
|
+
const joinRootPath = (root, path) => {
|
|
750
|
+
const normalizedRoot = root.replace(/\/+$/, '');
|
|
751
|
+
const normalizedPath = path.replace(/^\/+/, '');
|
|
752
|
+
return normalizedRoot ? `${normalizedRoot}/${normalizedPath}` : normalizedPath;
|
|
753
|
+
};
|
|
754
|
+
export function installGccCompatibilityHeaders(memfs) {
|
|
755
|
+
memfs.addDirectory('include/c++/v1/ext/pb_ds');
|
|
756
|
+
for (const header of GCC_COMPATIBILITY_HEADERS) {
|
|
757
|
+
memfs.addFile(header.path, header.contents);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
export function writeGccCompatibilityHeaders(fs, root = '') {
|
|
761
|
+
for (const directory of gccCompatibilityDirectories) {
|
|
762
|
+
fs.mkdirTree(joinRootPath(root, directory));
|
|
763
|
+
}
|
|
764
|
+
for (const header of GCC_COMPATIBILITY_HEADERS) {
|
|
765
|
+
fs.writeFile(joinRootPath(root, header.path), header.contents);
|
|
766
|
+
}
|
|
767
|
+
}
|