@isolated-vm/experimental 0.0.9 → 0.0.10

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 (152) hide show
  1. package/addon/CMakeLists.txt +1 -1
  2. package/addon/handle/local_of.cc +150 -0
  3. package/addon/handle/types.cc +8 -137
  4. package/addon/handle/value_of.cc +82 -27
  5. package/addon/support/callback_info.cc +5 -5
  6. package/addon/support/callback_storage.cc +2 -2
  7. package/addon/support/free_function.cc +2 -2
  8. package/addon/support/initialize.cc +2 -2
  9. package/addon/transfer/accept.cc +84 -64
  10. package/addon/transfer/visit.cc +90 -47
  11. package/addon/value/array.cc +6 -6
  12. package/addon/value/array_buffer.cc +27 -18
  13. package/addon/value/function.cc +5 -5
  14. package/addon/value/function.h.cc +5 -5
  15. package/addon/value/object.cc +3 -3
  16. package/addon/value/primitive.cc +36 -36
  17. package/addon/value/prototype.cc +7 -7
  18. package/addon/value/record.cc +20 -20
  19. package/addon/value/value.cc +1 -1
  20. package/addon/value/vector.cc +9 -9
  21. package/backend/backend.d.cts +9 -9
  22. package/dist/frontend/agent.d.ts +1 -0
  23. package/dist/frontend/agent.d.ts.map +1 -1
  24. package/dist/frontend/agent.js.map +1 -1
  25. package/dist/frontend/module.d.ts +1 -1
  26. package/dist/frontend/module.d.ts.map +1 -1
  27. package/dist/frontend/module.js.map +1 -1
  28. package/dist/frontend/reference.d.ts +3 -3
  29. package/dist/frontend/reference.d.ts.map +1 -1
  30. package/dist/test/00.agent/00.prerequisites.d.ts +2 -0
  31. package/dist/test/00.agent/00.prerequisites.d.ts.map +1 -0
  32. package/dist/test/00.agent/00.prerequisites.js +25 -0
  33. package/dist/test/00.agent/00.prerequisites.js.map +1 -0
  34. package/dist/test/00.agent/10.clock.d.ts +2 -0
  35. package/dist/test/00.agent/10.clock.d.ts.map +1 -0
  36. package/dist/test/{00.datetime.js → 00.agent/10.clock.js} +8 -8
  37. package/dist/test/00.agent/10.clock.js.map +1 -0
  38. package/dist/test/00.agent/10.random.d.ts +2 -0
  39. package/dist/test/00.agent/10.random.d.ts.map +1 -0
  40. package/dist/test/{00.random.js → 00.agent/10.random.js} +4 -4
  41. package/dist/test/00.agent/10.random.js.map +1 -0
  42. package/dist/test/10.transfer/00.primitives.d.ts +2 -0
  43. package/dist/test/10.transfer/00.primitives.d.ts.map +1 -0
  44. package/dist/test/10.transfer/00.primitives.js +54 -0
  45. package/dist/test/10.transfer/00.primitives.js.map +1 -0
  46. package/dist/test/10.transfer/10.array_buffer.d.ts +2 -0
  47. package/dist/test/10.transfer/10.array_buffer.d.ts.map +1 -0
  48. package/dist/test/{20.array_buffer.js → 10.transfer/10.array_buffer.js} +69 -64
  49. package/dist/test/10.transfer/10.array_buffer.js.map +1 -0
  50. package/dist/test/10.transfer/50.interceptors.d.ts +2 -0
  51. package/dist/test/10.transfer/50.interceptors.d.ts.map +1 -0
  52. package/dist/test/10.transfer/50.interceptors.js +108 -0
  53. package/dist/test/10.transfer/50.interceptors.js.map +1 -0
  54. package/dist/test/10.transfer/90.regressions.d.ts +2 -0
  55. package/dist/test/10.transfer/90.regressions.d.ts.map +1 -0
  56. package/dist/test/10.transfer/90.regressions.js +72 -0
  57. package/dist/test/10.transfer/90.regressions.js.map +1 -0
  58. package/dist/test/20.intrinsics/00.script.d.ts +2 -0
  59. package/dist/test/20.intrinsics/00.script.d.ts.map +1 -0
  60. package/dist/test/{10.script.js → 20.intrinsics/00.script.js} +7 -7
  61. package/dist/test/20.intrinsics/00.script.js.map +1 -0
  62. package/dist/test/20.intrinsics/05.global.d.ts.map +1 -0
  63. package/dist/test/{05.global.js → 20.intrinsics/05.global.js} +5 -5
  64. package/dist/test/20.intrinsics/05.global.js.map +1 -0
  65. package/dist/test/20.intrinsics/10.reference.d.ts.map +1 -0
  66. package/dist/test/{10.reference.js → 20.intrinsics/10.reference.js} +15 -15
  67. package/dist/test/20.intrinsics/10.reference.js.map +1 -0
  68. package/dist/test/20.intrinsics/20.module.d.ts +2 -0
  69. package/dist/test/20.intrinsics/20.module.d.ts.map +1 -0
  70. package/dist/test/{10.module.js → 20.intrinsics/20.module.js} +18 -18
  71. package/dist/test/20.intrinsics/20.module.js.map +1 -0
  72. package/dist/test/50.features/50.timers.d.ts.map +1 -0
  73. package/dist/test/{50.timers.js → 50.features/50.timers.js} +8 -8
  74. package/dist/test/50.features/50.timers.js.map +1 -0
  75. package/dist/test/50.features/90.i18n.d.ts +2 -0
  76. package/dist/test/50.features/90.i18n.d.ts.map +1 -0
  77. package/dist/test/{99.i18n.js → 50.features/90.i18n.js} +6 -6
  78. package/dist/test/50.features/90.i18n.js.map +1 -0
  79. package/dist/test/90.isolation/00.dispose.d.ts +1 -1
  80. package/dist/test/90.isolation/00.dispose.d.ts.map +1 -1
  81. package/dist/test/90.isolation/00.dispose.js +23 -5
  82. package/dist/test/90.isolation/00.dispose.js.map +1 -1
  83. package/dist/test/90.isolation/10.memory.d.ts +2 -0
  84. package/dist/test/90.isolation/10.memory.d.ts.map +1 -0
  85. package/dist/test/90.isolation/10.memory.js +31 -0
  86. package/dist/test/90.isolation/10.memory.js.map +1 -0
  87. package/dist/test/fixtures.js +2 -2
  88. package/dist/test/fixtures.js.map +1 -1
  89. package/dist/test/glob.d.ts +2 -0
  90. package/dist/test/glob.d.ts.map +1 -0
  91. package/dist/test/glob.js +11 -0
  92. package/dist/test/glob.js.map +1 -0
  93. package/dist/tsconfig.tsbuildinfo +1 -1
  94. package/dist/utility/completion.d.ts +2 -1
  95. package/dist/utility/completion.d.ts.map +1 -1
  96. package/dist/utility/completion.js +4 -0
  97. package/dist/utility/completion.js.map +1 -1
  98. package/frontend/agent.ts +1 -0
  99. package/frontend/module.ts +1 -1
  100. package/frontend/reference.ts +3 -3
  101. package/package.json +13 -13
  102. package/test/00.agent/00.prerequisites.ts +12 -0
  103. package/test/{00.datetime.ts → 00.agent/10.clock.ts} +7 -7
  104. package/test/{00.random.ts → 00.agent/10.random.ts} +3 -3
  105. package/test/10.transfer/00.primitives.ts +47 -0
  106. package/test/{20.array_buffer.ts → 10.transfer/10.array_buffer.ts} +40 -35
  107. package/test/10.transfer/50.interceptors.ts +63 -0
  108. package/test/10.transfer/90.regressions.ts +38 -0
  109. package/test/{10.script.ts → 20.intrinsics/00.script.ts} +6 -6
  110. package/test/{05.global.ts → 20.intrinsics/05.global.ts} +5 -5
  111. package/test/{10.reference.ts → 20.intrinsics/10.reference.ts} +18 -17
  112. package/test/{10.module.ts → 20.intrinsics/20.module.ts} +17 -17
  113. package/test/{50.timers.ts → 50.features/50.timers.ts} +8 -8
  114. package/test/{99.i18n.ts → 50.features/90.i18n.ts} +5 -5
  115. package/test/90.isolation/00.dispose.ts +12 -5
  116. package/test/90.isolation/10.memory.ts +19 -0
  117. package/test/fixtures.ts +4 -4
  118. package/test/glob.ts +11 -0
  119. package/utility/completion.ts +6 -1
  120. package/addon/handle/bound_value.cc +0 -45
  121. package/dist/test/00.datetime.d.ts +0 -2
  122. package/dist/test/00.datetime.d.ts.map +0 -1
  123. package/dist/test/00.datetime.js.map +0 -1
  124. package/dist/test/00.random.d.ts +0 -2
  125. package/dist/test/00.random.d.ts.map +0 -1
  126. package/dist/test/00.random.js.map +0 -1
  127. package/dist/test/00.transfer.d.ts +0 -2
  128. package/dist/test/00.transfer.d.ts.map +0 -1
  129. package/dist/test/00.transfer.js +0 -168
  130. package/dist/test/00.transfer.js.map +0 -1
  131. package/dist/test/05.global.d.ts.map +0 -1
  132. package/dist/test/05.global.js.map +0 -1
  133. package/dist/test/10.module.d.ts +0 -2
  134. package/dist/test/10.module.d.ts.map +0 -1
  135. package/dist/test/10.module.js.map +0 -1
  136. package/dist/test/10.reference.d.ts.map +0 -1
  137. package/dist/test/10.reference.js.map +0 -1
  138. package/dist/test/10.script.d.ts +0 -2
  139. package/dist/test/10.script.d.ts.map +0 -1
  140. package/dist/test/10.script.js.map +0 -1
  141. package/dist/test/20.array_buffer.d.ts +0 -2
  142. package/dist/test/20.array_buffer.d.ts.map +0 -1
  143. package/dist/test/20.array_buffer.js.map +0 -1
  144. package/dist/test/50.timers.d.ts.map +0 -1
  145. package/dist/test/50.timers.js.map +0 -1
  146. package/dist/test/99.i18n.d.ts +0 -2
  147. package/dist/test/99.i18n.d.ts.map +0 -1
  148. package/dist/test/99.i18n.js.map +0 -1
  149. package/test/00.transfer.ts +0 -134
  150. /package/dist/test/{05.global.d.ts → 20.intrinsics/05.global.d.ts} +0 -0
  151. /package/dist/test/{10.reference.d.ts → 20.intrinsics/10.reference.d.ts} +0 -0
  152. /package/dist/test/{50.timers.d.ts → 50.features/50.timers.d.ts} +0 -0
