@geastack/compiler 1.0.21 → 1.0.22

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 (35) hide show
  1. package/dist/compiler.js +2 -1
  2. package/dist/conversion/build.d.ts +12 -0
  3. package/dist/conversion/build.js +15 -0
  4. package/dist/ir/callable-class-flow.d.ts +3 -1
  5. package/dist/ir/callable-class-flow.js +27 -1
  6. package/dist/ir/certificate.js +87 -16
  7. package/dist/ir/certify/carrier-keys.js +3 -1
  8. package/dist/ir/lower-invocation.js +7 -1
  9. package/dist/ir/proven-branches.js +3 -1
  10. package/dist/ir/reflection-demand.js +10 -0
  11. package/dist/project-preparation.js +20 -0
  12. package/dist/semantics/class-alias.d.ts +16 -1
  13. package/dist/semantics/class-alias.js +21 -2
  14. package/dist/semantics/class-heritage.js +2 -2
  15. package/dist/semantics/frontend.js +35 -7
  16. package/dist/semantics/normalize/bivariant-slot-parameter.js +21 -6
  17. package/dist/semantics/normalize/commonjs-require.d.ts +9 -5
  18. package/dist/semantics/normalize/commonjs-require.js +127 -44
  19. package/dist/semantics/normalize/host-mutation-key-reader.js +35 -10
  20. package/dist/semantics/normalize/identities.js +15 -0
  21. package/dist/semantics/normalize/object-bag-bindings.js +16 -2
  22. package/dist/semantics/normalize/omitted-stated-parameter.d.ts +1 -1
  23. package/dist/semantics/normalize/omitted-stated-parameter.js +34 -4
  24. package/dist/semantics/normalize/parameter-bindings.js +33 -7
  25. package/dist/semantics/normalize/structural.js +17 -0
  26. package/dist/semantics/program.js +42 -20
  27. package/dist/semantics/shared-declaration-files.d.ts +44 -0
  28. package/dist/semantics/shared-declaration-files.js +42 -0
  29. package/dist/semantics/subclass-member-overlay-transform.js +95 -53
  30. package/dist/targets/cpp/emit-allocation.js +34 -1
  31. package/dist/targets/cpp/emit-union-properties.js +16 -3
  32. package/dist/targets/cpp/manifest/capabilities.js +10 -1
  33. package/dist/targets/cpp/records.js +8 -1
  34. package/package.json +10 -10
  35. package/src/targets/cpp/runtime/gea_runtime.h +66 -14
@@ -246,8 +246,19 @@ T& realmSlot() { return realmSlot<Tag, T, Lifetime>([] { return new T{}; }); }
246
246
  *
247
247
  * A null argument flushes every open output stream, not just `stdout`.
248
248
  */
