@ugo-studio/jspp 0.3.1 → 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/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 +44 -61
- 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 +63 -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 -2
- package/src/prelude/utils/assignment_operators.hpp +40 -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 +87 -87
- package/src/prelude/utils/operators_native.hpp +349 -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/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
|
@@ -4,52 +4,62 @@
|
|
|
4
4
|
#include "any_value.hpp"
|
|
5
5
|
#include "utils/operators.hpp"
|
|
6
6
|
|
|
7
|
-
namespace jspp
|
|
7
|
+
namespace jspp
|
|
8
|
+
{
|
|
8
9
|
|
|
9
10
|
// --- FRIEND IMPLEMENTATIONS ---
|
|
10
11
|
|
|
11
|
-
inline AnyValue &operator+=(AnyValue &lhs, const AnyValue &rhs)
|
|
12
|
+
inline AnyValue &operator+=(AnyValue &lhs, const AnyValue &rhs)
|
|
13
|
+
{
|
|
12
14
|
lhs = jspp::add(lhs, rhs);
|
|
13
15
|
return lhs;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
|
-
inline AnyValue &operator-=(AnyValue &lhs, const AnyValue &rhs)
|
|
18
|
+
inline AnyValue &operator-=(AnyValue &lhs, const AnyValue &rhs)
|
|
19
|
+
{
|
|
17
20
|
lhs = jspp::sub(lhs, rhs);
|
|
18
21
|
return lhs;
|
|
19
22
|
}
|
|
20
23
|
|
|
21
|
-
inline AnyValue &operator*=(AnyValue &lhs, const AnyValue &rhs)
|
|
24
|
+
inline AnyValue &operator*=(AnyValue &lhs, const AnyValue &rhs)
|
|
25
|
+
{
|
|
22
26
|
lhs = jspp::mul(lhs, rhs);
|
|
23
27
|
return lhs;
|
|
24
28
|
}
|
|
25
29
|
|
|
26
|
-
inline AnyValue &operator/=(AnyValue &lhs, const AnyValue &rhs)
|
|
30
|
+
inline AnyValue &operator/=(AnyValue &lhs, const AnyValue &rhs)
|
|
31
|
+
{
|
|
27
32
|
lhs = jspp::div(lhs, rhs);
|
|
28
33
|
return lhs;
|
|
29
34
|
}
|
|
30
35
|
|
|
31
|
-
inline AnyValue &operator%=(AnyValue &lhs, const AnyValue &rhs)
|
|
36
|
+
inline AnyValue &operator%=(AnyValue &lhs, const AnyValue &rhs)
|
|
37
|
+
{
|
|
32
38
|
lhs = jspp::mod(lhs, rhs);
|
|
33
39
|
return lhs;
|
|
34
40
|
}
|
|
35
41
|
|
|
36
|
-
inline AnyValue &operator++(AnyValue &val)
|
|
42
|
+
inline AnyValue &operator++(AnyValue &val)
|
|
43
|
+
{
|
|
37
44
|
val = jspp::add(val, 1.0);
|
|
38
45
|
return val;
|
|
39
46
|
}
|
|
40
47
|
|
|
41
|
-
inline AnyValue operator++(AnyValue &val, int)
|
|
48
|
+
inline AnyValue operator++(AnyValue &val, int)
|
|
49
|
+
{
|
|
42
50
|
AnyValue temp = val;
|
|
43
51
|
val = jspp::add(val, 1.0);
|
|
44
52
|
return temp;
|
|
45
53
|
}
|
|
46
54
|
|
|
47
|
-
inline AnyValue &operator--(AnyValue &val)
|
|
55
|
+
inline AnyValue &operator--(AnyValue &val)
|
|
56
|
+
{
|
|
48
57
|
val = jspp::sub(val, 1.0);
|
|
49
58
|
return val;
|
|
50
59
|
}
|
|
51
60
|
|
|
52
|
-
inline AnyValue operator--(AnyValue &val, int)
|
|
61
|
+
inline AnyValue operator--(AnyValue &val, int)
|
|
62
|
+
{
|
|
53
63
|
AnyValue temp = val;
|
|
54
64
|
val = jspp::sub(val, 1.0);
|
|
55
65
|
return temp;
|
|
@@ -57,43 +67,53 @@ namespace jspp {
|
|
|
57
67
|
|
|
58
68
|
// --- OVERLOADS FOR PRIMITIVES ---
|
|
59
69
|
|
|
60
|
-
inline AnyValue &operator+=(AnyValue &lhs, const double &rhs)
|
|
70
|
+
inline AnyValue &operator+=(AnyValue &lhs, const double &rhs)
|
|
71
|
+
{
|
|
61
72
|
lhs = jspp::add(lhs, rhs);
|
|
62
73
|
return lhs;
|
|
63
74
|
}
|
|
64
|
-
inline AnyValue &operator+=(AnyValue &lhs, const int &rhs)
|
|
75
|
+
inline AnyValue &operator+=(AnyValue &lhs, const int &rhs)
|
|
76
|
+
{
|
|
65
77
|
return lhs += static_cast<double>(rhs);
|
|
66
78
|
}
|
|
67
79
|
|
|
68
|
-
inline AnyValue &operator-=(AnyValue &lhs, const double &rhs)
|
|
80
|
+
inline AnyValue &operator-=(AnyValue &lhs, const double &rhs)
|
|
81
|
+
{
|
|
69
82
|
lhs = jspp::sub(lhs, rhs);
|
|
70
83
|
return lhs;
|
|
71
84
|
}
|
|
72
|
-
inline AnyValue &operator-=(AnyValue &lhs, const int &rhs)
|
|
85
|
+
inline AnyValue &operator-=(AnyValue &lhs, const int &rhs)
|
|
86
|
+
{
|
|
73
87
|
return lhs -= static_cast<double>(rhs);
|
|
74
88
|
}
|
|
75
89
|
|
|
76
|
-
inline AnyValue &operator*=(AnyValue &lhs, const double &rhs)
|
|
90
|
+
inline AnyValue &operator*=(AnyValue &lhs, const double &rhs)
|
|
91
|
+
{
|
|
77
92
|
lhs = jspp::mul(lhs, rhs);
|
|
78
93
|
return lhs;
|
|
79
94
|
}
|
|
80
|
-
inline AnyValue &operator*=(AnyValue &lhs, const int &rhs)
|
|
95
|
+
inline AnyValue &operator*=(AnyValue &lhs, const int &rhs)
|
|
96
|
+
{
|
|
81
97
|
return lhs *= static_cast<double>(rhs);
|
|
82
98
|
}
|
|
83
99
|
|
|
84
|
-
inline AnyValue &operator/=(AnyValue &lhs, const double &rhs)
|
|
100
|
+
inline AnyValue &operator/=(AnyValue &lhs, const double &rhs)
|
|
101
|
+
{
|
|
85
102
|
lhs = jspp::div(lhs, rhs);
|
|
86
103
|
return lhs;
|
|
87
104
|
}
|
|
88
|
-
inline AnyValue &operator/=(AnyValue &lhs, const int &rhs)
|
|
105
|
+
inline AnyValue &operator/=(AnyValue &lhs, const int &rhs)
|
|
106
|
+
{
|
|
89
107
|
return lhs /= static_cast<double>(rhs);
|
|
90
108
|
}
|
|
91
109
|
|
|
92
|
-
inline AnyValue &operator%=(AnyValue &lhs, const double &rhs)
|
|
110
|
+
inline AnyValue &operator%=(AnyValue &lhs, const double &rhs)
|
|
111
|
+
{
|
|
93
112
|
lhs = jspp::mod(lhs, rhs);
|
|
94
113
|
return lhs;
|
|
95
114
|
}
|
|
96
|
-
inline AnyValue &operator%=(AnyValue &lhs, const int &rhs)
|
|
115
|
+
inline AnyValue &operator%=(AnyValue &lhs, const int &rhs)
|
|
116
|
+
{
|
|
97
117
|
return lhs %= static_cast<double>(rhs);
|
|
98
118
|
}
|
|
99
119
|
}
|
|
@@ -26,7 +26,7 @@ namespace jspp
|
|
|
26
26
|
inline std::string to_log_string(const AnyValue &val, std::unordered_set<const void *> &visited, int depth)
|
|
27
27
|
{
|
|
28
28
|
// 1. Try Primitives
|
|
29
|
-
auto primitiveStr =
|
|
29
|
+
auto primitiveStr = format_native(val, depth);
|
|
30
30
|
if (primitiveStr.has_value())
|
|
31
31
|
{
|
|
32
32
|
return primitiveStr.value();
|
|
@@ -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 ---
|
|
@@ -92,23 +92,23 @@ namespace jspp
|
|
|
92
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
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
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
|
{
|
|
@@ -120,39 +120,39 @@ namespace jspp
|
|
|
120
120
|
{
|
|
121
121
|
if (lhs.is_number() && rhs.is_number())
|
|
122
122
|
return AnyValue::make_number(lhs.as_double() - rhs.as_double());
|
|
123
|
-
return AnyValue::make_number(
|
|
123
|
+
return AnyValue::make_number(sub_native(lhs, rhs));
|
|
124
124
|
}
|
|
125
125
|
inline AnyValue sub(const AnyValue &lhs, const double &rhs)
|
|
126
126
|
{
|
|
127
127
|
if (lhs.is_number())
|
|
128
128
|
return AnyValue::make_number(lhs.as_double() - rhs);
|
|
129
|
-
return AnyValue::make_number(
|
|
129
|
+
return AnyValue::make_number(sub_native(lhs, rhs));
|
|
130
130
|
}
|
|
131
131
|
inline AnyValue sub(const double &lhs, const AnyValue &rhs)
|
|
132
132
|
{
|
|
133
133
|
if (rhs.is_number())
|
|
134
134
|
return AnyValue::make_number(lhs - rhs.as_double());
|
|
135
|
-
return AnyValue::make_number(
|
|
135
|
+
return AnyValue::make_number(sub_native(lhs, rhs));
|
|
136
136
|
}
|
|
137
137
|
inline AnyValue sub(const double &lhs, const double &rhs) { return AnyValue::make_number(lhs - rhs); }
|
|
138
138
|
|
|
139
139
|
// 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(
|
|
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)); }
|
|
144
144
|
|
|
145
145
|
// 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(
|
|
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)); }
|
|
150
150
|
|
|
151
151
|
// 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(
|
|
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)); }
|
|
156
156
|
|
|
157
157
|
// --- UNARY OPERATORS ---
|
|
158
158
|
inline AnyValue plus(const AnyValue &val)
|
|
@@ -173,10 +173,10 @@ namespace jspp
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
// --- 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(
|
|
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)); }
|
|
180
180
|
|
|
181
181
|
// --- COMPARISON OPERATORS ---
|
|
182
182
|
|
|
@@ -186,122 +186,122 @@ namespace jspp
|
|
|
186
186
|
if (lhs.is_string() && rhs.is_string())
|
|
187
187
|
return AnyValue::make_boolean(lhs.as_string()->value < rhs.as_string()->value);
|
|
188
188
|
|
|
189
|
-
return AnyValue::make_boolean(
|
|
189
|
+
return AnyValue::make_boolean(less_than_native(lhs, rhs));
|
|
190
190
|
}
|
|
191
191
|
inline AnyValue less_than(const AnyValue &lhs, const double &rhs)
|
|
192
192
|
{
|
|
193
|
-
return AnyValue::make_boolean(
|
|
193
|
+
return AnyValue::make_boolean(less_than_native(lhs, rhs));
|
|
194
194
|
}
|
|
195
195
|
inline AnyValue less_than(const double &lhs, const AnyValue &rhs)
|
|
196
196
|
{
|
|
197
|
-
return AnyValue::make_boolean(
|
|
197
|
+
return AnyValue::make_boolean(less_than_native(lhs, rhs));
|
|
198
198
|
}
|
|
199
199
|
inline AnyValue less_than(const double &lhs, const double &rhs)
|
|
200
200
|
{
|
|
201
|
-
return AnyValue::make_boolean(
|
|
201
|
+
return AnyValue::make_boolean(less_than_native(lhs, rhs));
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
inline AnyValue greater_than(const AnyValue &lhs, const AnyValue &rhs) { return less_than(rhs, lhs); }
|
|
205
205
|
inline AnyValue greater_than(const AnyValue &lhs, const double &rhs) { return less_than(rhs, lhs); }
|
|
206
206
|
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(
|
|
207
|
+
inline AnyValue greater_than(const double &lhs, const double &rhs) { return AnyValue::make_boolean(greater_than_native(lhs, rhs)); }
|
|
208
208
|
|
|
209
209
|
inline AnyValue less_than_or_equal(const AnyValue &lhs, const AnyValue &rhs)
|
|
210
210
|
{
|
|
211
211
|
if (lhs.is_string() && rhs.is_string())
|
|
212
212
|
return AnyValue::make_boolean(lhs.as_string()->value <= rhs.as_string()->value);
|
|
213
|
-
return AnyValue::make_boolean(
|
|
213
|
+
return AnyValue::make_boolean(less_than_or_equal_native(lhs, rhs));
|
|
214
214
|
}
|
|
215
215
|
inline AnyValue less_than_or_equal(const AnyValue &lhs, const double &rhs)
|
|
216
216
|
{
|
|
217
|
-
return AnyValue::make_boolean(
|
|
217
|
+
return AnyValue::make_boolean(less_than_or_equal_native(lhs, rhs));
|
|
218
218
|
}
|
|
219
219
|
inline AnyValue less_than_or_equal(const double &lhs, const AnyValue &rhs)
|
|
220
220
|
{
|
|
221
|
-
return AnyValue::make_boolean(
|
|
221
|
+
return AnyValue::make_boolean(less_than_or_equal_native(lhs, rhs));
|
|
222
222
|
}
|
|
223
223
|
inline AnyValue less_than_or_equal(const double &lhs, const double &rhs)
|
|
224
224
|
{
|
|
225
|
-
return AnyValue::make_boolean(
|
|
225
|
+
return AnyValue::make_boolean(less_than_or_equal_native(lhs, rhs));
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
inline AnyValue greater_than_or_equal(const AnyValue &lhs, const AnyValue &rhs)
|
|
229
229
|
{
|
|
230
230
|
if (lhs.is_string() && rhs.is_string())
|
|
231
231
|
return AnyValue::make_boolean(lhs.as_string()->value >= rhs.as_string()->value);
|
|
232
|
-
return AnyValue::make_boolean(
|
|
232
|
+
return AnyValue::make_boolean(greater_than_or_equal_native(lhs, rhs));
|
|
233
233
|
}
|
|
234
234
|
inline AnyValue greater_than_or_equal(const AnyValue &lhs, const double &rhs)
|
|
235
235
|
{
|
|
236
|
-
return AnyValue::make_boolean(
|
|
236
|
+
return AnyValue::make_boolean(greater_than_or_equal_native(lhs, rhs));
|
|
237
237
|
}
|
|
238
238
|
inline AnyValue greater_than_or_equal(const double &lhs, const AnyValue &rhs)
|
|
239
239
|
{
|
|
240
|
-
return AnyValue::make_boolean(
|
|
240
|
+
return AnyValue::make_boolean(greater_than_or_equal_native(lhs, rhs));
|
|
241
241
|
}
|
|
242
242
|
inline AnyValue greater_than_or_equal(const double &lhs, const double &rhs)
|
|
243
243
|
{
|
|
244
|
-
return AnyValue::make_boolean(
|
|
244
|
+
return AnyValue::make_boolean(greater_than_or_equal_native(lhs, rhs));
|
|
245
245
|
}
|
|
246
246
|
|
|
247
247
|
// Equality ==
|
|
248
248
|
inline AnyValue equal(const AnyValue &lhs, const AnyValue &rhs)
|
|
249
249
|
{
|
|
250
|
-
return AnyValue::make_boolean(
|
|
250
|
+
return AnyValue::make_boolean(is_equal_to_native(lhs, rhs));
|
|
251
251
|
}
|
|
252
252
|
inline AnyValue equal(const AnyValue &lhs, const double &rhs)
|
|
253
253
|
{
|
|
254
254
|
if (lhs.is_number())
|
|
255
|
-
return AnyValue::make_boolean(
|
|
256
|
-
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)));
|
|
257
257
|
}
|
|
258
258
|
inline AnyValue equal(const double &lhs, const AnyValue &rhs)
|
|
259
259
|
{
|
|
260
260
|
if (rhs.is_number())
|
|
261
|
-
return AnyValue::make_boolean(
|
|
262
|
-
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)));
|
|
263
263
|
}
|
|
264
264
|
inline AnyValue equal(const double &lhs, const double &rhs)
|
|
265
265
|
{
|
|
266
|
-
return AnyValue::make_boolean(
|
|
266
|
+
return AnyValue::make_boolean(equal_native(lhs, rhs));
|
|
267
267
|
}
|
|
268
268
|
|
|
269
|
-
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)); }
|
|
270
270
|
inline AnyValue not_equal(const AnyValue &lhs, const double &rhs) { return AnyValue::make_boolean(!equal(lhs, rhs).as_boolean()); }
|
|
271
271
|
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(
|
|
272
|
+
inline AnyValue not_equal(const double &lhs, const double &rhs) { return AnyValue::make_boolean(not_equal_native(lhs, rhs)); }
|
|
273
273
|
|
|
274
274
|
// --- 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(
|
|
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)); }
|
|
279
279
|
|
|
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(
|
|
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)); }
|
|
284
284
|
|
|
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(
|
|
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)); }
|
|
289
289
|
|
|
290
290
|
// --- 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(
|
|
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)); }
|
|
295
295
|
|
|
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(
|
|
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)); }
|
|
300
300
|
|
|
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(
|
|
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)); }
|
|
305
305
|
|
|
306
306
|
// --- LOGICAL SHORT-CIRCUITING HELPERS ---
|
|
307
307
|
inline AnyValue logical_and(const AnyValue &lhs, const AnyValue &rhs)
|