@typecad/cuttlefish 0.1.0-alpha.1

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 (377) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +79 -0
  3. package/dist/api/board-types.d.ts +1 -0
  4. package/dist/api/board-types.js +4 -0
  5. package/dist/api/capabilities.d.ts +12 -0
  6. package/dist/api/capabilities.js +1 -0
  7. package/dist/api/config.d.ts +120 -0
  8. package/dist/api/config.js +7 -0
  9. package/dist/api/index.d.ts +5 -0
  10. package/dist/api/index.js +2 -0
  11. package/dist/api/schema/builder.d.ts +14 -0
  12. package/dist/api/schema/builder.js +15 -0
  13. package/dist/api/schema/index.d.ts +2 -0
  14. package/dist/api/schema/index.js +1 -0
  15. package/dist/api/schema/types.d.ts +257 -0
  16. package/dist/api/schema/types.js +4 -0
  17. package/dist/api/shared/async-runtime-static.d.ts +8 -0
  18. package/dist/api/shared/async-runtime-static.js +201 -0
  19. package/dist/api/shared/async-types.d.ts +42 -0
  20. package/dist/api/shared/async-types.js +8 -0
  21. package/dist/api/shared/board-resolver.d.ts +12 -0
  22. package/dist/api/shared/board-resolver.js +7 -0
  23. package/dist/api/shared/cpp-type-ir.d.ts +229 -0
  24. package/dist/api/shared/cpp-type-ir.js +672 -0
  25. package/dist/api/shared/display-adapter.d.ts +12 -0
  26. package/dist/api/shared/display-adapter.js +145 -0
  27. package/dist/api/shared/display-adapters/eink-mono.d.ts +2 -0
  28. package/dist/api/shared/display-adapters/eink-mono.js +53 -0
  29. package/dist/api/shared/display-adapters/sdl.d.ts +2 -0
  30. package/dist/api/shared/display-adapters/sdl.js +452 -0
  31. package/dist/api/shared/display-adapters/ssd1309.d.ts +2 -0
  32. package/dist/api/shared/display-adapters/ssd1309.js +136 -0
  33. package/dist/api/shared/display-adapters/st7796.d.ts +2 -0
  34. package/dist/api/shared/display-adapters/st7796.js +132 -0
  35. package/dist/api/shared/display-capabilities.d.ts +45 -0
  36. package/dist/api/shared/display-capabilities.js +54 -0
  37. package/dist/api/shared/display-op-ir.d.ts +62 -0
  38. package/dist/api/shared/display-op-ir.js +19 -0
  39. package/dist/api/shared/display-profile.d.ts +265 -0
  40. package/dist/api/shared/display-profile.js +338 -0
  41. package/dist/api/shared/graphics-strategy.d.ts +29 -0
  42. package/dist/api/shared/graphics-strategy.js +11 -0
  43. package/dist/api/shared/hal-op-ir.d.ts +393 -0
  44. package/dist/api/shared/hal-op-ir.js +18 -0
  45. package/dist/api/shared/index.d.ts +26 -0
  46. package/dist/api/shared/index.js +21 -0
  47. package/dist/api/shared/ir-core.d.ts +363 -0
  48. package/dist/api/shared/ir-core.js +8 -0
  49. package/dist/api/shared/ir-declarations.d.ts +201 -0
  50. package/dist/api/shared/ir-declarations.js +26 -0
  51. package/dist/api/shared/ir.d.ts +85 -0
  52. package/dist/api/shared/ir.js +13 -0
  53. package/dist/api/shared/platform-strategy.d.ts +402 -0
  54. package/dist/api/shared/platform-strategy.js +14 -0
  55. package/dist/api/shared/polyfill-helper-registry.d.ts +11 -0
  56. package/dist/api/shared/polyfill-helper-registry.js +86 -0
  57. package/dist/api/shared/polyfill-types.d.ts +33 -0
  58. package/dist/api/shared/polyfill-types.js +76 -0
  59. package/dist/api/shared/promise-runtime.d.ts +10 -0
  60. package/dist/api/shared/promise-runtime.js +244 -0
  61. package/dist/api/shared/snprintf-types.d.ts +29 -0
  62. package/dist/api/shared/snprintf-types.js +8 -0
  63. package/dist/api/shared/string-method-registry.d.ts +53 -0
  64. package/dist/api/shared/string-method-registry.js +168 -0
  65. package/dist/api/shared/toolchain-types.d.ts +63 -0
  66. package/dist/api/shared/toolchain-types.js +71 -0
  67. package/dist/api/shared/types.d.ts +50 -0
  68. package/dist/api/shared/types.js +6 -0
  69. package/dist/ast/parse.d.ts +2 -0
  70. package/dist/ast/parse.js +4 -0
  71. package/dist/cache.d.ts +26 -0
  72. package/dist/cache.js +95 -0
  73. package/dist/cli-utils.d.ts +37 -0
  74. package/dist/cli-utils.js +250 -0
  75. package/dist/cli.d.ts +2 -0
  76. package/dist/cli.js +635 -0
  77. package/dist/config-loader.d.ts +78 -0
  78. package/dist/config-loader.js +508 -0
  79. package/dist/config-schema.d.ts +233 -0
  80. package/dist/config-schema.js +83 -0
  81. package/dist/create/board-checklist.d.ts +2 -0
  82. package/dist/create/board-checklist.js +52 -0
  83. package/dist/create/board-codegen.d.ts +9 -0
  84. package/dist/create/board-codegen.js +238 -0
  85. package/dist/create/board-generators.d.ts +12 -0
  86. package/dist/create/board-generators.js +652 -0
  87. package/dist/create/board-spec.d.ts +640 -0
  88. package/dist/create/board-spec.js +215 -0
  89. package/dist/create/eslint-rules-template.d.ts +2 -0
  90. package/dist/create/eslint-rules-template.js +672 -0
  91. package/dist/create/index.d.ts +11 -0
  92. package/dist/create/index.js +8 -0
  93. package/dist/create/init-scaffold.d.ts +27 -0
  94. package/dist/create/init-scaffold.js +150 -0
  95. package/dist/create/init-templates.d.ts +24 -0
  96. package/dist/create/init-templates.js +379 -0
  97. package/dist/create/init-wizard.d.ts +8 -0
  98. package/dist/create/init-wizard.js +168 -0
  99. package/dist/debug/breakpoint-loader.d.ts +24 -0
  100. package/dist/debug/breakpoint-loader.js +137 -0
  101. package/dist/debug/index.d.ts +3 -0
  102. package/dist/debug/index.js +7 -0
  103. package/dist/debug/preprocessor.d.ts +9 -0
  104. package/dist/debug/preprocessor.js +214 -0
  105. package/dist/debug/types.d.ts +32 -0
  106. package/dist/debug/types.js +6 -0
  107. package/dist/diagnostics/diagnostics-report.d.ts +51 -0
  108. package/dist/diagnostics/diagnostics-report.js +333 -0
  109. package/dist/diagnostics/json-schema.d.ts +138 -0
  110. package/dist/diagnostics/json-schema.js +27 -0
  111. package/dist/diagnostics/md-writer.d.ts +10 -0
  112. package/dist/diagnostics/md-writer.js +336 -0
  113. package/dist/diagnostics/mermaid-builder.d.ts +65 -0
  114. package/dist/diagnostics/mermaid-builder.js +681 -0
  115. package/dist/emit/cpp-emitter.d.ts +6 -0
  116. package/dist/emit/cpp-emitter.js +48 -0
  117. package/dist/emit/emitters/class-emitter.d.ts +2 -0
  118. package/dist/emit/emitters/class-emitter.js +523 -0
  119. package/dist/emit/emitters/emitter-context.d.ts +174 -0
  120. package/dist/emit/emitters/emitter-context.js +1 -0
  121. package/dist/emit/emitters/entrypoint-synthesizer.d.ts +2 -0
  122. package/dist/emit/emitters/entrypoint-synthesizer.js +175 -0
  123. package/dist/emit/emitters/function-emitter-impl.d.ts +19 -0
  124. package/dist/emit/emitters/function-emitter-impl.js +428 -0
  125. package/dist/emit/emitters/line-appender.d.ts +15 -0
  126. package/dist/emit/emitters/line-appender.js +344 -0
  127. package/dist/emit/emitters/namespace-emitter.d.ts +2 -0
  128. package/dist/emit/emitters/namespace-emitter.js +324 -0
  129. package/dist/emit/emitters/output-finalizer.d.ts +4 -0
  130. package/dist/emit/emitters/output-finalizer.js +267 -0
  131. package/dist/emit/emitters/setup.d.ts +3 -0
  132. package/dist/emit/emitters/setup.js +851 -0
  133. package/dist/emit/emitters/top-level-prep.d.ts +2 -0
  134. package/dist/emit/emitters/top-level-prep.js +706 -0
  135. package/dist/emit/emitters/type-decl-emitter.d.ts +2 -0
  136. package/dist/emit/emitters/type-decl-emitter.js +251 -0
  137. package/dist/emit/emitters/ui-emitter.d.ts +21 -0
  138. package/dist/emit/emitters/ui-emitter.js +564 -0
  139. package/dist/emit/enum-emitter.d.ts +1 -0
  140. package/dist/emit/enum-emitter.js +1 -0
  141. package/dist/emit/expression-renderer.d.ts +283 -0
  142. package/dist/emit/expression-renderer.js +1477 -0
  143. package/dist/emit/native-helpers-emitter.d.ts +11 -0
  144. package/dist/emit/native-helpers-emitter.js +34 -0
  145. package/dist/emit/route-hal-op.d.ts +5 -0
  146. package/dist/emit/route-hal-op.js +13 -0
  147. package/dist/emit/snprintf-helpers.d.ts +17 -0
  148. package/dist/emit/snprintf-helpers.js +462 -0
  149. package/dist/emit/statement-renderer.d.ts +189 -0
  150. package/dist/emit/statement-renderer.js +948 -0
  151. package/dist/emit/utils/async-state-machine.d.ts +42 -0
  152. package/dist/emit/utils/async-state-machine.js +343 -0
  153. package/dist/emit/utils/comment-helpers.d.ts +20 -0
  154. package/dist/emit/utils/comment-helpers.js +31 -0
  155. package/dist/emit/utils/cpp-helpers.d.ts +47 -0
  156. package/dist/emit/utils/cpp-helpers.js +85 -0
  157. package/dist/emit/utils/include-resolver.d.ts +58 -0
  158. package/dist/emit/utils/include-resolver.js +155 -0
  159. package/dist/emit/utils/index.d.ts +8 -0
  160. package/dist/emit/utils/index.js +12 -0
  161. package/dist/emit/utils/type-inference.d.ts +159 -0
  162. package/dist/emit/utils/type-inference.js +559 -0
  163. package/dist/eslint-check.d.ts +10 -0
  164. package/dist/eslint-check.js +102 -0
  165. package/dist/framework-package.d.ts +10 -0
  166. package/dist/framework-package.js +58 -0
  167. package/dist/framework-registry.d.ts +39 -0
  168. package/dist/framework-registry.js +30 -0
  169. package/dist/incremental-cache.d.ts +116 -0
  170. package/dist/incremental-cache.js +335 -0
  171. package/dist/ir/adc-range-validation.d.ts +11 -0
  172. package/dist/ir/adc-range-validation.js +250 -0
  173. package/dist/ir/ast-node-utils.d.ts +8 -0
  174. package/dist/ir/ast-node-utils.js +32 -0
  175. package/dist/ir/board-pin-utils.d.ts +13 -0
  176. package/dist/ir/board-pin-utils.js +65 -0
  177. package/dist/ir/board-resolver.d.ts +36 -0
  178. package/dist/ir/board-resolver.js +437 -0
  179. package/dist/ir/build-ir-state.d.ts +167 -0
  180. package/dist/ir/build-ir-state.js +306 -0
  181. package/dist/ir/build-ir.d.ts +2 -0
  182. package/dist/ir/build-ir.js +808 -0
  183. package/dist/ir/call-graph.d.ts +35 -0
  184. package/dist/ir/call-graph.js +194 -0
  185. package/dist/ir/compile-time-only.d.ts +2 -0
  186. package/dist/ir/compile-time-only.js +16 -0
  187. package/dist/ir/declaration-builders.d.ts +9 -0
  188. package/dist/ir/declaration-builders.js +608 -0
  189. package/dist/ir/entry-points.d.ts +30 -0
  190. package/dist/ir/entry-points.js +191 -0
  191. package/dist/ir/expression-to-ir.d.ts +5 -0
  192. package/dist/ir/expression-to-ir.js +2249 -0
  193. package/dist/ir/extract-property-chain.d.ts +10 -0
  194. package/dist/ir/extract-property-chain.js +30 -0
  195. package/dist/ir/feature-prescan.d.ts +3 -0
  196. package/dist/ir/feature-prescan.js +43 -0
  197. package/dist/ir/feature-registry.d.ts +30 -0
  198. package/dist/ir/feature-registry.js +816 -0
  199. package/dist/ir/filter.d.ts +7 -0
  200. package/dist/ir/filter.js +85 -0
  201. package/dist/ir/function-builder.d.ts +19 -0
  202. package/dist/ir/function-builder.js +670 -0
  203. package/dist/ir/hal/hal-emitter.d.ts +62 -0
  204. package/dist/ir/hal/hal-emitter.js +735 -0
  205. package/dist/ir/hal/hal-parser.d.ts +61 -0
  206. package/dist/ir/hal/hal-parser.js +473 -0
  207. package/dist/ir/hal/hal-plugins.d.ts +34 -0
  208. package/dist/ir/hal/hal-plugins.js +706 -0
  209. package/dist/ir/hal-resolver.d.ts +5 -0
  210. package/dist/ir/hal-resolver.js +5 -0
  211. package/dist/ir/heap-analysis.d.ts +8 -0
  212. package/dist/ir/heap-analysis.js +350 -0
  213. package/dist/ir/heap-array-validation.d.ts +24 -0
  214. package/dist/ir/heap-array-validation.js +29 -0
  215. package/dist/ir/identifier-collector.d.ts +18 -0
  216. package/dist/ir/identifier-collector.js +439 -0
  217. package/dist/ir/interrupt-analysis.d.ts +39 -0
  218. package/dist/ir/interrupt-analysis.js +467 -0
  219. package/dist/ir/memory-budget-validation.d.ts +10 -0
  220. package/dist/ir/memory-budget-validation.js +86 -0
  221. package/dist/ir/namespace-builder.d.ts +7 -0
  222. package/dist/ir/namespace-builder.js +152 -0
  223. package/dist/ir/ownership-analysis.d.ts +9 -0
  224. package/dist/ir/ownership-analysis.js +1207 -0
  225. package/dist/ir/peripheral-ownership.d.ts +3 -0
  226. package/dist/ir/peripheral-ownership.js +152 -0
  227. package/dist/ir/peripheral-symbols.d.ts +7 -0
  228. package/dist/ir/peripheral-symbols.js +57 -0
  229. package/dist/ir/peripheral-usage.d.ts +54 -0
  230. package/dist/ir/peripheral-usage.js +691 -0
  231. package/dist/ir/peripheral-validation.d.ts +8 -0
  232. package/dist/ir/peripheral-validation.js +77 -0
  233. package/dist/ir/pin-alias-conflict.d.ts +4 -0
  234. package/dist/ir/pin-alias-conflict.js +34 -0
  235. package/dist/ir/pin-capability-validation.d.ts +6 -0
  236. package/dist/ir/pin-capability-validation.js +413 -0
  237. package/dist/ir/pin-mode-validation.d.ts +10 -0
  238. package/dist/ir/pin-mode-validation.js +301 -0
  239. package/dist/ir/pin-safety.d.ts +11 -0
  240. package/dist/ir/pin-safety.js +58 -0
  241. package/dist/ir/program-analysis.d.ts +44 -0
  242. package/dist/ir/program-analysis.js +589 -0
  243. package/dist/ir/pulldown-validation.d.ts +7 -0
  244. package/dist/ir/pulldown-validation.js +49 -0
  245. package/dist/ir/pwm-timer-sharing.d.ts +4 -0
  246. package/dist/ir/pwm-timer-sharing.js +93 -0
  247. package/dist/ir/reachability.d.ts +68 -0
  248. package/dist/ir/reachability.js +224 -0
  249. package/dist/ir/register-decorators.d.ts +6 -0
  250. package/dist/ir/register-decorators.js +49 -0
  251. package/dist/ir/render-expr.d.ts +4 -0
  252. package/dist/ir/render-expr.js +127 -0
  253. package/dist/ir/resource-analysis.d.ts +19 -0
  254. package/dist/ir/resource-analysis.js +153 -0
  255. package/dist/ir/statement-to-ir.d.ts +23 -0
  256. package/dist/ir/statement-to-ir.js +349 -0
  257. package/dist/ir/symbol-table.d.ts +68 -0
  258. package/dist/ir/symbol-table.js +179 -0
  259. package/dist/ir/symbol-types.d.ts +56 -0
  260. package/dist/ir/symbol-types.js +107 -0
  261. package/dist/ir/timer0-pwm-timing-conflict.d.ts +4 -0
  262. package/dist/ir/timer0-pwm-timing-conflict.js +71 -0
  263. package/dist/ir/timing-validation.d.ts +7 -0
  264. package/dist/ir/timing-validation.js +95 -0
  265. package/dist/ir/transformers/array-methods.d.ts +8 -0
  266. package/dist/ir/transformers/array-methods.js +493 -0
  267. package/dist/ir/transformers/call-statement.d.ts +5 -0
  268. package/dist/ir/transformers/call-statement.js +758 -0
  269. package/dist/ir/transformers/callback-context-registry.d.ts +20 -0
  270. package/dist/ir/transformers/callback-context-registry.js +55 -0
  271. package/dist/ir/transformers/canvas-lowering.d.ts +42 -0
  272. package/dist/ir/transformers/canvas-lowering.js +249 -0
  273. package/dist/ir/transformers/control-flow.d.ts +8 -0
  274. package/dist/ir/transformers/control-flow.js +508 -0
  275. package/dist/ir/transformers/expressions.d.ts +7 -0
  276. package/dist/ir/transformers/expressions.js +406 -0
  277. package/dist/ir/transformers/hal-call-resolver.d.ts +29 -0
  278. package/dist/ir/transformers/hal-call-resolver.js +274 -0
  279. package/dist/ir/transformers/hal-emit-helpers.d.ts +14 -0
  280. package/dist/ir/transformers/hal-emit-helpers.js +63 -0
  281. package/dist/ir/transformers/namespace-methods.d.ts +20 -0
  282. package/dist/ir/transformers/namespace-methods.js +110 -0
  283. package/dist/ir/transformers/register-assignment.d.ts +5 -0
  284. package/dist/ir/transformers/register-assignment.js +56 -0
  285. package/dist/ir/transformers/ui-call-resolver.d.ts +149 -0
  286. package/dist/ir/transformers/ui-call-resolver.js +1136 -0
  287. package/dist/ir/transformers/ui-callback-lowering.d.ts +62 -0
  288. package/dist/ir/transformers/ui-callback-lowering.js +623 -0
  289. package/dist/ir/transformers/ui-mount.d.ts +20 -0
  290. package/dist/ir/transformers/ui-mount.js +35 -0
  291. package/dist/ir/transformers/ui-reactive.d.ts +68 -0
  292. package/dist/ir/transformers/ui-reactive.js +129 -0
  293. package/dist/ir/transformers/variables.d.ts +14 -0
  294. package/dist/ir/transformers/variables.js +1045 -0
  295. package/dist/ir/try-catch-validation.d.ts +26 -0
  296. package/dist/ir/try-catch-validation.js +128 -0
  297. package/dist/ir/type-resolution.d.ts +31 -0
  298. package/dist/ir/type-resolution.js +977 -0
  299. package/dist/ir/ui-element-auto-wire.d.ts +50 -0
  300. package/dist/ir/ui-element-auto-wire.js +218 -0
  301. package/dist/ir/unit-suspicion-validation.d.ts +12 -0
  302. package/dist/ir/unit-suspicion-validation.js +296 -0
  303. package/dist/ir/utils/walk-ir.d.ts +6 -0
  304. package/dist/ir/utils/walk-ir.js +162 -0
  305. package/dist/ir/validation-orchestrator.d.ts +4 -0
  306. package/dist/ir/validation-orchestrator.js +45 -0
  307. package/dist/libdef/base-class-resolver.d.ts +23 -0
  308. package/dist/libdef/base-class-resolver.js +50 -0
  309. package/dist/libdef/cpp-to-decl.d.ts +34 -0
  310. package/dist/libdef/cpp-to-decl.js +584 -0
  311. package/dist/libdef/header-parser.d.ts +53 -0
  312. package/dist/libdef/header-parser.js +269 -0
  313. package/dist/libdef/registry.d.ts +10 -0
  314. package/dist/libdef/registry.js +142 -0
  315. package/dist/mapping/peripheral-names.d.ts +23 -0
  316. package/dist/mapping/peripheral-names.js +63 -0
  317. package/dist/mapping/source-map.d.ts +46 -0
  318. package/dist/mapping/source-map.js +207 -0
  319. package/dist/orchestrator/dts-generator.d.ts +17 -0
  320. package/dist/orchestrator/dts-generator.js +83 -0
  321. package/dist/orchestrator/graph-builder.d.ts +18 -0
  322. package/dist/orchestrator/graph-builder.js +218 -0
  323. package/dist/orchestrator/semantic-facts-verifier.d.ts +38 -0
  324. package/dist/orchestrator/semantic-facts-verifier.js +121 -0
  325. package/dist/orchestrator/semantic-facts.d.ts +141 -0
  326. package/dist/orchestrator/semantic-facts.js +652 -0
  327. package/dist/orchestrator/type-checker.d.ts +39 -0
  328. package/dist/orchestrator/type-checker.js +760 -0
  329. package/dist/platform/async-runtime.d.ts +8 -0
  330. package/dist/platform/async-runtime.js +26 -0
  331. package/dist/platform/generic-strategy.d.ts +101 -0
  332. package/dist/platform/generic-strategy.js +289 -0
  333. package/dist/platform/index.d.ts +4 -0
  334. package/dist/platform/index.js +9 -0
  335. package/dist/platform/registry.d.ts +21 -0
  336. package/dist/platform/registry.js +42 -0
  337. package/dist/platform/toolchain.d.ts +4 -0
  338. package/dist/platform/toolchain.js +43 -0
  339. package/dist/preview/client.d.ts +1 -0
  340. package/dist/preview/client.js +137 -0
  341. package/dist/preview/server.d.ts +5 -0
  342. package/dist/preview/server.js +199 -0
  343. package/dist/profiler/index.d.ts +28 -0
  344. package/dist/profiler/index.js +28 -0
  345. package/dist/profiler/profiler.d.ts +95 -0
  346. package/dist/profiler/profiler.js +338 -0
  347. package/dist/profiler/types.d.ts +87 -0
  348. package/dist/profiler/types.js +12 -0
  349. package/dist/stores/display-profile-store.d.ts +16 -0
  350. package/dist/stores/display-profile-store.js +48 -0
  351. package/dist/stores/theme-store.d.ts +13 -0
  352. package/dist/stores/theme-store.js +30 -0
  353. package/dist/testing.d.ts +45 -0
  354. package/dist/testing.js +47 -0
  355. package/dist/transpile/resolution.d.ts +29 -0
  356. package/dist/transpile/resolution.js +282 -0
  357. package/dist/transpile.d.ts +3 -0
  358. package/dist/transpile.js +722 -0
  359. package/dist/types.d.ts +217 -0
  360. package/dist/types.js +1 -0
  361. package/dist/ui/ui-bridge.d.ts +4 -0
  362. package/dist/ui/ui-bridge.js +34 -0
  363. package/dist/ui-hook.d.ts +84 -0
  364. package/dist/ui-hook.js +45 -0
  365. package/dist/utils/cli.d.ts +3 -0
  366. package/dist/utils/cli.js +463 -0
  367. package/dist/utils/fs.d.ts +4 -0
  368. package/dist/utils/fs.js +23 -0
  369. package/dist/utils/logger.d.ts +2 -0
  370. package/dist/utils/logger.js +8 -0
  371. package/dist/utils/strings.d.ts +35 -0
  372. package/dist/utils/strings.js +142 -0
  373. package/dist/utils/ui.d.ts +66 -0
  374. package/dist/utils/ui.js +149 -0
  375. package/dist/watch.d.ts +35 -0
  376. package/dist/watch.js +111 -0
  377. package/package.json +127 -0
