@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.
Files changed (127) hide show
  1. package/LICENSE +25 -25
  2. package/README.md +20 -12
  3. package/dist/cli/args.js +22 -0
  4. package/dist/cli/compiler.js +53 -0
  5. package/dist/cli/index.js +43 -107
  6. package/dist/cli/pch.js +71 -0
  7. package/dist/cli/runner.js +23 -0
  8. package/dist/cli/spinner.js +27 -11
  9. package/dist/cli/transpiler.js +20 -0
  10. package/dist/cli/utils.js +59 -0
  11. package/dist/cli/wasm.js +70 -0
  12. package/dist/index.js +17 -6
  13. package/dist/{analysis → interpreter/analysis}/scope.js +38 -3
  14. package/dist/{analysis → interpreter/analysis}/typeAnalyzer.js +563 -28
  15. package/dist/{core → interpreter/core}/codegen/class-handlers.js +1 -1
  16. package/dist/{core → interpreter/core}/codegen/control-flow-handlers.js +12 -11
  17. package/dist/{core → interpreter/core}/codegen/declaration-handlers.js +28 -9
  18. package/dist/{core → interpreter/core}/codegen/destructuring-handlers.js +9 -4
  19. package/dist/{core → interpreter/core}/codegen/expression-handlers.js +82 -88
  20. package/dist/{core → interpreter/core}/codegen/function-handlers.js +159 -46
  21. package/dist/{core → interpreter/core}/codegen/helpers.js +170 -25
  22. package/dist/interpreter/core/codegen/index.js +156 -0
  23. package/dist/{core → interpreter/core}/codegen/literal-handlers.js +9 -0
  24. package/dist/{core → interpreter/core}/codegen/statement-handlers.js +47 -7
  25. package/package.json +6 -4
  26. package/scripts/precompile-headers.ts +293 -50
  27. package/scripts/setup-compiler.ts +63 -63
  28. package/scripts/setup-emsdk.ts +114 -0
  29. package/src/prelude/any_value.cpp +888 -0
  30. package/src/prelude/any_value.hpp +29 -24
  31. package/src/prelude/{exception_helpers.hpp → exception.cpp} +53 -53
  32. package/src/prelude/exception.hpp +27 -27
  33. package/src/prelude/iterator_instantiations.hpp +10 -0
  34. package/src/prelude/{index.hpp → jspp.hpp} +13 -17
  35. package/src/prelude/library/array.cpp +191 -0
  36. package/src/prelude/library/array.hpp +5 -178
  37. package/src/prelude/library/boolean.cpp +30 -0
  38. package/src/prelude/library/boolean.hpp +14 -0
  39. package/src/prelude/library/console.cpp +125 -0
  40. package/src/prelude/library/console.hpp +9 -97
  41. package/src/prelude/library/error.cpp +100 -0
  42. package/src/prelude/library/error.hpp +8 -108
  43. package/src/prelude/library/function.cpp +69 -0
  44. package/src/prelude/library/function.hpp +6 -5
  45. package/src/prelude/library/global.cpp +98 -0
  46. package/src/prelude/library/global.hpp +12 -28
  47. package/src/prelude/library/global_usings.hpp +15 -0
  48. package/src/prelude/library/math.cpp +261 -0
  49. package/src/prelude/library/math.hpp +8 -288
  50. package/src/prelude/library/object.cpp +379 -0
  51. package/src/prelude/library/object.hpp +5 -267
  52. package/src/prelude/library/performance.cpp +21 -0
  53. package/src/prelude/library/performance.hpp +5 -20
  54. package/src/prelude/library/process.cpp +38 -0
  55. package/src/prelude/library/process.hpp +3 -31
  56. package/src/prelude/library/promise.cpp +131 -0
  57. package/src/prelude/library/promise.hpp +5 -116
  58. package/src/prelude/library/symbol.cpp +56 -0
  59. package/src/prelude/library/symbol.hpp +5 -46
  60. package/src/prelude/library/timer.cpp +88 -0
  61. package/src/prelude/library/timer.hpp +11 -87
  62. package/src/prelude/runtime.cpp +19 -0
  63. package/src/prelude/types.hpp +26 -20
  64. package/src/prelude/utils/access.hpp +123 -32
  65. package/src/prelude/utils/assignment_operators.hpp +119 -99
  66. package/src/prelude/utils/log_any_value/array.hpp +61 -40
  67. package/src/prelude/utils/log_any_value/function.hpp +39 -39
  68. package/src/prelude/utils/log_any_value/log_any_value.hpp +1 -1
  69. package/src/prelude/utils/log_any_value/object.hpp +60 -3
  70. package/src/prelude/utils/log_any_value/primitives.hpp +1 -1
  71. package/src/prelude/utils/operators.hpp +109 -94
  72. package/src/prelude/utils/operators_native.hpp +349 -0
  73. package/src/prelude/utils/well_known_symbols.hpp +24 -24
  74. package/src/prelude/values/array.cpp +1399 -0
  75. package/src/prelude/values/array.hpp +4 -0
  76. package/src/prelude/values/async_iterator.cpp +251 -0
  77. package/src/prelude/values/async_iterator.hpp +60 -32
  78. package/src/prelude/values/boolean.cpp +64 -0
  79. package/src/prelude/values/function.cpp +262 -0
  80. package/src/prelude/values/function.hpp +10 -30
  81. package/src/prelude/values/iterator.cpp +309 -0
  82. package/src/prelude/values/iterator.hpp +33 -64
  83. package/src/prelude/values/number.cpp +221 -0
  84. package/src/prelude/values/object.cpp +200 -0
  85. package/src/prelude/values/object.hpp +4 -0
  86. package/src/prelude/values/promise.cpp +479 -0
  87. package/src/prelude/values/promise.hpp +9 -2
  88. package/src/prelude/values/prototypes/array.hpp +46 -1348
  89. package/src/prelude/values/prototypes/async_iterator.hpp +19 -61
  90. package/src/prelude/values/prototypes/boolean.hpp +24 -0
  91. package/src/prelude/values/prototypes/function.hpp +7 -46
  92. package/src/prelude/values/prototypes/iterator.hpp +15 -191
  93. package/src/prelude/values/prototypes/number.hpp +30 -210
  94. package/src/prelude/values/prototypes/object.hpp +7 -23
  95. package/src/prelude/values/prototypes/promise.hpp +8 -186
  96. package/src/prelude/values/prototypes/string.hpp +28 -553
  97. package/src/prelude/values/prototypes/symbol.hpp +9 -70
  98. package/src/prelude/values/shape.hpp +52 -52
  99. package/src/prelude/values/string.cpp +485 -0
  100. package/src/prelude/values/symbol.cpp +89 -0
  101. package/src/prelude/values/symbol.hpp +101 -101
  102. package/dist/cli/file-utils.js +0 -20
  103. package/dist/cli-utils/args.js +0 -59
  104. package/dist/cli-utils/colors.js +0 -9
  105. package/dist/cli-utils/file-utils.js +0 -20
  106. package/dist/cli-utils/spinner.js +0 -55
  107. package/dist/cli.js +0 -153
  108. package/dist/core/codegen/index.js +0 -86
  109. package/src/prelude/any_value_access.hpp +0 -170
  110. package/src/prelude/any_value_defines.hpp +0 -190
  111. package/src/prelude/any_value_helpers.hpp +0 -374
  112. package/src/prelude/utils/operators_primitive.hpp +0 -337
  113. package/src/prelude/values/helpers/array.hpp +0 -199
  114. package/src/prelude/values/helpers/async_iterator.hpp +0 -275
  115. package/src/prelude/values/helpers/function.hpp +0 -109
  116. package/src/prelude/values/helpers/iterator.hpp +0 -145
  117. package/src/prelude/values/helpers/object.hpp +0 -104
  118. package/src/prelude/values/helpers/promise.hpp +0 -254
  119. package/src/prelude/values/helpers/string.hpp +0 -37
  120. package/src/prelude/values/helpers/symbol.hpp +0 -21
  121. /package/dist/{ast → interpreter/ast}/symbols.js +0 -0
  122. /package/dist/{ast → interpreter/ast}/types.js +0 -0
  123. /package/dist/{core → interpreter/core}/codegen/visitor.js +0 -0
  124. /package/dist/{core → interpreter/core}/constants.js +0 -0
  125. /package/dist/{core → interpreter/core}/error.js +0 -0
  126. /package/dist/{core → interpreter/core}/parser.js +0 -0
  127. /package/dist/{core → interpreter/core}/traverser.js +0 -0
