diff options
| author | Cliff Click <cliffc@acm.org> | 2024-09-04 19:51:46 -0700 |
|---|---|---|
| committer | Thalia Archibald <thalia@archibald.dev> | 2024-09-07 10:54:48 -0700 |
| commit | b5294c3dae75a036c57278aa80f7928717a1e22c (patch) | |
| tree | 5fd6688c1efd3c637b9d94ca76f8ccb603072e07 /chapter14/src/main/java | |
| parent | c7bfd1e3e00f11b9cc4ab24324ce2e4d783c3bbd (diff) | |
| download | Simple-b5294c3dae75a036c57278aa80f7928717a1e22c.tar.gz Simple-b5294c3dae75a036c57278aa80f7928717a1e22c.zip | |
minus is sane for high ranges
Diffstat (limited to 'chapter14/src/main/java')
| -rw-r--r-- | chapter14/src/main/java/com/seaofnodes/simple/node/MinusNode.java | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/chapter14/src/main/java/com/seaofnodes/simple/node/MinusNode.java b/chapter14/src/main/java/com/seaofnodes/simple/node/MinusNode.java index 6e3b82e9..8a2c9406 100644 --- a/chapter14/src/main/java/com/seaofnodes/simple/node/MinusNode.java +++ b/chapter14/src/main/java/com/seaofnodes/simple/node/MinusNode.java @@ -20,8 +20,10 @@ public class MinusNode extends Node { @Override public Type compute() { - if( in(1)._type instanceof TypeInteger i0 ) + if( in(1)._type instanceof TypeInteger i0 ) { + 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); } |
