Skip to content

Object system#97

Merged
mdbergmann merged 8 commits into
masterfrom
object-system
Feb 22, 2026
Merged

Object system#97
mdbergmann merged 8 commits into
masterfrom
object-system

Conversation

@mdbergmann
Copy link
Copy Markdown
Owner

No description provided.

mdbergmann and others added 8 commits February 21, 2026 13:46
Allow struct type names as SUB parameter types, e.g. `SUB Foo(MyStruct s)`,
which the compiler treats as ADDRESS internally with auto-generated struct
pointer setup. Eliminates boilerplate of manual DECLARE STRUCT + assignment.

Changes:
- acedef.h: add p_structdef[] to SYM for per-param structdef tracking
- sub.c: extend forward_ref() and sub_params() to recognize struct type
  identifiers, entering struct params as structure objects with correct
  structdef linkage for -> member access

All 221 tests pass including new test_struct_sub_param.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Replace output-comparison tests with ASSERT-based tests for
class_basic, class_sub_param, and struct_sub_param. Remove
.expected files and test_ prefix per unit test conventions.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Phase 2: CLASS type with hidden 4-byte FNV-1a type ID at offset 0,
DECLARE CLASS for instances, member access via ->.

Phase 3: METHOD compiles like SUB with deterministic labels
(_METH_<Name>_<Class>), always XDEF'd for cross-module linking.
Two-phase param parsing collects class names before emitting code.
EXIT METHOD supported via existing exit_sub_name mechanism.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
…hases 4-7)

Phase 4: GENERIC METHOD declaration with ON clauses and dispatch tables
Phase 5: _gm_dispatch runtime linking GENERIC → METHOD at call sites
Phase 6: ATOM dispatch, cross-module tests, error tests (236 tests pass)
Phase 7: CLASS EXTENDS for single inheritance with parent chain walk
  - copy_struct_members() copies parent members into child class
  - Class descriptors (_CLASSDESC_<NAME>) emitted in DATA section
  - Instance offset 0 stores descriptor pointer (not hash directly)
  - dispatch.s rewritten: CLASS path walks parent chain, ATOM path exact match
  - 239 tests pass including 3 new inheritance/dispatch tests

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Merge small tests into comprehensive ones with stronger assertions,
replacing weak `ASSERT 1 = 1` compile-only checks with runtime value
verification. Add mixed param type coverage (CLASS+STRING, CLASS+SINGLE,
CLASS+ATOM+LONGINT) and 3-level inheritance chain tests.

Consolidated:
- generic_dispatch.b absorbs generic_basic, generic_return,
  generic_single_return, generic_mixed_params
- generic_atom.b absorbs generic_class_atom
- generic_inherit.b absorbs generic_override
- method_basic.b absorbs class_sub_param

New error tests: class_dup (88), class_unknown (87),
class_extends_undef (97), generic_on_mismatch (96)

All 35 syntax + 24 error tests pass on emulator.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Comprehensive chapter covering CLASS, METHOD, GENERIC METHOD with
subsections: CLASS declaration, EXTENDS inheritance, METHOD definition
(with mixed param types), GENERIC METHOD declaration, multiple dispatch,
ATOM dispatch, inheritance and dispatch, cross-module dispatch,
performance considerations, and error messages.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Resolve conflicts in sub.c: keep CLASS+STRUCT checks (superset of
master's STRUCT-only checks). bin/ace: keep ours (includes CLASS support).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
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