Author: leo
Date: Mon Aug 15 07:56:16 2005
New Revision: 8968

Modified:
   trunk/classes/key.pmc
   trunk/languages/tcl/classes/tclarray.pmc
Log:
Fix TclArray Iterator

* implement iterator code in get_pmc_keyed
* key.pmc checks now for isa('Hash') instead of explicit types


Modified: trunk/classes/key.pmc
==============================================================================
--- trunk/classes/key.pmc       (original)
+++ trunk/classes/key.pmc       Mon Aug 15 07:56:16 2005
@@ -281,6 +281,7 @@ PMC_int_val(-1) means end of iteration.
     PMC* nextkey_keyed (PMC* agg, INTVAL what) {
         INTVAL n = VTABLE_elements(INTERP, agg);
         PMC *ret = SELF;
+        STRING *_hash;
 
         switch (what) {
             case ITERATE_FROM_START_KEYS:
@@ -303,9 +304,8 @@ PMC_int_val(-1) means end of iteration.
                  * KEY_integer_FLAG alone is an indexed hash lookup
                  * with an Integer KEY
                  */
-                if (agg->vtable->base_type == enum_class_PerlHash)
-                    PObj_get_FLAGS(ret) |= KEY_hash_iterator_FLAGS;
-                if (agg->vtable->base_type == enum_class_Hash)
+                 _hash = CONST_STRING(interpreter, "Hash");
+                if (VTABLE_isa(INTERP, agg, _hash))
                     PObj_get_FLAGS(ret) |= KEY_hash_iterator_FLAGS;
         init:
                 PMC_int_val(ret) = 0;

Modified: trunk/languages/tcl/classes/tclarray.pmc
==============================================================================
--- trunk/languages/tcl/classes/tclarray.pmc    (original)
+++ trunk/languages/tcl/classes/tclarray.pmc    Mon Aug 15 07:56:16 2005
@@ -28,7 +28,7 @@ This is the Array PMC for the Tcl implem
 
 #include "parrot/parrot.h"
 
-static INTVAL dynclass_TclInt;
+static INTVAL dynclass_TclString;
 
 /*
 
@@ -65,7 +65,7 @@ Initializes variables needed by the clas
 
     void class_init () {
         if (pass) {
-            dynclass_TclInt = Parrot_PMC_typenum(INTERP,"TclInt");
+            dynclass_TclString = Parrot_PMC_typenum(INTERP,"TclString");
         }
     }
 
@@ -83,10 +83,19 @@ XXX - Why is Hash's implementation insuf
 
 
     PMC* get_pmc_keyed (PMC* key) {
-        STRING* keystr = make_hash_key(INTERP, key);
-        HashBucket *b = hash_get_bucket(INTERP, (Hash*) PMC_struct_val(SELF),
-                                        keystr);
-        PMC* nextkey;
+        STRING *s;
+        PMC* nextkey, *result;
+        Hash *hash = PMC_struct_val(SELF);
+        HashBucket *b;
+        switch (PObj_get_FLAGS(key) & KEY_type_FLAGS) {
+            case KEY_hash_iterator_FLAGS:
+                s = hash_get_idx(INTERP, hash, key);
+                result = pmc_new(INTERP, dynclass_TclString);
+                VTABLE_set_string_native(INTERP, result, s);
+                return result;
+        }
+        s = make_hash_key(INTERP, key);
+        b = hash_get_bucket(INTERP, hash, s);
         if (b == NULL) {
             return NULL;
         }

Reply via email to