@ugo-studio/jspp 0.3.1 → 0.3.3
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/dist/cli/args.js +22 -0
- package/dist/cli/compiler.js +53 -0
- package/dist/cli/index.js +43 -117
- package/dist/cli/pch.js +71 -0
- package/dist/cli/runner.js +23 -0
- package/dist/cli/spinner.js +27 -11
- package/dist/cli/transpiler.js +20 -0
- package/dist/cli/utils.js +25 -27
- package/dist/cli/wasm.js +70 -0
- package/dist/index.js +17 -6
- package/dist/{analysis → interpreter/analysis}/scope.js +34 -1
- package/dist/{analysis → interpreter/analysis}/typeAnalyzer.js +542 -3
- package/dist/{core → interpreter/core}/codegen/class-handlers.js +1 -1
- package/dist/{core → interpreter/core}/codegen/control-flow-handlers.js +2 -2
- package/dist/{core → interpreter/core}/codegen/declaration-handlers.js +21 -9
- package/dist/{core → interpreter/core}/codegen/destructuring-handlers.js +3 -3
- package/dist/{core → interpreter/core}/codegen/expression-handlers.js +136 -82
- package/dist/{core → interpreter/core}/codegen/function-handlers.js +108 -61
- package/dist/{core → interpreter/core}/codegen/helpers.js +79 -11
- package/dist/interpreter/core/codegen/index.js +156 -0
- package/dist/{core → interpreter/core}/codegen/literal-handlers.js +9 -0
- package/dist/{core → interpreter/core}/codegen/statement-handlers.js +39 -1
- package/package.json +6 -4
- package/scripts/precompile-headers.ts +71 -19
- package/scripts/setup-emsdk.ts +114 -0
- package/src/prelude/any_value.cpp +851 -599
- package/src/prelude/any_value.hpp +28 -30
- package/src/prelude/jspp.hpp +3 -1
- package/src/prelude/library/boolean.cpp +30 -0
- package/src/prelude/library/boolean.hpp +14 -0
- package/src/prelude/library/error.cpp +2 -2
- package/src/prelude/library/global.cpp +2 -0
- package/src/prelude/library/math.cpp +46 -43
- package/src/prelude/library/math.hpp +2 -0
- package/src/prelude/library/object.cpp +1 -1
- package/src/prelude/types.hpp +10 -9
- package/src/prelude/utils/access.hpp +2 -36
- package/src/prelude/utils/assignment_operators.hpp +136 -20
- package/src/prelude/utils/log_any_value/log_any_value.hpp +1 -1
- package/src/prelude/utils/log_any_value/primitives.hpp +1 -1
- package/src/prelude/utils/operators.hpp +123 -88
- package/src/prelude/utils/operators_native.hpp +360 -0
- package/src/prelude/utils/well_known_symbols.hpp +13 -13
- package/src/prelude/values/array.cpp +3 -3
- package/src/prelude/values/boolean.cpp +64 -0
- package/src/prelude/values/iterator.cpp +262 -210
- package/src/prelude/values/number.cpp +137 -92
- package/src/prelude/values/object.cpp +163 -122
- package/src/prelude/values/prototypes/boolean.hpp +24 -0
- package/src/prelude/values/prototypes/number.hpp +8 -1
- package/dist/cli/file-utils.js +0 -20
- package/dist/cli-utils/args.js +0 -59
- package/dist/cli-utils/colors.js +0 -9
- package/dist/cli-utils/file-utils.js +0 -20
- package/dist/cli-utils/spinner.js +0 -55
- package/dist/cli.js +0 -153
- package/dist/core/codegen/index.js +0 -88
- package/src/prelude/utils/operators_primitive.hpp +0 -337
- /package/dist/{ast → interpreter/ast}/symbols.js +0 -0
- /package/dist/{ast → interpreter/ast}/types.js +0 -0
- /package/dist/{core → interpreter/core}/codegen/visitor.js +0 -0
- /package/dist/{core → interpreter/core}/constants.js +0 -0
- /package/dist/{core → interpreter/core}/error.js +0 -0
- /package/dist/{core → interpreter/core}/parser.js +0 -0
- /package/dist/{core → interpreter/core}/traverser.js +0 -0
|
@@ -2,85 +2,120 @@
|
|
|
2
2
|
|
|
3
3
|
#include "types.hpp"
|
|
4
4
|
#include "any_value.hpp"
|
|
5
|
-
#include "
|
|
5
|
+
#include "operators_native.hpp"
|
|
6
6
|
#include <cstdint> // For int32_t
|
|
7
7
|
#include <cmath> // For fmod, isnan, isinf, floor, abs, pow
|
|
8
|
-
#include <string> // For std::
|
|
8
|
+
#include <string> // For std::stod
|
|
9
9
|
#include <algorithm> // For std::all_of
|
|
10
10
|
#include <limits> // For numeric_limits
|
|
11
11
|
|
|
12
12
|
namespace jspp
|
|
13
13
|
{
|
|
14
|
+
// --- TYPE OF ---
|
|
15
|
+
inline AnyValue type_of(const std::optional<AnyValue> &val = std::nullopt)
|
|
16
|
+
{
|
|
17
|
+
if (!val.has_value())
|
|
18
|
+
return AnyValue::make_string("undefined");
|
|
19
|
+
|
|
20
|
+
switch (val.value().get_type())
|
|
21
|
+
{
|
|
22
|
+
case JsType::Undefined:
|
|
23
|
+
return AnyValue::make_string("undefined");
|
|
24
|
+
case JsType::Null:
|
|
25
|
+
return AnyValue::make_string("object");
|
|
26
|
+
case JsType::Boolean:
|
|
27
|
+
return AnyValue::make_string("boolean");
|
|
28
|
+
case JsType::Number:
|
|
29
|
+
return AnyValue::make_string("number");
|
|
30
|
+
case JsType::String:
|
|
31
|
+
return AnyValue::make_string("string");
|
|
32
|
+
case JsType::Symbol:
|
|
33
|
+
return AnyValue::make_string("symbol");
|
|
34
|
+
case JsType::Function:
|
|
35
|
+
return AnyValue::make_string("function");
|
|
36
|
+
case JsType::Object:
|
|
37
|
+
return AnyValue::make_string("object");
|
|
38
|
+
case JsType::Array:
|
|
39
|
+
return AnyValue::make_string("object");
|
|
40
|
+
case JsType::Iterator:
|
|
41
|
+
return AnyValue::make_string("object");
|
|
42
|
+
case JsType::AsyncIterator:
|
|
43
|
+
return AnyValue::make_string("object");
|
|
44
|
+
default:
|
|
45
|
+
return AnyValue::make_string("undefined");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
14
49
|
// Operator === (returns boolean wrapped in AnyValue)
|
|
15
50
|
inline const AnyValue is_strictly_equal_to(const AnyValue &lhs, const double &rhs) noexcept
|
|
16
51
|
{
|
|
17
|
-
return AnyValue::make_boolean(
|
|
52
|
+
return AnyValue::make_boolean(is_strictly_equal_to_native(lhs, rhs));
|
|
18
53
|
}
|
|
19
54
|
inline const AnyValue is_strictly_equal_to(const double &lhs, const AnyValue &rhs) noexcept
|
|
20
55
|
{
|
|
21
|
-
return AnyValue::make_boolean(
|
|
56
|
+
return AnyValue::make_boolean(is_strictly_equal_to_native(lhs, rhs));
|
|
22
57
|
}
|
|
23
58
|
inline const AnyValue is_strictly_equal_to(const double &lhs, const double &rhs) noexcept
|
|
24
59
|
{
|
|
25
|
-
return AnyValue::make_boolean(
|
|
60
|
+
return AnyValue::make_boolean(is_strictly_equal_to_native(lhs, rhs));
|
|
26
61
|
}
|
|
27
62
|
inline const AnyValue is_strictly_equal_to(const AnyValue &lhs, const AnyValue &rhs) noexcept
|
|
28
63
|
{
|
|
29
|
-
return AnyValue::make_boolean(
|
|
64
|
+
return AnyValue::make_boolean(is_strictly_equal_to_native(lhs, rhs));
|
|
30
65
|
}
|
|
31
66
|
|
|
32
67
|
// Operator == (returns boolean wrapped in AnyValue)
|
|
33
68
|
inline const AnyValue is_equal_to(const AnyValue &lhs, const double &rhs) noexcept
|
|
34
69
|
{
|
|
35
|
-
return AnyValue::make_boolean(
|
|
70
|
+
return AnyValue::make_boolean(is_equal_to_native(lhs, rhs));
|
|
36
71
|
}
|
|
37
72
|
inline const AnyValue is_equal_to(const double &lhs, const AnyValue &rhs) noexcept
|
|
38
73
|
{
|
|
39
|
-
return AnyValue::make_boolean(
|
|
74
|
+
return AnyValue::make_boolean(is_equal_to_native(lhs, rhs));
|
|
40
75
|
}
|
|
41
76
|
inline const AnyValue is_equal_to(const double &lhs, const double &rhs) noexcept
|
|
42
77
|
{
|
|
43
|
-
return AnyValue::make_boolean(
|
|
78
|
+
return AnyValue::make_boolean(is_equal_to_native(lhs, rhs));
|
|
44
79
|
}
|
|
45
80
|
inline const AnyValue is_equal_to(const AnyValue &lhs, const AnyValue &rhs) noexcept
|
|
46
81
|
{
|
|
47
|
-
return AnyValue::make_boolean(
|
|
82
|
+
return AnyValue::make_boolean(is_equal_to_native(lhs, rhs));
|
|
48
83
|
}
|
|
49
84
|
|
|
50
85
|
// Operator !== (returns boolean wrapped in AnyValue)
|
|
51
86
|
inline const AnyValue not_strictly_equal_to(const AnyValue &lhs, const double &rhs) noexcept
|
|
52
87
|
{
|
|
53
|
-
return AnyValue::make_boolean(!
|
|
88
|
+
return AnyValue::make_boolean(!is_strictly_equal_to_native(lhs, rhs));
|
|
54
89
|
}
|
|
55
90
|
inline const AnyValue not_strictly_equal_to(const double &lhs, const AnyValue &rhs) noexcept
|
|
56
91
|
{
|
|
57
|
-
return AnyValue::make_boolean(!
|
|
92
|
+
return AnyValue::make_boolean(!is_strictly_equal_to_native(lhs, rhs));
|
|
58
93
|
}
|
|
59
94
|
inline const AnyValue not_strictly_equal_to(const double &lhs, const double &rhs) noexcept
|
|
60
95
|
{
|
|
61
|
-
return AnyValue::make_boolean(!
|
|
96
|
+
return AnyValue::make_boolean(!is_strictly_equal_to_native(lhs, rhs));
|
|
62
97
|
}
|
|
63
98
|
inline const AnyValue not_strictly_equal_to(const AnyValue &lhs, const AnyValue &rhs) noexcept
|
|
64
99
|
{
|
|
65
|
-
return AnyValue::make_boolean(!
|
|
100
|
+
return AnyValue::make_boolean(!is_strictly_equal_to_native(lhs, rhs));
|
|
66
101
|
}
|
|
67
102
|
|
|
68
103
|
// Operator != (returns boolean wrapped in AnyValue)
|
|
69
104
|
inline const AnyValue not_equal_to(const AnyValue &lhs, const double &rhs) noexcept
|
|
70
105
|
{
|
|
71
|
-
return AnyValue::make_boolean(!
|
|
106
|
+
return AnyValue::make_boolean(!is_equal_to_native(lhs, rhs));
|
|
72
107
|
}
|
|
73
108
|
inline const AnyValue not_equal_to(const double &lhs, const AnyValue &rhs) noexcept
|
|
74
109
|
{
|
|
75
|
-
return AnyValue::make_boolean(!
|
|
110
|
+
return AnyValue::make_boolean(!is_equal_to_native(lhs, rhs));
|
|
76
111
|
}
|
|
77
112
|
inline const AnyValue not_equal_to(const double &lhs, const double &rhs) noexcept
|
|
78
113
|
{
|
|
79
|
-
return AnyValue::make_boolean(!
|
|
114
|
+
return AnyValue::make_boolean(!is_equal_to_native(lhs, rhs));
|
|
80
115
|
}
|
|
81
116
|
inline const AnyValue not_equal_to(const AnyValue &lhs, const AnyValue &rhs) noexcept
|
|
82
117
|
{
|
|
83
|
-
return AnyValue::make_boolean(!
|
|
118
|
+
return AnyValue::make_boolean(!is_equal_to_native(lhs, rhs));
|
|
84
119
|
}
|
|
85
120
|
|
|
86
121
|
// --- BASIC ARITHMETIC ---
|
|
@@ -92,23 +127,23 @@ namespace jspp
|
|
|
92
127
|
return AnyValue::make_number(lhs.as_double() + rhs.as_double());
|
|
93
128
|
if (lhs.is_string() || rhs.is_string())
|
|
94
129
|
return AnyValue::make_string(lhs.to_std_string() + rhs.to_std_string());
|
|
95
|
-
return AnyValue::make_number(
|
|
130
|
+
return AnyValue::make_number(add_native(lhs, rhs));
|
|
96
131
|
}
|
|
97
132
|
inline AnyValue add(const AnyValue &lhs, const double &rhs)
|
|
98
133
|
{
|
|
99
134
|
if (lhs.is_number())
|
|
100
135
|
return AnyValue::make_number(lhs.as_double() + rhs);
|
|
101
136
|
if (lhs.is_string())
|
|
102
|
-
return AnyValue::make_string(lhs.to_std_string() +
|
|
103
|
-
return AnyValue::make_number(
|
|
137
|
+
return AnyValue::make_string(lhs.to_std_string() + JsNumber::to_std_string(rhs));
|
|
138
|
+
return AnyValue::make_number(add_native(lhs, rhs));
|
|
104
139
|
}
|
|
105
140
|
inline AnyValue add(const double &lhs, const AnyValue &rhs)
|
|
106
141
|
{
|
|
107
142
|
if (rhs.is_number())
|
|
108
143
|
return AnyValue::make_number(lhs + rhs.as_double());
|
|
109
144
|
if (rhs.is_string())
|
|
110
|
-
return AnyValue::make_string(
|
|
111
|
-
return AnyValue::make_number(
|
|
145
|
+
return AnyValue::make_string(JsNumber::to_std_string(lhs) + rhs.to_std_string());
|
|
146
|
+
return AnyValue::make_number(add_native(lhs, rhs));
|
|
112
147
|
}
|
|
113
148
|
inline AnyValue add(const double &lhs, const double &rhs)
|
|
114
149
|
{
|
|
@@ -120,39 +155,39 @@ namespace jspp
|
|
|
120
155
|
{
|
|
121
156
|
if (lhs.is_number() && rhs.is_number())
|
|
122
157
|
return AnyValue::make_number(lhs.as_double() - rhs.as_double());
|
|
123
|
-
return AnyValue::make_number(
|
|
158
|
+
return AnyValue::make_number(sub_native(lhs, rhs));
|
|
124
159
|
}
|
|
125
160
|
inline AnyValue sub(const AnyValue &lhs, const double &rhs)
|
|
126
161
|
{
|
|
127
162
|
if (lhs.is_number())
|
|
128
163
|
return AnyValue::make_number(lhs.as_double() - rhs);
|
|
129
|
-
return AnyValue::make_number(
|
|
164
|
+
return AnyValue::make_number(sub_native(lhs, rhs));
|
|
130
165
|
}
|
|
131
166
|
inline AnyValue sub(const double &lhs, const AnyValue &rhs)
|
|
132
167
|
{
|
|
133
168
|
if (rhs.is_number())
|
|
134
169
|
return AnyValue::make_number(lhs - rhs.as_double());
|
|
135
|
-
return AnyValue::make_number(
|
|
170
|
+
return AnyValue::make_number(sub_native(lhs, rhs));
|
|
136
171
|
}
|
|
137
172
|
inline AnyValue sub(const double &lhs, const double &rhs) { return AnyValue::make_number(lhs - rhs); }
|
|
138
173
|
|
|
139
174
|
// Function mul
|
|
140
|
-
inline AnyValue mul(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
141
|
-
inline AnyValue mul(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(
|
|
142
|
-
inline AnyValue mul(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
143
|
-
inline AnyValue mul(const double &lhs, const double &rhs) { return AnyValue::make_number(
|
|
175
|
+
inline AnyValue mul(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(mul_native(lhs, rhs)); }
|
|
176
|
+
inline AnyValue mul(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(mul_native(lhs, rhs)); }
|
|
177
|
+
inline AnyValue mul(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(mul_native(lhs, rhs)); }
|
|
178
|
+
inline AnyValue mul(const double &lhs, const double &rhs) { return AnyValue::make_number(mul_native(lhs, rhs)); }
|
|
144
179
|
|
|
145
180
|
// Function div
|
|
146
|
-
inline AnyValue div(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
147
|
-
inline AnyValue div(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(
|
|
148
|
-
inline AnyValue div(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
149
|
-
inline AnyValue div(const double &lhs, const double &rhs) { return AnyValue::make_number(
|
|
181
|
+
inline AnyValue div(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(div_native(lhs, rhs)); }
|
|
182
|
+
inline AnyValue div(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(div_native(lhs, rhs)); }
|
|
183
|
+
inline AnyValue div(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(div_native(lhs, rhs)); }
|
|
184
|
+
inline AnyValue div(const double &lhs, const double &rhs) { return AnyValue::make_number(div_native(lhs, rhs)); }
|
|
150
185
|
|
|
151
186
|
// Function mod
|
|
152
|
-
inline AnyValue mod(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
153
|
-
inline AnyValue mod(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(
|
|
154
|
-
inline AnyValue mod(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
155
|
-
inline AnyValue mod(const double &lhs, const double &rhs) { return AnyValue::make_number(
|
|
187
|
+
inline AnyValue mod(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(mod_native(lhs, rhs)); }
|
|
188
|
+
inline AnyValue mod(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(mod_native(lhs, rhs)); }
|
|
189
|
+
inline AnyValue mod(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(mod_native(lhs, rhs)); }
|
|
190
|
+
inline AnyValue mod(const double &lhs, const double &rhs) { return AnyValue::make_number(mod_native(lhs, rhs)); }
|
|
156
191
|
|
|
157
192
|
// --- UNARY OPERATORS ---
|
|
158
193
|
inline AnyValue plus(const AnyValue &val)
|
|
@@ -173,10 +208,10 @@ namespace jspp
|
|
|
173
208
|
}
|
|
174
209
|
|
|
175
210
|
// --- EXPONENTIATION ---
|
|
176
|
-
inline AnyValue pow(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
177
|
-
inline AnyValue pow(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(
|
|
178
|
-
inline AnyValue pow(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
179
|
-
inline AnyValue pow(const double &lhs, const double &rhs) { return AnyValue::make_number(
|
|
211
|
+
inline AnyValue pow(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(pow_native(lhs, rhs)); }
|
|
212
|
+
inline AnyValue pow(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(pow_native(lhs, rhs)); }
|
|
213
|
+
inline AnyValue pow(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(pow_native(lhs, rhs)); }
|
|
214
|
+
inline AnyValue pow(const double &lhs, const double &rhs) { return AnyValue::make_number(pow_native(lhs, rhs)); }
|
|
180
215
|
|
|
181
216
|
// --- COMPARISON OPERATORS ---
|
|
182
217
|
|
|
@@ -186,122 +221,122 @@ namespace jspp
|
|
|
186
221
|
if (lhs.is_string() && rhs.is_string())
|
|
187
222
|
return AnyValue::make_boolean(lhs.as_string()->value < rhs.as_string()->value);
|
|
188
223
|
|
|
189
|
-
return AnyValue::make_boolean(
|
|
224
|
+
return AnyValue::make_boolean(less_than_native(lhs, rhs));
|
|
190
225
|
}
|
|
191
226
|
inline AnyValue less_than(const AnyValue &lhs, const double &rhs)
|
|
192
227
|
{
|
|
193
|
-
return AnyValue::make_boolean(
|
|
228
|
+
return AnyValue::make_boolean(less_than_native(lhs, rhs));
|
|
194
229
|
}
|
|
195
230
|
inline AnyValue less_than(const double &lhs, const AnyValue &rhs)
|
|
196
231
|
{
|
|
197
|
-
return AnyValue::make_boolean(
|
|
232
|
+
return AnyValue::make_boolean(less_than_native(lhs, rhs));
|
|
198
233
|
}
|
|
199
234
|
inline AnyValue less_than(const double &lhs, const double &rhs)
|
|
200
235
|
{
|
|
201
|
-
return AnyValue::make_boolean(
|
|
236
|
+
return AnyValue::make_boolean(less_than_native(lhs, rhs));
|
|
202
237
|
}
|
|
203
238
|
|
|
204
239
|
inline AnyValue greater_than(const AnyValue &lhs, const AnyValue &rhs) { return less_than(rhs, lhs); }
|
|
205
240
|
inline AnyValue greater_than(const AnyValue &lhs, const double &rhs) { return less_than(rhs, lhs); }
|
|
206
241
|
inline AnyValue greater_than(const double &lhs, const AnyValue &rhs) { return less_than(rhs, lhs); }
|
|
207
|
-
inline AnyValue greater_than(const double &lhs, const double &rhs) { return AnyValue::make_boolean(
|
|
242
|
+
inline AnyValue greater_than(const double &lhs, const double &rhs) { return AnyValue::make_boolean(greater_than_native(lhs, rhs)); }
|
|
208
243
|
|
|
209
244
|
inline AnyValue less_than_or_equal(const AnyValue &lhs, const AnyValue &rhs)
|
|
210
245
|
{
|
|
211
246
|
if (lhs.is_string() && rhs.is_string())
|
|
212
247
|
return AnyValue::make_boolean(lhs.as_string()->value <= rhs.as_string()->value);
|
|
213
|
-
return AnyValue::make_boolean(
|
|
248
|
+
return AnyValue::make_boolean(less_than_or_equal_native(lhs, rhs));
|
|
214
249
|
}
|
|
215
250
|
inline AnyValue less_than_or_equal(const AnyValue &lhs, const double &rhs)
|
|
216
251
|
{
|
|
217
|
-
return AnyValue::make_boolean(
|
|
252
|
+
return AnyValue::make_boolean(less_than_or_equal_native(lhs, rhs));
|
|
218
253
|
}
|
|
219
254
|
inline AnyValue less_than_or_equal(const double &lhs, const AnyValue &rhs)
|
|
220
255
|
{
|
|
221
|
-
return AnyValue::make_boolean(
|
|
256
|
+
return AnyValue::make_boolean(less_than_or_equal_native(lhs, rhs));
|
|
222
257
|
}
|
|
223
258
|
inline AnyValue less_than_or_equal(const double &lhs, const double &rhs)
|
|
224
259
|
{
|
|
225
|
-
return AnyValue::make_boolean(
|
|
260
|
+
return AnyValue::make_boolean(less_than_or_equal_native(lhs, rhs));
|
|
226
261
|
}
|
|
227
262
|
|
|
228
263
|
inline AnyValue greater_than_or_equal(const AnyValue &lhs, const AnyValue &rhs)
|
|
229
264
|
{
|
|
230
265
|
if (lhs.is_string() && rhs.is_string())
|
|
231
266
|
return AnyValue::make_boolean(lhs.as_string()->value >= rhs.as_string()->value);
|
|
232
|
-
return AnyValue::make_boolean(
|
|
267
|
+
return AnyValue::make_boolean(greater_than_or_equal_native(lhs, rhs));
|
|
233
268
|
}
|
|
234
269
|
inline AnyValue greater_than_or_equal(const AnyValue &lhs, const double &rhs)
|
|
235
270
|
{
|
|
236
|
-
return AnyValue::make_boolean(
|
|
271
|
+
return AnyValue::make_boolean(greater_than_or_equal_native(lhs, rhs));
|
|
237
272
|
}
|
|
238
273
|
inline AnyValue greater_than_or_equal(const double &lhs, const AnyValue &rhs)
|
|
239
274
|
{
|
|
240
|
-
return AnyValue::make_boolean(
|
|
275
|
+
return AnyValue::make_boolean(greater_than_or_equal_native(lhs, rhs));
|
|
241
276
|
}
|
|
242
277
|
inline AnyValue greater_than_or_equal(const double &lhs, const double &rhs)
|
|
243
278
|
{
|
|
244
|
-
return AnyValue::make_boolean(
|
|
279
|
+
return AnyValue::make_boolean(greater_than_or_equal_native(lhs, rhs));
|
|
245
280
|
}
|
|
246
281
|
|
|
247
282
|
// Equality ==
|
|
248
283
|
inline AnyValue equal(const AnyValue &lhs, const AnyValue &rhs)
|
|
249
284
|
{
|
|
250
|
-
return AnyValue::make_boolean(
|
|
285
|
+
return AnyValue::make_boolean(is_equal_to_native(lhs, rhs));
|
|
251
286
|
}
|
|
252
287
|
inline AnyValue equal(const AnyValue &lhs, const double &rhs)
|
|
253
288
|
{
|
|
254
289
|
if (lhs.is_number())
|
|
255
|
-
return AnyValue::make_boolean(
|
|
256
|
-
return AnyValue::make_boolean(
|
|
290
|
+
return AnyValue::make_boolean(equal_native(lhs.as_double(), rhs));
|
|
291
|
+
return AnyValue::make_boolean(is_equal_to_native(lhs, AnyValue::make_number(rhs)));
|
|
257
292
|
}
|
|
258
293
|
inline AnyValue equal(const double &lhs, const AnyValue &rhs)
|
|
259
294
|
{
|
|
260
295
|
if (rhs.is_number())
|
|
261
|
-
return AnyValue::make_boolean(
|
|
262
|
-
return AnyValue::make_boolean(
|
|
296
|
+
return AnyValue::make_boolean(equal_native(lhs, rhs.as_double()));
|
|
297
|
+
return AnyValue::make_boolean(is_equal_to_native(rhs, AnyValue::make_number(lhs)));
|
|
263
298
|
}
|
|
264
299
|
inline AnyValue equal(const double &lhs, const double &rhs)
|
|
265
300
|
{
|
|
266
|
-
return AnyValue::make_boolean(
|
|
301
|
+
return AnyValue::make_boolean(equal_native(lhs, rhs));
|
|
267
302
|
}
|
|
268
303
|
|
|
269
|
-
inline AnyValue not_equal(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_boolean(!
|
|
304
|
+
inline AnyValue not_equal(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_boolean(!is_equal_to_native(lhs, rhs)); }
|
|
270
305
|
inline AnyValue not_equal(const AnyValue &lhs, const double &rhs) { return AnyValue::make_boolean(!equal(lhs, rhs).as_boolean()); }
|
|
271
306
|
inline AnyValue not_equal(const double &lhs, const AnyValue &rhs) { return AnyValue::make_boolean(!equal(lhs, rhs).as_boolean()); }
|
|
272
|
-
inline AnyValue not_equal(const double &lhs, const double &rhs) { return AnyValue::make_boolean(
|
|
307
|
+
inline AnyValue not_equal(const double &lhs, const double &rhs) { return AnyValue::make_boolean(not_equal_native(lhs, rhs)); }
|
|
273
308
|
|
|
274
309
|
// --- BITWISE OPERATORS ---
|
|
275
|
-
inline AnyValue bitwise_xor(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
276
|
-
inline AnyValue bitwise_xor(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(
|
|
277
|
-
inline AnyValue bitwise_xor(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
278
|
-
inline AnyValue bitwise_xor(const double &lhs, const double &rhs) { return AnyValue::make_number(
|
|
310
|
+
inline AnyValue bitwise_xor(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(bitwise_xor_native(lhs, rhs)); }
|
|
311
|
+
inline AnyValue bitwise_xor(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(bitwise_xor_native(lhs, rhs)); }
|
|
312
|
+
inline AnyValue bitwise_xor(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(bitwise_xor_native(lhs, rhs)); }
|
|
313
|
+
inline AnyValue bitwise_xor(const double &lhs, const double &rhs) { return AnyValue::make_number(bitwise_xor_native(lhs, rhs)); }
|
|
279
314
|
|
|
280
|
-
inline AnyValue bitwise_and(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
281
|
-
inline AnyValue bitwise_and(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(
|
|
282
|
-
inline AnyValue bitwise_and(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
283
|
-
inline AnyValue bitwise_and(const double &lhs, const double &rhs) { return AnyValue::make_number(
|
|
315
|
+
inline AnyValue bitwise_and(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(bitwise_and_native(lhs, rhs)); }
|
|
316
|
+
inline AnyValue bitwise_and(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(bitwise_and_native(lhs, rhs)); }
|
|
317
|
+
inline AnyValue bitwise_and(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(bitwise_and_native(lhs, rhs)); }
|
|
318
|
+
inline AnyValue bitwise_and(const double &lhs, const double &rhs) { return AnyValue::make_number(bitwise_and_native(lhs, rhs)); }
|
|
284
319
|
|
|
285
|
-
inline AnyValue bitwise_or(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
286
|
-
inline AnyValue bitwise_or(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(
|
|
287
|
-
inline AnyValue bitwise_or(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
288
|
-
inline AnyValue bitwise_or(const double &lhs, const double &rhs) { return AnyValue::make_number(
|
|
320
|
+
inline AnyValue bitwise_or(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(bitwise_or_native(lhs, rhs)); }
|
|
321
|
+
inline AnyValue bitwise_or(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(bitwise_or_native(lhs, rhs)); }
|
|
322
|
+
inline AnyValue bitwise_or(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(bitwise_or_native(lhs, rhs)); }
|
|
323
|
+
inline AnyValue bitwise_or(const double &lhs, const double &rhs) { return AnyValue::make_number(bitwise_or_native(lhs, rhs)); }
|
|
289
324
|
|
|
290
325
|
// --- SHIFT OPERATORS ---
|
|
291
|
-
inline AnyValue left_shift(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
292
|
-
inline AnyValue left_shift(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(
|
|
293
|
-
inline AnyValue left_shift(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
294
|
-
inline AnyValue left_shift(const double &lhs, const double &rhs) { return AnyValue::make_number(
|
|
326
|
+
inline AnyValue left_shift(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(left_shift_native(lhs, rhs)); }
|
|
327
|
+
inline AnyValue left_shift(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(left_shift_native(lhs, rhs)); }
|
|
328
|
+
inline AnyValue left_shift(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(left_shift_native(lhs, rhs)); }
|
|
329
|
+
inline AnyValue left_shift(const double &lhs, const double &rhs) { return AnyValue::make_number(left_shift_native(lhs, rhs)); }
|
|
295
330
|
|
|
296
|
-
inline AnyValue right_shift(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
297
|
-
inline AnyValue right_shift(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(
|
|
298
|
-
inline AnyValue right_shift(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
299
|
-
inline AnyValue right_shift(const double &lhs, const double &rhs) { return AnyValue::make_number(
|
|
331
|
+
inline AnyValue right_shift(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(right_shift_native(lhs, rhs)); }
|
|
332
|
+
inline AnyValue right_shift(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(right_shift_native(lhs, rhs)); }
|
|
333
|
+
inline AnyValue right_shift(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(right_shift_native(lhs, rhs)); }
|
|
334
|
+
inline AnyValue right_shift(const double &lhs, const double &rhs) { return AnyValue::make_number(right_shift_native(lhs, rhs)); }
|
|
300
335
|
|
|
301
|
-
inline AnyValue unsigned_right_shift(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
302
|
-
inline AnyValue unsigned_right_shift(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(
|
|
303
|
-
inline AnyValue unsigned_right_shift(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
304
|
-
inline AnyValue unsigned_right_shift(const double &lhs, const double &rhs) { return AnyValue::make_number(
|
|
336
|
+
inline AnyValue unsigned_right_shift(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(unsigned_right_shift_native(lhs, rhs)); }
|
|
337
|
+
inline AnyValue unsigned_right_shift(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(unsigned_right_shift_native(lhs, rhs)); }
|
|
338
|
+
inline AnyValue unsigned_right_shift(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(unsigned_right_shift_native(lhs, rhs)); }
|
|
339
|
+
inline AnyValue unsigned_right_shift(const double &lhs, const double &rhs) { return AnyValue::make_number(unsigned_right_shift_native(lhs, rhs)); }
|
|
305
340
|
|
|
306
341
|
// --- LOGICAL SHORT-CIRCUITING HELPERS ---
|
|
307
342
|
inline AnyValue logical_and(const AnyValue &lhs, const AnyValue &rhs)
|
|
@@ -349,4 +384,4 @@ namespace jspp
|
|
|
349
384
|
return lhs;
|
|
350
385
|
return rhs;
|
|
351
386
|
}
|
|
352
|
-
}
|
|
387
|
+
}
|