diff options
| author | Cliff Click <cliffc@acm.org> | 2024-09-23 14:33:31 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2024-10-06 08:56:22 -0700 |
| commit | b4701681889637da276aa05a5bf8da019aebe0d9 (patch) | |
| tree | 1a159c543d7a8ed36e5fab9529a9ce72a8e4d994 /chapter15/src/main | |
| parent | 2185153ea9764090b1e7bd1511b448768a28d6ea (diff) | |
| download | Simple-b4701681889637da276aa05a5bf8da019aebe0d9.tar.gz Simple-b4701681889637da276aa05a5bf8da019aebe0d9.zip | |
sub same moves to compute
Diffstat (limited to 'chapter15/src/main')
| -rw-r--r-- | chapter15/src/main/java/com/seaofnodes/simple/node/SubNode.java | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/chapter15/src/main/java/com/seaofnodes/simple/node/SubNode.java b/chapter15/src/main/java/com/seaofnodes/simple/node/SubNode.java index 89e7227e..009fb30e 100644 --- a/chapter15/src/main/java/com/seaofnodes/simple/node/SubNode.java +++ b/chapter15/src/main/java/com/seaofnodes/simple/node/SubNode.java @@ -30,15 +30,15 @@ public class SubNode extends Node { if (i1.isConstant() && i2.isConstant()) return TypeInteger.constant(i1.value()-i2.value()); } + // Sub of same is 0 + if( in(1)==in(2) ) + return TypeInteger.ZERO; + return TypeInteger.BOT; } @Override public Node idealize() { - // Sub of same is 0 - if( in(1)==in(2) ) - return Parser.ZERO; - // x - (-y) is x+y if( in(2) instanceof MinusNode minus ) return new AddNode(in(1),minus.in(1)); |
