@ugo-studio/jspp 0.2.6 → 0.2.7

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 (42) hide show
  1. package/dist/analysis/typeAnalyzer.js +56 -24
  2. package/dist/ast/symbols.js +28 -19
  3. package/dist/cli/index.js +1 -1
  4. package/dist/core/codegen/class-handlers.js +8 -8
  5. package/dist/core/codegen/control-flow-handlers.js +17 -7
  6. package/dist/core/codegen/declaration-handlers.js +21 -9
  7. package/dist/core/codegen/expression-handlers.js +558 -126
  8. package/dist/core/codegen/function-handlers.js +101 -108
  9. package/dist/core/codegen/helpers.js +28 -7
  10. package/dist/core/codegen/index.js +6 -4
  11. package/dist/core/codegen/literal-handlers.js +4 -2
  12. package/dist/core/codegen/statement-handlers.js +39 -19
  13. package/package.json +1 -1
  14. package/src/prelude/any_value.hpp +89 -59
  15. package/src/prelude/any_value_access.hpp +1 -1
  16. package/src/prelude/any_value_helpers.hpp +85 -43
  17. package/src/prelude/index.hpp +1 -0
  18. package/src/prelude/library/array.hpp +3 -2
  19. package/src/prelude/types.hpp +8 -8
  20. package/src/prelude/utils/access.hpp +62 -6
  21. package/src/prelude/utils/assignment_operators.hpp +14 -14
  22. package/src/prelude/utils/log_any_value/array.hpp +0 -15
  23. package/src/prelude/utils/log_any_value/primitives.hpp +2 -0
  24. package/src/prelude/utils/operators.hpp +117 -474
  25. package/src/prelude/utils/operators_primitive.hpp +337 -0
  26. package/src/prelude/values/helpers/array.hpp +4 -4
  27. package/src/prelude/values/helpers/async_iterator.hpp +2 -2
  28. package/src/prelude/values/helpers/function.hpp +3 -3
  29. package/src/prelude/values/helpers/iterator.hpp +2 -2
  30. package/src/prelude/values/helpers/object.hpp +3 -3
  31. package/src/prelude/values/helpers/promise.hpp +1 -1
  32. package/src/prelude/values/helpers/string.hpp +1 -1
  33. package/src/prelude/values/helpers/symbol.hpp +1 -1
  34. package/src/prelude/values/prototypes/array.hpp +1125 -853
  35. package/src/prelude/values/prototypes/async_iterator.hpp +32 -14
  36. package/src/prelude/values/prototypes/function.hpp +30 -18
  37. package/src/prelude/values/prototypes/iterator.hpp +40 -17
  38. package/src/prelude/values/prototypes/number.hpp +119 -62
  39. package/src/prelude/values/prototypes/object.hpp +10 -4
  40. package/src/prelude/values/prototypes/promise.hpp +167 -109
  41. package/src/prelude/values/prototypes/string.hpp +407 -231
  42. package/src/prelude/values/prototypes/symbol.hpp +45 -23
