[SCM] master: Simplify logical expressions.

tthomas@sourceware.org tthomas@sourceware.org
Thu Nov 15 21:54:00 GMT 2007


The branch, master has been updated
       via  b88be9142254b4b1c5d5cd094137f52861ad9432 (commit)
      from  690290c4dde512010e498ddc45360a12f78324e7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit b88be9142254b4b1c5d5cd094137f52861ad9432
Author: Teresa Thomas <tthomas@redhat.com>
Date:   Thu Nov 15 16:50:28 2007 -0500

    Simplify logical expressions.
    
    frysk-core/frysk/value/ChangeLog
    2007-11-15  Teresa Thomas  <tthomas@redhat.com>
    
    	* ArithmeticUnit.java (getLogicalValue): Delete
    	argument mem, define here.
    	(logicalNegation): Update.
    	(logicalOr): Update.
    	(logicalAnd): Update.
    	* AddressUnit.java (getLogicalValue): Delete.
    	* FloatingPointUnit.java (getLogicalValue): Delete.
    	* IntegerUnit.java (getLogicalValue): Delete.
    	* TestValue.java: Update.
    
    frysk-core/frysk/expr/ChangeLog
    2007-11-15  Teresa Thomas  <tthomas@redhat.com>
    
    	* CExprEvaluator.g: Update.

-----------------------------------------------------------------------

Summary of changes:
 frysk-core/frysk/expr/CExprEvaluator.g        |    8 +++---
 frysk-core/frysk/expr/ChangeLog               |    6 ++++-
 frysk-core/frysk/value/AddressUnit.java       |    7 +----
 frysk-core/frysk/value/ArithmeticUnit.java    |   33 +++++++++++-------------
 frysk-core/frysk/value/ChangeLog              |   12 +++++++++
 frysk-core/frysk/value/FloatingPointUnit.java |    8 +-----
 frysk-core/frysk/value/IntegerUnit.java       |    8 ------
 frysk-core/frysk/value/TestValue.java         |   24 +++++++----------
 8 files changed, 48 insertions(+), 58 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/expr/CExprEvaluator.g b/frysk-core/frysk/expr/CExprEvaluator.g
index a4f9403..5de32c6 100644
--- a/frysk-core/frysk/expr/CExprEvaluator.g
+++ b/frysk-core/frysk/expr/CExprEvaluator.g
@@ -255,16 +255,16 @@ expr returns [Value returnVar=null]
         }
     |   #(AND  v1=expr v2=expr) {
             returnVar = v1.getType().getALU(exprSymTab.getWordSize())
-                        .logicalAnd(v1, v2, exprSymTab.taskMemory()); 
+                        .logicalAnd(v1, v2); 
         }
     |   #(OR  v1=expr v2=expr) {
             returnVar = v1.getType().getALU(exprSymTab.getWordSize())
-                        .logicalOr(v1, v2,exprSymTab.taskMemory()); 
+                        .logicalOr(v1, v2); 
         }
     |   #(NOT  v1=expr) {
             // byte buffer needed for Pointer/Address types
             returnVar = v1.getType().getALU(exprSymTab.getWordSize())
-                        .logicalNegation(v1, exprSymTab.taskMemory()); 
+                        .logicalNegation(v1); 
         }
     |   #(TILDE v1=expr) {
             returnVar = v1.getType().getALU(exprSymTab.getWordSize())
