@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,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Statement Renderer for C++ code emission.
|
|
3
|
+
* Encapsulates all statement rendering logic with explicit dependencies.
|
|
4
|
+
* Extracted from cpp-emitter.ts
|
|
5
|
+
*/
|
|
6
|
+
import type { StatementIR } 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
|
+
import { ExpressionRenderer } from "./expression-renderer.js";
|
|
12
|
+
/**
|
|
13
|
+
* Context needed for statement rendering.
|
|
14
|
+
*/
|
|
15
|
+
interface StatementRendererContext {
|
|
16
|
+
/** The platform strategy for target-specific rendering */
|
|
17
|
+
strategy: PlatformStrategy;
|
|
18
|
+
/** Board constants for Board.definition.* access */
|
|
19
|
+
boardConstants?: BoardConstants;
|
|
20
|
+
/** Map of class simple names to fully qualified names (framework library imports) */
|
|
21
|
+
classNameMap?: Map<string, string>;
|
|
22
|
+
/** Set of enum names for scoped enum access (::) */
|
|
23
|
+
enumNames: Set<string>;
|
|
24
|
+
/** Set of string enum names (lowered to const char* namespaces; members are const char*) */
|
|
25
|
+
stringEnumNames?: Set<string>;
|
|
26
|
+
/** Set of enum names with values outside 16-bit int range */
|
|
27
|
+
largeEnumNames: Set<string>;
|
|
28
|
+
/** Map of function names to their return types */
|
|
29
|
+
knownFunctionReturnTypes: Map<string, string>;
|
|
30
|
+
/** Map of variable names to their inferred C++ types (for snprintf format specifiers) */
|
|
31
|
+
knownVariableTypes?: Map<string, KnownVariableInfo>;
|
|
32
|
+
/** Map of variable names to their pointer types */
|
|
33
|
+
pointerVarTypes?: Map<string, string>;
|
|
34
|
+
/** Module-scope (file-global) pointer variables, consulted to arrow assign/
|
|
35
|
+
* update targets (`btn.lastPress = 1` → `btn->lastPress = 1`) when the
|
|
36
|
+
* target's receiver is a global pointer (e.g. ISR-captured). Threaded from
|
|
37
|
+
* EmitterContext; replaces the file-wide text sweep formerly in
|
|
38
|
+
* output-finalizer.ts. */
|
|
39
|
+
globalPointerVarTypes?: Map<string, string>;
|
|
40
|
+
/** Set of variable names known to hold string values */
|
|
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 (::) */
|
|
45
|
+
namespaceNames?: Set<string>;
|
|
46
|
+
/** Map of variable names to their class's accessor map for getter/setter rewriting */
|
|
47
|
+
varAccessorNames?: Map<string, Map<string, "getter" | "setter" | "both">>;
|
|
48
|
+
/** Map of class type names to their accessor map (type-keyed fallback for getter/setter rewriting). */
|
|
49
|
+
typeAccessorNames?: Map<string, Map<string, "getter" | "setter" | "both">>;
|
|
50
|
+
/** Imported class names from other transpiled modules */
|
|
51
|
+
crossModuleClassNames?: Set<string>;
|
|
52
|
+
/** Shared counter for unique snprintf buffer names across statement renders */
|
|
53
|
+
snprintfCounter?: {
|
|
54
|
+
value: number;
|
|
55
|
+
};
|
|
56
|
+
/** Map of interface/type name to field C++ types */
|
|
57
|
+
interfaceFieldTypes?: Map<string, Map<string, string>>;
|
|
58
|
+
/**
|
|
59
|
+
* Shared sink for emit-time diagnostics. When provided, the renderer's
|
|
60
|
+
* fallback paths (e.g. an unregistered HAL operation) push structured
|
|
61
|
+
* warnings here instead of silently emitting placeholder comments. The
|
|
62
|
+
* array is the same one finalizeOutput merges into the final diagnostics
|
|
63
|
+
* list. Optional so ad-hoc/test constructions still work.
|
|
64
|
+
*/
|
|
65
|
+
diagnostics?: Diagnostic[];
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Renders StatementIR nodes to C++ code strings.
|
|
69
|
+
*/
|
|
70
|
+
export declare class StatementRenderer {
|
|
71
|
+
private readonly strategy;
|
|
72
|
+
private readonly expressionRenderer;
|
|
73
|
+
private readonly knownFunctionReturnTypes;
|
|
74
|
+
private readonly pointerVarTypes?;
|
|
75
|
+
private readonly globalPointerVarTypes?;
|
|
76
|
+
private readonly classNameMap?;
|
|
77
|
+
private readonly varAccessorNames;
|
|
78
|
+
private readonly crossModuleClassNames?;
|
|
79
|
+
private readonly enumNames;
|
|
80
|
+
private readonly stringEnumNames;
|
|
81
|
+
/** Namespace names — used to rewrite assign-target `Ns.x` to `Ns::x`. */
|
|
82
|
+
private readonly namespaceNames;
|
|
83
|
+
private readonly interfaceFieldTypes;
|
|
84
|
+
/** Shared emit-time diagnostics sink (see StatementRendererContext.diagnostics). */
|
|
85
|
+
private readonly _diagnostics;
|
|
86
|
+
constructor(context: StatementRendererContext);
|
|
87
|
+
/**
|
|
88
|
+
* Gets the underlying expression renderer for direct use.
|
|
89
|
+
*/
|
|
90
|
+
getExprRenderer(): ExpressionRenderer;
|
|
91
|
+
/**
|
|
92
|
+
* Renders a statement IR node to a C++ string, including any snprintf
|
|
93
|
+
* prelude lines accumulated during expression rendering.
|
|
94
|
+
*
|
|
95
|
+
* @param statement The statement to render
|
|
96
|
+
* @param forHeader Whether this is for a header file (no semicolons)
|
|
97
|
+
* @param calleeTransformer Optional transformer for callee names
|
|
98
|
+
* @param knownVariableTypes Optional override for variable type mapping
|
|
99
|
+
* @returns Object with prelude lines and the rendered statement
|
|
100
|
+
*/
|
|
101
|
+
renderWithPrelude(statement: StatementIR, forHeader?: boolean, calleeTransformer?: (callee: string) => string, knownVariableTypes?: Map<string, KnownVariableInfo>): {
|
|
102
|
+
prelude: string[];
|
|
103
|
+
statement: string;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Renders a statement IR node to a C++ string.
|
|
107
|
+
*
|
|
108
|
+
* @param statement The statement to render
|
|
109
|
+
* @param forHeader Whether this is for a header file (no semicolons)
|
|
110
|
+
* @param calleeTransformer Optional transformer for callee names
|
|
111
|
+
* @param knownVariableTypes Optional override for variable type mapping
|
|
112
|
+
* @returns The C++ code string
|
|
113
|
+
*/
|
|
114
|
+
render(statement: StatementIR, forHeader?: boolean, calleeTransformer?: (callee: string) => string, knownVariableTypes?: Map<string, KnownVariableInfo>): string;
|
|
115
|
+
/**
|
|
116
|
+
* Arrow the leading receiver of an assign/update target when it is a
|
|
117
|
+
* module-scope (file-global) pointer variable: `btn.lastPress` →
|
|
118
|
+
* `btn->lastPress`. This covers ISR-captured globals whose pointer type
|
|
119
|
+
* wasn't visible at IR build time (the target is a plain string here, not a
|
|
120
|
+
* property-access IR node). Only the leading receiver is rewritten — a
|
|
121
|
+
* chain like `btn->field.x` is left alone. Replaces the file-wide text sweep
|
|
122
|
+
* formerly in output-finalizer.ts.
|
|
123
|
+
*/
|
|
124
|
+
private arrowGlobalPointerTarget;
|
|
125
|
+
private fixCrossModuleMethodCall;
|
|
126
|
+
private renderCall;
|
|
127
|
+
private renderVarDecl;
|
|
128
|
+
/**
|
|
129
|
+
* Renders a typed name with proper C++ syntax.
|
|
130
|
+
*/
|
|
131
|
+
renderTypedName(cppType: string, name: string, isConst?: boolean, isRef?: boolean): string;
|
|
132
|
+
/**
|
|
133
|
+
* Renders function parameters.
|
|
134
|
+
* Emits `const` for parameters annotated with `Shared<T>` (ownershipKind === 'shared').
|
|
135
|
+
*/
|
|
136
|
+
renderParameters(parameters: Array<{
|
|
137
|
+
name: string;
|
|
138
|
+
cppType: string;
|
|
139
|
+
defaultValue?: any;
|
|
140
|
+
isRest?: boolean;
|
|
141
|
+
ownershipKind?: 'owned' | 'shared' | 'mutable';
|
|
142
|
+
}>, forHeader?: boolean): string;
|
|
143
|
+
/**
|
|
144
|
+
* Public type-mapping entry point for emitters that emit types directly
|
|
145
|
+
* (function return types, forward declarations) rather than via
|
|
146
|
+
* renderTypedName. Applies the same string-enum → const char* substitution.
|
|
147
|
+
*/
|
|
148
|
+
mapTypeForEmit(typeName: string): string;
|
|
149
|
+
/**
|
|
150
|
+
* Map a function's return type for emission. Unlike {@link mapTypeForEmit},
|
|
151
|
+
* this respects the strategy's {@code mapReturnType} contract: the value
|
|
152
|
+
* produced by {@code mapReturnType} is already final and must NOT be
|
|
153
|
+
* re-normalised. This matters for entrypoints like {@code main}, whose
|
|
154
|
+
* mapped {@code int} return type would otherwise be turned back into
|
|
155
|
+
* {@code long long} by {@code normalizeCppType}.
|
|
156
|
+
*
|
|
157
|
+
* For non-entrypoint functions we still apply the string-enum → const char*
|
|
158
|
+
* substitution (which {@code mapReturnType} does not perform), preserving
|
|
159
|
+
* existing behaviour for ordinary functions.
|
|
160
|
+
*/
|
|
161
|
+
mapReturnTypeForEmit(fnName: string, returnType: string): string;
|
|
162
|
+
private normalizeCppType;
|
|
163
|
+
private inferFieldType;
|
|
164
|
+
/**
|
|
165
|
+
* Transform console.log/error/warn calls based on target platform.
|
|
166
|
+
*/
|
|
167
|
+
private transformConsoleCall;
|
|
168
|
+
private renderEmitArg;
|
|
169
|
+
/**
|
|
170
|
+
* Map a function name to its platform-specific name.
|
|
171
|
+
*
|
|
172
|
+
* The entrypoint sentinel `__cuttlefish_entrypoint__` maps to the strategy's
|
|
173
|
+
* entrypoint name (`main` on native, `setup` on Arduino). For every OTHER
|
|
174
|
+
* name we delegate to `strategy.mapFunctionName`, which is where a target
|
|
175
|
+
* can rename a user function that would otherwise collide with a C++/
|
|
176
|
+
* framework reserved name — e.g. the Arduino strategy renames a user
|
|
177
|
+
* `function main()` to `cuttlefish_main`, because Arduino has no `main()`
|
|
178
|
+
* (the entrypoints are the auto-generated `setup()`/`loop()`), and a
|
|
179
|
+
* file-scope `static void main()` collides with C++'s required `int main()`
|
|
180
|
+
* signature. Routing every name through the strategy here is the single
|
|
181
|
+
* place that makes such renames actually take effect at emit time.
|
|
182
|
+
*/
|
|
183
|
+
mapFunctionName(originalName: string): string;
|
|
184
|
+
/**
|
|
185
|
+
* Map a TypeScript return type to its C++ equivalent for a specific function.
|
|
186
|
+
*/
|
|
187
|
+
mapReturnType(fnName: string, tsType: string): string;
|
|
188
|
+
}
|
|
189
|
+
export {};
|