249
- [[noreturn]] inline void abortAfterFlush() {
249
+ inline void flushAllOutput() {
250
+ #if defined(__PICOLIBC__)
251
+ // picolibc (the ESP32-S31's libc) declares fflush's argument nonnull and has
252
+ // no flush-everything form; the console streams are what a death must keep.
253
+ std::fflush(stdout);
254
+ std::fflush(stderr);
255
+ #else
250
256
  std::fflush(nullptr);
257
+ #endif
258
+ }
259
+
260
+ [[noreturn]] inline void abortAfterFlush() {
261
+ flushAllOutput();
251
262
  std::abort();
252
263
  }
253
264
 
@@ -259,7 +270,7 @@ T& realmSlot() { return realmSlot<Tag, T, Lifetime>([] { return new T{}; }); }
259
270
  inline std::terminate_handler previousTerminateHandler = nullptr;
260
271
 
261
272
  inline void flushThenTerminate() {
262
- std::fflush(nullptr);
273
+ flushAllOutput();
263
274
  if (previousTerminateHandler != nullptr) previousTerminateHandler();
264
275
  std::abort();
265
276
  }
@@ -19768,6 +19779,13 @@ template <typename Element>
19768
19779
  struct DynamicRestArgument<gea::Ref<gea::ArrayObject<Element>>> {
19769
19780
  static constexpr bool supported = DynamicCallableCarrier<Element>::supported;
19770
19781
 
19782
+ /** 10.2.11: the rest parameter is an Array of every argument from `from` on. */
19783
+ static gea::Ref<gea::ArrayObject<Element>> pack(const Value* arguments, std::size_t count, std::size_t from) {
19784
+ gea::Ref<gea::ArrayObject<Element>> rest = gea::makeRef<gea::ArrayObject<Element>>();
19785
+ for (std::size_t at = from; at < count; at += 1) rest->push(DynamicCallableCarrier<Element>::in(arguments[at], at));
19786
+ return rest;
19787
+ }
19788
+
19771
19789
  static void append(std::vector<Value>& destination, const gea::Ref<gea::ArrayObject<Element>>& rest) {
19772
19790
  if (!rest) refusePayloadMismatch("a dynamic call adapter's rest argument");
19773
19791
  for (std::size_t index = 0; index < rest->size(); index += 1) {
@@ -19782,6 +19800,48 @@ struct DynamicRestArgument<gea::Ref<gea::ArrayObject<Element>>> {
19782
19800
  }
19783
19801
  };
19784
19802
 
19803
+ /**
19804
+ * A rest slot carried as a fixed tuple record rather than an Array: a function
19805
+ * that forwards `arguments` (three.js's `WebGLState` wraps every GL call as
19806
+ * `function compressedTexImage2D() { gl.compressedTexImage2D( ...arguments ) }`)
19807
+ * lowers its argument list to a record whose own keys are the canonical
19808
+ * indexes "0".."n". Its own-field table is the whole protocol needed: the
19809
+ * present index keys in order are the argument list, and each incoming
19810
+ * argument is written to its index. A slot the caller did not supply is
19811
+ * deleted, so it is absent as an unsupplied argument is.
19812
+ */
19813
+ template <typename T>
19814
+ requires(NativeFieldTable<T> && NativeOwnFieldDeletion<T>)
19815
+ struct DynamicRestArgument<gea::Ref<T>> {
19816
+ static constexpr bool supported = true;
19817
+
19818
+ static void append(std::vector<Value>& destination, const gea::Ref<T>& rest) {
19819
+ if (!rest) refusePayloadMismatch("a dynamic call adapter's rest argument");
19820
+ std::vector<PropertyKey> keys;
19821
+ rest->gea_ownFieldKeys(keys);
19822
+ for (const PropertyKey& key : keys) {
19823
+ Value slot;
19824
+ if (!rest->gea_readOwnField(key, slot)) refusePayloadMismatch("a dynamic call adapter's rest argument slot");
19825
+ destination.push_back(std::move(slot));
19826
+ }
19827
+ }
19828
+
19829
+ static gea::Ref<T> pack(const Value* arguments, std::size_t count, std::size_t from) {
19830
+ gea::Ref<T> rest = gea::makeRef<T>();
19831
+ std::vector<PropertyKey> keys;
19832
+ rest->gea_ownFieldKeys(keys);
19833
+ for (std::size_t index = 0; index < keys.size(); index += 1) {
19834
+ if (from + index < count) {
19835
+ if (!rest->gea_writeOwnField(keys[index], arguments[from + index], true))
19836
+ refusePayloadMismatch("a dynamic call adapter's rest argument slot");
19837
+ } else {
19838
+ rest->gea_deleteOwnField(keys[index]);
19839
+ }
19840
+ }
19841
+ return rest;
19842
+ }
19843
+ };
19844
+
19785
19845
  /**
19786
19846
  * A function value crossing the boundary in the READ direction, and the one
19787
19847
  * carrier for which an exact payload match is not the general case.
@@ -21122,9 +21182,7 @@ struct DynamicRestCallSignature<CallableObject<Result(Arguments...)>, RestFrom>
21122
21182
  using Args = std::tuple<Arguments...>;
21123
21183
  static constexpr bool shaped = sizeof...(Arguments) > 0 && RestFrom + 1 == sizeof...(Arguments);
21124
21184
  using RestParam = typename RestSlotOf<shaped, Args>::type;
21125
- using Element = typename RestElementOf<RestParam>::type;
21126
- static constexpr bool supported = shaped && RestElementOf<RestParam>::ok &&
21127
- DynamicCallableCarrier<Element>::supported &&
21185
+ static constexpr bool supported = shaped && DynamicRestArgument<RestParam>::supported &&
21128
21186
  (std::is_void_v<Result> || DynamicCallableCarrier<Result>::supported) &&
21129
21187
  (DynamicCallableCarrier<Arguments>::supported && ...);
21130
21188
 
@@ -21137,9 +21195,7 @@ struct DynamicRestCallSignature<CallableObject<Result(Arguments...)>, RestFrom>
21137
21195
  template <std::size_t... Fixed>
21138
21196
  static Value invoke(const CallableObject<Result(Arguments...)>& callable, const Value* arguments, std::size_t count,
21139
21197
  std::index_sequence<Fixed...>) {
21140
- gea::Ref<gea::ArrayObject<Element>> rest = gea::makeRef<gea::ArrayObject<Element>>();
21141
- for (std::size_t at = RestFrom; at < count; at += 1)
21142
- rest->push(DynamicCallableCarrier<Element>::in(arguments[at], at));
21198
+ RestParam rest = DynamicRestArgument<RestParam>::pack(arguments, count, RestFrom);
21143
21199
  if constexpr (std::is_void_v<Result>) {
21144
21200
  callable.call(
21145
21201
  DynamicCallableCarrier<std::tuple_element_t<Fixed, Args>>::in(dynamicCallArgument(arguments, count, Fixed), Fixed)...,
@@ -21174,9 +21230,7 @@ struct DynamicRestCallSignature<CallableConstructorObject<Result(Arguments...),
21174
21230
  using Args = std::tuple<Arguments...>;
21175
21231
  static constexpr bool shaped = sizeof...(Arguments) > 0 && RestFrom + 1 == sizeof...(Arguments);
21176
21232
  using RestParam = typename RestSlotOf<shaped, Args>::type;
21177
- using Element = typename RestElementOf<RestParam>::type;
21178
- static constexpr bool supported = shaped && RestElementOf<RestParam>::ok &&
21179
- DynamicCallableCarrier<Element>::supported &&
21233
+ static constexpr bool supported = shaped && DynamicRestArgument<RestParam>::supported &&
21180
21234
  (std::is_void_v<Result> || DynamicCallableCarrier<Result>::supported) &&
21181
21235
  (DynamicCallableCarrier<Arguments>::supported && ...);
21182
21236
 
@@ -21187,9 +21241,7 @@ struct DynamicRestCallSignature<CallableConstructorObject<Result(Arguments...),
21187
21241
  private:
21188
21242
  template <std::size_t... Fixed>
21189
21243
  static Value invoke(const Callable& callable, const Value* arguments, std::size_t count, std::index_sequence<Fixed...>) {
21190
- gea::Ref<gea::ArrayObject<Element>> rest = gea::makeRef<gea::ArrayObject<Element>>();
21191
- for (std::size_t at = RestFrom; at < count; at += 1)
21192
- rest->push(DynamicCallableCarrier<Element>::in(arguments[at], at));
21244
+ RestParam rest = DynamicRestArgument<RestParam>::pack(arguments, count, RestFrom);
21193
21245
  if constexpr (std::is_void_v<Result>) {
21194
21246
  callable.call(
21195
21247
  DynamicCallableCarrier<std::tuple_element_t<Fixed, Args>>::in(dynamicCallArgument(arguments, count, Fixed), Fixed)...,