This is the mail archive of the frysk-cvs@sources.redhat.com mailing list for the frysk project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[SCM] frysk system monitor/debugger branch, master, updated. 17c8a7ffe15ebae6973d44ba9dcf9d35487d89bc


The branch, master has been updated
       via  17c8a7ffe15ebae6973d44ba9dcf9d35487d89bc (commit)
       via  edeb2f82b0415eac3261fa50a4ce1862212b5d1e (commit)
      from  6c1b2134a1081b7d65f0656fcc13a9ae85d964f9 (commit)

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

- Log -----------------------------------------------------------------
commit 17c8a7ffe15ebae6973d44ba9dcf9d35487d89bc
Author: Teresa Thomas <tthomas@redhat.com>
Date:   Tue Nov 6 15:40:02 2007 -0500

    Implement -, -= operators in Arithmetic Unit.
    
    frysk-core/frysk/value/ChangeLog
    2007-11-06  Teresa Thomas  <tthomas@redhat.com>
    
    	* ArithmeticUnit.java (subtract): New.
    	(minusEqual): New.
    	* AddressUnit.java (subtract): New.
    	* IntegerUnit.java (subtract): New.
    	* FloatingPointUnit.java (subtract): New.
    	* Type.java (subtract): Delete.
    	(minusEqual): Delete.
    	* ArithmeticType.java (subtract): Delete.
    	(minusEqual): Delete.
    	* TypeDecorator.java (subtract): Delete.
    	(minusEqual): Delete.
    	* TestValue.java: Updated.
    
    frysk-core/frysk/expr/ChangeLog
    2007-11-06  Teresa Thomas  <tthomas@redhat.com>
    
    	* CExprEvaluator.g (MINUS): Use Arithmetic Unit.
    	(MINUSEQUAL): Ditto.

commit edeb2f82b0415eac3261fa50a4ce1862212b5d1e
Author: Teresa Thomas <tthomas@redhat.com>
Date:   Tue Nov 6 15:31:41 2007 -0500

    Double dispatch for ALU simplified.
    
    frysk-core/frysk/value/ChangeLog
    2007-11-06  Teresa Thomas  <tthomas@redhat.com>
    
    	* IntegerType.java: Double dispatch for ALU simplified.
    	* ArrayType.java: Ditto.
    	* PointerType.java: Ditto.
    	* FloatingPointType.java: Ditto.
    	* Type.java: Updated.

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

Summary of changes:
 frysk-core/frysk/expr/CExprEvaluator.g        |   14 ++++++++------
 frysk-core/frysk/expr/ChangeLog               |    5 +++++
 frysk-core/frysk/value/AddressUnit.java       |   12 ++++++++++--
 frysk-core/frysk/value/ArithmeticType.java    |   14 --------------
 frysk-core/frysk/value/ArithmeticUnit.java    |    6 ++++++
 frysk-core/frysk/value/ArrayType.java         |    6 +-----
 frysk-core/frysk/value/ChangeLog              |   21 +++++++++++++++++++++
 frysk-core/frysk/value/FloatingPointType.java |   10 +++++-----
 frysk-core/frysk/value/FloatingPointUnit.java |    5 +++++
 frysk-core/frysk/value/IntegerType.java       |   18 +++++++++---------
 frysk-core/frysk/value/IntegerUnit.java       |    5 +++++
 frysk-core/frysk/value/PointerType.java       |   11 +++++++----
 frysk-core/frysk/value/TestValue.java         |    8 ++++----
 frysk-core/frysk/value/Type.java              |   13 +++++++------
 frysk-core/frysk/value/TypeDecorator.java     |    6 ------
 15 files changed, 93 insertions(+), 61 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/expr/CExprEvaluator.g b/frysk-core/frysk/expr/CExprEvaluator.g
index 0ed0db0..d5bf068 100644
--- a/frysk-core/frysk/expr/CExprEvaluator.g
+++ b/frysk-core/frysk/expr/CExprEvaluator.g
@@ -145,11 +145,17 @@ expr returns [Value returnVar=null]
                         .plusEqual(v1, v2);
         }        
     |   ( #(MINUS expr expr) )=> #(MINUS v1=expr v2=expr) {
-            returnVar = v1.getType().subtract(v1, v2);  
+            returnVar = v1.getType().getALU(v2.getType(), exprSymTab.getWordSize())
+                        .subtract(v1, v2);  
         }
