@ugo-studio/jspp 0.1.4 → 0.1.6
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/analysis/scope.js +17 -0
- package/dist/analysis/typeAnalyzer.js +7 -1
- package/dist/ast/symbols.js +32 -0
- package/dist/ast/types.js +0 -6
- package/dist/cli-utils/args.js +57 -0
- package/dist/cli-utils/colors.js +9 -0
- package/dist/cli-utils/file-utils.js +20 -0
- package/dist/cli-utils/spinner.js +55 -0
- package/dist/cli.js +105 -30
- package/dist/core/codegen/class-handlers.js +10 -6
- package/dist/core/codegen/control-flow-handlers.js +57 -28
- package/dist/core/codegen/declaration-handlers.js +10 -6
- package/dist/core/codegen/expression-handlers.js +206 -61
- package/dist/core/codegen/function-handlers.js +203 -76
- package/dist/core/codegen/helpers.js +125 -28
- package/dist/core/codegen/index.js +23 -15
- package/dist/core/codegen/literal-handlers.js +15 -6
- package/dist/core/codegen/statement-handlers.js +282 -84
- package/dist/core/codegen/visitor.js +3 -1
- package/package.json +1 -1
- package/src/prelude/any_value.hpp +221 -342
- package/src/prelude/any_value_access.hpp +168 -81
- package/src/prelude/any_value_defines.hpp +74 -35
- package/src/prelude/any_value_helpers.hpp +75 -180
- package/src/prelude/exception.hpp +1 -0
- package/src/prelude/exception_helpers.hpp +4 -4
- package/src/prelude/index.hpp +12 -2
- package/src/prelude/library/array.hpp +190 -0
- package/src/prelude/library/console.hpp +6 -5
- package/src/prelude/library/error.hpp +10 -8
- package/src/prelude/library/function.hpp +10 -0
- package/src/prelude/library/global.hpp +20 -0
- package/src/prelude/library/math.hpp +308 -0
- package/src/prelude/library/object.hpp +288 -0
- package/src/prelude/library/performance.hpp +1 -1
- package/src/prelude/library/process.hpp +39 -0
- package/src/prelude/library/promise.hpp +57 -55
- package/src/prelude/library/symbol.hpp +45 -57
- package/src/prelude/library/timer.hpp +6 -6
- package/src/prelude/types.hpp +54 -0
- package/src/prelude/utils/access.hpp +215 -11
- package/src/prelude/utils/assignment_operators.hpp +99 -0
- package/src/prelude/utils/log_any_value/array.hpp +8 -8
- package/src/prelude/utils/log_any_value/function.hpp +6 -4
- package/src/prelude/utils/log_any_value/object.hpp +41 -24
- package/src/prelude/utils/log_any_value/primitives.hpp +3 -1
- package/src/prelude/utils/operators.hpp +750 -274
- package/src/prelude/utils/well_known_symbols.hpp +12 -0
- package/src/prelude/values/array.hpp +8 -6
- package/src/prelude/values/async_iterator.hpp +79 -0
- package/src/prelude/values/descriptors.hpp +2 -2
- package/src/prelude/values/function.hpp +72 -62
- package/src/prelude/values/helpers/array.hpp +64 -28
- package/src/prelude/values/helpers/async_iterator.hpp +275 -0
- package/src/prelude/values/helpers/function.hpp +81 -92
- package/src/prelude/values/helpers/iterator.hpp +3 -3
- package/src/prelude/values/helpers/object.hpp +54 -9
- package/src/prelude/values/helpers/promise.hpp +13 -6
- package/src/prelude/values/iterator.hpp +1 -1
- package/src/prelude/values/object.hpp +10 -3
- package/src/prelude/values/promise.hpp +7 -11
- package/src/prelude/values/prototypes/array.hpp +851 -12
- package/src/prelude/values/prototypes/async_iterator.hpp +50 -0
- package/src/prelude/values/prototypes/function.hpp +2 -2
- package/src/prelude/values/prototypes/iterator.hpp +5 -5
- package/src/prelude/values/prototypes/number.hpp +153 -0
- package/src/prelude/values/prototypes/object.hpp +2 -2
- package/src/prelude/values/prototypes/promise.hpp +40 -30
- package/src/prelude/values/prototypes/string.hpp +28 -28
- package/src/prelude/values/prototypes/symbol.hpp +20 -3
- package/src/prelude/values/shape.hpp +52 -0
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include "types.hpp"
|
|
4
|
+
#include "shape.hpp"
|
|
5
|
+
#include <vector>
|
|
6
|
+
#include <unordered_set>
|
|
4
7
|
|
|
5
8
|
namespace jspp
|
|
6
9
|
{
|
|
@@ -9,13 +12,17 @@ namespace jspp
|
|
|
9
12
|
|
|
10
13
|
struct JsObject
|
|
11
14
|
{
|
|
12
|
-
std::
|
|
15
|
+
std::shared_ptr<Shape> shape;
|
|
16
|
+
std::vector<AnyValue> storage;
|
|
13
17
|
std::shared_ptr<AnyValue> proto;
|
|
18
|
+
std::unordered_set<std::string> deleted_keys;
|
|
14
19
|
|
|
15
|
-
JsObject()
|
|
16
|
-
|
|
20
|
+
JsObject();
|
|
21
|
+
JsObject(std::initializer_list<std::pair<std::string, AnyValue>> p, std::shared_ptr<AnyValue> pr = nullptr);
|
|
22
|
+
JsObject(const std::map<std::string, AnyValue> &p, std::shared_ptr<AnyValue> pr = nullptr);
|
|
17
23
|
|
|
18
24
|
std::string to_std_string() const;
|
|
25
|
+
bool has_property(const std::string &key) const;
|
|
19
26
|
AnyValue get_property(const std::string &key, const AnyValue &thisVal);
|
|
20
27
|
AnyValue set_property(const std::string &key, const AnyValue &value, const AnyValue &thisVal);
|
|
21
28
|
};
|
|
@@ -20,8 +20,8 @@ namespace jspp
|
|
|
20
20
|
{
|
|
21
21
|
PromiseStatus status = PromiseStatus::Pending;
|
|
22
22
|
std::shared_ptr<AnyValue> result; // Value if fulfilled, reason if rejected
|
|
23
|
-
std::vector<std::function<void(AnyValue)>> onFulfilled;
|
|
24
|
-
std::vector<std::function<void(AnyValue)>> onRejected;
|
|
23
|
+
std::vector<std::function<void(const AnyValue&)>> onFulfilled;
|
|
24
|
+
std::vector<std::function<void(const AnyValue&)>> onRejected;
|
|
25
25
|
|
|
26
26
|
PromiseState(); // Defined in helpers
|
|
27
27
|
};
|
|
@@ -40,12 +40,14 @@ namespace jspp
|
|
|
40
40
|
// --- Promise Logic ---
|
|
41
41
|
void resolve(const AnyValue& value);
|
|
42
42
|
void reject(const AnyValue& reason);
|
|
43
|
-
void then(std::function<void(AnyValue)> onFulfilled, std::function<void(AnyValue)> onRejected = nullptr);
|
|
43
|
+
void then(std::function<void(const AnyValue&)> onFulfilled, std::function<void(const AnyValue&)> onRejected = nullptr);
|
|
44
44
|
|
|
45
45
|
// --- Methods ---
|
|
46
46
|
std::string to_std_string() const;
|
|
47
47
|
AnyValue get_property(const std::string& key, const AnyValue& thisVal);
|
|
48
48
|
AnyValue set_property(const std::string& key, const AnyValue& value, const AnyValue& thisVal);
|
|
49
|
+
|
|
50
|
+
auto operator co_await() const;
|
|
49
51
|
};
|
|
50
52
|
|
|
51
53
|
struct JsPromisePromiseType {
|
|
@@ -61,13 +63,7 @@ namespace jspp
|
|
|
61
63
|
|
|
62
64
|
// await_transform for AnyValue
|
|
63
65
|
auto await_transform(const AnyValue& value);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// Awaiter for AnyValue
|
|
67
|
-
struct AnyValueAwaiter {
|
|
68
|
-
const AnyValue& value; // Reference to the value being awaited
|
|
69
|
-
bool await_ready();
|
|
70
|
-
void await_suspend(std::coroutine_handle<> h);
|
|
71
|
-
AnyValue await_resume();
|
|
66
|
+
// await_transform for JsPromise
|
|
67
|
+
auto await_transform(const JsPromise& value);
|
|
72
68
|
};
|
|
73
69
|
}
|