public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
* [SCM]  master: Support expression index[arrayName].
@ 2007-11-08 20:39 tthomas
  0 siblings, 0 replies; only message in thread
From: tthomas @ 2007-11-08 20:39 UTC (permalink / raw)
  To: frysk-cvs

The branch, master has been updated
       via  92e9c47e02ab8b02ccd29dac7763d286d4652353 (commit)
      from  f0dd7a1f1381eb180a42ab7ddb9f56d717aa48ff (commit)

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

- Log -----------------------------------------------------------------
commit 92e9c47e02ab8b02ccd29dac7763d286d4652353
Author: Teresa Thomas <tthomas@redhat.com>
Date:   Thu Nov 8 15:38:17 2007 -0500

    Support expression index[arrayName].
    
    frysk-core/frysk/value/ChangeLog
    2007-11-08  Teresa Thomas  <tthomas@redhat.com>
    
    	* Type.java (index): Make operation commutative.
    	* TestArray.java (testIndexOneD): Add test for above.

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

Summary of changes:
 frysk-core/frysk/value/ChangeLog      |    5 +++++
 frysk-core/frysk/value/TestArray.java |    3 ++-
 frysk-core/frysk/value/Type.java      |    4 ++++
 3 files changed, 11 insertions(+), 1 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/value/ChangeLog b/frysk-core/frysk/value/ChangeLog
index 0906a1d..e696918 100644
--- a/frysk-core/frysk/value/ChangeLog
+++ b/frysk-core/frysk/value/ChangeLog
@@ -1,4 +1,9 @@
 2007-11-08  Teresa Thomas  <tthomas@redhat.com>
+
+	* Type.java (index): Make operation commutative.
+	* TestArray.java (testIndexOneD): Add test for above.	
+
+2007-11-08  Teresa Thomas  <tthomas@redhat.com>
 	
 	* AddressUnit.java (wordSize): New.
 	(add): Use wordSize for pointer creation.
diff --git a/frysk-core/frysk/value/TestArray.java b/frysk-core/frysk/value/TestArray.java
index 5706a02..25015c6 100644
--- a/frysk-core/frysk/value/TestArray.java
+++ b/frysk-core/frysk/value/TestArray.java
@@ -95,7 +95,8 @@ public class TestArray extends TestCase {
 	Location l = new ScratchLocation(new byte[] { 2 });
 	IntegerType t = new UnsignedType("type", ByteOrder.BIG_ENDIAN, 1);
 	Value index = new Value(t, l);
-	assertEquals("IndexOneD", 151653132, arrayType.index(arr, index, null).asLong());
+	assertEquals("Array[index]", 151653132, arrayType.index(arr, index, null).asLong());
+	assertEquals("Index[array]", 151653132, t.index(index, arr, null).asLong());	
     }
 
     /**
diff --git a/frysk-core/frysk/value/Type.java b/frysk-core/frysk/value/Type.java
index c13cb2e..7bfe22c 100644
--- a/frysk-core/frysk/value/Type.java
+++ b/frysk-core/frysk/value/Type.java
@@ -218,6 +218,10 @@ public abstract class Type {
     	throw new InvalidOperatorException(this, ".");
     } 
     public Value index(Value var1, Value var2, ByteBuffer taskMem) {
+	// In C, var1[var2] = var2[var1]
+	if (var2.getType() instanceof ArrayType || 
+	    var2.getType() instanceof PointerType)
+	    return var2.getType().index (var2, var1, taskMem);
     	throw new InvalidOperatorException(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-08 20:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-08 20:39 [SCM] master: Support expression index[arrayName] 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).