@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
@@ -3,101 +3,188 @@
3
3
  #include "types.hpp"
4
4
  #include "any_value.hpp"
5
5
 
6
- jspp::AnyValue jspp::AnyValue::get_own_property(const std::string &key) const
6
+ namespace jspp
7
7
  {
8
- return get_property_with_receiver(key, *this);
9
- }
10
- jspp::AnyValue jspp::AnyValue::get_own_property(uint32_t idx) const noexcept
11
- {
12
- switch (storage.type)
8
+ AnyValue AnyValue::get_own_property(const std::string &key) const
13
9
  {
14
- case JsType::Array:
15
- return storage.array->get_property(idx);
16
- case JsType::String:
17
- return storage.str->get_property(idx);
18
- default:
19
- return get_own_property(std::to_string(idx));
10
+ return get_property_with_receiver(key, *this);
20
11
  }
21
- }
22
- jspp::AnyValue jspp::AnyValue::get_own_property(const AnyValue &key) const noexcept
23
- {
24
- if (key.storage.type == JsType::Number && storage.type == JsType::Array)
25
- return storage.array->get_property(key.storage.number);
26
- if (key.storage.type == JsType::Number && storage.type == JsType::String)
27
- return storage.str->get_property(key.storage.number);
12
+ bool AnyValue::has_property(const std::string &key) const
13
+ {
14
+ switch (get_type())
15
+ {
16
+ case JsType::Object:
17
+ return std::get<std::shared_ptr<JsObject>>(storage)->has_property(key);
18
+ case JsType::Array:
19
+ return std::get<std::shared_ptr<JsArray>>(storage)->has_property(key);
20
+ case JsType::Function:
21
+ return std::get<std::shared_ptr<JsFunction>>(storage)->has_property(key);
22
+ case JsType::Promise:
23
+ // Promises don't have their own props usually, but could.
24
+ return false;
25
+ case JsType::Iterator:
26
+ return false;
27
+ case JsType::AsyncIterator:
28
+ return false;
29
+ case JsType::Symbol:
30
+ return false;
31
+ case JsType::String:
32
+ if (key == "length")
33
+ return true;
34
+ if (JsArray::is_array_index(key))
35
+ {
36
+ uint32_t idx = static_cast<uint32_t>(std::stoull(key));
37
+ return idx < std::get<std::shared_ptr<JsString>>(storage)->value.length();
38
+ }
39
+ return false;
40
+ case JsType::Number:
41
+ return false;
42
+ case JsType::Uninitialized:
43
+ Exception::throw_uninitialized_reference("#<Object>");
44
+ return false;
45
+ default:
46
+ return false;
47
+ }
48
+ }
49
+ AnyValue AnyValue::get_own_property(uint32_t idx) const
50
+ {
51
+ switch (storage.index())
52
+ {
53
+ case 7: // Array
54
+ return std::get<std::shared_ptr<JsArray>>(storage)->get_property(idx);
55
+ case 5: // String
56
+ return std::get<std::shared_ptr<JsString>>(storage)->get_property(idx);
57
+ case 4: // Number
58
+ return get_own_property(std::to_string(idx));
59
+ default:
60
+ return get_own_property(std::to_string(idx));
61
+ }
62
+ }
63
+ AnyValue AnyValue::get_own_property(const AnyValue &key) const
64
+ {
65
+ if (key.is_number() && is_array())
66
+ return std::get<std::shared_ptr<JsArray>>(storage)->get_property(key.as_double());
67
+ if (key.is_number() && is_string())
68
+ return std::get<std::shared_ptr<JsString>>(storage)->get_property(key.as_double());
28
69
 
29
- // If the key is a Symbol, use its internal key string
30
- if (key.storage.type == JsType::Symbol)
31
- return get_own_property(key.storage.symbol->key);
70
+ // If the key is a Symbol, use its internal key string
71
+ if (key.is_symbol())
72
+ return get_own_property(key.as_symbol()->key);
32
73
 
33
- return get_own_property(key.to_std_string());
34
- }
74
+ return get_own_property(key.to_std_string());
75
+ }
35
76
 
