@ugo-studio/jspp 0.1.3 → 0.1.4

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 (69) hide show
  1. package/README.md +2 -2
  2. package/dist/analysis/scope.js +16 -4
  3. package/dist/analysis/typeAnalyzer.js +253 -20
  4. package/dist/ast/types.js +6 -0
  5. package/dist/cli.js +1 -2
  6. package/dist/core/codegen/class-handlers.js +127 -0
  7. package/dist/core/codegen/control-flow-handlers.js +464 -0
  8. package/dist/core/codegen/declaration-handlers.js +31 -14
  9. package/dist/core/codegen/expression-handlers.js +429 -117
  10. package/dist/core/codegen/function-handlers.js +91 -15
  11. package/dist/core/codegen/helpers.js +66 -2
  12. package/dist/core/codegen/index.js +17 -6
  13. package/dist/core/codegen/literal-handlers.js +3 -0
  14. package/dist/core/codegen/statement-handlers.js +133 -204
  15. package/dist/core/codegen/visitor.js +29 -3
  16. package/package.json +3 -3
  17. package/src/prelude/any_value.hpp +658 -634
  18. package/src/prelude/any_value_access.hpp +103 -0
  19. package/src/prelude/any_value_defines.hpp +151 -0
  20. package/src/prelude/any_value_helpers.hpp +246 -225
  21. package/src/prelude/exception.hpp +31 -0
  22. package/src/prelude/exception_helpers.hpp +49 -0
  23. package/src/prelude/index.hpp +18 -9
  24. package/src/prelude/library/console.hpp +13 -13
  25. package/src/prelude/library/error.hpp +111 -0
  26. package/src/prelude/library/global.hpp +15 -4
  27. package/src/prelude/library/performance.hpp +2 -2
  28. package/src/prelude/library/promise.hpp +121 -0
  29. package/src/prelude/library/symbol.hpp +3 -4
  30. package/src/prelude/library/timer.hpp +92 -0
  31. package/src/prelude/scheduler.hpp +145 -0
  32. package/src/prelude/types.hpp +10 -1
  33. package/src/prelude/utils/access.hpp +174 -0
  34. package/src/prelude/utils/log_any_value/array.hpp +245 -0
  35. package/src/prelude/utils/log_any_value/config.hpp +32 -0
  36. package/src/prelude/utils/log_any_value/function.hpp +37 -0
  37. package/src/prelude/utils/log_any_value/fwd.hpp +15 -0
  38. package/src/prelude/utils/log_any_value/helpers.hpp +62 -0
  39. package/src/prelude/utils/log_any_value/log_any_value.hpp +94 -0
  40. package/src/prelude/utils/log_any_value/object.hpp +119 -0
  41. package/src/prelude/utils/log_any_value/primitives.hpp +41 -0
  42. package/src/prelude/{operators.hpp → utils/operators.hpp} +29 -10
  43. package/src/prelude/{well_known_symbols.hpp → utils/well_known_symbols.hpp} +0 -1
  44. package/src/prelude/values/array.hpp +3 -2
  45. package/src/prelude/{descriptors.hpp → values/descriptors.hpp} +2 -2
  46. package/src/prelude/values/function.hpp +76 -51
  47. package/src/prelude/values/helpers/array.hpp +20 -11
  48. package/src/prelude/values/helpers/function.hpp +125 -77
  49. package/src/prelude/values/helpers/iterator.hpp +13 -7
  50. package/src/prelude/values/helpers/object.hpp +36 -6
  51. package/src/prelude/values/helpers/promise.hpp +181 -0
  52. package/src/prelude/values/helpers/string.hpp +3 -3
  53. package/src/prelude/values/helpers/symbol.hpp +2 -2
  54. package/src/prelude/values/iterator.hpp +13 -5
  55. package/src/prelude/values/object.hpp +6 -2
  56. package/src/prelude/values/promise.hpp +73 -0
  57. package/src/prelude/values/prototypes/array.hpp +16 -16
  58. package/src/prelude/values/prototypes/function.hpp +4 -4
  59. package/src/prelude/values/prototypes/iterator.hpp +11 -10
  60. package/src/prelude/values/prototypes/object.hpp +26 -0
  61. package/src/prelude/values/prototypes/promise.hpp +124 -0
  62. package/src/prelude/values/prototypes/string.hpp +26 -26
  63. package/src/prelude/values/prototypes/symbol.hpp +5 -3
  64. package/src/prelude/values/string.hpp +1 -1
  65. package/src/prelude/values/symbol.hpp +1 -1
  66. package/src/prelude/access.hpp +0 -91
  67. package/src/prelude/error.hpp +0 -31
  68. package/src/prelude/error_helpers.hpp +0 -59
  69. package/src/prelude/log_string.hpp +0 -407
