diff options
| author | Cliff Click <cliffc@acm.org> | 2024-09-05 09:15:15 -0700 |
|---|---|---|
| committer | Thalia Archibald <thalia@archibald.dev> | 2024-09-07 10:54:48 -0700 |
| commit | ec7f127c3b32e229ada9ee52def44d6f476c0a99 (patch) | |
| tree | b87d15e9157562b0316f216a23885ac3fafaa5ea /chapter13/src/main/java | |
| parent | 489598387697dcefee1ec2aa5e356b3134722a9a (diff) | |
| download | Simple-ec7f127c3b32e229ada9ee52def44d6f476c0a99.tar.gz Simple-ec7f127c3b32e229ada9ee52def44d6f476c0a99.zip | |
Cleanup comments to match design
Went through several iterations, one where a null _obj was allowed, but settled on using TypeStruct.BOT instead.
Diffstat (limited to 'chapter13/src/main/java')
| -rw-r--r-- | chapter13/src/main/java/com/seaofnodes/simple/type/TypeMemPtr.java | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/chapter13/src/main/java/com/seaofnodes/simple/type/TypeMemPtr.java b/chapter13/src/main/java/com/seaofnodes/simple/type/TypeMemPtr.java index 1ad65611..e671c584 100644 --- a/chapter13/src/main/java/com/seaofnodes/simple/type/TypeMemPtr.java +++ b/chapter13/src/main/java/com/seaofnodes/simple/type/TypeMemPtr.java @@ -13,16 +13,21 @@ import java.util.ArrayList; */ public class TypeMemPtr extends Type { // A TypeMemPtr is pair (obj,nil) - // where obj is one of - // (null,TypeStruct). - // where nil is one of - // (true,false) meaning an explicit null is allowed or not + // where obj is a TypeStruct, possibly TypeStruct.BOT + // where nil is an explicit null is allowed or not - public final TypeStruct _obj; // null, a TypeStruct, or sentinel TypeStruct.MANY + // Examples: + // (Person,false) - a not-nil Person + // (Person,true ) - a Person or a nil + // (BOT ,false) - a not-nil void* (unspecified struct) + // (TOP ,true ) - a nil + + public final TypeStruct _obj; public final boolean _nil; private TypeMemPtr(TypeStruct obj, boolean nil) { super(TMEMPTR); + assert obj!=null; _obj = obj; _nil = nil; } @@ -44,17 +49,14 @@ public class TypeMemPtr extends Type { } @Override - public TypeMemPtr dual() { return TypeMemPtr.make(_obj==null ? null : _obj.dual(), !_nil); } + public TypeMemPtr dual() { return TypeMemPtr.make(_obj.dual(), !_nil); } @Override - public Type glb() { - if( _obj==null ) return BOT; - return make(_obj.glb(),true); - } + public Type glb() { return make(_obj.glb(),true); } @Override public TypeMemPtr makeInit() { return NULLPTR; } @Override - int hash() { return (_obj==null ? 0xDEADBEEF : _obj.hashCode()) ^ (_nil ? 1024 : 0); } + int hash() { return _obj.hashCode() ^ (_nil ? 1024 : 0); } @Override boolean eq(Type t) { |
