summaryrefslogtreecommitdiff
path: root/chapter14/src/main
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-10-03 14:03:48 -0700
committerCliff Click <cliffc@acm.org>2026-10-03 14:03:48 -0700
commit22df891893d30e9906d0b14fc3ae5d8e67d500b2 (patch)
tree2bda142f92febc8b26f1cabd4bb0c46d1864f34b /chapter14/src/main
parentc3958e34c0de21df52e57e47e4f47ffe6464f138 (diff)
downloadSimple-22df891893d30e9906d0b14fc3ae5d8e67d500b2.tar.gz
Simple-22df891893d30e9906d0b14fc3ae5d8e67d500b2.zip
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
Diffstat (limited to 'chapter14/src/main')
-rw-r--r--chapter14/src/main/java/com/seaofnodes/simple/type/TypeStruct.java14
1 files changed, 6 insertions, 8 deletions
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;