summaryrefslogtreecommitdiff
path: root/chapter13/README.md
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2024-08-05 11:46:17 -0700
committerDibyendu Majumdar <dibyendumajumdar@users.noreply.github.com>2024-08-06 00:50:58 +0100
commit0fb76e75be3a35d6b4741e9ae4378fa04868a840 (patch)
tree4f531ef7ccfd3f032687177c057628bb64ad7c10 /chapter13/README.md
parent5dad6618f075aac78023183354f0456e5dcc1d54 (diff)
downloadSimple-0fb76e75be3a35d6b4741e9ae4378fa04868a840.tar.gz
Simple-0fb76e75be3a35d6b4741e9ae4378fa04868a840.zip
Ref types working
GCM uses a breadth-first pass for schedule-late instead of a post-order; the post-order walk depends on StoreNodes being pinned, which is true in C2 but not Simple. Move GCM call out of IterPeeps. Struct field init is "makeInit()" not integer zero. Rename Type._print to print. Store,Load prints include field name.
Diffstat (limited to 'chapter13/README.md')
-rw-r--r--chapter13/README.md25
1 files changed, 22 insertions, 3 deletions
diff --git a/chapter13/README.md b/chapter13/README.md
index e381f1dc..49737663 100644
--- a/chapter13/README.md
+++ b/chapter13/README.md
@@ -1,9 +1,9 @@
-# Chapter 12: Floats, Arrays, Refs
-
-## Floats
+# Chapter 12: Floats, References and Arrays
In this chapter we add a series of new types and some modest syntax.
+## Floats
+
Floating point values start with the `flt` type and compute IEEE754 64-bit arithmetic.
Integer expressions auto-widen to floats when involved in a float expression.
@@ -45,3 +45,22 @@ Within the Type Lattice, we now add the following domain:
with a TOP, BOT and constants
+## References
+
+Structs can reference other structs; references can be mutually recursive.
+Any reference field can allow null or not, same as a normal variable.
+
+```java
+struct Person {
+ String name; // No string type, yet
+ int age;
+ FamilyTree tree?; // A family tree, or not
+}
+struct FamilyTree {
+ Person father?;
+ Person mother?;
+ Person []kids?;
+}
+```
+
+Normal field syntax works: `person.tree.father = new Person;` or `person.tree.father.name = "Dad";`.