@spotlightjs/spotlight 4.11.4 → 4.11.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.
Files changed (173) hide show
  1. package/dist/_virtual/ajv.js +6 -3
  2. package/dist/_virtual/ajv2.js +13 -0
  3. package/dist/_virtual/index.js +6 -3
  4. package/dist/_virtual/index10.js +3 -3
  5. package/dist/_virtual/index11.js +3 -3
  6. package/dist/_virtual/index12.js +13 -0
  7. package/dist/_virtual/index2.js +3 -3
  8. package/dist/_virtual/index3.js +3 -3
  9. package/dist/_virtual/index4.js +3 -3
  10. package/dist/_virtual/index5.js +3 -3
  11. package/dist/_virtual/index6.js +3 -3
  12. package/dist/_virtual/index7.js +3 -3
  13. package/dist/_virtual/index8.js +3 -3
  14. package/dist/_virtual/index9.js +3 -3
  15. package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js +1 -1
  16. package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js.map +1 -1
  17. package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js +3 -3
  18. package/dist/node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/formats.js +203 -194
  19. package/dist/node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/formats.js.map +1 -1
  20. package/dist/node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/index.js +47 -47
  21. package/dist/node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/index.js.map +1 -1
  22. package/dist/node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/limit.js +77 -69
  23. package/dist/node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/limit.js.map +1 -1
  24. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/ajv.js +78 -81
  25. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/ajv.js.map +1 -1
  26. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/code.js +145 -136
  27. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/code.js.map +1 -1
  28. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/index.js +692 -685
  29. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/index.js.map +1 -1
  30. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/scope.js +143 -135
  31. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/scope.js.map +1 -1
  32. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/errors.js +122 -116
  33. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/errors.js.map +1 -1
  34. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/index.js +216 -214
  35. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/index.js.map +1 -1
  36. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/names.js +43 -35
  37. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/names.js.map +1 -1
  38. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/ref_error.js +19 -11
  39. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/ref_error.js.map +1 -1
  40. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/resolve.js +149 -144
  41. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/resolve.js.map +1 -1
  42. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/rules.js +31 -25
  43. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/rules.js.map +1 -1
  44. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/util.js +164 -160
  45. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/util.js.map +1 -1
  46. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/applicability.js +23 -17
  47. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/applicability.js.map +1 -1
  48. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/boolSchema.js +7 -10
  49. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/boolSchema.js.map +1 -1
  50. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/dataType.js +174 -173
  51. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/dataType.js.map +1 -1
  52. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/defaults.js +5 -7
  53. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/defaults.js.map +1 -1
  54. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/index.js +21 -28
  55. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/index.js.map +1 -1
  56. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/keyword.js +11 -15
  57. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/keyword.js.map +1 -1
  58. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/subschema.js +5 -7
  59. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/subschema.js.map +1 -1
  60. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.js +571 -570
  61. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.js.map +1 -1
  62. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/refs/data.json.js +3 -17
  63. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/refs/data.json.js.map +1 -1
  64. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/refs/json-schema-draft-07.json.js +4 -236
  65. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/refs/json-schema-draft-07.json.js.map +1 -1
  66. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/equal.js +16 -7
  67. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/equal.js.map +1 -1
  68. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/ucs2length.js +27 -18
  69. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/ucs2length.js.map +1 -1
  70. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/uri.js +16 -7
  71. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/uri.js.map +1 -1
  72. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/validation_error.js.map +1 -1
  73. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +55 -48
  74. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js.map +1 -1
  75. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +104 -99
  76. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js.map +1 -1
  77. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/allOf.js +30 -22
  78. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/allOf.js.map +1 -1
  79. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +20 -12
  80. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/anyOf.js.map +1 -1
  81. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/contains.js +95 -88
  82. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/contains.js.map +1 -1
  83. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +94 -88
  84. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js.map +1 -1
  85. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/if.js +71 -64
  86. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/if.js.map +1 -1
  87. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/index.js +67 -74
  88. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/index.js.map +1 -1
  89. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/items.js +60 -54
  90. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/items.js.map +1 -1
  91. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js +41 -36
  92. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js.map +1 -1
  93. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/not.js +34 -26
  94. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/not.js.map +1 -1
  95. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +60 -53
  96. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js.map +1 -1
  97. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +73 -67
  98. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js.map +1 -1
  99. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +20 -12
  100. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js.map +1 -1
  101. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/properties.js +61 -55
  102. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/properties.js.map +1 -1
  103. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +46 -39
  104. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js.map +1 -1
  105. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +21 -13
  106. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/thenElse.js.map +1 -1
  107. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/code.js +132 -129
  108. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/code.js.map +1 -1
  109. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/id.js +17 -8
  110. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/id.js.map +1 -1
  111. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/index.js +27 -20
  112. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/index.js.map +1 -1
  113. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/ref.js +121 -118
  114. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/ref.js.map +1 -1
  115. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/discriminator/index.js +104 -100
  116. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/discriminator/index.js.map +1 -1
  117. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/discriminator/types.js +15 -9
  118. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/discriminator/types.js.map +1 -1
  119. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/draft7.js +30 -26
  120. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/draft7.js.map +1 -1
  121. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/format/format.js +84 -76
  122. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/format/format.js.map +1 -1
  123. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/format/index.js +16 -8
  124. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/format/index.js.map +1 -1
  125. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/metadata.js +24 -18
  126. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/metadata.js.map +1 -1
  127. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/const.js +33 -27
  128. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/const.js.map +1 -1
  129. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/enum.js +53 -47
  130. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/enum.js.map +1 -1
  131. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/index.js +52 -53
  132. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/index.js.map +1 -1
  133. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js +32 -24
  134. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js.map +1 -1
  135. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js +37 -31
  136. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js.map +1 -1
  137. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +35 -27
  138. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js.map +1 -1
  139. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +32 -24
  140. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js.map +1 -1
  141. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +31 -23
  142. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js.map +1 -1
  143. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/pattern.js +41 -35
  144. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/pattern.js.map +1 -1
  145. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/required.js +80 -74
  146. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/required.js.map +1 -1
  147. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +71 -66
  148. package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js.map +1 -1
  149. package/dist/node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js +34 -27
  150. package/dist/node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js.map +1 -1
  151. package/dist/node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/index.js +250 -245
  152. package/dist/node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/index.js.map +1 -1
  153. package/dist/node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/lib/schemes.js +201 -175
  154. package/dist/node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/lib/schemes.js.map +1 -1
  155. package/dist/node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/lib/utils.js +267 -259
  156. package/dist/node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/lib/utils.js.map +1 -1
  157. package/dist/node_modules/.pnpm/json-schema-traverse@1.0.0/node_modules/json-schema-traverse/index.js +83 -78
  158. package/dist/node_modules/.pnpm/json-schema-traverse@1.0.0/node_modules/json-schema-traverse/index.js.map +1 -1
  159. package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@4.1.13/node_modules/zod-to-json-schema/dist/esm/Options.js +1 -1
  160. package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@4.1.13/node_modules/zod-to-json-schema/dist/esm/Options.js.map +1 -1
  161. package/dist/node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/core/util.js +1 -1
  162. package/dist/node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/core/util.js.map +1 -1
  163. package/dist/sentry-config.js +2 -2
  164. package/dist/server/cli/run.js +2 -2
  165. package/dist/server/cli.js +2 -2
  166. package/dist/server/mcp/mcp.js +2 -2
  167. package/dist/ui/assets/index.js +61 -70
  168. package/dist/ui/assets/index2.js +1 -1
  169. package/dist/ui/assets/instrumentation.js +18 -18
  170. package/dist/ui/assets/main.css +1 -1
  171. package/dist/ui/assets/main.js +1 -1
  172. package/dist/ui/assets/serverTimingMeta.js +23 -30
  173. package/package.json +4 -4