+    |   #(MINUSEQUAL v1=expr v2=expr)  {
+            returnVar = v1.getType().getALU(v2.getType(), exprSymTab.getWordSize())
+                        .minusEqual(v1, v2);
+        }        
     |   #(MINUS v1=expr ) {
             returnVar = intType.createValue(0);
-            returnVar = returnVar.getType().subtract(returnVar, v1); 
+            returnVar = returnVar.getType().getALU(v1.getType(), exprSymTab.getWordSize())
+                        .subtract(returnVar, v1); 
         }
     |   ( #(STAR expr expr) )=> #(STAR  v1=expr v2=expr) {
             returnVar = v1.getType().multiply(v1, v2); 
@@ -266,10 +272,6 @@ expr returns [Value returnVar=null]
             v1.getType().divideEqual(v1, v2);
             returnVar = v1;
         }
-    |   #(MINUSEQUAL v1=expr v2=expr)  {
-            v1.getType().minusEqual(v1, v2);
-            returnVar = v1;
-        }
     |   #(MODEQUAL v1=expr v2=expr)  {
             v1.getType().modEqual(v1, v2);
             returnVar = v1;
diff --git a/frysk-core/frysk/expr/ChangeLog b/frysk-core/frysk/expr/ChangeLog
index 82ee63c..1f93590 100644
--- a/frysk-core/frysk/expr/ChangeLog
+++ b/frysk-core/frysk/expr/ChangeLog
@@ -1,3 +1,8 @@
+2007-11-06  Teresa Thomas  <tthomas@redhat.com>
+	
+	* CExprEvaluator.g (MINUS): Use Arithmetic Unit.
+	(MINUSEQUAL): Ditto.
+	
 2007-11-05  Teresa Thomas  <tthomas@redhat.com>
 
 	* CExprEvaluator.g (INDEX): Update.
diff --git a/frysk-core/frysk/value/AddressUnit.java b/frysk-core/frysk/value/AddressUnit.java
index 9c60d05..cf2b316 100644
--- a/frysk-core/frysk/value/AddressUnit.java
+++ b/frysk-core/frysk/value/AddressUnit.java
@@ -47,9 +47,10 @@ public class AddressUnit
 extends ArithmeticUnit
 {
     public AddressUnit (ArrayType t, int wordSize) {
-	    retType = new PointerType(t.getName(), ByteOrder.BIG_ENDIAN, 
-		                      wordSize, t.getType());
+	retType = new PointerType(t.getName(), ByteOrder.BIG_ENDIAN, 
+		                  wordSize, t.getType());
     }
+    
     public AddressUnit (PointerType t) {
 	retType = t;
     }
@@ -107,4 +108,11 @@ extends ArithmeticUnit
         (arrValue.getLocation().getAddress() + arrType.getType().getSize()*intValue.asLong());        
 
     }  
+    
+    public Value subtract(Value v1, Value v2) {	
+	// v1-v2 = v1+(-v2)
+	Location l = new ScratchLocation (v2.asBigInteger().negate().toByteArray());
+	Value v2Neg = new Value (v2.getType(), l);
+	return add (v1, v2Neg);
+    }
 }
\ No newline at end of file
diff --git a/frysk-core/frysk/value/ArithmeticType.java b/frysk-core/frysk/value/ArithmeticType.java
index d67ccb1..8a2ee4d 100644
--- a/frysk-core/frysk/value/ArithmeticType.java
+++ b/frysk-core/frysk/value/ArithmeticType.java
@@ -118,16 +118,6 @@ public abstract class ArithmeticType
 	    }
 	}
     }
-    
-    public Value subtract(Value var1, Value var2) {
-	ArithmeticType type = returnType(var1, var2);
-	if (type instanceof IntegerType)
-	    return type.createValue(var1.asLong() - var2.asLong());
-	else if (type instanceof FloatingPointType)
-	    return type.createValue(var1.doubleValue() - var2.doubleValue());
-	else
-	    throw new RuntimeException("type conversion botch");
-    }
 
     public Value multiply(Value var1, Value var2) {
 	ArithmeticType type = returnType(var1, var2);
@@ -297,10 +287,6 @@ public abstract class ArithmeticType
 	return var1.assign(var2);
     }
 
-    public Value minusEqual(Value var1, Value var2) {
-	return var1.assign(subtract(var1, var2));
-    }
-
     public Value timesEqual(Value var1, Value var2) {
 	return var1.assign(multiply(var1, var2));
     }
