/* Presentation-sized views of the chapter lattices. Lines run down the order.
* Focused views deliberately omit other domains; see README.md for sources.
*/
(function () {
const R=window.REBASE, esc=R.escape;
const text=(x,y,s,cls='')=>'
'+body+'
'+subtitle+'
⊤ above ⊥ · lines show lattice order · meet moves downward to the greatest lower bound
arg : ⊥:int3 : 3'),
point('Meet combines alternatives.','1 ∧ 1 = 11 ∧ 2 = ⊥:int'),
point('Every node computes a type.','A constant result can replace the node. Tuples meet element by element.')
],'Other integer constants and tuple interiors are omitted.'),
notes:'These are abstract values, not the Java class hierarchy. Show global top/bottom versus domain top/bottom. Chapter 4 has one control element, flat integer constants, and tuples. AddNode.compute evaluates constant operands; meet is the operation for combining alternatives, not integer addition. Return to Example for the local rewrites.
'}, control:{id:'lattice',label:'Lattice',steps:0, body:()=>page('Reachability is a type, too.','Chapter 8 · the Chapter 6 control lattice carries through loops',early(true),[ point('Control gains a dual.','⊤:ctrl = unreachable⊥:ctrl = reachable'),
point('A Phi meets live inputs.','Phi(1, 2) : ⊥:intOnly the control branch changed from the preceding diagram. Region computes reachability; Region removes dead predecessors and their Phi inputs; Phi meets the remaining value types. A loop introduces a cycle in the graph, not another type domain. Optimistic solving comes later, in Chapter 24.
'}, domains:{id:'domains',label:'Domains',steps:0, body:()=>page('Memory joins the type lattice.','Chapter 11 · six domains under the same global bounds',domains(),[ point('Memory has alias slices.','MEM#2 ∧ MEM#3 = ⊥:memThis is specifically Chapter 11: control, integers, pointers, structs, memory, and tuples. The boxes with ellipses abbreviate each domain, not extra lattice elements. Memory slices in 11 are flat aliases; typed contents arrive in Chapter 15. Distinguish the TypeMem meet from the MemMerge dependency node we just inspected.
'}, contents:{id:'contents',label:'Memory types',steps:0, body:()=>page('Memory carries facts about contents.','Chapters 15–17b · one alias, with integer ranges from Chapter 14',contents(),[ point('Fix the alias; vary its contents.','MEM#2 : TMEM#2:0 ∧ MEM#2:1= MEM#2:[0,1]'),
point('Types and dependencies cooperate.','The type bounds values in a slice. Memory edges and pointer identity determine which Store a Load can see.')
],'Selected elements for alias #2 only; other aliases and memory bounds omitted.'),
notes:'Chapter 15 adds TypeMem contents, using the integer ranges introduced in Chapter 14. This is a fixed-alias, integer-contents slice of the larger lattice. The top and bottom pictured belong to those integer contents, not global memory top and bottom. The contents type summarizes allocated objects in that alias; it does not name the object selected by p.x. Return to Examples and connect this to the independent p.y Store.
'}, ranges:{id:'ranges',label:'Ranges',steps:0, body:()=>page('Refine the integer domain.','Chapter 14 · constants become singleton ranges',ranges(),[ point('Meet takes the bounding interval.','0 ∧ 1 = [0,1][a,b] ∧ [c,d]= [min(a,c), max(b,d)]'),
point('Dual swaps the endpoints.','dual([0,1]) = [1,0]Show the 0/1 diamond, with [0,1] below and its dual [1,0] above. The high side is an algebraic dual, not a second collection of runtime intervals. These selected elements omit other ranges and the float domain. Keep this quick: it supplies the picture needed again at SCCP.
'}, functions:{id:'lattice',label:'Lattice',steps:0, body:()=>page('A function value has a target set.','Chapter 18 · hold signature, result type, and nullability fixed',functions(),[ point('Merge alternatives by union.','{add1} ∧ {twice}= {add1, twice}'),
point('A singleton identifies the callee.','One known target makes direct linking possible. Trivial inlining also checks usage and recursion.'),
point('The full type has more components.','Argument tuple, return type, nullability, and target bits all participate. Only the target-set projection is drawn.')
],'Restricted to two possible targets. The empty set is top in this projection.'),
notes:'TypeFunPtr meets target bits with bitwise OR. For this drawing fix the other components, including an int return type, and restrict the universe to the two named functions. This is not the complete function-pointer lattice or a diagram of function subtyping. The concrete demo calls each singleton directly; it does not form the two-target union. Connect singleton information to the additional single-use and non-recursion checks for inlining.
'}, rich:{id:'rich',label:'Rich lattice',steps:0, body:()=>'Control · integer ranges · floats · nullability · pointers · function targets · memory · structs · tuples · return addresses · constant arrays
It’s just a lattice.So the fixed-point theory works.
It’s a rich lattice.So we get rich results.
Chapter 24’s actual type ordering · representative elements across every family · click for full size
Pull back from the little integer diamond to the full range of type families. This diagram is generated from Chapter 24 Type.gather(), including duals, and the actual isa/meet ordering: 143 representative types, 256 transitively reduced order edges. It samples each family; it does not enumerate every interval, function target set, or recursive aggregate. An edge can span elements outside the sample. Repeated compact labels can hide differing type components; opening the SVG gives full-type tooltips.
The two messages are: it is just a lattice, so the monotone fixed-point framework applies; it is a rich lattice, so the result contains far more than integer constants. Reachability, ranges, nullability, memory contents, and callable targets all participate. The usual monotonicity and convergence conditions still matter. The arrows here are lattice order, not IR dependencies.
'}, sccp:{id:'lattice',label:'Lattice',steps:0, body:()=>page('Solve the cycle from the high side.','Chapter 24 · the integer lattice is already available',ranges(true),[ point('Seed unknown results at top.','Phi(1, ⊤:int) = 1'),
point('The backedge confirms it.','2 − 1 = 1Phi(1, 1) = 1'),
point('Propagate to a fixed point.','Types descend as reachable information arrives. Control types decide which predecessors contribute.')
],'Orange shows an analysis update; gray lines show the selected lattice order.'),
notes:'Reuse the range picture, now showing the descent from integer top to 1. The loop Phi and subtraction both settle at 1. Global top may be used to initialize an untyped result; the picture projects onto the integer domain. Contrast with seeding at integer bottom, which cannot discover this invariant. Lattice order and the direction of solving are distinct from the graph viewer’s use-to-definition arrows.
'} }; const attach=(id,items)=>{R.slides.find(s=>s.id===id).views=items.map(key=>views[key]);}; attach('arithmetic',['early']); attach('control',['control']); attach('memory',['domains','contents','ranges']); attach('inline',['functions']); attach('sccp',['rich']); })();