[svn:parrot] r39230 - in trunk: src/pmc t/pmc

pmichaud at svn.parrot.org pmichaud at svn.parrot.org
Fri May 29 04:40:52 UTC 2009


Author: pmichaud
Date: Fri May 29 04:40:52 2009
New Revision: 39230
URL: https://trac.parrot.org/parrot/changeset/39230

Log:
[core]  Add "get_subid" method to Sub PMC.

Modified:
   trunk/src/pmc/sub.pmc
   trunk/t/pmc/sub.t

Modified: trunk/src/pmc/sub.pmc
==============================================================================
--- trunk/src/pmc/sub.pmc	Fri May 29 00:28:36 2009	(r39229)
+++ trunk/src/pmc/sub.pmc	Fri May 29 04:40:52 2009	(r39230)
@@ -908,6 +908,15 @@
         RETURN(PMC *lexinfo);
     }
 
+    METHOD get_subid() {
+        Parrot_sub *sub;
+        STRING     *subid;
+
+        PMC_get_sub(INTERP, SELF, sub);
+        subid = sub->subid ? sub->subid : CONST_STRING(interp, "");
+        RETURN(STRING *subid);
+    }
+
     METHOD get_outer() {
         Parrot_sub *sub;
         PMC        *outersub;

Modified: trunk/t/pmc/sub.t
==============================================================================
--- trunk/t/pmc/sub.t	Fri May 29 00:28:36 2009	(r39229)
+++ trunk/t/pmc/sub.t	Fri May 29 04:40:52 2009	(r39230)
@@ -9,7 +9,7 @@
 use Test::More;
 use Parrot::Test::Util 'create_tempfile';
 
-use Parrot::Test tests => 68;
+use Parrot::Test tests => 69;
 use Parrot::Config;
 
 =head1 NAME
@@ -1589,6 +1589,39 @@
 lived
 OUTPUT
 
+pir_output_is( <<'CODE', <<'OUTPUT', '.get_subid' );
+.sub 'main'
+    .const 'Sub' foo = 'foo'
+    $S0 = foo.'get_subid'()
+    say $S0
+
+    $P0 = get_global 'bar'
+    $S0 = $P0.'get_subid'()
+    say $S0
+
+    $P0 = get_global 'baz'
+    $S0 = $P0.'get_subid'()
+    say $S0
+.end
+
+.sub '' :subid('foo')
+    say 'foo'
+.end
+
+.sub 'bar'
+    say 'bar'
+.end
+
+.sub 'baz' :subid('bazsubid')
+    say 'baz'
+.end
+CODE
+foo
+bar
+bazsubid
+OUTPUT
+
+
 # Local Variables:
 #   mode: cperl
 #   cperl-indent-level: 4


More information about the parrot-commits mailing list