@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,363 @@
1
+ import type { HALOpIR } from './hal-op-ir.js';
2
+ import type { SourceSpan } from './types.js';
3
+ /**
4
+ * The C++ type carried on every IR declaration field. Stored as a string at
5
+ * the IR level (so construction sites read naturally: `cppType: "int"`), but
6
+ * every *consumer* parses it once via `parseCppType` and inspects the resulting
7
+ * `CppTypeIR` structurally (by `kind`) instead of re-parsing with
8
+ * startsWith/endsWith/slice. See `cpp-type-ir.ts`.
9
+ *
10
+ * Keeping the field a string preserves readable IR construction; the structural
11
+ * value is realized at inspection sites, which is where the historical ad-hoc
12
+ * string parsing was concentrated.
13
+ */
14
+ export type CppType = string;
15
+ export interface ParameterIR {
16
+ name: string;
17
+ cppType: string;
18
+ defaultValue?: ExpressionIR;
19
+ isRest: boolean;
20
+ /** Ownership kind inferred from type annotation (Shared<T>, Mutable<T>, Owned<T>). */
21
+ ownershipKind?: 'owned' | 'shared' | 'mutable';
22
+ }
23
+ export type ExpressionIR = {
24
+ kind: "number";
25
+ value: number;
26
+ cppType?: "int" | "float" | "double";
27
+ } | {
28
+ kind: "string";
29
+ value: string;
30
+ } | {
31
+ kind: "boolean";
32
+ value: boolean;
33
+ } | {
34
+ kind: "identifier";
35
+ value: string;
36
+ } | {
37
+ kind: "raw";
38
+ value: string;
39
+ newClassName?: string;
40
+ } | {
41
+ kind: "await";
42
+ value: ExpressionIR;
43
+ } | {
44
+ kind: "ternary";
45
+ condition: ExpressionIR;
46
+ whenTrue: ExpressionIR;
47
+ whenFalse: ExpressionIR;
48
+ } | {
49
+ kind: "array";
50
+ elementType: string;
51
+ elements: ExpressionIR[];
52
+ } | {
53
+ kind: "string_concat";
54
+ parts: ExpressionIR[];
55
+ } | {
56
+ kind: "template_string";
57
+ expression: ExpressionIR;
58
+ } | {
59
+ kind: "object";
60
+ fields: {
61
+ name: string;
62
+ value: ExpressionIR;
63
+ }[];
64
+ cppType?: CppType;
65
+ } | {
66
+ kind: "instanceof";
67
+ object: ExpressionIR;
68
+ className: string;
69
+ } | {
70
+ kind: "spread_array";
71
+ elementType: string;
72
+ spreadExpr: ExpressionIR;
73
+ additionalElements: ExpressionIR[];
74
+ }
75
+ /** Binary expression: left OP right (e.g. `val + 100`, `a && b`). */
76
+ | {
77
+ kind: "binary";
78
+ left: ExpressionIR;
79
+ operator: string;
80
+ right: ExpressionIR;
81
+ }
82
+ /** Unary expression: OP operand (prefix) or operand OP (postfix). */
83
+ | {
84
+ kind: "unary";
85
+ operator: string;
86
+ operand: ExpressionIR;
87
+ postfix?: boolean;
88
+ }
89
+ /**
90
+ * Property access: `object.property`.
91
+ * Produced by `expressionToIR` for all property-read expressions so that
92
+ * the emitter can recognise and translate TypeCAD metadata paths like
93
+ * `Board.definition.mcu` without regex post-processing.
94
+ */
95
+ | {
96
+ kind: "property-access";
97
+ object: ExpressionIR;
98
+ property: string;
99
+ isStatic?: boolean;
100
+ isEnum?: boolean;
101
+ isNamespace?: boolean;
102
+ isPointer?: boolean;
103
+ }
104
+ /**
105
+ * A callback function (arrow function or function expression) passed as an argument.
106
+ * Used for interrupt handlers and other callback contexts.
107
+ * The emitter generates a standalone function and passes its name.
108
+ * debounceMs: Optional debounce delay in milliseconds (set by .debounce() chain).
109
+ * isInterruptHandler: True when this callback is an ISR (affects safety validation).
110
+ */
111
+ | {
112
+ kind: "callback";
113
+ params: string[];
114
+ statements: StatementIR[];
115
+ sourceSpan: SourceSpan;
116
+ debounceMs?: number;
117
+ isInterruptHandler?: boolean;
118
+ }
119
+ /** Arrow function or lambda expression: (params) => expression | { statements } */
120
+ | {
121
+ kind: "lambda";
122
+ params: ParameterIR[];
123
+ body: StatementIR[];
124
+ returnType: CppType;
125
+ isExpressionBody: boolean;
126
+ }
127
+ /** A general method call with structured argument IR (preserves callbacks/lambdas). */
128
+ | {
129
+ kind: "method-call";
130
+ callee: string;
131
+ args: ExpressionIR[];
132
+ isStatic?: boolean;
133
+ isNamespace?: boolean;
134
+ isPointer?: boolean;
135
+ restElementType?: string;
136
+ cppType?: string;
137
+ }
138
+ /** Array element access: `object[index]`. */
139
+ | {
140
+ kind: "element-access";
141
+ object: ExpressionIR;
142
+ index: ExpressionIR;
143
+ elementType?: string;
144
+ }
145
+ /** Tuple element access: `std::get<N>(object)` for std::tuple types. */
146
+ | {
147
+ kind: "tuple-access";
148
+ object: ExpressionIR;
149
+ index: number;
150
+ }
151
+ /** Parenthesized expression: preserves explicit grouping from TS source (e.g. `(2+3)*4`). */
152
+ | {
153
+ kind: "paren";
154
+ inner: ExpressionIR;
155
+ }
156
+ /**
157
+ * HAL operation used as an expression (returns a value).
158
+ * The framework strategy resolves the operation to a C++ expression string.
159
+ */
160
+ | {
161
+ kind: "hal-expr";
162
+ operation: HALOpIR;
163
+ };
164
+ export interface CallExpressionIR {
165
+ kind: "call";
166
+ sourceSpan: SourceSpan;
167
+ leadingComments?: string[];
168
+ trailingComments?: string[];
169
+ callee: string;
170
+ args: ExpressionIR[];
171
+ /** True when this call was originally written as `await call()` in the TS source. */
172
+ isAwaited?: boolean;
173
+ }
174
+ export interface VariableDeclarationIR {
175
+ kind: "var_decl";
176
+ sourceSpan: SourceSpan;
177
+ leadingComments?: string[];
178
+ trailingComments?: string[];
179
+ name: string;
180
+ storage: "var" | "let" | "const";
181
+ cppType: string;
182
+ initializer?: ExpressionIR;
183
+ /** True when the variable should be marked as volatile in C++ (prevents compiler optimization). */
184
+ isVolatile?: boolean;
185
+ /** Ownership kind inferred from type annotation (Shared<T>, Mutable<T>, Owned<T>). */
186
+ ownershipKind?: 'owned' | 'shared' | 'mutable';
187
+ }
188
+ export interface AssignmentIR {
189
+ kind: "assign";
190
+ sourceSpan: SourceSpan;
191
+ leadingComments?: string[];
192
+ trailingComments?: string[];
193
+ target: string;
194
+ operator: "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "&=" | "|=" | "^=" | "<<=" | ">>=";
195
+ value: ExpressionIR;
196
+ }
197
+ export interface UpdateIR {
198
+ kind: "update";
199
+ sourceSpan: SourceSpan;
200
+ leadingComments?: string[];
201
+ trailingComments?: string[];
202
+ target: string;
203
+ operator: "++" | "--";
204
+ prefix: boolean;
205
+ }
206
+ export interface ReturnIR {
207
+ kind: "return";
208
+ sourceSpan: SourceSpan;
209
+ leadingComments?: string[];
210
+ trailingComments?: string[];
211
+ value?: ExpressionIR;
212
+ /**
213
+ * The C++ return type of the enclosing function, when known at IR-build
214
+ * time. Used by the renderer to lower `return null`/`return undefined` to a
215
+ * value-initialized `return {};` when the function returns a struct (a
216
+ * `nullptr`/`CUTTLEFISH_UNDEFINED` literal cannot convert to a struct type).
217
+ * Demo #14 Finding A.
218
+ */
219
+ functionReturnType?: CppType;
220
+ }
221
+ export interface WhileIR {
222
+ kind: "while";
223
+ sourceSpan: SourceSpan;
224
+ leadingComments?: string[];
225
+ trailingComments?: string[];
226
+ condition: ExpressionIR;
227
+ body: StatementIR[];
228
+ }
229
+ export interface IfIR {
230
+ kind: "if";
231
+ sourceSpan: SourceSpan;
232
+ leadingComments?: string[];
233
+ trailingComments?: string[];
234
+ condition: ExpressionIR;
235
+ thenBranch: StatementIR[];
236
+ elseBranch?: StatementIR[];
237
+ }
238
+ export interface ForIR {
239
+ kind: "for";
240
+ sourceSpan: SourceSpan;
241
+ leadingComments?: string[];
242
+ trailingComments?: string[];
243
+ initializer?: StatementIR;
244
+ condition?: ExpressionIR;
245
+ increment?: StatementIR;
246
+ body: StatementIR[];
247
+ }
248
+ export interface ForOfIR {
249
+ kind: "for_of";
250
+ sourceSpan: SourceSpan;
251
+ leadingComments?: string[];
252
+ trailingComments?: string[];
253
+ variable: StatementIR;
254
+ iterable: ExpressionIR;
255
+ body: StatementIR[];
256
+ }
257
+ export interface ForInIR {
258
+ kind: "for_in";
259
+ sourceSpan: SourceSpan;
260
+ leadingComments?: string[];
261
+ trailingComments?: string[];
262
+ variable: StatementIR;
263
+ object: ExpressionIR;
264
+ /** Field/key names of the iterated object, used to generate a key array for C++ emission */
265
+ keys?: string[];
266
+ body: StatementIR[];
267
+ }
268
+ export interface BreakIR {
269
+ kind: "break";
270
+ sourceSpan: SourceSpan;
271
+ leadingComments?: string[];
272
+ trailingComments?: string[];
273
+ label?: string;
274
+ }
275
+ export interface ContinueIR {
276
+ kind: "continue";
277
+ sourceSpan: SourceSpan;
278
+ leadingComments?: string[];
279
+ trailingComments?: string[];
280
+ label?: string;
281
+ }
282
+ export interface DoWhileIR {
283
+ kind: "do_while";
284
+ sourceSpan: SourceSpan;
285
+ leadingComments?: string[];
286
+ trailingComments?: string[];
287
+ condition: ExpressionIR;
288
+ body: StatementIR[];
289
+ }
290
+ export interface SwitchIR {
291
+ kind: "switch";
292
+ sourceSpan: SourceSpan;
293
+ leadingComments?: string[];
294
+ trailingComments?: string[];
295
+ expression: ExpressionIR;
296
+ cases: CaseIR[];
297
+ }
298
+ export interface CaseIR {
299
+ kind: "case";
300
+ sourceSpan: SourceSpan;
301
+ leadingComments?: string[];
302
+ trailingComments?: string[];
303
+ value?: ExpressionIR;
304
+ body: StatementIR[];
305
+ }
306
+ export interface TryIR {
307
+ kind: "try";
308
+ sourceSpan: SourceSpan;
309
+ leadingComments?: string[];
310
+ trailingComments?: string[];
311
+ tryBlock: StatementIR[];
312
+ catchParam?: string;
313
+ catchBlock?: StatementIR[];
314
+ finallyBlock?: StatementIR[];
315
+ }
316
+ export interface ThrowIR {
317
+ kind: "throw";
318
+ sourceSpan: SourceSpan;
319
+ leadingComments?: string[];
320
+ trailingComments?: string[];
321
+ value: ExpressionIR;
322
+ }
323
+ export interface LabeledIR {
324
+ kind: "labeled";
325
+ sourceSpan: SourceSpan;
326
+ leadingComments?: string[];
327
+ trailingComments?: string[];
328
+ label: string;
329
+ body: StatementIR[];
330
+ }
331
+ export interface BlockIR {
332
+ kind: "block";
333
+ sourceSpan: SourceSpan;
334
+ leadingComments?: string[];
335
+ trailingComments?: string[];
336
+ body: StatementIR[];
337
+ }
338
+ export interface HALOpStatementIR {
339
+ kind: "hal-op";
340
+ sourceSpan: SourceSpan;
341
+ leadingComments?: string[];
342
+ trailingComments?: string[];
343
+ /** The semantic hardware operation to emit. */
344
+ operation: HALOpIR;
345
+ /** When true, the operation returns a value that should be captured. */
346
+ returns_value: boolean;
347
+ }
348
+ export interface YieldIR {
349
+ kind: "yield";
350
+ sourceSpan: SourceSpan;
351
+ leadingComments?: string[];
352
+ trailingComments?: string[];
353
+ value?: ExpressionIR;
354
+ isDelegate?: boolean;
355
+ }
356
+ export interface SuperCallIR {
357
+ kind: "super_call";
358
+ sourceSpan: SourceSpan;
359
+ leadingComments?: string[];
360
+ trailingComments?: string[];
361
+ args: ExpressionIR[];
362
+ }
363
+ export type StatementIR = CallExpressionIR | SuperCallIR | VariableDeclarationIR | AssignmentIR | UpdateIR | ReturnIR | WhileIR | DoWhileIR | IfIR | ForIR | ForOfIR | ForInIR | BreakIR | ContinueIR | SwitchIR | TryIR | ThrowIR | LabeledIR | BlockIR | HALOpStatementIR | YieldIR;
@@ -0,0 +1,8 @@
1
+ // ---------------------------------------------------------------------------
2
+ // IR: Core expression and statement types
3
+ //
4
+ // Contains ExpressionIR and StatementIR (and all supporting interfaces).
5
+ // These two union types are mutually recursive (callbacks embed statements,
6
+ // statements embed expressions) so they must live in the same file.
7
+ // ---------------------------------------------------------------------------
8
+ export {};
@@ -0,0 +1,201 @@
1
+ import type { SourceSpan } from './types.js';
2
+ import type { CppType, ExpressionIR, ParameterIR, StatementIR } from './ir-core.js';
3
+ export interface FunctionIR {
4
+ originalName: string;
5
+ isAsync: boolean;
6
+ returnType: CppType;
7
+ sourceSpan: SourceSpan;
8
+ leadingComments?: string[];
9
+ trailingComments?: string[];
10
+ parameters: ParameterIR[];
11
+ statements: StatementIR[];
12
+ /** Generic type parameters (e.g. `["T"]` for `function clamp<T>(...)`). */
13
+ typeParameters?: string[];
14
+ /** C++ static_assert expressions for constrained type parameters (e.g. `"T" → "std::is_arithmetic_v<T>"`). */
15
+ typeParameterConstraints?: Map<string, string>;
16
+ /** True when the return type is a readonly mapped type — emitter adds `const`. */
17
+ isReadonlyReturnType?: boolean;
18
+ /** True when this is a generator function (function*). */
19
+ isGenerator?: boolean;
20
+ /** True when the function is exported (has `export` keyword). */
21
+ isExported?: boolean;
22
+ }
23
+ export interface StructDefIR {
24
+ name: string;
25
+ fields: {
26
+ name: string;
27
+ cppType: CppType;
28
+ }[];
29
+ }
30
+ export interface EnumIR {
31
+ name: string;
32
+ sourceSpan: SourceSpan;
33
+ leadingComments?: string[];
34
+ trailingComments?: string[];
35
+ members: {
36
+ name: string;
37
+ value?: number | string;
38
+ }[];
39
+ isConst: boolean;
40
+ }
41
+ /**
42
+ * A "string enum" is a TypeScript enum whose members are all initialized to
43
+ * string literals, e.g. `enum Color { Red = "RED", Green = "GREEN" }`.
44
+ *
45
+ * String enums are lowered to a `namespace` of `constexpr const char*`
46
+ * constants so that member access (`Color::Red`) yields a `const char*`.
47
+ * This makes `===` comparisons against string literals and string
48
+ * concatenation behave like TypeScript without requiring reverse-mapping
49
+ * helpers or `std::to_string`.
50
+ *
51
+ * A mixed enum (some numeric, some string members) is NOT a string enum —
52
+ * it is emitted as a numeric `enum class` as before.
53
+ */
54
+ export declare function isStringEnum(enumDef: {
55
+ members: {
56
+ value?: number | string;
57
+ }[];
58
+ }): boolean;
59
+ export interface ClassFieldIR {
60
+ name: string;
61
+ cppType: CppType;
62
+ visibility: "public" | "private" | "protected";
63
+ initializer?: ExpressionIR;
64
+ isStatic?: boolean;
65
+ }
66
+ export interface ClassConstructorIR {
67
+ parameters: ParameterIR[];
68
+ statements: StatementIR[];
69
+ }
70
+ export interface ClassMethodIR {
71
+ name: string;
72
+ returnType: CppType;
73
+ parameters: ParameterIR[];
74
+ statements: StatementIR[];
75
+ visibility: "public" | "private" | "protected";
76
+ isStatic: boolean;
77
+ isAbstract: boolean;
78
+ isOverride?: boolean;
79
+ /** Generic type parameters (e.g. `["T"]` for `method<T>(...)`). */
80
+ typeParameters?: string[];
81
+ /** True when this is a generator method. */
82
+ isGenerator?: boolean;
83
+ }
84
+ export interface ClassGetterIR {
85
+ name: string;
86
+ returnType: CppType;
87
+ statements: StatementIR[];
88
+ visibility: "public" | "private" | "protected";
89
+ isStatic: boolean;
90
+ }
91
+ export interface ClassSetterIR {
92
+ name: string;
93
+ parameter: ParameterIR;
94
+ statements: StatementIR[];
95
+ visibility: "public" | "private" | "protected";
96
+ isStatic: boolean;
97
+ }
98
+ export interface ClassIR {
99
+ name: string;
100
+ extendsClass?: string;
101
+ implementsInterfaces?: string[];
102
+ isAbstract: boolean;
103
+ sourceSpan: SourceSpan;
104
+ leadingComments?: string[];
105
+ trailingComments?: string[];
106
+ fields: ClassFieldIR[];
107
+ methods: ClassMethodIR[];
108
+ getters: ClassGetterIR[];
109
+ setters: ClassSetterIR[];
110
+ constructor?: ClassConstructorIR;
111
+ typeParameters?: string[];
112
+ decorators?: string[];
113
+ }
114
+ export interface InterfaceIR {
115
+ name: string;
116
+ sourceSpan: SourceSpan;
117
+ leadingComments?: string[];
118
+ trailingComments?: string[];
119
+ extendsInterfaces?: string[];
120
+ fields: {
121
+ name: string;
122
+ cppType: CppType;
123
+ isOptional: boolean;
124
+ }[];
125
+ methods: {
126
+ name: string;
127
+ returnType: CppType;
128
+ parameters: ParameterIR[];
129
+ }[];
130
+ /** Namespace scope for hoisted interfaces (e.g. "test_complex_types__types"). */
131
+ parentScope?: string;
132
+ /** Index signature (e.g., `[key: string]: number`). */
133
+ indexSignature?: {
134
+ keyType: string;
135
+ valueType: CppType;
136
+ };
137
+ }
138
+ export interface VariantStructIR {
139
+ name: string;
140
+ fields: {
141
+ name: string;
142
+ cppType: string;
143
+ }[];
144
+ }
145
+ export interface TypeAliasIR {
146
+ name: string;
147
+ sourceSpan: SourceSpan;
148
+ leadingComments?: string[];
149
+ trailingComments?: string[];
150
+ cppType: string;
151
+ structFields?: {
152
+ name: string;
153
+ cppType: string;
154
+ }[];
155
+ variantStructs?: VariantStructIR[];
156
+ typeParameters?: string[];
157
+ }
158
+ export interface NamespaceIR {
159
+ name: string;
160
+ sourceSpan: SourceSpan;
161
+ leadingComments?: string[];
162
+ trailingComments?: string[];
163
+ enums: EnumIR[];
164
+ classes: ClassIR[];
165
+ interfaces: InterfaceIR[];
166
+ typeAliases: TypeAliasIR[];
167
+ functions: FunctionIR[];
168
+ constants: {
169
+ name: string;
170
+ cppType: CppType;
171
+ value: ExpressionIR;
172
+ storage?: "const" | "let" | "var";
173
+ }[];
174
+ /** Reassignment statements inside the namespace (e.g. x = 5). */
175
+ assignments?: {
176
+ target: string;
177
+ value: ExpressionIR;
178
+ }[];
179
+ children?: NamespaceIR[];
180
+ }
181
+ export interface RegisterBitFieldIR {
182
+ /** Field name */
183
+ name: string;
184
+ /** High bit index (inclusive) */
185
+ hi: number;
186
+ /** Low bit index (inclusive) */
187
+ lo: number;
188
+ /** Width in bits (hi - lo + 1) */
189
+ width: number;
190
+ }
191
+ export interface RegisterClassIR {
192
+ /** Register class name (e.g. "USART1") */
193
+ name: string;
194
+ /** MMIO register address (e.g. 0x40011000) */
195
+ address: number;
196
+ /** Bit field descriptors */
197
+ bitFields: RegisterBitFieldIR[];
198
+ sourceSpan: SourceSpan;
199
+ leadingComments?: string[];
200
+ trailingComments?: string[];
201
+ }
@@ -0,0 +1,26 @@
1
+ // ---------------------------------------------------------------------------
2
+ // IR: Declaration types
3
+ //
4
+ // Contains IR types for top-level declarations: functions, classes,
5
+ // interfaces, enums, structs, namespaces, type aliases, and register-mapped
6
+ // structs. These all depend on ExpressionIR/StatementIR from ir-core.ts
7
+ // but do not create circular references.
8
+ // ---------------------------------------------------------------------------
9
+ /**
10
+ * A "string enum" is a TypeScript enum whose members are all initialized to
11
+ * string literals, e.g. `enum Color { Red = "RED", Green = "GREEN" }`.
12
+ *
13
+ * String enums are lowered to a `namespace` of `constexpr const char*`
14
+ * constants so that member access (`Color::Red`) yields a `const char*`.
15
+ * This makes `===` comparisons against string literals and string
16
+ * concatenation behave like TypeScript without requiring reverse-mapping
17
+ * helpers or `std::to_string`.
18
+ *
19
+ * A mixed enum (some numeric, some string members) is NOT a string enum —
20
+ * it is emitted as a numeric `enum class` as before.
21
+ */
22
+ export function isStringEnum(enumDef) {
23
+ if (enumDef.members.length === 0)
24
+ return false;
25
+ return enumDef.members.every(m => typeof m.value === "string");
26
+ }
@@ -0,0 +1,85 @@
1
+ import type { BoardConstants } from './board-resolver.js';
2
+ import type { Diagnostic } from './types.js';
3
+ import type { RegisteredCallback } from '../../ir/build-ir-state.js';
4
+ export type { CppType, ParameterIR, ExpressionIR, CallExpressionIR, SuperCallIR, VariableDeclarationIR, AssignmentIR, UpdateIR, ReturnIR, WhileIR, IfIR, ForIR, ForOfIR, ForInIR, BreakIR, ContinueIR, DoWhileIR, SwitchIR, CaseIR, TryIR, ThrowIR, LabeledIR, BlockIR, HALOpStatementIR, StatementIR, } from './ir-core.js';
5
+ export type { HALOpIR, HALOperationKind, GpioWriteOp, GpioReadOp, GpioToggleOp, GpioSetModeOp, PwmWriteOp, PwmGetFrequencyOp, PwmGetResolutionOp, AdcReadOp, AdcGetResolutionOp, AdcSetReferenceOp, AdcGetReferenceOp, AdcReadVoltageOp, DacWriteOp, InterruptAttachOp, InterruptDetachOp, TonePlayOp, ToneStopOp, TimingDelayOp, TimingDelayMicrosecondsOp, TimingMillisOp, TimingMicrosOp, TimingFreeHeapOp, TimingSetIntervalOp, TimingSetTimeoutOp, TimingClearIntervalOp, TimingClearTimeoutOp, I2cBeginOp, I2cEndOp, I2cSetClockOp, I2cBeginTransmissionOp, I2cWriteOp, I2cEndTransmissionOp, I2cRequestFromOp, I2cAvailableOp, I2cReadOp, I2cRecoverOp, SpiBeginOp, SpiEndOp, SpiTransferOp, SpibeginTransactionOp, SpiEndTransactionOp, SpiSetModeOp, SpiSetBitOrderOp, SpiCsLowOp, SpiCsHighOp, UartBeginOp, UartEndOp, UartPrintOp, UartPrintlnOp, UartPrintfOp, UartWriteOp, UartReadOp, UartPeekOp, UartAvailableOp, UartFlushOp, PulseInOp, PulseInLongOp, ShiftOutOp, ShiftInOp, BoardResolveOp, SnprintfEmitOp, RawCppOp, } from './hal-op-ir.js';
6
+ export type { FunctionIR, StructDefIR, EnumIR, ClassFieldIR, ClassConstructorIR, ClassMethodIR, ClassGetterIR, ClassSetterIR, ClassIR, InterfaceIR, TypeAliasIR, NamespaceIR, RegisterBitFieldIR, RegisterClassIR, } from './ir-declarations.js';
7
+ export interface ImportIR {
8
+ moduleSpecifier: string;
9
+ namedImports: string[];
10
+ /** For default imports: import X from "./module.js" */
11
+ defaultImportName?: string;
12
+ }
13
+ export interface ReExportIR {
14
+ moduleSpecifier: string;
15
+ /** true for `export * from`, array for `export { a, b } from` */
16
+ exportAll: boolean;
17
+ namedExports?: string[];
18
+ }
19
+ /**
20
+ * Tracks which hardware peripherals are used in the program.
21
+ * This enables compile-time initialization optimization.
22
+ */
23
+ export interface PeripheralUsageIR {
24
+ /** ADC is used (analogRead on A0-A5) */
25
+ adc: boolean;
26
+ /** PWM is used (analogWrite on D3, D5, D6, D9, D10, D11) */
27
+ pwm: boolean;
28
+ /** External interrupts are used (attachInterrupt on D2, D3) */
29
+ externalInterrupts: boolean;
30
+ /** Timer0-based timing is used (millis, micros) */
31
+ timer0: boolean;
32
+ /** I2C bus is used */
33
+ i2c: boolean;
34
+ /** SPI bus is used */
35
+ spi: boolean;
36
+ /** UART/Serial is used */
37
+ uart: boolean;
38
+ /** Specific PWM pins used (for targeted timer initialization) */
39
+ pwmPinsUsed: Set<number>;
40
+ /** Specific ADC channels used */
41
+ adcChannelsUsed: Set<number>;
42
+ /** Pins configured as output */
43
+ outputPins: Set<number>;
44
+ /** Pins configured as input with pullup */
45
+ inputPullupPins: Set<number>;
46
+ /** Pins configured as input (no pullup) */
47
+ inputPins: Set<number>;
48
+ /** Pins configured as input with pulldown */
49
+ inputPulldownPins: Set<number>;
50
+ /** All pin names explicitly referenced */
51
+ pinsUsed: Set<string>;
52
+ /** Specific pins used for external interrupts */
53
+ interruptPinsUsed: Set<number>;
54
+ }
55
+ import type { StructDefIR, EnumIR, ClassIR, InterfaceIR, NamespaceIR, TypeAliasIR, RegisterClassIR, FunctionIR } from './ir-declarations.js';
56
+ import type { StatementIR } from './ir-core.js';
57
+ export interface ProgramIR {
58
+ fileName: string;
59
+ imports: ImportIR[];
60
+ reExports: ReExportIR[];
61
+ structs: StructDefIR[];
62
+ enums: EnumIR[];
63
+ classes: ClassIR[];
64
+ interfaces: InterfaceIR[];
65
+ namespaces: NamespaceIR[];
66
+ typeAliases: TypeAliasIR[];
67
+ /** Register-mapped structs (from @register decorator) */
68
+ registerClasses: RegisterClassIR[];
69
+ topLevelStatements: StatementIR[];
70
+ functions: FunctionIR[];
71
+ boilerplates: Set<string>;
72
+ diagnostics: Diagnostic[];
73
+ /** Compile-time constants extracted from the imported board-definition file. */
74
+ boardConstants?: BoardConstants;
75
+ /** Tracks which hardware peripherals are used (for optimized initialization) */
76
+ peripheralUsage?: PeripheralUsageIR;
77
+ /** Library includes registered by inline evaluators (e.g., "<SPI.h>", "<Wire.h>") */
78
+ requiredIncludes?: Set<string>;
79
+ /** The name of the default export, if this module has `export default <name>` */
80
+ defaultExportName?: string;
81
+ /** Registered callbacks from the HAL resolver */
82
+ registeredCallbacks?: RegisteredCallback[];
83
+ /** Map of function names to their rest parameter element types (e.g., "sum" -> "int") */
84
+ restParamFunctions?: Map<string, string>;
85
+ }
@@ -0,0 +1,13 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Intermediate Representation (IR) types
3
+ //
4
+ // This file defines the top-level program container (ProgramIR) and
5
+ // re-exports all IR types from the focused sub-modules:
6
+ //
7
+ // ir-core.ts — ExpressionIR, StatementIR, and supporting types
8
+ // ir-declarations.ts — FunctionIR, ClassIR, InterfaceIR, NamespaceIR, etc.
9
+ //
10
+ // Consumers can import from this file as before, or directly from the
11
+ // sub-modules for more precise dependencies.
12
+ // ---------------------------------------------------------------------------
13
+ export {};