@ugo-studio/jspp 0.2.9 → 0.3.1

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.
Files changed (97) hide show
  1. package/LICENSE +25 -25
  2. package/README.md +20 -12
  3. package/dist/analysis/scope.js +5 -3
  4. package/dist/analysis/typeAnalyzer.js +21 -25
  5. package/dist/cli/index.js +14 -4
  6. package/dist/cli/utils.js +61 -0
  7. package/dist/core/codegen/class-handlers.js +6 -6
  8. package/dist/core/codegen/control-flow-handlers.js +10 -9
  9. package/dist/core/codegen/declaration-handlers.js +10 -3
  10. package/dist/core/codegen/destructuring-handlers.js +9 -4
  11. package/dist/core/codegen/expression-handlers.js +40 -29
  12. package/dist/core/codegen/function-handlers.js +78 -12
  13. package/dist/core/codegen/helpers.js +91 -14
  14. package/dist/core/codegen/index.js +4 -2
  15. package/dist/core/codegen/statement-handlers.js +9 -7
  16. package/package.json +2 -2
  17. package/scripts/precompile-headers.ts +249 -50
  18. package/scripts/setup-compiler.ts +63 -63
  19. package/src/prelude/any_value.cpp +636 -0
  20. package/src/prelude/any_value.hpp +369 -362
  21. package/src/prelude/{exception_helpers.hpp → exception.cpp} +53 -53
  22. package/src/prelude/exception.hpp +27 -27
  23. package/src/prelude/iterator_instantiations.hpp +10 -0
  24. package/src/prelude/{index.hpp → jspp.hpp} +10 -16
  25. package/src/prelude/library/array.cpp +191 -0
  26. package/src/prelude/library/array.hpp +13 -186
  27. package/src/prelude/library/console.cpp +125 -0
  28. package/src/prelude/library/console.hpp +24 -112
  29. package/src/prelude/library/error.cpp +100 -0
  30. package/src/prelude/library/error.hpp +13 -113
  31. package/src/prelude/library/function.cpp +69 -0
  32. package/src/prelude/library/function.hpp +11 -10
  33. package/src/prelude/library/global.cpp +96 -0
  34. package/src/prelude/library/global.hpp +12 -28
  35. package/src/prelude/library/global_usings.hpp +15 -0
  36. package/src/prelude/library/math.cpp +258 -0
  37. package/src/prelude/library/math.hpp +26 -308
  38. package/src/prelude/library/object.cpp +379 -0
  39. package/src/prelude/library/object.hpp +14 -276
  40. package/src/prelude/library/performance.cpp +21 -0
  41. package/src/prelude/library/performance.hpp +5 -20
  42. package/src/prelude/library/process.cpp +38 -0
  43. package/src/prelude/library/process.hpp +11 -39
  44. package/src/prelude/library/promise.cpp +131 -0
  45. package/src/prelude/library/promise.hpp +12 -123
  46. package/src/prelude/library/symbol.cpp +56 -0
  47. package/src/prelude/library/symbol.hpp +11 -52
  48. package/src/prelude/library/timer.cpp +88 -0
  49. package/src/prelude/library/timer.hpp +16 -92
  50. package/src/prelude/runtime.cpp +19 -0
  51. package/src/prelude/types.hpp +184 -179
  52. package/src/prelude/utils/access.hpp +502 -411
  53. package/src/prelude/utils/assignment_operators.hpp +99 -99
  54. package/src/prelude/utils/log_any_value/array.hpp +61 -40
  55. package/src/prelude/utils/log_any_value/function.hpp +39 -39
  56. package/src/prelude/utils/log_any_value/object.hpp +60 -3
  57. package/src/prelude/utils/operators.hpp +351 -336
  58. package/src/prelude/utils/operators_primitive.hpp +336 -336
  59. package/src/prelude/utils/well_known_symbols.hpp +24 -24
  60. package/src/prelude/values/array.cpp +1399 -0
  61. package/src/prelude/values/array.hpp +4 -1
  62. package/src/prelude/values/async_iterator.cpp +251 -0
  63. package/src/prelude/values/async_iterator.hpp +111 -83
  64. package/src/prelude/values/function.cpp +262 -0
  65. package/src/prelude/values/function.hpp +62 -82
  66. package/src/prelude/values/iterator.cpp +309 -0
  67. package/src/prelude/values/iterator.hpp +33 -64
  68. package/src/prelude/values/number.cpp +176 -0
  69. package/src/prelude/values/object.cpp +159 -0
  70. package/src/prelude/values/object.hpp +4 -0
  71. package/src/prelude/values/promise.cpp +479 -0
  72. package/src/prelude/values/promise.hpp +79 -72
  73. package/src/prelude/values/prototypes/array.hpp +46 -1336
  74. package/src/prelude/values/prototypes/async_iterator.hpp +19 -61
  75. package/src/prelude/values/prototypes/function.hpp +7 -46
  76. package/src/prelude/values/prototypes/iterator.hpp +25 -201
  77. package/src/prelude/values/prototypes/number.hpp +23 -210
  78. package/src/prelude/values/prototypes/object.hpp +7 -23
  79. package/src/prelude/values/prototypes/promise.hpp +18 -196
  80. package/src/prelude/values/prototypes/string.hpp +39 -542
  81. package/src/prelude/values/prototypes/symbol.hpp +9 -70
  82. package/src/prelude/values/shape.hpp +52 -52
  83. package/src/prelude/values/string.cpp +485 -0
  84. package/src/prelude/values/string.hpp +25 -26
  85. package/src/prelude/values/symbol.cpp +89 -0
  86. package/src/prelude/values/symbol.hpp +101 -101
  87. package/src/prelude/any_value_access.hpp +0 -170
  88. package/src/prelude/any_value_defines.hpp +0 -190
  89. package/src/prelude/any_value_helpers.hpp +0 -374
  90. package/src/prelude/values/helpers/array.hpp +0 -209
  91. package/src/prelude/values/helpers/async_iterator.hpp +0 -275
  92. package/src/prelude/values/helpers/function.hpp +0 -109
  93. package/src/prelude/values/helpers/iterator.hpp +0 -145
  94. package/src/prelude/values/helpers/object.hpp +0 -104
  95. package/src/prelude/values/helpers/promise.hpp +0 -254
  96. package/src/prelude/values/helpers/string.hpp +0 -61
  97. package/src/prelude/values/helpers/symbol.hpp +0 -21
