diff options
Diffstat (limited to 'src/jcgp/backend/function/BitwiseLogic.java')
-rw-r--r-- | src/jcgp/backend/function/BitwiseLogic.java | 124 |
1 files changed, 62 insertions, 62 deletions
diff --git a/src/jcgp/backend/function/BitwiseLogic.java b/src/jcgp/backend/function/BitwiseLogic.java index 14f4488..a4c2737 100644 --- a/src/jcgp/backend/function/BitwiseLogic.java +++ b/src/jcgp/backend/function/BitwiseLogic.java @@ -31,8 +31,8 @@ public class BitwiseLogic extends FunctionSet { public static class ConstantZero extends Function { @Override - public Long run(Connection... connections) { - return new Long(0); + public UnsignedInteger run(Connection... connections) { + return new UnsignedInteger(0); } @Override @@ -48,8 +48,8 @@ public class BitwiseLogic extends FunctionSet { public static class ConstantOne extends Function { @Override - public Long run(Connection... connections) { - return new Long(Long.MAX_VALUE); + public UnsignedInteger run(Connection... connections) { + return new UnsignedInteger(0xFFFF); } @Override @@ -65,11 +65,11 @@ public class BitwiseLogic extends FunctionSet { public static class WireA extends Function { @Override - public Long run(Connection... connections) { + public UnsignedInteger run(Connection... connections) { if (connections.length < getArity()) { throw new IllegalArgumentException(getName() + " received " + connections.length + " connections but arity is " + getArity() + "."); } else { - return ((Long) connections[0].getValue()).longValue(); + return ((UnsignedInteger) connections[0].getValue()); } } @@ -86,11 +86,11 @@ public class BitwiseLogic extends FunctionSet { public static class WireB extends Function { @Override - public Long run(Connection... connections) { + public UnsignedInteger run(Connection... connections) { if (connections.length < getArity()) { throw new IllegalArgumentException(getName() + " received " + connections.length + " connections but arity is " + getArity() + "."); } else { - return ((Long) connections[1].getValue()).longValue(); + return ((UnsignedInteger) connections[1].getValue()); } } @@ -107,11 +107,11 @@ public class BitwiseLogic extends FunctionSet { public static class NotA extends Function { @Override - public Long run(Connection... connections) { + public UnsignedInteger run(Connection... connections) { if (connections.length < getArity()) { throw new IllegalArgumentException(getName() + " received " + connections.length + " connections but arity is " + getArity() + "."); } else { - return ~((Long) connections[0].getValue()).longValue(); + return new UnsignedInteger(~((UnsignedInteger) connections[0].getValue()).get()); } } @@ -128,11 +128,11 @@ public class BitwiseLogic extends FunctionSet { public static class NotB extends Function { @Override - public Long run(Connection... connections) { + public UnsignedInteger run(Connection... connections) { if (connections.length < getArity()) { throw new IllegalArgumentException(getName() + " received " + connections.length + " connections but arity is " + getArity() + "."); } else { - return ~((Long) connections[1].getValue()).longValue(); + return new UnsignedInteger(~((UnsignedInteger) connections[1].getValue()).get()); } } @@ -149,15 +149,15 @@ public class BitwiseLogic extends FunctionSet { public static class And extends Function { @Override - public Long run(Connection... connections) { + public UnsignedInteger run(Connection... connections) { if (connections.length < getArity()) { throw new IllegalArgumentException(getName() + " received " + connections.length + " connections but arity is " + getArity() + "."); } else { - Long arg1 = ((Long) connections[0].getValue()); - Long arg2 = ((Long) connections[1].getValue()); - Long result = arg1 & arg2; + UnsignedInteger arg1 = ((UnsignedInteger) connections[0].getValue()); + UnsignedInteger arg2 = ((UnsignedInteger) connections[1].getValue()); + Integer result = arg1.get() & arg2.get(); - return result; + return new UnsignedInteger(result); } } @@ -174,15 +174,15 @@ public class BitwiseLogic extends FunctionSet { public static class AndNotA extends Function { @Override - public Long run(Connection... connections) { + public UnsignedInteger run(Connection... connections) { if (connections.length < getArity()) { throw new IllegalArgumentException(getName() + " received " + connections.length + " connections but arity is " + getArity() + "."); } else { - Long arg1 = ((Long) connections[0].getValue()); - Long arg2 = ((Long) connections[1].getValue()); - Long result = ~arg1 & arg2; + UnsignedInteger arg1 = ((UnsignedInteger) connections[0].getValue()); + UnsignedInteger arg2 = ((UnsignedInteger) connections[1].getValue()); + Integer result = ~(arg1.get()) & arg2.get(); - return result; + return new UnsignedInteger(result); } } @@ -199,15 +199,15 @@ public class BitwiseLogic extends FunctionSet { public static class AndNotB extends Function { @Override - public Long run(Connection... connections) { + public UnsignedInteger run(Connection... connections) { if (connections.length < getArity()) { throw new IllegalArgumentException(getName() + " received " + connections.length + " connections but arity is " + getArity() + "."); } else { - Long arg1 = ((Long) connections[0].getValue()); - Long arg2 = ((Long) connections[1].getValue()); - Long result = arg1 & ~arg2; + UnsignedInteger arg1 = ((UnsignedInteger) connections[0].getValue()); + UnsignedInteger arg2 = ((UnsignedInteger) connections[1].getValue()); + Integer result = arg1.get() & ~(arg2.get()); - return result; + return new UnsignedInteger(result); } } @@ -224,15 +224,15 @@ public class BitwiseLogic extends FunctionSet { public static class Nor extends Function { @Override - public Long run(Connection... connections) { + public UnsignedInteger run(Connection... connections) { if (connections.length < getArity()) { throw new IllegalArgumentException(getName() + " received " + connections.length + " connections but arity is " + getArity() + "."); } else { - Long arg1 = ((Long) connections[0].getValue()); - Long arg2 = ((Long) connections[1].getValue()); - Long result = arg1 | arg2; + UnsignedInteger arg1 = ((UnsignedInteger) connections[0].getValue()); + UnsignedInteger arg2 = ((UnsignedInteger) connections[1].getValue()); + Integer result = arg1.get() | arg2.get(); - return ~result; + return new UnsignedInteger(~result); } } @@ -249,15 +249,15 @@ public class BitwiseLogic extends FunctionSet { public static class Xor extends Function { @Override - public Long run(Connection... connections) { + public UnsignedInteger run(Connection... connections) { if (connections.length < getArity()) { throw new IllegalArgumentException(getName() + " received " + connections.length + " connections but arity is " + getArity() + "."); } else { - Long arg1 = ((Long) connections[0].getValue()); - Long arg2 = ((Long) connections[1].getValue()); - Long result = arg1 ^ arg2; + UnsignedInteger arg1 = ((UnsignedInteger) connections[0].getValue()); + UnsignedInteger arg2 = ((UnsignedInteger) connections[1].getValue()); + Integer result = arg1.get() ^ arg2.get(); - return result; + return new UnsignedInteger(result); } } @@ -274,15 +274,15 @@ public class BitwiseLogic extends FunctionSet { public static class Xnor extends Function { @Override - public Long run(Connection... connections) { + public UnsignedInteger run(Connection... connections) { if (connections.length < getArity()) { throw new IllegalArgumentException(getName() + " received " + connections.length + " connections but arity is " + getArity() + "."); } else { - Long arg1 = ((Long) connections[0].getValue()); - Long arg2 = ((Long) connections[1].getValue()); - Long result = arg1 ^ arg2; + UnsignedInteger arg1 = ((UnsignedInteger) connections[0].getValue()); + UnsignedInteger arg2 = ((UnsignedInteger) connections[1].getValue()); + Integer result = arg1.get() ^ arg2.get(); - return ~result; + return new UnsignedInteger(~result); } } @@ -299,15 +299,15 @@ public class BitwiseLogic extends FunctionSet { public static class Or extends Function { @Override - public Long run(Connection... connections) { + public UnsignedInteger run(Connection... connections) { if (connections.length < getArity()) { throw new IllegalArgumentException(getName() + " received " + connections.length + " connections but arity is " + getArity() + "."); } else { - Long arg1 = ((Long) connections[0].getValue()); - Long arg2 = ((Long) connections[1].getValue()); - Long result = arg1 | arg2; + UnsignedInteger arg1 = ((UnsignedInteger) connections[0].getValue()); + UnsignedInteger arg2 = ((UnsignedInteger) connections[1].getValue()); + Integer result = arg1.get() | arg2.get(); - return result; + return new UnsignedInteger(result); } } @@ -324,15 +324,15 @@ public class BitwiseLogic extends FunctionSet { public static class OrNotA extends Function { @Override - public Long run(Connection... connections) { + public UnsignedInteger run(Connection... connections) { if (connections.length < getArity()) { throw new IllegalArgumentException(getName() + " received " + connections.length + " connections but arity is " + getArity() + "."); } else { - Long arg1 = ((Long) connections[0].getValue()); - Long arg2 = ((Long) connections[1].getValue()); - Long result = ~arg1 | arg2; + UnsignedInteger arg1 = ((UnsignedInteger) connections[0].getValue()); + UnsignedInteger arg2 = ((UnsignedInteger) connections[1].getValue()); + Integer result = ~arg1.get() | arg2.get(); - return result; + return new UnsignedInteger(result); } } @@ -349,15 +349,15 @@ public class BitwiseLogic extends FunctionSet { public static class OrNotB extends Function { @Override - public Long run(Connection... connections) { + public UnsignedInteger run(Connection... connections) { if (connections.length < getArity()) { throw new IllegalArgumentException(getName() + " received " + connections.length + " connections but arity is " + getArity() + "."); } else { - Long arg1 = ((Long) connections[0].getValue()); - Long arg2 = ((Long) connections[1].getValue()); - Long result = arg1 | ~arg2; + UnsignedInteger arg1 = ((UnsignedInteger) connections[0].getValue()); + UnsignedInteger arg2 = ((UnsignedInteger) connections[1].getValue()); + Integer result = arg1.get() | ~arg2.get(); - return result; + return new UnsignedInteger(result); } } @@ -374,15 +374,15 @@ public class BitwiseLogic extends FunctionSet { public static class Nand extends Function { @Override - public Long run(Connection... connections) { + public UnsignedInteger run(Connection... connections) { if (connections.length < getArity()) { throw new IllegalArgumentException(getName() + " received " + connections.length + " connections but arity is " + getArity() + "."); } else { - Long arg1 = ((Long) connections[0].getValue()); - Long arg2 = ((Long) connections[1].getValue()); - Long result = arg1 & arg2; + UnsignedInteger arg1 = ((UnsignedInteger) connections[0].getValue()); + UnsignedInteger arg2 = ((UnsignedInteger) connections[1].getValue()); + Integer result = arg1.get() & arg2.get(); - return ~result; + return new UnsignedInteger(~result); } } |