summaryrefslogtreecommitdiff
path: root/chapter15/src/main/java
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-09-22 16:02:08 -0700
committerCliff Click <cliffc@acm.org>2026-09-22 16:02:08 -0700
commit695429df954b084d2226fe2a6c1a47e1861bcc01 (patch)
tree5ee6fb3eb2b71b92cef509c28b7dfbeceea044cb /chapter15/src/main/java
parentfb80ada35ce2806c2f617a0e336d2ca4ab1d5d12 (diff)
downloadSimple-695429df954b084d2226fe2a6c1a47e1861bcc01.tar.gz
Simple-695429df954b084d2226fe2a6c1a47e1861bcc01.zip
int fallbacks for int ops
all chapters, a little sharper for int ops
Diffstat (limited to 'chapter15/src/main/java')
-rw-r--r--chapter15/src/main/java/com/seaofnodes/simple/node/MinusNode.java2
-rw-r--r--chapter15/src/main/java/com/seaofnodes/simple/node/NotNode.java5
2 files changed, 4 insertions, 3 deletions
diff --git a/chapter15/src/main/java/com/seaofnodes/simple/node/MinusNode.java b/chapter15/src/main/java/com/seaofnodes/simple/node/MinusNode.java
index 7e95088f..63cfd110 100644
--- a/chapter15/src/main/java/com/seaofnodes/simple/node/MinusNode.java
+++ b/chapter15/src/main/java/com/seaofnodes/simple/node/MinusNode.java
@@ -22,7 +22,7 @@ public class MinusNode extends Node {
if( i0.isHigh() ) return TypeInteger.TOP;
return i0==TypeInteger.BOT ? TypeInteger.BOT : TypeInteger.make(-i0._max,-i0._min);
}
- return TypeInteger.TOP.meet(in(1)._type);
+ return in(1)._type.isHigh() ? TypeInteger.TOP : TypeInteger.BOT;
}
@Override
diff --git a/chapter15/src/main/java/com/seaofnodes/simple/node/NotNode.java b/chapter15/src/main/java/com/seaofnodes/simple/node/NotNode.java
index 3ef5d19e..17b6e46e 100644
--- a/chapter15/src/main/java/com/seaofnodes/simple/node/NotNode.java
+++ b/chapter15/src/main/java/com/seaofnodes/simple/node/NotNode.java
@@ -21,7 +21,8 @@ public class NotNode extends Node {
if( t0.isHigh() ) return TypeInteger.BOOL.dual();
switch( t0 ) {
case TypeInteger i0: return i0._max < 0 || i0._min > 0 ? TypeInteger.FALSE : (i0==TypeInteger.ZERO ? TypeInteger.TRUE : TypeInteger.BOT);
- case TypeFloat i0: return i0.isConstant() ? TypeInteger.constant(i0.value()==0 ? 1 : 0) : i0;
+ case TypeFloat i0:
+ return i0.isConstant() ? TypeInteger.constant(i0.value()==0 ? 1 : 0) : TypeInteger.BOT;
case TypeMemPtr p0:
// top->top, bot->bot, null->1, *void->0, not-null ptr->0, ptr/nil->bot
// If input in null then true
@@ -34,7 +35,7 @@ public class NotNode extends Node {
if( t0.getClass() != Type.class )
// Only doing NOT on ints and ptrs
throw Utils.TODO();
- return t0==Type.TOP ? Type.TOP : Type.BOTTOM;
+ return t0==Type.TOP ? TypeInteger.TOP : TypeInteger.BOT;
}
}