@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.
- package/LICENSE +21 -0
- package/README.md +79 -0
- package/dist/api/board-types.d.ts +1 -0
- package/dist/api/board-types.js +4 -0
- package/dist/api/capabilities.d.ts +12 -0
- package/dist/api/capabilities.js +1 -0
- package/dist/api/config.d.ts +120 -0
- package/dist/api/config.js +7 -0
- package/dist/api/index.d.ts +5 -0
- package/dist/api/index.js +2 -0
- package/dist/api/schema/builder.d.ts +14 -0
- package/dist/api/schema/builder.js +15 -0
- package/dist/api/schema/index.d.ts +2 -0
- package/dist/api/schema/index.js +1 -0
- package/dist/api/schema/types.d.ts +257 -0
- package/dist/api/schema/types.js +4 -0
- package/dist/api/shared/async-runtime-static.d.ts +8 -0
- package/dist/api/shared/async-runtime-static.js +201 -0
- package/dist/api/shared/async-types.d.ts +42 -0
- package/dist/api/shared/async-types.js +8 -0
- package/dist/api/shared/board-resolver.d.ts +12 -0
- package/dist/api/shared/board-resolver.js +7 -0
- package/dist/api/shared/cpp-type-ir.d.ts +229 -0
- package/dist/api/shared/cpp-type-ir.js +672 -0
- package/dist/api/shared/display-adapter.d.ts +12 -0
- package/dist/api/shared/display-adapter.js +145 -0
- package/dist/api/shared/display-adapters/eink-mono.d.ts +2 -0
- package/dist/api/shared/display-adapters/eink-mono.js +53 -0
- package/dist/api/shared/display-adapters/sdl.d.ts +2 -0
- package/dist/api/shared/display-adapters/sdl.js +452 -0
- package/dist/api/shared/display-adapters/ssd1309.d.ts +2 -0
- package/dist/api/shared/display-adapters/ssd1309.js +136 -0
- package/dist/api/shared/display-adapters/st7796.d.ts +2 -0
- package/dist/api/shared/display-adapters/st7796.js +132 -0
- package/dist/api/shared/display-capabilities.d.ts +45 -0
- package/dist/api/shared/display-capabilities.js +54 -0
- package/dist/api/shared/display-op-ir.d.ts +62 -0
- package/dist/api/shared/display-op-ir.js +19 -0
- package/dist/api/shared/display-profile.d.ts +265 -0
- package/dist/api/shared/display-profile.js +338 -0
- package/dist/api/shared/graphics-strategy.d.ts +29 -0
- package/dist/api/shared/graphics-strategy.js +11 -0
- package/dist/api/shared/hal-op-ir.d.ts +393 -0
- package/dist/api/shared/hal-op-ir.js +18 -0
- package/dist/api/shared/index.d.ts +26 -0
- package/dist/api/shared/index.js +21 -0
- package/dist/api/shared/ir-core.d.ts +363 -0
- package/dist/api/shared/ir-core.js +8 -0
- package/dist/api/shared/ir-declarations.d.ts +201 -0
- package/dist/api/shared/ir-declarations.js +26 -0
- package/dist/api/shared/ir.d.ts +85 -0
- package/dist/api/shared/ir.js +13 -0
- package/dist/api/shared/platform-strategy.d.ts +402 -0
- package/dist/api/shared/platform-strategy.js +14 -0
- package/dist/api/shared/polyfill-helper-registry.d.ts +11 -0
- package/dist/api/shared/polyfill-helper-registry.js +86 -0
- package/dist/api/shared/polyfill-types.d.ts +33 -0
- package/dist/api/shared/polyfill-types.js +76 -0
- package/dist/api/shared/promise-runtime.d.ts +10 -0
- package/dist/api/shared/promise-runtime.js +244 -0
- package/dist/api/shared/snprintf-types.d.ts +29 -0
- package/dist/api/shared/snprintf-types.js +8 -0
- package/dist/api/shared/string-method-registry.d.ts +53 -0
- package/dist/api/shared/string-method-registry.js +168 -0
- package/dist/api/shared/toolchain-types.d.ts +63 -0
- package/dist/api/shared/toolchain-types.js +71 -0
- package/dist/api/shared/types.d.ts +50 -0
- package/dist/api/shared/types.js +6 -0
- package/dist/ast/parse.d.ts +2 -0
- package/dist/ast/parse.js +4 -0
- package/dist/cache.d.ts +26 -0
- package/dist/cache.js +95 -0
- package/dist/cli-utils.d.ts +37 -0
- package/dist/cli-utils.js +250 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +635 -0
- package/dist/config-loader.d.ts +78 -0
- package/dist/config-loader.js +508 -0
- package/dist/config-schema.d.ts +233 -0
- package/dist/config-schema.js +83 -0
- package/dist/create/board-checklist.d.ts +2 -0
- package/dist/create/board-checklist.js +52 -0
- package/dist/create/board-codegen.d.ts +9 -0
- package/dist/create/board-codegen.js +238 -0
- package/dist/create/board-generators.d.ts +12 -0
- package/dist/create/board-generators.js +652 -0
- package/dist/create/board-spec.d.ts +640 -0
- package/dist/create/board-spec.js +215 -0
- package/dist/create/eslint-rules-template.d.ts +2 -0
- package/dist/create/eslint-rules-template.js +672 -0
- package/dist/create/index.d.ts +11 -0
- package/dist/create/index.js +8 -0
- package/dist/create/init-scaffold.d.ts +27 -0
- package/dist/create/init-scaffold.js +150 -0
- package/dist/create/init-templates.d.ts +24 -0
- package/dist/create/init-templates.js +379 -0
- package/dist/create/init-wizard.d.ts +8 -0
- package/dist/create/init-wizard.js +168 -0
- package/dist/debug/breakpoint-loader.d.ts +24 -0
- package/dist/debug/breakpoint-loader.js +137 -0
- package/dist/debug/index.d.ts +3 -0
- package/dist/debug/index.js +7 -0
- package/dist/debug/preprocessor.d.ts +9 -0
- package/dist/debug/preprocessor.js +214 -0
- package/dist/debug/types.d.ts +32 -0
- package/dist/debug/types.js +6 -0
- package/dist/diagnostics/diagnostics-report.d.ts +51 -0
- package/dist/diagnostics/diagnostics-report.js +333 -0
- package/dist/diagnostics/json-schema.d.ts +138 -0
- package/dist/diagnostics/json-schema.js +27 -0
- package/dist/diagnostics/md-writer.d.ts +10 -0
- package/dist/diagnostics/md-writer.js +336 -0
- package/dist/diagnostics/mermaid-builder.d.ts +65 -0
- package/dist/diagnostics/mermaid-builder.js +681 -0
- package/dist/emit/cpp-emitter.d.ts +6 -0
- package/dist/emit/cpp-emitter.js +48 -0
- package/dist/emit/emitters/class-emitter.d.ts +2 -0
- package/dist/emit/emitters/class-emitter.js +523 -0
- package/dist/emit/emitters/emitter-context.d.ts +174 -0
- package/dist/emit/emitters/emitter-context.js +1 -0
- package/dist/emit/emitters/entrypoint-synthesizer.d.ts +2 -0
- package/dist/emit/emitters/entrypoint-synthesizer.js +175 -0
- package/dist/emit/emitters/function-emitter-impl.d.ts +19 -0
- package/dist/emit/emitters/function-emitter-impl.js +428 -0
- package/dist/emit/emitters/line-appender.d.ts +15 -0
- package/dist/emit/emitters/line-appender.js +344 -0
- package/dist/emit/emitters/namespace-emitter.d.ts +2 -0
- package/dist/emit/emitters/namespace-emitter.js +324 -0
- package/dist/emit/emitters/output-finalizer.d.ts +4 -0
- package/dist/emit/emitters/output-finalizer.js +267 -0
- package/dist/emit/emitters/setup.d.ts +3 -0
- package/dist/emit/emitters/setup.js +851 -0
- package/dist/emit/emitters/top-level-prep.d.ts +2 -0
- package/dist/emit/emitters/top-level-prep.js +706 -0
- package/dist/emit/emitters/type-decl-emitter.d.ts +2 -0
- package/dist/emit/emitters/type-decl-emitter.js +251 -0
- package/dist/emit/emitters/ui-emitter.d.ts +21 -0
- package/dist/emit/emitters/ui-emitter.js +564 -0
- package/dist/emit/enum-emitter.d.ts +1 -0
- package/dist/emit/enum-emitter.js +1 -0
- package/dist/emit/expression-renderer.d.ts +283 -0
- package/dist/emit/expression-renderer.js +1477 -0
- package/dist/emit/native-helpers-emitter.d.ts +11 -0
- package/dist/emit/native-helpers-emitter.js +34 -0
- package/dist/emit/route-hal-op.d.ts +5 -0
- package/dist/emit/route-hal-op.js +13 -0
- package/dist/emit/snprintf-helpers.d.ts +17 -0
- package/dist/emit/snprintf-helpers.js +462 -0
- package/dist/emit/statement-renderer.d.ts +189 -0
- package/dist/emit/statement-renderer.js +948 -0
- package/dist/emit/utils/async-state-machine.d.ts +42 -0
- package/dist/emit/utils/async-state-machine.js +343 -0
- package/dist/emit/utils/comment-helpers.d.ts +20 -0
- package/dist/emit/utils/comment-helpers.js +31 -0
- package/dist/emit/utils/cpp-helpers.d.ts +47 -0
- package/dist/emit/utils/cpp-helpers.js +85 -0
- package/dist/emit/utils/include-resolver.d.ts +58 -0
- package/dist/emit/utils/include-resolver.js +155 -0
- package/dist/emit/utils/index.d.ts +8 -0
- package/dist/emit/utils/index.js +12 -0
- package/dist/emit/utils/type-inference.d.ts +159 -0
- package/dist/emit/utils/type-inference.js +559 -0
- package/dist/eslint-check.d.ts +10 -0
- package/dist/eslint-check.js +102 -0
- package/dist/framework-package.d.ts +10 -0
- package/dist/framework-package.js +58 -0
- package/dist/framework-registry.d.ts +39 -0
- package/dist/framework-registry.js +30 -0
- package/dist/incremental-cache.d.ts +116 -0
- package/dist/incremental-cache.js +335 -0
- package/dist/ir/adc-range-validation.d.ts +11 -0
- package/dist/ir/adc-range-validation.js +250 -0
- package/dist/ir/ast-node-utils.d.ts +8 -0
- package/dist/ir/ast-node-utils.js +32 -0
- package/dist/ir/board-pin-utils.d.ts +13 -0
- package/dist/ir/board-pin-utils.js +65 -0
- package/dist/ir/board-resolver.d.ts +36 -0
- package/dist/ir/board-resolver.js +437 -0
- package/dist/ir/build-ir-state.d.ts +167 -0
- package/dist/ir/build-ir-state.js +306 -0
- package/dist/ir/build-ir.d.ts +2 -0
- package/dist/ir/build-ir.js +808 -0
- package/dist/ir/call-graph.d.ts +35 -0
- package/dist/ir/call-graph.js +194 -0
- package/dist/ir/compile-time-only.d.ts +2 -0
- package/dist/ir/compile-time-only.js +16 -0
- package/dist/ir/declaration-builders.d.ts +9 -0
- package/dist/ir/declaration-builders.js +608 -0
- package/dist/ir/entry-points.d.ts +30 -0
- package/dist/ir/entry-points.js +191 -0
- package/dist/ir/expression-to-ir.d.ts +5 -0
- package/dist/ir/expression-to-ir.js +2249 -0
- package/dist/ir/extract-property-chain.d.ts +10 -0
- package/dist/ir/extract-property-chain.js +30 -0
- package/dist/ir/feature-prescan.d.ts +3 -0
- package/dist/ir/feature-prescan.js +43 -0
- package/dist/ir/feature-registry.d.ts +30 -0
- package/dist/ir/feature-registry.js +816 -0
- package/dist/ir/filter.d.ts +7 -0
- package/dist/ir/filter.js +85 -0
- package/dist/ir/function-builder.d.ts +19 -0
- package/dist/ir/function-builder.js +670 -0
- package/dist/ir/hal/hal-emitter.d.ts +62 -0
- package/dist/ir/hal/hal-emitter.js +735 -0
- package/dist/ir/hal/hal-parser.d.ts +61 -0
- package/dist/ir/hal/hal-parser.js +473 -0
- package/dist/ir/hal/hal-plugins.d.ts +34 -0
- package/dist/ir/hal/hal-plugins.js +706 -0
- package/dist/ir/hal-resolver.d.ts +5 -0
- package/dist/ir/hal-resolver.js +5 -0
- package/dist/ir/heap-analysis.d.ts +8 -0
- package/dist/ir/heap-analysis.js +350 -0
- package/dist/ir/heap-array-validation.d.ts +24 -0
- package/dist/ir/heap-array-validation.js +29 -0
- package/dist/ir/identifier-collector.d.ts +18 -0
- package/dist/ir/identifier-collector.js +439 -0
- package/dist/ir/interrupt-analysis.d.ts +39 -0
- package/dist/ir/interrupt-analysis.js +467 -0
- package/dist/ir/memory-budget-validation.d.ts +10 -0
- package/dist/ir/memory-budget-validation.js +86 -0
- package/dist/ir/namespace-builder.d.ts +7 -0
- package/dist/ir/namespace-builder.js +152 -0
- package/dist/ir/ownership-analysis.d.ts +9 -0
- package/dist/ir/ownership-analysis.js +1207 -0
- package/dist/ir/peripheral-ownership.d.ts +3 -0
- package/dist/ir/peripheral-ownership.js +152 -0
- package/dist/ir/peripheral-symbols.d.ts +7 -0
- package/dist/ir/peripheral-symbols.js +57 -0
- package/dist/ir/peripheral-usage.d.ts +54 -0
- package/dist/ir/peripheral-usage.js +691 -0
- package/dist/ir/peripheral-validation.d.ts +8 -0
- package/dist/ir/peripheral-validation.js +77 -0
- package/dist/ir/pin-alias-conflict.d.ts +4 -0
- package/dist/ir/pin-alias-conflict.js +34 -0
- package/dist/ir/pin-capability-validation.d.ts +6 -0
- package/dist/ir/pin-capability-validation.js +413 -0
- package/dist/ir/pin-mode-validation.d.ts +10 -0
- package/dist/ir/pin-mode-validation.js +301 -0
- package/dist/ir/pin-safety.d.ts +11 -0
- package/dist/ir/pin-safety.js +58 -0
- package/dist/ir/program-analysis.d.ts +44 -0
- package/dist/ir/program-analysis.js +589 -0
- package/dist/ir/pulldown-validation.d.ts +7 -0
- package/dist/ir/pulldown-validation.js +49 -0
- package/dist/ir/pwm-timer-sharing.d.ts +4 -0
- package/dist/ir/pwm-timer-sharing.js +93 -0
- package/dist/ir/reachability.d.ts +68 -0
- package/dist/ir/reachability.js +224 -0
- package/dist/ir/register-decorators.d.ts +6 -0
- package/dist/ir/register-decorators.js +49 -0
- package/dist/ir/render-expr.d.ts +4 -0
- package/dist/ir/render-expr.js +127 -0
- package/dist/ir/resource-analysis.d.ts +19 -0
- package/dist/ir/resource-analysis.js +153 -0
- package/dist/ir/statement-to-ir.d.ts +23 -0
- package/dist/ir/statement-to-ir.js +349 -0
- package/dist/ir/symbol-table.d.ts +68 -0
- package/dist/ir/symbol-table.js +179 -0
- package/dist/ir/symbol-types.d.ts +56 -0
- package/dist/ir/symbol-types.js +107 -0
- package/dist/ir/timer0-pwm-timing-conflict.d.ts +4 -0
- package/dist/ir/timer0-pwm-timing-conflict.js +71 -0
- package/dist/ir/timing-validation.d.ts +7 -0
- package/dist/ir/timing-validation.js +95 -0
- package/dist/ir/transformers/array-methods.d.ts +8 -0
- package/dist/ir/transformers/array-methods.js +493 -0
- package/dist/ir/transformers/call-statement.d.ts +5 -0
- package/dist/ir/transformers/call-statement.js +758 -0
- package/dist/ir/transformers/callback-context-registry.d.ts +20 -0
- package/dist/ir/transformers/callback-context-registry.js +55 -0
- package/dist/ir/transformers/canvas-lowering.d.ts +42 -0
- package/dist/ir/transformers/canvas-lowering.js +249 -0
- package/dist/ir/transformers/control-flow.d.ts +8 -0
- package/dist/ir/transformers/control-flow.js +508 -0
- package/dist/ir/transformers/expressions.d.ts +7 -0
- package/dist/ir/transformers/expressions.js +406 -0
- package/dist/ir/transformers/hal-call-resolver.d.ts +29 -0
- package/dist/ir/transformers/hal-call-resolver.js +274 -0
- package/dist/ir/transformers/hal-emit-helpers.d.ts +14 -0
- package/dist/ir/transformers/hal-emit-helpers.js +63 -0
- package/dist/ir/transformers/namespace-methods.d.ts +20 -0
- package/dist/ir/transformers/namespace-methods.js +110 -0
- package/dist/ir/transformers/register-assignment.d.ts +5 -0
- package/dist/ir/transformers/register-assignment.js +56 -0
- package/dist/ir/transformers/ui-call-resolver.d.ts +149 -0
- package/dist/ir/transformers/ui-call-resolver.js +1136 -0
- package/dist/ir/transformers/ui-callback-lowering.d.ts +62 -0
- package/dist/ir/transformers/ui-callback-lowering.js +623 -0
- package/dist/ir/transformers/ui-mount.d.ts +20 -0
- package/dist/ir/transformers/ui-mount.js +35 -0
- package/dist/ir/transformers/ui-reactive.d.ts +68 -0
- package/dist/ir/transformers/ui-reactive.js +129 -0
- package/dist/ir/transformers/variables.d.ts +14 -0
- package/dist/ir/transformers/variables.js +1045 -0
- package/dist/ir/try-catch-validation.d.ts +26 -0
- package/dist/ir/try-catch-validation.js +128 -0
- package/dist/ir/type-resolution.d.ts +31 -0
- package/dist/ir/type-resolution.js +977 -0
- package/dist/ir/ui-element-auto-wire.d.ts +50 -0
- package/dist/ir/ui-element-auto-wire.js +218 -0
- package/dist/ir/unit-suspicion-validation.d.ts +12 -0
- package/dist/ir/unit-suspicion-validation.js +296 -0
- package/dist/ir/utils/walk-ir.d.ts +6 -0
- package/dist/ir/utils/walk-ir.js +162 -0
- package/dist/ir/validation-orchestrator.d.ts +4 -0
- package/dist/ir/validation-orchestrator.js +45 -0
- package/dist/libdef/base-class-resolver.d.ts +23 -0
- package/dist/libdef/base-class-resolver.js +50 -0
- package/dist/libdef/cpp-to-decl.d.ts +34 -0
- package/dist/libdef/cpp-to-decl.js +584 -0
- package/dist/libdef/header-parser.d.ts +53 -0
- package/dist/libdef/header-parser.js +269 -0
- package/dist/libdef/registry.d.ts +10 -0
- package/dist/libdef/registry.js +142 -0
- package/dist/mapping/peripheral-names.d.ts +23 -0
- package/dist/mapping/peripheral-names.js +63 -0
- package/dist/mapping/source-map.d.ts +46 -0
- package/dist/mapping/source-map.js +207 -0
- package/dist/orchestrator/dts-generator.d.ts +17 -0
- package/dist/orchestrator/dts-generator.js +83 -0
- package/dist/orchestrator/graph-builder.d.ts +18 -0
- package/dist/orchestrator/graph-builder.js +218 -0
- package/dist/orchestrator/semantic-facts-verifier.d.ts +38 -0
- package/dist/orchestrator/semantic-facts-verifier.js +121 -0
- package/dist/orchestrator/semantic-facts.d.ts +141 -0
- package/dist/orchestrator/semantic-facts.js +652 -0
- package/dist/orchestrator/type-checker.d.ts +39 -0
- package/dist/orchestrator/type-checker.js +760 -0
- package/dist/platform/async-runtime.d.ts +8 -0
- package/dist/platform/async-runtime.js +26 -0
- package/dist/platform/generic-strategy.d.ts +101 -0
- package/dist/platform/generic-strategy.js +289 -0
- package/dist/platform/index.d.ts +4 -0
- package/dist/platform/index.js +9 -0
- package/dist/platform/registry.d.ts +21 -0
- package/dist/platform/registry.js +42 -0
- package/dist/platform/toolchain.d.ts +4 -0
- package/dist/platform/toolchain.js +43 -0
- package/dist/preview/client.d.ts +1 -0
- package/dist/preview/client.js +137 -0
- package/dist/preview/server.d.ts +5 -0
- package/dist/preview/server.js +199 -0
- package/dist/profiler/index.d.ts +28 -0
- package/dist/profiler/index.js +28 -0
- package/dist/profiler/profiler.d.ts +95 -0
- package/dist/profiler/profiler.js +338 -0
- package/dist/profiler/types.d.ts +87 -0
- package/dist/profiler/types.js +12 -0
- package/dist/stores/display-profile-store.d.ts +16 -0
- package/dist/stores/display-profile-store.js +48 -0
- package/dist/stores/theme-store.d.ts +13 -0
- package/dist/stores/theme-store.js +30 -0
- package/dist/testing.d.ts +45 -0
- package/dist/testing.js +47 -0
- package/dist/transpile/resolution.d.ts +29 -0
- package/dist/transpile/resolution.js +282 -0
- package/dist/transpile.d.ts +3 -0
- package/dist/transpile.js +722 -0
- package/dist/types.d.ts +217 -0
- package/dist/types.js +1 -0
- package/dist/ui/ui-bridge.d.ts +4 -0
- package/dist/ui/ui-bridge.js +34 -0
- package/dist/ui-hook.d.ts +84 -0
- package/dist/ui-hook.js +45 -0
- package/dist/utils/cli.d.ts +3 -0
- package/dist/utils/cli.js +463 -0
- package/dist/utils/fs.d.ts +4 -0
- package/dist/utils/fs.js +23 -0
- package/dist/utils/logger.d.ts +2 -0
- package/dist/utils/logger.js +8 -0
- package/dist/utils/strings.d.ts +35 -0
- package/dist/utils/strings.js +142 -0
- package/dist/utils/ui.d.ts +66 -0
- package/dist/utils/ui.js +149 -0
- package/dist/watch.d.ts +35 -0
- package/dist/watch.js +111 -0
- package/package.json +127 -0
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Expression Renderer for C++ code emission.
|
|
3
|
+
* Encapsulates all expression rendering logic with explicit dependencies.
|
|
4
|
+
* Extracted from cpp-emitter.ts
|
|
5
|
+
*/
|
|
6
|
+
import type { ExpressionIR } from "../api/index.js";
|
|
7
|
+
import type { PlatformStrategy } from "../api/shared/index.js";
|
|
8
|
+
import type { BoardConstants } from "../ir/board-resolver.js";
|
|
9
|
+
import type { KnownVariableInfo } from "../api/shared/index.js";
|
|
10
|
+
import type { Diagnostic } from "../types.js";
|
|
11
|
+
/**
|
|
12
|
+
* Context needed for expression rendering.
|
|
13
|
+
*/
|
|
14
|
+
interface ExpressionRendererContext {
|
|
15
|
+
/** The platform strategy for target-specific rendering */
|
|
16
|
+
strategy: PlatformStrategy;
|
|
17
|
+
/** Board constants for Board.definition.* access */
|
|
18
|
+
boardConstants?: BoardConstants;
|
|
19
|
+
/** Map of class simple names to fully qualified names (framework library imports) */
|
|
20
|
+
classNameMap?: Map<string, string>;
|
|
21
|
+
/** Set of enum names for scoped enum access (::) */
|
|
22
|
+
enumNames: Set<string>;
|
|
23
|
+
/** Set of string enum names (lowered to const char* namespaces; members are const char*) */
|
|
24
|
+
stringEnumNames?: Set<string>;
|
|
25
|
+
/** Set of enum names with values outside 16-bit int range */
|
|
26
|
+
largeEnumNames: Set<string>;
|
|
27
|
+
/** Map of function names to their return types */
|
|
28
|
+
knownFunctionReturnTypes?: Map<string, string>;
|
|
29
|
+
/** Map of variable names to their inferred C++ types (for snprintf format specifiers) */
|
|
30
|
+
knownVariableTypes?: Map<string, KnownVariableInfo>;
|
|
31
|
+
/** Map of variable names to their pointer types */
|
|
32
|
+
pointerVarTypes?: Map<string, string>;
|
|
33
|
+
/** Module-scope (file-global) variables resolved to pointer C++ types, used
|
|
34
|
+
* to decide `->` vs `.` when a bare identifier resolves to a global pointer
|
|
35
|
+
* (e.g. an ISR-captured `const btn = new Button()` accessed inside a hoisted
|
|
36
|
+
* callback, where the local-scope type map is empty). Replaces the
|
|
37
|
+
* file-wide `\b${name}\.` → `${name}->` text sweep that previously patched
|
|
38
|
+
* this in output-finalizer.ts. */
|
|
39
|
+
globalPointerVarTypes?: Map<string, string>;
|
|
40
|
+
/** Set of variable names known to hold string values (for snprintf %s) */
|
|
41
|
+
stringVarNames?: Set<string>;
|
|
42
|
+
/** Set of variable names known to be emitted as C arrays */
|
|
43
|
+
cArrayVarNames?: Set<string>;
|
|
44
|
+
/** Set of namespace names for scoped access (::) instead of (.) */
|
|
45
|
+
namespaceNames?: Set<string>;
|
|
46
|
+
/** Cross-module class names recognized by the expression renderer. */
|
|
47
|
+
crossModuleClassNames?: Set<string>;
|
|
48
|
+
/** Map of variable names to their class's accessor map for getter/setter rewriting */
|
|
49
|
+
varAccessorNames?: Map<string, Map<string, "getter" | "setter" | "both">>;
|
|
50
|
+
/**
|
|
51
|
+
* Map of class type names to their accessor map. Used as a fallback when a
|
|
52
|
+
* member access's receiver isn't in `varAccessorNames` (e.g. a for-of loop
|
|
53
|
+
* variable, a function-call return, or a chained access) but its resolved
|
|
54
|
+
* C++ type names a class with getters. Lets the getter rewrite
|
|
55
|
+
* (`obj.prop` → `obj->getProp()`) fire for any pointer-valued receiver of a
|
|
56
|
+
* known class type, not just `this` and explicitly-registered variables.
|
|
57
|
+
*/
|
|
58
|
+
typeAccessorNames?: Map<string, Map<string, "getter" | "setter" | "both">>;
|
|
59
|
+
/** Optional transformer for expression values */
|
|
60
|
+
exprTransformer?: (expr: string) => string;
|
|
61
|
+
/** Shared counter for unique snprintf buffer names across statement renders */
|
|
62
|
+
snprintfCounter?: {
|
|
63
|
+
value: number;
|
|
64
|
+
};
|
|
65
|
+
/** Map of interface/type name to field C++ types */
|
|
66
|
+
interfaceFieldTypes?: Map<string, Map<string, string>>;
|
|
67
|
+
/** Names of top-level const object variables (e.g. `const CONFIG = {...}`),
|
|
68
|
+
* used to distinguish `.` member access on an instance from `::` on a
|
|
69
|
+
* namespace/class. */
|
|
70
|
+
knownTopLevelObjectTypes?: Map<string, string>;
|
|
71
|
+
/**
|
|
72
|
+
* Shared sink for emit-time diagnostics. When provided, the renderer's
|
|
73
|
+
* fallback paths (e.g. an unregistered HAL operation) push structured
|
|
74
|
+
* warnings here instead of silently emitting placeholder comments. The
|
|
75
|
+
* array is the same one finalizeOutput merges into the final diagnostics
|
|
76
|
+
* list. Optional so ad-hoc/test constructions still work.
|
|
77
|
+
*/
|
|
78
|
+
diagnostics?: Diagnostic[];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Renders ExpressionIR nodes to C++ code strings.
|
|
82
|
+
*/
|
|
83
|
+
export declare class ExpressionRenderer {
|
|
84
|
+
private readonly strategy;
|
|
85
|
+
private readonly boardConstants?;
|
|
86
|
+
private readonly classNameMap?;
|
|
87
|
+
private readonly enumNames;
|
|
88
|
+
private readonly stringEnumNames;
|
|
89
|
+
private readonly largeEnumNames;
|
|
90
|
+
private readonly knownFunctionReturnTypes?;
|
|
91
|
+
private readonly knownVariableTypes?;
|
|
92
|
+
private readonly pointerVarTypes?;
|
|
93
|
+
private readonly globalPointerVarTypes?;
|
|
94
|
+
private readonly stringVarNames?;
|
|
95
|
+
private readonly cArrayVarNames?;
|
|
96
|
+
private readonly namespaceNames;
|
|
97
|
+
private readonly varAccessorNames;
|
|
98
|
+
private readonly typeAccessorNames;
|
|
99
|
+
private readonly interfaceFieldTypes;
|
|
100
|
+
private readonly knownTopLevelObjectTypes?;
|
|
101
|
+
/** Accumulated snprintf prelude lines (buffer declarations, dtostrf calls, snprintf calls). */
|
|
102
|
+
private _preludeLines;
|
|
103
|
+
/** Monotonic counter for unique snprintf buffer names. Shared across renders when provided. */
|
|
104
|
+
private _snprintfCounter;
|
|
105
|
+
/** Shared emit-time diagnostics sink (see ExpressionRendererContext.diagnostics). */
|
|
106
|
+
private readonly _diagnostics;
|
|
107
|
+
constructor(context: ExpressionRendererContext);
|
|
108
|
+
/**
|
|
109
|
+
* Gets the board constants (for access by statement renderer).
|
|
110
|
+
*/
|
|
111
|
+
getBoardConstants(): BoardConstants | undefined;
|
|
112
|
+
/**
|
|
113
|
+
* Clear accumulated prelude lines. Call before each top-level render.
|
|
114
|
+
*/
|
|
115
|
+
clearPrelude(): void;
|
|
116
|
+
/**
|
|
117
|
+
* Drain accumulated prelude lines and clear. The caller is responsible
|
|
118
|
+
* for emitting these lines before the statement that uses the expression.
|
|
119
|
+
*/
|
|
120
|
+
drainPrelude(): string[];
|
|
121
|
+
/**
|
|
122
|
+
* Push lines directly into the prelude buffer. Used by the statement renderer
|
|
123
|
+
* to inject multi-statement expansions (e.g. Wire read setup) that must appear
|
|
124
|
+
* before the surrounding statement.
|
|
125
|
+
*/
|
|
126
|
+
pushPrelude(lines: string[]): void;
|
|
127
|
+
/**
|
|
128
|
+
* Renders an expression IR node to a C++ string.
|
|
129
|
+
*
|
|
130
|
+
* @param expr The expression to render
|
|
131
|
+
* @param exprTransformer Optional transformer for raw expressions
|
|
132
|
+
* @param knownVariableTypes Optional override for variable type mapping
|
|
133
|
+
* @returns The C++ code string
|
|
134
|
+
*/
|
|
135
|
+
render(expr: ExpressionIR, exprTransformer?: (expr: string) => string, knownVariableTypes?: Map<string, KnownVariableInfo>): string;
|
|
136
|
+
private renderIdentifier;
|
|
137
|
+
private renderRaw;
|
|
138
|
+
private renderTernary;
|
|
139
|
+
private normalizeRecordType;
|
|
140
|
+
private inferExpressionCppType;
|
|
141
|
+
/**
|
|
142
|
+
* True when a C++ type name denotes a string value: either the strategy's
|
|
143
|
+
* built-in string-like types (std::string, const char*, Arduino String, …)
|
|
144
|
+
* OR a TypeScript string-enum name, which is lowered to `const char*`.
|
|
145
|
+
*/
|
|
146
|
+
private isStringLikeCppType;
|
|
147
|
+
private shouldSkipStringWrap;
|
|
148
|
+
/**
|
|
149
|
+
* Resolve an expression to its C++ type when possible (consulting
|
|
150
|
+
* `knownVariableTypes`, interface/class field type maps, enum/string-enum
|
|
151
|
+
* sets, etc.). Returns `undefined` when the type cannot be determined.
|
|
152
|
+
*
|
|
153
|
+
* Public so emit-layer callers (e.g. the switch emitter in line-appender)
|
|
154
|
+
* can make type-aware lowering decisions — see demo #16 gap #1: a `switch`
|
|
155
|
+
* on a struct field of enum type must not be wrapped in `std::string(...)`.
|
|
156
|
+
*/
|
|
157
|
+
inferCppType(expr: ExpressionIR, knownVariableTypes?: Map<string, KnownVariableInfo>): string | undefined;
|
|
158
|
+
private renderKnownStringValue;
|
|
159
|
+
private renderStringConcat;
|
|
160
|
+
private renderTemplateString;
|
|
161
|
+
/**
|
|
162
|
+
* Build snprintf format string and args from string_concat parts.
|
|
163
|
+
* Returns the buffer name on success, or undefined if snprintf can't handle it.
|
|
164
|
+
*/
|
|
165
|
+
private buildSnprintfFromParts;
|
|
166
|
+
/**
|
|
167
|
+
* Infer printf format specifier for an expression.
|
|
168
|
+
* Returns format string, rendered arg, estimated length, and optional prelude lines, or undefined if unknown.
|
|
169
|
+
*/
|
|
170
|
+
inferFormatSpecifier(expr: ExpressionIR, exprTransformer?: (expr: string) => string, knownVariableTypes?: Map<string, KnownVariableInfo>): {
|
|
171
|
+
format: string;
|
|
172
|
+
arg: string;
|
|
173
|
+
estimatedLength: number;
|
|
174
|
+
preludeLines?: string[];
|
|
175
|
+
} | undefined;
|
|
176
|
+
private renderArray;
|
|
177
|
+
private renderObject;
|
|
178
|
+
private renderSpreadArray;
|
|
179
|
+
private renderInstanceof;
|
|
180
|
+
private renderElementAccess;
|
|
181
|
+
private isEnumComparisonOperand;
|
|
182
|
+
/**
|
|
183
|
+
* Render an expression value that will be assigned to a non-enum lvalue,
|
|
184
|
+
* passed as a non-enum argument, or otherwise consumed where C++ `enum class`
|
|
185
|
+
* won't implicitly convert. If the value is a numeric-enum operand, wrap it
|
|
186
|
+
* in `static_cast<int>(...)` so it composes with int-typed targets (e.g.
|
|
187
|
+
* `links[0] = LinkFlag.Wired` → `links[0] = static_cast<int>(LinkFlag::Wired)`).
|
|
188
|
+
* String-enum operands are passed through unchanged (they're `const char*`).
|
|
189
|
+
*
|
|
190
|
+
* This is the assignment/argument-site counterpart to the operator-level
|
|
191
|
+
* enum wrapping in renderBinary. SUPPORT_MATRIX §1.7: enum values used as
|
|
192
|
+
* integers need an explicit cast in C++.
|
|
193
|
+
*/
|
|
194
|
+
renderEnumSafeValue(expr: ExpressionIR, knownVariableTypes?: Map<string, KnownVariableInfo>): string;
|
|
195
|
+
/**
|
|
196
|
+
* Render a value that will be stored into an lvalue of a known C++ type
|
|
197
|
+
* (an `assign` target, a `var_decl` initializer, a `push_back` argument,
|
|
198
|
+
* ...). Centralizes the **enum ↔ integral storage boundary** so every
|
|
199
|
+
* assignment/initialization site lowers consistently:
|
|
200
|
+
*
|
|
201
|
+
* - target is a numeric C++ type, value is a numeric-enum operand →
|
|
202
|
+
* `static_cast<int>(value)` (enum → int). This is the existing
|
|
203
|
+
* `renderEnumSafeValue` direction, now driven by the target type
|
|
204
|
+
* instead of duplicated per site.
|
|
205
|
+
* - target is a C++ `enum class`, value is a numeric/element-access
|
|
206
|
+
* operand → `static_cast<EnumType>(value)` (int → enum). C++ `enum
|
|
207
|
+
* class` does not implicitly convert FROM an integral storage type
|
|
208
|
+
* either, so reading an `int`/`uint8_t` cell back into an enum-typed
|
|
209
|
+
* local needs the reverse cast. SUPPORT_MATRIX §1.7.
|
|
210
|
+
*
|
|
211
|
+
* This closes the "enum↔integral storage boundary" family — the previous
|
|
212
|
+
* point-specific casts handled enum-as-array-index (demo #28 E) and
|
|
213
|
+
* enum-as-Map-key (demo #28 E review) but NOT enum stored into integral
|
|
214
|
+
* storage, integral storage read back into an enum, or an enum value
|
|
215
|
+
* passed to `push_back` on an integral-element vector. Demo #32 Finding A.
|
|
216
|
+
*
|
|
217
|
+
* String enums (`const char*`) and string-like targets are passed through
|
|
218
|
+
* unchanged. Unknown/auto target types are passed through unchanged
|
|
219
|
+
* (safer than a wrong cast).
|
|
220
|
+
*/
|
|
221
|
+
renderValueForTarget(expr: ExpressionIR, targetType: string | undefined, knownVariableTypes?: Map<string, KnownVariableInfo>, exprTransformer?: (expr: string) => string): string;
|
|
222
|
+
/**
|
|
223
|
+
* Resolve a rendered C++ lvalue STRING (the `target` carried by an `assign`
|
|
224
|
+
* IR node, e.g. `this->nxt[r][c]`, `cells[i]`, `flag`) to its declared C++
|
|
225
|
+
* element/value type. This is the string-target counterpart to
|
|
226
|
+
* `inferExpressionCppType`'s element-access / property-access / identifier
|
|
227
|
+
* branches: the assign target is already rendered to text at IR-build time,
|
|
228
|
+
* so the emit layer must recover its type from the text + the shared type
|
|
229
|
+
* maps (the same maps `inferExpressionCppType` consults).
|
|
230
|
+
*
|
|
231
|
+
* Structural, not regex-rewrite: it splits the base from trailing `[...]`
|
|
232
|
+
* subscripts, resolves the base via the class-field / local / global-pointer
|
|
233
|
+
* maps, then unwraps one `std::vector<T>` / `StaticArray<T,N>` layer per
|
|
234
|
+
* subscript. Returns `undefined` when the type can't be resolved confidently
|
|
235
|
+
* — callers fall through to plain rendering (never an incorrect cast).
|
|
236
|
+
* Demo #32 Finding A.
|
|
237
|
+
*/
|
|
238
|
+
inferLvalueCppType(target: string, knownVariableTypes?: Map<string, KnownVariableInfo>): string | undefined;
|
|
239
|
+
/**
|
|
240
|
+
* Resolve a subscript-free rendered base (`this->field`, `obj->field`,
|
|
241
|
+
* `obj.field`, or a bare local name) to its declared C++ type. The string
|
|
242
|
+
* counterpart of `inferExpressionCppType`'s identifier / property-access
|
|
243
|
+
* branches. Demo #32 Finding A.
|
|
244
|
+
*/
|
|
245
|
+
private resolveLvalueBaseType;
|
|
246
|
+
/**
|
|
247
|
+
* Shared enum-operand wrapping for binary operators. Detects whether each
|
|
248
|
+
* side is a numeric-enum operand (excluding string enums), casts it to int,
|
|
249
|
+
* and applies defensive symmetry: if exactly one side is an enum, the other
|
|
250
|
+
* side is also cast so the operator sees `int op int`. Returns the
|
|
251
|
+
* (possibly rewrapped) left and right strings.
|
|
252
|
+
*
|
|
253
|
+
* Used by the arithmetic, bitwise, and comparison branches of renderBinary
|
|
254
|
+
* so the enum-cast logic lives in one place rather than three.
|
|
255
|
+
*/
|
|
256
|
+
private castEnumOperandsForOperator;
|
|
257
|
+
/**
|
|
258
|
+
* Returns true when an expression is a string-enum member access, i.e. it
|
|
259
|
+
* resolves to a `constexpr const char*` (e.g. `Color.Red` where Color is a
|
|
260
|
+
* TS string enum). Such operands must NOT be static_cast<int>'d in
|
|
261
|
+
* comparisons — they compare as C-strings instead.
|
|
262
|
+
*/
|
|
263
|
+
private isStringEnumOperand;
|
|
264
|
+
private getNumericEnumOperandName;
|
|
265
|
+
private renderBinary;
|
|
266
|
+
private renderUnary;
|
|
267
|
+
private renderPropertyAccess;
|
|
268
|
+
private renderCallback;
|
|
269
|
+
private renderLambda;
|
|
270
|
+
private renderMethodCall;
|
|
271
|
+
private escapeFinalMemberName;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Normalizes a raw expression string for C++ output.
|
|
275
|
+
* Handles === to == conversion, enum access, and class name transformation.
|
|
276
|
+
*/
|
|
277
|
+
export declare function normalizeRawExpression(value: string, strategy: PlatformStrategy, classNameMap?: Map<string, string>): string;
|
|
278
|
+
/**
|
|
279
|
+
* Transform type names to their fully qualified names (with namespaces).
|
|
280
|
+
* E.g., "SHT3x*" -> "Microfire::SHT3x*", "SHT3x" -> "Microfire::SHT3x"
|
|
281
|
+
*/
|
|
282
|
+
export declare function transformTypeName(cppType: string, classNameMap: Map<string, string> | undefined): string;
|
|
283
|
+
export {};
|