@ugo-studio/jspp 0.3.0 → 0.3.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/LICENSE +25 -25
- package/README.md +20 -12
- package/dist/cli/args.js +22 -0
- package/dist/cli/compiler.js +53 -0
- package/dist/cli/index.js +43 -107
- 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 +59 -0
- package/dist/cli/wasm.js +70 -0
- package/dist/index.js +17 -6
- package/dist/{analysis → interpreter/analysis}/scope.js +38 -3
- package/dist/{analysis → interpreter/analysis}/typeAnalyzer.js +563 -28
- package/dist/{core → interpreter/core}/codegen/class-handlers.js +1 -1
- package/dist/{core → interpreter/core}/codegen/control-flow-handlers.js +12 -11
- package/dist/{core → interpreter/core}/codegen/declaration-handlers.js +28 -9
- package/dist/{core → interpreter/core}/codegen/destructuring-handlers.js +9 -4
- package/dist/{core → interpreter/core}/codegen/expression-handlers.js +82 -88
- package/dist/{core → interpreter/core}/codegen/function-handlers.js +159 -46
- package/dist/{core → interpreter/core}/codegen/helpers.js +170 -25
- 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 +47 -7
- package/package.json +6 -4
- package/scripts/precompile-headers.ts +293 -50
- package/scripts/setup-compiler.ts +63 -63
- package/scripts/setup-emsdk.ts +114 -0
- package/src/prelude/any_value.cpp +888 -0
- package/src/prelude/any_value.hpp +29 -24
- package/src/prelude/{exception_helpers.hpp → exception.cpp} +53 -53
- package/src/prelude/exception.hpp +27 -27
- package/src/prelude/iterator_instantiations.hpp +10 -0
- package/src/prelude/{index.hpp → jspp.hpp} +13 -17
- package/src/prelude/library/array.cpp +191 -0
- package/src/prelude/library/array.hpp +5 -178
- package/src/prelude/library/boolean.cpp +30 -0
- package/src/prelude/library/boolean.hpp +14 -0
- package/src/prelude/library/console.cpp +125 -0
- package/src/prelude/library/console.hpp +9 -97
- package/src/prelude/library/error.cpp +100 -0
- package/src/prelude/library/error.hpp +8 -108
- package/src/prelude/library/function.cpp +69 -0
- package/src/prelude/library/function.hpp +6 -5
- package/src/prelude/library/global.cpp +98 -0
- package/src/prelude/library/global.hpp +12 -28
- package/src/prelude/library/global_usings.hpp +15 -0
- package/src/prelude/library/math.cpp +261 -0
- package/src/prelude/library/math.hpp +8 -288
- package/src/prelude/library/object.cpp +379 -0
- package/src/prelude/library/object.hpp +5 -267
- package/src/prelude/library/performance.cpp +21 -0
- package/src/prelude/library/performance.hpp +5 -20
- package/src/prelude/library/process.cpp +38 -0
- package/src/prelude/library/process.hpp +3 -31
- package/src/prelude/library/promise.cpp +131 -0
- package/src/prelude/library/promise.hpp +5 -116
- package/src/prelude/library/symbol.cpp +56 -0
- package/src/prelude/library/symbol.hpp +5 -46
- package/src/prelude/library/timer.cpp +88 -0
- package/src/prelude/library/timer.hpp +11 -87
- package/src/prelude/runtime.cpp +19 -0
- package/src/prelude/types.hpp +26 -20
- package/src/prelude/utils/access.hpp +123 -32
- package/src/prelude/utils/assignment_operators.hpp +119 -99
- package/src/prelude/utils/log_any_value/array.hpp +61 -40
- package/src/prelude/utils/log_any_value/function.hpp +39 -39
- package/src/prelude/utils/log_any_value/log_any_value.hpp +1 -1
- package/src/prelude/utils/log_any_value/object.hpp +60 -3
- package/src/prelude/utils/log_any_value/primitives.hpp +1 -1
- package/src/prelude/utils/operators.hpp +109 -94
- package/src/prelude/utils/operators_native.hpp +349 -0
- package/src/prelude/utils/well_known_symbols.hpp +24 -24
- package/src/prelude/values/array.cpp +1399 -0
- package/src/prelude/values/array.hpp +4 -0
- package/src/prelude/values/async_iterator.cpp +251 -0
- package/src/prelude/values/async_iterator.hpp +60 -32
- package/src/prelude/values/boolean.cpp +64 -0
- package/src/prelude/values/function.cpp +262 -0
- package/src/prelude/values/function.hpp +10 -30
- package/src/prelude/values/iterator.cpp +309 -0
- package/src/prelude/values/iterator.hpp +33 -64
- package/src/prelude/values/number.cpp +221 -0
- package/src/prelude/values/object.cpp +200 -0
- package/src/prelude/values/object.hpp +4 -0
- package/src/prelude/values/promise.cpp +479 -0
- package/src/prelude/values/promise.hpp +9 -2
- package/src/prelude/values/prototypes/array.hpp +46 -1348
- package/src/prelude/values/prototypes/async_iterator.hpp +19 -61
- package/src/prelude/values/prototypes/boolean.hpp +24 -0
- package/src/prelude/values/prototypes/function.hpp +7 -46
- package/src/prelude/values/prototypes/iterator.hpp +15 -191
- package/src/prelude/values/prototypes/number.hpp +30 -210
- package/src/prelude/values/prototypes/object.hpp +7 -23
- package/src/prelude/values/prototypes/promise.hpp +8 -186
- package/src/prelude/values/prototypes/string.hpp +28 -553
- package/src/prelude/values/prototypes/symbol.hpp +9 -70
- package/src/prelude/values/shape.hpp +52 -52
- package/src/prelude/values/string.cpp +485 -0
- package/src/prelude/values/symbol.cpp +89 -0
- package/src/prelude/values/symbol.hpp +101 -101
- 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 -86
- package/src/prelude/any_value_access.hpp +0 -170
- package/src/prelude/any_value_defines.hpp +0 -190
- package/src/prelude/any_value_helpers.hpp +0 -374
- package/src/prelude/utils/operators_primitive.hpp +0 -337
- package/src/prelude/values/helpers/array.hpp +0 -199
- package/src/prelude/values/helpers/async_iterator.hpp +0 -275
- package/src/prelude/values/helpers/function.hpp +0 -109
- package/src/prelude/values/helpers/iterator.hpp +0 -145
- package/src/prelude/values/helpers/object.hpp +0 -104
- package/src/prelude/values/helpers/promise.hpp +0 -254
- package/src/prelude/values/helpers/string.hpp +0 -37
- package/src/prelude/values/helpers/symbol.hpp +0 -21
- /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,10 +2,10 @@
|
|
|
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
|
|
|
@@ -14,73 +14,73 @@ namespace jspp
|
|
|
14
14
|
// Operator === (returns boolean wrapped in AnyValue)
|
|
15
15
|
inline const AnyValue is_strictly_equal_to(const AnyValue &lhs, const double &rhs) noexcept
|
|
16
16
|
{
|
|
17
|
-
return AnyValue::make_boolean(
|
|
17
|
+
return AnyValue::make_boolean(is_strictly_equal_to_native(lhs, rhs));
|
|
18
18
|
}
|
|
19
19
|
inline const AnyValue is_strictly_equal_to(const double &lhs, const AnyValue &rhs) noexcept
|
|
20
20
|
{
|
|
21
|
-
return AnyValue::make_boolean(
|
|
21
|
+
return AnyValue::make_boolean(is_strictly_equal_to_native(lhs, rhs));
|
|
22
22
|
}
|
|
23
23
|
inline const AnyValue is_strictly_equal_to(const double &lhs, const double &rhs) noexcept
|
|
24
24
|
{
|
|
25
|
-
return AnyValue::make_boolean(
|
|
25
|
+
return AnyValue::make_boolean(is_strictly_equal_to_native(lhs, rhs));
|
|
26
26
|
}
|
|
27
27
|
inline const AnyValue is_strictly_equal_to(const AnyValue &lhs, const AnyValue &rhs) noexcept
|
|
28
28
|
{
|
|
29
|
-
return AnyValue::make_boolean(
|
|
29
|
+
return AnyValue::make_boolean(is_strictly_equal_to_native(lhs, rhs));
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
// Operator == (returns boolean wrapped in AnyValue)
|
|
33
33
|
inline const AnyValue is_equal_to(const AnyValue &lhs, const double &rhs) noexcept
|
|
34
34
|
{
|
|
35
|
-
return AnyValue::make_boolean(
|
|
35
|
+
return AnyValue::make_boolean(is_equal_to_native(lhs, rhs));
|
|
36
36
|
}
|
|
37
37
|
inline const AnyValue is_equal_to(const double &lhs, const AnyValue &rhs) noexcept
|
|
38
38
|
{
|
|
39
|
-
return AnyValue::make_boolean(
|
|
39
|
+
return AnyValue::make_boolean(is_equal_to_native(lhs, rhs));
|
|
40
40
|
}
|
|
41
41
|
inline const AnyValue is_equal_to(const double &lhs, const double &rhs) noexcept
|
|
42
42
|
{
|
|
43
|
-
return AnyValue::make_boolean(
|
|
43
|
+
return AnyValue::make_boolean(is_equal_to_native(lhs, rhs));
|
|
44
44
|
}
|
|
45
45
|
inline const AnyValue is_equal_to(const AnyValue &lhs, const AnyValue &rhs) noexcept
|
|
46
46
|
{
|
|
47
|
-
return AnyValue::make_boolean(
|
|
47
|
+
return AnyValue::make_boolean(is_equal_to_native(lhs, rhs));
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
// Operator !== (returns boolean wrapped in AnyValue)
|
|
51
51
|
inline const AnyValue not_strictly_equal_to(const AnyValue &lhs, const double &rhs) noexcept
|
|
52
52
|
{
|
|
53
|
-
return AnyValue::make_boolean(!
|
|
53
|
+
return AnyValue::make_boolean(!is_strictly_equal_to_native(lhs, rhs));
|
|
54
54
|
}
|
|
55
55
|
inline const AnyValue not_strictly_equal_to(const double &lhs, const AnyValue &rhs) noexcept
|
|
56
56
|
{
|
|
57
|
-
return AnyValue::make_boolean(!
|
|
57
|
+
return AnyValue::make_boolean(!is_strictly_equal_to_native(lhs, rhs));
|
|
58
58
|
}
|
|
59
59
|
inline const AnyValue not_strictly_equal_to(const double &lhs, const double &rhs) noexcept
|
|
60
60
|
{
|
|
61
|
-
return AnyValue::make_boolean(!
|
|
61
|
+
return AnyValue::make_boolean(!is_strictly_equal_to_native(lhs, rhs));
|
|
62
62
|
}
|
|
63
63
|
inline const AnyValue not_strictly_equal_to(const AnyValue &lhs, const AnyValue &rhs) noexcept
|
|
64
64
|
{
|
|
65
|
-
return AnyValue::make_boolean(!
|
|
65
|
+
return AnyValue::make_boolean(!is_strictly_equal_to_native(lhs, rhs));
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
// Operator != (returns boolean wrapped in AnyValue)
|
|
69
69
|
inline const AnyValue not_equal_to(const AnyValue &lhs, const double &rhs) noexcept
|
|
70
70
|
{
|
|
71
|
-
return AnyValue::make_boolean(!
|
|
71
|
+
return AnyValue::make_boolean(!is_equal_to_native(lhs, rhs));
|
|
72
72
|
}
|
|
73
73
|
inline const AnyValue not_equal_to(const double &lhs, const AnyValue &rhs) noexcept
|
|
74
74
|
{
|
|
75
|
-
return AnyValue::make_boolean(!
|
|
75
|
+
return AnyValue::make_boolean(!is_equal_to_native(lhs, rhs));
|
|
76
76
|
}
|
|
77
77
|
inline const AnyValue not_equal_to(const double &lhs, const double &rhs) noexcept
|
|
78
78
|
{
|
|
79
|
-
return AnyValue::make_boolean(!
|
|
79
|
+
return AnyValue::make_boolean(!is_equal_to_native(lhs, rhs));
|
|
80
80
|
}
|
|
81
81
|
inline const AnyValue not_equal_to(const AnyValue &lhs, const AnyValue &rhs) noexcept
|
|
82
82
|
{
|
|
83
|
-
return AnyValue::make_boolean(!
|
|
83
|
+
return AnyValue::make_boolean(!is_equal_to_native(lhs, rhs));
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
// --- BASIC ARITHMETIC ---
|
|
@@ -89,55 +89,70 @@ namespace jspp
|
|
|
89
89
|
inline AnyValue add(const AnyValue &lhs, const AnyValue &rhs)
|
|
90
90
|
{
|
|
91
91
|
if (lhs.is_number() && rhs.is_number())
|
|
92
|
-
return AnyValue::make_number(
|
|
92
|
+
return AnyValue::make_number(lhs.as_double() + rhs.as_double());
|
|
93
93
|
if (lhs.is_string() || rhs.is_string())
|
|
94
94
|
return AnyValue::make_string(lhs.to_std_string() + rhs.to_std_string());
|
|
95
|
-
return AnyValue::make_number(
|
|
95
|
+
return AnyValue::make_number(add_native(lhs, rhs));
|
|
96
96
|
}
|
|
97
97
|
inline AnyValue add(const AnyValue &lhs, const double &rhs)
|
|
98
98
|
{
|
|
99
99
|
if (lhs.is_number())
|
|
100
|
-
return AnyValue::make_number(
|
|
100
|
+
return AnyValue::make_number(lhs.as_double() + rhs);
|
|
101
101
|
if (lhs.is_string())
|
|
102
|
-
return AnyValue::make_string(lhs.to_std_string() +
|
|
103
|
-
return AnyValue::make_number(
|
|
102
|
+
return AnyValue::make_string(lhs.to_std_string() + JsNumber::to_std_string(rhs));
|
|
103
|
+
return AnyValue::make_number(add_native(lhs, rhs));
|
|
104
104
|
}
|
|
105
105
|
inline AnyValue add(const double &lhs, const AnyValue &rhs)
|
|
106
106
|
{
|
|
107
107
|
if (rhs.is_number())
|
|
108
|
-
return AnyValue::make_number(
|
|
108
|
+
return AnyValue::make_number(lhs + rhs.as_double());
|
|
109
109
|
if (rhs.is_string())
|
|
110
|
-
return AnyValue::make_string(
|
|
111
|
-
return AnyValue::make_number(
|
|
110
|
+
return AnyValue::make_string(JsNumber::to_std_string(lhs) + rhs.to_std_string());
|
|
111
|
+
return AnyValue::make_number(add_native(lhs, rhs));
|
|
112
112
|
}
|
|
113
113
|
inline AnyValue add(const double &lhs, const double &rhs)
|
|
114
114
|
{
|
|
115
|
-
return AnyValue::make_number(
|
|
115
|
+
return AnyValue::make_number(lhs + rhs);
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
// Function sub
|
|
119
|
-
inline AnyValue sub(const AnyValue &lhs, const AnyValue &rhs)
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
119
|
+
inline AnyValue sub(const AnyValue &lhs, const AnyValue &rhs)
|
|
120
|
+
{
|
|
121
|
+
if (lhs.is_number() && rhs.is_number())
|
|
122
|
+
return AnyValue::make_number(lhs.as_double() - rhs.as_double());
|
|
123
|
+
return AnyValue::make_number(sub_native(lhs, rhs));
|
|
124
|
+
}
|
|
125
|
+
inline AnyValue sub(const AnyValue &lhs, const double &rhs)
|
|
126
|
+
{
|
|
127
|
+
if (lhs.is_number())
|
|
128
|
+
return AnyValue::make_number(lhs.as_double() - rhs);
|
|
129
|
+
return AnyValue::make_number(sub_native(lhs, rhs));
|
|
130
|
+
}
|
|
131
|
+
inline AnyValue sub(const double &lhs, const AnyValue &rhs)
|
|
132
|
+
{
|
|
133
|
+
if (rhs.is_number())
|
|
134
|
+
return AnyValue::make_number(lhs - rhs.as_double());
|
|
135
|
+
return AnyValue::make_number(sub_native(lhs, rhs));
|
|
136
|
+
}
|
|
137
|
+
inline AnyValue sub(const double &lhs, const double &rhs) { return AnyValue::make_number(lhs - rhs); }
|
|
123
138
|
|
|
124
139
|
// Function mul
|
|
125
|
-
inline AnyValue mul(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
126
|
-
inline AnyValue mul(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(
|
|
127
|
-
inline AnyValue mul(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
128
|
-
inline AnyValue mul(const double &lhs, const double &rhs) { return AnyValue::make_number(
|
|
140
|
+
inline AnyValue mul(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(mul_native(lhs, rhs)); }
|
|
141
|
+
inline AnyValue mul(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(mul_native(lhs, rhs)); }
|
|
142
|
+
inline AnyValue mul(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(mul_native(lhs, rhs)); }
|
|
143
|
+
inline AnyValue mul(const double &lhs, const double &rhs) { return AnyValue::make_number(mul_native(lhs, rhs)); }
|
|
129
144
|
|
|
130
145
|
// Function div
|
|
131
|
-
inline AnyValue div(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
132
|
-
inline AnyValue div(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(
|
|
133
|
-
inline AnyValue div(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
134
|
-
inline AnyValue div(const double &lhs, const double &rhs) { return AnyValue::make_number(
|
|
146
|
+
inline AnyValue div(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(div_native(lhs, rhs)); }
|
|
147
|
+
inline AnyValue div(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(div_native(lhs, rhs)); }
|
|
148
|
+
inline AnyValue div(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(div_native(lhs, rhs)); }
|
|
149
|
+
inline AnyValue div(const double &lhs, const double &rhs) { return AnyValue::make_number(div_native(lhs, rhs)); }
|
|
135
150
|
|
|
136
151
|
// Function mod
|
|
137
|
-
inline AnyValue mod(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
138
|
-
inline AnyValue mod(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(
|
|
139
|
-
inline AnyValue mod(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
140
|
-
inline AnyValue mod(const double &lhs, const double &rhs) { return AnyValue::make_number(
|
|
152
|
+
inline AnyValue mod(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(mod_native(lhs, rhs)); }
|
|
153
|
+
inline AnyValue mod(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(mod_native(lhs, rhs)); }
|
|
154
|
+
inline AnyValue mod(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(mod_native(lhs, rhs)); }
|
|
155
|
+
inline AnyValue mod(const double &lhs, const double &rhs) { return AnyValue::make_number(mod_native(lhs, rhs)); }
|
|
141
156
|
|
|
142
157
|
// --- UNARY OPERATORS ---
|
|
143
158
|
inline AnyValue plus(const AnyValue &val)
|
|
@@ -158,10 +173,10 @@ namespace jspp
|
|
|
158
173
|
}
|
|
159
174
|
|
|
160
175
|
// --- EXPONENTIATION ---
|
|
161
|
-
inline AnyValue pow(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
162
|
-
inline AnyValue pow(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(
|
|
163
|
-
inline AnyValue pow(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
164
|
-
inline AnyValue pow(const double &lhs, const double &rhs) { return AnyValue::make_number(
|
|
176
|
+
inline AnyValue pow(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(pow_native(lhs, rhs)); }
|
|
177
|
+
inline AnyValue pow(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(pow_native(lhs, rhs)); }
|
|
178
|
+
inline AnyValue pow(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(pow_native(lhs, rhs)); }
|
|
179
|
+
inline AnyValue pow(const double &lhs, const double &rhs) { return AnyValue::make_number(pow_native(lhs, rhs)); }
|
|
165
180
|
|
|
166
181
|
// --- COMPARISON OPERATORS ---
|
|
167
182
|
|
|
@@ -171,122 +186,122 @@ namespace jspp
|
|
|
171
186
|
if (lhs.is_string() && rhs.is_string())
|
|
172
187
|
return AnyValue::make_boolean(lhs.as_string()->value < rhs.as_string()->value);
|
|
173
188
|
|
|
174
|
-
return AnyValue::make_boolean(
|
|
189
|
+
return AnyValue::make_boolean(less_than_native(lhs, rhs));
|
|
175
190
|
}
|
|
176
191
|
inline AnyValue less_than(const AnyValue &lhs, const double &rhs)
|
|
177
192
|
{
|
|
178
|
-
return AnyValue::make_boolean(
|
|
193
|
+
return AnyValue::make_boolean(less_than_native(lhs, rhs));
|
|
179
194
|
}
|
|
180
195
|
inline AnyValue less_than(const double &lhs, const AnyValue &rhs)
|
|
181
196
|
{
|
|
182
|
-
return AnyValue::make_boolean(
|
|
197
|
+
return AnyValue::make_boolean(less_than_native(lhs, rhs));
|
|
183
198
|
}
|
|
184
199
|
inline AnyValue less_than(const double &lhs, const double &rhs)
|
|
185
200
|
{
|
|
186
|
-
return AnyValue::make_boolean(
|
|
201
|
+
return AnyValue::make_boolean(less_than_native(lhs, rhs));
|
|
187
202
|
}
|
|
188
203
|
|
|
189
204
|
inline AnyValue greater_than(const AnyValue &lhs, const AnyValue &rhs) { return less_than(rhs, lhs); }
|
|
190
205
|
inline AnyValue greater_than(const AnyValue &lhs, const double &rhs) { return less_than(rhs, lhs); }
|
|
191
206
|
inline AnyValue greater_than(const double &lhs, const AnyValue &rhs) { return less_than(rhs, lhs); }
|
|
192
|
-
inline AnyValue greater_than(const double &lhs, const double &rhs) { return AnyValue::make_boolean(
|
|
207
|
+
inline AnyValue greater_than(const double &lhs, const double &rhs) { return AnyValue::make_boolean(greater_than_native(lhs, rhs)); }
|
|
193
208
|
|
|
194
209
|
inline AnyValue less_than_or_equal(const AnyValue &lhs, const AnyValue &rhs)
|
|
195
210
|
{
|
|
196
211
|
if (lhs.is_string() && rhs.is_string())
|
|
197
|
-
|
|
198
|
-
return AnyValue::make_boolean(
|
|
212
|
+
return AnyValue::make_boolean(lhs.as_string()->value <= rhs.as_string()->value);
|
|
213
|
+
return AnyValue::make_boolean(less_than_or_equal_native(lhs, rhs));
|
|
199
214
|
}
|
|
200
215
|
inline AnyValue less_than_or_equal(const AnyValue &lhs, const double &rhs)
|
|
201
216
|
{
|
|
202
|
-
return AnyValue::make_boolean(
|
|
217
|
+
return AnyValue::make_boolean(less_than_or_equal_native(lhs, rhs));
|
|
203
218
|
}
|
|
204
219
|
inline AnyValue less_than_or_equal(const double &lhs, const AnyValue &rhs)
|
|
205
220
|
{
|
|
206
|
-
return AnyValue::make_boolean(
|
|
221
|
+
return AnyValue::make_boolean(less_than_or_equal_native(lhs, rhs));
|
|
207
222
|
}
|
|
208
223
|
inline AnyValue less_than_or_equal(const double &lhs, const double &rhs)
|
|
209
224
|
{
|
|
210
|
-
return AnyValue::make_boolean(
|
|
225
|
+
return AnyValue::make_boolean(less_than_or_equal_native(lhs, rhs));
|
|
211
226
|
}
|
|
212
227
|
|
|
213
228
|
inline AnyValue greater_than_or_equal(const AnyValue &lhs, const AnyValue &rhs)
|
|
214
229
|
{
|
|
215
230
|
if (lhs.is_string() && rhs.is_string())
|
|
216
|
-
|
|
217
|
-
return AnyValue::make_boolean(
|
|
231
|
+
return AnyValue::make_boolean(lhs.as_string()->value >= rhs.as_string()->value);
|
|
232
|
+
return AnyValue::make_boolean(greater_than_or_equal_native(lhs, rhs));
|
|
218
233
|
}
|
|
219
234
|
inline AnyValue greater_than_or_equal(const AnyValue &lhs, const double &rhs)
|
|
220
235
|
{
|
|
221
|
-
return AnyValue::make_boolean(
|
|
236
|
+
return AnyValue::make_boolean(greater_than_or_equal_native(lhs, rhs));
|
|
222
237
|
}
|
|
223
238
|
inline AnyValue greater_than_or_equal(const double &lhs, const AnyValue &rhs)
|
|
224
239
|
{
|
|
225
|
-
return AnyValue::make_boolean(
|
|
240
|
+
return AnyValue::make_boolean(greater_than_or_equal_native(lhs, rhs));
|
|
226
241
|
}
|
|
227
242
|
inline AnyValue greater_than_or_equal(const double &lhs, const double &rhs)
|
|
228
243
|
{
|
|
229
|
-
return AnyValue::make_boolean(
|
|
244
|
+
return AnyValue::make_boolean(greater_than_or_equal_native(lhs, rhs));
|
|
230
245
|
}
|
|
231
246
|
|
|
232
247
|
// Equality ==
|
|
233
248
|
inline AnyValue equal(const AnyValue &lhs, const AnyValue &rhs)
|
|
234
249
|
{
|
|
235
|
-
return AnyValue::make_boolean(
|
|
250
|
+
return AnyValue::make_boolean(is_equal_to_native(lhs, rhs));
|
|
236
251
|
}
|
|
237
252
|
inline AnyValue equal(const AnyValue &lhs, const double &rhs)
|
|
238
253
|
{
|
|
239
254
|
if (lhs.is_number())
|
|
240
|
-
return AnyValue::make_boolean(
|
|
241
|
-
return AnyValue::make_boolean(
|
|
255
|
+
return AnyValue::make_boolean(equal_native(lhs.as_double(), rhs));
|
|
256
|
+
return AnyValue::make_boolean(is_equal_to_native(lhs, AnyValue::make_number(rhs)));
|
|
242
257
|
}
|
|
243
258
|
inline AnyValue equal(const double &lhs, const AnyValue &rhs)
|
|
244
259
|
{
|
|
245
260
|
if (rhs.is_number())
|
|
246
|
-
return AnyValue::make_boolean(
|
|
247
|
-
return AnyValue::make_boolean(
|
|
261
|
+
return AnyValue::make_boolean(equal_native(lhs, rhs.as_double()));
|
|
262
|
+
return AnyValue::make_boolean(is_equal_to_native(rhs, AnyValue::make_number(lhs)));
|
|
248
263
|
}
|
|
249
264
|
inline AnyValue equal(const double &lhs, const double &rhs)
|
|
250
265
|
{
|
|
251
|
-
return AnyValue::make_boolean(
|
|
266
|
+
return AnyValue::make_boolean(equal_native(lhs, rhs));
|
|
252
267
|
}
|
|
253
268
|
|
|
254
|
-
inline AnyValue not_equal(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_boolean(!
|
|
269
|
+
inline AnyValue not_equal(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_boolean(!is_equal_to_native(lhs, rhs)); }
|
|
255
270
|
inline AnyValue not_equal(const AnyValue &lhs, const double &rhs) { return AnyValue::make_boolean(!equal(lhs, rhs).as_boolean()); }
|
|
256
271
|
inline AnyValue not_equal(const double &lhs, const AnyValue &rhs) { return AnyValue::make_boolean(!equal(lhs, rhs).as_boolean()); }
|
|
257
|
-
inline AnyValue not_equal(const double &lhs, const double &rhs) { return AnyValue::make_boolean(
|
|
272
|
+
inline AnyValue not_equal(const double &lhs, const double &rhs) { return AnyValue::make_boolean(not_equal_native(lhs, rhs)); }
|
|
258
273
|
|
|
259
274
|
// --- BITWISE OPERATORS ---
|
|
260
|
-
inline AnyValue bitwise_xor(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
261
|
-
inline AnyValue bitwise_xor(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(
|
|
262
|
-
inline AnyValue bitwise_xor(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
263
|
-
inline AnyValue bitwise_xor(const double &lhs, const double &rhs) { return AnyValue::make_number(
|
|
275
|
+
inline AnyValue bitwise_xor(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(bitwise_xor_native(lhs, rhs)); }
|
|
276
|
+
inline AnyValue bitwise_xor(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(bitwise_xor_native(lhs, rhs)); }
|
|
277
|
+
inline AnyValue bitwise_xor(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(bitwise_xor_native(lhs, rhs)); }
|
|
278
|
+
inline AnyValue bitwise_xor(const double &lhs, const double &rhs) { return AnyValue::make_number(bitwise_xor_native(lhs, rhs)); }
|
|
264
279
|
|
|
265
|
-
inline AnyValue bitwise_and(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
266
|
-
inline AnyValue bitwise_and(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(
|
|
267
|
-
inline AnyValue bitwise_and(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
268
|
-
inline AnyValue bitwise_and(const double &lhs, const double &rhs) { return AnyValue::make_number(
|
|
280
|
+
inline AnyValue bitwise_and(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(bitwise_and_native(lhs, rhs)); }
|
|
281
|
+
inline AnyValue bitwise_and(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(bitwise_and_native(lhs, rhs)); }
|
|
282
|
+
inline AnyValue bitwise_and(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(bitwise_and_native(lhs, rhs)); }
|
|
283
|
+
inline AnyValue bitwise_and(const double &lhs, const double &rhs) { return AnyValue::make_number(bitwise_and_native(lhs, rhs)); }
|
|
269
284
|
|
|
270
|
-
inline AnyValue bitwise_or(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
271
|
-
inline AnyValue bitwise_or(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(
|
|
272
|
-
inline AnyValue bitwise_or(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
273
|
-
inline AnyValue bitwise_or(const double &lhs, const double &rhs) { return AnyValue::make_number(
|
|
285
|
+
inline AnyValue bitwise_or(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(bitwise_or_native(lhs, rhs)); }
|
|
286
|
+
inline AnyValue bitwise_or(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(bitwise_or_native(lhs, rhs)); }
|
|
287
|
+
inline AnyValue bitwise_or(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(bitwise_or_native(lhs, rhs)); }
|
|
288
|
+
inline AnyValue bitwise_or(const double &lhs, const double &rhs) { return AnyValue::make_number(bitwise_or_native(lhs, rhs)); }
|
|
274
289
|
|
|
275
290
|
// --- SHIFT OPERATORS ---
|
|
276
|
-
inline AnyValue left_shift(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
277
|
-
inline AnyValue left_shift(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(
|
|
278
|
-
inline AnyValue left_shift(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
279
|
-
inline AnyValue left_shift(const double &lhs, const double &rhs) { return AnyValue::make_number(
|
|
291
|
+
inline AnyValue left_shift(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(left_shift_native(lhs, rhs)); }
|
|
292
|
+
inline AnyValue left_shift(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(left_shift_native(lhs, rhs)); }
|
|
293
|
+
inline AnyValue left_shift(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(left_shift_native(lhs, rhs)); }
|
|
294
|
+
inline AnyValue left_shift(const double &lhs, const double &rhs) { return AnyValue::make_number(left_shift_native(lhs, rhs)); }
|
|
280
295
|
|
|
281
|
-
inline AnyValue right_shift(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
282
|
-
inline AnyValue right_shift(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(
|
|
283
|
-
inline AnyValue right_shift(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
284
|
-
inline AnyValue right_shift(const double &lhs, const double &rhs) { return AnyValue::make_number(
|
|
296
|
+
inline AnyValue right_shift(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(right_shift_native(lhs, rhs)); }
|
|
297
|
+
inline AnyValue right_shift(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(right_shift_native(lhs, rhs)); }
|
|
298
|
+
inline AnyValue right_shift(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(right_shift_native(lhs, rhs)); }
|
|
299
|
+
inline AnyValue right_shift(const double &lhs, const double &rhs) { return AnyValue::make_number(right_shift_native(lhs, rhs)); }
|
|
285
300
|
|
|
286
|
-
inline AnyValue unsigned_right_shift(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
287
|
-
inline AnyValue unsigned_right_shift(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(
|
|
288
|
-
inline AnyValue unsigned_right_shift(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(
|
|
289
|
-
inline AnyValue unsigned_right_shift(const double &lhs, const double &rhs) { return AnyValue::make_number(
|
|
301
|
+
inline AnyValue unsigned_right_shift(const AnyValue &lhs, const AnyValue &rhs) { return AnyValue::make_number(unsigned_right_shift_native(lhs, rhs)); }
|
|
302
|
+
inline AnyValue unsigned_right_shift(const AnyValue &lhs, const double &rhs) { return AnyValue::make_number(unsigned_right_shift_native(lhs, rhs)); }
|
|
303
|
+
inline AnyValue unsigned_right_shift(const double &lhs, const AnyValue &rhs) { return AnyValue::make_number(unsigned_right_shift_native(lhs, rhs)); }
|
|
304
|
+
inline AnyValue unsigned_right_shift(const double &lhs, const double &rhs) { return AnyValue::make_number(unsigned_right_shift_native(lhs, rhs)); }
|
|
290
305
|
|
|
291
306
|
// --- LOGICAL SHORT-CIRCUITING HELPERS ---
|
|
292
307
|
inline AnyValue logical_and(const AnyValue &lhs, const AnyValue &rhs)
|