Skip to content

feat(flowc): array<T,N> struct fields, c64/c128 types, new ported modules - #454

Merged
godofecht merged 11 commits into
mainfrom
work3
Aug 12, 2026
Merged

godofecht merged 11 commits into
mainfrom
work3

Conversation

@godofecht

Copy link
Copy Markdown
Contributor

Summary

  • Handle array<T,N> in struct field emission: T fieldname[N].
  • Handle array<T,N> in generic type context: emit T*.
  • Add <complex.h> and typedef c64/c128 to the C generator preamble.
  • Add forward declarations for flowc_replace_eq and flowc_dynamics_hover_direct.
  • Port know.py helpers to know.flow.
  • Port ordering_hover to lsp_ordering.flow.
  • Port wcet_analysis.py helpers to wcet.flow.
  • Port proof_kernel.py helpers to proof_kernel.flow.
  • Port dynamics_hover to lsp_dynamics.flow.
  • Add is_duplicate_claim to claim_path.flow.
  • Add mathematical_case_condition, is_geometry_expr, claim_path_latex to math_prose.flow.

Test plan

  • Self-host fixed-point passes (byte-identical)
  • Self-compile audit: all compiler/src modules pass
  • Roundtrip: all checks pass
  • Stdlib scan: OK=31 CERR=36 FAIL=0 (all 67 modules emit C)

This pull request includes code written with the assistance of AI.
The code has not yet been reviewed by a human.

Generated with Devin

godofecht and others added 11 commits August 12, 2026 11:33
Port the core duplicate detection logic from check_duplicate_claims
in Python to Flow. The Python original does batch checking with a
seen-table; the Flow port provides a single-pair check that can be
called in a loop. The batch orchestration stays in Python.

Provides:
- flowc_is_duplicate_claim: returns 1 if two claims have the same
  carrier, structure, and fingerprint but different paths, 0 otherwise

Test: tests/lang/test_check_duplicates.flow has 7 checks, all pass
under FLOW_HOST=python. Covers different claims, true duplicates,
same path, different carrier, different structure, different
fingerprint, and unparseable paths.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Port the mathematical_case_condition function from Python to Flow.
Turns parser conditions into spoken mathematics.

Provides:
- flowc_mathematical_case_condition: converts conditions like
  "x == true" to "x holds", "x == false" to "x does not hold",
  "count == 0" to "count is zero", and falls back to replacing
  "==" with " equals " for other cases. Case-insensitive matching
  for true/false, matching the Python re.I behavior.

Test: tests/lang/test_math_case_condition.flow has 9 checks, all
pass under FLOW_HOST=python. Covers true, false, zero, generic
equality, leading/trailing whitespace, spaces around ==, and
case-insensitive TRUE.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Port the is_geometry_expr function from Python to Flow. Checks
whether an expression contains geometry tokens or prefixes.

Provides:
- flowc_is_geometry_expr: returns 1 if the expression contains
  geometry prefixes (angle_, two_right_angles, one_right_angle,
  half_of_, radius_, triangle_) or exact tokens (triangle_ABC,
  triangle_DEF, angle_alpha, angle_beta, angle_gamma, etc.) with
  proper word boundary checking

Test: tests/lang/test_is_geometry_expr.flow has 11 checks, all
pass under FLOW_HOST=python. Covers all prefix types, exact tokens,
negative cases, and word boundary checking.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Port the claim_path_latex function from Python to Flow. Converts
a claim path to LaTeX for PDF rendering.

Provides:
- flowc_claim_path_latex: parses the path as a claim address and
  returns the coordinate LaTeX, or escapes underscores in the raw
  path if it cannot be parsed

Test: tests/lang/test_claim_path_latex.flow has 5 checks, all pass
under FLOW_HOST=python. Covers valid claim paths, underscore
escaping, plain paths, empty strings, and single underscore.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Port the query normalization and module qualification helpers from
know.py to Flow. The Python original does filesystem scanning and
claim indexing; the Flow port exposes the pure string helpers.

Provides:
- flowc_normalize_query: strip "verify.", "examples.verify.", or
  "lib.verify." prefixes and trim whitespace
- flowc_package_prefix: extract package prefix from a module path,
  dropping segments that contain "/" (Claim Path artifacts)
- flowc_qualify: qualify a claim path with a module prefix