@@ -13,6 +13,7 @@ namespace jspp
13
13
  std::vector<AnyValue> dense; // dense storage for small/contiguous indices
14
14
  std::unordered_map<uint32_t, AnyValue> sparse; // sparse indices (very large indices)
15
15
  std::unordered_map<std::string, AnyValue> props; // non-index string properties
16
+ std::map<AnyValue, AnyValue> symbol_props;
16
17
  AnyValue proto;
17
18
  uint64_t length = 0;
18
19
 
@@ -23,13 +24,15 @@ namespace jspp
23
24
  JsType get_heap_type() const override { return JsType::Array; }
24
25
 
25
26
  std::string to_std_string() const;
26
- JsIterator<AnyValue> get_iterator();
27
27
 
28
28
  bool has_property(const std::string &key) const;
29
+ bool has_symbol_property(const AnyValue &key) const;
29
30
  AnyValue get_property(const std::string &key, const AnyValue &thisVal);
30
31
  AnyValue get_property(uint32_t idx);
32
+ AnyValue get_symbol_property(const AnyValue &key, const AnyValue &thisVal);
31
33
  AnyValue set_property(const std::string &key, const AnyValue &value, const AnyValue &thisVal);
32
34
  AnyValue set_property(uint32_t idx, const AnyValue &value);
35
+ AnyValue set_symbol_property(const AnyValue &key, const AnyValue &value, const AnyValue &thisVal);
33
36
 
34
37
  static bool is_array_index(const std::string &s)
