selfhost/cmd/wcc/check: populate tinfo.fields + .tupleelems (#57, A.6.3i-phase-1)
Phase 1 of A.6.3i: populate the field chain in tinfofornode's TSTRUCT
and TTUPLE arms so Phase 2/J/K (#58/#59/#60) can retire dotfieldtnode,
dotinnerstructptr, dotchainresolve, and indexbaseesz off their AST-keyed
structinfo walk and onto a tinfo read. Direct analog 26724fe (#50 phase
1, A.6.3f-a) for the head/tail append-list pattern.
TSTRUCT walks n.list's N_TFIELD chain in lockstep with the existing
natural-layout offset accumulator: alloc tfield {name, type_, offset,
tnext}, link head/tail, set r.fields after the loop. Mirrors cstage
cmd/wcc/check.c:468-527. Harec cite: ref/harec/include/types.h:109-115
struct_field and ref/harec/src/type_store.c:314-347 struct_init_from_atype.
Anonymous-embed promotion not populated here (#13 per the cstage cite
at check.ww:1263).
TTUPLE adds a new ttupleelem struct {type_, offset, tnext} on a new
tinfo.tupleelems slot, distinct from .fields per Rob's call: harec
splits struct_field vs type_tuple at types.h:109-115 vs :122-126
because tuples are positional/anonymous and struct members are named,
and the name="" idiom #50 reused for tagged-variants-on-tparam would
conflate two semantic axes. Diverges from cstage cmd/wcc/check.c:329-345
which stores tuple positionals on t->params (Tparam, no offset, consumer
recomputes by walking at cgen.c:5723-5750); storing the offset matches
the A.6 stamp-once-read-many arc Phase 2/J/K consume. Offset is raw-sum
(no per-element padding) matching cstage cgen.c:5723-5750, distinct
from harec's add_padding at type_store.c:561.
Purely additive: r.fields and r.tupleelems have zero readers today.
Phase 2/J/K consume. make test 133/133 (worker port); test-unit 124/124
post comment-only review trim.
This commit is contained in:
@@ -74,6 +74,19 @@ type tparam = struct {
|
||||
tnext: *tparam,
|
||||
};
|
||||
|
||||
// #57 A.6.3i-phase-1: tuple positional element. Distinct from tfield
|
||||
// (named, struct member) per harec's split at ref/harec/include/types.h
|
||||
// :109-115 (struct_field) vs :122-126 (type_tuple) — tuple positionals
|
||||
// carry no name (positional only) and a separate next-link. Rule-12
|
||||
// sea-of-stars mirrors Hare's structural choice; the empty-name idiom
|
||||
// from #50's TTAGGED-on-tparam would conflate two semantic axes
|
||||
// (variants can be named; positionals never can).
|
||||
type ttupleelem = struct {
|
||||
type_: *tinfo,
|
||||
offset: u64,
|
||||
tnext: *ttupleelem,
|
||||
};
|
||||
|
||||
type tinfo = struct {
|
||||
kind: tykind,
|
||||
size: u64,
|
||||
@@ -82,6 +95,11 @@ type tinfo = struct {
|
||||
alen: u64,
|
||||
fields: *tfield,
|
||||
params: *tparam,
|
||||
tupleelems: *ttupleelem, // #57 A.6.3i-phase-1: TY_TUPLE
|
||||
// positional chain (harec types.h:122-126
|
||||
// `struct type_tuple`). Distinct slot from
|
||||
// .fields so struct-member vs tuple-
|
||||
// positional stay axis-separated.
|
||||
ret: *tinfo,
|
||||
variadic: i32,
|
||||
nullable: i32, // #61 A.3: TY_TAGGED `(*T | void)` fold collapses to
|
||||
@@ -148,7 +166,7 @@ type tctx = struct {
|
||||
// ---- constructors -----------------------------------------------------
|
||||
|
||||
export fn newtype(k: tykind) *tinfo = {
|
||||
let t: *tinfo = alloc(tinfo{kind=k, size=0u64, align=0u64, sub=nil, alen=0u64, fields=nil, params=nil, ret=nil, variadic=0, nullable=0, name="", under=nil, slotsize=0u64})!;
|
||||
let t: *tinfo = alloc(tinfo{kind=k, size=0u64, align=0u64, sub=nil, alen=0u64, fields=nil, params=nil, tupleelems=nil, ret=nil, variadic=0, nullable=0, name="", under=nil, slotsize=0u64})!;
|
||||
return t;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user