36
- jspp::AnyValue jspp::AnyValue::get_property_with_receiver(const std::string &key, const AnyValue &receiver) const
37
- {
38
- switch (storage.type)
77
+ AnyValue AnyValue::get_property_with_receiver(const std::string &key, const AnyValue &receiver) const
39
78
  {
40
- case JsType::Object:
41
- return storage.object->get_property(key, receiver);
42
- case JsType::Array:
43
- return storage.array->get_property(key, receiver);
44
- case JsType::Function:
45
- return storage.function->get_property(key, receiver);
46
- case JsType::Promise:
47
- return storage.promise->get_property(key, receiver);
48
- case JsType::Iterator:
49
- return storage.iterator->get_property(key, receiver);
50
- case JsType::Symbol:
51
- return storage.symbol->get_property(key, receiver);
52
- case JsType::String:
53
- return storage.str->get_property(key, receiver);
54
- case JsType::Undefined:
55
- throw Exception::make_exception("Cannot read properties of undefined (reading '" + key + "')", "TypeError");
56
- case JsType::Null:
57
- throw Exception::make_exception("Cannot read properties of null (reading '" + key + "')", "TypeError");
58
- default:
59
- return AnyValue::make_undefined();
79
+ switch (get_type())
80
+ {
81
+ case JsType::Object:
82
+ return std::get<std::shared_ptr<JsObject>>(storage)->get_property(key, receiver);
83
+ case JsType::Array:
84
+ return std::get<std::shared_ptr<JsArray>>(storage)->get_property(key, receiver);
85
+ case JsType::Function:
86
+ return std::get<std::shared_ptr<JsFunction>>(storage)->get_property(key, receiver);
87
+ case JsType::Promise:
88
+ return std::get<std::shared_ptr<JsPromise>>(storage)->get_property(key, receiver);
89
+ case JsType::Iterator:
90
+ return std::get<std::shared_ptr<JsIterator<AnyValue>>>(storage)->get_property(key, receiver);
91
+ case JsType::AsyncIterator:
92
+ return std::get<std::shared_ptr<JsAsyncIterator<AnyValue>>>(storage)->get_property(key, receiver);
93
+ case JsType::Symbol:
94
+ return std::get<std::shared_ptr<JsSymbol>>(storage)->get_property(key, receiver);
95
+ case JsType::String:
96
+ return std::get<std::shared_ptr<JsString>>(storage)->get_property(key, receiver);
97
+ case JsType::Number:
98
+ {
99
+ auto proto_it = NumberPrototypes::get(key, std::get<double>(storage));
100
+ if (proto_it.has_value())
101
+ {
102
+ return AnyValue::resolve_property_for_read(proto_it.value(), receiver, key);
103
+ }
104
+ return AnyValue::make_undefined();
105
+ }
106
+ case JsType::Undefined:
107
+ throw Exception::make_exception("Cannot read properties of undefined (reading '" + key + "')", "TypeError");
108
+ case JsType::Null:
109
+ throw Exception::make_exception("Cannot read properties of null (reading '" + key + "')", "TypeError");
110
+ case JsType::Uninitialized:
111
+ Exception::throw_uninitialized_reference("#<Object>");
112
+ default:
113
+ return AnyValue::make_undefined();
114
+ }
60
115
  }
61
- }
62
116
 