@@ -1,225 +1,246 @@
1
- #pragma once
2
-
3
- #include "types.hpp"
4
- #include "any_value.hpp"
5
- #include "values/string.hpp"
6
-
7
- const bool jspp::AnyValue::is_truthy() const noexcept
8
- {
9
- switch (storage.type)
10
- {
11
- case JsType::Boolean:
12
- return storage.boolean;
13
- case JsType::Number:
14
- return storage.number != 0.0;
15
- case JsType::String:
16
- return !storage.str->value.empty();
17
- case JsType::Undefined:
18
- return false;
19
- case JsType::Null:
20
- return false;
21
- case JsType::Uninitialized:
22
- return false;
23
- default:
24
- return true;
25
- }
26
- }
27
-
28
- const bool jspp::AnyValue::is_strictly_equal_to(const AnyValue &other) const noexcept
29
- {
30
- if (storage.type == other.storage.type)
31
- {
32
- switch (storage.type)
33
- {
34
- case JsType::Boolean:
35
- return storage.boolean == other.storage.boolean;
36
- case JsType::Number:
37
- return storage.number == other.storage.number;
38
- case JsType::String:
39
- return (storage.str->value == other.storage.str->value);
40
- case JsType::Array:
41
- return (storage.array == other.storage.array);
42
- case JsType::Object:
43
- return (storage.object == other.storage.object);
44
- case JsType::Function:
45
- return (storage.function == other.storage.function);
46
- case JsType::Symbol:
47
- // Symbols are unique by reference/pointer identity
48
- return (storage.symbol == other.storage.symbol);
49
- case JsType::DataDescriptor:
50
- return (resolve_property_for_read(*this).is_strictly_equal_to(resolve_property_for_read(other)));
51
- case JsType::AccessorDescriptor:
52
- return (resolve_property_for_read(*this).is_strictly_equal_to(resolve_property_for_read(other)));
53
- default:
54
- return true;
55
- }
56
- }
57
- return false;
58
- }
59
- const bool jspp::AnyValue::is_equal_to(const AnyValue &other) const noexcept
60
- {
61
- // Implements JavaScript's Abstract Equality Comparison Algorithm (==)
62
- // Step 1: If types are the same, use strict equality (===)
63
- if (storage.type == other.storage.type)
64
- {
65
- return is_strictly_equal_to(other);
66
- }
67
- // Steps 2 & 3: null == undefined
68
- if ((is_null() && other.is_undefined()) || (is_undefined() && other.is_null()))
69
- {
70
- return true;
71
- }
72
- // Step 4 & 5: number == string
73
- if (is_number() && other.is_string())
74
- {
75
- double num_this = this->as_double();
76
- double num_other;
77
- try
78
- {
79
- const std::string &s = other.as_string()->value;
80
- // JS considers empty string or whitespace-only string to be 0
81
- if (s.empty() || std::all_of(s.begin(), s.end(), [](unsigned char c)
82
- { return std::isspace(c); }))
83
- {
84
- num_other = 0.0;
85
- }
86
- else
87
- {
88
- size_t pos;
89
- num_other = std::stod(s, &pos);
90
- // Check if the entire string was consumed, allowing for trailing whitespace
91
- while (pos < s.length() && std::isspace(static_cast<unsigned char>(s[pos])))
92
- {
93
- pos++;
94
- }
95
- if (pos != s.length())
96
- {
97
- num_other = std::numeric_limits<double>::quiet_NaN();
98
- }
99
- }
100
- }
101
- catch (...)
102
- {
103
- num_other = std::numeric_limits<double>::quiet_NaN();
104
- }
105
- return num_this == num_other;
106
- }
107
- if (is_string() && other.is_number())
108
- {
109
- // Delegate to the other operand to avoid code duplication
110
- return other.is_equal_to(*this);
111
- }
112
- // Step 6 & 7: boolean == any
113
- if (is_boolean())
114
- {
115
- // Convert boolean to number and re-compare
116
- return AnyValue::make_number(as_boolean() ? 1.0 : 0.0).is_equal_to(other);
117
- }
118
- if (other.is_boolean())
119
- {
120
- // Convert boolean to number and re-compare
121
- return is_equal_to(AnyValue::make_number(other.as_boolean() ? 1.0 : 0.0));
122
- }
123
- // Step 8 & 9: object == (string or number or symbol)
124
- // Simplified: Objects convert to primitives.
125
- if ((is_object() || is_array() || is_function()) && (other.is_string() || other.is_number() || other.is_symbol()))
126
- {
127
- // Convert object to primitive (string) and re-compare.
128
- // This is a simplification of JS's ToPrimitive.
129
- return AnyValue::make_string(to_std_string()).is_equal_to(other);
130
- }
131
- if ((other.is_object() || other.is_array() || other.is_function()) && (is_string() || is_number() || is_symbol()))
132
- {
133
- return other.is_equal_to(*this);
134
- }
135
- // Step 10: Parse datacriptor or accessor descriptor to primitive and re-compare
136
- if (is_data_descriptor() || is_accessor_descriptor())
137
- {
138
- AnyValue prim = resolve_property_for_read(*this);
139
- return prim.is_equal_to(other);
140
- }
141
- // Step 11: All other cases (e.g., object == null) are false.
142
- return false;
143
- }
144
-
145
- const jspp::AnyValue jspp::AnyValue::is_strictly_equal_to_primitive(const AnyValue &other) const noexcept
146
- {
147
- return AnyValue::make_boolean(is_strictly_equal_to(other));
148
- }
149
- const jspp::AnyValue jspp::AnyValue::is_equal_to_primitive(const AnyValue &other) const noexcept
150
- {
151
- return AnyValue::make_boolean(is_equal_to(other));
152
- }
153
-
154
- const jspp::AnyValue jspp::AnyValue::not_strictly_equal_to_primitive(const AnyValue &other) const noexcept
155
- {
156
- return AnyValue::make_boolean(!is_strictly_equal_to(other));
157
- }
158
- const jspp::AnyValue jspp::AnyValue::not_equal_to_primitive(const AnyValue &other) const noexcept
159
- {
160
- return AnyValue::make_boolean(!is_equal_to(other));
161
- }
162
-
163
- const std::string jspp::AnyValue::to_std_string() const noexcept
164
- {
165
- switch (storage.type)
166
- {
167
- case JsType::Undefined:
168
- return "undefined";
169
- case JsType::Null:
170
- return "null";
171
- case JsType::Boolean:
172
- return storage.boolean ? "true" : "false";
173
- case JsType::String:
174
- return storage.str->to_std_string();
175
- case JsType::Object:
176
- return storage.object->to_std_string();
177
- case JsType::Array:
178
- return storage.array->to_std_string();
179
- case JsType::Function:
180
- return storage.function->to_std_string();
181
- case JsType::Iterator:
182
- return storage.iterator->to_std_string();
183
- case JsType::Symbol:
184
- return storage.symbol->to_std_string();
185
- case JsType::DataDescriptor:
186
- return storage.data_desc->value->to_std_string();
187
- case JsType::AccessorDescriptor:
188
- {
189
- if (storage.accessor_desc->get.has_value())
190
- return storage.accessor_desc->get.value()({}).to_std_string();
191
- else
192
- return "undefined";
193
- }
194
- case JsType::Number:
195
- {
196
- if (std::isnan(storage.number))
197
- {
198
- return "NaN";
199
- }
200
- if (std::abs(storage.number) >= 1e21 || (std::abs(storage.number) > 0 && std::abs(storage.number) < 1e-6))
201
- {
202
- std::ostringstream oss;
203
- oss << std::scientific << std::setprecision(4) << storage.number;
204
- return oss.str();
205
- }
206
- else
207
- {
208
- std::ostringstream oss;
209
- oss << std::setprecision(6) << std::fixed << storage.number;
210
- std::string s = oss.str();
211
- s.erase(s.find_last_not_of('0') + 1, std::string::npos);
212
- if (!s.empty() && s.back() == '.')
213
- {
214
- s.pop_back();
215
- }
216
- return s;
217
- }
218
- }
219
- // Uninitialized and default should not be reached under normal circumstances
220
- case JsType::Uninitialized:
221
- return "<uninitialized>";
222
- default:
223
- return "";
224
- }
225
- }
1
+ #pragma once
2
+
3
+ #include "types.hpp"
4
+ #include "any_value.hpp"
5
+ #include "values/string.hpp"
6
+
7
+ namespace jspp
8
+ {
9
+ const bool AnyValue::is_truthy() const noexcept
10
+ {
11
+ switch (storage.type)
12
+ {
13
+ case JsType::Boolean:
14
+ return storage.boolean;
15
+ case JsType::Number:
16
+ return storage.number != 0.0;
17
+ case JsType::String:
18
+ return !storage.str->value.empty();
19
+ case JsType::Undefined:
20
+ return false;
21
+ case JsType::Null:
22
+ return false;
23
+ case JsType::Uninitialized:
24
+ return false;
25
+ default:
26
+ return true;
27
+ }
28
+ }
29
+
30
+ const bool AnyValue::is_strictly_equal_to_primitive(const AnyValue &other) const noexcept
31
+ {
32
+ if (storage.type == other.storage.type)
33
+ {
34
+ switch (storage.type)
35
+ {
36
+ case JsType::Boolean:
37
+ return storage.boolean == other.storage.boolean;
38
+ case JsType::Number:
39
+ return storage.number == other.storage.number;
40
+ case JsType::String:
41
+ return (storage.str->value == other.storage.str->value);
42
+ case JsType::Array:
43
+ return (storage.array == other.storage.array);
44
+ case JsType::Object:
45
+ return (storage.object == other.storage.object);
46
+ case JsType::Function:
47
+ return (storage.function == other.storage.function);
48
+ case JsType::Iterator:
49
+ return (storage.iterator == other.storage.iterator);
50
+ case JsType::Promise:
51
+ return (storage.promise == other.storage.promise);
52
+ case JsType::Symbol:
53
+ // Symbols are unique by reference/pointer identity
54
+ return (storage.symbol == other.storage.symbol);
55
+ case JsType::DataDescriptor:
56
+ return storage.data_desc == other.storage.data_desc;
57
+ case JsType::AccessorDescriptor:
58
+ return storage.accessor_desc == other.storage.accessor_desc;
59
+ default:
60
+ return true;
61
+ }
62
+ }
63
+ return false;
64
+ }
65
+ const bool AnyValue::is_equal_to_primitive(const AnyValue &other) const noexcept
66
+ {
67
+ // Implements JavaScript's Abstract Equality Comparison Algorithm (==)
68
+ // Step 1: If types are the same, use strict equality (===)
69
+ if (storage.type == other.storage.type)
70
+ {
71
+ return is_strictly_equal_to_primitive(other);
72
+ }
73
+ // Steps 2 & 3: null == undefined
74
+ if ((is_null() && other.is_undefined()) || (is_undefined() && other.is_null()))
75
+ {
76
+ return true;
77
+ }
78
+ // Step 4 & 5: number == string
79
+ if (is_number() && other.is_string())
80
+ {
81
+ double num_this = this->as_double();
82
+ double num_other;
83
+ try
84
+ {
85
+ const std::string &s = other.as_string()->value;
86
+ // JS considers empty string or whitespace-only string to be 0
87
+ if (s.empty() || std::all_of(s.begin(), s.end(), [](unsigned char c)
88
+ { return std::isspace(c); }))
89
+ {
90
+ num_other = 0.0;
91
+ }
92
+ else
93
+ {
94
+ size_t pos;
95
+ num_other = std::stod(s, &pos);
96
+ // Check if the entire string was consumed, allowing for trailing whitespace
97
+ while (pos < s.length() && std::isspace(static_cast<unsigned char>(s[pos])))
98
+ {
99
+ pos++;
100
+ }
101
+ if (pos != s.length())
102
+ {
103
+ num_other = std::numeric_limits<double>::quiet_NaN();
104
+ }
105
+ }
106
+ }
107
+ catch (...)
108
+ {
109
+ num_other = std::numeric_limits<double>::quiet_NaN();
110
+ }
111
+ return num_this == num_other;
112
+ }
113
+ if (is_string() && other.is_number())
114
+ {
115
+ // Delegate to the other operand to avoid code duplication
116
+ return other.is_equal_to_primitive(*this);
117
+ }
118
+ // Step 6 & 7: boolean == any
119
+ if (is_boolean())
120
+ {
121
+ // Convert boolean to number and re-compare
122
+ return AnyValue::make_number(as_boolean() ? 1.0 : 0.0).is_equal_to_primitive(other);
123
+ }
124
+ if (other.is_boolean())
125
+ {
126
+ // Convert boolean to number and re-compare
127
+ return is_equal_to_primitive(AnyValue::make_number(other.as_boolean() ? 1.0 : 0.0));
128
+ }
129
+ // Step 8 & 9: object == (string or number or symbol)
130
+ // Simplified: Objects convert to primitives.
131
+ if ((is_object() || is_array() || is_function() || is_promise() || is_iterator()) && (other.is_string() || other.is_number() || other.is_symbol()))
132
+ {
133
+ // Convert object to primitive (string) and re-compare.
134
+ // This is a simplification of JS's ToPrimitive.
135
+ return AnyValue::make_string(to_std_string()).is_equal_to_primitive(other);
136
+ }
137
+ if ((other.is_object() || other.is_array() || other.is_function() || other.is_promise() || other.is_iterator()) && (is_string() || is_number() || is_symbol()))
138
+ {
139
+ return other.is_equal_to_primitive(*this);
140
+ }
141
+ // Step 10: Datacriptor or accessor descriptor
142
+ if (is_data_descriptor() || is_accessor_descriptor())
143
+ {
144
+ return (*this).is_strictly_equal_to_primitive(other);
145
+ }
146
+ // Step 11: All other cases (e.g., object == null) are false.
147
+ return false;
148
+ }
149
+
150
+ const AnyValue AnyValue::is_strictly_equal_to(const AnyValue &other) const noexcept
151
+ {
152
+ return AnyValue::make_boolean(is_strictly_equal_to_primitive(other));
153
+ }
154
+ const AnyValue AnyValue::is_equal_to(const AnyValue &other) const noexcept
155
+ {
156
+ return AnyValue::make_boolean(is_equal_to_primitive(other));
157
+ }
158
+
159
+ const AnyValue AnyValue::not_strictly_equal_to(const AnyValue &other) const noexcept
160
+ {
161
+ return AnyValue::make_boolean(!is_strictly_equal_to_primitive(other));
162
+ }
163
+ const AnyValue AnyValue::not_equal_to(const AnyValue &other) const noexcept
164
+ {
165
+ return AnyValue::make_boolean(!is_equal_to_primitive(other));
166
+ }
167
+
168
+ const std::string AnyValue::to_std_string() const noexcept
169
+ {
170
+ switch (storage.type)
171
+ {
172
+ case JsType::Undefined:
173
+ return "undefined";
174
+ case JsType::Null:
175
+ return "null";
176
+ case JsType::Boolean:
177
+ return storage.boolean ? "true" : "false";
178
+ case JsType::String:
179
+ return storage.str->to_std_string();
180
+ case JsType::Object:
181
+ return storage.object->to_std_string();
182
+ case JsType::Array:
183
+ return storage.array->to_std_string();
184
+ case JsType::Function:
185
+ return storage.function->to_std_string();
186
+ case JsType::Iterator:
187
+ return storage.iterator->to_std_string();
188
+ case JsType::Promise:
189
+ return storage.promise->to_std_string();
190
+ case JsType::Symbol:
191
+ return storage.symbol->to_std_string();
192
+ case JsType::DataDescriptor:
193
+ return storage.data_desc->value->to_std_string();
194
+ case JsType::AccessorDescriptor:
195
+ {
196
+ if (storage.accessor_desc->get.has_value())
197
+ return storage.accessor_desc->get.value()(*this, {}).to_std_string();
198
+ else
199
+ return "undefined";
200
+ }
201
+ case JsType::Number:
202
+ {
203
+ if (std::isnan(storage.number))
204
+ {
205
+ return "NaN";
206
+ }
207
+ if (std::abs(storage.number) >= 1e21 || (std::abs(storage.number) > 0 && std::abs(storage.number) < 1e-6))
208
+ {
209
+ std::ostringstream oss;
210
+ oss << std::scientific << std::setprecision(4) << storage.number;
211
+ return oss.str();
212
+ }
213
+ else
214
+ {
215
+ std::ostringstream oss;
216
+ oss << std::setprecision(6) << std::fixed << storage.number;
217
+ std::string s = oss.str();
218
+ s.erase(s.find_last_not_of('0') + 1, std::string::npos);
219
+ if (!s.empty() && s.back() == '.')
220
+ {
221
+ s.pop_back();
222
+ }
223
+ return s;
224
+ }
225
+ }
226
+ // Uninitialized and default should not be reached under normal circumstances
227
+ case JsType::Uninitialized:
228
+ return "<uninitialized>";
229
+ default:
230
+ return "";
231
+ }
232
+ }
233
+
234
+ void AnyValue::set_prototype(const AnyValue &proto)
235
+ {
236
+ if (is_object())
237
+ {
238
+ storage.object->proto = std::make_shared<AnyValue>(proto);
239
+ }
240
+ else if (is_function())
241
+ {
242
+ storage.function->proto = std::make_shared<AnyValue>(proto);
243
+ }
244
+ }
245
+
246
+ }
@@ -0,0 +1,31 @@
1
+
2
+ #pragma once
3
+
4
+ #include "types.hpp"
5
+
6
+ namespace jspp
7
+ {
8
+ class AnyValue;
9
+
10
+ struct Exception : std::exception
11
+ {
12
+ std::shared_ptr<AnyValue> data;
13
+
14
+ explicit Exception(std::shared_ptr<AnyValue> d)
15
+ : data(std::move(d)) {}
16
+ explicit Exception(const AnyValue &value)
17
+ : data(std::make_shared<AnyValue>(value)) {}
18
+ explicit Exception(AnyValue &&value)
19
+ : data(std::make_shared<AnyValue>(std::move(value))) {}
20
+
21
+ const char *what() const noexcept override;
22
+ static Exception make_exception(const std::string &message, const std::string &name);
23
+ static AnyValue exception_to_any_value(const std::exception &ex);
24
+
25
+ // --- THROWERS
26
+ static AnyValue throw_unresolved_reference(const std::string &var_name);
27
+ static AnyValue throw_uninitialized_reference(const std::string &var_name);
28
+ static AnyValue throw_immutable_assignment();
29
+ static AnyValue throw_invalid_return_statement();
30
+ };
31
+ }
@@ -0,0 +1,49 @@
1
+ #pragma once
2
+
3
+ #include "types.hpp"
4
+ #include "exception.hpp"
5
+ #include "any_value.hpp"
6
+
7
+ const char *jspp::Exception::what() const noexcept
8
+ {
9
+ return data->to_std_string().c_str();
10
+ }
11
+
12
+ jspp::Exception jspp::Exception::make_exception(const std::string &message, const std::string &name = "Error")
13
+ {
14
+ // Use the global Error object to construct the exception
15
+ std::vector<AnyValue> args = { AnyValue::make_string(message) };
16
+ AnyValue errorObj = ::Error.construct(args);
17
+ errorObj.define_data_property("name", AnyValue::make_string(name));
18
+
19
+ return Exception(errorObj);
20
+ }
21
+ jspp::AnyValue jspp::Exception::exception_to_any_value(const std::exception &ex)
22
+ {
23
+ if (const jspp::Exception *err = dynamic_cast<const jspp::Exception *>(&ex))
24
+ {
25
+ return (*err->data);
26
+ }
27
+ else
28
+ {
29
+ return AnyValue::make_string(ex.what());
30
+ }
31
+ }
32
+
33
+ // --- THROWERS
34
+ jspp::AnyValue jspp::Exception::throw_unresolved_reference(const std::string &var_name)
35
+ {
36
+ throw Exception::make_exception(var_name + " is not defined", "ReferenceError");
37
+ }
38
+ jspp::AnyValue jspp::Exception::throw_uninitialized_reference(const std::string &var_name)
39
+ {
40
+ throw Exception::make_exception("Cannot access '" + var_name + "' before initialization", "ReferenceError");
41
+ }
42
+ jspp::AnyValue jspp::Exception::throw_immutable_assignment()
43
+ {
44
+ throw Exception::make_exception("Assignment to constant variable.", "TypeError");
45
+ }
46
+ jspp::AnyValue jspp::Exception::throw_invalid_return_statement()
47
+ {
48
+ throw Exception::make_exception("Return statements are only valid inside functions.", "SyntaxError");
49
+ }
@@ -1,7 +1,7 @@
1
1
  #pragma once
