From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17359 invoked by alias); 14 Nov 2007 21:54:31 -0000 Received: (qmail 17310 invoked by uid 9708); 14 Nov 2007 21:54:31 -0000 Date: Wed, 14 Nov 2007 21:54:00 -0000 Message-ID: <20071114215431.17295.qmail@sourceware.org> From: tthomas@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Use integer return type for existing relational operations. X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: e60eaf6b29b3ca49957843adc7e69f898f0f1a43 X-Git-Newrev: d3ba8c41604b2cf30372d8bb00758b3d4e4596d0 Mailing-List: contact frysk-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-cvs-owner@sourceware.org Reply-To: frysk@sourceware.org X-SW-Source: 2007-q4/txt/msg00367.txt.bz2 The branch, master has been updated via d3ba8c41604b2cf30372d8bb00758b3d4e4596d0 (commit) from e60eaf6b29b3ca49957843adc7e69f898f0f1a43 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit d3ba8c41604b2cf30372d8bb00758b3d4e4596d0 Author: Teresa Thomas Date: Wed Nov 14 16:50:48 2007 -0500 Use integer return type for existing relational operations. frysk-core/frysk/value/ChangeLog 2007-11-14 Teresa Thomas * FloatingPointUnit.java: Use intType for relational operations. * IntegerUnit.java: Ditto. * TestValue.java (testFloatOps): Update. (testIntOps): Update. (isTrue (double)): Delete. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/value/ChangeLog | 9 +++- frysk-core/frysk/value/FloatingPointUnit.java | 12 ++-- frysk-core/frysk/value/IntegerUnit.java | 12 ++-- frysk-core/frysk/value/TestValue.java | 64 +++++++++++------------- 4 files changed, 49 insertions(+), 48 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/value/ChangeLog b/frysk-core/frysk/value/ChangeLog index 7ae7fae..9e7aed0 100644 --- a/frysk-core/frysk/value/ChangeLog +++ b/frysk-core/frysk/value/ChangeLog @@ -1,5 +1,12 @@ 2007-11-14 Teresa Thomas + * FloatingPointUnit.java: Use intType for relational + operations. + * IntegerUnit.java: Ditto. + * TestValue.java (testFloatOps): Update. + (testIntOps): Update. + (isTrue (double)): Delete. + * ArithmeticUnit.java (logicalAnd(Value,Value)): Delete. * ArithmeticUnit.java (logicalOr(Value,Value)): Delete. @@ -17,7 +24,7 @@ (getLogicalValue): New. * FloatingPointUnit.java: Update. (getLogicalValue): New. - * TestValue.java: Add tests for above. + * TestValue.java: Add tests for above. 2007-11-13 Teresa Thomas diff --git a/frysk-core/frysk/value/FloatingPointUnit.java b/frysk-core/frysk/value/FloatingPointUnit.java index 6b57434..fcaee8f 100644 --- a/frysk-core/frysk/value/FloatingPointUnit.java +++ b/frysk-core/frysk/value/FloatingPointUnit.java @@ -81,27 +81,27 @@ public class FloatingPointUnit } public Value lessThan (Value v1, Value v2) { - return retType.createValue + return intType.createValue (v1.doubleValue() < v2.doubleValue() ? 1:0); } public Value greaterThan (Value v1, Value v2) { - return retType.createValue + return intType.createValue (v1.doubleValue() > v2.doubleValue() ? 1:0); } public Value greaterThanOrEqualTo (Value v1, Value v2) { - return retType.createValue + return intType.createValue (v1.doubleValue() >= v2.doubleValue() ? 1:0); } public Value lessThanOrEqualTo (Value v1, Value v2) { - return retType.createValue + return intType.createValue (v1.doubleValue() <= v2.doubleValue() ? 1:0); } public Value equal (Value v1, Value v2) { - return retType.createValue + return intType.createValue (v1.doubleValue() == v2.doubleValue() ? 1:0); } public Value notEqual (Value v1, Value v2) { - return retType.createValue + return intType.createValue (v1.doubleValue() != v2.doubleValue() ? 1:0); } diff --git a/frysk-core/frysk/value/IntegerUnit.java b/frysk-core/frysk/value/IntegerUnit.java index ce3f505..01e5636 100644 --- a/frysk-core/frysk/value/IntegerUnit.java +++ b/frysk-core/frysk/value/IntegerUnit.java @@ -94,27 +94,27 @@ public class IntegerUnit } public Value lessThan(Value v1, Value v2) { - return retType.createValue + return intType.createValue (v1.asBigInteger().compareTo(v2.asBigInteger()) < 0 ? 1 : 0); } public Value greaterThan(Value v1, Value v2) { - return retType.createValue + return intType.createValue (v1.asBigInteger().compareTo(v2.asBigInteger()) > 0 ? 1 : 0); } public Value lessThanOrEqualTo(Value v1, Value v2) { - return retType.createValue + return intType.createValue (v1.asBigInteger().compareTo(v2.asBigInteger()) <= 0 ? 1 : 0); } public Value greaterThanOrEqualTo(Value v1, Value v2) { - return retType.createValue + return intType.createValue (v1.asBigInteger().compareTo(v2.asBigInteger()) >= 0 ? 1 : 0); } public Value equal(Value v1, Value v2) { - return retType.createValue + return intType.createValue (v1.asBigInteger().compareTo(v2.asBigInteger()) == 0 ? 1 : 0); } public Value notEqual(Value v1, Value v2) { - return retType.createValue + return intType.createValue (v1.asBigInteger().compareTo(v2.asBigInteger()) != 0 ? 1 : 0); } diff --git a/frysk-core/frysk/value/TestValue.java b/frysk-core/frysk/value/TestValue.java index 30507f5..76b8d04 100644 --- a/frysk-core/frysk/value/TestValue.java +++ b/frysk-core/frysk/value/TestValue.java @@ -94,14 +94,6 @@ public class TestValue else return false; } - - private boolean isTrue (double d) - { - if (d != 0) - return true; - else - return false; - } public void testIntOps () { @@ -121,18 +113,6 @@ public class TestValue assertEquals ("9 << 4", 9 << 4, v3.asLong()); v3 = v1.getType().getALU(v2.getType(), 0).shiftRight(v2, v1); assertEquals ("9 >> 4", 9 >> 4, v3.asLong()); - v3 = v1.getType().getALU(v2.getType(), 0).lessThan(v2, v1); - assertEquals ("9 < 4", 9 < 4, isTrue(v3.asLong())); - v3 = v1.getType().getALU(v2.getType(), 0).greaterThan(v2, v1); - assertEquals ("9 > 4", 9 > 4, isTrue(v3.asLong())); - v3 = v1.getType().getALU(v2.getType(), 0).lessThanOrEqualTo(v2, v1); - assertEquals ("9 <= 4", 9 <= 4, isTrue(v3.asLong())); - v3 = v1.getType().getALU(v2.getType(), 0).greaterThanOrEqualTo(v2, v1); - assertEquals ("9 >= 4", 9 >= 4, isTrue(v3.asLong())); - v3 = v1.getType().getALU(v2.getType(), 0).equal(v2, v1); - assertEquals ("9 == 4", 9 == 4, isTrue(v3.asLong())); - v3 =v1.getType().getALU(v2.getType(), 0).notEqual(v2, v1); - assertEquals ("9 != 4", 9 != 4, isTrue(v3.asLong())); v3 = v1.getType().getALU(v2.getType(), 0).bitWiseAnd(v2, v1); assertEquals ("9 && 4", 9 & 4, v3.asLong()); v3 = v1.getType().getALU(v2.getType(), 0).bitWiseOr(v2, v1); @@ -140,7 +120,20 @@ public class TestValue v3 = v1.getType().getALU(v2.getType(), 0).bitWiseXor(v2, v1); assertEquals ("9 ^ 4", 9 ^ 4, v3.asLong()); v3 = v1.getType().getALU(v2.getType(), 0).bitWiseComplement(v1); - assertEquals ("~4", ~4, v3.asLong()); + assertEquals ("~4", ~4, v3.asLong()); + // wordSize required for constructing integer return type. + v3 = v1.getType().getALU(v2.getType(), wordSize).lessThan(v2, v1); + assertEquals ("9 < 4", 9 < 4, isTrue(v3.asLong())); + v3 = v1.getType().getALU(v2.getType(), wordSize).greaterThan(v2, v1); + assertEquals ("9 > 4", 9 > 4, isTrue(v3.asLong())); + v3 = v1.getType().getALU(v2.getType(), wordSize).lessThanOrEqualTo(v2, v1); + assertEquals ("9 <= 4", 9 <= 4, isTrue(v3.asLong())); + v3 = v1.getType().getALU(v2.getType(), wordSize).greaterThanOrEqualTo(v2, v1); + assertEquals ("9 >= 4", 9 >= 4, isTrue(v3.asLong())); + v3 = v1.getType().getALU(v2.getType(), wordSize).equal(v2, v1); + assertEquals ("9 == 4", 9 == 4, isTrue(v3.asLong())); + v3 =v1.getType().getALU(v2.getType(), wordSize).notEqual(v2, v1); + assertEquals ("9 != 4", 9 != 4, isTrue(v3.asLong())); v3 = v1.getType().getALU(wordSize).logicalAnd(v2, v1, null); assertEquals ("9 && 4", 1, v3.asLong()); v3 = v1.getType().getALU(wordSize).logicalOr(v2, v1, null); @@ -164,7 +157,7 @@ public class TestValue v3 = v1.getType().getALU(v2.getType(), 0).shiftLeftEqual(v3, v1); assertEquals ("v3 <<= 4", 0, v3.asLong()); v3 = v1.getType().getALU(v2.getType(), 0).shiftRightEqual(v3, v1); - assertEquals ("v3 >>= 4", 0, v3.asLong()); + assertEquals ("v3 >>= 4", 0, v3.asLong()); v3 = v1.getType().getALU(v2.getType(), 0).bitWiseOrEqual(v3, v1); assertEquals ("v3 |= 4", 4, v3.asLong()); v3 = v1.getType().getALU(v2.getType(), 0).bitWiseXorEqual(v3, v1); @@ -186,18 +179,6 @@ public class TestValue assertEquals ("9 * 4", 9 * 4, v3.doubleValue(), 0); v3 = v1.getType().getALU(v2.getType(), 0).mod(v2, v1); assertEquals ("9 % 4", 9 % 4, v3.doubleValue(), 0); - v3 = v1.getType().getALU(v2.getType(), 0).lessThan(v2, v1); - assertEquals ("9 < 4", 9 < 4, isTrue(v3.doubleValue())); - v3 = v1.getType().getALU(v2.getType(), 0).greaterThan(v2, v1); - assertEquals ("9 > 4", 9 > 4, isTrue(v3.doubleValue())); - v3 = v1.getType().getALU(v2.getType(), 0).lessThanOrEqualTo(v2, v1); - assertEquals ("9 <= 4", 9 <= 4, isTrue(v3.doubleValue())); - v3 = v1.getType().getALU(v2.getType(), 0).greaterThanOrEqualTo(v2, v1); - assertEquals ("9 >= 4", 9 >= 4, isTrue(v3.doubleValue())); - v3 = v1.getType().getALU(v2.getType(), 0).equal(v2, v1); - assertEquals ("9 == 4", 9 == 4, isTrue(v3.doubleValue())); - v3 = v1.getType().getALU(v2.getType(), 0).notEqual(v2, v1); - assertEquals ("9 != 4", v2 != v1, isTrue(v3.doubleValue())); v3 = v3.assign(v1); assertEquals ("v3 = 4", 4, v3.doubleValue(), 0); v3 = v3.getType().getALU(v1.getType(), 0).plusEqual(v3, v1); @@ -210,7 +191,20 @@ public class TestValue assertEquals ("v3 /= 4", 4, v3.doubleValue(), 0); v3 = v3.getType().getALU(v1.getType(), 0).modEqual(v3, v1); assertEquals ("v3 %= 4", 0, v3.doubleValue(), 0); - // Note: Return type of logical expression is int. + // Note: Return type of relational, logical expression is int. + // wordSize required for constructing integer return type. + v3 = v1.getType().getALU(v2.getType(), wordSize).lessThan(v2, v1); + assertEquals ("9 < 4", 9 < 4, isTrue(v3.asLong())); + v3 = v1.getType().getALU(v2.getType(), wordSize).greaterThan(v2, v1); + assertEquals ("9 > 4", 9 > 4, isTrue(v3.asLong())); + v3 = v1.getType().getALU(v2.getType(), wordSize).lessThanOrEqualTo(v2, v1); + assertEquals ("9 <= 4", 9 <= 4, isTrue(v3.asLong())); + v3 = v1.getType().getALU(v2.getType(), wordSize).greaterThanOrEqualTo(v2, v1); + assertEquals ("9 >= 4", 9 >= 4, isTrue(v3.asLong())); + v3 = v1.getType().getALU(v2.getType(), wordSize).equal(v2, v1); + assertEquals ("9 == 4", 9 == 4, isTrue(v3.asLong())); + v3 = v1.getType().getALU(v2.getType(), wordSize).notEqual(v2, v1); + assertEquals ("9 != 4", v2 != v1, isTrue(v3.asLong())); v3 = v1.getType().getALU(wordSize).logicalAnd(v2, v1, null); assertEquals ("9 && 4", 1, v3.asLong()); v3 = v1.getType().getALU(wordSize).logicalOr(v2, v1, null); hooks/post-receive -- frysk system monitor/debugger