blaise/tools
Graeme Geldenhuys 519aefdc5c fix(codegen): virtual-dispatch property accessors through the vtable
A property whose getter or setter is declared `virtual` did not dispatch
through the vtable: reading or writing the property through a base-typed
variable holding a derived instance called the BASE accessor, not the
override. A direct b.GetVal() call dispatched correctly, but b.Val (the
property over the same virtual getter) did not.

    TBase = class
      function GetVal: Integer; virtual; begin Result := 1; end;
      property Val: Integer read GetVal;
    end;
    TDerived = class(TBase)
      function GetVal: Integer; override; begin Result := 99; end;
    end;
    b: TBase := TDerived.Create;
    WriteLn(b.Val);   // was 1, now 99

The property read/write lowering always emitted a static call to the
accessor's declaring class. Now the semantic pass records the accessor's
vtable slot on the AST node (PropAccessorVSlot, -1 when the accessor is
not virtual), and codegen dispatches through the vtable when the slot is
>= 0, exactly as a direct method call does.

QBE: PropAccessorTarget computes the call target — emitting the vptr+slot
loads and returning the function-pointer temp for a virtual accessor, or
the static mangled symbol otherwise — and each call site emits its own
`call <target>(...)`. (A single emit-and-return helper was tried first
but tripped a latent native-backend miscompile on the self-compile; see
bugs.txt. The target-string shape avoids it.) Native:
EmitPropAccessorCallNative dispatches through the vtable or statically.

Covers getter and setter, on both backends. Adds
TE2EInheritTests.TestRun_VirtualProperty{Getter,Setter}_Dispatches
(dual-backend). The two new AST fields are marked `safe` in
bif-coverage.status (semantic-set, not serialised).
2026-06-16 12:59:46 +01:00
..
bif-coverage fix(codegen): virtual-dispatch property accessors through the vtable 2026-06-16 12:59:46 +01:00
kanban fix(kanban): add missing () on SystemOffset call in kanban.data.pas 2026-06-06 21:30:07 +01:00
migration-analyser fix: we don't have any code for migration-analyser yet. Disable tests for it. 2026-05-08 00:52:44 +01:00
.gitkeep Initial project scaffold 2026-04-20 14:22:10 +01:00