diff --git a/frysk-core/frysk/value/ArithmeticUnit.java b/frysk-core/frysk/value/ArithmeticUnit.java
index e4ca07e..c8aae93 100644
--- a/frysk-core/frysk/value/ArithmeticUnit.java
+++ b/frysk-core/frysk/value/ArithmeticUnit.java
@@ -48,7 +48,13 @@ public abstract class ArithmeticUnit
     
     public abstract Value add(Value v1, Value v2);
     
+    public abstract Value subtract(Value v1, Value v2);
+    
     public Value plusEqual(Value v1, Value v2) {
 	return v1.assign(add(v1, v2));
     }
+    
+    public Value minusEqual(Value v1, Value v2) {
+	return v1.assign(subtract(v1, v2));
+    }
 }
\ No newline at end of file
diff --git a/frysk-core/frysk/value/ArrayType.java b/frysk-core/frysk/value/ArrayType.java
index 9266a9b..6eb0893 100644
--- a/frysk-core/frysk/value/ArrayType.java
+++ b/frysk-core/frysk/value/ArrayType.java
@@ -223,11 +223,7 @@ public class ArrayType
 	return new AddressUnit(this, wordSize);
     }   
     
-    public ArithmeticUnit getALU(FloatingPointType type, int wordSize) {
+    public ArithmeticUnit getALU(PointerType type, int wordSize) {
 	throw new RuntimeException("Invalid Pointer Arithmetic");
     }
-    
-    public ArithmeticUnit getALU(PointerType type) {
-	throw new RuntimeException("Invalid Pointer Arithmetic");
-    }     
 }
diff --git a/frysk-core/frysk/value/ChangeLog b/frysk-core/frysk/value/ChangeLog
index 9383af9..188cec8 100644
--- a/frysk-core/frysk/value/ChangeLog
+++ b/frysk-core/frysk/value/ChangeLog
@@ -1,3 +1,24 @@
+2007-11-06  Teresa Thomas  <tthomas@redhat.com>
+
+	* ArithmeticUnit.java (subtract): New.
+	(minusEqual): New.	
+	* AddressUnit.java (subtract): New.
+	* IntegerUnit.java (subtract): New.
+	* FloatingPointUnit.java (subtract): New.	
+	* Type.java (subtract): Delete.
+	(minusEqual): Delete.
+	* ArithmeticType.java (subtract): Delete.
+	(minusEqual): Delete.	
+	* TypeDecorator.java (subtract): Delete.
+	(minusEqual): Delete.
+	* TestValue.java: Updated.	
+
+	* IntegerType.java: Double dispatch for ALU simplified.
+	* ArrayType.java: Ditto.
+	* PointerType.java: Ditto.
+	* FloatingPointType.java: Ditto.	
+	* Type.java: Updated.
+
 2007-11-05  Sami Wagiaalla  <swagiaal@redhat.com>
 
 	* CompositeType.java (add): Added javadoc.
diff --git a/frysk-core/frysk/value/FloatingPointType.java b/frysk-core/frysk/value/FloatingPointType.java
index 245043e..f20a8e8 100644
--- a/frysk-core/frysk/value/FloatingPointType.java
+++ b/frysk-core/frysk/value/FloatingPointType.java
@@ -98,14 +98,14 @@ public class FloatingPointType
     }
     
     public ArithmeticUnit getALU(IntegerType type, int wordSize) {
-	// FIXME: Should this be resolved by a double 
-	// dispatch of IntegerType?
-	if (type instanceof PointerType)
-	    throw new RuntimeException("Invalid Pointer Arithmetic");
 	return new FloatingPointUnit(this);
     }
     
     public ArithmeticUnit getALU(FloatingPointType type, int wordSize) {
 	return new FloatingPointUnit(this, type);
-    }        
+    }   
+    
+    public ArithmeticUnit getALU(PointerType type, int wordSize) {
+	throw new RuntimeException("Invalid Pointer Arithmetic");
+    }    
 }
diff --git a/frysk-core/frysk/value/FloatingPointUnit.java b/frysk-core/frysk/value/FloatingPointUnit.java
index c921b2e..f10a103 100644
--- a/frysk-core/frysk/value/FloatingPointUnit.java
+++ b/frysk-core/frysk/value/FloatingPointUnit.java
@@ -58,4 +58,9 @@ public class FloatingPointUnit
 	return retType.createValue
 	               (v1.doubleValue() + v2.doubleValue());
     }    
+    
+    public Value subtract(Value v1, Value v2) {
+	return retType.createValue
+	               (v1.doubleValue() - v2.doubleValue());
+    }  
 }    
