develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34668 - trunk/src/pmc

From:
tewk
Date:
December 30, 2008 12:51
Subject:
[svn:parrot] r34668 - trunk/src/pmc
Message ID:
20081230205056.7F237CB9FA@x12.develooper.com
Author: tewk
Date: Tue Dec 30 12:50:55 2008
New Revision: 34668

Modified:
   trunk/src/pmc/fixedstringarray.pmc
   trunk/src/pmc/string.pmc

Log:
[core] added get_repr to FixedStringArray and added get_repr to String

Modified: trunk/src/pmc/fixedstringarray.pmc
==============================================================================
--- trunk/src/pmc/fixedstringarray.pmc	(original)
+++ trunk/src/pmc/fixedstringarray.pmc	Tue Dec 30 12:50:55 2008
@@ -475,6 +475,37 @@
 
 /*
 
+=item C<STRING *get_repr()>
+
+Returns the Parrot string representation C<key>.
+
+=cut
+
+*/
+
+    VTABLE STRING *get_repr() {
+        STRING *res    = CONST_STRING(INTERP, "[ ");
+        const INTVAL n = SELF.get_integer();
+        INTVAL  j;
+
+        for (j = 0; j < n; ++j) {
+            PMC * const val = SELF.get_pmc_keyed_int(j);
+            res = string_append(INTERP, res, CONST_STRING(INTERP, "\""));
+            res = string_append(INTERP, res, VTABLE_get_repr(INTERP, val));
+            res = string_append(INTERP, res, CONST_STRING(INTERP, "\""));
+
+            if (j < n - 1)
+                res = string_append(INTERP, res, CONST_STRING(INTERP, ", "));
+        }
+
+        res = string_append(INTERP, res, CONST_STRING(INTERP, " ]"));
+        return res;
+    }
+
+
+
+/*
+
 =back
 
 =head2 Freeze/thaw Interface

Modified: trunk/src/pmc/string.pmc
==============================================================================
--- trunk/src/pmc/string.pmc	(original)
+++ trunk/src/pmc/string.pmc	Tue Dec 30 12:50:55 2008
@@ -977,7 +977,7 @@
     }
 
     VTABLE STRING* get_repr() {
-        return key_set_to_string(INTERP, SELF);
+        return VTABLE_get_string(INTERP, SELF);
     }
 
 /*



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About