@@ -1,99 +1,119 @@
1
- #pragma once
2
-
3
- #include "types.hpp"
4
- #include "any_value.hpp"
5
- #include "utils/operators.hpp"
6
-
7
- namespace jspp {
8
-
9
- // --- FRIEND IMPLEMENTATIONS ---
10
-
11
- inline AnyValue &operator+=(AnyValue &lhs, const AnyValue &rhs) {
12
- lhs = jspp::add(lhs, rhs);
13
- return lhs;
14
- }
15
-
16
- inline AnyValue &operator-=(AnyValue &lhs, const AnyValue &rhs) {
17
- lhs = jspp::sub(lhs, rhs);
18
- return lhs;
19
- }
20
-
21
- inline AnyValue &operator*=(AnyValue &lhs, const AnyValue &rhs) {
22
- lhs = jspp::mul(lhs, rhs);
23
- return lhs;
24
- }
25
-
26
- inline AnyValue &operator/=(AnyValue &lhs, const AnyValue &rhs) {
27
- lhs = jspp::div(lhs, rhs);
28
- return lhs;
29
- }
30
-
31
- inline AnyValue &operator%=(AnyValue &lhs, const AnyValue &rhs) {
32
- lhs = jspp::mod(lhs, rhs);
33
- return lhs;
34
- }
35
-
36
- inline AnyValue &operator++(AnyValue &val) {
37
- val = jspp::add(val, 1.0);
38
- return val;
39
- }
40
-
41
- inline AnyValue operator++(AnyValue &val, int) {
42
- AnyValue temp = val;
43
- val = jspp::add(val, 1.0);
44
- return temp;
45
- }
46
-
47
- inline AnyValue &operator--(AnyValue &val) {
48
- val = jspp::sub(val, 1.0);
49
- return val;
50
- }
51
-
52
- inline AnyValue operator--(AnyValue &val, int) {
53
- AnyValue temp = val;
54
- val = jspp::sub(val, 1.0);
55
- return temp;
56
- }
57
-
58
- // --- OVERLOADS FOR PRIMITIVES ---
59
-
60
- inline AnyValue &operator+=(AnyValue &lhs, const double &rhs) {
61
- lhs = jspp::add(lhs, rhs);
62
- return lhs;
63
- }
64
- inline AnyValue &operator+=(AnyValue &lhs, const int &rhs) {
65
- return lhs += static_cast<double>(rhs);
66
- }
67
-
68
- inline AnyValue &operator-=(AnyValue &lhs, const double &rhs) {
69
- lhs = jspp::sub(lhs, rhs);
70
- return lhs;
71
- }
72
- inline AnyValue &operator-=(AnyValue &lhs, const int &rhs) {
73
- return lhs -= static_cast<double>(rhs);
74
- }
75
-
76
- inline AnyValue &operator*=(AnyValue &lhs, const double &rhs) {
77
- lhs = jspp::mul(lhs, rhs);
78
- return lhs;
79
- }
80
- inline AnyValue &operator*=(AnyValue &lhs, const int &rhs) {
81
- return lhs *= static_cast<double>(rhs);
82
- }
83
-
84
- inline AnyValue &operator/=(AnyValue &lhs, const double &rhs) {
85
- lhs = jspp::div(lhs, rhs);
86
- return lhs;
87
- }
88
- inline AnyValue &operator/=(AnyValue &lhs, const int &rhs) {
89
- return lhs /= static_cast<double>(rhs);
90
- }
91
-
92
- inline AnyValue &operator%=(AnyValue &lhs, const double &rhs) {
93
- lhs = jspp::mod(lhs, rhs);
94
- return lhs;
95
- }
96
- inline AnyValue &operator%=(AnyValue &lhs, const int &rhs) {
97
- return lhs %= static_cast<double>(rhs);
98
- }
99
- }
1
+ #pragma once
2
+
3
+ #include "types.hpp"
4
+ #include "any_value.hpp"
5
+ #include "utils/operators.hpp"
6
+
7
+ namespace jspp
8
+ {
9
+
10
+ // --- FRIEND IMPLEMENTATIONS ---
11
+
12
+ inline AnyValue &operator+=(AnyValue &lhs, const AnyValue &rhs)
13
+ {
14
+ lhs = jspp::add(lhs, rhs);
15
+ return lhs;
16
+ }
17
+
18
+ inline AnyValue &operator-=(AnyValue &lhs, const AnyValue &rhs)
19
+ {
20
+ lhs = jspp::sub(lhs, rhs);
21
+ return lhs;
22
+ }
23
+
24
+ inline AnyValue &operator*=(AnyValue &lhs, const AnyValue &rhs)
25
+ {
26
+ lhs = jspp::mul(lhs, rhs);
27
+ return lhs;
28
+ }
29
+
30
+ inline AnyValue &operator/=(AnyValue &lhs, const AnyValue &rhs)
31
+ {
32
+ lhs = jspp::div(lhs, rhs);
33
+ return lhs;
34
+ }
35
+
36
+ inline AnyValue &operator%=(AnyValue &lhs, const AnyValue &rhs)
37
+ {
38
+ lhs = jspp::mod(lhs, rhs);
39
+ return lhs;
40
+ }
41
+
42
+ inline AnyValue &operator++(AnyValue &val)
43
+ {
44
+ val = jspp::add(val, 1.0);
45
+ return val;
46
+ }
47
+
48
+ inline AnyValue operator++(AnyValue &val, int)
49
+ {
50
+ AnyValue temp = val;
51
+ val = jspp::add(val, 1.0);
52
+ return temp;
53
+ }
54
+
55
+ inline AnyValue &operator--(AnyValue &val)
56
+ {
57
+ val = jspp::sub(val, 1.0);
58
+ return val;
59
+ }
60
+
61
+ inline AnyValue operator--(AnyValue &val, int)
62
+ {
63
+ AnyValue temp = val;
64
+ val = jspp::sub(val, 1.0);
65
+ return temp;
66
+ }
67
+
68
+ // --- OVERLOADS FOR PRIMITIVES ---
69
+
70
+ inline AnyValue &operator+=(AnyValue &lhs, const double &rhs)
71
+ {
72
+ lhs = jspp::add(lhs, rhs);
73
+ return lhs;
74
+ }
75
+ inline AnyValue &operator+=(AnyValue &lhs, const int &rhs)
76
+ {
77
+ return lhs += static_cast<double>(rhs);
78
+ }
79
+
80
+ inline AnyValue &operator-=(AnyValue &lhs, const double &rhs)
81
+ {
82
+ lhs = jspp::sub(lhs, rhs);
83
+ return lhs;
84
+ }
85
+ inline AnyValue &operator-=(AnyValue &lhs, const int &rhs)
86
+ {
87
+ return lhs -= static_cast<double>(rhs);
88
+ }
89
+
90
+ inline AnyValue &operator*=(AnyValue &lhs, const double &rhs)
91
+ {
92
+ lhs = jspp::mul(lhs, rhs);
93
+ return lhs;
94
+ }
95
+ inline AnyValue &operator*=(AnyValue &lhs, const int &rhs)
96
+ {
97
+ return lhs *= static_cast<double>(rhs);
98
+ }
99
+
100
+ inline AnyValue &operator/=(AnyValue &lhs, const double &rhs)
101
+ {
102
+ lhs = jspp::div(lhs, rhs);
103
+ return lhs;
104
+ }
105
+ inline AnyValue &operator/=(AnyValue &lhs, const int &rhs)
106
+ {
107
+ return lhs /= static_cast<double>(rhs);
108
+ }
109
+
110
+ inline AnyValue &operator%=(AnyValue &lhs, const double &rhs)
111
+ {
112
+ lhs = jspp::mod(lhs, rhs);
113
+ return lhs;
114
+ }
115
+ inline AnyValue &operator%=(AnyValue &lhs, const int &rhs)
116
+ {
117
+ return lhs %= static_cast<double>(rhs);
118
+ }
119
+ }
@@ -18,7 +18,7 @@ namespace jspp
18
18
  {
19
19
  auto arr = val.as_array();
20
20
  size_t item_count = static_cast<size_t>(arr->length);
21
- size_t prop_count = arr->props.size();
21
+ size_t prop_count = arr->props.size() + arr->symbol_props.size();
22
22
 
23
23
  std::string indent(depth * 2, ' ');
24
24
  std::string next_indent((depth + 1) * 2, ' ');
@@ -102,28 +102,36 @@ namespace jspp
102
102
  }