@@ -2,728 +2,735 @@
2
2
  !(function() {
3
3
  try {
4
4
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
5
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "baa08684-4c73-4b60-b4af-7250c6e38c3d", e._sentryDebugIdIdentifier = "sentry-dbid-baa08684-4c73-4b60-b4af-7250c6e38c3d");
5
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "e71d1ec0-d827-4bff-be63-38bacca88075", e._sentryDebugIdIdentifier = "sentry-dbid-e71d1ec0-d827-4bff-be63-38bacca88075");
6
6
  } catch (e2) {
7
7
  }
8
8
  })();
9
- import { __exports as codegen } from "../../../../../../../../_virtual/index.js";
10
- import "./code.js";
11
- import "./scope.js";
12
- import { __exports as code } from "../../../../../../../../_virtual/code.js";
13
- import { __exports as scope } from "../../../../../../../../_virtual/scope.js";
14
- (function(exports$1) {
15
- Object.defineProperty(exports$1, "__esModule", { value: true });
16
- exports$1.or = exports$1.and = exports$1.not = exports$1.CodeGen = exports$1.operators = exports$1.varKinds = exports$1.ValueScopeName = exports$1.ValueScope = exports$1.Scope = exports$1.Name = exports$1.regexpCode = exports$1.stringify = exports$1.getProperty = exports$1.nil = exports$1.strConcat = exports$1.str = exports$1._ = void 0;
17
- const code_1 = code;
18
- const scope_1 = scope;
19
- var code_2 = code;
20
- Object.defineProperty(exports$1, "_", { enumerable: true, get: function() {
21
- return code_2._;
22
- } });
23
- Object.defineProperty(exports$1, "str", { enumerable: true, get: function() {
24
- return code_2.str;
25
- } });
26
- Object.defineProperty(exports$1, "strConcat", { enumerable: true, get: function() {
27
- return code_2.strConcat;
28
- } });
29
- Object.defineProperty(exports$1, "nil", { enumerable: true, get: function() {
30
- return code_2.nil;
31
- } });
32
- Object.defineProperty(exports$1, "getProperty", { enumerable: true, get: function() {
33
- return code_2.getProperty;
34
- } });
35
- Object.defineProperty(exports$1, "stringify", { enumerable: true, get: function() {
36
- return code_2.stringify;
37
- } });
38
- Object.defineProperty(exports$1, "regexpCode", { enumerable: true, get: function() {
39
- return code_2.regexpCode;
40
- } });
41
- Object.defineProperty(exports$1, "Name", { enumerable: true, get: function() {
42
- return code_2.Name;
43
- } });
44
- var scope_2 = scope;
45
- Object.defineProperty(exports$1, "Scope", { enumerable: true, get: function() {
46
- return scope_2.Scope;
47
- } });
48
- Object.defineProperty(exports$1, "ValueScope", { enumerable: true, get: function() {
49
- return scope_2.ValueScope;
50
- } });
51
- Object.defineProperty(exports$1, "ValueScopeName", { enumerable: true, get: function() {
52
- return scope_2.ValueScopeName;
53
- } });
54
- Object.defineProperty(exports$1, "varKinds", { enumerable: true, get: function() {
55
- return scope_2.varKinds;
56
- } });
57
- exports$1.operators = {
58
- GT: new code_1._Code(">"),
59
- GTE: new code_1._Code(">="),
60
- LT: new code_1._Code("<"),
61
- LTE: new code_1._Code("<="),
62
- EQ: new code_1._Code("==="),
63
- NEQ: new code_1._Code("!=="),
64
- NOT: new code_1._Code("!"),
65
- OR: new code_1._Code("||"),
66
- AND: new code_1._Code("&&"),
67
- ADD: new code_1._Code("+")
68
- };
69
- class Node {
70
- optimizeNodes() {
71
- return this;
72
- }
73
- optimizeNames(_names, _constants) {
74
- return this;
75
- }
76
- }
77
- class Def extends Node {
78
- constructor(varKind, name, rhs) {
79
- super();
80
- this.varKind = varKind;
81
- this.name = name;
82
- this.rhs = rhs;
83
- }
84
- render({ es5, _n }) {
85
- const varKind = es5 ? scope_1.varKinds.var : this.varKind;
86
- const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
87
- return `${varKind} ${this.name}${rhs};` + _n;
88
- }
89
- optimizeNames(names, constants) {
90
- if (!names[this.name.str])
91
- return;
92
- if (this.rhs)
93
- this.rhs = optimizeExpr(this.rhs, names, constants);
94
- return this;
95
- }
96
- get names() {
97
- return this.rhs instanceof code_1._CodeOrName ? this.rhs.names : {};
98
- }
99
- }
100
- class Assign extends Node {
101
- constructor(lhs, rhs, sideEffects) {
102
- super();
103
- this.lhs = lhs;
104
- this.rhs = rhs;
105
- this.sideEffects = sideEffects;
106
- }
107
- render({ _n }) {
108
- return `${this.lhs} = ${this.rhs};` + _n;
109
- }
110
- optimizeNames(names, constants) {
111
- if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects)
112
- return;
113
- this.rhs = optimizeExpr(this.rhs, names, constants);
114
- return this;
115
- }
116
- get names() {
117
- const names = this.lhs instanceof code_1.Name ? {} : { ...this.lhs.names };
118
- return addExprNames(names, this.rhs);
119
- }
120
- }
121
- class AssignOp extends Assign {
122
- constructor(lhs, op, rhs, sideEffects) {
123
- super(lhs, rhs, sideEffects);
124
- this.op = op;
125
- }
126
- render({ _n }) {
127
- return `${this.lhs} ${this.op}= ${this.rhs};` + _n;
128
- }
129
- }
130
- class Label extends Node {
131
- constructor(label) {
132
- super();
133
- this.label = label;
134
- this.names = {};
135
- }
136
- render({ _n }) {
137
- return `${this.label}:` + _n;
138
- }
139
- }
140
- class Break extends Node {
141
- constructor(label) {
142
- super();
143
- this.label = label;
144
- this.names = {};
145
- }
146
- render({ _n }) {
147
- const label = this.label ? ` ${this.label}` : "";
148
- return `break${label};` + _n;
149
- }
150
- }
151
- class Throw extends Node {
152
- constructor(error) {
153
- super();
154
- this.error = error;
9
+ import { __exports as codegen } from "../../../../../../../../_virtual/index5.js";
10
+ import { __require as requireCode } from "./code.js";
11
+ import { __require as requireScope } from "./scope.js";
12
+ var hasRequiredCodegen;
13
+ function requireCodegen() {
14
+ if (hasRequiredCodegen) return codegen;
15
+ hasRequiredCodegen = 1;
16
+ (function(exports$1) {
17
+ Object.defineProperty(exports$1, "__esModule", { value: true });
18
+ exports$1.or = exports$1.and = exports$1.not = exports$1.CodeGen = exports$1.operators = exports$1.varKinds = exports$1.ValueScopeName = exports$1.ValueScope = exports$1.Scope = exports$1.Name = exports$1.regexpCode = exports$1.stringify = exports$1.getProperty = exports$1.nil = exports$1.strConcat = exports$1.str = exports$1._ = void 0;
19
+ const code_1 = /* @__PURE__ */ requireCode();
20
+ const scope_1 = /* @__PURE__ */ requireScope();
21
+ var code_2 = /* @__PURE__ */ requireCode();
22
+ Object.defineProperty(exports$1, "_", { enumerable: true, get: function() {
23
+ return code_2._;
24
+ } });
25
+ Object.defineProperty(exports$1, "str", { enumerable: true, get: function() {
26
+ return code_2.str;
27
+ } });
28
+ Object.defineProperty(exports$1, "strConcat", { enumerable: true, get: function() {
29
+ return code_2.strConcat;
30
+ } });
31
+ Object.defineProperty(exports$1, "nil", { enumerable: true, get: function() {
32
+ return code_2.nil;
33
+ } });
34
+ Object.defineProperty(exports$1, "getProperty", { enumerable: true, get: function() {
35
+ return code_2.getProperty;
36
+ } });
37
+ Object.defineProperty(exports$1, "stringify", { enumerable: true, get: function() {
38
+ return code_2.stringify;
39
+ } });
40
+ Object.defineProperty(exports$1, "regexpCode", { enumerable: true, get: function() {
41
+ return code_2.regexpCode;
42
+ } });
43
+ Object.defineProperty(exports$1, "Name", { enumerable: true, get: function() {
44
+ return code_2.Name;
45
+ } });
46
+ var scope_2 = /* @__PURE__ */ requireScope();
47
+ Object.defineProperty(exports$1, "Scope", { enumerable: true, get: function() {
48
+ return scope_2.Scope;
49
+ } });
50
+ Object.defineProperty(exports$1, "ValueScope", { enumerable: true, get: function() {
51
+ return scope_2.ValueScope;
52
+ } });
53
+ Object.defineProperty(exports$1, "ValueScopeName", { enumerable: true, get: function() {
54
+ return scope_2.ValueScopeName;
55
+ } });
56
+ Object.defineProperty(exports$1, "varKinds", { enumerable: true, get: function() {
57
+ return scope_2.varKinds;
58
+ } });
59
+ exports$1.operators = {
60
+ GT: new code_1._Code(">"),
61
+ GTE: new code_1._Code(">="),
62
+ LT: new code_1._Code("<"),
63
+ LTE: new code_1._Code("<="),
64
+ EQ: new code_1._Code("==="),
65
+ NEQ: new code_1._Code("!=="),
66
+ NOT: new code_1._Code("!"),
67
+ OR: new code_1._Code("||"),
68
+ AND: new code_1._Code("&&"),
69
+ ADD: new code_1._Code("+")
70
+ };
71
+ class Node {
72
+ optimizeNodes() {
73
+ return this;
74
+ }
75
+ optimizeNames(_names, _constants) {
76
+ return this;
77
+ }
155
78
  }
156
- render({ _n }) {
157
- return `throw ${this.error};` + _n;
79
+ class Def extends Node {
80
+ constructor(varKind, name, rhs) {
81
+ super();
82
+ this.varKind = varKind;
83
+ this.name = name;
84
+ this.rhs = rhs;
85
+ }
86
+ render({ es5, _n }) {
87
+ const varKind = es5 ? scope_1.varKinds.var : this.varKind;
88
+ const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
89
+ return `${varKind} ${this.name}${rhs};` + _n;
90
+ }
91
+ optimizeNames(names, constants) {
92
+ if (!names[this.name.str])
93
+ return;
94
+ if (this.rhs)
95
+ this.rhs = optimizeExpr(this.rhs, names, constants);
96
+ return this;
97
+ }
98
+ get names() {
99
+ return this.rhs instanceof code_1._CodeOrName ? this.rhs.names : {};
100
+ }
158
101
  }
159
- get names() {
160
- return this.error.names;
102
+ class Assign extends Node {
103
+ constructor(lhs, rhs, sideEffects) {
104
+ super();
105
+ this.lhs = lhs;
106
+ this.rhs = rhs;
107
+ this.sideEffects = sideEffects;
108
+ }
109
+ render({ _n }) {
110
+ return `${this.lhs} = ${this.rhs};` + _n;
111
+ }
112
+ optimizeNames(names, constants) {
113
+ if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects)
114
+ return;
115
+ this.rhs = optimizeExpr(this.rhs, names, constants);
116
+ return this;
117
+ }
118
+ get names() {
119
+ const names = this.lhs instanceof code_1.Name ? {} : { ...this.lhs.names };
120
+ return addExprNames(names, this.rhs);
121
+ }
161
122
  }
162
- }
163
- class AnyCode extends Node {
164
- constructor(code2) {
165
- super();
166
- this.code = code2;
123
+ class AssignOp extends Assign {
124
+ constructor(lhs, op, rhs, sideEffects) {
125
+ super(lhs, rhs, sideEffects);
126
+ this.op = op;
127
+ }
128
+ render({ _n }) {
129
+ return `${this.lhs} ${this.op}= ${this.rhs};` + _n;
130
+ }
167
131
  }
168
- render({ _n }) {
169
- return `${this.code};` + _n;
132
+ class Label extends Node {
133
+ constructor(label) {
134
+ super();
135
+ this.label = label;
136
+ this.names = {};
137
+ }
138
+ render({ _n }) {
139
+ return `${this.label}:` + _n;
140
+ }
170
141
  }
171
- optimizeNodes() {
172
- return `${this.code}` ? this : void 0;
142
+ class Break extends Node {
143
+ constructor(label) {
144
+ super();
145
+ this.label = label;
146
+ this.names = {};
147
+ }
148
+ render({ _n }) {
149
+ const label = this.label ? ` ${this.label}` : "";
150
+ return `break${label};` + _n;
151
+ }
173
152
  }
174
- optimizeNames(names, constants) {
175
- this.code = optimizeExpr(this.code, names, constants);
176
- return this;
153
+ class Throw extends Node {
154
+ constructor(error) {
155
+ super();
156
+ this.error = error;
157
+ }
158
+ render({ _n }) {
159
+ return `throw ${this.error};` + _n;
160
+ }
161
+ get names() {
162
+ return this.error.names;
163
+ }
177
164
  }
178
- get names() {
179
- return this.code instanceof code_1._CodeOrName ? this.code.names : {};
165
+ class AnyCode extends Node {
166
+ constructor(code) {
167
+ super();
168
+ this.code = code;
169
+ }
170
+ render({ _n }) {
171
+ return `${this.code};` + _n;
172
+ }
173
+ optimizeNodes() {
174
+ return `${this.code}` ? this : void 0;
175
+ }
176
+ optimizeNames(names, constants) {
177
+ this.code = optimizeExpr(this.code, names, constants);
178
+ return this;
179
+ }
180
+ get names() {
181
+ return this.code instanceof code_1._CodeOrName ? this.code.names : {};
182
+ }
180
183
  }
181
- }
182
- class ParentNode extends Node {
183
- constructor(nodes = []) {
184
- super();
185
- this.nodes = nodes;
186
- }
187
- render(opts) {
188
- return this.nodes.reduce((code2, n) => code2 + n.render(opts), "");
189
- }
190
- optimizeNodes() {
191
- const { nodes } = this;
192
- let i = nodes.length;
193
- while (i--) {
194
- const n = nodes[i].optimizeNodes();
195
- if (Array.isArray(n))
196
- nodes.splice(i, 1, ...n);
197
- else if (n)
198
- nodes[i] = n;
199
- else
184
+ class ParentNode extends Node {
185
+ constructor(nodes = []) {
186
+ super();
187
+ this.nodes = nodes;
188
+ }
189
+ render(opts) {
190
+ return this.nodes.reduce((code, n) => code + n.render(opts), "");
191
+ }
192
+ optimizeNodes() {
193
+ const { nodes } = this;
194
+ let i = nodes.length;
195
+ while (i--) {
196
+ const n = nodes[i].optimizeNodes();
197
+ if (Array.isArray(n))
198
+ nodes.splice(i, 1, ...n);
199
+ else if (n)
200
+ nodes[i] = n;
201
+ else
202
+ nodes.splice(i, 1);
203
+ }
204
+ return nodes.length > 0 ? this : void 0;
205
+ }
206
+ optimizeNames(names, constants) {
207
+ const { nodes } = this;
208
+ let i = nodes.length;
209
+ while (i--) {
210
+ const n = nodes[i];
211
+ if (n.optimizeNames(names, constants))
212
+ continue;
213
+ subtractNames(names, n.names);
200
214
  nodes.splice(i, 1);
215
+ }
216
+ return nodes.length > 0 ? this : void 0;
201
217
  }
202
- return nodes.length > 0 ? this : void 0;
203
- }
204
- optimizeNames(names, constants) {
205
- const { nodes } = this;
206
- let i = nodes.length;
207
- while (i--) {
208
- const n = nodes[i];
209
- if (n.optimizeNames(names, constants))
210
- continue;
211
- subtractNames(names, n.names);
212
- nodes.splice(i, 1);
218
+ get names() {
219
+ return this.nodes.reduce((names, n) => addNames(names, n.names), {});
213
220
  }
214
- return nodes.length > 0 ? this : void 0;
215
- }
216
- get names() {
217
- return this.nodes.reduce((names, n) => addNames(names, n.names), {});
218
- }
219
- }
220
- class BlockNode extends ParentNode {
221
- render(opts) {
222
- return "{" + opts._n + super.render(opts) + "}" + opts._n;
223
221
  }
224
- }
225
- class Root extends ParentNode {
226
- }
227
- class Else extends BlockNode {
228
- }
229
- Else.kind = "else";
230
- class If extends BlockNode {
231
- constructor(condition, nodes) {
232
- super(nodes);
233
- this.condition = condition;
234
- }
235
- render(opts) {
236
- let code2 = `if(${this.condition})` + super.render(opts);
237
- if (this.else)
238
- code2 += "else " + this.else.render(opts);
239
- return code2;
240
- }
241
- optimizeNodes() {
242
- super.optimizeNodes();
243
- const cond = this.condition;
244
- if (cond === true)
245
- return this.nodes;
246
- let e = this.else;
247
- if (e) {
248
- const ns = e.optimizeNodes();
249
- e = this.else = Array.isArray(ns) ? new Else(ns) : ns;
250
- }
251
- if (e) {
252
- if (cond === false)
253
- return e instanceof If ? e : e.nodes;
254
- if (this.nodes.length)
255
- return this;
256
- return new If(not(cond), e instanceof If ? [e] : e.nodes);
257
- }
258
- if (cond === false || !this.nodes.length)
259
- return void 0;
260
- return this;
261
- }
262
- optimizeNames(names, constants) {
263
- var _a;
264
- this.else = (_a = this.else) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants);
265
- if (!(super.optimizeNames(names, constants) || this.else))
266
- return;
267
- this.condition = optimizeExpr(this.condition, names, constants);
268
- return this;
269
- }
270
- get names() {
271
- const names = super.names;
272
- addExprNames(names, this.condition);
273
- if (this.else)
274
- addNames(names, this.else.names);
275
- return names;
276
- }
277
- }
278
- If.kind = "if";
279
- class For extends BlockNode {
280
- }
281
- For.kind = "for";
282
- class ForLoop extends For {
283
- constructor(iteration) {
284
- super();
285
- this.iteration = iteration;
222
+ class BlockNode extends ParentNode {
223
+ render(opts) {
224
+ return "{" + opts._n + super.render(opts) + "}" + opts._n;
225
+ }
286
226
  }
287
- render(opts) {
288
- return `for(${this.iteration})` + super.render(opts);
227
+ class Root extends ParentNode {
289
228
  }
290
- optimizeNames(names, constants) {
291
- if (!super.optimizeNames(names, constants))
292
- return;
293
- this.iteration = optimizeExpr(this.iteration, names, constants);
294
- return this;
229
+ class Else extends BlockNode {
295
230
  }
296
- get names() {
297
- return addNames(super.names, this.iteration.names);
231
+ Else.kind = "else";
232
+ class If extends BlockNode {
233
+ constructor(condition, nodes) {
234
+ super(nodes);
235
+ this.condition = condition;
236
+ }
237
+ render(opts) {
238
+ let code = `if(${this.condition})` + super.render(opts);
239
+ if (this.else)
240
+ code += "else " + this.else.render(opts);
241
+ return code;
242
+ }
243
+ optimizeNodes() {
244
+ super.optimizeNodes();
245
+ const cond = this.condition;
246
+ if (cond === true)
247
+ return this.nodes;
248
+ let e = this.else;
249
+ if (e) {
250
+ const ns = e.optimizeNodes();
251
+ e = this.else = Array.isArray(ns) ? new Else(ns) : ns;
252
+ }
253
+ if (e) {
254
+ if (cond === false)
255
+ return e instanceof If ? e : e.nodes;
256
+ if (this.nodes.length)
257
+ return this;
258
+ return new If(not(cond), e instanceof If ? [e] : e.nodes);
259
+ }
260
+ if (cond === false || !this.nodes.length)
261
+ return void 0;
262
+ return this;
263
+ }
264
+ optimizeNames(names, constants) {
265
+ var _a;
266
+ this.else = (_a = this.else) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants);
267
+ if (!(super.optimizeNames(names, constants) || this.else))
268
+ return;
269
+ this.condition = optimizeExpr(this.condition, names, constants);
270
+ return this;
271
+ }
272
+ get names() {
273
+ const names = super.names;
274
+ addExprNames(names, this.condition);
275
+ if (this.else)
276
+ addNames(names, this.else.names);
277
+ return names;
278
+ }
298
279
  }
299
- }
300
- class ForRange extends For {
301
- constructor(varKind, name, from, to) {
302
- super();
303
- this.varKind = varKind;
304
- this.name = name;
305
- this.from = from;
306
- this.to = to;
307
- }
308
- render(opts) {
309
- const varKind = opts.es5 ? scope_1.varKinds.var : this.varKind;
310
- const { name, from, to } = this;
311
- return `for(${varKind} ${name}=${from}; ${name}<${to}; ${name}++)` + super.render(opts);
312
- }
313
- get names() {
314
- const names = addExprNames(super.names, this.from);
315
- return addExprNames(names, this.to);
280
+ If.kind = "if";
281
+ class For extends BlockNode {
316
282
  }
317
- }
318
- class ForIter extends For {
319
- constructor(loop, varKind, name, iterable) {
320
- super();
321
- this.loop = loop;
322
- this.varKind = varKind;
323
- this.name = name;
324
- this.iterable = iterable;
325
- }
326
- render(opts) {
327
- return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
328
- }
329
- optimizeNames(names, constants) {
330
- if (!super.optimizeNames(names, constants))
331
- return;
332
- this.iterable = optimizeExpr(this.iterable, names, constants);
333
- return this;
334
- }
335
- get names() {
336
- return addNames(super.names, this.iterable.names);
283
+ For.kind = "for";
284
+ class ForLoop extends For {
285
+ constructor(iteration) {
286
+ super();
287
+ this.iteration = iteration;
288
+ }
289
+ render(opts) {
290
+ return `for(${this.iteration})` + super.render(opts);
291
+ }
292
+ optimizeNames(names, constants) {
293
+ if (!super.optimizeNames(names, constants))
294
+ return;
295
+ this.iteration = optimizeExpr(this.iteration, names, constants);
296
+ return this;
297
+ }
298
+ get names() {
299
+ return addNames(super.names, this.iteration.names);
300
+ }
337
301
  }
338
- }
339
- class Func extends BlockNode {
340
- constructor(name, args, async) {
341
- super();
342
- this.name = name;
343
- this.args = args;
344
- this.async = async;
302
+ class ForRange extends For {
303
+ constructor(varKind, name, from, to) {
304
+ super();
305
+ this.varKind = varKind;
306
+ this.name = name;
307
+ this.from = from;
308
+ this.to = to;
309
+ }
310
+ render(opts) {
311
+ const varKind = opts.es5 ? scope_1.varKinds.var : this.varKind;
312
+ const { name, from, to } = this;
313
+ return `for(${varKind} ${name}=${from}; ${name}<${to}; ${name}++)` + super.render(opts);
314
+ }
315
+ get names() {
316
+ const names = addExprNames(super.names, this.from);
317
+ return addExprNames(names, this.to);
318
+ }
345
319
  }
346
- render(opts) {
347
- const _async = this.async ? "async " : "";
348
- return `${_async}function ${this.name}(${this.args})` + super.render(opts);
320
+ class ForIter extends For {
321
+ constructor(loop, varKind, name, iterable) {
322
+ super();
323
+ this.loop = loop;
324
+ this.varKind = varKind;
325
+ this.name = name;
326
+ this.iterable = iterable;
327
+ }
328
+ render(opts) {
329
+ return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
330
+ }
331
+ optimizeNames(names, constants) {
332
+ if (!super.optimizeNames(names, constants))
333
+ return;
334
+ this.iterable = optimizeExpr(this.iterable, names, constants);
335
+ return this;
336
+ }
337
+ get names() {
338
+ return addNames(super.names, this.iterable.names);
339
+ }
349
340
  }
350
- }
351
- Func.kind = "func";
352
- class Return extends ParentNode {
353
- render(opts) {
354
- return "return " + super.render(opts);
341
+ class Func extends BlockNode {
342
+ constructor(name, args, async) {
343
+ super();
344
+ this.name = name;
345
+ this.args = args;
346
+ this.async = async;
347
+ }
348
+ render(opts) {
349
+ const _async = this.async ? "async " : "";
350
+ return `${_async}function ${this.name}(${this.args})` + super.render(opts);
351
+ }
355
352
  }
356
- }
357
- Return.kind = "return";
358
- class Try extends BlockNode {
359
- render(opts) {
360
- let code2 = "try" + super.render(opts);
361
- if (this.catch)
362
- code2 += this.catch.render(opts);
363
- if (this.finally)
364
- code2 += this.finally.render(opts);
365
- return code2;
366
- }
367
- optimizeNodes() {
368
- var _a, _b;
369
- super.optimizeNodes();
370
- (_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNodes();
371
- (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes();
372
- return this;
373
- }
374
- optimizeNames(names, constants) {
375
- var _a, _b;
376
- super.optimizeNames(names, constants);
377
- (_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants);
378
- (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants);
379
- return this;
380
- }
381
- get names() {
382
- const names = super.names;
383
- if (this.catch)
384
- addNames(names, this.catch.names);
385
- if (this.finally)
386
- addNames(names, this.finally.names);
387
- return names;
353
+ Func.kind = "func";
354
+ class Return extends ParentNode {
355
+ render(opts) {
356
+ return "return " + super.render(opts);
357
+ }
388
358
  }
389
- }
390
- class Catch extends BlockNode {
391
- constructor(error) {
392
- super();
393
- this.error = error;
359
+ Return.kind = "return";
360
+ class Try extends BlockNode {
361
+ render(opts) {
362
+ let code = "try" + super.render(opts);
363
+ if (this.catch)
364
+ code += this.catch.render(opts);
365
+ if (this.finally)
366
+ code += this.finally.render(opts);
367
+ return code;
368
+ }
369
+ optimizeNodes() {
370
+ var _a, _b;
371
+ super.optimizeNodes();
372
+ (_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNodes();
373
+ (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes();
374
+ return this;
375
+ }
376
+ optimizeNames(names, constants) {
377
+ var _a, _b;
378
+ super.optimizeNames(names, constants);
379
+ (_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants);
380
+ (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants);
381
+ return this;
382
+ }
383
+ get names() {
384
+ const names = super.names;
385
+ if (this.catch)
386
+ addNames(names, this.catch.names);
387
+ if (this.finally)
388
+ addNames(names, this.finally.names);
389
+ return names;
390
+ }
394
391
  }
395
- render(opts) {
396
- return `catch(${this.error})` + super.render(opts);
392
+ class Catch extends BlockNode {
393
+ constructor(error) {
394
+ super();
395
+ this.error = error;
396
+ }
397
+ render(opts) {
398
+ return `catch(${this.error})` + super.render(opts);
399
+ }
397
400
  }
398
- }
399
- Catch.kind = "catch";
400
- class Finally extends BlockNode {
401
- render(opts) {
402
- return "finally" + super.render(opts);
401
+ Catch.kind = "catch";
402
+ class Finally extends BlockNode {
403
+ render(opts) {
404
+ return "finally" + super.render(opts);
405
+ }
403
406
  }
404
- }
405
- Finally.kind = "finally";
406
- class CodeGen {
407
- constructor(extScope, opts = {}) {
408
- this._values = {};
409
- this._blockStarts = [];
410
- this._constants = {};
411
- this.opts = { ...opts, _n: opts.lines ? "\n" : "" };
412
- this._extScope = extScope;
413
- this._scope = new scope_1.Scope({ parent: extScope });
414
- this._nodes = [new Root()];
415
- }
416
- toString() {
417
- return this._root.render(this.opts);
418
- }
419
- // returns unique name in the internal scope
420
- name(prefix) {
421
- return this._scope.name(prefix);
422
- }
423
- // reserves unique name in the external scope
424
- scopeName(prefix) {
425
- return this._extScope.name(prefix);
426
- }
427
- // reserves unique name in the external scope and assigns value to it
428
- scopeValue(prefixOrName, value) {
429
- const name = this._extScope.value(prefixOrName, value);
430
- const vs = this._values[name.prefix] || (this._values[name.prefix] = /* @__PURE__ */ new Set());
431
- vs.add(name);
432
- return name;
433
- }
434
- getScopeValue(prefix, keyOrRef) {
435
- return this._extScope.getValue(prefix, keyOrRef);
436
- }
437
- // return code that assigns values in the external scope to the names that are used internally
438
- // (same names that were returned by gen.scopeName or gen.scopeValue)
439
- scopeRefs(scopeName) {
440
- return this._extScope.scopeRefs(scopeName, this._values);
441
- }
442
- scopeCode() {
443
- return this._extScope.scopeCode(this._values);
444
- }
445
- _def(varKind, nameOrPrefix, rhs, constant) {
446
- const name = this._scope.toName(nameOrPrefix);
447
- if (rhs !== void 0 && constant)
448
- this._constants[name.str] = rhs;
449
- this._leafNode(new Def(varKind, name, rhs));
450
- return name;
451
- }
452
- // `const` declaration (`var` in es5 mode)
453
- const(nameOrPrefix, rhs, _constant) {
454
- return this._def(scope_1.varKinds.const, nameOrPrefix, rhs, _constant);
455
- }
456
- // `let` declaration with optional assignment (`var` in es5 mode)
457
- let(nameOrPrefix, rhs, _constant) {
458
- return this._def(scope_1.varKinds.let, nameOrPrefix, rhs, _constant);
459
- }
460
- // `var` declaration with optional assignment
461
- var(nameOrPrefix, rhs, _constant) {
462
- return this._def(scope_1.varKinds.var, nameOrPrefix, rhs, _constant);
463
- }
464
- // assignment code
465
- assign(lhs, rhs, sideEffects) {
466
- return this._leafNode(new Assign(lhs, rhs, sideEffects));
467
- }
468
- // `+=` code
469
- add(lhs, rhs) {
470
- return this._leafNode(new AssignOp(lhs, exports$1.operators.ADD, rhs));
471
- }
472
- // appends passed SafeExpr to code or executes Block
473
- code(c) {
474
- if (typeof c == "function")
475
- c();
476
- else if (c !== code_1.nil)
477
- this._leafNode(new AnyCode(c));
478
- return this;
479
- }
480
- // returns code for object literal for the passed argument list of key-value pairs
481
- object(...keyValues) {
482
- const code2 = ["{"];
483
- for (const [key, value] of keyValues) {
484
- if (code2.length > 1)
485
- code2.push(",");
486
- code2.push(key);
487
- if (key !== value || this.opts.es5) {
488
- code2.push(":");
489
- (0, code_1.addCodeArg)(code2, value);
407
+ Finally.kind = "finally";
408
+ class CodeGen {
409
+ constructor(extScope, opts = {}) {
410
+ this._values = {};
411
+ this._blockStarts = [];
412
+ this._constants = {};
413
+ this.opts = { ...opts, _n: opts.lines ? "\n" : "" };
414
+ this._extScope = extScope;
415
+ this._scope = new scope_1.Scope({ parent: extScope });
416
+ this._nodes = [new Root()];
417
+ }
418
+ toString() {
419
+ return this._root.render(this.opts);
420
+ }
421
+ // returns unique name in the internal scope
422
+ name(prefix) {
423
+ return this._scope.name(prefix);
424
+ }
425
+ // reserves unique name in the external scope
426
+ scopeName(prefix) {
427
+ return this._extScope.name(prefix);
428
+ }
429
+ // reserves unique name in the external scope and assigns value to it
430
+ scopeValue(prefixOrName, value) {
431
+ const name = this._extScope.value(prefixOrName, value);
432
+ const vs = this._values[name.prefix] || (this._values[name.prefix] = /* @__PURE__ */ new Set());
433
+ vs.add(name);
434
+ return name;
435
+ }
436
+ getScopeValue(prefix, keyOrRef) {
437
+ return this._extScope.getValue(prefix, keyOrRef);
438
+ }
439
+ // return code that assigns values in the external scope to the names that are used internally
440
+ // (same names that were returned by gen.scopeName or gen.scopeValue)
441
+ scopeRefs(scopeName) {
442
+ return this._extScope.scopeRefs(scopeName, this._values);
443
+ }
444
+ scopeCode() {
445
+ return this._extScope.scopeCode(this._values);
446
+ }
447
+ _def(varKind, nameOrPrefix, rhs, constant) {
448
+ const name = this._scope.toName(nameOrPrefix);
449
+ if (rhs !== void 0 && constant)
450
+ this._constants[name.str] = rhs;
451
+ this._leafNode(new Def(varKind, name, rhs));
452
+ return name;
453
+ }
454
+ // `const` declaration (`var` in es5 mode)
455
+ const(nameOrPrefix, rhs, _constant) {
456
+ return this._def(scope_1.varKinds.const, nameOrPrefix, rhs, _constant);
457
+ }
458
+ // `let` declaration with optional assignment (`var` in es5 mode)
459
+ let(nameOrPrefix, rhs, _constant) {
460
+ return this._def(scope_1.varKinds.let, nameOrPrefix, rhs, _constant);
461
+ }
462
+ // `var` declaration with optional assignment
463
+ var(nameOrPrefix, rhs, _constant) {
464
+ return this._def(scope_1.varKinds.var, nameOrPrefix, rhs, _constant);
465
+ }
466
+ // assignment code
467
+ assign(lhs, rhs, sideEffects) {
468
+ return this._leafNode(new Assign(lhs, rhs, sideEffects));
469
+ }
470
+ // `+=` code
471
+ add(lhs, rhs) {
472
+ return this._leafNode(new AssignOp(lhs, exports$1.operators.ADD, rhs));
473
+ }
474
+ // appends passed SafeExpr to code or executes Block
475
+ code(c) {
476
+ if (typeof c == "function")
477
+ c();
478
+ else if (c !== code_1.nil)
479
+ this._leafNode(new AnyCode(c));
480
+ return this;
481
+ }
482
+ // returns code for object literal for the passed argument list of key-value pairs
483
+ object(...keyValues) {
484
+ const code = ["{"];
485
+ for (const [key, value] of keyValues) {
486
+ if (code.length > 1)
487
+ code.push(",");
488
+ code.push(key);
489
+ if (key !== value || this.opts.es5) {
490
+ code.push(":");
491
+ (0, code_1.addCodeArg)(code, value);
492
+ }
493
+ }
494
+ code.push("}");
495
+ return new code_1._Code(code);
496
+ }
497
+ // `if` clause (or statement if `thenBody` and, optionally, `elseBody` are passed)
498
+ if(condition, thenBody, elseBody) {
499
+ this._blockNode(new If(condition));
500
+ if (thenBody && elseBody) {
501
+ this.code(thenBody).else().code(elseBody).endIf();
502
+ } else if (thenBody) {
503
+ this.code(thenBody).endIf();
504
+ } else if (elseBody) {
505
+ throw new Error('CodeGen: "else" body without "then" body');
506
+ }
507
+ return this;
508
+ }
509
+ // `else if` clause - invalid without `if` or after `else` clauses
510
+ elseIf(condition) {
511
+ return this._elseNode(new If(condition));
512
+ }
513
+ // `else` clause - only valid after `if` or `else if` clauses
514
+ else() {
515
+ return this._elseNode(new Else());
516
+ }
517
+ // end `if` statement (needed if gen.if was used only with condition)
518
+ endIf() {
519
+ return this._endBlockNode(If, Else);
520
+ }
521
+ _for(node, forBody) {
522
+ this._blockNode(node);
523
+ if (forBody)
524
+ this.code(forBody).endFor();
525
+ return this;
526
+ }
527
+ // a generic `for` clause (or statement if `forBody` is passed)
528
+ for(iteration, forBody) {
529
+ return this._for(new ForLoop(iteration), forBody);
530
+ }
531
+ // `for` statement for a range of values
532
+ forRange(nameOrPrefix, from, to, forBody, varKind = this.opts.es5 ? scope_1.varKinds.var : scope_1.varKinds.let) {
533
+ const name = this._scope.toName(nameOrPrefix);
534
+ return this._for(new ForRange(varKind, name, from, to), () => forBody(name));
535
+ }
536
+ // `for-of` statement (in es5 mode replace with a normal for loop)
537
+ forOf(nameOrPrefix, iterable, forBody, varKind = scope_1.varKinds.const) {
538
+ const name = this._scope.toName(nameOrPrefix);
539
+ if (this.opts.es5) {
540
+ const arr = iterable instanceof code_1.Name ? iterable : this.var("_arr", iterable);
541
+ return this.forRange("_i", 0, (0, code_1._)`${arr}.length`, (i) => {
542
+ this.var(name, (0, code_1._)`${arr}[${i}]`);
543
+ forBody(name);
544
+ });
490
545
  }
546
+ return this._for(new ForIter("of", varKind, name, iterable), () => forBody(name));
491
547
  }
492
- code2.push("}");
493
- return new code_1._Code(code2);
494
- }
495
- // `if` clause (or statement if `thenBody` and, optionally, `elseBody` are passed)
496
- if(condition, thenBody, elseBody) {
497
- this._blockNode(new If(condition));
498
- if (thenBody && elseBody) {
499
- this.code(thenBody).else().code(elseBody).endIf();
500
- } else if (thenBody) {
501
- this.code(thenBody).endIf();
502
- } else if (elseBody) {
503
- throw new Error('CodeGen: "else" body without "then" body');
504
- }
505
- return this;
506
- }
507
- // `else if` clause - invalid without `if` or after `else` clauses
508
- elseIf(condition) {
509
- return this._elseNode(new If(condition));
510
- }
511
- // `else` clause - only valid after `if` or `else if` clauses
512
- else() {
513
- return this._elseNode(new Else());
514
- }
515
- // end `if` statement (needed if gen.if was used only with condition)
516
- endIf() {
517
- return this._endBlockNode(If, Else);
518
- }
519
- _for(node, forBody) {
520
- this._blockNode(node);
521
- if (forBody)
522
- this.code(forBody).endFor();
523
- return this;
524
- }
525
- // a generic `for` clause (or statement if `forBody` is passed)
526
- for(iteration, forBody) {
527
- return this._for(new ForLoop(iteration), forBody);
528
- }
529
- // `for` statement for a range of values
530
- forRange(nameOrPrefix, from, to, forBody, varKind = this.opts.es5 ? scope_1.varKinds.var : scope_1.varKinds.let) {
531
- const name = this._scope.toName(nameOrPrefix);
532
- return this._for(new ForRange(varKind, name, from, to), () => forBody(name));
533
- }
534
- // `for-of` statement (in es5 mode replace with a normal for loop)
535
- forOf(nameOrPrefix, iterable, forBody, varKind = scope_1.varKinds.const) {
536
- const name = this._scope.toName(nameOrPrefix);
537
- if (this.opts.es5) {
538
- const arr = iterable instanceof code_1.Name ? iterable : this.var("_arr", iterable);
539
- return this.forRange("_i", 0, (0, code_1._)`${arr}.length`, (i) => {
540
- this.var(name, (0, code_1._)`${arr}[${i}]`);
541
- forBody(name);
542
- });
543
- }
544
- return this._for(new ForIter("of", varKind, name, iterable), () => forBody(name));
545
- }
546
- // `for-in` statement.
547
- // With option `ownProperties` replaced with a `for-of` loop for object keys
548
- forIn(nameOrPrefix, obj, forBody, varKind = this.opts.es5 ? scope_1.varKinds.var : scope_1.varKinds.const) {
549
- if (this.opts.ownProperties) {
550
- return this.forOf(nameOrPrefix, (0, code_1._)`Object.keys(${obj})`, forBody);
551
- }
552
- const name = this._scope.toName(nameOrPrefix);
553
- return this._for(new ForIter("in", varKind, name, obj), () => forBody(name));
554
- }
555
- // end `for` loop
556
- endFor() {
557
- return this._endBlockNode(For);
558
- }
559
- // `label` statement
560
- label(label) {
561
- return this._leafNode(new Label(label));
562
- }
563
- // `break` statement
564
- break(label) {
565
- return this._leafNode(new Break(label));
566
- }
567
- // `return` statement
568
- return(value) {
569
- const node = new Return();
570
- this._blockNode(node);
571
- this.code(value);
572
- if (node.nodes.length !== 1)
573
- throw new Error('CodeGen: "return" should have one node');
574
- return this._endBlockNode(Return);
575
- }
576
- // `try` statement
577
- try(tryBody, catchCode, finallyCode) {
578
- if (!catchCode && !finallyCode)
579
- throw new Error('CodeGen: "try" without "catch" and "finally"');
580
- const node = new Try();
581
- this._blockNode(node);
582
- this.code(tryBody);
583
- if (catchCode) {
584
- const error = this.name("e");
585
- this._currNode = node.catch = new Catch(error);
586
- catchCode(error);
587
- }
588
- if (finallyCode) {
589
- this._currNode = node.finally = new Finally();
590
- this.code(finallyCode);
591
- }
592
- return this._endBlockNode(Catch, Finally);
593
- }
594
- // `throw` statement
595
- throw(error) {
596
- return this._leafNode(new Throw(error));
597
- }
598
- // start self-balancing block
599
- block(body, nodeCount) {
600
- this._blockStarts.push(this._nodes.length);
601
- if (body)
602
- this.code(body).endBlock(nodeCount);
603
- return this;
604
- }
605
- // end the current self-balancing block
606
- endBlock(nodeCount) {
607
- const len = this._blockStarts.pop();
608
- if (len === void 0)
609
- throw new Error("CodeGen: not in self-balancing block");
610
- const toClose = this._nodes.length - len;
611
- if (toClose < 0 || nodeCount !== void 0 && toClose !== nodeCount) {
612
- throw new Error(`CodeGen: wrong number of nodes: ${toClose} vs ${nodeCount} expected`);
613
- }
614
- this._nodes.length = len;
615
- return this;
616
- }
617
- // `function` heading (or definition if funcBody is passed)
618
- func(name, args = code_1.nil, async, funcBody) {
619
- this._blockNode(new Func(name, args, async));
620
- if (funcBody)
621
- this.code(funcBody).endFunc();
622
- return this;
623
- }
624
- // end function definition
625
- endFunc() {
626
- return this._endBlockNode(Func);
627
- }
628
- optimize(n = 1) {
629
- while (n-- > 0) {
630
- this._root.optimizeNodes();
631
- this._root.optimizeNames(this._root.names, this._constants);
632
- }
633
- }
634
- _leafNode(node) {
635
- this._currNode.nodes.push(node);
636
- return this;
637
- }
638
- _blockNode(node) {
639
- this._currNode.nodes.push(node);
640
- this._nodes.push(node);
641
- }
642
- _endBlockNode(N1, N2) {
643
- const n = this._currNode;
644
- if (n instanceof N1 || N2 && n instanceof N2) {
645
- this._nodes.pop();
548
+ // `for-in` statement.
549
+ // With option `ownProperties` replaced with a `for-of` loop for object keys
550
+ forIn(nameOrPrefix, obj, forBody, varKind = this.opts.es5 ? scope_1.varKinds.var : scope_1.varKinds.const) {
551
+ if (this.opts.ownProperties) {
552
+ return this.forOf(nameOrPrefix, (0, code_1._)`Object.keys(${obj})`, forBody);
553
+ }
554
+ const name = this._scope.toName(nameOrPrefix);
555
+ return this._for(new ForIter("in", varKind, name, obj), () => forBody(name));
556
+ }
557
+ // end `for` loop
558
+ endFor() {
559
+ return this._endBlockNode(For);
560
+ }
561
+ // `label` statement
562
+ label(label) {
563
+ return this._leafNode(new Label(label));
564
+ }
565
+ // `break` statement
566
+ break(label) {
567
+ return this._leafNode(new Break(label));
568
+ }
569
+ // `return` statement
570
+ return(value) {
571
+ const node = new Return();
572
+ this._blockNode(node);
573
+ this.code(value);
574
+ if (node.nodes.length !== 1)
575
+ throw new Error('CodeGen: "return" should have one node');
576
+ return this._endBlockNode(Return);
577
+ }
578
+ // `try` statement
579
+ try(tryBody, catchCode, finallyCode) {
580
+ if (!catchCode && !finallyCode)
581
+ throw new Error('CodeGen: "try" without "catch" and "finally"');
582
+ const node = new Try();
583
+ this._blockNode(node);
584
+ this.code(tryBody);
585
+ if (catchCode) {
586
+ const error = this.name("e");
587
+ this._currNode = node.catch = new Catch(error);
588
+ catchCode(error);
589
+ }
590
+ if (finallyCode) {
591
+ this._currNode = node.finally = new Finally();
592
+ this.code(finallyCode);
593
+ }
594
+ return this._endBlockNode(Catch, Finally);
595
+ }
596
+ // `throw` statement
597
+ throw(error) {
598
+ return this._leafNode(new Throw(error));
599
+ }
600
+ // start self-balancing block
601
+ block(body, nodeCount) {
602
+ this._blockStarts.push(this._nodes.length);
603
+ if (body)
604
+ this.code(body).endBlock(nodeCount);
605
+ return this;
606
+ }
607
+ // end the current self-balancing block
608
+ endBlock(nodeCount) {
609
+ const len = this._blockStarts.pop();
610
+ if (len === void 0)
611
+ throw new Error("CodeGen: not in self-balancing block");
612
+ const toClose = this._nodes.length - len;
613
+ if (toClose < 0 || nodeCount !== void 0 && toClose !== nodeCount) {
614
+ throw new Error(`CodeGen: wrong number of nodes: ${toClose} vs ${nodeCount} expected`);
615
+ }
616
+ this._nodes.length = len;
617
+ return this;
618
+ }
619
+ // `function` heading (or definition if funcBody is passed)
620
+ func(name, args = code_1.nil, async, funcBody) {
621
+ this._blockNode(new Func(name, args, async));
622
+ if (funcBody)
623
+ this.code(funcBody).endFunc();
624
+ return this;
625
+ }
626
+ // end function definition
627
+ endFunc() {
628
+ return this._endBlockNode(Func);
629
+ }
630
+ optimize(n = 1) {
631
+ while (n-- > 0) {
632
+ this._root.optimizeNodes();
633
+ this._root.optimizeNames(this._root.names, this._constants);
634
+ }
635
+ }
636
+ _leafNode(node) {
637
+ this._currNode.nodes.push(node);
638
+ return this;
639
+ }
640
+ _blockNode(node) {
641
+ this._currNode.nodes.push(node);
642
+ this._nodes.push(node);
643
+ }
644
+ _endBlockNode(N1, N2) {
645
+ const n = this._currNode;
646
+ if (n instanceof N1 || N2 && n instanceof N2) {
647
+ this._nodes.pop();
648
+ return this;
649
+ }
650
+ throw new Error(`CodeGen: not in block "${N2 ? `${N1.kind}/${N2.kind}` : N1.kind}"`);
651
+ }
652
+ _elseNode(node) {
653
+ const n = this._currNode;
654
+ if (!(n instanceof If)) {
655
+ throw new Error('CodeGen: "else" without "if"');
656
+ }
657
+ this._currNode = n.else = node;
646
658
  return this;
647
659
  }
648
- throw new Error(`CodeGen: not in block "${N2 ? `${N1.kind}/${N2.kind}` : N1.kind}"`);
660
+ get _root() {
661
+ return this._nodes[0];
662
+ }
663
+ get _currNode() {
664
+ const ns = this._nodes;
665
+ return ns[ns.length - 1];
666
+ }
667
+ set _currNode(node) {
668
+ const ns = this._nodes;
669
+ ns[ns.length - 1] = node;
670
+ }
671
+ }
672
+ exports$1.CodeGen = CodeGen;
673
+ function addNames(names, from) {
674
+ for (const n in from)
675
+ names[n] = (names[n] || 0) + (from[n] || 0);
676
+ return names;
649
677
  }
650
- _elseNode(node) {
651
- const n = this._currNode;
652
- if (!(n instanceof If)) {
653
- throw new Error('CodeGen: "else" without "if"');
678
+ function addExprNames(names, from) {
679
+ return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
680
+ }
681
+ function optimizeExpr(expr, names, constants) {
682
+ if (expr instanceof code_1.Name)
683
+ return replaceName(expr);
684
+ if (!canOptimize(expr))
685
+ return expr;
686
+ return new code_1._Code(expr._items.reduce((items, c) => {
687
+ if (c instanceof code_1.Name)
688
+ c = replaceName(c);
689
+ if (c instanceof code_1._Code)
690
+ items.push(...c._items);
691
+ else
692
+ items.push(c);
693
+ return items;
694
+ }, []));
695
+ function replaceName(n) {
696
+ const c = constants[n.str];
697
+ if (c === void 0 || names[n.str] !== 1)
698
+ return n;
699
+ delete names[n.str];
700
+ return c;
701
+ }
702
+ function canOptimize(e) {
703
+ return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants[c.str] !== void 0);
654
704
  }
655
- this._currNode = n.else = node;
656
- return this;
657
705
  }
658
- get _root() {
659
- return this._nodes[0];
706
+ function subtractNames(names, from) {
707
+ for (const n in from)
708
+ names[n] = (names[n] || 0) - (from[n] || 0);
660
709
  }
661
- get _currNode() {
662
- const ns = this._nodes;
663
- return ns[ns.length - 1];
710
+ function not(x) {
711
+ return typeof x == "boolean" || typeof x == "number" || x === null ? !x : (0, code_1._)`!${par(x)}`;
664
712
  }
665
- set _currNode(node) {
666
- const ns = this._nodes;
667
- ns[ns.length - 1] = node;
713
+ exports$1.not = not;
714
+ const andCode = mappend(exports$1.operators.AND);
715
+ function and(...args) {
716
+ return args.reduce(andCode);
668
717
  }
669
- }
670
- exports$1.CodeGen = CodeGen;
671
- function addNames(names, from) {
672
- for (const n in from)
673
- names[n] = (names[n] || 0) + (from[n] || 0);
674
- return names;
675
- }
676
- function addExprNames(names, from) {
677
- return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
678
- }
679
- function optimizeExpr(expr, names, constants) {
680
- if (expr instanceof code_1.Name)
681
- return replaceName(expr);
682
- if (!canOptimize(expr))
683
- return expr;
684
- return new code_1._Code(expr._items.reduce((items, c) => {
685
- if (c instanceof code_1.Name)
686
- c = replaceName(c);
687
- if (c instanceof code_1._Code)
688
- items.push(...c._items);
689
- else
690
- items.push(c);
691
- return items;
692
- }, []));
693
- function replaceName(n) {
694
- const c = constants[n.str];
695
- if (c === void 0 || names[n.str] !== 1)
696
- return n;
697
- delete names[n.str];
698
- return c;
699
- }
700
- function canOptimize(e) {
701
- return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants[c.str] !== void 0);
718
+ exports$1.and = and;
719
+ const orCode = mappend(exports$1.operators.OR);
720
+ function or(...args) {
721
+ return args.reduce(orCode);
702
722
  }
703
- }
704
- function subtractNames(names, from) {
705
- for (const n in from)
706
- names[n] = (names[n] || 0) - (from[n] || 0);
707
- }
708
- function not(x) {
709
- return typeof x == "boolean" || typeof x == "number" || x === null ? !x : (0, code_1._)`!${par(x)}`;
710
- }
711
- exports$1.not = not;
712
- const andCode = mappend(exports$1.operators.AND);
713
- function and(...args) {
714
- return args.reduce(andCode);
715
- }
716
- exports$1.and = and;
717
- const orCode = mappend(exports$1.operators.OR);
718
- function or(...args) {
719
- return args.reduce(orCode);
720
- }
721
- exports$1.or = or;
722
- function mappend(op) {
723
- return (x, y) => x === code_1.nil ? y : y === code_1.nil ? x : (0, code_1._)`${par(x)} ${op} ${par(y)}`;
724
- }
725
- function par(x) {
726
- return x instanceof code_1.Name ? x : (0, code_1._)`(${x})`;
727
- }
728
- })(codegen);
723
+ exports$1.or = or;
724
+ function mappend(op) {
725
+ return (x, y) => x === code_1.nil ? y : y === code_1.nil ? x : (0, code_1._)`${par(x)} ${op} ${par(y)}`;
726
+ }
727
+ function par(x) {
728
+ return x instanceof code_1.Name ? x : (0, code_1._)`(${x})`;
729
+ }
730
+ })(codegen);
731
+ return codegen;
732
+ }
733
+ export {
734
+ requireCodegen as __require
735
+ };
729
736
  //# sourceMappingURL=index.js.map