\ No newline at end of file
diff --git a/frysk-core/frysk/value/IntegerType.java b/frysk-core/frysk/value/IntegerType.java
index 1dd3b84..73cb5c4 100644
--- a/frysk-core/frysk/value/IntegerType.java
+++ b/frysk-core/frysk/value/IntegerType.java
@@ -82,19 +82,19 @@ public abstract class IntegerType
 	return type.getALU(this, wordSize);
     }
     
-    public ArithmeticUnit getALU(PointerType type, int wordSize) {
-	return new AddressUnit(type);
-    }
-    
     public ArithmeticUnit getALU(IntegerType type, int wordSize) {
-	// FIXME: Should this be resolved by a double 
-	// dispatch of IntegerType?
-	if (type instanceof PointerType)
-	    return new AddressUnit((PointerType)type);
 	return new IntegerUnit(this, type);
     }
     
+    public ArithmeticUnit getALU(PointerType type, int wordSize) {
+	return new AddressUnit((PointerType)type);
+    }
+    
     public ArithmeticUnit getALU(FloatingPointType type, int wordSize) {
 	return new FloatingPointUnit(type);
-    }    
+    }   
+
+    public ArithmeticUnit getALU(ArrayType type, int wordSize) {
+	return new AddressUnit(type, wordSize);
+    }  
 }
diff --git a/frysk-core/frysk/value/IntegerUnit.java b/frysk-core/frysk/value/IntegerUnit.java
index 33a663b..32defa8 100644
--- a/frysk-core/frysk/value/IntegerUnit.java
+++ b/frysk-core/frysk/value/IntegerUnit.java
@@ -55,4 +55,9 @@ public class IntegerUnit
 	return retType.createValue
 	               (v1.asBigInteger().add(v2.asBigInteger()));
     }
+    
+    public Value subtract(Value v1, Value v2) {
+	return retType.createValue
+	               (v1.asBigInteger().subtract(v2.asBigInteger()));
+    }
 }
\ No newline at end of file
diff --git a/frysk-core/frysk/value/PointerType.java b/frysk-core/frysk/value/PointerType.java
index 42e58c2..a0e5743 100644
--- a/frysk-core/frysk/value/PointerType.java
+++ b/frysk-core/frysk/value/PointerType.java
@@ -129,7 +129,6 @@ public class PointerType
 	Value offset = createValue (v.asLong() + idx.asLong()*type.getSize());
 	return dereference (offset, taskMem) ;      
     }    
-    
 
     public ArithmeticUnit getALU(Type type, int wordSize) {
 	return type.getALU(this, wordSize);
@@ -139,11 +138,15 @@ public class PointerType
 	return new AddressUnit(this);
     }   
     
+    public ArithmeticUnit getALU(PointerType type, int wordSize) {
+	throw new RuntimeException("Invalid Pointer Arithmetic");
+    } 
+    
     public ArithmeticUnit getALU(FloatingPointType type, int wordSize) {
 	throw new RuntimeException("Invalid Pointer Arithmetic");
-    }
+    } 
     
-    public ArithmeticUnit getALU(PointerType type, int wordSize) {
+    public ArithmeticUnit getALU(ArrayType type, int wordSize) {
 	throw new RuntimeException("Invalid Pointer Arithmetic");
-    }     
+    }
 }
diff --git a/frysk-core/frysk/value/TestValue.java b/frysk-core/frysk/value/TestValue.java
index 36e776e..7dbf48c 100644
--- a/frysk-core/frysk/value/TestValue.java
+++ b/frysk-core/frysk/value/TestValue.java
@@ -104,7 +104,7 @@ public class TestValue
 	Value v2 = shortType.createValue(9);
 	Value v3 = v1.getType().getALU(v2.getType(), 0).add(v1, v2);
 	assertEquals ("4 + 9", 4 + 9, v3.asLong());	
-	v3 = v1.getType().subtract(v2, v1);
+	v3 = v1.getType().getALU(v2.getType(), 0).subtract(v2, v1);
 	assertEquals ("9 - 4", 9 - 4, v3.asLong());
 	v3 = v1.getType().multiply(v2, v1);
 	assertEquals ("9 * 4", 9 * 4, v3.asLong());
@@ -142,7 +142,7 @@ public class TestValue
 	assertEquals ("v3 = 4", 4, v3.asLong());
 	v3 = v1.getType().getALU(v2.getType(), 0).plusEqual(v3, v1);
 	assertEquals ("v3 += 4", 8, v3.asLong());	
