Skip to content

Struct enhancements#81

Merged
mdbergmann merged 9 commits into
masterfrom
struct-enhancements
Feb 16, 2026
Merged

Struct enhancements#81
mdbergmann merged 9 commits into
masterfrom
struct-enhancements

Conversation

@mdbergmann
Copy link
Copy Markdown
Owner

No description provided.

mdbergmann and others added 9 commits February 15, 2026 19:45
Extend the SIZE keyword from STRING-only to all base types in struct
definitions. Array members push their address (like STRING) and reject
scalar assignment. Includes spec, state file, and test.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add STRUCM.structdef pointer to link struct members to their type
definition, enabling chained -> resolution for nested structs.
Supports arbitrary nesting depth (a->b->c->field) by accumulating
offsets at compile time. Updated push_struct (read), assign_to_struct
(write), and address_of_object (@addr) to handle embedded structs.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Phase 3: Add structptrtype for typed pointer members (Inner *ptr).
Enables -> chaining through pointer members in push_struct,
assign_to_struct, and VARPTR. BSS emits ds.l 1 for pointer slot.

Phase 4: Allow self-referential struct pointers (Node *nxt) by
relaxing the self-reference check in define_structure(). Embedded
self-references (infinite size) are still rejected.

Full test suite passes (123 tests across all categories).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Support Inner items SIZE n syntax for arrays of embedded structs
inside struct definitions. Indexed access via c->items(i)->field
with runtime index expressions, constant and variable indices.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Allow s->arr(i) syntax for BYTE/SHORTINT/LONGINT/SINGLE SIZE n
members, matching the existing struct array indexing pattern.
Previously these required manual PEEK/POKE with pointer arithmetic.

Three helper functions extracted to reduce duplication:
- gen_typed_array_addr(): index computation (misc.c, calls parser)
- gen_push_value_a0(): push value at (a0) by type (codegen.c)
- gen_store_value_a0(): pop and store value by type (codegen.c)

Supported in all struct access contexts: direct, embedded struct
chains, struct pointer chains, and inside struct array elements.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Document typed arrays (SIZE for all types), indexed access s->member(i),
chained -> for embedded structs, typed struct pointers, self-referential
structs, and struct arrays as members in ref.txt, ace.txt, quickref.txt,
and CubicIDE quickinfo.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
#80)

Use Phase 5 struct array members (HttpHeader SIZE 16/32) instead of
STRING SIZE 5120/10240 with manual pointer arithmetic. Remove 7
helper functions (_HdrSetSlot, _HdrGetName, etc.) and rewrite 9
callers to use typed struct array indexing. Also change TcpConn
_bufData from STRING to BYTE (Phase 1 feature). Binary layout
unchanged.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@mdbergmann mdbergmann merged commit 16dfa1f into master Feb 16, 2026
@mdbergmann mdbergmann mentioned this pull request Feb 16, 2026
@mdbergmann mdbergmann deleted the struct-enhancements branch February 19, 2026 19:55
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