@@ -0,0 +1,337 @@
1
+ #pragma once
2
+
3
+ #include "types.hpp"
4
+ #include "any_value.hpp"
5
+ #include <cstdint> // For int32_t
6
+ #include <cmath> // For fmod, isnan, isinf, floor, abs, pow
7
+ #include <string> // For std::to_string, std::stod
8
+ #include <algorithm> // For std::all_of
9
+ #include <limits> // For numeric_limits
10
+
11
+ namespace jspp
12
+ {
13
+ // Private namespace for helper functions that implement JS type conversions.
14
+ namespace Operators_Private
15
+ {
16
+ // Implements the ToNumber abstract operation from ECMA-262.
17
+ inline double ToNumber(const AnyValue &val)
18
+ {
19
+ if (val.is_number())
20
+ return val.as_double();
21
+ if (val.is_null())
22
+ return 0.0;
23
+ if (val.is_undefined())
24
+ return std::numeric_limits<double>::quiet_NaN();
25
+ if (val.is_boolean())
26
+ return val.as_boolean() ? 1.0 : 0.0;
27
+ if (val.is_string())
28
+ {
29
+ const std::string &s = val.as_string()->value;
30
+ if (s.empty() || std::all_of(s.begin(), s.end(), [](unsigned char c)
31
+ { return std::isspace(c); }))
32
+ return 0.0;
33
+ try
34
+ {
35
+ size_t pos;
36
+ double num = std::stod(s, &pos);
37
+ while (pos < s.length() && std::isspace(static_cast<unsigned char>(s[pos])))
38
+ pos++;
39
+ if (pos != s.length())
40
+ return std::numeric_limits<double>::quiet_NaN();
41
+ return num;
42
+ }
43
+ catch (...)
44
+ {
45
+ return std::numeric_limits<double>::quiet_NaN();
46
+ }
47
+ }
48
+ if (val.is_uninitialized())
49
+ {
50
+ // THROW
51
+ Exception::throw_uninitialized_reference("#<Object>");
52
+ }
53
+ // Default to NaN
54
+ return std::numeric_limits<double>::quiet_NaN();
55
+ }
56
+ // Implements the ToInt32 abstract operation from ECMA-262.
57
+ inline int32_t ToInt32(const AnyValue &val)
58
+ {
59
+ double num = ToNumber(val);
60
+
61
+ if (std::isnan(num) || std::isinf(num) || num == 0)
62
+ return 0;
63
+
64
+ double posInt = std::signbit(num) ? -std::floor(std::abs(num)) : std::floor(std::abs(num));
65
+ double int32bit = fmod(posInt, 4294967296.0); // 2^32
66
+
67
+ if (int32bit >= 2147483648.0) // 2^31
68
+ return static_cast<int32_t>(int32bit - 4294967296.0);
69
+ else
70
+ return static_cast<int32_t>(int32bit);
71
+ }
72
+ // Implements the ToUint32 abstract operation from ECMA-262.
73
+ inline uint32_t ToUint32(const AnyValue &val)
74
+ {
75
+ double num = ToNumber(val);
76
+ if (std::isnan(num) || std::isinf(num) || num == 0)
77
+ return 0;
78
+ double posInt = std::signbit(num) ? -std::floor(std::abs(num)) : std::floor(std::abs(num));
79
+ uint32_t uint32bit = static_cast<uint32_t>(fmod(posInt, 4294967296.0));
80
+ return uint32bit;
81
+ }
82
+ }
83
+
84
+ // --- TRUTHY CHECKER ---
85
+ inline const bool is_truthy(const double &val) noexcept
86
+ {
87
+ return val != 0.0 && !std::isnan(val);
88
+ }
89
+ inline const bool is_truthy(const std::string &val) noexcept
90
+ {
91
+ return !val.empty();
92
+ }
93
+ inline const bool is_truthy(const AnyValue &val) noexcept
94
+ {
95
+ switch (val.get_type())
96
+ {
97
+ case JsType::Number:
98
+ return is_truthy(val.as_double());
99
+ case JsType::String:
100
+ return is_truthy(val.as_string()->value);
101
+ case JsType::Boolean:
102
+ return val.as_boolean();
103
+ case JsType::Null:
104
+ case JsType::Undefined:
105
+ case JsType::Uninitialized:
106
+ return false;
107
+ default:
108
+ return true;
109
+ }
110
+ }
111
+
112
+ // --- BASIC EQUALITY ---
113
+
114
+ // Operator === (returns primitive boolean)
115
+ inline const bool is_strictly_equal_to_primitive(const AnyValue &lhs, const double &rhs) noexcept
116
+ {
117
+ if (lhs.is_number())
118
+ return lhs.as_double() == rhs;
119
+ return false;
120
+ }
121
+ inline const bool is_strictly_equal_to_primitive(const double &lhs, const AnyValue &rhs) noexcept
122
+ {
123
+ if (rhs.is_number())
124
+ return lhs == rhs.as_double();
125
+ return false;
126
+ }
127
+ inline const bool is_strictly_equal_to_primitive(const double &lhs, const double &rhs) noexcept
128
+ {
129
+ return lhs == rhs;
130
+ }
131
+ inline const bool is_strictly_equal_to_primitive(const AnyValue &lhs, const AnyValue &rhs) noexcept
132
+ {
133
+ JsType type = lhs.get_type();
134
+ if (type != rhs.get_type())
135
+ return false;
136
+ switch (type)
137
+ {
138
+ case JsType::Boolean:
139
+ return lhs.as_boolean() == rhs.as_boolean();
140
+ case JsType::Number:
141
+ return lhs.as_double() == rhs.as_double();
142
+ case JsType::String:
143
+ return lhs.as_string()->value == rhs.as_string()->value;
144
+ case JsType::Array:
145
+ return lhs.as_array() == rhs.as_array();
146
+ case JsType::Object:
147
+ return lhs.as_object() == rhs.as_object();
148
+ case JsType::Function:
149
+ return lhs.as_function() == rhs.as_function();
150
+ case JsType::Iterator:
151
+ return lhs.as_iterator() == rhs.as_iterator();
152
+ case JsType::AsyncIterator:
153
+ return lhs.as_async_iterator() == rhs.as_async_iterator();
154
+ case JsType::Promise:
155
+ return lhs.as_promise() == rhs.as_promise();
156
+ case JsType::Symbol:
157
+ return lhs.as_symbol() == rhs.as_symbol();
158
+ case JsType::DataDescriptor:
159
+ return lhs.as_data_descriptor() == rhs.as_data_descriptor();
160
+ case JsType::AccessorDescriptor:
161
+ return lhs.as_accessor_descriptor() == rhs.as_accessor_descriptor();
162
+ default:
163
+ return true;
164
+ }
165
+ }
166
+
167
+ // Operator == (returns primitive boolean)
168
+ inline const bool is_equal_to_primitive(const AnyValue &lhs, const double &rhs) noexcept
169
+ {
170
+ return is_equal_to_primitive(lhs, AnyValue::make_number(rhs));
171
+ }
172
+ inline const bool is_equal_to_primitive(const double &lhs, const AnyValue &rhs) noexcept
173
+ {
174
+ return is_equal_to_primitive(AnyValue::make_number(lhs), rhs);
175
+ }
176
+ inline const bool is_equal_to_primitive(const double &lhs, const double &rhs) noexcept
177
+ {
178
+ return lhs == rhs;
179
+ }
180
+ inline const bool is_equal_to_primitive(const AnyValue &lhs, const AnyValue &rhs) noexcept
181
+ {
182
+ JsType lhs_type = lhs.get_type();
183
+ JsType rhs_type = rhs.get_type();
184
+ if (lhs_type == rhs_type)
185
+ {
186
+ return is_strictly_equal_to_primitive(lhs, rhs);
187
+ }
188
+ if ((lhs_type == JsType::Null && rhs_type == JsType::Undefined) || (lhs_type == JsType::Undefined && rhs_type == JsType::Null))
189
+ {
190
+ return true;
191
+ }
192
+ if (lhs_type == JsType::Number && rhs_type == JsType::String)
193
+ {
194
+ return lhs.as_double() == Operators_Private::ToNumber(rhs);
195
+ }
196
+ if (lhs_type == JsType::String && rhs_type == JsType::Number)
197
+ {
198
+ return Operators_Private::ToNumber(lhs) == rhs.as_double();
199
+ }
200
+ if (lhs_type == JsType::Boolean)
201
+ {
202
+ return is_equal_to_primitive(lhs.as_boolean() ? 1.0 : 0.0, rhs);
203
+ }
204
+ if (rhs_type == JsType::Boolean)
205
+ {
206
+ return is_equal_to_primitive(lhs, AnyValue::make_number(rhs.as_boolean() ? 1.0 : 0.0));
207
+ }
208
+ if ((lhs_type == JsType::Object || lhs_type == JsType::Array || lhs_type == JsType::Function || lhs_type == JsType::Promise || lhs_type == JsType::Iterator) &&
209
+ (rhs_type == JsType::String || rhs_type == JsType::Number || rhs_type == JsType::Symbol))
210
+ {
211
+ return is_equal_to_primitive(AnyValue::make_string(lhs.to_std_string()), rhs);
212
+ }
213
+ if ((rhs_type == JsType::Object || rhs_type == JsType::Array || rhs_type == JsType::Function || rhs_type == JsType::Promise || rhs_type == JsType::Iterator) &&
214
+ (lhs_type == JsType::String || lhs_type == JsType::Number || lhs_type == JsType::Symbol))
215
+ {
216
+ return is_equal_to_primitive(lhs, AnyValue::make_string(rhs.to_std_string()));
217
+ }
218
+ if (lhs_type == JsType::DataDescriptor || lhs_type == JsType::AccessorDescriptor)
219
+ {
220
+ return is_strictly_equal_to_primitive(lhs, rhs);
221
+ }
222
+ return false;
223
+ }
224
+
225
+ // --- PRIMITIVE ARITHMETIC OPERATORS ---
226
+ inline double add_primitive(const double &lhs, const double &rhs) { return lhs + rhs; }
227
+ inline double add_primitive(const AnyValue &lhs, const AnyValue &rhs) { return Operators_Private::ToNumber(lhs) + Operators_Private::ToNumber(rhs); }
228
+ inline double add_primitive(const AnyValue &lhs, const double &rhs) { return Operators_Private::ToNumber(lhs) + rhs; }
229
+ inline double add_primitive(const double &lhs, const AnyValue &rhs) { return lhs + Operators_Private::ToNumber(rhs); }
230
+
231
+ inline double sub_primitive(const double &lhs, const double &rhs) { return lhs - rhs; }
232
+ inline double sub_primitive(const AnyValue &lhs, const AnyValue &rhs) { return Operators_Private::ToNumber(lhs) - Operators_Private::ToNumber(rhs); }
233
+ inline double sub_primitive(const AnyValue &lhs, const double &rhs) { return Operators_Private::ToNumber(lhs) - rhs; }
234
+ inline double sub_primitive(const double &lhs, const AnyValue &rhs) { return lhs - Operators_Private::ToNumber(rhs); }
235
+
236
+ inline double mul_primitive(const double &lhs, const double &rhs) { return lhs * rhs; }
237
+ inline double mul_primitive(const AnyValue &lhs, const AnyValue &rhs) { return Operators_Private::ToNumber(lhs) * Operators_Private::ToNumber(rhs); }
238
+ inline double mul_primitive(const AnyValue &lhs, const double &rhs) { return Operators_Private::ToNumber(lhs) * rhs; }
239
+ inline double mul_primitive(const double &lhs, const AnyValue &rhs) { return lhs * Operators_Private::ToNumber(rhs); }
240
+
241
+ inline double div_primitive(const double &lhs, const double &rhs) { return lhs / rhs; }
242
+ inline double div_primitive(const AnyValue &lhs, const AnyValue &rhs) { return Operators_Private::ToNumber(lhs) / Operators_Private::ToNumber(rhs); }
243
+ inline double div_primitive(const AnyValue &lhs, const double &rhs) { return Operators_Private::ToNumber(lhs) / rhs; }
244
+ inline double div_primitive(const double &lhs, const AnyValue &rhs) { return lhs / Operators_Private::ToNumber(rhs); }
245
+
246
+ inline double mod_primitive(const double &lhs, const double &rhs) { return std::fmod(lhs, rhs); }
247
+ inline double mod_primitive(const AnyValue &lhs, const AnyValue &rhs) { return std::fmod(Operators_Private::ToNumber(lhs), Operators_Private::ToNumber(rhs)); }
248
+ inline double mod_primitive(const AnyValue &lhs, const double &rhs) { return std::fmod(Operators_Private::ToNumber(lhs), rhs); }
249
+ inline double mod_primitive(const double &lhs, const AnyValue &rhs) { return std::fmod(lhs, Operators_Private::ToNumber(rhs)); }
250
+
251
+ inline double pow_primitive(const double &lhs, const double &rhs) { return std::pow(lhs, rhs); }
252
+ inline double pow_primitive(const AnyValue &lhs, const AnyValue &rhs) { return std::pow(Operators_Private::ToNumber(lhs), Operators_Private::ToNumber(rhs)); }
253
+ inline double pow_primitive(const AnyValue &lhs, const double &rhs) { return std::pow(Operators_Private::ToNumber(lhs), rhs); }
254
+ inline double pow_primitive(const double &lhs, const AnyValue &rhs) { return std::pow(lhs, Operators_Private::ToNumber(rhs)); }
255
+
256
+ // --- PRIMITIVE COMPARISON OPERATORS ---
257
+ inline bool less_than_primitive(const double &lhs, const double &rhs) { return lhs < rhs; }
258
+ inline bool less_than_primitive(const AnyValue &lhs, const AnyValue &rhs) { return less_than_primitive(Operators_Private::ToNumber(lhs), Operators_Private::ToNumber(rhs)); }
259
+ inline bool less_than_primitive(const AnyValue &lhs, const double &rhs) { return less_than_primitive(Operators_Private::ToNumber(lhs), rhs); }
260
+ inline bool less_than_primitive(const double &lhs, const AnyValue &rhs) { return less_than_primitive(lhs, Operators_Private::ToNumber(rhs)); }
261
+
262
+ inline bool greater_than_primitive(const double &lhs, const double &rhs) { return lhs > rhs; }
263
+ inline bool greater_than_primitive(const AnyValue &lhs, const AnyValue &rhs) { return greater_than_primitive(Operators_Private::ToNumber(lhs), Operators_Private::ToNumber(rhs)); }
264
+ inline bool greater_than_primitive(const AnyValue &lhs, const double &rhs) { return greater_than_primitive(Operators_Private::ToNumber(lhs), rhs); }
265
+ inline bool greater_than_primitive(const double &lhs, const AnyValue &rhs) { return greater_than_primitive(lhs, Operators_Private::ToNumber(rhs)); }
266
+
267
+ inline bool less_than_or_equal_primitive(const double &lhs, const double &rhs) { return lhs <= rhs; }
268
+ inline bool less_than_or_equal_primitive(const AnyValue &lhs, const AnyValue &rhs) { return less_than_or_equal_primitive(Operators_Private::ToNumber(lhs), Operators_Private::ToNumber(rhs)); }
269
+ inline bool less_than_or_equal_primitive(const AnyValue &lhs, const double &rhs) { return less_than_or_equal_primitive(Operators_Private::ToNumber(lhs), rhs); }
270
+ inline bool less_than_or_equal_primitive(const double &lhs, const AnyValue &rhs) { return less_than_or_equal_primitive(lhs, Operators_Private::ToNumber(rhs)); }
271
+
272
+ inline bool greater_than_or_equal_primitive(const double &lhs, const double &rhs) { return lhs >= rhs; }
273
+ inline bool greater_than_or_equal_primitive(const AnyValue &lhs, const AnyValue &rhs) { return greater_than_or_equal_primitive(Operators_Private::ToNumber(lhs), Operators_Private::ToNumber(rhs)); }
274
+ inline bool greater_than_or_equal_primitive(const AnyValue &lhs, const double &rhs) { return greater_than_or_equal_primitive(Operators_Private::ToNumber(lhs), rhs); }
275
+ inline bool greater_than_or_equal_primitive(const double &lhs, const AnyValue &rhs) { return greater_than_or_equal_primitive(lhs, Operators_Private::ToNumber(rhs)); }
276
+
277
+ inline bool equal_primitive(const double &lhs, const double &rhs) { return lhs == rhs; }
278
+ inline bool equal_primitive(const AnyValue &lhs, const AnyValue &rhs) { return equal_primitive(Operators_Private::ToNumber(lhs), Operators_Private::ToNumber(rhs)); }
279
+ inline bool equal_primitive(const AnyValue &lhs, const double &rhs) { return equal_primitive(Operators_Private::ToNumber(lhs), rhs); }
280
+ inline bool equal_primitive(const double &lhs, const AnyValue &rhs) { return equal_primitive(lhs, Operators_Private::ToNumber(rhs)); }
281
+
282
+ inline bool not_equal_primitive(const double &lhs, const double &rhs) { return lhs != rhs; }
283
+ inline bool not_equal_primitive(const AnyValue &lhs, const AnyValue &rhs) { return not_equal_primitive(Operators_Private::ToNumber(lhs), Operators_Private::ToNumber(rhs)); }
284
+ inline bool not_equal_primitive(const AnyValue &lhs, const double &rhs) { return not_equal_primitive(Operators_Private::ToNumber(lhs), rhs); }
285
+ inline bool not_equal_primitive(const double &lhs, const AnyValue &rhs) { return not_equal_primitive(lhs, Operators_Private::ToNumber(rhs)); }
286
+
287
+ // --- PRIMITIVE BITWISE OPERATORS ---
288
+ inline double bitwise_and_primitive(const double &lhs, const double &rhs)
289
+ {
290
+ return static_cast<double>(static_cast<int32_t>(lhs) & static_cast<int32_t>(rhs));
291
+ }
292
+ inline double bitwise_and_primitive(const AnyValue &lhs, const AnyValue &rhs) { return bitwise_and_primitive(Operators_Private::ToInt32(lhs), Operators_Private::ToInt32(rhs)); }
293
+ inline double bitwise_and_primitive(const AnyValue &lhs, const double &rhs) { return bitwise_and_primitive(Operators_Private::ToInt32(lhs), rhs); }
294
+ inline double bitwise_and_primitive(const double &lhs, const AnyValue &rhs) { return bitwise_and_primitive(lhs, Operators_Private::ToInt32(rhs)); }
295
+
296
+ inline double bitwise_or_primitive(const double &lhs, const double &rhs)
297
+ {
298
+ return static_cast<double>(static_cast<int32_t>(lhs) | static_cast<int32_t>(rhs));
299
+ }
300
+ inline double bitwise_or_primitive(const AnyValue &lhs, const AnyValue &rhs) { return bitwise_or_primitive(Operators_Private::ToInt32(lhs), Operators_Private::ToInt32(rhs)); }
301
+ inline double bitwise_or_primitive(const AnyValue &lhs, const double &rhs) { return bitwise_or_primitive(Operators_Private::ToInt32(lhs), rhs); }
302
+ inline double bitwise_or_primitive(const double &lhs, const AnyValue &rhs) { return bitwise_or_primitive(lhs, Operators_Private::ToInt32(rhs)); }
303
+
304
+ inline double bitwise_xor_primitive(const double &lhs, const double &rhs)
305
+ {
306
+ return static_cast<double>(static_cast<int32_t>(lhs) ^ static_cast<int32_t>(rhs));
307
+ }
308
+ inline double bitwise_xor_primitive(const AnyValue &lhs, const AnyValue &rhs) { return bitwise_xor_primitive(Operators_Private::ToInt32(lhs), Operators_Private::ToInt32(rhs)); }
309
+ inline double bitwise_xor_primitive(const AnyValue &lhs, const double &rhs) { return bitwise_xor_primitive(Operators_Private::ToInt32(lhs), rhs); }
310
+ inline double bitwise_xor_primitive(const double &lhs, const AnyValue &rhs) { return bitwise_xor_primitive(lhs, Operators_Private::ToInt32(rhs)); }
311
+
312
+ inline double left_shift_primitive(const double &lhs, const double &rhs)
313
+ {
314
+ return static_cast<double>(static_cast<int32_t>(lhs) << (static_cast<int32_t>(rhs) & 0x1F));
315
+ }
316
+ inline double left_shift_primitive(const AnyValue &lhs, const AnyValue &rhs) { return left_shift_primitive(Operators_Private::ToInt32(lhs), Operators_Private::ToInt32(rhs)); }
317
+ inline double left_shift_primitive(const AnyValue &lhs, const double &rhs) { return left_shift_primitive(Operators_Private::ToInt32(lhs), rhs); }
318
+ inline double left_shift_primitive(const double &lhs, const AnyValue &rhs) { return left_shift_primitive(lhs, Operators_Private::ToInt32(rhs)); }
319
+
320
+ inline double right_shift_primitive(const double &lhs, const double &rhs)
321
+ {
322
+ return static_cast<double>(static_cast<int32_t>(lhs) >> (static_cast<int32_t>(rhs) & 0x1F));
323
+ }
324
+ inline double right_shift_primitive(const AnyValue &lhs, const AnyValue &rhs) { return right_shift_primitive(Operators_Private::ToInt32(lhs), Operators_Private::ToInt32(rhs)); }
325
+ inline double right_shift_primitive(const AnyValue &lhs, const double &rhs) { return right_shift_primitive(Operators_Private::ToInt32(lhs), rhs); }
326
+ inline double right_shift_primitive(const double &lhs, const AnyValue &rhs) { return right_shift_primitive(lhs, Operators_Private::ToInt32(rhs)); }
327
+
328
+ inline double unsigned_right_shift_primitive(const double &lhs, const double &rhs)
329
+ {
330
+ uint32_t l = static_cast<uint32_t>(fmod(lhs, 4294967296.0));
331
+ return static_cast<double>(l >> (static_cast<int32_t>(rhs) & 0x1F));
332
+ }
333
+ inline double unsigned_right_shift_primitive(const AnyValue &lhs, const AnyValue &rhs) { return unsigned_right_shift_primitive(Operators_Private::ToUint32(lhs), Operators_Private::ToInt32(rhs)); }
334
+ inline double unsigned_right_shift_primitive(const AnyValue &lhs, const double &rhs) { return unsigned_right_shift_primitive(Operators_Private::ToUint32(lhs), rhs); }
335
+ inline double unsigned_right_shift_primitive(const double &lhs, const AnyValue &rhs) { return unsigned_right_shift_primitive(lhs, Operators_Private::ToInt32(rhs)); }
336
+
337
+ }
@@ -81,7 +81,7 @@ inline bool jspp::JsArray::has_property(const std::string &key) const
81
81
  return true;