-	v3 = v1.getType().minusEqual(v3, v1);
+	v3 = v1.getType().getALU(v2.getType(), 0).minusEqual(v3, v1);
 	assertEquals ("v3 -= 4", 4, v3.asLong());
 	v3 = v1.getType().timesEqual(v3, v1);
 	assertEquals ("v3 *= 4", 16, v3.asLong());
@@ -168,7 +168,7 @@ public class TestValue
 	Value v2 = doubleType.createValue(9.0);
 	Value v3 = v1.getType().getALU(v2.getType(), 0).add(v1, v2);	
 	assertEquals ("4 + 9", 4 + 9, v3.doubleValue(), 0);
-	v3 = v1.getType().subtract(v2, v1);
+	v3 = v1.getType().getALU(v2.getType(), 0).subtract(v2, v1);
 	assertEquals ("9 - 4", 9 - 4, v3.doubleValue(), 0);
 	v3 = v1.getType().multiply(v2, v1);
 	assertEquals ("9 * 4", 9 * 4, v3.doubleValue(), 0);
@@ -190,7 +190,7 @@ public class TestValue
 	assertEquals ("v3 = 4", 4, v3.doubleValue(), 0);
 	v3 = v1.getType().getALU(v3.getType(), 0).plusEqual(v3, v1);
 	assertEquals ("v3 += 4", 8, v3.doubleValue(), 0);	
-	v3 = v1.getType().minusEqual(v3, v1);
+	v3 = v1.getType().getALU(v2.getType(), 0).minusEqual(v3, v1);
 	assertEquals ("v3 -= 4", 4, v3.doubleValue(), 0);
 	v3 = v1.getType().timesEqual(v3, v1);
 	assertEquals ("v3 *= 4", 16, v3.doubleValue(), 0);
diff --git a/frysk-core/frysk/value/Type.java b/frysk-core/frysk/value/Type.java
index b39e949..cb204aa 100644
--- a/frysk-core/frysk/value/Type.java
+++ b/frysk-core/frysk/value/Type.java
@@ -137,9 +137,13 @@ public abstract class Type {
     public ArithmeticUnit getALU(FloatingPointType type, int wordSize){
 	throw new RuntimeException("Invalid Arithmetic Unit");
     }
-    public Value subtract (Value var1, Value var2) {
-        throw new InvalidOperatorException(this, "-");
-    }
+    public ArithmeticUnit getALU(PointerType type, int wordSize) {
+	throw new RuntimeException("Invalid Arithmetic Unit");
+    }    
+    public ArithmeticUnit getALU(ArrayType type, int wordSize) {
+	throw new RuntimeException("Invalid Arithmetic Unit");
+    }  
+    
     public Value multiply (Value var1, Value var2) {
         throw new InvalidOperatorException(this, "*");
     }
@@ -203,9 +207,6 @@ public abstract class Type {
     public Value modEqual (Value var1, Value var2) {
         throw new InvalidOperatorException(this, "%=");
     }
-    public Value minusEqual (Value var1, Value var2) {
-        throw new InvalidOperatorException(this, "-=");
-    }
     public Value shiftLeftEqual (Value var1, Value var2) {
         throw new InvalidOperatorException(this, "<<=");
     }
diff --git a/frysk-core/frysk/value/TypeDecorator.java b/frysk-core/frysk/value/TypeDecorator.java
index 5e928e2..30e2fc7 100644
--- a/frysk-core/frysk/value/TypeDecorator.java
+++ b/frysk-core/frysk/value/TypeDecorator.java
@@ -89,9 +89,6 @@ abstract class TypeDecorator extends Type {
 	      decorated.toPrint(writer);
 	  }
 	}
-	public Value subtract(Value var1, Value var2) {
-		return decorated.subtract(var1, var2);
-	}
 	public Value multiply(Value var1, Value var2) {
 		return decorated.multiply(var1, var2);
 	}
@@ -155,9 +152,6 @@ abstract class TypeDecorator extends Type {
 	public Value modEqual(Value var1, Value var2) {
 		return decorated.modEqual(var1, var2);
 	}
-	public Value minusEqual(Value var1, Value var2) {
-		return decorated.minusEqual(var1, var2);
-	}
 	public Value shiftLeftEqual(Value var1, Value var2) {
 		return decorated.shiftLeftEqual(var1, var2);
 	}


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]