@ugo-studio/jspp 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -36
- package/dist/analysis/scope.js +7 -0
- package/dist/analysis/typeAnalyzer.js +96 -43
- package/dist/ast/symbols.js +34 -24
- package/dist/cli/args.js +59 -0
- package/dist/cli/colors.js +9 -0
- package/dist/cli/file-utils.js +20 -0
- package/dist/cli/index.js +160 -0
- package/dist/cli/spinner.js +55 -0
- package/dist/core/codegen/class-handlers.js +8 -8
- package/dist/core/codegen/control-flow-handlers.js +19 -9
- package/dist/core/codegen/declaration-handlers.js +30 -10
- package/dist/core/codegen/expression-handlers.js +649 -161
- package/dist/core/codegen/function-handlers.js +107 -103
- package/dist/core/codegen/helpers.js +61 -14
- package/dist/core/codegen/index.js +13 -9
- package/dist/core/codegen/literal-handlers.js +4 -2
- package/dist/core/codegen/statement-handlers.js +147 -55
- package/dist/core/codegen/visitor.js +22 -2
- package/dist/core/constants.js +16 -0
- package/dist/core/error.js +58 -0
- package/dist/index.js +6 -3
- package/package.json +3 -3
- package/src/prelude/any_value.hpp +89 -59
- package/src/prelude/any_value_access.hpp +1 -1
- package/src/prelude/any_value_helpers.hpp +85 -43
- package/src/prelude/index.hpp +1 -0
- package/src/prelude/library/array.hpp +3 -2
- package/src/prelude/scheduler.hpp +144 -144
- package/src/prelude/types.hpp +8 -8
- package/src/prelude/utils/access.hpp +62 -6
- package/src/prelude/utils/assignment_operators.hpp +14 -14
- package/src/prelude/utils/log_any_value/array.hpp +0 -15
- package/src/prelude/utils/log_any_value/object.hpp +12 -10
- package/src/prelude/utils/log_any_value/primitives.hpp +2 -0
- package/src/prelude/utils/operators.hpp +117 -474
- package/src/prelude/utils/operators_primitive.hpp +337 -0
- package/src/prelude/values/helpers/array.hpp +4 -4
- package/src/prelude/values/helpers/async_iterator.hpp +2 -2
- package/src/prelude/values/helpers/function.hpp +3 -3
- package/src/prelude/values/helpers/iterator.hpp +2 -2
- package/src/prelude/values/helpers/object.hpp +3 -3
- package/src/prelude/values/helpers/promise.hpp +1 -1
- package/src/prelude/values/helpers/string.hpp +1 -1
- package/src/prelude/values/helpers/symbol.hpp +1 -1
- package/src/prelude/values/prototypes/array.hpp +1125 -853
- package/src/prelude/values/prototypes/async_iterator.hpp +32 -14
- package/src/prelude/values/prototypes/function.hpp +30 -18
- package/src/prelude/values/prototypes/iterator.hpp +40 -17
- package/src/prelude/values/prototypes/number.hpp +119 -62
- package/src/prelude/values/prototypes/object.hpp +10 -4
- package/src/prelude/values/prototypes/promise.hpp +167 -109
- package/src/prelude/values/prototypes/string.hpp +407 -231
- package/src/prelude/values/prototypes/symbol.hpp +45 -23
|
@@ -9,50 +9,72 @@ namespace jspp
|
|
|
9
9
|
{
|
|
10
10
|
namespace SymbolPrototypes
|
|
11
11
|
{
|
|
12
|
-
inline
|
|
12
|
+
inline AnyValue &get_toString_fn()
|
|
13
|
+
{
|
|
14
|
+
static AnyValue fn = AnyValue::make_function([](const AnyValue &thisVal, std::span<const AnyValue>) -> AnyValue
|
|
15
|
+
{ return AnyValue::make_string(thisVal.as_symbol()->to_std_string()); },
|
|
16
|
+
"toString");
|
|
17
|
+
return fn;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
inline AnyValue &get_valueOf_fn()
|
|
21
|
+
{
|
|
22
|
+
static AnyValue fn = AnyValue::make_function([](const AnyValue &thisVal, std::span<const AnyValue>) -> AnyValue
|
|
23
|
+
{ return thisVal; },
|
|
24
|
+
"valueOf");
|
|
25
|
+
return fn;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
inline AnyValue &get_toPrimitive_fn()
|
|
29
|
+
{
|
|
30
|
+
static AnyValue fn = AnyValue::make_function([](const AnyValue &thisVal, std::span<const AnyValue>) -> AnyValue
|
|
31
|
+
{ return thisVal; },
|
|
32
|
+
"[Symbol.toPrimitive]");
|
|
33
|
+
return fn;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
inline AnyValue &get_description_desc()
|
|
37
|
+
{
|
|
38
|
+
static auto getter = [](const AnyValue &thisVal, std::span<const AnyValue>) -> AnyValue
|
|
39
|
+
{
|
|
40
|
+
auto self = thisVal.as_symbol();
|
|
41
|
+
if (self->description.empty())
|
|
42
|
+
{
|
|
43
|
+
return Constants::UNDEFINED;
|
|
44
|
+
}
|
|
45
|
+
return AnyValue::make_string(self->description);
|
|
46
|
+
};
|
|
47
|
+
static AnyValue desc = AnyValue::make_accessor_descriptor(getter, std::nullopt, false, true);
|
|
48
|
+
return desc;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
inline std::optional<AnyValue> get(const std::string &key)
|
|
13
52
|
{
|
|
14
53
|
// --- toString() method ---
|
|
15
54
|
if (key == "toString" || key == WellKnownSymbols::toStringTag->key)
|
|
16
55
|
{
|
|
17
|
-
return
|
|
18
|
-
{ return AnyValue::make_string(self->to_std_string()); },
|
|
19
|
-
key);
|
|
56
|
+
return get_toString_fn();
|
|
20
57
|
}
|
|
21
58
|
|
|
22
59
|
// --- valueOf() method ---
|
|
23
60
|
if (key == "valueOf")
|
|
24
61
|
{
|
|
25
|
-
return
|
|
26
|
-
{ return thisVal; },
|
|
27
|
-
key);
|
|
62
|
+
return get_valueOf_fn();
|
|
28
63
|
}
|
|
29
64
|
|
|
30
65
|
// --- [Symbol.toPrimitive] ---
|
|
31
66
|
if (key == WellKnownSymbols::toPrimitive->key)
|
|
32
67
|
{
|
|
33
|
-
return
|
|
34
|
-
{ return thisVal; },
|
|
35
|
-
"[Symbol.toPrimitive]");
|
|
68
|
+
return get_toPrimitive_fn();
|
|
36
69
|
}
|
|
37
70
|
|
|
38
71
|
// --- description property ---
|
|
39
72
|
if (key == "description")
|
|
40
73
|
{
|
|
41
|
-
return
|
|
42
|
-
[self](const AnyValue &thisVal, std::span<const AnyValue>) -> AnyValue
|
|
43
|
-
{
|
|
44
|
-
if (self->description.empty())
|
|
45
|
-
{
|
|
46
|
-
return Constants::UNDEFINED;
|
|
47
|
-
}
|
|
48
|
-
return AnyValue::make_string(self->description);
|
|
49
|
-
},
|
|
50
|
-
std::nullopt,
|
|
51
|
-
false,
|
|
52
|
-
true);
|
|
74
|
+
return get_description_desc();
|
|
53
75
|
}
|
|
54
76
|
|
|
55
77
|
return std::nullopt;
|
|
56
78
|
}
|
|
57
79
|
}
|
|
58
|
-
}
|
|
80
|
+
}
|