@@ -7,7 +7,7 @@ target_link_libraries(isolated_vm PRIVATE ${auto_js} utility_js)
7
7
  target_sources(isolated_vm
8
8
  PUBLIC FILE_SET CXX_MODULES FILES
9
9
  _module.cc
10
- handle/bound_value.cc
10
+ handle/local_of.cc
11
11
  handle/types.cc
12
12
  handle/value_of.cc
13
13
  support/callback_info.cc
@@ -0,0 +1,150 @@
1
+ export module isolated_vm:handle.local_of;
2
+ export import :handle.types;
3
+ import auto_js;
4
+ import std;
5
+ import util;
6
+
7
+ namespace isolated_vm {
8
+ using namespace js;
9
+
10
+ // Map of `local_of<Tag>` to its concrete implementation class
11
+ template <class Tag>
12
+ struct local_specialization;
13
+
14
+ // Tagged isolated_vm value. Each `local_of<T>` inherits from the tag before it.
15
+ export template <class Tag = value_tag>
16
+ class local_of : public local_of<typename Tag::tag_type> {
17
+ protected:
18
+ using local_type = local_specialization<Tag>::type;
19
+ explicit local_of(runtime_handle value) : local_of<typename Tag::tag_type>{value} {}
20
+
21
+ public:
22
+ local_of() = default;
23
+ using tag_type = Tag;
24
+
25
+ // Constructor from tagged `runtime_handle` flavors
26
+ explicit local_of(local_type value)
27
+ requires(type<local_type> != type<runtime_handle>) :
28
+ local_of{runtime_handle{value}} {}
29
+
30
+ // "Downcast" to a more specific tag. Potentially unsafe.
31
+ template <std::convertible_to<Tag> To>
32
+ auto cast(To /*tag*/) const -> local_of<To> { return local_of<To>::from(*this); }
33
+
34
+ // Construct from any `value_handle`. Potentially unsafe.
35
+ static auto from(runtime_handle value_) -> local_of<Tag> { return std::bit_cast<local_of<Tag>>(value_); }
36
+
37
+ // Forward `make` to specialization
38
+ static auto make(auto&&... args) -> local_of<Tag> { return local_type::make(std::forward<decltype(args)>(args)...); }
39
+
40
+ // Dereference operators
41
+ auto operator*() const -> local_type { return std::bit_cast<local_type>(runtime_handle{*this}); }
42
+ auto operator->() const -> auto { return util::pointer_delegate{**this}; }
43
+ };
44
+
45
+ // Sentinel instantiation
46
+ template <>
47
+ class local_of<void> : public runtime_handle {
48
+ public:
49
+ using runtime_handle::runtime_handle;
50
+ explicit local_of(runtime_handle value) : runtime_handle{value} {}
51
+ local_of() = default;
52
+ };
53
+
54
+ // Deduction guide
55
+ template <class Type>
56
+ local_of(Type value) -> local_of<typename Type::tag_type>;
57
+
58
+ // Details applied to each level of the `local_of<T>` hierarchy.
59
+ template <class Tag>
60
+ struct local_next : local_specialization<typename Tag::tag_type>::type {
61
+ using local_specialization<typename Tag::tag_type>::type::type;
62
+ using tag_type = Tag;
63
+ };
64
+
65
+ // `local_of<Tag>` implementation specializations. The default specialization selects the nearest
66
+ // specialization, or simply `runtime_handle` as the base class.
67
+ template <class Tag>
68
+ struct local_specialization
69
+ : local_specialization<typename Tag::tag_type> {};
70
+
71
+ template <>
72
+ struct local_specialization<void>
73
+ : std::type_identity<runtime_handle> {};
74
+
75
+ template <>
76
+ struct local_specialization<value_tag>
77
+ : std::type_identity<class local_for_value> {};
78
+
79
+ template <>
80
+ struct local_specialization<primitive_tag>
81
+ : std::type_identity<class local_for_primitive> {};
82
+
83
+ template <>
84
+ struct local_specialization<undefined_tag>
85
+ : std::type_identity<class local_for_undefined> {};
86
+
87
+ template <>
88
+ struct local_specialization<null_tag>
89
+ : std::type_identity<class local_for_null> {};
90
+
91
+ template <>
92
+ struct local_specialization<boolean_tag>
93
+ : std::type_identity<class local_for_boolean> {};
94
+
95
+ template <>
96
+ struct local_specialization<number_tag>
97
+ : std::type_identity<class local_for_number> {};
98
+
99
+ template <>
100
+ struct local_specialization<name_tag>
101
+ : std::type_identity<class local_for_name> {};
102
+
103
+ template <>
104
+ struct local_specialization<string_tag>
105
+ : std::type_identity<class local_for_string> {};
106
+
107
+ template <>
108
+ struct local_specialization<bigint_tag>
109
+ : std::type_identity<class local_for_bigint> {};
110
+
111
+ template <>
112
+ struct local_specialization<function_tag>
113
+ : std::type_identity<class local_for_function> {};
114
+
115
+ template <>
116
+ struct local_specialization<object_tag>
117
+ : std::type_identity<class local_for_object> {};
118
+
119
+ template <>
120
+ struct local_specialization<record_tag>
121
+ : std::type_identity<class local_for_record> {};
122
+
123
+ template <>
124
+ struct local_specialization<list_tag>
125
+ : std::type_identity<class local_for_array> {};
126
+
127
+ template <>
128
+ struct local_specialization<data_block_tag>
129
+ : std::type_identity<class local_for_data_block> {};
130
+
131
+ template <>
132
+ struct local_specialization<array_buffer_tag>
133
+ : std::type_identity<class local_for_array_buffer> {};
134
+
135
+ template <>
136
+ struct local_specialization<array_buffer_view_tag>
137
+ : std::type_identity<class local_for_array_buffer_view> {};
138
+
139
+ template <>
140
+ struct local_specialization<prototype_tag>
141
+ : std::type_identity<class local_for_prototype> {};
142
+
143
+ } // namespace isolated_vm
144
+
145
+ // Specialize for `js::forward`. Makes `js::forward{local_of<Tag>}` infer
146
+ // `js::forward<Tag, ...>`.
147
+ namespace js {
148
+ template <class Tag>
149
+ struct forward_tag_for<isolated_vm::local_of<Tag>> : std::type_identity<Tag> {};
150
+ } // namespace js
@@ -4,13 +4,11 @@ import auto_js;
4
4
  namespace isolated_vm {
5
5
  using namespace js;
6
6
 
7
- // `value_handle` is the base class of `value_of<T>`, and `bound_value<T>`.
8
- class value_handle {
9
- protected:
10
- explicit value_handle(void* value) : value_{value} {}
11
-
7
+ // `runtime_handle` is the base class of `local_of<T>` and `value_of<T>` member types.
8
+ class runtime_handle {
12
9
  public:
13
- value_handle() = default;
10
+ explicit runtime_handle(void* value) : value_{value} {}
11
+ runtime_handle() = default;
14
12
 
15
13
  // Check empty value
16
14
  explicit operator bool() const { return value_ != nullptr; }
@@ -19,138 +17,11 @@ class value_handle {
19
17
  void* value_{};
20
18
  };
21
19
 
22
- // `value_of` forward declarations
20
+ // Forward declarations for handle types which declare template deduction guides on each other.
23
21
  export template <class Tag = value_tag>
24
- class value_of;
25
-
26
- template <class Tag>
27
- class value_next;
28
-
29
- // `bound_value` forward declarations
30
- export template <class Tag>
31
- class bound_value;
32
-
33
- template <class Tag>
34
- class bound_value_next;
35
-
36
- template <class Type>
37
- class bound_value_for_typed_array_of;
38
-
39
- // Map of `value_of<Tag>` / `bound_value<Tag>` to concrete implementation classes.
40
- template <class Tag>
41
- struct value_defaults {
42
- using bound_type = bound_value_next<Tag>;
43
- using value_type = value_next<Tag>;
44
- };
45
-
46
- template <class Tag>
47
- struct value_specialization : value_defaults<Tag> {};
48
-
49
- // Typed specializations
50
- template <>
51
- struct value_specialization<value_tag> : value_defaults<value_tag> {
52
- using value_type = class value_for_value;
53
- };
54
-
55
- template <>
56
- struct value_specialization<primitive_tag> : value_defaults<primitive_tag> {
57
- using value_type = class value_for_primitive;
58
- };
59
-
60
- template <>
61
- struct value_specialization<undefined_tag> : value_defaults<undefined_tag> {
62
- using value_type = class value_for_undefined;
63
- };
64
-
65
- template <>
66
- struct value_specialization<null_tag> : value_defaults<null_tag> {
67
- using value_type = class value_for_null;
68
- };
69
-
70
- template <>
71
- struct value_specialization<boolean_tag> : value_defaults<boolean_tag> {
72
- using bound_type = class bound_value_for_boolean;
73
- using value_type = class value_for_boolean;
74
- };
75
-
76
- template <>
77
- struct value_specialization<number_tag> : value_defaults<number_tag> {
78
- using bound_type = class bound_value_for_number;
79
- using value_type = class value_for_number;
80
- };
81
-
82
- template <>
83
- struct value_specialization<name_tag> : value_defaults<name_tag> {
84
- using value_type = class value_for_name;
85
- };
86
-
87
- template <>
88
- struct value_specialization<string_tag> : value_defaults<string_tag> {
89
- using bound_type = class bound_value_for_string;
90
- using value_type = class value_for_string;
91
- };
22
+ class local_of;
92
23
 
93
- template <>
94
- struct value_specialization<bigint_tag> : value_defaults<bigint_tag> {
95
- using bound_type = class bound_value_for_bigint;
96
- using value_type = class value_for_bigint;
97
- };
98
-
99
- template <>
100
- struct value_specialization<function_tag> : value_defaults<function_tag> {
101
- using value_type = class value_for_function;
102
- };
103
-
104
- template <>
105
- struct value_specialization<object_tag> : value_defaults<object_tag> {
106
- using value_type = class value_for_object;
107
- };
108
-
109
- template <>
110
- struct value_specialization<record_tag> : value_defaults<record_tag> {
111
- using bound_type = class bound_value_for_record;
112
- using value_type = class value_for_record;
113
- };
114
-
115
- template <>
116
- struct value_specialization<list_tag> : value_defaults<list_tag> {
117
- using value_type = class value_for_array;
118
- };
119
-
120
- template <>
121
- struct value_specialization<vector_tag> : value_defaults<vector_tag> {
122
- using bound_type = class bound_value_for_vector;
123
- };
124
-
125
- template <>
126
- struct value_specialization<data_block_tag> : value_defaults<data_block_tag> {
127
- using bound_type = class bound_value_for_data_block;
128
- using value_type = class value_for_data_block;
129
- };
130
-
131
- template <>
132
- struct value_specialization<array_buffer_tag> : value_defaults<array_buffer_tag> {
133
- using value_type = class value_for_array_buffer;
134
- };
135
-
136
- template <>
137
- struct value_specialization<array_buffer_view_tag> : value_defaults<array_buffer_view_tag> {
138
- using value_type = class value_for_array_buffer_view;
139
- };
140
-
141
- template <>
142
- struct value_specialization<data_view_tag> : value_defaults<data_view_tag> {
143
- using bound_type = bound_value_for_typed_array_of<void>;
144
- };
145
-
146
- template <class Type>
147
- struct value_specialization<typed_array_tag_of<Type>> : value_defaults<typed_array_tag_of<Type>> {
148
- using bound_type = bound_value_for_typed_array_of<Type>;
149
- };
150
-
151
- template <>
152
- struct value_specialization<prototype_tag> : value_defaults<prototype_tag> {
153
- using value_type = class value_for_prototype;
154
- };
24
+ export template <class Tag = value_tag>
25
+ class value_of;
155
26
 
156
27
  } // namespace isolated_vm
@@ -1,47 +1,102 @@
1
1
  export module isolated_vm:handle.value_of;
2
- export import :handle.types;
2
+ import :handle.types;
3
+ import :support.lock_fwd;
3
4
  import auto_js;
4
5
  import std;
5
6
 
6
7
  namespace isolated_vm {
7
8
  using namespace js;
8
9
 
9
- // Details applied to each level of the `value_of<T>` hierarchy.
10
+ // Map of `value_of<Tag>` to concrete implementation classes.
10
11
  template <class Tag>
11
- class value_next : public value_of<typename Tag::tag_type> {
12
+ struct value_specialization;
13
+
14
+ // Member & method implementation for stateful objects. Used internally in visitors.
15
+ template <class Tag>
16
+ class value_of : public value_specialization<Tag>::type {
12
17
  public:
13
- using value_of<typename Tag::tag_type>::value_of;
18
+ using value_type = value_specialization<Tag>::type;
19
+ using value_type::value_type;
20
+ };
14
21
 
15
- // "Downcast" to a more specific tag. Potentially unsafe.
16
- template <std::convertible_to<Tag> To>
17
- auto cast(To /*tag*/) const -> value_of<To> { return value_of<To>::from(*this); }
22
+ // Sentinel instantiation
23
+ template <>
24
+ class value_of<void> : public runtime_handle {
25
+ protected:
26
+ value_of() = default;
27
+ value_of(const runtime_lock& lock, runtime_handle value) :
28
+ runtime_handle{value},
29
+ lock_{&lock} {}
18
30
 
19
- // Construct from any `value_handle`. Potentially unsafe.
20
- static auto from(value_handle value_) -> value_of<Tag> { return std::bit_cast<value_of<Tag>>(value_); }
21
- };
31
+ [[nodiscard]] auto lock() const -> const runtime_lock& { return *lock_; }
22
32
 
23
- // Tagged isolated_vm value
24
- export template <class Tag>
25
- class value_of : public value_specialization<Tag>::value_type {
26
- public:
27
- using value_specialization<Tag>::value_type::value_type;
33
+ private:
34
+ const runtime_lock* lock_{};
28
35
  };
29
36
 
30
- template <std::derived_from<bound_value<void>> Type>
31
- value_of(Type) -> value_of<typename Type::tag_type>;
37
+ // Deduction guide
38
+ template <class Tag>
39
+ value_of(auto, local_of<Tag>) -> value_of<Tag>;
32
40
 
33
- // Sentinel instantiation
34
- template <>
35
- class value_of<void> : public value_handle {
41
+ // Details applied to each level of the `value_of<T>` hierarchy.
42
+ template <class Tag>
43
+ class value_next : public value_of<typename Tag::tag_type> {
36
44
  public:
37
- using value_handle::value_handle;
45
+ using tag_type = Tag;
46
+
47
+ value_next() = default;
48
+ value_next(auto&& lock, local_of<Tag> value, auto&&... rest) :
49
+ value_of<typename Tag::tag_type>{std::forward<decltype(lock)>(lock), value, std::forward<decltype(rest)>(rest)...} {}
50
+
51
+ // NOLINTNEXTLINE(google-explicit-constructor)
52
+ operator local_of<Tag>() const { return local_of<Tag>::from(runtime_handle{*this}); }
38
53
  };
39
54
 
40
- } // namespace isolated_vm
55
+ // `value_of<Tag>` specializations.
56
+ template <class Type> class value_for_typed_array_of;
41
57
 
42
- // Specialize for `js::forward`. Makes `js::forward{value_of<Tag>}` infer
43
- // `js::forward<Tag, ...>`.
44
- namespace js {
45
58
  template <class Tag>
46
- struct forward_tag_for<isolated_vm::value_of<Tag>> : std::type_identity<Tag> {};
47
- } // namespace js
59
+ struct value_specialization
60
+ : std::type_identity<value_next<Tag>> {};
61
+
62
+ template <>
63
+ struct value_specialization<void>
64
+ : std::type_identity<value_of<void>> {};
65
+
66
+ template <>
67
+ struct value_specialization<boolean_tag>
68
+ : std::type_identity<class value_for_boolean> {};
69
+
70
+ template <>
71
+ struct value_specialization<number_tag>
72
+ : std::type_identity<class value_for_number> {};
73
+
74
+ template <>
75
+ struct value_specialization<string_tag>
76
+ : std::type_identity<class value_for_string> {};
77
+
78
+ template <>
79
+ struct value_specialization<bigint_tag>
80
+ : std::type_identity<class value_for_bigint> {};
81
+
82
+ template <>
83
+ struct value_specialization<record_tag>
84
+ : std::type_identity<class value_for_record> {};
85
+
86
+ template <>
87
+ struct value_specialization<vector_tag>
88
+ : std::type_identity<class value_for_vector> {};
89
+
90
+ template <>
91
+ struct value_specialization<data_block_tag>
92
+ : std::type_identity<class value_for_data_block> {};
93
+
94
+ template <class Type>
95
+ struct value_specialization<typed_array_tag_of<Type>>
96
+ : std::type_identity<value_for_typed_array_of<Type>> {};
97
+
98
+ template <>
99
+ struct value_specialization<data_view_tag>
100
+ : std::type_identity<class value_for_data_view> {};
101
+
102
+ } // namespace isolated_vm
@@ -2,7 +2,7 @@ module;
2
2
  #include "auto_js/export_tag.h"
3
3
  #include <cassert>
4
4
  export module isolated_vm:support.callback_info_fwd;
5
- import :handle.value_of;
5
+ import :handle.local_of;
6
6
  import :value.primitive;
7
7
  import auto_js;
8
8
  import std;
@@ -16,7 +16,7 @@ class EXPORT callback_info {
16
16
 
17
17
  public:
18
18
  class iterator;
19
- using value_type = value_of<>;
19
+ using value_type = local_of<>;
20
20
 
21
21
  [[nodiscard]] constexpr auto begin() const -> iterator;
22
22
  [[nodiscard]] constexpr auto end() const -> iterator;
@@ -73,11 +73,11 @@ using namespace isolated_vm;
73
73
 
74
74
  // `arguments` visitor
75
75
  template <>
76
- struct visit_subject_for<callback_info> : visit_subject_for<value_of<>> {};
76
+ struct visit_subject_for<callback_info> : visit_subject_for<local_of<>> {};
77
77
 
78
78
  template <class Meta>
79
- struct visit<Meta, callback_info> : visit<Meta, value_of<>> {
80
- using visit_type = visit<Meta, value_of<>>;
79
+ struct visit<Meta, callback_info> : visit<Meta, local_of<>> {
80
+ using visit_type = visit<Meta, local_of<>>;
81
81
  using visit_type::visit_type;
82
82
 
83
83
  using visit_type::operator();
@@ -10,7 +10,7 @@ import util;
10
10
  namespace isolated_vm {
11
11
  using namespace js;
12
12
 
13
- using runtime_callback_type = auto (*)(const runtime_lock&, callback_info, const void*) -> value_of<>;
13
+ using runtime_callback_type = auto (*)(const runtime_lock&, callback_info, const void*) -> local_of<>;
14
14
  using runtime_callback_finalizer_type = auto (*)(void*) -> void;
15
15
 
16
16
  using runtime_callback_data_span_type = std::span<std::byte>;
@@ -42,7 +42,7 @@ const auto max_callback_storage_size = sizeof(runtime_callback_function_storage<
42
42
  auto make_callback_storage(std::invocable<const runtime_lock&, callback_info> auto function) {
43
43
  using function_type = decltype(function);
44
44
  using data_type = runtime_callback_function_storage<function_type>;
45
- constexpr auto callback = runtime_callback_type{[](const runtime_lock& lock, callback_info info, const void* data) -> value_of<> {
45
+ constexpr auto callback = runtime_callback_type{[](const runtime_lock& lock, callback_info info, const void* data) -> local_of<> {
46
46
  const auto& storage = *static_cast<const data_type*>(data);
47
47
  return storage.function(lock, info);
48
48
  }};
@@ -15,7 +15,7 @@ constexpr auto make_free_function(auto function) {
15
15
  ) -> auto {
16
16
  using callback_type = decltype(callback);
17
17
  auto bound_function = util::bind{
18
- [](const callback_type& callback, Lock lock, callback_info info) noexcept(Nx) -> value_of<> {
18
+ [](const callback_type& callback, Lock lock, callback_info info) noexcept(Nx) -> local_of<> {
19
19
  auto run = util::regular_return{[ & ]() -> decltype(auto) {
20
20
  return std::apply(
21
21
  callback,
@@ -25,7 +25,7 @@ constexpr auto make_free_function(auto function) {
25
25
  )
26
26
  );
27
27
  }};
28
- return js::transfer_in_strict<value_of<>>(run().value_or(std::monostate{}), lock);
28
+ return js::transfer_in_strict<local_of<>>(run().value_or(std::monostate{}), lock);
29
29
  },
30
30
  std::move(callback),
31
31
  };
@@ -9,7 +9,7 @@ import util;
9
9
  namespace isolated_vm {
10
10
  export namespace detail {
11
11
  using make_addon_names = auto() -> std::vector<std::u16string>;
12
- using accept_addon_values = auto(std::span<value_of<prototype_tag>>) -> void;
12
+ using accept_addon_values = auto(std::span<local_of<prototype_tag>>) -> void;
13
13
  using initialize_addon = auto(const basic_lock&, util::function_ref<accept_addon_values>) -> void;
14
14
  } // namespace detail
15
15
 
@@ -67,7 +67,7 @@ addon::addon(std::type_identity<Type> /*environment*/, auto callback) {
67
67
  constexpr auto make_exports = [](const basic_lock& lock, util::function_ref<detail::accept_addon_values> make) -> void {
68
68
  constexpr auto values = get_descriptors(std::integral_constant<std::size_t, 1>{}, callback_type{}());
69
69
  constexpr auto size = std::tuple_size_v<decltype(values)>;
70
- auto vm_values = js::transfer_in_strict<std::array<value_of<prototype_tag>, size>>(values, lock);
70
+ auto vm_values = js::transfer_in_strict<std::array<local_of<prototype_tag>, size>>(values, lock);
71
71
  make(std::span{vm_values});
72
72
  };
73
73
  register_addon(make_names, make_exports);