@ugo-studio/jspp 0.1.3 → 0.1.5
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 +2 -2
- package/dist/analysis/scope.js +33 -4
- package/dist/analysis/typeAnalyzer.js +260 -21
- package/dist/ast/symbols.js +29 -0
- 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 -31
- package/dist/core/codegen/class-handlers.js +131 -0
- package/dist/core/codegen/control-flow-handlers.js +474 -0
- package/dist/core/codegen/declaration-handlers.js +36 -15
- package/dist/core/codegen/expression-handlers.js +579 -125
- package/dist/core/codegen/function-handlers.js +222 -37
- package/dist/core/codegen/helpers.js +158 -4
- package/dist/core/codegen/index.js +20 -8
- package/dist/core/codegen/literal-handlers.js +18 -6
- package/dist/core/codegen/statement-handlers.js +171 -228
- package/dist/core/codegen/visitor.js +31 -3
- package/package.json +3 -3
- package/src/prelude/any_value.hpp +510 -633
- package/src/prelude/any_value_access.hpp +151 -0
- package/src/prelude/any_value_defines.hpp +190 -0
- package/src/prelude/any_value_helpers.hpp +139 -225
- package/src/prelude/exception.hpp +32 -0
- package/src/prelude/exception_helpers.hpp +49 -0
- package/src/prelude/index.hpp +25 -9
- package/src/prelude/library/array.hpp +190 -0
- package/src/prelude/library/console.hpp +14 -13
- package/src/prelude/library/error.hpp +113 -0
- package/src/prelude/library/function.hpp +10 -0
- package/src/prelude/library/global.hpp +35 -4
- package/src/prelude/library/math.hpp +308 -0
- package/src/prelude/library/object.hpp +288 -0
- package/src/prelude/library/performance.hpp +2 -2
- package/src/prelude/library/process.hpp +39 -0
- package/src/prelude/library/promise.hpp +131 -0
- package/src/prelude/library/symbol.hpp +46 -59
- package/src/prelude/library/timer.hpp +92 -0
- package/src/prelude/scheduler.hpp +145 -0
- package/src/prelude/types.hpp +58 -1
- package/src/prelude/utils/access.hpp +345 -0
- package/src/prelude/utils/assignment_operators.hpp +99 -0
- package/src/prelude/utils/log_any_value/array.hpp +245 -0
- package/src/prelude/utils/log_any_value/config.hpp +32 -0
- package/src/prelude/utils/log_any_value/function.hpp +39 -0
- package/src/prelude/utils/log_any_value/fwd.hpp +15 -0
- package/src/prelude/utils/log_any_value/helpers.hpp +62 -0
- package/src/prelude/utils/log_any_value/log_any_value.hpp +94 -0
- package/src/prelude/utils/log_any_value/object.hpp +136 -0
- package/src/prelude/utils/log_any_value/primitives.hpp +43 -0
- package/src/prelude/utils/operators.hpp +751 -0
- package/src/prelude/utils/well_known_symbols.hpp +25 -0
- package/src/prelude/values/array.hpp +10 -7
- package/src/prelude/{descriptors.hpp → values/descriptors.hpp} +2 -2
- package/src/prelude/values/function.hpp +85 -51
- package/src/prelude/values/helpers/array.hpp +80 -35
- package/src/prelude/values/helpers/function.hpp +110 -77
- package/src/prelude/values/helpers/iterator.hpp +16 -10
- package/src/prelude/values/helpers/object.hpp +85 -10
- package/src/prelude/values/helpers/promise.hpp +181 -0
- package/src/prelude/values/helpers/string.hpp +3 -3
- package/src/prelude/values/helpers/symbol.hpp +2 -2
- package/src/prelude/values/iterator.hpp +14 -6
- package/src/prelude/values/object.hpp +14 -3
- package/src/prelude/values/promise.hpp +73 -0
- package/src/prelude/values/prototypes/array.hpp +855 -16
- package/src/prelude/values/prototypes/function.hpp +4 -4
- package/src/prelude/values/prototypes/iterator.hpp +11 -10
- package/src/prelude/values/prototypes/number.hpp +153 -0
- package/src/prelude/values/prototypes/object.hpp +26 -0
- package/src/prelude/values/prototypes/promise.hpp +134 -0
- package/src/prelude/values/prototypes/string.hpp +29 -29
- package/src/prelude/values/prototypes/symbol.hpp +22 -3
- package/src/prelude/values/shape.hpp +52 -0
- package/src/prelude/values/string.hpp +1 -1
- package/src/prelude/values/symbol.hpp +1 -1
- package/src/prelude/access.hpp +0 -91
- package/src/prelude/error.hpp +0 -31
- package/src/prelude/error_helpers.hpp +0 -59
- package/src/prelude/log_string.hpp +0 -407
- package/src/prelude/operators.hpp +0 -256
- package/src/prelude/well_known_symbols.hpp +0 -14
|
@@ -1,225 +1,139 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include "types.hpp"
|
|
4
|
-
#include "any_value.hpp"
|
|
5
|
-
#include "values/string.hpp"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
case JsType::
|
|
35
|
-
return storage
|
|
36
|
-
case JsType::
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
{
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
//
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
//
|
|
128
|
-
//
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
+
#include "exception.hpp"
|
|
7
|
+
|
|
8
|
+
namespace jspp
|
|
9
|
+
{
|
|
10
|
+
std::string AnyValue::to_std_string() const
|
|
11
|
+
{
|
|
12
|
+
switch (get_type())
|
|
13
|
+
{
|
|
14
|
+
case JsType::Undefined:
|
|
15
|
+
return "undefined";
|
|
16
|
+
case JsType::Null:
|
|
17
|
+
return "null";
|
|
18
|
+
case JsType::Boolean:
|
|
19
|
+
return std::get<bool>(storage) ? "true" : "false";
|
|
20
|
+
case JsType::String:
|
|
21
|
+
return std::get<std::shared_ptr<JsString>>(storage)->to_std_string();
|
|
22
|
+
case JsType::Object:
|
|
23
|
+
return std::get<std::shared_ptr<JsObject>>(storage)->to_std_string();
|
|
24
|
+
case JsType::Array:
|
|
25
|
+
return std::get<std::shared_ptr<JsArray>>(storage)->to_std_string();
|
|
26
|
+
case JsType::Function:
|
|
27
|
+
return std::get<std::shared_ptr<JsFunction>>(storage)->to_std_string();
|
|
28
|
+
case JsType::Iterator:
|
|
29
|
+
return std::get<std::shared_ptr<JsIterator<AnyValue>>>(storage)->to_std_string();
|
|
30
|
+
case JsType::Promise:
|
|
31
|
+
return std::get<std::shared_ptr<JsPromise>>(storage)->to_std_string();
|
|
32
|
+
case JsType::Symbol:
|
|
33
|
+
return std::get<std::shared_ptr<JsSymbol>>(storage)->to_std_string();
|
|
34
|
+
case JsType::DataDescriptor:
|
|
35
|
+
return std::get<std::shared_ptr<DataDescriptor>>(storage)->value->to_std_string();
|
|
36
|
+
case JsType::AccessorDescriptor:
|
|
37
|
+
{
|
|
38
|
+
if (std::get<std::shared_ptr<AccessorDescriptor>>(storage)->get.has_value())
|
|
39
|
+
return std::get<std::shared_ptr<AccessorDescriptor>>(storage)->get.value()(*this, {}).to_std_string();
|
|
40
|
+
else
|
|
41
|
+
return "undefined";
|
|
42
|
+
}
|
|
43
|
+
case JsType::Number:
|
|
44
|
+
{
|
|
45
|
+
double num = std::get<double>(storage);
|
|
46
|
+
if (std::isnan(num))
|
|
47
|
+
{
|
|
48
|
+
return "NaN";
|
|
49
|
+
}
|
|
50
|
+
if (std::abs(num) >= 1e21 || (std::abs(num) > 0 && std::abs(num) < 1e-6))
|
|
51
|
+
{
|
|
52
|
+
std::ostringstream oss;
|
|
53
|
+
oss << std::scientific << std::setprecision(4) << num;
|
|
54
|
+
return oss.str();
|
|
55
|
+
}
|
|
56
|
+
else
|
|
57
|
+
{
|
|
58
|
+
std::ostringstream oss;
|
|
59
|
+
oss << std::setprecision(6) << std::fixed << num;
|
|
60
|
+
std::string s = oss.str();
|
|
61
|
+
s.erase(s.find_last_not_of('0') + 1, std::string::npos);
|
|
62
|
+
if (!s.empty() && s.back() == '.')
|
|
63
|
+
{
|
|
64
|
+
s.pop_back();
|
|
65
|
+
}
|
|
66
|
+
return s;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
case JsType::Uninitialized:
|
|
70
|
+
Exception::throw_uninitialized_reference("#<Object>");
|
|
71
|
+
default:
|
|
72
|
+
return "";
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
void AnyValue::set_prototype(const AnyValue &proto)
|
|
77
|
+
{
|
|
78
|
+
if (is_object())
|
|
79
|
+
{
|
|
80
|
+
std::get<std::shared_ptr<JsObject>>(storage)->proto = std::make_shared<AnyValue>(proto);
|
|
81
|
+
}
|
|
82
|
+
else if (is_array())
|
|
83
|
+
{
|
|
84
|
+
std::get<std::shared_ptr<JsArray>>(storage)->proto = std::make_shared<AnyValue>(proto);
|
|
85
|
+
}
|
|
86
|
+
else if (is_function())
|
|
87
|
+
{
|
|
88
|
+
std::get<std::shared_ptr<JsFunction>>(storage)->proto = std::make_shared<AnyValue>(proto);
|
|
89
|
+
}
|
|
90
|
+
else if (is_uninitialized())
|
|
91
|
+
{
|
|
92
|
+
Exception::throw_uninitialized_reference("#<Object>");
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// AnyValue::call implementation
|
|
97
|
+
const AnyValue AnyValue::call(const AnyValue &thisVal, std::span<const AnyValue> args, const std::optional<std::string> &expr = std::nullopt) const
|
|
98
|
+
{
|
|
99
|
+
if (!is_function())
|
|
100
|
+
{
|
|
101
|
+
throw Exception::make_exception(expr.value_or(to_std_string()) + " is not a function", "TypeError");
|
|
102
|
+
}
|
|
103
|
+
return as_function()->call(thisVal, args); // Convert to function before calling, to avoid an infinite loop
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// AnyValue::construct implementation
|
|
107
|
+
const AnyValue AnyValue::construct(std::span<const AnyValue> args, const std::optional<std::string> &name) const
|
|
108
|
+
{
|
|
109
|
+
if (!is_function() || !as_function()->is_constructor)
|
|
110
|
+
{
|
|
111
|
+
// std::cerr << "Construct fail: " << name.value_or(to_std_string()) << " is_function=" << is_function() << " is_constructor=" << (is_function() ? as_function()->is_constructor : false) << std::endl;
|
|
112
|
+
throw Exception::make_exception(name.value_or(to_std_string()) + " is not a constructor", "TypeError");
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// 1. Get prototype
|
|
116
|
+
AnyValue proto = get_own_property("prototype");
|
|
117
|
+
// If prototype is not an object, default to a plain object (which ideally inherits from Object.prototype)
|
|
118
|
+
// Here we just make a plain object.
|
|
119
|
+
if (!proto.is_object())
|
|
120
|
+
{
|
|
121
|
+
proto = AnyValue::make_object({});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// 2. Create instance
|
|
125
|
+
AnyValue instance = AnyValue::make_object_with_proto({}, proto);
|
|
126
|
+
|
|
127
|
+
// 3. Call function
|
|
128
|
+
// We pass 'instance' as 'this'
|
|
129
|
+
AnyValue result = call(instance, args);
|
|
130
|
+
|
|
131
|
+
// 4. Return result if object, else instance
|
|
132
|
+
if (result.is_object() || result.is_function() || result.is_array() || result.is_promise())
|
|
133
|
+
{
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
136
|
+
return instance;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
|
|
2
|
+
#pragma once
|
|
3
|
+
|
|
4
|
+
#include <exception>
|
|
5
|
+
#include "types.hpp"
|
|
6
|
+
|
|
7
|
+
namespace jspp
|
|
8
|
+
{
|
|
9
|
+
class AnyValue;
|
|
10
|
+
|
|
11
|
+
struct Exception : std::exception
|
|
12
|
+
{
|
|
13
|
+
std::shared_ptr<AnyValue> data;
|
|
14
|
+
|
|
15
|
+
explicit Exception(std::shared_ptr<AnyValue> d)
|
|
16
|
+
: data(std::move(d)) {}
|
|
17
|
+
explicit Exception(const AnyValue &value)
|
|
18
|
+
: data(std::make_shared<AnyValue>(value)) {}
|
|
19
|
+
explicit Exception(AnyValue &&value)
|
|
20
|
+
: data(std::make_shared<AnyValue>(std::move(value))) {}
|
|
21
|
+
|
|
22
|
+
const char *what() const noexcept override;
|
|
23
|
+
static Exception make_exception(const std::string &message, const std::string &name);
|
|
24
|
+
static AnyValue exception_to_any_value(const std::exception &ex);
|
|
25
|
+
|
|
26
|
+
// --- THROWERS
|
|
27
|
+
static AnyValue throw_unresolved_reference(const std::string &var_name);
|
|
28
|
+
static AnyValue throw_uninitialized_reference(const std::string &var_name);
|
|
29
|
+
static AnyValue throw_immutable_assignment();
|
|
30
|
+
static AnyValue throw_invalid_return_statement();
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -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, name);
|
|
17
|
+
errorObj.define_data_property("name", AnyValue::make_string(name), true, false, true);
|
|
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
|
+
}
|
package/src/prelude/index.hpp
CHANGED
|
@@ -1,43 +1,59 @@
|
|
|
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
|
+
#include "values/shape.hpp"
|
|
7
8
|
#include "values/symbol.hpp"
|
|
8
9
|
#include "values/non_values.hpp"
|
|
9
10
|
#include "values/object.hpp"
|
|
10
11
|
#include "values/array.hpp"
|
|
11
12
|
#include "values/function.hpp"
|
|
12
13
|
#include "values/iterator.hpp"
|
|
14
|
+
#include "values/promise.hpp"
|
|
13
15
|
#include "values/string.hpp"
|
|
14
16
|
|
|
15
|
-
#include "error.hpp"
|
|
16
|
-
#include "descriptors.hpp"
|
|
17
17
|
#include "any_value.hpp"
|
|
18
|
+
#include "values/descriptors.hpp"
|
|
18
19
|
#include "any_value_helpers.hpp"
|
|
19
|
-
#include "
|
|
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"
|
|
33
|
+
#include "values/prototypes/number.hpp"
|
|
27
34
|
|
|
28
35
|
#include "values/helpers/symbol.hpp"
|
|
29
36
|
#include "values/helpers/object.hpp"
|
|
30
37
|
#include "values/helpers/array.hpp"
|
|
31
38
|
#include "values/helpers/function.hpp"
|
|
32
39
|
#include "values/helpers/iterator.hpp"
|
|
40
|
+
#include "values/helpers/promise.hpp"
|
|
33
41
|
#include "values/helpers/string.hpp"
|
|
34
42
|
|
|
35
|
-
//
|
|
36
|
-
#include "operators.hpp"
|
|
37
|
-
#include "
|
|
38
|
-
#include "
|
|
43
|
+
// utilities
|
|
44
|
+
#include "utils/operators.hpp"
|
|
45
|
+
#include "utils/assignment_operators.hpp"
|
|
46
|
+
#include "utils/access.hpp"
|
|
47
|
+
#include "utils/log_any_value/log_any_value.hpp"
|
|
39
48
|
|
|
40
49
|
// js standard libraries
|
|
41
50
|
#include "library/symbol.hpp"
|
|
51
|
+
#include "library/process.hpp"
|
|
52
|
+
#include "library/function.hpp"
|
|
42
53
|
#include "library/console.hpp"
|
|
43
54
|
#include "library/performance.hpp"
|
|
55
|
+
#include "library/promise.hpp"
|
|
56
|
+
#include "library/math.hpp"
|
|
57
|
+
#include "library/object.hpp"
|
|
58
|
+
#include "library/array.hpp"
|
|
59
|
+
#include "library/global.hpp"
|