wcc: array static-init let/def DATA emit via SSoT helper (#129 A.3)
Extract emit_array_data + emit_array_lit_bytes helpers (both stages, mirrored) for module-level let/def with N_ARRLIT initializer or no-rhs zero-init. Two-pass validate-then-emit: validate pass walks elements and fails atomically on any non-foldable element (no partial-byte emit on failure); emit pass writes element bytes after success. Element-kind dispatch: integer via fold_int_literal byte-for-byte preserved from pre-A.3 inline arm (bootstrap NEUTRAL — 6 live consumers in lib/os/bufio/strings/encoding-utf8/strconv-stof_data), float via inline bitcast + sign-XOR byte-loop (A.1 shape, no INT64_MIN — sibling #144), struct via recursion into emit_struct_lit_bytes (A.2 helper). Out-of-scope element kinds (ptr-elem, nested-array) rule-7 fatal. emit_struct_lit_bytes gains TY_ARRAY field arm calling emit_array_lit_ bytes recursively — closes A.2 parked shape-15 (array-in-struct `def D: dt = dt{tag=42, buf=[1u8,2u8,3u8,4u8]};`). LOAD-side widened symmetric to A.2 precedent: cstage cgindex N_INDEX direct-ident isglobal gate widened via new DefArray registry (def_isarraydef populated in let_collect parallel to DefStruct); wwstage cgindex N_INDEX falls through to defvartnode on letvartnode nil (reads defent.dtnode field added in A.2). Both stages materialise array-def via LEAQ name(SB) same as array-let. Mid-impl rule-7 stop: refactor initially routed only rhs==N_ARRLIT through emitarraydata, leaving nil-rhs zero-init arrays (e.g. `let f64tos_buf: [64]u8;` in lib/strconv) silently SKIPPED → undef-ref at link of wwstage-rebuilt selfhost binaries. Caught on first gate run via bootstrap 994/995 RED. Fixed by adding nil-rhs branch to emitarraydata (zero-fills arrt.size bytes) + widening wwstage caller to route both N_ARRLIT and nil through helper. Same-class-lower-stratum pattern (recurring across A.1 N_UN-peel, A.2 sz==8-short-circuit, A.3 nil-rhs-drop); banked as feedback memory. Test 919 (11 rows: int-elem 1B/4B/8B + signed-N_UN-peel + float-elem f64/f32 + def-int / def-float / struct-with-array-field shape-15 + explicit-zero + single-elem-regression) registered. Make test: 182/182 incl. 990-997 byte-id + combined_ww_fresh. Followups filed: - #43 — wwstage emitletdataw str/slice-size arms lack !isarr guards; hypothetical no-rhs [16/24]u8 triple-emits (NOT A.3-introduced; no live consumer; 2-line parity fix)
This commit is contained in:
6
Makefile
6
Makefile
@@ -341,6 +341,7 @@ TESTS = $(BIN)/test_smoke $(BIN)/test_lex $(BIN)/test_parse $(BIN)/test_check \
|
||||
$(BIN)/test_arr_float_call_index_run \
|
||||
$(BIN)/test_def_float_lit_run \
|
||||
$(BIN)/test_struct_composite_init_run \
|
||||
$(BIN)/test_array_static_init_run \
|
||||
$(BIN)/test_f64cgen_run \
|
||||
$(BIN)/test_f64crossmod_run \
|
||||
$(BIN)/test_tuprecv_run \
|
||||
@@ -1159,6 +1160,11 @@ $(BIN)/test_struct_composite_init_run: test/wcc/918_struct_composite_init_run.c
|
||||
$(LIB)/libwwrt.a | $(BIN)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
$(BIN)/test_array_static_init_run: test/wcc/919_array_static_init_run.c \
|
||||
$(BIN)/ww $(BIN)/w6c $(BIN)/w6c_ww $(BIN)/w6a $(BIN)/w6l \
|
||||
$(LIB)/libwwrt.a | $(BIN)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
$(BIN)/test_f64cgen_run: test/wcc/951_f64cgen_run.c $(BIN)/ww $(BIN)/w6c \
|
||||
$(BIN)/w6a $(BIN)/w6l $(LIB)/libwwrt.a | $(BIN)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
Reference in New Issue
Block a user