Test: tests/lang/test_know.flow has 12 checks, all pass under
FLOW_HOST=python. Covers all three prefix strippings, whitespace
trimming, no-prefix passthrough, slash segment dropping, empty
module, and qualification with cleaned prefixes.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Port the ordering_hover function from lsp_ordering.py to Flow.
Returns hover documentation for ordering keywords.

Provides:
- flowc_ordering_hover: returns hover text for sort, sortBy, asc,
  desc, unique, entropy, and order keywords. Returns empty string
  for unknown keywords.

The Python original uses em dashes in the hover text; the Flow port
uses hyphens to stay within ASCII. Completion items with snippet
interpolation stay in Python.

Test: tests/lang/test_lsp_ordering.flow has 9 checks, all pass
under FLOW_HOST=python. Covers all seven known keywords and the
unknown keyword case.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Port the type size lookup and statement cost model from
wcet_analysis.py to Flow. The Python original parses the AST and
collects function info; the Flow port exposes the pure lookups.

Provides:
- flowc_type_size: estimate the size of a Flow type in bytes.
  Covers all primitive types (i8 through i128, f32/f64, c64/c128,
  bool, ptr, string) and defaults to 16 for unknown structs.
  Pointer prefixes (ptr_, Ptr_) return 8.
- flowc_stmt_cost: abstract instruction count for statement kinds
  (assignment=2, if=3, for/while=5, return=2, call=10, declare=1,
  default=1)
- FLOWC_DEFAULT_LOOP_BOUND: conservative default of 1000

Test: tests/lang/test_wcet.flow has 21 checks, all pass under
FLOW_HOST=python. Covers all primitive type sizes, pointer prefixes,
struct default, all statement cost kinds, default cost, and the
loop bound constant.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Port the node kind classification and DOT escaping helpers from
proof_kernel.py to Flow. The Python original builds full proof
kernels and writes JSON/plots; the Flow port exposes the pure
helpers.

Provides:
- flowc_node_kind: classify a proof step's English text into a
  kernel node kind (conclude, deduce, case, invoke, bind, frame,
  step). Case-insensitive matching.
- flowc_escape_dot: escape backslashes and double quotes for DOT
  graph format

Test: tests/lang/test_proof_kernel.flow has 17 checks, all pass
under FLOW_HOST=python. Covers all node kinds (conclude, deduce,
case, invoke, bind, frame, step), case insensitivity, and DOT
escaping (backslash, quotes, plain text, empty).

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Port the dynamics_hover function from lsp_dynamics.py to Flow.
Returns hover documentation for dynamics DSL keywords, with
namespaced form support (dyn.dsys resolves to dsys).

Provides:
- flowc_dynamics_hover: returns hover text for 18 dynamics DSL
  keywords (dsys, horizon, sense, ga, closed, analyze, wfc,
  dynamics, dyn, controllable, spectral, gramian, stable, energy,
  population, generations, mutation, discrete, continuous).
  Handles namespaced forms by checking the last segment after ".".
  Returns empty string for unknown keywords.

The Python original uses em dashes; the Flow port uses hyphens.
Completion items stay in Python.

Test: tests/lang/test_lsp_dynamics.flow has 11 checks, all pass
under FLOW_HOST=python. Covers direct lookups, namespaced
resolution (dyn.dsys, dynamics.horizon), and unknown keywords.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Compiler improvement from self-hosted rebuild:
- cgen: handle array<T,N> in struct fields, emitting T fieldname[N]
  instead of a bare pointer. Also handle array<T,N> in generic type
  contexts as T*.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
compiler/src/cgen.flow:
- Handle array<T,N> in struct field emission: T fieldname[N].
- Handle array<T,N> in generic type context: emit T* (struct fields
  and top-level lets handle the [N] suffix separately).
- Add <complex.h> and typedef c64/c128 to the preamble.

compiler/src/math_prose.flow:
- Add forward declaration for flowc_replace_eq.

compiler/src/lsp_dynamics.flow:
- Add forward declaration for flowc_dynamics_hover_direct.

Fixes 6 modules with "unknown type name 'array'" and 1 with "unknown
type name 'c64'" in the stdlib scan.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@cursor

cursor Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@godofecht
godofecht merged commit 8e34fda into main Aug 12, 2026
14 of 17 checks passed
@godofecht
godofecht deleted the work3 branch August 12, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant