From a4994371c0b0fbea9d2802acc22d9cc3977a0de0 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Sun, 4 Oct 2026 13:30:41 -0700 Subject: Slides for 2026 REBASE --- docs/2026_REBASE/tools/BackendDump.java | 45 +++++++++++++++++++++++ docs/2026_REBASE/tools/RichLattice.java | 59 ++++++++++++++++++++++++++++++ docs/2026_REBASE/tools/snapshot-library.py | 16 ++++++++ 3 files changed, 120 insertions(+) create mode 100644 docs/2026_REBASE/tools/BackendDump.java create mode 100644 docs/2026_REBASE/tools/RichLattice.java create mode 100644 docs/2026_REBASE/tools/snapshot-library.py (limited to 'docs/2026_REBASE/tools') diff --git a/docs/2026_REBASE/tools/BackendDump.java b/docs/2026_REBASE/tools/BackendDump.java new file mode 100644 index 00000000..faac89a4 --- /dev/null +++ b/docs/2026_REBASE/tools/BackendDump.java @@ -0,0 +1,45 @@ +import com.seaofnodes.simple.codegen.CodeGen; +import com.seaofnodes.simple.node.*; +import java.nio.file.*; +import java.util.regex.Pattern; + +/** Run from the repo root with Chapter 21's built classes on the classpath. */ +public class BackendDump { + static String js(String s) { + return "\""+s.replace("\\","\\\\").replace("\"","\\\"") + .replace("\r", "").replace("\n","\\n")+"\""; + } + public static void main(String[] args) throws Exception { + Path deck=Path.of("docs/2026_REBASE"); + String source=Files.readString(deck.resolve("demos/backend.smp")); + CodeGen code=new CodeGen(source).parse().opto().typeCheck().loopTree() + .instSelect("x86_64_v2","SystemV"); + String selected=code.toString(); + // Every row from the whole graph, in printer order. Show concrete Java + // classes and every input slot; omit types and redundant use lists. + StringBuilder compact=new StringBuilder("id node inputs\n"); + var rows=Pattern.compile("(?m)^\\s*(\\d+) ").matcher(selected); + int count=0; + while(rows.find()) { + Node n=code.f(Integer.parseInt(rows.group(1))); + String name=n.getClass().getSimpleName(); + if(n instanceof ParmNode || n instanceof CProjNode) name+=":"+n.label(); + compact.append(String.format("%2d %-16s",n._nid,name)); + for(int i=0;i "#d3e7f5"; + case "TypeFloat" -> "#c7eee9"; + case "TypePtr", "TypeMemPtr" -> "#cce4d6"; + case "TypeFunPtr" -> "#dfd0ef"; + case "TypeMem" -> "#a9c9e5"; + case "TypeStruct", "Field" -> "#e0ebc8"; + case "TypeTuple" -> "#f2d7e4"; + case "TypeRPC" -> "#f4d4b5"; + default -> name.startsWith("TypeConAry") ? "#d9d5cc" : "#faedce"; + }; + } + public static void main(String[] args) throws Exception { + var types=new ArrayList<>(new LinkedHashSet<>(Arrays.asList(Type.gather()))); + int size=types.size(); + boolean[][] above=new boolean[size][size]; + for(int i=0;i n").append(j).append(";\n");edges++;} + } + dot.append("}\n"); + Files.writeString(Path.of("docs/2026_REBASE/assets/rich-lattice.gv"),dot); + System.out.println(size+" representative types; "+edges+" order edges (transitively reduced)."); + } +} diff --git a/docs/2026_REBASE/tools/snapshot-library.py b/docs/2026_REBASE/tools/snapshot-library.py new file mode 100644 index 00000000..dee09d2f --- /dev/null +++ b/docs/2026_REBASE/tools/snapshot-library.py @@ -0,0 +1,16 @@ +"""Bundle the current Chapter 25 stdlib and methods example for offline browsing.""" +from pathlib import Path +import json + +deck = Path(__file__).resolve().parents[1] +repo = deck.parents[1] +source = repo / "chapter25/src/main/smp" +paths = [source / "sys.smp", *sorted((source / "sys").rglob("*.smp"))] +files = {path.relative_to(source).as_posix(): path.read_text(encoding="utf-8") for path in paths} +bundle = {"origin": "chapter25/src/main/smp", "files": files, + "methods": (deck / "demos/methods.smp").read_text(encoding="utf-8")} +(deck / "stdlib.js").write_text( + "/* Generated by tools/snapshot-library.py; local source snapshot. */\n" + "window.REBASE.library = " + json.dumps(bundle, ensure_ascii=False, indent=2) + ";\n", + encoding="utf-8", newline="\n") +print(f"Bundled {len(files)} standard-library files and the methods example.") -- cgit v1.2.3