public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
* [SCM] master: Implement logical negation (!) for float and Address Types.
@ 2007-11-13 19:59 tthomas
0 siblings, 0 replies; only message in thread
From: tthomas @ 2007-11-13 19:59 UTC (permalink / raw)
To: frysk-cvs
The branch, master has been updated
via fc228ee2d3554182856206ca08158e551ed5dfcb (commit)
via 9fd6262cfe554b85e3333b6b46d0988729ae1a25 (commit)
via c3260297538be6ea92f807cf3192dfbef1c0b8f1 (commit)
from b9945ac4ff2ab204f6c340a90bbaba11f8265266 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email.
- Log -----------------------------------------------------------------
commit fc228ee2d3554182856206ca08158e551ed5dfcb
Author: Teresa Thomas <tthomas@redhat.com>
Date: Tue Nov 13 14:49:36 2007 -0500
Implement logical negation (!) for float and Address Types.
frysk-core/frysk/value/ChangeLog
2007-11-13 Teresa Thomas <tthomas@redhat.com>
* ArithmeticUnit.java (logicalNegation): Add task mem to
parmeter list.
* IntegerUnit.java (logicalNegation): Update.
* AddressUnit.java (logicalNegation): New.
* FloatingPointUnit.java (logicalNegation): New.
* TestValue.java (testFloatOps): Test for above.
(testAddressOps): New.
frysk-core/frysk/pkglibdir/ChangeLog
2007-11-13 Teresa Thomas <tthomas@redhat.com>
* funit-addresses.c (ptr): New.
ase enter the commit message for your changes.
commit 9fd6262cfe554b85e3333b6b46d0988729ae1a25
Merge: c3260297538be6ea92f807cf3192dfbef1c0b8f1 b9945ac4ff2ab204f6c340a90bbaba11f8265266
Author: Teresa Thomas <tthomas@redhat.com>
Date: Tue Nov 13 14:43:43 2007 -0500
Merge branch 'master' of ssh://sources.redhat.com/git/frysk
commit c3260297538be6ea92f807cf3192dfbef1c0b8f1
Author: Teresa Thomas <tthomas@redhat.com>
Date: Tue Nov 13 14:40:13 2007 -0500
Add new getALU with no type arguments. Use for unary operations.
frysk-core/frysk/expr/ChangeLog
2007-11-13 Teresa Thomas <tthomas@redhat.com>
* CExprEvaluator.g: Update.
frysk-core/frysk/value/ChangeLog
2007-11-13 Teresa Thomas <tthomas@redhat.com>
* ArrayType.java (getALU): New.
* PointerType.java (getALU): New.
* Type.java (getALU): New.
* FloatingPointType.java (getALU): New.
* IntegerType.java (getALU): New.
* IntegerUnit.java (IntegerUnit): New.
-----------------------------------------------------------------------
Summary of changes:
frysk-core/frysk/expr/CExprEvaluator.g | 9 ++++-----
frysk-core/frysk/expr/ChangeLog | 4 ++++
frysk-core/frysk/pkglibdir/ChangeLog | 4 ++++
frysk-core/frysk/pkglibdir/funit-addresses.c | 3 ++-
frysk-core/frysk/value/AddressUnit.java | 6 ++++++
frysk-core/frysk/value/ArithmeticUnit.java | 3 ++-
frysk-core/frysk/value/ArrayType.java | 4 ++++
frysk-core/frysk/value/ChangeLog | 17 +++++++++++++++++
frysk-core/frysk/value/FloatingPointType.java | 4 ++++
frysk-core/frysk/value/FloatingPointUnit.java | 11 ++++++++++-
frysk-core/frysk/value/IntegerType.java | 4 ++++
frysk-core/frysk/value/IntegerUnit.java | 12 +++++++++++-
frysk-core/frysk/value/PointerType.java | 4 ++++
frysk-core/frysk/value/TestValue.java | 21 ++++++++++++++++++++-
frysk-core/frysk/value/Type.java | 4 ++++
15 files changed, 100 insertions(+), 10 deletions(-)
First 500 lines of diff:
diff --git a/frysk-core/frysk/expr/CExprEvaluator.g b/frysk-core/frysk/expr/CExprEvaluator.g
index 411e134..4f06c19 100644
--- a/frysk-core/frysk/expr/CExprEvaluator.g
+++ b/frysk-core/frysk/expr/CExprEvaluator.g
@@ -266,13 +266,12 @@ expr returns [Value returnVar=null]
.logicalOr(v1, v2);
}
| #(NOT v1=expr) {
- returnVar = v1.getType().getALU(v1.getType(),
- exprSymTab.getWordSize())
- .logicalNegation(v1);
+ // byte buffer needed for Pointer/Address types
+ returnVar = v1.getType().getALU(exprSymTab.getWordSize())
+ .logicalNegation(v1, exprSymTab.taskMemory());
}
| #(TILDE v1=expr) {
- returnVar = v1.getType().getALU(v1.getType(),
- exprSymTab.getWordSize())
+ returnVar = v1.getType().getALU(exprSymTab.getWordSize())
.bitWiseComplement(v1);
}
| #(COND_EXPR log_expr=expr v1=expr v2=expr) {
diff --git a/frysk-core/frysk/expr/ChangeLog b/frysk-core/frysk/expr/ChangeLog
index 24693ab..4d06e8a 100644
--- a/frysk-core/frysk/expr/ChangeLog
+++ b/frysk-core/frysk/expr/ChangeLog
@@ -1,3 +1,7 @@
+2007-11-13 Teresa Thomas <tthomas@redhat.com>
+
+ * CExprEvaluator.g: Update.
+
2007-11-09 Teresa Thomas <tthomas@redhat.com>
* CExprEvaluator.g: Update evaluator to
diff --git a/frysk-core/frysk/pkglibdir/ChangeLog b/frysk-core/frysk/pkglibdir/ChangeLog
index 891af0c..ea6107a 100644
--- a/frysk-core/frysk/pkglibdir/ChangeLog
+++ b/frysk-core/frysk/pkglibdir/ChangeLog
@@ -1,3 +1,7 @@
+2007-11-13 Teresa Thomas <tthomas@redhat.com>
+
+ * funit-addresses.c (ptr): New.
+
2007-11-12 Andrew Cagney <cagney@redhat.com>
* funit-stack-inlined.c: Rename funit-inlined.c
diff --git a/frysk-core/frysk/pkglibdir/funit-addresses.c b/frysk-core/frysk/pkglibdir/funit-addresses.c
index a0422a2..e35142d 100644
--- a/frysk-core/frysk/pkglibdir/funit-addresses.c
+++ b/frysk-core/frysk/pkglibdir/funit-addresses.c
@@ -62,7 +62,8 @@ int twoD[2][3] = { {99, 88, 77},
{11, 12, 13},
};
int oneD[] = { 4, 3, 2, 1};
-char* string = "hello world\n";
+char* string = "hello world";
+int* ptr = NULL;
int main(int argc, char* argv[])
{
diff --git a/frysk-core/frysk/value/AddressUnit.java b/frysk-core/frysk/value/AddressUnit.java
index 5f9b8f5..8917459 100644
--- a/frysk-core/frysk/value/AddressUnit.java
+++ b/frysk-core/frysk/value/AddressUnit.java
@@ -40,6 +40,7 @@
package frysk.value;
import inua.eio.ByteOrder;
+import inua.eio.ByteBuffer;
/**
* Operation handling for pointers and addresses.
*/
@@ -123,4 +124,9 @@ extends ArithmeticUnit
Value v2Neg = new Value (v2.getType(), l);
return add (v1, v2Neg);
}
+
+ public Value logicalNegation(Value v1, ByteBuffer mem) {
+ return intType.createValue
+ (v1.toPrint(Format.NATURAL, mem).equals("0x0")? 1:0);
+ }
}
\ No newline at end of file
diff --git a/frysk-core/frysk/value/ArithmeticUnit.java b/frysk-core/frysk/value/ArithmeticUnit.java
index e68df96..acfe985 100644
--- a/frysk-core/frysk/value/ArithmeticUnit.java
+++ b/frysk-core/frysk/value/ArithmeticUnit.java
@@ -40,6 +40,7 @@
package frysk.value;
import inua.eio.ByteOrder;
+import inua.eio.ByteBuffer;
/**
* Arithmetic and Logical Operation handling
@@ -148,7 +149,7 @@ public abstract class ArithmeticUnit
throw new InvalidOperatorException
(v1.getType(), v2.getType(), "||");
}
- public Value logicalNegation(Value v1) {
+ public Value logicalNegation(Value v1, ByteBuffer mem) {
throw new InvalidOperatorException
(v1.getType(), "!");
}
diff --git a/frysk-core/frysk/value/ArrayType.java b/frysk-core/frysk/value/ArrayType.java
index 12d2480..7813722 100644
--- a/frysk-core/frysk/value/ArrayType.java
+++ b/frysk-core/frysk/value/ArrayType.java
@@ -264,4 +264,8 @@ public class ArrayType
public ArithmeticUnit getALU(PointerType type, int wordSize) {
throw new RuntimeException("Invalid Pointer Arithmetic");
}
+ // Use for unary operations.
+ public ArithmeticUnit getALU(int wordSize) {
+ return new AddressUnit(this, wordSize);
+ }
}
diff --git a/frysk-core/frysk/value/ChangeLog b/frysk-core/frysk/value/ChangeLog
index 9744fcc..43d1291 100644
--- a/frysk-core/frysk/value/ChangeLog
+++ b/frysk-core/frysk/value/ChangeLog
@@ -1,3 +1,20 @@
+2007-11-13 Teresa Thomas <tthomas@redhat.com>
+
+ * ArithmeticUnit.java (logicalNegation): Add task mem to
+ parmeter list.
+ * IntegerUnit.java (logicalNegation): Update.
+ * AddressUnit.java (logicalNegation): New.
+ * FloatingPointUnit.java (logicalNegation): New.
+ * TestValue.java (testFloatOps): Test for above.
+ (testAddressOps): New.
+
+ * ArrayType.java (getALU): New.
+ * PointerType.java (getALU): New.
+ * Type.java (getALU): New.
+ * FloatingPointType.java (getALU): New.
+ * IntegerType.java (getALU): New.
+ * IntegerUnit.java (IntegerUnit): New.
+
2007-11-12 Teresa Thomas <tthomas@redhat.com>
* ArithmeticUnit.java (intType): New.
diff --git a/frysk-core/frysk/value/FloatingPointType.java b/frysk-core/frysk/value/FloatingPointType.java
index f0456d2..63aa570 100644
--- a/frysk-core/frysk/value/FloatingPointType.java
+++ b/frysk-core/frysk/value/FloatingPointType.java
@@ -108,4 +108,8 @@ public class FloatingPointType
public ArithmeticUnit getALU(PointerType type, int wordSize) {
throw new RuntimeException("Invalid Pointer Arithmetic");
}
+ // Use for unary operations.
+ public ArithmeticUnit getALU(int wordSize) {
+ return new FloatingPointUnit(this, wordSize);
+ }
}
diff --git a/frysk-core/frysk/value/FloatingPointUnit.java b/frysk-core/frysk/value/FloatingPointUnit.java
index c7bee21..3e1ff5e 100644
--- a/frysk-core/frysk/value/FloatingPointUnit.java
+++ b/frysk-core/frysk/value/FloatingPointUnit.java
@@ -38,6 +38,7 @@
// exception.
package frysk.value;
+import inua.eio.ByteBuffer;
/**
* Arithmetic and logical operation handling
@@ -101,5 +102,13 @@ public class FloatingPointUnit
public Value notEqual (Value v1, Value v2) {
return retType.createValue
(v1.doubleValue() != v2.doubleValue() ? 1:0);
- }
+ }
+
+ /**
+ * @param mem - unused here.
+ */
+ public Value logicalNegation(Value v1, ByteBuffer mem) {
+ return intType.createValue
+ (v1.doubleValue() == 0.0? 1 : 0);
+ }
}
\ No newline at end of file
diff --git a/frysk-core/frysk/value/IntegerType.java b/frysk-core/frysk/value/IntegerType.java
index 28ed015..db9166b 100644
--- a/frysk-core/frysk/value/IntegerType.java
+++ b/frysk-core/frysk/value/IntegerType.java
@@ -96,4 +96,8 @@ public abstract class IntegerType
public ArithmeticUnit getALU(ArrayType type, int wordSize) {
return new AddressUnit(type, wordSize);
}
+ // Use for unary operations.
+ public ArithmeticUnit getALU(int wordSize) {
+ return new IntegerUnit(this, wordSize);
+ }
}
diff --git a/frysk-core/frysk/value/IntegerUnit.java b/frysk-core/frysk/value/IntegerUnit.java
index 1f96e2c..e43adbd 100644
--- a/frysk-core/frysk/value/IntegerUnit.java
+++ b/frysk-core/frysk/value/IntegerUnit.java
@@ -40,6 +40,7 @@
package frysk.value;
import java.math.BigInteger;
+import inua.eio.ByteBuffer;
/**
* Arithmetic and logical Operation handling
@@ -55,6 +56,12 @@ public class IntegerUnit
retType = (t1.getSize() > t2.getSize()) ?
t1 : t2;
}
+
+ public IntegerUnit (IntegerType t1, int wordSize) {
+ super (wordSize);
+ // Return type should be the larger type.
+ retType = t1 ;
+ }
public Value add(Value v1, Value v2) {
return retType.createValue
@@ -138,7 +145,10 @@ public class IntegerUnit
((v1.asBigInteger().compareTo(BigInteger.ZERO) == 0 ? false : true)
|| (v1.asBigInteger().compareTo(BigInteger.ZERO) == 0 ? false : true) ? 1 : 0);
}
- public Value logicalNegation(Value v1) {
+ /**
+ * @ param mem - unused here.
+ */
+ public Value logicalNegation(Value v1, ByteBuffer mem) {
return retType.createValue
(v1.asBigInteger().compareTo(BigInteger.ZERO) == 0 ? 1 : 0);
}
diff --git a/frysk-core/frysk/value/PointerType.java b/frysk-core/frysk/value/PointerType.java
index d056ec1..5b238d7 100644
--- a/frysk-core/frysk/value/PointerType.java
+++ b/frysk-core/frysk/value/PointerType.java
@@ -148,4 +148,8 @@ public class PointerType
public ArithmeticUnit getALU(ArrayType type, int wordSize) {
throw new RuntimeException("Invalid Pointer Arithmetic");
}
+ // Use for unary operations.
+ public ArithmeticUnit getALU(int wordSize) {
+ return new AddressUnit(this, wordSize);
+ }
}
diff --git a/frysk-core/frysk/value/TestValue.java b/frysk-core/frysk/value/TestValue.java
index 13f6142..d8c8289 100644
--- a/frysk-core/frysk/value/TestValue.java
+++ b/frysk-core/frysk/value/TestValue.java
@@ -39,6 +39,7 @@
package frysk.value;
+import inua.eio.ArrayByteBuffer;
import inua.eio.ByteOrder;
import frysk.junit.TestCase;
@@ -140,7 +141,7 @@ public class TestValue
assertEquals ("9 & 4", 1, v3.asLong());
v3 = v1.getType().getALU(v2.getType(), 0).logicalOr(v2, v1);
assertEquals ("9 | 4", 1, v3.asLong());
- v3 = v1.getType().getALU(v1.getType(), 0).logicalNegation(v1);
+ v3 = v1.getType().getALU(v1.getType(), 0).logicalNegation(v1, null);
assertEquals ("!4", 0, v3.asLong());
bool = v2.getType().getALU(v2.getType(), 0).getLogicalValue(v2);
assertEquals ("bool(9)", true, bool);
@@ -205,5 +206,23 @@ 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.
+ v3 = v1.getType().getALU(v1.getType(), 0).logicalNegation(v1, null);
+ 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));
+ // Construct the pointer to it.
+ Location l = new ScratchLocation(new byte[] { 4 });
+ Value string = new Value (t, l);
+
+ Value v = t.getALU(8).logicalNegation(string, memory);
+ assertEquals("!string", 0, v.asLong());
+ }
}
diff --git a/frysk-core/frysk/value/Type.java b/frysk-core/frysk/value/Type.java
index 9188070..f61d137 100644
--- a/frysk-core/frysk/value/Type.java
+++ b/frysk-core/frysk/value/Type.java
@@ -142,11 +142,15 @@ public abstract class Type {
throw new RuntimeException("Invalid Arithmetic Unit");
}
public ArithmeticUnit getALU(PointerType type, int wordSize) {
+ System.out.println ("Type:PType");
throw new RuntimeException("Invalid Arithmetic Unit");
}
public ArithmeticUnit getALU(ArrayType type, int wordSize) {
throw new RuntimeException("Invalid Arithmetic Unit");
}
+ public ArithmeticUnit getALU(int wordSize) {
+ throw new RuntimeException("Invalid Arithmetic Unit");
+ }
public Value addressOf(Value var1, ByteOrder order, int wordSize) {
PointerType pType = new PointerType("AddressPtr", order, wordSize, this);
hooks/post-receive
--
frysk system monitor/debugger
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-11-13 19:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-13 19:59 [SCM] master: Implement logical negation (!) for float and Address Types tthomas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).