@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.
Files changed (71) hide show
  1. package/dist/analysis/scope.js +17 -0
  2. package/dist/analysis/typeAnalyzer.js +7 -1
  3. package/dist/ast/symbols.js +32 -0
  4. package/dist/ast/types.js +0 -6
  5. package/dist/cli-utils/args.js +57 -0
  6. package/dist/cli-utils/colors.js +9 -0
  7. package/dist/cli-utils/file-utils.js +20 -0
  8. package/dist/cli-utils/spinner.js +55 -0
  9. package/dist/cli.js +105 -30
  10. package/dist/core/codegen/class-handlers.js +10 -6
  11. package/dist/core/codegen/control-flow-handlers.js +57 -28
  12. package/dist/core/codegen/declaration-handlers.js +10 -6
  13. package/dist/core/codegen/expression-handlers.js +206 -61
  14. package/dist/core/codegen/function-handlers.js +203 -76
  15. package/dist/core/codegen/helpers.js +125 -28
  16. package/dist/core/codegen/index.js +23 -15
  17. package/dist/core/codegen/literal-handlers.js +15 -6
  18. package/dist/core/codegen/statement-handlers.js +282 -84
  19. package/dist/core/codegen/visitor.js +3 -1
  20. package/package.json +1 -1
  21. package/src/prelude/any_value.hpp +221 -342
  22. package/src/prelude/any_value_access.hpp +168 -81
  23. package/src/prelude/any_value_defines.hpp +74 -35
  24. package/src/prelude/any_value_helpers.hpp +75 -180
  25. package/src/prelude/exception.hpp +1 -0
  26. package/src/prelude/exception_helpers.hpp +4 -4
  27. package/src/prelude/index.hpp +12 -2
  28. package/src/prelude/library/array.hpp +190 -0
  29. package/src/prelude/library/console.hpp +6 -5
  30. package/src/prelude/library/error.hpp +10 -8
  31. package/src/prelude/library/function.hpp +10 -0
  32. package/src/prelude/library/global.hpp +20 -0
  33. package/src/prelude/library/math.hpp +308 -0
  34. package/src/prelude/library/object.hpp +288 -0
  35. package/src/prelude/library/performance.hpp +1 -1
  36. package/src/prelude/library/process.hpp +39 -0
  37. package/src/prelude/library/promise.hpp +57 -55
  38. package/src/prelude/library/symbol.hpp +45 -57
  39. package/src/prelude/library/timer.hpp +6 -6
  40. package/src/prelude/types.hpp +54 -0
  41. package/src/prelude/utils/access.hpp +215 -11
  42. package/src/prelude/utils/assignment_operators.hpp +99 -0
  43. package/src/prelude/utils/log_any_value/array.hpp +8 -8
  44. package/src/prelude/utils/log_any_value/function.hpp +6 -4
  45. package/src/prelude/utils/log_any_value/object.hpp +41 -24
  46. package/src/prelude/utils/log_any_value/primitives.hpp +3 -1
  47. package/src/prelude/utils/operators.hpp +750 -274
  48. package/src/prelude/utils/well_known_symbols.hpp +12 -0
  49. package/src/prelude/values/array.hpp +8 -6
  50. package/src/prelude/values/async_iterator.hpp +79 -0
  51. package/src/prelude/values/descriptors.hpp +2 -2
  52. package/src/prelude/values/function.hpp +72 -62
  53. package/src/prelude/values/helpers/array.hpp +64 -28
  54. package/src/prelude/values/helpers/async_iterator.hpp +275 -0
  55. package/src/prelude/values/helpers/function.hpp +81 -92
  56. package/src/prelude/values/helpers/iterator.hpp +3 -3
  57. package/src/prelude/values/helpers/object.hpp +54 -9
  58. package/src/prelude/values/helpers/promise.hpp +13 -6
  59. package/src/prelude/values/iterator.hpp +1 -1
  60. package/src/prelude/values/object.hpp +10 -3
  61. package/src/prelude/values/promise.hpp +7 -11
  62. package/src/prelude/values/prototypes/array.hpp +851 -12
  63. package/src/prelude/values/prototypes/async_iterator.hpp +50 -0
  64. package/src/prelude/values/prototypes/function.hpp +2 -2
  65. package/src/prelude/values/prototypes/iterator.hpp +5 -5
  66. package/src/prelude/values/prototypes/number.hpp +153 -0
  67. package/src/prelude/values/prototypes/object.hpp +2 -2
  68. package/src/prelude/values/prototypes/promise.hpp +40 -30
  69. package/src/prelude/values/prototypes/string.hpp +28 -28
  70. package/src/prelude/values/prototypes/symbol.hpp +20 -3
  71. 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::map<std::string, AnyValue> props;
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() : proto(nullptr) {}
16
- explicit JsObject(const std::map<std::string, AnyValue> &p, std::shared_ptr<AnyValue> pr = nullptr) : props(p), proto(pr) {}
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
  }