@tsonic/emitter 0.0.1 → 0.0.3

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 (652) hide show
  1. package/dist/.tsbuildinfo +1 -0
  2. package/dist/adapter-generator.d.ts +28 -0
  3. package/dist/adapter-generator.d.ts.map +1 -0
  4. package/dist/adapter-generator.js +83 -0
  5. package/dist/adapter-generator.js.map +1 -0
  6. package/dist/array.test.d.ts +6 -0
  7. package/dist/array.test.d.ts.map +1 -0
  8. package/dist/array.test.js +274 -0
  9. package/dist/array.test.js.map +1 -0
  10. package/dist/constants.d.ts +15 -0
  11. package/dist/constants.d.ts.map +1 -0
  12. package/dist/constants.js +22 -0
  13. package/dist/constants.js.map +1 -0
  14. package/dist/core/exports.d.ts +10 -0
  15. package/dist/core/exports.d.ts.map +1 -0
  16. package/dist/core/exports.js +28 -0
  17. package/dist/core/exports.js.map +1 -0
  18. package/dist/core/imports.d.ts +26 -0
  19. package/dist/core/imports.d.ts.map +1 -0
  20. package/dist/core/imports.js +245 -0
  21. package/dist/core/imports.js.map +1 -0
  22. package/dist/core/imports.test.d.ts +6 -0
  23. package/dist/core/imports.test.d.ts.map +1 -0
  24. package/dist/core/imports.test.js +76 -0
  25. package/dist/core/imports.test.js.map +1 -0
  26. package/dist/core/index.d.ts +9 -0
  27. package/dist/core/index.d.ts.map +1 -0
  28. package/{src/core/index.ts → dist/core/index.js} +1 -1
  29. package/dist/core/index.js.map +1 -0
  30. package/dist/core/module-emitter/assembly.d.ts +21 -0
  31. package/dist/core/module-emitter/assembly.d.ts.map +1 -0
  32. package/dist/core/module-emitter/assembly.js +58 -0
  33. package/dist/core/module-emitter/assembly.js.map +1 -0
  34. package/dist/core/module-emitter/header.d.ts +10 -0
  35. package/dist/core/module-emitter/header.d.ts.map +1 -0
  36. package/dist/core/module-emitter/header.js +13 -0
  37. package/dist/core/module-emitter/header.js.map +1 -0
  38. package/{src/core/module-emitter/index.ts → dist/core/module-emitter/index.d.ts} +3 -10
  39. package/dist/core/module-emitter/index.d.ts.map +1 -0
  40. package/dist/core/module-emitter/index.js +10 -0
  41. package/dist/core/module-emitter/index.js.map +1 -0
  42. package/dist/core/module-emitter/namespace.d.ts +14 -0
  43. package/dist/core/module-emitter/namespace.d.ts.map +1 -0
  44. package/dist/core/module-emitter/namespace.js +26 -0
  45. package/dist/core/module-emitter/namespace.js.map +1 -0
  46. package/dist/core/module-emitter/orchestrator.d.ts +10 -0
  47. package/dist/core/module-emitter/orchestrator.d.ts.map +1 -0
  48. package/dist/core/module-emitter/orchestrator.js +58 -0
  49. package/dist/core/module-emitter/orchestrator.js.map +1 -0
  50. package/dist/core/module-emitter/separation.d.ts +14 -0
  51. package/dist/core/module-emitter/separation.d.ts.map +1 -0
  52. package/dist/core/module-emitter/separation.js +27 -0
  53. package/dist/core/module-emitter/separation.js.map +1 -0
  54. package/dist/core/module-emitter/static-container.d.ts +18 -0
  55. package/dist/core/module-emitter/static-container.d.ts.map +1 -0
  56. package/dist/core/module-emitter/static-container.js +49 -0
  57. package/dist/core/module-emitter/static-container.js.map +1 -0
  58. package/dist/core/module-emitter.d.ts +6 -0
  59. package/dist/core/module-emitter.d.ts.map +1 -0
  60. package/{src/core/module-emitter.ts → dist/core/module-emitter.js} +1 -1
  61. package/dist/core/module-emitter.js.map +1 -0
  62. package/dist/core/module-emitter.test.d.ts +6 -0
  63. package/dist/core/module-emitter.test.d.ts.map +1 -0
  64. package/dist/core/module-emitter.test.js +147 -0
  65. package/dist/core/module-emitter.test.js.map +1 -0
  66. package/dist/core/module-map.d.ts +35 -0
  67. package/dist/core/module-map.d.ts.map +1 -0
  68. package/dist/core/module-map.js +170 -0
  69. package/dist/core/module-map.js.map +1 -0
  70. package/dist/core/options.d.ts +9 -0
  71. package/dist/core/options.d.ts.map +1 -0
  72. package/dist/core/options.js +14 -0
  73. package/dist/core/options.js.map +1 -0
  74. package/dist/core/type-params.d.ts +9 -0
  75. package/dist/core/type-params.d.ts.map +1 -0
  76. package/dist/core/type-params.js +31 -0
  77. package/dist/core/type-params.js.map +1 -0
  78. package/dist/emitter-types/context.d.ts +29 -0
  79. package/dist/emitter-types/context.d.ts.map +1 -0
  80. package/dist/emitter-types/context.js +68 -0
  81. package/dist/emitter-types/context.js.map +1 -0
  82. package/dist/emitter-types/core.d.ts +142 -0
  83. package/dist/emitter-types/core.d.ts.map +1 -0
  84. package/dist/emitter-types/core.js +5 -0
  85. package/dist/emitter-types/core.js.map +1 -0
  86. package/dist/emitter-types/csharp-types.d.ts +27 -0
  87. package/dist/emitter-types/csharp-types.d.ts.map +1 -0
  88. package/dist/emitter-types/csharp-types.js +5 -0
  89. package/dist/emitter-types/csharp-types.js.map +1 -0
  90. package/dist/emitter-types/formatting.d.ts +9 -0
  91. package/dist/emitter-types/formatting.d.ts.map +1 -0
  92. package/dist/emitter-types/formatting.js +11 -0
  93. package/dist/emitter-types/formatting.js.map +1 -0
  94. package/dist/emitter-types/fqn.d.ts +53 -0
  95. package/dist/emitter-types/fqn.d.ts.map +1 -0
  96. package/dist/emitter-types/fqn.js +65 -0
  97. package/dist/emitter-types/fqn.js.map +1 -0
  98. package/dist/emitter-types/index.d.ts +9 -0
  99. package/dist/emitter-types/index.d.ts.map +1 -0
  100. package/dist/emitter-types/index.js +7 -0
  101. package/dist/emitter-types/index.js.map +1 -0
  102. package/dist/emitter.d.ts +27 -0
  103. package/dist/emitter.d.ts.map +1 -0
  104. package/dist/emitter.js +127 -0
  105. package/dist/emitter.js.map +1 -0
  106. package/dist/expression-emitter.d.ts +15 -0
  107. package/dist/expression-emitter.d.ts.map +1 -0
  108. package/dist/expression-emitter.js +69 -0
  109. package/dist/expression-emitter.js.map +1 -0
  110. package/dist/expressions/access.d.ts +12 -0
  111. package/dist/expressions/access.d.ts.map +1 -0
  112. package/dist/expressions/access.js +116 -0
  113. package/dist/expressions/access.js.map +1 -0
  114. package/dist/expressions/calls.d.ts +18 -0
  115. package/dist/expressions/calls.d.ts.map +1 -0
  116. package/dist/expressions/calls.js +324 -0
  117. package/dist/expressions/calls.js.map +1 -0
  118. package/dist/expressions/collections.d.ts +24 -0
  119. package/dist/expressions/collections.d.ts.map +1 -0
  120. package/dist/expressions/collections.js +254 -0
  121. package/dist/expressions/collections.js.map +1 -0
  122. package/dist/expressions/functions.d.ts +18 -0
  123. package/dist/expressions/functions.d.ts.map +1 -0
  124. package/dist/expressions/functions.js +60 -0
  125. package/dist/expressions/functions.js.map +1 -0
  126. package/dist/expressions/identifiers.d.ts +22 -0
  127. package/dist/expressions/identifiers.d.ts.map +1 -0
  128. package/dist/expressions/identifiers.js +99 -0
  129. package/dist/expressions/identifiers.js.map +1 -0
  130. package/dist/expressions/index.d.ts +12 -0
  131. package/dist/expressions/index.d.ts.map +1 -0
  132. package/{src/expressions/index.ts → dist/expressions/index.js} +3 -21
  133. package/dist/expressions/index.js.map +1 -0
  134. package/dist/expressions/index.test.d.ts +6 -0
  135. package/dist/expressions/index.test.d.ts.map +1 -0
  136. package/dist/expressions/index.test.js +480 -0
  137. package/dist/expressions/index.test.js.map +1 -0
  138. package/dist/expressions/literals.d.ts +31 -0
  139. package/dist/expressions/literals.d.ts.map +1 -0
  140. package/dist/expressions/literals.js +116 -0
  141. package/dist/expressions/literals.js.map +1 -0
  142. package/dist/expressions/operators.d.ts +72 -0
  143. package/dist/expressions/operators.d.ts.map +1 -0
  144. package/dist/expressions/operators.js +247 -0
  145. package/dist/expressions/operators.js.map +1 -0
  146. package/dist/expressions/other.d.ts +28 -0
  147. package/dist/expressions/other.d.ts.map +1 -0
  148. package/dist/expressions/other.js +48 -0
  149. package/dist/expressions/other.js.map +1 -0
  150. package/dist/generator-exchange.d.ts +11 -0
  151. package/dist/generator-exchange.d.ts.map +1 -0
  152. package/dist/generator-exchange.js +92 -0
  153. package/dist/generator-exchange.js.map +1 -0
  154. package/dist/generator.test.d.ts +6 -0
  155. package/dist/generator.test.d.ts.map +1 -0
  156. package/dist/generator.test.js +177 -0
  157. package/dist/generator.test.js.map +1 -0
  158. package/dist/golden-tests/config-parser.d.ts +9 -0
  159. package/dist/golden-tests/config-parser.d.ts.map +1 -0
  160. package/dist/golden-tests/config-parser.js +57 -0
  161. package/dist/golden-tests/config-parser.js.map +1 -0
  162. package/dist/golden-tests/discovery.d.ts +9 -0
  163. package/dist/golden-tests/discovery.d.ts.map +1 -0
  164. package/dist/golden-tests/discovery.js +51 -0
  165. package/dist/golden-tests/discovery.js.map +1 -0
  166. package/{src/golden-tests/index.ts → dist/golden-tests/index.d.ts} +1 -1
  167. package/dist/golden-tests/index.d.ts.map +1 -0
  168. package/dist/golden-tests/index.js +9 -0
  169. package/dist/golden-tests/index.js.map +1 -0
  170. package/dist/golden-tests/registration.d.ts +9 -0
  171. package/dist/golden-tests/registration.d.ts.map +1 -0
  172. package/dist/golden-tests/registration.js +23 -0
  173. package/dist/golden-tests/registration.js.map +1 -0
  174. package/dist/golden-tests/runner.d.ts +13 -0
  175. package/dist/golden-tests/runner.d.ts.map +1 -0
  176. package/dist/golden-tests/runner.js +100 -0
  177. package/dist/golden-tests/runner.js.map +1 -0
  178. package/dist/golden-tests/tree-builder.d.ts +9 -0
  179. package/dist/golden-tests/tree-builder.d.ts.map +1 -0
  180. package/dist/golden-tests/tree-builder.js +35 -0
  181. package/dist/golden-tests/tree-builder.js.map +1 -0
  182. package/dist/golden-tests/types.d.ts +19 -0
  183. package/dist/golden-tests/types.d.ts.map +1 -0
  184. package/dist/golden-tests/types.js +5 -0
  185. package/dist/golden-tests/types.js.map +1 -0
  186. package/dist/golden.test.d.ts +11 -0
  187. package/dist/golden.test.d.ts.map +1 -0
  188. package/{src/golden.test.ts → dist/golden.test.js} +15 -20
  189. package/dist/golden.test.js.map +1 -0
  190. package/dist/hierarchical-bindings.test.d.ts +6 -0
  191. package/dist/hierarchical-bindings.test.d.ts.map +1 -0
  192. package/dist/hierarchical-bindings.test.js +204 -0
  193. package/dist/hierarchical-bindings.test.js.map +1 -0
  194. package/dist/index.d.ts +9 -0
  195. package/dist/index.d.ts.map +1 -0
  196. package/{src/index.ts → dist/index.js} +2 -7
  197. package/dist/index.js.map +1 -0
  198. package/dist/integration.test.d.ts +6 -0
  199. package/dist/integration.test.d.ts.map +1 -0
  200. package/dist/integration.test.js +235 -0
  201. package/dist/integration.test.js.map +1 -0
  202. package/dist/specialization/call-site-rewriting.test.d.ts +6 -0
  203. package/dist/specialization/call-site-rewriting.test.d.ts.map +1 -0
  204. package/dist/specialization/call-site-rewriting.test.js +92 -0
  205. package/dist/specialization/call-site-rewriting.test.js.map +1 -0
  206. package/dist/specialization/collection/expressions.d.ts +10 -0
  207. package/dist/specialization/collection/expressions.d.ts.map +1 -0
  208. package/dist/specialization/collection/expressions.js +142 -0
  209. package/dist/specialization/collection/expressions.js.map +1 -0
  210. package/dist/specialization/collection/index.d.ts +7 -0
  211. package/dist/specialization/collection/index.d.ts.map +1 -0
  212. package/{src/specialization/collection/index.ts → dist/specialization/collection/index.js} +1 -1
  213. package/dist/specialization/collection/index.js.map +1 -0
  214. package/dist/specialization/collection/orchestrator.d.ts +11 -0
  215. package/dist/specialization/collection/orchestrator.d.ts.map +1 -0
  216. package/dist/specialization/collection/orchestrator.js +18 -0
  217. package/dist/specialization/collection/orchestrator.js.map +1 -0
  218. package/dist/specialization/collection/statements.d.ts +10 -0
  219. package/dist/specialization/collection/statements.d.ts.map +1 -0
  220. package/dist/specialization/collection/statements.js +75 -0
  221. package/dist/specialization/collection/statements.js.map +1 -0
  222. package/dist/specialization/collection.d.ts +6 -0
  223. package/dist/specialization/collection.d.ts.map +1 -0
  224. package/dist/specialization/collection.js +6 -0
  225. package/dist/specialization/collection.js.map +1 -0
  226. package/dist/specialization/generation.d.ts +11 -0
  227. package/dist/specialization/generation.d.ts.map +1 -0
  228. package/dist/specialization/generation.js +137 -0
  229. package/dist/specialization/generation.js.map +1 -0
  230. package/dist/specialization/generic-classes.test.d.ts +6 -0
  231. package/dist/specialization/generic-classes.test.d.ts.map +1 -0
  232. package/dist/specialization/generic-classes.test.js +55 -0
  233. package/dist/specialization/generic-classes.test.js.map +1 -0
  234. package/dist/specialization/generic-functions.test.d.ts +6 -0
  235. package/dist/specialization/generic-functions.test.d.ts.map +1 -0
  236. package/dist/specialization/generic-functions.test.js +275 -0
  237. package/dist/specialization/generic-functions.test.js.map +1 -0
  238. package/dist/specialization/helpers.d.ts +13 -0
  239. package/dist/specialization/helpers.d.ts.map +1 -0
  240. package/dist/specialization/helpers.js +33 -0
  241. package/dist/specialization/helpers.js.map +1 -0
  242. package/dist/specialization/index.d.ts +10 -0
  243. package/dist/specialization/index.d.ts.map +1 -0
  244. package/{src/specialization/index.ts → dist/specialization/index.js} +3 -17
  245. package/dist/specialization/index.js.map +1 -0
  246. package/dist/specialization/interfaces.test.d.ts +6 -0
  247. package/dist/specialization/interfaces.test.d.ts.map +1 -0
  248. package/dist/specialization/interfaces.test.js +139 -0
  249. package/dist/specialization/interfaces.test.js.map +1 -0
  250. package/dist/specialization/naming.d.ts +13 -0
  251. package/dist/specialization/naming.d.ts.map +1 -0
  252. package/dist/specialization/naming.js +25 -0
  253. package/dist/specialization/naming.js.map +1 -0
  254. package/dist/specialization/substitution.d.ts +17 -0
  255. package/dist/specialization/substitution.d.ts.map +1 -0
  256. package/dist/specialization/substitution.js +150 -0
  257. package/dist/specialization/substitution.js.map +1 -0
  258. package/dist/specialization/type-aliases.test.d.ts +6 -0
  259. package/dist/specialization/type-aliases.test.d.ts.map +1 -0
  260. package/dist/specialization/type-aliases.test.js +124 -0
  261. package/dist/specialization/type-aliases.test.js.map +1 -0
  262. package/dist/specialization/types.d.ts +14 -0
  263. package/dist/specialization/types.d.ts.map +1 -0
  264. package/dist/specialization/types.js +5 -0
  265. package/dist/specialization/types.js.map +1 -0
  266. package/{src/specialization-generator.ts → dist/specialization-generator.d.ts} +4 -15
  267. package/dist/specialization-generator.d.ts.map +1 -0
  268. package/dist/specialization-generator.js +11 -0
  269. package/dist/specialization-generator.js.map +1 -0
  270. package/dist/statement-emitter.d.ts +13 -0
  271. package/dist/statement-emitter.d.ts.map +1 -0
  272. package/dist/statement-emitter.js +67 -0
  273. package/dist/statement-emitter.js.map +1 -0
  274. package/dist/statements/blocks.d.ts +40 -0
  275. package/dist/statements/blocks.d.ts.map +1 -0
  276. package/dist/statements/blocks.js +86 -0
  277. package/dist/statements/blocks.js.map +1 -0
  278. package/{src/statements/classes/helpers.ts → dist/statements/classes/helpers.d.ts} +2 -3
  279. package/dist/statements/classes/helpers.d.ts.map +1 -0
  280. package/dist/statements/classes/helpers.js +8 -0
  281. package/dist/statements/classes/helpers.js.map +1 -0
  282. package/dist/statements/classes/index.d.ts +9 -0
  283. package/dist/statements/classes/index.d.ts.map +1 -0
  284. package/{src/statements/classes/index.ts → dist/statements/classes/index.js} +2 -6
  285. package/dist/statements/classes/index.js.map +1 -0
  286. package/dist/statements/classes/inline-types.d.ts +21 -0
  287. package/dist/statements/classes/inline-types.d.ts.map +1 -0
  288. package/dist/statements/classes/inline-types.js +50 -0
  289. package/dist/statements/classes/inline-types.js.map +1 -0
  290. package/dist/statements/classes/members/constructors.d.ts +12 -0
  291. package/dist/statements/classes/members/constructors.d.ts.map +1 -0
  292. package/dist/statements/classes/members/constructors.js +90 -0
  293. package/dist/statements/classes/members/constructors.js.map +1 -0
  294. package/dist/statements/classes/members/index.d.ts +8 -0
  295. package/dist/statements/classes/members/index.d.ts.map +1 -0
  296. package/{src/statements/classes/members/index.ts → dist/statements/classes/members/index.js} +1 -1
  297. package/dist/statements/classes/members/index.js.map +1 -0
  298. package/dist/statements/classes/members/methods.d.ts +12 -0
  299. package/dist/statements/classes/members/methods.d.ts.map +1 -0
  300. package/dist/statements/classes/members/methods.js +100 -0
  301. package/dist/statements/classes/members/methods.js.map +1 -0
  302. package/dist/statements/classes/members/orchestrator.d.ts +10 -0
  303. package/dist/statements/classes/members/orchestrator.d.ts.map +1 -0
  304. package/dist/statements/classes/members/orchestrator.js +24 -0
  305. package/dist/statements/classes/members/orchestrator.js.map +1 -0
  306. package/dist/statements/classes/members/properties.d.ts +12 -0
  307. package/dist/statements/classes/members/properties.d.ts.map +1 -0
  308. package/dist/statements/classes/members/properties.js +48 -0
  309. package/dist/statements/classes/members/properties.js.map +1 -0
  310. package/dist/statements/classes/members.d.ts +6 -0
  311. package/dist/statements/classes/members.d.ts.map +1 -0
  312. package/{src/statements/classes/members.ts → dist/statements/classes/members.js} +1 -1
  313. package/dist/statements/classes/members.js.map +1 -0
  314. package/dist/statements/classes/parameters.d.ts +10 -0
  315. package/dist/statements/classes/parameters.d.ts.map +1 -0
  316. package/dist/statements/classes/parameters.js +50 -0
  317. package/dist/statements/classes/parameters.js.map +1 -0
  318. package/dist/statements/classes/properties.d.ts +11 -0
  319. package/dist/statements/classes/properties.d.ts.map +1 -0
  320. package/dist/statements/classes/properties.js +74 -0
  321. package/dist/statements/classes/properties.js.map +1 -0
  322. package/dist/statements/classes.d.ts +6 -0
  323. package/dist/statements/classes.d.ts.map +1 -0
  324. package/dist/statements/classes.js +6 -0
  325. package/dist/statements/classes.js.map +1 -0
  326. package/dist/statements/control/conditionals.d.ts +18 -0
  327. package/dist/statements/control/conditionals.d.ts.map +1 -0
  328. package/dist/statements/control/conditionals.js +98 -0
  329. package/dist/statements/control/conditionals.js.map +1 -0
  330. package/dist/statements/control/exceptions.d.ts +18 -0
  331. package/dist/statements/control/exceptions.d.ts.map +1 -0
  332. package/dist/statements/control/exceptions.js +38 -0
  333. package/dist/statements/control/exceptions.js.map +1 -0
  334. package/dist/statements/control/index.d.ts +7 -0
  335. package/dist/statements/control/index.d.ts.map +1 -0
  336. package/{src/statements/control/index.ts → dist/statements/control/index.js} +2 -6
  337. package/dist/statements/control/index.js.map +1 -0
  338. package/dist/statements/control/loops.d.ts +29 -0
  339. package/dist/statements/control/loops.d.ts.map +1 -0
  340. package/dist/statements/control/loops.js +186 -0
  341. package/dist/statements/control/loops.js.map +1 -0
  342. package/dist/statements/control.d.ts +6 -0
  343. package/dist/statements/control.d.ts.map +1 -0
  344. package/dist/statements/control.js +6 -0
  345. package/dist/statements/control.js.map +1 -0
  346. package/dist/statements/declarations/classes.d.ts +12 -0
  347. package/dist/statements/declarations/classes.d.ts.map +1 -0
  348. package/dist/statements/declarations/classes.js +61 -0
  349. package/dist/statements/declarations/classes.js.map +1 -0
  350. package/dist/statements/declarations/enums.d.ts +12 -0
  351. package/dist/statements/declarations/enums.d.ts.map +1 -0
  352. package/dist/statements/declarations/enums.js +25 -0
  353. package/dist/statements/declarations/enums.js.map +1 -0
  354. package/dist/statements/declarations/functions.d.ts +12 -0
  355. package/dist/statements/declarations/functions.d.ts.map +1 -0
  356. package/dist/statements/declarations/functions.js +110 -0
  357. package/dist/statements/declarations/functions.js.map +1 -0
  358. package/dist/statements/declarations/index.d.ts +10 -0
  359. package/dist/statements/declarations/index.d.ts.map +1 -0
  360. package/{src/statements/declarations/index.ts → dist/statements/declarations/index.js} +1 -1
  361. package/dist/statements/declarations/index.js.map +1 -0
  362. package/dist/statements/declarations/interfaces.d.ts +12 -0
  363. package/dist/statements/declarations/interfaces.d.ts.map +1 -0
  364. package/dist/statements/declarations/interfaces.js +85 -0
  365. package/dist/statements/declarations/interfaces.js.map +1 -0
  366. package/dist/statements/declarations/structs.test.d.ts +5 -0
  367. package/dist/statements/declarations/structs.test.d.ts.map +1 -0
  368. package/dist/statements/declarations/structs.test.js +165 -0
  369. package/dist/statements/declarations/structs.test.js.map +1 -0
  370. package/dist/statements/declarations/type-aliases.d.ts +12 -0
  371. package/dist/statements/declarations/type-aliases.d.ts.map +1 -0
  372. package/dist/statements/declarations/type-aliases.js +80 -0
  373. package/dist/statements/declarations/type-aliases.js.map +1 -0
  374. package/dist/statements/declarations/variables.d.ts +12 -0
  375. package/dist/statements/declarations/variables.d.ts.map +1 -0
  376. package/dist/statements/declarations/variables.js +120 -0
  377. package/dist/statements/declarations/variables.js.map +1 -0
  378. package/dist/statements/declarations.d.ts +6 -0
  379. package/dist/statements/declarations.d.ts.map +1 -0
  380. package/dist/statements/declarations.js +6 -0
  381. package/dist/statements/declarations.js.map +1 -0
  382. package/dist/statements/index.d.ts +8 -0
  383. package/dist/statements/index.d.ts.map +1 -0
  384. package/dist/statements/index.js +12 -0
  385. package/dist/statements/index.js.map +1 -0
  386. package/dist/statements/index.test.d.ts +6 -0
  387. package/dist/statements/index.test.d.ts.map +1 -0
  388. package/dist/statements/index.test.js +248 -0
  389. package/dist/statements/index.test.js.map +1 -0
  390. package/dist/type-assertion.test.d.ts +6 -0
  391. package/dist/type-assertion.test.d.ts.map +1 -0
  392. package/dist/type-assertion.test.js +133 -0
  393. package/dist/type-assertion.test.js.map +1 -0
  394. package/dist/type-emitter.d.ts +6 -0
  395. package/dist/type-emitter.d.ts.map +1 -0
  396. package/dist/type-emitter.js +6 -0
  397. package/dist/type-emitter.js.map +1 -0
  398. package/dist/types/arrays.d.ts +12 -0
  399. package/dist/types/arrays.d.ts.map +1 -0
  400. package/dist/types/arrays.js +15 -0
  401. package/dist/types/arrays.js.map +1 -0
  402. package/dist/types/dictionaries.d.ts +17 -0
  403. package/dist/types/dictionaries.d.ts.map +1 -0
  404. package/dist/types/dictionaries.js +37 -0
  405. package/dist/types/dictionaries.js.map +1 -0
  406. package/dist/types/emitter.d.ts +10 -0
  407. package/dist/types/emitter.d.ts.map +1 -0
  408. package/dist/types/emitter.js +53 -0
  409. package/dist/types/emitter.js.map +1 -0
  410. package/dist/types/functions.d.ts +12 -0
  411. package/dist/types/functions.d.ts.map +1 -0
  412. package/dist/types/functions.js +34 -0
  413. package/dist/types/functions.js.map +1 -0
  414. package/dist/types/index.d.ts +14 -0
  415. package/dist/types/index.d.ts.map +1 -0
  416. package/{src/types/index.ts → dist/types/index.js} +1 -1
  417. package/dist/types/index.js.map +1 -0
  418. package/dist/types/index.test.d.ts +6 -0
  419. package/dist/types/index.test.d.ts.map +1 -0
  420. package/dist/types/index.test.js +109 -0
  421. package/dist/types/index.test.js.map +1 -0
  422. package/dist/types/intersections.d.ts +12 -0
  423. package/dist/types/intersections.d.ts.map +1 -0
  424. package/dist/types/intersections.js +13 -0
  425. package/dist/types/intersections.js.map +1 -0
  426. package/dist/types/literals.d.ts +12 -0
  427. package/dist/types/literals.d.ts.map +1 -0
  428. package/dist/types/literals.js +20 -0
  429. package/dist/types/literals.js.map +1 -0
  430. package/{src/types/objects.ts → dist/types/objects.d.ts} +4 -11
  431. package/dist/types/objects.d.ts.map +1 -0
  432. package/dist/types/objects.js +19 -0
  433. package/dist/types/objects.js.map +1 -0
  434. package/dist/types/parameters.d.ts +15 -0
  435. package/dist/types/parameters.d.ts.map +1 -0
  436. package/dist/types/parameters.js +69 -0
  437. package/dist/types/parameters.js.map +1 -0
  438. package/dist/types/parameters.test.d.ts +5 -0
  439. package/dist/types/parameters.test.d.ts.map +1 -0
  440. package/dist/types/parameters.test.js +135 -0
  441. package/dist/types/parameters.test.js.map +1 -0
  442. package/dist/types/primitives.d.ts +12 -0
  443. package/dist/types/primitives.d.ts.map +1 -0
  444. package/dist/types/primitives.js +17 -0
  445. package/dist/types/primitives.js.map +1 -0
  446. package/dist/types/references.d.ts +14 -0
  447. package/dist/types/references.d.ts.map +1 -0
  448. package/dist/types/references.js +154 -0
  449. package/dist/types/references.js.map +1 -0
  450. package/dist/types/unions.d.ts +12 -0
  451. package/dist/types/unions.d.ts.map +1 -0
  452. package/dist/types/unions.js +45 -0
  453. package/dist/types/unions.js.map +1 -0
  454. package/dist/types/unions.test.d.ts +6 -0
  455. package/dist/types/unions.test.d.ts.map +1 -0
  456. package/dist/types/unions.test.js +367 -0
  457. package/dist/types/unions.test.js.map +1 -0
  458. package/dist/types.d.ts +7 -0
  459. package/dist/types.d.ts.map +1 -0
  460. package/dist/types.js +6 -0
  461. package/dist/types.js.map +1 -0
  462. package/package.json +5 -2
  463. package/scripts/update-golden-tests.ts +0 -119
  464. package/src/adapter-generator.ts +0 -112
  465. package/src/array.test.ts +0 -301
  466. package/src/constants.ts +0 -32
  467. package/src/core/exports.ts +0 -36
  468. package/src/core/imports.test.ts +0 -83
  469. package/src/core/imports.ts +0 -243
  470. package/src/core/module-emitter/assembly.ts +0 -83
  471. package/src/core/module-emitter/header.ts +0 -19
  472. package/src/core/module-emitter/namespace.ts +0 -39
  473. package/src/core/module-emitter/orchestrator.ts +0 -98
  474. package/src/core/module-emitter/separation.ts +0 -41
  475. package/src/core/module-emitter/static-container.ts +0 -75
  476. package/src/core/module-emitter.test.ts +0 -154
  477. package/src/core/module-map.ts +0 -218
  478. package/src/core/options.ts +0 -16
  479. package/src/core/type-params.ts +0 -34
  480. package/src/emitter-types/context.ts +0 -91
  481. package/src/emitter-types/core.ts +0 -138
  482. package/src/emitter-types/csharp-types.ts +0 -42
  483. package/src/emitter-types/formatting.ts +0 -13
  484. package/src/emitter-types/fqn.ts +0 -81
  485. package/src/emitter-types/index.ts +0 -31
  486. package/src/emitter.ts +0 -107
  487. package/src/expression-emitter.ts +0 -112
  488. package/src/expressions/access.ts +0 -104
  489. package/src/expressions/calls.ts +0 -264
  490. package/src/expressions/collections.ts +0 -354
  491. package/src/expressions/functions.ts +0 -71
  492. package/src/expressions/identifiers.ts +0 -125
  493. package/src/expressions/index.test.ts +0 -515
  494. package/src/expressions/literals.ts +0 -138
  495. package/src/expressions/operators.ts +0 -211
  496. package/src/expressions/other.ts +0 -63
  497. package/src/generator-exchange.ts +0 -120
  498. package/src/generator.test.ts +0 -193
  499. package/src/golden-tests/config-parser.ts +0 -67
  500. package/src/golden-tests/discovery.ts +0 -61
  501. package/src/golden-tests/registration.ts +0 -26
  502. package/src/golden-tests/runner.ts +0 -131
  503. package/src/golden-tests/tree-builder.ts +0 -43
  504. package/src/golden-tests/types.ts +0 -21
  505. package/src/hierarchical-bindings.test.ts +0 -258
  506. package/src/integration.test.ts +0 -303
  507. package/src/specialization/call-site-rewriting.test.ts +0 -99
  508. package/src/specialization/collection/expressions.ts +0 -184
  509. package/src/specialization/collection/orchestrator.ts +0 -25
  510. package/src/specialization/collection/statements.ts +0 -91
  511. package/src/specialization/collection.ts +0 -10
  512. package/src/specialization/generation.ts +0 -189
  513. package/src/specialization/generic-classes.test.ts +0 -59
  514. package/src/specialization/generic-functions.test.ts +0 -292
  515. package/src/specialization/helpers.ts +0 -39
  516. package/src/specialization/interfaces.test.ts +0 -151
  517. package/src/specialization/naming.ts +0 -34
  518. package/src/specialization/substitution.ts +0 -186
  519. package/src/specialization/type-aliases.test.ts +0 -134
  520. package/src/specialization/types.ts +0 -19
  521. package/src/statement-emitter.ts +0 -117
  522. package/src/statements/blocks.ts +0 -115
  523. package/src/statements/classes/inline-types.ts +0 -79
  524. package/src/statements/classes/members/constructors.ts +0 -123
  525. package/src/statements/classes/members/methods.ts +0 -137
  526. package/src/statements/classes/members/orchestrator.ts +0 -33
  527. package/src/statements/classes/members/properties.ts +0 -62
  528. package/src/statements/classes/parameters.ts +0 -69
  529. package/src/statements/classes/properties.ts +0 -95
  530. package/src/statements/classes.ts +0 -14
  531. package/src/statements/control/conditionals.ts +0 -134
  532. package/src/statements/control/exceptions.ts +0 -59
  533. package/src/statements/control/loops.ts +0 -250
  534. package/src/statements/control.ts +0 -14
  535. package/src/statements/declarations/classes.ts +0 -89
  536. package/src/statements/declarations/enums.ts +0 -32
  537. package/src/statements/declarations/functions.ts +0 -147
  538. package/src/statements/declarations/interfaces.ts +0 -116
  539. package/src/statements/declarations/structs.test.ts +0 -182
  540. package/src/statements/declarations/type-aliases.ts +0 -104
  541. package/src/statements/declarations/variables.ts +0 -159
  542. package/src/statements/declarations.ts +0 -13
  543. package/src/statements/index.test.ts +0 -258
  544. package/src/statements/index.ts +0 -43
  545. package/src/type-assertion.test.ts +0 -143
  546. package/src/type-emitter.ts +0 -18
  547. package/src/types/arrays.ts +0 -21
  548. package/src/types/dictionaries.ts +0 -52
  549. package/src/types/emitter.ts +0 -76
  550. package/src/types/functions.ts +0 -45
  551. package/src/types/index.test.ts +0 -116
  552. package/src/types/intersections.ts +0 -19
  553. package/src/types/literals.ts +0 -26
  554. package/src/types/parameters.test.ts +0 -146
  555. package/src/types/parameters.ts +0 -95
  556. package/src/types/primitives.ts +0 -24
  557. package/src/types/references.ts +0 -187
  558. package/src/types/unions.test.ts +0 -397
  559. package/src/types/unions.ts +0 -62
  560. package/src/types.ts +0 -33
  561. package/testcases/README.md +0 -213
  562. package/testcases/arrays/basic/ArrayLiteral.ts +0 -4
  563. package/testcases/arrays/basic/config.yaml +0 -1
  564. package/testcases/arrays/destructuring/ArrayDestructure.ts +0 -4
  565. package/testcases/arrays/destructuring/config.yaml +0 -1
  566. package/testcases/arrays/methods/ArrayMethods.ts +0 -6
  567. package/testcases/arrays/methods/config.yaml +0 -1
  568. package/testcases/arrays/multidimensional/MultiDimensional.ts +0 -10
  569. package/testcases/arrays/multidimensional/config.yaml +0 -1
  570. package/testcases/arrays/spread/ArraySpread.ts +0 -3
  571. package/testcases/arrays/spread/config.yaml +0 -1
  572. package/testcases/async/basic/AsyncFunction.ts +0 -5
  573. package/testcases/async/basic/config.yaml +0 -1
  574. package/testcases/classes/abstract/AbstractClasses.ts +0 -53
  575. package/testcases/classes/abstract/config.yaml +0 -1
  576. package/testcases/classes/basic/Person.ts +0 -12
  577. package/testcases/classes/basic/config.yaml +0 -1
  578. package/testcases/classes/constructor/User.ts +0 -11
  579. package/testcases/classes/constructor/config.yaml +0 -1
  580. package/testcases/classes/field-inference/Counter.ts +0 -11
  581. package/testcases/classes/field-inference/config.yaml +0 -1
  582. package/testcases/classes/inheritance/Inheritance.ts +0 -24
  583. package/testcases/classes/inheritance/config.yaml +0 -1
  584. package/testcases/classes/static-members/MathHelper.ts +0 -12
  585. package/testcases/classes/static-members/config.yaml +0 -1
  586. package/testcases/control-flow/error-handling/ErrorHandling.ts +0 -13
  587. package/testcases/control-flow/error-handling/config.yaml +0 -1
  588. package/testcases/control-flow/loops/Loops.ts +0 -21
  589. package/testcases/control-flow/loops/config.yaml +0 -1
  590. package/testcases/control-flow/switch/SwitchStatement.ts +0 -15
  591. package/testcases/control-flow/switch/config.yaml +0 -1
  592. package/testcases/edge-cases/complex-expressions/ComplexExpressions.ts +0 -10
  593. package/testcases/edge-cases/complex-expressions/config.yaml +0 -1
  594. package/testcases/edge-cases/nested-scopes/NestedScopes.ts +0 -10
  595. package/testcases/edge-cases/nested-scopes/config.yaml +0 -1
  596. package/testcases/edge-cases/shadowing/Shadowing.ts +0 -16
  597. package/testcases/edge-cases/shadowing/config.yaml +0 -1
  598. package/testcases/functions/arrow/ArrowFunction.ts +0 -5
  599. package/testcases/functions/arrow/config.yaml +0 -1
  600. package/testcases/functions/basic/Greet.ts +0 -3
  601. package/testcases/functions/basic/config.yaml +0 -1
  602. package/testcases/functions/closures/Closures.ts +0 -11
  603. package/testcases/functions/closures/config.yaml +0 -1
  604. package/testcases/functions/default-params/DefaultParams.ts +0 -7
  605. package/testcases/functions/default-params/config.yaml +0 -1
  606. package/testcases/functions/rest-params/RestParams.ts +0 -7
  607. package/testcases/functions/rest-params/config.yaml +0 -1
  608. package/testcases/functions/type-guards/TypeGuards.ts +0 -52
  609. package/testcases/functions/type-guards/config.yaml +0 -1
  610. package/testcases/operators/logical/LogicalOperators.ts +0 -11
  611. package/testcases/operators/logical/config.yaml +0 -1
  612. package/testcases/operators/nullish-coalescing/NullishCoalescing.ts +0 -7
  613. package/testcases/operators/nullish-coalescing/config.yaml +0 -1
  614. package/testcases/operators/optional-chaining/OptionalChaining.ts +0 -15
  615. package/testcases/operators/optional-chaining/config.yaml +0 -1
  616. package/testcases/real-world/advanced-generics/advanced-generics.ts +0 -116
  617. package/testcases/real-world/advanced-generics/config.yaml +0 -1
  618. package/testcases/real-world/async-ops/async-ops.ts +0 -67
  619. package/testcases/real-world/async-ops/config.yaml +0 -1
  620. package/testcases/real-world/business-logic/business-logic.ts +0 -215
  621. package/testcases/real-world/business-logic/config.yaml +0 -1
  622. package/testcases/real-world/calculator/calculator.ts +0 -29
  623. package/testcases/real-world/calculator/config.yaml +0 -1
  624. package/testcases/real-world/data-structures/config.yaml +0 -1
  625. package/testcases/real-world/data-structures/data-structures.ts +0 -133
  626. package/testcases/real-world/functional/config.yaml +0 -1
  627. package/testcases/real-world/functional/functional.ts +0 -116
  628. package/testcases/real-world/shapes/config.yaml +0 -1
  629. package/testcases/real-world/shapes/shapes.ts +0 -87
  630. package/testcases/real-world/string-utils/config.yaml +0 -1
  631. package/testcases/real-world/string-utils/string-utils.ts +0 -47
  632. package/testcases/real-world/todo-list/config.yaml +0 -1
  633. package/testcases/real-world/todo-list/todo-list.ts +0 -52
  634. package/testcases/real-world/type-guards/config.yaml +0 -1
  635. package/testcases/real-world/type-guards/type-guards.ts +0 -71
  636. package/testcases/structs/basic/Point.ts +0 -9
  637. package/testcases/structs/basic/config.yaml +0 -1
  638. package/testcases/types/conditional/ConditionalTypes.ts +0 -35
  639. package/testcases/types/conditional/config.yaml +0 -1
  640. package/testcases/types/constants/ModuleConstants.ts +0 -6
  641. package/testcases/types/constants/config.yaml +0 -1
  642. package/testcases/types/generics/Generics.ts +0 -15
  643. package/testcases/types/generics/config.yaml +0 -1
  644. package/testcases/types/interfaces/Interfaces.ts +0 -14
  645. package/testcases/types/interfaces/config.yaml +0 -1
  646. package/testcases/types/mapped/MappedTypes.ts +0 -27
  647. package/testcases/types/mapped/config.yaml +0 -1
  648. package/testcases/types/tuples-intersections/TuplesAndIntersections.ts +0 -46
  649. package/testcases/types/tuples-intersections/config.yaml +0 -1
  650. package/testcases/types/unions/UnionTypes.ts +0 -11
  651. package/testcases/types/unions/config.yaml +0 -1
  652. package/tsconfig.json +0 -14