82
82
  }
83
83
 
84
- if (ArrayPrototypes::get(key, const_cast<JsArray *>(this)).has_value())
84
+ if (ArrayPrototypes::get(key).has_value())
85
85
  return true;
86
86
  return false;
87
87
  }
@@ -102,7 +102,7 @@ inline jspp::AnyValue jspp::JsArray::get_property(const std::string &key, const
102
102
  {
103
103
  if (key == "length")
104
104
  {
105
- auto proto_it = ArrayPrototypes::get(key, this);
105
+ auto proto_it = ArrayPrototypes::get(key);
106
106
  if (proto_it.has_value())
107
107
  {
108
108
  return AnyValue::resolve_property_for_read(proto_it.value(), thisVal, key);
@@ -117,7 +117,7 @@ inline jspp::AnyValue jspp::JsArray::get_property(const std::string &key, const
117
117
  }
118
118
  }
119
119
 
120
- auto proto_it = ArrayPrototypes::get(key, this);
120
+ auto proto_it = ArrayPrototypes::get(key);
121
121
  if (proto_it.has_value())
122
122
  {
123
123
  return AnyValue::resolve_property_for_read(proto_it.value(), thisVal, key);
@@ -155,7 +155,7 @@ inline jspp::AnyValue jspp::JsArray::set_property(const std::string &key, const
155
155
  }
156
156
  else
157
157
  {
158
- auto proto_val_opt = ArrayPrototypes::get(key, this);
158
+ auto proto_val_opt = ArrayPrototypes::get(key);
159
159
 
160
160
  if (proto_val_opt.has_value())
161
161
  {
@@ -21,7 +21,7 @@ jspp::AnyValue jspp::JsAsyncIterator<T>::get_property(const std::string &key, co
21
21
  {
22
22
  if constexpr (std::is_same_v<T, AnyValue>)
23
23
  {
24
- auto proto_it = AsyncIteratorPrototypes::get(key, this);
24
+ auto proto_it = AsyncIteratorPrototypes::get(key);
25
25
  if (proto_it.has_value())
26
26
  {
27
27
  return AnyValue::resolve_property_for_read(proto_it.value(), thisVal, key);
@@ -37,7 +37,7 @@ jspp::AnyValue jspp::JsAsyncIterator<T>::set_property(const std::string &key, co
37
37
  {
38
38
  if constexpr (std::is_same_v<T, AnyValue>)
39
39
  {
40
- auto proto_it = AsyncIteratorPrototypes::get(key, this);
40
+ auto proto_it = AsyncIteratorPrototypes::get(key);
41
41
  if (proto_it.has_value())
42
42
  {
43
43
  auto proto_value = proto_it.value();
@@ -51,7 +51,7 @@ namespace jspp
51
51
  if (proto.has_property(key))
52
52
  return true;
53
53
  }
54
- if (FunctionPrototypes::get(key, const_cast<JsFunction *>(this)).has_value())
54
+ if (FunctionPrototypes::get(key).has_value())
55
55
  return true;
56
56
  return false;
57
57
  }
@@ -69,7 +69,7 @@ namespace jspp
69
69
  }
70
70
  }
71
71
 
72
- auto proto_it = FunctionPrototypes::get(key, this);
72
+ auto proto_it = FunctionPrototypes::get(key);
73
73
  if (proto_it.has_value())
74
74
  {
75
75
  return AnyValue::resolve_property_for_read(proto_it.value(), thisVal, key);
@@ -81,7 +81,7 @@ namespace jspp
81
81
 
82
82
  inline AnyValue JsFunction::set_property(const std::string &key, const AnyValue &value, const AnyValue &thisVal)
83
83
  {
84
- auto proto_it = FunctionPrototypes::get(key, this);
84
+ auto proto_it = FunctionPrototypes::get(key);
85
85
  if (proto_it.has_value())
86
86
  {
87
87
  auto proto_value = proto_it.value();
@@ -60,7 +60,7 @@ jspp::AnyValue jspp::JsIterator<T>::get_property(const std::string &key, const A
60
60
  // check prototype
61
61
  if constexpr (std::is_same_v<T, AnyValue>)
62
62
  {
63
- auto proto_it = IteratorPrototypes::get(key, this);
63
+ auto proto_it = IteratorPrototypes::get(key);
64
64
  if (proto_it.has_value())
65
65
  {
66
66
  return AnyValue::resolve_property_for_read(proto_it.value(), thisVal, key);
@@ -79,7 +79,7 @@ jspp::AnyValue jspp::JsIterator<T>::set_property(const std::string &key, const A
79
79
  // set prototype property if accessor descriptor
80
80
  if constexpr (std::is_same_v<T, AnyValue>)
81
81
  {
82
- auto proto_it = IteratorPrototypes::get(key, this);
82
+ auto proto_it = IteratorPrototypes::get(key);
83
83
  if (proto_it.has_value())
84
84
  {
85
85
  auto proto_value = proto_it.value();
@@ -42,7 +42,7 @@ inline bool jspp::JsObject::has_property(const std::string &key) const
42
42
  if (proto.has_property(key))
43
43
  return true;
44
44
  }
45
- if (ObjectPrototypes::get(key, const_cast<JsObject *>(this)).has_value())
45
+ if (ObjectPrototypes::get(key).has_value())
46
46
  return true;
47
47
  return false;
48
48
  }
@@ -62,7 +62,7 @@ inline jspp::AnyValue jspp::JsObject::get_property(const std::string &key, const
62
62
  }
63
63
  }
64
64
 
65
- auto proto_it = ObjectPrototypes::get(key, this);
65
+ auto proto_it = ObjectPrototypes::get(key);
66
66
  if (proto_it.has_value())
67
67
  {
68
68
  return AnyValue::resolve_property_for_read(proto_it.value(), thisVal, key);
@@ -74,7 +74,7 @@ inline jspp::AnyValue jspp::JsObject::get_property(const std::string &key, const
74
74
 
75
75
  inline jspp::AnyValue jspp::JsObject::set_property(const std::string &key, const AnyValue &value, const AnyValue &thisVal)
76
76
  {
77
- auto proto_it = ObjectPrototypes::get(key, this);
77
+ auto proto_it = ObjectPrototypes::get(key);
78
78
  if (proto_it.has_value())
79
79
  {
80
80
  auto proto_value = proto_it.value();
@@ -143,7 +143,7 @@ namespace jspp
143
143
  inline AnyValue JsPromise::get_property(const std::string &key, const AnyValue &thisVal)
144
144
  {
145
145
  // Prototype lookup
146
- auto proto_it = PromisePrototypes::get(key, const_cast<JsPromise *>(this));
146
+ auto proto_it = PromisePrototypes::get(key);
147
147
  if (proto_it.has_value())
148
148
  {
149
149
  return AnyValue::resolve_property_for_read(proto_it.value(), thisVal, key);
@@ -24,7 +24,7 @@ inline jspp::JsIterator<jspp::AnyValue> jspp::JsString::get_iterator()
24
24
 
25
25
  inline jspp::AnyValue jspp::JsString::get_property(const std::string &key, const AnyValue &thisVal)
26
26
  {
27
- auto proto_fn = StringPrototypes::get(key, this);
27
+ auto proto_fn = StringPrototypes::get(key);
28
28
  if (proto_fn.has_value())
29
29
  {
30
30
  return AnyValue::resolve_property_for_read(proto_fn.value(), thisVal, key);
@@ -12,7 +12,7 @@ inline std::string jspp::JsSymbol::to_std_string() const
12
12
 
13
13
  inline jspp::AnyValue jspp::JsSymbol::get_property(const std::string &key, const AnyValue &thisVal)
14
14
  {
15
- auto proto_it = SymbolPrototypes::get(key, this);
15
+ auto proto_it = SymbolPrototypes::get(key);
16
16
  if (proto_it.has_value())
17
17
  {
18
18
  return AnyValue::resolve_property_for_read(proto_it.value(), thisVal, key);