63
- jspp::AnyValue jspp::AnyValue::set_own_property(const std::string &key, const AnyValue &value) const
64
- {
65
- switch (storage.type)
117
+ AnyValue AnyValue::set_own_property(const std::string &key, const AnyValue &value) const
66
118
  {
67
- case JsType::Object:
68
- return storage.object->set_property(key, value, *this);
69
- case JsType::Array:
70
- return storage.array->set_property(key, value, *this);
71
- case JsType::Function:
72
- return storage.function->set_property(key, value, *this);
73
- case JsType::Promise:
74
- return storage.promise->set_property(key, value, *this);
75
- case JsType::Undefined:
76
- throw Exception::make_exception("Cannot set properties of undefined (setting '" + key + "')", "TypeError");
77
- case JsType::Null:
78
- throw Exception::make_exception("Cannot set properties of null (setting '" + key + "')", "TypeError");
79
- default:
80
- return value;
119
+ switch (get_type())
120
+ {
121
+ case JsType::Object:
122
+ return std::get<std::shared_ptr<JsObject>>(storage)->set_property(key, value, *this);
123
+ case JsType::Array:
124
+ return std::get<std::shared_ptr<JsArray>>(storage)->set_property(key, value, *this);
125
+ case JsType::Function:
126
+ return std::get<std::shared_ptr<JsFunction>>(storage)->set_property(key, value, *this);
127
+ case JsType::Promise:
128
+ return std::get<std::shared_ptr<JsPromise>>(storage)->set_property(key, value, *this);
129
+ case JsType::Undefined:
130
+ throw Exception::make_exception("Cannot set properties of undefined (setting '" + key + "')", "TypeError");
131
+ case JsType::Null:
132
+ throw Exception::make_exception("Cannot set properties of null (setting '" + key + "')", "TypeError");
133
+ default:
134
+ return value;
135
+ }
81
136
  }
82
- }
83
- jspp::AnyValue jspp::AnyValue::set_own_property(uint32_t idx, const AnyValue &value) const
84
- {
85
- if (storage.type == JsType::Array)
137
+ AnyValue AnyValue::set_own_property(uint32_t idx, const AnyValue &value) const
86
138
  {
87
- return storage.array->set_property(idx, value);
139
+ if (is_array())
140
+ {
141
+ return std::get<std::shared_ptr<JsArray>>(storage)->set_property(idx, value);
142
+ }
143
+ return set_own_property(std::to_string(idx), value);
88
144
  }
89
- return set_own_property(std::to_string(idx), value);
90
- }
91
- jspp::AnyValue jspp::AnyValue::set_own_property(const AnyValue &key, const AnyValue &value) const
92
- {
93
- if (key.storage.type == JsType::Number && storage.type == JsType::Array)
145
+ AnyValue AnyValue::set_own_property(const AnyValue &key, const AnyValue &value) const
146
+ {
147
+ if (key.is_number() && is_array())
148
+ {
149
+ return std::get<std::shared_ptr<JsArray>>(storage)->set_property(key.as_double(), value);
150
+ }
151
+
152
+ // If the key is a Symbol, use its internal key string
153
+ if (key.is_symbol())
154
+ return set_own_property(key.as_symbol()->key, value);
155
+
156
+ return set_own_property(key.to_std_string(), value);
157
+ }
158
+
159
+ AnyValue AnyValue::call_own_property(const std::string &key, std::span<const AnyValue> args) const
160
+ {
161
+ return get_own_property(key).call((*this), args, key);
162
+ }
163
+ AnyValue AnyValue::call_own_property(uint32_t idx, std::span<const AnyValue> args) const
94
164
  {
95
- return storage.array->set_property(key.storage.number, value);
165
+ switch (storage.index())
166
+ {
167
+ case 7: // Array
168
+ return std::get<std::shared_ptr<JsArray>>(storage)->get_property(idx).call((*this), args, "[" + std::to_string(idx) + "]");
169
+ case 5: // String
170
+ return std::get<std::shared_ptr<JsString>>(storage)->get_property(idx).call((*this), args, "[" + std::to_string(idx) + "]");
171
+ case 4: // Number
172
+ return call_own_property(std::to_string(idx), args);
173
+ default:
174
+ return call_own_property(std::to_string(idx), args);
175
+ }
96
176
  }
177
+ AnyValue AnyValue::call_own_property(const AnyValue &key, std::span<const AnyValue> args) const
178
+ {
179
+ if (key.is_number() && is_array())
180
+ return std::get<std::shared_ptr<JsArray>>(storage)->get_property(key.as_double()).call((*this), args, "[" + key.to_std_string() + "]");
181
+ if (key.is_number() && is_string())
182
+ return std::get<std::shared_ptr<JsString>>(storage)->get_property(key.as_double()).call((*this), args, "[" + key.to_std_string() + "]");
97
183
 
98
- // If the key is a Symbol, use its internal key string
99
- if (key.storage.type == JsType::Symbol)
100
- return set_own_property(key.storage.symbol->key, value);
184
+ // If the key is a Symbol, use its internal key string
185
+ if (key.is_symbol())
186
+ return call_own_property(key.as_symbol()->key, args);
101
187
 
102
- return set_own_property(key.to_std_string(), value);
103
- }
188
+ return call_own_property(key.to_std_string(), args);
189
+ }
190
+ }
@@ -7,16 +7,25 @@
7
7
 