@@ -1,243 +0,0 @@
1
- /**
2
- * Import processing and resolution
3
- *
4
- * All imports are resolved to fully-qualified global:: references.
5
- * No using statements are emitted - everything uses explicit FQN.
6
- *
7
- * All CLR name resolution happens here using module map - the emitter
8
- * just uses the pre-computed clrName directly (no string parsing).
9
- */
10
-
11
- import { IrImport, IrModule, IrImportSpecifier } from "@tsonic/frontend";
12
- import { EmitterContext, ImportBinding } from "../types.js";
13
- import { resolveImportPath } from "./module-map.js";
14
-
15
- /**
16
- * Process imports and build ImportBindings for local modules.
17
- *
18
- * NOTE: No using statements are collected. All type/member references
19
- * are emitted as fully-qualified global:: names.
20
- *
21
- * - BCL/runtime imports: No action needed (types use global:: FQN)
22
- * - Local module imports: Build ImportBindings with fully-qualified CLR names
23
- */
24
- export const processImports = (
25
- imports: readonly IrImport[],
26
- context: EmitterContext,
27
- module: IrModule
28
- ): EmitterContext => {
29
- const importBindings = new Map<string, ImportBinding>();
30
-
31
- const updatedContext = imports.reduce((ctx, imp) => {
32
- // BCL/runtime imports: No using needed, types are emitted with global:: FQN
33
- // .NET imports: No using needed, types are emitted with global:: FQN
34
-
35
- if (imp.isLocal) {
36
- // Local import - build ImportBindings with fully-qualified CLR names
37
- // NO using directive for local modules
38
- const moduleMap = ctx.options.moduleMap;
39
- const exportMap = ctx.options.exportMap;
40
- if (moduleMap) {
41
- const targetPath = resolveImportPath(module.filePath, imp.source);
42
-
43
- // Process each import specifier - may need to resolve re-exports
44
- for (const spec of imp.specifiers) {
45
- const exportName =
46
- spec.kind === "named"
47
- ? spec.name
48
- : spec.kind === "default"
49
- ? ""
50
- : "";
51
-
52
- // Check if this is a re-export - look up in export map
53
- const reexportKey = `${targetPath}:${exportName}`;
54
- const reexportSource = exportMap?.get(reexportKey);
55
-
56
- // Determine the actual source module
57
- const actualSourcePath = reexportSource?.sourceFile ?? targetPath;
58
- const actualExportName = reexportSource?.sourceName ?? exportName;
59
- const targetModule = moduleMap.get(actualSourcePath);
60
-
61
- if (targetModule) {
62
- const binding = createImportBinding(
63
- spec,
64
- targetModule.namespace,
65
- targetModule.className,
66
- actualExportName
67
- );
68
- if (binding) {
69
- importBindings.set(binding.localName, binding.importBinding);
70
- }
71
- }
72
- }
73
- // If module not found in map, it's a compilation error - will be caught elsewhere
74
- }
75
- // No module map = single file compilation, no import bindings needed
76
- }
77
-
78
- // External packages not supported in MVP
79
- return ctx;
80
- }, context);
81
-
82
- // Add import bindings to context
83
- return {
84
- ...updatedContext,
85
- importBindings,
86
- };
87
- };
88
-
89
- /**
90
- * Create import binding with fully-qualified global:: CLR names.
91
- * Uses isType from frontend (set by TS checker) to determine kind.
92
- *
93
- * - Type imports: clrName is the type's global:: FQN (global::namespace.TypeName)
94
- * - Value imports: clrName is the container global:: FQN, member is the export name
95
- * - Namespace imports: clrName is the container global:: FQN
96
- */
97
- const createImportBinding = (
98
- spec: IrImportSpecifier,
99
- namespace: string,
100
- containerClassName: string,
101
- resolvedExportName: string
102
- ): { localName: string; importBinding: ImportBinding } | null => {
103
- const localName = spec.localName;
104
- const containerFqn = `global::${namespace}.${containerClassName}`;
105
-
106
- if (spec.kind === "named") {
107
- // Use isType from frontend (determined by TS checker)
108
- const isType = spec.isType === true;
109
-
110
- if (isType) {
111
- // Type import: clrName is the type's FQN at namespace level
112
- // Types are emitted at namespace level, not inside container class
113
- return {
114
- localName,
115
- importBinding: {
116
- kind: "type",
117
- clrName: `global::${namespace}.${resolvedExportName}`,
118
- },
119
- };
120
- } else {
121
- // Value import: clrName is container, member is the export name
122
- return {
123
- localName,
124
- importBinding: {
125
- kind: "value",
126
- clrName: containerFqn,
127
- member: resolvedExportName,
128
- },
129
- };
130
- }
131
- }
132
-
133
- if (spec.kind === "default") {
134
- // Default export binds to the container class itself
135
- // TODO: Consider adding diagnostic for unsupported default exports
136
- return {
137
- localName,
138
- importBinding: {
139
- kind: "value",
140
- clrName: containerFqn,
141
- },
142
- };
143
- }
144
-
145
- if (spec.kind === "namespace") {
146
- // Namespace imports (import * as M) - bind to the container class
147
- return {
148
- localName,
149
- importBinding: {
150
- kind: "namespace",
151
- clrName: containerFqn,
152
- },
153
- };
154
- }
155
-
156
- return null;
157
- };
158
-
159
- /**
160
- * Resolve local import to a namespace (legacy fallback for single-file compilation)
161
- */
162
- export const resolveLocalImport = (
163
- imp: IrImport,
164
- currentFilePath: string,
165
- rootNamespace: string
166
- ): string | null => {
167
- // Normalize paths - handle both Unix and Windows separators
168
- const normalize = (p: string) => p.replace(/\\/g, "/");
169
- const currentFile = normalize(currentFilePath);
170
-
171
- // Get the directory of the current file
172
- const currentDir = currentFile.substring(0, currentFile.lastIndexOf("/"));
173
-
174
- // Resolve the import path relative to current directory
175
- const resolvedPath = resolveRelativePath(currentDir, imp.source);
176
-
177
- // Remove .ts extension and get directory path
178
- const withoutExtension = resolvedPath.replace(/\.ts$/, "");
179
- const dirPath = withoutExtension.substring(
180
- 0,
181
- withoutExtension.lastIndexOf("/")
182
- );
183
-
184
- // Convert directory path to namespace - only use path after last "/src/"
185
- const relativePath = extractRelativePath(dirPath);
186
- const parts = relativePath.split("/").filter((p) => p !== "" && p !== ".");
187
-
188
- return parts.length === 0
189
- ? rootNamespace
190
- : `${rootNamespace}.${parts.join(".")}`;
191
- };
192
-
193
- /**
194
- * Resolve a relative import path from a given directory
195
- */
196
- const resolveRelativePath = (currentDir: string, source: string): string => {
197
- if (source.startsWith("./")) {
198
- return `${currentDir}/${source.substring(2)}`;
199
- }
200
-
201
- if (source.startsWith("../")) {
202
- const parts = currentDir.split("/");
203
- const sourceCopy = source;
204
- return resolveParentPath(parts, sourceCopy);
205
- }
206
-
207
- return `${currentDir}/${source}`;
208
- };
209
-
210
- /**
211
- * Resolve parent path references (..)
212
- */
213
- const resolveParentPath = (parts: string[], source: string): string => {
214
- if (!source.startsWith("../")) {
215
- return `${parts.join("/")}/${source}`;
216
- }
217
- return resolveParentPath(parts.slice(0, -1), source.substring(3));
218
- };
219
-
220
- /**
221
- * Extract relative path from a directory path
222
- */
223
- const extractRelativePath = (dirPath: string): string => {
224
- const srcIndex = dirPath.lastIndexOf("/src/");
225
-
226
- if (srcIndex >= 0) {
227
- return dirPath.substring(srcIndex + 5);
228
- }
229
-
230
- if (dirPath.endsWith("/src")) {
231
- return "";
232
- }
233
-
234
- if (dirPath.startsWith("src/")) {
235
- return dirPath.substring(4);
236
- }
237
-
238
- if (dirPath === "src") {
239
- return "";
240
- }
241
-
242
- return "";
243
- };
@@ -1,83 +0,0 @@
1
- /**
2
- * Final output assembly
3
- *
4
- * NOTE: No using statements are emitted. All type and member references
5
- * use fully-qualified global:: names to eliminate any ambiguity.
6
- */
7
-
8
- import { IrModule } from "@tsonic/frontend";
9
- import { EmitterContext } from "../../types.js";
10
-
11
- export type AssemblyParts = {
12
- readonly header: string;
13
- readonly adaptersCode: string;
14
- readonly specializationsCode: string;
15
- readonly exchangesCode: string;
16
- readonly namespaceDeclsCode: string;
17
- readonly staticContainerCode: string;
18
- };
19
-
20
- /**
21
- * Assemble final C# output from all parts
22
- */
23
- export const assembleOutput = (
24
- module: IrModule,
25
- parts: AssemblyParts,
26
- _finalContext: EmitterContext
27
- ): string => {
28
- const result: string[] = [];
29
-
30
- if (parts.header) {
31
- result.push(parts.header);
32
- }
33
-
34
- result.push(`namespace ${module.namespace}`);
35
- result.push("{");
36
-
37
- // Emit adapters before class code
38
- if (parts.adaptersCode) {
39
- const indentedAdapters = parts.adaptersCode
40
- .split("\n")
41
- .map((line) => (line ? " " + line : line))
42
- .join("\n");
43
- result.push(indentedAdapters);
44
- result.push("");
45
- }
46
-
47
- // Emit specializations after adapters
48
- if (parts.specializationsCode) {
49
- const indentedSpecializations = parts.specializationsCode
50
- .split("\n")
51
- .map((line) => (line ? " " + line : line))
52
- .join("\n");
53
- result.push(indentedSpecializations);
54
- result.push("");
55
- }
56
-
57
- // Emit generator exchange objects after specializations
58
- if (parts.exchangesCode) {
59
- const indentedExchanges = parts.exchangesCode
60
- .split("\n")
61
- .map((line) => (line ? " " + line : line))
62
- .join("\n");
63
- result.push(indentedExchanges);
64
- result.push("");
65
- }
66
-
67
- // Emit namespace-level declarations first
68
- if (parts.namespaceDeclsCode) {
69
- result.push(parts.namespaceDeclsCode);
70
- }
71
-
72
- // Then emit static container if needed
73
- if (parts.staticContainerCode) {
74
- if (parts.namespaceDeclsCode) {
75
- result.push("");
76
- }
77
- result.push(parts.staticContainerCode);
78
- }
79
-
80
- result.push("}");
81
-
82
- return result.join("\n");
83
- };
@@ -1,19 +0,0 @@
1
- /**
2
- * File header generation
3
- */
4
-
5
- import { IrModule } from "@tsonic/frontend";
6
- import { EmitterOptions } from "../../types.js";
7
- import { generateFileHeader } from "../../constants.js";
8
-
9
- /**
10
- * Generate file header with source info
11
- */
12
- export const generateHeader = (
13
- module: IrModule,
14
- options: EmitterOptions
15
- ): string => {
16
- return generateFileHeader(module.filePath, {
17
- includeTimestamp: options.includeTimestamp,
18
- });
19
- };
@@ -1,39 +0,0 @@
1
- /**
2
- * Namespace-level declaration emission
3
- */
4
-
5
- import { IrStatement } from "@tsonic/frontend";
6
- import { EmitterContext, indent } from "../../types.js";
7
- import { emitStatement } from "../../statement-emitter.js";
8
-
9
- export type NamespaceEmissionResult = {
10
- readonly code: string;
11
- readonly context: EmitterContext;
12
- };
13
-
14
- /**
15
- * Emit namespace-level declarations (classes, interfaces)
16
- */
17
- export const emitNamespaceDeclarations = (
18
- declarations: readonly IrStatement[],
19
- baseContext: EmitterContext,
20
- hasInheritance: boolean
21
- ): NamespaceEmissionResult => {
22
- const namespaceParts: string[] = [];
23
- const namespaceContext = { ...indent(baseContext), hasInheritance };
24
- let currentContext = namespaceContext;
25
-
26
- for (const decl of declarations) {
27
- // Use the same base context for each declaration to maintain consistent indentation
28
- const [code, newContext] = emitStatement(decl, namespaceContext);
29
- namespaceParts.push(code);
30
- // Track context for using statements, but don't let indentation accumulate
31
- // Preserve the hasInheritance flag
32
- currentContext = { ...newContext, hasInheritance };
33
- }
34
-
35
- return {
36
- code: namespaceParts.join("\n"),
37
- context: currentContext,
38
- };
39
- };
@@ -1,98 +0,0 @@
1
- /**
2
- * Module emission orchestrator
3
- */
4
-
5
- import { IrModule } from "@tsonic/frontend";
6
- import { EmitterOptions, createContext } from "../../types.js";
7
- import { generateStructuralAdapters } from "../../adapter-generator.js";
8
- import {
9
- collectSpecializations,
10
- generateSpecializations,
11
- } from "../../specialization-generator.js";
12
- import { generateGeneratorExchanges } from "../../generator-exchange.js";
13
- import { defaultOptions } from "../options.js";
14
- import { collectTypeParameters } from "../type-params.js";
15
- import { processImports } from "../imports.js";
16
- import { generateHeader } from "./header.js";
17
- import { separateStatements } from "./separation.js";
18
- import { emitNamespaceDeclarations } from "./namespace.js";
19
- import {
20
- emitStaticContainer,
21
- hasMatchingClassName,
22
- } from "./static-container.js";
23
- import { assembleOutput, type AssemblyParts } from "./assembly.js";
24
-
25
- /**
26
- * Emit C# code from an IR module
27
- */
28
- export const emitModule = (
29
- module: IrModule,
30
- options: Partial<EmitterOptions> = {}
31
- ): string => {
32
- const finalOptions: EmitterOptions = { ...defaultOptions, ...options };
33
- const context = createContext(finalOptions);
34
-
35
- // Generate file header
36
- const header = generateHeader(module, finalOptions);
37
-
38
- // Process imports to collect using statements
39
- const processedContext = processImports(module.imports, context, module);
40
-
41
- // Collect type parameters and generate adapters
42
- const typeParams = collectTypeParameters(module);
43
- const [adaptersCode, adaptersContext] = generateStructuralAdapters(
44
- typeParams,
45
- processedContext
46
- );
47
-
48
- // Collect specializations and generate monomorphized versions
49
- const specializations = collectSpecializations(module);
50
- const [specializationsCode, specializationsContext] = generateSpecializations(
51
- specializations,
52
- adaptersContext
53
- );
54
-
55
- // Generate exchange objects for generators
56
- const [exchangesCode, exchangesContext] = generateGeneratorExchanges(
57
- module,
58
- specializationsContext
59
- );
60
-
61
- // Separate namespace-level declarations from static container members
62
- const { namespaceLevelDecls, staticContainerMembers, hasInheritance } =
63
- separateStatements(module);
64
-
65
- // Emit namespace-level declarations (classes, interfaces)
66
- const namespaceResult = emitNamespaceDeclarations(
67
- namespaceLevelDecls,
68
- exchangesContext,
69
- hasInheritance
70
- );
71
-
72
- // Emit static container class unless there's a namespace-level class with same name
73
- let staticContainerCode = "";
74
- let finalContext = namespaceResult.context;
75
-
76
- if (!hasMatchingClassName(namespaceLevelDecls, module.className)) {
77
- const containerResult = emitStaticContainer(
78
- module,
79
- staticContainerMembers,
80
- namespaceResult.context, // Use context from namespace declarations to preserve usings
81
- hasInheritance
82
- );
83
- staticContainerCode = containerResult.code;
84
- finalContext = containerResult.context;
85
- }
86
-
87
- // Assemble final output
88
- const parts: AssemblyParts = {
89
- header,
90
- adaptersCode,
91
- specializationsCode,
92
- exchangesCode,
93
- namespaceDeclsCode: namespaceResult.code,
94
- staticContainerCode,
95
- };
96
-
97
- return assembleOutput(module, parts, finalContext);
98
- };
@@ -1,41 +0,0 @@
1
- /**
2
- * Statement separation logic
3
- */
4
-
5
- import { IrModule, IrStatement } from "@tsonic/frontend";
6
-
7
- export type SeparatedStatements = {
8
- readonly namespaceLevelDecls: readonly IrStatement[];
9
- readonly staticContainerMembers: readonly IrStatement[];
10
- readonly hasInheritance: boolean;
11
- };
12
-
13
- /**
14
- * Separate namespace-level declarations from static container members
15
- */
16
- export const separateStatements = (module: IrModule): SeparatedStatements => {
17
- const namespaceLevelDecls: IrStatement[] = [];
18
- const staticContainerMembers: IrStatement[] = [];
19
-
20
- // Detect if module has any inheritance (for virtual/override keywords)
21
- const hasInheritance = module.body.some(
22
- (stmt) => stmt.kind === "classDeclaration" && stmt.superClass
23
- );
24
-
25
- for (const stmt of module.body) {
26
- if (
27
- stmt.kind === "classDeclaration" ||
28
- stmt.kind === "interfaceDeclaration"
29
- ) {
30
- namespaceLevelDecls.push(stmt);
31
- } else {
32
- staticContainerMembers.push(stmt);
33
- }
34
- }
35
-
36
- return {
37
- namespaceLevelDecls,
38
- staticContainerMembers,
39
- hasInheritance,
40
- };
41
- };
@@ -1,75 +0,0 @@
1
- /**
2
- * Static container class emission
3
- */
4
-
5
- import { IrModule, IrStatement } from "@tsonic/frontend";
6
- import { EmitterContext, indent, getIndent, withStatic } from "../../types.js";
7
- import { emitStatement } from "../../statement-emitter.js";
8
- import { emitExport } from "../exports.js";
9
-
10
- export type StaticContainerResult = {
11
- readonly code: string;
12
- readonly context: EmitterContext;
13
- };
14
-
15
- /**
16
- * Check if there's a namespace-level class with the same name as the module
17
- */
18
- export const hasMatchingClassName = (
19
- declarations: readonly IrStatement[],
20
- className: string
21
- ): boolean => {
22
- return declarations.some(
23
- (decl) =>
24
- (decl.kind === "classDeclaration" ||
25
- decl.kind === "interfaceDeclaration") &&
26
- decl.name === className
27
- );
28
- };
29
-
30
- /**
31
- * Emit static container class for module-level members
32
- */
33
- export const emitStaticContainer = (
34
- module: IrModule,
35
- members: readonly IrStatement[],
36
- baseContext: EmitterContext,
37
- hasInheritance: boolean
38
- ): StaticContainerResult => {
39
- const classContext = withStatic(indent(baseContext), true);
40
- const bodyContext = indent(classContext);
41
- const ind = getIndent(classContext);
42
-
43
- const containerParts: string[] = [];
44
- containerParts.push(`${ind}public static class ${module.className}`);
45
- containerParts.push(`${ind}{`);
46
-
47
- const bodyParts: string[] = [];
48
- let bodyCurrentContext = bodyContext;
49
-
50
- for (const stmt of members) {
51
- const [code, newContext] = emitStatement(stmt, bodyCurrentContext);
52
- bodyParts.push(code);
53
- bodyCurrentContext = newContext;
54
- }
55
-
56
- // Handle explicit exports
57
- for (const exp of module.exports) {
58
- const exportCode = emitExport(exp, bodyCurrentContext);
59
- if (exportCode[0]) {
60
- bodyParts.push(exportCode[0]);
61
- bodyCurrentContext = exportCode[1];
62
- }
63
- }
64
-
65
- if (bodyParts.length > 0) {
66
- containerParts.push(bodyParts.join("\n\n"));
67
- }
68
-
69
- containerParts.push(`${ind}}`);
70
-
71
- return {
72
- code: containerParts.join("\n"),
73
- context: { ...bodyCurrentContext, hasInheritance },
74
- };
75
- };