35
38
  {
@@ -0,0 +1,251 @@
1
+ #include "jspp.hpp"
2
+ #include "values/async_iterator.hpp"
3
+ #include "values/prototypes/async_iterator.hpp"
4
+
5
+ namespace jspp {
6
+
7
+ template <typename T>
8
+ JsAsyncIterator<T>::JsAsyncIterator(handle_type h) : handle(h) {}
9
+
10
+ template <typename T>
11
+ JsAsyncIterator<T>::JsAsyncIterator(JsAsyncIterator &&other) noexcept
12
+ : handle(std::exchange(other.handle, nullptr)),
13
+ props(std::move(other.props)),
14
+ symbol_props(std::move(other.symbol_props)) {}
15
+
16
+ template <typename T>
17
+ JsAsyncIterator<T>::~JsAsyncIterator() { if (handle) handle.destroy(); }
18
+
19
+ template <typename T>
20
+ JsAsyncIterator<T> JsAsyncIterator<T>::promise_type::get_return_object() {
21
+ return JsAsyncIterator{std::coroutine_handle<promise_type>::from_promise(*this)};
22
+ }
23
+
24
+ template <typename T>
25
+ std::suspend_always JsAsyncIterator<T>::promise_type::initial_suspend() noexcept { return {}; }
26
+
27
+ template <typename T>
28
+ std::suspend_always JsAsyncIterator<T>::promise_type::final_suspend() noexcept { return {}; }
29
+
30
+ template <typename T>
31
+ bool JsAsyncIterator<T>::promise_type::YieldAwaiter::await_ready() { return false; }
32
+
33
+ template <typename T>
34
+ void JsAsyncIterator<T>::promise_type::YieldAwaiter::await_suspend(std::coroutine_handle<promise_type> h) {}
35
+
36
+ template <typename T>
37
+ T JsAsyncIterator<T>::promise_type::YieldAwaiter::await_resume() { return p.current_input; }
38
+
39
+ template <typename T>
40
+ void JsAsyncIterator<T>::promise_type::unhandled_exception() {
41
+ try {
42
+ std::rethrow_exception(std::current_exception());
43
+ } catch (const Exception &e) {
44
+ fail_all(e.data);
45
+ } catch (const std::exception &e) {
46
+ fail_all(AnyValue::make_string(e.what()));
47
+ } catch (...) {
48
+ fail_all(AnyValue::make_string("Unknown error in async generator"));
49
+ }
50
+ }
51
+
52
+ template <typename T>
53
+ bool JsAsyncIterator<T>::promise_type::AsyncIterAwaiter::await_ready() { return base_awaiter.await_ready(); }
54
+
55
+ template <typename T>
56
+ void JsAsyncIterator<T>::promise_type::AsyncIterAwaiter::await_suspend(std::coroutine_handle<promise_type> h) {
57
+ if (!base_awaiter.value.is_promise()) {
58
+ jspp::Scheduler::instance().enqueue([h]() mutable {
59
+ auto &pr = h.promise();
60
+ pr.is_awaiting = false;
61
+ pr.is_running = true;
62
+ h.resume();
63
+ pr.is_running = false;
64
+ if (!h.done() && !pr.is_awaiting && !pr.pending_calls.empty()) {
65
+ while (!h.done() && !pr.is_awaiting && !pr.pending_calls.empty()) {
66
+ pr.is_running = true;
67
+ pr.current_input = pr.pending_calls.front().second;
68
+ h.resume();
69
+ pr.is_running = false;
70
+ }
71
+ }
72
+ });
73
+ return;
74
+ }
75
+ auto p = base_awaiter.value.as_promise();
76
+ p->then(
77
+ [h](AnyValue v) mutable {
78
+ auto &pr = h.promise();
79
+ pr.is_awaiting = false;
80
+ pr.is_running = true;
81
+ h.resume();
82
+ pr.is_running = false;
83
+ if (!h.done() && !pr.is_awaiting && !pr.pending_calls.empty()) {
84
+ while (!h.done() && !pr.is_awaiting && !pr.pending_calls.empty()) {
85
+ pr.is_running = true;
86
+ pr.current_input = pr.pending_calls.front().second;
87
+ h.resume();
88
+ pr.is_running = false;
89
+ }
90
+ }
91
+ },
92
+ [h](AnyValue e) mutable {
93
+ auto &pr = h.promise();
94
+ pr.is_awaiting = false;
95
+ pr.is_running = true;
96
+ h.resume();
97
+ pr.is_running = false;
98
+ }
99
+ );
100
+ }
101
+
102
+ template <typename T>
103
+ AnyValue JsAsyncIterator<T>::promise_type::AsyncIterAwaiter::await_resume() { return base_awaiter.await_resume(); }
104
+
105
+ template <typename T>
106
+ typename JsAsyncIterator<T>::promise_type::AsyncIterAwaiter JsAsyncIterator<T>::promise_type::await_transform(AnyValue value) {
107
+ is_awaiting = true;
108
+ return AsyncIterAwaiter{AnyValueAwaiter{std::move(value)}, *this};
109
+ }
110
+
111
+ template <typename T>
112
+ std::string JsAsyncIterator<T>::to_std_string() const { return "[object AsyncGenerator]"; }
113
+
114
+ template <typename T>
115
+ void JsAsyncIterator<T>::resume_next()
116
+ {
117
+ if (!handle || handle.done()) return;
118
+ auto &p = handle.promise();
119
+ if (p.is_awaiting || p.is_running) return;
120
+ if (p.pending_calls.empty()) return;
121
+ p.is_running = true;
122
+ auto &next_call = p.pending_calls.front();
123
+ p.current_input = next_call.second;
124
+ handle.resume();
125
+ p.is_running = false;
126
+ if (!p.pending_calls.empty() && !p.is_awaiting && !handle.done()) {
127
+ this->ref();
128
+ Scheduler::instance().enqueue([this]() { this->resume_next(); this->deref(); });
129
+ }
130
+ }
131
+
132
+ template <typename T>
133
+ JsPromise JsAsyncIterator<T>::next(const T &val)
134
+ {
135
+ JsPromise p;
136
+ if (handle) {
137
+ if (handle.done()) p.resolve(AnyValue::make_object({{"value", Constants::UNDEFINED}, {"done", Constants::TRUE}}));
138
+ else { handle.promise().pending_calls.push({p, val}); resume_next(); }
139
+ } else p.resolve(AnyValue::make_object({{"value", Constants::UNDEFINED}, {"done", Constants::TRUE}}));
140
+ return p;
141
+ }
142
+
143
+ template <typename T>
144
+ bool JsAsyncIterator<T>::has_symbol_property(const AnyValue &key) const { return symbol_props.count(key) > 0; }
145
+
146
+ template <typename T>
147
+ AnyValue JsAsyncIterator<T>::get_property(const std::string &key, AnyValue thisVal)
148
+ {
149
+ auto it = props.find(key);
150
+ if (it == props.end()) {
151
+ if constexpr (std::is_same_v<T, AnyValue>) {
152
+ auto proto_it = AsyncIteratorPrototypes::get(key);
153
+ if (proto_it.has_value()) return AnyValue::resolve_property_for_read(proto_it.value(), thisVal, key);
154
+ }
155
+ return Constants::UNDEFINED;
156
+ }
157
+ return AnyValue::resolve_property_for_read(it->second, thisVal, key);
158
+ }
159
+
160
+ template <typename T>
161
+ AnyValue JsAsyncIterator<T>::get_symbol_property(const AnyValue &key, AnyValue thisVal)
162
+ {
163
+ auto it = symbol_props.find(key);
164
+ if (it == symbol_props.end()) {
165
+ if constexpr (std::is_same_v<T, AnyValue>) {
166
+ auto proto_it = AsyncIteratorPrototypes::get(key);
167
+ if (proto_it.has_value()) return AnyValue::resolve_property_for_read(proto_it.value(), thisVal, key.to_std_string());
168
+ }
169
+ return Constants::UNDEFINED;
170
+ }
171
+ return AnyValue::resolve_property_for_read(it->second, thisVal, key.to_std_string());
172
+ }
173
+
174
+ template <typename T>
175
+ AnyValue JsAsyncIterator<T>::set_property(const std::string &key, AnyValue value, AnyValue thisVal)
176
+ {
177
+ if constexpr (std::is_same_v<T, AnyValue>) {
178
+ auto proto_it = AsyncIteratorPrototypes::get(key);
179
+ if (proto_it.has_value()) {
180
+ auto proto_value = proto_it.value();
181
+ if (proto_value.is_accessor_descriptor()) return AnyValue::resolve_property_for_write(proto_value, thisVal, value, key);
182
+ if (proto_value.is_data_descriptor() && !proto_value.as_data_descriptor()->writable) return AnyValue::resolve_property_for_write(proto_value, thisVal, value, key);
183
+ }
184
+ }
185
+ auto it = props.find(key);
186
+ if (it != props.end()) return jspp::AnyValue::resolve_property_for_write(it->second, thisVal, value, key);
187
+ else { props[key] = value; return value; }
188
+ }
189
+
190
+ template <typename T>
191
+ AnyValue JsAsyncIterator<T>::set_symbol_property(const AnyValue &key, AnyValue value, AnyValue thisVal)
192
+ {
193
+ auto it = symbol_props.find(key);
194
+ if (it != symbol_props.end()) return AnyValue::resolve_property_for_write(it->second, thisVal, value, key.to_std_string());
195
+ else { symbol_props[key] = value; return value; }
196
+ }
197
+
198
+ // Explicit template instantiation
199
+ template class JsAsyncIterator<AnyValue>;
200
+
201
+ namespace AsyncIteratorPrototypes {
202
+
203
+ AnyValue &get_toString_fn()
204
+ {
205
+ static AnyValue fn = AnyValue::make_function([](const AnyValue &thisVal, std::span<const AnyValue>) -> AnyValue
206
+ { return AnyValue::make_string(thisVal.as_async_iterator()->to_std_string()); },
207
+ "toString");
208
+ return fn;
209
+ }
210
+
211
+ AnyValue &get_asyncIterator_fn()
212
+ {
213
+ static AnyValue fn = AnyValue::make_function([](const AnyValue &thisVal, std::span<const AnyValue>) -> AnyValue
214
+ { return thisVal; },
215
+ "Symbol.asyncIterator");
216
+ return fn;
217
+ }
218
+
219
+ AnyValue &get_next_fn()
220
+ {
221
+ static AnyValue fn = AnyValue::make_function([](const AnyValue &thisVal, std::span<const AnyValue> args) -> AnyValue
222
+ {
223
+ AnyValue val = args.empty() ? Constants::UNDEFINED : args[0];
224
+ auto res = thisVal.as_async_iterator()->next(val);
225
+ return AnyValue::make_promise(res); },
226
+ "next");
227
+ return fn;
228
+ }
229
+
230
+ std::optional<AnyValue> get(const std::string &key)
231
+ {
232
+ if (key == "toString") return get_toString_fn();
233
+ if (key == "next") return get_next_fn();
234
+ return std::nullopt;
235
+ }
236
+
237
+ std::optional<AnyValue> get(const AnyValue &key)
238
+ {
239
+ if (key.is_string())
240
+ return get(key.as_string()->value);
241
+
242
+ if (key == AnyValue::from_symbol(WellKnownSymbols::toStringTag)) return get_toString_fn();
243
+ if (key == AnyValue::from_symbol(WellKnownSymbols::asyncIterator)) return get_asyncIterator_fn();
244
+ if (key == "next") return get_next_fn();
245
+
246
+ return std::nullopt;
247
+ }
248
+
249
+ } // namespace AsyncIteratorPrototypes
250
+
251
+ } // namespace jspp
@@ -1,83 +1,111 @@
1
- #pragma once
2
-
3
- #include "types.hpp"
4
- #include <coroutine>
5
- #include <optional>
6
- #include <queue>
7
- #include <iostream>
8
- #include <utility>
9
- #include <exception>
10
- #include "values/promise.hpp"
11
- #include "scheduler.hpp"
12
-
13
- namespace jspp
14
- {
15
- // Forward declaration of AnyValue
16
- class AnyValue;
17
-
18
- template <typename T>
19
- class JsAsyncIterator : public HeapObject
20
- {
21
- public:
22
- JsType get_heap_type() const override { return JsType::AsyncIterator; }
23
-
24
- struct promise_type
25
- {
26
- std::queue<std::pair<JsPromise, T>> pending_calls;
27
- bool is_awaiting = false;
28
- bool is_running = false;
29
- T current_input;
30
-
31
- JsAsyncIterator get_return_object()
32
- {
33
- return JsAsyncIterator{
34
- std::coroutine_handle<promise_type>::from_promise(*this)};
35
- }
36
-
37
- std::suspend_always initial_suspend() noexcept { return {}; }
38
-
39
- std::suspend_always final_suspend() noexcept { return {}; }
40
-
41
- // Declarations
42
- template <typename From>
43
- auto yield_value(From &&from);
44
-
45
- template <typename From>
46
- void return_value(From &&from);
47
-
48
- void unhandled_exception();
49
-
50
- void fail_all(const AnyValue &reason);
51
-
52
- auto await_transform(AnyValue value);
53
- };
54
-
55
- using handle_type = std::coroutine_handle<promise_type>;
56
- handle_type handle;
57
-
58
- explicit JsAsyncIterator(handle_type h) : handle(h) {}
59
- JsAsyncIterator(JsAsyncIterator &&other) noexcept
60
- : handle(std::exchange(other.handle, nullptr)),
61
- props(std::move(other.props)) {}
62
-
63
- JsAsyncIterator(const JsAsyncIterator &) = delete;
64
- JsAsyncIterator &operator=(const JsAsyncIterator &) = delete;
65
-
66
- ~JsAsyncIterator()
67
- {
68
- if (handle)
69
- handle.destroy();
70
- }
71
-
72
- std::unordered_map<std::string, AnyValue> props;
73
-
74
- std::string to_std_string() const;
75
-
76
- JsPromise next(const T &val = T());
77
-
78
- AnyValue get_property(const std::string &key, AnyValue thisVal);
79
- AnyValue set_property(const std::string &key, AnyValue value, AnyValue thisVal);
80
-
81
- void resume_next();
82
- };
83
- }
1
+ #pragma once
2
+
3
+ #include "types.hpp"
4
+ #include <coroutine>
5
+ #include <optional>
6
+ #include <queue>
7
+ #include <vector>
8
+
9
+ namespace jspp
10
+ {
11
+ class AnyValue;
12
+ struct JsPromise;
13
+
14
+ template <typename T>
15
+ class JsAsyncIterator : public HeapObject
16
+ {
17
+ public:
18
+ JsType get_heap_type() const override { return JsType::AsyncIterator; }
19
+
20
+ struct promise_type
21
+ {
22
+ std::queue<std::pair<JsPromise, T>> pending_calls;
23
+ bool is_awaiting = false;
24
+ bool is_running = false;
25
+ T current_input;
26
+
27
+ JsAsyncIterator get_return_object();
28
+ std::suspend_always initial_suspend() noexcept;
29
+ std::suspend_always final_suspend() noexcept;
30
+
31
+ struct YieldAwaiter
32
+ {
33
+ promise_type &p;
34
+ bool await_ready();
35
+ void await_suspend(std::coroutine_handle<promise_type> h);
36
+ T await_resume();
37
+ };
38
+
39
+ template <typename From>
40
+ YieldAwaiter yield_value(From &&from) {
41
+ if (!pending_calls.empty()) {
42
+ auto call = pending_calls.front();
43
+ pending_calls.pop();
44
+ AnyValue result = AnyValue::make_object({{"value", std::forward<From>(from)}, {"done", Constants::FALSE}});
45
+ call.first.resolve(result);
46
+ }
47
+ return YieldAwaiter{*this};
48
+ }
49
+
50
+ template <typename From>
51
+ void return_value(From &&from) {
52
+ if (!pending_calls.empty()) {
53
+ auto call = pending_calls.front();
54
+ pending_calls.pop();
55
+ AnyValue result = AnyValue::make_object({{"value", std::forward<From>(from)}, {"done", Constants::TRUE}});
56
+ call.first.resolve(result);
57
+ }
58
+ while (!pending_calls.empty()) {
59
+ auto call = pending_calls.front();
60
+ pending_calls.pop();
61
+ AnyValue result = AnyValue::make_object({{"value", Constants::UNDEFINED}, {"done", Constants::TRUE}});
62
+ call.first.resolve(result);
63
+ }
64
+ }
65
+
66
+ void unhandled_exception();
67
+
68
+ void fail_all(const AnyValue &reason) {
69
+ while (!pending_calls.empty()) {
70
+ auto call = pending_calls.front();
71
+ pending_calls.pop();
72
+ call.first.reject(reason);
73
+ }
74
+ }
75
+
76
+ struct AsyncIterAwaiter
77
+ {
78
+ AnyValueAwaiter base_awaiter;
79
+ promise_type &p_ref;
80
+
81
+ bool await_ready();
82
+ void await_suspend(std::coroutine_handle<promise_type> h);
83
+ AnyValue await_resume();
84
+ };
85
+
86
+ AsyncIterAwaiter await_transform(AnyValue value);
87
+ };
88
+
89
+ using handle_type = std::coroutine_handle<promise_type>;
90
+ handle_type handle;
91
+
92
+ explicit JsAsyncIterator(handle_type h);
93
+ JsAsyncIterator(JsAsyncIterator &&other) noexcept;
94
+ JsAsyncIterator(const JsAsyncIterator &) = delete;
95
+ JsAsyncIterator &operator=(const JsAsyncIterator &) = delete;
96
+ ~JsAsyncIterator();
97
+
98
+ std::unordered_map<std::string, AnyValue> props;
99
+ std::map<AnyValue, AnyValue> symbol_props;
100
+
101
+ std::string to_std_string() const;
102
+ JsPromise next(const T &val = T());
103
+ bool has_symbol_property(const AnyValue &key) const;
104
+ AnyValue get_property(const std::string &key, AnyValue thisVal);
105
+ AnyValue get_symbol_property(const AnyValue &key, AnyValue thisVal);
106
+ AnyValue set_property(const std::string &key, AnyValue value, AnyValue thisVal);
107
+ AnyValue set_symbol_property(const AnyValue &key, AnyValue value, AnyValue thisVal);
108
+
109
+ void resume_next();
110
+ };
111
+ }