103
103
 
104
104
  // Print properties
105
- if (prop_count > 0)
105
+ for (const auto &pair : arr->props)
106
106
  {
107
- ss << Color::BRIGHT_BLACK << ", " << Color::RESET;
107
+ if (!is_enumerable_property(pair.second))
108
+ continue;
108
109
 
109
- size_t current_prop = 0;
110
- for (const auto &pair : arr->props)
111
- {
112
- if (!is_enumerable_property(pair.second))
113
- continue;
110
+ if (needs_comma)
111
+ ss << Color::BRIGHT_BLACK << ", " << Color::RESET;
114
112
 
115
- if (is_valid_js_identifier(pair.first))
116
- {
117
- ss << pair.first;
118
- }
119
- else
120
- {
121
- ss << "\"" << pair.first << "\"";
122
- }
123
- ss << ": " << to_log_string(pair.second, visited, depth + 1);
124
- if (++current_prop < prop_count)
125
- ss << Color::BRIGHT_BLACK << ", " << Color::RESET;
113
+ if (is_valid_js_identifier(pair.first))
114
+ {
115
+ ss << pair.first;
126
116
  }
117
+ else
118
+ {
119
+ ss << "\"" << pair.first << "\"";
120
+ }
121
+ ss << ": " << to_log_string(pair.second, visited, depth + 1);
122
+ needs_comma = true;
123
+ }
124
+ for (const auto &pair : arr->symbol_props)
125
+ {
126
+ if (!is_enumerable_property(pair.second))
127
+ continue;
128
+
129
+ if (needs_comma)
130
+ ss << Color::BRIGHT_BLACK << ", " << Color::RESET;
131
+
132
+ ss << Color::BLUE << pair.first.to_std_string() << Color::RESET;
133
+ ss << ": " << to_log_string(pair.second, visited, depth + 1);
134
+ needs_comma = true;
127
135
  }
128
136
 
129
137
  ss << " ]";
@@ -193,34 +201,47 @@ namespace jspp
193
201
  ss << next_indent << Color::BRIGHT_BLACK << "... " << (item_count - items_to_show) << " more items" << Color::RESET;
194
202
  }