8
8
  namespace jspp
9
9
  {
10
-
11
10
  inline void AnyValue::define_data_property(const std::string &key, const AnyValue &value)
12
11
  {
13
12
  if (is_object())
14
13
  {
15
- storage.object->props[key] = value;
14
+ auto obj = std::get<std::shared_ptr<JsObject>>(storage);
15
+ auto offset = obj->shape->get_offset(key);
16
+ if (offset.has_value())
17
+ {
18
+ obj->storage[offset.value()] = value;
19
+ }
20
+ else
21
+ {
22
+ obj->shape = obj->shape->transition(key);
23
+ obj->storage.push_back(value);
24
+ }
16
25
  }
17
26
  else if (is_function())
18
27
  {
19
- storage.function->props[key] = value;
28
+ std::get<std::shared_ptr<JsFunction>>(storage)->props[key] = value;
20
29
  }
21
30
  }
22
31
 
@@ -37,42 +46,56 @@ namespace jspp
37
46
  {
38
47
  if (is_object())
39
48
  {
40
- auto &props = storage.object->props;
41
- auto it = props.find(key);
42
- if (it != props.end() && it->second.is_accessor_descriptor())
49
+ auto obj = std::get<std::shared_ptr<JsObject>>(storage);
50
+ auto offset = obj->shape->get_offset(key);
51
+
52
+ if (offset.has_value())
43
53
  {
44
- auto desc = it->second.as_accessor_descriptor();
45
- desc->get = [getter](const AnyValue &thisVal, const std::vector<AnyValue> &args) -> AnyValue
54
+ auto &val = obj->storage[offset.value()];
55
+ if (val.is_accessor_descriptor())
46
56
  {
47
- return getter.as_function()->call(thisVal, args);
48
- };
57
+ auto desc = val.as_accessor_descriptor();
58
+ desc->get = [getter](const AnyValue &thisVal, std::span<const AnyValue> args) -> AnyValue
59
+ {
60
+ return getter.call(thisVal, args);
61
+ };
62
+ }
63
+ else
64
+ {
65
+ auto getFunc = [getter](const AnyValue &thisVal, std::span<const AnyValue> args) -> AnyValue
66
+ {
67
+ return getter.call(thisVal, args);
68
+ };
69
+ obj->storage[offset.value()] = AnyValue::make_accessor_descriptor(getFunc, std::nullopt, true, true);
70
+ }
49
71
  }
50
72
  else
51
73
  {
52
- auto getFunc = [getter](const AnyValue &thisVal, const std::vector<AnyValue> &args) -> AnyValue
74
+ auto getFunc = [getter](const AnyValue &thisVal, std::span<const AnyValue> args) -> AnyValue
53
75
  {
54
- return getter.as_function()->call(thisVal, args);
76
+ return getter.call(thisVal, args);
55
77
  };
56
- props[key] = AnyValue::make_accessor_descriptor(getFunc, std::nullopt, true, true);
78
+ obj->shape = obj->shape->transition(key);
79
+ obj->storage.push_back(AnyValue::make_accessor_descriptor(getFunc, std::nullopt, true, true));
57
80
  }
58
81
  }
59
82
  else if (is_function())
60
83
  {
61
- auto &props = storage.function->props;
84
+ auto &props = std::get<std::shared_ptr<JsFunction>>(storage)->props;
62
85
  auto it = props.find(key);
63
86
  if (it != props.end() && it->second.is_accessor_descriptor())
64
87
  {
65
88
  auto desc = it->second.as_accessor_descriptor();
66
- desc->get = [getter](const AnyValue &thisVal, const std::vector<AnyValue> &args) -> AnyValue
89
+ desc->get = [getter](const AnyValue &thisVal, std::span<const AnyValue> args) -> AnyValue
67
90
  {
68
- return getter.as_function()->call(thisVal, args);
91
+ return getter.call(thisVal, args);
69
92
  };
70
93
  }
71
94
  else
72
95
  {
73
- auto getFunc = [getter](const AnyValue &thisVal, const std::vector<AnyValue> &args) -> AnyValue
96
+ auto getFunc = [getter](const AnyValue &thisVal, std::span<const AnyValue> args) -> AnyValue
74
97
  {
75
- return getter.as_function()->call(thisVal, args);
98
+ return getter.call(thisVal, args);
76
99
  };
77
100
  props[key] = AnyValue::make_accessor_descriptor(getFunc, std::nullopt, true, true);
78
101
  }
@@ -91,50 +114,66 @@ namespace jspp
91
114
  {
92
115
  if (is_object())
93
116
  {
94
- auto &props = storage.object->props;
95
- auto it = props.find(key);
96
- if (it != props.end() && it->second.is_accessor_descriptor())
117
+ auto obj = std::get<std::shared_ptr<JsObject>>(storage);
118
+ auto offset = obj->shape->get_offset(key);
119
+
120
+ if (offset.has_value())
97
121
  {
98
- auto desc = it->second.as_accessor_descriptor();
99
- desc->set = [setter](const AnyValue &thisVal, const std::vector<AnyValue> &args) -> AnyValue
122
+ auto &val = obj->storage[offset.value()];
123
+ if (val.is_accessor_descriptor())
100
124
  {
101
- if (args.empty())
102
- return AnyValue::make_undefined();
103
- return setter.as_function()->call(thisVal, args);
104
- };
125
+ auto desc = val.as_accessor_descriptor();
126
+ desc->set = [setter](const AnyValue &thisVal, std::span<const AnyValue> args) -> AnyValue
127
+ {
128
+ if (args.empty())
129
+ return AnyValue::make_undefined();
130
+ return setter.call(thisVal, args);
131
+ };
132
+ }
133
+ else
134
+ {
135
+ auto setFunc = [setter](const AnyValue &thisVal, std::span<const AnyValue> args) -> AnyValue
136
+ {
137
+ if (args.empty())
138
+ return AnyValue::make_undefined();
139
+ return setter.call(thisVal, args);
140
+ };
141
+ obj->storage[offset.value()] = AnyValue::make_accessor_descriptor(std::nullopt, setFunc, true, true);
142
+ }
105
143
  }
106
144
  else
107
145
  {
108
- auto setFunc = [setter](const AnyValue &thisVal, const std::vector<AnyValue> &args) -> AnyValue
146
+ auto setFunc = [setter](const AnyValue &thisVal, std::span<const AnyValue> args) -> AnyValue
109
147
  {
110
148
  if (args.empty())
111
149
  return AnyValue::make_undefined();
112
- return setter.as_function()->call(thisVal, args);
150
+ return setter.call(thisVal, args);
113
151
  };
114
- props[key] = AnyValue::make_accessor_descriptor(std::nullopt, setFunc, true, true);
152
+ obj->shape = obj->shape->transition(key);
153
+ obj->storage.push_back(AnyValue::make_accessor_descriptor(std::nullopt, setFunc, true, true));
115
154
  }
116
155
  }
117
156
  else if (is_function())
118
157
  {
119
- auto &props = storage.function->props;
158
+ auto &props = std::get<std::shared_ptr<JsFunction>>(storage)->props;
120
159
  auto it = props.find(key);
121
160
  if (it != props.end() && it->second.is_accessor_descriptor())
122
161
  {
123
162
  auto desc = it->second.as_accessor_descriptor();
124
- desc->set = [setter](const AnyValue &thisVal, const std::vector<AnyValue> &args) -> AnyValue
163
+ desc->set = [setter](const AnyValue &thisVal, std::span<const AnyValue> args) -> AnyValue
125
164
  {
126
165
  if (args.empty())
127
166
  return AnyValue::make_undefined();
128
- return setter.as_function()->call(thisVal, args);
167
+ return setter.call(thisVal, args);
129
168
  };
130
169
  }
131
170
  else
132
171
  {
133
- auto setFunc = [setter](const AnyValue &thisVal, const std::vector<AnyValue> &args) -> AnyValue
172
+ auto setFunc = [setter](const AnyValue &thisVal, std::span<const AnyValue> args) -> AnyValue
134
173
  {
135
174
  if (args.empty())
136
175
  return AnyValue::make_undefined();
137
- return setter.as_function()->call(thisVal, args);
176
+ return setter.call(thisVal, args);
138
177
  };
139
178
  props[key] = AnyValue::make_accessor_descriptor(std::nullopt, setFunc, true, true);
140
179
  }