From 22df891893d30e9906d0b14fc3ae5d8e67d500b2 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Sat, 3 Oct 2026 14:03:48 -0700 Subject: Chapter renumber, and split ch 17 Renumber chapters 10a, 10b, 11, 12, 13, 14 -> 10, 11, 13, 12, [11,14]. Split ch 17 into a 17a and 17b; shuffle around im/mutable syntax to be consistent, and present it more slowly. THe new immutable syntax is pushed through all later chapters --- .../main/java/com/seaofnodes/simple/type/TypeStruct.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'chapter14/src/main/java') diff --git a/chapter14/src/main/java/com/seaofnodes/simple/type/TypeStruct.java b/chapter14/src/main/java/com/seaofnodes/simple/type/TypeStruct.java index 2599a383..8ad59a39 100644 --- a/chapter14/src/main/java/com/seaofnodes/simple/type/TypeStruct.java +++ b/chapter14/src/main/java/com/seaofnodes/simple/type/TypeStruct.java @@ -8,14 +8,12 @@ import java.util.ArrayList; */ public class TypeStruct extends Type { - // A Struct has a name and a set of fields; the fields themselves have - // names and types. Briefly during parsing its allowed to have a - // forward-ref to a Struct; in this case the _fields array is null. - // Its illegal to attempt to load a field from a forward-ref struct. - // - // During the normal optimization run, struct types "bottom out" at further - // struct references, so we don't have to handle e.g. cyclic types. The - // "bottom out" is again the forward-ref struct. + // Immutable shallow references, resolved by name in Parser.TYPES when needed. + // A name-only struct has _fields == null, even after its definition is known. + // For LLI { LLI? next; int i; }, L0 is name-only and L1.next points to L0; + // TYPES["LLI"] holds L1. We deliberately stop recursive type expansion here, + // keeping interning and lattice operations finite and acyclic. Never patch + // L0 into L1: field access looks up the complete declaration by name instead. public final String _name; public final Field[] _fields; -- cgit v1.2.3