195
203
  // Print properties
196
- else if (prop_count > 0)
204
+ size_t current_prop = 0;
205
+ for (const auto &pair : arr->props)
197
206
  {
207
+ if (current_prop >= MAX_OBJECT_PROPS)
208
+ break;
209
+ if (!is_enumerable_property(pair.second))
210
+ continue;
211
+
198
212
  if (first_item_printed)
199
213
  ss << Color::BRIGHT_BLACK << ",\n"
200
214
  << Color::RESET;
201
215
 
202
- size_t current_prop = 0;
203
- for (const auto &pair : arr->props)
216
+ ss << next_indent;
217
+ if (is_valid_js_identifier(pair.first))
204
218
  {
205
- if (current_prop >= MAX_OBJECT_PROPS)
206
- break;
207
- if (!is_enumerable_property(pair.second))
208
- continue;
209
-
210
- ss << next_indent;
211
- if (is_valid_js_identifier(pair.first))
212
- {
213
- ss << pair.first;
214
- }
215
- else
216
- {
217
- ss << "\"" << pair.first << "\"";
218
- }
219
- ss << ": " << to_log_string(pair.second, visited, depth + 1);
220
- if (++current_prop < prop_count)
221
- ss << Color::BRIGHT_BLACK << ",\n"
222
- << Color::RESET;
219
+ ss << pair.first;
223
220
  }
221
+ else
222
+ {
223
+ ss << "\"" << pair.first << "\"";
224
+ }
225
+ ss << ": " << to_log_string(pair.second, visited, depth + 1);
226
+ first_item_printed = true;
227
+ current_prop++;
228
+ }
229
+ for (const auto &pair : arr->symbol_props)
230
+ {
231
+ if (current_prop >= MAX_OBJECT_PROPS)
232
+ break;
233
+ if (!is_enumerable_property(pair.second))
234
+ continue;
235
+
236
+ if (first_item_printed)
237
+ ss << Color::BRIGHT_BLACK << ",\n"
238
+ << Color::RESET;
239
+
240
+ ss << next_indent;
241
+ ss << Color::BLUE << pair.first.to_std_string() << Color::RESET;
242
+ ss << ": " << to_log_string(pair.second, visited, depth + 1);
243
+ first_item_printed = true;
244
+ current_prop++;
224
245
  }