2
2
 
3
3
  #include "types.hpp"
4
- #include "well_known_symbols.hpp"
4
+ #include "utils/well_known_symbols.hpp"
5
5
 
6
6
  // values
7
7
  #include "values/symbol.hpp"
@@ -10,34 +10,43 @@
10
10
  #include "values/array.hpp"
11
11
  #include "values/function.hpp"
12
12
  #include "values/iterator.hpp"
13
+ #include "values/promise.hpp"
13
14
  #include "values/string.hpp"
14
15
 
15
- #include "error.hpp"
16
- #include "descriptors.hpp"
16
+ #include "exception.hpp"
17
+ #include "values/descriptors.hpp"
17
18
  #include "any_value.hpp"
18
19
  #include "any_value_helpers.hpp"
19
- #include "error_helpers.hpp"
20
+ #include "any_value_access.hpp"
21
+ #include "any_value_defines.hpp"
22
+ #include "library/error.hpp"
23
+ #include "exception_helpers.hpp"
24
+ #include "scheduler.hpp"
20
25
 
21
26
  #include "values/prototypes/symbol.hpp"
22
- #include "values/prototypes/string.hpp"
23
27
  #include "values/prototypes/object.hpp"
24
28
  #include "values/prototypes/array.hpp"
25
29
  #include "values/prototypes/function.hpp"
26
30
  #include "values/prototypes/iterator.hpp"
31
+ #include "values/prototypes/promise.hpp"
32
+ #include "values/prototypes/string.hpp"
27
33
 
28
34
  #include "values/helpers/symbol.hpp"
29
35
  #include "values/helpers/object.hpp"
30
36
  #include "values/helpers/array.hpp"
31
37
  #include "values/helpers/function.hpp"
32
38
  #include "values/helpers/iterator.hpp"
39
+ #include "values/helpers/promise.hpp"
33
40
  #include "values/helpers/string.hpp"
34
41
 
35
- // helpers
36
- #include "operators.hpp"
37
- #include "access.hpp"
38
- #include "log_string.hpp"
42
+ // utilities
43
+ #include "utils/operators.hpp"
44
+ #include "utils/access.hpp"
45
+ #include "utils/log_any_value/log_any_value.hpp"
39
46
 
40
47
  // js standard libraries
41
48
  #include "library/symbol.hpp"
42
49
  #include "library/console.hpp"
43
50
  #include "library/performance.hpp"
51
+ #include "library/promise.hpp"
52
+ #include "library/global.hpp"