@@ -273,7 +273,7 @@ expr returns [Value returnVar=null]
     |   #(COND_EXPR  log_expr=expr v1=expr v2=expr) {
             returnVar = ((log_expr.getType().getALU(log_expr.getType(), 
                         exprSymTab.getWordSize())
-                        .getLogicalValue(log_expr, exprSymTab.taskMemory())) 
+                        .getLogicalValue(log_expr)) 
                         ? v1 : v2);
         }
     |   o:OCTALINT  {
diff --git a/frysk-core/frysk/expr/ChangeLog b/frysk-core/frysk/expr/ChangeLog
index c877379..8dc8423 100644
--- a/frysk-core/frysk/expr/ChangeLog
+++ b/frysk-core/frysk/expr/ChangeLog
@@ -1,9 +1,13 @@
+2007-11-15  Teresa Thomas  <tthomas@redhat.com>
+	
+	* CExprEvaluator.g: Update.
+
 2007-11-15  Andrew Cagney  <cagney@redhat.com>
 
 	* CExpr.g (options): Delete ASTLabelType.
 	* CExprEvaluator.g (options): Ditto.
 	* ExprAST.java: Delete.
-
+	
 2007-11-14  Andrew Cagney  <cagney@redhat.com>
 
 	* CExprAnnotator.g: Delete.
diff --git a/frysk-core/frysk/value/AddressUnit.java b/frysk-core/frysk/value/AddressUnit.java
index 32b7503..094b589 100644
--- a/frysk-core/frysk/value/AddressUnit.java
+++ b/frysk-core/frysk/value/AddressUnit.java
@@ -40,7 +40,6 @@
 package frysk.value;
 
 import inua.eio.ByteOrder;
-import inua.eio.ByteBuffer;
 
 /**
  * Operation handling for pointers and addresses.
@@ -120,9 +119,5 @@ extends ArithmeticUnit
 	Location l = new ScratchLocation (v2.asBigInteger().negate().toByteArray());
 	Value v2Neg = new Value (v2.getType(), l);
 	return add (v1, v2Neg);
-    }
-
-    public boolean getLogicalValue (Value v1, ByteBuffer mem) {
-	return (v1.toPrint(Format.NATURAL, mem).equals("0x0")? false:true);
-    }      
+    }     
 }
\ No newline at end of file
diff --git a/frysk-core/frysk/value/ArithmeticUnit.java b/frysk-core/frysk/value/ArithmeticUnit.java
index 5280224..897fd9a 100644
--- a/frysk-core/frysk/value/ArithmeticUnit.java
+++ b/frysk-core/frysk/value/ArithmeticUnit.java
@@ -39,8 +39,9 @@
 
 package frysk.value;
 
+import java.math.BigInteger;
+
 import inua.eio.ByteOrder;
-import inua.eio.ByteBuffer;
 
 /**
  * Arithmetic and Logical Operation handling
@@ -144,24 +145,20 @@ public abstract class ArithmeticUnit
     }
     
     // Logical expressions - valid for any scalar types.
-    public Value logicalAnd (Value v1, Value v2, ByteBuffer mem) {
-	boolean op1 = v1.getType().getALU(wordSize).getLogicalValue(v1, mem);
-	boolean op2 = v2.getType().getALU(wordSize).getLogicalValue(v2, mem);
-	return intType.createValue( (op1 && op2) ? 1:0);
-    }
-    public Value logicalOr (Value v1, Value v2, ByteBuffer mem) {
-	boolean op1 = v1.getType().getALU(wordSize).getLogicalValue(v1, mem);
-	boolean op2 = v2.getType().getALU(wordSize).getLogicalValue(v2, mem);
-	return intType.createValue( op1 || op2 ? 1:0);
-    }
-    public Value logicalNegation(Value v1, ByteBuffer mem) {
-	boolean op1 = v1.getType().getALU(wordSize).getLogicalValue(v1, mem);
-	return intType.createValue( op1 ? 0:1);
+    public Value logicalAnd (Value v1, Value v2) {
+	return intType.createValue( 
+		       (getLogicalValue(v1) && getLogicalValue(v2)) ? 1:0);
+    }
+    public Value logicalOr (Value v1, Value v2) {
+	return intType.createValue( 
+		       (getLogicalValue(v1) || getLogicalValue(v2)) ? 1:0);
+    }
+    public Value logicalNegation(Value v1) {
+	return intType.createValue( getLogicalValue(v1) ? 0:1);
     }     
-    public boolean getLogicalValue (Value v1, ByteBuffer mem) {
-        throw new InvalidOperatorException
-                  (v1.getType(), "getLogicalValue");
-    }  
+    public boolean getLogicalValue (Value v1) {
+	return (!(v1.asBigInteger().compareTo(BigInteger.ZERO) == 0)); 
+    }    
     
     // Assigment expressions.
     public Value plusEqual(Value v1, Value v2) {
diff --git a/frysk-core/frysk/value/ChangeLog b/frysk-core/frysk/value/ChangeLog
index 9e7aed0..9265646 100644
--- a/frysk-core/frysk/value/ChangeLog
+++ b/frysk-core/frysk/value/ChangeLog
@@ -1,3 +1,15 @@
+2007-11-15  Teresa Thomas  <tthomas@redhat.com>
+
+	* ArithmeticUnit.java (getLogicalValue): Delete 
+	argument mem, define here.
+	(logicalNegation): Update.
+	(logicalOr): Update.
+	(logicalAnd): Update.
+	* AddressUnit.java (getLogicalValue): Delete.
+	* FloatingPointUnit.java (getLogicalValue): Delete. 
+	* IntegerUnit.java (getLogicalValue): Delete.	
+	* TestValue.java: Update.
+			
 2007-11-14  Teresa Thomas  <tthomas@redhat.com>
 
 	* FloatingPointUnit.java: Use intType for relational
diff --git a/frysk-core/frysk/value/FloatingPointUnit.java b/frysk-core/frysk/value/FloatingPointUnit.java
index fcaee8f..01cfb41 100644
--- a/frysk-core/frysk/value/FloatingPointUnit.java
+++ b/frysk-core/frysk/value/FloatingPointUnit.java
@@ -39,8 +39,6 @@
 
 package frysk.value;
 
-import inua.eio.ByteBuffer;
-
 /**
  * Arithmetic and logical operation handling
  * for floating points.
@@ -103,9 +101,5 @@ public class FloatingPointUnit
     public Value notEqual (Value v1, Value v2) {
 	return intType.createValue
 	       (v1.doubleValue() != v2.doubleValue() ? 1:0);
-    }
-    
-    public boolean getLogicalValue (Value v1, ByteBuffer mem) {
-	return ((v1.doubleValue() == 0.0) ? false : true);
-    }   
+    } 
 }    
\ No newline at end of file
diff --git a/frysk-core/frysk/value/IntegerUnit.java b/frysk-core/frysk/value/IntegerUnit.java
index 01e5636..73f2d2d 100644
--- a/frysk-core/frysk/value/IntegerUnit.java
+++ b/frysk-core/frysk/value/IntegerUnit.java
@@ -39,9 +39,6 @@
 
 package frysk.value;
 
-import java.math.BigInteger;
-import inua.eio.ByteBuffer;
-
 /**
  *  Arithmetic and logical Operation handling 
  *  for integers. All arithmetic done using 
@@ -134,9 +131,4 @@ public class IntegerUnit
 	return retType.createValue
 	       (v1.asBigInteger().not());
     }
-    
-    public boolean getLogicalValue (Value v1, ByteBuffer mem) {
-	return ((v1.asBigInteger().compareTo(BigInteger.ZERO) == 0) 
-		 ? false : true);
-    }    
 }
\ No newline at end of file
diff --git a/frysk-core/frysk/value/TestValue.java b/frysk-core/frysk/value/TestValue.java
index 76b8d04..b7391af 100644
--- a/frysk-core/frysk/value/TestValue.java
+++ b/frysk-core/frysk/value/TestValue.java
@@ -39,7 +39,6 @@
 
 package frysk.value;
 
-import inua.eio.ArrayByteBuffer;
 import inua.eio.ByteOrder;
 import frysk.Config;
 import frysk.junit.TestCase;
@@ -134,13 +133,13 @@ public class TestValue
 	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);
+	v3 = v1.getType().getALU(wordSize).logicalAnd(v2, v1);
 	assertEquals ("9 && 4", 1, v3.asLong());
-	v3 = v1.getType().getALU(wordSize).logicalOr(v2, v1, null);
+	v3 = v1.getType().getALU(wordSize).logicalOr(v2, v1);
 	assertEquals ("9 || 4", 1, v3.asLong());	
-	v3 = v1.getType().getALU(wordSize).logicalNegation(v1, null);
+	v3 = v1.getType().getALU(wordSize).logicalNegation(v1);
 	assertEquals ("!4", 0, v3.asLong());		
-	bool = v2.getType().getALU(wordSize).getLogicalValue(v2, null);
+	bool = v2.getType().getALU(wordSize).getLogicalValue(v2);
 	assertEquals ("bool(9)", true, bool);		
 	v3 = v3.assign(v1);	
 	assertEquals ("v3 = 4", 4, v3.asLong());
@@ -205,19 +204,16 @@ public class TestValue
 	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);
+	v3 = v1.getType().getALU(wordSize).logicalAnd(v2, v1);
 	assertEquals ("9 && 4", 1, v3.asLong());
-	v3 = v1.getType().getALU(wordSize).logicalOr(v2, v1, null);
+	v3 = v1.getType().getALU(wordSize).logicalOr(v2, v1);
 	assertEquals ("9 || 4", 1, v3.asLong());			
-	v3 = v1.getType().getALU(wordSize).logicalNegation(v1, null);
+	v3 = v1.getType().getALU(wordSize).logicalNegation(v1);
 	assertEquals ("!4", 0, v3.asLong());		
     }
     
     public void testAddressOps() 
     {
-	// Construct a buffer with a string in it.
-	ArrayByteBuffer memory
-	= new ArrayByteBuffer("0123Hello World\0>>>".getBytes());
 	Type t = new PointerType("xxx", ByteOrder.BIG_ENDIAN, 1,
 	 	 new CharType("char", ByteOrder.BIG_ENDIAN,
 			       1, true));
@@ -226,11 +222,11 @@ public class TestValue
 	Value ptr = new Value (t, l);
 	Value v1 = intType.createValue(4);
 
-	Value v = v1.getType().getALU(wordSize).logicalAnd(v1, ptr, memory);
+	Value v = v1.getType().getALU(wordSize).logicalAnd(v1, ptr);
 	assertEquals ("ptr && 4", 1, v.asLong());
-	v = v1.getType().getALU(wordSize).logicalOr(v1, ptr, memory);
+	v = v1.getType().getALU(wordSize).logicalOr(v1, ptr);
 	assertEquals ("ptr || 4", 1, v.asLong());	
-	v =  t.getALU(8).logicalNegation(ptr, memory);
+	v =  t.getALU(8).logicalNegation(ptr);
 	assertEquals("!ptr", 0, v.asLong());
     }  
 }


hooks/post-receive
--
frysk system monitor/debugger



More information about the Frysk-cvs mailing list