Skip to content

feat(ast): struct definitions and member access - #73

Merged
rieske merged 7 commits into
masterfrom
feature/struct-member-access
Jul 25, 2026
Merged

feat(ast): struct definitions and member access#73
rieske merged 7 commits into
masterfrom
feature/struct-member-access

Conversation

@rieske

@rieske rieske commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • CSNB for struct definitions (named + anonymous) → type::structure
  • Tag registry for struct S references after definition
  • MemberAccess AST + FieldAddress IR for . / ->
  • Nested aggregates yield addresses (dual-type like multi-dim arrays)
  • Functional StructsTest

Stack

PR D of remaining track (after arrays/casts). Next: initializers / FP / …

Test plan

  • Full local ctest
  • CI green / coverage non-regression

Parse struct Tag { … } and anonymous structs into type::structure layout,
implement . and -> via MemberAccess + FieldAddress IR, and cover member
R/W, arrow, and nested structs with functional StructsTest.
@mergify

mergify Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@coveralls

coveralls commented Jul 24, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 93.169% (+0.2%) from 92.942% — feature/struct-member-access into master

rieske added 3 commits July 24, 2026 16:38
Exercise more FieldAddress / MemberAccess paths to avoid Coveralls
regression on the struct-member-access PR.
- Mutate incomplete structure layout via shared members so self-ref
  `struct Node *next` and forward tags observe completed fields
- ArrayAccess yields address for structure elements (`a[i].x` stores)
- Fix multi-level pointer accumulation in Identifier::getFundamentalType
- Tighten `.` vs `->` (reject `p.x` on pointers; dual-type nested still OK)
- Regression tests for self-ref, array-of-struct, double pointer arrow, and
  illegal dot-on-pointer
Incomplete struct objects and assigning nested/array dual-type aggregates
as whole values are diagnosed instead of miscompiling. Tighten -> so
dual-type nested members require dot, not arrow.
rieske added a commit that referenced this pull request Jul 25, 2026
Replay tip-quality infrastructure onto #73 so later PRs stay feature-focused:

- Expression dual-type: setTypeAndResult / setResultOnly / setAggregateAddressResult
- Drop ArrayAccess::yieldsAddress in favor of holdsAggregateAddress()
- TypeQuery + productCanAssignFrom / incompleteStructure free functions
- Split SemanticAnalysisVisitor into Calls / Expressions / Statements
- Split CSNB into ContextualSyntaxNodeBuilder + CSNB_Creators
- Shared assignSourceType / resolveMemberBase helpers
- Named r10 via getIndirectCallTargetRegister (for later indirect calls)

Brace initializers and function pointers remain out of scope for this PR.
rieske added a commit that referenced this pull request Jul 25, 2026
Replay tip-quality infrastructure onto #73 so later PRs stay feature-focused:

- Expression::ValueForm (Scalar / AggregateAddress)
- setTypeAndResult / setAggregateAddressResult; drop setResultOnly
- TypeQuery + productCanAssignFrom / productAssignFailureMessage
- Split SemanticAnalysisVisitor into Calls / Expressions / Statements
- Split CSNB into ContextualSyntaxNodeBuilder + CSNB_Creators
- Shared assignSourceType / resolveMemberBase helpers

No function-pointer or brace-initializer surface in this PR.
@rieske
rieske force-pushed the feature/struct-member-access branch 2 times, most recently from 12e5cc8 to f0976fc Compare July 25, 2026 07:31
- Expression dual ownership: expressionType/valueType/ValueForm
- TypeQuery productCanAssignFrom + arraySubscriptInfo
- symbols::AnnotationStore on AST; AddressPlan (Field/Index); CallPlan
- SA/CSNB splits; resolveMemberBase trusts ValueForm

No brace initializers or function-pointer surface.
@rieske
rieske force-pushed the feature/struct-member-access branch from f0976fc to b70a025 Compare July 25, 2026 07:54
- Remove dead FP codegen (functionAddress, indirect Call, r10 helper)
- Call is direct-only until #75
- Drop unused FunctionDesignatorPlan from AddressPlan on this PR
- Unit tests: TypeQuery + AnnotationStore
- More StructsTest paths (errors, nested, sizeof, whole assign)
rieske added a commit that referenced this pull request Jul 25, 2026
Re-introduce FunctionDesignatorPlan, indirect Call, and StackMachine
functionAddress / callProcedureIndirect on the FP tip after #73 removed
them to recover Coveralls.
rieske added a commit that referenced this pull request Jul 25, 2026
Re-introduce FunctionDesignatorPlan, indirect Call, and StackMachine
functionAddress / callProcedureIndirect on the FP tip after #73 removed
them to recover Coveralls.
- Cover CSNB unimplemented stubs + doNothing/notImplementedYet
- Expression dual-type helpers unit tests
- TypeQuery dual-subscript fallback / incomplete-member cases
- Remove dual MemberAccess offset/baseIsPointer (FieldPlan only)
- More StructsTest (const, short/unsigned not implemented)
rieske added a commit that referenced this pull request Jul 25, 2026
Re-introduce FunctionDesignatorPlan, indirect Call, and StackMachine
functionAddress / callProcedureIndirect on the FP tip after #73 removed
them to recover Coveralls.
@rieske
rieske force-pushed the feature/struct-member-access branch from 109220e to f62d65f Compare July 25, 2026 11:33
@rieske
rieske merged commit 05b917f into master Jul 25, 2026
4 checks passed
@rieske
rieske deleted the feature/struct-member-access branch July 25, 2026 11:44
rieske added a commit that referenced this pull request Jul 25, 2026
Re-introduce FunctionDesignatorPlan, indirect Call, and StackMachine
functionAddress / callProcedureIndirect on the FP tip after #73 removed
them to recover Coveralls.
rieske added a commit that referenced this pull request Jul 25, 2026
Re-introduce FunctionDesignatorPlan, indirect Call, and StackMachine
functionAddress / callProcedureIndirect on the FP tip after #73 removed
them to recover Coveralls.
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.

2 participants