225
246
  ss << "\n";
226
247
  ss << indent << "]";
@@ -1,39 +1,39 @@
1
- #pragma once
2
- #include "types.hpp"
3
- #include "any_value.hpp"
4
- #include "utils/log_any_value/config.hpp"
5
- #include <string>
6
-
7
- namespace jspp
8
- {
9
- namespace LogAnyValue
10
- {
11
- inline std::string format_function(const AnyValue &val)
12
- {
13
- auto fn = val.as_function();
14
-
15
- if (fn->is_class)
16
- {
17
- std::string extends_part = "";
18
- if (!fn->proto.is_uninitialized() && !fn->proto.is_undefined() && !fn->proto.is_null())
19
- {
20
- if (fn->proto.is_function())
21
- {
22
- auto parent = fn->proto.as_function();
23
- std::string name = parent->name.value_or("");
24
- if (!name.empty())
25
- {
26
- extends_part = " extends " + name;
27
- }
28
- }
29
- }
30
- std::string name = fn->name.value_or("");
31
- return Color::CYAN + std::string("[class ") + (name.empty() ? "(anonymous)" : name) + extends_part + "]" + Color::RESET;
32
- }
33
-
34
- auto type_part = fn->is_generator ? "GeneratorFunction" : "Function";
35
- auto name_part = fn->name.has_value() ? ": " + fn->name.value() : " (anonymous)";
36
- return Color::CYAN + "[" + type_part + name_part + "]" + Color::RESET;
37
- }
38
- }
39
- }
1
+ #pragma once
2
+ #include "types.hpp"
3
+ #include "any_value.hpp"
4
+ #include "utils/log_any_value/config.hpp"
5
+ #include <string>
6
+
7
+ namespace jspp
8
+ {
9
+ namespace LogAnyValue
10
+ {
11
+ inline std::string format_function(const AnyValue &val)
12
+ {
13
+ auto fn = val.as_function();
14
+
15
+ if (fn->is_class)
16
+ {
17
+ std::string extends_part = "";
18
+ if (!fn->proto.is_uninitialized() && !fn->proto.is_undefined() && !fn->proto.is_null())
19
+ {
20
+ if (fn->proto.is_function())
21
+ {
22
+ auto parent = fn->proto.as_function();
23
+ std::string name = parent->name.value_or("");
24
+ if (!name.empty())
25
+ {
26
+ extends_part = " extends " + name;
27
+ }
28
+ }
29
+ }
30
+ std::string name = fn->name.value_or("");
31
+ return Color::CYAN + std::string("[class ") + (name.empty() ? "(anonymous)" : name) + extends_part + "]" + Color::RESET;
32
+ }
33
+
34
+ auto type_part = fn->is_generator ? "GeneratorFunction" : "Function";
35
+ auto name_part = fn->name.has_value() ? ": " + fn->name.value() : " (anonymous)";
36
+ return Color::CYAN + "[" + type_part + name_part + "]" + Color::RESET;
37
+ }
38
+ }
39
+ }
@@ -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 = format_primitive(val, depth);
29
+ auto primitiveStr = format_native(val, depth);
30
30
  if (primitiveStr.has_value())
31
31
  {
32
32
  return primitiveStr.value();
@@ -17,7 +17,7 @@ namespace jspp
17
17
  {
18
18
  auto obj = val.as_object();
19
19
 
20
- size_t prop_count = obj->storage.size();
20
+ size_t prop_count = obj->storage.size() + obj->symbol_props.size();
21
21
  bool use_horizontal_layout = prop_count > 0 && prop_count <= HORIZONTAL_OBJECT_MAX_PROPS;
22
22
 
23
23
  for (size_t i = 0; i < obj->storage.size(); ++i)
@@ -34,19 +34,47 @@ namespace jspp
34
34
  break;
35
35
  }
36
36
  }
37
+ for (const auto &pair : obj->symbol_props)
38
+ {
39
+ if (!is_enumerable_property(pair.second))
40
+ {
41
+ prop_count--;
42
+ continue;
43
+ }
44
+ if (use_horizontal_layout && !is_simple_value(pair.second))
45
+ {
46
+ use_horizontal_layout = false;
47
+ break;
48
+ }
49
+ }
37
50
 
38
51
  std::string indent(depth * 2, ' ');
39
52
  std::string next_indent((depth + 1) * 2, ' ');
40
53
  std::stringstream ss;
54
+ // ... (omitting intermediate parts for brevity in explanation, but including in replacement)
55
+ // Use Symbol.toStringTag for object prefix
56
+ bool has_tag = false;
57
+ try
58
+ {
59
+ auto tag_val = val.get_own_property(AnyValue::from_symbol(WellKnownSymbols::toStringTag));
60
+ if (tag_val.is_string())
61
+ {
62
+ ss << tag_val.to_std_string() << " ";
63
+ has_tag = true;
64
+ }
65
+ }
66
+ catch (...)
67
+ {
68
+ }
41
69
 
42
70
  // Special handling for Error objects
43
71
  try
44
72
  {
45
73
  const AnyValue args[] = {val};
46
- auto is_error = is_truthy(isErrorFn.call(isErrorFn, std::span<const AnyValue>(args, 1)));
74
+ auto is_error = is_truthy(isErrorFn.call(isErrorFn, std::span<const jspp::AnyValue>(args, 1)));
47
75
  if (is_error)
48
76
  {
49
- auto result = errorToStringFn.call(val, std::span<const AnyValue>{});
77
+ auto result = errorToStringFn.call(val, std::span<const jspp::AnyValue>{});
50
78
  if (result.is_string())
51
79
  {
52
80
  ss << result.to_std_string();
@@ -88,6 +116,18 @@ namespace jspp
88
116
  if (++current_prop < prop_count)
89
117
  ss << Color::BRIGHT_BLACK << ", " << Color::RESET;
90
118
  }
119
+ for (const auto &pair : obj->symbol_props)
120
+ {
121
+ if (!is_enumerable_property(pair.second))
122
+ continue;
123
+
124
+ ss << Color::BRIGHT_BLACK << "[" << Color::RESET;
125
+ ss << Color::BLUE << pair.first.to_std_string() << Color::RESET;
126
+ ss << Color::BRIGHT_BLACK << "]: " << Color::RESET;
127
+ ss << to_log_string(pair.second, visited, depth + 1);
128
+ if (++current_prop < prop_count)
129
+ ss << Color::BRIGHT_BLACK << ", " << Color::RESET;
130
+ }
91
131
  ss << " }";
92
132
  }
93
133
  else
@@ -124,6 +164,23 @@ namespace jspp
124
164
  ss << to_log_string(prop_val, visited, depth + 1);
125
165
  props_shown++;
126
166
  }
167
+ for (const auto &pair : obj->symbol_props)
168
+ {
169
+ if (props_shown >= MAX_OBJECT_PROPS)
170
+ break;
171
+
172
+ if (!is_enumerable_property(pair.second))
173
+ continue;
174
+
175
+ if (props_shown > 0)
176
+ ss << ",\n";
177
+
178
+ ss << next_indent;
179
+ ss << Color::BLUE << pair.first.to_std_string() << Color::RESET;
180
+ ss << Color::BRIGHT_BLACK << ": " << Color::RESET;
181
+ ss << to_log_string(pair.second, visited, depth + 1);
182
+ props_shown++;
183
+ }
127
184
  if (prop_count > MAX_OBJECT_PROPS)
128
185
  ss << ",\n"
129
186
  << next_indent << Color::BRIGHT_BLACK << "... " << (prop_count - MAX_OBJECT_PROPS) << " more properties" << Color::RESET;
@@ -11,7 +11,7 @@ namespace jspp
11
11
  {
12
12
  namespace LogAnyValue
13
13
  {
14
- inline std::optional<std::string> format_primitive(const AnyValue &val, int depth)
14
+ inline std::optional<std::string> format_native(const AnyValue &val, int depth)
15
15
  {
16
16
  if (val.is_uninitialized())
17
17
  {