9 Commits
Author SHA1 Message Date
Irmen de Jong f7529dbd2a Fix direct struct instance array fields on IR backends; drop debug prints 2026-11-22 16:57:06 +01:00
Irmen de Jong c9f874c557 Performance: absolute addressing for struct instance fields on classic 6502 codegen
Classic (old) 6502 codegen now uses absolute addressing (lda/sta/inc/dec addr)
instead of building a zero-page pointer for direct single struct instances and
memory-mapped instances. Covers byte/word/float reads, writes, and byte inc/dec.
2026-11-22 16:36:22 +01:00
Irmen de Jong 5dcf746d98 Fix struct instance access on IR/new6502 backends and namespaced struct types 2026-11-22 16:21:48 +01:00
Irmen de Jong 48a826db0a fix swap() on struct instances 2026-11-21 14:04:20 +01:00
Irmen de Jong 32f82e9e16 fix subroutine-local struct types 2026-11-21 13:48:11 +01:00
Irmen de Jong e92a79c887 Add memory-mapped single struct instances 2026-11-21 12:29:32 +01:00
Irmen de Jong 6842239900 Support typed address-of struct instances in static initializer data
Taking the address of a direct struct instance in static initializer data
(pointer arrays and pointer-typed struct fields) worked on 6502 only. The
typed `&&` operator already provides the needed type, but the IR path broke
on targets without symbol prefixes:

- The virtual target skips symbol prefixing, so address-of symbols kept
  their plain scoped names (`main.p1`) while the struct instance storage is
  registered as `prog8_struct_instances.main_p1`. IRUnusedCodeRemover then
  crashed with "no chunk with label 'main.p1'" (only when optimizing).
  StConvert now resolves both the plain scoped form and the p8i_->p8v_
  prefixed form used on 6502 and m68k targets.

- Both symbol prefixers rebuilt PtAddressOf nodes for static initializer
  elements without their typed/msb flags; the flags are now preserved.
2026-11-20 00:52:52 +01:00
Irmen de Jong c1afe48564 Add real struct instance variables on 6502 targets
Allow `Point p` declarations with direct field access, initialization and
whole-struct copy on the 6502-based targets as well. Remove the checker
rejection and the corresponding doc/table restrictions.

Direct instances are emitted in a prog8_struct_instances block (or its
_bss variant when uninitialized or a union); references get a consistent
label via the new structInstanceLabel mapping, which rewrites the 'v'
declaration prefix to the 'i' reference prefix of the symbol prefixer.
Pointer-deref chains load the instance's storage address as the start
pointer, so field reads, writes and address-of work as expected.
2026-11-19 19:13:37 +01:00
Irmen de Jong e954d8b705 Add real struct instance variables on IR/m68k and virtual targets
Allow `Point p` declarations with direct field access, initialization and
whole-struct copy (`q = p` lowers to sys.memcopy) on 32-bit and virtual
targets. 6502 targets reject with a clear error and keep using pointers or
arrays of struct instances.

Direct variables are represented as StStructInstance nodes with static
storage; field access resolves via PtrDereference and address-of/field
addresses use the struct-instances symbol labels. Adds array-literal-to-
struct-initializer lowering and avoids false frame-address-escape warnings.
2026-11-19 00:32:50 +01:00