@@ -0,0 +1,437 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Board constant resolver
3
+ //
4
+ // Parses a TypeScript board-definition file (e.g. code/board-arduino-uno/index.ts)
5
+ // using the TypeScript compiler API and extracts all compile-time scalar values
6
+ // from the exported `BoardDefinition` object into a flat dot-path map.
7
+ //
8
+ // The result is stored in `ProgramIR.boardConstants` and used by the C++
9
+ // emitter to fold `Board.definition.*` property accesses into inline literals
10
+ // – without maintaining a separate hard-coded copy of the manifest.
11
+ // ---------------------------------------------------------------------------
12
+ import path from "node:path";
13
+ import fs from "node:fs";
14
+ import ts from "typescript";
15
+ /**
16
+ * Returns a set of default board constants (standard Arduino Uno-like)
17
+ * used as a fallback when no specific board manifest is loaded.
18
+ */
19
+ export function getDefaultBoardConstants() {
20
+ const result = new Map();
21
+ result.set("pins.analogOffset", 14);
22
+ result.set("peripherals.aliases.UART0", "Serial");
23
+ result.set("peripherals.aliases.I2C0", "Wire");
24
+ result.set("peripherals.aliases.SPI0", "SPI");
25
+ return result;
26
+ }
27
+ /**
28
+ * Parse a TypeScript board-definition source file and return a flat map of
29
+ * all compile-time constant scalar values exported as a `BoardDefinition`.
30
+ *
31
+ * Properties whose values are arrays, spread elements, or other non-literal
32
+ * expressions are silently skipped (no partial constant maps for board pins
33
+ * etc. are needed by the emitter).
34
+ *
35
+ * @param defFilePath Absolute path to the board definition `index.ts`.
36
+ */
37
+ export function resolveBoardConstants(defFilePath) {
38
+ const result = new Map();
39
+ // Build a minimal TypeScript program just to get a parsed AST with type
40
+ // information for the target file. We don't need emit or diagnostics.
41
+ const program = ts.createProgram([defFilePath], {
42
+ noEmit: true,
43
+ skipLibCheck: true,
44
+ strict: false,
45
+ target: ts.ScriptTarget.ES2020,
46
+ });
47
+ // The source file may be keyed with either Windows or POSIX separators.
48
+ const sourceFile = program.getSourceFile(defFilePath) ??
49
+ program.getSourceFile(defFilePath.replace(/\\/g, "/"));
50
+ if (!sourceFile)
51
+ return result;
52
+ // Find exported variable declarations — both object literals (board/MCU defs)
53
+ // and arrays of objects (peripheral instance lists).
54
+ ts.forEachChild(sourceFile, (node) => {
55
+ if (!ts.isVariableStatement(node))
56
+ return;
57
+ const isExported = node.modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword);
58
+ if (!isExported)
59
+ return;
60
+ for (const decl of node.declarationList.declarations) {
61
+ if (!ts.isIdentifier(decl.name))
62
+ continue;
63
+ const varName = decl.name.text;
64
+ const init = decl.initializer;
65
+ // Object literal — walk normally (board/MCU definitions)
66
+ let walkInit = init;
67
+ // Unwrap `as const` / type assertions
68
+ while (walkInit && ts.isAsExpression(walkInit))
69
+ walkInit = walkInit.expression;
70
+ if (walkInit && ts.isObjectLiteralExpression(walkInit)) {
71
+ // Peripheral capability objects (e.g. PWM_CAPABILITIES → peripherals.pwm.*)
72
+ // are namespaced so HAL lookups like board("peripherals.pwm.resolution")
73
+ // resolve. Other object literals (board/MCU definitions) walk with no prefix.
74
+ if (varName.endsWith("_CAPABILITIES")) {
75
+ const baseName = varName.replace("_CAPABILITIES", "").toLowerCase();
76
+ walkObjectLiteral(walkInit, `peripherals.${baseName}`, result);
77
+ }
78
+ else {
79
+ walkObjectLiteral(walkInit, "", result);
80
+ }
81
+ }
82
+ // Array of objects — walk for peripheral instance data
83
+ // (e.g., ADC_INSTANCES → peripherals.adc.0.*)
84
+ if (walkInit && ts.isArrayLiteralExpression(walkInit)) {
85
+ if (varName.endsWith("_INSTANCES")) {
86
+ const baseName = varName.replace("_INSTANCES", "").toLowerCase();
87
+ const prefix = `peripherals.${baseName}`;
88
+ walkArrayLiteral(walkInit, prefix, result);
89
+ }
90
+ }
91
+ }
92
+ });
93
+ // After parsing the board file, check for MCU imports and merge pin data.
94
+ // Board definitions often use `...MCU.pins` spread which the AST walker
95
+ // cannot handle, but the MCU file has static pin data we can parse.
96
+ resolveAndMergeMCUConstants(defFilePath, result);
97
+ return result;
98
+ }
99
+ /**
100
+ * Detect MCU package imports in a board definition file, resolve the MCU
101
+ * definition file, parse its pin/peripheral constants, and merge them into
102
+ * the board constants. This handles the common pattern where board definitions
103
+ * use spread operators (`...ATmega328P.pins`) that the AST walker can't parse.
104
+ */
105
+ function resolveAndMergeMCUConstants(boardFilePath, boardConstants) {
106
+ // Only proceed if the board file didn't produce pin.all entries on its own
107
+ let hasPinData = false;
108
+ for (const key of boardConstants.keys()) {
109
+ if (key.startsWith("pins.all.")) {
110
+ hasPinData = true;
111
+ break;
112
+ }
113
+ }
114
+ if (hasPinData)
115
+ return;
116
+ // Parse the board file to find MCU imports
117
+ const sourceText = fs.readFileSync(boardFilePath, "utf-8");
118
+ const sourceFile = ts.createSourceFile(boardFilePath, sourceText, ts.ScriptTarget.Latest, true);
119
+ let mcuSpecifier;
120
+ for (const stmt of sourceFile.statements) {
121
+ if (!ts.isImportDeclaration(stmt))
122
+ continue;
123
+ const spec = stmt.moduleSpecifier;
124
+ if (!ts.isStringLiteral(spec))
125
+ continue;
126
+ if (spec.text.startsWith("@typecad/mcu-")) {
127
+ mcuSpecifier = spec.text;
128
+ break;
129
+ }
130
+ }
131
+ if (!mcuSpecifier)
132
+ return;
133
+ // Resolve the MCU package file path
134
+ const parts = mcuSpecifier.split("/");
135
+ const pkgName = parts[1]; // e.g. "mcu-atmega328p"
136
+ const mcuFileNames = ["mcu.ts", "index.ts"];
137
+ let dir = path.dirname(boardFilePath);
138
+ while (true) {
139
+ for (const mcuFileName of mcuFileNames) {
140
+ const nmCandidate = path.join(dir, "node_modules", "@typecad", pkgName, "src", mcuFileName);
141
+ if (fs.existsSync(nmCandidate)) {
142
+ mergeMCUConstants(nmCandidate, boardConstants);
143
+ return;
144
+ }
145
+ const pkgCandidate = path.join(dir, "packages", pkgName, "src", mcuFileName);
146
+ if (fs.existsSync(pkgCandidate)) {
147
+ mergeMCUConstants(pkgCandidate, boardConstants);
148
+ return;
149
+ }
150
+ }
151
+ const parent = path.dirname(dir);
152
+ if (parent === dir)
153
+ break;
154
+ dir = parent;
155
+ }
156
+ }
157
+ /**
158
+ * Parse an MCU definition file and merge its pin data into the board constants.
159
+ */
160
+ function mergeMCUConstants(mcuFilePath, boardConstants) {
161
+ const mcuConstants = resolveBoardConstants(mcuFilePath);
162
+ // Merge MCU pin data and peripheral constants into board constants.
163
+ // Don't overwrite existing board-specific values
164
+ for (const [key, value] of mcuConstants.entries()) {
165
+ if (key.startsWith("pins.") || key.startsWith("peripherals.")) {
166
+ if (!boardConstants.has(key)) {
167
+ boardConstants.set(key, value);
168
+ }
169
+ }
170
+ }
171
+ // Copy architecture if the MCU has it and the board doesn't
172
+ if (mcuConstants.has("architecture") && !boardConstants.has("architecture")) {
173
+ boardConstants.set("architecture", mcuConstants.get("architecture"));
174
+ }
175
+ // Also parse the MCU peripherals file for ADC/PWM/Timer data that the MCU
176
+ // definition references via import (e.g., `peripherals: MCU_PERIPHERALS`).
177
+ const mcuDir = path.dirname(mcuFilePath);
178
+ const periphFile = path.join(mcuDir, "peripherals.ts");
179
+ if (fs.existsSync(periphFile)) {
180
+ const periphConstants = resolveBoardConstants(periphFile);
181
+ for (const [key, value] of periphConstants.entries()) {
182
+ if (!boardConstants.has(key)) {
183
+ boardConstants.set(key, value);
184
+ }
185
+ }
186
+ }
187
+ }
188
+ // ---------------------------------------------------------------------------
189
+ // Helpers
190
+ // ---------------------------------------------------------------------------
191
+ /**
192
+ * Recursively walk an `ObjectLiteralExpression`, adding scalar leaf values
193
+ * to `out` keyed by their dot-separated path.
194
+ *
195
+ * @param obj Current object literal to visit.
196
+ * @param prefix Dot-path accumulated so far (empty string at top level).
197
+ * @param out Accumulator map.
198
+ */
199
+ function walkObjectLiteral(obj, prefix, out) {
200
+ for (const prop of obj.properties) {
201
+ // Only handle plain `key: value` assignments.
202
+ // Shorthand, spread, methods, and getters are ignored.
203
+ if (!ts.isPropertyAssignment(prop))
204
+ continue;
205
+ const keyNode = prop.name;
206
+ const key = ts.isIdentifier(keyNode) || ts.isStringLiteral(keyNode) || ts.isNumericLiteral(keyNode)
207
+ ? keyNode.text
208
+ : undefined;
209
+ if (!key)
210
+ continue;
211
+ const fullPath = prefix ? `${prefix}.${key}` : key;
212
+ const init = prop.initializer;
213
+ const scalar = resolveScalar(init);
214
+ if (scalar !== undefined) {
215
+ out.set(fullPath, scalar);
216
+ }
217
+ else if (ts.isObjectLiteralExpression(init)) {
218
+ // Recurse into nested objects (e.g. `memory: { flash: 32_768, ... }`).
219
+ walkObjectLiteral(init, fullPath, out);
220
+ }
221
+ else if (ts.isArrayLiteralExpression(init)) {
222
+ // Capture string arrays (e.g. `pins.unsafe: ['D0', 'D1']`)
223
+ const arrValues = [];
224
+ for (const elem of init.elements) {
225
+ if (ts.isStringLiteral(elem)) {
226
+ arrValues.push(elem.text);
227
+ }
228
+ }
229
+ if (arrValues.length > 0) {
230
+ out.set(fullPath, arrValues.join(','));
231
+ }
232
+ else {
233
+ walkArrayLiteral(init, fullPath, out);
234
+ }
235
+ }
236
+ // Encode peripheral pin maps in a compact parseable format.
237
+ // pins.i2c = { 0: { sda: 'A4', scl: 'A5' } } -> "0:sda=A4,scl=A5"
238
+ // pins.spi = { 0: { mosi: 'D11', miso: 'D12', sck: 'D13', cs: 'D10' } } -> "0:mosi=D11,miso=D12,sck=D13,cs=D10"
239
+ // pins.uart = { 0: { tx: 'D1', rx: 'D0' } } -> "0:tx=D1,rx=D0"
240
+ if (ts.isObjectLiteralExpression(init)) {
241
+ const encoded = tryEncodePeripheralPinMap(key, init);
242
+ if (encoded) {
243
+ out.set(fullPath, encoded);
244
+ }
245
+ }
246
+ // Other complex expressions are silently ignored.
247
+ }
248
+ }
249
+ function walkArrayLiteral(arr, prefix, out) {
250
+ arr.elements.forEach((elem, index) => {
251
+ const fullPath = `${prefix}.${index}`;
252
+ const scalar = resolveScalar(elem);
253
+ if (scalar !== undefined) {
254
+ out.set(fullPath, scalar);
255
+ return;
256
+ }
257
+ if (ts.isObjectLiteralExpression(elem)) {
258
+ walkObjectLiteral(elem, fullPath, out);
259
+ return;
260
+ }
261
+ if (ts.isArrayLiteralExpression(elem)) {
262
+ const arrValues = [];
263
+ for (const nested of elem.elements) {
264
+ if (ts.isStringLiteral(nested)) {
265
+ arrValues.push(nested.text);
266
+ }
267
+ }
268
+ if (arrValues.length > 0) {
269
+ out.set(fullPath, arrValues.join(','));
270
+ }
271
+ }
272
+ });
273
+ }
274
+ /**
275
+ * Try to evaluate a simple literal expression to a scalar JS value.
276
+ * Returns `undefined` for anything that is not a plain, directly readable
277
+ * literal (string, number, boolean, negative-number).
278
+ */
279
+ function resolveScalar(expr) {
280
+ // Strip `as const` / `as T` type assertions — recurse on the inner expression.
281
+ if (ts.isAsExpression(expr))
282
+ return resolveScalar(expr.expression);
283
+ // String literal
284
+ if (ts.isStringLiteral(expr))
285
+ return expr.text;
286
+ // Numeric literal — TypeScript preserves underscore separators in `.text`
287
+ // (e.g. 32_768), so we strip them before converting.
288
+ if (ts.isNumericLiteral(expr)) {
289
+ return Number(expr.text.replace(/_/g, ""));
290
+ }
291
+ // Boolean keywords
292
+ if (expr.kind === ts.SyntaxKind.TrueKeyword)
293
+ return true;
294
+ if (expr.kind === ts.SyntaxKind.FalseKeyword)
295
+ return false;
296
+ // Negative numeric literals: -32768 or -1_024
297
+ if (ts.isPrefixUnaryExpression(expr) &&
298
+ expr.operator === ts.SyntaxKind.MinusToken &&
299
+ ts.isNumericLiteral(expr.operand)) {
300
+ return -Number(expr.operand.text.replace(/_/g, ""));
301
+ }
302
+ return undefined;
303
+ }
304
+ // ---------------------------------------------------------------------------
305
+ // Peripheral pin map encoding
306
+ // ---------------------------------------------------------------------------
307
+ /**
308
+ * Try to encode a peripheral pin map object into a compact string format.
309
+ * Handles pins.i2c, pins.spi, pins.uart structures.
310
+ *
311
+ * Input: { 0: { sda: 'A4', scl: 'A5' } }
312
+ * Output: "0:sda=A4,scl=A5"
313
+ *
314
+ * Input: { 0: { mosi: 'D11', miso: 'D12', sck: 'D13', cs: 'D10' } }
315
+ * Output: "0:mosi=D11,miso=D12,sck=D13,cs=D10"
316
+ */
317
+ function tryEncodePeripheralPinMap(key, obj) {
318
+ // Only encode known peripheral pin structures
319
+ if (key !== 'i2c' && key !== 'spi' && key !== 'uart')
320
+ return undefined;
321
+ const instances = [];
322
+ for (const prop of obj.properties) {
323
+ if (!ts.isPropertyAssignment(prop))
324
+ continue;
325
+ const keyNode = prop.name;
326
+ if (!ts.isIdentifier(keyNode) && !ts.isStringLiteral(keyNode) && !ts.isNumericLiteral(keyNode))
327
+ continue;
328
+ const instanceKey = keyNode.text;
329
+ const value = prop.initializer;
330
+ if (!ts.isObjectLiteralExpression(value))
331
+ continue;
332
+ // Parse the inner object { sda: 'A4', scl: 'A5' } etc.
333
+ const fields = [];
334
+ for (const field of value.properties) {
335
+ if (!ts.isPropertyAssignment(field))
336
+ continue;
337
+ const fieldKey = field.name;
338
+ if (!ts.isIdentifier(fieldKey) && !ts.isStringLiteral(fieldKey) && !ts.isNumericLiteral(fieldKey))
339
+ continue;
340
+ const fieldValue = field.initializer;
341
+ if (!ts.isStringLiteral(fieldValue))
342
+ continue;
343
+ fields.push(`${fieldKey.text}=${fieldValue.text}`);
344
+ }
345
+ if (fields.length > 0) {
346
+ instances.push(`${instanceKey}:${fields.join(',')}`);
347
+ }
348
+ }
349
+ if (instances.length > 0) {
350
+ return instances.join(';');
351
+ }
352
+ return undefined;
353
+ }
354
+ /**
355
+ * Given a source file path and a relative import module specifier, check
356
+ * whether the import resolves to a TypeCAD board-definition package
357
+ * (path pattern: /code/board-*\/index.ts).
358
+ *
359
+ * Returns the absolute path to the board index.ts on match, otherwise
360
+ * undefined.
361
+ */
362
+ export function tryResolveBoardDefFile(fromFile, moduleSpecifier, boardPackage) {
363
+ // Handle the "@typecad/board" virtual import — rewrite to the concrete board
364
+ // package so the rest of the resolution logic works unchanged.
365
+ // (Case-insensitive so the documented mixed-case form resolves identically.)
366
+ let effectiveSpecifier = moduleSpecifier;
367
+ if (moduleSpecifier.toLowerCase() === "@typecad/board" && boardPackage) {
368
+ effectiveSpecifier = boardPackage;
369
+ }
370
+ // Handle relative imports (e.g. "../code/board-arduino-uno/pins")
371
+ if (effectiveSpecifier.startsWith(".")) {
372
+ const dir = path.dirname(fromFile);
373
+ const base = path.resolve(dir, moduleSpecifier);
374
+ // Candidates: bare path, +.ts, or /index.ts
375
+ const candidates = [
376
+ base,
377
+ `${base}.ts`,
378
+ path.join(base, "index.ts"),
379
+ ];
380
+ for (const candidate of candidates) {
381
+ if (!fs.existsSync(candidate))
382
+ continue;
383
+ const normalized = candidate.replace(/\\/g, "/");
384
+ if (/[\\/]board-/.test(normalized)) {
385
+ // Always redirect to index.ts in the board package root so we parse the
386
+ // BoardDefinition manifest regardless of which file was actually imported
387
+ // (e.g. board.ts, pins.ts, etc.).
388
+ const boardDir = path.dirname(candidate);
389
+ const indexTs = path.join(boardDir, "index.ts");
390
+ return fs.existsSync(indexTs) ? indexTs : candidate;
391
+ }
392
+ }
393
+ return undefined;
394
+ }
395
+ // Handle npm-scoped board package imports (e.g. "@typecad/board-esp32-devkit")
396
+ if (effectiveSpecifier.startsWith("@typecad/board-")) {
397
+ const parts = effectiveSpecifier.split("/");
398
+ const pkgName = parts[1]; // "board-esp32-devkit"
399
+ // Walk up from the importing file's directory to find node_modules OR a packages directory (monorepo)
400
+ let dir = path.dirname(fromFile);
401
+ while (true) {
402
+ // 1. Try node_modules
403
+ const nmCandidate = path.join(dir, "node_modules", "@typecad", pkgName, "src", "index.ts");
404
+ if (fs.existsSync(nmCandidate))
405
+ return nmCandidate;
406
+ // 2. Try packages/ directory (monorepo layout)
407
+ const pkgCandidate = path.join(dir, "packages", pkgName, "src", "index.ts");
408
+ if (fs.existsSync(pkgCandidate))
409
+ return pkgCandidate;
410
+ // 3. Try sibling packages directory (if fromFile is inside a package)
411
+ const siblingPkgCandidate = path.join(path.dirname(dir), "packages", pkgName, "src", "index.ts");
412
+ if (fs.existsSync(siblingPkgCandidate))
413
+ return siblingPkgCandidate;
414
+ const parent = path.dirname(dir);
415
+ if (parent === dir)
416
+ break; // reached filesystem root
417
+ dir = parent;
418
+ }
419
+ }
420
+ return undefined;
421
+ }
422
+ /**
423
+ * Resolve the framework-specific build target (e.g. Arduino FQBN) from the
424
+ * board package's manifest.
425
+ *
426
+ * @param boardPackage Board package identifier or path.
427
+ * @param configPath Path to the project config file (for relative resolution).
428
+ * @param framework Target framework name (default: 'arduino').
429
+ */
430
+ export function resolveBoardBuildTarget(boardPackage, configPath, framework = "arduino") {
431
+ const defFile = tryResolveBoardDefFile(configPath, boardPackage);
432
+ if (!defFile)
433
+ return undefined;
434
+ const constants = resolveBoardConstants(defFile);
435
+ const target = constants.get(`build.frameworks.${framework}`);
436
+ return typeof target === "string" ? target : undefined;
437
+ }
@@ -0,0 +1,167 @@
1
+ import type { FunctionIR, ClassIR, EnumIR, InterfaceIR, TypeAliasIR, ExpressionIR } from "../api/index.js";
2
+ import type { PlatformStrategy } from "../api/shared/index.js";
3
+ import type { Diagnostic } from "../types.js";
4
+ import { AsyncLocalStorage } from "node:async_hooks";
5
+ import { BoardConstants } from "./board-resolver.js";
6
+ export type { IrTypeScope } from "./symbol-types.js";
7
+ export interface HALInstance {
8
+ className: string;
9
+ fieldValues: Map<string, string>;
10
+ _spreadParamName?: string;
11
+ [key: string]: unknown;
12
+ }
13
+ export interface RegisteredCallback {
14
+ placeholderName: string;
15
+ callbackIR: ExpressionIR & {
16
+ kind: "callback";
17
+ };
18
+ }
19
+ export type PointerTracker = Map<string, string>;
20
+ export declare class CompilationContext {
21
+ topLevelClasses: Map<string, ClassIR>;
22
+ registerFieldMap: Map<string, Map<string, {
23
+ hi: number;
24
+ lo: number;
25
+ width: number;
26
+ }>>;
27
+ hoistedNestedFunctions: FunctionIR[];
28
+ hoistedNestedClasses: ClassIR[];
29
+ hoistedNestedEnums: EnumIR[];
30
+ hoistedNestedInterfaces: InterfaceIR[];
31
+ hoistedNestedTypeAliases: TypeAliasIR[];
32
+ nestedFunctionAliases: Map<string, string>;
33
+ nestedClassAliases: Map<string, string>;
34
+ activeCArrayVars: Set<string>;
35
+ activeArrayLiteralVars: Set<string>;
36
+ activeStringVars: Set<string>;
37
+ mutableArrayVars: Set<string>;
38
+ arrayLiteralSizes: Map<string, number>;
39
+ filteredArrayLengthVars: Map<string, string>;
40
+ activeNamespaceNames: Set<string>;
41
+ topLevelClassNames: Set<string>;
42
+ topLevelInterfaceNames: Set<string>;
43
+ classTypeNames: Set<string>;
44
+ activeEnumNames: Set<string>;
45
+ activeStringEnumNames: Set<string>;
46
+ activePinUsage: Map<string, {
47
+ pinNumber: string;
48
+ source: string;
49
+ }>;
50
+ activePeripheralUsage: Map<string, {
51
+ instance: number;
52
+ source: string;
53
+ }>;
54
+ peripheralAliasMap: Map<string, string>;
55
+ pinAliasMap: Map<string, string>;
56
+ mcuPinForwardMap: Map<string, string>;
57
+ mcuPinReverseMap: Map<string, string>;
58
+ requiredIncludes: Set<string>;
59
+ registeredCallbacks: RegisteredCallback[];
60
+ _currentBoardConstants: BoardConstants | undefined;
61
+ activeExtendsClass: string | undefined;
62
+ contextId: string;
63
+ halInstances: Map<string, HALInstance>;
64
+ /**
65
+ * Top-level `const x = <receiver>.<method>(...)` alias declarations, recorded
66
+ * as varName → receiver source text in a cheap up-front pass (no resolution).
67
+ * `resolveHALReceiver` follows this lazily so a function that references `x`
68
+ * resolves correctly even when declared before the `const x = ...`. This makes
69
+ * HAL resolution order-independent (demo #34 Finding C). Only mode-setter
70
+ * methods (asOutput/asInput/...) are recorded here — value-bearing reads are
71
+ * excluded so they don't alias the pin (Finding B).
72
+ */
73
+ topLevelAliasReceivers: Map<string, {
74
+ receiver: string;
75
+ method: string;
76
+ args?: string[];
77
+ }>;
78
+ floatVariables: Set<string>;
79
+ snprintfCounter: number;
80
+ callbackPlaceholderCounter: number;
81
+ activeStrategy: PlatformStrategy | null;
82
+ restParamFunctions: Map<string, string>;
83
+ /**
84
+ * Diagnostics sink for the current file build. Populated by buildProgramIR
85
+ * with the same array returned in ProgramIR.diagnostics, so diagnostics
86
+ * pushed from deep in IR lowering (e.g. renderExprAsText's fallback paths)
87
+ * flow into the fatal-gate check in transpile.ts without that diagnostic
88
+ * array having to be threaded through ~80 call sites. May be empty before
89
+ * buildProgramIR assigns it; callers must null-check.
90
+ */
91
+ diagnostics: Diagnostic[];
92
+ /**
93
+ * Module-level free-function return types for the file currently being
94
+ * lowered. Populated by buildProgramIR so UI callbacks / timers can resolve
95
+ * helper return types. Cleared in resetBuildState.
96
+ */
97
+ activeFunctionReturnTypes: Map<string, string>;
98
+ }
99
+ /**
100
+ * AsyncLocalStorage for context isolation across parallel transpilations.
101
+ * When no store is active (e.g. in tests or non-async code paths), the
102
+ * globalDefaultContext is used as fallback.
103
+ *
104
+ * IMPORTANT: `resetBuildState()` must be called between transpilations to
105
+ * clear the globalDefaultContext. In watch mode, this is done automatically
106
+ * at the start of each `transpileFile()` call.
107
+ */
108
+ export declare const contextStorage: AsyncLocalStorage<CompilationContext>;
109
+ export declare function getContext(): CompilationContext;
110
+ export declare const topLevelClasses: Map<string, ClassIR>;
111
+ export declare const registerFieldMap: Map<string, Map<string, {
112
+ hi: number;
113
+ lo: number;
114
+ width: number;
115
+ }>>;
116
+ export declare const halInstances: Map<string, HALInstance>;
117
+ export declare const topLevelAliasReceivers: Map<string, {
118
+ receiver: string;
119
+ method: string;
120
+ args?: string[];
121
+ }>;
122
+ export declare const floatVariables: Set<string>;
123
+ export declare const hoistedNestedFunctions: FunctionIR[];
124
+ export declare const hoistedNestedClasses: ClassIR[];
125
+ export declare const hoistedNestedEnums: EnumIR[];
126
+ export declare const hoistedNestedInterfaces: InterfaceIR[];
127
+ export declare const hoistedNestedTypeAliases: TypeAliasIR[];
128
+ export declare const nestedFunctionAliases: Map<string, string>;
129
+ export declare const nestedClassAliases: Map<string, string>;
130
+ export declare const activeCArrayVars: Set<string>;
131
+ export declare const activeArrayLiteralVars: Set<string>;
132
+ export declare const activeStringVars: Set<string>;
133
+ export declare const mutableArrayVars: Set<string>;
134
+ export declare const arrayLiteralSizes: Map<string, number>;
135
+ export declare const filteredArrayLengthVars: Map<string, string>;
136
+ export declare const activeNamespaceNames: Set<string>;
137
+ export declare const topLevelClassNames: Set<string>;
138
+ export declare const topLevelInterfaceNames: Set<string>;
139
+ export declare const classTypeNames: Set<string>;
140
+ export declare const activeEnumNames: Set<string>;
141
+ export declare const activeStringEnumNames: Set<string>;
142
+ export declare const activePinUsage: Map<string, {
143
+ pinNumber: string;
144
+ source: string;
145
+ }>;
146
+ export declare const activePeripheralUsage: Map<string, {
147
+ instance: number;
148
+ source: string;
149
+ }>;
150
+ export declare const peripheralAliasMap: Map<string, string>;
151
+ export declare const pinAliasMap: Map<string, string>;
152
+ export declare const mcuPinForwardMap: Map<string, string>;
153
+ export declare const mcuPinReverseMap: Map<string, string>;
154
+ export declare const requiredIncludes: Set<string>;
155
+ export declare const registeredCallbacks: RegisteredCallback[];
156
+ export declare const discriminatedUnionVariantNames: Map<string, string[]>;
157
+ export declare const restParamFunctions: Map<string, string>;
158
+ export declare const activeFunctionReturnTypes: Map<string, string>;
159
+ export declare function getActiveExtendsClass(): string | undefined;
160
+ export declare function setActiveExtendsClass(v: string | undefined): void;
161
+ export declare const PIN_FACTORY_FUNCTIONS: Set<string>;
162
+ export declare const CONSTANT_FOLD_FUNCTIONS: Set<string>;
163
+ export declare const TYPED_ARRAY_ELEMENT_MAP: Record<string, string>;
164
+ export declare function getCurrentBoardConstants(): BoardConstants;
165
+ export declare function setCurrentBoardConstants(v: BoardConstants | undefined): void;
166
+ export declare function resetBuildState(): void;
167
+ export declare function resetFunctionScopeState(): void;